@loomwork/projection-runtime 0.0.0-stage → 0.1.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.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +64 -2
- package/dist/InMemoryProjectionRuntime.d.ts +70 -0
- package/dist/InMemoryProjectionRuntime.d.ts.map +1 -0
- package/dist/InMemoryProjectionRuntime.js +305 -0
- package/dist/InMemoryProjectionRuntime.js.map +1 -0
- package/dist/esm/InMemoryProjectionRuntime.js +301 -0
- package/dist/esm/InMemoryProjectionRuntime.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +59 -3
- package/src/InMemoryProjectionRuntime.ts +384 -0
- package/src/index.ts +5 -0
- package/src/projectionStorm.bench.ts +146 -0
- package/src/types.ts +73 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InMemoryProjectionRuntime.js","sourceRoot":"","sources":["../src/InMemoryProjectionRuntime.ts"],"names":[],"mappings":";;;AAwBA;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAkC/B,MAAa,yBAAyB;IACnB,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IAClD,MAAM,GAAG,IAAI,GAAG,EAAmB,CAAC;IACpC,WAAW,GAAG,IAAI,GAAG,EAAyC,CAAC;IAChF,+EAA+E;IAC/E,mFAAmF;IAClE,mBAAmB,GAAG,IAAI,GAAG,EAA8B,CAAC;IAE5D,QAAQ,CAAU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M,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;QACD,+EAA+E;QAC/E,iFAAiF;QACjF,6EAA6E;QAC7E,sEAAsE;QACtE,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpD,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;oBACrC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;oBAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAxTD,8DAwTC"}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cap on how many matching events a lazy projection buffers while its fold code loads. A local
|
|
3
|
+
* `import()` resolves in well under this window; exceeding it means the load is stuck or broken,
|
|
4
|
+
* so we stop buffering (the projection is a read-model, rebuildable from the log) rather than
|
|
5
|
+
* grow memory without bound. Generous so normal bursts never hit it.
|
|
6
|
+
*/
|
|
7
|
+
const LAZY_BUFFER_LIMIT = 10_000;
|
|
8
|
+
/**
|
|
9
|
+
* How many least-recently-touched executions eviction will step over looking for an
|
|
10
|
+
* unsubscribed one. Bounds the per-event cost of `touch`; see its comment for why giving up
|
|
11
|
+
* (and sitting one entry over the cap) is the right failure direction.
|
|
12
|
+
*/
|
|
13
|
+
const EVICTION_SCAN_LIMIT = 64;
|
|
14
|
+
export class InMemoryProjectionRuntime {
|
|
15
|
+
projections = new Map();
|
|
16
|
+
states = new Map();
|
|
17
|
+
subscribers = new Map();
|
|
18
|
+
// Selector-subscribers, keyed like `subscribers`. Kept separate so whole-state
|
|
19
|
+
// subscription stays a zero-overhead fast path when no selector-subscribers exist.
|
|
20
|
+
selectorSubscribers = new Map();
|
|
21
|
+
coalesce;
|
|
22
|
+
dirtyKeys = new Set();
|
|
23
|
+
flushScheduled = false;
|
|
24
|
+
// Insertion order = LRU order over distinct executions, for the retention bound.
|
|
25
|
+
maxExecutions;
|
|
26
|
+
execOrder = new Map();
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.coalesce = config?.coalesceNotifications ?? false;
|
|
29
|
+
this.maxExecutions = config?.maxExecutions ?? 10_000;
|
|
30
|
+
}
|
|
31
|
+
/** Drop all retained state + subscribers for an execution (e.g. after it completes). */
|
|
32
|
+
forget(executionId) {
|
|
33
|
+
for (const projectionId of this.projections.keys()) {
|
|
34
|
+
const key = this.stateKey(projectionId, executionId);
|
|
35
|
+
this.states.delete(key);
|
|
36
|
+
this.subscribers.delete(key);
|
|
37
|
+
this.selectorSubscribers.delete(key);
|
|
38
|
+
}
|
|
39
|
+
this.execOrder.delete(executionId);
|
|
40
|
+
}
|
|
41
|
+
/** True if anything is currently subscribed to any projection of this execution. */
|
|
42
|
+
hasSubscribers(executionId) {
|
|
43
|
+
for (const projectionId of this.projections.keys()) {
|
|
44
|
+
const key = this.stateKey(projectionId, executionId);
|
|
45
|
+
if (this.subscribers.has(key) || this.selectorSubscribers.has(key))
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Drop an execution's retained STATE only — never its subscriber registries.
|
|
52
|
+
*
|
|
53
|
+
* The distinction is the whole point. `forget` is an explicit "this execution is done"
|
|
54
|
+
* from a caller who knows it; eviction is a cache decision the caller never made, and
|
|
55
|
+
* dropping a live subscriber's registry there does not degrade — it disconnects. The
|
|
56
|
+
* handler set is captured by closure in `subscribe`, so once the map entry is gone
|
|
57
|
+
* `notify` looks up a key that no longer exists and that subscriber never fires again.
|
|
58
|
+
*/
|
|
59
|
+
evictState(executionId) {
|
|
60
|
+
for (const projectionId of this.projections.keys()) {
|
|
61
|
+
this.states.delete(this.stateKey(projectionId, executionId));
|
|
62
|
+
}
|
|
63
|
+
this.execOrder.delete(executionId);
|
|
64
|
+
}
|
|
65
|
+
touch(executionId) {
|
|
66
|
+
this.execOrder.delete(executionId);
|
|
67
|
+
this.execOrder.set(executionId, true);
|
|
68
|
+
if (this.execOrder.size <= this.maxExecutions)
|
|
69
|
+
return;
|
|
70
|
+
// Evict least-recently-touched first, but SKIP anything with a live subscriber:
|
|
71
|
+
// evicting a state someone is folding into resets it to `initialState`, which is
|
|
72
|
+
// corruption rather than a cache miss (the same rule `AgentSurfaceRuntime` follows).
|
|
73
|
+
//
|
|
74
|
+
// The scan is bounded rather than exhaustive: if the oldest entries are all subscribed,
|
|
75
|
+
// giving up costs one over-cap entry, while scanning on would make `touch` — which runs
|
|
76
|
+
// once per event — O(retained). Over the cap is the safe direction; `forget` is the
|
|
77
|
+
// explicit remedy.
|
|
78
|
+
let examined = 0;
|
|
79
|
+
for (const candidate of this.execOrder.keys()) {
|
|
80
|
+
if (examined++ >= EVICTION_SCAN_LIMIT)
|
|
81
|
+
return;
|
|
82
|
+
if (this.hasSubscribers(candidate))
|
|
83
|
+
continue;
|
|
84
|
+
this.evictState(candidate);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
stateKey(projectionId, executionId) {
|
|
89
|
+
return `${projectionId}::${executionId}`;
|
|
90
|
+
}
|
|
91
|
+
register(projection) {
|
|
92
|
+
const active = {
|
|
93
|
+
id: projection.id,
|
|
94
|
+
initialState: projection.initialState,
|
|
95
|
+
...(projection.version !== undefined && { version: projection.version }),
|
|
96
|
+
loading: false,
|
|
97
|
+
buffer: [],
|
|
98
|
+
...(projection.handlers !== undefined && {
|
|
99
|
+
handlers: projection.handlers,
|
|
100
|
+
}),
|
|
101
|
+
...(projection.lazy !== undefined && {
|
|
102
|
+
eventTypes: new Set(projection.lazy.eventTypes),
|
|
103
|
+
load: projection.lazy.load,
|
|
104
|
+
}),
|
|
105
|
+
};
|
|
106
|
+
this.projections.set(projection.id, active);
|
|
107
|
+
}
|
|
108
|
+
getState(projectionId, executionId) {
|
|
109
|
+
const key = this.stateKey(projectionId, executionId);
|
|
110
|
+
if (this.states.has(key)) {
|
|
111
|
+
return this.states.get(key);
|
|
112
|
+
}
|
|
113
|
+
const projection = this.projections.get(projectionId);
|
|
114
|
+
if (!projection) {
|
|
115
|
+
throw new Error(`Projection "${projectionId}" is not registered`);
|
|
116
|
+
}
|
|
117
|
+
return projection.initialState;
|
|
118
|
+
}
|
|
119
|
+
subscribe(projectionId, executionId, handler) {
|
|
120
|
+
const key = this.stateKey(projectionId, executionId);
|
|
121
|
+
if (!this.subscribers.has(key)) {
|
|
122
|
+
this.subscribers.set(key, new Set());
|
|
123
|
+
}
|
|
124
|
+
const handlers = this.subscribers.get(key);
|
|
125
|
+
const wrapper = (s) => handler(s);
|
|
126
|
+
handlers.add(wrapper);
|
|
127
|
+
return () => {
|
|
128
|
+
handlers.delete(wrapper);
|
|
129
|
+
// Only retire the map entry if it is still OUR set. After an explicit `forget`, a later
|
|
130
|
+
// subscriber installs a fresh set under the same key; without this identity check a
|
|
131
|
+
// stale unsubscribe would empty its own orphaned set and then delete the live one,
|
|
132
|
+
// silently disconnecting a subscriber that did nothing wrong.
|
|
133
|
+
if (handlers.size === 0 && this.subscribers.get(key) === handlers) {
|
|
134
|
+
this.subscribers.delete(key);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
subscribeSelector(projectionId, executionId, selector, handler, isEqual = Object.is) {
|
|
139
|
+
const key = this.stateKey(projectionId, executionId);
|
|
140
|
+
let set = this.selectorSubscribers.get(key);
|
|
141
|
+
if (!set) {
|
|
142
|
+
set = new Set();
|
|
143
|
+
this.selectorSubscribers.set(key, set);
|
|
144
|
+
}
|
|
145
|
+
const sel = selector;
|
|
146
|
+
const entry = {
|
|
147
|
+
selector: sel,
|
|
148
|
+
isEqual: isEqual,
|
|
149
|
+
handler: handler,
|
|
150
|
+
// Seed from current state so change-only holds from the first event on.
|
|
151
|
+
last: sel(this.peekState(projectionId, executionId)),
|
|
152
|
+
};
|
|
153
|
+
set.add(entry);
|
|
154
|
+
return () => {
|
|
155
|
+
set.delete(entry);
|
|
156
|
+
// Same identity check as `subscribe` — never retire a set that is no longer ours.
|
|
157
|
+
if (set.size === 0 && this.selectorSubscribers.get(key) === set) {
|
|
158
|
+
this.selectorSubscribers.delete(key);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
// Current state without throwing for an unregistered/unseen projection (unlike
|
|
163
|
+
// getState) — used to seed a selector-subscription's `last`. resolve-by-path
|
|
164
|
+
// selectors are null-safe, so an absent state seeds cleanly to `undefined`.
|
|
165
|
+
peekState(projectionId, executionId) {
|
|
166
|
+
const key = this.stateKey(projectionId, executionId);
|
|
167
|
+
if (this.states.has(key))
|
|
168
|
+
return this.states.get(key);
|
|
169
|
+
return this.projections.get(projectionId)?.initialState;
|
|
170
|
+
}
|
|
171
|
+
handleEvent(event) {
|
|
172
|
+
for (const [, projection] of this.projections) {
|
|
173
|
+
if (projection.handlers !== undefined) {
|
|
174
|
+
// Eager (or an already-loaded lazy) projection — fold synchronously as before.
|
|
175
|
+
this.apply(projection, projection.handlers, event);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
// Lazy projection: gate on the compiler-recorded event types WITHOUT loading the
|
|
179
|
+
// fold code. A non-matching event never touches this projection (0 code loaded).
|
|
180
|
+
// A projection whose load already failed permanently is skipped (no buffer, no retry).
|
|
181
|
+
if (projection.loadFailed === true)
|
|
182
|
+
continue;
|
|
183
|
+
if (projection.eventTypes?.has(event.eventType) !== true)
|
|
184
|
+
continue;
|
|
185
|
+
// First matching event: buffer it (and any that arrive during load), kick the
|
|
186
|
+
// one-time import, and drain the buffer in arrival order once the code is ready.
|
|
187
|
+
// Bounded so a stuck/broken load can't grow the buffer without limit.
|
|
188
|
+
if (projection.buffer.length < LAZY_BUFFER_LIMIT)
|
|
189
|
+
projection.buffer.push(event);
|
|
190
|
+
if (!projection.loading) {
|
|
191
|
+
projection.loading = true;
|
|
192
|
+
projection.load()
|
|
193
|
+
.then((handlers) => {
|
|
194
|
+
projection.handlers = handlers;
|
|
195
|
+
projection.eventTypes = undefined; // resolved — the eager path takes over
|
|
196
|
+
projection.loading = false;
|
|
197
|
+
const buffered = projection.buffer;
|
|
198
|
+
projection.buffer = [];
|
|
199
|
+
for (const buf of buffered)
|
|
200
|
+
this.apply(projection, handlers, buf);
|
|
201
|
+
})
|
|
202
|
+
.catch((err) => {
|
|
203
|
+
// A chunk load failure is not transient (missing/broken module). Abandon the
|
|
204
|
+
// projection: free the buffer and stop retrying, rather than leak memory and
|
|
205
|
+
// re-import on every matching event. The read-model can be rebuilt from the log.
|
|
206
|
+
projection.loading = false;
|
|
207
|
+
projection.loadFailed = true;
|
|
208
|
+
projection.buffer = [];
|
|
209
|
+
console.warn(`[loom] projection "${projection.id}" failed to load its fold code — it will not update: ${String(err)}`);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
this.touch(event.executionId);
|
|
214
|
+
}
|
|
215
|
+
/** Fold one event into a projection's state via the matching handler, then notify. */
|
|
216
|
+
apply(projection, handlers, event) {
|
|
217
|
+
// Own-key lookup: the fold map is user-authored and the event type is caller-controlled,
|
|
218
|
+
// so `handlers["__proto__"]` would resolve to `Object.prototype` — truthy, defeating the
|
|
219
|
+
// `!handler` guard, and then called as a function. Mirrors `getHandler` in @loomwork/replay-vm.
|
|
220
|
+
if (!Object.hasOwn(handlers, event.eventType))
|
|
221
|
+
return;
|
|
222
|
+
const handler = handlers[event.eventType];
|
|
223
|
+
if (typeof handler !== "function")
|
|
224
|
+
return;
|
|
225
|
+
const key = this.stateKey(projection.id, event.executionId);
|
|
226
|
+
// One `get` on the hot path (this runs per event per projection); `has` is consulted only
|
|
227
|
+
// in the rare case where the retained state is itself `undefined`.
|
|
228
|
+
const retained = this.states.get(key);
|
|
229
|
+
const currentState = retained !== undefined || this.states.has(key) ? retained : projection.initialState;
|
|
230
|
+
const nextState = handler(currentState, event);
|
|
231
|
+
this.states.set(key, nextState);
|
|
232
|
+
this.notify(key, nextState);
|
|
233
|
+
}
|
|
234
|
+
seedState(projectionId, executionId, state) {
|
|
235
|
+
const key = this.stateKey(projectionId, executionId);
|
|
236
|
+
this.states.set(key, state);
|
|
237
|
+
this.touch(executionId);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* ADR 0095 — the declared `version` of every registered projection that has one.
|
|
241
|
+
*
|
|
242
|
+
* Projections that declare nothing are ABSENT rather than present-and-empty: the caller
|
|
243
|
+
* compares this against what an artifact recorded, and a key mapped to `""` would compare
|
|
244
|
+
* equal to another empty declaration and read as a verified match.
|
|
245
|
+
*/
|
|
246
|
+
pins() {
|
|
247
|
+
// No prototype: a projection registered as `__proto__` would otherwise set one instead
|
|
248
|
+
// of adding a key, and vanish from every comparison without a finding.
|
|
249
|
+
const pins = Object.create(null);
|
|
250
|
+
for (const [id, projection] of this.projections) {
|
|
251
|
+
if (projection.version !== undefined)
|
|
252
|
+
pins[id] = projection.version;
|
|
253
|
+
}
|
|
254
|
+
return pins;
|
|
255
|
+
}
|
|
256
|
+
notify(key, state) {
|
|
257
|
+
if (!this.coalesce) {
|
|
258
|
+
this.emit(key, state);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
// Defer: mark dirty and flush once per microtask with the latest state.
|
|
262
|
+
this.dirtyKeys.add(key);
|
|
263
|
+
if (!this.flushScheduled) {
|
|
264
|
+
this.flushScheduled = true;
|
|
265
|
+
queueMicrotask(() => this.flush());
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
flush() {
|
|
269
|
+
this.flushScheduled = false;
|
|
270
|
+
const keys = Array.from(this.dirtyKeys);
|
|
271
|
+
this.dirtyKeys.clear();
|
|
272
|
+
for (const key of keys) {
|
|
273
|
+
// Read the current state so subscribers always see the latest value even
|
|
274
|
+
// when many events for the same key arrived within the batch.
|
|
275
|
+
this.emit(key, this.states.get(key));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
emit(key, state) {
|
|
279
|
+
const handlers = this.subscribers.get(key);
|
|
280
|
+
if (handlers) {
|
|
281
|
+
for (const handler of handlers) {
|
|
282
|
+
handler(state);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
// Selector-subscribers: recompute each slice against the latest state and fire
|
|
286
|
+
// only those whose slice actually changed — so an unrelated slice's update never
|
|
287
|
+
// wakes this subscriber. Snapshot the set so an unsubscribe during iteration
|
|
288
|
+
// (a handler tearing itself down) can't mutate the live set mid-loop.
|
|
289
|
+
const selectors = this.selectorSubscribers.get(key);
|
|
290
|
+
if (selectors) {
|
|
291
|
+
for (const entry of [...selectors]) {
|
|
292
|
+
const next = entry.selector(state);
|
|
293
|
+
if (!entry.isEqual(entry.last, next)) {
|
|
294
|
+
entry.last = next;
|
|
295
|
+
entry.handler(next);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=InMemoryProjectionRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InMemoryProjectionRuntime.js","sourceRoot":"","sources":["../../src/InMemoryProjectionRuntime.ts"],"names":[],"mappings":"AAwBA;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAkC/B,MAAM,OAAO,yBAAyB;IACnB,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IAClD,MAAM,GAAG,IAAI,GAAG,EAAmB,CAAC;IACpC,WAAW,GAAG,IAAI,GAAG,EAAyC,CAAC;IAChF,+EA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W,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,QAAQ,EAAE,CAAC;YACb,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;QACD,+EAA+E;QAC/E,iFAAiF;QACjF,6EAA6E;QAC7E,sEAAsE;QACtE,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpD,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;oBACrC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;oBAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAE1B,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,KAAK,+BAA+B,GACrC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryProjectionRuntime = void 0;
|
|
4
|
+
var InMemoryProjectionRuntime_1 = require("./InMemoryProjectionRuntime");
|
|
5
|
+
Object.defineProperty(exports, "InMemoryProjectionRuntime", { enumerable: true, get: function () { return InMemoryProjectionRuntime_1.InMemoryProjectionRuntime; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yEAGqC;AAFnC,sIAAA,yBAAyB,OAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { EventEnvelope } from "@loomwork/core";
|
|
2
|
+
export type ProjectionFoldMap<TState> = {
|
|
3
|
+
[eventType: string]: (state: TState, event: EventEnvelope) => TState;
|
|
4
|
+
};
|
|
5
|
+
export interface Projection<TState> {
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* ADR 0095 — the declared semantics of this fold. An artifact that binds to `id` (a
|
|
9
|
+
* blueprint's `DataBinding`, a saved report) records this string, and `checkVersionPins`
|
|
10
|
+
* compares what was recorded against what is registered: a changed query, filter,
|
|
11
|
+
* aggregation or window then reads as a finding instead of a silently different number.
|
|
12
|
+
*
|
|
13
|
+
* Bump it when the fold's MEANING changes — a refactor producing the same state is not a
|
|
14
|
+
* new version. Declared rather than derived, for the reason `flowContentHash` excludes
|
|
15
|
+
* handler code: a fold closure has no stable fingerprint.
|
|
16
|
+
*/
|
|
17
|
+
version?: string;
|
|
18
|
+
initialState: TState;
|
|
19
|
+
/** The eager fold map — present when handlers are inline / already resolved. */
|
|
20
|
+
handlers?: ProjectionFoldMap<TState>;
|
|
21
|
+
/**
|
|
22
|
+
* Event-type-gated lazy form: the fold code stays unloaded until an event whose type
|
|
23
|
+
* is in `eventTypes` first arrives, at which point `load()` is `import()`-ed once (its
|
|
24
|
+
* events buffered until ready). A projection whose event types never fire never loads
|
|
25
|
+
* its code. Exactly one of `handlers` / `lazy` should be set.
|
|
26
|
+
*/
|
|
27
|
+
lazy?: {
|
|
28
|
+
eventTypes: string[];
|
|
29
|
+
load: () => Promise<ProjectionFoldMap<TState>>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface ProjectionRuntime {
|
|
33
|
+
register<TState>(projection: Projection<TState>): void;
|
|
34
|
+
getState<TState>(projectionId: string, executionId: string): TState;
|
|
35
|
+
subscribe<TState>(projectionId: string, executionId: string, handler: (state: TState) => void): () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Fine-grained ("selector") subscription: invoke `handler` only when
|
|
38
|
+
* `selector(state)` changes — by `isEqual`, default `Object.is` — rather than on
|
|
39
|
+
* every projection event. The framework-agnostic building block for live rendering
|
|
40
|
+
* surfaces (terminal, editor webview, TUI, …): each derives a slice-granular,
|
|
41
|
+
* memoized subscription from the shared read-model without reimplementing the diff.
|
|
42
|
+
*
|
|
43
|
+
* Change-only, exactly like {@link subscribe}: it does NOT fire on subscribe. The
|
|
44
|
+
* last slice is seeded from current state at subscribe time, so the first `handler`
|
|
45
|
+
* call is the first genuine change. Read the initial value via `getState` + selector.
|
|
46
|
+
* Participates in `coalesceNotifications` — a burst collapses to one call per changed
|
|
47
|
+
* slice per microtask.
|
|
48
|
+
*/
|
|
49
|
+
subscribeSelector<TState, TSlice>(projectionId: string, executionId: string, selector: (state: TState) => TSlice, handler: (slice: TSlice) => void, isEqual?: (a: TSlice, b: TSlice) => boolean): () => void;
|
|
50
|
+
handleEvent(event: EventEnvelope): void;
|
|
51
|
+
seedState(projectionId: string, executionId: string, state: unknown): void;
|
|
52
|
+
/**
|
|
53
|
+
* ADR 0095 — the declared `version` of every registered projection that has one, by id.
|
|
54
|
+
*
|
|
55
|
+
* OPTIONAL on the interface so an existing implementation stays valid; a runtime that
|
|
56
|
+
* omits it simply cannot answer the question, and `checkVersionPins` reports that as
|
|
57
|
+
* `unpinned` rather than as a pass.
|
|
58
|
+
*/
|
|
59
|
+
pins?(): Readonly<Record<string, string>>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,MAAM,iBAAiB,CAAC,MAAM,IAAI;IACtC,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,KAAK,MAAM,CAAC;CACtE,CAAC;AAEF,MAAM,WAAW,UAAU,CAAC,MAAM;IAChC,EAAE,EAAE,MAAM,CAAC;IACX;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACrC;;;;;OAKG;IACH,IAAI,CAAC,EAAE;QACL,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,IAAI,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;KAChD,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACvD,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IACpE,SAAS,CAAC,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC/B,MAAM,IAAI,CAAC;IACd;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAC9B,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EACnC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,EAChC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,GAC1C,MAAM,IAAI,CAAC;IACd,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACxC,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3E;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC3C"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomwork/projection-runtime",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Event-to-projection transformation runtime with live subscriptions",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"node": "./dist/index.js",
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@loomwork/core": "^0.1.1",
|
|
20
|
+
"@loomwork/event-runtime": "^0.1.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^22.0.0",
|
|
24
|
+
"typescript": "^5.6.3",
|
|
25
|
+
"vitest": "^2.1.8"
|
|
26
|
+
},
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/chhetrisushil/loom.git",
|
|
31
|
+
"directory": "packages/projection-runtime"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"src",
|
|
36
|
+
"!src/**/*.test.ts",
|
|
37
|
+
"!src/**/*.test.tsx",
|
|
38
|
+
"!src/**/__tests__",
|
|
39
|
+
"!src/**/__fixtures__",
|
|
40
|
+
"!src/**/__snapshots__",
|
|
41
|
+
"!src/**/__golden__",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"NOTICE"
|
|
44
|
+
],
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"tag": "next"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=20.0.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc --build && rm -rf dist/esm && tsc -p tsconfig.esm.json",
|
|
54
|
+
"build:esm": "rm -rf dist/esm && tsc -p tsconfig.esm.json",
|
|
55
|
+
"dev": "tsc --build --watch",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:watch": "vitest",
|
|
58
|
+
"bench": "vitest bench --run",
|
|
59
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
60
|
+
"typecheck:tests": "tsc -p tsconfig.test.json"
|
|
61
|
+
}
|
|
6
62
|
}
|