@jxsuite/runtime 6.2.1 → 6.2.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/dist/runtime.js +92 -2
- package/dist/runtime.js.map +3 -3
- package/package.json +2 -2
package/dist/runtime.js
CHANGED
|
@@ -1489,7 +1489,97 @@ function isTemplateString(value) {
|
|
|
1489
1489
|
return typeof value === "string" && value.includes("${");
|
|
1490
1490
|
}
|
|
1491
1491
|
function bodyReturnsValue(body) {
|
|
1492
|
-
return /\breturn\b[^\S\n]*(?![;}\s]|$)/.test(body);
|
|
1492
|
+
return /\breturn\b[^\S\n]*(?![;}\s]|$)/.test(maskCode(body));
|
|
1493
|
+
}
|
|
1494
|
+
function maskCode(body) {
|
|
1495
|
+
if (!/[/'"`]/u.test(body)) {
|
|
1496
|
+
return body;
|
|
1497
|
+
}
|
|
1498
|
+
const known = masked.get(body);
|
|
1499
|
+
if (known !== undefined) {
|
|
1500
|
+
return known;
|
|
1501
|
+
}
|
|
1502
|
+
const result = scanCode(body);
|
|
1503
|
+
if (masked.size >= MASKED_LIMIT) {
|
|
1504
|
+
masked.clear();
|
|
1505
|
+
}
|
|
1506
|
+
masked.set(body, result);
|
|
1507
|
+
return result;
|
|
1508
|
+
}
|
|
1509
|
+
var masked = new Map;
|
|
1510
|
+
var MASKED_LIMIT = 2048;
|
|
1511
|
+
function scanCode(body) {
|
|
1512
|
+
const out = body.split("");
|
|
1513
|
+
const blank = (at) => {
|
|
1514
|
+
if (out[at] !== undefined && out[at] !== `
|
|
1515
|
+
`) {
|
|
1516
|
+
out[at] = " ";
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
const substitutions = [];
|
|
1520
|
+
let inTemplate = false;
|
|
1521
|
+
let at = 0;
|
|
1522
|
+
while (at < body.length) {
|
|
1523
|
+
const char = body.charAt(at);
|
|
1524
|
+
if (inTemplate) {
|
|
1525
|
+
if (char === "\\") {
|
|
1526
|
+
blank(at);
|
|
1527
|
+
blank(at + 1);
|
|
1528
|
+
at += 2;
|
|
1529
|
+
} else if (char === "`") {
|
|
1530
|
+
inTemplate = false;
|
|
1531
|
+
at += 1;
|
|
1532
|
+
} else if (char === "$" && body.charAt(at + 1) === "{") {
|
|
1533
|
+
substitutions.push(0);
|
|
1534
|
+
inTemplate = false;
|
|
1535
|
+
at += 2;
|
|
1536
|
+
} else {
|
|
1537
|
+
blank(at);
|
|
1538
|
+
at += 1;
|
|
1539
|
+
}
|
|
1540
|
+
} else if (char === "/" && body.charAt(at + 1) === "/") {
|
|
1541
|
+
while (at < body.length && body.charAt(at) !== `
|
|
1542
|
+
`) {
|
|
1543
|
+
blank(at);
|
|
1544
|
+
at += 1;
|
|
1545
|
+
}
|
|
1546
|
+
} else if (char === "/" && body.charAt(at + 1) === "*") {
|
|
1547
|
+
const end = body.indexOf("*/", at + 2);
|
|
1548
|
+
const stop = end === -1 ? body.length : end + 2;
|
|
1549
|
+
for (;at < stop; at += 1) {
|
|
1550
|
+
blank(at);
|
|
1551
|
+
}
|
|
1552
|
+
} else if (char === "'" || char === '"') {
|
|
1553
|
+
at += 1;
|
|
1554
|
+
while (at < body.length && body.charAt(at) !== char && body.charAt(at) !== `
|
|
1555
|
+
`) {
|
|
1556
|
+
if (body.charAt(at) === "\\") {
|
|
1557
|
+
blank(at);
|
|
1558
|
+
at += 1;
|
|
1559
|
+
}
|
|
1560
|
+
blank(at);
|
|
1561
|
+
at += 1;
|
|
1562
|
+
}
|
|
1563
|
+
at += 1;
|
|
1564
|
+
} else if (char === "`") {
|
|
1565
|
+
inTemplate = true;
|
|
1566
|
+
at += 1;
|
|
1567
|
+
} else {
|
|
1568
|
+
const open = substitutions.length - 1;
|
|
1569
|
+
if (open >= 0 && char === "{") {
|
|
1570
|
+
substitutions[open] = (substitutions[open] ?? 0) + 1;
|
|
1571
|
+
} else if (open >= 0 && char === "}") {
|
|
1572
|
+
if (substitutions[open] === 0) {
|
|
1573
|
+
substitutions.pop();
|
|
1574
|
+
inTemplate = true;
|
|
1575
|
+
} else {
|
|
1576
|
+
substitutions[open] = (substitutions[open] ?? 1) - 1;
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
at += 1;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
return out.join("");
|
|
1493
1583
|
}
|
|
1494
1584
|
function isNestedStyle(value) {
|
|
1495
1585
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -5367,5 +5457,5 @@ export {
|
|
|
5367
5457
|
transposeCanvasUnits
|
|
5368
5458
|
};
|
|
5369
5459
|
|
|
5370
|
-
//# debugId=
|
|
5460
|
+
//# debugId=0833DD60FD5CF0CE64756E2164756E21
|
|
5371
5461
|
//# sourceMappingURL=runtime.js.map
|