@4399ywkf/core 5.3.0 → 5.4.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.
@@ -1,7 +1,7 @@
1
- import { Y as YwkfConfig } from '../schema-QzJlmn39.js';
2
- export { B as BuiltinPluginConfig, D as DevServerConfig, E as EnvConfig, H as HtmlConfig, M as MicroFrontendConfig, O as OptionalPluginConfig, b as OutputConfig, P as PerformanceConfig, R as RouterConfig, S as StyleConfig, T as ToolsConfig, c as YwkfUserConfig, d as defaultConfig, a as defineConfig } from '../schema-QzJlmn39.js';
1
+ import { Y as YwkfConfig } from '../schema-BblOKuYl.js';
2
+ export { B as BuiltinPluginConfig, D as DevServerConfig, E as EnvConfig, H as HtmlConfig, M as MicroFrontendConfig, O as OptionalPluginConfig, b as OutputConfig, P as PerformanceConfig, R as RouterConfig, S as StyleConfig, T as ToolsConfig, c as YwkfUserConfig, d as defaultConfig, a as defineConfig } from '../schema-BblOKuYl.js';
3
3
  import '@rspack/core';
4
- import '../types-ZJhd87ue.js';
4
+ import '../types-DZ7Nz9bQ.js';
5
5
  import 'react';
6
6
  import 'react-router';
7
7
 
