@dcloudio/uni-cli-shared 3.0.0-alpha-3090020230826001 → 3.0.0-alpha-3090020230909001

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.
@@ -7,6 +7,7 @@ export declare const EXTNAME_VUE_RE: RegExp;
7
7
  export declare const EXTNAME_JS_RE: RegExp;
8
8
  export declare const EXTNAME_TS_RE: RegExp;
9
9
  export declare const extensions: string[];
10
+ export declare const uni_app_x_extensions: string[];
10
11
  export declare const PAGES_JSON_JS = "pages-json-js";
11
12
  export declare const PAGES_JSON_UTS = "pages-json-uts";
12
13
  export declare const MANIFEST_JSON_JS = "manifest-json-js";
package/dist/constants.js CHANGED
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
3
+ exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
4
4
  exports.PUBLIC_DIR = 'static';
5
5
  exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
6
6
  exports.EXTNAME_TS = ['.ts', '.tsx'];
7
- exports.EXTNAME_VUE = ['.vue', '.nvue', '.uvue'];
7
+ exports.EXTNAME_VUE = ['.vue', '.nvue'];
8
8
  exports.EXTNAME_VUE_TEMPLATE = ['.vue', '.nvue', '.jsx', '.tsx'];
9
- exports.EXTNAME_VUE_RE = /\.(vue|nvue)$/;
9
+ exports.EXTNAME_VUE_RE = /\.(vue|nvue|uvue)$/;
10
10
  exports.EXTNAME_JS_RE = /\.(js|jsx|ts|tsx|mjs)$/;
11
11
  exports.EXTNAME_TS_RE = /\.tsx?$/;
