@dcloudio/uni-cli-shared 3.0.0-4000820240401001 → 3.0.0-4010420240430001

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.
Files changed (98) hide show
  1. package/dist/deps.d.ts +2 -0
  2. package/dist/deps.js +3 -0
  3. package/dist/easycom.js +4 -3
  4. package/dist/hbx/alias.js +26 -5
  5. package/dist/hbx/index.d.ts +1 -1
  6. package/dist/hbx/log.d.ts +1 -1
  7. package/dist/hbx/log.js +2 -1
  8. package/dist/index.d.ts +2 -1
  9. package/dist/index.js +3 -2
  10. package/dist/json/app/pages/code.d.ts +1 -1
  11. package/dist/json/mp/index.d.ts +1 -1
  12. package/dist/json/mp/jsonFile.d.ts +1 -1
  13. package/dist/json/mp/pages.d.ts +1 -1
  14. package/dist/json/mp/project.js +2 -2
  15. package/dist/json/mp/types.d.ts +1 -1
  16. package/dist/json/mp/utils.d.ts +1 -1
  17. package/dist/json/uni-x/uniConfig.js +4 -0
  18. package/dist/logs/console.d.ts +2 -4
  19. package/dist/logs/console.js +7 -4
  20. package/dist/logs/format.d.ts +1 -1
  21. package/dist/mp/ast.d.ts +1 -1
  22. package/dist/mp/externalClasses.d.ts +1 -1
  23. package/dist/mp/imports.d.ts +2 -2
  24. package/dist/mp/plugin.d.ts +1 -1
  25. package/dist/mp/tags.js +5 -6
  26. package/dist/mp/usingComponents.d.ts +1 -1
  27. package/dist/postcss/index.d.ts +1 -1
  28. package/dist/uni_modules.d.ts +23 -0
  29. package/dist/uni_modules.js +80 -12
  30. package/dist/utils.d.ts +3 -5
  31. package/dist/utils.js +7 -7
  32. package/dist/uts.d.ts +3 -4
  33. package/dist/uts.js +28 -42
  34. package/dist/utsUtils.d.ts +2 -0
  35. package/dist/utsUtils.js +44 -0
  36. package/dist/vite/autoImport.d.ts +1 -1
  37. package/dist/vite/autoImport.js +1 -0
  38. package/dist/vite/features.d.ts +1 -0
  39. package/dist/vite/features.js +31 -28
  40. package/dist/vite/index.d.ts +2 -1
  41. package/dist/vite/plugins/console.d.ts +2 -2
  42. package/dist/vite/plugins/copy.d.ts +1 -1
  43. package/dist/vite/plugins/easycom.d.ts +2 -2
  44. package/dist/vite/plugins/index.d.ts +1 -0
  45. package/dist/vite/plugins/index.js +3 -1
  46. package/dist/vite/plugins/inject.d.ts +1 -1
  47. package/dist/vite/plugins/inject.js +2 -2
  48. package/dist/vite/plugins/jsonJs.d.ts +3 -3
  49. package/dist/vite/plugins/mainJs.d.ts +2 -2
  50. package/dist/vite/plugins/sfc.d.ts +6 -0
  51. package/dist/vite/plugins/sfc.js +136 -0
  52. package/dist/vite/plugins/uts/ext-api.d.ts +2 -1
  53. package/dist/vite/plugins/uts/ext-api.js +4 -5
  54. package/dist/vite/plugins/uts/uni_modules.d.ts +1 -1
  55. package/dist/vite/plugins/uts/uni_modules.js +20 -7
  56. package/dist/vite/plugins/uts/uvue.js +1 -1
  57. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +2 -2
  58. package/dist/vite/plugins/vitejs/plugins/asset.js +1 -1
  59. package/dist/vite/plugins/vitejs/plugins/css.d.ts +4 -4
  60. package/dist/vite/plugins/vitejs/plugins/css.js +10 -2
  61. package/dist/vite/plugins/vitejs/utils.d.ts +1 -1
  62. package/dist/vite/utils/ast.d.ts +2 -2
  63. package/dist/vite/utils/ast.js +7 -6
  64. package/dist/vite/utils/utils.d.ts +2 -2
  65. package/dist/vue/babel.d.ts +1 -1
  66. package/dist/vue/parse.d.ts +1 -1
  67. package/dist/vue/parse.js +8 -7
  68. package/dist/vue/transforms/index.d.ts +1 -0
  69. package/dist/vue/transforms/index.js +1 -0
  70. package/dist/vue/transforms/templateTransformAssetUrl.d.ts +1 -1
  71. package/dist/vue/transforms/templateTransformAssetUrl.js +8 -8
  72. package/dist/vue/transforms/templateTransformSrcset.d.ts +2 -2
  73. package/dist/vue/transforms/templateTransformSrcset.js +7 -7
  74. package/dist/vue/transforms/templateUtils.d.ts +1 -1
  75. package/dist/vue/transforms/transformComponent.d.ts +2 -2
  76. package/dist/vue/transforms/transformComponent.js +7 -3
  77. package/dist/vue/transforms/transformEvent.d.ts +1 -1
  78. package/dist/vue/transforms/transformPageHead.d.ts +1 -1
  79. package/dist/vue/transforms/transformRef.d.ts +1 -1
  80. package/dist/vue/transforms/transformRef.js +1 -1
  81. package/dist/vue/transforms/transformRefresherSlot.d.ts +8 -0
  82. package/dist/vue/transforms/transformRefresherSlot.js +58 -0
  83. package/dist/vue/transforms/transformTag.d.ts +1 -1
  84. package/dist/vue/transforms/transformUTSComponent.d.ts +1 -1
  85. package/dist/vue/transforms/transformUTSComponent.js +2 -2
  86. package/dist/vue/transforms/vModel.d.ts +1 -1
  87. package/dist/vue/transforms/vOn.d.ts +1 -1
  88. package/dist/vue/transforms/vOn.js +4 -4
  89. package/dist/vue/utils.d.ts +4 -1
  90. package/dist/vue/utils.js +47 -8
  91. package/dist/watcher.d.ts +1 -1
  92. package/lib/@vue/compiler-sfc/LICENSE +21 -0
  93. package/lib/@vue/compiler-sfc/README.md +80 -0
  94. package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +20665 -0
  95. package/lib/@vue/compiler-sfc/dist/compiler-sfc.d.ts +543 -0
  96. package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +48237 -0
  97. package/lib/@vue/compiler-sfc/package.json +67 -0
  98. package/package.json +20 -18
