stillflow.engine 0.3.1 → 0.4.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.
Files changed (37) hide show
  1. package/dist/index.d.ts +2 -4
  2. package/dist/index.js +2 -4
  3. package/dist/stillflow/index.d.ts +5 -0
  4. package/dist/stillflow/index.js +3 -0
  5. package/dist/stillflow-adapters/dom/base.dom.d.ts +3 -1
  6. package/dist/stillflow-adapters/dom/base.dom.js +4 -1
  7. package/dist/stillflow-adapters/dom/jsx.dom.d.ts +3 -1
  8. package/dist/stillflow-adapters/dom/jsx.dom.js +4 -0
  9. package/dist/stillflow-adapters/dom/symbols.d.ts +1 -0
  10. package/dist/stillflow-adapters/dom/vm/compile/dom.apply.d.ts +3 -5
  11. package/dist/stillflow-adapters/dom/vm/compile/dom.apply.js +4 -3
  12. package/dist/stillflow-adapters/dom/vm/compile/dom.compile-vm.js +34 -1
  13. package/dist/stillflow-adapters/dom/vm/compile/dom.compile.d.ts +1 -1
  14. package/dist/stillflow-adapters/dom/vm/compile/dom.compile.js +14 -2
  15. package/dist/stillflow-adapters/dom/vm/compile/dom.context.d.ts +2 -1
  16. package/dist/stillflow-adapters/dom/vm/dom.codes.d.ts +1 -0
  17. package/dist/stillflow-adapters/dom/vm/dom.directives.d.ts +3 -1
  18. package/dist/stillflow-adapters/dom/vm/dom.template.d.ts +1 -0
  19. package/dist/stillflow-adapters/dom/vm/dom.types.d.ts +1 -1
  20. package/dist/stillflow-adapters/index.d.ts +0 -1
  21. package/dist/stillflow-adapters/index.js +0 -1
  22. package/dist/stillflow-adapters/vm.d.ts +3 -0
  23. package/dist/stillflow-adapters/vm.js +2 -0
  24. package/dist/stillflow-examples/app.js +39 -29
  25. package/dist/stillflow-examples/test.js +8 -7
  26. package/dist/stillflow-vm/abstract/target.d.ts +7 -0
  27. package/dist/stillflow-vm/abstract/target.js +1 -0
  28. package/dist/stillflow-vm/binding.js +1 -0
  29. package/dist/stillflow-vm/index.d.ts +2 -0
  30. package/dist/stillflow-vm/index.js +1 -0
  31. package/package.json +19 -1
  32. package/dist/stillflow-adapters/dom/vm/utilities/dom.symbols.d.ts +0 -5
  33. package/dist/stillflow-adapters/dom/vm/utilities/dom.symbols.js +0 -5
  34. /package/dist/stillflow-adapters/{binding.js → dom/symbols.js} +0 -0
  35. /package/dist/{stillflow-adapters → stillflow-vm}/binding.d.ts +0 -0
  36. /package/dist/{stillflow-adapters → stillflow-vm}/runtime/jsx.runtime.d.ts +0 -0
  37. /package/dist/{stillflow-adapters → stillflow-vm}/runtime/jsx.runtime.js +0 -0
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import * as adapters from './stillflow-adapters/index.js';
2
2
  import * as collection from './stillflow-collection/index.js';
3
+ import * as core from './stillflow/index.js';
3
4
  import * as vm from './stillflow-vm/index.js';
4
5
  import operators from './stillflow/operators.js';
5
- export { Stillflow } from './stillflow/stillflow.js';
6
- export { State } from './stillflow/state.js';
7
- export { Batcher } from './stillflow/tools/batcher.js';
8
- export { operators, adapters, collection, vm };
6
+ export { operators, adapters, collection, core, vm };
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import * as adapters from './stillflow-adapters/index.js';
2
2
  import * as collection from './stillflow-collection/index.js';
3
+ import * as core from './stillflow/index.js';
3
4
  import * as vm from './stillflow-vm/index.js';
4
5
  import operators from './stillflow/operators.js';
