powerlines 0.42.37 → 0.42.39
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/{api-BVTRS4-e.mjs → api-ObH5-iUb.mjs} +186 -138
- package/dist/api-ObH5-iUb.mjs.map +1 -0
- package/dist/{api-UG5GXKwF.cjs → api-XaP3Nf6H.cjs} +190 -142
- package/dist/{api-context-CEJ3s11k.mjs → api-context-DuZIIJsm.mjs} +2 -2
- package/dist/api-context-DuZIIJsm.mjs.map +1 -0
- package/dist/{api-context-BurprRit.cjs → api-context-g8U0DTyF.cjs} +5 -5
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/esbuild.cjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.mjs +1 -1
- package/dist/rolldown.cjs +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/{ts-morph-Cf4wz3E0.cjs → ts-morph-BvE8TMhv.cjs} +1 -1
- package/dist/{tsconfig-ChmbpAO7.cjs → tsconfig-BjkktvB9.cjs} +2 -2
- package/dist/tsdown.cjs +1 -1
- package/dist/tsup.cjs +1 -1
- package/dist/typescript/index.cjs +2 -2
- package/dist/unplugin.cjs +1 -1
- package/dist/unplugin.mjs +1 -1
- package/dist/vite.cjs +2 -2
- package/dist/webpack.cjs +1 -1
- package/package.json +8 -8
- package/dist/api-BVTRS4-e.mjs.map +0 -1
- package/dist/api-context-CEJ3s11k.mjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-AIJqnxB6.cjs');
|
|
2
|
-
const require_ts_morph = require('./ts-morph-
|
|
2
|
+
const require_ts_morph = require('./ts-morph-BvE8TMhv.cjs');
|
|
3
3
|
const require_utils = require('./utils.cjs');
|
|
4
4
|
const require_plugin_utils = require('./plugin-utils.cjs');
|
|
5
|
-
const require_api_context = require('./api-context-
|
|
6
|
-
const require_tsconfig = require('./tsconfig-
|
|
5
|
+
const require_api_context = require('./api-context-g8U0DTyF.cjs');
|
|
6
|
+
const require_tsconfig = require('./tsconfig-BjkktvB9.cjs');
|
|
7
7
|
let _storm_software_config_tools_logger_console = require("@storm-software/config-tools/logger/console");
|
|
8
8
|
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
9
9
|
let _stryke_fs_copy_file = require("@stryke/fs/copy-file");
|
|
@@ -31,11 +31,11 @@ let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-obje
|
|
|
31
31
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
32
32
|
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
33
33
|
let chalk = require("chalk");
|
|
34
|
-
chalk = require_chunk.__toESM(chalk);
|
|
34
|
+
chalk = require_chunk.__toESM(chalk, 1);
|
|
35
35
|
let defu = require("defu");
|
|
36
|
-
defu = require_chunk.__toESM(defu);
|
|
36
|
+
defu = require_chunk.__toESM(defu, 1);
|
|
37
37
|
let handlebars = require("handlebars");
|
|
38
|
-
handlebars = require_chunk.__toESM(handlebars);
|
|
38
|
+
handlebars = require_chunk.__toESM(handlebars, 1);
|
|
39
39
|
let _stryke_string_format_pretty_bytes = require("@stryke/string-format/pretty-bytes");
|
|
40
40
|
let ts_morph = require("ts-morph");
|
|
41
41
|
let _stryke_string_format_package = require("@stryke/string-format/package");
|
|
@@ -45,7 +45,7 @@ let _stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
|
45
45
|
|
|
46
46
|
//#region package.json
|
|
47
47
|
var name = "powerlines";
|
|
48
|
-
var version = "0.42.
|
|
48
|
+
var version = "0.42.39";
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/_internal/helpers/generate-types.ts
|
|
@@ -58,96 +58,135 @@ var version = "0.42.37";
|
|
|
58
58
|
function formatTypes(code = "") {
|
|
59
59
|
return code.replaceAll("#private;", "").replace(/__Ω/g, "");
|
|
60
60
|
}
|
|
61
|
-
async function
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
async function extractModuleDeclarations(ctx, filePath, name, text) {
|
|
62
|
+
const imports = [];
|
|
63
|
+
const exports = [];
|
|
64
|
+
const comment = text.match(new RegExp(`\\/\\*\\*(?s:.)*?@module\\s+${ctx.context.config.framework}:${name}(?s:.)*?\\*\\/\\s+`))?.find((comment) => (0, _stryke_type_checks_is_set_string.isSetString)(comment?.trim()));
|
|
65
|
+
const sourceFile = new ts_morph.Project({ useInMemoryFileSystem: true }).createSourceFile("module.d.ts", text);
|
|
66
|
+
for (const ref of sourceFile.getTypeReferenceDirectives()) if (ref.getFileName() && !ctx.context.builtins.some((builtin) => ref.getFileName().endsWith(builtin))) imports.push({
|
|
67
|
+
name: ref.getFileName(),
|
|
68
|
+
ambient: true
|
|
68
69
|
});
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
for (const statement of sourceFile.getStatements()) if (ts_morph.Node.isImportDeclaration(statement)) {
|
|
71
|
+
const moduleSpec = statement.getModuleSpecifierValue();
|
|
72
|
+
if (statement.getNamespaceImport()) imports.push({
|
|
73
|
+
name: moduleSpec,
|
|
74
|
+
specifiers: [{ name: statement.getNamespaceImport().getText() }],
|
|
75
|
+
all: true
|
|
76
|
+
});
|
|
77
|
+
else if (statement.getNamedImports().length > 0 || statement.getDefaultImport()) {
|
|
78
|
+
const specifiers = [];
|
|
79
|
+
if (statement.getDefaultImport()) specifiers.push({
|
|
80
|
+
name: statement.getDefaultImport().getText(),
|
|
81
|
+
default: true,
|
|
82
|
+
type: statement.isTypeOnly()
|
|
83
|
+
});
|
|
84
|
+
statement.getNamedImports().forEach((named) => {
|
|
85
|
+
specifiers.push({
|
|
86
|
+
name: named.getName(),
|
|
87
|
+
alias: named.getAliasNode()?.getText(),
|
|
88
|
+
type: statement.isTypeOnly()
|
|
82
89
|
});
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
});
|
|
91
|
+
imports.push({
|
|
92
|
+
name: moduleSpec,
|
|
93
|
+
specifiers
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
} else if (ts_morph.Node.isExportDeclaration(statement)) {
|
|
97
|
+
const moduleSpec = statement.getModuleSpecifierValue();
|
|
98
|
+
if (moduleSpec) {
|
|
85
99
|
let resolvedSpec = moduleSpec;
|
|
86
|
-
if (context.
|
|
87
|
-
const resolved = await context.resolve(moduleSpec, filePath);
|
|
88
|
-
if (resolved) {
|
|
89
|
-
const mapped = fileToModuleMap.get(resolved.id);
|
|
90
|
-
if (mapped) resolvedSpec = mapped;
|
|
91
|
-
else context.trace(`Could not resolve relative import '${moduleSpec}' from '${filePath}' to a builtin module. Keeping as-is.`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (namespaceImport) importLines.push(`\timport * as ${namespaceImport.getText()} from '${resolvedSpec}';`);
|
|
100
|
+
if (!ctx.context.builtins.includes(moduleSpec)) if (ctx.emitted.has(moduleSpec)) resolvedSpec = ctx.emitted.get(moduleSpec);
|
|
95
101
|
else {
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
for (const named of namedImports) {
|
|
99
|
-
const alias = named.getAliasNode()?.getText();
|
|
100
|
-
specifiers.push(alias ? `${named.getName()} as ${alias}` : named.getName());
|
|
101
|
-
}
|
|
102
|
-
if (specifiers.length > 0) {
|
|
103
|
-
const typeOnly = statement.isTypeOnly() ? " type" : "";
|
|
104
|
-
importLines.push(`\timport${typeOnly} { ${specifiers.join(", ")} } from '${resolvedSpec}';`);
|
|
105
|
-
}
|
|
102
|
+
const resolvedModule = await ctx.context.resolve(moduleSpec, filePath);
|
|
103
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(resolvedModule?.id)) resolvedSpec = resolvedModule.id;
|
|
106
104
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
105
|
+
const namedExports = statement.getNamedExports();
|
|
106
|
+
if (namedExports.length > 0) exports.push({
|
|
107
|
+
name: resolvedSpec,
|
|
108
|
+
text: statement.getText(),
|
|
109
|
+
fullText: statement.getFullText(),
|
|
110
|
+
specifiers: namedExports.map((named) => ({
|
|
111
|
+
name: named.getName(),
|
|
112
|
+
alias: named.getAliasNode()?.getText(),
|
|
113
|
+
type: statement.isTypeOnly()
|
|
114
|
+
})),
|
|
115
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n").trim()
|
|
116
|
+
});
|
|
117
|
+
else exports.push({
|
|
118
|
+
name: resolvedSpec,
|
|
119
|
+
text: statement.getText(),
|
|
120
|
+
fullText: statement.getFullText(),
|
|
121
|
+
all: true,
|
|
122
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n").trim()
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
const specifiers = statement.getNamedExports().map((named) => ({
|
|
126
|
+
name: named.getName(),
|
|
127
|
+
alias: named.getAliasNode()?.getText(),
|
|
128
|
+
type: statement.isTypeOnly()
|
|
129
|
+
}));
|
|
130
|
+
if (specifiers.length > 0) exports.push({
|
|
131
|
+
text: statement.getText(),
|
|
132
|
+
fullText: statement.getFullText(),
|
|
133
|
+
specifiers,
|
|
134
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
|
|
135
|
+
});
|
|
136
136
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
} else if (ts_morph.Node.isExportAssignment(statement)) exports.push({
|
|
138
|
+
text: statement.getText(),
|
|
139
|
+
fullText: statement.getFullText(),
|
|
140
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
|
|
141
|
+
});
|
|
142
|
+
else if (ts_morph.Node.isFunctionDeclaration(statement) && statement.isExported() && statement.getNameNode()) exports.push({
|
|
143
|
+
text: statement.getText(),
|
|
144
|
+
fullText: statement.getFullText(),
|
|
145
|
+
specifiers: [{ name: statement.getNameNode().getText() }],
|
|
146
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
|
|
147
|
+
});
|
|
148
|
+
else if (ts_morph.Node.isVariableStatement(statement) && statement.isExported()) exports.push({
|
|
149
|
+
text: statement.getText(),
|
|
150
|
+
fullText: statement.getFullText(),
|
|
151
|
+
specifiers: statement.getDeclarationList().getDeclarations().filter((decl) => decl.getNameNode() && ts_morph.Node.isIdentifier(decl.getNameNode())).map((decl) => ({ name: decl.getNameNode().getText() })),
|
|
152
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
|
|
153
|
+
});
|
|
154
|
+
else if (ts_morph.Node.isClassDeclaration(statement) && statement.isExported()) {
|
|
155
|
+
const nameNode = statement.getNameNode();
|
|
156
|
+
exports.push({
|
|
157
|
+
text: statement.getText(),
|
|
158
|
+
fullText: statement.getFullText(),
|
|
159
|
+
specifiers: nameNode ? [{ name: nameNode.getText() }] : void 0,
|
|
160
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
|
|
161
|
+
});
|
|
162
|
+
} else if (ts_morph.Node.isInterfaceDeclaration(statement) && statement.isExported()) {
|
|
163
|
+
const nameNode = statement.getNameNode();
|
|
164
|
+
exports.push({
|
|
165
|
+
text: statement.getText(),
|
|
166
|
+
fullText: statement.getFullText(),
|
|
167
|
+
specifiers: nameNode ? [{ name: nameNode.getText() }] : void 0,
|
|
168
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
|
|
169
|
+
});
|
|
170
|
+
} else if (ts_morph.Node.isTypeAliasDeclaration(statement) && statement.isExported()) {
|
|
171
|
+
const nameNode = statement.getNameNode();
|
|
172
|
+
exports.push({
|
|
173
|
+
text: statement.getText(),
|
|
174
|
+
fullText: statement.getFullText(),
|
|
175
|
+
specifiers: nameNode ? [{ name: nameNode.getText() }] : void 0,
|
|
176
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
|
|
177
|
+
});
|
|
178
|
+
} else if (ctx.context.config.output.sourceMap || !statement.getFullText().includes("//# sourceMappingURL=")) exports.push({
|
|
179
|
+
text: statement.getText(),
|
|
180
|
+
fullText: statement.getFullText(),
|
|
181
|
+
comment: statement.getLeadingCommentRanges().filter((c) => (0, _stryke_type_checks_is_set_string.isSetString)(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
|
|
182
|
+
});
|
|
147
183
|
return {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
184
|
+
name,
|
|
185
|
+
text,
|
|
186
|
+
sourceFile,
|
|
187
|
+
comment,
|
|
188
|
+
imports,
|
|
189
|
+
exports
|
|
151
190
|
};
|
|
152
191
|
}
|
|
153
192
|
/**
|
|
@@ -194,68 +233,77 @@ async function emitBuiltinTypes(context, files) {
|
|
|
194
233
|
directives: []
|
|
195
234
|
};
|
|
196
235
|
}
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
236
|
+
const ctx = {
|
|
237
|
+
context,
|
|
238
|
+
modules: [],
|
|
239
|
+
emitted: /* @__PURE__ */ new Map()
|
|
240
|
+
};
|
|
241
|
+
await Promise.all(emittedFiles.map(async (emittedFile) => {
|
|
200
242
|
const filePath = (0, _stryke_path_append.appendPath)(emittedFile.filePath, context.workspaceConfig.workspaceRoot);
|
|
201
243
|
if (!filePath.endsWith(".map") && (0, _stryke_path_file_path_fns.findFileName)(filePath) !== "tsconfig.tsbuildinfo" && (0, _stryke_path_is_parent_path.isParentPath)(filePath, context.builtinsPath)) {
|
|
202
|
-
const
|
|
203
|
-
if (context.builtins.includes(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
filePath,
|
|
207
|
-
text: emittedFile.text
|
|
208
|
-
});
|
|
244
|
+
const moduleName = (0, _stryke_path_replace.replaceExtension)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)(filePath, context.builtinsPath), (0, _stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)), "", { fullExtension: true });
|
|
245
|
+
if (context.builtins.includes(moduleName)) {
|
|
246
|
+
ctx.emitted.set(filePath, moduleName);
|
|
247
|
+
ctx.modules.push(await extractModuleDeclarations(ctx, filePath, moduleName, emittedFile.text));
|
|
209
248
|
}
|
|
210
249
|
}
|
|
211
|
-
}
|
|
212
|
-
const
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
context.trace(`Processing emitted type declaration file: ${entry.filePath}`);
|
|
224
|
-
const moduleId = fileToModuleMap.get(entry.filePath);
|
|
225
|
-
const moduleDecl = await writeModuleDeclarations(context, entry.filePath, moduleId, entry.text, fileToModuleMap);
|
|
226
|
-
if (!isFirst) code += "\n\n";
|
|
227
|
-
isFirst = false;
|
|
228
|
-
code += moduleDecl.content;
|
|
229
|
-
for (const dep of moduleDecl.ambient) if (dep.external) {
|
|
230
|
-
const directive = dep.id;
|
|
231
|
-
if (!directives.includes(directive)) directives.push(directive);
|
|
232
|
-
} else if (builtins.some((builtin) => builtin.id === dep.id)) ambientModules.add(builtins.find((builtin) => builtin.id === dep.id).path);
|
|
233
|
-
else if (builtins.some((builtin) => (0, _stryke_path_replace.replaceExtension)(builtin.path) === (0, _stryke_path_replace.replaceExtension)(dep.id))) ambientModules.add(dep.id);
|
|
234
|
-
else {
|
|
235
|
-
const resolved = await context.resolve(dep.id, entry.filePath);
|
|
236
|
-
if (resolved) {
|
|
237
|
-
for (const name of [
|
|
238
|
-
resolved.id,
|
|
239
|
-
`${resolved.id}.d.ts`,
|
|
240
|
-
`${resolved.id}.d.mts`,
|
|
241
|
-
`${resolved.id}.d.cts`,
|
|
242
|
-
(0, _stryke_path_replace.replaceExtension)(resolved.id, ".d.ts"),
|
|
243
|
-
(0, _stryke_path_replace.replaceExtension)(resolved.id, ".d.mts"),
|
|
244
|
-
(0, _stryke_path_replace.replaceExtension)(resolved.id, ".d.cts"),
|
|
245
|
-
`${resolved.id}/index.d.ts`
|
|
246
|
-
]) if (emittedContentMap.has(name)) {
|
|
247
|
-
ambientModules.add(name);
|
|
250
|
+
}));
|
|
251
|
+
const commonDeclarations = [];
|
|
252
|
+
for (const mod of ctx.modules) for (const importRef of mod.imports.filter((importRef) => context.builtins.some((builtin) => importRef.name.endsWith(`:${builtin}`)))) {
|
|
253
|
+
const moduleRef = ctx.modules.find((moduleRef) => importRef.name.endsWith(`:${moduleRef.name}`));
|
|
254
|
+
if (moduleRef) {
|
|
255
|
+
let declaration;
|
|
256
|
+
for (const decl of moduleRef.exports.filter((decl) => (0, _stryke_type_checks_is_set_object.isSetObject)(decl))) {
|
|
257
|
+
const specifiers = decl.specifiers?.filter((specifier) => importRef.specifiers?.some((s) => (specifier.alias ? specifier.alias : specifier.name) === (s.alias ? s.alias : s.name)));
|
|
258
|
+
if (specifiers && specifiers.length > 0) {
|
|
259
|
+
importRef.specifiers = importRef.specifiers?.filter((s) => !specifiers.some((specifier) => (specifier.alias ? specifier.alias : specifier.name) === (s.alias ? s.alias : s.name)));
|
|
260
|
+
if (importRef.specifiers && importRef.specifiers.length === 0 && !importRef.all && !importRef.ambient) mod.imports = mod.imports.filter((imp) => imp.name !== importRef.name);
|
|
261
|
+
declaration = decl;
|
|
248
262
|
break;
|
|
249
263
|
}
|
|
250
264
|
}
|
|
265
|
+
if (declaration) {
|
|
266
|
+
for (const decl of moduleRef.exports.filter((decl) => (0, _stryke_type_checks_is_set_object.isSetObject)(decl) && !decl.specifiers?.some((s) => declaration?.specifiers?.some((specifier) => (specifier.alias ? specifier.alias : specifier.name) === (s.alias ? s.alias : s.name))))) {
|
|
267
|
+
const exportModuleRef = decl;
|
|
268
|
+
if ((exportModuleRef.specifiers?.some((s) => s.alias || s.name) || exportModuleRef.name) && new RegExp(`(^|\\s|\\n|\\r\\n|\\(|\\)|<|>|{|}|\\[|\\]|\\!|\\?|\\.|,|\\*|&|:)(${exportModuleRef.specifiers?.map((s) => `${s.alias ? `${s.alias}|` : ""}${s.name}`).join("|") || exportModuleRef.name})($|\\s|\\n|\\r\\n|\\(|\\)|<|>|{|}|\\[|\\]|\\!|\\?|\\.|,|\\*|&|:|;)`).test(declaration.text)) commonDeclarations.push(exportModuleRef);
|
|
269
|
+
}
|
|
270
|
+
commonDeclarations.push(declaration);
|
|
271
|
+
}
|
|
251
272
|
}
|
|
252
273
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
274
|
+
let code = "";
|
|
275
|
+
const directives = [];
|
|
276
|
+
for (const commonDeclaration of commonDeclarations) {
|
|
277
|
+
code += formatTypes(`${commonDeclaration.comment?.trim() ? commonDeclaration.comment.trim() : ""}${commonDeclaration.comment?.trim() ? "\n" : ""}${formatTypes(commonDeclaration.text.replace(/\s*export\s*/, "").replace(/\s*declare\s*interface\s*/, "interface ").replace(/\s*declare\s*type\s*/, "type "))}`);
|
|
278
|
+
code += "\n\n";
|
|
279
|
+
}
|
|
280
|
+
for (const mod of ctx.modules) {
|
|
281
|
+
code += mod.comment ? `${mod.comment.trim()}\n` : "";
|
|
282
|
+
code += `declare module "${context.config.framework}:${mod.name}" { \n`;
|
|
283
|
+
for (const importRef of mod.imports) if (importRef.ambient) code += directives.push(importRef.name);
|
|
284
|
+
else if (importRef.all) code += `\timport * as ${(0, _stryke_path_file_path_fns.findFileName)(importRef.name)} from "${importRef.name}";\n`;
|
|
285
|
+
else if (importRef.specifiers) {
|
|
286
|
+
const typeOnly = importRef.specifiers.every((s) => s.type) ? " type" : "";
|
|
287
|
+
const specifiers = importRef.specifiers.map((s) => s.alias ? `${s.name} as ${s.alias}` : s.name).join(", ");
|
|
288
|
+
code += `\timport${typeOnly} { ${specifiers} } from "${importRef.name}";\n`;
|
|
258
289
|
}
|
|
290
|
+
if (mod.imports.length > 0) code += "\n";
|
|
291
|
+
for (const exportRef of mod.exports.filter((e) => (0, _stryke_type_checks_is_string.isString)(e) || !e.specifiers || !commonDeclarations.some((commonDecl) => commonDecl.specifiers && commonDecl.specifiers.some((specifier) => e.specifiers?.some((s) => (s.alias ? s.alias : s.name) === (specifier.alias ? specifier.alias : specifier.name)))))) if ((0, _stryke_type_checks_is_set_string.isSetString)(exportRef)) code += `${exportRef}\n`;
|
|
292
|
+
else if (exportRef.name) {
|
|
293
|
+
if (exportRef.all) code += `${exportRef.comment?.trim() ? exportRef.comment.trim() : ""}${exportRef.comment?.trim() ? "\n" : ""}export * from "${exportRef.name}";\n`;
|
|
294
|
+
else if (exportRef.specifiers) {
|
|
295
|
+
if (exportRef.comment?.trim()) code += `${exportRef.comment.trim()}\n`;
|
|
296
|
+
code += `\texport${exportRef.specifiers.every((s) => s.type) ? " type" : ""} { ${exportRef.specifiers.map((s) => s.alias ? `${s.name} as ${s.alias}` : s.name).join(", ")} } from "${exportRef.name}";\n`;
|
|
297
|
+
}
|
|
298
|
+
} else code += `${exportRef.comment?.trim() ? exportRef.comment.trim() : ""}${exportRef.comment?.trim() ? "\n" : ""}${formatTypes(exportRef.text.replace(/\s*export\s*declare\s*/, "export ").replace(/\s*declare\s*/, " "))}\n`;
|
|
299
|
+
mod.exports.filter((e) => !(0, _stryke_type_checks_is_string.isString)(e) && e.specifiers && commonDeclarations.some((commonDeclaration) => commonDeclaration.specifiers && commonDeclaration.specifiers.some((specifier) => e.specifiers?.some((s) => (s.alias ? s.alias : s.name) === (specifier.alias ? specifier.alias : specifier.name))))).forEach((e, i, arr) => {
|
|
300
|
+
if (i === 0) code += "\nexport { ";
|
|
301
|
+
else code += ", ";
|
|
302
|
+
code += `${e?.specifiers?.filter((s) => commonDeclarations.some((commonDeclaration) => commonDeclaration.specifiers && commonDeclaration.specifiers.some((specifier) => (s.alias ? s.alias : s.name) === (specifier.alias ? specifier.alias : specifier.name)))).map((s) => s.alias ? `${s.name} as ${s.alias}` : s.name).join(", ") || ""}`;
|
|
303
|
+
if (i === arr.length - 1) code += ` };\n`;
|
|
304
|
+
});
|
|
305
|
+
code += "}";
|
|
306
|
+
code += "\n\n";
|
|
259
307
|
}
|
|
260
308
|
code = await (0, require_utils.utils_exports.format)(context, context.typesPath, code);
|
|
261
309
|
context.debug(`A TypeScript declaration file (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new Blob((0, _stryke_convert_to_array.toArray)(code)).size)}) emitted for the built-in modules types.`);
|
|
@@ -1876,7 +1876,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
1876
1876
|
*/
|
|
1877
1877
|
get alias() {
|
|
1878
1878
|
return this.builtins.reduce((ret, id) => {
|
|
1879
|
-
const moduleId = `${this.config?.framework || "powerlines"}:${id.replace(
|
|
1879
|
+
const moduleId = `${this.config?.framework || "powerlines"}:${id.replace(/^.*:/, "")}`;
|
|
1880
1880
|
if (!ret[moduleId]) {
|
|
1881
1881
|
const path = this.fs.paths[id];
|
|
1882
1882
|
if (path) ret[moduleId] = path;
|
|
@@ -2981,4 +2981,4 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
2981
2981
|
|
|
2982
2982
|
//#endregion
|
|
2983
2983
|
export { FileId as a, FileStorage as c, writeMetaFile as d, callHook as f, PowerlinesContext as i, FileSystem as l, PowerlinesEnvironmentContext as n, FileMetadata as o, mergeConfigs as p, createPluginContext as r, FileMetadata_KeyValuePair as s, PowerlinesAPIContext as t, _capnpFileId as u };
|
|
2984
|
-
//# sourceMappingURL=api-context-
|
|
2984
|
+
//# sourceMappingURL=api-context-DuZIIJsm.mjs.map
|