marko 6.0.92 → 6.0.93
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/common/errors.d.ts +3 -0
- package/dist/common/types.d.ts +1 -3
- package/dist/debug/dom.js +54 -19
- package/dist/debug/dom.mjs +54 -19
- package/dist/debug/html.js +33 -13
- package/dist/debug/html.mjs +30 -13
- package/dist/dom/scope.d.ts +1 -1
- package/dist/dom/signals.d.ts +1 -0
- package/dist/dom.d.ts +2 -1
- package/dist/dom.js +93 -82
- package/dist/dom.mjs +93 -82
- package/dist/html/writer.d.ts +4 -3
- package/dist/html.d.ts +1 -0
- package/dist/html.js +17 -6
- package/dist/html.mjs +14 -6
- package/dist/translator/core/html-comment.d.ts +0 -2
- package/dist/translator/core/html-script.d.ts +0 -2
- package/dist/translator/core/html-style.d.ts +0 -2
- package/dist/translator/index.js +254 -352
- package/dist/translator/util/references.d.ts +1 -0
- package/dist/translator/util/sections.d.ts +1 -0
- package/dist/translator/util/signals.d.ts +2 -1
- package/dist/translator/util/translate-var.d.ts +2 -0
- package/dist/translator/visitors/program/html.d.ts +1 -0
- package/dist/translator/visitors/tag/native-tag.d.ts +0 -2
- package/package.json +1 -1
package/dist/dom.mjs
CHANGED
|
@@ -10,6 +10,10 @@ function* attrTagIterator() {
|
|
|
10
10
|
yield this, yield* this[rest];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// src/common/errors.ts
|
|
14
|
+
function _assert_hoist(value) {
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
// src/common/for.ts
|
|
14
18
|
function forIn(obj, cb) {
|
|
15
19
|
for (let key in obj)
|
|
@@ -119,31 +123,32 @@ function stripSpacesAndPunctuation(str) {
|
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
// src/dom/scope.ts
|
|
126
|
+
var nextScopeId = 1e6;
|
|
122
127
|
function createScope($global, closestBranch) {
|
|
123
128
|
let scope = {
|
|
124
|
-
l:
|
|
125
|
-
|
|
129
|
+
l: nextScopeId++,
|
|
130
|
+
n: 1,
|
|
126
131
|
k: closestBranch,
|
|
127
132
|
$global
|
|
128
133
|
};
|
|
129
134
|
return pendingScopes.push(scope), scope;
|
|
130
135
|
}
|
|
131
|
-
function skipScope(
|
|
132
|
-
return
|
|
136
|
+
function skipScope() {
|
|
137
|
+
return nextScopeId++;
|
|
133
138
|
}
|
|
134
139
|
function findBranchWithKey(scope, key) {
|
|
135
140
|
let branch = scope.k;
|
|
136
141
|
for (; branch && !branch[key]; )
|
|
137
|
-
branch = branch.
|
|
142
|
+
branch = branch.x;
|
|
138
143
|
return branch;
|
|
139
144
|
}
|
|
140
145
|
function destroyBranch(branch) {
|
|
141
|
-
branch.y?.
|
|
146
|
+
branch.x?.y?.delete(branch), destroyNestedBranches(branch);
|
|
142
147
|
}
|
|
143
148
|
function destroyNestedBranches(branch) {
|
|
144
|
-
branch.
|
|
145
|
-
for (let id in scope.
|
|
146
|
-
scope
|
|
149
|
+
branch.z = 1, branch.y?.forEach(destroyNestedBranches), branch.I?.forEach((scope) => {
|
|
150
|
+
for (let id in scope.A)
|
|
151
|
+
$signalReset(scope, id);
|
|
147
152
|
});
|
|
148
153
|
}
|
|
149
154
|
function removeAndDestroyBranch(branch) {
|
|
@@ -176,7 +181,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
176
181
|
} else if (value === 37 /* Replace */ || value === 49 /* DynamicTagWithVar */)
|
|
177
182
|
walker.currentNode.replaceWith(
|
|
178
183
|
walker.currentNode = scope[currentScopeIndex++] = new Text()
|
|
179
|
-
), value === 49 /* DynamicTagWithVar */ && (scope[currentScopeIndex++] = skipScope(
|
|
184
|
+
), value === 49 /* DynamicTagWithVar */ && (scope[currentScopeIndex++] = skipScope());
|
|
180
185
|
else {
|
|
181
186
|
if (value === 38 /* EndChild */)
|
|
182
187
|
return currentWalkIndex;
|
|
@@ -185,7 +190,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
185
190
|
currentWalkIndex,
|
|
186
191
|
walkCodes,
|
|
187
192
|
scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
|
|
188
|
-
), value === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(
|
|
193
|
+
), value === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope());
|
|
189
194
|
else if (value < 92)
|
|
190
195
|
for (value = 20 /* Next */ * currentMultiplier + value - 67 /* Next */; value--; )
|
|
191
196
|
walker.nextNode();
|
|
@@ -230,16 +235,18 @@ function init(runtimeId = "M") {
|
|
|
230
235
|
orphanBranches.splice(i, claimed);
|
|
231
236
|
};
|
|
232
237
|
return {
|
|
233
|
-
|
|
238
|
+
J() {
|
|
234
239
|
visitType === "[" /* BranchStart */ ? (endBranch(), branchStarts.push(visit)) : (visitScope[
|
|
235
|
-
nextToken()
|
|
240
|
+
"j" /* Getter */ + nextToken()
|
|
236
241
|
/* read accessor */
|
|
237
|
-
] =
|
|
242
|
+
] = /* @__PURE__ */ ((node) => () => node)(
|
|
243
|
+
visitScope[lastToken] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit
|
|
244
|
+
), nextToken(), endBranch(
|
|
238
245
|
visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */
|
|
239
246
|
));
|
|
240
247
|
},
|
|
241
|
-
|
|
242
|
-
scope.k = scopeLookup[scope.g || branchParents.get(scopeId)], branchParents.has(scopeId) && (scope.k && ((scope.
|
|
248
|
+
q(scope) {
|
|
249
|
+
scope.k = scopeLookup[scope.g || branchParents.get(scopeId)], branchParents.has(scopeId) && (scope.k && ((scope.x = scope.k).y ||= /* @__PURE__ */ new Set()).add(scope), scope.k = scope);
|
|
243
250
|
}
|
|
244
251
|
};
|
|
245
252
|
})(), $global, lastScopeId = 0, lastEffect, visits, resumes, scopeId, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, nextToken = () => lastToken = visitText.slice(
|
|
@@ -253,7 +260,7 @@ function init(runtimeId = "M") {
|
|
|
253
260
|
for (visit of visits = render.v)
|
|
254
261
|
lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], (scopeId = +nextToken()) && (visitScope = scopeLookup[scopeId] ||= {
|
|
255
262
|
l: scopeId
|
|
256
|
-
}), visitType === "*" /* Node */ ? visitScope["j" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling) : branchesEnabled && branches.
|
|
263
|
+
}), visitType === "*" /* Node */ ? visitScope["j" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling) : branchesEnabled && branches.J();
|
|
257
264
|
for (let serialized of resumes = render.r || [])
|
|
258
265
|
if (typeof serialized == "string")
|
|
259
266
|
lastEffect = serialized;
|
|
@@ -269,7 +276,7 @@ function init(runtimeId = "M") {
|
|
|
269
276
|
$global ? typeof scope == "number" ? lastScopeId += scope : (scopeId = ++lastScopeId, scope.$global = $global, scope.l = scopeId, scopeLookup[scopeId] !== scope && (scopeLookup[scopeId] = Object.assign(
|
|
270
277
|
scope,
|
|
271
278
|
scopeLookup[scopeId]
|
|
272
|
-
)), branchesEnabled && branches.
|
|
279
|
+
)), branchesEnabled && branches.q(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId);
|
|
273
280
|
} finally {
|
|
274
281
|
isResuming = visits.length = resumes.length = 0;
|
|
275
282
|
}
|
|
@@ -515,7 +522,7 @@ function _let(valueAccessor, fn) {
|
|
|
515
522
|
let valueChangeAccessor = "o" /* TagVariableChange */ + valueAccessor, update = (scope, value) => {
|
|
516
523
|
scope[valueAccessor] !== value && (scope[valueAccessor] = value, fn && fn(scope, value));
|
|
517
524
|
};
|
|
518
|
-
return (scope, value, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value ||
|
|
525
|
+
return (scope, value, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value || scope.n) && (scope[valueAccessor] = value, fn && fn(scope, value)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value) : (schedule(), queueRender(
|
|
519
526
|
scope,
|
|
520
527
|
update,
|
|
521
528
|
valueAccessor,
|
|
@@ -530,7 +537,7 @@ function _const(valueAccessor, fn = () => {
|
|
|
530
537
|
}
|
|
531
538
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "l") {
|
|
532
539
|
return (scope) => {
|
|
533
|
-
scope.
|
|
540
|
+
scope.n ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
534
541
|
};
|
|
535
542
|
}
|
|
536
543
|
function _for_closure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
@@ -540,7 +547,7 @@ function _for_closure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
|
540
547
|
ownerScope,
|
|
541
548
|
() => {
|
|
542
549
|
for (let scope of scopes)
|
|
543
|
-
!scope.
|
|
550
|
+
!scope.n && !scope.z && childSignal(scope);
|
|
544
551
|
},
|
|
545
552
|
-1,
|
|
546
553
|
0,
|
|
@@ -552,7 +559,7 @@ function _for_closure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
|
552
559
|
function _if_closure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
|
553
560
|
let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
|
554
561
|
let ifScope = scope[scopeAccessor];
|
|
555
|
-
ifScope && !ifScope.
|
|
562
|
+
ifScope && !ifScope.n && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, childSignal, -1);
|
|
556
563
|
};
|
|
557
564
|
return ownerSignal._ = childSignal, ownerSignal;
|
|
558
565
|
}
|
|
@@ -564,13 +571,13 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
|
564
571
|
));
|
|
565
572
|
}
|
|
566
573
|
function _closure(...closureSignals) {
|
|
567
|
-
let [{
|
|
574
|
+
let [{ D: ___scopeInstancesAccessor, E: ___signalIndexAccessor }] = closureSignals;
|
|
568
575
|
for (let i = closureSignals.length; i--; )
|
|
569
|
-
closureSignals[i].
|
|
576
|
+
closureSignals[i].K = i;
|
|
570
577
|
return (scope) => {
|
|
571
578
|
if (scope[___scopeInstancesAccessor])
|
|
572
579
|
for (let childScope of scope[___scopeInstancesAccessor])
|
|
573
|
-
childScope.
|
|
580
|
+
childScope.n || queueRender(
|
|
574
581
|
childScope,
|
|
575
582
|
closureSignals[childScope[___signalIndexAccessor]],
|
|
576
583
|
-1
|
|
@@ -579,13 +586,13 @@ function _closure(...closureSignals) {
|
|
|
579
586
|
}
|
|
580
587
|
function _closure_get(valueAccessor, fn, getOwnerScope) {
|
|
581
588
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = ((scope) => {
|
|
582
|
-
scope[closureSignal.
|
|
589
|
+
scope[closureSignal.E] = closureSignal.K, childSignal(scope), subscribeToScopeSet(
|
|
583
590
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
|
584
|
-
closureSignal.
|
|
591
|
+
closureSignal.D,
|
|
585
592
|
scope
|
|
586
593
|
);
|
|
587
594
|
});
|
|
588
|
-
return closureSignal.
|
|
595
|
+
return closureSignal.D = "a" /* ClosureScopes */ + valueAccessor, closureSignal.E = "b" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
|
|
589
596
|
}
|
|
590
597
|
function closure(valueAccessor, fn, getOwnerScope) {
|
|
591
598
|
return (scope) => {
|
|
@@ -617,6 +624,9 @@ function _script(id, fn) {
|
|
|
617
624
|
queueEffect(scope, fn);
|
|
618
625
|
};
|
|
619
626
|
}
|
|
627
|
+
function _el_read(value) {
|
|
628
|
+
return rendering && void 0, value;
|
|
629
|
+
}
|
|
620
630
|
function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
|
|
621
631
|
if (scope)
|
|
622
632
|
if (Symbol.iterator in scope)
|
|
@@ -626,7 +636,7 @@ function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
|
|
|
626
636
|
}
|
|
627
637
|
function _hoist(...path) {
|
|
628
638
|
return (scope) => {
|
|
629
|
-
let getOne = (...args) => iterator().next().value(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
|
|
639
|
+
let getOne = (...args) => iterator().next().value?.(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
|
|
630
640
|
return getOne;
|
|
631
641
|
};
|
|
632
642
|
}
|
|
@@ -634,7 +644,7 @@ function _hoist(...path) {
|
|
|
634
644
|
// src/dom/renderer.ts
|
|
635
645
|
function createBranch($global, renderer, parentScope, parentNode) {
|
|
636
646
|
let branch = createScope($global), parentBranch = parentScope?.k;
|
|
637
|
-
return branch._ = renderer.
|
|
647
|
+
return branch._ = renderer.t || parentScope, branch.k = branch, parentBranch && (branch.x = parentBranch, (parentBranch.y ||= /* @__PURE__ */ new Set()).add(branch)), renderer.B?.(
|
|
638
648
|
branch,
|
|
639
649
|
parentNode.namespaceURI
|
|
640
650
|
), branch;
|
|
@@ -646,7 +656,7 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
|
646
656
|
);
|
|
647
657
|
}
|
|
648
658
|
function setupBranch(renderer, branch) {
|
|
649
|
-
return renderer.
|
|
659
|
+
return renderer.C && queueRender(branch, renderer.C, -1), branch;
|
|
650
660
|
}
|
|
651
661
|
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
652
662
|
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
|
|
@@ -664,11 +674,11 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
664
674
|
};
|
|
665
675
|
return (owner) => ({
|
|
666
676
|
l: id,
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
677
|
+
B: clone,
|
|
678
|
+
t: owner,
|
|
679
|
+
C: setup,
|
|
670
680
|
m: params,
|
|
671
|
-
|
|
681
|
+
o: dynamicScopesAccessor
|
|
672
682
|
});
|
|
673
683
|
}
|
|
674
684
|
function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
@@ -683,7 +693,7 @@ function _content_closures(renderer, closureFns) {
|
|
|
683
693
|
closureSignals[key] = _const(key, closureFns[key]);
|
|
684
694
|
return (owner, closureValues) => {
|
|
685
695
|
let instance = renderer(owner);
|
|
686
|
-
return instance.
|
|
696
|
+
return instance.F = closureSignals, instance.L = closureValues, instance;
|
|
687
697
|
};
|
|
688
698
|
}
|
|
689
699
|
function _content_branch(template, walks, setup, params) {
|
|
@@ -840,9 +850,9 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
|
840
850
|
}
|
|
841
851
|
function _attr_content(scope, nodeAccessor, value) {
|
|
842
852
|
let content = normalizeClientRender(value), rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
|
843
|
-
scope[rendererAccessor] !== (scope[rendererAccessor] = content?.l) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.
|
|
844
|
-
content.
|
|
845
|
-
content.
|
|
853
|
+
scope[rendererAccessor] !== (scope[rendererAccessor] = content?.l) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.o && subscribeToScopeSet(
|
|
854
|
+
content.t,
|
|
855
|
+
content.o,
|
|
846
856
|
scope["d" /* ConditionalScope */ + nodeAccessor]
|
|
847
857
|
));
|
|
848
858
|
}
|
|
@@ -999,8 +1009,8 @@ function _await(nodeAccessor, renderer) {
|
|
|
999
1009
|
scope,
|
|
1000
1010
|
"d" /* PlaceholderContent */
|
|
1001
1011
|
), awaitBranch = scope[branchAccessor];
|
|
1002
|
-
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), !scope[promiseAccessor] && (tryWithPlaceholder.
|
|
1003
|
-
() => tryWithPlaceholder.
|
|
1012
|
+
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), !scope[promiseAccessor] && (tryWithPlaceholder.p = (tryWithPlaceholder.p || 0) + 1) === 1 && requestAnimationFrame(
|
|
1013
|
+
() => tryWithPlaceholder.p && runEffects(
|
|
1004
1014
|
prepareEffects(
|
|
1005
1015
|
() => queueRender(
|
|
1006
1016
|
tryWithPlaceholder,
|
|
@@ -1040,21 +1050,22 @@ function _await(nodeAccessor, renderer) {
|
|
|
1040
1050
|
),
|
|
1041
1051
|
referenceNode.parentNode,
|
|
1042
1052
|
referenceNode
|
|
1043
|
-
), referenceNode.remove()), renderer.m?.(awaitBranch, [data]), tryWithPlaceholder && (placeholderShown.add(pendingEffects), !--tryWithPlaceholder.
|
|
1053
|
+
), referenceNode.remove()), renderer.m?.(awaitBranch, [data]), tryWithPlaceholder && (placeholderShown.add(pendingEffects), !--tryWithPlaceholder.p)) {
|
|
1044
1054
|
let placeholderBranch = tryWithPlaceholder.c;
|
|
1045
1055
|
tryWithPlaceholder.c = 0, placeholderBranch && (placeholderBranch.h.parentNode.insertBefore(
|
|
1046
1056
|
tryWithPlaceholder.h.parentNode,
|
|
1047
1057
|
placeholderBranch.h
|
|
1048
|
-
), removeAndDestroyBranch(placeholderBranch))
|
|
1049
|
-
|
|
1050
|
-
|
|
1058
|
+
), removeAndDestroyBranch(placeholderBranch)), queueEffect(tryWithPlaceholder, (scope2) => {
|
|
1059
|
+
let pendingEffects2 = scope2.G;
|
|
1060
|
+
pendingEffects2 && (scope2.G = [], runEffects(pendingEffects2, !0));
|
|
1061
|
+
});
|
|
1051
1062
|
}
|
|
1052
1063
|
},
|
|
1053
1064
|
-1
|
|
1054
1065
|
));
|
|
1055
1066
|
},
|
|
1056
1067
|
(error) => {
|
|
1057
|
-
thisPromise === scope[promiseAccessor] && (tryWithPlaceholder && (tryWithPlaceholder.
|
|
1068
|
+
thisPromise === scope[promiseAccessor] && (tryWithPlaceholder && (tryWithPlaceholder.p = 0), scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
|
|
1058
1069
|
}
|
|
1059
1070
|
);
|
|
1060
1071
|
};
|
|
@@ -1078,7 +1089,7 @@ function renderCatch(scope, error) {
|
|
|
1078
1089
|
let tryWithCatch = findBranchWithKey(scope, "b" /* CatchContent */);
|
|
1079
1090
|
if (tryWithCatch) {
|
|
1080
1091
|
let owner = tryWithCatch._, placeholderBranch = tryWithCatch.c;
|
|
1081
|
-
placeholderBranch && (tryWithCatch.
|
|
1092
|
+
placeholderBranch && (tryWithCatch.p = 0, owner["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
|
|
1082
1093
|
owner,
|
|
1083
1094
|
tryWithCatch.a,
|
|
1084
1095
|
tryWithCatch.b,
|
|
@@ -1122,15 +1133,15 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1122
1133
|
0,
|
|
1123
1134
|
content,
|
|
1124
1135
|
createAndSetupBranch
|
|
1125
|
-
), content.
|
|
1126
|
-
content.
|
|
1127
|
-
content.
|
|
1136
|
+
), content.o && subscribeToScopeSet(
|
|
1137
|
+
content.t,
|
|
1138
|
+
content.o,
|
|
1128
1139
|
scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
|
|
1129
1140
|
);
|
|
1130
1141
|
}
|
|
1131
|
-
} else normalizedRenderer?.
|
|
1132
|
-
normalizedRenderer.
|
|
1133
|
-
normalizedRenderer.
|
|
1142
|
+
} else normalizedRenderer?.o && subscribeToScopeSet(
|
|
1143
|
+
normalizedRenderer.t,
|
|
1144
|
+
normalizedRenderer.o,
|
|
1134
1145
|
scope[childScopeAccessor]
|
|
1135
1146
|
);
|
|
1136
1147
|
if (normalizedRenderer) {
|
|
@@ -1142,10 +1153,10 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1142
1153
|
(inputIsArgs ? args[0] : args) || {}
|
|
1143
1154
|
);
|
|
1144
1155
|
else {
|
|
1145
|
-
for (let accessor in normalizedRenderer.
|
|
1146
|
-
normalizedRenderer.
|
|
1156
|
+
for (let accessor in normalizedRenderer.F)
|
|
1157
|
+
normalizedRenderer.F[accessor](
|
|
1147
1158
|
childScope,
|
|
1148
|
-
normalizedRenderer.
|
|
1159
|
+
normalizedRenderer.L[accessor]
|
|
1149
1160
|
);
|
|
1150
1161
|
if (normalizedRenderer.m)
|
|
1151
1162
|
if (inputIsArgs)
|
|
@@ -1239,17 +1250,17 @@ var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caugh
|
|
|
1239
1250
|
function queueRender(scope, signal, signalKey, value, scopeKey = scope.l) {
|
|
1240
1251
|
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
|
1241
1252
|
if (existingRender)
|
|
1242
|
-
existingRender.
|
|
1253
|
+
existingRender.H = value;
|
|
1243
1254
|
else {
|
|
1244
1255
|
let render = {
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1256
|
+
u: key,
|
|
1257
|
+
q: scope,
|
|
1258
|
+
M: signal,
|
|
1259
|
+
H: value
|
|
1249
1260
|
}, i = pendingRenders.push(render) - 1;
|
|
1250
1261
|
for (; i; ) {
|
|
1251
1262
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
|
1252
|
-
if (key - parent.
|
|
1263
|
+
if (key - parent.u >= 0) break;
|
|
1253
1264
|
pendingRenders[i] = parent, i = parentIndex;
|
|
1254
1265
|
}
|
|
1255
1266
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
|
@@ -1288,54 +1299,54 @@ function runRenders() {
|
|
|
1288
1299
|
for (; pendingRenders.length; ) {
|
|
1289
1300
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
|
1290
1301
|
if (render !== item) {
|
|
1291
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
|
1302
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).u;
|
|
1292
1303
|
for (; i < mid; ) {
|
|
1293
1304
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
|
1294
|
-
if (right < pendingRenders.length && pendingRenders[right].
|
|
1305
|
+
if (right < pendingRenders.length && pendingRenders[right].u - pendingRenders[bestChild].u < 0 && (bestChild = right), pendingRenders[bestChild].u - key >= 0)
|
|
1295
1306
|
break;
|
|
1296
1307
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
|
1297
1308
|
}
|
|
1298
1309
|
pendingRenders[i] = item;
|
|
1299
1310
|
}
|
|
1300
|
-
render.
|
|
1311
|
+
render.q.k?.z || runRender(render);
|
|
1301
1312
|
}
|
|
1302
1313
|
for (let scope of pendingScopes)
|
|
1303
|
-
scope.
|
|
1314
|
+
scope.n = 0;
|
|
1304
1315
|
pendingScopes = [];
|
|
1305
1316
|
}
|
|
1306
|
-
var runRender = (render) => render.
|
|
1317
|
+
var runRender = (render) => render.M(render.q, render.H), _enable_catch = () => {
|
|
1307
1318
|
_enable_catch = () => {
|
|
1308
1319
|
}, enableBranches();
|
|
1309
1320
|
let handlePendingTry = (fn, scope, branch) => {
|
|
1310
1321
|
for (; branch; ) {
|
|
1311
|
-
if (branch.
|
|
1312
|
-
return (branch.
|
|
1313
|
-
branch = branch.
|
|
1322
|
+
if (branch.p)
|
|
1323
|
+
return (branch.G ||= []).push(fn, scope);
|
|
1324
|
+
branch = branch.x;
|
|
1314
1325
|
}
|
|
1315
1326
|
};
|
|
1316
1327
|
runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
|
|
1317
1328
|
if (checkPending || caughtError.has(effects)) {
|
|
1318
1329
|
let i = 0, fn, scope, branch;
|
|
1319
1330
|
for (; i < effects.length; )
|
|
1320
|
-
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.
|
|
1331
|
+
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.z && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope, scope);
|
|
1321
1332
|
} else
|
|
1322
1333
|
runEffects2(effects);
|
|
1323
1334
|
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
|
1324
1335
|
try {
|
|
1325
1336
|
runRender2(render);
|
|
1326
1337
|
} catch (error) {
|
|
1327
|
-
renderCatch(render.
|
|
1338
|
+
renderCatch(render.q, error);
|
|
1328
1339
|
}
|
|
1329
1340
|
})(runRender);
|
|
1330
1341
|
};
|
|
1331
1342
|
|
|
1332
1343
|
// src/dom/abort-signal.ts
|
|
1333
1344
|
function $signalReset(scope, id) {
|
|
1334
|
-
let ctrl = scope.
|
|
1335
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
|
1345
|
+
let ctrl = scope.A?.[id];
|
|
1346
|
+
ctrl && (queueEffect(ctrl, abort), scope.A[id] = void 0);
|
|
1336
1347
|
}
|
|
1337
1348
|
function $signal(scope, id) {
|
|
1338
|
-
return scope.k && (scope.k.
|
|
1349
|
+
return scope.k && (scope.k.I ||= /* @__PURE__ */ new Set()).add(scope), ((scope.A ||= {})[id] ||= new AbortController()).signal;
|
|
1339
1350
|
}
|
|
1340
1351
|
function abort(ctrl) {
|
|
1341
1352
|
ctrl.abort();
|
|
@@ -1357,7 +1368,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1357
1368
|
_resume(RENDERER_REGISTER_ID, fn);
|
|
1358
1369
|
},
|
|
1359
1370
|
isRenderer(renderer) {
|
|
1360
|
-
return renderer.
|
|
1371
|
+
return renderer.B;
|
|
1361
1372
|
},
|
|
1362
1373
|
getStartNode(branch) {
|
|
1363
1374
|
return branch.h;
|
|
@@ -1379,7 +1390,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1379
1390
|
},
|
|
1380
1391
|
createRenderer(params, clone) {
|
|
1381
1392
|
let renderer = _content_branch(0, 0, 0, params);
|
|
1382
|
-
return renderer.
|
|
1393
|
+
return renderer.B = (branch) => {
|
|
1383
1394
|
let cloned = clone();
|
|
1384
1395
|
branch.h = cloned.startNode, branch.j = cloned.endNode;
|
|
1385
1396
|
}, renderer;
|
|
@@ -1392,10 +1403,10 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1392
1403
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
|
1393
1404
|
}
|
|
1394
1405
|
if (component.effects = prepareEffects(() => {
|
|
1395
|
-
branch || (created = 1,
|
|
1406
|
+
branch || (created = 1, branch = component.scope = createAndSetupBranch(
|
|
1396
1407
|
out.global,
|
|
1397
1408
|
renderer,
|
|
1398
|
-
renderer.
|
|
1409
|
+
renderer.t,
|
|
1399
1410
|
document.body
|
|
1400
1411
|
)), renderer.m?.(branch, renderer._ ? args[0] : args);
|
|
1401
1412
|
}), created)
|
|
@@ -1417,12 +1428,10 @@ var _template = (id, template, walks, setup, inputSignal) => {
|
|
|
1417
1428
|
function mount(input = {}, reference, position) {
|
|
1418
1429
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
|
1419
1430
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
|
1420
|
-
p: 0,
|
|
1421
1431
|
runtimeId: "M",
|
|
1422
1432
|
renderId: "_",
|
|
1423
1433
|
...$global
|
|
1424
1434
|
}) : $global = {
|
|
1425
|
-
p: 0,
|
|
1426
1435
|
runtimeId: "M",
|
|
1427
1436
|
renderId: "_"
|
|
1428
1437
|
}, position) {
|
|
@@ -1444,7 +1453,7 @@ function mount(input = {}, reference, position) {
|
|
|
1444
1453
|
parentNode
|
|
1445
1454
|
), branch.e = (newValue) => {
|
|
1446
1455
|
curValue = newValue;
|
|
1447
|
-
}, this.
|
|
1456
|
+
}, this.C?.(branch), args?.(branch, input);
|
|
1448
1457
|
});
|
|
1449
1458
|
return insertChildNodes(
|
|
1450
1459
|
parentNode,
|
|
@@ -1473,6 +1482,7 @@ function mount(input = {}, reference, position) {
|
|
|
1473
1482
|
export {
|
|
1474
1483
|
$signal,
|
|
1475
1484
|
$signalReset,
|
|
1485
|
+
_assert_hoist,
|
|
1476
1486
|
_attr,
|
|
1477
1487
|
_attr_class,
|
|
1478
1488
|
_attr_class_item,
|
|
@@ -1511,6 +1521,7 @@ export {
|
|
|
1511
1521
|
_content_resume,
|
|
1512
1522
|
_dynamic_tag,
|
|
1513
1523
|
_el,
|
|
1524
|
+
_el_read,
|
|
1514
1525
|
_enable_catch,
|
|
1515
1526
|
_for_closure,
|
|
1516
1527
|
_for_in,
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _hoist_read_error } from "../common/errors";
|
|
1
2
|
import { type $Global, type Accessor, type Falsy, ResumeSymbol } from "../common/types";
|
|
2
3
|
import { Serializer } from "./serializer";
|
|
3
4
|
import type { ServerRenderer } from "./template";
|
|
@@ -33,10 +34,10 @@ export declare function _serialize_if(condition: undefined | 1 | Record<string,
|
|
|
33
34
|
export declare function _serialize_guard(condition: undefined | 1 | Record<string, 1>, key: string): 0 | 1;
|
|
34
35
|
export declare function _el_resume(scopeId: number, accessor: Accessor, shouldResume?: 0 | 1): string;
|
|
35
36
|
export declare function _sep(shouldResume: 0 | 1): "" | "<!>";
|
|
36
|
-
export declare function _el(scopeId: number, id
|
|
37
|
-
export declare function _hoist(scopeId: number, id
|
|
37
|
+
export declare function _el(scopeId: number, id: string): () => void;
|
|
38
|
+
export declare function _hoist(scopeId: number, id: string): {
|
|
38
39
|
(): void;
|
|
39
|
-
[Symbol.iterator]:
|
|
40
|
+
[Symbol.iterator]: typeof _hoist_read_error;
|
|
40
41
|
};
|
|
41
42
|
export declare function _resume_branch(scopeId: number): void;
|
|
42
43
|
export declare function isInResumedBranch(): boolean;
|
package/dist/html.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { attrTag, attrTags } from "./common/attr-tag";
|
|
2
|
+
export { _assert_hoist, _el_read_error, _hoist_read_error, } from "./common/errors";
|
|
2
3
|
export { _attr, _attr_class, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_option_value, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, } from "./html/attrs";
|
|
3
4
|
export { compat } from "./html/compat";
|
|
4
5
|
export { _escape, _escape_script, _escape_style, _escape_textarea_value, _unescaped, } from "./html/content";
|
package/dist/html.js
CHANGED
|
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0
|
|
|
18
18
|
var html_exports = {};
|
|
19
19
|
__export(html_exports, {
|
|
20
20
|
$global: () => $global,
|
|
21
|
+
_assert_hoist: () => _assert_hoist,
|
|
21
22
|
_attr: () => _attr,
|
|
22
23
|
_attr_class: () => _attr_class,
|
|
23
24
|
_attr_content: () => _attr_content,
|
|
@@ -39,6 +40,7 @@ __export(html_exports, {
|
|
|
39
40
|
_content_resume: () => _content_resume,
|
|
40
41
|
_dynamic_tag: () => _dynamic_tag,
|
|
41
42
|
_el: () => _el,
|
|
43
|
+
_el_read_error: () => _el_read_error,
|
|
42
44
|
_el_resume: () => _el_resume,
|
|
43
45
|
_escape: () => _escape,
|
|
44
46
|
_escape_script: () => _escape_script,
|
|
@@ -50,6 +52,7 @@ __export(html_exports, {
|
|
|
50
52
|
_for_to: () => _for_to,
|
|
51
53
|
_for_until: () => _for_until,
|
|
52
54
|
_hoist: () => _hoist,
|
|
55
|
+
_hoist_read_error: () => _hoist_read_error,
|
|
53
56
|
_html: () => _html,
|
|
54
57
|
_id: () => _id,
|
|
55
58
|
_if: () => _if,
|
|
@@ -96,6 +99,14 @@ function* attrTagIterator() {
|
|
|
96
99
|
yield this, yield* this[rest];
|
|
97
100
|
}
|
|
98
101
|
|
|
102
|
+
// src/common/errors.ts
|
|
103
|
+
function _el_read_error() {
|
|
104
|
+
}
|
|
105
|
+
function _hoist_read_error() {
|
|
106
|
+
}
|
|
107
|
+
function _assert_hoist(value) {
|
|
108
|
+
}
|
|
109
|
+
|
|
99
110
|
// src/common/helpers.ts
|
|
100
111
|
function classValue(classValue2) {
|
|
101
112
|
return toDelimitedString(classValue2, " ", stringifyClassObject);
|
|
@@ -1192,14 +1203,11 @@ function _sep(shouldResume) {
|
|
|
1192
1203
|
return shouldResume === 0 ? "" : "<!>";
|
|
1193
1204
|
}
|
|
1194
1205
|
function _el(scopeId, id) {
|
|
1195
|
-
|
|
1196
|
-
};
|
|
1197
|
-
return id ? _resume(getter, id, scopeId) : getter;
|
|
1206
|
+
return _resume(() => void 0, id, scopeId);
|
|
1198
1207
|
}
|
|
1199
1208
|
function _hoist(scopeId, id) {
|
|
1200
|
-
let getter = () =>
|
|
1201
|
-
|
|
1202
|
-
return getter[Symbol.iterator] = getter, id ? _resume(getter, id, scopeId) : getter;
|
|
1209
|
+
let getter = () => void 0;
|
|
1210
|
+
return getter[Symbol.iterator] = _hoist_read_error, _resume(getter, id, scopeId);
|
|
1203
1211
|
}
|
|
1204
1212
|
function _resume_branch(scopeId) {
|
|
1205
1213
|
let branchId = $chunk.context?.[branchIdKey];
|
|
@@ -2246,6 +2254,7 @@ function NOOP3() {
|
|
|
2246
2254
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2247
2255
|
0 && (module.exports = {
|
|
2248
2256
|
$global,
|
|
2257
|
+
_assert_hoist,
|
|
2249
2258
|
_attr,
|
|
2250
2259
|
_attr_class,
|
|
2251
2260
|
_attr_content,
|
|
@@ -2267,6 +2276,7 @@ function NOOP3() {
|
|
|
2267
2276
|
_content_resume,
|
|
2268
2277
|
_dynamic_tag,
|
|
2269
2278
|
_el,
|
|
2279
|
+
_el_read_error,
|
|
2270
2280
|
_el_resume,
|
|
2271
2281
|
_escape,
|
|
2272
2282
|
_escape_script,
|
|
@@ -2278,6 +2288,7 @@ function NOOP3() {
|
|
|
2278
2288
|
_for_to,
|
|
2279
2289
|
_for_until,
|
|
2280
2290
|
_hoist,
|
|
2291
|
+
_hoist_read_error,
|
|
2281
2292
|
_html,
|
|
2282
2293
|
_id,
|
|
2283
2294
|
_if,
|
package/dist/html.mjs
CHANGED
|
@@ -10,6 +10,14 @@ function* attrTagIterator() {
|
|
|
10
10
|
yield this, yield* this[rest];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// src/common/errors.ts
|
|
14
|
+
function _el_read_error() {
|
|
15
|
+
}
|
|
16
|
+
function _hoist_read_error() {
|
|
17
|
+
}
|
|
18
|
+
function _assert_hoist(value) {
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
// src/common/helpers.ts
|
|
14
22
|
function classValue(classValue2) {
|
|
15
23
|
return toDelimitedString(classValue2, " ", stringifyClassObject);
|
|
@@ -1106,14 +1114,11 @@ function _sep(shouldResume) {
|
|
|
1106
1114
|
return shouldResume === 0 ? "" : "<!>";
|
|
1107
1115
|
}
|
|
1108
1116
|
function _el(scopeId, id) {
|
|
1109
|
-
|
|
1110
|
-
};
|
|
1111
|
-
return id ? _resume(getter, id, scopeId) : getter;
|
|
1117
|
+
return _resume(() => void 0, id, scopeId);
|
|
1112
1118
|
}
|
|
1113
1119
|
function _hoist(scopeId, id) {
|
|
1114
|
-
let getter = () =>
|
|
1115
|
-
|
|
1116
|
-
return getter[Symbol.iterator] = getter, id ? _resume(getter, id, scopeId) : getter;
|
|
1120
|
+
let getter = () => void 0;
|
|
1121
|
+
return getter[Symbol.iterator] = _hoist_read_error, _resume(getter, id, scopeId);
|
|
1117
1122
|
}
|
|
1118
1123
|
function _resume_branch(scopeId) {
|
|
1119
1124
|
let branchId = $chunk.context?.[branchIdKey];
|
|
@@ -2159,6 +2164,7 @@ function NOOP3() {
|
|
|
2159
2164
|
}
|
|
2160
2165
|
export {
|
|
2161
2166
|
$global,
|
|
2167
|
+
_assert_hoist,
|
|
2162
2168
|
_attr,
|
|
2163
2169
|
_attr_class,
|
|
2164
2170
|
_attr_content,
|
|
@@ -2180,6 +2186,7 @@ export {
|
|
|
2180
2186
|
_content_resume,
|
|
2181
2187
|
_dynamic_tag,
|
|
2182
2188
|
_el,
|
|
2189
|
+
_el_read_error,
|
|
2183
2190
|
_el_resume,
|
|
2184
2191
|
_escape,
|
|
2185
2192
|
_escape_script,
|
|
@@ -2191,6 +2198,7 @@ export {
|
|
|
2191
2198
|
_for_to,
|
|
2192
2199
|
_for_until,
|
|
2193
2200
|
_hoist,
|
|
2201
|
+
_hoist_read_error,
|
|
2194
2202
|
_html,
|
|
2195
2203
|
_id,
|
|
2196
2204
|
_if,
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { type Tag } from "@marko/compiler/babel-utils";
|
|
2
2
|
import { type Binding } from "../util/references";
|
|
3
3
|
declare const kNodeBinding: unique symbol;
|
|
4
|
-
declare const kGetterId: unique symbol;
|
|
5
4
|
declare module "@marko/compiler/dist/types" {
|
|
6
5
|
interface NodeExtra {
|
|
7
6
|
[kNodeBinding]?: Binding;
|
|
8
|
-
[kGetterId]?: string;
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
9
|
declare const _default: Tag;
|