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/socket.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Voodoo.js v0.
|
|
6
|
+
* Voodoo.js v0.10.0
|
|
7
7
|
* JavaScript feels like magic.
|
|
8
8
|
* (c) 2026 Voodoo.js contributors. MIT License.
|
|
9
9
|
*/
|
|
@@ -413,6 +413,14 @@ Expression: ${expression}` : message);
|
|
|
413
413
|
}
|
|
414
414
|
};
|
|
415
415
|
var SPREAD = /* @__PURE__ */ Symbol("spread");
|
|
416
|
+
var ReturnSignal = class {
|
|
417
|
+
constructor(value) {
|
|
418
|
+
__publicField(this, "value", value);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
function unwrap(value) {
|
|
422
|
+
return value instanceof ReturnSignal ? value.value : value;
|
|
423
|
+
}
|
|
416
424
|
var BLOCKED_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
417
425
|
function chaveBloqueada(key) {
|
|
418
426
|
return typeof key === "string" && BLOCKED_KEYS.has(key);
|
|
@@ -458,6 +466,19 @@ function evaluate(node, scope) {
|
|
|
458
466
|
);
|
|
459
467
|
return obj[key];
|
|
460
468
|
}
|
|
469
|
+
case "new": {
|
|
470
|
+
const target2 = evaluate(node.callee, scope);
|
|
471
|
+
if (typeof target2 !== "function") {
|
|
472
|
+
throw new VoodooRuntimeError(
|
|
473
|
+
`Cannot construct ${stringify(target2)}: it is not a constructor`
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
if (target2 === Function) {
|
|
477
|
+
throw new VoodooRuntimeError("Cannot construct Function: expressions never compile code");
|
|
478
|
+
}
|
|
479
|
+
const args = evalArgs(node.args, scope);
|
|
480
|
+
return Reflect.construct(target2, args);
|
|
481
|
+
}
|
|
461
482
|
case "call": {
|
|
462
483
|
let thisArg;
|
|
463
484
|
let fn;
|
|
@@ -505,6 +526,19 @@ function evaluate(node, scope) {
|
|
|
505
526
|
}
|
|
506
527
|
case "unary": {
|
|
507
528
|
if (node.op === "...") return { [SPREAD]: evaluate(node.a, scope) };
|
|
529
|
+
if (node.op === "delete") {
|
|
530
|
+
if (node.a.t !== "member") {
|
|
531
|
+
throw new VoodooRuntimeError(
|
|
532
|
+
"delete needs a property, as in `delete user.name` or `delete list[0]`"
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
const owner = evaluate(node.a.o, scope);
|
|
536
|
+
if (owner == null) return true;
|
|
537
|
+
const key = checkKey(
|
|
538
|
+
node.a.computed ? evaluate(node.a.p, scope) : node.a.p.v
|
|
539
|
+
);
|
|
540
|
+
return delete owner[key];
|
|
541
|
+
}
|
|
508
542
|
if (node.op === "typeof") {
|
|
509
543
|
if (node.a.t === "id") {
|
|
510
544
|
if (chaveBloqueada(node.a.n)) return "undefined";
|
|
@@ -522,6 +556,8 @@ function evaluate(node, scope) {
|
|
|
522
556
|
return -v;
|
|
523
557
|
case "+":
|
|
524
558
|
return +v;
|
|
559
|
+
case "~":
|
|
560
|
+
return ~v;
|
|
525
561
|
case "void":
|
|
526
562
|
return void 0;
|
|
527
563
|
}
|
|
@@ -569,6 +605,23 @@ function evaluate(node, scope) {
|
|
|
569
605
|
return l in r;
|
|
570
606
|
case "instanceof":
|
|
571
607
|
return l instanceof r;
|
|
608
|
+
// The bitwise operators coerce through ToInt32, and `>>>` through
|
|
609
|
+
// ToUint32, which is why the two shifts disagree for negatives:
|
|
610
|
+
// `-1 >> 0` is -1 and `-1 >>> 0` is 4294967295. Applying the JavaScript
|
|
611
|
+
// operator directly gets that for free; hand-rolling the coercion is
|
|
612
|
+
// how an implementation ends up subtly wrong on exactly those cases.
|
|
613
|
+
case "&":
|
|
614
|
+
return l & r;
|
|
615
|
+
case "|":
|
|
616
|
+
return l | r;
|
|
617
|
+
case "^":
|
|
618
|
+
return l ^ r;
|
|
619
|
+
case "<<":
|
|
620
|
+
return l << r;
|
|
621
|
+
case ">>":
|
|
622
|
+
return l >> r;
|
|
623
|
+
case ">>>":
|
|
624
|
+
return l >>> r;
|
|
572
625
|
}
|
|
573
626
|
throw new VoodooRuntimeError(`Unsupported operator: ${node.op}`);
|
|
574
627
|
}
|
|
@@ -626,21 +679,16 @@ function evaluate(node, scope) {
|
|
|
626
679
|
const methodParams = node.params;
|
|
627
680
|
const methodBody = node.body;
|
|
628
681
|
return function(...args) {
|
|
629
|
-
const vars =
|
|
630
|
-
for (let i = 0; i < methodParams.length; i++) vars[methodParams[i]] = args[i];
|
|
682
|
+
const vars = bindParams(methodParams, args, scope);
|
|
631
683
|
const owner = this;
|
|
632
684
|
const base = owner !== null && typeof owner === "object" ? scope.child(owner) : scope;
|
|
633
|
-
return evaluate(methodBody, base.child(vars));
|
|
685
|
+
return unwrap(evaluate(methodBody, base.child(vars)));
|
|
634
686
|
};
|
|
635
687
|
}
|
|
636
688
|
case "arrow": {
|
|
637
689
|
const params = node.params;
|
|
638
690
|
const body = node.body;
|
|
639
|
-
return (...args) =>
|
|
640
|
-
const vars = {};
|
|
641
|
-
for (let i = 0; i < params.length; i++) vars[params[i]] = args[i];
|
|
642
|
-
return evaluate(body, scope.child(vars));
|
|
643
|
-
};
|
|
691
|
+
return (...args) => unwrap(evaluate(body, scope.child(bindParams(params, args, scope))));
|
|
644
692
|
}
|
|
645
693
|
case "obj": {
|
|
646
694
|
const out = {};
|
|
@@ -678,14 +726,65 @@ function evaluate(node, scope) {
|
|
|
678
726
|
}
|
|
679
727
|
return out;
|
|
680
728
|
}
|
|
729
|
+
case "return":
|
|
730
|
+
return new ReturnSignal(node.a ? evaluate(node.a, scope) : void 0);
|
|
681
731
|
case "seq": {
|
|
682
732
|
let last;
|
|
683
|
-
for (const stmt of node.body)
|
|
733
|
+
for (const stmt of node.body) {
|
|
734
|
+
last = evaluate(stmt, scope);
|
|
735
|
+
if (last instanceof ReturnSignal) return last;
|
|
736
|
+
}
|
|
684
737
|
return last;
|
|
685
738
|
}
|
|
686
739
|
}
|
|
687
740
|
throw new VoodooRuntimeError(`Unknown node: ${node.t}`);
|
|
688
741
|
}
|
|
742
|
+
function bindParam(param, value, vars, scope) {
|
|
743
|
+
if (param.kind === "rest") {
|
|
744
|
+
vars[param.name] = value;
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
if (param.def !== void 0 && value === void 0) {
|
|
748
|
+
value = evaluate(param.def, scope.child(vars));
|
|
749
|
+
}
|
|
750
|
+
if (param.kind === "id") {
|
|
751
|
+
vars[param.name] = value;
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
if (param.kind === "obj") {
|
|
755
|
+
if (value == null) {
|
|
756
|
+
throw new VoodooRuntimeError(
|
|
757
|
+
`Cannot destructure ${value === null ? "null" : "undefined"}`
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
const taken = /* @__PURE__ */ new Set();
|
|
761
|
+
for (const { key, value: inner } of param.props) {
|
|
762
|
+
taken.add(key);
|
|
763
|
+
bindParam(inner, value[checkKey(key)], vars, scope);
|
|
764
|
+
}
|
|
765
|
+
if (param.rest) {
|
|
766
|
+
const rest = {};
|
|
767
|
+
for (const key of Object.keys(value)) {
|
|
768
|
+
if (!taken.has(key)) rest[key] = value[key];
|
|
769
|
+
}
|
|
770
|
+
vars[param.rest] = rest;
|
|
771
|
+
}
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
const items = Array.isArray(value) ? value : Array.from(value);
|
|
775
|
+
param.elements.forEach((element, index) => {
|
|
776
|
+
if (element) bindParam(element, items[index], vars, scope);
|
|
777
|
+
});
|
|
778
|
+
if (param.rest) vars[param.rest] = items.slice(param.elements.length);
|
|
779
|
+
}
|
|
780
|
+
function bindParams(params, args, scope) {
|
|
781
|
+
const vars = {};
|
|
782
|
+
for (let i = 0; i < params.length; i++) {
|
|
783
|
+
const param = params[i];
|
|
784
|
+
bindParam(param, param.kind === "rest" ? args.slice(i) : args[i], vars, scope);
|
|
785
|
+
}
|
|
786
|
+
return vars;
|
|
787
|
+
}
|
|
689
788
|
function evalArgs(args, scope) {
|
|
690
789
|
const out = [];
|
|
691
790
|
for (const arg of args) {
|
|
@@ -758,6 +857,7 @@ var PUNCTUATORS = [
|
|
|
758
857
|
"!==",
|
|
759
858
|
"**=",
|
|
760
859
|
"...",
|
|
860
|
+
">>>",
|
|
761
861
|
"<<=",
|
|
762
862
|
">>=",
|
|
763
863
|
"&&=",
|
|
@@ -780,6 +880,11 @@ var PUNCTUATORS = [
|
|
|
780
880
|
"*=",
|
|
781
881
|
"/=",
|
|
782
882
|
"%=",
|
|
883
|
+
"&=",
|
|
884
|
+
"|=",
|
|
885
|
+
"^=",
|
|
886
|
+
"<<",
|
|
887
|
+
">>",
|
|
783
888
|
"+",
|
|
784
889
|
"-",
|
|
785
890
|
"*",
|
|
@@ -789,6 +894,10 @@ var PUNCTUATORS = [
|
|
|
789
894
|
"<",
|
|
790
895
|
">",
|
|
791
896
|
"=",
|
|
897
|
+
"&",
|
|
898
|
+
"|",
|
|
899
|
+
"^",
|
|
900
|
+
"~",
|
|
792
901
|
"(",
|
|
793
902
|
")",
|
|
794
903
|
"[",
|
|
@@ -852,6 +961,10 @@ function tokenize(source) {
|
|
|
852
961
|
raw = "0b";
|
|
853
962
|
i += 2;
|
|
854
963
|
while (i < len && /[01_]/.test(source[i])) raw += source[i++];
|
|
964
|
+
} else if (ch === "0" && (source[i + 1] === "o" || source[i + 1] === "O")) {
|
|
965
|
+
raw = "0o";
|
|
966
|
+
i += 2;
|
|
967
|
+
while (i < len && /[0-7_]/.test(source[i])) raw += source[i++];
|
|
855
968
|
} else {
|
|
856
969
|
while (i < len && /[0-9_]/.test(source[i])) raw += source[i++];
|
|
857
970
|
if (source[i] === ".") {
|
|
@@ -1008,25 +1121,31 @@ var BINARY_PRECEDENCE = {
|
|
|
1008
1121
|
"??": 1,
|
|
1009
1122
|
"||": 2,
|
|
1010
1123
|
"&&": 3,
|
|
1011
|
-
"
|
|
1012
|
-
"
|
|
1013
|
-
"
|
|
1014
|
-
"
|
|
1015
|
-
"
|
|
1016
|
-
"
|
|
1017
|
-
"
|
|
1018
|
-
"
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
"
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
"
|
|
1025
|
-
"
|
|
1026
|
-
"
|
|
1124
|
+
"|": 4,
|
|
1125
|
+
"^": 5,
|
|
1126
|
+
"&": 6,
|
|
1127
|
+
"==": 7,
|
|
1128
|
+
"!=": 7,
|
|
1129
|
+
"===": 7,
|
|
1130
|
+
"!==": 7,
|
|
1131
|
+
"<": 8,
|
|
1132
|
+
">": 8,
|
|
1133
|
+
"<=": 8,
|
|
1134
|
+
">=": 8,
|
|
1135
|
+
in: 8,
|
|
1136
|
+
instanceof: 8,
|
|
1137
|
+
"<<": 9,
|
|
1138
|
+
">>": 9,
|
|
1139
|
+
">>>": 9,
|
|
1140
|
+
"+": 10,
|
|
1141
|
+
"-": 10,
|
|
1142
|
+
"*": 11,
|
|
1143
|
+
"/": 11,
|
|
1144
|
+
"%": 11,
|
|
1145
|
+
"**": 12
|
|
1027
1146
|
};
|
|
1028
1147
|
var ASSIGN_OPS = /* @__PURE__ */ new Set(["=", "+=", "-=", "*=", "/=", "%=", "**=", "&&=", "||=", "??="]);
|
|
1029
|
-
var UNARY_OPS = /* @__PURE__ */ new Set(["!", "-", "+", "typeof", "void"]);
|
|
1148
|
+
var UNARY_OPS = /* @__PURE__ */ new Set(["!", "-", "+", "~", "typeof", "void", "delete"]);
|
|
1030
1149
|
var LITERALS = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1031
1150
|
true: true,
|
|
1032
1151
|
false: false,
|
|
@@ -1108,6 +1227,13 @@ var Parser = class {
|
|
|
1108
1227
|
* language is an expression.
|
|
1109
1228
|
*/
|
|
1110
1229
|
parseStatement() {
|
|
1230
|
+
if (this.peek().type === "ident" && this.peek().value === "return") {
|
|
1231
|
+
this.next();
|
|
1232
|
+
if (this.isPunct(";") || this.isPunct(",") || this.isPunct("}") || this.peek().type === "eof") {
|
|
1233
|
+
return { t: "return", a: null };
|
|
1234
|
+
}
|
|
1235
|
+
return { t: "return", a: this.parseExpression() };
|
|
1236
|
+
}
|
|
1111
1237
|
if (this.peek().type === "ident" && this.peek().value === "if" && this.isPunct("(", 1)) {
|
|
1112
1238
|
this.next();
|
|
1113
1239
|
this.expect("(");
|
|
@@ -1161,7 +1287,7 @@ var Parser = class {
|
|
|
1161
1287
|
if (this.peek().type === "ident" && this.isPunct("=>", 1)) {
|
|
1162
1288
|
const param = this.next().value;
|
|
1163
1289
|
this.next();
|
|
1164
|
-
return { t: "arrow", params: [param], body: this.parseArrowBody() };
|
|
1290
|
+
return { t: "arrow", params: [{ kind: "id", name: param }], body: this.parseArrowBody() };
|
|
1165
1291
|
}
|
|
1166
1292
|
if (this.isPunct("(")) {
|
|
1167
1293
|
const arrow = this.tryParseParenArrow();
|
|
@@ -1198,19 +1324,108 @@ var Parser = class {
|
|
|
1198
1324
|
const after = this.tokens[i + 1];
|
|
1199
1325
|
if (!after || after.type !== "punct" || after.value !== "=>") return null;
|
|
1200
1326
|
this.next();
|
|
1327
|
+
let params;
|
|
1328
|
+
try {
|
|
1329
|
+
params = this.parseParamList();
|
|
1330
|
+
} catch {
|
|
1331
|
+
this.pos = start;
|
|
1332
|
+
return null;
|
|
1333
|
+
}
|
|
1334
|
+
this.expect("=>");
|
|
1335
|
+
return { t: "arrow", params, body: this.parseArrowBody() };
|
|
1336
|
+
}
|
|
1337
|
+
/** Parameters up to the closing parenthesis, which it consumes. */
|
|
1338
|
+
parseParamList() {
|
|
1201
1339
|
const params = [];
|
|
1202
1340
|
while (!this.isPunct(")")) {
|
|
1203
|
-
|
|
1204
|
-
if (t.type !== "ident") {
|
|
1205
|
-
this.pos = start;
|
|
1206
|
-
return null;
|
|
1207
|
-
}
|
|
1208
|
-
params.push(t.value);
|
|
1341
|
+
params.push(this.parseParam());
|
|
1209
1342
|
if (this.isPunct(",")) this.next();
|
|
1343
|
+
else break;
|
|
1210
1344
|
}
|
|
1211
1345
|
this.expect(")");
|
|
1212
|
-
|
|
1213
|
-
|
|
1346
|
+
return params;
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* One binding: `x`, `x = 1`, `...xs`, `{ a, b: c = 2 }`, `[a, , b]`.
|
|
1350
|
+
*
|
|
1351
|
+
* Recursive, so a pattern nests to any depth the way JavaScript's does.
|
|
1352
|
+
*/
|
|
1353
|
+
parseParam() {
|
|
1354
|
+
if (this.isPunct("...")) {
|
|
1355
|
+
this.next();
|
|
1356
|
+
const name = this.next();
|
|
1357
|
+
if (name.type !== "ident") {
|
|
1358
|
+
throw new VoodooSyntaxError("Expected a name after ...", this.source, name.start);
|
|
1359
|
+
}
|
|
1360
|
+
return { kind: "rest", name: name.value };
|
|
1361
|
+
}
|
|
1362
|
+
let param;
|
|
1363
|
+
if (this.isPunct("{")) {
|
|
1364
|
+
this.next();
|
|
1365
|
+
const props = [];
|
|
1366
|
+
let rest;
|
|
1367
|
+
while (!this.isPunct("}")) {
|
|
1368
|
+
if (this.isPunct("...")) {
|
|
1369
|
+
this.next();
|
|
1370
|
+
const name = this.next();
|
|
1371
|
+
if (name.type !== "ident") {
|
|
1372
|
+
throw new VoodooSyntaxError("Expected a name after ...", this.source, name.start);
|
|
1373
|
+
}
|
|
1374
|
+
rest = name.value;
|
|
1375
|
+
} else {
|
|
1376
|
+
const key = this.next();
|
|
1377
|
+
if (key.type !== "ident" && key.type !== "str") {
|
|
1378
|
+
throw new VoodooSyntaxError("Expected a property name", this.source, key.start);
|
|
1379
|
+
}
|
|
1380
|
+
const value = this.isPunct(":") ? (this.next(), this.parseParam()) : { kind: "id", name: key.value };
|
|
1381
|
+
if (this.isPunct("=")) {
|
|
1382
|
+
this.next();
|
|
1383
|
+
value.def = this.parseAssignment();
|
|
1384
|
+
}
|
|
1385
|
+
props.push({ key: String(key.value), value });
|
|
1386
|
+
}
|
|
1387
|
+
if (this.isPunct(",")) this.next();
|
|
1388
|
+
else break;
|
|
1389
|
+
}
|
|
1390
|
+
this.expect("}");
|
|
1391
|
+
param = { kind: "obj", props, rest };
|
|
1392
|
+
} else if (this.isPunct("[")) {
|
|
1393
|
+
this.next();
|
|
1394
|
+
const elements = [];
|
|
1395
|
+
let rest;
|
|
1396
|
+
while (!this.isPunct("]")) {
|
|
1397
|
+
if (this.isPunct(",")) {
|
|
1398
|
+
this.next();
|
|
1399
|
+
elements.push(null);
|
|
1400
|
+
continue;
|
|
1401
|
+
}
|
|
1402
|
+
if (this.isPunct("...")) {
|
|
1403
|
+
this.next();
|
|
1404
|
+
const name = this.next();
|
|
1405
|
+
if (name.type !== "ident") {
|
|
1406
|
+
throw new VoodooSyntaxError("Expected a name after ...", this.source, name.start);
|
|
1407
|
+
}
|
|
1408
|
+
rest = name.value;
|
|
1409
|
+
} else {
|
|
1410
|
+
elements.push(this.parseParam());
|
|
1411
|
+
}
|
|
1412
|
+
if (this.isPunct(",")) this.next();
|
|
1413
|
+
else break;
|
|
1414
|
+
}
|
|
1415
|
+
this.expect("]");
|
|
1416
|
+
param = { kind: "arr", elements, rest };
|
|
1417
|
+
} else {
|
|
1418
|
+
const name = this.next();
|
|
1419
|
+
if (name.type !== "ident") {
|
|
1420
|
+
throw new VoodooSyntaxError("Expected a parameter name", this.source, name.start);
|
|
1421
|
+
}
|
|
1422
|
+
param = { kind: "id", name: name.value };
|
|
1423
|
+
}
|
|
1424
|
+
if (this.isPunct("=")) {
|
|
1425
|
+
this.next();
|
|
1426
|
+
param.def = this.parseAssignment();
|
|
1427
|
+
}
|
|
1428
|
+
return param;
|
|
1214
1429
|
}
|
|
1215
1430
|
parseConditional() {
|
|
1216
1431
|
const test = this.parseBinary(0);
|
|
@@ -1270,8 +1485,57 @@ var Parser = class {
|
|
|
1270
1485
|
}
|
|
1271
1486
|
return expr;
|
|
1272
1487
|
}
|
|
1488
|
+
/**
|
|
1489
|
+
* `new X`, `new X(a, b)`, and `new a.b.C(x)`.
|
|
1490
|
+
*
|
|
1491
|
+
* `new` did not exist here, in the lexer, or in the interpreter. So
|
|
1492
|
+
* `new Date(0)` lexed as the identifier `new` followed by `Date(0)`, the
|
|
1493
|
+
* parser dropped the dangling identifier, and what ran was `Date(0)`. Called
|
|
1494
|
+
* without `new`, `Date` returns a STRING of the current time, so
|
|
1495
|
+
* `new Date(0)` produced today's date as text, `new Date(0) instanceof Date`
|
|
1496
|
+
* was false, and `new Date(0).getTime()` failed with "getTime is not a
|
|
1497
|
+
* function". Three wrong answers, none of them an error.
|
|
1498
|
+
*
|
|
1499
|
+
* The callee is parsed as a member chain WITHOUT consuming a call, because in
|
|
1500
|
+
* JavaScript the argument list binds to the `new`: `new a.b.C(x)` constructs
|
|
1501
|
+
* `a.b.C` with `x`, and never calls `a.b.C(x)` and constructs the result. The
|
|
1502
|
+
* trailing `(` is then read here, and anything after it, such as
|
|
1503
|
+
* `new Date(0).getTime()`, is left to the ordinary member loop below.
|
|
1504
|
+
*/
|
|
1505
|
+
parseNew() {
|
|
1506
|
+
this.next();
|
|
1507
|
+
const callee = this.parseMemberOnly(this.parsePrimary());
|
|
1508
|
+
const args = this.isPunct("(") ? this.parseArguments() : [];
|
|
1509
|
+
return { t: "new", callee, args };
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Member access only: `.x`, `?.x` and `[x]`, stopping at a call.
|
|
1513
|
+
*
|
|
1514
|
+
* Used for a `new` callee, where the argument list belongs to the `new`
|
|
1515
|
+
* rather than to the expression it is constructing.
|
|
1516
|
+
*/
|
|
1517
|
+
parseMemberOnly(start) {
|
|
1518
|
+
let expr = start;
|
|
1519
|
+
for (; ; ) {
|
|
1520
|
+
if (this.isPunct(".")) {
|
|
1521
|
+
this.next();
|
|
1522
|
+
const prop = this.next();
|
|
1523
|
+
if (prop.type !== "ident") {
|
|
1524
|
+
throw new VoodooSyntaxError("Invalid property name", this.source, prop.start);
|
|
1525
|
+
}
|
|
1526
|
+
expr = { t: "member", o: expr, p: { t: "lit", v: prop.value }, computed: false, opt: false };
|
|
1527
|
+
} else if (this.isPunct("[")) {
|
|
1528
|
+
this.next();
|
|
1529
|
+
const p = this.parseExpression();
|
|
1530
|
+
this.expect("]");
|
|
1531
|
+
expr = { t: "member", o: expr, p, computed: true, opt: false };
|
|
1532
|
+
} else {
|
|
1533
|
+
return expr;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1273
1537
|
parseCallMember() {
|
|
1274
|
-
let expr = this.parsePrimary();
|
|
1538
|
+
let expr = this.isIdent("new") ? this.parseNew() : this.parsePrimary();
|
|
1275
1539
|
for (; ; ) {
|
|
1276
1540
|
if (this.isPunct(".")) {
|
|
1277
1541
|
this.next();
|
|
@@ -1336,16 +1600,7 @@ var Parser = class {
|
|
|
1336
1600
|
this.next();
|
|
1337
1601
|
if (this.peek().type === "ident") this.next();
|
|
1338
1602
|
this.expect("(");
|
|
1339
|
-
const params =
|
|
1340
|
-
while (!this.isPunct(")")) {
|
|
1341
|
-
const param = this.next();
|
|
1342
|
-
if (param.type !== "ident") {
|
|
1343
|
-
throw new VoodooSyntaxError("Expected a parameter name", this.source, param.start);
|
|
1344
|
-
}
|
|
1345
|
-
params.push(param.value);
|
|
1346
|
-
if (this.isPunct(",")) this.next();
|
|
1347
|
-
}
|
|
1348
|
-
this.expect(")");
|
|
1603
|
+
const params = this.parseParamList();
|
|
1349
1604
|
return { t: "arrow", params, body: this.parseArrowBody() };
|
|
1350
1605
|
}
|
|
1351
1606
|
if (t.type === "num" || t.type === "str") {
|
|
@@ -1450,16 +1705,7 @@ var Parser = class {
|
|
|
1450
1705
|
props.push({ key, value: this.parseAssignment() });
|
|
1451
1706
|
} else if (this.isPunct("(")) {
|
|
1452
1707
|
this.next();
|
|
1453
|
-
const params =
|
|
1454
|
-
while (!this.isPunct(")")) {
|
|
1455
|
-
const param = this.next();
|
|
1456
|
-
if (param.type !== "ident") {
|
|
1457
|
-
throw new VoodooSyntaxError("Expected a parameter name", this.source, param.start);
|
|
1458
|
-
}
|
|
1459
|
-
params.push(param.value);
|
|
1460
|
-
if (this.isPunct(",")) this.next();
|
|
1461
|
-
}
|
|
1462
|
-
this.expect(")");
|
|
1708
|
+
const params = this.parseParamList();
|
|
1463
1709
|
props.push({ key, value: { t: "method", params, body: this.parseArrowBody() } });
|
|
1464
1710
|
} else {
|
|
1465
1711
|
props.push({ key, value: { t: "id", n: key } });
|
package/dist/socket.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { socketSupported, createSocket, socket } from './chunk-
|
|
2
|
-
export { ENGINE, SIO, createSocket, decodeEngine, decodeSocketIo, encodeSocketIo, engineURL, resolveSocketURL, socket, socketSupported } from './chunk-
|
|
3
|
-
import { evaluateIn, readAttr } from './chunk-
|
|
4
|
-
import { reactive } from './chunk-
|
|
5
|
-
import { warnAlias } from './chunk-
|
|
6
|
-
import { parseDuration } from './chunk-
|
|
7
|
-
import { defineDirective, PRIORITY, config } from './chunk-
|
|
8
|
-
import './chunk-
|
|
1
|
+
import { socketSupported, createSocket, socket } from './chunk-HW75QJLQ.js';
|
|
2
|
+
export { ENGINE, SIO, createSocket, decodeEngine, decodeSocketIo, encodeSocketIo, engineURL, resolveSocketURL, socket, socketSupported } from './chunk-HW75QJLQ.js';
|
|
3
|
+
import { evaluateIn, readAttr } from './chunk-OUEXXXTU.js';
|
|
4
|
+
import { reactive } from './chunk-H64IUSGJ.js';
|
|
5
|
+
import { warnAlias } from './chunk-EYNFAYEV.js';
|
|
6
|
+
import { parseDuration } from './chunk-H3RGM7PR.js';
|
|
7
|
+
import { defineDirective, PRIORITY, config } from './chunk-PXUSD6TT.js';
|
|
8
|
+
import './chunk-3JV2AYK6.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Voodoo.js v0.
|
|
11
|
+
* Voodoo.js v0.10.0
|
|
12
12
|
* JavaScript feels like magic.
|
|
13
13
|
* (c) 2026 Voodoo.js contributors. MIT License.
|
|
14
14
|
*/
|
package/dist/utils.cjs
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { capitalize, chunk, clone, debounce, device, escapeHtml, formatCurrency, formatDate, formatFileSize, formatNumber, formatPercent, get, groupBy, isBrowser, matchesMedia, memoize, merge, once, parseDuration, random, relativeTime, sample, set, setFormatDefaults, sleep, slugify, sortBy, stripTags, throttle, titleCase, truncate, uid, unique, uuid } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { capitalize, chunk, clone, debounce, device, escapeHtml, formatCurrency, formatDate, formatFileSize, formatNumber, formatPercent, get, groupBy, isBrowser, matchesMedia, memoize, merge, once, parseDuration, random, relativeTime, sample, set, setFormatDefaults, sleep, slugify, sortBy, stripTags, throttle, titleCase, truncate, uid, unique, uuid } from './chunk-H3RGM7PR.js';
|
|
2
|
+
import './chunk-3JV2AYK6.js';
|
|
3
3
|
//# sourceMappingURL=utils.js.map
|
|
4
4
|
//# sourceMappingURL=utils.js.map
|