-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'gh-pages' of https://github.com/LivelyKernel/lively4-core…
… into gh-pages
- Loading branch information
Showing
15 changed files
with
273 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
demos/stefan/aexpr-diss-inter-tagger-reliability/combined/legend.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
both change detection | ||
both reactive behavior | ||
different (change detection for primary tagger, reactive behavior for second tagger) | ||
*/ |
4 changes: 4 additions & 0 deletions
4
demos/stefan/aexpr-diss-inter-tagger-reliability/combined/legend.js.l4a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{"type":"Reference","version":"7a3bb6b0486f99bdcc17d5acc9b73a62fa43d60b","content":"/*\n\n both change detection\n both reactive behavior\n different (change detection for primary tagger, reactive behavior for second tagger)\n\n\n*/"} | ||
{"from":4,"to":18,"name":"color","color":"#fdd49e"} | ||
{"from":41,"to":55,"name":"color","color":"#a1d99b"} | ||
{"from":79,"to":93,"name":"color","color":"repeating-linear-gradient(-45deg, rgba(253, 212, 158, 0.4), rgba(253, 212, 158, 0.4) 10px, rgba(161, 217, 155, 0.4) 10px, rgba(161, 217, 155, 0.4) 20px)"} |
74 changes: 74 additions & 0 deletions
74
demos/stefan/aexpr-diss-inter-tagger-reliability/combined/task-main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
export default function({ types: t, template, traverse, }) { | ||
|
||
|
||
/* Generic Signal Computation One Time per File */ | ||
var setup = template(` | ||
var aexprCallbacks = [], | ||
signals = [], | ||
solveSignals = false, | ||
resolveSignals = function() { | ||
if(!solveSignals) { | ||
solveSignals = true; | ||
signals.forEach(s => s()); | ||
solveSignals = false; | ||
let nonSignalCB; | ||
while(nonSignalCB = aexprCallbacks.pop()) { | ||
nonSignalCB(); | ||
} | ||
} | ||
}, | ||
newAExpr = function(axp) { | ||
return { | ||
onChange(cb) { | ||
axp.onChange(val => { | ||
if(solveSignals) { | ||
aexprCallbacks.push(() => cb(axp.getCurrentValue())); | ||
} else { | ||
return cb(val); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
`); | ||
|
||
/* Replace assignemnt with Signal */ | ||
var signal = template(`(aexpr(() => init).onChange(resolveSignals), signals.push(() => name = init), init)`); | ||
|
||
|
||
/* Find Assginemnts and Instrument Assigments */ | ||
return { | ||
visitor: { | ||
Program(program) { | ||
let aexprs = new Set(); | ||
program.traverse({ | ||
CallExpression(path) { | ||
let callee = path.get("callee"); | ||
if (callee.isIdentifier() && callee.node.name === 'aexpr') | ||
aexprs.add(path); | ||
} | ||
}); | ||
aexprs.forEach(path => path.replaceWith(template(`newAExpr(expr)`)({ expr: path.node }))); | ||
|
||
program.traverse({ | ||
Identifier(path) { | ||
if (!path.parentPath.isVariableDeclarator()) { return; } | ||
|
||
// const as substitute for 'signal' for now #TODO | ||
var declaration = path.parentPath.parentPath.node; | ||
if (declaration.kind !== 'const') { return; } | ||
declaration.kind = 'let'; | ||
|
||
var init = path.parentPath.get('init'); | ||
init.replaceWith(signal({ | ||
init: init, | ||
name: path.node | ||
}).expression); | ||
} | ||
}); | ||
|
||
program.unshiftContainer("body", setup()); | ||
} | ||
} | ||
}; | ||
} |
13 changes: 13 additions & 0 deletions
13
demos/stefan/aexpr-diss-inter-tagger-reliability/combined/task-main.js.l4a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{"type":"Reference","version":"4336710bba85b744fcec03d4879016a596e53750","content":"export default function({ types: t, template, traverse, }) {\n\n\n /* Generic Signal Computation One Time per File */\n var setup = template(`\nvar aexprCallbacks = [],\n signals = [],\n solveSignals = false,\n resolveSignals = function() {\n if(!solveSignals) {\n solveSignals = true;\n signals.forEach(s => s());\n solveSignals = false;\n let nonSignalCB;\n while(nonSignalCB = aexprCallbacks.pop()) {\n nonSignalCB();\n }\n}\n },\n newAExpr = function(axp) {\n return {\n onChange(cb) {\n axp.onChange(val => {\n if(solveSignals) {\n aexprCallbacks.push(() => cb(axp.getCurrentValue()));\n } else {\n return cb(val);\n }\n });\n }\n }\n }\n`);\n\n /* Replace assignemnt with Signal */\n var signal = template(`(aexpr(() => init).onChange(resolveSignals), signals.push(() => name = init), init)`);\n\n\n /* Find Assginemnts and Instrument Assigments */\n return {\n visitor: {\n Program(program) {\n let aexprs = new Set();\n program.traverse({\n CallExpression(path) {\n let callee = path.get(\"callee\");\n if (callee.isIdentifier() && callee.node.name === 'aexpr')\n aexprs.add(path);\n }\n });\n aexprs.forEach(path => path.replaceWith(template(`newAExpr(expr)`)({ expr: path.node })));\n\n program.traverse({\n Identifier(path) {\n if (!path.parentPath.isVariableDeclarator()) { return; }\n\n // const as substitute for 'signal' for now #TODO\n var declaration = path.parentPath.parentPath.node;\n if (declaration.kind !== 'const') { return; }\n declaration.kind = 'let';\n\n var init = path.parentPath.get('init');\n init.replaceWith(signal({\n init: init,\n name: path.node\n }).expression);\n }\n });\n\n program.unshiftContainer(\"body\", setup());\n }\n }\n };\n}\n"} | ||
{"from":0,"to":139,"name":"color","color":"#fdd49e"} | ||
{"from":139,"to":170,"name":"color","color":"#a1d99b"} | ||
{"from":183,"to":889,"name":"color","color":"#a1d99b"} | ||
{"from":889,"to":1002,"name":"color","color":"#fdd49e"} | ||
{"from":1002,"to":1033,"name":"color","color":"#a1d99b"} | ||
{"from":1035,"to":1156,"name":"color","color":"#fdd49e"} | ||
{"from":1156,"to":1510,"name":"color","color":"#a1d99b"} | ||
{"from":1510,"to":2067,"name":"color","color":"#fdd49e"} | ||
{"from":170,"to":183,"name":"color","color":"repeating-linear-gradient(-45deg, rgba(253, 212, 158, 0.4), rgba(253, 212, 158, 0.4) 10px, rgba(161, 217, 155, 0.4) 10px, rgba(161, 217, 155, 0.4) 20px)"} | ||
{"from":2109,"to":2131,"name":"color","color":"#fdd49e"} | ||
{"from":2067,"to":2109,"name":"color","color":"repeating-linear-gradient(-45deg, rgba(253, 212, 158, 0.4), rgba(253, 212, 158, 0.4) 10px, rgba(161, 217, 155, 0.4) 10px, rgba(161, 217, 155, 0.4) 20px)"} | ||
{"from":1033,"to":1035,"name":"color","color":"#fdd49e"} |
28 changes: 28 additions & 0 deletions
28
demos/stefan/aexpr-diss-inter-tagger-reliability/combined/task-setup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
var aexprCallbacks = [], | ||
signals = [], | ||
solveSignals = false, | ||
resolveSignals = function() { | ||
if(!solveSignals) { | ||
solveSignals = true; | ||
signals.forEach(s => s()); | ||
solveSignals = false; | ||
let nonSignalCB; | ||
while(nonSignalCB = aexprCallbacks.pop()) { | ||
nonSignalCB(); | ||
} | ||
} | ||
}, | ||
newAExpr = function(axp) { | ||
return { | ||
onChange(cb) { | ||
axp.onChange(val => { | ||
if(solveSignals) { | ||
aexprCallbacks.push(() => cb(axp.getCurrentValue())); | ||
} else { | ||
return cb(val); | ||
} | ||
}); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
demos/stefan/aexpr-diss-inter-tagger-reliability/combined/task-setup.js.l4a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{"type":"Reference","version":"145dfbcc92a2cec900d41835a4854f84b76810c9","content":"\nvar aexprCallbacks = [],\n signals = [],\n solveSignals = false,\n resolveSignals = function() {\n if(!solveSignals) {\n solveSignals = true;\n signals.forEach(s => s());\n solveSignals = false;\n let nonSignalCB;\n while(nonSignalCB = aexprCallbacks.pop()) {\n nonSignalCB();\n }\n }\n },\n newAExpr = function(axp) {\n return {\n onChange(cb) {\n axp.onChange(val => {\n if(solveSignals) {\n aexprCallbacks.push(() => cb(axp.getCurrentValue()));\n } else {\n return cb(val);\n }\n });\n }\n }\n }"} | ||
{"from":0,"to":30,"name":"color","color":"#a1d99b"} | ||
{"from":43,"to":755,"name":"color","color":"#a1d99b"} | ||
{"from":40,"to":40,"name":"color","color":"repeating-linear-gradient(-45deg, rgba(253, 212, 158, 0.4), rgba(253, 212, 158, 0.4) 10px, rgba(161, 217, 155, 0.4) 10px, rgba(161, 217, 155, 0.4) 20px)"} | ||
{"from":30,"to":43,"name":"color","color":"repeating-linear-gradient(-45deg, rgba(253, 212, 158, 0.4), rgba(253, 212, 158, 0.4) 10px, rgba(161, 217, 155, 0.4) 10px, rgba(161, 217, 155, 0.4) 20px)"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.