@plugin-light/shared 0.0.11 → 0.0.19
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/README.md +7 -3
- package/lib/black-list.d.ts +2 -0
- package/lib/config-project.d.ts +6 -6
- package/lib/config.d.ts +18 -1
- package/lib/core/index.d.ts +1 -0
- package/lib/core/node-module-file/find.d.ts +7 -0
- package/lib/core/node-module-file/index.d.ts +1 -0
- package/lib/css.d.ts +3 -0
- package/lib/helper.d.ts +0 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +127 -29
- package/lib/platform.d.ts +1 -0
- package/lib/uni-env.d.ts +17 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
## 公共包
|
|
2
2
|
|
|
3
|
-
除 `t-comm` 外,`plugin-light`
|
|
3
|
+
除 `t-comm` 外,`plugin-light-shared` 是整个工具库中最底层的依赖,业务无需直接引用。
|
|
4
4
|
|
|
5
5
|
### 如何使用
|
|
6
6
|
|
|
7
7
|
安装
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
pnpm add plugin-light
|
|
10
|
+
pnpm add @plugin-light/shared -D
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
使用
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
|
-
import { getDeps } from 'plugin-light
|
|
16
|
+
import { getDeps } from '@plugin-light/shared';
|
|
17
17
|
|
|
18
18
|
getDeps(__dirname);
|
|
19
19
|
```
|
|
20
|
+
|
|
21
|
+
### 更新日志
|
|
22
|
+
|
|
23
|
+
[点此查看](./CHANGELOG.md)
|
package/lib/config-project.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare const DEFAULT_TRANSPILE_DEPENDENCIES: string[];
|
|
2
2
|
export declare const DEFAULT_ADAPTER_DIRS: string[];
|
|
3
|
-
export declare const AEGIS_EXTERNAL_SCRIPT_LINK
|
|
4
|
-
export declare const UNI_SIMPLE_ROUTER_SCRIPT_LINK
|
|
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
5
|
export declare const EXTERNAL_LINK_MAP: {
|
|
6
|
-
AXIOS:
|
|
7
|
-
VUE_LAZY_LOAD:
|
|
8
|
-
AEGIS_WEB:
|
|
9
|
-
UNI_SIMPLE_ROUTER:
|
|
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
10
|
};
|
package/lib/config.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare const PLATFORM_MAP: {
|
|
|
2
2
|
readonly MP_WX: "mp-weixin";
|
|
3
3
|
readonly MP_QQ: "mp-qq";
|
|
4
4
|
readonly MP_ALIPAY: "mp-alipay";
|
|
5
|
+
readonly MP_JD: "mp-jd";
|
|
5
6
|
readonly H5: "h5";
|
|
6
7
|
};
|
|
7
8
|
export declare const ALL_PLATFORM = "ALL";
|
|
@@ -21,5 +22,21 @@ export declare const CSS_MAP: {
|
|
|
21
22
|
};
|
|
22
23
|
export declare const CSS_POSTFIX_MAP: any;
|
|
23
24
|
export declare const CDN_MAP: {
|
|
24
|
-
|
|
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";
|
|
25
42
|
};
|
package/lib/core/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { findNodeModuleFile, type IFindNodeModuleFile } from './find';
|
package/lib/css.d.ts
ADDED
package/lib/helper.d.ts
CHANGED
|
@@ -6,4 +6,3 @@ export declare function updateAssetSource(assets: Record<string, any>, key: stri
|
|
|
6
6
|
export declare function removeFirstSlash(key: string): string;
|
|
7
7
|
export declare function parseSetDeps(deps: Record<string, any>): Record<string, any>;
|
|
8
8
|
export declare function getRelativePath(filePath: string): string;
|
|
9
|
-
export declare function getUniCliCache(key?: string): any;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
export * from './core';
|
|
2
|
+
export { isInBlackList, } from './black-list';
|
|
2
3
|
export { checkBundleAnalyze, checkDebugMode, } from './bundle-analyze';
|
|
3
4
|
export { PLATFORM_MAP, ALL_PLATFORM, PLATFORMS_ALL, PLATFORMS_MP, HTML_MAP, CSS_MAP, CSS_POSTFIX_MAP, CDN_MAP, } from './config';
|
|
4
5
|
export { DEFAULT_TRANSPILE_DEPENDENCIES, DEFAULT_ADAPTER_DIRS, AEGIS_EXTERNAL_SCRIPT_LINK, UNI_SIMPLE_ROUTER_SCRIPT_LINK, EXTERNAL_LINK_MAP, } from './config-project';
|
|
5
|
-
export { ROOT_NAME, saveJsonToLog, createLogDir, normalizePath, updateAssetSource, removeFirstSlash, parseSetDeps, getRelativePath,
|
|
6
|
+
export { ROOT_NAME, saveJsonToLog, createLogDir, normalizePath, updateAssetSource, removeFirstSlash, parseSetDeps, getRelativePath, } from './helper';
|
|
6
7
|
export { DEFAULT_CONTEXT_OBJECT, } from './context';
|
|
8
|
+
export { scssLogger, } from './css';
|
|
7
9
|
export { getDeps, } from './deps';
|
|
8
10
|
export { findDependencies, } from './find-dependencies';
|
|
9
11
|
export { checkH5, } from './h5';
|
|
10
12
|
export { getLoaderFile, getLoaderProdFile, } from './loader-file';
|
|
11
13
|
export { saveLoaderLog, recordLoaderLog, } from './loader-log';
|
|
14
|
+
export { getWxmlAndWxssPostfix, } from './platform';
|
|
12
15
|
export { getProjectName, getSubProjectName, } from './project-name';
|
|
13
16
|
export { updateManifest, revertManifest, } from './replace-manifest';
|
|
14
17
|
export { getRootDir, } from './root';
|
|
15
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
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var tComm = require('t-comm');
|
|
8
|
+
var path$1 = require('node:path');
|
|
9
|
+
var fs$1 = require('node:fs');
|
|
8
10
|
|
|
9
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
12
|
|
|
@@ -28,7 +30,8 @@ function _interopNamespace(e) {
|
|
|
28
30
|
|
|
29
31
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
30
32
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
31
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
33
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
|
|
34
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
|
|
32
35
|
|
|
33
36
|
function getRootDir() {
|
|
34
37
|
return process.cwd();
|
|
@@ -161,7 +164,7 @@ function getCommitCode(versionName) {
|
|
|
161
164
|
if (versionName) {
|
|
162
165
|
code = `
|
|
163
166
|
window.${versionName} = {
|
|
164
|
-
message: '${commitInfo.message}',
|
|
167
|
+
message: '${parseQuote(commitInfo.message)}',
|
|
165
168
|
author: '${commitInfo.author}',
|
|
166
169
|
date: '${commitInfo.date}',
|
|
167
170
|
hash: '${commitInfo.hash}',
|
|
@@ -267,6 +270,30 @@ function getComponentName(dir) {
|
|
|
267
270
|
return match?.[1] || '';
|
|
268
271
|
}
|
|
269
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
|
+
|
|
270
297
|
function replaceDirective(source, list) {
|
|
271
298
|
if (!list.length)
|
|
272
299
|
return source;
|
|
@@ -342,6 +369,19 @@ function handleImg(str = '', urlHandler = '') {
|
|
|
342
369
|
return res;
|
|
343
370
|
}
|
|
344
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
|
+
|
|
345
385
|
function checkBundleAnalyze() {
|
|
346
386
|
return process.argv.includes('--bundleAnalyzer')
|
|
347
387
|
|| !!process.env.npm_config_report;
|
|
@@ -354,6 +394,7 @@ const PLATFORM_MAP = {
|
|
|
354
394
|
MP_WX: 'mp-weixin',
|
|
355
395
|
MP_QQ: 'mp-qq',
|
|
356
396
|
MP_ALIPAY: 'mp-alipay',
|
|
397
|
+
MP_JD: 'mp-jd',
|
|
357
398
|
H5: 'h5',
|
|
358
399
|
};
|
|
359
400
|
const ALL_PLATFORM = 'ALL';
|
|
@@ -384,7 +425,23 @@ const CSS_POSTFIX_MAP = Object.keys(CSS_MAP)
|
|
|
384
425
|
return acc;
|
|
385
426
|
}, {});
|
|
386
427
|
const CDN_MAP = {
|
|
387
|
-
|
|
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',
|
|
388
445
|
};
|
|
389
446
|
|
|
390
447
|
const DEFAULT_TRANSPILE_DEPENDENCIES = [
|
|
@@ -407,20 +464,6 @@ const DEFAULT_TRANSPILE_DEPENDENCIES = [
|
|
|
407
464
|
'pmd-business',
|
|
408
465
|
'pmd-api',
|
|
409
466
|
'@zebra-ui/swiper',
|
|
410
|
-
// /[@\\]tencent[/\\]press-ui/,
|
|
411
|
-
// /[@\\]tencent[/\\]press-plus/,
|
|
412
|
-
// /[@\\]tencent[/\\]pmd-aegis/,
|
|
413
|
-
// /[@\\]tencent[/\\]pmd-app-info/,
|
|
414
|
-
// /[@\\]tencent[/\\]pmd-config/,
|
|
415
|
-
// /[@\\]tencent[/\\]pmd-location/,
|
|
416
|
-
// /[@\\]tencent[/\\]pmd-login/,
|
|
417
|
-
// /[@\\]tencent[/\\]pmd-network/,
|
|
418
|
-
// /[@\\]tencent[/\\]pmd-report/,
|
|
419
|
-
// /[@\\]tencent[/\\]pmd-tools/,
|
|
420
|
-
// /[@\\]tencent[/\\]pmd-widget/,
|
|
421
|
-
// /[@\\]tencent[/\\]pmd-vue/,
|
|
422
|
-
// /[@\\]tencent[/\\]pmd-jsapi/,
|
|
423
|
-
// /[@\\]zebra-ui[/\\]swiper/,
|
|
424
467
|
];
|
|
425
468
|
const DEFAULT_ADAPTER_DIRS = [
|
|
426
469
|
'comm',
|
|
@@ -435,12 +478,12 @@ const DEFAULT_ADAPTER_DIRS = [
|
|
|
435
478
|
'static',
|
|
436
479
|
'node-modules',
|
|
437
480
|
];
|
|
438
|
-
const AEGIS_EXTERNAL_SCRIPT_LINK =
|
|
439
|
-
const UNI_SIMPLE_ROUTER_SCRIPT_LINK =
|
|
481
|
+
const AEGIS_EXTERNAL_SCRIPT_LINK = CDN_MAP.AEGIS_WEB;
|
|
482
|
+
const UNI_SIMPLE_ROUTER_SCRIPT_LINK = CDN_MAP.UNI_SIMPLE_ROUTER_BETA4;
|
|
440
483
|
const EXTERNAL_LINK_MAP = {
|
|
441
|
-
AXIOS:
|
|
442
|
-
VUE_LAZY_LOAD:
|
|
443
|
-
AEGIS_WEB:
|
|
484
|
+
AXIOS: CDN_MAP.AXIOS,
|
|
485
|
+
VUE_LAZY_LOAD: CDN_MAP.VUE_LAZY_LOAD,
|
|
486
|
+
AEGIS_WEB: CDN_MAP.AEGIS_WEB,
|
|
444
487
|
UNI_SIMPLE_ROUTER: UNI_SIMPLE_ROUTER_SCRIPT_LINK,
|
|
445
488
|
};
|
|
446
489
|
|
|
@@ -518,12 +561,6 @@ function parseSetDeps(deps) {
|
|
|
518
561
|
function getRelativePath(filePath) {
|
|
519
562
|
return path__namespace.relative(process.cwd(), path__namespace.resolve(filePath));
|
|
520
563
|
}
|
|
521
|
-
function getUniCliCache(key) {
|
|
522
|
-
const cache = require('@dcloudio/uni-cli-shared/lib/cache');
|
|
523
|
-
if (!key)
|
|
524
|
-
return cache;
|
|
525
|
-
return cache[key];
|
|
526
|
-
}
|
|
527
564
|
|
|
528
565
|
const DEFAULT_KEYS = [
|
|
529
566
|
'UNI_APP_X',
|
|
@@ -560,6 +597,17 @@ const DEFAULT_CONTEXT_OBJECT = DEFAULT_KEYS.reduce((acc, key) => ({
|
|
|
560
597
|
[key]: false,
|
|
561
598
|
}), {});
|
|
562
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
|
+
|
|
563
611
|
function getDeps(dir) {
|
|
564
612
|
const data = tComm.readFileSync(path__default["default"].resolve(dir, 'package.json'), true);
|
|
565
613
|
return Object.keys({
|
|
@@ -642,6 +690,18 @@ function recordLoaderLog(file, content) {
|
|
|
642
690
|
global[LOG_KEY][file].push(content);
|
|
643
691
|
}
|
|
644
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
|
+
|
|
645
705
|
function getProjectName() {
|
|
646
706
|
let result = '';
|
|
647
707
|
try {
|
|
@@ -712,6 +772,24 @@ function getSubProjectConfig(subProjectRoot) {
|
|
|
712
772
|
return res;
|
|
713
773
|
}
|
|
714
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
|
+
|
|
715
793
|
exports.AEGIS_EXTERNAL_SCRIPT_LINK = AEGIS_EXTERNAL_SCRIPT_LINK;
|
|
716
794
|
exports.ALL_PLATFORM = ALL_PLATFORM;
|
|
717
795
|
exports.BASE_SCSS = BASE_SCSS;
|
|
@@ -734,7 +812,9 @@ exports.checkH5 = checkH5;
|
|
|
734
812
|
exports.createLogDir = createLogDir;
|
|
735
813
|
exports.crossGameStyle = crossGameStyle;
|
|
736
814
|
exports.findDependencies = findDependencies;
|
|
815
|
+
exports.findNodeModuleFile = findNodeModuleFile;
|
|
737
816
|
exports.genInjectContent = genInjectContent;
|
|
817
|
+
exports.getAppPlatform = getAppPlatform;
|
|
738
818
|
exports.getCommitCode = getCommitCode;
|
|
739
819
|
exports.getComponentName = getComponentName;
|
|
740
820
|
exports.getDeps = getDeps;
|
|
@@ -743,6 +823,7 @@ exports.getLoaderFile = getLoaderFile;
|
|
|
743
823
|
exports.getLoaderProdFile = getLoaderProdFile;
|
|
744
824
|
exports.getMpInsertCode = getMpInsertCode;
|
|
745
825
|
exports.getMpVersionCode = getMpVersionCode;
|
|
826
|
+
exports.getPlatform = getPlatform;
|
|
746
827
|
exports.getProjectName = getProjectName;
|
|
747
828
|
exports.getRelativePath = getRelativePath;
|
|
748
829
|
exports.getRootDir = getRootDir;
|
|
@@ -750,9 +831,25 @@ exports.getStyleList = getStyleList;
|
|
|
750
831
|
exports.getSubProjectConfig = getSubProjectConfig;
|
|
751
832
|
exports.getSubProjectName = getSubProjectName;
|
|
752
833
|
exports.getSubProjectRoot = getSubProjectRoot;
|
|
753
|
-
exports.
|
|
834
|
+
exports.getUtsPlatform = getUtsPlatform;
|
|
754
835
|
exports.getVersionCode = getVersionCode;
|
|
755
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;
|
|
756
853
|
exports.normalizePath = normalizePath;
|
|
757
854
|
exports.parseSetDeps = parseSetDeps;
|
|
758
855
|
exports.recordLoaderLog = recordLoaderLog;
|
|
@@ -761,6 +858,7 @@ exports.replaceDirective = replaceDirective;
|
|
|
761
858
|
exports.revertManifest = revertManifest;
|
|
762
859
|
exports.saveJsonToLog = saveJsonToLog;
|
|
763
860
|
exports.saveLoaderLog = saveLoaderLog;
|
|
861
|
+
exports.scssLogger = scssLogger;
|
|
764
862
|
exports.updateAssetSource = updateAssetSource;
|
|
765
863
|
exports.updateManifest = updateManifest;
|
|
766
864
|
exports.vLazyCore = vLazyCore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getWxmlAndWxssPostfix(): (".wxml" | ".qml" | ".axml" | ".jxml" | ".wxss" | ".qss" | ".acss" | ".jxss")[];
|
package/lib/uni-env.d.ts
ADDED
|
@@ -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
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugin-light/shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"main": "./lib/index",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib/"
|
|
7
7
|
],
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/novlan1/
|
|
10
|
+
"url": "https://github.com/novlan1/plugin-light"
|
|
11
11
|
},
|
|
12
12
|
"author": "guowangyang",
|
|
13
|
-
"homepage": "https://novlan1.github.io/
|
|
13
|
+
"homepage": "https://novlan1.github.io/plugin-light/",
|
|
14
14
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/novlan1/
|
|
15
|
+
"url": "https://github.com/novlan1/plugin-light/issues"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"t-comm": "^1.3.
|
|
18
|
+
"t-comm": "^1.3.139"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "rm -rf lib && rollup -c",
|