@shijiu/jsview 1.9.921 → 1.9.943-next-vue.0
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/dom/bin/jsview-dom-browser.min.js +1 -1
- package/dom/bin/jsview-dom-native.min.js +1 -1
- package/dom/bin/jsview-engine-js-browser.min.js +1 -1
- package/dom/bin/jsview-forge-define.min.js +1 -1
- package/dom/index.mjs +2 -1
- package/dom/target_core_revision.mjs +4 -4
- package/loader/jsview-loader.js +1 -5
- package/package.json +1 -1
- package/patches/node_modules/@vitejs/plugin-vue/dist/index.mjs +2729 -0
- package/patches/node_modules/@vitejs/plugin-vue/package.json +51 -0
- package/patches/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js +3152 -0
- package/patches/node_modules/@vue/compiler-dom/package.json +43 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js +90 -25
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-checker.js +189 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-formator.cjs.js +919 -0
- package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +17 -0
- package/patches/node_modules/postcss-js/objectifier.js +1 -1
- package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +2 -2
- package/tools/jsview-batch-upgrade.mjs +40 -5
- package/tools/jsview-post-install.mjs +2 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-format.js +0 -201
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-types.js +0 -83
|
@@ -333,6 +333,23 @@ function parseName(name) {
|
|
|
333
333
|
options[m[0].toLowerCase()] = true;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
+
// JsView Added >>>
|
|
337
|
+
// 处理自定义的 addEventListener() options, 前缀为jsv
|
|
338
|
+
// onJsvXxx留给自定义Event,这样判断防止出现下面写法
|
|
339
|
+
// :jsvevent.jsvoption1.jsvoption2 => onJsvEventJsvOption1JsvOption2
|
|
340
|
+
if (name.lastIndexOf('Jsv') > 2) {
|
|
341
|
+
options = options ?? {};
|
|
342
|
+
|
|
343
|
+
const optNames = name.substring(3); // 过滤掉jsvEvent
|
|
344
|
+
const optArray = optNames.split('Jsv');
|
|
345
|
+
// optArray[0] 为EventName部分内容
|
|
346
|
+
for (let idx = optArray.length - 1; idx > 0; idx--) {
|
|
347
|
+
const optName = 'jsv' + optArray[idx];
|
|
348
|
+
options[optName] = true;
|
|
349
|
+
name = name.slice(0, name.length - optName.length);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
// JsView Added <<<
|
|
336
353
|
const event = name[2] === ':' ? name.slice(3) : hyphenate(name.slice(2));
|
|
337
354
|
return [event, options];
|
|
338
355
|
}
|
|
@@ -34,8 +34,8 @@ const jsviewConfig = defineConfig({
|
|
|
34
34
|
'export-sfc': ['\0plugin-vue:export-helper'], // 将_export_sfc独立出来,防止被集成在jsview-vue中导致import deadloop.
|
|
35
35
|
'vue': ['vue'], // 将vue独立出来,防止被集成在main.js中导致import deadloop.
|
|
36
36
|
// 将dom-entry和forge-define分割出来,防止被集成在main.js中导致import deadloop.
|
|
37
|
-
'forge-define': ['@shijiu/jsview/dom/jsv-forge-define.mjs'],
|
|
38
|
-
'jsivew-dom-entry': ['@shijiu/jsview/dom/index.mjs'],
|
|
37
|
+
// 'forge-define': ['@shijiu/jsview/dom/jsv-forge-define.mjs'],
|
|
38
|
+
// 'jsivew-dom-entry': ['@shijiu/jsview/dom/index.mjs'],
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
},
|
|
@@ -176,15 +176,45 @@ function upgradeStagePixel(options) {
|
|
|
176
176
|
// 过滤 (+ px), (+ 'px'), (+ "px"), (+ `px`), ( + ' px ') 等
|
|
177
177
|
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
178
178
|
/ *\+ ['"`]* *px *['"`]*/g, '');
|
|
179
|
-
// 过滤 (00px), ('00px'), ("00px"), (`00px`), ('00px') 等
|
|
180
|
-
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
181
|
-
/['"`]*([0-9]+)px['"`]*/g, '$1');
|
|
182
179
|
// 过滤 (' 00px '), (" 00px "), (` 00px `), ('00px ') 等
|
|
183
180
|
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
184
|
-
/
|
|
181
|
+
/' *([0-9]+)px *'/g, '$1');
|
|
182
|
+
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
183
|
+
/" *([0-9]+)px *"/g, '$1');
|
|
184
|
+
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
185
|
+
/` *([0-9]+)px *`/g, '$1');
|
|
185
186
|
// 过滤 ('${00}px'), ("${00}px"), (`${00}px`), ( ' ${00}px ') 等
|
|
186
187
|
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
187
188
|
/['"`]*(\${.*?})px *['"`]*/g, '$1');
|
|
189
|
+
// 过滤 (00px), ('00px'), ("00px"), (`00px`), ('00px') 等
|
|
190
|
+
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
191
|
+
/'([0-9]+)px'/g, '$1');
|
|
192
|
+
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
193
|
+
/"([0-9]+)px"/g, '$1');
|
|
194
|
+
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
195
|
+
/`([0-9]+)px`/g, '$1');
|
|
196
|
+
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
197
|
+
/([0-9]+)px/g, '$1');
|
|
198
|
+
|
|
199
|
+
const numberStyleList = [
|
|
200
|
+
'height',
|
|
201
|
+
'left',
|
|
202
|
+
'top',
|
|
203
|
+
'width',
|
|
204
|
+
|
|
205
|
+
'borderRadius',
|
|
206
|
+
|
|
207
|
+
'fontSize',
|
|
208
|
+
'lineHeight',
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
for (const numberStyle of numberStyleList) {
|
|
212
|
+
const regExp = new RegExp(`:${numberStyle}=['"\`] *([0-9]+) *['"\`]`, 'g');
|
|
213
|
+
const toValue = `:${numberStyle}=$1`;
|
|
214
|
+
|
|
215
|
+
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
216
|
+
regExp, toValue);
|
|
217
|
+
}
|
|
188
218
|
|
|
189
219
|
return;
|
|
190
220
|
}
|
|
@@ -242,7 +272,12 @@ function upgradeStageImportPostfix(options)
|
|
|
242
272
|
|
|
243
273
|
let fixedContent = content;
|
|
244
274
|
|
|
245
|
-
|
|
275
|
+
let importFilePath = null;
|
|
276
|
+
if (importFromFile.startsWith('@')) {
|
|
277
|
+
importFilePath = path.resolve(options.rootDir, 'src', importFromFile.replace('@/', ''));
|
|
278
|
+
} else {
|
|
279
|
+
importFilePath = path.resolve(currentDir, importFromFile);
|
|
280
|
+
}
|
|
246
281
|
if (fs.existsSync(importFilePath + '.js')) {
|
|
247
282
|
// 执行到此处,则需要给给import的文件加上js尾缀。当同时存在.js和.vue时,.js优先。
|
|
248
283
|
fixedContent = content.replace(importFromFile, importFromFile + '.js');
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
const { StyleName, StyleVariable } = require("./jsview-style-types");
|
|
2
|
-
|
|
3
|
-
class StyleConverter {
|
|
4
|
-
static ToInteger(value) {
|
|
5
|
-
if (StyleVariable.IsVariable(value)) {
|
|
6
|
-
return value;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (!value) {
|
|
10
|
-
return value;
|
|
11
|
-
}
|
|
12
|
-
if (typeof value !== "string") {
|
|
13
|
-
return Math.floor(value);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
value = StyleConverter.ExecIfCalc(value);
|
|
17
|
-
const ret = parseInt(value);
|
|
18
|
-
if (ret != value && value.endsWith('px') == false) {
|
|
19
|
-
throw Error("Bad unit in value " + value);
|
|
20
|
-
}
|
|
21
|
-
return ret;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static ToFloat(value) {
|
|
25
|
-
if (StyleVariable.IsVariable(value)) {
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!value) {
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
if (typeof value !== "string") {
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
value = StyleConverter.ExecIfCalc(value);
|
|
37
|
-
let ret = parseFloat(value);
|
|
38
|
-
return ret;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static ToString(value) {
|
|
42
|
-
if (StyleVariable.IsVariable(value)) {
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (!value) {
|
|
47
|
-
return "";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
value = StyleConverter.ExecIfCalc(value);
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static ExecIfCalc(value) {
|
|
55
|
-
if (typeof value !== "string") {
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const isCalc = (value.startsWith("calc("));
|
|
60
|
-
if (!isCalc) {
|
|
61
|
-
return value;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const expr = value.replace(/calc(\(.*\))/, '$1')
|
|
65
|
-
let ret = null;
|
|
66
|
-
try {
|
|
67
|
-
ret = eval(expr);
|
|
68
|
-
} catch (ex) {
|
|
69
|
-
console.error("Failed to exec StyleConverter.ExecIfCalc(" + value + ")");
|
|
70
|
-
throw ex;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
console.log('execIfCalc() value=', value, " ret=", ret);
|
|
74
|
-
return ret;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
class StyleFormatter {
|
|
80
|
-
static GetFormattedValue(propName, propValue) {
|
|
81
|
-
let formattedValue = propValue;
|
|
82
|
-
|
|
83
|
-
switch (propName) {
|
|
84
|
-
case StyleName.Layout.Height:
|
|
85
|
-
case StyleName.Layout.Left:
|
|
86
|
-
case StyleName.Layout.Top:
|
|
87
|
-
case StyleName.Layout.Width:
|
|
88
|
-
formattedValue = StyleFormatter.#GetLayoutValue(propName, propValue);
|
|
89
|
-
break;
|
|
90
|
-
case StyleName.Background.BackgroundColor:
|
|
91
|
-
case StyleName.Background.BackgroundImage:
|
|
92
|
-
case StyleName.Background.BorderRadius:
|
|
93
|
-
formattedValue = StyleFormatter.#GetBackgroundValue(propName, propValue);
|
|
94
|
-
break;
|
|
95
|
-
case StyleName.Effect.BackfaceVisibility:
|
|
96
|
-
case StyleName.Effect.BorderImage:
|
|
97
|
-
case StyleName.Effect.BorderImageWidth:
|
|
98
|
-
case StyleName.Effect.BorderImageOutset:
|
|
99
|
-
case StyleName.Effect.ClipPath:
|
|
100
|
-
case StyleName.Effect.Display:
|
|
101
|
-
case StyleName.Effect.ObjectFit:
|
|
102
|
-
case StyleName.Effect.Opacity:
|
|
103
|
-
case StyleName.Effect.Overflow:
|
|
104
|
-
case StyleName.Effect.Perspective:
|
|
105
|
-
case StyleName.Effect.PerspectiveOrigin:
|
|
106
|
-
case StyleName.Effect.Visibility:
|
|
107
|
-
case StyleName.Effect.ZIndex:
|
|
108
|
-
formattedValue = StyleFormatter.#GetEffectValue(propName, propValue);
|
|
109
|
-
break;
|
|
110
|
-
case StyleName.Text.Color:
|
|
111
|
-
case StyleName.Text.FontFamily:
|
|
112
|
-
case StyleName.Text.FontSize:
|
|
113
|
-
case StyleName.Text.FontStyle:
|
|
114
|
-
case StyleName.Text.FontWeight:
|
|
115
|
-
case StyleName.Text.LineHeight:
|
|
116
|
-
case StyleName.Text.TextAlign:
|
|
117
|
-
case StyleName.Text.TextShadow:
|
|
118
|
-
case StyleName.Text.TextOverflow:
|
|
119
|
-
case StyleName.Text.Transform:
|
|
120
|
-
case StyleName.Text.TransformOrigin:
|
|
121
|
-
case StyleName.Text.TransformStyle:
|
|
122
|
-
case StyleName.Text.WebkitTextStroke:
|
|
123
|
-
case StyleName.Text.WhiteSpace:
|
|
124
|
-
case StyleName.Text.WordWrap:
|
|
125
|
-
formattedValue = StyleFormatter.#GetTextValue(propName, propValue);
|
|
126
|
-
break;
|
|
127
|
-
case StyleName.Motion.Animation:
|
|
128
|
-
case StyleName.Motion.Transition:
|
|
129
|
-
formattedValue = StyleFormatter.#GetMotionValue(propName, propValue);
|
|
130
|
-
break;
|
|
131
|
-
default:
|
|
132
|
-
// 返回未处理的值
|
|
133
|
-
console.warn("JsView Warn: Unimplemented style property [" + propName + "]");
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return formattedValue;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
static #GetLayoutValue(propName, propValue) {
|
|
141
|
-
const formattedValue = StyleConverter.ToInteger(propValue);
|
|
142
|
-
|
|
143
|
-
return formattedValue;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
static #GetBackgroundValue(propName, propValue) {
|
|
147
|
-
let formattedValue = null;
|
|
148
|
-
switch (propName) {
|
|
149
|
-
default:
|
|
150
|
-
formattedValue = StyleConverter.ToString(propValue);
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return formattedValue;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
static #GetEffectValue(propName, propValue) {
|
|
158
|
-
let formattedValue = null;
|
|
159
|
-
switch (propName) {
|
|
160
|
-
case StyleName.Effect.ClipPath:
|
|
161
|
-
case StyleName.Effect.Display:
|
|
162
|
-
case StyleName.Effect.Overflow:
|
|
163
|
-
case StyleName.Effect.Visibility:
|
|
164
|
-
formattedValue = StyleConverter.ToString(propValue);
|
|
165
|
-
break;
|
|
166
|
-
case StyleName.Effect.Opacity:
|
|
167
|
-
formattedValue = StyleConverter.ToFloat(propValue);
|
|
168
|
-
break;
|
|
169
|
-
default:
|
|
170
|
-
formattedValue = StyleConverter.ToInteger(propValue);
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return formattedValue;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
static #GetTextValue(propName, propValue) {
|
|
178
|
-
let formattedValue = null;
|
|
179
|
-
switch (propName) {
|
|
180
|
-
case StyleName.Text.FontSize:
|
|
181
|
-
case StyleName.Text.LineHeight:
|
|
182
|
-
formattedValue = StyleConverter.ToInteger(propValue);
|
|
183
|
-
break;
|
|
184
|
-
default:
|
|
185
|
-
formattedValue = StyleConverter.ToString(propValue);
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return formattedValue;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
static #GetMotionValue(propName, propValue) {
|
|
193
|
-
// 需要留到执行时处理
|
|
194
|
-
const formattedValue = StyleConverter.ToString(propValue);
|
|
195
|
-
|
|
196
|
-
return formattedValue;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
exports.getFormattedValue = StyleFormatter.GetFormattedValue;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
class StyleName {
|
|
2
|
-
static Layout = class {
|
|
3
|
-
static Height = "height";
|
|
4
|
-
static Left = "left";
|
|
5
|
-
static Top = "top";
|
|
6
|
-
static Width = "width";
|
|
7
|
-
|
|
8
|
-
constructor() { throw new Error("new StyleName.Layout() is forbidden."); }
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static Background = class {
|
|
12
|
-
static BackgroundColor = "backgroundColor";
|
|
13
|
-
static BackgroundImage = "backgroundImage";
|
|
14
|
-
static BorderRadius = "borderRadius";
|
|
15
|
-
|
|
16
|
-
constructor() { throw new Error("new StyleName.Background() is forbidden."); }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static Effect = class {
|
|
20
|
-
static BackfaceVisibility = "backfaceVisibility";
|
|
21
|
-
static BorderImage = "borderImage";
|
|
22
|
-
static BorderImageWidth = "borderImageWidth";
|
|
23
|
-
static BorderImageOutset = "borderImageOutset";
|
|
24
|
-
static ClipPath = "clipPath";
|
|
25
|
-
static Display = "display";
|
|
26
|
-
static ObjectFit = "objectFit";
|
|
27
|
-
static Opacity = "opacity";
|
|
28
|
-
static Overflow = "overflow";
|
|
29
|
-
static Perspective = "perspective";
|
|
30
|
-
static PerspectiveOrigin = "perspectiveOrigin";
|
|
31
|
-
static Transform = "transform";
|
|
32
|
-
static TransformOrigin = "transformOrigin";
|
|
33
|
-
static TransformStyle = "transformStyle";
|
|
34
|
-
static Visibility = "visibility";
|
|
35
|
-
static ZIndex = "zIndex";
|
|
36
|
-
|
|
37
|
-
constructor() { throw new Error("new StyleName.Effect() is forbidden."); }
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static Text = class {
|
|
41
|
-
static Color = "color";
|
|
42
|
-
static FontFamily = "fontFamily";
|
|
43
|
-
static FontSize = "fontSize";
|
|
44
|
-
static FontStyle = "fontStyle";
|
|
45
|
-
static FontWeight = "fontWeight";
|
|
46
|
-
static LineHeight = "lineHeight";
|
|
47
|
-
static TextAlign = "textAlign";
|
|
48
|
-
static TextOverflow = "textOverflow";
|
|
49
|
-
static TextShadow = "textShadow";
|
|
50
|
-
static Transform = "transform";
|
|
51
|
-
static TransformOrigin = "transformOrigin";
|
|
52
|
-
static TransformStyle = "transformStyle";
|
|
53
|
-
static WebkitTextStroke = "WebkitTextStroke";
|
|
54
|
-
static WhiteSpace = "whiteSpace";
|
|
55
|
-
static WordWrap = "wordWrap";
|
|
56
|
-
static JsvTextEmoji = "JsvTextEmoji";
|
|
57
|
-
|
|
58
|
-
constructor() { throw new Error("new StyleName.Text() is forbidden."); }
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
static Motion = class {
|
|
62
|
-
static Animation = "animation";
|
|
63
|
-
static Transition = "transition";
|
|
64
|
-
|
|
65
|
-
constructor() { throw new Error("new StyleName.Motion() is forbidden."); }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
constructor() { throw new Error("new StyleName() is forbidden."); }
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
class StyleVariable {
|
|
72
|
-
static IsVariable(value) {
|
|
73
|
-
let variable = value.toString();
|
|
74
|
-
|
|
75
|
-
const isVar = (variable.startsWith("--") || variable.startsWith("var(--"));
|
|
76
|
-
return isVar;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
constructor() { throw new Error("new StyleVariable() is forbidden."); }
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
exports.StyleName = StyleName;
|
|
83
|
-
exports.StyleVariable = StyleVariable;
|