@dcloudio/uni-cli-shared 3.0.0-3090620231104002 → 3.0.0-3090920231225001
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 +1 -0
- package/dist/constants.js +3 -2
- package/dist/hbx/log.js +2 -1
- package/dist/json/app/manifest/nvue.d.ts +1 -1
- package/dist/json/app/pages/uniConfig.d.ts +5 -0
- package/dist/json/app/pages/uniConfig.js +2 -1
- package/dist/json/index.d.ts +1 -1
- package/dist/json/index.js +7 -3
- package/dist/json/mp/pages.js +1 -1
- package/dist/json/pages.js +19 -14
- package/dist/json/uni-x/index.d.ts +10 -0
- package/dist/json/uni-x/index.js +209 -0
- package/dist/json/uni-x/manifest.d.ts +2 -0
- package/dist/json/uni-x/manifest.js +21 -0
- package/dist/json/uni-x/uniConfig.d.ts +1 -0
- package/dist/json/uni-x/uniConfig.js +18 -0
- package/dist/preprocess/context.js +10 -6
- package/dist/uni_modules.js +12 -1
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +18 -1
- package/dist/uts.js +17 -8
- package/dist/vite/autoImport.d.ts +3 -0
- package/dist/vite/autoImport.js +105 -0
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/index.js +1 -0
- package/dist/vite/plugins/index.d.ts +3 -3
- package/dist/vite/plugins/index.js +4 -3
- package/dist/vite/plugins/uts/{app.d.ts → uni_modules.d.ts} +2 -1
- package/dist/vite/plugins/uts/{app.js → uni_modules.js} +5 -4
- package/dist/vite/plugins/uts/uvue.d.ts +2 -0
- package/dist/vite/plugins/uts/{h5.js → uvue.js} +4 -4
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +5 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +56 -9
- package/dist/vite/plugins/vitejs/utils.d.ts +7 -1
- package/dist/vite/plugins/vitejs/utils.js +44 -6
- package/dist/vite/utils/utils.d.ts +3 -0
- package/dist/vite/utils/utils.js +39 -1
- package/package.json +5 -4
- package/dist/json/uniAppX.d.ts +0 -1
- package/dist/json/uniAppX.js +0 -79
- package/dist/vite/plugins/uts/h5.d.ts +0 -2
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const PUBLIC_DIR = "static";
|
|
2
2
|
export declare const EXTNAME_JS: string[];
|
|
3
|
+
export declare const X_EXTNAME_JS: string[];
|
|
3
4
|
export declare const EXTNAME_TS: string[];
|
|
4
5
|
export declare const EXTNAME_VUE: string[];
|
|
5
6
|
export declare const X_EXTNAME_VUE: string[];
|
package/dist/constants.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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.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.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.X_EXTNAME_JS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
|
4
4
|
exports.PUBLIC_DIR = 'static';
|
|
5
5
|
exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
|
|
6
|
+
exports.X_EXTNAME_JS = ['.uts', ...exports.EXTNAME_JS];
|
|
6
7
|
exports.EXTNAME_TS = ['.ts', '.tsx'];
|
|
7
8
|
exports.EXTNAME_VUE = ['.vue', '.nvue', '.uvue'];
|
|
8
9
|
exports.X_EXTNAME_VUE = ['.uvue', '.vue'];
|
|
@@ -38,7 +39,7 @@ exports.BINDING_COMPONENTS = '__BINDING_COMPONENTS__';
|
|
|
38
39
|
exports.PAGE_EXTNAME_APP = ['.nvue', '.vue', '.tsx', '.jsx', '.js'];
|
|
39
40
|
// 其他平台解析页面后缀的优先级
|
|
40
41
|
exports.PAGE_EXTNAME = ['.vue', '.nvue', '.tsx', '.jsx', '.js'];
|
|
41
|
-
exports.X_PAGE_EXTNAME = ['.
|
|
42
|
+
exports.X_PAGE_EXTNAME = ['.uvue', '.vue', '.tsx', '.jsx', '.js'];
|
|
42
43
|
exports.X_PAGE_EXTNAME_APP = ['.uvue', '.tsx', '.jsx', '.js'];
|
|
43
44
|
exports.H5_API_STYLE_PATH = '@dcloudio/uni-h5/style/api/';
|
|
44
45
|
exports.H5_FRAMEWORK_STYLE_PATH = '@dcloudio/uni-h5/style/framework/';
|
package/dist/hbx/log.js
CHANGED
|
@@ -43,7 +43,8 @@ if (typeof console !== 'undefined') {
|
|
|
43
43
|
// overridedConsole('error', console.error, ZERO_WIDTH_CHAR.ERROR)
|
|
44
44
|
}
|
|
45
45
|
function formatAtFilename(filename, line, column) {
|
|
46
|
-
|
|
46
|
+
const file = path_1.default.relative(process.env.UNI_INPUT_DIR, filename.replace('\x00', '').split('?')[0]);
|
|
47
|
+
return `at ${picocolors_1.default.cyan((0, utils_1.normalizePath)(file === 'pages-json-uts' ? 'pages.json' : file) +
|
|
47
48
|
':' +
|
|
48
49
|
(line || 1) +
|
|
49
50
|
':' +
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function initNVue(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
|
2
|
-
export declare function getNVueCompiler(manifestJson: Record<string, any>): "uni-app" | "
|
|
2
|
+
export declare function getNVueCompiler(manifestJson: Record<string, any>): "uni-app" | "vue" | "weex" | "vite";
|
|
3
3
|
export declare function getNVueStyleCompiler(manifestJson: Record<string, any>): "uni-app" | "weex";
|
|
4
4
|
export declare function getNVueFlexDirection(manifestJson: Record<string, any>): "column" | "row" | "row-reverse" | "column-reverse";
|
|
@@ -1 +1,6 @@
|
|
|
1
1
|
export declare function normalizeAppUniConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
2
|
+
export declare function parseEntryPagePath(pagesJson: UniApp.PagesJson): {
|
|
3
|
+
entryPagePath: string;
|
|
4
|
+
entryPageQuery: string;
|
|
5
|
+
realEntryPagePath: string;
|
|
6
|
+
};
|
|
@@ -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.normalizeAppUniConfig = void 0;
|
|
6
|
+
exports.parseEntryPagePath = exports.normalizeAppUniConfig = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const i18n_1 = require("../../../i18n");
|
|
9
9
|
const manifest_1 = require("../../manifest");
|
|
@@ -70,3 +70,4 @@ function parseEntryPagePath(pagesJson) {
|
|
|
70
70
|
}
|
|
71
71
|
return res;
|
|
72
72
|
}
|
|
73
|
+
exports.parseEntryPagePath = parseEntryPagePath;
|
package/dist/json/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export * from './json';
|
|
|
4
4
|
export * from './pages';
|
|
5
5
|
export * from './manifest';
|
|
6
6
|
export * from './theme';
|
|
7
|
-
export { normalizeUniAppXAppPagesJson } from './
|
|
7
|
+
export { normalizeUniAppXAppPagesJson, normalizeUniAppXAppConfig, checkPagesJson, parseUniXFlexDirection, parseUniXSplashScreen, } from './uni-x';
|
package/dist/json/index.js
CHANGED
|
@@ -14,12 +14,16 @@ 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.normalizeUniAppXAppPagesJson = void 0;
|
|
17
|
+
exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = exports.checkPagesJson = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
|
|
18
18
|
__exportStar(require("./mp"), exports);
|
|
19
19
|
__exportStar(require("./app"), exports);
|
|
20
20
|
__exportStar(require("./json"), exports);
|
|
21
21
|
__exportStar(require("./pages"), exports);
|
|
22
22
|
__exportStar(require("./manifest"), exports);
|
|
23
23
|
__exportStar(require("./theme"), exports);
|
|
24
|
-
var
|
|
25
|
-
Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return
|
|
24
|
+
var uni_x_1 = require("./uni-x");
|
|
25
|
+
Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppPagesJson; } });
|
|
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
|
+
Object.defineProperty(exports, "parseUniXFlexDirection", { enumerable: true, get: function () { return uni_x_1.parseUniXFlexDirection; } });
|
|
29
|
+
Object.defineProperty(exports, "parseUniXSplashScreen", { enumerable: true, get: function () { return uni_x_1.parseUniXSplashScreen; } });
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -24,9 +24,9 @@ const NON_APP_JSON_KEYS = [
|
|
|
24
24
|
'usingComponents',
|
|
25
25
|
'optimization',
|
|
26
26
|
'scopedSlotsCompiler',
|
|
27
|
-
'usingComponents',
|
|
28
27
|
'uniStatistics',
|
|
29
28
|
'mergeVirtualHostAttributes',
|
|
29
|
+
'styleIsolation',
|
|
30
30
|
];
|
|
31
31
|
function mergeMiniProgramAppJson(appJson, platformJson = {}) {
|
|
32
32
|
Object.keys(platformJson).forEach((name) => {
|
package/dist/json/pages.js
CHANGED
|
@@ -194,23 +194,28 @@ function normalizeSubpackageSubNVues(root, style = { navigationBar: {} }) {
|
|
|
194
194
|
return style;
|
|
195
195
|
}
|
|
196
196
|
function normalizePageStyle(pagePath, pageStyle, platform) {
|
|
197
|
-
const hasNVue = pagePath &&
|
|
198
|
-
process.env.UNI_INPUT_DIR &&
|
|
199
|
-
fs_1.default.existsSync(path_1.default.join(process.env.UNI_INPUT_DIR, pagePath + '.nvue'))
|
|
200
|
-
? true
|
|
201
|
-
: undefined;
|
|
202
197
|
let isNVue = false;
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
198
|
+
if (process.env.UNI_APP_X === 'true') {
|
|
199
|
+
isNVue = undefined;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
const hasNVue = pagePath &&
|
|
203
|
+
process.env.UNI_INPUT_DIR &&
|
|
204
|
+
fs_1.default.existsSync(path_1.default.join(process.env.UNI_INPUT_DIR, pagePath + '.nvue'))
|
|
205
|
+
? true
|
|
206
|
+
: undefined;
|
|
207
|
+
if (hasNVue) {
|
|
208
|
+
const hasVue = fs_1.default.existsSync(path_1.default.join(process.env.UNI_INPUT_DIR, pagePath + '.vue'));
|
|
209
|
+
if (hasVue) {
|
|
210
|
+
if (platform === 'app') {
|
|
211
|
+
if (process.env.UNI_NVUE_COMPILER !== 'vue') {
|
|
212
|
+
isNVue = true;
|
|
213
|
+
}
|
|
209
214
|
}
|
|
210
215
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
216
|
+
else {
|
|
217
|
+
isNVue = true;
|
|
218
|
+
}
|
|
214
219
|
}
|
|
215
220
|
}
|
|
216
221
|
if (pageStyle) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { parseUniXFlexDirection, parseUniXSplashScreen } from './manifest';
|
|
2
|
+
export declare function checkPagesJson(jsonStr: string, inputDir: string): boolean;
|
|
3
|
+
export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.PagesJson;
|
|
4
|
+
/**
|
|
5
|
+
* TODO 应该闭包,通过globalThis赋值?
|
|
6
|
+
* @param pagesJson
|
|
7
|
+
* @param manifestJson
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeUniAppXAppConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
@@ -0,0 +1,209 @@
|
|
|
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.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = exports.checkPagesJson = exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const shared_1 = require("@vue/shared");
|
|
10
|
+
const jsonc_parser_1 = require("jsonc-parser");
|
|
11
|
+
const json_1 = require("../json");
|
|
12
|
+
const pages_1 = require("../pages");
|
|
13
|
+
const utils_1 = require("../../utils");
|
|
14
|
+
const uniRoutes_1 = require("../app/pages/uniRoutes");
|
|
15
|
+
const uniConfig_1 = require("./uniConfig");
|
|
16
|
+
const utils_2 = require("../../vite/plugins/vitejs/utils");
|
|
17
|
+
var manifest_1 = require("./manifest");
|
|
18
|
+
Object.defineProperty(exports, "parseUniXFlexDirection", { enumerable: true, get: function () { return manifest_1.parseUniXFlexDirection; } });
|
|
19
|
+
Object.defineProperty(exports, "parseUniXSplashScreen", { enumerable: true, get: function () { return manifest_1.parseUniXSplashScreen; } });
|
|
20
|
+
function checkPagesJson(jsonStr, inputDir) {
|
|
21
|
+
if (!inputDir) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const errors = [];
|
|
25
|
+
const root = (0, jsonc_parser_1.parseTree)(jsonStr, errors);
|
|
26
|
+
if (!root) {
|
|
27
|
+
if (errors.length) {
|
|
28
|
+
for (const error of errors) {
|
|
29
|
+
const { line, column } = (0, utils_2.offsetToLineColumn)(jsonStr, error.offset);
|
|
30
|
+
throw {
|
|
31
|
+
name: 'SyntaxError',
|
|
32
|
+
code: error.error,
|
|
33
|
+
message: (0, jsonc_parser_1.printParseErrorCode)(error.error),
|
|
34
|
+
loc: {
|
|
35
|
+
start: { line, column },
|
|
36
|
+
},
|
|
37
|
+
offsetStart: error.offset,
|
|
38
|
+
offsetEnd: error.offset + error.length,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const pagePathNodes = walkNodes(findRootNode(root, ['pages']));
|
|
45
|
+
findRootNode(root, ['subPackages', 'subpackages']).forEach((node) => {
|
|
46
|
+
const subPackageRoot = findSubPackageRoot(node);
|
|
47
|
+
if (subPackageRoot) {
|
|
48
|
+
findRootNode(node, ['pages']).forEach((subNode) => {
|
|
49
|
+
walkNodes(subNode.children ?? []).forEach((node) => {
|
|
50
|
+
pagePathNodes.push({
|
|
51
|
+
...node,
|
|
52
|
+
value: (0, utils_1.normalizePath)(path_1.default.join(subPackageRoot, node.value)),
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (pagePathNodes.length) {
|
|
59
|
+
for (const node of pagePathNodes) {
|
|
60
|
+
const pagePath = node.value ?? '';
|
|
61
|
+
if (fs_1.default.existsSync(path_1.default.join(inputDir, pagePath + '.uvue')) ||
|
|
62
|
+
fs_1.default.existsSync(path_1.default.join(inputDir, pagePath + '.vue'))) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const { line, column } = (0, utils_2.offsetToLineColumn)(jsonStr, node.offset);
|
|
66
|
+
throw {
|
|
67
|
+
name: 'CompilerError',
|
|
68
|
+
code: 'CompilerError',
|
|
69
|
+
message: `The page path "${pagePath}" does not exist`,
|
|
70
|
+
loc: {
|
|
71
|
+
start: { line, column },
|
|
72
|
+
},
|
|
73
|
+
offsetStart: node.offset,
|
|
74
|
+
offsetEnd: node.offset + node.length,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
exports.checkPagesJson = checkPagesJson;
|
|
81
|
+
function findSubPackageRoot(node) {
|
|
82
|
+
const child = node.children?.find((child) => child.type === 'property' &&
|
|
83
|
+
child.children &&
|
|
84
|
+
child.children.find((child) => child.type === 'string' && child.value === 'root'));
|
|
85
|
+
if (child && child.children?.length === 2) {
|
|
86
|
+
return child.children[1].value;
|
|
87
|
+
}
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
function findRootNode(node, property) {
|
|
91
|
+
const { type, children } = node;
|
|
92
|
+
if (type === 'object' && children) {
|
|
93
|
+
const child = children.find((child) => child.type === 'property' &&
|
|
94
|
+
child.children &&
|
|
95
|
+
child.children.find((child) => child.type === 'string' && property.includes(child.value)));
|
|
96
|
+
if (child) {
|
|
97
|
+
const node = child.children.find((child) => child.type === 'array');
|
|
98
|
+
return node?.children ?? [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
function walkNodes(node) {
|
|
104
|
+
const pagePathNodes = [];
|
|
105
|
+
node.forEach((node) => walkNode(node, pagePathNodes));
|
|
106
|
+
return pagePathNodes;
|
|
107
|
+
}
|
|
108
|
+
function walkNode(node, pagePathNodes) {
|
|
109
|
+
const { type, children } = node;
|
|
110
|
+
if (type === 'property' && children && children.length === 2) {
|
|
111
|
+
const maybePagePathNode = children[0];
|
|
112
|
+
const maybePagePathValueNode = children[1];
|
|
113
|
+
if (maybePagePathNode.type === 'string' &&
|
|
114
|
+
maybePagePathNode.value === 'path' &&
|
|
115
|
+
maybePagePathValueNode.type === 'string' &&
|
|
116
|
+
(0, shared_1.isString)(maybePagePathValueNode.value)) {
|
|
117
|
+
pagePathNodes.push(maybePagePathValueNode);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (children) {
|
|
121
|
+
children.forEach((node) => walkNode(node, pagePathNodes));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function normalizeUniAppXAppPagesJson(jsonStr) {
|
|
125
|
+
checkPagesJson(jsonStr, process.env.UNI_INPUT_DIR);
|
|
126
|
+
const pagesJson = {
|
|
127
|
+
pages: [],
|
|
128
|
+
globalStyle: {},
|
|
129
|
+
};
|
|
130
|
+
let userPagesJson = {
|
|
131
|
+
pages: [],
|
|
132
|
+
globalStyle: {},
|
|
133
|
+
};
|
|
134
|
+
// preprocess
|
|
135
|
+
try {
|
|
136
|
+
userPagesJson = (0, json_1.parseJson)(jsonStr, true);
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
console.error(`[vite] Error: pages.json parse failed.\n`, jsonStr, e);
|
|
140
|
+
}
|
|
141
|
+
// pages
|
|
142
|
+
(0, pages_1.validatePages)(userPagesJson, jsonStr);
|
|
143
|
+
userPagesJson.subPackages =
|
|
144
|
+
userPagesJson.subPackages || userPagesJson.subpackages;
|
|
145
|
+
// subPackages
|
|
146
|
+
if (userPagesJson.subPackages) {
|
|
147
|
+
userPagesJson.pages.push(...normalizeSubPackages(userPagesJson.subPackages));
|
|
148
|
+
}
|
|
149
|
+
pagesJson.pages = userPagesJson.pages;
|
|
150
|
+
// pageStyle
|
|
151
|
+
normalizePages(pagesJson.pages);
|
|
152
|
+
// globalStyle
|
|
153
|
+
pagesJson.globalStyle = normalizePageStyle(userPagesJson.globalStyle);
|
|
154
|
+
// tabBar
|
|
155
|
+
if (userPagesJson.tabBar) {
|
|
156
|
+
pagesJson.tabBar = userPagesJson.tabBar;
|
|
157
|
+
}
|
|
158
|
+
// condition
|
|
159
|
+
if (userPagesJson.condition) {
|
|
160
|
+
pagesJson.condition = userPagesJson.condition;
|
|
161
|
+
}
|
|
162
|
+
// uniIdRouter
|
|
163
|
+
if (userPagesJson.uniIdRouter) {
|
|
164
|
+
pagesJson.uniIdRouter = userPagesJson.uniIdRouter;
|
|
165
|
+
}
|
|
166
|
+
return pagesJson;
|
|
167
|
+
}
|
|
168
|
+
exports.normalizeUniAppXAppPagesJson = normalizeUniAppXAppPagesJson;
|
|
169
|
+
function normalizeSubPackages(subPackages) {
|
|
170
|
+
const pages = [];
|
|
171
|
+
if ((0, shared_1.isArray)(subPackages)) {
|
|
172
|
+
subPackages.forEach(({ root, pages: subPages }) => {
|
|
173
|
+
if (root && subPages.length) {
|
|
174
|
+
subPages.forEach((subPage) => {
|
|
175
|
+
subPage.path = (0, utils_1.normalizePath)(path_1.default.join(root, subPage.path));
|
|
176
|
+
subPage.style = subPage.style;
|
|
177
|
+
pages.push(subPage);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return pages;
|
|
183
|
+
}
|
|
184
|
+
function normalizePages(pages) {
|
|
185
|
+
pages.forEach((page) => {
|
|
186
|
+
page.style = normalizePageStyle(page.style);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function normalizePageStyle(pageStyle) {
|
|
190
|
+
if (pageStyle) {
|
|
191
|
+
(0, shared_1.extend)(pageStyle, pageStyle['app']);
|
|
192
|
+
(0, pages_1.removePlatformStyle)(pageStyle);
|
|
193
|
+
return pageStyle;
|
|
194
|
+
}
|
|
195
|
+
return {};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* TODO 应该闭包,通过globalThis赋值?
|
|
199
|
+
* @param pagesJson
|
|
200
|
+
* @param manifestJson
|
|
201
|
+
* @returns
|
|
202
|
+
*/
|
|
203
|
+
function normalizeUniAppXAppConfig(pagesJson, manifestJson) {
|
|
204
|
+
return `const __uniConfig = ${(0, uniConfig_1.normalizeAppXUniConfig)(pagesJson, manifestJson)};
|
|
205
|
+
const __uniRoutes = ${(0, uniRoutes_1.normalizeAppUniRoutes)(pagesJson)}.map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
|
|
206
|
+
|
|
207
|
+
`;
|
|
208
|
+
}
|
|
209
|
+
exports.normalizeUniAppXAppConfig = normalizeUniAppXAppConfig;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = void 0;
|
|
4
|
+
const shared_1 = require("@vue/shared");
|
|
5
|
+
const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse'];
|
|
6
|
+
function parseUniXFlexDirection(manifestJson) {
|
|
7
|
+
const flexDir = manifestJson?.['uni-app-x']?.['flex-direction'];
|
|
8
|
+
if (flexDir && flexDirs.includes(flexDir)) {
|
|
9
|
+
return flexDir;
|
|
10
|
+
}
|
|
11
|
+
return 'column';
|
|
12
|
+
}
|
|
13
|
+
exports.parseUniXFlexDirection = parseUniXFlexDirection;
|
|
14
|
+
function parseUniXSplashScreen(manifestJson) {
|
|
15
|
+
const splashScreen = manifestJson?.['app']?.['splashScreen'];
|
|
16
|
+
if ((0, shared_1.isPlainObject)(splashScreen)) {
|
|
17
|
+
return splashScreen;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
exports.parseUniXSplashScreen = parseUniXSplashScreen;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeAppXUniConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeAppXUniConfig = void 0;
|
|
4
|
+
const uniConfig_1 = require("../app/pages/uniConfig");
|
|
5
|
+
function normalizeAppXUniConfig(pagesJson, manifestJson) {
|
|
6
|
+
const config = {
|
|
7
|
+
pages: [],
|
|
8
|
+
globalStyle: pagesJson.globalStyle,
|
|
9
|
+
appname: manifestJson.name || '',
|
|
10
|
+
compilerVersion: process.env.UNI_COMPILER_VERSION,
|
|
11
|
+
...(0, uniConfig_1.parseEntryPagePath)(pagesJson),
|
|
12
|
+
tabBar: pagesJson.tabBar,
|
|
13
|
+
fallbackLocale: manifestJson.fallbackLocale,
|
|
14
|
+
};
|
|
15
|
+
// TODO 待支持分包
|
|
16
|
+
return JSON.stringify(config);
|
|
17
|
+
}
|
|
18
|
+
exports.normalizeAppXUniConfig = normalizeAppXUniConfig;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initPreContext = exports.getPreUVueContext = exports.getPreNVueContext = exports.getPreVueContext = void 0;
|
|
4
|
-
const
|
|
4
|
+
const extend = Object.assign;
|
|
5
|
+
const isString = (val) => typeof val === 'string';
|
|
6
|
+
const objectToString = Object.prototype.toString;
|
|
7
|
+
const toTypeString = (value) => objectToString.call(value);
|
|
8
|
+
const isPlainObject = (val) => toTypeString(val) === '[object Object]';
|
|
5
9
|
const DEFAULT_KEYS = [
|
|
6
10
|
'UNI_APP_X',
|
|
7
11
|
'APP',
|
|
@@ -88,21 +92,21 @@ function initPreContext(platform, userPreContext, utsPlatform, isX) {
|
|
|
88
92
|
defaultContext.WEB = true;
|
|
89
93
|
}
|
|
90
94
|
if (userPreContext) {
|
|
91
|
-
if (
|
|
95
|
+
if (isString(userPreContext)) {
|
|
92
96
|
try {
|
|
93
97
|
userPreContext = JSON.parse(userPreContext);
|
|
94
98
|
}
|
|
95
99
|
catch (e) { }
|
|
96
100
|
}
|
|
97
|
-
if (
|
|
101
|
+
if (isPlainObject(userPreContext)) {
|
|
98
102
|
Object.keys(userPreContext).forEach((key) => {
|
|
99
103
|
defaultContext[normalizeKey(key)] = !!userPreContext[key];
|
|
100
104
|
});
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
extend(preVueContext, defaultContext, vueContext);
|
|
108
|
+
extend(preNVueContext, defaultContext, nvueContext);
|
|
109
|
+
extend(preUVueContext, defaultContext, uvueContext);
|
|
106
110
|
}
|
|
107
111
|
exports.initPreContext = initPreContext;
|
|
108
112
|
function normalizeKey(name) {
|
package/dist/uni_modules.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseInjects = exports.parseUniExtApis = void 0;
|
|
7
|
+
// 重要:此文件编译后的js,需同步至 vue2 编译器中 uni-cli-shared/lib/uts/uni_modules.js
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
10
|
function parseUniExtApis(vite = true, platform, language = 'javascript') {
|
|
@@ -63,6 +64,9 @@ exports.parseUniExtApis = parseUniExtApis;
|
|
|
63
64
|
* @returns
|
|
64
65
|
*/
|
|
65
66
|
function parseInjects(vite = true, platform, language, source, uniModuleRootDir, exports = {}) {
|
|
67
|
+
if (platform === 'app-plus') {
|
|
68
|
+
platform = 'app';
|
|
69
|
+
}
|
|
66
70
|
let rootDefines = {};
|
|
67
71
|
Object.keys(exports).forEach((name) => {
|
|
68
72
|
if (name.startsWith('uni')) {
|
|
@@ -71,10 +75,17 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
|
|
|
71
75
|
});
|
|
72
76
|
const injects = {};
|
|
73
77
|
if (Object.keys(rootDefines).length) {
|
|
74
|
-
|
|
78
|
+
let hasPlatformFile = uniModuleRootDir
|
|
75
79
|
? fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'index.uts')) ||
|
|
76
80
|
fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', platform))
|
|
77
81
|
: true;
|
|
82
|
+
if (!hasPlatformFile) {
|
|
83
|
+
if (platform === 'app') {
|
|
84
|
+
hasPlatformFile =
|
|
85
|
+
fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-android')) ||
|
|
86
|
+
fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-ios'));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
78
89
|
for (const key in rootDefines) {
|
|
79
90
|
Object.assign(injects, parseInject(vite, platform, language, source, 'uni', rootDefines[key], hasPlatformFile));
|
|
80
91
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { default as hash } from 'hash-sum';
|
|
|
2
2
|
import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
|
|
3
3
|
import { ParserPlugin } from '@babel/parser';
|
|
4
4
|
export declare const version: any;
|
|
5
|
+
export { camelize, capitalize, isArray } from '@vue/shared';
|
|
5
6
|
export declare let isRunningWithYarnPnp: boolean;
|
|
6
7
|
export declare const isWindows: boolean;
|
|
7
8
|
export declare function normalizePath(id: string): string;
|
|
@@ -20,3 +21,5 @@ export declare function resolveSourceMapPath(outputDir?: string, platform?: UniA
|
|
|
20
21
|
export declare function installDepTips(type: 'dependencies' | 'devDependencies', module: string, version?: string): string;
|
|
21
22
|
export declare function isAppVue(filename: string): boolean;
|
|
22
23
|
export declare function resolveAppVue(inputDir: string): string;
|
|
24
|
+
export declare function parseImporter(importer: string): string;
|
|
25
|
+
export declare function createResolveErrorMsg(source: string, importer: 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.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.isRunningWithYarnPnp = exports.version = exports.hash = void 0;
|
|
6
|
+
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.isRunningWithYarnPnp = exports.isArray = exports.capitalize = exports.camelize = exports.version = 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"));
|
|
@@ -14,6 +14,11 @@ Object.defineProperty(exports, "hash", { enumerable: true, get: function () { re
|
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
15
|
const platform_1 = require("./platform");
|
|
16
16
|
exports.version = require('../package.json').version;
|
|
17
|
+
// 专为 uts.ts 服务
|
|
18
|
+
var shared_2 = require("@vue/shared");
|
|
19
|
+
Object.defineProperty(exports, "camelize", { enumerable: true, get: function () { return shared_2.camelize; } });
|
|
20
|
+
Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return shared_2.capitalize; } });
|
|
21
|
+
Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return shared_2.isArray; } });
|
|
17
22
|
try {
|
|
18
23
|
exports.isRunningWithYarnPnp = Boolean(require('pnpapi'));
|
|
19
24
|
}
|
|
@@ -124,3 +129,15 @@ function resolveAppVue(inputDir) {
|
|
|
124
129
|
return normalizePath(path_1.default.resolve(inputDir, 'App.vue'));
|
|
125
130
|
}
|
|
126
131
|
exports.resolveAppVue = resolveAppVue;
|
|
132
|
+
function parseImporter(importer) {
|
|
133
|
+
importer = importer.split('?')[0];
|
|
134
|
+
if (path_1.default.isAbsolute(importer)) {
|
|
135
|
+
return normalizePath(path_1.default.relative(process.env.UNI_INPUT_DIR, importer));
|
|
136
|
+
}
|
|
137
|
+
return importer;
|
|
138
|
+
}
|
|
139
|
+
exports.parseImporter = parseImporter;
|
|
140
|
+
function createResolveErrorMsg(source, importer) {
|
|
141
|
+
return `Could not resolve "${source}" from "${parseImporter(importer)}"`;
|
|
142
|
+
}
|
|
143
|
+
exports.createResolveErrorMsg = createResolveErrorMsg;
|
package/dist/uts.js
CHANGED
|
@@ -7,11 +7,20 @@ exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce =
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
10
|
-
const shared_1 = require("@vue/shared");
|
|
11
10
|
const hbx_1 = require("./hbx");
|
|
12
11
|
const utils_1 = require("./utils");
|
|
13
|
-
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
14
12
|
const uni_modules_1 = require("./uni_modules");
|
|
13
|
+
// 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
|
|
14
|
+
function once(fn, ctx = null) {
|
|
15
|
+
let res;
|
|
16
|
+
return ((...args) => {
|
|
17
|
+
if (fn) {
|
|
18
|
+
res = fn.apply(ctx, args);
|
|
19
|
+
fn = null;
|
|
20
|
+
}
|
|
21
|
+
return res;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
15
24
|
/**
|
|
16
25
|
* 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
|
|
17
26
|
* @param id
|
|
@@ -114,7 +123,7 @@ function parseUTSComponent(name, type) {
|
|
|
114
123
|
const meta = utsComponents.get(name);
|
|
115
124
|
if (meta) {
|
|
116
125
|
const namespace = meta[type === 'swift' ? 'swiftModule' : 'kotlinPackage'] || '';
|
|
117
|
-
const className = (0,
|
|
126
|
+
const className = (0, utils_1.capitalize)((0, utils_1.camelize)(name)) + 'Component';
|
|
118
127
|
return {
|
|
119
128
|
className,
|
|
120
129
|
namespace,
|
|
@@ -209,16 +218,16 @@ function prefix(id) {
|
|
|
209
218
|
return id;
|
|
210
219
|
}
|
|
211
220
|
function parseKotlinPackageWithPluginId(id, is_uni_modules) {
|
|
212
|
-
return 'uts.sdk.' + (is_uni_modules ? 'modules.' : '') + (0,
|
|
221
|
+
return 'uts.sdk.' + (is_uni_modules ? 'modules.' : '') + (0, utils_1.camelize)(prefix(id));
|
|
213
222
|
}
|
|
214
223
|
exports.parseKotlinPackageWithPluginId = parseKotlinPackageWithPluginId;
|
|
215
224
|
function parseSwiftPackageWithPluginId(id, is_uni_modules) {
|
|
216
225
|
return ('UTSSDK' +
|
|
217
226
|
(is_uni_modules ? 'Modules' : '') +
|
|
218
|
-
(0,
|
|
227
|
+
(0, utils_1.capitalize)((0, utils_1.camelize)(prefix(id))));
|
|
219
228
|
}
|
|
220
229
|
exports.parseSwiftPackageWithPluginId = parseSwiftPackageWithPluginId;
|
|
221
|
-
exports.parseUniExtApiNamespacesOnce =
|
|
230
|
+
exports.parseUniExtApiNamespacesOnce = once((platform, language) => {
|
|
222
231
|
const extApis = (0, exports.parseUniExtApiNamespacesJsOnce)(platform, language);
|
|
223
232
|
const namespaces = {};
|
|
224
233
|
Object.keys(extApis).forEach((name) => {
|
|
@@ -235,12 +244,12 @@ exports.parseUniExtApiNamespacesOnce = (0, uni_shared_1.once)((platform, languag
|
|
|
235
244
|
});
|
|
236
245
|
return namespaces;
|
|
237
246
|
});
|
|
238
|
-
exports.parseUniExtApiNamespacesJsOnce =
|
|
247
|
+
exports.parseUniExtApiNamespacesJsOnce = once((platform, language) => {
|
|
239
248
|
const extApis = (0, uni_modules_1.parseUniExtApis)(true, platform, language);
|
|
240
249
|
const namespaces = {};
|
|
241
250
|
Object.keys(extApis).forEach((name) => {
|
|
242
251
|
const options = extApis[name];
|
|
243
|
-
if ((0,
|
|
252
|
+
if ((0, utils_1.isArray)(options) && options.length >= 2) {
|
|
244
253
|
namespaces[name.replace('uni.', '')] = [options[0], options[1]];
|
|
245
254
|
}
|
|
246
255
|
});
|