stillflow.engine 0.1.9 → 0.2.1

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 +14 -4
  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} +52 -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/jsx.dom.js +1 -1
  27. package/dist/stillflow-adapters/dom/properties/modifiers.d.ts +3 -4
  28. package/dist/stillflow-collection/index.d.ts +3 -0
  29. package/dist/stillflow-collection/index.js +2 -0
  30. package/dist/stillflow-examples/app.js +7 -5
  31. package/dist/stillflow-examples/test.js +4 -4
  32. package/package.json +1 -1
  33. package/dist/stillflow-adapters/dom/compiler/apply.d.ts +0 -37
  34. package/dist/stillflow-adapters/dom/compiler/apply.generator.d.ts +0 -5
  35. package/dist/stillflow-adapters/dom/compiler/apply.js +0 -289
  36. package/dist/stillflow-adapters/dom/compiler/compile.d.ts +0 -18
  37. package/dist/stillflow-adapters/dom/compiler/compile.js +0 -47
  38. package/dist/stillflow-adapters/dom/compiler/pool.d.ts +0 -21
  39. package/dist/stillflow-adapters/dom/compiler/pool.js +0 -91
  40. package/dist/stillflow-adapters/dom/compiler/test.d.ts +0 -1
  41. package/dist/stillflow-adapters/dom/compiler/test.js +0 -59
  42. package/dist/stillflow-adapters/dom/compiler/transform.d.ts +0 -2
  43. package/dist/stillflow-adapters/dom/compiler/transform.js +0 -41
  44. package/dist/stillflow-adapters/dom/dom.js +0 -1
  45. package/dist/stillflow-adapters/dom/index.d.ts +0 -15
  46. package/dist/stillflow-adapters/dom/index.js +0 -22
  47. package/dist/stillflow-adapters/dom/types.d.ts +0 -4
  48. package/dist/stillflow-adapters/dom/types.js +0 -1
  49. package/dist/stillflow-adapters/dom/vm/compile.d.ts +0 -8
  50. package/dist/stillflow-adapters/dom/vm/compile.js +0 -8
  51. package/dist/stillflow-adapters/dom/vm/instructions/instructions.d.ts +0 -1
  52. package/dist/stillflow-adapters/dom/vm/instructions/instructions.js +0 -1
  53. package/dist/stillflow-adapters/dom/vm/resources.d.ts +0 -1
  54. package/dist/stillflow-adapters/dom/vm/resources.js +0 -1
  55. package/dist/stillflow-examples/files.d.ts +0 -1
  56. package/dist/stillflow-examples/files.js +0 -29
  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,59 +0,0 @@