package/dist/deps.d.ts CHANGED
@@ -16,4 +16,6 @@ export declare const COMPONENT_DEPS_CSS: {
16
16
  textarea: string[];
17
17
  'web-view': string[];
18
18
  picker: string[];
19
+ 'scroll-view': string[];
20
+ 'list-view': string[];
19
21
  };
package/dist/deps.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.COMPONENT_DEPS_CSS = exports.API_DEPS_CSS = void 0;
4
4
  const constants_1 = require("./constants");
5
5
  const RESIZE_SENSOR_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'resize-sensor.css';
6
+ const REFRESHER_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'refresher.css';
6
7
  exports.API_DEPS_CSS = {
7
8
  showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
8
9
  showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
@@ -36,4 +37,6 @@ exports.COMPONENT_DEPS_CSS = {
36
37
  `${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view.css`,
37
38
  `${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view-column.css`,
38
39
  ],
40
+ 'scroll-view': [REFRESHER_CSS],
41
+ 'list-view': [RESIZE_SENSOR_CSS, REFRESHER_CSS],
39
42
  };
package/dist/easycom.js CHANGED
@@ -14,6 +14,7 @@ const utils_1 = require("./utils");
14
14
  const pages_1 = require("./json/pages");
15
15
  const messages_1 = require("./messages");
16
16
  const uts_1 = require("./uts");
17
+ const utsUtils_1 = require("./utsUtils");
17
18
  const debugEasycom = (0, debug_1.default)('uni:easycom');
18
19
  const easycoms = [];
19
20
  const easycomsCache = new Map();
@@ -238,7 +239,7 @@ function genResolveEasycomCode(importDeclarations, code, name) {
238
239
  return `resolveEasycom(${code.replace('_resolveComponent', '__resolveDynamicComponent')}, ${name})`;
239
240
  }
240
241
  exports.genResolveEasycomCode = genResolveEasycomCode;
241
- exports.UNI_EASYCOM_EXCLUDE = [/App.vue$/, /@dcloudio\/uni-h5/];
242
+ exports.UNI_EASYCOM_EXCLUDE = [/@dcloudio\/uni-h5/];
242
243
  const utsEasyComAutoImports = {};
243
244
  function getUTSEasyComAutoImports() {
244
245
  return utsEasyComAutoImports;
@@ -265,8 +266,8 @@ function genUTSComponentPublicInstanceImported(root, fileName) {
265
266
  fileName = (0, utils_1.normalizePath)(path_1.default.relative(root, fileName));
266
267
  }
267
268
  if (fileName.startsWith('@/')) {
268
- return ((0, uts_1.genUTSClassName)(fileName.replace('@/', '')) + 'ComponentPublicInstance');
269
+ return ((0, utsUtils_1.genUTSClassName)(fileName.replace('@/', '')) + 'ComponentPublicInstance');
269
270
  }
270
- return (0, uts_1.genUTSClassName)(fileName) + 'ComponentPublicInstance';
271
+ return (0, utsUtils_1.genUTSClassName)(fileName) + 'ComponentPublicInstance';
271
272
  }
272
273
  exports.genUTSComponentPublicInstanceImported = genUTSComponentPublicInstanceImported;
package/dist/hbx/alias.js CHANGED
@@ -8,14 +8,14 @@ const path_1 = __importDefault(require("path"));
8
8
  const module_alias_1 = __importDefault(require("module-alias"));
9
9
  const env_1 = require("./env");
10
10
  const hbxPlugins = {
11
- // typescript: 'compile-typescript/node_modules/typescript',
11
+ typescript: 'compile-typescript/node_modules/typescript',
12
12
  less: 'compile-less/node_modules/less',
13
13
  sass: 'compile-dart-sass/node_modules/sass',
14
14
  stylus: 'compile-stylus/node_modules/stylus',
15
15
  pug: 'compile-pug-cli/node_modules/pug',
16
16
  };
