@alloy-js/core 0.23.0-dev.0 → 0.23.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -22
- package/dist/devtools/index.html +68 -0
- package/dist/src/binder.d.ts +2 -0
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +55 -12
- package/dist/src/binder.js.map +1 -1
- package/dist/src/components/AccessExpression.d.ts +78 -0
- package/dist/src/components/AccessExpression.d.ts.map +1 -0
- package/dist/src/components/AccessExpression.js +218 -0
- package/dist/src/components/AccessExpression.js.map +1 -0
- package/dist/src/components/AccessExpression.test.d.ts +2 -0
- package/dist/src/components/AccessExpression.test.d.ts.map +1 -0
- package/dist/src/components/AccessExpression.test.js +137 -0
- package/dist/src/components/AccessExpression.test.js.map +1 -0
- package/dist/src/components/AppendFile.d.ts.map +1 -1
- package/dist/src/components/AppendFile.js +14 -3
- package/dist/src/components/AppendFile.js.map +1 -1
- package/dist/src/components/Block.js +1 -1
- package/dist/src/components/Block.js.map +1 -1
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +2 -1
- package/dist/src/components/Declaration.js.map +1 -1
- package/dist/src/components/Prose.js +2 -2
- package/dist/src/components/Prose.js.map +1 -1
- package/dist/src/components/Scope.d.ts.map +1 -1
- package/dist/src/components/Scope.js +6 -1
- package/dist/src/components/Scope.js.map +1 -1
- package/dist/src/components/SourceDirectory.d.ts.map +1 -1
- package/dist/src/components/SourceDirectory.js +1 -2
- package/dist/src/components/SourceDirectory.js.map +1 -1
- package/dist/src/components/TemplateFile.d.ts.map +1 -1
- package/dist/src/components/TemplateFile.js +18 -3
- package/dist/src/components/TemplateFile.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/content-slot.d.ts.map +1 -1
- package/dist/src/content-slot.js +7 -6
- package/dist/src/content-slot.js.map +1 -1
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js +10 -3
- package/dist/src/context.js.map +1 -1
- package/dist/src/debug/cli.d.ts +6 -0
- package/dist/src/debug/cli.d.ts.map +1 -0
- package/dist/src/{debug.js → debug/cli.js} +78 -84
- package/dist/src/debug/cli.js.map +1 -0
- package/dist/src/debug/diagnostics.test.d.ts +2 -0
- package/dist/src/debug/diagnostics.test.d.ts.map +1 -0
- package/dist/src/debug/diagnostics.test.js +45 -0
- package/dist/src/debug/diagnostics.test.js.map +1 -0
- package/dist/src/debug/effects.d.ts +73 -0
- package/dist/src/debug/effects.d.ts.map +1 -0
- package/dist/src/debug/effects.js +228 -0
- package/dist/src/debug/effects.js.map +1 -0
- package/dist/src/debug/effects.test.d.ts +2 -0
- package/dist/src/debug/effects.test.d.ts.map +1 -0
- package/dist/src/debug/effects.test.js +84 -0
- package/dist/src/debug/effects.test.js.map +1 -0
- package/dist/src/debug/files.d.ts +14 -0
- package/dist/src/debug/files.d.ts.map +1 -0
- package/dist/src/debug/files.js +40 -0
- package/dist/src/debug/files.js.map +1 -0
- package/dist/src/debug/files.test.d.ts +2 -0
- package/dist/src/debug/files.test.d.ts.map +1 -0
- package/dist/src/debug/files.test.js +89 -0
- package/dist/src/debug/files.test.js.map +1 -0
- package/dist/src/debug/index.d.ts +61 -0
- package/dist/src/debug/index.d.ts.map +1 -0
- package/dist/src/debug/index.js +69 -0
- package/dist/src/debug/index.js.map +1 -0
- package/dist/src/debug/render.d.ts +57 -0
- package/dist/src/debug/render.d.ts.map +1 -0
- package/dist/src/debug/render.js +519 -0
- package/dist/src/debug/render.js.map +1 -0
- package/dist/src/debug/render.test.d.ts +2 -0
- package/dist/src/debug/render.test.d.ts.map +1 -0
- package/dist/src/debug/render.test.js +328 -0
- package/dist/src/debug/render.test.js.map +1 -0
- package/dist/src/debug/serialize.d.ts +9 -0
- package/dist/src/debug/serialize.d.ts.map +1 -0
- package/dist/src/debug/serialize.js +70 -0
- package/dist/src/debug/serialize.js.map +1 -0
- package/dist/src/debug/symbols.d.ts +15 -0
- package/dist/src/debug/symbols.d.ts.map +1 -0
- package/dist/src/debug/symbols.js +173 -0
- package/dist/src/debug/symbols.js.map +1 -0
- package/dist/src/debug/symbols.test.d.ts +2 -0
- package/dist/src/debug/symbols.test.d.ts.map +1 -0
- package/dist/src/debug/symbols.test.js +104 -0
- package/dist/src/debug/symbols.test.js.map +1 -0
- package/dist/src/debug/trace.d.ts +342 -0
- package/dist/src/debug/trace.d.ts.map +1 -0
- package/dist/src/debug/trace.js +443 -0
- package/dist/src/debug/trace.js.map +1 -0
- package/dist/src/devtools/devtools-protocol.d.ts +232 -0
- package/dist/src/devtools/devtools-protocol.d.ts.map +1 -0
- package/dist/src/devtools/devtools-protocol.js +2 -0
- package/dist/src/devtools/devtools-protocol.js.map +1 -0
- package/dist/src/devtools/devtools-server.browser.d.ts +28 -0
- package/dist/src/devtools/devtools-server.browser.d.ts.map +1 -0
- package/dist/src/devtools/devtools-server.browser.js +36 -0
- package/dist/src/devtools/devtools-server.browser.js.map +1 -0
- package/dist/src/devtools/devtools-server.d.ts +72 -0
- package/dist/src/devtools/devtools-server.d.ts.map +1 -0
- package/dist/src/devtools/devtools-server.js +256 -0
- package/dist/src/devtools/devtools-server.js.map +1 -0
- package/dist/src/devtools/devtools-transport.d.ts +23 -0
- package/dist/src/devtools/devtools-transport.d.ts.map +1 -0
- package/dist/src/devtools/devtools-transport.js +114 -0
- package/dist/src/devtools/devtools-transport.js.map +1 -0
- package/dist/src/devtools-entry.browser.d.ts +4 -0
- package/dist/src/devtools-entry.browser.d.ts.map +1 -0
- package/dist/src/devtools-entry.browser.js +2 -0
- package/dist/src/devtools-entry.browser.js.map +1 -0
- package/dist/src/devtools-entry.d.ts +4 -0
- package/dist/src/devtools-entry.d.ts.map +1 -0
- package/dist/src/devtools-entry.js +2 -0
- package/dist/src/devtools-entry.js.map +1 -0
- package/dist/src/diagnostics.d.ts +34 -0
- package/dist/src/diagnostics.d.ts.map +1 -0
- package/dist/src/diagnostics.js +89 -0
- package/dist/src/diagnostics.js.map +1 -0
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/print-hook.d.ts +14 -0
- package/dist/src/print-hook.d.ts.map +1 -0
- package/dist/src/print-hook.js +10 -0
- package/dist/src/print-hook.js.map +1 -0
- package/dist/src/reactive-union-set.d.ts.map +1 -1
- package/dist/src/reactive-union-set.js +28 -3
- package/dist/src/reactive-union-set.js.map +1 -1
- package/dist/src/reactivity.d.ts +50 -8
- package/dist/src/reactivity.d.ts.map +1 -1
- package/dist/src/reactivity.js +225 -39
- package/dist/src/reactivity.js.map +1 -1
- package/dist/src/render-stack.d.ts +30 -0
- package/dist/src/render-stack.d.ts.map +1 -0
- package/dist/src/render-stack.js +251 -0
- package/dist/src/render-stack.js.map +1 -0
- package/dist/src/render.d.ts +9 -19
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +371 -159
- package/dist/src/render.js.map +1 -1
- package/dist/src/resource.d.ts.map +1 -1
- package/dist/src/resource.js +5 -0
- package/dist/src/resource.js.map +1 -1
- package/dist/src/runtime/component.d.ts +7 -1
- package/dist/src/runtime/component.d.ts.map +1 -1
- package/dist/src/runtime/component.js +4 -1
- package/dist/src/runtime/component.js.map +1 -1
- package/dist/src/scheduler.d.ts +8 -0
- package/dist/src/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler.js +69 -3
- package/dist/src/scheduler.js.map +1 -1
- package/dist/src/symbols/basic-symbol.d.ts.map +1 -1
- package/dist/src/symbols/basic-symbol.js +6 -1
- package/dist/src/symbols/basic-symbol.js.map +1 -1
- package/dist/src/symbols/decl.d.ts.map +1 -1
- package/dist/src/symbols/decl.js +5 -1
- package/dist/src/symbols/decl.js.map +1 -1
- package/dist/src/symbols/output-scope.d.ts +2 -1
- package/dist/src/symbols/output-scope.d.ts.map +1 -1
- package/dist/src/symbols/output-scope.js +13 -8
- package/dist/src/symbols/output-scope.js.map +1 -1
- package/dist/src/symbols/output-symbol.d.ts +1 -0
- package/dist/src/symbols/output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/output-symbol.js +25 -8
- package/dist/src/symbols/output-symbol.js.map +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 -1
- package/dist/src/symbols/symbol-slot.d.ts.map +1 -1
- package/dist/src/symbols/symbol-slot.js +15 -0
- package/dist/src/symbols/symbol-slot.js.map +1 -1
- package/dist/src/symbols/symbol-slot.test.d.ts +2 -0
- package/dist/src/symbols/symbol-slot.test.d.ts.map +1 -0
- package/dist/src/symbols/symbol-slot.test.js +35 -0
- package/dist/src/symbols/symbol-slot.test.js.map +1 -0
- package/dist/src/symbols/symbol-table.d.ts.map +1 -1
- package/dist/src/symbols/symbol-table.js +6 -5
- package/dist/src/symbols/symbol-table.js.map +1 -1
- package/dist/src/trace.d.ts +2 -0
- package/dist/src/trace.d.ts.map +1 -0
- package/dist/src/trace.js +2 -0
- package/dist/src/trace.js.map +1 -0
- package/dist/src/tracer.d.ts +2 -228
- package/dist/src/tracer.d.ts.map +1 -1
- package/dist/src/tracer.js +5 -298
- package/dist/src/tracer.js.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +7 -5
- package/dist/src/utils.js.map +1 -1
- package/dist/test/components/append-file.test.d.ts.map +1 -1
- package/dist/test/components/append-file.test.js +18 -10
- package/dist/test/components/append-file.test.js.map +1 -1
- package/dist/test/components/template-file.test.d.ts.map +1 -1
- package/dist/test/components/template-file.test.js +6 -4
- package/dist/test/components/template-file.test.js.map +1 -1
- package/dist/test/lazy-isempty.test.d.ts +2 -0
- package/dist/test/lazy-isempty.test.d.ts.map +1 -0
- package/dist/test/lazy-isempty.test.js +89 -0
- package/dist/test/lazy-isempty.test.js.map +1 -0
- package/dist/test/reactive-union-set-disposers.test.d.ts +2 -0
- package/dist/test/reactive-union-set-disposers.test.d.ts.map +1 -0
- package/dist/test/reactive-union-set-disposers.test.js +98 -0
- package/dist/test/reactive-union-set-disposers.test.js.map +1 -0
- package/dist/test/reactivity/shallow-reactive.test.d.ts +2 -0
- package/dist/test/reactivity/shallow-reactive.test.d.ts.map +1 -0
- package/dist/test/reactivity/shallow-reactive.test.js +52 -0
- package/dist/test/reactivity/shallow-reactive.test.js.map +1 -0
- package/dist/test/rendering/basic.test.js +3 -0
- package/dist/test/rendering/basic.test.js.map +1 -1
- package/dist/test/rendering/print-render-stack.test.d.ts +2 -0
- package/dist/test/rendering/print-render-stack.test.d.ts.map +1 -0
- package/dist/test/rendering/print-render-stack.test.js +207 -0
- package/dist/test/rendering/print-render-stack.test.js.map +1 -0
- package/dist/test/scheduler-extended.test.d.ts +2 -0
- package/dist/test/scheduler-extended.test.d.ts.map +1 -0
- package/dist/test/scheduler-extended.test.js +96 -0
- package/dist/test/scheduler-extended.test.js.map +1 -0
- package/dist/test/scheduler.test.d.ts +2 -0
- package/dist/test/scheduler.test.d.ts.map +1 -0
- package/dist/test/scheduler.test.js +46 -0
- package/dist/test/scheduler.test.js.map +1 -0
- package/dist/testing/create-test-wrapper.d.ts +1 -1
- package/dist/testing/create-test-wrapper.d.ts.map +1 -1
- package/dist/testing/create-test-wrapper.js +1 -1
- package/dist/testing/create-test-wrapper.js.map +1 -1
- package/dist/testing/devtools-utils.d.ts +26 -0
- package/dist/testing/devtools-utils.d.ts.map +1 -0
- package/dist/testing/devtools-utils.js +140 -0
- package/dist/testing/devtools-utils.js.map +1 -0
- package/dist/testing/extend-expect.d.ts.map +1 -1
- package/dist/testing/extend-expect.js +63 -1
- package/dist/testing/extend-expect.js.map +1 -1
- package/dist/testing/render.d.ts +2 -2
- package/dist/testing/render.d.ts.map +1 -1
- package/dist/testing/render.js +2 -2
- package/dist/testing/render.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -7
- package/scripts/copy-devtools-ui.mjs +26 -0
- package/src/binder.ts +71 -16
- package/src/components/AccessExpression.test.tsx +132 -0
- package/src/components/AccessExpression.tsx +344 -0
- package/src/components/AppendFile.tsx +14 -9
- package/src/components/Block.tsx +1 -1
- package/src/components/Declaration.tsx +2 -1
- package/src/components/Prose.tsx +1 -1
- package/src/components/Scope.tsx +6 -1
- package/src/components/SourceDirectory.tsx +1 -2
- package/src/components/TemplateFile.tsx +18 -9
- package/src/components/index.tsx +1 -0
- package/src/content-slot.tsx +7 -7
- package/src/context.ts +17 -6
- package/src/{debug.ts → debug/cli.ts} +112 -127
- package/src/debug/diagnostics.test.tsx +55 -0
- package/src/debug/effects.test.tsx +89 -0
- package/src/debug/effects.ts +317 -0
- package/src/debug/files.test.tsx +96 -0
- package/src/debug/files.ts +40 -0
- package/src/debug/index.ts +128 -0
- package/src/debug/render.test.tsx +379 -0
- package/src/debug/render.ts +639 -0
- package/src/debug/serialize.ts +85 -0
- package/src/debug/symbols.test.tsx +106 -0
- package/src/debug/symbols.ts +239 -0
- package/src/debug/trace.ts +312 -0
- package/src/devtools/devtools-protocol.ts +312 -0
- package/src/devtools/devtools-server.browser.ts +71 -0
- package/src/devtools/devtools-server.ts +290 -0
- package/src/devtools/devtools-transport.ts +154 -0
- package/src/devtools-entry.browser.ts +52 -0
- package/src/devtools-entry.ts +54 -0
- package/src/diagnostics.ts +141 -0
- package/src/index.ts +2 -7
- package/src/print-hook.ts +22 -0
- package/src/reactive-union-set.ts +85 -44
- package/src/reactivity.ts +301 -59
- package/src/render-stack.ts +294 -0
- package/src/render.ts +470 -216
- package/src/resource.ts +28 -19
- package/src/runtime/component.ts +11 -0
- package/src/scheduler.ts +80 -4
- package/src/symbols/basic-symbol.ts +6 -1
- package/src/symbols/decl.ts +5 -1
- package/src/symbols/output-scope.ts +21 -13
- package/src/symbols/output-symbol.ts +34 -14
- package/src/symbols/symbol-flow.ts +76 -39
- package/src/symbols/symbol-slot.test.tsx +41 -0
- package/src/symbols/symbol-slot.tsx +47 -20
- package/src/symbols/symbol-table.ts +6 -10
- package/src/trace.ts +1 -0
- package/src/tracer.ts +13 -242
- package/src/utils.tsx +24 -17
- package/temp/api.json +4187 -1603
- package/test/components/append-file.test.tsx +36 -29
- package/test/components/template-file.test.tsx +11 -11
- package/test/lazy-isempty.test.tsx +106 -0
- package/test/reactive-union-set-disposers.test.tsx +112 -0
- package/test/reactivity/shallow-reactive.test.tsx +56 -0
- package/test/rendering/basic.test.tsx +4 -0
- package/test/rendering/print-render-stack.test.tsx +244 -0
- package/test/scheduler-extended.test.tsx +122 -0
- package/test/scheduler.test.tsx +50 -0
- package/testing/create-test-wrapper.tsx +1 -1
- package/testing/devtools-utils.ts +203 -0
- package/testing/extend-expect.ts +89 -0
- package/testing/render.ts +2 -2
- package/testing/vitest.d.ts +9 -0
- package/dist/src/debug.d.ts +0 -15
- package/dist/src/debug.d.ts.map +0 -1
- package/dist/src/debug.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alloy-js/core",
|
|
3
|
-
"version": "0.23.0-dev.
|
|
3
|
+
"version": "0.23.0-dev.10",
|
|
4
4
|
"description": "",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/alloy-framework/alloy.git"
|
|
8
|
+
},
|
|
5
9
|
"main": "./dist/src/index.js",
|
|
6
10
|
"exports": {
|
|
7
11
|
".": {
|
|
@@ -23,33 +27,43 @@
|
|
|
23
27
|
},
|
|
24
28
|
"./components": {
|
|
25
29
|
"import": "./dist/src/components/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./devtools": {
|
|
32
|
+
"types": "./dist/src/devtools-entry.d.ts",
|
|
33
|
+
"browser": "./dist/src/devtools-entry.browser.js",
|
|
34
|
+
"import": "./dist/src/devtools-entry.js"
|
|
26
35
|
}
|
|
27
36
|
},
|
|
28
37
|
"browser": {
|
|
29
38
|
"./dist/src/host/alloy-host.js": "./dist/src/host/alloy-host.browser.js",
|
|
30
39
|
"./src/host/alloy-host.ts": "./src/host/alloy-host.browser.ts",
|
|
31
40
|
"./dist/src/inspect.js": "./dist/src/inspect.browser.js",
|
|
32
|
-
"./src/inspect.ts": "./src/inspect.browser.ts"
|
|
41
|
+
"./src/inspect.ts": "./src/inspect.browser.ts",
|
|
42
|
+
"./dist/src/devtools/devtools-server.js": "./dist/src/devtools/devtools-server.browser.js",
|
|
43
|
+
"./src/devtools/devtools-server.ts": "./src/devtools/devtools-server.browser.ts"
|
|
33
44
|
},
|
|
34
45
|
"keywords": [],
|
|
35
46
|
"author": "brian.terlson@microsoft.com",
|
|
36
47
|
"license": "MIT",
|
|
37
48
|
"dependencies": {
|
|
49
|
+
"@types/ws": "^8.18.1",
|
|
38
50
|
"@vue/reactivity": "^3.5.13",
|
|
39
|
-
"picocolors": "^1.1.1",
|
|
40
51
|
"cli-table3": "^0.6.5",
|
|
52
|
+
"devalue": "^5.6.2",
|
|
41
53
|
"pathe": "^2.0.3",
|
|
42
|
-
"
|
|
54
|
+
"picocolors": "^1.1.1",
|
|
55
|
+
"prettier": "^3.6.2",
|
|
56
|
+
"ws": "^8.19.0"
|
|
43
57
|
},
|
|
44
58
|
"devDependencies": {
|
|
45
|
-
"@alloy-js/cli": "~0.22.0 || >= 0.23.0-dev.
|
|
46
|
-
"@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.
|
|
59
|
+
"@alloy-js/cli": "~0.22.0 || >= 0.23.0-dev.3",
|
|
60
|
+
"@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.1",
|
|
47
61
|
"@microsoft/api-extractor": "~7.52.8",
|
|
48
62
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
49
63
|
"concurrently": "^9.2.0",
|
|
50
64
|
"typescript": "^5.8.3",
|
|
51
65
|
"vite": "^7.0.6",
|
|
52
|
-
"vitest": "
|
|
66
|
+
"vitest": "3.2.4"
|
|
53
67
|
},
|
|
54
68
|
"type": "module",
|
|
55
69
|
"scripts": {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { copyFile, mkdir } from "fs/promises";
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const srcFile = join(__dirname, "../../devtools/dist/index.html");
|
|
11
|
+
const destFile = join(__dirname, "../dist/devtools/index.html");
|
|
12
|
+
|
|
13
|
+
async function copyDevtoolsUi() {
|
|
14
|
+
try {
|
|
15
|
+
await mkdir(dirname(destFile), { recursive: true });
|
|
16
|
+
await copyFile(srcFile, destFile);
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.log("Copied devtools UI to core dist");
|
|
19
|
+
} catch (error) {
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.error("Failed to copy devtools UI:", error);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
void copyDevtoolsUi();
|
package/src/binder.ts
CHANGED
|
@@ -2,8 +2,11 @@ import { computed, Ref, ShallowRef, shallowRef } from "@vue/reactivity";
|
|
|
2
2
|
import { useBinder } from "./context/binder.js";
|
|
3
3
|
import { useMemberContext } from "./context/member-scope.js";
|
|
4
4
|
import { useScope } from "./context/scope.js";
|
|
5
|
-
import {
|
|
5
|
+
import { debug, TracePhase } from "./debug/index.js";
|
|
6
|
+
import { emitDiagnostic, type DiagnosticHandle } from "./diagnostics.js";
|
|
7
|
+
import { effect, onCleanup } from "./reactivity.js";
|
|
6
8
|
import {
|
|
9
|
+
inspectRefkey,
|
|
7
10
|
isMemberRefkey,
|
|
8
11
|
MemberRefkey,
|
|
9
12
|
refkey,
|
|
@@ -13,12 +16,7 @@ import {
|
|
|
13
16
|
} from "./refkey.js";
|
|
14
17
|
import { OutputScope } from "./symbols/output-scope.js";
|
|
15
18
|
import { type OutputSymbol } from "./symbols/output-symbol.js";
|
|
16
|
-
import {
|
|
17
|
-
formatRefkeys,
|
|
18
|
-
formatSymbolName,
|
|
19
|
-
trace,
|
|
20
|
-
TracePhase,
|
|
21
|
-
} from "./tracer.js";
|
|
19
|
+
import { formatRefkeys, formatSymbolName } from "./tracer.js";
|
|
22
20
|
export type Metadata = object;
|
|
23
21
|
|
|
24
22
|
/**
|
|
@@ -211,6 +209,24 @@ export interface BinderOptions {
|
|
|
211
209
|
nameConflictResolver?: NameConflictResolver;
|
|
212
210
|
}
|
|
213
211
|
|
|
212
|
+
export function createScope<TScope extends OutputScope, Args extends unknown[]>(
|
|
213
|
+
ctor: new (...args: Args) => TScope,
|
|
214
|
+
...args: Args
|
|
215
|
+
): TScope {
|
|
216
|
+
const scope = new ctor(...args);
|
|
217
|
+
debug.symbols.registerScope(scope);
|
|
218
|
+
return scope;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function createSymbol<
|
|
222
|
+
TSymbol extends OutputSymbol,
|
|
223
|
+
Args extends unknown[],
|
|
224
|
+
>(ctor: new (...args: Args) => TSymbol, ...args: Args): TSymbol {
|
|
225
|
+
const symbol = new ctor(...args);
|
|
226
|
+
debug.symbols.registerSymbol(symbol);
|
|
227
|
+
return symbol;
|
|
228
|
+
}
|
|
229
|
+
|
|
214
230
|
export function createOutputBinder(options: BinderOptions = {}): Binder {
|
|
215
231
|
const binder: Binder = {
|
|
216
232
|
resolveDeclarationByKey,
|
|
@@ -247,6 +263,7 @@ export function createOutputBinder(options: BinderOptions = {}): Binder {
|
|
|
247
263
|
}
|
|
248
264
|
|
|
249
265
|
function notifySymbolDeleted(symbol: OutputSymbol) {
|
|
266
|
+
debug.symbols.unregisterSymbol(symbol);
|
|
250
267
|
if (!refkey) {
|
|
251
268
|
return;
|
|
252
269
|
}
|
|
@@ -458,25 +475,25 @@ export function createOutputBinder(options: BinderOptions = {}): Binder {
|
|
|
458
475
|
const resolvedSymbol = getSymbolForRefkey(refkey);
|
|
459
476
|
|
|
460
477
|
return computed(() => {
|
|
461
|
-
trace(
|
|
478
|
+
debug.trace(
|
|
462
479
|
TracePhase.resolve.pending,
|
|
463
480
|
() => `Resolving ${formatRefkeys(refkey)}.`,
|
|
464
481
|
);
|
|
465
482
|
const symbol = resolvedSymbol.value as TSymbol;
|
|
466
483
|
if (!symbol) {
|
|
467
|
-
trace(
|
|
484
|
+
debug.trace(
|
|
468
485
|
TracePhase.resolve.failure,
|
|
469
486
|
() => `No symbol for ${formatRefkeys(refkey)}.`,
|
|
470
487
|
);
|
|
471
488
|
return undefined;
|
|
472
489
|
}
|
|
473
|
-
trace(
|
|
490
|
+
debug.trace(
|
|
474
491
|
TracePhase.resolve.pending,
|
|
475
492
|
() =>
|
|
476
493
|
`${formatRefkeys(refkey)} resolved to ${formatSymbolName(symbol)}.`,
|
|
477
494
|
);
|
|
478
495
|
if (symbol.isTransient) {
|
|
479
|
-
trace(
|
|
496
|
+
debug.trace(
|
|
480
497
|
TracePhase.resolve.failure,
|
|
481
498
|
() => `Symbol ${formatSymbolName(symbol)} is transient.`,
|
|
482
499
|
);
|
|
@@ -485,7 +502,7 @@ export function createOutputBinder(options: BinderOptions = {}): Binder {
|
|
|
485
502
|
|
|
486
503
|
const chain = scopeChain(symbol.scope);
|
|
487
504
|
if (chain.some((scope) => scope.isTransient)) {
|
|
488
|
-
trace(
|
|
505
|
+
debug.trace(
|
|
489
506
|
TracePhase.resolve.failure,
|
|
490
507
|
() => `Symbol ${formatSymbolName(symbol)} is in a transient scope.`,
|
|
491
508
|
);
|
|
@@ -533,7 +550,7 @@ export function createOutputBinder(options: BinderOptions = {}): Binder {
|
|
|
533
550
|
for (const descriptor of allDescriptors) {
|
|
534
551
|
const member = descriptor.symbol as TSymbol;
|
|
535
552
|
if (currentBase.isTyped && !currentBase.hasTypeSymbol) {
|
|
536
|
-
trace(
|
|
553
|
+
debug.trace(
|
|
537
554
|
TracePhase.resolve.pending,
|
|
538
555
|
() =>
|
|
539
556
|
`${formatRefkeys(refkey)} needs type information from a parent type.`,
|
|
@@ -550,7 +567,7 @@ export function createOutputBinder(options: BinderOptions = {}): Binder {
|
|
|
550
567
|
currentBase = member;
|
|
551
568
|
}
|
|
552
569
|
|
|
553
|
-
trace(
|
|
570
|
+
debug.trace(
|
|
554
571
|
TracePhase.resolve.success,
|
|
555
572
|
() =>
|
|
556
573
|
`${formatRefkeys(refkey)} successfully resolved to ${formatSymbolName(symbol)}.`,
|
|
@@ -628,7 +645,7 @@ export function createOutputBinder(options: BinderOptions = {}): Binder {
|
|
|
628
645
|
function notifySymbolCreated(symbol: OutputSymbol): void {
|
|
629
646
|
effect<Refkey[]>((oldRefkeys) => {
|
|
630
647
|
if (symbol.refkeys) {
|
|
631
|
-
trace(
|
|
648
|
+
debug.trace(
|
|
632
649
|
TracePhase.resolve.pending,
|
|
633
650
|
() => `Notifying resolutions for ${formatRefkeys(symbol.refkeys)}.`,
|
|
634
651
|
);
|
|
@@ -702,11 +719,49 @@ export function resolve<
|
|
|
702
719
|
throw new Error("Can't resolve refkey without a binder");
|
|
703
720
|
}
|
|
704
721
|
|
|
705
|
-
|
|
722
|
+
const result = binder.resolveDeclarationByKey(
|
|
706
723
|
scope as TScope,
|
|
707
724
|
refkey,
|
|
708
725
|
options,
|
|
709
726
|
) as any;
|
|
727
|
+
|
|
728
|
+
let diagnosticHandle: DiagnosticHandle | null = null;
|
|
729
|
+
|
|
730
|
+
effect(
|
|
731
|
+
() => {
|
|
732
|
+
if (result.value === undefined) {
|
|
733
|
+
// Emit diagnostic for this specific reference site
|
|
734
|
+
if (!diagnosticHandle) {
|
|
735
|
+
diagnosticHandle = emitDiagnostic({
|
|
736
|
+
severity: "warning",
|
|
737
|
+
message: `Unresolved refkey: ${inspectRefkey(refkey)}`,
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
} else {
|
|
741
|
+
// Dismiss diagnostic when resolved
|
|
742
|
+
if (diagnosticHandle) {
|
|
743
|
+
diagnosticHandle.dismiss();
|
|
744
|
+
diagnosticHandle = null;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
undefined,
|
|
749
|
+
{
|
|
750
|
+
debug: {
|
|
751
|
+
name: `binder:resolve:${inspectRefkey(refkey)}`,
|
|
752
|
+
type: "binder",
|
|
753
|
+
},
|
|
754
|
+
},
|
|
755
|
+
);
|
|
756
|
+
|
|
757
|
+
onCleanup(() => {
|
|
758
|
+
if (diagnosticHandle) {
|
|
759
|
+
diagnosticHandle.dismiss();
|
|
760
|
+
diagnosticHandle = null;
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
return result;
|
|
710
765
|
}
|
|
711
766
|
|
|
712
767
|
/**
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import "../../testing/extend-expect.js";
|
|
3
|
+
import {
|
|
4
|
+
BasePartProps,
|
|
5
|
+
createAccessExpression,
|
|
6
|
+
} from "../components/AccessExpression.jsx";
|
|
7
|
+
import { code } from "../index.js";
|
|
8
|
+
import { printTree, renderTree } from "../render.js";
|
|
9
|
+
import { Children } from "../runtime/component.js";
|
|
10
|
+
|
|
11
|
+
interface TestPartProps extends BasePartProps {
|
|
12
|
+
name?: string;
|
|
13
|
+
args?: Children;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface TestPart extends Record<string, unknown> {
|
|
17
|
+
name: string | undefined;
|
|
18
|
+
args: Children | undefined;
|
|
19
|
+
isFirst: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { Expression, Part } = createAccessExpression<TestPartProps, TestPart>({
|
|
23
|
+
createDescriptor(props, symbol, first) {
|
|
24
|
+
return {
|
|
25
|
+
name: symbol?.name ?? props.name,
|
|
26
|
+
args: props.args,
|
|
27
|
+
isFirst: first,
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
getBase(part) {
|
|
32
|
+
return part.name ?? "";
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
formatPart(part, _prevPart, _inCallChain) {
|
|
36
|
+
if (part.args !== undefined) {
|
|
37
|
+
return code`.${part.name}(${part.args})`;
|
|
38
|
+
}
|
|
39
|
+
return code`.${part.name}`;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
isCallPart(part) {
|
|
43
|
+
return part.args !== undefined;
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("createAccessExpression", () => {
|
|
48
|
+
it("renders a single part as the base", () => {
|
|
49
|
+
expect(
|
|
50
|
+
<Expression>
|
|
51
|
+
<Part name="foo" />
|
|
52
|
+
</Expression>,
|
|
53
|
+
).toRenderTo("foo");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("renders multiple parts with dot access", () => {
|
|
57
|
+
expect(
|
|
58
|
+
<Expression>
|
|
59
|
+
<Part name="foo" />
|
|
60
|
+
<Part name="bar" />
|
|
61
|
+
<Part name="baz" />
|
|
62
|
+
</Expression>,
|
|
63
|
+
).toRenderTo("foo.bar.baz");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("renders parts with call arguments", () => {
|
|
67
|
+
expect(
|
|
68
|
+
<Expression>
|
|
69
|
+
<Part name="foo" />
|
|
70
|
+
<Part name="bar" args="x, y" />
|
|
71
|
+
</Expression>,
|
|
72
|
+
).toRenderTo("foo.bar(x, y)");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("returns empty for no parts", () => {
|
|
76
|
+
expect(<Expression>{false}</Expression>).toRenderTo("");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("flattens nested Expression instances", () => {
|
|
80
|
+
const inner = (
|
|
81
|
+
<Expression>
|
|
82
|
+
<Part name="bar" />
|
|
83
|
+
<Part name="baz" />
|
|
84
|
+
</Expression>
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(
|
|
88
|
+
<Expression>
|
|
89
|
+
<Part name="foo" />
|
|
90
|
+
{inner}
|
|
91
|
+
</Expression>,
|
|
92
|
+
).toRenderTo("foo.bar.baz");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("ignores non-Part children", () => {
|
|
96
|
+
expect(
|
|
97
|
+
<Expression>
|
|
98
|
+
<Part name="foo" />
|
|
99
|
+
{"some string"}
|
|
100
|
+
<Part name="bar" />
|
|
101
|
+
</Expression>,
|
|
102
|
+
).toRenderTo("foo.bar");
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe("createAccessExpression: call chain formatting", () => {
|
|
107
|
+
it("uses linear format with only one call", () => {
|
|
108
|
+
const tree = renderTree(
|
|
109
|
+
<Expression>
|
|
110
|
+
<Part name="foo" />
|
|
111
|
+
<Part name="bar" args="x" />
|
|
112
|
+
</Expression>,
|
|
113
|
+
);
|
|
114
|
+
// Single call → linear, no grouping.
|
|
115
|
+
expect(printTree(tree)).toBe("foo.bar(x)");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("uses call chain format with multiple calls", () => {
|
|
119
|
+
const tree = renderTree(
|
|
120
|
+
<Expression>
|
|
121
|
+
<Part name="foo" />
|
|
122
|
+
<Part name="bar" args="x" />
|
|
123
|
+
<Part name="baz" args="y" />
|
|
124
|
+
</Expression>,
|
|
125
|
+
);
|
|
126
|
+
// Multiple calls → call chain with group/indent wrapping.
|
|
127
|
+
const result = printTree(tree);
|
|
128
|
+
// Should contain both calls.
|
|
129
|
+
expect(result).toContain("bar(x)");
|
|
130
|
+
expect(result).toContain("baz(y)");
|
|
131
|
+
});
|
|
132
|
+
});
|