@dcloudio/uni-cli-shared 3.0.0-alpha-3030720220111001 → 3.0.0-alpha-3030720220111002
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/checkUpdate.js +1 -1
- package/dist/easycom.js +1 -1
- package/dist/mp/ast.d.ts +4 -0
- package/dist/mp/ast.js +12 -0
- package/dist/mp/externalClasses.d.ts +5 -0
- package/dist/mp/externalClasses.js +42 -0
- package/dist/mp/index.d.ts +3 -1
- package/dist/mp/index.js +7 -2
- package/dist/mp/usingComponents.d.ts +0 -4
- package/dist/mp/usingComponents.js +1 -9
- package/dist/vite/plugins/console.js +2 -2
- package/dist/vite/plugins/copy.js +1 -1
- package/dist/vite/plugins/cssScoped.js +2 -2
- package/dist/vite/plugins/inject.js +3 -3
- package/dist/vite/utils/plugin.js +10 -1
- package/package.json +3 -3
package/dist/checkUpdate.js
CHANGED
|
@@ -14,7 +14,7 @@ const compare_versions_1 = __importDefault(require("compare-versions"));
|
|
|
14
14
|
const shared_1 = require("@vue/shared");
|
|
15
15
|
const json_1 = require("./json");
|
|
16
16
|
const hbx_1 = require("./hbx");
|
|
17
|
-
const debugCheckUpdate = (0, debug_1.default)('
|
|
17
|
+
const debugCheckUpdate = (0, debug_1.default)('uni:check-update');
|
|
18
18
|
const INTERVAL = 1000 * 60 * 60 * 24;
|
|
19
19
|
async function checkUpdate(options) {
|
|
20
20
|
if (process.env.CI) {
|
package/dist/easycom.js
CHANGED
|
@@ -13,7 +13,7 @@ const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
const pages_1 = require("./json/pages");
|
|
15
15
|
const messages_1 = require("./messages");
|
|
16
|
-
const debugEasycom = (0, debug_1.default)('
|
|
16
|
+
const debugEasycom = (0, debug_1.default)('uni:easycom');
|
|
17
17
|
const easycoms = [];
|
|
18
18
|
const easycomsCache = new Map();
|
|
19
19
|
const easycomsInvalidCache = new Set();
|
package/dist/mp/ast.d.ts
ADDED
package/dist/mp/ast.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseProgram = void 0;
|
|
4
|
+
const parser_1 = require("@babel/parser");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
function parseProgram(code, importer, { babelParserPlugins }) {
|
|
7
|
+
return (0, parser_1.parse)(code, {
|
|
8
|
+
plugins: (0, utils_1.normalizeParsePlugins)(importer, babelParserPlugins),
|
|
9
|
+
sourceType: 'module',
|
|
10
|
+
}).program;
|
|
11
|
+
}
|
|
12
|
+
exports.parseProgram = parseProgram;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Program } from '@babel/types';
|
|
2
|
+
export declare function hasExternalClasses(code: string): boolean;
|
|
3
|
+
export declare function findMiniProgramComponentExternalClasses(filename: string): string[] | undefined;
|
|
4
|
+
export declare function updateMiniProgramComponentExternalClasses(filename: string, classes: string[]): void;
|
|
5
|
+
export declare function parseExternalClasses(ast: Program): string[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseExternalClasses = exports.updateMiniProgramComponentExternalClasses = exports.findMiniProgramComponentExternalClasses = exports.hasExternalClasses = void 0;
|
|
4
|
+
const types_1 = require("@babel/types");
|
|
5
|
+
const estree_walker_1 = require("estree-walker");
|
|
6
|
+
const externalClassesCache = new Map();
|
|
7
|
+
function hasExternalClasses(code) {
|
|
8
|
+
return code.includes('externalClasses');
|
|
9
|
+
}
|
|
10
|
+
exports.hasExternalClasses = hasExternalClasses;
|
|
11
|
+
function findMiniProgramComponentExternalClasses(filename) {
|
|
12
|
+
return externalClassesCache.get(filename);
|
|
13
|
+
}
|
|
14
|
+
exports.findMiniProgramComponentExternalClasses = findMiniProgramComponentExternalClasses;
|
|
15
|
+
function updateMiniProgramComponentExternalClasses(filename, classes) {
|
|
16
|
+
externalClassesCache.set(filename, classes);
|
|
17
|
+
}
|
|
18
|
+
exports.updateMiniProgramComponentExternalClasses = updateMiniProgramComponentExternalClasses;
|
|
19
|
+
function parseExternalClasses(ast) {
|
|
20
|
+
const classes = [];
|
|
21
|
+
estree_walker_1.walk(ast, {
|
|
22
|
+
enter(child, parent) {
|
|
23
|
+
if (!(0, types_1.isIdentifier)(child) || child.name !== 'externalClasses') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// export default { externalClasses: ['my-class'] }
|
|
27
|
+
if (!(0, types_1.isObjectProperty)(parent)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!(0, types_1.isArrayExpression)(parent.value)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
parent.value.elements.forEach((element) => {
|
|
34
|
+
if ((0, types_1.isStringLiteral)(element)) {
|
|
35
|
+
classes.push(element.value);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return classes;
|
|
41
|
+
}
|
|
42
|
+
exports.parseExternalClasses = parseExternalClasses;
|
package/dist/mp/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './ast';
|
|
1
2
|
export * from './nvue';
|
|
2
3
|
export * from './event';
|
|
3
4
|
export * from './style';
|
|
@@ -5,4 +6,5 @@ export * from './template';
|
|
|
5
6
|
export * from './constants';
|
|
6
7
|
export { HTML_TO_MINI_PROGRAM_TAGS } from './tags';
|
|
7
8
|
export { copyMiniProgramPluginJson } from './plugin';
|
|
8
|
-
export {
|
|
9
|
+
export { parseMainDescriptor, parseScriptDescriptor, parseTemplateDescriptor, transformDynamicImports, updateMiniProgramGlobalComponents, updateMiniProgramComponentsByMainFilename, updateMiniProgramComponentsByScriptFilename, updateMiniProgramComponentsByTemplateFilename, } from './usingComponents';
|
|
10
|
+
export { hasExternalClasses, parseExternalClasses, findMiniProgramComponentExternalClasses, updateMiniProgramComponentExternalClasses, } from './externalClasses';
|
package/dist/mp/index.js
CHANGED
|
@@ -10,7 +10,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.transformDynamicImports = exports.parseTemplateDescriptor = exports.parseScriptDescriptor = exports.parseMainDescriptor = exports.
|
|
13
|
+
exports.updateMiniProgramComponentExternalClasses = exports.findMiniProgramComponentExternalClasses = exports.parseExternalClasses = exports.hasExternalClasses = exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.transformDynamicImports = exports.parseTemplateDescriptor = exports.parseScriptDescriptor = exports.parseMainDescriptor = exports.copyMiniProgramPluginJson = exports.HTML_TO_MINI_PROGRAM_TAGS = void 0;
|
|
14
|
+
__exportStar(require("./ast"), exports);
|
|
14
15
|
__exportStar(require("./nvue"), exports);
|
|
15
16
|
__exportStar(require("./event"), exports);
|
|
16
17
|
__exportStar(require("./style"), exports);
|
|
@@ -21,7 +22,6 @@ Object.defineProperty(exports, "HTML_TO_MINI_PROGRAM_TAGS", { enumerable: true,
|
|
|
21
22
|
var plugin_1 = require("./plugin");
|
|
22
23
|
Object.defineProperty(exports, "copyMiniProgramPluginJson", { enumerable: true, get: function () { return plugin_1.copyMiniProgramPluginJson; } });
|
|
23
24
|
var usingComponents_1 = require("./usingComponents");
|
|
24
|
-
Object.defineProperty(exports, "parseProgram", { enumerable: true, get: function () { return usingComponents_1.parseProgram; } });
|
|
25
25
|
Object.defineProperty(exports, "parseMainDescriptor", { enumerable: true, get: function () { return usingComponents_1.parseMainDescriptor; } });
|
|
26
26
|
Object.defineProperty(exports, "parseScriptDescriptor", { enumerable: true, get: function () { return usingComponents_1.parseScriptDescriptor; } });
|
|
27
27
|
Object.defineProperty(exports, "parseTemplateDescriptor", { enumerable: true, get: function () { return usingComponents_1.parseTemplateDescriptor; } });
|
|
@@ -30,3 +30,8 @@ Object.defineProperty(exports, "updateMiniProgramGlobalComponents", { enumerable
|
|
|
30
30
|
Object.defineProperty(exports, "updateMiniProgramComponentsByMainFilename", { enumerable: true, get: function () { return usingComponents_1.updateMiniProgramComponentsByMainFilename; } });
|
|
31
31
|
Object.defineProperty(exports, "updateMiniProgramComponentsByScriptFilename", { enumerable: true, get: function () { return usingComponents_1.updateMiniProgramComponentsByScriptFilename; } });
|
|
32
32
|
Object.defineProperty(exports, "updateMiniProgramComponentsByTemplateFilename", { enumerable: true, get: function () { return usingComponents_1.updateMiniProgramComponentsByTemplateFilename; } });
|
|
33
|
+
var externalClasses_1 = require("./externalClasses");
|
|
34
|
+
Object.defineProperty(exports, "hasExternalClasses", { enumerable: true, get: function () { return externalClasses_1.hasExternalClasses; } });
|
|
35
|
+
Object.defineProperty(exports, "parseExternalClasses", { enumerable: true, get: function () { return externalClasses_1.parseExternalClasses; } });
|
|
36
|
+
Object.defineProperty(exports, "findMiniProgramComponentExternalClasses", { enumerable: true, get: function () { return externalClasses_1.findMiniProgramComponentExternalClasses; } });
|
|
37
|
+
Object.defineProperty(exports, "updateMiniProgramComponentExternalClasses", { enumerable: true, get: function () { return externalClasses_1.updateMiniProgramComponentExternalClasses; } });
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { ImportDeclaration, Program } from '@babel/types';
|
|
2
|
-
import { ParserPlugin } from '@babel/parser';
|
|
3
2
|
import type { PluginContext } from 'rollup';
|
|
4
3
|
declare type BindingComponents = Record<string, {
|
|
5
4
|
tag: string;
|
|
6
5
|
type: 'unknown' | 'setup' | 'self';
|
|
7
6
|
}>;
|
|
8
|
-
export declare function parseProgram(code: string, importer: string, { babelParserPlugins }: {
|
|
9
|
-
babelParserPlugins?: ParserPlugin[];
|
|
10
|
-
}): Program;
|
|
11
7
|
interface MainDescriptor {
|
|
12
8
|
imports: ImportDeclaration[];
|
|
13
9
|
script: string;
|
|
@@ -3,9 +3,8 @@ 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.transformDynamicImports = exports.parseScriptDescriptor = exports.parseTemplateDescriptor = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.parseMainDescriptor =
|
|
6
|
+
exports.transformDynamicImports = exports.parseScriptDescriptor = exports.parseTemplateDescriptor = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.parseMainDescriptor = void 0;
|
|
7
7
|
const types_1 = require("@babel/types");
|
|
8
|
-
const parser_1 = require("@babel/parser");
|
|
9
8
|
const estree_walker_1 = require("estree-walker");
|
|
10
9
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
11
10
|
const shared_1 = require("@vue/shared");
|
|
@@ -15,13 +14,6 @@ const constants_1 = require("../constants");
|
|
|
15
14
|
const utils_1 = require("../utils");
|
|
16
15
|
const utils_2 = require("../vite/utils");
|
|
17
16
|
const jsonFile_1 = require("../json/mp/jsonFile");
|
|
18
|
-
function parseProgram(code, importer, { babelParserPlugins }) {
|
|
19
|
-
return (0, parser_1.parse)(code, {
|
|
20
|
-
plugins: (0, utils_1.normalizeParsePlugins)(importer, babelParserPlugins),
|
|
21
|
-
sourceType: 'module',
|
|
22
|
-
}).program;
|
|
23
|
-
}
|
|
24
|
-
exports.parseProgram = parseProgram;
|
|
25
17
|
const mainDescriptors = new Map();
|
|
26
18
|
const scriptDescriptors = new Map();
|
|
27
19
|
const templateDescriptors = new Map();
|
|
@@ -9,12 +9,12 @@ const pluginutils_1 = require("@rollup/pluginutils");
|
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const console_1 = require("../../logs/console");
|
|
11
11
|
const utils_2 = require("../../vite/utils/utils");
|
|
12
|
-
const debugConsole = (0, debug_1.default)('
|
|
12
|
+
const debugConsole = (0, debug_1.default)('uni:console');
|
|
13
13
|
function uniConsolePlugin(options) {
|
|
14
14
|
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
|
15
15
|
let resolvedConfig;
|
|
16
16
|
return {
|
|
17
|
-
name: '
|
|
17
|
+
name: 'uni:console',
|
|
18
18
|
enforce: 'pre',
|
|
19
19
|
configResolved(config) {
|
|
20
20
|
resolvedConfig = config;
|
|
@@ -8,7 +8,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const debug_1 = __importDefault(require("debug"));
|
|
9
9
|
const constants_1 = require("../../constants");
|
|
10
10
|
const preprocess_1 = require("../../preprocess");
|
|
11
|
-
const debugScoped = (0, debug_1.default)('
|
|
11
|
+
const debugScoped = (0, debug_1.default)('uni:scoped');
|
|
12
12
|
const SCOPED_RE = /<style\s[^>]*scoped[^>]*>/i;
|
|
13
13
|
function addScoped(code) {
|
|
14
14
|
if (SCOPED_RE.test(code)) {
|
|
@@ -18,7 +18,7 @@ function addScoped(code) {
|
|
|
18
18
|
}
|
|
19
19
|
function uniCssScopedPlugin({ filter } = { filter: () => false }) {
|
|
20
20
|
return {
|
|
21
|
-
name: '
|
|
21
|
+
name: 'uni:css-scoped',
|
|
22
22
|
enforce: 'pre',
|
|
23
23
|
transform(code, id) {
|
|
24
24
|
if (!filter(id))
|
|
@@ -11,8 +11,8 @@ const estree_walker_1 = require("estree-walker");
|
|
|
11
11
|
const shared_1 = require("@vue/shared");
|
|
12
12
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
|
-
const debugInject = (0, debug_1.default)('
|
|
15
|
-
const debugInjectTry = (0, debug_1.default)('
|
|
14
|
+
const debugInject = (0, debug_1.default)('uni:inject');
|
|
15
|
+
const debugInjectTry = (0, debug_1.default)('uni:inject-try');
|
|
16
16
|
function uniViteInjectPlugin(options) {
|
|
17
17
|
if (!options)
|
|
18
18
|
throw new Error('Missing options');
|
|
@@ -41,7 +41,7 @@ function uniViteInjectPlugin(options) {
|
|
|
41
41
|
const sourceMap = options.sourceMap !== false;
|
|
42
42
|
const callback = options.callback;
|
|
43
43
|
return {
|
|
44
|
-
name: '
|
|
44
|
+
name: 'uni:inject',
|
|
45
45
|
// 确保在 commonjs 之后,否则会混合 es6 module 与 cjs 的代码,导致 commonjs 失效
|
|
46
46
|
enforce: 'post',
|
|
47
47
|
transform(code, id) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.removePlugins = exports.replacePlugins = exports.injectCssPostPlugin = exports.injectCssPlugin = exports.injectAssetPlugin = void 0;
|
|
4
|
+
const shared_1 = require("@vue/shared");
|
|
4
5
|
const asset_1 = require("../plugins/vitejs/plugins/asset");
|
|
5
6
|
const css_1 = require("../plugins/vitejs/plugins/css");
|
|
6
7
|
function injectAssetPlugin(config) {
|
|
@@ -12,7 +13,15 @@ function injectCssPlugin(config) {
|
|
|
12
13
|
}
|
|
13
14
|
exports.injectCssPlugin = injectCssPlugin;
|
|
14
15
|
function injectCssPostPlugin(config, { chunkCssFilename, chunkCssCode, }) {
|
|
15
|
-
|
|
16
|
+
const newCssPostPlugin = (0, css_1.cssPostPlugin)(config, {
|
|
17
|
+
chunkCssFilename,
|
|
18
|
+
chunkCssCode,
|
|
19
|
+
});
|
|
20
|
+
const oldCssPostPlugin = config.plugins.find((p) => p.name === newCssPostPlugin.name);
|
|
21
|
+
// 直接覆盖原有方法,不能删除,替换,因为 unocss 在 pre 阶段已经获取到了旧的 css-post 插件对象
|
|
22
|
+
if (oldCssPostPlugin) {
|
|
23
|
+
(0, shared_1.extend)(oldCssPostPlugin, newCssPostPlugin);
|
|
24
|
+
}
|
|
16
25
|
}
|
|
17
26
|
exports.injectCssPostPlugin = injectCssPostPlugin;
|
|
18
27
|
function replacePlugins(plugins, config) {
|
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-3030720220111002",
|
|
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-3030720220111002",
|
|
25
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3030720220111002",
|
|
26
26
|
"@rollup/pluginutils": "^4.1.2",
|
|
27
27
|
"@vue/compiler-core": "3.2.26",
|
|
28
28
|
"@vue/compiler-dom": "3.2.26",
|