@mpxjs/webpack-plugin 2.10.17-beta.3 → 2.10.17-beta.6
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/lib/config.js +60 -0
- package/lib/file-loader.js +4 -1
- package/lib/global.d.ts +245 -0
- package/lib/index.js +29 -2
- package/lib/json-compiler/index.js +13 -4
- package/lib/loader.js +4 -0
- package/lib/platform/json/wx/index.js +6 -0
- package/lib/platform/style/wx/index.js +57 -33
- package/lib/platform/template/wx/component-config/ad.js +5 -0
- package/lib/platform/template/wx/component-config/button.js +10 -3
- package/lib/platform/template/wx/component-config/camera.js +25 -3
- package/lib/platform/template/wx/component-config/canvas.js +8 -1
- package/lib/platform/template/wx/component-config/cover-image.js +7 -2
- package/lib/platform/template/wx/component-config/cover-view.js +3 -1
- package/lib/platform/template/wx/component-config/form.js +27 -2
- package/lib/platform/template/wx/component-config/image.js +5 -0
- package/lib/platform/template/wx/component-config/input.js +11 -1
- package/lib/platform/template/wx/component-config/label.js +10 -2
- package/lib/platform/template/wx/component-config/map.js +11 -0
- package/lib/platform/template/wx/component-config/movable-area.js +4 -1
- package/lib/platform/template/wx/component-config/movable-view.js +17 -2
- package/lib/platform/template/wx/component-config/navigator.js +26 -0
- package/lib/platform/template/wx/component-config/picker-view.js +12 -0
- package/lib/platform/template/wx/component-config/picker.js +3 -1
- package/lib/platform/template/wx/component-config/progress.js +11 -1
- package/lib/platform/template/wx/component-config/rich-text.js +5 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
- package/lib/platform/template/wx/component-config/slider.js +8 -0
- package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
- package/lib/platform/template/wx/component-config/swiper.js +10 -0
- package/lib/platform/template/wx/component-config/text.js +5 -0
- package/lib/platform/template/wx/component-config/textarea.js +20 -3
- package/lib/platform/template/wx/component-config/unsupported.js +10 -1
- package/lib/platform/template/wx/component-config/video.js +10 -0
- package/lib/platform/template/wx/index.js +21 -1
- package/lib/react/LoadAsyncChunkModule.js +1 -1
- package/lib/react/processStyles.js +21 -9
- package/lib/react/style-helper.js +76 -13
- package/lib/resolver/AddModePlugin.js +23 -8
- package/lib/runtime/components/react/animationHooks/index.ts +75 -0
- package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +198 -0
- package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +297 -0
- package/lib/runtime/components/react/animationHooks/utils.ts +196 -0
- package/lib/runtime/components/react/context.ts +7 -1
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +15 -0
- package/lib/runtime/components/react/dist/animationHooks/index.js +67 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +182 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +274 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.js +150 -0
- package/lib/runtime/components/react/dist/context.d.ts +6 -2
- package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-camera.jsx +236 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +10 -9
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +11 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +71 -39
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts +3 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +22 -8
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/parser.d.ts +0 -1
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts +1 -1
- package/lib/runtime/components/react/dist/utils.jsx +34 -13
- package/lib/runtime/components/react/mpx-camera.tsx +327 -0
- package/lib/runtime/components/react/mpx-input.tsx +15 -9
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +7 -2
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
- package/lib/runtime/components/react/mpx-swiper.tsx +86 -37
- package/lib/runtime/components/react/mpx-view.tsx +27 -12
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/tsconfig.json +26 -0
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +34 -16
- package/lib/runtime/optionProcessor.js +5 -0
- package/lib/runtime/optionProcessorReact.js +7 -0
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/style-compiler/strip-conditional-loader/rebaseUrl.js +225 -0
- package/lib/style-compiler/strip-conditional-loader.js +76 -185
- package/lib/template-compiler/compiler.js +1 -3
- package/lib/utils/dom-tag-config.js +1 -1
- package/lib/utils/string.js +25 -1
- package/package.json +6 -4
- package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.js +0 -289
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +0 -320
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
const path = require('node:path')
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {(id: string, importer?: string, aliasOnly?: boolean) => Promise<string | undefined>} ResolveIdFn
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {(unquotedUrl: string, rawUrl: string) => Promise<string | false> | string | false} CssUrlReplacer
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// https://drafts.csswg.org/css-syntax-3/#identifier-code-point
|
|
10
|
+
const cssUrlRE = /(?<!@import\s+)(?<=^|[^\w\-\u0080-\uffff])url\((\s*('[^']+'|"[^"]+")\s*|(?:\\.|[^'")\\])+)\)/
|
|
11
|
+
const cssDataUriRE = /(?<=^|[^\w\-\u0080-\uffff])data-uri\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/
|
|
12
|
+
const importCssRE = /@import\s+(?:url\()?('[^']+\.css'|"[^"]+\.css"|[^'"\s)]+\.css)/
|
|
13
|
+
const nonEscapedDoubleQuoteRe = /(?<!\\)"/g
|
|
14
|
+
const externalRE = /^([a-z]+:)?\/\//
|
|
15
|
+
const isExternalUrl = url => externalRE.test(url)
|
|
16
|
+
|
|
17
|
+
const dataUrlRE = /^\s*data:/i
|
|
18
|
+
const isDataUrl = url => dataUrlRE.test(url)
|
|
19
|
+
const functionCallRE = /^[A-Z_][.\w-]*\(/i
|
|
20
|
+
|
|
21
|
+
function skipUrlReplacer(unquotedUrl) {
|
|
22
|
+
return isExternalUrl(unquotedUrl) || isDataUrl(unquotedUrl) || unquotedUrl[0] === '#' || unquotedUrl[0] === '@' || functionCallRE.test(unquotedUrl)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {string} rawUrl
|
|
28
|
+
* @param {string} matched
|
|
29
|
+
* @param {CssUrlReplacer} replacer
|
|
30
|
+
* @param {string} funcName
|
|
31
|
+
* @returns {Promise<string>}
|
|
32
|
+
*/
|
|
33
|
+
async function doUrlReplace(rawUrl, matched, replacer, funcName = 'url') {
|
|
34
|
+
let wrap = ''
|
|
35
|
+
const first = rawUrl[0]
|
|
36
|
+
let unquotedUrl = rawUrl
|
|
37
|
+
if (first === '"' || first === "'") {
|
|
38
|
+
wrap = first
|
|
39
|
+
unquotedUrl = rawUrl.slice(1, -1)
|
|
40
|
+
}
|
|
41
|
+
if (skipUrlReplacer(unquotedUrl)) {
|
|
42
|
+
return matched
|
|
43
|
+
}
|
|
44
|
+
// Remove escape sequences to get the actual file name before resolving.
|
|
45
|
+
unquotedUrl = unquotedUrl.replace(/\\(\W)/g, '$1')
|
|
46
|
+
|
|
47
|
+
let newUrl = await replacer(unquotedUrl, rawUrl)
|
|
48
|
+
if (newUrl === false) {
|
|
49
|
+
return matched
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The new url might need wrapping even if the original did not have it, e.g.
|
|
53
|
+
// if a space was added during replacement or the URL contains ")"
|
|
54
|
+
if (wrap === '' && (newUrl !== encodeURI(newUrl) || newUrl.includes(')'))) {
|
|
55
|
+
wrap = '"'
|
|
56
|
+
}
|
|
57
|
+
// If wrapping in single quotes and newUrl also contains single quotes, switch to double quotes.
|
|
58
|
+
// Give preference to double quotes since SVG inlining converts double quotes to single quotes.
|
|
59
|
+
if (wrap === "'" && newUrl.includes("'")) {
|
|
60
|
+
wrap = '"'
|
|
61
|
+
}
|
|
62
|
+
// Escape double quotes if they exist (they also tend to be rarer than single quotes)
|
|
63
|
+
if (wrap === '"' && newUrl.includes('"')) {
|
|
64
|
+
newUrl = newUrl.replace(nonEscapedDoubleQuoteRe, '\\"')
|
|
65
|
+
}
|
|
66
|
+
return `${funcName}(${wrap}${newUrl}${wrap})`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param {string} rawUrl
|
|
72
|
+
* @param {string} matched
|
|
73
|
+
* @param {CssUrlReplacer} replacer
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
async function doImportCSSReplace(rawUrl, matched, replacer) {
|
|
77
|
+
let wrap = ''
|
|
78
|
+
const first = rawUrl[0]
|
|
79
|
+
let unquotedUrl = rawUrl
|
|
80
|
+
if (first === '"' || first === "'") {
|
|
81
|
+
wrap = first
|
|
82
|
+
unquotedUrl = rawUrl.slice(1, -1)
|
|
83
|
+
}
|
|
84
|
+
if (skipUrlReplacer(unquotedUrl)) {
|
|
85
|
+
return matched
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const newUrl = await replacer(unquotedUrl, rawUrl)
|
|
89
|
+
if (newUrl === false) {
|
|
90
|
+
return matched
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const prefix = matched.includes('url(') ? 'url(' : ''
|
|
94
|
+
return `@import ${prefix}${wrap}${newUrl}${wrap}`
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param {string} input
|
|
100
|
+
* @param {RegExp} re
|
|
101
|
+
* @param {(match: RegExpMatchArray) => string | Promise<string>} replacer
|
|
102
|
+
* @returns {Promise<string>}
|
|
103
|
+
*/
|
|
104
|
+
async function asyncReplace(input, re, replacer) {
|
|
105
|
+
let match = null
|
|
106
|
+
let remaining = input
|
|
107
|
+
let rewritten = ''
|
|
108
|
+
while ((match = re.exec(remaining))) {
|
|
109
|
+
rewritten += remaining.slice(0, match.index)
|
|
110
|
+
rewritten += await replacer(match)
|
|
111
|
+
remaining = remaining.slice(match.index + match[0].length)
|
|
112
|
+
}
|
|
113
|
+
rewritten += remaining
|
|
114
|
+
return rewritten
|
|
115
|
+
}
|
|
116
|
+
module.exports.asyncReplace = asyncReplace
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
*
|
|
120
|
+
* @param {string} css
|
|
121
|
+
* @param {CssUrlReplacer} replacer
|
|
122
|
+
* @returns
|
|
123
|
+
*/
|
|
124
|
+
function rewriteCssUrls(css, replacer) {
|
|
125
|
+
return asyncReplace(css, cssUrlRE, async match => {
|
|
126
|
+
const [matched, rawUrl] = match
|
|
127
|
+
return await doUrlReplace(rawUrl.trim(), matched, replacer)
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* @param {string} css
|
|
134
|
+
* @param {CssUrlReplacer} replacer
|
|
135
|
+
* @returns
|
|
136
|
+
*/
|
|
137
|
+
function rewriteCssDataUris(css, replacer) {
|
|
138
|
+
return asyncReplace(css, cssDataUriRE, async match => {
|
|
139
|
+
const [matched, rawUrl] = match
|
|
140
|
+
return await doUrlReplace(rawUrl.trim(), matched, replacer, 'data-uri')
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
*
|
|
145
|
+
* @param {string} css
|
|
146
|
+
* @param {CssUrlReplacer} replacer
|
|
147
|
+
* @returns
|
|
148
|
+
*/
|
|
149
|
+
function rewriteImportCss(css, replacer) {
|
|
150
|
+
return asyncReplace(css, importCssRE, async match => {
|
|
151
|
+
const [matched, rawUrl] = match
|
|
152
|
+
return await doImportCSSReplace(rawUrl, matched, replacer)
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const windowsSlashRE = /\\/g
|
|
157
|
+
function slash(p) {
|
|
158
|
+
return p.replace(windowsSlashRE, '/')
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const isWindows = typeof process !== 'undefined' && process.platform === 'win32'
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
* @param {string} id
|
|
165
|
+
* @returns {string}
|
|
166
|
+
*/
|
|
167
|
+
function normalizePath(id) {
|
|
168
|
+
return path.posix.normalize(isWindows ? slash(id) : id)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
*
|
|
173
|
+
* @param {string} file
|
|
174
|
+
* @param {string} rootFile
|
|
175
|
+
* @param {string} content
|
|
176
|
+
* @param {ResolveIdFn} resolver
|
|
177
|
+
* @param {(unquotedUrl: string, rawUrl: string) => boolean} [ignoreUrl]
|
|
178
|
+
* @returns {Promise<{ file: string, contents?: string }>}
|
|
179
|
+
*/
|
|
180
|
+
async function rebaseUrls(file, rootFile, content, resolver, ignoreUrl) {
|
|
181
|
+
// file = path.resolve(file) // ensure os-specific flashes
|
|
182
|
+
// in the same dir, no need to rebase
|
|
183
|
+
const fileDir = path.dirname(file)
|
|
184
|
+
const rootDir = path.dirname(rootFile)
|
|
185
|
+
|
|
186
|
+
// no url()
|
|
187
|
+
const hasUrls = cssUrlRE.test(content)
|
|
188
|
+
// data-uri() calls
|
|
189
|
+
const hasDataUris = cssDataUriRE.test(content)
|
|
190
|
+
// no @import xxx.css
|
|
191
|
+
const hasImportCss = importCssRE.test(content)
|
|
192
|
+
|
|
193
|
+
if (!hasUrls && !hasDataUris && !hasImportCss) {
|
|
194
|
+
return { file }
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
let rebased
|
|
198
|
+
const rebaseFn = async (unquotedUrl, rawUrl) => {
|
|
199
|
+
if (ignoreUrl?.(unquotedUrl, rawUrl)) return false
|
|
200
|
+
if (unquotedUrl[0] === '/') return unquotedUrl
|
|
201
|
+
const absolute = (await resolver(unquotedUrl, file)) || path.resolve(fileDir, unquotedUrl)
|
|
202
|
+
const relative = path.relative(rootDir, absolute)
|
|
203
|
+
return normalizePath(relative)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// fix css imports in less such as `@import "foo.css"`
|
|
207
|
+
if (hasImportCss) {
|
|
208
|
+
rebased = await rewriteImportCss(content, rebaseFn)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (hasUrls) {
|
|
212
|
+
rebased = await rewriteCssUrls(rebased || content, rebaseFn)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (hasDataUris) {
|
|
216
|
+
rebased = await rewriteCssDataUris(rebased || content, rebaseFn)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
file,
|
|
221
|
+
contents: rebased
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
module.exports.rebaseUrls = rebaseUrls
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
const fs = require('fs
|
|
2
|
-
const parseRequest = require('../utils/parse-request')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const loaderUtils = require('loader-utils')
|
|
1
|
+
const fs = require('fs')
|
|
5
2
|
|
|
6
3
|
class Node {
|
|
7
4
|
constructor(type, condition = null) {
|
|
@@ -14,7 +11,12 @@ class Node {
|
|
|
14
11
|
|
|
15
12
|
// 提取 css string 为 token
|
|
16
13
|
function tokenize(cssString) {
|
|
17
|
-
|
|
14
|
+
// Support /* ... */, // ..., and <!-- ... --> styles
|
|
15
|
+
// 1. : /\/\*\s*@mpx-(if|elif|else|endif)(?:\s*\(([\s\S]*?)\))?\s*\*\//g
|
|
16
|
+
// 2. : /\/\/\s*@mpx-(if|elif|else|endif)(?:\s*\((.*?)\))?\s*$/gm
|
|
17
|
+
// 3. : /<!--\s*@mpx-(if|elif|else|endif)(?:\s*\(([\s\S]*?)\))?\s*-->/g
|
|
18
|
+
// Combined:
|
|
19
|
+
const regex = /(?:\/\*\s*@mpx-(if|elif|else|endif)(?:\s*\(([\s\S]*?)\))?\s*\*\/)|(?:\/\/\s*@mpx-(if|elif|else|endif)(?:\s*\((.*?)\))?\s*)|(?:<!--\s*@mpx-(if|elif|else|endif)(?:\s*\(([\s\S]*?)\))?\s*-->)/g
|
|
18
20
|
const tokens = []
|
|
19
21
|
let lastIndex = 0
|
|
20
22
|
let match
|
|
@@ -25,11 +27,15 @@ function tokenize(cssString) {
|
|
|
25
27
|
const text = cssString.substring(lastIndex, match.index)
|
|
26
28
|
tokens.push({ type: 'text', content: text })
|
|
27
29
|
}
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
+
// 1,2: (/* ... */)
|
|
31
|
+
// 3,4: (// ...)
|
|
32
|
+
// 5,6: (<!-- ... -->)
|
|
33
|
+
const type = match[1] || match[3] || match[5]
|
|
34
|
+
const condition = (match[2] || match[4] || match[6])
|
|
35
|
+
|
|
30
36
|
tokens.push({
|
|
31
|
-
type:
|
|
32
|
-
condition:
|
|
37
|
+
type: type,
|
|
38
|
+
condition: condition ? condition.trim() : null
|
|
33
39
|
})
|
|
34
40
|
lastIndex = regex.lastIndex
|
|
35
41
|
}
|
|
@@ -131,189 +137,81 @@ function traverseAndEvaluate(ast, defs) {
|
|
|
131
137
|
*/
|
|
132
138
|
function stripCondition(content, defs) {
|
|
133
139
|
const ast = parse(content)
|
|
134
|
-
|
|
135
|
-
return result
|
|
140
|
+
return traverseAndEvaluate(ast, defs)
|
|
136
141
|
}
|
|
137
142
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
* @property {string} css 源文件
|
|
143
|
-
* @property {Record<string, any>} defs 条件定义
|
|
144
|
-
* @property {import('webpack').LoaderContext<any>['resolve']} resolve webpack resolve 方法
|
|
145
|
-
*/
|
|
143
|
+
let proxyReadFileSync
|
|
144
|
+
let proxyReadFile
|
|
145
|
+
const rawReadFileSync = fs.readFileSync
|
|
146
|
+
const rawReadFile = fs.readFile
|
|
146
147
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
* @property {(filename: string) => Promise<string> | string;} load 加载文件内容的函数
|
|
151
|
-
* @property {(id: string, base: string) => Promise<string | null> | string | null;} resolve 解析文件路径的函数
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
async function atImport(options) {
|
|
155
|
-
let { css, load, resolve, from } = options
|
|
156
|
-
const fromParent = path.dirname(from)
|
|
157
|
-
const e1 = /\/\*[\s\S]*?\*\//g
|
|
158
|
-
// 匹配 // 单行注释,可能匹配到静态资源中的 http:// 的 //,不过影响不大, @import 不太可能出现在静态资源链接中
|
|
159
|
-
const e2 = /\/\/.*/g
|
|
160
|
-
// 使用正则匹配匹配出 多行注释和单行注释
|
|
161
|
-
const comments = []
|
|
162
|
-
let comment
|
|
163
|
-
while ((comment = e1.exec(css))) {
|
|
164
|
-
const [content] = comment
|
|
165
|
-
comments.push({
|
|
166
|
-
start: comment.index,
|
|
167
|
-
end: comment.index + content.length,
|
|
168
|
-
content: content
|
|
169
|
-
})
|
|
148
|
+
function rewriteFSForCss() {
|
|
149
|
+
fs.readFileSync = function () {
|
|
150
|
+
return (proxyReadFileSync || rawReadFileSync).apply(fs, arguments)
|
|
170
151
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const [content] = comment
|
|
174
|
-
comments.push({
|
|
175
|
-
start: comment.index,
|
|
176
|
-
end: comment.index + content.length,
|
|
177
|
-
content: content
|
|
178
|
-
})
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// 排序方便二分
|
|
182
|
-
comments.sort((a, b) => (a.start > b.start ? 1 : -1))
|
|
183
|
-
|
|
184
|
-
function isInComments(index) {
|
|
185
|
-
let left = 0
|
|
186
|
-
let right = comments.length - 1
|
|
187
|
-
|
|
188
|
-
while (left <= right) {
|
|
189
|
-
const mid = Math.floor((left + right) / 2)
|
|
190
|
-
const comment = comments[mid]
|
|
191
|
-
|
|
192
|
-
if (index >= comment.start && index <= comment.end) {
|
|
193
|
-
return true
|
|
194
|
-
} else if (index < comment.start) {
|
|
195
|
-
right = mid - 1
|
|
196
|
-
} else {
|
|
197
|
-
left = mid + 1
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return false
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// 使用正则表达式匹配出所有 @import 语法,语法包含 @import "path", @import 'path', @import url("path"), @import url('path')
|
|
205
|
-
// 注意清理分号,否则留个分号会报错
|
|
206
|
-
const importRegex = /@import\s+(url\(['"]([^'"]+)['"]\)|['"]([^'"]+)['"])(\s*;)?/g
|
|
207
|
-
let importList = []
|
|
208
|
-
let importMatch
|
|
209
|
-
while ((importMatch = importRegex.exec(css))) {
|
|
210
|
-
const fullMatch = importMatch[0]
|
|
211
|
-
const importSyntax = fullMatch.trim()
|
|
212
|
-
importSyntax.startsWith('@import')
|
|
213
|
-
const importValue = importSyntax.slice(7).trim()
|
|
214
|
-
// 匹配 @import 后字符串格式
|
|
215
|
-
const importUrlRegex = /url\s*\(['"]([^'"]+)['"]\)/g
|
|
216
|
-
const importStrRegexp = /^(['"])([^'"]+)\1/
|
|
217
|
-
|
|
218
|
-
let urlMatch = null
|
|
219
|
-
if (importValue.startsWith('url')) {
|
|
220
|
-
urlMatch = importUrlRegex.exec(importValue)?.[1]
|
|
221
|
-
} else {
|
|
222
|
-
urlMatch = importStrRegexp.exec(importValue)?.[2]
|
|
223
|
-
}
|
|
224
|
-
if (!urlMatch) {
|
|
225
|
-
continue
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
importList.push({
|
|
229
|
-
start: importMatch.index,
|
|
230
|
-
end: importMatch.index + fullMatch.length,
|
|
231
|
-
content: fullMatch,
|
|
232
|
-
url: urlMatch
|
|
233
|
-
})
|
|
152
|
+
fs.readFile = function () {
|
|
153
|
+
return (proxyReadFile || rawReadFile).apply(fs, arguments)
|
|
234
154
|
}
|
|
235
|
-
|
|
236
|
-
// 过滤掉在注释中的 @import 语法
|
|
237
|
-
importList = importList.filter(imp => !isInComments(imp.start))
|
|
238
|
-
|
|
239
|
-
// 逆序替换 import,避免修改内容导致的索引偏移问题
|
|
240
|
-
importList.sort((a, b) => (a.start > b.start ? -1 : 1))
|
|
241
|
-
|
|
242
|
-
for (const imp of importList) {
|
|
243
|
-
const importPath = imp.url
|
|
244
|
-
if (!importPath) continue
|
|
245
|
-
// 非法路径直接报错
|
|
246
|
-
const resolvedUrl = await resolve(importPath, fromParent)
|
|
247
|
-
const content = (await load(resolvedUrl)) ?? ''
|
|
248
|
-
css = css.slice(0, imp.start) + '\n' + content + '\n' + css.slice(imp.end)
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return css
|
|
252
155
|
}
|
|
253
|
-
/**
|
|
254
|
-
* @param {StripByPostcssOption} options
|
|
255
|
-
*/
|
|
256
|
-
async function stripByPostcss(options) {
|
|
257
|
-
const defs = options.defs ?? {}
|
|
258
|
-
|
|
259
|
-
function stripContentCondition(content) {
|
|
260
|
-
content = stripCondition(content, defs)
|
|
261
156
|
|
|
262
|
-
|
|
263
|
-
|
|
157
|
+
function startFSStripForCss(defs) {
|
|
158
|
+
function shouldStrip(path) {
|
|
159
|
+
return typeof path === 'string' && /\.(styl|scss|sass|less|css|mpx)$/.test(path)
|
|
160
|
+
}
|
|
161
|
+
proxyReadFileSync = function (path, options) {
|
|
162
|
+
const content = rawReadFileSync.call(fs, path, options)
|
|
163
|
+
if (shouldStrip(path)) {
|
|
164
|
+
try {
|
|
165
|
+
if (typeof content === 'string') {
|
|
166
|
+
return stripCondition(content, defs)
|
|
167
|
+
} else if (Buffer.isBuffer(content)) {
|
|
168
|
+
const str = content.toString('utf-8')
|
|
169
|
+
const result = stripCondition(str, defs)
|
|
170
|
+
if (result !== str) {
|
|
171
|
+
return Buffer.from(result, 'utf-8')
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} catch (e) {
|
|
175
|
+
return content
|
|
176
|
+
}
|
|
264
177
|
}
|
|
265
|
-
|
|
266
178
|
return content
|
|
267
179
|
}
|
|
268
180
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const atImportOptions = {
|
|
275
|
-
async load(filename) {
|
|
276
|
-
let content = await fs.readFile(filename, 'utf-8')
|
|
181
|
+
proxyReadFile = function () {
|
|
182
|
+
const args = Array.from(arguments)
|
|
183
|
+
const callback = args[args.length - 1]
|
|
184
|
+
const path = args[0]
|
|
277
185
|
|
|
278
|
-
|
|
186
|
+
if (typeof callback !== 'function') {
|
|
187
|
+
return rawReadFile.apply(fs, args)
|
|
188
|
+
}
|
|
279
189
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
190
|
+
const wrappedCallback = (err, data) => {
|
|
191
|
+
if (err) return callback(err)
|
|
192
|
+
if (shouldStrip(path)) {
|
|
193
|
+
try {
|
|
194
|
+
if (typeof data === 'string') {
|
|
195
|
+
const result = stripCondition(data, defs)
|
|
196
|
+
return callback(null, result)
|
|
197
|
+
} else if (Buffer.isBuffer(data)) {
|
|
198
|
+
const content = data.toString('utf-8')
|
|
199
|
+
const result = stripCondition(content, defs)
|
|
200
|
+
if (result !== content) {
|
|
201
|
+
return callback(null, Buffer.from(result, 'utf-8'))
|
|
202
|
+
}
|
|
293
203
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
204
|
+
} catch (e) {
|
|
205
|
+
return callback(null, data)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
callback(null, data)
|
|
297
209
|
}
|
|
298
|
-
}
|
|
299
210
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
...atImportOptions,
|
|
303
|
-
from: options.resourcePath,
|
|
304
|
-
css: afterConditionStrip
|
|
305
|
-
})
|
|
211
|
+
args[args.length - 1] = wrappedCallback
|
|
212
|
+
return rawReadFile.apply(fs, args)
|
|
306
213
|
}
|
|
307
214
|
}
|
|
308
|
-
|
|
309
|
-
const createResolver = (contetx, extensions) =>
|
|
310
|
-
contetx.getResolve({ mainFiles: ['index'], extensions: [...extensions, '.css'], preferRelative: true })
|
|
311
|
-
const resolver = {
|
|
312
|
-
stylus: contetx => createResolver(contetx, ['.styl']),
|
|
313
|
-
scss: contetx => createResolver(contetx, ['.scss']),
|
|
314
|
-
less: contetx => createResolver(contetx, ['.styl'])
|
|
315
|
-
}
|
|
316
|
-
|
|
317
215
|
/**
|
|
318
216
|
*
|
|
319
217
|
* @this {import('webpack').LoaderContext<any>}
|
|
@@ -325,18 +223,11 @@ module.exports = async function (css) {
|
|
|
325
223
|
const callback = this.async()
|
|
326
224
|
|
|
327
225
|
const mpx = this.getMpx()
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
const result = await stripByPostcss({
|
|
331
|
-
lang: queryObj.lang,
|
|
332
|
-
resourcePath,
|
|
333
|
-
css,
|
|
334
|
-
defs: mpx.defs,
|
|
335
|
-
resolve: resolver[queryObj.lang] ? resolver[queryObj.lang](this) : this.resolve.bind(this)
|
|
336
|
-
})
|
|
226
|
+
const result = stripCondition(css, mpx.defs)
|
|
337
227
|
|
|
338
|
-
callback(null, result
|
|
228
|
+
callback(null, result)
|
|
339
229
|
}
|
|
340
230
|
|
|
341
|
-
module.exports.stripByPostcss = stripByPostcss
|
|
342
231
|
module.exports.stripCondition = stripCondition
|
|
232
|
+
module.exports.rewriteFSForCss = rewriteFSForCss
|
|
233
|
+
module.exports.startFSStripForCss = startFSStripForCss
|
|
@@ -764,8 +764,6 @@ function parse (template, options) {
|
|
|
764
764
|
|
|
765
765
|
const children = currentParent.children
|
|
766
766
|
|
|
767
|
-
// const isTextLikeParent = currentParent.tag === 'text' || currentParent.tag === 'mpx-text' || currentParent.tag === 'Text' || currentParent.tag === 'mpx-simple-text'
|
|
768
|
-
|
|
769
767
|
if (currentParent.tag !== 'text') {
|
|
770
768
|
text = text.trim()
|
|
771
769
|
} else {
|
|
@@ -2719,7 +2717,7 @@ function postProcessTemplate (el) {
|
|
|
2719
2717
|
}
|
|
2720
2718
|
}
|
|
2721
2719
|
|
|
2722
|
-
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,tenon,ios,android,harmony,noMode')
|
|
2720
|
+
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,tenon,ios,android,harmony,ks,noMode')
|
|
2723
2721
|
|
|
2724
2722
|
function isValidModeP (i) {
|
|
2725
2723
|
return isValidMode(i[0] === '_' ? i.slice(1) : i)
|
|
@@ -91,7 +91,7 @@ const isBuildInReactTag = makeMap(
|
|
|
91
91
|
'mpx-movable-area,mpx-label,mpx-input,' +
|
|
92
92
|
'mpx-image,mpx-form,mpx-checkbox,mpx-checkbox-group,mpx-button,' +
|
|
93
93
|
'mpx-rich-text,mpx-picker-view-column,mpx-picker-view,mpx-picker,' +
|
|
94
|
-
'mpx-icon,mpx-canvas'
|
|
94
|
+
'mpx-icon,mpx-canvas,mpx-camera'
|
|
95
95
|
)
|
|
96
96
|
|
|
97
97
|
const isSpace = makeMap('ensp,emsp,nbsp')
|
package/lib/utils/string.js
CHANGED
|
@@ -28,9 +28,33 @@ function trimBlankRow (str) {
|
|
|
28
28
|
return str.replace(/^\s*[\r\n]/gm, '')
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// 多value解析
|
|
32
|
+
function parseValues (str, char = ' ') {
|
|
33
|
+
let stack = 0
|
|
34
|
+
let temp = ''
|
|
35
|
+
const result = []
|
|
36
|
+
for (let i = 0; i < str.length; i++) {
|
|
37
|
+
if (str[i] === '(') {
|
|
38
|
+
stack++
|
|
39
|
+
} else if (str[i] === ')') {
|
|
40
|
+
stack--
|
|
41
|
+
}
|
|
42
|
+
// 非括号内 或者 非分隔字符且非空
|
|
43
|
+
if (stack !== 0 || str[i] !== char) {
|
|
44
|
+
temp += str[i]
|
|
45
|
+
}
|
|
46
|
+
if ((stack === 0 && str[i] === char) || i === str.length - 1) {
|
|
47
|
+
result.push(temp.trim())
|
|
48
|
+
temp = ''
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result
|
|
52
|
+
}
|
|
53
|
+
|
|
31
54
|
module.exports = {
|
|
32
55
|
isCapital,
|
|
33
56
|
isMustache,
|
|
34
57
|
capitalToHyphen,
|
|
35
|
-
trimBlankRow
|
|
58
|
+
trimBlankRow,
|
|
59
|
+
parseValues
|
|
36
60
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.10.17-beta.
|
|
3
|
+
"version": "2.10.17-beta.6",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -80,11 +80,11 @@
|
|
|
80
80
|
"scripts": {
|
|
81
81
|
"test": "jest --passWithNoTests",
|
|
82
82
|
"copy-icons": "cp -r ./lib/runtime/components/react/mpx-icon/icons ./lib/runtime/components/react/dist/mpx-icon/icons",
|
|
83
|
-
"build": "rimraf ./lib/runtime/components/react/dist && tsc && npm run copy-icons"
|
|
83
|
+
"build": "rimraf ./lib/runtime/components/react/dist && tsc -p ./lib/runtime/components/react/tsconfig.json && npm run copy-icons"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@d11/react-native-fast-image": "^8.6.12",
|
|
87
|
-
"@mpxjs/api-proxy": "^2.10.17",
|
|
87
|
+
"@mpxjs/api-proxy": "^2.10.17-beta.0",
|
|
88
88
|
"@types/babel-traverse": "^6.25.4",
|
|
89
89
|
"@types/babel-types": "^7.0.4",
|
|
90
90
|
"@types/glob": "^8.1.0",
|
|
@@ -97,8 +97,10 @@
|
|
|
97
97
|
"react-native-safe-area-context": "^4.12.0",
|
|
98
98
|
"react-native-svg": "^15.8.0",
|
|
99
99
|
"react-native-video": "^6.9.0",
|
|
100
|
+
"react-native-vision-camera": "^4.7.2",
|
|
100
101
|
"react-native-webview": "^13.12.2",
|
|
101
|
-
"rimraf": "^6.0.1"
|
|
102
|
+
"rimraf": "^6.0.1",
|
|
103
|
+
"webpack": "^5.75.0"
|
|
102
104
|
},
|
|
103
105
|
"engines": {
|
|
104
106
|
"node": ">=14.14.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACjF,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG7D,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAC/C,aAAa,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,UAAU,CAAC,KAAK,IAAI,CAAA;CAC/D,CAAC,CA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|
-
{"version":3,"file":"event.config.d.ts","sourceRoot":"","sources":["../event.config.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,cAAc,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAyB3E,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getInnerListeners.d.ts","sourceRoot":"","sources":["../getInnerListeners.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,EAEL,SAAS,EAET,WAAW,EAEX,SAAS,EACT,wBAAwB,EAEzB,MAAM,2BAA2B,CAAA;AAsElC,eAAO,MAAM,cAAc,iCAErB,GAAG;;;WAKA,KAAK,QAgBb,CAAA;AAyID,QAAA,MAAM,aAAa,WACV,KAAK,6CAEA,SAAS,wBA8Dc,wBAAwB,KAAK,IAAI,uBA2BrE,CAAA;AACD,eAAe,aAAa,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mpx-async-suspense.d.ts","sourceRoot":"","sources":["../mpx-async-suspense.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAkC,SAAS,EAAiB,MAAM,OAAO,CAAA;AAiGzG,UAAU,kBAAkB;IAC1B,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,GAAG,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,aAAa,CAAC,OAAO,CAAC,CAAA;IACzC,WAAW,CAAC,EAAE,MAAM,aAAa,CAAC,OAAO,CAAC,CAAA;IAC1C,WAAW,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;CACtC;AAID,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA6E/C,C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AI;IAId,MAAM,IAAK,IAAI;IAMf,aAAa,IAAK,IAAI;IAUtB,oBAAoB,IAAK,IAAI;CAM9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasGradient.d.ts","sourceRoot":"","sources":["../../mpx-canvas/CanvasGradient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAA0B,MAAM,SAAS,CAAA;AAGhF,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,OAAO,CAAC,MAAM,CAAiB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;gBACN,MAAM,EAAE,cAAc,EAAE,gBAAgB,UAAQ;IAQ7D,WAAW,CAAE,OAAO,EAAE,cAAc;CAGrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasRenderingContext2D.d.ts","sourceRoot":"","sources":["../../mpx-canvas/CanvasRenderingContext2D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAA4E,MAAM,SAAS,CAAA;AA0ElI,MAAM,CAAC,OAAO,OAAO,wBAAwB;IAC3C,MAAM,EAAE,cAAc,CAAA;gBACT,MAAM,EAAE,cAAc;IAOnC,WAAW,CAAE,OAAO,EAAE,cAAc;CAGrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../mpx-canvas/Image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAA6B,cAAc,EAAE,MAAM,SAAS,CAAA;AAUnG,qBAAa,KAAK;IAChB,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,OAAO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