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.
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 -168
  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 -120
  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
@@ -0,0 +1,557 @@
1
+ // \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ // src/stillflow-collection/delta.js
13
+ function clear_delta(delta) {
14
+ delta.addes = 0;
15
+ delta.swaps.clear();
16
+ delta.updates.clear();
17
+ delta.removes.clear();
18
+ delta.replaces = false;
19
+ delta.clears = false;
20
+ }
21
+ function copy_delta(delta) {
22
+ return {
23
+ addes: delta.addes,
24
+ swaps: new Map(delta.swaps),
25
+ updates: new Set(delta.updates),
26
+ removes: new Set(delta.removes),
27
+ replaces: delta.replaces,
28
+ clears: delta.clears
29
+ };
30
+ }
31
+ // src/stillflow-collection/flushable.ts
32
+ var FlushableCollection = class {
33
+ _base;
34
+ _delta = {
35
+ addes: 0,
36
+ swaps: /* @__PURE__ */ new Map(),
37
+ updates: /* @__PURE__ */ new Set(),
38
+ removes: /* @__PURE__ */ new Set(),
39
+ replaces: false,
40
+ clears: false
41
+ };
42
+ constructor(_base) {
43
+ this._base = _base;
44
+ }
45
+ at(index) {
46
+ return this._base.at(index);
47
+ }
48
+ map(id) {
49
+ return this._base.map(id);
50
+ }
51
+ add(value) {
52
+ this._delta.addes++;
53
+ this._base.add(value);
54
+ }
55
+ set(index, value) {
56
+ this._delta.updates.add(index);
57
+ this._base.set(index, value);
58
+ }
59
+ swap(i, j) {
60
+ this._delta.swaps.set(i, j);
61
+ this._base.swap(i, j);
62
+ }
63
+ attach(value) {
64
+ this._delta.addes += value.length;
65
+ this._base.attach(value);
66
+ }
67
+ mutate(index, mutator) {
68
+ this._delta.updates.add(index);
69
+ this._base.mutate(index, mutator);
70
+ }
71
+ shrink() {
72
+ this._base.shrink();
73
+ }
74
+ mark_cleared() {
75
+ this._delta.clears = true;
76
+ this._base.mark_cleared();
77
+ }
78
+ mark_removed(index) {
79
+ this._delta.removes.add(index);
80
+ this._base.mark_removed(index);
81
+ }
82
+ mark_removed_range(left, right) {
83
+ for (let index = left; index <= right; index++) this._delta.removes.add(index);
84
+ this._base.mark_removed_range(left, right);
85
+ }
86
+ flush() {
87
+ this._delta.replaces = this._delta.addes > 0 && this._delta.clears;
88
+ const delta = copy_delta(this._delta);
89
+ clear_delta(this._delta);
90
+ return delta;
91
+ }
92
+ get size() {
93
+ return this._base.size;
94
+ }
95
+ get capacity() {
96
+ return this._base.capacity;
97
+ }
98
+ };
99
+ // src/stillflow-collection/utilities/fenwick-tree.ts
100
+ var Fenwick = class Fenwick {
101
+ _size;
102
+ _tree;
103
+ constructor(_size, old = /* @__PURE__ */ new Int32Array(0)) {
104
+ this._size = _size;
105
+ this._tree = new Int32Array(this._size + 1);
106
+ this._tree.set(old);
107
+ }
108
+ add(start, delta) {
109
+ for (let index = start + 1; index <= this._size; index += index & -index) this._tree[index] += delta;
110
+ }
111
+ count(end) {
112
+ let amount = 0;
113
+ for (let index = end + 1; index > 0; index -= index & -index) amount += this._tree[index];
114
+ return amount;
115
+ }
116
+ grow(length) {
117
+ return new Fenwick(this._size + length, this._tree);
118
+ }
119
+ get size() {
120
+ return this._size;
121
+ }
122
+ };
123
+ // src/stillflow-collection/fenwick.ts
124
+ var FenwickCollection = class FenwickCollection {
125
+ _size;
126
+ static GROW = 2;
127
+ static REMOVE_COUNT = 1;
128
+ _removes = /* @__PURE__ */ new Set();
129
+ _tree;
130
+ _shift = 0;
131
+ _data;
132
+ constructor(_size = 1) {
133
+ this._size = _size;
134
+ this._data = new Array();
135
+ this._tree = new Fenwick(this._size);
136
+ }
137
+ at(index) {
138
+ return this._data[index + this._shift];
139
+ }
140
+ map(id) {
141
+ let physical_index = 0;
142
+ let step = 1;
143
+ while (step * 2 <= this._size) step *= 2;
144
+ for (let index = step; index > 0; index >>= 1) {
145
+ const next = physical_index + index;
146
+ if (next <= this._data.length) {
147
+ if (next - this._tree.count(next) <= id) physical_index = next;
148
+ }
149
+ }
150
+ return physical_index + this._shift;
151
+ }
152
+ set(index, value) {
153
+ this._data[index + this._shift] = value;
154
+ }
155
+ add(value) {
156
+ if (this._data.push(value) >= this._size) {
157
+ this._tree = this._tree.grow(this._size);
158
+ this._size *= FenwickCollection.GROW;
159
+ }
160
+ }
161
+ swap(i, j) {
162
+ const temporary = this.at(i);
163
+ this.set(i, this.at(j));
164
+ this.set(j, temporary);
165
+ }
166
+ attach(value) {
167
+ this._data = this._data.concat(value);
168
+ const index = this._data.length;
169
+ while (index >= this._size) {
170
+ this._tree = this._tree.grow(this._size);
171
+ this._size *= FenwickCollection.GROW;
172
+ }
173
+ }
174
+ mutate(index, mutator) {
175
+ mutator(this.at(index));
176
+ }
177
+ shrink() {
178
+ this._data.splice(0, this._shift);
179
+ this._shift = 0;
180
+ const removes = Array.from(this._removes).sort((i, j) => j - i);
181
+ for (const id of removes) this._data.splice(id, 1);
182
+ this._removes.clear();
183
+ this._size = this._data.length + 1;
184
+ this._tree = new Fenwick(this._size);
185
+ }
186
+ mark_cleared() {
187
+ this._shift = this._data.length;
188
+ this._size = this._data.length + 1;
189
+ this._removes.clear();
190
+ this._tree = new Fenwick(this._size);
191
+ }
192
+ mark_removed(index) {
193
+ this.mark_removed_range(index, index);
194
+ }
195
+ mark_removed_range(left, right) {
196
+ if (left > right) return;
197
+ for (let index = left; index <= right; index++) if (this._removes.has(index) === false) {
198
+ this._tree.add(index, FenwickCollection.REMOVE_COUNT);
199
+ this._removes.add(index);
200
+ }
201
+ }
202
+ get size() {
203
+ return this._data.length - this._shift - this._tree.count(this._data.length - this._shift);
204
+ }
205
+ get capacity() {
206
+ return this._size;
207
+ }
208
+ };
209
+ // src/stillflow-collection/index.ts
210
+ var stillflow_collection_exports = /* @__PURE__ */ __exportAll({
211
+ Fenwick: () => FenwickCollection,
212
+ Flushable: () => FlushableCollection
213
+ });
214
+ // src/stillflow/state.ts
215
+ var State = class {
216
+ _state = /* @__PURE__ */ new Map();
217
+ write(path, value) {
218
+ this._state.set(path, value);
219
+ }
220
+ read(path) {
221
+ return this._state.get(path);
222
+ }
223
+ remove(path) {
224
+ this._state.delete(path);
225
+ }
226
+ };
227
+ // src/stillflow/compiler/compile.ts
228
+ function $CompileIR(source) {
229
+ const ir = {
230
+ refs: Object.create(null),
231
+ links: Object.create(null),
232
+ locals: Object.create(null),
233
+ backrefs: Object.create(null),
234
+ behaviors: Object.create(null)
235
+ };
236
+ for (const key in source) {
237
+ const operator = source[key];
238
+ switch (operator.type) {
239
+ case "is":
240
+ ir.behaviors[key] = operator.factory;
241
+ break;
242
+ case "ref":
243
+ ir.refs[key] = operator.path;
244
+ break;
245
+ case "link":
246
+ ir.links[key] = operator.source;
247
+ break;
248
+ case "local":
249
+ ir.locals[key] = operator.value;
250
+ break;
251
+ case "backref":
252
+ ir.backrefs[key] = operator.path;
253
+ break;
254
+ default: throw new Error(`Undefined operator '${operator}'`);
255
+ }
256
+ }
257
+ return ir;
258
+ }
259
+ function $ProcessBackrefs(kernel, source, view) {
260
+ for (const key in source.backrefs) kernel.write(source.backrefs[key], view[key]);
261
+ }
262
+ function $ProcessLocals(source, view) {
263
+ for (const key in source.locals) view[key] = source.locals[key];
264
+ }
265
+ function $ProcessLinks(kernel, source, view) {
266
+ for (const key in source.links) {
267
+ view[key] = view[key] || {};
268
+ $Process(kernel, source.links[key], view[key]);
269
+ }
270
+ }
271
+ function $ProcessRef(kernel, source, view) {
272
+ for (const key in source.refs) view[key] = kernel.read(source.refs[key]);
273
+ }
274
+ function $ProcessIs(source, view) {
275
+ for (const key in source.behaviors) view.meta.behaviors[key] = source.behaviors[key];
276
+ }
277
+ function $Process(kernel, source, view) {
278
+ view.meta = {
279
+ instantiated: false,
280
+ behaviors: Object.create(null),
281
+ source
282
+ };
283
+ $ProcessBackrefs(kernel, source, view);
284
+ $ProcessLocals(source, view);
285
+ $ProcessLinks(kernel, source, view);
286
+ $ProcessRef(kernel, source, view);
287
+ $ProcessIs(source, view);
288
+ }
289
+ function $ProcessWrite(kernel, source, view) {
290
+ $ProcessBackrefs(kernel, source, view);
291
+ $ProcessLinks(kernel, source, view);
292
+ }
293
+ function $ProcessRead(kernel, source, view) {
294
+ $ProcessRef(kernel, source, view);
295
+ $ProcessLinks(kernel, source, view);
296
+ }
297
+ function $Compile(kernel, source) {
298
+ const view = Object.create(null);
299
+ $Process(kernel, $CompileIR(source), view);
300
+ return view;
301
+ }
302
+ // src/stillflow/compiler/instantiate.ts
303
+ function $Instantiate(view, factories) {
304
+ function copy(view) {
305
+ return {
306
+ ...view,
307
+ meta: {
308
+ ...view.meta,
309
+ behaviors: { ...view.meta.behaviors }
310
+ }
311
+ };
312
+ }
313
+ function deepcopy(view, cache) {
314
+ if (cache.has(view)) return cache.get(view);
315
+ const instance = copy(view);
316
+ cache.set(view, instance);
317
+ for (const key in view.meta.source.links) instance[key] = deepcopy(view[key], cache);
318
+ return instance;
319
+ }
320
+ function instantiate(view, seen) {
321
+ if (seen.has(view) || view.meta.instantiated) return;
322
+ seen.add(view);
323
+ for (const key in view.meta.behaviors) view[key] = factories.get(view.meta.behaviors[key], view);
324
+ for (const key in view.meta.source.links) instantiate(view[key], seen);
325
+ view.meta.instantiated = true;
326
+ }
327
+ const instance = deepcopy(view, /* @__PURE__ */ new WeakMap());
328
+ instantiate(instance, /* @__PURE__ */ new Set());
329
+ return instance;
330
+ }
331
+ // src/stillflow/factories/factories.ts
332
+ var Factories = class Factories {
333
+ _parent;
334
+ _factories = /* @__PURE__ */ new Map();
335
+ constructor(_parent = null) {
336
+ this._parent = _parent;
337
+ }
338
+ add(type, factory) {
339
+ this._factories.set(type, factory);
340
+ }
341
+ get(type, view) {
342
+ const factory = this._factories.get(type);
343
+ if (factory === void 0) return this._parent?.get(type, view);
344
+ return factory(view, this);
345
+ }
346
+ make() {
347
+ return new Factories(this);
348
+ }
349
+ };
350
+ // src/stillflow/kernel/buffer.ts
351
+ var Buffer$1 = class {
352
+ _messages = /* @__PURE__ */ new Map();
353
+ constructor() {}
354
+ write(path, value) {
355
+ this._messages.set(path, value);
356
+ }
357
+ discard() {
358
+ this._messages.clear();
359
+ }
360
+ commit(state) {
361
+ for (const [path, value] of this._messages.entries()) state.write(path, value);
362
+ this._messages.clear();
363
+ }
364
+ };
365
+ // src/stillflow/kernel/signal.ts
366
+ var Signal = class {
367
+ _subscribers = /* @__PURE__ */ new Set();
368
+ subscribe(site) {
369
+ this._subscribers.add(site);
370
+ return () => this._subscribers.delete(site);
371
+ }
372
+ dispatch(payload) {
373
+ for (const subscriber of this._subscribers) subscriber(payload);
374
+ }
375
+ };
376
+ // src/stillflow/kernel/kernel.ts
377
+ var Kernel = class {
378
+ _state;
379
+ _before = new Signal();
380
+ _after = new Signal();
381
+ _commiting = false;
382
+ _additional = new Buffer$1();
383
+ _buffers = /* @__PURE__ */ new Set([this._additional]);
384
+ constructor(_state) {
385
+ this._state = _state;
386
+ }
387
+ bind(buffer) {
388
+ this._buffers.add(buffer);
389
+ return () => this._buffers.delete(buffer);
390
+ }
391
+ before(site) {
392
+ return this._before.subscribe(site);
393
+ }
394
+ after(site) {
395
+ return this._after.subscribe(site);
396
+ }
397
+ write(path, value) {
398
+ this._additional.write(path, value);
399
+ }
400
+ read(path) {
401
+ return this._state.read(path);
402
+ }
403
+ remove(path) {
404
+ this._state.remove(path);
405
+ }
406
+ commit() {
407
+ if (this._commiting) throw new Error(`Can not "kernel.commit()" within commit`);
408
+ this._commiting = true;
409
+ this._before.dispatch();
410
+ for (const buffer of this._buffers) buffer.commit(this._state);
411
+ this._after.dispatch();
412
+ this._commiting = false;
413
+ }
414
+ };
415
+ // src/stillflow/operators.ts
416
+ function ref(path) {
417
+ return {
418
+ type: "ref",
419
+ path
420
+ };
421
+ }
422
+ function backref(path) {
423
+ return {
424
+ type: "backref",
425
+ path
426
+ };
427
+ }
428
+ function local(value) {
429
+ return {
430
+ type: "local",
431
+ value
432
+ };
433
+ }
434
+ function link(source) {
435
+ return {
436
+ type: "link",
437
+ source
438
+ };
439
+ }
440
+ function is(factory) {
441
+ return {
442
+ type: "is",
443
+ factory
444
+ };
445
+ }
446
+ var operators_default = {
447
+ ref,
448
+ backref,
449
+ link,
450
+ local,
451
+ is
452
+ };
453
+ // src/stillflow/variable.ts
454
+ var Variable = class {
455
+ _kernel;
456
+ _key;
457
+ constructor(_kernel, _key) {
458
+ this._kernel = _kernel;
459
+ this._key = _key;
460
+ }
461
+ write(value) {
462
+ this._kernel.write(this._key, value);
463
+ }
464
+ read() {
465
+ return this._kernel.read(this._key);
466
+ }
467
+ remove() {
468
+ this._kernel.remove(this._key);
469
+ }
470
+ ref() {
471
+ return operators_default.ref(this._key);
472
+ }
473
+ backref() {
474
+ return operators_default.backref(this._key);
475
+ }
476
+ };
477
+ // src/stillflow/tools/batcher.ts
478
+ var Batcher = class {
479
+ _strategy;
480
+ _commiting = false;
481
+ _tasks = /* @__PURE__ */ new Set();
482
+ constructor(_strategy) {
483
+ this._strategy = _strategy;
484
+ }
485
+ task(task) {
486
+ this._tasks.add(task);
487
+ if (this._commiting) return;
488
+ this._commiting = true;
489
+ this._strategy(() => {
490
+ for (const task of this._tasks) task();
491
+ this._commiting = false;
492
+ });
493
+ }
494
+ };
495
+ // src/stillflow/stillflow.ts
496
+ var Stillflow = class {
497
+ _state;
498
+ _options;
499
+ _views = /* @__PURE__ */ new Set();
500
+ _kernel;
501
+ _batcher;
502
+ constructor(_state, _options = { strategy: (site) => site() }) {
503
+ this._state = _state;
504
+ this._options = _options;
505
+ this._kernel = new Kernel(this._state);
506
+ this._batcher = new Batcher(this._options.strategy);
507
+ this._kernel.before(() => {
508
+ for (const view of [...this._views]) $ProcessWrite(this._kernel, view.meta.source, view);
509
+ });
510
+ this._kernel.after(() => {
511
+ for (const view of [...this._views]) $ProcessRead(this._kernel, view.meta.source, view);
512
+ });
513
+ }
514
+ on(site) {
515
+ return this._kernel.after(site);
516
+ }
517
+ factory() {
518
+ return new Factories();
519
+ }
520
+ buffer() {
521
+ return new Buffer$1();
522
+ }
523
+ bind(buffer) {
524
+ this._kernel.bind(buffer);
525
+ }
526
+ compile(source) {
527
+ const view = $Compile(this._kernel, source);
528
+ this._views.add(view);
529
+ return view;
530
+ }
531
+ instantiate(source, factory) {
532
+ const view = $Instantiate(source, factory);
533
+ this._views.delete(source);
534
+ this._views.add(view);
535
+ return view;
536
+ }
537
+ commit() {
538
+ this._batcher.task(() => this._kernel.commit());
539
+ }
540
+ variable(path) {
541
+ return new Variable(this._kernel, path);
542
+ }
543
+ };
544
+ // src/stillflow/index.ts
545
+ var stillflow_exports = /* @__PURE__ */ __exportAll({
546
+ Batcher: () => Batcher,
547
+ State: () => State,
548
+ Stillflow: () => Stillflow
549
+ });
550
+ // src/stillflow-vite/runtime/jsx.dom.ts
551
+ var jsx_dom_exports = /* @__PURE__ */ __exportAll({
552
+ $: () => $,
553
+ jsxdom: () => jsxdom
554
+ });
555
+ var jsxdom = Object.create(null);
556
+ var $ = (() => {});
557
+ export { stillflow_collection_exports as collections, stillflow_exports as core, operators_default as operators, jsx_dom_exports as runtime };
@@ -0,0 +1,42 @@
1
+ // \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __exportAll = (all, no_symbols) => {
9
+ let target = {};
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
+ return target;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
+ key = keys[i];
20
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
+ get: ((k) => from[k]).bind(null, key),
22
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
+ });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ Object.defineProperty(exports, "__exportAll", {
32
+ enumerable: true,
33
+ get: function() {
34
+ return __exportAll;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "__toESM", {
38
+ enumerable: true,
39
+ get: function() {
40
+ return __toESM;
41
+ }
42
+ });
@@ -1,4 +1,4 @@
1
- import { IR } from "./IR.js";
1
+ import { IR } from './IR.js';
2
2
  export type Meta = {
3
3
  meta: {
4
4
  instantiated: boolean;
@@ -1,5 +1,5 @@
1
- import { Meta } from "./meta.js";
2
- import { Backref, Link, Local, Ref } from "./operators.js";
1
+ import { Meta } from './meta.js';
2
+ import { Backref, Link, Local, Ref } from './operators.js';
3
3
  type Mapping = Record<string, any>;
4
4
  type OperatorView<V extends Mapping, T extends Mapping, K extends keyof V> = V[K] extends Ref<T, infer K0> ? T[K0] : V[K] extends Backref<T, infer K1> ? T[K1] : V[K] extends Local<infer K2> ? K2 : V[K] extends Link<infer K3> ? View<K3, T> : any;
5
5
  export type View<V extends Mapping, T extends Mapping> = Meta & {
@@ -1,8 +1,8 @@
1
- import { Backref, Is, Link, Local, Ref } from "../abstracts/operators.js";
2
- import { Kernel } from "../kernel/kernel.js";
3
- import { IR } from "../abstracts/IR.js";
4
- import { Meta } from "../abstracts/meta.js";
5
- import { View } from "../abstracts/view.js";
1
+ import { Backref, Is, Link, Local, Ref } from '../abstracts/operators.js';
2
+ import { Kernel } from '../kernel/kernel.js';
3
+ import { IR } from '../abstracts/IR.js';
4
+ import { Meta } from '../abstracts/meta.js';
5
+ import { View } from '../abstracts/view.js';
6
6
  type Mapping = Record<string, any>;
7
7
  type Source = Record<string, Link<any> | Ref<any, any> | Backref<any, any> | Local<any> | Is>;
8
8
  export declare function $ProcessWrite<T extends Mapping>(kernel: Kernel<T>, source: IR, view: Mapping): void;
@@ -1,3 +1,3 @@
1
- import { Meta } from "../abstracts/meta.js";
2
- import { Factories } from "../factories/factories.js";
1
+ import { Meta } from '../abstracts/meta.js';
2
+ import { Factories } from '../factories/factories.js';
3
3
  export declare function $Instantiate<V extends Meta>(view: V, factories: Factories): Meta;
@@ -1,5 +1,5 @@
1
1
  export { State } from './state.js';
2
- export { AbstractState as Abstract } from './abstracts/state.js';
3
2
  export { Stillflow } from './stillflow.js';
4
3
  export { Batcher } from './tools/batcher.js';
5
- export { type Buffer } from './kernel/buffer.js';
4
+ export type { Buffer } from './kernel/buffer.js';
5
+ export type { AbstractState as Abstract } from './abstracts/state.js';
@@ -1,4 +1,4 @@
1
- import { AbstractState } from "../abstracts/state.js";
1
+ import { AbstractState } from '../abstracts/state.js';
2
2
  type Mapping = Record<string, any>;
3
3
  export declare class Buffer<T extends Mapping = Mapping> {
4
4
  private _messages;
@@ -1,5 +1,5 @@
1
- import { Buffer } from "./buffer.js";
2
- import { AbstractState } from "../abstracts/state.js";
1
+ import { Buffer } from './buffer.js';
2
+ import { AbstractState } from '../abstracts/state.js';
3
3
  type Mapping = Record<string, any>;
4
4
  export declare class Kernel<T extends Mapping = Mapping> implements AbstractState<T> {
5
5
  private _state;
@@ -1,4 +1,4 @@
1
- import { Backref, Is, Link, Local, Ref } from "./abstracts/operators.js";
1
+ import { Backref, Is, Link, Local, Ref } from './abstracts/operators.js';
2
2
  type Mapping = Record<string, any>;
3
3
  declare function ref<T extends Mapping, K extends keyof T>(path: K): Ref<T, K>;
4
4
  declare function backref<T extends Mapping, K extends keyof T>(path: K): Backref<T, K>;
@@ -1,4 +1,4 @@
1
- import { AbstractState } from "./abstracts/state.js";
1
+ import { AbstractState } from './abstracts/state.js';
2
2
  type Mapping = Record<string, any>;
3
3
  export declare class State<T extends Mapping = Mapping> implements AbstractState<T> {
4
4
  private _state;
@@ -1,9 +1,9 @@
1
- import { Meta } from "./abstracts/meta.js";
2
- import { AbstractState } from "./abstracts/state.js";
3
- import { View } from "./abstracts/view.js";
4
- import { Factories } from "./factories/factories.js";
5
- import { Buffer } from "./kernel/buffer.js";
6
- import { Variable } from "./variable.js";
1
+ import { Meta } from './abstracts/meta.js';
2
+ import { AbstractState } from './abstracts/state.js';
3
+ import { View } from './abstracts/view.js';
4
+ import { Factories } from './factories/factories.js';
5
+ import { Buffer } from './kernel/buffer.js';
6
+ import { Variable } from './variable.js';
7
7
  type Mapping = Record<string, any>;
8
8
  type Options = {
9
9
  strategy: (site: () => void) => void;
@@ -1,5 +1,5 @@
1
- import { Backref, Ref } from "./abstracts/operators.js";
2
- import { Kernel } from "./kernel/kernel.js";
1
+ import { Backref, Ref } from './abstracts/operators.js';
2
+ import { Kernel } from './kernel/kernel.js';
3
3
  export declare class Variable<T extends Record<string, any>, P extends keyof T> {
4
4
  private _kernel;
5
5
  private _key;