marko 6.0.119 → 6.0.120

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.js CHANGED
@@ -179,7 +179,7 @@ function normalizeDynamicRenderer(value) {
179
179
  if (value) {
180
180
  if (typeof value == "string") return value;
181
181
  let normalized = value.content || value.default || value;
182
- if (/* @__KEY__ */ "g" in normalized)
182
+ if (/* @__KEY__ */ "f" in normalized)
183
183
  return normalized;
184
184
  }
185
185
  }
@@ -237,6 +237,13 @@ function stripSpacesAndPunctuation(str) {
237
237
  return str.replace(/[^\p{L}\p{N}]/gu, "");
238
238
  }
239
239
 
240
+ // src/dom/parse-html.ts
241
+ var parsers = {};
242
+ function parseHTML(html, ns) {
243
+ let parser = parsers[ns] ||= document.createElementNS(ns, "template");
244
+ return parser.innerHTML = html, parser.content || parser;
245
+ }
246
+
240
247
  // src/dom/scope.ts
241
248
  var nextScopeId = 1e6;
242
249
  function createScope($global, closestBranch) {
@@ -292,6 +299,133 @@ function tempDetachBranch(branch) {
292
299
  );
293
300
  }
294
301
 
302
+ // src/dom/schedule.ts
303
+ var isScheduled, channel;
304
+ function schedule() {
305
+ isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
306
+ }
307
+ function flushAndWaitFrame() {
308
+ run(), requestAnimationFrame(triggerMacroTask);
309
+ }
310
+ function triggerMacroTask() {
311
+ channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
312
+ isScheduled = 0, run();
313
+ }), channel.port2.postMessage(0);
314
+ }
315
+
316
+ // src/dom/signals.ts
317
+ function _let(id, fn) {
318
+ let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" /* TagVariableChange */ + valueAccessor;
319
+ 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);
320
+ }
321
+ function _const(valueAccessor, fn) {
322
+ return valueAccessor = decodeAccessor(valueAccessor), (scope, value) => {
323
+ (!(valueAccessor in scope) || scope[valueAccessor] !== value) && (scope[valueAccessor] = value, fn?.(scope));
324
+ };
325
+ }
326
+ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L" /* Id */) {
327
+ return (scope) => {
328
+ scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
329
+ };
330
+ }
331
+ function _for_closure(ownerLoopNodeAccessor, fn) {
332
+ ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
333
+ let scopeAccessor = "A" /* BranchScopes */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
334
+ let scopes = toArray(ownerScope[scopeAccessor]);
335
+ scopes.length && queueRender(
336
+ ownerScope,
337
+ () => {
338
+ for (let scope of scopes)
339
+ !scope.H && !scope.I && fn(scope);
340
+ },
341
+ -1,
342
+ 0,
343
+ scopes[0].L
344
+ );
345
+ };
346
+ return ownerSignal._ = fn, ownerSignal;
347
+ }
348
+ function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
349
+ ownerConditionalNodeAccessor = decodeAccessor(
350
+ ownerConditionalNodeAccessor
351
+ );
352
+ let scopeAccessor = "A" /* BranchScopes */ + ownerConditionalNodeAccessor, branchAccessor = "D" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
353
+ let ifScope = scope[scopeAccessor];
354
+ ifScope && !ifScope.H && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
355
+ };
356
+ return ownerSignal._ = fn, ownerSignal;
357
+ }
358
+ function subscribeToScopeSet(ownerScope, accessor, scope) {
359
+ let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
360
+ subscribers.has(scope) || (subscribers.add(scope), $signal(scope, -1).addEventListener(
361
+ "abort",
362
+ () => ownerScope[accessor].delete(scope)
363
+ ));
364
+ }
365
+ function _closure(...closureSignals) {
366
+ let [{ k: ___scopeInstancesAccessor, l: ___signalIndexAccessor }] = closureSignals;
367
+ for (let i = closureSignals.length; i--; )
368
+ closureSignals[i].q = i;
369
+ return (scope) => {
370
+ if (scope[___scopeInstancesAccessor])
371
+ for (let childScope of scope[___scopeInstancesAccessor])
372
+ childScope.H || queueRender(
373
+ childScope,
374
+ closureSignals[childScope[___signalIndexAccessor]],
375
+ -1
376
+ );
377
+ };
378
+ }
379
+ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
380
+ valueAccessor = decodeAccessor(valueAccessor);
381
+ let closureSignal = ((scope) => {
382
+ scope[closureSignal.l] = closureSignal.q, fn(scope), subscribeToScopeSet(
383
+ getOwnerScope ? getOwnerScope(scope) : scope._,
384
+ closureSignal.k,
385
+ scope
386
+ );
387
+ });
388
+ return closureSignal.k = "B" /* ClosureScopes */ + valueAccessor, closureSignal.l = "C" /* ClosureSignalIndex */ + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
389
+ }
390
+ function _child_setup(setup) {
391
+ return setup._ = (scope, owner) => {
392
+ scope._ = owner, queueRender(scope, setup, -1);
393
+ }, setup;
394
+ }
395
+ function _var(scope, childAccessor, signal) {
396
+ scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
397
+ }
398
+ var _return = (scope, value) => scope.T?.(value);
399
+ function _return_change(scope, changeHandler) {
400
+ changeHandler && (scope.U = changeHandler);
401
+ }
402
+ var _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
403
+ function _id({ ["$" /* Global */]: $global }) {
404
+ let id = tagIdsByGlobal.get($global) || 0;
405
+ return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
406
+ }
407
+ function _script(id, fn) {
408
+ return _resume(id, fn), (scope) => {
409
+ queueEffect(scope, fn);
410
+ };
411
+ }
412
+ function _el_read(value) {
413
+ return rendering && void 0, value;
414
+ }
415
+ function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
416
+ if (scope)
417
+ if (Symbol.iterator in scope)
418
+ for (let s of scope instanceof Map ? scope.values() : scope)
419
+ yield* traverseAllHoisted(s, path, curIndex);
420
+ else curIndex ? yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1) : yield scope[path[0]];
421
+ }
422
+ function _hoist(...path) {
423
+ return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
424
+ let getOne = (...args) => iterator().next().value?.(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
425
+ return getOne;
426
+ };
427
+ }
428
+
295
429
  // src/dom/walker.ts
