@alloy-js/core 0.20.0-dev.3 → 0.20.0-dev.6
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/src/binder.d.ts +62 -38
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +214 -173
- 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 +8 -2
- package/dist/src/components/MemberDeclaration.d.ts +2 -2
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js +9 -5
- package/dist/src/components/MemberScope.d.ts +30 -13
- package/dist/src/components/MemberScope.d.ts.map +1 -1
- package/dist/src/components/MemberScope.js +37 -15
- package/dist/src/components/Output.d.ts.map +1 -1
- package/dist/src/components/Output.js +2 -5
- 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 +5 -5
- package/dist/src/components/Scope.d.ts.map +1 -1
- package/dist/src/components/Scope.js +9 -5
- package/dist/src/context/member-scope.d.ts +7 -8
- package/dist/src/context/member-scope.d.ts.map +1 -1
- package/dist/src/context/member-scope.js +5 -5
- package/dist/src/context/name-policy.d.ts.map +1 -1
- package/dist/src/context/name-policy.js +3 -0
- package/dist/src/context/scope.d.ts +1 -0
- package/dist/src/context/scope.d.ts.map +1 -1
- package/dist/src/context/scope.js +7 -0
- package/dist/src/inspect.browser.d.ts +5 -0
- package/dist/src/inspect.browser.d.ts.map +1 -0
- package/dist/src/inspect.browser.js +5 -0
- package/dist/src/inspect.d.ts +2 -0
- package/dist/src/inspect.d.ts.map +1 -0
- package/dist/src/inspect.js +1 -0
- package/dist/src/name-policy.d.ts +11 -0
- package/dist/src/name-policy.d.ts.map +1 -1
- package/dist/src/name-policy.js +3 -0
- package/dist/src/reactive-union-set.d.ts.map +1 -1
- package/dist/src/reactive-union-set.js +12 -8
- package/dist/src/refkey.d.ts +39 -3
- package/dist/src/refkey.d.ts.map +1 -1
- package/dist/src/refkey.js +52 -8
- package/dist/src/symbols/basic-scope.d.ts +14 -0
- package/dist/src/symbols/basic-scope.d.ts.map +1 -0
- package/dist/src/symbols/basic-scope.js +20 -0
- package/dist/src/symbols/basic-symbol.d.ts +19 -0
- package/dist/src/symbols/basic-symbol.d.ts.map +1 -0
- package/dist/src/symbols/basic-symbol.js +28 -0
- package/dist/src/symbols/index.d.ts +3 -1
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +3 -1
- package/dist/src/symbols/output-scope.d.ts +70 -41
- package/dist/src/symbols/output-scope.d.ts.map +1 -1
- package/dist/src/symbols/output-scope.js +98 -130
- package/dist/src/symbols/output-space.d.ts +25 -0
- package/dist/src/symbols/output-space.d.ts.map +1 -0
- package/dist/src/symbols/output-space.js +35 -0
- package/dist/src/symbols/output-symbol.d.ts +213 -37
- package/dist/src/symbols/output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/output-symbol.js +323 -203
- package/dist/src/symbols/symbol-flow.d.ts +1 -1
- package/dist/src/symbols/symbol-flow.d.ts.map +1 -1
- package/dist/src/symbols/symbol-flow.js +22 -7
- package/dist/src/symbols/symbol-slot.d.ts +27 -9
- package/dist/src/symbols/symbol-slot.d.ts.map +1 -1
- package/dist/src/symbols/symbol-slot.js +20 -4
- package/dist/src/symbols/symbol-table.d.ts +19 -8
- package/dist/src/symbols/symbol-table.d.ts.map +1 -1
- package/dist/src/symbols/symbol-table.js +65 -16
- package/dist/src/tracer.d.ts +15 -3
- package/dist/src/tracer.d.ts.map +1 -1
- package/dist/src/tracer.js +39 -63
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +4 -4
- package/dist/src/write-output.d.ts +1 -1
- package/dist/src/write-output.d.ts.map +1 -1
- package/dist/src/write-output.js +31 -37
- package/dist/test/components/declaration.test.js +9 -14
- package/dist/test/components/reference-or-content.test.js +2 -2
- package/dist/test/symbols/output-scope.test.js +33 -198
- package/dist/test/symbols/output-symbol.test.js +139 -385
- package/dist/test/symbols/resolution.test.js +431 -114
- package/dist/test/symbols/symbol-table.test.d.ts +2 -0
- package/dist/test/symbols/symbol-table.test.d.ts.map +1 -0
- package/dist/test/symbols/symbol-table.test.js +14 -0
- package/dist/test/symbols/utils.d.ts +10 -24
- package/dist/test/symbols/utils.d.ts.map +1 -1
- package/dist/test/symbols/utils.js +23 -45
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
- package/src/binder.ts +348 -273
- package/src/components/Declaration.tsx +13 -3
- package/src/components/MemberDeclaration.tsx +15 -8
- package/src/components/MemberScope.tsx +61 -20
- package/src/components/Output.tsx +0 -4
- package/src/components/Scope.tsx +16 -9
- package/src/context/member-scope.ts +10 -10
- package/src/context/name-policy.ts +3 -0
- package/src/context/scope.ts +9 -0
- package/src/inspect.browser.ts +6 -0
- package/src/inspect.ts +1 -0
- package/src/name-policy.ts +14 -0
- package/src/reactive-union-set.ts +14 -8
- package/src/refkey.ts +88 -14
- package/src/symbols/basic-scope.ts +23 -0
- package/src/symbols/basic-symbol.ts +32 -0
- package/src/symbols/index.ts +3 -1
- package/src/symbols/output-scope.ts +131 -170
- package/src/symbols/output-space.ts +49 -0
- package/src/symbols/output-symbol.ts +434 -258
- package/src/symbols/symbol-flow.ts +38 -9
- package/src/symbols/symbol-slot.tsx +46 -8
- package/src/symbols/symbol-table.ts +95 -21
- package/src/tracer.ts +53 -83
- package/src/utils.tsx +4 -4
- package/src/write-output.ts +33 -45
- package/temp/api.json +5551 -3066
- package/test/components/declaration.test.tsx +6 -19
- package/test/components/reference-or-content.test.tsx +2 -2
- package/test/symbols/output-scope.test.ts +33 -125
- package/test/symbols/output-symbol.test.ts +128 -348
- package/test/symbols/resolution.test.ts +530 -117
- package/test/symbols/symbol-table.test.ts +15 -0
- package/test/symbols/utils.ts +38 -74
- package/tsdoc.json +4 -0
- package/dist/src/slot.d.ts +0 -15
- package/dist/src/slot.d.ts.map +0 -1
- package/dist/src/slot.js +0 -50
- package/dist/src/symbols/flags.d.ts +0 -70
- package/dist/src/symbols/flags.d.ts.map +0 -1
- package/dist/src/symbols/flags.js +0 -72
- package/dist/test/components/slot.test.d.ts +0 -2
- package/dist/test/components/slot.test.d.ts.map +0 -1
- package/dist/test/components/slot.test.js +0 -134
- package/src/slot.ts +0 -89
- package/src/symbols/flags.ts +0 -82
- package/test/components/slot.test.tsx +0 -174
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Refkey } from "../refkey.js";
|
|
1
|
+
import { Namekey, Refkey } from "../refkey.js";
|
|
2
2
|
import type { Children } from "../runtime/component.js";
|
|
3
3
|
import { OutputSymbol } from "../symbols/output-symbol.js";
|
|
4
4
|
/**
|
|
@@ -20,7 +20,7 @@ export interface DeclarationPropsWithInfo {
|
|
|
20
20
|
/**
|
|
21
21
|
* The name of this declaration.
|
|
22
22
|
*/
|
|
23
|
-
name: string;
|
|
23
|
+
name: string | Namekey;
|
|
24
24
|
/**
|
|
25
25
|
* The unique key or array of unique keys for this declaration.
|
|
26
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Declaration.d.ts","sourceRoot":"","sources":["../../../src/components/Declaration.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Declaration.d.ts","sourceRoot":"","sources":["../../../src/components/Declaration.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,MAAM,EAAE,YAAY,CAAC;IAErB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAEvB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,gBAAgB,GACxB,0BAA0B,GAC1B,wBAAwB,CAAC;AAE7B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAiClD"}
|
|
@@ -2,8 +2,10 @@ import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/
|
|
|
2
2
|
import { useContext } from "../context.js";
|
|
3
3
|
import { BinderContext } from "../context/binder.js";
|
|
4
4
|
import { DeclarationContext } from "../context/declaration.js";
|
|
5
|
+
import { useScope } from "../context/scope.js";
|
|
5
6
|
import { onCleanup } from "../reactivity.js";
|
|
6
|
-
import {
|
|
7
|
+
import { BasicScope } from "../symbols/basic-scope.js";
|
|
8
|
+
import { BasicSymbol } from "../symbols/basic-symbol.js";
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Create a declaration by providing an already created symbol. The symbol is
|
|
@@ -40,7 +42,11 @@ export function Declaration(props) {
|
|
|
40
42
|
if ("symbol" in props) {
|
|
41
43
|
declaration = props.symbol;
|
|
42
44
|
} else {
|
|
43
|
-
|
|
45
|
+
const scope = useScope();
|
|
46
|
+
if (!(scope instanceof BasicScope)) {
|
|
47
|
+
throw new Error("Declaration component cannot create a symbol in a non-basic scope");
|
|
48
|
+
}
|
|
49
|
+
declaration = new BasicSymbol(props.name, scope.symbols, {
|
|
44
50
|
binder,
|
|
45
51
|
refkeys: [props.refkey ?? []].flat(),
|
|
46
52
|
metadata: props.metadata
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Refkey } from "../refkey.js";
|
|
1
|
+
import type { Namekey, Refkey } from "../refkey.js";
|
|
2
2
|
import type { Children } from "../runtime/component.js";
|
|
3
3
|
import { OutputSymbol } from "../symbols/output-symbol.js";
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ export interface MemberDeclarationPropsWithInfo {
|
|
|
9
9
|
/**
|
|
10
10
|
* The name of this declaration.
|
|
11
11
|
*/
|
|
12
|
-
name: string;
|
|
12
|
+
name: string | Namekey;
|
|
13
13
|
/**
|
|
14
14
|
* The refkey or array refkeys for this declaration.
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemberDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/MemberDeclaration.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MemberDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/MemberDeclaration.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAEvB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;;OAGG;IACH,MAAM,EAAE,YAAY,CAAC;IAErB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,sBAAsB,GAC9B,8BAA8B,GAC9B,gCAAgC,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,YAsC9D"}
|
|
@@ -2,8 +2,8 @@ import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/
|
|
|
2
2
|
import { useContext } from "../context.js";
|
|
3
3
|
import { BinderContext } from "../context/binder.js";
|
|
4
4
|
import { MemberDeclarationContext } from "../context/member-declaration.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useMemberContext } from "../context/member-scope.js";
|
|
6
|
+
import { BasicSymbol } from "../symbols/basic-symbol.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Create a member declaration by providing a symbol name and optional symbol
|
|
@@ -46,10 +46,14 @@ export function MemberDeclaration(props) {
|
|
|
46
46
|
if (!infoProps.name) {
|
|
47
47
|
throw new Error("Must provide a member name, or else provide a member symbol");
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
const scopeContext = useMemberContext();
|
|
50
|
+
if (!(scopeContext.ownerSymbol instanceof BasicSymbol)) {
|
|
51
|
+
throw new Error("MemberDeclaration component cannot create a symbol in a non-basic scope");
|
|
52
|
+
}
|
|
53
|
+
const space = infoProps.static ? scopeContext.ownerSymbol.staticMembers : scopeContext.ownerSymbol.instanceMembers;
|
|
54
|
+
declaration = new BasicSymbol(infoProps.name, space, {
|
|
50
55
|
refkeys: infoProps.refkey,
|
|
51
|
-
metadata: infoProps.metadata
|
|
52
|
-
flags: infoProps.static ? OutputSymbolFlags.StaticMember : OutputSymbolFlags.InstanceMember
|
|
56
|
+
metadata: infoProps.metadata
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
return _$createComponent(MemberDeclarationContext.Provider, {
|
|
@@ -1,29 +1,46 @@
|
|
|
1
1
|
import type { Children } from "../runtime/component.js";
|
|
2
|
+
import { OutputScope } from "../symbols/output-scope.js";
|
|
2
3
|
import type { OutputSymbol } from "../symbols/output-symbol.js";
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Declare a member scope by providing an already created scope. The scope is
|
|
6
|
+
* exposed via {@link ScopeContext}.
|
|
7
|
+
*/
|
|
8
|
+
export interface MemberScopePropsWithValue {
|
|
4
9
|
/**
|
|
5
|
-
* The
|
|
10
|
+
* The scope to use. If not provided, a new scope will be created.
|
|
11
|
+
*/
|
|
12
|
+
value: OutputScope;
|
|
13
|
+
children?: Children;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a member scope by providing a name and optional metadata.
|
|
17
|
+
*/
|
|
18
|
+
export interface MemberScopePropsWithInfo {
|
|
19
|
+
/**
|
|
20
|
+
* The name of this scope.
|
|
6
21
|
*/
|
|
7
22
|
name?: string;
|
|
8
23
|
/**
|
|
9
|
-
* The symbol
|
|
10
|
-
* {@link OutputSymbolFlags.InstanceMemberContainer} or
|
|
11
|
-
* {@link OutputSymbolFlags.StaticMemberContainer}.
|
|
24
|
+
* The symbol whose members provide the symbols for this scope.
|
|
12
25
|
*/
|
|
13
|
-
|
|
26
|
+
ownerSymbol: OutputSymbol;
|
|
27
|
+
/**
|
|
28
|
+
* Additional metadata for the scope.
|
|
29
|
+
*/
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
14
31
|
children?: Children;
|
|
15
32
|
}
|
|
33
|
+
export type MemberScopeProps = MemberScopePropsWithValue | MemberScopePropsWithInfo;
|
|
16
34
|
/**
|
|
17
|
-
* Declare a member scope, which is a scope
|
|
18
|
-
*
|
|
19
|
-
* declarations and resolution of instance members.
|
|
35
|
+
* Declare a member scope, which is a lexical scope whose symbols are provided
|
|
36
|
+
* by the owner symbol.
|
|
20
37
|
*
|
|
21
38
|
* @remarks
|
|
22
39
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
40
|
+
* This is used to create members of a symbol, e.g. for class members and the
|
|
41
|
+
* like. In some languages, this scope may provide symbols which are can be
|
|
42
|
+
* referenced lexically, but in other languages, these members may not be in
|
|
43
|
+
* scope and instead must be referenced via the owner symbol itself.
|
|
27
44
|
*/
|
|
28
45
|
export declare function MemberScope(props: MemberScopeProps): Children;
|
|
29
46
|
//# sourceMappingURL=MemberScope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemberScope.d.ts","sourceRoot":"","sources":["../../../src/components/MemberScope.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MemberScope.d.ts","sourceRoot":"","sources":["../../../src/components/MemberScope.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,KAAK,EAAE,WAAW,CAAC;IAEnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,YAAY,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,gBAAgB,GACxB,yBAAyB,GACzB,wBAAwB,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAsBlD"}
|
|
@@ -1,26 +1,48 @@
|
|
|
1
|
-
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { MemberContext } from "../context/member-scope.js";
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
|
|
6
|
+
import { Scope } from "./Scope.js";
|
|
7
|
+
|
|
3
8
|
/**
|
|
4
|
-
* Declare a member scope
|
|
5
|
-
*
|
|
6
|
-
|
|
9
|
+
* Declare a member scope by providing an already created scope. The scope is
|
|
10
|
+
* exposed via {@link ScopeContext}.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create a member scope by providing a name and optional metadata.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Declare a member scope, which is a lexical scope whose symbols are provided
|
|
19
|
+
* by the owner symbol.
|
|
7
20
|
*
|
|
8
21
|
* @remarks
|
|
9
22
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
23
|
+
* This is used to create members of a symbol, e.g. for class members and the
|
|
24
|
+
* like. In some languages, this scope may provide symbols which are can be
|
|
25
|
+
* referenced lexically, but in other languages, these members may not be in
|
|
26
|
+
* scope and instead must be referenced via the owner symbol itself.
|
|
14
27
|
*/
|
|
15
28
|
export function MemberScope(props) {
|
|
29
|
+
if ("value" in props) {
|
|
30
|
+
const sym = props.value;
|
|
31
|
+
if (!sym.isMemberScope) {
|
|
32
|
+
throw new Error("MemberScope must be passed a value that is a member scope.");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
16
35
|
const context = {
|
|
17
|
-
|
|
18
|
-
staticMembers: props.owner.staticMemberScope
|
|
36
|
+
ownerSymbol: "value" in props ? props.value.ownerSymbol : props.ownerSymbol
|
|
19
37
|
};
|
|
20
|
-
return _$createComponent(
|
|
21
|
-
value: context,
|
|
38
|
+
return _$createComponent(Scope, _$mergeProps(props, {
|
|
22
39
|
get children() {
|
|
23
|
-
return
|
|
40
|
+
return _$createComponent(MemberContext.Provider, {
|
|
41
|
+
value: context,
|
|
42
|
+
get children() {
|
|
43
|
+
return props.children;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
24
46
|
}
|
|
25
|
-
});
|
|
47
|
+
}));
|
|
26
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Output.d.ts","sourceRoot":"","sources":["../../../src/components/Output.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Output.d.ts","sourceRoot":"","sources":["../../../src/components/Output.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAMxD,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAE5B;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAE9D;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,YAiCxC"}
|
|
@@ -3,7 +3,6 @@ import { createOutputBinder, getSymbolCreator } from "../binder.js";
|
|
|
3
3
|
import { BinderContext } from "../context/binder.js";
|
|
4
4
|
import { NamePolicyContext } from "../context/name-policy.js";
|
|
5
5
|
import { getContext } from "../reactivity.js";
|
|
6
|
-
import { extensionEffects } from "../slot.js";
|
|
7
6
|
import { SourceDirectory } from "./SourceDirectory.js";
|
|
8
7
|
|
|
9
8
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -41,14 +40,12 @@ export function Output(props) {
|
|
|
41
40
|
return _$createComponent(BinderContext.Provider, {
|
|
42
41
|
value: binder,
|
|
43
42
|
get children() {
|
|
44
|
-
return
|
|
45
|
-
extensionEffects.forEach(e => e());
|
|
46
|
-
}, _$memo(() => _$memo(() => !!props.namePolicy)() ? _$createComponent(NamePolicyContext.Provider, {
|
|
43
|
+
return _$memo(() => !!props.namePolicy)() ? _$createComponent(NamePolicyContext.Provider, {
|
|
47
44
|
get value() {
|
|
48
45
|
return props.namePolicy;
|
|
49
46
|
},
|
|
50
47
|
children: dir
|
|
51
|
-
}) : dir
|
|
48
|
+
}) : dir;
|
|
52
49
|
}
|
|
53
50
|
});
|
|
54
51
|
}
|
|
@@ -4,5 +4,5 @@ export interface ReferenceOrContentProps {
|
|
|
4
4
|
readonly refkey: Refkey;
|
|
5
5
|
readonly children: Children;
|
|
6
6
|
}
|
|
7
|
-
export declare function ReferenceOrContent(props: ReferenceOrContentProps): import("@vue/reactivity").ComputedRef<Children>;
|
|
7
|
+
export declare function ReferenceOrContent(props: ReferenceOrContentProps): import("@vue/reactivity").ComputedRef<string | number | boolean | void | (() => Children) | import("@vue/reactivity").Ref<any, any> | import("../refkey.js").SymbolRefkey | import("../refkey.js").MemberRefkey | import("../reactivity.js").CustomContext | import("../index.js").IndentIntrinsicElement | import("../index.js").IndentIfBreakIntrinsicElement | import("../index.js").BrIntrinsicElement | import("../index.js").LineIntrinsicElement | import("../index.js").HbrIntrinsicElement | import("../index.js").HardlineIntrinsicElement | import("../index.js").SbrIntrinsicElement | import("../index.js").SoftlineIntrinsicElement | import("../index.js").GroupIntrinsicElement | import("../index.js").AlignIntrinsicElement | import("../index.js").FillIntrinsicElement | import("../index.js").BreakParentIntrinsicElement | import("../index.js").LineSuffixIntrinsicElement | import("../index.js").LineSuffixBoundaryIntrinsicElement | import("../index.js").DedentIntrinsicElement | import("../index.js").LiterallineIntrinsicElement | import("../index.js").LbrIntrinsicElement | import("../index.js").DedentToRootIntrinsicElement | import("../index.js").MarkAsRootIntrinsicElement | import("../index.js").IfBreakIntrinsicElement | Children[] | null>;
|
|
8
8
|
//# sourceMappingURL=ReferenceOrContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceOrContent.d.ts","sourceRoot":"","sources":["../../../src/components/ReferenceOrContent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"ReferenceOrContent.d.ts","sourceRoot":"","sources":["../../../src/components/ReferenceOrContent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,4tCAUhE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Children } from "../runtime/component.js";
|
|
2
2
|
import { OutputScope } from "../symbols/output-scope.js";
|
|
3
|
+
import { OutputSymbol } from "../symbols/output-symbol.js";
|
|
3
4
|
/**
|
|
4
5
|
* Declare a scope by providing an already created scope. The scope is merely
|
|
5
6
|
* exposed via {@link ScopeContext}.
|
|
@@ -15,11 +16,6 @@ export interface ScopePropsWithValue {
|
|
|
15
16
|
* Create a scope by providing a name and optional metadata.
|
|
16
17
|
*/
|
|
17
18
|
export interface ScopePropsWithInfo {
|
|
18
|
-
/**
|
|
19
|
-
* The kind of scope. This may be used by application code to determine how
|
|
20
|
-
* to handle symbols in this scope. It is not used by the core framework.
|
|
21
|
-
*/
|
|
22
|
-
kind?: string;
|
|
23
19
|
/**
|
|
24
20
|
* The name of this scope.
|
|
25
21
|
*/
|
|
@@ -28,6 +24,10 @@ export interface ScopePropsWithInfo {
|
|
|
28
24
|
* Additional metadata for the scope.
|
|
29
25
|
*/
|
|
30
26
|
metadata?: Record<string, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Create a member scope with the owner symbol providing the in-scope symbols.
|
|
29
|
+
*/
|
|
30
|
+
ownerSymbol?: OutputSymbol;
|
|
31
31
|
children?: Children;
|
|
32
32
|
}
|
|
33
33
|
export type ScopeProps = ScopePropsWithValue | ScopePropsWithInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scope.d.ts","sourceRoot":"","sources":["../../../src/components/Scope.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Scope.d.ts","sourceRoot":"","sources":["../../../src/components/Scope.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,KAAK,EAAE,WAAW,CAAC;IAEnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC;IAE3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,YAsBtC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { ScopeContext } from "../context/scope.js";
|
|
3
|
-
import {
|
|
2
|
+
import { ScopeContext, useScope } from "../context/scope.js";
|
|
3
|
+
import { BasicScope } from "../symbols/basic-scope.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Declare a scope by providing an already created scope. The scope is merely
|
|
@@ -22,9 +22,13 @@ export function Scope(props) {
|
|
|
22
22
|
if ("value" in props) {
|
|
23
23
|
scope = props.value;
|
|
24
24
|
} else {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const parentScope = useScope();
|
|
26
|
+
if (parentScope && !(parentScope instanceof BasicScope)) {
|
|
27
|
+
throw new Error("Scope component can only make scopes within a BasicScope");
|
|
28
|
+
}
|
|
29
|
+
scope = new BasicScope(props.name ?? "", parentScope, {
|
|
30
|
+
metadata: props.metadata,
|
|
31
|
+
ownerSymbol: props.ownerSymbol
|
|
28
32
|
});
|
|
29
33
|
}
|
|
30
34
|
return _$createComponent(ScopeContext.Provider, {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { ComponentContext } from "../context.js";
|
|
2
|
-
import
|
|
2
|
+
import { OutputSymbol } from "../symbols/output-symbol.js";
|
|
3
3
|
/**
|
|
4
|
-
* The member
|
|
5
|
-
*
|
|
4
|
+
* The member context provides the symbol upon which new member symbols
|
|
5
|
+
* should be created.
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
8
|
-
|
|
9
|
-
instanceMembers?: OutputScope;
|
|
7
|
+
export interface MemberContext {
|
|
8
|
+
ownerSymbol: OutputSymbol;
|
|
10
9
|
}
|
|
11
|
-
export declare const
|
|
12
|
-
export declare function
|
|
10
|
+
export declare const MemberContext: ComponentContext<MemberContext>;
|
|
11
|
+
export declare function useMemberContext(): MemberContext | undefined;
|
|
13
12
|
//# sourceMappingURL=member-scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member-scope.d.ts","sourceRoot":"","sources":["../../../src/context/member-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,
|
|
1
|
+
{"version":3,"file":"member-scope.d.ts","sourceRoot":"","sources":["../../../src/context/member-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,YAAY,CAAC;CAC3B;AAED,eAAO,MAAM,aAAa,EAAE,gBAAgB,CAAC,aAAa,CACrB,CAAC;AAEtC,wBAAgB,gBAAgB,8BAE/B"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createNamedContext, useContext } from "../context.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The member
|
|
5
|
-
*
|
|
4
|
+
* The member context provides the symbol upon which new member symbols
|
|
5
|
+
* should be created.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
export function
|
|
10
|
-
return useContext(
|
|
8
|
+
export const MemberContext = createNamedContext("MemberContext");
|
|
9
|
+
export function useMemberContext() {
|
|
10
|
+
return useContext(MemberContext);
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-policy.d.ts","sourceRoot":"","sources":["../../../src/context/name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"name-policy.d.ts","sourceRoot":"","sources":["../../../src/context/name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAQ/D,CAAC;AAEL,wBAAgB,aAAa,uBAE5B"}
|
|
@@ -2,4 +2,5 @@ import { ComponentContext } from "../context.js";
|
|
|
2
2
|
import type { OutputScope } from "../symbols/output-scope.js";
|
|
3
3
|
export declare const ScopeContext: ComponentContext<OutputScope>;
|
|
4
4
|
export declare function useScope(): OutputScope;
|
|
5
|
+
export declare function useMemberScope(): OutputScope;
|
|
5
6
|
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/context/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,WAAW,CAC1B,CAAC;AAE9B,wBAAgB,QAAQ,gBAEvB"}
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/context/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,WAAW,CAC1B,CAAC;AAE9B,wBAAgB,QAAQ,gBAEvB;AAED,wBAAgB,cAAc,gBAO7B"}
|
|
@@ -2,4 +2,11 @@ import { createNamedContext, useContext } from "../context.js";
|
|
|
2
2
|
export const ScopeContext = createNamedContext("Scope");
|
|
3
3
|
export function useScope() {
|
|
4
4
|
return useContext(ScopeContext);
|
|
5
|
+
}
|
|
6
|
+
export function useMemberScope() {
|
|
7
|
+
const scope = useScope();
|
|
8
|
+
if (!scope.isMemberScope) {
|
|
9
|
+
throw new Error("Expected a member scope, but got a non-member scope.");
|
|
10
|
+
}
|
|
11
|
+
return scope;
|
|
5
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.browser.d.ts","sourceRoot":"","sources":["../../src/inspect.browser.ts"],"names":[],"mappings":"AACA,wBAAgB,OAAO,WAEtB;yBAFe,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { inspect } from "util";
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
export interface NamePolicyGetter {
|
|
2
|
+
(originalName: string): string;
|
|
3
|
+
}
|
|
1
4
|
export interface NamePolicy<TElements extends string> {
|
|
5
|
+
/**
|
|
6
|
+
* Apply the language policy to the provided name for the provided element
|
|
7
|
+
* type.
|
|
8
|
+
*/
|
|
2
9
|
getName(originalName: string, element: TElements): string;
|
|
10
|
+
/**
|
|
11
|
+
* Get a function that takes a name and applies the naming policy to it.
|
|
12
|
+
*/
|
|
13
|
+
for(element: TElements): NamePolicyGetter;
|
|
3
14
|
}
|
|
4
15
|
export declare function createNamePolicy<T extends string>(namer: (name: string, elements: T) => string): NamePolicy<T>;
|
|
5
16
|
//# sourceMappingURL=name-policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-policy.d.ts","sourceRoot":"","sources":["../../src/name-policy.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU,CAAC,SAAS,SAAS,MAAM;IAClD,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"name-policy.d.ts","sourceRoot":"","sources":["../../src/name-policy.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AACD,MAAM,WAAW,UAAU,CAAC,SAAS,SAAS,MAAM;IAClD;;;OAGG;IACH,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1D;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,SAAS,GAAG,gBAAgB,CAAC;CAC3C;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,MAAM,GAC3C,UAAU,CAAC,CAAC,CAAC,CASf"}
|
package/dist/src/name-policy.js
CHANGED
|
@@ -1 +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,C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C,CAAC,CAAC,EAAE,OAAO,GAAE,uBAAuB,CAAC,CAAC,CAAM;IAsClE,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IAuDjD,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;CAiCjE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITERATE_KEY, ReactiveFlags, shallowReactive, shallowReadonly, track, TrackOpTypes, trigger, TriggerOpTypes } from "@vue/reactivity";
|
|
2
|
-
import { effect } from "./reactivity.js";
|
|
2
|
+
import { effect, untrack } from "./reactivity.js";
|
|
3
3
|
export class ReactiveUnionSet extends Set {
|
|
4
4
|
_refcounts = new Map();
|
|
5
5
|
_indexes = [];
|
|
@@ -91,7 +91,7 @@ export class ReactiveUnionSet extends Set {
|
|
|
91
91
|
effect(() => {
|
|
92
92
|
for (const [prevSourceValue, prevTargetValue] of prevValues) {
|
|
93
93
|
if (!subset.has(prevSourceValue)) {
|
|
94
|
-
onDelete?.(prevSourceValue);
|
|
94
|
+
untrack(() => onDelete?.(prevSourceValue));
|
|
95
95
|
prevValues.delete(prevSourceValue);
|
|
96
96
|
this.delete(prevTargetValue);
|
|
97
97
|
}
|
|
@@ -99,7 +99,7 @@ export class ReactiveUnionSet extends Set {
|
|
|
99
99
|
for (const value of subset) {
|
|
100
100
|
if (!prevValues.has(value)) {
|
|
101
101
|
if (onAdd) {
|
|
102
|
-
const added = onAdd(value);
|
|
102
|
+
const added = untrack(() => onAdd(value));
|
|
103
103
|
prevValues.set(value, added);
|
|
104
104
|
} else {
|
|
105
105
|
this.add(value);
|
|
@@ -161,14 +161,18 @@ export class ReactiveUnionSet extends Set {
|
|
|
161
161
|
this._indexes.push({
|
|
162
162
|
add: value => {
|
|
163
163
|
effect(oldValue => {
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
if (oldValue) {
|
|
165
|
+
for (const id of [oldValue].flat()) {
|
|
166
|
+
index.delete(id);
|
|
167
|
+
}
|
|
166
168
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
|
|
170
|
+
// we filter to avoid overwriting existing values (first wins)
|
|
171
|
+
const mappedValues = [mapper(value)].flat().filter(v => untrack(() => !index.has(v)));
|
|
172
|
+
for (const id of mappedValues) {
|
|
169
173
|
index.set(id, value);
|
|
170
174
|
}
|
|
171
|
-
return
|
|
175
|
+
return mappedValues;
|
|
172
176
|
});
|
|
173
177
|
},
|
|
174
178
|
delete: value => {
|
package/dist/src/refkey.d.ts
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
declare const RefkeySym: unique symbol;
|
|
2
|
-
export type
|
|
3
|
-
key: string;
|
|
2
|
+
export type RefkeyBase = {
|
|
4
3
|
[RefkeySym]: true;
|
|
5
4
|
};
|
|
5
|
+
export type Refkey = SymbolRefkey | MemberRefkey | Namekey;
|
|
6
|
+
export interface SymbolRefkey extends RefkeyBase {
|
|
7
|
+
key: string;
|
|
8
|
+
}
|
|
9
|
+
export interface NamekeyOptions {
|
|
10
|
+
ignoreNamePolicy?: boolean;
|
|
11
|
+
ignoreNameConflict?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface Namekey<TOptions extends NamekeyOptions = NamekeyOptions> extends SymbolRefkey {
|
|
14
|
+
name: string;
|
|
15
|
+
options: TOptions;
|
|
16
|
+
}
|
|
17
|
+
export interface MemberRefkey extends RefkeyBase {
|
|
18
|
+
base: Refkey;
|
|
19
|
+
member: Refkey;
|
|
20
|
+
}
|
|
6
21
|
export declare function isRefkey(value: unknown): value is Refkey;
|
|
22
|
+
export declare function isSymbolRefkey(value: unknown): value is SymbolRefkey;
|
|
23
|
+
export declare function isMemberRefkey(value: unknown): value is MemberRefkey;
|
|
24
|
+
export declare function isNamekey(value: unknown): value is Namekey;
|
|
7
25
|
/**
|
|
8
26
|
* Create a refkey for the provided arguments. Passing no arguments returns a
|
|
9
27
|
* fresh refkey that is guaranteed to be unique. Otherwise, the arguments passed
|
|
@@ -18,6 +36,24 @@ export declare function isRefkey(value: unknown): value is Refkey;
|
|
|
18
36
|
* equal to other `NaN` values, and `-0`, which is considered identical to `+0`
|
|
19
37
|
*/
|
|
20
38
|
export declare function refkey(...args: unknown[]): Refkey;
|
|
39
|
+
/**
|
|
40
|
+
* Create a namekey with the given name. The namekey is a unique refkey that
|
|
41
|
+
* represents a single symbol with the given name and the provided
|
|
42
|
+
* naming-related options.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* const myClass = namekey("MyClass");
|
|
47
|
+
*
|
|
48
|
+
* return <>
|
|
49
|
+
* <ClassDeclaration name={myClass} />
|
|
50
|
+
* {myClass}
|
|
51
|
+
* </>
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* Renders a class and a reference to that class.
|
|
55
|
+
*/
|
|
56
|
+
export declare function namekey(name: string, options?: NamekeyOptions): Namekey;
|
|
21
57
|
/**
|
|
22
58
|
* Create a refkey for an instantiation of a symbol.
|
|
23
59
|
*
|
|
@@ -40,6 +76,6 @@ export declare function refkey(...args: unknown[]): Refkey;
|
|
|
40
76
|
* instantiated variable refkey and the refkey of the inner member
|
|
41
77
|
* `refkey(rk1, rk3)`.
|
|
42
78
|
*/
|
|
43
|
-
export declare function memberRefkey(base: Refkey, member: Refkey):
|
|
79
|
+
export declare function memberRefkey(base: Refkey, member: Refkey): MemberRefkey;
|
|
44
80
|
export {};
|
|
45
81
|
//# 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,MA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