@windwalker-io/core 4.2.9 → 4.2.11

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 (36) hide show
  1. package/LICENSE +19 -19
  2. package/dist/debugger/Dashboard-CzDoLneW.js +1 -0
  3. package/dist/debugger/{Database-BGuRRq-L.js → Database-CSU8eOK6.js} +2 -2
  4. package/dist/debugger/DefaultLayout-fPOBRlxo.js +1 -0
  5. package/dist/debugger/Events-zF0JqyW4.js +1 -0
  6. package/dist/debugger/KeyValueTable-6M6bFpX8.js +1 -0
  7. package/dist/debugger/{Request-yQA1-Fkb.js → Request-DKOZpKRC.js} +1 -1
  8. package/dist/debugger/{Routing-C5mAPB17.js → Routing-puFmtUNp.js} +1 -1
  9. package/dist/debugger/{System-JFuNpoZY.js → System-Daos7PgT.js} +1 -1
  10. package/dist/debugger/{Timeline-Uii-K9v_.js → Timeline-BozTDh0s.js} +1 -1
  11. package/dist/debugger/debugger.js +11 -11
  12. package/dist/next.js +17 -4
  13. package/package.json +7 -3
  14. package/src/asset-bundler.mjs +114 -114
  15. package/src/debugger/types/global.d.js +2 -2
  16. package/src/index.mjs +10 -10
  17. package/src/legacy/4.0/js-sync.mjs +74 -74
  18. package/src/next/fusion/index.ts +2 -2
  19. package/src/next/fusion/plugins/assets.ts +29 -29
  20. package/src/next/fusion/plugins/index.ts +3 -3
  21. package/src/next/fusion/plugins/systemjs.ts +66 -66
  22. package/src/next/fusion/processors/cloneAssets.ts +85 -81
  23. package/src/next/fusion/processors/cssModulize.ts +128 -128
  24. package/src/next/fusion/processors/index.ts +4 -4
  25. package/src/next/fusion/processors/installVendors.ts +184 -184
  26. package/src/next/fusion/processors/jsModulize.ts +319 -307
  27. package/src/next/index.ts +2 -2
  28. package/src/next/utilities/asset-sync.ts +47 -47
  29. package/src/next/utilities/crypto.ts +11 -11
  30. package/src/next/utilities/fs.ts +61 -61
  31. package/src/next/utilities/index.ts +5 -5
  32. package/src/next/utilities/modules.ts +17 -17
  33. package/dist/debugger/Dashboard-Bm7ihi81.js +0 -1
  34. package/dist/debugger/DefaultLayout-DviqbPNR.js +0 -1
  35. package/dist/debugger/Events-CNF6gvg0.js +0 -1
  36. package/dist/debugger/KeyValueTable-BfTkP1Rg.js +0 -1
