stillflow.engine 0.1.9 → 0.2.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 (68) hide show
  1. package/README.md +10 -0
  2. package/dist/index.d.ts +2 -4
  3. package/dist/index.js +2 -3
  4. package/dist/stillflow-adapters/dom/aot/appliers/apply.d.ts +6 -0
  5. package/dist/stillflow-adapters/dom/{compiler/apply.generator.js → aot/appliers/apply.js} +40 -57
  6. package/dist/stillflow-adapters/dom/aot/compiler/compile.d.ts +11 -0
  7. package/dist/stillflow-adapters/dom/aot/compiler/compile.js +71 -0
  8. package/dist/stillflow-adapters/dom/aot/dom.delegator.d.ts +6 -0
  9. package/dist/stillflow-adapters/dom/aot/dom.delegator.js +39 -0
  10. package/dist/stillflow-adapters/dom/aot/dom.directives.d.ts +16 -0
  11. package/dist/stillflow-adapters/dom/aot/dom.operations.d.ts +3 -0
  12. package/dist/stillflow-adapters/dom/aot/dom.operations.js +1 -0
  13. package/dist/stillflow-adapters/dom/aot/dom.pool.d.ts +11 -0
  14. package/dist/stillflow-adapters/dom/aot/dom.pool.js +47 -0
  15. package/dist/stillflow-adapters/dom/aot/dom.resources.d.ts +3 -0
  16. package/dist/stillflow-adapters/dom/aot/dom.resources.js +3 -0
  17. package/dist/stillflow-adapters/dom/aot/dom.symbols.d.ts +5 -0
  18. package/dist/stillflow-adapters/dom/aot/dom.symbols.js +5 -0
  19. package/dist/stillflow-adapters/dom/{dom.d.ts → aot/dom.types.d.ts} +2 -2
  20. package/dist/stillflow-adapters/dom/aot/transformers/transform.d.ts +3 -0
  21. package/dist/stillflow-adapters/dom/aot/transformers/transform.js +42 -0
  22. package/dist/stillflow-adapters/dom/base.dom.d.ts +5 -3
  23. package/dist/stillflow-adapters/dom/base.dom.js +20 -12
  24. package/dist/stillflow-adapters/dom/description/describe.d.ts +1 -1
  25. package/dist/stillflow-adapters/dom/jsx.dom.d.ts +3 -3
  26. package/dist/stillflow-adapters/dom/properties/modifiers.d.ts +3 -4
  27. package/dist/stillflow-collection/index.d.ts +3 -0
  28. package/dist/stillflow-collection/index.js +2 -0
  29. package/dist/stillflow-examples/app.js +7 -5
  30. package/package.json +1 -1
  31. package/dist/stillflow-adapters/dom/compiler/apply.d.ts +0 -37
  32. package/dist/stillflow-adapters/dom/compiler/apply.generator.d.ts +0 -5
  33. package/dist/stillflow-adapters/dom/compiler/apply.js +0 -289
  34. package/dist/stillflow-adapters/dom/compiler/compile.d.ts +0 -18
  35. package/dist/stillflow-adapters/dom/compiler/compile.js +0 -47
  36. package/dist/stillflow-adapters/dom/compiler/pool.d.ts +0 -21
  37. package/dist/stillflow-adapters/dom/compiler/pool.js +0 -91
  38. package/dist/stillflow-adapters/dom/compiler/test.d.ts +0 -1
  39. package/dist/stillflow-adapters/dom/compiler/test.js +0 -59
  40. package/dist/stillflow-adapters/dom/compiler/transform.d.ts +0 -2
  41. package/dist/stillflow-adapters/dom/compiler/transform.js +0 -41
  42. package/dist/stillflow-adapters/dom/dom.js +0 -1
  43. package/dist/stillflow-adapters/dom/index.d.ts +0 -15
  44. package/dist/stillflow-adapters/dom/index.js +0 -22
  45. package/dist/stillflow-adapters/dom/types.d.ts +0 -4
  46. package/dist/stillflow-adapters/dom/types.js +0 -1
  47. package/dist/stillflow-adapters/dom/vm/compile.d.ts +0 -8
  48. package/dist/stillflow-adapters/dom/vm/compile.js +0 -8
  49. package/dist/stillflow-adapters/dom/vm/instructions/instructions.d.ts +0 -1
  50. package/dist/stillflow-adapters/dom/vm/instructions/instructions.js +0 -1
  51. package/dist/stillflow-adapters/dom/vm/resources.d.ts +0 -1
  52. package/dist/stillflow-adapters/dom/vm/resources.js +0 -1
  53. package/dist/stillflow-examples/files.d.ts +0 -1
  54. package/dist/stillflow-examples/files.js +0 -29
  55. package/dist/stillflow-examples/test.d.ts +0 -1
  56. package/dist/stillflow-examples/test.js +0 -35
  57. package/dist/stillflow-vm/analyze.d.ts +0 -7
  58. package/dist/stillflow-vm/analyze.js +0 -22
  59. package/dist/stillflow-vm/buffer.d.ts +0 -1
  60. package/dist/stillflow-vm/buffer.js +0 -1
  61. package/dist/stillflow-vm/instruction.d.ts +0 -1
  62. package/dist/stillflow-vm/instruction.js +0 -1
  63. package/dist/stillflow-vm/pool.d.ts +0 -1
  64. package/dist/stillflow-vm/pool.js +0 -1
  65. package/dist/stillflow-vm/resources.d.ts +0 -14
  66. package/dist/stillflow-vm/resources.js +0 -16
  67. /package/dist/stillflow-adapters/dom/{compiler/apply-generator.d.ts → aot/dom.directives.js} +0 -0
  68. /package/dist/stillflow-adapters/dom/{compiler/apply-generator.js → aot/dom.types.js} +0 -0
