@shijiu/jsview-vue 0.9.283-alpha.0 → 0.9.286-alpha.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/package.json
CHANGED
|
@@ -210,7 +210,9 @@ function compileAndSaveImportedNode(styleFilePath, styleNodes) {
|
|
|
210
210
|
let styleContent = "";
|
|
211
211
|
|
|
212
212
|
styleNodes.forEach(node => {
|
|
213
|
-
if(
|
|
213
|
+
if(node.name === "keyframes") {
|
|
214
|
+
styleContent += compileKeyframesNode(node);
|
|
215
|
+
} else if(!!node.selector) {
|
|
214
216
|
styleContent += compileSelectorNode(node);
|
|
215
217
|
styleSelectors.add(node.selector);
|
|
216
218
|
} else {
|
|
@@ -237,13 +239,39 @@ function compileAndSaveImportedNode(styleFilePath, styleNodes) {
|
|
|
237
239
|
};
|
|
238
240
|
}
|
|
239
241
|
|
|
242
|
+
function getStringOffset(source, line, column) {
|
|
243
|
+
check(!isNaN(line), source, "JsView Error: Failed to get string offset, line is NaN.");
|
|
244
|
+
check(!isNaN(column), source, "JsView Error: Failed to get string offset, column is NaN.");
|
|
245
|
+
|
|
246
|
+
line -= 1;
|
|
247
|
+
column -= 1;
|
|
248
|
+
|
|
249
|
+
var offset = 0;
|
|
250
|
+
for (var idx = 0; idx < line; idx++) {
|
|
251
|
+
offset = source.indexOf('\n', offset + 1);
|
|
252
|
+
check(offset >= 0, source, "JsView Error: Failed to get string offset, line=" + line + ", column=" + column);
|
|
253
|
+
}
|
|
254
|
+
offset += column;
|
|
255
|
+
|
|
256
|
+
return offset;
|
|
257
|
+
}
|
|
258
|
+
|
|
240
259
|
function compileKeyframesNode(node) {
|
|
241
260
|
const name = node.name;
|
|
242
261
|
check(name, node.source.input.css, "JsView Error: name is not found!");
|
|
243
262
|
|
|
244
263
|
check(name === "keyframes", node.source.input.css, "JsView Error: @keyframes name is not found!");
|
|
245
264
|
|
|
246
|
-
|
|
265
|
+
let startOffset = node.source.start.offset;
|
|
266
|
+
let endOffset = node.source.end.offset;
|
|
267
|
+
if (typeof (startOffset) == 'undefined') {
|
|
268
|
+
startOffset = getStringOffset(node.source.input.css, node.source.start.line, node.source.start.column);
|
|
269
|
+
}
|
|
270
|
+
if (typeof (endOffset) == 'undefined') {
|
|
271
|
+
endOffset = getStringOffset(node.source.input.css, node.source.end.line, node.source.end.column);
|
|
272
|
+
}
|
|
273
|
+
const content = node.source.input.css.slice(startOffset, endOffset + 1);
|
|
274
|
+
// console.log('jsview-css-to-js.compileKeyframesNode() \n', startOffset, endOffset, content);
|
|
247
275
|
|
|
248
276
|
let styleContent = "'" + node.params + "':'";
|
|
249
277
|
styleContent += content.replace(/\n/g, " ");
|