@marko/runtime-tags 6.0.109 → 6.0.111
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/debug/dom.js +21 -36
- package/dist/debug/dom.mjs +21 -36
- package/dist/dom.js +33 -42
- package/dist/dom.mjs +33 -42
- package/dist/translator/index.js +47 -34
- package/dist/translator/util/references.d.ts +1 -0
- package/dist/translator/util/walks.d.ts +2 -1
- package/dist/translator/util/writer.d.ts +2 -2
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
|
@@ -535,19 +535,20 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
535
535
|
const serializeContext = {
|
|
536
536
|
_: registeredValues
|
|
537
537
|
};
|
|
538
|
-
const visitBranches = branchesEnabled && /* @__PURE__ */ (() => {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
538
|
+
const visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
|
|
539
|
+
return (branchId, branch, childBranch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
540
|
+
if (visitType !== "[" /* BranchStart */) {
|
|
541
|
+
visitScope["Getter:" /* Getter */ + nextToken(
|
|
542
|
+
/* read accessor */
|
|
543
|
+
)] = /* @__PURE__ */ ((node) => () => node)(
|
|
544
|
+
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit
|
|
545
|
+
);
|
|
546
|
+
accessor = "BranchScopes:" /* BranchScopes */ + lastToken;
|
|
547
|
+
singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */;
|
|
548
|
+
nextToken(
|
|
549
|
+
/* read optional first branchId */
|
|
550
|
+
);
|
|
551
|
+
}
|
|
551
552
|
while (branchId = +lastToken) {
|
|
552
553
|
(endedBranches ||= []).push(
|
|
553
554
|
branch = scopeLookup[branchId] ||= {
|
|
@@ -592,33 +593,16 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
592
593
|
visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
|
|
593
594
|
}
|
|
594
595
|
}
|
|
595
|
-
};
|
|
596
|
-
return () => {
|
|
597
596
|
if (visitType === "[" /* BranchStart */) {
|
|
598
|
-
if (
|
|
599
|
-
endBranch();
|
|
600
|
-
} else {
|
|
597
|
+
if (!endedBranches) {
|
|
601
598
|
branchScopesStack.push(curBranchScopes);
|
|
602
599
|
curBranchScopes = void 0;
|
|
603
600
|
}
|
|
604
601
|
branchStarts.push(visit);
|
|
605
|
-
} else {
|
|
606
|
-
visitScope["Getter:" /* Getter */ + nextToken(
|
|
607
|
-
/* read accessor */
|
|
608
|
-
)] = /* @__PURE__ */ ((node) => () => node)(
|
|
609
|
-
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit
|
|
610
|
-
);
|
|
611
|
-
endBranch(
|
|
612
|
-
"BranchScopes:" /* BranchScopes */ + lastToken,
|
|
613
|
-
(nextToken(
|
|
614
|
-
/* read optional first branchId */
|
|
615
|
-
), visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */)
|
|
616
|
-
);
|
|
617
602
|
}
|
|
618
603
|
};
|
|
619
604
|
})();
|
|
620
605
|
let $global;
|
|
621
|
-
let lastScopeId = 0;
|
|
622
606
|
let lastEffect;
|
|
623
607
|
let visits;
|
|
624
608
|
let resumes;
|
|
@@ -628,12 +612,13 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
628
612
|
let visitScope;
|
|
629
613
|
let lastToken;
|
|
630
614
|
let lastTokenIndex;
|
|
615
|
+
let lastScopeId = 0;
|
|
631
616
|
const nextToken = () => lastToken = visitText.slice(
|
|
632
617
|
lastTokenIndex,
|
|
633
618
|
// eslint-disable-next-line no-cond-assign
|
|
634
619
|
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
|
|
635
620
|
);
|
|
636
|
-
render.w = () => {
|
|
621
|
+
render.w = (effects = []) => {
|
|
637
622
|
try {
|
|
638
623
|
walk2();
|
|
639
624
|
isResuming = 1;
|
|
@@ -641,11 +626,11 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
641
626
|
if (typeof serialized === "string") {
|
|
642
627
|
lastEffect = serialized;
|
|
643
628
|
} else if (typeof serialized === "number") {
|
|
644
|
-
|
|
629
|
+
effects.push(
|
|
630
|
+
registeredValues[lastEffect],
|
|
645
631
|
scopeLookup[serialized] ||= {
|
|
646
632
|
["#Id" /* Id */]: serialized
|
|
647
|
-
}
|
|
648
|
-
registeredValues[lastEffect]
|
|
633
|
+
}
|
|
649
634
|
);
|
|
650
635
|
} else {
|
|
651
636
|
for (const scope of serialized(serializeContext)) {
|
|
@@ -680,7 +665,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
680
665
|
visitBranches();
|
|
681
666
|
}
|
|
682
667
|
}
|
|
683
|
-
|
|
668
|
+
runEffects(effects);
|
|
684
669
|
} finally {
|
|
685
670
|
isResuming = visits.length = resumes.length = 0;
|
|
686
671
|
}
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -432,19 +432,20 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
432
432
|
const serializeContext = {
|
|
433
433
|
_: registeredValues
|
|
434
434
|
};
|
|
435
|
-
const visitBranches = branchesEnabled && /* @__PURE__ */ (() => {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
435
|
+
const visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
|
|
436
|
+
return (branchId, branch, childBranch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
437
|
+
if (visitType !== "[" /* BranchStart */) {
|
|
438
|
+
visitScope["Getter:" /* Getter */ + nextToken(
|
|
439
|
+
/* read accessor */
|
|
440
|
+
)] = /* @__PURE__ */ ((node) => () => node)(
|
|
441
|
+
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit
|
|
442
|
+
);
|
|
443
|
+
accessor = "BranchScopes:" /* BranchScopes */ + lastToken;
|
|
444
|
+
singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */;
|
|
445
|
+
nextToken(
|
|
446
|
+
/* read optional first branchId */
|
|
447
|
+
);
|
|
448
|
+
}
|
|
448
449
|
while (branchId = +lastToken) {
|
|
449
450
|
(endedBranches ||= []).push(
|
|
450
451
|
branch = scopeLookup[branchId] ||= {
|
|
@@ -489,33 +490,16 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
489
490
|
visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
|
|
490
491
|
}
|
|
491
492
|
}
|
|
492
|
-
};
|
|
493
|
-
return () => {
|
|
494
493
|
if (visitType === "[" /* BranchStart */) {
|
|
495
|
-
if (
|
|
496
|
-
endBranch();
|
|
497
|
-
} else {
|
|
494
|
+
if (!endedBranches) {
|
|
498
495
|
branchScopesStack.push(curBranchScopes);
|
|
499
496
|
curBranchScopes = void 0;
|
|
500
497
|
}
|
|
501
498
|
branchStarts.push(visit);
|
|
502
|
-
} else {
|
|
503
|
-
visitScope["Getter:" /* Getter */ + nextToken(
|
|
504
|
-
/* read accessor */
|
|
505
|
-
)] = /* @__PURE__ */ ((node) => () => node)(
|
|
506
|
-
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit
|
|
507
|
-
);
|
|
508
|
-
endBranch(
|
|
509
|
-
"BranchScopes:" /* BranchScopes */ + lastToken,
|
|
510
|
-
(nextToken(
|
|
511
|
-
/* read optional first branchId */
|
|
512
|
-
), visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */)
|
|
513
|
-
);
|
|
514
499
|
}
|
|
515
500
|
};
|
|
516
501
|
})();
|
|
517
502
|
let $global;
|
|
518
|
-
let lastScopeId = 0;
|
|
519
503
|
let lastEffect;
|
|
520
504
|
let visits;
|
|
521
505
|
let resumes;
|
|
@@ -525,12 +509,13 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
525
509
|
let visitScope;
|
|
526
510
|
let lastToken;
|
|
527
511
|
let lastTokenIndex;
|
|
512
|
+
let lastScopeId = 0;
|
|
528
513
|
const nextToken = () => lastToken = visitText.slice(
|
|
529
514
|
lastTokenIndex,
|
|
530
515
|
// eslint-disable-next-line no-cond-assign
|
|
531
516
|
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
|
|
532
517
|
);
|
|
533
|
-
render.w = () => {
|
|
518
|
+
render.w = (effects = []) => {
|
|
534
519
|
try {
|
|
535
520
|
walk2();
|
|
536
521
|
isResuming = 1;
|
|
@@ -538,11 +523,11 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
538
523
|
if (typeof serialized === "string") {
|
|
539
524
|
lastEffect = serialized;
|
|
540
525
|
} else if (typeof serialized === "number") {
|
|
541
|
-
|
|
526
|
+
effects.push(
|
|
527
|
+
registeredValues[lastEffect],
|
|
542
528
|
scopeLookup[serialized] ||= {
|
|
543
529
|
["#Id" /* Id */]: serialized
|
|
544
|
-
}
|
|
545
|
-
registeredValues[lastEffect]
|
|
530
|
+
}
|
|
546
531
|
);
|
|
547
532
|
} else {
|
|
548
533
|
for (const scope of serialized(serializeContext)) {
|
|
@@ -577,7 +562,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
577
562
|
visitBranches();
|
|
578
563
|
}
|
|
579
564
|
}
|
|
580
|
-
|
|
565
|
+
runEffects(effects);
|
|
581
566
|
} finally {
|
|
582
567
|
isResuming = visits.length = resumes.length = 0;
|
|
583
568
|
}
|
package/dist/dom.js
CHANGED
|
@@ -342,60 +342,51 @@ function init(runtimeId = "M") {
|
|
|
342
342
|
value: resumeRender = ((renderId) => {
|
|
343
343
|
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, serializeContext = {
|
|
344
344
|
_: registeredValues
|
|
345
|
-
}, visitBranches = branchesEnabled && /* @__PURE__ */ (() => {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
345
|
+
}, visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, childBranch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
346
|
+
for (visitType !== "[" /* BranchStart */ && (visitScope["J" /* Getter */ + nextToken(
|
|
347
|
+
/* read accessor */
|
|
348
|
+
)] = /* @__PURE__ */ ((node) => () => node)(
|
|
349
|
+
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit
|
|
350
|
+
), accessor = "A" /* BranchScopes */ + lastToken, singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */, nextToken(
|
|
351
|
+
/* read optional first branchId */
|
|
352
|
+
)); branchId = +lastToken; ) {
|
|
353
|
+
if ((endedBranches ||= []).push(
|
|
354
|
+
branch = scopeLookup[branchId] ||= {
|
|
355
|
+
L: branchId
|
|
356
|
+
}
|
|
357
|
+
), branch.F = branch, singleNode) {
|
|
358
|
+
for (; startVisit.previousSibling && ~visits.indexOf(
|
|
359
|
+
startVisit = startVisit.previousSibling
|
|
360
|
+
); ) ;
|
|
361
|
+
branch.K = branch.S = startVisit, visitType === "'" /* BranchEndNativeTag */ && (branch.a = startVisit);
|
|
362
|
+
} else
|
|
363
|
+
curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
364
|
+
for (; i && orphanBranches[--i].L > branchId; )
|
|
365
|
+
(childBranch = orphanBranches.pop()).N = branch, (branch.D ||= /* @__PURE__ */ new Set()).add(
|
|
366
|
+
childBranch
|
|
366
367
|
);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
)] = /* @__PURE__ */ ((node) => () => node)(
|
|
374
|
-
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit
|
|
375
|
-
), endBranch(
|
|
376
|
-
"A" /* BranchScopes */ + lastToken,
|
|
377
|
-
(nextToken(
|
|
378
|
-
/* read optional first branchId */
|
|
379
|
-
), visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */)
|
|
380
|
-
));
|
|
381
|
-
};
|
|
382
|
-
})(), $global, lastScopeId = 0, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, nextToken = () => lastToken = visitText.slice(
|
|
368
|
+
nextToken(
|
|
369
|
+
/* read optional next branchId */
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
endedBranches && (orphanBranches.push(...endedBranches), singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0])), visitType === "[" /* BranchStart */ && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
|
|
373
|
+
})(), $global, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, lastScopeId = 0, nextToken = () => lastToken = visitText.slice(
|
|
383
374
|
lastTokenIndex,
|
|
384
375
|
// eslint-disable-next-line no-cond-assign
|
|
385
376
|
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
|
|
386
377
|
);
|
|
387
|
-
return render.w = () => {
|
|
378
|
+
return render.w = (effects = []) => {
|
|
388
379
|
try {
|
|
389
380
|
walk2(), isResuming = 1;
|
|
390
381
|
for (let serialized of resumes = render.r || [])
|
|
391
382
|
if (typeof serialized == "string")
|
|
392
383
|
lastEffect = serialized;
|
|
393
384
|
else if (typeof serialized == "number")
|
|
394
|
-
|
|
385
|
+
effects.push(
|
|
386
|
+
registeredValues[lastEffect],
|
|
395
387
|
scopeLookup[serialized] ||= {
|
|
396
388
|
L: serialized
|
|
397
|
-
}
|
|
398
|
-
registeredValues[lastEffect]
|
|
389
|
+
}
|
|
399
390
|
);
|
|
400
391
|
else
|
|
401
392
|
for (let scope of serialized(serializeContext))
|
|
@@ -406,7 +397,7 @@ function init(runtimeId = "M") {
|
|
|
406
397
|
)] ||= {
|
|
407
398
|
L: +lastToken
|
|
408
399
|
}, visitType === "*" /* Node */ ? visitScope["J" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling) : branchesEnabled && visitBranches();
|
|
409
|
-
|
|
400
|
+
runEffects(effects);
|
|
410
401
|
} finally {
|
|
411
402
|
isResuming = visits.length = resumes.length = 0;
|
|
412
403
|
}
|
package/dist/dom.mjs
CHANGED
|
@@ -242,60 +242,51 @@ function init(runtimeId = "M") {
|
|
|
242
242
|
value: resumeRender = ((renderId) => {
|
|
243
243
|
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, serializeContext = {
|
|
244
244
|
_: registeredValues
|
|
245
|
-
}, visitBranches = branchesEnabled && /* @__PURE__ */ (() => {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
245
|
+
}, visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, childBranch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
246
|
+
for (visitType !== "[" /* BranchStart */ && (visitScope["J" /* Getter */ + nextToken(
|
|
247
|
+
/* read accessor */
|
|
248
|
+
)] = /* @__PURE__ */ ((node) => () => node)(
|
|
249
|
+
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit
|
|
250
|
+
), accessor = "A" /* BranchScopes */ + lastToken, singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */, nextToken(
|
|
251
|
+
/* read optional first branchId */
|
|
252
|
+
)); branchId = +lastToken; ) {
|
|
253
|
+
if ((endedBranches ||= []).push(
|
|
254
|
+
branch = scopeLookup[branchId] ||= {
|
|
255
|
+
L: branchId
|
|
256
|
+
}
|
|
257
|
+
), branch.F = branch, singleNode) {
|
|
258
|
+
for (; startVisit.previousSibling && ~visits.indexOf(
|
|
259
|
+
startVisit = startVisit.previousSibling
|
|
260
|
+
); ) ;
|
|
261
|
+
branch.K = branch.S = startVisit, visitType === "'" /* BranchEndNativeTag */ && (branch.a = startVisit);
|
|
262
|
+
} else
|
|
263
|
+
curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
264
|
+
for (; i && orphanBranches[--i].L > branchId; )
|
|
265
|
+
(childBranch = orphanBranches.pop()).N = branch, (branch.D ||= /* @__PURE__ */ new Set()).add(
|
|
266
|
+
childBranch
|
|
266
267
|
);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
)] = /* @__PURE__ */ ((node) => () => node)(
|
|
274
|
-
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit
|
|
275
|
-
), endBranch(
|
|
276
|
-
"A" /* BranchScopes */ + lastToken,
|
|
277
|
-
(nextToken(
|
|
278
|
-
/* read optional first branchId */
|
|
279
|
-
), visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */)
|
|
280
|
-
));
|
|
281
|
-
};
|
|
282
|
-
})(), $global, lastScopeId = 0, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, nextToken = () => lastToken = visitText.slice(
|
|
268
|
+
nextToken(
|
|
269
|
+
/* read optional next branchId */
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
endedBranches && (orphanBranches.push(...endedBranches), singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0])), visitType === "[" /* BranchStart */ && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
|
|
273
|
+
})(), $global, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, lastScopeId = 0, nextToken = () => lastToken = visitText.slice(
|
|
283
274
|
lastTokenIndex,
|
|
284
275
|
// eslint-disable-next-line no-cond-assign
|
|
285
276
|
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
|
|
286
277
|
);
|
|
287
|
-
return render.w = () => {
|
|
278
|
+
return render.w = (effects = []) => {
|
|
288
279
|
try {
|
|
289
280
|
walk2(), isResuming = 1;
|
|
290
281
|
for (let serialized of resumes = render.r || [])
|
|
291
282
|
if (typeof serialized == "string")
|
|
292
283
|
lastEffect = serialized;
|
|
293
284
|
else if (typeof serialized == "number")
|
|
294
|
-
|
|
285
|
+
effects.push(
|
|
286
|
+
registeredValues[lastEffect],
|
|
295
287
|
scopeLookup[serialized] ||= {
|
|
296
288
|
L: serialized
|
|
297
|
-
}
|
|
298
|
-
registeredValues[lastEffect]
|
|
289
|
+
}
|
|
299
290
|
);
|
|
300
291
|
else
|
|
301
292
|
for (let scope of serialized(serializeContext))
|
|
@@ -306,7 +297,7 @@ function init(runtimeId = "M") {
|
|
|
306
297
|
)] ||= {
|
|
307
298
|
L: +lastToken
|
|
308
299
|
}, visitType === "*" /* Node */ ? visitScope["J" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling) : branchesEnabled && visitBranches();
|
|
309
|
-
|
|
300
|
+
runEffects(effects);
|
|
310
301
|
} finally {
|
|
311
302
|
isResuming = visits.length = resumes.length = 0;
|
|
312
303
|
}
|
package/dist/translator/index.js
CHANGED
|
@@ -2827,10 +2827,7 @@ function getExprIfSerialized(section, reason, expr) {
|
|
|
2827
2827
|
|
|
2828
2828
|
// src/translator/util/walks.ts
|
|
2829
2829
|
var import_compiler15 = require("@marko/compiler");
|
|
2830
|
-
var [getWalks] = createSectionState(
|
|
2831
|
-
"walks",
|
|
2832
|
-
() => [""]
|
|
2833
|
-
);
|
|
2830
|
+
var [getWalks] = createSectionState("walks", () => [""]);
|
|
2834
2831
|
var [getWalkComment] = createSectionState(
|
|
2835
2832
|
"walkComment",
|
|
2836
2833
|
() => []
|
|
@@ -2871,16 +2868,12 @@ function enterShallow(path5) {
|
|
|
2871
2868
|
const steps = getSteps(section);
|
|
2872
2869
|
steps.push(0 /* Enter */, 1 /* Exit */);
|
|
2873
2870
|
}
|
|
2874
|
-
function injectWalks(tag, expr) {
|
|
2871
|
+
function injectWalks(tag, name2, expr) {
|
|
2875
2872
|
const section = getSection(tag);
|
|
2876
2873
|
const walks = getWalks(section);
|
|
2877
2874
|
const walkComment = getWalkComment(section);
|
|
2878
2875
|
visitInternal(section);
|
|
2879
|
-
walkComment.push(
|
|
2880
|
-
`${walkCodeToName[tag.node.var ? 48 /* BeginChildWithVar */ : 47 /* BeginChild */]}`,
|
|
2881
|
-
expr && import_compiler15.types.isIdentifier(expr) ? expr.name : tag.get("name").toString(),
|
|
2882
|
-
walkCodeToName[38 /* EndChild */]
|
|
2883
|
-
);
|
|
2876
|
+
walkComment.push(`<${name2}${tag.node.var ? "/var" : ""}>`);
|
|
2884
2877
|
appendLiteral(
|
|
2885
2878
|
walks,
|
|
2886
2879
|
String.fromCharCode(
|
|
@@ -2979,18 +2972,18 @@ function getWalkString(section) {
|
|
|
2979
2972
|
}
|
|
2980
2973
|
visitInternal(section);
|
|
2981
2974
|
const walks = getWalks(section);
|
|
2982
|
-
const walkLiteral = normalizeStringExpression(walks);
|
|
2975
|
+
const walkLiteral = normalizeStringExpression(walks.map(unwrapWalk));
|
|
2983
2976
|
if (walkLiteral && walkLiteral.value !== "") {
|
|
2984
2977
|
withLeadingComment(walkLiteral, getWalkComment(section).join(", "));
|
|
2985
2978
|
}
|
|
2986
2979
|
return walkLiteral;
|
|
2987
2980
|
}
|
|
2981
|
+
function unwrapWalk(walk) {
|
|
2982
|
+
return typeof walk === "function" ? walk() || "" : walk;
|
|
2983
|
+
}
|
|
2988
2984
|
|
|
2989
2985
|
// src/translator/util/writer.ts
|
|
2990
|
-
var [getWrites] = createSectionState(
|
|
2991
|
-
"writes",
|
|
2992
|
-
() => [""]
|
|
2993
|
-
);
|
|
2986
|
+
var [getWrites] = createSectionState("writes", () => [""]);
|
|
2994
2987
|
var [getTrailerWrites] = createSectionState(
|
|
2995
2988
|
"trailerWrites",
|
|
2996
2989
|
() => [""]
|
|
@@ -3011,7 +3004,7 @@ function consumeHTML(path5) {
|
|
|
3011
3004
|
const section = getSection(path5);
|
|
3012
3005
|
const writes = getWrites(section);
|
|
3013
3006
|
const trailers = getTrailerWrites(section);
|
|
3014
|
-
const writeResult = normalizeStringExpression(writes);
|
|
3007
|
+
const writeResult = normalizeStringExpression(writes.map(unwrapWrite));
|
|
3015
3008
|
const trailerResult = normalizeStringExpression(trailers);
|
|
3016
3009
|
writes.length = 0;
|
|
3017
3010
|
writes[0] = "";
|
|
@@ -3050,9 +3043,12 @@ var [getSectionMeta] = createSectionState(
|
|
|
3050
3043
|
const writePostfix = section.content?.endType === 1 /* Dynamic */ ? "<!>" : "";
|
|
3051
3044
|
const writes = getWrites(section);
|
|
3052
3045
|
const meta = {
|
|
3053
|
-
setup: getSetup(section),
|
|
3054
3046
|
walks: getWalkString(section),
|
|
3055
|
-
writes: normalizeStringExpression([
|
|
3047
|
+
writes: normalizeStringExpression([
|
|
3048
|
+
writePrefix,
|
|
3049
|
+
...writes.map(unwrapWrite),
|
|
3050
|
+
writePostfix
|
|
3051
|
+
]),
|
|
3056
3052
|
decls: void 0
|
|
3057
3053
|
};
|
|
3058
3054
|
return meta;
|
|
@@ -3097,6 +3093,9 @@ function markNode(path5, nodeBinding, reason) {
|
|
|
3097
3093
|
}
|
|
3098
3094
|
}
|
|
3099
3095
|
}
|
|
3096
|
+
function unwrapWrite(write) {
|
|
3097
|
+
return typeof write === "function" ? write() || "" : write;
|
|
3098
|
+
}
|
|
3100
3099
|
|
|
3101
3100
|
// src/translator/core/return.ts
|
|
3102
3101
|
var tagsWithReturn = /* @__PURE__ */ new WeakSet();
|
|
@@ -4362,8 +4361,9 @@ function getRegisteredFnExpression(node) {
|
|
|
4362
4361
|
var dom_default = {
|
|
4363
4362
|
translate: {
|
|
4364
4363
|
exit(program) {
|
|
4364
|
+
forEachSectionReverse(getSectionMeta);
|
|
4365
4365
|
const section = getSectionForBody(program);
|
|
4366
|
-
const { walks, writes,
|
|
4366
|
+
const { walks, writes, decls } = getSectionMeta(section);
|
|
4367
4367
|
const domExports = program.node.extra.domExports;
|
|
4368
4368
|
const templateIdentifier = import_compiler23.types.identifier(domExports.template);
|
|
4369
4369
|
const walksIdentifier = import_compiler23.types.identifier(domExports.walks);
|
|
@@ -4398,14 +4398,15 @@ var dom_default = {
|
|
|
4398
4398
|
});
|
|
4399
4399
|
const tagParamsSignal = childSection.params && initValue(childSection.params);
|
|
4400
4400
|
const tagParamsIdentifier = tagParamsSignal && signalHasStatements(tagParamsSignal) ? tagParamsSignal.identifier : void 0;
|
|
4401
|
-
const { walks: walks2, writes: writes2,
|
|
4401
|
+
const { walks: walks2, writes: writes2, decls: decls2 } = getSectionMeta(childSection);
|
|
4402
|
+
const setup = getSetup(childSection);
|
|
4402
4403
|
writeSignals(childSection);
|
|
4403
4404
|
if (!childSection.downstreamBinding || bindingHasDownstreamExpressions(childSection.downstreamBinding)) {
|
|
4404
4405
|
if (getSectionParentIsOwner(childSection)) {
|
|
4405
4406
|
setSectionRendererArgs(childSection, [
|
|
4406
4407
|
writes2,
|
|
4407
4408
|
walks2,
|
|
4408
|
-
|
|
4409
|
+
setup,
|
|
4409
4410
|
tagParamsIdentifier
|
|
4410
4411
|
]);
|
|
4411
4412
|
} else {
|
|
@@ -4415,7 +4416,7 @@ var dom_default = {
|
|
|
4415
4416
|
...replaceNullishAndEmptyFunctionsWith0([
|
|
4416
4417
|
writes2,
|
|
4417
4418
|
walks2,
|
|
4418
|
-
|
|
4419
|
+
setup,
|
|
4419
4420
|
tagParamsIdentifier,
|
|
4420
4421
|
childSection.hoisted || childSection.isHoistThrough ? getSectionInstancesAccessorLiteral(childSection) : void 0
|
|
4421
4422
|
])
|
|
@@ -4455,13 +4456,13 @@ var dom_default = {
|
|
|
4455
4456
|
}
|
|
4456
4457
|
}
|
|
4457
4458
|
if (decls2) {
|
|
4458
|
-
extraDecls = extraDecls ? [...
|
|
4459
|
+
extraDecls = extraDecls ? [...decls2, ...extraDecls] : decls2;
|
|
4459
4460
|
}
|
|
4460
4461
|
}
|
|
4461
4462
|
});
|
|
4462
4463
|
writeSignals(section);
|
|
4463
4464
|
writeRegisteredFns();
|
|
4464
|
-
if (!
|
|
4465
|
+
if (!getSetup(section)) {
|
|
4465
4466
|
program.node.body.unshift(
|
|
4466
4467
|
import_compiler23.types.exportNamedDeclaration(
|
|
4467
4468
|
import_compiler23.types.variableDeclaration("const", [
|
|
@@ -8484,8 +8485,8 @@ function finalizeReferences() {
|
|
|
8484
8485
|
}
|
|
8485
8486
|
}
|
|
8486
8487
|
}
|
|
8488
|
+
forEachSection(finalizeParamSerializeReasonGroups);
|
|
8487
8489
|
forEachSectionReverse((section) => {
|
|
8488
|
-
finalizeParamSerializeReasonGroups(section);
|
|
8489
8490
|
finalizeKnownTags(section);
|
|
8490
8491
|
finalizeSerializeReason(section);
|
|
8491
8492
|
finalizeParamSerializeReasonGroups(section);
|
|
@@ -9421,6 +9422,11 @@ var define_default = {
|
|
|
9421
9422
|
const babelBinding = tag.scope.getBinding(tag.node.var.name);
|
|
9422
9423
|
let allDirectReferences = true;
|
|
9423
9424
|
for (const ref of babelBinding.referencePaths) {
|
|
9425
|
+
if (isReferenceHoisted(babelBinding.path, ref)) {
|
|
9426
|
+
throw ref.buildCodeFrameError(
|
|
9427
|
+
"Hoisted values must be functions. The `<define>` tag variable may not be hoisted. Please move the `<define>` tag prior to any references or extract to a separate `.marko` file."
|
|
9428
|
+
);
|
|
9429
|
+
}
|
|
9424
9430
|
if (ref.parent.type === "MarkoTag" && ref.parent.name === ref.node) {
|
|
9425
9431
|
(ref.parent.extra ??= {}).defineBodySection = bodySection;
|
|
9426
9432
|
dropReferences(ref.parent.name);
|
|
@@ -11478,6 +11484,7 @@ function buildUndefined4() {
|
|
|
11478
11484
|
// src/translator/core/try.ts
|
|
11479
11485
|
var import_compiler57 = require("@marko/compiler");
|
|
11480
11486
|
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
11487
|
+
var hasEnabledCatch = /* @__PURE__ */ new WeakSet();
|
|
11481
11488
|
var kDOMBinding2 = Symbol("try tag dom binding");
|
|
11482
11489
|
var try_default = {
|
|
11483
11490
|
analyze(tag) {
|
|
@@ -11591,9 +11598,13 @@ var try_default = {
|
|
|
11591
11598
|
translatedAttrs.statements
|
|
11592
11599
|
);
|
|
11593
11600
|
}
|
|
11594
|
-
(0, import_babel_utils46.getProgram)().node
|
|
11595
|
-
|
|
11596
|
-
|
|
11601
|
+
const program = (0, import_babel_utils46.getProgram)().node;
|
|
11602
|
+
if (!hasEnabledCatch.has(program)) {
|
|
11603
|
+
hasEnabledCatch.add(program);
|
|
11604
|
+
program.body.push(
|
|
11605
|
+
import_compiler57.types.expressionStatement(callRuntime("_enable_catch"))
|
|
11606
|
+
);
|
|
11607
|
+
}
|
|
11597
11608
|
addValue(
|
|
11598
11609
|
section,
|
|
11599
11610
|
referencedBindings,
|
|
@@ -12181,7 +12192,7 @@ function translateDOM(tag) {
|
|
|
12181
12192
|
}
|
|
12182
12193
|
);
|
|
12183
12194
|
write`${import_compiler62.types.identifier(childExports.template)}`;
|
|
12184
|
-
injectWalks(tag, import_compiler62.types.identifier(childExports.walks));
|
|
12195
|
+
injectWalks(tag, tagName, import_compiler62.types.identifier(childExports.walks));
|
|
12185
12196
|
} else {
|
|
12186
12197
|
knownTagTranslateDOM(
|
|
12187
12198
|
tag,
|
|
@@ -12214,6 +12225,7 @@ function translateDOM(tag) {
|
|
|
12214
12225
|
write`${(0, import_babel_utils50.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
|
12215
12226
|
injectWalks(
|
|
12216
12227
|
tag,
|
|
12228
|
+
tagName,
|
|
12217
12229
|
(0, import_babel_utils50.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
|
12218
12230
|
);
|
|
12219
12231
|
}
|
|
@@ -12359,11 +12371,12 @@ var dynamic_tag_default = {
|
|
|
12359
12371
|
}
|
|
12360
12372
|
}
|
|
12361
12373
|
);
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
|
|
12374
|
+
write`${() => getSectionMetaIdentifiers(definedBodySection).writes || ""}`;
|
|
12375
|
+
injectWalks(
|
|
12376
|
+
tag,
|
|
12377
|
+
tag.get("name").toString(),
|
|
12378
|
+
() => getSectionMetaIdentifiers(definedBodySection).walks
|
|
12379
|
+
);
|
|
12367
12380
|
tag.remove();
|
|
12368
12381
|
}
|
|
12369
12382
|
return;
|
|
@@ -86,6 +86,7 @@ export declare function trackDomVarReferences(tag: t.NodePath<t.MarkoTag>, bindi
|
|
|
86
86
|
export declare function trackVarReferences(tag: t.NodePath<t.MarkoTag>, type: BindingType, upstreamAlias?: Binding["upstreamAlias"]): Binding | undefined;
|
|
87
87
|
export declare function trackParamsReferences(body: t.NodePath<t.MarkoTagBody | t.Program>, type: BindingType, upstreamAlias?: Binding["upstreamAlias"]): Binding | undefined;
|
|
88
88
|
export declare function trackHoistedReference(referencePath: t.NodePath<t.Identifier>, binding: Binding): void;
|
|
89
|
+
export declare function isReferenceHoisted(bindingPath: t.NodePath, reference: t.NodePath): boolean;
|
|
89
90
|
export declare function setReferencesScope(path: t.NodePath<any>): void;
|
|
90
91
|
export declare function mergeReferences<T extends t.Node>(section: Section, target: T, nodes: (t.Node | undefined)[]): NonNullable<T["extra"]> & ReferencedExtra;
|
|
91
92
|
export declare function compareReferences(a: ReferencedBindings, b: ReferencedBindings): number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
|
2
2
|
import { WalkCode } from "../../common/types";
|
|
3
3
|
import { type Section } from "../util/sections";
|
|
4
|
+
type Walk = string | t.Expression | (() => undefined | string | t.Expression);
|
|
4
5
|
export declare enum Step {
|
|
5
6
|
Enter = 0,
|
|
6
7
|
Exit = 1
|
|
@@ -9,7 +10,7 @@ type VisitCodes = WalkCode.Get | WalkCode.Inside | WalkCode.Replace | WalkCode.D
|
|
|
9
10
|
export declare function enter(path: t.NodePath<any>): void;
|
|
10
11
|
export declare function exit(path: t.NodePath<any>): void;
|
|
11
12
|
export declare function enterShallow(path: t.NodePath<any>): void;
|
|
12
|
-
export declare function injectWalks(tag: t.NodePath<t.MarkoTag>,
|
|
13
|
+
export declare function injectWalks(tag: t.NodePath<t.MarkoTag>, name: string, expr: Walk): void;
|
|
13
14
|
export declare function visit(path: t.NodePath<t.MarkoTag | t.MarkoPlaceholder | t.Program>, code: VisitCodes): void;
|
|
14
15
|
export declare function getWalkString(section: Section): t.Expression | undefined;
|
|
15
16
|
export {};
|
|
@@ -2,12 +2,12 @@ import { types as t } from "@marko/compiler";
|
|
|
2
2
|
import { type Section } from "../util/sections";
|
|
3
3
|
import { type Binding } from "./references";
|
|
4
4
|
import type { SerializeReason } from "./serialize-reasons";
|
|
5
|
-
|
|
5
|
+
type Write = string | t.Expression | (() => undefined | string | t.Expression);
|
|
6
|
+
export declare function writeTo(path: t.NodePath<any>, trailer?: boolean): (strs: TemplateStringsArray, ...exprs: Write[]) => void;
|
|
6
7
|
export declare function consumeHTML(path: t.NodePath<any>): t.ExpressionStatement | undefined;
|
|
7
8
|
export declare function flushBefore(path: t.NodePath<any>): void;
|
|
8
9
|
export declare function flushInto(path: t.NodePath<t.MarkoTag> | t.NodePath<t.Program>): void;
|
|
9
10
|
interface SectionMeta {
|
|
10
|
-
setup: t.Expression | undefined;
|
|
11
11
|
walks: t.Expression | undefined;
|
|
12
12
|
writes: t.Expression | undefined;
|
|
13
13
|
decls: t.VariableDeclarator[] | undefined;
|