stillflow.engine 0.4.9 → 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 -168
- 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 -120
- 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
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { HTML_TAGS } from "./tags.js";
|
|
2
|
-
import { describe } from "./description/describe.js";
|
|
3
|
-
const DYNAMIC_PROPERTY_CONDITIONAL_MAP = 'conditional';
|
|
4
|
-
const DYNAMIC_PROPERTY_PREFIX = `sf:`;
|
|
5
|
-
const DYNAMIC_PROPERTY_SWITCH = `${DYNAMIC_PROPERTY_PREFIX}vm`;
|
|
6
|
-
const DYNAMIC_PROPERTY_CYCLES = [`${DYNAMIC_PROPERTY_PREFIX}for`, `${DYNAMIC_PROPERTY_PREFIX}each`];
|
|
7
|
-
const DYNAMIC_PROPERTY_CONDITIONAL = `${DYNAMIC_PROPERTY_PREFIX}if`;
|
|
8
|
-
const DELEGATE_EVENT_PROPERTY_PREFIX = `${DYNAMIC_PROPERTY_PREFIX}on-`;
|
|
9
|
-
const COMMON_EVENT_PROPERTY_PREFIX = `on:`;
|
|
10
|
-
const COMMON_STYLES_PROPERTY = 'styles';
|
|
11
|
-
class JSXDOMUtilities {
|
|
12
|
-
static patch(object, key, value) {
|
|
13
|
-
object[key] = value;
|
|
14
|
-
}
|
|
15
|
-
static outsort_children(all) {
|
|
16
|
-
const dynamic_content = new Array();
|
|
17
|
-
const static_content = new Array();
|
|
18
|
-
const children = new Array();
|
|
19
|
-
if (Array.isArray(all) == false) {
|
|
20
|
-
all = [all];
|
|
21
|
-
}
|
|
22
|
-
for (const child of all) {
|
|
23
|
-
if (typeof child === 'string' || typeof child === 'number') {
|
|
24
|
-
static_content.push(child.toString());
|
|
25
|
-
}
|
|
26
|
-
else if (typeof child === 'function') {
|
|
27
|
-
dynamic_content.push(child);
|
|
28
|
-
}
|
|
29
|
-
else if (typeof child === 'object') {
|
|
30
|
-
children.push(child);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
throw new Error(`JSX does not support typeof of ${typeof child} element`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return { static_content, dynamic_content, children };
|
|
37
|
-
}
|
|
38
|
-
static map_properties(jsx) {
|
|
39
|
-
const jsx_properties = jsx;
|
|
40
|
-
const dom_properties = {
|
|
41
|
-
styles: {},
|
|
42
|
-
modifiers: {},
|
|
43
|
-
properties: {},
|
|
44
|
-
events: {}
|
|
45
|
-
};
|
|
46
|
-
for (const property in jsx) {
|
|
47
|
-
if (property.startsWith(COMMON_EVENT_PROPERTY_PREFIX)) {
|
|
48
|
-
this.patch(dom_properties.events, property.slice(COMMON_EVENT_PROPERTY_PREFIX.length), jsx_properties[property]);
|
|
49
|
-
}
|
|
50
|
-
else if (property.startsWith(DELEGATE_EVENT_PROPERTY_PREFIX)) {
|
|
51
|
-
dom_properties.modifiers.events = dom_properties.modifiers.events || {};
|
|
52
|
-
this.patch(dom_properties.modifiers.events, property.slice(DELEGATE_EVENT_PROPERTY_PREFIX.length), jsx_properties[property]);
|
|
53
|
-
}
|
|
54
|
-
else if (property === DYNAMIC_PROPERTY_CONDITIONAL) {
|
|
55
|
-
this.patch(dom_properties.modifiers, DYNAMIC_PROPERTY_CONDITIONAL_MAP, jsx_properties[property]);
|
|
56
|
-
}
|
|
57
|
-
else if (DYNAMIC_PROPERTY_CYCLES.includes(property)) {
|
|
58
|
-
dom_properties.modifiers.iterate = {
|
|
59
|
-
select: jsx_properties[DYNAMIC_PROPERTY_CYCLES[0]],
|
|
60
|
-
each: jsx_properties[DYNAMIC_PROPERTY_CYCLES[1]]
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
else if (property === DYNAMIC_PROPERTY_SWITCH) {
|
|
64
|
-
this.patch(dom_properties.modifiers, DYNAMIC_PROPERTY_SWITCH.slice(DYNAMIC_PROPERTY_PREFIX.length), jsx_properties[property]);
|
|
65
|
-
}
|
|
66
|
-
else if (property.startsWith(DYNAMIC_PROPERTY_PREFIX)) {
|
|
67
|
-
dom_properties.modifiers.properties = dom_properties.modifiers.properties || {};
|
|
68
|
-
this.patch(dom_properties.modifiers.properties, property.slice(DYNAMIC_PROPERTY_PREFIX.length), jsx_properties[property]);
|
|
69
|
-
}
|
|
70
|
-
else if (property === COMMON_STYLES_PROPERTY) {
|
|
71
|
-
this.patch(dom_properties, property, jsx_properties[property]);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
this.patch(dom_properties.properties, property, jsx_properties[property]);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return dom_properties;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
export const JSXDOM_REGISTRY = Object.create(null);
|
|
81
|
-
for (const tag of HTML_TAGS) {
|
|
82
|
-
JSXDOM_REGISTRY[tag] = (context, all) => {
|
|
83
|
-
const { static_content, dynamic_content, children } = JSXDOMUtilities.outsort_children(all);
|
|
84
|
-
const properties = JSXDOMUtilities.map_properties(context);
|
|
85
|
-
properties.text = static_content.join(String());
|
|
86
|
-
if (dynamic_content.length > 0) {
|
|
87
|
-
properties.modifiers.text = (context) => {
|
|
88
|
-
let contents = String();
|
|
89
|
-
for (const site of dynamic_content) {
|
|
90
|
-
contents += site(context);
|
|
91
|
-
}
|
|
92
|
-
return contents;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
properties.name = tag;
|
|
96
|
-
return describe(properties, children);
|
|
97
|
-
};
|
|
98
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const HTML_TAGS: readonly ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", "mark", "menu", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "search", "section", "select", "slot", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr"];
|
|
2
|
-
export declare const SVG_TAGS: readonly ["a", "animate", "animateMotion", "animateTransform", "circle", "clipPath", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "foreignObject", "g", "image", "line", "linearGradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "script", "set", "stop", "style", "svg", "switch", "symbol", "text", "textPath", "title", "tspan", "use", "view"];
|
|
3
|
-
export declare const MATH_TAGS: readonly ["a", "annotation", "annotation-xml", "maction", "math", "merror", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"];
|
|
4
|
-
export type HTMLTag = typeof HTML_TAGS[number];
|
|
5
|
-
export type SVGTag = typeof SVG_TAGS[number];
|
|
6
|
-
export type MathTag = typeof MATH_TAGS[number];
|
|
7
|
-
export type Tag = HTMLTag | SVGTag | MathTag;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// AUTO-GENERATED by scripts/gen-tags.ts. Do not edit.
|
|
2
|
-
// Source: typescript/lib/lib.dom.d.ts
|
|
3
|
-
export const HTML_TAGS = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", "mark", "menu", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "search", "section", "select", "slot", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr"];
|
|
4
|
-
export const SVG_TAGS = ["a", "animate", "animateMotion", "animateTransform", "circle", "clipPath", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "foreignObject", "g", "image", "line", "linearGradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "script", "set", "stop", "style", "svg", "switch", "symbol", "text", "textPath", "title", "tspan", "use", "view"];
|
|
5
|
-
export const MATH_TAGS = ["a", "annotation", "annotation-xml", "maction", "math", "merror", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"];
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { run_dom_vm } from "./dom.compile-vm.js";
|
|
2
|
-
import { compile } from "./dom.compile.js";
|
|
3
|
-
export const apply = (node) => {
|
|
4
|
-
const compilation = compile(node);
|
|
5
|
-
const applier = run_dom_vm(compilation);
|
|
6
|
-
return {
|
|
7
|
-
root: compilation.root,
|
|
8
|
-
applier: (root, context) => applier(root, context),
|
|
9
|
-
};
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { run_dom_vm_keyed } from "./dom.compile-vm.keyed.js";
|
|
2
|
-
import { compile } from "./dom.compile.js";
|
|
3
|
-
export const apply_keyed = (node) => {
|
|
4
|
-
const compilation = compile(node);
|
|
5
|
-
const applier = run_dom_vm_keyed(compilation);
|
|
6
|
-
return {
|
|
7
|
-
root: compilation.root,
|
|
8
|
-
applier: (root, context) => applier(root, context),
|
|
9
|
-
};
|
|
10
|
-
};
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import * as vm from "../../../../stillflow-vm/index.js";
|
|
2
|
-
import { Pool } from "../utilities/dom.pool.js";
|
|
3
|
-
import { EventDelegator } from "../utilities/dom.delegator.js";
|
|
4
|
-
import { SF_ANY, SF_CACHE, SF_CACHE_TEXT, SF_CONTEXT, SF_HANDLERS, SF_LISTENED } from "../dom.symbols.js";
|
|
5
|
-
import { markup_template } from "./dom.markup.js";
|
|
6
|
-
const generators = {
|
|
7
|
-
[6 /* Codes.VM */](bytecode, offset, context) {
|
|
8
|
-
const anchor = bytecode[offset + 2];
|
|
9
|
-
const select = context.functions[bytecode[offset + 2]];
|
|
10
|
-
const node = context.nodes[bytecode[offset + 3]];
|
|
11
|
-
const selectIndex = context.payload.add_payload(select);
|
|
12
|
-
const nodeIndex = context.payload.add_payload(node);
|
|
13
|
-
const slotIndex = context.payload.add_payload({
|
|
14
|
-
active: undefined,
|
|
15
|
-
cache: new Map()
|
|
16
|
-
});
|
|
17
|
-
let code = String();
|
|
18
|
-
code += `{`;
|
|
19
|
-
code += `const compile = ${selectIndex}(context);`;
|
|
20
|
-
code += `if (${slotIndex}.active !== undefined) {`;
|
|
21
|
-
code += `${slotIndex}.active.root.remove();`;
|
|
22
|
-
code += `}`;
|
|
23
|
-
code += `let next = ${slotIndex}.cache.get(compile);`;
|
|
24
|
-
code += `if (next === undefined) {`;
|
|
25
|
-
code += `next = compile(${nodeIndex});`;
|
|
26
|
-
code += `${slotIndex}.cache.set(compile, next);`;
|
|
27
|
-
code += `}`;
|
|
28
|
-
code += `${slotIndex}.active = next;`;
|
|
29
|
-
code += `if (next !== undefined) {`;
|
|
30
|
-
code += `const anchor = sf_node_cache[${anchor}];`;
|
|
31
|
-
code += `anchor.parentNode.insertBefore(next.root, anchor);`;
|
|
32
|
-
code += `}`;
|
|
33
|
-
code += `if (${slotIndex}.active !== undefined) {`;
|
|
34
|
-
code += `${slotIndex}.active.applier(${slotIndex}.active.root, context);`;
|
|
35
|
-
code += `}`;
|
|
36
|
-
code += `}`;
|
|
37
|
-
return code;
|
|
38
|
-
},
|
|
39
|
-
[5 /* Codes.PROPERTY */](bytecode, offset, context) {
|
|
40
|
-
const container = bytecode[offset + 2];
|
|
41
|
-
const property = context.strings[bytecode[offset + 3]];
|
|
42
|
-
const handler = context.functions[bytecode[offset + 4]];
|
|
43
|
-
const propertyIndex = context.payload.add(property);
|
|
44
|
-
const handlerIndex = context.payload.add(handler);
|
|
45
|
-
const payload = context.payload.payload;
|
|
46
|
-
return `sf_node_cache[${container}][${payload(propertyIndex)}] = ${payload(handlerIndex)}(context);`;
|
|
47
|
-
},
|
|
48
|
-
[3 /* Codes.TEXT */](bytecode, offset, context) {
|
|
49
|
-
const container = bytecode[offset + 2];
|
|
50
|
-
const handler = context.functions[bytecode[offset + 3]];
|
|
51
|
-
const handlerIndex = context.payload.add(handler);
|
|
52
|
-
return `sf_text_cache[${container}].data = ${context.payload.payload(handlerIndex)}(context);`;
|
|
53
|
-
},
|
|
54
|
-
[4 /* Codes.EVENT */](bytecode, offset, context) {
|
|
55
|
-
const container = bytecode[offset + 2];
|
|
56
|
-
const event = context.strings[bytecode[offset + 3]];
|
|
57
|
-
const handler = context.functions[bytecode[offset + 4]];
|
|
58
|
-
const eventIndex = context.payload.add(event);
|
|
59
|
-
const handlerIndex = context.payload.add(handler);
|
|
60
|
-
const delegatorIndex = context.payload.add(context.delegator);
|
|
61
|
-
const payload = context.payload.payload;
|
|
62
|
-
let code = String();
|
|
63
|
-
code += `{`;
|
|
64
|
-
code += `const element = sf_node_cache[${container}];`;
|
|
65
|
-
code += `element.${SF_CONTEXT} = context;`;
|
|
66
|
-
code += `if (!element.${SF_LISTENED}) {`;
|
|
67
|
-
code += `element.${SF_LISTENED} = true;`;
|
|
68
|
-
code += `${payload(delegatorIndex)}.add(element, ${payload(eventIndex)}, ${payload(handlerIndex)});`;
|
|
69
|
-
code += `}`;
|
|
70
|
-
code += `}`;
|
|
71
|
-
return code;
|
|
72
|
-
},
|
|
73
|
-
[0 /* Codes.IF */](bytecode, offset, context) {
|
|
74
|
-
const container = bytecode[offset + 2];
|
|
75
|
-
const handler = context.functions[bytecode[offset + 3]];
|
|
76
|
-
const payload = context.payload.payload;
|
|
77
|
-
let code = String();
|
|
78
|
-
const handlerIndex = context.payload.add(handler);
|
|
79
|
-
code += `{`;
|
|
80
|
-
code += `const element = sf_node_cache[${container}];`;
|
|
81
|
-
code += `const condition = ${payload(handlerIndex)}(context);`;
|
|
82
|
-
code += `element.style.display = condition ? String() : 'none';`;
|
|
83
|
-
code += `}`;
|
|
84
|
-
return code;
|
|
85
|
-
},
|
|
86
|
-
[2 /* Codes.FOR */](bytecode, offset, context) {
|
|
87
|
-
const container = bytecode[offset + 2];
|
|
88
|
-
const select = context.functions[bytecode[offset + 3]];
|
|
89
|
-
const template = context.templates[bytecode[offset + 4]];
|
|
90
|
-
const item_applier = run_dom_vm(template);
|
|
91
|
-
item_applier(template.root, SF_ANY);
|
|
92
|
-
const selectIndex = context.payload.add_payload(select);
|
|
93
|
-
const applierIndex = context.payload.add_payload(item_applier);
|
|
94
|
-
const templateIndex = context.payload.add_payload(template.root);
|
|
95
|
-
const elementsIndex = context.payload.add_payload([]);
|
|
96
|
-
const poolIndex = context.payload.add_payload(new Pool());
|
|
97
|
-
let code = String();
|
|
98
|
-
code += `{`;
|
|
99
|
-
code += `const items = ${selectIndex}(context);`;
|
|
100
|
-
code += `const target = sf_node_cache[${container}];`;
|
|
101
|
-
code += `const { replaces, clears, addes, swaps, removes, updates } = items.flush();`;
|
|
102
|
-
code += `if (replaces) {`;
|
|
103
|
-
code += `const items_size = items.size;`;
|
|
104
|
-
code += `const children_size = ${elementsIndex}.length;`;
|
|
105
|
-
code += `const common_size = Math.min(items_size, children_size);`;
|
|
106
|
-
code += `for (let i = 0; i < common_size; i++) {`;
|
|
107
|
-
code += `${applierIndex}(${elementsIndex}[i], items.at(i));`;
|
|
108
|
-
code += `}`;
|
|
109
|
-
code += `if (items_size < children_size) {`;
|
|
110
|
-
code += `for (let i = items_size; i < children_size; i++) {`;
|
|
111
|
-
code += `const element = ${elementsIndex}[i];`;
|
|
112
|
-
code += `${poolIndex}.add(element);`;
|
|
113
|
-
code += `element.remove();`;
|
|
114
|
-
code += `}`;
|
|
115
|
-
code += `${elementsIndex}.length = items_size;`;
|
|
116
|
-
code += `}`;
|
|
117
|
-
code += `else if (children_size < items_size) {`;
|
|
118
|
-
code += `const fragment = document.createDocumentFragment();`;
|
|
119
|
-
code += `const elements = new Array(items_size - children_size);`;
|
|
120
|
-
code += `for (let i = children_size; i < items_size; i++) {`;
|
|
121
|
-
code += `const element = ${poolIndex}.get() || ${templateIndex}.cloneNode(true);`;
|
|
122
|
-
code += `element.${SF_HANDLERS} = ${templateIndex}.${SF_HANDLERS};`;
|
|
123
|
-
code += `element.${SF_CONTEXT} = items.at(i);`;
|
|
124
|
-
code += `${applierIndex}(element, items.at(i));`;
|
|
125
|
-
code += `elements[i - children_size] = element;`;
|
|
126
|
-
code += `fragment.appendChild(element);`;
|
|
127
|
-
code += `}`;
|
|
128
|
-
code += `${elementsIndex}.push(...elements);`;
|
|
129
|
-
code += `target.appendChild(fragment);`;
|
|
130
|
-
code += `}`;
|
|
131
|
-
code += `}`;
|
|
132
|
-
code += `else {`;
|
|
133
|
-
code += `if (clears) {`;
|
|
134
|
-
code += `const freelist = ${elementsIndex}.splice(0);`;
|
|
135
|
-
code += `for (const element of freelist) {`;
|
|
136
|
-
code += `element.${SF_HANDLERS} = undefined;`;
|
|
137
|
-
code += `${poolIndex}.add(element);`;
|
|
138
|
-
code += `}`;
|
|
139
|
-
code += `target.textContent = String();`;
|
|
140
|
-
code += `}`;
|
|
141
|
-
code += `if (addes > 0) {`;
|
|
142
|
-
code += `const fragment = document.createDocumentFragment();`;
|
|
143
|
-
code += `const elements = new Array(addes);`;
|
|
144
|
-
code += `const old_size = ${elementsIndex}.length;`;
|
|
145
|
-
code += `for (let i = 0; i < addes; i++) {`;
|
|
146
|
-
code += `const element = ${poolIndex}.get() || ${templateIndex}.cloneNode(true);`;
|
|
147
|
-
code += `element.${SF_HANDLERS} = ${templateIndex}.${SF_HANDLERS};`;
|
|
148
|
-
code += `element.${SF_CONTEXT} = items.at(i + old_size);`;
|
|
149
|
-
code += `${applierIndex}(element, items.at(i + old_size));`;
|
|
150
|
-
code += `elements[i] = element;`;
|
|
151
|
-
code += `fragment.appendChild(element);`;
|
|
152
|
-
code += `}`;
|
|
153
|
-
code += `${elementsIndex}.push(...elements);`;
|
|
154
|
-
code += `target.appendChild(fragment);`;
|
|
155
|
-
code += `}`;
|
|
156
|
-
code += `for (const [i, j] of swaps.entries()) {`;
|
|
157
|
-
code += `${applierIndex}(${elementsIndex}[i], items.at(i));`;
|
|
158
|
-
code += `${elementsIndex}[i].${SF_CONTEXT} = items.at(i);`;
|
|
159
|
-
code += `${applierIndex}(${elementsIndex}[j], items.at(j));`;
|
|
160
|
-
code += `${elementsIndex}[j].${SF_CONTEXT} = items.at(j);`;
|
|
161
|
-
code += `}`;
|
|
162
|
-
code += `for (const id of removes) {`;
|
|
163
|
-
code += `const element = ${elementsIndex}[id];`;
|
|
164
|
-
code += `element.${SF_HANDLERS} = undefined;`;
|
|
165
|
-
code += `${poolIndex}.add(element);`;
|
|
166
|
-
code += `element.remove();`;
|
|
167
|
-
code += `}`;
|
|
168
|
-
code += `for (const id of updates) {`;
|
|
169
|
-
code += `${applierIndex}(${elementsIndex}[id], items.at(id));`;
|
|
170
|
-
code += `}`;
|
|
171
|
-
code += `}`;
|
|
172
|
-
code += `${poolIndex}.tick();`;
|
|
173
|
-
code += `}`;
|
|
174
|
-
return code;
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
const DELEGATOR = new EventDelegator();
|
|
178
|
-
const create_context = (payload, input) => {
|
|
179
|
-
return {
|
|
180
|
-
node: input.node,
|
|
181
|
-
nodes: input.nodes,
|
|
182
|
-
payload,
|
|
183
|
-
strings: input.strings,
|
|
184
|
-
functions: input.functions,
|
|
185
|
-
templates: input.templates,
|
|
186
|
-
delegator: DELEGATOR
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
const dom_vm = vm.create({
|
|
190
|
-
generators,
|
|
191
|
-
preamble(context) {
|
|
192
|
-
let code = String();
|
|
193
|
-
const markupIndex = context.payload.add_payload(markup_template(context.node));
|
|
194
|
-
code += `return function(root, context) {`;
|
|
195
|
-
code += `${markupIndex}(root);`;
|
|
196
|
-
code += `const sf_node_cache = root.${SF_CACHE};`;
|
|
197
|
-
code += `const sf_text_cache = root.${SF_CACHE_TEXT};`;
|
|
198
|
-
return code;
|
|
199
|
-
},
|
|
200
|
-
epilogue() {
|
|
201
|
-
return `}`;
|
|
202
|
-
},
|
|
203
|
-
});
|
|
204
|
-
export const run_dom_vm = (template) => dom_vm(template.bytecode, template, create_context);
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import * as vm from "../../../../stillflow-vm/index.js";
|
|
2
|
-
import { EventDelegator } from "../utilities/dom.delegator.js";
|
|
3
|
-
import { SF_ANY, SF_CACHE, SF_CACHE_TEXT, SF_CONTEXT, SF_HANDLERS, SF_LISTENED } from "../dom.symbols.js";
|
|
4
|
-
import { markup_template } from "./dom.markup.js";
|
|
5
|
-
const generators = {
|
|
6
|
-
[6 /* Codes.VM */](bytecode, offset, context) {
|
|
7
|
-
const anchor = bytecode[offset + 2];
|
|
8
|
-
const select = context.functions[bytecode[offset + 2]];
|
|
9
|
-
const node = context.nodes[bytecode[offset + 3]];
|
|
10
|
-
const selectIndex = context.payload.add_payload(select);
|
|
11
|
-
const nodeIndex = context.payload.add_payload(node);
|
|
12
|
-
const slotIndex = context.payload.add_payload({
|
|
13
|
-
active: undefined,
|
|
14
|
-
cache: new Map()
|
|
15
|
-
});
|
|
16
|
-
let code = String();
|
|
17
|
-
code += `{`;
|
|
18
|
-
code += `const compile = ${selectIndex}(context);`;
|
|
19
|
-
code += `if (${slotIndex}.active !== undefined) {`;
|
|
20
|
-
code += `${slotIndex}.active.root.remove();`;
|
|
21
|
-
code += `}`;
|
|
22
|
-
code += `let next = ${slotIndex}.cache.get(compile);`;
|
|
23
|
-
code += `if (next === undefined) {`;
|
|
24
|
-
code += `next = compile(${nodeIndex});`;
|
|
25
|
-
code += `${slotIndex}.cache.set(compile, next);`;
|
|
26
|
-
code += `}`;
|
|
27
|
-
code += `${slotIndex}.active = next;`;
|
|
28
|
-
code += `if (next !== undefined) {`;
|
|
29
|
-
code += `const anchor = sf_node_cache[${anchor}];`;
|
|
30
|
-
code += `anchor.parentNode.insertBefore(next.root, anchor);`;
|
|
31
|
-
code += `}`;
|
|
32
|
-
code += `if (${slotIndex}.active !== undefined) {`;
|
|
33
|
-
code += `${slotIndex}.active.applier(${slotIndex}.active.root, context);`;
|
|
34
|
-
code += `}`;
|
|
35
|
-
code += `}`;
|
|
36
|
-
return code;
|
|
37
|
-
},
|
|
38
|
-
[5 /* Codes.PROPERTY */](bytecode, offset, context) {
|
|
39
|
-
const container = bytecode[offset + 2];
|
|
40
|
-
const property = context.strings[bytecode[offset + 3]];
|
|
41
|
-
const handler = context.functions[bytecode[offset + 4]];
|
|
42
|
-
const propertyIndex = context.payload.add(property);
|
|
43
|
-
const handlerIndex = context.payload.add(handler);
|
|
44
|
-
const payload = context.payload.payload;
|
|
45
|
-
return `sf_node_cache[${container}][${payload(propertyIndex)}] = ${payload(handlerIndex)}(context);`;
|
|
46
|
-
},
|
|
47
|
-
[3 /* Codes.TEXT */](bytecode, offset, context) {
|
|
48
|
-
const container = bytecode[offset + 2];
|
|
49
|
-
const handler = context.functions[bytecode[offset + 3]];
|
|
50
|
-
const handlerIndex = context.payload.add(handler);
|
|
51
|
-
return `sf_text_cache[${container}].data = ${context.payload.payload(handlerIndex)}(context);`;
|
|
52
|
-
},
|
|
53
|
-
[4 /* Codes.EVENT */](bytecode, offset, context) {
|
|
54
|
-
const container = bytecode[offset + 2];
|
|
55
|
-
const event = context.strings[bytecode[offset + 3]];
|
|
56
|
-
const handler = context.functions[bytecode[offset + 4]];
|
|
57
|
-
const eventIndex = context.payload.add(event);
|
|
58
|
-
const handlerIndex = context.payload.add(handler);
|
|
59
|
-
const delegatorIndex = context.payload.add(context.delegator);
|
|
60
|
-
const payload = context.payload.payload;
|
|
61
|
-
let code = String();
|
|
62
|
-
code += `{`;
|
|
63
|
-
code += `const element = sf_node_cache[${container}];`;
|
|
64
|
-
code += `element.${SF_CONTEXT} = context;`;
|
|
65
|
-
code += `if (!element.${SF_LISTENED}) {`;
|
|
66
|
-
code += `element.${SF_LISTENED} = true;`;
|
|
67
|
-
code += `${payload(delegatorIndex)}.add(element, ${payload(eventIndex)}, ${payload(handlerIndex)});`;
|
|
68
|
-
code += `}`;
|
|
69
|
-
code += `}`;
|
|
70
|
-
return code;
|
|
71
|
-
},
|
|
72
|
-
[0 /* Codes.IF */](bytecode, offset, context) {
|
|
73
|
-
const container = bytecode[offset + 2];
|
|
74
|
-
const handler = context.functions[bytecode[offset + 3]];
|
|
75
|
-
const payload = context.payload.payload;
|
|
76
|
-
let code = String();
|
|
77
|
-
const handlerIndex = context.payload.add(handler);
|
|
78
|
-
code += `{`;
|
|
79
|
-
code += `const element = sf_node_cache[${container}];`;
|
|
80
|
-
code += `const condition = ${payload(handlerIndex)}(context);`;
|
|
81
|
-
code += `element.style.display = condition ? String() : 'none';`;
|
|
82
|
-
code += `}`;
|
|
83
|
-
return code;
|
|
84
|
-
},
|
|
85
|
-
[2 /* Codes.FOR */](bytecode, offset, context) {
|
|
86
|
-
const container = bytecode[offset + 2];
|
|
87
|
-
const select = context.functions[bytecode[offset + 3]];
|
|
88
|
-
const template = context.templates[bytecode[offset + 4]];
|
|
89
|
-
const item_applier = run_dom_vm_keyed(template);
|
|
90
|
-
item_applier(template.root, SF_ANY);
|
|
91
|
-
const selectIndex = context.payload.add_payload(select);
|
|
92
|
-
const applierIndex = context.payload.add_payload(item_applier);
|
|
93
|
-
const templateIndex = context.payload.add_payload(template.root);
|
|
94
|
-
const elementsIndex = context.payload.add_payload([]);
|
|
95
|
-
let code = String();
|
|
96
|
-
code += `{`;
|
|
97
|
-
code += `const items = ${selectIndex}(context);`;
|
|
98
|
-
code += `const target = sf_node_cache[${container}];`;
|
|
99
|
-
code += `const { clears, addes, swaps, removes, updates } = items.flush();`;
|
|
100
|
-
code += `if (clears) {`;
|
|
101
|
-
code += `const freelist = ${elementsIndex}.splice(0);`;
|
|
102
|
-
code += `for (const element of freelist) {`;
|
|
103
|
-
code += `element.${SF_HANDLERS} = undefined;`;
|
|
104
|
-
code += `}`;
|
|
105
|
-
code += `target.textContent = String();`;
|
|
106
|
-
code += `}`;
|
|
107
|
-
code += `if (addes > 0) {`;
|
|
108
|
-
code += `const fragment = document.createDocumentFragment();`;
|
|
109
|
-
code += `const elements = new Array(addes);`;
|
|
110
|
-
code += `const old_size = ${elementsIndex}.length;`;
|
|
111
|
-
code += `for (let i = 0; i < addes; i++) {`;
|
|
112
|
-
code += `const element = ${templateIndex}.cloneNode(true);`;
|
|
113
|
-
code += `element.${SF_HANDLERS} = ${templateIndex}.${SF_HANDLERS};`;
|
|
114
|
-
code += `element.${SF_CONTEXT} = items.at(i + old_size);`;
|
|
115
|
-
code += `${applierIndex}(element, items.at(i + old_size));`;
|
|
116
|
-
code += `elements[i] = element;`;
|
|
117
|
-
code += `fragment.appendChild(element);`;
|
|
118
|
-
code += `}`;
|
|
119
|
-
code += `${elementsIndex}.push(...elements);`;
|
|
120
|
-
code += `target.appendChild(fragment);`;
|
|
121
|
-
code += `}`;
|
|
122
|
-
code += `for (const [i, j] of swaps.entries()) {`;
|
|
123
|
-
code += `target.insertBefore(${elementsIndex}[i], ${elementsIndex}[j + 1]);`;
|
|
124
|
-
code += `target.insertBefore(${elementsIndex}[j], ${elementsIndex}[i + 1]);`;
|
|
125
|
-
code += `const temporary = ${elementsIndex}[i];`;
|
|
126
|
-
code += `${elementsIndex}[i] = ${elementsIndex}[j];`;
|
|
127
|
-
code += `${elementsIndex}[j] = temporary;`;
|
|
128
|
-
code += `}`;
|
|
129
|
-
code += `for (const id of removes) {`;
|
|
130
|
-
code += `const element = ${elementsIndex}[id];`;
|
|
131
|
-
code += `element.${SF_HANDLERS} = undefined;`;
|
|
132
|
-
code += `element.remove();`;
|
|
133
|
-
code += `}`;
|
|
134
|
-
code += `for (const id of updates) {`;
|
|
135
|
-
code += `${applierIndex}(${elementsIndex}[id], items.at(id));`;
|
|
136
|
-
code += `}`;
|
|
137
|
-
code += `}`;
|
|
138
|
-
return code;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
const DELEGATOR = new EventDelegator();
|
|
142
|
-
const create_context = (payload, input) => {
|
|
143
|
-
return {
|
|
144
|
-
node: input.node,
|
|
145
|
-
nodes: input.nodes,
|
|
146
|
-
payload,
|
|
147
|
-
strings: input.strings,
|
|
148
|
-
functions: input.functions,
|
|
149
|
-
templates: input.templates,
|
|
150
|
-
delegator: DELEGATOR
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
const dom_vm = vm.create({
|
|
154
|
-
generators,
|
|
155
|
-
preamble(context) {
|
|
156
|
-
let code = String();
|
|
157
|
-
const markupIndex = context.payload.add_payload(markup_template(context.node));
|
|
158
|
-
code += `return function(root, context) {`;
|
|
159
|
-
code += `${markupIndex}(root);`;
|
|
160
|
-
code += `const sf_node_cache = root.${SF_CACHE};`;
|
|
161
|
-
code += `const sf_text_cache = root.${SF_CACHE_TEXT};`;
|
|
162
|
-
return code;
|
|
163
|
-
},
|
|
164
|
-
epilogue() {
|
|
165
|
-
return `}`;
|
|
166
|
-
},
|
|
167
|
-
});
|
|
168
|
-
export const run_dom_vm_keyed = (template) => dom_vm(template.bytecode, template, create_context);
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as vm from "../../../../stillflow-vm/index.js";
|
|
2
|
-
import { transform } from "../transform/dom.transform.js";
|
|
3
|
-
export function compile(node) {
|
|
4
|
-
const emitter = new vm.Emitter();
|
|
5
|
-
const strings = new vm.Payload();
|
|
6
|
-
const functions = new vm.Payload();
|
|
7
|
-
const templates = new vm.Payload();
|
|
8
|
-
const nodes = new vm.Payload();
|
|
9
|
-
let next_node_id = 0;
|
|
10
|
-
function walk(current) {
|
|
11
|
-
const modifiers = current.properties.modifiers;
|
|
12
|
-
const has_properties = modifiers?.properties !== undefined;
|
|
13
|
-
const has_events = modifiers?.events !== undefined;
|
|
14
|
-
const has_text = modifiers?.text !== undefined;
|
|
15
|
-
const has_for = modifiers?.iterate !== undefined;
|
|
16
|
-
const has_if = modifiers?.conditional !== undefined;
|
|
17
|
-
const has_vm = modifiers?.vm !== undefined;
|
|
18
|
-
let current_id = -1;
|
|
19
|
-
if (has_properties || has_events || has_text || has_for || has_if || has_vm) {
|
|
20
|
-
current_id = next_node_id++;
|
|
21
|
-
}
|
|
22
|
-
if (has_properties) {
|
|
23
|
-
const properties = modifiers.properties;
|
|
24
|
-
for (const key in properties) {
|
|
25
|
-
const propertyIndex = strings.add(key);
|
|
26
|
-
const functionIndex = functions.add(properties[key]);
|
|
27
|
-
emitter.emit(5 /* Codes.PROPERTY */, current_id, propertyIndex, functionIndex);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (has_events) {
|
|
31
|
-
const events = modifiers.events;
|
|
32
|
-
for (const name in events) {
|
|
33
|
-
const eventIndex = strings.add(name);
|
|
34
|
-
const functionIndex = functions.add(events[name]);
|
|
35
|
-
emitter.emit(4 /* Codes.EVENT */, current_id, eventIndex, functionIndex);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (has_text) {
|
|
39
|
-
const functionIndex = functions.add(modifiers.text);
|
|
40
|
-
emitter.emit(3 /* Codes.TEXT */, current_id, functionIndex);
|
|
41
|
-
}
|
|
42
|
-
if (has_if) {
|
|
43
|
-
const functionIndex = functions.add(modifiers.conditional);
|
|
44
|
-
emitter.emit(0 /* Codes.IF */, current_id, functionIndex);
|
|
45
|
-
}
|
|
46
|
-
if (has_vm) {
|
|
47
|
-
if (current.children.length > 1) {
|
|
48
|
-
throw new Error(`Too much children for "sf:vm". Expected 1, but got ${node.children.length}`);
|
|
49
|
-
}
|
|
50
|
-
const selectIndex = functions.add(modifiers.vm);
|
|
51
|
-
const nodeIndex = nodes.add(current.children[0]);
|
|
52
|
-
emitter.emit(6 /* Codes.VM */, current_id, selectIndex, nodeIndex);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (has_for) {
|
|
56
|
-
const iterate = modifiers.iterate;
|
|
57
|
-
const selectIndex = functions.add(iterate.select);
|
|
58
|
-
const subTemplate = compile(iterate.each());
|
|
59
|
-
const templateIndex = templates.add(subTemplate);
|
|
60
|
-
emitter.emit(2 /* Codes.FOR */, current_id, selectIndex, templateIndex);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
for (const child of current.children) {
|
|
64
|
-
walk(child);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
walk(node);
|
|
68
|
-
return {
|
|
69
|
-
node,
|
|
70
|
-
root: transform(node),
|
|
71
|
-
nodes: nodes.values,
|
|
72
|
-
strings: strings.values,
|
|
73
|
-
bytecode: emitter.finish(),
|
|
74
|
-
functions: functions.values,
|
|
75
|
-
templates: templates.values
|
|
76
|
-
};
|
|
77
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as vm from "../../../../stillflow-vm/index.js";
|
|
2
|
-
import { Template } from "../dom.template.js";
|
|
3
|
-
import { AnyDOM } from "../dom.types.js";
|
|
4
|
-
import { EventDelegator } from "../utilities/dom.delegator.js";
|
|
5
|
-
export type Context = {
|
|
6
|
-
node: AnyDOM<any>;
|
|
7
|
-
nodes: AnyDOM<any>[];
|
|
8
|
-
payload: vm.Payload;
|
|
9
|
-
strings: string[];
|
|
10
|
-
functions: Function[];
|
|
11
|
-
templates: Template[];
|
|
12
|
-
delegator: EventDelegator;
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|