@dcloudio/uni-cli-shared 3.0.0-alpha-4010920240607001 → 3.0.0-alpha-4020120240618001
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/easycom.js +10 -1
- package/dist/fs.js +8 -5
- package/dist/json/theme.js +55 -1
- package/dist/preprocess/context.js +9 -2
- package/dist/uni_modules.d.ts +1 -0
- package/dist/uni_modules.js +16 -1
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +17 -2
- package/dist/uts.d.ts +1 -1
- package/dist/uts.js +10 -3
- package/dist/vite/autoImport.js +4 -1
- package/dist/vite/plugins/uts/uni_modules.d.ts +1 -1
- package/dist/vite/plugins/uts/uni_modules.js +57 -5
- package/dist/vite/plugins/vitejs/plugins/asset.js +1 -1
- package/package.json +4 -4
- package/dist/utils.spec.d.ts +0 -1
- package/dist/utils.spec.js +0 -17
package/dist/easycom.js
CHANGED
|
@@ -174,7 +174,16 @@ function matchEasycom(tag) {
|
|
|
174
174
|
return source;
|
|
175
175
|
}
|
|
176
176
|
exports.matchEasycom = matchEasycom;
|
|
177
|
-
const isDir = (path) =>
|
|
177
|
+
const isDir = (path) => {
|
|
178
|
+
const stat = fs_1.default.lstatSync(path);
|
|
179
|
+
if (stat.isDirectory()) {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
else if (stat.isSymbolicLink()) {
|
|
183
|
+
return fs_1.default.lstatSync(fs_1.default.realpathSync(path)).isDirectory();
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
};
|
|
178
187
|
function initAutoScanEasycom(dir, rootDir, extensions) {
|
|
179
188
|
if (!path_1.default.isAbsolute(dir)) {
|
|
180
189
|
dir = path_1.default.resolve(rootDir, dir);
|
package/dist/fs.js
CHANGED
|
@@ -7,12 +7,15 @@ exports.emptyDir = void 0;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
function emptyDir(dir, skip = []) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
try {
|
|
11
|
+
for (const file of fs_1.default.readdirSync(dir)) {
|
|
12
|
+
if (skip.includes(file)) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
// node >= 14.14.0
|
|
16
|
+
fs_1.default.rmSync(path_1.default.resolve(dir, file), { recursive: true, force: true });
|
|
13
17
|
}
|
|
14
|
-
// node >= 14.14.0
|
|
15
|
-
fs_1.default.rmSync(path_1.default.resolve(dir, file), { recursive: true, force: true });
|
|
16
18
|
}
|
|
19
|
+
catch (e) { }
|
|
17
20
|
}
|
|
18
21
|
exports.emptyDir = emptyDir;
|
package/dist/json/theme.js
CHANGED
|
@@ -27,7 +27,61 @@ const parseThemeJson = (themeLocation = 'theme.json') => {
|
|
|
27
27
|
return (0, json_1.parseJson)(jsonStr, true);
|
|
28
28
|
};
|
|
29
29
|
exports.parseThemeJson = parseThemeJson;
|
|
30
|
-
|
|
30
|
+
const SCHEME_RE = /^([a-z-]+:)?\/\//i;
|
|
31
|
+
const DATA_RE = /^data:.*,.*/;
|
|
32
|
+
function normalizeFilepath(filepath) {
|
|
33
|
+
if (!(SCHEME_RE.test(filepath) || DATA_RE.test(filepath)) &&
|
|
34
|
+
filepath.indexOf('/') !== 0) {
|
|
35
|
+
return (0, uni_shared_1.addLeadingSlash)(filepath);
|
|
36
|
+
}
|
|
37
|
+
return filepath;
|
|
38
|
+
}
|
|
39
|
+
const parseThemeJsonIconPath = (themeConfig, curPathThemeJsonKey) => {
|
|
40
|
+
if (themeConfig.light?.[curPathThemeJsonKey]) {
|
|
41
|
+
themeConfig.light[curPathThemeJsonKey] = normalizeFilepath(themeConfig.light[curPathThemeJsonKey]);
|
|
42
|
+
}
|
|
43
|
+
if (themeConfig.dark?.[curPathThemeJsonKey]) {
|
|
44
|
+
themeConfig.dark[curPathThemeJsonKey] = normalizeFilepath(themeConfig.dark[curPathThemeJsonKey]);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function normalizeUniConfigThemeJsonIconPath(themeConfig, pagesJson) {
|
|
48
|
+
// 处理 tabbar 下 list -> item -> iconPath、selectedIconPath; midButton -> backgroundImage 路径 / 不开头的情况
|
|
49
|
+
const tabBar = pagesJson.tabBar;
|
|
50
|
+
if (tabBar) {
|
|
51
|
+
tabBar.list.forEach((item) => {
|
|
52
|
+
if (item.iconPath && item.iconPath.indexOf('@') === 0) {
|
|
53
|
+
parseThemeJsonIconPath(themeConfig, item.iconPath.replace(/^@/, ''));
|
|
54
|
+
}
|
|
55
|
+
if (item.selectedIconPath && item.selectedIconPath.indexOf('@') === 0) {
|
|
56
|
+
parseThemeJsonIconPath(themeConfig, item.selectedIconPath.replace(/^@/, ''));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const midButtonBackgroundImage = tabBar.midButton?.backgroundImage;
|
|
60
|
+
if (midButtonBackgroundImage &&
|
|
61
|
+
midButtonBackgroundImage.indexOf('@') === 0) {
|
|
62
|
+
parseThemeJsonIconPath(themeConfig, midButtonBackgroundImage.replace(/^@/, ''));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return themeConfig;
|
|
66
|
+
}
|
|
67
|
+
const getPagesJson = (inputDir) => {
|
|
68
|
+
const pagesFilename = path_1.default.join(inputDir, 'pages.json');
|
|
69
|
+
if (!fs_1.default.existsSync(pagesFilename)) {
|
|
70
|
+
return {
|
|
71
|
+
pages: [],
|
|
72
|
+
globalStyle: { navigationBar: {} },
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const jsonStr = fs_1.default.readFileSync(pagesFilename, 'utf8');
|
|
76
|
+
return (0, json_1.parseJson)(jsonStr, true);
|
|
77
|
+
};
|
|
78
|
+
exports.normalizeThemeConfigOnce = (0, uni_shared_1.once)((manifestJsonPlatform = {}) => {
|
|
79
|
+
const themeConfig = (0, exports.parseThemeJson)(manifestJsonPlatform.themeLocation);
|
|
80
|
+
if (process.env.UNI_INPUT_DIR) {
|
|
81
|
+
normalizeUniConfigThemeJsonIconPath(themeConfig, getPagesJson(process.env.UNI_INPUT_DIR));
|
|
82
|
+
}
|
|
83
|
+
return themeConfig;
|
|
84
|
+
});
|
|
31
85
|
function initTheme(manifestJson, pagesJson) {
|
|
32
86
|
const platform = process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM;
|
|
33
87
|
const manifestPlatform = manifestJson['plus'] || manifestJson[platform] || {};
|
|
@@ -69,9 +69,16 @@ function initPreContext(platform, userPreContext, utsPlatform, isX) {
|
|
|
69
69
|
nvueContext.UNI_APP_X = true;
|
|
70
70
|
uvueContext.UNI_APP_X = true;
|
|
71
71
|
}
|
|
72
|
-
if (platform === 'app' ||
|
|
72
|
+
if (platform === 'app' ||
|
|
73
|
+
platform === 'app-plus' ||
|
|
74
|
+
platform === 'app-harmony') {
|
|
73
75
|
defaultContext.APP = true;
|
|
74
|
-
|
|
76
|
+
if (platform === 'app-harmony') {
|
|
77
|
+
defaultContext.APP_HARMONY = true;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
defaultContext.APP_PLUS = isX ? false : true;
|
|
81
|
+
}
|
|
75
82
|
vueContext.APP_VUE = true;
|
|
76
83
|
nvueContext.APP_NVUE = true;
|
|
77
84
|
nvueContext.APP_PLUS_NVUE = true;
|
package/dist/uni_modules.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare function getUniExtApiProviderRegisters(): {
|
|
|
30
30
|
class: string;
|
|
31
31
|
}[];
|
|
32
32
|
export declare function parseUniExtApis(vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language?: UTSTargetLanguage): Injects;
|
|
33
|
+
export declare function parseUniExtApi(pluginDir: string, pluginId: string, vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language?: UTSTargetLanguage): Injects | undefined;
|
|
33
34
|
export type Injects = {
|
|
34
35
|
[name: string]: string | [string, string] | [string, string, DefineOptions['app']] | false;
|
|
35
36
|
};
|
package/dist/uni_modules.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.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.parseUniExtApis = exports.getUniExtApiProviderRegisters = 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.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"));
|
|
@@ -80,6 +80,21 @@ function parseUniExtApis(vite = true, platform, language = 'javascript') {
|
|
|
80
80
|
return injects;
|
|
81
81
|
}
|
|
82
82
|
exports.parseUniExtApis = parseUniExtApis;
|
|
83
|
+
function parseUniExtApi(pluginDir, pluginId, vite = true, platform, language = 'javascript') {
|
|
84
|
+
const pkgPath = path_1.default.resolve(pluginDir, 'package.json');
|
|
85
|
+
if (!fs_extra_1.default.existsSync(pkgPath)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
let exports;
|
|
89
|
+
const pkg = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'));
|
|
90
|
+
if (pkg && pkg.uni_modules && pkg.uni_modules['uni-ext-api']) {
|
|
91
|
+
exports = pkg.uni_modules['uni-ext-api'];
|
|
92
|
+
}
|
|
93
|
+
if (exports) {
|
|
94
|
+
return parseInjects(vite, platform, language, `@/uni_modules/${pluginId}`, pluginDir, exports);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.parseUniExtApi = parseUniExtApi;
|
|
83
98
|
/**
|
|
84
99
|
* uni:'getBatteryInfo'
|
|
85
100
|
* import getBatteryInfo from '..'
|
package/dist/utils.d.ts
CHANGED
|
@@ -22,9 +22,15 @@ export declare function pathToGlob(pathString: string, glob: string, options?: {
|
|
|
22
22
|
}): string;
|
|
23
23
|
export declare function resolveSourceMapPath(outputDir?: string, platform?: UniApp.PLATFORM): string;
|
|
24
24
|
export declare function installDepTips(type: 'dependencies' | 'devDependencies', module: string, version?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* 根据路径判断是否为 App.(u?)vue
|
|
27
|
+
* @param {string} filename 相对、绝对路径
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
25
30
|
export declare function isAppVue(filename: string): boolean;
|
|
26
31
|
export declare function resolveAppVue(inputDir: string): string;
|
|
27
32
|
export declare function parseImporter(importer: string): string;
|
|
28
33
|
export declare function createResolveErrorMsg(source: string, importer: string): string;
|
|
29
34
|
export declare function enableSourceMap(): boolean;
|
|
30
35
|
export declare function requireUniHelpers(): any;
|
|
36
|
+
export declare function normalizeEmitAssetFileName(fileName: 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.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;
|
|
6
|
+
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"));
|
|
@@ -135,8 +135,14 @@ function installDepTips(type, module, version) {
|
|
|
135
135
|
Please run \`${picocolors_1.default.cyan(`${getInstallCommand(process.cwd())} ${module + (version ? '@' + version : '')}${type === 'devDependencies' ? ' -D' : ''}`)}\` and try again.`;
|
|
136
136
|
}
|
|
137
137
|
exports.installDepTips = installDepTips;
|
|
138
|
+
/**
|
|
139
|
+
* 根据路径判断是否为 App.(u?)vue
|
|
140
|
+
* @param {string} filename 相对、绝对路径
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
138
143
|
function isAppVue(filename) {
|
|
139
|
-
|
|
144
|
+
const _filePath = normalizePath(filename);
|
|
145
|
+
return /(\/|\\)app\.(u?)vue$/.test(_filePath.toLowerCase());
|
|
140
146
|
}
|
|
141
147
|
exports.isAppVue = isAppVue;
|
|
142
148
|
function resolveAppVue(inputDir) {
|
|
@@ -169,3 +175,12 @@ function requireUniHelpers() {
|
|
|
169
175
|
return require(path_1.default.join(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers'));
|
|
170
176
|
}
|
|
171
177
|
exports.requireUniHelpers = requireUniHelpers;
|
|
178
|
+
function normalizeEmitAssetFileName(fileName) {
|
|
179
|
+
if (process.env.UNI_APP_X_TSC === 'true') {
|
|
180
|
+
if (path_1.default.extname(fileName) !== '.ts') {
|
|
181
|
+
return fileName + '.ts';
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return fileName;
|
|
185
|
+
}
|
|
186
|
+
exports.normalizeEmitAssetFileName = normalizeEmitAssetFileName;
|
package/dist/uts.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { EasycomMatcher } from './easycom';
|
|
|
8
8
|
* @param importer
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
|
-
export declare function resolveUTSAppModule(id: string, importer: string, includeUTSSDK?: boolean): string | undefined;
|
|
11
|
+
export declare function resolveUTSAppModule(platform: typeof process.env.UNI_UTS_PLATFORM, id: string, importer: string, includeUTSSDK?: boolean): string | undefined;
|
|
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;
|
package/dist/uts.js
CHANGED
|
@@ -27,7 +27,7 @@ function once(fn, ctx = null) {
|
|
|
27
27
|
* @param importer
|
|
28
28
|
* @returns
|
|
29
29
|
*/
|
|
30
|
-
function resolveUTSAppModule(id, importer, includeUTSSDK = true) {
|
|
30
|
+
function resolveUTSAppModule(platform, id, importer, includeUTSSDK = true) {
|
|
31
31
|
id = path_1.default.resolve(importer, id);
|
|
32
32
|
if (id.includes('uni_modules') || (includeUTSSDK && id.includes('utssdk'))) {
|
|
33
33
|
const parts = (0, utils_1.normalizePath)(id).split('/');
|
|
@@ -51,6 +51,12 @@ function resolveUTSAppModule(id, importer, includeUTSSDK = true) {
|
|
|
51
51
|
return path_1.default.resolve(id, basedir, p);
|
|
52
52
|
};
|
|
53
53
|
const extname = ['.uts'];
|
|
54
|
+
if (platform === 'app-harmony') {
|
|
55
|
+
if (resolveUTSFile(resolvePlatformDir(platform), extname)) {
|
|
56
|
+
return id;
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
54
60
|
if (resolveUTSFile(resolvePlatformDir('app-android'), extname)) {
|
|
55
61
|
return id;
|
|
56
62
|
}
|
|
@@ -64,8 +70,9 @@ exports.resolveUTSAppModule = resolveUTSAppModule;
|
|
|
64
70
|
// 仅限 root/uni_modules/test-plugin | root/utssdk/test-plugin 格式
|
|
65
71
|
function resolveUTSModule(id, importer, includeUTSSDK = true) {
|
|
66
72
|
if (process.env.UNI_PLATFORM === 'app' ||
|
|
67
|
-
process.env.UNI_PLATFORM === 'app-plus'
|
|
68
|
-
|
|
73
|
+
process.env.UNI_PLATFORM === 'app-plus' ||
|
|
74
|
+
process.env.UNI_PLATFORM === 'app-harmony') {
|
|
75
|
+
return resolveUTSAppModule(process.env.UNI_UTS_PLATFORM, id, importer);
|
|
69
76
|
}
|
|
70
77
|
id = path_1.default.resolve(importer, id);
|
|
71
78
|
if (id.includes('uni_modules') || (includeUTSSDK && id.includes('utssdk'))) {
|
package/dist/vite/autoImport.js
CHANGED
|
@@ -12,7 +12,6 @@ const uniPreset = {
|
|
|
12
12
|
'onShow',
|
|
13
13
|
'onHide',
|
|
14
14
|
// App
|
|
15
|
-
'onAppShow',
|
|
16
15
|
'onLaunch',
|
|
17
16
|
'onError',
|
|
18
17
|
'onThemeChange',
|
|
@@ -40,6 +39,10 @@ const uniPreset = {
|
|
|
40
39
|
const uniH5Preset = {
|
|
41
40
|
from: '@dcloudio/uni-h5',
|
|
42
41
|
imports: [
|
|
42
|
+
'onAppShow',
|
|
43
|
+
'onAppHide',
|
|
44
|
+
'offAppHide',
|
|
45
|
+
'offAppShow',
|
|
43
46
|
'UniElement',
|
|
44
47
|
'UniElementImpl',
|
|
45
48
|
'UniButtonElement',
|
|
@@ -5,7 +5,7 @@ interface UniUTSPluginOptions {
|
|
|
5
5
|
isSingleThread?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare const utsPlugins: Set<string>;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function uniUTSAppUniModulesPlugin(options?: UniUTSPluginOptions): Plugin;
|
|
9
9
|
export declare function buildUniExtApis(): Promise<void>;
|
|
10
10
|
export declare function resolveExtApiProvider(pkg: Record<string, any>): {
|
|
11
11
|
name?: string | undefined;
|
|
@@ -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.uniDecryptUniModulesPlugin = exports.resolveExtApiProvider = exports.buildUniExtApis = exports.
|
|
6
|
+
exports.uniDecryptUniModulesPlugin = exports.resolveExtApiProvider = exports.buildUniExtApis = exports.uniUTSAppUniModulesPlugin = exports.utsPlugins = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
@@ -23,12 +23,14 @@ function isUniHelpers(id) {
|
|
|
23
23
|
const utsModuleCaches = new Map();
|
|
24
24
|
exports.utsPlugins = new Set();
|
|
25
25
|
let uniExtApiCompiler = async () => { };
|
|
26
|
-
|
|
26
|
+
// 该插件仅限app-android、app-ios、app-harmony
|
|
27
|
+
function uniUTSAppUniModulesPlugin(options = {}) {
|
|
27
28
|
const inputDir = process.env.UNI_INPUT_DIR;
|
|
28
29
|
process.env.UNI_UTS_USING_ROLLUP = 'true';
|
|
29
30
|
const compilePlugin = async (pluginDir) => {
|
|
30
31
|
exports.utsPlugins.add(path_1.default.basename(pluginDir));
|
|
31
32
|
const pkgJson = require(path_1.default.join(pluginDir, 'package.json'));
|
|
33
|
+
const isExtApi = !!pkgJson.uni_modules?.['uni-ext-api'];
|
|
32
34
|
const extApiProvider = resolveExtApiProvider(pkgJson);
|
|
33
35
|
// 如果是 provider 扩展,需要判断 provider 的宿主插件是否在本地,在的话,自动导入该宿主插件包名
|
|
34
36
|
let uniExtApiProviderServicePlugin = '';
|
|
@@ -45,6 +47,12 @@ function uniUTSUniModulesPlugin(options = {}) {
|
|
|
45
47
|
await compilePlugin(path_1.default.resolve(inputDir, 'uni_modules', dep));
|
|
46
48
|
}
|
|
47
49
|
}
|
|
50
|
+
if (process.env.UNI_PLATFORM === 'app-harmony') {
|
|
51
|
+
return compiler.compileArkTS(pluginDir, {
|
|
52
|
+
isX: !!options.x,
|
|
53
|
+
isExtApi,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
48
56
|
return compiler.compile(pluginDir, {
|
|
49
57
|
isX: !!options.x,
|
|
50
58
|
isSingleThread: !!options.isSingleThread,
|
|
@@ -84,7 +92,7 @@ function uniUTSUniModulesPlugin(options = {}) {
|
|
|
84
92
|
if (id.endsWith('.css')) {
|
|
85
93
|
return;
|
|
86
94
|
}
|
|
87
|
-
const module = (0, uts_1.resolveUTSAppModule)(id, importer ? path_1.default.dirname(importer) : inputDir, options.x !== true);
|
|
95
|
+
const module = (0, uts_1.resolveUTSAppModule)(process.env.UNI_UTS_PLATFORM, id, importer ? path_1.default.dirname(importer) : inputDir, options.x !== true);
|
|
88
96
|
if (module) {
|
|
89
97
|
// app-js 会直接返回 index.uts 路径,不需要 uts-proxy
|
|
90
98
|
if (module.endsWith('.uts')) {
|
|
@@ -144,10 +152,14 @@ function uniUTSUniModulesPlugin(options = {}) {
|
|
|
144
152
|
};
|
|
145
153
|
}
|
|
146
154
|
},
|
|
147
|
-
async generateBundle() {
|
|
155
|
+
async generateBundle() {
|
|
156
|
+
if (process.env.UNI_PLATFORM === 'app-harmony') {
|
|
157
|
+
genAppHarmonyIndex(inputDir, exports.utsPlugins);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
148
160
|
};
|
|
149
161
|
}
|
|
150
|
-
exports.
|
|
162
|
+
exports.uniUTSAppUniModulesPlugin = uniUTSAppUniModulesPlugin;
|
|
151
163
|
async function buildUniExtApis() {
|
|
152
164
|
await uniExtApiCompiler();
|
|
153
165
|
}
|
|
@@ -201,3 +213,43 @@ function uniDecryptUniModulesPlugin() {
|
|
|
201
213
|
};
|
|
202
214
|
}
|
|
203
215
|
exports.uniDecryptUniModulesPlugin = uniDecryptUniModulesPlugin;
|
|
216
|
+
function genAppHarmonyIndex(inputDir, utsPlugins) {
|
|
217
|
+
if (!process.env.UNI_APP_HARMONY_PROJECT_PATH) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const uniModulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
221
|
+
const importCodes = [];
|
|
222
|
+
const extApiCodes = [];
|
|
223
|
+
const registerCodes = [];
|
|
224
|
+
utsPlugins.forEach((plugin) => {
|
|
225
|
+
const injects = (0, uni_modules_1.parseUniExtApi)(path_1.default.resolve(uniModulesDir, plugin), plugin, true, 'app-harmony', 'arkts');
|
|
226
|
+
if (injects) {
|
|
227
|
+
Object.keys(injects).forEach((key) => {
|
|
228
|
+
const inject = injects[key];
|
|
229
|
+
if (Array.isArray(inject) && inject.length > 1) {
|
|
230
|
+
const apiName = inject[1];
|
|
231
|
+
importCodes.push(`import { ${inject[1]} } from './${plugin}/utssdk/app-harmony'`);
|
|
232
|
+
extApiCodes.push(`uni.${apiName} = ${apiName}`);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
const ident = (0, utils_2.camelize)(plugin);
|
|
238
|
+
importCodes.push(`import * as ${ident} from './${plugin}/utssdk/app-harmony'`);
|
|
239
|
+
registerCodes.push(`uni.registerUTSPlugin('uni_modules/${plugin}', ${ident})`);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
fs_1.default.writeFileSync(path_1.default.resolve((0, uts_1.resolveUTSCompiler)().resolveAppHarmonyUniModulesRootDir(process.env.UNI_APP_HARMONY_PROJECT_PATH), 'index.generated.ets'), `// This file is automatically generated by uni-app.
|
|
243
|
+
// Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
|
244
|
+
${importCodes.join('\n')}
|
|
245
|
+
|
|
246
|
+
export function initUniModules(uni: ESObject) {
|
|
247
|
+
initUniExtApi(uni)
|
|
248
|
+
${registerCodes.join('\n ')}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function initUniExtApi(uni: ESObject) {
|
|
252
|
+
${extApiCodes.join('\n ')}
|
|
253
|
+
}
|
|
254
|
+
`);
|
|
255
|
+
}
|
|
@@ -96,7 +96,7 @@ function assetPlugin(config, options) {
|
|
|
96
96
|
if (options?.isAndroidX) {
|
|
97
97
|
this.emitFile({
|
|
98
98
|
type: 'asset',
|
|
99
|
-
fileName: (0, utils_3.normalizeNodeModules)(path_1.default.relative(process.env.UNI_INPUT_DIR, id)
|
|
99
|
+
fileName: (0, utils_3.normalizeEmitAssetFileName)((0, utils_3.normalizeNodeModules)(path_1.default.relative(process.env.UNI_INPUT_DIR, id))),
|
|
100
100
|
source: `export default ${JSON.stringify(parseAssets(config, url))}`,
|
|
101
101
|
});
|
|
102
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-4020120240618001",
|
|
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-
|
|
30
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
29
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-4020120240618001",
|
|
30
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-4020120240618001",
|
|
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-
|
|
74
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-4020120240618001",
|
|
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",
|
package/dist/utils.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils.spec.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("./utils");
|
|
4
|
-
describe('test: packages/uni-cli-shared/src/utils.ts', () => {
|
|
5
|
-
test('test:normalizeIdentifier', () => {
|
|
6
|
-
// 根据 path 返回合法 js 变量
|
|
7
|
-
expect((0, utils_1.normalizeIdentifier)('pages/index/index')).toBe('PagesIndexIndex');
|
|
8
|
-
expect((0, utils_1.normalizeIdentifier)('pages/index0.0/index')).toBe('PagesIndex00Index');
|
|
9
|
-
// note: filter `-`
|
|
10
|
-
expect((0, utils_1.normalizeIdentifier)('pages/index1-0/index')).toBe('PagesIndex10Index');
|
|
11
|
-
expect((0, utils_1.normalizeIdentifier)('pages/index2-0///index')).toBe('PagesIndex20Index');
|
|
12
|
-
expect((0, utils_1.normalizeIdentifier)('pages/index3--0/index')).toBe('PagesIndex30Index');
|
|
13
|
-
expect((0, utils_1.normalizeIdentifier)('pages/index4---0/index')).toBe('PagesIndex40Index');
|
|
14
|
-
expect((0, utils_1.normalizeIdentifier)('pages/index5 0/index')).toBe('PagesIndex50Index');
|
|
15
|
-
expect((0, utils_1.normalizeIdentifier)('2pages/index6/index')).toBe('_2pagesIndex6Index');
|
|
16
|
-
});
|
|
17
|
-
});
|