@windwalker-io/core 4.2.1 → 4.2.3
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/debugger/{Dashboard-CQHU0d2H.js → Dashboard-Bm7ihi81.js} +1 -1
- package/dist/debugger/{Database-VIM7Qa1v.js → Database-BGuRRq-L.js} +1 -1
- package/dist/debugger/{DefaultLayout-B32TQLQX.js → DefaultLayout-DviqbPNR.js} +1 -1
- package/dist/debugger/{Events-CUBbmkGz.js → Events-CNF6gvg0.js} +1 -1
- package/dist/debugger/{KeyValueTable-CQHDOoM1.js → KeyValueTable-BfTkP1Rg.js} +1 -1
- package/dist/debugger/{Request-aNwJ2Iha.js → Request-yQA1-Fkb.js} +1 -1
- package/dist/debugger/{Routing-D8BolD7h.js → Routing-C5mAPB17.js} +1 -1
- package/dist/debugger/{System-DGIjiMcw.js → System-JFuNpoZY.js} +1 -1
- package/dist/debugger/{Timeline-Bj8IvPmS.js → Timeline-Uii-K9v_.js} +1 -1
- package/dist/debugger/debugger.js +10 -10
- package/dist/next.d.ts +15 -1
- package/dist/next.js +55 -13
- package/package.json +4 -4
- package/src/app/app.ts +43 -0
- package/src/next/fusion/processors/cssModulize.ts +23 -1
- package/src/next/fusion/processors/index.ts +2 -2
- package/src/next/fusion/processors/jsModulize.ts +56 -56
- package/src/next/utilities/asset-sync.ts +1 -1
package/dist/next.d.ts
CHANGED
|
@@ -18,6 +18,13 @@ export declare function containsMiddleGlob(str: string): boolean;
|
|
|
18
18
|
|
|
19
19
|
export declare function cssModulize(entry: string, dest: string): CssModulizeProcessor;
|
|
20
20
|
|
|
21
|
+
export declare function cssModulizeDeep(stage: string, entry: string, dest: string, options?: CssModulizeDeepOptions): CssModulizeProcessor;
|
|
22
|
+
|
|
23
|
+
export declare interface CssModulizeDeepOptions {
|
|
24
|
+
mergeCss?: boolean;
|
|
25
|
+
parseBlades?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
declare class CssModulizeProcessor implements ProcessorInterface {
|
|
22
29
|
protected processor: ReturnType<typeof css>;
|
|
23
30
|
protected bladePatterns: string[];
|
|
@@ -54,7 +61,14 @@ export declare function installVendors(npmVendors?: string[], to?: string): {
|
|
|
54
61
|
|
|
55
62
|
export declare function jsModulize(entry: string, dest: string, options?: JsModulizeOptions): JsModulizeProcessor;
|
|
56
63
|
|
|
57
|
-
declare
|
|
64
|
+
export declare function jsModulizeDeep(stage: string, entry: string, dest: string, options?: JsModulizeDeepOptions): JsModulizeProcessor;
|
|
65
|
+
|
|
66
|
+
export declare interface JsModulizeDeepOptions extends JsModulizeOptions {
|
|
67
|
+
mergeScripts?: boolean;
|
|
68
|
+
parseBlades?: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export declare interface JsModulizeOptions {
|
|
58
72
|
tmpPath?: string;
|
|
59
73
|
cleanTmp?: boolean;
|
|
60
74
|
}
|
package/dist/next.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getGlobBaseFromPattern, callback, css, js,
|
|
1
|
+
import { getGlobBaseFromPattern, callback, css, js, plugin, callbackAfterBuild, copyGlob, symlink } from "@windwalker-io/fusion-next";
|
|
2
2
|
import isGlob from "is-glob";
|
|
3
3
|
import micromatch from "micromatch";
|
|
4
4
|
import path, { relative, normalize, resolve } from "node:path";
|
|
@@ -55,7 +55,7 @@ function findModules(suffix = "", rootModule = "src/Module") {
|
|
|
55
55
|
}) || [];
|
|
56
56
|
}).flat();
|
|
57
57
|
if (rootModule) {
|
|
58
|
-
vendors.
|
|
58
|
+
vendors.push(rootModule + "/" + suffix);
|
|
59
59
|
}
|
|
60
60
|
return [...new Set(vendors)];
|
|
61
61
|
}
|
|
@@ -199,6 +199,19 @@ function systemCSSFix() {
|
|
|
199
199
|
function cssModulize(entry, dest) {
|
|
200
200
|
return new CssModulizeProcessor(css(entry, dest));
|
|
201
201
|
}
|
|
202
|
+
function cssModulizeDeep(stage, entry, dest, options = {}) {
|
|
203
|
+
const processor = cssModulize(entry, dest);
|
|
204
|
+
if (options.mergeCss ?? true) {
|
|
205
|
+
processor.mergeCss(findModules(`${stage}/**/assets/*.scss`));
|
|
206
|
+
}
|
|
207
|
+
if (options.parseBlades ?? true) {
|
|
208
|
+
processor.parseBlades(
|
|
209
|
+
findModules(`${stage}/**/*.blade.php`),
|
|
210
|
+
findPackages("views/**/*.blade.php")
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
return processor;
|
|
214
|
+
}
|
|
202
215
|
class CssModulizeProcessor {
|
|
203
216
|
constructor(processor, bladePatterns = [], cssPatterns = []) {
|
|
204
217
|
this.processor = processor;
|
|
@@ -267,6 +280,21 @@ ${imports}
|
|
|
267
280
|
function jsModulize(entry, dest, options = {}) {
|
|
268
281
|
return new JsModulizeProcessor(js(entry, dest), options);
|
|
269
282
|
}
|
|
283
|
+
function jsModulizeDeep(stage, entry, dest, options = {}) {
|
|
284
|
+
const processor = jsModulize(entry, dest, options).stage(stage.toLowerCase());
|
|
285
|
+
if (options.mergeScripts ?? true) {
|
|
286
|
+
processor.mergeScripts(
|
|
287
|
+
findModules(`${stage}/**/assets/*.ts`)
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
if (options.parseBlades ?? true) {
|
|
291
|
+
processor.parseBlades(
|
|
292
|
+
findModules(`${stage}/**/*.blade.php`),
|
|
293
|
+
findPackages("views/**/*.blade.php")
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
return processor;
|
|
297
|
+
}
|
|
270
298
|
class JsModulizeProcessor {
|
|
271
299
|
constructor(processor, options = {}) {
|
|
272
300
|
this.processor = processor;
|
|
@@ -285,6 +313,9 @@ class JsModulizeProcessor {
|
|
|
285
313
|
builder.postBuildCallbacks.push((options, bundle) => {
|
|
286
314
|
fs$1.removeSync(tmpPath);
|
|
287
315
|
});
|
|
316
|
+
builder.serverStopCallbacks.push((options, bundle) => {
|
|
317
|
+
fs$1.removeSync(tmpPath);
|
|
318
|
+
});
|
|
288
319
|
}
|
|
289
320
|
this.ignoreMainImport(task);
|
|
290
321
|
builder.resolveIdCallbacks.push((id) => {
|
|
@@ -293,11 +324,12 @@ class JsModulizeProcessor {
|
|
|
293
324
|
}
|
|
294
325
|
});
|
|
295
326
|
const scriptFiles = findFilesFromGlobArray(this.scriptPatterns);
|
|
296
|
-
const bladeFiles =
|
|
327
|
+
const bladeFiles = findBladeFiles(this.bladePatterns);
|
|
297
328
|
builder.loadCallbacks.push((src, options) => {
|
|
298
329
|
const srcFile = stripUrlQuery(src);
|
|
330
|
+
const scripts = {};
|
|
299
331
|
if (normalize(srcFile) === inputFile) {
|
|
300
|
-
|
|
332
|
+
const bladeScripts = parseScriptsFromBlades(bladeFiles);
|
|
301
333
|
for (const scriptFile of scriptFiles) {
|
|
302
334
|
let fullpath = scriptFile.fullpath;
|
|
303
335
|
if (fullpath.endsWith(".d.ts")) {
|
|
@@ -310,25 +342,31 @@ class JsModulizeProcessor {
|
|
|
310
342
|
key = this.stagePrefix + "/" + key;
|
|
311
343
|
}
|
|
312
344
|
key = "view:" + crypto.createHash("md5").update(key).digest("hex");
|
|
313
|
-
|
|
314
|
-
`;
|
|
345
|
+
scripts[key] = fullpath;
|
|
315
346
|
}
|
|
316
347
|
const listens = [];
|
|
317
348
|
fs$1.ensureDirSync(tmpPath);
|
|
318
|
-
for (const result of
|
|
349
|
+
for (const result of bladeScripts) {
|
|
319
350
|
let key = result.as;
|
|
320
|
-
const
|
|
351
|
+
const filename = result.path.replace(/\\|\//g, "_");
|
|
352
|
+
const tmpFile = tmpPath + "/" + filename + ".ts";
|
|
321
353
|
if (!fs$1.existsSync(tmpFile) || fs$1.readFileSync(tmpFile, "utf8") !== result.code) {
|
|
322
354
|
fs$1.writeFileSync(tmpFile, result.code);
|
|
323
355
|
}
|
|
324
|
-
|
|
325
|
-
`;
|
|
356
|
+
scripts[`inline:${key}`] = tmpFile;
|
|
326
357
|
const fullpath = resolve(result.file.fullpath).replace(/\\/g, "/");
|
|
327
358
|
if (!listens.includes(fullpath)) {
|
|
328
359
|
listens.push(fullpath);
|
|
329
360
|
}
|
|
330
361
|
}
|
|
331
|
-
listJS
|
|
362
|
+
let listJS = `{
|
|
363
|
+
`;
|
|
364
|
+
for (const key in scripts) {
|
|
365
|
+
const fullpath = scripts[key];
|
|
366
|
+
listJS += `'${key}': () => import('${fullpath}'),
|
|
367
|
+
`;
|
|
368
|
+
}
|
|
369
|
+
listJS += `}`;
|
|
332
370
|
builder.watches.push(...listens);
|
|
333
371
|
let { code, comments } = stripComments(fs$1.readFileSync(srcFile, "utf-8"));
|
|
334
372
|
code = code.replace(/defineJsModules\((.*?)\)/g, listJS);
|
|
@@ -371,8 +409,10 @@ class JsModulizeProcessor {
|
|
|
371
409
|
return this;
|
|
372
410
|
}
|
|
373
411
|
}
|
|
374
|
-
function
|
|
375
|
-
|
|
412
|
+
function findBladeFiles(patterns) {
|
|
413
|
+
return findFilesFromGlobArray(Array.isArray(patterns) ? patterns : [patterns]);
|
|
414
|
+
}
|
|
415
|
+
function parseScriptsFromBlades(files) {
|
|
376
416
|
return files.map((file) => {
|
|
377
417
|
const bladeText = fs$1.readFileSync(file.fullpath, "utf8");
|
|
378
418
|
const html = parse(bladeText);
|
|
@@ -520,6 +560,7 @@ export {
|
|
|
520
560
|
cloneAssets,
|
|
521
561
|
containsMiddleGlob,
|
|
522
562
|
cssModulize,
|
|
563
|
+
cssModulizeDeep,
|
|
523
564
|
ensureDirPath,
|
|
524
565
|
findFilesFromGlobArray,
|
|
525
566
|
findModules,
|
|
@@ -528,6 +569,7 @@ export {
|
|
|
528
569
|
injectSystemJS,
|
|
529
570
|
installVendors,
|
|
530
571
|
jsModulize,
|
|
572
|
+
jsModulizeDeep,
|
|
531
573
|
loadJson,
|
|
532
574
|
removeLastGlob,
|
|
533
575
|
resolveModuleRealpath,
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windwalker-io/core",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Windwalker Core JS package",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "yarn build:next && yarn build:debugger",
|
|
8
8
|
"dev": "yarn dev:debugger",
|
|
9
|
-
"build:next": "vite build --config vite.config.
|
|
9
|
+
"build:next": "vite build --config vite.next.config.ts",
|
|
10
10
|
"dev:next": "yarn build:next --watch",
|
|
11
|
-
"build:debugger": "vite build --config vite.config.
|
|
12
|
-
"dev:debugger": "vite --config vite.config.
|
|
11
|
+
"build:debugger": "vite build --config vite.debugger.config.ts",
|
|
12
|
+
"dev:debugger": "vite --config vite.debugger.config.ts"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": "./src/index.js",
|
package/src/app/app.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
type Route = string | RouteLoader;
|
|
2
2
|
type RouteLoader = () => Promise<any>;
|
|
3
3
|
|
|
4
|
+
let currentProps: Record<string, any> | null = null;
|
|
5
|
+
|
|
4
6
|
export class App {
|
|
5
7
|
routes: Record<string, RouteLoader> = {};
|
|
8
|
+
queue: (() => Promise<any>)[] = [];
|
|
9
|
+
queueRunning = false;
|
|
6
10
|
|
|
7
11
|
constructor(routes: Record<string, Route> = {}) {
|
|
8
12
|
this.registerRoutes(routes);
|
|
@@ -42,9 +46,48 @@ export class App {
|
|
|
42
46
|
return target();
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
async importSync<T = any>(route: string, props: Record<string, any> = {}): Promise<T> {
|
|
50
|
+
return new Promise<any>((resolve) => {
|
|
51
|
+
const target = this.routes[route];
|
|
52
|
+
|
|
53
|
+
if (!target) {
|
|
54
|
+
throw new Error(`Unable to import file: ${route}, file not found.`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.queue.push(async () => {
|
|
58
|
+
currentProps = props;
|
|
59
|
+
resolve(await target());
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
this.runQueue();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async runQueue() {
|
|
67
|
+
if (!this.queueRunning) {
|
|
68
|
+
this.queueRunning = true;
|
|
69
|
+
let item: () => any;
|
|
70
|
+
|
|
71
|
+
while (item = this.queue.shift()) {
|
|
72
|
+
await item();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.queueRunning = false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
45
79
|
reset() {
|
|
46
80
|
this.routes = {};
|
|
47
81
|
|
|
48
82
|
return this;
|
|
49
83
|
}
|
|
50
84
|
}
|
|
85
|
+
|
|
86
|
+
export function useMacroProps<T extends Record<string, any> = Record<string, any>>(): T {
|
|
87
|
+
console.log('get');
|
|
88
|
+
if (currentProps == null) {
|
|
89
|
+
throw new Error('Cannot get macro props.');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return { ...currentProps } as T;
|
|
93
|
+
}
|
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
import { stripUrlQuery } from '@/next';
|
|
2
1
|
import { type ConfigBuilder, css, type ProcessorInterface, type ProcessorPreview } from '@windwalker-io/fusion-next';
|
|
3
2
|
import { WatchTask } from '@windwalker-io/fusion-next/src/types';
|
|
4
3
|
import fg from 'fast-glob';
|
|
5
4
|
import fs from 'fs-extra';
|
|
6
5
|
import { parse } from 'node-html-parser';
|
|
7
6
|
import { normalize, resolve } from 'node:path';
|
|
7
|
+
import { findModules, findPackages, stripUrlQuery } from '../../utilities';
|
|
8
8
|
|
|
9
9
|
export function cssModulize(entry: string, dest: string) {
|
|
10
10
|
return new CssModulizeProcessor(css(entry, dest));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export interface CssModulizeDeepOptions {
|
|
14
|
+
mergeCss?: boolean;
|
|
15
|
+
parseBlades?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function cssModulizeDeep(stage: string, entry: string, dest: string, options: CssModulizeDeepOptions = {}) {
|
|
19
|
+
const processor = cssModulize(entry, dest);
|
|
20
|
+
|
|
21
|
+
if (options.mergeCss ?? true) {
|
|
22
|
+
processor.mergeCss(findModules(`${stage}/**/assets/*.scss`));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (options.parseBlades ?? true) {
|
|
26
|
+
processor.parseBlades(
|
|
27
|
+
findModules(`${stage}/**/*.blade.php`),
|
|
28
|
+
findPackages('views/**/*.blade.php'),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return processor;
|
|
33
|
+
}
|
|
34
|
+
|
|
13
35
|
class CssModulizeProcessor implements ProcessorInterface {
|
|
14
36
|
|
|
15
37
|
constructor(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { cssModulize } from './cssModulize';
|
|
2
|
-
export { jsModulize } from './jsModulize';
|
|
1
|
+
export { cssModulize, cssModulizeDeep, type CssModulizeDeepOptions } from './cssModulize';
|
|
2
|
+
export { jsModulize, jsModulizeDeep, type JsModulizeOptions, type JsModulizeDeepOptions } from './jsModulize';
|
|
3
3
|
export { installVendors } from './installVendors';
|
|
4
4
|
export { cloneAssets } from './cloneAssets';
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { type FindFileResult, findFilesFromGlobArray, stripUrlQuery } from '@/next';
|
|
2
1
|
import {
|
|
3
2
|
type BuildTask,
|
|
4
3
|
type ConfigBuilder,
|
|
4
|
+
js,
|
|
5
5
|
type MaybePromise,
|
|
6
|
+
plugin as addPlugin,
|
|
6
7
|
type ProcessorInterface,
|
|
7
8
|
type ProcessorPreview,
|
|
8
|
-
js,
|
|
9
9
|
shortHash,
|
|
10
|
-
plugin as addPlugin,
|
|
11
10
|
} from '@windwalker-io/fusion-next';
|
|
12
|
-
import { WatchTask } from '@windwalker-io/fusion-next/src/types';
|
|
13
11
|
import fs from 'fs-extra';
|
|
14
|
-
import crypto from 'node:crypto';
|
|
15
12
|
import { parse } from 'node-html-parser';
|
|
13
|
+
import crypto from 'node:crypto';
|
|
16
14
|
import { normalize, resolve } from 'node:path';
|
|
15
|
+
import { type FindFileResult, findFilesFromGlobArray, findModules, findPackages, stripUrlQuery } from '../../utilities';
|
|
17
16
|
|
|
18
17
|
export interface JsModulizeOptions {
|
|
19
18
|
tmpPath?: string;
|
|
@@ -24,6 +23,31 @@ export function jsModulize(entry: string, dest: string, options: JsModulizeOptio
|
|
|
24
23
|
return new JsModulizeProcessor(js(entry, dest), options);
|
|
25
24
|
}
|
|
26
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
|
+
|
|
27
51
|
export class JsModulizeProcessor implements ProcessorInterface {
|
|
28
52
|
protected scriptPatterns: string[] = [];
|
|
29
53
|
protected bladePatterns: string[] = [];
|
|
@@ -39,36 +63,15 @@ export class JsModulizeProcessor implements ProcessorInterface {
|
|
|
39
63
|
const tmpPath = this.options.tmpPath ?? resolve('./tmp/fusion/jsmodules/').replace(/\\/g, '/');
|
|
40
64
|
const clean = this.options.cleanTmp ?? true;
|
|
41
65
|
|
|
42
|
-
// const appFileName = 'js/' + this.stagePrefix + '/app.js';
|
|
43
|
-
// const appSrcFileName = 'resources/assets/src/' + this.stagePrefix + '/app.js';
|
|
44
|
-
// const task = builder.addTask(appFileName);
|
|
45
|
-
|
|
46
66
|
if (clean) {
|
|
47
67
|
builder.postBuildCallbacks.push((options, bundle) => {
|
|
48
68
|
fs.removeSync(tmpPath);
|
|
49
69
|
});
|
|
70
|
+
builder.serverStopCallbacks.push((options, bundle) => {
|
|
71
|
+
fs.removeSync(tmpPath);
|
|
72
|
+
});
|
|
50
73
|
}
|
|
51
74
|
|
|
52
|
-
// builder.merge({
|
|
53
|
-
// resolve: {
|
|
54
|
-
// alias: {
|
|
55
|
-
// '@main': task.input
|
|
56
|
-
// }
|
|
57
|
-
// }
|
|
58
|
-
// });
|
|
59
|
-
|
|
60
|
-
// builder.entryFileNamesCallbacks.push((chunkInfo) => {
|
|
61
|
-
// if (chunkInfo.facadeModuleId === appSrcFileName) {
|
|
62
|
-
// return appFileName;
|
|
63
|
-
// }
|
|
64
|
-
// });
|
|
65
|
-
//
|
|
66
|
-
// builder.resolveIdCallbacks.push((id) => {
|
|
67
|
-
// if (id === task.input) {
|
|
68
|
-
// return appSrcFileName;
|
|
69
|
-
// }
|
|
70
|
-
// });
|
|
71
|
-
|
|
72
75
|
this.ignoreMainImport(task);
|
|
73
76
|
|
|
74
77
|
builder.resolveIdCallbacks.push((id) => {
|
|
@@ -77,24 +80,27 @@ export class JsModulizeProcessor implements ProcessorInterface {
|
|
|
77
80
|
}
|
|
78
81
|
});
|
|
79
82
|
|
|
83
|
+
// Todo: Must dynamic changes in load() hook
|
|
80
84
|
const scriptFiles = findFilesFromGlobArray(this.scriptPatterns);
|
|
81
|
-
const bladeFiles =
|
|
85
|
+
const bladeFiles = findBladeFiles(this.bladePatterns);
|
|
82
86
|
|
|
83
87
|
// Watches
|
|
84
|
-
//
|
|
88
|
+
// Currently we don't watch blade files because not necessary to reload full-pages.
|
|
89
|
+
// for (const bladeFile of bladeScripts) {
|
|
85
90
|
// builder.watches.push({
|
|
86
91
|
// file: resolve(bladeFile.file.fullpath),
|
|
87
92
|
// moduleFile: inputFile,
|
|
88
|
-
// updateType: '
|
|
93
|
+
// updateType: 'js-update',
|
|
89
94
|
// } satisfies WatchTask);
|
|
90
95
|
// }
|
|
91
96
|
|
|
92
97
|
builder.loadCallbacks.push((src, options) => {
|
|
93
98
|
const srcFile = stripUrlQuery(src);
|
|
94
|
-
|
|
99
|
+
const scripts: Record<string, string> = {};
|
|
100
|
+
|
|
95
101
|
// if (src === appSrcFileName) {
|
|
96
102
|
if (normalize(srcFile) === inputFile) {
|
|
97
|
-
|
|
103
|
+
const bladeScripts = parseScriptsFromBlades(bladeFiles);
|
|
98
104
|
|
|
99
105
|
// Merge standalone ts files
|
|
100
106
|
for (const scriptFile of scriptFiles) {
|
|
@@ -116,7 +122,7 @@ export class JsModulizeProcessor implements ProcessorInterface {
|
|
|
116
122
|
// md5
|
|
117
123
|
key = 'view:' + crypto.createHash('md5').update(key).digest('hex');
|
|
118
124
|
|
|
119
|
-
|
|
125
|
+
scripts[key] = fullpath;
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
// Parse from blades
|
|
@@ -124,19 +130,16 @@ export class JsModulizeProcessor implements ProcessorInterface {
|
|
|
124
130
|
|
|
125
131
|
fs.ensureDirSync(tmpPath);
|
|
126
132
|
|
|
127
|
-
for (const result of
|
|
133
|
+
for (const result of bladeScripts) {
|
|
128
134
|
let key = result.as;
|
|
129
|
-
const
|
|
135
|
+
const filename = result.path.replace(/\\|\//g, '_');
|
|
136
|
+
const tmpFile = tmpPath + '/' + filename + '.ts';
|
|
130
137
|
|
|
131
138
|
if (!fs.existsSync(tmpFile) || fs.readFileSync(tmpFile, 'utf8') !== result.code) {
|
|
132
139
|
fs.writeFileSync(tmpFile, result.code);
|
|
133
140
|
}
|
|
134
141
|
|
|
135
|
-
|
|
136
|
-
// key = this.stagePrefix + '/' + key;
|
|
137
|
-
// }
|
|
138
|
-
|
|
139
|
-
listJS += `'inline:${key}': () => import('${tmpFile}'),\n`;
|
|
142
|
+
scripts[`inline:${key}`] = tmpFile;
|
|
140
143
|
|
|
141
144
|
const fullpath = resolve(result.file.fullpath).replace(/\\/g, '/');
|
|
142
145
|
|
|
@@ -145,19 +148,14 @@ export class JsModulizeProcessor implements ProcessorInterface {
|
|
|
145
148
|
}
|
|
146
149
|
}
|
|
147
150
|
|
|
148
|
-
listJS
|
|
151
|
+
let listJS = `{\n`;
|
|
149
152
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// const app = new App();
|
|
157
|
-
// app.registerRoutes(${listJS});
|
|
158
|
-
//
|
|
159
|
-
// export default app;
|
|
160
|
-
// `;
|
|
153
|
+
for (const key in scripts) {
|
|
154
|
+
const fullpath = scripts[key];
|
|
155
|
+
listJS += `'${key}': () => import('${fullpath}'),\n`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
listJS += `}`;
|
|
161
159
|
|
|
162
160
|
// Listen extra files
|
|
163
161
|
builder.watches.push(...listens);
|
|
@@ -237,9 +235,11 @@ interface ScriptResult {
|
|
|
237
235
|
// .filter((c) => c.trim() !== '');
|
|
238
236
|
// }
|
|
239
237
|
|
|
240
|
-
function
|
|
241
|
-
|
|
238
|
+
function findBladeFiles(patterns: string | string[]) {
|
|
239
|
+
return findFilesFromGlobArray(Array.isArray(patterns) ? patterns : [patterns]);
|
|
240
|
+
}
|
|
242
241
|
|
|
242
|
+
function parseScriptsFromBlades(files: FindFileResult[]): ScriptResult[] {
|
|
243
243
|
return files.map((file) => {
|
|
244
244
|
const bladeText = fs.readFileSync(file.fullpath, 'utf8');
|
|
245
245
|
|