@dcloudio/uni-cli-shared 3.0.0-alpha-4000620240320001 → 3.0.0-alpha-4000620240323001

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 (48) hide show
  1. package/dist/deps.d.ts +0 -2
  2. package/dist/deps.js +0 -3
  3. package/dist/easycom.js +2 -3
  4. package/dist/hbx/alias.js +3 -20
  5. package/dist/hbx/log.js +1 -2
  6. package/dist/index.d.ts +1 -2
  7. package/dist/index.js +1 -3
  8. package/dist/json/app/pages/code.d.ts +1 -1
  9. package/dist/json/mp/index.d.ts +1 -1
  10. package/dist/json/mp/project.js +2 -2
  11. package/dist/json/mp/types.d.ts +1 -1
  12. package/dist/json/uni-x/uniConfig.js +0 -4
  13. package/dist/mp/tags.js +5 -5
  14. package/dist/uni_modules.d.ts +0 -20
  15. package/dist/uni_modules.js +12 -71
  16. package/dist/utils.d.ts +2 -0
  17. package/dist/utils.js +7 -7
  18. package/dist/uts.d.ts +3 -1
  19. package/dist/uts.js +44 -23
  20. package/dist/vite/features.js +27 -27
  21. package/dist/vite/index.d.ts +0 -1
  22. package/dist/vite/plugins/inject.js +2 -2
  23. package/dist/vite/plugins/uts/ext-api.d.ts +1 -2
  24. package/dist/vite/plugins/uts/ext-api.js +5 -4
  25. package/dist/vite/plugins/uts/uni_modules.js +2 -11
  26. package/dist/vite/plugins/vitejs/plugins/asset.js +1 -1
  27. package/dist/vite/plugins/vitejs/plugins/css.js +1 -10
  28. package/dist/vite/utils/ast.js +6 -7
  29. package/dist/vue/index.d.ts +0 -1
  30. package/dist/vue/index.js +1 -3
  31. package/dist/vue/parse.js +7 -8
  32. package/dist/vue/transforms/index.d.ts +0 -1
  33. package/dist/vue/transforms/index.js +0 -1
  34. package/dist/vue/transforms/templateTransformAssetUrl.js +8 -8
  35. package/dist/vue/transforms/templateTransformSrcset.js +7 -7
  36. package/dist/vue/transforms/transformComponent.js +3 -7
  37. package/dist/vue/transforms/transformRef.js +1 -1
  38. package/dist/vue/transforms/transformUTSComponent.js +2 -2
  39. package/dist/vue/transforms/vOn.js +4 -4
  40. package/dist/vue/utils.d.ts +1 -4
  41. package/dist/vue/utils.js +8 -47
  42. package/package.json +16 -16
  43. package/dist/utsUtils.d.ts +0 -2
  44. package/dist/utsUtils.js +0 -44
  45. package/dist/vue/polyfill.d.ts +0 -3
  46. package/dist/vue/polyfill.js +0 -24
  47. package/dist/vue/transforms/transformRefresherSlot.d.ts +0 -8
  48. package/dist/vue/transforms/transformRefresherSlot.js +0 -58
package/dist/deps.d.ts CHANGED
@@ -16,6 +16,4 @@ 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[];
21
19
  };
package/dist/deps.js CHANGED
@@ -3,7 +3,6 @@ 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';
7
6
  exports.API_DEPS_CSS = {
8
7
  showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
9
8
  showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
@@ -37,6 +36,4 @@ exports.COMPONENT_DEPS_CSS = {
37
36
  `${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view.css`,
38
37
  `${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view-column.css`,
39
38
  ],
40
- 'scroll-view': [REFRESHER_CSS],
41
- 'list-view': [RESIZE_SENSOR_CSS, REFRESHER_CSS],
42
39
  };
package/dist/easycom.js CHANGED
@@ -14,7 +14,6 @@ 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");
18
17
  const debugEasycom = (0, debug_1.default)('uni:easycom');
19
18
  const easycoms = [];
20
19
  const easycomsCache = new Map();
