@dcloudio/uni-cli-shared 3.0.0-alpha-3060020220901002 → 3.0.0-alpha-3060120220907003

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.
@@ -18,18 +18,18 @@ function initDefine(stringifyBoolean = false) {
18
18
  'process.env.UNI_APP_VERSION_NAME': JSON.stringify(manifestJson.versionName || ''),
19
19
  'process.env.UNI_APP_VERSION_CODE': JSON.stringify(manifestJson.versionCode || ''),
20
20
  'process.env.UNI_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
21
- 'process.env.UNI_SUB_PLATFORM': JSON.stringify(process.env.UNI_SUB_PLATFORM),
22
- 'process.env.UNI_MP_PLUGIN': JSON.stringify(process.env.UNI_MP_PLUGIN),
23
- 'process.env.UNI_SUBPACKAGE': JSON.stringify(process.env.UNI_SUBPACKAGE),
24
- 'process.env.UNI_COMPILER_VERSION': JSON.stringify(process.env.UNI_COMPILER_VERSION),
21
+ 'process.env.UNI_SUB_PLATFORM': JSON.stringify(process.env.UNI_SUB_PLATFORM || ''),
22
+ 'process.env.UNI_MP_PLUGIN': JSON.stringify(process.env.UNI_MP_PLUGIN || ''),
23
+ 'process.env.UNI_SUBPACKAGE': JSON.stringify(process.env.UNI_SUBPACKAGE || ''),
24
+ 'process.env.UNI_COMPILER_VERSION': JSON.stringify(process.env.UNI_COMPILER_VERSION || ''),
25
25
  'process.env.RUN_BY_HBUILDERX': stringifyBoolean
26
26
  ? JSON.stringify(isRunByHBuilderX)
27
27
  : isRunByHBuilderX,
28
- 'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT),
29
- 'process.env.UNI_CLOUD_PROVIDER': JSON.stringify(process.env.UNI_CLOUD_PROVIDER),
30
- 'process.env.UNICLOUD_DEBUG': JSON.stringify(process.env.UNICLOUD_DEBUG),
28
+ 'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT || ''),
29
+ 'process.env.UNI_CLOUD_PROVIDER': JSON.stringify(process.env.UNI_CLOUD_PROVIDER || ''),
30
+ 'process.env.UNICLOUD_DEBUG': JSON.stringify(process.env.UNICLOUD_DEBUG || ''),
31
31
  // 兼容旧版本
32
- 'process.env.VUE_APP_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
32
+ 'process.env.VUE_APP_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM || ''),
33
33
  };
34
34
  }
35
35
  exports.initDefine = initDefine;