17
17
  function initModuleAlias() {
18
- const compilerSfcPath = require.resolve('@vue/compiler-sfc');
18
+ const compilerSfcPath = path_1.default.resolve(__dirname, '../../lib/@vue/compiler-sfc');
19
19
  const serverRendererPath = require.resolve('@vue/server-renderer');
20
20
  module_alias_1.default.addAliases({
21
21
  '@vue/shared': require.resolve('@vue/shared'),
@@ -34,8 +34,21 @@ function initModuleAlias() {
34
34
  }
35
35
  if ((0, env_1.isInHBuilderX)()) {
36
36
  // 又是为了复用 HBuilderX 的插件逻辑,硬编码映射
37
- Object.keys(hbxPlugins).forEach((name) => {
38
- module_alias_1.default.addAlias(name, path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[name]));
37
+ Object.keys(hbxPlugins).forEach((lang) => {
38
+ const realPath = path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[lang]);
39
+ module_alias_1.default.addAlias(lang,
40
+ // @ts-expect-error
41
+ () => {
42
+ try {
43
+ require.resolve(realPath);
44
+ }
45
+ catch (e) {
46
+ const msg = exports.moduleAliasFormatter.format(`Preprocessor dependency "${lang}" not found. Did you install it?`);
47
+ console.error(msg);
48
+ process.exit(0);
49
+ }
50
+ return realPath;
51
+ });
39
52
  });
40
53
  // web 平台用了 vite 内置 css 插件,该插件会加载预编译器如scss、less等,需要转向到 HBuilderX 的对应编译器插件
41
54
  if (process.env.UNI_PLATFORM === 'h5' ||
@@ -91,7 +104,11 @@ exports.moduleAliasFormatter = {
91
104
  format(msg) {
92
105
  let lang = '';
93
106
  let preprocessor = '';
94
- if (msg.includes(`"sass"`)) {
107
+ if (msg.includes(`"pug"`)) {
108
+ lang = 'pug';
109
+ preprocessor = 'compile-pug-cli';
110
+ }
111
+ else if (msg.includes(`"sass"`)) {
95
112
  lang = 'sass';
96
113
  preprocessor = 'compile-dart-sass';
97
114
  }
@@ -103,6 +120,10 @@ exports.moduleAliasFormatter = {
103
120
  lang = 'stylus';
104
121
  preprocessor = 'compile-stylus';
105
122
  }
123
+ else if (msg.includes('"typescript"')) {
124
+ lang = 'typescript';
125
+ preprocessor = 'compile-typescript';
126
+ }
106
127
  if (lang) {
107
128
  // 仅提醒一次
108
129
  if (installPreprocessorTips[lang]) {
@@ -1,4 +1,4 @@
1
1
  export { formatAtFilename } from './log';
2
2
  export * from './env';
3
3
  export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
4
- export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin;
4
+ export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin<any>;
package/dist/hbx/log.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { LogErrorOptions } from 'vite';
2
- import { Formatter } from '../logs/format';
2
+ import type { Formatter } from '../logs/format';
3
3
  export declare function formatAtFilename(filename: string, line?: number, column?: number): string;
4
4
  export declare const h5ServeFormatter: Formatter;
5
5
  export declare const removeInfoFormatter: Formatter;
package/dist/hbx/log.js CHANGED
@@ -7,6 +7,7 @@ exports.errorFormatter = exports.removeWarnFormatter = exports.removeInfoFormatt
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const picocolors_1 = __importDefault(require("picocolors"));
10
+ const compiler_core_1 = require("@vue/compiler-core");
10
11
  const shared_1 = require("@vue/shared");
11
12
  const utils_1 = require("../utils");
12
13
  const constants_1 = require("../constants");
@@ -117,7 +118,7 @@ function buildErrorMessage(err, args = [], includeStack = true) {
117
118
  constants_1.EXTNAME_VUE_RE.test(err.id)) {
118
119
  try {
119
120
  const ast = (0, ast_1.parseVue)(fs_1.default.readFileSync(err.id, 'utf8'), []);
120
- const scriptNode = ast.children.find((node) => node.type === 1 /* NodeTypes.ELEMENT */ && node.tag === 'script');
121
+ const scriptNode = ast.children.find((node) => node.type === compiler_core_1.NodeTypes.ELEMENT && node.tag === 'script');
121
122
  if (scriptNode) {
122
123
  const scriptLoc = scriptNode.loc;
123
124
  args.push(picocolors_1.default.yellow(pad((0, utils_2.generateCodeFrame)(scriptLoc.source, err.loc))));
package/dist/index.d.ts CHANGED
@@ -21,7 +21,8 @@ export * from './esbuild';
21
21
  export * from './resolve';
22
22
  export * from './scripts';
23
23
  export * from './platform';
24
- export { parseUniExtApis, parseInjects, Define, DefineOptions, Defines, } from './uni_modules';
24
+ export * from './utsUtils';
25
+ export { parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, } from './uni_modules';
25
26
  export { M } from './messages';
26
27
  export * from './exports';
27
28
  export { checkUpdate } from './checkUpdate';
package/dist/index.js CHANGED
@@ -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.checkUpdate = exports.M = exports.parseInjects = exports.parseUniExtApis = void 0;
17
+ exports.checkUpdate = exports.M = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = void 0;
18
18
  __exportStar(require("./fs"), exports);
19
19
  __exportStar(require("./mp"), exports);
20
20
  __exportStar(require("./url"), exports);
@@ -38,12 +38,13 @@ __exportStar(require("./esbuild"), exports);
38
38
  __exportStar(require("./resolve"), exports);
39
39
  __exportStar(require("./scripts"), exports);
40
40
  __exportStar(require("./platform"), exports);
41
+ __exportStar(require("./utsUtils"), exports);
41
42
  var uni_modules_1 = require("./uni_modules");
42
43
  Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
43
44
  Object.defineProperty(exports, "parseInjects", { enumerable: true, get: function () { return uni_modules_1.parseInjects; } });
45
+ Object.defineProperty(exports, "getUniExtApiProviderRegisters", { enumerable: true, get: function () { return uni_modules_1.getUniExtApiProviderRegisters; } });
44
46
  var messages_1 = require("./messages");
45
47
  Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
46
48
  __exportStar(require("./exports"), exports);
47
- // @ts-ignore
48
49
  var checkUpdate_1 = require("./checkUpdate");
49
50
  Object.defineProperty(exports, "checkUpdate", { enumerable: true, get: function () { return checkUpdate_1.checkUpdate; } });
@@ -1,4 +1,4 @@
1
1
  export declare const arrayBufferCode = "\nif (typeof uni !== 'undefined' && uni && uni.requireGlobal) {\n const global = uni.requireGlobal()\n ArrayBuffer = global.ArrayBuffer\n Int8Array = global.Int8Array\n Uint8Array = global.Uint8Array\n Uint8ClampedArray = global.Uint8ClampedArray\n Int16Array = global.Int16Array\n Uint16Array = global.Uint16Array\n Int32Array = global.Int32Array\n Uint32Array = global.Uint32Array\n Float32Array = global.Float32Array\n Float64Array = global.Float64Array\n BigInt64Array = global.BigInt64Array\n BigUint64Array = global.BigUint64Array\n};\n";
2
- export declare const polyfillCode: string;
2
+ export declare const polyfillCode = "\nif (typeof Promise !== 'undefined' && !Promise.prototype.finally) {\n Promise.prototype.finally = function(callback) {\n const promise = this.constructor\n return this.then(\n value => promise.resolve(callback()).then(() => value),\n reason => promise.resolve(callback()).then(() => {\n throw reason\n })\n )\n }\n};\n\nif (typeof uni !== 'undefined' && uni && uni.requireGlobal) {\n const global = uni.requireGlobal()\n ArrayBuffer = global.ArrayBuffer\n Int8Array = global.Int8Array\n Uint8Array = global.Uint8Array\n Uint8ClampedArray = global.Uint8ClampedArray\n Int16Array = global.Int16Array\n Uint16Array = global.Uint16Array\n Int32Array = global.Int32Array\n Uint32Array = global.Uint32Array\n Float32Array = global.Float32Array\n Float64Array = global.Float64Array\n BigInt64Array = global.BigInt64Array\n BigUint64Array = global.BigUint64Array\n};\n\n";
3
3
  export declare const restoreGlobalCode = "\nif(uni.restoreGlobal){\n uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)\n}\n";
4
4
  export declare const globalCode: string;
@@ -1,4 +1,4 @@
1
1
  export * from './jsonFile';
2
- export { AppJson } from './types';
2
+ export { AppJson, ComponentJson } from './types';
3
3
  export { mergeMiniProgramAppJson, parseMiniProgramPagesJson } from './pages';
4
4
  export { parseMiniProgramProjectJson } from './project';
@@ -1,4 +1,4 @@
1
- import { ComponentJson, PageWindowOptions, UsingComponents } from './types';
1
+ import type { ComponentJson, PageWindowOptions, UsingComponents } from './types';
2
2
  export declare function isMiniProgramPageFile(file: string, inputDir?: string): boolean;
3
3
  export declare function isMiniProgramPageSfcFile(file: string, inputDir?: string): boolean;
4
4
  export declare function hasJsonFile(filename: string): boolean;
@@ -1,4 +1,4 @@
1
- import { AppJson, NetworkTimeout, PageWindowOptions } from './types';
1
+ import type { AppJson, NetworkTimeout, PageWindowOptions } from './types';
2
2
  interface ParsePagesJsonOptions {
3
3
  debug?: boolean;
4
4
  darkmode?: boolean;
@@ -83,8 +83,8 @@ function parseMiniProgramCondition(pagesJson) {
83
83
  list: [
84
84
  {
85
85
  id: 0,
86
- name: launchPagePath,
87
- pathName: launchPagePath,
86
+ name: launchPagePath, // 模式名称
87
+ pathName: launchPagePath, // 启动页面,必选
88
88
  query: process.env.UNI_CLI_LAUNCH_PAGE_QUERY || '', // 启动参数,在页面的onLoad函数里面得到。
89
89
  },
90
90
  ],
@@ -2,7 +2,7 @@ export interface ComponentJson {
2
2
  component: true;
3
3
  usingComponents?: UsingComponents;
4
4
  usingSwanComponents?: UsingComponents;
5
- styleIsolation?: 'apply-shared' | 'shared';
5
+ styleIsolation?: 'apply-shared' | 'shared' | 'isolated';
6
6
  }
7
7
  interface ShareWindowOptions {
8
8
  navigationBarBackgroundColor?: string;
@@ -1,3 +1,3 @@
1
- import { AppWindowOptions, PageWindowOptions, TabBar } from './types';
1
+ import type { AppWindowOptions, PageWindowOptions, TabBar } from './types';
2
2
  export declare function parseWindowOptions(style: UniApp.PagesJsonPageStyle, platform: UniApp.PLATFORM, windowOptionsMap?: Record<string, string>): PageWindowOptions | AppWindowOptions;
3
3
  export declare function parseTabBar(tabBar: UniApp.TabBarOptions, platform: UniApp.PLATFORM, tabBarOptionsMap?: Record<string, string>, tabBarItemOptionsMap?: Record<string, string>): TabBar;
@@ -12,6 +12,10 @@ function normalizeAppXUniConfig(pagesJson, manifestJson) {
12
12
  tabBar: pagesJson.tabBar,
13
13
  fallbackLocale: manifestJson.fallbackLocale,
14
14
  };
15
+ if (config.realEntryPagePath) {
16
+ config.conditionUrl = config.entryPagePath;
17
+ config.entryPagePath = config.realEntryPagePath;
18
+ }
15
19
  // TODO 待支持分包
16
20
  return JSON.stringify(config);
17
21
  }
@@ -1,4 +1,2 @@
1
- export declare function rewriteConsoleExpr(method: string, id: string, filename: string, code: string, sourceMap?: boolean): {
2
- code: string;
3
- map: import("magic-string").SourceMap | null;
4
- };
1
+ import type { TransformResult } from 'vite';
2
+ export declare function rewriteConsoleExpr(method: string, id: string, filename: string, code: string, sourceMap?: boolean): TransformResult;
@@ -16,10 +16,13 @@ function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
16
16
  const [, expr, type] = match;
17
17
  s.overwrite(match.index, match.index + expr.length + 1, method + `('${type}','at ${filename}:${locate(match.index).line + 1}',`);
18
18
  }
19
- return {
20
- code: s.toString(),
21
- map: sourceMap ? s.generateMap({ source: id, hires: true }) : null,
22
- };
19
+ if (s.hasChanged()) {
20
+ return {
21
+ code: s.toString(),
22
+ map: sourceMap ? s.generateMap({ hires: true }) : { mappings: '' },
23
+ };
24
+ }
25
+ return { code, map: { mappings: '' } };
23
26
  }
24
27
  exports.rewriteConsoleExpr = rewriteConsoleExpr;
25
28
  function getLocator(source) {
@@ -1,4 +1,4 @@
1
- import { LogErrorOptions, LogOptions } from 'vite';
1
+ import type { LogErrorOptions, LogOptions } from 'vite';
2
2
  export interface Formatter<T extends LogOptions = LogOptions> {
3
3
  test: (msg: string, options?: T) => boolean;
4
4
  format: (msg: string, options?: T) => string;
package/dist/mp/ast.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Program } from '@babel/types';
2
- import { ParserPlugin } from '@babel/parser';
2
+ import { type ParserPlugin } from '@babel/parser';
3
3
  export declare function parseProgram(code: string, importer: string, { babelParserPlugins }: {
4
4
  babelParserPlugins?: ParserPlugin[];
5
5
  }): Program;
@@ -1,4 +1,4 @@
1
- import { Program } from '@babel/types';
1
+ import { type Program } from '@babel/types';
2
2
  export declare function hasExternalClasses(code: string): boolean;
3
3
  export declare function findMiniProgramComponentExternalClasses(filename: string): string[] | undefined;
4
4
  export declare function updateMiniProgramComponentExternalClasses(filename: string, classes: string[]): void;
@@ -1,5 +1,5 @@
1
- import { PluginContext } from 'rollup';
2
- import { ImportSpecifier } from 'es-module-lexer';
1
+ import type { PluginContext } from 'rollup';
2
+ import { type ImportSpecifier } from 'es-module-lexer';
3
3
  /**
4
4
  * 暂时没用
5
5
  * @param source
@@ -1,3 +1,3 @@
1
- import { UniViteCopyPluginTarget } from '../vite/plugins/copy';
1
+ import type { UniViteCopyPluginTarget } from '../vite/plugins/copy';
2
2
  export declare const copyMiniProgramPluginJson: UniViteCopyPluginTarget;
3
3
  export declare const copyMiniProgramThemeJson: () => UniViteCopyPluginTarget[];
package/dist/mp/tags.js CHANGED
@@ -49,7 +49,6 @@ exports.HTML_TO_MINI_PROGRAM_TAGS = {
49
49
  select: 'picker',
50
50
  option: 'view',
51
51
  optgroup: 'view',
52
- // label: 'label',
53
52
  fieldset: 'view',
54
53
  datalist: 'picker',
55
54
  legend: 'view',
@@ -103,12 +102,12 @@ exports.HTML_TO_MINI_PROGRAM_TAGS = {
103
102
  dialog: 'view',
104
103
  summary: 'view',
105
104
  // progress: 'progress',
106
- meter: 'progress',
107
- head: 'view',
108
- meta: 'view',
109
- base: 'text',
105
+ meter: 'progress', // todo
106
+ head: 'view', // todo
107
+ meta: 'view', // todo
108
+ base: 'text', // todo
110
109
  // 'map': 'image', // TODO不是很恰当
111
- area: 'navigator',
110
+ area: 'navigator', // j结合map使用
112
111
  script: 'view',
113
112
  noscript: 'view',
114
113
  embed: 'view',
@@ -1,4 +1,4 @@
1
- import { ImportDeclaration, Program } from '@babel/types';
1
+ import { type ImportDeclaration, type Program } from '@babel/types';
2
2
  import type { PluginContext } from 'rollup';
3
3
  type BindingComponents = Record<string, {
4
4
  tag: string;
@@ -1,7 +1,7 @@
1
1
  import type { Plugin } from 'postcss';
2
2
  import type { Options } from 'autoprefixer';
3
3
  import uniPostcssScopedPlugin from './plugins/stylePluginScoped';
4
- import uniPostcssPlugin, { UniAppCssProcessorOptions } from './plugins/uniapp';
4
+ import uniPostcssPlugin, { type UniAppCssProcessorOptions } from './plugins/uniapp';
5
5
  export { uniPostcssPlugin };
6
6
  export { uniPostcssScopedPlugin };
7
7
  export declare function initPostcssPlugin({ uniApp, autoprefixer, }?: {
@@ -21,6 +21,14 @@ export declare function getUniExtApiProviders(): {
21
21
  name?: string | undefined;
22
22
  servicePlugin?: string | undefined;
23
23
  }[];
24
+ export declare function getUniExtApiPlugins(): {
25
+ plugin: string;
26
+ }[];
27
+ export declare function getUniExtApiProviderRegisters(): {
28
+ name: string;
29
+ service: string;
30
+ class: string;
31
+ }[];
24
32
  export declare function parseUniExtApis(vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language?: UTSTargetLanguage): Injects;
25
33
  export type Injects = {
26
34
  [name: string]: string | [string, string] | [string, string, DefineOptions['app']] | false;
@@ -47,3 +55,18 @@ export type Injects = {
47
55
  * @returns
48
56
  */
49
57
  export declare function parseInjects(vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage, source: string, uniModuleRootDir: string, exports?: Exports): Injects;
58
+ /**
59
+ * @private
60
+ */
61
+ export declare const camelize: (str: string) => string;
62
+ /**
63
+ * @private
64
+ */
65
+ export declare const capitalize: (str: string) => string;
66
+ /**
67
+ * 解析 UTS 类型的模块依赖列表
68
+ * @param deps
69
+ * @param inputDir
70
+ * @returns
71
+ */
72
+ export declare function parseUTSModuleDeps(deps: string[], inputDir: string): string[];
@@ -3,15 +3,40 @@ 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.parseInjects = exports.parseUniExtApis = exports.getUniExtApiProviders = void 0;
6
+ exports.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.getUniExtApiPlugins = exports.getUniExtApiProviders = void 0;
7
7
  // 重要:此文件编译后的js,需同步至 vue2 编译器中 uni-cli-shared/lib/uts/uni_modules.js
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
10
10
  const extApiProviders = [];
11
+ const extApiPlugins = new Set();
11
12
  function getUniExtApiProviders() {
12
13
  return extApiProviders;
13
14
  }
14
15
  exports.getUniExtApiProviders = getUniExtApiProviders;
16
+ function getUniExtApiPlugins() {
17
+ return [...extApiPlugins].map((plugin) => {
18
+ return { plugin };
19
+ });
20
+ }
21
+ exports.getUniExtApiPlugins = getUniExtApiPlugins;
22
+ function getUniExtApiProviderRegisters() {
23
+ const result = [];
24
+ extApiProviders.forEach((provider) => {
25
+ if (provider.name && provider.service) {
26
+ result.push({
27
+ name: provider.name,
28
+ service: provider.service,
29
+ class: `uts.sdk.modules.${(0, exports.camelize)(provider.plugin)}.${(0, exports.capitalize)((0, exports.camelize)('uni-ext-api-' +
30
+ provider.service +
31
+ '-' +
32
+ provider.name +
33
+ '-provider'))}`,
34
+ });
35
+ }
36
+ });
37
+ return result;
38
+ }
39
+ exports.getUniExtApiProviderRegisters = getUniExtApiProviderRegisters;
15
40
  function parseUniExtApis(vite = true, platform, language = 'javascript') {
16
41
  if (!process.env.UNI_INPUT_DIR) {
17
42
  return {};
@@ -22,6 +47,7 @@ function parseUniExtApis(vite = true, platform, language = 'javascript') {
22
47
  }
23
48
  const injects = {};
24
49
  extApiProviders.length = 0;
50
+ extApiPlugins.clear();
25
51
  fs_extra_1.default.readdirSync(uniModulesDir).forEach((uniModuleDir) => {
26
52
  // 必须以 uni- 开头
27
53
  if (!uniModuleDir.startsWith('uni-')) {
@@ -44,6 +70,7 @@ function parseUniExtApis(vite = true, platform, language = 'javascript') {
44
70
  provider.plugin = uniModuleDir;
45
71
  extApiProviders.push(provider);
46
72
  }
73
+ extApiPlugins.add(uniModuleDir);
47
74
  const curInjects = parseInjects(vite, platform, language, `@/uni_modules/${uniModuleDir}`, uniModuleRootDir, exports);
48
75
  Object.assign(injects, curInjects);
49
76
  }
@@ -109,6 +136,11 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
109
136
  source = `${source}/utssdk/index.uts`;
110
137
  }
111
138
  }
139
+ else if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
140
+ if (fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-js', 'index.uts'))) {
141
+ source = `${source}/utssdk/app-js/index.uts`;
142
+ }
143
+ }
112
144
  for (const key in rootDefines) {
113
145
  Object.assign(injects, parseInject(vite, platform, language, source, 'uni', rootDefines[key], hasPlatformFile));
114
146
  }
@@ -157,19 +189,24 @@ function parseInject(vite = true, platform, language, source, globalObject, defi
157
189
  if (p === 'app') {
158
190
  const appOptions = defineOptions.app;
159
191
  if (isPlainObject(appOptions)) {
160
- if (language === 'javascript') {
161
- if (appOptions.js === false) {
162
- return;
192
+ // js engine 下且存在 app-js,不检查
193
+ const skipCheck = process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js' &&
194
+ source.includes('app-js');
195
+ if (!skipCheck) {
196
+ if (language === 'javascript') {
197
+ if (appOptions.js === false) {
198
+ return;
199
+ }
163
200
  }
164
- }
165
- else if (language === 'kotlin') {
166
- if (appOptions.kotlin === false) {
167
- return;
201
+ else if (language === 'kotlin') {
202
+ if (appOptions.kotlin === false) {
203
+ return;
204
+ }
168
205
  }
169
- }
170
- else if (language === 'swift') {
171
- if (appOptions.swift === false) {
172
- return;
206
+ else if (language === 'swift') {
207
+ if (appOptions.swift === false) {
208
+ return;
209
+ }
173
210
  }
174
211
  }
175
212
  }
@@ -197,3 +234,34 @@ const toTypeString = (value) => objectToString.call(value);
197
234
  function isPlainObject(val) {
198
235
  return toTypeString(val) === '[object Object]';
199
236
  }
237
+ const cacheStringFunction = (fn) => {
238
+ const cache = Object.create(null);
239
+ return ((str) => {
240
+ const hit = cache[str];
241
+ return hit || (cache[str] = fn(str));
242
+ });
243
+ };
244
+ const camelizeRE = /-(\w)/g;
245
+ /**
246
+ * @private
247
+ */
248
+ exports.camelize = cacheStringFunction((str) => {
249
+ return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
250
+ });
251
+ /**
252
+ * @private
253
+ */
254
+ exports.capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
255
+ /**
256
+ * 解析 UTS 类型的模块依赖列表
257
+ * @param deps
258
+ * @param inputDir
259
+ * @returns
260
+ */
261
+ function parseUTSModuleDeps(deps, inputDir) {
262
+ const modulesDir = path_1.default.resolve(inputDir, 'uni_modules');
263
+ return deps.filter((dep) => {
264
+ return fs_extra_1.default.existsSync(path_1.default.resolve(modulesDir, dep, 'utssdk'));
265
+ });
266
+ }
267
+ exports.parseUTSModuleDeps = parseUTSModuleDeps;
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  export { default as hash } from 'hash-sum';
2
- import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
3
- import { ParserPlugin } from '@babel/parser';
4
- export declare const version: any;
2
+ import { type ElementNode, type RootNode, type TemplateChildNode } from '@vue/compiler-core';
3
+ import type { ParserPlugin } from '@babel/parser';
5
4
  export { camelize, capitalize, isArray } from '@vue/shared';
6
- export declare let isRunningWithYarnPnp: boolean;
7
5
  export declare const isWindows: boolean;
8
6
  export declare function normalizePath(id: string): string;
9
7
  export declare function checkElementNodeTag(node: RootNode | TemplateChildNode | null | undefined, tag: string): node is ElementNode;
@@ -12,7 +10,7 @@ export declare function normalizePagePath(pagePath: string, platform: UniApp.PLA
12
10
  export declare function removeExt(str: string): string;
13
11
  export declare function normalizeNodeModules(str: string): string;
14
12
  export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
15
- export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): (import("@babel/parser").ParserPluginWithOptions | ("jsx" | "asyncDoExpressions" | "asyncGenerators" | "bigInt" | "classPrivateMethods" | "classPrivateProperties" | "classProperties" | "classStaticBlock" | "decimal" | "decorators-legacy" | "deferredImportEvaluation" | "decoratorAutoAccessors" | "destructuringPrivate" | "doExpressions" | "dynamicImport" | "explicitResourceManagement" | "exportDefaultFrom" | "exportNamespaceFrom" | "flow" | "flowComments" | "functionBind" | "functionSent" | "importMeta" | "logicalAssignment" | "importAssertions" | "importAttributes" | "importReflection" | "moduleBlocks" | "moduleStringNames" | "nullishCoalescingOperator" | "numericSeparator" | "objectRestSpread" | "optionalCatchBinding" | "optionalChaining" | "partialApplication" | "placeholders" | "privateIn" | "regexpUnicodeSets" | "sourcePhaseImports" | "throwExpressions" | "topLevelAwait" | "v8intrinsic" | "decorators" | "estree" | "moduleAttributes" | "optionalChainingAssign" | "pipelineOperator" | "recordAndTuple" | "typescript"))[];
13
+ export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): (import("@babel/parser").ParserPluginWithOptions | ("jsx" | "typescript" | "asyncDoExpressions" | "asyncGenerators" | "bigInt" | "classPrivateMethods" | "classPrivateProperties" | "classProperties" | "classStaticBlock" | "decimal" | "decorators-legacy" | "deferredImportEvaluation" | "decoratorAutoAccessors" | "destructuringPrivate" | "doExpressions" | "dynamicImport" | "explicitResourceManagement" | "exportDefaultFrom" | "exportNamespaceFrom" | "flow" | "flowComments" | "functionBind" | "functionSent" | "importMeta" | "logicalAssignment" | "importAssertions" | "importAttributes" | "importReflection" | "moduleBlocks" | "moduleStringNames" | "nullishCoalescingOperator" | "numericSeparator" | "objectRestSpread" | "optionalCatchBinding" | "optionalChaining" | "partialApplication" | "placeholders" | "privateIn" | "regexpUnicodeSets" | "sourcePhaseImports" | "throwExpressions" | "topLevelAwait" | "v8intrinsic" | "decorators" | "estree" | "moduleAttributes" | "optionalChainingAssign" | "pipelineOperator" | "recordAndTuple"))[];
16
14
  export declare function pathToGlob(pathString: string, glob: string, options?: {
17
15
  windows?: boolean;
18
16
  escape?: boolean;
package/dist/utils.js CHANGED
@@ -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.createResolveErrorMsg = exports.parseImporter = exports.resolveAppVue = exports.isAppVue = exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.isArray = exports.capitalize = exports.camelize = exports.version = exports.hash = void 0;
6
+ exports.createResolveErrorMsg = exports.parseImporter = exports.resolveAppVue = exports.isAppVue = exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isArray = exports.capitalize = exports.camelize = exports.hash = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -12,25 +12,25 @@ const shared_1 = require("@vue/shared");
12
12
  var hash_sum_1 = require("hash-sum");
13
13
  Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return __importDefault(hash_sum_1).default; } });
14
14
  const constants_1 = require("./constants");
15
+ const compiler_core_1 = require("@vue/compiler-core");
15
16
  const platform_1 = require("./platform");
16
17
  const hbx_1 = require("./hbx");
17
- exports.version = require('../package.json').version;
18
18
  // 专为 uts.ts 服务
19
19
  var shared_2 = require("@vue/shared");
20
20
  Object.defineProperty(exports, "camelize", { enumerable: true, get: function () { return shared_2.camelize; } });
21
21
  Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return shared_2.capitalize; } });
22
22
  Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return shared_2.isArray; } });
23
- try {
24
- exports.isRunningWithYarnPnp = Boolean(require('pnpapi'));
25
- }
26
- catch { }
23
+ // export let isRunningWithYarnPnp: boolean
24
+ // try {
25
+ // isRunningWithYarnPnp = Boolean(require('pnpapi'))
26
+ // } catch {}
27
27
  exports.isWindows = os_1.default.platform() === 'win32';
28
28
  function normalizePath(id) {
29
29
  return exports.isWindows ? id.replace(/\\/g, '/') : id;
30
30
  }
31
31
  exports.normalizePath = normalizePath;
32
32
  function checkElementNodeTag(node, tag) {
33
- return !!node && node.type === 1 /* NodeTypes.ELEMENT */ && node.tag === tag;
33
+ return !!node && node.type === compiler_core_1.NodeTypes.ELEMENT && node.tag === tag;
34
34
  }
35
35
  exports.checkElementNodeTag = checkElementNodeTag;
36
36
  function normalizeIdentifier(str) {
package/dist/uts.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import * as UTSCompiler from '@dcloudio/uni-uts-v1';
4
- import { type EasycomMatcher } from './easycom';
3
+ import type * as UTSCompiler from '@dcloudio/uni-uts-v1';
4
+ import type { EasycomMatcher } from './easycom';
5
5
  /**
6
6
  * 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
7
7
  * @param id
@@ -23,5 +23,4 @@ export declare function parseSwiftPackageWithPluginId(id: string, is_uni_modules
23
23
  export type UTSTargetLanguage = typeof process.env.UNI_UTS_TARGET_LANGUAGE;
24
24
  export declare const parseUniExtApiNamespacesOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
25
25
  export declare const parseUniExtApiNamespacesJsOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
26
- export declare function matchUTSComponent(tag: string): boolean;
27
- export declare function genUTSClassName(fileName: string, prefix?: string): string;
26
+ export declare function resolveUniTypeScript(): any;