@lynx-js/rspeedy 0.8.7 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/bin/rspeedy.js +2 -2
  3. package/dist/cli/main.js +414 -0
  4. package/dist/cli/start.js +171 -0
  5. package/dist/index.d.ts +2971 -0
  6. package/dist/index.js +39556 -0
  7. package/dist/register/hooks.js +552 -0
  8. package/dist/register/index.js +22 -0
  9. package/dist/src_cli_build_ts.js +47 -0
  10. package/dist/src_cli_commands_ts.js +60 -0
  11. package/dist/src_cli_dev_ts.js +87 -0
  12. package/dist/src_cli_exit_ts.js +111 -0
  13. package/dist/src_cli_inspect_ts.js +42 -0
  14. package/dist/src_cli_preview_ts.js +49 -0
  15. package/dist/src_config_loadConfig_ts-src_create-rspeedy_ts.js +39311 -0
  16. package/dist/src_plugins_api_plugin_ts.js +32 -0
  17. package/dist/src_plugins_chunkLoading_plugin_ts.js +35 -0
  18. package/dist/src_plugins_dev_plugin_ts.js +141 -0
  19. package/dist/src_plugins_index_ts.js +60 -0
  20. package/dist/src_plugins_inspect_plugin_ts.js +48 -0
  21. package/dist/src_plugins_minify_plugin_ts.js +85 -0
  22. package/dist/src_plugins_optimization_plugin_ts.js +25 -0
  23. package/dist/src_plugins_output_plugin_ts.js +46 -0
  24. package/dist/src_plugins_resolve_plugin_ts.js +21 -0
  25. package/dist/src_plugins_rsdoctor_plugin_ts.js +59 -0
  26. package/dist/src_plugins_sourcemap_plugin_ts.js +99 -0
  27. package/dist/src_plugins_stats_plugin_ts.js +26 -0
  28. package/dist/src_plugins_swc_plugin_ts.js +36 -0
  29. package/dist/src_plugins_target_plugin_ts.js +45 -0
  30. package/dist/src_version_ts.js +18 -0
  31. package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1435 -0
  32. package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt +1 -0
  33. package/dist/vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js +1761 -0
  34. package/dist/vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1067 -0
  35. package/dist/vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be.js +416 -0
  36. package/package.json +36 -23
  37. package/LICENSE +0 -202
  38. package/lib/api.d.ts +0 -46
  39. package/lib/api.js +0 -2
  40. package/lib/cli/build.d.ts +0 -4
  41. package/lib/cli/build.js +0 -32
  42. package/lib/cli/commands.d.ts +0 -5
  43. package/lib/cli/commands.js +0 -45
  44. package/lib/cli/dev.d.ts +0 -4
  45. package/lib/cli/dev.js +0 -75
  46. package/lib/cli/exit.d.ts +0 -1
  47. package/lib/cli/exit.js +0 -51
  48. package/lib/cli/inspect.d.ts +0 -8
  49. package/lib/cli/inspect.js +0 -30
  50. package/lib/cli/main.d.ts +0 -1
  51. package/lib/cli/main.js +0 -39
  52. package/lib/cli/preview.d.ts +0 -4
  53. package/lib/cli/preview.js +0 -31
  54. package/lib/cli/start.d.ts +0 -6
  55. package/lib/cli/start.js +0 -88
  56. package/lib/config/defaults.d.ts +0 -2
  57. package/lib/config/defaults.js +0 -32
  58. package/lib/config/defineConfig.d.ts +0 -22
  59. package/lib/config/defineConfig.js +0 -24
  60. package/lib/config/dev/client.d.ts +0 -15
  61. package/lib/config/dev/client.js +0 -2
  62. package/lib/config/dev/index.d.ts +0 -173
  63. package/lib/config/dev/index.js +0 -2
  64. package/lib/config/index.d.ts +0 -172
  65. package/lib/config/index.js +0 -2
  66. package/lib/config/loadConfig.d.ts +0 -50
  67. package/lib/config/loadConfig.js +0 -98
  68. package/lib/config/mergeRspeedyConfig.d.ts +0 -36
  69. package/lib/config/mergeRspeedyConfig.js +0 -42
  70. package/lib/config/output/css-modules.d.ts +0 -84
  71. package/lib/config/output/css-modules.js +0 -2
  72. package/lib/config/output/dist-path.d.ts +0 -19
  73. package/lib/config/output/dist-path.js +0 -2
  74. package/lib/config/output/filename.d.ts +0 -167
  75. package/lib/config/output/filename.js +0 -2
  76. package/lib/config/output/index.d.ts +0 -324
  77. package/lib/config/output/index.js +0 -2
  78. package/lib/config/output/minify.d.ts +0 -80
  79. package/lib/config/output/minify.js +0 -2
  80. package/lib/config/output/source-map.d.ts +0 -68
  81. package/lib/config/output/source-map.js +0 -2
  82. package/lib/config/performance/chunk-split.d.ts +0 -192
  83. package/lib/config/performance/chunk-split.js +0 -2
  84. package/lib/config/performance/index.d.ts +0 -165
  85. package/lib/config/performance/index.js +0 -2
  86. package/lib/config/rsbuild/entry.d.ts +0 -3
  87. package/lib/config/rsbuild/entry.js +0 -31
  88. package/lib/config/rsbuild/index.d.ts +0 -4
  89. package/lib/config/rsbuild/index.js +0 -75
  90. package/lib/config/server/index.d.ts +0 -91
  91. package/lib/config/server/index.js +0 -2
  92. package/lib/config/source/decorators.d.ts +0 -43
  93. package/lib/config/source/decorators.js +0 -2
  94. package/lib/config/source/entry.d.ts +0 -84
  95. package/lib/config/source/entry.js +0 -2
  96. package/lib/config/source/index.d.ts +0 -474
  97. package/lib/config/source/index.js +0 -2
  98. package/lib/config/source/transformImport.d.ts +0 -106
  99. package/lib/config/source/transformImport.js +0 -2
  100. package/lib/config/tools/css-extract.d.ts +0 -72
  101. package/lib/config/tools/css-extract.js +0 -2
  102. package/lib/config/tools/css-loader.d.ts +0 -130
  103. package/lib/config/tools/css-loader.js +0 -2
  104. package/lib/config/tools/index.d.ts +0 -170
  105. package/lib/config/tools/index.js +0 -2
  106. package/lib/config/validate.d.ts +0 -4
  107. package/lib/config/validate.js +0 -28877
  108. package/lib/create-rspeedy.d.ts +0 -52
  109. package/lib/create-rspeedy.js +0 -49
  110. package/lib/debug.d.ts +0 -3
  111. package/lib/debug.js +0 -25
  112. package/lib/index.d.ts +0 -46
  113. package/lib/index.js +0 -11
  114. package/lib/plugins/api.plugin.d.ts +0 -3
  115. package/lib/plugins/api.plugin.js +0 -25
  116. package/lib/plugins/chunkLoading.plugin.d.ts +0 -2
  117. package/lib/plugins/chunkLoading.plugin.js +0 -43
  118. package/lib/plugins/dev.plugin.d.ts +0 -5
  119. package/lib/plugins/dev.plugin.js +0 -137
  120. package/lib/plugins/index.d.ts +0 -3
  121. package/lib/plugins/index.js +0 -49
  122. package/lib/plugins/inspect.plugin.d.ts +0 -4
  123. package/lib/plugins/inspect.plugin.js +0 -39
  124. package/lib/plugins/minify.plugin.d.ts +0 -3
  125. package/lib/plugins/minify.plugin.js +0 -89
  126. package/lib/plugins/optimization.plugin.d.ts +0 -2
  127. package/lib/plugins/optimization.plugin.js +0 -31
  128. package/lib/plugins/output.plugin.d.ts +0 -3
  129. package/lib/plugins/output.plugin.js +0 -34
  130. package/lib/plugins/resolve.plugin.d.ts +0 -2
  131. package/lib/plugins/resolve.plugin.js +0 -38
  132. package/lib/plugins/rsdoctor.plugin.d.ts +0 -3
  133. package/lib/plugins/rsdoctor.plugin.js +0 -48
  134. package/lib/plugins/sourcemap.plugin.d.ts +0 -2
  135. package/lib/plugins/sourcemap.plugin.js +0 -86
  136. package/lib/plugins/stats.plugin.d.ts +0 -2
  137. package/lib/plugins/stats.plugin.js +0 -20
  138. package/lib/plugins/swc.plugin.d.ts +0 -2
  139. package/lib/plugins/swc.plugin.js +0 -21
  140. package/lib/plugins/target.plugin.d.ts +0 -2
  141. package/lib/plugins/target.plugin.js +0 -22
  142. package/lib/utils/getESVersionTarget.d.ts +0 -1
  143. package/lib/utils/getESVersionTarget.js +0 -7
  144. package/lib/utils/is-ci.d.ts +0 -1
  145. package/lib/utils/is-ci.js +0 -7
  146. package/lib/utils/is-lynx.d.ts +0 -2
  147. package/lib/utils/is-lynx.js +0 -6
  148. package/lib/utils/is-web.d.ts +0 -2
  149. package/lib/utils/is-web.js +0 -6
  150. package/lib/version.d.ts +0 -4
  151. package/lib/version.js +0 -15
  152. package/lib/webpack/CompilationIdPlugin.d.ts +0 -4
  153. package/lib/webpack/CompilationIdPlugin.js +0 -20
  154. package/lib/webpack/EvalSourceMapDevToolPlugin.d.ts +0 -9
  155. package/lib/webpack/EvalSourceMapDevToolPlugin.js +0 -15
  156. package/lib/webpack/ProvidePlugin.d.ts +0 -9
  157. package/lib/webpack/ProvidePlugin.js +0 -15
  158. package/lib/webpack/SourceMapDevToolPlugin.d.ts +0 -9
  159. package/lib/webpack/SourceMapDevToolPlugin.js +0 -15
  160. package/register/data.d.ts +0 -9
  161. package/register/hooks.js +0 -146
  162. package/register/index.js +0 -47
  163. /package/{register → dist/register}/index.d.ts +0 -0
