@dcloudio/uni-cli-shared 3.0.0-alpha-4010820240520001 → 3.0.0-alpha-4010820240523001

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.
@@ -102,6 +102,7 @@ export declare function initCheckEnv(): Record<string, string>;
102
102
  export declare function resolveEncryptUniModule(id: string, platform: typeof process.env.UNI_UTS_PLATFORM, isX?: boolean): string | undefined;
103
103
  export declare function checkEncryptUniModules(inputDir: string, params: {
104
104
  mode: 'development' | 'production';
105
+ packType: 'debug' | 'release';
105
106
  compilerVersion: string;
106
107
  appid: string;
107
108
  appname: string;
@@ -407,6 +407,7 @@ function findEncryptUniModuleCache(uniModuleId, cacheDir, options) {
407
407
  !isEnvExpired(pkg.uni_modules?.artifacts?.env || {}, options.env)) {
408
408
  return pkg;
409
409
  }
410
+ console.log(`插件${uniModuleId} 缓存已过期,需要重新云编译。`);
410
411
  // 已过期的插件,删除缓存
411
412
  fs_extra_1.default.rmSync(uniModuleCacheDir, { recursive: true });
412
413
  }
@@ -494,10 +495,22 @@ async function checkEncryptUniModules(inputDir, params) {
494
495
  try {
495
496
  const isLogin = await C();
496
497
  console.log(`正在云编译插件${isLogin ? '' : '(请先登录)'}:${modules.join(',')}...`);
497
- const downloadUrl = await U({
498
- params,
499
- attachment: zipFile,
500
- });
498
+ let downloadUrl = '';
499
+ try {
500
+ downloadUrl = await U({
501
+ params,
502
+ attachment: zipFile,
503
+ });
504
+ }
505
+ catch (e) {
506
+ if (e.message && e.message === '{"error":"UserNotLogin"}') {
507
+ console.log('当前项目包含需要云编译的付费插件,需要您先登录HBuilderX账号。');
508
+ }
509
+ else {
510
+ console.error(e);
511
+ }
512
+ process.exit(0);
513
+ }
501
514
  await D(downloadUrl, downloadFile);
502
515
  // unzip
503
516
  const AdmZip = require('adm-zip');
@@ -4,6 +4,9 @@ exports.initAutoImportOptions = void 0;
4
4
  const uniPreset = {
5
5
  from: '@dcloudio/uni-app',
6
6
  imports: [
7
+ // ssr
8
+ 'ssrRef',
9
+ 'shallowSsrRef',
7
10
  // uni-app lifecycle
8
11
  // App and Page
9
12
  'onShow',
@@ -1,5 +1,6 @@
1
1
  import type { Plugin, ResolveFn } from 'vite';
2
2
  import type { CssUrlReplacer } from './plugins/vitejs/plugins/css';
3
3
  export declare function createEncryptCssUrlReplacer(resolve: ResolveFn): CssUrlReplacer;
4
+ export declare function uniEncryptUniModulesAssetsPlugin(): Plugin;
4
5
  export declare function uniEncryptUniModulesPlugin(): Plugin;
5
6
  export declare function addUniModulesExtApiComponents(relativeFilename: string, components: string[]): void;
@@ -3,12 +3,13 @@ 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.addUniModulesExtApiComponents = exports.uniEncryptUniModulesPlugin = exports.createEncryptCssUrlReplacer = void 0;
6
+ exports.addUniModulesExtApiComponents = exports.uniEncryptUniModulesPlugin = exports.uniEncryptUniModulesAssetsPlugin = exports.createEncryptCssUrlReplacer = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const uni_modules_1 = require("../uni_modules");
10
10
  const utils_1 = require("./plugins/vitejs/utils");
11
11
  const uts_1 = require("../uts");
12
+ const utils_2 = require("../utils");
12
13
  function createEncryptCssUrlReplacer(resolve) {
13
14
  return async (url, importer) => {
14
15
  if (url.startsWith('/') && !url.startsWith('//')) {
@@ -17,12 +18,44 @@ function createEncryptCssUrlReplacer(resolve) {
17
18
  }
18
19
  const resolved = await resolve(url, importer);
19
20
  if (resolved) {
20
- return ('@/' + (0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, resolved)));
21
+ return ('@/' + (0, utils_2.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, resolved)));
21
22
  }
22
23
  return url;
23
24
  };
24
25
  }
25
26
  exports.createEncryptCssUrlReplacer = createEncryptCssUrlReplacer;
27
+ // 处理静态资源加载(目前仅限非app-android)
28
+ function uniEncryptUniModulesAssetsPlugin() {
29
+ let resolvedConfig;
30
+ return {
31
+ name: 'uni:encrypt-uni-modules-assets',
32
+ enforce: 'pre',
33
+ configResolved(config) {
34
+ resolvedConfig = config;
35
+ },
36
+ resolveId(id, importer) {
37
+ if (resolvedConfig.assetsInclude((0, utils_1.cleanUrl)(id))) {
38
+ id = (0, utils_2.normalizePath)(id);
39
+ if (importer && (id.startsWith('./') || id.startsWith('../'))) {
40
+ id = (0, utils_2.normalizePath)(path_1.default.resolve(path_1.default.dirname(importer), id));
41
+ }
42
+ if (path_1.default.isAbsolute(id)) {
43
+ id = '@/' + path_1.default.relative(process.env.UNI_INPUT_DIR, id);
44
+ }
45
+ return `\0${id}`;
46
+ }
47
+ },
48
+ load(id) {
49
+ if (resolvedConfig.assetsInclude((0, utils_1.cleanUrl)(id))) {
50
+ return {
51
+ code: `export default ${JSON.stringify(id.replace(/\0/g, ''))}`,
52
+ moduleSideEffects: false,
53
+ };
54
+ }
55
+ },
56
+ };
57
+ }
58
+ exports.uniEncryptUniModulesAssetsPlugin = uniEncryptUniModulesAssetsPlugin;
26
59
  function uniEncryptUniModulesPlugin() {
27
60
  let resolvedConfig;
28
61
  return {
@@ -42,9 +75,28 @@ function uniEncryptUniModulesPlugin() {
42
75
  config.build.rollupOptions.external = createExternal(config);
43
76
  resolvedConfig = config;
44
77
  },
45
- resolveId(id) {
46
- if (resolvedConfig.assetsInclude((0, utils_1.cleanUrl)(id))) {
47
- return `\0${id}`;
78
+ resolveId(id, importer) {
79
+ if (process.env.UNI_UTS_PLATFORM !== 'app-android') {
80
+ if (resolvedConfig.assetsInclude((0, utils_1.cleanUrl)(id))) {
81
+ id = (0, utils_2.normalizePath)(id);
82
+ if (importer && (id.startsWith('./') || id.startsWith('../'))) {
83
+ id = (0, utils_2.normalizePath)(path_1.default.resolve(path_1.default.dirname(importer), id));
84
+ }
85
+ if (path_1.default.isAbsolute(id)) {
86
+ id = '@/' + path_1.default.relative(process.env.UNI_INPUT_DIR, id);
87
+ }
88
+ return `\0${id}`;
89
+ }
90
+ }
91
+ },
92
+ load(id) {
93
+ if (process.env.UNI_UTS_PLATFORM !== 'app-android') {
94
+ if (resolvedConfig.assetsInclude((0, utils_1.cleanUrl)(id))) {
95
+ return {
96
+ code: `export default ${JSON.stringify(id.replace(/\0/g, ''))}`,
97
+ moduleSideEffects: false,
98
+ };
99
+ }
48
100
  }
49
101
  },
50
102
  generateBundle(_, bundle) {
@@ -121,12 +173,6 @@ function uvueOutDir() {
121
173
  }
122
174
  function createExternal(config) {
123
175
  return function external(source) {
124
- if (
125
- // android 平台需要编译 assets 资源
126
- process.env.UNI_UTS_PLATFORM !== 'app-android' &&
127
- config.assetsInclude((0, utils_1.cleanUrl)(source))) {
128
- return true;
129
- }
130
176
  if ([
131
177
  'vue',
132
178
  'plugin-vue:export-helper',
@@ -220,7 +266,7 @@ function genUniModulesPackageJson(uniModuleId, inputDir, artifacts) {
220
266
  }, null, 2);
221
267
  }
222
268
  function parseUniModuleId(relativeFilename) {
223
- const parts = (0, utils_1.normalizePath)(relativeFilename).split('/', 2);
269
+ const parts = (0, utils_2.normalizePath)(relativeFilename).split('/', 2);
224
270
  if (parts[0] === 'uni_modules') {
225
271
  return parts[1];
226
272
  }
@@ -171,6 +171,8 @@ function uniDecryptUniModulesPlugin() {
171
171
  mode: process.env.NODE_ENV !== 'development'
172
172
  ? 'production'
173
173
  : 'development',
174
+ packType: process.env.UNI_APP_PACK_TYPE ||
175
+ (process.env.NODE_ENV !== 'development' ? 'release' : 'debug'),
174
176
  compilerVersion: process.env.UNI_COMPILER_VERSION,
175
177
  appid: manifest.appid,
176
178
  appname: manifest.name,
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformPageHead = void 0;
4
+ const compiler_core_1 = require("@vue/compiler-core");
4
5
  const utils_1 = require("../../utils");
5
6
  const transformPageHead = (node, context) => {
6
7
  // 发现是page-meta下的head,直接remove该节点
7
- (0, utils_1.checkElementNodeTag)(node, 'head') &&
8
- (0, utils_1.checkElementNodeTag)(context.parent, 'page-meta') &&
9
- context.removeNode(node);
8
+ if ((0, utils_1.checkElementNodeTag)(node, 'head') &&
9
+ (0, utils_1.checkElementNodeTag)(context.parent, 'page-meta')) {
10
+ ;
11
+ node.tag = 'page-meta-head';
12
+ node.tagType = compiler_core_1.ElementTypes.COMPONENT;
13
+ }
10
14
  };
11
15
  exports.transformPageHead = transformPageHead;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-4010820240520001",
3
+ "version": "3.0.0-alpha-4010820240523001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,8 +26,8 @@
26
26
  "@babel/core": "^7.23.3",
27
27
  "@babel/parser": "^7.23.9",
28
28
  "@babel/types": "^7.20.7",
29
- "@dcloudio/uni-i18n": "3.0.0-alpha-4010820240520001",
30
- "@dcloudio/uni-shared": "3.0.0-alpha-4010820240520001",
29
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4010820240523001",
30
+ "@dcloudio/uni-shared": "3.0.0-alpha-4010820240523001",
31
31
  "@intlify/core-base": "9.1.9",
32
32
  "@intlify/shared": "9.1.9",
33
33
  "@intlify/vue-devtools": "9.1.9",
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
73
73
  "devDependencies": {
74
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-4010820240520001",
74
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4010820240523001",
75
75
  "@types/adm-zip": "^0.5.5",
76
76
  "@types/babel__code-frame": "^7.0.6",
77
77
  "@types/babel__core": "^7.1.19",