@dcloudio/uni-cli-shared 3.0.0-5020420260813002 → 3.0.0-5020620260917001
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/dom2/fontFamily.js +2 -2
- package/dist/dom2/index.d.ts +1 -0
- package/dist/dom2/index.js +1 -0
- package/dist/dom2/script.d.ts +8 -0
- package/dist/dom2/script.js +25 -0
- package/dist/hbx/env.d.ts +0 -3
- package/dist/hbx/env.js +104 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/json/mp/pages.d.ts +1 -1
- package/dist/json/mp/types.d.ts +1 -0
- package/dist/json/mp/utils.d.ts +1 -1
- package/dist/json/mp/utils.js +13 -1
- package/dist/json/uni-x/index.d.ts +5 -0
- package/dist/json/uni-x/index.js +17 -8
- package/dist/mp/externalClasses.d.ts +17 -0
- package/dist/mp/externalClasses.js +77 -1
- package/dist/mp/index.d.ts +1 -1
- package/dist/mp/index.js +10 -1
- package/dist/postcss/plugins/stylePluginExternal.js +46 -0
- package/dist/resolve.d.ts +1 -1
- package/dist/resolve.js +32 -7
- package/dist/uasm.d.ts +75 -0
- package/dist/uasm.js +466 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +13 -1
- package/dist/uts/extApi.d.ts +7 -0
- package/dist/uts/extApi.js +34 -0
- package/dist/vite/cloud.js +7 -1
- package/dist/vite/index.d.ts +10 -0
- package/dist/vite/plugins/uts/uni_modules.js +6 -1
- package/dist/vite/plugins/uts/uvue.js +122 -19
- package/dist/vue/transforms/x/transformMPBuiltInTag.js +3 -0
- package/dist/workers.d.ts +1 -0
- package/dist/workers.js +23 -5
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.cjs +230 -91
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.d.cts +27 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.d.mts +27 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.d.ts +27 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.mjs +230 -91
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +54 -15
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +54 -15
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.d.ts +7 -8
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +54 -15
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +12 -3
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +12 -3
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +63 -16
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +7 -7
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +10 -2
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +63 -16
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +7 -7
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +383 -3203
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +984 -498
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +370 -268
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +143 -132
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +393 -258
- package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -1
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.js +14 -5
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +14 -5
- package/lib/dom2/app/@vue/shared/dist/shared.d.ts +7 -5
- package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +14 -5
- package/package.json +5 -5
package/dist/dom2/fontFamily.js
CHANGED
|
@@ -15,7 +15,7 @@ function createJsStylePlaceholder(id) {
|
|
|
15
15
|
exports.createJsStylePlaceholder = createJsStylePlaceholder;
|
|
16
16
|
function createJsStylePlaceholderRegExp(id) {
|
|
17
17
|
const hashId = (0, hash_sum_1.default)(id);
|
|
18
|
-
return new RegExp(`\\{\\s*"${exports.JS_STYLE_PLACEHOLDER_MARKER}"\\s*:\\s*"${hashId}"\\s*\\}`, 'g');
|
|
18
|
+
return new RegExp(`\\{\\s*(?:"${exports.JS_STYLE_PLACEHOLDER_MARKER}"|'${exports.JS_STYLE_PLACEHOLDER_MARKER}'|${exports.JS_STYLE_PLACEHOLDER_MARKER})\\s*:\\s*(?:"${hashId}"|'${hashId}')\\s*\\}`, 'g');
|
|
19
19
|
}
|
|
20
20
|
exports.createJsStylePlaceholderRegExp = createJsStylePlaceholderRegExp;
|
|
21
|
-
exports.ANY_JS_STYLE_PLACEHOLDER_RE = new RegExp(`\\{\\s*"${exports.JS_STYLE_PLACEHOLDER_MARKER}"\\s*:\\s*"
|
|
21
|
+
exports.ANY_JS_STYLE_PLACEHOLDER_RE = new RegExp(`\\{\\s*(?:"${exports.JS_STYLE_PLACEHOLDER_MARKER}"|'${exports.JS_STYLE_PLACEHOLDER_MARKER}'|${exports.JS_STYLE_PLACEHOLDER_MARKER})\\s*:\\s*(?:"[^"]+?"|'[^']+?')\\s*\\}`, 'g');
|
package/dist/dom2/index.d.ts
CHANGED
package/dist/dom2/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./sharedData"), exports);
|
|
18
|
+
__exportStar(require("./script"), exports);
|
|
18
19
|
__exportStar(require("./vue"), exports);
|
|
19
20
|
__exportStar(require("./fontFamily"), exports);
|
|
20
21
|
__exportStar(require("./rootScrollView"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UasmTransformOptions } from '../uasm';
|
|
2
|
+
import type { UniVitePlugin } from '../vite';
|
|
3
|
+
export interface UniVaporScriptPluginOptions {
|
|
4
|
+
sharedDataLibName?: string;
|
|
5
|
+
sharedDataLibAsGlobal?: boolean;
|
|
6
|
+
uasm?: UasmTransformOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare function uniVaporScriptPlugin(options?: UniVaporScriptPluginOptions): UniVitePlugin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniVaporScriptPlugin = void 0;
|
|
4
|
+
const uts_1 = require("../uts");
|
|
5
|
+
const extApi_1 = require("../uts/extApi");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const sharedData_1 = require("./sharedData");
|
|
8
|
+
function uniVaporScriptPlugin(options = {}) {
|
|
9
|
+
const { uasm, ...sharedData } = options;
|
|
10
|
+
const { D2SP } = (0, utils_1.requireUniHelpers)();
|
|
11
|
+
const nodeEnv = process.env.UNI_NODE_ENV || process.env.NODE_ENV;
|
|
12
|
+
const extApi = (0, utils_1.isNormalCompileTarget)() && nodeEnv !== 'development'
|
|
13
|
+
? (0, extApi_1.initUts2jsExtApiOptions)()
|
|
14
|
+
: undefined;
|
|
15
|
+
return D2SP({
|
|
16
|
+
typescript: (0, uts_1.resolveUTSCompiler)().getTypeScript(),
|
|
17
|
+
extApi,
|
|
18
|
+
uasm,
|
|
19
|
+
sharedData: {
|
|
20
|
+
...(0, sharedData_1.initUts2jsSharedDataOptions)(),
|
|
21
|
+
...sharedData,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.uniVaporScriptPlugin = uniVaporScriptPlugin;
|
package/dist/hbx/env.d.ts
CHANGED
package/dist/hbx/env.js
CHANGED
|
@@ -4,8 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fixBinaryPath = exports.initModulePaths = exports.runByHBuilderX = exports.isInHBuilderX = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const module_1 = __importDefault(require("module"));
|
|
10
|
+
const url_1 = require("url");
|
|
9
11
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
10
12
|
const resolve_1 = require("../resolve");
|
|
11
13
|
const utils_1 = require("../utils");
|
|
@@ -19,12 +21,47 @@ exports.runByHBuilderX = (0, uni_shared_1.once)(() => {
|
|
|
19
21
|
/**
|
|
20
22
|
* 增加 node_modules
|
|
21
23
|
*/
|
|
24
|
+
const initializedModulePaths = new Set();
|
|
25
|
+
function getPackageName(specifier) {
|
|
26
|
+
if (!specifier ||
|
|
27
|
+
specifier.startsWith('.') ||
|
|
28
|
+
specifier.startsWith('/') ||
|
|
29
|
+
specifier.startsWith('\\') ||
|
|
30
|
+
specifier.startsWith('#') ||
|
|
31
|
+
specifier.includes(':') ||
|
|
32
|
+
/[\\%?#]/.test(specifier)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const segments = specifier.split('/');
|
|
36
|
+
if (segments.some((segment) => !segment || segment === '.' || segment === '..') ||
|
|
37
|
+
(specifier.startsWith('@') &&
|
|
38
|
+
(segments.length < 2 || segments[0].length === 1))) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const packageName = specifier.startsWith('@')
|
|
42
|
+
? segments.slice(0, 2).join('/')
|
|
43
|
+
: segments[0];
|
|
44
|
+
return packageName;
|
|
45
|
+
}
|
|
46
|
+
function canFallbackToNodeModules(specifier, error, nodeModulesPath) {
|
|
47
|
+
const code = error?.code;
|
|
48
|
+
if (code !== 'ERR_MODULE_NOT_FOUND') {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const packageName = getPackageName(specifier);
|
|
52
|
+
return (!!packageName && fs_1.default.existsSync(path_1.default.resolve(nodeModulesPath, packageName)));
|
|
53
|
+
}
|
|
22
54
|
function initModulePaths() {
|
|
23
55
|
if (!(0, utils_2.isInHBuilderX)()) {
|
|
24
56
|
return;
|
|
25
57
|
}
|
|
26
|
-
const Module = module.constructor.length > 1 ? module.constructor : module_1.default;
|
|
27
58
|
const nodeModulesPath = path_1.default.resolve(process.env.UNI_CLI_CONTEXT, 'node_modules');
|
|
59
|
+
if (initializedModulePaths.has(nodeModulesPath)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const parentURL = (0, url_1.pathToFileURL)(path_1.default.resolve(process.env.UNI_CLI_CONTEXT, 'package.json')).href;
|
|
63
|
+
const moduleApi = module_1.default;
|
|
64
|
+
const Module = module.constructor.length > 1 ? module.constructor : module_1.default;
|
|
28
65
|
const oldNodeModulePaths = Module._nodeModulePaths;
|
|
29
66
|
Module._nodeModulePaths = function (from) {
|
|
30
67
|
const paths = oldNodeModulePaths.call(this, from);
|
|
@@ -33,6 +70,72 @@ function initModulePaths() {
|
|
|
33
70
|
}
|
|
34
71
|
return paths;
|
|
35
72
|
};
|
|
73
|
+
if (moduleApi.registerHooks) {
|
|
74
|
+
moduleApi.registerHooks({
|
|
75
|
+
resolve(specifier, context, nextResolve) {
|
|
76
|
+
try {
|
|
77
|
+
return nextResolve(specifier, context);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (!canFallbackToNodeModules(specifier, error, nodeModulesPath)) {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
return nextResolve(specifier, { ...context, parentURL });
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
initializedModulePaths.add(nodeModulesPath);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// Node 的 ESM 解析不会使用 _nodeModulePaths,需要单独回退到 HBuilderX 内置依赖。
|
|
91
|
+
const register = moduleApi.register;
|
|
92
|
+
if (register) {
|
|
93
|
+
const nodeModulesURL = (0, url_1.pathToFileURL)(nodeModulesPath + path_1.default.sep).href;
|
|
94
|
+
const loader = `
|
|
95
|
+
import { existsSync } from 'node:fs'
|
|
96
|
+
|
|
97
|
+
const parentURL = ${JSON.stringify(parentURL)}
|
|
98
|
+
const nodeModulesURL = ${JSON.stringify(nodeModulesURL)}
|
|
99
|
+
|
|
100
|
+
export async function resolve(specifier, context, nextResolve) {
|
|
101
|
+
try {
|
|
102
|
+
return await nextResolve(specifier, context)
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (
|
|
105
|
+
error?.code !== 'ERR_MODULE_NOT_FOUND' ||
|
|
106
|
+
!specifier ||
|
|
107
|
+
specifier.startsWith('.') ||
|
|
108
|
+
specifier.startsWith('/') ||
|
|
109
|
+
specifier.startsWith('\\\\') ||
|
|
110
|
+
specifier.startsWith('#') ||
|
|
111
|
+
specifier.includes(':') ||
|
|
112
|
+
/[\\\\%?#]/.test(specifier)
|
|
113
|
+
) {
|
|
114
|
+
throw error
|
|
115
|
+
}
|
|
116
|
+
const segments = specifier.split('/')
|
|
117
|
+
if (
|
|
118
|
+
segments.some(
|
|
119
|
+
(segment) => !segment || segment === '.' || segment === '..'
|
|
120
|
+
) ||
|
|
121
|
+
(specifier.startsWith('@') &&
|
|
122
|
+
(segments.length < 2 || segments[0].length === 1))
|
|
123
|
+
) {
|
|
124
|
+
throw error
|
|
125
|
+
}
|
|
126
|
+
const packageName = specifier.startsWith('@')
|
|
127
|
+
? segments.slice(0, 2).join('/')
|
|
128
|
+
: segments[0]
|
|
129
|
+
if (!existsSync(new URL(packageName + '/', nodeModulesURL))) {
|
|
130
|
+
throw error
|
|
131
|
+
}
|
|
132
|
+
return nextResolve(specifier, { ...context, parentURL })
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
register(`data:text/javascript,${encodeURIComponent(loader)}`, (0, url_1.pathToFileURL)(process.env.UNI_CLI_CONTEXT + path_1.default.sep));
|
|
137
|
+
}
|
|
138
|
+
initializedModulePaths.add(nodeModulesPath);
|
|
36
139
|
}
|
|
37
140
|
exports.initModulePaths = initModulePaths;
|
|
38
141
|
function resolveEsbuildModule(name) {
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './hbx';
|
|
|
6
6
|
export * from './ssr';
|
|
7
7
|
export * from './vue';
|
|
8
8
|
export * from './uts';
|
|
9
|
+
export * from './uts/extApi';
|
|
9
10
|
export * from './x';
|
|
10
11
|
export * from './logs';
|
|
11
12
|
export * from './dom2';
|
|
@@ -25,6 +26,7 @@ export * from './scripts';
|
|
|
25
26
|
export * from './platform';
|
|
26
27
|
export * from './utsUtils';
|
|
27
28
|
export * from './workers';
|
|
29
|
+
export * from './uasm';
|
|
28
30
|
export { parseUniExtApi, parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, formatExtApiProviderName, } from './uni_modules';
|
|
29
31
|
export { copyEncryptUniModulesDom2Bytes, getUniModulesEncryptType, parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
|
|
30
32
|
import type { EncryptPackageJson } from './uni_modules.cloud';
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __exportStar(require("./hbx"), exports);
|
|
|
23
23
|
__exportStar(require("./ssr"), exports);
|
|
24
24
|
__exportStar(require("./vue"), exports);
|
|
25
25
|
__exportStar(require("./uts"), exports);
|
|
26
|
+
__exportStar(require("./uts/extApi"), exports);
|
|
26
27
|
__exportStar(require("./x"), exports);
|
|
27
28
|
__exportStar(require("./logs"), exports);
|
|
28
29
|
__exportStar(require("./dom2"), exports);
|
|
@@ -42,6 +43,7 @@ __exportStar(require("./scripts"), exports);
|
|
|
42
43
|
__exportStar(require("./platform"), exports);
|
|
43
44
|
__exportStar(require("./utsUtils"), exports);
|
|
44
45
|
__exportStar(require("./workers"), exports);
|
|
46
|
+
__exportStar(require("./uasm"), exports);
|
|
45
47
|
var uni_modules_1 = require("./uni_modules");
|
|
46
48
|
Object.defineProperty(exports, "parseUniExtApi", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApi; } });
|
|
47
49
|
Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
|
package/dist/json/mp/pages.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ interface ParsePagesJsonOptions {
|
|
|
4
4
|
darkmode?: boolean;
|
|
5
5
|
subpackages: boolean;
|
|
6
6
|
independentSubpackages?: boolean;
|
|
7
|
-
windowOptionsMap?: Record<string, string>;
|
|
7
|
+
windowOptionsMap?: Record<string, string | string[]>;
|
|
8
8
|
tabBarOptionsMap?: Record<string, string>;
|
|
9
9
|
tabBarItemOptionsMap?: Record<string, string>;
|
|
10
10
|
networkTimeout?: NetworkTimeout;
|
package/dist/json/mp/types.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface PageWindowOptions extends ShareWindowOptions {
|
|
|
28
28
|
style?: Style;
|
|
29
29
|
singlePage?: SinglePage;
|
|
30
30
|
restartStrategy?: RestartStrategy;
|
|
31
|
+
styleIsolation?: 'shared' | 'isolated';
|
|
31
32
|
}
|
|
32
33
|
export interface AppWindowOptions extends ShareWindowOptions {
|
|
33
34
|
visualEffectInBackground?: 'none' | 'hidden';
|
package/dist/json/mp/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AppWindowOptions, PageWindowOptions, TabBar } from './types';
|
|
2
|
-
export declare function parseWindowOptions(style: UniApp.PagesJsonPageStyle, platform: UniApp.PLATFORM, windowOptionsMap?: Record<string, string>): PageWindowOptions | AppWindowOptions;
|
|
2
|
+
export declare function parseWindowOptions(style: UniApp.PagesJsonPageStyle, platform: UniApp.PLATFORM, windowOptionsMap?: Record<string, string | string[]>): PageWindowOptions | AppWindowOptions;
|
|
3
3
|
export declare function parseTabBar(tabBar: UniApp.TabBarOptions, platform: UniApp.PLATFORM, tabBarOptionsMap?: Record<string, string>, tabBarItemOptionsMap?: Record<string, string>): TabBar;
|
package/dist/json/mp/utils.js
CHANGED
|
@@ -21,6 +21,18 @@ function convert(to, from, map) {
|
|
|
21
21
|
});
|
|
22
22
|
return to;
|
|
23
23
|
}
|
|
24
|
+
function convertWindowOptions(to, from, map) {
|
|
25
|
+
Object.entries(map).forEach(([key, value]) => {
|
|
26
|
+
const names = (0, shared_1.isArray)(value) ? value : [value];
|
|
27
|
+
for (const name of names) {
|
|
28
|
+
if ((0, shared_1.hasOwn)(from, name)) {
|
|
29
|
+
to[key] = from[name];
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return to;
|
|
35
|
+
}
|
|
24
36
|
function parseWindowOptions(style, platform, windowOptionsMap) {
|
|
25
37
|
if (!style) {
|
|
26
38
|
return {};
|
|
@@ -29,7 +41,7 @@ function parseWindowOptions(style, platform, windowOptionsMap) {
|
|
|
29
41
|
(0, pages_1.removePlatformStyle)(trimJson(style));
|
|
30
42
|
const res = {};
|
|
31
43
|
if (windowOptionsMap) {
|
|
32
|
-
return (0, shared_1.extend)(
|
|
44
|
+
return (0, shared_1.extend)(convertWindowOptions(res, style, windowOptionsMap), platformStyle);
|
|
33
45
|
}
|
|
34
46
|
return (0, shared_1.extend)(res, style, platformStyle);
|
|
35
47
|
}
|
|
@@ -3,6 +3,11 @@ export interface UniXPageOptions {
|
|
|
3
3
|
disableScroll?: boolean;
|
|
4
4
|
enablePullDownRefresh?: boolean;
|
|
5
5
|
scrollIndicator?: 'none';
|
|
6
|
+
enableBackToTop?: boolean;
|
|
7
|
+
bounces?: boolean;
|
|
8
|
+
androidOverscroll?: boolean;
|
|
9
|
+
androidRefresherColor?: string;
|
|
10
|
+
backgroundColor?: string;
|
|
6
11
|
}
|
|
7
12
|
export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.PagesJson;
|
|
8
13
|
export declare function parseUniXPageOptions(filename: string): UniXPageOptions | undefined;
|
package/dist/json/uni-x/index.js
CHANGED
|
@@ -90,18 +90,27 @@ function updateUniXPageOptions(pagesJson) {
|
|
|
90
90
|
}
|
|
91
91
|
const pageOptions = new Map();
|
|
92
92
|
pagesJson.pages.forEach((page) => {
|
|
93
|
-
pageOptions.set(page.path, normalizeRootPageOptions(page.style));
|
|
93
|
+
pageOptions.set(page.path, normalizeRootPageOptions(page.style, pagesJson.globalStyle));
|
|
94
94
|
});
|
|
95
95
|
uniXPageOptionsCache.set(inputDir, pageOptions);
|
|
96
96
|
}
|
|
97
|
-
function normalizeRootPageOptions(pageStyle) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
97
|
+
function normalizeRootPageOptions(pageStyle, globalStyle) {
|
|
98
|
+
const androidRefresherColor = pageStyle?.androidRefresherColor ?? globalStyle.androidRefresherColor;
|
|
99
|
+
const backgroundColor = pageStyle?.backgroundColor ?? globalStyle.backgroundColor;
|
|
101
100
|
return {
|
|
102
|
-
disableScroll: pageStyle
|
|
103
|
-
enablePullDownRefresh: isEnablePullDownRefresh(pageStyle) || undefined,
|
|
104
|
-
scrollIndicator: pageStyle
|
|
101
|
+
disableScroll: pageStyle?.disableScroll === true || undefined,
|
|
102
|
+
enablePullDownRefresh: (pageStyle && isEnablePullDownRefresh(pageStyle)) || undefined,
|
|
103
|
+
scrollIndicator: pageStyle?.scrollIndicator,
|
|
104
|
+
// 新增的根滚动配置遵循 pages.json 页面样式覆盖全局样式的规则。
|
|
105
|
+
enableBackToTop: pageStyle?.enableBackToTop ?? globalStyle.enableBackToTop,
|
|
106
|
+
bounces: pageStyle?.bounces ?? globalStyle.bounces,
|
|
107
|
+
androidOverscroll: pageStyle?.androidOverscroll ?? globalStyle.androidOverscroll,
|
|
108
|
+
androidRefresherColor: androidRefresherColor?.startsWith('@')
|
|
109
|
+
? undefined
|
|
110
|
+
: androidRefresherColor,
|
|
111
|
+
backgroundColor: backgroundColor?.startsWith('@')
|
|
112
|
+
? undefined
|
|
113
|
+
: backgroundColor,
|
|
105
114
|
};
|
|
106
115
|
}
|
|
107
116
|
function initUniXPageOptions() {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type Program } from '@babel/types';
|
|
2
2
|
import type { SFCStyleBlock } from '@vue/compiler-sfc';
|
|
3
|
+
export declare const ALIPAY_CLASS_MASK_APP = 1;
|
|
4
|
+
export declare const ALIPAY_CLASS_MASK_PAGE: number;
|
|
5
|
+
export declare const ALIPAY_CLASS_MASK_COMPONENT: number;
|
|
6
|
+
export declare const ALIPAY_STYLE_CLASS_PREFIXES: readonly ["-a-", "-p-", "-c-"];
|
|
3
7
|
/**
|
|
4
8
|
* 页面使用的 externalClasses 信息
|
|
5
9
|
* - staticClasses: 静态绑定的 class 值集合,如 my-class="foo" 中的 "foo"
|
|
@@ -38,4 +42,17 @@ export declare function findMiniProgramComponentStyleIsolation(pagePahth: string
|
|
|
38
42
|
styleIsolation: StyleIsolation;
|
|
39
43
|
isPage: boolean;
|
|
40
44
|
} | undefined;
|
|
45
|
+
export declare function clearMiniProgramComponentStyleIsolation(pagePahth: string): void;
|
|
46
|
+
export declare function isAlipayXStyleIsolation(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 将 styleIsolation 转换为模板节点需要携带的来源 mask。
|
|
49
|
+
* mask 在编译期确定,SJS 运行时只做字符串展开,避免在视图层重复判断组件配置。
|
|
50
|
+
*/
|
|
51
|
+
export declare function getAlipayStyleIsolationClassMask(filename: string): number;
|
|
52
|
+
export declare function isAlipayStyleIsolationClass(value: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 静态 class 在编译期直接展开,避免把可提前完成的字符串处理留到 SJS 运行时。
|
|
55
|
+
* 保留前缀属于支付宝隔离实现的内部协议,静态可识别的用户 class 必须及时报错。
|
|
56
|
+
*/
|
|
57
|
+
export declare function formatAlipayStyleIsolationClasses(value: string, mask: number, keepRaw?: boolean): string;
|
|
41
58
|
export declare function createDefaultSFCStyleBlock(source: string): SFCStyleBlock;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDefaultSFCStyleBlock = exports.findMiniProgramComponentStyleIsolation = exports.updateMiniProgramComponentStyleIsolation = exports.parseStyleIsolation = exports.parseExternalClasses = exports.updateMiniProgramComponentExternalClasses = exports.findMiniProgramComponentExternalClasses = exports.hasExternalClasses = exports.clearPageExternalClasses = exports.addPageExternalClasses = exports.updatePageExternalClasses = exports.findPageExternalClasses = void 0;
|
|
3
|
+
exports.createDefaultSFCStyleBlock = exports.formatAlipayStyleIsolationClasses = exports.isAlipayStyleIsolationClass = exports.getAlipayStyleIsolationClassMask = exports.isAlipayXStyleIsolation = exports.clearMiniProgramComponentStyleIsolation = exports.findMiniProgramComponentStyleIsolation = exports.updateMiniProgramComponentStyleIsolation = exports.parseStyleIsolation = exports.parseExternalClasses = exports.updateMiniProgramComponentExternalClasses = exports.findMiniProgramComponentExternalClasses = exports.hasExternalClasses = exports.clearPageExternalClasses = exports.addPageExternalClasses = exports.updatePageExternalClasses = exports.findPageExternalClasses = exports.ALIPAY_STYLE_CLASS_PREFIXES = exports.ALIPAY_CLASS_MASK_COMPONENT = exports.ALIPAY_CLASS_MASK_PAGE = exports.ALIPAY_CLASS_MASK_APP = void 0;
|
|
4
4
|
const types_1 = require("@babel/types");
|
|
5
5
|
const estree_walker_1 = require("estree-walker");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
+
const utils_2 = require("../utils");
|
|
8
|
+
const pages_1 = require("../json/pages");
|
|
7
9
|
const externalClassesCache = new Map();
|
|
10
|
+
// 支付宝 ACSS 不支持微信小程序使用的 [class] 隔离方案,因此使用来源前缀作为隔离键。
|
|
11
|
+
exports.ALIPAY_CLASS_MASK_APP = 1;
|
|
12
|
+
exports.ALIPAY_CLASS_MASK_PAGE = 1 << 1;
|
|
13
|
+
exports.ALIPAY_CLASS_MASK_COMPONENT = 1 << 2;
|
|
14
|
+
exports.ALIPAY_STYLE_CLASS_PREFIXES = ['-a-', '-p-', '-c-'];
|
|
8
15
|
const pageStyleIsolationCache = new Map();
|
|
9
16
|
const pageExternalClassesCache = new Map();
|
|
10
17
|
function findPageExternalClasses(filename) {
|
|
@@ -112,6 +119,75 @@ function findMiniProgramComponentStyleIsolation(pagePahth) {
|
|
|
112
119
|
return pageStyleIsolationCache.get((0, utils_1.normalizePath)(pagePahth));
|
|
113
120
|
}
|
|
114
121
|
exports.findMiniProgramComponentStyleIsolation = findMiniProgramComponentStyleIsolation;
|
|
122
|
+
function clearMiniProgramComponentStyleIsolation(pagePahth) {
|
|
123
|
+
pageStyleIsolationCache.delete((0, utils_1.normalizePath)(pagePahth));
|
|
124
|
+
}
|
|
125
|
+
exports.clearMiniProgramComponentStyleIsolation = clearMiniProgramComponentStyleIsolation;
|
|
126
|
+
function isAlipayXStyleIsolation() {
|
|
127
|
+
return (process.env.UNI_PLATFORM === 'mp-alipay' &&
|
|
128
|
+
process.env.UNI_APP_X === 'true' &&
|
|
129
|
+
process.env.UNI_APP_STYLE_ISOLATION_VERSION === '2');
|
|
130
|
+
}
|
|
131
|
+
exports.isAlipayXStyleIsolation = isAlipayXStyleIsolation;
|
|
132
|
+
/**
|
|
133
|
+
* 将 styleIsolation 转换为模板节点需要携带的来源 mask。
|
|
134
|
+
* mask 在编译期确定,SJS 运行时只做字符串展开,避免在视图层重复判断组件配置。
|
|
135
|
+
*/
|
|
136
|
+
function getAlipayStyleIsolationClassMask(filename) {
|
|
137
|
+
if ((0, utils_2.isAppVue)(filename)) {
|
|
138
|
+
return exports.ALIPAY_CLASS_MASK_APP;
|
|
139
|
+
}
|
|
140
|
+
const isolation = findMiniProgramComponentStyleIsolation(filename);
|
|
141
|
+
const isPage = isolation?.isPage || (0, pages_1.isUniPageFile)(filename);
|
|
142
|
+
const styleIsolation = isolation?.styleIsolation;
|
|
143
|
+
if (isPage) {
|
|
144
|
+
return styleIsolation === 'isolated'
|
|
145
|
+
? exports.ALIPAY_CLASS_MASK_PAGE
|
|
146
|
+
: exports.ALIPAY_CLASS_MASK_APP | exports.ALIPAY_CLASS_MASK_PAGE;
|
|
147
|
+
}
|
|
148
|
+
if (styleIsolation === 'app') {
|
|
149
|
+
return exports.ALIPAY_CLASS_MASK_APP | exports.ALIPAY_CLASS_MASK_COMPONENT;
|
|
150
|
+
}
|
|
151
|
+
if (styleIsolation === 'app-and-page') {
|
|
152
|
+
return (exports.ALIPAY_CLASS_MASK_APP |
|
|
153
|
+
exports.ALIPAY_CLASS_MASK_PAGE |
|
|
154
|
+
exports.ALIPAY_CLASS_MASK_COMPONENT);
|
|
155
|
+
}
|
|
156
|
+
return exports.ALIPAY_CLASS_MASK_COMPONENT;
|
|
157
|
+
}
|
|
158
|
+
exports.getAlipayStyleIsolationClassMask = getAlipayStyleIsolationClassMask;
|
|
159
|
+
function isAlipayStyleIsolationClass(value) {
|
|
160
|
+
return exports.ALIPAY_STYLE_CLASS_PREFIXES.some((prefix) => value.startsWith(prefix));
|
|
161
|
+
}
|
|
162
|
+
exports.isAlipayStyleIsolationClass = isAlipayStyleIsolationClass;
|
|
163
|
+
/**
|
|
164
|
+
* 静态 class 在编译期直接展开,避免把可提前完成的字符串处理留到 SJS 运行时。
|
|
165
|
+
* 保留前缀属于支付宝隔离实现的内部协议,静态可识别的用户 class 必须及时报错。
|
|
166
|
+
*/
|
|
167
|
+
function formatAlipayStyleIsolationClasses(value, mask, keepRaw = true) {
|
|
168
|
+
const result = [];
|
|
169
|
+
const classes = value.split(/\s+/).filter(Boolean);
|
|
170
|
+
for (const clazz of classes) {
|
|
171
|
+
if (isAlipayStyleIsolationClass(clazz)) {
|
|
172
|
+
throw new Error(`支付宝小程序样式隔离不允许 class 使用保留前缀:${clazz}`);
|
|
173
|
+
}
|
|
174
|
+
// externalClass 跨组件传递时不能保留原名,否则子组件会将其误认为本地 class 再补组件前缀。
|
|
175
|
+
if (keepRaw) {
|
|
176
|
+
result.push(clazz);
|
|
177
|
+
}
|
|
178
|
+
if (mask & exports.ALIPAY_CLASS_MASK_APP) {
|
|
179
|
+
result.push('-a-' + clazz);
|
|
180
|
+
}
|
|
181
|
+
if (mask & exports.ALIPAY_CLASS_MASK_PAGE) {
|
|
182
|
+
result.push('-p-' + clazz);
|
|
183
|
+
}
|
|
184
|
+
if (mask & exports.ALIPAY_CLASS_MASK_COMPONENT) {
|
|
185
|
+
result.push('-c-' + clazz);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return result.join(' ');
|
|
189
|
+
}
|
|
190
|
+
exports.formatAlipayStyleIsolationClasses = formatAlipayStyleIsolationClasses;
|
|
115
191
|
function createDefaultSFCStyleBlock(source) {
|
|
116
192
|
const offset = source.length;
|
|
117
193
|
return {
|
package/dist/mp/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export * from './constants';
|
|
|
9
9
|
export { HTML_TO_MINI_PROGRAM_TAGS } from './tags';
|
|
10
10
|
export { copyMiniProgramPluginJson, copyMiniProgramThemeJson, createCopyPluginTarget, } from './plugin';
|
|
11
11
|
export { parseMainDescriptor, parseScriptDescriptor, parseTemplateDescriptor, transformDynamicImports, updateMiniProgramGlobalComponents, updateMiniProgramComponentsByMainFilename, updateMiniProgramComponentsByScriptFilename, updateMiniProgramComponentsByTemplateFilename, getGlobalComponentSource, } from './usingComponents';
|
|
12
|
-
export { hasExternalClasses, parseExternalClasses, parseStyleIsolation, findMiniProgramComponentExternalClasses, updateMiniProgramComponentExternalClasses, updateMiniProgramComponentStyleIsolation, findMiniProgramComponentStyleIsolation, findPageExternalClasses, updatePageExternalClasses, addPageExternalClasses, clearPageExternalClasses, createDefaultSFCStyleBlock, } from './externalClasses';
|
|
12
|
+
export { hasExternalClasses, parseExternalClasses, parseStyleIsolation, findMiniProgramComponentExternalClasses, updateMiniProgramComponentExternalClasses, updateMiniProgramComponentStyleIsolation, clearMiniProgramComponentStyleIsolation, findMiniProgramComponentStyleIsolation, findPageExternalClasses, updatePageExternalClasses, addPageExternalClasses, clearPageExternalClasses, createDefaultSFCStyleBlock, isAlipayXStyleIsolation, getAlipayStyleIsolationClassMask, isAlipayStyleIsolationClass, formatAlipayStyleIsolationClasses, ALIPAY_CLASS_MASK_APP, ALIPAY_CLASS_MASK_PAGE, ALIPAY_CLASS_MASK_COMPONENT, ALIPAY_STYLE_CLASS_PREFIXES, } from './externalClasses';
|
|
13
13
|
export type { PageExternalClassesInfo } from './externalClasses';
|
package/dist/mp/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createDefaultSFCStyleBlock = exports.clearPageExternalClasses = exports.addPageExternalClasses = exports.updatePageExternalClasses = exports.findPageExternalClasses = exports.findMiniProgramComponentStyleIsolation = exports.updateMiniProgramComponentStyleIsolation = exports.updateMiniProgramComponentExternalClasses = exports.findMiniProgramComponentExternalClasses = exports.parseStyleIsolation = exports.parseExternalClasses = exports.hasExternalClasses = exports.getGlobalComponentSource = exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.transformDynamicImports = exports.parseTemplateDescriptor = exports.parseScriptDescriptor = exports.parseMainDescriptor = exports.createCopyPluginTarget = exports.copyMiniProgramThemeJson = exports.copyMiniProgramPluginJson = exports.HTML_TO_MINI_PROGRAM_TAGS = void 0;
|
|
17
|
+
exports.ALIPAY_STYLE_CLASS_PREFIXES = exports.ALIPAY_CLASS_MASK_COMPONENT = exports.ALIPAY_CLASS_MASK_PAGE = exports.ALIPAY_CLASS_MASK_APP = exports.formatAlipayStyleIsolationClasses = exports.isAlipayStyleIsolationClass = exports.getAlipayStyleIsolationClassMask = exports.isAlipayXStyleIsolation = exports.createDefaultSFCStyleBlock = exports.clearPageExternalClasses = exports.addPageExternalClasses = exports.updatePageExternalClasses = exports.findPageExternalClasses = exports.findMiniProgramComponentStyleIsolation = exports.clearMiniProgramComponentStyleIsolation = exports.updateMiniProgramComponentStyleIsolation = exports.updateMiniProgramComponentExternalClasses = exports.findMiniProgramComponentExternalClasses = exports.parseStyleIsolation = exports.parseExternalClasses = exports.hasExternalClasses = exports.getGlobalComponentSource = exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.transformDynamicImports = exports.parseTemplateDescriptor = exports.parseScriptDescriptor = exports.parseMainDescriptor = exports.createCopyPluginTarget = exports.copyMiniProgramThemeJson = exports.copyMiniProgramPluginJson = exports.HTML_TO_MINI_PROGRAM_TAGS = void 0;
|
|
18
18
|
__exportStar(require("./ast"), exports);
|
|
19
19
|
__exportStar(require("./wxs"), exports);
|
|
20
20
|
__exportStar(require("./nvue"), exports);
|
|
@@ -46,9 +46,18 @@ Object.defineProperty(exports, "parseStyleIsolation", { enumerable: true, get: f
|
|
|
46
46
|
Object.defineProperty(exports, "findMiniProgramComponentExternalClasses", { enumerable: true, get: function () { return externalClasses_1.findMiniProgramComponentExternalClasses; } });
|
|
47
47
|
Object.defineProperty(exports, "updateMiniProgramComponentExternalClasses", { enumerable: true, get: function () { return externalClasses_1.updateMiniProgramComponentExternalClasses; } });
|
|
48
48
|
Object.defineProperty(exports, "updateMiniProgramComponentStyleIsolation", { enumerable: true, get: function () { return externalClasses_1.updateMiniProgramComponentStyleIsolation; } });
|
|
49
|
+
Object.defineProperty(exports, "clearMiniProgramComponentStyleIsolation", { enumerable: true, get: function () { return externalClasses_1.clearMiniProgramComponentStyleIsolation; } });
|
|
49
50
|
Object.defineProperty(exports, "findMiniProgramComponentStyleIsolation", { enumerable: true, get: function () { return externalClasses_1.findMiniProgramComponentStyleIsolation; } });
|
|
50
51
|
Object.defineProperty(exports, "findPageExternalClasses", { enumerable: true, get: function () { return externalClasses_1.findPageExternalClasses; } });
|
|
51
52
|
Object.defineProperty(exports, "updatePageExternalClasses", { enumerable: true, get: function () { return externalClasses_1.updatePageExternalClasses; } });
|
|
52
53
|
Object.defineProperty(exports, "addPageExternalClasses", { enumerable: true, get: function () { return externalClasses_1.addPageExternalClasses; } });
|
|
53
54
|
Object.defineProperty(exports, "clearPageExternalClasses", { enumerable: true, get: function () { return externalClasses_1.clearPageExternalClasses; } });
|
|
54
55
|
Object.defineProperty(exports, "createDefaultSFCStyleBlock", { enumerable: true, get: function () { return externalClasses_1.createDefaultSFCStyleBlock; } });
|
|
56
|
+
Object.defineProperty(exports, "isAlipayXStyleIsolation", { enumerable: true, get: function () { return externalClasses_1.isAlipayXStyleIsolation; } });
|
|
57
|
+
Object.defineProperty(exports, "getAlipayStyleIsolationClassMask", { enumerable: true, get: function () { return externalClasses_1.getAlipayStyleIsolationClassMask; } });
|
|
58
|
+
Object.defineProperty(exports, "isAlipayStyleIsolationClass", { enumerable: true, get: function () { return externalClasses_1.isAlipayStyleIsolationClass; } });
|
|
59
|
+
Object.defineProperty(exports, "formatAlipayStyleIsolationClasses", { enumerable: true, get: function () { return externalClasses_1.formatAlipayStyleIsolationClasses; } });
|
|
60
|
+
Object.defineProperty(exports, "ALIPAY_CLASS_MASK_APP", { enumerable: true, get: function () { return externalClasses_1.ALIPAY_CLASS_MASK_APP; } });
|
|
61
|
+
Object.defineProperty(exports, "ALIPAY_CLASS_MASK_PAGE", { enumerable: true, get: function () { return externalClasses_1.ALIPAY_CLASS_MASK_PAGE; } });
|
|
62
|
+
Object.defineProperty(exports, "ALIPAY_CLASS_MASK_COMPONENT", { enumerable: true, get: function () { return externalClasses_1.ALIPAY_CLASS_MASK_COMPONENT; } });
|
|
63
|
+
Object.defineProperty(exports, "ALIPAY_STYLE_CLASS_PREFIXES", { enumerable: true, get: function () { return externalClasses_1.ALIPAY_STYLE_CLASS_PREFIXES; } });
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
|
|
7
7
|
const pages_1 = require("../../json/pages");
|
|
8
8
|
const externalClasses_1 = require("../../mp/externalClasses");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
9
10
|
/**
|
|
10
11
|
* 基于页面 externalClasses 使用情况提升页面样式优先级
|
|
11
12
|
*
|
|
@@ -31,6 +32,11 @@ const externalPlugin = () => {
|
|
|
31
32
|
if (!platform.startsWith('mp-')) {
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
35
|
+
// 支付宝 ACSS 不支持 [class],隔离 2.0 使用来源前缀完成样式命中控制。
|
|
36
|
+
if ((0, externalClasses_1.isAlipayXStyleIsolation)()) {
|
|
37
|
+
processAlipayStyleIsolation(root);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
34
40
|
// 从 postcss source 中获取当前样式所属文件
|
|
35
41
|
const filePath = root.source?.input?.file;
|
|
36
42
|
if (!filePath) {
|
|
@@ -66,6 +72,46 @@ const externalPlugin = () => {
|
|
|
66
72
|
},
|
|
67
73
|
};
|
|
68
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* 单 class 选择器按 App、页面、组件来源改写为不同前缀;页面额外补 page 提权,
|
|
77
|
+
* 从而在同名 class 下保持“页面 > 组件 > App”。复杂选择器继续遵循支付宝原生行为。
|
|
78
|
+
*/
|
|
79
|
+
function processAlipayStyleIsolation(root) {
|
|
80
|
+
const filePath = root.source?.input?.file;
|
|
81
|
+
if (!filePath) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const prefix = (0, utils_1.isAppVue)(filePath)
|
|
85
|
+
? '-a-'
|
|
86
|
+
: (0, pages_1.isUniPageFile)(filePath)
|
|
87
|
+
? '-p-'
|
|
88
|
+
: '-c-';
|
|
89
|
+
const isPage = prefix === '-p-';
|
|
90
|
+
root.walkRules((rule) => {
|
|
91
|
+
if (rule.parent?.type === 'atrule' &&
|
|
92
|
+
/-?keyframes$/.test(rule.parent.name)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
rule.selector = (0, postcss_selector_parser_1.default)((selectorRoot) => {
|
|
96
|
+
selectorRoot.each((selector) => {
|
|
97
|
+
// 所有静态 CSS class 都要校验,防止用户 class 与内部隔离键冲突。
|
|
98
|
+
selector.walkClasses((classNode) => {
|
|
99
|
+
if ((0, externalClasses_1.isAlipayStyleIsolationClass)(classNode.value)) {
|
|
100
|
+
throw rule.error(`支付宝小程序样式隔离不允许 class 使用保留前缀:${classNode.value}`);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
if (selector.nodes.length !== 1 || selector.nodes[0].type !== 'class') {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
selector.nodes[0].value = prefix + selector.nodes[0].value;
|
|
107
|
+
if (isPage) {
|
|
108
|
+
selector.prepend(postcss_selector_parser_1.default.combinator({ value: ' ' }));
|
|
109
|
+
selector.prepend(postcss_selector_parser_1.default.tag({ value: 'page' }));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}).processSync(rule.selector);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
69
115
|
function processRule(rule, processedRules, staticClasses, hasDynamic) {
|
|
70
116
|
// 同一个 Rule 只处理一次,避免被重复追加 [class]
|
|
71
117
|
if (processedRules.has(rule)) {
|
package/dist/resolve.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export declare function resolvePinia(): string;
|
|
|
12
12
|
export declare function resolveProjectPinia(): string | undefined;
|
|
13
13
|
export declare function resolvePiniaDependencies(): Record<string, string>;
|
|
14
14
|
export declare function resolvePiniaAlias(): Record<string, string>;
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function resolveVueI18nAlias(): Record<string, string>;
|
|
16
16
|
export declare function resolveComponentsLibPath(): string;
|
|
17
17
|
export declare function resolveComponentsLibDirs(): string[];
|