@dcloudio/uni-cli-shared 3.0.0-5010520260709001 → 3.0.0-5010520260709002
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/dom2/vue.d.ts +1 -0
- package/dist/dom2/vue.js +14 -1
- package/dist/hbx/alias.js +18 -16
- package/dist/json/app/pages/definePage.js +1 -3
- package/dist/json/mp/index.d.ts +0 -2
- package/dist/json/mp/index.js +1 -23
- package/dist/json/mp/jsonFile.d.ts +2 -3
- package/dist/json/mp/jsonFile.js +13 -83
- package/dist/json/mp/pages.d.ts +0 -1
- package/dist/json/mp/pages.js +2 -6
- package/dist/logs/console.js +1 -4
- package/dist/messages/en.d.ts +0 -1
- package/dist/messages/en.js +0 -1
- package/dist/messages/index.d.ts +0 -2
- package/dist/messages/zh_CN.d.ts +0 -1
- package/dist/messages/zh_CN.js +0 -1
- package/dist/mp/usingComponents.d.ts +5 -7
- package/dist/mp/usingComponents.js +34 -63
- package/dist/resolve.d.ts +0 -1
- package/dist/resolve.js +2 -9
- package/dist/vite/plugins/cssScoped.js +2 -11
- package/dist/vite/plugins/easycom.js +1 -3
- package/dist/vite/plugins/inject.js +2 -7
- package/dist/vite/plugins/jsonJs.js +3 -41
- package/dist/vite/plugins/sfc.js +1 -4
- package/dist/vite/plugins/vitejs/plugins/asset.js +1 -14
- package/dist/vite/plugins/vitejs/plugins/css.js +1 -35
- package/dist/vue/transforms/index.js +1 -1
- package/dist/x.d.ts +0 -1
- package/dist/x.js +1 -5
- package/package.json +5 -5
- package/dist/json/mp/subpackage.d.ts +0 -26
- package/dist/json/mp/subpackage.js +0 -236
package/dist/dom2/vue.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare function initVueTemplateCompilerExtraOptions(descriptor: SFCDescr
|
|
|
9
9
|
enableRootScrollViewTransform: boolean;
|
|
10
10
|
rootScrollView: import("src/json/uni-x").UniXPageOptions | undefined;
|
|
11
11
|
scriptCppBlocks: any;
|
|
12
|
+
disableStaticStyle: boolean;
|
|
12
13
|
onVueTemplateCompileLog(type: 'warn' | 'error', error: CompilerError): void;
|
|
13
14
|
r: any;
|
|
14
15
|
className: any;
|
package/dist/dom2/vue.js
CHANGED
|
@@ -13,19 +13,32 @@ function initVueTemplateCompilerExtraOptions(descriptor) {
|
|
|
13
13
|
const relativeFilename = (0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename));
|
|
14
14
|
const rootScrollView = (0, json_1.parseUniXPageOptions)(filename);
|
|
15
15
|
const componentType = rootScrollView || (0, json_1.isUniPageFile)(filename) ? 'page' : 'component';
|
|
16
|
+
const isDevX = process.env.UNI_HX_VERSION_DEV === 'true' &&
|
|
17
|
+
process.env.UNI_APP_X === 'true';
|
|
16
18
|
const isDynamic = process.env.UNI_APP_X_DOM2_DYNAMIC === 'true';
|
|
19
|
+
let disableStaticStyle = false;
|
|
20
|
+
if (isDevX &&
|
|
21
|
+
// 动态渲染时,仍旧使用静态样式,避免性能问题。
|
|
22
|
+
!isDynamic &&
|
|
23
|
+
process.env.NODE_ENV === 'development') {
|
|
24
|
+
if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
|
|
25
|
+
// 开发版本、开发模式下,非鸿蒙release模式打包
|
|
26
|
+
disableStaticStyle = process.env.UNI_APP_HARMONY_RUN_MODE !== 'release';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
17
29
|
const helper = (0, utils_1.requireUniHelpers)();
|
|
18
30
|
return {
|
|
19
31
|
root: (0, utils_1.normalizePath)(process.env.UNI_INPUT_DIR),
|
|
20
32
|
platform: process.env.UNI_UTS_PLATFORM,
|
|
21
33
|
componentType,
|
|
22
|
-
filename,
|
|
34
|
+
filename: filename,
|
|
23
35
|
relativeFilename,
|
|
24
36
|
helper,
|
|
25
37
|
enableRootScrollViewTransform: true,
|
|
26
38
|
// 仅页面透传 rootScrollView,避免非页面组件误触发 ROOT 自动包裹逻辑。
|
|
27
39
|
rootScrollView: componentType === 'page' ? rootScrollView : undefined,
|
|
28
40
|
scriptCppBlocks: descriptor.scriptCppBlocks,
|
|
41
|
+
disableStaticStyle,
|
|
29
42
|
onVueTemplateCompileLog(type, error) {
|
|
30
43
|
return (0, vue_1.onVueTemplateCompileLog)(type, error, descriptor.source, relativeFilename);
|
|
31
44
|
},
|
package/dist/hbx/alias.js
CHANGED
|
@@ -5,9 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.formatInstallHBuilderXPluginTips = exports.moduleAliasFormatter = exports.installHBuilderXPlugin = exports.initModuleAlias = void 0;
|
|
7
7
|
// 注意:该文件尽可能少依赖其他文件,否则可能会导致还没有alias的时候,就加载了目标模块
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const module_alias_1 = __importDefault(require("module-alias"));
|
|
10
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const jsonc_parser_1 = require("jsonc-parser");
|
|
11
13
|
const hbxPlugins = {
|
|
12
14
|
typescript: 'compile-typescript/node_modules/typescript',
|
|
13
15
|
less: 'compile-less/node_modules/less',
|
|
@@ -15,32 +17,32 @@ const hbxPlugins = {
|
|
|
15
17
|
stylus: 'compile-stylus/node_modules/stylus',
|
|
16
18
|
pug: 'compile-pug-cli/node_modules/pug',
|
|
17
19
|
};
|
|
18
|
-
function isWebOrMpPlatform(platform) {
|
|
19
|
-
return platform === 'h5' || platform === 'web' || platform?.startsWith('mp-');
|
|
20
|
-
}
|
|
21
20
|
function initModuleAlias() {
|
|
22
21
|
const libDir = path_1.default.resolve(__dirname, '../../lib');
|
|
23
22
|
const compilerSfcPath = path_1.default.resolve(libDir, '@vue/compiler-sfc');
|
|
24
23
|
const serverRendererPath = require.resolve('@vue/server-renderer');
|
|
25
|
-
if (process.env.UNI_OUTPUT_DIR) {
|
|
26
|
-
const baseOutDir = path_1.default.basename(process.env.UNI_OUTPUT_DIR);
|
|
27
|
-
process.env.UNI_APP_X_CACHE_DIR =
|
|
28
|
-
process.env.UNI_APP_X_CACHE_DIR ||
|
|
29
|
-
path_1.default.resolve(process.env.UNI_OUTPUT_DIR, '../cache/.' + baseOutDir);
|
|
30
|
-
}
|
|
31
24
|
// 对路径进行兼容
|
|
32
25
|
if (!process.env.UNI_APP_X_DOM2_CPP_DIR &&
|
|
33
26
|
process.env.UNI_APP_HARMONY_DOM2_CPP_DIR) {
|
|
34
27
|
process.env.UNI_APP_X_DOM2_CPP_DIR =
|
|
35
28
|
process.env.UNI_APP_HARMONY_DOM2_CPP_DIR;
|
|
36
29
|
}
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
// TODO 等待正式对外推出后,删除这个兼容逻辑
|
|
31
|
+
if (process.env.UNI_APP_PLATFORM === 'ios' ||
|
|
32
|
+
process.env.UNI_APP_PLATFORM === 'android') {
|
|
33
|
+
if (process.env.UNI_INPUT_DIR) {
|
|
34
|
+
const manifestJsonFilename = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'manifest.json');
|
|
35
|
+
if (fs_1.default.existsSync(manifestJsonFilename)) {
|
|
36
|
+
const manifestJsonStr = fs_1.default.readFileSync(manifestJsonFilename, 'utf-8');
|
|
37
|
+
const manifestJson = (0, jsonc_parser_1.parse)(manifestJsonStr);
|
|
38
|
+
if (manifestJson?.['uni-app-x']?.vapor === true) {
|
|
39
|
+
const vaporFilename = path_1.default.resolve(process.env.UNI_INPUT_DIR, '.vapor');
|
|
40
|
+
if (fs_1.default.existsSync(vaporFilename)) {
|
|
41
|
+
process.env.UNI_APP_X_DOM2 = 'true';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
44
46
|
}
|
|
45
47
|
if (process.env.UNI_APP_X_DOM2 === 'true') {
|
|
46
48
|
if (process.env.UNI_OUTPUT_DIR &&
|
|
@@ -46,9 +46,7 @@ function defineNVuePageCode(pagesJson) {
|
|
|
46
46
|
}
|
|
47
47
|
const pagePathWithExtname = (0, utils_1.normalizePagePath)(page.path, 'app');
|
|
48
48
|
if (pagePathWithExtname) {
|
|
49
|
-
importNVuePagesCode.push(
|
|
50
|
-
// 使用 res.default 确保 rollup 不会摇树
|
|
51
|
-
`import('./${pagePathWithExtname}').then((res)=>{res.default})`);
|
|
49
|
+
importNVuePagesCode.push(`import('./${pagePathWithExtname}').then((res)=>{res()})`);
|
|
52
50
|
}
|
|
53
51
|
});
|
|
54
52
|
return importNVuePagesCode.join('\n');
|
package/dist/json/mp/index.d.ts
CHANGED
|
@@ -2,5 +2,3 @@ export * from './jsonFile';
|
|
|
2
2
|
export { AppJson, ComponentJson, MiniProgramComponentsType } from './types';
|
|
3
3
|
export { mergeMiniProgramAppJson, parseMiniProgramPagesJson } from './pages';
|
|
4
4
|
export { parseMiniProgramProjectJson } from './project';
|
|
5
|
-
export { MP_INDEPENDENT_ROOT_QUERY, MP_INDEPENDENT_MAIN_PREFIX, MP_INDEPENDENT_VIRTUAL_ROOT_QUERY, formatIndependentVirtualId, getIndependentRootByFilename, getIndependentRoots, getIndependentSubPackages, hasIndependentRoot, isAppPagesJson, isInIndependentRoot, normalizeIndependentRoot, parseIndependentMainRoot, parseIndependentRoot, parseIndependentSubPackages, parseIndependentVirtualRoot, resolveIndependentRoot, setIndependentSubPackages, stringifyIndependentRoots, withIndependentRoot, withIndependentRootIfNeeded, withoutIndependentRoot, } from './subpackage';
|
|
6
|
-
export type { IndependentSubPackage } from './subpackage';
|
package/dist/json/mp/index.js
CHANGED
|
@@ -14,32 +14,10 @@ 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.parseMiniProgramProjectJson = exports.parseMiniProgramPagesJson = exports.mergeMiniProgramAppJson = void 0;
|
|
18
18
|
__exportStar(require("./jsonFile"), exports);
|
|
19
19
|
var pages_1 = require("./pages");
|
|
20
20
|
Object.defineProperty(exports, "mergeMiniProgramAppJson", { enumerable: true, get: function () { return pages_1.mergeMiniProgramAppJson; } });
|
|
21
21
|
Object.defineProperty(exports, "parseMiniProgramPagesJson", { enumerable: true, get: function () { return pages_1.parseMiniProgramPagesJson; } });
|
|
22
22
|
var project_1 = require("./project");
|
|
23
23
|
Object.defineProperty(exports, "parseMiniProgramProjectJson", { enumerable: true, get: function () { return project_1.parseMiniProgramProjectJson; } });
|
|
24
|
-
var subpackage_1 = require("./subpackage");
|
|
25
|
-
Object.defineProperty(exports, "MP_INDEPENDENT_ROOT_QUERY", { enumerable: true, get: function () { return subpackage_1.MP_INDEPENDENT_ROOT_QUERY; } });
|
|
26
|
-
Object.defineProperty(exports, "MP_INDEPENDENT_MAIN_PREFIX", { enumerable: true, get: function () { return subpackage_1.MP_INDEPENDENT_MAIN_PREFIX; } });
|
|
27
|
-
Object.defineProperty(exports, "MP_INDEPENDENT_VIRTUAL_ROOT_QUERY", { enumerable: true, get: function () { return subpackage_1.MP_INDEPENDENT_VIRTUAL_ROOT_QUERY; } });
|
|
28
|
-
Object.defineProperty(exports, "formatIndependentVirtualId", { enumerable: true, get: function () { return subpackage_1.formatIndependentVirtualId; } });
|
|
29
|
-
Object.defineProperty(exports, "getIndependentRootByFilename", { enumerable: true, get: function () { return subpackage_1.getIndependentRootByFilename; } });
|
|
30
|
-
Object.defineProperty(exports, "getIndependentRoots", { enumerable: true, get: function () { return subpackage_1.getIndependentRoots; } });
|
|
31
|
-
Object.defineProperty(exports, "getIndependentSubPackages", { enumerable: true, get: function () { return subpackage_1.getIndependentSubPackages; } });
|
|
32
|
-
Object.defineProperty(exports, "hasIndependentRoot", { enumerable: true, get: function () { return subpackage_1.hasIndependentRoot; } });
|
|
33
|
-
Object.defineProperty(exports, "isAppPagesJson", { enumerable: true, get: function () { return subpackage_1.isAppPagesJson; } });
|
|
34
|
-
Object.defineProperty(exports, "isInIndependentRoot", { enumerable: true, get: function () { return subpackage_1.isInIndependentRoot; } });
|
|
35
|
-
Object.defineProperty(exports, "normalizeIndependentRoot", { enumerable: true, get: function () { return subpackage_1.normalizeIndependentRoot; } });
|
|
36
|
-
Object.defineProperty(exports, "parseIndependentMainRoot", { enumerable: true, get: function () { return subpackage_1.parseIndependentMainRoot; } });
|
|
37
|
-
Object.defineProperty(exports, "parseIndependentRoot", { enumerable: true, get: function () { return subpackage_1.parseIndependentRoot; } });
|
|
38
|
-
Object.defineProperty(exports, "parseIndependentSubPackages", { enumerable: true, get: function () { return subpackage_1.parseIndependentSubPackages; } });
|
|
39
|
-
Object.defineProperty(exports, "parseIndependentVirtualRoot", { enumerable: true, get: function () { return subpackage_1.parseIndependentVirtualRoot; } });
|
|
40
|
-
Object.defineProperty(exports, "resolveIndependentRoot", { enumerable: true, get: function () { return subpackage_1.resolveIndependentRoot; } });
|
|
41
|
-
Object.defineProperty(exports, "setIndependentSubPackages", { enumerable: true, get: function () { return subpackage_1.setIndependentSubPackages; } });
|
|
42
|
-
Object.defineProperty(exports, "stringifyIndependentRoots", { enumerable: true, get: function () { return subpackage_1.stringifyIndependentRoots; } });
|
|
43
|
-
Object.defineProperty(exports, "withIndependentRoot", { enumerable: true, get: function () { return subpackage_1.withIndependentRoot; } });
|
|
44
|
-
Object.defineProperty(exports, "withIndependentRootIfNeeded", { enumerable: true, get: function () { return subpackage_1.withIndependentRootIfNeeded; } });
|
|
45
|
-
Object.defineProperty(exports, "withoutIndependentRoot", { enumerable: true, get: function () { return subpackage_1.withoutIndependentRoot; } });
|
|
@@ -6,12 +6,11 @@ export declare function getComponentJsonFilenames(): string[];
|
|
|
6
6
|
export declare function findJsonFile(filename: string): Record<string, any> | ComponentJson | PageWindowOptions | undefined;
|
|
7
7
|
export declare function findUsingComponents(filename: string): UsingComponents | undefined;
|
|
8
8
|
export declare function normalizeJsonFilename(filename: string): string;
|
|
9
|
-
export declare function findChangedJsonFiles(supportGlobalUsingComponents?: boolean
|
|
9
|
+
export declare function findChangedJsonFiles(supportGlobalUsingComponents?: boolean): Map<string, string>;
|
|
10
10
|
export declare function addMiniProgramAppJson(appJson: Record<string, any>): void;
|
|
11
11
|
export declare function addMiniProgramPageJson(filename: string, json: PageWindowOptions): void;
|
|
12
12
|
export declare function addMiniProgramComponentJson(filename: string, json: ComponentJson): void;
|
|
13
13
|
export declare function addMiniProgramUsingComponents(filename: string, json: UsingComponents): void;
|
|
14
|
-
export declare function resetMiniProgramJsonFiles(): void;
|
|
15
14
|
export declare function isMiniProgramUsingComponent(name: string, options: {
|
|
16
15
|
filename: string;
|
|
17
16
|
inputDir: string;
|
|
@@ -40,5 +39,5 @@ export declare function findMiniProgramUsingComponents({ filename, inputDir, com
|
|
|
40
39
|
* - "demo": "wxcomponents/demo"
|
|
41
40
|
* - [TODO 待确认] "demo": "../wxcomponents/demo"
|
|
42
41
|
*/
|
|
43
|
-
export declare function findUsingComponentsJson(pathInpages: string, componentsDir: string
|
|
42
|
+
export declare function findUsingComponentsJson(pathInpages: string, componentsDir: string): Record<any, any>;
|
|
44
43
|
export {};
|
package/dist/json/mp/jsonFile.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.findUsingComponentsJson = exports.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.
|
|
6
|
+
exports.findUsingComponentsJson = exports.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -11,9 +11,7 @@ const utils_1 = require("../../utils");
|
|
|
11
11
|
const resolve_1 = require("../../resolve");
|
|
12
12
|
const utils_2 = require("../../vue/utils");
|
|
13
13
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
14
|
-
const subpackage_1 = require("./subpackage");
|
|
15
14
|
let appJsonCache = {};
|
|
16
|
-
let independentRootsCache = [];
|
|
17
15
|
const jsonFilesCache = new Map();
|
|
18
16
|
const jsonPagesCache = new Map();
|
|
19
17
|
const jsonComponentsCache = new Map();
|
|
@@ -66,12 +64,8 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
|
66
64
|
// app.json mp-baidu 在 win 不支持相对路径。所有平台改用绝对路径
|
|
67
65
|
if (filename !== 'app') {
|
|
68
66
|
let usingComponents = newJson.usingComponents;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
? supportGlobalUsingComponents(filename)
|
|
72
|
-
: supportGlobalUsingComponents;
|
|
73
|
-
// 如果小程序不支持 global 的 usingComponents,或独立分包冷启动不能依赖 app.json
|
|
74
|
-
if (!supportGlobalUsingComponentsForFile || independentRoot) {
|
|
67
|
+
// 如果小程序不支持 global 的 usingComponents
|
|
68
|
+
if (!supportGlobalUsingComponents) {
|
|
75
69
|
// 从取全局的 usingComponents 并补充到子组件 usingComponents 中
|
|
76
70
|
const globalUsingComponents = appJsonCache?.usingComponents || {};
|
|
77
71
|
const globalComponents = findUsingComponents('app') || {};
|
|
@@ -81,9 +75,6 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
|
81
75
|
...newJson.usingComponents,
|
|
82
76
|
};
|
|
83
77
|
}
|
|
84
|
-
if (independentRoot) {
|
|
85
|
-
validateIndependentUsingComponents(filename, independentRoot, usingComponents);
|
|
86
|
-
}
|
|
87
78
|
Object.keys(usingComponents).forEach((name) => {
|
|
88
79
|
const componentFilename = usingComponents[name];
|
|
89
80
|
if (componentFilename.startsWith('/')) {
|
|
@@ -111,40 +102,8 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
|
111
102
|
return changedJsonFiles;
|
|
112
103
|
}
|
|
113
104
|
exports.findChangedJsonFiles = findChangedJsonFiles;
|
|
114
|
-
function findIndependentRoot(filename, independentRoots) {
|
|
115
|
-
return independentRoots.find((root) => {
|
|
116
|
-
return filename === root || filename.startsWith(root + '/');
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
function validateIndependentUsingComponents(filename, root, usingComponents) {
|
|
120
|
-
Object.keys(usingComponents).forEach((name) => {
|
|
121
|
-
const componentFilename = usingComponents[name];
|
|
122
|
-
if (isLocalUsingComponent(componentFilename) &&
|
|
123
|
-
!isUsingComponentInRoot(componentFilename, root, filename)) {
|
|
124
|
-
throw new Error(`独立分包 "${root}" 不能在 "${filename}" 中使用 root 外组件 "${name}"(${componentFilename}),请移动到 "${root}" 内或改为页面局部组件。`);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
function isUsingComponentInRoot(componentFilename, root, ownerFilename) {
|
|
129
|
-
const filename = normalizeUsingComponentFilename(componentFilename, ownerFilename);
|
|
130
|
-
return filename === root || filename.startsWith(root + '/');
|
|
131
|
-
}
|
|
132
|
-
function normalizeUsingComponentFilename(componentFilename, ownerFilename) {
|
|
133
|
-
if (componentFilename.startsWith('/')) {
|
|
134
|
-
return (0, utils_1.normalizePath)(componentFilename).replace(/^\/+/, '');
|
|
135
|
-
}
|
|
136
|
-
if (componentFilename.startsWith('.')) {
|
|
137
|
-
return (0, utils_1.normalizePath)(path_1.default.join(path_1.default.dirname(ownerFilename), componentFilename));
|
|
138
|
-
}
|
|
139
|
-
return (0, utils_1.normalizePath)(componentFilename);
|
|
140
|
-
}
|
|
141
|
-
function isLocalUsingComponent(componentFilename) {
|
|
142
|
-
return (!/^(?:plugin|dynamicLib|ext):\/\//.test(componentFilename) &&
|
|
143
|
-
!componentFilename.startsWith('weui-miniprogram'));
|
|
144
|
-
}
|
|
145
105
|
function addMiniProgramAppJson(appJson) {
|
|
146
106
|
appJsonCache = appJson;
|
|
147
|
-
independentRootsCache = (0, subpackage_1.parseIndependentSubPackages)(appJson).map(({ root }) => root);
|
|
148
107
|
}
|
|
149
108
|
exports.addMiniProgramAppJson = addMiniProgramAppJson;
|
|
150
109
|
function addMiniProgramPageJson(filename, json) {
|
|
@@ -159,16 +118,6 @@ function addMiniProgramUsingComponents(filename, json) {
|
|
|
159
118
|
jsonUsingComponentsCache.set(filename, json);
|
|
160
119
|
}
|
|
161
120
|
exports.addMiniProgramUsingComponents = addMiniProgramUsingComponents;
|
|
162
|
-
function resetMiniProgramJsonFiles() {
|
|
163
|
-
appJsonCache = {};
|
|
164
|
-
independentRootsCache = [];
|
|
165
|
-
(0, subpackage_1.setIndependentSubPackages)([]);
|
|
166
|
-
jsonFilesCache.clear();
|
|
167
|
-
jsonPagesCache.clear();
|
|
168
|
-
jsonComponentsCache.clear();
|
|
169
|
-
jsonUsingComponentsCache.clear();
|
|
170
|
-
}
|
|
171
|
-
exports.resetMiniProgramJsonFiles = resetMiniProgramJsonFiles;
|
|
172
121
|
function isMiniProgramUsingComponent(name, options) {
|
|
173
122
|
return !!findMiniProgramUsingComponents(options)[name];
|
|
174
123
|
}
|
|
@@ -186,21 +135,20 @@ function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, })
|
|
|
186
135
|
if (globalUsingComponents) {
|
|
187
136
|
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(globalUsingComponents, componentsDir));
|
|
188
137
|
}
|
|
189
|
-
const
|
|
190
|
-
const jsonFile = findJsonFile(ownerFilename);
|
|
138
|
+
const jsonFile = findJsonFile((0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)(filename, inputDir)));
|
|
191
139
|
if (jsonFile) {
|
|
192
140
|
if (jsonFile.usingComponents) {
|
|
193
|
-
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingComponents, componentsDir
|
|
141
|
+
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingComponents, componentsDir));
|
|
194
142
|
}
|
|
195
143
|
// mp-baidu 特有
|
|
196
144
|
if (jsonFile.usingSwanComponents) {
|
|
197
|
-
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingSwanComponents, componentsDir
|
|
145
|
+
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingSwanComponents, componentsDir));
|
|
198
146
|
}
|
|
199
147
|
}
|
|
200
148
|
return miniProgramComponents;
|
|
201
149
|
}
|
|
202
150
|
exports.findMiniProgramUsingComponents = findMiniProgramUsingComponents;
|
|
203
|
-
function findMiniProgramUsingComponent(usingComponents, componentsDir
|
|
151
|
+
function findMiniProgramUsingComponent(usingComponents, componentsDir) {
|
|
204
152
|
return Object.keys(usingComponents).reduce((res, name) => {
|
|
205
153
|
const path = usingComponents[name];
|
|
206
154
|
if (path.includes('plugin://')) {
|
|
@@ -217,8 +165,7 @@ function findMiniProgramUsingComponent(usingComponents, componentsDir, ownerFile
|
|
|
217
165
|
}
|
|
218
166
|
else if (componentsDir &&
|
|
219
167
|
path.includes(componentsDir + '/') &&
|
|
220
|
-
findUsingComponentsJson(path, componentsDir
|
|
221
|
-
'xr-frame') {
|
|
168
|
+
findUsingComponentsJson(path, componentsDir).renderer === 'xr-frame') {
|
|
222
169
|
// mp-weixin & x-frame
|
|
223
170
|
res[name] = 'xr-frame';
|
|
224
171
|
}
|
|
@@ -246,15 +193,17 @@ function findMiniProgramUsingComponent(usingComponents, componentsDir, ownerFile
|
|
|
246
193
|
* - "demo": "wxcomponents/demo"
|
|
247
194
|
* - [TODO 待确认] "demo": "../wxcomponents/demo"
|
|
248
195
|
*/
|
|
249
|
-
function findUsingComponentsJson(pathInpages, componentsDir
|
|
196
|
+
function findUsingComponentsJson(pathInpages, componentsDir) {
|
|
250
197
|
// 兼容test case
|
|
251
198
|
if (!process.env.UNI_INPUT_DIR)
|
|
252
199
|
return {};
|
|
253
|
-
|
|
254
|
-
if (
|
|
200
|
+
let [, dir] = pathInpages.split(componentsDir);
|
|
201
|
+
if (dir === '') {
|
|
255
202
|
console.warn(`${pathInpages} 路径里没有找到对应的 ${componentsDir} 目录`);
|
|
256
203
|
return {};
|
|
257
204
|
}
|
|
205
|
+
dir = '.' + dir;
|
|
206
|
+
const fulldir = path_1.default.resolve(process.env.UNI_INPUT_DIR, componentsDir, dir);
|
|
258
207
|
let jsonPath = fulldir + '.json';
|
|
259
208
|
if (fs_1.default.existsSync(jsonPath)) {
|
|
260
209
|
return require(jsonPath);
|
|
@@ -267,22 +216,3 @@ function findUsingComponentsJson(pathInpages, componentsDir, ownerFilename) {
|
|
|
267
216
|
return {};
|
|
268
217
|
}
|
|
269
218
|
exports.findUsingComponentsJson = findUsingComponentsJson;
|
|
270
|
-
function resolveUsingComponentsDir(pathInpages, componentsDir, ownerFilename) {
|
|
271
|
-
const normalizedPath = (0, utils_1.normalizePath)(pathInpages);
|
|
272
|
-
if (normalizedPath.startsWith('/')) {
|
|
273
|
-
return path_1.default.resolve(process.env.UNI_INPUT_DIR, '.' + normalizedPath);
|
|
274
|
-
}
|
|
275
|
-
if (ownerFilename && normalizedPath.startsWith('.')) {
|
|
276
|
-
return path_1.default.resolve(process.env.UNI_INPUT_DIR, path_1.default.dirname(ownerFilename), normalizedPath);
|
|
277
|
-
}
|
|
278
|
-
const marker = componentsDir + '/';
|
|
279
|
-
const index = normalizedPath.indexOf(marker);
|
|
280
|
-
if (index === -1) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
const dir = normalizedPath.slice(index + componentsDir.length);
|
|
284
|
-
if (!dir) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
return path_1.default.resolve(process.env.UNI_INPUT_DIR, componentsDir, '.' + dir);
|
|
288
|
-
}
|
package/dist/json/mp/pages.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ interface ParsePagesJsonOptions {
|
|
|
3
3
|
debug?: boolean;
|
|
4
4
|
darkmode?: boolean;
|
|
5
5
|
subpackages: boolean;
|
|
6
|
-
independentSubpackages?: boolean;
|
|
7
6
|
windowOptionsMap?: Record<string, string>;
|
|
8
7
|
tabBarOptionsMap?: Record<string, string>;
|
|
9
8
|
tabBarItemOptionsMap?: Record<string, string>;
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -44,7 +44,7 @@ function mergeMiniProgramAppJson(appJson, platformJson = {}, source = {}) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
exports.mergeMiniProgramAppJson = mergeMiniProgramAppJson;
|
|
47
|
-
function parsePagesJson(jsonStr, platform, { debug, darkmode,
|
|
47
|
+
function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, subpackages, windowOptionsMap, tabBarOptionsMap, tabBarItemOptionsMap, } = {
|
|
48
48
|
subpackages: false,
|
|
49
49
|
}) {
|
|
50
50
|
let appJson = {
|
|
@@ -81,11 +81,7 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, independentSubpack
|
|
|
81
81
|
pagesJson.subPackages = pagesJson.subPackages || pagesJson.subpackages;
|
|
82
82
|
if (pagesJson.subPackages) {
|
|
83
83
|
if (subpackages) {
|
|
84
|
-
appJson.subPackages = pagesJson.subPackages.map((
|
|
85
|
-
const { root, pages, ...rest } = subPackage;
|
|
86
|
-
if (!independentSubpackages) {
|
|
87
|
-
delete rest.independent;
|
|
88
|
-
}
|
|
84
|
+
appJson.subPackages = pagesJson.subPackages.map(({ root, pages, ...rest }) => {
|
|
89
85
|
return (0, shared_1.extend)({
|
|
90
86
|
root,
|
|
91
87
|
pages: pages.map((page) => {
|
package/dist/logs/console.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.appendConsoleExpr = exports.restoreConsoleExpr = exports.rewriteConsoleExpr = void 0;
|
|
7
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
-
const x_1 = require("../x");
|
|
10
9
|
function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
|
|
11
10
|
filename = (0, utils_1.normalizePath)(filename);
|
|
12
11
|
const re = /(console\.(log|info|debug|warn|error))\s*\(([^)]+)\)/g;
|
|
@@ -20,9 +19,7 @@ function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
|
|
|
20
19
|
if (s.hasChanged()) {
|
|
21
20
|
return {
|
|
22
21
|
code: s.toString(),
|
|
23
|
-
map: sourceMap
|
|
24
|
-
? s.generateMap({ hires: (0, x_1.shouldUseHighResolutionSourceMap)() })
|
|
25
|
-
: { mappings: '' },
|
|
22
|
+
map: sourceMap ? s.generateMap({ hires: true }) : { mappings: '' },
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
25
|
return { code, map: null };
|
package/dist/messages/en.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ declare const _default: {
|
|
|
15
15
|
readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
|
|
16
16
|
readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
|
|
17
17
|
readonly 'dev.watching.restart.vapor': "DONE Restart required. Switching vapor mode requires restarting to take effect.";
|
|
18
|
-
readonly 'dev.watching.restart.independentSubPackages': "DONE Restart required. Changing independent subpackage roots requires restarting to take effect.";
|
|
19
18
|
readonly 'dev.watching.vapor.render.target': "vapor-render-target in manifest.json was changed to {manifestTarget}, but the running console is still {runtimeTarget}.";
|
|
20
19
|
readonly 'build.failed': "DONE Build failed.";
|
|
21
20
|
readonly 'compiler.build.failed': "Build failed with errors.";
|
package/dist/messages/en.js
CHANGED
|
@@ -17,7 +17,6 @@ exports.default = {
|
|
|
17
17
|
'dev.watching.end.pages': 'DONE Build complete. PAGES:{pages}',
|
|
18
18
|
'dev.watching.end.files': 'DONE Build complete. FILES:{files}',
|
|
19
19
|
'dev.watching.restart.vapor': 'DONE Restart required. Switching vapor mode requires restarting to take effect.',
|
|
20
|
-
'dev.watching.restart.independentSubPackages': 'DONE Restart required. Changing independent subpackage roots requires restarting to take effect.',
|
|
21
20
|
'dev.watching.vapor.render.target': 'vapor-render-target in manifest.json was changed to {manifestTarget}, but the running console is still {runtimeTarget}.',
|
|
22
21
|
'build.failed': 'DONE Build failed.',
|
|
23
22
|
'compiler.build.failed': 'Build failed with errors.',
|
package/dist/messages/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export declare const M: {
|
|
|
15
15
|
readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
|
|
16
16
|
readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
|
|
17
17
|
readonly 'dev.watching.restart.vapor': "DONE Restart required. 切换蒸汽模式需要重新运行才能生效。";
|
|
18
|
-
readonly 'dev.watching.restart.independentSubPackages': "DONE Restart required. 独立分包 root 列表变化需要重新运行才能生效。";
|
|
19
18
|
readonly 'dev.watching.vapor.render.target': "manifest.json 中更改了视图层编译目标为{manifestTarget},但注意运行控制台还是{runtimeTarget}。";
|
|
20
19
|
readonly 'build.failed': "DONE Build failed.";
|
|
21
20
|
readonly 'compiler.build.failed': "编译失败";
|
|
@@ -74,7 +73,6 @@ export declare const M: {
|
|
|
74
73
|
readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
|
|
75
74
|
readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
|
|
76
75
|
readonly 'dev.watching.restart.vapor': "DONE Restart required. Switching vapor mode requires restarting to take effect.";
|
|
77
|
-
readonly 'dev.watching.restart.independentSubPackages': "DONE Restart required. Changing independent subpackage roots requires restarting to take effect.";
|
|
78
76
|
readonly 'dev.watching.vapor.render.target': "vapor-render-target in manifest.json was changed to {manifestTarget}, but the running console is still {runtimeTarget}.";
|
|
79
77
|
readonly 'build.failed': "DONE Build failed.";
|
|
80
78
|
readonly 'compiler.build.failed': "Build failed with errors.";
|
package/dist/messages/zh_CN.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ declare const _default: {
|
|
|
15
15
|
readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
|
|
16
16
|
readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
|
|
17
17
|
readonly 'dev.watching.restart.vapor': "DONE Restart required. 切换蒸汽模式需要重新运行才能生效。";
|
|
18
|
-
readonly 'dev.watching.restart.independentSubPackages': "DONE Restart required. 独立分包 root 列表变化需要重新运行才能生效。";
|
|
19
18
|
readonly 'dev.watching.vapor.render.target': "manifest.json 中更改了视图层编译目标为{manifestTarget},但注意运行控制台还是{runtimeTarget}。";
|
|
20
19
|
readonly 'build.failed': "DONE Build failed.";
|
|
21
20
|
readonly 'compiler.build.failed': "编译失败";
|
package/dist/messages/zh_CN.js
CHANGED
|
@@ -17,7 +17,6 @@ exports.default = {
|
|
|
17
17
|
'dev.watching.end.pages': 'DONE Build complete. PAGES:{pages}',
|
|
18
18
|
'dev.watching.end.files': 'DONE Build complete. FILES:{files}',
|
|
19
19
|
'dev.watching.restart.vapor': 'DONE Restart required. 切换蒸汽模式需要重新运行才能生效。',
|
|
20
|
-
'dev.watching.restart.independentSubPackages': 'DONE Restart required. 独立分包 root 列表变化需要重新运行才能生效。',
|
|
21
20
|
'dev.watching.vapor.render.target': 'manifest.json 中更改了视图层编译目标为{manifestTarget},但注意运行控制台还是{runtimeTarget}。',
|
|
22
21
|
'build.failed': 'DONE Build failed.',
|
|
23
22
|
'compiler.build.failed': '编译失败',
|
|
@@ -10,18 +10,17 @@ interface MainDescriptor {
|
|
|
10
10
|
script: string;
|
|
11
11
|
template: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function parseMainDescriptor(filename: string, ast: Program, resolve: ParseDescriptor['resolve']
|
|
14
|
-
export declare function updateMiniProgramComponentsByScriptFilename(scriptFilename: string, inputDir: string, normalizeComponentName: (name: string) => string
|
|
15
|
-
export declare function updateMiniProgramComponentsByTemplateFilename(templateFilename: string, inputDir: string, normalizeComponentName: (name: string) => string
|
|
16
|
-
export declare function updateMiniProgramGlobalComponents(filename: string, ast: Program, { inputDir, resolve, normalizeComponentName,
|
|
13
|
+
export declare function parseMainDescriptor(filename: string, ast: Program, resolve: ParseDescriptor['resolve']): Promise<MainDescriptor>;
|
|
14
|
+
export declare function updateMiniProgramComponentsByScriptFilename(scriptFilename: string, inputDir: string, normalizeComponentName: (name: string) => string): void;
|
|
15
|
+
export declare function updateMiniProgramComponentsByTemplateFilename(templateFilename: string, inputDir: string, normalizeComponentName: (name: string) => string): void;
|
|
16
|
+
export declare function updateMiniProgramGlobalComponents(filename: string, ast: Program, { inputDir, resolve, normalizeComponentName, }: {
|
|
17
17
|
inputDir: string;
|
|
18
18
|
resolve: ParseDescriptor['resolve'];
|
|
19
19
|
normalizeComponentName: (name: string) => string;
|
|
20
|
-
root?: string;
|
|
21
20
|
}): Promise<{
|
|
22
21
|
imports: ImportDeclaration[];
|
|
23
22
|
}>;
|
|
24
|
-
export declare function updateMiniProgramComponentsByMainFilename(mainFilename: string, inputDir: string, normalizeComponentName: (name: string) => string
|
|
23
|
+
export declare function updateMiniProgramComponentsByMainFilename(mainFilename: string, inputDir: string, normalizeComponentName: (name: string) => string): void;
|
|
25
24
|
export interface TemplateDescriptor {
|
|
26
25
|
bindingComponents: BindingComponents;
|
|
27
26
|
imports: ImportDeclaration[];
|
|
@@ -38,7 +37,6 @@ export declare function parseTemplateDescriptor(filename: string, ast: Program,
|
|
|
38
37
|
interface ParseDescriptor {
|
|
39
38
|
resolve: PluginContext['resolve'];
|
|
40
39
|
isExternal: boolean;
|
|
41
|
-
root?: string;
|
|
42
40
|
}
|
|
43
41
|
export interface ScriptDescriptor extends TemplateDescriptor {
|
|
44
42
|
setupBindingComponents: BindingComponents;
|