@alloy-js/core 0.16.0 → 0.18.0-dev.2
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 +19 -235
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +85 -386
- package/dist/src/code.d.ts +1 -1
- package/dist/src/code.d.ts.map +1 -1
- package/dist/src/components/Block.d.ts +1 -1
- package/dist/src/components/Block.d.ts.map +1 -1
- package/dist/src/components/Block.js +3 -1
- package/dist/src/components/Declaration.d.ts +2 -2
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +6 -5
- package/dist/src/components/For.d.ts +1 -1
- package/dist/src/components/For.d.ts.map +1 -1
- package/dist/src/components/For.js +1 -1
- package/dist/src/components/Indent.d.ts +1 -1
- package/dist/src/components/Indent.d.ts.map +1 -1
- package/dist/src/components/List.d.ts +1 -1
- package/dist/src/components/List.d.ts.map +1 -1
- package/dist/src/components/List.js +3 -1
- package/dist/src/components/MemberDeclaration.d.ts +3 -3
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js +4 -4
- package/dist/src/components/MemberScope.d.ts +2 -2
- package/dist/src/components/MemberScope.d.ts.map +1 -1
- package/dist/src/components/MemberScope.js +0 -2
- package/dist/src/components/Output.d.ts +1 -1
- package/dist/src/components/Output.d.ts.map +1 -1
- package/dist/src/components/Output.js +1 -1
- package/dist/src/components/Prose.d.ts +1 -1
- package/dist/src/components/Prose.d.ts.map +1 -1
- package/dist/src/components/ReferenceOrContent.d.ts +1 -1
- package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
- package/dist/src/components/Scope.d.ts +2 -2
- package/dist/src/components/Scope.d.ts.map +1 -1
- package/dist/src/components/Scope.js +3 -6
- package/dist/src/components/Show.d.ts +1 -1
- package/dist/src/components/Show.d.ts.map +1 -1
- package/dist/src/components/SourceDirectory.d.ts +1 -1
- package/dist/src/components/SourceDirectory.d.ts.map +1 -1
- package/dist/src/components/SourceDirectory.js +1 -1
- package/dist/src/components/SourceFile.d.ts +1 -1
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +1 -1
- package/dist/src/components/StatementList.d.ts +1 -1
- package/dist/src/components/StatementList.d.ts.map +1 -1
- package/dist/src/components/StatementList.js +1 -1
- package/dist/src/components/Switch.d.ts +2 -2
- package/dist/src/components/Switch.d.ts.map +1 -1
- package/dist/src/components/Switch.js +2 -1
- package/dist/src/components/Wrap.d.ts +1 -1
- package/dist/src/components/Wrap.d.ts.map +1 -1
- package/dist/src/context/assignment.d.ts +1 -1
- package/dist/src/context/assignment.d.ts.map +1 -1
- package/dist/src/context/binder.d.ts +3 -3
- package/dist/src/context/binder.d.ts.map +1 -1
- package/dist/src/context/declaration.d.ts +1 -1
- package/dist/src/context/declaration.d.ts.map +1 -1
- package/dist/src/context/member-declaration.d.ts +1 -1
- package/dist/src/context/member-declaration.d.ts.map +1 -1
- package/dist/src/context/member-declaration.js +0 -1
- package/dist/src/context/member-scope.d.ts +1 -1
- package/dist/src/context/member-scope.d.ts.map +1 -1
- package/dist/src/context/name-policy.d.ts +1 -1
- package/dist/src/context/name-policy.d.ts.map +1 -1
- package/dist/src/context/scope.d.ts +1 -1
- package/dist/src/context/scope.d.ts.map +1 -1
- package/dist/src/context/source-directory.d.ts +1 -1
- package/dist/src/context/source-directory.d.ts.map +1 -1
- package/dist/src/context/source-file.d.ts +2 -2
- package/dist/src/context/source-file.d.ts.map +1 -1
- package/dist/src/context.d.ts +2 -2
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js +1 -1
- package/dist/src/debug.d.ts +1 -0
- package/dist/src/debug.d.ts.map +1 -1
- package/dist/src/debug.js +4 -1
- package/dist/src/index.d.ts +8 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -2
- package/dist/src/jsx-runtime.d.ts +4 -272
- package/dist/src/jsx-runtime.d.ts.map +1 -1
- package/dist/src/jsx-runtime.js +3 -315
- package/dist/src/props-combinators.d.ts +19 -0
- package/dist/src/props-combinators.d.ts.map +1 -0
- package/dist/src/props-combinators.js +108 -0
- package/dist/src/reactive-union-set.d.ts +29 -0
- package/dist/src/reactive-union-set.d.ts.map +1 -0
- package/dist/src/reactive-union-set.js +183 -0
- package/dist/src/reactivity.d.ts +75 -0
- package/dist/src/reactivity.d.ts.map +1 -0
- package/dist/src/reactivity.js +141 -0
- package/dist/src/refkey.d.ts +36 -0
- package/dist/src/refkey.d.ts.map +1 -1
- package/dist/src/refkey.js +40 -0
- package/dist/src/render.d.ts +5 -1
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +68 -15
- package/dist/src/runtime/component.d.ts +24 -0
- package/dist/src/runtime/component.d.ts.map +1 -0
- package/dist/src/runtime/component.js +19 -0
- package/dist/src/runtime/intrinsic.d.ts +168 -0
- package/dist/src/runtime/intrinsic.d.ts.map +1 -0
- package/dist/src/runtime/intrinsic.js +11 -0
- package/dist/src/scheduler.d.ts +2 -2
- package/dist/src/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler.js +27 -6
- package/dist/src/slot.d.ts +2 -2
- package/dist/src/slot.d.ts.map +1 -1
- package/dist/src/slot.js +1 -1
- package/dist/src/stc.d.ts +1 -1
- package/dist/src/stc.d.ts.map +1 -1
- package/dist/src/sti.d.ts +7 -6
- package/dist/src/sti.d.ts.map +1 -1
- package/dist/src/sti.js +1 -1
- package/dist/src/symbols/flags.d.ts +70 -0
- package/dist/src/symbols/flags.d.ts.map +1 -0
- package/dist/src/symbols/flags.js +72 -0
- package/dist/src/symbols/index.d.ts +7 -0
- package/dist/src/symbols/index.d.ts.map +1 -0
- package/dist/src/symbols/index.js +6 -0
- package/dist/src/symbols/output-scope.d.ts +94 -0
- package/dist/src/symbols/output-scope.d.ts.map +1 -0
- package/dist/src/symbols/output-scope.js +222 -0
- package/dist/src/symbols/output-symbol.d.ts +89 -0
- package/dist/src/symbols/output-symbol.d.ts.map +1 -0
- package/dist/src/symbols/output-symbol.js +333 -0
- package/dist/src/symbols/symbol-flow.d.ts +13 -0
- package/dist/src/symbols/symbol-flow.d.ts.map +1 -0
- package/dist/src/symbols/symbol-flow.js +74 -0
- package/dist/src/symbols/symbol-slot.d.ts +12 -0
- package/dist/src/symbols/symbol-slot.d.ts.map +1 -0
- package/dist/src/symbols/symbol-slot.js +36 -0
- package/dist/src/symbols/symbol-table.d.ts +14 -0
- package/dist/src/symbols/symbol-table.d.ts.map +1 -0
- package/dist/src/symbols/symbol-table.js +42 -0
- package/dist/src/tap.d.ts +3 -2
- package/dist/src/tap.d.ts.map +1 -1
- package/dist/src/tracer.d.ts +238 -0
- package/dist/src/tracer.d.ts.map +1 -0
- package/dist/src/tracer.js +496 -0
- package/dist/src/tsdoc-metadata.json +1 -1
- package/dist/src/utils.d.ts +4 -3
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +2 -1
- package/dist/test/components/slot.test.js +5 -7
- package/dist/test/props-with-defaults.test.js +1 -1
- package/dist/test/reactive-union-set.test.d.ts +2 -0
- package/dist/test/reactive-union-set.test.d.ts.map +1 -0
- package/dist/test/reactive-union-set.test.js +170 -0
- package/dist/test/reactivity/cleanup.test.js +2 -1
- package/dist/test/reactivity/memo.test.js +1 -1
- package/dist/test/reactivity/untrack.test.js +1 -1
- package/dist/test/rendering/memoization.test.js +2 -1
- package/dist/test/split-props.test.js +1 -1
- package/dist/test/symbols/output-scope.test.d.ts +2 -0
- package/dist/test/symbols/output-scope.test.d.ts.map +1 -0
- package/dist/test/symbols/output-scope.test.js +343 -0
- package/dist/test/symbols/output-symbol.test.d.ts +2 -0
- package/dist/test/symbols/output-symbol.test.d.ts.map +1 -0
- package/dist/test/symbols/output-symbol.test.js +447 -0
- package/dist/test/symbols/resolution.test.d.ts +2 -0
- package/dist/test/symbols/resolution.test.d.ts.map +1 -0
- package/dist/test/symbols/resolution.test.js +141 -0
- package/dist/test/symbols/utils.d.ts +25 -0
- package/dist/test/symbols/utils.d.ts.map +1 -0
- package/dist/test/symbols/utils.js +47 -0
- package/dist/testing/extend-expect.d.ts +15 -0
- package/dist/testing/extend-expect.d.ts.map +1 -1
- package/dist/testing/extend-expect.js +2 -1
- package/dist/testing/render.d.ts +1 -1
- package/dist/testing/render.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -24
- package/src/binder.ts +146 -672
- package/src/code.ts +1 -1
- package/src/components/Block.tsx +4 -1
- package/src/components/Declaration.tsx +8 -7
- package/src/components/For.tsx +2 -1
- package/src/components/Indent.tsx +1 -1
- package/src/components/List.tsx +3 -1
- package/src/components/MemberDeclaration.tsx +7 -6
- package/src/components/MemberScope.tsx +2 -5
- package/src/components/Output.tsx +2 -1
- package/src/components/Prose.tsx +1 -1
- package/src/components/ReferenceOrContent.tsx +1 -1
- package/src/components/Scope.tsx +3 -7
- package/src/components/Show.tsx +1 -1
- package/src/components/SourceDirectory.tsx +2 -1
- package/src/components/SourceFile.tsx +2 -1
- package/src/components/StatementList.tsx +2 -1
- package/src/components/Switch.tsx +2 -1
- package/src/components/Wrap.tsx +1 -1
- package/src/context/assignment.ts +1 -1
- package/src/context/binder.ts +3 -3
- package/src/context/declaration.ts +1 -1
- package/src/context/member-declaration.ts +1 -1
- package/src/context/member-scope.ts +1 -1
- package/src/context/name-policy.ts +1 -1
- package/src/context/scope.ts +1 -1
- package/src/context/source-directory.ts +1 -1
- package/src/context/source-file.ts +2 -2
- package/src/context.ts +3 -7
- package/src/debug.ts +5 -1
- package/src/index.ts +15 -1
- package/src/jsx-runtime.ts +15 -674
- package/src/props-combinators.ts +148 -0
- package/src/reactive-union-set.ts +238 -0
- package/src/reactivity.ts +230 -0
- package/src/refkey.ts +40 -0
- package/src/render.ts +97 -26
- package/src/runtime/component.ts +67 -0
- package/src/runtime/intrinsic.ts +199 -0
- package/src/scheduler.ts +31 -6
- package/src/slot.ts +3 -4
- package/src/stc.ts +2 -2
- package/src/sti.ts +11 -11
- package/src/symbols/flags.ts +82 -0
- package/src/symbols/index.ts +6 -0
- package/src/symbols/output-scope.ts +296 -0
- package/src/symbols/output-symbol.ts +459 -0
- package/src/symbols/symbol-flow.ts +100 -0
- package/src/symbols/symbol-slot.tsx +48 -0
- package/src/symbols/symbol-table.ts +72 -0
- package/src/tap.ts +3 -2
- package/src/tracer.ts +474 -0
- package/src/utils.tsx +7 -5
- package/temp/api.json +7446 -5133
- package/test/components/slot.test.tsx +8 -11
- package/test/props-with-defaults.test.ts +1 -1
- package/test/reactive-union-set.test.tsx +191 -0
- package/test/reactivity/cleanup.test.tsx +2 -1
- package/test/reactivity/memo.test.tsx +1 -1
- package/test/reactivity/untrack.test.ts +1 -1
- package/test/rendering/basic.test.tsx +1 -1
- package/test/rendering/memoization.test.tsx +1 -1
- package/test/split-props.test.ts +1 -1
- package/test/symbols/output-scope.test.ts +300 -0
- package/test/symbols/output-symbol.test.ts +456 -0
- package/test/symbols/resolution.test.ts +170 -0
- package/test/symbols/utils.ts +93 -0
- package/test/utils.test.tsx +1 -1
- package/testing/extend-expect.ts +16 -0
- package/testing/render.ts +1 -2
- package/LICENSE +0 -7
- package/dist/test/symbols.test.d.ts +0 -2
- package/dist/test/symbols.test.d.ts.map +0 -1
- package/dist/test/symbols.test.js +0 -884
- package/test/symbols.test.ts +0 -1006
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { computed, isReactive, proxyRefs, toRefs } from "@vue/reactivity";
|
|
2
|
+
import { untrack } from "./reactivity.js";
|
|
3
|
+
export function mergeProps(...sources) {
|
|
4
|
+
const target = {};
|
|
5
|
+
for (let i = 0; i < sources.length; i++) {
|
|
6
|
+
let source = sources[i];
|
|
7
|
+
if (typeof source === "function") source = source();
|
|
8
|
+
if (source) {
|
|
9
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
10
|
+
for (const key in descriptors) {
|
|
11
|
+
if (key in target) continue;
|
|
12
|
+
Object.defineProperty(target, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get() {
|
|
15
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
16
|
+
let s = sources[i];
|
|
17
|
+
if (typeof s === "function") s = s();
|
|
18
|
+
const v = (s || {})[key];
|
|
19
|
+
if (v !== undefined) return v;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return target;
|
|
27
|
+
}
|
|
28
|
+
export function splitProps(props, ...keys) {
|
|
29
|
+
if (isReactive(props)) {
|
|
30
|
+
const refs = untrack(() => toRefs(props));
|
|
31
|
+
const remainingKeys = new Set(Object.keys(refs));
|
|
32
|
+
const result = keys.map(keySet => {
|
|
33
|
+
const resultSet = {};
|
|
34
|
+
for (const key of keySet) {
|
|
35
|
+
resultSet[key] = refs[key];
|
|
36
|
+
remainingKeys.delete(key);
|
|
37
|
+
}
|
|
38
|
+
return proxyRefs(resultSet);
|
|
39
|
+
});
|
|
40
|
+
const remaining = {};
|
|
41
|
+
for (const key of remainingKeys) {
|
|
42
|
+
remaining[key] = refs[key];
|
|
43
|
+
}
|
|
44
|
+
return [...result, proxyRefs(remaining)];
|
|
45
|
+
}
|
|
46
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
47
|
+
const remainingKeys = new Set(Object.keys(descriptors));
|
|
48
|
+
const result = keys.map(keySet => {
|
|
49
|
+
const resultSet = {};
|
|
50
|
+
for (const key of keySet) {
|
|
51
|
+
if (key in descriptors) {
|
|
52
|
+
Object.defineProperty(resultSet, key, descriptors[key]);
|
|
53
|
+
remainingKeys.delete(key);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return resultSet;
|
|
57
|
+
});
|
|
58
|
+
const remaining = {};
|
|
59
|
+
for (const key of remainingKeys) {
|
|
60
|
+
Object.defineProperty(remaining, key, descriptors[key]);
|
|
61
|
+
}
|
|
62
|
+
return [...result, remaining];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Applies default values to a props object. Reactive props are handled properly
|
|
67
|
+
* by ensuring that their value is not accessed by `defaultProps`, avoiding any
|
|
68
|
+
* unintended side effects.
|
|
69
|
+
*/
|
|
70
|
+
export function defaultProps(props, defaults) {
|
|
71
|
+
if (isReactive(props)) {
|
|
72
|
+
const refs = untrack(() => toRefs(props));
|
|
73
|
+
for (const key in defaults) {
|
|
74
|
+
const originalRef = refs[key];
|
|
75
|
+
refs[key] = computed(() => originalRef.value === undefined ? defaults[key] : originalRef.value);
|
|
76
|
+
}
|
|
77
|
+
return proxyRefs(refs);
|
|
78
|
+
}
|
|
79
|
+
const withDefaults = {};
|
|
80
|
+
const copied = new Set();
|
|
81
|
+
for (const key in defaults) {
|
|
82
|
+
copied.add(key);
|
|
83
|
+
const desc = Object.getOwnPropertyDescriptor(props, key);
|
|
84
|
+
if (!desc) {
|
|
85
|
+
withDefaults[key] = defaults[key];
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (desc.get) {
|
|
89
|
+
const originalGet = desc.get;
|
|
90
|
+
desc.get = function () {
|
|
91
|
+
const value = originalGet.call(this);
|
|
92
|
+
return value === undefined ? defaults[key] : value;
|
|
93
|
+
};
|
|
94
|
+
Object.defineProperty(withDefaults, key, desc);
|
|
95
|
+
} else {
|
|
96
|
+
desc.value = desc.value === undefined ? defaults[key] : desc.value;
|
|
97
|
+
Object.defineProperty(withDefaults, key, desc);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
101
|
+
for (const key in descriptors) {
|
|
102
|
+
if (copied.has(key)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
Object.defineProperty(withDefaults, key, descriptors[key]);
|
|
106
|
+
}
|
|
107
|
+
return withDefaults;
|
|
108
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ReactiveFlags } from "@vue/reactivity";
|
|
2
|
+
export interface ReactiveUnionSetOptions<T> {
|
|
3
|
+
onAdd?: OnReactiveSetAddCallback<T>;
|
|
4
|
+
onDelete?: OnReactiveSetDeleteCallback<T>;
|
|
5
|
+
}
|
|
6
|
+
export type OnReactiveSetDeleteCallback<T> = (value: T) => void;
|
|
7
|
+
export type OnReactiveSetAddCallback<T> = (value: T) => T;
|
|
8
|
+
export declare class ReactiveUnionSet<T> extends Set<T> {
|
|
9
|
+
private _subsets;
|
|
10
|
+
private _onAdd?;
|
|
11
|
+
private _onDelete?;
|
|
12
|
+
private _refcounts;
|
|
13
|
+
private _indexes;
|
|
14
|
+
[ReactiveFlags.IS_REACTIVE]: boolean;
|
|
15
|
+
private _handleAdd;
|
|
16
|
+
private _handleDelete;
|
|
17
|
+
constructor(options?: ReactiveUnionSetOptions<T>);
|
|
18
|
+
get size(): number;
|
|
19
|
+
[Symbol.iterator](): SetIterator<T>;
|
|
20
|
+
keys(): SetIterator<T>;
|
|
21
|
+
values(): SetIterator<T>;
|
|
22
|
+
entries(): SetIterator<[T, T]>;
|
|
23
|
+
add(item: T): this;
|
|
24
|
+
delete(item: T): boolean;
|
|
25
|
+
addSubset(subset: Set<T>, options?: ReactiveUnionSetOptions<T>): void;
|
|
26
|
+
createDerivedSet<U>(mapper: (value: T) => U | U[]): Readonly<import("@vue/reactivity").ShallowReactive<Set<U>>>;
|
|
27
|
+
createIndex<U>(mapper: (value: T) => U | U[]): ReadonlyMap<U, T>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=reactive-union-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive-union-set.d.ts","sourceRoot":"","sources":["../../src/reactive-union-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAOd,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,wBAAwB,CAAC,CAAC,CA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,GAAG,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;CA4BjE"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { ITERATE_KEY, ReactiveFlags, shallowReactive, shallowReadonly, track, TrackOpTypes, trigger, TriggerOpTypes } from "@vue/reactivity";
|
|
2
|
+
import { effect } from "./reactivity.js";
|
|
3
|
+
export class ReactiveUnionSet extends Set {
|
|
4
|
+
_refcounts = new Map();
|
|
5
|
+
_indexes = [];
|
|
6
|
+
[ReactiveFlags.IS_REACTIVE] = true;
|
|
7
|
+
_handleAdd(value) {
|
|
8
|
+
value = this._onAdd ? this._onAdd(value) : value;
|
|
9
|
+
for (const index of this._indexes) {
|
|
10
|
+
index.add(value);
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
_handleDelete(value) {
|
|
15
|
+
if (this._onDelete) {
|
|
16
|
+
this._onDelete(value);
|
|
17
|
+
}
|
|
18
|
+
for (const index of this._indexes) {
|
|
19
|
+
index.delete(value);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
super();
|
|
25
|
+
this._subsets = new Set();
|
|
26
|
+
this._onAdd = options.onAdd;
|
|
27
|
+
this._onDelete = options.onDelete;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
get size() {
|
|
31
|
+
track(this, TrackOpTypes.ITERATE, ITERATE_KEY);
|
|
32
|
+
return super.size;
|
|
33
|
+
}
|
|
34
|
+
[Symbol.iterator]() {
|
|
35
|
+
track(this, TrackOpTypes.ITERATE, ITERATE_KEY);
|
|
36
|
+
return super[Symbol.iterator]();
|
|
37
|
+
}
|
|
38
|
+
keys() {
|
|
39
|
+
track(this, TrackOpTypes.ITERATE, ITERATE_KEY);
|
|
40
|
+
return super.keys();
|
|
41
|
+
}
|
|
42
|
+
values() {
|
|
43
|
+
track(this, TrackOpTypes.ITERATE, ITERATE_KEY);
|
|
44
|
+
return super.values();
|
|
45
|
+
}
|
|
46
|
+
entries() {
|
|
47
|
+
track(this, TrackOpTypes.ITERATE, ITERATE_KEY);
|
|
48
|
+
return super.entries();
|
|
49
|
+
}
|
|
50
|
+
add(item) {
|
|
51
|
+
if (this._refcounts.has(item)) {
|
|
52
|
+
this._refcounts.set(item, this._refcounts.get(item) + 1);
|
|
53
|
+
} else {
|
|
54
|
+
this._refcounts.set(item, 1);
|
|
55
|
+
super.add(item);
|
|
56
|
+
this._handleAdd(item);
|
|
57
|
+
trigger(this, TriggerOpTypes.ADD, item, item);
|
|
58
|
+
}
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
delete(item) {
|
|
62
|
+
const count = this._refcounts.get(item);
|
|
63
|
+
if (count === undefined) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (count > 1) {
|
|
67
|
+
this._refcounts.set(item, count - 1);
|
|
68
|
+
} else {
|
|
69
|
+
this._refcounts.delete(item);
|
|
70
|
+
super.delete(item);
|
|
71
|
+
this._handleDelete(item);
|
|
72
|
+
trigger(this, TriggerOpTypes.DELETE, undefined, item);
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
addSubset(subset, options = {}) {
|
|
77
|
+
if (this._subsets.has(subset)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const {
|
|
81
|
+
onAdd,
|
|
82
|
+
onDelete
|
|
83
|
+
} = options;
|
|
84
|
+
this._subsets.add(subset);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Contains a map of the previous values and their mapped values
|
|
88
|
+
* that were added to the parent set.
|
|
89
|
+
*/
|
|
90
|
+
const prevValues = new Map();
|
|
91
|
+
effect(() => {
|
|
92
|
+
for (const [prevSourceValue, prevTargetValue] of prevValues) {
|
|
93
|
+
if (!subset.has(prevSourceValue)) {
|
|
94
|
+
onDelete?.(prevSourceValue);
|
|
95
|
+
prevValues.delete(prevSourceValue);
|
|
96
|
+
this.delete(prevTargetValue);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const value of subset) {
|
|
100
|
+
if (!prevValues.has(value)) {
|
|
101
|
+
if (onAdd) {
|
|
102
|
+
const added = onAdd(value);
|
|
103
|
+
prevValues.set(value, added);
|
|
104
|
+
} else {
|
|
105
|
+
this.add(value);
|
|
106
|
+
prevValues.set(value, value);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
createDerivedSet(mapper) {
|
|
113
|
+
const set = shallowReactive(new Set());
|
|
114
|
+
const refcounts = new Map();
|
|
115
|
+
function ref(value) {
|
|
116
|
+
if (refcounts.has(value)) {
|
|
117
|
+
const count = refcounts.get(value) + 1;
|
|
118
|
+
refcounts.set(value, count);
|
|
119
|
+
return count;
|
|
120
|
+
} else {
|
|
121
|
+
refcounts.set(value, 1);
|
|
122
|
+
set.add(value);
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function unref(value) {
|
|
127
|
+
const count = refcounts.get(value);
|
|
128
|
+
if (count > 1) {
|
|
129
|
+
refcounts.set(value, count - 1);
|
|
130
|
+
return count - 1;
|
|
131
|
+
} else {
|
|
132
|
+
refcounts.delete(value);
|
|
133
|
+
set.delete(value);
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this._indexes.push({
|
|
138
|
+
add: value => {
|
|
139
|
+
effect(prev => {
|
|
140
|
+
for (const id of [prev].flat()) {
|
|
141
|
+
unref(id);
|
|
142
|
+
}
|
|
143
|
+
const mappedValue = mapper(value);
|
|
144
|
+
for (const id of [mappedValue].flat()) {
|
|
145
|
+
ref(id);
|
|
146
|
+
}
|
|
147
|
+
return mappedValue;
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
delete: value => {
|
|
151
|
+
const mappedValue = mapper(value);
|
|
152
|
+
for (const id of [mappedValue].flat()) {
|
|
153
|
+
unref(id);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return shallowReadonly(set);
|
|
158
|
+
}
|
|
159
|
+
createIndex(mapper) {
|
|
160
|
+
const index = shallowReactive(new Map());
|
|
161
|
+
this._indexes.push({
|
|
162
|
+
add: value => {
|
|
163
|
+
effect(oldValue => {
|
|
164
|
+
for (const id of [oldValue].flat()) {
|
|
165
|
+
index.delete(id);
|
|
166
|
+
}
|
|
167
|
+
const mappedValue = mapper(value);
|
|
168
|
+
for (const id of [mappedValue].flat()) {
|
|
169
|
+
index.set(id, value);
|
|
170
|
+
}
|
|
171
|
+
return mappedValue;
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
delete: value => {
|
|
175
|
+
const mappedValue = mapper(value);
|
|
176
|
+
for (const id of [mappedValue].flat()) {
|
|
177
|
+
index.delete(id);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return shallowReadonly(index);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ShallowReactive } from "@vue/reactivity";
|
|
2
|
+
import type { RenderedTextTree } from "./render.js";
|
|
3
|
+
import type { Children, ComponentCreator } from "./runtime/component.js";
|
|
4
|
+
import type { OutputSymbol } from "./symbols/output-symbol.js";
|
|
5
|
+
export declare function getElementCache(): ElementCache;
|
|
6
|
+
export type ElementCacheKey = ComponentCreator | (() => unknown) | CustomContext;
|
|
7
|
+
export type ElementCache = Map<ElementCacheKey, RenderedTextTree>;
|
|
8
|
+
export interface Disposable {
|
|
9
|
+
(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface Context {
|
|
12
|
+
disposables: Disposable[];
|
|
13
|
+
owner: Context | null;
|
|
14
|
+
context?: Record<symbol, unknown>;
|
|
15
|
+
meta?: Record<string, any>;
|
|
16
|
+
/**
|
|
17
|
+
* A cache of RenderTextTree nodes created within this context,
|
|
18
|
+
* indexed by the component or function which created them.
|
|
19
|
+
*/
|
|
20
|
+
elementCache: ElementCache;
|
|
21
|
+
/**
|
|
22
|
+
* When this context was created by a component, this will
|
|
23
|
+
* be the component that created it.
|
|
24
|
+
*/
|
|
25
|
+
componentOwner?: ComponentCreator<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Whether this context will take an emitted symbol.
|
|
28
|
+
*/
|
|
29
|
+
takesSymbols: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The symbol that this component has taken.
|
|
32
|
+
*/
|
|
33
|
+
takenSymbols?: ShallowReactive<Set<OutputSymbol>>;
|
|
34
|
+
}
|
|
35
|
+
export declare function getContext(): Context | null;
|
|
36
|
+
export interface RootOptions {
|
|
37
|
+
componentOwner?: ComponentCreator<any>;
|
|
38
|
+
}
|
|
39
|
+
export declare function root<T>(fn: (d: Disposable) => T, options?: RootOptions): T;
|
|
40
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
41
|
+
export declare function memo<T>(fn: () => T, equal?: boolean): () => T;
|
|
42
|
+
export declare function effect<T>(fn: (prev?: T) => T, current?: T): void;
|
|
43
|
+
/**
|
|
44
|
+
* Register a cleanup function which is called when the current reactive scope
|
|
45
|
+
* is recalculated or disposed. This is useful to clean up any side effects
|
|
46
|
+
* created in the reactive scope.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
*
|
|
50
|
+
* When onCleanup is called inside a component definition, the provided function
|
|
51
|
+
* is called when the component is removed from the tree. This can be useful to
|
|
52
|
+
* clean up any side effects created as a result of rendering the component. For
|
|
53
|
+
* example, if rendering a component creates a symbol, `onCleanup` can be used
|
|
54
|
+
* to remove the symbol when the component is removed from the tree.
|
|
55
|
+
*
|
|
56
|
+
* When onCleanup is called inside a memo or effect, the function is called when
|
|
57
|
+
* the effect is refreshed (e.g. when a memo or computed recalculates) or
|
|
58
|
+
* disposed (e.g. it is no longer needed because it is attached to a component
|
|
59
|
+
* which was removed).
|
|
60
|
+
*/
|
|
61
|
+
export declare function onCleanup(fn: Disposable): void;
|
|
62
|
+
/**
|
|
63
|
+
* Create a custom reactive context for the children returned by
|
|
64
|
+
* the provided context.
|
|
65
|
+
*/
|
|
66
|
+
export interface CustomContext {
|
|
67
|
+
[CUSTOM_CONTEXT_SYM]: true;
|
|
68
|
+
useCustomContext: (useCb: CustomContextChildrenCallback) => void;
|
|
69
|
+
}
|
|
70
|
+
export type CustomContextChildrenCallback = (child: Children) => void;
|
|
71
|
+
declare const CUSTOM_CONTEXT_SYM: unique symbol;
|
|
72
|
+
export declare function createCustomContext(useCallback: (useChildren: CustomContextChildrenCallback) => void): CustomContext;
|
|
73
|
+
export declare function isCustomContext(child: Children): child is CustomContext;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=reactivity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactivity.d.ts","sourceRoot":"","sources":["../../src/reactivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAW/D,wBAAgB,eAAe,iBAE9B;AAED,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,CAAC,MAAM,OAAO,CAAC,GACf,aAAa,CAAC;AAElB,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAElE,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,C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AM,kBAAkB,eAAW,CAAC;AAEpC,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,CAAC,WAAW,EAAE,6BAA6B,KAAK,IAAI,GAChE,aAAa,CAOf;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,IAAI,aAAa,CAMvE"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { pauseTracking, resetTracking, shallowRef, stop, effect as vueEffect } from "@vue/reactivity";
|
|
2
|
+
import { scheduler } from "./scheduler.js";
|
|
3
|
+
import { trace, TracePhase } from "./tracer.js";
|
|
4
|
+
|
|
5
|
+
// check for multiple versions of alloy here.
|
|
6
|
+
if (globalThis.__ALLOY__) {
|
|
7
|
+
throw new Error("Multiple versions of Alloy are loaded for this project. This will likely cause undesirable behavior.");
|
|
8
|
+
}
|
|
9
|
+
globalThis.__ALLOY__ = true;
|
|
10
|
+
export function getElementCache() {
|
|
11
|
+
return getContext().elementCache;
|
|
12
|
+
}
|
|
13
|
+
let globalContext = null;
|
|
14
|
+
export function getContext() {
|
|
15
|
+
return globalContext;
|
|
16
|
+
}
|
|
17
|
+
export function root(fn, options) {
|
|
18
|
+
const context = {
|
|
19
|
+
componentOwner: options?.componentOwner,
|
|
20
|
+
disposables: [],
|
|
21
|
+
owner: globalContext,
|
|
22
|
+
context: {},
|
|
23
|
+
elementCache: new Map(),
|
|
24
|
+
takesSymbols: false,
|
|
25
|
+
takenSymbols: undefined
|
|
26
|
+
};
|
|
27
|
+
globalContext = context;
|
|
28
|
+
let ret;
|
|
29
|
+
try {
|
|
30
|
+
ret = untrack(() => fn(() => {
|
|
31
|
+
for (const d of context.disposables) {
|
|
32
|
+
d();
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
} finally {
|
|
36
|
+
globalContext = globalContext.owner;
|
|
37
|
+
}
|
|
38
|
+
return ret;
|
|
39
|
+
}
|
|
40
|
+
export function untrack(fn) {
|
|
41
|
+
pauseTracking();
|
|
42
|
+
const v = fn();
|
|
43
|
+
resetTracking();
|
|
44
|
+
return v;
|
|
45
|
+
}
|
|
46
|
+
export function memo(fn, equal) {
|
|
47
|
+
const o = shallowRef();
|
|
48
|
+
effect(prev => {
|
|
49
|
+
const res = fn();
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
51
|
+
(!equal || prev !== res) && (o.value = res);
|
|
52
|
+
return res;
|
|
53
|
+
}, undefined);
|
|
54
|
+
return () => o.value;
|
|
55
|
+
}
|
|
56
|
+
export function effect(fn, current) {
|
|
57
|
+
const context = {
|
|
58
|
+
context: {},
|
|
59
|
+
disposables: [],
|
|
60
|
+
owner: globalContext,
|
|
61
|
+
elementCache: new Map(),
|
|
62
|
+
takesSymbols: false,
|
|
63
|
+
takenSymbols: undefined
|
|
64
|
+
};
|
|
65
|
+
const cleanupFn = final => {
|
|
66
|
+
const d = context.disposables;
|
|
67
|
+
context.disposables = [];
|
|
68
|
+
for (let k = 0, len = d.length; k < len; k++) d[k]();
|
|
69
|
+
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
71
|
+
final && stop(runner);
|
|
72
|
+
};
|
|
73
|
+
onCleanup(() => cleanupFn(true));
|
|
74
|
+
const runner = vueEffect(() => {
|
|
75
|
+
cleanupFn(false);
|
|
76
|
+
const oldContext = globalContext;
|
|
77
|
+
globalContext = context;
|
|
78
|
+
try {
|
|
79
|
+
current = fn(current);
|
|
80
|
+
} finally {
|
|
81
|
+
globalContext = oldContext;
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
scheduler: scheduler(() => runner),
|
|
85
|
+
onTrack(event) {
|
|
86
|
+
trace(TracePhase.effect.track, () => {
|
|
87
|
+
return `tracking ${event.target}, ${event.key}`;
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
onTrigger(event) {
|
|
91
|
+
trace(TracePhase.effect.trigger, () => {
|
|
92
|
+
return `triggering ${event.target}, ${event.key}`;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// allow recursive effects (recursive option does nothing, possible bug)
|
|
98
|
+
runner.effect.flags |= 1 << 5;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Register a cleanup function which is called when the current reactive scope
|
|
103
|
+
* is recalculated or disposed. This is useful to clean up any side effects
|
|
104
|
+
* created in the reactive scope.
|
|
105
|
+
*
|
|
106
|
+
* @remarks
|
|
107
|
+
*
|
|
108
|
+
* When onCleanup is called inside a component definition, the provided function
|
|
109
|
+
* is called when the component is removed from the tree. This can be useful to
|
|
110
|
+
* clean up any side effects created as a result of rendering the component. For
|
|
111
|
+
* example, if rendering a component creates a symbol, `onCleanup` can be used
|
|
112
|
+
* to remove the symbol when the component is removed from the tree.
|
|
113
|
+
*
|
|
114
|
+
* When onCleanup is called inside a memo or effect, the function is called when
|
|
115
|
+
* the effect is refreshed (e.g. when a memo or computed recalculates) or
|
|
116
|
+
* disposed (e.g. it is no longer needed because it is attached to a component
|
|
117
|
+
* which was removed).
|
|
118
|
+
*/
|
|
119
|
+
export function onCleanup(fn) {
|
|
120
|
+
if (globalContext != null) {
|
|
121
|
+
globalContext.disposables.push(fn);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Create a custom reactive context for the children returned by
|
|
127
|
+
* the provided context.
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
const CUSTOM_CONTEXT_SYM = Symbol();
|
|
131
|
+
export function createCustomContext(useCallback) {
|
|
132
|
+
return {
|
|
133
|
+
[CUSTOM_CONTEXT_SYM]: true,
|
|
134
|
+
useCustomContext(useCb) {
|
|
135
|
+
useCallback(useCb);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
export function isCustomContext(child) {
|
|
140
|
+
return typeof child === "object" && child !== null && Object.hasOwn(child, CUSTOM_CONTEXT_SYM);
|
|
141
|
+
}
|
package/dist/src/refkey.d.ts
CHANGED
|
@@ -4,6 +4,42 @@ export type Refkey = {
|
|
|
4
4
|
[RefkeySym]: true;
|
|
5
5
|
};
|
|
6
6
|
export declare function isRefkey(value: unknown): value is Refkey;
|
|
7
|
+
/**
|
|
8
|
+
* Create a refkey for the provided arguments. Passing no arguments returns a
|
|
9
|
+
* fresh refkey that is guaranteed to be unique. Otherwise, the arguments passed
|
|
10
|
+
* will be used to create a refkey for those values. Providing the same
|
|
11
|
+
* arguments will always return the same refkey.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
*
|
|
15
|
+
* Values are compared using the SameValueZero algorithm, which considers
|
|
16
|
+
* objects the same if they are reference identical, and primitives the same if
|
|
17
|
+
* they are the same value, with the exception of `NaN`, which is always considered
|
|
18
|
+
* equal to other `NaN` values, and `-0`, which is considered identical to `+0`
|
|
19
|
+
*/
|
|
7
20
|
export declare function refkey(...args: unknown[]): Refkey;
|
|
21
|
+
/**
|
|
22
|
+
* Create a refkey for an instantiation of a symbol.
|
|
23
|
+
*
|
|
24
|
+
* @param base - The refkey of the symbol holding the instantiation.
|
|
25
|
+
* @param member - The refkey of the non-instantiated member symbol (either the
|
|
26
|
+
* instance or static member symbol)
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
*
|
|
30
|
+
* Refkeys for instantiated and copied members are a composite refkey of the
|
|
31
|
+
* owner's refkey and the member's refkey. So for example, given a refkey for an
|
|
32
|
+
* instantiation of a class `rk1`, and a refkey for the instance member of that
|
|
33
|
+
* class `rk2`, the refkey for the instantiated static member is
|
|
34
|
+
* `refkey(rk1, rk2)`. This function will return the same refkey given those
|
|
35
|
+
* same parameters.
|
|
36
|
+
*
|
|
37
|
+
* When a static member symbol `rk3` is owned by another static or instance
|
|
38
|
+
* member symbol (i.e. the outer symbol is itself a member container), the
|
|
39
|
+
* refkey of the instaniated static member is still just the composite of the
|
|
40
|
+
* instantiated variable refkey and the refkey of the inner member
|
|
41
|
+
* `refkey(rk1, rk3)`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function memberRefkey(base: Refkey, member: Refkey): Refkey;
|
|
8
44
|
export {};
|
|
9
45
|
//# sourceMappingURL=refkey.d.ts.map
|
package/dist/src/refkey.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refkey.d.ts","sourceRoot":"","sources":["../../src/refkey.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,SAAS,EAAE,OAAO,MAAiB,CAAC;AAE1C,MAAM,MAAM,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,CAAC,SAAS,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAaxD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAMxD;
|
|
1
|
+
{"version":3,"file":"refkey.d.ts","sourceRoot":"","sources":["../../src/refkey.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,SAAS,EAAE,OAAO,MAAiB,CAAC;AAE1C,MAAM,MAAM,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,CAAC,SAAS,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAaxD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAMxD;AAcD;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAWjD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjE"}
|
package/dist/src/refkey.js
CHANGED
|
@@ -31,6 +31,20 @@ function getKey(value) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
const knownRefkeys = new Map();
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Create a refkey for the provided arguments. Passing no arguments returns a
|
|
37
|
+
* fresh refkey that is guaranteed to be unique. Otherwise, the arguments passed
|
|
38
|
+
* will be used to create a refkey for those values. Providing the same
|
|
39
|
+
* arguments will always return the same refkey.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
*
|
|
43
|
+
* Values are compared using the SameValueZero algorithm, which considers
|
|
44
|
+
* objects the same if they are reference identical, and primitives the same if
|
|
45
|
+
* they are the same value, with the exception of `NaN`, which is always considered
|
|
46
|
+
* equal to other `NaN` values, and `-0`, which is considered identical to `+0`
|
|
47
|
+
*/
|
|
34
48
|
export function refkey(...args) {
|
|
35
49
|
const keys = args.length === 0 ? [getKey({})] : args.map(v => getKey(v));
|
|
36
50
|
const compositeKey = keys.map(v => v.key).join("\u2063");
|
|
@@ -40,4 +54,30 @@ export function refkey(...args) {
|
|
|
40
54
|
const key = createRefkey(compositeKey);
|
|
41
55
|
knownRefkeys.set(compositeKey, key);
|
|
42
56
|
return key;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create a refkey for an instantiation of a symbol.
|
|
61
|
+
*
|
|
62
|
+
* @param base - The refkey of the symbol holding the instantiation.
|
|
63
|
+
* @param member - The refkey of the non-instantiated member symbol (either the
|
|
64
|
+
* instance or static member symbol)
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
*
|
|
68
|
+
* Refkeys for instantiated and copied members are a composite refkey of the
|
|
69
|
+
* owner's refkey and the member's refkey. So for example, given a refkey for an
|
|
70
|
+
* instantiation of a class `rk1`, and a refkey for the instance member of that
|
|
71
|
+
* class `rk2`, the refkey for the instantiated static member is
|
|
72
|
+
* `refkey(rk1, rk2)`. This function will return the same refkey given those
|
|
73
|
+
* same parameters.
|
|
74
|
+
*
|
|
75
|
+
* When a static member symbol `rk3` is owned by another static or instance
|
|
76
|
+
* member symbol (i.e. the outer symbol is itself a member container), the
|
|
77
|
+
* refkey of the instaniated static member is still just the composite of the
|
|
78
|
+
* instantiated variable refkey and the refkey of the inner member
|
|
79
|
+
* `refkey(rk1, rk3)`.
|
|
80
|
+
*/
|
|
81
|
+
export function memberRefkey(base, member) {
|
|
82
|
+
return refkey(base, member);
|
|
43
83
|
}
|
package/dist/src/render.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Doc } from "prettier";
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from "./reactivity.js";
|
|
3
|
+
import { Children, Component, Props } from "./runtime/component.js";
|
|
3
4
|
/**
|
|
4
5
|
* Turning components into source text involves three different trees produced
|
|
5
6
|
* sequentially:
|
|
@@ -119,4 +120,7 @@ export interface PrintTreeOptions {
|
|
|
119
120
|
tabWidth?: number;
|
|
120
121
|
}
|
|
121
122
|
export declare function printTree(tree: RenderedTextTree, options?: PrintTreeOptions): string;
|
|
123
|
+
export declare function pushStack(component: Component<any>, props: Props): void;
|
|
124
|
+
export declare function popStack(): void;
|
|
125
|
+
export declare function printRenderStack(): void;
|
|
122
126
|
//# sourceMappingURL=render.d.ts.map
|
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;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAO,MAAM,UAAU,CAAC;AAKpC,OAAO,EACL,OAAO,EAQR,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,QAAQ,EACR,SAAS,EAET,KAAK,EACN,MAAM,wBAAwB,CAAC;AA0BhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,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