@dcloudio/uni-cli-shared 3.0.0-alpha-3060420220922009 → 3.0.0-alpha-3060720221017001
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.d.ts +0 -1
- package/dist/constants.js +1 -2
- package/dist/hbx/log.js +29 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/json/app/manifest/nvue.d.ts +1 -1
- package/dist/json/pages.d.ts +1 -0
- package/dist/json/pages.js +11 -1
- package/dist/messages/en.d.ts +1 -0
- package/dist/messages/en.js +1 -0
- package/dist/messages/index.d.ts +2 -0
- package/dist/messages/zh_CN.d.ts +1 -0
- package/dist/messages/zh_CN.js +1 -0
- package/dist/uni_modules.d.ts +28 -4
- package/dist/uni_modules.js +46 -59
- package/dist/vite/plugins/index.d.ts +0 -1
- package/dist/vite/plugins/index.js +1 -3
- package/dist/vite/plugins/inject.js +4 -8
- package/dist/vite/utils/url.d.ts +3 -0
- package/dist/vite/utils/url.js +2 -6
- package/package.json +9 -9
- package/dist/vite/plugins/uniModules.d.ts +0 -4
- package/dist/vite/plugins/uniModules.js +0 -26
- package/lib/.DS_Store +0 -0
- package/lib/vue-i18n/.DS_Store +0 -0
package/dist/constants.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export declare const EXTNAME_VUE_RE: RegExp;
|
|
|
7
7
|
export declare const EXTNAME_JS_RE: RegExp;
|
|
8
8
|
export declare const EXTNAME_TS_RE: RegExp;
|
|
9
9
|
export declare const extensions: string[];
|
|
10
|
-
export declare const UNI_MODULES_EXPORTS = "\0uni-modules-exports";
|
|
11
10
|
export declare const PAGES_JSON_JS = "pages-json-js";
|
|
12
11
|
export declare const MANIFEST_JSON_JS = "manifest-json-js";
|
|
13
12
|
export declare const JSON_JS_MAP: {
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_JS = exports.
|
|
3
|
+
exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_JS = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
|
4
4
|
exports.PUBLIC_DIR = 'static';
|
|
5
5
|
exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
|
|
6
6
|
exports.EXTNAME_TS = ['.ts', '.tsx'];
|
|
@@ -18,7 +18,6 @@ exports.extensions = [
|
|
|
18
18
|
'.tsx',
|
|
19
19
|
'.json',
|
|
20
20
|
].concat(exports.EXTNAME_VUE);
|
|
21
|
-
exports.UNI_MODULES_EXPORTS = '\0uni-modules-exports';
|
|
22
21
|
exports.PAGES_JSON_JS = 'pages-json-js';
|
|
23
22
|
exports.MANIFEST_JSON_JS = 'manifest-json-js';
|
|
24
23
|
exports.JSON_JS_MAP = {
|
package/dist/hbx/log.js
CHANGED
|
@@ -15,6 +15,33 @@ const utils_2 = require("../vite/plugins/vitejs/utils");
|
|
|
15
15
|
const SIGNAL_H5_LOCAL = ' ➜ Local:';
|
|
16
16
|
const SIGNAL_H5_NETWORK = ' ➜ Network:';
|
|
17
17
|
const networkLogs = [];
|
|
18
|
+
const ZERO_WIDTH_CHAR = {
|
|
19
|
+
NOTE: '',
|
|
20
|
+
WARNING: '\u200B',
|
|
21
|
+
ERROR: '\u200C',
|
|
22
|
+
backup0: '\u200D',
|
|
23
|
+
backup1: '\u200E',
|
|
24
|
+
backup2: '\u200F',
|
|
25
|
+
backup3: '\uFEFF',
|
|
26
|
+
};
|
|
27
|
+
function overridedConsole(name, oldFn, char) {
|
|
28
|
+
console[name] = function (...args) {
|
|
29
|
+
oldFn.apply(this, args.map((arg) => {
|
|
30
|
+
let item;
|
|
31
|
+
if (typeof arg !== 'object') {
|
|
32
|
+
item = `${char}${arg}${char}`;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
item = `${char}${JSON.stringify(arg)}${char}`;
|
|
36
|
+
}
|
|
37
|
+
return item;
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (typeof console !== 'undefined') {
|
|
42
|
+
overridedConsole('warn', console.warn, ZERO_WIDTH_CHAR.WARNING);
|
|
43
|
+
// overridedConsole('error', console.error, ZERO_WIDTH_CHAR.ERROR)
|
|
44
|
+
}
|
|
18
45
|
function formatAtFilename(filename, line, column) {
|
|
19
46
|
return `at ${picocolors_1.default.cyan((0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename.split('?')[0])) +
|
|
20
47
|
':' +
|
|
@@ -29,7 +56,7 @@ exports.h5ServeFormatter = {
|
|
|
29
56
|
},
|
|
30
57
|
format(msg) {
|
|
31
58
|
if (msg.includes(SIGNAL_H5_NETWORK)) {
|
|
32
|
-
networkLogs.push(msg.replace('➜ ', '
|
|
59
|
+
networkLogs.push(msg.replace('➜ ', '*'));
|
|
33
60
|
process.nextTick(() => {
|
|
34
61
|
if (networkLogs.length) {
|
|
35
62
|
// 延迟打印所有 network,仅最后一个 network 替换 ➜ 为 -,通知 hbx
|
|
@@ -41,7 +68,7 @@ exports.h5ServeFormatter = {
|
|
|
41
68
|
});
|
|
42
69
|
return '';
|
|
43
70
|
}
|
|
44
|
-
return msg.replace('➜ ', '
|
|
71
|
+
return msg.replace('➜ ', '*');
|
|
45
72
|
},
|
|
46
73
|
};
|
|
47
74
|
const REMOVED_MSGS = [
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './esbuild';
|
|
|
20
20
|
export * from './resolve';
|
|
21
21
|
export * from './scripts';
|
|
22
22
|
export * from './platform';
|
|
23
|
+
export { parseUniExtApis } from './uni_modules';
|
|
23
24
|
export { M } from './messages';
|
|
24
25
|
export * from './exports';
|
|
25
26
|
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 = void 0;
|
|
17
|
+
exports.checkUpdate = exports.M = exports.parseUniExtApis = void 0;
|
|
18
18
|
__exportStar(require("./fs"), exports);
|
|
19
19
|
__exportStar(require("./mp"), exports);
|
|
20
20
|
__exportStar(require("./url"), exports);
|
|
@@ -37,6 +37,8 @@ __exportStar(require("./esbuild"), exports);
|
|
|
37
37
|
__exportStar(require("./resolve"), exports);
|
|
38
38
|
__exportStar(require("./scripts"), exports);
|
|
39
39
|
__exportStar(require("./platform"), exports);
|
|
40
|
+
var uni_modules_1 = require("./uni_modules");
|
|
41
|
+
Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
|
|
40
42
|
var messages_1 = require("./messages");
|
|
41
43
|
Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
|
|
42
44
|
__exportStar(require("./exports"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function initNVue(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
|
2
2
|
export declare function getNVueCompiler(manifestJson: Record<string, any>): "uni-app" | "weex" | "vue" | "vite";
|
|
3
3
|
export declare function getNVueStyleCompiler(manifestJson: Record<string, any>): "uni-app" | "weex";
|
|
4
|
-
export declare function getNVueFlexDirection(manifestJson: Record<string, any>): "
|
|
4
|
+
export declare function getNVueFlexDirection(manifestJson: Record<string, any>): "column" | "row" | "row-reverse" | "column-reverse";
|
package/dist/json/pages.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function isUniPageFile(file: string, inputDir?: string): boolean;
|
|
2
|
+
export declare function isUniPageSetupAndTs(file: string): boolean;
|
|
2
3
|
export declare function isUniPageSfcFile(file: string, inputDir?: string): boolean;
|
|
3
4
|
/**
|
|
4
5
|
* 小程序平台慎用,因为该解析不支持 subpackages
|
package/dist/json/pages.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.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageFile = void 0;
|
|
6
|
+
exports.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageFile = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -11,6 +11,8 @@ const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
const json_1 = require("./json");
|
|
13
13
|
const utils_2 = require("../vue/utils");
|
|
14
|
+
const vite_1 = require("../vite");
|
|
15
|
+
const constants_1 = require("../constants");
|
|
14
16
|
const pagesCacheSet = new Set();
|
|
15
17
|
function isUniPageFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
|
16
18
|
if (inputDir && path_1.default.isAbsolute(file)) {
|
|
@@ -19,6 +21,14 @@ function isUniPageFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
|
|
19
21
|
return pagesCacheSet.has((0, utils_1.removeExt)(file));
|
|
20
22
|
}
|
|
21
23
|
exports.isUniPageFile = isUniPageFile;
|
|
24
|
+
function isUniPageSetupAndTs(file) {
|
|
25
|
+
const { filename, query } = (0, vite_1.parseVueRequest)(file);
|
|
26
|
+
return !!(query.vue &&
|
|
27
|
+
query.setup &&
|
|
28
|
+
(0, shared_1.hasOwn)(query, 'lang.ts') &&
|
|
29
|
+
constants_1.EXTNAME_VUE_RE.test(filename));
|
|
30
|
+
}
|
|
31
|
+
exports.isUniPageSetupAndTs = isUniPageSetupAndTs;
|
|
22
32
|
function isUniPageSfcFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
|
23
33
|
return (0, utils_2.isVueSfcFile)(file) && isUniPageFile(file, inputDir);
|
|
24
34
|
}
|
package/dist/messages/en.d.ts
CHANGED
|
@@ -19,5 +19,6 @@ declare const _default: {
|
|
|
19
19
|
readonly 'mp.component.args[1]': "{0} requires two parameters";
|
|
20
20
|
readonly 'mp.360.unsupported': "360 is unsupported";
|
|
21
21
|
readonly 'file.notfound': "{file} is not found";
|
|
22
|
+
readonly 'uts.ios.tips': "The project uses the uts plug-in. After the uts plug-in code is modified, the [Custom playground native runner](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground) needs to be regenerated to take effect";
|
|
22
23
|
};
|
|
23
24
|
export default _default;
|
package/dist/messages/en.js
CHANGED
|
@@ -21,4 +21,5 @@ exports.default = {
|
|
|
21
21
|
'mp.component.args[1]': '{0} requires two parameters',
|
|
22
22
|
'mp.360.unsupported': '360 is unsupported',
|
|
23
23
|
'file.notfound': '{file} is not found',
|
|
24
|
+
'uts.ios.tips': 'The project uses the uts plug-in. After the uts plug-in code is modified, the [Custom playground native runner](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground) needs to be regenerated to take effect',
|
|
24
25
|
};
|
package/dist/messages/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const M: {
|
|
|
19
19
|
readonly 'mp.component.args[1]': "{0}需要两个参数";
|
|
20
20
|
readonly 'mp.360.unsupported': "vue3暂不支持360小程序";
|
|
21
21
|
readonly 'file.notfound': "{file} 文件不存在";
|
|
22
|
+
readonly 'uts.ios.tips': "项目使用了uts插件,iOS平台uts插件代码修改后需要重新生成[自定义基座](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground)才能生效";
|
|
22
23
|
} | {
|
|
23
24
|
readonly 'app.compiler.version': "Compiler version: {version}";
|
|
24
25
|
readonly compiling: "Compiling...";
|
|
@@ -40,4 +41,5 @@ export declare const M: {
|
|
|
40
41
|
readonly 'mp.component.args[1]': "{0} requires two parameters";
|
|
41
42
|
readonly 'mp.360.unsupported': "360 is unsupported";
|
|
42
43
|
readonly 'file.notfound': "{file} is not found";
|
|
44
|
+
readonly 'uts.ios.tips': "The project uses the uts plug-in. After the uts plug-in code is modified, the [Custom playground native runner](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground) needs to be regenerated to take effect";
|
|
43
45
|
};
|
package/dist/messages/zh_CN.d.ts
CHANGED
|
@@ -19,5 +19,6 @@ declare const _default: {
|
|
|
19
19
|
readonly 'mp.component.args[1]': "{0}需要两个参数";
|
|
20
20
|
readonly 'mp.360.unsupported': "vue3暂不支持360小程序";
|
|
21
21
|
readonly 'file.notfound': "{file} 文件不存在";
|
|
22
|
+
readonly 'uts.ios.tips': "项目使用了uts插件,iOS平台uts插件代码修改后需要重新生成[自定义基座](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground)才能生效";
|
|
22
23
|
};
|
|
23
24
|
export default _default;
|
package/dist/messages/zh_CN.js
CHANGED
|
@@ -21,4 +21,5 @@ exports.default = {
|
|
|
21
21
|
'mp.component.args[1]': '{0}需要两个参数',
|
|
22
22
|
'mp.360.unsupported': 'vue3暂不支持360小程序',
|
|
23
23
|
'file.notfound': '{file} 文件不存在',
|
|
24
|
+
'uts.ios.tips': '项目使用了uts插件,iOS平台uts插件代码修改后需要重新生成[自定义基座](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground)才能生效',
|
|
24
25
|
};
|
package/dist/uni_modules.d.ts
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
declare type Define = string | string[] | Record<string, string
|
|
1
|
+
declare type Define = string | string[] | Record<string, string> | false;
|
|
2
2
|
declare type Defines = {
|
|
3
3
|
[name: string]: Define;
|
|
4
4
|
};
|
|
5
5
|
interface Exports {
|
|
6
6
|
[name: string]: Define | Defines | false;
|
|
7
7
|
}
|
|
8
|
-
export declare function
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export declare function parseUniExtApis(): Injects;
|
|
9
|
+
declare type Injects = {
|
|
10
|
+
[name: string]: string | string[] | false;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* uni:'getBatteryInfo'
|
|
14
|
+
* import getBatteryInfo from '..'
|
|
15
|
+
*
|
|
16
|
+
* uni:['getBatteryInfo']
|
|
17
|
+
* import { getBatteryInfo } from '..'
|
|
18
|
+
*
|
|
19
|
+
* uni:['openLocation','chooseLocation']
|
|
20
|
+
* import { openLocation, chooseLocation } from '..'
|
|
21
|
+
*
|
|
22
|
+
* uni:{
|
|
23
|
+
* onUserCaptureScreen: "onCaptureScreen"
|
|
24
|
+
* offUserCaptureScreen: "offCaptureScreen"
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* uni.getBatteryInfo = getBatteryInfo
|
|
28
|
+
* @param source
|
|
29
|
+
* @param globalObject
|
|
30
|
+
* @param define
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseInjects(platform: UniApp.PLATFORM, source: string, exports?: Exports): Injects;
|
|
34
|
+
export declare function parseInject(source: string, globalObject: string, define: Define): Injects;
|
|
11
35
|
export {};
|
package/dist/uni_modules.js
CHANGED
|
@@ -3,63 +3,34 @@ 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.parseInject = exports.parseInjects = exports.parseUniExtApis = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const merge_1 = require("merge");
|
|
10
|
-
function
|
|
10
|
+
function parseUniExtApis() {
|
|
11
11
|
const uniModulesDir = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'uni_modules');
|
|
12
12
|
if (!fs_extra_1.default.existsSync(uniModulesDir)) {
|
|
13
|
-
return
|
|
13
|
+
return {};
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
const assignCodes = [];
|
|
15
|
+
const injects = {};
|
|
17
16
|
fs_extra_1.default.readdirSync(uniModulesDir).forEach((uniModuleDir) => {
|
|
18
17
|
var _a, _b;
|
|
18
|
+
// 必须以 uni- 开头
|
|
19
|
+
if (!uniModuleDir.startsWith('uni-')) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
19
22
|
const pkgPath = path_1.default.resolve(uniModulesDir, uniModuleDir, 'package.json');
|
|
20
23
|
if (!fs_extra_1.default.existsSync(pkgPath)) {
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
|
-
const exports = (_b = (_a = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))) === null || _a === void 0 ? void 0 : _a.uni_modules) === null || _b === void 0 ? void 0 : _b
|
|
26
|
+
const exports = (_b = (_a = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))) === null || _a === void 0 ? void 0 : _a.uni_modules) === null || _b === void 0 ? void 0 : _b['uni-ext-api'];
|
|
24
27
|
if (exports) {
|
|
25
|
-
|
|
26
|
-
importCodes.push(...exportsImportCodes);
|
|
27
|
-
assignCodes.push(...exportsAssignCodes);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
if (!importCodes.length) {
|
|
31
|
-
return '';
|
|
32
|
-
}
|
|
33
|
-
return `${importCodes.join('\n')}
|
|
34
|
-
${assignCodes.join('\n')}`;
|
|
35
|
-
}
|
|
36
|
-
exports.genUniModulesExports = genUniModulesExports;
|
|
37
|
-
function parseExports(platform, source, exports = {}) {
|
|
38
|
-
const rootDefines = {};
|
|
39
|
-
Object.keys(exports).forEach((name) => {
|
|
40
|
-
if (name.startsWith('uni')) {
|
|
41
|
-
rootDefines[name] = exports[name];
|
|
28
|
+
Object.assign(injects, parseInjects(process.env.UNI_PLATFORM === 'h5' ? 'web' : process.env.UNI_PLATFORM, `@/uni_modules/${uniModuleDir}`, exports));
|
|
42
29
|
}
|
|
43
30
|
});
|
|
44
|
-
|
|
45
|
-
// 该平台不支持
|
|
46
|
-
if (platformDefines === false) {
|
|
47
|
-
return [[], []];
|
|
48
|
-
}
|
|
49
|
-
return parseDefines(source, (0, merge_1.recursive)(true, rootDefines, platformDefines));
|
|
50
|
-
}
|
|
51
|
-
exports.parseExports = parseExports;
|
|
52
|
-
function parseDefines(source, defines = {}) {
|
|
53
|
-
const importCodes = [];
|
|
54
|
-
const assignCodes = [];
|
|
55
|
-
Object.keys(defines).forEach((name) => {
|
|
56
|
-
const [defineImportCodes, defineAssignCodes] = parseDefine(source, name, defines[name]);
|
|
57
|
-
importCodes.push(...defineImportCodes);
|
|
58
|
-
assignCodes.push(...defineAssignCodes);
|
|
59
|
-
});
|
|
60
|
-
return [importCodes, assignCodes];
|
|
31
|
+
return injects;
|
|
61
32
|
}
|
|
62
|
-
exports.
|
|
33
|
+
exports.parseUniExtApis = parseUniExtApis;
|
|
63
34
|
/**
|
|
64
35
|
* uni:'getBatteryInfo'
|
|
65
36
|
* import getBatteryInfo from '..'
|
|
@@ -81,32 +52,48 @@ exports.parseDefines = parseDefines;
|
|
|
81
52
|
* @param define
|
|
82
53
|
* @returns
|
|
83
54
|
*/
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
55
|
+
function parseInjects(platform, source, exports = {}) {
|
|
56
|
+
let rootDefines = {};
|
|
57
|
+
Object.keys(exports).forEach((name) => {
|
|
58
|
+
if (name.startsWith('uni')) {
|
|
59
|
+
rootDefines[name] = exports[name];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const platformDefines = exports[platform];
|
|
63
|
+
// 该平台不支持
|
|
64
|
+
if (platformDefines === false) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
if (platformDefines) {
|
|
68
|
+
rootDefines = (0, merge_1.recursive)(true, rootDefines, platformDefines);
|
|
69
|
+
}
|
|
70
|
+
const injects = {};
|
|
71
|
+
for (const key in rootDefines) {
|
|
72
|
+
Object.assign(injects, parseInject(source, 'uni', rootDefines[key]));
|
|
73
|
+
}
|
|
74
|
+
return injects;
|
|
75
|
+
}
|
|
76
|
+
exports.parseInjects = parseInjects;
|
|
77
|
+
function parseInject(source, globalObject, define) {
|
|
78
|
+
const injects = {};
|
|
79
|
+
if (define === false) {
|
|
80
|
+
}
|
|
81
|
+
else if (typeof define === 'string') {
|
|
82
|
+
// {'uni.getBatteryInfo' : '@dcloudio/uni-getbatteryinfo'}
|
|
83
|
+
injects[globalObject + '.' + define] = source;
|
|
90
84
|
}
|
|
91
85
|
else if (Array.isArray(define)) {
|
|
92
|
-
|
|
86
|
+
// {'uni.getBatteryInfo' : ['@dcloudio/uni-getbatteryinfo','getBatteryInfo]}
|
|
93
87
|
define.forEach((d) => {
|
|
94
|
-
|
|
88
|
+
injects[globalObject + '.' + d] = [source, d];
|
|
95
89
|
});
|
|
96
90
|
}
|
|
97
91
|
else {
|
|
98
92
|
const keys = Object.keys(define);
|
|
99
|
-
const specifiers = [];
|
|
100
93
|
keys.forEach((d) => {
|
|
101
|
-
|
|
102
|
-
specifiers.push(`${define[d]} as ${d}`);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
specifiers.push(d);
|
|
106
|
-
}
|
|
107
|
-
assignCodes.push(`${globalObject}.${d} = ${d}`);
|
|
94
|
+
injects[globalObject + '.' + d] = [source, define[d]];
|
|
108
95
|
});
|
|
109
|
-
importCodes.push(`import { ${specifiers.join(', ')} } from '${source}'`);
|
|
110
96
|
}
|
|
111
|
-
return
|
|
97
|
+
return injects;
|
|
112
98
|
}
|
|
99
|
+
exports.parseInject = parseInject;
|
|
@@ -5,7 +5,6 @@ export * from './mainJs';
|
|
|
5
5
|
export * from './jsonJs';
|
|
6
6
|
export * from './console';
|
|
7
7
|
export * from './dynamicImportPolyfill';
|
|
8
|
-
export { uniModulesExportsPlugin } from './uniModules';
|
|
9
8
|
export { assetPlugin, getAssetHash } from './vitejs/plugins/asset';
|
|
10
9
|
export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, } from './vitejs/plugins/css';
|
|
11
10
|
export { generateCodeFrame } from './vitejs/utils';
|
|
@@ -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.generateCodeFrame = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.assetPlugin =
|
|
17
|
+
exports.generateCodeFrame = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.assetPlugin = void 0;
|
|
18
18
|
__exportStar(require("./cssScoped"), exports);
|
|
19
19
|
__exportStar(require("./copy"), exports);
|
|
20
20
|
__exportStar(require("./inject"), exports);
|
|
@@ -22,8 +22,6 @@ __exportStar(require("./mainJs"), exports);
|
|
|
22
22
|
__exportStar(require("./jsonJs"), exports);
|
|
23
23
|
__exportStar(require("./console"), exports);
|
|
24
24
|
__exportStar(require("./dynamicImportPolyfill"), exports);
|
|
25
|
-
var uniModules_1 = require("./uniModules");
|
|
26
|
-
Object.defineProperty(exports, "uniModulesExportsPlugin", { enumerable: true, get: function () { return uniModules_1.uniModulesExportsPlugin; } });
|
|
27
25
|
var asset_1 = require("./vitejs/plugins/asset");
|
|
28
26
|
Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
|
|
29
27
|
Object.defineProperty(exports, "getAssetHash", { enumerable: true, get: function () { return asset_1.getAssetHash; } });
|
|
@@ -11,7 +11,6 @@ const estree_walker_1 = require("estree-walker");
|
|
|
11
11
|
const shared_1 = require("@vue/shared");
|
|
12
12
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
|
-
const constants_1 = require("../../constants");
|
|
15
14
|
const debugInject = (0, debug_1.default)('uni:inject');
|
|
16
15
|
const debugInjectTry = (0, debug_1.default)('uni:inject-try');
|
|
17
16
|
function uniViteInjectPlugin(name, options) {
|
|
@@ -46,13 +45,10 @@ function uniViteInjectPlugin(name, options) {
|
|
|
46
45
|
// 确保在 commonjs 之后,否则会混合 es6 module 与 cjs 的代码,导致 commonjs 失效
|
|
47
46
|
enforce: 'post',
|
|
48
47
|
transform(code, id) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!(0, utils_1.isJsFile)(id))
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
48
|
+
if (!filter(id))
|
|
49
|
+
return null;
|
|
50
|
+
if (!(0, utils_1.isJsFile)(id))
|
|
51
|
+
return null;
|
|
56
52
|
debugInjectTry(id);
|
|
57
53
|
if (code.search(firstpass) === -1)
|
|
58
54
|
return null;
|
package/dist/vite/utils/url.d.ts
CHANGED
package/dist/vite/utils/url.js
CHANGED
|
@@ -54,15 +54,11 @@ exports.hashRE = /#.*$/;
|
|
|
54
54
|
const cleanUrl = (url) => url.replace(exports.hashRE, '').replace(exports.queryRE, '');
|
|
55
55
|
exports.cleanUrl = cleanUrl;
|
|
56
56
|
function isJsFile(id) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
const isJs = constants_1.EXTNAME_JS_RE.test(id);
|
|
57
|
+
const { filename, query } = parseVueRequest(id);
|
|
58
|
+
const isJs = constants_1.EXTNAME_JS_RE.test(filename);
|
|
62
59
|
if (isJs) {
|
|
63
60
|
return true;
|
|
64
61
|
}
|
|
65
|
-
const { filename, query } = parseVueRequest(id);
|
|
66
62
|
const isVueJs = constants_1.EXTNAME_VUE.includes(path_1.default.extname(filename)) && !query.vue;
|
|
67
63
|
if (isVueJs) {
|
|
68
64
|
return true;
|
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-3060720221017001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"@babel/core": "^7.18.13",
|
|
26
26
|
"@babel/parser": "^7.18.13",
|
|
27
27
|
"@babel/types": "^7.17.0",
|
|
28
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
29
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
28
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3060720221017001",
|
|
29
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3060720221017001",
|
|
30
30
|
"@intlify/core-base": "9.1.9",
|
|
31
31
|
"@intlify/shared": "9.1.9",
|
|
32
32
|
"@intlify/vue-devtools": "9.1.9",
|
|
33
33
|
"@rollup/pluginutils": "^4.2.0",
|
|
34
|
-
"@vue/compiler-core": "3.2.
|
|
35
|
-
"@vue/compiler-dom": "3.2.
|
|
36
|
-
"@vue/compiler-sfc": "3.2.
|
|
37
|
-
"@vue/server-renderer": "3.2.
|
|
38
|
-
"@vue/shared": "3.2.
|
|
34
|
+
"@vue/compiler-core": "3.2.41",
|
|
35
|
+
"@vue/compiler-dom": "3.2.41",
|
|
36
|
+
"@vue/compiler-sfc": "3.2.41",
|
|
37
|
+
"@vue/server-renderer": "3.2.41",
|
|
38
|
+
"@vue/shared": "3.2.41",
|
|
39
39
|
"autoprefixer": "^10.4.12",
|
|
40
40
|
"base64url": "^3.0.1",
|
|
41
41
|
"chokidar": "^3.5.3",
|
|
@@ -76,6 +76,6 @@
|
|
|
76
76
|
"@types/sass": "^1.43.1",
|
|
77
77
|
"@types/stylus": "^0.48.36",
|
|
78
78
|
"postcss": "^8.4.16",
|
|
79
|
-
"vue": "3.2.
|
|
79
|
+
"vue": "3.2.41"
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uniModulesExportsPlugin = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const uni_modules_1 = require("../../uni_modules");
|
|
6
|
-
function uniModulesExportsPlugin({ enable, }) {
|
|
7
|
-
return {
|
|
8
|
-
name: 'uni:modules:exports',
|
|
9
|
-
resolveId(id) {
|
|
10
|
-
if (id === constants_1.UNI_MODULES_EXPORTS) {
|
|
11
|
-
return constants_1.UNI_MODULES_EXPORTS;
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
load(id) {
|
|
15
|
-
if (id !== constants_1.UNI_MODULES_EXPORTS) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
// 未启用
|
|
19
|
-
if (!enable) {
|
|
20
|
-
return '';
|
|
21
|
-
}
|
|
22
|
-
return (0, uni_modules_1.genUniModulesExports)();
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.uniModulesExportsPlugin = uniModulesExportsPlugin;
|
package/lib/.DS_Store
DELETED
|
Binary file
|
package/lib/vue-i18n/.DS_Store
DELETED
|
Binary file
|