@dcloudio/uni-cli-shared 3.0.0-alpha-4060720250515001 → 3.0.0-alpha-4070120250530001

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.
package/dist/uts.d.ts CHANGED
@@ -17,6 +17,8 @@ interface UTSComponentMeta {
17
17
  source: string;
18
18
  kotlinPackage: string;
19
19
  swiftModule: string;
20
+ kotlinNamespace: string;
21
+ swiftNamespace: string;
20
22
  }
21
23
  interface UTSCustomElementMeta extends UTSComponentMeta {
22
24
  exports: [string][];
@@ -46,6 +48,7 @@ export declare function initUTSCustomElements(inputDir: string, platform: UniApp
46
48
  export declare function parseCustomElementExports(filePath: string, unimport?: Unimport): Promise<Import[]>;
47
49
  export declare function parseKotlinPackageWithPluginId(id: string, is_uni_modules: boolean): string;
48
50
  export declare function parseSwiftPackageWithPluginId(id: string, is_uni_modules: boolean): string;
51
+ export declare function parseSwiftModuleWithPluginId(id: string, is_uni_modules: boolean): string;
49
52
  export type UTSTargetLanguage = typeof process.env.UNI_UTS_TARGET_LANGUAGE;
50
53
  export declare const parseUniExtApiNamespacesOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
51
54
  export declare const parseUniExtApiNamespacesJsOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
package/dist/uts.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.isUniHelpers = exports.isUTSProxy = exports.tscOutDir = exports.uvueOutDir = exports.genUniExtApiDeclarationFileOnce = exports.initUTSSwiftAutoImportsOnce = exports.initUTSKotlinAutoImportsOnce = exports.resolveUniTypeScript = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.parseCustomElementExports = exports.initUTSCustomElements = exports.initUTSComponents = exports.parseUTSCustomElement = exports.parseUTSComponent = exports.getUTSCustomElementAutoImports = exports.getUTSComponentAutoImports = exports.getUTSCustomElement = exports.isUTSCustomElement = exports.getUTSPluginCustomElements = exports.getUTSCustomElements = exports.clearUTSCustomElements = exports.isUTSComponent = exports.clearUTSComponents = exports.getUTSCustomElementsExports = exports.resolveUTSCompilerVersion = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
6
+ exports.isUniHelpers = exports.isUTSProxy = exports.tscOutDir = exports.uvueOutDir = exports.genUniExtApiDeclarationFileOnce = exports.initUTSSwiftAutoImportsOnce = exports.initUTSKotlinAutoImportsOnce = exports.resolveUniTypeScript = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftModuleWithPluginId = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.parseCustomElementExports = exports.initUTSCustomElements = exports.initUTSComponents = exports.parseUTSCustomElement = exports.parseUTSComponent = exports.getUTSCustomElementAutoImports = exports.getUTSComponentAutoImports = exports.getUTSCustomElement = exports.isUTSCustomElement = exports.getUTSPluginCustomElements = exports.getUTSCustomElements = exports.clearUTSCustomElements = exports.isUTSComponent = exports.clearUTSComponents = exports.getUTSCustomElementsExports = exports.resolveUTSCompilerVersion = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
7
7
  // 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -259,7 +259,7 @@ exports.getUTSCustomElementAutoImports = getUTSCustomElementAutoImports;
259
259
  function parseUTSComponent(name, type) {
260
260
  const meta = utsComponents.get(name);
261
261
  if (meta) {
262
- const namespace = meta[type === 'swift' ? 'swiftModule' : 'kotlinPackage'] || '';
262
+ const namespace = meta[type === 'swift' ? 'swiftNamespace' : 'kotlinNamespace'] || '';
263
263
  const className = (0, utils_1.capitalize)((0, utils_1.camelize)(name)) + 'Component';
264
264
  return {
265
265
  className,
@@ -272,7 +272,7 @@ exports.parseUTSComponent = parseUTSComponent;
272
272
  function parseUTSCustomElement(name, type) {
273
273
  const meta = getUTSCustomElement(name);
274
274
  if (meta) {
275
- const namespace = meta[type === 'swift' ? 'swiftModule' : 'kotlinPackage'] || '';
275
+ const namespace = meta[type === 'swift' ? 'swiftNamespace' : 'kotlinNamespace'] || '';
276
276
  const className = (0, utils_1.capitalize)((0, utils_1.camelize)(name)) + 'Element';
277
277
  return {
278
278
  className,
@@ -316,10 +316,15 @@ function initUTSComponents(inputDir, platform) {
316
316
  (0, utils_1.normalizePath)(isApp
317
317
  ? path_1.default.relative(inputDir, is_uni_modules_utssdk ? path_1.default.dirname(dir) : dir)
318
318
  : path_1.default.relative(inputDir, file));
319
+ const kotlinPackage = parseKotlinPackageWithPluginId(pluginId, is_uni_modules_utssdk);
320
+ const swiftModule = parseSwiftModuleWithPluginId(pluginId, is_uni_modules_utssdk);
321
+ const swiftNamespace = parseSwiftPackageWithPluginId(pluginId, is_uni_modules_utssdk);
319
322
  easycomsObj[`^${name}$`] = {
320
323
  source: isApp ? `${source}?uts-proxy` : source,
321
- kotlinPackage: parseKotlinPackageWithPluginId(pluginId, is_uni_modules_utssdk),
322
- swiftModule: parseSwiftPackageWithPluginId(pluginId, is_uni_modules_utssdk),
324
+ kotlinPackage: kotlinPackage,
325
+ swiftModule: swiftModule,
326
+ kotlinNamespace: kotlinPackage,
327
+ swiftNamespace: swiftNamespace,
323
328
  };
324
329
  }
325
330
  });
@@ -337,6 +342,8 @@ function initUTSComponents(inputDir, platform) {
337
342
  source: obj.source,
338
343
  kotlinPackage: obj.kotlinPackage,
339
344
  swiftModule: obj.swiftModule,
345
+ kotlinNamespace: obj.kotlinPackage,
346
+ swiftNamespace: obj.swiftNamespace,
340
347
  });
341
348
  });
342
349
  return components;
@@ -381,10 +388,15 @@ function initUTSCustomElements(inputDir, platform) {
381
388
  ? path_1.default.relative(inputDir, path_1.default.dirname(dir))
382
389
  : path_1.default.relative(inputDir, filePath));
383
390
  const importSource = isApp ? `${source}?uts-proxy` : source;
391
+ const kotlinPackage = parseKotlinPackageWithPluginId(pluginId, true);
392
+ const swiftModule = parseSwiftModuleWithPluginId(pluginId, true);
393
+ const swiftNamespace = parseSwiftPackageWithPluginId(pluginId, true);
384
394
  const meta = {
385
395
  source: importSource,
386
- kotlinPackage: parseKotlinPackageWithPluginId(pluginId, true),
387
- swiftModule: parseSwiftPackageWithPluginId(pluginId, true),
396
+ kotlinPackage: kotlinPackage,
397
+ swiftModule: swiftModule,
398
+ kotlinNamespace: kotlinPackage,
399
+ swiftNamespace: swiftNamespace,
388
400
  };
389
401
  utsCustomElements.set(name, meta);
390
402
  parseCustomElementExports(filePath, unimport).then((exports_) => {
@@ -460,6 +472,13 @@ function parseSwiftPackageWithPluginId(id, is_uni_modules) {
460
472
  (0, utils_1.capitalize)((0, utils_1.camelize)(prefix(id))));
461
473
  }
462
474
  exports.parseSwiftPackageWithPluginId = parseSwiftPackageWithPluginId;
475
+ function parseSwiftModuleWithPluginId(id, is_uni_modules) {
476
+ if (!is_uni_modules) {
477
+ return parseSwiftPackageWithPluginId(id, is_uni_modules);
478
+ }
479
+ return `unimodule` + (0, utils_1.capitalize)((0, utils_1.camelize)(prefix(id)));
480
+ }
481
+ exports.parseSwiftModuleWithPluginId = parseSwiftModuleWithPluginId;
463
482
  async function parseUniExtApiAutoImports(uniExtApiAutoImports, extApis, parseSource) {
464
483
  if (Object.keys(extApis).length) {
465
484
  const { parseExportIdentifiers } = resolveUTSCompiler();
@@ -505,7 +524,7 @@ async function parseUniExtApiSwiftAutoImportsOnce(extApis) {
505
524
  }
506
525
  uniExtApiSwiftAutoImports = {};
507
526
  return parseUniExtApiAutoImports(uniExtApiSwiftAutoImports, extApis, (pluginId) => {
508
- return parseSwiftPackageWithPluginId(pluginId, true);
527
+ return parseSwiftModuleWithPluginId(pluginId, true);
509
528
  });
510
529
  }
511
530
  exports.parseUniExtApiNamespacesOnce = once((platform, language) => {
@@ -519,7 +538,7 @@ exports.parseUniExtApiNamespacesOnce = once((platform, language) => {
519
538
  source = parseKotlinPackageWithPluginId(pluginId, true);
520
539
  }
521
540
  else if (language === 'swift') {
522
- source = parseSwiftPackageWithPluginId(pluginId, true);
541
+ source = parseSwiftModuleWithPluginId(pluginId, true);
523
542
  }
524
543
  namespaces[name] = [source, options[1]];
525
544
  });
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initAutoImportOptions = void 0;
4
4
  const uni_shared_1 = require("@dcloudio/uni-shared");
5
5
  const uts_1 = require("../uts");
6
- const uniPreset = {
6
+ const uniLifeCyclePreset = {
7
7
  from: '@dcloudio/uni-app',
8
8
  imports: [
9
9
  // ssr
@@ -95,7 +95,47 @@ const uniMiniProgramPreset = {
95
95
  imports: ['UniElement', 'UniElementImpl'],
96
96
  };
97
97
  const cloudPreset = {
98
- '@dcloudio/uni-cloud': ['uniCloud', 'UniCloudError'],
98
+ from: '@dcloudio/uni-cloud',
99
+ imports: ['uniCloud', 'UniCloudError'],
100
+ };
101
+ const uniAppLifeCyclePreset = {
102
+ from: 'vue',
103
+ imports: [
104
+ // ssr
105
+ 'ssrRef',
106
+ 'shallowSsrRef',
107
+ // uni-app lifecycle
108
+ // App and Page
109
+ 'onShow',
110
+ 'onHide',
111
+ // App
112
+ 'onLaunch',
113
+ 'onError',
114
+ 'onThemeChange',
115
+ // onKeyboardHeightChange,
116
+ 'onPageNotFound',
117
+ 'onUnhandledRejection',
118
+ // onLastPageBackPress,
119
+ 'onExit',
120
+ // Page
121
+ 'onPageShow',
122
+ 'onPageHide',
123
+ 'onLoad',
124
+ 'onReady',
125
+ 'onUnload',
126
+ 'onResize',
127
+ 'onBackPress',
128
+ 'onPageScroll',
129
+ 'onTabItemTap',
130
+ 'onReachBottom',
131
+ 'onPullDownRefresh',
132
+ // 其他
133
+ 'onShareTimeline',
134
+ 'onShareAppMessage',
135
+ // onShareChat, // xhs-share
136
+ // 辅助,用于自定义render函数时,开发者可以调用此方法渲染组件的slot
137
+ 'renderComponentSlot',
138
+ ],
99
139
  };
100
140
  const vuePreset = {
101
141
  from: 'vue',
@@ -167,7 +207,18 @@ const vuePreset = {
167
207
  };
168
208
  function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
169
209
  rewriteAutoImportOnce();
170
- const autoImport = [uniPreset, cloudPreset, vuePreset];
210
+ const autoImport = [vuePreset];
211
+ // 只有app-ios和app-harmony平台特殊处理
212
+ if (platform === 'app-ios' || platform === 'app-harmony') {
213
+ autoImport.push(uniAppLifeCyclePreset);
214
+ }
215
+ else {
216
+ autoImport.push(uniLifeCyclePreset);
217
+ }
218
+ // 内置框架编译时,不能注入这些内容
219
+ if (!process.env.UNI_COMPILE_EXT_API_TYPE) {
220
+ autoImport.push(cloudPreset);
221
+ }
171
222
  if (platform === 'web') {
172
223
  autoImport.push(uniH5Preset);
173
224
  }
@@ -13,7 +13,7 @@ function uniUniModulesExtApiPlugin() {
13
13
  external: ['vue'],
14
14
  output: {
15
15
  format: 'iife',
16
- entryFileNames: 'components.js',
16
+ entryFileNames: `${process.env.UNI_COMPILE_EXT_API_OUT_FILE_NAME || 'components'}.js`,
17
17
  globals: {
18
18
  vue: 'Vue',
19
19
  uni: 'uni',
@@ -375,7 +375,7 @@ function uniUTSAppUniModulesPlugin(options = {}) {
375
375
  },
376
376
  async swiftAutoImports() {
377
377
  return (0, uts_1.initUTSSwiftAutoImportsOnce)().then((autoImports) => {
378
- return filterAutoImports(autoImports, (0, uts_1.parseSwiftPackageWithPluginId)(pluginId, true));
378
+ return filterAutoImports(autoImports, (0, uts_1.parseSwiftModuleWithPluginId)(pluginId, true));
379
379
  });
380
380
  },
381
381
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-4060720250515001",
3
+ "version": "3.0.0-alpha-4070120250530001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -68,8 +68,8 @@
68
68
  "unimport": "4.1.1",
69
69
  "unplugin-auto-import": "19.1.0",
70
70
  "xregexp": "3.1.0",
71
- "@dcloudio/uni-i18n": "3.0.0-alpha-4060720250515001",
72
- "@dcloudio/uni-shared": "3.0.0-alpha-4060720250515001"
71
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4070120250530001",
72
+ "@dcloudio/uni-shared": "3.0.0-alpha-4070120250530001"
73
73
  },
74
74
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
75
75
  "devDependencies": {
@@ -89,6 +89,6 @@
89
89
  "code-frame": "link:@types/@babel/code-frame",
90
90
  "postcss": "^8.4.21",
91
91
  "vue": "3.4.21",
92
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-4060720250515001"
92
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4070120250530001"
93
93
  }
94
94
  }