marko 6.0.0-next.3.27 → 6.0.0-next.3.29
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/compat-meta.d.ts +1 -0
- package/dist/debug/dom.js +96 -63
- package/dist/debug/dom.mjs +96 -63
- package/dist/debug/html.js +107 -32
- package/dist/debug/html.mjs +106 -32
- package/dist/dom/compat.d.ts +2 -2
- package/dist/dom/dom.d.ts +2 -1
- package/dist/dom/parse-html.d.ts +4 -2
- package/dist/dom/renderer.d.ts +4 -4
- package/dist/dom.js +104 -81
- package/dist/dom.mjs +104 -81
- package/dist/html/compat.d.ts +1 -0
- package/dist/html/serializer.d.ts +2 -0
- package/dist/html.d.ts +1 -0
- package/dist/html.js +26 -17
- package/dist/html.mjs +25 -17
- package/dist/translator/index.js +56 -13
- package/dist/translator/util/references.d.ts +2 -1
- package/dist/translator/util/sections.d.ts +1 -0
- package/package.json +2 -2
package/dist/dom.mjs
CHANGED
@@ -143,17 +143,17 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
143
143
|
var registeredValues = {}, Render = class {
|
144
144
|
n = [];
|
145
145
|
o = {};
|
146
|
-
|
146
|
+
A = {
|
147
147
|
_: registeredValues
|
148
148
|
};
|
149
149
|
constructor(renders, runtimeId, renderId) {
|
150
|
-
this.
|
150
|
+
this.B = renders, this.C = runtimeId, this.p = renderId, this.q = renders[renderId], this.s();
|
151
151
|
}
|
152
152
|
w() {
|
153
153
|
this.q.w(), this.s();
|
154
154
|
}
|
155
155
|
s() {
|
156
|
-
let data2 = this.q, serializeContext = this.
|
156
|
+
let data2 = this.q, serializeContext = this.A, scopeLookup = this.o, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
157
157
|
if (visits.length) {
|
158
158
|
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
|
159
159
|
data2.v = [];
|
@@ -204,7 +204,7 @@ var registeredValues = {}, Render = class {
|
|
204
204
|
let resumeData = resumes[i++];
|
205
205
|
if (typeof resumeData == "function") {
|
206
206
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
207
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.
|
207
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.C, $global.renderId = this.p);
|
208
208
|
for (let scopeId in scopes)
|
209
209
|
if (scopeId !== "$") {
|
210
210
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -218,7 +218,7 @@ var registeredValues = {}, Render = class {
|
|
218
218
|
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.t = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch));
|
219
219
|
}
|
220
220
|
}
|
221
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.
|
221
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.B[this.p] : registeredValues[resumes[i++]](
|
222
222
|
scopeLookup[resumeData],
|
223
223
|
scopeLookup[resumeData]
|
224
224
|
);
|
@@ -256,7 +256,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
256
256
|
}
|
257
257
|
}
|
258
258
|
function registerSubscriber(id, signal) {
|
259
|
-
return register(id, signal.
|
259
|
+
return register(id, signal.D), signal;
|
260
260
|
}
|
261
261
|
function nodeRef(id, key) {
|
262
262
|
return register(id, (scope) => () => scope[key]);
|
@@ -435,22 +435,10 @@ function toValueProp(it) {
|
|
435
435
|
}
|
436
436
|
|
437
437
|
// src/dom/parse-html.ts
|
438
|
-
var
|
439
|
-
function parseHTML(html2) {
|
440
|
-
|
441
|
-
|
442
|
-
function parseHTMLOrSingleNode(html2) {
|
443
|
-
let content = parseHTML(html2);
|
444
|
-
if (content.firstChild) {
|
445
|
-
if (content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
|
446
|
-
// a single replaced node, in which case the walker can't replace
|
447
|
-
// the node itself.
|
448
|
-
content.firstChild.nodeType !== 8)
|
449
|
-
return content.firstChild;
|
450
|
-
let fragment = new DocumentFragment();
|
451
|
-
return fragment.appendChild(content), fragment;
|
452
|
-
}
|
453
|
-
return new Text();
|
438
|
+
var parsers = {};
|
439
|
+
function parseHTML(html2, ns) {
|
440
|
+
let parser = parsers[ns] ||= document.createElementNS(ns, "template"), content = (parser.innerHTML = html2, parser.content || parser);
|
441
|
+
return content.firstChild || content.appendChild(new Text()), content;
|
454
442
|
}
|
455
443
|
|
456
444
|
// src/dom/dom.ts
|
@@ -590,11 +578,16 @@ function attrsEvents(scope, nodeAccessor) {
|
|
590
578
|
on(el, name, events[name]);
|
591
579
|
}
|
592
580
|
function html(scope, value2, accessor) {
|
593
|
-
let firstChild = scope[accessor], lastChild = scope[accessor + "-" /* DynamicPlaceholderLastChild */] || firstChild, newContent = parseHTML(
|
594
|
-
value2 || value2 === 0 ? value2 + "" : "
|
595
|
-
|
581
|
+
let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope[accessor + "-" /* DynamicPlaceholderLastChild */] || firstChild, newContent = parseHTML(
|
582
|
+
value2 || value2 === 0 ? value2 + "" : "",
|
583
|
+
parentNode.namespaceURI
|
596
584
|
);
|
597
|
-
|
585
|
+
insertChildNodes(
|
586
|
+
parentNode,
|
587
|
+
firstChild,
|
588
|
+
scope[accessor] = newContent.firstChild,
|
589
|
+
scope[accessor + "-" /* DynamicPlaceholderLastChild */] = newContent.lastChild
|
590
|
+
), removeChildNodes(firstChild, lastChild);
|
598
591
|
}
|
599
592
|
function props(scope, nodeIndex, index) {
|
600
593
|
let nextProps = scope[index], prevProps = scope[index + "-"], node = scope[nodeIndex];
|
@@ -626,6 +619,18 @@ function removeChildNodes(startNode, endNode) {
|
|
626
619
|
current.remove(), current = next;
|
627
620
|
}
|
628
621
|
}
|
622
|
+
function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
|
623
|
+
parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
|
624
|
+
}
|
625
|
+
function toInsertNode(startNode, endNode) {
|
626
|
+
if (startNode === endNode) return startNode;
|
627
|
+
let parent = new DocumentFragment(), stop = endNode.nextSibling, current = startNode;
|
628
|
+
for (; current !== stop; ) {
|
629
|
+
let next = current.nextSibling;
|
630
|
+
parent.appendChild(current), current = next;
|
631
|
+
}
|
632
|
+
return parent;
|
633
|
+
}
|
629
634
|
|
630
635
|
// src/dom/scope.ts
|
631
636
|
var pendingScopes = [];
|
@@ -649,7 +654,7 @@ function destroyBranch(branch) {
|
|
649
654
|
branch.t?.k?.delete(branch), destroyNestedBranches(branch);
|
650
655
|
}
|
651
656
|
function destroyNestedBranches(branch) {
|
652
|
-
branch.
|
657
|
+
branch.E = 1, branch.k?.forEach(destroyNestedBranches), branch.F?.forEach((scope) => {
|
653
658
|
for (let id in scope.h)
|
654
659
|
scope.h[id]?.abort();
|
655
660
|
});
|
@@ -658,11 +663,12 @@ function removeAndDestroyBranch(branch) {
|
|
658
663
|
destroyBranch(branch), removeChildNodes(branch.a, branch.b);
|
659
664
|
}
|
660
665
|
function insertBranchBefore(branch, parentNode, nextSibling) {
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
+
insertChildNodes(
|
667
|
+
parentNode,
|
668
|
+
nextSibling,
|
669
|
+
branch.a,
|
670
|
+
branch.b
|
671
|
+
);
|
666
672
|
}
|
667
673
|
|
668
674
|
// src/dom/reconcile.ts
|
@@ -784,35 +790,35 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
|
|
784
790
|
}
|
785
791
|
|
786
792
|
// src/dom/renderer.ts
|
787
|
-
function createBranchScopeWithRenderer(renderer, $global, parentScope) {
|
793
|
+
function createBranchScopeWithRenderer(renderer, $global, parentScope, parentNode) {
|
788
794
|
let branch = createBranch(
|
789
795
|
$global,
|
790
796
|
renderer.u || parentScope,
|
791
797
|
parentScope
|
792
798
|
);
|
793
|
-
return initBranch(renderer, branch), branch;
|
799
|
+
return initBranch(renderer, branch, parentNode), branch;
|
794
800
|
}
|
795
|
-
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
|
801
|
+
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope, parentNode) {
|
796
802
|
if (typeof tagNameOrRenderer != "string")
|
797
803
|
return createBranchScopeWithRenderer(
|
798
804
|
tagNameOrRenderer,
|
799
805
|
$global,
|
800
|
-
parentScope
|
806
|
+
parentScope,
|
807
|
+
parentNode
|
801
808
|
);
|
802
809
|
let branch = createBranch($global, parentScope, parentScope);
|
803
|
-
return branch[0] = branch.a = branch.b = document.
|
810
|
+
return branch[0] = branch.a = branch.b = document.createElementNS(
|
811
|
+
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
812
|
+
tagNameOrRenderer
|
813
|
+
), branch;
|
804
814
|
}
|
805
815
|
function createBranch($global, ownerScope, parentScope) {
|
806
816
|
let branch = createScope($global), parentBranch = parentScope.c;
|
807
817
|
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.t = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
|
808
818
|
}
|
809
|
-
function initBranch(renderer, branch) {
|
810
|
-
let
|
811
|
-
|
812
|
-
dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
|
813
|
-
renderer.F,
|
814
|
-
branch
|
815
|
-
), branch.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, branch.b = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.x && queueRender(branch, renderer.x), dom;
|
819
|
+
function initBranch(renderer, branch, parentNode) {
|
820
|
+
let clone = renderer.l(parentNode.namespaceURI), cloneParent = clone.parentNode;
|
821
|
+
walk(cloneParent?.firstChild || clone, renderer.G, branch), branch.a = cloneParent?.firstChild || clone, branch.b = cloneParent?.lastChild || clone, renderer.x && queueRender(branch, renderer.x);
|
816
822
|
}
|
817
823
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
818
824
|
return (scope, attrsOrOp) => {
|
@@ -843,12 +849,12 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
|
843
849
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
844
850
|
return (owner) => ({
|
845
851
|
j: id,
|
846
|
-
|
847
|
-
|
852
|
+
y: template,
|
853
|
+
G: walks,
|
848
854
|
x: setup,
|
849
855
|
l: _clone,
|
850
856
|
u: owner,
|
851
|
-
|
857
|
+
J: void 0,
|
852
858
|
get d() {
|
853
859
|
return args ||= getArgs?.();
|
854
860
|
}
|
@@ -857,10 +863,16 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
|
857
863
|
function createRenderer(template, walks, setup, getArgs) {
|
858
864
|
return createRendererWithOwner(template, walks, setup, getArgs)();
|
859
865
|
}
|
860
|
-
function _clone() {
|
861
|
-
return (this.
|
862
|
-
this.
|
863
|
-
|
866
|
+
function _clone(ns) {
|
867
|
+
return ((cloneCache[ns] ||= {})[this.y] ||= createCloneableHTML(
|
868
|
+
this.y,
|
869
|
+
ns
|
870
|
+
))();
|
871
|
+
}
|
872
|
+
var cloneCache = {};
|
873
|
+
function createCloneableHTML(html2, ns) {
|
874
|
+
let { firstChild, lastChild } = parseHTML(html2, ns), parent = document.createElementNS(ns, "t");
|
875
|
+
return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? () => firstChild.cloneNode(!0) : () => parent.cloneNode(!0).firstChild;
|
864
876
|
}
|
865
877
|
|
866
878
|
// src/dom/control-flow.ts
|
@@ -880,7 +892,12 @@ var conditional = function(nodeAccessor, fn, getIntersection) {
|
|
880
892
|
};
|
881
893
|
};
|
882
894
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
883
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(
|
895
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(
|
896
|
+
newRenderer,
|
897
|
+
scope.$global,
|
898
|
+
scope,
|
899
|
+
prevBranch.b.parentNode
|
900
|
+
) : getEmptyBranch(scope[nodeAccessor]);
|
884
901
|
insertBranchBefore(
|
885
902
|
newBranch,
|
886
903
|
prevBranch.b.parentNode,
|
@@ -904,7 +921,12 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
904
921
|
};
|
905
922
|
};
|
906
923
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
907
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(
|
924
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(
|
925
|
+
newRenderer,
|
926
|
+
scope.$global,
|
927
|
+
scope,
|
928
|
+
referenceNode
|
929
|
+
) : void 0;
|
908
930
|
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
909
931
|
}
|
910
932
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
@@ -949,20 +971,16 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
949
971
|
params?.(branch, valueOrOp);
|
950
972
|
return;
|
951
973
|
}
|
952
|
-
let referenceNode = scope[nodeAccessor], referenceIsMarker = referenceNode.nodeType
|
953
|
-
|
974
|
+
let referenceNode = scope[nodeAccessor], referenceIsMarker = referenceNode.nodeType > 1 /* Element */, oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */] || (referenceIsMarker ? emptyMarkerMap : emptyMap), oldArray = scope[nodeAccessor + "!" /* LoopScopeArray */] || Array.from(oldMap.values()), parentNode = referenceIsMarker ? referenceNode.parentNode || oldArray[0].a.parentNode : referenceNode, newMap, newArray, afterReference, needsReconciliation = !0;
|
975
|
+
forEach(valueOrOp, (key, args) => {
|
954
976
|
let branch = oldMap.get(key);
|
955
|
-
branch || (branch = createBranchScopeWithRenderer(
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
afterReference = null, parentNode = referenceNode;
|
963
|
-
reconcile(parentNode, oldArray, newArray, afterReference);
|
964
|
-
}
|
965
|
-
scope[nodeAccessor + "(" /* LoopScopeMap */] = newMap, scope[nodeAccessor + "!" /* LoopScopeArray */] = newArray;
|
977
|
+
branch || (branch = createBranchScopeWithRenderer(
|
978
|
+
renderer,
|
979
|
+
scope.$global,
|
980
|
+
scope,
|
981
|
+
parentNode
|
982
|
+
)), params && params(branch, args), newMap ? (newMap.set(key, branch), newArray.push(branch)) : (newMap = /* @__PURE__ */ new Map([[key, branch]]), newArray = [branch]);
|
983
|
+
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyBranch(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation && (referenceIsMarker ? (oldMap === emptyMarkerMap && getEmptyBranch(referenceNode), afterReference = oldArray[oldArray.length - 1].b.nextSibling) : afterReference = null, reconcile(parentNode, oldArray, newArray, afterReference)), scope[nodeAccessor + "(" /* LoopScopeMap */] = newMap, scope[nodeAccessor + "!" /* LoopScopeArray */] = newArray;
|
966
984
|
};
|
967
985
|
}
|
968
986
|
function bySecondArg(_item, index) {
|
@@ -1038,7 +1056,7 @@ function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersectio
|
|
1038
1056
|
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1039
1057
|
});
|
1040
1058
|
};
|
1041
|
-
return helperSignal._ = setupSignal, helperSignal.
|
1059
|
+
return helperSignal._ = setupSignal, helperSignal.D = subscribe, helperSignal;
|
1042
1060
|
}
|
1043
1061
|
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1044
1062
|
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
@@ -1080,9 +1098,9 @@ function queueSource(scope, signal, value2) {
|
|
1080
1098
|
function queueRender(scope, signal, value2) {
|
1081
1099
|
let i = pendingRenders.length, render = {
|
1082
1100
|
m: scope,
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1101
|
+
H: signal,
|
1102
|
+
I: value2,
|
1103
|
+
z: i
|
1086
1104
|
};
|
1087
1105
|
for (pendingRenders.push(render); i; ) {
|
1088
1106
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
@@ -1135,12 +1153,12 @@ function runRenders() {
|
|
1135
1153
|
}
|
1136
1154
|
pendingRenders[i] = item;
|
1137
1155
|
}
|
1138
|
-
render.m.c?.
|
1156
|
+
render.m.c?.E || render.H(render.m, render.I);
|
1139
1157
|
}
|
1140
1158
|
finishPendingScopes();
|
1141
1159
|
}
|
1142
1160
|
function comparePendingRenders(a, b) {
|
1143
|
-
return getBranchDepth(a) - getBranchDepth(b) || a.
|
1161
|
+
return getBranchDepth(a) - getBranchDepth(b) || a.z - b.z;
|
1144
1162
|
}
|
1145
1163
|
function getBranchDepth(render) {
|
1146
1164
|
return render.m.c?.f || 0;
|
@@ -1152,23 +1170,23 @@ function resetAbortSignal(scope, id) {
|
|
1152
1170
|
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
1153
1171
|
}
|
1154
1172
|
function getAbortSignal(scope, id) {
|
1155
|
-
return scope.c && (scope.c.
|
1173
|
+
return scope.c && (scope.c.F ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
1156
1174
|
}
|
1157
1175
|
function abort(ctrl) {
|
1158
1176
|
ctrl.abort();
|
1159
1177
|
}
|
1160
1178
|
|
1161
1179
|
// src/common/compat-meta.ts
|
1162
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
|
1180
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
1163
1181
|
|
1164
1182
|
// src/dom/compat.ts
|
1165
1183
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1166
1184
|
patchConditionals,
|
1167
1185
|
queueEffect,
|
1168
|
-
init() {
|
1186
|
+
init(warp10Noop) {
|
1169
1187
|
register(SET_SCOPE_REGISTER_ID, (branch) => {
|
1170
1188
|
classIdToBranch.set(branch.m5c, branch);
|
1171
|
-
});
|
1189
|
+
}), register(RENDER_BODY_ID, warp10Noop);
|
1172
1190
|
},
|
1173
1191
|
registerRenderer(fn) {
|
1174
1192
|
register(RENDERER_REGISTER_ID, fn);
|
@@ -1214,9 +1232,9 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1214
1232
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1215
1233
|
}
|
1216
1234
|
if (component.effects = prepareEffects(() => {
|
1217
|
-
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.u, initBranch(renderer, branch)), applyArgs(branch, args);
|
1235
|
+
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.u, initBranch(renderer, branch, document.body)), applyArgs(branch, args);
|
1218
1236
|
}), !existing)
|
1219
|
-
return branch.a
|
1237
|
+
return toInsertNode(branch.a, branch.b);
|
1220
1238
|
}
|
1221
1239
|
};
|
1222
1240
|
function noop() {
|
@@ -1228,7 +1246,7 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
1228
1246
|
return renderer.mount = mount, renderer._ = renderer, register(templateId, renderer);
|
1229
1247
|
};
|
1230
1248
|
function mount(input = {}, reference, position) {
|
1231
|
-
let branch,
|
1249
|
+
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1232
1250
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1233
1251
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1234
1252
|
renderId: DEFAULT_RENDER_ID,
|
@@ -1248,9 +1266,14 @@ function mount(input = {}, reference, position) {
|
|
1248
1266
|
break;
|
1249
1267
|
}
|
1250
1268
|
let args = this.d, effects = prepareEffects(() => {
|
1251
|
-
branch = createScope($global),
|
1269
|
+
branch = createScope($global), initBranch(this, branch, parentNode), args?.(branch, [input]);
|
1252
1270
|
});
|
1253
|
-
return
|
1271
|
+
return insertChildNodes(
|
1272
|
+
parentNode,
|
1273
|
+
nextSibling,
|
1274
|
+
branch.a,
|
1275
|
+
branch.b
|
1276
|
+
), runEffects(effects), {
|
1254
1277
|
update: (newInput) => {
|
1255
1278
|
args && runEffects(
|
1256
1279
|
prepareEffects(() => {
|
package/dist/html/compat.d.ts
CHANGED
@@ -11,4 +11,5 @@ export declare const compat: {
|
|
11
11
|
toJSON(this: WeakKey): [registryId: string, scopeId: unknown] | undefined;
|
12
12
|
render(renderer: ServerRenderer, willRerender: boolean, classAPIOut: any, component: any, input: any): void;
|
13
13
|
registerRenderer(renderer: any, id: string): any;
|
14
|
+
registerRenderBody(fn: any): void;
|
14
15
|
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { Boundary } from "./writer";
|
2
|
+
export declare function debug(obj: WeakKey, file: string, loc: string | 0, vars?: Record<string, string>): WeakKey;
|
2
3
|
export declare class Serializer {
|
3
4
|
#private;
|
4
5
|
get flushed(): boolean;
|
@@ -12,3 +13,4 @@ export declare function getRegistered(val: WeakKey): {
|
|
12
13
|
scope: unknown;
|
13
14
|
} | undefined;
|
14
15
|
export declare function stringify(val: unknown): string;
|
16
|
+
export declare function toAccess(accessor: string): string;
|
package/dist/html.d.ts
CHANGED
@@ -5,5 +5,6 @@ export { compat } from "./html/compat";
|
|
5
5
|
export { escapeScript, escapeStyle, escapeXML, toString } from "./html/content";
|
6
6
|
export { createRenderer, dynamicTagArgs, dynamicTagInput, } from "./html/dynamic-tag";
|
7
7
|
export { forIn, forInBy, forOf, forOfBy, forTo, forToBy } from "./html/for";
|
8
|
+
export { debug } from "./html/serializer";
|
8
9
|
export { createTemplate } from "./html/template";
|
9
10
|
export { $global, ensureScopeWithId, fork, getScopeById, markResumeNode, nextScopeId, nextTagId, nodeRef, peekNextScope, register, resumeClosestBranch, resumeConditional, resumeForIn, resumeForOf, resumeForTo, resumeSingleNodeConditional, resumeSingleNodeForIn, resumeSingleNodeForOf, resumeSingleNodeForTo, tryContent, write, writeEffect, writeExistingScope, writeScope, writeTrailers, } from "./html/writer";
|
package/dist/html.js
CHANGED
@@ -32,6 +32,7 @@ __export(html_exports, {
|
|
32
32
|
controllable_textarea_value: () => controllable_textarea_value,
|
33
33
|
createRenderer: () => createRenderer,
|
34
34
|
createTemplate: () => createTemplate,
|
35
|
+
debug: () => debug,
|
35
36
|
dynamicTagArgs: () => dynamicTagArgs,
|
36
37
|
dynamicTagInput: () => dynamicTagInput,
|
37
38
|
ensureScopeWithId: () => ensureScopeWithId,
|
@@ -435,7 +436,11 @@ var { hasOwnProperty } = {}, Generator = function* () {
|
|
435
436
|
}
|
436
437
|
init = "";
|
437
438
|
assigns = "";
|
438
|
-
}
|
439
|
+
};
|
440
|
+
function debug(obj, file, loc, vars) {
|
441
|
+
return obj;
|
442
|
+
}
|
443
|
+
var Serializer = class {
|
439
444
|
#state = new State();
|
440
445
|
get flushed() {
|
441
446
|
return this.#state.flushed;
|
@@ -562,7 +567,7 @@ function writeSymbol(state, val, parent, accessor) {
|
|
562
567
|
function writeUnknownSymbol(state) {
|
563
568
|
return state.buf.push("Symbol()"), !0;
|
564
569
|
}
|
565
|
-
function writeNever() {
|
570
|
+
function writeNever(state, val, ref) {
|
566
571
|
return !1;
|
567
572
|
}
|
568
573
|
function writeNull(state) {
|
@@ -1618,7 +1623,7 @@ function escapeAttrValue(str) {
|
|
1618
1623
|
}
|
1619
1624
|
|
1620
1625
|
// src/common/compat-meta.ts
|
1621
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
|
1626
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
1622
1627
|
|
1623
1628
|
// src/common/meta.ts
|
1624
1629
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
@@ -1745,8 +1750,10 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1745
1750
|
let asyncOut = classAPIOut.beginAsync();
|
1746
1751
|
(boundary.onNext = () => {
|
1747
1752
|
boundary.done && (boundary.signal.aborted ? asyncOut.error(boundary.signal.reason) : queueMicrotask(() => {
|
1748
|
-
|
1749
|
-
|
1753
|
+
if (head = prepareChunk(head), boundary.done) {
|
1754
|
+
let { scripts, html } = head;
|
1755
|
+
asyncOut.script(scripts), asyncOut.write(html), asyncOut.end(), head.html = head.scripts = "";
|
1756
|
+
}
|
1750
1757
|
}));
|
1751
1758
|
})();
|
1752
1759
|
},
|
@@ -1757,6 +1764,9 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1757
1764
|
register(id, () => {
|
1758
1765
|
})
|
1759
1766
|
);
|
1767
|
+
},
|
1768
|
+
registerRenderBody(fn) {
|
1769
|
+
register(RENDER_BODY_ID, fn);
|
1760
1770
|
}
|
1761
1771
|
};
|
1762
1772
|
|
@@ -1805,16 +1815,17 @@ var ServerRenderResult = class {
|
|
1805
1815
|
aborted = !0, reason = err, reject && reject(err);
|
1806
1816
|
},
|
1807
1817
|
() => {
|
1808
|
-
done = !0, resolve && resolve({ value, done: !value });
|
1818
|
+
done = !0, resolve && (resolve({ value, done: !value }), value = "");
|
1809
1819
|
}
|
1810
1820
|
);
|
1811
1821
|
return {
|
1812
1822
|
next() {
|
1823
|
+
if (aborted)
|
1824
|
+
return Promise.reject(reason);
|
1813
1825
|
if (value) {
|
1814
1826
|
let result = { value, done: !1 };
|
1815
1827
|
return value = "", Promise.resolve(result);
|
1816
|
-
}
|
1817
|
-
return done ? Promise.resolve({ value: "", done }) : aborted ? Promise.reject(reason) : new Promise(exec);
|
1828
|
+
} else return done ? Promise.resolve({ value: "", done }) : new Promise(exec);
|
1818
1829
|
},
|
1819
1830
|
throw(error) {
|
1820
1831
|
return done || aborted || boundary?.abort(error), Promise.resolve({
|
@@ -1881,7 +1892,7 @@ var ServerRenderResult = class {
|
|
1881
1892
|
return reject(new Error("Cannot read from a consumed render result"));
|
1882
1893
|
let { boundary } = head;
|
1883
1894
|
(boundary.onNext = () => {
|
1884
|
-
boundary.
|
1895
|
+
boundary.signal.aborted ? (boundary.onNext = NOOP2, reject(boundary.signal.reason)) : boundary.done && (head = prepareChunk(head), boundary.done && resolve(flushChunk(head, !0)));
|
1885
1896
|
})();
|
1886
1897
|
});
|
1887
1898
|
}
|
@@ -1892,14 +1903,9 @@ var ServerRenderResult = class {
|
|
1892
1903
|
return;
|
1893
1904
|
}
|
1894
1905
|
let { boundary } = head, onNext = boundary.onNext = (write2) => {
|
1895
|
-
if (
|
1896
|
-
|
1897
|
-
|
1898
|
-
return;
|
1899
|
-
}
|
1900
|
-
head = prepareChunk(head);
|
1901
|
-
}
|
1902
|
-
if (write2 || boundary.done) {
|
1906
|
+
if (boundary.signal.aborted)
|
1907
|
+
tick2 || offTick(onNext), boundary.onNext = NOOP2, onAbort(boundary.signal.reason);
|
1908
|
+
else if ((write2 || boundary.done) && (head = prepareChunk(head)), write2 || boundary.done) {
|
1903
1909
|
let html = flushChunk(head, boundary.done);
|
1904
1910
|
html && onWrite(html), boundary.done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
|
1905
1911
|
} else tick2 && (tick2 = !1, queueTick(onNext));
|
@@ -1913,6 +1919,8 @@ var ServerRenderResult = class {
|
|
1913
1919
|
return this.#head = null, flushChunk(prepareChunk(head), !0);
|
1914
1920
|
}
|
1915
1921
|
};
|
1922
|
+
function NOOP2() {
|
1923
|
+
}
|
1916
1924
|
// Annotate the CommonJS export names for ESM import in node:
|
1917
1925
|
0 && (module.exports = {
|
1918
1926
|
$global,
|
@@ -1930,6 +1938,7 @@ var ServerRenderResult = class {
|
|
1930
1938
|
controllable_textarea_value,
|
1931
1939
|
createRenderer,
|
1932
1940
|
createTemplate,
|
1941
|
+
debug,
|
1933
1942
|
dynamicTagArgs,
|
1934
1943
|
dynamicTagInput,
|
1935
1944
|
ensureScopeWithId,
|
package/dist/html.mjs
CHANGED
@@ -358,7 +358,11 @@ var { hasOwnProperty } = {}, Generator = function* () {
|
|
358
358
|
}
|
359
359
|
init = "";
|
360
360
|
assigns = "";
|
361
|
-
}
|
361
|
+
};
|
362
|
+
function debug(obj, file, loc, vars) {
|
363
|
+
return obj;
|
364
|
+
}
|
365
|
+
var Serializer = class {
|
362
366
|
#state = new State();
|
363
367
|
get flushed() {
|
364
368
|
return this.#state.flushed;
|
@@ -485,7 +489,7 @@ function writeSymbol(state, val, parent, accessor) {
|
|
485
489
|
function writeUnknownSymbol(state) {
|
486
490
|
return state.buf.push("Symbol()"), !0;
|
487
491
|
}
|
488
|
-
function writeNever() {
|
492
|
+
function writeNever(state, val, ref) {
|
489
493
|
return !1;
|
490
494
|
}
|
491
495
|
function writeNull(state) {
|
@@ -1541,7 +1545,7 @@ function escapeAttrValue(str) {
|
|
1541
1545
|
}
|
1542
1546
|
|
1543
1547
|
// src/common/compat-meta.ts
|
1544
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
|
1548
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
1545
1549
|
|
1546
1550
|
// src/common/meta.ts
|
1547
1551
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
@@ -1668,8 +1672,10 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1668
1672
|
let asyncOut = classAPIOut.beginAsync();
|
1669
1673
|
(boundary.onNext = () => {
|
1670
1674
|
boundary.done && (boundary.signal.aborted ? asyncOut.error(boundary.signal.reason) : queueMicrotask(() => {
|
1671
|
-
|
1672
|
-
|
1675
|
+
if (head = prepareChunk(head), boundary.done) {
|
1676
|
+
let { scripts, html } = head;
|
1677
|
+
asyncOut.script(scripts), asyncOut.write(html), asyncOut.end(), head.html = head.scripts = "";
|
1678
|
+
}
|
1673
1679
|
}));
|
1674
1680
|
})();
|
1675
1681
|
},
|
@@ -1680,6 +1686,9 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1680
1686
|
register(id, () => {
|
1681
1687
|
})
|
1682
1688
|
);
|
1689
|
+
},
|
1690
|
+
registerRenderBody(fn) {
|
1691
|
+
register(RENDER_BODY_ID, fn);
|
1683
1692
|
}
|
1684
1693
|
};
|
1685
1694
|
|
@@ -1728,16 +1737,17 @@ var ServerRenderResult = class {
|
|
1728
1737
|
aborted = !0, reason = err, reject && reject(err);
|
1729
1738
|
},
|
1730
1739
|
() => {
|
1731
|
-
done = !0, resolve && resolve({ value, done: !value });
|
1740
|
+
done = !0, resolve && (resolve({ value, done: !value }), value = "");
|
1732
1741
|
}
|
1733
1742
|
);
|
1734
1743
|
return {
|
1735
1744
|
next() {
|
1745
|
+
if (aborted)
|
1746
|
+
return Promise.reject(reason);
|
1736
1747
|
if (value) {
|
1737
1748
|
let result = { value, done: !1 };
|
1738
1749
|
return value = "", Promise.resolve(result);
|
1739
|
-
}
|
1740
|
-
return done ? Promise.resolve({ value: "", done }) : aborted ? Promise.reject(reason) : new Promise(exec);
|
1750
|
+
} else return done ? Promise.resolve({ value: "", done }) : new Promise(exec);
|
1741
1751
|
},
|
1742
1752
|
throw(error) {
|
1743
1753
|
return done || aborted || boundary?.abort(error), Promise.resolve({
|
@@ -1804,7 +1814,7 @@ var ServerRenderResult = class {
|
|
1804
1814
|
return reject(new Error("Cannot read from a consumed render result"));
|
1805
1815
|
let { boundary } = head;
|
1806
1816
|
(boundary.onNext = () => {
|
1807
|
-
boundary.
|
1817
|
+
boundary.signal.aborted ? (boundary.onNext = NOOP2, reject(boundary.signal.reason)) : boundary.done && (head = prepareChunk(head), boundary.done && resolve(flushChunk(head, !0)));
|
1808
1818
|
})();
|
1809
1819
|
});
|
1810
1820
|
}
|
@@ -1815,14 +1825,9 @@ var ServerRenderResult = class {
|
|
1815
1825
|
return;
|
1816
1826
|
}
|
1817
1827
|
let { boundary } = head, onNext = boundary.onNext = (write2) => {
|
1818
|
-
if (
|
1819
|
-
|
1820
|
-
|
1821
|
-
return;
|
1822
|
-
}
|
1823
|
-
head = prepareChunk(head);
|
1824
|
-
}
|
1825
|
-
if (write2 || boundary.done) {
|
1828
|
+
if (boundary.signal.aborted)
|
1829
|
+
tick2 || offTick(onNext), boundary.onNext = NOOP2, onAbort(boundary.signal.reason);
|
1830
|
+
else if ((write2 || boundary.done) && (head = prepareChunk(head)), write2 || boundary.done) {
|
1826
1831
|
let html = flushChunk(head, boundary.done);
|
1827
1832
|
html && onWrite(html), boundary.done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
|
1828
1833
|
} else tick2 && (tick2 = !1, queueTick(onNext));
|
@@ -1836,6 +1841,8 @@ var ServerRenderResult = class {
|
|
1836
1841
|
return this.#head = null, flushChunk(prepareChunk(head), !0);
|
1837
1842
|
}
|
1838
1843
|
};
|
1844
|
+
function NOOP2() {
|
1845
|
+
}
|
1839
1846
|
export {
|
1840
1847
|
$global,
|
1841
1848
|
attr,
|
@@ -1852,6 +1859,7 @@ export {
|
|
1852
1859
|
controllable_textarea_value,
|
1853
1860
|
createRenderer,
|
1854
1861
|
createTemplate,
|
1862
|
+
debug,
|
1855
1863
|
dynamicTagArgs,
|
1856
1864
|
dynamicTagInput,
|
1857
1865
|
ensureScopeWithId,
|