@alloy-js/typescript 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/src/components/ArrayExpression.d.ts +1 -1
- package/dist/src/components/ArrayExpression.d.ts.map +1 -1
- package/dist/src/components/ArrayExpression.js +18 -28
- package/dist/src/components/ArrayExpression.js.map +1 -1
- package/dist/src/components/BarrelFile.d.ts.map +1 -1
- package/dist/src/components/BarrelFile.js +11 -9
- package/dist/src/components/BarrelFile.js.map +1 -1
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +8 -9
- package/dist/src/components/ClassDeclaration.js.map +1 -1
- package/dist/src/components/CommaList.d.ts +12 -0
- package/dist/src/components/CommaList.d.ts.map +1 -0
- package/dist/src/components/CommaList.js +19 -0
- package/dist/src/components/CommaList.js.map +1 -0
- package/dist/src/components/Declaration.d.ts +4 -0
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +3 -2
- package/dist/src/components/Declaration.js.map +1 -1
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +21 -18
- package/dist/src/components/EnumDeclaration.js.map +1 -1
- package/dist/src/components/EnumMember.d.ts.map +1 -1
- package/dist/src/components/EnumMember.js.map +1 -1
- package/dist/src/components/ExportStatement.d.ts.map +1 -1
- package/dist/src/components/ExportStatement.js +3 -1
- package/dist/src/components/ExportStatement.js.map +1 -1
- package/dist/src/components/FunctionCallExpression.d.ts +2 -2
- package/dist/src/components/FunctionCallExpression.d.ts.map +1 -1
- package/dist/src/components/FunctionCallExpression.js +26 -9
- package/dist/src/components/FunctionCallExpression.js.map +1 -1
- package/dist/src/components/FunctionDeclaration.d.ts +10 -2
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +136 -33
- package/dist/src/components/FunctionDeclaration.js.map +1 -1
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +25 -31
- package/dist/src/components/ImportStatement.js.map +1 -1
- package/dist/src/components/Interface.d.ts +1 -1
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +5 -5
- package/dist/src/components/Interface.js.map +1 -1
- package/dist/src/components/JSDoc.d.ts +10 -0
- package/dist/src/components/JSDoc.d.ts.map +1 -0
- package/dist/src/components/JSDoc.js +24 -0
- package/dist/src/components/JSDoc.js.map +1 -0
- package/dist/src/components/JSDocComment.d.ts +11 -0
- package/dist/src/components/JSDocComment.d.ts.map +1 -0
- package/dist/src/components/JSDocComment.js +16 -0
- package/dist/src/components/JSDocComment.js.map +1 -0
- package/dist/src/components/JSDocExample.d.ts +12 -0
- package/dist/src/components/JSDocExample.d.ts.map +1 -0
- package/dist/src/components/JSDocExample.js +26 -0
- package/dist/src/components/JSDocExample.js.map +1 -0
- package/dist/src/components/JSDocParagraph.d.ts +10 -0
- package/dist/src/components/JSDocParagraph.d.ts.map +1 -0
- package/dist/src/components/JSDocParagraph.js +23 -0
- package/dist/src/components/JSDocParagraph.js.map +1 -0
- package/dist/src/components/MemberChainExpression.d.ts +11 -0
- package/dist/src/components/MemberChainExpression.d.ts.map +1 -0
- package/dist/src/components/MemberChainExpression.js +100 -0
- package/dist/src/components/MemberChainExpression.js.map +1 -0
- package/dist/src/components/ObjectExpression.d.ts +1 -1
- package/dist/src/components/ObjectExpression.d.ts.map +1 -1
- package/dist/src/components/ObjectExpression.js +45 -42
- package/dist/src/components/ObjectExpression.js.map +1 -1
- package/dist/src/components/PackageDirectory.d.ts +1 -3
- package/dist/src/components/PackageDirectory.d.ts.map +1 -1
- package/dist/src/components/PackageDirectory.js +9 -16
- package/dist/src/components/PackageDirectory.js.map +1 -1
- package/dist/src/components/PackageJson.d.ts +39 -0
- package/dist/src/components/PackageJson.d.ts.map +1 -1
- package/dist/src/components/PackageJson.js +30 -12
- package/dist/src/components/PackageJson.js.map +1 -1
- package/dist/src/components/Reference.js +1 -1
- package/dist/src/components/Reference.js.map +1 -1
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +13 -6
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/TsConfigJson.d.ts.map +1 -1
- package/dist/src/components/TsConfigJson.js.map +1 -1
- package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
- package/dist/src/components/TypeDeclaration.js.map +1 -1
- package/dist/src/components/ValueExpression.d.ts.map +1 -1
- package/dist/src/components/ValueExpression.js.map +1 -1
- package/dist/src/components/VarDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.js +5 -4
- package/dist/src/components/VarDeclaration.js.map +1 -1
- package/dist/src/components/index.d.ts +2 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +2 -1
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/stc/index.d.ts +21 -21
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +1 -1
- package/dist/src/components/stc/index.js.map +1 -1
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +5 -2
- package/dist/src/symbols/reference.js.map +1 -1
- package/dist/src/symbols/ts-output-symbol.d.ts +2 -1
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js +4 -1
- package/dist/src/symbols/ts-output-symbol.js.map +1 -1
- package/dist/src/symbols/ts-package-scope.d.ts +0 -15
- package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-package-scope.js +0 -8
- package/dist/src/symbols/ts-package-scope.js.map +1 -1
- package/dist/test/imports.test.d.ts.map +1 -1
- package/dist/test/jsdoc.test.d.ts +2 -0
- package/dist/test/jsdoc.test.d.ts.map +1 -0
- package/dist/test/member-chain.test.d.ts +2 -0
- package/dist/test/member-chain.test.d.ts.map +1 -0
- package/dist/test/utils.d.ts +2 -2
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/values.test.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -5
- package/src/components/ArrayExpression.tsx +22 -32
- package/src/components/BarrelFile.tsx +7 -13
- package/src/components/ClassDeclaration.tsx +33 -28
- package/src/components/CommaList.tsx +23 -0
- package/src/components/Declaration.tsx +14 -5
- package/src/components/EnumDeclaration.tsx +23 -16
- package/src/components/EnumMember.tsx +7 -4
- package/src/components/ExportStatement.tsx +9 -2
- package/src/components/FunctionCallExpression.tsx +18 -9
- package/src/components/FunctionDeclaration.tsx +173 -56
- package/src/components/ImportStatement.tsx +6 -9
- package/src/components/Interface.tsx +20 -13
- package/src/components/JSDoc.tsx +28 -0
- package/src/components/JSDocComment.tsx +23 -0
- package/src/components/JSDocExample.tsx +30 -0
- package/src/components/JSDocParagraph.tsx +35 -0
- package/src/components/MemberChainExpression.tsx +91 -0
- package/src/components/ObjectExpression.tsx +53 -48
- package/src/components/PackageDirectory.tsx +22 -30
- package/src/components/PackageJson.tsx +91 -29
- package/src/components/SourceFile.tsx +15 -8
- package/src/components/TsConfigJson.tsx +5 -3
- package/src/components/TypeDeclaration.tsx +5 -3
- package/src/components/ValueExpression.tsx +3 -1
- package/src/components/VarDeclaration.tsx +13 -7
- package/src/components/index.ts +2 -1
- package/src/components/stc/index.ts +1 -1
- package/src/symbols/reference.ts +7 -4
- package/src/symbols/ts-output-symbol.ts +6 -2
- package/src/symbols/ts-package-scope.ts +0 -28
- package/temp/api.json +802 -395
- package/test/array.test.tsx +40 -7
- package/test/basic.test.tsx +26 -21
- package/test/class.test.tsx +65 -53
- package/test/enum.test.tsx +18 -13
- package/test/externals.test.tsx +6 -7
- package/test/function-call-expression.test.tsx +39 -17
- package/test/function-declaration.test.tsx +96 -78
- package/test/imports.test.tsx +115 -75
- package/test/interface.test.tsx +32 -22
- package/test/jsdoc.test.tsx +154 -0
- package/test/member-chain.test.tsx +124 -0
- package/test/name-policy.test.tsx +33 -26
- package/test/package-external.test.tsx +106 -7
- package/test/package.test.tsx +57 -5
- package/test/reference.test.tsx +2 -6
- package/test/utils.tsx +3 -1
- package/test/value-expression.test.tsx +2 -6
- package/test/values.test.tsx +67 -73
- package/test/var-declaration.test.tsx +11 -5
- package/test/vitest.d.ts +6 -1
- package/tsconfig.json +8 -1
- package/dist/src/components/Block.d.ts +0 -6
- package/dist/src/components/Block.d.ts.map +0 -1
- package/dist/src/components/Block.js +0 -11
- package/dist/src/components/Block.js.map +0 -1
- package/src/components/Block.tsx +0 -12
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alloy-js/typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
|
-
"development": "./src/index.ts",
|
|
8
7
|
"import": "./dist/src/index.js"
|
|
9
8
|
},
|
|
10
9
|
"./stc": {
|
|
11
|
-
"development": "./src/components/stc/index.ts",
|
|
12
10
|
"import": "./dist/src/components/stc/index.js"
|
|
13
11
|
}
|
|
14
12
|
},
|
|
@@ -18,7 +16,7 @@
|
|
|
18
16
|
"dependencies": {
|
|
19
17
|
"change-case": "^5.4.4",
|
|
20
18
|
"pathe": "^1.1.2",
|
|
21
|
-
"@alloy-js/core": "~0.
|
|
19
|
+
"@alloy-js/core": "~0.7.0"
|
|
22
20
|
},
|
|
23
21
|
"devDependencies": {
|
|
24
22
|
"@babel/cli": "^7.24.7",
|
|
@@ -29,7 +27,7 @@
|
|
|
29
27
|
"concurrently": "^8.2.2",
|
|
30
28
|
"typescript": "^5.7.3",
|
|
31
29
|
"vitest": "^3.0.4",
|
|
32
|
-
"@alloy-js/babel-preset": "~0.
|
|
30
|
+
"@alloy-js/babel-preset": "~0.2.0"
|
|
33
31
|
},
|
|
34
32
|
"type": "module",
|
|
35
33
|
"scripts": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Children,
|
|
1
|
+
import { Children, For, Indent } from "@alloy-js/core";
|
|
2
2
|
import { ValueExpression } from "./ValueExpression.js";
|
|
3
3
|
|
|
4
4
|
export interface ArrayExpressionProps {
|
|
@@ -7,35 +7,25 @@ export interface ArrayExpressionProps {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function ArrayExpression(props: ArrayExpressionProps) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return elements;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return memo(() => {
|
|
35
|
-
if (elements.value.length === 0) {
|
|
36
|
-
return "[]";
|
|
37
|
-
} else {
|
|
38
|
-
return ["[\n", <Indent>{elements.value}</Indent>, "\n]"];
|
|
39
|
-
}
|
|
40
|
-
});
|
|
10
|
+
return (
|
|
11
|
+
<group>
|
|
12
|
+
[
|
|
13
|
+
<Indent break="soft">
|
|
14
|
+
<For each={props.jsValue ?? []} comma line>
|
|
15
|
+
{(value) => <ValueExpression jsValue={value} />}
|
|
16
|
+
</For>
|
|
17
|
+
{props.children && (
|
|
18
|
+
<>
|
|
19
|
+
{props.jsValue && props.jsValue.length > 0 && (
|
|
20
|
+
<>
|
|
21
|
+
,<br />
|
|
22
|
+
</>
|
|
23
|
+
)}
|
|
24
|
+
{props.children}
|
|
25
|
+
</>
|
|
26
|
+
)}
|
|
27
|
+
</Indent>
|
|
28
|
+
<sbr />]
|
|
29
|
+
</group>
|
|
30
|
+
);
|
|
41
31
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
mapJoin,
|
|
3
|
-
memo,
|
|
4
|
-
SourceDirectoryContext,
|
|
5
|
-
useContext,
|
|
6
|
-
} from "@alloy-js/core";
|
|
1
|
+
import { For, memo, SourceDirectoryContext, useContext } from "@alloy-js/core";
|
|
7
2
|
import { basename } from "pathe";
|
|
8
3
|
import { getSourceDirectoryData } from "../source-directory-data.js";
|
|
9
4
|
import { TSModuleScope } from "../symbols/index.js";
|
|
@@ -84,13 +79,12 @@ export function BarrelFile(props: BarrelFileProps) {
|
|
|
84
79
|
(m) => basename(m.name) !== "index.ts",
|
|
85
80
|
);
|
|
86
81
|
|
|
87
|
-
|
|
88
|
-
return mapJoin(allModules, (module) => {
|
|
89
|
-
return <ExportStatement star from={module} />;
|
|
90
|
-
});
|
|
82
|
+
return [...sourceFiles, ...nestedBarrels];
|
|
91
83
|
});
|
|
92
84
|
|
|
93
|
-
return
|
|
94
|
-
{
|
|
95
|
-
|
|
85
|
+
return (
|
|
86
|
+
<SourceFile path={path} export={props.export}>
|
|
87
|
+
<For each={exports}>{(mod) => <ExportStatement star from={mod} />}</For>
|
|
88
|
+
</SourceFile>
|
|
89
|
+
);
|
|
96
90
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Block,
|
|
2
3
|
Children,
|
|
3
4
|
MemberDeclaration,
|
|
4
5
|
MemberName,
|
|
@@ -56,11 +57,12 @@ export function ClassDeclaration(props: ClassDeclarationProps) {
|
|
|
56
57
|
const extendsPart = props.extends && <> extends {props.extends}</>;
|
|
57
58
|
const flags = OutputSymbolFlags.MemberContainer;
|
|
58
59
|
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
return (
|
|
61
|
+
<Declaration {...props} flags={flags} nameKind="class">
|
|
62
|
+
class <Name />
|
|
63
|
+
{extendsPart} <Block>{props.children}</Block>
|
|
64
|
+
</Declaration>
|
|
65
|
+
);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
export interface ClassMemberProps {
|
|
@@ -97,17 +99,15 @@ export function ClassMember(props: ClassMemberProps) {
|
|
|
97
99
|
name = `#${name}`;
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
return
|
|
101
|
-
{
|
|
102
|
-
props.public && "public "
|
|
103
|
-
|
|
104
|
-
props.
|
|
105
|
-
|
|
106
|
-
props.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}{props.children}
|
|
110
|
-
</MemberDeclaration>;
|
|
102
|
+
return (
|
|
103
|
+
<MemberDeclaration symbol={sym} name={name} refkey={props.refkey}>
|
|
104
|
+
{props.public && "public "}
|
|
105
|
+
{props.private && "private "}
|
|
106
|
+
{props.protected && "protected "}
|
|
107
|
+
{props.static && "static "}
|
|
108
|
+
{props.children}
|
|
109
|
+
</MemberDeclaration>
|
|
110
|
+
);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export interface ClassFieldProps extends ClassMemberProps {
|
|
@@ -119,9 +119,13 @@ export function ClassField(props: ClassFieldProps) {
|
|
|
119
119
|
const typeSection = props.type && <>: {props.type}</>;
|
|
120
120
|
const initializerSection = props.children && <> = {props.children}</>;
|
|
121
121
|
|
|
122
|
-
return
|
|
123
|
-
<
|
|
124
|
-
|
|
122
|
+
return (
|
|
123
|
+
<ClassMember {...props}>
|
|
124
|
+
<MemberName />
|
|
125
|
+
{typeSection}
|
|
126
|
+
{initializerSection}
|
|
127
|
+
</ClassMember>
|
|
128
|
+
);
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
export interface ClassMethodProps extends ClassMemberProps {
|
|
@@ -133,13 +137,14 @@ export interface ClassMethodProps extends ClassMemberProps {
|
|
|
133
137
|
|
|
134
138
|
export function ClassMethod(props: ClassMethodProps) {
|
|
135
139
|
const returnType = props.returnType && <>: {props.returnType}</>;
|
|
136
|
-
return
|
|
137
|
-
{
|
|
138
|
-
props.async && "async "
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{props.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
return (
|
|
141
|
+
<ClassMember {...props}>
|
|
142
|
+
{props.async && "async "}
|
|
143
|
+
<MemberName />
|
|
144
|
+
<Scope name={props.name} kind="function">
|
|
145
|
+
(<FunctionDeclaration.Parameters parameters={props.parameters} />)
|
|
146
|
+
{returnType} <Block>{props.children}</Block>
|
|
147
|
+
</Scope>
|
|
148
|
+
</ClassMember>
|
|
149
|
+
);
|
|
145
150
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Children, List, splitProps } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
export interface CommaListProps {
|
|
4
|
+
children: Children;
|
|
5
|
+
hardline?: boolean;
|
|
6
|
+
softline?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A comma-separated list of items (e.g. arguments to a function call,
|
|
11
|
+
* parameters, etc).
|
|
12
|
+
*/
|
|
13
|
+
export function CommaList(props: CommaListProps) {
|
|
14
|
+
return (
|
|
15
|
+
<List
|
|
16
|
+
comma
|
|
17
|
+
{...splitProps(props, ["hardline", "softline"])}
|
|
18
|
+
enderPunctuation
|
|
19
|
+
>
|
|
20
|
+
{props.children}
|
|
21
|
+
</List>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
Declaration as CoreDeclaration,
|
|
4
4
|
MemberScope,
|
|
5
5
|
OutputSymbolFlags,
|
|
6
|
-
refkey,
|
|
7
6
|
Refkey,
|
|
8
7
|
} from "@alloy-js/core";
|
|
9
8
|
import { TypeScriptElements, useTSNamePolicy } from "../name-policy.js";
|
|
@@ -29,6 +28,11 @@ export interface BaseDeclarationProps {
|
|
|
29
28
|
*/
|
|
30
29
|
refkey?: Refkey;
|
|
31
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Multiple unique keys for this declaration.
|
|
33
|
+
*/
|
|
34
|
+
refkeys?: Refkey[];
|
|
35
|
+
|
|
32
36
|
/**
|
|
33
37
|
* Whether to export this declaration from the module.
|
|
34
38
|
*/
|
|
@@ -84,7 +88,8 @@ export function Declaration(props: DeclarationProps) {
|
|
|
84
88
|
|
|
85
89
|
const sym = createTSSymbol({
|
|
86
90
|
name: namePolicy.getName(props.name, props.nameKind),
|
|
87
|
-
refkey: props.refkey
|
|
91
|
+
refkey: props.refkey,
|
|
92
|
+
refkeys: props.refkeys,
|
|
88
93
|
export: props.export,
|
|
89
94
|
default: props.default,
|
|
90
95
|
flags: props.flags,
|
|
@@ -99,7 +104,11 @@ export function Declaration(props: DeclarationProps) {
|
|
|
99
104
|
children = () => props.children;
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
return (
|
|
108
|
+
<CoreDeclaration symbol={sym}>
|
|
109
|
+
{props.export ? "export " : ""}
|
|
110
|
+
{props.default ? "default " : ""}
|
|
111
|
+
{children}
|
|
112
|
+
</CoreDeclaration>
|
|
113
|
+
);
|
|
105
114
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Block,
|
|
3
|
+
computed,
|
|
2
4
|
Declaration as CoreDeclaration,
|
|
5
|
+
For,
|
|
3
6
|
MemberScope,
|
|
4
7
|
Name,
|
|
5
8
|
OutputSymbolFlags,
|
|
6
|
-
mapJoin,
|
|
7
|
-
refkey,
|
|
8
9
|
useBinder,
|
|
9
10
|
} from "@alloy-js/core";
|
|
10
11
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
@@ -29,25 +30,31 @@ export function EnumDeclaration(props: EnumDeclarationProps) {
|
|
|
29
30
|
binder,
|
|
30
31
|
scope,
|
|
31
32
|
name: name,
|
|
32
|
-
refkey: props.refkey
|
|
33
|
+
refkey: props.refkey,
|
|
34
|
+
refkeys: props.refkeys,
|
|
33
35
|
default: props.default,
|
|
34
36
|
export: props.export,
|
|
35
37
|
flags: OutputSymbolFlags.StaticMemberContainer,
|
|
36
38
|
});
|
|
37
39
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{ joiner: ",\n" },
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
return <CoreDeclaration symbol={sym}>
|
|
47
|
-
{props.export ? "export " : ""}{props.default ? "default " : ""}enum <Name /> {"{"}
|
|
40
|
+
const valueEntries = computed(() => Object.entries(props.jsValue ?? {}));
|
|
41
|
+
return (
|
|
42
|
+
<CoreDeclaration symbol={sym}>
|
|
43
|
+
{props.export ? "export " : ""}
|
|
44
|
+
{props.default ? "default " : ""}enum <Name />{" "}
|
|
48
45
|
<MemberScope owner={sym}>
|
|
49
|
-
|
|
46
|
+
<Block>
|
|
47
|
+
<For each={valueEntries} comma hardline enderPunctuation>
|
|
48
|
+
{([name, value]) => <EnumMember name={name} jsValue={value} />}
|
|
49
|
+
</For>
|
|
50
|
+
{props.children && (
|
|
51
|
+
<>
|
|
52
|
+
{valueEntries.value.length > 0 && <hbr />}
|
|
53
|
+
{props.children}
|
|
54
|
+
</>
|
|
55
|
+
)}
|
|
56
|
+
</Block>
|
|
50
57
|
</MemberScope>
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
</CoreDeclaration>
|
|
59
|
+
);
|
|
53
60
|
}
|
|
@@ -44,9 +44,12 @@ export function EnumMember(props: EnumMemberProps) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
const nameCode = sym ? sym.name : name;
|
|
47
|
-
const valueCode =
|
|
48
|
-
<ValueExpression jsValue={props.jsValue} />
|
|
49
|
-
: props.value;
|
|
47
|
+
const valueCode =
|
|
48
|
+
props.jsValue ? <ValueExpression jsValue={props.jsValue} /> : props.value;
|
|
50
49
|
|
|
51
|
-
return
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
{nameCode} = {valueCode}
|
|
53
|
+
</>
|
|
54
|
+
);
|
|
52
55
|
}
|
|
@@ -12,9 +12,16 @@ export function ExportStatement(props: ExportStatementProps) {
|
|
|
12
12
|
if (props.star) {
|
|
13
13
|
const module = useSourceFile();
|
|
14
14
|
for (const symbol of props.from!.symbols.values()) {
|
|
15
|
-
|
|
15
|
+
for (const refkey of symbol.refkeys) {
|
|
16
|
+
module.scope.exportedSymbols.set(refkey, symbol as TSOutputSymbol);
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
|
-
return
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
export * from "
|
|
22
|
+
{modulePath(relative(dirname(module.scope.name), props.from!.name))}";
|
|
23
|
+
</>
|
|
24
|
+
);
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
return "";
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import { Children,
|
|
2
|
-
import { Reference } from "./Reference.js";
|
|
1
|
+
import { Children, For, Indent, Wrap } from "@alloy-js/core";
|
|
3
2
|
|
|
4
3
|
export interface FunctionCallExpressionProps {
|
|
5
|
-
|
|
4
|
+
target: Children;
|
|
6
5
|
args?: Children[];
|
|
7
6
|
}
|
|
7
|
+
|
|
8
8
|
export function FunctionCallExpression(props: FunctionCallExpressionProps) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
return (
|
|
10
|
+
<group>
|
|
11
|
+
{props.target}(
|
|
12
|
+
<Wrap
|
|
13
|
+
when={!!props.args && props.args.length > 1}
|
|
14
|
+
with={Indent}
|
|
15
|
+
props={{ break: "soft", trailingBreak: true }}
|
|
16
|
+
>
|
|
17
|
+
<For each={props.args ?? []} comma line>
|
|
18
|
+
{(arg) => arg}
|
|
19
|
+
</For>
|
|
20
|
+
</Wrap>
|
|
21
|
+
)
|
|
22
|
+
</group>
|
|
23
|
+
);
|
|
15
24
|
}
|