@lark-apaas/coding-vite-preset 0.1.0
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/LICENSE +7 -0
- package/README.md +68 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +69 -0
- package/lib/index.js.map +1 -0
- package/lib/module-alias/clsx.d.ts +4 -0
- package/lib/module-alias/clsx.d.ts.map +1 -0
- package/lib/module-alias/clsx.js +13 -0
- package/lib/module-alias/clsx.js.map +1 -0
- package/lib/module-alias/echarts-for-react.d.ts +14 -0
- package/lib/module-alias/echarts-for-react.d.ts.map +1 -0
- package/lib/module-alias/echarts-for-react.js +142 -0
- package/lib/module-alias/echarts-for-react.js.map +1 -0
- package/lib/module-alias/echarts.d.ts +9 -0
- package/lib/module-alias/echarts.d.ts.map +1 -0
- package/lib/module-alias/echarts.js +84 -0
- package/lib/module-alias/echarts.js.map +1 -0
- package/lib/module-alias/registry_echarts_theme.d.ts +692 -0
- package/lib/module-alias/registry_echarts_theme.d.ts.map +1 -0
- package/lib/module-alias/registry_echarts_theme.js +394 -0
- package/lib/module-alias/registry_echarts_theme.js.map +1 -0
- package/lib/polyfills/index.d.ts +15 -0
- package/lib/polyfills/index.d.ts.map +1 -0
- package/lib/polyfills/index.js +36 -0
- package/lib/polyfills/index.js.map +1 -0
- package/lib/preset.d.ts +14 -0
- package/lib/preset.d.ts.map +1 -0
- package/lib/preset.js +452 -0
- package/lib/preset.js.map +1 -0
- package/lib/utils/hmr-timing.d.ts +10 -0
- package/lib/utils/hmr-timing.d.ts.map +1 -0
- package/lib/utils/hmr-timing.js +102 -0
- package/lib/utils/hmr-timing.js.map +1 -0
- package/lib/utils/normalize-base-path.d.ts +12 -0
- package/lib/utils/normalize-base-path.d.ts.map +1 -0
- package/lib/utils/normalize-base-path.js +24 -0
- package/lib/utils/normalize-base-path.js.map +1 -0
- package/lib/utils/snapdom-proxy.d.ts +8 -0
- package/lib/utils/snapdom-proxy.d.ts.map +1 -0
- package/lib/utils/snapdom-proxy.js +52 -0
- package/lib/utils/snapdom-proxy.js.map +1 -0
- package/lib/vite-plugins/banner-plugin.d.ts +3 -0
- package/lib/vite-plugins/banner-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/banner-plugin.js +26 -0
- package/lib/vite-plugins/banner-plugin.js.map +1 -0
- package/lib/vite-plugins/css-legacy-plugin.d.ts +12 -0
- package/lib/vite-plugins/css-legacy-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/css-legacy-plugin.js +205 -0
- package/lib/vite-plugins/css-legacy-plugin.js.map +1 -0
- package/lib/vite-plugins/error-overlay-plugin.d.ts +33 -0
- package/lib/vite-plugins/error-overlay-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/error-overlay-plugin.js +129 -0
- package/lib/vite-plugins/error-overlay-plugin.js.map +1 -0
- package/lib/vite-plugins/html-output-plugin.d.ts +21 -0
- package/lib/vite-plugins/html-output-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/html-output-plugin.js +171 -0
- package/lib/vite-plugins/html-output-plugin.js.map +1 -0
- package/lib/vite-plugins/module-alias-plugin.d.ts +10 -0
- package/lib/vite-plugins/module-alias-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/module-alias-plugin.js +40 -0
- package/lib/vite-plugins/module-alias-plugin.js.map +1 -0
- package/lib/vite-plugins/og-meta-plugin.d.ts +17 -0
- package/lib/vite-plugins/og-meta-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/og-meta-plugin.js +80 -0
- package/lib/vite-plugins/og-meta-plugin.js.map +1 -0
- package/lib/vite-plugins/polyfill-plugin.d.ts +12 -0
- package/lib/vite-plugins/polyfill-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/polyfill-plugin.js +132 -0
- package/lib/vite-plugins/polyfill-plugin.js.map +1 -0
- package/lib/vite-plugins/route-parser-plugin.d.ts +13 -0
- package/lib/vite-plugins/route-parser-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/route-parser-plugin.js +120 -0
- package/lib/vite-plugins/route-parser-plugin.js.map +1 -0
- package/lib/vite-plugins/runtime-injection-plugin.d.ts +23 -0
- package/lib/vite-plugins/runtime-injection-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/runtime-injection-plugin.js +93 -0
- package/lib/vite-plugins/runtime-injection-plugin.js.map +1 -0
- package/lib/vite-plugins/slardar-plugin.d.ts +10 -0
- package/lib/vite-plugins/slardar-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/slardar-plugin.js +102 -0
- package/lib/vite-plugins/slardar-plugin.js.map +1 -0
- package/lib/vite-plugins/source-map-upload-plugin.d.ts +7 -0
- package/lib/vite-plugins/source-map-upload-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/source-map-upload-plugin.js +85 -0
- package/lib/vite-plugins/source-map-upload-plugin.js.map +1 -0
- package/lib/vite-plugins/static-assets-plugin.d.ts +27 -0
- package/lib/vite-plugins/static-assets-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/static-assets-plugin.js +393 -0
- package/lib/vite-plugins/static-assets-plugin.js.map +1 -0
- package/lib/vite-plugins/view-context-plugin.d.ts +4 -0
- package/lib/vite-plugins/view-context-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/view-context-plugin.js +40 -0
- package/lib/vite-plugins/view-context-plugin.js.map +1 -0
- package/lib/vite-plugins/vite-client-patch-plugin.d.ts +23 -0
- package/lib/vite-plugins/vite-client-patch-plugin.d.ts.map +1 -0
- package/lib/vite-plugins/vite-client-patch-plugin.js +53 -0
- package/lib/vite-plugins/vite-client-patch-plugin.js.map +1 -0
- package/package.json +61 -0
- package/src/empty.css +1 -0
- package/src/inspector-stub.js +6 -0
- package/src/module-alias/clsx.mjs +8 -0
- package/src/module-alias/echarts-for-react.mjs +129 -0
- package/src/module-alias/echarts.mjs +43 -0
- package/src/module-alias/registry_echarts_theme.mjs +390 -0
- package/src/overlay/components.js +94 -0
- package/src/overlay/index.js +443 -0
- package/src/overlay/vite-client.js +554 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.minifyHtmlWithHbsProtection = minifyHtmlWithHbsProtection;
|
|
7
|
+
exports.htmlOutputPlugin = htmlOutputPlugin;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const html_minifier_terser_1 = require("html-minifier-terser");
|
|
11
|
+
/**
|
|
12
|
+
* Minify HTML while preserving HBS (Handlebars) template expressions.
|
|
13
|
+
*
|
|
14
|
+
* HBS expressions like {{csrfToken}} and {{{appAvatar}}} are temporarily
|
|
15
|
+
* replaced with safe placeholders before minification, then restored after.
|
|
16
|
+
*/
|
|
17
|
+
async function minifyHtmlWithHbsProtection(html) {
|
|
18
|
+
// Replace HBS expressions with placeholders before minification
|
|
19
|
+
// to prevent html-minifier-terser from corrupting them
|
|
20
|
+
const hbsPlaceholders = [];
|
|
21
|
+
let processed = html.replace(/\{\{\{?.+?\}\}\}?/g, (match) => {
|
|
22
|
+
const index = hbsPlaceholders.length;
|
|
23
|
+
hbsPlaceholders.push(match);
|
|
24
|
+
return `__HBS_${index}__`;
|
|
25
|
+
});
|
|
26
|
+
processed = await (0, html_minifier_terser_1.minify)(processed, {
|
|
27
|
+
collapseWhitespace: true,
|
|
28
|
+
removeComments: true,
|
|
29
|
+
removeRedundantAttributes: true,
|
|
30
|
+
removeEmptyAttributes: true,
|
|
31
|
+
minifyCSS: true,
|
|
32
|
+
// Do NOT minifyJS — inline scripts may reference HBS placeholders
|
|
33
|
+
minifyJS: false,
|
|
34
|
+
});
|
|
35
|
+
// Restore HBS expressions
|
|
36
|
+
processed = processed.replace(/__HBS_(\d+)__/g, (_, index) => {
|
|
37
|
+
return hbsPlaceholders[Number(index)];
|
|
38
|
+
});
|
|
39
|
+
return processed;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Vite plugin to handle HTML output:
|
|
43
|
+
* 1. In production: fixes HTML output path (removes extra 'client' directory)
|
|
44
|
+
* 2. In development: writes transformed HTML to disk for backend to serve
|
|
45
|
+
*/
|
|
46
|
+
function htmlOutputPlugin(options) {
|
|
47
|
+
const { isDev, outDir } = options;
|
|
48
|
+
let config;
|
|
49
|
+
let server = null;
|
|
50
|
+
/**
|
|
51
|
+
* Transform and write HTML to disk for backend to serve
|
|
52
|
+
*/
|
|
53
|
+
async function writeHtmlToDisk() {
|
|
54
|
+
if (!server || !config)
|
|
55
|
+
return;
|
|
56
|
+
try {
|
|
57
|
+
// Find the input HTML file from rollup options
|
|
58
|
+
const rollupInput = config.build.rollupOptions?.input;
|
|
59
|
+
let htmlPath;
|
|
60
|
+
if (typeof rollupInput === 'string') {
|
|
61
|
+
htmlPath = rollupInput;
|
|
62
|
+
}
|
|
63
|
+
else if (Array.isArray(rollupInput)) {
|
|
64
|
+
htmlPath = rollupInput.find((f) => f.endsWith('.html')) || '';
|
|
65
|
+
}
|
|
66
|
+
else if (rollupInput && typeof rollupInput === 'object') {
|
|
67
|
+
htmlPath =
|
|
68
|
+
Object.values(rollupInput).find((f) => f.endsWith('.html')) || '';
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
htmlPath = path_1.default.resolve(config.root, 'index.html');
|
|
72
|
+
}
|
|
73
|
+
if (!htmlPath || !fs_1.default.existsSync(htmlPath)) {
|
|
74
|
+
console.warn(`[html-output] HTML file not found: ${htmlPath}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// Read the source HTML
|
|
78
|
+
let html = fs_1.default.readFileSync(htmlPath, 'utf-8');
|
|
79
|
+
// Apply Vite's HTML transformations (this calls all plugin's transformIndexHtml hooks)
|
|
80
|
+
const url = '/' + path_1.default.relative(config.root, htmlPath);
|
|
81
|
+
html = await server.transformIndexHtml(url, html);
|
|
82
|
+
// Write to output directory
|
|
83
|
+
const outputPath = path_1.default.resolve(outDir, 'index.html');
|
|
84
|
+
// Ensure output directory exists
|
|
85
|
+
const dir = path_1.default.dirname(outputPath);
|
|
86
|
+
if (!fs_1.default.existsSync(dir)) {
|
|
87
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
88
|
+
}
|
|
89
|
+
fs_1.default.writeFileSync(outputPath, html);
|
|
90
|
+
console.log(`[html-output] Written to: ${outputPath}`);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
console.error(`[html-output] Failed to write HTML:`, e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
name: 'vite-html-output',
|
|
98
|
+
configResolved(resolvedConfig) {
|
|
99
|
+
config = resolvedConfig;
|
|
100
|
+
},
|
|
101
|
+
configureServer(devServer) {
|
|
102
|
+
if (!isDev)
|
|
103
|
+
return;
|
|
104
|
+
server = devServer;
|
|
105
|
+
// Return a post hook to run after all plugins' configureServer and
|
|
106
|
+
// Vite's internal middlewares are set up
|
|
107
|
+
return () => {
|
|
108
|
+
writeHtmlToDisk();
|
|
109
|
+
// Watch for HTML file changes
|
|
110
|
+
const rollupInput = config.build.rollupOptions?.input;
|
|
111
|
+
let htmlPath;
|
|
112
|
+
if (typeof rollupInput === 'string' && rollupInput.endsWith('.html')) {
|
|
113
|
+
htmlPath = rollupInput;
|
|
114
|
+
}
|
|
115
|
+
else if (rollupInput && typeof rollupInput === 'object') {
|
|
116
|
+
const inputs = Array.isArray(rollupInput)
|
|
117
|
+
? rollupInput
|
|
118
|
+
: Object.values(rollupInput);
|
|
119
|
+
htmlPath = inputs.find((f) => f.endsWith('.html'));
|
|
120
|
+
}
|
|
121
|
+
if (htmlPath) {
|
|
122
|
+
devServer.watcher.add(htmlPath);
|
|
123
|
+
devServer.watcher.on('change', (file) => {
|
|
124
|
+
if (file === htmlPath) {
|
|
125
|
+
console.log(`[html-output] HTML changed, regenerating...`);
|
|
126
|
+
writeHtmlToDisk();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
// In production, fix the HTML output path and minify after build
|
|
133
|
+
async closeBundle() {
|
|
134
|
+
if (!isDev && config) {
|
|
135
|
+
const outDir = config.build.outDir;
|
|
136
|
+
const wrongPath = path_1.default.resolve(outDir, 'client/index.html');
|
|
137
|
+
const correctPath = path_1.default.resolve(outDir, 'index.html');
|
|
138
|
+
// Check if HTML was output to wrong location
|
|
139
|
+
if (fs_1.default.existsSync(wrongPath)) {
|
|
140
|
+
// Move HTML to correct location
|
|
141
|
+
fs_1.default.renameSync(wrongPath, correctPath);
|
|
142
|
+
console.log(`[html-output] Moved: ${wrongPath} -> ${correctPath}`);
|
|
143
|
+
// Remove empty client directory if it exists
|
|
144
|
+
const clientDir = path_1.default.resolve(outDir, 'client');
|
|
145
|
+
try {
|
|
146
|
+
const files = fs_1.default.readdirSync(clientDir);
|
|
147
|
+
if (files.length === 0) {
|
|
148
|
+
fs_1.default.rmdirSync(clientDir);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// Directory doesn't exist or not empty, ignore
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Minify HTML (protect HBS templates like {{csrfToken}}, {{{appAvatar}}})
|
|
156
|
+
if (fs_1.default.existsSync(correctPath)) {
|
|
157
|
+
try {
|
|
158
|
+
const html = fs_1.default.readFileSync(correctPath, 'utf-8');
|
|
159
|
+
const minified = await minifyHtmlWithHbsProtection(html);
|
|
160
|
+
fs_1.default.writeFileSync(correctPath, minified);
|
|
161
|
+
console.log(`[html-output] Minified: ${correctPath}`);
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
console.warn(`[html-output] HTML minification failed, skipping:`, e);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=html-output-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-output-plugin.js","sourceRoot":"","sources":["../../src/vite-plugins/html-output-plugin.ts"],"names":[],"mappings":";;;;;AAWA,kEA0BC;AAcD,4CAwIC;AA3LD,4CAAoB;AACpB,gDAAwB;AAExB,+DAA8C;AAE9C;;;;;GAKG;AACI,KAAK,UAAU,2BAA2B,CAAC,IAAY;IAC5D,gEAAgE;IAChE,uDAAuD;IACvD,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC3D,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC;QACrC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,OAAO,SAAS,KAAK,IAAI,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,SAAS,GAAG,MAAM,IAAA,6BAAM,EAAC,SAAS,EAAE;QAClC,kBAAkB,EAAE,IAAI;QACxB,cAAc,EAAE,IAAI;QACpB,yBAAyB,EAAE,IAAI;QAC/B,qBAAqB,EAAE,IAAI;QAC3B,SAAS,EAAE,IAAI;QACf,kEAAkE;QAClE,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,0BAA0B;IAC1B,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;QAC3D,OAAO,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC;AASD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,OAAgC;IAC/D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClC,I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WAAW,CAAC,CAAC;oBACtC,OAAO,CAAC,GAAG,CAAC,wBAAwB,SAAS,OAAO,WAAW,EAAE,CAAC,CAAC;oBAEnE,6CAA6C;oBAC7C,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;oBACjD,IAAI,CAAC;wBACH,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;wBACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;4BACvB,YAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;wBAC1B,CAAC;oBACH,CAAC;oBAAC,MAAM,CAAC;wBACP,+CAA+C;oBACjD,CAAC;gBACH,CAAC;gBAED,0EAA0E;gBAC1E,IAAI,YAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC/B,IAAI,CAAC;wBACH,MAAM,IAAI,GAAG,YAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;wBACnD,MAAM,QAAQ,GAAG,MAAM,2BAA2B,CAAC,IAAI,CAAC,CAAC;wBACzD,YAAE,CAAC,aAAa,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;wBACxC,OAAO,CAAC,GAAG,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;oBACxD,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACX,OAAO,CAAC,IAAI,CAAC,mDAAmD,EAAE,CAAC,CAAC,CAAC;oBACvE,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Module alias plugin for Vite
|
|
4
|
+
* Replaces imports of 'clsx' and 'echarts' with custom wrapper modules
|
|
5
|
+
*
|
|
6
|
+
* Uses ESM (.mjs) files that work directly in browser without bundling
|
|
7
|
+
*/
|
|
8
|
+
export declare function moduleAliasPlugin(): Plugin;
|
|
9
|
+
export default moduleAliasPlugin;
|
|
10
|
+
//# sourceMappingURL=module-alias-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-alias-plugin.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/module-alias-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CA6B1C;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.moduleAliasPlugin = moduleAliasPlugin;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
/**
|
|
9
|
+
* Module alias plugin for Vite
|
|
10
|
+
* Replaces imports of 'clsx' and 'echarts' with custom wrapper modules
|
|
11
|
+
*
|
|
12
|
+
* Uses ESM (.mjs) files that work directly in browser without bundling
|
|
13
|
+
*/
|
|
14
|
+
function moduleAliasPlugin() {
|
|
15
|
+
return {
|
|
16
|
+
name: 'fullstack-module-alias',
|
|
17
|
+
enforce: 'pre',
|
|
18
|
+
resolveId(source, importer) {
|
|
19
|
+
// Skip if importing from our own module-alias directory
|
|
20
|
+
if (importer && importer.includes('module-alias')) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
// Replace 'clsx' with our wrapper (ESM version in src/)
|
|
24
|
+
if (source === 'clsx') {
|
|
25
|
+
return path_1.default.resolve(__dirname, '../../src/module-alias/clsx.mjs');
|
|
26
|
+
}
|
|
27
|
+
// Replace 'echarts' with our wrapper (ESM version in src/)
|
|
28
|
+
if (source === 'echarts') {
|
|
29
|
+
return path_1.default.resolve(__dirname, '../../src/module-alias/echarts.mjs');
|
|
30
|
+
}
|
|
31
|
+
// Replace 'echarts-for-react' with our wrapper (ESM version in src/)
|
|
32
|
+
if (source === 'echarts-for-react') {
|
|
33
|
+
return path_1.default.resolve(__dirname, '../../src/module-alias/echarts-for-react.mjs');
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.default = moduleAliasPlugin;
|
|
40
|
+
//# sourceMappingURL=module-alias-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-alias-plugin.js","sourceRoot":"","sources":["../../src/vite-plugins/module-alias-plugin.ts"],"names":[],"mappings":";;;;;AASA,8CA6BC;AArCD,gDAAwB;AAExB;;;;;GAKG;AACH,SAAgB,iBAAiB;IAC/B,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,OAAO,EAAE,KAAK;QAEd,SAAS,CAAC,MAAM,EAAE,QAAQ;YACxB,wDAAwD;YACxD,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;gBAClD,OAAO,IAAI,CAAC;YACd,CAAC;YAED,wDAAwD;YACxD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;gBACtB,OAAO,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iCAAiC,CAAC,CAAC;YACpE,CAAC;YAED,2DAA2D;YAC3D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,oCAAoC,CAAC,CAAC;YACvE,CAAC;YAED,qEAAqE;YACrE,IAAI,MAAM,KAAK,mBAAmB,EAAE,CAAC;gBACnC,OAAO,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,8CAA8C,CAAC,CAAC;YACjF,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAED,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
interface OgMetaPluginOptions {
|
|
3
|
+
/** Custom OG tag configuration */
|
|
4
|
+
customTags?: Array<{
|
|
5
|
+
property: string;
|
|
6
|
+
placeholder: string;
|
|
7
|
+
}>;
|
|
8
|
+
/** Custom title placeholder */
|
|
9
|
+
titlePlaceholder?: string;
|
|
10
|
+
/** Custom description placeholder */
|
|
11
|
+
descriptionPlaceholder?: string;
|
|
12
|
+
/** Custom favicon placeholder */
|
|
13
|
+
faviconPlaceholder?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function ogMetaPlugin(options?: OgMetaPluginOptions): Plugin;
|
|
16
|
+
export default ogMetaPlugin;
|
|
17
|
+
//# sourceMappingURL=og-meta-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"og-meta-plugin.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/og-meta-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,UAAU,mBAAmB;IAC3B,kCAAkC;IAClC,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IACH,+BAA+B;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iCAAiC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAaD,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAsGtE;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ogMetaPlugin = ogMetaPlugin;
|
|
4
|
+
// Default OG tags configuration
|
|
5
|
+
const defaultOgTags = [
|
|
6
|
+
{ property: 'og:title', placeholder: '{{appName}}' },
|
|
7
|
+
{ property: 'og:description', placeholder: '{{appDescription}}' },
|
|
8
|
+
{ property: 'og:image', placeholder: '{{appAvatar}}' },
|
|
9
|
+
];
|
|
10
|
+
const defaultTitlePlaceholder = '{{appName}}';
|
|
11
|
+
const defaultDescriptionPlaceholder = '{{appDescription}}';
|
|
12
|
+
const defaultFaviconPlaceholder = '{{appAvatar}}';
|
|
13
|
+
function ogMetaPlugin(options = {}) {
|
|
14
|
+
const { customTags, titlePlaceholder = defaultTitlePlaceholder, descriptionPlaceholder = defaultDescriptionPlaceholder, faviconPlaceholder = defaultFaviconPlaceholder, } = options;
|
|
15
|
+
const ogTags = customTags || defaultOgTags;
|
|
16
|
+
return {
|
|
17
|
+
name: 'fullstack-og-meta',
|
|
18
|
+
transformIndexHtml(html) {
|
|
19
|
+
let result = html;
|
|
20
|
+
// 1. Process OG Meta tags
|
|
21
|
+
ogTags.forEach(({ property, placeholder }) => {
|
|
22
|
+
// Escape special characters to avoid regex errors
|
|
23
|
+
const escapedProperty = property.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
24
|
+
// Check if meta tag with this property exists
|
|
25
|
+
const metaRegex = new RegExp(`<meta\\s+[^>]*property=["']?${escapedProperty}["']?[^>]*>`, 'i');
|
|
26
|
+
if (metaRegex.test(result)) {
|
|
27
|
+
// If exists, replace its content with placeholder
|
|
28
|
+
const replaceRegex = new RegExp(`(<meta\\s+[^>]*property=["']?${escapedProperty}["']?[^>]*content=)["'][^"']*["']([^>]*>)`, 'gi');
|
|
29
|
+
result = result.replace(replaceRegex, `$1"${placeholder}"$2`);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// If not exists, insert new tag before </head>
|
|
33
|
+
const newMetaTag = `\n <meta property="${property}" content="${placeholder}">`;
|
|
34
|
+
result = result.replace('</head>', `${newMetaTag}\n </head>`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
// 2. Process <title> tag
|
|
38
|
+
const titleRegex = /<title>[^<]*<\/title>/i;
|
|
39
|
+
if (titleRegex.test(result)) {
|
|
40
|
+
// If title tag exists, replace its content
|
|
41
|
+
result = result.replace(/<title>[^<]*<\/title>/gi, `<title>${titlePlaceholder}</title>`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// If not exists, insert before </head>
|
|
45
|
+
const newTitleTag = `\n <title>${titlePlaceholder}</title>`;
|
|
46
|
+
result = result.replace('</head>', `${newTitleTag}\n </head>`);
|
|
47
|
+
}
|
|
48
|
+
// 2.1 Process <meta name="description"> tag
|
|
49
|
+
const descriptionMetaRegex = /<meta\b[^>]*\bname=["']description["'][^>]*>/i;
|
|
50
|
+
const descriptionMetaReplaceRegex = /<meta\b[^>]*\bname=["']description["'][^>]*>/gi;
|
|
51
|
+
if (descriptionMetaRegex.test(result)) {
|
|
52
|
+
result = result.replace(descriptionMetaReplaceRegex, (metaTag) => {
|
|
53
|
+
if (/\bcontent=/.test(metaTag)) {
|
|
54
|
+
return metaTag.replace(/\bcontent=(["'])([\s\S]*?)\1/i, `content="${descriptionPlaceholder}"`);
|
|
55
|
+
}
|
|
56
|
+
return metaTag.replace(/>$/, ` content="${descriptionPlaceholder}">`);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const newDescriptionTag = `\n <meta name="description" content="${descriptionPlaceholder}">`;
|
|
61
|
+
result = result.replace('</head>', `${newDescriptionTag}\n </head>`);
|
|
62
|
+
}
|
|
63
|
+
// 3. Process <link rel="icon"> tag
|
|
64
|
+
const iconRegex = /<link\s+[^>]*rel=["']?(?:icon|shortcut icon)["']?[^>]*>/i;
|
|
65
|
+
if (iconRegex.test(result)) {
|
|
66
|
+
// If icon tag exists, replace its href
|
|
67
|
+
const replaceIconRegex = /(<link\s+[^>]*rel=["']?(?:icon|shortcut icon)["']?[^>]*href=)["'][^"']*["']([^>]*>)/gi;
|
|
68
|
+
result = result.replace(replaceIconRegex, `$1"${faviconPlaceholder}"$2`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// If not exists, insert before </head>
|
|
72
|
+
const newIconTag = `\n <link rel="icon" href="${faviconPlaceholder}">`;
|
|
73
|
+
result = result.replace('</head>', `${newIconTag}\n </head>`);
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
exports.default = ogMetaPlugin;
|
|
80
|
+
//# sourceMappingURL=og-meta-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"og-meta-plugin.js","sourceRoot":"","sources":["../../src/vite-plugins/og-meta-plugin.ts"],"names":[],"mappings":";;AA2BA,oCAsGC;AAjHD,gCAAgC;AAChC,MAAM,aAAa,GAAG;IACpB,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE;IACpD,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,oBAAoB,EAAE;IACjE,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE;CACvD,CAAC;AAEF,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAC9C,MAAM,6BAA6B,GAAG,oBAAoB,CAAC;AAC3D,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAElD,SAAgB,YAAY,CAAC,UAA+B,EAAE;IAC5D,MAAM,EACJ,UAAU,EACV,gBAAgB,GAAG,uBAAuB,EAC1C,sBAAsB,GAAG,6BAA6B,EACtD,kBAAkB,GAAG,yBAAyB,GAC/C,GAAG,OAAO,CAAC;IAEZ,MAAM,MAAM,GAAG,UAAU,IAAI,aAAa,CAAC;IAE3C,OAAO;QACL,IAAI,EAAE,mBAAmB;QAEzB,kBAAkB,CAAC,IAAI;YACrB,IAAI,MAAM,GAAG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@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Polyfill Plugin (Vite)
|
|
4
|
+
*
|
|
5
|
+
* 对齐 rspack-preset 的 PolyfillPlugin:
|
|
6
|
+
* 使用 core-js 为旧版浏览器生成独立的 polyfill 文件
|
|
7
|
+
* 通过检测脚本按需加载,现代浏览器不会加载 polyfill
|
|
8
|
+
*
|
|
9
|
+
* 仅在生产构建时生效
|
|
10
|
+
*/
|
|
11
|
+
export declare function polyfillPlugin(): Plugin;
|
|
12
|
+
//# sourceMappingURL=polyfill-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyfill-plugin.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/polyfill-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAA0B,MAAM,MAAM,CAAC;AAK3D;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,MAAM,CA6EvC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.polyfillPlugin = polyfillPlugin;
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
/**
|
|
42
|
+
* Polyfill Plugin (Vite)
|
|
43
|
+
*
|
|
44
|
+
* 对齐 rspack-preset 的 PolyfillPlugin:
|
|
45
|
+
* 使用 core-js 为旧版浏览器生成独立的 polyfill 文件
|
|
46
|
+
* 通过检测脚本按需加载,现代浏览器不会加载 polyfill
|
|
47
|
+
*
|
|
48
|
+
* 仅在生产构建时生效
|
|
49
|
+
*/
|
|
50
|
+
function polyfillPlugin() {
|
|
51
|
+
let config;
|
|
52
|
+
return {
|
|
53
|
+
name: 'fullstack-polyfill',
|
|
54
|
+
apply: 'build',
|
|
55
|
+
enforce: 'post',
|
|
56
|
+
configResolved(resolvedConfig) {
|
|
57
|
+
config = resolvedConfig;
|
|
58
|
+
},
|
|
59
|
+
async generateBundle(_options, bundle) {
|
|
60
|
+
// 使用 Vite build API 打包 polyfills 入口(Vite 8 内部使用 Rolldown)
|
|
61
|
+
const polyfillEntry = path_1.default.resolve(__dirname, '../polyfills/index');
|
|
62
|
+
const { build } = await Promise.resolve().then(() => __importStar(require('vite')));
|
|
63
|
+
try {
|
|
64
|
+
const result = await build({
|
|
65
|
+
configFile: false,
|
|
66
|
+
logLevel: 'silent',
|
|
67
|
+
build: {
|
|
68
|
+
write: false,
|
|
69
|
+
lib: {
|
|
70
|
+
entry: polyfillEntry,
|
|
71
|
+
formats: ['iife'],
|
|
72
|
+
name: 'polyfills',
|
|
73
|
+
fileName: 'polyfills',
|
|
74
|
+
},
|
|
75
|
+
minify: true,
|
|
76
|
+
rollupOptions: {
|
|
77
|
+
output: { inlineDynamicImports: true },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const output = Array.isArray(result) ? result[0] : result;
|
|
82
|
+
const polyfillCode = 'output' in output
|
|
83
|
+
? output.output[0]?.code || ''
|
|
84
|
+
: '';
|
|
85
|
+
this.emitFile({
|
|
86
|
+
type: 'asset',
|
|
87
|
+
fileName: 'polyfills.js',
|
|
88
|
+
source: polyfillCode,
|
|
89
|
+
});
|
|
90
|
+
console.log(`[PolyfillPlugin] Generated polyfills.js (${Math.round(polyfillCode.length / 1024)}KB)`);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
console.error('[PolyfillPlugin] Failed to build polyfills:', error);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// 修改 HTML,注入检测脚本
|
|
97
|
+
const base = config.base || '/';
|
|
98
|
+
const polyfillUrl = `${base}polyfills.js`.replace(/\/+/g, '/').replace(':/', '://');
|
|
99
|
+
const htmlFiles = Object.keys(bundle).filter((name) => name.endsWith('.html'));
|
|
100
|
+
for (const htmlFile of htmlFiles) {
|
|
101
|
+
const chunk = bundle[htmlFile];
|
|
102
|
+
if (chunk.type !== 'asset')
|
|
103
|
+
continue;
|
|
104
|
+
let htmlContent = typeof chunk.source === 'string' ? chunk.source : Buffer.from(chunk.source).toString('utf-8');
|
|
105
|
+
const detectionScript = generateDetectionScript(polyfillUrl);
|
|
106
|
+
// 注入到 <head> 最前面
|
|
107
|
+
htmlContent = htmlContent.replace(/<head([^>]*)>/i, `<head$1>\n${detectionScript}`);
|
|
108
|
+
chunk.source = htmlContent;
|
|
109
|
+
console.log(`[PolyfillPlugin] Updated ${htmlFile} with polyfill detection`);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function generateDetectionScript(polyfillUrl) {
|
|
115
|
+
return `<script>
|
|
116
|
+
(function(){
|
|
117
|
+
var needsPolyfill=(function(){
|
|
118
|
+
try{
|
|
119
|
+
if(typeof crypto==="undefined"||typeof crypto.randomUUID!=="function")return true;
|
|
120
|
+
if(typeof Object.hasOwn!=="function")return true;
|
|
121
|
+
if(typeof[].at!=="function")return true;
|
|
122
|
+
if(typeof[].findLast!=="function")return true;
|
|
123
|
+
return false;
|
|
124
|
+
}catch(e){return true}
|
|
125
|
+
})();
|
|
126
|
+
if(needsPolyfill){
|
|
127
|
+
document.write('<script src="${polyfillUrl}"><\\/script>');
|
|
128
|
+
}
|
|
129
|
+
})();
|
|
130
|
+
</script>`;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=polyfill-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyfill-plugin.js","sourceRoot":"","sources":["../../src/vite-plugins/polyfill-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,wCA6EC;AA5FD,gDAAwB;AAMxB;;;;;;;;GAQG;AACH,SAAgB,cAAc;IAC5B,IAAI,MAAsB,CAAC;IAE3B,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,MAAM;QAEf,cAAc,CAAC,cAAc;YAC3B,MAAM,GAAG,cAAc,CAAC;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|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export { normalizeBasePath, parseRoutesFromFile as parseRoutes } from '@lark-apaas/devtool-kits';
|
|
3
|
+
interface RouteParserPluginOptions {
|
|
4
|
+
appPath?: string;
|
|
5
|
+
outputPath?: string;
|
|
6
|
+
/** Base path for the routes content (e.g., '/miaoda_custom_plugin'). If not provided, reads from CLIENT_BASE_PATH env */
|
|
7
|
+
basePath?: string;
|
|
8
|
+
/** Base path for serving routes.json in dev mode (e.g., '/miaoda_custom_plugin'). Defaults to CLIENT_BASE_PATH env */
|
|
9
|
+
serveBasePath?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function routeParserPlugin(options?: RouteParserPluginOptions): Plugin;
|
|
12
|
+
export default routeParserPlugin;
|
|
13
|
+
//# sourceMappingURL=route-parser-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-parser-plugin.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/route-parser-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAWlD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEjG,UAAU,wBAAwB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yHAAyH;IACzH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sHAAsH;IACtH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAsCD,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,wBAA6B,GACrC,MAAM,CA8DR;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.parseRoutes = exports.normalizeBasePath = void 0;
|
|
37
|
+
exports.routeParserPlugin = routeParserPlugin;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const devtool_kits_1 = require("@lark-apaas/devtool-kits");
|
|
41
|
+
// Re-export for backward compatibility
|
|
42
|
+
var devtool_kits_2 = require("@lark-apaas/devtool-kits");
|
|
43
|
+
Object.defineProperty(exports, "normalizeBasePath", { enumerable: true, get: function () { return devtool_kits_2.normalizeBasePath; } });
|
|
44
|
+
Object.defineProperty(exports, "parseRoutes", { enumerable: true, get: function () { return devtool_kits_2.parseRoutesFromFile; } });
|
|
45
|
+
function generateRoutes(appPath, outputPath, basePath, lastHash, cachedRoutes) {
|
|
46
|
+
const appFilePath = path.resolve(process.cwd(), appPath);
|
|
47
|
+
const defaultPath = basePath ? `${basePath}/` : '/';
|
|
48
|
+
if (!fs.existsSync(appFilePath)) {
|
|
49
|
+
(0, devtool_kits_1.routeParserLog)('warn', `App.tsx file does not exist: ${appFilePath}`);
|
|
50
|
+
return cachedRoutes.value || [{ path: defaultPath }];
|
|
51
|
+
}
|
|
52
|
+
const currentHash = (0, devtool_kits_1.calculateFileHash)(appFilePath);
|
|
53
|
+
if (lastHash.value === currentHash && cachedRoutes.value) {
|
|
54
|
+
return cachedRoutes.value;
|
|
55
|
+
}
|
|
56
|
+
lastHash.value = currentHash;
|
|
57
|
+
const routes = (0, devtool_kits_1.parseRoutesFromFile)(appPath, basePath);
|
|
58
|
+
cachedRoutes.value = routes;
|
|
59
|
+
const outputDir = path.dirname(outputPath);
|
|
60
|
+
if (!fs.existsSync(outputDir)) {
|
|
61
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
62
|
+
}
|
|
63
|
+
fs.writeFileSync(outputPath, JSON.stringify(routes, null, 2));
|
|
64
|
+
(0, devtool_kits_1.routeParserLog)('info', `Generated routes.json (${routes.length} routes)`);
|
|
65
|
+
return routes;
|
|
66
|
+
}
|
|
67
|
+
function routeParserPlugin(options = {}) {
|
|
68
|
+
const { appPath = './client/src/app.tsx', outputPath = './dist/client/routes.json', } = options;
|
|
69
|
+
const envBasePath = process.env.CLIENT_BASE_PATH || '';
|
|
70
|
+
const configuredBasePath = (0, devtool_kits_1.normalizeBasePath)(options.basePath ?? envBasePath);
|
|
71
|
+
const serveBasePath = (0, devtool_kits_1.normalizeBasePath)(options.serveBasePath ?? envBasePath);
|
|
72
|
+
const lastHash = { value: null };
|
|
73
|
+
const cachedRoutes = { value: null };
|
|
74
|
+
return {
|
|
75
|
+
name: 'fullstack-route-parser',
|
|
76
|
+
configureServer(server) {
|
|
77
|
+
const appFullPath = path.resolve(process.cwd(), appPath);
|
|
78
|
+
const fullOutputPath = path.resolve(process.cwd(), outputPath);
|
|
79
|
+
generateRoutes(appPath, fullOutputPath, configuredBasePath, lastHash, cachedRoutes);
|
|
80
|
+
server.watcher.add(appFullPath);
|
|
81
|
+
server.watcher.on('change', (file) => {
|
|
82
|
+
if (file === appFullPath) {
|
|
83
|
+
generateRoutes(appPath, fullOutputPath, configuredBasePath, lastHash, cachedRoutes);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const routesJsonPath = serveBasePath ? `${serveBasePath}/routes.json` : '/routes.json';
|
|
87
|
+
server.middlewares.use((req, res, next) => {
|
|
88
|
+
const urlPath = req.url?.split('?')[0];
|
|
89
|
+
if (urlPath === routesJsonPath) {
|
|
90
|
+
if (fs.existsSync(fullOutputPath)) {
|
|
91
|
+
res.setHeader('Content-Type', 'application/json');
|
|
92
|
+
res.end(fs.readFileSync(fullOutputPath, 'utf-8'));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
res.statusCode = 404;
|
|
96
|
+
res.end(JSON.stringify({ error: 'routes.json not found' }));
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
next();
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
buildStart() {
|
|
104
|
+
const fullOutputPath = path.resolve(process.cwd(), outputPath);
|
|
105
|
+
generateRoutes(appPath, fullOutputPath, configuredBasePath, lastHash, cachedRoutes);
|
|
106
|
+
},
|
|
107
|
+
generateBundle() {
|
|
108
|
+
const fullOutputPath = path.resolve(process.cwd(), outputPath);
|
|
109
|
+
if (fs.existsSync(fullOutputPath)) {
|
|
110
|
+
this.emitFile({
|
|
111
|
+
type: 'asset',
|
|
112
|
+
fileName: 'routes.json',
|
|
113
|
+
source: fs.readFileSync(fullOutputPath, 'utf-8'),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
exports.default = routeParserPlugin;
|
|
120
|
+
//# sourceMappingURL=route-parser-plugin.js.map
|