miniprogram-ci 1.8.12 → 1.8.35
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/CHANGELOG.md +7 -1
- package/README.md +0 -1
- package/dist/@types/ci/getDevSourceMap.d.ts +1 -1
- package/dist/@types/config.d.ts +1 -1
- package/dist/@types/core/compile/handler/mpjson.d.ts +5 -0
- package/dist/@types/core/worker_thread/childprocess_manager.d.ts +4 -0
- package/dist/@types/core/worker_thread/task/minifywxml.d.ts +26 -1
- package/dist/@types/summer/graph/appgraph.d.ts +3 -1
- package/dist/@types/summer/plugins/minifywxml.d.ts +5 -0
- package/dist/@types/types/miniprogram-json/app.d.ts +3 -0
- package/dist/@types/types/miniprogram-json/page.d.ts +6 -1
- package/dist/@types/utils/babel_plugin_worklet.d.ts +34 -0
- package/dist/@types/utils/locales/locales.d.ts +3 -0
- package/dist/@types/utils/locales/zh.d.ts +3 -0
- package/dist/@types/vendor/code-analyse/index.d.ts +58 -1
- package/dist/ci/getDevSourceMap.js +1 -1
- package/dist/config.js +1 -1
- package/dist/core/compile/game.js +1 -1
- package/dist/core/compile/handler/mpjson.js +1 -1
- package/dist/core/compile/index.js +1 -1
- package/dist/core/compile/mini_program.js +1 -1
- package/dist/core/js/enhance.js +1 -1
- package/dist/core/json/app/checkAppFields.js +1 -1
- package/dist/core/json/app/getAppJSON.js +1 -1
- package/dist/core/json/page/getPageJSON.js +1 -1
- package/dist/core/worker_thread/childprocess_manager.js +1 -1
- package/dist/core/worker_thread/index.js +1 -1
- package/dist/core/worker_thread/task/index.js +1 -1
- package/dist/core/worker_thread/task/minifywxml.js +1 -1
- package/dist/manifest.json +2 -2
- package/dist/summer/ci.js +1 -1
- package/dist/summer/devtool.js +1 -1
- package/dist/summer/graph/appconf.js +1 -1
- package/dist/summer/graph/appgraph.js +1 -1
- package/dist/summer/plugins/enhance.js +1 -1
- package/dist/summer/plugins/index.js +1 -1
- package/dist/summer/plugins/minifywxml.js +1 -0
- package/dist/utils/babel_plugin_worklet.js +3 -0
- package/dist/utils/common.js +1 -1
- package/dist/utils/locales/en.js +1 -1
- package/dist/utils/locales/zh.js +1 -1
- package/dist/vendor/code-analyse/index.js +1 -1
- package/dist/vendor/schema/dist/app.js +30 -1
- package/dist/vendor/schema/dist/ext.js +34 -3
- package/dist/vendor/schema/dist/game.js +1 -1
- package/dist/vendor/schema/dist/page.js +5 -3
- package/dist/vendor/schema/dist/plugin.js +1 -1
- package/dist/vendor/schema/dist/pluginpage.js +1 -1
- package/dist/vendor/schema/dist/projectconfig.js +5 -1
- package/dist/vendor/schema/dist/projectprivateconfig.js +12 -1
- package/dist/vendor/schema/dist/sitemap.js +1 -1
- package/dist/vendor/schema/dist/theme.js +1 -1
- package/package.json +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
## 1.8.35
|
|
2
|
+
- `new` 新增 支持拉取第三方代开发的“授权小程序”的 sourcemap
|
|
3
|
+
## 1.8.25
|
|
4
|
+
- `new` 更新 增强编译支持编译 worklet 函数
|
|
5
|
+
- `fix` 修复 使用编译插件时,也支持 wxml 压缩功能
|
|
6
|
+
## 1.8.18
|
|
7
|
+
- `new` 更新 `analyseCode` 代码依赖分析能力。
|
|
2
8
|
## 1.8.12
|
|
3
9
|
- `new` app.json 配置支持 halfPage
|
|
4
10
|
- `new` 更新 上传时忽略 project.private.config.json 文件
|
package/README.md
CHANGED
|
@@ -4,4 +4,4 @@ export interface IGetDevSourceMapOption {
|
|
|
4
4
|
robot: number;
|
|
5
5
|
sourceMapSavePath: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function getDevSourceMap(options: IGetDevSourceMapOption): Promise<
|
|
7
|
+
export declare function getDevSourceMap(options: IGetDevSourceMapOption): Promise<any>;
|
package/dist/@types/config.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IProject, MiniProgramCI } from '../../../types';
|
|
3
|
+
export declare function addSkylineRendererToComponents(pageJSONResults: {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
}, potantialComponentResults: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
}): void;
|
|
3
8
|
export declare function compileJSON(project: IProject, options: MiniProgramCI.ICompileOptions): Promise<{
|
|
4
9
|
[filePath: string]: Buffer | string;
|
|
5
10
|
}>;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { MiniProgramCI } from '../../types';
|
|
2
|
+
export declare class ChildProcessCrashedError extends Error {
|
|
3
|
+
type: 'ERR_WORKER_OUT_OF_MEMORY';
|
|
4
|
+
constructor(type: 'ERR_WORKER_OUT_OF_MEMORY', message: string);
|
|
5
|
+
}
|
|
2
6
|
declare class TaskManager {
|
|
3
7
|
private _taskQueue;
|
|
4
8
|
private _instance;
|
|
@@ -7,6 +7,25 @@ interface ICompileData {
|
|
|
7
7
|
setting: MiniProgramCI.ICompileSettings;
|
|
8
8
|
code: Buffer;
|
|
9
9
|
}
|
|
10
|
+
declare enum TokenType {
|
|
11
|
+
ATTR = 0,
|
|
12
|
+
STRING1 = 1,
|
|
13
|
+
STRING2 = 2,
|
|
14
|
+
OTHERS = 3
|
|
15
|
+
}
|
|
16
|
+
declare class Token {
|
|
17
|
+
type: TokenType;
|
|
18
|
+
value: string;
|
|
19
|
+
constructor(type: TokenType, value: string);
|
|
20
|
+
}
|
|
21
|
+
declare class Tokenizer {
|
|
22
|
+
constructor(src: string, path: string);
|
|
23
|
+
generateTokens(output: Array<Token>): number;
|
|
24
|
+
private m_pSrc;
|
|
25
|
+
private path;
|
|
26
|
+
private machine;
|
|
27
|
+
}
|
|
28
|
+
declare function generateWXMLFromTokens(tokens: Array<Token>): string;
|
|
10
29
|
declare function minifyWXML(data: ICompileData): Promise<{
|
|
11
30
|
error: null;
|
|
12
31
|
code: string;
|
|
@@ -18,4 +37,10 @@ declare function minifyWXML(data: ICompileData): Promise<{
|
|
|
18
37
|
};
|
|
19
38
|
code?: undefined;
|
|
20
39
|
}>;
|
|
21
|
-
|
|
40
|
+
declare const _default: {
|
|
41
|
+
minifyWXML: typeof minifyWXML;
|
|
42
|
+
Tokenizer: typeof Tokenizer;
|
|
43
|
+
generateWXMLFromTokens: typeof generateWXMLFromTokens;
|
|
44
|
+
Token: typeof Token;
|
|
45
|
+
};
|
|
46
|
+
export = _default;
|
|
@@ -54,6 +54,9 @@ export declare namespace AppJSON {
|
|
|
54
54
|
usingComponents?: {
|
|
55
55
|
[key: string]: string;
|
|
56
56
|
};
|
|
57
|
+
componentPlaceholder?: {
|
|
58
|
+
[key: string]: string;
|
|
59
|
+
};
|
|
57
60
|
tabBar?: ITabBar;
|
|
58
61
|
requiredBackgroundModes?: Array<string>;
|
|
59
62
|
navigateToMiniProgramAppIdList?: Array<string>;
|
|
@@ -13,7 +13,12 @@ export declare namespace PageJSON {
|
|
|
13
13
|
disableSwipeBack?: boolean;
|
|
14
14
|
backgroundColorTop?: string;
|
|
15
15
|
backgroundColorBottom?: string;
|
|
16
|
-
usingComponents?:
|
|
16
|
+
usingComponents?: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
componentPlaceholder?: {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
17
22
|
componentGenerics?: any;
|
|
18
23
|
pageOrientation?: BaseInfo.PageOrientation;
|
|
19
24
|
renderer?: 'skyline' | 'webview';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const template: any;
|
|
2
|
+
declare const generate: any;
|
|
3
|
+
declare const hash: any;
|
|
4
|
+
declare const transformSync: any;
|
|
5
|
+
declare const traverse: any;
|
|
6
|
+
declare const parse: any;
|
|
7
|
+
declare const buildBindFunc: (func: any) => any;
|
|
8
|
+
declare const buildWorkletFunc: (func: any) => any;
|
|
9
|
+
declare const functionArgsToWorkletize: Map<string, number[]>;
|
|
10
|
+
declare const objectHooks: Set<string>;
|
|
11
|
+
declare const globals: Set<string>;
|
|
12
|
+
declare const blacklistedFunctions: Set<string>;
|
|
13
|
+
declare const possibleOptFunction: Set<string>;
|
|
14
|
+
declare class ClosureGenerator {
|
|
15
|
+
constructor();
|
|
16
|
+
mergeAns(oldAns: any, newAns: any): any[];
|
|
17
|
+
findPrefixRec(path: any): any;
|
|
18
|
+
findPrefix(base: any, babelPath: any): any[];
|
|
19
|
+
addPath(base: any, babelPath: any): void;
|
|
20
|
+
generateNodeForBase(t: any, current: any, parent: any): any;
|
|
21
|
+
generate(t: any, variables: any, names: any): any;
|
|
22
|
+
}
|
|
23
|
+
declare function buildWorkletString(t: any, fun: any, closureVariables: any, name: any): any;
|
|
24
|
+
declare function generateWorkletFactory(t: any, fun: any): any;
|
|
25
|
+
declare function removeWorkletDirective(fun: any): undefined;
|
|
26
|
+
declare function makeWorkletName(t: any, fun: any): any;
|
|
27
|
+
declare function makeWorklet(t: any, fun: any, fileName: any): any;
|
|
28
|
+
declare function processWorkletFunction(t: any, fun: any, fileName: any): void;
|
|
29
|
+
declare function processWorkletObjectMethod(t: any, path: any, fileName: any): void;
|
|
30
|
+
declare function processIfWorkletNode(t: any, fun: any, fileName: any): void;
|
|
31
|
+
declare function processWorklets(t: any, path: any, fileName: any): void;
|
|
32
|
+
declare const FUNCTIONLESS_FLAG = 1;
|
|
33
|
+
declare const STATEMENTLESS_FLAG = 2;
|
|
34
|
+
declare function isPossibleOptimization(fun: any): number;
|
|
@@ -13,6 +13,7 @@ declare const _default: {
|
|
|
13
13
|
JSON_SHOULD_NOT_START_WITH: import("./fomatable_string").FormatableString;
|
|
14
14
|
JSON_SHOULD_NOT_CONTAIN: import("./fomatable_string").FormatableString;
|
|
15
15
|
NOT_FOUND: import("./fomatable_string").FormatableString;
|
|
16
|
+
NOT_FOUND_IN_ROOT_DIR: import("./fomatable_string").FormatableString;
|
|
16
17
|
MINIPROGRAM_APP_JSON_NOT_FOUND: import("./fomatable_string").FormatableString;
|
|
17
18
|
PLUGIN_JSON_NOT_FOUND: import("./fomatable_string").FormatableString;
|
|
18
19
|
PLUGIN_PATH_SAME_WITH_MINIPROGRAM: import("./fomatable_string").FormatableString;
|
|
@@ -32,6 +33,8 @@ declare const _default: {
|
|
|
32
33
|
JSON_TABBAR_ICON_EXT: import("./fomatable_string").FormatableString;
|
|
33
34
|
JSON_CONTENT_SHOULD_NOT_BE: import("./fomatable_string").FormatableString;
|
|
34
35
|
JSON_RESOLVE_ALIAS_ILLEGAL: import("./fomatable_string").FormatableString;
|
|
36
|
+
JSON_RESOLVE_ALIAS_INCLUDE_STAR: import("./fomatable_string").FormatableString;
|
|
37
|
+
JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH: import("./fomatable_string").FormatableString;
|
|
35
38
|
APP_JSON_SHOULD_SET_LAZYCODELOADING: import("./fomatable_string").FormatableString;
|
|
36
39
|
PAGE_JSON_SHOULD_SET_DISABLESCROLL_TRUE: import("./fomatable_string").FormatableString;
|
|
37
40
|
PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM: import("./fomatable_string").FormatableString;
|
|
@@ -13,6 +13,7 @@ declare const _default: {
|
|
|
13
13
|
JSON_SHOULD_NOT_START_WITH: FormatableString;
|
|
14
14
|
JSON_SHOULD_NOT_CONTAIN: FormatableString;
|
|
15
15
|
NOT_FOUND: FormatableString;
|
|
16
|
+
NOT_FOUND_IN_ROOT_DIR: FormatableString;
|
|
16
17
|
MINIPROGRAM_APP_JSON_NOT_FOUND: FormatableString;
|
|
17
18
|
PLUGIN_JSON_NOT_FOUND: FormatableString;
|
|
18
19
|
PLUGIN_PATH_SAME_WITH_MINIPROGRAM: FormatableString;
|
|
@@ -32,6 +33,8 @@ declare const _default: {
|
|
|
32
33
|
JSON_TABBAR_ICON_EXT: FormatableString;
|
|
33
34
|
JSON_CONTENT_SHOULD_NOT_BE: FormatableString;
|
|
34
35
|
JSON_RESOLVE_ALIAS_ILLEGAL: FormatableString;
|
|
36
|
+
JSON_RESOLVE_ALIAS_INCLUDE_STAR: FormatableString;
|
|
37
|
+
JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH: FormatableString;
|
|
35
38
|
APP_JSON_SHOULD_SET_LAZYCODELOADING: FormatableString;
|
|
36
39
|
PAGE_JSON_SHOULD_SET_DISABLESCROLL_TRUE: FormatableString;
|
|
37
40
|
PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM: FormatableString;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
/**
|
|
3
2
|
* 根据入口JS文件路径,分析出所有依赖的js文件
|
|
4
3
|
* @public
|
|
@@ -64,6 +63,7 @@ export declare interface AnalyzerPlugin {
|
|
|
64
63
|
onModuleBuildFailed?(module: IModule, cost: number, error: Error): void;
|
|
65
64
|
afterModuleBuild?(module: IModule, cost: number, error: Error | null): void;
|
|
66
65
|
onModuleReuse?(module: IModule): void;
|
|
66
|
+
onModuleReuseFailed?(module: IModule, error: Error): void;
|
|
67
67
|
onModuleSerialize?(module: IModule, data: Record<string, any>): void;
|
|
68
68
|
onSerialize?(data: Record<string, any>): void;
|
|
69
69
|
}
|
|
@@ -141,6 +141,10 @@ export declare class Graph {
|
|
|
141
141
|
|
|
142
142
|
declare class GraphContext {
|
|
143
143
|
fileHelper: IFileHelper;
|
|
144
|
+
resolveAliasConf?: Array<{
|
|
145
|
+
key: string;
|
|
146
|
+
value: string;
|
|
147
|
+
}>;
|
|
144
148
|
es6Parser: {
|
|
145
149
|
isLayaGame: boolean;
|
|
146
150
|
};
|
|
@@ -149,6 +153,8 @@ declare class GraphContext {
|
|
|
149
153
|
};
|
|
150
154
|
constructor(options: GraphOptions);
|
|
151
155
|
private initMiniprogram;
|
|
156
|
+
setResolveAlias(resolveAlias: IAppJSON['resolveAlias']): void;
|
|
157
|
+
resolveJsFromAlias(request: string): string | undefined;
|
|
152
158
|
}
|
|
153
159
|
|
|
154
160
|
declare interface GraphOptions {
|
|
@@ -164,6 +170,31 @@ export declare interface IAnalyseResult {
|
|
|
164
170
|
modules: IModuleSerialize[];
|
|
165
171
|
}
|
|
166
172
|
|
|
173
|
+
declare interface IAppJSON {
|
|
174
|
+
pages?: string[];
|
|
175
|
+
workers?: string;
|
|
176
|
+
subPackages?: ISubpackageItem[];
|
|
177
|
+
subpackages?: ISubpackageItem[];
|
|
178
|
+
usingComponents?: IStringKeyMap;
|
|
179
|
+
plugins?: {
|
|
180
|
+
[alias: string]: IPluginConfig;
|
|
181
|
+
};
|
|
182
|
+
functionalPages?: boolean | {
|
|
183
|
+
independent?: boolean;
|
|
184
|
+
};
|
|
185
|
+
useExtendedLib?: {
|
|
186
|
+
[index: string]: boolean | string;
|
|
187
|
+
};
|
|
188
|
+
sitemapLocation?: string;
|
|
189
|
+
themeLocation?: string;
|
|
190
|
+
tabBar?: {
|
|
191
|
+
custom?: boolean;
|
|
192
|
+
};
|
|
193
|
+
resolveAlias?: {
|
|
194
|
+
[key: string]: string;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
167
198
|
/**
|
|
168
199
|
* @public
|
|
169
200
|
*/
|
|
@@ -206,6 +237,7 @@ export declare interface IFileHelper {
|
|
|
206
237
|
getJSON(filePath: string): Promise<unknown>;
|
|
207
238
|
readdir(dirPath: string): Promise<string[]>;
|
|
208
239
|
watchFileChange(callback: () => void): void;
|
|
240
|
+
getLocalFileString?(filePath: string): Promise<string>;
|
|
209
241
|
}
|
|
210
242
|
|
|
211
243
|
/**
|
|
@@ -222,6 +254,8 @@ export declare interface IModule {
|
|
|
222
254
|
type: ModuleErrorType;
|
|
223
255
|
error: any;
|
|
224
256
|
}>;
|
|
257
|
+
usePlugins?: Set<string>;
|
|
258
|
+
useTags?: Set<string>;
|
|
225
259
|
build(graphContext: GraphContext): Promise<IDep[]>;
|
|
226
260
|
reuse?(graphContext: GraphContext): Promise<void>;
|
|
227
261
|
isValid(): boolean;
|
|
@@ -258,6 +292,12 @@ export declare interface IPackageFile {
|
|
|
258
292
|
subPackage: string | null;
|
|
259
293
|
}
|
|
260
294
|
|
|
295
|
+
declare interface IPluginConfig {
|
|
296
|
+
version: string;
|
|
297
|
+
provider: string;
|
|
298
|
+
export?: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
261
301
|
/**
|
|
262
302
|
* @public
|
|
263
303
|
*/
|
|
@@ -268,6 +308,23 @@ export declare interface IStat {
|
|
|
268
308
|
size?: number;
|
|
269
309
|
}
|
|
270
310
|
|
|
311
|
+
declare interface IStringKeyMap<T = any> {
|
|
312
|
+
[propName: string]: T;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare interface ISubpackageItem {
|
|
316
|
+
name?: string;
|
|
317
|
+
root: string;
|
|
318
|
+
pages: string[];
|
|
319
|
+
plugins: {
|
|
320
|
+
[alias: string]: IPluginConfig;
|
|
321
|
+
};
|
|
322
|
+
independent: boolean;
|
|
323
|
+
useExtendedLib: {
|
|
324
|
+
[index: string]: boolean | string;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
271
328
|
/**
|
|
272
329
|
* @public
|
|
273
330
|
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDevSourceMap=void 0;const tslib_1=require("tslib"),fs_1=(0,tslib_1.__importDefault)(require("fs")),path_1=(0,tslib_1.__importDefault)(require("path")),log_1=(0,tslib_1.__importDefault)(require("../utils/log")),request_1=require("../utils/request"),url_config_1=require("../utils/url_config"),sign_1=require("../utils/sign"),JsZip=require("jszip"),ERR_MSG_PREFIX="download source map failed:";async function
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDevSourceMap=void 0;const tslib_1=require("tslib"),fs_1=(0,tslib_1.__importDefault)(require("fs")),path_1=(0,tslib_1.__importDefault)(require("path")),log_1=(0,tslib_1.__importDefault)(require("../utils/log")),request_1=require("../utils/request"),url_config_1=require("../utils/url_config"),sign_1=require("../utils/sign"),JsZip=require("jszip"),ERR_MSG_PREFIX="download source map failed:";async function getExtAppId(e){let r,t={};try{r=await e.getFile(e.miniprogramRoot,"ext.json"),t=JSON.parse(r.toString("utf-8"))}catch(e){}if(null==t?void 0:t.extEnable)return t.extAppid}async function getDevSourceMap(e){const{project:r,robot:t}=e;let{sourceMapSavePath:o}=e;if(!r){const e="params project is requried";throw log_1.default.error(e),e}if("number"!=typeof t||Math.round(t)>30||Math.round(t)<=0){const e="params robot is invalid";throw log_1.default.error(e),e}if(!o){const e="params sourceMapSavePath is invalid";throw log_1.default.error(e),e}path_1.default.isAbsolute(o)||(o=path_1.default.join(process.cwd(),o));const a=await(0,sign_1.getSignature)(r.privateKey,r.appid),i=await getExtAppId(r),{body:s}=await(0,request_1.request)({url:url_config_1.GET_DEV_SOURCE_MAP,method:"post",gzip:!0,body:JSON.stringify({appid:r.appid,signature:a,robot:t,extAppId:i}),headers:{"content-type":"application/json"}});let l;try{l=JSON.parse(s)}catch(e){const r=ERR_MSG_PREFIX+" resp body is not a valid json";throw log_1.default.error(r),r}if(0!==l.errCode)throw new Error(`request failed, errCode: ${l.errCode}, errMsg: ${l.errMsg}`);const u=l.data;if(!Array.isArray(u.sourcemap_list)){const e=`${ERR_MSG_PREFIX} respData.sourcemap_list, respData: ${JSON.stringify(u)}`;throw log_1.default.error(e),e}const p=u.sourcemap_list,n=new JsZip;try{p.forEach(e=>{n.folder(path_1.default.dirname(e.fullpath)).file(path_1.default.basename(e.fullpath),e.sourcemap)})}catch(e){const r=ERR_MSG_PREFIX+" source map add folder or add file error";throw log_1.default.error(r),r}let c;try{c=await n.generateAsync({type:"nodebuffer"})}catch(e){const r=ERR_MSG_PREFIX+" source map generate zip error";throw log_1.default.error(r),r}try{fs_1.default.writeFileSync(o,c)}catch(e){const r=`${ERR_MSG_PREFIX} save source map to ${o} failed. Error detail: ${JSON.stringify(e)}`;throw log_1.default.error(r),r}return c}exports.getDevSourceMap=getDevSourceMap;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";var COMPILE_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="1.8.
|
|
2
|
+
"use strict";var COMPILE_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="1.8.35",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(_){_.miniProgram="miniProgram",_.miniProgramPlugin="miniProgramPlugin",_.miniGame="miniGame",_.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE=exports.COMPILE_TYPE||(exports.COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}};
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),game_1=(0,tslib_1.__importDefault)(require("../json/game")),projectconfig_1=require("../json/projectconfig"),common_1=require("./common"),taskstatus_1=require("../../utils/taskstatus"),config_1=require("../../config"),common_2=require("../../utils/common"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),white_ext_list_1=require("../../utils/white_ext_list"),uglifyfilenames_1=require("../protect/uglifyfilenames");async function compileGameJSON(e,t){const{onProgressUpdate:
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),game_1=(0,tslib_1.__importDefault)(require("../json/game")),projectconfig_1=require("../json/projectconfig"),common_1=require("./common"),taskstatus_1=require("../../utils/taskstatus"),config_1=require("../../config"),common_2=require("../../utils/common"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),white_ext_list_1=require("../../utils/white_ext_list"),uglifyfilenames_1=require("../protect/uglifyfilenames");async function compileGameJSON(e,t){const{onProgressUpdate:i=(()=>{})}=t,o=new taskstatus_1.TaskStatus("game.json");i(o);const a=await(0,game_1.default)(e);return o.done(),i(o),a}async function compile(e,t){var i;const o=await(0,projectconfig_1.getProjectConfigJSON)(e),a=o.miniprogramRoot||"",{GameWhiteList:s}=await(0,white_ext_list_1.getWhiteExtList)(),n=e.getFileList(a,"").filter(common_1.isNotIgnoredByProjectConfig.bind(null,o,a)).filter(e=>s.has(path_1.default.posix.extname(e))),r=await compileGameJSON(e,t);e.stat(a,"game.js")||(0,common_2.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a,"game.js")),filePath:path_1.default.posix.join(a,"game.js"),code:config_1.FILE_NOT_FOUND});const m=n.filter(e=>".js"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(a,e)),l=await(0,common_1.compileJSFiles)(e,m,a,t),_=n.filter(e=>e!==path_1.default.posix.join(a,"game.json")&&".js"!==path_1.default.posix.extname(e)),c=await(0,common_1.compileOther)(e,_,t),p=await(0,common_1.getUploadProjectConfig)(e,o);let f=Object.assign(Object.assign({},l),c);if(e.type===config_1.COMPILE_TYPE.miniGame){if(p.miniprogramRoot&&"."!==p.miniprogramRoot&&"./"!==p.miniprogramRoot){const t={};for(const i in f)t[path_1.default.posix.relative(e.miniprogramRoot,i)]=f[i];f=t}p.miniprogramRoot="",f["game.json"]=JSON.stringify(r)}else f[path_1.default.posix.join(p.miniprogramRoot||"","game.json")]=JSON.stringify(r);return p.__compileDebugInfo__=t.__compileDebugInfo__||{},f["project.config.json"]=JSON.stringify(p),delete f["project.private.config.json"],e.type===config_1.COMPILE_TYPE.miniGame&&(null===(i=t.setting)||void 0===i?void 0:i.codeProtect)&&(f=await(0,uglifyfilenames_1.uglifyFileNames)(e,f)),f}exports.compile=compile;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileJSON=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),app_1=require("../../json/app"),getExtJSON_1=require("../../json/app/getExtJSON"),common_1=require("../../../utils/common"),getPageJSON_1=require("../../json/page/getPageJSON"),taskstatus_1=require("../../../utils/taskstatus"),projectconfig_1=require("../../json/projectconfig"),common_2=require("../common");
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileJSON=exports.addSkylineRendererToComponents=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),app_1=require("../../json/app"),getExtJSON_1=require("../../json/app/getExtJSON"),common_1=require("../../../utils/common"),getPageJSON_1=require("../../json/page/getPageJSON"),taskstatus_1=require("../../../utils/taskstatus"),projectconfig_1=require("../../json/projectconfig"),common_2=require("../common");function addSkylineRendererToComponents(e,t){const o=new Set,n=new Set;function s(e,t){Object.values(t.usingComponents||{}).forEach(t=>{const s=path_1.default.posix.join(path_1.default.posix.dirname(e),t+".json");o.has(s)||n.add(s)}),Object.values(t.componentGenerics||{}).forEach(t=>{if("object"==typeof t&&"string"==typeof t.default){const s=path_1.default.posix.join(path_1.default.posix.dirname(e),t.default+".json");o.has(s)||n.add(s)}})}for(const t of Object.keys(e)){const o=JSON.parse(e[t]);"skyline"===o.renderer&&s(t,o)}for(;n.size>0;){const e=n.values().next().value;if(n.delete(e),o.add(e),t[e]&&"string"==typeof t[e]){const o=JSON.parse(t[e]);if("webview"===o.renderer)throw new Error(`The component (${e}) is configured with renderer: 'webview', but is used in skyline pages`);o.renderer="skyline",t[e]=JSON.stringify(o),s(e,o)}}}async function compilePageJSON(e,t,o,n){const{onProgressUpdate:s=(()=>{})}=n,a={};for(const n of t){const t=new taskstatus_1.TaskStatus(n);s(t);const i=await(0,getPageJSON_1.getPageJSON)(e,{miniprogramRoot:o,pagePath:n});a[path_1.default.posix.join(o,n+".json")]=JSON.stringify(i),t.done(),s(t)}return a}async function compileJSON(e,t){const{onProgressUpdate:o=(()=>{})}=t,n=await(0,projectconfig_1.getProjectConfigJSON)(e),{miniprogramRoot:s=""}=n;let a=new taskstatus_1.TaskStatus("app.json");o(a);const i=await(0,app_1.getAppJSON)(e);let r;a.done(),o(a);const p=await e.attr();(null==p?void 0:p.platform)&&(a=new taskstatus_1.TaskStatus("ext.json"),o(a),r=await(0,getExtJSON_1.getExtJSON)(e),a.done(),o(a));const c=(0,common_1.getAllPages)(i),l=await compilePageJSON(e,c,s,t),d=new Set(["app.json","ext.json"].concat(c.map(e=>e+".json"))),u=(0,common_1.getAllTargetTypeFilesWithOtherTypeFilesOfSameName)(e,".json",[".wxml",".js"],s).filter(common_2.isNotIgnoredByProjectConfig.bind(null,n,s)).filter(e=>{const t=path_1.default.posix.relative(s,e);return!d.has(t)}).map(e=>path_1.default.posix.relative(s,e).replace(/\.json$/,"")),f=await compilePageJSON(e,u,s,t);u.forEach(e=>d.add(e+".json")),addSkylineRendererToComponents(l,f);const g=e.getFileList(s,".json").filter(common_2.isNotIgnoredByProjectConfig.bind(null,n,s)).filter(e=>{const t=path_1.default.posix.relative(s,e);return!d.has(t)}),m=await(0,common_2.compileOther)(e,g,t),j=Object.assign(Object.assign(Object.assign({[path_1.default.posix.join(s,"app.json")]:JSON.stringify(i)},l),f),m);return r&&(j[path_1.default.posix.join(s,"ext.json")]=JSON.stringify(r)),j}exports.addSkylineRendererToComponents=addSkylineRendererToComponents,exports.compileJSON=compileJSON;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const game_1=require("./game"),mini_program_1=require("./mini_program"),mini_program_plugin_1=require("./mini_program_plugin"),game_plugin_1=require("./game_plugin"),config_1=require("../../config"),reactiveCache_1=require("../json/reactiveCache");async function compile(e,i){const o=(0,reactiveCache_1.tryToGetReactiveProject)(e);return await o.updateProject(),i.__compileDebugInfo__?i.__compileDebugInfo__.ciVersion=config_1.CI_VERSION:i.__compileDebugInfo__={from:"ci",useNewCompileModule:!0,devtoolsVersion:"0",compileSetting:i.setting,ciVersion:config_1.CI_VERSION},process.env.isDevtools&&(e.nameMappingFromDevtools=i.nameMapping||{}),e.type===config_1.COMPILE_TYPE.miniGame?(0,game_1.compile)(e,i):e.type===config_1.COMPILE_TYPE.miniProgramPlugin?(0,mini_program_plugin_1.compile)(e,i):e.type===config_1.COMPILE_TYPE.miniGamePlugin?(0,game_plugin_1.compile)(e,i):(0,mini_program_1.compile)(e,i)}exports.compile=compile;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tslib_1=require("tslib"),game_1=require("./game"),mini_program_1=require("./mini_program"),mini_program_plugin_1=require("./mini_program_plugin"),game_plugin_1=require("./game_plugin"),config_1=require("../../config"),reactiveCache_1=require("../json/reactiveCache"),common_1=require("../../utils/common"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales"));async function checkProjectTypeMatchProjectAttr(e){const i=await e.attr();!i.gameApp||e.type!==config_1.COMPILE_TYPE.miniProgramPlugin&&e.type!==config_1.COMPILE_TYPE.miniProgram||(0,common_1.throwError)({filePath:"",msg:locales_1.default.config.PROJECT_TYPE_ERROR.format(e.type,e.appid,locales_1.default.config.MINI_GAME),code:config_1.PROJECT_TYPE_ERROR}),i.gameApp||e.type!==config_1.COMPILE_TYPE.miniGame&&e.type!==config_1.COMPILE_TYPE.miniGamePlugin||(0,common_1.throwError)({filePath:"",msg:locales_1.default.config.PROJECT_TYPE_ERROR.format(e.type,e.appid,locales_1.default.config.MINI_PROGRAM),code:config_1.PROJECT_TYPE_ERROR})}async function compile(e,i){const o=(0,reactiveCache_1.tryToGetReactiveProject)(e);return await o.updateProject(),i.__compileDebugInfo__?i.__compileDebugInfo__.ciVersion=config_1.CI_VERSION:i.__compileDebugInfo__={from:"ci",useNewCompileModule:!0,devtoolsVersion:"0",compileSetting:i.setting,ciVersion:config_1.CI_VERSION},process.env.isDevtools&&(e.nameMappingFromDevtools=i.nameMapping||{}),await checkProjectTypeMatchProjectAttr(e),e.type===config_1.COMPILE_TYPE.miniGame?(0,game_1.compile)(e,i):e.type===config_1.COMPILE_TYPE.miniProgramPlugin?(0,mini_program_plugin_1.compile)(e,i):e.type===config_1.COMPILE_TYPE.miniGamePlugin?(0,game_plugin_1.compile)(e,i):(0,mini_program_1.compile)(e,i)}exports.compile=compile;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tslib_1=require("tslib"),common_1=require("./common"),mpjson_1=require("./handler/mpjson"),white_ext_list_1=require("../../utils/white_ext_list"),config_1=require("../../config"),
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tslib_1=require("tslib"),common_1=require("./common"),mpjson_1=require("./handler/mpjson"),white_ext_list_1=require("../../utils/white_ext_list"),config_1=require("../../config"),path_1=(0,tslib_1.__importDefault)(require("path")),projectconfig_1=require("../json/projectconfig"),uglifyfilenames_1=require("../protect/uglifyfilenames"),partial_1=require("../analyse/partial"),lodash_1=(0,tslib_1.__importDefault)(require("lodash")),summer=(0,tslib_1.__importStar)(require("../../summer/ci"));async function compile(e,i){var t,o,a,l;const s=await(0,projectconfig_1.getProjectConfigJSON)(e);if(null===(t=s.setting)||void 0===t?void 0:t.useCompilerPlugins)return summer.compile(e,s,i,s.setting.useCompilerPlugins);const r=s.miniprogramRoot||"",{MiniProgramWhiteList:p}=await(0,white_ext_list_1.getWhiteExtList)();let n=e.getFileList(r,"").filter(common_1.isNotIgnoredByProjectConfig.bind(null,s,r)).filter(e=>p.has(path_1.default.posix.extname(e)));if((null===(o=i.compilePages)||void 0===o?void 0:o.length)&&i.analyzer){const e=(0,partial_1.partialGetCodeFiles)(i.analyzer,i.compilePages).map(e=>path_1.default.posix.join(r,e)),t=n.filter(e=>{const i=path_1.default.posix.extname(e);return".js"!==i&&".json"!==i&&".wxss"!==i&&".wxml"!==i});n=t.concat(e)}let c=!1,m=await(0,mpjson_1.compileJSON)(e,i);if((null===(a=i.compilePages)||void 0===a?void 0:a.length)&&i.analyzer){const e=JSON.parse(m[path_1.default.posix.join(r,"app.json")]);e.pages=e.pages.filter(e=>{var t;return null===(t=i.compilePages)||void 0===t?void 0:t.includes(e)}),0===e.pages.length&&(e.pages=["partialcompileplaceholder"],c=!0),e.subPackages&&(e.subPackages.forEach(e=>{e.pages=e.pages.filter(t=>{var o;return null===(o=i.compilePages)||void 0===o?void 0:o.includes(e.root+t)})}),e.subPackages=e.subPackages.filter(e=>e.pages.length>0)),m[path_1.default.posix.join(r,"app.json")]=JSON.stringify(e),m=lodash_1.default.pick(m,Object.keys(m).filter(e=>m[e]instanceof Buffer||n.includes(e)))}const _=n.filter(e=>".js"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(r,e)),u=await(0,common_1.compileJSFiles)(e,_,r,i),f=n.filter(e=>".wxss"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(r,e)),g=await(0,common_1.compileWXSSFiles)(e,f,r,i),d=n.filter(e=>".wxml"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(r,e)),h=await(0,common_1.compileWXMLFiles)(e,d,r,i),j=n.filter(e=>{const i=path_1.default.posix.extname(e);return".js"!==i&&".json"!==i&&".wxss"!==i&&".wxml"!==i}),x=await(0,common_1.compileOther)(e,j,i);let v=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},m),u),x),g),h);if(c&&(v[path_1.default.posix.join(r,"partialcompileplaceholder.js")]||(v[path_1.default.posix.join(r,"partialcompileplaceholder.js")]=""),v[path_1.default.posix.join(r,"partialcompileplaceholder.wxml")]||(v[path_1.default.posix.join(r,"partialcompileplaceholder.wxml")]="")),e.type===config_1.COMPILE_TYPE.miniProgram){if(s.miniprogramRoot&&"."!==s.miniprogramRoot&&"./"!==s.miniprogramRoot){const i={};for(const t in v)i[path_1.default.posix.relative(e.miniprogramRoot,t)]=v[t];v=i}v["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:i.__compileDebugInfo__||{}}),delete v["project.private.config.json"]}else v["project.config.json"]=JSON.stringify({miniprogramRoot:e.miniprogramRoot||"",__compileDebugInfo__:i.__compileDebugInfo__||{}}),delete v["project.private.config.json"];return e.type===config_1.COMPILE_TYPE.miniProgram&&(null===(l=i.setting)||void 0===l?void 0:l.codeProtect)&&(v=await(0,uglifyfilenames_1.uglifyFileNames)(e,v)),v}exports.compile=compile;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/core/js/enhance.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const config_1=require("../../config"),babel_helper_1=require("../../utils/babel_helper"),_transformRuntimeCustom=()=>require("../../utils/babel_transform_plugin"),babel7=()=>require("@babel/core"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),_pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),_presetEnv=()=>require("@babel/preset-env");function getPluginsList(e){const r=[[require("../../utils/babel_transform_plugin")],[require("@babel/plugin-transform-runtime"),{corejs:!1,helpers:!0,regenerator:!e.hasRegenerator,version:"7.12.1"}]].concat((0,babel_helper_1.getCustomPlugins)([]));return r.push([require("@babel/plugin-transform-modules-commonjs"),{allowTopLevelThis:e.disableUseStrict,importInterop:e=>e.startsWith("@babel/runtime/helpers/")?"node":"babel"}]),r}const enhance=e=>{const{code:r,babelRoot:
|
|
1
|
+
"use strict";const config_1=require("../../config"),babel_helper_1=require("../../utils/babel_helper"),_transformRuntimeCustom=()=>require("../../utils/babel_transform_plugin"),_pluginTransformWorklet=()=>require("../../utils/babel_plugin_worklet"),babel7=()=>require("@babel/core"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),_pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),_presetEnv=()=>require("@babel/preset-env");function getPluginsList(e){const r=[[require("../../utils/babel_transform_plugin")],[require("@babel/plugin-transform-runtime"),{corejs:!1,helpers:!0,regenerator:!e.hasRegenerator,version:"7.12.1"}]].concat((0,babel_helper_1.getCustomPlugins)([]));return r.push([require("@babel/plugin-transform-modules-commonjs"),{allowTopLevelThis:e.disableUseStrict,importInterop:e=>e.startsWith("@babel/runtime/helpers/")?"node":"babel"}]),e.supportWorklet&&r.push([require("../../utils/babel_plugin_worklet")]),r}const enhance=e=>{const{code:r,babelRoot:l,filePath:t,inputSourceMap:s}=e,o=r,n=/regeneratorRuntime\.mark/.test(r),i=e.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r),u=o.includes('"worklet"')||o.includes("'worklet'");let a=null;try{a=require("@babel/core").transform(r,{presets:[[require("@babel/preset-env"),{targets:{chrome:53,ios:8},include:["@babel/plugin-transform-computed-properties"]}]],babelrc:!1,plugins:getPluginsList({hasRegenerator:n,disableUseStrict:i,supportWorklet:u}),sourceFileName:t,inputSourceMap:s,sourceMaps:!0,configFile:!1})}catch(e){return{error:{message:`file: ${t}\n ${e.message}`,code:config_1.BABEL_TRANS_JS_ERR}}}let b=(null==a?void 0:a.code)||r;const p=(null==a?void 0:a.map)||s;i&&(b=b.replace(/^"use strict";/,""));const c=(0,babel_helper_1.collectBabelHelpers)(o),{transformCode:m,helpers:g}=(0,babel_helper_1.replaceBabelHelpers)(b,c,t,l);return b=m,{code:b,map:p,helpers:g||[]}};module.exports=enhance;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkResolveAlias=exports.checkRenderer=exports.checkOpenDataContext=exports.getAppJSONVariableDecalearProperty=exports.checkEntranceDeclare=exports.checkComponentPath=exports.checkMainPkgPluginIsInSubPkg=exports.checkMainPkgPageIsInSubpkg=exports.checkTabbarPage=exports.checkEntryPagePath=exports.checkPreloadRule=exports.checkFunctionalPages=exports.checkNavigateToMiniProgramAppIdList=exports.checkPlugins=exports.checkSubpackages=exports.checkSitemapLocation=exports.checkMainPkgPages=exports.checkOpenLocationPagePath=exports.checkWorkers=exports.checkTabbar=exports.checkWindow=exports.checkPageExist=void 0;const tslib_1=require("tslib"),lodash_1=(0,tslib_1.__importDefault)(require("lodash")),config_1=require("../../../config"),common_1=require("../common"),common_2=require("../../../utils/common"),tools_1=require("../../../utils/tools"),path_1=(0,tslib_1.__importDefault)(require("path")),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),projectconfig_1=require("../projectconfig");function checkPageExist(e,o,t){const{miniprogramRoot:a,project:c,filePath:n}=e;c.stat(a,o+".wxml")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".wxml"),code:config_1.FILE_NOT_FOUND,filePath:n}),c.stat(a,o+".js")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".js"),code:config_1.FILE_NOT_FOUND,filePath:n})}function checkWindow(e){const{inputJSON:o,mode:t}=e;let a=""+e.filePath;o.themeLocation&&(a+=` or ${o.themeLocation}["${t}"]`);const c=[],{window:n}=o;n&&(void 0!==n.navigationBarBackgroundColor&&((0,tools_1.isHexColor)(n.navigationBarBackgroundColor)||c.push(`["window"]["navigationBarBackgroundColor"]: "${n.navigationBarBackgroundColor}" is not hexColor`)),void 0!==n.backgroundColor&&((0,tools_1.isHexColor)(n.backgroundColor)||c.push(`["window"]["backgroundColor"]: "${n.backgroundColor}" is not hexColor`)),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:a}))}function checkTabbar(e){const{project:o,miniprogramRoot:t,inputJSON:a,mode:c}=e;let n=""+e.filePath;a.themeLocation&&(n+=` or ${a.themeLocation}["${c}"]`);const{tabBar:r}=a,i=o.attrSync(),{setting:s}=i;if(!r)return;const l=[];r.list.length<s.MinTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_LEAST.format(s.MinTabbarCount),filePath:n}),r.list.length>s.MaxTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_MOST.format(s.MaxTabbarCount),filePath:n});for(let e=0;e<r.list.length;e++){const a=r.list[e],{pagePath:c}=a;if((0,common_2.checkPath)({value:c,tips:`["tabBar"]["list"][${e}]["pagePath"]`,filePath:n}),!c){l.push(locales_1.default.config.JSON_TABBAR_PATH_EMPTY.format(e));continue}c.indexOf("?")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"?")),c.indexOf(".")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"."));const i=r.list.slice(0,e).findIndex(e=>e.pagePath===c);i>=0&&l.push(locales_1.default.config.JSON_TABBAR_PATH_SAME_WITH_OTHER.format(e,i));const h=[];a.iconPath&&((0,common_2.checkPath)({value:a.iconPath,tips:`["tabBar"]["list"][${e}]["iconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),h.push({name:"iconPath",path:a.iconPath})),a.selectedIconPath&&((0,common_2.checkPath)({value:a.selectedIconPath,tips:`["tabBar"]["list"][${e}]["selectedIconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),h.push({name:"selectedIconPath",path:a.selectedIconPath})),h.forEach(a=>{const c=o.stat(t,a.path);if(!c)return void l.push(locales_1.default.config.NOT_FOUND.format(`["tabBar"]["list"][${e}]["${a.name}"]: "${a.path}"`));if(c.isDirectory)return void l.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["tabBar"]["list"][${e}]["${a.name}"]`,locales_1.default.config.FILE));c.size>1024*s.MaxTabbarIconSize&&l.push(locales_1.default.config.JSON_TABBAR_ICON_MAX_SIZE.format([e,a.name,s.MaxTabbarIconSize]));const n=path_1.default.posix.extname(a.path);config_1.TABBAR_ICON_WHITE_LIST.indexOf(n)<0&&l.push(locales_1.default.config.JSON_TABBAR_ICON_EXT.format([e,a.name,config_1.TABBAR_ICON_WHITE_LIST.join("、")]))})}l.length>0&&(0,common_2.throwError)({msg:l.join("\n"),filePath:n})}function checkWorkers(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e,{workers:n}=c;if(void 0===n)return;const r='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:a}),(0,common_2.checkPath)({value:n,tips:r,filePath:a});const i=o.stat(t,n);i&&i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:a}),c.workers=(0,tools_1.normalizePath)(n+"/")}function checkOpenLocationPagePath(e){const{filePath:o,inputJSON:t}=e,{openLocationPagePath:a}=t;if(void 0===a)return;const c='["openLocationPagePath"]';(0,common_2.checkPath)({value:a,tips:c,filePath:o}),checkPageExist(e,a,c)}exports.checkPageExist=checkPageExist,exports.checkWindow=checkWindow,exports.checkTabbar=checkTabbar,exports.checkWorkers=checkWorkers,exports.checkOpenLocationPagePath=checkOpenLocationPagePath;const checkMainPkgPages=e=>{const{filePath:o,inputJSON:t}=e,{pages:a}=t;if(!a)return;const c={};for(let t=0;t<a.length;t++){const n=a[t],r=`["pages"][${t}]`;(0,common_2.checkPath)({value:n,tips:r,filePath:o}),c[n]&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_PAGES_REPEAT.format(`"${n}"`,'["pages"]'),filePath:o}),c[n]=!0,checkPageExist(e,n,r)}};function checkSitemapLocation(e){const{filePath:o,inputJSON:t}=e,{sitemapLocation:a}=t;if(void 0===a)return;const{project:c,miniprogramRoot:n}=e,r='["sitemapLocation"]';(0,common_2.checkPath)({value:a,tips:r,filePath:o});const i=c.stat(n,a);i&&!i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(r,a),filePath:o});".json"!==path_1.default.posix.extname(a)&&(0,common_2.throwError)({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(r,".json"),filePath:o});const s=c.getFile(n,a),l=(0,common_2.checkUTF8)(s,a),h=(0,common_1.checkJSONFormat)(l,a),f=(0,schemaValidate_1.schemaValidate)("sitemap",h);if(f.error.length){const e=f.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");(0,common_2.throwError)({msg:e,filePath:a})}}function checkSubpackages(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;let n='["subPackages"]';c.subpackages&&(n='["subpackages"]',c.subPackages=c.subpackages,delete c.subpackages);const r=[];if(c.subPackages){const i=o.attrSync(),{setting:s}=i;c.subPackages.length>s.MaxSubPackageLimit&&(0,common_2.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,s.MaxSubPackageLimit]),filePath:a});const l={},h={};for(let i=0;i<c.subPackages.length;i++){const s=c.subPackages[i],f=`${n}[${i}]`;if((0,common_2.checkPath)({value:s.root,tips:`${n}[${i}]["root"]`,filePath:a}),s.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(s.name){if(s.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(h[s.name]){r.push(locales_1.default.config.SAME_ITEM.format(f,h[s.name],"name"));continue}h[s.name]=f}if(s.root=(0,tools_1.normalizePath)(s.root+"/"),l[s.root]){r.push(locales_1.default.config.SAME_ITEM.format(f,l[s.root],"root"));continue}l[s.root]=f;const _=o.stat(t,s.root);if(!_){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}if(!_.isDirectory){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}const p={};for(let o=0,t=s.pages.length;o<t;o++){const t=s.pages[o];(0,common_2.checkPath)({value:t,tips:`${n}[${i}]["pages"][${o}]`,filePath:a});const c=(0,tools_1.normalizePath)(path_1.default.posix.join(s.root,t));p[c]?r.push(locales_1.default.config.JSON_PAGES_REPEAT.format([`"${t}"`,`${n}[${i}]`])):(p[c]=!0,checkPageExist(e,c,`${n}[${i}]["pages"][${o}]`))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a});for(let e=0;e<c.subPackages.length;e++){const o=c.subPackages[e];let t=-1;const a="/"+o.root;c.subPackages.forEach((o,c)=>{if(c!==e&&o.root){const e="/"+o.root;0===a.indexOf(e)&&(t=c)}}),-1===t||r.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`${n}[${t}]["root"]`,`${n}[${e}]["root"]`))}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}}function checkPlugins(e){const{filePath:o,inputJSON:t,project:a}=e,c=[],n=t.plugins||{},r=(0,projectconfig_1.getProjectConfigJSON)(a);function i(e,o){const{appid:t}=a,n=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(n||"dev"!==e.version)if(n)"dev"===e.version&&e.provider!==t&&e.provider!==r.pluginAppid?c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["provider"]',`"${t}"`)):e.provider===t&&"dev"!==e.version&&c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["version"]','"dev"'));else{if("dev"===e.version||"latest"===e.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(e.version)||/^dev-[A-Za-z0-9]+$/.test(e.version))return!0;c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT]))}else c.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(o+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}for(const e in n){i(n[e],`["plugins"]["${e}"]`)}t.subPackages&&t.subPackages.forEach((e,o)=>{if(!e.plugins)return;const t=`["subPackages"][${o}]`;for(const o in e.plugins){i(e.plugins[o],`${t}["plugins"]["${o}"]`)}}),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkNavigateToMiniProgramAppIdList(e){const{filePath:o,inputJSON:t,project:a}=e,c=[];if(t.navigateToMiniProgramAppIdList){const e=a.attrSync(),{appType:o=config_1.APP_TYPE.NORMAL,setting:n}=e;if(o!==config_1.APP_TYPE.NATIVE){const e=null==n?void 0:n.NavigateMiniprogramLimit;t.navigateToMiniProgramAppIdList.length>e&&c.push(locales_1.default.config.EXCEED_LIMIT.format('["navigateToMiniProgramAppIdList"]',e))}}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkFunctionalPages(e){const{inputJSON:o}=e;if(o.functionalPages&&"object"!==(0,tools_1.getType)(o.functionalPages)){const e='["functionalPages"] 配置需要更新,详见文档: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html';o.__warning__?o.__warning__=`${o.__warning__}\n${e}`:o.__warning__=e}}function checkPreloadRule(e,o){const{inputJSON:t,filePath:a}=e,{preloadRule:c,subPackages:n}=t;if(!c||!n)return;const r=[],i={},s={},l={};o.forEach(e=>{i[e.root]=!0,l[e.path]=!0,e.name&&(s[e.name]=!0)});for(const e in c){if(!l[e]&&!e.includes("__plugin__/")){r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]: ${locales_1.default.config.PAGE_PATH}`));continue}const o=c[e];for(let t=0,a=o.packages.length;t<a;t++){let a=o.packages[t];a!==config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT&&(s[a]||(a=(0,tools_1.normalizePath)(a+"/"),i[a]||r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]["packages"][${t}]: ${a}`))))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}function checkEntryPagePath(e,o){const{inputJSON:t,filePath:a}=e,{entryPagePath:c}=t;if(!c)return;(0,common_2.checkPath)({value:c,tips:'["entryPagePath"]',filePath:a});let n=!1;for(const e of o)if(e.path===c){n=!0;break}n||(0,common_2.throwError)({msg:locales_1.default.config.JSON_ENTRY_PAGE_PATH_NOT_FOUND.format(["pages、subPackages","entryPagePath"]),filePath:a})}function checkTabbarPage(e){const{filePath:o,inputJSON:t}=e,{tabBar:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.list.length;e++){const o=a.list[e],{pagePath:t}=o;c.indexOf(t)<0&&n.push(`["tabBar"][${e}]["pagePath"]: "${t}" need in ["pages"]`)}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPageIsInSubpkg(e){const{filePath:o,inputJSON:t}=e,{subPackages:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.length;e++){const o=a[e];for(let t=0;t<c.length;t++){const a=c[t];0===a.indexOf(o.root)&&n.push(locales_1.default.config.SHOULD_NOT_IN.format([`["pages"][${t}]: "${a}"`,`["subPackages"][${e}]`]))}}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPluginIsInSubPkg(e){const{filePath:o,inputJSON:t}=e,{plugins:a={},subPackages:c}=t,n={},r={},i=[];for(const e in a){const o=a[e],t=`["plugins"]["${e}"]`;n[o.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${e}"]`,n[o.provider].tips,"provider")):n[o.provider]=r[e]={provider:o.provider,version:o.version,alias:e,tips:t}}if(c)for(let e=0;e<c.length;e++){const o=c[e];if(o.plugins)for(const t in o.plugins){const a=`["subPackages"][${e}]["plugins"]`,c=o.plugins[t];n[c.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`${a}["${t}"]`,n[c.provider].tips,"provider")):r[t]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(`${a}["${t}"]`,r[t].tips)):n[c.provider]=r[t]={provider:c.provider,version:c.version,alias:c,tips:a}}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:o})}function checkComponentPath(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:path_1.default.posix.relative(t,a),inputJSON:c})}function checkEntranceDeclare(e){const o=e.inputJSON;if(!o.entranceDeclare||!o.entranceDeclare.locationMessage)return;let t=o.pages||[];o.subpackages&&(t=t.concat(o.subpackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t)),o.subPackages&&(t=t.concat(o.subPackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t));const a=[],c=o.entranceDeclare.locationMessage.path;void 0===c?a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_EMPTY.format([])):t.includes(c)||a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_ERR.format([c||"undefined"])),a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:e.filePath})}function getAppJSONVariableDecalearProperty(e){const{windowPropertWhiteList:o,tabBarPropertyWhiteList:t,tabbarListItemPropertyWhiteList:a}=config_1.jsonVariablePropertyWhiteList;let c=[];return"[object Object]"===Object.prototype.toString.call(e.window)&&(c=c.concat(Object.keys(e.window).filter(e=>o.includes(e)).map(o=>({property:`["window"]["${o}"]`,value:e.window[o]})).filter(e=>e.value.startsWith("@")))),"[object Object]"===Object.prototype.toString.call(e.tabBar)&&(c=c.concat(Object.keys(e.tabBar).filter(e=>t.includes(e)).map(o=>({property:`["tabBar"]["${o}"]`,value:e.tabBar[o]})).filter(e=>e.value.startsWith("@"))),Array.isArray(e.tabBar.list)&&e.tabBar.list.forEach((o,t)=>{c=c.concat(Object.keys(o).filter(e=>a.includes(e)).map(o=>({property:`["tabBar"]["list"][${t}]["${o}"]`,value:e.tabBar.list[t][o]})).filter(e=>e.value.startsWith("@")))})),c}function checkOpenDataContext(e,o){const{project:t,miniprogramRoot:a,filePath:c}=e,{openDataContext:n}=o;if(void 0===n)return;(0,common_2.checkPath)({value:n,tips:'["openDataContext"]',filePath:c});const r=t.stat(a,n);r&&r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:c});const i=path_1.default.posix.join(n,"./index.js"),s=t.stat(a,i);s&&s.isFile||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',i),filePath:c}),o.openDataContext=(0,tools_1.normalizePath)(n+"/")}function checkRenderer(e){const{filePath:o,inputJSON:t}=e,{renderer:a,lazyCodeLoading:c}=t;"skyline"===a&&"requiredComponents"!==c&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format("app.json"),filePath:o})}function checkResolveAlias(e){const{filePath:o,inputJSON:t}=e,{resolveAlias:a}=t;if(a){const e=e=>e.includes("//");for(const t in a)(e(t)||e(a[t]))&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_ILLEGAL.format(t,a[t]),filePath:o})}}exports.checkMainPkgPages=checkMainPkgPages,exports.checkSitemapLocation=checkSitemapLocation,exports.checkSubpackages=checkSubpackages,exports.checkPlugins=checkPlugins,exports.checkNavigateToMiniProgramAppIdList=checkNavigateToMiniProgramAppIdList,exports.checkFunctionalPages=checkFunctionalPages,exports.checkPreloadRule=checkPreloadRule,exports.checkEntryPagePath=checkEntryPagePath,exports.checkTabbarPage=checkTabbarPage,exports.checkMainPkgPageIsInSubpkg=checkMainPkgPageIsInSubpkg,exports.checkMainPkgPluginIsInSubPkg=checkMainPkgPluginIsInSubPkg,exports.checkComponentPath=checkComponentPath,exports.checkEntranceDeclare=checkEntranceDeclare,exports.getAppJSONVariableDecalearProperty=getAppJSONVariableDecalearProperty,exports.checkOpenDataContext=checkOpenDataContext,exports.checkRenderer=checkRenderer,exports.checkResolveAlias=checkResolveAlias;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkResolveAlias=exports.checkRenderer=exports.checkOpenDataContext=exports.getAppJSONVariableDecalearProperty=exports.checkEntranceDeclare=exports.checkComponentPath=exports.checkMainPkgPluginIsInSubPkg=exports.checkMainPkgPageIsInSubpkg=exports.checkTabbarPage=exports.checkEntryPagePath=exports.checkPreloadRule=exports.checkFunctionalPages=exports.checkNavigateToMiniProgramAppIdList=exports.checkPlugins=exports.checkSubpackages=exports.checkSitemapLocation=exports.checkMainPkgPages=exports.checkOpenLocationPagePath=exports.checkWorkers=exports.checkTabbar=exports.checkWindow=exports.checkPageExist=void 0;const tslib_1=require("tslib"),lodash_1=(0,tslib_1.__importDefault)(require("lodash")),config_1=require("../../../config"),common_1=require("../common"),common_2=require("../../../utils/common"),tools_1=require("../../../utils/tools"),path_1=(0,tslib_1.__importDefault)(require("path")),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),projectconfig_1=require("../projectconfig");function checkPageExist(e,o,t){const{miniprogramRoot:a,project:c,filePath:n}=e;c.stat(a,o+".wxml")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".wxml"),code:config_1.FILE_NOT_FOUND,filePath:n}),c.stat(a,o+".js")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".js"),code:config_1.FILE_NOT_FOUND,filePath:n})}function checkWindow(e){const{inputJSON:o,mode:t}=e;let a=""+e.filePath;o.themeLocation&&(a+=` or ${o.themeLocation}["${t}"]`);const c=[],{window:n}=o;n&&(void 0!==n.navigationBarBackgroundColor&&((0,tools_1.isHexColor)(n.navigationBarBackgroundColor)||c.push(`["window"]["navigationBarBackgroundColor"]: "${n.navigationBarBackgroundColor}" is not hexColor`)),void 0!==n.backgroundColor&&((0,tools_1.isHexColor)(n.backgroundColor)||c.push(`["window"]["backgroundColor"]: "${n.backgroundColor}" is not hexColor`)),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:a}))}function checkTabbar(e){const{project:o,miniprogramRoot:t,inputJSON:a,mode:c}=e;let n=""+e.filePath;a.themeLocation&&(n+=` or ${a.themeLocation}["${c}"]`);const{tabBar:r}=a,i=o.attrSync(),{setting:s}=i;if(!r)return;const l=[];r.list.length<s.MinTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_LEAST.format(s.MinTabbarCount),filePath:n}),r.list.length>s.MaxTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_MOST.format(s.MaxTabbarCount),filePath:n});for(let e=0;e<r.list.length;e++){const a=r.list[e],{pagePath:c}=a;if((0,common_2.checkPath)({value:c,tips:`["tabBar"]["list"][${e}]["pagePath"]`,filePath:n}),!c){l.push(locales_1.default.config.JSON_TABBAR_PATH_EMPTY.format(e));continue}c.indexOf("?")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"?")),c.indexOf(".")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"."));const i=r.list.slice(0,e).findIndex(e=>e.pagePath===c);i>=0&&l.push(locales_1.default.config.JSON_TABBAR_PATH_SAME_WITH_OTHER.format(e,i));const h=[];a.iconPath&&((0,common_2.checkPath)({value:a.iconPath,tips:`["tabBar"]["list"][${e}]["iconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),h.push({name:"iconPath",path:a.iconPath})),a.selectedIconPath&&((0,common_2.checkPath)({value:a.selectedIconPath,tips:`["tabBar"]["list"][${e}]["selectedIconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),h.push({name:"selectedIconPath",path:a.selectedIconPath})),h.forEach(a=>{const c=o.stat(t,a.path);if(!c)return void l.push(locales_1.default.config.NOT_FOUND.format(`["tabBar"]["list"][${e}]["${a.name}"]: "${a.path}"`));if(c.isDirectory)return void l.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["tabBar"]["list"][${e}]["${a.name}"]`,locales_1.default.config.FILE));c.size>1024*s.MaxTabbarIconSize&&l.push(locales_1.default.config.JSON_TABBAR_ICON_MAX_SIZE.format([e,a.name,s.MaxTabbarIconSize]));const n=path_1.default.posix.extname(a.path);config_1.TABBAR_ICON_WHITE_LIST.indexOf(n)<0&&l.push(locales_1.default.config.JSON_TABBAR_ICON_EXT.format([e,a.name,config_1.TABBAR_ICON_WHITE_LIST.join("、")]))})}l.length>0&&(0,common_2.throwError)({msg:l.join("\n"),filePath:n})}function checkWorkers(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e,{workers:n}=c;if(void 0===n)return;const r='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:a}),(0,common_2.checkPath)({value:n,tips:r,filePath:a});const i=o.stat(t,n);i&&i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:a}),c.workers=(0,tools_1.normalizePath)(n+"/")}function checkOpenLocationPagePath(e){const{filePath:o,inputJSON:t}=e,{openLocationPagePath:a}=t;if(void 0===a)return;const c='["openLocationPagePath"]';(0,common_2.checkPath)({value:a,tips:c,filePath:o}),checkPageExist(e,a,c)}exports.checkPageExist=checkPageExist,exports.checkWindow=checkWindow,exports.checkTabbar=checkTabbar,exports.checkWorkers=checkWorkers,exports.checkOpenLocationPagePath=checkOpenLocationPagePath;const checkMainPkgPages=e=>{const{filePath:o,inputJSON:t}=e,{pages:a}=t;if(!a)return;const c={};for(let t=0;t<a.length;t++){const n=a[t],r=`["pages"][${t}]`;(0,common_2.checkPath)({value:n,tips:r,filePath:o}),c[n]&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_PAGES_REPEAT.format(`"${n}"`,'["pages"]'),filePath:o}),c[n]=!0,checkPageExist(e,n,r)}};function checkSitemapLocation(e){const{filePath:o,inputJSON:t}=e,{sitemapLocation:a}=t;if(void 0===a)return;const{project:c,miniprogramRoot:n}=e,r='["sitemapLocation"]';(0,common_2.checkPath)({value:a,tips:r,filePath:o});const i=c.stat(n,a);i&&!i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(r,a),filePath:o});".json"!==path_1.default.posix.extname(a)&&(0,common_2.throwError)({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(r,".json"),filePath:o});const s=c.getFile(n,a),l=(0,common_2.checkUTF8)(s,a),h=(0,common_1.checkJSONFormat)(l,a),f=(0,schemaValidate_1.schemaValidate)("sitemap",h);if(f.error.length){const e=f.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");(0,common_2.throwError)({msg:e,filePath:a})}}function checkSubpackages(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;let n='["subPackages"]';c.subpackages&&(n='["subpackages"]',c.subPackages=c.subpackages,delete c.subpackages);const r=[];if(c.subPackages){const i=o.attrSync(),{setting:s}=i;c.subPackages.length>s.MaxSubPackageLimit&&(0,common_2.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,s.MaxSubPackageLimit]),filePath:a});const l={},h={};for(let i=0;i<c.subPackages.length;i++){const s=c.subPackages[i],f=`${n}[${i}]`;if((0,common_2.checkPath)({value:s.root,tips:`${n}[${i}]["root"]`,filePath:a}),s.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(s.name){if(s.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(h[s.name]){r.push(locales_1.default.config.SAME_ITEM.format(f,h[s.name],"name"));continue}h[s.name]=f}if(s.root=(0,tools_1.normalizePath)(s.root+"/"),l[s.root]){r.push(locales_1.default.config.SAME_ITEM.format(f,l[s.root],"root"));continue}l[s.root]=f;const _=o.stat(t,s.root);if(!_){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}if(!_.isDirectory){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}const p={};for(let o=0,t=s.pages.length;o<t;o++){const t=s.pages[o];(0,common_2.checkPath)({value:t,tips:`${n}[${i}]["pages"][${o}]`,filePath:a});const c=(0,tools_1.normalizePath)(path_1.default.posix.join(s.root,t));p[c]?r.push(locales_1.default.config.JSON_PAGES_REPEAT.format([`"${t}"`,`${n}[${i}]`])):(p[c]=!0,checkPageExist(e,c,`${n}[${i}]["pages"][${o}]`))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a});for(let e=0;e<c.subPackages.length;e++){const o=c.subPackages[e];let t=-1;const a="/"+o.root;c.subPackages.forEach((o,c)=>{if(c!==e&&o.root){const e="/"+o.root;0===a.indexOf(e)&&(t=c)}}),-1===t||r.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`${n}[${t}]["root"]`,`${n}[${e}]["root"]`))}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}}function checkPlugins(e){const{filePath:o,inputJSON:t,project:a}=e,c=[],n=t.plugins||{},r=(0,projectconfig_1.getProjectConfigJSON)(a);function i(e,o){const{appid:t}=a,n=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(n||"dev"!==e.version)if(n)"dev"===e.version&&e.provider!==t&&e.provider!==r.pluginAppid?c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["provider"]',`"${t}"`)):e.provider===t&&"dev"!==e.version&&c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["version"]','"dev"'));else{if("dev"===e.version||"latest"===e.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(e.version)||/^dev-[A-Za-z0-9]+$/.test(e.version))return!0;c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT]))}else c.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(o+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}for(const e in n){i(n[e],`["plugins"]["${e}"]`)}t.subPackages&&t.subPackages.forEach((e,o)=>{if(!e.plugins)return;const t=`["subPackages"][${o}]`;for(const o in e.plugins){i(e.plugins[o],`${t}["plugins"]["${o}"]`)}}),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkNavigateToMiniProgramAppIdList(e){const{filePath:o,inputJSON:t,project:a}=e,c=[];if(t.navigateToMiniProgramAppIdList){const e=a.attrSync(),{appType:o=config_1.APP_TYPE.NORMAL,setting:n}=e;if(o!==config_1.APP_TYPE.NATIVE){const e=null==n?void 0:n.NavigateMiniprogramLimit;t.navigateToMiniProgramAppIdList.length>e&&c.push(locales_1.default.config.EXCEED_LIMIT.format('["navigateToMiniProgramAppIdList"]',e))}}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkFunctionalPages(e){const{inputJSON:o}=e;if(o.functionalPages&&"object"!==(0,tools_1.getType)(o.functionalPages)){const e='["functionalPages"] 配置需要更新,详见文档: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html';o.__warning__?o.__warning__=`${o.__warning__}\n${e}`:o.__warning__=e}}function checkPreloadRule(e,o){const{inputJSON:t,filePath:a}=e,{preloadRule:c,subPackages:n}=t;if(!c||!n)return;const r=[],i={},s={},l={};o.forEach(e=>{i[e.root]=!0,l[e.path]=!0,e.name&&(s[e.name]=!0)});for(const e in c){if(!l[e]&&!e.includes("__plugin__/")){r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]: ${locales_1.default.config.PAGE_PATH}`));continue}const o=c[e];for(let t=0,a=o.packages.length;t<a;t++){let a=o.packages[t];a!==config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT&&(s[a]||(a=(0,tools_1.normalizePath)(a+"/"),i[a]||r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]["packages"][${t}]: ${a}`))))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}function checkEntryPagePath(e,o){const{inputJSON:t,filePath:a}=e,{entryPagePath:c}=t;if(!c)return;(0,common_2.checkPath)({value:c,tips:'["entryPagePath"]',filePath:a});let n=!1;for(const e of o)if(e.path===c){n=!0;break}n||(0,common_2.throwError)({msg:locales_1.default.config.JSON_ENTRY_PAGE_PATH_NOT_FOUND.format(["pages、subPackages","entryPagePath"]),filePath:a})}function checkTabbarPage(e){const{filePath:o,inputJSON:t}=e,{tabBar:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.list.length;e++){const o=a.list[e],{pagePath:t}=o;c.indexOf(t)<0&&n.push(`["tabBar"][${e}]["pagePath"]: "${t}" need in ["pages"]`)}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPageIsInSubpkg(e){const{filePath:o,inputJSON:t}=e,{subPackages:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.length;e++){const o=a[e];for(let t=0;t<c.length;t++){const a=c[t];0===a.indexOf(o.root)&&n.push(locales_1.default.config.SHOULD_NOT_IN.format([`["pages"][${t}]: "${a}"`,`["subPackages"][${e}]`]))}}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPluginIsInSubPkg(e){const{filePath:o,inputJSON:t}=e,{plugins:a={},subPackages:c}=t,n={},r={},i=[];for(const e in a){const o=a[e],t=`["plugins"]["${e}"]`;n[o.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${e}"]`,n[o.provider].tips,"provider")):n[o.provider]=r[e]={provider:o.provider,version:o.version,alias:e,tips:t}}if(c)for(let e=0;e<c.length;e++){const o=c[e];if(o.plugins)for(const t in o.plugins){const a=`["subPackages"][${e}]["plugins"]`,c=o.plugins[t];n[c.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`${a}["${t}"]`,n[c.provider].tips,"provider")):r[t]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(`${a}["${t}"]`,r[t].tips)):n[c.provider]=r[t]={provider:c.provider,version:c.version,alias:c,tips:a}}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:o})}function checkComponentPath(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:path_1.default.posix.relative(t,a),inputJSON:c})}function checkEntranceDeclare(e){const o=e.inputJSON;if(!o.entranceDeclare||!o.entranceDeclare.locationMessage)return;let t=o.pages||[];o.subpackages&&(t=t.concat(o.subpackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t)),o.subPackages&&(t=t.concat(o.subPackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t));const a=[],c=o.entranceDeclare.locationMessage.path;void 0===c?a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_EMPTY.format([])):t.includes(c)||a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_ERR.format([c||"undefined"])),a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:e.filePath})}function getAppJSONVariableDecalearProperty(e){const{windowPropertWhiteList:o,tabBarPropertyWhiteList:t,tabbarListItemPropertyWhiteList:a}=config_1.jsonVariablePropertyWhiteList;let c=[];return"[object Object]"===Object.prototype.toString.call(e.window)&&(c=c.concat(Object.keys(e.window).filter(e=>o.includes(e)).map(o=>({property:`["window"]["${o}"]`,value:e.window[o]})).filter(e=>e.value.startsWith("@")))),"[object Object]"===Object.prototype.toString.call(e.tabBar)&&(c=c.concat(Object.keys(e.tabBar).filter(e=>t.includes(e)).map(o=>({property:`["tabBar"]["${o}"]`,value:e.tabBar[o]})).filter(e=>e.value.startsWith("@"))),Array.isArray(e.tabBar.list)&&e.tabBar.list.forEach((o,t)=>{c=c.concat(Object.keys(o).filter(e=>a.includes(e)).map(o=>({property:`["tabBar"]["list"][${t}]["${o}"]`,value:e.tabBar.list[t][o]})).filter(e=>e.value.startsWith("@")))})),c}function checkOpenDataContext(e,o){const{project:t,miniprogramRoot:a,filePath:c}=e,{openDataContext:n}=o;if(void 0===n)return;(0,common_2.checkPath)({value:n,tips:'["openDataContext"]',filePath:c});const r=t.stat(a,n);r&&r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:c});const i=path_1.default.posix.join(n,"./index.js"),s=t.stat(a,i);s&&s.isFile||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',i),filePath:c}),o.openDataContext=(0,tools_1.normalizePath)(n+"/")}function checkRenderer(e){const{filePath:o,inputJSON:t}=e,{renderer:a,lazyCodeLoading:c}=t;"skyline"===a&&"requiredComponents"!==c&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format("app.json"),filePath:o})}function checkResolveAlias(e){const{filePath:o,inputJSON:t}=e,{resolveAlias:a}=t;if(a){const e=e=>e.includes("//");for(const t in a)(e(t)||e(a[t]))&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_ILLEGAL.format(t,a[t]),filePath:o}),a[t].startsWith("./")&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH.format(a[t]),filePath:o}),t.endsWith("/*")&&a[t].endsWith("/*")||(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_INCLUDE_STAR.format(t,a[t]),filePath:o})}}exports.checkMainPkgPages=checkMainPkgPages,exports.checkSitemapLocation=checkSitemapLocation,exports.checkSubpackages=checkSubpackages,exports.checkPlugins=checkPlugins,exports.checkNavigateToMiniProgramAppIdList=checkNavigateToMiniProgramAppIdList,exports.checkFunctionalPages=checkFunctionalPages,exports.checkPreloadRule=checkPreloadRule,exports.checkEntryPagePath=checkEntryPagePath,exports.checkTabbarPage=checkTabbarPage,exports.checkMainPkgPageIsInSubpkg=checkMainPkgPageIsInSubpkg,exports.checkMainPkgPluginIsInSubPkg=checkMainPkgPluginIsInSubPkg,exports.checkComponentPath=checkComponentPath,exports.checkEntranceDeclare=checkEntranceDeclare,exports.getAppJSONVariableDecalearProperty=getAppJSONVariableDecalearProperty,exports.checkOpenDataContext=checkOpenDataContext,exports.checkRenderer=checkRenderer,exports.checkResolveAlias=checkResolveAlias;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAppJSON=exports.getRawAppJSON=exports.checkAppJSON=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),projectconfig_1=require("../projectconfig"),common_1=require("../../../utils/common"),config_1=require("../../../config"),common_2=require("../common"),cache_1=require("../../../utils/cache"),lodash_1=require("lodash"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),theme_1=require("../theme"),reactiveCache_1=require("../reactiveCache"),checkAppFields_1=require("./checkAppFields");function transValidateResult(e){return e.error.map(e=>{if("type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType)return locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]);{const c=""===e.errorProperty?e.requireProperty:`${e.errorProperty}.${e.requireProperty}`;return locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([c])}}).join("\n")}function checkAppJSON(e){const{inputJSON:c}=e;let{filePath:r}=e;const a=(0,theme_1.getThemeLocation)(e.project);if(!a){const e=(0,checkAppFields_1.getAppJSONVariableDecalearProperty)(c);e.length&&(0,common_1.throwError)({msg:'appJSON["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}`).join("\n"),filePath:r})}let o={light:{},dark:{}};a&&(o=(0,theme_1.checkThemeJSON)(e.project,{themeLocation:a}));const t=(0,theme_1.mergeThemeJSONToAppJSON)(o,c),p=(0,checkAppFields_1.getAppJSONVariableDecalearProperty)(t.appJSONLight);p.length&&(0,common_1.throwError)({msg:p.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${a}["light"]`).join("\n"),filePath:r});const i=(0,checkAppFields_1.getAppJSONVariableDecalearProperty)(t.appJSONDark);i.length&&(0,common_1.throwError)({msg:i.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${a}["dark"]`).join("\n"),filePath:r});const n=(0,schemaValidate_1.schemaValidate)("app",t.appJSONLight),l=(0,schemaValidate_1.schemaValidate)("app",t.appJSONDark);if(n.warning&&(c.__warning__=locales_1.default.config.INVALID.format(n.warning)),a&&l.warning&&(c.__warning__=locales_1.default.config.INVALID.format(l.warning)),n.error.length){const e=transValidateResult(n);a&&(r+=` or ${a}["light"]`),(0,common_1.throwError)({msg:e,filePath:r})}if(a&&l.error.length){const e=transValidateResult(l);a&&(r+=` or ${a}["dark"]`),(0,common_1.throwError)({msg:e,filePath:r})}const s=Object.assign(Object.assign({},e),{mode:"light",inputJSON:t.appJSONLight}),h=Object.assign(Object.assign({},e),{mode:"dark",inputJSON:t.appJSONDark});(0,checkAppFields_1.checkMainPkgPages)(e),(0,checkAppFields_1.checkSubpackages)(e),(0,checkAppFields_1.checkTabbar)(s),a&&(0,checkAppFields_1.checkTabbar)(h),(0,checkAppFields_1.checkWorkers)(e),(0,checkAppFields_1.checkFunctionalPages)(e),(0,checkAppFields_1.checkOpenLocationPagePath)(e),(0,checkAppFields_1.checkOpenDataContext)(e,c),(0,checkAppFields_1.checkSitemapLocation)(e),(0,checkAppFields_1.checkPlugins)(e),(0,checkAppFields_1.checkWindow)(s),a&&(0,checkAppFields_1.checkWindow)(h),(0,checkAppFields_1.checkComponentPath)(e);const _=(0,common_1.getAllPagesInfo)(c);return(0,checkAppFields_1.checkEntryPagePath)(e,_),(0,checkAppFields_1.checkPreloadRule)(e,_),(0,checkAppFields_1.checkTabbarPage)(e),(0,checkAppFields_1.checkMainPkgPageIsInSubpkg)(e),(0,checkAppFields_1.checkMainPkgPluginIsInSubPkg)(e),(0,checkAppFields_1.checkEntranceDeclare)(e),(0,checkAppFields_1.checkRenderer)(e),(0,checkAppFields_1.checkResolveAlias)(e),c}exports.checkAppJSON=checkAppJSON,exports.getRawAppJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.RAW_APP_JSON,e=>{const c=(0,projectconfig_1.getProjectConfigJSON)(e),{miniprogramRoot:r=""}=c,a=(0,tools_1.normalizePath)(path_1.default.posix.join(r,"app.json"));e.stat(r,"app.json")||(""===r?(0,common_1.throwError)({msg:locales_1.default.config.
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAppJSON=exports.getRawAppJSON=exports.checkAppJSON=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),projectconfig_1=require("../projectconfig"),common_1=require("../../../utils/common"),config_1=require("../../../config"),common_2=require("../common"),cache_1=require("../../../utils/cache"),lodash_1=require("lodash"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),theme_1=require("../theme"),reactiveCache_1=require("../reactiveCache"),checkAppFields_1=require("./checkAppFields");function transValidateResult(e){return e.error.map(e=>{if("type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType)return locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]);{const c=""===e.errorProperty?e.requireProperty:`${e.errorProperty}.${e.requireProperty}`;return locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([c])}}).join("\n")}function checkAppJSON(e){const{inputJSON:c}=e;let{filePath:r}=e;const a=(0,theme_1.getThemeLocation)(e.project);if(!a){const e=(0,checkAppFields_1.getAppJSONVariableDecalearProperty)(c);e.length&&(0,common_1.throwError)({msg:'appJSON["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}`).join("\n"),filePath:r})}let o={light:{},dark:{}};a&&(o=(0,theme_1.checkThemeJSON)(e.project,{themeLocation:a}));const t=(0,theme_1.mergeThemeJSONToAppJSON)(o,c),p=(0,checkAppFields_1.getAppJSONVariableDecalearProperty)(t.appJSONLight);p.length&&(0,common_1.throwError)({msg:p.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${a}["light"]`).join("\n"),filePath:r});const i=(0,checkAppFields_1.getAppJSONVariableDecalearProperty)(t.appJSONDark);i.length&&(0,common_1.throwError)({msg:i.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${a}["dark"]`).join("\n"),filePath:r});const n=(0,schemaValidate_1.schemaValidate)("app",t.appJSONLight),l=(0,schemaValidate_1.schemaValidate)("app",t.appJSONDark);if(n.warning&&(c.__warning__=locales_1.default.config.INVALID.format(n.warning)),a&&l.warning&&(c.__warning__=locales_1.default.config.INVALID.format(l.warning)),n.error.length){const e=transValidateResult(n);a&&(r+=` or ${a}["light"]`),(0,common_1.throwError)({msg:e,filePath:r})}if(a&&l.error.length){const e=transValidateResult(l);a&&(r+=` or ${a}["dark"]`),(0,common_1.throwError)({msg:e,filePath:r})}const s=Object.assign(Object.assign({},e),{mode:"light",inputJSON:t.appJSONLight}),h=Object.assign(Object.assign({},e),{mode:"dark",inputJSON:t.appJSONDark});(0,checkAppFields_1.checkMainPkgPages)(e),(0,checkAppFields_1.checkSubpackages)(e),(0,checkAppFields_1.checkTabbar)(s),a&&(0,checkAppFields_1.checkTabbar)(h),(0,checkAppFields_1.checkWorkers)(e),(0,checkAppFields_1.checkFunctionalPages)(e),(0,checkAppFields_1.checkOpenLocationPagePath)(e),(0,checkAppFields_1.checkOpenDataContext)(e,c),(0,checkAppFields_1.checkSitemapLocation)(e),(0,checkAppFields_1.checkPlugins)(e),(0,checkAppFields_1.checkWindow)(s),a&&(0,checkAppFields_1.checkWindow)(h),(0,checkAppFields_1.checkComponentPath)(e);const _=(0,common_1.getAllPagesInfo)(c);return(0,checkAppFields_1.checkEntryPagePath)(e,_),(0,checkAppFields_1.checkPreloadRule)(e,_),(0,checkAppFields_1.checkTabbarPage)(e),(0,checkAppFields_1.checkMainPkgPageIsInSubpkg)(e),(0,checkAppFields_1.checkMainPkgPluginIsInSubPkg)(e),(0,checkAppFields_1.checkEntranceDeclare)(e),(0,checkAppFields_1.checkRenderer)(e),(0,checkAppFields_1.checkResolveAlias)(e),c}exports.checkAppJSON=checkAppJSON,exports.getRawAppJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.RAW_APP_JSON,e=>{const c=(0,projectconfig_1.getProjectConfigJSON)(e),{miniprogramRoot:r=""}=c,a=(0,tools_1.normalizePath)(path_1.default.posix.join(r,"app.json"));e.stat(r,"app.json")||(""===r?(0,common_1.throwError)({msg:locales_1.default.config.NOT_FOUND_IN_ROOT_DIR.format(a),code:config_1.FILE_NOT_FOUND,filePath:a}):(0,common_1.throwError)({msg:locales_1.default.config.MINIPROGRAM_APP_JSON_NOT_FOUND.format(r,"app.json"),code:config_1.FILE_NOT_FOUND,filePath:a}));const o=e.getFile(r,"app.json");return(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(o,a),a)}),exports.getAppJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.APP_JSON,e=>{const c=(0,lodash_1.cloneDeep)((0,exports.getRawAppJSON)(e)),r=(0,projectconfig_1.getProjectConfigJSON)(e),{miniprogramRoot:a=""}=r;return checkAppJSON({project:e,miniprogramRoot:a,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(a,"app.json")),inputJSON:c}),c});
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSON=exports.originGetPageJSON=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),lodash_1=require("lodash"),getExtJSON_1=require("../app/getExtJSON"),app_1=require("../app"),tools_1=require("../../../utils/tools"),checkPageJSON_1=require("./checkPageJSON"),common_1=require("../common"),common_2=require("../../../utils/common"),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),spreadUsingComponent=e=>{const{project:t,pagePath:o,inputJSON:n}=e;if(o.includes("miniprogram_npm"))return;const i=(0,app_1.getAppJSON)(t);if((0,common_1.checkPagePathIsInIndependentSubpackage)(i,o))return;const
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSON=exports.originGetPageJSON=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),lodash_1=require("lodash"),getExtJSON_1=require("../app/getExtJSON"),app_1=require("../app"),tools_1=require("../../../utils/tools"),checkPageJSON_1=require("./checkPageJSON"),common_1=require("../common"),common_2=require("../../../utils/common"),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),spreadUsingComponent=e=>{const{project:t,pagePath:o,inputJSON:n}=e;if(o.includes("miniprogram_npm"))return;const i=(0,app_1.getAppJSON)(t);if((0,common_1.checkPagePathIsInIndependentSubpackage)(i,o))return;if(i.componentPlaceholder){n.componentPlaceholder=n.componentPlaceholder||{};for(const e in i.componentPlaceholder)n.componentPlaceholder[e]=n.componentPlaceholder[e]||i.componentPlaceholder[e]}const c=Object.assign({},i.usingComponents);if(0!==Object.keys(c).length){n.usingComponents||(n.usingComponents={});for(const e in c){if(n.usingComponents[e])continue;const t=c[e]||"";if(t.startsWith("/")||t.startsWith("plugin://")){n.usingComponents[e]=t;continue}const i=(0,tools_1.normalizePath)(path_1.default.posix.relative(path_1.default.posix.dirname(o),t));n.usingComponents[e]=i.startsWith(".")?i:"./"+i}}},mergeExtJSON=e=>{var t;const{project:o,inputJSON:n,pagePath:i}=e,c=(0,getExtJSON_1.getExtJSON)(o);(null===(t=null==c?void 0:c.extPages)||void 0===t?void 0:t[i])&&Object.assign(n,c.extPages[i])},checkComponentPath=e=>{const{project:t,miniprogramRoot:o,pagePath:n,inputJSON:i}=e;(0,common_1.checkComponentPath)({project:t,root:o,relativePath:n+".json",inputJSON:i})},checkComponentGenerics=e=>{const{pagePath:t,inputJSON:o}=e,n=t+".json";if(!o.componentGenerics)return;const i=[];for(const e in o.componentGenerics){const t=o.componentGenerics[e],n=(0,tools_1.getType)(t);"boolean"===n||"object"===n?"object"===n&&"string"!==(0,tools_1.getType)(t.default)&&i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]["default"]`,"string"])):i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]`,"boolean/object"]))}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:n})};function checkRenderer(e){const{filePath:t,inputJSON:o}=e,{renderer:n}=o,i=(0,app_1.getAppJSON)(e.project);(0,common_2.getAllPages)(i).includes(e.pagePath)&&("skyline"===n&&"requiredComponents"!==i.lazyCodeLoading&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format(t),filePath:t}),("skyline"===n||"skyline"===i.renderer&&"webview"!==n)&&(o.disableScroll=!0,o.navigationStyle="custom"))}const compilePageJSON=e=>{mergeExtJSON(e),checkComponentGenerics(e),checkComponentPath(e),spreadUsingComponent(e),checkRenderer(e)};function originGetPageJSON(e,t){const{pagePath:o,miniprogramRoot:n=""}=t,i=(0,tools_1.normalizePath)(path_1.default.posix.join(n,o+".json")),c=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(e),r=(0,lodash_1.cloneDeep)(c.getPageJSON("checked",t));return compilePageJSON({project:e,miniprogramRoot:n,inputJSON:r,filePath:i,pagePath:o}),r.usingComponents||(r.usingComponents={}),r}async function getPageJSON(e,t){const o=(0,reactiveCache_1.tryToGetReactiveProject)(e);return(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(o).getPageJSON("compiled",t)}exports.originGetPageJSON=originGetPageJSON,reactiveCache_1.ReactiveJSONCompiler.setOriginCheckPageJSON(checkPageJSON_1.checkPageJSON),reactiveCache_1.ReactiveJSONCompiler.setOriginGetPageJSON(originGetPageJSON),exports.getPageJSON=getPageJSON;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|