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.js
CHANGED
@@ -67,7 +67,7 @@ __export(dom_exports, {
|
|
67
67
|
props: () => props,
|
68
68
|
register: () => register,
|
69
69
|
registerBoundSignal: () => registerBoundSignal,
|
70
|
-
|
70
|
+
registerDynamicClosure: () => registerDynamicClosure,
|
71
71
|
resetAbortSignal: () => resetAbortSignal,
|
72
72
|
run: () => run,
|
73
73
|
setTagVar: () => setTagVar,
|
@@ -111,23 +111,6 @@ function forTo(to, from, step, cb) {
|
|
111
111
|
cb(start + i * delta);
|
112
112
|
}
|
113
113
|
|
114
|
-
// src/dom/schedule.ts
|
115
|
-
var port2 = /* @__PURE__ */ (() => {
|
116
|
-
let { port1, port2: port22 } = new MessageChannel();
|
117
|
-
return port1.onmessage = () => {
|
118
|
-
isScheduled = !1, run();
|
119
|
-
}, port22;
|
120
|
-
})(), isScheduled;
|
121
|
-
function schedule() {
|
122
|
-
isScheduled || (isScheduled = !0, queueMicrotask(flushAndWaitFrame));
|
123
|
-
}
|
124
|
-
function flushAndWaitFrame() {
|
125
|
-
run(), requestAnimationFrame(triggerMacroTask);
|
126
|
-
}
|
127
|
-
function triggerMacroTask() {
|
128
|
-
port2.postMessage(0);
|
129
|
-
}
|
130
|
-
|
131
114
|
// src/common/helpers.ts
|
132
115
|
function classValue(value2) {
|
133
116
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -175,26 +158,20 @@ function normalizeDynamicRenderer(value2) {
|
|
175
158
|
}
|
176
159
|
|
177
160
|
// src/dom/event.ts
|
178
|
-
var
|
161
|
+
var defaultDelegator = createDelegator();
|
179
162
|
function on(element, type, handler) {
|
180
|
-
|
181
|
-
handlersByElement || elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap()), handlersByElement.has(element) || defaultDelegator(element, type, handleDelegated), handlersByElement.set(element, handler || null);
|
163
|
+
element["$" + type] === void 0 && defaultDelegator(element, type, handleDelegated), element["$" + type] = handler || null;
|
182
164
|
}
|
183
165
|
function createDelegator() {
|
184
166
|
let kEvents = Symbol();
|
185
167
|
return function(node, type, handler) {
|
186
|
-
|
187
|
-
(root[kEvents] ||= {})[type] ||= (root.addEventListener(type, handler, !0), 1);
|
168
|
+
((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, !0), 1);
|
188
169
|
};
|
189
170
|
}
|
190
171
|
function handleDelegated(ev) {
|
191
172
|
let target = !rendering && ev.target;
|
192
|
-
|
193
|
-
|
194
|
-
if (handlersByElement.get(target)?.(ev, target), ev.bubbles)
|
195
|
-
for (; (target = target.parentNode) && !ev.cancelBubble; )
|
196
|
-
handlersByElement.get(target)?.(ev, target);
|
197
|
-
}
|
173
|
+
for (; target; )
|
174
|
+
target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
|
198
175
|
}
|
199
176
|
|
200
177
|
// src/dom/resolve-cursor-position.ts
|
@@ -224,19 +201,19 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
224
201
|
|
225
202
|
// src/dom/resume.ts
|
226
203
|
var registeredValues = {}, Render = class {
|
227
|
-
|
228
|
-
|
229
|
-
|
204
|
+
l = [];
|
205
|
+
m = {};
|
206
|
+
C = {
|
230
207
|
_: registeredValues
|
231
208
|
};
|
232
209
|
constructor(renders, runtimeId, renderId) {
|
233
|
-
this.
|
210
|
+
this.D = renders, this.E = runtimeId, this.n = renderId, this.o = renders[renderId], this.p();
|
234
211
|
}
|
235
212
|
w() {
|
236
|
-
this.
|
213
|
+
this.o.w(), this.p();
|
237
214
|
}
|
238
|
-
|
239
|
-
let data2 = this.
|
215
|
+
p() {
|
216
|
+
let data2 = this.o, serializeContext = this.C, scopeLookup = this.m, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
240
217
|
if (visits.length) {
|
241
218
|
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
|
242
219
|
data2.v = [];
|
@@ -258,7 +235,7 @@ var registeredValues = {}, Render = class {
|
|
258
235
|
else if (token === "$" /* ClosestBranch */)
|
259
236
|
closestBranchMarkers.set(scopeId, visit);
|
260
237
|
else if (token === "[" /* BranchStart */)
|
261
|
-
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.
|
238
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.l.push(this.e)), this.e = scopeId, scope.a = visit;
|
262
239
|
else if (token === "]" /* BranchEnd */) {
|
263
240
|
scope[data3] = visit;
|
264
241
|
let curParent = visit.parentNode, startNode = branchEnd(
|
@@ -266,7 +243,7 @@ var registeredValues = {}, Render = class {
|
|
266
243
|
visit,
|
267
244
|
visit
|
268
245
|
).a;
|
269
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.
|
246
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.l.pop();
|
270
247
|
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
271
248
|
let next = data3.indexOf(" "), curNode = visit;
|
272
249
|
for (scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
@@ -287,7 +264,7 @@ var registeredValues = {}, Render = class {
|
|
287
264
|
let resumeData = resumes[i++];
|
288
265
|
if (typeof resumeData == "function") {
|
289
266
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
290
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.
|
267
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.E, $global.renderId = this.n);
|
291
268
|
for (let scopeId in scopes)
|
292
269
|
if (scopeId !== "$") {
|
293
270
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -298,10 +275,10 @@ var registeredValues = {}, Render = class {
|
|
298
275
|
let parentBranchId = parentBranchIds.get(scopeId);
|
299
276
|
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
300
277
|
let branch = scope, parentBranch = branch.c;
|
301
|
-
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.
|
278
|
+
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.q = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch));
|
302
279
|
}
|
303
280
|
}
|
304
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.
|
281
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.D[this.n] : registeredValues[resumes[i++]](
|
305
282
|
scopeLookup[resumeData],
|
306
283
|
scopeLookup[resumeData]
|
307
284
|
);
|
@@ -338,9 +315,6 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
338
315
|
});
|
339
316
|
}
|
340
317
|
}
|
341
|
-
function registerSubscriber(id, signal) {
|
342
|
-
return register(id, signal.D), signal;
|
343
|
-
}
|
344
318
|
function nodeRef(id, key) {
|
345
319
|
return register(id, (scope) => () => scope[key]);
|
346
320
|
}
|
@@ -418,7 +392,7 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
418
392
|
valueChange
|
419
393
|
));
|
420
394
|
};
|
421
|
-
|
395
|
+
el._ || new MutationObserver(() => {
|
422
396
|
let value2 = scope[nodeAccessor + ":" /* ControlledValue */];
|
423
397
|
(Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) && onChange();
|
424
398
|
}).observe(el, {
|
@@ -476,19 +450,17 @@ function setValueAndUpdateSelection(el, value2) {
|
|
476
450
|
function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
477
451
|
scope[nodeAccessor + ";" /* ControlledHandler */] = checkedChange, checkedChange ? (scope[nodeAccessor + "=" /* ControlledType */] = type, scope[nodeAccessor].checked = checked) : (scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */, scope[nodeAccessor].defaultChecked = checked);
|
478
452
|
}
|
479
|
-
var controllableDelegate = createDelegator()
|
453
|
+
var controllableDelegate = createDelegator();
|
480
454
|
function syncControllable(el, event, hasChanged, onChange) {
|
481
|
-
|
455
|
+
el._ || (controllableDelegate(el, event, handleChange), el.form && controllableDelegate(el.form, "reset", handleFormReset), isResuming && hasChanged(el) && queueMicrotask(onChange)), el._ = onChange;
|
482
456
|
}
|
483
457
|
function handleChange(ev) {
|
484
|
-
|
458
|
+
ev.target._?.(ev);
|
485
459
|
}
|
486
460
|
function handleFormReset(ev) {
|
487
461
|
let handlers = [];
|
488
|
-
for (let el of ev.target.elements)
|
489
|
-
|
490
|
-
handler && hasFormElementChanged(el) && handlers.push(handler);
|
491
|
-
}
|
462
|
+
for (let el of ev.target.elements)
|
463
|
+
el._ && hasFormElementChanged(el) && handlers.push(el._);
|
492
464
|
requestAnimationFrame(() => {
|
493
465
|
if (!ev.defaultPrevented)
|
494
466
|
for (let change of handlers)
|
@@ -723,9 +695,10 @@ function toInsertNode(startNode, endNode) {
|
|
723
695
|
|
724
696
|
// src/dom/scope.ts
|
725
697
|
var pendingScopes = [];
|
726
|
-
function createScope($global) {
|
698
|
+
function createScope($global, closestBranch) {
|
727
699
|
let scope = {
|
728
700
|
g: 1,
|
701
|
+
c: closestBranch,
|
729
702
|
$global
|
730
703
|
};
|
731
704
|
return pendingScopes.push(scope), scope;
|
@@ -735,15 +708,11 @@ function finishPendingScopes() {
|
|
735
708
|
scope.g = 0;
|
736
709
|
pendingScopes = [];
|
737
710
|
}
|
738
|
-
var emptyBranch = createScope({});
|
739
|
-
function getEmptyBranch(marker) {
|
740
|
-
return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
|
741
|
-
}
|
742
711
|
function destroyBranch(branch) {
|
743
|
-
branch.
|
712
|
+
branch.q?.j?.delete(branch), destroyNestedBranches(branch);
|
744
713
|
}
|
745
714
|
function destroyNestedBranches(branch) {
|
746
|
-
branch.
|
715
|
+
branch.F = 1, branch.j?.forEach(destroyNestedBranches), branch.G?.forEach((scope) => {
|
747
716
|
for (let id in scope.h)
|
748
717
|
scope.h[id]?.abort();
|
749
718
|
});
|
@@ -760,6 +729,222 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
760
729
|
);
|
761
730
|
}
|
762
731
|
|
732
|
+
// src/dom/schedule.ts
|
733
|
+
var port2 = /* @__PURE__ */ (() => {
|
734
|
+
let { port1, port2: port22 } = new MessageChannel();
|
735
|
+
return port1.onmessage = () => {
|
736
|
+
isScheduled = !1, run();
|
737
|
+
}, port22;
|
738
|
+
})(), isScheduled;
|
739
|
+
function schedule() {
|
740
|
+
isScheduled || (isScheduled = !0, queueMicrotask(flushAndWaitFrame));
|
741
|
+
}
|
742
|
+
function flushAndWaitFrame() {
|
743
|
+
run(), requestAnimationFrame(triggerMacroTask);
|
744
|
+
}
|
745
|
+
function triggerMacroTask() {
|
746
|
+
port2.postMessage(0);
|
747
|
+
}
|
748
|
+
|
749
|
+
// src/dom/signals.ts
|
750
|
+
var MARK = {}, CLEAN = {}, DIRTY = {};
|
751
|
+
function state(valueAccessor, fn, getIntersection) {
|
752
|
+
let valueSignal = value(valueAccessor, fn, getIntersection), markAccessor = valueAccessor + "#" /* Mark */, valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
753
|
+
return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
|
754
|
+
scope,
|
755
|
+
valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
756
|
+
) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : (schedule(), queueSource(scope, valueSignal, valueOrOp)), valueOrOp);
|
757
|
+
}
|
758
|
+
function value(valueAccessor, fn, getIntersection) {
|
759
|
+
let markAccessor = valueAccessor + "#" /* Mark */, intersection2;
|
760
|
+
return (scope, valueOrOp) => {
|
761
|
+
if (valueOrOp === MARK)
|
762
|
+
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && getIntersection && (intersection2 ||= getIntersection())(scope, MARK);
|
763
|
+
else if (valueOrOp !== DIRTY) {
|
764
|
+
let existing = scope[markAccessor] !== void 0;
|
765
|
+
(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]--;
|
766
|
+
}
|
767
|
+
};
|
768
|
+
}
|
769
|
+
var accessorId = 0;
|
770
|
+
function intersection(count, fn, getIntersection) {
|
771
|
+
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2;
|
772
|
+
return (scope, op) => {
|
773
|
+
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;
|
774
|
+
};
|
775
|
+
}
|
776
|
+
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn, getIntersection) {
|
777
|
+
let childSignal = closure(valueAccessor, fn, getIntersection), loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */, loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */, ownerSignal = (ownerScope) => {
|
778
|
+
for (let scope of ownerScope[loopScopeAccessor] || ownerScope[loopScopeMapAccessor]?.values() || [])
|
779
|
+
scope.g || queueSource(scope, childSignal);
|
780
|
+
};
|
781
|
+
return ownerSignal._ = childSignal, ownerSignal;
|
782
|
+
}
|
783
|
+
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
784
|
+
let childSignal = closure(valueAccessor, fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, ownerSignal = (scope) => {
|
785
|
+
let ifScope = scope[scopeAccessor];
|
786
|
+
ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, childSignal);
|
787
|
+
};
|
788
|
+
return ownerSignal._ = childSignal, ownerSignal;
|
789
|
+
}
|
790
|
+
function dynamicClosure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
791
|
+
let subscribersAccessor = "?" /* Dynamic */ + accessorId++, childSignal = closure(
|
792
|
+
valueAccessor,
|
793
|
+
fn,
|
794
|
+
getIntersection,
|
795
|
+
getOwnerScope
|
796
|
+
), ownerSignal = (ownerScope) => {
|
797
|
+
let subscribers = ownerScope[subscribersAccessor];
|
798
|
+
if (subscribers)
|
799
|
+
for (let subscriber of subscribers)
|
800
|
+
subscriber.g || queueSource(subscriber, childSignal);
|
801
|
+
}, subscribe = (scope) => {
|
802
|
+
let owner = getOwnerScope ? getOwnerScope(scope) : scope._, subscribers = owner[subscribersAccessor] ||= /* @__PURE__ */ new Set();
|
803
|
+
subscribers.has(scope) || (subscribers.add(scope), getAbortSignal(scope, -1).addEventListener(
|
804
|
+
"abort",
|
805
|
+
() => subscribers.delete(scope)
|
806
|
+
));
|
807
|
+
};
|
808
|
+
return ownerSignal.H = subscribe, ownerSignal._ = (scope) => {
|
809
|
+
childSignal(scope), subscribe(scope);
|
810
|
+
}, ownerSignal;
|
811
|
+
}
|
812
|
+
function registerDynamicClosure(id, valueAccessor, fn, getIntersection, getOwnerScope) {
|
813
|
+
let signal = dynamicClosure(
|
814
|
+
valueAccessor,
|
815
|
+
fn,
|
816
|
+
getIntersection,
|
817
|
+
getOwnerScope
|
818
|
+
);
|
819
|
+
return register(id, signal.H), signal;
|
820
|
+
}
|
821
|
+
function closure(valueAccessor, fn, getIntersection, getOwnerScope) {
|
822
|
+
let intersection2;
|
823
|
+
return (scope, op) => {
|
824
|
+
op || fn && fn(
|
825
|
+
scope,
|
826
|
+
(getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
|
827
|
+
), getIntersection && (intersection2 ||= getIntersection())(scope, op ? MARK : DIRTY);
|
828
|
+
};
|
829
|
+
}
|
830
|
+
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
831
|
+
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
832
|
+
}
|
833
|
+
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
834
|
+
function setTagVarChange(scope, changeHandler) {
|
835
|
+
scope["@" /* TagVariableChange */] = changeHandler;
|
836
|
+
}
|
837
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
838
|
+
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
839
|
+
function nextTagId({ $global }) {
|
840
|
+
let id = tagIdsByGlobal.get($global) || 0;
|
841
|
+
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
842
|
+
}
|
843
|
+
function inChild(childAccessor, signal) {
|
844
|
+
return (scope, valueOrOp) => {
|
845
|
+
signal(scope[childAccessor], valueOrOp);
|
846
|
+
};
|
847
|
+
}
|
848
|
+
function intersections(signals) {
|
849
|
+
return (scope, op) => {
|
850
|
+
for (let signal of signals)
|
851
|
+
signal(scope, op);
|
852
|
+
};
|
853
|
+
}
|
854
|
+
function effect(id, fn) {
|
855
|
+
return register(id, fn), (scope) => {
|
856
|
+
queueEffect(scope, fn);
|
857
|
+
};
|
858
|
+
}
|
859
|
+
|
860
|
+
// src/dom/queue.ts
|
861
|
+
var pendingRenders = [], pendingEffects = [], rendering = !1;
|
862
|
+
function queueSource(scope, signal, value2) {
|
863
|
+
let prevRendering = rendering;
|
864
|
+
rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2);
|
865
|
+
}
|
866
|
+
function queueRender(scope, signal, value2) {
|
867
|
+
let i = pendingRenders.length, render = {
|
868
|
+
s: scope,
|
869
|
+
I: signal,
|
870
|
+
J: value2,
|
871
|
+
t: scope.c?.f || 0,
|
872
|
+
u: i
|
873
|
+
};
|
874
|
+
for (pendingRenders.push(render); i; ) {
|
875
|
+
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
876
|
+
if (comparePendingRenders(render, parent) >= 0) break;
|
877
|
+
pendingRenders[i] = parent, i = parentIndex;
|
878
|
+
}
|
879
|
+
pendingRenders[i] = render;
|
880
|
+
}
|
881
|
+
function queueEffect(scope, fn) {
|
882
|
+
pendingEffects.push(scope, fn);
|
883
|
+
}
|
884
|
+
function run() {
|
885
|
+
let effects = pendingEffects;
|
886
|
+
try {
|
887
|
+
rendering = !0, runRenders();
|
888
|
+
} finally {
|
889
|
+
pendingRenders = [], pendingEffects = [], rendering = !1;
|
890
|
+
}
|
891
|
+
runEffects(effects);
|
892
|
+
}
|
893
|
+
function prepareEffects(fn) {
|
894
|
+
let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
895
|
+
pendingRenders = [];
|
896
|
+
try {
|
897
|
+
rendering = !0, fn(), runRenders();
|
898
|
+
} finally {
|
899
|
+
rendering = !1, pendingRenders = prevRenders, pendingEffects = prevEffects;
|
900
|
+
}
|
901
|
+
return preparedEffects;
|
902
|
+
}
|
903
|
+
function runEffects(effects) {
|
904
|
+
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
905
|
+
let scope = effects[i], fn = effects[i + 1];
|
906
|
+
fn(scope, scope);
|
907
|
+
}
|
908
|
+
}
|
909
|
+
function runRenders() {
|
910
|
+
for (; pendingRenders.length; ) {
|
911
|
+
let render = pendingRenders[0], next = pendingRenders.pop();
|
912
|
+
if (render !== next) {
|
913
|
+
let i = 0, mid = pendingRenders.length >> 1, item = pendingRenders[0] = next;
|
914
|
+
for (; i < mid; ) {
|
915
|
+
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
916
|
+
if (right < pendingRenders.length && comparePendingRenders(
|
917
|
+
pendingRenders[right],
|
918
|
+
pendingRenders[bestChild]
|
919
|
+
) < 0 && (bestChild = right), comparePendingRenders(pendingRenders[bestChild], item) >= 0)
|
920
|
+
break;
|
921
|
+
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
922
|
+
}
|
923
|
+
pendingRenders[i] = item;
|
924
|
+
}
|
925
|
+
render.s.c?.F || render.I(render.s, render.J);
|
926
|
+
}
|
927
|
+
finishPendingScopes();
|
928
|
+
}
|
929
|
+
function comparePendingRenders(a, b) {
|
930
|
+
return a.t - b.t || a.u - b.u;
|
931
|
+
}
|
932
|
+
|
933
|
+
// src/dom/abort-signal.ts
|
934
|
+
function resetAbortSignal(scope, id) {
|
935
|
+
let ctrl = scope.h?.[id];
|
936
|
+
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
937
|
+
}
|
938
|
+
function getAbortSignal(scope, id) {
|
939
|
+
return scope.c && (scope.c.G ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
940
|
+
}
|
941
|
+
function abort(ctrl) {
|
942
|
+
ctrl.abort();
|
943
|
+
}
|
944
|
+
|
945
|
+
// src/common/compat-meta.ts
|
946
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
947
|
+
|
763
948
|
// src/dom/reconcile.ts
|
764
949
|
var WRONG_POS = 2147483647;
|
765
950
|
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
@@ -815,9 +1000,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
815
1000
|
}
|
816
1001
|
}
|
817
1002
|
function longestIncreasingSubsequence(a) {
|
818
|
-
let p = a.slice(), result = [];
|
819
|
-
result.push(0);
|
820
|
-
let u, v;
|
1003
|
+
let p = a.slice(), result = [0], u, v;
|
821
1004
|
for (let i = 0, il = a.length; i < il; ++i) {
|
822
1005
|
if (a[i] === -1)
|
823
1006
|
continue;
|
@@ -845,44 +1028,46 @@ function trimWalkString(walkString) {
|
|
845
1028
|
return walkString.slice(0, end + 1);
|
846
1029
|
}
|
847
1030
|
function walk(startNode, walkCodes, branch) {
|
848
|
-
walker.currentNode = startNode, walkInternal(walkCodes, branch
|
1031
|
+
walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
|
849
1032
|
}
|
850
|
-
function walkInternal(walkCodes, scope
|
1033
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
851
1034
|
let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
852
|
-
for (;
|
853
|
-
if (currentMultiplier = storedMultiplier, storedMultiplier = 0, value2
|
854
|
-
|
855
|
-
else if (value2
|
856
|
-
|
857
|
-
walker.
|
858
|
-
|
859
|
-
|
860
|
-
for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
|
861
|
-
walker.nextSibling();
|
862
|
-
else if (value2 >= 67 /* Next */)
|
863
|
-
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
864
|
-
walker.nextNode();
|
865
|
-
else if (value2 === 47 /* BeginChild */) {
|
866
|
-
let childScope = scope[currentScopeIndex++] = createScope(scope.$global);
|
867
|
-
childScope.c = scope.c, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
868
|
-
} else {
|
1035
|
+
for (; currentWalkIndex < walkCodes.length; )
|
1036
|
+
if (value2 = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 === 32 /* Get */)
|
1037
|
+
scope[currentScopeIndex++] = walker.currentNode;
|
1038
|
+
else if (value2 === 37 /* Replace */)
|
1039
|
+
walker.currentNode.replaceWith(
|
1040
|
+
walker.currentNode = scope[currentScopeIndex++] = new Text()
|
1041
|
+
);
|
1042
|
+
else {
|
869
1043
|
if (value2 === 38 /* EndChild */)
|
870
1044
|
return currentWalkIndex;
|
871
|
-
if (value2 ===
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
1045
|
+
if (value2 === 47 /* BeginChild */)
|
1046
|
+
currentWalkIndex = walkInternal(
|
1047
|
+
currentWalkIndex,
|
1048
|
+
walkCodes,
|
1049
|
+
scope[currentScopeIndex++] = createScope(scope.$global, scope.c)
|
1050
|
+
);
|
1051
|
+
else if (value2 < 92)
|
1052
|
+
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
1053
|
+
walker.nextNode();
|
1054
|
+
else if (value2 < 107)
|
1055
|
+
for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
|
1056
|
+
walker.nextSibling();
|
1057
|
+
else if (value2 < 117) {
|
1058
|
+
for (value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */; value2--; )
|
1059
|
+
walker.parentNode();
|
1060
|
+
walker.nextSibling();
|
1061
|
+
} else
|
1062
|
+
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
877
1063
|
}
|
878
|
-
return currentWalkIndex;
|
879
1064
|
}
|
880
1065
|
|
881
1066
|
// src/dom/renderer.ts
|
882
1067
|
function createBranchScopeWithRenderer(renderer, $global, parentScope, parentNode) {
|
883
1068
|
let branch = createBranch(
|
884
1069
|
$global,
|
885
|
-
renderer.
|
1070
|
+
renderer.x || parentScope,
|
886
1071
|
parentScope
|
887
1072
|
);
|
888
1073
|
return initBranch(renderer, branch, parentNode), branch;
|
@@ -903,11 +1088,11 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
903
1088
|
}
|
904
1089
|
function createBranch($global, ownerScope, parentScope) {
|
905
1090
|
let branch = createScope($global), parentBranch = parentScope.c;
|
906
|
-
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.
|
1091
|
+
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;
|
907
1092
|
}
|
908
1093
|
function initBranch(renderer, branch, parentNode) {
|
909
1094
|
let clone = renderer.k(parentNode.namespaceURI), cloneParent = clone.parentNode;
|
910
|
-
walk(cloneParent
|
1095
|
+
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);
|
911
1096
|
}
|
912
1097
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
913
1098
|
return (scope, attrsOrOp) => {
|
@@ -919,7 +1104,7 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
919
1104
|
return renderer.d?.(childScope, attrsOrOp);
|
920
1105
|
let content = getContent?.(scope);
|
921
1106
|
if (typeof renderer == "string")
|
922
|
-
|
1107
|
+
setConditionalRenderer(
|
923
1108
|
childScope,
|
924
1109
|
0,
|
925
1110
|
content,
|
@@ -942,12 +1127,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
942
1127
|
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
943
1128
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
944
1129
|
return (owner) => ({
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
1130
|
+
A: id,
|
1131
|
+
B: template,
|
1132
|
+
y: walks,
|
1133
|
+
z: setup,
|
949
1134
|
k: _clone,
|
950
|
-
|
1135
|
+
x: owner,
|
951
1136
|
get d() {
|
952
1137
|
return args ||= getArgs?.();
|
953
1138
|
}
|
@@ -957,8 +1142,8 @@ function createRenderer(template, walks, setup, getArgs) {
|
|
957
1142
|
return createRendererWithOwner(template, walks, setup, getArgs)();
|
958
1143
|
}
|
959
1144
|
function _clone(ns) {
|
960
|
-
return ((cloneCache[ns] ||= {})[this.
|
961
|
-
this.
|
1145
|
+
return ((cloneCache[ns] ||= {})[this.B] ||= createCloneableHTML(
|
1146
|
+
this.B,
|
962
1147
|
ns
|
963
1148
|
))();
|
964
1149
|
}
|
@@ -972,7 +1157,7 @@ function createCloneableHTML(html2, ns) {
|
|
972
1157
|
function conditional(nodeAccessor, ...branches) {
|
973
1158
|
let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
974
1159
|
return (scope, newBranchIndexOrOp) => {
|
975
|
-
newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN &&
|
1160
|
+
newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN && setConditionalRenderer(
|
976
1161
|
scope,
|
977
1162
|
nodeAccessor,
|
978
1163
|
branches[scope[branchAccessor] = newBranchIndexOrOp],
|
@@ -988,40 +1173,21 @@ var dynamicTag = function(nodeAccessor, fn, getIntersection) {
|
|
988
1173
|
return (scope, newRendererOrOp) => {
|
989
1174
|
if (newRendererOrOp === DIRTY) return;
|
990
1175
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
intersection2?.(scope, op);
|
1176
|
+
newRendererOrOp !== MARK && newRendererOrOp !== CLEAN && (isDifferentRenderer(
|
1177
|
+
currentRenderer,
|
1178
|
+
scope[rendererAccessor] = normalizeDynamicRenderer(newRendererOrOp)
|
1179
|
+
) ? (setConditionalRenderer(
|
1180
|
+
scope,
|
1181
|
+
nodeAccessor,
|
1182
|
+
scope[rendererAccessor],
|
1183
|
+
createBranchScopeWithTagNameOrRenderer
|
1184
|
+
), fn && fn(scope), op = DIRTY) : op = CLEAN), intersection2?.(scope, op);
|
1001
1185
|
};
|
1002
1186
|
};
|
1003
1187
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1004
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] ||
|
1005
|
-
|
1006
|
-
|
1007
|
-
scope,
|
1008
|
-
prevBranch.b.parentNode
|
1009
|
-
) : getEmptyBranch(scope[nodeAccessor]);
|
1010
|
-
prevBranch !== newBranch && (insertBranchBefore(
|
1011
|
-
newBranch,
|
1012
|
-
prevBranch.b.parentNode,
|
1013
|
-
prevBranch.b.nextSibling
|
1014
|
-
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch);
|
1015
|
-
}
|
1016
|
-
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer, createBranch2) {
|
1017
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranch2(newRenderer, scope.$global, scope, referenceNode);
|
1018
|
-
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1019
|
-
}
|
1020
|
-
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1021
|
-
[Symbol(), /* @__PURE__ */ getEmptyBranch(0)]
|
1022
|
-
]), emptyMarkerArray = [
|
1023
|
-
/* @__PURE__ */ getEmptyBranch(0)
|
1024
|
-
], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
|
1188
|
+
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);
|
1189
|
+
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());
|
1190
|
+
}
|
1025
1191
|
function loopOf(nodeAccessor, renderer) {
|
1026
1192
|
return loop(
|
1027
1193
|
nodeAccessor,
|
@@ -1051,24 +1217,27 @@ function loopTo(nodeAccessor, renderer) {
|
|
1051
1217
|
function loop(nodeAccessor, renderer, forEach) {
|
1052
1218
|
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.d;
|
1053
1219
|
return (scope, valueOrOp) => {
|
1054
|
-
if (valueOrOp
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1220
|
+
if (valueOrOp !== DIRTY)
|
1221
|
+
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
1222
|
+
if (params)
|
1223
|
+
for (let branch of scope[loopScopeAccessor] || scope[nodeAccessor + "(" /* LoopScopeMap */]?.values() || [])
|
1224
|
+
params(branch, valueOrOp);
|
1225
|
+
} else {
|
1226
|
+
let referenceNode = scope[nodeAccessor], oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */], oldArray = oldMap ? scope[nodeAccessor + "!" /* LoopScopeArray */] || [
|
1227
|
+
...oldMap.values()
|
1228
|
+
] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].a.parentNode : referenceNode, newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map(), newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
|
1229
|
+
forEach(valueOrOp, (key, args) => {
|
1230
|
+
let branch = oldMap?.get(key) || createBranchScopeWithRenderer(
|
1231
|
+
renderer,
|
1232
|
+
scope.$global,
|
1233
|
+
scope,
|
1234
|
+
parentNode
|
1235
|
+
);
|
1236
|
+
params?.(branch, args), newMap.set(key, branch), newArray.push(branch);
|
1237
|
+
});
|
1238
|
+
let afterReference = null;
|
1239
|
+
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);
|
1240
|
+
}
|
1072
1241
|
};
|
1073
1242
|
}
|
1074
1243
|
function bySecondArg(_item, index) {
|
@@ -1078,194 +1247,8 @@ function byFirstArg(name) {
|
|
1078
1247
|
return name;
|
1079
1248
|
}
|
1080
1249
|
function isDifferentRenderer(a, b) {
|
1081
|
-
return a !== b && (a?.
|
1082
|
-
}
|
1083
|
-
|
1084
|
-
// src/dom/signals.ts
|
1085
|
-
var MARK = {}, CLEAN = {}, DIRTY = {};
|
1086
|
-
function state(valueAccessor, fn, getIntersection) {
|
1087
|
-
let valueSignal = value(valueAccessor, fn, getIntersection), markAccessor = valueAccessor + "#" /* Mark */, valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
1088
|
-
return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
|
1089
|
-
scope,
|
1090
|
-
valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
1091
|
-
) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : queueSource(scope, valueSignal, valueOrOp), valueOrOp);
|
1092
|
-
}
|
1093
|
-
function value(valueAccessor, fn, getIntersection) {
|
1094
|
-
let markAccessor = valueAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1095
|
-
return (scope, valueOrOp) => {
|
1096
|
-
if (valueOrOp === MARK)
|
1097
|
-
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK);
|
1098
|
-
else if (valueOrOp !== DIRTY) {
|
1099
|
-
let existing = scope[markAccessor] !== void 0;
|
1100
|
-
(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]--;
|
1101
|
-
}
|
1102
|
-
};
|
1103
|
-
}
|
1104
|
-
var accessorId = 0;
|
1105
|
-
function intersection(count, fn, getIntersection) {
|
1106
|
-
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1107
|
-
return (scope, op) => {
|
1108
|
-
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;
|
1109
|
-
};
|
1110
|
-
}
|
1111
|
-
function closure(fn, getIntersection) {
|
1112
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1113
|
-
return (scope, valueOrOp) => {
|
1114
|
-
valueOrOp === MARK ? intersection2?.(scope, MARK) : (fn && fn(scope, valueOrOp), intersection2?.(scope, DIRTY));
|
1115
|
-
};
|
1116
|
-
}
|
1117
|
-
function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
1118
|
-
let signal = closure(fn, getIntersection), loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */, loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */, helperSignal = (ownerScope, value2) => {
|
1119
|
-
let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1120
|
-
if (loopScopes !== emptyMarkerArray)
|
1121
|
-
for (let scope of loopScopes)
|
1122
|
-
scope.g || queueSource(scope, signal, value2);
|
1123
|
-
};
|
1124
|
-
return helperSignal._ = signal, helperSignal;
|
1125
|
-
}
|
1126
|
-
function conditionalClosure(ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
1127
|
-
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1128
|
-
let ifScope = scope[scopeAccessor];
|
1129
|
-
ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, signal, value2);
|
1130
|
-
};
|
1131
|
-
return helperSignal._ = signal, helperSignal;
|
1132
|
-
}
|
1133
|
-
var defaultGetOwnerScope = (scope) => scope._;
|
1134
|
-
function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1135
|
-
let ownerSubscribersAccessor = "?" /* Dynamic */ + accessorId++, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
|
1136
|
-
let subscribers = ownerScope[ownerSubscribersAccessor];
|
1137
|
-
if (subscribers)
|
1138
|
-
for (let subscriber of subscribers)
|
1139
|
-
subscriber.g || queueSource(subscriber, _signal, value2);
|
1140
|
-
}, setupSignal = (scope, value2) => {
|
1141
|
-
_signal(scope, value2), subscribe(scope);
|
1142
|
-
}, subscribe = (scope) => {
|
1143
|
-
(getOwnerScope(scope)[ownerSubscribersAccessor] ||= /* @__PURE__ */ new Set()).add(scope), getAbortSignal(scope, -1).addEventListener("abort", () => {
|
1144
|
-
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1145
|
-
});
|
1146
|
-
};
|
1147
|
-
return helperSignal._ = setupSignal, helperSignal.D = subscribe, helperSignal;
|
1148
|
-
}
|
1149
|
-
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1150
|
-
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
1151
|
-
}
|
1152
|
-
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
1153
|
-
function setTagVarChange(scope, changeHandler) {
|
1154
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
1155
|
-
}
|
1156
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1157
|
-
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1158
|
-
function nextTagId({ $global }) {
|
1159
|
-
let id = tagIdsByGlobal.get($global) || 0;
|
1160
|
-
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1161
|
-
}
|
1162
|
-
function inChild(childAccessor, signal) {
|
1163
|
-
return (scope, valueOrOp) => {
|
1164
|
-
signal(scope[childAccessor], valueOrOp);
|
1165
|
-
};
|
1166
|
-
}
|
1167
|
-
function intersections(signals) {
|
1168
|
-
return (scope, op) => {
|
1169
|
-
for (let signal of signals)
|
1170
|
-
signal(scope, op);
|
1171
|
-
};
|
1172
|
-
}
|
1173
|
-
function effect(id, fn) {
|
1174
|
-
return register(id, fn), (scope) => {
|
1175
|
-
queueEffect(scope, fn);
|
1176
|
-
};
|
1177
|
-
}
|
1178
|
-
|
1179
|
-
// src/dom/queue.ts
|
1180
|
-
var pendingRenders = [], pendingEffects = [], rendering = !1;
|
1181
|
-
function queueSource(scope, signal, value2) {
|
1182
|
-
schedule();
|
1183
|
-
let prevRendering = rendering;
|
1184
|
-
return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
|
1185
|
-
}
|
1186
|
-
function queueRender(scope, signal, value2) {
|
1187
|
-
let i = pendingRenders.length, render = {
|
1188
|
-
l: scope,
|
1189
|
-
H: signal,
|
1190
|
-
I: value2,
|
1191
|
-
z: i
|
1192
|
-
};
|
1193
|
-
for (pendingRenders.push(render); i; ) {
|
1194
|
-
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1195
|
-
if (comparePendingRenders(render, parent) >= 0) break;
|
1196
|
-
pendingRenders[i] = parent, i = parentIndex;
|
1197
|
-
}
|
1198
|
-
pendingRenders[i] = render;
|
1199
|
-
}
|
1200
|
-
function queueEffect(scope, fn) {
|
1201
|
-
pendingEffects.push(scope, fn);
|
1202
|
-
}
|
1203
|
-
function run() {
|
1204
|
-
let effects = pendingEffects;
|
1205
|
-
try {
|
1206
|
-
rendering = !0, runRenders();
|
1207
|
-
} finally {
|
1208
|
-
pendingRenders = [], pendingEffects = [], rendering = !1;
|
1209
|
-
}
|
1210
|
-
runEffects(effects);
|
1211
|
-
}
|
1212
|
-
function prepareEffects(fn) {
|
1213
|
-
let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
1214
|
-
pendingRenders = [];
|
1215
|
-
try {
|
1216
|
-
rendering = !0, fn(), runRenders();
|
1217
|
-
} finally {
|
1218
|
-
rendering = !1, pendingRenders = prevRenders, pendingEffects = prevEffects;
|
1219
|
-
}
|
1220
|
-
return preparedEffects;
|
1250
|
+
return a !== b && (a?.A || 0) !== b?.A;
|
1221
1251
|
}
|
1222
|
-
function runEffects(effects = pendingEffects) {
|
1223
|
-
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
1224
|
-
let scope = effects[i], fn = effects[i + 1];
|
1225
|
-
fn(scope, scope);
|
1226
|
-
}
|
1227
|
-
}
|
1228
|
-
function runRenders() {
|
1229
|
-
for (; pendingRenders.length; ) {
|
1230
|
-
let render = pendingRenders[0], next = pendingRenders.pop();
|
1231
|
-
if (render !== next) {
|
1232
|
-
let i = 0, mid = pendingRenders.length >> 1, item = pendingRenders[0] = next;
|
1233
|
-
for (; i < mid; ) {
|
1234
|
-
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1235
|
-
if (right < pendingRenders.length && comparePendingRenders(
|
1236
|
-
pendingRenders[right],
|
1237
|
-
pendingRenders[bestChild]
|
1238
|
-
) < 0 && (bestChild = right), comparePendingRenders(pendingRenders[bestChild], item) >= 0)
|
1239
|
-
break;
|
1240
|
-
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1241
|
-
}
|
1242
|
-
pendingRenders[i] = item;
|
1243
|
-
}
|
1244
|
-
render.l.c?.E || render.H(render.l, render.I);
|
1245
|
-
}
|
1246
|
-
finishPendingScopes();
|
1247
|
-
}
|
1248
|
-
function comparePendingRenders(a, b) {
|
1249
|
-
return getBranchDepth(a) - getBranchDepth(b) || a.z - b.z;
|
1250
|
-
}
|
1251
|
-
function getBranchDepth(render) {
|
1252
|
-
return render.l.c?.f || 0;
|
1253
|
-
}
|
1254
|
-
|
1255
|
-
// src/dom/abort-signal.ts
|
1256
|
-
function resetAbortSignal(scope, id) {
|
1257
|
-
let ctrl = scope.h?.[id];
|
1258
|
-
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
1259
|
-
}
|
1260
|
-
function getAbortSignal(scope, id) {
|
1261
|
-
return scope.c && (scope.c.F ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
1262
|
-
}
|
1263
|
-
function abort(ctrl) {
|
1264
|
-
ctrl.abort();
|
1265
|
-
}
|
1266
|
-
|
1267
|
-
// src/common/compat-meta.ts
|
1268
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
1269
1252
|
|
1270
1253
|
// src/dom/compat.ts
|
1271
1254
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
@@ -1303,7 +1286,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1303
1286
|
}) {
|
1304
1287
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1305
1288
|
value2[0],
|
1306
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1289
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.m[value2[1]]
|
1307
1290
|
) : value2;
|
1308
1291
|
},
|
1309
1292
|
createRenderer(setup, clone, args) {
|
@@ -1320,7 +1303,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1320
1303
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1321
1304
|
}
|
1322
1305
|
if (component.effects = prepareEffects(() => {
|
1323
|
-
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.
|
1306
|
+
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.x, initBranch(renderer, branch, document.body)), applyArgs(branch, args);
|
1324
1307
|
}), !existing)
|
1325
1308
|
return toInsertNode(branch.a, branch.b);
|
1326
1309
|
}
|
@@ -1362,14 +1345,14 @@ function mount(input = {}, reference, position) {
|
|
1362
1345
|
branch.a,
|
1363
1346
|
branch.b
|
1364
1347
|
), runEffects(effects), {
|
1365
|
-
update
|
1348
|
+
update(newInput) {
|
1366
1349
|
args && runEffects(
|
1367
1350
|
prepareEffects(() => {
|
1368
1351
|
args(branch, MARK), args(branch, [newInput]);
|
1369
1352
|
})
|
1370
1353
|
);
|
1371
1354
|
},
|
1372
|
-
destroy
|
1355
|
+
destroy() {
|
1373
1356
|
removeAndDestroyBranch(branch);
|
1374
1357
|
}
|
1375
1358
|
};
|