@@ -0,0 +1,552 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_typescript__ from "typescript";
3
+ const FLAG_REPLACE_WITH_OPEN_PAREN = 1;
4
+ const FLAG_REPLACE_WITH_CLOSE_PAREN = 2;
5
+ const FLAG_REPLACE_WITH_SEMI = 3;
6
+ function getSpace(input, start, end) {
7
+ let out = "";
8
+ for(let i = start; i < end; i++){
9
+ const charCode = input.charCodeAt(i);
10
+ switch(charCode){
11
+ case 10:
12
+ out += "\n";
13
+ break;
14
+ case 13:
15
+ out += "\r";
16
+ break;
17
+ default:
18
+ out += " ";
19
+ }
20
+ }
21
+ return out;
22
+ }
23
+ class BlankString {
24
+ constructor(input){
25
+ this.__input = input;
26
+ this.__ranges = [];
27
+ }
28
+ blankButStartWithOpenParen(start, end) {
29
+ this.__ranges.push(FLAG_REPLACE_WITH_OPEN_PAREN, start, end);
30
+ }
31
+ blankButEndWithCloseParen(start, end) {
32
+ this.__ranges.push(0, start, end - 1);
33
+ this.__ranges.push(FLAG_REPLACE_WITH_CLOSE_PAREN, end - 1, end);
34
+ }
35
+ blankButStartWithSemi(start, end) {
36
+ this.__ranges.push(FLAG_REPLACE_WITH_SEMI, start, end);
37
+ }
38
+ blank(start, end) {
39
+ this.__ranges.push(0, start, end);
40
+ }
41
+ toString() {
42
+ const ranges = this.__ranges;
43
+ const input = this.__input;
44
+ if (0 === ranges.length) return input;
45
+ let out = "";
46
+ let previousEnd = 0;
47
+ const max = Math.max;
48
+ for(let i = 0; i < ranges.length; i += 3){
49
+ const flags = ranges[i];
50
+ let rangeStart = ranges[i + 1];
51
+ const rangeEnd = ranges[i + 2];
52
+ rangeStart = max(rangeStart, previousEnd);
53
+ out += input.slice(previousEnd, rangeStart);
54
+ if (flags === FLAG_REPLACE_WITH_CLOSE_PAREN) {
55
+ out += ")";
56
+ rangeStart += 1;
57
+ } else if (flags === FLAG_REPLACE_WITH_SEMI) {
58
+ out += ";";
59
+ rangeStart += 1;
60
+ } else if (flags === FLAG_REPLACE_WITH_OPEN_PAREN) {
61
+ out += "(";
62
+ rangeStart += 1;
63
+ }
64
+ previousEnd = rangeEnd;
65
+ out += getSpace(input, rangeStart, previousEnd);
66
+ }
67
+ return out + input.slice(previousEnd);
68
+ }
69
+ }
70
+ const SK = __WEBPACK_EXTERNAL_MODULE_typescript__["default"].SyntaxKind;
71
+ const VISIT_BLANKED = "";
72
+ const VISITED_JS = null;
73
+ const languageOptions = {
74
+ languageVersion: __WEBPACK_EXTERNAL_MODULE_typescript__["default"].ScriptTarget.ESNext,
75
+ impliedNodeFormat: __WEBPACK_EXTERNAL_MODULE_typescript__["default"].ModuleKind.ESNext
76
+ };
77
+ const scanner = __WEBPACK_EXTERNAL_MODULE_typescript__["default"].createScanner(__WEBPACK_EXTERNAL_MODULE_typescript__["default"].ScriptTarget.ESNext, true, __WEBPACK_EXTERNAL_MODULE_typescript__["default"].LanguageVariant.Standard);
78
+ if (__WEBPACK_EXTERNAL_MODULE_typescript__["default"].JSDocParsingMode) {
79
+ languageOptions.jsDocParsingMode = __WEBPACK_EXTERNAL_MODULE_typescript__["default"].JSDocParsingMode.ParseNone;
80
+ scanner.setJSDocParsingMode(__WEBPACK_EXTERNAL_MODULE_typescript__["default"].JSDocParsingMode.ParseNone);
81
+ }
82
+ let src = "";
83
+ let str = new BlankString("");
84
+ let ast;
85
+ let onError;
86
+ let seenJS = false;
87
+ let parentStatement;
88
+ function tsBlankSpace(input, onErrorArg) {
89
+ return blankSourceFile(__WEBPACK_EXTERNAL_MODULE_typescript__["default"].createSourceFile("input.ts", input, languageOptions, false, __WEBPACK_EXTERNAL_MODULE_typescript__["default"].ScriptKind.TS), onErrorArg);
90
+ }
91
+ function blankSourceFile(source, onErrorArg) {
92
+ try {
93
+ const input = source.getFullText(source);
94
+ src = input;
95
+ str = new BlankString(input);
96
+ onError = onErrorArg;
97
+ scanner.setText(input);
98
+ ast = source;
99
+ visitNodeArray(ast.statements, true, false);
100
+ return str.toString();
101
+ } finally{
102
+ scanner.setText("");
103
+ onError = void 0;
104
+ ast = void 0;
105
+ str = void 0;
106
+ src = "";
107
+ seenJS = false;
108
+ parentStatement = void 0;
109
+ }
110
+ }
111
+ function visitUnknownNodeArray(nodes) {
112
+ if (0 === nodes.length) return VISITED_JS;
113
+ return visitNodeArray(nodes, __WEBPACK_EXTERNAL_MODULE_typescript__["default"].isStatement(nodes[0]), false);
114
+ }
115
+ function visitNodeArray(nodes, isStatementLike, isFunctionBody) {
116
+ const previousParentStatement = parentStatement;
117
+ const previousSeenJS = seenJS;
118
+ if (isFunctionBody) seenJS = false;
119
+ for(let i = 0; i < nodes.length; i++){
120
+ const n = nodes[i];
121
+ if (isStatementLike) parentStatement = n;
122
+ if (visitStatementLike(n) === VISITED_JS) seenJS = true;
123
+ }
124
+ parentStatement = previousParentStatement;
125
+ if (isFunctionBody) seenJS = previousSeenJS;
126
+ return seenJS ? VISITED_JS : VISIT_BLANKED;
127
+ }
128
+ function visitStatementLike(node) {
129
+ const kind = node.kind;
130
+ switch(kind){
131
+ case SK.ImportDeclaration:
132
+ return visitImportDeclaration(node);
133
+ case SK.ExportDeclaration:
134
+ return visitExportDeclaration(node);
135
+ case SK.ExportAssignment:
136
+ return visitExportAssignment(node);
137
+ case SK.ImportEqualsDeclaration:
138
+ onError && onError(node);
139
+ return VISITED_JS;
140
+ }
141
+ return innerVisitor(node, kind);
142
+ }
143
+ function visitor(node) {
144
+ const r = innerVisitor(node, node.kind);
145
+ if (r === VISITED_JS) seenJS = true;
146
+ return r;
147
+ }
148
+ function innerVisitor(node, kind) {
149
+ switch(kind){
150
+ case SK.Identifier:
151
+ return VISITED_JS;
152
+ case SK.VariableDeclaration:
153
+ return visitVariableDeclaration(node);
154
+ case SK.VariableStatement:
155
+ return visitVariableStatement(node);
156
+ case SK.CallExpression:
157
+ case SK.NewExpression:
158
+ return visitCallOrNewExpression(node);
159
+ case SK.TypeAliasDeclaration:
160
+ case SK.InterfaceDeclaration:
161
+ blankStatement(node);
162
+ return VISIT_BLANKED;
163
+ case SK.ClassDeclaration:
164
+ case SK.ClassExpression:
165
+ return visitClassLike(node);
166
+ case SK.ExpressionWithTypeArguments:
167
+ return visitExpressionWithTypeArguments(node);
168
+ case SK.PropertyDeclaration:
169
+ return visitPropertyDeclaration(node);
170
+ case SK.NonNullExpression:
171
+ return visitNonNullExpression(node);
172
+ case SK.SatisfiesExpression:
173
+ case SK.AsExpression:
174
+ return visitTypeAssertion(node);
175
+ case SK.ArrowFunction:
176
+ case SK.FunctionDeclaration:
177
+ case SK.MethodDeclaration:
178
+ case SK.Constructor:
179
+ case SK.FunctionExpression:
180
+ case SK.GetAccessor:
181
+ case SK.SetAccessor:
182
+ return visitFunctionLikeDeclaration(node, kind);
183
+ case SK.EnumDeclaration:
184
+ return visitEnum(node);
185
+ case SK.ModuleDeclaration:
186
+ return visitModule(node);
187
+ case SK.IndexSignature:
188
+ blankExact(node);
189
+ return VISIT_BLANKED;
190
+ case SK.TaggedTemplateExpression:
191
+ return visitTaggedTemplate(node);
192
+ case SK.TypeAssertionExpression:
193
+ return visitLegacyTypeAssertion(node);
194
+ }
195
+ return node.forEachChild(visitor, visitUnknownNodeArray) || VISITED_JS;
196
+ }
197
+ function visitVariableStatement(node) {
198
+ if (node.modifiers && modifiersContainsDeclare(node.modifiers)) {
199
+ blankStatement(node);
200
+ return VISIT_BLANKED;
201
+ }
202
+ node.forEachChild(visitor, visitUnknownNodeArray);
203
+ return VISITED_JS;
204
+ }
205
+ function visitCallOrNewExpression(node) {
206
+ visitor(node.expression);
207
+ if (node.typeArguments) blankGenerics(node, node.typeArguments, false);
208
+ if (node.arguments) {
209
+ const args = node.arguments;
210
+ for(let i = 0; i < args.length; i++)visitor(args[i]);
211
+ }
212
+ return VISITED_JS;
213
+ }
214
+ function visitTaggedTemplate(node) {
215
+ visitor(node.tag);
216
+ if (node.typeArguments) blankGenerics(node, node.typeArguments, false);
217
+ visitor(node.template);
218
+ return VISITED_JS;
219
+ }
220
+ function visitVariableDeclaration(node) {
221
+ visitor(node.name);
222
+ node.exclamationToken && blankExact(node.exclamationToken);
223
+ node.type && blankTypeNode(node.type);
224
+ if (node.initializer) visitor(node.initializer);
225
+ return VISITED_JS;
226
+ }
227
+ function visitClassLike(node) {
228
+ if (node.modifiers) {
229
+ if (modifiersContainsDeclare(node.modifiers)) {
230
+ blankStatement(node);
231
+ return VISIT_BLANKED;
232
+ }
233
+ visitModifiers(node.modifiers, false);
234
+ }
235
+ if (node.typeParameters && node.typeParameters.length) blankGenerics(node, node.typeParameters, false);
236
+ const { heritageClauses } = node;
237
+ if (heritageClauses) for(let i = 0; i < heritageClauses.length; i++){
238
+ const hc = heritageClauses[i];
239
+ if (hc.token === SK.ImplementsKeyword) blankExact(hc);
240
+ else if (hc.token === SK.ExtendsKeyword) hc.forEachChild(visitor);
241
+ }
242
+ visitNodeArray(node.members, true, false);
243
+ return VISITED_JS;
244
+ }
245
+ function visitExpressionWithTypeArguments(node) {
246
+ visitor(node.expression);
247
+ if (node.typeArguments) blankGenerics(node, node.typeArguments, false);
248
+ return VISITED_JS;
249
+ }
250
+ const classElementModifiersToRemoveArray = [
251
+ SK.AbstractKeyword,
252
+ SK.DeclareKeyword,
253
+ SK.OverrideKeyword,
254
+ SK.PrivateKeyword,
255
+ SK.ProtectedKeyword,
256
+ SK.PublicKeyword,
257
+ SK.ReadonlyKeyword
258
+ ];
259
+ const classElementModifiersToRemove = new Set(classElementModifiersToRemoveArray);
260
+ function isRemovedModifier(kind) {
261
+ return classElementModifiersToRemove.has(kind);
262
+ }
263
+ function visitModifiers(modifiers, addSemi) {
264
+ for(let i = 0; i < modifiers.length; i++){
265
+ const modifier = modifiers[i];
266
+ const kind = modifier.kind;
267
+ if (isRemovedModifier(kind)) {
268
+ if (addSemi && 0 === i) {
269
+ str.blankButStartWithSemi(modifier.getStart(ast), modifier.end);
270
+ addSemi = false;
271
+ } else blankExact(modifier);
272
+ continue;
273
+ }
274
+ if (kind === SK.Decorator) {
275
+ visitor(modifier);
276
+ continue;
277
+ }
278
+ }
279
+ }
280
+ function visitPropertyDeclaration(node) {
281
+ if (node.modifiers) {
282
+ if (modifiersContainsAbstractOrDeclare(node.modifiers)) {
283
+ blankStatement(node);
284
+ return VISIT_BLANKED;
285
+ }
286
+ visitModifiers(node.modifiers, node.name.kind === SK.ComputedPropertyName);
287
+ }
288
+ node.exclamationToken && blankExact(node.exclamationToken);
289
+ node.questionToken && blankExact(node.questionToken);
290
+ node.type && blankTypeNode(node.type);
291
+ visitor(node.name);
292
+ if (node.initializer) visitor(node.initializer);
293
+ return VISITED_JS;
294
+ }
295
+ function visitNonNullExpression(node) {
296
+ visitor(node.expression);
297
+ str.blank(node.end - 1, node.end);
298
+ return VISITED_JS;
299
+ }
300
+ function visitTypeAssertion(node) {
301
+ const r = visitor(node.expression);
302
+ const nodeEnd = node.end;
303
+ if (parentStatement && nodeEnd === parentStatement.end && 59 !== src.charCodeAt(nodeEnd)) str.blankButStartWithSemi(node.expression.end, nodeEnd);
304
+ else str.blank(node.expression.end, nodeEnd);
305
+ return r;
306
+ }
307
+ function visitLegacyTypeAssertion(node) {
308
+ onError && onError(node);
309
+ return visitor(node.expression);
310
+ }
311
+ const unsupportedParameterModifiers = new Set([
312
+ SK.PublicKeyword,
313
+ SK.ProtectedKeyword,
314
+ SK.PrivateKeyword,
315
+ SK.ReadonlyKeyword
316
+ ]);
317
+ function visitFunctionLikeDeclaration(node, kind) {
318
+ if (!node.body) {
319
+ if (node.modifiers && modifiersContainsDeclare(node.modifiers)) {
320
+ blankStatement(node);
321
+ return VISIT_BLANKED;
322
+ }
323
+ blankExact(node);
324
+ return VISIT_BLANKED;
325
+ }
326
+ const nodeName = node.name;
327
+ if (node.modifiers) visitModifiers(node.modifiers, !!nodeName && nodeName.kind === SK.ComputedPropertyName);
328
+ if (nodeName) visitor(nodeName);
329
+ let moveOpenParen = false;
330
+ const params = node.parameters;
331
+ if (node.typeParameters && node.typeParameters.length) {
332
+ moveOpenParen = spansLines(node.typeParameters.pos, params.pos);
333
+ blankGenerics(node, node.typeParameters, moveOpenParen);
334
+ }
335
+ node.questionToken && blankExact(node.questionToken);
336
+ if (moveOpenParen) str.blank(params.pos - 1, params.pos);
337
+ for(let i = 0; i < params.length; i++){
338
+ const p = params[i];
339
+ if (0 === i && "this" === p.name.getText(ast)) {
340
+ blankExactAndOptionalTrailingComma(p);
341
+ continue;
342
+ }
343
+ if (onError && p.modifiers) for(let i = 0; i < p.modifiers.length; i++){
344
+ const modifier = p.modifiers[i];
345
+ if (unsupportedParameterModifiers.has(modifier.kind)) onError(modifier);
346
+ }
347
+ visitor(p.name);
348
+ p.questionToken && blankExact(p.questionToken);
349
+ p.type && blankTypeNode(p.type);
350
+ p.initializer && visitor(p.initializer);
351
+ }
352
+ const returnType = node.type;
353
+ const isArrow = kind === SK.ArrowFunction;
354
+ if (returnType) if (isArrow && spansLines(node.parameters.end, node.equalsGreaterThanToken.pos)) {
355
+ const paramEnd = getClosingParenthesisPos(node.parameters);
356
+ str.blankButEndWithCloseParen(paramEnd - 1, returnType.getEnd());
357
+ } else blankTypeNode(returnType);
358
+ const body = node.body;
359
+ if (body.kind === SK.Block) visitNodeArray(body.statements, true, true);
360
+ else visitor(node.body);
361
+ return VISITED_JS;
362
+ }
363
+ function spansLines(a, b) {
364
+ for(let i = a; i < b; i++)if (10 === src.charCodeAt(i)) return true;
365
+ return false;
366
+ }
367
+ function visitImportDeclaration(node) {
368
+ if (node.importClause) {
369
+ if (node.importClause.isTypeOnly) {
370
+ blankStatement(node);
371
+ return VISIT_BLANKED;
372
+ }
373
+ const { namedBindings } = node.importClause;
374
+ if (namedBindings && __WEBPACK_EXTERNAL_MODULE_typescript__["default"].isNamedImports(namedBindings)) {
375
+ const elements = namedBindings.elements;
376
+ for(let i = 0; i < elements.length; i++){
377
+ const e = elements[i];
378
+ e.isTypeOnly && blankExactAndOptionalTrailingComma(e);
379
+ }
380
+ }
381
+ }
382
+ return VISITED_JS;
383
+ }
384
+ function visitExportDeclaration(node) {
385
+ if (node.isTypeOnly) {
386
+ blankStatement(node);
387
+ return VISIT_BLANKED;
388
+ }
389
+ const { exportClause } = node;
390
+ if (exportClause && __WEBPACK_EXTERNAL_MODULE_typescript__["default"].isNamedExports(exportClause)) {
391
+ const elements = exportClause.elements;
392
+ for(let i = 0; i < elements.length; i++){
393
+ const e = elements[i];
394
+ e.isTypeOnly && blankExactAndOptionalTrailingComma(e);
395
+ }
396
+ }
397
+ return VISITED_JS;
398
+ }
399
+ function visitExportAssignment(node) {
400
+ if (node.isExportEquals) {
401
+ onError && onError(node);
402
+ return VISITED_JS;
403
+ }
404
+ visitor(node.expression);
405
+ return VISITED_JS;
406
+ }
407
+ function visitModule(node) {
408
+ if (node.flags & __WEBPACK_EXTERNAL_MODULE_typescript__["default"].NodeFlags.GlobalAugmentation || node.flags & __WEBPACK_EXTERNAL_MODULE_typescript__["default"].NodeFlags.Namespace && (node.modifiers && modifiersContainsDeclare(node.modifiers) || !valueNamespaceWorker(node)) || node.name.kind === SK.StringLiteral) {
409
+ blankStatement(node);
410
+ return VISIT_BLANKED;
411
+ }
412
+ onError && onError(node);
413
+ return VISITED_JS;
414
+ }
415
+ function visitEnum(node) {
416
+ if (node.modifiers && modifiersContainsDeclare(node.modifiers)) {
417
+ blankStatement(node);
418
+ return VISIT_BLANKED;
419
+ }
420
+ onError && onError(node);
421
+ return VISITED_JS;
422
+ }
423
+ function valueNamespaceWorker(node) {
424
+ switch(node.kind){
425
+ case SK.TypeAliasDeclaration:
426
+ case SK.InterfaceDeclaration:
427
+ return false;
428
+ case SK.ImportEqualsDeclaration:
429
+ {
430
+ const { modifiers } = node;
431
+ return modifiers?.some((m)=>m.kind === SK.ExportKeyword) || false;
432
+ }
433
+ case SK.ModuleDeclaration:
434
+ {
435
+ if (!(node.flags & __WEBPACK_EXTERNAL_MODULE_typescript__["default"].NodeFlags.Namespace)) return true;
436
+ const { body } = node;
437
+ if (!body) return false;
438
+ if (body.kind === SK.ModuleDeclaration) return valueNamespaceWorker(body);
439
+ return body.forEachChild(valueNamespaceWorker) || false;
440
+ }
441
+ }
442
+ return true;
443
+ }
444
+ function modifiersContainsDeclare(modifiers) {
445
+ for(let i = 0; i < modifiers.length; i++){
446
+ const modifier = modifiers[i];
447
+ if (modifier.kind === SK.DeclareKeyword) return true;
448
+ }
449
+ return false;
450
+ }
451
+ function modifiersContainsAbstractOrDeclare(modifiers) {
452
+ for(let i = 0; i < modifiers.length; i++){
453
+ const modifierKind = modifiers[i].kind;
454
+ if (modifierKind === SK.AbstractKeyword || modifierKind === SK.DeclareKeyword) return true;
455
+ }
456
+ return false;
457
+ }
458
+ function scanRange(start, end, callback) {
459
+ return scanner.scanRange(start, end - start, callback);
460
+ }
461
+ function endPosOfToken(token) {
462
+ let first = true;
463
+ let start = 0;
464
+ while(true){
465
+ const next = scanner.scan();
466
+ if (first) {
467
+ start = scanner.getTokenStart();
468
+ first = false;
469
+ }
470
+ if (next === token) break;
471
+ if (next === SK.EndOfFileToken) return start;
472
+ }
473
+ return scanner.getTokenEnd();
474
+ }
475
+ function getGreaterThanToken() {
476
+ return endPosOfToken(SK.GreaterThanToken);
477
+ }
478
+ function getClosingParen() {
479
+ return endPosOfToken(SK.CloseParenToken);
480
+ }
481
+ function blankTypeNode(n) {
482
+ str.blank(n.getFullStart() - 1, n.end);
483
+ }
484
+ function blankExact(n) {
485
+ str.blank(n.getStart(ast), n.end);
486
+ }
487
+ function blankStatement(n) {
488
+ if (seenJS) str.blankButStartWithSemi(n.getStart(ast), n.end);
489
+ else str.blank(n.getStart(ast), n.end);
490
+ }
491
+ function blankExactAndOptionalTrailingComma(n) {
492
+ scanner.resetTokenState(n.end);
493
+ const trailingComma = scanner.scan() === SK.CommaToken;
494
+ str.blank(n.getStart(ast), trailingComma ? scanner.getTokenEnd() : n.end);
495
+ }
496
+ function blankGenerics(node, arr, startWithParen) {
497
+ const start = arr.pos - 1;
498
+ const end = scanRange(arr.end, node.end, getGreaterThanToken);
499
+ startWithParen ? str.blankButStartWithOpenParen(start, end) : str.blank(start, end);
500
+ }
501
+ function getClosingParenthesisPos(node) {
502
+ return scanRange(0 === node.length ? node.pos : node[node.length - 1].end, ast.end, getClosingParen);
503
+ }
504
+ const state = {
505
+ active: true,
506
+ port: null
507
+ };
508
+ const hooks_initialize = function(data) {
509
+ state.port = data.port;
510
+ data.port.on('message', onMessage);
511
+ };
512
+ const hooks_resolve = async function(specifier, context, nextResolve) {
513
+ try {
514
+ return await nextResolve(specifier, context);
515
+ } catch (err) {
516
+ const url = parseURL(err?.url);
517
+ if (state.active && url?.pathname.endsWith('.js')) try {
518
+ return await nextResolve(url.pathname.slice(0, -3) + '.ts', context);
519
+ } catch {}
520
+ throw err;
521
+ }
522
+ };
523
+ const hooks_load = async function(url, context, nextLoad) {
524
+ const fullURL = parseURL(url);
525
+ if (!fullURL) return nextLoad(url, context);
526
+ const { pathname } = fullURL;
527
+ const isCts = pathname.endsWith('.cts');
528
+ if (!(pathname.endsWith('.ts') || pathname.endsWith('.mts') || isCts) || !state.active) return nextLoad(url, context);
529
+ const result = await nextLoad(url, {
530
+ ...context,
531
+ format: 'module'
532
+ });
533
+ const transformedSource = tsBlankSpace(result.source.toString());
534
+ return {
535
+ format: isCts ? 'commonjs' : 'module',
536
+ shortCircuit: true,
537
+ source: transformedSource + '\n//# sourceURL=' + url
538
+ };
539
+ };
540
+ function onMessage(message) {
541
+ if ('deactivate' === message) state.active = false;
542
+ state.port?.off('message', onMessage);
543
+ }
544
+ function parseURL(url) {
545
+ if (null == url) return null;
546
+ try {
547
+ return new __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.URL(url, 'file://');
548
+ } catch {
549
+ return null;
550
+ }
551
+ }
552
+ export { hooks_initialize as initialize, hooks_load as load, hooks_resolve as resolve };
@@ -0,0 +1,22 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
2
+ function register() {
3
+ if (!__WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__["default"].register) throw new Error([
4
+ `This version of Node.js (${process.version}) does not support module.register(). You can either:`,
5
+ " - Upgrade to Node.js v18.19 or v20.6 and above",
6
+ " - Use `lynx.config.js` instead of `lynx.config.ts`"
7
+ ].join('\n'));
8
+ const { port1, port2 } = new MessageChannel();
9
+ __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__["default"].register(`./hooks.js?${Date.now()}`, import.meta.url, {
10
+ parentURL: import.meta.url,
11
+ data: {
12
+ port: port2
13
+ },
14
+ transferList: [
15
+ port2
16
+ ]
17
+ });
18
+ return function() {
19
+ port1.postMessage('deactivate');
20
+ };
21
+ }
22
+ export { register };
@@ -0,0 +1,47 @@
1
+ export const __webpack_ids__ = [
2
+ 'src_cli_build_ts'
3
+ ];
4
+ export const __webpack_modules__ = {
5
+ "./src/cli/build.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6
+ __webpack_require__.r(__webpack_exports__);
7
+ __webpack_require__.d(__webpack_exports__, {
8
+ build: ()=>build
9
+ });
10
+ var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
11
+ var _exit_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/cli/exit.ts");
12
+ var _config_loadConfig_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/config/loadConfig.ts");
13
+ var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/create-rspeedy.ts");
14
+ var _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/utils/is-ci.ts");
15
+ async function build(cwd, buildOptions) {
16
+ const shouldExit = 'true' !== process.env['RSDOCTOR'] || (0, _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_4__.y)();
17
+ try {
18
+ const { content: rspeedyConfig } = await (0, _config_loadConfig_js__WEBPACK_IMPORTED_MODULE_2__.ME)({
19
+ cwd,
20
+ configPath: buildOptions.config
21
+ });
22
+ const options = {
23
+ cwd,
24
+ rspeedyConfig
25
+ };
26
+ if (buildOptions.envMode) options.loadEnv = {
27
+ mode: buildOptions.envMode
28
+ };
29
+ if (buildOptions.environment) options.environment = buildOptions.environment;
30
+ const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__.S)(options);
31
+ await rspeedy.build();
32
+ } catch (error) {
33
+ _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error(error);
34
+ if (shouldExit) return void (0, _exit_js__WEBPACK_IMPORTED_MODULE_1__.exit)(1);
35
+ }
36
+ if (shouldExit) (0, _exit_js__WEBPACK_IMPORTED_MODULE_1__.exit)();
37
+ }
38
+ },
39
+ "./src/utils/is-ci.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
40
+ __webpack_require__.d(__webpack_exports__, {
41
+ y: ()=>isCI
42
+ });
43
+ function isCI() {
44
+ return !!process.env['CI'] && 'false' !== process.env['CI'];
45
+ }
46
+ }
47
+ };
@@ -0,0 +1,60 @@
1
+ export const __webpack_ids__ = [
2
+ 'src_cli_commands_ts'
3
+ ];
4
+ export const __webpack_modules__ = {
5
+ "./src/cli/commands.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6
+ __webpack_require__.r(__webpack_exports__);
7
+ __webpack_require__.d(__webpack_exports__, {
8
+ apply: ()=>apply
9
+ });
10
+ var _version_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/version.ts");
11
+ function applyCommonOptions(command) {
12
+ command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--env-mode <mode>', 'specify the env mode to load the .env.[mode] file"');
13
+ }
14
+ function apply(program) {
15
+ const cwd = process.cwd();
16
+ program.name('rspeedy').usage('<command> [options]').version(_version_js__WEBPACK_IMPORTED_MODULE_0__.version).option('--unmanaged', 'Force to use the unmanaged version of Rspeedy, instead of the locally installed.').showHelpAfterError(true).showSuggestionAfterError(true).exitOverride();
17
+ const buildCommand = program.command('build');
18
+ buildCommand.description('Build the project in production mode').option('--environment <name...>', 'specify the name of environment to build').action((buildOptions)=>Promise.all([
19
+ __webpack_require__.e("src_config_loadConfig_ts-src_create-rspeedy_ts"),
20
+ __webpack_require__.e("src_cli_build_ts")
21
+ ]).then(__webpack_require__.bind(__webpack_require__, "./src/cli/build.ts")).then(({ build })=>build.call(buildCommand, cwd, buildOptions)));
22
+ const devCommand = program.command('dev');
23
+ devCommand.description('Run the dev server and watch for source file changes while serving.').option('--base <base>', 'specify the base path of the server').option('--environment <name...>', 'specify the name of environment to build').action((devOptions)=>Promise.all([
24
+ __webpack_require__.e("src_config_loadConfig_ts-src_create-rspeedy_ts"),
25
+ __webpack_require__.e("src_cli_dev_ts")
26
+ ]).then(__webpack_require__.bind(__webpack_require__, "./src/cli/dev.ts")).then(({ dev })=>dev.call(devCommand, cwd, devOptions)));
27
+ const inspectCommand = program.command('inspect');
28
+ inspectCommand.description('View the Rsbuild config and Rspack config of the project.').option('--mode <mode>', 'specify the mode of Rsbuild', 'development').option('--output <output>', 'specify inspect content output path').option('--verbose', 'show full function definitions in output').action((inspectOptions)=>Promise.all([
29
+ __webpack_require__.e("src_config_loadConfig_ts-src_create-rspeedy_ts"),
30
+ __webpack_require__.e("src_cli_inspect_ts")
31
+ ]).then(__webpack_require__.bind(__webpack_require__, "./src/cli/inspect.ts")).then(({ inspect })=>inspect.call(inspectCommand, cwd, inspectOptions)));
32
+ const previewCommand = program.command('preview');
33
+ previewCommand.description('Preview the production build outputs locally.').option('--base <base>', 'specify the base path of the server').action((previewOptions)=>Promise.all([
34
+ __webpack_require__.e("src_config_loadConfig_ts-src_create-rspeedy_ts"),
35
+ __webpack_require__.e("src_cli_preview_ts")
36
+ ]).then(__webpack_require__.bind(__webpack_require__, "./src/cli/preview.ts")).then(({ preview })=>preview.call(previewCommand, cwd, previewOptions)));
37
+ const commonCommands = [
38
+ devCommand,
39
+ buildCommand,
40
+ inspectCommand,
41
+ previewCommand
42
+ ];
43
+ commonCommands.forEach((command)=>applyCommonOptions(command));
44
+ return program;
45
+ }
46
+ },
47
+ "./src/version.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
48
+ __webpack_require__.d(__webpack_exports__, {
49
+ rsbuildVersion: ()=>core_.version,
50
+ version: ()=>version,
51
+ rspackVersion: ()=>rspackVersion
52
+ });
53
+ var core_ = __webpack_require__("@rsbuild/core");
54
+ var package_namespaceObject = {
55
+ i8: "0.9.1"
56
+ };
57
+ const version = package_namespaceObject.i8;
58
+ const rspackVersion = core_.rspack.rspackVersion;
59
+ }
60
+ };