stillflow.engine 0.4.8 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +12 -30
  2. package/dist/index.cjs.js +566 -0
  3. package/dist/index.d.ts +4 -5
  4. package/dist/index.es.js +557 -0
  5. package/dist/rolldown-runtime-BW-eSwOZ.cjs +42 -0
  6. package/dist/stillflow/abstracts/meta.d.ts +1 -1
  7. package/dist/stillflow/abstracts/view.d.ts +2 -2
  8. package/dist/stillflow/compiler/compile.d.ts +5 -5
  9. package/dist/stillflow/compiler/instantiate.d.ts +2 -2
  10. package/dist/stillflow/index.d.ts +2 -2
  11. package/dist/stillflow/kernel/buffer.d.ts +1 -1
  12. package/dist/stillflow/kernel/kernel.d.ts +2 -2
  13. package/dist/stillflow/operators.d.ts +1 -1
  14. package/dist/stillflow/state.d.ts +1 -1
  15. package/dist/stillflow/stillflow.d.ts +6 -6
  16. package/dist/stillflow/variable.d.ts +2 -2
  17. package/dist/stillflow-collection/fenwick.d.ts +1 -1
  18. package/dist/stillflow-collection/flushable.d.ts +2 -2
  19. package/dist/stillflow-collection/index.d.ts +3 -3
  20. package/dist/stillflow-collection/utilities/range-fenwick-tree.d.ts +1 -1
  21. package/dist/stillflow-vite/babel-vm/abstract/binding.d.ts +4 -0
  22. package/dist/stillflow-vite/babel-vm/abstract/configurator.d.ts +7 -0
  23. package/dist/stillflow-vite/babel-vm/abstract/generator.d.ts +2 -0
  24. package/dist/stillflow-vite/babel-vm/classes/payload.d.ts +23 -0
  25. package/dist/stillflow-vite/babel-vm/index.d.ts +7 -0
  26. package/dist/stillflow-vite/babel-vm/utilities/build.d.ts +6 -0
  27. package/dist/stillflow-vite/babel-vm/utilities/create.d.ts +11 -0
  28. package/dist/stillflow-vite/dom/build-vm/build.d.ts +4 -0
  29. package/dist/stillflow-vite/dom/build-vm/build.dom.d.ts +6 -0
  30. package/dist/stillflow-vite/dom/build-vm/compile.d.ts +8 -0
  31. package/dist/stillflow-vite/dom/build-vm/markup.d.ts +7 -0
  32. package/dist/stillflow-vite/dom/build-vm/run.d.ts +12 -0
  33. package/dist/stillflow-vite/dom/build-vm/template.d.ts +14 -0
  34. package/dist/stillflow-vite/dom/build-vm/transform.d.ts +10 -0
  35. package/dist/{stillflow-adapters/dom/vm/dom.codes.d.ts → stillflow-vite/dom/directives/codes.d.ts} +1 -2
  36. package/dist/stillflow-vite/dom/directives/generators.d.ts +3 -0
  37. package/dist/stillflow-vite/dom/environment.d.ts +21 -0
  38. package/dist/stillflow-vite/dom/helpers/collectors.d.ts +9 -0
  39. package/dist/stillflow-vite/dom/helpers/extractors.d.ts +11 -0
  40. package/dist/stillflow-vite/dom/helpers/getters.d.ts +7 -0
  41. package/dist/stillflow-vite/dom/helpers/replacers.d.ts +2 -0
  42. package/dist/stillflow-vite/dom/properties/directives.d.ts +16 -0
  43. package/dist/{stillflow-adapters → stillflow-vite}/dom/properties/properties.d.ts +4 -3
  44. package/dist/{stillflow-adapters/dom/vm/dom.types.d.ts → stillflow-vite/dom/properties/types.d.ts} +2 -2
  45. package/dist/{stillflow-adapters/dom/vm/utilities/dom.delegator.d.ts → stillflow-vite/dom/utilities/delegator.d.ts} +1 -0
  46. package/dist/stillflow-vite/dom.plugin.d.ts +2 -0
  47. package/dist/{stillflow-adapters/dom → stillflow-vite/runtime}/jsx.dom.d.ts +20 -14
  48. package/dist/vite.cjs.js +18348 -0
  49. package/dist/vite.es.js +18345 -0
  50. package/dist/vite.plugin.d.ts +2 -0
  51. package/package.json +41 -29
  52. package/dist/index.js +0 -6
  53. package/dist/jsx-runtime.d.ts +0 -3
  54. package/dist/jsx-runtime.js +0 -7
  55. package/dist/stillflow/abstracts/IR.js +0 -1
  56. package/dist/stillflow/abstracts/meta.js +0 -1
  57. package/dist/stillflow/abstracts/operators.js +0 -1
  58. package/dist/stillflow/abstracts/state.js +0 -1
  59. package/dist/stillflow/abstracts/view.js +0 -1
  60. package/dist/stillflow/compiler/compile.js +0 -84
  61. package/dist/stillflow/compiler/instantiate.js +0 -40
  62. package/dist/stillflow/factories/factories.js +0 -20
  63. package/dist/stillflow/index.js +0 -3
  64. package/dist/stillflow/kernel/buffer.js +0 -16
  65. package/dist/stillflow/kernel/kernel.js +0 -44
  66. package/dist/stillflow/kernel/signal.js +0 -12
  67. package/dist/stillflow/operators.js +0 -31
  68. package/dist/stillflow/state.js +0 -12
  69. package/dist/stillflow/stillflow.js +0 -59
  70. package/dist/stillflow/tools/batcher.js +0 -21
  71. package/dist/stillflow/variable.js +0 -24
  72. package/dist/stillflow-adapters/dom/base.dom.d.ts +0 -17
  73. package/dist/stillflow-adapters/dom/base.dom.js +0 -31
  74. package/dist/stillflow-adapters/dom/description/describe.d.ts +0 -3
  75. package/dist/stillflow-adapters/dom/description/describe.js +0 -6
  76. package/dist/stillflow-adapters/dom/jsx.dom.js +0 -98
  77. package/dist/stillflow-adapters/dom/properties/properties.js +0 -1
  78. package/dist/stillflow-adapters/dom/tags.d.ts +0 -7
  79. package/dist/stillflow-adapters/dom/tags.js +0 -5
  80. package/dist/stillflow-adapters/dom/vm/compile/dom.apply.d.ts +0 -3
  81. package/dist/stillflow-adapters/dom/vm/compile/dom.apply.js +0 -10
  82. package/dist/stillflow-adapters/dom/vm/compile/dom.apply.keyed.d.ts +0 -3
  83. package/dist/stillflow-adapters/dom/vm/compile/dom.apply.keyed.js +0 -10
  84. package/dist/stillflow-adapters/dom/vm/compile/dom.compile-vm.d.ts +0 -2
  85. package/dist/stillflow-adapters/dom/vm/compile/dom.compile-vm.js +0 -204
  86. package/dist/stillflow-adapters/dom/vm/compile/dom.compile-vm.keyed.d.ts +0 -2
  87. package/dist/stillflow-adapters/dom/vm/compile/dom.compile-vm.keyed.js +0 -167
  88. package/dist/stillflow-adapters/dom/vm/compile/dom.compile.d.ts +0 -3
  89. package/dist/stillflow-adapters/dom/vm/compile/dom.compile.js +0 -77
  90. package/dist/stillflow-adapters/dom/vm/compile/dom.context.d.ts +0 -13
  91. package/dist/stillflow-adapters/dom/vm/compile/dom.context.js +0 -1
  92. package/dist/stillflow-adapters/dom/vm/compile/dom.markup.d.ts +0 -3
  93. package/dist/stillflow-adapters/dom/vm/compile/dom.markup.js +0 -32
  94. package/dist/stillflow-adapters/dom/vm/dom.codes.js +0 -1
  95. package/dist/stillflow-adapters/dom/vm/dom.directives.d.ts +0 -18
  96. package/dist/stillflow-adapters/dom/vm/dom.directives.js +0 -1
  97. package/dist/stillflow-adapters/dom/vm/dom.symbols.js +0 -18
  98. package/dist/stillflow-adapters/dom/vm/dom.template.d.ts +0 -10
  99. package/dist/stillflow-adapters/dom/vm/dom.template.js +0 -1
  100. package/dist/stillflow-adapters/dom/vm/dom.types.js +0 -1
  101. package/dist/stillflow-adapters/dom/vm/transform/dom.transform.d.ts +0 -3
  102. package/dist/stillflow-adapters/dom/vm/transform/dom.transform.js +0 -54
  103. package/dist/stillflow-adapters/dom/vm/utilities/dom.delegator.js +0 -39
  104. package/dist/stillflow-adapters/dom/vm/utilities/dom.pool.js +0 -46
  105. package/dist/stillflow-adapters/index.d.ts +0 -2
  106. package/dist/stillflow-adapters/index.js +0 -2
  107. package/dist/stillflow-collection/abstract/collection.js +0 -1
  108. package/dist/stillflow-collection/delta.js +0 -18
  109. package/dist/stillflow-collection/fenwick.js +0 -102
  110. package/dist/stillflow-collection/flushable.js +0 -70
  111. package/dist/stillflow-collection/index.js +0 -2
  112. package/dist/stillflow-collection/utilities/disjointed-set.js +0 -45
  113. package/dist/stillflow-collection/utilities/fenwick-tree.js +0 -27
  114. package/dist/stillflow-collection/utilities/interval-merger.js +0 -70
  115. package/dist/stillflow-collection/utilities/range-fenwick-tree.js +0 -28
  116. package/dist/stillflow-examples/app.js +0 -123
  117. package/dist/stillflow-examples/data.js +0 -73
  118. package/dist/stillflow-examples/test.js +0 -32
  119. package/dist/stillflow-scripts/gen-tags.d.ts +0 -1
  120. package/dist/stillflow-scripts/gen-tags.js +0 -50
  121. package/dist/stillflow-vm/abstract/config.d.ts +0 -6
  122. package/dist/stillflow-vm/abstract/config.js +0 -1
  123. package/dist/stillflow-vm/abstract/generator.d.ts +0 -1
  124. package/dist/stillflow-vm/abstract/generator.js +0 -1
  125. package/dist/stillflow-vm/abstract/target.d.ts +0 -7
  126. package/dist/stillflow-vm/abstract/target.js +0 -1
  127. package/dist/stillflow-vm/binding.d.ts +0 -4
  128. package/dist/stillflow-vm/binding.js +0 -1
  129. package/dist/stillflow-vm/create.d.ts +0 -5
  130. package/dist/stillflow-vm/create.js +0 -17
  131. package/dist/stillflow-vm/emitter.js +0 -9
  132. package/dist/stillflow-vm/index.d.ts +0 -6
  133. package/dist/stillflow-vm/index.js +0 -3
  134. package/dist/stillflow-vm/payload.d.ts +0 -9
  135. package/dist/stillflow-vm/payload.js +0 -24
  136. /package/dist/{stillflow-vm → stillflow-vite/babel-vm/classes}/emitter.d.ts +0 -0
  137. /package/dist/{stillflow-adapters/dom/vm/utilities/dom.pool.d.ts → stillflow-vite/dom/utilities/pool.d.ts} +0 -0
  138. /package/dist/{stillflow-adapters/dom/vm/dom.symbols.d.ts → stillflow-vite/dom/utilities/symbols.d.ts} +0 -0