12
- exports.extensions = [
12
+ const COMMON_EXTENSIONS = [
13
13
  '.uts',
14
14
  '.mjs',
15
15
  '.js',
@@ -17,7 +17,9 @@ exports.extensions = [
17
17
  '.jsx',
18
18
  '.tsx',
19
19
  '.json',
20
- ].concat(exports.EXTNAME_VUE);
20
+ ];
21
+ exports.extensions = COMMON_EXTENSIONS.concat(exports.EXTNAME_VUE);
22
+ exports.uni_app_x_extensions = COMMON_EXTENSIONS.concat(['.uvue', '.vue']);
21
23
  exports.PAGES_JSON_JS = 'pages-json-js';
22
24
  exports.PAGES_JSON_UTS = 'pages-json-uts';
23
25
  exports.MANIFEST_JSON_JS = 'manifest-json-js';
package/dist/easycom.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  interface EasycomOption {
2
2
  dirs?: string[];
3
3
  rootDir: string;
4
- extensions?: string[];
4
+ extensions: string[];
5
5
  autoscan?: boolean;
6
6
  custom?: EasycomCustom;
7
7
  }
@@ -13,9 +13,10 @@ export interface EasycomMatcher {
13
13
  interface EasycomCustom {
14
14
  [key: string]: string;
15
15
  }
16
- export declare function initEasycoms(inputDir: string, { dirs, platform }: {
16
+ export declare function initEasycoms(inputDir: string, { dirs, platform, isX, }: {
17
17
  dirs: string[];
18
18
  platform: UniApp.PLATFORM;
19
+ isX?: boolean;
19
20
  }): {
20
21
  options: EasycomOption;
21
22
  filter: (id: unknown) => boolean;
package/dist/easycom.js CHANGED
@@ -24,7 +24,7 @@ function clearEasycom() {
24
24
  easycomsCache.clear();
25
25
  easycomsInvalidCache.clear();
26
26
  }
27
- function initEasycoms(inputDir, { dirs, platform }) {
27
+ function initEasycoms(inputDir, { dirs, platform, isX, }) {
28
28
  const componentsDir = path_1.default.resolve(inputDir, 'components');
29
29
  const uniModulesDir = path_1.default.resolve(inputDir, 'uni_modules');
30
30
  const initEasycomOptions = (pagesJson) => {
@@ -41,6 +41,7 @@ function initEasycoms(inputDir, { dirs, platform }) {
41
41
  rootDir: inputDir,
42
42
  autoscan: !!(easycom && easycom.autoscan),
43
43
  custom: (easycom && easycom.custom) || {},
44
+ extensions: [...(isX ? ['.uvue'] : []), ...['.vue', '.jsx', '.tsx']],
44
45
  };
45
46
  debugEasycom(easycomOptions);
46
47
  return easycomOptions;
@@ -59,13 +60,14 @@ function initEasycoms(inputDir, { dirs, platform }) {
59
60
  };
60
61
  initEasycom(options);
61
62
  initUTSEasycom();
63
+ const componentExtNames = isX ? 'uvue|vue' : 'vue';
62
64
  const res = {
63
65
  options,
64
66
  filter: (0, pluginutils_1.createFilter)([
65
- 'components/*/*.(vue|jsx|tsx)',
66
- 'uni_modules/*/components/*/*.(vue|jsx|tsx)',
67
- 'utssdk/*/**/*.vue',
68
- 'uni_modules/*/utssdk/*/*.vue',
67
+ 'components/*/*.(' + componentExtNames + '|jsx|tsx)',
68
+ 'uni_modules/*/components/*/*.(' + componentExtNames + '|jsx|tsx)',
69
+ 'utssdk/*/**/*.(' + componentExtNames + ')',
70
+ 'uni_modules/*/utssdk/*/*.(' + componentExtNames + ')',
69
71
  ], [], {
70
72
  resolve: inputDir,
71
73
  }),
@@ -94,7 +96,7 @@ function initUniModulesEasycomDirs(uniModulesDir) {
94
96
  })
95
97
  .filter(Boolean);
96
98
  }
97
- function initEasycom({ dirs, rootDir, custom, extensions = ['.vue', '.jsx', '.tsx'], }) {
99
+ function initEasycom({ dirs, rootDir, custom, extensions }) {
98
100
  clearEasycom();
99
101
  const easycomsObj = Object.create(null);
100
102
  if (dirs && dirs.length && rootDir) {
@@ -2,3 +2,4 @@ export declare function normalizeAppManifestJson(userManifestJson: Record<string
2
2
  export * from './env';
3
3
  export { APP_CONFUSION_FILENAME, isConfusionFile, hasConfusionFile, } from './confusion';
4
4
  export { getNVueCompiler, getNVueStyleCompiler, getNVueFlexDirection, } from './nvue';
5
+ export { parseArguments } from './arguments';
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getNVueFlexDirection = exports.getNVueStyleCompiler = exports.getNVueCompiler = exports.hasConfusionFile = exports.isConfusionFile = exports.APP_CONFUSION_FILENAME = exports.normalizeAppManifestJson = void 0;
17
+ exports.parseArguments = exports.getNVueFlexDirection = exports.getNVueStyleCompiler = exports.getNVueCompiler = exports.hasConfusionFile = exports.isConfusionFile = exports.APP_CONFUSION_FILENAME = exports.normalizeAppManifestJson = void 0;
18
18
  const shared_1 = require("@vue/shared");
19
19
  const merge_1 = require("./merge");
20
20
  const defaultManifestJson_1 = require("./defaultManifestJson");
@@ -59,3 +59,5 @@ var nvue_2 = require("./nvue");
59
59
  Object.defineProperty(exports, "getNVueCompiler", { enumerable: true, get: function () { return nvue_2.getNVueCompiler; } });
60
60
  Object.defineProperty(exports, "getNVueStyleCompiler", { enumerable: true, get: function () { return nvue_2.getNVueStyleCompiler; } });
61
61
  Object.defineProperty(exports, "getNVueFlexDirection", { enumerable: true, get: function () { return nvue_2.getNVueFlexDirection; } });
62
+ var arguments_2 = require("./arguments");
63
+ Object.defineProperty(exports, "parseArguments", { enumerable: true, get: function () { return arguments_2.parseArguments; } });
@@ -215,9 +215,9 @@ function normalizePageStyle(pagePath, pageStyle, platform) {
215
215
  }
216
216
  if (pageStyle) {
217
217
  if (platform === 'h5') {
218
- (0, shared_1.extend)(pageStyle, pageStyle['app'] || pageStyle['app-plus']);
218
+ (0, shared_1.extend)(pageStyle, pageStyle['app'] || pageStyle['app-plus'], pageStyle['web'] || pageStyle['h5']);
219
219
  }
220
- if (platform === 'app') {
220
+ else if (platform === 'app') {
221
221
  (0, shared_1.extend)(pageStyle, pageStyle['app'] || pageStyle['app-plus']);
222
222
  }
223
223
  else {
@@ -383,7 +383,7 @@ function normalizeFilepath(filepath) {
383
383
  }
384
384
  return filepath;
385
385
  }
386
- const platforms = ['h5', 'app', 'mp-', 'quickapp'];
386
+ const platforms = ['h5', 'app', 'mp-', 'quickapp', 'web'];
387
387
  function removePlatformStyle(pageStyle) {
388
388
  Object.keys(pageStyle).forEach((name) => {
389
389
  if (platforms.find((prefix) => name.startsWith(prefix))) {
@@ -42,6 +42,10 @@ function normalizeUniAppXAppPagesJson(jsonStr) {
42
42
  if (userPagesJson.tabBar) {
43
43
  pagesJson.tabBar = userPagesJson.tabBar;
44
44
  }
45
+ // condition
46
+ if (userPagesJson.condition) {
47
+ pagesJson.condition = userPagesJson.condition;
48
+ }
45
49
  return pagesJson;
46
50
  }
47
51
  exports.normalizeUniAppXAppPagesJson = normalizeUniAppXAppPagesJson;
@@ -40,5 +40,6 @@ declare const _default: {
40
40
  readonly 'prompt.run.devtools.quickapp-webview-huawei': "Huawei Quick App Devtools";
41
41
  readonly 'prompt.run.devtools.quickapp-webview-union': "Quick App Alliance Devtools";
42
42
  readonly 'uvue.unsupported': "uvue does not support {platform} platform";
43
+ readonly 'uvue.dev.watching.end.empty': "The compilation outcome remains unchanged; there is no need to synchronize.";
43
44
  };
44
45
  export default _default;
@@ -42,4 +42,5 @@ exports.default = {
42
42
  'prompt.run.devtools.quickapp-webview-huawei': 'Huawei Quick App Devtools',
43
43
  'prompt.run.devtools.quickapp-webview-union': 'Quick App Alliance Devtools',
44
44
  'uvue.unsupported': 'uvue does not support {platform} platform',
45
+ 'uvue.dev.watching.end.empty': 'The compilation outcome remains unchanged; there is no need to synchronize.',
45
46
  };
@@ -40,6 +40,7 @@ export declare const M: {
40
40
  readonly 'prompt.run.devtools.quickapp-webview-huawei': "华为快应用开发者工具";
41
41
  readonly 'prompt.run.devtools.quickapp-webview-union': "快应用联盟开发者工具";
42
42
  readonly 'uvue.unsupported': "uvue 暂不支持 {platform} 平台";
43
+ readonly 'uvue.dev.watching.end.empty': "本次代码变更,编译结果未发生变化,跳过同步手机端程序文件。";
43
44
  } | {
44
45
  readonly 'app.compiler.version': "Compiler version: {version}";
45
46
  readonly compiling: "Compiling...";
@@ -82,4 +83,5 @@ export declare const M: {
82
83
  readonly 'prompt.run.devtools.quickapp-webview-huawei': "Huawei Quick App Devtools";
83
84
  readonly 'prompt.run.devtools.quickapp-webview-union': "Quick App Alliance Devtools";
84
85
  readonly 'uvue.unsupported': "uvue does not support {platform} platform";
86
+ readonly 'uvue.dev.watching.end.empty': "The compilation outcome remains unchanged; there is no need to synchronize.";
85
87
  };
@@ -40,5 +40,6 @@ declare const _default: {
40
40
  readonly 'prompt.run.devtools.quickapp-webview-huawei': "华为快应用开发者工具";
41
41
  readonly 'prompt.run.devtools.quickapp-webview-union': "快应用联盟开发者工具";
42
42
  readonly 'uvue.unsupported': "uvue 暂不支持 {platform} 平台";
43
+ readonly 'uvue.dev.watching.end.empty': "本次代码变更,编译结果未发生变化,跳过同步手机端程序文件。";
43
44
  };
44
45
  export default _default;
@@ -42,4 +42,5 @@ exports.default = {
42
42
  'prompt.run.devtools.quickapp-webview-huawei': '华为快应用开发者工具',
43
43
  'prompt.run.devtools.quickapp-webview-union': '快应用联盟开发者工具',
44
44
  'uvue.unsupported': 'uvue 暂不支持 {platform} 平台',
45
+ 'uvue.dev.watching.end.empty': '本次代码变更,编译结果未发生变化,跳过同步手机端程序文件。',
45
46
  };
package/dist/platform.js CHANGED
@@ -5,6 +5,7 @@ const BUILT_IN_PLATFORMS = [
5
5
  'app',
6
6
  'app-plus',
7
7
  'h5',
8
+ 'web',
8
9
  'mp-360',
9
10
  'mp-alipay',
10
11
  'mp-baidu',
@@ -53,6 +53,7 @@ function initPreContext(platform, userPreContext, utsPlatform, isX) {
53
53
  DEFAULT_KEYS.forEach((key) => {
54
54
  defaultContext[key] = false;
55
55
  });
56
+ defaultContext.uniVersion = parseFloat(process.env.UNI_COMPILER_VERSION) || 0;
56
57
  defaultContext[normalizeKey(platform)] = true;
57
58
  vueContext.VUE3 = true;
58
59
  nvueContext.VUE3 = true;
package/dist/resolve.js CHANGED
@@ -19,7 +19,7 @@ exports.requireResolve = requireResolve;
19
19
  function resolveWithSymlinks(id, basedir) {
20
20
  return resolve_1.default.sync(id, {
21
21
  basedir,
22
- extensions: constants_1.extensions,
22
+ extensions: process.env.UNI_APP_X === 'true' ? constants_1.uni_app_x_extensions : constants_1.extensions,
23
23
  // necessary to work with pnpm
24
24
  preserveSymlinks: true,
25
25
  });
@@ -6,6 +6,6 @@ export * from './jsonJs';
6
6
  export * from './console';
7
7
  export * from './dynamicImportPolyfill';
8
8
  export * from './utsPlugin';
9
- export { assetPlugin, getAssetHash } from './vitejs/plugins/asset';
9
+ export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
10
10
  export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, } from './vitejs/plugins/css';
11
- export { generateCodeFrame } from './vitejs/utils';
11
+ export { generateCodeFrame, locToStartAndEnd } from './vitejs/utils';
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.generateCodeFrame = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.assetPlugin = void 0;
17
+ exports.locToStartAndEnd = exports.generateCodeFrame = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.parseAssets = exports.assetPlugin = void 0;
18
18
  __exportStar(require("./cssScoped"), exports);
19
19
  __exportStar(require("./copy"), exports);
20
20
  __exportStar(require("./inject"), exports);
@@ -25,6 +25,7 @@ __exportStar(require("./dynamicImportPolyfill"), exports);
25
25
  __exportStar(require("./utsPlugin"), exports);
26
26
  var asset_1 = require("./vitejs/plugins/asset");
27
27
  Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
28
+ Object.defineProperty(exports, "parseAssets", { enumerable: true, get: function () { return asset_1.parseAssets; } });
28
29
  Object.defineProperty(exports, "getAssetHash", { enumerable: true, get: function () { return asset_1.getAssetHash; } });
29
30
  var css_1 = require("./vitejs/plugins/css");
30
31
  Object.defineProperty(exports, "isCSSRequest", { enumerable: true, get: function () { return css_1.isCSSRequest; } });
@@ -35,3 +36,4 @@ Object.defineProperty(exports, "cssLangRE", { enumerable: true, get: function ()
35
36
  Object.defineProperty(exports, "commonjsProxyRE", { enumerable: true, get: function () { return css_1.commonjsProxyRE; } });
36
37
  var utils_1 = require("./vitejs/utils");
37
38
  Object.defineProperty(exports, "generateCodeFrame", { enumerable: true, get: function () { return utils_1.generateCodeFrame; } });
39
+ Object.defineProperty(exports, "locToStartAndEnd", { enumerable: true, get: function () { return utils_1.locToStartAndEnd; } });
@@ -7,7 +7,10 @@ export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>
7
7
  /**
8
8
  * Also supports loading plain strings with import text from './foo.txt?raw'
9
9
  */
10
- export declare function assetPlugin(config: ResolvedConfig): Plugin;
10
+ export declare function assetPlugin(config: ResolvedConfig, options?: {
11
+ isAppX: boolean;
12
+ }): Plugin;
13
+ export declare function parseAssets(config: ResolvedConfig, code: string): string;
11
14
  export declare function registerAssetToChunk(chunk: RenderedChunk, file: string): void;
12
15
  export declare function checkPublicFile(url: string, { publicDir }: ResolvedConfig): string | undefined;
13
16
  export declare function fileToUrl(id: string, config: ResolvedConfig, ctx: PluginContext, canInline?: boolean): string;
@@ -26,11 +26,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.urlToBuiltUrl = exports.getAssetHash = exports.assetFileNamesToFileName = exports.getAssetFilename = exports.fileToUrl = exports.checkPublicFile = exports.registerAssetToChunk = exports.assetPlugin = exports.chunkToEmittedAssetsMap = exports.assetUrlRE = void 0;
29
+ exports.urlToBuiltUrl = exports.getAssetHash = exports.assetFileNamesToFileName = exports.getAssetFilename = exports.fileToUrl = exports.checkPublicFile = exports.registerAssetToChunk = exports.parseAssets = exports.assetPlugin = exports.chunkToEmittedAssetsMap = exports.assetUrlRE = void 0;
30
30
  const path_1 = __importDefault(require("path"));
31
31
  const url_1 = require("url");
32
32
  const lite_1 = __importDefault(require("mime/lite"));
33
- const fs_1 = __importStar(require("fs"));
33
+ const fs_extra_1 = __importStar(require("fs-extra"));
34
34
  const magic_string_1 = __importDefault(require("magic-string"));
35
35
  const crypto_1 = require("crypto");
36
36
  const utils_1 = require("../utils");
@@ -38,9 +38,6 @@ const utils_2 = require("../../../../vite/utils/utils");
38
38
  const shared_1 = require("@vue/shared");
39
39
  const utils_3 = require("../../../../utils");
40
40
  exports.assetUrlRE = /__VITE_ASSET__([a-z\d]{8})__(?:\$_(.*?)__)?/g;
41
- // urls in JS must be quoted as strings, so when replacing them we need
42
- // a different regex
43
- const assetUrlQuotedRE = /"__VITE_ASSET__([a-z\d]{8})__(?:\$_(.*?)__)?"/g;
44
41
  const rawRE = /(\?|&)raw(?:&|$)/;
45
42
  const urlRE = /(\?|&)url(?:&|$)/;
46
43
  exports.chunkToEmittedAssetsMap = new WeakMap();
@@ -51,7 +48,7 @@ const emittedHashMap = new WeakMap();
51
48
  /**
52
49
  * Also supports loading plain strings with import text from './foo.txt?raw'
53
50
  */
54
- function assetPlugin(config) {
51
+ function assetPlugin(config, options) {
55
52
  // assetHashToFilenameMap initialization in buildStart causes getAssetFilename to return undefined
56
53
  assetHashToFilenameMap.set(config, new Map());
57
54
  return {
@@ -81,19 +78,39 @@ function assetPlugin(config) {
81
78
  if (rawRE.test(id)) {
82
79
  const file = checkPublicFile(id, config) || (0, utils_1.cleanUrl)(id);
83
80
  // raw query, read file and return as string
84
- return `export default ${JSON.stringify(await fs_1.promises.readFile(file, 'utf-8'))}`;
81
+ return `export default ${JSON.stringify(await fs_extra_1.promises.readFile(file, 'utf-8'))}`;
85
82
  }
86
83
  if (!config.assetsInclude((0, utils_1.cleanUrl)(id)) && !urlRE.test(id)) {
87
84
  return;
88
85
  }
89
86
  id = id.replace(urlRE, '$1').replace(/[\?&]$/, '');
90
- const url = await fileToUrl(id, config, this);
87
+ const url = await fileToUrl(id, config, options?.isAppX
88
+ ? {
89
+ emitFile(emittedFile) {
90
+ // 直接写入目标目录
91
+ fs_extra_1.default.outputFileSync(path_1.default.resolve(process.env.UNI_OUTPUT_DIR, emittedFile.fileName), emittedFile.source);
92
+ },
93
+ }
94
+ : this);
95
+ if (options?.isAppX) {
96
+ this.emitFile({
97
+ type: 'asset',
98
+ fileName: (0, utils_3.normalizeNodeModules)(path_1.default.relative(process.env.UNI_INPUT_DIR, id) + '.uts'),
99
+ source: `export default ${JSON.stringify(parseAssets(config, url))}`,
100
+ });
101
+ }
91
102
  return `export default ${JSON.stringify(url)}`;
92
103
  },
93
104
  renderChunk(code, chunk) {
94
105
  let match;
95
106
  let s;
96
- while ((match = assetUrlQuotedRE.exec(code))) {
107
+ exports.assetUrlRE.lastIndex = 0;
108
+ // Urls added with JS using e.g.
109
+ // imgElement.src = "__VITE_ASSET__5aa0ddc0__" are using quotes
110
+ // Urls added in CSS that is imported in JS end up like
111
+ // var inlined = ".inlined{color:green;background:url(__VITE_ASSET__5aa0ddc0__)}\n";
112
+ // In both cases, the wrapping should already be fine
113
+ while ((match = exports.assetUrlRE.exec(code))) {
97
114
  s = s || (s = new magic_string_1.default(code));
98
115
  const [full, hash, postfix = ''] = match;
99
116
  // some internal plugins may still need to emit chunks (e.g. worker) so
@@ -101,7 +118,7 @@ function assetPlugin(config) {
101
118
  const file = getAssetFilename(hash, config) || this.getFileName(hash);
102
119
  registerAssetToChunk(chunk, file);
103
120
  const outputFilepath = config.base + file + postfix;
104
- s.overwrite(match.index, match.index + full.length, JSON.stringify(outputFilepath));
121
+ s.overwrite(match.index, match.index + full.length, outputFilepath);
105
122
  }
106
123
  if (s) {
107
124
  return {
@@ -116,6 +133,25 @@ function assetPlugin(config) {
116
133
  };
117
134
  }
118
135
  exports.assetPlugin = assetPlugin;
136
+ function parseAssets(config, code) {
137
+ let match;
138
+ let s;
139
+ exports.assetUrlRE.lastIndex = 0;
140
+ while ((match = exports.assetUrlRE.exec(code))) {
141
+ s = s || (s = new magic_string_1.default(code));
142
+ const [full, hash, postfix = ''] = match;
143
+ // some internal plugins may still need to emit chunks (e.g. worker) so
144
+ // fallback to this.getFileName for that.
145
+ const file = getAssetFilename(hash, config);
146
+ const outputFilepath = config.base + file + postfix;
147
+ s.overwrite(match.index, match.index + full.length, outputFilepath);
148
+ }
149
+ if (s) {
150
+ return s.toString();
151
+ }
152
+ return code;
153
+ }
154
+ exports.parseAssets = parseAssets;
119
155
  function registerAssetToChunk(chunk, file) {
120
156
  let emitted = exports.chunkToEmittedAssetsMap.get(chunk);
121
157
  if (!emitted) {
@@ -132,7 +168,7 @@ function checkPublicFile(url, { publicDir }) {
132
168
  return;
133
169
  }
134
170
  const publicFile = path_1.default.join(publicDir, (0, utils_1.cleanUrl)(url));
135
- if (fs_1.default.existsSync(publicFile)) {
171
+ if (fs_extra_1.default.existsSync(publicFile)) {
136
172
  return publicFile;
137
173
  }
138
174
  else {
@@ -235,7 +271,7 @@ function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canI
235
271
  return cached;
236
272
  }
237
273
  const file = (0, utils_1.cleanUrl)(id);
238
- const content = fs_1.default.readFileSync(file);
274
+ const content = fs_extra_1.default.readFileSync(file);
239
275
  let url;
240
276
  if (canInline && content.length < Number(config.build.assetsInlineLimit)) {
241
277
  // base64 inlined as a string
@@ -19,6 +19,19 @@ export declare function posToNumber(source: string, pos: number | {
19
19
  line: number;
20
20
  column: number;
21
21
  }): number;
22
+ export declare function locToStartAndEnd(source: string, loc: {
23
+ start: {
24
+ line: number;
25
+ column: number;
26
+ };
27
+ end: {
28
+ line: number;
29
+ column: number;
30
+ };
31
+ }): {
32
+ start: number;
33
+ end: number;
34
+ };
22
35
  export declare function generateCodeFrame(source: string, start?: number | {
23
36
  line: number;
24
37
  column: number;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.combineSourcemaps = exports.processSrcSet = exports.generateCodeFrame = exports.posToNumber = exports.pad = exports.isObject = exports.asyncReplace = exports.multilineCommentsRE = exports.isDataUrl = exports.dataUrlRE = exports.isExternalUrl = exports.externalRE = exports.cleanUrl = exports.hashRE = exports.queryRE = exports.normalizePath = exports.isWindows = exports.deepImportRE = exports.bareImportRE = exports.slash = void 0;
6
+ exports.combineSourcemaps = exports.processSrcSet = exports.generateCodeFrame = exports.locToStartAndEnd = exports.posToNumber = exports.pad = exports.isObject = exports.asyncReplace = exports.multilineCommentsRE = exports.isDataUrl = exports.dataUrlRE = exports.isExternalUrl = exports.externalRE = exports.cleanUrl = exports.hashRE = exports.queryRE = exports.normalizePath = exports.isWindows = exports.deepImportRE = exports.bareImportRE = exports.slash = void 0;
7
7
  /**
8
8
  * https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts
9
9
  */
@@ -60,14 +60,23 @@ function posToNumber(source, pos) {
60
60
  if (typeof pos === 'number')
61
61
  return pos;
62
62
  const lines = source.split(splitRE);
63
- const { line, column } = pos;
63
+ return posToNumberByLines(lines, pos.line, pos.column);
64
+ }
65
+ exports.posToNumber = posToNumber;
66
+ function posToNumberByLines(lines, line, column) {
64
67
  let start = 0;
65
68
  for (let i = 0; i < line - 1; i++) {
66
69
  start += lines[i].length + 1;
67
70
  }
68
71
  return start + column;
69
72
  }
70
- exports.posToNumber = posToNumber;
73
+ function locToStartAndEnd(source, loc) {
74
+ const lines = source.split(splitRE);
75
+ const start = posToNumberByLines(lines, loc.start.line, loc.start.column);
76
+ const end = posToNumberByLines(lines, loc.end.line, loc.end.column);
77
+ return { start, end };
78
+ }
79
+ exports.locToStartAndEnd = locToStartAndEnd;
71
80
  function generateCodeFrame(source, start = 0, end) {
72
81
  start = posToNumber(source, start);
73
82
  end = end || start;
@@ -4,7 +4,9 @@ export interface UniViteFilterPluginOptions {
4
4
  resolvedConfig: ResolvedConfig;
5
5
  filter: (id: string) => boolean;
6
6
  }
7
- export declare function injectAssetPlugin(config: ResolvedConfig): void;
7
+ export declare function injectAssetPlugin(config: ResolvedConfig, options?: {
8
+ isAppX: boolean;
9
+ }): void;
8
10
  export declare function injectCssPlugin(config: ResolvedConfig): void;
9
11
  export declare function injectCssPostPlugin(config: ResolvedConfig, newCssPostPlugin: Plugin): void;
10
12
  export declare function replacePlugins(plugins: Plugin[], config: ResolvedConfig): void;
@@ -4,8 +4,8 @@ exports.insertBeforePlugin = exports.removePlugins = exports.replacePlugins = ex
4
4
  const shared_1 = require("@vue/shared");
5
5
  const asset_1 = require("../plugins/vitejs/plugins/asset");
6
6
  const css_1 = require("../plugins/vitejs/plugins/css");
7
- function injectAssetPlugin(config) {
8
- replacePlugins([(0, asset_1.assetPlugin)(config)], config);
7
+ function injectAssetPlugin(config, options) {
8
+ replacePlugins([(0, asset_1.assetPlugin)(config, options)], config);
9
9
  }
10
10
  exports.injectAssetPlugin = injectAssetPlugin;
11
11
  function injectCssPlugin(config) {
@@ -375,7 +375,8 @@ function getTestTemplate(test) {
375
375
  test = test.trim();
376
376
 
377
377
  // force single equals replacement
378
- test = test.replace(/([^=!])=([^=])/g, '$1==$2');
378
+ // fixed by xxxxxx 不替换,会影响 >= 等判断
379
+ // test = test.replace(/([^=!])=([^=])/g, '$1==$2');
379
380
  // fixed by xxxxxx
380
381
  test = test.replace(/-/g, '_')
381
382
  return new Function("context", "with (context||{}){ return ( " + test + " ); }");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3090020230826001",
3
+ "version": "3.0.0-alpha-3090020230909001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "@babel/core": "^7.21.3",
26
26
  "@babel/parser": "^7.16.4",
27
27
  "@babel/types": "^7.20.7",
28
- "@dcloudio/uni-i18n": "3.0.0-alpha-3090020230826001",
29
- "@dcloudio/uni-shared": "3.0.0-alpha-3090020230826001",
28
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3090020230909001",
29
+ "@dcloudio/uni-shared": "3.0.0-alpha-3090020230909001",
30
30
  "@intlify/core-base": "9.1.9",
31
31
  "@intlify/shared": "9.1.9",
32
32
  "@intlify/vue-devtools": "9.1.9",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
66
66
  "devDependencies": {
67
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-3090020230826001",
67
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-3090020230909001",
68
68
  "@types/babel__core": "^7.1.19",
69
69
  "@types/debug": "^4.1.7",
70
70
  "@types/estree": "^0.0.51",