@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,26 +1,15 @@
|
|
|
1
1
|
import { expect, it } from "vitest";
|
|
2
2
|
import { Output } from "../../src/components/Output.jsx";
|
|
3
|
-
import {
|
|
4
|
-
Declaration,
|
|
5
|
-
ref,
|
|
6
|
-
renderTree,
|
|
7
|
-
Scope,
|
|
8
|
-
useBinder,
|
|
9
|
-
} from "../../src/index.js";
|
|
3
|
+
import { Declaration, ref, renderTree, Scope } from "../../src/index.js";
|
|
10
4
|
import { flushJobs } from "../../src/scheduler.js";
|
|
11
|
-
import {
|
|
5
|
+
import { BasicScope } from "../../src/symbols/basic-scope.js";
|
|
12
6
|
|
|
13
7
|
it("creates and cleans up a symbol", () => {
|
|
14
|
-
const GetBinder = createTap(() => {
|
|
15
|
-
return useBinder();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const binderRef = GetBinder.ref;
|
|
19
8
|
const doDecl = ref(true);
|
|
9
|
+
const scope = new BasicScope("test", undefined);
|
|
20
10
|
const template = (
|
|
21
11
|
<Output>
|
|
22
|
-
<
|
|
23
|
-
<Scope name="foo">
|
|
12
|
+
<Scope value={scope}>
|
|
24
13
|
{doDecl.value ?
|
|
25
14
|
<Declaration name="foo"></Declaration>
|
|
26
15
|
: ""}
|
|
@@ -30,10 +19,8 @@ it("creates and cleans up a symbol", () => {
|
|
|
30
19
|
|
|
31
20
|
renderTree(template);
|
|
32
21
|
|
|
33
|
-
|
|
34
|
-
const subScope = [...binder.globalScope.children][0];
|
|
35
|
-
expect(subScope.symbols.size).toBe(1);
|
|
22
|
+
expect(scope.symbols.size).toBe(1);
|
|
36
23
|
doDecl.value = false;
|
|
37
24
|
flushJobs();
|
|
38
|
-
expect(
|
|
25
|
+
expect(scope.symbols.size).toBe(0);
|
|
39
26
|
});
|
|
@@ -20,7 +20,7 @@ function TestWrapper(props: { children: Children }) {
|
|
|
20
20
|
|
|
21
21
|
function Reference(props: { refkey: Refkey }) {
|
|
22
22
|
const result = resolve(props.refkey);
|
|
23
|
-
return result.value.
|
|
23
|
+
return result.value.symbol.name;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
return (
|
|
@@ -111,7 +111,7 @@ it("resolve ref via source file reference", () => {
|
|
|
111
111
|
|
|
112
112
|
const Reference = vi.fn((props: { refkey: Refkey }) => {
|
|
113
113
|
const result = resolve(props.refkey);
|
|
114
|
-
return `ViaRef.${result.value.
|
|
114
|
+
return `ViaRef.${result.value.symbol.name}`;
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
const template = (
|
|
@@ -1,48 +1,33 @@
|
|
|
1
1
|
import { reactive, watch } from "@vue/reactivity";
|
|
2
|
-
import {
|
|
3
|
-
import { Binder, createOutputBinder } from "../../src/binder.js";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
3
|
import { Refkey } from "../../src/refkey.js";
|
|
5
4
|
import { flushJobs } from "../../src/scheduler.js";
|
|
6
|
-
import {
|
|
7
|
-
import { OutputScope } from "../../src/symbols/output-scope.js";
|
|
8
|
-
import { OutputSymbol } from "../../src/symbols/output-symbol.js";
|
|
5
|
+
import { BasicScope } from "../../src/symbols/basic-scope.js";
|
|
9
6
|
import { SymbolTable } from "../../src/symbols/symbol-table.js";
|
|
10
|
-
|
|
11
|
-
let binder: Binder;
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
binder = createOutputBinder();
|
|
14
|
-
});
|
|
7
|
+
import { binder, createScope, createSymbol } from "./utils.js";
|
|
15
8
|
|
|
16
9
|
describe("OutputScope constructor", () => {
|
|
17
10
|
it("initializes properties correctly with default options", () => {
|
|
18
|
-
const scope =
|
|
11
|
+
const scope = createScope("testScope");
|
|
19
12
|
expect(scope.name).toBe("testScope");
|
|
20
13
|
expect(scope.binder).toBe(binder);
|
|
21
14
|
expect(scope.id).toEqual(expect.any(Number));
|
|
22
|
-
expect(scope.kind).toBe("scope");
|
|
23
|
-
expect(scope.flags).toBe(OutputScopeFlags.None);
|
|
24
15
|
expect(scope.metadata).toEqual({});
|
|
25
|
-
expect(scope.parent).toBe(binder.globalScope);
|
|
26
|
-
expect(scope.owner).toBeUndefined();
|
|
27
16
|
expect(scope.symbols).toBeInstanceOf(SymbolTable);
|
|
28
17
|
expect(scope.symbolNames.size).toBe(0);
|
|
29
18
|
expect(scope.children.size).toBe(0);
|
|
30
19
|
});
|
|
31
20
|
|
|
32
21
|
it("initializes properties correctly with custom options", () => {
|
|
33
|
-
const parentScope =
|
|
22
|
+
const parentScope = createScope("parentScope");
|
|
34
23
|
const metadata = { foo: "bar" };
|
|
35
24
|
|
|
36
|
-
const scope = new
|
|
25
|
+
const scope = new BasicScope("testScope", parentScope, {
|
|
37
26
|
binder,
|
|
38
|
-
kind: "namespace",
|
|
39
27
|
metadata,
|
|
40
|
-
parent: parentScope,
|
|
41
28
|
});
|
|
42
29
|
|
|
43
30
|
expect(scope.name).toBe("testScope");
|
|
44
|
-
expect(scope.kind).toBe("namespace");
|
|
45
|
-
expect(scope.flags).toBe(OutputScopeFlags.None);
|
|
46
31
|
expect(scope.metadata.foo).toBe("bar");
|
|
47
32
|
expect(scope.parent).toBe(parentScope);
|
|
48
33
|
expect(parentScope.children.has(scope)).toBe(true);
|
|
@@ -51,7 +36,7 @@ describe("OutputScope constructor", () => {
|
|
|
51
36
|
|
|
52
37
|
describe("OutputScope reactivity", () => {
|
|
53
38
|
it("is reactive on name", () => {
|
|
54
|
-
const scope =
|
|
39
|
+
const scope = createScope("initialName");
|
|
55
40
|
const nameSpy = vi.fn();
|
|
56
41
|
watch(() => scope.name, nameSpy);
|
|
57
42
|
|
|
@@ -61,31 +46,20 @@ describe("OutputScope reactivity", () => {
|
|
|
61
46
|
expect(scope.name).toBe("newName");
|
|
62
47
|
});
|
|
63
48
|
|
|
64
|
-
it("is reactive on flags", () => {
|
|
65
|
-
const scope = new OutputScope("scope", { binder });
|
|
66
|
-
const flagsSpy = vi.fn();
|
|
67
|
-
watch(() => scope.flags, flagsSpy);
|
|
68
|
-
|
|
69
|
-
scope.flags = OutputScopeFlags.InstanceMemberScope;
|
|
70
|
-
flushJobs();
|
|
71
|
-
expect(flagsSpy).toHaveBeenCalled();
|
|
72
|
-
expect(scope.flags).toBe(OutputScopeFlags.InstanceMemberScope);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
49
|
it("updates symbolNames when symbols are added", () => {
|
|
76
|
-
const scope =
|
|
50
|
+
const scope = createScope("scope");
|
|
77
51
|
const symbolNamesSpy = vi.fn();
|
|
78
52
|
watch(() => scope.symbolNames.size, symbolNamesSpy);
|
|
79
53
|
|
|
80
|
-
|
|
54
|
+
createSymbol("symbol1", scope);
|
|
81
55
|
flushJobs();
|
|
82
56
|
expect(symbolNamesSpy).toHaveBeenCalled();
|
|
83
57
|
expect(scope.symbolNames.has("symbol1")).toBe(true);
|
|
84
58
|
});
|
|
85
59
|
|
|
86
60
|
it("updates symbolNames when a symbol's name changes", () => {
|
|
87
|
-
const scope =
|
|
88
|
-
const symbol =
|
|
61
|
+
const scope = createScope("scope");
|
|
62
|
+
const [symbol] = createSymbol("oldName", scope);
|
|
89
63
|
flushJobs();
|
|
90
64
|
|
|
91
65
|
// Verify initial state
|
|
@@ -114,7 +88,7 @@ describe("OutputScope reactivity", () => {
|
|
|
114
88
|
});
|
|
115
89
|
|
|
116
90
|
it("doesn't get wrapped in a reactive proxy", () => {
|
|
117
|
-
const scope =
|
|
91
|
+
const scope = createScope("scope");
|
|
118
92
|
|
|
119
93
|
const rScope = reactive(scope);
|
|
120
94
|
expect(rScope).toBe(scope);
|
|
@@ -123,9 +97,9 @@ describe("OutputScope reactivity", () => {
|
|
|
123
97
|
|
|
124
98
|
describe("OutputScope#symbols", () => {
|
|
125
99
|
it("adds symbols to its collection", () => {
|
|
126
|
-
const scope =
|
|
127
|
-
const sym1 =
|
|
128
|
-
const sym2 =
|
|
100
|
+
const scope = createScope("scope");
|
|
101
|
+
const [sym1] = createSymbol("sym1", scope);
|
|
102
|
+
const [sym2] = createSymbol("sym2", scope);
|
|
129
103
|
flushJobs();
|
|
130
104
|
|
|
131
105
|
expect(scope.symbols.size).toBe(2);
|
|
@@ -134,23 +108,25 @@ describe("OutputScope#symbols", () => {
|
|
|
134
108
|
});
|
|
135
109
|
|
|
136
110
|
it("resolves symbol name conflicts", () => {
|
|
137
|
-
const scope =
|
|
138
|
-
const s1 =
|
|
139
|
-
const s2 =
|
|
140
|
-
const s3 =
|
|
111
|
+
const scope = createScope("scope");
|
|
112
|
+
const [s1] = createSymbol("sym", scope);
|
|
113
|
+
const [s2] = createSymbol("sym", scope);
|
|
114
|
+
const [s3] = createSymbol("sym", scope);
|
|
115
|
+
|
|
141
116
|
flushJobs();
|
|
142
117
|
|
|
143
118
|
expect(s1.name).toBe("sym");
|
|
144
119
|
expect(s2.name).toBe("sym_2");
|
|
145
120
|
expect(s3.name).toBe("sym_3");
|
|
121
|
+
flushJobs();
|
|
146
122
|
expect(scope.symbolNames.has("sym")).toBe(true);
|
|
147
123
|
expect(scope.symbolNames.has("sym_2")).toBe(true);
|
|
148
124
|
expect(scope.symbolNames.has("sym_3")).toBe(true);
|
|
149
125
|
});
|
|
150
126
|
|
|
151
127
|
it("updates when a symbol is deleted", () => {
|
|
152
|
-
const scope =
|
|
153
|
-
const sym =
|
|
128
|
+
const scope = createScope("scope");
|
|
129
|
+
const [sym] = createSymbol("sym", scope);
|
|
154
130
|
flushJobs();
|
|
155
131
|
|
|
156
132
|
expect(scope.symbols.size).toBe(1);
|
|
@@ -166,15 +142,15 @@ describe("OutputScope#symbols", () => {
|
|
|
166
142
|
});
|
|
167
143
|
|
|
168
144
|
it("updates when a symbol changes scope", () => {
|
|
169
|
-
const scope1 =
|
|
170
|
-
const scope2 =
|
|
171
|
-
const sym =
|
|
145
|
+
const scope1 = createScope("scope1");
|
|
146
|
+
const scope2 = createScope("scope2");
|
|
147
|
+
const [sym] = createSymbol("sym", scope1);
|
|
172
148
|
flushJobs();
|
|
173
149
|
|
|
174
150
|
expect(scope1.symbols.size).toBe(1);
|
|
175
151
|
expect(scope2.symbols.size).toBe(0);
|
|
176
152
|
|
|
177
|
-
sym.
|
|
153
|
+
sym.spaces = [scope2.symbols];
|
|
178
154
|
flushJobs();
|
|
179
155
|
|
|
180
156
|
expect(scope1.symbols.size).toBe(0);
|
|
@@ -188,7 +164,7 @@ describe("OutputScope#symbols", () => {
|
|
|
188
164
|
|
|
189
165
|
describe("OutputScope#symbolsByRefkey", () => {
|
|
190
166
|
it("maps refkeys to symbols", () => {
|
|
191
|
-
const scope =
|
|
167
|
+
const scope = createScope("scope");
|
|
192
168
|
|
|
193
169
|
// Use the refkey function to create refkeys
|
|
194
170
|
// This is based on how refkey is being imported in binder.ts
|
|
@@ -197,16 +173,12 @@ describe("OutputScope#symbolsByRefkey", () => {
|
|
|
197
173
|
const key2b = "key2b" as unknown as Refkey;
|
|
198
174
|
|
|
199
175
|
// Create a symbol with a refkey
|
|
200
|
-
const sym1 =
|
|
201
|
-
binder,
|
|
202
|
-
scope,
|
|
176
|
+
const [sym1] = createSymbol("sym1", scope, {
|
|
203
177
|
refkeys: [key1],
|
|
204
178
|
});
|
|
205
179
|
|
|
206
180
|
// Create a symbol with multiple refkeys
|
|
207
|
-
const sym2 =
|
|
208
|
-
binder,
|
|
209
|
-
scope,
|
|
181
|
+
const [sym2] = createSymbol("sym2", scope, {
|
|
210
182
|
refkeys: [key2a, key2b],
|
|
211
183
|
});
|
|
212
184
|
|
|
@@ -220,9 +192,9 @@ describe("OutputScope#symbolsByRefkey", () => {
|
|
|
220
192
|
|
|
221
193
|
describe("OutputScope#children", () => {
|
|
222
194
|
it("tracks child scopes", () => {
|
|
223
|
-
const parentScope =
|
|
224
|
-
const child1 =
|
|
225
|
-
const child2 =
|
|
195
|
+
const parentScope = createScope("parent");
|
|
196
|
+
const child1 = createScope("child1", parentScope);
|
|
197
|
+
const child2 = createScope("child2", parentScope);
|
|
226
198
|
flushJobs();
|
|
227
199
|
|
|
228
200
|
expect(parentScope.children.size).toBe(2);
|
|
@@ -234,67 +206,3 @@ describe("OutputScope#children", () => {
|
|
|
234
206
|
expect(child2.parent).toBe(parentScope);
|
|
235
207
|
});
|
|
236
208
|
});
|
|
237
|
-
|
|
238
|
-
describe("OutputScope#clone", () => {
|
|
239
|
-
let originalScope: OutputScope;
|
|
240
|
-
const originalMetadata = { data: "original", nested: { value: 1 } };
|
|
241
|
-
|
|
242
|
-
beforeEach(() => {
|
|
243
|
-
const parentScope = new OutputScope("parent", { binder });
|
|
244
|
-
|
|
245
|
-
originalScope = new OutputScope("original", {
|
|
246
|
-
binder: binder,
|
|
247
|
-
kind: "class",
|
|
248
|
-
metadata: { ...originalMetadata },
|
|
249
|
-
parent: parentScope,
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
// Add a symbol and child scope to the original
|
|
253
|
-
new OutputSymbol("symbolInOriginal", { binder, scope: originalScope });
|
|
254
|
-
new OutputScope("childOfOriginal", { binder, parent: originalScope });
|
|
255
|
-
flushJobs();
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it("clones basic properties", () => {
|
|
259
|
-
const newScope = new OutputScope("newScope", { binder });
|
|
260
|
-
const clonedScope = originalScope.clone({ parent: newScope });
|
|
261
|
-
|
|
262
|
-
expect(clonedScope.name).toBe(originalScope.name);
|
|
263
|
-
expect(clonedScope.kind).toBe(originalScope.kind);
|
|
264
|
-
expect(clonedScope.flags).toBe(originalScope.flags);
|
|
265
|
-
expect(clonedScope.id).not.toBe(originalScope.id);
|
|
266
|
-
|
|
267
|
-
expect(clonedScope.metadata).toEqual(originalScope.metadata);
|
|
268
|
-
|
|
269
|
-
expect(clonedScope.symbols.size).toBe(1);
|
|
270
|
-
expect(clonedScope.children.size).toBe(1);
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
it("can override parent in clone options", () => {
|
|
274
|
-
const newParent = new OutputScope("newParent", { binder });
|
|
275
|
-
const clonedScope = originalScope.clone({ parent: newParent });
|
|
276
|
-
flushJobs();
|
|
277
|
-
|
|
278
|
-
expect(clonedScope.parent).toBe(newParent);
|
|
279
|
-
expect(newParent.children.has(clonedScope)).toBe(true);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it("can override owner in clone options", () => {
|
|
283
|
-
const newOwnerParent = new OutputScope("newOwnerParent", { binder });
|
|
284
|
-
const newOwner = new OutputSymbol("newOwner", {
|
|
285
|
-
binder,
|
|
286
|
-
scope: newOwnerParent,
|
|
287
|
-
});
|
|
288
|
-
const clonedScope = originalScope.clone({ owner: newOwner });
|
|
289
|
-
flushJobs();
|
|
290
|
-
|
|
291
|
-
expect(clonedScope.owner).toBe(newOwner);
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it("allows independent changes to clone properties", () => {
|
|
295
|
-
const clonedScope = originalScope.clone();
|
|
296
|
-
clonedScope.name = "clonedName";
|
|
297
|
-
|
|
298
|
-
expect(originalScope.name).toBe("original");
|
|
299
|
-
});
|
|
300
|
-
});
|