@plugin-light/shared 0.0.8

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.
Files changed (43) hide show
  1. package/README.md +23 -0
  2. package/lib/black-list.d.ts +2 -0
  3. package/lib/bundle-analyze.d.ts +2 -0
  4. package/lib/config-project.d.ts +10 -0
  5. package/lib/config.d.ts +42 -0
  6. package/lib/context.d.ts +1 -0
  7. package/lib/core/cross-game-style/config.d.ts +1 -0
  8. package/lib/core/cross-game-style/cross-game-style.d.ts +7 -0
  9. package/lib/core/cross-game-style/index.d.ts +2 -0
  10. package/lib/core/cross-game-style/style-name.d.ts +1 -0
  11. package/lib/core/cross-game-style/types.d.ts +4 -0
  12. package/lib/core/gen-version/gen-version.d.ts +11 -0
  13. package/lib/core/gen-version/index.d.ts +2 -0
  14. package/lib/core/gen-version/types.d.ts +5 -0
  15. package/lib/core/ifdef/index.d.ts +1 -0
  16. package/lib/core/ifdef/types.d.ts +5 -0
  17. package/lib/core/index.d.ts +7 -0
  18. package/lib/core/inject-dynamic-style/helper.d.ts +9 -0
  19. package/lib/core/inject-dynamic-style/index.d.ts +2 -0
  20. package/lib/core/inject-dynamic-style/types.d.ts +4 -0
  21. package/lib/core/node-module-file/find.d.ts +7 -0
  22. package/lib/core/node-module-file/index.d.ts +1 -0
  23. package/lib/core/replace-vue-directive/index.d.ts +1 -0
  24. package/lib/core/replace-vue-directive/replace-vue-directive.d.ts +1 -0
  25. package/lib/core/v-lazy/index.d.ts +2 -0
  26. package/lib/core/v-lazy/types.d.ts +3 -0
  27. package/lib/core/v-lazy/v-lazy.d.ts +2 -0
  28. package/lib/css.d.ts +3 -0
  29. package/lib/deps.d.ts +1 -0
  30. package/lib/find-dependencies.d.ts +1 -0
  31. package/lib/h5.d.ts +1 -0
  32. package/lib/helper.d.ts +8 -0
  33. package/lib/index.d.ts +19 -0
  34. package/lib/index.js +864 -0
  35. package/lib/loader-file.d.ts +2 -0
  36. package/lib/loader-log.d.ts +2 -0
  37. package/lib/platform.d.ts +1 -0
  38. package/lib/project-name.d.ts +2 -0
  39. package/lib/replace-manifest.d.ts +2 -0
  40. package/lib/root.d.ts +1 -0
  41. package/lib/sub-project.d.ts +5 -0
  42. package/lib/uni-env.d.ts +17 -0
  43. package/package.json +27 -0
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ ## 公共包
2
+
3
+ 除 `t-comm` 外,`plugin-light-shared` 是整个工具库中最底层的依赖,业务无需直接引用。
4
+
5
+ ### 如何使用
6
+
7
+ 安装
8
+
9
+ ```bash
10
+ pnpm add @plugin-light/shared -D
11
+ ```
12
+
13
+ 使用
14
+
15
+ ```js
16
+ import { getDeps } from '@plugin-light/shared';
17
+
18
+ getDeps(__dirname);
19
+ ```
20
+
21
+ ### 更新日志
22
+
23
+ [点此查看](./CHANGELOG.md)
@@ -0,0 +1,2 @@
1
+ export type IBlackList = Array<string | RegExp>;
2
+ export declare function isInBlackList(filePath: string, blackList?: IBlackList): boolean;
@@ -0,0 +1,2 @@
1
+ export declare function checkBundleAnalyze(): boolean;
2
+ export declare function checkDebugMode(): boolean;
@@ -0,0 +1,10 @@
1
+ export declare const DEFAULT_TRANSPILE_DEPENDENCIES: string[];
2
+ export declare const DEFAULT_ADAPTER_DIRS: string[];
3
+ export declare const AEGIS_EXTERNAL_SCRIPT_LINK: "https://image-1251917893.file.myqcloud.com/igame/npm/aegis-web/aegis.min.js";
4
+ export declare const UNI_SIMPLE_ROUTER_SCRIPT_LINK: "https://image-1251917893.file.myqcloud.com/igame/npm/uni-simple-router/uni-simple-router-2.0.8-beta-4.js";
5
+ export declare const EXTERNAL_LINK_MAP: {
6
+ AXIOS: "https://image-1251917893.file.myqcloud.com/igame/npm/axios@0.18.0/dist/axios.min.js";
7
+ VUE_LAZY_LOAD: "https://image-1251917893.file.myqcloud.com/igame/npm/vue-lazyload@1.3.3/vue-lazyload.js";
8
+ AEGIS_WEB: "https://image-1251917893.file.myqcloud.com/igame/npm/aegis-web/aegis.min.js";
9
+ UNI_SIMPLE_ROUTER: "https://image-1251917893.file.myqcloud.com/igame/npm/uni-simple-router/uni-simple-router-2.0.8-beta-4.js";
10
+ };
@@ -0,0 +1,42 @@
1
+ export declare const PLATFORM_MAP: {
2
+ readonly MP_WX: "mp-weixin";
3
+ readonly MP_QQ: "mp-qq";
4
+ readonly MP_ALIPAY: "mp-alipay";
5
+ readonly MP_JD: "mp-jd";
6
+ readonly H5: "h5";
7
+ };
8
+ export declare const ALL_PLATFORM = "ALL";
9
+ export declare const PLATFORMS_MP: ("mp-weixin" | "mp-qq")[];
10
+ export declare const PLATFORMS_ALL: ("mp-weixin" | "mp-qq" | "h5")[];
11
+ export declare const HTML_MAP: {
12
+ readonly MP_WX: ".wxml";
13
+ readonly MP_QQ: ".qml";
14
+ readonly MP_ALIPAY: ".axml";
15
+ readonly MP_JD: ".jxml";
16
+ };
17
+ export declare const CSS_MAP: {
18
+ readonly MP_WX: ".wxss";
19
+ readonly MP_QQ: ".qss";
20
+ readonly MP_ALIPAY: ".acss";
21
+ readonly MP_JD: ".jxss";
22
+ };
23
+ export declare const CSS_POSTFIX_MAP: any;
24
+ export declare const CDN_MAP: {
25
+ readonly UNI_SIMPLE_ROUTER_BETA4: "https://image-1251917893.file.myqcloud.com/igame/npm/uni-simple-router/uni-simple-router-2.0.8-beta-4.js";
26
+ readonly UNI_SIMPLE_ROUTER: "https://image-1251917893.file.myqcloud.com/igame/npm/uni-simple-router/uni-simple-router%402.0.8-beta.4-1.js";
27
+ readonly AEGIS_WEB: "https://image-1251917893.file.myqcloud.com/igame/npm/aegis-web/aegis.min.js";
28
+ readonly AEGIS_WEB_V2: "https://image-1251917893.file.myqcloud.com/igame/npm/aegis-web/v2.min.2.3.41.js";
29
+ readonly AXIOS: "https://image-1251917893.file.myqcloud.com/igame/npm/axios@0.18.0/dist/axios.min.js";
30
+ readonly VUE_LAZY_LOAD: "https://image-1251917893.file.myqcloud.com/igame/npm/vue-lazyload@1.3.3/vue-lazyload.js";
31
+ readonly VUE_V2: "https://image-1251917893.file.myqcloud.com/igame/npm/vue%402.6.10/dist/vue.runtime.min.js";
32
+ readonly VUE_V3: "https://image-1251917893.file.myqcloud.com/igame/npm/vue@3.3.6/vue.runtime.global.prod.js";
33
+ readonly VUE_DEMI: "https://image-1251917893.file.myqcloud.com/igame/npm/vue-demi@0.14.6/index.iife.min.js";
34
+ readonly VUE_ROUTER_V3: "https://image-1251917893.file.myqcloud.com/igame/npm/vue-router@3.5.2/dist/vue-router.min.js";
35
+ readonly VUE_ROUTER_V4: "https://image-1251917893.file.myqcloud.com/igame/npm/vue-router@4.2.5/vue-router.global.prod.js";
36
+ readonly VUEX_V3: "https://image-1251917893.file.myqcloud.com/igame/npm/vuex@3.0.1/dist/vuex.min.js";
37
+ readonly VUEX_V4: "https://image-1251917893.cos.ap-guangzhou.myqcloud.com/igame/npm/vuex%404.1.0/vuex.global.prod.js";
38
+ readonly PINIA: "https://image-1251917893.file.myqcloud.com/igame/npm/pinia@2.1.7/pinia.iife.min.js";
39
+ readonly ELEMENT_PLUS: "https://image-1251917893.file.myqcloud.com/igame/npm/element-plus/element-plus%402.7.8.js";
40
+ readonly ELEMENT_PLUS_CSS: "https://image-1251917893.file.myqcloud.com/igame/npm/element-plus/element-plus%402.7.8.css";
41
+ readonly E_MONITOR: "https://image-1251917893.file.myqcloud.com/igame/common/js/emonitor_custom_46f41566.js";
42
+ };
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_CONTEXT_OBJECT: {};
@@ -0,0 +1 @@
1
+ export declare const TIP_STYLE_NAME = "@TIP_STYLE_NAME";
@@ -0,0 +1,7 @@
1
+ import type { ICrossGameStyleOptions } from './types';
2
+ export declare function crossGameStyle({ source, options, dir, removeImport, }: {
3
+ source: string;
4
+ options?: ICrossGameStyleOptions;
5
+ dir: string;
6
+ removeImport?: boolean;
7
+ }): string;
@@ -0,0 +1,2 @@
1
+ export { crossGameStyle } from './cross-game-style';
2
+ export type { ICrossGameStyleOptions } from './types';
@@ -0,0 +1 @@
1
+ export declare function getStyleName(): string;
@@ -0,0 +1,4 @@
1
+ export type ICrossGameStyleOptions = {
2
+ styleName?: string | Array<string>;
3
+ platforms?: Array<string>;
4
+ };
@@ -0,0 +1,11 @@
1
+ import type { IGenVersionOptions } from './types';
2
+ export declare function getVersionCode(versionName?: string): string;
3
+ export declare function getCommitCode(versionName?: string): string;
4
+ export declare function getMpVersionCode(): string;
5
+ export declare function getMpInsertCode(): string;
6
+ export declare function getGenVersionPluginOptions(options: IGenVersionOptions): {
7
+ buildName: string;
8
+ commitName: string;
9
+ delay: number;
10
+ };
11
+ export declare function getWebInsertCode(options: IGenVersionOptions): string;
@@ -0,0 +1,2 @@
1
+ export { getVersionCode, getCommitCode, getMpVersionCode, getMpInsertCode, getGenVersionPluginOptions, getWebInsertCode, } from './gen-version';
2
+ export type { IGenVersionOptions, } from './types';
@@ -0,0 +1,5 @@
1
+ export type IGenVersionOptions = {
2
+ buildName?: string;
3
+ commitName?: string;
4
+ delay?: number;
5
+ };
@@ -0,0 +1 @@
1
+ export type { IIfdefOptions } from './types';
@@ -0,0 +1,5 @@
1
+ export type IIfdefOptions = {
2
+ context?: Record<string, boolean>;
3
+ log?: boolean;
4
+ type: Array<string>;
5
+ };
@@ -0,0 +1,7 @@
1
+ export * from './cross-game-style';
2
+ export * from './gen-version';
3
+ export * from './ifdef';
4
+ export * from './inject-dynamic-style';
5
+ export * from './node-module-file';
6
+ export * from './replace-vue-directive';
7
+ export * from './v-lazy';
@@ -0,0 +1,9 @@
1
+ export declare const BASE_SCSS = "base.scss";
2
+ export declare function getStyleList(dir: string): string[];
3
+ export declare function genInjectContent({ styleList, componentName, topElement, dir, }: {
4
+ styleList: Array<string>;
5
+ componentName: string;
6
+ topElement: string;
7
+ dir?: string;
8
+ }): string;
9
+ export declare function getComponentName(dir: string): string;
@@ -0,0 +1,2 @@
1
+ export { BASE_SCSS, getStyleList, genInjectContent, getComponentName } from './helper';
2
+ export type { IInjectDynamicStyleWebOptions } from './types';
@@ -0,0 +1,4 @@
1
+ export type IInjectDynamicStyleWebOptions = {
2
+ topElement?: string;
3
+ platforms?: Array<string>;
4
+ };
@@ -0,0 +1,7 @@
1
+ export type IFindNodeModuleFile = {
2
+ name: string;
3
+ target: string;
4
+ filePath: string;
5
+ root?: string;
6
+ };
7
+ export declare function findNodeModuleFile({ name, target, filePath, root, }: IFindNodeModuleFile): string[];
@@ -0,0 +1 @@
1
+ export { findNodeModuleFile, type IFindNodeModuleFile } from './find';
@@ -0,0 +1 @@
1
+ export { replaceDirective } from './replace-vue-directive';
@@ -0,0 +1 @@
1
+ export declare function replaceDirective(source: string, list: Array<string>): string;
@@ -0,0 +1,2 @@
1
+ export { vLazyCore } from './v-lazy';
2
+ export type { IVLazyOptions } from './types';
@@ -0,0 +1,3 @@
1
+ export type IVLazyOptions = {
2
+ urlHandler?: string;
3
+ };
@@ -0,0 +1,2 @@
1
+ import type { IVLazyOptions } from './types';
2
+ export declare function vLazyCore(source: string, options?: IVLazyOptions): string;
package/lib/css.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const scssLogger: {
2
+ warn(message: any, options: any): void;
3
+ };
package/lib/deps.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function getDeps(dir: string): string[];
@@ -0,0 +1 @@
1
+ export declare function findDependencies(content: string): string[];
package/lib/h5.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function checkH5(): boolean;
@@ -0,0 +1,8 @@
1
+ export declare const ROOT_NAME = "MAIN";
2
+ export declare function saveJsonToLog(content: any, file: string, needLog?: boolean): void;
3
+ export declare function createLogDir(): void;
4
+ export declare const normalizePath: (path: string) => string;
5
+ export declare function updateAssetSource(assets: Record<string, any>, key: string, source: string): void;
6
+ export declare function removeFirstSlash(key: string): string;
7
+ export declare function parseSetDeps(deps: Record<string, any>): Record<string, any>;
8
+ export declare function getRelativePath(filePath: string): string;
package/lib/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ export * from './core';
2
+ export { isInBlackList, } from './black-list';
3
+ export { checkBundleAnalyze, checkDebugMode, } from './bundle-analyze';
4
+ export { PLATFORM_MAP, ALL_PLATFORM, PLATFORMS_ALL, PLATFORMS_MP, HTML_MAP, CSS_MAP, CSS_POSTFIX_MAP, CDN_MAP, } from './config';
5
+ export { DEFAULT_TRANSPILE_DEPENDENCIES, DEFAULT_ADAPTER_DIRS, AEGIS_EXTERNAL_SCRIPT_LINK, UNI_SIMPLE_ROUTER_SCRIPT_LINK, EXTERNAL_LINK_MAP, } from './config-project';
6
+ export { ROOT_NAME, saveJsonToLog, createLogDir, normalizePath, updateAssetSource, removeFirstSlash, parseSetDeps, getRelativePath, } from './helper';
7
+ export { DEFAULT_CONTEXT_OBJECT, } from './context';
8
+ export { scssLogger, } from './css';
9
+ export { getDeps, } from './deps';
10
+ export { findDependencies, } from './find-dependencies';
11
+ export { checkH5, } from './h5';
12
+ export { getLoaderFile, getLoaderProdFile, } from './loader-file';
13
+ export { saveLoaderLog, recordLoaderLog, } from './loader-log';
14
+ export { getWxmlAndWxssPostfix, } from './platform';
15
+ export { getProjectName, getSubProjectName, } from './project-name';
16
+ export { updateManifest, revertManifest, } from './replace-manifest';
17
+ export { getRootDir, } from './root';
18
+ export { getSubProjectConfig, getSubProjectRoot, } from './sub-project';
19
+ export { getPlatform, getUtsPlatform, getAppPlatform, isH5, isApp, isAppAndroid, isAppIOS, isMp, isMpWeixin, isMpAlipay, isMpBaidu, isMpKuaishou, isMpQQ, isMpToutiao, isQuickapp, isQuickappUnion, isQuickappHuawei, } from './uni-env';
package/lib/index.js ADDED
@@ -0,0 +1,864 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var fs = require('fs');
6
+ var path = require('path');
7
+ var tComm = require('t-comm');
8
+ var path$1 = require('node:path');
9
+ var fs$1 = require('node:fs');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n["default"] = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
32
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
33
+ var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
34
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
35
+
36
+ function getRootDir() {
37
+ return process.cwd();
38
+ }
39
+
40
+ function getAppDir() {
41
+ if (process.env.VUE_APP_DIR) {
42
+ return process.env.VUE_APP_DIR;
43
+ }
44
+ if (process.env.UNI_INPUT_DIR) {
45
+ return process.env.UNI_INPUT_DIR;
46
+ }
47
+ const dir = tComm.readEnvVariable('VUE_APP_DIR', path__namespace.join(getRootDir(), '.env.local'));
48
+ if (dir) {
49
+ return dir;
50
+ }
51
+ return '';
52
+ }
53
+ function getStyleName() {
54
+ const configPath = path__namespace.resolve(getRootDir(), 'src', getAppDir(), 'config.js');
55
+ let config = { styleName: '' };
56
+ if (fs__namespace.existsSync(configPath)) {
57
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
58
+ config = require(configPath);
59
+ }
60
+ const { styleName } = config;
61
+ return styleName;
62
+ }
63
+
64
+ const TIP_STYLE_NAME = '@TIP_STYLE_NAME';
65
+
66
+ function tryRemoveImport(source, removeImport = false) {
67
+ let res = source;
68
+ if (removeImport) {
69
+ res = res.replace(`src="${TIP_STYLE_NAME}"`, '').replace(`src='${TIP_STYLE_NAME}'`, '');
70
+ }
71
+ else {
72
+ res = res.replace(TIP_STYLE_NAME, '');
73
+ }
74
+ return res;
75
+ }
76
+ function crossGameStyle({ source, options, dir, removeImport = false, }) {
77
+ if (!source.includes(TIP_STYLE_NAME)) {
78
+ return source;
79
+ }
80
+ let styleName = '';
81
+ // 使用 env.local 的样式 VUE_APP_DIR = module/ingame-nba,即为 nba
82
+ if (options?.styleName) {
83
+ styleName = options.styleName;
84
+ }
85
+ else if (getStyleName()) {
86
+ styleName = getStyleName();
87
+ }
88
+ if (Array.isArray(styleName)) {
89
+ if (styleName.length > 1) {
90
+ styleName = styleName.filter((item) => {
91
+ const cssAbsolutePath = `${dir}/css/${item}.scss`;
92
+ return fs__namespace.existsSync(cssAbsolutePath);
93
+ });
94
+ if (styleName.length > 1) {
95
+ const styleTags = styleName
96
+ .filter((item) => {
97
+ const cssAbsolutePath = `${dir}/css/${item}.scss`;
98
+ return removeImport ? fs__namespace.existsSync(cssAbsolutePath) : true;
99
+ })
100
+ .map(item => `.${item} {@import './css/${item}.scss';}`);
101
+ const res = tryRemoveImport(source, removeImport);
102
+ return res.replace(/<\/style>/, `</style>${['<style scoped lang="scss">', ...styleTags, '</style>'].join('')}`);
103
+ }
104
+ }
105
+ styleName = styleName[0] || '';
106
+ }
107
+ const cssPath = `./css/${styleName}.scss`;
108
+ const cssAbsolutePath = `${dir}/css/${styleName}.scss`;
109
+ const exist = fs__namespace.existsSync(cssAbsolutePath);
110
+ if (exist) {
111
+ return source.replace(TIP_STYLE_NAME, cssPath);
112
+ }
113
+ return tryRemoveImport(source, removeImport);
114
+ }
115
+
116
+ function parseQuote(str = '') {
117
+ return str.replace(/'/g, '"');
118
+ }
119
+ function getVersionCode(versionName) {
120
+ let author = '';
121
+ let branch = '';
122
+ try {
123
+ author = tComm.getGitAuthor(false) || '';
124
+ branch = tComm.getGitCurBranch() || '';
125
+ }
126
+ catch (err) { }
127
+ const versionInfo = {
128
+ time: tComm.timeStampFormat(Date.now(), 'yyyy-MM-dd hh:mm:ss'),
129
+ author,
130
+ branch,
131
+ netEnv: process.env.NET_ENV || '',
132
+ };
133
+ let code = '';
134
+ if (versionName) {
135
+ code = `
136
+ window.${versionName} = {
137
+ time: '${versionInfo.time}',
138
+ author: '${versionInfo.author}',
139
+ branch: '${versionInfo.branch}',
140
+ netEnv: '${versionInfo.netEnv}',
141
+ }
142
+ `;
143
+ return code;
144
+ }
145
+ code = `
146
+ console.info('[system]', '');
147
+ console.info('[system]', 'Build Time: ${versionInfo.time || ''}');
148
+ console.info('[system]', 'Build Author: ${versionInfo.author || ''}');
149
+ console.info('[system]', 'Build Branch: ${versionInfo.branch || ''}');
150
+ console.info('[system]', 'Build Net Env: ${versionInfo.netEnv || ''}');
151
+ `;
152
+ return code;
153
+ }
154
+ function getCommitCode(versionName) {
155
+ let commitInfo = {};
156
+ try {
157
+ commitInfo = tComm.getGitCommitInfo();
158
+ }
159
+ catch (err) { }
160
+ if (commitInfo.timeStamp) {
161
+ commitInfo.date = tComm.timeStampFormat(commitInfo.timeStamp, 'yyyy-MM-dd hh:mm:ss');
162
+ }
163
+ let code = '';
164
+ if (versionName) {
165
+ code = `
166
+ window.${versionName} = {
167
+ message: '${parseQuote(commitInfo.message)}',
168
+ author: '${commitInfo.author}',
169
+ date: '${commitInfo.date}',
170
+ hash: '${commitInfo.hash}',
171
+ }
172
+ `;
173
+ return code;
174
+ }
175
+ code = `
176
+ console.info('[system]', '');
177
+ console.info('[system]', 'Last Commit Message: ${parseQuote(commitInfo.message) || ''}');
178
+ console.info('[system]', 'Last Commit Author: ${commitInfo.author || ''}');
179
+ console.info('[system]', 'Last Commit Time: ${commitInfo.date || ''}');
180
+ console.info('[system]', 'Last Commit Hash: ${commitInfo.hash || ''}');
181
+ `;
182
+ return code;
183
+ }
184
+ function getMpVersionCode() {
185
+ return `
186
+ var uni = (typeof wx !== 'undefined' && wx)
187
+ || (typeof qq !== 'undefined' && qq)
188
+ || (typeof jd !== 'undefined' && jd)
189
+ || (typeof my !== 'undefined' && my);
190
+
191
+ var miniProgram = uni.getAccountInfoSync().miniProgram || {};
192
+ var systemInfo = uni.getSystemInfoSync() || {};
193
+ var envVersionMap = {
194
+ develop: '开发版',
195
+ trial: '体验版',
196
+ release: '正式版'
197
+ }
198
+ var { envVersion = '', version = '' } = miniProgram;
199
+ var { brand, model, pixelRatio } = systemInfo;
200
+ var versionDesc = \`\${envVersion}(\${envVersionMap[envVersion] || ''})\`;
201
+
202
+ console.info('[system]', '');
203
+ console.info('[system]', \`Env Version:\${envVersion ? versionDesc : ''}\`);
204
+ console.info('[system]', \`Version:\${version}\`);
205
+
206
+ console.info('[system]', '');
207
+ console.info('[system]', \`Brand:\${brand}, \${model}\`);
208
+ console.info('[system]', \`PixelRatio:\${pixelRatio}\`);
209
+ `;
210
+ }
211
+ function getMpInsertCode() {
212
+ const insertCode = `
213
+ try {
214
+ setTimeout(() => {
215
+ ${getVersionCode()}
216
+ ${getCommitCode()}
217
+ ${getMpVersionCode()}
218
+ }, 2000);
219
+ } catch(err) {}
220
+ `;
221
+ return insertCode;
222
+ }
223
+ function getGenVersionPluginOptions(options) {
224
+ const buildName = options?.buildName || '';
225
+ const commitName = options?.commitName || '';
226
+ const delay = options?.delay === undefined ? 10 : options?.delay;
227
+ return {
228
+ buildName,
229
+ commitName,
230
+ delay,
231
+ };
232
+ }
233
+ function getWebInsertCode(options) {
234
+ const { buildName, commitName, delay } = getGenVersionPluginOptions(options || {});
235
+ return `
236
+ <script>
237
+ try {
238
+ setTimeout(() => {
239
+ ${getVersionCode(buildName)}
240
+ ${getCommitCode(commitName)}
241
+ }, ${delay});
242
+ } catch(err) {}
243
+ </script>
244
+ `;
245
+ }
246
+
247
+ const BASE_SCSS = 'base.scss';
248
+ function getStyleList(dir) {
249
+ const cssList = fs__namespace.readdirSync(dir);
250
+ const filtered = cssList
251
+ .filter(item => item.endsWith('scss') && !item.startsWith(BASE_SCSS))
252
+ .map(item => item.replace(/\.scss$/, ''));
253
+ return filtered;
254
+ }
255
+ function genInjectContent({ styleList, componentName, topElement, dir = '', }) {
256
+ const styleStr = styleList.map((item) => `
257
+ &--type-${item} {
258
+ @import './${dir}${item}.scss';
259
+ }`).join('\n');
260
+ return `
261
+ ${topElement}.${componentName} {
262
+ ${styleStr}
263
+ }
264
+ `;
265
+ }
266
+ function getComponentName(dir) {
267
+ const tPath = tComm.normalizePath(dir);
268
+ const reg = /\/([^/]+)\/css/;
269
+ const match = tPath.match(reg);
270
+ return match?.[1] || '';
271
+ }
272
+
273
+ function findNodeModuleFile({ name, target, filePath, root, }) {
274
+ const iRoot = root ?? process.cwd();
275
+ const NODE_MODULES = 'node_modules';
276
+ const PNPM = `${NODE_MODULES}/.pnpm`;
277
+ const nodeModulesTargetFile = path__default["default"].resolve(iRoot, NODE_MODULES, name, filePath);
278
+ const exist = fs__default["default"].existsSync(nodeModulesTargetFile);
279
+ if (exist) {
280
+ return [
281
+ nodeModulesTargetFile,
282
+ ];
283
+ }
284
+ const pnpmRoot = path__default["default"].resolve(iRoot, PNPM);
285
+ if (!fs__default["default"].existsSync(pnpmRoot)) {
286
+ return [];
287
+ }
288
+ const pnpmList = fs__default["default"].readdirSync(pnpmRoot);
289
+ const list = pnpmList.filter(item => item.startsWith(target));
290
+ const innerFileList = list.map((file) => {
291
+ const targetFile = path__default["default"].resolve(`${PNPM}/${file}/node_modules/${name}/${filePath}`);
292
+ return targetFile;
293
+ }).filter(file => fs__default["default"].existsSync(file));
294
+ return innerFileList;
295
+ }
296
+
297
+ function replaceDirective(source, list) {
298
+ if (!list.length)
299
+ return source;
300
+ const reg = new RegExp(`(?<=<[^<]+)v-${list.join('|')}=?[^\\s]*`, 'g');
301
+ const newSource = source.replace(reg, '');
302
+ return newSource;
303
+ }
304
+
305
+ const htmlReg = /(?<=<template>)([\s\S]+)(?=<\/template>)/;
306
+ const imgReg = /(<img[\s\S]+?)v-lazy=(?:"|')(.*?)(?:"|')([\s\S]*?>)/g;
307
+ const sizeReg = /(?<=[\s\n]+(?:data-)?)size=(?:"|')(\d+)(?:"|')/;
308
+ const widthReg = /(?<=[\s\n]+(?:data-)?)width=(?:"|')(\d+)(?:"|')/;
309
+ const heightReg = /(?<=[\s\n]+(?:data-)?)height=(?:"|')(\d+)(?:"|')/;
310
+ function vLazyCore(source, options) {
311
+ const { urlHandler } = options || {};
312
+ let html = '';
313
+ const match = source.match(htmlReg);
314
+ if (match?.[1]) {
315
+ html = match[1];
316
+ }
317
+ if (!html)
318
+ return source;
319
+ if (!html.match(imgReg))
320
+ return source;
321
+ const newHtml = handleImg(html, urlHandler);
322
+ const newSource = source.replace(htmlReg, () => newHtml);
323
+ return newSource;
324
+ }
325
+ function getSize(pre, post, reg) {
326
+ let size = '';
327
+ const preMatch = pre.match(reg);
328
+ const postMatch = post.match(reg);
329
+ if (preMatch?.[1]) {
330
+ size = preMatch[1];
331
+ }
332
+ else if (postMatch?.[1]) {
333
+ size = postMatch[1];
334
+ }
335
+ return size;
336
+ }
337
+ function getImgSrc({ urlHandler, src, size, width, height, }) {
338
+ let srcStr = src;
339
+ if (!urlHandler) {
340
+ return src;
341
+ }
342
+ if (width && height) {
343
+ srcStr = `${urlHandler}(${src}, ${width}, ${height})`;
344
+ }
345
+ else if (size) {
346
+ srcStr = `${urlHandler}(${src}, ${size}, ${size})`;
347
+ }
348
+ else {
349
+ srcStr = `${urlHandler}(${src})`;
350
+ }
351
+ return srcStr;
352
+ }
353
+ function handleImg(str = '', urlHandler = '') {
354
+ const res = str.replace(imgReg, (...args) => {
355
+ const { 1: pre, 2: src, 3: post } = args;
356
+ const size = getSize(pre, post, sizeReg);
357
+ const width = getSize(pre, post, widthReg);
358
+ const height = getSize(pre, post, heightReg);
359
+ const srcStr = getImgSrc({
360
+ urlHandler,
361
+ src,
362
+ size,
363
+ width,
364
+ height,
365
+ });
366
+ const innerRes = `${pre} :src="${srcStr}" lazy-load ${post}`;
367
+ return innerRes;
368
+ });
369
+ return res;
370
+ }
371
+
372
+ function isInBlackList(filePath, blackList) {
373
+ if (!blackList) {
374
+ return false;
375
+ }
376
+ const found = blackList.find((item) => {
377
+ if (typeof item === 'string') {
378
+ return filePath.includes(item);
379
+ }
380
+ return item.test(filePath);
381
+ });
382
+ return !!found;
383
+ }
384
+
385
+ function checkBundleAnalyze() {
386
+ return process.argv.includes('--bundleAnalyzer')
387
+ || !!process.env.npm_config_report;
388
+ }
389
+ function checkDebugMode() {
390
+ return !!process.env.DEBUG_MODE;
391
+ }
392
+
393
+ const PLATFORM_MAP = {
394
+ MP_WX: 'mp-weixin',
395
+ MP_QQ: 'mp-qq',
396
+ MP_ALIPAY: 'mp-alipay',
397
+ MP_JD: 'mp-jd',
398
+ H5: 'h5',
399
+ };
400
+ const ALL_PLATFORM = 'ALL';
401
+ const PLATFORMS_MP = [
402
+ PLATFORM_MAP.MP_WX,
403
+ PLATFORM_MAP.MP_QQ,
404
+ ];
405
+ const PLATFORMS_ALL = [
406
+ PLATFORM_MAP.MP_WX,
407
+ PLATFORM_MAP.MP_QQ,
408
+ PLATFORM_MAP.H5,
409
+ ];
410
+ const HTML_MAP = {
411
+ MP_WX: '.wxml',
412
+ MP_QQ: '.qml',
413
+ MP_ALIPAY: '.axml',
414
+ MP_JD: '.jxml',
415
+ };
416
+ const CSS_MAP = {
417
+ MP_WX: '.wxss',
418
+ MP_QQ: '.qss',
419
+ MP_ALIPAY: '.acss',
420
+ MP_JD: '.jxss',
421
+ };
422
+ const CSS_POSTFIX_MAP = Object.keys(CSS_MAP)
423
+ .reduce((acc, item) => {
424
+ acc[item] = CSS_MAP[item].slice(1);
425
+ return acc;
426
+ }, {});
427
+ const CDN_MAP = {
428
+ UNI_SIMPLE_ROUTER_BETA4: 'https://image-1251917893.file.myqcloud.com/igame/npm/uni-simple-router/uni-simple-router-2.0.8-beta-4.js',
429
+ UNI_SIMPLE_ROUTER: 'https://image-1251917893.file.myqcloud.com/igame/npm/uni-simple-router/uni-simple-router%402.0.8-beta.4-1.js',
430
+ AEGIS_WEB: 'https://image-1251917893.file.myqcloud.com/igame/npm/aegis-web/aegis.min.js',
431
+ AEGIS_WEB_V2: 'https://image-1251917893.file.myqcloud.com/igame/npm/aegis-web/v2.min.2.3.41.js',
432
+ AXIOS: 'https://image-1251917893.file.myqcloud.com/igame/npm/axios@0.18.0/dist/axios.min.js',
433
+ VUE_LAZY_LOAD: 'https://image-1251917893.file.myqcloud.com/igame/npm/vue-lazyload@1.3.3/vue-lazyload.js',
434
+ VUE_V2: 'https://image-1251917893.file.myqcloud.com/igame/npm/vue%402.6.10/dist/vue.runtime.min.js',
435
+ VUE_V3: 'https://image-1251917893.file.myqcloud.com/igame/npm/vue@3.3.6/vue.runtime.global.prod.js',
436
+ VUE_DEMI: 'https://image-1251917893.file.myqcloud.com/igame/npm/vue-demi@0.14.6/index.iife.min.js',
437
+ VUE_ROUTER_V3: 'https://image-1251917893.file.myqcloud.com/igame/npm/vue-router@3.5.2/dist/vue-router.min.js',
438
+ VUE_ROUTER_V4: 'https://image-1251917893.file.myqcloud.com/igame/npm/vue-router@4.2.5/vue-router.global.prod.js',
439
+ VUEX_V3: 'https://image-1251917893.file.myqcloud.com/igame/npm/vuex@3.0.1/dist/vuex.min.js',
440
+ VUEX_V4: 'https://image-1251917893.cos.ap-guangzhou.myqcloud.com/igame/npm/vuex%404.1.0/vuex.global.prod.js',
441
+ PINIA: 'https://image-1251917893.file.myqcloud.com/igame/npm/pinia@2.1.7/pinia.iife.min.js',
442
+ ELEMENT_PLUS: 'https://image-1251917893.file.myqcloud.com/igame/npm/element-plus/element-plus%402.7.8.js',
443
+ ELEMENT_PLUS_CSS: 'https://image-1251917893.file.myqcloud.com/igame/npm/element-plus/element-plus%402.7.8.css',
444
+ E_MONITOR: 'https://image-1251917893.file.myqcloud.com/igame/common/js/emonitor_custom_46f41566.js',
445
+ };
446
+
447
+ const DEFAULT_TRANSPILE_DEPENDENCIES = [
448
+ 'pmd-merchant-ui',
449
+ 'press-ui',
450
+ 'press-plus',
451
+ 'pmd-aegis',
452
+ 'pmd-app-info',
453
+ 'pmd-config',
454
+ 'pmd-location',
455
+ 'pmd-login',
456
+ 'pmd-network',
457
+ 'pmd-report',
458
+ 'pmd-tools',
459
+ 'pmd-types',
460
+ 'pmd-widget',
461
+ 'pmd-vue',
462
+ 'pmd-jsapi',
463
+ 'pmd-component',
464
+ 'pmd-business',
465
+ 'pmd-api',
466
+ '@zebra-ui/swiper',
467
+ ];
468
+ const DEFAULT_ADAPTER_DIRS = [
469
+ 'comm',
470
+ 'common',
471
+ 'component',
472
+ 'live-component',
473
+ 'logic',
474
+ 'local-logic',
475
+ 'local-component',
476
+ 'login',
477
+ 'pages',
478
+ 'static',
479
+ 'node-modules',
480
+ ];
481
+ const AEGIS_EXTERNAL_SCRIPT_LINK = CDN_MAP.AEGIS_WEB;
482
+ const UNI_SIMPLE_ROUTER_SCRIPT_LINK = CDN_MAP.UNI_SIMPLE_ROUTER_BETA4;
483
+ const EXTERNAL_LINK_MAP = {
484
+ AXIOS: CDN_MAP.AXIOS,
485
+ VUE_LAZY_LOAD: CDN_MAP.VUE_LAZY_LOAD,
486
+ AEGIS_WEB: CDN_MAP.AEGIS_WEB,
487
+ UNI_SIMPLE_ROUTER: UNI_SIMPLE_ROUTER_SCRIPT_LINK,
488
+ };
489
+
490
+ /* eslint-disable @typescript-eslint/no-require-imports */
491
+ const ROOT_NAME = 'MAIN';
492
+ function saveJsonToLog(content, file, needLog = true) {
493
+ if (!needLog)
494
+ return;
495
+ createLogDir();
496
+ const filePath = `./log/${file}`;
497
+ let beforeContent = [];
498
+ let newContent = [{
499
+ logTime: tComm.timeStampFormat(Date.now(), 'yyyy-MM-dd hh:mm:ss'),
500
+ data: content,
501
+ }];
502
+ if (fs__namespace.existsSync(filePath)) {
503
+ try {
504
+ beforeContent = tComm.readFileSync(filePath, true).logList || [];
505
+ }
506
+ catch (err) {
507
+ beforeContent = [];
508
+ }
509
+ }
510
+ if (beforeContent && Array.isArray(beforeContent)) {
511
+ newContent.push(...beforeContent);
512
+ }
513
+ newContent = newContent.slice(0, 10);
514
+ try {
515
+ fs__namespace.writeFile(filePath, JSON.stringify({ logList: newContent }, null, 2), {
516
+ encoding: 'utf-8',
517
+ }, () => { });
518
+ }
519
+ catch (err) {
520
+ }
521
+ }
522
+ function createLogDir() {
523
+ if (!fs__namespace.existsSync('./log')) {
524
+ fs__namespace.mkdirSync('./log');
525
+ }
526
+ }
527
+ const normalizePath = (path) => (tComm.isWindows() ? path.replace(/\\/g, '/') : path);
528
+ function updateAssetSource(assets, key, source) {
529
+ assets[key] = {
530
+ source() {
531
+ return source;
532
+ },
533
+ size() {
534
+ return source.length;
535
+ },
536
+ };
537
+ }
538
+ function removeFirstSlash(key) {
539
+ if (key.startsWith('/')) {
540
+ return key.slice(1);
541
+ }
542
+ return key;
543
+ }
544
+ function sortStringList(list) {
545
+ list.sort((a, b) => {
546
+ if (a > b)
547
+ return 1;
548
+ if (a < b)
549
+ return -1;
550
+ return 0;
551
+ });
552
+ return list;
553
+ }
554
+ function parseSetDeps(deps) {
555
+ return Object.keys(deps).reduce((acc, item) => {
556
+ acc[item] = Array.from(deps[item]);
557
+ sortStringList(acc[item]);
558
+ return acc;
559
+ }, {});
560
+ }
561
+ function getRelativePath(filePath) {
562
+ return path__namespace.relative(process.cwd(), path__namespace.resolve(filePath));
563
+ }
564
+
565
+ const DEFAULT_KEYS = [
566
+ 'UNI_APP_X',
567
+ 'APP',
568
+ 'APP_UVUE',
569
+ 'APP_NVUE',
570
+ 'APP_PLUS',
571
+ 'APP_PLUS_NVUE',
572
+ 'APP_VUE',
573
+ 'APP_ANDROID',
574
+ 'APP_IOS',
575
+ 'APP_HARMONY',
576
+ 'H5',
577
+ 'MP',
578
+ 'MP_360',
579
+ 'MP_ALIPAY',
580
+ 'MP_BAIDU',
581
+ 'MP_QQ',
582
+ 'MP_LARK',
583
+ 'MP_TOUTIAO',
584
+ 'MP_WEIXIN',
585
+ 'MP_KUAISHOU',
586
+ 'MP_JD',
587
+ 'QUICKAPP_NATIVE',
588
+ 'QUICKAPP_WEBVIEW',
589
+ 'QUICKAPP_WEBVIEW_HUAWEI',
590
+ 'QUICKAPP_WEBVIEW_UNION',
591
+ 'VUE2',
592
+ 'VUE3',
593
+ 'WEB',
594
+ ];
595
+ const DEFAULT_CONTEXT_OBJECT = DEFAULT_KEYS.reduce((acc, key) => ({
596
+ ...acc,
597
+ [key]: false,
598
+ }), {});
599
+
600
+ const scssLogger = {
601
+ warn(message, options) {
602
+ // Mute "Mixed Declarations" warning
603
+ if (options.deprecation && message.includes('mixed-decls')) {
604
+ return;
605
+ }
606
+ // List all other warnings
607
+ console.warn(`▲ [WARNING]: ${message}`);
608
+ },
609
+ };
610
+
611
+ function getDeps(dir) {
612
+ const data = tComm.readFileSync(path__default["default"].resolve(dir, 'package.json'), true);
613
+ return Object.keys({
614
+ ...data.dependencies,
615
+ });
616
+ }
617
+
618
+ function getParent(path, level) {
619
+ if (!level) {
620
+ return path.parent;
621
+ }
622
+ return getParent(path.parentPath, level - 1);
623
+ }
624
+ function findDependencies(content) {
625
+ const parser = require('@babel/parser');
626
+ const traverse = require('@babel/traverse').default;
627
+ const sourceList = [];
628
+ const ast = parser.parse(content, {
629
+ // 不加这个配置,报错:SyntaxError: 'import' and 'export' may appear only with 'sourceType: "module"'
630
+ sourceType: 'module',
631
+ plugins: ['typescript'],
632
+ });
633
+ traverse(ast, {
634
+ CallExpression(path) {
635
+ if (path.node.callee.name === 'require') {
636
+ if (path.node.arguments[0].type === 'StringLiteral') {
637
+ sourceList.push(path.node.arguments[0].value);
638
+ }
639
+ if (getParent(path, 0).type === 'ExpressionStatement'
640
+ && getParent(path, 1).type === 'BlockStatement'
641
+ && getParent(path, 2).type === 'ObjectMethod'
642
+ && getParent(path, 3).type === 'ObjectExpression'
643
+ && getParent(path, 4)?.type === 'ObjectProperty'
644
+ && getParent(path, 4)?.key?.name === 'components'
645
+ && getParent(path, 5)?.type === 'ObjectExpression'
646
+ && getParent(path, 6)?.type === 'ExportDefaultDeclaration'
647
+ && path.node.arguments[0].type === 'ArrayExpression') {
648
+ sourceList.push(path.node.arguments[0].elements[0].value);
649
+ }
650
+ }
651
+ },
652
+ ImportDeclaration(path) {
653
+ sourceList.push(path.node.source.value);
654
+ },
655
+ });
656
+ return sourceList;
657
+ }
658
+
659
+ function checkH5() {
660
+ return process.env.VUE_APP_PLATFORM === 'h5';
661
+ }
662
+
663
+ const LOADER_PROD = 'loader.prod.js';
664
+ function getLoaderFile(dir = '', isProd = false) {
665
+ if (isProd) {
666
+ return path__default["default"].resolve(dir, LOADER_PROD);
667
+ }
668
+ return path__default["default"].resolve(dir, 'loader.js');
669
+ }
670
+ function getLoaderProdFile(dir = '') {
671
+ return path__default["default"].resolve(dir, LOADER_PROD);
672
+ }
673
+
674
+ const LOG_KEY = 'LOADER_LOGS';
675
+ function saveLoaderLog() {
676
+ const loaderLogs = global[LOG_KEY];
677
+ if (!loaderLogs)
678
+ return;
679
+ Object.keys(loaderLogs).forEach((file) => {
680
+ saveJsonToLog(loaderLogs[file], file);
681
+ });
682
+ }
683
+ function recordLoaderLog(file, content) {
684
+ if (!global[LOG_KEY]) {
685
+ global[LOG_KEY] = {};
686
+ }
687
+ if (!global[LOG_KEY][file]) {
688
+ global[LOG_KEY][file] = [];
689
+ }
690
+ global[LOG_KEY][file].push(content);
691
+ }
692
+
693
+ function getWxmlAndWxssPostfix() {
694
+ const map = Object.keys(PLATFORM_MAP).reduce((acc, item) => {
695
+ acc[PLATFORM_MAP[item]] = item;
696
+ return acc;
697
+ }, {});
698
+ const key = map[process.env.UNI_PLATFORM || ''];
699
+ return [
700
+ HTML_MAP[key],
701
+ CSS_MAP[key],
702
+ ];
703
+ }
704
+
705
+ function getProjectName() {
706
+ let result = '';
707
+ try {
708
+ const json = tComm.readFileSync('package.json', true) || {};
709
+ result = json.name || '';
710
+ }
711
+ catch (err) { }
712
+ return result;
713
+ }
714
+ function getSubProjectName() {
715
+ const name = process.env.VUE_APP_DIR?.split('/')?.[1] || '';
716
+ return name;
717
+ }
718
+
719
+ // 读取 manifest.json ,修改后重新写入
720
+ const manifestPath = `${process.env.UNI_INPUT_DIR}/manifest.json`;
721
+ let originManifest = '';
722
+ try {
723
+ originManifest = fs__namespace.readFileSync(manifestPath, { encoding: 'utf-8' });
724
+ }
725
+ catch (err) {
726
+ }
727
+ let Manifest = originManifest;
728
+ function replaceManifest(path, value) {
729
+ const arr = path.split('.');
730
+ const len = arr.length;
731
+ const lastItem = arr[len - 1];
732
+ let i = 0;
733
+ const ManifestArr = Manifest.split(/\n/);
734
+ for (let index = 0; index < ManifestArr.length; index++) {
735
+ const item = ManifestArr[index];
736
+ if (new RegExp(`"${arr[i]}"`).test(item))
737
+ i = i + 1;
738
+ if (i === len) {
739
+ const hasComma = /,/.test(item);
740
+ ManifestArr[index] = item.replace(new RegExp(`"${lastItem}"[\\s\\S]*:[\\s\\S]*`), `"${lastItem}": ${value}${hasComma ? ',' : ''}`);
741
+ break;
742
+ }
743
+ }
744
+ Manifest = ManifestArr.join('\n');
745
+ }
746
+ function updateManifest(path, value) {
747
+ replaceManifest(path, value);
748
+ fs__namespace.writeFileSync(manifestPath, Manifest, {
749
+ flag: 'w',
750
+ });
751
+ }
752
+ function revertManifest() {
753
+ fs__namespace.writeFileSync(manifestPath, originManifest, {
754
+ flag: 'w',
755
+ });
756
+ }
757
+
758
+ function getSubProjectRoot({ root, appDir, }) {
759
+ let subProjectRoot = `${path__default["default"].resolve(root, `./src/${appDir}`)}/`;
760
+ if (!appDir) {
761
+ subProjectRoot = path__default["default"].resolve(root, './src/');
762
+ }
763
+ return subProjectRoot;
764
+ }
765
+ function getSubProjectConfig(subProjectRoot) {
766
+ let res = {};
767
+ try {
768
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
769
+ res = require(path__default["default"].resolve(subProjectRoot, 'config.js'));
770
+ }
771
+ catch (err) { }
772
+ return res;
773
+ }
774
+
775
+ const getPlatform = () => process.env.UNI_PLATFORM || '';
776
+ const getUtsPlatform = () => process.env.UNI_UTS_PLATFORM || '';
777
+ const getAppPlatform = () => process.env.UNI_APP_PLATFORM || '';
778
+ const isH5 = () => getPlatform() === 'h5';
779
+ const isApp = () => getPlatform() === 'app';
780
+ const isAppAndroid = () => getAppPlatform() === 'android' || getUtsPlatform() === 'app-android';
781
+ const isAppIOS = () => getAppPlatform() === 'ios' || getUtsPlatform() === 'app-ios';
782
+ const isMp = () => /^mp-/i.test(getPlatform());
783
+ const isMpWeixin = () => getPlatform() === 'mp-weixin';
784
+ const isMpAlipay = () => getPlatform() === 'mp-alipay';
785
+ const isMpBaidu = () => getPlatform() === 'mp-baidu';
786
+ const isMpKuaishou = () => getPlatform() === 'mp-kuaishou';
787
+ const isMpQQ = () => getPlatform() === 'mp-qq';
788
+ const isMpToutiao = () => getPlatform() === 'mp-toutiao';
789
+ const isQuickapp = () => /^quickapp-webview/i.test(getPlatform());
790
+ const isQuickappUnion = () => getPlatform() === 'quickapp-webview-union';
791
+ const isQuickappHuawei = () => getPlatform() === 'quickapp-webview-huawei';
792
+
793
+ exports.AEGIS_EXTERNAL_SCRIPT_LINK = AEGIS_EXTERNAL_SCRIPT_LINK;
794
+ exports.ALL_PLATFORM = ALL_PLATFORM;
795
+ exports.BASE_SCSS = BASE_SCSS;
796
+ exports.CDN_MAP = CDN_MAP;
797
+ exports.CSS_MAP = CSS_MAP;
798
+ exports.CSS_POSTFIX_MAP = CSS_POSTFIX_MAP;
799
+ exports.DEFAULT_ADAPTER_DIRS = DEFAULT_ADAPTER_DIRS;
800
+ exports.DEFAULT_CONTEXT_OBJECT = DEFAULT_CONTEXT_OBJECT;
801
+ exports.DEFAULT_TRANSPILE_DEPENDENCIES = DEFAULT_TRANSPILE_DEPENDENCIES;
802
+ exports.EXTERNAL_LINK_MAP = EXTERNAL_LINK_MAP;
803
+ exports.HTML_MAP = HTML_MAP;
804
+ exports.PLATFORMS_ALL = PLATFORMS_ALL;
805
+ exports.PLATFORMS_MP = PLATFORMS_MP;
806
+ exports.PLATFORM_MAP = PLATFORM_MAP;
807
+ exports.ROOT_NAME = ROOT_NAME;
808
+ exports.UNI_SIMPLE_ROUTER_SCRIPT_LINK = UNI_SIMPLE_ROUTER_SCRIPT_LINK;
809
+ exports.checkBundleAnalyze = checkBundleAnalyze;
810
+ exports.checkDebugMode = checkDebugMode;
811
+ exports.checkH5 = checkH5;
812
+ exports.createLogDir = createLogDir;
813
+ exports.crossGameStyle = crossGameStyle;
814
+ exports.findDependencies = findDependencies;
815
+ exports.findNodeModuleFile = findNodeModuleFile;
816
+ exports.genInjectContent = genInjectContent;
817
+ exports.getAppPlatform = getAppPlatform;
818
+ exports.getCommitCode = getCommitCode;
819
+ exports.getComponentName = getComponentName;
820
+ exports.getDeps = getDeps;
821
+ exports.getGenVersionPluginOptions = getGenVersionPluginOptions;
822
+ exports.getLoaderFile = getLoaderFile;
823
+ exports.getLoaderProdFile = getLoaderProdFile;
824
+ exports.getMpInsertCode = getMpInsertCode;
825
+ exports.getMpVersionCode = getMpVersionCode;
826
+ exports.getPlatform = getPlatform;
827
+ exports.getProjectName = getProjectName;
828
+ exports.getRelativePath = getRelativePath;
829
+ exports.getRootDir = getRootDir;
830
+ exports.getStyleList = getStyleList;
831
+ exports.getSubProjectConfig = getSubProjectConfig;
832
+ exports.getSubProjectName = getSubProjectName;
833
+ exports.getSubProjectRoot = getSubProjectRoot;
834
+ exports.getUtsPlatform = getUtsPlatform;
835
+ exports.getVersionCode = getVersionCode;
836
+ exports.getWebInsertCode = getWebInsertCode;
837
+ exports.getWxmlAndWxssPostfix = getWxmlAndWxssPostfix;
838
+ exports.isApp = isApp;
839
+ exports.isAppAndroid = isAppAndroid;
840
+ exports.isAppIOS = isAppIOS;
841
+ exports.isH5 = isH5;
842
+ exports.isInBlackList = isInBlackList;
843
+ exports.isMp = isMp;
844
+ exports.isMpAlipay = isMpAlipay;
845
+ exports.isMpBaidu = isMpBaidu;
846
+ exports.isMpKuaishou = isMpKuaishou;
847
+ exports.isMpQQ = isMpQQ;
848
+ exports.isMpToutiao = isMpToutiao;
849
+ exports.isMpWeixin = isMpWeixin;
850
+ exports.isQuickapp = isQuickapp;
851
+ exports.isQuickappHuawei = isQuickappHuawei;
852
+ exports.isQuickappUnion = isQuickappUnion;
853
+ exports.normalizePath = normalizePath;
854
+ exports.parseSetDeps = parseSetDeps;
855
+ exports.recordLoaderLog = recordLoaderLog;
856
+ exports.removeFirstSlash = removeFirstSlash;
857
+ exports.replaceDirective = replaceDirective;
858
+ exports.revertManifest = revertManifest;
859
+ exports.saveJsonToLog = saveJsonToLog;
860
+ exports.saveLoaderLog = saveLoaderLog;
861
+ exports.scssLogger = scssLogger;
862
+ exports.updateAssetSource = updateAssetSource;
863
+ exports.updateManifest = updateManifest;
864
+ exports.vLazyCore = vLazyCore;
@@ -0,0 +1,2 @@
1
+ export declare function getLoaderFile(dir?: string, isProd?: boolean): string;
2
+ export declare function getLoaderProdFile(dir?: string): string;
@@ -0,0 +1,2 @@
1
+ export declare function saveLoaderLog(): void;
2
+ export declare function recordLoaderLog(file: string, content: any): void;
@@ -0,0 +1 @@
1
+ export declare function getWxmlAndWxssPostfix(): (".wxml" | ".qml" | ".axml" | ".jxml" | ".wxss" | ".qss" | ".acss" | ".jxss")[];
@@ -0,0 +1,2 @@
1
+ export declare function getProjectName(): string;
2
+ export declare function getSubProjectName(): string;
@@ -0,0 +1,2 @@
1
+ export declare function updateManifest(path: string, value: string): void;
2
+ export declare function revertManifest(): void;
package/lib/root.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function getRootDir(): string;
@@ -0,0 +1,5 @@
1
+ export declare function getSubProjectRoot({ root, appDir, }: {
2
+ root: string;
3
+ appDir: string;
4
+ }): string;
5
+ export declare function getSubProjectConfig(subProjectRoot: string): Record<string, any>;
@@ -0,0 +1,17 @@
1
+ export declare const getPlatform: () => string;
2
+ export declare const getUtsPlatform: () => string;
3
+ export declare const getAppPlatform: () => string;
4
+ export declare const isH5: () => boolean;
5
+ export declare const isApp: () => boolean;
6
+ export declare const isAppAndroid: () => boolean;
7
+ export declare const isAppIOS: () => boolean;
8
+ export declare const isMp: () => boolean;
9
+ export declare const isMpWeixin: () => boolean;
10
+ export declare const isMpAlipay: () => boolean;
11
+ export declare const isMpBaidu: () => boolean;
12
+ export declare const isMpKuaishou: () => boolean;
13
+ export declare const isMpQQ: () => boolean;
14
+ export declare const isMpToutiao: () => boolean;
15
+ export declare const isQuickapp: () => boolean;
16
+ export declare const isQuickappUnion: () => boolean;
17
+ export declare const isQuickappHuawei: () => boolean;
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@plugin-light/shared",
3
+ "version": "0.0.8",
4
+ "homepage": "https://novlan1.github.io/plugin-light/",
5
+ "bugs": {
6
+ "url": "https://github.com/novlan1/plugin-light/issues"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/novlan1/plugin-light"
11
+ },
12
+ "license": "MIT",
13
+ "author": "guowangyang",
14
+ "main": "./lib/index",
15
+ "files": [
16
+ "lib/"
17
+ ],
18
+ "dependencies": {
19
+ "t-comm": "^1.3.139"
20
+ },
21
+ "scripts": {
22
+ "build": "rm -rf lib && rollup -c",
23
+ "bump": "node ../../script/monorepo/version-simple $PWD",
24
+ "changelog": "node ../../script/monorepo/changelog $PWD",
25
+ "release": "node ../../script/monorepo/release $PWD"
26
+ }
27
+ }