@@ -1,22 +0,0 @@
1
- import { HTML_TAGS } from "./tags.js";
2
- import { Compiler } from "./compiler/compile.js";
3
- import { Appliers } from "./compiler/apply.js";
4
- import { transform } from "./compiler/transform.js";
5
- import { describe } from "./description/describe.js";
6
- export const DOM_REGISTRY = Object.create(null);
7
- export class DOMAdapter {
8
- $(root) {
9
- const element = transform(root);
10
- const compiler = new Compiler();
11
- const compilation = compiler.compile(root);
12
- const appliers = new Appliers();
13
- const applier = appliers.apply(compilation);
14
- const update = (context) => applier(element, context);
15
- return { element, update };
16
- }
17
- }
18
- for (const tag of HTML_TAGS) {
19
- DOM_REGISTRY[tag] = (properties, children = []) => {
20
- return describe({ ...properties, name: tag }, children);
21
- };
22
- }
@@ -1,4 +0,0 @@
1
- import { Binding } from "../binding.js";
2
- import { Properties } from "./properties/properties.js";
3
- export type DOM<V, K extends keyof HTMLElementTagNameMap> = Binding<Properties<V, K>>;
4
- export type AnyDOM<V> = Binding<Properties<V, keyof HTMLElementTagNameMap>>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { AnyDOM } from "../types.js";
2
- export type Instructions = Uint32Array;
3
- export type Template = {
4
- paths: number[][];
5
- stream: Instructions;
6
- };
7
- export declare function traverse(node: AnyDOM<any>, path: number[], site: (node: AnyDOM<any>, path: number[]) => void): void;
8
- export declare function compile(node: AnyDOM<any>): Template;
@@ -1,8 +0,0 @@
1
- export function traverse(node, path, site) {
2
- site(node, path);
3
- for (let id = 0; id < node.children.length; id++) {
4
- traverse(node.children[id], [...path, id], site);
5
- }
6
- }
7
- export function compile(node) {
8
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,29 +0,0 @@
1
- import { Stillflow, State, adapters, FlushableCollection, FenwickCollection } from "../index.js";
2
- const { jsxdom, dom } = adapters;
3
- const core = new Stillflow(new State());
4
- const factory = core.factory();
5
- factory.add('collection', () => new FlushableCollection(new FenwickCollection(100)));
6
- function FileView({ depth }) {
7
- return (adapters.jsx(jsxdom.div, { styles: { 'padding': `${depth * 4}px` } },
8
- adapters.jsx(jsxdom.span, null, (context) => context.name),
9
- adapters.jsx(jsxdom.div, { "sf:for": (context) => context.files, "sf:each": () => adapters.jsx(FileView, { depth: depth + 1 }) })));
10
- }
11
- const root = {
12
- name: 'test',
13
- files: factory.get('collection', {})
14
- };
15
- root.files.add({
16
- name: 'test-0',
17
- files: factory.get('collection', {})
18
- });
19
- root.files.at(0).files.add({
20
- name: 'test-0-1',
21
- files: factory.get('collection', {})
22
- });
23
- root.files.add({
24
- name: 'test-1',
25
- files: factory.get('collection', {})
26
- });
27
- const { element, update } = dom.$(adapters.jsx(FileView, { depth: 0 }));
28
- update(root);
29
- document.body.append(element);
@@ -1 +0,0 @@
1
- export {};
@@ -1,35 +0,0 @@
1
- import { Stillflow, State, FenwickCollection, FlushableCollection, operators, adapters } from '../index.js';
2
- const { jsxdom, dom } = adapters;
3
- const state = new State();
4
- const stillflow = new Stillflow(state);
5
- const factory = stillflow.factory();
6
- factory.add(FlushableCollection.name, () => new FlushableCollection(new FenwickCollection(100)));
7
- const source = {
8
- input: stillflow.variable('input').backref(),
9
- items: operators.is(FlushableCollection.name)
10
- };
11
- const view = stillflow.compile(source);
12
- const instance = stillflow.instantiate(view, factory);
13
- function change(event) {
14
- instance.input = event.target.value;
15
- stillflow.commit();
16
- }
17
- function add() {
18
- instance.items.add({ label: instance.input });
19
- instance.input = String();
20
- stillflow.commit();
21
- }
22
- function TodoItem() {
23
- return (adapters.jsx(jsxdom.div, null, (context) => context.label));
24
- }
25
- 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) })));
30
- }
31
- const { element: app, update } = dom.$(adapters.jsx(App, null));
32
- stillflow.on(() => update(instance));
33
- instance.input = String();
34
- document.body.appendChild(app);
35
- update(instance);
@@ -1,7 +0,0 @@
1
- import { Binding } from "../stillflow-adapters/binding.js";
2
- export declare class Analyzer<P> {
3
- private static readonly MAXIMAL_SIZE;
4
- private static ID_COUNTER;
5
- private traverse;
6
- analyze(binding: Binding<P>): Uint32Array;
7
- }
@@ -1,22 +0,0 @@
1
- export class Analyzer {
2
- static MAXIMAL_SIZE = 2 ** 16;
3
- static ID_COUNTER = 0;
4
- traverse(binding, callback, path = []) {
5
- callback(binding, path);
6
- for (let index = 0, length = binding.children.length; index < length; index++) {
7
- const child = binding.children[index];
8
- if (typeof child === 'object') {
9
- this.traverse(child, callback, [...path, index]);
10
- }
11
- }
12
- }
13
- analyze(binding) {
14
- const buffer = new Uint32Array(Analyzer.MAXIMAL_SIZE);
15
- let offset = 0;
16
- let length = 0;
17
- buffer[offset++] = length;
18
- this.traverse(binding, (binding, path) => {
19
- });
20
- return buffer;
21
- }
22
- }
@@ -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 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- import { FlushableCollection } from "../index.js";
2
- import { Binding } from "../stillflow-adapters/binding.js";
3
- export declare class Resources<T> {
4
- private _resources;
5
- add(resource: T): number;
6
- get(index: number): T;
7
- }
8
- export declare const POOL_STRINGS: Resources<string>;
9
- export declare const TEXT_PROPERTIES: Resources<(context: unknown) => string>;
10
- export declare const CONDITIONAL_PROPERTIES: Resources<(context: unknown) => boolean>;
11
- export declare const EVENT_PROPERTIES: Resources<(event: unknown, context: unknown) => void>;
12
- export declare const PROPERTIES: Resources<(event: unknown) => string>;
13
- export declare const ITERATE_PROPERTIES: Resources<[(context: unknown) => FlushableCollection<unknown>, () => Binding<unknown>]>;
14
- export declare const POOLS: never[];
@@ -1,16 +0,0 @@
1
- export class Resources {
2
- _resources = [];
3
- add(resource) {
4
- return this._resources.push(resource);
5
- }
6
- get(index) {
7
- return this._resources[index];
8
- }
9
- }
10
- export const POOL_STRINGS = new Resources();
11
- export const TEXT_PROPERTIES = new Resources();
12
- export const CONDITIONAL_PROPERTIES = new Resources();
13
- export const EVENT_PROPERTIES = new Resources();
14
- export const PROPERTIES = new Resources();
15
- export const ITERATE_PROPERTIES = new Resources();
16
- export const POOLS = [];