@alloy-js/core 0.20.0-dev.4 → 0.20.0-dev.7
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 +74 -38
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +235 -173
- package/dist/src/binder.js.map +1 -0
- package/dist/src/code.js +2 -1
- package/dist/src/code.js.map +1 -0
- package/dist/src/components/AppendFile.js +2 -1
- package/dist/src/components/AppendFile.js.map +1 -0
- package/dist/src/components/Block.js +2 -1
- package/dist/src/components/Block.js.map +1 -0
- package/dist/src/components/CopyFile.js +2 -1
- package/dist/src/components/CopyFile.js.map +1 -0
- 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 +10 -3
- package/dist/src/components/Declaration.js.map +1 -0
- package/dist/src/components/For.js +2 -1
- package/dist/src/components/For.js.map +1 -0
- package/dist/src/components/Indent.js +2 -1
- package/dist/src/components/Indent.js.map +1 -0
- package/dist/src/components/List.js +2 -1
- package/dist/src/components/List.js.map +1 -0
- 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 +11 -6
- package/dist/src/components/MemberDeclaration.js.map +1 -0
- package/dist/src/components/MemberName.js +2 -1
- package/dist/src/components/MemberName.js.map +1 -0
- 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 +39 -16
- package/dist/src/components/MemberScope.js.map +1 -0
- package/dist/src/components/Name.js +2 -1
- package/dist/src/components/Name.js.map +1 -0
- package/dist/src/components/Output.d.ts.map +1 -1
- package/dist/src/components/Output.js +4 -6
- package/dist/src/components/Output.js.map +1 -0
- package/dist/src/components/Prose.js +2 -1
- package/dist/src/components/Prose.js.map +1 -0
- package/dist/src/components/ReferenceOrContent.d.ts +1 -1
- package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
- package/dist/src/components/ReferenceOrContent.js +2 -1
- package/dist/src/components/ReferenceOrContent.js.map +1 -0
- 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 +11 -6
- package/dist/src/components/Scope.js.map +1 -0
- package/dist/src/components/Show.js +2 -1
- package/dist/src/components/Show.js.map +1 -0
- package/dist/src/components/SourceDirectory.js +2 -1
- package/dist/src/components/SourceDirectory.js.map +1 -0
- package/dist/src/components/SourceFile.js +2 -1
- package/dist/src/components/SourceFile.js.map +1 -0
- package/dist/src/components/StatementList.js +2 -1
- package/dist/src/components/StatementList.js.map +1 -0
- package/dist/src/components/Switch.js +2 -1
- package/dist/src/components/Switch.js.map +1 -0
- package/dist/src/components/TemplateFile.js +2 -1
- package/dist/src/components/TemplateFile.js.map +1 -0
- package/dist/src/components/UpdateFile.js +2 -1
- package/dist/src/components/UpdateFile.js.map +1 -0
- package/dist/src/components/Wrap.js +2 -1
- package/dist/src/components/Wrap.js.map +1 -0
- package/dist/src/components/index.js +2 -1
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/stc/index.js +2 -1
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/components/stc/sti.js +2 -1
- package/dist/src/components/stc/sti.js.map +1 -0
- package/dist/src/context/assignment.js +2 -1
- package/dist/src/context/assignment.js.map +1 -0
- package/dist/src/context/binder.js +2 -1
- package/dist/src/context/binder.js.map +1 -0
- package/dist/src/context/declaration.js +2 -1
- package/dist/src/context/declaration.js.map +1 -0
- package/dist/src/context/index.js +2 -1
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/context/member-declaration.js +2 -1
- package/dist/src/context/member-declaration.js.map +1 -0
- 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 +7 -6
- package/dist/src/context/member-scope.js.map +1 -0
- package/dist/src/context/name-policy.d.ts.map +1 -1
- package/dist/src/context/name-policy.js +5 -1
- package/dist/src/context/name-policy.js.map +1 -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 +9 -1
- package/dist/src/context/scope.js.map +1 -0
- package/dist/src/context/source-directory.js +2 -1
- package/dist/src/context/source-directory.js.map +1 -0
- package/dist/src/context/source-file.js +2 -1
- package/dist/src/context/source-file.js.map +1 -0
- package/dist/src/context.js +2 -1
- package/dist/src/context.js.map +1 -0
- package/dist/src/debug.js +2 -1
- package/dist/src/debug.js.map +1 -0
- package/dist/src/host/alloy-host.browser.js +2 -1
- package/dist/src/host/alloy-host.browser.js.map +1 -0
- package/dist/src/host/alloy-host.js +2 -1
- package/dist/src/host/alloy-host.js.map +1 -0
- package/dist/src/host/interface.js +2 -1
- package/dist/src/host/interface.js.map +1 -0
- package/dist/src/index.browser.js +2 -1
- package/dist/src/index.browser.js.map +1 -0
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -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 +6 -0
- package/dist/src/inspect.browser.js.map +1 -0
- package/dist/src/inspect.d.ts +2 -0
- package/dist/src/inspect.d.ts.map +1 -0
- package/dist/src/inspect.js +2 -0
- package/dist/src/inspect.js.map +1 -0
- package/dist/src/jsx-runtime.js +2 -1
- package/dist/src/jsx-runtime.js.map +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 +5 -1
- package/dist/src/name-policy.js.map +1 -0
- package/dist/src/props-combinators.js +2 -1
- package/dist/src/props-combinators.js.map +1 -0
- package/dist/src/reactive-union-set.d.ts.map +1 -1
- package/dist/src/reactive-union-set.js +14 -9
- package/dist/src/reactive-union-set.js.map +1 -0
- package/dist/src/reactivity.js +2 -1
- package/dist/src/reactivity.js.map +1 -0
- package/dist/src/refkey.d.ts +39 -3
- package/dist/src/refkey.d.ts.map +1 -1
- package/dist/src/refkey.js +65 -10
- package/dist/src/refkey.js.map +1 -0
- package/dist/src/render.js +2 -1
- package/dist/src/render.js.map +1 -0
- package/dist/src/resource.js +2 -1
- package/dist/src/resource.js.map +1 -0
- package/dist/src/runtime/component.js +2 -1
- package/dist/src/runtime/component.js.map +1 -0
- package/dist/src/runtime/intrinsic.js +2 -1
- package/dist/src/runtime/intrinsic.js.map +1 -0
- package/dist/src/scheduler.js +2 -1
- package/dist/src/scheduler.js.map +1 -0
- package/dist/src/stc.js +2 -1
- package/dist/src/stc.js.map +1 -0
- package/dist/src/sti.js +2 -1
- package/dist/src/sti.js.map +1 -0
- 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 +21 -0
- package/dist/src/symbols/basic-scope.js.map +1 -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 +29 -0
- package/dist/src/symbols/basic-symbol.js.map +1 -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 +5 -2
- package/dist/src/symbols/index.js.map +1 -0
- 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 +100 -131
- package/dist/src/symbols/output-scope.js.map +1 -0
- 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 +36 -0
- package/dist/src/symbols/output-space.js.map +1 -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 +325 -204
- package/dist/src/symbols/output-symbol.js.map +1 -0
- 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 +24 -8
- package/dist/src/symbols/symbol-flow.js.map +1 -0
- 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 +22 -5
- package/dist/src/symbols/symbol-slot.js.map +1 -0
- 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 +67 -17
- package/dist/src/symbols/symbol-table.js.map +1 -0
- package/dist/src/tap.js +2 -1
- package/dist/src/tap.js.map +1 -0
- package/dist/src/tracer.d.ts +15 -3
- package/dist/src/tracer.d.ts.map +1 -1
- package/dist/src/tracer.js +41 -64
- package/dist/src/tracer.js.map +1 -0
- package/dist/src/utils.js +2 -1
- package/dist/src/utils.js.map +1 -0
- package/dist/src/write-output.js +2 -1
- package/dist/src/write-output.js.map +1 -0
- package/dist/test/browser-build.test.js +2 -1
- package/dist/test/browser-build.test.js.map +1 -0
- package/dist/test/children.test.js +2 -1
- package/dist/test/children.test.js.map +1 -0
- package/dist/test/components/append-file.test.js +2 -1
- package/dist/test/components/append-file.test.js.map +1 -0
- package/dist/test/components/block.test.js +2 -1
- package/dist/test/components/block.test.js.map +1 -0
- package/dist/test/components/copy-file.test.js +2 -1
- package/dist/test/components/copy-file.test.js.map +1 -0
- package/dist/test/components/declaration.test.js +11 -15
- package/dist/test/components/declaration.test.js.map +1 -0
- package/dist/test/components/list.test.js +2 -1
- package/dist/test/components/list.test.js.map +1 -0
- package/dist/test/components/prose.test.js +2 -1
- package/dist/test/components/prose.test.js.map +1 -0
- package/dist/test/components/reference-or-content.test.js +4 -3
- package/dist/test/components/reference-or-content.test.js.map +1 -0
- package/dist/test/components/source-file.test.js +2 -1
- package/dist/test/components/source-file.test.js.map +1 -0
- package/dist/test/components/template-file.test.js +2 -1
- package/dist/test/components/template-file.test.js.map +1 -0
- package/dist/test/components/update-file.test.js +2 -1
- package/dist/test/components/update-file.test.js.map +1 -0
- package/dist/test/components/wrap.test.js +2 -1
- package/dist/test/components/wrap.test.js.map +1 -0
- package/dist/test/control-flow/for.test.js +2 -1
- package/dist/test/control-flow/for.test.js.map +1 -0
- package/dist/test/control-flow/match.test.js +2 -1
- package/dist/test/control-flow/match.test.js.map +1 -0
- package/dist/test/control-flow/show.test.js +2 -1
- package/dist/test/control-flow/show.test.js.map +1 -0
- package/dist/test/name-policy.test.js +2 -1
- package/dist/test/name-policy.test.js.map +1 -0
- package/dist/test/props-with-defaults.test.js +2 -1
- package/dist/test/props-with-defaults.test.js.map +1 -0
- package/dist/test/reactive-union-set.test.js +2 -1
- package/dist/test/reactive-union-set.test.js.map +1 -0
- package/dist/test/reactivity/circular-reactives.test.js +2 -1
- package/dist/test/reactivity/circular-reactives.test.js.map +1 -0
- package/dist/test/reactivity/cleanup.test.js +2 -1
- package/dist/test/reactivity/cleanup.test.js.map +1 -0
- package/dist/test/reactivity/memo.test.js +2 -1
- package/dist/test/reactivity/memo.test.js.map +1 -0
- package/dist/test/reactivity/ref-rendering.test.js +2 -1
- package/dist/test/reactivity/ref-rendering.test.js.map +1 -0
- package/dist/test/reactivity/test.test.js +2 -1
- package/dist/test/reactivity/test.test.js.map +1 -0
- package/dist/test/reactivity/untrack.test.js +2 -1
- package/dist/test/reactivity/untrack.test.js.map +1 -0
- package/dist/test/refkey.test.js +2 -1
- package/dist/test/refkey.test.js.map +1 -0
- package/dist/test/rendering/basic.test.js +2 -1
- package/dist/test/rendering/basic.test.js.map +1 -0
- package/dist/test/rendering/code.test.js +2 -1
- package/dist/test/rendering/code.test.js.map +1 -0
- package/dist/test/rendering/formatting.test.js +2 -1
- package/dist/test/rendering/formatting.test.js.map +1 -0
- package/dist/test/rendering/indent.test.js +2 -1
- package/dist/test/rendering/indent.test.js.map +1 -0
- package/dist/test/rendering/memoization.test.js +2 -1
- package/dist/test/rendering/memoization.test.js.map +1 -0
- package/dist/test/rendering/refkeys.test.js +2 -1
- package/dist/test/rendering/refkeys.test.js.map +1 -0
- package/dist/test/split-props.test.js +2 -1
- package/dist/test/split-props.test.js.map +1 -0
- package/dist/test/stc.test.js +2 -1
- package/dist/test/stc.test.js.map +1 -0
- package/dist/test/symbols/output-scope.test.js +34 -198
- package/dist/test/symbols/output-scope.test.js.map +1 -0
- package/dist/test/symbols/output-symbol.test.js +141 -386
- package/dist/test/symbols/output-symbol.test.js.map +1 -0
- package/dist/test/symbols/resolution.test.js +433 -115
- package/dist/test/symbols/resolution.test.js.map +1 -0
- 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 +15 -0
- package/dist/test/symbols/symbol-table.test.js.map +1 -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 +25 -46
- package/dist/test/symbols/utils.js.map +1 -0
- package/dist/test/utils.test.js +2 -1
- package/dist/test/utils.test.js.map +1 -0
- package/dist/testing/extend-expect.js +2 -1
- package/dist/testing/extend-expect.js.map +1 -0
- package/dist/testing/extend-expect.test.js +2 -1
- package/dist/testing/extend-expect.test.js.map +1 -0
- package/dist/testing/index.js +2 -1
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/render.js +2 -1
- package/dist/testing/render.js.map +1 -0
- package/dist/testing/vitest.d.js +2 -1
- package/dist/testing/vitest.d.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/src/binder.ts +368 -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 +106 -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/temp/api.json +7009 -4461
- 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,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
effect,
|
|
2
3
|
reactive,
|
|
3
4
|
ReactiveFlags,
|
|
4
5
|
shallowReactive,
|
|
@@ -6,33 +7,35 @@ import {
|
|
|
6
7
|
TrackOpTypes,
|
|
7
8
|
trigger,
|
|
8
9
|
TriggerOpTypes,
|
|
9
|
-
watch,
|
|
10
10
|
} from "@vue/reactivity";
|
|
11
11
|
import type { Binder } from "../binder.js";
|
|
12
12
|
import { useBinder } from "../context/binder.js";
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
formatScopeName,
|
|
19
|
-
trace,
|
|
20
|
-
traceEffect,
|
|
21
|
-
TracePhase,
|
|
22
|
-
} from "../tracer.js";
|
|
23
|
-
import { OutputScopeFlags } from "./flags.js";
|
|
24
|
-
import type { OutputSymbol } from "./output-symbol.js";
|
|
25
|
-
import { SymbolTable } from "./symbol-table.js";
|
|
13
|
+
import { inspect } from "../inspect.js";
|
|
14
|
+
import { untrack } from "../reactivity.js";
|
|
15
|
+
import { formatScope, trace, traceEffect, TracePhase } from "../tracer.js";
|
|
16
|
+
import { OutputDeclarationSpace, OutputSpace } from "./output-space.js";
|
|
17
|
+
import { OutputSymbol } from "./output-symbol.js";
|
|
26
18
|
|
|
27
19
|
let scopeCount = 0;
|
|
28
20
|
|
|
29
21
|
export interface OutputScopeOptions {
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Arbitrary metadata that is associated with this scope.
|
|
24
|
+
*/
|
|
32
25
|
metadata?: Record<string, unknown>;
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The binder instance this scope belongs to. If not provided, it will
|
|
29
|
+
* attempt to find the current binder from context.
|
|
30
|
+
*/
|
|
35
31
|
binder?: Binder;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The owner symbol of this scope. When provided, this scope becomes a member
|
|
35
|
+
* scope, which exposes the symbols on its owner symbol instead of having its
|
|
36
|
+
* own declaration spaces.
|
|
37
|
+
*/
|
|
38
|
+
ownerSymbol?: OutputSymbol;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
@@ -53,16 +56,20 @@ export interface OutputScopeOptions {
|
|
|
53
56
|
* Scopes are reactive values, which allows you to observe changes to the scope
|
|
54
57
|
* within a reactive context.
|
|
55
58
|
*/
|
|
56
|
-
export class OutputScope {
|
|
57
|
-
|
|
59
|
+
export abstract class OutputScope {
|
|
60
|
+
static readonly declarationSpaces: Readonly<string[]> = [] as const;
|
|
61
|
+
|
|
58
62
|
#name: string;
|
|
59
63
|
/**
|
|
60
64
|
* The name of the scope.
|
|
65
|
+
*
|
|
66
|
+
* @reactive
|
|
61
67
|
*/
|
|
62
68
|
get name() {
|
|
63
69
|
track(this, TrackOpTypes.GET, "name");
|
|
64
70
|
return this.#name;
|
|
65
71
|
}
|
|
72
|
+
|
|
66
73
|
set name(name: string) {
|
|
67
74
|
const old = this.#name;
|
|
68
75
|
this.#name = name;
|
|
@@ -72,85 +79,66 @@ export class OutputScope {
|
|
|
72
79
|
#id: number;
|
|
73
80
|
/**
|
|
74
81
|
* The unique id of this scope.
|
|
82
|
+
*
|
|
83
|
+
* @readonly
|
|
75
84
|
*/
|
|
76
85
|
get id() {
|
|
77
86
|
return this.#id;
|
|
78
87
|
}
|
|
79
88
|
|
|
80
|
-
#kind: string;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* The kind of scope. Subtypes will likely provide a set of known scope kinds.
|
|
84
|
-
* The kind is not used by the binder itself.
|
|
85
|
-
*/
|
|
86
|
-
get kind() {
|
|
87
|
-
return this.#kind;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#flags: OutputScopeFlags;
|
|
91
|
-
/**
|
|
92
|
-
* The flags that describe this scope.
|
|
93
|
-
*/
|
|
94
|
-
get flags() {
|
|
95
|
-
track(this, TrackOpTypes.GET, "flags");
|
|
96
|
-
return this.#flags;
|
|
97
|
-
}
|
|
98
|
-
set flags(flags: OutputScopeFlags) {
|
|
99
|
-
const old = this.#flags;
|
|
100
|
-
this.#flags = flags;
|
|
101
|
-
trigger(this, TriggerOpTypes.SET, "flags", flags, old);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
89
|
// read only
|
|
105
90
|
#metadata: Record<string, unknown>;
|
|
91
|
+
/**
|
|
92
|
+
* Arbitrary metadata associated with this scope. This property is not
|
|
93
|
+
* reactive but the metadata object is a reactive object.
|
|
94
|
+
*
|
|
95
|
+
* @readonly
|
|
96
|
+
*/
|
|
106
97
|
get metadata() {
|
|
107
98
|
return this.#metadata;
|
|
108
99
|
}
|
|
109
100
|
|
|
110
101
|
#parent?: OutputScope;
|
|
102
|
+
|
|
111
103
|
/**
|
|
112
|
-
* The
|
|
113
|
-
*
|
|
114
|
-
*
|
|
104
|
+
* The parent scope of this scope. Undefined if this is a root scope.
|
|
105
|
+
*
|
|
106
|
+
* @reactive
|
|
115
107
|
*/
|
|
116
108
|
get parent() {
|
|
109
|
+
track(this, TrackOpTypes.GET, "parent");
|
|
117
110
|
return this.#parent;
|
|
118
111
|
}
|
|
119
112
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* The symbol that owns this scope. This is only defined for scopes that have
|
|
123
|
-
* the {@link OutputScopeFlags.StaticMemberScope} or
|
|
124
|
-
* {@link OutputScopeFlags.InstanceMemberScope} flag.
|
|
125
|
-
*/
|
|
126
|
-
get owner() {
|
|
127
|
-
return this.#owner;
|
|
128
|
-
}
|
|
113
|
+
set parent(scope: OutputScope | undefined) {
|
|
114
|
+
const old = this.#parent;
|
|
129
115
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
116
|
+
if (old) {
|
|
117
|
+
old.children.delete(this);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (scope) {
|
|
121
|
+
scope.children.add(this);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
trigger(this, TriggerOpTypes.SET, "parent", scope, old);
|
|
125
|
+
this.#parent = scope;
|
|
136
126
|
}
|
|
137
127
|
|
|
138
|
-
#
|
|
128
|
+
#spaces: Record<string, OutputDeclarationSpace>;
|
|
129
|
+
|
|
139
130
|
/**
|
|
140
|
-
*
|
|
131
|
+
* Get the declaration space for the given key.
|
|
141
132
|
*/
|
|
142
|
-
|
|
143
|
-
return this.#
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
#symbolNames: ReadonlySet<string>;
|
|
147
|
-
get symbolNames() {
|
|
148
|
-
return this.#symbolNames;
|
|
133
|
+
spaceFor(key: string): OutputSpace | undefined {
|
|
134
|
+
return this.#spaces[key];
|
|
149
135
|
}
|
|
150
136
|
|
|
151
137
|
#children: Set<OutputScope>;
|
|
152
138
|
/**
|
|
153
139
|
* The scopes nested within this scope.
|
|
140
|
+
*
|
|
141
|
+
* @readonly
|
|
154
142
|
*/
|
|
155
143
|
get children() {
|
|
156
144
|
return this.#children;
|
|
@@ -159,6 +147,8 @@ export class OutputScope {
|
|
|
159
147
|
#binder: Binder | undefined;
|
|
160
148
|
/**
|
|
161
149
|
* The binder that created this scope.
|
|
150
|
+
*
|
|
151
|
+
* @readonly
|
|
162
152
|
*/
|
|
163
153
|
get binder() {
|
|
164
154
|
return this.#binder;
|
|
@@ -166,43 +156,34 @@ export class OutputScope {
|
|
|
166
156
|
|
|
167
157
|
[ReactiveFlags.SKIP] = this;
|
|
168
158
|
|
|
169
|
-
constructor(
|
|
159
|
+
constructor(
|
|
160
|
+
name: string,
|
|
161
|
+
parentScope: OutputScope | undefined,
|
|
162
|
+
options: OutputScopeOptions = {},
|
|
163
|
+
) {
|
|
170
164
|
this.#name = name;
|
|
171
165
|
this.#id = scopeCount++;
|
|
172
|
-
this.#flags = options.flags ?? OutputScopeFlags.None;
|
|
173
|
-
this.#kind = options.kind ?? "scope";
|
|
174
166
|
this.#metadata = reactive(options.metadata ?? {});
|
|
175
167
|
this.#binder = options.binder ?? useBinder();
|
|
176
|
-
this.#owner = options.owner;
|
|
177
168
|
this.#children = shallowReactive(new Set());
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
throw new Error("Member scopes must have an owner");
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
if (!this.#parent) {
|
|
185
|
-
this.#parent =
|
|
186
|
-
options.parent ?? useScope() ?? this.#binder?.globalScope;
|
|
187
|
-
}
|
|
188
|
-
if (this.#parent) {
|
|
189
|
-
// not global scope
|
|
190
|
-
this.#parent.children.add(this);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
this.#symbols = new SymbolTable(this, {
|
|
195
|
-
nameConflictResolver: this.#binder?.nameConflictResolver,
|
|
196
|
-
});
|
|
197
|
-
this.#symbolsByRefkey = this.#symbols.createIndex((s) => s.refkeys);
|
|
198
|
-
this.#symbolNames = this.#symbols.createDerivedSet((s) => {
|
|
199
|
-
return s.name;
|
|
169
|
+
this.#parent = parentScope;
|
|
170
|
+
effect(() => {
|
|
171
|
+
this.#setOwnerSymbol(options.ownerSymbol?.movedTo ?? options.ownerSymbol);
|
|
200
172
|
});
|
|
201
173
|
|
|
202
174
|
if (this.#parent) {
|
|
203
175
|
this.#parent.children.add(this);
|
|
204
176
|
}
|
|
205
177
|
|
|
178
|
+
const constructor = this.constructor as typeof OutputScope;
|
|
179
|
+
|
|
180
|
+
this.#spaces = Object.fromEntries(
|
|
181
|
+
constructor.declarationSpaces.map((spaceKey) => [
|
|
182
|
+
spaceKey,
|
|
183
|
+
new OutputDeclarationSpace(this, spaceKey, this.#binder),
|
|
184
|
+
]),
|
|
185
|
+
);
|
|
186
|
+
|
|
206
187
|
this.#binder?.notifyScopeCreated(this);
|
|
207
188
|
|
|
208
189
|
trace(TracePhase.scope.create, () => `${formatScope(this)}`);
|
|
@@ -211,86 +192,66 @@ export class OutputScope {
|
|
|
211
192
|
});
|
|
212
193
|
}
|
|
213
194
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
`Moving symbols from ${formatScopeName(source)} to ${formatScopeName(this)}`,
|
|
222
|
-
);
|
|
223
|
-
this.#symbols.addSubset(source.#symbols, {
|
|
224
|
-
onAdd: (symbol) => {
|
|
225
|
-
if (options?.onAdd) {
|
|
226
|
-
return options.onAdd(symbol);
|
|
227
|
-
}
|
|
228
|
-
symbol.scope = this;
|
|
229
|
-
return symbol;
|
|
230
|
-
},
|
|
231
|
-
onDelete: (symbol) => {
|
|
232
|
-
if (options?.onDelete) {
|
|
233
|
-
options.onDelete(symbol);
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
});
|
|
195
|
+
/**
|
|
196
|
+
* Get all the declaration spaces in this scope.
|
|
197
|
+
*
|
|
198
|
+
* @readonly
|
|
199
|
+
*/
|
|
200
|
+
get spaces() {
|
|
201
|
+
return Object.values(this.#spaces);
|
|
237
202
|
}
|
|
238
203
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return options.onAdd(symbol);
|
|
252
|
-
}
|
|
253
|
-
return symbol.copyToScope(this);
|
|
254
|
-
},
|
|
255
|
-
onDelete: (symbol) => {
|
|
256
|
-
if (options?.onDelete) {
|
|
257
|
-
options.onDelete(symbol);
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
});
|
|
204
|
+
#ownerSymbol: OutputSymbol | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* The symbol whose members are in scope. When an owner symbol is present,
|
|
207
|
+
* this scope is considered a member scope, and does not provide its own
|
|
208
|
+
* declaration spaces.
|
|
209
|
+
*
|
|
210
|
+
* @readonly
|
|
211
|
+
* @reactive
|
|
212
|
+
*/
|
|
213
|
+
get ownerSymbol() {
|
|
214
|
+
track(this, TrackOpTypes.GET, "ownerSymbol");
|
|
215
|
+
return this.#ownerSymbol;
|
|
261
216
|
}
|
|
262
217
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
const clone = new OutputScope(this.#name, {
|
|
270
|
-
binder: this.#binder,
|
|
271
|
-
flags: this.#flags,
|
|
272
|
-
kind: this.#kind,
|
|
273
|
-
metadata: this.#metadata,
|
|
274
|
-
parent: options.parent,
|
|
275
|
-
owner: options.owner,
|
|
276
|
-
});
|
|
218
|
+
#setOwnerSymbol(value: OutputSymbol | undefined) {
|
|
219
|
+
const old = this.#ownerSymbol;
|
|
220
|
+
this.#ownerSymbol = value;
|
|
221
|
+
trigger(this, TriggerOpTypes.SET, "ownerSymbol", value, old);
|
|
222
|
+
}
|
|
277
223
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
for (const child of this.#children) {
|
|
289
|
-
clone.children.add(child.clone());
|
|
224
|
+
/**
|
|
225
|
+
* Whether this scope is a transient scope. Transient scopes are used for
|
|
226
|
+
* temporary values that are to be combined with other non-transient symbols.
|
|
227
|
+
* Scopes are transient when their owner symbol is transient.
|
|
228
|
+
*
|
|
229
|
+
* @readonly
|
|
230
|
+
*/
|
|
231
|
+
get isTransient() {
|
|
232
|
+
if (!this.ownerSymbol) {
|
|
233
|
+
return false;
|
|
290
234
|
}
|
|
291
235
|
|
|
292
|
-
|
|
236
|
+
return this.ownerSymbol.isTransient;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Check if this is scope is a member scope. Member scopes have no member
|
|
240
|
+
* spaces of their own, but instead put members of their owner symbol in
|
|
241
|
+
* scope.
|
|
242
|
+
*
|
|
243
|
+
* @readonly
|
|
244
|
+
* @reactive
|
|
245
|
+
*/
|
|
246
|
+
get isMemberScope() {
|
|
247
|
+
return !!this.ownerSymbol;
|
|
248
|
+
}
|
|
293
249
|
|
|
294
|
-
|
|
250
|
+
[inspect.custom]() {
|
|
251
|
+
const ownerSymbol =
|
|
252
|
+
this.ownerSymbol ? ` for ${inspect(this.ownerSymbol)}` : "";
|
|
253
|
+
return untrack(
|
|
254
|
+
() => `${this.constructor.name} ${this.name}[${this.id}]${ownerSymbol}`,
|
|
255
|
+
);
|
|
295
256
|
}
|
|
296
257
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Binder } from "../binder.js";
|
|
2
|
+
import { inspect } from "../inspect.js";
|
|
3
|
+
import { untrack } from "../reactivity.js";
|
|
4
|
+
import { OutputScope } from "./output-scope.js";
|
|
5
|
+
import { OutputSymbol } from "./output-symbol.js";
|
|
6
|
+
import { SymbolTable } from "./symbol-table.js";
|
|
7
|
+
|
|
8
|
+
export type OutputSpace = OutputDeclarationSpace | OutputMemberSpace;
|
|
9
|
+
export class OutputDeclarationSpace extends SymbolTable {
|
|
10
|
+
constructor(scope: OutputScope, key: string, binder?: Binder) {
|
|
11
|
+
super(key, binder);
|
|
12
|
+
this.#scope = scope;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#scope: OutputScope;
|
|
16
|
+
/**
|
|
17
|
+
* The scope this declaration space belongs to.
|
|
18
|
+
*/
|
|
19
|
+
get scope() {
|
|
20
|
+
return this.#scope;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[inspect.custom]() {
|
|
24
|
+
return untrack(
|
|
25
|
+
() => `OutputDeclarationSpace for scope ${inspect(this.#scope)}`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class OutputMemberSpace extends SymbolTable {
|
|
31
|
+
constructor(symbol: OutputSymbol, key: string, binder?: Binder) {
|
|
32
|
+
super(key, binder);
|
|
33
|
+
this.#symbol = symbol;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#symbol: OutputSymbol;
|
|
37
|
+
/**
|
|
38
|
+
* The symbol this member space belongs to.
|
|
39
|
+
*/
|
|
40
|
+
get symbol() {
|
|
41
|
+
return this.#symbol;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[inspect.custom]() {
|
|
45
|
+
return untrack(
|
|
46
|
+
() => `OutputMemberSpace for symbol ${inspect(this.#symbol)}`,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|