119 lines
5.0 KiB
JavaScript
119 lines
5.0 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.COMPONENT_DEPS_CSS = exports.API_DEPS_CSS = exports.resolveWebVaporComponentStyle = void 0;
|
|
const constants_1 = require("./constants");
|
|
const x_1 = require("./x");
|
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
const RESIZE_SENSOR_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'resize-sensor.css';
|
|
const REFRESHER_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'refresher.css';
|
|
const webVaporStyleComponents = new Set([
|
|
'input',
|
|
'textarea',
|
|
'scroll-view',
|
|
'video',
|
|
'web-view',
|
|
'ad',
|
|
]);
|
|
// Easycom、API 和框架内部组件共用同一份路径选择,避免漏载或同时加载旧版与 Vapor 样式。
|
|
// 同步组件优先:将来接入内网实现后,自动使用其生成样式。
|
|
function resolveWebVaporComponentStyle(name) {
|
|
if ((0, uni_shared_1.hasWebVaporComponentStyle)(name)) {
|
|
return constants_1.X_VAPOR_BASE_COMPONENTS_STYLE_PATH + name + '.css';
|
|
}
|
|
if (webVaporStyleComponents.has(name)) {
|
|
return constants_1.H5_COMPONENTS_STYLE_PATH + 'vapor/' + name + '.css';
|
|
}
|
|
}
|
|
exports.resolveWebVaporComponentStyle = resolveWebVaporComponentStyle;
|
|
function componentCss(name, isWebVapor) {
|
|
return ((isWebVapor && resolveWebVaporComponentStyle(name)) ||
|
|
constants_1.BASE_COMPONENTS_STYLE_PATH + name + '.css');
|
|
}
|
|
// 框架内部的 ScrollView 已在框架构建时编译,用户项目的 Easycom 不会再次扫描。
|
|
// Web Vapor 的外层组件或 API 需显式声明其样式,避免发行裁剪时漏载。
|
|
function webVaporScrollViewCss() {
|
|
return [componentCss('scroll-view', true)];
|
|
}
|
|
const API_DEPS_CSS = (isX) => {
|
|
// API 内部组件已随框架编译,需在项目使用该 API 时加载对应渲染模式的样式。
|
|
const isWebVapor = isX && (0, x_1.isUniAppXWebVapor)();
|
|
const scrollViewCss = isWebVapor ? webVaporScrollViewCss() : [];
|
|
const deps_css = {
|
|
showModal: [],
|
|
showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
|
|
showActionSheet: scrollViewCss,
|
|
previewImage: [
|
|
RESIZE_SENSOR_CSS,
|
|
componentCss('swiper', isWebVapor),
|
|
componentCss('swiper-item', isWebVapor),
|
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-area.css`,
|
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-view.css`,
|
|
],
|
|
openLocation: [`${constants_1.H5_API_STYLE_PATH}location-view.css`],
|
|
chooseLocation: [],
|
|
showLoading: [],
|
|
};
|
|
if (isX) {
|
|
deps_css.showModal = [
|
|
componentCss('textarea', isWebVapor),
|
|
...scrollViewCss,
|
|
];
|
|
deps_css.chooseLocation = [
|
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/view.css`,
|
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/text.css`,
|
|
isWebVapor
|
|
? componentCss('input', true)
|
|
: `${constants_1.BASE_COMPONENTS_STYLE_PATH}/input.css`,
|
|
`${constants_1.H5_COMPONENTS_STYLE_PATH}/map.css`,
|
|
...(isWebVapor
|
|
? scrollViewCss
|
|
: [`${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`]),
|
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/image.css`,
|
|
];
|
|
deps_css.showLoading = [
|
|
`${isWebVapor
|
|
? constants_1.X_VAPOR_BASE_COMPONENTS_STYLE_PATH
|
|
: constants_1.X_BASE_COMPONENTS_STYLE_PATH}loading.css`,
|
|
];
|
|
}
|
|
else {
|
|
deps_css.showModal = [`${constants_1.H5_API_STYLE_PATH}modal.css`];
|
|
deps_css.showActionSheet = [`${constants_1.H5_API_STYLE_PATH}action-sheet.css`];
|
|
deps_css.chooseLocation = [
|
|
`${constants_1.H5_API_STYLE_PATH}/location-picker.css`,
|
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/input.css`,
|
|
`${constants_1.H5_COMPONENTS_STYLE_PATH}/map.css`,
|
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`,
|
|
];
|
|
}
|
|
return deps_css;
|
|
};
|
|
exports.API_DEPS_CSS = API_DEPS_CSS;
|
|
const COMPONENT_DEPS_CSS = (isX) => {
|
|
const isWebVapor = isX && (0, x_1.isUniAppXWebVapor)();
|
|
const scrollViewCss = isWebVapor ? webVaporScrollViewCss() : [];
|
|
return {
|
|
canvas: [RESIZE_SENSOR_CSS],
|
|
image: [RESIZE_SENSOR_CSS],
|
|
'movable-area': [RESIZE_SENSOR_CSS],
|
|
'picker-view': [RESIZE_SENSOR_CSS],
|
|
'picker-view-column': [RESIZE_SENSOR_CSS, ...scrollViewCss],
|
|
'rich-text': [RESIZE_SENSOR_CSS],
|
|
textarea: [RESIZE_SENSOR_CSS],
|
|
'web-view': [RESIZE_SENSOR_CSS],
|
|
picker: [
|
|
RESIZE_SENSOR_CSS,
|
|
componentCss('picker-view', isWebVapor),
|
|
componentCss('picker-view-column', isWebVapor),
|
|
...scrollViewCss,
|
|
],
|
|
'scroll-view': isWebVapor ? [] : [REFRESHER_CSS],
|
|
'list-view': [
|
|
RESIZE_SENSOR_CSS,
|
|
...(isWebVapor ? scrollViewCss : [REFRESHER_CSS]),
|
|
],
|
|
...(isWebVapor ? { waterflow: [RESIZE_SENSOR_CSS, ...scrollViewCss] } : {}),
|
|
};
|
|
};
|
|
exports.COMPONENT_DEPS_CSS = COMPONENT_DEPS_CSS;
|