@@ -1,123 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "..//jsx-runtime.js";
2
- import { core, operators, adapters, collection } from "../index.js";
3
- import { buildData } from "./data.js";
4
- const { Stillflow, State, Batcher } = core;
5
- const { jsxdom, dom } = adapters;
6
- class BenchmarkApplicationController {
7
- _stillflow = new Stillflow(new State());
8
- _clearing = new Batcher(site => site());
9
- _factory = this._stillflow.factory();
10
- _view;
11
- schedule_clear() {
12
- this._view.items.mark_cleared();
13
- this._clearing.task(() => this._view.items.shrink());
14
- }
15
- deselect() {
16
- this._view.selection.current_id = undefined;
17
- this._view.selection.previous_id = undefined;
18
- }
19
- create(count = 1000) {
20
- this.schedule_clear();
21
- this.deselect();
22
- this.add(count);
23
- }
24
- get source() {
25
- const previous_id = this._stillflow.variable('previous_id');
26
- const current_id = this._stillflow.variable('current_id');
27
- const data = this._stillflow.variable('data');
28
- return {
29
- selection: operators.link({
30
- previous_id: previous_id.backref(),
31
- current_id: current_id.backref()
32
- }),
33
- data: data.backref(),
34
- items: operators.is(collection.Flushable.name)
35
- };
36
- }
37
- constructor() {
38
- const col = new collection.Flushable(new collection.Fenwick(10000));
39
- const view = this._stillflow.compile(this.source);
40
- this._factory.add(collection.Flushable.name, view => col);
41
- this._view = this._stillflow.instantiate(view, this._factory);
42
- }
43
- is_selected(id) {
44
- return this._view.selection.current_id === id;
45
- }
46
- add(count = 1000) {
47
- this._view.items.attach(buildData(count));
48
- this._stillflow.commit();
49
- }
50
- run() {
51
- this.create(1000);
52
- }
53
- run_lots() {
54
- this.create(10000);
55
- }
56
- remove(id) {
57
- for (let index = 0, size = this._view.items.size; index < size; index += 2) {
58
- this._view.items.mark_removed(index);
59
- }
60
- this._stillflow.commit();
61
- }
62
- select(id) {
63
- const NO_OP = () => { };
64
- this._view.selection.previous_id = this._view.selection.current_id;
65
- this._view.selection.current_id = id;
66
- this._view.items.mutate(this._view.selection.previous_id || 0, NO_OP);
67
- this._view.items.mutate(id, NO_OP);
68
- this._stillflow.commit();
69
- }
70
- clear() {
71
- this.schedule_clear();
72
- this._stillflow.commit();
73
- }
74
- update() {
75
- const length = this._view.items.size;
76
- const mutator = (view) => view.label += ' !!!';
77
- for (let id = 0; id < length; id += 10) {
78
- this._view.items.mutate(this._view.items.map(id), mutator);
79
- }
80
- this._stillflow.commit();
81
- }
82
- swap() {
83
- const size = this._view.items.size;
84
- const mutator = (id) => (view) => view.index = id;
85
- if (size > 998) {
86
- this._view.items.swap(1, 998);
87
- this._view.items.mutate(1, mutator(1));
88
- this._view.items.mutate(998, mutator(998));
89
- this._stillflow.commit();
90
- }
91
- }
92
- get items() {
93
- return this._view.items;
94
- }
95
- get core() {
96
- return this._stillflow;
97
- }
98
- }
99
- function BenchmarkApplicationHeader() {
100
- return (_jsx(jsxdom.div, { className: "col-md-6", children: _jsx(jsxdom.h1, { children: "Stillflow" }) }));
101
- }
102
- function BenchmarkApplicationButton(context) {
103
- return (_jsx(jsxdom.div, { className: "col-sm-6 smallpad", children: _jsx(jsxdom.button, { type: "button", className: "btn btn-primary btn-block", id: context.id, "on:click": context.handle, children: context.text }) }));
104
- }
105
- function BenchmarkApplicationTableRow(context) {
106
- const { controller } = context;
107
- return (_jsxs(jsxdom.tr, { "sf:className": (context) => controller.is_selected(context.index) ? "danger" : String(), children: [_jsx(jsxdom.td, { className: "col-md-1", children: (context) => context.id }), _jsx(jsxdom.td, { className: "col-md-4", children: _jsx(jsxdom.a, { "sf:on-click": (event, context) => controller.select(context.index), children: (context) => context.label }) }), _jsx(jsxdom.td, { className: "col-md-1", children: _jsx(jsxdom.a, { "sf:on-click": (event, context) => controller.remove(context.index), children: _jsx(jsxdom.span, { ariaHidden: "true", className: "glyphicon glyphicon-remove" }) }) }), _jsx(jsxdom.td, { className: "col-md-6" })] }));
108
- }
109
- function BenchmarkApplicationTable(context) {
110
- const { controller } = context;
111
- return (_jsx(jsxdom.table, { className: "table table-hover table-striped test-data", children: _jsx(jsxdom.tbody, { "sf:for": () => controller.items, "sf:each": () => _jsx(BenchmarkApplicationTableRow, { controller: controller }) }) }));
112
- }
113
- function BenchmarkApplicationView(context) {
114
- const { controller } = context;
115
- return (_jsxs(jsxdom.div, { id: "app", className: "container", children: [_jsx(jsxdom.div, { className: "jumbotron", children: _jsxs(jsxdom.div, { className: "row", children: [_jsx(BenchmarkApplicationHeader, {}), _jsx(jsxdom.div, { className: "row", children: _jsxs(jsxdom.div, { className: "col-md-6", children: [_jsx(BenchmarkApplicationButton, { text: "Create 1,000 rows", id: "run", handle: () => controller.run() }), _jsx(BenchmarkApplicationButton, { text: "Create 10,000 rows", id: "runlots", handle: () => controller.run_lots() }), _jsx(BenchmarkApplicationButton, { text: "Append 1,000 rows", id: "add", handle: () => controller.add() }), _jsx(BenchmarkApplicationButton, { text: "Update every 10th row", id: "update", handle: () => controller.update() }), _jsx(BenchmarkApplicationButton, { text: "Clear", id: "clear", handle: () => controller.clear() }), _jsx(BenchmarkApplicationButton, { text: "Swap rows", id: "swaprows", handle: () => controller.swap() })] }) })] }) }), _jsx(BenchmarkApplicationTable, { controller: controller }), _jsx(jsxdom.span, { ariaHidden: "true", className: "preloadicon glyphicon glyphicon-remove" })] }));
116
- }
117
- const controller = new BenchmarkApplicationController();
118
- const update = dom.$(_jsx(BenchmarkApplicationView, { controller: controller }), {
119
- mode: 'keyed',
120
- container: document.body
121
- });
122
- controller.core.on(() => update({}));
123
- update({});
@@ -1,73 +0,0 @@
1
- let ID = 1;
2
- function _random(max) {
3
- return Math.round(Math.random() * 1000) % max;
4
- }
5
- export function buildData(count = 1000) {
6
- const adjectives = [
7
- 'pretty',
8
- 'large',
9
- 'big',
10
- 'small',
11
- 'tall',
12
- 'short',
13
- 'long',
14
- 'handsome',
15
- 'plain',
16
- 'quaint',
17
- 'clean',
18
- 'elegant',
19
- 'easy',
20
- 'angry',
21
- 'crazy',
22
- 'helpful',
23
- 'mushy',
24
- 'odd',
25
- 'unsightly',
26
- 'adorable',
27
- 'important',
28
- 'inexpensive',
29
- 'cheap',
30
- 'expensive',
31
- 'fancy'
32
- ];
33
- const colours = [
34
- 'red',
35
- 'yellow',
36
- 'blue',
37
- 'green',
38
- 'pink',
39
- 'brown',
40
- 'purple',
41
- 'brown',
42
- 'white',
43
- 'black',
44
- 'orange'
45
- ];
46
- const nouns = [
47
- 'table',
48
- 'chair',
49
- 'house',
50
- 'bbq',
51
- 'desk',
52
- 'car',
53
- 'pony',
54
- 'cookie',
55
- 'sandwich',
56
- 'burger',
57
- 'pizza',
58
- 'mouse',
59
- 'keyboard'
60
- ];
61
- const data = [];
62
- for (let i = 0; i < count; i++)
63
- data.push({
64
- id: ID++,
65
- index: i,
66
- label: adjectives[_random(adjectives.length)] +
67
- ' ' +
68
- colours[_random(colours.length)] +
69
- ' ' +
70
- nouns[_random(nouns.length)]
71
- });
72
- return data;
73
- }
@@ -1,32 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "..//jsx-runtime.js";
2
- import { core, collection, operators, adapters } from '../index.js';
3
- const { jsxdom, dom } = adapters;
4
- const state = new core.State();
5
- const stillflow = new core.Stillflow(state);
6
- const factory = stillflow.factory();
7
- factory.add(collection.Flushable.name, () => new collection.Flushable(new collection.Fenwick(100)));
8
- const source = {
9
- input: stillflow.variable('input').backref(),
10
- items: operators.is(collection.Flushable.name)
11
- };
12
- const view = stillflow.compile(source);
13
- const instance = stillflow.instantiate(view, factory);
14
- function change(event) {
15
- instance.input = event.target.value;
16
- stillflow.commit();
17
- }
18
- function add() {
19
- instance.items.add({ label: instance.input });
20
- instance.input = String();
21
- stillflow.commit();
22
- }
23
- function TodoItem() {
24
- return (_jsx(jsxdom.div, { children: (context) => context.label }));
25
- }
26
- function App() {
27
- return (_jsxs(jsxdom.div, { children: [_jsx(jsxdom.input, { "sf:value": (context) => context.input, "on:change": change }), _jsx(jsxdom.button, { "on:click": add, children: "Add" }), _jsx(jsxdom.div, { "sf:for": (context) => context.items, "sf:each": () => _jsx(TodoItem, {}) })] }));
28
- }
29
- const update = dom.$(_jsx(App, {}), { container: document.body });
30
- stillflow.on(() => update(instance));
31
- instance.input = String();
32
- stillflow.commit();
@@ -1 +0,0 @@
1
- export {};
@@ -1,50 +0,0 @@
1
- // scripts/gen-tags.ts
2
- import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
3
- import { resolve, dirname } from 'node:path';
4
- function extractKeys(dts, interfaceName) {
5
- // ищем `interface Name { ... }` с балансировкой скобок
6
- const start = dts.indexOf(`interface ${interfaceName}`);
7
- if (start === -1)
8
- throw new Error(`${interfaceName} not found in lib.dom.d.ts`);
9
- const braceOpen = dts.indexOf('{', start);
10
- let depth = 0;
11
- let braceClose = -1;
12
- for (let i = braceOpen; i < dts.length; i++) {
13
- if (dts[i] === '{')
14
- depth++;
15
- else if (dts[i] === '}') {
16
- depth--;
17
- if (depth === 0) {
18
- braceClose = i;
19
- break;
20
- }
21
- }
22
- }
23
- if (braceClose === -1)
24
- throw new Error(`Unbalanced braces in ${interfaceName}`);
25
- const body = dts.slice(braceOpen + 1, braceClose);
26
- // ключи в мапе — это строковые литералы: "div": HTMLDivElement;
27
- return [...body.matchAll(/"([^"]+)"\s*:/g)].map(m => m[1]);
28
- }
29
- const dtsPath = resolve('node_modules/@typescript/typescript-win32-x64/lib/lib.dom.d.ts');
30
- const dts = readFileSync(dtsPath, 'utf8');
31
- const html = extractKeys(dts, 'HTMLElementTagNameMap');
32
- const svg = extractKeys(dts, 'SVGElementTagNameMap');
33
- const math = extractKeys(dts, 'MathMLElementTagNameMap');
34
- const out = `// AUTO-GENERATED by scripts/gen-tags.ts. Do not edit.
35
- // Source: typescript/lib/lib.dom.d.ts
36
-
37
- export const HTML_TAGS = ${JSON.stringify(html)} as const
38
- export const SVG_TAGS = ${JSON.stringify(svg)} as const
39
- export const MATH_TAGS = ${JSON.stringify(math)} as const
40
-
41
- export type HTMLTag = typeof HTML_TAGS[number]
42
- export type SVGTag = typeof SVG_TAGS[number]
43
- export type MathTag = typeof MATH_TAGS[number]
44
-
45
- export type Tag = HTMLTag | SVGTag | MathTag
46
- `;
47
- const outPath = resolve('src/stillflow-adapters/dom/tags.ts');
48
- mkdirSync(dirname(outPath), { recursive: true });
49
- writeFileSync(outPath, out);
50
- console.log(`Generated: ${html.length} HTML, ${svg.length} SVG, ${math.length} MathML tags`);
@@ -1,6 +0,0 @@
1
- import { VMGenerator } from "./generator.js";
2
- export type VMConfig<Context> = {
3
- generators: Record<number, VMGenerator<Context>>;
4
- preamble: (context: Context) => string;
5
- epilogue: (context: Context) => string;
6
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export type VMGenerator<Context> = (bytecode: ArrayLike<number>, offset: number, context: Context) => string;
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
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>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export type Binding<P> = {
2
- children: Binding<P>[];
3
- properties: P;
4
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { VMConfig } from "./abstract/config.js";
2
- import { Payload } from "./payload.js";
3
- export declare function vm_create<Input, Context extends {
4
- payload: Payload;
5
- }>(config: VMConfig<Context>): (bytecode: ArrayLike<number>, input: Input, create_context: (payload: Payload, input: Input) => Context) => any;
@@ -1,17 +0,0 @@
1
- import { Payload } from "./payload.js";
2
- export function vm_create(config) {
3
- return function compile(bytecode, input, create_context) {
4
- const payload = new Payload();
5
- const context = create_context(payload, input);
6
- let code = config.preamble(context);
7
- let offset = 0;
8
- while (bytecode[offset] !== 0) {
9
- const size = bytecode[offset];
10
- const operation = bytecode[offset + 1];
11
- code += config.generators[operation](bytecode, offset, context);
12
- offset += size;
13
- }
14
- code += config.epilogue(context);
15
- return new Function(...payload.parameters, code)(...payload.values);
16
- };
17
- }
@@ -1,9 +0,0 @@
1
- export class Emitter {
2
- _code = [];
3
- emit(operation, ...args) {
4
- this._code.push(args.length + 2, operation, ...args);
5
- }
6
- finish() {
7
- return new Uint16Array(this._code.concat([0]));
8
- }
9
- }
@@ -1,6 +0,0 @@
1
- export { Emitter } from './emitter.js';
2
- export { Payload } from './payload.js';
3
- export { VMConfig as Config } from './abstract/config.js';
4
- export { VMGenerator as Generator } from './abstract/generator.js';
5
- export { VMTarget as Target, VMCompiler as Compiler } from './abstract/target.js';
6
- export { vm_create as create } from './create.js';
@@ -1,3 +0,0 @@
1
- export { Emitter } from './emitter.js';
2
- export { Payload } from './payload.js';
3
- export { vm_create as create } from './create.js';
@@ -1,9 +0,0 @@
1
- export declare class Payload {
2
- private _indices;
3
- private _index;
4
- payload(index: number): string;
5
- add(value: any): number;
6
- add_payload(value: any): string;
7
- get parameters(): string[];
8
- get values(): any[];
9
- }
@@ -1,24 +0,0 @@
1
- export class Payload {
2
- _indices = new Map();
3
- _index = 0;
4
- payload(index) {
5
- return `p${index}`;
6
- }
7
- add(value) {
8
- let payload_name = this._indices.get(value);
9
- if (payload_name === undefined) {
10
- payload_name = this._index++;
11
- this._indices.set(value, payload_name);
12
- }
13
- return payload_name;
14
- }
15
- add_payload(value) {
16
- return this.payload(this.add(value));
17
- }
18
- get parameters() {
19
- return Array.from(this._indices.values()).map(index => this.payload(index));
20
- }
21
- get values() {
22
- return Array.from(this._indices.keys());
23
- }
24
- }