stillflow.engine 0.4.8 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -30
- package/dist/index.cjs.js +566 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.es.js +557 -0
- package/dist/rolldown-runtime-BW-eSwOZ.cjs +42 -0
- package/dist/stillflow/abstracts/meta.d.ts +1 -1
- package/dist/stillflow/abstracts/view.d.ts +2 -2
- package/dist/stillflow/compiler/compile.d.ts +5 -5
- package/dist/stillflow/compiler/instantiate.d.ts +2 -2
- package/dist/stillflow/index.d.ts +2 -2
- package/dist/stillflow/kernel/buffer.d.ts +1 -1
- package/dist/stillflow/kernel/kernel.d.ts +2 -2
- package/dist/stillflow/operators.d.ts +1 -1
- package/dist/stillflow/state.d.ts +1 -1
- package/dist/stillflow/stillflow.d.ts +6 -6
- package/dist/stillflow/variable.d.ts +2 -2
- package/dist/stillflow-collection/fenwick.d.ts +1 -1
- package/dist/stillflow-collection/flushable.d.ts +2 -2
- package/dist/stillflow-collection/index.d.ts +3 -3
- package/dist/stillflow-collection/utilities/range-fenwick-tree.d.ts +1 -1
- package/dist/stillflow-vite/babel-vm/abstract/binding.d.ts +4 -0
- package/dist/stillflow-vite/babel-vm/abstract/configurator.d.ts +7 -0
- package/dist/stillflow-vite/babel-vm/abstract/generator.d.ts +2 -0
- package/dist/stillflow-vite/babel-vm/classes/payload.d.ts +23 -0
- package/dist/stillflow-vite/babel-vm/index.d.ts +7 -0
- package/dist/stillflow-vite/babel-vm/utilities/build.d.ts +6 -0
- package/dist/stillflow-vite/babel-vm/utilities/create.d.ts +11 -0
- package/dist/stillflow-vite/dom/build-vm/build.d.ts +4 -0
- package/dist/stillflow-vite/dom/build-vm/build.dom.d.ts +6 -0
- package/dist/stillflow-vite/dom/build-vm/compile.d.ts +8 -0
- package/dist/stillflow-vite/dom/build-vm/markup.d.ts +7 -0
- package/dist/stillflow-vite/dom/build-vm/run.d.ts +12 -0
- package/dist/stillflow-vite/dom/build-vm/template.d.ts +14 -0
- package/dist/stillflow-vite/dom/build-vm/transform.d.ts +10 -0
- package/dist/{stillflow-adapters/dom/vm/dom.codes.d.ts → stillflow-vite/dom/directives/codes.d.ts} +1 -2
- package/dist/stillflow-vite/dom/directives/generators.d.ts +3 -0
- package/dist/stillflow-vite/dom/environment.d.ts +21 -0
- package/dist/stillflow-vite/dom/helpers/collectors.d.ts +9 -0
- package/dist/stillflow-vite/dom/helpers/extractors.d.ts +11 -0
- package/dist/stillflow-vite/dom/helpers/getters.d.ts +7 -0
- package/dist/stillflow-vite/dom/helpers/replacers.d.ts +2 -0
- package/dist/stillflow-vite/dom/properties/directives.d.ts +16 -0
- package/dist/{stillflow-adapters → stillflow-vite}/dom/properties/properties.d.ts +4 -3
- package/dist/{stillflow-adapters/dom/vm/dom.types.d.ts → stillflow-vite/dom/properties/types.d.ts} +2 -2
- package/dist/{stillflow-adapters/dom/vm/utilities/dom.delegator.d.ts → stillflow-vite/dom/utilities/delegator.d.ts} +1 -0
- package/dist/stillflow-vite/dom.plugin.d.ts +2 -0
- package/dist/{stillflow-adapters/dom → stillflow-vite/runtime}/jsx.dom.d.ts +20 -14
- package/dist/vite.cjs.js +18348 -0
- package/dist/vite.es.js +18345 -0
- package/dist/vite.plugin.d.ts +2 -0
- package/package.json +41 -29
- package/dist/index.js +0 -6
- package/dist/jsx-runtime.d.ts +0 -3
- package/dist/jsx-runtime.js +0 -7
- package/dist/stillflow/abstracts/IR.js +0 -1
- package/dist/stillflow/abstracts/meta.js +0 -1
- package/dist/stillflow/abstracts/operators.js +0 -1
- package/dist/stillflow/abstracts/state.js +0 -1
- package/dist/stillflow/abstracts/view.js +0 -1
- package/dist/stillflow/compiler/compile.js +0 -84
- package/dist/stillflow/compiler/instantiate.js +0 -40
- package/dist/stillflow/factories/factories.js +0 -20
- package/dist/stillflow/index.js +0 -3
- package/dist/stillflow/kernel/buffer.js +0 -16
- package/dist/stillflow/kernel/kernel.js +0 -44
- package/dist/stillflow/kernel/signal.js +0 -12
- package/dist/stillflow/operators.js +0 -31
- package/dist/stillflow/state.js +0 -12
- package/dist/stillflow/stillflow.js +0 -59
- package/dist/stillflow/tools/batcher.js +0 -21
- package/dist/stillflow/variable.js +0 -24
- package/dist/stillflow-adapters/dom/base.dom.d.ts +0 -17
- package/dist/stillflow-adapters/dom/base.dom.js +0 -31
- package/dist/stillflow-adapters/dom/description/describe.d.ts +0 -3
- package/dist/stillflow-adapters/dom/description/describe.js +0 -6
- package/dist/stillflow-adapters/dom/jsx.dom.js +0 -98
- package/dist/stillflow-adapters/dom/properties/properties.js +0 -1
- package/dist/stillflow-adapters/dom/tags.d.ts +0 -7
- package/dist/stillflow-adapters/dom/tags.js +0 -5
- package/dist/stillflow-adapters/dom/vm/compile/dom.apply.d.ts +0 -3
- package/dist/stillflow-adapters/dom/vm/compile/dom.apply.js +0 -10
- package/dist/stillflow-adapters/dom/vm/compile/dom.apply.keyed.d.ts +0 -3
- package/dist/stillflow-adapters/dom/vm/compile/dom.apply.keyed.js +0 -10
- package/dist/stillflow-adapters/dom/vm/compile/dom.compile-vm.d.ts +0 -2
- package/dist/stillflow-adapters/dom/vm/compile/dom.compile-vm.js +0 -204
- package/dist/stillflow-adapters/dom/vm/compile/dom.compile-vm.keyed.d.ts +0 -2
- package/dist/stillflow-adapters/dom/vm/compile/dom.compile-vm.keyed.js +0 -167
- package/dist/stillflow-adapters/dom/vm/compile/dom.compile.d.ts +0 -3
- package/dist/stillflow-adapters/dom/vm/compile/dom.compile.js +0 -77
- package/dist/stillflow-adapters/dom/vm/compile/dom.context.d.ts +0 -13
- package/dist/stillflow-adapters/dom/vm/compile/dom.context.js +0 -1
- package/dist/stillflow-adapters/dom/vm/compile/dom.markup.d.ts +0 -3
- package/dist/stillflow-adapters/dom/vm/compile/dom.markup.js +0 -32
- package/dist/stillflow-adapters/dom/vm/dom.codes.js +0 -1
- package/dist/stillflow-adapters/dom/vm/dom.directives.d.ts +0 -18
- package/dist/stillflow-adapters/dom/vm/dom.directives.js +0 -1
- package/dist/stillflow-adapters/dom/vm/dom.symbols.js +0 -18
- package/dist/stillflow-adapters/dom/vm/dom.template.d.ts +0 -10
- package/dist/stillflow-adapters/dom/vm/dom.template.js +0 -1
- package/dist/stillflow-adapters/dom/vm/dom.types.js +0 -1
- package/dist/stillflow-adapters/dom/vm/transform/dom.transform.d.ts +0 -3
- package/dist/stillflow-adapters/dom/vm/transform/dom.transform.js +0 -54
- package/dist/stillflow-adapters/dom/vm/utilities/dom.delegator.js +0 -39
- package/dist/stillflow-adapters/dom/vm/utilities/dom.pool.js +0 -46
- package/dist/stillflow-adapters/index.d.ts +0 -2
- package/dist/stillflow-adapters/index.js +0 -2
- package/dist/stillflow-collection/abstract/collection.js +0 -1
- package/dist/stillflow-collection/delta.js +0 -18
- package/dist/stillflow-collection/fenwick.js +0 -102
- package/dist/stillflow-collection/flushable.js +0 -70
- package/dist/stillflow-collection/index.js +0 -2
- package/dist/stillflow-collection/utilities/disjointed-set.js +0 -45
- package/dist/stillflow-collection/utilities/fenwick-tree.js +0 -27
- package/dist/stillflow-collection/utilities/interval-merger.js +0 -70
- package/dist/stillflow-collection/utilities/range-fenwick-tree.js +0 -28
- package/dist/stillflow-examples/app.js +0 -123
- package/dist/stillflow-examples/data.js +0 -73
- package/dist/stillflow-examples/test.js +0 -32
- package/dist/stillflow-scripts/gen-tags.d.ts +0 -1
- package/dist/stillflow-scripts/gen-tags.js +0 -50
- package/dist/stillflow-vm/abstract/config.d.ts +0 -6
- package/dist/stillflow-vm/abstract/config.js +0 -1
- package/dist/stillflow-vm/abstract/generator.d.ts +0 -1
- package/dist/stillflow-vm/abstract/generator.js +0 -1
- package/dist/stillflow-vm/abstract/target.d.ts +0 -7
- package/dist/stillflow-vm/abstract/target.js +0 -1
- package/dist/stillflow-vm/binding.d.ts +0 -4
- package/dist/stillflow-vm/binding.js +0 -1
- package/dist/stillflow-vm/create.d.ts +0 -5
- package/dist/stillflow-vm/create.js +0 -17
- package/dist/stillflow-vm/emitter.js +0 -9
- package/dist/stillflow-vm/index.d.ts +0 -6
- package/dist/stillflow-vm/index.js +0 -3
- package/dist/stillflow-vm/payload.d.ts +0 -9
- package/dist/stillflow-vm/payload.js +0 -24
- /package/dist/{stillflow-vm → stillflow-vite/babel-vm/classes}/emitter.d.ts +0 -0
- /package/dist/{stillflow-adapters/dom/vm/utilities/dom.pool.d.ts → stillflow-vite/dom/utilities/pool.d.ts} +0 -0
- /package/dist/{stillflow-adapters/dom/vm/dom.symbols.d.ts → stillflow-vite/dom/utilities/symbols.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stillflow.engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A headless, transaction-based UI engine with AOT compilation.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.js",
|
|
6
|
+
"main": "./dist/index.es.js",
|
|
7
|
+
"module": "./dist/index.es.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
"./main": {
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
|
-
"import": "./dist/index.js"
|
|
18
|
-
},
|
|
19
|
-
"./adapters": {
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"import": "./dist/index.js"
|
|
12
|
+
"import": "./dist/index.es.js",
|
|
13
|
+
"require": "./dist/index.cjs.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
22
15
|
},
|
|
23
16
|
"./core": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
17
|
+
"import": "./dist/index.es.js",
|
|
18
|
+
"require": "./dist/index.cjs.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./runtime": {
|
|
22
|
+
"import": "./dist/index.es.js",
|
|
23
|
+
"require": "./dist/index.cjs.js",
|
|
24
|
+
"types": "./dist/index.d.ts"
|
|
26
25
|
},
|
|
27
|
-
"./
|
|
28
|
-
"
|
|
29
|
-
"
|
|
26
|
+
"./collections": {
|
|
27
|
+
"import": "./dist/index.es.js",
|
|
28
|
+
"require": "./dist/index.cjs.js",
|
|
29
|
+
"types": "./dist/index.d.ts"
|
|
30
30
|
},
|
|
31
|
-
"./
|
|
32
|
-
"
|
|
33
|
-
"
|
|
31
|
+
"./operators": {
|
|
32
|
+
"import": "./dist/index.es.js",
|
|
33
|
+
"require": "./dist/index.cjs.js",
|
|
34
|
+
"types": "./dist/index.d.ts"
|
|
34
35
|
},
|
|
35
|
-
"./
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"./vite": {
|
|
37
|
+
"import": "./dist/vite.es.js",
|
|
38
|
+
"require": "./dist/vite.cjs.js",
|
|
39
|
+
"types": "./dist/vite.plugin.d.ts"
|
|
38
40
|
}
|
|
39
41
|
},
|
|
40
42
|
"files": [
|
|
@@ -61,14 +63,24 @@
|
|
|
61
63
|
},
|
|
62
64
|
"homepage": "https://github.com/SampleUserD/Stillflow.Engine#readme",
|
|
63
65
|
"scripts": {
|
|
64
|
-
"build": "
|
|
65
|
-
"
|
|
66
|
+
"build": "npm run build:lib",
|
|
67
|
+
"build:lib": "vite build --mode lib",
|
|
68
|
+
"build:app": "vite build",
|
|
66
69
|
"prepublishOnly": "npm run build"
|
|
67
70
|
},
|
|
68
71
|
"devDependencies": {
|
|
72
|
+
"@babel/core": "^8.1.2",
|
|
73
|
+
"@types/babel__core": "^7.20.5",
|
|
69
74
|
"@types/node": "^26.6.6",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
75
|
+
"typescript": "^5.0.0",
|
|
76
|
+
"vite-plugin-dts": "^5.1.2"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"vite": "^8.3.8"
|
|
80
|
+
},
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"vite": {
|
|
83
|
+
"optional": true
|
|
84
|
+
}
|
|
73
85
|
}
|
|
74
86
|
}
|
package/dist/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as adapters from './stillflow-adapters/index.js';
|
|
2
|
-
import * as collection from './stillflow-collection/index.js';
|
|
3
|
-
import * as core from './stillflow/index.js';
|
|
4
|
-
import * as vm from './stillflow-vm/index.js';
|
|
5
|
-
import operators from './stillflow/operators.js';
|
|
6
|
-
export { operators, adapters, collection, core, vm };
|
package/dist/jsx-runtime.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { Binding } from "./stillflow-vm/binding.js";
|
|
2
|
-
export declare function jsx<T>(type: (properties: Record<string, any>, children: Binding<any>[]) => Binding<T>, properties: Record<string, any>): Binding<T>;
|
|
3
|
-
export declare function jsxs<T>(type: (properties: Record<string, any>, children: Binding<any>[]) => Binding<T>, properties: Record<string, any>): Binding<T>;
|
package/dist/jsx-runtime.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
function $CompileIR(source) {
|
|
2
|
-
const ir = {
|
|
3
|
-
refs: Object.create(null),
|
|
4
|
-
links: Object.create(null),
|
|
5
|
-
locals: Object.create(null),
|
|
6
|
-
backrefs: Object.create(null),
|
|
7
|
-
behaviors: Object.create(null)
|
|
8
|
-
};
|
|
9
|
-
for (const key in source) {
|
|
10
|
-
const operator = source[key];
|
|
11
|
-
switch (operator.type) {
|
|
12
|
-
case 'is':
|
|
13
|
-
ir.behaviors[key] = operator.factory;
|
|
14
|
-
break;
|
|
15
|
-
case 'ref':
|
|
16
|
-
ir.refs[key] = operator.path;
|
|
17
|
-
break;
|
|
18
|
-
case 'link':
|
|
19
|
-
ir.links[key] = operator.source;
|
|
20
|
-
break;
|
|
21
|
-
case 'local':
|
|
22
|
-
ir.locals[key] = operator.value;
|
|
23
|
-
break;
|
|
24
|
-
case 'backref':
|
|
25
|
-
ir.backrefs[key] = operator.path;
|
|
26
|
-
break;
|
|
27
|
-
default:
|
|
28
|
-
throw new Error(`Undefined operator '${operator}'`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return ir;
|
|
32
|
-
}
|
|
33
|
-
function $ProcessBackrefs(kernel, source, view) {
|
|
34
|
-
for (const key in source.backrefs) {
|
|
35
|
-
kernel.write(source.backrefs[key], view[key]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function $ProcessLocals(source, view) {
|
|
39
|
-
for (const key in source.locals) {
|
|
40
|
-
view[key] = source.locals[key];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function $ProcessLinks(kernel, source, view) {
|
|
44
|
-
for (const key in source.links) {
|
|
45
|
-
view[key] = view[key] || {};
|
|
46
|
-
$Process(kernel, source.links[key], view[key]);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function $ProcessRef(kernel, source, view) {
|
|
50
|
-
for (const key in source.refs) {
|
|
51
|
-
view[key] = kernel.read(source.refs[key]);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function $ProcessIs(source, view) {
|
|
55
|
-
for (const key in source.behaviors) {
|
|
56
|
-
view.meta.behaviors[key] = source.behaviors[key];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function $Process(kernel, source, view) {
|
|
60
|
-
view.meta = {
|
|
61
|
-
instantiated: false,
|
|
62
|
-
behaviors: Object.create(null),
|
|
63
|
-
source
|
|
64
|
-
};
|
|
65
|
-
$ProcessBackrefs(kernel, source, view);
|
|
66
|
-
$ProcessLocals(source, view);
|
|
67
|
-
$ProcessLinks(kernel, source, view);
|
|
68
|
-
$ProcessRef(kernel, source, view);
|
|
69
|
-
$ProcessIs(source, view);
|
|
70
|
-
}
|
|
71
|
-
export function $ProcessWrite(kernel, source, view) {
|
|
72
|
-
$ProcessBackrefs(kernel, source, view);
|
|
73
|
-
$ProcessLinks(kernel, source, view);
|
|
74
|
-
}
|
|
75
|
-
export function $ProcessRead(kernel, source, view) {
|
|
76
|
-
$ProcessRef(kernel, source, view);
|
|
77
|
-
$ProcessLinks(kernel, source, view);
|
|
78
|
-
}
|
|
79
|
-
export function $Compile(kernel, source) {
|
|
80
|
-
const view = Object.create(null);
|
|
81
|
-
const ir = $CompileIR(source);
|
|
82
|
-
$Process(kernel, ir, view);
|
|
83
|
-
return view;
|
|
84
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export function $Instantiate(view, factories) {
|
|
2
|
-
function copy(view) {
|
|
3
|
-
return {
|
|
4
|
-
...view,
|
|
5
|
-
meta: {
|
|
6
|
-
...view.meta,
|
|
7
|
-
behaviors: {
|
|
8
|
-
...view.meta.behaviors
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function deepcopy(view, cache) {
|
|
14
|
-
if (cache.has(view)) {
|
|
15
|
-
return cache.get(view);
|
|
16
|
-
}
|
|
17
|
-
const instance = copy(view);
|
|
18
|
-
cache.set(view, instance);
|
|
19
|
-
for (const key in view.meta.source.links) {
|
|
20
|
-
instance[key] = deepcopy(view[key], cache);
|
|
21
|
-
}
|
|
22
|
-
return instance;
|
|
23
|
-
}
|
|
24
|
-
function instantiate(view, seen) {
|
|
25
|
-
if (seen.has(view) || view.meta.instantiated) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
seen.add(view);
|
|
29
|
-
for (const key in view.meta.behaviors) {
|
|
30
|
-
view[key] = factories.get(view.meta.behaviors[key], view);
|
|
31
|
-
}
|
|
32
|
-
for (const key in view.meta.source.links) {
|
|
33
|
-
instantiate(view[key], seen);
|
|
34
|
-
}
|
|
35
|
-
view.meta.instantiated = true;
|
|
36
|
-
}
|
|
37
|
-
const instance = deepcopy(view, new WeakMap());
|
|
38
|
-
instantiate(instance, new Set());
|
|
39
|
-
return instance;
|
|
40
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export class Factories {
|
|
2
|
-
_parent;
|
|
3
|
-
_factories = new Map();
|
|
4
|
-
constructor(_parent = null) {
|
|
5
|
-
this._parent = _parent;
|
|
6
|
-
}
|
|
7
|
-
add(type, factory) {
|
|
8
|
-
this._factories.set(type, factory);
|
|
9
|
-
}
|
|
10
|
-
get(type, view) {
|
|
11
|
-
const factory = this._factories.get(type);
|
|
12
|
-
if (factory === undefined) {
|
|
13
|
-
return this._parent?.get(type, view);
|
|
14
|
-
}
|
|
15
|
-
return factory(view, this);
|
|
16
|
-
}
|
|
17
|
-
make() {
|
|
18
|
-
return new Factories(this);
|
|
19
|
-
}
|
|
20
|
-
}
|
package/dist/stillflow/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export class Buffer {
|
|
2
|
-
_messages = new Map();
|
|
3
|
-
constructor() { }
|
|
4
|
-
write(path, value) {
|
|
5
|
-
this._messages.set(path, value);
|
|
6
|
-
}
|
|
7
|
-
discard() {
|
|
8
|
-
this._messages.clear();
|
|
9
|
-
}
|
|
10
|
-
commit(state) {
|
|
11
|
-
for (const [path, value] of this._messages.entries()) {
|
|
12
|
-
state.write(path, value);
|
|
13
|
-
}
|
|
14
|
-
this._messages.clear();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Signal } from "./signal.js";
|
|
2
|
-
import { Buffer } from "./buffer.js";
|
|
3
|
-
export class Kernel {
|
|
4
|
-
_state;
|
|
5
|
-
_before = new Signal();
|
|
6
|
-
_after = new Signal();
|
|
7
|
-
_commiting = false;
|
|
8
|
-
_additional = new Buffer();
|
|
9
|
-
_buffers = new Set([this._additional]);
|
|
10
|
-
constructor(_state) {
|
|
11
|
-
this._state = _state;
|
|
12
|
-
}
|
|
13
|
-
bind(buffer) {
|
|
14
|
-
this._buffers.add(buffer);
|
|
15
|
-
return () => this._buffers.delete(buffer);
|
|
16
|
-
}
|
|
17
|
-
before(site) {
|
|
18
|
-
return this._before.subscribe(site);
|
|
19
|
-
}
|
|
20
|
-
after(site) {
|
|
21
|
-
return this._after.subscribe(site);
|
|
22
|
-
}
|
|
23
|
-
write(path, value) {
|
|
24
|
-
this._additional.write(path, value);
|
|
25
|
-
}
|
|
26
|
-
read(path) {
|
|
27
|
-
return this._state.read(path);
|
|
28
|
-
}
|
|
29
|
-
remove(path) {
|
|
30
|
-
this._state.remove(path);
|
|
31
|
-
}
|
|
32
|
-
commit() {
|
|
33
|
-
if (this._commiting) {
|
|
34
|
-
throw new Error(`Can not "kernel.commit()" within commit`);
|
|
35
|
-
}
|
|
36
|
-
this._commiting = true;
|
|
37
|
-
this._before.dispatch();
|
|
38
|
-
for (const buffer of this._buffers) {
|
|
39
|
-
buffer.commit(this._state);
|
|
40
|
-
}
|
|
41
|
-
this._after.dispatch();
|
|
42
|
-
this._commiting = false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export class Signal {
|
|
2
|
-
_subscribers = new Set();
|
|
3
|
-
subscribe(site) {
|
|
4
|
-
this._subscribers.add(site);
|
|
5
|
-
return () => this._subscribers.delete(site);
|
|
6
|
-
}
|
|
7
|
-
dispatch(payload) {
|
|
8
|
-
for (const subscriber of this._subscribers) {
|
|
9
|
-
subscriber(payload);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
function ref(path) {
|
|
2
|
-
return {
|
|
3
|
-
type: 'ref',
|
|
4
|
-
path
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
function backref(path) {
|
|
8
|
-
return {
|
|
9
|
-
type: 'backref',
|
|
10
|
-
path
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function local(value) {
|
|
14
|
-
return {
|
|
15
|
-
type: 'local',
|
|
16
|
-
value
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function link(source) {
|
|
20
|
-
return {
|
|
21
|
-
type: 'link',
|
|
22
|
-
source
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function is(factory) {
|
|
26
|
-
return {
|
|
27
|
-
type: 'is',
|
|
28
|
-
factory
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export default { ref, backref, link, local, is };
|
package/dist/stillflow/state.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { $Compile, $ProcessRead, $ProcessWrite } from "./compiler/compile.js";
|
|
2
|
-
import { $Instantiate } from "./compiler/instantiate.js";
|
|
3
|
-
import { Factories } from "./factories/factories.js";
|
|
4
|
-
import { Buffer } from "./kernel/buffer.js";
|
|
5
|
-
import { Kernel } from "./kernel/kernel.js";
|
|
6
|
-
import { Variable } from "./variable.js";
|
|
7
|
-
import { Batcher } from "./tools/batcher.js";
|
|
8
|
-
export class Stillflow {
|
|
9
|
-
_state;
|
|
10
|
-
_options;
|
|
11
|
-
_views = new Set();
|
|
12
|
-
_kernel;
|
|
13
|
-
_batcher;
|
|
14
|
-
constructor(_state, _options = { strategy: (site) => site() }) {
|
|
15
|
-
this._state = _state;
|
|
16
|
-
this._options = _options;
|
|
17
|
-
this._kernel = new Kernel(this._state);
|
|
18
|
-
this._batcher = new Batcher(this._options.strategy);
|
|
19
|
-
this._kernel.before(() => {
|
|
20
|
-
for (const view of [...this._views]) {
|
|
21
|
-
$ProcessWrite(this._kernel, view.meta.source, view);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
this._kernel.after(() => {
|
|
25
|
-
for (const view of [...this._views]) {
|
|
26
|
-
$ProcessRead(this._kernel, view.meta.source, view);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
on(site) {
|
|
31
|
-
return this._kernel.after(site);
|
|
32
|
-
}
|
|
33
|
-
factory() {
|
|
34
|
-
return new Factories();
|
|
35
|
-
}
|
|
36
|
-
buffer() {
|
|
37
|
-
return new Buffer();
|
|
38
|
-
}
|
|
39
|
-
bind(buffer) {
|
|
40
|
-
this._kernel.bind(buffer);
|
|
41
|
-
}
|
|
42
|
-
compile(source) {
|
|
43
|
-
const view = $Compile(this._kernel, source);
|
|
44
|
-
this._views.add(view);
|
|
45
|
-
return view;
|
|
46
|
-
}
|
|
47
|
-
instantiate(source, factory) {
|
|
48
|
-
const view = $Instantiate(source, factory);
|
|
49
|
-
this._views.delete(source);
|
|
50
|
-
this._views.add(view);
|
|
51
|
-
return view;
|
|
52
|
-
}
|
|
53
|
-
commit() {
|
|
54
|
-
this._batcher.task(() => this._kernel.commit());
|
|
55
|
-
}
|
|
56
|
-
variable(path) {
|
|
57
|
-
return new Variable(this._kernel, path);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export class Batcher {
|
|
2
|
-
_strategy;
|
|
3
|
-
_commiting = false;
|
|
4
|
-
_tasks = new Set();
|
|
5
|
-
constructor(_strategy) {
|
|
6
|
-
this._strategy = _strategy;
|
|
7
|
-
}
|
|
8
|
-
task(task) {
|
|
9
|
-
this._tasks.add(task);
|
|
10
|
-
if (this._commiting) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
this._commiting = true;
|
|
14
|
-
this._strategy(() => {
|
|
15
|
-
for (const task of this._tasks) {
|
|
16
|
-
task();
|
|
17
|
-
}
|
|
18
|
-
this._commiting = false;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import operators from "./operators.js";
|
|
2
|
-
export class Variable {
|
|
3
|
-
_kernel;
|
|
4
|
-
_key;
|
|
5
|
-
constructor(_kernel, _key) {
|
|
6
|
-
this._kernel = _kernel;
|
|
7
|
-
this._key = _key;
|
|
8
|
-
}
|
|
9
|
-
write(value) {
|
|
10
|
-
this._kernel.write(this._key, value);
|
|
11
|
-
}
|
|
12
|
-
read() {
|
|
13
|
-
return this._kernel.read(this._key);
|
|
14
|
-
}
|
|
15
|
-
remove() {
|
|
16
|
-
this._kernel.remove(this._key);
|
|
17
|
-
}
|
|
18
|
-
ref() {
|
|
19
|
-
return operators.ref(this._key);
|
|
20
|
-
}
|
|
21
|
-
backref() {
|
|
22
|
-
return operators.backref(this._key);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as vm from '../../stillflow-vm/index.js';
|
|
2
|
-
import { AnyDOM } from "./vm/dom.types.js";
|
|
3
|
-
import { Properties } from "./properties/properties.js";
|
|
4
|
-
import { Binding } from "../../stillflow-vm/binding.js";
|
|
5
|
-
type PropertiesWithoutServices<V, K extends keyof HTMLElementTagNameMap> = Omit<Properties<V, K>, 'name'>;
|
|
6
|
-
type Options = {
|
|
7
|
-
mode?: 'keyed' | 'non-keyed';
|
|
8
|
-
container: HTMLElement;
|
|
9
|
-
};
|
|
10
|
-
export type DOMRegistry = {
|
|
11
|
-
[K in keyof HTMLElementTagNameMap]: <V>(properties: Partial<PropertiesWithoutServices<V, K>>, children?: Binding<any>[]) => AnyDOM<V>;
|
|
12
|
-
} & {
|
|
13
|
-
$: <V>(root: AnyDOM<V>, options?: Options) => (context: V) => void;
|
|
14
|
-
$compile: vm.Compiler<Properties<any, any>, HTMLElement>;
|
|
15
|
-
};
|
|
16
|
-
export declare const DOM_REGISTRY: DOMRegistry;
|
|
17
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { HTML_TAGS } from "./tags.js";
|
|
2
|
-
import { describe } from "./description/describe.js";
|
|
3
|
-
import { apply } from "./vm/compile/dom.apply.js";
|
|
4
|
-
import { apply_keyed } from './vm/compile/dom.apply.keyed.js';
|
|
5
|
-
const DEFAULT_OPTIONS = {
|
|
6
|
-
mode: undefined,
|
|
7
|
-
container: document.body
|
|
8
|
-
};
|
|
9
|
-
export const DOM_REGISTRY = Object.create(null);
|
|
10
|
-
DOM_REGISTRY.$ = function $(root, options = DEFAULT_OPTIONS) {
|
|
11
|
-
let runner;
|
|
12
|
-
switch (options.mode) {
|
|
13
|
-
case 'keyed':
|
|
14
|
-
runner = apply_keyed(root);
|
|
15
|
-
break;
|
|
16
|
-
case 'non-keyed':
|
|
17
|
-
default:
|
|
18
|
-
runner = apply(root);
|
|
19
|
-
}
|
|
20
|
-
const update = (context) => runner.applier(runner.root, context);
|
|
21
|
-
options.container.appendChild(runner.root);
|
|
22
|
-
return update;
|
|
23
|
-
};
|
|
24
|
-
DOM_REGISTRY.$compile = function $compile(node) {
|
|
25
|
-
return apply(node);
|
|
26
|
-
};
|
|
27
|
-
for (const tag of HTML_TAGS) {
|
|
28
|
-
DOM_REGISTRY[tag] = (properties, children = []) => {
|
|
29
|
-
return describe({ ...properties, name: tag }, children);
|
|
30
|
-
};
|
|
31
|
-
}
|