@dcloudio/uni-cli-shared 3.0.0-alpha-3030420211228002 → 3.0.0-alpha-3030520211229003
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/json/manifest.d.ts +1 -0
- package/dist/json/manifest.js +6 -1
- package/dist/json/pages.d.ts +13 -0
- package/dist/json/pages.js +26 -2
- package/dist/mp/template.d.ts +2 -1
- package/dist/mp/usingComponents.d.ts +8 -1
- package/dist/mp/usingComponents.js +9 -3
- package/dist/platform.d.ts +2 -0
- package/dist/platform.js +31 -0
- package/dist/vite/plugins/copy.d.ts +4 -1
- package/dist/vite/plugins/copy.js +2 -1
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugins/asset.js +3 -2
- package/dist/vite/utils/index.d.ts +1 -0
- package/dist/vite/utils/index.js +1 -0
- package/dist/vite/utils/utils.d.ts +2 -0
- package/dist/vite/utils/utils.js +10 -0
- package/dist/watcher.js +3 -3
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __exportStar(require("./filter"), exports);
|
|
|
32
32
|
__exportStar(require("./esbuild"), exports);
|
|
33
33
|
__exportStar(require("./resolve"), exports);
|
|
34
34
|
__exportStar(require("./scripts"), exports);
|
|
35
|
+
__exportStar(require("./platform"), exports);
|
|
35
36
|
var messages_1 = require("./messages");
|
|
36
37
|
Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
|
|
37
38
|
__exportStar(require("./exports"), exports);
|
package/dist/json/manifest.d.ts
CHANGED
|
@@ -24,4 +24,5 @@ export declare function getRouterOptions(manifestJson: Record<string, any>): {
|
|
|
24
24
|
base?: string;
|
|
25
25
|
};
|
|
26
26
|
export declare function isEnableTreeShaking(manifestJson: Record<string, any>): boolean;
|
|
27
|
+
export declare function getDevServerOptions(manifestJson: Record<string, any>): any;
|
|
27
28
|
export {};
|
package/dist/json/manifest.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isEnableTreeShaking = exports.getRouterOptions = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
|
|
6
|
+
exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -57,3 +57,8 @@ function isEnableTreeShaking(manifestJson) {
|
|
|
57
57
|
return ((_c = (_b = (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.optimization) === null || _b === void 0 ? void 0 : _b.treeShaking) === null || _c === void 0 ? void 0 : _c.enable) !== false;
|
|
58
58
|
}
|
|
59
59
|
exports.isEnableTreeShaking = isEnableTreeShaking;
|
|
60
|
+
function getDevServerOptions(manifestJson) {
|
|
61
|
+
var _a;
|
|
62
|
+
return (0, shared_1.extend)({}, (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.devServer);
|
|
63
|
+
}
|
|
64
|
+
exports.getDevServerOptions = getDevServerOptions;
|
package/dist/json/pages.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export declare function isUniPageFile(file: string, inputDir?: string): boolean;
|
|
2
2
|
export declare function isUniPageSfcFile(file: string, inputDir?: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* 小程序平台慎用,因为该解析不支持 subpackages
|
|
5
|
+
* @param inputDir
|
|
6
|
+
* @param platform
|
|
7
|
+
* @param normalize
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
3
10
|
export declare const parsePagesJson: (inputDir: string, platform: UniApp.PLATFORM, normalize?: boolean) => UniApp.PagesJson;
|
|
11
|
+
/**
|
|
12
|
+
* 该方法解析出来的是不支持 subpackages,会被合并入 pages
|
|
13
|
+
*/
|
|
4
14
|
export declare const parsePagesJsonOnce: (inputDir: string, platform: UniApp.PLATFORM, normalize?: boolean) => UniApp.PagesJson;
|
|
5
15
|
/**
|
|
6
16
|
* 目前 App 和 H5 使用了该方法
|
|
@@ -15,3 +25,6 @@ export declare function normalizePagesJson(jsonStr: string, platform: UniApp.PLA
|
|
|
15
25
|
export declare function validatePages(pagesJson: Record<string, any>, jsonStr: string): void;
|
|
16
26
|
export declare function removePlatformStyle(pageStyle: Record<string, any>): Record<string, any>;
|
|
17
27
|
export declare function normalizePagesRoute(pagesJson: UniApp.PagesJson): UniApp.UniRoute[];
|
|
28
|
+
declare function parseSubpackagesRoot(inputDir: string, platform: UniApp.PLATFORM): string[];
|
|
29
|
+
export declare const parseSubpackagesRootOnce: typeof parseSubpackagesRoot;
|
|
30
|
+
export {};
|
package/dist/json/pages.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageFile = void 0;
|
|
6
|
+
exports.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageFile = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -23,6 +23,13 @@ function isUniPageSfcFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
|
|
23
23
|
return (0, utils_2.isVueSfcFile)(file) && isUniPageFile(file, inputDir);
|
|
24
24
|
}
|
|
25
25
|
exports.isUniPageSfcFile = isUniPageSfcFile;
|
|
26
|
+
/**
|
|
27
|
+
* 小程序平台慎用,因为该解析不支持 subpackages
|
|
28
|
+
* @param inputDir
|
|
29
|
+
* @param platform
|
|
30
|
+
* @param normalize
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
26
33
|
const parsePagesJson = (inputDir, platform, normalize = true) => {
|
|
27
34
|
const jsonStr = fs_1.default.readFileSync(path_1.default.join(inputDir, 'pages.json'), 'utf8');
|
|
28
35
|
if (normalize) {
|
|
@@ -31,6 +38,9 @@ const parsePagesJson = (inputDir, platform, normalize = true) => {
|
|
|
31
38
|
return (0, json_1.parseJson)(jsonStr, true);
|
|
32
39
|
};
|
|
33
40
|
exports.parsePagesJson = parsePagesJson;
|
|
41
|
+
/**
|
|
42
|
+
* 该方法解析出来的是不支持 subpackages,会被合并入 pages
|
|
43
|
+
*/
|
|
34
44
|
exports.parsePagesJsonOnce = (0, uni_shared_1.once)(exports.parsePagesJson);
|
|
35
45
|
/**
|
|
36
46
|
* 目前 App 和 H5 使用了该方法
|
|
@@ -122,7 +132,7 @@ function normalizeSubpackages(subpackages) {
|
|
|
122
132
|
}
|
|
123
133
|
return pages;
|
|
124
134
|
}
|
|
125
|
-
function normalizeSubpackageSubNVues(root, style) {
|
|
135
|
+
function normalizeSubpackageSubNVues(root, style = { navigationBar: {} }) {
|
|
126
136
|
const platformStyle = style['app'] || style['app-plus'];
|
|
127
137
|
if (!platformStyle) {
|
|
128
138
|
return style;
|
|
@@ -351,3 +361,17 @@ function isEnablePullDownRefresh(pageStyle) {
|
|
|
351
361
|
function normalizePullToRefresh(pageStyle) {
|
|
352
362
|
return pageStyle.pullToRefresh;
|
|
353
363
|
}
|
|
364
|
+
function parseSubpackagesRoot(inputDir, platform) {
|
|
365
|
+
const pagesJson = (0, exports.parsePagesJson)(inputDir, platform, false);
|
|
366
|
+
const subpackages = pagesJson.subPackages || pagesJson.subpackages;
|
|
367
|
+
const roots = [];
|
|
368
|
+
if ((0, shared_1.isArray)(subpackages)) {
|
|
369
|
+
subpackages.forEach(({ root }) => {
|
|
370
|
+
if (root) {
|
|
371
|
+
roots.push(root);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return roots;
|
|
376
|
+
}
|
|
377
|
+
exports.parseSubpackagesRootOnce = (0, uni_shared_1.once)(parseSubpackagesRoot);
|
package/dist/mp/template.d.ts
CHANGED
|
@@ -58,5 +58,12 @@ export declare function parseScriptDescriptor(filename: string, ast: Program, op
|
|
|
58
58
|
* @param dynamicImport
|
|
59
59
|
* @returns
|
|
60
60
|
*/
|
|
61
|
-
export declare function transformDynamicImports(code: string, imports: ImportDeclaration[],
|
|
61
|
+
export declare function transformDynamicImports(code: string, imports: ImportDeclaration[], { id, sourceMap, dynamicImport, }: {
|
|
62
|
+
id?: string;
|
|
63
|
+
sourceMap?: boolean;
|
|
64
|
+
dynamicImport: (name: string, source: string) => string;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
code: string;
|
|
67
|
+
map: null;
|
|
68
|
+
}>;
|
|
62
69
|
export {};
|
|
@@ -376,15 +376,21 @@ async function parseVueComponentImports(importer, imports, resolve) {
|
|
|
376
376
|
* @param dynamicImport
|
|
377
377
|
* @returns
|
|
378
378
|
*/
|
|
379
|
-
async function transformDynamicImports(code, imports, dynamicImport) {
|
|
379
|
+
async function transformDynamicImports(code, imports, { id, sourceMap, dynamicImport, }) {
|
|
380
380
|
if (!imports.length) {
|
|
381
|
-
return
|
|
381
|
+
return {
|
|
382
|
+
code,
|
|
383
|
+
map: null,
|
|
384
|
+
};
|
|
382
385
|
}
|
|
383
386
|
const s = new magic_string_1.default(code);
|
|
384
387
|
for (let i = 0; i < imports.length; i++) {
|
|
385
388
|
const { start, end, specifiers: [specifier], source, } = imports[i];
|
|
386
389
|
s.overwrite(start, end, dynamicImport(specifier.local.name, source.value) + ';');
|
|
387
390
|
}
|
|
388
|
-
return
|
|
391
|
+
return {
|
|
392
|
+
code: s.toString(),
|
|
393
|
+
map: null,
|
|
394
|
+
};
|
|
389
395
|
}
|
|
390
396
|
exports.transformDynamicImports = transformDynamicImports;
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPlatforms = exports.registerPlatform = void 0;
|
|
4
|
+
const BUILT_IN_PLATFORMS = [
|
|
5
|
+
'app',
|
|
6
|
+
'app-plus',
|
|
7
|
+
'h5',
|
|
8
|
+
'mp-360',
|
|
9
|
+
'mp-alipay',
|
|
10
|
+
'mp-baidu',
|
|
11
|
+
'mp-jd',
|
|
12
|
+
'mp-kuaishou',
|
|
13
|
+
'mp-lark',
|
|
14
|
+
'mp-qq',
|
|
15
|
+
'mp-toutiao',
|
|
16
|
+
'mp-weixin',
|
|
17
|
+
'quickapp-webview',
|
|
18
|
+
'quickapp-webview-huawei',
|
|
19
|
+
'quickapp-webview-union',
|
|
20
|
+
];
|
|
21
|
+
const platforms = [...BUILT_IN_PLATFORMS];
|
|
22
|
+
function registerPlatform(platform) {
|
|
23
|
+
if (!platforms.includes(platform)) {
|
|
24
|
+
platforms.push(platform);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.registerPlatform = registerPlatform;
|
|
28
|
+
function getPlatforms() {
|
|
29
|
+
return platforms;
|
|
30
|
+
}
|
|
31
|
+
exports.getPlatforms = getPlatforms;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { WatchOptions } from 'chokidar';
|
|
1
2
|
import type { Plugin } from 'vite';
|
|
2
3
|
import { FileWatcherOptions } from '../../watcher';
|
|
3
|
-
export declare type UniViteCopyPluginTarget = Omit<FileWatcherOptions, 'verbose'
|
|
4
|
+
export declare type UniViteCopyPluginTarget = Omit<FileWatcherOptions, 'verbose'> & {
|
|
5
|
+
watchOptions?: WatchOptions;
|
|
6
|
+
};
|
|
4
7
|
export interface UniViteCopyPluginOptions {
|
|
5
8
|
targets: UniViteCopyPluginTarget[];
|
|
6
9
|
verbose: boolean;
|
|
@@ -21,13 +21,14 @@ function uniViteCopyPlugin({ targets, verbose, }) {
|
|
|
21
21
|
}
|
|
22
22
|
inited = true;
|
|
23
23
|
return new Promise((resolve) => {
|
|
24
|
-
Promise.all(targets.map((target) => {
|
|
24
|
+
Promise.all(targets.map(({ watchOptions, ...target }) => {
|
|
25
25
|
return new Promise((resolve) => {
|
|
26
26
|
new watcher_1.FileWatcher({
|
|
27
27
|
verbose,
|
|
28
28
|
...target,
|
|
29
29
|
}).watch({
|
|
30
30
|
cwd: process.env.UNI_INPUT_DIR,
|
|
31
|
+
...watchOptions,
|
|
31
32
|
}, (watcher) => {
|
|
32
33
|
if (process.env.NODE_ENV !== 'development') {
|
|
33
34
|
// 生产模式下,延迟 close,否则会影响 chokidar 初始化的 add 等事件
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import type { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
|
|
2
3
|
import { Plugin } from '../plugin';
|
|
3
4
|
import { ResolvedConfig } from '../config';
|
|
4
|
-
import type { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
|
|
5
5
|
export declare const assetUrlRE: RegExp;
|
|
6
6
|
export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>>;
|
|
7
7
|
/**
|
|
@@ -27,9 +27,10 @@ const path_1 = __importDefault(require("path"));
|
|
|
27
27
|
const url_1 = require("url");
|
|
28
28
|
const lite_1 = __importDefault(require("mime/lite"));
|
|
29
29
|
const fs_1 = __importStar(require("fs"));
|
|
30
|
-
const utils_1 = require("../utils");
|
|
31
30
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
32
31
|
const crypto_1 = require("crypto");
|
|
32
|
+
const utils_1 = require("../utils");
|
|
33
|
+
const utils_2 = require("../../../../vite/utils/utils");
|
|
33
34
|
exports.assetUrlRE = /__VITE_ASSET__([a-z\d]{8})__(?:\$_(.*?)__)?/g;
|
|
34
35
|
// urls in JS must be quoted as strings, so when replacing them we need
|
|
35
36
|
// a different regex
|
|
@@ -99,7 +100,7 @@ function assetPlugin(config) {
|
|
|
99
100
|
if (s) {
|
|
100
101
|
return {
|
|
101
102
|
code: s.toString(),
|
|
102
|
-
map: config
|
|
103
|
+
map: (0, utils_2.withSourcemap)(config) ? s.generateMap({ hires: true }) : null,
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
106
|
else {
|
|
@@ -2,5 +2,6 @@ import type { ResolvedConfig } from 'vite';
|
|
|
2
2
|
export * from './ast';
|
|
3
3
|
export * from './url';
|
|
4
4
|
export * from './plugin';
|
|
5
|
+
export * from './utils';
|
|
5
6
|
export declare const buildInCssSet: Set<string>;
|
|
6
7
|
export declare function isCombineBuiltInCss(config: ResolvedConfig): boolean;
|
package/dist/vite/utils/index.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.isCombineBuiltInCss = exports.buildInCssSet = void 0;
|
|
|
14
14
|
__exportStar(require("./ast"), exports);
|
|
15
15
|
__exportStar(require("./url"), exports);
|
|
16
16
|
__exportStar(require("./plugin"), exports);
|
|
17
|
+
__exportStar(require("./utils"), exports);
|
|
17
18
|
// 内置组件css列表,h5平台需要合并进去首页css中
|
|
18
19
|
exports.buildInCssSet = new Set();
|
|
19
20
|
function isCombineBuiltInCss(config) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withSourcemap = void 0;
|
|
4
|
+
function withSourcemap(config) {
|
|
5
|
+
if (config.command === 'serve') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
return !!config.build.sourcemap;
|
|
9
|
+
}
|
|
10
|
+
exports.withSourcemap = withSourcemap;
|
package/dist/watcher.js
CHANGED
|
@@ -57,14 +57,14 @@ class FileWatcher {
|
|
|
57
57
|
if (content) {
|
|
58
58
|
return fs_extra_1.default
|
|
59
59
|
.outputFile(to, content)
|
|
60
|
-
.catch((
|
|
60
|
+
.catch(() => {
|
|
61
61
|
// this.info('copy', e)
|
|
62
62
|
})
|
|
63
63
|
.then(() => this.onChange && this.onChange());
|
|
64
64
|
}
|
|
65
65
|
return fs_extra_1.default
|
|
66
66
|
.copy(this.from(from), to, { overwrite: true })
|
|
67
|
-
.catch((
|
|
67
|
+
.catch(() => {
|
|
68
68
|
// this.info('copy', e)
|
|
69
69
|
})
|
|
70
70
|
.then(() => this.onChange && this.onChange());
|
|
@@ -74,7 +74,7 @@ class FileWatcher {
|
|
|
74
74
|
this.info('remove', from + '=>' + to);
|
|
75
75
|
return fs_extra_1.default
|
|
76
76
|
.remove(to)
|
|
77
|
-
.catch((
|
|
77
|
+
.catch(() => {
|
|
78
78
|
// this.info('remove', e)
|
|
79
79
|
})
|
|
80
80
|
.then(() => this.onChange && this.onChange());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-3030520211229003",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@babel/core": "^7.16.5",
|
|
22
22
|
"@babel/parser": "^7.16.4",
|
|
23
23
|
"@babel/types": "^7.16.0",
|
|
24
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
25
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
24
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3030520211229003",
|
|
25
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3030520211229003",
|
|
26
26
|
"@rollup/pluginutils": "^4.1.2",
|
|
27
27
|
"@vue/compiler-core": "3.2.26",
|
|
28
28
|
"@vue/compiler-dom": "3.2.26",
|