marko 6.0.119 → 6.0.121

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/dom.mjs CHANGED
@@ -76,7 +76,7 @@ function normalizeDynamicRenderer(value) {
76
76
  if (value) {
77
77
  if (typeof value == "string") return value;
78
78
  let normalized = value.content || value.default || value;
79
- if (/* @__KEY__ */ "g" in normalized)
79
+ if (/* @__KEY__ */ "f" in normalized)
80
80
  return normalized;
81
81
  }
82
82
  }
@@ -134,6 +134,13 @@ function stripSpacesAndPunctuation(str) {
134
134
  return str.replace(/[^\p{L}\p{N}]/gu, "");
135
135
  }
136
136
 
137
+ // src/dom/parse-html.ts
138
+ var parsers = {};
139
+ function parseHTML(html, ns) {
140
+ let parser = parsers[ns] ||= document.createElementNS(ns, "template");
141
+ return parser.innerHTML = html, parser.content || parser;
142
+ }
143
+
137
144
  // src/dom/scope.ts
138
145
  var nextScopeId = 1e6;
139
146
  function createScope($global, closestBranch) {
@@ -189,6 +196,133 @@ function tempDetachBranch(branch) {
189
196
  );
190
197
  }
191
198
 
199
+ // src/dom/schedule.ts
200
+ var isScheduled, channel;
201
+ function schedule() {
202
+ isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
203
+ }
204
+ function flushAndWaitFrame() {
205
+ run(), requestAnimationFrame(triggerMacroTask);
206
+ }
207
+ function triggerMacroTask() {
208
+ channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
209
+ isScheduled = 0, run();
210
+ }), channel.port2.postMessage(0);
211
+ }
212
+
213
+ // src/dom/signals.ts
214
+ function _let(id, fn) {
215
+ let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" /* TagVariableChange */ + valueAccessor;
216
+ return (scope, value, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value || scope.H) && (scope[valueAccessor] = value, fn?.(scope)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value) : scope[valueAccessor] !== (scope[valueAccessor] = value) && fn && (schedule(), queueRender(scope, fn, id)), value);
217
+ }
218
+ function _const(valueAccessor, fn) {
219
+ return valueAccessor = decodeAccessor(valueAccessor), (scope, value) => {
220
+ (!(valueAccessor in scope) || scope[valueAccessor] !== value) && (scope[valueAccessor] = value, fn?.(scope));
221
+ };
222
+ }
223
+ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L" /* Id */) {
224
+ return (scope) => {
225
+ scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
226
+ };
227
+ }
228
+ function _for_closure(ownerLoopNodeAccessor, fn) {
229
+ ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
230
+ let scopeAccessor = "A" /* BranchScopes */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
231
+ let scopes = toArray(ownerScope[scopeAccessor]);
232
+ scopes.length && queueRender(
233
+ ownerScope,
234
+ () => {
235
+ for (let scope of scopes)
236
+ !scope.H && !scope.I && fn(scope);
237
+ },
238
+ -1,
239
+ 0,
240
+ scopes[0].L
241
+ );
242
+ };
243
+ return ownerSignal._ = fn, ownerSignal;
244
+ }
245
+ function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
246
+ ownerConditionalNodeAccessor = decodeAccessor(
247
+ ownerConditionalNodeAccessor
248
+ );
249
+ let scopeAccessor = "A" /* BranchScopes */ + ownerConditionalNodeAccessor, branchAccessor = "D" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
250
+ let ifScope = scope[scopeAccessor];
251
+ ifScope && !ifScope.H && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
252
+ };
253
+ return ownerSignal._ = fn, ownerSignal;
254
+ }
255
+ function subscribeToScopeSet(ownerScope, accessor, scope) {
256
+ let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
257
+ subscribers.has(scope) || (subscribers.add(scope), $signal(scope, -1).addEventListener(
258
+ "abort",
259
+ () => ownerScope[accessor].delete(scope)
260
+ ));
261
+ }
262
+ function _closure(...closureSignals) {
263
+ let [{ k: ___scopeInstancesAccessor, l: ___signalIndexAccessor }] = closureSignals;
264
+ for (let i = closureSignals.length; i--; )
265
+ closureSignals[i].q = i;
266
+ return (scope) => {
267
+ if (scope[___scopeInstancesAccessor])
268
+ for (let childScope of scope[___scopeInstancesAccessor])
269
+ childScope.H || queueRender(
270
+ childScope,
271
+ closureSignals[childScope[___signalIndexAccessor]],
272
+ -1
273
+ );
274
+ };
275
+ }
276
+ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
277
+ valueAccessor = decodeAccessor(valueAccessor);
278
+ let closureSignal = ((scope) => {
279
+ scope[closureSignal.l] = closureSignal.q, fn(scope), subscribeToScopeSet(
280
+ getOwnerScope ? getOwnerScope(scope) : scope._,
281
+ closureSignal.k,
282
+ scope
283
+ );
284
+ });
285
+ return closureSignal.k = "B" /* ClosureScopes */ + valueAccessor, closureSignal.l = "C" /* ClosureSignalIndex */ + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
286
+ }
287
+ function _child_setup(setup) {
288
+ return setup._ = (scope, owner) => {
289
+ scope._ = owner, queueRender(scope, setup, -1);
290
+ }, setup;
291
+ }
292
+ function _var(scope, childAccessor, signal) {
293
+ scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
294
+ }
295
+ var _return = (scope, value) => scope.T?.(value);
296
+ function _return_change(scope, changeHandler) {
297
+ changeHandler && (scope.U = changeHandler);
298
+ }
299
+ var _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
300
+ function _id({ ["$" /* Global */]: $global }) {
301
+ let id = tagIdsByGlobal.get($global) || 0;
302
+ return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
303
+ }
304
+ function _script(id, fn) {
305
+ return _resume(id, fn), (scope) => {
306
+ queueEffect(scope, fn);
307
+ };
308
+ }
309
+ function _el_read(value) {
310
+ return rendering && void 0, value;
311
+ }
312
+ function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
313
+ if (scope)
314
+ if (Symbol.iterator in scope)
315
+ for (let s of scope instanceof Map ? scope.values() : scope)
316
+ yield* traverseAllHoisted(s, path, curIndex);
317
+ else curIndex ? yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1) : yield scope[path[0]];
318
+ }
319
+ function _hoist(...path) {
320
+ return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
321
+ let getOne = (...args) => iterator().next().value?.(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
322
+ return getOne;
323
+ };
324
+ }
325
+
192
326
  // src/dom/walker.ts
