@4399ywkf/core 5.3.1 → 5.4.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.
- package/biome.json +34 -30
- package/dist/cli/index.js +152 -101
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +120 -75
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +163 -116
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +3 -6
- package/dist/plugin/index.js.map +1 -1
- package/dist/router/index.d.ts +20 -20
- package/dist/router/index.js +8 -10
- package/dist/router/index.js.map +1 -1
- package/dist/rspack/index.d.ts +2 -2
- package/dist/rspack/index.js +133 -86
- package/dist/rspack/index.js.map +1 -1
- package/dist/runtime/index.d.ts +17 -17
- package/dist/runtime/index.js +11 -15
- package/dist/runtime/index.js.map +1 -1
- package/dist/{schema-Ade9gA3U.d.ts → schema-BblOKuYl.d.ts} +223 -223
- package/dist/{types-ZJhd87ue.d.ts → types-DZ7Nz9bQ.d.ts} +54 -54
- package/package.json +7 -6
package/dist/rspack/index.js
CHANGED
|
@@ -150,9 +150,7 @@ var browserCheckPlugin = createPlugin((options = {}) => ({
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
const minVersions = explicitVersions ? { ...baseVersions, ...explicitVersions } : baseVersions;
|
|
153
|
-
logger.info(
|
|
154
|
-
`\u6D4F\u89C8\u5668\u517C\u5BB9\u6027\u68C0\u67E5\u5DF2\u542F\u7528 (\u7279\u6027\u68C0\u6D4B: ${features.join(", ")})`
|
|
155
|
-
);
|
|
153
|
+
logger.info(`\u6D4F\u89C8\u5668\u517C\u5BB9\u6027\u68C0\u67E5\u5DF2\u542F\u7528 (\u7279\u6027\u68C0\u6D4B: ${features.join(", ")})`);
|
|
156
154
|
logger.info(
|
|
157
155
|
`\u6700\u4F4E\u7248\u672C\u8981\u6C42: Chrome ${minVersions.chrome ?? "\u2014"}, Edge ${minVersions.edge ?? "\u2014"}, Firefox ${minVersions.firefox ?? "\u2014"}, Safari ${minVersions.safari ?? "\u2014"}${fromBrowserslist !== false ? " (\u4ECE browserslist \u8BFB\u53D6)" : ""}`
|
|
158
156
|
);
|
|
@@ -192,7 +190,7 @@ var browserCheckPlugin = createPlugin((options = {}) => ({
|
|
|
192
190
|
const insertIndex = lastImportIndex >= 0 ? lastImportIndex + 1 : 0;
|
|
193
191
|
lines.splice(insertIndex, 0, checkBlock);
|
|
194
192
|
let result = lines.join("\n");
|
|
195
|
-
result = result.
|
|
193
|
+
result = result.replaceAll(
|
|
196
194
|
/(\s*)(await\s+)?runApp\(\);?/g,
|
|
197
195
|
(_, indent, awaitKw) => `${indent}if (__ywkfBrowserOk) { ${awaitKw || ""}runApp(); }`
|
|
198
196
|
);
|
|
@@ -216,37 +214,39 @@ function buildFeatureChecks(features) {
|
|
|
216
214
|
return lines;
|
|
217
215
|
}
|
|
218
216
|
function buildVersionChecks(minVersions) {
|
|
219
|
-
const entries = Object.entries(minVersions).filter(
|
|
220
|
-
([, v]) => v != null
|
|
221
|
-
);
|
|
217
|
+
const entries = Object.entries(minVersions).filter(([, v]) => v != null);
|
|
222
218
|
if (entries.length === 0) return [];
|
|
223
219
|
const lines = ["// UA \u7248\u672C\u68C0\u6D4B", "const ua = navigator.userAgent;"];
|
|
224
220
|
for (const [browser, minVer] of entries) {
|
|
225
221
|
switch (browser) {
|
|
226
|
-
case "chrome":
|
|
222
|
+
case "chrome": {
|
|
227
223
|
lines.push(
|
|
228
224
|
`const chromeMatch = /Chrome\\/(\\d+)/.exec(ua);`,
|
|
229
225
|
`if (chromeMatch && !/Edg\\//.test(ua) && Number(chromeMatch[1]) < ${minVer}) return false;`
|
|
230
226
|
);
|
|
231
227
|
break;
|
|
232
|
-
|
|
228
|
+
}
|
|
229
|
+
case "edge": {
|
|
233
230
|
lines.push(
|
|
234
231
|
`const edgeMatch = /Edg\\/(\\d+)/.exec(ua);`,
|
|
235
232
|
`if (edgeMatch && Number(edgeMatch[1]) < ${minVer}) return false;`
|
|
236
233
|
);
|
|
237
234
|
break;
|
|
238
|
-
|
|
235
|
+
}
|
|
236
|
+
case "firefox": {
|
|
239
237
|
lines.push(
|
|
240
238
|
`const firefoxMatch = /Firefox\\/(\\d+)/.exec(ua);`,
|
|
241
239
|
`if (firefoxMatch && Number(firefoxMatch[1]) < ${minVer}) return false;`
|
|
242
240
|
);
|
|
243
241
|
break;
|
|
244
|
-
|
|
242
|
+
}
|
|
243
|
+
case "safari": {
|
|
245
244
|
lines.push(
|
|
246
245
|
`const safariMatch = /Version\\/(\\d+\\.?\\d*)/.exec(ua);`,
|
|
247
246
|
`if (safariMatch && /Safari/.test(ua) && !/Chrome/.test(ua) && Number(safariMatch[1]) < ${minVer}) return false;`
|
|
248
247
|
);
|
|
249
248
|
break;
|
|
249
|
+
}
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
return lines;
|
|
@@ -339,9 +339,9 @@ function readBrowserslistFile(filePath) {
|
|
|
339
339
|
function extractMinVersions(queries) {
|
|
340
340
|
const result = {};
|
|
341
341
|
const expanded = queries.flatMap((q) => q.split(",").map((s) => s.trim()));
|
|
342
|
-
const versionPattern = /^(
|
|
342
|
+
const versionPattern = /^([a-z_]+)\s*(?:(>=?)\s*)?(\d+(?:\.\d+)?)\s*$/i;
|
|
343
343
|
for (const query of expanded) {
|
|
344
|
-
if (/^(not|dead|last|defaults|>?\s*\d+%|unreleased|current)/i.test(query)) {
|
|
344
|
+
if (/^(?:not|dead|last|defaults|>?\s*\d+%|unreleased|current)/i.test(query)) {
|
|
345
345
|
continue;
|
|
346
346
|
}
|
|
347
347
|
const match = versionPattern.exec(query);
|
|
@@ -382,7 +382,7 @@ var garfishPlugin = createPlugin((options = {}) => ({
|
|
|
382
382
|
rspackConfig.devServer = {
|
|
383
383
|
...rspackConfig.devServer,
|
|
384
384
|
headers: {
|
|
385
|
-
...rspackConfig.devServer?.headers
|
|
385
|
+
...rspackConfig.devServer?.headers,
|
|
386
386
|
"Access-Control-Allow-Origin": "*",
|
|
387
387
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
388
388
|
"Access-Control-Allow-Headers": "*"
|
|
@@ -626,7 +626,7 @@ function scaffoldSourceFiles(cwd, sourceDir, namespaces, logger) {
|
|
|
626
626
|
}
|
|
627
627
|
const indexPath = join3(dir, "index.ts");
|
|
628
628
|
if (!existsSync3(indexPath)) {
|
|
629
|
-
const imports = namespaces.map((ns) => `import ${ns} from
|
|
629
|
+
const imports = namespaces.map((ns) => `import ${ns} from './${ns}';`).join("\n");
|
|
630
630
|
const entries = namespaces.join(",\n ");
|
|
631
631
|
const content = `${imports}
|
|
632
632
|
|
|
@@ -643,19 +643,19 @@ export default resources;
|
|
|
643
643
|
function buildDefaultNsFile(ns) {
|
|
644
644
|
if (ns === "common") {
|
|
645
645
|
return `export default {
|
|
646
|
-
welcome:
|
|
647
|
-
loading:
|
|
648
|
-
confirm:
|
|
649
|
-
cancel:
|
|
650
|
-
save:
|
|
651
|
-
delete:
|
|
652
|
-
edit:
|
|
653
|
-
back:
|
|
646
|
+
welcome: '\u6B22\u8FCE\u4F7F\u7528',
|
|
647
|
+
loading: '\u52A0\u8F7D\u4E2D...',
|
|
648
|
+
confirm: '\u786E\u5B9A',
|
|
649
|
+
cancel: '\u53D6\u6D88',
|
|
650
|
+
save: '\u4FDD\u5B58',
|
|
651
|
+
delete: '\u5220\u9664',
|
|
652
|
+
edit: '\u7F16\u8F91',
|
|
653
|
+
back: '\u8FD4\u56DE',
|
|
654
654
|
} as const;
|
|
655
655
|
`;
|
|
656
656
|
}
|
|
657
657
|
return `export default {
|
|
658
|
-
title:
|
|
658
|
+
title: '${ns}',
|
|
659
659
|
} as const;
|
|
660
660
|
`;
|
|
661
661
|
}
|
|
@@ -663,11 +663,11 @@ function scaffoldResourcesFile(cwd, sourceDir, _namespaces, locales, defaultLoca
|
|
|
663
663
|
const parentDir = join3(cwd, sourceDir, "..");
|
|
664
664
|
const filePath = join3(parentDir, "resources.ts");
|
|
665
665
|
if (existsSync3(filePath)) return;
|
|
666
|
-
const content = `import resources from
|
|
666
|
+
const content = `import type resources from './default';
|
|
667
667
|
|
|
668
|
-
export const DEFAULT_LOCALE =
|
|
668
|
+
export const DEFAULT_LOCALE = '${defaultLocale}';
|
|
669
669
|
|
|
670
|
-
export const SUPPORTED_LOCALES = ${
|
|
670
|
+
export const SUPPORTED_LOCALES = [${locales.map((l) => `'${l}'`).join(", ")}] as const;
|
|
671
671
|
|
|
672
672
|
export type SupportedLocale = (typeof SUPPORTED_LOCALES)[number];
|
|
673
673
|
|
|
@@ -679,7 +679,7 @@ export const normalizeLocale = (locale?: string): SupportedLocale => {
|
|
|
679
679
|
if (!locale) return DEFAULT_LOCALE as SupportedLocale;
|
|
680
680
|
|
|
681
681
|
for (const l of SUPPORTED_LOCALES) {
|
|
682
|
-
if (l.startsWith(locale) || locale.startsWith(l.split(
|
|
682
|
+
if (l.startsWith(locale) || locale.startsWith(l.split('-')[0])) {
|
|
683
683
|
return l;
|
|
684
684
|
}
|
|
685
685
|
}
|
|
@@ -687,11 +687,9 @@ export const normalizeLocale = (locale?: string): SupportedLocale => {
|
|
|
687
687
|
return DEFAULT_LOCALE as SupportedLocale;
|
|
688
688
|
};
|
|
689
689
|
|
|
690
|
-
export const localeOptions =
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
2
|
|
694
|
-
)} as const;
|
|
690
|
+
export const localeOptions = [
|
|
691
|
+
${locales.map((l) => ` { value: '${l}', label: '${getLocaleLabel(l)}' },`).join("\n")}
|
|
692
|
+
] as const;
|
|
695
693
|
`;
|
|
696
694
|
writeFileSync2(filePath, content, "utf-8");
|
|
697
695
|
logger.info(`\u5DF2\u751F\u6210\u7C7B\u578B\u6587\u4EF6: ${sourceDir}/../resources.ts`);
|
|
@@ -710,35 +708,35 @@ function getLocaleLabel(locale) {
|
|
|
710
708
|
"ru-RU": "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
|
|
711
709
|
"it-IT": "Italiano",
|
|
712
710
|
"vi-VN": "Ti\u1EBFng Vi\u1EC7t",
|
|
713
|
-
ar: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"
|
|
711
|
+
"ar": "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"
|
|
714
712
|
};
|
|
715
713
|
return map[locale] || locale;
|
|
716
714
|
}
|
|
717
715
|
function scaffoldConvertScript(cwd, sourceDir, localesDir, defaultLocale, logger) {
|
|
718
716
|
const scriptsDir = join3(cwd, "scripts");
|
|
719
|
-
const scriptPath = join3(scriptsDir, "i18n-gen.
|
|
720
|
-
if (existsSync3(scriptPath)) return;
|
|
717
|
+
const scriptPath = join3(scriptsDir, "i18n-gen.cjs");
|
|
718
|
+
if (existsSync3(scriptPath) || existsSync3(join3(scriptsDir, "i18n-gen.js"))) return;
|
|
721
719
|
if (!existsSync3(scriptsDir)) {
|
|
722
720
|
mkdirSync(scriptsDir, { recursive: true });
|
|
723
721
|
}
|
|
724
|
-
const content = `const fs = require(
|
|
725
|
-
const path = require(
|
|
722
|
+
const content = `const fs = require('node:fs');
|
|
723
|
+
const path = require('node:path');
|
|
726
724
|
|
|
727
|
-
const sourceDir = path.join(__dirname,
|
|
728
|
-
const targetDir = path.join(__dirname,
|
|
725
|
+
const sourceDir = path.join(__dirname, '../${sourceDir}');
|
|
726
|
+
const targetDir = path.join(__dirname, '../${localesDir}/${defaultLocale}');
|
|
729
727
|
|
|
730
728
|
const files = fs
|
|
731
729
|
.readdirSync(sourceDir)
|
|
732
|
-
.filter((file) => file.endsWith(
|
|
733
|
-
.map((file) => path.basename(file,
|
|
730
|
+
.filter((file) => file.endsWith('.ts') && file !== 'index.ts')
|
|
731
|
+
.map((file) => path.basename(file, '.ts'));
|
|
734
732
|
|
|
735
|
-
require(
|
|
733
|
+
require('ts-node/register');
|
|
736
734
|
|
|
737
735
|
if (!fs.existsSync(targetDir)) {
|
|
738
736
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
739
737
|
}
|
|
740
738
|
|
|
741
|
-
console.log(
|
|
739
|
+
console.log('\u5F00\u59CB\u8F6C\u6362 TypeScript \u6587\u4EF6\u5230 JSON...\\n');
|
|
742
740
|
|
|
743
741
|
files.forEach((fileName) => {
|
|
744
742
|
try {
|
|
@@ -747,28 +745,28 @@ files.forEach((fileName) => {
|
|
|
747
745
|
const moduleContent = require(modulePath).default;
|
|
748
746
|
const jsonContent = JSON.stringify(moduleContent, null, 2);
|
|
749
747
|
const targetPath = path.join(targetDir, \`\${fileName}.json\`);
|
|
750
|
-
fs.writeFileSync(targetPath, jsonContent,
|
|
748
|
+
fs.writeFileSync(targetPath, jsonContent, 'utf8');
|
|
751
749
|
console.log(\` \${fileName}.ts \u2192 \${fileName}.json\`);
|
|
752
750
|
} catch (error) {
|
|
753
751
|
console.error(\` \u8F6C\u6362 \${fileName}.ts \u5931\u8D25:\`, error.message);
|
|
754
752
|
}
|
|
755
753
|
});
|
|
756
754
|
|
|
757
|
-
console.log(
|
|
755
|
+
console.log('\\n\u8F6C\u6362\u5B8C\u6210\uFF01');
|
|
758
756
|
`;
|
|
759
757
|
writeFileSync2(scriptPath, content, "utf-8");
|
|
760
|
-
logger.info("\u5DF2\u751F\u6210\u8F6C\u6362\u811A\u672C: scripts/i18n-gen.
|
|
758
|
+
logger.info("\u5DF2\u751F\u6210\u8F6C\u6362\u811A\u672C: scripts/i18n-gen.cjs");
|
|
761
759
|
}
|
|
762
760
|
function scaffoldI18nRc(cwd, localesDir, defaultLocale, locales, logger) {
|
|
763
761
|
const filePath = join3(cwd, ".i18nrc.js");
|
|
764
762
|
if (existsSync3(filePath)) return;
|
|
765
|
-
const outputLocales = locales.filter((l) => l !== defaultLocale).map((l) => `
|
|
766
|
-
const content = `const { defineConfig } = require(
|
|
763
|
+
const outputLocales = locales.filter((l) => l !== defaultLocale).map((l) => `'${l}'`).join(", ");
|
|
764
|
+
const content = `const { defineConfig } = require('@4399ywkf/i18n');
|
|
767
765
|
|
|
768
766
|
module.exports = defineConfig({
|
|
769
|
-
entry:
|
|
770
|
-
entryLocale:
|
|
771
|
-
output:
|
|
767
|
+
entry: '${localesDir}/${defaultLocale}',
|
|
768
|
+
entryLocale: '${defaultLocale}',
|
|
769
|
+
output: '${localesDir}',
|
|
772
770
|
outputLocales: [${outputLocales}],
|
|
773
771
|
});
|
|
774
772
|
`;
|
|
@@ -787,15 +785,16 @@ function scaffoldLocaleJsonDirs(cwd, localesDir, locales, defaultLocale, namespa
|
|
|
787
785
|
const filePath = join3(localeDir, `${ns}.json`);
|
|
788
786
|
if (!existsSync3(filePath)) {
|
|
789
787
|
const placeholder = ns === "common" ? JSON.stringify(
|
|
788
|
+
// 键按字母序排列,与 @4399ywkf/lint 的 Prettier(prettier-plugin-sort-json)一致
|
|
790
789
|
{
|
|
791
|
-
|
|
792
|
-
loading: "Loading...",
|
|
793
|
-
confirm: "OK",
|
|
790
|
+
back: "Back",
|
|
794
791
|
cancel: "Cancel",
|
|
795
|
-
|
|
792
|
+
confirm: "OK",
|
|
796
793
|
delete: "Delete",
|
|
797
794
|
edit: "Edit",
|
|
798
|
-
|
|
795
|
+
loading: "Loading...",
|
|
796
|
+
save: "Save",
|
|
797
|
+
welcome: "Welcome"
|
|
799
798
|
},
|
|
800
799
|
null,
|
|
801
800
|
2
|
|
@@ -861,7 +860,7 @@ function scanMockFiles(dir) {
|
|
|
861
860
|
for (const entry of entries) {
|
|
862
861
|
const fullPath = join4(dir, entry);
|
|
863
862
|
const stat = statSync(fullPath);
|
|
864
|
-
if (stat.isFile() && /\.(ts|js|mjs)$/.test(entry)) {
|
|
863
|
+
if (stat.isFile() && /\.(?:ts|js|mjs)$/.test(entry)) {
|
|
865
864
|
files.push(fullPath);
|
|
866
865
|
} else if (stat.isDirectory()) {
|
|
867
866
|
files.push(...scanMockFiles(fullPath));
|
|
@@ -1338,12 +1337,13 @@ function generateThemeProvider(opts) {
|
|
|
1338
1337
|
scopePopupContainer
|
|
1339
1338
|
} = opts;
|
|
1340
1339
|
const isAutoLocale = locale === "auto";
|
|
1341
|
-
const sections = [
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1340
|
+
const sections = [
|
|
1341
|
+
`// \u6B64\u6587\u4EF6\u7531 @4399ywkf/plugin-theme v3 \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u624B\u52A8\u4FEE\u6539`,
|
|
1342
|
+
buildImports({ globalReset, cssVar, scopePopupContainer, locale }),
|
|
1343
|
+
TYPES_CODE,
|
|
1344
|
+
buildStoreCode({ defaultAppearance, primaryColor, neutralColor, locale }),
|
|
1345
|
+
HOOKS_CODE
|
|
1346
|
+
];
|
|
1347
1347
|
if (globalReset) sections.push(GLOBAL_RESET_CODE);
|
|
1348
1348
|
if (cssVar) sections.push(buildCssVarSyncCode());
|
|
1349
1349
|
if (darkMode) sections.push(APPEARANCE_SYNC_CODE);
|
|
@@ -2038,18 +2038,58 @@ export type { StateCreator, StoreApi } from "zustand";
|
|
|
2038
2038
|
|
|
2039
2039
|
// src/config/normalize.ts
|
|
2040
2040
|
var BUILTIN_PLUGINS = [
|
|
2041
|
-
{
|
|
2042
|
-
|
|
2043
|
-
|
|
2041
|
+
{
|
|
2042
|
+
key: "reactQuery",
|
|
2043
|
+
factory: reactQueryPlugin,
|
|
2044
|
+
pluginName: "@4399ywkf/plugin-react-query"
|
|
2045
|
+
},
|
|
2046
|
+
{
|
|
2047
|
+
key: "zustand",
|
|
2048
|
+
factory: zustandPlugin,
|
|
2049
|
+
pluginName: "@4399ywkf/plugin-zustand"
|
|
2050
|
+
},
|
|
2051
|
+
{
|
|
2052
|
+
key: "tailwind",
|
|
2053
|
+
factory: tailwindPlugin,
|
|
2054
|
+
pluginName: "@4399ywkf/plugin-tailwind"
|
|
2055
|
+
}
|
|
2044
2056
|
];
|
|
2045
2057
|
var OPTIONAL_PLUGINS = [
|
|
2046
|
-
{
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
{
|
|
2052
|
-
|
|
2058
|
+
{
|
|
2059
|
+
key: "biome",
|
|
2060
|
+
factory: biomePlugin,
|
|
2061
|
+
pluginName: "@4399ywkf/plugin-biome"
|
|
2062
|
+
},
|
|
2063
|
+
{
|
|
2064
|
+
key: "analytics",
|
|
2065
|
+
factory: analyticsPlugin,
|
|
2066
|
+
pluginName: "@4399ywkf/plugin-analytics"
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
key: "mock",
|
|
2070
|
+
factory: mockPlugin,
|
|
2071
|
+
pluginName: "@4399ywkf/plugin-mock"
|
|
2072
|
+
},
|
|
2073
|
+
{
|
|
2074
|
+
key: "theme",
|
|
2075
|
+
factory: themePlugin,
|
|
2076
|
+
pluginName: "@4399ywkf/plugin-theme"
|
|
2077
|
+
},
|
|
2078
|
+
{
|
|
2079
|
+
key: "i18n",
|
|
2080
|
+
factory: i18nPlugin,
|
|
2081
|
+
pluginName: "@4399ywkf/plugin-i18n"
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
key: "garfish",
|
|
2085
|
+
factory: garfishPlugin,
|
|
2086
|
+
pluginName: "@4399ywkf/plugin-garfish"
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
key: "browserCheck",
|
|
2090
|
+
factory: browserCheckPlugin,
|
|
2091
|
+
pluginName: "@4399ywkf/plugin-browser-check"
|
|
2092
|
+
}
|
|
2053
2093
|
];
|
|
2054
2094
|
var ALL_SHORTHAND_KEYS = /* @__PURE__ */ new Set([
|
|
2055
2095
|
...BUILTIN_PLUGINS.map((p) => p.key),
|
|
@@ -2086,7 +2126,7 @@ function winPath(path) {
|
|
|
2086
2126
|
if (isExtendedLengthPath) {
|
|
2087
2127
|
return path;
|
|
2088
2128
|
}
|
|
2089
|
-
return path.
|
|
2129
|
+
return path.replaceAll("\\", "/");
|
|
2090
2130
|
}
|
|
2091
2131
|
var EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
2092
2132
|
"components",
|
|
@@ -2222,16 +2262,16 @@ var ConventionalRouteGenerator = class {
|
|
|
2222
2262
|
*/
|
|
2223
2263
|
resolveRoutePath(dirName, parentPath) {
|
|
2224
2264
|
let segment;
|
|
2225
|
-
if (
|
|
2265
|
+
if (/^\[\.\.\..+\]$/.test(dirName)) {
|
|
2226
2266
|
segment = "*";
|
|
2227
|
-
} else if (
|
|
2267
|
+
} else if (/^\[.+\$\]$/.test(dirName)) {
|
|
2228
2268
|
const param = dirName.slice(1, -2);
|
|
2229
2269
|
segment = `:${param}?`;
|
|
2230
|
-
} else if (
|
|
2270
|
+
} else if (/^\[.+\]$/.test(dirName)) {
|
|
2231
2271
|
const param = dirName.slice(1, -1);
|
|
2232
2272
|
segment = `:${param}`;
|
|
2233
2273
|
} else if (dirName.includes(".")) {
|
|
2234
|
-
segment = dirName.
|
|
2274
|
+
segment = dirName.replaceAll(".", "/");
|
|
2235
2275
|
} else {
|
|
2236
2276
|
segment = dirName;
|
|
2237
2277
|
}
|
|
@@ -2242,7 +2282,7 @@ var ConventionalRouteGenerator = class {
|
|
|
2242
2282
|
*/
|
|
2243
2283
|
generateRouteName(path) {
|
|
2244
2284
|
const name = path.split("/").filter(Boolean).map((s) => s.replace(/^:/, "Param").replace(/\?$/, "Optional").replace(/^\*$/, "CatchAll")).map((s) => {
|
|
2245
|
-
const cleaned = s.
|
|
2285
|
+
const cleaned = s.replaceAll(/[^a-z0-9]/gi, "");
|
|
2246
2286
|
if (!cleaned) return "";
|
|
2247
2287
|
return cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
|
|
2248
2288
|
}).join("");
|
|
@@ -2362,9 +2402,7 @@ export default routes;
|
|
|
2362
2402
|
);
|
|
2363
2403
|
}
|
|
2364
2404
|
if (route.errorFile) {
|
|
2365
|
-
errorImports.push(
|
|
2366
|
-
`import ${name}Error from "@/pages/${toImportPath(route.errorFile)}";`
|
|
2367
|
-
);
|
|
2405
|
+
errorImports.push(`import ${name}Error from "@/pages/${toImportPath(route.errorFile)}";`);
|
|
2368
2406
|
}
|
|
2369
2407
|
if (route.loadingFile) {
|
|
2370
2408
|
loadingImports.push(
|
|
@@ -2875,7 +2913,7 @@ var YwkfGenerator = class {
|
|
|
2875
2913
|
* 标准化内容(去掉时间戳等动态部分)
|
|
2876
2914
|
*/
|
|
2877
2915
|
normalizeContent(content) {
|
|
2878
|
-
return content.
|
|
2916
|
+
return content.replaceAll(/\/\/ Generated at: .+/g, "").replaceAll(/\/\*\* Generated at: .+ \*\//g, "");
|
|
2879
2917
|
}
|
|
2880
2918
|
};
|
|
2881
2919
|
|
|
@@ -3095,7 +3133,16 @@ function resolveYwkfBuildId(appName) {
|
|
|
3095
3133
|
function createBaseConfig(config, cwd, options = {}) {
|
|
3096
3134
|
const isDev = options.isDev ?? process.env.NODE_ENV !== "production";
|
|
3097
3135
|
const { resolveApp } = createPathResolver(cwd);
|
|
3098
|
-
const {
|
|
3136
|
+
const {
|
|
3137
|
+
appName,
|
|
3138
|
+
appCName,
|
|
3139
|
+
output,
|
|
3140
|
+
html,
|
|
3141
|
+
alias: userAlias,
|
|
3142
|
+
microFrontend,
|
|
3143
|
+
router,
|
|
3144
|
+
reactCompiler
|
|
3145
|
+
} = config;
|
|
3099
3146
|
const buildId = resolveYwkfBuildId(appName);
|
|
3100
3147
|
const { env: clientEnv, dropped: droppedEnvKeys } = buildClientEnv({ cwd, env: config.env });
|
|
3101
3148
|
if (droppedEnvKeys.length > 0) {
|
|
@@ -3128,7 +3175,7 @@ function createBaseConfig(config, cwd, options = {}) {
|
|
|
3128
3175
|
...alias,
|
|
3129
3176
|
"process/browser.js": require2.resolve("process/browser.js"),
|
|
3130
3177
|
"process/browser": require2.resolve("process/browser.js"),
|
|
3131
|
-
react: resolveApp("node_modules/react"),
|
|
3178
|
+
"react": resolveApp("node_modules/react"),
|
|
3132
3179
|
"react-dom": resolveApp("node_modules/react-dom"),
|
|
3133
3180
|
"react-router": resolveApp("node_modules/react-router")
|
|
3134
3181
|
},
|