@@ -142,9 +142,7 @@ var browserCheckPlugin = createPlugin((options = {}) => ({
142
142
  }
143
143
  }
144
144
  const minVersions = explicitVersions ? { ...baseVersions, ...explicitVersions } : baseVersions;
145
- logger.info(
146
- `\u6D4F\u89C8\u5668\u517C\u5BB9\u6027\u68C0\u67E5\u5DF2\u542F\u7528 (\u7279\u6027\u68C0\u6D4B: ${features.join(", ")})`
147
- );
145
+ logger.info(`\u6D4F\u89C8\u5668\u517C\u5BB9\u6027\u68C0\u67E5\u5DF2\u542F\u7528 (\u7279\u6027\u68C0\u6D4B: ${features.join(", ")})`);
148
146
  logger.info(
149
147
  `\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)" : ""}`
150
148
  );
@@ -184,7 +182,7 @@ var browserCheckPlugin = createPlugin((options = {}) => ({
184
182
  const insertIndex = lastImportIndex >= 0 ? lastImportIndex + 1 : 0;
185
183
  lines.splice(insertIndex, 0, checkBlock);
186
184
  let result = lines.join("\n");
187
- result = result.replace(
185
+ result = result.replaceAll(
188
186
  /(\s*)(await\s+)?runApp\(\);?/g,
189
187
  (_, indent, awaitKw) => `${indent}if (__ywkfBrowserOk) { ${awaitKw || ""}runApp(); }`
190
188
  );
@@ -208,37 +206,39 @@ function buildFeatureChecks(features) {
208
206
  return lines;
209
207
  }
210
208
  function buildVersionChecks(minVersions) {
211
- const entries = Object.entries(minVersions).filter(
212
- ([, v]) => v != null
213
- );
209
+ const entries = Object.entries(minVersions).filter(([, v]) => v != null);
214
210
  if (entries.length === 0) return [];
215
211
  const lines = ["// UA \u7248\u672C\u68C0\u6D4B", "const ua = navigator.userAgent;"];
216
212
  for (const [browser, minVer] of entries) {
217
213
  switch (browser) {
218
- case "chrome":
214
+ case "chrome": {
219
215
  lines.push(
220
216
  `const chromeMatch = /Chrome\\/(\\d+)/.exec(ua);`,
221
217
  `if (chromeMatch && !/Edg\\//.test(ua) && Number(chromeMatch[1]) < ${minVer}) return false;`
222
218
  );
223
219
  break;
224
- case "edge":
220
+ }
221
+ case "edge": {
225
222
  lines.push(
226
223
  `const edgeMatch = /Edg\\/(\\d+)/.exec(ua);`,
227
224
  `if (edgeMatch && Number(edgeMatch[1]) < ${minVer}) return false;`
228
225
  );
229
226
  break;
230
- case "firefox":
227
+ }
228
+ case "firefox": {
231
229
  lines.push(
232
230
  `const firefoxMatch = /Firefox\\/(\\d+)/.exec(ua);`,
233
231
  `if (firefoxMatch && Number(firefoxMatch[1]) < ${minVer}) return false;`
234
232
  );
235
233
  break;
236
- case "safari":
234
+ }
235
+ case "safari": {
237
236
  lines.push(
238
237
  `const safariMatch = /Version\\/(\\d+\\.?\\d*)/.exec(ua);`,
239
238
  `if (safariMatch && /Safari/.test(ua) && !/Chrome/.test(ua) && Number(safariMatch[1]) < ${minVer}) return false;`
240
239
  );
241
240
  break;
241
+ }
242
242
  }
243
243
  }
244
244
  return lines;
@@ -331,9 +331,9 @@ function readBrowserslistFile(filePath) {
331
331
  function extractMinVersions(queries) {
332
332
  const result = {};
333
333
  const expanded = queries.flatMap((q) => q.split(",").map((s) => s.trim()));
334
- const versionPattern = /^(\w+)\s*(?:(>=?)\s*)?(\d+(?:\.\d+)?)\s*$/i;
334
+ const versionPattern = /^([a-z_]+)\s*(?:(>=?)\s*)?(\d+(?:\.\d+)?)\s*$/i;
335
335
  for (const query of expanded) {
336
- if (/^(not|dead|last|defaults|>?\s*\d+%|unreleased|current)/i.test(query)) {
336
+ if (/^(?:not|dead|last|defaults|>?\s*\d+%|unreleased|current)/i.test(query)) {
337
337
  continue;
338
338
  }
339
339
  const match = versionPattern.exec(query);
@@ -374,7 +374,7 @@ var garfishPlugin = createPlugin((options = {}) => ({
374
374
  rspackConfig.devServer = {
375
375
  ...rspackConfig.devServer,
376
376
  headers: {
377
- ...rspackConfig.devServer?.headers || {},
377
+ ...rspackConfig.devServer?.headers,
378
378
  "Access-Control-Allow-Origin": "*",
379
379
  "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
380
380
  "Access-Control-Allow-Headers": "*"
@@ -702,7 +702,7 @@ function getLocaleLabel(locale) {
702
702
  "ru-RU": "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
703
703
  "it-IT": "Italiano",
704
704
  "vi-VN": "Ti\u1EBFng Vi\u1EC7t",
705
- ar: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"
705
+ "ar": "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"
706
706
  };
707
707
  return map[locale] || locale;
708
708
  }
@@ -755,7 +755,7 @@ function scaffoldI18nRc(cwd, localesDir, defaultLocale, locales, logger) {
755
755
  const filePath = join3(cwd, ".i18nrc.js");
756
756
  if (existsSync3(filePath)) return;
757
757
  const outputLocales = locales.filter((l) => l !== defaultLocale).map((l) => `"${l}"`).join(", ");
758
- const content = `const { defineConfig } = require("@lobehub/i18n-cli");
758
+ const content = `const { defineConfig } = require("@4399ywkf/i18n");
759
759
 
760
760
  module.exports = defineConfig({
761
761
  entry: "${localesDir}/${defaultLocale}",
@@ -765,7 +765,7 @@ module.exports = defineConfig({
765
765
  });
766
766
  `;
767
767
  writeFileSync2(filePath, content, "utf-8");
768
- logger.info("\u5DF2\u751F\u6210\u7FFB\u8BD1\u914D\u7F6E: .i18nrc.js\uFF08@lobehub/i18n-cli\uFF09");
768
+ logger.info("\u5DF2\u751F\u6210\u7FFB\u8BD1\u914D\u7F6E: .i18nrc.js\uFF08\u9700\u5B89\u88C5 @4399ywkf/i18n\uFF09");
769
769
  }
770
770
  function scaffoldLocaleJsonDirs(cwd, localesDir, locales, defaultLocale, namespaces, logger) {
771
771
  const baseDir = join3(cwd, localesDir);
@@ -853,7 +853,7 @@ function scanMockFiles(dir) {
853
853
  for (const entry of entries) {
854
854
  const fullPath = join4(dir, entry);
855
855
  const stat = statSync(fullPath);
856
- if (stat.isFile() && /\.(ts|js|mjs)$/.test(entry)) {
856
+ if (stat.isFile() && /\.(?:ts|js|mjs)$/.test(entry)) {
857
857
  files.push(fullPath);
858
858
  } else if (stat.isDirectory()) {
859
859
  files.push(...scanMockFiles(fullPath));
@@ -1330,12 +1330,13 @@ function generateThemeProvider(opts) {
1330
1330
  scopePopupContainer
1331
1331
  } = opts;
1332
1332
  const isAutoLocale = locale === "auto";
1333
- const sections = [];
1334
- sections.push(`// \u6B64\u6587\u4EF6\u7531 @4399ywkf/plugin-theme v3 \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u624B\u52A8\u4FEE\u6539`);
1335
- sections.push(buildImports({ globalReset, cssVar, scopePopupContainer, locale }));
1336
- sections.push(TYPES_CODE);
1337
- sections.push(buildStoreCode({ defaultAppearance, primaryColor, neutralColor, locale }));
1338
- sections.push(HOOKS_CODE);
1333
+ const sections = [
1334
+ `// \u6B64\u6587\u4EF6\u7531 @4399ywkf/plugin-theme v3 \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u624B\u52A8\u4FEE\u6539`,
1335
+ buildImports({ globalReset, cssVar, scopePopupContainer, locale }),
1336
+ TYPES_CODE,
1337
+ buildStoreCode({ defaultAppearance, primaryColor, neutralColor, locale }),
1338
+ HOOKS_CODE
1339
+ ];
1339
1340
  if (globalReset) sections.push(GLOBAL_RESET_CODE);
1340
1341
  if (cssVar) sections.push(buildCssVarSyncCode());
1341
1342
  if (darkMode) sections.push(APPEARANCE_SYNC_CODE);
@@ -2030,18 +2031,58 @@ export type { StateCreator, StoreApi } from "zustand";
2030
2031
 
2031
2032
  // src/config/normalize.ts
2032
2033
  var BUILTIN_PLUGINS = [
2033
- { key: "reactQuery", factory: reactQueryPlugin, pluginName: "@4399ywkf/plugin-react-query" },
2034
- { key: "zustand", factory: zustandPlugin, pluginName: "@4399ywkf/plugin-zustand" },
2035
- { key: "tailwind", factory: tailwindPlugin, pluginName: "@4399ywkf/plugin-tailwind" }
2034
+ {
2035
+ key: "reactQuery",
2036
+ factory: reactQueryPlugin,
2037
+ pluginName: "@4399ywkf/plugin-react-query"
2038
+ },
2039
+ {
2040
+ key: "zustand",
2041
+ factory: zustandPlugin,
2042
+ pluginName: "@4399ywkf/plugin-zustand"
2043
+ },
2044
+ {
2045
+ key: "tailwind",
2046
+ factory: tailwindPlugin,
2047
+ pluginName: "@4399ywkf/plugin-tailwind"
2048
+ }
2036
2049
  ];
2037
2050
  var OPTIONAL_PLUGINS = [
2038
- { key: "biome", factory: biomePlugin, pluginName: "@4399ywkf/plugin-biome" },
2039
- { key: "analytics", factory: analyticsPlugin, pluginName: "@4399ywkf/plugin-analytics" },
2040
- { key: "mock", factory: mockPlugin, pluginName: "@4399ywkf/plugin-mock" },
2041
- { key: "theme", factory: themePlugin, pluginName: "@4399ywkf/plugin-theme" },
2042
- { key: "i18n", factory: i18nPlugin, pluginName: "@4399ywkf/plugin-i18n" },
2043
- { key: "garfish", factory: garfishPlugin, pluginName: "@4399ywkf/plugin-garfish" },
2044
- { key: "browserCheck", factory: browserCheckPlugin, pluginName: "@4399ywkf/plugin-browser-check" }
2051
+ {
2052
+ key: "biome",
2053
+ factory: biomePlugin,
2054
+ pluginName: "@4399ywkf/plugin-biome"
2055
+ },
2056
+ {
2057
+ key: "analytics",
2058
+ factory: analyticsPlugin,
2059
+ pluginName: "@4399ywkf/plugin-analytics"
2060
+ },
2061
+ {
2062
+ key: "mock",
2063
+ factory: mockPlugin,
2064
+ pluginName: "@4399ywkf/plugin-mock"
2065
+ },
2066
+ {
2067
+ key: "theme",
2068
+ factory: themePlugin,
2069
+ pluginName: "@4399ywkf/plugin-theme"
2070
+ },
2071
+ {
2072
+ key: "i18n",
2073
+ factory: i18nPlugin,
2074
+ pluginName: "@4399ywkf/plugin-i18n"
2075
+ },
2076
+ {
2077
+ key: "garfish",
2078
+ factory: garfishPlugin,
2079
+ pluginName: "@4399ywkf/plugin-garfish"
2080
+ },
2081
+ {
2082
+ key: "browserCheck",
2083
+ factory: browserCheckPlugin,
2084
+ pluginName: "@4399ywkf/plugin-browser-check"
2085
+ }
2045
2086
  ];
2046
2087
  var ALL_SHORTHAND_KEYS = /* @__PURE__ */ new Set([
2047
2088
  ...BUILTIN_PLUGINS.map((p) => p.key),
@@ -2174,7 +2215,12 @@ var defaultConfig = {
2174
2215
  };
2175
2216
 
2176
2217
  // src/config/loader.ts
2177
- var CONFIG_FILES = ["ywkf.config.ts", "ywkf.config.mts", "ywkf.config.js", "ywkf.config.mjs"];
2218
+ var CONFIG_FILES = [
2219
+ "ywkf.config.ts",
2220
+ "ywkf.config.mts",
2221
+ "ywkf.config.js",
2222
+ "ywkf.config.mjs"
2223
+ ];
2178
2224
  function findConfigFile(cwd) {
2179
2225
  for (const file of CONFIG_FILES) {
2180
2226
  const configPath = resolve2(cwd, file);