@mpxjs/webpack-plugin 2.8.28-beta.1 → 2.8.28-beta.2
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/runtime/stringify.wxs +44 -8
- package/package.json +2 -2
|
@@ -24,8 +24,9 @@ function objectKeys (obj) {
|
|
|
24
24
|
var shift = false
|
|
25
25
|
for (var i = 1; i < objStr.length - 1; i++) {
|
|
26
26
|
var item = objStr[i]
|
|
27
|
+
var lastItem = objStr[i - 1]
|
|
27
28
|
if (inKey) {
|
|
28
|
-
if (item === ':') {
|
|
29
|
+
if (item === ':' && lastItem === '"') {
|
|
29
30
|
keys.push(key.slice(1, -1))
|
|
30
31
|
key = ''
|
|
31
32
|
inKey = false
|
|
@@ -93,18 +94,53 @@ function isDef (v) {
|
|
|
93
94
|
return v !== undefined && v !== null
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
var escapeMap = {
|
|
98
|
+
'(': '_pl_',
|
|
99
|
+
')': '_pr_',
|
|
100
|
+
'[': '_bl_',
|
|
101
|
+
']': '_br_',
|
|
102
|
+
'{': '_cl_',
|
|
103
|
+
'#': '_h_',
|
|
104
|
+
'!': '_i_',
|
|
105
|
+
'/': '_s_',
|
|
106
|
+
'.': '_d_',
|
|
107
|
+
':': '_c_',
|
|
108
|
+
',': '_2c_',
|
|
109
|
+
'%': '_p_',
|
|
110
|
+
// wxs can not use '\'' as key
|
|
111
|
+
// wxs环境中'\''!=="'",此文件不能格式化,否则会导致程序错误
|
|
112
|
+
"'": '_q_',
|
|
113
|
+
// wxs can not use '"' as key
|
|
114
|
+
'"': '_dq_',
|
|
115
|
+
'+': '_a_',
|
|
116
|
+
'$': '_si_'
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
var escapeReg = genRegExp('[()[\]{}#!/.:,%\'"+$]', 'g')
|
|
120
|
+
|
|
121
|
+
function mpEscape (str) {
|
|
122
|
+
return str.replace(escapeReg, function (match) {
|
|
123
|
+
if (escapeMap[match]) return escapeMap[match]
|
|
124
|
+
// fix wxs can not use '}' as key
|
|
125
|
+
if (match === '}') return '_cr_'
|
|
126
|
+
// unknown escaped
|
|
127
|
+
return '_u_'
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
96
132
|
function stringifyDynamicClass (value) {
|
|
97
|
-
if (!value) return ''
|
|
98
133
|
if (isArray(value)) {
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return stringifyObject(value)
|
|
134
|
+
value = stringifyArray(value)
|
|
135
|
+
} else if (isObject(value)) {
|
|
136
|
+
value = stringifyObject(value)
|
|
103
137
|
}
|
|
138
|
+
|
|
104
139
|
if (typeof value === 'string') {
|
|
105
|
-
return value
|
|
140
|
+
return mpEscape(value)
|
|
141
|
+
} else {
|
|
142
|
+
return ''
|
|
106
143
|
}
|
|
107
|
-
return ''
|
|
108
144
|
}
|
|
109
145
|
|
|
110
146
|
function stringifyArray (value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.28-beta.
|
|
3
|
+
"version": "2.8.28-beta.2",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14.14.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "8b8a77ed1cc2f6fcd9def0aac15c7d31d05f62c4"
|
|
86
86
|
}
|