@dcloudio/uni-cli-shared 3.0.0-alpha-3090420231023001 → 3.0.0-alpha-3090620231030001

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.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseInjects = exports.parseUniExtApis = void 0;
7
+ // 重要:此文件编译后的js,需同步至 vue2 编译器中 uni-cli-shared/lib/uts/uni_modules.js
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
10
  function parseUniExtApis(vite = true, platform, language = 'javascript') {
@@ -63,6 +64,9 @@ exports.parseUniExtApis = parseUniExtApis;
63
64
  * @returns
64
65
  */
65
66
  function parseInjects(vite = true, platform, language, source, uniModuleRootDir, exports = {}) {
67
+ if (platform === 'app-plus') {
68
+ platform = 'app';
69
+ }
66
70
  let rootDefines = {};
67
71
  Object.keys(exports).forEach((name) => {
68
72
  if (name.startsWith('uni')) {
@@ -71,10 +75,17 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
71
75
  });
72
76
  const injects = {};
73
77
  if (Object.keys(rootDefines).length) {
74
- const hasPlatformFile = uniModuleRootDir
78
+ let hasPlatformFile = uniModuleRootDir
75
79
  ? fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'index.uts')) ||
76
80
  fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', platform))
77
81
  : true;
82
+ if (!hasPlatformFile) {
83
+ if (platform === 'app') {
84
+ hasPlatformFile =
85
+ fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-android')) ||
86
+ fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-ios'));
87
+ }
88
+ }
78
89
  for (const key in rootDefines) {
79
90
  Object.assign(injects, parseInject(vite, platform, language, source, 'uni', rootDefines[key], hasPlatformFile));
80
91
  }
package/dist/utils.d.ts CHANGED
@@ -2,6 +2,7 @@ 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
4
  export declare const version: any;
5
+ export { camelize, capitalize, isArray } from '@vue/shared';
5
6
  export declare let isRunningWithYarnPnp: boolean;
6
7
  export declare const isWindows: boolean;
7
8
  export declare function normalizePath(id: string): string;
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.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.version = exports.hash = void 0;
6
+ 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"));
@@ -14,6 +14,11 @@ Object.defineProperty(exports, "hash", { enumerable: true, get: function () { re
14
14
  const constants_1 = require("./constants");
15
15
  const platform_1 = require("./platform");
16
16
  exports.version = require('../package.json').version;
17
+ // 专为 uts.ts 服务
18
+ var shared_2 = require("@vue/shared");
19
+ Object.defineProperty(exports, "camelize", { enumerable: true, get: function () { return shared_2.camelize; } });
20
+ Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return shared_2.capitalize; } });
21
+ Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return shared_2.isArray; } });
17
22
  try {
18
23
  exports.isRunningWithYarnPnp = Boolean(require('pnpapi'));
19
24
  }
package/dist/uts.js CHANGED
@@ -7,11 +7,20 @@ exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce =
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fast_glob_1 = __importDefault(require("fast-glob"));
10
- const shared_1 = require("@vue/shared");
11
10
  const hbx_1 = require("./hbx");
12
11
  const utils_1 = require("./utils");
13
- const uni_shared_1 = require("@dcloudio/uni-shared");
14
12
  const uni_modules_1 = require("./uni_modules");