5
- export { Stillflow } from './stillflow/stillflow.js';
6
- export { State } from './stillflow/state.js';
7
- export { Batcher } from './stillflow/tools/batcher.js';
8
- export { operators, adapters, collection, vm };
6
+ export { operators, adapters, collection, core, vm };
@@ -0,0 +1,5 @@
1
+ export { State } from './state.js';
2
+ export { AbstractState as Abstract } from './abstracts/state.js';
3
+ export { Stillflow } from './stillflow.js';
4
+ export { Batcher } from './tools/batcher.js';
5
+ export { type Buffer } from './kernel/buffer.js';
@@ -0,0 +1,3 @@
1
+ export { State } from './state.js';
2
+ export { Stillflow } from './stillflow.js';
3
+ export { Batcher } from './tools/batcher.js';
@@ -1,6 +1,7 @@
1
+ import * as vm from '../../stillflow-vm/index.js';
1
2
  import { AnyDOM } from "./vm/dom.types.js";
2
3
  import { Properties } from "./properties/properties.js";
3
- import { Binding } from "../binding.js";
4
+ import { Binding } from "../../stillflow-vm/binding.js";
4
5
  type PropertiesWithoutServices<V, K extends keyof HTMLElementTagNameMap> = Omit<Properties<V, K>, 'name'>;
