@geajs/ui 0.2.9 → 0.2.10
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/dist/bind.mjs +74 -35
- package/dist/bind.mjs.map +1 -1
- package/dist/combobox.mjs +74 -6
- package/dist/combobox.mjs.map +1 -1
- package/dist/compiled-component.mjs +11 -9
- package/dist/compiled-component.mjs.map +1 -1
- package/dist/compiled-reactive-component.mjs +129 -31
- package/dist/compiled-reactive-component.mjs.map +1 -1
- package/dist/component-id.mjs +12 -1
- package/dist/component-id.mjs.map +1 -1
- package/dist/conditional.mjs.map +1 -1
- package/dist/delegate-event.mjs +9 -9
- package/dist/delegate-event.mjs.map +1 -1
- package/dist/disposer.mjs +30 -11
- package/dist/disposer.mjs.map +1 -1
- package/dist/draggable2.mjs +135 -32
- package/dist/draggable2.mjs.map +1 -1
- package/dist/file-upload.mjs +74 -6
- package/dist/file-upload.mjs.map +1 -1
- package/dist/hover-card.mjs +2 -2
- package/dist/hover-card.mjs.map +1 -1
- package/dist/input2.mjs +2 -2
- package/dist/input2.mjs.map +1 -1
- package/dist/item-obs.mjs +11 -48
- package/dist/item-obs.mjs.map +1 -1
- package/dist/keyed-list.mjs +90 -39
- package/dist/keyed-list.mjs.map +1 -1
- package/dist/menu.mjs +7 -7
- package/dist/menu.mjs.map +1 -1
- package/dist/pin-input.mjs +6 -6
- package/dist/pin-input.mjs.map +1 -1
- package/dist/progress.mjs +2 -2
- package/dist/progress.mjs.map +1 -1
- package/dist/rating-group.mjs +8 -8
- package/dist/rating-group.mjs.map +1 -1
- package/dist/reactive-attr.mjs +2 -2
- package/dist/reactive-attr.mjs.map +1 -1
- package/dist/reactive-bool.mjs +2 -2
- package/dist/reactive-bool.mjs.map +1 -1
- package/dist/reactive-class-name.mjs +2 -2
- package/dist/reactive-class-name.mjs.map +1 -1
- package/dist/reactive-class.mjs +5 -4
- package/dist/reactive-class.mjs.map +1 -1
- package/dist/reactive-style.mjs +15 -12
- package/dist/reactive-style.mjs.map +1 -1
- package/dist/reactive-text.mjs +4 -4
- package/dist/reactive-text.mjs.map +1 -1
- package/dist/tags-input.mjs +10 -10
- package/dist/tags-input.mjs.map +1 -1
- package/dist/tooltip.mjs +3 -3
- package/dist/tooltip.mjs.map +1 -1
- package/dist/zag-component.d.mts +1 -0
- package/dist/zag-component.mjs +10 -1
- package/dist/zag-component.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -4,34 +4,65 @@ import { i as GEA_SET_PROPS, n as GEA_DISPOSER, r as GEA_OBSERVE_DIRECT, t as GE
|
|
|
4
4
|
import { t as getComponentId } from "./component-id.mjs";
|
|
5
5
|
import { n as _DIRTY_PROPS, t as _DIRTY } from "./dirty-symbols.mjs";
|
|
6
6
|
//#region ../gea/src/runtime/compiled-store.ts
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
const _PRIV = Symbol("gea.store.priv");
|
|
8
|
+
const _NESTED = Symbol("gea.store.nested");
|
|
9
|
+
/**
|
|
10
|
+
* `O`/`V` are generic (not `object`/`any`) — this helper hides a value under
|
|
11
|
+
* a symbol key on WHATEVER object it's called with (the raw store, its
|
|
12
|
+
* proxy, a Map cache, ...), so its own declaration can't pin a single
|
|
13
|
+
* concrete shape; each call site supplies its own concrete `O`/`V`.
|
|
14
|
+
*/
|
|
15
|
+
function _hidden(target, key, value) {
|
|
16
|
+
Object.defineProperty(target, key, {
|
|
17
|
+
value,
|
|
18
|
+
writable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
enumerable: false
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Same shape as `_hidden`: a generic reflection probe, not tied to one type. */
|
|
10
24
|
function _isPlain(v) {
|
|
11
25
|
if (!v || typeof v !== "object") return false;
|
|
12
26
|
const p = Object.getPrototypeOf(v);
|
|
13
|
-
return p === Object.prototype || p === null ||
|
|
27
|
+
return p === Object.prototype || p === null || Array.isArray(v);
|
|
14
28
|
}
|
|
29
|
+
/** Unwrap a proxy value to its raw target, preserving whatever type it was. */
|
|
15
30
|
function _unwrap(v) {
|
|
16
31
|
return v && v[GEA_PROXY_RAW] || v;
|
|
17
32
|
}
|
|
33
|
+
function _fireBucket(bucket, value, changes) {
|
|
34
|
+
if (bucket.size === 0) return;
|
|
35
|
+
if (bucket.size === 1) for (const h of bucket) {
|
|
36
|
+
h(value, changes);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const snapshot = [];
|
|
40
|
+
for (const h of bucket) snapshot.push(h);
|
|
41
|
+
for (let i = 0; i < snapshot.length; i++) try {
|
|
42
|
+
snapshot[i](value, changes);
|
|
43
|
+
} catch {}
|
|
44
|
+
}
|
|
18
45
|
function _flush(raw, state) {
|
|
19
46
|
state.scheduled = false;
|
|
20
47
|
const pending = state.pending;
|
|
21
48
|
if (!pending || pending.size === 0) return;
|
|
22
49
|
state.pending = void 0;
|
|
23
50
|
let allChanges = null;
|
|
24
|
-
for (const
|
|
51
|
+
for (const entry of pending) {
|
|
52
|
+
const prop = entry[0];
|
|
53
|
+
const changes = entry[1];
|
|
25
54
|
if (state.rootObservers || state.derived) {
|
|
26
55
|
allChanges ??= [];
|
|
27
56
|
for (let i = 0; i < changes.length; i++) allChanges.push(changes[i]);
|
|
28
57
|
}
|
|
29
58
|
const bucket = state.observers?.get(prop);
|
|
30
59
|
if (!bucket || bucket.size === 0) continue;
|
|
31
|
-
|
|
60
|
+
_fireBucket(bucket, raw[prop], changes);
|
|
32
61
|
}
|
|
33
|
-
if (allChanges && state.rootObservers)
|
|
34
|
-
if (allChanges && state.derived) for (const
|
|
62
|
+
if (allChanges && state.rootObservers) _fireBucket(state.rootObservers, raw, allChanges);
|
|
63
|
+
if (allChanges && state.derived) for (const entry of state.derived) {
|
|
64
|
+
const prop = entry[0];
|
|
65
|
+
const bucket = entry[1];
|
|
35
66
|
if (bucket.size === 0) continue;
|
|
36
67
|
let value;
|
|
37
68
|
try {
|
|
@@ -39,11 +70,15 @@ function _flush(raw, state) {
|
|
|
39
70
|
} catch {
|
|
40
71
|
continue;
|
|
41
72
|
}
|
|
42
|
-
|
|
73
|
+
_fireBucket(bucket, value, allChanges);
|
|
43
74
|
}
|
|
44
75
|
}
|
|
76
|
+
function _hasQueuedConsumers(state, prop) {
|
|
77
|
+
const bucket = state.observers?.get(prop);
|
|
78
|
+
return !!(bucket && bucket.size > 0 || state.rootObservers && state.rootObservers.size > 0 || state.derived && state.derived.size > 0);
|
|
79
|
+
}
|
|
45
80
|
function _queue(raw, state, prop, change = {}) {
|
|
46
|
-
if (!state.ready || !state
|
|
81
|
+
if (!state.ready || !_hasQueuedConsumers(state, prop)) return;
|
|
47
82
|
const rec = {
|
|
48
83
|
prop,
|
|
49
84
|
pathParts: [prop],
|
|
@@ -60,19 +95,31 @@ function _queue(raw, state, prop, change = {}) {
|
|
|
60
95
|
queueMicrotask(() => _flush(raw, state));
|
|
61
96
|
}
|
|
62
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Nested object/array traversal INSIDE one of `S`'s own fields (e.g.
|
|
100
|
+
* `store.list[0].name`): once inside a field's own substructure, the shape
|
|
101
|
+
* is no longer described by `S` (a field's element/property types aren't
|
|
102
|
+
* modeled recursively here) — `V` is a genuinely open per-call type at this
|
|
103
|
+
* depth, kept as a type parameter rather than `any` so it's at least
|
|
104
|
+
* threaded through instead of erased, but this is the one spot in this file
|
|
105
|
+
* that's honestly a dynamic-JS-object-graph boundary: how deep a nested
|
|
106
|
+
* value's shape goes isn't knowable without walking `S` structurally.
|
|
107
|
+
*/
|
|
63
108
|
function _wrapNested(raw, state, target, rootProp) {
|
|
64
109
|
if (!_isPlain(target)) return target;
|
|
65
|
-
|
|
110
|
+
const targetObj = target;
|
|
111
|
+
let perTarget = targetObj[_NESTED];
|
|
66
112
|
if (perTarget) {
|
|
67
113
|
const cached = perTarget.get(rootProp);
|
|
68
114
|
if (cached) return cached;
|
|
69
115
|
}
|
|
70
|
-
const proxy = new Proxy(
|
|
116
|
+
const proxy = new Proxy(targetObj, {
|
|
71
117
|
get(obj, prop) {
|
|
72
118
|
if (prop === GEA_PROXY_RAW) return obj;
|
|
73
119
|
if (typeof prop === "symbol") return obj[prop];
|
|
120
|
+
trackRead(raw, rootProp);
|
|
74
121
|
const val = obj[prop];
|
|
75
|
-
if (
|
|
122
|
+
if (Array.isArray(obj) && typeof val === "function") {
|
|
76
123
|
if (prop === "push") return (...args) => {
|
|
77
124
|
const start = obj.length;
|
|
78
125
|
const result = Array.prototype.push.apply(obj, args.map(_unwrap));
|
|
@@ -81,6 +128,7 @@ function _wrapNested(raw, state, target, rootProp) {
|
|
|
81
128
|
start,
|
|
82
129
|
count: obj.length - start
|
|
83
130
|
});
|
|
131
|
+
else _queue(raw, state, rootProp);
|
|
84
132
|
return result;
|
|
85
133
|
};
|
|
86
134
|
if (prop === "splice") return (...args) => {
|
|
@@ -99,7 +147,26 @@ function _wrapNested(raw, state, target, rootProp) {
|
|
|
99
147
|
count: before - after
|
|
100
148
|
});
|
|
101
149
|
else _queue(raw, state, rootProp, { type: "reorder" });
|
|
102
|
-
}
|
|
150
|
+
} else _queue(raw, state, rootProp);
|
|
151
|
+
return result;
|
|
152
|
+
};
|
|
153
|
+
if (prop === "pop" || prop === "shift") return (...args) => {
|
|
154
|
+
const before = obj.length;
|
|
155
|
+
const result = Array.prototype[prop].apply(obj, args);
|
|
156
|
+
const after = obj.length;
|
|
157
|
+
if (obj === raw[rootProp] && after < before) _queue(raw, state, rootProp, {
|
|
158
|
+
type: "remove",
|
|
159
|
+
start: prop === "pop" ? after : 0,
|
|
160
|
+
count: 1
|
|
161
|
+
});
|
|
162
|
+
else _queue(raw, state, rootProp);
|
|
163
|
+
return result;
|
|
164
|
+
};
|
|
165
|
+
if (prop === "unshift" || prop === "sort" || prop === "reverse") return (...args) => {
|
|
166
|
+
const callArgs = prop === "unshift" ? args.map(_unwrap) : args;
|
|
167
|
+
const result = Array.prototype[prop].apply(obj, callArgs);
|
|
168
|
+
if (obj === raw[rootProp]) _queue(raw, state, rootProp, { type: "reorder" });
|
|
169
|
+
else _queue(raw, state, rootProp);
|
|
103
170
|
return result;
|
|
104
171
|
};
|
|
105
172
|
}
|
|
@@ -114,7 +181,7 @@ function _wrapNested(raw, state, target, rootProp) {
|
|
|
114
181
|
const old = obj[prop];
|
|
115
182
|
if (old === value) return true;
|
|
116
183
|
obj[prop] = value;
|
|
117
|
-
if (
|
|
184
|
+
if (Array.isArray(obj)) {
|
|
118
185
|
if (value && typeof value === "object") value[_DIRTY] = true;
|
|
119
186
|
const idx = +prop;
|
|
120
187
|
if (Number.isInteger(idx) && obj === raw[rootProp]) {
|
|
@@ -135,11 +202,25 @@ function _wrapNested(raw, state, target, rootProp) {
|
|
|
135
202
|
newValue: value
|
|
136
203
|
});
|
|
137
204
|
return true;
|
|
205
|
+
},
|
|
206
|
+
deleteProperty(obj, prop) {
|
|
207
|
+
if (typeof prop === "symbol") {
|
|
208
|
+
delete obj[prop];
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
const old = obj[prop];
|
|
212
|
+
delete obj[prop];
|
|
213
|
+
if (!Array.isArray(obj)) obj[_DIRTY] = true;
|
|
214
|
+
_queue(raw, state, rootProp, {
|
|
215
|
+
previousValue: old,
|
|
216
|
+
type: "delete"
|
|
217
|
+
});
|
|
218
|
+
return true;
|
|
138
219
|
}
|
|
139
220
|
});
|
|
140
221
|
if (!perTarget) {
|
|
141
222
|
perTarget = /* @__PURE__ */ new Map();
|
|
142
|
-
|
|
223
|
+
_hidden(targetObj, _NESTED, perTarget);
|
|
143
224
|
}
|
|
144
225
|
perTarget.set(rootProp, proxy);
|
|
145
226
|
return proxy;
|
|
@@ -147,7 +228,7 @@ function _wrapNested(raw, state, target, rootProp) {
|
|
|
147
228
|
var CompiledStore = class {
|
|
148
229
|
constructor() {
|
|
149
230
|
const state = { ready: false };
|
|
150
|
-
|
|
231
|
+
_hidden(this, _PRIV, state);
|
|
151
232
|
const proxy = new Proxy(this, {
|
|
152
233
|
get(target, prop, receiver) {
|
|
153
234
|
if (prop === GEA_PROXY_RAW) return target;
|
|
@@ -164,8 +245,14 @@ var CompiledStore = class {
|
|
|
164
245
|
}
|
|
165
246
|
value = _unwrap(value);
|
|
166
247
|
const old = target[prop];
|
|
167
|
-
if (old === value && prop in target)
|
|
168
|
-
|
|
248
|
+
if (old === value && prop in target) {
|
|
249
|
+
if (Array.isArray(value)) _queue(target, state, prop, {
|
|
250
|
+
previousValue: old,
|
|
251
|
+
newValue: value
|
|
252
|
+
});
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
if (old && typeof old === "object") delete old[_NESTED];
|
|
169
256
|
target[prop] = value;
|
|
170
257
|
const direct = state.direct?.get(prop);
|
|
171
258
|
if (direct) for (const h of direct) h(value);
|
|
@@ -176,22 +263,28 @@ var CompiledStore = class {
|
|
|
176
263
|
return true;
|
|
177
264
|
}
|
|
178
265
|
});
|
|
179
|
-
|
|
266
|
+
_hidden(proxy, _PRIV, state);
|
|
180
267
|
this[GEA_STORE_ROOT] = proxy;
|
|
181
268
|
return proxy;
|
|
182
269
|
}
|
|
183
270
|
observe(pathOrProp, handler) {
|
|
184
|
-
const state =
|
|
271
|
+
const state = this[_PRIV];
|
|
185
272
|
if (!state) return () => {};
|
|
186
273
|
state.ready = true;
|
|
187
274
|
const isArr = Array.isArray(pathOrProp);
|
|
188
|
-
|
|
275
|
+
let path = [];
|
|
276
|
+
let text = "";
|
|
277
|
+
if (typeof pathOrProp === "string") text = pathOrProp;
|
|
278
|
+
else path = pathOrProp;
|
|
279
|
+
if (isArr && path.length === 0 || !isArr && text === "") {
|
|
189
280
|
const bucket = state.rootObservers ?? (state.rootObservers = /* @__PURE__ */ new Set());
|
|
190
281
|
bucket.add(handler);
|
|
191
|
-
return () =>
|
|
282
|
+
return () => {
|
|
283
|
+
bucket.delete(handler);
|
|
284
|
+
};
|
|
192
285
|
}
|
|
193
|
-
const prop = isArr ?
|
|
194
|
-
const tail = isArr &&
|
|
286
|
+
const prop = isArr ? path[0] ?? "" : text;
|
|
287
|
+
const tail = isArr && path.length > 1 ? path.slice(1) : null;
|
|
195
288
|
const finalHandler = tail ? (value, changes) => {
|
|
196
289
|
let next = value;
|
|
197
290
|
for (let i = 0; i < tail.length; i++) {
|
|
@@ -212,17 +305,21 @@ var CompiledStore = class {
|
|
|
212
305
|
let bucket = observers.get(prop);
|
|
213
306
|
if (!bucket) observers.set(prop, bucket = /* @__PURE__ */ new Set());
|
|
214
307
|
bucket.add(finalHandler);
|
|
215
|
-
return () =>
|
|
308
|
+
return () => {
|
|
309
|
+
bucket.delete(finalHandler);
|
|
310
|
+
};
|
|
216
311
|
}
|
|
217
312
|
[GEA_OBSERVE_DIRECT](prop, handler) {
|
|
218
|
-
const state =
|
|
313
|
+
const state = this[_PRIV];
|
|
219
314
|
if (!state) return () => {};
|
|
220
315
|
state.ready = true;
|
|
221
316
|
const direct = state.direct ?? (state.direct = /* @__PURE__ */ new Map());
|
|
222
317
|
let bucket = direct.get(prop);
|
|
223
318
|
if (!bucket) direct.set(prop, bucket = /* @__PURE__ */ new Set());
|
|
224
319
|
bucket.add(handler);
|
|
225
|
-
return () =>
|
|
320
|
+
return () => {
|
|
321
|
+
bucket.delete(handler);
|
|
322
|
+
};
|
|
226
323
|
}
|
|
227
324
|
};
|
|
228
325
|
//#endregion
|
|
@@ -257,7 +354,8 @@ var CompiledReactiveComponent = class CompiledReactiveComponent extends Compiled
|
|
|
257
354
|
configurable: true,
|
|
258
355
|
get: () => thunks[k]()
|
|
259
356
|
});
|
|
260
|
-
|
|
357
|
+
const childrenThunk = thunks.children;
|
|
358
|
+
if (typeof childrenThunk === "function") {
|
|
261
359
|
let cached = void 0;
|
|
262
360
|
let cacheNode = false;
|
|
263
361
|
Object.defineProperty(out, "children", {
|
|
@@ -265,8 +363,8 @@ var CompiledReactiveComponent = class CompiledReactiveComponent extends Compiled
|
|
|
265
363
|
configurable: true,
|
|
266
364
|
get: () => {
|
|
267
365
|
if (cacheNode) return cached;
|
|
268
|
-
const v =
|
|
269
|
-
if (v && typeof v.nodeType === "number") {
|
|
366
|
+
const v = childrenThunk();
|
|
367
|
+
if (v !== null && typeof v === "object" && typeof v.nodeType === "number") {
|
|
270
368
|
cached = v;
|
|
271
369
|
cacheNode = true;
|
|
272
370
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiled-reactive-component.mjs","names":["GEA_DIRTY","GEA_DIRTY_PROPS"],"sources":["../../gea/src/runtime/compiled-store.ts","../../gea/src/runtime/compiled-reactive-component.ts"],"sourcesContent":["import { GEA_PROXY_RAW, GEA_STORE_ROOT } from './symbols'\nimport { GEA_OBSERVE_DIRECT } from './internal-symbols'\nimport { GEA_DIRTY, GEA_DIRTY_PROPS } from './dirty-symbols'\nimport { trackRead } from './with-tracking'\n\ntype Handler = (value: any, changes?: any[]) => void\n\ninterface StoreState {\n observers?: Map<string, Set<Handler>>\n rootObservers?: Set<Handler>\n derived?: Map<string, Set<Handler>>\n direct?: Map<string, Set<(value: any) => void>>\n pending?: Map<string, any[]>\n scheduled?: boolean\n ready?: boolean\n}\n\nconst _priv = new WeakMap<any, StoreState>()\nconst _nestedCache = new WeakMap<object, Map<string, any>>()\nconst _isArr = Array.isArray\n\nfunction _isPlain(v: any): boolean {\n if (!v || typeof v !== 'object') return false\n const p = Object.getPrototypeOf(v)\n return p === Object.prototype || p === null || _isArr(v)\n}\n\nfunction _unwrap(v: any): any {\n return (v && v[GEA_PROXY_RAW]) || v\n}\n\nfunction _flush(raw: any, state: StoreState): void {\n state.scheduled = false\n const pending = state.pending\n if (!pending || pending.size === 0) return\n state.pending = undefined\n let allChanges: any[] | null = null\n for (const [prop, changes] of pending) {\n if (state.rootObservers || state.derived) {\n allChanges ??= []\n for (let i = 0; i < changes.length; i++) allChanges.push(changes[i])\n }\n const bucket = state.observers?.get(prop)\n if (!bucket || bucket.size === 0) continue\n for (const h of bucket) h(raw[prop], changes)\n }\n if (allChanges && state.rootObservers) {\n for (const h of state.rootObservers) h(raw, allChanges)\n }\n if (allChanges && state.derived) {\n for (const [prop, bucket] of state.derived) {\n if (bucket.size === 0) continue\n let value: any\n try {\n value = raw[prop]\n } catch {\n continue\n }\n for (const h of bucket) h(value, allChanges)\n }\n }\n}\n\nfunction _queue(raw: any, state: StoreState, prop: string, change: any = {}): void {\n if (!state.ready || !state.observers?.has(prop)) return\n const rec = { prop, pathParts: [prop], type: 'update', target: raw, ...change }\n const pending = state.pending ?? (state.pending = new Map())\n const arr = pending.get(prop)\n if (arr) arr.push(rec)\n else pending.set(prop, [rec])\n if (!state.scheduled) {\n state.scheduled = true\n queueMicrotask(() => _flush(raw, state))\n }\n}\n\nfunction _wrapNested(raw: any, state: StoreState, target: any, rootProp: string): any {\n if (!_isPlain(target)) return target\n let perTarget = _nestedCache.get(target)\n if (perTarget) {\n const cached = perTarget.get(rootProp)\n if (cached) return cached\n }\n const proxy = new Proxy(target, {\n get(obj, prop) {\n if (prop === GEA_PROXY_RAW) return obj\n if (typeof prop === 'symbol') return obj[prop as any]\n const val = obj[prop as any]\n if (_isArr(obj) && typeof val === 'function') {\n if (prop === 'push') {\n return (...args: any[]) => {\n const start = obj.length\n const result = Array.prototype.push.apply(obj, args.map(_unwrap))\n if (obj === raw[rootProp] && obj.length > start) {\n _queue(raw, state, rootProp, { type: 'append', start, count: obj.length - start })\n }\n return result\n }\n }\n if (prop === 'splice') {\n return (...args: any[]) => {\n const before = obj.length\n const start = args[0] | 0\n const result = Array.prototype.splice.apply(\n obj,\n args.length > 2 ? [args[0], args[1], ...args.slice(2).map(_unwrap)] : args,\n )\n if (obj === raw[rootProp]) {\n const after = obj.length\n if (after < before) _queue(raw, state, rootProp, { type: 'remove', start, count: before - after })\n else _queue(raw, state, rootProp, { type: 'reorder' })\n }\n return result\n }\n }\n }\n return _isPlain(val) ? _wrapNested(raw, state, val, rootProp) : val\n },\n set(obj, prop, value) {\n if (typeof prop === 'symbol') {\n obj[prop as any] = value\n return true\n }\n value = _unwrap(value)\n const old = obj[prop as any]\n if (old === value) return true\n obj[prop as any] = value\n if (_isArr(obj)) {\n if (value && typeof value === 'object') value[GEA_DIRTY] = true\n const idx = +prop\n if (Number.isInteger(idx) && obj === raw[rootProp]) {\n _queue(raw, state, rootProp, { aipu: true, arix: idx, previousValue: old, newValue: value })\n return true\n }\n } else {\n obj[GEA_DIRTY] = true\n ;(obj[GEA_DIRTY_PROPS] ??= new Set()).add(prop)\n }\n _queue(raw, state, rootProp, { previousValue: old, newValue: value })\n return true\n },\n })\n if (!perTarget) {\n perTarget = new Map()\n _nestedCache.set(target, perTarget)\n }\n perTarget.set(rootProp, proxy)\n return proxy\n}\n\nexport class CompiledStore {\n constructor() {\n const state: StoreState = { ready: false }\n _priv.set(this, state)\n const proxy = new Proxy(this, {\n get(target, prop, receiver) {\n if (prop === GEA_PROXY_RAW) return target\n if (typeof prop === 'symbol') return (target as any)[prop]\n trackRead(receiver ?? target, prop)\n const value = (target as any)[prop]\n if (typeof value === 'function') return value.bind(receiver)\n return _isPlain(value) ? _wrapNested(target, state, value, prop) : value\n },\n set(target, prop, value) {\n if (typeof prop === 'symbol') {\n ;(target as any)[prop] = value\n return true\n }\n value = _unwrap(value)\n const old = (target as any)[prop]\n if (old === value && prop in target) return true\n if (old && typeof old === 'object') _nestedCache.delete(old)\n ;(target as any)[prop] = value\n const direct = state.direct?.get(prop)\n if (direct) for (const h of direct) h(value)\n _queue(target, state, prop, { previousValue: old, newValue: value })\n return true\n },\n })\n _priv.set(proxy, state)\n ;(this as any)[GEA_STORE_ROOT] = proxy\n return proxy\n }\n\n observe(pathOrProp: string | readonly string[], handler: Handler): () => void {\n const state = _priv.get(this)\n if (!state) return () => {}\n state.ready = true\n const isArr = Array.isArray(pathOrProp)\n if ((isArr && pathOrProp.length === 0) || pathOrProp === '') {\n const bucket = state.rootObservers ?? (state.rootObservers = new Set())\n bucket.add(handler)\n return () => bucket.delete(handler)\n }\n const prop = isArr ? pathOrProp[0] : pathOrProp\n const tail = isArr && pathOrProp.length > 1 ? pathOrProp.slice(1) : null\n const finalHandler: Handler = tail\n ? (value, changes) => {\n let next = value\n for (let i = 0; i < tail.length; i++) {\n if (next == null) return\n next = next[tail[i]]\n }\n handler(next, changes)\n }\n : handler\n let isDerived = false\n if (!Object.prototype.hasOwnProperty.call(this, prop)) {\n for (\n let proto = Object.getPrototypeOf(this);\n proto && proto !== Object.prototype;\n proto = Object.getPrototypeOf(proto)\n ) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, prop)\n if (descriptor) {\n isDerived = !!descriptor.get\n break\n }\n }\n }\n const observers = isDerived\n ? (state.derived ?? (state.derived = new Map()))\n : (state.observers ?? (state.observers = new Map()))\n let bucket = observers.get(prop)\n if (!bucket) observers.set(prop, (bucket = new Set()))\n bucket.add(finalHandler)\n return () => bucket!.delete(finalHandler)\n }\n\n [GEA_OBSERVE_DIRECT](prop: string, handler: (value: any) => void): () => void {\n const state = _priv.get(this)\n if (!state) return () => {}\n state.ready = true\n const direct = state.direct ?? (state.direct = new Map())\n let bucket = direct.get(prop)\n if (!bucket) direct.set(prop, (bucket = new Set()))\n bucket.add(handler)\n return () => bucket!.delete(handler)\n }\n}\n\nexport default CompiledStore\n","import { GEA_CREATE_TEMPLATE, GEA_DOM_COMPONENT, GEA_ELEMENT, GEA_ON_PROP_CHANGE } from './symbols'\nimport { GEA_CREATED_CALLED, GEA_DISPOSER, GEA_SET_PROPS } from './internal-symbols'\nimport { createDisposer, type Disposer } from './disposer'\nimport { CompiledStore } from './compiled-store'\nimport { getComponentId } from './component-id'\n\ntype PropThunks = Record<string, () => any>\nconst GEA_COMPONENT_ID = Symbol()\nconst GEA_LAST_PROP_VALUES = Symbol()\n\nexport class CompiledReactiveComponent<P extends Record<string, any> = Record<string, any>> extends CompiledStore {\n rendered = false\n props: P = {} as P;\n\n [GEA_ELEMENT] = null as HTMLElement | null;\n [GEA_DISPOSER] = createDisposer() as Disposer;\n [GEA_CREATED_CALLED] = false\n\n get id(): string {\n return ((this as any)[GEA_COMPONENT_ID] ??= getComponentId())\n }\n\n set id(value: string) {\n ;(this as any)[GEA_COMPONENT_ID] = value\n }\n\n get el(): HTMLElement | null {\n return this[GEA_ELEMENT] ?? null\n }\n\n [GEA_SET_PROPS](thunks: PropThunks): void {\n const createdCalled = this[GEA_CREATED_CALLED]\n const notifyPropChange = createdCalled ? (this as any)[GEA_ON_PROP_CHANGE] : undefined\n const prevValues: Record<string, any> | undefined =\n typeof notifyPropChange === 'function' ? (this as any)[GEA_LAST_PROP_VALUES] : undefined\n const out: Record<string, any> = {}\n for (const k in thunks) {\n Object.defineProperty(out, k, {\n enumerable: true,\n configurable: true,\n get: () => thunks[k](),\n })\n }\n if (typeof thunks.children === 'function') {\n let cached: any = undefined\n let cacheNode = false\n Object.defineProperty(out, 'children', {\n enumerable: true,\n configurable: true,\n get: () => {\n if (cacheNode) return cached\n const v = thunks.children()\n if (v && typeof v.nodeType === 'number') {\n cached = v\n cacheNode = true\n }\n return v\n },\n })\n }\n this.props = out as P\n const nextValues: Record<string, any> = {}\n for (const key in thunks) nextValues[key] = this.props?.[key]\n ;(this as any)[GEA_LAST_PROP_VALUES] = nextValues\n if (!createdCalled) {\n this[GEA_CREATED_CALLED] = true\n if (this.created !== CompiledReactiveComponent.prototype.created) this.created(this.props)\n } else if (typeof notifyPropChange === 'function') {\n for (const key in thunks) {\n const prev = prevValues?.[key]\n const next = this.props?.[key]\n if (next !== prev || (prev !== null && typeof prev === 'object')) notifyPropChange.call(this, key, next)\n }\n }\n }\n\n [GEA_CREATE_TEMPLATE](_disposer: Disposer): Node {\n return document.createDocumentFragment()\n }\n\n render(parent: Node, _index?: number): void {\n if (!this[GEA_CREATED_CALLED]) {\n this[GEA_CREATED_CALLED] = true\n if (this.created !== CompiledReactiveComponent.prototype.created) this.created(this.props)\n }\n let node = this[GEA_CREATE_TEMPLATE](this[GEA_DISPOSER])\n if (node == null) node = document.createComment('')\n if (typeof (node as any).nodeType !== 'number') {\n if (Array.isArray(node)) {\n const frag = document.createDocumentFragment()\n for (const n of node) {\n if (n == null) continue\n if (typeof (n as any).nodeType === 'number') frag.appendChild(n as Node)\n else frag.appendChild(document.createTextNode(String(n)))\n }\n node = frag\n } else {\n node = document.createTextNode(String(node))\n }\n }\n parent.appendChild(node)\n if (node.nodeType === 11) {\n this[GEA_ELEMENT] = ((parent as Element).lastElementChild as HTMLElement | null) ?? null\n } else if (node.nodeType === 1) {\n this[GEA_ELEMENT] = node as HTMLElement\n }\n const el = this[GEA_ELEMENT] as any\n if (el) el[GEA_DOM_COMPONENT] = this\n this.rendered = true\n this.onAfterRender()\n }\n\n onAfterRender(): void {\n /* no-op */\n }\n\n created(_props?: P): void {\n /* no-op */\n }\n\n dispose(): void {\n this[GEA_DISPOSER].dispose()\n const e = this[GEA_ELEMENT] as HTMLElement | null\n if (e && e.parentNode) e.parentNode.removeChild(e)\n this[GEA_ELEMENT] = null\n }\n\n $(sel: string): Element | null {\n const e = this[GEA_ELEMENT] as HTMLElement | null\n return e ? e.querySelector(sel) : null\n }\n\n $$(sel: string): Element[] {\n const e = this[GEA_ELEMENT] as HTMLElement | null\n return e ? Array.from(e.querySelectorAll(sel)) : []\n }\n}\n\nexport default CompiledReactiveComponent\n"],"mappings":";;;;;;AAiBA,MAAM,wBAAQ,IAAI,SAA0B;AAC5C,MAAM,+BAAe,IAAI,SAAmC;AAC5D,MAAM,SAAS,MAAM;AAErB,SAAS,SAAS,GAAiB;AACjC,KAAI,CAAC,KAAK,OAAO,MAAM,SAAU,QAAO;CACxC,MAAM,IAAI,OAAO,eAAe,EAAE;AAClC,QAAO,MAAM,OAAO,aAAa,MAAM,QAAQ,OAAO,EAAE;;AAG1D,SAAS,QAAQ,GAAa;AAC5B,QAAQ,KAAK,EAAE,kBAAmB;;AAGpC,SAAS,OAAO,KAAU,OAAyB;AACjD,OAAM,YAAY;CAClB,MAAM,UAAU,MAAM;AACtB,KAAI,CAAC,WAAW,QAAQ,SAAS,EAAG;AACpC,OAAM,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,QAAI,KAAK,KAAM;AACf,QAAI,OAAQ,EAAU,aAAa,SAAU,MAAK,YAAY,EAAU;QACnE,MAAK,YAAY,SAAS,eAAe,OAAO,EAAE,CAAC,CAAC;;AAE3D,UAAO;QAEP,QAAO,SAAS,eAAe,OAAO,KAAK,CAAC;AAGhD,SAAO,YAAY,KAAK;AACxB,MAAI,KAAK,aAAa,GACpB,MAAK,eAAiB,OAAmB,oBAA2C;WAC3E,KAAK,aAAa,EAC3B,MAAK,eAAe;EAEtB,MAAM,KAAK,KAAK;AAChB,MAAI,GAAI,IAAG,qBAAqB;AAChC,OAAK,WAAW;AAChB,OAAK,eAAe;;CAGtB,gBAAsB;CAItB,QAAQ,QAAkB;CAI1B,UAAgB;AACd,OAAK,cAAc,SAAS;EAC5B,MAAM,IAAI,KAAK;AACf,MAAI,KAAK,EAAE,WAAY,GAAE,WAAW,YAAY,EAAE;AAClD,OAAK,eAAe;;CAGtB,EAAE,KAA6B;EAC7B,MAAM,IAAI,KAAK;AACf,SAAO,IAAI,EAAE,cAAc,IAAI,GAAG;;CAGpC,GAAG,KAAwB;EACzB,MAAM,IAAI,KAAK;AACf,SAAO,IAAI,MAAM,KAAK,EAAE,iBAAiB,IAAI,CAAC,GAAG,EAAE"}
|
|
1
|
+
{"version":3,"file":"compiled-reactive-component.mjs","names":["GEA_DIRTY","GEA_DIRTY_PROPS"],"sources":["../../gea/src/runtime/compiled-store.ts","../../gea/src/runtime/compiled-reactive-component.ts"],"sourcesContent":["import { GEA_PROXY_RAW, GEA_STORE_ROOT } from './symbols'\nimport { GEA_OBSERVE_DIRECT } from './internal-symbols'\nimport { GEA_DIRTY, GEA_DIRTY_PROPS } from './dirty-symbols'\nimport { trackRead } from './with-tracking'\nimport type { Change } from '../store'\n\n/**\n * A store observer: the changed value, and the batch of changes that\n * produced it. `S` is `CompiledStore<S>`'s own type parameter — the\n * concrete store subclass's field shape, resolved once per subclass exactly\n * the way `CompiledComponent<P>` resolves `P` for a component's props. A\n * single `Map<string, Set<Handler<S>>>` holds observers across every field\n * of `S` at once, so the exact field a given handler fires for isn't known\n * at this layer — but the closed set of types it could possibly be (every\n * member of `S`) is, which is why `value` is `S[keyof S]` rather than\n * `any`/`unknown`.\n */\ntype Handler<S> = (value: S[keyof S], changes: Change[]) => void\n\ninterface StoreState<S> {\n observers?: Map<string, Set<Handler<S>>>\n rootObservers?: Set<Handler<S>>\n derived?: Map<string, Set<Handler<S>>>\n direct?: Map<string, Set<(value: S[keyof S]) => void>>\n /** Queued change records, keyed by the prop they were recorded against —\n * each entry is `Change`-shaped (built by `_queue` below), not a raw\n * store value, so `Change[]` is exact rather than `any[]`. */\n pending?: Map<string, Change[]>\n scheduled?: boolean\n ready?: boolean\n}\n\n// Symbol properties, not `WeakMap`s keyed by the store object. See the same\n// change in `compiled-lean-store`: geatsc marks any value reaching a weak-key\n// position as a weak-handle ownership subject and then rejects it for carrying a\n// dynamic representation, which every store value does. A non-enumerable symbol\n// property has the same lifetime, stays out of `Object.keys` / `for...in` /\n// `JSON.stringify`, and passes through the proxy traps' existing symbol\n// short-circuit.\nconst _PRIV = Symbol('gea.store.priv')\nconst _NESTED = Symbol('gea.store.nested')\n\n/**\n * `O`/`V` are generic (not `object`/`any`) — this helper hides a value under\n * a symbol key on WHATEVER object it's called with (the raw store, its\n * proxy, a Map cache, ...), so its own declaration can't pin a single\n * concrete shape; each call site supplies its own concrete `O`/`V`.\n */\nfunction _hidden<O extends object, V>(target: O, key: symbol, value: V): void {\n Object.defineProperty(target, key, { value, writable: true, configurable: true, enumerable: false })\n}\n\n/** Same shape as `_hidden`: a generic reflection probe, not tied to one type. */\nfunction _isPlain<V>(v: V): boolean {\n if (!v || typeof v !== 'object') return false\n const p = Object.getPrototypeOf(v)\n return p === Object.prototype || p === null || Array.isArray(v)\n}\n\n/** Unwrap a proxy value to its raw target, preserving whatever type it was. */\nfunction _unwrap<V>(v: V): V {\n const rawTarget = v && (v as unknown as Record<symbol, unknown>)[GEA_PROXY_RAW]\n return (rawTarget as V) || v\n}\n\nfunction _fireBucket<S>(bucket: Set<Handler<S>>, value: S[keyof S], changes: Change[]): void {\n if (bucket.size === 0) return\n if (bucket.size === 1) {\n for (const h of bucket) {\n h(value, changes)\n return\n }\n }\n const snapshot: Handler<S>[] = []\n for (const h of bucket) snapshot.push(h)\n for (let i = 0; i < snapshot.length; i++) {\n try {\n snapshot[i](value, changes)\n } catch {\n /* isolate sibling observers */\n }\n }\n}\n\nfunction _flush<S>(raw: S, state: StoreState<S>): void {\n state.scheduled = false\n const pending = state.pending\n if (!pending || pending.size === 0) return\n state.pending = undefined\n let allChanges: Change[] | null = null\n for (const entry of pending) {\n const prop = entry[0]\n const changes = entry[1]\n if (state.rootObservers || state.derived) {\n allChanges ??= []\n for (let i = 0; i < changes.length; i++) allChanges.push(changes[i])\n }\n const bucket = state.observers?.get(prop)\n if (!bucket || bucket.size === 0) continue\n _fireBucket(bucket, raw[prop as keyof S], changes)\n }\n if (allChanges && state.rootObservers) {\n _fireBucket(state.rootObservers, raw as S[keyof S], allChanges)\n }\n if (allChanges && state.derived) {\n for (const entry of state.derived) {\n const prop = entry[0]\n const bucket = entry[1]\n if (bucket.size === 0) continue\n let value: S[keyof S]\n try {\n value = raw[prop as keyof S]\n } catch {\n continue\n }\n _fireBucket(bucket, value, allChanges)\n }\n }\n}\n\nfunction _hasQueuedConsumers<S>(state: StoreState<S>, prop: string): boolean {\n const bucket = state.observers?.get(prop)\n return !!(\n (bucket && bucket.size > 0) ||\n (state.rootObservers && state.rootObservers.size > 0) ||\n (state.derived && state.derived.size > 0)\n )\n}\n\nfunction _queue<S>(raw: S, state: StoreState<S>, prop: string, change: Partial<Change> = {}): void {\n if (!state.ready || !_hasQueuedConsumers(state, prop)) return\n const rec: Change = { prop, pathParts: [prop], type: 'update', target: raw, ...change }\n const pending = state.pending ?? (state.pending = new Map())\n const arr = pending.get(prop)\n if (arr) arr.push(rec)\n else pending.set(prop, [rec])\n if (!state.scheduled) {\n state.scheduled = true\n queueMicrotask(() => _flush(raw, state))\n }\n}\n\n/**\n * Nested object/array traversal INSIDE one of `S`'s own fields (e.g.\n * `store.list[0].name`): once inside a field's own substructure, the shape\n * is no longer described by `S` (a field's element/property types aren't\n * modeled recursively here) — `V` is a genuinely open per-call type at this\n * depth, kept as a type parameter rather than `any` so it's at least\n * threaded through instead of erased, but this is the one spot in this file\n * that's honestly a dynamic-JS-object-graph boundary: how deep a nested\n * value's shape goes isn't knowable without walking `S` structurally.\n */\nfunction _wrapNested<S, V>(raw: S, state: StoreState<S>, target: V, rootProp: string): V {\n if (!_isPlain(target)) return target\n const targetObj = target as unknown as Record<PropertyKey, unknown>\n let perTarget: Map<string, unknown> | undefined = (targetObj as unknown as Record<symbol, Map<string, unknown>>)[\n _NESTED\n ]\n if (perTarget) {\n const cached = perTarget.get(rootProp)\n if (cached) return cached as V\n }\n const proxy = new Proxy(targetObj, {\n get(obj, prop) {\n if (prop === GEA_PROXY_RAW) return obj\n if (typeof prop === 'symbol') return obj[prop]\n trackRead(raw as object, rootProp)\n const val = obj[prop]\n if (Array.isArray(obj) && typeof val === 'function') {\n if (prop === 'push') {\n return (...args: unknown[]) => {\n const start = (obj as unknown[]).length\n const result = Array.prototype.push.apply(obj, args.map(_unwrap))\n if (obj === (raw as Record<string, unknown>)[rootProp] && (obj as unknown[]).length > start) {\n _queue(raw, state, rootProp, { type: 'append', start, count: (obj as unknown[]).length - start })\n } else {\n _queue(raw, state, rootProp)\n }\n return result\n }\n }\n if (prop === 'splice') {\n return (...args: unknown[]) => {\n const before = (obj as unknown[]).length\n const start = (args[0] as number) | 0\n const result = Array.prototype.splice.apply(\n obj,\n args.length > 2\n ? ([args[0], args[1], ...args.slice(2).map(_unwrap)] as [number, number, ...unknown[]])\n : (args as [number, number]),\n )\n if (obj === (raw as Record<string, unknown>)[rootProp]) {\n const after = (obj as unknown[]).length\n if (after < before) _queue(raw, state, rootProp, { type: 'remove', start, count: before - after })\n else _queue(raw, state, rootProp, { type: 'reorder' })\n } else {\n _queue(raw, state, rootProp)\n }\n return result\n }\n }\n if (prop === 'pop' || prop === 'shift') {\n return (...args: unknown[]) => {\n const before = (obj as unknown[]).length\n const result = (Array.prototype as unknown as Record<string, (...a: unknown[]) => unknown>)[prop].apply(\n obj,\n args,\n )\n const after = (obj as unknown[]).length\n if (obj === (raw as Record<string, unknown>)[rootProp] && after < before) {\n _queue(raw, state, rootProp, { type: 'remove', start: prop === 'pop' ? after : 0, count: 1 })\n } else {\n _queue(raw, state, rootProp)\n }\n return result\n }\n }\n if (prop === 'unshift' || prop === 'sort' || prop === 'reverse') {\n return (...args: unknown[]) => {\n const callArgs = prop === 'unshift' ? args.map(_unwrap) : args\n const result = (Array.prototype as unknown as Record<string, (...a: unknown[]) => unknown>)[prop].apply(\n obj,\n callArgs,\n )\n if (obj === (raw as Record<string, unknown>)[rootProp]) {\n _queue(raw, state, rootProp, { type: 'reorder' })\n } else {\n _queue(raw, state, rootProp)\n }\n return result\n }\n }\n }\n return _isPlain(val) ? _wrapNested(raw, state, val, rootProp) : val\n },\n set(obj, prop, value) {\n if (typeof prop === 'symbol') {\n obj[prop] = value\n return true\n }\n value = _unwrap(value)\n const old = obj[prop]\n if (old === value) return true\n obj[prop] = value\n if (Array.isArray(obj)) {\n if (value && typeof value === 'object') (value as Record<symbol, unknown>)[GEA_DIRTY] = true\n const idx = +prop\n if (Number.isInteger(idx) && obj === (raw as Record<string, unknown>)[rootProp]) {\n _queue(raw, state, rootProp, { aipu: true, arix: idx, previousValue: old, newValue: value })\n return true\n }\n } else {\n ;(obj as Record<symbol, unknown>)[GEA_DIRTY] = true\n const dirtyProps = ((obj as Record<symbol, unknown>)[GEA_DIRTY_PROPS] ??= new Set()) as Set<string>\n dirtyProps.add(prop)\n }\n _queue(raw, state, rootProp, { previousValue: old, newValue: value })\n return true\n },\n deleteProperty(obj, prop) {\n if (typeof prop === 'symbol') {\n delete obj[prop]\n return true\n }\n const old = obj[prop]\n delete obj[prop]\n if (!Array.isArray(obj)) (obj as Record<symbol, unknown>)[GEA_DIRTY] = true\n _queue(raw, state, rootProp, { previousValue: old, type: 'delete' })\n return true\n },\n })\n if (!perTarget) {\n perTarget = new Map()\n _hidden(targetObj, _NESTED, perTarget)\n }\n perTarget.set(rootProp, proxy)\n return proxy as V\n}\n\nexport class CompiledStore<S extends Record<string, any> = Record<string, any>> {\n constructor() {\n const state: StoreState<S> = { ready: false }\n _hidden(this, _PRIV, state)\n const proxy = new Proxy(this as unknown as S, {\n get(target: S, prop: string | symbol, receiver: object) {\n if (prop === GEA_PROXY_RAW) return target\n if (typeof prop === 'symbol') return (target as Record<symbol, unknown>)[prop]\n trackRead(receiver ?? target, prop)\n const value = target[prop as keyof S]\n if (typeof value === 'function') return (value as (...args: unknown[]) => unknown).bind(receiver)\n return _isPlain(value) ? _wrapNested(target, state, value, prop) : value\n },\n set(target: S, prop: string | symbol, value: unknown) {\n if (typeof prop === 'symbol') {\n ;(target as Record<symbol, unknown>)[prop] = value\n return true\n }\n value = _unwrap(value)\n const old = target[prop as keyof S]\n if (old === value && prop in target) {\n if (Array.isArray(value)) _queue(target, state, prop, { previousValue: old, newValue: value })\n return true\n }\n if (old && typeof old === 'object') delete (old as Record<symbol, unknown>)[_NESTED]\n ;(target as Record<string, unknown>)[prop] = value\n const direct = state.direct?.get(prop)\n if (direct) for (const h of direct) h(value as S[keyof S])\n _queue(target, state, prop, { previousValue: old, newValue: value })\n return true\n },\n })\n _hidden(proxy as unknown as object, _PRIV, state)\n ;(this as unknown as Record<symbol, unknown>)[GEA_STORE_ROOT] = proxy\n return proxy as unknown as this\n }\n\n observe(pathOrProp: string | readonly string[], handler: Handler<S>): () => void {\n const state: StoreState<S> | undefined = (this as unknown as Record<symbol, StoreState<S>>)[_PRIV]\n if (!state) return () => {}\n state.ready = true\n const isArr = Array.isArray(pathOrProp)\n // `path` / `text` carry the two alternatives in their own exact slots so\n // `.length` / `[0]` / `.slice` have a `readonly string[]` receiver: called on\n // `pathOrProp` — declared `string | readonly string[]` — the intrinsic has no\n // single receiver carrier and `pathOrProp.slice(1)` fail-closed with\n // `representation-plan coverage gap for CallExpression`. Each read is already\n // guarded by `isArr`, so neither default is ever observed.\n let path: readonly string[] = []\n let text = ''\n if (typeof pathOrProp === 'string') text = pathOrProp\n else path = pathOrProp\n if ((isArr && path.length === 0) || (!isArr && text === '')) {\n const bucket = state.rootObservers ?? (state.rootObservers = new Set())\n bucket.add(handler)\n return () => {\n bucket.delete(handler)\n }\n }\n const prop = isArr ? (path[0] ?? '') : text\n const tail = isArr && path.length > 1 ? path.slice(1) : null\n const finalHandler: Handler<S> = tail\n ? (value, changes) => {\n let next: unknown = value\n for (let i = 0; i < tail.length; i++) {\n if (next == null) return\n next = (next as Record<string, unknown>)[tail[i]]\n }\n handler(next as S[keyof S], changes)\n }\n : handler\n let isDerived = false\n if (!Object.prototype.hasOwnProperty.call(this, prop)) {\n for (\n let proto = Object.getPrototypeOf(this);\n proto && proto !== Object.prototype;\n proto = Object.getPrototypeOf(proto)\n ) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, prop)\n if (descriptor) {\n isDerived = !!descriptor.get\n break\n }\n }\n }\n const observers = isDerived\n ? (state.derived ?? (state.derived = new Map()))\n : (state.observers ?? (state.observers = new Map()))\n let bucket = observers.get(prop)\n if (!bucket) observers.set(prop, (bucket = new Set()))\n bucket.add(finalHandler)\n return () => {\n bucket!.delete(finalHandler)\n }\n }\n\n [GEA_OBSERVE_DIRECT](prop: string, handler: (value: S[keyof S]) => void): () => void {\n const state: StoreState<S> | undefined = (this as unknown as Record<symbol, StoreState<S>>)[_PRIV]\n if (!state) return () => {}\n state.ready = true\n const direct = state.direct ?? (state.direct = new Map())\n let bucket = direct.get(prop)\n if (!bucket) direct.set(prop, (bucket = new Set()))\n bucket.add(handler)\n return () => {\n bucket!.delete(handler)\n }\n }\n}\n\nexport default CompiledStore\n","import { GEA_CREATE_TEMPLATE, GEA_DOM_COMPONENT, GEA_ELEMENT, GEA_ON_PROP_CHANGE } from './symbols'\nimport { GEA_CREATED_CALLED, GEA_DISPOSER, GEA_SET_PROPS } from './internal-symbols'\nimport { createDisposer, type Disposer } from './disposer'\nimport { CompiledStore } from './compiled-store'\nimport { getComponentId } from './component-id'\nimport type { Renderable } from './renderable'\n\n/**\n * One thunk per prop of `P`, each returning that prop's own type.\n *\n * Generic rather than a flat dictionary so a component's props keep their\n * declared types all the way through `GEA_SET_PROPS` — the compiler emits one\n * thunk per JSX attribute, so the mapping is exact at every instantiation.\n *\n * `children` is intersected in separately (not folded into the mapped part)\n * because JSX always permits a childless invocation regardless of whether\n * `P` declares a `children` field — the compiler attaches a children thunk\n * whenever the call site has JSX children, independent of `P`'s own shape.\n */\ntype PropThunks<P> = { [K in keyof P]: () => P[K] } & { children?: () => Renderable }\nconst GEA_COMPONENT_ID = Symbol()\nconst GEA_LAST_PROP_VALUES = Symbol()\n\nexport class CompiledReactiveComponent<P extends Record<string, any> = Record<string, any>> extends CompiledStore {\n rendered = false\n props: P = {} as P;\n\n [GEA_ELEMENT] = null as HTMLElement | null;\n [GEA_DISPOSER] = createDisposer() as Disposer;\n [GEA_CREATED_CALLED] = false\n\n get id(): string {\n return ((this as any)[GEA_COMPONENT_ID] ??= getComponentId())\n }\n\n set id(value: string) {\n ;(this as any)[GEA_COMPONENT_ID] = value\n }\n\n get el(): HTMLElement | null {\n return this[GEA_ELEMENT] ?? null\n }\n\n [GEA_SET_PROPS](thunks: PropThunks<P>): void {\n const createdCalled = this[GEA_CREATED_CALLED]\n const notifyPropChange = createdCalled ? (this as any)[GEA_ON_PROP_CHANGE] : undefined\n const prevValues: Record<string, any> | undefined =\n typeof notifyPropChange === 'function' ? (this as any)[GEA_LAST_PROP_VALUES] : undefined\n const out: Record<string, any> = {}\n for (const k in thunks) {\n Object.defineProperty(out, k, {\n enumerable: true,\n configurable: true,\n get: () => thunks[k](),\n })\n }\n const childrenThunk = thunks.children\n if (typeof childrenThunk === 'function') {\n let cached: Renderable = undefined\n let cacheNode = false\n Object.defineProperty(out, 'children', {\n enumerable: true,\n configurable: true,\n get: () => {\n if (cacheNode) return cached\n const v = childrenThunk()\n if (v !== null && typeof v === 'object' && typeof (v as Node).nodeType === 'number') {\n cached = v\n cacheNode = true\n }\n return v\n },\n })\n }\n this.props = out as P\n const nextValues: Record<string, any> = {}\n for (const key in thunks) nextValues[key] = this.props?.[key]\n ;(this as any)[GEA_LAST_PROP_VALUES] = nextValues\n if (!createdCalled) {\n this[GEA_CREATED_CALLED] = true\n if (this.created !== CompiledReactiveComponent.prototype.created) this.created(this.props)\n } else if (typeof notifyPropChange === 'function') {\n for (const key in thunks) {\n const prev = prevValues?.[key]\n const next = this.props?.[key]\n if (next !== prev || (prev !== null && typeof prev === 'object')) notifyPropChange.call(this, key, next)\n }\n }\n }\n\n [GEA_CREATE_TEMPLATE](_disposer: Disposer): Node {\n return document.createDocumentFragment()\n }\n\n render(parent: Node, _index?: number): void {\n if (!this[GEA_CREATED_CALLED]) {\n this[GEA_CREATED_CALLED] = true\n if (this.created !== CompiledReactiveComponent.prototype.created) this.created(this.props)\n }\n let node = this[GEA_CREATE_TEMPLATE](this[GEA_DISPOSER])\n if (node == null) node = document.createComment('')\n if (typeof (node as any).nodeType !== 'number') {\n if (Array.isArray(node)) {\n const frag = document.createDocumentFragment()\n for (const n of node) {\n if (n == null) continue\n if (typeof (n as any).nodeType === 'number') frag.appendChild(n as Node)\n else frag.appendChild(document.createTextNode(String(n)))\n }\n node = frag\n } else {\n node = document.createTextNode(String(node))\n }\n }\n parent.appendChild(node)\n if (node.nodeType === 11) {\n this[GEA_ELEMENT] = ((parent as Element).lastElementChild as HTMLElement | null) ?? null\n } else if (node.nodeType === 1) {\n this[GEA_ELEMENT] = node as HTMLElement\n }\n const el = this[GEA_ELEMENT] as any\n if (el) el[GEA_DOM_COMPONENT] = this\n this.rendered = true\n this.onAfterRender()\n }\n\n onAfterRender(): void {\n /* no-op */\n }\n\n created(_props?: P): void {\n /* no-op */\n }\n\n dispose(): void {\n this[GEA_DISPOSER].dispose()\n const e = this[GEA_ELEMENT] as HTMLElement | null\n if (e && e.parentNode) e.parentNode.removeChild(e)\n this[GEA_ELEMENT] = null\n }\n\n $(sel: string): Element | null {\n const e = this[GEA_ELEMENT] as HTMLElement | null\n return e ? e.querySelector(sel) : null\n }\n\n $$(sel: string): Element[] {\n const e = this[GEA_ELEMENT] as HTMLElement | null\n return e ? Array.from(e.querySelectorAll(sel)) : []\n }\n}\n\nexport default CompiledReactiveComponent\n"],"mappings":";;;;;;AAuCA,MAAM,QAAQ,OAAO,iBAAiB;AACtC,MAAM,UAAU,OAAO,mBAAmB;;;;;;;AAQ1C,SAAS,QAA6B,QAAW,KAAa,OAAgB;AAC5E,QAAO,eAAe,QAAQ,KAAK;EAAE;EAAO,UAAU;EAAM,cAAc;EAAM,YAAY;EAAO,CAAC;;;AAItG,SAAS,SAAY,GAAe;AAClC,KAAI,CAAC,KAAK,OAAO,MAAM,SAAU,QAAO;CACxC,MAAM,IAAI,OAAO,eAAe,EAAE;AAClC,QAAO,MAAM,OAAO,aAAa,MAAM,QAAQ,MAAM,QAAQ,EAAE;;;AAIjE,SAAS,QAAW,GAAS;AAE3B,QADkB,KAAM,EAAyC,kBACtC;;AAG7B,SAAS,YAAe,QAAyB,OAAmB,SAAyB;AAC3F,KAAI,OAAO,SAAS,EAAG;AACvB,KAAI,OAAO,SAAS,EAClB,MAAK,MAAM,KAAK,QAAQ;AACtB,IAAE,OAAO,QAAQ;AACjB;;CAGJ,MAAM,WAAyB,EAAE;AACjC,MAAK,MAAM,KAAK,OAAQ,UAAS,KAAK,EAAE;AACxC,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IACnC,KAAI;AACF,WAAS,GAAG,OAAO,QAAQ;SACrB;;AAMZ,SAAS,OAAU,KAAQ,OAA4B;AACrD,OAAM,YAAY;CAClB,MAAM,UAAU,MAAM;AACtB,KAAI,CAAC,WAAW,QAAQ,SAAS,EAAG;AACpC,OAAM,UAAU,KAAA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6
|
+
* Deliberately base 10, not base 36. `Number.prototype.toString(radix)` is only
|
|
7
|
+
* exactly specified for a receiver that is a safe integer, and a compiler that
|
|
8
|
+
* proves its output rather than trusting it cannot establish that for a runtime
|
|
9
|
+
* counter without an integer-domain analysis — so the radix form is refused on
|
|
10
|
+
* the embedded target, where this module is compiled ahead of time.
|
|
11
|
+
*
|
|
12
|
+
* The radix only ever bought a shorter string. Ids stay just as unique.
|
|
13
|
+
*/
|
|
3
14
|
function getComponentId() {
|
|
4
15
|
counter ??= Math.floor(Math.random() * 2147483648);
|
|
5
|
-
return (counter++).toString(
|
|
16
|
+
return (counter++).toString();
|
|
6
17
|
}
|
|
7
18
|
//#endregion
|
|
8
19
|
export { getComponentId as t };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-id.mjs","names":[],"sources":["../../gea/src/runtime/component-id.ts"],"sourcesContent":["let counter: number | null = null\n\nexport function getComponentId(): string {\n counter ??= Math.floor(Math.random() * 2147483648)\n return (counter++).toString(
|
|
1
|
+
{"version":3,"file":"component-id.mjs","names":[],"sources":["../../gea/src/runtime/component-id.ts"],"sourcesContent":["let counter: number | null = null\n\n/**\n * A process-unique component id.\n *\n * Deliberately base 10, not base 36. `Number.prototype.toString(radix)` is only\n * exactly specified for a receiver that is a safe integer, and a compiler that\n * proves its output rather than trusting it cannot establish that for a runtime\n * counter without an integer-domain analysis — so the radix form is refused on\n * the embedded target, where this module is compiled ahead of time.\n *\n * The radix only ever bought a shorter string. Ids stay just as unique.\n */\nexport function getComponentId(): string {\n counter ??= Math.floor(Math.random() * 2147483648)\n return (counter++).toString()\n}\n"],"mappings":";AAAA,IAAI,UAAyB;;;;;;;;;;;;AAa7B,SAAgB,iBAAyB;AACvC,aAAY,KAAK,MAAM,KAAK,QAAQ,GAAG,WAAW;AAClD,SAAQ,WAAW,UAAU"}
|
package/dist/conditional.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional.mjs","names":[],"sources":["../../gea/src/runtime/conditional.ts"],"sourcesContent":["/**\n * conditional(parent, anchor, disposer, root, cond, mkTrue, mkFalse?)\n *\n * Closure-compiled reactive conditional: mounts one of two branches into\n * `parent` immediately before `anchor`, and swaps when `cond()` changes.\n *\n * - Each branch gets its own child disposer scope (`disposer.child()`), so\n * anything the branch sets up (subscriptions, nested conditionals, keyed\n * lists, mounted components) tears down when the branch unmounts.\n * - Dep tracking on `cond` is done lexically via `withTracking(disposer, root, ...)`.\n * `root` is the enclosing component's store proxy — proxy gets during `cond()`\n * push paths into the active scope; on any notified path, the scope re-runs.\n * - `mkFalse` is optional; if omitted, the falsy branch renders a placeholder\n * comment so the anchor position stays well-defined.\n * - DocumentFragment returns are handled: `insertBefore` moves a fragment's\n * children into `parent`, so we capture `childNodes` BEFORE insertion to\n * later remove the exact set of inserted nodes.\n */\n\nimport type { Disposer } from './disposer'\nimport { withTracking, untrack } from './with-tracking'\n\ntype BranchFactory = (d: Disposer) => Node\n\nexport function conditional(\n parent: Node,\n anchor: Comment,\n disposer: Disposer,\n root:
|
|
1
|
+
{"version":3,"file":"conditional.mjs","names":[],"sources":["../../gea/src/runtime/conditional.ts"],"sourcesContent":["/**\n * conditional(parent, anchor, disposer, root, cond, mkTrue, mkFalse?)\n *\n * Closure-compiled reactive conditional: mounts one of two branches into\n * `parent` immediately before `anchor`, and swaps when `cond()` changes.\n *\n * - Each branch gets its own child disposer scope (`disposer.child()`), so\n * anything the branch sets up (subscriptions, nested conditionals, keyed\n * lists, mounted components) tears down when the branch unmounts.\n * - Dep tracking on `cond` is done lexically via `withTracking(disposer, root, ...)`.\n * `root` is the enclosing component's store proxy — proxy gets during `cond()`\n * push paths into the active scope; on any notified path, the scope re-runs.\n * - `mkFalse` is optional; if omitted, the falsy branch renders a placeholder\n * comment so the anchor position stays well-defined.\n * - DocumentFragment returns are handled: `insertBefore` moves a fragment's\n * children into `parent`, so we capture `childNodes` BEFORE insertion to\n * later remove the exact set of inserted nodes.\n */\n\nimport type { Disposer } from './disposer'\nimport { withTracking, untrack } from './with-tracking'\n\ntype BranchFactory = (d: Disposer) => Node\n\nexport function conditional(\n parent: Node,\n anchor: Comment,\n disposer: Disposer,\n root: object,\n cond: () => boolean,\n mkTrue: BranchFactory,\n mkFalse?: BranchFactory,\n): void {\n let currentValue: boolean | null = null\n let currentNodes: Node[] | null = null\n let currentChild: Disposer | null = null\n\n // Install a persistent sentinel at the compiler anchor's position. The\n // original anchor is removed so downstream compiler walk indices (which\n // treat the conditional slot as a single node position) stay correct. The\n // sentinel stays in the DOM for the lifetime of this conditional and serves\n // as a stable insertion point for every swap.\n const sentinel = document.createComment('')\n const p0 = anchor.parentNode ?? parent\n p0.insertBefore(sentinel, anchor)\n p0.removeChild(anchor)\n\n const placeholder: BranchFactory = () => document.createComment('')\n const elseFactory = mkFalse ?? placeholder\n\n function unmount(): void {\n if (currentChild) {\n currentChild.dispose()\n currentChild = null\n }\n if (currentNodes) {\n for (let i = 0; i < currentNodes.length; i++) {\n const n = currentNodes[i]\n const p = n.parentNode\n if (p) p.removeChild(n)\n }\n currentNodes = null\n }\n }\n\n function mount(v: boolean): void {\n const childD = disposer.child()\n const factory = v ? mkTrue : elseFactory\n // Build the branch's DOM without leaking eager reads into the enclosing\n // withTracking scope. Fine-grained reactive primitives inside the branch\n // (reactiveText, reactiveAttr, keyedList, etc.) set up their own tracking\n // scopes via bind/withTracking — they don't need the outer scope.\n const node = untrack(() => factory(childD))\n // Capture child list BEFORE insertion — DocumentFragment children are\n // moved out of the fragment into `parent` on insertBefore. Use nodeType\n // (11 = DOCUMENT_FRAGMENT_NODE) so the check works regardless of whether\n // `DocumentFragment` is a global in the host environment.\n const isFragment = node.nodeType === 11\n const nodes: Node[] = isFragment ? Array.from(node.childNodes) : [node]\n const p = sentinel.parentNode ?? parent\n p.insertBefore(node, sentinel)\n currentChild = childD\n currentNodes = nodes\n }\n\n function swap(v: boolean): void {\n if (v === currentValue) return\n unmount()\n currentValue = v\n mount(v)\n }\n\n withTracking(disposer, root, () => {\n const v = !!cond()\n swap(v)\n })\n\n // Ensure final teardown when the parent scope disposes. `withTracking`\n // already registers its own teardown for subscriptions; we additionally\n // remove the live branch nodes + dispose the active branch scope.\n disposer.add(() => {\n unmount()\n if (sentinel.parentNode) sentinel.parentNode.removeChild(sentinel)\n currentValue = null\n })\n}\n"],"mappings":";;AAwBA,SAAgB,YACd,QACA,QACA,UACA,MACA,MACA,QACA,SACM;CACN,IAAI,eAA+B;CACnC,IAAI,eAA8B;CAClC,IAAI,eAAgC;CAOpC,MAAM,WAAW,SAAS,cAAc,GAAG;CAC3C,MAAM,KAAK,OAAO,cAAc;AAChC,IAAG,aAAa,UAAU,OAAO;AACjC,IAAG,YAAY,OAAO;CAEtB,MAAM,oBAAmC,SAAS,cAAc,GAAG;CACnE,MAAM,cAAc,WAAW;CAE/B,SAAS,UAAgB;AACvB,MAAI,cAAc;AAChB,gBAAa,SAAS;AACtB,kBAAe;;AAEjB,MAAI,cAAc;AAChB,QAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;IAC5C,MAAM,IAAI,aAAa;IACvB,MAAM,IAAI,EAAE;AACZ,QAAI,EAAG,GAAE,YAAY,EAAE;;AAEzB,kBAAe;;;CAInB,SAAS,MAAM,GAAkB;EAC/B,MAAM,SAAS,SAAS,OAAO;EAC/B,MAAM,UAAU,IAAI,SAAS;EAK7B,MAAM,OAAO,cAAc,QAAQ,OAAO,CAAC;EAM3C,MAAM,QADa,KAAK,aAAa,KACF,MAAM,KAAK,KAAK,WAAW,GAAG,CAAC,KAAK;AAEvE,GADU,SAAS,cAAc,QAC/B,aAAa,MAAM,SAAS;AAC9B,iBAAe;AACf,iBAAe;;CAGjB,SAAS,KAAK,GAAkB;AAC9B,MAAI,MAAM,aAAc;AACxB,WAAS;AACT,iBAAe;AACf,QAAM,EAAE;;AAGV,cAAa,UAAU,YAAY;AAEjC,OAAK,CADM,CAAC,MAAM,CACX;GACP;AAKF,UAAS,UAAU;AACjB,WAAS;AACT,MAAI,SAAS,WAAY,UAAS,WAAW,YAAY,SAAS;AAClE,iBAAe;GACf"}
|
package/dist/delegate-event.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
//#region ../gea/src/runtime/delegate-event.ts
|
|
2
|
-
const _NON_BUBBLING =
|
|
3
|
-
blur
|
|
4
|
-
focus
|
|
5
|
-
mouseenter
|
|
6
|
-
mouseleave
|
|
7
|
-
scroll
|
|
8
|
-
|
|
2
|
+
const _NON_BUBBLING = new Set([
|
|
3
|
+
"blur",
|
|
4
|
+
"focus",
|
|
5
|
+
"mouseenter",
|
|
6
|
+
"mouseleave",
|
|
7
|
+
"scroll"
|
|
8
|
+
]);
|
|
9
9
|
function dispatchWithCurrentTarget(handler, event, currentTarget) {
|
|
10
10
|
const previous = Object.getOwnPropertyDescriptor(event, "currentTarget");
|
|
11
11
|
Object.defineProperty(event, "currentTarget", {
|
|
@@ -39,11 +39,11 @@ function delegateEvent(root, type, pairs, _disposer) {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
}, _NON_BUBBLING
|
|
42
|
+
}, _NON_BUBBLING.has(type));
|
|
43
43
|
}
|
|
44
44
|
for (let i = 0; i < pairs.length; i++) {
|
|
45
45
|
const el = pairs[i][0];
|
|
46
|
-
if (el) if (pairs[i]
|
|
46
|
+
if (el) if (pairs[i].length > 2) el[k] = pairs[i][1];
|
|
47
47
|
else el[currentTargetKey] = pairs[i][1];
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate-event.mjs","names":[],"sources":["../../gea/src/runtime/delegate-event.ts"],"sourcesContent":["/**\n * Per-document event delegation via element expando properties.\n *\n * Fast JSX-declared handlers are stored as own properties on their host\n * element (`el.__on_click = handler`). Handlers that need element-local\n * `currentTarget` semantics use the slower `__onct_click` slot.\n * A single document-level listener per eventType walks from `e.target` up,\n * checks the expando on each node, and dispatches.\n *\n * Why this beats a Map<Element, Handler> dispatcher:\n * - Expando lookup is an inline-cached own-property read.\n * - No per-list Map allocation; DOM nodes are the storage.\n * - Detached elements take their handler expando with them, so bulk row\n * teardown avoids removeEventListener / Map.delete work.\n *\n * Although the real DOM listener is installed on the document, Gea exposes\n * element-local handler semantics: while a matched handler runs,\n * `e.currentTarget` is the element that owned that handler.\n */\n\nimport type { Disposer } from './disposer'\n\
|
|
1
|
+
{"version":3,"file":"delegate-event.mjs","names":[],"sources":["../../gea/src/runtime/delegate-event.ts"],"sourcesContent":["/**\n * Per-document event delegation via element expando properties.\n *\n * Fast JSX-declared handlers are stored as own properties on their host\n * element (`el.__on_click = handler`). Handlers that need element-local\n * `currentTarget` semantics use the slower `__onct_click` slot.\n * A single document-level listener per eventType walks from `e.target` up,\n * checks the expando on each node, and dispatches.\n *\n * Why this beats a Map<Element, Handler> dispatcher:\n * - Expando lookup is an inline-cached own-property read.\n * - No per-list Map allocation; DOM nodes are the storage.\n * - Detached elements take their handler expando with them, so bulk row\n * teardown avoids removeEventListener / Map.delete work.\n *\n * Although the real DOM listener is installed on the document, Gea exposes\n * element-local handler semantics: while a matched handler runs,\n * `e.currentTarget` is the element that owned that handler.\n */\n\nimport type { Disposer } from './disposer'\n\n// A Set keeps the membership test native under geatsc; a Record<string, true>\n// computed access has no native plan and trips the boxed-equality guard.\n// Mirrors `delegate-event-fast.ts`, which took the same treatment.\nconst _NON_BUBBLING = new Set<string>(['blur', 'focus', 'mouseenter', 'mouseleave', 'scroll'])\n\ntype Handler = (e: Event) => void\ntype HandlerPair = [Element, Handler] | [Element, Handler, false]\n\nfunction dispatchWithCurrentTarget(handler: Handler, event: Event, currentTarget: Element): void {\n const previous = Object.getOwnPropertyDescriptor(event, 'currentTarget')\n Object.defineProperty(event, 'currentTarget', { configurable: true, value: currentTarget })\n try {\n handler(event)\n } finally {\n if (previous) Object.defineProperty(event, 'currentTarget', previous)\n else delete (event as any).currentTarget\n }\n}\n\nexport function delegateEvent(root: Element, type: string, pairs: HandlerPair[], _disposer: Disposer): void {\n // Prefer the live global `document` — template clones' ownerDocument may\n // differ from the adopted document (jsdom installs fresh docs per test).\n const rt: any = typeof document !== 'undefined' ? document : root.ownerDocument\n const k = '__on_' + type\n const currentTargetKey = '__onct_' + type\n const flag = '__d_' + type\n if (!rt[flag]) {\n rt[flag] = 1\n rt.addEventListener(\n type,\n (e: Event) => {\n for (let n: Node | null = e.target as Node | null; n && n !== rt; n = n.parentNode) {\n const h = (n as any)[k] as Handler | undefined\n if (h !== undefined) {\n h(e)\n return\n }\n const hct = (n as any)[currentTargetKey] as Handler | undefined\n if (hct !== undefined) {\n dispatchWithCurrentTarget(hct, e, n as Element)\n return\n }\n }\n },\n _NON_BUBBLING.has(type),\n )\n }\n for (let i = 0; i < pairs.length; i++) {\n const el = pairs[i][0]\n if (el) {\n // A 3-element pair (`[el, handler, false]`) is the compiler's\n // fast, no-shadow marker; a plain 2-element pair defaults to the\n // slower `currentTarget`-shadowing slot. Test the pair length (a\n // native numeric compare) rather than `pairs[i][2] === false`, whose\n // boxed `false | undefined` equality has no native plan under geatsc.\n if (pairs[i].length > 2) {\n ;(el as any)[k] = pairs[i][1]\n } else {\n ;(el as any)[currentTargetKey] = pairs[i][1]\n }\n }\n }\n // No disposer cleanup: when the element is removed from the DOM and GC'd,\n // the expando dies with it. Skipping a symmetric removeDelegate avoids\n // N `delete el[k]` per row on large replace/clear workloads. A dead expando\n // on a detached element is harmless: events no longer bubble through it, so\n // the document listener never walks into it.\n}\n"],"mappings":";AAyBA,MAAM,gBAAgB,IAAI,IAAY;CAAC;CAAQ;CAAS;CAAc;CAAc;CAAS,CAAC;AAK9F,SAAS,0BAA0B,SAAkB,OAAc,eAA8B;CAC/F,MAAM,WAAW,OAAO,yBAAyB,OAAO,gBAAgB;AACxE,QAAO,eAAe,OAAO,iBAAiB;EAAE,cAAc;EAAM,OAAO;EAAe,CAAC;AAC3F,KAAI;AACF,UAAQ,MAAM;WACN;AACR,MAAI,SAAU,QAAO,eAAe,OAAO,iBAAiB,SAAS;MAChE,QAAQ,MAAc;;;AAI/B,SAAgB,cAAc,MAAe,MAAc,OAAsB,WAA2B;CAG1G,MAAM,KAAU,OAAO,aAAa,cAAc,WAAW,KAAK;CAClE,MAAM,IAAI,UAAU;CACpB,MAAM,mBAAmB,YAAY;CACrC,MAAM,OAAO,SAAS;AACtB,KAAI,CAAC,GAAG,OAAO;AACb,KAAG,QAAQ;AACX,KAAG,iBACD,OACC,MAAa;AACZ,QAAK,IAAI,IAAiB,EAAE,QAAuB,KAAK,MAAM,IAAI,IAAI,EAAE,YAAY;IAClF,MAAM,IAAK,EAAU;AACrB,QAAI,MAAM,KAAA,GAAW;AACnB,OAAE,EAAE;AACJ;;IAEF,MAAM,MAAO,EAAU;AACvB,QAAI,QAAQ,KAAA,GAAW;AACrB,+BAA0B,KAAK,GAAG,EAAa;AAC/C;;;KAIN,cAAc,IAAI,KAAK,CACxB;;AAEH,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,KAAK,MAAM,GAAG;AACpB,MAAI,GAMF,KAAI,MAAM,GAAG,SAAS,EAClB,IAAW,KAAK,MAAM,GAAG;MAEzB,IAAW,oBAAoB,MAAM,GAAG"}
|
package/dist/disposer.mjs
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
//#region ../gea/src/runtime/disposer.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Disposer — LIFO teardown registry.
|
|
4
|
+
*
|
|
5
|
+
* Class-based so the `add` / `dispose` / `child` methods live on the prototype
|
|
6
|
+
* once, instead of being closures created per instance. Each `createDisposer()`
|
|
7
|
+
* call was allocating 3 closures; on a 1000-row keyed list with per-row
|
|
8
|
+
* children that's ~3000 closure allocations that GC had to chase. The class
|
|
9
|
+
* form drops that to one shared prototype plus the per-instance `f[]` array
|
|
10
|
+
* and (for children) a single dispose-bridge closure.
|
|
11
|
+
*
|
|
12
|
+
* `Disposer` is the CLASS, not an interface over it. The interface had exactly
|
|
13
|
+
* two implementors — this class and the `NOOP_DISPOSER` object literal — which
|
|
14
|
+
* made every `Disposer`-typed slot polymorphic between a class instance and a
|
|
15
|
+
* record, and geatsc has no native carrier for that: the type derives lattice
|
|
16
|
+
* bottom, so `CompiledComponent`'s `[GEA_DISPOSER] = createDisposer() as
|
|
17
|
+
* Disposer` field raised `representation-plan coverage gap for
|
|
18
|
+
* PropertyDeclaration`, and `conditional()`'s `currentChild: Disposer | null`
|
|
19
|
+
* capture blocked its whole nested-function cluster. One class with a `noop`
|
|
20
|
+
* flag has a single concrete carrier and behaves identically: a no-op disposer
|
|
21
|
+
* registers nothing, disposes an empty stack, and hands back itself as its own
|
|
22
|
+
* child.
|
|
23
|
+
*/
|
|
24
|
+
var Disposer = class Disposer {
|
|
25
|
+
constructor(noop = false) {
|
|
4
26
|
this.f = [];
|
|
27
|
+
this.noop = noop;
|
|
5
28
|
}
|
|
6
29
|
add(fn) {
|
|
30
|
+
if (this.noop) return;
|
|
7
31
|
this.f.push(fn);
|
|
8
32
|
}
|
|
9
33
|
dispose() {
|
|
@@ -14,7 +38,8 @@ var _Disposer = class _Disposer {
|
|
|
14
38
|
f.length = 0;
|
|
15
39
|
}
|
|
16
40
|
child() {
|
|
17
|
-
|
|
41
|
+
if (this.noop) return this;
|
|
42
|
+
const c = new Disposer();
|
|
18
43
|
this.f.push(_dispatchChild(c));
|
|
19
44
|
return c;
|
|
20
45
|
}
|
|
@@ -23,7 +48,7 @@ function _dispatchChild(c) {
|
|
|
23
48
|
return () => c.dispose();
|
|
24
49
|
}
|
|
25
50
|
function createDisposer() {
|
|
26
|
-
return new
|
|
51
|
+
return new Disposer();
|
|
27
52
|
}
|
|
28
53
|
/**
|
|
29
54
|
* Shared no-op disposer for rows that register no cleanup work.
|
|
@@ -33,13 +58,7 @@ function createDisposer() {
|
|
|
33
58
|
* fresh `{ add() {}, dispose() {}, child() { return this } }` literal per
|
|
34
59
|
* row. 09 clear1k ×8 was paying ~8k object-literal allocations before.
|
|
35
60
|
*/
|
|
36
|
-
const NOOP_DISPOSER =
|
|
37
|
-
add(_fn) {},
|
|
38
|
-
dispose() {},
|
|
39
|
-
child() {
|
|
40
|
-
return NOOP_DISPOSER;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
61
|
+
const NOOP_DISPOSER = new Disposer(true);
|
|
43
62
|
//#endregion
|
|
44
63
|
export { createDisposer as n, NOOP_DISPOSER as t };
|
|
45
64
|
|
package/dist/disposer.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disposer.mjs","names":[],"sources":["../../gea/src/runtime/disposer.ts"],"sourcesContent":["/**\n * Disposer — LIFO teardown registry.\n *\n * Class-based so the `add` / `dispose` / `child` methods live on the prototype\n * once, instead of being closures created per instance. Each `createDisposer()`\n * call was allocating 3 closures; on a 1000-row keyed list with per-row\n * children that's ~3000 closure allocations that GC had to chase. The class\n * form drops that to one shared prototype plus the per-instance `f[]` array\n * and (for children) a single dispose-bridge closure.\n
|
|
1
|
+
{"version":3,"file":"disposer.mjs","names":[],"sources":["../../gea/src/runtime/disposer.ts"],"sourcesContent":["/**\n * Disposer — LIFO teardown registry.\n *\n * Class-based so the `add` / `dispose` / `child` methods live on the prototype\n * once, instead of being closures created per instance. Each `createDisposer()`\n * call was allocating 3 closures; on a 1000-row keyed list with per-row\n * children that's ~3000 closure allocations that GC had to chase. The class\n * form drops that to one shared prototype plus the per-instance `f[]` array\n * and (for children) a single dispose-bridge closure.\n *\n * `Disposer` is the CLASS, not an interface over it. The interface had exactly\n * two implementors — this class and the `NOOP_DISPOSER` object literal — which\n * made every `Disposer`-typed slot polymorphic between a class instance and a\n * record, and geatsc has no native carrier for that: the type derives lattice\n * bottom, so `CompiledComponent`'s `[GEA_DISPOSER] = createDisposer() as\n * Disposer` field raised `representation-plan coverage gap for\n * PropertyDeclaration`, and `conditional()`'s `currentChild: Disposer | null`\n * capture blocked its whole nested-function cluster. One class with a `noop`\n * flag has a single concrete carrier and behaves identically: a no-op disposer\n * registers nothing, disposes an empty stack, and hands back itself as its own\n * child.\n */\n\nexport class Disposer {\n f: Array<() => void> = []\n /** A shared no-op disposer ignores registrations and owns no children. */\n noop: boolean\n\n constructor(noop = false) {\n this.noop = noop\n }\n\n add(fn: () => void): void {\n if (this.noop) return\n this.f.push(fn)\n }\n\n dispose(): void {\n const f = this.f\n // Hoisted try/catch (one per dispose call, not per iteration) — measurable\n // on 09_clear1k's ~5000-cleanup teardown. Framework-owned cleanups don't\n // throw under normal operation; if one does, the remainder of THIS\n // disposer's stack is skipped (best-effort teardown: one failure does not\n // run the rest of this disposer's callbacks).\n try {\n for (let i = f.length - 1; i >= 0; i--) f[i]()\n } catch {\n /* one handler threw */\n }\n f.length = 0\n }\n\n child(): Disposer {\n if (this.noop) return this\n const c = new Disposer()\n this.f.push(_dispatchChild(c))\n return c\n }\n}\n\nfunction _dispatchChild(c: Disposer): () => void {\n return () => c.dispose()\n}\n\nexport function createDisposer(): Disposer {\n return new Disposer()\n}\n\n/**\n * Shared no-op disposer for rows that register no cleanup work.\n *\n * The compiler references this (via `@geajs/core`'s export surface) whenever\n * a keyed-list site proves `noRowDisposer: true` — cheaper than emitting a\n * fresh `{ add() {}, dispose() {}, child() { return this } }` literal per\n * row. 09 clear1k ×8 was paying ~8k object-literal allocations before.\n */\nexport const NOOP_DISPOSER: Disposer = new Disposer(true)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,WAAb,MAAa,SAAS;CAKpB,YAAY,OAAO,OAAO;WAJH,EAAE;AAKvB,OAAK,OAAO;;CAGd,IAAI,IAAsB;AACxB,MAAI,KAAK,KAAM;AACf,OAAK,EAAE,KAAK,GAAG;;CAGjB,UAAgB;EACd,MAAM,IAAI,KAAK;AAMf,MAAI;AACF,QAAK,IAAI,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,IAAK,GAAE,IAAI;UACxC;AAGR,IAAE,SAAS;;CAGb,QAAkB;AAChB,MAAI,KAAK,KAAM,QAAO;EACtB,MAAM,IAAI,IAAI,UAAU;AACxB,OAAK,EAAE,KAAK,eAAe,EAAE,CAAC;AAC9B,SAAO;;;AAIX,SAAS,eAAe,GAAyB;AAC/C,cAAa,EAAE,SAAS;;AAG1B,SAAgB,iBAA2B;AACzC,QAAO,IAAI,UAAU;;;;;;;;;;AAWvB,MAAa,gBAA0B,IAAI,SAAS,KAAK"}
|