@@ -266,8 +265,8 @@ function genUTSComponentPublicInstanceImported(root, fileName) {
266
265
  fileName = (0, utils_1.normalizePath)(path_1.default.relative(root, fileName));
267
266
  }
268
267
  if (fileName.startsWith('@/')) {
269
- return ((0, utsUtils_1.genUTSClassName)(fileName.replace('@/', '')) + 'ComponentPublicInstance');
268
+ return ((0, uts_1.genUTSClassName)(fileName.replace('@/', '')) + 'ComponentPublicInstance');
270
269
  }
271
- return (0, utsUtils_1.genUTSClassName)(fileName) + 'ComponentPublicInstance';
270
+ return (0, uts_1.genUTSClassName)(fileName) + 'ComponentPublicInstance';
272
271
  }
273
272
  exports.genUTSComponentPublicInstanceImported = genUTSComponentPublicInstanceImported;
package/dist/hbx/alias.js CHANGED
@@ -34,21 +34,8 @@ function initModuleAlias() {
34
34
  }
35
35
  if ((0, env_1.isInHBuilderX)()) {
36
36
  // 又是为了复用 HBuilderX 的插件逻辑,硬编码映射
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
- });
37
+ Object.keys(hbxPlugins).forEach((name) => {
38
+ module_alias_1.default.addAlias(name, path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[name]));
52
39
  });
53
40
  // web 平台用了 vite 内置 css 插件,该插件会加载预编译器如scss、less等,需要转向到 HBuilderX 的对应编译器插件
54
41
  if (process.env.UNI_PLATFORM === 'h5' ||
@@ -104,11 +91,7 @@ exports.moduleAliasFormatter = {
104
91
  format(msg) {
105
92
  let lang = '';
106
93
  let preprocessor = '';
107
- if (msg.includes(`"pug"`)) {
108
- lang = 'pug';
109
- preprocessor = 'compile-pug-cli';
110
- }
111
- else if (msg.includes(`"sass"`)) {
94
+ if (msg.includes(`"sass"`)) {
112
95
  lang = 'sass';
113
96
  preprocessor = 'compile-dart-sass';
114
97
  }
package/dist/hbx/log.js CHANGED
@@ -7,7 +7,6 @@ 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");
11
10
  const shared_1 = require("@vue/shared");
12
11
  const utils_1 = require("../utils");
13
12
  const constants_1 = require("../constants");
@@ -118,7 +117,7 @@ function buildErrorMessage(err, args = [], includeStack = true) {
118
117
  constants_1.EXTNAME_VUE_RE.test(err.id)) {
119
118
  try {
120
119
  const ast = (0, ast_1.parseVue)(fs_1.default.readFileSync(err.id, 'utf8'), []);
121
- const scriptNode = ast.children.find((node) => node.type === compiler_core_1.NodeTypes.ELEMENT && node.tag === 'script');
120
+ const scriptNode = ast.children.find((node) => node.type === 1 /* NodeTypes.ELEMENT */ && node.tag === 'script');
122
121
  if (scriptNode) {
123
122
  const scriptLoc = scriptNode.loc;
124
123
  args.push(picocolors_1.default.yellow(pad((0, utils_2.generateCodeFrame)(scriptLoc.source, err.loc))));
package/dist/index.d.ts CHANGED
@@ -21,8 +21,7 @@ export * from './esbuild';
21
21
  export * from './resolve';
22
22
  export * from './scripts';
23
23
  export * from './platform';
24
- export * from './utsUtils';
25
- export { parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, } from './uni_modules';
24
+ export { parseUniExtApis, parseInjects, Define, DefineOptions, Defines, } from './uni_modules';
26
25
  export { M } from './messages';
27
26
  export * from './exports';
28
27
  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.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = void 0;
17
+ exports.checkUpdate = exports.M = 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,11 +38,9 @@ __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);
42
41
  var uni_modules_1 = require("./uni_modules");
43
42
  Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
44
43
  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; } });
46
44
  var messages_1 = require("./messages");
47
45
  Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
48
46
  __exportStar(require("./exports"), exports);
@@ -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 = "\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";
2
+ export declare const polyfillCode: string;
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, ComponentJson } from './types';
2
+ export { AppJson } from './types';
3
3
  export { mergeMiniProgramAppJson, parseMiniProgramPagesJson } from './pages';
4
4
  export { parseMiniProgramProjectJson } from './project';
@@ -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' | 'isolated';
5
+ styleIsolation?: 'apply-shared' | 'shared';
6
6
  }
7
7
  interface ShareWindowOptions {
8
8
  navigationBarBackgroundColor?: string;
@@ -12,10 +12,6 @@ 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
- }
19
15
  // TODO 待支持分包
20
16
  return JSON.stringify(config);
21
17
  }