5
6
  type Options = {
6
7
  container: HTMLElement;
@@ -9,6 +10,7 @@ export type DOMRegistry = {
9
10
  [K in keyof HTMLElementTagNameMap]: <V>(properties: Partial<PropertiesWithoutServices<V, K>>, children?: Binding<any>[]) => AnyDOM<V>;
10
11
  } & {
11
12
  $: <V>(root: AnyDOM<V>, options?: Options) => (context: V) => void;
13
+ $compile: vm.Compiler<Properties<any, any>, HTMLElement>;
12
14
  };
13
15
  export declare const DOM_REGISTRY: DOMRegistry;
14
16
  export {};
@@ -7,10 +7,13 @@ const DEFAULT_OPTIONS = {
7
7
  export const DOM_REGISTRY = Object.create(null);
8
8
  DOM_REGISTRY.$ = function $(root, options = DEFAULT_OPTIONS) {
9
9
  const runner = apply(root);
10
- const update = (context) => runner.run(context);
10
+ const update = (context) => runner.applier(runner.root, context);
11
11
  options.container.appendChild(runner.root);
12
12
  return update;
13
13
  };
14
+ DOM_REGISTRY.$compile = function $compile(node) {
15
+ return apply(node);
16
+ };
14
17
  for (const tag of HTML_TAGS) {
15
18
  DOM_REGISTRY[tag] = (properties, children = []) => {
16
19
  return describe({ ...properties, name: tag }, children);
@@ -1,5 +1,6 @@
1
+ import * as vm from '../../stillflow-vm/index.js';
1
2
  import { AnyDOM } from "./vm/dom.types.js";
2
- import { collection } from "../../index.js";
3
+ import * as collection from "../../stillflow-collection/index.js";
3
4
  declare const DYNAMIC_PROPERTY_PREFIX = "sf:";
4
5
  declare const DELEGATE_EVENT_PROPERTY_PREFIX = "sf:on-";
5
6
  declare const COMMON_EVENT_PROPERTY_PREFIX = "on:";
@@ -8,6 +9,7 @@ type ElementStyles<K extends keyof HTMLElementTagNameMap> = {
8
9
  };
9
10
  type ElementPropertiesWithoutStyles<K extends keyof HTMLElementTagNameMap> = Omit<HTMLElementTagNameMap[K], 'style'>;
10
11
  type ElementServicePropertiesWithoutPrefix<V> = {
12
+ 'vm': (context: V) => (node: AnyDOM<V>) => vm.Target<HTMLElement, V>;
11
13
  'if': (context: V) => boolean;
12
14
  'for': (context: V) => collection.Flushable<unknown>;
13
15
  'each': () => AnyDOM<V>;
@@ -2,6 +2,7 @@ import { HTML_TAGS } from "./tags.js";
2
2
  import { describe } from "./description/describe.js";
3
3
  const DYNAMIC_PROPERTY_CONDITIONAL_MAP = 'conditional';
4
4
  const DYNAMIC_PROPERTY_PREFIX = `sf:`;
5
+ const DYNAMIC_PROPERTY_SWITCH = `${DYNAMIC_PROPERTY_PREFIX}vm`;
5
6
  const DYNAMIC_PROPERTY_CYCLES = [`${DYNAMIC_PROPERTY_PREFIX}for`, `${DYNAMIC_PROPERTY_PREFIX}each`];
6
7
  const DYNAMIC_PROPERTY_CONDITIONAL = `${DYNAMIC_PROPERTY_PREFIX}if`;
7
8
  const DELEGATE_EVENT_PROPERTY_PREFIX = `${DYNAMIC_PROPERTY_PREFIX}on-`;
@@ -56,6 +57,9 @@ class JSXDOMUtilities {
56
57
  each: jsx_properties[DYNAMIC_PROPERTY_CYCLES[1]]
57
58
  };
58
59
  }
60
+ else if (property === DYNAMIC_PROPERTY_SWITCH) {
61
+ this.patch(dom_properties.modifiers, DYNAMIC_PROPERTY_SWITCH.slice(DYNAMIC_PROPERTY_PREFIX.length), jsx_properties[property]);
62
+ }
59
63
  else if (property.startsWith(DYNAMIC_PROPERTY_PREFIX)) {
60
64
  dom_properties.modifiers.properties = dom_properties.modifiers.properties || {};
61
65
  this.patch(dom_properties.modifiers.properties, property.slice(DYNAMIC_PROPERTY_PREFIX.length), jsx_properties[property]);
@@ -0,0 +1 @@
1
+ export type Adapters = 'webgl' | 'canvas' | 'dom';
@@ -1,5 +1,3 @@
1
- import { AnyDOM } from "../dom.types.js";
2
- export declare function apply<V>(node: AnyDOM<V>): {
3
- root: HTMLElement;
4
- run: (context: V) => any;
5
- };
1
+ import * as vm from '../../../../stillflow-vm/index.js';
2
+ import { Properties } from '../../properties/properties.js';
3
+ export declare const apply: vm.Compiler<Properties<any, any>, HTMLElement>;
@@ -1,10 +1,11 @@
1
1
  import { run_dom_vm } from "./dom.compile-vm.js";
2
2
  import { compile } from "./dom.compile.js";
3
- export function apply(node) {
3
+ export const apply = (node) => {
4
4
  const compilation = compile(node);
5
5
  const applier = run_dom_vm(compilation);
6
6
  return {
7
7
  root: compilation.root,
8
- run: (context) => applier(compilation.root, context)
8
+ applier: (root, context) => applier(root, context),
9
+ dispose: (root) => root.remove()
9
10
  };
10
- }
11
+ };
@@ -1,9 +1,41 @@
1
- import { vm } from "../../../../index.js";
1
+ import * as vm from "../../../../stillflow-vm/index.js";
2
2
  import { Pool } from "../utilities/dom.pool.js";
3
3
  import { EventDelegator } from "../utilities/dom.delegator.js";
4
4
  import { SF_ANY, SF_CACHE, SF_CACHE_TEXT, SF_CONTEXT, SF_HANDLERS, SF_LISTENED } from "../dom.symbols.js";
5
5
  import { markup_template } from "./dom.markup.js";
6
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
+ },
7
39
  [5 /* Codes.PROPERTY */](bytecode, offset, context) {
8
40
  const container = bytecode[offset + 2];
9
41
  const property = context.strings[bytecode[offset + 3]];
@@ -146,6 +178,7 @@ const DELEGATOR = new EventDelegator();
146
178
  const create_context = (payload, input) => {
147
179
  return {
148
180
  node: input.node,
181
+ nodes: input.nodes,
149
182
  payload,
150
183
  strings: input.strings,
151
184
  functions: input.functions,
@@ -1,3 +1,3 @@
1
1
  import { AnyDOM } from "../dom.types.js";
2
2
  import { Template } from "../dom.template.js";
3
- export declare function compile(node: AnyDOM<any>): Template;
3
+ export declare function compile<Context>(node: AnyDOM<Context>): Template;
@@ -1,10 +1,11 @@
1
- import { vm } from "../../../../index.js";
1
+ import * as vm from "../../../../stillflow-vm/index.js";
2
2
  import { transform } from "../transform/dom.transform.js";
3
3
  export function compile(node) {
4
4
  const emitter = new vm.Emitter();
5
5
  const strings = new vm.Payload();
6
6
  const functions = new vm.Payload();
7
7
  const templates = new vm.Payload();
8
+ const nodes = new vm.Payload();
8
9
  let next_node_id = 0;
9
10
  function walk(current) {
10
11
  const modifiers = current.properties.modifiers;
@@ -13,8 +14,9 @@ export function compile(node) {
13
14
  const has_text = modifiers?.text !== undefined;
14
15
  const has_for = modifiers?.iterate !== undefined;
15
16
  const has_if = modifiers?.conditional !== undefined;
17
+ const has_vm = modifiers?.vm !== undefined;
16
18
  let current_id = -1;
17
- if (has_properties || has_events || has_text || has_for || has_if) {
19
+ if (has_properties || has_events || has_text || has_for || has_if || has_vm) {
18
20
  current_id = next_node_id++;
19
21
  }
20
22
  if (has_properties) {
@@ -41,6 +43,15 @@ export function compile(node) {
41
43
  const functionIndex = functions.add(modifiers.conditional);
42
44
  emitter.emit(0 /* Codes.IF */, current_id, functionIndex);
43
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
+ }
44
55
  if (has_for) {
45
56
  const iterate = modifiers.iterate;
46
57
  const selectIndex = functions.add(iterate.select);
@@ -57,6 +68,7 @@ export function compile(node) {
57
68
  return {
58
69
  node,
59
70
  root: transform(node),
71
+ nodes: nodes.values,
60
72
  strings: strings.values,
61
73
  bytecode: emitter.finish(),
62
74
  functions: functions.values,
@@ -1,9 +1,10 @@
1
- import { vm } from "../../../../index.js";
1
+ import * as vm from "../../../../stillflow-vm/index.js";
2
2
  import { Template } from "../dom.template.js";
3
3
  import { AnyDOM } from "../dom.types.js";
4
4
  import { EventDelegator } from "../utilities/dom.delegator.js";
5
5
  export type Context = {
6
6
  node: AnyDOM<any>;
7
+ nodes: AnyDOM<any>[];
7
8
  payload: vm.Payload;
8
9
  strings: string[];
9
10
  functions: Function[];
@@ -1,5 +1,6 @@
1
1
  export declare const enum Codes {
2
2
  IF = 0,
3
+ VM = 6,
3
4
  END = 1,
4
5
  FOR = 2,
5
6
  TEXT = 3,
@@ -1,6 +1,8 @@
1
- import { collection } from "../../../index.js";
1
+ import * as collection from "../../../stillflow-collection/index.js";
2
+ import * as vm from '../../../stillflow-vm/index.js';
2
3
  import { AnyDOM } from "./dom.types.js";
3
4
  export type Directives<V, K extends keyof HTMLElementTagNameMap = any> = Partial<{
5
+ vm: (context: V) => vm.Target<unknown, V>;
4
6
  text: (context: V) => string;
5
7
  events: Partial<{
6
8
  [L in keyof HTMLElementEventMap]: (event: HTMLElementEventMap[L], context: V) => void;
@@ -2,6 +2,7 @@ import { AnyDOM } from "./dom.types.js";
2
2
  export interface Template {
3
3
  node: AnyDOM<any>;
4
4
  root: HTMLElement;
5
+ nodes: AnyDOM<any>[];
5
6
  bytecode: ArrayLike<number>;
6
7
  strings: string[];
7
8
  functions: Function[];
@@ -1,4 +1,4 @@
1
- import { Binding } from "../../binding.js";
1
+ import { Binding } from "../../../stillflow-vm/binding.js";
2
2
  import { Properties } from "../properties/properties.js";
3
3
  export type DOM<V, K extends keyof HTMLElementTagNameMap> = Binding<Properties<V, K>>;
4
4
  export type AnyDOM<V> = Binding<Properties<V, keyof HTMLElementTagNameMap>>;
@@ -1,3 +1,2 @@
1
- export { jsx } from './runtime/jsx.runtime.js';
2
1
  export { JSXDOM_REGISTRY as jsxdom } from './dom/jsx.dom.js';
3
2
  export { DOM_REGISTRY as dom } from './dom/base.dom.js';
@@ -1,3 +1,2 @@
1
- export { jsx } from './runtime/jsx.runtime.js';
2
1
  export { JSXDOM_REGISTRY as jsxdom } from './dom/jsx.dom.js';
3
2
  export { DOM_REGISTRY as dom } from './dom/base.dom.js';
@@ -0,0 +1,3 @@
1
+ export declare function vm({ type }: {
2
+ type: () => string;
3
+ }): void;
@@ -0,0 +1,2 @@
1
+ export function vm({ type }) {
2
+ }
@@ -1,5 +1,6 @@
1
- import { Stillflow, State, Batcher, operators, adapters, collection } from "../index.js";
1
+ import { core, vm, operators, adapters, collection } from "../index.js";
2
2
  import { buildData } from "./data.js";
3
+ const { Stillflow, State, Batcher } = core;
3
4
  const { jsxdom, dom } = adapters;
4
5
  class BenchmarkApplicationController {
5
6
  _stillflow = new Stillflow(new State());
@@ -95,46 +96,55 @@ class BenchmarkApplicationController {
95
96
  }
96
97
  }
97
98
  function BenchmarkApplicationHeader() {
98
- return (adapters.jsx(jsxdom.div, { className: "col-md-6" },
99
- adapters.jsx(jsxdom.h1, null, "Stillflow")));
99
+ return (vm.jsx(jsxdom.div, { className: "col-md-6" },
100
+ vm.jsx(jsxdom.h1, null, "Stillflow")));
100
101
  }
101
102
  function BenchmarkApplicationButton(context) {
102
- return (adapters.jsx(jsxdom.div, { className: "col-sm-6 smallpad" },
103
- adapters.jsx(jsxdom.button, { type: "button", className: "btn btn-primary btn-block", id: context.id, "on:click": context.handle }, context.text)));
103
+ return (vm.jsx(jsxdom.div, { className: "col-sm-6 smallpad" },
104
+ vm.jsx(jsxdom.button, { type: "button", className: "btn btn-primary btn-block", id: context.id, "on:click": context.handle }, context.text)));
104
105
  }
105
106
  function BenchmarkApplicationTableRow(context) {
106
107
  const { controller } = context;
107
- return (adapters.jsx(jsxdom.tr, { "sf:className": (context) => controller.is_selected(context.index) ? "danger" : String() },
108
- adapters.jsx(jsxdom.td, { className: "col-md-1" }, (context) => context.id),
109
- adapters.jsx(jsxdom.td, { className: "col-md-4" },
110
- adapters.jsx(jsxdom.a, { "sf:on-click": (event, context) => controller.select(context.index) }, (context) => context.label)),
111
- adapters.jsx(jsxdom.td, { className: "col-md-1" },
112
- adapters.jsx(jsxdom.a, { "sf:on-click": (event, context) => controller.remove(context.index) },
113
- adapters.jsx(jsxdom.span, { ariaHidden: "true", className: "glyphicon glyphicon-remove" }))),
114
- adapters.jsx(jsxdom.td, { className: "col-md-6" })));
108
+ return (vm.jsx(jsxdom.tr, { "sf:className": (context) => controller.is_selected(context.index) ? "danger" : String() },
109
+ vm.jsx(jsxdom.td, { className: "col-md-1" }, (context) => context.id),
110
+ vm.jsx(jsxdom.td, { className: "col-md-4" },
111
+ vm.jsx(jsxdom.a, { "sf:on-click": (event, context) => controller.select(context.index) }, (context) => context.label)),
112
+ vm.jsx(jsxdom.td, { className: "col-md-1" },
113
+ vm.jsx(jsxdom.a, { "sf:on-click": (event, context) => controller.remove(context.index) },
114
+ vm.jsx(jsxdom.span, { ariaHidden: "true", className: "glyphicon glyphicon-remove" }))),
115
+ vm.jsx(jsxdom.td, { className: "col-md-6" })));
115
116
  }
116
117
  function BenchmarkApplicationTable(context) {
117
118
  const { controller } = context;
118
- return (adapters.jsx(jsxdom.table, { className: "table table-hover table-striped test-data" }, adapters.jsx(jsxdom.tbody, { "sf:for": () => controller.items, "sf:each": () => adapters.jsx(BenchmarkApplicationTableRow, { controller: controller }) })));
119
+ return (vm.jsx(jsxdom.table, { className: "table table-hover table-striped test-data" }, vm.jsx(jsxdom.tbody, { "sf:for": () => controller.items, "sf:each": () => vm.jsx(BenchmarkApplicationTableRow, { controller: controller }) })));
119
120
  }
120
121
  function BenchmarkApplicationView(context) {
121
122
  const { controller } = context;
122
- return (adapters.jsx(jsxdom.div, { id: "app", className: "container" },
123
- adapters.jsx(jsxdom.div, { className: "jumbotron" },
124
- adapters.jsx(jsxdom.div, { className: "row" },
125
- adapters.jsx(BenchmarkApplicationHeader, null),
126
- adapters.jsx(jsxdom.div, { className: "row" },
127
- adapters.jsx(jsxdom.div, { className: "col-md-6" },
128
- adapters.jsx(BenchmarkApplicationButton, { text: "Create 1,000 rows", id: "run", handle: () => controller.run() }),
129
- adapters.jsx(BenchmarkApplicationButton, { text: "Create 10,000 rows", id: "runlots", handle: () => controller.run_lots() }),
130
- adapters.jsx(BenchmarkApplicationButton, { text: "Append 1,000 rows", id: "add", handle: () => controller.add() }),
131
- adapters.jsx(BenchmarkApplicationButton, { text: "Update every 10th row", id: "update", handle: () => controller.update() }),
132
- adapters.jsx(BenchmarkApplicationButton, { text: "Clear", id: "clear", handle: () => controller.clear() }),
133
- adapters.jsx(BenchmarkApplicationButton, { text: "Swap rows", id: "swaprows", handle: () => controller.swap() }))))),
134
- adapters.jsx(BenchmarkApplicationTable, { controller: controller }),
135
- adapters.jsx(jsxdom.span, { ariaHidden: "true", className: "preloadicon glyphicon glyphicon-remove" })));
123
+ return (vm.jsx(jsxdom.div, { id: "app", className: "container" },
124
+ vm.jsx(jsxdom.div, { className: "jumbotron" },
125
+ vm.jsx(jsxdom.div, { className: "row" },
126
+ vm.jsx(BenchmarkApplicationHeader, null),
127
+ vm.jsx(jsxdom.div, { className: "row" },
128
+ vm.jsx(jsxdom.div, { className: "col-md-6" },
129
+ vm.jsx(BenchmarkApplicationButton, { text: "Create 1,000 rows", id: "run", handle: () => controller.run() }),
130
+ vm.jsx(BenchmarkApplicationButton, { text: "Create 10,000 rows", id: "runlots", handle: () => controller.run_lots() }),
131
+ vm.jsx(BenchmarkApplicationButton, { text: "Append 1,000 rows", id: "add", handle: () => controller.add() }),
132
+ vm.jsx(BenchmarkApplicationButton, { text: "Update every 10th row", id: "update", handle: () => controller.update() }),
133
+ vm.jsx(BenchmarkApplicationButton, { text: "Clear", id: "clear", handle: () => controller.clear() }),
134
+ vm.jsx(BenchmarkApplicationButton, { text: "Swap rows", id: "swaprows", handle: () => controller.swap() }))))),
135
+ vm.jsx(BenchmarkApplicationTable, { controller: controller }),
136
+ vm.jsx(jsxdom.span, { ariaHidden: "true", className: "preloadicon glyphicon glyphicon-remove" })));
137
+ }
138
+ function custom_compiler(node) {
139
+ return {
140
+ root: document.createElement('canvas'),
141
+ applier(root, context) {
142
+ root.getContext('2d').fillRect(0, 0, 100, 100);
143
+ }
144
+ };
136
145
  }
137
146
  const controller = new BenchmarkApplicationController();
138
- const update = dom.$(adapters.jsx(BenchmarkApplicationView, { controller: controller }));
147
+ const update = dom.$(vm.jsx(jsxdom.div, { "sf:vm": () => custom_compiler },
148
+ vm.jsx(BenchmarkApplicationView, { controller: controller })));
139
149
  controller.core.on(() => update({}));
140
150
  update({});
@@ -1,4 +1,5 @@
1
- import { Stillflow, State, collection, operators, adapters } from '../index.js';
1
+ import { core, vm, collection, operators, adapters } from '../index.js';
2
+ const { Stillflow, State, Batcher } = core;
2
3
  const { jsxdom, dom } = adapters;
3
4
  const state = new State();
4
5
  const stillflow = new Stillflow(state);
@@ -20,15 +21,15 @@ function add() {
20
21
  stillflow.commit();
21
22
  }
22
23
  function TodoItem() {
23
- return (adapters.jsx(jsxdom.div, null, (context) => context.label));
24
+ return (vm.jsx(jsxdom.div, null, (context) => context.label));
24
25
  }
25
26
  function App() {
26
- return (adapters.jsx(jsxdom.div, null,
27
- adapters.jsx(jsxdom.input, { "sf:value": (context) => context.input, "on:change": change }),
28
- adapters.jsx(jsxdom.button, { "on:click": add }, "Add"),
29
- adapters.jsx(jsxdom.div, { "sf:for": (context) => context.items, "sf:each": () => adapters.jsx(TodoItem, null) })));
27
+ return (vm.jsx(jsxdom.div, null,
28
+ vm.jsx(jsxdom.input, { "sf:value": (context) => context.input, "on:change": change }),
29
+ vm.jsx(jsxdom.button, { "on:click": add }, "Add"),
30
+ vm.jsx(jsxdom.div, { "sf:for": (context) => context.items, "sf:each": () => vm.jsx(TodoItem, null) })));
30
31
  }
31
- const update = dom.$(adapters.jsx(App, null), {
32
+ const update = dom.$(vm.jsx(App, null), {
32
33
  container: document.body
33
34
  });
34
35
  stillflow.on(() => update(instance));
@@ -0,0 +1,7 @@
1
+ import { Binding } from "../binding.js";
2
+ export interface VMTarget<Root = any, Context = any> {
3
+ root: Root;
4
+ applier: (root: Root, context: Context) => void;
5
+ dispose?: (root: Root) => void;
6
+ }
7
+ export type VMCompiler<Properties extends Record<string, any> = Record<string, any>, Root = any> = (node: Binding<Properties>) => VMTarget<Root>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -2,4 +2,6 @@ export { Emitter } from './emitter.js';
2
2
  export { Payload } from './payload.js';
3
3
  export { VMConfig as Config } from './abstract/config.js';
4
4
  export { VMGenerator as Generator } from './abstract/generator.js';
5
+ export { VMTarget as Target, VMCompiler as Compiler } from './abstract/target.js';
6
+ export { jsx } from './runtime/jsx.runtime.js';
5
7
  export { vm_create as create } from './create.js';
@@ -1,3 +1,4 @@
1
1
  export { Emitter } from './emitter.js';
2
2
  export { Payload } from './payload.js';
3
+ export { jsx } from './runtime/jsx.runtime.js';
3
4
  export { vm_create as create } from './create.js';
package/package.json CHANGED
@@ -1,11 +1,29 @@
1
1
  {
2
2
  "name": "stillflow.engine",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "A headless, transaction-based UI engine with AOT compilation.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
+ "sideEffects": false,
10
+ "exports": {
11
+ ".": [
12
+ "./dist/index.js"
13
+ ],
14
+ "./adapters": [
15
+ "./dist/index.js"
16
+ ],
17
+ "./core": [
18
+ "./dist/index.js"
19
+ ],
20
+ "./vm": [
21
+ "./dist/index.js"
22
+ ],
23
+ "./collection": [
24
+ "./dist/index.js"
25
+ ]
26
+ },
9
27
  "files": [
10
28
  "dist",
11
29
  "README.md"
@@ -1,5 +0,0 @@
1
- export declare const SF_LISTENED = "__stillflow_listened__";
2
- export declare const SF_CONTEXT = "__stillflow_context__";
3
- export declare const SF_CACHE_TEXT = "__stillflow_cache_text__";
4
- export declare const SF_CACHE = "__stillflow_cache__";
5
- export declare const SF_HANDLERS = "__stillflow_handlers__";
@@ -1,5 +0,0 @@
1
- export const SF_LISTENED = '__stillflow_listened__';
2
- export const SF_CONTEXT = '__stillflow_context__';
3
- export const SF_CACHE_TEXT = '__stillflow_cache_text__';
4
- export const SF_CACHE = '__stillflow_cache__';
5
- export const SF_HANDLERS = `__stillflow_handlers__`;