@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/biome.json
CHANGED
|
@@ -1,32 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
"formatter": {
|
|
10
|
-
"enabled": true,
|
|
11
|
-
"indentStyle": "space"
|
|
2
|
+
"assist": {
|
|
3
|
+
"actions": {
|
|
4
|
+
"source": {
|
|
5
|
+
"organizeImports": "on"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
12
8
|
},
|
|
13
9
|
"css": {
|
|
14
10
|
"formatter": {
|
|
15
11
|
"quoteStyle": "single"
|
|
16
12
|
}
|
|
17
13
|
},
|
|
14
|
+
"files": {
|
|
15
|
+
"ignoreUnknown": true,
|
|
16
|
+
"includes": [
|
|
17
|
+
"**",
|
|
18
|
+
"!**/.vscode/**/*",
|
|
19
|
+
"!**/node_modules/**/*",
|
|
20
|
+
"!**/dist/**/*",
|
|
21
|
+
"!**/.ywkf/**/*",
|
|
22
|
+
"!**/public/**/*.html"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"formatter": {
|
|
26
|
+
"enabled": true,
|
|
27
|
+
"indentStyle": "space",
|
|
28
|
+
"indentWidth": 2,
|
|
29
|
+
"lineWidth": 100,
|
|
30
|
+
"lineEnding": "lf"
|
|
31
|
+
},
|
|
18
32
|
"javascript": {
|
|
19
33
|
"formatter": {
|
|
20
34
|
"quoteStyle": "single",
|
|
21
|
-
"arrowParentheses": "asNeeded",
|
|
22
35
|
"jsxQuoteStyle": "double",
|
|
23
|
-
"
|
|
36
|
+
"quoteProperties": "preserve",
|
|
37
|
+
"trailingCommas": "all",
|
|
38
|
+
"semicolons": "always",
|
|
39
|
+
"arrowParentheses": "always",
|
|
40
|
+
"bracketSpacing": true,
|
|
41
|
+
"bracketSameLine": false
|
|
24
42
|
}
|
|
25
43
|
},
|
|
26
44
|
"linter": {
|
|
27
45
|
"enabled": true,
|
|
28
46
|
"rules": {
|
|
29
|
-
"recommended": true,
|
|
30
47
|
"style": {
|
|
31
48
|
"useNodejsImportProtocol": "off",
|
|
32
49
|
"noNonNullAssertion": "off",
|
|
@@ -67,22 +84,9 @@
|
|
|
67
84
|
}
|
|
68
85
|
}
|
|
69
86
|
},
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
"files": {
|
|
78
|
-
"ignoreUnknown": true,
|
|
79
|
-
"includes": [
|
|
80
|
-
"**",
|
|
81
|
-
"!**/.vscode/**/*",
|
|
82
|
-
"!**/node_modules/**/*",
|
|
83
|
-
"!**/dist/**/*",
|
|
84
|
-
"!**/.ywkf/**/*",
|
|
85
|
-
"!**/public/**/*.html"
|
|
86
|
-
]
|
|
87
|
+
"vcs": {
|
|
88
|
+
"enabled": true,
|
|
89
|
+
"clientKind": "git",
|
|
90
|
+
"useIgnoreFile": true
|
|
87
91
|
}
|
|
88
92
|
}
|
package/dist/cli/index.js
CHANGED
|
@@ -155,9 +155,7 @@ var browserCheckPlugin = createPlugin((options = {}) => ({
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
const minVersions = explicitVersions ? { ...baseVersions, ...explicitVersions } : baseVersions;
|
|
158
|
-
logger.info(
|
|
159
|
-
`\u6D4F\u89C8\u5668\u517C\u5BB9\u6027\u68C0\u67E5\u5DF2\u542F\u7528 (\u7279\u6027\u68C0\u6D4B: ${features.join(", ")})`
|
|
160
|
-
);
|
|
158
|
+
logger.info(`\u6D4F\u89C8\u5668\u517C\u5BB9\u6027\u68C0\u67E5\u5DF2\u542F\u7528 (\u7279\u6027\u68C0\u6D4B: ${features.join(", ")})`);
|
|
161
159
|
logger.info(
|
|
162
160
|
`\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)" : ""}`
|
|
163
161
|
);
|
|
@@ -197,7 +195,7 @@ var browserCheckPlugin = createPlugin((options = {}) => ({
|
|
|
197
195
|
const insertIndex = lastImportIndex >= 0 ? lastImportIndex + 1 : 0;
|
|
198
196
|
lines.splice(insertIndex, 0, checkBlock);
|
|
199
197
|
let result = lines.join("\n");
|
|
200
|
-
result = result.
|
|
198
|
+
result = result.replaceAll(
|
|
201
199
|
/(\s*)(await\s+)?runApp\(\);?/g,
|
|
202
200
|
(_, indent, awaitKw) => `${indent}if (__ywkfBrowserOk) { ${awaitKw || ""}runApp(); }`
|
|
203
201
|
);
|
|
@@ -221,37 +219,39 @@ function buildFeatureChecks(features) {
|
|
|
221
219
|
return lines;
|
|
222
220
|
}
|
|
223
221
|
function buildVersionChecks(minVersions) {
|
|
224
|
-
const entries = Object.entries(minVersions).filter(
|
|
225
|
-
([, v]) => v != null
|
|
226
|
-
);
|
|
222
|
+
const entries = Object.entries(minVersions).filter(([, v]) => v != null);
|
|
227
223
|
if (entries.length === 0) return [];
|
|
228
224
|
const lines = ["// UA \u7248\u672C\u68C0\u6D4B", "const ua = navigator.userAgent;"];
|
|
229
225
|
for (const [browser, minVer] of entries) {
|
|
230
226
|
switch (browser) {
|
|
231
|
-
case "chrome":
|
|
227
|
+
case "chrome": {
|
|
232
228
|
lines.push(
|
|
233
229
|
`const chromeMatch = /Chrome\\/(\\d+)/.exec(ua);`,
|
|
234
230
|
`if (chromeMatch && !/Edg\\//.test(ua) && Number(chromeMatch[1]) < ${minVer}) return false;`
|
|
235
231
|
);
|
|
236
232
|
break;
|
|
237
|
-
|
|
233
|
+
}
|
|
234
|
+
case "edge": {
|
|
238
235
|
lines.push(
|
|
239
236
|
`const edgeMatch = /Edg\\/(\\d+)/.exec(ua);`,
|
|
240
237
|
`if (edgeMatch && Number(edgeMatch[1]) < ${minVer}) return false;`
|
|
241
238
|
);
|
|
242
239
|
break;
|
|
243
|
-
|
|
240
|
+
}
|
|
241
|
+
case "firefox": {
|
|
244
242
|
lines.push(
|
|
245
243
|
`const firefoxMatch = /Firefox\\/(\\d+)/.exec(ua);`,
|
|
246
244
|
`if (firefoxMatch && Number(firefoxMatch[1]) < ${minVer}) return false;`
|
|
247
245
|
);
|
|
248
246
|
break;
|
|
249
|
-
|
|
247
|
+
}
|
|
248
|
+
case "safari": {
|
|
250
249
|
lines.push(
|
|
251
250
|
`const safariMatch = /Version\\/(\\d+\\.?\\d*)/.exec(ua);`,
|
|
252
251
|
`if (safariMatch && /Safari/.test(ua) && !/Chrome/.test(ua) && Number(safariMatch[1]) < ${minVer}) return false;`
|
|
253
252
|
);
|
|
254
253
|
break;
|
|
254
|
+
}
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
return lines;
|
|
@@ -344,9 +344,9 @@ function readBrowserslistFile(filePath) {
|
|
|
344
344
|
function extractMinVersions(queries) {
|
|
345
345
|
const result = {};
|
|
346
346
|
const expanded = queries.flatMap((q) => q.split(",").map((s) => s.trim()));
|
|
347
|
-
const versionPattern = /^(
|
|
347
|
+
const versionPattern = /^([a-z_]+)\s*(?:(>=?)\s*)?(\d+(?:\.\d+)?)\s*$/i;
|
|
348
348
|
for (const query of expanded) {
|
|
349
|
-
if (/^(not|dead|last|defaults|>?\s*\d+%|unreleased|current)/i.test(query)) {
|
|
349
|
+
if (/^(?:not|dead|last|defaults|>?\s*\d+%|unreleased|current)/i.test(query)) {
|
|
350
350
|
continue;
|
|
351
351
|
}
|
|
352
352
|
const match = versionPattern.exec(query);
|
|
@@ -387,7 +387,7 @@ var garfishPlugin = createPlugin((options = {}) => ({
|
|
|
387
387
|
rspackConfig.devServer = {
|
|
388
388
|
...rspackConfig.devServer,
|
|
389
389
|
headers: {
|
|
390
|
-
...rspackConfig.devServer?.headers
|
|
390
|
+
...rspackConfig.devServer?.headers,
|
|
391
391
|
"Access-Control-Allow-Origin": "*",
|
|
392
392
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
393
393
|
"Access-Control-Allow-Headers": "*"
|
|
@@ -631,7 +631,7 @@ function scaffoldSourceFiles(cwd, sourceDir, namespaces, logger) {
|
|
|
631
631
|
}
|
|
632
632
|
const indexPath = join3(dir, "index.ts");
|
|
633
633
|
if (!existsSync3(indexPath)) {
|
|
634
|
-
const imports = namespaces.map((ns) => `import ${ns} from
|
|
634
|
+
const imports = namespaces.map((ns) => `import ${ns} from './${ns}';`).join("\n");
|
|
635
635
|
const entries = namespaces.join(",\n ");
|
|
636
636
|
const content = `${imports}
|
|
637
637
|
|
|
@@ -648,19 +648,19 @@ export default resources;
|
|
|
648
648
|
function buildDefaultNsFile(ns) {
|
|
649
649
|
if (ns === "common") {
|
|
650
650
|
return `export default {
|
|
651
|
-
welcome:
|
|
652
|
-
loading:
|
|
653
|
-
confirm:
|
|
654
|
-
cancel:
|
|
655
|
-
save:
|
|
656
|
-
delete:
|
|
657
|
-
edit:
|
|
658
|
-
back:
|
|
651
|
+
welcome: '\u6B22\u8FCE\u4F7F\u7528',
|
|
652
|
+
loading: '\u52A0\u8F7D\u4E2D...',
|
|
653
|
+
confirm: '\u786E\u5B9A',
|
|
654
|
+
cancel: '\u53D6\u6D88',
|
|
655
|
+
save: '\u4FDD\u5B58',
|
|
656
|
+
delete: '\u5220\u9664',
|
|
657
|
+
edit: '\u7F16\u8F91',
|
|
658
|
+
back: '\u8FD4\u56DE',
|
|
659
659
|
} as const;
|
|
660
660
|
`;
|
|
661
661
|
}
|
|
662
662
|
return `export default {
|
|
663
|
-
title:
|
|
663
|
+
title: '${ns}',
|
|
664
664
|
} as const;
|
|
665
665
|
`;
|
|
666
666
|
}
|
|
@@ -668,11 +668,11 @@ function scaffoldResourcesFile(cwd, sourceDir, _namespaces, locales, defaultLoca
|
|
|
668
668
|
const parentDir = join3(cwd, sourceDir, "..");
|
|
669
669
|
const filePath = join3(parentDir, "resources.ts");
|
|
670
670
|
if (existsSync3(filePath)) return;
|
|
671
|
-
const content = `import resources from
|
|
671
|
+
const content = `import type resources from './default';
|
|
672
672
|
|
|
673
|
-
export const DEFAULT_LOCALE =
|
|
673
|
+
export const DEFAULT_LOCALE = '${defaultLocale}';
|
|
674
674
|
|
|
675
|
-
export const SUPPORTED_LOCALES = ${
|
|
675
|
+
export const SUPPORTED_LOCALES = [${locales.map((l) => `'${l}'`).join(", ")}] as const;
|
|
676
676
|
|
|
677
677
|
export type SupportedLocale = (typeof SUPPORTED_LOCALES)[number];
|
|
678
678
|
|
|
@@ -684,7 +684,7 @@ export const normalizeLocale = (locale?: string): SupportedLocale => {
|
|
|
684
684
|
if (!locale) return DEFAULT_LOCALE as SupportedLocale;
|
|
685
685
|
|
|
686
686
|
for (const l of SUPPORTED_LOCALES) {
|
|
687
|
-
if (l.startsWith(locale) || locale.startsWith(l.split(
|
|
687
|
+
if (l.startsWith(locale) || locale.startsWith(l.split('-')[0])) {
|
|
688
688
|
return l;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
@@ -692,11 +692,9 @@ export const normalizeLocale = (locale?: string): SupportedLocale => {
|
|
|
692
692
|
return DEFAULT_LOCALE as SupportedLocale;
|
|
693
693
|
};
|
|
694
694
|
|
|
695
|
-
export const localeOptions =
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
2
|
|
699
|
-
)} as const;
|
|
695
|
+
export const localeOptions = [
|
|
696
|
+
${locales.map((l) => ` { value: '${l}', label: '${getLocaleLabel(l)}' },`).join("\n")}
|
|
697
|
+
] as const;
|
|
700
698
|
`;
|
|
701
699
|
writeFileSync2(filePath, content, "utf-8");
|
|
702
700
|
logger.info(`\u5DF2\u751F\u6210\u7C7B\u578B\u6587\u4EF6: ${sourceDir}/../resources.ts`);
|
|
@@ -715,35 +713,35 @@ function getLocaleLabel(locale) {
|
|
|
715
713
|
"ru-RU": "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
|
|
716
714
|
"it-IT": "Italiano",
|
|
717
715
|
"vi-VN": "Ti\u1EBFng Vi\u1EC7t",
|
|
718
|
-
ar: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"
|
|
716
|
+
"ar": "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"
|
|
719
717
|
};
|
|
720
718
|
return map[locale] || locale;
|
|
721
719
|
}
|
|
722
720
|
function scaffoldConvertScript(cwd, sourceDir, localesDir, defaultLocale, logger) {
|
|
723
721
|
const scriptsDir = join3(cwd, "scripts");
|
|
724
|
-
const scriptPath = join3(scriptsDir, "i18n-gen.
|
|
725
|
-
if (existsSync3(scriptPath)) return;
|
|
722
|
+
const scriptPath = join3(scriptsDir, "i18n-gen.cjs");
|
|
723
|
+
if (existsSync3(scriptPath) || existsSync3(join3(scriptsDir, "i18n-gen.js"))) return;
|
|
726
724
|
if (!existsSync3(scriptsDir)) {
|
|
727
725
|
mkdirSync(scriptsDir, { recursive: true });
|
|
728
726
|
}
|
|
729
|
-
const content = `const fs = require(
|
|
730
|
-
const path = require(
|
|
727
|
+
const content = `const fs = require('node:fs');
|
|
728
|
+
const path = require('node:path');
|
|
731
729
|
|
|
732
|
-
const sourceDir = path.join(__dirname,
|
|
733
|
-
const targetDir = path.join(__dirname,
|
|
730
|
+
const sourceDir = path.join(__dirname, '../${sourceDir}');
|
|
731
|
+
const targetDir = path.join(__dirname, '../${localesDir}/${defaultLocale}');
|
|
734
732
|
|
|
735
733
|
const files = fs
|
|
736
734
|
.readdirSync(sourceDir)
|
|
737
|
-
.filter((file) => file.endsWith(
|
|
738
|
-
.map((file) => path.basename(file,
|
|
735
|
+
.filter((file) => file.endsWith('.ts') && file !== 'index.ts')
|
|
736
|
+
.map((file) => path.basename(file, '.ts'));
|
|
739
737
|
|
|
740
|
-
require(
|
|
738
|
+
require('ts-node/register');
|
|
741
739
|
|
|
742
740
|
if (!fs.existsSync(targetDir)) {
|
|
743
741
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
744
742
|
}
|
|
745
743
|
|
|
746
|
-
console.log(
|
|
744
|
+
console.log('\u5F00\u59CB\u8F6C\u6362 TypeScript \u6587\u4EF6\u5230 JSON...\\n');
|
|
747
745
|
|
|
748
746
|
files.forEach((fileName) => {
|
|
749
747
|
try {
|
|
@@ -752,28 +750,28 @@ files.forEach((fileName) => {
|
|
|
752
750
|
const moduleContent = require(modulePath).default;
|
|
753
751
|
const jsonContent = JSON.stringify(moduleContent, null, 2);
|
|
754
752
|
const targetPath = path.join(targetDir, \`\${fileName}.json\`);
|
|
755
|
-
fs.writeFileSync(targetPath, jsonContent,
|
|
753
|
+
fs.writeFileSync(targetPath, jsonContent, 'utf8');
|
|
756
754
|
console.log(\` \${fileName}.ts \u2192 \${fileName}.json\`);
|
|
757
755
|
} catch (error) {
|
|
758
756
|
console.error(\` \u8F6C\u6362 \${fileName}.ts \u5931\u8D25:\`, error.message);
|
|
759
757
|
}
|
|
760
758
|
});
|
|
761
759
|
|
|
762
|
-
console.log(
|
|
760
|
+
console.log('\\n\u8F6C\u6362\u5B8C\u6210\uFF01');
|
|
763
761
|
`;
|
|
764
762
|
writeFileSync2(scriptPath, content, "utf-8");
|
|
765
|
-
logger.info("\u5DF2\u751F\u6210\u8F6C\u6362\u811A\u672C: scripts/i18n-gen.
|
|
763
|
+
logger.info("\u5DF2\u751F\u6210\u8F6C\u6362\u811A\u672C: scripts/i18n-gen.cjs");
|
|
766
764
|
}
|
|
767
765
|
function scaffoldI18nRc(cwd, localesDir, defaultLocale, locales, logger) {
|
|
768
766
|
const filePath = join3(cwd, ".i18nrc.js");
|
|
769
767
|
if (existsSync3(filePath)) return;
|
|
770
|
-
const outputLocales = locales.filter((l) => l !== defaultLocale).map((l) => `
|
|
771
|
-
const content = `const { defineConfig } = require(
|
|
768
|
+
const outputLocales = locales.filter((l) => l !== defaultLocale).map((l) => `'${l}'`).join(", ");
|
|
769
|
+
const content = `const { defineConfig } = require('@4399ywkf/i18n');
|
|
772
770
|
|
|
773
771
|
module.exports = defineConfig({
|
|
774
|
-
entry:
|
|
775
|
-
entryLocale:
|
|
776
|
-
output:
|
|
772
|
+
entry: '${localesDir}/${defaultLocale}',
|
|
773
|
+
entryLocale: '${defaultLocale}',
|
|
774
|
+
output: '${localesDir}',
|
|
777
775
|
outputLocales: [${outputLocales}],
|
|
778
776
|
});
|
|
779
777
|
`;
|
|
@@ -792,15 +790,16 @@ function scaffoldLocaleJsonDirs(cwd, localesDir, locales, defaultLocale, namespa
|
|
|
792
790
|
const filePath = join3(localeDir, `${ns}.json`);
|
|
793
791
|
if (!existsSync3(filePath)) {
|
|
794
792
|
const placeholder = ns === "common" ? JSON.stringify(
|
|
793
|
+
// 键按字母序排列,与 @4399ywkf/lint 的 Prettier(prettier-plugin-sort-json)一致
|
|
795
794
|
{
|
|
796
|
-
|
|
797
|
-
loading: "Loading...",
|
|
798
|
-
confirm: "OK",
|
|
795
|
+
back: "Back",
|
|
799
796
|
cancel: "Cancel",
|
|
800
|
-
|
|
797
|
+
confirm: "OK",
|
|
801
798
|
delete: "Delete",
|
|
802
799
|
edit: "Edit",
|
|
803
|
-
|
|
800
|
+
loading: "Loading...",
|
|
801
|
+
save: "Save",
|
|
802
|
+
welcome: "Welcome"
|
|
804
803
|
},
|
|
805
804
|
null,
|
|
806
805
|
2
|
|
@@ -866,7 +865,7 @@ function scanMockFiles(dir) {
|
|
|
866
865
|
for (const entry of entries) {
|
|
867
866
|
const fullPath = join4(dir, entry);
|
|
868
867
|
const stat = statSync(fullPath);
|
|
869
|
-
if (stat.isFile() && /\.(ts|js|mjs)$/.test(entry)) {
|
|
868
|
+
if (stat.isFile() && /\.(?:ts|js|mjs)$/.test(entry)) {
|
|
870
869
|
files.push(fullPath);
|
|
871
870
|
} else if (stat.isDirectory()) {
|
|
872
871
|
files.push(...scanMockFiles(fullPath));
|
|
@@ -1343,12 +1342,13 @@ function generateThemeProvider(opts) {
|
|
|
1343
1342
|
scopePopupContainer
|
|
1344
1343
|
} = opts;
|
|
1345
1344
|
const isAutoLocale = locale === "auto";
|
|
1346
|
-
const sections = [
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1345
|
+
const sections = [
|
|
1346
|
+
`// \u6B64\u6587\u4EF6\u7531 @4399ywkf/plugin-theme v3 \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u624B\u52A8\u4FEE\u6539`,
|
|
1347
|
+
buildImports({ globalReset, cssVar, scopePopupContainer, locale }),
|
|
1348
|
+
TYPES_CODE,
|
|
1349
|
+
buildStoreCode({ defaultAppearance, primaryColor, neutralColor, locale }),
|
|
1350
|
+
HOOKS_CODE
|
|
1351
|
+
];
|
|
1352
1352
|
if (globalReset) sections.push(GLOBAL_RESET_CODE);
|
|
1353
1353
|
if (cssVar) sections.push(buildCssVarSyncCode());
|
|
1354
1354
|
if (darkMode) sections.push(APPEARANCE_SYNC_CODE);
|
|
@@ -2043,18 +2043,58 @@ export type { StateCreator, StoreApi } from "zustand";
|
|
|
2043
2043
|
|
|
2044
2044
|
// src/config/normalize.ts
|
|
2045
2045
|
var BUILTIN_PLUGINS = [
|
|
2046
|
-
{
|
|
2047
|
-
|
|
2048
|
-
|
|
2046
|
+
{
|
|
2047
|
+
key: "reactQuery",
|
|
2048
|
+
factory: reactQueryPlugin,
|
|
2049
|
+
pluginName: "@4399ywkf/plugin-react-query"
|
|
2050
|
+
},
|
|
2051
|
+
{
|
|
2052
|
+
key: "zustand",
|
|
2053
|
+
factory: zustandPlugin,
|
|
2054
|
+
pluginName: "@4399ywkf/plugin-zustand"
|
|
2055
|
+
},
|
|
2056
|
+
{
|
|
2057
|
+
key: "tailwind",
|
|
2058
|
+
factory: tailwindPlugin,
|
|
2059
|
+
pluginName: "@4399ywkf/plugin-tailwind"
|
|
2060
|
+
}
|
|
2049
2061
|
];
|
|
2050
2062
|
var OPTIONAL_PLUGINS = [
|
|
2051
|
-
{
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
{
|
|
2057
|
-
|
|
2063
|
+
{
|
|
2064
|
+
key: "biome",
|
|
2065
|
+
factory: biomePlugin,
|
|
2066
|
+
pluginName: "@4399ywkf/plugin-biome"
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
key: "analytics",
|
|
2070
|
+
factory: analyticsPlugin,
|
|
2071
|
+
pluginName: "@4399ywkf/plugin-analytics"
|
|
2072
|
+
},
|
|
2073
|
+
{
|
|
2074
|
+
key: "mock",
|
|
2075
|
+
factory: mockPlugin,
|
|
2076
|
+
pluginName: "@4399ywkf/plugin-mock"
|
|
2077
|
+
},
|
|
2078
|
+
{
|
|
2079
|
+
key: "theme",
|
|
2080
|
+
factory: themePlugin,
|
|
2081
|
+
pluginName: "@4399ywkf/plugin-theme"
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
key: "i18n",
|
|
2085
|
+
factory: i18nPlugin,
|
|
2086
|
+
pluginName: "@4399ywkf/plugin-i18n"
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
key: "garfish",
|
|
2090
|
+
factory: garfishPlugin,
|
|
2091
|
+
pluginName: "@4399ywkf/plugin-garfish"
|
|
2092
|
+
},
|
|
2093
|
+
{
|
|
2094
|
+
key: "browserCheck",
|
|
2095
|
+
factory: browserCheckPlugin,
|
|
2096
|
+
pluginName: "@4399ywkf/plugin-browser-check"
|
|
2097
|
+
}
|
|
2058
2098
|
];
|
|
2059
2099
|
var ALL_SHORTHAND_KEYS = /* @__PURE__ */ new Set([
|
|
2060
2100
|
...BUILTIN_PLUGINS.map((p) => p.key),
|
|
@@ -2184,7 +2224,12 @@ var defaultConfig = {
|
|
|
2184
2224
|
};
|
|
2185
2225
|
|
|
2186
2226
|
// src/config/loader.ts
|
|
2187
|
-
var CONFIG_FILES = [
|
|
2227
|
+
var CONFIG_FILES = [
|
|
2228
|
+
"ywkf.config.ts",
|
|
2229
|
+
"ywkf.config.mts",
|
|
2230
|
+
"ywkf.config.js",
|
|
2231
|
+
"ywkf.config.mjs"
|
|
2232
|
+
];
|
|
2188
2233
|
function findConfigFile(cwd) {
|
|
2189
2234
|
for (const file of CONFIG_FILES) {
|
|
2190
2235
|
const configPath = resolve2(cwd, file);
|
|
@@ -2509,7 +2554,7 @@ function winPath(path) {
|
|
|
2509
2554
|
if (isExtendedLengthPath) {
|
|
2510
2555
|
return path;
|
|
2511
2556
|
}
|
|
2512
|
-
return path.
|
|
2557
|
+
return path.replaceAll("\\", "/");
|
|
2513
2558
|
}
|
|
2514
2559
|
var EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
2515
2560
|
"components",
|
|
@@ -2645,16 +2690,16 @@ var ConventionalRouteGenerator = class {
|
|
|
2645
2690
|
*/
|
|
2646
2691
|
resolveRoutePath(dirName, parentPath) {
|
|
2647
2692
|
let segment;
|
|
2648
|
-
if (
|
|
2693
|
+
if (/^\[\.\.\..+\]$/.test(dirName)) {
|
|
2649
2694
|
segment = "*";
|
|
2650
|
-
} else if (
|
|
2695
|
+
} else if (/^\[.+\$\]$/.test(dirName)) {
|
|
2651
2696
|
const param = dirName.slice(1, -2);
|
|
2652
2697
|
segment = `:${param}?`;
|
|
2653
|
-
} else if (
|
|
2698
|
+
} else if (/^\[.+\]$/.test(dirName)) {
|
|
2654
2699
|
const param = dirName.slice(1, -1);
|
|
2655
2700
|
segment = `:${param}`;
|
|
2656
2701
|
} else if (dirName.includes(".")) {
|
|
2657
|
-
segment = dirName.
|
|
2702
|
+
segment = dirName.replaceAll(".", "/");
|
|
2658
2703
|
} else {
|
|
2659
2704
|
segment = dirName;
|
|
2660
2705
|
}
|
|
@@ -2665,7 +2710,7 @@ var ConventionalRouteGenerator = class {
|
|
|
2665
2710
|
*/
|
|
2666
2711
|
generateRouteName(path) {
|
|
2667
2712
|
const name = path.split("/").filter(Boolean).map((s) => s.replace(/^:/, "Param").replace(/\?$/, "Optional").replace(/^\*$/, "CatchAll")).map((s) => {
|
|
2668
|
-
const cleaned = s.
|
|
2713
|
+
const cleaned = s.replaceAll(/[^a-z0-9]/gi, "");
|
|
2669
2714
|
if (!cleaned) return "";
|
|
2670
2715
|
return cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
|
|
2671
2716
|
}).join("");
|
|
@@ -2785,9 +2830,7 @@ export default routes;
|
|
|
2785
2830
|
);
|
|
2786
2831
|
}
|
|
2787
2832
|
if (route.errorFile) {
|
|
2788
|
-
errorImports.push(
|
|
2789
|
-
`import ${name}Error from "@/pages/${toImportPath(route.errorFile)}";`
|
|
2790
|
-
);
|
|
2833
|
+
errorImports.push(`import ${name}Error from "@/pages/${toImportPath(route.errorFile)}";`);
|
|
2791
2834
|
}
|
|
2792
2835
|
if (route.loadingFile) {
|
|
2793
2836
|
loadingImports.push(
|
|
@@ -3298,7 +3341,7 @@ var YwkfGenerator = class {
|
|
|
3298
3341
|
* 标准化内容(去掉时间戳等动态部分)
|
|
3299
3342
|
*/
|
|
3300
3343
|
normalizeContent(content) {
|
|
3301
|
-
return content.
|
|
3344
|
+
return content.replaceAll(/\/\/ Generated at: .+/g, "").replaceAll(/\/\*\* Generated at: .+ \*\//g, "");
|
|
3302
3345
|
}
|
|
3303
3346
|
};
|
|
3304
3347
|
|
|
@@ -3518,7 +3561,16 @@ function resolveYwkfBuildId(appName) {
|
|
|
3518
3561
|
function createBaseConfig(config, cwd, options = {}) {
|
|
3519
3562
|
const isDev = options.isDev ?? process.env.NODE_ENV !== "production";
|
|
3520
3563
|
const { resolveApp } = createPathResolver(cwd);
|
|
3521
|
-
const {
|
|
3564
|
+
const {
|
|
3565
|
+
appName,
|
|
3566
|
+
appCName,
|
|
3567
|
+
output,
|
|
3568
|
+
html,
|
|
3569
|
+
alias: userAlias,
|
|
3570
|
+
microFrontend,
|
|
3571
|
+
router,
|
|
3572
|
+
reactCompiler
|
|
3573
|
+
} = config;
|
|
3522
3574
|
const buildId = resolveYwkfBuildId(appName);
|
|
3523
3575
|
const { env: clientEnv, dropped: droppedEnvKeys } = buildClientEnv({ cwd, env: config.env });
|
|
3524
3576
|
if (droppedEnvKeys.length > 0) {
|
|
@@ -3551,7 +3603,7 @@ function createBaseConfig(config, cwd, options = {}) {
|
|
|
3551
3603
|
...alias,
|
|
3552
3604
|
"process/browser.js": require2.resolve("process/browser.js"),
|
|
3553
3605
|
"process/browser": require2.resolve("process/browser.js"),
|
|
3554
|
-
react: resolveApp("node_modules/react"),
|
|
3606
|
+
"react": resolveApp("node_modules/react"),
|
|
3555
3607
|
"react-dom": resolveApp("node_modules/react-dom"),
|
|
3556
3608
|
"react-router": resolveApp("node_modules/react-router")
|
|
3557
3609
|
},
|
|
@@ -4403,9 +4455,10 @@ function registerShortcuts(getPrinter, opts) {
|
|
|
4403
4455
|
const cmd = buffer.trim().toLowerCase();
|
|
4404
4456
|
buffer = "";
|
|
4405
4457
|
switch (cmd) {
|
|
4406
|
-
case "h":
|
|
4458
|
+
case "h": {
|
|
4407
4459
|
getPrinter().printShortcuts();
|
|
4408
4460
|
break;
|
|
4461
|
+
}
|
|
4409
4462
|
case "o": {
|
|
4410
4463
|
const url = `http://${displayHost(opts.getHost())}:${opts.getPort()}/`;
|
|
4411
4464
|
import("child_process").then((cp) => {
|
|
@@ -4415,12 +4468,14 @@ function registerShortcuts(getPrinter, opts) {
|
|
|
4415
4468
|
console.log(` ${chalk.green("\u279C")} Opening ${chalk.cyan(url)}...`);
|
|
4416
4469
|
break;
|
|
4417
4470
|
}
|
|
4418
|
-
case "c":
|
|
4471
|
+
case "c": {
|
|
4419
4472
|
console.clear();
|
|
4420
4473
|
break;
|
|
4421
|
-
|
|
4474
|
+
}
|
|
4475
|
+
case "q": {
|
|
4422
4476
|
opts.onQuit();
|
|
4423
4477
|
break;
|
|
4478
|
+
}
|
|
4424
4479
|
}
|
|
4425
4480
|
};
|
|
4426
4481
|
process.stdin.on("data", handler);
|
|
@@ -4571,20 +4626,16 @@ async function findPortHolder(port) {
|
|
|
4571
4626
|
const pid2 = parseWindowsNetstatPid(stdout2, port);
|
|
4572
4627
|
return pid2 === null ? null : { pid: pid2 };
|
|
4573
4628
|
}
|
|
4574
|
-
const { stdout } = await execFileAsync(
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
{ timeout: 1500 }
|
|
4578
|
-
);
|
|
4629
|
+
const { stdout } = await execFileAsync("lsof", ["-nP", `-iTCP:${port}`, "-sTCP:LISTEN", "-t"], {
|
|
4630
|
+
timeout: 1500
|
|
4631
|
+
});
|
|
4579
4632
|
const pid = Number.parseInt(stdout.trim().split(/\s+/)[0], 10);
|
|
4580
4633
|
if (!Number.isInteger(pid)) return null;
|
|
4581
4634
|
let name;
|
|
4582
4635
|
try {
|
|
4583
|
-
const { stdout: comm } = await execFileAsync(
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
{ timeout: 1500 }
|
|
4587
|
-
);
|
|
4636
|
+
const { stdout: comm } = await execFileAsync("ps", ["-p", String(pid), "-o", "comm="], {
|
|
4637
|
+
timeout: 1500
|
|
4638
|
+
});
|
|
4588
4639
|
name = comm.trim().split("/").pop() || void 0;
|
|
4589
4640
|
} catch {
|
|
4590
4641
|
}
|
|
@@ -4731,7 +4782,7 @@ async function startDevServer(cwd, config) {
|
|
|
4731
4782
|
printer.updateProgress(0, "rebuilding");
|
|
4732
4783
|
});
|
|
4733
4784
|
const devServerOptions = {
|
|
4734
|
-
...rspackConfig.devServer
|
|
4785
|
+
...rspackConfig.devServer,
|
|
4735
4786
|
host,
|
|
4736
4787
|
port,
|
|
4737
4788
|
setupExitSignals: false
|