1
- return function (root, context) {
2
- p0(root, p1);
3
- (function () { const items = p2.select(context); const target = root.__stillflow_cache__[0]; const { replaces, clears, addes, swaps, removes, updates } = items.flush(); if (replaces) {
4
- const items_count = items.size;
5
- const child_count = this._elements.length;
6
- const common_count = Math.min(items_count, child_count);
7
- for (let index = 0; index < common_count; index++) {
8
- p2.applier(p2.elements[index], items.at(index));
9
- }
10
- if (items_count < child_count) {
11
- for (let index = items_count; index < child_count; index++) {
12
- const element = p2.elements[index];
13
- this._pool.add(element);
14
- element.remove();
15
- }
16
- p2.elements.length = items_count;
17
- }
18
- else if (child_count < items_count) {
19
- const fragment = document.createDocumentFragment();
20
- const elements = new Array(items_count - child_count);
21
- for (let index = child_count; index < items_count; index++) {
22
- const element = p2.pool.get() || p2.template.cloneNode(true);
23
- p2.applier(element, items.at(index));
24
- p2.elements[index - child_count] = element;
25
- fragment.appendChild(element);
26
- }
27
- p2.elements = p2.elements.concat(elements);
28
- target.appendChild(fragment);
29
- }
30
- return;
31
- } if (clears) {
32
- const free = p2.elements.splice(0);
33
- for (const element of free) {
34
- p2.pool.add(element);
35
- }
36
- target.innerHTML = String();
37
- } if (addes > 0) {
38
- const fragment = document.createDocumentFragment();
39
- const elements = new Array(addes);
40
- for (let index = 0; index < addes; index++) {
41
- const element = p2.template.cloneNode(true);
42
- p2.applier(element, items.at(index));
43
- elements[index] = element;
44
- fragment.appendChild(element);
45
- }
46
- p2.elements = p2.elements.concat(elements);
47
- target.appendChild(fragment);
48
- } for (const [i, j] of swaps.entries()) {
49
- p2.applier(p2.elements[i], items.at(i));
50
- p2.applier(p2.elements[j], items.at(j));
51
- } for (const id of removes) {
52
- const element = p2.elements[id];
53
- this._pool.add(element);
54
- element.remove();
55
- } for (const id of updates) {
56
- p2.applier(p2.elements[id], items.at(id));
57
- } })();
58
- };
59
- export {};
@@ -1,2 +0,0 @@
1
- import { DOM } from "../types.js";
2
- export declare function transform<V, K extends keyof HTMLElementTagNameMap>(description: DOM<V, K>): HTMLElementTagNameMap[K];
@@ -1,41 +0,0 @@
1
- function apply_text(description, root) {
2
- const text = description.properties.text || String();
3
- if (root.firstChild === null || root.firstChild.nodeType !== Node.TEXT_NODE) {
4
- root.insertBefore(document.createTextNode(text), null);
5
- return;
6
- }
7
- root.firstChild.nodeValue = text;
8
- }
9
- function apply_properties(description, root) {
10
- let { properties } = description.properties;
11
- properties = properties || {};
12
- for (const key in properties) {
13
- root[key] = properties[key];
14
- }
15
- }
16
- function apply_styles(description, root) {
17
- let { styles } = description.properties;
18
- styles = styles || {};
19
- for (const key in styles) {
20
- root.style[key] = styles[key];
21
- }
22
- }
23
- function apply_events(description, root) {
24
- let { events } = description.properties;
25
- events = events || {};
26
- for (const key in events) {
27
- root.addEventListener(key, events[key]);
28
- }
29
- }
30
- export function transform(description) {
31
- let { name } = description.properties;
32
- const root = document.createElement(name);
33
- apply_properties(description, root);
34
- apply_styles(description, root);
35
- apply_events(description, root);
36
- apply_text(description, root);
37
- for (const child of description.children) {
38
- root.appendChild(transform(child));
39
- }
40
- return root;
41
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import { AnyDOM } from "./dom.js";
2
- import { Properties } from "./properties/properties.js";
3
- import { Binding } from "../binding.js";
4
- type PropertiesWithoutServices<V, K extends keyof HTMLElementTagNameMap> = Omit<Properties<V, K>, 'name'>;
5
- export type DOMRegistry = {
6
- [K in keyof HTMLElementTagNameMap]: <V>(properties: Partial<PropertiesWithoutServices<V, K>>, children?: Binding<any>[]) => AnyDOM<V>;
7
- };
8
- export declare const DOM_REGISTRY: DOMRegistry;
9
- export declare class DOMAdapter<V> {
10
- $(root: AnyDOM<V>): {
11
- element: HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBRElement | HTMLBaseElement | HTMLBodyElement | HTMLButtonElement | HTMLCanvasElement | HTMLDListElement | HTMLDataElement | HTMLDataListElement | HTMLDetailsElement | HTMLDialogElement | HTMLDivElement | HTMLElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHRElement | HTMLHeadElement | HTMLHeadingElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLInputElement | HTMLLIElement | HTMLLabelElement | HTMLLegendElement | HTMLLinkElement | HTMLMapElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLModElement | HTMLOListElement | HTMLObjectElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLParagraphElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLQuoteElement | HTMLScriptElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLSpanElement | HTMLStyleElement | HTMLTableCaptionElement | HTMLTableCellElement | HTMLTableColElement | HTMLTableElement | HTMLTableRowElement | HTMLTableSectionElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTrackElement | HTMLUListElement | HTMLVideoElement;
12
- update: (context: V) => void;
13
- };
14
- }
15
- export {};
@@ -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,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 = [];