193
327
  var walker = /* @__PURE__ */ document.createTreeWalker(document);
194
328
  function walk(startNode, walkCodes, branch) {
@@ -231,6 +365,79 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
231
365
  }
232
366
  }
233
367
 
368
+ // src/dom/renderer.ts
369
+ function createBranch($global, renderer, parentScope, parentNode) {
370
+ let branch = createScope($global);
371
+ return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.h?.(
372
+ branch,
373
+ parentNode.namespaceURI
374
+ ), branch;
375
+ }
376
+ function setParentBranch(branch, parentBranch) {
377
+ parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
378
+ }
379
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
380
+ return setupBranch(
381
+ renderer,
382
+ createBranch($global, renderer, parentScope, parentNode)
383
+ );
384
+ }
385
+ function setupBranch(renderer, branch) {
386
+ return renderer.j && queueRender(branch, renderer.j, -1), branch;
387
+ }
388
+ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
389
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
390
+ let clone = template ? (branch, ns) => {
391
+ ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
392
+ template,
393
+ ns
394
+ ))(branch, walks);
395
+ } : (branch) => {
396
+ walk(
397
+ branch.S = branch.K = new Text(),
398
+ walks,
399
+ branch
400
+ );
401
+ };
402
+ return (owner) => ({
403
+ f: id,
404
+ h: clone,
405
+ e: owner,
406
+ j: setup,
407
+ b: params,
408
+ d: dynamicScopesAccessor
409
+ });
410
+ }
411
+ function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
412
+ return _resume(
413
+ id,
414
+ _content(id, template, walks, setup, params, dynamicScopesAccessor)
415
+ );
416
+ }
417
+ function _content_closures(renderer, closureFns) {
418
+ let closureSignals = {};
419
+ for (let key in closureFns)
420
+ closureSignals[key] = _const(+key, closureFns[key]);
421
+ return (owner, closureValues) => {
422
+ let instance = renderer(owner);
423
+ return instance.n = closureSignals, instance.t = closureValues, instance;
424
+ };
425
+ }
426
+ var cloneCache = {};
427
+ function createCloneableHTML(html, ns) {
428
+ let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
429
+ return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
430
+ walk(
431
+ branch.S = branch.K = firstChild.cloneNode(!0),
432
+ walks,
433
+ branch
434
+ );
435
+ } : (branch, walks) => {
436
+ let clone = parent.cloneNode(!0);
437
+ walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
438
+ };
439
+ }
440
+
234
441
  // src/dom/resume.ts
235
442
  var registeredValues = {}, branchesEnabled;
