@dcloudio/uni-cli-shared 3.0.0-alpha-3000020210914001 → 3.0.0-alpha-3020920210927001
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.js +2 -2
- package/dist/postcss/index.d.ts +2 -0
- package/dist/postcss/index.js +3 -1
- package/dist/postcss/plugins/uniapp.d.ts +12 -0
- package/dist/postcss/plugins/uniapp.js +85 -0
- package/dist/vite/features.d.ts +1 -0
- package/dist/vite/features.js +12 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +4 -1
- package/package.json +3 -2
package/dist/constants.js
CHANGED
|
@@ -7,9 +7,9 @@ exports.EXTNAME_VUE = ['.vue', '.nvue'];
|
|
|
7
7
|
exports.EXTNAME_VUE_RE = /\.(vue|nvue)$/;
|
|
8
8
|
exports.EXTNAME_JS_RE = /\.[jt]sx?$/;
|
|
9
9
|
// APP 平台解析页面后缀的优先级
|
|
10
|
-
exports.PAGE_EXTNAME_APP = ['.nvue', '.vue'];
|
|
10
|
+
exports.PAGE_EXTNAME_APP = ['.nvue', '.vue', '.tsx', '.jsx', '.js'];
|
|
11
11
|
// 其他平台解析页面后缀的优先级
|
|
12
|
-
exports.PAGE_EXTNAME = ['.vue', '.nvue'];
|
|
12
|
+
exports.PAGE_EXTNAME = ['.vue', '.nvue', '.tsx', '.jsx', '.js'];
|
|
13
13
|
exports.H5_API_STYLE_PATH = '@dcloudio/uni-h5/style/api/';
|
|
14
14
|
exports.H5_FRAMEWORK_STYLE_PATH = '@dcloudio/uni-h5/style/framework/';
|
|
15
15
|
exports.H5_COMPONENTS_STYLE_PATH = '@dcloudio/uni-h5/style/';
|
package/dist/postcss/index.d.ts
CHANGED
package/dist/postcss/index.js
CHANGED
|
@@ -3,6 +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.uniPostcssScopedPlugin = void 0;
|
|
6
|
+
exports.uniPostcssScopedPlugin = exports.uniPostcssPlugin = void 0;
|
|
7
7
|
const stylePluginScoped_1 = __importDefault(require("./plugins/stylePluginScoped"));
|
|
8
8
|
exports.uniPostcssScopedPlugin = stylePluginScoped_1.default;
|
|
9
|
+
const uniapp_1 = __importDefault(require("./plugins/uniapp"));
|
|
10
|
+
exports.uniPostcssPlugin = uniapp_1.default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from 'postcss';
|
|
2
|
+
interface UniAppCssProcessorOptions {
|
|
3
|
+
page?: string;
|
|
4
|
+
unit?: string;
|
|
5
|
+
unitRatio?: number;
|
|
6
|
+
unitPrecision?: number;
|
|
7
|
+
}
|
|
8
|
+
declare const uniapp: {
|
|
9
|
+
(opts?: UniAppCssProcessorOptions | undefined): Plugin;
|
|
10
|
+
postcss: boolean;
|
|
11
|
+
};
|
|
12
|
+
export default uniapp;
|
|
@@ -0,0 +1,85 @@
|
|
|
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 shared_1 = require("@vue/shared");
|
|
7
|
+
const postcss_1 = require("postcss");
|
|
8
|
+
const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
|
|
9
|
+
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
10
|
+
const defaultUniAppCssProcessorOptions = shared_1.extend({
|
|
11
|
+
page: 'body',
|
|
12
|
+
}, uni_shared_1.defaultRpx2Unit);
|
|
13
|
+
const BG_PROPS = [
|
|
14
|
+
'background',
|
|
15
|
+
'background-clip',
|
|
16
|
+
'background-color',
|
|
17
|
+
'background-image',
|
|
18
|
+
'background-origin',
|
|
19
|
+
'background-position',
|
|
20
|
+
'background-repeat',
|
|
21
|
+
'background-size',
|
|
22
|
+
'background-attachment',
|
|
23
|
+
];
|
|
24
|
+
function transform(selector, page, state) {
|
|
25
|
+
if (selector.type !== 'tag') {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const { value } = selector;
|
|
29
|
+
if (uni_shared_1.isBuiltInComponent(value)) {
|
|
30
|
+
selector.value = uni_shared_1.COMPONENT_SELECTOR_PREFIX + value;
|
|
31
|
+
}
|
|
32
|
+
else if (value === 'page') {
|
|
33
|
+
if (!page) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
selector.value = page;
|
|
37
|
+
if (page !== 'body') {
|
|
38
|
+
state.bg = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function createBodyBackgroundRule(origRule) {
|
|
43
|
+
const bgDecls = [];
|
|
44
|
+
origRule.walkDecls((decl) => {
|
|
45
|
+
if (BG_PROPS.indexOf(decl.prop) !== -1) {
|
|
46
|
+
bgDecls.push(decl.clone());
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (bgDecls.length) {
|
|
50
|
+
origRule.after(postcss_1.rule({ selector: 'body' }).append(bgDecls));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function walkRules(page) {
|
|
54
|
+
return (rule) => {
|
|
55
|
+
const state = { bg: false };
|
|
56
|
+
rule.selector = postcss_selector_parser_1.default((selectors) => selectors.walk((selector) => transform(selector, page, state))).processSync(rule.selector);
|
|
57
|
+
state.bg && createBodyBackgroundRule(rule);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function walkDecls(rpx2unit) {
|
|
61
|
+
return (decl) => {
|
|
62
|
+
const { value } = decl;
|
|
63
|
+
if (value.indexOf('rpx') === -1 && value.indexOf('upx') === -1) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
decl.value = rpx2unit(decl.value);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const uniapp = (opts) => {
|
|
70
|
+
const { page, unit, unitRatio, unitPrecision } = shared_1.extend({}, defaultUniAppCssProcessorOptions, opts || {});
|
|
71
|
+
const rpx2unit = uni_shared_1.createRpx2Unit(unit, unitRatio, unitPrecision);
|
|
72
|
+
return {
|
|
73
|
+
postcssPlugin: 'uni-app',
|
|
74
|
+
prepare() {
|
|
75
|
+
return {
|
|
76
|
+
OnceExit(root) {
|
|
77
|
+
root.walkDecls(walkDecls(rpx2unit));
|
|
78
|
+
root.walkRules(walkRules(page));
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
uniapp.postcss = true;
|
|
85
|
+
exports.default = uniapp;
|
package/dist/vite/features.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare function initFeatures(options: InitFeaturesOptions): {
|
|
|
21
21
|
__UNI_FEATURE_I18N_FR__: boolean;
|
|
22
22
|
__UNI_FEATURE_I18N_ZH_HANS__: boolean;
|
|
23
23
|
__UNI_FEATURE_I18N_ZH_HANT__: boolean;
|
|
24
|
+
__UNI_FEATURE_UNI_CLOUD__: boolean;
|
|
24
25
|
__UNI_FEATURE_I18N_LOCALE__: boolean;
|
|
25
26
|
__UNI_FEATURE_NVUE__: boolean;
|
|
26
27
|
__UNI_FEATURE_ROUTER_MODE__: "\"hash\"" | "\"history\"";
|
package/dist/vite/features.js
CHANGED
|
@@ -15,6 +15,7 @@ function initProjectFeature({ inputDir }) {
|
|
|
15
15
|
i18nFr: true,
|
|
16
16
|
i18nZhHans: true,
|
|
17
17
|
i18nZhHant: true,
|
|
18
|
+
uniCloud: false,
|
|
18
19
|
};
|
|
19
20
|
const localesDir = path_1.default.resolve(inputDir, 'locale');
|
|
20
21
|
if (fs_1.default.existsSync(localesDir)) {
|
|
@@ -22,6 +23,15 @@ function initProjectFeature({ inputDir }) {
|
|
|
22
23
|
features.i18nLocale = true;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
26
|
+
if (process.env.UNI_CLOUD_PROVIDER) {
|
|
27
|
+
try {
|
|
28
|
+
const providers = JSON.parse(process.env.UNI_CLOUD_PROVIDER);
|
|
29
|
+
if (providers.length) {
|
|
30
|
+
features.uniCloud = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (e) { }
|
|
34
|
+
}
|
|
25
35
|
return features;
|
|
26
36
|
}
|
|
27
37
|
function initPagesFeature({ pagesJson, command, inputDir, ssr, }) {
|
|
@@ -133,7 +143,7 @@ function initManifestFeature({ manifestJson, command, platform, }) {
|
|
|
133
143
|
return features;
|
|
134
144
|
}
|
|
135
145
|
function initFeatures(options) {
|
|
136
|
-
const { wx, wxs, rpx, nvue, i18nEn, i18nEs, i18nFr, i18nZhHans, i18nZhHant, i18nLocale, vueOptionsApi, vueProdDevTools, pages, tabBar, tabBarMidButton, promise, longpress, routerMode, topWindow, leftWindow, rightWindow, navigationBar, pullDownRefresh, navigationBarButtons, navigationBarSearchInput, navigationBarTransparent, } = shared_1.extend(initManifestFeature(options), initPagesFeature(options), initProjectFeature(options));
|
|
146
|
+
const { wx, wxs, rpx, nvue, uniCloud, i18nEn, i18nEs, i18nFr, i18nZhHans, i18nZhHant, i18nLocale, vueOptionsApi, vueProdDevTools, pages, tabBar, tabBarMidButton, promise, longpress, routerMode, topWindow, leftWindow, rightWindow, navigationBar, pullDownRefresh, navigationBarButtons, navigationBarSearchInput, navigationBarTransparent, } = shared_1.extend(initManifestFeature(options), initPagesFeature(options), initProjectFeature(options));
|
|
137
147
|
const features = {
|
|
138
148
|
// vue
|
|
139
149
|
__VUE_OPTIONS_API__: vueOptionsApi,
|
|
@@ -150,6 +160,7 @@ function initFeatures(options) {
|
|
|
150
160
|
__UNI_FEATURE_I18N_ZH_HANS__: i18nZhHans,
|
|
151
161
|
__UNI_FEATURE_I18N_ZH_HANT__: i18nZhHant,
|
|
152
162
|
// 以下特性,编译器已自动识别是否需要启用
|
|
163
|
+
__UNI_FEATURE_UNI_CLOUD__: uniCloud,
|
|
153
164
|
__UNI_FEATURE_I18N_LOCALE__: i18nLocale,
|
|
154
165
|
__UNI_FEATURE_NVUE__: nvue,
|
|
155
166
|
__UNI_FEATURE_ROUTER_MODE__: routerMode,
|
|
@@ -101,7 +101,10 @@ function cssPlugin(config) {
|
|
|
101
101
|
}
|
|
102
102
|
exports.cssPlugin = cssPlugin;
|
|
103
103
|
function normalizeCssChunkFilename(id) {
|
|
104
|
-
return utils_1.normalizePath(path_1.default.relative(process.env.UNI_INPUT_DIR, id
|
|
104
|
+
return utils_1.normalizePath(path_1.default.relative(process.env.UNI_INPUT_DIR, id
|
|
105
|
+
.split('?')[0]
|
|
106
|
+
.replace(constants_1.EXTNAME_VUE_RE, '.css')
|
|
107
|
+
.replace(constants_1.EXTNAME_JS_RE, '.css')));
|
|
105
108
|
}
|
|
106
109
|
function findCssModuleIds(moduleId, cssModuleIds, seen) {
|
|
107
110
|
if (!cssModuleIds) {
|
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-3020920210927001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
"hash-sum": "^2.0.0",
|
|
30
30
|
"jsonc-parser": "^3.0.0",
|
|
31
31
|
"merge": "^2.1.1",
|
|
32
|
+
"postcss-selector-parser": "^6.0.6",
|
|
32
33
|
"rollup-plugin-copy": "^3.4.0",
|
|
33
34
|
"tapable": "^2.2.0",
|
|
34
35
|
"xregexp": "3.1.0"
|
|
35
36
|
},
|
|
36
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "549c7f3fe68aa81496713db2567a847eeb49c0d7",
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@types/hash-sum": "^1.0.0"
|
|
39
40
|
}
|