albio
Advanced tools
Comparing version 1.0.10 to 1.0.11
58
index.js
@@ -9,13 +9,13 @@ 'use strict'; | ||
function set_data(text, data) { | ||
data = '' + data; | ||
if (text.wholeText !== data) text.data = data; | ||
data = '' + data; | ||
if (text.wholeText !== data) | ||
text.data = data; | ||
} | ||
function text(data) { | ||
return document.createTextNode(data); | ||
return document.createTextNode(data); | ||
} | ||
function check_dirty_deps(dirt, deps) { | ||
if (dirt === null) return false; | ||
return Object.keys(dirt).some((key) => deps.indexOf(key) > -1); | ||
if (dirt === null) | ||
return false; | ||
return Object.keys(dirt).some((key) => deps.indexOf(key) > -1); | ||
} | ||
@@ -26,35 +26,29 @@ | ||
const resolved_promise = Promise.resolve(); | ||
function scheduleUpdate(update) { | ||
workQueue.push(update); | ||
if (!update_scheduled) { | ||
update_scheduled = true; | ||
resolved_promise.then(flush); | ||
} | ||
workQueue.push(update); | ||
if (!update_scheduled) { | ||
update_scheduled = true; | ||
resolved_promise.then(flush); | ||
} | ||
} | ||
function flush() { | ||
while (workQueue.length > 0) { | ||
const work = workQueue.shift(); | ||
if (work) work(); | ||
} | ||
update_scheduled = false; | ||
while (workQueue.length > 0) { | ||
const work = workQueue.shift(); | ||
if (work) | ||
work(); | ||
} | ||
update_scheduled = false; | ||
} | ||
function $$invalidate(dirty, expression, update) { | ||
let dependencies = new Set(); | ||
periscopic.extract_names(fetch_object((expression ).left)).forEach((name) => | ||
dependencies.add(name), | ||
); | ||
[...dependencies].forEach((d) => (dirty[d] = true)); | ||
scheduleUpdate(update); | ||
return eval(codeRed.print(expression).code); | ||
let dependencies = new Set(); | ||
periscopic.extract_names(fetch_object(expression.left)).forEach((name) => dependencies.add(name)); | ||
[...dependencies].forEach((d) => (dirty[d] = true)); | ||
scheduleUpdate(update); | ||
return eval(codeRed.print(expression).code); | ||
} | ||
function fetch_object(node) { | ||
while (node.type === 'MemberExpression') node = node.object; | ||
return node ; | ||
while (node.type === 'MemberExpression') | ||
node = node.object; | ||
return node; | ||
} | ||
@@ -61,0 +55,0 @@ |
@@ -9,13 +9,13 @@ 'use strict'; | ||
function set_data(text, data) { | ||
data = '' + data; | ||
if (text.wholeText !== data) text.data = data; | ||
data = '' + data; | ||
if (text.wholeText !== data) | ||
text.data = data; | ||
} | ||
function text(data) { | ||
return document.createTextNode(data); | ||
return document.createTextNode(data); | ||
} | ||
function check_dirty_deps(dirt, deps) { | ||
if (dirt === null) return false; | ||
return Object.keys(dirt).some((key) => deps.indexOf(key) > -1); | ||
if (dirt === null) | ||
return false; | ||
return Object.keys(dirt).some((key) => deps.indexOf(key) > -1); | ||
} | ||
@@ -26,35 +26,29 @@ | ||
const resolved_promise = Promise.resolve(); | ||
function scheduleUpdate(update) { | ||
workQueue.push(update); | ||
if (!update_scheduled) { | ||
update_scheduled = true; | ||
resolved_promise.then(flush); | ||
} | ||
workQueue.push(update); | ||
if (!update_scheduled) { | ||
update_scheduled = true; | ||
resolved_promise.then(flush); | ||
} | ||
} | ||
function flush() { | ||
while (workQueue.length > 0) { | ||
const work = workQueue.shift(); | ||
if (work) work(); | ||
} | ||
update_scheduled = false; | ||
while (workQueue.length > 0) { | ||
const work = workQueue.shift(); | ||
if (work) | ||
work(); | ||
} | ||
update_scheduled = false; | ||
} | ||
function $$invalidate(dirty, expression, update) { | ||
let dependencies = new Set(); | ||
periscopic.extract_names(fetch_object((expression ).left)).forEach((name) => | ||
dependencies.add(name), | ||
); | ||
[...dependencies].forEach((d) => (dirty[d] = true)); | ||
scheduleUpdate(update); | ||
return eval(codeRed.print(expression).code); | ||
let dependencies = new Set(); | ||
periscopic.extract_names(fetch_object(expression.left)).forEach((name) => dependencies.add(name)); | ||
[...dependencies].forEach((d) => (dirty[d] = true)); | ||
scheduleUpdate(update); | ||
return eval(codeRed.print(expression).code); | ||
} | ||
function fetch_object(node) { | ||
while (node.type === 'MemberExpression') node = node.object; | ||
return node ; | ||
while (node.type === 'MemberExpression') | ||
node = node.object; | ||
return node; | ||
} | ||
@@ -61,0 +55,0 @@ |
{ | ||
"main": "./index", | ||
"module": "./index.mjs" | ||
"module": "./index.mjs", | ||
"types": "./index.d.ts" | ||
} |
{ | ||
"name": "albio", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "🚀 Tiny compiler-powered reactivity library for sensible web apps", | ||
@@ -38,3 +38,3 @@ "main": "index", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"build": "rimraf types && rollup -c", | ||
"dev": "rollup -cw", | ||
@@ -71,9 +71,9 @@ "test": "jest --silent --runInBand", | ||
"@rollup/plugin-typescript": "^10.0.1", | ||
"@swc-node/jest": "^1.5.2", | ||
"@swc/core": "^1.3.24", | ||
"@swc-node/jest": "^1.5.6", | ||
"@swc/core": "^1.3.25", | ||
"@types/estree": "0.0.50", | ||
"@types/jest": "^27.5.2", | ||
"@types/js-beautify": "^1.13.3", | ||
"@types/node": "^16.11.48", | ||
"acorn": "^8.8.0", | ||
"@types/node": "^16.18.11", | ||
"acorn": "^8.8.1", | ||
"esbuild": "^0.13.15", | ||
@@ -84,9 +84,10 @@ "estree-walker": "^3.0.2", | ||
"jsep": "^1.3.8", | ||
"parse5": "^7.0.0", | ||
"parse5": "^7.1.2", | ||
"parse5-htmlparser2-tree-adapter": "^7.0.0", | ||
"prettier": "^2.7.1", | ||
"rollup": "^2.78.0", | ||
"prettier": "^2.8.2", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.79.1", | ||
"ts-node": "^10.9.1", | ||
"tsc-alias": "^1.8.2", | ||
"typescript": "^4.7.4" | ||
"typescript": "^4.9.4" | ||
}, | ||
@@ -93,0 +94,0 @@ "dependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3874756
20
32993
28