@@ -9,7 +9,7 @@ const libDir = path_1.default.resolve(__dirname, '../../lib');
9
9
  function initAppProvide() {
10
10
  const cryptoDefine = [path_1.default.join(libDir, 'crypto.js'), 'default'];
11
11
  return {
12
- __f__: ['@dcloudio/uni-shared', 'formatAppLog'],
12
+ __f__: ['@dcloudio/uni-app', 'formatAppLog'],
13
13
  crypto: cryptoDefine,
14
14
  'window.crypto': cryptoDefine,
15
15
  'global.crypto': cryptoDefine,
@@ -20,7 +20,7 @@ function initAppProvide() {
20
20
  exports.initAppProvide = initAppProvide;
21
21
  function initH5Provide() {
22
22
  return {
23
- __f__: ['@dcloudio/uni-shared', 'formatH5Log'],
23
+ __f__: ['@dcloudio/uni-app', 'formatH5Log'],
24
24
  };
25
25
  }
26
26
  exports.initH5Provide = initH5Provide;
package/dist/hbx/log.js CHANGED
@@ -87,7 +87,7 @@ function buildErrorMessage(err, args = [], includeStack = true) {
87
87
  constants_1.EXTNAME_VUE_RE.test(err.id)) {
88
88
  try {
89
89
  const ast = (0, ast_1.parseVue)(fs_1.default.readFileSync(err.id, 'utf8'), []);
90
- const scriptNode = ast.children.find((node) => node.type === 1 /* ELEMENT */ && node.tag === 'script');
90
+ const scriptNode = ast.children.find((node) => node.type === 1 /* NodeTypes.ELEMENT */ && node.tag === 'script');
91
91
  if (scriptNode) {
92
92
  const scriptLoc = scriptNode.loc;
93
93
  args.push(picocolors_1.default.yellow(pad((0, utils_2.generateCodeFrame)(scriptLoc.source, err.loc))));
package/dist/i18n.d.ts CHANGED
@@ -7,4 +7,4 @@ export declare const initI18nOptionsOnce: typeof initI18nOptions;
7
7
  export declare function isUniAppLocaleFile(filepath: string): boolean;
8
8
  export declare function getLocaleFiles(cwd: string): string[];
9
9
  export declare function initLocales(dir: string, withMessages?: boolean): Record<string, Record<string, string>>;
10
- export declare function resolveI18nLocale(platfrom: UniApp.PLATFORM, locales: string[], locale?: string): string;
10
+ export declare function resolveI18nLocale(platform: UniApp.PLATFORM, locales: string[], locale?: string): string;
package/dist/i18n.js CHANGED
@@ -77,12 +77,12 @@ function initLocales(dir, withMessages = true) {
77
77
  }, {});
78
78
  }
79
79
  exports.initLocales = initLocales;
80
- function resolveI18nLocale(platfrom, locales, locale) {
80
+ function resolveI18nLocale(platform, locales, locale) {
81
81
  if (locale && locales.includes(locale)) {
82
82
  return locale;
83
83
  }
84
84
  const defaultLocales = ['zh-Hans', 'zh-Hant'];
85
- if (platfrom === 'app' || platfrom === 'h5') {
85
+ if (platform === 'app' || platform === 'h5') {
86
86
  defaultLocales.unshift('en');
87
87
  }
88
88
  else {
@@ -21,6 +21,7 @@ export declare function normalizeNetworkTimeout(networkTimeout?: Partial<typeof
21
21
  export declare function getUniStatistics(inputDir: string, platform: UniApp.PLATFORM): any;
22
22
  export declare function isEnableUniPushV1(inputDir: string, platform: UniApp.PLATFORM): boolean;
23
23
  export declare function isEnableUniPushV2(inputDir: string, platform: UniApp.PLATFORM): boolean;
24
+ export declare function isEnableSecureNetwork(inputDir: string, platform: UniApp.PLATFORM): boolean;
24
25
  export declare function isUniPushOffline(inputDir: string): boolean;
25
26
  export declare function getRouterOptions(manifestJson: Record<string, any>): {
26
27
  mode?: 'history' | 'hash';
@@ -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.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
6
+ exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const shared_1 = require("@vue/shared");
@@ -72,6 +72,15 @@ function isEnableUniPushV2(inputDir, platform) {
72
72
  return ((_g = (_f = manifest[platform]) === null || _f === void 0 ? void 0 : _f.unipush) === null || _g === void 0 ? void 0 : _g.enable) === true;
73
73
  }
74
74
  exports.isEnableUniPushV2 = isEnableUniPushV2;
75
+ function isEnableSecureNetwork(inputDir, platform) {
76
+ var _a, _b;
77
+ const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
78
+ if (platform === 'app') {
79
+ return false; // 暂未支持app
80
+ }
81
+ return ((_b = (_a = manifest[platform]) === null || _a === void 0 ? void 0 : _a.secureNetwork) === null || _b === void 0 ? void 0 : _b.enable) === true;
82
+ }
83
+ exports.isEnableSecureNetwork = isEnableSecureNetwork;
75
84
  function isUniPushOffline(inputDir) {
76
85
  var _a, _b, _c, _d, _e;
77
86
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
@@ -1,2 +1,3 @@
1
1
  export declare function registerPlatform(platform: string): void;
2
2
  export declare function getPlatforms(): string[];
3
+ export declare function getPlatformDir(): string;
package/dist/platform.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPlatforms = exports.registerPlatform = void 0;
3
+ exports.getPlatformDir = exports.getPlatforms = exports.registerPlatform = void 0;
4
4
  const BUILT_IN_PLATFORMS = [
5
5
  'app',
6
6
  'app-plus',
@@ -29,3 +29,10 @@ function getPlatforms() {
29
29
  return platforms;
30
30
  }
31
31
  exports.getPlatforms = getPlatforms;
32
+ function getPlatformDir() {
33
+ if (process.env.UNI_PLATFORM === 'app' && process.env.UNI_APP_PLATFORM) {
34
+ return process.env.UNI_PLATFORM + '-' + process.env.UNI_APP_PLATFORM;
35
+ }
36
+ return process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM;
37
+ }
38
+ exports.getPlatformDir = getPlatformDir;
@@ -5,7 +5,7 @@ export interface UniAppCssProcessorOptions {
5
5
  unitPrecision?: number;
6
6
  }
7
7
  declare const uniapp: {
8
- (opts?: UniAppCssProcessorOptions | undefined): Plugin;
8
+ (opts?: UniAppCssProcessorOptions): Plugin;
9
9
  postcss: boolean;
10
10
  };
11
11
  export default uniapp;
package/dist/resolve.js CHANGED
@@ -121,10 +121,6 @@ function resolveUtsModule(id, importer, platform) {
121
121
  return;
122
122
  }
123
123
  const platformDir = path_1.default.resolve(id, parentDir === 'uni_modules' ? 'utssdk' : '', platform);
124
- // App平台仅支持 uts
125
- if (platform === 'app-android') {
126
- return resolveUtsFile(platformDir, ['.uts']);
127
- }
128
124
  return resolveUtsFile(platformDir);
129
125
  }
130
126
  }
package/dist/utils.d.ts CHANGED
@@ -15,4 +15,4 @@ export declare function pathToGlob(pathString: string, glob: string, options?: {
15
15
  windows?: boolean;
16
16
  escape?: boolean;
17
17
  }): string;
18
- export declare function resolveSourceMapPath(dir: string, platform: UniApp.PLATFORM): string;
18
+ export declare function resolveSourceMapPath(): string;
package/dist/utils.js CHANGED
@@ -11,6 +11,7 @@ const shared_1 = require("@vue/shared");
11
11
  var hash_sum_1 = require("hash-sum");
12
12
  Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return __importDefault(hash_sum_1).default; } });
13
13
  const constants_1 = require("./constants");
14
+ const platform_1 = require("./platform");
14
15
  try {
15
16
  exports.isRunningWithYarnPnp = Boolean(require('pnpapi'));
16
17
  }
@@ -21,7 +22,7 @@ function normalizePath(id) {
21
22
  }
22
23
  exports.normalizePath = normalizePath;
23
24
  function checkElementNodeTag(node, tag) {
24
- return !!node && node.type === 1 /* ELEMENT */ && node.tag === tag;
25
+ return !!node && node.type === 1 /* NodeTypes.ELEMENT */ && node.tag === tag;
25
26
  }
26
27
  exports.checkElementNodeTag = checkElementNodeTag;
27
28
  function normalizeIdentifier(str) {
@@ -86,7 +87,7 @@ function pathToGlob(pathString, glob, options = {}) {
86
87
  return path_1.default.posix.join(safeStr, glob);
87
88
  }
88
89
  exports.pathToGlob = pathToGlob;
89
- function resolveSourceMapPath(dir, platform) {
90
- return path_1.default.resolve(dir, '../.sourcemap/' + platform);
90
+ function resolveSourceMapPath() {
91
+ return path_1.default.resolve(process.env.UNI_OUTPUT_DIR, '../.sourcemap/' + (0, platform_1.getPlatformDir)());
91
92
  }
92
93
  exports.resolveSourceMapPath = resolveSourceMapPath;
@@ -201,13 +201,26 @@ function assetFileNamesToFileName(assetFileNames, file, contentHash, content) {
201
201
  case '[hash]':
202
202
  return hash;
203
203
  case '[name]':
204
- return name;
204
+ return sanitizeFileName(name);
205
205
  }
206
206
  throw new Error(`invalid placeholder ${placeholder} in assetFileNames "${assetFileNames}"`);
207
207
  });
208
208
  return fileName;
209
209
  }
210
210
  exports.assetFileNamesToFileName = assetFileNamesToFileName;
211
+ // taken from https://github.com/rollup/rollup/blob/a8647dac0fe46c86183be8596ef7de25bc5b4e4b/src/utils/sanitizeFileName.ts
212
+ // https://datatracker.ietf.org/doc/html/rfc2396
213
+ // eslint-disable-next-line no-control-regex
214
+ const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g;
215
+ const DRIVE_LETTER_REGEX = /^[a-z]:/i;
216
+ function sanitizeFileName(name) {
217
+ const match = DRIVE_LETTER_REGEX.exec(name);
218
+ const driveLetter = match ? match[0] : '';
219
+ // A `:` is only allowed as part of a windows drive letter (ex: C:\foo)
220
+ // Otherwise, avoid them because they can refer to NTFS alternate data streams.
221
+ return (driveLetter +
222
+ name.substring(driveLetter.length).replace(INVALID_CHAR_REGEX, '_'));
223
+ }
211
224
  /**
212
225
  * Register an asset to be emitted as part of the bundle (if necessary)
213
226
  * and returns the resolved public URL
@@ -281,17 +281,17 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
281
281
  let opts = (preprocessorOptions && preprocessorOptions[lang]) || {};
282
282
  // support @import from node dependencies by default
283
283
  switch (lang) {
284
- case "scss" /* scss */:
285
- case "sass" /* sass */:
284
+ case "scss" /* PreprocessLang.scss */:
285
+ case "sass" /* PreprocessLang.sass */:
286
286
  opts = {
287
287
  includePaths: ['node_modules'],
288
288
  alias: config.resolve.alias,
289
289
  ...opts,
290
290
  };
291
291
  break;
292
- case "less" /* less */:
293
- case "styl" /* styl */:
294
- case "stylus" /* stylus */:
292
+ case "less" /* PreprocessLang.less */:
293
+ case "styl" /* PreprocessLang.styl */:
294
+ case "stylus" /* PreprocessLang.stylus */:
295
295
  opts = {
296
296
  paths: ['node_modules'],
297
297
  alias: config.resolve.alias,
@@ -305,6 +305,10 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
305
305
  if (preprocessResult.errors.length) {
306
306
  throw preprocessResult.errors[0];
307
307
  }
308
+ // TODO 升级
309
+ // if (preprocessResult.error) {
310
+ // throw preprocessResult.error
311
+ // }
308
312
  code = preprocessResult.code;
309
313
  preprocessorMap = combineSourcemapsIfExists(opts.filename, preprocessResult.map, preprocessResult.additionalMap);
310
314
  if (preprocessResult.deps) {
@@ -363,69 +367,81 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
363
367
  map: preprocessorMap,
364
368
  };
365
369
  }
366
- // postcss is an unbundled dep and should be lazy imported
367
- const postcssResult = await (await Promise.resolve().then(() => __importStar(require('postcss'))))
368
- .default(postcssPlugins)
369
- .process(code, {
370
- ...postcssOptions,
371
- to: id,
372
- from: id,
373
- ...(devSourcemap
374
- ? {
375
- map: {
376
- inline: false,
377
- annotation: false,
378
- // postcss may return virtual files
379
- // we cannot obtain content of them, so this needs to be enabled
380
- sourcesContent: true,
381
- // when "prev: preprocessorMap", the result map may include duplicate filename in `postcssResult.map.sources`
382
- // prev: preprocessorMap,
383
- },
384
- }
385
- : {}),
386
- });
387
- // record CSS dependencies from @imports
388
- for (const message of postcssResult.messages) {
389
- if (message.type === 'dependency') {
390
- deps.add((0, utils_1.normalizePath)(message.file));
391
- }
392
- else if (message.type === 'dir-dependency') {
393
- // https://github.com/postcss/postcss/blob/main/docs/guidelines/plugin.md#3-dependencies
394
- const { dir, glob: globPattern = '**' } = message;
395
- const pattern = (0, utils_1.normalizePath)(path_1.default.resolve(path_1.default.dirname(id), dir)) + `/` + globPattern;
396
- const files = fast_glob_1.default.sync(pattern, {
397
- ignore: ['**/node_modules/**'],
398
- });
399
- for (let i = 0; i < files.length; i++) {
400
- deps.add(files[i]);
370
+ let postcssResult;
371
+ try {
372
+ // postcss is an unbundled dep and should be lazy imported
373
+ postcssResult = await (await Promise.resolve().then(() => __importStar(require('postcss'))))
374
+ .default(postcssPlugins)
375
+ .process(code, {
376
+ ...postcssOptions,
377
+ to: id,
378
+ from: id,
379
+ ...(devSourcemap
380
+ ? {
381
+ map: {
382
+ inline: false,
383
+ annotation: false,
384
+ // postcss may return virtual files
385
+ // we cannot obtain content of them, so this needs to be enabled
386
+ sourcesContent: true,
387
+ // when "prev: preprocessorMap", the result map may include duplicate filename in `postcssResult.map.sources`
388
+ // prev: preprocessorMap,
389
+ },
390
+ }
391
+ : {}),
392
+ });
393
+ // record CSS dependencies from @imports
394
+ for (const message of postcssResult.messages) {
395
+ if (message.type === 'dependency') {
396
+ deps.add((0, utils_1.normalizePath)(message.file));
401
397
  }
402
- if (server) {
403
- // register glob importers so we can trigger updates on file add/remove
404
- if (!(id in server._globImporters)) {
398
+ else if (message.type === 'dir-dependency') {
399
+ // https://github.com/postcss/postcss/blob/main/docs/guidelines/plugin.md#3-dependencies
400
+ const { dir, glob: globPattern = '**' } = message;
401
+ const pattern = (0, utils_1.normalizePath)(path_1.default.resolve(path_1.default.dirname(id), dir)) + `/` + globPattern;
402
+ const files = fast_glob_1.default.sync(pattern, {
403
+ ignore: ['**/node_modules/**'],
404
+ });
405
+ for (let i = 0; i < files.length; i++) {
406
+ deps.add(files[i]);
407
+ }
408
+ if (server) {
409
+ // register glob importers so we can trigger updates on file add/remove
410
+ if (!(id in server._globImporters)) {
411
+ ;
412
+ server._globImporters[id] = {
413
+ module: server.moduleGraph.getModuleById(id),
414
+ importGlobs: [],
415
+ };
416
+ }
405
417
  ;
406
- server._globImporters[id] = {
407
- module: server.moduleGraph.getModuleById(id),
408
- importGlobs: [],
409
- };
418
+ server._globImporters[id].importGlobs.push({
419
+ base: config.root,
420
+ pattern,
421
+ });
410
422
  }
411
- ;
412
- server._globImporters[id].importGlobs.push({
413
- base: config.root,
414
- pattern,
415
- });
416
423
  }
417
- }
418
- else if (message.type === 'warning') {
419
- let msg = `[vite:css] ${message.text}`;
420
- if (message.line && message.column) {
421
- msg += `\n${(0, utils_1.generateCodeFrame)(code, {
422
- line: message.line,
423
- column: message.column,
424
- })}`;
424
+ else if (message.type === 'warning') {
425
+ let msg = `[vite:css] ${message.text}`;
426
+ if (message.line && message.column) {
427
+ msg += `\n${(0, utils_1.generateCodeFrame)(code, {
428
+ line: message.line,
429
+ column: message.column,
430
+ })}`;
431
+ }
432
+ config.logger.warn(picocolors_1.default.yellow(msg));
425
433
  }
426
- config.logger.warn(picocolors_1.default.yellow(msg));
427
434
  }
428
435
  }
436
+ catch (e) {
437
+ e.message = `[postcss] ${e.message}`;
438
+ e.code = code;
439
+ e.loc = {
440
+ column: e.column,
441
+ line: e.line,
442
+ };
443
+ throw e;
444
+ }
429
445
  if (!devSourcemap) {
430
446
  return {
431
447
  ast: postcssResult,
@@ -696,7 +712,7 @@ function loadPreprocessor(lang, root) {
696
712
  }
697
713
  // .scss/.sass processor
698
714
  const scss = async (source, root, options, resolvers, isNVue) => {
699
- const render = loadPreprocessor("sass" /* sass */, root).render;
715
+ const render = loadPreprocessor("sass" /* PreprocessLang.sass */, root).render;
700
716
  const internalImporter = (url, importer, done) => {
701
717
  resolvers.sass(url, importer).then((resolved) => {
702
718
  if (resolved) {
@@ -825,7 +841,7 @@ async function rebaseUrls(file, rootFile, alias, isNVue = false) {
825
841
  }
826
842
  // .less
827
843
  const less = async (source, root, options, resolvers, isNVue) => {
828
- const nodeLess = loadPreprocessor("less" /* less */, root);
844
+ const nodeLess = loadPreprocessor("less" /* PreprocessLang.less */, root);
829
845
  const viteResolverPlugin = createViteLessPlugin(nodeLess, options.filename, options.alias, resolvers, isNVue);
830
846
  const { content, map: additionalMap } = await getSource(source, options.filename, options.additionalData, options.enableSourcemap);
831
847
  let result;
@@ -917,7 +933,7 @@ function createViteLessPlugin(less, rootFile, alias, resolvers, isNVue) {
917
933
  // .styl
918
934
  const styl = async (source, root, options) => {
919
935
  var _a;
920
- const nodeStylus = loadPreprocessor("stylus" /* stylus */, root);
936
+ const nodeStylus = loadPreprocessor("stylus" /* PreprocessLang.stylus */, root);
921
937
  // Get source with preprocessor options.additionalData. Make sure a new line separator
922
938
  // is added to avoid any render error, as added stylus content may not have semi-colon separators
923
939
  const { content, map: additionalMap } = await getSource(source, options.filename, options.additionalData, options.enableSourcemap, '\n');
@@ -986,11 +1002,11 @@ async function getSource(source, filename, additionalData, enableSourcemap, sep
986
1002
  };
987
1003
  }
988
1004
  const preProcessors = Object.freeze({
989
- ["less" /* less */]: less,
990
- ["sass" /* sass */]: sass,
991
- ["scss" /* scss */]: scss,
992
- ["styl" /* styl */]: styl,
993
- ["stylus" /* stylus */]: styl,
1005
+ ["less" /* PreprocessLang.less */]: less,
1006
+ ["sass" /* PreprocessLang.sass */]: sass,
1007
+ ["scss" /* PreprocessLang.scss */]: scss,
1008
+ ["styl" /* PreprocessLang.styl */]: styl,
1009
+ ["stylus" /* PreprocessLang.stylus */]: styl,
994
1010
  });
995
1011
  function isPreProcessor(lang) {
996
1012
  return lang && lang in preProcessors;
@@ -64,7 +64,7 @@ function parseVue(code, errors) {
64
64
  return (0, compiler_dom_1.parse)(code, {
65
65
  isNativeTag: () => true,
66
66
  isPreTag: () => true,
67
- getTextMode: () => 0 /* DATA */,
67
+ getTextMode: () => 0 /* TextModes.DATA */,
68
68
  onError: (e) => {
69
69
  errors.push(e);
70
70
  },
@@ -72,18 +72,18 @@ function parseVue(code, errors) {
72
72
  }
73
73
  exports.parseVue = parseVue;
74
74
  function isElementNode(node) {
75
- return node.type === 1 /* ELEMENT */;
75
+ return node.type === 1 /* NodeTypes.ELEMENT */;
76
76
  }
77
77
  exports.isElementNode = isElementNode;
78
78
  function isAttributeNode(node) {
79
- return node.type === 6 /* ATTRIBUTE */;
79
+ return node.type === 6 /* NodeTypes.ATTRIBUTE */;
80
80
  }
81
81
  exports.isAttributeNode = isAttributeNode;
82
82
  function isDirectiveNode(node) {
83
- return node.type === 7 /* DIRECTIVE */;
83
+ return node.type === 7 /* NodeTypes.DIRECTIVE */;
84
84
  }
85
85
  exports.isDirectiveNode = isDirectiveNode;
86
86
  function isSimpleExpressionNode(node) {
87
- return node.type === 4 /* SIMPLE_EXPRESSION */;
87
+ return node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */;
88
88
  }
89
89
  exports.isSimpleExpressionNode = isSimpleExpressionNode;
package/dist/vue/parse.js CHANGED
@@ -28,7 +28,7 @@ function parseVueCode(code, isNVue = false) {
28
28
  code = parseWxsCode(wxsNodes, code);
29
29
  // add watch
30
30
  for (const wxsNode of wxsNodes) {
31
- const srcProp = wxsNode.props.find((prop) => prop.type === 6 /* ATTRIBUTE */ && prop.name === 'src');
31
+ const srcProp = wxsNode.props.find((prop) => prop.type === 6 /* NodeTypes.ATTRIBUTE */ && prop.name === 'src');
32
32
  if (srcProp && srcProp.value) {
33
33
  files.push(srcProp.value.content);
34
34
  }
@@ -44,10 +44,10 @@ function traverseNode(node, blockNodes) {
44
44
  if ((0, ast_1.isElementNode)(node) && node.tag === 'block') {
45
45
  blockNodes.push(node);
46
46
  }
47
- if (node.type === 10 /* IF_BRANCH */ ||
48
- node.type === 11 /* FOR */ ||
49
- node.type === 1 /* ELEMENT */ ||
50
- node.type === 0 /* ROOT */) {
47
+ if (node.type === 10 /* NodeTypes.IF_BRANCH */ ||
48
+ node.type === 11 /* NodeTypes.FOR */ ||
49
+ node.type === 1 /* NodeTypes.ELEMENT */ ||
50
+ node.type === 0 /* NodeTypes.ROOT */) {
51
51
  traverseChildren(node, blockNodes);
52
52
  }
53
53
  }
@@ -73,10 +73,10 @@ function parseBlockNode(code, blocks) {
73
73
  return magicString.toString();
74
74
  }
75
75
  function parseWxsNodes(ast) {
76
- return ast.children.filter((node) => node.type === 1 /* ELEMENT */ &&
76
+ return ast.children.filter((node) => node.type === 1 /* NodeTypes.ELEMENT */ &&
77
77
  node.tag === 'script' &&
78
78
  node.props.find((prop) => prop.name === 'lang' &&
79
- prop.type === 6 /* ATTRIBUTE */ &&
79
+ prop.type === 6 /* NodeTypes.ATTRIBUTE */ &&
80
80
  prop.value &&
81
81
  WXS_ATTRS.includes(prop.value.content)));
82
82
  }
@@ -51,7 +51,7 @@ exports.createAssetUrlTransformWithOptions = createAssetUrlTransformWithOptions;
51
51
  * ```
52
52
  */
53
53
  const transformAssetUrl = (node, context, options = exports.defaultAssetUrlOptions) => {
54
- if (node.type === 1 /* ELEMENT */) {
54
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
55
55
  if (!node.props.length) {
56
56
  return;
57
57
  }
@@ -69,7 +69,7 @@ const transformAssetUrl = (node, context, options = exports.defaultAssetUrlOptio
69
69
  // - 非 static 资源转换为 import
70
70
  const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
71
71
  node.props.forEach((attr, index) => {
72
- if (attr.type !== 6 /* ATTRIBUTE */ ||
72
+ if (attr.type !== 6 /* NodeTypes.ATTRIBUTE */ ||
73
73
  !assetAttrs.includes(attr.name) ||
74
74
  !attr.value ||
75
75
  (0, templateUtils_1.isExternalUrl)(attr.value.content) ||
@@ -104,7 +104,7 @@ const transformAssetUrl = (node, context, options = exports.defaultAssetUrlOptio
104
104
  // absolute url (e.g. webpack file-loader)
105
105
  const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
106
106
  node.props[index] = {
107
- type: 7 /* DIRECTIVE */,
107
+ type: 7 /* NodeTypes.DIRECTIVE */,
108
108
  name: 'bind',
109
109
  arg: (0, compiler_core_1.createSimpleExpression)(attr.name, true, attr.loc),
110
110
  exp,
@@ -126,7 +126,7 @@ function getImportsExpressionExp(path, hash, loc, context) {
126
126
  }
127
127
  else {
128
128
  name = `_imports_${context.imports.length}`;
129
- exp = (0, compiler_core_1.createSimpleExpression)(name, false, loc, 2 /* CAN_HOIST */);
129
+ exp = (0, compiler_core_1.createSimpleExpression)(name, false, loc, 2 /* ConstantTypes.CAN_HOIST */);
130
130
  context.imports.push({ exp, path });
131
131
  }
132
132
  if (!hash) {
@@ -135,16 +135,16 @@ function getImportsExpressionExp(path, hash, loc, context) {
135
135
  const hashExp = `${name} + '${hash}'`;
136
136
  const existingHoistIndex = context.hoists.findIndex((h) => {
137
137
  return (h &&
138
- h.type === 4 /* SIMPLE_EXPRESSION */ &&
138
+ h.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
139
139
  !h.isStatic &&
140
140
  h.content === hashExp);
141
141
  });
142
142
  if (existingHoistIndex > -1) {
143
- return (0, compiler_core_1.createSimpleExpression)(`_hoisted_${existingHoistIndex + 1}`, false, loc, 2 /* CAN_HOIST */);
143
+ return (0, compiler_core_1.createSimpleExpression)(`_hoisted_${existingHoistIndex + 1}`, false, loc, 2 /* ConstantTypes.CAN_HOIST */);
144
144
  }
145
- return context.hoist((0, compiler_core_1.createSimpleExpression)(hashExp, false, loc, 2 /* CAN_HOIST */));
145
+ return context.hoist((0, compiler_core_1.createSimpleExpression)(hashExp, false, loc, 2 /* ConstantTypes.CAN_HOIST */));
146
146
  }
147
147
  else {
148
- return (0, compiler_core_1.createSimpleExpression)(`''`, false, loc, 2 /* CAN_HOIST */);
148
+ return (0, compiler_core_1.createSimpleExpression)(`''`, false, loc, 2 /* ConstantTypes.CAN_HOIST */);
149
149
  }
150
150
  }
@@ -16,10 +16,10 @@ const createSrcsetTransformWithOptions = (options) => {
16
16
  };
17
17
  exports.createSrcsetTransformWithOptions = createSrcsetTransformWithOptions;
18
18
  const transformSrcset = (node, context, options = templateTransformAssetUrl_1.defaultAssetUrlOptions) => {
19
- if (node.type === 1 /* ELEMENT */) {
19
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
20
20
  if (srcsetTags.includes(node.tag) && node.props.length) {
21
21
  node.props.forEach((attr, index) => {
22
- if (attr.name === 'srcset' && attr.type === 6 /* ATTRIBUTE */) {
22
+ if (attr.name === 'srcset' && attr.type === 6 /* NodeTypes.ATTRIBUTE */) {
23
23
  if (!attr.value)
24
24
  return;
25
25
  const value = attr.value.content;
@@ -80,17 +80,17 @@ const transformSrcset = (node, context, options = templateTransformAssetUrl_1.de
80
80
  if (path) {
81
81
  const existingImportsIndex = context.imports.findIndex((i) => i.path === path);
82
82
  if (existingImportsIndex > -1) {
83
- exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${existingImportsIndex}`, false, attr.loc, 2 /* CAN_HOIST */);
83
+ exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${existingImportsIndex}`, false, attr.loc, 2 /* ConstantTypes.CAN_HOIST */);
84
84
  }
85
85
  else {
86
- exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${context.imports.length}`, false, attr.loc, 2 /* CAN_HOIST */);
86
+ exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${context.imports.length}`, false, attr.loc, 2 /* ConstantTypes.CAN_HOIST */);
87
87
  context.imports.push({ exp, path });
88
88
  }
89
89
  compoundExpression.children.push(exp);
90
90
  }
91
91
  }
92
92
  else {
93
- const exp = (0, compiler_core_1.createSimpleExpression)(`"${url}"`, false, attr.loc, 2 /* CAN_HOIST */);
93
+ const exp = (0, compiler_core_1.createSimpleExpression)(`"${url}"`, false, attr.loc, 2 /* ConstantTypes.CAN_HOIST */);
94
94
  compoundExpression.children.push(exp);
95
95
  }
96
96
  const isNotLast = imageCandidates.length - 1 > index;
@@ -105,9 +105,9 @@ const transformSrcset = (node, context, options = templateTransformAssetUrl_1.de
105
105
  }
106
106
  });
107
107
  const hoisted = context.hoist(compoundExpression);
108
- hoisted.constType = 2 /* CAN_HOIST */;
108
+ hoisted.constType = 2 /* ConstantTypes.CAN_HOIST */;
109
109
  node.props[index] = {
110
- type: 7 /* DIRECTIVE */,
110
+ type: 7 /* NodeTypes.DIRECTIVE */,
111
111
  name: 'bind',
112
112
  arg: (0, compiler_core_1.createSimpleExpression)('srcset', true, attr.loc),
113
113
  exp: hoisted,
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTransformComponentLink = void 0;
4
4
  const compiler_core_1 = require("@vue/compiler-core");
5
5
  const utils_1 = require("../utils");
6
- function createTransformComponentLink(name, type = 7 /* DIRECTIVE */) {
6
+ function createTransformComponentLink(name, type = 7 /* NodeTypes.DIRECTIVE */) {
7
7
  return function transformComponentLink(node, context) {
8
8
  if (!(0, utils_1.isUserComponent)(node, context)) {
9
9
  return;
10
10
  }
11
- if (type === 7 /* DIRECTIVE */) {
11
+ if (type === 7 /* NodeTypes.DIRECTIVE */) {
12
12
  node.props.push({
13
- type: 7 /* DIRECTIVE */,
13
+ type: 7 /* NodeTypes.DIRECTIVE */,
14
14
  name: 'on',
15
15
  modifiers: [],
16
16
  loc: compiler_core_1.locStub,
@@ -16,7 +16,7 @@ function addVueRef(node, context) {
16
16
  if (!refProp) {
17
17
  return;
18
18
  }
19
- if (refProp.type === 6 /* ATTRIBUTE */) {
19
+ if (refProp.type === 6 /* NodeTypes.ATTRIBUTE */) {
20
20
  refProp.name = 'u-' + utils_1.VUE_REF;
21
21
  }
22
22
  else {
@@ -27,7 +27,7 @@ function createTransformOn(baseTransformOn, { match } = {
27
27
  }
28
28
  const value = res.props[0].value;
29
29
  res.props[0].value = createCustomEventExpr();
30
- addEventOpts(node.tagType === 1 /* COMPONENT */
30
+ addEventOpts(node.tagType === 1 /* ElementTypes.COMPONENT */
31
31
  ? (0, uni_shared_1.customizeEvent)(arg.content)
32
32
  : arg.content, value, node, context);
33
33
  return res;
@@ -39,7 +39,7 @@ function createCustomEventExpr() {
39
39
  }
40
40
  exports.createCustomEventExpr = createCustomEventExpr;
41
41
  function addEventOpts(event, value, node, context) {
42
- const attrName = node.tagType === 1 /* COMPONENT */
42
+ const attrName = node.tagType === 1 /* ElementTypes.COMPONENT */
43
43
  ? ATTR_DATA_EVENT_OPTS
44
44
  : exports.ATTR_DATASET_EVENT_OPTS;
45
45
  const opts = (0, compiler_core_1.findProp)(node, attrName, true);
@@ -69,7 +69,7 @@ function createDataEventOptsProp(name, event, exp, context) {
69
69
  children.push(')');
70
70
  }
71
71
  return {
72
- type: 7 /* DIRECTIVE */,
72
+ type: 7 /* NodeTypes.DIRECTIVE */,
73
73
  name: 'bind',
74
74
  loc: compiler_core_1.locStub,
75
75
  modifiers: [],
package/dist/vue/utils.js CHANGED
@@ -17,8 +17,8 @@ function isVueSfcFile(id) {
17
17
  }
18
18
  exports.isVueSfcFile = isVueSfcFile;
19
19
  function isUserComponent(node, context) {
20
- return (node.type === 1 /* ELEMENT */ &&
21
- node.tagType === 1 /* COMPONENT */ &&
20
+ return (node.type === 1 /* NodeTypes.ELEMENT */ &&
21
+ node.tagType === 1 /* ElementTypes.COMPONENT */ &&
22
22
  !(0, uni_shared_1.isComponentTag)(node.tag) &&
23
23
  !(0, compiler_core_1.isCoreComponent)(node.tag) &&
24
24
  !context.isBuiltInComponent(node.tag));
@@ -26,11 +26,11 @@ function isUserComponent(node, context) {
26
26
  exports.isUserComponent = isUserComponent;
27
27
  function createAttributeNode(name, content) {
28
28
  return {
29
- type: 6 /* ATTRIBUTE */,
29
+ type: 6 /* NodeTypes.ATTRIBUTE */,
30
30
  loc: compiler_core_1.locStub,
31
31
  name,
32
32
  value: {
33
- type: 2 /* TEXT */,
33
+ type: 2 /* NodeTypes.TEXT */,
34
34
  loc: compiler_core_1.locStub,
35
35
  content,
36
36
  },
@@ -41,7 +41,7 @@ function createClassAttribute(clazz) {
41
41
  return createAttributeNode('class', clazz);
42
42
  }
43
43
  function addStaticClass(node, clazz) {
44
- const classProp = node.props.find((prop) => prop.type === 6 /* ATTRIBUTE */ && prop.name === 'class');
44
+ const classProp = node.props.find((prop) => prop.type === 6 /* NodeTypes.ATTRIBUTE */ && prop.name === 'class');
45
45
  if (!classProp) {
46
46
  return node.props.unshift(createClassAttribute(clazz));
47
47
  }
@@ -49,7 +49,7 @@ function addStaticClass(node, clazz) {
49
49
  return (classProp.value.content = classProp.value.content + ' ' + clazz);
50
50
  }
51
51
  classProp.value = {
52
- type: 2 /* TEXT */,
52
+ type: 2 /* NodeTypes.TEXT */,
53
53
  loc: compiler_core_1.locStub,
54
54
  content: clazz,
55
55
  };
@@ -57,7 +57,7 @@ function addStaticClass(node, clazz) {
57
57
  exports.addStaticClass = addStaticClass;
58
58
  function createDirectiveNode(name, arg, exp) {
59
59
  return {
60
- type: 7 /* DIRECTIVE */,
60
+ type: 7 /* NodeTypes.DIRECTIVE */,
61
61
  name,
62
62
  modifiers: [],
63
63
  loc: compiler_core_1.locStub,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3060020220901002",
3
+ "version": "3.0.0-alpha-3060120220907003",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,17 +22,17 @@
22
22
  "@babel/core": "^7.17.9",
23
23
  "@babel/parser": "^7.17.9",
24
24
  "@babel/types": "^7.17.0",
25
- "@dcloudio/uni-i18n": "3.0.0-alpha-3060020220901002",
26
- "@dcloudio/uni-shared": "3.0.0-alpha-3060020220901002",
25
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3060120220907003",
26
+ "@dcloudio/uni-shared": "3.0.0-alpha-3060120220907003",
27
27
  "@intlify/core-base": "9.1.9",
28
28
  "@intlify/shared": "9.1.9",
29
29
  "@intlify/vue-devtools": "9.1.9",
30
30
  "@rollup/pluginutils": "^4.2.0",
31
- "@vue/compiler-core": "3.2.37",
32
- "@vue/compiler-dom": "3.2.37",
33
- "@vue/compiler-sfc": "3.2.37",
34
- "@vue/server-renderer": "3.2.37",
35
- "@vue/shared": "3.2.37",
31
+ "@vue/compiler-core": "3.2.39",
32
+ "@vue/compiler-dom": "3.2.39",
33
+ "@vue/compiler-sfc": "3.2.39",
34
+ "@vue/server-renderer": "3.2.39",
35
+ "@vue/shared": "3.2.39",
36
36
  "autoprefixer": "^10.4.8",
37
37
  "base64url": "^3.0.1",
38
38
  "chokidar": "^3.5.3",
@@ -73,6 +73,6 @@
73
73
  "@types/sass": "^1.43.1",
74
74
  "@types/stylus": "^0.48.36",
75
75
  "postcss": "^8.4.13",
76
- "vue": "3.2.37"
76
+ "vue": "3.2.39"
77
77
  }
78
78
  }