@dcloudio/uni-cli-shared 3.0.0-alpha-4020820240914002 → 3.0.0-alpha-4020820240920001
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/index.d.ts +1 -2
- package/dist/index.js +3 -4
- package/dist/json/app/manifest/defaultManifestJson.js +1 -1
- package/dist/json/app/manifest/launchwebview.js +1 -11
- package/dist/json/manifest.js +1 -2
- package/dist/json/pages.js +1 -1
- package/dist/mp/template.d.ts +1 -5
- package/dist/preprocess/context.d.ts +0 -5
- package/dist/preprocess/context.js +5 -14
- package/dist/resolve.d.ts +1 -2
- package/dist/resolve.js +3 -14
- package/dist/uni_modules.d.ts +49 -0
- package/dist/uni_modules.js +325 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +3 -13
- package/dist/uts.d.ts +1 -8
- package/dist/uts.js +25 -169
- package/dist/vite/autoImport.js +1 -1
- package/dist/vite/cloud.d.ts +0 -1
- package/dist/vite/cloud.js +10 -48
- package/dist/vite/index.d.ts +0 -1
- package/dist/vite/index.js +0 -1
- package/dist/vite/plugins/uts/uni_modules.d.ts +0 -4
- package/dist/vite/plugins/uts/uni_modules.js +23 -260
- package/dist/vite/plugins/vitejs/plugins/asset.js +0 -1
- package/dist/vite/utils/index.js +1 -2
- package/dist/vite/utils/utils.js +6 -11
- package/dist/watcher.js +3 -18
- package/package.json +6 -6
- package/dist/uni_modules.cloud.d.ts +0 -49
- package/dist/uni_modules.cloud.js +0 -332
- package/dist/vite/extApi.d.ts +0 -2
- package/dist/vite/extApi.js +0 -32
package/dist/index.d.ts
CHANGED
|
@@ -22,8 +22,7 @@ export * from './resolve';
|
|
|
22
22
|
export * from './scripts';
|
|
23
23
|
export * from './platform';
|
|
24
24
|
export * from './utsUtils';
|
|
25
|
-
export { parseUniExtApi, parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, formatExtApiProviderName, } from './uni_modules';
|
|
26
|
-
export { parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
|
|
25
|
+
export { parseUniExtApi, parseUniExtApis, parseInjects, parseUniModulesArtifacts, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, resolveEncryptUniModule, formatExtApiProviderName, } from './uni_modules';
|
|
27
26
|
export { M } from './messages';
|
|
28
27
|
export * from './exports';
|
|
29
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.
|
|
17
|
+
exports.checkUpdate = exports.M = exports.formatExtApiProviderName = exports.resolveEncryptUniModule = exports.getUniExtApiProviderRegisters = exports.parseUniModulesArtifacts = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
|
|
18
18
|
__exportStar(require("./fs"), exports);
|
|
19
19
|
__exportStar(require("./mp"), exports);
|
|
20
20
|
__exportStar(require("./url"), exports);
|
|
@@ -43,11 +43,10 @@ var uni_modules_1 = require("./uni_modules");
|
|
|
43
43
|
Object.defineProperty(exports, "parseUniExtApi", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApi; } });
|
|
44
44
|
Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
|
|
45
45
|
Object.defineProperty(exports, "parseInjects", { enumerable: true, get: function () { return uni_modules_1.parseInjects; } });
|
|
46
|
+
Object.defineProperty(exports, "parseUniModulesArtifacts", { enumerable: true, get: function () { return uni_modules_1.parseUniModulesArtifacts; } });
|
|
46
47
|
Object.defineProperty(exports, "getUniExtApiProviderRegisters", { enumerable: true, get: function () { return uni_modules_1.getUniExtApiProviderRegisters; } });
|
|
48
|
+
Object.defineProperty(exports, "resolveEncryptUniModule", { enumerable: true, get: function () { return uni_modules_1.resolveEncryptUniModule; } });
|
|
47
49
|
Object.defineProperty(exports, "formatExtApiProviderName", { enumerable: true, get: function () { return uni_modules_1.formatExtApiProviderName; } });
|
|
48
|
-
var uni_modules_cloud_1 = require("./uni_modules.cloud");
|
|
49
|
-
Object.defineProperty(exports, "parseUniModulesArtifacts", { enumerable: true, get: function () { return uni_modules_cloud_1.parseUniModulesArtifacts; } });
|
|
50
|
-
Object.defineProperty(exports, "resolveEncryptUniModule", { enumerable: true, get: function () { return uni_modules_cloud_1.resolveEncryptUniModule; } });
|
|
51
50
|
var messages_1 = require("./messages");
|
|
52
51
|
Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
|
|
53
52
|
__exportStar(require("./exports"), exports);
|
|
@@ -14,17 +14,7 @@ function initLaunchwebview(manifestJson, pagesJson) {
|
|
|
14
14
|
}
|
|
15
15
|
catch (e) { }
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
if (manifestJson.plus.useragent.value) {
|
|
19
|
-
manifestJson.plus.useragent.value = [
|
|
20
|
-
'uni-app',
|
|
21
|
-
manifestJson.plus.useragent.value,
|
|
22
|
-
].join(' ');
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
manifestJson.plus.useragent.value = 'uni-app';
|
|
26
|
-
}
|
|
27
|
-
}
|
|
17
|
+
manifestJson.plus.useragent.value = 'uni-app';
|
|
28
18
|
(0, shared_1.extend)(manifestJson.plus.launchwebview, {
|
|
29
19
|
id: '1',
|
|
30
20
|
kernel: 'WKWebview',
|
package/dist/json/manifest.js
CHANGED
|
@@ -9,11 +9,10 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
10
10
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
11
11
|
const json_1 = require("./json");
|
|
12
|
-
const utils_1 = require("../utils");
|
|
13
12
|
const parseManifestJson = (inputDir) => {
|
|
14
13
|
const manifestFilename = path_1.default.join(inputDir, 'manifest.json');
|
|
15
14
|
if (!fs_1.default.existsSync(manifestFilename)) {
|
|
16
|
-
if (
|
|
15
|
+
if (process.env.UNI_COMPILE_TARGET === 'uni_modules') {
|
|
17
16
|
return {};
|
|
18
17
|
}
|
|
19
18
|
}
|
package/dist/json/pages.js
CHANGED
|
@@ -45,7 +45,7 @@ exports.isUniPageSfcFile = isUniPageSfcFile;
|
|
|
45
45
|
const parsePagesJson = (inputDir, platform, normalize = true) => {
|
|
46
46
|
const pagesFilename = path_1.default.join(inputDir, 'pages.json');
|
|
47
47
|
if (!fs_1.default.existsSync(pagesFilename)) {
|
|
48
|
-
if (
|
|
48
|
+
if (process.env.UNI_COMPILE_TARGET === 'uni_modules') {
|
|
49
49
|
return {
|
|
50
50
|
pages: [],
|
|
51
51
|
globalStyle: { navigationBar: {} },
|
package/dist/mp/template.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EmittedAsset } from 'rollup';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ElementNode } from '@vue/compiler-core';
|
|
3
3
|
import type { MiniProgramComponentsType } from '../json/mp/types';
|
|
4
4
|
type LazyElementFn = (node: ElementNode, context: {
|
|
5
5
|
isMiniProgramComponent(name: string): MiniProgramComponentsType | undefined;
|
|
@@ -10,10 +10,6 @@ type LazyElementFn = (node: ElementNode, context: {
|
|
|
10
10
|
}[] | true;
|
|
11
11
|
} | boolean;
|
|
12
12
|
export interface MiniProgramCompilerOptions {
|
|
13
|
-
/**
|
|
14
|
-
* 检查属性名称是否符合平台要求,比如华为快应用不允许使用 key 属性等
|
|
15
|
-
*/
|
|
16
|
-
checkPropName?: (name: string, prop: AttributeNode | DirectiveNode, node: ElementNode) => boolean;
|
|
17
13
|
/**
|
|
18
14
|
* 需要延迟渲染的组件,通常是某个组件的某个事件会立刻触发,需要延迟到首次 render 之后,比如微信 editor 的 ready 事件,快手 switch 的 change
|
|
19
15
|
*/
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
export declare function getPreVueContext(): any;
|
|
2
2
|
export declare function getPreNVueContext(): any;
|
|
3
3
|
export declare function getPreUVueContext(): any;
|
|
4
|
-
export declare function initScopedPreContext(platform: UniApp.PLATFORM, userPreContext?: Record<string, boolean> | string, utsPlatform?: typeof process.env.UNI_UTS_PLATFORM, isX?: boolean): {
|
|
5
|
-
preVueContext: any;
|
|
6
|
-
preNVueContext: any;
|
|
7
|
-
preUVueContext: any;
|
|
8
|
-
};
|
|
9
4
|
export declare function initPreContext(platform: UniApp.PLATFORM, userPreContext?: Record<string, boolean> | string, utsPlatform?: typeof process.env.UNI_UTS_PLATFORM, isX?: boolean): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initPreContext = exports.
|
|
3
|
+
exports.initPreContext = exports.getPreUVueContext = exports.getPreNVueContext = exports.getPreVueContext = void 0;
|
|
4
4
|
const extend = Object.assign;
|
|
5
5
|
const isString = (val) => typeof val === 'string';
|
|
6
6
|
const objectToString = Object.prototype.toString;
|
|
@@ -51,7 +51,7 @@ function getPreUVueContext() {
|
|
|
51
51
|
return preUVueContext;
|
|
52
52
|
}
|
|
53
53
|
exports.getPreUVueContext = getPreUVueContext;
|
|
54
|
-
function
|
|
54
|
+
function initPreContext(platform, userPreContext, utsPlatform, isX) {
|
|
55
55
|
const vueContext = Object.create(null);
|
|
56
56
|
const nvueContext = Object.create(null);
|
|
57
57
|
const uvueContext = Object.create(null);
|
|
@@ -112,18 +112,9 @@ function initScopedPreContext(platform, userPreContext, utsPlatform, isX) {
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
preUVueContext: extend({}, defaultContext, uvueContext),
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
exports.initScopedPreContext = initScopedPreContext;
|
|
122
|
-
function initPreContext(platform, userPreContext, utsPlatform, isX) {
|
|
123
|
-
const { preVueContext: scopedPreVueContext, preNVueContext: scopedPreNVueContext, preUVueContext: scopedPreUVueContext, } = initScopedPreContext(platform, userPreContext, utsPlatform, isX);
|
|
124
|
-
extend(preVueContext, scopedPreVueContext);
|
|
125
|
-
extend(preNVueContext, scopedPreNVueContext);
|
|
126
|
-
extend(preUVueContext, scopedPreUVueContext);
|
|
115
|
+
extend(preVueContext, defaultContext, vueContext);
|
|
116
|
+
extend(preNVueContext, defaultContext, nvueContext);
|
|
117
|
+
extend(preUVueContext, defaultContext, uvueContext);
|
|
127
118
|
}
|
|
128
119
|
exports.initPreContext = initPreContext;
|
|
129
120
|
function normalizeKey(name) {
|
package/dist/resolve.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export declare function requireResolve(filename: string, basedir: string): strin
|
|
|
2
2
|
export declare function relativeFile(from: string, to: string): string;
|
|
3
3
|
export declare const resolveMainPathOnce: (inputDir: string) => string;
|
|
4
4
|
export declare function getBuiltInPaths(): string[];
|
|
5
|
-
export declare function resolveBuiltIn(
|
|
5
|
+
export declare function resolveBuiltIn(path: string): string;
|
|
6
6
|
export declare function resolveVueI18nRuntime(): string;
|
|
7
7
|
export declare function resolveComponentsLibPath(): string;
|
|
8
|
-
export declare function resolveComponentsLibDirs(): string[];
|
package/dist/resolve.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.
|
|
6
|
+
exports.resolveComponentsLibPath = exports.resolveVueI18nRuntime = exports.resolveBuiltIn = exports.getBuiltInPaths = exports.resolveMainPathOnce = exports.relativeFile = exports.requireResolve = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const debug_1 = __importDefault(require("debug"));
|
|
@@ -93,13 +93,8 @@ function getBuiltInPaths() {
|
|
|
93
93
|
return paths;
|
|
94
94
|
}
|
|
95
95
|
exports.getBuiltInPaths = getBuiltInPaths;
|
|
96
|
-
function resolveBuiltIn(
|
|
97
|
-
|
|
98
|
-
process.env.UNI_APP_NEXT_WORKSPACE &&
|
|
99
|
-
module.startsWith('@dcloudio/')) {
|
|
100
|
-
return path_1.default.resolve(process.env.UNI_APP_NEXT_WORKSPACE, 'packages', module);
|
|
101
|
-
}
|
|
102
|
-
return require.resolve(module, { paths: getBuiltInPaths() });
|
|
96
|
+
function resolveBuiltIn(path) {
|
|
97
|
+
return require.resolve(path, { paths: getBuiltInPaths() });
|
|
103
98
|
}
|
|
104
99
|
exports.resolveBuiltIn = resolveBuiltIn;
|
|
105
100
|
function resolveVueI18nRuntime() {
|
|
@@ -130,9 +125,3 @@ function resolveComponentsLibPath() {
|
|
|
130
125
|
return componentsLibPath;
|
|
131
126
|
}
|
|
132
127
|
exports.resolveComponentsLibPath = resolveComponentsLibPath;
|
|
133
|
-
function resolveComponentsLibDirs() {
|
|
134
|
-
return process.env.UNI_COMPILE_TARGET === 'ext-api'
|
|
135
|
-
? []
|
|
136
|
-
: [resolveComponentsLibPath()];
|
|
137
|
-
}
|
|
138
|
-
exports.resolveComponentsLibDirs = resolveComponentsLibDirs;
|
package/dist/uni_modules.d.ts
CHANGED
|
@@ -73,3 +73,52 @@ export declare const capitalize: (str: string) => string;
|
|
|
73
73
|
* @returns
|
|
74
74
|
*/
|
|
75
75
|
export declare function parseUTSModuleDeps(deps: string[], inputDir: string): string[];
|
|
76
|
+
export declare function genEncryptEasyComModuleIndex(platform: typeof process.env.UNI_UTS_PLATFORM, components: Record<string, '.vue' | '.uvue'>): string;
|
|
77
|
+
export declare function parseUniModulesWithComponents(inputDir: string): Record<string, Record<string, ".vue" | ".uvue">>;
|
|
78
|
+
/**
|
|
79
|
+
* 解析 easyCom 组件列表
|
|
80
|
+
* @param pluginId
|
|
81
|
+
* @param inputDir
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
export declare function parseEasyComComponents(pluginId: string, inputDir: string, detectBinary?: boolean): Record<string, ".vue" | ".uvue">;
|
|
85
|
+
export declare function findEncryptUniModules(inputDir: string, cacheDir?: string): Record<string, EncryptPackageJson | undefined>;
|
|
86
|
+
export declare function findUploadEncryptUniModulesFiles(uniModules: Record<string, EncryptPackageJson | undefined>, platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string): Record<string, string[]>;
|
|
87
|
+
export declare function packUploadEncryptUniModules(uniModules: Record<string, EncryptPackageJson | undefined>, platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string, cacheDir: string): {
|
|
88
|
+
zipFile: string;
|
|
89
|
+
modules: string[];
|
|
90
|
+
};
|
|
91
|
+
interface EncryptPackageJson {
|
|
92
|
+
id: string;
|
|
93
|
+
version: string;
|
|
94
|
+
uni_modules: {
|
|
95
|
+
dependencies: string[];
|
|
96
|
+
artifacts: {
|
|
97
|
+
env: {
|
|
98
|
+
compilerVersion: string;
|
|
99
|
+
} & Record<string, any>;
|
|
100
|
+
apis: string[];
|
|
101
|
+
components: string[];
|
|
102
|
+
scopedSlots: string[];
|
|
103
|
+
declaration: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export declare function initCheckEnv(): Record<string, string>;
|
|
108
|
+
export declare function resolveEncryptUniModule(id: string, platform: typeof process.env.UNI_UTS_PLATFORM, isX?: boolean): string | undefined;
|
|
109
|
+
export declare function checkEncryptUniModules(inputDir: string, params: {
|
|
110
|
+
mode: 'development' | 'production';
|
|
111
|
+
packType: 'debug' | 'release';
|
|
112
|
+
compilerVersion: string;
|
|
113
|
+
appid: string;
|
|
114
|
+
appname: string;
|
|
115
|
+
platform: typeof process.env.UNI_UTS_PLATFORM;
|
|
116
|
+
'uni-app-x': boolean;
|
|
117
|
+
}): Promise<{} | undefined>;
|
|
118
|
+
export declare function parseUniModulesArtifacts(): {
|
|
119
|
+
name: string;
|
|
120
|
+
package: string;
|
|
121
|
+
scopedSlots: string[];
|
|
122
|
+
declaration: string;
|
|
123
|
+
}[];
|
|
124
|
+
export {};
|
package/dist/uni_modules.js
CHANGED
|
@@ -3,10 +3,14 @@ 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.parseUniExtApi = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.formatExtApiProviderName = exports.getUniExtApiPlugins = exports.getUniExtApiProviders = void 0;
|
|
6
|
+
exports.parseUniModulesArtifacts = exports.checkEncryptUniModules = exports.resolveEncryptUniModule = exports.initCheckEnv = exports.packUploadEncryptUniModules = exports.findUploadEncryptUniModulesFiles = exports.findEncryptUniModules = exports.parseEasyComComponents = exports.parseUniModulesWithComponents = exports.genEncryptEasyComModuleIndex = exports.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApi = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.formatExtApiProviderName = 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
|
+
const fast_glob_1 = require("fast-glob");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
const easycom_1 = require("./easycom");
|
|
13
|
+
const messages_1 = require("./messages");
|
|
10
14
|
const extApiProviders = [];
|
|
11
15
|
const extApiPlugins = new Set();
|
|
12
16
|
function getUniExtApiProviders() {
|
|
@@ -277,3 +281,323 @@ function parseUTSModuleDeps(deps, inputDir) {
|
|
|
277
281
|
});
|
|
278
282
|
}
|
|
279
283
|
exports.parseUTSModuleDeps = parseUTSModuleDeps;
|
|
284
|
+
function genEncryptEasyComModuleIndex(platform, components) {
|
|
285
|
+
const imports = [];
|
|
286
|
+
const ids = [];
|
|
287
|
+
Object.keys(components).forEach((component) => {
|
|
288
|
+
const id = (0, exports.capitalize)((0, exports.camelize)(component));
|
|
289
|
+
ids.push(id);
|
|
290
|
+
let instance = '';
|
|
291
|
+
if (platform === 'app-android') {
|
|
292
|
+
instance = (0, easycom_1.genUTSComponentPublicInstanceIdent)(component);
|
|
293
|
+
// 类型
|
|
294
|
+
ids.push(instance);
|
|
295
|
+
}
|
|
296
|
+
imports.push(`import ${id}${instance ? `, { ${instance} }` : ''} from './components/${component}/${component}${components[component]}'`);
|
|
297
|
+
});
|
|
298
|
+
return `
|
|
299
|
+
${imports.join('\n')}
|
|
300
|
+
export {
|
|
301
|
+
${ids.join(',\n ')}
|
|
302
|
+
}
|
|
303
|
+
`;
|
|
304
|
+
}
|
|
305
|
+
exports.genEncryptEasyComModuleIndex = genEncryptEasyComModuleIndex;
|
|
306
|
+
// 目前该函数仅在云端使用(目前仅限iOS/web),云端编译时,提交上来的uni_modules是过滤好的
|
|
307
|
+
function parseUniModulesWithComponents(inputDir) {
|
|
308
|
+
const modulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
309
|
+
const uniModules = {};
|
|
310
|
+
if (fs_extra_1.default.existsSync(modulesDir)) {
|
|
311
|
+
fs_extra_1.default.readdirSync(modulesDir).forEach((uniModuleDir) => {
|
|
312
|
+
if (!fs_extra_1.default.existsSync(path_1.default.resolve(modulesDir, uniModuleDir, 'package.json'))) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
// 解析加密的 easyCom 插件列表
|
|
316
|
+
const components = parseEasyComComponents(uniModuleDir, inputDir, false);
|
|
317
|
+
uniModules[uniModuleDir] = components;
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return uniModules;
|
|
321
|
+
}
|
|
322
|
+
exports.parseUniModulesWithComponents = parseUniModulesWithComponents;
|
|
323
|
+
/**
|
|
324
|
+
* 解析 easyCom 组件列表
|
|
325
|
+
* @param pluginId
|
|
326
|
+
* @param inputDir
|
|
327
|
+
* @returns
|
|
328
|
+
*/
|
|
329
|
+
function parseEasyComComponents(pluginId, inputDir, detectBinary = true) {
|
|
330
|
+
const componentsDir = path_1.default.resolve(inputDir, 'uni_modules', pluginId, 'components');
|
|
331
|
+
const components = {};
|
|
332
|
+
if (fs_extra_1.default.existsSync(componentsDir)) {
|
|
333
|
+
fs_extra_1.default.readdirSync(componentsDir).forEach((componentDir) => {
|
|
334
|
+
const componentFile = path_1.default.resolve(componentsDir, componentDir, componentDir);
|
|
335
|
+
const extname = ['.vue', '.uvue'].find((extname) => {
|
|
336
|
+
const filename = componentFile + extname;
|
|
337
|
+
// 探测 filename 是否是二进制文件
|
|
338
|
+
if (fs_extra_1.default.existsSync(filename)) {
|
|
339
|
+
if (detectBinary) {
|
|
340
|
+
// 延迟require,这个是新增的依赖,无法及时同步到内部测试版本HBuilderX中,导致报错,所以延迟require吧
|
|
341
|
+
if (require('isbinaryfile').isBinaryFileSync(filename)) {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
if (extname) {
|
|
351
|
+
components[componentDir] = extname;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return components;
|
|
356
|
+
}
|
|
357
|
+
exports.parseEasyComComponents = parseEasyComComponents;
|
|
358
|
+
// 查找所有普通加密插件 uni_modules
|
|
359
|
+
function findEncryptUniModules(inputDir, cacheDir = '') {
|
|
360
|
+
const modulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
361
|
+
const uniModules = {};
|
|
362
|
+
if (fs_extra_1.default.existsSync(modulesDir)) {
|
|
363
|
+
fs_extra_1.default.readdirSync(modulesDir).forEach((uniModuleDir) => {
|
|
364
|
+
const uniModuleRootDir = path_1.default.resolve(modulesDir, uniModuleDir);
|
|
365
|
+
if (!fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'encrypt'))) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
// 仅扫描普通加密插件,无需依赖
|
|
369
|
+
if (fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk'))) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
const pkg = require(path_1.default.resolve(uniModuleRootDir, 'package.json'));
|
|
373
|
+
uniModules[uniModuleDir] = findEncryptUniModuleCache(uniModuleDir, cacheDir, { version: pkg.version, env: initCheckEnv() });
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
return uniModules;
|
|
377
|
+
}
|
|
378
|
+
exports.findEncryptUniModules = findEncryptUniModules;
|
|
379
|
+
function findUploadEncryptUniModulesFiles(uniModules, platform, inputDir) {
|
|
380
|
+
const modules = {};
|
|
381
|
+
Object.keys(uniModules).forEach((uniModuleId) => {
|
|
382
|
+
if (!uniModules[uniModuleId]) {
|
|
383
|
+
modules[uniModuleId] = findUniModuleFiles(platform, uniModuleId, inputDir);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
return modules;
|
|
387
|
+
}
|
|
388
|
+
exports.findUploadEncryptUniModulesFiles = findUploadEncryptUniModulesFiles;
|
|
389
|
+
function packUploadEncryptUniModules(uniModules, platform, inputDir, cacheDir) {
|
|
390
|
+
const modules = findUploadEncryptUniModulesFiles(uniModules, platform, inputDir);
|
|
391
|
+
const uploadModuleIds = Object.keys(modules);
|
|
392
|
+
if (uploadModuleIds.length) {
|
|
393
|
+
// 延迟 require,避免 vue2 编译器需要安装此依赖,目前该方法仅在 vite 编译器中使用
|
|
394
|
+
const AdmZip = require('adm-zip');
|
|
395
|
+
const zip = new AdmZip();
|
|
396
|
+
uploadModuleIds.forEach((moduleId) => {
|
|
397
|
+
modules[moduleId].forEach((file) => {
|
|
398
|
+
zip.addLocalFile(file, path_1.default.dirname(path_1.default.relative(inputDir, file)));
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
const zipFile = path_1.default.resolve(cacheDir, 'cloud-compile-plugins.zip');
|
|
402
|
+
zip.writeZip(zipFile);
|
|
403
|
+
return {
|
|
404
|
+
zipFile,
|
|
405
|
+
modules: uploadModuleIds,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
return {
|
|
409
|
+
zipFile: '',
|
|
410
|
+
modules: [],
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
exports.packUploadEncryptUniModules = packUploadEncryptUniModules;
|
|
414
|
+
function isEnvExpired(value, other) {
|
|
415
|
+
const valueKeys = Object.keys(value);
|
|
416
|
+
const otherKeys = Object.keys(other);
|
|
417
|
+
if (valueKeys.length !== otherKeys.length) {
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
if (valueKeys.find((name) => value[name] !== other[name])) {
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
function findEncryptUniModuleCache(uniModuleId, cacheDir, options) {
|
|
426
|
+
if (!cacheDir) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const uniModuleCacheDir = path_1.default.resolve(cacheDir, 'uni_modules', uniModuleId);
|
|
430
|
+
if (fs_extra_1.default.existsSync(uniModuleCacheDir)) {
|
|
431
|
+
const pkg = require(path_1.default.resolve(uniModuleCacheDir, 'package.json'));
|
|
432
|
+
// 插件版本以及各种环境一致
|
|
433
|
+
if (pkg.version === options.version &&
|
|
434
|
+
!isEnvExpired(pkg.uni_modules?.artifacts?.env || {}, options.env)) {
|
|
435
|
+
const declaration = path_1.default.resolve(uniModuleCacheDir, 'utssdk/app-android/index.d.uts');
|
|
436
|
+
pkg.uni_modules.artifacts.declaration = fs_extra_1.default.existsSync(declaration)
|
|
437
|
+
? declaration
|
|
438
|
+
: '';
|
|
439
|
+
return pkg;
|
|
440
|
+
}
|
|
441
|
+
console.log(`插件${uniModuleId} 缓存已过期,需要重新云编译。`);
|
|
442
|
+
// 已过期的插件,删除缓存
|
|
443
|
+
fs_extra_1.default.rmSync(uniModuleCacheDir, { recursive: true });
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const KNOWN_ASSET_TYPES = [
|
|
447
|
+
// images
|
|
448
|
+
'png',
|
|
449
|
+
'jpe?g',
|
|
450
|
+
'gif',
|
|
451
|
+
'svg',
|
|
452
|
+
'ico',
|
|
453
|
+
'webp',
|
|
454
|
+
'avif',
|
|
455
|
+
// media
|
|
456
|
+
'mp4',
|
|
457
|
+
'webm',
|
|
458
|
+
'ogg',
|
|
459
|
+
'mp3',
|
|
460
|
+
'wav',
|
|
461
|
+
'flac',
|
|
462
|
+
'aac',
|
|
463
|
+
// fonts
|
|
464
|
+
'woff2?',
|
|
465
|
+
'eot',
|
|
466
|
+
'ttf',
|
|
467
|
+
'otf',
|
|
468
|
+
// other
|
|
469
|
+
'pdf',
|
|
470
|
+
'txt',
|
|
471
|
+
];
|
|
472
|
+
function findUniModuleFiles(platform, id, inputDir) {
|
|
473
|
+
return (0, fast_glob_1.sync)(`uni_modules/${id}/**/*`, {
|
|
474
|
+
cwd: inputDir,
|
|
475
|
+
absolute: true,
|
|
476
|
+
ignore: [
|
|
477
|
+
'**/*.md',
|
|
478
|
+
...(platform !== 'app-android' // 非 android 平台不需要扫描 assets
|
|
479
|
+
? [`**/*.{${KNOWN_ASSET_TYPES.join(',')}}`]
|
|
480
|
+
: []),
|
|
481
|
+
],
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
function initCheckEnv() {
|
|
485
|
+
return {
|
|
486
|
+
// 云端编译的版本号不带日期及小版本
|
|
487
|
+
compilerVersion: process.env.UNI_COMPILER_VERSION,
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
exports.initCheckEnv = initCheckEnv;
|
|
491
|
+
function findLastIndex(array, predicate) {
|
|
492
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
493
|
+
if (predicate(array[i], i, array)) {
|
|
494
|
+
return i;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return -1;
|
|
498
|
+
}
|
|
499
|
+
let encryptUniModules = {};
|
|
500
|
+
function resolveEncryptUniModule(id, platform, isX = true) {
|
|
501
|
+
const parts = id.split('?', 2)[0].split('/');
|
|
502
|
+
const index = findLastIndex(parts, (part) => part === 'uni_modules');
|
|
503
|
+
if (index !== -1) {
|
|
504
|
+
const uniModuleId = parts[index + 1];
|
|
505
|
+
if (uniModuleId in encryptUniModules) {
|
|
506
|
+
if (parts[index + 2]) {
|
|
507
|
+
console.warn(messages_1.M['uni_modules.import']
|
|
508
|
+
.replace('{0}', uniModuleId)
|
|
509
|
+
.replace('{1}', uniModuleId)
|
|
510
|
+
.replace('{2}', parts.slice(index + 2).join('/')));
|
|
511
|
+
}
|
|
512
|
+
// 原生平台走旧的uts-proxy
|
|
513
|
+
return (0, utils_1.normalizePath)(path_1.default.join(process.env.UNI_INPUT_DIR, `uni_modules/${uniModuleId}?${isX && platform === 'app-android' ? 'uts-proxy' : 'uni_helpers'}`));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
exports.resolveEncryptUniModule = resolveEncryptUniModule;
|
|
518
|
+
async function checkEncryptUniModules(inputDir, params) {
|
|
519
|
+
// 扫描加密插件云编译
|
|
520
|
+
encryptUniModules = findEncryptUniModules(inputDir, process.env.UNI_MODULES_ENCRYPT_CACHE_DIR);
|
|
521
|
+
if (!Object.keys(encryptUniModules).length) {
|
|
522
|
+
return {};
|
|
523
|
+
}
|
|
524
|
+
if (!process.env.UNI_HBUILDERX_PLUGINS) {
|
|
525
|
+
return {};
|
|
526
|
+
}
|
|
527
|
+
const cacheDir = process.env.UNI_MODULES_ENCRYPT_CACHE_DIR;
|
|
528
|
+
const { zipFile, modules } = packUploadEncryptUniModules(encryptUniModules, process.env.UNI_UTS_PLATFORM, inputDir, cacheDir);
|
|
529
|
+
if (zipFile) {
|
|
530
|
+
const downloadFile = path_1.default.resolve(cacheDir, 'uni_modules.download.zip');
|
|
531
|
+
const { C, D, R, U } = (0, utils_1.requireUniHelpers)();
|
|
532
|
+
try {
|
|
533
|
+
const isLogin = await C();
|
|
534
|
+
const tips = process.env.UNI_UTS_PLATFORM !== 'app-android'
|
|
535
|
+
? '(此过程耗时较长)'
|
|
536
|
+
: '';
|
|
537
|
+
console.log(`正在云编译插件${isLogin ? '' : '(请先登录)'}${tips}:${modules.join(',')}...`);
|
|
538
|
+
let downloadUrl = '';
|
|
539
|
+
try {
|
|
540
|
+
downloadUrl = await U({
|
|
541
|
+
params,
|
|
542
|
+
attachment: zipFile,
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
catch (e) {
|
|
546
|
+
if (e.message && e.message === '{"error":"UserNotLogin"}') {
|
|
547
|
+
console.log('当前项目包含需要云编译的付费插件,需要您先登录HBuilderX账号。');
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
console.error(e);
|
|
551
|
+
}
|
|
552
|
+
process.exit(0);
|
|
553
|
+
}
|
|
554
|
+
await D(downloadUrl, downloadFile);
|
|
555
|
+
// unzip
|
|
556
|
+
const AdmZip = require('adm-zip');
|
|
557
|
+
const zip = new AdmZip(downloadFile);
|
|
558
|
+
zip.extractAllTo(cacheDir, true);
|
|
559
|
+
fs_extra_1.default.unlinkSync(zipFile);
|
|
560
|
+
fs_extra_1.default.unlinkSync(downloadFile);
|
|
561
|
+
R({
|
|
562
|
+
dir: process.env.UNI_INPUT_DIR,
|
|
563
|
+
cacheDir: process.env.UNI_MODULES_ENCRYPT_CACHE_DIR,
|
|
564
|
+
});
|
|
565
|
+
console.log(`云编译已完成`);
|
|
566
|
+
console.log(`正在编译中...`);
|
|
567
|
+
}
|
|
568
|
+
catch (e) {
|
|
569
|
+
fs_extra_1.default.existsSync(zipFile) && fs_extra_1.default.unlinkSync(zipFile);
|
|
570
|
+
fs_extra_1.default.existsSync(downloadFile) && fs_extra_1.default.unlinkSync(downloadFile);
|
|
571
|
+
console.error(e);
|
|
572
|
+
process.exit(0);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
// android 平台需要在这里初始化
|
|
577
|
+
if (params.platform === 'app-android') {
|
|
578
|
+
const { R } = (0, utils_1.requireUniHelpers)();
|
|
579
|
+
R({
|
|
580
|
+
dir: process.env.UNI_INPUT_DIR,
|
|
581
|
+
cacheDir: process.env.UNI_MODULES_ENCRYPT_CACHE_DIR,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
encryptUniModules = findEncryptUniModules(inputDir, process.env.UNI_MODULES_ENCRYPT_CACHE_DIR);
|
|
586
|
+
}
|
|
587
|
+
exports.checkEncryptUniModules = checkEncryptUniModules;
|
|
588
|
+
function parseUniModulesArtifacts() {
|
|
589
|
+
const res = [];
|
|
590
|
+
Object.keys(encryptUniModules).forEach((uniModuleId) => {
|
|
591
|
+
const pkg = encryptUniModules[uniModuleId];
|
|
592
|
+
if (pkg?.uni_modules?.artifacts) {
|
|
593
|
+
res.push({
|
|
594
|
+
name: uniModuleId,
|
|
595
|
+
package: `uts.sdk.modules.${(0, exports.camelize)(uniModuleId)}`,
|
|
596
|
+
scopedSlots: pkg.uni_modules.artifacts.scopedSlots || [],
|
|
597
|
+
declaration: pkg.uni_modules.artifacts.declaration,
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
return res;
|
|
602
|
+
}
|
|
603
|
+
exports.parseUniModulesArtifacts = parseUniModulesArtifacts;
|
package/dist/utils.d.ts
CHANGED
|
@@ -35,4 +35,3 @@ export declare function enableSourceMap(): boolean;
|
|
|
35
35
|
export declare function requireUniHelpers(): any;
|
|
36
36
|
export declare function normalizeEmitAssetFileName(fileName: string): string;
|
|
37
37
|
export declare function createShadowImageUrl(cdn: number, type?: string): string;
|
|
38
|
-
export declare function isNormalCompileTarget(): 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.
|
|
6
|
+
exports.createShadowImageUrl = exports.normalizeEmitAssetFileName = exports.requireUniHelpers = exports.enableSourceMap = 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"));
|
|
@@ -169,13 +169,8 @@ function createResolveErrorMsg(source, importer) {
|
|
|
169
169
|
}
|
|
170
170
|
exports.createResolveErrorMsg = createResolveErrorMsg;
|
|
171
171
|
function enableSourceMap() {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
if (process.env.UNI_APP_SOURCEMAP === 'false') {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
return process.env.NODE_ENV === 'development' && isNormalCompileTarget();
|
|
172
|
+
return (process.env.NODE_ENV === 'development' &&
|
|
173
|
+
process.env.UNI_COMPILE_TARGET !== 'uni_modules');
|
|
179
174
|
}
|
|
180
175
|
exports.enableSourceMap = enableSourceMap;
|
|
181
176
|
function requireUniHelpers() {
|
|
@@ -218,8 +213,3 @@ function createShadowImageUrl(cdn, type = 'grey') {
|
|
|
218
213
|
return `https://cdn${(cdn || 0) + (process.env.UNI_APP_X === 'true' ? 1000 : 0) || ''}.dcloud.net.cn/${identStr}img/shadow-${type}.png`;
|
|
219
214
|
}
|
|
220
215
|
exports.createShadowImageUrl = createShadowImageUrl;
|
|
221
|
-
function isNormalCompileTarget() {
|
|
222
|
-
// 目前有特殊编译目标 uni_modules 和 ext-api
|
|
223
|
-
return !process.env.UNI_COMPILE_TARGET;
|
|
224
|
-
}
|
|
225
|
-
exports.isNormalCompileTarget = isNormalCompileTarget;
|
package/dist/uts.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare function resolveUTSAppModule(platform: typeof process.env.UNI_UTS
|
|
|
12
12
|
export declare function resolveUTSModule(id: string, importer: string, includeUTSSDK?: boolean): string | undefined;
|
|
13
13
|
export declare function resolveUTSCompiler(): typeof UTSCompiler;
|
|
14
14
|
export declare function isUTSComponent(name: string): boolean;
|
|
15
|
-
export declare function getUTSComponentAutoImports(
|
|
15
|
+
export declare function getUTSComponentAutoImports(): Record<string, [[string]]>;
|
|
16
16
|
export declare function parseUTSComponent(name: string, type: 'kotlin' | 'swift'): {
|
|
17
17
|
className: string;
|
|
18
18
|
namespace: string;
|
|
@@ -25,10 +25,3 @@ export type UTSTargetLanguage = typeof process.env.UNI_UTS_TARGET_LANGUAGE;
|
|
|
25
25
|
export declare const parseUniExtApiNamespacesOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
|
|
26
26
|
export declare const parseUniExtApiNamespacesJsOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
|
|
27
27
|
export declare function resolveUniTypeScript(): any;
|
|
28
|
-
export declare function initUTSKotlinAutoImportsOnce(): Promise<Record<string, [string, (string | undefined)?][]>>;
|
|
29
|
-
export declare function initUTSSwiftAutoImportsOnce(): Promise<Record<string, [string, (string | undefined)?][]>>;
|
|
30
|
-
export declare const genUniExtApiDeclarationFileOnce: (tscInputDir: string) => void;
|
|
31
|
-
export declare function uvueOutDir(platform: 'app-android' | 'app-ios' | 'app-harmony'): string;
|
|
32
|
-
export declare function tscOutDir(platform: 'app-android' | 'app-ios' | 'app-harmony'): string;
|
|
33
|
-
export declare function isUTSProxy(id: string): boolean;
|
|
34
|
-
export declare function isUniHelpers(id: string): boolean;
|