@alloy-js/core 0.23.0-dev.12 → 0.23.0-dev.15
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/api-extractor.json +1 -8
- package/api-extractor.testing.json +19 -0
- package/dist/dev/src/binder.js +108 -1
- package/dist/dev/src/binder.js.map +1 -1
- package/dist/dev/src/components/Block.js +17 -5
- package/dist/dev/src/components/Block.js.map +1 -1
- package/dist/dev/src/components/List.js +1 -1
- package/dist/dev/src/components/List.js.map +1 -1
- package/dist/dev/src/components/MemberDeclaration.js +6 -6
- package/dist/dev/src/components/MemberName.js +7 -0
- package/dist/dev/src/components/MemberName.js.map +1 -1
- package/dist/dev/src/components/MemberScope.js +7 -2
- package/dist/dev/src/components/MemberScope.js.map +1 -1
- package/dist/dev/src/components/Output.js +4 -4
- package/dist/dev/src/components/Output.js.map +1 -1
- package/dist/dev/src/components/Scope.js +7 -1
- package/dist/dev/src/components/Scope.js.map +1 -1
- package/dist/dev/src/components/SourceFile.js +3 -3
- package/dist/dev/src/components/SourceFile.js.map +1 -1
- package/dist/dev/src/context/binder.js +5 -0
- package/dist/dev/src/context/binder.js.map +1 -1
- package/dist/dev/src/context/format-options.js +14 -1
- package/dist/dev/src/context/format-options.js.map +1 -1
- package/dist/dev/src/context/scope.js +5 -0
- package/dist/dev/src/context/scope.js.map +1 -1
- package/dist/dev/src/context/source-directory.js +9 -0
- package/dist/dev/src/context/source-directory.js.map +1 -1
- package/dist/dev/src/debug/cli.js +3 -2
- package/dist/dev/src/debug/cli.js.map +1 -1
- package/dist/dev/src/debug/source-map.browser.js +24 -0
- package/dist/dev/src/debug/source-map.browser.js.map +1 -0
- package/dist/dev/src/debug/trace.js +7 -6
- package/dist/dev/src/debug/trace.js.map +1 -1
- package/dist/dev/src/host/node-host.browser.js +21 -0
- package/dist/dev/src/host/node-host.browser.js.map +1 -0
- package/dist/dev/src/host/node-host.js +20 -0
- package/dist/dev/src/host/node-host.js.map +1 -0
- package/dist/dev/src/library-symbol-reference.js +54 -0
- package/dist/dev/src/library-symbol-reference.js.map +1 -1
- package/dist/dev/src/name-policy.js +27 -0
- package/dist/dev/src/name-policy.js.map +1 -1
- package/dist/dev/src/reactivity.js +16 -0
- package/dist/dev/src/reactivity.js.map +1 -1
- package/dist/dev/src/render-stack.js +4 -3
- package/dist/dev/src/render-stack.js.map +1 -1
- package/dist/dev/src/render.js.map +1 -1
- package/dist/dev/src/symbols/output-scope.js +34 -1
- package/dist/dev/src/symbols/output-scope.js.map +1 -1
- package/dist/dev/src/symbols/output-space.js +15 -0
- package/dist/dev/src/symbols/output-space.js.map +1 -1
- package/dist/dev/src/symbols/output-symbol.js +81 -11
- package/dist/dev/src/symbols/output-symbol.js.map +1 -1
- package/dist/dev/src/symbols/symbol-slot.js +7 -0
- package/dist/dev/src/symbols/symbol-slot.js.map +1 -1
- package/dist/dev/src/symbols/symbol-slot.test.js +27 -2
- package/dist/dev/src/symbols/symbol-slot.test.js.map +1 -1
- package/dist/dev/src/write-output.js +6 -5
- package/dist/dev/src/write-output.js.map +1 -1
- package/dist/dev/test/browser-build.test.js +67 -68
- package/dist/dev/test/browser-build.test.js.map +1 -1
- package/dist/dev/testing/create-test-wrapper.js +59 -5
- package/dist/dev/testing/create-test-wrapper.js.map +1 -1
- package/dist/dev/testing/extend-expect.js +20 -0
- package/dist/dev/testing/extend-expect.js.map +1 -1
- package/dist/dev/testing/index.js +1 -1
- package/dist/dev/testing/index.js.map +1 -1
- package/dist/dev/testing/render.js +11 -0
- package/dist/dev/testing/render.js.map +1 -1
- package/dist/src/binder.d.ts +107 -3
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +108 -1
- package/dist/src/binder.js.map +1 -1
- package/dist/src/components/Block.d.ts +12 -0
- package/dist/src/components/Block.d.ts.map +1 -1
- package/dist/src/components/Block.js +12 -0
- package/dist/src/components/Block.js.map +1 -1
- package/dist/src/components/List.d.ts +11 -1
- package/dist/src/components/List.d.ts.map +1 -1
- package/dist/src/components/List.js.map +1 -1
- package/dist/src/components/MemberDeclaration.d.ts +6 -6
- package/dist/src/components/MemberDeclaration.js +6 -6
- package/dist/src/components/MemberName.d.ts +6 -0
- package/dist/src/components/MemberName.d.ts.map +1 -1
- package/dist/src/components/MemberName.js +7 -0
- package/dist/src/components/MemberName.js.map +1 -1
- package/dist/src/components/MemberScope.d.ts +5 -0
- package/dist/src/components/MemberScope.d.ts.map +1 -1
- package/dist/src/components/MemberScope.js +5 -0
- package/dist/src/components/MemberScope.js.map +1 -1
- package/dist/src/components/Output.d.ts +4 -2
- package/dist/src/components/Output.d.ts.map +1 -1
- package/dist/src/components/Output.js.map +1 -1
- package/dist/src/components/Scope.d.ts +6 -0
- package/dist/src/components/Scope.d.ts.map +1 -1
- package/dist/src/components/Scope.js +6 -0
- package/dist/src/components/Scope.js.map +1 -1
- package/dist/src/components/SourceFile.d.ts +22 -2
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/context/binder.d.ts +4 -0
- package/dist/src/context/binder.d.ts.map +1 -1
- package/dist/src/context/binder.js +5 -0
- package/dist/src/context/binder.js.map +1 -1
- package/dist/src/context/format-options.d.ts +14 -1
- package/dist/src/context/format-options.d.ts.map +1 -1
- package/dist/src/context/format-options.js +14 -1
- package/dist/src/context/format-options.js.map +1 -1
- package/dist/src/context/scope.d.ts +4 -0
- package/dist/src/context/scope.d.ts.map +1 -1
- package/dist/src/context/scope.js +5 -0
- package/dist/src/context/scope.js.map +1 -1
- package/dist/src/context/source-directory.d.ts +9 -0
- package/dist/src/context/source-directory.d.ts.map +1 -1
- package/dist/src/context/source-directory.js +9 -0
- package/dist/src/context/source-directory.js.map +1 -1
- package/dist/src/debug/cli.d.ts.map +1 -1
- package/dist/src/debug/cli.js +3 -2
- package/dist/src/debug/cli.js.map +1 -1
- package/dist/src/debug/source-map.browser.d.ts +16 -0
- package/dist/src/debug/source-map.browser.d.ts.map +1 -0
- package/dist/src/debug/source-map.browser.js +24 -0
- package/dist/src/debug/source-map.browser.js.map +1 -0
- package/dist/src/debug/trace.d.ts.map +1 -1
- package/dist/src/debug/trace.js +7 -6
- package/dist/src/debug/trace.js.map +1 -1
- package/dist/src/host/node-host.browser.d.ts +11 -0
- package/dist/src/host/node-host.browser.d.ts.map +1 -0
- package/dist/src/host/node-host.browser.js +21 -0
- package/dist/src/host/node-host.browser.js.map +1 -0
- package/dist/src/host/node-host.d.ts +11 -0
- package/dist/src/host/node-host.d.ts.map +1 -0
- package/dist/src/host/node-host.js +20 -0
- package/dist/src/host/node-host.js.map +1 -0
- package/dist/src/library-symbol-reference.d.ts +52 -0
- package/dist/src/library-symbol-reference.d.ts.map +1 -1
- package/dist/src/library-symbol-reference.js +54 -0
- package/dist/src/library-symbol-reference.js.map +1 -1
- package/dist/src/name-policy.d.ts +30 -3
- package/dist/src/name-policy.d.ts.map +1 -1
- package/dist/src/name-policy.js +27 -0
- package/dist/src/name-policy.js.map +1 -1
- package/dist/src/reactivity.d.ts +15 -0
- package/dist/src/reactivity.d.ts.map +1 -1
- package/dist/src/reactivity.js +16 -0
- package/dist/src/reactivity.js.map +1 -1
- package/dist/src/render-stack.d.ts.map +1 -1
- package/dist/src/render-stack.js +4 -3
- package/dist/src/render-stack.js.map +1 -1
- package/dist/src/render.d.ts +2 -0
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js.map +1 -1
- package/dist/src/symbols/output-scope.d.ts +33 -1
- package/dist/src/symbols/output-scope.d.ts.map +1 -1
- package/dist/src/symbols/output-scope.js +34 -1
- package/dist/src/symbols/output-scope.js.map +1 -1
- package/dist/src/symbols/output-space.d.ts +12 -0
- package/dist/src/symbols/output-space.d.ts.map +1 -1
- package/dist/src/symbols/output-space.js +15 -0
- package/dist/src/symbols/output-space.js.map +1 -1
- package/dist/src/symbols/output-symbol.d.ts +93 -12
- package/dist/src/symbols/output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/output-symbol.js +81 -11
- package/dist/src/symbols/output-symbol.js.map +1 -1
- package/dist/src/symbols/symbol-slot.d.ts.map +1 -1
- package/dist/src/symbols/symbol-slot.js +7 -0
- package/dist/src/symbols/symbol-slot.js.map +1 -1
- package/dist/src/symbols/symbol-slot.test.js +18 -1
- package/dist/src/symbols/symbol-slot.test.js.map +1 -1
- package/dist/src/write-output.d.ts.map +1 -1
- package/dist/src/write-output.js +6 -5
- package/dist/src/write-output.js.map +1 -1
- package/dist/test/browser-build.test.js +67 -68
- package/dist/test/browser-build.test.js.map +1 -1
- package/dist/testing/create-test-wrapper.d.ts +75 -2
- package/dist/testing/create-test-wrapper.d.ts.map +1 -1
- package/dist/testing/create-test-wrapper.js +55 -1
- package/dist/testing/create-test-wrapper.js.map +1 -1
- package/dist/testing/extend-expect.d.ts +26 -0
- package/dist/testing/extend-expect.d.ts.map +1 -1
- package/dist/testing/extend-expect.js +20 -0
- package/dist/testing/extend-expect.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/render.d.ts +9 -0
- package/dist/testing/render.d.ts.map +1 -1
- package/dist/testing/render.js +11 -0
- package/dist/testing/render.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/api/components/AppendRegion.md +83 -0
- package/docs/api/components/Block.md +49 -0
- package/docs/api/components/CopyFile.md +26 -0
- package/docs/api/components/Declaration.md +85 -0
- package/docs/api/components/For.md +91 -0
- package/docs/api/components/Indent.md +40 -0
- package/docs/api/components/List.md +68 -0
- package/docs/api/components/MemberDeclaration.md +89 -0
- package/docs/api/components/MemberName.md +21 -0
- package/docs/api/components/MemberScope.md +81 -0
- package/docs/api/components/Name.md +19 -0
- package/docs/api/components/Output.md +62 -0
- package/docs/api/components/Prose.md +29 -0
- package/docs/api/components/ReferenceOrContent.md +28 -0
- package/docs/api/components/Scope.md +83 -0
- package/docs/api/components/Show.md +32 -0
- package/docs/api/components/SourceDirectory.md +28 -0
- package/docs/api/components/SourceFile.md +60 -0
- package/docs/api/components/StatementList.md +29 -0
- package/docs/api/components/Switch.md +42 -0
- package/docs/api/components/TemplateFile.md +71 -0
- package/docs/api/components/TemplateVariable.md +57 -0
- package/docs/api/components/UpdateFile.md +56 -0
- package/docs/api/components/Wrap.md +40 -0
- package/docs/api/components/createAccessExpression.md +55 -0
- package/docs/api/components/index.md +27 -0
- package/docs/api/contexts/Assignment-context.md +43 -0
- package/docs/api/contexts/Binder-context.md +22 -0
- package/docs/api/contexts/Declaration-context.md +15 -0
- package/docs/api/contexts/Member-context.md +17 -0
- package/docs/api/contexts/MemberDeclaration-context.md +24 -0
- package/docs/api/contexts/NamePolicy-context.md +18 -0
- package/docs/api/contexts/Scope-context.md +20 -0
- package/docs/api/contexts/SourceDirectory-context.md +26 -0
- package/docs/api/contexts/SourceFile-context.md +19 -0
- package/docs/api/contexts/index.md +11 -0
- package/docs/api/functions/attachDiagnosticsCollector.md +18 -0
- package/docs/api/functions/baseListPropsToMapJoinArgs.md +20 -0
- package/docs/api/functions/children.md +27 -0
- package/docs/api/functions/childrenArray.md +25 -0
- package/docs/api/functions/code.md +25 -0
- package/docs/api/functions/computed.md +18 -0
- package/docs/api/functions/createComponent.md +20 -0
- package/docs/api/functions/createContentSlot.md +33 -0
- package/docs/api/functions/createContext.md +19 -0
- package/docs/api/functions/createCustomContext.md +18 -0
- package/docs/api/functions/createDeclarationTap.md +20 -0
- package/docs/api/functions/createFileResource.md +35 -0
- package/docs/api/functions/createFormatOptionsContextFor.md +28 -0
- package/docs/api/functions/createIntrinsic.md +19 -0
- package/docs/api/functions/createMemberTap.md +20 -0
- package/docs/api/functions/createNamePolicy.md +37 -0
- package/docs/api/functions/createNamedContext.md +19 -0
- package/docs/api/functions/createOutputBinder.md +24 -0
- package/docs/api/functions/createRenderTreeHook.md +19 -0
- package/docs/api/functions/createResource.md +77 -0
- package/docs/api/functions/createScope.md +35 -0
- package/docs/api/functions/createScopeTap.md +20 -0
- package/docs/api/functions/createSourceFileTap.md +20 -0
- package/docs/api/functions/createSymbol.md +25 -0
- package/docs/api/functions/createSymbolSlot.md +19 -0
- package/docs/api/functions/createTap.md +55 -0
- package/docs/api/functions/decl.md +20 -0
- package/docs/api/functions/defaultProps.md +21 -0
- package/docs/api/functions/effect.md +26 -0
- package/docs/api/functions/emitDiagnostic.md +18 -0
- package/docs/api/functions/emitSymbol.md +18 -0
- package/docs/api/functions/ensureIsEmpty.md +20 -0
- package/docs/api/functions/findCurrentEffectId.md +19 -0
- package/docs/api/functions/findKeyedChild.md +19 -0
- package/docs/api/functions/findKeyedChildren.md +19 -0
- package/docs/api/functions/findUnkeyedChildren.md +18 -0
- package/docs/api/functions/formatReactivePropertyLabel.md +21 -0
- package/docs/api/functions/getAssignmentSymbol.md +19 -0
- package/docs/api/functions/getContext.md +17 -0
- package/docs/api/functions/getContextForRenderNode.md +18 -0
- package/docs/api/functions/getDiagnosticsForTree.md +18 -0
- package/docs/api/functions/getEffectDebugId.md +18 -0
- package/docs/api/functions/getElementCache.md +17 -0
- package/docs/api/functions/getReactiveCreationLocation.md +18 -0
- package/docs/api/functions/getSymbolCreator.md +18 -0
- package/docs/api/functions/getSymbolCreatorSymbol.md +17 -0
- package/docs/api/functions/index.md +105 -0
- package/docs/api/functions/inspectRefkey.md +18 -0
- package/docs/api/functions/instantiateTakenMembersTo.md +20 -0
- package/docs/api/functions/isComponentCreator.md +19 -0
- package/docs/api/functions/isCustomContext.md +18 -0
- package/docs/api/functions/isIntrinsicElement.md +18 -0
- package/docs/api/functions/isKeyedChild.md +18 -0
- package/docs/api/functions/isLibrarySymbolReference.md +18 -0
- package/docs/api/functions/isMemberRefkey.md +18 -0
- package/docs/api/functions/isNamekey.md +18 -0
- package/docs/api/functions/isPrintHook.md +18 -0
- package/docs/api/functions/isRefkey.md +18 -0
- package/docs/api/functions/isRefkeyable.md +18 -0
- package/docs/api/functions/isRenderableObject.md +20 -0
- package/docs/api/functions/isSymbolRefkey.md +18 -0
- package/docs/api/functions/join.md +33 -0
- package/docs/api/functions/mapJoin.md +106 -0
- package/docs/api/functions/memberRefkey.md +27 -0
- package/docs/api/functions/memo.md +29 -0
- package/docs/api/functions/mergeProps.md +64 -0
- package/docs/api/functions/moveTakenMembersTo.md +18 -0
- package/docs/api/functions/namekey.md +41 -0
- package/docs/api/functions/nextReactiveId.md +19 -0
- package/docs/api/functions/notifyContentState.md +17 -0
- package/docs/api/functions/onCleanup.md +26 -0
- package/docs/api/functions/printTree.md +31 -0
- package/docs/api/functions/reactivePropertyRefId.md +21 -0
- package/docs/api/functions/ref.md +21 -0
- package/docs/api/functions/refId.md +18 -0
- package/docs/api/functions/refkey.md +24 -0
- package/docs/api/functions/render.md +31 -0
- package/docs/api/functions/renderAsync.md +31 -0
- package/docs/api/functions/renderTree.md +18 -0
- package/docs/api/functions/reportDiagnostics.md +18 -0
- package/docs/api/functions/resetRefIdCounter.md +17 -0
- package/docs/api/functions/resolve.md +31 -0
- package/docs/api/functions/root.md +25 -0
- package/docs/api/functions/shallowReactive.md +18 -0
- package/docs/api/functions/shallowRef.md +21 -0
- package/docs/api/functions/sourceFilesForTree.md +31 -0
- package/docs/api/functions/splitProps.md +19 -0
- package/docs/api/functions/stc.md +18 -0
- package/docs/api/functions/sti.md +18 -0
- package/docs/api/functions/symbolForRefkey.md +24 -0
- package/docs/api/functions/taggedComponent.md +19 -0
- package/docs/api/functions/takeSymbols.md +18 -0
- package/docs/api/functions/text.md +19 -0
- package/docs/api/functions/toRef.md +20 -0
- package/docs/api/functions/toRefkey.md +18 -0
- package/docs/api/functions/toRefs.md +20 -0
- package/docs/api/functions/traverseOutput.md +21 -0
- package/docs/api/functions/unresolvedRefkey.md +18 -0
- package/docs/api/functions/untrack.md +18 -0
- package/docs/api/functions/useContext.md +18 -0
- package/docs/api/functions/useFormatOptions.md +18 -0
- package/docs/api/functions/useMemberContext.md +17 -0
- package/docs/api/functions/useMemberScope.md +17 -0
- package/docs/api/functions/writeOutput.md +21 -0
- package/docs/api/index.md +9 -0
- package/docs/api/testing/functions/createTestWrapper.md +70 -0
- package/docs/api/testing/functions/d.md +21 -0
- package/docs/api/testing/functions/dedent.md +18 -0
- package/docs/api/testing/functions/index.md +6 -0
- package/docs/api/testing/functions/renderToString.md +20 -0
- package/docs/api/testing/index.md +4 -0
- package/docs/api/testing/types/TestWrapper.md +10 -0
- package/docs/api/testing/types/ToRenderToOptions.md +24 -0
- package/docs/api/testing/types/index.md +4 -0
- package/docs/api/types/AlignIntrinsicElement.md +5 -0
- package/docs/api/types/AppendRegionProps.md +5 -0
- package/docs/api/types/BaseListProps.md +21 -0
- package/docs/api/types/BasePartProps.md +10 -0
- package/docs/api/types/BasicScope.md +15 -0
- package/docs/api/types/BasicSymbol.md +18 -0
- package/docs/api/types/Binder.md +18 -0
- package/docs/api/types/BinderOptions.md +7 -0
- package/docs/api/types/BrIntrinsicElement.md +5 -0
- package/docs/api/types/BreakParentIntrinsicElement.md +5 -0
- package/docs/api/types/Child.md +5 -0
- package/docs/api/types/Children.md +5 -0
- package/docs/api/types/ChildrenOptions.md +7 -0
- package/docs/api/types/CommonFormatOptions.md +8 -0
- package/docs/api/types/Component.md +8 -0
- package/docs/api/types/ComponentContext.md +11 -0
- package/docs/api/types/ComponentCreator.md +11 -0
- package/docs/api/types/ComponentDefinition.md +7 -0
- package/docs/api/types/ContentOutputFile.md +10 -0
- package/docs/api/types/ContentSlot.md +12 -0
- package/docs/api/types/Context.md +19 -0
- package/docs/api/types/ContextProviderProps.md +8 -0
- package/docs/api/types/CopyFileContext.md +8 -0
- package/docs/api/types/CopyOutputFile.md +9 -0
- package/docs/api/types/CustomContext.md +10 -0
- package/docs/api/types/CustomContextChildrenCallback.md +5 -0
- package/docs/api/types/DeclarationProps.md +5 -0
- package/docs/api/types/DedentIntrinsicElement.md +5 -0
- package/docs/api/types/DedentToRootIntrinsicElement.md +5 -0
- package/docs/api/types/Diagnostic.md +11 -0
- package/docs/api/types/DiagnosticHandle.md +7 -0
- package/docs/api/types/DiagnosticInput.md +10 -0
- package/docs/api/types/DiagnosticSeverity.md +5 -0
- package/docs/api/types/DiagnosticStackEntry.md +9 -0
- package/docs/api/types/DiagnosticsCollector.md +8 -0
- package/docs/api/types/Disposable_2.md +7 -0
- package/docs/api/types/EffectDebugOptions.md +8 -0
- package/docs/api/types/EffectOptions.md +7 -0
- package/docs/api/types/ElementCache.md +5 -0
- package/docs/api/types/ElementCacheKey.md +5 -0
- package/docs/api/types/FillIntrinsicElement.md +5 -0
- package/docs/api/types/ForCallbackArgs.md +5 -0
- package/docs/api/types/ForSupportedCollections.md +5 -0
- package/docs/api/types/GroupIntrinsicElement.md +5 -0
- package/docs/api/types/HardlineIntrinsicElement.md +5 -0
- package/docs/api/types/HbrIntrinsicElement.md +5 -0
- package/docs/api/types/IfBreakIntrinsicElement.md +5 -0
- package/docs/api/types/IndentIfBreakIntrinsicElement.md +5 -0
- package/docs/api/types/IndentIntrinsicElement.md +5 -0
- package/docs/api/types/IntrinsicElement.md +5 -0
- package/docs/api/types/IntrinsicElementBase.md +9 -0
- package/docs/api/types/IntrinsicElements.md +26 -0
- package/docs/api/types/JoinOptions.md +9 -0
- package/docs/api/types/LbrIntrinsicElement.md +5 -0
- package/docs/api/types/LibrarySymbolReference.md +13 -0
- package/docs/api/types/LineIntrinsicElement.md +5 -0
- package/docs/api/types/LineSuffixBoundaryIntrinsicElement.md +5 -0
- package/docs/api/types/LineSuffixIntrinsicElement.md +5 -0
- package/docs/api/types/LiterallineIntrinsicElement.md +5 -0
- package/docs/api/types/MakeChildrenOptional.md +7 -0
- package/docs/api/types/MarkAsRootIntrinsicElement.md +5 -0
- package/docs/api/types/MatchProps.md +9 -0
- package/docs/api/types/MemberDeclarationProps.md +5 -0
- package/docs/api/types/MemberDescriptor.md +10 -0
- package/docs/api/types/MemberRefkey.md +10 -0
- package/docs/api/types/MemberResolutionContext.md +10 -0
- package/docs/api/types/MemberResolver.md +32 -0
- package/docs/api/types/MemberScopeProps.md +5 -0
- package/docs/api/types/Metadata.md +5 -0
- package/docs/api/types/NameConflictResolver.md +27 -0
- package/docs/api/types/NamePolicy.md +8 -0
- package/docs/api/types/NamePolicyGetter.md +9 -0
- package/docs/api/types/Namekey.md +10 -0
- package/docs/api/types/NamekeyOptions.md +8 -0
- package/docs/api/types/OnReactiveSetAddCallback.md +5 -0
- package/docs/api/types/OnReactiveSetDeleteCallback.md +5 -0
- package/docs/api/types/OutputDeclarationSpace.md +13 -0
- package/docs/api/types/OutputDirectory.md +59 -0
- package/docs/api/types/OutputFile.md +5 -0
- package/docs/api/types/OutputFileBase.md +8 -0
- package/docs/api/types/OutputMemberSpace.md +13 -0
- package/docs/api/types/OutputScope.md +33 -0
- package/docs/api/types/OutputScopeOptions.md +9 -0
- package/docs/api/types/OutputSpace.md +7 -0
- package/docs/api/types/OutputSymbol.md +76 -0
- package/docs/api/types/OutputSymbolOptions.md +16 -0
- package/docs/api/types/OutputVisitor.md +10 -0
- package/docs/api/types/PrintHook.md +10 -0
- package/docs/api/types/PrintTreeOptions.md +11 -0
- package/docs/api/types/Props.md +5 -0
- package/docs/api/types/ReactiveUnionSet.md +20 -0
- package/docs/api/types/ReactiveUnionSetOptions.md +8 -0
- package/docs/api/types/Refkey.md +5 -0
- package/docs/api/types/Refkeyable.md +5 -0
- package/docs/api/types/RefkeyableObject.md +7 -0
- package/docs/api/types/RenderableObject.md +9 -0
- package/docs/api/types/RenderedTextTree.md +5 -0
- package/docs/api/types/ResolutionResult.md +39 -0
- package/docs/api/types/ResolveDeclarationByKeyOptions.md +7 -0
- package/docs/api/types/Resource.md +11 -0
- package/docs/api/types/RootOptions.md +7 -0
- package/docs/api/types/SbrIntrinsicElement.md +5 -0
- package/docs/api/types/ScopeProps.md +5 -0
- package/docs/api/types/SoftlineIntrinsicElement.md +5 -0
- package/docs/api/types/SourceLocation.md +9 -0
- package/docs/api/types/SplitProps.md +12 -0
- package/docs/api/types/StcComponentCreator.md +9 -0
- package/docs/api/types/StcSignature.md +5 -0
- package/docs/api/types/StiComponentCreator.md +9 -0
- package/docs/api/types/StiSignature.md +7 -0
- package/docs/api/types/SymbolCreator.md +15 -0
- package/docs/api/types/SymbolRefkey.md +9 -0
- package/docs/api/types/SymbolSlot.md +12 -0
- package/docs/api/types/SymbolTable.md +15 -0
- package/docs/api/types/TakeSymbolCallback.md +7 -0
- package/docs/api/types/TakeSymbolsCallback.md +7 -0
- package/docs/api/types/Tap.md +11 -0
- package/docs/api/types/TapHandler.md +9 -0
- package/docs/api/types/Tapper.md +9 -0
- package/docs/api/types/TemplateVariableProps.md +5 -0
- package/docs/api/types/index.md +122 -0
- package/docs/api/variables/FormatOptions.md +5 -0
- package/docs/api/variables/Match.md +7 -0
- package/docs/api/variables/REFKEYABLE.md +5 -0
- package/docs/api/variables/RENDERABLE.md +5 -0
- package/docs/api/variables/TO_SYMBOL.md +39 -0
- package/docs/api/variables/contextsByKey.md +5 -0
- package/docs/api/variables/index.md +11 -0
- package/docs/api/variables/intrinsicElementKey.md +5 -0
- package/docs/api/variables/matchTag.md +5 -0
- package/docs/api/variables/printHookTag.md +7 -0
- package/docs/components.md +97 -0
- package/docs/context.md +67 -0
- package/docs/control-flow.md +5 -0
- package/docs/debugging.md +105 -0
- package/docs/formatting.md +99 -0
- package/docs/guides/language-package-guide.md +593 -0
- package/docs/guides/references-and-refkeys.md +210 -0
- package/docs/guides/style-guide.md +244 -0
- package/docs/index.md +22 -0
- package/docs/reactivity.md +68 -0
- package/docs/rendering.md +41 -0
- package/docs/symbols-and-scopes.md +180 -0
- package/package.json +8 -4
- package/src/binder.ts +107 -3
- package/src/components/Block.tsx +12 -0
- package/src/components/List.tsx +11 -1
- package/src/components/MemberDeclaration.tsx +6 -6
- package/src/components/MemberName.tsx +6 -0
- package/src/components/MemberScope.tsx +5 -0
- package/src/components/Output.tsx +4 -1
- package/src/components/Scope.tsx +6 -0
- package/src/components/SourceFile.tsx +22 -2
- package/src/context/binder.ts +4 -0
- package/src/context/format-options.ts +14 -1
- package/src/context/scope.ts +4 -0
- package/src/context/source-directory.ts +9 -0
- package/src/debug/cli.ts +3 -2
- package/src/debug/source-map.browser.ts +30 -0
- package/src/debug/trace.ts +7 -6
- package/src/host/node-host.browser.ts +23 -0
- package/src/host/node-host.ts +22 -0
- package/src/library-symbol-reference.ts +52 -0
- package/src/name-policy.ts +30 -3
- package/src/reactivity.ts +15 -0
- package/src/render-stack.ts +4 -3
- package/src/render.ts +2 -0
- package/src/symbols/output-scope.ts +33 -1
- package/src/symbols/output-space.ts +13 -0
- package/src/symbols/output-symbol.ts +93 -12
- package/src/symbols/symbol-slot.test.tsx +28 -1
- package/src/symbols/symbol-slot.tsx +8 -0
- package/src/write-output.ts +6 -5
- package/temp/api-testing.json +673 -0
- package/temp/api.json +48 -47
- package/test/browser-build.test.ts +71 -78
- package/testing/create-test-wrapper.tsx +81 -2
- package/testing/extend-expect.ts +22 -1
- package/testing/index.ts +1 -1
- package/testing/render.ts +9 -0
- package/testing/vitest.d.ts +3 -8
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Symbols & Scopes
|
|
2
|
+
|
|
3
|
+
Alloy's symbol system models declarations, references, and name resolution — the same concepts found in compilers, adapted for code generation.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The [**binder**](api/contexts/Binder-context.md) is the central registry, set up by [`<Output>`](api/components/Output.md). It tracks scopes and symbols. Scopes form a tree mirroring the output structure; each symbol lives in a scope and is identified by one or more [**refkeys**](api/types/Refkey.md). When a refkey appears in JSX, the binder resolves it to the target symbol and computes the scope path between reference and declaration so language packages can emit the correct reference syntax.
|
|
8
|
+
|
|
9
|
+
## Symbols
|
|
10
|
+
|
|
11
|
+
[`OutputSymbol`](api/types/OutputSymbol.md) is the base class. Key properties: reactive `name` (subject to name policies), `refkeys`, `scope`, and optional member spaces.
|
|
12
|
+
|
|
13
|
+
Language packages subclass `OutputSymbol` to add language-specific properties (e.g., accessibility, static/abstract flags).
|
|
14
|
+
|
|
15
|
+
`BasicSymbol` is a concrete subclass from core with "static" and "instance" member spaces — suitable for simple languages or prototyping.
|
|
16
|
+
|
|
17
|
+
### Declaring Symbols
|
|
18
|
+
|
|
19
|
+
[`<Declaration>`](api/components/Declaration.md) creates a `BasicSymbol` by default:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
const fnKey = refkey();
|
|
23
|
+
<Declaration name="myFunction" refkey={fnKey}>
|
|
24
|
+
{/* content */}
|
|
25
|
+
</Declaration>;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For custom symbol types, pass a pre-created symbol via `symbol`:
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
const sym = createSymbol(MyCustomSymbol, namekey, scope.symbols, options);
|
|
32
|
+
<Declaration symbol={sym}>{/* content */}</Declaration>;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
See [`OutputSymbol`](api/types/OutputSymbol.md) and [`OutputSymbolOptions`](api/types/OutputSymbolOptions.md) for parameter details.
|
|
36
|
+
|
|
37
|
+
Language packages wrap [`<Declaration>`](api/components/Declaration.md) with their own components that create language-specific symbol types.
|
|
38
|
+
|
|
39
|
+
### Member Spaces
|
|
40
|
+
|
|
41
|
+
Symbols can have member spaces holding child symbols. Override `static memberSpaces` to declare the space keys for your symbol type (e.g., `["static", "instance"]`). [`<MemberScope>`](api/components/MemberScope.md) enters a member space; [`<MemberDeclaration>`](api/components/MemberDeclaration.md) declares within it.
|
|
42
|
+
|
|
43
|
+
Member spaces ([`OutputMemberSpace`](api/types/OutputSpace.md)) belong to symbols; declaration spaces ([`OutputDeclarationSpace`](api/types/OutputSpace.md)) belong to scopes. Together they form the [`OutputSpace`](api/types/OutputSpace.md) type. Symbols register via the constructor `space` parameter.
|
|
44
|
+
|
|
45
|
+
### Typed Symbols
|
|
46
|
+
|
|
47
|
+
Symbols support a type-symbol relationship through three properties:
|
|
48
|
+
|
|
49
|
+
- **`isTyped`**: set at construction when `OutputSymbolOptions.type` is provided. Not reactive.
|
|
50
|
+
- **`type`**: reactive getter/setter for the type symbol reference. The setter accepts `OutputSymbol` or `Ref<OutputSymbol>` (for deferred resolution) and auto-dealiases. When `isTyped` is true but `type` is not yet resolved, the symbol's members are unavailable until the type arrives.
|
|
51
|
+
- **`hasTypeSymbol`**: derived reactive getter (`this.type !== undefined`).
|
|
52
|
+
|
|
53
|
+
Language packages can add their own symbol properties to control resolution behavior.
|
|
54
|
+
|
|
55
|
+
### Member Resolution
|
|
56
|
+
|
|
57
|
+
The default `resolveMemberByName()` performs:
|
|
58
|
+
|
|
59
|
+
1. If `isTyped`, delegate to `type.resolveMemberByName()` (or return `undefined` if type not yet available).
|
|
60
|
+
2. Otherwise, search member spaces in order for a matching name.
|
|
61
|
+
|
|
62
|
+
There is no privacy or reachability check in the default resolver. When a language needs access-control filtering, provide a custom `memberResolver` callback. **Return `void` to accept** the member; **throw an error to reject** it. See [`MemberResolver`](api/types/MemberResolver.md) for details.
|
|
63
|
+
|
|
64
|
+
## Scopes
|
|
65
|
+
|
|
66
|
+
`OutputScope` is the base class, forming a tree. Each scope has parent/children, one or more **declaration spaces** (named collections of symbols), and is either **lexical** (own declarations) or a **member** scope (exposing an owner symbol's members).
|
|
67
|
+
|
|
68
|
+
Language packages subclass `OutputScope` for custom declaration spaces and behavior (e.g., import tracking, namespace resolution).
|
|
69
|
+
|
|
70
|
+
`BasicScope` is a concrete subclass from core with a single "symbols" space — suitable for simple languages or prototyping.
|
|
71
|
+
|
|
72
|
+
[`<Scope>`](api/components/Scope.md) creates a `BasicScope` by default. Language packages pass custom scope instances via the `value` prop. Use [`createScope()`](api/contexts/Scope-context.md) to construct one.
|
|
73
|
+
|
|
74
|
+
### OutputScope Members
|
|
75
|
+
|
|
76
|
+
| Member | Type | Description |
|
|
77
|
+
| ------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
78
|
+
| `name` | `string` (reactive) | Descriptive name (used in debugging). |
|
|
79
|
+
| `parent` | `OutputScope \| undefined` (reactive) | Parent scope, or `undefined` for roots. |
|
|
80
|
+
| `children` | `Set<OutputScope>` (readonly) | Directly nested child scopes. |
|
|
81
|
+
| `binder` | `Binder \| undefined` (readonly) | Binder that owns this scope. |
|
|
82
|
+
| `metadata` | `Record<string, unknown>` | The property itself is not reactive; the returned object is a reactive plain object (`Record<string, unknown>` wrapped with Vue `reactive()`). |
|
|
83
|
+
| `spaceFor(key)` | `OutputSpace \| undefined` | Returns the declaration space for `key`. `undefined` if `key` is not in `declarationSpaces`. |
|
|
84
|
+
| `declarationSpaces` | `string[]` (static) | Space keys defined by this scope subclass. |
|
|
85
|
+
|
|
86
|
+
### Declaration Spaces
|
|
87
|
+
|
|
88
|
+
A scope can have multiple declaration spaces. Override `static declarationSpaces` to declare the space keys for your scope type. Core's `BasicScope` provides a single "symbols" space; language packages define their own — e.g., a language might define separate "types" and "values" spaces.
|
|
89
|
+
|
|
90
|
+
## Refkeys
|
|
91
|
+
|
|
92
|
+
A [`Refkey`](api/types/Refkey.md) uniquely identifies a symbol. Created with [`refkey()`](api/functions/refkey.md):
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const myClassKey = refkey();
|
|
96
|
+
const myClassKey = refkey("MyClass"); // stable seed
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Composite:** `refkey(a, b)` — deterministic key from multiple arguments.
|
|
100
|
+
**Member:** [`memberRefkey(baseKey, "member")`](api/functions/memberRefkey.md) — access a member of another symbol.
|
|
101
|
+
|
|
102
|
+
When a `Refkey` appears as a JSX child, the binder resolves it and emits the appropriate reference. If resolution fails, [`unresolvedRefkey(refkey)`](api/functions/unresolvedRefkey.md) returns a placeholder.
|
|
103
|
+
|
|
104
|
+
A [`Namekey`](api/types/Namekey.md) is a refkey variant that carries a name and options. Use [`namekey(name, options?)`](api/functions/namekey.md) for names that must bypass the name policy:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
const name = namekey("$special", { ignoreNamePolicy: true });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Binder
|
|
111
|
+
|
|
112
|
+
The central resolution engine. Tracks all scopes and symbols, resolves refkeys by searching up the scope tree, computes scope paths (`pathUp`/`pathDown`), and handles member resolution chains.
|
|
113
|
+
|
|
114
|
+
Set up by [`<Output>`](api/components/Output.md), available via [`BinderContext`](api/contexts/Binder-context.md). Scopes inherit binder from parent.
|
|
115
|
+
|
|
116
|
+
### [`resolve(refkey, options?)`](api/functions/resolve.md)
|
|
117
|
+
|
|
118
|
+
Primary API for resolving a refkey from a component. Returns a reactive `Ref<`[`ResolutionResult`](api/types/ResolutionResult.md)`>`. Generics narrow to language-specific types:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const result = resolve<MyLangScope, MyLangSymbol>(myRefkey);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The [`ResolutionResult`](api/types/ResolutionResult.md) contains the resolved symbol, common ancestor scope, scope paths, and member path. Language packages use `pathDown` to decide how to render a reference.
|
|
125
|
+
|
|
126
|
+
## Symbol Flow
|
|
127
|
+
|
|
128
|
+
Symbols can be **emitted** upward and **taken** by ancestors:
|
|
129
|
+
|
|
130
|
+
- [**`emitSymbol(symbol)`**](api/functions/emitSymbol.md) — emit from current component.
|
|
131
|
+
- [**`takeSymbols(cb?)`**](api/functions/takeSymbols.md) — capture emitted descendants. Returns a reactive set.
|
|
132
|
+
- [**`moveTakenMembersTo(symbol)`**](api/functions/moveTakenMembersTo.md) — take descendants and move as members.
|
|
133
|
+
- [**`createSymbolSlot()`**](api/functions/createSymbolSlot.md) — wrapper component capturing emitted symbols in a subtree.
|
|
134
|
+
|
|
135
|
+
Example: a variable declaration component wraps its type annotation in a symbol slot, then associates captured type symbols with the variable's symbol.
|
|
136
|
+
|
|
137
|
+
## Name Policies
|
|
138
|
+
|
|
139
|
+
`NamePolicy` transforms names by element type (e.g., camelCase for variables, PascalCase for classes). Set on [`<Output>`](api/components/Output.md), applied automatically. Symbols can opt out with `ignoreNamePolicy`.
|
|
140
|
+
|
|
141
|
+
Name conflict resolution is per-language (e.g., a language package might append `_1`, `_2` to conflicting imports).
|
|
142
|
+
|
|
143
|
+
## Extending Symbols and Scopes
|
|
144
|
+
|
|
145
|
+
Custom reactive properties use Vue's `track()` / `trigger()`:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import { track, trigger, TrackOpTypes, TriggerOpTypes } from "@alloy-js/core";
|
|
149
|
+
|
|
150
|
+
class CSharpSymbol extends OutputSymbol {
|
|
151
|
+
#isStatic = false;
|
|
152
|
+
get isStatic() {
|
|
153
|
+
track(this, TrackOpTypes.GET, "isStatic");
|
|
154
|
+
return this.#isStatic;
|
|
155
|
+
}
|
|
156
|
+
set isStatic(value: boolean) {
|
|
157
|
+
const old = this.#isStatic;
|
|
158
|
+
this.#isStatic = value;
|
|
159
|
+
trigger(this, TriggerOpTypes.SET, "isStatic", value, old);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## External Libraries
|
|
165
|
+
|
|
166
|
+
Language packages model external dependencies as scope/symbol trees outside rendered output. [`REFKEYABLE`](api/variables/REFKEYABLE.md) lets objects produce a refkey for resolution. [`TO_SYMBOL`](api/variables/TO_SYMBOL.md) enables lazy symbol creation — the binder calls `[TO_SYMBOL]()` on first reference.
|
|
167
|
+
|
|
168
|
+
Typical pattern:
|
|
169
|
+
|
|
170
|
+
1. Describe the library structure with a descriptor object.
|
|
171
|
+
2. Implement `[REFKEYABLE]()` (returns a refkey) and `[TO_SYMBOL]()` (creates the symbol) on each descriptor.
|
|
172
|
+
3. Cache symbols per binder in a `WeakMap<Binder, Symbol>`.
|
|
173
|
+
4. Use `lazyMemberInitializer` on container types to initialize members lazily when first accessed.
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
const lib = createLibrary("my-lib", { SomeType: { kind: "type", members: { ... } } });
|
|
177
|
+
<>{lib.SomeType}</> // symbol created lazily on first reference
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Library descriptors self-register on demand — no additional wiring to `<Output>` is needed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alloy-js/core",
|
|
3
|
-
"version": "0.23.0-dev.
|
|
3
|
+
"version": "0.23.0-dev.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,8 +43,12 @@
|
|
|
43
43
|
"browser": {
|
|
44
44
|
"./dist/src/host/alloy-host.js": "./dist/src/host/alloy-host.browser.js",
|
|
45
45
|
"./src/host/alloy-host.ts": "./src/host/alloy-host.browser.ts",
|
|
46
|
+
"./dist/src/host/node-host.js": "./dist/src/host/node-host.browser.js",
|
|
47
|
+
"./src/host/node-host.ts": "./src/host/node-host.browser.ts",
|
|
46
48
|
"./dist/src/inspect.js": "./dist/src/inspect.browser.js",
|
|
47
49
|
"./src/inspect.ts": "./src/inspect.browser.ts",
|
|
50
|
+
"./dist/src/debug/source-map.js": "./dist/src/debug/source-map.browser.js",
|
|
51
|
+
"./src/debug/source-map.ts": "./src/debug/source-map.browser.ts",
|
|
48
52
|
"./dist/src/devtools/devtools-server.js": "./dist/src/devtools/devtools-server.browser.js",
|
|
49
53
|
"./src/devtools/devtools-server.ts": "./src/devtools/devtools-server.browser.ts"
|
|
50
54
|
},
|
|
@@ -62,8 +66,8 @@
|
|
|
62
66
|
"ws": "^8.19.0"
|
|
63
67
|
},
|
|
64
68
|
"devDependencies": {
|
|
65
|
-
"@alloy-js/cli": "~0.22.0 || >= 0.23.0-dev.
|
|
66
|
-
"@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.
|
|
69
|
+
"@alloy-js/cli": "~0.22.0 || >= 0.23.0-dev.5",
|
|
70
|
+
"@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.2",
|
|
67
71
|
"@microsoft/api-extractor": "~7.52.8",
|
|
68
72
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
69
73
|
"concurrently": "^9.2.0",
|
|
@@ -73,7 +77,7 @@
|
|
|
73
77
|
},
|
|
74
78
|
"type": "module",
|
|
75
79
|
"scripts": {
|
|
76
|
-
"generate-docs": "api-extractor run",
|
|
80
|
+
"generate-docs": "api-extractor run && api-extractor run -c api-extractor.testing.json",
|
|
77
81
|
"build": "alloy build --with-dev && pnpm run generate-docs",
|
|
78
82
|
"clean": "rimraf dist/ .temp/",
|
|
79
83
|
"test": "vitest run",
|
package/src/binder.ts
CHANGED
|
@@ -102,7 +102,9 @@ export interface Binder {
|
|
|
102
102
|
* * **commonScope**: global scope, because this is the most specific scope that contains both the declaration and the reference.
|
|
103
103
|
* * **pathUp**: [namespace scope 2], because this is the scope between the reference and the common scope.
|
|
104
104
|
* * **pathDown**: [namespace scope 1], because this is the scope between the common scope and the declaration
|
|
105
|
-
* * **memberPath**: [
|
|
105
|
+
* * **memberPath**: [bar]
|
|
106
|
+
* * **lexicalDeclaration**: foo
|
|
107
|
+
* For deeper chains (e.g., foo.bar.baz where bar and baz are member symbols, foo is not): memberPath = [bar, baz], lexicalDeclaration = foo.
|
|
106
108
|
*/
|
|
107
109
|
export interface ResolutionResult<
|
|
108
110
|
TScope extends OutputScope,
|
|
@@ -149,8 +151,8 @@ export interface ResolutionResult<
|
|
|
149
151
|
commonScope: TScope | undefined;
|
|
150
152
|
|
|
151
153
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
+
* Member symbols from the lexical declaration (exclusive) to the resolved symbol
|
|
155
|
+
* (inclusive). Empty when resolving a non-member symbol.
|
|
154
156
|
*/
|
|
155
157
|
memberPath: TSymbol[];
|
|
156
158
|
}
|
|
@@ -164,6 +166,36 @@ export interface MemberDescriptor {
|
|
|
164
166
|
isMemberAccess: boolean;
|
|
165
167
|
}
|
|
166
168
|
|
|
169
|
+
/**
|
|
170
|
+
* A callable interface invoked by the binder when two or more symbols in the
|
|
171
|
+
* same scope share a name. The resolver mutates symbol names to eliminate
|
|
172
|
+
* conflicts (e.g., appending `_2`, `_3`).
|
|
173
|
+
*
|
|
174
|
+
* @remarks
|
|
175
|
+
* The resolver is called with the shared `name` and all symbols in the scope
|
|
176
|
+
* that have that original name. Rename a symbol by assigning to `symbol.name`.
|
|
177
|
+
* Symbols with `ignoreNameConflict: true` are excluded. The default resolver
|
|
178
|
+
* keeps the first symbol unchanged and renames subsequent ones
|
|
179
|
+
* `originalName + "_2"`, `originalName + "_3"`, etc.
|
|
180
|
+
*
|
|
181
|
+
* Assigned names pass through the active name policy before being stored;
|
|
182
|
+
* design suffixes to produce the correct final name after policy
|
|
183
|
+
* transformation, or set `ignoreNamePolicy` on the symbol after resolution.
|
|
184
|
+
*
|
|
185
|
+
* Conflict detection is keyed on `originalName`
|
|
186
|
+
* (see {@link OutputSymbol.originalName}). Symbols that differ in original
|
|
187
|
+
* name but normalize to the same policy-applied name are never detected as
|
|
188
|
+
* conflicting.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const resolver: NameConflictResolver = (name, symbols) => {
|
|
193
|
+
* for (let i = 1; i < symbols.length; i++) {
|
|
194
|
+
* symbols[i].name = symbols[i].originalName + "_" + (i + 1);
|
|
195
|
+
* }
|
|
196
|
+
* };
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
167
199
|
export interface NameConflictResolver {
|
|
168
200
|
(name: string, symbols: OutputSymbol[]): void;
|
|
169
201
|
}
|
|
@@ -187,7 +219,28 @@ export interface MemberResolutionContext<TScope extends OutputScope> {
|
|
|
187
219
|
}
|
|
188
220
|
|
|
189
221
|
/**
|
|
222
|
+
* A callback that performs access-control filtering during member resolution.
|
|
190
223
|
*
|
|
224
|
+
* @remarks
|
|
225
|
+
*
|
|
226
|
+
* When provided to {@link ResolveDeclarationByKeyOptions}, it entirely replaces
|
|
227
|
+
* the default checks (ownership assertion and `isMemberSymbol` assertion).
|
|
228
|
+
*
|
|
229
|
+
* **Contract:**
|
|
230
|
+
* - **Return `void`** to accept the member.
|
|
231
|
+
* - **Throw an error** to reject the member — the error propagates to the caller,
|
|
232
|
+
* matching the behavior of the default checks.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* const resolver: MemberResolver<MyScope, MySymbol> = (owner, member, ctx) => {
|
|
237
|
+
* if (member.isPrivate && !ctx.isMemberAccess) {
|
|
238
|
+
* throw new Error(`${member.name} is not accessible here`);
|
|
239
|
+
* }
|
|
240
|
+
* };
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @see {@link MemberResolutionContext} for available context properties.
|
|
191
244
|
*/
|
|
192
245
|
export interface MemberResolver<
|
|
193
246
|
TScope extends OutputScope,
|
|
@@ -209,6 +262,30 @@ export interface BinderOptions {
|
|
|
209
262
|
nameConflictResolver?: NameConflictResolver;
|
|
210
263
|
}
|
|
211
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Construct a scope instance and register it with devtools. Prefer this over
|
|
267
|
+
* calling `new` directly so that debugging tools can track the scope.
|
|
268
|
+
*
|
|
269
|
+
* @remarks
|
|
270
|
+
*
|
|
271
|
+
* Inside a component, obtain the current scope with `useScope()` and pass it
|
|
272
|
+
* as the `parentScope` constructor argument so the new scope is wired into
|
|
273
|
+
* the scope tree.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```tsx
|
|
277
|
+
* function MyScope(props) {
|
|
278
|
+
* const parentScope = useScope();
|
|
279
|
+
* const scope = createScope(MyScope, "scope-name", parentScope);
|
|
280
|
+
* return <Scope value={scope}>{props.children}</Scope>;
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* @param ctor - The scope subclass constructor.
|
|
285
|
+
* @param args - Positional arguments forwarded directly to the scope
|
|
286
|
+
* constructor; see {@link OutputScope} for the base-class constructor
|
|
287
|
+
* signature.
|
|
288
|
+
*/
|
|
212
289
|
export function createScope<TScope extends OutputScope, Args extends unknown[]>(
|
|
213
290
|
ctor: new (...args: Args) => TScope,
|
|
214
291
|
...args: Args
|
|
@@ -218,6 +295,19 @@ export function createScope<TScope extends OutputScope, Args extends unknown[]>(
|
|
|
218
295
|
return scope;
|
|
219
296
|
}
|
|
220
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Construct a symbol instance and register it with devtools. Prefer this over
|
|
300
|
+
* calling `new` directly so that debugging tools can track the symbol.
|
|
301
|
+
*
|
|
302
|
+
* @remarks
|
|
303
|
+
*
|
|
304
|
+
* Binder registration (via `useBinder()` + `notifySymbolCreated()`) happens
|
|
305
|
+
* inside the `OutputSymbol` constructor regardless of whether you use
|
|
306
|
+
* `createSymbol` or `new`. This helper only adds devtools registration.
|
|
307
|
+
*
|
|
308
|
+
* @param ctor - The symbol subclass constructor.
|
|
309
|
+
* @param args - Arguments forwarded to the constructor.
|
|
310
|
+
*/
|
|
221
311
|
export function createSymbol<
|
|
222
312
|
TSymbol extends OutputSymbol,
|
|
223
313
|
Args extends unknown[],
|
|
@@ -803,6 +893,20 @@ export function getSymbolCreatorSymbol(): typeof createSymbolsSymbol {
|
|
|
803
893
|
return createSymbolsSymbol;
|
|
804
894
|
}
|
|
805
895
|
|
|
896
|
+
/**
|
|
897
|
+
* An object that can register symbols into a binder. Pass instances to the
|
|
898
|
+
* `externals` prop of `<Output>` to make library symbols resolvable.
|
|
899
|
+
*
|
|
900
|
+
* @remarks
|
|
901
|
+
* `SymbolCreator` is a low-level core mechanism for eager symbol registration.
|
|
902
|
+
* The recommended pattern for language packages is lazy self-registration:
|
|
903
|
+
* implement `[TO_SYMBOL]()` on descriptors to call `useBinder()`, create and
|
|
904
|
+
* cache symbols per binder via a `WeakMap`, and register them into the
|
|
905
|
+
* appropriate scope automatically. This approach does not require `externals`.
|
|
906
|
+
* See the C# package's `createLibrary()` for a reference implementation.
|
|
907
|
+
*
|
|
908
|
+
* See {@link TO_SYMBOL} and {@link REFKEYABLE}.
|
|
909
|
+
*/
|
|
806
910
|
export interface SymbolCreator {
|
|
807
911
|
[createSymbolsSymbol](binder: Binder): void;
|
|
808
912
|
}
|
package/src/components/Block.tsx
CHANGED
|
@@ -31,6 +31,18 @@ export interface BlockProps {
|
|
|
31
31
|
* Create an indented block of source text. The block has `opener` text which is
|
|
32
32
|
* added prior to the block, which defaults to `"{"`, and `closer` text which is
|
|
33
33
|
* added after the block, which defaults to `"}"`.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
*
|
|
37
|
+
* When `children` is empty, `Block` renders as `{}` (opener immediately followed
|
|
38
|
+
* by closer) with no indented content — no explicit empty check is needed before
|
|
39
|
+
* passing children.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* // Safe even when props.members is empty — renders `{}`
|
|
44
|
+
* <Block>{props.members}</Block>
|
|
45
|
+
* ```
|
|
34
46
|
*/
|
|
35
47
|
export function Block(props: BlockProps) {
|
|
36
48
|
const ContentSlot = createContentSlot();
|
package/src/components/List.tsx
CHANGED
|
@@ -39,7 +39,17 @@ export interface BaseListProps {
|
|
|
39
39
|
ender?: Children;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Place the join punctuation at the end,
|
|
42
|
+
* Place the join punctuation at the end, without a line break. The punctuation
|
|
43
|
+
* is emitted unconditionally in flat and broken modes.
|
|
44
|
+
*
|
|
45
|
+
* To add trailing punctuation only in broken mode, use `ender` with `<ifBreak>`
|
|
46
|
+
* inside a `<group>` with a non-hardline joiner (e.g. `line`):
|
|
47
|
+
*
|
|
48
|
+
* ```tsx
|
|
49
|
+
* <group>
|
|
50
|
+
* <List comma line ender={<ifBreak>,</ifBreak>}>...</List>
|
|
51
|
+
* </group>
|
|
52
|
+
* ```
|
|
43
53
|
*/
|
|
44
54
|
enderPunctuation?: boolean;
|
|
45
55
|
}
|
|
@@ -60,16 +60,16 @@ export type MemberDeclarationProps =
|
|
|
60
60
|
*
|
|
61
61
|
* This component must be called in one of two ways: with a name and an optional
|
|
62
62
|
* refkey, or else passing in the symbol. When called with a name and refkey, a
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
* `BasicSymbol` will be created in the current member space. When called with a
|
|
64
|
+
* `name`, the owning scope must be a `BasicScope`; for custom scope/symbol
|
|
65
|
+
* types, pass a pre-created `symbol` instead.
|
|
66
66
|
*
|
|
67
67
|
* When called with a symbol, that symbol is merely exposed via
|
|
68
|
-
* {@link MemberDeclarationContext}
|
|
69
|
-
*
|
|
70
|
-
* {@link BinderContext}.
|
|
68
|
+
* {@link MemberDeclarationContext} (not {@link DeclarationContext}). Use
|
|
69
|
+
* {@link MemberName} (not `<Name />`) to render the declared member's name.
|
|
71
70
|
*
|
|
72
71
|
* @see {@link BinderContext}
|
|
72
|
+
* @see {@link MemberName}
|
|
73
73
|
*/
|
|
74
74
|
export function MemberDeclaration(props: MemberDeclarationProps) {
|
|
75
75
|
const binder = useContext(BinderContext);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { useContext } from "../context.js";
|
|
2
2
|
import { MemberDeclarationContext } from "../context/member-declaration.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Renders the name of the current member declaration from
|
|
6
|
+
* {@link MemberDeclarationContext}. Use this inside a
|
|
7
|
+
* {@link MemberDeclaration} component instead of `<Name />`, which reads from
|
|
8
|
+
* the top-level {@link DeclarationContext}.
|
|
9
|
+
*/
|
|
4
10
|
export function MemberName() {
|
|
5
11
|
const declSymbol = useContext(MemberDeclarationContext);
|
|
6
12
|
if (!declSymbol) {
|
|
@@ -56,6 +56,11 @@ export type MemberScopeProps =
|
|
|
56
56
|
* like. In some languages, this scope may provide symbols which are can be
|
|
57
57
|
* referenced lexically, but in other languages, these members may not be in
|
|
58
58
|
* scope and instead must be referenced via the owner symbol itself.
|
|
59
|
+
*
|
|
60
|
+
* When called with `name` (without `value`), this delegates to `<Scope>` which
|
|
61
|
+
* creates a `BasicScope`. The same restriction applies: the parent scope must
|
|
62
|
+
* be a `BasicScope`. For custom scope types, create your scope and pass it via
|
|
63
|
+
* the `value` prop.
|
|
59
64
|
*/
|
|
60
65
|
export function MemberScope(props: MemberScopeProps) {
|
|
61
66
|
if ("value" in props) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createOutputBinder,
|
|
3
3
|
getSymbolCreator,
|
|
4
|
+
NameConflictResolver,
|
|
4
5
|
SymbolCreator,
|
|
5
6
|
} from "../binder.js";
|
|
6
7
|
import { BinderContext } from "../context/binder.js";
|
|
@@ -28,8 +29,10 @@ export interface OutputProps extends PrintTreeOptions {
|
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Policy for handling multiple symbols declared with the same name.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link NameConflictResolver}
|
|
31
34
|
*/
|
|
32
|
-
nameConflictResolver?:
|
|
35
|
+
nameConflictResolver?: NameConflictResolver;
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
38
|
* The base path for the output contents. Defaults to "."
|
package/src/components/Scope.tsx
CHANGED
|
@@ -47,6 +47,12 @@ export type ScopeProps = ScopePropsWithValue | ScopePropsWithInfo;
|
|
|
47
47
|
* Declare a scope for this component's children. Any symbols and scopes
|
|
48
48
|
* declared in the children of this component will be in this scope.
|
|
49
49
|
*
|
|
50
|
+
* @remarks
|
|
51
|
+
*
|
|
52
|
+
* When called with `name` (without `value`), this creates a `BasicScope`. The
|
|
53
|
+
* parent scope must also be a `BasicScope`; for custom scope types, create your
|
|
54
|
+
* scope and pass it via the `value` prop instead.
|
|
55
|
+
*
|
|
50
56
|
* @see {@link ScopeContext}
|
|
51
57
|
*/
|
|
52
58
|
export function Scope(props: ScopeProps) {
|
|
@@ -17,6 +17,11 @@ export interface SourceFileProps extends PrintTreeOptions {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The type of contents in this file.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* This is a metadata hint only. It does not trigger formatting or content
|
|
23
|
+
* processing. The value is forwarded to debug tooling and the
|
|
24
|
+
* `ContentOutputFile` output metadata.
|
|
20
25
|
*/
|
|
21
26
|
filetype: string;
|
|
22
27
|
|
|
@@ -28,8 +33,23 @@ export interface SourceFileProps extends PrintTreeOptions {
|
|
|
28
33
|
*/
|
|
29
34
|
reference?: ComponentDefinition<{ refkey: Refkey }>;
|
|
30
35
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
36
|
+
* Content rendered before the file body, separated from it by a hard line
|
|
37
|
+
* break. The separator is emitted whenever `header` is not `undefined` —
|
|
38
|
+
* including when it is an empty string or a component that renders nothing.
|
|
39
|
+
* To suppress both the header and the separator, omit this prop entirely.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* // Omitting `header` suppresses both header and separator:
|
|
44
|
+
* <SourceFile filetype="txt" path="output/data.txt">
|
|
45
|
+
* {children}
|
|
46
|
+
* </SourceFile>
|
|
47
|
+
*
|
|
48
|
+
* // An empty string still emits the separator newline:
|
|
49
|
+
* <SourceFile filetype="txt" path="output/data.txt" header="">
|
|
50
|
+
* {children}
|
|
51
|
+
* </SourceFile>
|
|
52
|
+
* ```
|
|
33
53
|
*/
|
|
34
54
|
header?: Children;
|
|
35
55
|
}
|
package/src/context/binder.ts
CHANGED
|
@@ -14,6 +14,10 @@ import type { Output } from "../components/Output.js";
|
|
|
14
14
|
export const BinderContext: ComponentContext<Binder> =
|
|
15
15
|
createNamedContext("Binder");
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Returns the current {@link Binder} from context, or `undefined` if no
|
|
19
|
+
* binder is available. The binder is provided by the {@link Output} component.
|
|
20
|
+
*/
|
|
17
21
|
export function useBinder() {
|
|
18
22
|
return useContext(BinderContext);
|
|
19
23
|
}
|
|
@@ -3,10 +3,23 @@ import { PrintTreeOptions } from "../render.js";
|
|
|
3
3
|
|
|
4
4
|
export interface CommonFormatOptions extends PrintTreeOptions {}
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Base format options provider and consumer for all file types. Language
|
|
8
|
+
* packages create their own via {@link createFormatOptionsContextFor}.
|
|
9
|
+
*/
|
|
6
10
|
export const { Provider: FormatOptions, useFormatOptions } =
|
|
7
11
|
createFormatOptionsContextFor<CommonFormatOptions>("*");
|
|
8
12
|
|
|
9
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Create a format options context for a specific file type. Returns a
|
|
15
|
+
* `Provider` component and a `useFormatOptions` hook.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
*
|
|
19
|
+
* Merge precedence: `defaults` (lowest) → Provider `value` → `overrides`
|
|
20
|
+
* argument to `useFormatOptions()` (highest). Undefined override values are
|
|
21
|
+
* ignored.
|
|
22
|
+
*/
|
|
10
23
|
export function createFormatOptionsContextFor<T>(
|
|
11
24
|
filetype: string,
|
|
12
25
|
defaults?: T,
|
package/src/context/scope.ts
CHANGED
|
@@ -8,6 +8,10 @@ import type { OutputScope } from "../symbols/output-scope.js";
|
|
|
8
8
|
export const ScopeContext: ComponentContext<OutputScope> =
|
|
9
9
|
createNamedContext("Scope");
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Returns the current {@link OutputScope} from context. Must be called inside
|
|
13
|
+
* a component that is a descendant of a `<Scope>` provider.
|
|
14
|
+
*/
|
|
11
15
|
export function useScope() {
|
|
12
16
|
return useContext(ScopeContext)!;
|
|
13
17
|
}
|
|
@@ -9,5 +9,14 @@ export interface SourceDirectoryContext {
|
|
|
9
9
|
path: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Always provided by `<Output>` — `useContext(SourceDirectoryContext)` is
|
|
14
|
+
* never `undefined` inside an `<Output>` tree. At the root of the tree,
|
|
15
|
+
* `path` equals the `basePath` prop on `<Output>` (default `"./"`); nested
|
|
16
|
+
* `<SourceDirectory>` components update `path` relative to their parent.
|
|
17
|
+
*
|
|
18
|
+
* @see {@link Output}
|
|
19
|
+
* @see {@link SourceDirectory}
|
|
20
|
+
*/
|
|
12
21
|
export const SourceDirectoryContext: ComponentContext<SourceDirectoryContext> =
|
|
13
22
|
createNamedContext("SourceDirectory");
|
package/src/debug/cli.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Table from "cli-table3";
|
|
2
2
|
import pc from "picocolors";
|
|
3
3
|
import { contextsByKey } from "../context.js";
|
|
4
|
+
import { stdoutWrite } from "../host/node-host.js";
|
|
4
5
|
import { getContext, untrack } from "../reactivity.js";
|
|
5
6
|
import { isReactiveTarget } from "./effects.js";
|
|
6
7
|
|
|
@@ -143,7 +144,7 @@ export function debugStack() {
|
|
|
143
144
|
currentContext.componentOwner &&
|
|
144
145
|
currentContext.componentOwner.component.name !== "Provider"
|
|
145
146
|
) {
|
|
146
|
-
|
|
147
|
+
stdoutWrite(
|
|
147
148
|
style.component.name(currentContext.componentOwner.component.name) +
|
|
148
149
|
"\n",
|
|
149
150
|
);
|
|
@@ -164,7 +165,7 @@ export function debugStack() {
|
|
|
164
165
|
: pc.gray("(none)"),
|
|
165
166
|
]);
|
|
166
167
|
|
|
167
|
-
|
|
168
|
+
stdoutWrite(table.toString() + "\n\n");
|
|
168
169
|
foundContexts = [];
|
|
169
170
|
}
|
|
170
171
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser stub for source-map resolution.
|
|
3
|
+
*
|
|
4
|
+
* Source maps are not resolved in the browser — all functions pass through
|
|
5
|
+
* their inputs unchanged.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { SourceLocation } from "../devtools/devtools-protocol.js";
|
|
9
|
+
|
|
10
|
+
export function loadSourceMapSupport() {
|
|
11
|
+
// no-op in browser
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getRealPath(fileName: string): string {
|
|
15
|
+
return fileName;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function resolveSourceMap(
|
|
19
|
+
fileName: string,
|
|
20
|
+
line: number,
|
|
21
|
+
col: number,
|
|
22
|
+
): { fileName: string; line: number; col: number } {
|
|
23
|
+
return { fileName, line, col };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function resolveComponentSource(
|
|
27
|
+
source: SourceLocation | undefined,
|
|
28
|
+
): SourceLocation | undefined {
|
|
29
|
+
return source;
|
|
30
|
+
}
|