296
430
  var walker = /* @__PURE__ */ document.createTreeWalker(document);
297
431
  function walk(startNode, walkCodes, branch) {
@@ -334,6 +468,79 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
334
468
  }
335
469
  }
336
470
 
471
+ // src/dom/renderer.ts
472
+ function createBranch($global, renderer, parentScope, parentNode) {
473
+ let branch = createScope($global);
474
+ return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.h?.(
475
+ branch,
476
+ parentNode.namespaceURI
477
+ ), branch;
478
+ }
479
+ function setParentBranch(branch, parentBranch) {
480
+ parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
481
+ }
482
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
483
+ return setupBranch(
484
+ renderer,
485
+ createBranch($global, renderer, parentScope, parentNode)
486
+ );
487
+ }
488
+ function setupBranch(renderer, branch) {
489
+ return renderer.j && queueRender(branch, renderer.j, -1), branch;
490
+ }
491
+ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
492
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
493
+ let clone = template ? (branch, ns) => {
494
+ ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
495
+ template,
496
+ ns
497
+ ))(branch, walks);
498
+ } : (branch) => {
499
+ walk(
500
+ branch.S = branch.K = new Text(),
501
+ walks,
502
+ branch
503
+ );
504
+ };
505
+ return (owner) => ({
506
+ f: id,
507
+ h: clone,
508
+ e: owner,
509
+ j: setup,
510
+ b: params,
511
+ d: dynamicScopesAccessor
512
+ });
513
+ }
514
+ function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
515
+ return _resume(
516
+ id,
517
+ _content(id, template, walks, setup, params, dynamicScopesAccessor)
518
+ );
519
+ }
520
+ function _content_closures(renderer, closureFns) {
521
+ let closureSignals = {};
522
+ for (let key in closureFns)
523
+ closureSignals[key] = _const(+key, closureFns[key]);
524
+ return (owner, closureValues) => {
525
+ let instance = renderer(owner);
526
+ return instance.n = closureSignals, instance.t = closureValues, instance;
527
+ };
528
+ }
529
+ var cloneCache = {};
530
+ function createCloneableHTML(html, ns) {
531
+ let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
532
+ return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
533
+ walk(
534
+ branch.S = branch.K = firstChild.cloneNode(!0),
535
+ walks,
536
+ branch
537
+ );
538
+ } : (branch, walks) => {
539
+ let clone = parent.cloneNode(!0);
540
+ walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
541
+ };
542
+ }
543
+
337
544
  // src/dom/resume.ts
338
545
  var registeredValues = {}, branchesEnabled;
