@alloy-js/core 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +67 -17
- package/dist/src/components/For.d.ts +1 -1
- package/dist/src/components/For.d.ts.map +1 -1
- package/dist/src/jsx-runtime.d.ts.map +1 -1
- package/dist/src/jsx-runtime.js +9 -3
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +5 -0
- package/dist/src/scheduler.d.ts +8 -0
- package/dist/src/scheduler.d.ts.map +1 -0
- package/dist/src/scheduler.js +17 -0
- package/dist/test/components/declaration.test.js +2 -0
- package/dist/test/control-flow/for.test.js +36 -2
- package/dist/test/reactivity/circular-reactives.test.d.ts +2 -0
- package/dist/test/reactivity/circular-reactives.test.d.ts.map +1 -0
- package/dist/test/reactivity/circular-reactives.test.js +31 -0
- package/dist/test/reactivity/cleanup.test.js +5 -0
- package/dist/test/reactivity/untrack.test.js +3 -0
- package/dist/test/rendering/memoization.test.js +2 -0
- package/dist/test/symbols.test.js +384 -11
- package/dist/test/utils.test.d.ts.map +1 -1
- package/dist/test/utils.test.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/binder.ts +100 -17
- package/src/components/For.tsx +4 -4
- package/src/jsx-runtime.ts +22 -12
- package/src/render.ts +5 -0
- package/src/scheduler.ts +24 -0
- package/temp/api.json +8 -8
- package/test/components/declaration.test.tsx +2 -0
- package/test/components/list.test.tsx +0 -1
- package/test/control-flow/for.test.tsx +34 -4
- package/test/reactivity/circular-reactives.test.tsx +32 -0
- package/test/reactivity/cleanup.test.tsx +5 -0
- package/test/reactivity/untrack.test.ts +3 -0
- package/test/rendering/memoization.test.tsx +2 -0
- package/test/symbols.test.ts +392 -13
- package/test/utils.test.tsx +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog - @alloy-js/core
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
- [#134](https://github.com/alloy-framework/alloy/pull/134) Support readonly collection in `<For>` `each` prop.
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- [#114](https://github.com/alloy-framework/alloy/pull/114) instantiateSymbolInto now mirrors both instance and static members (including nested static hierarchies), and no longer errors on static-only sources.
|
|
12
|
+
|
|
13
|
+
### Breaking Changes
|
|
14
|
+
|
|
15
|
+
- [#127](https://github.com/alloy-framework/alloy/pull/127) Use a scheduler for effects. Effects are no longer run instantly but are queued to run after the current effect finishes. This significantly reduces effect calls due to coalescing multiple updates and also enables more recursive patterns.
|
|
16
|
+
|
|
17
|
+
|
|
3
18
|
## 0.11.0
|
|
4
19
|
|
|
5
20
|
### Bug Fixes
|
package/dist/src/binder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binder.d.ts","sourceRoot":"","sources":["../../src/binder.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"binder.d.ts","sourceRoot":"","sources":["../../src/binder.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,GAAG,EAGJ,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAU,MAAM,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,IAAI,IAAI;IAER;;;OAGG;IACH,uBAAuB,IAAS;IAEhC;;;OAGG;IACH,qBAAqB,IAAS;IAE9B;;OAEG;IACH,eAAe,IAAkD;IAEjE;;;OAGG;IACH,cAAc,IAAS;IAEvB;;;OAGG;IACH,YAAY,IAAS;IAErB;;OAEG;IACH,MAAM,KAAgC;CACvC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,M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;;OAEG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAEhC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,aAAa;IAC5B,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,CAwnBtE;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACrB,MAAM,SAAS,WAAW,EAC1B,OAAO,SAAS,YAAY,EAC5B,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAUxD;AAED,QAAA,MAAM,mBAAmB,EAAE,OAAO,MAAiB,CAAC;AACpD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,GACrB,aAAa,CAAC,OAAO,mBAAmB,CAAC,CAE3C;AAED,wBAAgB,sBAAsB,IAAI,OAAO,mBAAmB,CAEnE;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,mBAAmB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C;AAaD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,GAAE,iBAA0C,2BAelD"}
|
package/dist/src/binder.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { computed,
|
|
1
|
+
import { computed, reactive, ref, shallowRef } from "@vue/reactivity";
|
|
2
2
|
import { useBinder } from "./context/binder.js";
|
|
3
3
|
import { useMemberScope } from "./context/member-scope.js";
|
|
4
4
|
import { useScope } from "./context/scope.js";
|
|
5
|
-
import { memo, untrack } from "./jsx-runtime.js";
|
|
5
|
+
import { effect, memo, onCleanup, untrack } from "./jsx-runtime.js";
|
|
6
6
|
import { refkey } from "./refkey.js";
|
|
7
|
+
import { queueJob } from "./scheduler.js";
|
|
7
8
|
/**
|
|
8
9
|
* Flags that describe an output symbol.
|
|
9
10
|
*/
|
|
@@ -170,6 +171,7 @@ export function createOutputBinder(options = {}) {
|
|
|
170
171
|
const waitingDeclarations = new Map();
|
|
171
172
|
const waitingSymbolNames = new Map();
|
|
172
173
|
const waitingScopeNames = new Map();
|
|
174
|
+
const deconflictJobs = new Map();
|
|
173
175
|
return binder;
|
|
174
176
|
function createScope(args) {
|
|
175
177
|
const {
|
|
@@ -294,23 +296,55 @@ export function createOutputBinder(options = {}) {
|
|
|
294
296
|
}
|
|
295
297
|
}
|
|
296
298
|
function instantiateSymbolInto(source, target) {
|
|
297
|
-
if (
|
|
298
|
-
|
|
299
|
+
if (target.staticMemberScope) {
|
|
300
|
+
return;
|
|
299
301
|
}
|
|
300
|
-
|
|
302
|
+
|
|
303
|
+
// Ensure static member scope exists
|
|
304
|
+
addStaticMembersToSymbol(target);
|
|
301
305
|
effect(() => {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
flags: sym.flags | OutputSymbolFlags.InstanceMember
|
|
311
|
-
});
|
|
306
|
+
// copy instance members if it's an instance‐container
|
|
307
|
+
if (source.flags & OutputSymbolFlags.InstanceMemberContainer) {
|
|
308
|
+
copyMembers(source.instanceMemberScope.symbols, target, target.staticMemberScope);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// copy static members if it's a static‐container
|
|
312
|
+
if (source.flags & OutputSymbolFlags.StaticMemberContainer) {
|
|
313
|
+
copyMembers(source.staticMemberScope.symbols, target, target.staticMemberScope);
|
|
312
314
|
}
|
|
313
315
|
});
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Recursively copy `symbols` from `sourceSym` into `intoScope` of `targetSym`.
|
|
319
|
+
* Always marks each instantiation as StaticMember so lookups use dot notation (e.g. Parent.child)
|
|
320
|
+
* and preserves any StaticMemberContainer flag to auto create newSym.staticMemberScope.
|
|
321
|
+
*/
|
|
322
|
+
function copyMembers(symbols, targetSym, intoScope) {
|
|
323
|
+
for (const srcSym of symbols) {
|
|
324
|
+
untrack(() => {
|
|
325
|
+
const wantKey = refkey(targetSym.refkeys[0], srcSym.refkeys[0]);
|
|
326
|
+
|
|
327
|
+
// create the new symbol. Preserve StaticMemberContainer if present
|
|
328
|
+
const newSym = createSymbol({
|
|
329
|
+
name: srcSym.name,
|
|
330
|
+
scope: intoScope,
|
|
331
|
+
refkey: wantKey,
|
|
332
|
+
flags: srcSym.flags | OutputSymbolFlags.StaticMember
|
|
333
|
+
});
|
|
334
|
+
onCleanup(() => {
|
|
335
|
+
binder.deleteSymbol(newSym);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// if the source symbol itself was a container of static members,
|
|
339
|
+
// recurse into the newSym.staticMemberScope that createSymbol just gave us
|
|
340
|
+
if (srcSym.staticMemberScope && srcSym.staticMemberScope.symbols.size > 0) {
|
|
341
|
+
// ensure we have that scope
|
|
342
|
+
addStaticMembersToSymbol(newSym);
|
|
343
|
+
copyMembers(srcSym.staticMemberScope.symbols, newSym, newSym.staticMemberScope);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
314
348
|
}
|
|
315
349
|
function addStaticMembersToSymbol(symbol) {
|
|
316
350
|
if (symbol.flags & OutputSymbolFlags.StaticMemberContainer) {
|
|
@@ -413,12 +447,12 @@ export function createOutputBinder(options = {}) {
|
|
|
413
447
|
}
|
|
414
448
|
function deconflict(symbol) {
|
|
415
449
|
const scope = symbol.scope;
|
|
416
|
-
const existingNames = [...scope.symbols].filter(sym => sym.
|
|
450
|
+
const existingNames = [...scope.symbols].filter(sym => sym.name === symbol.name);
|
|
417
451
|
if (existingNames.length < 2) {
|
|
418
452
|
return;
|
|
419
453
|
}
|
|
420
454
|
if (options.nameConflictResolver) {
|
|
421
|
-
|
|
455
|
+
queueJob(deconflictJobForScopeAndName(scope, symbol.name, options.nameConflictResolver));
|
|
422
456
|
} else {
|
|
423
457
|
// default disambiguation is first-wins
|
|
424
458
|
for (let i = 1; i < existingNames.length; i++) {
|
|
@@ -426,6 +460,22 @@ export function createOutputBinder(options = {}) {
|
|
|
426
460
|
}
|
|
427
461
|
}
|
|
428
462
|
}
|
|
463
|
+
function deconflictJobForScopeAndName(scope, name, handler) {
|
|
464
|
+
if (!deconflictJobs.has(scope)) {
|
|
465
|
+
deconflictJobs.set(scope, new Map());
|
|
466
|
+
}
|
|
467
|
+
const jobs = deconflictJobs.get(scope);
|
|
468
|
+
if (jobs.has(name)) {
|
|
469
|
+
return jobs.get(name);
|
|
470
|
+
}
|
|
471
|
+
const job = () => {
|
|
472
|
+
const conflictedSymbols = [...scope.symbols].filter(sym => sym.name === name);
|
|
473
|
+
handler(name, conflictedSymbols);
|
|
474
|
+
jobs.delete(name);
|
|
475
|
+
};
|
|
476
|
+
jobs.set(name, job);
|
|
477
|
+
return job;
|
|
478
|
+
}
|
|
429
479
|
function getSymbolForRefkey(refkey) {
|
|
430
480
|
const symbol = knownDeclarations.get(refkey);
|
|
431
481
|
if (symbol) {
|
|
@@ -18,7 +18,7 @@ export interface ForProps<T extends ForSupportedCollections | (() => ForSupporte
|
|
|
18
18
|
*/
|
|
19
19
|
skipFalsy?: boolean;
|
|
20
20
|
}
|
|
21
|
-
export type ForSupportedCollections =
|
|
21
|
+
export type ForSupportedCollections = readonly unknown[] | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown> | IterableIterator<unknown>;
|
|
22
22
|
/**
|
|
23
23
|
* The For component iterates over the provided array and invokes the child
|
|
24
24
|
* callback for each item. It can optionally be prov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SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,uBAAuB,GAC/B,SAAS,OAAO,EAAE,GAClB,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,GAC7B,WAAW,CAAC,OAAO,CAAC,GACpB,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,GAAG,CACjB,CAAC,SACG,uBAAuB,GACvB,CAAC,MAAM,uBAAuB,CAAC,GAC/B,GAAG,CAAC,uBAAuB,CAAC,EAChC,CAAC,SAAS,QAAQ,EAClB,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,aAetB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,GAAG,EAMJ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAU/C,MAAM,WAAW,UAAU;IACzB,IAAI,IAAI,CAAC;CACV;AAED,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAGtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGlC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE3B;;;OAGG;IACH,YAAY,EAAE,YAAY,CAAC;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CAC5C;AAGD,wBAAgB,U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C,GAAG,CAAC,CAAC;AA2BjB,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI;IAC9D,GAAG;SACA,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,EAAE,GACnC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GACpD,KAAK;KACR;IACD;SAAG,CAAC,IAAI,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAAE;CAC1D,CAAC;AAEF,wBAAgB,UAAU,CACxB,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAC1B,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC7D,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAyCxC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CA8C5E"}
|
package/dist/src/jsx-runtime.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Much of the implementations in this file are inspired by vuerx-js
|
|
2
2
|
// See: https://github.com/ryansolid/vuerx-jsx.
|
|
3
3
|
import { computed, isReactive, pauseTracking, proxyRefs, resetTracking, shallowRef, stop, toRefs, effect as vueEffect } from "@vue/reactivity";
|
|
4
|
+
import { scheduler } from "./scheduler.js";
|
|
4
5
|
if (globalThis.ALLOY) {
|
|
5
6
|
throw new Error("Multiple versions of the JSX Runtime have been loaded. This will likely cause undesirable behavior.");
|
|
6
7
|
}
|
|
@@ -62,10 +63,10 @@ export function effect(fn, current) {
|
|
|
62
63
|
for (let k = 0, len = d.length; k < len; k++) d[k]();
|
|
63
64
|
|
|
64
65
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
65
|
-
final && stop(
|
|
66
|
+
final && stop(runner);
|
|
66
67
|
};
|
|
67
68
|
onCleanup(() => cleanupFn(true));
|
|
68
|
-
const
|
|
69
|
+
const runner = vueEffect(() => {
|
|
69
70
|
cleanupFn(false);
|
|
70
71
|
const oldContext = globalContext;
|
|
71
72
|
globalContext = context;
|
|
@@ -74,7 +75,12 @@ export function effect(fn, current) {
|
|
|
74
75
|
} finally {
|
|
75
76
|
globalContext = oldContext;
|
|
76
77
|
}
|
|
77
|
-
}, {
|
|
78
|
+
}, {
|
|
79
|
+
scheduler: scheduler(() => runner)
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// allow recursive effects (recursive option does nothing, possible bug)
|
|
83
|
+
runner.effect.flags |= 1 << 5;
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
/**
|
package/dist/src/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAO,MAAM,UAAU,CAAC;AAIpC,OAAO,EAEL,QAAQ,EACR,OAAO,EAcR,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAO,MAAM,UAAU,CAAC;AAIpC,OAAO,EAEL,QAAQ,EACR,OAAO,EAcR,MAAM,kBAAkB,CAAC;AAwB1B;;;;;;;;;;;;;;;;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,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAOD,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,gBAAgB,UAc3E"}
|
package/dist/src/render.js
CHANGED
|
@@ -5,6 +5,7 @@ import { useContext } from "./context.js";
|
|
|
5
5
|
import { SourceFileContext } from "./context/source-file.js";
|
|
6
6
|
import { effect, getContext, getElementCache, isComponentCreator, isCustomContext, isIntrinsicElement, popStack, printRenderStack, pushStack, root, untrack } from "./jsx-runtime.js";
|
|
7
7
|
import { isRefkey } from "./refkey.js";
|
|
8
|
+
import { flushJobs } from "./scheduler.js";
|
|
8
9
|
const {
|
|
9
10
|
builders: {
|
|
10
11
|
align,
|
|
@@ -127,6 +128,7 @@ function traceRender(phase, message) {
|
|
|
127
128
|
}
|
|
128
129
|
export function render(children, options) {
|
|
129
130
|
const tree = renderTree(children);
|
|
131
|
+
flushJobs();
|
|
130
132
|
let rootDirectory = undefined;
|
|
131
133
|
|
|
132
134
|
// when passing Output, the first render tree child is the Output component.
|
|
@@ -403,6 +405,9 @@ export function printTree(tree, options) {
|
|
|
403
405
|
...defaultPrintTreeOptions,
|
|
404
406
|
...Object.fromEntries(Object.entries(options ?? {}).filter(([_, v]) => v !== undefined))
|
|
405
407
|
};
|
|
408
|
+
|
|
409
|
+
// make sure queue is empty
|
|
410
|
+
flushJobs();
|
|
406
411
|
const d = printTreeWorker(tree);
|
|
407
412
|
return doc.printer.printDocToString(d, options).formatted;
|
|
408
413
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactiveEffectRunner } from "@vue/reactivity";
|
|
2
|
+
export interface QueueJob {
|
|
3
|
+
(): any;
|
|
4
|
+
}
|
|
5
|
+
export declare function scheduler(jobGetter: () => ReactiveEffectRunner): () => void;
|
|
6
|
+
export declare function queueJob(job: QueueJob): void;
|
|
7
|
+
export declare function flushJobs(): void;
|
|
8
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,QAAQ;IACvB,IAAI,GAAG,CAAC;CACT;AAGD,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,oBAAoB,cAI9D;AACD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,QAAQ,QAIrC;AAED,wBAAgB,SAAS,SAKxB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const queue = new Set();
|
|
2
|
+
export function scheduler(jobGetter) {
|
|
3
|
+
return () => {
|
|
4
|
+
queueJob(jobGetter());
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function queueJob(job) {
|
|
8
|
+
// the set is serving an important purpose here in deduping the effects we run
|
|
9
|
+
// (which in effect coalesces multiple update effects together).
|
|
10
|
+
queue.add(job);
|
|
11
|
+
}
|
|
12
|
+
export function flushJobs() {
|
|
13
|
+
for (const job of queue) {
|
|
14
|
+
queue.delete(job);
|
|
15
|
+
job();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -2,6 +2,7 @@ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/
|
|
|
2
2
|
import { expect, it } from "vitest";
|
|
3
3
|
import { Output } from "../../src/components/Output.js";
|
|
4
4
|
import { Declaration, ref, renderTree, Scope, useBinder } from "../../src/index.js";
|
|
5
|
+
import { flushJobs } from "../../src/scheduler.js";
|
|
5
6
|
import { createTap } from "../../src/tap.js";
|
|
6
7
|
it("creates and cleans up a symbol", () => {
|
|
7
8
|
const GetBinder = createTap(() => {
|
|
@@ -26,5 +27,6 @@ it("creates and cleans up a symbol", () => {
|
|
|
26
27
|
const subScope = [...binder.globalScope.children][0];
|
|
27
28
|
expect(subScope.symbols.size).toBe(1);
|
|
28
29
|
doDecl.value = false;
|
|
30
|
+
flushJobs();
|
|
29
31
|
expect(subScope.symbols.size).toBe(0);
|
|
30
32
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import "@alloy-js/core/testing";
|
|
3
3
|
import { d } from "@alloy-js/core/testing";
|
|
4
|
-
import { expect, it } from "vitest";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
5
|
import { For } from "../../src/components/For.js";
|
|
6
6
|
import { onCleanup, printTree, reactive, renderTree } from "../../src/index.js";
|
|
7
|
+
import { flushJobs } from "../../src/scheduler.js";
|
|
7
8
|
it("works", () => {
|
|
8
9
|
const messages = ["hi", "bye"];
|
|
9
10
|
const template = _$createComponent(For, {
|
|
@@ -15,6 +16,33 @@ it("works", () => {
|
|
|
15
16
|
bye, Jose!
|
|
16
17
|
`);
|
|
17
18
|
});
|
|
19
|
+
describe("readonly collections", () => {
|
|
20
|
+
const out = d`
|
|
21
|
+
a
|
|
22
|
+
b
|
|
23
|
+
`;
|
|
24
|
+
it("array", () => {
|
|
25
|
+
const messages = ["a", "b"];
|
|
26
|
+
expect(_$createComponent(For, {
|
|
27
|
+
each: messages,
|
|
28
|
+
children: x => [x]
|
|
29
|
+
})).toRenderTo(out);
|
|
30
|
+
});
|
|
31
|
+
it("map", () => {
|
|
32
|
+
const messages = new Map([["a", "a"], ["b", "b"]]);
|
|
33
|
+
expect(_$createComponent(For, {
|
|
34
|
+
each: messages,
|
|
35
|
+
children: x => [x]
|
|
36
|
+
})).toRenderTo(out);
|
|
37
|
+
});
|
|
38
|
+
it("set", () => {
|
|
39
|
+
const messages = new Set(["a", "b"]);
|
|
40
|
+
expect(_$createComponent(For, {
|
|
41
|
+
each: messages,
|
|
42
|
+
children: x => [x]
|
|
43
|
+
})).toRenderTo(out);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
18
46
|
it("handles map entries", () => {
|
|
19
47
|
const map = new Map([["a", {
|
|
20
48
|
name: "foo"
|
|
@@ -62,6 +90,7 @@ it("doesn't rerender mappers", () => {
|
|
|
62
90
|
const tree = renderTree(template);
|
|
63
91
|
expect(count).toBe(2);
|
|
64
92
|
messages.push("maybe");
|
|
93
|
+
flushJobs();
|
|
65
94
|
expect(count).toBe(3);
|
|
66
95
|
expect(printTree(tree)).toBe(d`
|
|
67
96
|
item 0
|
|
@@ -79,6 +108,7 @@ it("doesn't rerender mappers with sets", () => {
|
|
|
79
108
|
const tree = renderTree(template);
|
|
80
109
|
expect(count).toBe(2);
|
|
81
110
|
messages.add("maybe");
|
|
111
|
+
flushJobs();
|
|
82
112
|
expect(count).toBe(3);
|
|
83
113
|
expect(printTree(tree)).toBe(d`
|
|
84
114
|
item 0
|
|
@@ -96,6 +126,7 @@ it("doesn't rerender mappers with maps", () => {
|
|
|
96
126
|
const tree = renderTree(template);
|
|
97
127
|
expect(count).toBe(2);
|
|
98
128
|
messages.set("maybe", "three");
|
|
129
|
+
flushJobs();
|
|
99
130
|
expect(count).toBe(3);
|
|
100
131
|
expect(printTree(tree)).toBe(d`
|
|
101
132
|
item 0
|
|
@@ -113,6 +144,7 @@ it("doesn't rerender mappers (with splice)", () => {
|
|
|
113
144
|
const tree = renderTree(template);
|
|
114
145
|
expect(count).toBe(3);
|
|
115
146
|
messages.splice(1, 1);
|
|
147
|
+
flushJobs();
|
|
116
148
|
// A sufficiently smart mapJoin would be able to handle this case...
|
|
117
149
|
// but for now we re-render everything after the splice point.
|
|
118
150
|
expect(count).toBe(4);
|
|
@@ -143,11 +175,13 @@ it("cleans up things which end up removed (with push)", () => {
|
|
|
143
175
|
Letter b
|
|
144
176
|
`);
|
|
145
177
|
items.pop();
|
|
178
|
+
flushJobs();
|
|
146
179
|
expect(cleanups).toEqual(["b"]);
|
|
147
180
|
expect(printTree(tree)).toBe(d`
|
|
148
181
|
Letter a
|
|
149
182
|
`);
|
|
150
183
|
items.pop();
|
|
184
|
+
flushJobs();
|
|
151
185
|
expect(cleanups).toEqual(["b", "a"]);
|
|
152
186
|
expect(printTree(tree)).toBe("");
|
|
153
187
|
});
|
|
@@ -174,7 +208,7 @@ it("cleans up things which end up removed (with splice)", () => {
|
|
|
174
208
|
Letter c
|
|
175
209
|
`);
|
|
176
210
|
items.splice(1, 1);
|
|
177
|
-
|
|
211
|
+
flushJobs();
|
|
178
212
|
// A sufficiently smart mapJoin would be able to handle this case...
|
|
179
213
|
// but for now we re-render everything after the splice point.
|
|
180
214
|
expect(cleanups).toEqual(["b", "c"]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circular-reactives.test.d.ts","sourceRoot":"","sources":["../../../test/reactivity/circular-reactives.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { shallowReactive } from "@vue/reactivity";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import { For } from "../../src/index.js";
|
|
5
|
+
import { printTree, renderTree } from "../../src/render.js";
|
|
6
|
+
import { d } from "../../testing/render.js";
|
|
7
|
+
it("it should work with circular reactives", () => {
|
|
8
|
+
const items = shallowReactive([]);
|
|
9
|
+
let added = false;
|
|
10
|
+
function MaybeAddString(props) {
|
|
11
|
+
if (!added) {
|
|
12
|
+
items.push("item " + items.length);
|
|
13
|
+
added = true;
|
|
14
|
+
}
|
|
15
|
+
return [_$memo(() => props.item)];
|
|
16
|
+
}
|
|
17
|
+
const template = [_$createComponent(For, {
|
|
18
|
+
each: items,
|
|
19
|
+
children: item => {
|
|
20
|
+
return _$createComponent(MaybeAddString, {
|
|
21
|
+
item: item
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
})];
|
|
25
|
+
const tree = renderTree(template);
|
|
26
|
+
items.push("item start");
|
|
27
|
+
expect(printTree(tree)).toBe(d`
|
|
28
|
+
item start
|
|
29
|
+
item 1
|
|
30
|
+
`);
|
|
31
|
+
});
|
|
@@ -2,6 +2,7 @@ import { effect, memo, onCleanup, createComponent as _$createComponent } from "@
|
|
|
2
2
|
import { ref } from "@vue/reactivity";
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import { renderTree } from "../../src/render.js";
|
|
5
|
+
import { flushJobs } from "../../src/scheduler.js";
|
|
5
6
|
describe("memo cleanup", () => {
|
|
6
7
|
it("cleans up when memo value is recomputed", () => {
|
|
7
8
|
const r = ref(1);
|
|
@@ -15,6 +16,7 @@ describe("memo cleanup", () => {
|
|
|
15
16
|
expect(m()).toBe(1);
|
|
16
17
|
expect(callCount).toBe(0);
|
|
17
18
|
r.value = 2;
|
|
19
|
+
flushJobs();
|
|
18
20
|
expect(m()).toBe(2);
|
|
19
21
|
expect(callCount).toBe(1);
|
|
20
22
|
});
|
|
@@ -31,6 +33,7 @@ describe("effect cleanup", () => {
|
|
|
31
33
|
});
|
|
32
34
|
expect(cleanedUp).toBe(false);
|
|
33
35
|
r.value = 2;
|
|
36
|
+
flushJobs();
|
|
34
37
|
expect(cleanedUp).toBe(true);
|
|
35
38
|
});
|
|
36
39
|
});
|
|
@@ -47,6 +50,7 @@ describe("element cleanup", () => {
|
|
|
47
50
|
const template = [el];
|
|
48
51
|
renderTree(template);
|
|
49
52
|
el.value = "";
|
|
53
|
+
flushJobs();
|
|
50
54
|
expect(cleanedUp).toBe(true);
|
|
51
55
|
});
|
|
52
56
|
it("should clean up when the element is unmounted, recursively", () => {
|
|
@@ -71,6 +75,7 @@ describe("element cleanup", () => {
|
|
|
71
75
|
const template = [el];
|
|
72
76
|
renderTree(template);
|
|
73
77
|
el.value = "";
|
|
78
|
+
flushJobs();
|
|
74
79
|
expect(cleanedUpC1).toBe(true);
|
|
75
80
|
expect(cleanedUpC2).toBe(true);
|
|
76
81
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ref } from "@vue/reactivity";
|
|
2
2
|
import { expect, it } from "vitest";
|
|
3
3
|
import { memo, untrack } from "../../src/jsx-runtime.js";
|
|
4
|
+
import { flushJobs } from "../../src/scheduler.js";
|
|
4
5
|
it("ignores signals for dependency tracking", () => {
|
|
5
6
|
const signal = ref(0);
|
|
6
7
|
const m = memo(() => {
|
|
@@ -8,6 +9,7 @@ it("ignores signals for dependency tracking", () => {
|
|
|
8
9
|
});
|
|
9
10
|
expect(m()).toBe(0);
|
|
10
11
|
signal.value = 1;
|
|
12
|
+
flushJobs();
|
|
11
13
|
expect(m()).toBe(0);
|
|
12
14
|
});
|
|
13
15
|
it("doesn't affect signal changes", () => {
|
|
@@ -19,5 +21,6 @@ it("doesn't affect signal changes", () => {
|
|
|
19
21
|
untrack(() => {
|
|
20
22
|
signal.value = 1;
|
|
21
23
|
});
|
|
24
|
+
flushJobs();
|
|
22
25
|
expect(m()).toBe(1);
|
|
23
26
|
});
|
|
@@ -2,6 +2,7 @@ import { memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-r
|
|
|
2
2
|
import { ref } from "@vue/reactivity";
|
|
3
3
|
import { expect, it } from "vitest";
|
|
4
4
|
import { renderTree } from "../../src/render.js";
|
|
5
|
+
import { flushJobs } from "../../src/scheduler.js";
|
|
5
6
|
it("memoizes child components", () => {
|
|
6
7
|
let renderCount = 0;
|
|
7
8
|
function Child() {
|
|
@@ -21,5 +22,6 @@ it("memoizes child components", () => {
|
|
|
21
22
|
const template = [items];
|
|
22
23
|
renderTree(template);
|
|
23
24
|
doThing.value = true;
|
|
25
|
+
flushJobs();
|
|
24
26
|
expect(renderCount).toBe(2);
|
|
25
27
|
});
|