marko 6.0.0-next.3.38 → 6.0.0-next.3.40
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 +696 -741
- package/dist/debug/dom.mjs +696 -741
- package/dist/dom/control-flow.d.ts +1 -2
- package/dist/dom/queue.d.ts +2 -2
- package/dist/dom/resume.d.ts +0 -1
- package/dist/dom/scope.d.ts +1 -2
- package/dist/dom/signals.d.ts +14 -6
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +323 -340
- package/dist/dom.mjs +323 -340
- package/dist/translator/index.js +40 -27
- 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);
|
@@ -92,26 +75,20 @@ function normalizeDynamicRenderer(value2) {
|
|
92
75
|
}
|
93
76
|
|
94
77
|
// src/dom/event.ts
|
95
|
-
var
|
78
|
+
var defaultDelegator = createDelegator();
|
96
79
|
function on(element, type, handler) {
|
97
|
-
|
98
|
-
handlersByElement || elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap()), handlersByElement.has(element) || defaultDelegator(element, type, handleDelegated), handlersByElement.set(element, handler || null);
|
80
|
+
element["$" + type] === void 0 && defaultDelegator(element, type, handleDelegated), element["$" + type] = handler || null;
|
99
81
|
}
|
100
82
|
function createDelegator() {
|
101
83
|
let kEvents = Symbol();
|
102
84
|
return function(node, type, handler) {
|
103
|
-
|
104
|
-
(root[kEvents] ||= {})[type] ||= (root.addEventListener(type, handler, !0), 1);
|
85
|
+
((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, !0), 1);
|
105
86
|
};
|
106
87
|
}
|
107
88
|
function handleDelegated(ev) {
|
108
89
|
let target = !rendering && ev.target;
|
109
|
-
|
110
|
-
|
111
|
-
if (handlersByElement.get(target)?.(ev, target), ev.bubbles)
|
112
|
-
for (; (target = target.parentNode) && !ev.cancelBubble; )
|
113
|
-
handlersByElement.get(target)?.(ev, target);
|
114
|
-
}
|
90
|
+
for (; target; )
|
91
|
+
target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
|
115
92
|
}
|
116
93
|
|
117
94
|
// src/dom/resolve-cursor-position.ts
|
@@ -141,19 +118,19 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
141
118
|
|
142
119
|
// src/dom/resume.ts
|
143
120
|
var registeredValues = {}, Render = class {
|
144
|
-
|
145
|
-
|
146
|
-
|
121
|
+
l = [];
|
122
|
+
m = {};
|
123
|
+
C = {
|
147
124
|
_: registeredValues
|
148
125
|
};
|
149
126
|
constructor(renders, runtimeId, renderId) {
|
150
|
-
this.
|
127
|
+
this.D = renders, this.E = runtimeId, this.n = renderId, this.o = renders[renderId], this.p();
|
151
128
|
}
|
152
129
|
w() {
|
153
|
-
this.
|
130
|
+
this.o.w(), this.p();
|
154
131
|
}
|
155
|
-
|
156
|
-
let data2 = this.
|
132
|
+
p() {
|
133
|
+
let data2 = this.o, serializeContext = this.C, scopeLookup = this.m, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
157
134
|
if (visits.length) {
|
158
135
|
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
|
159
136
|
data2.v = [];
|
@@ -175,7 +152,7 @@ var registeredValues = {}, Render = class {
|
|
175
152
|
else if (token === "$" /* ClosestBranch */)
|
176
153
|
closestBranchMarkers.set(scopeId, visit);
|
177
154
|
else if (token === "[" /* BranchStart */)
|
178
|
-
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.
|
155
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.l.push(this.e)), this.e = scopeId, scope.a = visit;
|
179
156
|
else if (token === "]" /* BranchEnd */) {
|
180
157
|
scope[data3] = visit;
|
181
158
|
let curParent = visit.parentNode, startNode = branchEnd(
|
@@ -183,7 +160,7 @@ var registeredValues = {}, Render = class {
|
|
183
160
|
visit,
|
184
161
|
visit
|
185
162
|
).a;
|
186
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.
|
163
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.l.pop();
|
187
164
|
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
188
165
|
let next = data3.indexOf(" "), curNode = visit;
|
189
166
|
for (scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
@@ -204,7 +181,7 @@ var registeredValues = {}, Render = class {
|
|
204
181
|
let resumeData = resumes[i++];
|
205
182
|
if (typeof resumeData == "function") {
|
206
183
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
207
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.
|
184
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.E, $global.renderId = this.n);
|
208
185
|
for (let scopeId in scopes)
|
209
186
|
if (scopeId !== "$") {
|
210
187
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -215,10 +192,10 @@ var registeredValues = {}, Render = class {
|
|
215
192
|
let parentBranchId = parentBranchIds.get(scopeId);
|
216
193
|
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
217
194
|
let branch = scope, parentBranch = branch.c;
|
218
|
-
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.
|
195
|
+
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.q = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch));
|
219
196
|
}
|
220
197
|
}
|
221
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.
|
198
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.D[this.n] : registeredValues[resumes[i++]](
|
222
199
|
scopeLookup[resumeData],
|
223
200
|
scopeLookup[resumeData]
|
224
201
|
);
|
@@ -255,9 +232,6 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
255
232
|
});
|
256
233
|
}
|
257
234
|
}
|
258
|
-
function registerSubscriber(id, signal) {
|
259
|
-
return register(id, signal.D), signal;
|
260
|
-
}
|
261
235
|
function nodeRef(id, key) {
|
262
236
|
return register(id, (scope) => () => scope[key]);
|
263
237
|
}
|
@@ -335,7 +309,7 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
335
309
|
valueChange
|
336
310
|
));
|
337
311
|
};
|
338
|
-
|
312
|
+
el._ || new MutationObserver(() => {
|
339
313
|
let value2 = scope[nodeAccessor + ":" /* ControlledValue */];
|
340
314
|
(Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) && onChange();
|
341
315
|
}).observe(el, {
|
@@ -393,19 +367,17 @@ function setValueAndUpdateSelection(el, value2) {
|
|
393
367
|
function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
394
368
|
scope[nodeAccessor + ";" /* ControlledHandler */] = checkedChange, checkedChange ? (scope[nodeAccessor + "=" /* ControlledType */] = type, scope[nodeAccessor].checked = checked) : (scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */, scope[nodeAccessor].defaultChecked = checked);
|
395
369
|
}
|
396
|
-
var controllableDelegate = createDelegator()
|
370
|
+
var controllableDelegate = createDelegator();
|
397
371
|
function syncControllable(el, event, hasChanged, onChange) {
|
398
|
-
|
372
|
+
el._ || (controllableDelegate(el, event, handleChange), el.form && controllableDelegate(el.form, "reset", handleFormReset), isResuming && hasChanged(el) && queueMicrotask(onChange)), el._ = onChange;
|
399
373
|
}
|
400
374
|
function handleChange(ev) {
|
401
|
-
|
375
|
+
ev.target._?.(ev);
|
402
376
|
}
|
403
377
|
function handleFormReset(ev) {
|
404
378
|
let handlers = [];
|
405
|
-
for (let el of ev.target.elements)
|
406
|
-
|
407
|
-
handler && hasFormElementChanged(el) && handlers.push(handler);
|
408
|
-
}
|
379
|
+
for (let el of ev.target.elements)
|
380
|
+
el._ && hasFormElementChanged(el) && handlers.push(el._);
|
409
381
|
requestAnimationFrame(() => {
|
410
382
|
if (!ev.defaultPrevented)
|
411
383
|
for (let change of handlers)
|
@@ -640,9 +612,10 @@ function toInsertNode(startNode, endNode) {
|
|
640
612
|
|
641
613
|
// src/dom/scope.ts
|
642
614
|
var pendingScopes = [];
|
643
|
-
function createScope($global) {
|
615
|
+
function createScope($global, closestBranch) {
|
644
616
|
let scope = {
|
645
617
|
g: 1,
|
618
|
+
c: closestBranch,
|
646
619
|
$global
|
647
620
|
};
|
648
621
|
return pendingScopes.push(scope), scope;
|
@@ -652,15 +625,11 @@ function finishPendingScopes() {
|
|
652
625
|
scope.g = 0;
|
653
626
|
pendingScopes = [];
|
654
627
|
}
|
655
|
-
var emptyBranch = createScope({});
|
656
|
-
function getEmptyBranch(marker) {
|
657
|
-
return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
|
658
|
-
}
|
659
628
|
function destroyBranch(branch) {
|
660
|
-
branch.
|
629
|
+
branch.q?.j?.delete(branch), destroyNestedBranches(branch);
|
661
630
|
}
|
662
631
|
function destroyNestedBranches(branch) {
|
663
|
-
branch.
|
632
|
+
branch.F = 1, branch.j?.forEach(destroyNestedBranches), branch.G?.forEach((scope) => {
|
664
633
|
for (let id in scope.h)
|
665
634
|
scope.h[id]?.abort();
|
666
635
|
});
|
@@ -677,6 +646,222 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
677
646
|
);
|
678
647
|
}
|
679
648
|
|
649
|
+
// src/dom/schedule.ts
|
650
|
+
var port2 = /* @__PURE__ */ (() => {
|
651
|
+
let { port1, port2: port22 } = new MessageChannel();
|
652
|
+
return port1.onmessage = () => {
|
653
|
+
isScheduled = !1, run();
|
654
|
+
}, port22;
|
655
|
+
})(), isScheduled;
|
656
|
+
function schedule() {
|
657
|
+
isScheduled || (isScheduled = !0, queueMicrotask(flushAndWaitFrame));
|
658
|
+
}
|
659
|
+
function flushAndWaitFrame() {
|
660
|
+
run(), requestAnimationFrame(triggerMacroTask);
|
661
|
+
}
|
662
|
+
function triggerMacroTask() {
|
663
|
+
port2.postMessage(0);
|
664
|
+
}
|
665
|
+
|
666
|
+
// src/dom/signals.ts
|
667
|
+
var MARK = {}, CLEAN = {}, DIRTY = {};
|
668
|
+
function state(valueAccessor, fn, getIntersection) {
|
669
|
+
let valueSignal = value(valueAccessor, fn, getIntersection), markAccessor = valueAccessor + "#" /* Mark */, valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
670
|
+
return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
|
671
|
+
scope,
|
672
|
+
valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
673
|
+
) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : (schedule(), queueSource(scope, valueSignal, valueOrOp)), valueOrOp);
|
674
|
+
}
|
675
|
+
function value(valueAccessor, fn, getIntersection) {
|
676
|
+
let markAccessor = valueAccessor + "#" /* Mark */, intersection2;
|
677
|
+
return (scope, valueOrOp) => {
|
678
|
+
if (valueOrOp === MARK)
|
679
|
+
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && getIntersection && (intersection2 ||= getIntersection())(scope, MARK);
|
680
|
+
else if (valueOrOp !== DIRTY) {
|
681
|
+
let existing = scope[markAccessor] !== void 0;
|
682
|
+
(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]--;
|
683
|
+
}
|
684
|
+
};
|
685
|
+
}
|
686
|
+
var accessorId = 0;
|
687
|
+
function intersection(count, fn, getIntersection) {
|
688
|
+
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2;
|
689
|
+
return (scope, op) => {
|
690
|
+
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;
|
691
|
+
};
|
692
|
+
}
|
693
|
+
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn, getIntersection) {
|
694
|
+
let childSignal = closure(valueAccessor, fn, getIntersection), loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */, loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */, ownerSignal = (ownerScope) => {
|
695
|
+
for (let scope of ownerScope[loopScopeAccessor] || ownerScope[loopScopeMapAccessor]?.values() || [])
|
696
|
+
scope.g || queueSource(scope, childSignal);
|
697
|
+
};
|
698
|
+
return ownerSignal._ = childSignal, ownerSignal;
|
699
|
+
}
|
700
|
+
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
701
|
+
let childSignal = closure(valueAccessor, fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, ownerSignal = (scope) => {
|
702
|
+
let ifScope = scope[scopeAccessor];
|
703
|
+
ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, childSignal);
|
704
|
+
};
|
705
|
+
return ownerSignal._ = childSignal, ownerSignal;
|
706
|
+
}
|
707
|
+
function dynamicClosure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
708
|
+
let subscribersAccessor = "?" /* Dynamic */ + accessorId++, childSignal = closure(
|
709
|
+
valueAccessor,
|
710
|
+
fn,
|
711
|
+
getIntersection,
|
712
|
+
getOwnerScope
|
713
|
+
), ownerSignal = (ownerScope) => {
|
714
|
+
let subscribers = ownerScope[subscribersAccessor];
|
715
|
+
if (subscribers)
|
716
|
+
for (let subscriber of subscribers)
|
717
|
+
subscriber.g || queueSource(subscriber, childSignal);
|
718
|
+
}, subscribe = (scope) => {
|
719
|
+
let owner = getOwnerScope ? getOwnerScope(scope) : scope._, subscribers = owner[subscribersAccessor] ||= /* @__PURE__ */ new Set();
|
720
|
+
subscribers.has(scope) || (subscribers.add(scope), getAbortSignal(scope, -1).addEventListener(
|
721
|
+
"abort",
|
722
|
+
() => subscribers.delete(scope)
|
723
|
+
));
|
724
|
+
};
|
725
|
+
return ownerSignal.H = subscribe, ownerSignal._ = (scope) => {
|
726
|
+
childSignal(scope), subscribe(scope);
|
727
|
+
}, ownerSignal;
|
728
|
+
}
|
729
|
+
function registerDynamicClosure(id, valueAccessor, fn, getIntersection, getOwnerScope) {
|
730
|
+
let signal = dynamicClosure(
|
731
|
+
valueAccessor,
|
732
|
+
fn,
|
733
|
+
getIntersection,
|
734
|
+
getOwnerScope
|
735
|
+
);
|
736
|
+
return register(id, signal.H), signal;
|
737
|
+
}
|
738
|
+
function closure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
739
|
+
let intersection2;
|
740
|
+
return (scope, op) => {
|
741
|
+
op || fn && fn(
|
742
|
+
scope,
|
743
|
+
(getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
|
744
|
+
), getIntersection && (intersection2 ||= getIntersection())(scope, op ? MARK : DIRTY);
|
745
|
+
};
|
746
|
+
}
|
747
|
+
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
748
|
+
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
749
|
+
}
|
750
|
+
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
751
|
+
function setTagVarChange(scope, changeHandler) {
|
752
|
+
scope["@" /* TagVariableChange */] = changeHandler;
|
753
|
+
}
|
754
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
755
|
+
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
756
|
+
function nextTagId({ $global }) {
|
757
|
+
let id = tagIdsByGlobal.get($global) || 0;
|
758
|
+
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
759
|
+
}
|
760
|
+
function inChild(childAccessor, signal) {
|
761
|
+
return (scope, valueOrOp) => {
|
762
|
+
signal(scope[childAccessor], valueOrOp);
|
763
|
+
};
|
764
|
+
}
|
765
|
+
function intersections(signals) {
|
766
|
+
return (scope, op) => {
|
767
|
+
for (let signal of signals)
|
768
|
+
signal(scope, op);
|
769
|
+
};
|
770
|
+
}
|
771
|
+
function effect(id, fn) {
|
772
|
+
return register(id, fn), (scope) => {
|
773
|
+
queueEffect(scope, fn);
|
774
|
+
};
|
775
|
+
}
|
776
|
+
|
777
|
+
// src/dom/queue.ts
|
778
|
+
var pendingRenders = [], pendingEffects = [], rendering = !1;
|
779
|
+
function queueSource(scope, signal, value2) {
|
780
|
+
let prevRendering = rendering;
|
781
|
+
rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2);
|
782
|
+
}
|
783
|
+
function queueRender(scope, signal, value2) {
|
784
|
+
let i = pendingRenders.length, render = {
|
785
|
+
s: scope,
|
786
|
+
I: signal,
|
787
|
+
J: value2,
|
788
|
+
t: scope.c?.f || 0,
|
789
|
+
u: i
|
790
|
+
};
|
791
|
+
for (pendingRenders.push(render); i; ) {
|
792
|
+
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
793
|
+
if (comparePendingRenders(render, parent) >= 0) break;
|
794
|
+
pendingRenders[i] = parent, i = parentIndex;
|
795
|
+
}
|
796
|
+
pendingRenders[i] = render;
|
797
|
+
}
|
798
|
+
function queueEffect(scope, fn) {
|
799
|
+
pendingEffects.push(scope, fn);
|
800
|
+
}
|
801
|
+
function run() {
|
802
|
+
let effects = pendingEffects;
|
803
|
+
try {
|
804
|
+
rendering = !0, runRenders();
|
805
|
+
} finally {
|
806
|
+
pendingRenders = [], pendingEffects = [], rendering = !1;
|
807
|
+
}
|
808
|
+
runEffects(effects);
|
809
|
+
}
|
810
|
+
function prepareEffects(fn) {
|
811
|
+
let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
812
|
+
pendingRenders = [];
|
813
|
+
try {
|
814
|
+
rendering = !0, fn(), runRenders();
|
815
|
+
} finally {
|
816
|
+
rendering = !1, pendingRenders = prevRenders, pendingEffects = prevEffects;
|
817
|
+
}
|
818
|
+
return preparedEffects;
|
819
|
+
}
|
820
|
+
function runEffects(effects) {
|
821
|
+
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
822
|
+
let scope = effects[i], fn = effects[i + 1];
|
823
|
+
fn(scope, scope);
|
824
|
+
}
|
825
|
+
}
|
826
|
+
function runRenders() {
|
827
|
+
for (; pendingRenders.length; ) {
|
828
|
+
let render = pendingRenders[0], next = pendingRenders.pop();
|
829
|
+
if (render !== next) {
|
830
|
+
let i = 0, mid = pendingRenders.length >> 1, item = pendingRenders[0] = next;
|
831
|
+
for (; i < mid; ) {
|
832
|
+
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
833
|
+
if (right < pendingRenders.length && comparePendingRenders(
|
834
|
+
pendingRenders[right],
|
835
|
+
pendingRenders[bestChild]
|
836
|
+
) < 0 && (bestChild = right), comparePendingRenders(pendingRenders[bestChild], item) >= 0)
|
837
|
+
break;
|
838
|
+
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
839
|
+
}
|
840
|
+
pendingRenders[i] = item;
|
841
|
+
}
|
842
|
+
render.s.c?.F || render.I(render.s, render.J);
|
843
|
+
}
|
844
|
+
finishPendingScopes();
|
845
|
+
}
|
846
|
+
function comparePendingRenders(a, b) {
|
847
|
+
return a.t - b.t || a.u - b.u;
|
848
|
+
}
|
849
|
+
|
850
|
+
// src/dom/abort-signal.ts
|
851
|
+
function resetAbortSignal(scope, id) {
|
852
|
+
let ctrl = scope.h?.[id];
|
853
|
+
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
854
|
+
}
|
855
|
+
function getAbortSignal(scope, id) {
|
856
|
+
return scope.c && (scope.c.G ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
857
|
+
}
|
858
|
+
function abort(ctrl) {
|
859
|
+
ctrl.abort();
|
860
|
+
}
|
861
|
+
|
862
|
+
// src/common/compat-meta.ts
|
863
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
864
|
+
|
680
865
|
// src/dom/reconcile.ts
|
681
866
|
var WRONG_POS = 2147483647;
|
682
867
|
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
@@ -732,9 +917,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
732
917
|
}
|
733
918
|
}
|
734
919
|
function longestIncreasingSubsequence(a) {
|
735
|
-
let p = a.slice(), result = [];
|
736
|
-
result.push(0);
|
737
|
-
let u, v;
|
920
|
+
let p = a.slice(), result = [0], u, v;
|
738
921
|
for (let i = 0, il = a.length; i < il; ++i) {
|
739
922
|
if (a[i] === -1)
|
740
923
|
continue;
|
@@ -762,44 +945,46 @@ function trimWalkString(walkString) {
|
|
762
945
|
return walkString.slice(0, end + 1);
|
763
946
|
}
|
764
947
|
function walk(startNode, walkCodes, branch) {
|
765
|
-
walker.currentNode = startNode, walkInternal(walkCodes, branch
|
948
|
+
walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
|
766
949
|
}
|
767
|
-
function walkInternal(walkCodes, scope
|
950
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
768
951
|
let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
769
|
-
for (;
|
770
|
-
if (currentMultiplier = storedMultiplier, storedMultiplier = 0, value2
|
771
|
-
|
772
|
-
else if (value2
|
773
|
-
|
774
|
-
walker.
|
775
|
-
|
776
|
-
|
777
|
-
for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
|
778
|
-
walker.nextSibling();
|
779
|
-
else if (value2 >= 67 /* Next */)
|
780
|
-
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
781
|
-
walker.nextNode();
|
782
|
-
else if (value2 === 47 /* BeginChild */) {
|
783
|
-
let childScope = scope[currentScopeIndex++] = createScope(scope.$global);
|
784
|
-
childScope.c = scope.c, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
785
|
-
} else {
|
952
|
+
for (; currentWalkIndex < walkCodes.length; )
|
953
|
+
if (value2 = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 === 32 /* Get */)
|
954
|
+
scope[currentScopeIndex++] = walker.currentNode;
|
955
|
+
else if (value2 === 37 /* Replace */)
|
956
|
+
walker.currentNode.replaceWith(
|
957
|
+
walker.currentNode = scope[currentScopeIndex++] = new Text()
|
958
|
+
);
|
959
|
+
else {
|
786
960
|
if (value2 === 38 /* EndChild */)
|
787
961
|
return currentWalkIndex;
|
788
|
-
if (value2 ===
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
962
|
+
if (value2 === 47 /* BeginChild */)
|
963
|
+
currentWalkIndex = walkInternal(
|
964
|
+
currentWalkIndex,
|
965
|
+
walkCodes,
|
966
|
+
scope[currentScopeIndex++] = createScope(scope.$global, scope.c)
|
967
|
+
);
|
968
|
+
else if (value2 < 92)
|
969
|
+
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
970
|
+
walker.nextNode();
|
971
|
+
else if (value2 < 107)
|
972
|
+
for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
|
973
|
+
walker.nextSibling();
|
974
|
+
else if (value2 < 117) {
|
975
|
+
for (value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */; value2--; )
|
976
|
+
walker.parentNode();
|
977
|
+
walker.nextSibling();
|
978
|
+
} else
|
979
|
+
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
794
980
|
}
|
795
|
-
return currentWalkIndex;
|
796
981
|
}
|
797
982
|
|
798
983
|
// src/dom/renderer.ts
|
799
984
|
function createBranchScopeWithRenderer(renderer, $global, parentScope, parentNode) {
|
800
985
|
let branch = createBranch(
|
801
986
|
$global,
|
802
|
-
renderer.
|
987
|
+
renderer.x || parentScope,
|
803
988
|
parentScope
|
804
989
|
);
|
805
990
|
return initBranch(renderer, branch, parentNode), branch;
|
@@ -820,11 +1005,11 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
820
1005
|
}
|
821
1006
|
function createBranch($global, ownerScope, parentScope) {
|
822
1007
|
let branch = createScope($global), parentBranch = parentScope.c;
|
823
|
-
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.
|
1008
|
+
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
1009
|
}
|
825
1010
|
function initBranch(renderer, branch, parentNode) {
|
826
1011
|
let clone = renderer.k(parentNode.namespaceURI), cloneParent = clone.parentNode;
|
827
|
-
walk(cloneParent
|
1012
|
+
cloneParent ? (walk(cloneParent.firstChild, renderer.y, branch), branch.a = cloneParent.firstChild, branch.b = cloneParent.lastChild) : (walk(clone, renderer.y, branch), branch.a = branch.b = clone), renderer.z && queueRender(branch, renderer.z);
|
828
1013
|
}
|
829
1014
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
830
1015
|
return (scope, attrsOrOp) => {
|
@@ -836,7 +1021,7 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
836
1021
|
return renderer.d?.(childScope, attrsOrOp);
|
837
1022
|
let content = getContent?.(scope);
|
838
1023
|
if (typeof renderer == "string")
|
839
|
-
|
1024
|
+
setConditionalRenderer(
|
840
1025
|
childScope,
|
841
1026
|
0,
|
842
1027
|
content,
|
@@ -859,12 +1044,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
859
1044
|
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
860
1045
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
861
1046
|
return (owner) => ({
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
1047
|
+
A: id,
|
1048
|
+
B: template,
|
1049
|
+
y: walks,
|
1050
|
+
z: setup,
|
866
1051
|
k: _clone,
|
867
|
-
|
1052
|
+
x: owner,
|
868
1053
|
get d() {
|
869
1054
|
return args ||= getArgs?.();
|
870
1055
|
}
|
@@ -874,8 +1059,8 @@ function createRenderer(template, walks, setup, getArgs) {
|
|
874
1059
|
return createRendererWithOwner(template, walks, setup, getArgs)();
|
875
1060
|
}
|
876
1061
|
function _clone(ns) {
|
877
|
-
return ((cloneCache[ns] ||= {})[this.
|
878
|
-
this.
|
1062
|
+
return ((cloneCache[ns] ||= {})[this.B] ||= createCloneableHTML(
|
1063
|
+
this.B,
|
879
1064
|
ns
|
880
1065
|
))();
|
881
1066
|
}
|
@@ -889,7 +1074,7 @@ function createCloneableHTML(html2, ns) {
|
|
889
1074
|
function conditional(nodeAccessor, ...branches) {
|
890
1075
|
let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
891
1076
|
return (scope, newBranchIndexOrOp) => {
|
892
|
-
newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN &&
|
1077
|
+
newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN && setConditionalRenderer(
|
893
1078
|
scope,
|
894
1079
|
nodeAccessor,
|
895
1080
|
branches[scope[branchAccessor] = newBranchIndexOrOp],
|
@@ -905,40 +1090,21 @@ var dynamicTag = function(nodeAccessor, fn, getIntersection) {
|
|
905
1090
|
return (scope, newRendererOrOp) => {
|
906
1091
|
if (newRendererOrOp === DIRTY) return;
|
907
1092
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
intersection2?.(scope, op);
|
1093
|
+
newRendererOrOp !== MARK && newRendererOrOp !== CLEAN && (isDifferentRenderer(
|
1094
|
+
currentRenderer,
|
1095
|
+
scope[rendererAccessor] = normalizeDynamicRenderer(newRendererOrOp)
|
1096
|
+
) ? (setConditionalRenderer(
|
1097
|
+
scope,
|
1098
|
+
nodeAccessor,
|
1099
|
+
scope[rendererAccessor],
|
1100
|
+
createBranchScopeWithTagNameOrRenderer
|
1101
|
+
), fn && fn(scope), op = DIRTY) : op = CLEAN), intersection2?.(scope, op);
|
918
1102
|
};
|
919
1103
|
};
|
920
1104
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
921
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] ||
|
922
|
-
|
923
|
-
|
924
|
-
scope,
|
925
|
-
prevBranch.b.parentNode
|
926
|
-
) : getEmptyBranch(scope[nodeAccessor]);
|
927
|
-
prevBranch !== newBranch && (insertBranchBefore(
|
928
|
-
newBranch,
|
929
|
-
prevBranch.b.parentNode,
|
930
|
-
prevBranch.b.nextSibling
|
931
|
-
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch);
|
932
|
-
}
|
933
|
-
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer, createBranch2) {
|
934
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranch2(newRenderer, scope.$global, scope, referenceNode);
|
935
|
-
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
936
|
-
}
|
937
|
-
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
938
|
-
[Symbol(), /* @__PURE__ */ getEmptyBranch(0)]
|
939
|
-
]), emptyMarkerArray = [
|
940
|
-
/* @__PURE__ */ getEmptyBranch(0)
|
941
|
-
], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
|
1105
|
+
let referenceNode = scope[nodeAccessor], prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.a || referenceNode).parentNode : referenceNode, newBranch = scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && createBranch2(newRenderer, scope.$global, scope, parentNode);
|
1106
|
+
referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.a) : parentNode.insertBefore(referenceNode, prevBranch.a), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
|
1107
|
+
}
|
942
1108
|
function loopOf(nodeAccessor, renderer) {
|
943
1109
|
return loop(
|
944
1110
|
nodeAccessor,
|
@@ -968,24 +1134,27 @@ function loopTo(nodeAccessor, renderer) {
|
|
968
1134
|
function loop(nodeAccessor, renderer, forEach) {
|
969
1135
|
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.d;
|
970
1136
|
return (scope, valueOrOp) => {
|
971
|
-
if (valueOrOp
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
1137
|
+
if (valueOrOp !== DIRTY)
|
1138
|
+
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
1139
|
+
if (params)
|
1140
|
+
for (let branch of scope[loopScopeAccessor] || scope[nodeAccessor + "(" /* LoopScopeMap */]?.values() || [])
|
1141
|
+
params(branch, valueOrOp);
|
1142
|
+
} else {
|
1143
|
+
let referenceNode = scope[nodeAccessor], oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */], oldArray = oldMap ? scope[nodeAccessor + "!" /* LoopScopeArray */] || [
|
1144
|
+
...oldMap.values()
|
1145
|
+
] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].a.parentNode : referenceNode, newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map(), newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
|
1146
|
+
forEach(valueOrOp, (key, args) => {
|
1147
|
+
let branch = oldMap?.get(key) || createBranchScopeWithRenderer(
|
1148
|
+
renderer,
|
1149
|
+
scope.$global,
|
1150
|
+
scope,
|
1151
|
+
parentNode
|
1152
|
+
);
|
1153
|
+
params?.(branch, args), newMap.set(key, branch), newArray.push(branch);
|
1154
|
+
});
|
1155
|
+
let afterReference = null;
|
1156
|
+
referenceNode !== parentNode && (oldArray.length ? (afterReference = oldArray[oldArray.length - 1].b.nextSibling, newArray.length || parentNode.insertBefore(referenceNode, afterReference)) : newArray.length && (afterReference = referenceNode.nextSibling, referenceNode.remove())), reconcile(parentNode, oldArray, newArray, afterReference);
|
1157
|
+
}
|
989
1158
|
};
|
990
1159
|
}
|
991
1160
|
function bySecondArg(_item, index) {
|
@@ -995,194 +1164,8 @@ function byFirstArg(name) {
|
|
995
1164
|
return name;
|
996
1165
|
}
|
997
1166
|
function isDifferentRenderer(a, b) {
|
998
|
-
return a !== b && (a?.
|
999
|
-
}
|
1000
|
-
|
1001
|
-
// src/dom/signals.ts
|
1002
|
-
var MARK = {}, CLEAN = {}, DIRTY = {};
|
1003
|
-
function state(valueAccessor, fn, getIntersection) {
|
1004
|
-
let valueSignal = value(valueAccessor, fn, getIntersection), markAccessor = valueAccessor + "#" /* Mark */, valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
1005
|
-
return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
|
1006
|
-
scope,
|
1007
|
-
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
|
-
}
|
1010
|
-
function value(valueAccessor, fn, getIntersection) {
|
1011
|
-
let markAccessor = valueAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1012
|
-
return (scope, valueOrOp) => {
|
1013
|
-
if (valueOrOp === MARK)
|
1014
|
-
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK);
|
1015
|
-
else if (valueOrOp !== DIRTY) {
|
1016
|
-
let existing = scope[markAccessor] !== void 0;
|
1017
|
-
(scope[markAccessor] ||= 1) === 1 && (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp ? intersection2?.(scope, CLEAN) : (scope[valueAccessor] = valueOrOp, fn && fn(scope, valueOrOp), intersection2?.(scope, DIRTY))), scope[markAccessor]--;
|
1018
|
-
}
|
1019
|
-
};
|
1020
|
-
}
|
1021
|
-
var accessorId = 0;
|
1022
|
-
function intersection(count, fn, getIntersection) {
|
1023
|
-
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1024
|
-
return (scope, op) => {
|
1025
|
-
op === MARK ? (scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(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, 0), intersection2?.(scope, DIRTY)) : intersection2?.(scope, CLEAN) : scope[dirtyAccessor] ||= op === DIRTY;
|
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));
|
1032
|
-
};
|
1033
|
-
}
|
1034
|
-
function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
1035
|
-
let signal = closure(fn, getIntersection), loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */, loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */, helperSignal = (ownerScope, value2) => {
|
1036
|
-
let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1037
|
-
if (loopScopes !== emptyMarkerArray)
|
1038
|
-
for (let scope of loopScopes)
|
1039
|
-
scope.g || queueSource(scope, signal, value2);
|
1040
|
-
};
|
1041
|
-
return helperSignal._ = signal, helperSignal;
|
1042
|
-
}
|
1043
|
-
function conditionalClosure(ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
1044
|
-
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1045
|
-
let ifScope = scope[scopeAccessor];
|
1046
|
-
ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, signal, value2);
|
1047
|
-
};
|
1048
|
-
return helperSignal._ = signal, helperSignal;
|
1049
|
-
}
|
1050
|
-
var defaultGetOwnerScope = (scope) => scope._;
|
1051
|
-
function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1052
|
-
let ownerSubscribersAccessor = "?" /* Dynamic */ + accessorId++, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
|
1053
|
-
let subscribers = ownerScope[ownerSubscribersAccessor];
|
1054
|
-
if (subscribers)
|
1055
|
-
for (let subscriber of subscribers)
|
1056
|
-
subscriber.g || queueSource(subscriber, _signal, value2);
|
1057
|
-
}, setupSignal = (scope, value2) => {
|
1058
|
-
_signal(scope, value2), subscribe(scope);
|
1059
|
-
}, subscribe = (scope) => {
|
1060
|
-
(getOwnerScope(scope)[ownerSubscribersAccessor] ||= /* @__PURE__ */ new Set()).add(scope), getAbortSignal(scope, -1).addEventListener("abort", () => {
|
1061
|
-
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1062
|
-
});
|
1063
|
-
};
|
1064
|
-
return helperSignal._ = setupSignal, helperSignal.D = subscribe, helperSignal;
|
1065
|
-
}
|
1066
|
-
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1067
|
-
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
1068
|
-
}
|
1069
|
-
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
1070
|
-
function setTagVarChange(scope, changeHandler) {
|
1071
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
1072
|
-
}
|
1073
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1074
|
-
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1075
|
-
function nextTagId({ $global }) {
|
1076
|
-
let id = tagIdsByGlobal.get($global) || 0;
|
1077
|
-
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1078
|
-
}
|
1079
|
-
function inChild(childAccessor, signal) {
|
1080
|
-
return (scope, valueOrOp) => {
|
1081
|
-
signal(scope[childAccessor], valueOrOp);
|
1082
|
-
};
|
1083
|
-
}
|
1084
|
-
function intersections(signals) {
|
1085
|
-
return (scope, op) => {
|
1086
|
-
for (let signal of signals)
|
1087
|
-
signal(scope, op);
|
1088
|
-
};
|
1089
|
-
}
|
1090
|
-
function effect(id, fn) {
|
1091
|
-
return register(id, fn), (scope) => {
|
1092
|
-
queueEffect(scope, fn);
|
1093
|
-
};
|
1094
|
-
}
|
1095
|
-
|
1096
|
-
// src/dom/queue.ts
|
1097
|
-
var pendingRenders = [], pendingEffects = [], rendering = !1;
|
1098
|
-
function queueSource(scope, signal, value2) {
|
1099
|
-
schedule();
|
1100
|
-
let prevRendering = rendering;
|
1101
|
-
return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
|
1102
|
-
}
|
1103
|
-
function queueRender(scope, signal, value2) {
|
1104
|
-
let i = pendingRenders.length, render = {
|
1105
|
-
l: scope,
|
1106
|
-
H: signal,
|
1107
|
-
I: value2,
|
1108
|
-
z: i
|
1109
|
-
};
|
1110
|
-
for (pendingRenders.push(render); i; ) {
|
1111
|
-
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1112
|
-
if (comparePendingRenders(render, parent) >= 0) break;
|
1113
|
-
pendingRenders[i] = parent, i = parentIndex;
|
1114
|
-
}
|
1115
|
-
pendingRenders[i] = render;
|
1116
|
-
}
|
1117
|
-
function queueEffect(scope, fn) {
|
1118
|
-
pendingEffects.push(scope, fn);
|
1119
|
-
}
|
1120
|
-
function run() {
|
1121
|
-
let effects = pendingEffects;
|
1122
|
-
try {
|
1123
|
-
rendering = !0, runRenders();
|
1124
|
-
} finally {
|
1125
|
-
pendingRenders = [], pendingEffects = [], rendering = !1;
|
1126
|
-
}
|
1127
|
-
runEffects(effects);
|
1128
|
-
}
|
1129
|
-
function prepareEffects(fn) {
|
1130
|
-
let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
1131
|
-
pendingRenders = [];
|
1132
|
-
try {
|
1133
|
-
rendering = !0, fn(), runRenders();
|
1134
|
-
} finally {
|
1135
|
-
rendering = !1, pendingRenders = prevRenders, pendingEffects = prevEffects;
|
1136
|
-
}
|
1137
|
-
return preparedEffects;
|
1167
|
+
return a !== b && (a?.A || 0) !== b?.A;
|
1138
1168
|
}
|
1139
|
-
function runEffects(effects = pendingEffects) {
|
1140
|
-
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
1141
|
-
let scope = effects[i], fn = effects[i + 1];
|
1142
|
-
fn(scope, scope);
|
1143
|
-
}
|
1144
|
-
}
|
1145
|
-
function runRenders() {
|
1146
|
-
for (; pendingRenders.length; ) {
|
1147
|
-
let render = pendingRenders[0], next = pendingRenders.pop();
|
1148
|
-
if (render !== next) {
|
1149
|
-
let i = 0, mid = pendingRenders.length >> 1, item = pendingRenders[0] = next;
|
1150
|
-
for (; i < mid; ) {
|
1151
|
-
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1152
|
-
if (right < pendingRenders.length && comparePendingRenders(
|
1153
|
-
pendingRenders[right],
|
1154
|
-
pendingRenders[bestChild]
|
1155
|
-
) < 0 && (bestChild = right), comparePendingRenders(pendingRenders[bestChild], item) >= 0)
|
1156
|
-
break;
|
1157
|
-
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1158
|
-
}
|
1159
|
-
pendingRenders[i] = item;
|
1160
|
-
}
|
1161
|
-
render.l.c?.E || render.H(render.l, render.I);
|
1162
|
-
}
|
1163
|
-
finishPendingScopes();
|
1164
|
-
}
|
1165
|
-
function comparePendingRenders(a, b) {
|
1166
|
-
return getBranchDepth(a) - getBranchDepth(b) || a.z - b.z;
|
1167
|
-
}
|
1168
|
-
function getBranchDepth(render) {
|
1169
|
-
return render.l.c?.f || 0;
|
1170
|
-
}
|
1171
|
-
|
1172
|
-
// src/dom/abort-signal.ts
|
1173
|
-
function resetAbortSignal(scope, id) {
|
1174
|
-
let ctrl = scope.h?.[id];
|
1175
|
-
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
1176
|
-
}
|
1177
|
-
function getAbortSignal(scope, id) {
|
1178
|
-
return scope.c && (scope.c.F ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
1179
|
-
}
|
1180
|
-
function abort(ctrl) {
|
1181
|
-
ctrl.abort();
|
1182
|
-
}
|
1183
|
-
|
1184
|
-
// src/common/compat-meta.ts
|
1185
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
1186
1169
|
|
1187
1170
|
// src/dom/compat.ts
|
1188
1171
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
@@ -1220,7 +1203,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1220
1203
|
}) {
|
1221
1204
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1222
1205
|
value2[0],
|
1223
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1206
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.m[value2[1]]
|
1224
1207
|
) : value2;
|
1225
1208
|
},
|
1226
1209
|
createRenderer(setup, clone, args) {
|
@@ -1237,7 +1220,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1237
1220
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1238
1221
|
}
|
1239
1222
|
if (component.effects = prepareEffects(() => {
|
1240
|
-
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.
|
1223
|
+
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.x, initBranch(renderer, branch, document.body)), applyArgs(branch, args);
|
1241
1224
|
}), !existing)
|
1242
1225
|
return toInsertNode(branch.a, branch.b);
|
1243
1226
|
}
|
@@ -1279,14 +1262,14 @@ function mount(input = {}, reference, position) {
|
|
1279
1262
|
branch.a,
|
1280
1263
|
branch.b
|
1281
1264
|
), runEffects(effects), {
|
1282
|
-
update
|
1265
|
+
update(newInput) {
|
1283
1266
|
args && runEffects(
|
1284
1267
|
prepareEffects(() => {
|
1285
1268
|
args(branch, MARK), args(branch, [newInput]);
|
1286
1269
|
})
|
1287
1270
|
);
|
1288
1271
|
},
|
1289
|
-
destroy
|
1272
|
+
destroy() {
|
1290
1273
|
removeAndDestroyBranch(branch);
|
1291
1274
|
}
|
1292
1275
|
};
|
@@ -1342,7 +1325,7 @@ export {
|
|
1342
1325
|
props,
|
1343
1326
|
register,
|
1344
1327
|
registerBoundSignal,
|
1345
|
-
|
1328
|
+
registerDynamicClosure,
|
1346
1329
|
resetAbortSignal,
|
1347
1330
|
run,
|
1348
1331
|
setTagVar,
|