339
546
  function enableBranches() {
@@ -345,7 +552,7 @@ function init(runtimeId = "M") {
345
552
  value: resumeRender = ((renderId) => {
346
553
  let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, serializeContext = {
347
554
  _: registeredValues
348
- }, visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, childBranch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
555
+ }, visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
349
556
  for (visitType !== "[" /* BranchStart */ && (visitScope["J" /* Getter */ + nextToken(
350
557
  /* read accessor */
351
558
  )] = /* @__PURE__ */ ((node) => () => node)(
@@ -357,7 +564,7 @@ function init(runtimeId = "M") {
357
564
  branch = scopeLookup[branchId] ||= {
358
565
  L: branchId
359
566
  }
360
- ), branch.F = branch, singleNode) {
567
+ ), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
361
568
  for (; startVisit.previousSibling && ~visits.indexOf(
362
569
  startVisit = startVisit.previousSibling
363
570
  ); ) ;
@@ -365,9 +572,7 @@ function init(runtimeId = "M") {
365
572
  } else
366
573
  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);
367
574
  for (; i && orphanBranches[--i].L > branchId; )
368
- (childBranch = orphanBranches.pop()).N = branch, (branch.D ||= /* @__PURE__ */ new Set()).add(
369
- childBranch
370
- );
575
+ setParentBranch(orphanBranches.pop(), branch);
371
576
  nextToken(
372
577
  /* read optional next branchId */
373
578
  );
@@ -621,210 +826,6 @@ function toValueProp(it) {
621
826
  return it.value;
622
827
  }
623
828
 
624
- // src/dom/parse-html.ts
625
- var parsers = {};
626
- function parseHTML(html, ns) {
627
- let parser = parsers[ns] ||= document.createElementNS(ns, "template");
628
- return parser.innerHTML = html, parser.content || parser;
629
- }
630
-
631
- // src/dom/schedule.ts
632
- var isScheduled, channel;
633
- function schedule() {
634
- isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
635
- }
636
- function flushAndWaitFrame() {
637
- run(), requestAnimationFrame(triggerMacroTask);
638
- }
639
- function triggerMacroTask() {
640
- channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
641
- isScheduled = 0, run();
642
- }), channel.port2.postMessage(0);
643
- }
644
-
645
- // src/dom/signals.ts
646
- function _let(id, fn) {
647
- let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" /* TagVariableChange */ + valueAccessor;
648
- 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);
649
- }
650
- function _const(valueAccessor, fn) {
651
- return valueAccessor = decodeAccessor(valueAccessor), (scope, value) => {
652
- (!(valueAccessor in scope) || scope[valueAccessor] !== value) && (scope[valueAccessor] = value, fn?.(scope));
653
- };
654
- }
655
- function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L" /* Id */) {
656
- return (scope) => {
657
- scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
658
- };
659
- }
660
- function _for_closure(ownerLoopNodeAccessor, fn) {
661
- ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
662
- let scopeAccessor = "A" /* BranchScopes */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
663
- let scopes = toArray(ownerScope[scopeAccessor]);
664
- scopes.length && queueRender(
665
- ownerScope,
666
- () => {
667
- for (let scope of scopes)
668
- !scope.H && !scope.I && fn(scope);
669
- },
670
- -1,
671
- 0,
672
- scopes[0].L
673
- );
674
- };
675
- return ownerSignal._ = fn, ownerSignal;
676
- }
677
- function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
678
- ownerConditionalNodeAccessor = decodeAccessor(
679
- ownerConditionalNodeAccessor
680
- );
681
- let scopeAccessor = "A" /* BranchScopes */ + ownerConditionalNodeAccessor, branchAccessor = "D" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
682
- let ifScope = scope[scopeAccessor];
683
- ifScope && !ifScope.H && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
684
- };
685
- return ownerSignal._ = fn, ownerSignal;
686
- }
687
- function subscribeToScopeSet(ownerScope, accessor, scope) {
688
- let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
689
- subscribers.has(scope) || (subscribers.add(scope), $signal(scope, -1).addEventListener(
690
- "abort",
691
- () => ownerScope[accessor].delete(scope)
692
- ));
693
- }
694
- function _closure(...closureSignals) {
695
- let [{ l: ___scopeInstancesAccessor, n: ___signalIndexAccessor }] = closureSignals;
696
- for (let i = closureSignals.length; i--; )
697
- closureSignals[i].t = i;
698
- return (scope) => {
699
- if (scope[___scopeInstancesAccessor])
700
- for (let childScope of scope[___scopeInstancesAccessor])
701
- childScope.H || queueRender(
702
- childScope,
703
- closureSignals[childScope[___signalIndexAccessor]],
704
- -1
705
- );
706
- };
707
- }
708
- function _closure_get(valueAccessor, fn, getOwnerScope) {
709
- valueAccessor = decodeAccessor(valueAccessor);
710
- let closureSignal = ((scope) => {
711
- scope[closureSignal.n] = closureSignal.t, fn(scope), subscribeToScopeSet(
712
- getOwnerScope ? getOwnerScope(scope) : scope._,
713
- closureSignal.l,
714
- scope
715
- );
716
- });
717
- return closureSignal.l = "B" /* ClosureScopes */ + valueAccessor, closureSignal.n = "C" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
718
- }
719
- function _child_setup(setup) {
720
- return setup._ = (scope, owner) => {
721
- scope._ = owner, queueRender(scope, setup, -1);
722
- }, setup;
723
- }
724
- function _var(scope, childAccessor, signal) {
725
- scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
726
- }
727
- var _return = (scope, value) => scope.T?.(value);
728
- function _return_change(scope, changeHandler) {
729
- changeHandler && (scope.U = changeHandler);
730
- }
731
- var _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
732
- function _id({ ["$" /* Global */]: $global }) {
733
- let id = tagIdsByGlobal.get($global) || 0;
734
- return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
735
- }
736
- function _script(id, fn) {
737
- return _resume(id, fn), (scope) => {
738
- queueEffect(scope, fn);
739
- };
740
- }
741
- function _el_read(value) {
742
- return rendering && void 0, value;
743
- }
744
- function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
745
- if (scope)
746
- if (Symbol.iterator in scope)
747
- for (let s of scope instanceof Map ? scope.values() : scope)
748
- yield* traverseAllHoisted(s, path, curIndex);
749
- else curIndex ? yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1) : yield scope[path[0]];
750
- }
751
- function _hoist(...path) {
752
- return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
753
- let getOne = (...args) => iterator().next().value?.(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
754
- return getOne;
755
- };
756
- }
757
-
758
- // src/dom/renderer.ts
759
- function createBranch($global, renderer, parentScope, parentNode) {
760
- let branch = createScope($global), parentBranch = parentScope?.F;
761
- return branch._ = renderer.e || parentScope, branch.F = branch, parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), renderer.h?.(
762
- branch,
763
- parentNode.namespaceURI
764
- ), branch;
765
- }
766
- function createAndSetupBranch($global, renderer, parentScope, parentNode) {
767
- return setupBranch(
768
- renderer,
769
- createBranch($global, renderer, parentScope, parentNode)
770
- );
771
- }
772
- function setupBranch(renderer, branch) {
773
- return renderer.j && queueRender(branch, renderer.j, -1), branch;
774
- }
775
- function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
776
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
777
- let clone = template ? (branch, ns) => {
778
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
779
- template,
780
- ns
781
- ))(branch, walks);
782
- } : (branch) => {
783
- walk(
784
- branch.S = branch.K = new Text(),
785
- walks,
786
- branch
787
- );
788
- };
789
- return (owner) => ({
790
- g: id,
791
- h: clone,
792
- e: owner,
793
- j: setup,
794
- a: params,
795
- b: dynamicScopesAccessor
796
- });
797
- }
798
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
799
- return _resume(
800
- id,
801
- _content(id, template, walks, setup, params, dynamicScopesAccessor)
802
- );
803
- }
804
- function _content_closures(renderer, closureFns) {
805
- let closureSignals = {};
806
- for (let key in closureFns)
807
- closureSignals[key] = _const(+key, closureFns[key]);
808
- return (owner, closureValues) => {
809
- let instance = renderer(owner);
810
- return instance.o = closureSignals, instance.u = closureValues, instance;
811
- };
812
- }
813
- var cloneCache = {};
814
- function createCloneableHTML(html, ns) {
815
- let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
816
- return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
817
- walk(
818
- branch.S = branch.K = firstChild.cloneNode(!0),
819
- walks,
820
- branch
821
- );
822
- } : (branch, walks) => {
823
- let clone = parent.cloneNode(!0);
824
- walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
825
- };
826
- }
827
-
828
829
  // src/dom/dom.ts
