marko 6.0.0-next.3.37 → 6.0.0-next.3.39
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 +180 -168
- package/dist/debug/dom.mjs +180 -168
- package/dist/dom/compat.d.ts +2 -2
- package/dist/dom/control-flow.d.ts +4 -5
- package/dist/dom/queue.d.ts +2 -2
- package/dist/dom/resume.d.ts +0 -1
- package/dist/dom/scope.d.ts +1 -1
- package/dist/dom/signals.d.ts +14 -7
- package/dist/dom.d.ts +3 -3
- package/dist/dom.js +154 -138
- package/dist/dom.mjs +154 -138
- package/dist/translator/core/for.d.ts +0 -9
- package/dist/translator/core/if.d.ts +0 -8
- package/dist/translator/index.js +580 -574
- package/dist/translator/util/is-only-child-in-parent.d.ts +14 -0
- package/dist/translator/util/signals.d.ts +2 -3
- package/package.json +1 -1
package/dist/dom.mjs
CHANGED
@@ -28,23 +28,6 @@ function forTo(to, from, step, cb) {
|
|
28
28
|
cb(start + i * delta);
|
29
29
|
}
|
30
30
|
|
31
|
-
// src/dom/schedule.ts
|
32
|
-
var port2 = /* @__PURE__ */ (() => {
|
33
|
-
let { port1, port2: port22 } = new MessageChannel();
|
34
|
-
return port1.onmessage = () => {
|
35
|
-
isScheduled = !1, run();
|
36
|
-
}, port22;
|
37
|
-
})(), isScheduled;
|
38
|
-
function schedule() {
|
39
|
-
isScheduled || (isScheduled = !0, queueMicrotask(flushAndWaitFrame));
|
40
|
-
}
|
41
|
-
function flushAndWaitFrame() {
|
42
|
-
run(), requestAnimationFrame(triggerMacroTask);
|
43
|
-
}
|
44
|
-
function triggerMacroTask() {
|
45
|
-
port2.postMessage(0);
|
46
|
-
}
|
47
|
-
|
48
31
|
// src/common/helpers.ts
|
49
32
|
function classValue(value2) {
|
50
33
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -141,19 +124,19 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
141
124
|
|
142
125
|
// src/dom/resume.ts
|
143
126
|
var registeredValues = {}, Render = class {
|
144
|
-
|
145
|
-
|
146
|
-
|
127
|
+
l = [];
|
128
|
+
m = {};
|
129
|
+
C = {
|
147
130
|
_: registeredValues
|
148
131
|
};
|
149
132
|
constructor(renders, runtimeId, renderId) {
|
150
|
-
this.
|
133
|
+
this.D = renders, this.E = runtimeId, this.n = renderId, this.o = renders[renderId], this.p();
|
151
134
|
}
|
152
135
|
w() {
|
153
|
-
this.
|
136
|
+
this.o.w(), this.p();
|
154
137
|
}
|
155
|
-
|
156
|
-
let data2 = this.
|
138
|
+
p() {
|
139
|
+
let data2 = this.o, serializeContext = this.C, scopeLookup = this.m, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
157
140
|
if (visits.length) {
|
158
141
|
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
|
159
142
|
data2.v = [];
|
@@ -175,7 +158,7 @@ var registeredValues = {}, Render = class {
|
|
175
158
|
else if (token === "$" /* ClosestBranch */)
|
176
159
|
closestBranchMarkers.set(scopeId, visit);
|
177
160
|
else if (token === "[" /* BranchStart */)
|
178
|
-
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.
|
161
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.l.push(this.e)), this.e = scopeId, scope.a = visit;
|
179
162
|
else if (token === "]" /* BranchEnd */) {
|
180
163
|
scope[data3] = visit;
|
181
164
|
let curParent = visit.parentNode, startNode = branchEnd(
|
@@ -183,7 +166,7 @@ var registeredValues = {}, Render = class {
|
|
183
166
|
visit,
|
184
167
|
visit
|
185
168
|
).a;
|
186
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.
|
169
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.l.pop();
|
187
170
|
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
188
171
|
let next = data3.indexOf(" "), curNode = visit;
|
189
172
|
for (scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
@@ -204,7 +187,7 @@ var registeredValues = {}, Render = class {
|
|
204
187
|
let resumeData = resumes[i++];
|
205
188
|
if (typeof resumeData == "function") {
|
206
189
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
207
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.
|
190
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.E, $global.renderId = this.n);
|
208
191
|
for (let scopeId in scopes)
|
209
192
|
if (scopeId !== "$") {
|
210
193
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -215,10 +198,10 @@ var registeredValues = {}, Render = class {
|
|
215
198
|
let parentBranchId = parentBranchIds.get(scopeId);
|
216
199
|
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
217
200
|
let branch = scope, parentBranch = branch.c;
|
218
|
-
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.
|
201
|
+
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.q = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch));
|
219
202
|
}
|
220
203
|
}
|
221
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.
|
204
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.D[this.n] : registeredValues[resumes[i++]](
|
222
205
|
scopeLookup[resumeData],
|
223
206
|
scopeLookup[resumeData]
|
224
207
|
);
|
@@ -255,9 +238,6 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
255
238
|
});
|
256
239
|
}
|
257
240
|
}
|
258
|
-
function registerSubscriber(id, signal) {
|
259
|
-
return register(id, signal.D), signal;
|
260
|
-
}
|
261
241
|
function nodeRef(id, key) {
|
262
242
|
return register(id, (scope) => () => scope[key]);
|
263
243
|
}
|
@@ -640,9 +620,10 @@ function toInsertNode(startNode, endNode) {
|
|
640
620
|
|
641
621
|
// src/dom/scope.ts
|
642
622
|
var pendingScopes = [];
|
643
|
-
function createScope($global) {
|
623
|
+
function createScope($global, closestBranch) {
|
644
624
|
let scope = {
|
645
625
|
g: 1,
|
626
|
+
c: closestBranch,
|
646
627
|
$global
|
647
628
|
};
|
648
629
|
return pendingScopes.push(scope), scope;
|
@@ -657,10 +638,10 @@ function getEmptyBranch(marker) {
|
|
657
638
|
return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
|
658
639
|
}
|
659
640
|
function destroyBranch(branch) {
|
660
|
-
branch.
|
641
|
+
branch.q?.j?.delete(branch), destroyNestedBranches(branch);
|
661
642
|
}
|
662
643
|
function destroyNestedBranches(branch) {
|
663
|
-
branch.
|
644
|
+
branch.F = 1, branch.j?.forEach(destroyNestedBranches), branch.G?.forEach((scope) => {
|
664
645
|
for (let id in scope.h)
|
665
646
|
scope.h[id]?.abort();
|
666
647
|
});
|
@@ -762,9 +743,9 @@ function trimWalkString(walkString) {
|
|
762
743
|
return walkString.slice(0, end + 1);
|
763
744
|
}
|
764
745
|
function walk(startNode, walkCodes, branch) {
|
765
|
-
walker.currentNode = startNode, walkInternal(walkCodes, branch
|
746
|
+
walker.currentNode = startNode, walkInternal(0, walkCodes, branch), walker.currentNode = document;
|
766
747
|
}
|
767
|
-
function walkInternal(walkCodes, scope
|
748
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
768
749
|
let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
769
750
|
for (; value2 = walkCodes.charCodeAt(currentWalkIndex++); )
|
770
751
|
if (currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 >= 117 /* Multiplier */)
|
@@ -779,10 +760,13 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
|
|
779
760
|
else if (value2 >= 67 /* Next */)
|
780
761
|
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
781
762
|
walker.nextNode();
|
782
|
-
else if (value2 === 47 /* BeginChild */)
|
783
|
-
|
784
|
-
|
785
|
-
|
763
|
+
else if (value2 === 47 /* BeginChild */)
|
764
|
+
currentWalkIndex = walkInternal(
|
765
|
+
currentWalkIndex,
|
766
|
+
walkCodes,
|
767
|
+
scope[currentScopeIndex++] = createScope(scope.$global, scope.c)
|
768
|
+
);
|
769
|
+
else {
|
786
770
|
if (value2 === 38 /* EndChild */)
|
787
771
|
return currentWalkIndex;
|
788
772
|
if (value2 === 32 /* Get */)
|
@@ -799,7 +783,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
|
|
799
783
|
function createBranchScopeWithRenderer(renderer, $global, parentScope, parentNode) {
|
800
784
|
let branch = createBranch(
|
801
785
|
$global,
|
802
|
-
renderer.
|
786
|
+
renderer.s || parentScope,
|
803
787
|
parentScope
|
804
788
|
);
|
805
789
|
return initBranch(renderer, branch, parentNode), branch;
|
@@ -820,11 +804,11 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
820
804
|
}
|
821
805
|
function createBranch($global, ownerScope, parentScope) {
|
822
806
|
let branch = createScope($global), parentBranch = parentScope.c;
|
823
|
-
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.
|
807
|
+
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.q = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
|
824
808
|
}
|
825
809
|
function initBranch(renderer, branch, parentNode) {
|
826
|
-
let clone = renderer.
|
827
|
-
walk(cloneParent
|
810
|
+
let clone = renderer.k(parentNode.namespaceURI), cloneParent = clone.parentNode;
|
811
|
+
cloneParent ? (walk(cloneParent.firstChild, renderer.t, branch), branch.a = cloneParent.firstChild, branch.b = cloneParent.lastChild) : (walk(clone, renderer.t, branch), branch.a = branch.b = clone), renderer.u && queueRender(branch, renderer.u);
|
828
812
|
}
|
829
813
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
830
814
|
return (scope, attrsOrOp) => {
|
@@ -836,7 +820,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
836
820
|
return renderer.d?.(childScope, attrsOrOp);
|
837
821
|
let content = getContent?.(scope);
|
838
822
|
if (typeof renderer == "string")
|
839
|
-
setConditionalRendererOnlyChild(
|
823
|
+
setConditionalRendererOnlyChild(
|
824
|
+
childScope,
|
825
|
+
0,
|
826
|
+
content,
|
827
|
+
createBranchScopeWithTagNameOrRenderer
|
828
|
+
), attrs(childScope, 0, attrsOrOp());
|
840
829
|
else if (renderer.d) {
|
841
830
|
let attributes = attrsOrOp();
|
842
831
|
renderer.d(
|
@@ -854,12 +843,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
854
843
|
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
855
844
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
856
845
|
return (owner) => ({
|
857
|
-
|
846
|
+
x: id,
|
858
847
|
y: template,
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
848
|
+
t: walks,
|
849
|
+
u: setup,
|
850
|
+
k: _clone,
|
851
|
+
s: owner,
|
863
852
|
get d() {
|
864
853
|
return args ||= getArgs?.();
|
865
854
|
}
|
@@ -881,57 +870,52 @@ function createCloneableHTML(html2, ns) {
|
|
881
870
|
}
|
882
871
|
|
883
872
|
// src/dom/control-flow.ts
|
884
|
-
function
|
885
|
-
|
873
|
+
function conditional(nodeAccessor, ...branches) {
|
874
|
+
let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
875
|
+
return (scope, newBranchIndexOrOp) => {
|
876
|
+
newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN && (scope[nodeAccessor].nodeType > 1 /* Element */ ? setConditionalRenderer : setConditionalRendererOnlyChild)(
|
877
|
+
scope,
|
878
|
+
nodeAccessor,
|
879
|
+
branches[scope[branchAccessor] = newBranchIndexOrOp],
|
880
|
+
createBranchScopeWithRenderer
|
881
|
+
);
|
882
|
+
};
|
886
883
|
}
|
887
|
-
|
884
|
+
function patchDynamicTag(fn) {
|
885
|
+
dynamicTag = fn(dynamicTag);
|
886
|
+
}
|
887
|
+
var dynamicTag = function(nodeAccessor, fn, getIntersection) {
|
888
888
|
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
889
889
|
return (scope, newRendererOrOp) => {
|
890
890
|
if (newRendererOrOp === DIRTY) return;
|
891
891
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
892
892
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
893
893
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
894
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(
|
894
|
+
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(
|
895
|
+
scope,
|
896
|
+
nodeAccessor,
|
897
|
+
normalizedRenderer,
|
898
|
+
createBranchScopeWithTagNameOrRenderer
|
899
|
+
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
895
900
|
}
|
896
901
|
intersection2?.(scope, op);
|
897
902
|
};
|
898
903
|
};
|
899
|
-
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
900
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ?
|
904
|
+
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
905
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranch2(
|
901
906
|
newRenderer,
|
902
907
|
scope.$global,
|
903
908
|
scope,
|
904
909
|
prevBranch.b.parentNode
|
905
910
|
) : getEmptyBranch(scope[nodeAccessor]);
|
906
|
-
insertBranchBefore(
|
911
|
+
prevBranch !== newBranch && (insertBranchBefore(
|
907
912
|
newBranch,
|
908
913
|
prevBranch.b.parentNode,
|
909
914
|
prevBranch.b.nextSibling
|
910
|
-
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
915
|
+
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch);
|
911
916
|
}
|
912
|
-
|
913
|
-
let
|
914
|
-
return (scope, newRendererOrOp) => {
|
915
|
-
if (newRendererOrOp === DIRTY) return;
|
916
|
-
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
917
|
-
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
918
|
-
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
919
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (currentRenderer = scope[rendererAccessor] = normalizedRenderer, setConditionalRendererOnlyChild(
|
920
|
-
scope,
|
921
|
-
nodeAccessor,
|
922
|
-
normalizedRenderer
|
923
|
-
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
924
|
-
}
|
925
|
-
intersection2?.(scope, op);
|
926
|
-
};
|
927
|
-
};
|
928
|
-
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
929
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranchScopeWithTagNameOrRenderer(
|
930
|
-
newRenderer,
|
931
|
-
scope.$global,
|
932
|
-
scope,
|
933
|
-
referenceNode
|
934
|
-
);
|
917
|
+
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer, createBranch2) {
|
918
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranch2(newRenderer, scope.$global, scope, referenceNode);
|
935
919
|
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
936
920
|
}
|
937
921
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
@@ -995,7 +979,24 @@ function byFirstArg(name) {
|
|
995
979
|
return name;
|
996
980
|
}
|
997
981
|
function isDifferentRenderer(a, b) {
|
998
|
-
return a !== b && (a?.
|
982
|
+
return a !== b && (a?.x || 0) !== b?.x;
|
983
|
+
}
|
984
|
+
|
985
|
+
// src/dom/schedule.ts
|
986
|
+
var port2 = /* @__PURE__ */ (() => {
|
987
|
+
let { port1, port2: port22 } = new MessageChannel();
|
988
|
+
return port1.onmessage = () => {
|
989
|
+
isScheduled = !1, run();
|
990
|
+
}, port22;
|
991
|
+
})(), isScheduled;
|
992
|
+
function schedule() {
|
993
|
+
isScheduled || (isScheduled = !0, queueMicrotask(flushAndWaitFrame));
|
994
|
+
}
|
995
|
+
function flushAndWaitFrame() {
|
996
|
+
run(), requestAnimationFrame(triggerMacroTask);
|
997
|
+
}
|
998
|
+
function triggerMacroTask() {
|
999
|
+
port2.postMessage(0);
|
999
1000
|
}
|
1000
1001
|
|
1001
1002
|
// src/dom/signals.ts
|
@@ -1005,63 +1006,81 @@ function state(valueAccessor, fn, getIntersection) {
|
|
1005
1006
|
return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
|
1006
1007
|
scope,
|
1007
1008
|
valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
1008
|
-
) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : queueSource(scope, valueSignal, valueOrOp), valueOrOp);
|
1009
|
+
) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : (schedule(), queueSource(scope, valueSignal, valueOrOp)), valueOrOp);
|
1009
1010
|
}
|
1010
1011
|
function value(valueAccessor, fn, getIntersection) {
|
1011
|
-
let markAccessor = valueAccessor + "#" /* Mark */, intersection2
|
1012
|
+
let markAccessor = valueAccessor + "#" /* Mark */, intersection2;
|
1012
1013
|
return (scope, valueOrOp) => {
|
1013
1014
|
if (valueOrOp === MARK)
|
1014
|
-
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2
|
1015
|
+
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && getIntersection && (intersection2 ||= getIntersection())(scope, MARK);
|
1015
1016
|
else if (valueOrOp !== DIRTY) {
|
1016
1017
|
let existing = scope[markAccessor] !== void 0;
|
1017
|
-
(scope[markAccessor] ||= 1) === 1 && (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp ? intersection2
|
1018
|
+
(scope[markAccessor] ||= 1) === 1 && (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp ? getIntersection && (intersection2 ||= getIntersection())(scope, CLEAN) : (scope[valueAccessor] = valueOrOp, fn && fn(scope, valueOrOp), getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY))), scope[markAccessor]--;
|
1018
1019
|
}
|
1019
1020
|
};
|
1020
1021
|
}
|
1021
1022
|
var accessorId = 0;
|
1022
1023
|
function intersection(count, fn, getIntersection) {
|
1023
|
-
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2
|
1024
|
+
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2;
|
1024
1025
|
return (scope, op) => {
|
1025
|
-
op === MARK ? (scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2
|
1026
|
-
};
|
1027
|
-
}
|
1028
|
-
function closure(fn, getIntersection) {
|
1029
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1030
|
-
return (scope, valueOrOp) => {
|
1031
|
-
valueOrOp === MARK ? intersection2?.(scope, MARK) : (fn && fn(scope, valueOrOp), intersection2?.(scope, DIRTY));
|
1026
|
+
op === MARK ? (scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && getIntersection && (intersection2 ||= getIntersection())(scope, MARK) : scope[markAccessor] === void 0 ? (scope[markAccessor] = count - 1, scope[dirtyAccessor] = !0) : --scope[markAccessor] === 0 ? op === DIRTY || scope[dirtyAccessor] ? (scope[dirtyAccessor] = !1, fn(scope), getIntersection && (intersection2 ||= getIntersection())(scope, DIRTY)) : getIntersection && (intersection2 ||= getIntersection())(scope, CLEAN) : scope[dirtyAccessor] ||= op === DIRTY;
|
1032
1027
|
};
|
1033
1028
|
}
|
1034
|
-
function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
1035
|
-
let
|
1029
|
+
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn, getIntersection) {
|
1030
|
+
let childSignal = closure(valueAccessor, fn, getIntersection), loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */, loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */, ownerSignal = (ownerScope) => {
|
1036
1031
|
let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1037
1032
|
if (loopScopes !== emptyMarkerArray)
|
1038
1033
|
for (let scope of loopScopes)
|
1039
|
-
scope.g || queueSource(scope,
|
1034
|
+
scope.g || queueSource(scope, childSignal);
|
1040
1035
|
};
|
1041
|
-
return
|
1036
|
+
return ownerSignal._ = childSignal, ownerSignal;
|
1042
1037
|
}
|
1043
|
-
function conditionalClosure(ownerConditionalNodeAccessor,
|
1044
|
-
let
|
1045
|
-
let
|
1046
|
-
|
1038
|
+
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
1039
|
+
let childSignal = closure(valueAccessor, fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, ownerSignal = (scope) => {
|
1040
|
+
let ifScope = scope[scopeAccessor];
|
1041
|
+
ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, childSignal);
|
1047
1042
|
};
|
1048
|
-
return
|
1049
|
-
}
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1043
|
+
return ownerSignal._ = childSignal, ownerSignal;
|
1044
|
+
}
|
1045
|
+
function dynamicClosure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
1046
|
+
let subscribersAccessor = "?" /* Dynamic */ + accessorId++, childSignal = closure(
|
1047
|
+
valueAccessor,
|
1048
|
+
fn,
|
1049
|
+
getIntersection,
|
1050
|
+
getOwnerScope
|
1051
|
+
), ownerSignal = (ownerScope) => {
|
1052
|
+
let subscribers = ownerScope[subscribersAccessor];
|
1054
1053
|
if (subscribers)
|
1055
1054
|
for (let subscriber of subscribers)
|
1056
|
-
subscriber.g || queueSource(subscriber,
|
1057
|
-
}, setupSignal = (scope, value2) => {
|
1058
|
-
_signal(scope, value2), subscribe(scope);
|
1055
|
+
subscriber.g || queueSource(subscriber, childSignal);
|
1059
1056
|
}, subscribe = (scope) => {
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1057
|
+
let owner = getOwnerScope ? getOwnerScope(scope) : scope._, subscribers = owner[subscribersAccessor] ||= /* @__PURE__ */ new Set();
|
1058
|
+
subscribers.has(scope) || (subscribers.add(scope), getAbortSignal(scope, -1).addEventListener(
|
1059
|
+
"abort",
|
1060
|
+
() => owner[subscribersAccessor].delete(scope)
|
1061
|
+
));
|
1062
|
+
};
|
1063
|
+
return ownerSignal.H = subscribe, ownerSignal._ = (scope) => {
|
1064
|
+
childSignal(scope), subscribe(scope);
|
1065
|
+
}, ownerSignal;
|
1066
|
+
}
|
1067
|
+
function registerDynamicClosure(id, valueAccessor, fn, getIntersection, getOwnerScope) {
|
1068
|
+
let signal = dynamicClosure(
|
1069
|
+
valueAccessor,
|
1070
|
+
fn,
|
1071
|
+
getIntersection,
|
1072
|
+
getOwnerScope
|
1073
|
+
);
|
1074
|
+
return register(id, signal.H), signal;
|
1075
|
+
}
|
1076
|
+
function closure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
1077
|
+
let intersection2;
|
1078
|
+
return (scope, op) => {
|
1079
|
+
op || fn && fn(
|
1080
|
+
scope,
|
1081
|
+
(getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
|
1082
|
+
), getIntersection && (intersection2 ||= getIntersection())(scope, op ? MARK : DIRTY);
|
1063
1083
|
};
|
1064
|
-
return helperSignal._ = setupSignal, helperSignal.D = subscribe, helperSignal;
|
1065
1084
|
}
|
1066
1085
|
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1067
1086
|
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
@@ -1096,16 +1115,16 @@ function effect(id, fn) {
|
|
1096
1115
|
// src/dom/queue.ts
|
1097
1116
|
var pendingRenders = [], pendingEffects = [], rendering = !1;
|
1098
1117
|
function queueSource(scope, signal, value2) {
|
1099
|
-
schedule();
|
1100
1118
|
let prevRendering = rendering;
|
1101
|
-
|
1119
|
+
rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2);
|
1102
1120
|
}
|
1103
1121
|
function queueRender(scope, signal, value2) {
|
1104
1122
|
let i = pendingRenders.length, render = {
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1123
|
+
z: scope,
|
1124
|
+
I: signal,
|
1125
|
+
J: value2,
|
1126
|
+
A: scope.c?.f || 0,
|
1127
|
+
B: i
|
1109
1128
|
};
|
1110
1129
|
for (pendingRenders.push(render); i; ) {
|
1111
1130
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
@@ -1136,7 +1155,7 @@ function prepareEffects(fn) {
|
|
1136
1155
|
}
|
1137
1156
|
return preparedEffects;
|
1138
1157
|
}
|
1139
|
-
function runEffects(effects
|
1158
|
+
function runEffects(effects) {
|
1140
1159
|
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
1141
1160
|
let scope = effects[i], fn = effects[i + 1];
|
1142
1161
|
fn(scope, scope);
|
@@ -1158,15 +1177,12 @@ function runRenders() {
|
|
1158
1177
|
}
|
1159
1178
|
pendingRenders[i] = item;
|
1160
1179
|
}
|
1161
|
-
render.
|
1180
|
+
render.z.c?.F || render.I(render.z, render.J);
|
1162
1181
|
}
|
1163
1182
|
finishPendingScopes();
|
1164
1183
|
}
|
1165
1184
|
function comparePendingRenders(a, b) {
|
1166
|
-
return
|
1167
|
-
}
|
1168
|
-
function getBranchDepth(render) {
|
1169
|
-
return render.m.c?.f || 0;
|
1185
|
+
return a.A - b.A || a.B - b.B;
|
1170
1186
|
}
|
1171
1187
|
|
1172
1188
|
// src/dom/abort-signal.ts
|
@@ -1175,7 +1191,7 @@ function resetAbortSignal(scope, id) {
|
|
1175
1191
|
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
1176
1192
|
}
|
1177
1193
|
function getAbortSignal(scope, id) {
|
1178
|
-
return scope.c && (scope.c.
|
1194
|
+
return scope.c && (scope.c.G ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
1179
1195
|
}
|
1180
1196
|
function abort(ctrl) {
|
1181
1197
|
ctrl.abort();
|
@@ -1186,7 +1202,7 @@ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID =
|
|
1186
1202
|
|
1187
1203
|
// src/dom/compat.ts
|
1188
1204
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1189
|
-
patchConditionals,
|
1205
|
+
patchConditionals: patchDynamicTag,
|
1190
1206
|
queueEffect,
|
1191
1207
|
init(warp10Noop) {
|
1192
1208
|
register(SET_SCOPE_REGISTER_ID, (branch) => {
|
@@ -1200,7 +1216,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1200
1216
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
1201
1217
|
},
|
1202
1218
|
isRenderer(renderer) {
|
1203
|
-
return renderer.
|
1219
|
+
return renderer.k;
|
1204
1220
|
},
|
1205
1221
|
getStartNode(branch) {
|
1206
1222
|
return branch.a;
|
@@ -1220,12 +1236,12 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1220
1236
|
}) {
|
1221
1237
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1222
1238
|
value2[0],
|
1223
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1239
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.m[value2[1]]
|
1224
1240
|
) : value2;
|
1225
1241
|
},
|
1226
1242
|
createRenderer(setup, clone, args) {
|
1227
1243
|
let renderer = createRenderer("", 0, setup, args && (() => args));
|
1228
|
-
return renderer.
|
1244
|
+
return renderer.k = clone, renderer;
|
1229
1245
|
},
|
1230
1246
|
render(out, component, renderer, args) {
|
1231
1247
|
let branch = component.scope;
|
@@ -1237,7 +1253,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1237
1253
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1238
1254
|
}
|
1239
1255
|
if (component.effects = prepareEffects(() => {
|
1240
|
-
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.
|
1256
|
+
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.s, initBranch(renderer, branch, document.body)), applyArgs(branch, args);
|
1241
1257
|
}), !existing)
|
1242
1258
|
return toInsertNode(branch.a, branch.b);
|
1243
1259
|
}
|
@@ -1279,14 +1295,14 @@ function mount(input = {}, reference, position) {
|
|
1279
1295
|
branch.a,
|
1280
1296
|
branch.b
|
1281
1297
|
), runEffects(effects), {
|
1282
|
-
update
|
1298
|
+
update(newInput) {
|
1283
1299
|
args && runEffects(
|
1284
1300
|
prepareEffects(() => {
|
1285
1301
|
args(branch, MARK), args(branch, [newInput]);
|
1286
1302
|
})
|
1287
1303
|
);
|
1288
1304
|
},
|
1289
|
-
destroy
|
1305
|
+
destroy() {
|
1290
1306
|
removeAndDestroyBranch(branch);
|
1291
1307
|
}
|
1292
1308
|
};
|
@@ -1301,7 +1317,6 @@ export {
|
|
1301
1317
|
compat,
|
1302
1318
|
conditional,
|
1303
1319
|
conditionalClosure,
|
1304
|
-
conditionalOnlyChild,
|
1305
1320
|
controllable_detailsOrDialog_open,
|
1306
1321
|
controllable_detailsOrDialog_open_effect,
|
1307
1322
|
controllable_input_checked,
|
@@ -1319,6 +1334,7 @@ export {
|
|
1319
1334
|
createTemplate,
|
1320
1335
|
data,
|
1321
1336
|
dynamicClosure,
|
1337
|
+
dynamicTag,
|
1322
1338
|
dynamicTagAttrs,
|
1323
1339
|
effect,
|
1324
1340
|
forIn,
|
@@ -1342,7 +1358,7 @@ export {
|
|
1342
1358
|
props,
|
1343
1359
|
register,
|
1344
1360
|
registerBoundSignal,
|
1345
|
-
|
1361
|
+
registerDynamicClosure,
|
1346
1362
|
resetAbortSignal,
|
1347
1363
|
run,
|
1348
1364
|
setTagVar,
|
@@ -1,14 +1,5 @@
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
2
|
-
import { type Binding } from "../util/references";
|
3
2
|
type ForType = "in" | "of" | "to";
|
4
|
-
declare const kForMarkerBinding: unique symbol;
|
5
|
-
declare const kOnlyChildInParent: unique symbol;
|
6
|
-
declare module "@marko/compiler/dist/types" {
|
7
|
-
interface NodeExtra {
|
8
|
-
[kForMarkerBinding]?: Binding;
|
9
|
-
[kOnlyChildInParent]?: boolean;
|
10
|
-
}
|
11
|
-
}
|
12
3
|
declare const _default: {
|
13
4
|
analyze(tag: t.NodePath<t.MarkoTag>): void;
|
14
5
|
translate: {
|
@@ -1,11 +1,4 @@
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
2
|
-
import { type Binding } from "../util/references";
|
3
|
-
declare const kBinding: unique symbol;
|
4
|
-
declare module "@marko/compiler/dist/types" {
|
5
|
-
interface MarkoTagExtra {
|
6
|
-
[kBinding]?: Binding;
|
7
|
-
}
|
8
|
-
}
|
9
2
|
export declare const IfTag: {
|
10
3
|
analyze(tag: t.NodePath<t.MarkoTag>): void;
|
11
4
|
translate: {
|
@@ -50,4 +43,3 @@ export declare const ElseTag: {
|
|
50
43
|
controlFlow: true;
|
51
44
|
};
|
52
45
|
};
|
53
|
-
export {};
|