@@ -1,307 +1,319 @@
1
- import {
2
- type BuildTask,
3
- type ConfigBuilder,
4
- js,
5
- type MaybePromise,
6
- plugin as addPlugin,
7
- type ProcessorInterface,
8
- type ProcessorPreview,
9
- shortHash,
10
- } from '@windwalker-io/fusion-next';
11
- import fs from 'fs-extra';
12
- import { parse } from 'node-html-parser';
13
- import crypto from 'node:crypto';
14
- import { normalize, resolve } from 'node:path';
15
- import { type FindFileResult, findFilesFromGlobArray, findModules, findPackages, stripUrlQuery } from '../../utilities';
16
-
17
- export interface JsModulizeOptions {
18
- tmpPath?: string;
19
- cleanTmp?: boolean;
20
- }
21
-
22
- export function jsModulize(entry: string, dest: string, options: JsModulizeOptions = {}) {
23
- return new JsModulizeProcessor(js(entry, dest), options);
24
- }
25
-
26
- export interface JsModulizeDeepOptions extends JsModulizeOptions {
27
- mergeScripts?: boolean;
28
- parseBlades?: boolean;
29
- }
30
-
31
- export function jsModulizeDeep(stage: string, entry: string, dest: string, options: JsModulizeDeepOptions = {}) {
32
- const processor = jsModulize(entry, dest, options)
33
- .stage(stage.toLowerCase());
34
-
35
- if (options.mergeScripts ?? true) {
36
- processor.mergeScripts(
37
- findModules(`${stage}/**/assets/*.ts`),
38
- );
39
- }
40
-
41
- if (options.parseBlades ?? true) {
42
- processor.parseBlades(
43
- findModules(`${stage}/**/*.blade.php`),
44
- findPackages('views/**/*.blade.php'),
45
- );
46
- }
47
-
48
- return processor;
49
- }
50
-
51
- export class JsModulizeProcessor implements ProcessorInterface {
52
- protected scriptPatterns: string[] = [];
53
- protected bladePatterns: string[] = [];
54
- protected stagePrefix: string = '';
55
-
56
- constructor(protected processor: ReturnType<typeof js>, protected options: JsModulizeOptions = {}) {
57
- }
58
-
59
- config(taskName: string, builder: ConfigBuilder) {
60
- const tasks = this.processor.config(taskName, builder) as BuildTask[];
61
- const task = tasks[0];
62
- const inputFile = resolve(task.input);
63
- const tmpPath = this.options.tmpPath ?? resolve('./tmp/fusion/jsmodules/').replace(/\\/g, '/');
64
- const clean = this.options.cleanTmp ?? true;
65
-
66
- if (clean) {
67
- builder.postBuildCallbacks.push((options, bundle) => {
68
- fs.removeSync(tmpPath);
69
- });
70
- builder.serverStopCallbacks.push((options, bundle) => {
71
- fs.removeSync(tmpPath);
72
- });
73
- }
74
-
75
- this.ignoreMainImport(task);
76
-
77
- builder.resolveIdCallbacks.push((id) => {
78
- if (id === '@main') {
79
- return { id, external: true };
80
- }
81
- });
82
-
83
- // Todo: Must dynamic changes in load() hook
84
- // const scriptFiles = findFilesFromGlobArray(this.scriptPatterns);
85
- // const bladeFiles = findBladeFiles(this.bladePatterns);
86
-
87
- // Watches
88
- // Currently we don't watch blade files because not necessary to reload full-pages.
89
- // for (const bladeFile of bladeScripts) {
90
- // builder.watches.push({
91
- // file: resolve(bladeFile.file.fullpath),
92
- // moduleFile: inputFile,
93
- // updateType: 'js-update',
94
- // } satisfies WatchTask);
95
- // }
96
-
97
- builder.loadCallbacks.push((src, options) => {
98
- const srcFile = stripUrlQuery(src);
99
- const scripts: Record<string, string> = {};
100
- const scriptFiles = findFilesFromGlobArray(this.scriptPatterns);
101
-
102
- // if (src === appSrcFileName) {
103
- if (normalize(srcFile) === inputFile) {
104
- const bladeFiles = findBladeFiles(this.bladePatterns);
105
- const bladeScripts = parseScriptsFromBlades(bladeFiles);
106
-
107
- // Merge standalone ts files
108
- for (const scriptFile of scriptFiles) {
109
- let fullpath = scriptFile.fullpath;
110
-
111
- if (fullpath.endsWith('.d.ts')) {
112
- continue;
113
- }
114
-
115
- let key = scriptFile.relativePath.replace(/assets\//, '').toLowerCase();
116
- fullpath = resolve(fullpath).replace(/\\/g, '/');
117
-
118
- key = key.substring(0, key.lastIndexOf('.'));
119
-
120
- if (this.stagePrefix) {
121
- key = this.stagePrefix + '/' + key;
122
- }
123
-
124
- // md5
125
- key = 'view:' + crypto.createHash('md5').update(key).digest('hex');
126
-
127
- scripts[key] = fullpath;
128
- }
129
-
130
- // Parse from blades
131
- const listens: string[] = [];
132
-
133
- fs.ensureDirSync(tmpPath);
134
-
135
- for (const result of bladeScripts) {
136
- let key = result.as;
137
- const filename = result.path
138
- .split(/\\|\//g)
139
- .pop()
140
- .replace(/\\|\//g, '_');
141
-
142
- const tmpFile = tmpPath + '/' + filename + '__' + result.as.replace(/\./g, '-') + '.ts';
143
-
144
- if (!fs.existsSync(tmpFile) || fs.readFileSync(tmpFile, 'utf8') !== result.code) {
145
- fs.writeFileSync(tmpFile, result.code);
146
- }
147
-
148
- scripts[`inline:${key}`] = tmpFile;
149
-
150
- const fullpath = resolve(result.file.fullpath).replace(/\\/g, '/');
151
-
152
- // builder.addWatch(fullpath, fullpath);
153
-
154
- // if (!listens.includes(fullpath)) {
155
- // listens.push(fullpath);
156
- // }
157
- }
158
-
159
- let listJS = `{\n`;
160
-
161
- for (const key in scripts) {
162
- const fullpath = scripts[key];
163
- listJS += `'${key}': () => import('${fullpath}'),\n`;
164
- }
165
-
166
- listJS += `}`;
167
-
168
- // Listen extra files
169
- // builder.watches.push(...listens);
170
- // for (const listen of listens) {
171
- // builder.addWatch(listen, listen);
172
- // }
173
-
174
- let { code, comments } = stripComments(fs.readFileSync(srcFile, 'utf-8'));
175
-
176
- // Replace `defineJsModules(...)`
177
- code = code.replace(/defineJsModules\((.*?)\)/g, listJS);
178
-
179
- return restoreComments(code, comments);
180
- }
181
- });
182
-
183
- return undefined;
184
- }
185
-
186
- /**
187
- * @see https://github.com/vitejs/vite/issues/6393#issuecomment-1006819717
188
- * @see https://stackoverflow.com/questions/76259677/vite-dev-server-throws-error-when-resolving-external-path-from-importmap
189
- */
190
- private ignoreMainImport(task: BuildTask) {
191
- const VALID_ID_PREFIX = `/@id/`;
192
- const importKeys = ['@main'];
193
- const reg = new RegExp(
194
- `${VALID_ID_PREFIX}(${importKeys.join("|")})`,
195
- "g"
196
- );
197
-
198
- addPlugin({
199
- name: 'keep-main-external-' + task.id,
200
- transform(code) {
201
- return reg.test(code) ? code.replace(reg, (m, s1) => s1) : code;
202
- }
203
- });
204
- }
205
-
206
- preview(): MaybePromise<ProcessorPreview[]> {
207
- return [];
208
- }
209
-
210
- mergeScripts(...patterns: (string | string[])[]) {
211
- this.scriptPatterns = this.scriptPatterns.concat(patterns.flat());
212
-
213
- return this;
214
- }
215
-
216
- parseBlades(...bladePatterns: (string[] | string)[]) {
217
- this.bladePatterns = this.bladePatterns.concat(bladePatterns.flat());
218
-
219
- return this;
220
- }
221
-
222
- stage(stage: string) {
223
- this.stagePrefix = stage;
224
-
225
- return this;
226
- }
227
- }
228
-
229
- interface ScriptResult {
230
- as: string;
231
- file: FindFileResult;
232
- path: string;
233
- code: string;
234
- }
235
-
236
- // function parseScriptsFromBlade(file: string, service: Record<string, ParsedModule>): string[] {
237
- // const bladeText = fs.readFileSync(file, 'utf8');
238
- //
239
- // const html = parse(bladeText);
240
- //
241
- // return html.querySelectorAll('script[lang]')
242
- // .filter(
243
- // (el) => ['ts', 'typescript'].includes(el.getAttribute('lang') || '')
244
- // )
245
- // .map((el) => el.innerHTML)
246
- // .filter((c) => c.trim() !== '');
247
- // }
248
-
249
- function findBladeFiles(patterns: string | string[]) {
250
- return findFilesFromGlobArray(Array.isArray(patterns) ? patterns : [patterns]);
251
- }
252
-
253
- function parseScriptsFromBlades(files: FindFileResult[]): ScriptResult[] {
254
- return files.map((file) => {
255
- const bladeText = fs.readFileSync(file.fullpath, 'utf8');
256
-
257
- const html = parse(bladeText);
258
- // const key = file.relativePath.replace(/.blade.php$/, '').toLowerCase();
259
-
260
- return html.querySelectorAll('script[lang][data-macro]')
261
- .filter(
262
- (el) => ['ts', 'typescript'].includes(el.getAttribute('lang') || '')
263
- )
264
- .map((el) => ({
265
- as: el.getAttribute('data-macro') || '',
266
- file: file,
267
- path: file.relativePath.replace(/.blade.php$/, ''),
268
- code: el.innerHTML
269
- }))
270
- .filter((c) => c.code.trim() !== '');
271
- })
272
- .flat();
273
- }
274
-
275
- type CommentPlaceholder = { key: string; value: string; };
276
-
277
- function stripComments(code: string): { code: string; comments: CommentPlaceholder[] } {
278
- const comments: CommentPlaceholder[] = [];
279
- let i = 0;
280
-
281
- code = code
282
- // Multi-line /* */
283
- .replace(/\/\*[\s\S]*?\*\//g, match => {
284
- const key = `__COMMENT_BLOCK_${i}__`;
285
- comments.push({ key, value: match });
286
- i++;
287
- return key;
288
- })
289
- // Single-line //
290
- .replace(/\/\/.*$/gm, match => {
291
- const key = `__COMMENT_LINE_${i}__`;
292
- comments.push({ key, value: match });
293
- i++;
294
- return key;
295
- });
296
-
297
- return { code, comments };
298
- }
299
-
300
- function restoreComments(code: string, comments: CommentPlaceholder[]): string {
301
- for (const { key, value } of comments) {
302
- const re = new RegExp(key, 'g');
303
- code = code.replace(re, value);
304
- }
305
-
306
- return code;
307
- }
1
+ import {
2
+ type BuildTask,
3
+ type ConfigBuilder,
4
+ js,
5
+ type MaybePromise,
6
+ plugin as addPlugin,
7
+ type ProcessorInterface,
8
+ type ProcessorPreview,
9
+ shortHash,
10
+ } from '@windwalker-io/fusion-next';
11
+ import fs from 'fs-extra';
12
+ import { parse } from 'node-html-parser';
13
+ import crypto from 'node:crypto';
14
+ import { normalize, resolve } from 'node:path';
15
+ import { type FindFileResult, findFilesFromGlobArray, findModules, findPackages, stripUrlQuery } from '../../utilities';
16
+
17
+ export interface JsModulizeOptions {
18
+ tmpPath?: string;
19
+ cleanTmp?: boolean;
20
+ }
21
+
22
+ export function jsModulize(entry: string, dest: string, options: JsModulizeOptions = {}) {
23
+ return new JsModulizeProcessor(js(entry, dest), options);
24
+ }
25
+
26
+ export interface JsModulizeDeepOptions extends JsModulizeOptions {
27
+ mergeScripts?: boolean;
28
+ parseBlades?: boolean;
29
+ }
30
+
31
+ export function jsModulizeDeep(stage: string, entry: string, dest: string, options: JsModulizeDeepOptions = {}) {
32
+ const processor = jsModulize(entry, dest, options)
33
+ .stage(stage.toLowerCase());
34
+
35
+ if (options.mergeScripts ?? true) {
36
+ processor.mergeScripts(
37
+ findModules(`${stage}/**/assets/*.ts`),
38
+ );
39
+ }
40
+
41
+ if (options.parseBlades ?? true) {
42
+ processor.parseBlades(
43
+ findModules(`${stage}/**/*.blade.php`),
44
+ findPackages('views/**/*.blade.php'),
45
+ );
46
+ }
47
+
48
+ return processor;
49
+ }
50
+
51
+ export class JsModulizeProcessor implements ProcessorInterface {
52
+ protected scriptPatterns: string[] = [];
53
+ protected bladePatterns: string[] = [];
54
+ protected stagePrefix: string = '';
55
+
56
+ constructor(protected processor: ReturnType<typeof js>, protected options: JsModulizeOptions = {}) {
57
+ }
58
+
59
+ config(taskName: string, builder: ConfigBuilder) {
60
+ const tasks = this.processor.config(taskName, builder) as BuildTask[];
61
+ const task = tasks[0];
62
+ const inputFile = resolve(task.input);
63
+ const tmpPath = this.options.tmpPath ?? resolve('./tmp/fusion/jsmodules/').replace(/\\/g, '/');
64
+ const clean = this.options.cleanTmp ?? true;
65
+
66
+ if (builder.config.build.watch) {
67
+ builder.merge({
68
+ build: {
69
+ watch: {
70
+ exclude: [
71
+ tmpPath + '/**',
72
+ ],
73
+ }
74
+ }
75
+ });
76
+ }
77
+
78
+ if (clean) {
79
+ builder.postBuildCallbacks.push((options, bundle) => {
80
+ fs.removeSync(tmpPath);
81
+ });
82
+ builder.serverStopCallbacks.push((options, bundle) => {
83
+ fs.removeSync(tmpPath);
84
+ });
85
+ }
86
+
87
+ this.ignoreMainImport(task);
88
+
89
+ builder.resolveIdCallbacks.push((id) => {
90
+ if (id === '@main') {
91
+ return { id, external: true };
92
+ }
93
+ });
94
+
95
+ // Todo: Must dynamic changes in load() hook
96
+ // const scriptFiles = findFilesFromGlobArray(this.scriptPatterns);
97
+ // const bladeFiles = findBladeFiles(this.bladePatterns);
98
+
99
+ // Watches
100
+ // Currently we don't watch blade files because not necessary to reload full-pages.
101
+ // for (const bladeFile of bladeScripts) {
102
+ // builder.watches.push({
103
+ // file: resolve(bladeFile.file.fullpath),
104
+ // moduleFile: inputFile,
105
+ // updateType: 'js-update',
106
+ // } satisfies WatchTask);
107
+ // }
108
+
109
+ builder.loadCallbacks.push((src, options) => {
110
+ const srcFile = stripUrlQuery(src);
111
+ const scripts: Record<string, string> = {};
112
+ const scriptFiles = findFilesFromGlobArray(this.scriptPatterns);
113
+
114
+ // if (src === appSrcFileName) {
115
+ if (normalize(srcFile) === inputFile) {
116
+ const bladeFiles = findBladeFiles(this.bladePatterns);
117
+ const bladeScripts = parseScriptsFromBlades(bladeFiles);
118
+
119
+ // Merge standalone ts files
120
+ for (const scriptFile of scriptFiles) {
121
+ let fullpath = scriptFile.fullpath;
122
+
123
+ if (fullpath.endsWith('.d.ts')) {
124
+ continue;
125
+ }
126
+
127
+ let key = scriptFile.relativePath.replace(/assets\//, '').toLowerCase();
128
+ fullpath = resolve(fullpath).replace(/\\/g, '/');
129
+
130
+ key = key.substring(0, key.lastIndexOf('.'));
131
+
132
+ if (this.stagePrefix) {
133
+ key = this.stagePrefix + '/' + key;
134
+ }
135
+
136
+ // md5
137
+ key = 'view:' + crypto.createHash('md5').update(key).digest('hex');
138
+
139
+ scripts[key] = fullpath;
140
+ }
141
+
142
+ // Parse from blades
143
+ const listens: string[] = [];
144
+
145
+ fs.ensureDirSync(tmpPath);
146
+
147
+ for (const result of bladeScripts) {
148
+ let key = result.as;
149
+ const filename = result.path
150
+ .split(/\\|\//g)
151
+ .pop()
152
+ .replace(/\\|\//g, '_');
153
+
154
+ const tmpFile = tmpPath + '/' + filename + '__' + result.as.replace(/\./g, '-') + '.ts';
155
+
156
+ if (!fs.existsSync(tmpFile) || fs.readFileSync(tmpFile, 'utf8') !== result.code) {
157
+ fs.writeFileSync(tmpFile, result.code);
158
+ }
159
+
160
+ scripts[`inline:${key}`] = tmpFile;
161
+
162
+ const fullpath = resolve(result.file.fullpath).replace(/\\/g, '/');
163
+
164
+ // builder.addWatch(fullpath, fullpath);
165
+
166
+ // if (!listens.includes(fullpath)) {
167
+ // listens.push(fullpath);
168
+ // }
169
+ }
170
+
171
+ let listJS = `{\n`;
172
+
173
+ for (const key in scripts) {
174
+ const fullpath = scripts[key];
175
+ listJS += `'${key}': () => import('${fullpath}'),\n`;
176
+ }
177
+
178
+ listJS += `}`;
179
+
180
+ // Listen extra files
181
+ // builder.watches.push(...listens);
182
+ // for (const listen of listens) {
183
+ // builder.addWatch(listen, listen);
184
+ // }
185
+
186
+ let { code, comments } = stripComments(fs.readFileSync(srcFile, 'utf-8'));
187
+
188
+ // Replace `defineJsModules(...)`
189
+ code = code.replace(/defineJsModules\((.*?)\)/g, listJS);
190
+
191
+ return restoreComments(code, comments);
192
+ }
193
+ });
194
+
195
+ return undefined;
196
+ }
197
+
198
+ /**
199
+ * @see https://github.com/vitejs/vite/issues/6393#issuecomment-1006819717
200
+ * @see https://stackoverflow.com/questions/76259677/vite-dev-server-throws-error-when-resolving-external-path-from-importmap
201
+ */
202
+ private ignoreMainImport(task: BuildTask) {
203
+ const VALID_ID_PREFIX = `/@id/`;
204
+ const importKeys = ['@main'];
205
+ const reg = new RegExp(
206
+ `${VALID_ID_PREFIX}(${importKeys.join("|")})`,
207
+ "g"
208
+ );
209
+
210
+ addPlugin({
211
+ name: 'keep-main-external-' + task.id,
212
+ transform(code) {
213
+ return reg.test(code) ? code.replace(reg, (m, s1) => s1) : code;
214
+ }
215
+ });
216
+ }
217
+
218
+ preview(): MaybePromise<ProcessorPreview[]> {
219
+ return [];
220
+ }
221
+
222
+ mergeScripts(...patterns: (string | string[])[]) {
223
+ this.scriptPatterns = this.scriptPatterns.concat(patterns.flat());
224
+
225
+ return this;
226
+ }
227
+
228
+ parseBlades(...bladePatterns: (string[] | string)[]) {
229
+ this.bladePatterns = this.bladePatterns.concat(bladePatterns.flat());
230
+
231
+ return this;
232
+ }
233
+
234
+ stage(stage: string) {
235
+ this.stagePrefix = stage;
236
+
237
+ return this;
238
+ }
239
+ }
240
+
241
+ interface ScriptResult {
242
+ as: string;
243
+ file: FindFileResult;
244
+ path: string;
245
+ code: string;
246
+ }
247
+
248
+ // function parseScriptsFromBlade(file: string, service: Record<string, ParsedModule>): string[] {
249
+ // const bladeText = fs.readFileSync(file, 'utf8');
250
+ //
251
+ // const html = parse(bladeText);
252
+ //
253
+ // return html.querySelectorAll('script[lang]')
254
+ // .filter(
255
+ // (el) => ['ts', 'typescript'].includes(el.getAttribute('lang') || '')
256
+ // )
257
+ // .map((el) => el.innerHTML)
258
+ // .filter((c) => c.trim() !== '');
259
+ // }
260
+
261
+ function findBladeFiles(patterns: string | string[]) {
262
+ return findFilesFromGlobArray(Array.isArray(patterns) ? patterns : [patterns]);
263
+ }
264
+
265
+ function parseScriptsFromBlades(files: FindFileResult[]): ScriptResult[] {
266
+ return files.map((file) => {
267
+ const bladeText = fs.readFileSync(file.fullpath, 'utf8');
268
+
269
+ const html = parse(bladeText);
270
+ // const key = file.relativePath.replace(/.blade.php$/, '').toLowerCase();
271
+
272
+ return html.querySelectorAll('script[lang][data-macro]')
273
+ .filter(
274
+ (el) => ['ts', 'typescript'].includes(el.getAttribute('lang') || '')
275
+ )
276
+ .map((el) => ({
277
+ as: el.getAttribute('data-macro') || '',
278
+ file: file,
279
+ path: file.relativePath.replace(/.blade.php$/, ''),
280
+ code: el.innerHTML
281
+ }))
282
+ .filter((c) => c.code.trim() !== '');
283
+ })
284
+ .flat();
285
+ }
286
+
287
+ type CommentPlaceholder = { key: string; value: string; };
288
+
289
+ function stripComments(code: string): { code: string; comments: CommentPlaceholder[] } {
290
+ const comments: CommentPlaceholder[] = [];
291
+ let i = 0;
292
+
293
+ code = code
294
+ // Multi-line /* */
295
+ .replace(/\/\*[\s\S]*?\*\//g, match => {
296
+ const key = `__COMMENT_BLOCK_${i}__`;
297
+ comments.push({ key, value: match });
298
+ i++;
299
+ return key;
300
+ })
301
+ // Single-line //
302
+ .replace(/\/\/.*$/gm, match => {
303
+ const key = `__COMMENT_LINE_${i}__`;
304
+ comments.push({ key, value: match });
305
+ i++;
306
+ return key;
307
+ });
308
+
309
+ return { code, comments };
310
+ }
311
+
312
+ function restoreComments(code: string, comments: CommentPlaceholder[]): string {
313
+ for (const { key, value } of comments) {
314
+ const re = new RegExp(key, 'g');
315
+ code = code.replace(re, value);
316
+ }
317
+
318
+ return code;
319
+ }
package/src/next/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './fusion';
2
- export * from './utilities';
1
+ export * from './fusion';
2
+ export * from './utilities';