236
443
  function enableBranches() {
@@ -242,7 +449,7 @@ function init(runtimeId = "M") {
242
449
  value: resumeRender = ((renderId) => {
243
450
  let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, serializeContext = {
244
451
  _: registeredValues
245
- }, visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, childBranch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
452
+ }, visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
246
453
  for (visitType !== "[" /* BranchStart */ && (visitScope["J" /* Getter */ + nextToken(
247
454
  /* read accessor */
248
455
  )] = /* @__PURE__ */ ((node) => () => node)(
@@ -254,7 +461,7 @@ function init(runtimeId = "M") {
254
461
  branch = scopeLookup[branchId] ||= {
255
462
  L: branchId
256
463
  }
257
- ), branch.F = branch, singleNode) {
464
+ ), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
258
465
  for (; startVisit.previousSibling && ~visits.indexOf(
259
466
  startVisit = startVisit.previousSibling
260
467
  ); ) ;
@@ -262,9 +469,7 @@ function init(runtimeId = "M") {
262
469
  } else
263
470
  curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
264
471
  for (; i && orphanBranches[--i].L > branchId; )
265
- (childBranch = orphanBranches.pop()).N = branch, (branch.D ||= /* @__PURE__ */ new Set()).add(
266
- childBranch
267
- );
472
+ setParentBranch(orphanBranches.pop(), branch);
268
473
  nextToken(
269
474
  /* read optional next branchId */
270
475
  );
@@ -518,210 +723,6 @@ function toValueProp(it) {
518
723
  return it.value;
519
724
  }
520
725
 
521
- // src/dom/parse-html.ts
522
- var parsers = {};
523
- function parseHTML(html, ns) {
524
- let parser = parsers[ns] ||= document.createElementNS(ns, "template");
525
- return parser.innerHTML = html, parser.content || parser;
526
- }
527
-
528
- // src/dom/schedule.ts
529
- var isScheduled, channel;
530
- function schedule() {
531
- isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
532
- }
533
- function flushAndWaitFrame() {
534
- run(), requestAnimationFrame(triggerMacroTask);
535
- }
536
- function triggerMacroTask() {
537
- channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
538
- isScheduled = 0, run();
539
- }), channel.port2.postMessage(0);
540
- }
541
-
542
- // src/dom/signals.ts
543
- function _let(id, fn) {
544
- let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" /* TagVariableChange */ + valueAccessor;
545
- return (scope, value, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value || scope.H) && (scope[valueAccessor] = value, fn?.(scope)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value) : scope[valueAccessor] !== (scope[valueAccessor] = value) && fn && (schedule(), queueRender(scope, fn, id)), value);
546
- }
547
- function _const(valueAccessor, fn) {
548
- return valueAccessor = decodeAccessor(valueAccessor), (scope, value) => {
549
- (!(valueAccessor in scope) || scope[valueAccessor] !== value) && (scope[valueAccessor] = value, fn?.(scope));
550
- };
551
- }
552
- function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L" /* Id */) {
553
- return (scope) => {
554
- scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
555
- };
556
- }
557
- function _for_closure(ownerLoopNodeAccessor, fn) {
558
- ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
559
- let scopeAccessor = "A" /* BranchScopes */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
560
- let scopes = toArray(ownerScope[scopeAccessor]);
561
- scopes.length && queueRender(
562
- ownerScope,
563
- () => {
564
- for (let scope of scopes)
565
- !scope.H && !scope.I && fn(scope);
566
- },
567
- -1,
568
- 0,
569
- scopes[0].L
570
- );
571
- };
572
- return ownerSignal._ = fn, ownerSignal;
573
- }
574
- function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
575
- ownerConditionalNodeAccessor = decodeAccessor(
576
- ownerConditionalNodeAccessor
577
- );
578
- let scopeAccessor = "A" /* BranchScopes */ + ownerConditionalNodeAccessor, branchAccessor = "D" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
579
- let ifScope = scope[scopeAccessor];
580
- ifScope && !ifScope.H && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
581
- };
582
- return ownerSignal._ = fn, ownerSignal;
583
- }
584
- function subscribeToScopeSet(ownerScope, accessor, scope) {
585
- let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
586
- subscribers.has(scope) || (subscribers.add(scope), $signal(scope, -1).addEventListener(
587
- "abort",
588
- () => ownerScope[accessor].delete(scope)
589
- ));
590
- }
591
- function _closure(...closureSignals) {
592
- let [{ l: ___scopeInstancesAccessor, n: ___signalIndexAccessor }] = closureSignals;
593
- for (let i = closureSignals.length; i--; )
594
- closureSignals[i].t = i;
595
- return (scope) => {
596
- if (scope[___scopeInstancesAccessor])
597
- for (let childScope of scope[___scopeInstancesAccessor])
598
- childScope.H || queueRender(
599
- childScope,
600
- closureSignals[childScope[___signalIndexAccessor]],
601
- -1
602
- );
603
- };
604
- }
605
- function _closure_get(valueAccessor, fn, getOwnerScope) {
606
- valueAccessor = decodeAccessor(valueAccessor);
607
- let closureSignal = ((scope) => {
608
- scope[closureSignal.n] = closureSignal.t, fn(scope), subscribeToScopeSet(
609
- getOwnerScope ? getOwnerScope(scope) : scope._,
610
- closureSignal.l,
611
- scope
612
- );
613
- });
614
- return closureSignal.l = "B" /* ClosureScopes */ + valueAccessor, closureSignal.n = "C" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
615
- }
616
- function _child_setup(setup) {
617
- return setup._ = (scope, owner) => {
618
- scope._ = owner, queueRender(scope, setup, -1);
619
- }, setup;
620
- }
621
- function _var(scope, childAccessor, signal) {
622
- scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
623
- }
624
- var _return = (scope, value) => scope.T?.(value);
625
- function _return_change(scope, changeHandler) {
626
- changeHandler && (scope.U = changeHandler);
627
- }
628
- var _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
629
- function _id({ ["$" /* Global */]: $global }) {
630
- let id = tagIdsByGlobal.get($global) || 0;
631
- return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
632
- }
633
- function _script(id, fn) {
634
- return _resume(id, fn), (scope) => {
635
- queueEffect(scope, fn);
636
- };
637
- }
638
- function _el_read(value) {
639
- return rendering && void 0, value;
640
- }
641
- function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
642
- if (scope)
643
- if (Symbol.iterator in scope)
644
- for (let s of scope instanceof Map ? scope.values() : scope)
645
- yield* traverseAllHoisted(s, path, curIndex);
646
- else curIndex ? yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1) : yield scope[path[0]];
647
- }
648
- function _hoist(...path) {
649
- return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
650
- let getOne = (...args) => iterator().next().value?.(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
651
- return getOne;
652
- };
653
- }
654
-
655
- // src/dom/renderer.ts
656
- function createBranch($global, renderer, parentScope, parentNode) {
657
- let branch = createScope($global), parentBranch = parentScope?.F;
658
- return branch._ = renderer.e || parentScope, branch.F = branch, parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), renderer.h?.(
659
- branch,
660
- parentNode.namespaceURI
661
- ), branch;
662
- }
663
- function createAndSetupBranch($global, renderer, parentScope, parentNode) {
664
- return setupBranch(
665
- renderer,
666
- createBranch($global, renderer, parentScope, parentNode)
667
- );
668
- }
669
- function setupBranch(renderer, branch) {
670
- return renderer.j && queueRender(branch, renderer.j, -1), branch;
671
- }
672
- function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
673
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
674
- let clone = template ? (branch, ns) => {
675
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
676
- template,
677
- ns
678
- ))(branch, walks);
679
- } : (branch) => {
680
- walk(
681
- branch.S = branch.K = new Text(),
682
- walks,
683
- branch
684
- );
685
- };
686
- return (owner) => ({
687
- g: id,
688
- h: clone,
689
- e: owner,
690
- j: setup,
691
- a: params,
692
- b: dynamicScopesAccessor
693
- });
694
- }
695
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
696
- return _resume(
697
- id,
698
- _content(id, template, walks, setup, params, dynamicScopesAccessor)
699
- );
700
- }
701
- function _content_closures(renderer, closureFns) {
702
- let closureSignals = {};
703
- for (let key in closureFns)
704
- closureSignals[key] = _const(+key, closureFns[key]);
705
- return (owner, closureValues) => {
706
- let instance = renderer(owner);
707
- return instance.o = closureSignals, instance.u = closureValues, instance;
708
- };
709
- }
710
- var cloneCache = {};
711
- function createCloneableHTML(html, ns) {
712
- let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
713
- return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
714
- walk(
715
- branch.S = branch.K = firstChild.cloneNode(!0),
716
- walks,
717
- branch
718
- );
719
- } : (branch, walks) => {
720
- let clone = parent.cloneNode(!0);
721
- walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
722
- };
723
- }
724
-
725
726
  // src/dom/dom.ts
