@alloy-js/typescript 0.19.0 → 0.20.0-dev.1
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/builtins/node.d.ts +1 -1
- package/dist/src/components/ArrowFunction.d.ts.map +1 -1
- package/dist/src/components/ArrowFunction.js +7 -13
- package/dist/src/components/BlockScope.d.ts.map +1 -1
- package/dist/src/components/BlockScope.js +3 -2
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +20 -30
- package/dist/src/components/Declaration.d.ts +2 -9
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +20 -43
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +5 -9
- package/dist/src/components/EnumMember.d.ts.map +1 -1
- package/dist/src/components/EnumMember.js +3 -4
- package/dist/src/components/ExportStatement.d.ts.map +1 -1
- package/dist/src/components/ExportStatement.js +2 -1
- package/dist/src/components/FunctionBase.d.ts.map +1 -1
- package/dist/src/components/FunctionBase.js +15 -12
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +3 -3
- package/dist/src/components/FunctionExpression.d.ts.map +1 -1
- package/dist/src/components/FunctionExpression.js +7 -13
- package/dist/src/components/FunctionType.d.ts.map +1 -1
- package/dist/src/components/FunctionType.js +3 -3
- package/dist/src/components/IfStatement.d.ts.map +1 -1
- package/dist/src/components/IfStatement.js +2 -1
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +3 -4
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +14 -13
- package/dist/src/components/InterfaceMethod.d.ts.map +1 -1
- package/dist/src/components/InterfaceMethod.js +4 -3
- package/dist/src/components/LexicalScope.d.ts +12 -0
- package/dist/src/components/LexicalScope.d.ts.map +1 -0
- package/dist/src/components/LexicalScope.js +24 -0
- package/dist/src/components/MemberDeclaration.d.ts +1 -10
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js +3 -7
- package/dist/src/components/MemberExpression.d.ts.map +1 -1
- package/dist/src/components/MemberExpression.js +13 -5
- package/dist/src/components/MemberScope.d.ts +15 -0
- package/dist/src/components/MemberScope.d.ts.map +1 -0
- package/dist/src/components/MemberScope.js +17 -0
- package/dist/src/components/NewExpression.d.ts.map +1 -1
- package/dist/src/components/NewExpression.js +5 -5
- package/dist/src/components/ObjectExpression.d.ts.map +1 -1
- package/dist/src/components/ObjectExpression.js +10 -14
- package/dist/src/components/PropertyName.js +1 -2
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +3 -2
- package/dist/src/components/VarDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.js +14 -26
- package/dist/src/context/index.d.ts +1 -1
- package/dist/src/context/index.d.ts.map +1 -1
- package/dist/src/context/index.js +1 -1
- package/dist/src/create-package.d.ts.map +1 -1
- package/dist/src/create-package.js +11 -33
- package/dist/src/symbols/index.d.ts +19 -0
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +72 -1
- package/dist/src/symbols/reference.d.ts +2 -2
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +68 -70
- package/dist/src/symbols/scopes.d.ts +5 -8
- package/dist/src/symbols/scopes.d.ts.map +1 -1
- package/dist/src/symbols/scopes.js +26 -0
- package/dist/src/symbols/ts-lexical-scope.d.ts +12 -0
- package/dist/src/symbols/ts-lexical-scope.d.ts.map +1 -0
- package/dist/src/symbols/ts-lexical-scope.js +16 -0
- package/dist/src/symbols/ts-member-scope.d.ts +12 -4
- package/dist/src/symbols/ts-member-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-member-scope.js +15 -6
- package/dist/src/symbols/ts-module-scope.d.ts +8 -3
- package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-module-scope.js +29 -18
- package/dist/src/symbols/ts-output-symbol.d.ts +19 -18
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js +60 -37
- package/dist/src/symbols/ts-package-scope.d.ts +1 -1
- package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-package-scope.js +4 -5
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +23 -1
- package/dist/test/class.test.js +4 -4
- package/dist/test/externals.test.js +2 -38
- package/dist/test/reference.test.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/components/ArrowFunction.tsx +7 -10
- package/src/components/BlockScope.tsx +3 -3
- package/src/components/ClassDeclaration.tsx +19 -44
- package/src/components/Declaration.tsx +22 -53
- package/src/components/EnumDeclaration.tsx +4 -11
- package/src/components/EnumMember.tsx +3 -3
- package/src/components/ExportStatement.tsx +2 -1
- package/src/components/FunctionBase.tsx +33 -28
- package/src/components/FunctionDeclaration.tsx +3 -3
- package/src/components/FunctionExpression.tsx +7 -10
- package/src/components/FunctionType.tsx +3 -3
- package/src/components/IfStatement.tsx +2 -1
- package/src/components/ImportStatement.tsx +4 -8
- package/src/components/Interface.tsx +15 -22
- package/src/components/InterfaceMethod.tsx +4 -4
- package/src/components/LexicalScope.tsx +27 -0
- package/src/components/MemberDeclaration.tsx +8 -20
- package/src/components/MemberExpression.tsx +25 -5
- package/src/components/MemberScope.tsx +29 -0
- package/src/components/NewExpression.tsx +4 -5
- package/src/components/ObjectExpression.tsx +11 -18
- package/src/components/PropertyName.tsx +2 -2
- package/src/components/SourceFile.tsx +3 -1
- package/src/components/VarDeclaration.tsx +14 -28
- package/src/context/index.ts +1 -1
- package/src/create-package.ts +10 -39
- package/src/symbols/index.ts +118 -0
- package/src/symbols/reference.tsx +163 -0
- package/src/symbols/scopes.ts +38 -13
- package/src/symbols/ts-lexical-scope.ts +18 -0
- package/src/symbols/ts-member-scope.ts +23 -6
- package/src/symbols/ts-module-scope.ts +31 -21
- package/src/symbols/ts-output-symbol.ts +111 -49
- package/src/symbols/ts-package-scope.ts +5 -5
- package/src/utils.ts +38 -1
- package/temp/api.json +1641 -713
- package/test/class.test.tsx +10 -4
- package/test/externals.test.tsx +1 -40
- package/test/reference.test.tsx +5 -5
- package/tsdoc-metadata.json +1 -1
- package/dist/src/context/private-scope.d.ts +0 -18
- package/dist/src/context/private-scope.d.ts.map +0 -1
- package/dist/src/context/private-scope.js +0 -8
- package/src/context/private-scope.ts +0 -23
- package/src/symbols/reference.ts +0 -197
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { computed, mapJoin, memo, SourceDirectoryContext, useContext } from "@alloy-js/core";
|
|
3
3
|
import { relative } from "pathe";
|
|
4
|
-
import { TSSymbolFlags } from "../symbols/index.js";
|
|
5
4
|
import { modulePath } from "../utils.js";
|
|
6
5
|
import { usePackage } from "./PackageDirectory.js";
|
|
7
6
|
export function ImportStatements(props) {
|
|
@@ -11,7 +10,7 @@ export function ImportStatements(props) {
|
|
|
11
10
|
}));
|
|
12
11
|
return mapJoin(() => imports.value, ([module, importedSymbols]) => {
|
|
13
12
|
let targetPath;
|
|
14
|
-
if (pkg
|
|
13
|
+
if (pkg?.scope !== module.parent) {
|
|
15
14
|
// importing from another package, so let's calculate the import.
|
|
16
15
|
const targetPackage = module.parent;
|
|
17
16
|
let foundPath = false;
|
|
@@ -64,7 +63,7 @@ export function ImportStatement(props) {
|
|
|
64
63
|
namedImportSymbols.sort((a, b) => {
|
|
65
64
|
return a.local.name.localeCompare(b.local.name);
|
|
66
65
|
});
|
|
67
|
-
const allNamedImportsAreTypes = namedImportSymbols.every(nis => nis.local.
|
|
66
|
+
const allNamedImportsAreTypes = namedImportSymbols.every(nis => nis.local.isTypeSymbol && !nis.local.isValueSymbol);
|
|
68
67
|
if (allNamedImportsAreTypes) {
|
|
69
68
|
parts.push("type ");
|
|
70
69
|
}
|
|
@@ -93,6 +92,6 @@ function ImportBinding(props) {
|
|
|
93
92
|
return `${targetName} as ${localName}`;
|
|
94
93
|
}
|
|
95
94
|
});
|
|
96
|
-
const prefix = memo(() => !props.inTypeImport && props.importedSymbol.local.
|
|
95
|
+
const prefix = memo(() => !props.inTypeImport && props.importedSymbol.local.isTypeSymbol && !props.importedSymbol.local.isValueSymbol ? "type " : "");
|
|
97
96
|
return [prefix, text];
|
|
98
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interface.d.ts","sourceRoot":"","sources":["../../../src/components/Interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,
|
|
1
|
+
{"version":3,"file":"Interface.d.ts","sourceRoot":"","sources":["../../../src/components/Interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAQR,MAAM,EAGP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AASrE,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,uBAAuB,EAAE,GAAG,MAAM,EAAE,CAAC;CACvD;AA+DD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,YAEpE;yBAFe,oBAAoB;;;AAMpC,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,+CAgB/B,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YAoD1D"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { Block, childrenArray, createSymbolSlot, effect, emitSymbol, findKeyedChild, findUnkeyedChildren,
|
|
2
|
+
import { Block, childrenArray, createSymbolSlot, effect, emitSymbol, findKeyedChild, findUnkeyedChildren, Name, Show, takeSymbols } from "@alloy-js/core";
|
|
3
3
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
4
4
|
import { Declaration } from "./Declaration.js";
|
|
5
5
|
import { JSDoc } from "./JSDoc.js";
|
|
6
|
+
import { useTSLexicalScope, useTSMemberScope } from "../symbols/scopes.js";
|
|
6
7
|
import { TSOutputSymbol, TSSymbolFlags } from "../symbols/ts-output-symbol.js";
|
|
7
8
|
import { TypeParameters } from "./FunctionBase.js";
|
|
8
9
|
import { MemberDeclaration } from "./MemberDeclaration.js";
|
|
10
|
+
import { MemberScope } from "./MemberScope.js";
|
|
9
11
|
import { PropertyName } from "./PropertyName.js";
|
|
10
12
|
import { ensureTypeRefContext } from "./TypeRefContext.js";
|
|
11
13
|
const _InterfaceDeclaration = ensureTypeRefContext(props => {
|
|
@@ -15,8 +17,8 @@ const _InterfaceDeclaration = ensureTypeRefContext(props => {
|
|
|
15
17
|
const takenSymbols = ExprSlot.ref.value;
|
|
16
18
|
for (const symbol of takenSymbols) {
|
|
17
19
|
// ignore non-transient symbols (likely not the result of an expression).
|
|
18
|
-
if (symbol.
|
|
19
|
-
symbol.
|
|
20
|
+
if (symbol.isTransient) {
|
|
21
|
+
symbol.moveMembersTo(sym);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
}
|
|
@@ -29,10 +31,10 @@ const _InterfaceDeclaration = ensureTypeRefContext(props => {
|
|
|
29
31
|
}
|
|
30
32
|
});
|
|
31
33
|
const extendsPart = props.extends ? [" extends ", _$memo(() => props.extends)] : "";
|
|
32
|
-
const flags = OutputSymbolFlags.StaticMemberContainer;
|
|
33
34
|
const name = useTSNamePolicy().getName(props.name, "interface");
|
|
34
35
|
const filteredChildren = findUnkeyedChildren(children);
|
|
35
|
-
const
|
|
36
|
+
const currentScope = useTSLexicalScope();
|
|
37
|
+
const sym = new TSOutputSymbol(name, currentScope.types, {
|
|
36
38
|
refkeys: props.refkey,
|
|
37
39
|
default: props.default,
|
|
38
40
|
export: props.export,
|
|
@@ -52,7 +54,6 @@ const _InterfaceDeclaration = ensureTypeRefContext(props => {
|
|
|
52
54
|
}
|
|
53
55
|
}), _$createComponent(Declaration, _$mergeProps(props, {
|
|
54
56
|
nameKind: "interface",
|
|
55
|
-
flags: flags,
|
|
56
57
|
kind: "type",
|
|
57
58
|
symbol: sym,
|
|
58
59
|
get children() {
|
|
@@ -81,14 +82,14 @@ export function InterfaceDeclaration(props) {
|
|
|
81
82
|
}
|
|
82
83
|
InterfaceDeclaration.TypeParameters = TypeParameters;
|
|
83
84
|
export const InterfaceExpression = ensureTypeRefContext(props => {
|
|
84
|
-
const symbol = new TSOutputSymbol("", {
|
|
85
|
-
|
|
85
|
+
const symbol = new TSOutputSymbol("", undefined, {
|
|
86
|
+
transient: true
|
|
86
87
|
});
|
|
87
88
|
emitSymbol(symbol);
|
|
88
89
|
return _$createIntrinsic("group", {
|
|
89
90
|
get children() {
|
|
90
91
|
return _$createComponent(MemberScope, {
|
|
91
|
-
|
|
92
|
+
ownerSymbol: symbol,
|
|
92
93
|
get children() {
|
|
93
94
|
return _$createComponent(Block, {
|
|
94
95
|
get children() {
|
|
@@ -120,17 +121,17 @@ export function InterfaceMember(props) {
|
|
|
120
121
|
const name = namer.getName(props.name, "interface-member");
|
|
121
122
|
let sym = undefined;
|
|
122
123
|
if (props.name) {
|
|
123
|
-
|
|
124
|
+
const scope = useTSMemberScope();
|
|
125
|
+
sym = new TSOutputSymbol(name, scope.ownerSymbol.staticMembers, {
|
|
124
126
|
refkeys: props.refkey,
|
|
125
|
-
flags: OutputSymbolFlags.StaticMember,
|
|
126
127
|
tsFlags: TSSymbolFlags.TypeSymbol | (props.nullish ?? props.optional ? TSSymbolFlags.Nullish : TSSymbolFlags.None)
|
|
127
128
|
});
|
|
128
129
|
const taken = takeSymbols();
|
|
129
130
|
effect(() => {
|
|
130
131
|
if (taken.size > 1) return;
|
|
131
132
|
const symbol = Array.from(taken)[0];
|
|
132
|
-
if (symbol?.
|
|
133
|
-
symbol.
|
|
133
|
+
if (symbol?.isTransient) {
|
|
134
|
+
symbol.moveMembersTo(sym);
|
|
134
135
|
}
|
|
135
136
|
});
|
|
136
137
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceMethod.d.ts","sourceRoot":"","sources":["../../../src/components/InterfaceMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"InterfaceMethod.d.ts","sourceRoot":"","sources":["../../../src/components/InterfaceMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,MAAM,EAEN,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAYxE,8DAA8D;AAC9D,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,qCAAqC;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;IACxB,kBAAkB;IAClB,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YAmC1D;yBAnCe,eAAe"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { childrenArray, findKeyedChild,
|
|
2
|
+
import { childrenArray, findKeyedChild, Prose, Show } from "@alloy-js/core";
|
|
3
3
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
4
4
|
import { getCallSignatureProps } from "../utils.js";
|
|
5
5
|
import { CallSignature } from "./CallSignature.js";
|
|
6
6
|
import { FunctionParameters, FunctionTypeParameters, getReturnType, TypeParameters } from "./FunctionBase.js";
|
|
7
7
|
import { JSDoc } from "./JSDoc.js";
|
|
8
8
|
import { JSDocParams } from "./JSDocParam.js";
|
|
9
|
+
import { LexicalScope } from "./LexicalScope.js";
|
|
10
|
+
import { MemberDeclaration } from "./MemberDeclaration.js";
|
|
9
11
|
|
|
10
12
|
/** Props for {@link (InterfaceMethod:namespace)} component */
|
|
11
13
|
|
|
@@ -69,11 +71,10 @@ export function InterfaceMethod(props) {
|
|
|
69
71
|
return props.refkey;
|
|
70
72
|
},
|
|
71
73
|
get children() {
|
|
72
|
-
return [name, _$createComponent(
|
|
74
|
+
return [name, _$createComponent(LexicalScope, {
|
|
73
75
|
get name() {
|
|
74
76
|
return props.name;
|
|
75
77
|
},
|
|
76
|
-
kind: "function",
|
|
77
78
|
get children() {
|
|
78
79
|
return _$createComponent(CallSignature, _$mergeProps(callSignatureProps, {
|
|
79
80
|
returnType: returnType
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ScopePropsWithInfo, ScopePropsWithValue } from "@alloy-js/core";
|
|
2
|
+
export interface LexicalScopePropsWithScopeValue extends ScopePropsWithValue {
|
|
3
|
+
}
|
|
4
|
+
export interface LeixcalScopePropsWithScopeInfo extends ScopePropsWithInfo {
|
|
5
|
+
}
|
|
6
|
+
export type LexicalScopeProps = LexicalScopePropsWithScopeValue | LeixcalScopePropsWithScopeInfo;
|
|
7
|
+
/**
|
|
8
|
+
* A lexical scope for TypeScript, which contains declaration spaces for types
|
|
9
|
+
* and values. Declaration components will create symbols in this scope.
|
|
10
|
+
*/
|
|
11
|
+
export declare function LexicalScope(props: LexicalScopeProps): import("@alloy-js/core").Children;
|
|
12
|
+
//# sourceMappingURL=LexicalScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LexicalScope.d.ts","sourceRoot":"","sources":["../../../src/components/LexicalScope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGhF,MAAM,WAAW,+BAAgC,SAAQ,mBAAmB;CAAG;AAC/E,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;CAAG;AAE7E,MAAM,MAAM,iBAAiB,GACzB,+BAA+B,GAC/B,8BAA8B,CAAC;AAEnC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qCAYpD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Scope } from "@alloy-js/core";
|
|
3
|
+
import { createLexicalScope, TSLexicalScope } from "../symbols/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* A lexical scope for TypeScript, which contains declaration spaces for types
|
|
6
|
+
* and values. Declaration components will create symbols in this scope.
|
|
7
|
+
*/
|
|
8
|
+
export function LexicalScope(props) {
|
|
9
|
+
let scope;
|
|
10
|
+
if ("value" in props) {
|
|
11
|
+
if (!(props.value instanceof TSLexicalScope)) {
|
|
12
|
+
throw new Error("LexicalScope value must be a TSLexicalScope instance");
|
|
13
|
+
}
|
|
14
|
+
scope = props.value;
|
|
15
|
+
} else {
|
|
16
|
+
scope = createLexicalScope(props.name ?? "Lexical scope", props);
|
|
17
|
+
}
|
|
18
|
+
return _$createComponent(Scope, {
|
|
19
|
+
value: scope,
|
|
20
|
+
get children() {
|
|
21
|
+
return props.children;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MemberDeclarationPropsWithInfo
|
|
1
|
+
import { MemberDeclarationPropsWithInfo } from "@alloy-js/core";
|
|
2
2
|
import { TypeScriptElements } from "../name-policy.js";
|
|
3
3
|
import { TSOutputSymbol } from "../symbols/index.js";
|
|
4
4
|
export interface MemberDeclarationProps extends Omit<MemberDeclarationPropsWithInfo, "name"> {
|
|
@@ -8,19 +8,10 @@ export interface MemberDeclarationProps extends Omit<MemberDeclarationPropsWithI
|
|
|
8
8
|
name?: string;
|
|
9
9
|
/** Name that shouldn't go through the name policy resolver again. */
|
|
10
10
|
exactName?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Whether this is a memberdeclaration of a type (e.g. interface, type alias) or a
|
|
13
|
-
* value (e.g. var, const, let).
|
|
14
|
-
*/
|
|
15
|
-
kind?: "type" | "value";
|
|
16
11
|
/**
|
|
17
12
|
* The name policy kind to apply to the memberdeclaration.
|
|
18
13
|
*/
|
|
19
14
|
nameKind?: TypeScriptElements;
|
|
20
|
-
/**
|
|
21
|
-
* Flags for the symbol created by this component.
|
|
22
|
-
*/
|
|
23
|
-
flags?: OutputSymbolFlags;
|
|
24
15
|
/**
|
|
25
16
|
* The symbol to use for this memberdeclaration.
|
|
26
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemberDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/MemberDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,8BAA8B,
|
|
1
|
+
{"version":3,"file":"MemberDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/MemberDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,8BAA8B,EAC/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAEL,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,8BAA8B,EAAE,MAAM,CAAC;IACpD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAE9B;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,qCAwBxE"}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { MemberDeclaration as CoreMemberDeclaration } from "@alloy-js/core";
|
|
3
3
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
4
|
-
import {
|
|
4
|
+
import { createStaticMemberSymbol, TSSymbolFlags } from "../symbols/index.js";
|
|
5
5
|
export function MemberDeclaration(props) {
|
|
6
6
|
let sym;
|
|
7
7
|
if (props.symbol) {
|
|
8
8
|
sym = props.symbol;
|
|
9
9
|
} else {
|
|
10
10
|
const namePolicy = useTSNamePolicy();
|
|
11
|
-
|
|
12
|
-
if (props.kind === "type") {
|
|
13
|
-
tsFlags |= TSSymbolFlags.TypeSymbol;
|
|
14
|
-
}
|
|
11
|
+
const tsFlags = props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None;
|
|
15
12
|
const name = props.exactName ?? namePolicy.getName(props.name, props.nameKind);
|
|
16
|
-
sym =
|
|
13
|
+
sym = createStaticMemberSymbol(name, {
|
|
17
14
|
refkeys: props.refkey,
|
|
18
|
-
flags: props.flags,
|
|
19
15
|
tsFlags,
|
|
20
16
|
metadata: props.metadata
|
|
21
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemberExpression.d.ts","sourceRoot":"","sources":["../../../src/components/MemberExpression.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKR,YAAY,EAGZ,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"MemberExpression.d.ts","sourceRoot":"","sources":["../../../src/components/MemberExpression.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKR,YAAY,EAGZ,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,QAAQ,CA6BvE;yBA7Be,gBAAgB;sBA6dS,yBAAyB;;AA5DlE,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAErB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE5B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB"}
|
|
@@ -162,7 +162,13 @@ function createPartDescriptorFromProps(partProps, first) {
|
|
|
162
162
|
}
|
|
163
163
|
return false;
|
|
164
164
|
}),
|
|
165
|
-
args: ref(partProps.args === true ? [] : partProps.args)
|
|
165
|
+
args: ref(partProps.args === true ? [] : partProps.args),
|
|
166
|
+
jsPrivate: computed(() => {
|
|
167
|
+
return !!symbolSource.value && symbolSource.value.isPrivateMemberSymbol;
|
|
168
|
+
}),
|
|
169
|
+
type: computed(() => {
|
|
170
|
+
return !!symbolSource.value && symbolSource.value.isTypeSymbol;
|
|
171
|
+
})
|
|
166
172
|
};
|
|
167
173
|
return reactive(part);
|
|
168
174
|
}
|
|
@@ -292,7 +298,9 @@ function formatNonCallChain(parts) {
|
|
|
292
298
|
} else {
|
|
293
299
|
// Determine if we should use nullish operator from previous part
|
|
294
300
|
const prevPart = parts[i - 1];
|
|
295
|
-
if (
|
|
301
|
+
if (prevPart.type) {
|
|
302
|
+
expression.push(formatArrayAccess(prevPart, part));
|
|
303
|
+
} else if (part.args !== undefined) {
|
|
296
304
|
// For parts with only args (no name), append function call directly with appropriate nullish operator
|
|
297
305
|
expression.push(formatCallExpr(prevPart, part));
|
|
298
306
|
} else if (part.accessStyle === "dot") {
|
|
@@ -309,9 +317,9 @@ function formatNonCallChain(parts) {
|
|
|
309
317
|
function formatArrayAccess(prevPart, part) {
|
|
310
318
|
return _$createIntrinsic("group", {
|
|
311
319
|
get children() {
|
|
312
|
-
return [_$memo(() => prevPart.nullish ? "?." : ""), "[", _$createIntrinsic("indent", {
|
|
320
|
+
return [_$memo(() => !prevPart.type && prevPart.nullish ? "?." : ""), "[", _$createIntrinsic("indent", {
|
|
313
321
|
get children() {
|
|
314
|
-
return [_$createIntrinsic("sbr", {}), _$memo(() => part.quoteId && '"'), _$memo(() => isIdPartDescriptor(part) ? part.id : part.index), _$memo(() => part.quoteId && '"')];
|
|
322
|
+
return [_$createIntrinsic("sbr", {}), _$memo(() => (prevPart.type || part.quoteId) && '"'), _$memo(() => isIdPartDescriptor(part) ? part.id : part.index), _$memo(() => (prevPart.type || part.quoteId) && '"')];
|
|
315
323
|
}
|
|
316
324
|
}), _$createIntrinsic("sbr", {}), "]"];
|
|
317
325
|
}
|
|
@@ -322,7 +330,7 @@ function formatDotAccess(prevPart, part) {
|
|
|
322
330
|
get children() {
|
|
323
331
|
return _$createIntrinsic("indent", {
|
|
324
332
|
get children() {
|
|
325
|
-
return [_$createIntrinsic("sbr", {}), _$memo(() => prevPart.nullish ? "?." : "."), _$memo(() => isIdPartDescriptor(part) ? part.id : part.index)];
|
|
333
|
+
return [_$createIntrinsic("sbr", {}), _$memo(() => prevPart.nullish ? "?." : "."), _$memo(() => isIdPartDescriptor(part) ? part.jsPrivate ? `#${part.id}` : part.id : part.index)];
|
|
326
334
|
}
|
|
327
335
|
});
|
|
328
336
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
|
+
import { TSOutputSymbol } from "../symbols/ts-output-symbol.js";
|
|
3
|
+
export interface MemberScopeProps {
|
|
4
|
+
children: Children;
|
|
5
|
+
/**
|
|
6
|
+
* The symbol that this member scope will create member symbols on.
|
|
7
|
+
*/
|
|
8
|
+
ownerSymbol: TSOutputSymbol;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A member scope for TypeScript. Member declarations will create symbols
|
|
12
|
+
* in this scope, which will be added to the owner symbol's members.
|
|
13
|
+
*/
|
|
14
|
+
export declare function MemberScope(props: MemberScopeProps): Children;
|
|
15
|
+
//# sourceMappingURL=MemberScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemberScope.d.ts","sourceRoot":"","sources":["../../../src/components/MemberScope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkC,MAAM,gBAAgB,CAAC;AAG1E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,WAAW,EAAE,cAAc,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAUlD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { MemberScope as CoreMemberScope } from "@alloy-js/core";
|
|
3
|
+
import { useTSLexicalScopeIfPresent } from "../symbols/scopes.js";
|
|
4
|
+
import { TSMemberScope } from "../symbols/ts-member-scope.js";
|
|
5
|
+
/**
|
|
6
|
+
* A member scope for TypeScript. Member declarations will create symbols
|
|
7
|
+
* in this scope, which will be added to the owner symbol's members.
|
|
8
|
+
*/
|
|
9
|
+
export function MemberScope(props) {
|
|
10
|
+
const memberScope = new TSMemberScope("member-scope", useTSLexicalScopeIfPresent(), props.ownerSymbol);
|
|
11
|
+
return _$createComponent(CoreMemberScope, {
|
|
12
|
+
value: memberScope,
|
|
13
|
+
get children() {
|
|
14
|
+
return props.children;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NewExpression.d.ts","sourceRoot":"","sources":["../../../src/components/NewExpression.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NewExpression.d.ts","sourceRoot":"","sources":["../../../src/components/NewExpression.tsx"],"names":[],"mappings":"AAKA,OAAO,EAEL,2BAA2B,EAC5B,MAAM,8BAA8B,CAAC;AAEtC,MAAM,WAAW,kBAAmB,SAAQ,2BAA2B;CAAG;AAE1E,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,qCAWtD"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { emitSymbol, instantiateTakenMembersTo as instantiateTakenSymbolsTo
|
|
3
|
-
import {
|
|
2
|
+
import { emitSymbol, instantiateTakenMembersTo as instantiateTakenSymbolsTo } from "@alloy-js/core";
|
|
3
|
+
import { createValueSymbol } from "../symbols/index.js";
|
|
4
4
|
import { FunctionCallExpression } from "./FunctionCallExpression.js";
|
|
5
5
|
export function NewExpression(props) {
|
|
6
|
-
const sym =
|
|
7
|
-
|
|
6
|
+
const sym = createValueSymbol("", {
|
|
7
|
+
transient: true
|
|
8
8
|
});
|
|
9
|
-
instantiateTakenSymbolsTo(sym);
|
|
9
|
+
instantiateTakenSymbolsTo(sym, "static", "instance");
|
|
10
10
|
emitSymbol(sym);
|
|
11
11
|
return ["new ", _$createComponent(FunctionCallExpression, props)];
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectExpression.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectExpression.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ObjectExpression.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectExpression.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAMR,MAAM,EAGP,MAAM,gBAAgB,CAAC;AAUxB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EACJ,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACnB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YAqD5D;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YAyCxD;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,YAYpE"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Block, computed, emitSymbol, For, Match, moveTakenMembersTo, Switch, takeSymbols } from "@alloy-js/core";
|
|
3
3
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
4
|
-
import {
|
|
4
|
+
import { createStaticMemberSymbol, createTransientValueSymbol } from "../symbols/index.js";
|
|
5
|
+
import { MemberScope } from "./MemberScope.js";
|
|
5
6
|
import { PropertyName } from "./PropertyName.js";
|
|
6
7
|
import { ValueExpression } from "./ValueExpression.js";
|
|
7
8
|
export function ObjectExpression(props) {
|
|
8
|
-
const symbol =
|
|
9
|
-
flags: OutputSymbolFlags.StaticMemberContainer | OutputSymbolFlags.Transient
|
|
10
|
-
});
|
|
9
|
+
const symbol = createTransientValueSymbol();
|
|
11
10
|
emitSymbol(symbol);
|
|
11
|
+
moveTakenMembersTo(symbol);
|
|
12
12
|
const jsValueProperties = computed(() => {
|
|
13
13
|
const jsValue = props.jsValue;
|
|
14
14
|
let properties;
|
|
@@ -36,7 +36,7 @@ export function ObjectExpression(props) {
|
|
|
36
36
|
return _$createIntrinsic("group", {
|
|
37
37
|
get children() {
|
|
38
38
|
return _$createComponent(MemberScope, {
|
|
39
|
-
|
|
39
|
+
ownerSymbol: symbol,
|
|
40
40
|
get children() {
|
|
41
41
|
return _$createComponent(Block, {
|
|
42
42
|
get children() {
|
|
@@ -77,11 +77,11 @@ export function ObjectProperty(props) {
|
|
|
77
77
|
}
|
|
78
78
|
let sym = undefined;
|
|
79
79
|
if (props.refkey && props.name) {
|
|
80
|
-
sym =
|
|
81
|
-
refkeys: props.refkey
|
|
82
|
-
flags: OutputSymbolFlags.StaticMember
|
|
80
|
+
sym = createStaticMemberSymbol(symbolName, {
|
|
81
|
+
refkeys: props.refkey
|
|
83
82
|
});
|
|
84
83
|
moveTakenMembersTo(sym);
|
|
84
|
+
emitSymbol(sym);
|
|
85
85
|
} else {
|
|
86
86
|
// noop
|
|
87
87
|
takeSymbols();
|
|
@@ -99,11 +99,7 @@ export function ObjectProperty(props) {
|
|
|
99
99
|
} else if (props.children) {
|
|
100
100
|
value = props.children;
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
return [name, ":", " ", _$createComponent(AssignmentContext.Provider, {
|
|
104
|
-
value: assignmentContext,
|
|
105
|
-
children: value
|
|
106
|
-
})];
|
|
102
|
+
return [name, ": ", value];
|
|
107
103
|
}
|
|
108
104
|
export function ObjectSpreadProperty(props) {
|
|
109
105
|
let value;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { MemberDeclarationContext, useContext } from "@alloy-js/core";
|
|
3
|
-
import { TSSymbolFlags } from "../symbols/ts-output-symbol.js";
|
|
4
3
|
import { isValidJSIdentifier } from "../utils.js";
|
|
5
4
|
/**
|
|
6
5
|
* A TypeScript property name for an interface, class, or object member. If the
|
|
@@ -19,7 +18,7 @@ export function PropertyName(props) {
|
|
|
19
18
|
if (!declSymbol) {
|
|
20
19
|
return "(no member declaration context)";
|
|
21
20
|
}
|
|
22
|
-
if (declSymbol.
|
|
21
|
+
if (declSymbol.isPrivateMemberSymbol) {
|
|
23
22
|
return ["#", _$memo(() => declSymbol.name)];
|
|
24
23
|
} else {
|
|
25
24
|
return [_$memo(() => quoteIfNeeded(declSymbol.name))];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAQhB,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKpD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB,CACX,CAAC;AAExD,wBAAgB,aAAa,sBAE5B;AACD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC3B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAmDhD;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { SourceFile as CoreSourceFile, createNamedContext, Scope, Show, SourceDirectoryContext, useContext } from "@alloy-js/core";
|
|
2
|
+
import { SourceFile as CoreSourceFile, createNamedContext, Scope, Show, SourceDirectoryContext, useContext, useScope } from "@alloy-js/core";
|
|
3
3
|
import { join } from "pathe";
|
|
4
4
|
import { getSourceDirectoryData } from "../source-directory-data.js";
|
|
5
5
|
import { TSModuleScope } from "../symbols/index.js";
|
|
@@ -16,7 +16,8 @@ export function SourceFile(props) {
|
|
|
16
16
|
const sdData = getSourceDirectoryData(directoryContext);
|
|
17
17
|
const currentDir = directoryContext.path;
|
|
18
18
|
const path = join(currentDir, props.path);
|
|
19
|
-
const
|
|
19
|
+
const parent = useScope();
|
|
20
|
+
const scope = new TSModuleScope(path, parent);
|
|
20
21
|
sdData.modules.add(scope);
|
|
21
22
|
const pkg = useContext(PackageContext);
|
|
22
23
|
if (pkg) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VarDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/VarDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"VarDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/VarDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKT,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAIxD,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YA6CxD"}
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { Declaration as CoreDeclaration, createSymbolSlot,
|
|
2
|
+
import { Declaration as CoreDeclaration, createSymbolSlot, Name, Show } from "@alloy-js/core";
|
|
3
3
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
4
|
-
import {
|
|
4
|
+
import { createValueSymbol } from "../symbols/index.js";
|
|
5
|
+
import { TSSymbolFlags } from "../symbols/ts-output-symbol.js";
|
|
5
6
|
import { JSDoc } from "./JSDoc.js";
|
|
6
7
|
import { TypeRefContext } from "./TypeRefContext.js";
|
|
7
8
|
export function VarDeclaration(props) {
|
|
8
9
|
const TypeSymbolSlot = createSymbolSlot();
|
|
9
10
|
const ValueTypeSymbolSlot = createSymbolSlot();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
for (const symbol of takenSymbols) {
|
|
19
|
-
// ignore non-transient symbols (likely not the result of an
|
|
20
|
-
// expression).
|
|
21
|
-
if (symbol.flags & OutputSymbolFlags.Transient) {
|
|
22
|
-
symbol.moveTo(sym);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
11
|
+
const name = useTSNamePolicy().getName(props.name, "variable");
|
|
12
|
+
const sym = createValueSymbol(name, {
|
|
13
|
+
refkeys: props.refkey,
|
|
14
|
+
default: props.default,
|
|
15
|
+
export: props.export,
|
|
16
|
+
metadata: props.metadata,
|
|
17
|
+
tsFlags: props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None,
|
|
18
|
+
type: props.type ? TypeSymbolSlot.firstSymbol : undefined
|
|
26
19
|
});
|
|
20
|
+
if (!props.type) {
|
|
21
|
+
ValueTypeSymbolSlot.moveMembersTo(sym);
|
|
22
|
+
}
|
|
27
23
|
const keyword = props.var ? "var" : props.let ? "let" : "const";
|
|
28
24
|
const type = props.type ? _$createComponent(TypeRefContext, {
|
|
29
25
|
get children() {
|
|
@@ -34,14 +30,6 @@ export function VarDeclaration(props) {
|
|
|
34
30
|
})];
|
|
35
31
|
}
|
|
36
32
|
}) : undefined;
|
|
37
|
-
const name = useTSNamePolicy().getName(props.name, "variable");
|
|
38
|
-
const sym = new TSOutputSymbol(name, {
|
|
39
|
-
refkeys: props.refkey,
|
|
40
|
-
default: props.default,
|
|
41
|
-
export: props.export,
|
|
42
|
-
metadata: props.metadata,
|
|
43
|
-
tsFlags: props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None
|
|
44
|
-
});
|
|
45
33
|
return [_$createComponent(Show, {
|
|
46
34
|
get when() {
|
|
47
35
|
return Boolean(props.doc);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
// type ref context isn't exported because it conflicts with the component of the same name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-package.d.ts","sourceRoot":"","sources":["../../src/create-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,MAAM,EAEX,aAAa,EACd,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-package.d.ts","sourceRoot":"","sources":["../../src/create-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,MAAM,EAEX,aAAa,EACd,MAAM,gBAAgB,CAAC;AAOxB,MAAM,WAAW,iBAAiB;IAChC,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAAC;CACzC;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAC7B,MAAM,GACN;IACE,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC7C,eAAe,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;CAChD,CAAC;AAEN;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,iBAAiB;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,CACvB,CAAC,SAAS;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAA;CAAE,IAC7D,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,EAAE,CAAC,GAC5D,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,qBAAqB,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;AAE3E,MAAM,MAAM,cAAc,CACxB,EAAE,SAAS,MAAM,CACf,MAAM,EACN;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAA;CAAE,CACtD,IAEC,aAAa,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG;KAG1B,CAAC,IAAI,MAAM,EAAE,IAAI,CAAC,SAAS,GAAG,GAAG,KAAK,GAAG,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CACnE,CAAC;AAUF,MAAM,MAAM,QAAQ,CAAC,WAAW,SAAS,SAAS,qBAAqB,EAAE,IAEvE;KACG,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM;CACpD,GAAG;KAED,CAAC,IAAI,OAAO,CACX,WAAW,CAAC,MAAM,CAAC,EACnB;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CACjB,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG;QACxB,MAAM,EAAE,CAAC,SAAS,CAChB;YAAE,aAAa,EAAE,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAA;SAAE,CAC5D,GACC,QAAQ,CAAC,EAAE,CAAC,GACZ,EAAE,CAAC;QACL,QAAQ,EAAE,CAAC,SAAS,CAClB;YAAE,eAAe,EAAE,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAA;SAAE,CAC9D,GACC,QAAQ,CAAC,EAAE,CAAC,GACZ,EAAE,CAAC;KACN;CACF,CAAC;AA8IJ,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,iBAAiB,EAC7D,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC3B,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CA6DnC"}
|