@powerlines/plugin-alloy 0.25.27 → 0.25.29
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/core/components/output.cjs +7 -19
- package/dist/core/components/output.mjs +7 -19
- package/dist/core/components/output.mjs.map +1 -1
- package/dist/core/components/single-line-comment.cjs +8 -7
- package/dist/core/components/single-line-comment.mjs +8 -7
- package/dist/core/components/single-line-comment.mjs.map +1 -1
- package/dist/core/components/source-file.cjs +7 -12
- package/dist/core/components/source-file.mjs +7 -12
- package/dist/core/components/source-file.mjs.map +1 -1
- package/dist/core/components/spacing.cjs +6 -7
- package/dist/core/components/spacing.mjs +6 -7
- package/dist/core/components/spacing.mjs.map +1 -1
- package/dist/core/contexts/context.mjs.map +1 -1
- package/dist/core/contexts/meta.mjs.map +1 -1
- package/dist/core/contexts/reflection.mjs.map +1 -1
- package/dist/core/helpers/code.mjs.map +1 -1
- package/dist/helpers/capnp.mjs.map +1 -1
- package/dist/helpers/create-builtin.mjs.map +1 -1
- package/dist/helpers/refkey.mjs.map +1 -1
- package/dist/helpers/typescript.mjs.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/dist/markdown/components/front-matter.cjs +9 -14
- package/dist/markdown/components/front-matter.mjs +9 -14
- package/dist/markdown/components/front-matter.mjs.map +1 -1
- package/dist/markdown/components/markdown-file.cjs +41 -89
- package/dist/markdown/components/markdown-file.mjs +41 -89
- package/dist/markdown/components/markdown-file.mjs.map +1 -1
- package/dist/markdown/components/markdown-table.cjs +20 -52
- package/dist/markdown/components/markdown-table.mjs +20 -52
- package/dist/markdown/components/markdown-table.mjs.map +1 -1
- package/dist/markdown/contexts/markdown-table.mjs.map +1 -1
- package/dist/render.cjs +4 -10
- package/dist/render.mjs +4 -10
- package/dist/render.mjs.map +1 -1
- package/dist/typescript/components/builtin-file.cjs +9 -31
- package/dist/typescript/components/builtin-file.mjs +9 -31
- package/dist/typescript/components/builtin-file.mjs.map +1 -1
- package/dist/typescript/components/class-declaration.cjs +80 -193
- package/dist/typescript/components/class-declaration.mjs +80 -193
- package/dist/typescript/components/class-declaration.mjs.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +1 -2
- package/dist/typescript/components/dynamic-import-statement.mjs +1 -2
- package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -1
- package/dist/typescript/components/entry-file.cjs +3 -10
- package/dist/typescript/components/entry-file.mjs +3 -10
- package/dist/typescript/components/entry-file.mjs.map +1 -1
- package/dist/typescript/components/infrastructure-file.cjs +3 -10
- package/dist/typescript/components/infrastructure-file.mjs +3 -10
- package/dist/typescript/components/infrastructure-file.mjs.map +1 -1
- package/dist/typescript/components/interface-declaration.cjs +47 -134
- package/dist/typescript/components/interface-declaration.mjs +47 -134
- package/dist/typescript/components/interface-declaration.mjs.map +1 -1
- package/dist/typescript/components/object-declaration.cjs +35 -79
- package/dist/typescript/components/object-declaration.mjs +35 -79
- package/dist/typescript/components/object-declaration.mjs.map +1 -1
- package/dist/typescript/components/property-name.cjs +3 -3
- package/dist/typescript/components/property-name.mjs +3 -3
- package/dist/typescript/components/property-name.mjs.map +1 -1
- package/dist/typescript/components/record-expression.mjs.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +53 -232
- package/dist/typescript/components/tsdoc-reflection.mjs +53 -232
- package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
- package/dist/typescript/components/tsdoc.cjs +140 -306
- package/dist/typescript/components/tsdoc.mjs +140 -306
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/components/type-declaration.cjs +9 -22
- package/dist/typescript/components/type-declaration.mjs +9 -22
- package/dist/typescript/components/type-declaration.mjs.map +1 -1
- package/dist/typescript/components/type-parameters.cjs +33 -60
- package/dist/typescript/components/type-parameters.mjs +33 -60
- package/dist/typescript/components/type-parameters.mjs.map +1 -1
- package/dist/typescript/components/typescript-file.cjs +65 -155
- package/dist/typescript/components/typescript-file.mjs +65 -155
- package/dist/typescript/components/typescript-file.mjs.map +1 -1
- package/dist/typescript/contexts/lexical-scope.cjs +1 -7
- package/dist/typescript/contexts/lexical-scope.mjs +1 -7
- package/dist/typescript/contexts/lexical-scope.mjs.map +1 -1
- package/dist/typescript/contexts/member-scope.cjs +2 -7
- package/dist/typescript/contexts/member-scope.mjs +2 -7
- package/dist/typescript/contexts/member-scope.mjs.map +1 -1
- package/dist/typescript/helpers/get-call-signature-props.mjs.map +1 -1
- package/dist/typescript/helpers/utilities.mjs.map +1 -1
- package/dist/yaml/components/yaml-file.cjs +48 -103
- package/dist/yaml/components/yaml-file.mjs +48 -103
- package/dist/yaml/components/yaml-file.mjs.map +1 -1
- package/package.json +7 -7
- package/dist/_virtual/_rolldown/runtime.mjs +0 -3
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { usePowerlinesSafe } from "../../core/contexts/context.mjs";
|
|
2
2
|
import { SingleLineComment } from "../../core/components/single-line-comment.mjs";
|
|
3
3
|
import { SourceFile } from "../../core/components/source-file.mjs";
|
|
4
|
-
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
4
|
import { For, Scope, Show, SourceDirectoryContext, code, computed, splitProps, useContext, useScope } from "@alloy-js/core";
|
|
6
5
|
import { appendPath } from "@stryke/path/append";
|
|
7
6
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
@@ -39,33 +38,15 @@ function TypescriptFile(props) {
|
|
|
39
38
|
if (pkg) if (isBoolean(props.export)) pkg.scope.addExport(modulePath, scope);
|
|
40
39
|
else pkg.scope.addExport(props.export, scope);
|
|
41
40
|
}
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return header ?? createComponent(TypescriptFileHeader, {
|
|
52
|
-
hashbang,
|
|
53
|
-
get children() {
|
|
54
|
-
return createComponent(TypescriptFileHeaderImports, {
|
|
55
|
-
imports,
|
|
56
|
-
builtinImports,
|
|
57
|
-
scope
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
filetype: tsx ? "tsx" : "typescript",
|
|
63
|
-
children
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
41
|
+
return <SourceFileContext$1.Provider value={{ scope }}>
|
|
42
|
+
<Scope value={scope}>
|
|
43
|
+
<SourceFile {...rest} path={modulePath} header={header ?? <TypescriptFileHeader hashbang={hashbang}>
|
|
44
|
+
<TypescriptFileHeaderImports imports={imports} builtinImports={builtinImports} scope={scope} />
|
|
45
|
+
</TypescriptFileHeader>} filetype={tsx ? "tsx" : "typescript"}>
|
|
46
|
+
{children}
|
|
47
|
+
</SourceFile>
|
|
48
|
+
</Scope>
|
|
49
|
+
</SourceFileContext$1.Provider>;
|
|
69
50
|
}
|
|
70
51
|
/**
|
|
71
52
|
* Renders the header for a Powerlines Typescript source file.
|
|
@@ -76,79 +57,46 @@ function TypescriptFile(props) {
|
|
|
76
57
|
function TypescriptFileHeader(props) {
|
|
77
58
|
const { header, hashbang, disableEslint = true, disableBiome = true, disablePrettier = false, children } = props;
|
|
78
59
|
const context = usePowerlinesSafe();
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
createComponent(Show, {
|
|
120
|
-
get when() {
|
|
121
|
-
return Boolean(disableBiome);
|
|
122
|
-
},
|
|
123
|
-
get children() {
|
|
124
|
-
return [createComponent(SingleLineComment, { children: "biome-ignore lint: disable" }), createIntrinsic("hbr", {})];
|
|
125
|
-
}
|
|
126
|
-
}),
|
|
127
|
-
createComponent(Show, {
|
|
128
|
-
get when() {
|
|
129
|
-
return Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome);
|
|
130
|
-
},
|
|
131
|
-
get children() {
|
|
132
|
-
return createIntrinsic("hbr", {});
|
|
133
|
-
}
|
|
134
|
-
}),
|
|
135
|
-
createComponent(Show, {
|
|
136
|
-
get when() {
|
|
137
|
-
return Boolean(children);
|
|
138
|
-
},
|
|
139
|
-
get children() {
|
|
140
|
-
return [children, createIntrinsic("hbr", {})];
|
|
141
|
-
}
|
|
142
|
-
}),
|
|
143
|
-
createComponent(SingleLineComment, { get children() {
|
|
144
|
-
return `Generated by ${titleCase(context?.config?.framework) || "Powerlines"}`;
|
|
145
|
-
} }),
|
|
146
|
-
createIntrinsic("hbr", {}),
|
|
147
|
-
createComponent(SingleLineComment, { get children() {
|
|
148
|
-
return getFileHeaderWarning(context);
|
|
149
|
-
} }),
|
|
150
|
-
createIntrinsic("hbr", {})
|
|
151
|
-
];
|
|
60
|
+
return <>
|
|
61
|
+
<Show when={Boolean(hashbang)}>
|
|
62
|
+
{hashbang === true ? code`#!/usr/bin/env ${context?.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node` : hashbang}
|
|
63
|
+
<hbr />
|
|
64
|
+
</Show>
|
|
65
|
+
<Show when={Boolean(header)}>
|
|
66
|
+
{header}
|
|
67
|
+
<hbr />
|
|
68
|
+
</Show>
|
|
69
|
+
<hbr />
|
|
70
|
+
<Show when={Boolean(disableEslint)}>
|
|
71
|
+
<SingleLineComment variant="slash-star">
|
|
72
|
+
{"eslint-disable"}
|
|
73
|
+
</SingleLineComment>
|
|
74
|
+
<hbr />
|
|
75
|
+
</Show>
|
|
76
|
+
<Show when={Boolean(disablePrettier)}>
|
|
77
|
+
<SingleLineComment variant="slash-star">
|
|
78
|
+
{"prettier-ignore"}
|
|
79
|
+
</SingleLineComment>
|
|
80
|
+
<hbr />
|
|
81
|
+
</Show>
|
|
82
|
+
<Show when={Boolean(disableBiome)}>
|
|
83
|
+
<SingleLineComment>{"biome-ignore lint: disable"}</SingleLineComment>
|
|
84
|
+
<hbr />
|
|
85
|
+
</Show>
|
|
86
|
+
<Show when={Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome)}>
|
|
87
|
+
<hbr />
|
|
88
|
+
</Show>
|
|
89
|
+
<Show when={Boolean(children)}>
|
|
90
|
+
<>
|
|
91
|
+
{children}
|
|
92
|
+
<hbr />
|
|
93
|
+
</>
|
|
94
|
+
</Show>
|
|
95
|
+
<SingleLineComment>{`Generated by ${titleCase(context?.config?.framework) || "Powerlines"}`}</SingleLineComment>
|
|
96
|
+
<hbr />
|
|
97
|
+
<SingleLineComment>{getFileHeaderWarning(context)}</SingleLineComment>
|
|
98
|
+
<hbr />
|
|
99
|
+
</>;
|
|
152
100
|
}
|
|
153
101
|
/**
|
|
154
102
|
* Renders the header for a Powerlines Typescript source file.
|
|
@@ -167,60 +115,22 @@ function TypescriptFileHeaderImports(props) {
|
|
|
167
115
|
const builtinImports = computed(() => {
|
|
168
116
|
return Object.fromEntries(Object.entries(builtinImportsProps ?? {}).map(([module, importItem]) => [module, Array.isArray(importItem) ? getUniqueBy(importItem, (i) => isString(i) ? i : i.alias || i.name) : importItem]));
|
|
169
117
|
});
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
get ender() {
|
|
187
|
-
return createIntrinsic("hbr", {});
|
|
188
|
-
},
|
|
189
|
-
children: ([module, importItem]) => code`import ${importItem === null ? "" : isString(importItem) ? importItem : `${importItem.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (importItem.filter((i) => !isString(i) && i.default).length > 0 && importItem.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (importItem.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${importItem.filter((i) => isString(i) || !i.default).map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")}`} from "${module}";`
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}),
|
|
193
|
-
createComponent(Show, {
|
|
194
|
-
get when() {
|
|
195
|
-
return memo(() => !!builtinImports.value)() && Object.keys(builtinImports.value).length > 0;
|
|
196
|
-
},
|
|
197
|
-
get children() {
|
|
198
|
-
return createComponent(For, {
|
|
199
|
-
get each() {
|
|
200
|
-
return Object.entries(builtinImports.value ?? {});
|
|
201
|
-
},
|
|
202
|
-
hardline: true,
|
|
203
|
-
get ender() {
|
|
204
|
-
return createIntrinsic("hbr", {});
|
|
205
|
-
},
|
|
206
|
-
children: ([module, importItem]) => code`import ${importItem === null ? "" : isString(importItem) ? importItem : `${importItem.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (importItem.filter((i) => !isString(i) && i.default).length > 0 && importItem.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (importItem.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${importItem.filter((i) => isString(i) || !i.default).map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")}`} from "${module.includes(":") ? module : `${context?.config?.framework || "powerlines"}:${module}`}";`
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}),
|
|
210
|
-
createComponent(Show, {
|
|
211
|
-
get when() {
|
|
212
|
-
return scope.importedModules.size > 0;
|
|
213
|
-
},
|
|
214
|
-
get children() {
|
|
215
|
-
return createComponent(ImportStatements, { get records() {
|
|
216
|
-
return scope.importedModules;
|
|
217
|
-
} });
|
|
218
|
-
}
|
|
219
|
-
}),
|
|
220
|
-
createIntrinsic("hbr", {})
|
|
221
|
-
];
|
|
222
|
-
}
|
|
223
|
-
});
|
|
118
|
+
return <Show when={scope.importedModules.size > 0 || !!imports.value && Object.keys(imports.value).length > 0 || !!builtinImports.value && Object.keys(builtinImports.value).length > 0}>
|
|
119
|
+
<Show when={!!imports.value && Object.keys(imports.value).length > 0}>
|
|
120
|
+
<For each={Object.entries(imports.value ?? {})} hardline ender={<hbr />}>
|
|
121
|
+
{([module, importItem]) => code`import ${importItem === null ? "" : isString(importItem) ? importItem : `${importItem.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (importItem.filter((i) => !isString(i) && i.default).length > 0 && importItem.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (importItem.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${importItem.filter((i) => isString(i) || !i.default).map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")}`} from "${module}";`}
|
|
122
|
+
</For>
|
|
123
|
+
</Show>
|
|
124
|
+
<Show when={builtinImports.value && Object.keys(builtinImports.value).length > 0}>
|
|
125
|
+
<For each={Object.entries(builtinImports.value ?? {})} hardline ender={<hbr />}>
|
|
126
|
+
{([module, importItem]) => code`import ${importItem === null ? "" : isString(importItem) ? importItem : `${importItem.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (importItem.filter((i) => !isString(i) && i.default).length > 0 && importItem.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (importItem.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${importItem.filter((i) => isString(i) || !i.default).map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")}`} from "${module.includes(":") ? module : `${context?.config?.framework || "powerlines"}:${module}`}";`}
|
|
127
|
+
</For>
|
|
128
|
+
</Show>
|
|
129
|
+
<Show when={scope.importedModules.size > 0}>
|
|
130
|
+
<ImportStatements records={scope.importedModules} />
|
|
131
|
+
</Show>
|
|
132
|
+
<hbr />
|
|
133
|
+
</Show>;
|
|
224
134
|
}
|
|
225
135
|
|
|
226
136
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-file.mjs","names":["code","computed","For","Scope","Show","SourceDirectoryContext","splitProps","useContext","useScope","getSourceDirectoryData","ImportStatements","PackageContext","SourceFileContext","TSModuleScope","useSourceFile","getUniqueBy","appendPath","titleCase","isBoolean","isString","getFileHeaderWarning","SingleLineComment","SourceFile","usePowerlinesSafe","TypescriptFile","props","children","path","imports","builtinImports","tsx","header","hashbang","rest","directoryContext","sdData","modulePath","scope","modules","add","pkg","addModule","export","addExport","_$createComponent","Provider","value","_$mergeProps","TypescriptFileHeader","TypescriptFileHeaderImports","filetype","disableEslint","disableBiome","disablePrettier","context","when","Boolean","_$memo","config","mode","_$createIntrinsic","variant","framework","importProps","builtinImportsProps","sourceFile","Object","fromEntries","entries","map","module","importItem","Array","isArray","i","alias","name","importedModules","size","keys","length","each","hardline","ender","filter","default","join","includes","records"],"sources":["../../../src/typescript/components/typescript-file.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport {\n code,\n computed,\n For,\n Scope,\n Show,\n SourceDirectoryContext,\n splitProps,\n useContext,\n useScope\n} from \"@alloy-js/core\";\nimport {\n getSourceDirectoryData,\n ImportStatements,\n PackageContext,\n SourceFileContext,\n TSModuleScope,\n useSourceFile\n} from \"@alloy-js/typescript\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { getFileHeaderWarning } from \"powerlines/utils\";\nimport { SingleLineComment } from \"../../core/components/single-line-comment\";\nimport { SourceFile, SourceFileProps } from \"../../core/components/source-file\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport {\n ComponentProps,\n SourceFileHeaderProps,\n TypescriptFileImportItem,\n TypescriptFileImports\n} from \"../../types/components\";\n\nexport type TypescriptFileProps = Omit<SourceFileProps, \"filetype\"> &\n ComponentProps & {\n hashbang?: Children | true;\n header?: Children;\n imports?: TypescriptFileImports;\n builtinImports?: TypescriptFileImports;\n export?: boolean | string;\n tsx?: boolean;\n };\n\n/**\n * A base component representing a Powerlines generated Typescript source file.\n *\n * @param props - The properties for the source file.\n * @returns The rendered source file component.\n */\nexport function TypescriptFile(props: TypescriptFileProps) {\n const [\n { children, path, imports, builtinImports, tsx, header, hashbang },\n rest\n ] = splitProps(props, [\n \"children\",\n \"path\",\n \"imports\",\n \"builtinImports\",\n \"tsx\",\n \"header\",\n \"hashbang\"\n ]);\n\n const directoryContext = useContext(SourceDirectoryContext)!;\n const sdData = getSourceDirectoryData(directoryContext);\n\n const modulePath = appendPath(path, directoryContext.path);\n const scope = new TSModuleScope(modulePath, useScope());\n sdData.modules.add(scope);\n\n const pkg = useContext(PackageContext);\n if (pkg) {\n pkg.scope.addModule(scope);\n }\n\n if (props.export) {\n if (pkg) {\n if (isBoolean(props.export)) {\n pkg.scope.addExport(modulePath, scope);\n } else {\n pkg.scope.addExport(props.export, scope);\n }\n }\n }\n\n return (\n <SourceFileContext.Provider\n value={{\n scope\n }}>\n <Scope value={scope}>\n <SourceFile\n {...rest}\n path={modulePath}\n header={\n header ?? (\n <TypescriptFileHeader hashbang={hashbang}>\n <TypescriptFileHeaderImports\n imports={imports}\n builtinImports={builtinImports}\n scope={scope}\n />\n </TypescriptFileHeader>\n )\n }\n filetype={tsx ? \"tsx\" : \"typescript\"}>\n {children}\n </SourceFile>\n </Scope>\n </SourceFileContext.Provider>\n );\n}\n\nexport interface TypescriptFileHeaderProps extends SourceFileHeaderProps {\n header?: Children;\n hashbang?: Children | true;\n}\n\n/**\n * Renders the header for a Powerlines Typescript source file.\n *\n * @param props - The properties for the source file header.\n * @returns The rendered source file header.\n */\nexport function TypescriptFileHeader(props: TypescriptFileHeaderProps) {\n const {\n header,\n hashbang,\n disableEslint = true,\n disableBiome = true,\n disablePrettier = false,\n children\n } = props;\n\n const context = usePowerlinesSafe();\n\n return (\n <>\n <Show when={Boolean(hashbang)}>\n {hashbang === true\n ? code`#!/usr/bin/env ${\n context?.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node`\n : hashbang}\n <hbr />\n </Show>\n <Show when={Boolean(header)}>\n {header}\n <hbr />\n </Show>\n <hbr />\n <Show when={Boolean(disableEslint)}>\n <SingleLineComment variant=\"slash-star\">\n {\"eslint-disable\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show when={Boolean(disablePrettier)}>\n <SingleLineComment variant=\"slash-star\">\n {\"prettier-ignore\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show when={Boolean(disableBiome)}>\n <SingleLineComment>{\"biome-ignore lint: disable\"}</SingleLineComment>\n <hbr />\n </Show>\n <Show\n when={\n Boolean(disableEslint) ||\n Boolean(disablePrettier) ||\n Boolean(disableBiome)\n }>\n <hbr />\n </Show>\n <Show when={Boolean(children)}>\n <>\n {children}\n <hbr />\n </>\n </Show>\n <SingleLineComment>{`Generated by ${\n titleCase(context?.config?.framework) || \"Powerlines\"\n }`}</SingleLineComment>\n <hbr />\n <SingleLineComment>{getFileHeaderWarning(context!)}</SingleLineComment>\n <hbr />\n </>\n );\n}\n\nexport interface TypescriptFileHeaderImportsProps extends SourceFileHeaderProps {\n imports?: TypescriptFileImports;\n builtinImports?: TypescriptFileImports;\n scope?: TSModuleScope;\n}\n\n/**\n * Renders the header for a Powerlines Typescript source file.\n *\n * @param props - The properties for the source file header.\n * @returns The rendered source file header.\n */\nexport function TypescriptFileHeaderImports(\n props: TypescriptFileHeaderImportsProps\n) {\n const { imports: importProps, builtinImports: builtinImportsProps } = props;\n\n const context = usePowerlinesSafe();\n const sourceFile = useSourceFile();\n\n const scope = props.scope ?? sourceFile.scope;\n\n const imports = computed(() => {\n return Object.fromEntries(\n Object.entries(importProps ?? {}).map(([module, importItem]) => [\n module,\n Array.isArray(importItem)\n ? getUniqueBy(importItem, i => (isString(i) ? i : i.alias || i.name))\n : importItem\n ])\n );\n });\n const builtinImports = computed(() => {\n return Object.fromEntries(\n Object.entries(builtinImportsProps ?? {}).map(([module, importItem]) => [\n module,\n Array.isArray(importItem)\n ? getUniqueBy(importItem, i => (isString(i) ? i : i.alias || i.name))\n : importItem\n ])\n );\n });\n\n return (\n <Show\n when={\n scope.importedModules.size > 0 ||\n (!!imports.value && Object.keys(imports.value).length > 0) ||\n (!!builtinImports.value && Object.keys(builtinImports.value).length > 0)\n }>\n <Show when={!!imports.value && Object.keys(imports.value).length > 0}>\n <For\n each={Object.entries(imports.value ?? {})}\n hardline\n ender={<hbr />}>\n {([module, importItem]) =>\n code`import ${\n importItem === null\n ? \"\"\n : isString(importItem)\n ? importItem\n : `${\n (\n importItem.filter(\n i => !isString(i) && i.default\n ) as TypescriptFileImportItem[]\n )\n .map(i => (i.alias ? i.alias : i.name))\n .join(\", \") +\n (importItem.filter(i => !isString(i) && i.default)\n .length > 0 &&\n importItem.filter(i => isString(i) || !i.default).length >\n 0\n ? \", \"\n : \"\") +\n (importItem.filter(i => isString(i) || !i.default)\n .length > 0\n ? `{ ${importItem\n .filter(i => isString(i) || !i.default)\n .map(i =>\n isString(i)\n ? i\n : i.alias\n ? `${i.name} as ${i.alias}`\n : i.name\n )\n .join(\", \")} }`\n : \"\")\n }`\n } from \"${module}\";`\n }\n </For>\n </Show>\n <Show\n when={\n builtinImports.value && Object.keys(builtinImports.value).length > 0\n }>\n <For\n each={Object.entries(\n (builtinImports.value ?? {}) as Record<\n string,\n null | Array<TypescriptFileImportItem | string>\n >\n )}\n hardline\n ender={<hbr />}>\n {([module, importItem]) =>\n code`import ${\n importItem === null\n ? \"\"\n : isString(importItem)\n ? importItem\n : `${\n (\n importItem.filter(\n i => !isString(i) && i.default\n ) as TypescriptFileImportItem[]\n )\n .map(i => (i.alias ? i.alias : i.name))\n .join(\", \") +\n (importItem.filter(i => !isString(i) && i.default)\n .length > 0 &&\n importItem.filter(i => isString(i) || !i.default).length >\n 0\n ? \", \"\n : \"\") +\n (importItem.filter(i => isString(i) || !i.default)\n .length > 0\n ? `{ ${importItem\n .filter(i => isString(i) || !i.default)\n .map(i =>\n isString(i)\n ? i\n : i.alias\n ? `${i.name} as ${i.alias}`\n : i.name\n )\n .join(\", \")} }`\n : \"\")\n }`\n } from \"${\n module.includes(\":\")\n ? module\n : `${context?.config?.framework || \"powerlines\"}:${module}`\n }\";`\n }\n </For>\n </Show>\n <Show when={scope.importedModules.size > 0}>\n <ImportStatements records={scope.importedModules} />\n </Show>\n <hbr />\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;SA2WwD,eAAA,OAAA;OAAA,aAAA,MAAA,SAAA,gBAAA,KAAA,QAAA,+BAAA,OAAA"}
|
|
1
|
+
{"version":3,"file":"typescript-file.mjs","names":["SourceFileContext"],"sources":["../../../src/typescript/components/typescript-file.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport {\n code,\n computed,\n For,\n Scope,\n Show,\n SourceDirectoryContext,\n splitProps,\n useContext,\n useScope\n} from \"@alloy-js/core\";\nimport {\n getSourceDirectoryData,\n ImportStatements,\n PackageContext,\n SourceFileContext,\n TSModuleScope,\n useSourceFile\n} from \"@alloy-js/typescript\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { getFileHeaderWarning } from \"powerlines/utils\";\nimport { SingleLineComment } from \"../../core/components/single-line-comment\";\nimport { SourceFile, SourceFileProps } from \"../../core/components/source-file\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport {\n ComponentProps,\n SourceFileHeaderProps,\n TypescriptFileImportItem,\n TypescriptFileImports\n} from \"../../types/components\";\n\nexport type TypescriptFileProps = Omit<SourceFileProps, \"filetype\"> &\n ComponentProps & {\n hashbang?: Children | true;\n header?: Children;\n imports?: TypescriptFileImports;\n builtinImports?: TypescriptFileImports;\n export?: boolean | string;\n tsx?: boolean;\n };\n\n/**\n * A base component representing a Powerlines generated Typescript source file.\n *\n * @param props - The properties for the source file.\n * @returns The rendered source file component.\n */\nexport function TypescriptFile(props: TypescriptFileProps) {\n const [\n { children, path, imports, builtinImports, tsx, header, hashbang },\n rest\n ] = splitProps(props, [\n \"children\",\n \"path\",\n \"imports\",\n \"builtinImports\",\n \"tsx\",\n \"header\",\n \"hashbang\"\n ]);\n\n const directoryContext = useContext(SourceDirectoryContext)!;\n const sdData = getSourceDirectoryData(directoryContext);\n\n const modulePath = appendPath(path, directoryContext.path);\n const scope = new TSModuleScope(modulePath, useScope());\n sdData.modules.add(scope);\n\n const pkg = useContext(PackageContext);\n if (pkg) {\n pkg.scope.addModule(scope);\n }\n\n if (props.export) {\n if (pkg) {\n if (isBoolean(props.export)) {\n pkg.scope.addExport(modulePath, scope);\n } else {\n pkg.scope.addExport(props.export, scope);\n }\n }\n }\n\n return (\n <SourceFileContext.Provider\n value={{\n scope\n }}>\n <Scope value={scope}>\n <SourceFile\n {...rest}\n path={modulePath}\n header={\n header ?? (\n <TypescriptFileHeader hashbang={hashbang}>\n <TypescriptFileHeaderImports\n imports={imports}\n builtinImports={builtinImports}\n scope={scope}\n />\n </TypescriptFileHeader>\n )\n }\n filetype={tsx ? \"tsx\" : \"typescript\"}>\n {children}\n </SourceFile>\n </Scope>\n </SourceFileContext.Provider>\n );\n}\n\nexport interface TypescriptFileHeaderProps extends SourceFileHeaderProps {\n header?: Children;\n hashbang?: Children | true;\n}\n\n/**\n * Renders the header for a Powerlines Typescript source file.\n *\n * @param props - The properties for the source file header.\n * @returns The rendered source file header.\n */\nexport function TypescriptFileHeader(props: TypescriptFileHeaderProps) {\n const {\n header,\n hashbang,\n disableEslint = true,\n disableBiome = true,\n disablePrettier = false,\n children\n } = props;\n\n const context = usePowerlinesSafe();\n\n return (\n <>\n <Show when={Boolean(hashbang)}>\n {hashbang === true\n ? code`#!/usr/bin/env ${\n context?.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node`\n : hashbang}\n <hbr />\n </Show>\n <Show when={Boolean(header)}>\n {header}\n <hbr />\n </Show>\n <hbr />\n <Show when={Boolean(disableEslint)}>\n <SingleLineComment variant=\"slash-star\">\n {\"eslint-disable\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show when={Boolean(disablePrettier)}>\n <SingleLineComment variant=\"slash-star\">\n {\"prettier-ignore\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show when={Boolean(disableBiome)}>\n <SingleLineComment>{\"biome-ignore lint: disable\"}</SingleLineComment>\n <hbr />\n </Show>\n <Show\n when={\n Boolean(disableEslint) ||\n Boolean(disablePrettier) ||\n Boolean(disableBiome)\n }>\n <hbr />\n </Show>\n <Show when={Boolean(children)}>\n <>\n {children}\n <hbr />\n </>\n </Show>\n <SingleLineComment>{`Generated by ${\n titleCase(context?.config?.framework) || \"Powerlines\"\n }`}</SingleLineComment>\n <hbr />\n <SingleLineComment>{getFileHeaderWarning(context!)}</SingleLineComment>\n <hbr />\n </>\n );\n}\n\nexport interface TypescriptFileHeaderImportsProps extends SourceFileHeaderProps {\n imports?: TypescriptFileImports;\n builtinImports?: TypescriptFileImports;\n scope?: TSModuleScope;\n}\n\n/**\n * Renders the header for a Powerlines Typescript source file.\n *\n * @param props - The properties for the source file header.\n * @returns The rendered source file header.\n */\nexport function TypescriptFileHeaderImports(\n props: TypescriptFileHeaderImportsProps\n) {\n const { imports: importProps, builtinImports: builtinImportsProps } = props;\n\n const context = usePowerlinesSafe();\n const sourceFile = useSourceFile();\n\n const scope = props.scope ?? sourceFile.scope;\n\n const imports = computed(() => {\n return Object.fromEntries(\n Object.entries(importProps ?? {}).map(([module, importItem]) => [\n module,\n Array.isArray(importItem)\n ? getUniqueBy(importItem, i => (isString(i) ? i : i.alias || i.name))\n : importItem\n ])\n );\n });\n const builtinImports = computed(() => {\n return Object.fromEntries(\n Object.entries(builtinImportsProps ?? {}).map(([module, importItem]) => [\n module,\n Array.isArray(importItem)\n ? getUniqueBy(importItem, i => (isString(i) ? i : i.alias || i.name))\n : importItem\n ])\n );\n });\n\n return (\n <Show\n when={\n scope.importedModules.size > 0 ||\n (!!imports.value && Object.keys(imports.value).length > 0) ||\n (!!builtinImports.value && Object.keys(builtinImports.value).length > 0)\n }>\n <Show when={!!imports.value && Object.keys(imports.value).length > 0}>\n <For\n each={Object.entries(imports.value ?? {})}\n hardline\n ender={<hbr />}>\n {([module, importItem]) =>\n code`import ${\n importItem === null\n ? \"\"\n : isString(importItem)\n ? importItem\n : `${\n (\n importItem.filter(\n i => !isString(i) && i.default\n ) as TypescriptFileImportItem[]\n )\n .map(i => (i.alias ? i.alias : i.name))\n .join(\", \") +\n (importItem.filter(i => !isString(i) && i.default)\n .length > 0 &&\n importItem.filter(i => isString(i) || !i.default).length >\n 0\n ? \", \"\n : \"\") +\n (importItem.filter(i => isString(i) || !i.default)\n .length > 0\n ? `{ ${importItem\n .filter(i => isString(i) || !i.default)\n .map(i =>\n isString(i)\n ? i\n : i.alias\n ? `${i.name} as ${i.alias}`\n : i.name\n )\n .join(\", \")} }`\n : \"\")\n }`\n } from \"${module}\";`\n }\n </For>\n </Show>\n <Show\n when={\n builtinImports.value && Object.keys(builtinImports.value).length > 0\n }>\n <For\n each={Object.entries(\n (builtinImports.value ?? {}) as Record<\n string,\n null | Array<TypescriptFileImportItem | string>\n >\n )}\n hardline\n ender={<hbr />}>\n {([module, importItem]) =>\n code`import ${\n importItem === null\n ? \"\"\n : isString(importItem)\n ? importItem\n : `${\n (\n importItem.filter(\n i => !isString(i) && i.default\n ) as TypescriptFileImportItem[]\n )\n .map(i => (i.alias ? i.alias : i.name))\n .join(\", \") +\n (importItem.filter(i => !isString(i) && i.default)\n .length > 0 &&\n importItem.filter(i => isString(i) || !i.default).length >\n 0\n ? \", \"\n : \"\") +\n (importItem.filter(i => isString(i) || !i.default)\n .length > 0\n ? `{ ${importItem\n .filter(i => isString(i) || !i.default)\n .map(i =>\n isString(i)\n ? i\n : i.alias\n ? `${i.name} as ${i.alias}`\n : i.name\n )\n .join(\", \")} }`\n : \"\")\n }`\n } from \"${\n module.includes(\":\")\n ? module\n : `${context?.config?.framework || \"powerlines\"}:${module}`\n }\";`\n }\n </For>\n </Show>\n <Show when={scope.importedModules.size > 0}>\n <ImportStatements records={scope.importedModules} />\n </Show>\n <hbr />\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsEA,SAAgB,eAAe,OAA4B;CACzD,MAAM,CACJ,EAAE,UAAU,MAAM,SAAS,gBAAgB,KAAK,QAAQ,YACxD,QACE,WAAW,OAAO;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,mBAAmB,WAAW,uBAAuB;CAC3D,MAAM,SAAS,uBAAuB,iBAAiB;CAEvD,MAAM,aAAa,WAAW,MAAM,iBAAiB,KAAK;CAC1D,MAAM,QAAQ,IAAI,cAAc,YAAY,UAAU,CAAC;AACvD,QAAO,QAAQ,IAAI,MAAM;CAEzB,MAAM,MAAM,WAAW,eAAe;AACtC,KAAI,IACF,KAAI,MAAM,UAAU,MAAM;AAG5B,KAAI,MAAM,QACR;MAAI,IACF,KAAI,UAAU,MAAM,OAAO,CACzB,KAAI,MAAM,UAAU,YAAY,MAAM;MAEtC,KAAI,MAAM,UAAU,MAAM,QAAQ,MAAM;;AAK9C,QACE,CAACA,oBAAkB,SACjB,OAAO,EACL,OACD,EAAE;MACH,CAAC,MAAM,OAAO,OAAO;QACnB,CAAC,eACK,MACJ,MAAM,YACN,QACE,UACE,CAAC,qBAAqB,UAAU,UAAU;gBACxC,CAAC,4BACC,SAAS,SACT,gBAAgB,gBAChB,OAAO,SACP;cACJ,EAAE,uBAGN,UAAU,MAAM,QAAQ,cAAc;WACrC,SAAS;QACZ,EAAE,WAAW;MACf,EAAE,MAAM;IACV,EAAEA,oBAAkB;;;;;;;;AAexB,SAAgB,qBAAqB,OAAkC;CACrE,MAAM,EACJ,QACA,UACA,gBAAgB,MAChB,eAAe,MACf,kBAAkB,OAClB,aACE;CAEJ,MAAM,UAAU,mBAAmB;AAEnC,QACE,EAAE;MACA,CAAC,KAAK,MAAM,QAAQ,SAAS,EAAE;SAC5B,aAAa,OAC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iB,SAAS,MAAM,mBAAmB;MACtD,EAAE,KAAK;MACP,CAAC,MAAM;IACT,EAAE"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
3
|
let _alloy_js_core = require("@alloy-js/core");
|
|
5
4
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
5
|
|
|
@@ -14,12 +13,7 @@ function LexicalScope(props) {
|
|
|
14
13
|
if (!(props.value instanceof _alloy_js_typescript.TSLexicalScope)) throw new TypeError("LexicalScope value must be a TSLexicalScope instance");
|
|
15
14
|
scope = props.value;
|
|
16
15
|
} else scope = (0, _alloy_js_typescript.createLexicalScope)(props.name ?? "Lexical scope", props);
|
|
17
|
-
return
|
|
18
|
-
value: scope,
|
|
19
|
-
get children() {
|
|
20
|
-
return props.children;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
16
|
+
return <_alloy_js_core.Scope value={scope}>{props.children}</_alloy_js_core.Scope>;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
//#endregion
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
1
|
import { Scope } from "@alloy-js/core";
|
|
3
2
|
import { TSLexicalScope, createLexicalScope } from "@alloy-js/typescript";
|
|
4
3
|
|
|
@@ -12,12 +11,7 @@ function LexicalScope(props) {
|
|
|
12
11
|
if (!(props.value instanceof TSLexicalScope)) throw new TypeError("LexicalScope value must be a TSLexicalScope instance");
|
|
13
12
|
scope = props.value;
|
|
14
13
|
} else scope = createLexicalScope(props.name ?? "Lexical scope", props);
|
|
15
|
-
return
|
|
16
|
-
value: scope,
|
|
17
|
-
get children() {
|
|
18
|
-
return props.children;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
14
|
+
return <Scope value={scope}>{props.children}</Scope>;
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexical-scope.mjs","names":[
|
|
1
|
+
{"version":3,"file":"lexical-scope.mjs","names":[],"sources":["../../../src/typescript/contexts/lexical-scope.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Scope, ScopePropsWithInfo, ScopePropsWithValue } from \"@alloy-js/core\";\nimport { createLexicalScope, TSLexicalScope } from \"@alloy-js/typescript\";\n\nexport interface LexicalScopePropsWithScopeValue extends ScopePropsWithValue {}\nexport interface LexicalScopePropsWithScopeInfo extends ScopePropsWithInfo {}\n\nexport type LexicalScopeProps =\n | LexicalScopePropsWithScopeValue\n | LexicalScopePropsWithScopeInfo;\n\n/**\n * A lexical scope for TypeScript, which contains declaration spaces for types and values. Declaration components will create symbols in this scope.\n */\nexport function LexicalScope(props: LexicalScopeProps) {\n let scope;\n if (\"value\" in props) {\n if (!(props.value instanceof TSLexicalScope)) {\n throw new TypeError(\n \"LexicalScope value must be a TSLexicalScope instance\"\n );\n }\n scope = props.value;\n } else {\n scope = createLexicalScope(props.name ?? \"Lexical scope\", props);\n }\n\n return <Scope value={scope}>{props.children}</Scope>;\n}\n"],"mappings":";;;;;;;AA+BA,SAAgB,aAAa,OAA0B;CACrD,IAAI;AACJ,KAAI,WAAW,OAAO;AACpB,MAAI,EAAE,MAAM,iBAAiB,gBAC3B,OAAM,IAAI,UACR,uDACD;AAEH,UAAQ,MAAM;OAEd,SAAQ,mBAAmB,MAAM,QAAQ,iBAAiB,MAAM;AAGlE,QAAO,CAAC,MAAM,OAAO,QAAQ,MAAM,SAAS,EAAE"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
3
|
let _alloy_js_core = require("@alloy-js/core");
|
|
5
4
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
5
|
|
|
@@ -12,12 +11,8 @@ let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
|
12
11
|
function MemberScope(props) {
|
|
13
12
|
const parentScope = (0, _alloy_js_typescript.useTSLexicalScopeIfPresent)();
|
|
14
13
|
const binder = props.ownerSymbol.binder ?? parentScope?.binder;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
get children() {
|
|
18
|
-
return props.children;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
14
|
+
const memberScope = (0, _alloy_js_core.createScope)(_alloy_js_typescript.TSMemberScope, "member-scope", parentScope, props.ownerSymbol, { binder });
|
|
15
|
+
return <_alloy_js_core.MemberScope value={memberScope}>{props.children}</_alloy_js_core.MemberScope>;
|
|
21
16
|
}
|
|
22
17
|
|
|
23
18
|
//#endregion
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
1
|
import { MemberScope as MemberScope$1, createScope } from "@alloy-js/core";
|
|
3
2
|
import { TSMemberScope, useTSLexicalScopeIfPresent } from "@alloy-js/typescript";
|
|
4
3
|
|
|
@@ -10,12 +9,8 @@ import { TSMemberScope, useTSLexicalScopeIfPresent } from "@alloy-js/typescript"
|
|
|
10
9
|
function MemberScope(props) {
|
|
11
10
|
const parentScope = useTSLexicalScopeIfPresent();
|
|
12
11
|
const binder = props.ownerSymbol.binder ?? parentScope?.binder;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
get children() {
|
|
16
|
-
return props.children;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
12
|
+
const memberScope = createScope(TSMemberScope, "member-scope", parentScope, props.ownerSymbol, { binder });
|
|
13
|
+
return <MemberScope$1 value={memberScope}>{props.children}</MemberScope$1>;
|
|
19
14
|
}
|
|
20
15
|
|
|
21
16
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member-scope.mjs","names":["
|
|
1
|
+
{"version":3,"file":"member-scope.mjs","names":["CoreMemberScope"],"sources":["../../../src/typescript/contexts/member-scope.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Children,\n MemberScope as CoreMemberScope,\n createScope\n} from \"@alloy-js/core\";\nimport {\n TSMemberScope,\n TSOutputSymbol,\n useTSLexicalScopeIfPresent\n} from \"@alloy-js/typescript\";\n\nexport interface MemberScopeProps {\n children: Children;\n\n /**\n * The symbol that this member scope will create member symbols on.\n */\n ownerSymbol: TSOutputSymbol;\n}\n\n/**\n * A member scope for TypeScript. Member declarations will create symbols\n * in this scope, which will be added to the owner symbol's members.\n */\nexport function MemberScope(props: MemberScopeProps) {\n const parentScope = useTSLexicalScopeIfPresent();\n const binder = props.ownerSymbol.binder ?? parentScope?.binder;\n const memberScope = createScope(\n TSMemberScope,\n \"member-scope\",\n parentScope,\n props.ownerSymbol,\n {\n binder\n }\n );\n\n return (\n <CoreMemberScope value={memberScope}>{props.children}</CoreMemberScope>\n );\n}\n"],"mappings":";;;;;;;;AA0CA,SAAgB,YAAY,OAAyB;CACnD,MAAM,cAAc,4BAA4B;CAChD,MAAM,SAAS,MAAM,YAAY,UAAU,aAAa;CACxD,MAAM,cAAc,YAClB,eACA,gBACA,aACA,MAAM,aACN,EACE,QACD,CACF;AAED,QACE,CAACA,cAAgB,OAAO,cAAc,MAAM,SAAS,EAAEA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-call-signature-props.mjs","names":[
|
|
1
|
+
{"version":3,"file":"get-call-signature-props.mjs","names":[],"sources":["../../../src/typescript/helpers/get-call-signature-props.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { defaultProps, splitProps } from \"@alloy-js/core\";\nimport { CallSignatureProps } from \"@alloy-js/typescript\";\n\n/**\n * Get the properties for a call signature, applying any defaults as necessary.\n *\n * @param props - The properties for the call signature.\n * @param defaults - Optional default properties to apply to the call signature.\n * @returns The properties for the call signature, with defaults applied as necessary.\n */\nexport function getCallSignatureProps(\n props: CallSignatureProps,\n defaults?: Partial<CallSignatureProps>\n) {\n const [callSignatureProps] = splitProps(props, [\n \"parameters\",\n \"parametersChildren\",\n \"typeParameters\",\n \"typeParametersChildren\",\n \"returnType\"\n ]);\n\n if (!defaults) {\n return callSignatureProps;\n }\n\n return defaultProps(callSignatureProps, defaults);\n}\n"],"mappings":";;;;;;;;;;AA4BA,SAAgB,sBACd,OACA,UACA;CACA,MAAM,CAAC,sBAAsB,WAAW,OAAO;EAC7C;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,KAAI,CAAC,SACH,QAAO;AAGT,QAAO,aAAa,oBAAoB,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.mjs","names":[
|
|
1
|
+
{"version":3,"file":"utilities.mjs","names":[],"sources":["../../../src/typescript/helpers/utilities.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Check if a string is a valid JavaScript identifier.\n *\n * @param identifier - The string to check.\n * @returns `true` if the string is a valid JavaScript identifier, `false` otherwise.\n */\nexport function isValidJSIdentifier(identifier: string) {\n return /^[\\p{ID_Start}$_][\\p{ID_Continue}$\\u200C\\u200D]*$/u.test(identifier);\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,oBAAoB,YAAoB;AACtD,QAAO,qDAAqD,KAAK,WAAW"}
|