@dcloudio/uni-cli-shared 3.0.0-4080720251210001 → 3.0.0-5000420260317001
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/constants.d.ts +3 -0
- package/dist/constants.js +6 -1
- package/dist/deps.js +6 -1
- package/dist/dom2/index.d.ts +1 -0
- package/dist/dom2/index.js +17 -0
- package/dist/dom2/sharedData.d.ts +2 -0
- package/dist/dom2/sharedData.js +19 -0
- package/dist/easycom.js +34 -5
- package/dist/env/define.d.ts +3 -0
- package/dist/env/define.js +12 -0
- package/dist/hbx/alias.js +15 -17
- package/dist/hbx/index.d.ts +1 -1
- package/dist/hbx/index.js +4 -2
- package/dist/hbx/log.d.ts +5 -0
- package/dist/hbx/log.js +44 -1
- package/dist/i18n.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/json/app/manifest/index.d.ts +1 -0
- package/dist/json/app/manifest/index.js +3 -1
- package/dist/json/mp/pages.js +0 -5
- package/dist/json/pages.d.ts +2 -2
- package/dist/json/pages.js +4 -1
- package/dist/json/uni-x/index.d.ts +1 -1
- package/dist/json/utils.js +31 -22
- package/dist/logs/console.js +1 -1
- package/dist/logs/index.d.ts +11 -0
- package/dist/logs/index.js +34 -1
- package/dist/messages/en.d.ts +6 -3
- package/dist/messages/en.js +6 -3
- package/dist/messages/index.d.ts +11 -5
- package/dist/messages/zh_CN.d.ts +5 -2
- package/dist/messages/zh_CN.js +5 -2
- package/dist/mp/assets.d.ts +1 -0
- package/dist/mp/assets.js +27 -1
- package/dist/mp/externalClasses.d.ts +38 -2
- package/dist/mp/externalClasses.js +90 -4
- package/dist/mp/index.d.ts +4 -3
- package/dist/mp/index.js +11 -1
- package/dist/mp/plugin.d.ts +1 -0
- package/dist/mp/plugin.js +14 -1
- package/dist/mp/style.d.ts +1 -0
- package/dist/mp/style.js +8 -1
- package/dist/mp/usingComponents.d.ts +1 -0
- package/dist/mp/usingComponents.js +17 -1
- package/dist/postcss/index.d.ts +2 -0
- package/dist/postcss/index.js +3 -1
- package/dist/postcss/plugins/stylePluginExternal.d.ts +17 -0
- package/dist/postcss/plugins/stylePluginExternal.js +127 -0
- package/dist/postcss/plugins/stylePluginScoped.js +30 -0
- package/dist/preprocess/context.js +2 -0
- package/dist/preprocess/index.d.ts +9 -6
- package/dist/preprocess/index.js +33 -8
- package/dist/resolve.js +5 -1
- package/dist/uni_modules.js +20 -4
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +9 -6
- package/dist/utsUtils.d.ts +1 -0
- package/dist/utsUtils.js +2 -1
- package/dist/vite/autoImport.js +91 -6
- package/dist/vite/plugins/console.js +1 -1
- package/dist/vite/plugins/cssScoped.js +2 -1
- package/dist/vite/plugins/easycom.js +7 -0
- package/dist/vite/plugins/json.js +69 -2
- package/dist/vite/plugins/pre.js +4 -2
- package/dist/vite/plugins/sfc.js +1 -1
- package/dist/vite/plugins/stats.js +32 -0
- package/dist/vite/plugins/uts/ext-api.js +1 -1
- package/dist/vite/plugins/uts/uni_modules.js +12 -0
- package/dist/vite/plugins/uts/uvue.js +7 -2
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -0
- package/dist/vite/plugins/vitejs/plugins/asset.js +19 -1
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +2 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +27 -10
- package/dist/vite/utils/ast.d.ts +2 -1
- package/dist/vite/utils/ast.js +5 -1
- package/dist/vue/parse.d.ts +2 -0
- package/dist/vue/parse.js +3 -1
- package/dist/vue/transforms/index.d.ts +1 -0
- package/dist/vue/transforms/index.js +1 -0
- package/dist/vue/transforms/transformLineBreak.d.ts +2 -0
- package/dist/vue/transforms/transformLineBreak.js +15 -0
- package/dist/vue/transforms/transformTag.d.ts +1 -1
- package/dist/vue/transforms/transformTag.js +5 -0
- package/dist/vue/transforms/x/transformMPBuiltInTag.js +2 -2
- package/dist/vue/utils.js +8 -1
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.js +42 -23
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.prod.js +42 -23
- package/lib/@vue/compiler-core/dist/compiler-core.esm-bundler.js +39 -19
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +4635 -1024
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +8762 -7849
- package/lib/dom2/app/@vitejs/plugin-vue/LICENSE +21 -0
- package/lib/dom2/app/@vitejs/plugin-vue/README.md +278 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.cjs +3353 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.d.cts +113 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.d.mts +111 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.d.ts +113 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.mjs +3338 -0
- package/lib/dom2/app/@vitejs/plugin-vue/package.json +50 -0
- package/lib/dom2/app/@vue/compiler-core/LICENSE +21 -0
- package/lib/dom2/app/@vue/compiler-core/README.md +1 -0
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +5492 -0
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +5436 -0
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.d.ts +1187 -0
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +4335 -0
- package/lib/dom2/app/@vue/compiler-core/index.js +7 -0
- package/lib/dom2/app/@vue/compiler-core/package.json +58 -0
- package/lib/dom2/app/@vue/compiler-dom/LICENSE +21 -0
- package/lib/dom2/app/@vue/compiler-dom/README.md +1 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +762 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +736 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.d.ts +73 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +5051 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +11 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +557 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +5234 -0
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +11 -0
- package/lib/dom2/app/@vue/compiler-dom/index.js +7 -0
- package/lib/dom2/app/@vue/compiler-dom/package.json +57 -0
- package/lib/dom2/app/@vue/compiler-sfc/LICENSE +21 -0
- package/lib/dom2/app/@vue/compiler-sfc/README.md +80 -0
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +15528 -0
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.d.ts +11595 -0
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +41525 -0
- package/lib/dom2/app/@vue/compiler-sfc/package.json +68 -0
- package/lib/dom2/app/@vue/compiler-vapor/LICENSE +21 -0
- package/lib/dom2/app/@vue/compiler-vapor/README.md +1 -0
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +3584 -0
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +22858 -0
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +22438 -0
- package/lib/dom2/app/@vue/compiler-vapor/package.json +51 -0
- package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -0
- package/lib/dom2/app/@vue/compiler-vapor-dom2/package.json +56 -0
- package/lib/dom2/app/@vue/shared/LICENSE +21 -0
- package/lib/dom2/app/@vue/shared/README.md +3 -0
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.js +773 -0
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +773 -0
- package/lib/dom2/app/@vue/shared/dist/shared.d.ts +412 -0
- package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +688 -0
- package/lib/dom2/app/@vue/shared/index.js +7 -0
- package/lib/dom2/app/@vue/shared/package.json +47 -0
- package/lib/preprocess/lib/preprocess.js +9 -3
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.js +1 -1
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.prod.js +1 -1
- package/package.json +8 -6
|
@@ -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.transformDynamicImports = exports.parseScriptDescriptor = exports.parseTemplateDescriptor = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.parseMainDescriptor = void 0;
|
|
6
|
+
exports.transformDynamicImports = exports.parseScriptDescriptor = exports.parseTemplateDescriptor = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.parseMainDescriptor = exports.getGlobalComponentSource = void 0;
|
|
7
7
|
const types_1 = require("@babel/types");
|
|
8
8
|
const estree_walker_1 = require("estree-walker");
|
|
9
9
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
@@ -17,6 +17,12 @@ const jsonFile_1 = require("../json/mp/jsonFile");
|
|
|
17
17
|
const mainDescriptors = new Map();
|
|
18
18
|
const scriptDescriptors = new Map();
|
|
19
19
|
const templateDescriptors = new Map();
|
|
20
|
+
// 存储全局组件名到完整源文件路径的映射
|
|
21
|
+
const globalComponentSourceMap = new Map();
|
|
22
|
+
function getGlobalComponentSource(componentName) {
|
|
23
|
+
return globalComponentSourceMap.get(componentName);
|
|
24
|
+
}
|
|
25
|
+
exports.getGlobalComponentSource = getGlobalComponentSource;
|
|
20
26
|
function findImportTemplateSource(ast) {
|
|
21
27
|
const importDeclaration = ast.body.find((node) => (0, types_1.isImportDeclaration)(node) &&
|
|
22
28
|
node.source.value.includes('vue&type=template'));
|
|
@@ -84,6 +90,16 @@ function findMainFilenameByTemplateFilename(templateFilename) {
|
|
|
84
90
|
}
|
|
85
91
|
async function updateMiniProgramGlobalComponents(filename, ast, { inputDir, resolve, normalizeComponentName, }) {
|
|
86
92
|
const { bindingComponents, imports } = await parseGlobalDescriptor(filename, ast, resolve);
|
|
93
|
+
// 存储全局组件名到完整源文件路径的映射
|
|
94
|
+
imports.forEach(({ source: { value }, specifiers: [specifier] }) => {
|
|
95
|
+
const { name } = specifier.local;
|
|
96
|
+
if (!bindingComponents[name]) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!globalComponentSourceMap.has(bindingComponents[name].tag)) {
|
|
100
|
+
globalComponentSourceMap.set(bindingComponents[name].tag, value);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
87
103
|
(0, jsonFile_1.addMiniProgramUsingComponents)('app', createUsingComponents(bindingComponents, imports, inputDir, normalizeComponentName));
|
|
88
104
|
return {
|
|
89
105
|
imports,
|
package/dist/postcss/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Plugin } from 'postcss';
|
|
2
2
|
import type { Options } from 'autoprefixer';
|
|
3
3
|
import uniPostcssScopedPlugin from './plugins/stylePluginScoped';
|
|
4
|
+
import uniPostcssExternalPlugin from './plugins/stylePluginExternal';
|
|
4
5
|
import uniPostcssPlugin, { type UniAppCssProcessorOptions } from './plugins/uniapp';
|
|
5
6
|
export { uniPostcssPlugin };
|
|
6
7
|
export { uniPostcssScopedPlugin };
|
|
8
|
+
export { uniPostcssExternalPlugin };
|
|
7
9
|
export declare function initPostcssPlugin({ uniApp, autoprefixer, }?: {
|
|
8
10
|
uniApp?: UniAppCssProcessorOptions;
|
|
9
11
|
autoprefixer?: Options | false;
|
package/dist/postcss/index.js
CHANGED
|
@@ -3,9 +3,11 @@ 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.initPostcssPlugin = exports.uniPostcssScopedPlugin = exports.uniPostcssPlugin = void 0;
|
|
6
|
+
exports.initPostcssPlugin = exports.uniPostcssExternalPlugin = exports.uniPostcssScopedPlugin = exports.uniPostcssPlugin = void 0;
|
|
7
7
|
const stylePluginScoped_1 = __importDefault(require("./plugins/stylePluginScoped"));
|
|
8
8
|
exports.uniPostcssScopedPlugin = stylePluginScoped_1.default;
|
|
9
|
+
const stylePluginExternal_1 = __importDefault(require("./plugins/stylePluginExternal"));
|
|
10
|
+
exports.uniPostcssExternalPlugin = stylePluginExternal_1.default;
|
|
9
11
|
const uniapp_1 = __importDefault(require("./plugins/uniapp"));
|
|
10
12
|
exports.uniPostcssPlugin = uniapp_1.default;
|
|
11
13
|
function initPostcssPlugin({ uniApp, autoprefixer, } = {}) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PluginCreator } from 'postcss';
|
|
2
|
+
/**
|
|
3
|
+
* PostCSS plugin to boost specificity for page CSS based on externalClasses usage
|
|
4
|
+
*
|
|
5
|
+
* For mini-program platforms (mp-*):
|
|
6
|
+
* - If page has no externalClasses usage: no transformation
|
|
7
|
+
* - If page has dynamic externalClasses: all selectors get page prefix
|
|
8
|
+
* .a -> page .a
|
|
9
|
+
* - If page has only static externalClasses: only matching selectors get page prefix
|
|
10
|
+
* .foo -> page .foo (if "foo" is in staticClasses)
|
|
11
|
+
* .bar -> .bar (unchanged, if "bar" is not in staticClasses)
|
|
12
|
+
*
|
|
13
|
+
* This ensures page styles have higher specificity than component styles
|
|
14
|
+
* while minimizing unnecessary transformations for performance
|
|
15
|
+
*/
|
|
16
|
+
declare const externalPlugin: PluginCreator<void>;
|
|
17
|
+
export default externalPlugin;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
|
|
7
|
+
const pages_1 = require("../../json/pages");
|
|
8
|
+
const externalClasses_1 = require("../../mp/externalClasses");
|
|
9
|
+
/**
|
|
10
|
+
* PostCSS plugin to boost specificity for page CSS based on externalClasses usage
|
|
11
|
+
*
|
|
12
|
+
* For mini-program platforms (mp-*):
|
|
13
|
+
* - If page has no externalClasses usage: no transformation
|
|
14
|
+
* - If page has dynamic externalClasses: all selectors get page prefix
|
|
15
|
+
* .a -> page .a
|
|
16
|
+
* - If page has only static externalClasses: only matching selectors get page prefix
|
|
17
|
+
* .foo -> page .foo (if "foo" is in staticClasses)
|
|
18
|
+
* .bar -> .bar (unchanged, if "bar" is not in staticClasses)
|
|
19
|
+
*
|
|
20
|
+
* This ensures page styles have higher specificity than component styles
|
|
21
|
+
* while minimizing unnecessary transformations for performance
|
|
22
|
+
*/
|
|
23
|
+
const externalPlugin = () => {
|
|
24
|
+
return {
|
|
25
|
+
postcssPlugin: 'uni-external',
|
|
26
|
+
prepare() {
|
|
27
|
+
const processedRules = new WeakSet();
|
|
28
|
+
return {
|
|
29
|
+
OnceExit(root) {
|
|
30
|
+
// Only mini-program platforms need page selector prepend
|
|
31
|
+
const platform = process.env.UNI_PLATFORM || '';
|
|
32
|
+
if (!platform.startsWith('mp-')) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// Get file path from postcss source
|
|
36
|
+
const filePath = root.source?.input?.file;
|
|
37
|
+
if (!filePath) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// Only process page files
|
|
41
|
+
if (!(0, pages_1.isUniPageFile)(filePath)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Get page's externalClasses info
|
|
45
|
+
const externalClassesInfo = (0, externalClasses_1.findPageExternalClasses)(filePath);
|
|
46
|
+
let staticClasses = new Set();
|
|
47
|
+
let hasDynamic = false;
|
|
48
|
+
if (process.env.NODE_ENV === 'development') {
|
|
49
|
+
hasDynamic = true;
|
|
50
|
+
}
|
|
51
|
+
else if (externalClassesInfo) {
|
|
52
|
+
staticClasses = externalClassesInfo.staticClasses;
|
|
53
|
+
if (externalClassesInfo.hasDynamic ||
|
|
54
|
+
externalClassesInfo.hasAppAndPageStyle) {
|
|
55
|
+
hasDynamic = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// If no static classes and no dynamic, skip processing
|
|
59
|
+
if (staticClasses.size === 0 && !hasDynamic) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
root.walkRules((rule) => {
|
|
63
|
+
processRule(rule, processedRules, staticClasses, hasDynamic);
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
function processRule(rule, processedRules, staticClasses, hasDynamic) {
|
|
71
|
+
// Skip already processed rules
|
|
72
|
+
if (processedRules.has(rule)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Skip keyframes rules
|
|
76
|
+
if (rule.parent &&
|
|
77
|
+
rule.parent.type === 'atrule' &&
|
|
78
|
+
/-?keyframes$/.test(rule.parent.name)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
processedRules.add(rule);
|
|
82
|
+
// Process selector based on externalClasses info
|
|
83
|
+
rule.selector = (0, postcss_selector_parser_1.default)((selectorRoot) => {
|
|
84
|
+
selectorRoot.each((selector) => {
|
|
85
|
+
if (hasDynamic) {
|
|
86
|
+
// Dynamic externalClasses: prepend page to all selectors
|
|
87
|
+
prependPageSelector(selector);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// Static only: only prepend page if selector contains any staticClasses
|
|
91
|
+
if (selectorContainsClasses(selector, staticClasses)) {
|
|
92
|
+
prependPageSelector(selector);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}).processSync(rule.selector);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if selector contains any of the specified classes
|
|
100
|
+
*/
|
|
101
|
+
function selectorContainsClasses(selector, classes) {
|
|
102
|
+
let found = false;
|
|
103
|
+
selector.walk((node) => {
|
|
104
|
+
if (node.type === 'class' && classes.has(node.value)) {
|
|
105
|
+
found = true;
|
|
106
|
+
return false; // stop walking
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return found;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Prepend 'page' selector for mini-program platforms
|
|
113
|
+
* .a -> page .a
|
|
114
|
+
* .b .c -> page .b .c
|
|
115
|
+
*/
|
|
116
|
+
function prependPageSelector(selector) {
|
|
117
|
+
// Skip if selector already starts with 'page'
|
|
118
|
+
const firstNode = selector.first;
|
|
119
|
+
if (firstNode && firstNode.type === 'tag' && firstNode.value === 'page') {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// Insert 'page' tag and a combinator (space) at the beginning
|
|
123
|
+
selector.prepend(postcss_selector_parser_1.default.combinator({ value: ' ' }));
|
|
124
|
+
selector.prepend(postcss_selector_parser_1.default.tag({ value: 'page' }));
|
|
125
|
+
}
|
|
126
|
+
externalPlugin.postcss = true;
|
|
127
|
+
exports.default = externalPlugin;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
|
|
7
|
+
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
7
8
|
const scopedPlugin = () => {
|
|
8
9
|
return {
|
|
9
10
|
postcssPlugin: 'uni-sfc-scoped',
|
|
@@ -26,14 +27,43 @@ function processRule(rule, hasVueSfcScoped) {
|
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
processedRules.add(rule);
|
|
30
|
+
const isXWeb = process.env.UNI_APP_X === 'true' && process.env.UNI_UTS_PLATFORM === 'web';
|
|
29
31
|
rule.selector = (0, postcss_selector_parser_1.default)((selectorRoot) => {
|
|
30
32
|
selectorRoot.each((selector) => {
|
|
31
33
|
hasVueSfcScoped
|
|
32
34
|
? rewriteDeprecatedSelector(selector)
|
|
33
35
|
: rewriteSelector(selector, selectorRoot);
|
|
36
|
+
if (isXWeb) {
|
|
37
|
+
rewritePartSelector(selector, selectorRoot);
|
|
38
|
+
}
|
|
34
39
|
});
|
|
35
40
|
}).processSync(rule.selector);
|
|
36
41
|
}
|
|
42
|
+
function rewritePartSelector(selector, selectorRoot) {
|
|
43
|
+
if (selector.some((n) => {
|
|
44
|
+
return n.type === 'pseudo' && n.value === '::part';
|
|
45
|
+
})) {
|
|
46
|
+
const uniPartSelector = selector.clone();
|
|
47
|
+
_rewritePartSelector(uniPartSelector, selectorRoot);
|
|
48
|
+
selectorRoot.insertAfter(selector, uniPartSelector);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function _rewritePartSelector(selector, selectorRoot) {
|
|
52
|
+
selector.each((n) => {
|
|
53
|
+
if (n.type === 'pseudo' && n.value === '::part') {
|
|
54
|
+
const partClass = (0, uni_shared_1.getPartClass)(n.nodes[0].toString());
|
|
55
|
+
selector.insertAfter(n, postcss_selector_parser_1.default.pseudo({
|
|
56
|
+
value: ':deep',
|
|
57
|
+
nodes: [
|
|
58
|
+
postcss_selector_parser_1.default.className({
|
|
59
|
+
value: partClass,
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
}));
|
|
63
|
+
selector.removeChild(n);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
37
67
|
/**
|
|
38
68
|
* @param selector
|
|
39
69
|
* @returns
|
|
@@ -37,6 +37,7 @@ const DEFAULT_KEYS = [
|
|
|
37
37
|
'VUE2',
|
|
38
38
|
'VUE3',
|
|
39
39
|
'WEB',
|
|
40
|
+
'VUE3_VAPOR',
|
|
40
41
|
];
|
|
41
42
|
const preVueContext = Object.create(null);
|
|
42
43
|
const preNVueContext = Object.create(null);
|
|
@@ -66,6 +67,7 @@ function initScopedPreContext(platform, userPreContext, utsPlatform, isX) {
|
|
|
66
67
|
vueContext.VUE3 = true;
|
|
67
68
|
nvueContext.VUE3 = true;
|
|
68
69
|
uvueContext.VUE3 = true;
|
|
70
|
+
uvueContext.VUE3_VAPOR = process.env.UNI_APP_X_DOM2 === 'true';
|
|
69
71
|
if (isX) {
|
|
70
72
|
vueContext.UNI_APP_X = true;
|
|
71
73
|
nvueContext.UNI_APP_X = true;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
export { initPreContext } from './context';
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export interface PreprocessOptions {
|
|
3
|
+
unbalanced?: 'error' | 'skip' | 'skip-lazy';
|
|
4
|
+
}
|
|
5
|
+
export declare function preJs(jsCode: string, filename: string, options?: PreprocessOptions): any;
|
|
6
|
+
export declare function preHtml(htmlCode: string, filename: string, options?: PreprocessOptions): any;
|
|
4
7
|
export declare const preCss: typeof preJs;
|
|
5
8
|
export declare const preJson: typeof preJs;
|
|
6
|
-
export declare function preNVueJs(jsCode: string, filename: string): any;
|
|
7
|
-
export declare function preNVueHtml(htmlCode: string, filename: string): any;
|
|
9
|
+
export declare function preNVueJs(jsCode: string, filename: string, options?: PreprocessOptions): any;
|
|
10
|
+
export declare function preNVueHtml(htmlCode: string, filename: string, options?: PreprocessOptions): any;
|
|
8
11
|
export declare const preNVueCss: typeof preNVueJs;
|
|
9
12
|
export declare const preNVueJson: typeof preNVueJs;
|
|
10
|
-
export declare function preUVueJs(jsCode: string, filename: string): any;
|
|
11
|
-
export declare function preUVueHtml(htmlCode: string, filename: string): any;
|
|
13
|
+
export declare function preUVueJs(jsCode: string, filename: string, options?: PreprocessOptions): any;
|
|
14
|
+
export declare function preUVueHtml(htmlCode: string, filename: string, options?: PreprocessOptions): any;
|
|
12
15
|
export declare const preUVueCss: typeof preUVueJs;
|
|
13
16
|
export declare const preUVueJson: typeof preUVueJs;
|
package/dist/preprocess/index.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.preUVueJson = exports.preUVueCss = exports.preUVueHtml = exports.preUVue
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const context_1 = require("./context");
|
|
10
|
+
const utils_2 = require("../vite/plugins/vitejs/utils");
|
|
10
11
|
/* eslint-disable no-restricted-globals */
|
|
11
12
|
const { preprocess: preprocessLib } = require('../../lib/preprocess');
|
|
12
13
|
var context_2 = require("./context");
|
|
@@ -23,55 +24,61 @@ function normalizeFilename(filename) {
|
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
function preJs(jsCode, filename) {
|
|
27
|
+
function preJs(jsCode, filename, options) {
|
|
27
28
|
if (process.env.UNI_APP_X === 'true') {
|
|
28
|
-
return preUVueJs(jsCode, filename);
|
|
29
|
+
return preUVueJs(jsCode, filename, options);
|
|
29
30
|
}
|
|
30
31
|
return preprocess(jsCode, (0, context_1.getPreVueContext)(), {
|
|
31
32
|
type: 'js',
|
|
32
33
|
filename: normalizeFilename(filename),
|
|
34
|
+
unbalanced: options?.unbalanced,
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
exports.preJs = preJs;
|
|
36
|
-
function preHtml(htmlCode, filename) {
|
|
38
|
+
function preHtml(htmlCode, filename, options) {
|
|
37
39
|
if (process.env.UNI_APP_X === 'true') {
|
|
38
|
-
return preUVueHtml(htmlCode, filename);
|
|
40
|
+
return preUVueHtml(htmlCode, filename, options);
|
|
39
41
|
}
|
|
40
42
|
return preprocess(htmlCode, (0, context_1.getPreVueContext)(), {
|
|
41
43
|
type: 'html',
|
|
42
44
|
filename: normalizeFilename(filename),
|
|
45
|
+
unbalanced: options?.unbalanced,
|
|
43
46
|
});
|
|
44
47
|
}
|
|
45
48
|
exports.preHtml = preHtml;
|
|
46
49
|
exports.preCss = preJs;
|
|
47
50
|
exports.preJson = preJs;
|
|
48
|
-
function preNVueJs(jsCode, filename) {
|
|
51
|
+
function preNVueJs(jsCode, filename, options) {
|
|
49
52
|
return preprocess(jsCode, (0, context_1.getPreNVueContext)(), {
|
|
50
53
|
type: 'js',
|
|
51
54
|
filename: normalizeFilename(filename),
|
|
55
|
+
unbalanced: options?.unbalanced,
|
|
52
56
|
});
|
|
53
57
|
}
|
|
54
58
|
exports.preNVueJs = preNVueJs;
|
|
55
|
-
function preNVueHtml(htmlCode, filename) {
|
|
59
|
+
function preNVueHtml(htmlCode, filename, options) {
|
|
56
60
|
return preprocess(htmlCode, (0, context_1.getPreNVueContext)(), {
|
|
57
61
|
type: 'html',
|
|
58
62
|
filename: normalizeFilename(filename),
|
|
63
|
+
unbalanced: options?.unbalanced,
|
|
59
64
|
});
|
|
60
65
|
}
|
|
61
66
|
exports.preNVueHtml = preNVueHtml;
|
|
62
67
|
exports.preNVueCss = preNVueJs;
|
|
63
68
|
exports.preNVueJson = preNVueJs;
|
|
64
|
-
function preUVueJs(jsCode, filename) {
|
|
69
|
+
function preUVueJs(jsCode, filename, options) {
|
|
65
70
|
return preprocess(jsCode, (0, context_1.getPreUVueContext)(), {
|
|
66
71
|
type: 'js',
|
|
67
72
|
filename: normalizeFilename(filename),
|
|
73
|
+
unbalanced: options?.unbalanced,
|
|
68
74
|
});
|
|
69
75
|
}
|
|
70
76
|
exports.preUVueJs = preUVueJs;
|
|
71
|
-
function preUVueHtml(htmlCode, filename) {
|
|
77
|
+
function preUVueHtml(htmlCode, filename, options) {
|
|
72
78
|
return preprocess(htmlCode, (0, context_1.getPreUVueContext)(), {
|
|
73
79
|
type: 'html',
|
|
74
80
|
filename: normalizeFilename(filename),
|
|
81
|
+
unbalanced: options?.unbalanced,
|
|
75
82
|
});
|
|
76
83
|
}
|
|
77
84
|
exports.preUVueHtml = preUVueHtml;
|
|
@@ -105,6 +112,24 @@ function preprocess(code, context, options) {
|
|
|
105
112
|
return preprocessLib(code, context, options);
|
|
106
113
|
}
|
|
107
114
|
catch (e) {
|
|
115
|
+
// `Unbalanced left delimiter found in string at position 1520`
|
|
116
|
+
// `Unbalanced right delimiter found in string at position 1520`
|
|
117
|
+
if (e.message) {
|
|
118
|
+
const msg = e.message;
|
|
119
|
+
// 正则匹配left/right及position
|
|
120
|
+
const unbalancedMatch = msg.match(/Unbalanced (left|right) delimiter found in string at position (\d+)/);
|
|
121
|
+
if (unbalancedMatch) {
|
|
122
|
+
const errorDirective = unbalancedMatch[1] === 'left' ? '#ifdef/#ifndef' : '#endif';
|
|
123
|
+
const missedDirective = unbalancedMatch[1] === 'left' ? '#endif' : '#ifdef/#ifndef';
|
|
124
|
+
const position = parseInt(unbalancedMatch[2], 10);
|
|
125
|
+
const filename = options.filename?.() || '';
|
|
126
|
+
const { line } = (0, utils_2.offsetToLineColumn)(code, position);
|
|
127
|
+
console.error(`条件编译失败: ${errorDirective} 缺少配对的 ${missedDirective}`);
|
|
128
|
+
console.error(`${filename.split(':')[0]}:${line}`);
|
|
129
|
+
console.log((0, utils_2.generateCodeFrame)(code, position));
|
|
130
|
+
return code;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
108
133
|
const msg = ERRORS[options.type];
|
|
109
134
|
if (msg) {
|
|
110
135
|
console.error(msg.replace('%FILENAME%', options.filename?.() || ''));
|
package/dist/resolve.js
CHANGED
|
@@ -109,7 +109,11 @@ exports.resolveVueI18nRuntime = resolveVueI18nRuntime;
|
|
|
109
109
|
let componentsLibPath = '';
|
|
110
110
|
function resolveComponentsLibPath() {
|
|
111
111
|
if (!componentsLibPath) {
|
|
112
|
-
const dir = process.env.
|
|
112
|
+
const dir = process.env.UNI_APP_X_DOM2 === 'true'
|
|
113
|
+
? '../lib-x-vapor'
|
|
114
|
+
: process.env.UNI_APP_X === 'true'
|
|
115
|
+
? '../lib-x'
|
|
116
|
+
: '../lib';
|
|
113
117
|
if ((0, env_1.isInHBuilderX)()) {
|
|
114
118
|
componentsLibPath = path_1.default.join(resolveBuiltIn('@dcloudio/uni-components/package.json'), dir);
|
|
115
119
|
}
|
package/dist/uni_modules.js
CHANGED
|
@@ -351,9 +351,25 @@ exports.capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() +
|
|
|
351
351
|
*/
|
|
352
352
|
function parseUTSModuleDeps(deps, inputDir) {
|
|
353
353
|
const modulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
354
|
-
return deps
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
354
|
+
return deps
|
|
355
|
+
.map((dep) => {
|
|
356
|
+
let depName = '';
|
|
357
|
+
if (dep.includes(':')) {
|
|
358
|
+
const parts = dep.split(':');
|
|
359
|
+
if (process.env.UNI_UTS_PLATFORM &&
|
|
360
|
+
process.env.UNI_UTS_PLATFORM === parts[0]) {
|
|
361
|
+
depName = parts[1];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
depName = dep;
|
|
366
|
+
}
|
|
367
|
+
if (depName &&
|
|
368
|
+
fs_extra_1.default.existsSync(path_1.default.resolve(modulesDir, depName, 'utssdk'))) {
|
|
369
|
+
return depName;
|
|
370
|
+
}
|
|
371
|
+
return '';
|
|
372
|
+
})
|
|
373
|
+
.filter(Boolean);
|
|
358
374
|
}
|
|
359
375
|
exports.parseUTSModuleDeps = parseUTSModuleDeps;
|
package/dist/utils.d.ts
CHANGED
|
@@ -23,8 +23,8 @@ export declare function pathToGlob(pathString: string, glob: string, options?: {
|
|
|
23
23
|
export declare function resolveSourceMapPath(outputDir?: string, platform?: UniApp.PLATFORM): string;
|
|
24
24
|
export declare function installDepTips(type: 'dependencies' | 'devDependencies', module: string, version?: string): string;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @param {string} filename
|
|
26
|
+
* 根据环境变量 UNI_INPUT_DIR 路径判断是否为 App.(u?)vue
|
|
27
|
+
* @param {string} filename
|
|
28
28
|
* @returns
|
|
29
29
|
*/
|
|
30
30
|
export declare function isAppVue(filename: string): boolean;
|
package/dist/utils.js
CHANGED
|
@@ -137,13 +137,13 @@ Please run \`${picocolors_1.default.cyan(`${getInstallCommand(process.cwd())} ${
|
|
|
137
137
|
}
|
|
138
138
|
exports.installDepTips = installDepTips;
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
141
|
-
* @param {string} filename
|
|
140
|
+
* 根据环境变量 UNI_INPUT_DIR 路径判断是否为 App.(u?)vue
|
|
141
|
+
* @param {string} filename
|
|
142
142
|
* @returns
|
|
143
143
|
*/
|
|
144
144
|
function isAppVue(filename) {
|
|
145
|
-
const
|
|
146
|
-
return
|
|
145
|
+
const appVue = resolveAppVue(process.env.UNI_INPUT_DIR);
|
|
146
|
+
return appVue === normalizePath(filename);
|
|
147
147
|
}
|
|
148
148
|
exports.isAppVue = isAppVue;
|
|
149
149
|
function resolveAppVue(inputDir) {
|
|
@@ -179,8 +179,11 @@ function enableSourceMap() {
|
|
|
179
179
|
}
|
|
180
180
|
exports.enableSourceMap = enableSourceMap;
|
|
181
181
|
function requireUniHelpers() {
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
if (process.env.UNI_HBUILDERX_PLUGINS) {
|
|
183
|
+
require(path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers/lib/bytenode'));
|
|
184
|
+
}
|
|
185
|
+
return require(process.env.UNI_HELPERS_DIR ??
|
|
186
|
+
path_1.default.join(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers'));
|
|
184
187
|
}
|
|
185
188
|
exports.requireUniHelpers = requireUniHelpers;
|
|
186
189
|
function normalizeEmitAssetFileName(fileName) {
|
package/dist/utsUtils.d.ts
CHANGED
package/dist/utsUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.genUTSClassName = exports.matchUTSComponent = void 0;
|
|
3
|
+
exports.verifySymbol = exports.genUTSClassName = exports.matchUTSComponent = void 0;
|
|
4
4
|
const easycom_1 = require("./easycom");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
6
|
function matchUTSComponent(tag) {
|
|
@@ -42,3 +42,4 @@ function verifySymbol(s) {
|
|
|
42
42
|
}
|
|
43
43
|
return buf.join('');
|
|
44
44
|
}
|
|
45
|
+
exports.verifySymbol = verifySymbol;
|