@skygraph/core 0.0.0-placeholder.0 → 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 (70) hide show
  1. package/LICENSE +21 -0
  2. package/dist/calendar.cjs +404 -0
  3. package/dist/calendar.cjs.map +1 -0
  4. package/dist/calendar.d.cts +209 -0
  5. package/dist/calendar.d.ts +209 -0
  6. package/dist/calendar.js +12 -0
  7. package/dist/calendar.js.map +1 -0
  8. package/dist/chunk-5CCD5Q4B.js +36 -0
  9. package/dist/chunk-5CCD5Q4B.js.map +1 -0
  10. package/dist/chunk-AB3RLBLW.js +357 -0
  11. package/dist/chunk-AB3RLBLW.js.map +1 -0
  12. package/dist/chunk-GEMALROQ.js +258 -0
  13. package/dist/chunk-GEMALROQ.js.map +1 -0
  14. package/dist/chunk-IY6LJU3L.js +256 -0
  15. package/dist/chunk-IY6LJU3L.js.map +1 -0
  16. package/dist/chunk-KMGRNPLG.js +453 -0
  17. package/dist/chunk-KMGRNPLG.js.map +1 -0
  18. package/dist/chunk-KP75DEA4.js +1012 -0
  19. package/dist/chunk-KP75DEA4.js.map +1 -0
  20. package/dist/chunk-Y7FTBBYX.js +397 -0
  21. package/dist/chunk-Y7FTBBYX.js.map +1 -0
  22. package/dist/chunk-ZWB7JGAJ.js +488 -0
  23. package/dist/chunk-ZWB7JGAJ.js.map +1 -0
  24. package/dist/form.cjs +498 -0
  25. package/dist/form.cjs.map +1 -0
  26. package/dist/form.d.cts +130 -0
  27. package/dist/form.d.ts +130 -0
  28. package/dist/form.js +8 -0
  29. package/dist/form.js.map +1 -0
  30. package/dist/graph.cjs +1065 -0
  31. package/dist/graph.cjs.map +1 -0
  32. package/dist/graph.d.cts +542 -0
  33. package/dist/graph.d.ts +542 -0
  34. package/dist/graph.js +24 -0
  35. package/dist/graph.js.map +1 -0
  36. package/dist/index.cjs +3656 -0
  37. package/dist/index.cjs.map +1 -0
  38. package/dist/index.d.cts +144 -0
  39. package/dist/index.d.ts +144 -0
  40. package/dist/index.js +467 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/runtime-internal.cjs +339 -0
  43. package/dist/runtime-internal.cjs.map +1 -0
  44. package/dist/runtime-internal.d.cts +130 -0
  45. package/dist/runtime-internal.d.ts +130 -0
  46. package/dist/runtime-internal.js +67 -0
  47. package/dist/runtime-internal.js.map +1 -0
  48. package/dist/table.cjs +537 -0
  49. package/dist/table.cjs.map +1 -0
  50. package/dist/table.d.cts +215 -0
  51. package/dist/table.d.ts +215 -0
  52. package/dist/table.js +16 -0
  53. package/dist/table.js.map +1 -0
  54. package/dist/tree.cjs +442 -0
  55. package/dist/tree.cjs.map +1 -0
  56. package/dist/tree.d.cts +76 -0
  57. package/dist/tree.d.ts +76 -0
  58. package/dist/tree.js +8 -0
  59. package/dist/tree.js.map +1 -0
  60. package/dist/types-B-rKQJ4R.d.cts +35 -0
  61. package/dist/types-B-rKQJ4R.d.ts +35 -0
  62. package/dist/virtual.cjs +283 -0
  63. package/dist/virtual.cjs.map +1 -0
  64. package/dist/virtual.d.cts +96 -0
  65. package/dist/virtual.d.ts +96 -0
  66. package/dist/virtual.js +9 -0
  67. package/dist/virtual.js.map +1 -0
  68. package/package.json +98 -18
  69. package/README.md +0 -12
  70. package/index.js +0 -3
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/runtime-internal.ts
21
+ var runtime_internal_exports = {};
22
+ __export(runtime_internal_exports, {
23
+ Batch: () => Batch,
24
+ ComputedEngine: () => ComputedEngine,
25
+ CycleDetector: () => CycleDetector,
26
+ Scheduler: () => Scheduler,
27
+ Store: () => Store,
28
+ SubscriptionEngine: () => SubscriptionEngine,
29
+ Transaction: () => Transaction,
30
+ createNode: () => createNode
31
+ });
32
+ module.exports = __toCommonJS(runtime_internal_exports);
33
+
34
+ // src/runtime/Node.ts
35
+ function createNode(id, value) {
36
+ return { id, value, version: 0 };
37
+ }
38
+
39
+ // src/runtime/Store.ts
40
+ var Store = class {
41
+ nodes = /* @__PURE__ */ new Map();
42
+ has(path) {
43
+ return this.nodes.has(path);
44
+ }
45
+ get(path) {
46
+ return this.nodes.get(path)?.value;
47
+ }
48
+ getNode(path) {
49
+ return this.nodes.get(path);
50
+ }
51
+ set(path, value) {
52
+ let node = this.nodes.get(path);
53
+ if (node) {
54
+ node.value = value;
55
+ node.version++;
56
+ return node;
57
+ }
58
+ node = createNode(path, value);
59
+ this.nodes.set(path, node);
60
+ return node;
61
+ }
62
+ delete(path) {
63
+ return this.nodes.delete(path);
64
+ }
65
+ paths() {
66
+ return this.nodes.keys();
67
+ }
68
+ size() {
69
+ return this.nodes.size;
70
+ }
71
+ };
72
+
73
+ // src/runtime/SubscriptionEngine.ts
74
+ var SubscriptionEngine = class {
75
+ listeners = /* @__PURE__ */ new Map();
76
+ subscribe(path, cb) {
77
+ let set = this.listeners.get(path);
78
+ if (!set) {
79
+ set = /* @__PURE__ */ new Set();
80
+ this.listeners.set(path, set);
81
+ }
82
+ set.add(cb);
83
+ return () => {
84
+ set.delete(cb);
85
+ if (set.size === 0) {
86
+ this.listeners.delete(path);
87
+ }
88
+ };
89
+ }
90
+ notify(path, value) {
91
+ const set = this.listeners.get(path);
92
+ if (!set) return;
93
+ for (const cb of set) {
94
+ cb(value);
95
+ }
96
+ }
97
+ notifyMany(changes) {
98
+ for (const [path, value] of changes) {
99
+ this.notify(path, value);
100
+ }
101
+ }
102
+ hasListeners(path) {
103
+ const set = this.listeners.get(path);
104
+ return set !== void 0 && set.size > 0;
105
+ }
106
+ clear() {
107
+ this.listeners.clear();
108
+ }
109
+ };
110
+
111
+ // src/runtime/Batch.ts
112
+ var Batch = class {
113
+ depth = 0;
114
+ pending = /* @__PURE__ */ new Map();
115
+ get isActive() {
116
+ return this.depth > 0;
117
+ }
118
+ start() {
119
+ this.depth++;
120
+ }
121
+ end() {
122
+ this.depth--;
123
+ if (this.depth > 0) return null;
124
+ if (this.pending.size === 0) return null;
125
+ const changes = new Map(this.pending);
126
+ this.pending.clear();
127
+ return changes;
128
+ }
129
+ enqueue(path, value) {
130
+ this.pending.set(path, value);
131
+ }
132
+ };
133
+
134
+ // src/runtime/Transaction.ts
135
+ var Transaction = class {
136
+ active = false;
137
+ staged = [];
138
+ get isActive() {
139
+ return this.active;
140
+ }
141
+ start() {
142
+ if (this.active) {
143
+ throw new Error("SkyGraph: nested transactions are not supported");
144
+ }
145
+ this.active = true;
146
+ this.staged = [];
147
+ }
148
+ /** STAGE: record a write without mutating the store */
149
+ stage(path, value, prevValue) {
150
+ this.staged.push({ path, value, prevValue });
151
+ }
152
+ /**
153
+ * RESOLVE + COMMIT: drop unchanged values, apply the rest to store.
154
+ * Returns the map of actually changed paths and their new values.
155
+ */
156
+ commit(store) {
157
+ const changes = /* @__PURE__ */ new Map();
158
+ for (const write of this.staged) {
159
+ if (Object.is(write.value, write.prevValue)) continue;
160
+ store.set(write.path, write.value);
161
+ changes.set(write.path, write.value);
162
+ }
163
+ this.active = false;
164
+ this.staged = [];
165
+ return changes;
166
+ }
167
+ getStaged() {
168
+ return this.staged;
169
+ }
170
+ complete() {
171
+ this.active = false;
172
+ this.staged = [];
173
+ }
174
+ rollback() {
175
+ this.active = false;
176
+ this.staged = [];
177
+ }
178
+ };
179
+
180
+ // src/runtime/CycleDetector.ts
181
+ var CycleDetector = class {
182
+ graph = /* @__PURE__ */ new Map();
183
+ addEdge(from, to) {
184
+ let deps = this.graph.get(from);
185
+ if (!deps) {
186
+ deps = /* @__PURE__ */ new Set();
187
+ this.graph.set(from, deps);
188
+ }
189
+ deps.add(to);
190
+ if (this.hasCycle(to, /* @__PURE__ */ new Set([from]))) {
191
+ deps.delete(to);
192
+ if (deps.size === 0) this.graph.delete(from);
193
+ throw new Error(
194
+ `SkyGraph: circular dependency detected: ${from} -> ${to}`
195
+ );
196
+ }
197
+ }
198
+ removeNode(id) {
199
+ this.graph.delete(id);
200
+ for (const deps of this.graph.values()) {
201
+ deps.delete(id);
202
+ }
203
+ }
204
+ getDependents(id) {
205
+ const targets = this.graph.get(id);
206
+ return targets ? [...targets] : [];
207
+ }
208
+ hasCycle(node, visited) {
209
+ if (visited.has(node)) return true;
210
+ const deps = this.graph.get(node);
211
+ if (!deps) return false;
212
+ visited.add(node);
213
+ for (const dep of deps) {
214
+ if (this.hasCycle(dep, new Set(visited))) return true;
215
+ }
216
+ return false;
217
+ }
218
+ };
219
+
220
+ // src/runtime/ComputedEngine.ts
221
+ var ComputedEngine = class {
222
+ computedNodes = /* @__PURE__ */ new Map();
223
+ cycleDetector = new CycleDetector();
224
+ register(target, deps, fn) {
225
+ if (this.computedNodes.has(target)) {
226
+ this.remove(target);
227
+ }
228
+ for (const dep of deps) {
229
+ this.cycleDetector.addEdge(dep, target);
230
+ }
231
+ this.computedNodes.set(target, { target, deps, fn });
232
+ }
233
+ remove(target) {
234
+ this.computedNodes.delete(target);
235
+ this.cycleDetector.removeNode(target);
236
+ }
237
+ isComputed(path) {
238
+ return this.computedNodes.has(path);
239
+ }
240
+ /**
241
+ * Like propagate, but returns both new and old values for middleware support.
242
+ * Does NOT write to the store — the caller handles that via dispatchWrite.
243
+ */
244
+ propagateRaw(changedPaths, store) {
245
+ const result = /* @__PURE__ */ new Map();
246
+ const visited = /* @__PURE__ */ new Set();
247
+ const queue = [...changedPaths];
248
+ while (queue.length > 0) {
249
+ const path = queue.shift();
250
+ if (visited.has(path)) continue;
251
+ visited.add(path);
252
+ const dependents = this.cycleDetector.getDependents(path);
253
+ for (const depTarget of dependents) {
254
+ const computed = this.computedNodes.get(depTarget);
255
+ if (!computed) continue;
256
+ const depValues = computed.deps.map((d) => {
257
+ const pending = result.get(d);
258
+ return pending ? pending.value : store.get(d);
259
+ });
260
+ const newValue = computed.fn(...depValues);
261
+ const oldValue = result.has(depTarget) ? result.get(depTarget).oldValue : store.get(depTarget);
262
+ if (!Object.is(newValue, oldValue)) {
263
+ result.set(depTarget, { value: newValue, oldValue });
264
+ queue.push(depTarget);
265
+ }
266
+ }
267
+ }
268
+ return result;
269
+ }
270
+ /**
271
+ * Initialize all computed values based on current store state.
272
+ */
273
+ initializeAll(store) {
274
+ for (const computed of this.computedNodes.values()) {
275
+ const depValues = computed.deps.map((d) => store.get(d));
276
+ const value = computed.fn(...depValues);
277
+ store.set(computed.target, value);
278
+ }
279
+ }
280
+ };
281
+
282
+ // src/runtime/Scheduler.ts
283
+ var Scheduler = class {
284
+ microQueue = [];
285
+ macroQueue = [];
286
+ renderQueue = [];
287
+ renderScheduled = false;
288
+ enqueueMicro(task) {
289
+ this.microQueue.push(task);
290
+ }
291
+ enqueueMacro(task) {
292
+ this.macroQueue.push(task);
293
+ queueMicrotask(() => this.flushMacro());
294
+ }
295
+ enqueueRender(task) {
296
+ this.renderQueue.push(task);
297
+ if (!this.renderScheduled) {
298
+ this.renderScheduled = true;
299
+ if (typeof requestAnimationFrame !== "undefined") {
300
+ requestAnimationFrame(() => this.flushRender());
301
+ } else {
302
+ queueMicrotask(() => this.flushRender());
303
+ }
304
+ }
305
+ }
306
+ flushMicro() {
307
+ while (this.microQueue.length > 0) {
308
+ const task = this.microQueue.shift();
309
+ task();
310
+ }
311
+ }
312
+ flushMacro() {
313
+ const tasks = [...this.macroQueue];
314
+ this.macroQueue = [];
315
+ for (const task of tasks) {
316
+ task();
317
+ }
318
+ }
319
+ flushRender() {
320
+ this.renderScheduled = false;
321
+ const tasks = [...this.renderQueue];
322
+ this.renderQueue = [];
323
+ for (const task of tasks) {
324
+ task();
325
+ }
326
+ }
327
+ };
328
+ // Annotate the CommonJS export names for ESM import in node:
329
+ 0 && (module.exports = {
330
+ Batch,
331
+ ComputedEngine,
332
+ CycleDetector,
333
+ Scheduler,
334
+ Store,
335
+ SubscriptionEngine,
336
+ Transaction,
337
+ createNode
338
+ });
339
+ //# sourceMappingURL=runtime-internal.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime-internal.ts","../src/runtime/Node.ts","../src/runtime/Store.ts","../src/runtime/SubscriptionEngine.ts","../src/runtime/Batch.ts","../src/runtime/Transaction.ts","../src/runtime/CycleDetector.ts","../src/runtime/ComputedEngine.ts","../src/runtime/Scheduler.ts"],"sourcesContent":["/**\r\n * @internal — runtime primitives for engine authors\r\n *\r\n * This entry point exposes low-level runtime building blocks (Store,\r\n * SubscriptionEngine, Batch, Transaction, ComputedEngine, Scheduler). It is\r\n * intended for authors of custom engines who need primitives beyond what the\r\n * public `Core` interface provides.\r\n *\r\n * STABILITY: these exports are NOT part of the semver-stable public API.\r\n * Signatures may change between minor versions. Production code should prefer\r\n * the main `@skygraph/core` entry point and the `Core` interface.\r\n *\r\n * The runtime MUST NOT import from `engines/*`. If a future change requires\r\n * runtime to know about engine categories, that is an architecture violation\r\n * — push the feature into middleware or a dedicated extension surface.\r\n */\r\nexport {\r\n Store,\r\n createNode,\r\n SubscriptionEngine,\r\n Batch,\r\n Transaction,\r\n ComputedEngine,\r\n CycleDetector,\r\n Scheduler,\r\n} from './runtime/index'\r\n\r\nexport type {\r\n Node,\r\n Listener,\r\n Unsubscribe,\r\n StagedWrite,\r\n ComputeFn,\r\n Task,\r\n} from './runtime/index'\r\n","export interface Node {\n readonly id: string\n value: unknown\n version: number\n}\n\nexport function createNode(id: string, value: unknown): Node {\n return { id, value, version: 0 }\n}\n","import { createNode } from './Node'\nimport type { Node } from './Node'\n\nexport class Store {\n private nodes: Map<string, Node> = new Map()\n\n has(path: string): boolean {\n return this.nodes.has(path)\n }\n\n get(path: string): unknown {\n return this.nodes.get(path)?.value\n }\n\n getNode(path: string): Node | undefined {\n return this.nodes.get(path)\n }\n\n set(path: string, value: unknown): Node {\n let node = this.nodes.get(path)\n if (node) {\n node.value = value\n node.version++\n return node\n }\n node = createNode(path, value)\n this.nodes.set(path, node)\n return node\n }\n\n delete(path: string): boolean {\n return this.nodes.delete(path)\n }\n\n paths(): IterableIterator<string> {\n return this.nodes.keys()\n }\n\n size(): number {\n return this.nodes.size\n }\n}\n","export type Listener = (value: unknown) => void\nexport type Unsubscribe = () => void\n\nexport class SubscriptionEngine {\n private listeners: Map<string, Set<Listener>> = new Map()\n\n subscribe(path: string, cb: Listener): Unsubscribe {\n let set = this.listeners.get(path)\n if (!set) {\n set = new Set()\n this.listeners.set(path, set)\n }\n set.add(cb)\n\n return () => {\n set!.delete(cb)\n if (set!.size === 0) {\n this.listeners.delete(path)\n }\n }\n }\n\n notify(path: string, value: unknown): void {\n const set = this.listeners.get(path)\n if (!set) return\n for (const cb of set) {\n cb(value)\n }\n }\n\n notifyMany(changes: Map<string, unknown>): void {\n for (const [path, value] of changes) {\n this.notify(path, value)\n }\n }\n\n hasListeners(path: string): boolean {\n const set = this.listeners.get(path)\n return set !== undefined && set.size > 0\n }\n\n clear(): void {\n this.listeners.clear()\n }\n}\n","/**\n * Batch collects path changes during a batch callback\n * and defers notifications until the callback completes.\n */\nexport class Batch {\n private depth = 0\n private pending: Map<string, unknown> = new Map()\n\n get isActive(): boolean {\n return this.depth > 0\n }\n\n start(): void {\n this.depth++\n }\n\n end(): Map<string, unknown> | null {\n this.depth--\n if (this.depth > 0) return null\n\n if (this.pending.size === 0) return null\n\n const changes = new Map(this.pending)\n this.pending.clear()\n return changes\n }\n\n enqueue(path: string, value: unknown): void {\n this.pending.set(path, value)\n }\n}\n","import type { Store } from './Store'\n\nexport interface StagedWrite {\n path: string\n value: unknown\n prevValue: unknown\n}\n\n/**\n * Transaction implements the pipeline:\n * SET -> STAGE -> RESOLVE -> PROPAGATE -> COMMIT -> NOTIFY\n *\n * PROPAGATE is handled externally by ComputedEngine.\n * NOTIFY is handled externally by SubscriptionEngine via Batch.\n */\nexport class Transaction {\n private active = false\n private staged: StagedWrite[] = []\n\n get isActive(): boolean {\n return this.active\n }\n\n start(): void {\n if (this.active) {\n throw new Error('SkyGraph: nested transactions are not supported')\n }\n this.active = true\n this.staged = []\n }\n\n /** STAGE: record a write without mutating the store */\n stage(path: string, value: unknown, prevValue: unknown): void {\n this.staged.push({ path, value, prevValue })\n }\n\n /**\n * RESOLVE + COMMIT: drop unchanged values, apply the rest to store.\n * Returns the map of actually changed paths and their new values.\n */\n commit(store: Store): Map<string, unknown> {\n const changes = new Map<string, unknown>()\n\n for (const write of this.staged) {\n if (Object.is(write.value, write.prevValue)) continue\n store.set(write.path, write.value)\n changes.set(write.path, write.value)\n }\n\n this.active = false\n this.staged = []\n return changes\n }\n\n getStaged(): readonly StagedWrite[] {\n return this.staged\n }\n\n complete(): void {\n this.active = false\n this.staged = []\n }\n\n rollback(): void {\n this.active = false\n this.staged = []\n }\n}\n","/**\n * Detects cycles in the computed dependency graph using DFS.\n * Throws on cycle detection to prevent infinite recomputation.\n */\nexport class CycleDetector {\n private graph: Map<string, Set<string>> = new Map()\n\n addEdge(from: string, to: string): void {\n let deps = this.graph.get(from)\n if (!deps) {\n deps = new Set()\n this.graph.set(from, deps)\n }\n deps.add(to)\n\n if (this.hasCycle(to, new Set([from]))) {\n deps.delete(to)\n if (deps.size === 0) this.graph.delete(from)\n throw new Error(\n `SkyGraph: circular dependency detected: ${from} -> ${to}`\n )\n }\n }\n\n removeNode(id: string): void {\n this.graph.delete(id)\n for (const deps of this.graph.values()) {\n deps.delete(id)\n }\n }\n\n getDependents(id: string): string[] {\n const targets = this.graph.get(id)\n return targets ? [...targets] : []\n }\n\n private hasCycle(node: string, visited: Set<string>): boolean {\n if (visited.has(node)) return true\n const deps = this.graph.get(node)\n if (!deps) return false\n visited.add(node)\n for (const dep of deps) {\n if (this.hasCycle(dep, new Set(visited))) return true\n }\n return false\n }\n}\n","import { CycleDetector } from './CycleDetector'\nimport type { Store } from './Store'\n\nexport type ComputeFn = (...values: unknown[]) => unknown\n\ninterface ComputedNode {\n target: string\n deps: string[]\n fn: ComputeFn\n}\n\n/**\n * Manages computed (derived) values in the reactive graph.\n * When a dependency changes, the computed value is recomputed\n * and only propagated if the result actually changed.\n */\nexport class ComputedEngine {\n private computedNodes: Map<string, ComputedNode> = new Map()\n private cycleDetector = new CycleDetector()\n\n register(target: string, deps: string[], fn: ComputeFn): void {\n if (this.computedNodes.has(target)) {\n this.remove(target)\n }\n\n for (const dep of deps) {\n this.cycleDetector.addEdge(dep, target)\n }\n\n this.computedNodes.set(target, { target, deps, fn })\n }\n\n remove(target: string): void {\n this.computedNodes.delete(target)\n this.cycleDetector.removeNode(target)\n }\n\n isComputed(path: string): boolean {\n return this.computedNodes.has(path)\n }\n\n /**\n * Like propagate, but returns both new and old values for middleware support.\n * Does NOT write to the store — the caller handles that via dispatchWrite.\n */\n propagateRaw(\n changedPaths: Set<string>,\n store: Store,\n ): Map<string, { value: unknown; oldValue: unknown }> {\n const result = new Map<string, { value: unknown; oldValue: unknown }>()\n const visited = new Set<string>()\n const queue = [...changedPaths]\n\n while (queue.length > 0) {\n const path = queue.shift()!\n if (visited.has(path)) continue\n visited.add(path)\n\n const dependents = this.cycleDetector.getDependents(path)\n\n for (const depTarget of dependents) {\n const computed = this.computedNodes.get(depTarget)\n if (!computed) continue\n\n const depValues = computed.deps.map((d) => {\n const pending = result.get(d)\n return pending ? pending.value : store.get(d)\n })\n const newValue = computed.fn(...depValues)\n const oldValue = result.has(depTarget)\n ? result.get(depTarget)!.oldValue\n : store.get(depTarget)\n\n if (!Object.is(newValue, oldValue)) {\n result.set(depTarget, { value: newValue, oldValue })\n queue.push(depTarget)\n }\n }\n }\n\n return result\n }\n\n /**\n * Initialize all computed values based on current store state.\n */\n initializeAll(store: Store): void {\n for (const computed of this.computedNodes.values()) {\n const depValues = computed.deps.map((d) => store.get(d))\n const value = computed.fn(...depValues)\n store.set(computed.target, value)\n }\n }\n}\n","export type Task = () => void\n\n/**\n * Scheduler manages different priority queues for updates.\n * - micro: synchronous, within current transaction\n * - macro: deferred async effects (validation, server sync)\n * - render: batched UI notifications (grouped per frame)\n */\nexport class Scheduler {\n private microQueue: Task[] = []\n private macroQueue: Task[] = []\n private renderQueue: Task[] = []\n private renderScheduled = false\n\n enqueueMicro(task: Task): void {\n this.microQueue.push(task)\n }\n\n enqueueMacro(task: Task): void {\n this.macroQueue.push(task)\n queueMicrotask(() => this.flushMacro())\n }\n\n enqueueRender(task: Task): void {\n this.renderQueue.push(task)\n if (!this.renderScheduled) {\n this.renderScheduled = true\n if (typeof requestAnimationFrame !== 'undefined') {\n requestAnimationFrame(() => this.flushRender())\n } else {\n queueMicrotask(() => this.flushRender())\n }\n }\n }\n\n flushMicro(): void {\n while (this.microQueue.length > 0) {\n const task = this.microQueue.shift()!\n task()\n }\n }\n\n private flushMacro(): void {\n const tasks = [...this.macroQueue]\n this.macroQueue = []\n for (const task of tasks) {\n task()\n }\n }\n\n private flushRender(): void {\n this.renderScheduled = false\n const tasks = [...this.renderQueue]\n this.renderQueue = []\n for (const task of tasks) {\n task()\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,SAAS,WAAW,IAAY,OAAsB;AAC3D,SAAO,EAAE,IAAI,OAAO,SAAS,EAAE;AACjC;;;ACLO,IAAM,QAAN,MAAY;AAAA,EACT,QAA2B,oBAAI,IAAI;AAAA,EAE3C,IAAI,MAAuB;AACzB,WAAO,KAAK,MAAM,IAAI,IAAI;AAAA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AEA,aAAmB;AACjB,WAAO,KAAK,WAAW,SAAS,GAAG;AACjC,YAAM,OAAO,KAAK,WAAW,MAAM;AACnC,WAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEQ,aAAmB;AACzB,UAAM,QAAQ,CAAC,GAAG,KAAK,UAAU;AACjC,SAAK,aAAa,CAAC;AACnB,eAAW,QAAQ,OAAO;AACxB,WAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEQ,cAAoB;AAC1B,SAAK,kBAAkB;AACvB,UAAM,QAAQ,CAAC,GAAG,KAAK,WAAW;AAClC,SAAK,cAAc,CAAC;AACpB,eAAW,QAAQ,OAAO;AACxB,WAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,130 @@
1
+ interface Node {
2
+ readonly id: string;
3
+ value: unknown;
4
+ version: number;
5
+ }
6
+ declare function createNode(id: string, value: unknown): Node;
7
+
8
+ declare class Store {
9
+ private nodes;
10
+ has(path: string): boolean;
11
+ get(path: string): unknown;
12
+ getNode(path: string): Node | undefined;
13
+ set(path: string, value: unknown): Node;
14
+ delete(path: string): boolean;
15
+ paths(): IterableIterator<string>;
16
+ size(): number;
17
+ }
18
+
19
+ type Listener = (value: unknown) => void;
20
+ type Unsubscribe = () => void;
21
+ declare class SubscriptionEngine {
22
+ private listeners;
23
+ subscribe(path: string, cb: Listener): Unsubscribe;
24
+ notify(path: string, value: unknown): void;
25
+ notifyMany(changes: Map<string, unknown>): void;
26
+ hasListeners(path: string): boolean;
27
+ clear(): void;
28
+ }
29
+
30
+ /**
31
+ * Batch collects path changes during a batch callback
32
+ * and defers notifications until the callback completes.
33
+ */
34
+ declare class Batch {
35
+ private depth;
36
+ private pending;
37
+ get isActive(): boolean;
38
+ start(): void;
39
+ end(): Map<string, unknown> | null;
40
+ enqueue(path: string, value: unknown): void;
41
+ }
42
+
43
+ interface StagedWrite {
44
+ path: string;
45
+ value: unknown;
46
+ prevValue: unknown;
47
+ }
48
+ /**
49
+ * Transaction implements the pipeline:
50
+ * SET -> STAGE -> RESOLVE -> PROPAGATE -> COMMIT -> NOTIFY
51
+ *
52
+ * PROPAGATE is handled externally by ComputedEngine.
53
+ * NOTIFY is handled externally by SubscriptionEngine via Batch.
54
+ */
55
+ declare class Transaction {
56
+ private active;
57
+ private staged;
58
+ get isActive(): boolean;
59
+ start(): void;
60
+ /** STAGE: record a write without mutating the store */
61
+ stage(path: string, value: unknown, prevValue: unknown): void;
62
+ /**
63
+ * RESOLVE + COMMIT: drop unchanged values, apply the rest to store.
64
+ * Returns the map of actually changed paths and their new values.
65
+ */
66
+ commit(store: Store): Map<string, unknown>;
67
+ getStaged(): readonly StagedWrite[];
68
+ complete(): void;
69
+ rollback(): void;
70
+ }
71
+
72
+ type ComputeFn = (...values: unknown[]) => unknown;
73
+ /**
74
+ * Manages computed (derived) values in the reactive graph.
75
+ * When a dependency changes, the computed value is recomputed
76
+ * and only propagated if the result actually changed.
77
+ */
78
+ declare class ComputedEngine {
79
+ private computedNodes;
80
+ private cycleDetector;
81
+ register(target: string, deps: string[], fn: ComputeFn): void;
82
+ remove(target: string): void;
83
+ isComputed(path: string): boolean;
84
+ /**
85
+ * Like propagate, but returns both new and old values for middleware support.
86
+ * Does NOT write to the store — the caller handles that via dispatchWrite.
87
+ */
88
+ propagateRaw(changedPaths: Set<string>, store: Store): Map<string, {
89
+ value: unknown;
90
+ oldValue: unknown;
91
+ }>;
92
+ /**
93
+ * Initialize all computed values based on current store state.
94
+ */
95
+ initializeAll(store: Store): void;
96
+ }
97
+
98
+ /**
99
+ * Detects cycles in the computed dependency graph using DFS.
100
+ * Throws on cycle detection to prevent infinite recomputation.
101
+ */
102
+ declare class CycleDetector {
103
+ private graph;
104
+ addEdge(from: string, to: string): void;
105
+ removeNode(id: string): void;
106
+ getDependents(id: string): string[];
107
+ private hasCycle;
108
+ }
109
+
110
+ type Task = () => void;
111
+ /**
112
+ * Scheduler manages different priority queues for updates.
113
+ * - micro: synchronous, within current transaction
114
+ * - macro: deferred async effects (validation, server sync)
115
+ * - render: batched UI notifications (grouped per frame)
116
+ */
117
+ declare class Scheduler {
118
+ private microQueue;
119
+ private macroQueue;
120
+ private renderQueue;
121
+ private renderScheduled;
122
+ enqueueMicro(task: Task): void;
123
+ enqueueMacro(task: Task): void;
124
+ enqueueRender(task: Task): void;
125
+ flushMicro(): void;
126
+ private flushMacro;
127
+ private flushRender;
128
+ }
129
+
130
+ export { Batch, type ComputeFn, ComputedEngine, CycleDetector, type Listener, type Node, Scheduler, type StagedWrite, Store, SubscriptionEngine, type Task, Transaction, type Unsubscribe, createNode };
@@ -0,0 +1,130 @@
1
+ interface Node {
2
+ readonly id: string;
3
+ value: unknown;
4
+ version: number;
5
+ }
6
+ declare function createNode(id: string, value: unknown): Node;
7
+
8
+ declare class Store {
9
+ private nodes;
10
+ has(path: string): boolean;
11
+ get(path: string): unknown;
12
+ getNode(path: string): Node | undefined;
13
+ set(path: string, value: unknown): Node;
14
+ delete(path: string): boolean;
15
+ paths(): IterableIterator<string>;
16
+ size(): number;
17
+ }
18
+
19
+ type Listener = (value: unknown) => void;
20
+ type Unsubscribe = () => void;
21
+ declare class SubscriptionEngine {
22
+ private listeners;
23
+ subscribe(path: string, cb: Listener): Unsubscribe;
24
+ notify(path: string, value: unknown): void;
25
+ notifyMany(changes: Map<string, unknown>): void;
26
+ hasListeners(path: string): boolean;
27
+ clear(): void;
28
+ }
29
+
30
+ /**
31
+ * Batch collects path changes during a batch callback
32
+ * and defers notifications until the callback completes.
33
+ */
34
+ declare class Batch {
35
+ private depth;
36
+ private pending;
37
+ get isActive(): boolean;
38
+ start(): void;
39
+ end(): Map<string, unknown> | null;
40
+ enqueue(path: string, value: unknown): void;
41
+ }
42
+
43
+ interface StagedWrite {
44
+ path: string;
45
+ value: unknown;
46
+ prevValue: unknown;
47
+ }
48
+ /**
49
+ * Transaction implements the pipeline:
50
+ * SET -> STAGE -> RESOLVE -> PROPAGATE -> COMMIT -> NOTIFY
51
+ *
52
+ * PROPAGATE is handled externally by ComputedEngine.
53
+ * NOTIFY is handled externally by SubscriptionEngine via Batch.
54
+ */
55
+ declare class Transaction {
56
+ private active;
57
+ private staged;
58
+ get isActive(): boolean;
59
+ start(): void;
60
+ /** STAGE: record a write without mutating the store */
61
+ stage(path: string, value: unknown, prevValue: unknown): void;
62
+ /**
63
+ * RESOLVE + COMMIT: drop unchanged values, apply the rest to store.
64
+ * Returns the map of actually changed paths and their new values.
65
+ */
66
+ commit(store: Store): Map<string, unknown>;
67
+ getStaged(): readonly StagedWrite[];
68
+ complete(): void;
69
+ rollback(): void;
70
+ }
71
+
72
+ type ComputeFn = (...values: unknown[]) => unknown;
73
+ /**
74
+ * Manages computed (derived) values in the reactive graph.
75
+ * When a dependency changes, the computed value is recomputed
76
+ * and only propagated if the result actually changed.
77
+ */
78
+ declare class ComputedEngine {
79
+ private computedNodes;
80
+ private cycleDetector;
81
+ register(target: string, deps: string[], fn: ComputeFn): void;
82
+ remove(target: string): void;
83
+ isComputed(path: string): boolean;
84
+ /**
85
+ * Like propagate, but returns both new and old values for middleware support.
86
+ * Does NOT write to the store — the caller handles that via dispatchWrite.
87
+ */
88
+ propagateRaw(changedPaths: Set<string>, store: Store): Map<string, {
89
+ value: unknown;
90
+ oldValue: unknown;
91
+ }>;
92
+ /**
93
+ * Initialize all computed values based on current store state.
94
+ */
95
+ initializeAll(store: Store): void;
96
+ }
97
+
98
+ /**
99
+ * Detects cycles in the computed dependency graph using DFS.
100
+ * Throws on cycle detection to prevent infinite recomputation.
101
+ */
102
+ declare class CycleDetector {
103
+ private graph;
104
+ addEdge(from: string, to: string): void;
105
+ removeNode(id: string): void;
106
+ getDependents(id: string): string[];
107
+ private hasCycle;
108
+ }
109
+
110
+ type Task = () => void;
111
+ /**
112
+ * Scheduler manages different priority queues for updates.
113
+ * - micro: synchronous, within current transaction
114
+ * - macro: deferred async effects (validation, server sync)
115
+ * - render: batched UI notifications (grouped per frame)
116
+ */
117
+ declare class Scheduler {
118
+ private microQueue;
119
+ private macroQueue;
120
+ private renderQueue;
121
+ private renderScheduled;
122
+ enqueueMicro(task: Task): void;
123
+ enqueueMacro(task: Task): void;
124
+ enqueueRender(task: Task): void;
125
+ flushMicro(): void;
126
+ private flushMacro;
127
+ private flushRender;
128
+ }
129
+
130
+ export { Batch, type ComputeFn, ComputedEngine, CycleDetector, type Listener, type Node, Scheduler, type StagedWrite, Store, SubscriptionEngine, type Task, Transaction, type Unsubscribe, createNode };
@@ -0,0 +1,67 @@
1
+ import {
2
+ Batch,
3
+ ComputedEngine,
4
+ CycleDetector,
5
+ Store,
6
+ SubscriptionEngine,
7
+ Transaction,
8
+ createNode
9
+ } from "./chunk-GEMALROQ.js";
10
+
11
+ // src/runtime/Scheduler.ts
12
+ var Scheduler = class {
13
+ microQueue = [];
14
+ macroQueue = [];
15
+ renderQueue = [];
16
+ renderScheduled = false;
17
+ enqueueMicro(task) {
18
+ this.microQueue.push(task);
19
+ }
20
+ enqueueMacro(task) {
21
+ this.macroQueue.push(task);
22
+ queueMicrotask(() => this.flushMacro());
23
+ }
24
+ enqueueRender(task) {
25
+ this.renderQueue.push(task);
26
+ if (!this.renderScheduled) {
27
+ this.renderScheduled = true;
28
+ if (typeof requestAnimationFrame !== "undefined") {
29
+ requestAnimationFrame(() => this.flushRender());
30
+ } else {
31
+ queueMicrotask(() => this.flushRender());
32
+ }
33
+ }
34
+ }
35
+ flushMicro() {
36
+ while (this.microQueue.length > 0) {
37
+ const task = this.microQueue.shift();
38
+ task();
39
+ }
40
+ }
41
+ flushMacro() {
42
+ const tasks = [...this.macroQueue];
43
+ this.macroQueue = [];
44
+ for (const task of tasks) {
45
+ task();
46
+ }
47
+ }
48
+ flushRender() {
49
+ this.renderScheduled = false;
50
+ const tasks = [...this.renderQueue];
51
+ this.renderQueue = [];
52
+ for (const task of tasks) {
53
+ task();
54
+ }
55
+ }
56
+ };
57
+ export {
58
+ Batch,
59
+ ComputedEngine,
60
+ CycleDetector,
61
+ Scheduler,
62
+ Store,
63
+ SubscriptionEngine,
64
+ Transaction,
65
+ createNode
66
+ };
67
+ //# sourceMappingURL=runtime-internal.js.map