@dcloudio/uni-cli-shared 3.0.0-4060520250512001 → 3.0.0-4070520250711001
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/alias.d.ts +1 -0
- package/dist/alias.js +4 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +5 -1
- package/dist/hbx/alias.js +6 -3
- package/dist/hbx/env.d.ts +1 -1
- package/dist/hbx/env.js +5 -20
- package/dist/hbx/log.js +1 -1
- package/dist/hbx/utils.d.ts +1 -0
- package/dist/hbx/utils.js +26 -0
- package/dist/json/app/pages/definePage.js +1 -1
- package/dist/json/index.d.ts +2 -1
- package/dist/json/index.js +5 -3
- package/dist/json/manifest.d.ts +6 -0
- package/dist/json/manifest.js +21 -1
- package/dist/json/mp/pages.js +2 -2
- package/dist/json/mp/project.js +1 -0
- package/dist/json/pages.d.ts +1 -0
- package/dist/json/pages.js +5 -5
- package/dist/json/uni-x/index.d.ts +2 -1
- package/dist/json/uni-x/index.js +23 -120
- package/dist/json/uni-x/manifest.d.ts +1 -2
- package/dist/json/uni-x/manifest.js +3 -11
- package/dist/json/utils.d.ts +1 -0
- package/dist/json/utils.js +128 -0
- 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/platform.d.ts +1 -1
- package/dist/polyfill.d.ts +1 -0
- package/dist/polyfill.js +9 -0
- package/dist/uni_modules.cloud.d.ts +12 -1
- package/dist/uni_modules.cloud.js +62 -16
- package/dist/uni_modules.js +2 -1
- package/dist/uts.d.ts +3 -0
- package/dist/uts.js +28 -9
- package/dist/vite/autoImport.js +54 -3
- package/dist/vite/cloud.js +1 -0
- package/dist/vite/extApi.js +1 -1
- package/dist/vite/plugins/console.js +11 -0
- package/dist/vite/plugins/easycom.js +0 -15
- package/dist/vite/plugins/uts/uni_modules.js +4 -7
- package/dist/vite/utils/ast.d.ts +2 -1
- package/dist/vite/utils/ast.js +5 -1
- package/dist/vite/utils/utils.d.ts +1 -1
- package/dist/vue/transforms/transformUTSComponent.d.ts +0 -1
- package/dist/vue/transforms/transformUTSComponent.js +1 -2
- package/dist/vue/utils.d.ts +1 -1
- package/lib/@vue/compiler-core/CHANGED.md +1 -0
- package/lib/@vue/compiler-core/LICENSE +21 -0
- package/lib/@vue/compiler-core/README.md +1 -0
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.js +6635 -0
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6511 -0
- package/lib/@vue/compiler-core/dist/compiler-core.d.ts +1034 -0
- package/lib/@vue/compiler-core/dist/compiler-core.esm-bundler.js +5684 -0
- package/lib/@vue/compiler-core/index.js +7 -0
- package/lib/@vue/compiler-core/package.json +58 -0
- package/lib/preprocessor/index.js +61 -0
- package/lib/preprocessor/preprocessor-macos-arm64.node +0 -0
- package/lib/preprocessor/preprocessor-macos-x86_64.node +0 -0
- package/lib/preprocessor/preprocessor-windows-x86_64.node +0 -0
- package/package.json +5 -4
package/dist/alias.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/alias.js
ADDED
package/dist/constants.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export declare const EXTNAME_VUE_TEMPLATE: string[];
|
|
|
7
7
|
export declare const EXTNAME_VUE_RE: RegExp;
|
|
8
8
|
export declare const EXTNAME_JS_RE: RegExp;
|
|
9
9
|
export declare const EXTNAME_TS_RE: RegExp;
|
|
10
|
+
export declare const SPECIAL_CHARS: {
|
|
11
|
+
WARN_BLOCK: string;
|
|
12
|
+
ERROR_BLOCK: string;
|
|
13
|
+
};
|
|
10
14
|
export declare const extensions: string[];
|
|
11
15
|
export declare const uni_app_x_extensions: string[];
|
|
12
16
|
export declare const PAGES_JSON_JS = "pages-json-js";
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.X_BASE_COMPONENTS_STYLE_PATH = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.X_PAGE_EXTNAME_APP = exports.X_PAGE_EXTNAME = 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_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.X_EXTNAME_VUE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
|
3
|
+
exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.X_BASE_COMPONENTS_STYLE_PATH = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.X_PAGE_EXTNAME_APP = exports.X_PAGE_EXTNAME = 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_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.SPECIAL_CHARS = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.X_EXTNAME_VUE = 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', '.uts'];
|
|
6
6
|
exports.EXTNAME_TS = ['.ts', '.tsx'];
|
|
@@ -10,6 +10,10 @@ exports.EXTNAME_VUE_TEMPLATE = ['.vue', '.nvue', '.uvue', '.jsx', '.tsx'];
|
|
|
10
10
|
exports.EXTNAME_VUE_RE = /\.(vue|nvue|uvue)$/;
|
|
11
11
|
exports.EXTNAME_JS_RE = /\.(js|jsx|ts|uts|tsx|mjs)$/;
|
|
12
12
|
exports.EXTNAME_TS_RE = /\.tsx?$/;
|
|
13
|
+
exports.SPECIAL_CHARS = {
|
|
14
|
+
WARN_BLOCK: '\uFEFF', // 警告块前后标识
|
|
15
|
+
ERROR_BLOCK: '\u2060', // 错误块前后标识
|
|
16
|
+
};
|
|
13
17
|
const COMMON_EXTENSIONS = [
|
|
14
18
|
'.uts',
|
|
15
19
|
'.mjs',
|
package/dist/hbx/alias.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// 注意:该文件尽可能少依赖其他文件,否则可能会导致还没有alias的时候,就加载了目标模块
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
5
|
};
|
|
@@ -6,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
7
|
exports.formatInstallHBuilderXPluginTips = exports.moduleAliasFormatter = exports.installHBuilderXPlugin = exports.initModuleAlias = void 0;
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const module_alias_1 = __importDefault(require("module-alias"));
|
|
9
|
-
const
|
|
10
|
+
const utils_1 = require("./utils");
|
|
10
11
|
const hbxPlugins = {
|
|
11
12
|
typescript: 'compile-typescript/node_modules/typescript',
|
|
12
13
|
less: 'compile-less/node_modules/less',
|
|
@@ -15,11 +16,13 @@ const hbxPlugins = {
|
|
|
15
16
|
pug: 'compile-pug-cli/node_modules/pug',
|
|
16
17
|
};
|
|
17
18
|
function initModuleAlias() {
|
|
18
|
-
const
|
|
19
|
+
const libDir = path_1.default.resolve(__dirname, '../../lib');
|
|
20
|
+
const compilerSfcPath = path_1.default.resolve(libDir, '@vue/compiler-sfc');
|
|
19
21
|
const serverRendererPath = require.resolve('@vue/server-renderer');
|
|
20
22
|
module_alias_1.default.addAliases({
|
|
21
23
|
'@vue/shared': require.resolve('@vue/shared'),
|
|
22
24
|
'@vue/shared/dist/shared.esm-bundler.js': require.resolve('@vue/shared/dist/shared.esm-bundler.js'),
|
|
25
|
+
'@vue/compiler-core': path_1.default.resolve(libDir, '@vue/compiler-core'),
|
|
23
26
|
'@vue/compiler-dom': require.resolve('@vue/compiler-dom'),
|
|
24
27
|
'@vue/compiler-sfc': compilerSfcPath,
|
|
25
28
|
'@vue/server-renderer': serverRendererPath,
|
|
@@ -32,7 +35,7 @@ function initModuleAlias() {
|
|
|
32
35
|
'vue/package.json': '@dcloudio/uni-h5-vue/package.json',
|
|
33
36
|
});
|
|
34
37
|
}
|
|
35
|
-
if ((0,
|
|
38
|
+
if ((0, utils_1.isInHBuilderX)()) {
|
|
36
39
|
// 又是为了复用 HBuilderX 的插件逻辑,硬编码映射
|
|
37
40
|
Object.keys(hbxPlugins).forEach((lang) => {
|
|
38
41
|
const realPath = path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[lang]);
|
package/dist/hbx/env.d.ts
CHANGED
package/dist/hbx/env.js
CHANGED
|
@@ -9,24 +9,9 @@ const module_1 = __importDefault(require("module"));
|
|
|
9
9
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
10
10
|
const resolve_1 = require("../resolve");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
process.env.UNI_HBUILDERX_PLUGINS = process.env.HX_APP_ROOT + '/plugins';
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
const { name } = require(path_1.default.resolve(process.cwd(), '../about/package.json'));
|
|
20
|
-
if (name === 'about') {
|
|
21
|
-
process.env.UNI_HBUILDERX_PLUGINS = path_1.default.resolve(process.cwd(), '..');
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
// console.error(e)
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
});
|
|
12
|
+
const utils_2 = require("./utils");
|
|
13
|
+
var utils_3 = require("./utils");
|
|
14
|
+
Object.defineProperty(exports, "isInHBuilderX", { enumerable: true, get: function () { return utils_3.isInHBuilderX; } });
|
|
30
15
|
exports.runByHBuilderX = (0, uni_shared_1.once)(() => {
|
|
31
16
|
return (!!process.env.UNI_HBUILDERX_PLUGINS &&
|
|
32
17
|
(!!process.env.RUN_BY_HBUILDERX || !!process.env.HX_Version));
|
|
@@ -35,7 +20,7 @@ exports.runByHBuilderX = (0, uni_shared_1.once)(() => {
|
|
|
35
20
|
* 增加 node_modules
|
|
36
21
|
*/
|
|
37
22
|
function initModulePaths() {
|
|
38
|
-
if (!(0,
|
|
23
|
+
if (!(0, utils_2.isInHBuilderX)()) {
|
|
39
24
|
return;
|
|
40
25
|
}
|
|
41
26
|
const Module = module.constructor.length > 1 ? module.constructor : module_1.default;
|
|
@@ -61,7 +46,7 @@ function resolveEsbuildModule(name) {
|
|
|
61
46
|
}
|
|
62
47
|
function fixBinaryPath() {
|
|
63
48
|
// cli 工程在 HBuilderX 中运行
|
|
64
|
-
if (!(0,
|
|
49
|
+
if (!(0, utils_2.isInHBuilderX)() && (0, exports.runByHBuilderX)()) {
|
|
65
50
|
if (utils_1.isWindows) {
|
|
66
51
|
const win64 = resolveEsbuildModule('esbuild-windows-64');
|
|
67
52
|
if (win64) {
|
package/dist/hbx/log.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isInHBuilderX: () => boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isInHBuilderX = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
9
|
+
exports.isInHBuilderX = (0, uni_shared_1.once)(() => {
|
|
10
|
+
// 自动化测试传入了 HX_APP_ROOT(其实就是UNI_HBUILDERX_PLUGINS)
|
|
11
|
+
if (process.env.HX_APP_ROOT) {
|
|
12
|
+
process.env.UNI_HBUILDERX_PLUGINS = process.env.HX_APP_ROOT + '/plugins';
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const { name } = require(path_1.default.resolve(process.cwd(), '../about/package.json'));
|
|
17
|
+
if (name === 'about') {
|
|
18
|
+
process.env.UNI_HBUILDERX_PLUGINS = path_1.default.resolve(process.cwd(), '..');
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
// console.error(e)
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
});
|
|
@@ -34,7 +34,7 @@ function defineNVuePageCode(pagesJson) {
|
|
|
34
34
|
}
|
|
35
35
|
const pagePathWithExtname = (0, utils_1.normalizePagePath)(page.path, 'app');
|
|
36
36
|
if (pagePathWithExtname) {
|
|
37
|
-
importNVuePagesCode.push(`import('./${pagePathWithExtname}').then((res)=>{res
|
|
37
|
+
importNVuePagesCode.push(`import('./${pagePathWithExtname}').then((res)=>{res()})`);
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
return importNVuePagesCode.join('\n');
|
package/dist/json/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export * from './json';
|
|
|
4
4
|
export * from './pages';
|
|
5
5
|
export * from './manifest';
|
|
6
6
|
export * from './theme';
|
|
7
|
-
export { normalizeUniAppXAppPagesJson, normalizeUniAppXAppConfig,
|
|
7
|
+
export { normalizeUniAppXAppPagesJson, normalizeUniAppXAppConfig, parseUniXFlexDirection, parseUniXSplashScreen, isUniXPageFile, getUniXPagePaths, } from './uni-x';
|
|
8
|
+
export { checkPagesJson } from './utils';
|
package/dist/json/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.
|
|
17
|
+
exports.checkPagesJson = exports.getUniXPagePaths = exports.isUniXPageFile = exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
|
|
18
18
|
__exportStar(require("./mp"), exports);
|
|
19
19
|
__exportStar(require("./app"), exports);
|
|
20
20
|
__exportStar(require("./json"), exports);
|
|
@@ -24,7 +24,9 @@ __exportStar(require("./theme"), exports);
|
|
|
24
24
|
var uni_x_1 = require("./uni-x");
|
|
25
25
|
Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppPagesJson; } });
|
|
26
26
|
Object.defineProperty(exports, "normalizeUniAppXAppConfig", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppConfig; } });
|
|
27
|
-
Object.defineProperty(exports, "checkPagesJson", { enumerable: true, get: function () { return uni_x_1.checkPagesJson; } });
|
|
28
27
|
Object.defineProperty(exports, "parseUniXFlexDirection", { enumerable: true, get: function () { return uni_x_1.parseUniXFlexDirection; } });
|
|
29
28
|
Object.defineProperty(exports, "parseUniXSplashScreen", { enumerable: true, get: function () { return uni_x_1.parseUniXSplashScreen; } });
|
|
30
|
-
Object.defineProperty(exports, "
|
|
29
|
+
Object.defineProperty(exports, "isUniXPageFile", { enumerable: true, get: function () { return uni_x_1.isUniXPageFile; } });
|
|
30
|
+
Object.defineProperty(exports, "getUniXPagePaths", { enumerable: true, get: function () { return uni_x_1.getUniXPagePaths; } });
|
|
31
|
+
var utils_1 = require("./utils");
|
|
32
|
+
Object.defineProperty(exports, "checkPagesJson", { enumerable: true, get: function () { return utils_1.checkPagesJson; } });
|
package/dist/json/manifest.d.ts
CHANGED
|
@@ -30,6 +30,12 @@ export declare function getRouterOptions(manifestJson: Record<string, any>): {
|
|
|
30
30
|
};
|
|
31
31
|
export declare function isEnableTreeShaking(manifestJson: Record<string, any>): boolean;
|
|
32
32
|
export declare function getDevServerOptions(manifestJson: Record<string, any>): any;
|
|
33
|
+
/**
|
|
34
|
+
* 非 uni-app-x 支持 app、app-plus、app-harmony
|
|
35
|
+
* uni-app-x 支持 app、app-android、app-ios、app-harmony
|
|
36
|
+
* UNI_PLATFORM仅包含app不细分平台
|
|
37
|
+
* UNI_UTS_PLATFORM细分了app-android、app-ios、app-harmony
|
|
38
|
+
*/
|
|
33
39
|
export declare function getPlatformManifestJson(manifestJson: any, platform?: UniApp.PLATFORM): any;
|
|
34
40
|
export declare function getPlatformManifestJsonOnce(): any;
|
|
35
41
|
export declare function validateThemeValue(value: string): boolean;
|
package/dist/json/manifest.js
CHANGED
|
@@ -83,7 +83,12 @@ function isEnableSecureNetwork(inputDir, platform) {
|
|
|
83
83
|
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
|
84
84
|
const platformManifest = getPlatformManifestJson(manifest, platform);
|
|
85
85
|
if (platform === 'app') {
|
|
86
|
-
|
|
86
|
+
if (process.env.UNI_APP_X === 'true') {
|
|
87
|
+
return !!platformManifest?.distribute?.modules?.['uni-secure-network'];
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return !!platformManifest?.modules?.SecureNetwork;
|
|
91
|
+
}
|
|
87
92
|
}
|
|
88
93
|
return platformManifest?.secureNetwork?.enable === true;
|
|
89
94
|
}
|
|
@@ -117,10 +122,25 @@ function getDevServerOptions(manifestJson) {
|
|
|
117
122
|
return (0, shared_1.extend)({}, platformManifest?.devServer);
|
|
118
123
|
}
|
|
119
124
|
exports.getDevServerOptions = getDevServerOptions;
|
|
125
|
+
/**
|
|
126
|
+
* 非 uni-app-x 支持 app、app-plus、app-harmony
|
|
127
|
+
* uni-app-x 支持 app、app-android、app-ios、app-harmony
|
|
128
|
+
* UNI_PLATFORM仅包含app不细分平台
|
|
129
|
+
* UNI_UTS_PLATFORM细分了app-android、app-ios、app-harmony
|
|
130
|
+
*/
|
|
120
131
|
function getPlatformManifestJson(manifestJson, platform) {
|
|
132
|
+
const isX = process.env.UNI_APP_X === 'true';
|
|
121
133
|
if (!platform) {
|
|
122
134
|
platform = process.env.UNI_PLATFORM;
|
|
123
135
|
}
|
|
136
|
+
if (isX) {
|
|
137
|
+
if (platform === 'app-android' || platform === 'app-ios') {
|
|
138
|
+
return manifestJson[platform] || manifestJson['app'] || {};
|
|
139
|
+
}
|
|
140
|
+
else if (platform === 'app') {
|
|
141
|
+
return (manifestJson[process.env.UNI_UTS_PLATFORM] || manifestJson['app'] || {});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
124
144
|
if (platform === 'app') {
|
|
125
145
|
return manifestJson['app-plus'] || manifestJson['plus'] || {};
|
|
126
146
|
}
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -14,11 +14,11 @@ const utils_2 = require("../../utils");
|
|
|
14
14
|
const project_1 = require("./project");
|
|
15
15
|
const manifest_1 = require("../manifest");
|
|
16
16
|
const theme_1 = require("../theme");
|
|
17
|
-
const
|
|
17
|
+
const utils_3 = require("../utils");
|
|
18
18
|
function parseMiniProgramPagesJson(jsonStr, platform, options = { subpackages: false }) {
|
|
19
19
|
if (process.env.UNI_APP_X === 'true') {
|
|
20
20
|
// 目前仅对x开放
|
|
21
|
-
(0,
|
|
21
|
+
(0, utils_3.checkPagesJson)(jsonStr, process.env.UNI_INPUT_DIR);
|
|
22
22
|
}
|
|
23
23
|
return parsePagesJson(jsonStr, platform, options);
|
|
24
24
|
}
|
package/dist/json/mp/project.js
CHANGED
package/dist/json/pages.d.ts
CHANGED
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.filterPlatformPages = exports.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageSetupAndUts = exports.isUniPageFile = void 0;
|
|
6
|
+
exports.filterPlatformPages = exports.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageSetupAndUts = exports.isUniPageFile = exports.pagesCacheSet = 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");
|
|
@@ -15,12 +15,12 @@ const vite_1 = require("../vite");
|
|
|
15
15
|
const constants_1 = require("../constants");
|
|
16
16
|
const theme_1 = require("./theme");
|
|
17
17
|
const manifest_1 = require("./manifest");
|
|
18
|
-
|
|
18
|
+
exports.pagesCacheSet = new Set();
|
|
19
19
|
function isUniPageFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
|
20
20
|
if (inputDir && path_1.default.isAbsolute(file)) {
|
|
21
21
|
file = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file));
|
|
22
22
|
}
|
|
23
|
-
return pagesCacheSet.has((0, utils_1.removeExt)(file));
|
|
23
|
+
return exports.pagesCacheSet.has((0, utils_1.removeExt)(file));
|
|
24
24
|
}
|
|
25
25
|
exports.isUniPageFile = isUniPageFile;
|
|
26
26
|
function isUniPageSetupAndUts(file) {
|
|
@@ -128,8 +128,8 @@ function normalizePagesJson(jsonStr, platform, { subpackages, } = { subpackages:
|
|
|
128
128
|
// 过滤平台page
|
|
129
129
|
filterPlatformPages(platform, pagesJson);
|
|
130
130
|
// 缓存页面列表
|
|
131
|
-
pagesCacheSet.clear();
|
|
132
|
-
pagesJson.pages.forEach((page) => pagesCacheSet.add(page.path));
|
|
131
|
+
exports.pagesCacheSet.clear();
|
|
132
|
+
pagesJson.pages.forEach((page) => exports.pagesCacheSet.add(page.path));
|
|
133
133
|
const manifestJsonPlatform = (0, manifest_1.getPlatformManifestJsonOnce)();
|
|
134
134
|
if (!manifestJsonPlatform.darkmode) {
|
|
135
135
|
const { pages, globalStyle, tabBar } = (0, theme_1.initTheme)(manifestJsonPlatform, pagesJson);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from './manifest';
|
|
2
|
-
export declare function checkPagesJson(jsonStr: string, inputDir: string): boolean;
|
|
3
2
|
export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.PagesJson;
|
|
4
3
|
/**
|
|
5
4
|
* TODO 应该闭包,通过globalThis赋值?
|
|
@@ -8,3 +7,5 @@ export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.Pa
|
|
|
8
7
|
* @returns
|
|
9
8
|
*/
|
|
10
9
|
export declare function normalizeUniAppXAppConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
10
|
+
export declare function isUniXPageFile(source: string, importer: string, inputDir?: string): boolean;
|
|
11
|
+
export declare function getUniXPagePaths(): any;
|
package/dist/json/uni-x/index.js
CHANGED
|
@@ -17,138 +17,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
21
|
-
const fs_1 = __importDefault(require("fs"));
|
|
20
|
+
exports.getUniXPagePaths = exports.isUniXPageFile = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
|
|
22
21
|
const path_1 = __importDefault(require("path"));
|
|
23
22
|
const shared_1 = require("@vue/shared");
|
|
24
|
-
const jsonc_parser_1 = require("jsonc-parser");
|
|
25
23
|
const json_1 = require("../json");
|
|
26
24
|
const pages_1 = require("../pages");
|
|
27
25
|
const utils_1 = require("../../utils");
|
|
28
26
|
const uniRoutes_1 = require("../app/pages/uniRoutes");
|
|
29
27
|
const uniConfig_1 = require("./uniConfig");
|
|
30
|
-
const utils_2 = require("../../vite/plugins/vitejs/utils");
|
|
31
28
|
const preprocess_1 = require("../../preprocess");
|
|
29
|
+
const utils_2 = require("../utils");
|
|
32
30
|
__exportStar(require("./manifest"), exports);
|
|
33
|
-
function checkPagesJson(jsonStr, inputDir) {
|
|
34
|
-
if (!inputDir) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
const errors = [];
|
|
38
|
-
const root = (0, jsonc_parser_1.parseTree)(jsonStr, errors);
|
|
39
|
-
if (!root) {
|
|
40
|
-
if (errors.length) {
|
|
41
|
-
for (const error of errors) {
|
|
42
|
-
const { line, column } = (0, utils_2.offsetToLineColumn)(jsonStr, error.offset);
|
|
43
|
-
throw {
|
|
44
|
-
name: 'SyntaxError',
|
|
45
|
-
code: error.error,
|
|
46
|
-
message: (0, jsonc_parser_1.printParseErrorCode)(error.error),
|
|
47
|
-
loc: {
|
|
48
|
-
start: { line, column },
|
|
49
|
-
},
|
|
50
|
-
offsetStart: error.offset,
|
|
51
|
-
offsetEnd: error.offset + error.length,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
const pagePathNodes = walkNodes(findRootNode(root, ['pages']));
|
|
58
|
-
findRootNode(root, ['subPackages', 'subpackages']).forEach((node) => {
|
|
59
|
-
const subPackageRoot = findSubPackageRoot(node);
|
|
60
|
-
if (subPackageRoot) {
|
|
61
|
-
findRootNode(node, ['pages']).forEach((subNode) => {
|
|
62
|
-
walkNodes(subNode.children ?? []).forEach((node) => {
|
|
63
|
-
pagePathNodes.push({
|
|
64
|
-
...node,
|
|
65
|
-
value: (0, utils_1.normalizePath)(path_1.default.join(subPackageRoot, node.value)),
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
if (pagePathNodes.length) {
|
|
72
|
-
for (const node of pagePathNodes) {
|
|
73
|
-
const pagePath = node.value ?? '';
|
|
74
|
-
if (pageExistsWithCaseSync(path_1.default.join(inputDir, pagePath))) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
const { line, column } = (0, utils_2.offsetToLineColumn)(jsonStr, node.offset);
|
|
78
|
-
throw {
|
|
79
|
-
name: 'CompilerError',
|
|
80
|
-
code: 'CompilerError',
|
|
81
|
-
message: `The page path "${pagePath}" does not exist`,
|
|
82
|
-
loc: {
|
|
83
|
-
start: { line, column },
|
|
84
|
-
},
|
|
85
|
-
offsetStart: node.offset,
|
|
86
|
-
offsetEnd: node.offset + node.length,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
exports.checkPagesJson = checkPagesJson;
|
|
93
|
-
function pageExistsWithCaseSync(pagePath) {
|
|
94
|
-
try {
|
|
95
|
-
const files = fs_1.default.readdirSync(path_1.default.dirname(pagePath));
|
|
96
|
-
const basename = path_1.default.basename(pagePath);
|
|
97
|
-
const uvuePage = basename + '.uvue';
|
|
98
|
-
const vuePage = basename + '.vue';
|
|
99
|
-
return files.some((file) => file === uvuePage || file === vuePage);
|
|
100
|
-
}
|
|
101
|
-
catch (e) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function findSubPackageRoot(node) {
|
|
106
|
-
const child = node.children?.find((child) => child.type === 'property' &&
|
|
107
|
-
child.children &&
|
|
108
|
-
child.children.find((child) => child.type === 'string' && child.value === 'root'));
|
|
109
|
-
if (child && child.children?.length === 2) {
|
|
110
|
-
return child.children[1].value;
|
|
111
|
-
}
|
|
112
|
-
return '';
|
|
113
|
-
}
|
|
114
|
-
function findRootNode(node, property) {
|
|
115
|
-
const { type, children } = node;
|
|
116
|
-
if (type === 'object' && children) {
|
|
117
|
-
const child = children.find((child) => child.type === 'property' &&
|
|
118
|
-
child.children &&
|
|
119
|
-
child.children.find((child) => child.type === 'string' && property.includes(child.value)));
|
|
120
|
-
if (child) {
|
|
121
|
-
const node = child.children.find((child) => child.type === 'array');
|
|
122
|
-
return node?.children ?? [];
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return [];
|
|
126
|
-
}
|
|
127
|
-
function walkNodes(node) {
|
|
128
|
-
const pagePathNodes = [];
|
|
129
|
-
node.forEach((node) => walkNode(node, pagePathNodes));
|
|
130
|
-
return pagePathNodes;
|
|
131
|
-
}
|
|
132
|
-
function walkNode(node, pagePathNodes) {
|
|
133
|
-
const { type, children } = node;
|
|
134
|
-
if (type === 'property' && children && children.length === 2) {
|
|
135
|
-
const maybePagePathNode = children[0];
|
|
136
|
-
const maybePagePathValueNode = children[1];
|
|
137
|
-
if (maybePagePathNode.type === 'string' &&
|
|
138
|
-
maybePagePathNode.value === 'path' &&
|
|
139
|
-
maybePagePathValueNode.type === 'string' &&
|
|
140
|
-
(0, shared_1.isString)(maybePagePathValueNode.value)) {
|
|
141
|
-
pagePathNodes.push(maybePagePathValueNode);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (children) {
|
|
145
|
-
children.forEach((node) => walkNode(node, pagePathNodes));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
31
|
function normalizeUniAppXAppPagesJson(jsonStr) {
|
|
149
32
|
// 先条件编译
|
|
150
33
|
jsonStr = (0, preprocess_1.preUVueJson)(jsonStr, 'pages.json');
|
|
151
|
-
checkPagesJson(jsonStr, process.env.UNI_INPUT_DIR);
|
|
34
|
+
(0, utils_2.checkPagesJson)(jsonStr, process.env.UNI_INPUT_DIR);
|
|
152
35
|
const pagesJson = {
|
|
153
36
|
pages: [],
|
|
154
37
|
globalStyle: {},
|
|
@@ -191,6 +74,9 @@ function normalizeUniAppXAppPagesJson(jsonStr) {
|
|
|
191
74
|
}
|
|
192
75
|
// 是否应该用 process.env.UNI_UTS_PLATFORM
|
|
193
76
|
(0, pages_1.filterPlatformPages)(process.env.UNI_PLATFORM, pagesJson);
|
|
77
|
+
// 缓存页面列表
|
|
78
|
+
pages_1.pagesCacheSet.clear();
|
|
79
|
+
pagesJson.pages.forEach((page) => pages_1.pagesCacheSet.add(page.path));
|
|
194
80
|
return pagesJson;
|
|
195
81
|
}
|
|
196
82
|
exports.normalizeUniAppXAppPagesJson = normalizeUniAppXAppPagesJson;
|
|
@@ -245,3 +131,20 @@ globalThis.__uniRoutes = __uniRoutes;`;
|
|
|
245
131
|
return appConfigJs;
|
|
246
132
|
}
|
|
247
133
|
exports.normalizeUniAppXAppConfig = normalizeUniAppXAppConfig;
|
|
134
|
+
function isUniXPageFile(source, importer, inputDir = process.env.UNI_INPUT_DIR) {
|
|
135
|
+
if (source.startsWith('@/')) {
|
|
136
|
+
return (0, pages_1.isUniPageFile)(source.slice(2), inputDir);
|
|
137
|
+
}
|
|
138
|
+
if (source.startsWith('.')) {
|
|
139
|
+
return (0, pages_1.isUniPageFile)(path_1.default.resolve(path_1.default.dirname(importer), source), inputDir);
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
exports.isUniXPageFile = isUniXPageFile;
|
|
144
|
+
function getUniXPagePaths() {
|
|
145
|
+
if (process.env.UNI_COMPILE_EXT_API_PAGE_PATHS) {
|
|
146
|
+
return JSON.parse(process.env.UNI_COMPILE_EXT_API_PAGE_PATHS);
|
|
147
|
+
}
|
|
148
|
+
return Array.from(pages_1.pagesCacheSet);
|
|
149
|
+
}
|
|
150
|
+
exports.getUniXPagePaths = getUniXPagePaths;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export declare function parseUniXFlexDirection(manifestJson: Record<string, any>): any;
|
|
2
|
-
export declare function parseUniXSplashScreen(manifestJson: Record<string, any>): false | object;
|
|
3
|
-
export declare function parseUniXUniStatistics(manifestJson: Record<string, any>): false | object;
|
|
2
|
+
export declare function parseUniXSplashScreen(platform: 'app-android' | 'app-ios' | 'app-harmony', manifestJson: Record<string, any>): false | object;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = void 0;
|
|
4
4
|
const shared_1 = require("@vue/shared");
|
|
5
5
|
const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse'];
|
|
6
6
|
function parseUniXFlexDirection(manifestJson) {
|
|
@@ -11,19 +11,11 @@ function parseUniXFlexDirection(manifestJson) {
|
|
|
11
11
|
return 'column';
|
|
12
12
|
}
|
|
13
13
|
exports.parseUniXFlexDirection = parseUniXFlexDirection;
|
|
14
|
-
function parseUniXSplashScreen(manifestJson) {
|
|
15
|
-
const splashScreen = manifestJson?.[
|
|
14
|
+
function parseUniXSplashScreen(platform, manifestJson) {
|
|
15
|
+
const splashScreen = (manifestJson?.[platform] || manifestJson?.app)?.['splashScreen'];
|
|
16
16
|
if ((0, shared_1.isPlainObject)(splashScreen)) {
|
|
17
17
|
return splashScreen;
|
|
18
18
|
}
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
exports.parseUniXSplashScreen = parseUniXSplashScreen;
|
|
22
|
-
function parseUniXUniStatistics(manifestJson) {
|
|
23
|
-
const uniStatistics = manifestJson?.['app']?.['uniStatistics'];
|
|
24
|
-
if ((0, shared_1.isPlainObject)(uniStatistics)) {
|
|
25
|
-
return uniStatistics;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
exports.parseUniXUniStatistics = parseUniXUniStatistics;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function checkPagesJson(jsonStr: string, inputDir: string): boolean;
|