voodoojs 0.7.0 → 0.10.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/README.md +1 -1
- package/dist/{chunk-YOZTHZS2.js → chunk-3JV2AYK6.js} +3 -3
- package/dist/{chunk-CYN6VLMD.js → chunk-EYNFAYEV.js} +4 -4
- package/dist/{chunk-ZIWLQZZL.js → chunk-H3RGM7PR.js} +4 -4
- package/dist/{chunk-4T2UIPWX.js → chunk-H64IUSGJ.js} +4 -4
- package/dist/{chunk-QO3I7VLJ.js → chunk-HW75QJLQ.js} +5 -5
- package/dist/{chunk-WSDB7K4X.js → chunk-IK4MQQTO.js} +6 -6
- package/dist/{chunk-JB2YYNK6.js → chunk-OUEXXXTU.js} +310 -64
- package/dist/{chunk-MMLUK37L.js → chunk-PXUSD6TT.js} +4 -3
- package/dist/{chunk-II3XBOAP.js → chunk-QWQPKMUH.js} +13 -13
- package/dist/{chunk-GIWKGFGY.js → chunk-TFDCAZYU.js} +4 -4
- package/dist/{chunk-E5T65CEI.js → chunk-WGMUFP5Q.js} +5 -5
- package/dist/essential.cjs +305 -58
- package/dist/essential.d.cts +2 -2
- package/dist/essential.d.ts +2 -2
- package/dist/essential.js +10 -10
- package/dist/gpu.cjs +1 -1
- package/dist/gpu.js +10 -10
- package/dist/http.cjs +1 -1
- package/dist/http.js +5 -5
- package/dist/index.cjs +577 -76
- package/dist/index.d.cts +118 -4
- package/dist/index.d.ts +118 -4
- package/dist/index.js +278 -31
- package/dist/{query-CC-_z7v0.d.ts → query-Cf-7iibE.d.ts} +53 -2
- package/dist/{query-sEJXe_cO.d.cts → query-DiQAS73Q.d.cts} +53 -2
- package/dist/reactivity.cjs +1 -1
- package/dist/reactivity.js +2 -2
- package/dist/socket.cjs +303 -57
- package/dist/socket.js +9 -9
- package/dist/style-NW74ROC5.js +5 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +2 -2
- package/dist/voodoo.core.js +312 -58
- package/dist/voodoo.core.min.js +18 -18
- package/dist/voodoo.full.js +582 -74
- package/dist/voodoo.full.min.js +61 -61
- package/dist/voodoo.js +312 -58
- package/dist/voodoo.min.js +25 -25
- package/package.json +127 -127
- package/dist/style-SLQ6PHZK.js +0 -5
package/dist/voodoo.core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Voodoo.js v0.
|
|
2
|
+
* Voodoo.js v0.10.0
|
|
3
3
|
* JavaScript feels like magic.
|
|
4
4
|
* (c) 2026 Voodoo.js contributors. MIT License.
|
|
5
5
|
*/
|
|
@@ -730,6 +730,7 @@ var Voodoo = (() => {
|
|
|
730
730
|
autoDiscover: true,
|
|
731
731
|
root: null,
|
|
732
732
|
devtools: false,
|
|
733
|
+
xrayShortcut: "ctrl+shift+f2",
|
|
733
734
|
baseURL: "",
|
|
734
735
|
globals: {},
|
|
735
736
|
locale: typeof navigator !== "undefined" ? navigator.language || "pt-BR" : "pt-BR",
|
|
@@ -865,6 +866,7 @@ ${pointer}`);
|
|
|
865
866
|
"!==",
|
|
866
867
|
"**=",
|
|
867
868
|
"...",
|
|
869
|
+
">>>",
|
|
868
870
|
"<<=",
|
|
869
871
|
">>=",
|
|
870
872
|
"&&=",
|
|
@@ -887,6 +889,11 @@ ${pointer}`);
|
|
|
887
889
|
"*=",
|
|
888
890
|
"/=",
|
|
889
891
|
"%=",
|
|
892
|
+
"&=",
|
|
893
|
+
"|=",
|
|
894
|
+
"^=",
|
|
895
|
+
"<<",
|
|
896
|
+
">>",
|
|
890
897
|
"+",
|
|
891
898
|
"-",
|
|
892
899
|
"*",
|
|
@@ -896,6 +903,10 @@ ${pointer}`);
|
|
|
896
903
|
"<",
|
|
897
904
|
">",
|
|
898
905
|
"=",
|
|
906
|
+
"&",
|
|
907
|
+
"|",
|
|
908
|
+
"^",
|
|
909
|
+
"~",
|
|
899
910
|
"(",
|
|
900
911
|
")",
|
|
901
912
|
"[",
|
|
@@ -960,6 +971,10 @@ ${pointer}`);
|
|
|
960
971
|
raw = "0b";
|
|
961
972
|
i += 2;
|
|
962
973
|
while (i < len && /[01_]/.test(source[i])) raw += source[i++];
|
|
974
|
+
} else if (ch === "0" && (source[i + 1] === "o" || source[i + 1] === "O")) {
|
|
975
|
+
raw = "0o";
|
|
976
|
+
i += 2;
|
|
977
|
+
while (i < len && /[0-7_]/.test(source[i])) raw += source[i++];
|
|
963
978
|
} else {
|
|
964
979
|
while (i < len && /[0-9_]/.test(source[i])) raw += source[i++];
|
|
965
980
|
if (source[i] === ".") {
|
|
@@ -1116,25 +1131,31 @@ ${pointer}`);
|
|
|
1116
1131
|
"??": 1,
|
|
1117
1132
|
"||": 2,
|
|
1118
1133
|
"&&": 3,
|
|
1119
|
-
"
|
|
1120
|
-
"
|
|
1121
|
-
"
|
|
1122
|
-
"
|
|
1123
|
-
"
|
|
1124
|
-
"
|
|
1125
|
-
"
|
|
1126
|
-
"
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
"
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
"
|
|
1133
|
-
"
|
|
1134
|
-
"
|
|
1134
|
+
"|": 4,
|
|
1135
|
+
"^": 5,
|
|
1136
|
+
"&": 6,
|
|
1137
|
+
"==": 7,
|
|
1138
|
+
"!=": 7,
|
|
1139
|
+
"===": 7,
|
|
1140
|
+
"!==": 7,
|
|
1141
|
+
"<": 8,
|
|
1142
|
+
">": 8,
|
|
1143
|
+
"<=": 8,
|
|
1144
|
+
">=": 8,
|
|
1145
|
+
in: 8,
|
|
1146
|
+
instanceof: 8,
|
|
1147
|
+
"<<": 9,
|
|
1148
|
+
">>": 9,
|
|
1149
|
+
">>>": 9,
|
|
1150
|
+
"+": 10,
|
|
1151
|
+
"-": 10,
|
|
1152
|
+
"*": 11,
|
|
1153
|
+
"/": 11,
|
|
1154
|
+
"%": 11,
|
|
1155
|
+
"**": 12
|
|
1135
1156
|
};
|
|
1136
1157
|
var ASSIGN_OPS = /* @__PURE__ */ new Set(["=", "+=", "-=", "*=", "/=", "%=", "**=", "&&=", "||=", "??="]);
|
|
1137
|
-
var UNARY_OPS = /* @__PURE__ */ new Set(["!", "-", "+", "typeof", "void"]);
|
|
1158
|
+
var UNARY_OPS = /* @__PURE__ */ new Set(["!", "-", "+", "~", "typeof", "void", "delete"]);
|
|
1138
1159
|
var LITERALS = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1139
1160
|
true: true,
|
|
1140
1161
|
false: false,
|
|
@@ -1216,6 +1237,13 @@ ${pointer}`);
|
|
|
1216
1237
|
* language is an expression.
|
|
1217
1238
|
*/
|
|
1218
1239
|
parseStatement() {
|
|
1240
|
+
if (this.peek().type === "ident" && this.peek().value === "return") {
|
|
1241
|
+
this.next();
|
|
1242
|
+
if (this.isPunct(";") || this.isPunct(",") || this.isPunct("}") || this.peek().type === "eof") {
|
|
1243
|
+
return { t: "return", a: null };
|
|
1244
|
+
}
|
|
1245
|
+
return { t: "return", a: this.parseExpression() };
|
|
1246
|
+
}
|
|
1219
1247
|
if (this.peek().type === "ident" && this.peek().value === "if" && this.isPunct("(", 1)) {
|
|
1220
1248
|
this.next();
|
|
1221
1249
|
this.expect("(");
|
|
@@ -1269,7 +1297,7 @@ ${pointer}`);
|
|
|
1269
1297
|
if (this.peek().type === "ident" && this.isPunct("=>", 1)) {
|
|
1270
1298
|
const param = this.next().value;
|
|
1271
1299
|
this.next();
|
|
1272
|
-
return { t: "arrow", params: [param], body: this.parseArrowBody() };
|
|
1300
|
+
return { t: "arrow", params: [{ kind: "id", name: param }], body: this.parseArrowBody() };
|
|
1273
1301
|
}
|
|
1274
1302
|
if (this.isPunct("(")) {
|
|
1275
1303
|
const arrow = this.tryParseParenArrow();
|
|
@@ -1306,19 +1334,108 @@ ${pointer}`);
|
|
|
1306
1334
|
const after = this.tokens[i + 1];
|
|
1307
1335
|
if (!after || after.type !== "punct" || after.value !== "=>") return null;
|
|
1308
1336
|
this.next();
|
|
1337
|
+
let params;
|
|
1338
|
+
try {
|
|
1339
|
+
params = this.parseParamList();
|
|
1340
|
+
} catch (e) {
|
|
1341
|
+
this.pos = start2;
|
|
1342
|
+
return null;
|
|
1343
|
+
}
|
|
1344
|
+
this.expect("=>");
|
|
1345
|
+
return { t: "arrow", params, body: this.parseArrowBody() };
|
|
1346
|
+
}
|
|
1347
|
+
/** Parameters up to the closing parenthesis, which it consumes. */
|
|
1348
|
+
parseParamList() {
|
|
1309
1349
|
const params = [];
|
|
1310
1350
|
while (!this.isPunct(")")) {
|
|
1311
|
-
|
|
1312
|
-
if (t.type !== "ident") {
|
|
1313
|
-
this.pos = start2;
|
|
1314
|
-
return null;
|
|
1315
|
-
}
|
|
1316
|
-
params.push(t.value);
|
|
1351
|
+
params.push(this.parseParam());
|
|
1317
1352
|
if (this.isPunct(",")) this.next();
|
|
1353
|
+
else break;
|
|
1318
1354
|
}
|
|
1319
1355
|
this.expect(")");
|
|
1320
|
-
|
|
1321
|
-
|
|
1356
|
+
return params;
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* One binding: `x`, `x = 1`, `...xs`, `{ a, b: c = 2 }`, `[a, , b]`.
|
|
1360
|
+
*
|
|
1361
|
+
* Recursive, so a pattern nests to any depth the way JavaScript's does.
|
|
1362
|
+
*/
|
|
1363
|
+
parseParam() {
|
|
1364
|
+
if (this.isPunct("...")) {
|
|
1365
|
+
this.next();
|
|
1366
|
+
const name = this.next();
|
|
1367
|
+
if (name.type !== "ident") {
|
|
1368
|
+
throw new VoodooSyntaxError("Expected a name after ...", this.source, name.start);
|
|
1369
|
+
}
|
|
1370
|
+
return { kind: "rest", name: name.value };
|
|
1371
|
+
}
|
|
1372
|
+
let param;
|
|
1373
|
+
if (this.isPunct("{")) {
|
|
1374
|
+
this.next();
|
|
1375
|
+
const props = [];
|
|
1376
|
+
let rest;
|
|
1377
|
+
while (!this.isPunct("}")) {
|
|
1378
|
+
if (this.isPunct("...")) {
|
|
1379
|
+
this.next();
|
|
1380
|
+
const name = this.next();
|
|
1381
|
+
if (name.type !== "ident") {
|
|
1382
|
+
throw new VoodooSyntaxError("Expected a name after ...", this.source, name.start);
|
|
1383
|
+
}
|
|
1384
|
+
rest = name.value;
|
|
1385
|
+
} else {
|
|
1386
|
+
const key = this.next();
|
|
1387
|
+
if (key.type !== "ident" && key.type !== "str") {
|
|
1388
|
+
throw new VoodooSyntaxError("Expected a property name", this.source, key.start);
|
|
1389
|
+
}
|
|
1390
|
+
const value = this.isPunct(":") ? (this.next(), this.parseParam()) : { kind: "id", name: key.value };
|
|
1391
|
+
if (this.isPunct("=")) {
|
|
1392
|
+
this.next();
|
|
1393
|
+
value.def = this.parseAssignment();
|
|
1394
|
+
}
|
|
1395
|
+
props.push({ key: String(key.value), value });
|
|
1396
|
+
}
|
|
1397
|
+
if (this.isPunct(",")) this.next();
|
|
1398
|
+
else break;
|
|
1399
|
+
}
|
|
1400
|
+
this.expect("}");
|
|
1401
|
+
param = { kind: "obj", props, rest };
|
|
1402
|
+
} else if (this.isPunct("[")) {
|
|
1403
|
+
this.next();
|
|
1404
|
+
const elements = [];
|
|
1405
|
+
let rest;
|
|
1406
|
+
while (!this.isPunct("]")) {
|
|
1407
|
+
if (this.isPunct(",")) {
|
|
1408
|
+
this.next();
|
|
1409
|
+
elements.push(null);
|
|
1410
|
+
continue;
|
|
1411
|
+
}
|
|
1412
|
+
if (this.isPunct("...")) {
|
|
1413
|
+
this.next();
|
|
1414
|
+
const name = this.next();
|
|
1415
|
+
if (name.type !== "ident") {
|
|
1416
|
+
throw new VoodooSyntaxError("Expected a name after ...", this.source, name.start);
|
|
1417
|
+
}
|
|
1418
|
+
rest = name.value;
|
|
1419
|
+
} else {
|
|
1420
|
+
elements.push(this.parseParam());
|
|
1421
|
+
}
|
|
1422
|
+
if (this.isPunct(",")) this.next();
|
|
1423
|
+
else break;
|
|
1424
|
+
}
|
|
1425
|
+
this.expect("]");
|
|
1426
|
+
param = { kind: "arr", elements, rest };
|
|
1427
|
+
} else {
|
|
1428
|
+
const name = this.next();
|
|
1429
|
+
if (name.type !== "ident") {
|
|
1430
|
+
throw new VoodooSyntaxError("Expected a parameter name", this.source, name.start);
|
|
1431
|
+
}
|
|
1432
|
+
param = { kind: "id", name: name.value };
|
|
1433
|
+
}
|
|
1434
|
+
if (this.isPunct("=")) {
|
|
1435
|
+
this.next();
|
|
1436
|
+
param.def = this.parseAssignment();
|
|
1437
|
+
}
|
|
1438
|
+
return param;
|
|
1322
1439
|
}
|
|
1323
1440
|
parseConditional() {
|
|
1324
1441
|
const test = this.parseBinary(0);
|
|
@@ -1378,8 +1495,57 @@ ${pointer}`);
|
|
|
1378
1495
|
}
|
|
1379
1496
|
return expr;
|
|
1380
1497
|
}
|
|
1498
|
+
/**
|
|
1499
|
+
* `new X`, `new X(a, b)`, and `new a.b.C(x)`.
|
|
1500
|
+
*
|
|
1501
|
+
* `new` did not exist here, in the lexer, or in the interpreter. So
|
|
1502
|
+
* `new Date(0)` lexed as the identifier `new` followed by `Date(0)`, the
|
|
1503
|
+
* parser dropped the dangling identifier, and what ran was `Date(0)`. Called
|
|
1504
|
+
* without `new`, `Date` returns a STRING of the current time, so
|
|
1505
|
+
* `new Date(0)` produced today's date as text, `new Date(0) instanceof Date`
|
|
1506
|
+
* was false, and `new Date(0).getTime()` failed with "getTime is not a
|
|
1507
|
+
* function". Three wrong answers, none of them an error.
|
|
1508
|
+
*
|
|
1509
|
+
* The callee is parsed as a member chain WITHOUT consuming a call, because in
|
|
1510
|
+
* JavaScript the argument list binds to the `new`: `new a.b.C(x)` constructs
|
|
1511
|
+
* `a.b.C` with `x`, and never calls `a.b.C(x)` and constructs the result. The
|
|
1512
|
+
* trailing `(` is then read here, and anything after it, such as
|
|
1513
|
+
* `new Date(0).getTime()`, is left to the ordinary member loop below.
|
|
1514
|
+
*/
|
|
1515
|
+
parseNew() {
|
|
1516
|
+
this.next();
|
|
1517
|
+
const callee = this.parseMemberOnly(this.parsePrimary());
|
|
1518
|
+
const args = this.isPunct("(") ? this.parseArguments() : [];
|
|
1519
|
+
return { t: "new", callee, args };
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Member access only: `.x`, `?.x` and `[x]`, stopping at a call.
|
|
1523
|
+
*
|
|
1524
|
+
* Used for a `new` callee, where the argument list belongs to the `new`
|
|
1525
|
+
* rather than to the expression it is constructing.
|
|
1526
|
+
*/
|
|
1527
|
+
parseMemberOnly(start2) {
|
|
1528
|
+
let expr = start2;
|
|
1529
|
+
for (; ; ) {
|
|
1530
|
+
if (this.isPunct(".")) {
|
|
1531
|
+
this.next();
|
|
1532
|
+
const prop = this.next();
|
|
1533
|
+
if (prop.type !== "ident") {
|
|
1534
|
+
throw new VoodooSyntaxError("Invalid property name", this.source, prop.start);
|
|
1535
|
+
}
|
|
1536
|
+
expr = { t: "member", o: expr, p: { t: "lit", v: prop.value }, computed: false, opt: false };
|
|
1537
|
+
} else if (this.isPunct("[")) {
|
|
1538
|
+
this.next();
|
|
1539
|
+
const p2 = this.parseExpression();
|
|
1540
|
+
this.expect("]");
|
|
1541
|
+
expr = { t: "member", o: expr, p: p2, computed: true, opt: false };
|
|
1542
|
+
} else {
|
|
1543
|
+
return expr;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1381
1547
|
parseCallMember() {
|
|
1382
|
-
let expr = this.parsePrimary();
|
|
1548
|
+
let expr = this.isIdent("new") ? this.parseNew() : this.parsePrimary();
|
|
1383
1549
|
for (; ; ) {
|
|
1384
1550
|
if (this.isPunct(".")) {
|
|
1385
1551
|
this.next();
|
|
@@ -1444,16 +1610,7 @@ ${pointer}`);
|
|
|
1444
1610
|
this.next();
|
|
1445
1611
|
if (this.peek().type === "ident") this.next();
|
|
1446
1612
|
this.expect("(");
|
|
1447
|
-
const params =
|
|
1448
|
-
while (!this.isPunct(")")) {
|
|
1449
|
-
const param = this.next();
|
|
1450
|
-
if (param.type !== "ident") {
|
|
1451
|
-
throw new VoodooSyntaxError("Expected a parameter name", this.source, param.start);
|
|
1452
|
-
}
|
|
1453
|
-
params.push(param.value);
|
|
1454
|
-
if (this.isPunct(",")) this.next();
|
|
1455
|
-
}
|
|
1456
|
-
this.expect(")");
|
|
1613
|
+
const params = this.parseParamList();
|
|
1457
1614
|
return { t: "arrow", params, body: this.parseArrowBody() };
|
|
1458
1615
|
}
|
|
1459
1616
|
if (t.type === "num" || t.type === "str") {
|
|
@@ -1559,16 +1716,7 @@ ${pointer}`);
|
|
|
1559
1716
|
props.push({ key, value: this.parseAssignment() });
|
|
1560
1717
|
} else if (this.isPunct("(")) {
|
|
1561
1718
|
this.next();
|
|
1562
|
-
const params =
|
|
1563
|
-
while (!this.isPunct(")")) {
|
|
1564
|
-
const param = this.next();
|
|
1565
|
-
if (param.type !== "ident") {
|
|
1566
|
-
throw new VoodooSyntaxError("Expected a parameter name", this.source, param.start);
|
|
1567
|
-
}
|
|
1568
|
-
params.push(param.value);
|
|
1569
|
-
if (this.isPunct(",")) this.next();
|
|
1570
|
-
}
|
|
1571
|
-
this.expect(")");
|
|
1719
|
+
const params = this.parseParamList();
|
|
1572
1720
|
props.push({ key, value: { t: "method", params, body: this.parseArrowBody() } });
|
|
1573
1721
|
} else {
|
|
1574
1722
|
props.push({ key, value: { t: "id", n: key } });
|
|
@@ -1672,6 +1820,14 @@ Expression: ${expression}` : message);
|
|
|
1672
1820
|
}
|
|
1673
1821
|
};
|
|
1674
1822
|
var SPREAD = /* @__PURE__ */ Symbol("spread");
|
|
1823
|
+
var ReturnSignal = class {
|
|
1824
|
+
constructor(value) {
|
|
1825
|
+
__publicField(this, "value", value);
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1828
|
+
function unwrap(value) {
|
|
1829
|
+
return value instanceof ReturnSignal ? value.value : value;
|
|
1830
|
+
}
|
|
1675
1831
|
var BLOCKED_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1676
1832
|
function chaveBloqueada(key) {
|
|
1677
1833
|
return typeof key === "string" && BLOCKED_KEYS.has(key);
|
|
@@ -1718,6 +1874,19 @@ Expression: ${expression}` : message);
|
|
|
1718
1874
|
);
|
|
1719
1875
|
return obj[key];
|
|
1720
1876
|
}
|
|
1877
|
+
case "new": {
|
|
1878
|
+
const target = evaluate(node.callee, scope);
|
|
1879
|
+
if (typeof target !== "function") {
|
|
1880
|
+
throw new VoodooRuntimeError(
|
|
1881
|
+
`Cannot construct ${stringify(target)}: it is not a constructor`
|
|
1882
|
+
);
|
|
1883
|
+
}
|
|
1884
|
+
if (target === Function) {
|
|
1885
|
+
throw new VoodooRuntimeError("Cannot construct Function: expressions never compile code");
|
|
1886
|
+
}
|
|
1887
|
+
const args = evalArgs(node.args, scope);
|
|
1888
|
+
return Reflect.construct(target, args);
|
|
1889
|
+
}
|
|
1721
1890
|
case "call": {
|
|
1722
1891
|
let thisArg;
|
|
1723
1892
|
let fn;
|
|
@@ -1765,6 +1934,19 @@ Expression: ${expression}` : message);
|
|
|
1765
1934
|
}
|
|
1766
1935
|
case "unary": {
|
|
1767
1936
|
if (node.op === "...") return { [SPREAD]: evaluate(node.a, scope) };
|
|
1937
|
+
if (node.op === "delete") {
|
|
1938
|
+
if (node.a.t !== "member") {
|
|
1939
|
+
throw new VoodooRuntimeError(
|
|
1940
|
+
"delete needs a property, as in `delete user.name` or `delete list[0]`"
|
|
1941
|
+
);
|
|
1942
|
+
}
|
|
1943
|
+
const owner = evaluate(node.a.o, scope);
|
|
1944
|
+
if (owner == null) return true;
|
|
1945
|
+
const key = checkKey(
|
|
1946
|
+
node.a.computed ? evaluate(node.a.p, scope) : node.a.p.v
|
|
1947
|
+
);
|
|
1948
|
+
return delete owner[key];
|
|
1949
|
+
}
|
|
1768
1950
|
if (node.op === "typeof") {
|
|
1769
1951
|
if (node.a.t === "id") {
|
|
1770
1952
|
if (chaveBloqueada(node.a.n)) return "undefined";
|
|
@@ -1782,6 +1964,8 @@ Expression: ${expression}` : message);
|
|
|
1782
1964
|
return -v;
|
|
1783
1965
|
case "+":
|
|
1784
1966
|
return +v;
|
|
1967
|
+
case "~":
|
|
1968
|
+
return ~v;
|
|
1785
1969
|
case "void":
|
|
1786
1970
|
return void 0;
|
|
1787
1971
|
}
|
|
@@ -1829,6 +2013,23 @@ Expression: ${expression}` : message);
|
|
|
1829
2013
|
return l in r;
|
|
1830
2014
|
case "instanceof":
|
|
1831
2015
|
return l instanceof r;
|
|
2016
|
+
// The bitwise operators coerce through ToInt32, and `>>>` through
|
|
2017
|
+
// ToUint32, which is why the two shifts disagree for negatives:
|
|
2018
|
+
// `-1 >> 0` is -1 and `-1 >>> 0` is 4294967295. Applying the JavaScript
|
|
2019
|
+
// operator directly gets that for free; hand-rolling the coercion is
|
|
2020
|
+
// how an implementation ends up subtly wrong on exactly those cases.
|
|
2021
|
+
case "&":
|
|
2022
|
+
return l & r;
|
|
2023
|
+
case "|":
|
|
2024
|
+
return l | r;
|
|
2025
|
+
case "^":
|
|
2026
|
+
return l ^ r;
|
|
2027
|
+
case "<<":
|
|
2028
|
+
return l << r;
|
|
2029
|
+
case ">>":
|
|
2030
|
+
return l >> r;
|
|
2031
|
+
case ">>>":
|
|
2032
|
+
return l >>> r;
|
|
1832
2033
|
}
|
|
1833
2034
|
throw new VoodooRuntimeError(`Unsupported operator: ${node.op}`);
|
|
1834
2035
|
}
|
|
@@ -1886,21 +2087,16 @@ Expression: ${expression}` : message);
|
|
|
1886
2087
|
const methodParams = node.params;
|
|
1887
2088
|
const methodBody = node.body;
|
|
1888
2089
|
return function(...args) {
|
|
1889
|
-
const vars =
|
|
1890
|
-
for (let i = 0; i < methodParams.length; i++) vars[methodParams[i]] = args[i];
|
|
2090
|
+
const vars = bindParams(methodParams, args, scope);
|
|
1891
2091
|
const owner = this;
|
|
1892
2092
|
const base = owner !== null && typeof owner === "object" ? scope.child(owner) : scope;
|
|
1893
|
-
return evaluate(methodBody, base.child(vars));
|
|
2093
|
+
return unwrap(evaluate(methodBody, base.child(vars)));
|
|
1894
2094
|
};
|
|
1895
2095
|
}
|
|
1896
2096
|
case "arrow": {
|
|
1897
2097
|
const params = node.params;
|
|
1898
2098
|
const body = node.body;
|
|
1899
|
-
return (...args) =>
|
|
1900
|
-
const vars = {};
|
|
1901
|
-
for (let i = 0; i < params.length; i++) vars[params[i]] = args[i];
|
|
1902
|
-
return evaluate(body, scope.child(vars));
|
|
1903
|
-
};
|
|
2099
|
+
return (...args) => unwrap(evaluate(body, scope.child(bindParams(params, args, scope))));
|
|
1904
2100
|
}
|
|
1905
2101
|
case "obj": {
|
|
1906
2102
|
const out = {};
|
|
@@ -1938,14 +2134,65 @@ Expression: ${expression}` : message);
|
|
|
1938
2134
|
}
|
|
1939
2135
|
return out;
|
|
1940
2136
|
}
|
|
2137
|
+
case "return":
|
|
2138
|
+
return new ReturnSignal(node.a ? evaluate(node.a, scope) : void 0);
|
|
1941
2139
|
case "seq": {
|
|
1942
2140
|
let last;
|
|
1943
|
-
for (const stmt of node.body)
|
|
2141
|
+
for (const stmt of node.body) {
|
|
2142
|
+
last = evaluate(stmt, scope);
|
|
2143
|
+
if (last instanceof ReturnSignal) return last;
|
|
2144
|
+
}
|
|
1944
2145
|
return last;
|
|
1945
2146
|
}
|
|
1946
2147
|
}
|
|
1947
2148
|
throw new VoodooRuntimeError(`Unknown node: ${node.t}`);
|
|
1948
2149
|
}
|
|
2150
|
+
function bindParam(param, value, vars, scope) {
|
|
2151
|
+
if (param.kind === "rest") {
|
|
2152
|
+
vars[param.name] = value;
|
|
2153
|
+
return;
|
|
2154
|
+
}
|
|
2155
|
+
if (param.def !== void 0 && value === void 0) {
|
|
2156
|
+
value = evaluate(param.def, scope.child(vars));
|
|
2157
|
+
}
|
|
2158
|
+
if (param.kind === "id") {
|
|
2159
|
+
vars[param.name] = value;
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
if (param.kind === "obj") {
|
|
2163
|
+
if (value == null) {
|
|
2164
|
+
throw new VoodooRuntimeError(
|
|
2165
|
+
`Cannot destructure ${value === null ? "null" : "undefined"}`
|
|
2166
|
+
);
|
|
2167
|
+
}
|
|
2168
|
+
const taken = /* @__PURE__ */ new Set();
|
|
2169
|
+
for (const { key, value: inner } of param.props) {
|
|
2170
|
+
taken.add(key);
|
|
2171
|
+
bindParam(inner, value[checkKey(key)], vars, scope);
|
|
2172
|
+
}
|
|
2173
|
+
if (param.rest) {
|
|
2174
|
+
const rest = {};
|
|
2175
|
+
for (const key of Object.keys(value)) {
|
|
2176
|
+
if (!taken.has(key)) rest[key] = value[key];
|
|
2177
|
+
}
|
|
2178
|
+
vars[param.rest] = rest;
|
|
2179
|
+
}
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
const items = Array.isArray(value) ? value : Array.from(value);
|
|
2183
|
+
param.elements.forEach((element, index) => {
|
|
2184
|
+
if (element) bindParam(element, items[index], vars, scope);
|
|
2185
|
+
});
|
|
2186
|
+
if (param.rest) vars[param.rest] = items.slice(param.elements.length);
|
|
2187
|
+
}
|
|
2188
|
+
function bindParams(params, args, scope) {
|
|
2189
|
+
const vars = {};
|
|
2190
|
+
for (let i = 0; i < params.length; i++) {
|
|
2191
|
+
const param = params[i];
|
|
2192
|
+
bindParam(param, param.kind === "rest" ? args.slice(i) : args[i], vars, scope);
|
|
2193
|
+
}
|
|
2194
|
+
return vars;
|
|
2195
|
+
}
|
|
1949
2196
|
function evalArgs(args, scope) {
|
|
1950
2197
|
const out = [];
|
|
1951
2198
|
for (const arg of args) {
|
|
@@ -6566,7 +6813,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
6566
6813
|
Object.defineProperties(rootScope.data, Object.getOwnPropertyDescriptors(values));
|
|
6567
6814
|
return rootScope.data;
|
|
6568
6815
|
}
|
|
6569
|
-
var version2 = "0.
|
|
6816
|
+
var version2 = "0.10.0";
|
|
6570
6817
|
var core = {
|
|
6571
6818
|
// Utilities first: Voodoo's own names can override.
|
|
6572
6819
|
...utils_exports,
|
|
@@ -8174,6 +8421,10 @@ ${block(':root:not([data-theme="light"])', dark.vars)}
|
|
|
8174
8421
|
const locale = script.getAttribute("data-locale");
|
|
8175
8422
|
if (locale) config.locale = locale;
|
|
8176
8423
|
if (readDevtoolsFlag(script)) config.devtools = true;
|
|
8424
|
+
const xrayShortcut = script.getAttribute("data-xray-shortcut");
|
|
8425
|
+
if (xrayShortcut !== null) {
|
|
8426
|
+
config.xrayShortcut = xrayShortcut === "false" || xrayShortcut === "" ? false : xrayShortcut;
|
|
8427
|
+
}
|
|
8177
8428
|
if (script.hasAttribute("data-no-styles")) config.injectStyles = false;
|
|
8178
8429
|
if (script.hasAttribute("data-no-observer")) config.autoDiscover = false;
|
|
8179
8430
|
if (script.hasAttribute("data-keep-attributes")) config.cleanAttributes = false;
|
|
@@ -8202,7 +8453,10 @@ ${block(':root:not([data-theme="light"])', dark.vars)}
|
|
|
8202
8453
|
const boot = () => {
|
|
8203
8454
|
theme.init();
|
|
8204
8455
|
applySavedPalette();
|
|
8456
|
+
if (typeof V2.extractJsx === "function") V2.extractJsx();
|
|
8205
8457
|
V2.start();
|
|
8458
|
+
if (typeof V2.activateJsx === "function") V2.activateJsx();
|
|
8459
|
+
if (typeof V2.enableXrayShortcut === "function") V2.enableXrayShortcut();
|
|
8206
8460
|
if (config.devtools) mountDevtools(V2);
|
|
8207
8461
|
};
|
|
8208
8462
|
whenReady(boot);
|