@marko/runtime-tags 6.0.139 → 6.0.141
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 +46 -23
- package/dist/debug/dom.mjs +46 -23
- package/dist/debug/html.js +3 -2
- package/dist/debug/html.mjs +3 -2
- package/dist/dom/resume.d.ts +1 -1
- package/dist/dom/signals.d.ts +5 -1
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +25 -17
- package/dist/dom.mjs +25 -17
- package/dist/html.js +4 -2
- package/dist/html.mjs +4 -2
- package/dist/translator/index.js +603 -525
- package/dist/translator/util/references.d.ts +22 -14
- package/dist/translator/util/sections.d.ts +1 -2
- package/dist/translator/util/signals.d.ts +4 -4
- package/dist/translator/util/translate-var.d.ts +0 -2
- package/dist/translator/visitors/program/dom.d.ts +1 -0
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
|
@@ -71,6 +71,7 @@ __export(dom_exports, {
|
|
|
71
71
|
_for_to: () => _for_to,
|
|
72
72
|
_for_until: () => _for_until,
|
|
73
73
|
_hoist: () => _hoist,
|
|
74
|
+
_hoist_resume: () => _hoist_resume,
|
|
74
75
|
_html: () => _html,
|
|
75
76
|
_id: () => _id,
|
|
76
77
|
_if: () => _if,
|
|
@@ -603,6 +604,11 @@ function _closure(...closureSignals) {
|
|
|
603
604
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
604
605
|
if (false) valueAccessor = decodeAccessor(valueAccessor);
|
|
605
606
|
const closureSignal = ((scope) => {
|
|
607
|
+
if (true) {
|
|
608
|
+
if (!(valueAccessor in (getOwnerScope ? getOwnerScope(scope) : scope["_" /* Owner */]))) {
|
|
609
|
+
throwUninitialized(valueAccessor);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
606
612
|
scope[closureSignal.___signalIndexAccessor] = closureSignal.___index;
|
|
607
613
|
fn(scope);
|
|
608
614
|
subscribeToScopeSet(
|
|
@@ -656,19 +662,22 @@ function _el_read(value) {
|
|
|
656
662
|
}
|
|
657
663
|
return value;
|
|
658
664
|
}
|
|
659
|
-
function*
|
|
665
|
+
function* traverse(scope, path, i = path.length - 1) {
|
|
660
666
|
if (rendering) {
|
|
661
667
|
_hoist_read_error();
|
|
662
668
|
}
|
|
663
669
|
if (scope) {
|
|
664
670
|
if (Symbol.iterator in scope) {
|
|
665
|
-
for (const
|
|
666
|
-
yield*
|
|
671
|
+
for (const childScope of scope.values()) {
|
|
672
|
+
yield* traverse(childScope, path, i);
|
|
667
673
|
}
|
|
668
|
-
} else if (curIndex) {
|
|
669
|
-
yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1);
|
|
670
674
|
} else {
|
|
671
|
-
|
|
675
|
+
const item = scope[path[i]];
|
|
676
|
+
if (i) {
|
|
677
|
+
yield* traverse(item, path, i - 1);
|
|
678
|
+
} else {
|
|
679
|
+
yield typeof item === "function" ? item() : item;
|
|
680
|
+
}
|
|
672
681
|
}
|
|
673
682
|
}
|
|
674
683
|
}
|
|
@@ -676,11 +685,24 @@ function _hoist(...path) {
|
|
|
676
685
|
if (false)
|
|
677
686
|
path = path.map((p) => typeof p === "string" ? p : decodeAccessor(p));
|
|
678
687
|
return (scope) => {
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
return
|
|
688
|
+
const fn = () => traverse(scope, path).next().value;
|
|
689
|
+
fn[Symbol.iterator] = () => traverse(scope, path);
|
|
690
|
+
return fn;
|
|
682
691
|
};
|
|
683
692
|
}
|
|
693
|
+
function _hoist_resume(id, ...path) {
|
|
694
|
+
return _resume(id, _hoist(...path));
|
|
695
|
+
}
|
|
696
|
+
function throwUninitialized(name) {
|
|
697
|
+
try {
|
|
698
|
+
__UNINITIALIZED__;
|
|
699
|
+
let __UNINITIALIZED__;
|
|
700
|
+
} catch (err) {
|
|
701
|
+
err.message = err.message.replaceAll("__UNINITIALIZED__", name);
|
|
702
|
+
throw err;
|
|
703
|
+
}
|
|
704
|
+
throw new ReferenceError(`Cannot access '${name}' before initialization`);
|
|
705
|
+
}
|
|
684
706
|
|
|
685
707
|
// src/dom/walker.ts
|
|
686
708
|
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
|
@@ -690,7 +712,6 @@ function walk(startNode, walkCodes, branch) {
|
|
|
690
712
|
}
|
|
691
713
|
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
692
714
|
let value;
|
|
693
|
-
let id;
|
|
694
715
|
let storedMultiplier = 0;
|
|
695
716
|
let currentMultiplier = 0;
|
|
696
717
|
let currentScopeIndex = 0;
|
|
@@ -700,8 +721,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
700
721
|
storedMultiplier = 0;
|
|
701
722
|
if (value === 32 /* Get */) {
|
|
702
723
|
const node = walker.currentNode;
|
|
703
|
-
scope[
|
|
704
|
-
scope["Getter:" /* Getter */ + id] = () => node;
|
|
724
|
+
scope[true ? getDebugKey(currentScopeIndex++, node) : decodeAccessor2(currentScopeIndex++)] = node;
|
|
705
725
|
} else if (value === 37 /* Replace */ || value === 49 /* DynamicTagWithVar */) {
|
|
706
726
|
walker.currentNode.replaceWith(
|
|
707
727
|
walker.currentNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : decodeAccessor2(currentScopeIndex++)] = new Text()
|
|
@@ -888,11 +908,9 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
888
908
|
const visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
|
|
889
909
|
return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
890
910
|
if (visitType !== "[" /* BranchStart */) {
|
|
891
|
-
visitScope[
|
|
911
|
+
visitScope[nextToken(
|
|
892
912
|
/* read accessor */
|
|
893
|
-
)] = /*
|
|
894
|
-
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit
|
|
895
|
-
);
|
|
913
|
+
)] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit;
|
|
896
914
|
accessor = "BranchScopes:" /* BranchScopes */ + lastToken;
|
|
897
915
|
singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */;
|
|
898
916
|
nextToken(
|
|
@@ -1005,7 +1023,9 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
1005
1023
|
/* read scope id */
|
|
1006
1024
|
));
|
|
1007
1025
|
if (visitType === "*" /* Node */) {
|
|
1008
|
-
visitScope[
|
|
1026
|
+
visitScope[nextToken(
|
|
1027
|
+
/* read accessor */
|
|
1028
|
+
)] = visit.previousSibling;
|
|
1009
1029
|
} else if (branchesEnabled) {
|
|
1010
1030
|
visitBranches();
|
|
1011
1031
|
}
|
|
@@ -1054,10 +1074,12 @@ function _var_resume(id, signal) {
|
|
|
1054
1074
|
return signal;
|
|
1055
1075
|
}
|
|
1056
1076
|
function _el(id, accessor) {
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1077
|
+
if (true) {
|
|
1078
|
+
return _resume(id, (scope) => () => _el_read(scope[accessor]));
|
|
1079
|
+
} else {
|
|
1080
|
+
accessor = decodeAccessor3(accessor);
|
|
1081
|
+
return _resume(id, (scope) => () => scope[accessor]);
|
|
1082
|
+
}
|
|
1061
1083
|
}
|
|
1062
1084
|
|
|
1063
1085
|
// src/dom/controllable.ts
|
|
@@ -1414,8 +1436,9 @@ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
|
|
|
1414
1436
|
el.removeAttribute(name);
|
|
1415
1437
|
}
|
|
1416
1438
|
}
|
|
1417
|
-
for (const
|
|
1418
|
-
|
|
1439
|
+
for (const name in nextAttrs) {
|
|
1440
|
+
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1441
|
+
if (!skip[key]) partial[key] = nextAttrs[name];
|
|
1419
1442
|
}
|
|
1420
1443
|
if (true) {
|
|
1421
1444
|
assertExclusiveAttrs({ ...nextAttrs, ...skip });
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -497,6 +497,11 @@ function _closure(...closureSignals) {
|
|
|
497
497
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
498
498
|
if (false) valueAccessor = decodeAccessor(valueAccessor);
|
|
499
499
|
const closureSignal = ((scope) => {
|
|
500
|
+
if (true) {
|
|
501
|
+
if (!(valueAccessor in (getOwnerScope ? getOwnerScope(scope) : scope["_" /* Owner */]))) {
|
|
502
|
+
throwUninitialized(valueAccessor);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
500
505
|
scope[closureSignal.___signalIndexAccessor] = closureSignal.___index;
|
|
501
506
|
fn(scope);
|
|
502
507
|
subscribeToScopeSet(
|
|
@@ -550,19 +555,22 @@ function _el_read(value) {
|
|
|
550
555
|
}
|
|
551
556
|
return value;
|
|
552
557
|
}
|
|
553
|
-
function*
|
|
558
|
+
function* traverse(scope, path, i = path.length - 1) {
|
|
554
559
|
if (rendering) {
|
|
555
560
|
_hoist_read_error();
|
|
556
561
|
}
|
|
557
562
|
if (scope) {
|
|
558
563
|
if (Symbol.iterator in scope) {
|
|
559
|
-
for (const
|
|
560
|
-
yield*
|
|
564
|
+
for (const childScope of scope.values()) {
|
|
565
|
+
yield* traverse(childScope, path, i);
|
|
561
566
|
}
|
|
562
|
-
} else if (curIndex) {
|
|
563
|
-
yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1);
|
|
564
567
|
} else {
|
|
565
|
-
|
|
568
|
+
const item = scope[path[i]];
|
|
569
|
+
if (i) {
|
|
570
|
+
yield* traverse(item, path, i - 1);
|
|
571
|
+
} else {
|
|
572
|
+
yield typeof item === "function" ? item() : item;
|
|
573
|
+
}
|
|
566
574
|
}
|
|
567
575
|
}
|
|
568
576
|
}
|
|
@@ -570,11 +578,24 @@ function _hoist(...path) {
|
|
|
570
578
|
if (false)
|
|
571
579
|
path = path.map((p) => typeof p === "string" ? p : decodeAccessor(p));
|
|
572
580
|
return (scope) => {
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
return
|
|
581
|
+
const fn = () => traverse(scope, path).next().value;
|
|
582
|
+
fn[Symbol.iterator] = () => traverse(scope, path);
|
|
583
|
+
return fn;
|
|
576
584
|
};
|
|
577
585
|
}
|
|
586
|
+
function _hoist_resume(id, ...path) {
|
|
587
|
+
return _resume(id, _hoist(...path));
|
|
588
|
+
}
|
|
589
|
+
function throwUninitialized(name) {
|
|
590
|
+
try {
|
|
591
|
+
__UNINITIALIZED__;
|
|
592
|
+
let __UNINITIALIZED__;
|
|
593
|
+
} catch (err) {
|
|
594
|
+
err.message = err.message.replaceAll("__UNINITIALIZED__", name);
|
|
595
|
+
throw err;
|
|
596
|
+
}
|
|
597
|
+
throw new ReferenceError(`Cannot access '${name}' before initialization`);
|
|
598
|
+
}
|
|
578
599
|
|
|
579
600
|
// src/dom/walker.ts
|
|
580
601
|
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
|
@@ -584,7 +605,6 @@ function walk(startNode, walkCodes, branch) {
|
|
|
584
605
|
}
|
|
585
606
|
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
586
607
|
let value;
|
|
587
|
-
let id;
|
|
588
608
|
let storedMultiplier = 0;
|
|
589
609
|
let currentMultiplier = 0;
|
|
590
610
|
let currentScopeIndex = 0;
|
|
@@ -594,8 +614,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
594
614
|
storedMultiplier = 0;
|
|
595
615
|
if (value === 32 /* Get */) {
|
|
596
616
|
const node = walker.currentNode;
|
|
597
|
-
scope[
|
|
598
|
-
scope["Getter:" /* Getter */ + id] = () => node;
|
|
617
|
+
scope[true ? getDebugKey(currentScopeIndex++, node) : decodeAccessor2(currentScopeIndex++)] = node;
|
|
599
618
|
} else if (value === 37 /* Replace */ || value === 49 /* DynamicTagWithVar */) {
|
|
600
619
|
walker.currentNode.replaceWith(
|
|
601
620
|
walker.currentNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : decodeAccessor2(currentScopeIndex++)] = new Text()
|
|
@@ -782,11 +801,9 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
782
801
|
const visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
|
|
783
802
|
return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
784
803
|
if (visitType !== "[" /* BranchStart */) {
|
|
785
|
-
visitScope[
|
|
804
|
+
visitScope[nextToken(
|
|
786
805
|
/* read accessor */
|
|
787
|
-
)] = /*
|
|
788
|
-
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit
|
|
789
|
-
);
|
|
806
|
+
)] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit;
|
|
790
807
|
accessor = "BranchScopes:" /* BranchScopes */ + lastToken;
|
|
791
808
|
singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */;
|
|
792
809
|
nextToken(
|
|
@@ -899,7 +916,9 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
899
916
|
/* read scope id */
|
|
900
917
|
));
|
|
901
918
|
if (visitType === "*" /* Node */) {
|
|
902
|
-
visitScope[
|
|
919
|
+
visitScope[nextToken(
|
|
920
|
+
/* read accessor */
|
|
921
|
+
)] = visit.previousSibling;
|
|
903
922
|
} else if (branchesEnabled) {
|
|
904
923
|
visitBranches();
|
|
905
924
|
}
|
|
@@ -948,10 +967,12 @@ function _var_resume(id, signal) {
|
|
|
948
967
|
return signal;
|
|
949
968
|
}
|
|
950
969
|
function _el(id, accessor) {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
970
|
+
if (true) {
|
|
971
|
+
return _resume(id, (scope) => () => _el_read(scope[accessor]));
|
|
972
|
+
} else {
|
|
973
|
+
accessor = decodeAccessor3(accessor);
|
|
974
|
+
return _resume(id, (scope) => () => scope[accessor]);
|
|
975
|
+
}
|
|
955
976
|
}
|
|
956
977
|
|
|
957
978
|
// src/dom/controllable.ts
|
|
@@ -1308,8 +1329,9 @@ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
|
|
|
1308
1329
|
el.removeAttribute(name);
|
|
1309
1330
|
}
|
|
1310
1331
|
}
|
|
1311
|
-
for (const
|
|
1312
|
-
|
|
1332
|
+
for (const name in nextAttrs) {
|
|
1333
|
+
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1334
|
+
if (!skip[key]) partial[key] = nextAttrs[name];
|
|
1313
1335
|
}
|
|
1314
1336
|
if (true) {
|
|
1315
1337
|
assertExclusiveAttrs({ ...nextAttrs, ...skip });
|
|
@@ -2574,6 +2596,7 @@ export {
|
|
|
2574
2596
|
_for_to,
|
|
2575
2597
|
_for_until,
|
|
2576
2598
|
_hoist,
|
|
2599
|
+
_hoist_resume,
|
|
2577
2600
|
_html,
|
|
2578
2601
|
_id,
|
|
2579
2602
|
_if,
|
package/dist/debug/html.js
CHANGED
|
@@ -3060,8 +3060,9 @@ function _attrs_content(data, nodeAccessor, scopeId, tagName, serializeReason) {
|
|
|
3060
3060
|
}
|
|
3061
3061
|
function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
|
|
3062
3062
|
const partial = {};
|
|
3063
|
-
for (const
|
|
3064
|
-
|
|
3063
|
+
for (const name in data) {
|
|
3064
|
+
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
3065
|
+
if (!skip[key]) partial[key] = data[name];
|
|
3065
3066
|
}
|
|
3066
3067
|
return _attrs(partial, nodeAccessor, scopeId, tagName);
|
|
3067
3068
|
}
|
package/dist/debug/html.mjs
CHANGED
|
@@ -2967,8 +2967,9 @@ function _attrs_content(data, nodeAccessor, scopeId, tagName, serializeReason) {
|
|
|
2967
2967
|
}
|
|
2968
2968
|
function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
|
|
2969
2969
|
const partial = {};
|
|
2970
|
-
for (const
|
|
2971
|
-
|
|
2970
|
+
for (const name in data) {
|
|
2971
|
+
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
2972
|
+
if (!skip[key]) partial[key] = data[name];
|
|
2972
2973
|
}
|
|
2973
2974
|
return _attrs(partial, nodeAccessor, scopeId, tagName);
|
|
2974
2975
|
}
|
package/dist/dom/resume.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AwaitCounter, type EncodedAccessor, type Scope } from "../common/types";
|
|
2
|
-
import type
|
|
2
|
+
import { type Signal } from "./signals";
|
|
3
3
|
type Resumes = (number | Scope)[];
|
|
4
4
|
type ResumeFn = (ctx: object) => Resumes;
|
|
5
5
|
export interface Renders {
|
package/dist/dom/signals.d.ts
CHANGED
|
@@ -29,4 +29,8 @@ export declare const _var_change: (scope: Scope, value: unknown, name?: string)
|
|
|
29
29
|
export declare function _id({ [AccessorProp.Global]: $global }: Scope): string;
|
|
30
30
|
export declare function _script(id: string, fn: (scope: Scope) => void): (scope: Scope) => void;
|
|
31
31
|
export declare function _el_read<T>(value: T): T;
|
|
32
|
-
|
|
32
|
+
type Hoistable<T> = () => T;
|
|
33
|
+
type Hoisted<T> = Hoistable<T> & Iterable<T>;
|
|
34
|
+
export declare function _hoist<T>(...path: Accessor[]): (scope: Scope) => Hoisted<T>;
|
|
35
|
+
export declare function _hoist_resume<T>(id: string, ...path: Accessor[]): (scope: Scope) => Hoisted<T>;
|
|
36
|
+
export {};
|
package/dist/dom.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export { _on } from "./dom/event";
|
|
|
11
11
|
export { _enable_catch as _enable_catch, run } from "./dom/queue";
|
|
12
12
|
export { _content, _content_closures, _content_resume } from "./dom/renderer";
|
|
13
13
|
export { _el, _resume, _var_resume, init } from "./dom/resume";
|
|
14
|
-
export { _child_setup, _closure, _closure_get, _const, _el_read, _for_closure, _hoist, _id, _if_closure, _let, _or, _return, _return_change, _script, _var, _var_change, } from "./dom/signals";
|
|
14
|
+
export { _child_setup, _closure, _closure_get, _const, _el_read, _for_closure, _hoist, _hoist_resume, _id, _if_closure, _let, _or, _return, _return_change, _script, _var, _var_change, } from "./dom/signals";
|
|
15
15
|
export { _template } from "./dom/template";
|
package/dist/dom.js
CHANGED
|
@@ -68,6 +68,7 @@ __export(dom_exports, {
|
|
|
68
68
|
_for_to: () => _for_to,
|
|
69
69
|
_for_until: () => _for_until,
|
|
70
70
|
_hoist: () => _hoist,
|
|
71
|
+
_hoist_resume: () => _hoist_resume,
|
|
71
72
|
_html: () => _html,
|
|
72
73
|
_id: () => _id,
|
|
73
74
|
_if: () => _if,
|
|
@@ -412,19 +413,25 @@ function _script(id, fn) {
|
|
|
412
413
|
function _el_read(value) {
|
|
413
414
|
return rendering && void 0, value;
|
|
414
415
|
}
|
|
415
|
-
function*
|
|
416
|
+
function* traverse(scope, path, i = path.length - 1) {
|
|
416
417
|
if (scope)
|
|
417
418
|
if (Symbol.iterator in scope)
|
|
418
|
-
for (let
|
|
419
|
-
yield*
|
|
420
|
-
else
|
|
419
|
+
for (let childScope of scope.values())
|
|
420
|
+
yield* traverse(childScope, path, i);
|
|
421
|
+
else {
|
|
422
|
+
let item = scope[path[i]];
|
|
423
|
+
i ? yield* traverse(item, path, i - 1) : yield typeof item == "function" ? item() : item;
|
|
424
|
+
}
|
|
421
425
|
}
|
|
422
426
|
function _hoist(...path) {
|
|
423
427
|
return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
|
|
424
|
-
let
|
|
425
|
-
return
|
|
428
|
+
let fn = () => traverse(scope, path).next().value;
|
|
429
|
+
return fn[Symbol.iterator] = () => traverse(scope, path), fn;
|
|
426
430
|
};
|
|
427
431
|
}
|
|
432
|
+
function _hoist_resume(id, ...path) {
|
|
433
|
+
return _resume(id, _hoist(...path));
|
|
434
|
+
}
|
|
428
435
|
|
|
429
436
|
// src/dom/walker.ts
|
|
430
437
|
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
|
@@ -432,11 +439,11 @@ function walk(startNode, walkCodes, branch) {
|
|
|
432
439
|
walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
|
|
433
440
|
}
|
|
434
441
|
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
435
|
-
let value,
|
|
442
|
+
let value, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
|
436
443
|
for (; currentWalkIndex < walkCodes.length; )
|
|
437
444
|
if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32 /* Get */) {
|
|
438
445
|
let node = walker.currentNode;
|
|
439
|
-
scope[
|
|
446
|
+
scope[decodeAccessor(currentScopeIndex++)] = node;
|
|
440
447
|
} else if (value === 37 /* Replace */ || value === 49 /* DynamicTagWithVar */)
|
|
441
448
|
walker.currentNode.replaceWith(
|
|
442
449
|
walker.currentNode = scope[decodeAccessor(currentScopeIndex++)] = new Text()
|
|
@@ -553,11 +560,9 @@ function init(runtimeId = "M") {
|
|
|
553
560
|
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, getScope = (id) => scopeLookup[id] ||= { L: +id }, serializeContext = {
|
|
554
561
|
_: registeredValues
|
|
555
562
|
}, visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
556
|
-
for (visitType !== "[" /* BranchStart */ && (visitScope[
|
|
563
|
+
for (visitType !== "[" /* BranchStart */ && (visitScope[nextToken(
|
|
557
564
|
/* read accessor */
|
|
558
|
-
)] = /*
|
|
559
|
-
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit
|
|
560
|
-
), accessor = "A" /* BranchScopes */ + lastToken, singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */, nextToken(
|
|
565
|
+
)] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit, accessor = "A" /* BranchScopes */ + lastToken, singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */, nextToken(
|
|
561
566
|
/* read optional first branchId */
|
|
562
567
|
)); branchId = +lastToken; ) {
|
|
563
568
|
if ((endedBranches ||= []).push(
|
|
@@ -593,7 +598,9 @@ function init(runtimeId = "M") {
|
|
|
593
598
|
for (visit of visits = render.v)
|
|
594
599
|
lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], visitScope = getScope(nextToken(
|
|
595
600
|
/* read scope id */
|
|
596
|
-
)), visitType === "*" /* Node */ ? visitScope[
|
|
601
|
+
)), visitType === "*" /* Node */ ? visitScope[nextToken(
|
|
602
|
+
/* read accessor */
|
|
603
|
+
)] = visit.previousSibling : branchesEnabled && visitBranches();
|
|
597
604
|
return visits.length = resumes.length = 0, effects;
|
|
598
605
|
}, render.w = () => {
|
|
599
606
|
walk2(), runResumeEffects(render);
|
|
@@ -630,8 +637,7 @@ function _var_resume(id, signal) {
|
|
|
630
637
|
return _resume(id, (scope) => (value) => signal(scope, value)), signal;
|
|
631
638
|
}
|
|
632
639
|
function _el(id, accessor) {
|
|
633
|
-
|
|
634
|
-
return _resume(id, (scope) => () => scope[getterAccessor]());
|
|
640
|
+
return accessor = decodeAccessor(accessor), _resume(id, (scope) => () => scope[accessor]);
|
|
635
641
|
}
|
|
636
642
|
|
|
637
643
|
// src/dom/controllable.ts
|
|
@@ -880,8 +886,10 @@ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
|
|
|
880
886
|
let { name } = el.attributes.item(i);
|
|
881
887
|
!skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
|
|
882
888
|
}
|
|
883
|
-
for (let
|
|
884
|
-
|
|
889
|
+
for (let name in nextAttrs) {
|
|
890
|
+
let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
891
|
+
skip[key] || (partial[key] = nextAttrs[name]);
|
|
892
|
+
}
|
|
885
893
|
attrsInternal(scope, nodeAccessor, partial);
|
|
886
894
|
}
|
|
887
895
|
function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
package/dist/dom.mjs
CHANGED
|
@@ -309,19 +309,25 @@ function _script(id, fn) {
|
|
|
309
309
|
function _el_read(value) {
|
|
310
310
|
return rendering && void 0, value;
|
|
311
311
|
}
|
|
312
|
-
function*
|
|
312
|
+
function* traverse(scope, path, i = path.length - 1) {
|
|
313
313
|
if (scope)
|
|
314
314
|
if (Symbol.iterator in scope)
|
|
315
|
-
for (let
|
|
316
|
-
yield*
|
|
317
|
-
else
|
|
315
|
+
for (let childScope of scope.values())
|
|
316
|
+
yield* traverse(childScope, path, i);
|
|
317
|
+
else {
|
|
318
|
+
let item = scope[path[i]];
|
|
319
|
+
i ? yield* traverse(item, path, i - 1) : yield typeof item == "function" ? item() : item;
|
|
320
|
+
}
|
|
318
321
|
}
|
|
319
322
|
function _hoist(...path) {
|
|
320
323
|
return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
|
|
321
|
-
let
|
|
322
|
-
return
|
|
324
|
+
let fn = () => traverse(scope, path).next().value;
|
|
325
|
+
return fn[Symbol.iterator] = () => traverse(scope, path), fn;
|
|
323
326
|
};
|
|
324
327
|
}
|
|
328
|
+
function _hoist_resume(id, ...path) {
|
|
329
|
+
return _resume(id, _hoist(...path));
|
|
330
|
+
}
|
|
325
331
|
|
|
326
332
|
// src/dom/walker.ts
|
|
327
333
|
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
|
@@ -329,11 +335,11 @@ function walk(startNode, walkCodes, branch) {
|
|
|
329
335
|
walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
|
|
330
336
|
}
|
|
331
337
|
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
332
|
-
let value,
|
|
338
|
+
let value, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
|
333
339
|
for (; currentWalkIndex < walkCodes.length; )
|
|
334
340
|
if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32 /* Get */) {
|
|
335
341
|
let node = walker.currentNode;
|
|
336
|
-
scope[
|
|
342
|
+
scope[decodeAccessor(currentScopeIndex++)] = node;
|
|
337
343
|
} else if (value === 37 /* Replace */ || value === 49 /* DynamicTagWithVar */)
|
|
338
344
|
walker.currentNode.replaceWith(
|
|
339
345
|
walker.currentNode = scope[decodeAccessor(currentScopeIndex++)] = new Text()
|
|
@@ -450,11 +456,9 @@ function init(runtimeId = "M") {
|
|
|
450
456
|
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, getScope = (id) => scopeLookup[id] ||= { L: +id }, serializeContext = {
|
|
451
457
|
_: registeredValues
|
|
452
458
|
}, visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
453
|
-
for (visitType !== "[" /* BranchStart */ && (visitScope[
|
|
459
|
+
for (visitType !== "[" /* BranchStart */ && (visitScope[nextToken(
|
|
454
460
|
/* read accessor */
|
|
455
|
-
)] = /*
|
|
456
|
-
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit
|
|
457
|
-
), accessor = "A" /* BranchScopes */ + lastToken, singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */, nextToken(
|
|
461
|
+
)] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit, accessor = "A" /* BranchScopes */ + lastToken, singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */, nextToken(
|
|
458
462
|
/* read optional first branchId */
|
|
459
463
|
)); branchId = +lastToken; ) {
|
|
460
464
|
if ((endedBranches ||= []).push(
|
|
@@ -490,7 +494,9 @@ function init(runtimeId = "M") {
|
|
|
490
494
|
for (visit of visits = render.v)
|
|
491
495
|
lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], visitScope = getScope(nextToken(
|
|
492
496
|
/* read scope id */
|
|
493
|
-
)), visitType === "*" /* Node */ ? visitScope[
|
|
497
|
+
)), visitType === "*" /* Node */ ? visitScope[nextToken(
|
|
498
|
+
/* read accessor */
|
|
499
|
+
)] = visit.previousSibling : branchesEnabled && visitBranches();
|
|
494
500
|
return visits.length = resumes.length = 0, effects;
|
|
495
501
|
}, render.w = () => {
|
|
496
502
|
walk2(), runResumeEffects(render);
|
|
@@ -527,8 +533,7 @@ function _var_resume(id, signal) {
|
|
|
527
533
|
return _resume(id, (scope) => (value) => signal(scope, value)), signal;
|
|
528
534
|
}
|
|
529
535
|
function _el(id, accessor) {
|
|
530
|
-
|
|
531
|
-
return _resume(id, (scope) => () => scope[getterAccessor]());
|
|
536
|
+
return accessor = decodeAccessor(accessor), _resume(id, (scope) => () => scope[accessor]);
|
|
532
537
|
}
|
|
533
538
|
|
|
534
539
|
// src/dom/controllable.ts
|
|
@@ -777,8 +782,10 @@ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
|
|
|
777
782
|
let { name } = el.attributes.item(i);
|
|
778
783
|
!skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
|
|
779
784
|
}
|
|
780
|
-
for (let
|
|
781
|
-
|
|
785
|
+
for (let name in nextAttrs) {
|
|
786
|
+
let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
787
|
+
skip[key] || (partial[key] = nextAttrs[name]);
|
|
788
|
+
}
|
|
782
789
|
attrsInternal(scope, nodeAccessor, partial);
|
|
783
790
|
}
|
|
784
791
|
function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
|
@@ -1598,6 +1605,7 @@ export {
|
|
|
1598
1605
|
_for_to,
|
|
1599
1606
|
_for_until,
|
|
1600
1607
|
_hoist,
|
|
1608
|
+
_hoist_resume,
|
|
1601
1609
|
_html,
|
|
1602
1610
|
_id,
|
|
1603
1611
|
_if,
|
package/dist/html.js
CHANGED
|
@@ -1910,8 +1910,10 @@ function _attrs_content(data, nodeAccessor, scopeId, tagName, serializeReason) {
|
|
|
1910
1910
|
}
|
|
1911
1911
|
function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
|
|
1912
1912
|
let partial = {};
|
|
1913
|
-
for (let
|
|
1914
|
-
|
|
1913
|
+
for (let name in data) {
|
|
1914
|
+
let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1915
|
+
skip[key] || (partial[key] = data[name]);
|
|
1916
|
+
}
|
|
1915
1917
|
return _attrs(partial, nodeAccessor, scopeId, tagName);
|
|
1916
1918
|
}
|
|
1917
1919
|
function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
|
package/dist/html.mjs
CHANGED
|
@@ -1820,8 +1820,10 @@ function _attrs_content(data, nodeAccessor, scopeId, tagName, serializeReason) {
|
|
|
1820
1820
|
}
|
|
1821
1821
|
function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
|
|
1822
1822
|
let partial = {};
|
|
1823
|
-
for (let
|
|
1824
|
-
|
|
1823
|
+
for (let name in data) {
|
|
1824
|
+
let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1825
|
+
skip[key] || (partial[key] = data[name]);
|
|
1826
|
+
}
|
|
1825
1827
|
return _attrs(partial, nodeAccessor, scopeId, tagName);
|
|
1826
1828
|
}
|
|
1827
1829
|
function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
|