829
830
  function _to_text(value) {
830
831
  return value || value === 0 ? value + "" : "";
@@ -967,9 +968,9 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
967
968
  }
968
969
  function _attr_content(scope, nodeAccessor, value) {
969
970
  let content = normalizeClientRender(value), rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
970
- scope[rendererAccessor] !== (scope[rendererAccessor] = content?.g) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.b && subscribeToScopeSet(
971
+ scope[rendererAccessor] !== (scope[rendererAccessor] = content?.f) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.d && subscribeToScopeSet(
971
972
  content.e,
972
- content.b,
973
+ content.d,
973
974
  scope["A" /* BranchScopes */ + nodeAccessor]
974
975
  ));
975
976
  }
@@ -1009,7 +1010,7 @@ function _html(scope, value, accessor) {
1009
1010
  }
1010
1011
  function normalizeClientRender(value) {
1011
1012
  let renderer = normalizeDynamicRenderer(value);
1012
- if (renderer && renderer.g)
1013
+ if (renderer && renderer.f)
1013
1014
  return renderer;
1014
1015
  }
1015
1016
  function normalizeAttrValue(value) {
@@ -1121,93 +1122,102 @@ function longestIncreasingSubsequence(a) {
1121
1122
  // src/dom/control-flow.ts
1122
1123
  function _await_promise(nodeAccessor, params) {
1123
1124
  nodeAccessor = decodeAccessor(nodeAccessor);
1124
- let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
1125
+ let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor;
1125
1126
  return _enable_catch(), (scope, promise) => {
1126
- let awaitCounter, renderData, tryWithPlaceholder = findBranchWithKey(
1127
- scope,
1128
- "Q" /* PlaceholderContent */
1129
- );
1130
- tryWithPlaceholder ? (renderData = self[tryWithPlaceholder.$.runtimeId]?.[tryWithPlaceholder.$.renderId], awaitCounter = tryWithPlaceholder.O ||= renderData?.p?.[tryWithPlaceholder.L], awaitCounter?.i || (awaitCounter = tryWithPlaceholder.O = {
1131
- d: 1,
1127
+ let awaitBranch = scope[branchAccessor], tryBranch = findBranchWithKey(scope, "Q" /* PlaceholderContent */) || awaitBranch, awaitCounter = tryBranch.O;
1128
+ awaitCounter?.i || (awaitCounter = tryBranch.O = {
1132
1129
  i: 0,
1133
1130
  c() {
1134
- if (!--awaitCounter.i) {
1135
- let placeholderBranch = tryWithPlaceholder.P;
1136
- tryWithPlaceholder.P = 0, placeholderBranch && (placeholderBranch.S.parentNode.insertBefore(
1137
- tryWithPlaceholder.S.parentNode,
1131
+ if (--awaitCounter.i) return 1;
1132
+ if (tryBranch === scope[branchAccessor])
1133
+ scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(
1134
+ scope[branchAccessor].S.parentNode
1135
+ );
1136
+ else {
1137
+ let placeholderBranch = tryBranch.P;
1138
+ placeholderBranch && (tryBranch.P = 0, placeholderBranch.S.parentNode.insertBefore(
1139
+ tryBranch.S.parentNode,
1138
1140
  placeholderBranch.S
1139
- ), removeAndDestroyBranch(placeholderBranch)), queueEffect(tryWithPlaceholder, (scope2) => {
1140
- let pendingEffects2 = scope2.J;
1141
- pendingEffects2 && (scope2.J = [], runEffects(pendingEffects2, !0));
1142
- });
1141
+ ), removeAndDestroyBranch(placeholderBranch));
1143
1142
  }
1143
+ queueEffect(tryBranch, (scope2) => {
1144
+ let pendingEffects2 = scope2.J;
1145
+ pendingEffects2 && (scope2.J = [], runEffects(pendingEffects2, 1));
1146
+ });
1144
1147
  }
1145
- }), placeholderShown.add(pendingEffects), !scope[promiseAccessor] && !awaitCounter.i++ && requestAnimationFrame(
1148
+ }), placeholderShown.add(pendingEffects), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(
1146
1149
  () => awaitCounter.i && runEffects(
1147
1150
  prepareEffects(
1148
1151
  () => queueRender(
1149
- tryWithPlaceholder,
1152
+ tryBranch === awaitBranch ? scope : tryBranch,
1150
1153
  () => {
1151
- insertBranchBefore(
1152
- tryWithPlaceholder.P = createAndSetupBranch(
1154
+ tryBranch.Q ? (insertBranchBefore(
1155
+ tryBranch.P = createAndSetupBranch(
1153
1156
  scope.$,
1154
- tryWithPlaceholder.Q,
1155
- tryWithPlaceholder._,
1156
- tryWithPlaceholder.S.parentNode
1157
+ tryBranch.Q,
1158
+ tryBranch._,
1159
+ tryBranch.S.parentNode
1157
1160
  ),
1158
- tryWithPlaceholder.S.parentNode,
1159
- tryWithPlaceholder.S
1160
- ), tempDetachBranch(tryWithPlaceholder);
1161
+ tryBranch.S.parentNode,
1162
+ tryBranch.S
1163
+ ), tempDetachBranch(tryBranch)) : awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(
1164
+ scope[nodeAccessor],
1165
+ awaitBranch.S
1166
+ ), tempDetachBranch(tryBranch));
1161
1167
  },
1162
1168
  -1
1163
1169
  )
1164
1170
  )
1165
1171
  )
1166
- )) : scope[branchAccessor] && !scope[promiseAccessor] && (scope[branchAccessor].S.parentNode.insertBefore(
1167
- scope[nodeAccessor],
1168
- scope[branchAccessor].S
1169
- ), tempDetachBranch(scope[branchAccessor]));
1172
+ ));
1170
1173
  let thisPromise = scope[promiseAccessor] = promise.then(
1171
1174
  (data) => {
1172
- thisPromise === scope[promiseAccessor] && (scope[promiseAccessor] = 0, schedule(), queueRender(
1173
- scope,
1174
- () => {
1175
- if (scope[branchAccessor] ? tryWithPlaceholder || scope[nodeAccessor].replaceWith(
1176
- scope[branchAccessor].S.parentNode
1177
- ) : (insertBranchBefore(
1178
- scope[branchAccessor] = createAndSetupBranch(
1179
- scope.$,
1180
- scope[rendererAccessor],
1181
- scope,
1182
- scope[nodeAccessor].parentNode
1183
- ),
1184
- scope[nodeAccessor].parentNode,
1185
- scope[nodeAccessor]
1186
- ), scope[nodeAccessor].remove()), params?.(scope[branchAccessor], [data]), awaitCounter && (placeholderShown.add(pendingEffects), awaitCounter.c(), !awaitCounter.d)) {
1187
- let fnScopes = /* @__PURE__ */ new Map(), effects = renderData.m();
1188
- for (let i = 0; i < pendingEffects.length; ) {
1189
- let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
1190
- scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
1191
- }
1192
- for (let i = 0; i < effects.length; ) {
1193
- let fn = effects[i++], scope2 = effects[i++];
1194
- fnScopes.get(fn)?.has(scope2) || queueEffect(scope2, fn);
1175
+ if (thisPromise === scope[promiseAccessor]) {
1176
+ let referenceNode = scope[nodeAccessor];
1177
+ scope[promiseAccessor] = 0, queueMicrotask(run), queueRender(
1178
+ scope,
1179
+ () => {
1180
+ (awaitBranch = scope[branchAccessor]).V && (pendingScopes.push(awaitBranch), setupBranch(
1181
+ awaitBranch.V,
1182
+ awaitBranch
1183
+ ), awaitBranch.V = 0, insertBranchBefore(
1184
+ awaitBranch,
1185
+ scope[nodeAccessor].parentNode,
1186
+ scope[nodeAccessor]
1187
+ ), referenceNode.remove()), params?.(awaitBranch, [data]);
1188
+ let pendingRenders2 = awaitBranch.W;
1189
+ if (awaitBranch.W = 0, pendingRenders2?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
1190
+ let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m();
1191
+ for (let i = 0; i < pendingEffects.length; ) {
1192
+ let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
1193
+ scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
1194
+ }
1195
+ for (let i = 0; i < effects.length; ) {
1196
+ let fn = effects[i++], scope2 = effects[i++];
1197
+ fnScopes.get(fn)?.has(scope2) || queueEffect(scope2, fn);
1198
+ }
1195
1199
  }
1196
- }
1197
- },
1198
- -1
1199
- ));
1200
+ },
1201
+ -1
1202
+ );
1203
+ }
1200
1204
  },
1201
1205
  (error) => {
1202
- thisPromise === scope[promiseAccessor] && (awaitCounter && (awaitCounter.i = 0), scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
1206
+ thisPromise === scope[promiseAccessor] && (awaitCounter.i = scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
1203
1207
  }
1204
1208
  );
1205
1209
  };
1206
1210
  }
1207
1211
  function _await_content(nodeAccessor, template, walks, setup) {
1208
- let rendererAccessor = "D" /* ConditionalRenderer */ + decodeAccessor(nodeAccessor), renderer = _content("", template, walks, setup)();
1212
+ nodeAccessor = decodeAccessor(nodeAccessor);
1213
+ let branchAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
1209
1214
  return (scope) => {
1210
- scope[rendererAccessor] = renderer;
1215
+ (scope[branchAccessor] = createBranch(
1216
+ scope.$,
1217
+ renderer,
1218
+ scope,
1219
+ scope[nodeAccessor].parentNode
1220
+ )).V = renderer, pendingScopes.pop();
1211
1221
  };
1212
1222
  }
1213
1223
  function _try(nodeAccessor, template, walks, setup) {
@@ -1235,7 +1245,7 @@ function renderCatch(scope, error) {
1235
1245
  tryWithCatch.C,
1236
1246
  tryWithCatch.E,
1237
1247
  createAndSetupBranch
1238
- ), tryWithCatch.E.a?.(
1248
+ ), tryWithCatch.E.b?.(
1239
1249
  owner["A" /* BranchScopes */ + tryWithCatch.C],
1240
1250
  [error]
1241
1251
  );
@@ -1271,7 +1281,7 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1271
1281
  let childScopeAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
1272
1282
  return enableBranches(), (scope, newRenderer, getInput) => {
1273
1283
  let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1274
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.g || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
1284
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.f || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
1275
1285
  if (setConditionalRenderer(
1276
1286
  scope,
1277
1287
  nodeAccessor,
@@ -1285,15 +1295,15 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1285
1295
  "a",
1286
1296
  content,
1287
1297
  createAndSetupBranch
1288
- ), content.b && subscribeToScopeSet(
1298
+ ), content.d && subscribeToScopeSet(
1289
1299
  content.e,
1290
- content.b,
1300
+ content.d,
1291
1301
  scope[childScopeAccessor]["Aa"]
1292
1302
  );
1293
1303
  }
1294
- } else normalizedRenderer?.b && subscribeToScopeSet(
1304
+ } else normalizedRenderer?.d && subscribeToScopeSet(
1295
1305
  normalizedRenderer.e,
1296
- normalizedRenderer.b,
1306
+ normalizedRenderer.d,
1297
1307
  scope[childScopeAccessor]
1298
1308
  );
1299
1309
  if (normalizedRenderer) {
@@ -1305,20 +1315,20 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1305
1315
  (inputIsArgs ? args[0] : args) || {}
1306
1316
  ), (childScope["Ia"] || childScope["Ea"]) && queueEffect(childScope, dynamicTagScript);
1307
1317
  else {
1308
- for (let accessor in normalizedRenderer.o)
1309
- normalizedRenderer.o[accessor](
1318
+ for (let accessor in normalizedRenderer.n)
1319
+ normalizedRenderer.n[accessor](
1310
1320
  childScope,
1311
- normalizedRenderer.u[accessor]
1321
+ normalizedRenderer.t[accessor]
1312
1322
  );
1313
- if (normalizedRenderer.a)
1323
+ if (normalizedRenderer.b)
1314
1324
  if (inputIsArgs)
1315
- normalizedRenderer.a(
1325
+ normalizedRenderer.b(
1316
1326
  childScope,
1317
1327
  normalizedRenderer._ ? args[0] : args
1318
1328
  );
1319
1329
  else {
1320
1330
  let inputWithContent = getContent ? { ...args, content: getContent(scope) } : args || {};
1321
- normalizedRenderer.a(
1331
+ normalizedRenderer.b(
1322
1332
  childScope,
1323
1333
  normalizedRenderer._ ? inputWithContent : [inputWithContent]
1324
1334
  );
@@ -1402,45 +1412,47 @@ function byFirstArg(name) {
1402
1412
  }
1403
1413
 
1404
1414
  // src/dom/queue.ts
1405
- var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
1415
+ var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), asyncRendersLookup, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
1406
1416
  function queueRender(scope, signal, signalKey, value, scopeKey = scope.L) {
1407
- let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
1408
- if (existingRender)
1409
- existingRender.q = value;
1410
- else {
1411
- let render = {
1412
- f: key,
1413
- k: scope,
1414
- x: signal,
1415
- q: value
1416
- }, i = pendingRenders.push(render) - 1;
1417
- for (; i; ) {
1418
- let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1419
- if (key - parent.f >= 0) break;
1420
- pendingRenders[i] = parent, i = parentIndex;
1417
+ let key = scopeKey * scopeKeyOffset + signalKey, render = signalKey >= 0 && pendingRendersLookup.get(key);
1418
+ render ? render.o = value : (queuePendingRender(
1419
+ render = {
1420
+ a: key,
1421
+ g: scope,
1422
+ u: signal,
1423
+ o: value
1421
1424
  }
1422
- signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
1425
+ ), signalKey >= 0 && pendingRendersLookup.set(key, render));
1426
+ }
1427
+ function queuePendingRender(render) {
1428
+ let i = pendingRenders.push(render) - 1;
1429
+ for (; i; ) {
1430
+ let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1431
+ if (render.a - parent.a >= 0) break;
1432
+ pendingRenders[i] = parent, i = parentIndex;
1423
1433
  }
1434
+ pendingRenders[i] = render;
1424
1435
  }
1425
1436
  function queueEffect(scope, fn) {
1426
1437
  pendingEffects.push(fn, scope);
1427
1438
  }
1428
1439
  function run() {
1429
1440
  let effects = pendingEffects;
1441
+ asyncRendersLookup = /* @__PURE__ */ new Map();
1430
1442
  try {
1431
1443
  rendering = 1, runRenders();
1432
1444
  } finally {
1433
- pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = 0;
1445
+ pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = rendering = 0, pendingRenders = [], pendingEffects = [];
1434
1446
  }
1435
1447
  runEffects(effects);
1436
1448
  }
1437
1449
  function prepareEffects(fn) {
1438
- let prevRenders = pendingRenders, prevRendersLookup = pendingRendersLookup, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
1439
- pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map();
1450
+ let prevRenders = pendingRenders, prevEffects = pendingEffects, prevLookup = asyncRendersLookup, preparedEffects = pendingEffects = [];
1451
+ pendingRenders = [], asyncRendersLookup = pendingRendersLookup, pendingRendersLookup = /* @__PURE__ */ new Map();
1440
1452
  try {
1441
1453
  rendering = 1, fn(), runRenders();
1442
1454
  } finally {
1443
- rendering = 0, pendingRenders = prevRenders, pendingRendersLookup = prevRendersLookup, pendingEffects = prevEffects;
1455
+ rendering = 0, pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = prevLookup, pendingRenders = prevRenders, pendingEffects = prevEffects;
1444
1456
  }
1445
1457
  return preparedEffects;
1446
1458
  }
@@ -1452,22 +1464,22 @@ function runRenders() {
1452
1464
  for (; pendingRenders.length; ) {
1453
1465
  let render = pendingRenders[0], item = pendingRenders.pop();
1454
1466
  if (render !== item) {
1455
- let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).f;
1467
+ let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).a;
1456
1468
  for (; i < mid; ) {
1457
1469
  let bestChild = (i << 1) + 1, right = bestChild + 1;
1458
- if (right < pendingRenders.length && pendingRenders[right].f - pendingRenders[bestChild].f < 0 && (bestChild = right), pendingRenders[bestChild].f - key >= 0)
1470
+ if (right < pendingRenders.length && pendingRenders[right].a - pendingRenders[bestChild].a < 0 && (bestChild = right), pendingRenders[bestChild].a - key >= 0)
1459
1471
  break;
1460
1472
  pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1461
1473
  }
1462
1474
  pendingRenders[i] = item;
1463
1475
  }
1464
- render.k.F?.I || runRender(render);
1476
+ render.g.F?.I || runRender(render);
1465
1477
  }
1466
1478
  for (let scope of pendingScopes)
1467
1479
  scope.H = 0;
1468
1480
  pendingScopes = [];
1469
1481
  }
1470
- var runRender = (render) => render.x(render.k, render.q), _enable_catch = () => {
1482
+ var runRender = (render) => render.u(render.g, render.o), _enable_catch = () => {
1471
1483
  _enable_catch = () => {
1472
1484
  }, enableBranches();
1473
1485
  let handlePendingTry = (fn, scope, branch) => {
@@ -1486,9 +1498,18 @@ var runRender = (render) => render.x(render.k, render.q), _enable_catch = () =>
1486
1498
  runEffects2(effects);
1487
1499
  })(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
1488
1500
  try {
1501
+ let branch = render.g.F;
1502
+ for (; branch; ) {
1503
+ if (branch.W)
1504
+ return asyncRendersLookup.set(
1505
+ render.a,
1506
+ render
1507
+ ), branch.W.push(render);
1508
+ branch = branch.N;
1509
+ }
1489
1510
  runRender2(render);
1490
1511
  } catch (error) {
1491
- renderCatch(render.k, error);
1512
+ renderCatch(render.g, error);
1492
1513
  }
1493
1514
  })(runRender);
1494
1515
  };
@@ -1561,7 +1582,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1561
1582
  renderer,
1562
1583
  renderer.e,
1563
1584
  document.body
1564
- )), renderer.a?.(branch, renderer._ ? args[0] : args);
1585
+ )), renderer.b?.(branch, renderer._ ? args[0] : args);
1565
1586
  }), created)
1566
1587
  return toInsertNode(
1567
1588
  branch.S,
@@ -1601,7 +1622,7 @@ function mount(input = {}, reference, position) {
1601
1622
  parentNode = reference.parentNode, nextSibling = reference.nextSibling;
1602
1623
  break;
1603
1624
  }
1604
- let curValue, args = this.a, effects = prepareEffects(() => {
1625
+ let curValue, args = this.b, effects = prepareEffects(() => {
1605
1626
  branch = createBranch(
1606
1627
  $global,
1607
1628
  this,