@dcloudio/uni-cli-shared 3.0.0-alpha-3050520220824001 → 3.0.0-alpha-3060020220830002
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/constants.js +1 -0
- package/dist/preprocess/context.js +12 -0
- package/dist/resolve.d.ts +1 -0
- package/dist/resolve.js +35 -13
- package/package.json +3 -3
package/dist/constants.js
CHANGED
|
@@ -8,6 +8,8 @@ const DEFAULT_KEYS = [
|
|
|
8
8
|
'APP_PLUS',
|
|
9
9
|
'APP_PLUS_NVUE',
|
|
10
10
|
'APP_VUE',
|
|
11
|
+
'APP_ANDROID',
|
|
12
|
+
'APP_IOS',
|
|
11
13
|
'H5',
|
|
12
14
|
'MP',
|
|
13
15
|
'MP_360',
|
|
@@ -52,6 +54,16 @@ function initPreContext(platform, userPreContext) {
|
|
|
52
54
|
vueContext.APP_VUE = true;
|
|
53
55
|
nvueContext.APP_NVUE = true;
|
|
54
56
|
nvueContext.APP_PLUS_NVUE = true;
|
|
57
|
+
if (process.env.UNI_APP_PLATFORM === 'android') {
|
|
58
|
+
defaultContext.APP_ANDROID = true;
|
|
59
|
+
}
|
|
60
|
+
else if (process.env.UNI_APP_PLATFORM === 'ios') {
|
|
61
|
+
defaultContext.APP_IOS = true;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
defaultContext.APP_ANDROID = true;
|
|
65
|
+
defaultContext.APP_IOS = true;
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
68
|
else if (platform.startsWith('mp-')) {
|
|
57
69
|
defaultContext.MP = true;
|
package/dist/resolve.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare function getBuiltInPaths(): string[];
|
|
|
5
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 resolveUtsModule(id: string, importer: string, platform: typeof process.env.UNI_UTS_PLATFORM): string | undefined;
|
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.resolveComponentsLibPath = exports.resolveVueI18nRuntime = exports.resolveBuiltIn = exports.getBuiltInPaths = exports.resolveMainPathOnce = exports.relativeFile = exports.requireResolve = void 0;
|
|
6
|
+
exports.resolveUtsModule = 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"));
|
|
@@ -22,18 +22,6 @@ function resolveWithSymlinks(id, basedir) {
|
|
|
22
22
|
extensions: constants_1.extensions,
|
|
23
23
|
// necessary to work with pnpm
|
|
24
24
|
preserveSymlinks: true,
|
|
25
|
-
pathFilter(pkg, filepath, relativePath) {
|
|
26
|
-
if (pkg.uni_modules && pkg.uni_modules.type === 'uts') {
|
|
27
|
-
if (process.env.UNI_APP_PLATFORM === 'app-android' ||
|
|
28
|
-
process.env.UNI_APP_PLATFORM === 'app-ios') {
|
|
29
|
-
const file = process.env.UNI_APP_PLATFORM + '/index.uts';
|
|
30
|
-
if (fs_1.default.existsSync(path_1.default.join(filepath.replace(relativePath, ''), file))) {
|
|
31
|
-
return file;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return relativePath;
|
|
36
|
-
},
|
|
37
25
|
});
|
|
38
26
|
}
|
|
39
27
|
function relativeFile(from, to) {
|
|
@@ -116,3 +104,37 @@ function resolveComponentsLibPath() {
|
|
|
116
104
|
return componentsLibPath;
|
|
117
105
|
}
|
|
118
106
|
exports.resolveComponentsLibPath = resolveComponentsLibPath;
|
|
107
|
+
// 仅限 root/uni_modules/test-plugin | root/utssdk/test-plugin 格式
|
|
108
|
+
function resolveUtsModule(id, importer, platform) {
|
|
109
|
+
id = path_1.default.resolve(importer, id);
|
|
110
|
+
if (id.includes('utssdk') || id.includes('uni_modules')) {
|
|
111
|
+
const parts = (0, utils_1.normalizePath)(id).split('/');
|
|
112
|
+
const parentDir = parts[parts.length - 2];
|
|
113
|
+
if (parentDir === 'uni_modules' || parentDir === 'utssdk') {
|
|
114
|
+
const index = path_1.default.resolve(id, 'index.uts');
|
|
115
|
+
if (fs_1.default.existsSync(index)) {
|
|
116
|
+
return index;
|
|
117
|
+
}
|
|
118
|
+
if (parentDir === 'uni_modules' &&
|
|
119
|
+
!fs_1.default.existsSync(path_1.default.join(id, 'utssdk'))) {
|
|
120
|
+
// uni_modules/test-plugin/utssdk不存在
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const platformDir = path_1.default.resolve(id, parentDir === 'uni_modules' ? 'utssdk' : '', platform);
|
|
124
|
+
// App平台仅支持 uts
|
|
125
|
+
if (platform === 'app-android' || platform === 'app-ios') {
|
|
126
|
+
return resolveUtsFile(platformDir, ['.uts']);
|
|
127
|
+
}
|
|
128
|
+
return resolveUtsFile(platformDir);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.resolveUtsModule = resolveUtsModule;
|
|
133
|
+
function resolveUtsFile(dir, extensions = ['.uts', '.ts', '.js']) {
|
|
134
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
135
|
+
const indexFile = path_1.default.join(dir, 'index' + extensions[i]);
|
|
136
|
+
if (fs_1.default.existsSync(indexFile)) {
|
|
137
|
+
return indexFile;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
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-3060020220830002",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"@babel/core": "^7.17.9",
|
|
23
23
|
"@babel/parser": "^7.17.9",
|
|
24
24
|
"@babel/types": "^7.17.0",
|
|
25
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
26
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
25
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3060020220830002",
|
|
26
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3060020220830002",
|
|
27
27
|
"@intlify/core-base": "9.1.9",
|
|
28
28
|
"@intlify/shared": "9.1.9",
|
|
29
29
|
"@intlify/vue-devtools": "9.1.9",
|