Skip to content

Commit

Permalink
Merge branch 'gh-pages' of https://github.com/LivelyKernel/lively4-core
Browse files Browse the repository at this point in the history
… into gh-pages
  • Loading branch information
JensLincke committed Feb 7, 2024
2 parents c03257f + 95897ba commit 08157fb
Show file tree
Hide file tree
Showing 15 changed files with 273 additions and 44 deletions.
10 changes: 5 additions & 5 deletions demos/stefan/aexpr-diss-inter-tagger-reliability/auswertung.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ const results = results = await runEvaluation(this);
'results computed'
</script>

<span style='background-color: #fdd49e;'>change detection</span>
<span style='background-color: #a1d99b;'>reactive behavior</span>

### main
### main.js
<script>
renderPaths(results.pathsMain)
</script>

### setup
### setup.js
<script>
renderPaths(results.pathsSetup)
</script>

<span style='background-color: #fdd49e; border-radius:3px; padding: 3px;'>change detection</span>
<span style='background-color: #a1d99b; border-radius:3px; padding: 3px;'>reactive behavior</span>

### cohen's kappa
cohen's kappa for binary classification:
```javascript
Expand Down
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)
*/
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)"}
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());
}
}
};
}
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"}
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);
}
});
}
}
}
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)"}
11 changes: 6 additions & 5 deletions src/client/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import tinycolor from 'src/external/tinycolor.js';




export class Annotation {
constructor(config) {
this.from = 0, // starts here...
Expand Down Expand Up @@ -45,9 +44,11 @@ export class Annotation {
codeMirrorMark(cm) {
var color = this.color || "lightgray"

color = tinycolor(color)
color.setAlpha(0.4)

const isGradient = color && color.startsWith && color.startsWith('repeating-linear-gradient');
if (!isGradient) {
color = tinycolor(color)
color.setAlpha(0.4)
}

var fromPos = cm.posFromIndex(this.from)
var toPos = cm.posFromIndex(this.to)
Expand All @@ -58,7 +59,7 @@ export class Annotation {
attributes: {
"data-annotation": JSON.stringify(this)
},
css: `background-color: ${color.toString()}`});
css: `background: ${color.toString()}`});
return marker
}

Expand Down
4 changes: 4 additions & 0 deletions src/client/lively.js
Original file line number Diff line number Diff line change
Expand Up @@ -2101,6 +2101,10 @@ export default class Lively {
static async onBodyPositionPreference(pos) {
lively.setPosition(document.body, pos);
}

static async onDisableAExpWorkspacePreference(workspaceDisabled) {
localStorage.setItem("DisableAExpWorkspace", workspaceDisabled)
}

static async onEnableAEDebuggingPreference(debuggingEnabled) {
if (self.lively4isLoading) return // no recompile needed
Expand Down
2 changes: 1 addition & 1 deletion src/client/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class Preferences {
InteractiveLayer: {default: false, short: "dev methods"},
ShowDocumentGrid: {default: true, short: "show grid"},
UseRP19JSX: {default: false, short: "use rp19 implementation for jsx"},
/* DisableAExpWorkspace: {default: false, short: "disable AExp in workspace"}, */
DisableAExpWorkspace: {default: false, short: "disable AExp in workspace"},
UseProxiesForAExprs: {default: false, short: "proxy-based Active Expressions"},
EnableAEDebugging: {default: true, short: "enable Active Expression debugging"},
SmartAELogging: {default: true, short: "Only log events for interesting Active Expressions"},
Expand Down
2 changes: 2 additions & 0 deletions src/components/tools/lively-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,12 @@ export default class Editor extends Morph {
["(Auto) Resolve Merge Conglicts", () => this.autoResolveMergeConflicts()],
])
} else if (this.annotatedText) {
const stripedColor = '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)';
items.push(...[
[<b>Annotations</b>],
[<span>mark <span style='background-color: #fdd49e'>orange</span></span>, () => this.onAnnotationsMarkColor("#fdd49e")],
[<span>mark <span style='background-color: #a1d99b'>green</span></span>, () => this.onAnnotationsMarkColor("#a1d99b")],
[<span>mark <span style={'background: ' + stripedColor}>striped</span></span>, () => this.onAnnotationsMarkColor(stripedColor)],
[<span>mark <span style='background-color: #9ecae1'>blue</span></span>, () => this.onAnnotationsMarkColor("#9ecae1")],
["clear", () => this.onAnnotationsClear()],
["delete all anntations", () => this.onDeleteAllAnnotations()],
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/ubg-cards-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
#form-layout {
display: grid;
grid-template-columns: min-content auto 2.5in;
grid-template-rows: repeat(7, auto) 1fr auto auto .5fr auto;
grid-template-rows: repeat(7, auto) 1fr auto auto .33fr auto;
grid-template-areas:
"isPrinted-key isPrinted-value preview"
"id-key id-value preview"
Expand Down
Loading

0 comments on commit 08157fb

Please sign in to comment.