package/dist/mp/tags.js CHANGED
@@ -103,12 +103,12 @@ exports.HTML_TO_MINI_PROGRAM_TAGS = {
103
103
  dialog: 'view',
104
104
  summary: 'view',
105
105
  // progress: 'progress',
106
- meter: 'progress', // todo
107
- head: 'view', // todo
108
- meta: 'view', // todo
109
- base: 'text', // todo
106
+ meter: 'progress',
107
+ head: 'view',
108
+ meta: 'view',
109
+ base: 'text',
110
110
  // 'map': 'image', // TODO不是很恰当
111
- area: 'navigator', // j结合map使用
111
+ area: 'navigator',
112
112
  script: 'view',
113
113
  noscript: 'view',
114
114
  embed: 'view',
@@ -21,11 +21,6 @@ export declare function getUniExtApiProviders(): {
21
21
  name?: string | undefined;
22
22
  servicePlugin?: string | undefined;
23
23
  }[];
24
- export declare function getUniExtApiProviderRegisters(): {
25
- name: string;
26
- service: string;
27
- class: string;
28
- }[];
29
24
  export declare function parseUniExtApis(vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language?: UTSTargetLanguage): Injects;
30
25
  export type Injects = {
31
26
  [name: string]: string | [string, string] | [string, string, DefineOptions['app']] | false;
@@ -52,18 +47,3 @@ export type Injects = {
52
47
  * @returns
53
48
  */
54
49
  export declare function parseInjects(vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage, source: string, uniModuleRootDir: string, exports?: Exports): Injects;
55
- /**
56
- * @private
57
- */
58
- export declare const camelize: (str: string) => string;
59
- /**
60
- * @private
61
- */
62
- export declare const capitalize: (str: string) => string;
63
- /**
64
- * 解析 UTS 类型的模块依赖列表
65
- * @param deps
66
- * @param inputDir
67
- * @returns
68
- */
69
- export declare function parseUTSModuleDeps(deps: string[], inputDir: string): string[];
@@ -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.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.getUniExtApiProviders = void 0;
6
+ exports.parseInjects = exports.parseUniExtApis = 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"));
@@ -12,24 +12,6 @@ function getUniExtApiProviders() {
12
12
  return extApiProviders;
13
13
  }
14
14
  exports.getUniExtApiProviders = getUniExtApiProviders;
15
- function getUniExtApiProviderRegisters() {
16
- const result = [];
17
- extApiProviders.forEach((provider) => {
18
- if (provider.name && provider.service) {
19
- result.push({
20
- name: provider.name,
21
- service: provider.service,
22
- class: `uts.sdk.modules.${(0, exports.camelize)(provider.plugin)}.${(0, exports.capitalize)((0, exports.camelize)('uni-ext-api-' +
23
- provider.service +
24
- '-' +
25
- provider.name +
26
- '-provider'))}`,
27
- });
28
- }
29
- });
30
- return result;
31
- }
32
- exports.getUniExtApiProviderRegisters = getUniExtApiProviderRegisters;
33
15
  function parseUniExtApis(vite = true, platform, language = 'javascript') {
34
16
  if (!process.env.UNI_INPUT_DIR) {
35
17
  return {};
@@ -127,11 +109,6 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
127
109
  source = `${source}/utssdk/index.uts`;
128
110
  }
129
111
  }
130
- else if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
131
- if (fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-js', 'index.uts'))) {
132
- source = `${source}/utssdk/app-js/index.uts`;
133
- }
134
- }
135
112
  for (const key in rootDefines) {
136
113
  Object.assign(injects, parseInject(vite, platform, language, source, 'uni', rootDefines[key], hasPlatformFile));
137
114
  }
@@ -180,24 +157,19 @@ function parseInject(vite = true, platform, language, source, globalObject, defi
180
157
  if (p === 'app') {
181
158
  const appOptions = defineOptions.app;
182
159
  if (isPlainObject(appOptions)) {
183
- // js engine 下且存在 app-js,不检查
184
- const skipCheck = process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js' &&
185
- source.includes('app-js');
186
- if (!skipCheck) {
187
- if (language === 'javascript') {
188
- if (appOptions.js === false) {
189
- return;
190
- }
160
+ if (language === 'javascript') {
161
+ if (appOptions.js === false) {
162
+ return;
191
163
  }
192
- else if (language === 'kotlin') {
193
- if (appOptions.kotlin === false) {
194
- return;
195
- }
164
+ }
165
+ else if (language === 'kotlin') {
166
+ if (appOptions.kotlin === false) {
167
+ return;
196
168
  }
197
- else if (language === 'swift') {
198
- if (appOptions.swift === false) {
199
- return;
200
- }
169
+ }
170
+ else if (language === 'swift') {
171
+ if (appOptions.swift === false) {
172
+ return;
201
173
  }
202
174
  }
203
175
  }
@@ -225,34 +197,3 @@ const toTypeString = (value) => objectToString.call(value);
225
197
  function isPlainObject(val) {
226
198
  return toTypeString(val) === '[object Object]';
227
199
  }
228
- const cacheStringFunction = (fn) => {
229
- const cache = Object.create(null);
230
- return ((str) => {
231
- const hit = cache[str];
232
- return hit || (cache[str] = fn(str));
233
- });
234
- };
235
- const camelizeRE = /-(\w)/g;
236
- /**
237
- * @private
238
- */
239
- exports.camelize = cacheStringFunction((str) => {
240
- return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
241
- });
242
- /**
243
- * @private
244
- */
245
- exports.capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
246
- /**
247
- * 解析 UTS 类型的模块依赖列表
248
- * @param deps
249
- * @param inputDir
250
- * @returns
251
- */
252
- function parseUTSModuleDeps(deps, inputDir) {
253
- const modulesDir = path_1.default.resolve(inputDir, 'uni_modules');
254
- return deps.filter((dep) => {
255
- return fs_extra_1.default.existsSync(path_1.default.resolve(modulesDir, dep, 'utssdk'));
256
- });
257
- }
258
- exports.parseUTSModuleDeps = parseUTSModuleDeps;
package/dist/utils.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export { default as hash } from 'hash-sum';
2
2
  import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
3
3
  import { ParserPlugin } from '@babel/parser';
4
+ export declare const version: any;
4
5
  export { camelize, capitalize, isArray } from '@vue/shared';
6
+ export declare let isRunningWithYarnPnp: boolean;
5
7
  export declare const isWindows: boolean;
6
8
  export declare function normalizePath(id: string): string;
7
9
  export declare function checkElementNodeTag(node: RootNode | TemplateChildNode | null | undefined, tag: string): node is ElementNode;
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.isArray = exports.capitalize = exports.camelize = 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.isRunningWithYarnPnp = exports.isArray = exports.capitalize = exports.camelize = exports.version = 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");
16
15
  const platform_1 = require("./platform");
17
16
  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
- // export let isRunningWithYarnPnp: boolean
24
- // try {
25
- // isRunningWithYarnPnp = Boolean(require('pnpapi'))
26
- // } catch {}
23
+ try {
24
+ exports.isRunningWithYarnPnp = Boolean(require('pnpapi'));
25
+ }
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 === compiler_core_1.NodeTypes.ELEMENT && node.tag === tag;
33
+ return !!node && node.type === 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
3
  import * as UTSCompiler from '@dcloudio/uni-uts-v1';
4
- import type { EasycomMatcher } from './easycom';
4
+ import { type EasycomMatcher } from './easycom';
5
5
  /**
6
6
  * 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
7
7
  * @param id
@@ -23,3 +23,5 @@ 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;
package/dist/uts.js CHANGED
@@ -3,14 +3,15 @@ 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.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.isUTSComponent = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
7
- // 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
6
+ exports.genUTSClassName = exports.matchUTSComponent = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.isUTSComponent = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
8
7
  const fs_1 = __importDefault(require("fs"));
9
8
  const path_1 = __importDefault(require("path"));
10
9
  const fast_glob_1 = __importDefault(require("fast-glob"));
11
10
  const hbx_1 = require("./hbx");
12
11
  const utils_1 = require("./utils");
12
+ const easycom_1 = require("./easycom");
13
13
  const uni_modules_1 = require("./uni_modules");
14
+ // 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
14
15
  function once(fn, ctx = null) {
15
16
  let res;
16
17
  return ((...args) => {
@@ -35,15 +36,6 @@ function resolveUTSAppModule(id, importer, includeUTSSDK = true) {
35
36
  if (parentDir === 'uni_modules' ||
36
37
  (includeUTSSDK && parentDir === 'utssdk')) {
37
38
  const basedir = parentDir === 'uni_modules' ? 'utssdk' : '';
38
- if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
39
- // js engine
40
- if (parentDir === 'uni_modules') {
41
- const appJsIndex = path_1.default.resolve(id, basedir, 'app-js', 'index.uts');
42
- if (fs_1.default.existsSync(appJsIndex)) {
43
- return appJsIndex;
44
- }
45
- }
46
- }
47
39
  if (fs_1.default.existsSync(path_1.default.resolve(id, basedir, 'index.uts'))) {
48
40
  return id;
49
41
  }
@@ -112,18 +104,8 @@ function resolveUTSCompiler() {
112
104
  });
113
105
  }
114
106
  catch (e) {
115
- let utsCompilerVersion = '';
116
- try {
117
- utsCompilerVersion = require('../package.json').version;
118
- }
119
- catch (e) {
120
- try {
121
- // vue2
122
- utsCompilerVersion = require('../../package.json').version;
123
- }
124
- catch (e) { }
125
- }
126
- if (utsCompilerVersion.startsWith('2.0.')) {
107
+ let utsCompilerVersion = utils_1.version;
108
+ if (utils_1.version.startsWith('2.0.')) {
127
109
  utsCompilerVersion = '^3.0.0-alpha-3060920221117001';
128
110
  }
129
111
  console.error((0, utils_1.installDepTips)('devDependencies', '@dcloudio/uni-uts-v1', utsCompilerVersion));
@@ -272,3 +254,42 @@ exports.parseUniExtApiNamespacesJsOnce = once((platform, language) => {
272
254
  });
273
255
  return namespaces;
274
256
  });
257
+ function matchUTSComponent(tag) {
258
+ const source = (0, easycom_1.matchEasycom)(tag);
259
+ return !!(source && source.includes('uts-proxy'));
260
+ }
261
+ exports.matchUTSComponent = matchUTSComponent;
262
+ function genUTSClassName(fileName, prefix = 'Gen') {
263
+ return (prefix +
264
+ (0, utils_1.capitalize)((0, utils_1.camelize)(verifySymbol((0, utils_1.removeExt)((0, utils_1.normalizeNodeModules)(fileName)
265
+ .replace(/[\/|_]/g, '-')
266
+ .replace(/-+/g, '-'))))));
267
+ }
268
+ exports.genUTSClassName = genUTSClassName;
269
+ function isValidStart(c) {
270
+ return !!c.match(/^[A-Za-z_-]$/);
271
+ }
272
+ function isValidContinue(c) {
273
+ return !!c.match(/^[A-Za-z0-9_-]$/);
274
+ }
275
+ function verifySymbol(s) {
276
+ const chars = Array.from(s);
277
+ if (isValidStart(chars[0]) && chars.slice(1).every(isValidContinue)) {
278
+ return s;
279
+ }
280
+ const buf = [];
281
+ let hasStart = false;
282
+ for (const c of chars) {
283
+ if (!hasStart && isValidStart(c)) {
284
+ hasStart = true;
285
+ buf.push(c);
286
+ }
287
+ else if (isValidContinue(c)) {
288
+ buf.push(c);
289
+ }
290
+ }
291
+ if (buf.length === 0) {
292
+ buf.push('_');
293
+ }
294
+ return buf.join('');
295
+ }
@@ -146,35 +146,35 @@ function initFeatures(options) {
146
146
  const { wx, wxs, rpx, nvue, uniCloud, i18nEn, i18nEs, i18nFr, i18nZhHans, i18nZhHant, i18nLocale, vueOptionsApi, vueProdDevTools, pages, tabBar, tabBarMidButton, promise, longpress, routerMode, topWindow, leftWindow, rightWindow, navigationBar, pullDownRefresh, navigationBarButtons, navigationBarSearchInput, navigationBarTransparent, } = (0, shared_1.extend)(initManifestFeature(options), initPagesFeature(options), initProjectFeature(options));
147
147
  const features = {
148
148
  // vue
149
- __VUE_OPTIONS_API__: vueOptionsApi, // enable/disable Options API support, default: true
150
- __VUE_PROD_DEVTOOLS__: vueProdDevTools, // enable/disable devtools support in production, default: false
149
+ __VUE_OPTIONS_API__: vueOptionsApi,
150
+ __VUE_PROD_DEVTOOLS__: vueProdDevTools,
151
151
  // uni
152
- __UNI_FEATURE_WX__: wx, // 是否启用小程序的组件实例 API,如:selectComponent 等(uni-core/src/service/plugin/appConfig)
153
- __UNI_FEATURE_WXS__: wxs, // 是否启用 wxs 支持,如:getComponentDescriptor 等(uni-core/src/view/plugin/appConfig)
154
- __UNI_FEATURE_RPX__: rpx, // 是否启用运行时 rpx 支持
155
- __UNI_FEATURE_PROMISE__: promise, // 是否启用旧版本的 promise 支持(即返回[err,res]的格式),默认返回标准
156
- __UNI_FEATURE_LONGPRESS__: longpress, // 是否启用longpress
157
- __UNI_FEATURE_I18N_EN__: i18nEn, // 是否启用en
158
- __UNI_FEATURE_I18N_ES__: i18nEs, // 是否启用es
159
- __UNI_FEATURE_I18N_FR__: i18nFr, // 是否启用fr
160
- __UNI_FEATURE_I18N_ZH_HANS__: i18nZhHans, // 是否启用zh_Hans
161
- __UNI_FEATURE_I18N_ZH_HANT__: i18nZhHant, // 是否启用zh_Hant
152
+ __UNI_FEATURE_WX__: wx,
153
+ __UNI_FEATURE_WXS__: wxs,
154
+ __UNI_FEATURE_RPX__: rpx,
155
+ __UNI_FEATURE_PROMISE__: promise,
156
+ __UNI_FEATURE_LONGPRESS__: longpress,
157
+ __UNI_FEATURE_I18N_EN__: i18nEn,
158
+ __UNI_FEATURE_I18N_ES__: i18nEs,
159
+ __UNI_FEATURE_I18N_FR__: i18nFr,
160
+ __UNI_FEATURE_I18N_ZH_HANS__: i18nZhHans,
161
+ __UNI_FEATURE_I18N_ZH_HANT__: i18nZhHant,
162
162
  // 以下特性,编译器已自动识别是否需要启用
163
- __UNI_FEATURE_UNI_CLOUD__: uniCloud, // 是否启用uniCloud
164
- __UNI_FEATURE_I18N_LOCALE__: i18nLocale, // 是否启用i18n
165
- __UNI_FEATURE_NVUE__: nvue, // 是否启用nvue
166
- __UNI_FEATURE_ROUTER_MODE__: routerMode, // 路由模式
167
- __UNI_FEATURE_PAGES__: pages, // 是否多页面
168
- __UNI_FEATURE_TABBAR__: tabBar, // 是否包含tabBar
169
- __UNI_FEATURE_TABBAR_MIDBUTTON__: tabBarMidButton, // 是否包含midButton
170
- __UNI_FEATURE_TOPWINDOW__: topWindow, // 是否包含topWindow
171
- __UNI_FEATURE_LEFTWINDOW__: leftWindow, // 是否包含leftWindow
172
- __UNI_FEATURE_RIGHTWINDOW__: rightWindow, // 是否包含rightWindow
173
- __UNI_FEATURE_RESPONSIVE__: topWindow || leftWindow || rightWindow, // 是否启用响应式
174
- __UNI_FEATURE_NAVIGATIONBAR__: navigationBar, // 是否启用标题栏
175
- __UNI_FEATURE_PULL_DOWN_REFRESH__: pullDownRefresh, // 是否启用下拉刷新
176
- __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__: navigationBarButtons, // 是否启用标题栏按钮
177
- __UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__: navigationBarSearchInput, // 是否启用标题栏搜索框
163
+ __UNI_FEATURE_UNI_CLOUD__: uniCloud,
164
+ __UNI_FEATURE_I18N_LOCALE__: i18nLocale,
165
+ __UNI_FEATURE_NVUE__: nvue,
166
+ __UNI_FEATURE_ROUTER_MODE__: routerMode,
167
+ __UNI_FEATURE_PAGES__: pages,
168
+ __UNI_FEATURE_TABBAR__: tabBar,
169
+ __UNI_FEATURE_TABBAR_MIDBUTTON__: tabBarMidButton,
170
+ __UNI_FEATURE_TOPWINDOW__: topWindow,
171
+ __UNI_FEATURE_LEFTWINDOW__: leftWindow,
172
+ __UNI_FEATURE_RIGHTWINDOW__: rightWindow,
173
+ __UNI_FEATURE_RESPONSIVE__: topWindow || leftWindow || rightWindow,
174
+ __UNI_FEATURE_NAVIGATIONBAR__: navigationBar,
175
+ __UNI_FEATURE_PULL_DOWN_REFRESH__: pullDownRefresh,
176
+ __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__: navigationBarButtons,
177
+ __UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__: navigationBarSearchInput,
178
178
  __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__: navigationBarTransparent, // 是否启用透明标题栏
179
179
  };
180
180
  // ssr nodejs features
@@ -22,7 +22,6 @@ interface UniVitePluginUniOptions {
22
22
  isCustomElement?: ParserOptions['isCustomElement'];
23
23
  directiveTransforms?: CompilerOptions['directiveTransforms'];
24
24
  nodeTransforms?: CompilerOptions['nodeTransforms'];
25
- whitespace?: CompilerOptions['whitespace'];
26
25
  };
27
26
  jsxOptions?: {
28
27
  babelPlugins?: any[];
@@ -12,7 +12,7 @@ const shared_1 = require("@vue/shared");
12
12
  const magic_string_1 = __importDefault(require("magic-string"));
13
13
  const utils_1 = require("../utils");
14
14
  const debugInject = (0, debug_1.default)('uni:inject');
15
- // const debugInjectTry = debug('uni:inject-try')
15
+ const debugInjectTry = (0, debug_1.default)('uni:inject-try');
16
16
  function uniViteInjectPlugin(name, options) {
17
17
  if (!options)
18
18
  throw new Error('Missing options');
@@ -49,7 +49,7 @@ function uniViteInjectPlugin(name, options) {
49
49
  return null;
50
50
  if (!(0, utils_1.isJsFile)(id))
51
51
  return null;
52
- // debugInjectTry(id)
52
+ debugInjectTry(id);
53
53
  if (code.search(firstpass) === -1)
54
54
  return null;
55
55
  if (path_1.sep !== '/')
@@ -1,6 +1,5 @@
1
1
  import type { Plugin } from 'vite';
2
- import { Injects, parseUniExtApis } from '../../../uni_modules';
3
- export declare const parseUniExtApisOnce: typeof parseUniExtApis;
2
+ import { Injects } from '../../../uni_modules';
4
3
  export declare function uniUTSExtApiReplace(): Plugin;
5
4
  /**
6
5
  * { 'uni.getBatteryInfo': ['@/uni_modules/uni-getbatteryinfo/utssdk/web/index.uts','getBatteryInfo'] }