726
727
  function _to_text(value) {
727
728
  return value || value === 0 ? value + "" : "";
@@ -864,9 +865,9 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
864
865
  }
865
866
  function _attr_content(scope, nodeAccessor, value) {
866
867
  let content = normalizeClientRender(value), rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
867
- scope[rendererAccessor] !== (scope[rendererAccessor] = content?.g) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.b && subscribeToScopeSet(
868
+ scope[rendererAccessor] !== (scope[rendererAccessor] = content?.f) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.d && subscribeToScopeSet(
868
869
  content.e,
869
- content.b,
870
+ content.d,
870
871
  scope["A" /* BranchScopes */ + nodeAccessor]
871
872
  ));
872
873
  }
@@ -906,7 +907,7 @@ function _html(scope, value, accessor) {
906
907
  }
907
908
  function normalizeClientRender(value) {
908
909
  let renderer = normalizeDynamicRenderer(value);
909
- if (renderer && renderer.g)
910
+ if (renderer && renderer.f)
910
911
  return renderer;
911
912
  }
912
913
  function normalizeAttrValue(value) {
@@ -1018,93 +1019,102 @@ function longestIncreasingSubsequence(a) {
1018
1019
  // src/dom/control-flow.ts
1019
1020
  function _await_promise(nodeAccessor, params) {
1020
1021
  nodeAccessor = decodeAccessor(nodeAccessor);
1021
- let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
1022
+ let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor;
1022
1023
  return _enable_catch(), (scope, promise) => {
1023
- let awaitCounter, renderData, tryWithPlaceholder = findBranchWithKey(
1024
- scope,
1025
- "Q" /* PlaceholderContent */
1026
- );
1027
- tryWithPlaceholder ? (renderData = self[tryWithPlaceholder.$.runtimeId]?.[tryWithPlaceholder.$.renderId], awaitCounter = tryWithPlaceholder.O ||= renderData?.p?.[tryWithPlaceholder.L], awaitCounter?.i || (awaitCounter = tryWithPlaceholder.O = {
1028
- d: 1,
1024
+ let awaitBranch = scope[branchAccessor], tryBranch = findBranchWithKey(scope, "Q" /* PlaceholderContent */) || awaitBranch, awaitCounter = tryBranch.O;
1025
+ awaitCounter?.i || (awaitCounter = tryBranch.O = {
1029
1026
  i: 0,
1030
1027
  c() {
1031
- if (!--awaitCounter.i) {
1032
- let placeholderBranch = tryWithPlaceholder.P;
1033
- tryWithPlaceholder.P = 0, placeholderBranch && (placeholderBranch.S.parentNode.insertBefore(
1034
- tryWithPlaceholder.S.parentNode,
1028
+ if (--awaitCounter.i) return 1;
1029
+ if (tryBranch === scope[branchAccessor])
1030
+ scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(
1031
+ scope[branchAccessor].S.parentNode
1032
+ );
1033
+ else {
1034
+ let placeholderBranch = tryBranch.P;
1035
+ placeholderBranch && (tryBranch.P = 0, placeholderBranch.S.parentNode.insertBefore(
1036
+ tryBranch.S.parentNode,
1035
1037
  placeholderBranch.S
1036
- ), removeAndDestroyBranch(placeholderBranch)), queueEffect(tryWithPlaceholder, (scope2) => {
1037
- let pendingEffects2 = scope2.J;
1038
- pendingEffects2 && (scope2.J = [], runEffects(pendingEffects2, !0));
1039
- });
1038
+ ), removeAndDestroyBranch(placeholderBranch));
1040
1039
  }
1040
+ queueEffect(tryBranch, (scope2) => {
1041
+ let pendingEffects2 = scope2.J;
1042
+ pendingEffects2 && (scope2.J = [], runEffects(pendingEffects2, 1));
1043
+ });
1041
1044
  }
1042
- }), placeholderShown.add(pendingEffects), !scope[promiseAccessor] && !awaitCounter.i++ && requestAnimationFrame(
1045
+ }), placeholderShown.add(pendingEffects), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(
1043
1046
  () => awaitCounter.i && runEffects(
1044
1047
  prepareEffects(
1045
1048
  () => queueRender(
1046
- tryWithPlaceholder,
1049
+ tryBranch === awaitBranch ? scope : tryBranch,
1047
1050
  () => {
1048
- insertBranchBefore(
1049
- tryWithPlaceholder.P = createAndSetupBranch(
1051
+ tryBranch.Q ? (insertBranchBefore(
1052
+ tryBranch.P = createAndSetupBranch(
1050
1053
  scope.$,
1051
- tryWithPlaceholder.Q,
1052
- tryWithPlaceholder._,
1053
- tryWithPlaceholder.S.parentNode
1054
+ tryBranch.Q,
1055
+ tryBranch._,
1056
+ tryBranch.S.parentNode
1054
1057
  ),
1055
- tryWithPlaceholder.S.parentNode,
1056
- tryWithPlaceholder.S
1057
- ), tempDetachBranch(tryWithPlaceholder);
1058
+ tryBranch.S.parentNode,
1059
+ tryBranch.S
1060
+ ), tempDetachBranch(tryBranch)) : awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(
1061
+ scope[nodeAccessor],
1062
+ awaitBranch.S
1063
+ ), tempDetachBranch(tryBranch));
1058
1064
  },
1059
1065
  -1
1060
1066
  )
1061
1067
  )
1062
1068
  )
1063
- )) : scope[branchAccessor] && !scope[promiseAccessor] && (scope[branchAccessor].S.parentNode.insertBefore(
1064
- scope[nodeAccessor],
1065
- scope[branchAccessor].S
1066
- ), tempDetachBranch(scope[branchAccessor]));
1069
+ ));
1067
1070
  let thisPromise = scope[promiseAccessor] = promise.then(
1068
1071
  (data) => {
1069
- thisPromise === scope[promiseAccessor] && (scope[promiseAccessor] = 0, schedule(), queueRender(
1070
- scope,
1071
- () => {
1072
- if (scope[branchAccessor] ? tryWithPlaceholder || scope[nodeAccessor].replaceWith(
1073
- scope[branchAccessor].S.parentNode
1074
- ) : (insertBranchBefore(
1075
- scope[branchAccessor] = createAndSetupBranch(
1076
- scope.$,
1077
- scope[rendererAccessor],
1078
- scope,
1079
- scope[nodeAccessor].parentNode
1080
- ),
1081
- scope[nodeAccessor].parentNode,
1082
- scope[nodeAccessor]
1083
- ), scope[nodeAccessor].remove()), params?.(scope[branchAccessor], [data]), awaitCounter && (placeholderShown.add(pendingEffects), awaitCounter.c(), !awaitCounter.d)) {
1084
- let fnScopes = /* @__PURE__ */ new Map(), effects = renderData.m();
1085
- for (let i = 0; i < pendingEffects.length; ) {
1086
- let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
1087
- scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
1088
- }
1089
- for (let i = 0; i < effects.length; ) {
1090
- let fn = effects[i++], scope2 = effects[i++];
1091
- fnScopes.get(fn)?.has(scope2) || queueEffect(scope2, fn);
1072
+ if (thisPromise === scope[promiseAccessor]) {
1073
+ let referenceNode = scope[nodeAccessor];
1074
+ scope[promiseAccessor] = 0, queueMicrotask(run), queueRender(
1075
+ scope,
1076
+ () => {
1077
+ (awaitBranch = scope[branchAccessor]).V && (pendingScopes.push(awaitBranch), setupBranch(
1078
+ awaitBranch.V,
1079
+ awaitBranch
1080
+ ), awaitBranch.V = 0, insertBranchBefore(
1081
+ awaitBranch,
1082
+ scope[nodeAccessor].parentNode,
1083
+ scope[nodeAccessor]
1084
+ ), referenceNode.remove()), params?.(awaitBranch, [data]);
1085
+ let pendingRenders2 = awaitBranch.W;
1086
+ if (awaitBranch.W = 0, pendingRenders2?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
1087
+ let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m();
1088
+ for (let i = 0; i < pendingEffects.length; ) {
1089
+ let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
1090
+ scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
1091
+ }
1092
+ for (let i = 0; i < effects.length; ) {
1093
+ let fn = effects[i++], scope2 = effects[i++];
1094
+ fnScopes.get(fn)?.has(scope2) || queueEffect(scope2, fn);
1095
+ }
1092
1096
  }
1093
- }
1094
- },
1095
- -1
1096
- ));
1097
+ },
1098
+ -1
1099
+ );
1100
+ }
1097
1101
  },
1098
1102
  (error) => {
1099
- thisPromise === scope[promiseAccessor] && (awaitCounter && (awaitCounter.i = 0), scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
1103
+ thisPromise === scope[promiseAccessor] && (awaitCounter.i = scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
1100
1104
  }
1101
1105
  );
1102
1106
  };
1103
1107
  }
1104
1108
  function _await_content(nodeAccessor, template, walks, setup) {
1105
- let rendererAccessor = "D" /* ConditionalRenderer */ + decodeAccessor(nodeAccessor), renderer = _content("", template, walks, setup)();
1109
+ nodeAccessor = decodeAccessor(nodeAccessor);
1110
+ let branchAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
1106
1111
  return (scope) => {
1107
- scope[rendererAccessor] = renderer;
1112
+ (scope[branchAccessor] = createBranch(
1113
+ scope.$,
1114
+ renderer,
1115
+ scope,
1116
+ scope[nodeAccessor].parentNode
1117
+ )).V = renderer, pendingScopes.pop();
1108
1118
  };
1109
1119
  }
1110
1120
  function _try(nodeAccessor, template, walks, setup) {
@@ -1132,7 +1142,7 @@ function renderCatch(scope, error) {
1132
1142
  tryWithCatch.C,
1133
1143
  tryWithCatch.E,
1134
1144
  createAndSetupBranch
1135
- ), tryWithCatch.E.a?.(
1145
+ ), tryWithCatch.E.b?.(
1136
1146
  owner["A" /* BranchScopes */ + tryWithCatch.C],
1137
1147
  [error]
1138
1148
  );
@@ -1168,7 +1178,7 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1168
1178
  let childScopeAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
1169
1179
  return enableBranches(), (scope, newRenderer, getInput) => {
1170
1180
  let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1171
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.g || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
1181
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.f || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
1172
1182
  if (setConditionalRenderer(
1173
1183
  scope,
1174
1184
  nodeAccessor,
@@ -1182,15 +1192,15 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1182
1192
  "a",
1183
1193
  content,
1184
1194
  createAndSetupBranch
1185
- ), content.b && subscribeToScopeSet(
1195
+ ), content.d && subscribeToScopeSet(
1186
1196
  content.e,
1187
- content.b,
1197
+ content.d,
1188
1198
  scope[childScopeAccessor]["Aa"]
1189
1199
  );
1190
1200
  }
1191
- } else normalizedRenderer?.b && subscribeToScopeSet(
1201
+ } else normalizedRenderer?.d && subscribeToScopeSet(
1192
1202
  normalizedRenderer.e,
1193
- normalizedRenderer.b,
1203
+ normalizedRenderer.d,
1194
1204
  scope[childScopeAccessor]
1195
1205
  );
1196
1206
  if (normalizedRenderer) {
@@ -1202,20 +1212,20 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1202
1212
  (inputIsArgs ? args[0] : args) || {}
1203
1213
  ), (childScope["Ia"] || childScope["Ea"]) && queueEffect(childScope, dynamicTagScript);
1204
1214
  else {
1205
- for (let accessor in normalizedRenderer.o)
1206
- normalizedRenderer.o[accessor](
1215
+ for (let accessor in normalizedRenderer.n)
1216
+ normalizedRenderer.n[accessor](
1207
1217
  childScope,
1208
- normalizedRenderer.u[accessor]
1218
+ normalizedRenderer.t[accessor]
1209
1219
  );
1210
- if (normalizedRenderer.a)
1220
+ if (normalizedRenderer.b)
1211
1221
  if (inputIsArgs)
1212
- normalizedRenderer.a(
1222
+ normalizedRenderer.b(
1213
1223
  childScope,
1214
1224
  normalizedRenderer._ ? args[0] : args
1215
1225
  );
1216
1226
  else {
1217
1227
  let inputWithContent = getContent ? { ...args, content: getContent(scope) } : args || {};
1218
- normalizedRenderer.a(
1228
+ normalizedRenderer.b(
1219
1229
  childScope,
1220
1230
  normalizedRenderer._ ? inputWithContent : [inputWithContent]
1221
1231
  );
@@ -1299,45 +1309,47 @@ function byFirstArg(name) {
1299
1309
  }
1300
1310
 
1301
1311
  // src/dom/queue.ts
1302
- var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
1312
+ var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), asyncRendersLookup, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
1303
1313
  function queueRender(scope, signal, signalKey, value, scopeKey = scope.L) {
1304
- let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
1305
- if (existingRender)
1306
- existingRender.q = value;
1307
- else {
1308
- let render = {
1309
- f: key,
1310
- k: scope,
1311
- x: signal,
1312
- q: value
1313
- }, i = pendingRenders.push(render) - 1;
1314
- for (; i; ) {
1315
- let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1316
- if (key - parent.f >= 0) break;
1317
- pendingRenders[i] = parent, i = parentIndex;
1314
+ let key = scopeKey * scopeKeyOffset + signalKey, render = signalKey >= 0 && pendingRendersLookup.get(key);
1315
+ render ? render.o = value : (queuePendingRender(
1316
+ render = {
1317
+ a: key,
1318
+ g: scope,
1319
+ u: signal,
1320
+ o: value
1318
1321
  }
1319
- signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
1322
+ ), signalKey >= 0 && pendingRendersLookup.set(key, render));
1323
+ }
1324
+ function queuePendingRender(render) {
1325
+ let i = pendingRenders.push(render) - 1;
1326
+ for (; i; ) {
1327
+ let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1328
+ if (render.a - parent.a >= 0) break;
1329
+ pendingRenders[i] = parent, i = parentIndex;
1320
1330
  }
1331
+ pendingRenders[i] = render;
1321
1332
  }
1322
1333
  function queueEffect(scope, fn) {
1323
1334
  pendingEffects.push(fn, scope);
1324
1335
  }
1325
1336
  function run() {
1326
1337
  let effects = pendingEffects;
1338
+ asyncRendersLookup = /* @__PURE__ */ new Map();
1327
1339
  try {
1328
1340
  rendering = 1, runRenders();
1329
1341
  } finally {
1330
- pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = 0;
1342
+ pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = rendering = 0, pendingRenders = [], pendingEffects = [];
1331
1343
  }
1332
1344
  runEffects(effects);
1333
1345
  }
1334
1346
  function prepareEffects(fn) {
1335
- let prevRenders = pendingRenders, prevRendersLookup = pendingRendersLookup, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
1336
- pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map();
1347
+ let prevRenders = pendingRenders, prevEffects = pendingEffects, prevLookup = asyncRendersLookup, preparedEffects = pendingEffects = [];
1348
+ pendingRenders = [], asyncRendersLookup = pendingRendersLookup, pendingRendersLookup = /* @__PURE__ */ new Map();
1337
1349
  try {
1338
1350
  rendering = 1, fn(), runRenders();
1339
1351
  } finally {
1340
- rendering = 0, pendingRenders = prevRenders, pendingRendersLookup = prevRendersLookup, pendingEffects = prevEffects;
1352
+ rendering = 0, pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = prevLookup, pendingRenders = prevRenders, pendingEffects = prevEffects;
1341
1353
  }
1342
1354
  return preparedEffects;
1343
1355
  }
@@ -1349,22 +1361,22 @@ function runRenders() {
1349
1361
  for (; pendingRenders.length; ) {
1350
1362
  let render = pendingRenders[0], item = pendingRenders.pop();
1351
1363
  if (render !== item) {
1352
- let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).f;
1364
+ let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).a;
1353
1365
  for (; i < mid; ) {
1354
1366
  let bestChild = (i << 1) + 1, right = bestChild + 1;
1355
- if (right < pendingRenders.length && pendingRenders[right].f - pendingRenders[bestChild].f < 0 && (bestChild = right), pendingRenders[bestChild].f - key >= 0)
1367
+ if (right < pendingRenders.length && pendingRenders[right].a - pendingRenders[bestChild].a < 0 && (bestChild = right), pendingRenders[bestChild].a - key >= 0)
1356
1368
  break;
1357
1369
  pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1358
1370
  }
1359
1371
  pendingRenders[i] = item;
1360
1372
  }
1361
- render.k.F?.I || runRender(render);
1373
+ render.g.F?.I || runRender(render);
1362
1374
  }
1363
1375
  for (let scope of pendingScopes)
1364
1376
  scope.H = 0;
1365
1377
  pendingScopes = [];
1366
1378
  }
1367
- var runRender = (render) => render.x(render.k, render.q), _enable_catch = () => {
1379
+ var runRender = (render) => render.u(render.g, render.o), _enable_catch = () => {
1368
1380
  _enable_catch = () => {
1369
1381
  }, enableBranches();
1370
1382
  let handlePendingTry = (fn, scope, branch) => {
@@ -1383,9 +1395,18 @@ var runRender = (render) => render.x(render.k, render.q), _enable_catch = () =>
1383
1395
  runEffects2(effects);
1384
1396
  })(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
1385
1397
  try {
1398
+ let branch = render.g.F;
1399
+ for (; branch; ) {
1400
+ if (branch.W)
1401
+ return asyncRendersLookup.set(
1402
+ render.a,
1403
+ render
1404
+ ), branch.W.push(render);
1405
+ branch = branch.N;
1406
+ }
1386
1407
  runRender2(render);
1387
1408
  } catch (error) {
1388
- renderCatch(render.k, error);
1409
+ renderCatch(render.g, error);
1389
1410
  }
1390
1411
  })(runRender);
1391
1412
  };
@@ -1458,7 +1479,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1458
1479
  renderer,
1459
1480
  renderer.e,
1460
1481
  document.body
1461
- )), renderer.a?.(branch, renderer._ ? args[0] : args);
1482
+ )), renderer.b?.(branch, renderer._ ? args[0] : args);
1462
1483
  }), created)
1463
1484
  return toInsertNode(
1464
1485
  branch.S,
@@ -1498,7 +1519,7 @@ function mount(input = {}, reference, position) {
1498
1519
  parentNode = reference.parentNode, nextSibling = reference.nextSibling;
1499
1520
  break;
1500
1521
  }
1501
- let curValue, args = this.a, effects = prepareEffects(() => {
1522
+ let curValue, args = this.b, effects = prepareEffects(() => {
1502
1523
  branch = createBranch(
1503
1524
  $global,
1504
1525
  this,