@shijiu/jsview 1.9.915 → 1.9.931
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/package.json +1 -1
- 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/compiler-sfc.cjs.js +2 -17
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js +87 -53
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-format.js +4 -4
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-types.js +3 -0
- package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +1531 -0
- package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +17 -0
- package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +3 -0
- package/tools/jsview-batch-upgrade.mjs +67 -36
- package/tools/jsview-post-install.mjs +1 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vue/compiler-dom",
|
|
3
|
+
"version": "3.2.45",
|
|
4
|
+
"description": "@vue/compiler-dom",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "dist/compiler-dom.esm-bundler.js",
|
|
7
|
+
"types": "dist/compiler-dom.d.ts",
|
|
8
|
+
"unpkg": "dist/compiler-dom.global.js",
|
|
9
|
+
"jsdelivr": "dist/compiler-dom.global.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"index.js",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"buildOptions": {
|
|
16
|
+
"name": "VueCompilerDOM",
|
|
17
|
+
"compat": true,
|
|
18
|
+
"formats": [
|
|
19
|
+
"esm-bundler",
|
|
20
|
+
"esm-browser",
|
|
21
|
+
"cjs",
|
|
22
|
+
"global"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/vuejs/core.git",
|
|
28
|
+
"directory": "packages/compiler-dom"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"vue"
|
|
32
|
+
],
|
|
33
|
+
"author": "Evan You",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/vuejs/core/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-dom#readme",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@vue/shared": "3.2.45",
|
|
41
|
+
"@vue/compiler-core": "3.2.45"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -17669,24 +17669,14 @@ function doCompileStyle(options) {
|
|
|
17669
17669
|
// In async mode, return a promise.
|
|
17670
17670
|
if (options.isAsync) {
|
|
17671
17671
|
return result
|
|
17672
|
-
|
|
17673
|
-
// CSS文件异步变动时触发文件更新
|
|
17674
|
-
// .then(result => ({
|
|
17675
|
-
.then(result => {
|
|
17676
|
-
jsvCssToJs.compileAndSaveImportedNode(filename, result.root.nodes)
|
|
17677
|
-
return {
|
|
17678
|
-
// JsView Modified <<<
|
|
17672
|
+
.then(result => ({
|
|
17679
17673
|
code: result.css || '',
|
|
17680
17674
|
map: result.map && result.map.toJSON(),
|
|
17681
17675
|
errors,
|
|
17682
17676
|
modules: cssModules,
|
|
17683
17677
|
rawResult: result,
|
|
17684
17678
|
dependencies: recordPlainCssDependencies(result.messages)
|
|
17685
|
-
|
|
17686
|
-
// CSS文件异步变动时触发文件更新
|
|
17687
|
-
// }))
|
|
17688
|
-
}})
|
|
17689
|
-
// JsView Modified <<<
|
|
17679
|
+
}))
|
|
17690
17680
|
.catch(error => ({
|
|
17691
17681
|
code: '',
|
|
17692
17682
|
map: undefined,
|
|
@@ -17699,11 +17689,6 @@ function doCompileStyle(options) {
|
|
|
17699
17689
|
// force synchronous transform (we know we only have sync plugins)
|
|
17700
17690
|
code = result.css;
|
|
17701
17691
|
outMap = result.map;
|
|
17702
|
-
|
|
17703
|
-
// JsView Added >>>
|
|
17704
|
-
// CSS文件同步变动时触发文件更新
|
|
17705
|
-
jsvCssToJs.compileAndSaveImportedNode(filename, result.result.root.nodes)
|
|
17706
|
-
// JsView Added <<<
|
|
17707
17692
|
}
|
|
17708
17693
|
catch (e) {
|
|
17709
17694
|
errors.push(e);
|
|
@@ -11,32 +11,87 @@ const path = require('path');
|
|
|
11
11
|
const postCssJs = require('postcss-js');
|
|
12
12
|
const styleFormat = require("./jsview-style-format");
|
|
13
13
|
|
|
14
|
+
const compilerSfc = require("./compiler-sfc.cjs");
|
|
15
|
+
const processorLangList = [
|
|
16
|
+
'less',
|
|
17
|
+
'sass',
|
|
18
|
+
'scss',
|
|
19
|
+
'styl',
|
|
20
|
+
'stylus',
|
|
21
|
+
];
|
|
22
|
+
|
|
14
23
|
const cachedCssStyles = {};
|
|
15
24
|
|
|
16
25
|
function ensureSfcDescriptor(descriptor) {
|
|
17
26
|
try {
|
|
18
27
|
ensureSfcDescriptorImpl(descriptor)
|
|
28
|
+
|
|
19
29
|
} catch (exception) {
|
|
20
|
-
console.error("Failed to call ensureSfcDescriptor()! Exception:\n", exception);
|
|
30
|
+
console.error("JsView Error: Failed to call ensureSfcDescriptor()! Exception:\n", exception);
|
|
21
31
|
}
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
function compileCssToJs(sfc, options) {
|
|
25
35
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// return
|
|
36
|
+
// 必须在此处parse css,否则npm run build时进入不到js代码中。
|
|
37
|
+
// const styleJsFilePath = getStyleJsFilePath(sfc.filename);
|
|
38
|
+
// return `\nimport "${styleJsFilePath}";`
|
|
39
|
+
|
|
40
|
+
const compiledJsContent = compileCssToJsImpl(sfc, options)
|
|
41
|
+
return compiledJsContent;
|
|
29
42
|
} catch (exception) {
|
|
30
|
-
console.error("Failed to call compileCssToJs()! Exception:\n", exception);
|
|
43
|
+
console.error("JsView Error: Failed to call compileCssToJs()! Exception:\n", exception);
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
46
|
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
function compileCssToJsImpl(sfc, options) {
|
|
48
|
+
let cachedStyleImports = [];
|
|
49
|
+
let cachedStyleSheets = {};
|
|
50
|
+
for (const style of sfc.styles) {
|
|
51
|
+
if(!!style.module) {
|
|
52
|
+
let errMsg = "JsView Error: style module is not released by Vue3!\n";
|
|
53
|
+
errMsg += style;
|
|
54
|
+
console.error(errMsg + " errors =", errors);
|
|
55
|
+
throw new Error(errMsg)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const compileStyleOptions = {
|
|
59
|
+
filename: sfc.filename,
|
|
60
|
+
id: `data-v-${options.id}`,
|
|
61
|
+
// map: null,
|
|
62
|
+
trim: true,
|
|
63
|
+
isProd: options.isProd,
|
|
64
|
+
|
|
65
|
+
source: style.content,
|
|
66
|
+
scoped: style.scoped,
|
|
67
|
+
modules: style.module,
|
|
68
|
+
|
|
69
|
+
preprocessLang: style.attrs.lang,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
if(!!style.attrs.src) { // 处理<style [scoped] src="xxx">
|
|
73
|
+
const baseDir = path.dirname(sfc.filename);
|
|
74
|
+
const cssSrcPath = path.resolve(baseDir, style.attrs.src);
|
|
75
|
+
compileStyleOptions.source = fs.readFileSync(cssSrcPath, "utf8");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const { rawResult, errors } = compilerSfc.compileStyle(compileStyleOptions)
|
|
79
|
+
if(errors.length) {
|
|
80
|
+
const errMsg = "JsView Error: Failed to compile style when convert css to js!";
|
|
81
|
+
console.error(errMsg + " errors =", errors);
|
|
82
|
+
throw new Error(errMsg)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const {styleImports, styleSheets } = compileAndSaveImportedNode(rawResult.result.root.nodes);
|
|
86
|
+
cachedStyleImports = [...cachedStyleImports, styleImports];
|
|
87
|
+
cachedStyleSheets = { ...cachedStyleSheets, ...styleSheets };
|
|
39
88
|
}
|
|
89
|
+
|
|
90
|
+
const styleJsContents = serializeStyleJsFile(cachedStyleImports, cachedStyleSheets);
|
|
91
|
+
|
|
92
|
+
// console.log("jsview-css-to-js.compileCssToJsImpl() styleJsContents=", styleJsContents);
|
|
93
|
+
|
|
94
|
+
return styleJsContents;
|
|
40
95
|
}
|
|
41
96
|
|
|
42
97
|
function ensureSfcDescriptorImpl(descriptor) {
|
|
@@ -113,8 +168,9 @@ function check(expr, source, errMsg) {
|
|
|
113
168
|
}
|
|
114
169
|
}
|
|
115
170
|
|
|
116
|
-
function
|
|
117
|
-
|
|
171
|
+
function compileAndSaveImportedNode(styleNodes) {
|
|
172
|
+
let styleImports = [];
|
|
173
|
+
let styleSheets = {};
|
|
118
174
|
|
|
119
175
|
styleNodes.forEach(node => {
|
|
120
176
|
if (node.type === "comment"
|
|
@@ -169,61 +225,34 @@ function compileAndSaveImportedNodeImpl(styleFilePath, styleNodes) {
|
|
|
169
225
|
}
|
|
170
226
|
})
|
|
171
227
|
|
|
172
|
-
// console.log('jsview-css-to-js.
|
|
173
|
-
serializeStyleJsFile(styleFilePath, { styleImports, styleSheets });
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function deserializeStyleJsFile(styleFilePath) {
|
|
177
|
-
const styleJsFilePath = getStyleJsFilePath(styleFilePath);
|
|
178
|
-
|
|
179
|
-
let styleImports = [];
|
|
180
|
-
let styleSheets = {};
|
|
181
|
-
|
|
182
|
-
let styleJsContent = fs.readFileSync(styleJsFilePath, "utf8");
|
|
183
|
-
if (styleJsContent) {
|
|
184
|
-
const styleSheetsFlags = getStyleSheetsDeclaredFlags();
|
|
185
|
-
const styleImportsContent = styleJsContent.substring(0, styleJsContent.indexOf(styleSheetsFlags.start));
|
|
186
|
-
let styleSheetsContent = styleJsContent.substring(0, styleJsContent.indexOf(styleSheetsFlags.end));
|
|
187
|
-
styleSheetsContent = styleSheetsContent.substring(styleJsContent.indexOf(styleSheetsFlags.start) + styleSheetsFlags.start.length);
|
|
188
|
-
|
|
189
|
-
styleImports = styleImportsContent.split('\n');
|
|
190
|
-
styleSheets = JSON.parse(styleSheetsContent.length != 0 ? styleSheetsContent : '{}');
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
228
|
+
// console.log('jsview-css-to-js.compileAndSaveImportedNode() styleSheets=', styleImports, styleSheets);
|
|
194
229
|
return {
|
|
195
230
|
styleImports,
|
|
196
231
|
styleSheets,
|
|
197
232
|
}
|
|
198
233
|
}
|
|
199
234
|
|
|
200
|
-
function serializeStyleJsFile(
|
|
201
|
-
|
|
235
|
+
function serializeStyleJsFile(styleImports, styleSheets) {
|
|
236
|
+
if (styleImports.length == 0
|
|
237
|
+
&& Object.keys(styleSheets).length === 0) {
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
202
240
|
|
|
203
|
-
const styleSheetsFlags = getStyleSheetsDeclaredFlags();
|
|
204
241
|
const styleImportsContent = styleImports.join('\n');
|
|
205
242
|
const styleSheetsContent = JSON.stringify(styleSheets);
|
|
206
243
|
|
|
207
|
-
let styleJsContent = "";
|
|
244
|
+
let styleJsContent = "\n";
|
|
208
245
|
styleJsContent += styleImportsContent;
|
|
209
|
-
styleJsContent +=
|
|
246
|
+
styleJsContent += "\nconst styleSheetsContent = ";
|
|
210
247
|
styleJsContent += styleSheetsContent;
|
|
211
|
-
styleJsContent +=
|
|
248
|
+
styleJsContent += ";\nwindow.JsvCode.Dom.DeclareStyleSheets(styleSheetsContent);";
|
|
212
249
|
|
|
213
|
-
|
|
214
|
-
fs.writeFileSync(styleJsFilePath, styleJsContent, "utf8");
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function getStyleSheetsDeclaredFlags() {
|
|
218
|
-
return {
|
|
219
|
-
start: "\nconst styleSheetsContent = ",
|
|
220
|
-
end: ";\nwindow.JsvCode.Dom.DeclareStyleSheets(styleSheetsContent);",
|
|
221
|
-
}
|
|
250
|
+
return styleJsContent;
|
|
222
251
|
}
|
|
223
252
|
|
|
224
253
|
function getStyleJsCacheDir() {
|
|
225
254
|
const nodeModulesDir = path.resolve(process.cwd(), 'node_modules');
|
|
226
|
-
const cacheDir = path.resolve(nodeModulesDir, '
|
|
255
|
+
const cacheDir = path.resolve(nodeModulesDir, '.vite', 'jsview', 'css-to-js'); // 不能放在.vite文件夹,否则有网络缓存,文件改变后不更新
|
|
227
256
|
if (!fs.existsSync(cacheDir)) {
|
|
228
257
|
fs.mkdirSync(cacheDir, { recursive: true });
|
|
229
258
|
}
|
|
@@ -236,7 +265,7 @@ function getStyleJsFilePath(styleFilePath) {
|
|
|
236
265
|
const cacheDir = getStyleJsCacheDir()
|
|
237
266
|
|
|
238
267
|
const styleFilePathHash = crypto.createHash('md5').update(styleFilePath).digest('hex').substring(0, 8);
|
|
239
|
-
const styleJsFileName =
|
|
268
|
+
const styleJsFileName = path.basename(styleFilePath) + '.' + styleFilePathHash + '.js';
|
|
240
269
|
const styleJsFilePath = path.join(cacheDir, styleJsFileName);
|
|
241
270
|
if (!fs.existsSync(styleJsFilePath)) {
|
|
242
271
|
fs.closeSync(fs.openSync(styleJsFilePath, 'w'));
|
|
@@ -345,7 +374,12 @@ function parsePostCssJs(node, selector, declarations) {
|
|
|
345
374
|
function parseUnscopedStyleSheets(node, selector, declarations, scopedId) {
|
|
346
375
|
let styleRules = {};
|
|
347
376
|
|
|
348
|
-
for (
|
|
377
|
+
for (let [name, value] of Object.entries(declarations)) {
|
|
378
|
+
// 处理var变量中如果存在'a.b'的写法,被翻译成'a\.b'的问题。
|
|
379
|
+
if (typeof (value) == 'string' && value.startsWith('var(--')) {
|
|
380
|
+
value = value.replaceAll('\\', '');
|
|
381
|
+
}
|
|
382
|
+
|
|
349
383
|
if (name.startsWith('@keyframes')) { // keyframes解嵌套处理
|
|
350
384
|
check(false, node.source.input.css, "JsView Error: Nested keyframes is not supported!");
|
|
351
385
|
delete declarations[name];
|
|
@@ -370,4 +404,4 @@ function parseUnscopedStyleSheets(node, selector, declarations, scopedId) {
|
|
|
370
404
|
|
|
371
405
|
exports.ensureSfcDescriptor = ensureSfcDescriptor;
|
|
372
406
|
exports.compileCssToJs = compileCssToJs;
|
|
373
|
-
exports.compileAndSaveImportedNode = compileAndSaveImportedNode;
|
|
407
|
+
// exports.compileAndSaveImportedNode = compileAndSaveImportedNode;
|
|
@@ -116,21 +116,21 @@ class StyleFormatter {
|
|
|
116
116
|
case StyleName.Text.TextAlign:
|
|
117
117
|
case StyleName.Text.TextShadow:
|
|
118
118
|
case StyleName.Text.TextOverflow:
|
|
119
|
+
case StyleName.Text.Transform:
|
|
120
|
+
case StyleName.Text.TransformOrigin:
|
|
121
|
+
case StyleName.Text.TransformStyle:
|
|
119
122
|
case StyleName.Text.WebkitTextStroke:
|
|
120
123
|
case StyleName.Text.WhiteSpace:
|
|
121
124
|
case StyleName.Text.WordWrap:
|
|
122
125
|
formattedValue = StyleFormatter.#GetTextValue(propName, propValue);
|
|
123
126
|
break;
|
|
124
127
|
case StyleName.Motion.Animation:
|
|
125
|
-
case StyleName.Motion.Transform:
|
|
126
|
-
case StyleName.Motion.TransformOrigin:
|
|
127
|
-
case StyleName.Motion.TransformStyle:
|
|
128
128
|
case StyleName.Motion.Transition:
|
|
129
129
|
formattedValue = StyleFormatter.#GetMotionValue(propName, propValue);
|
|
130
130
|
break;
|
|
131
131
|
default:
|
|
132
132
|
// 返回未处理的值
|
|
133
|
-
console.warn("JsView Warn: Unimplemented style property " + propName);
|
|
133
|
+
console.warn("JsView Warn: Unimplemented style property [" + propName + "]");
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -47,6 +47,9 @@ class StyleName {
|
|
|
47
47
|
static TextAlign = "textAlign";
|
|
48
48
|
static TextOverflow = "textOverflow";
|
|
49
49
|
static TextShadow = "textShadow";
|
|
50
|
+
static Transform = "transform";
|
|
51
|
+
static TransformOrigin = "transformOrigin";
|
|
52
|
+
static TransformStyle = "transformStyle";
|
|
50
53
|
static WebkitTextStroke = "WebkitTextStroke";
|
|
51
54
|
static WhiteSpace = "whiteSpace";
|
|
52
55
|
static WordWrap = "wordWrap";
|