13
+ // 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
14
+ function once(fn, ctx = null) {
15
+ let res;
16
+ return ((...args) => {
17
+ if (fn) {
18
+ res = fn.apply(ctx, args);
19
+ fn = null;
20
+ }
21
+ return res;
22
+ });
23
+ }
15
24
  /**
16
25
  * 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
17
26
  * @param id
@@ -114,7 +123,7 @@ function parseUTSComponent(name, type) {
114
123
  const meta = utsComponents.get(name);
115
124
  if (meta) {
116
125
  const namespace = meta[type === 'swift' ? 'swiftModule' : 'kotlinPackage'] || '';
117
- const className = (0, shared_1.capitalize)((0, shared_1.camelize)(name)) + 'Component';
126
+ const className = (0, utils_1.capitalize)((0, utils_1.camelize)(name)) + 'Component';
118
127
  return {
119
128
  className,
120
129
  namespace,
@@ -209,16 +218,16 @@ function prefix(id) {
209
218
  return id;
210
219
  }
211
220
  function parseKotlinPackageWithPluginId(id, is_uni_modules) {
212
- return 'uts.sdk.' + (is_uni_modules ? 'modules.' : '') + (0, shared_1.camelize)(prefix(id));
221
+ return 'uts.sdk.' + (is_uni_modules ? 'modules.' : '') + (0, utils_1.camelize)(prefix(id));
213
222
  }
214
223
  exports.parseKotlinPackageWithPluginId = parseKotlinPackageWithPluginId;
215
224
  function parseSwiftPackageWithPluginId(id, is_uni_modules) {
216
225
  return ('UTSSDK' +
217
226
  (is_uni_modules ? 'Modules' : '') +
218
- (0, shared_1.capitalize)((0, shared_1.camelize)(prefix(id))));
227
+ (0, utils_1.capitalize)((0, utils_1.camelize)(prefix(id))));
219
228
  }
220
229
  exports.parseSwiftPackageWithPluginId = parseSwiftPackageWithPluginId;
221
- exports.parseUniExtApiNamespacesOnce = (0, uni_shared_1.once)((platform, language) => {
230
+ exports.parseUniExtApiNamespacesOnce = once((platform, language) => {
222
231
  const extApis = (0, exports.parseUniExtApiNamespacesJsOnce)(platform, language);
223
232
  const namespaces = {};
224
233
  Object.keys(extApis).forEach((name) => {
@@ -235,12 +244,12 @@ exports.parseUniExtApiNamespacesOnce = (0, uni_shared_1.once)((platform, languag
235
244
  });
236
245
  return namespaces;
237
246
  });
238
- exports.parseUniExtApiNamespacesJsOnce = (0, uni_shared_1.once)((platform, language) => {
247
+ exports.parseUniExtApiNamespacesJsOnce = once((platform, language) => {
239
248
  const extApis = (0, uni_modules_1.parseUniExtApis)(true, platform, language);
240
249
  const namespaces = {};
241
250
  Object.keys(extApis).forEach((name) => {
242
251
  const options = extApis[name];
243
- if ((0, shared_1.isArray)(options) && options.length >= 2) {
252
+ if ((0, utils_1.isArray)(options) && options.length >= 2) {
244
253
  namespaces[name.replace('uni.', '')] = [options[0], options[1]];
245
254
  }
246
255
  });
@@ -5,8 +5,8 @@ export * from './mainJs';
5
5
  export * from './jsonJs';
6
6
  export * from './console';
7
7
  export * from './dynamicImportPolyfill';
8
- export * from './uts/app';
9
- export * from './uts/h5';
8
+ export * from './uts/uni_modules';
9
+ export * from './uts/uvue';
10
10
  export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
11
11
  export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, } from './vitejs/plugins/css';
12
12
  export { generateCodeFrame, locToStartAndEnd } from './vitejs/utils';
@@ -22,8 +22,8 @@ __exportStar(require("./mainJs"), exports);
22
22
  __exportStar(require("./jsonJs"), exports);
23
23
  __exportStar(require("./console"), exports);
24
24
  __exportStar(require("./dynamicImportPolyfill"), exports);
25
- __exportStar(require("./uts/app"), exports);
26
- __exportStar(require("./uts/h5"), exports);
25
+ __exportStar(require("./uts/uni_modules"), exports);
26
+ __exportStar(require("./uts/uvue"), exports);
27
27
  var asset_1 = require("./vitejs/plugins/asset");
28
28
  Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
29
29
  Object.defineProperty(exports, "parseAssets", { enumerable: true, get: function () { return asset_1.parseAssets; } });
@@ -2,7 +2,8 @@ import type { Plugin } from 'vite';
2
2
  interface UniUTSPluginOptions {
3
3
  x?: boolean;
4
4
  extApis?: Record<string, [string, string]>;
5
+ isSingleThread?: boolean;
5
6
  }
6
7
  export declare const utsPlugins: Set<string>;
7
- export declare function uniUTSAppPlugin(options?: UniUTSPluginOptions): Plugin;
8
+ export declare function uniUTSUniModulesPlugin(options?: UniUTSPluginOptions): Plugin;
8
9
  export {};
@@ -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.uniUTSAppPlugin = exports.utsPlugins = void 0;
6
+ exports.uniUTSUniModulesPlugin = exports.utsPlugins = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const uni_shared_1 = require("@dcloudio/uni-shared");
9
9
  const uts_1 = require("../../../uts");
@@ -14,10 +14,10 @@ function isUTSProxy(id) {
14
14
  }
15
15
  const utsModuleCaches = new Map();
16
16
  exports.utsPlugins = new Set();
17
- function uniUTSAppPlugin(options = {}) {
17
+ function uniUTSUniModulesPlugin(options = {}) {
18
18
  process.env.UNI_UTS_USING_ROLLUP = 'true';
19
19
  return {
20
- name: 'uni:uts',
20
+ name: 'uni:uts-uni_modules',
21
21
  apply: 'build',
22
22
  enforce: 'pre',
23
23
  resolveId(id, importer) {
@@ -66,6 +66,7 @@ function uniUTSAppPlugin(options = {}) {
66
66
  exports.utsPlugins.add(path_1.default.basename(pluginDir));
67
67
  return (0, uts_1.resolveUTSCompiler)().compile(pluginDir, {
68
68
  isX: !!options.x,
69
+ isSingleThread: !!options.isSingleThread,
69
70
  isPlugin: true,
70
71
  extApis: options.extApis,
71
72
  sourceMap: process.env.NODE_ENV === 'development',
@@ -86,4 +87,4 @@ function uniUTSAppPlugin(options = {}) {
86
87
  },
87
88
  };
88
89
  }
89
- exports.uniUTSAppPlugin = uniUTSAppPlugin;
90
+ exports.uniUTSUniModulesPlugin = uniUTSUniModulesPlugin;
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function uniUTSUVueJavaScriptPlugin(options?: {}): Plugin;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uniUTSJsPlugin = void 0;
3
+ exports.uniUTSUVueJavaScriptPlugin = void 0;
4
4
  const vue_1 = require("../../../vue");
5
- function uniUTSJsPlugin(options = {}) {
5
+ function uniUTSUVueJavaScriptPlugin(options = {}) {
6
6
  process.env.UNI_UTS_USING_ROLLUP = 'true';
7
7
  return {
8
- name: 'uni:uts',
8
+ name: 'uni:uts-uvue',
9
9
  enforce: 'pre',
10
10
  configResolved(config) {
11
11
  // 移除自带的 esbuild 处理 ts 文件
@@ -30,4 +30,4 @@ function uniUTSJsPlugin(options = {}) {
30
30
  },
31
31
  };
32
32
  }
33
- exports.uniUTSJsPlugin = uniUTSJsPlugin;
33
+ exports.uniUTSUVueJavaScriptPlugin = uniUTSUVueJavaScriptPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3090420231023001",
3
+ "version": "3.0.0-alpha-3090620231030001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "@babel/core": "^7.21.3",
26
26
  "@babel/parser": "^7.16.4",
27
27
  "@babel/types": "^7.20.7",
28
- "@dcloudio/uni-i18n": "3.0.0-alpha-3090420231023001",
29
- "@dcloudio/uni-shared": "3.0.0-alpha-3090420231023001",
28
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3090620231030001",
29
+ "@dcloudio/uni-shared": "3.0.0-alpha-3090620231030001",
30
30
  "@intlify/core-base": "9.1.9",
31
31
  "@intlify/shared": "9.1.9",
32
32
  "@intlify/vue-devtools": "9.1.9",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
66
66
  "devDependencies": {
67
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-3090420231023001",
67
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-3090620231030001",
68
68
  "@types/babel__core": "^7.1.19",
69
69
  "@types/debug": "^4.1.7",
70
70
  "@types/estree": "^0.0.51",
@@ -1,2 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- export declare function uniUTSJsPlugin(options?: {}): Plugin;