marko 6.0.39 → 6.0.41

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
@@ -151,11 +151,11 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
151
151
  }
152
152
  }
153
153
  },
154
- o(scope) {
154
+ p(scope) {
155
155
  let parentBranchId = scope.g || parentBranchIds.get(scopeId);
156
156
  if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
157
157
  let branch = scope, parentBranch = branch.k;
158
- scope.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch));
158
+ scope.k = branch, parentBranch && (branch.y = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch));
159
159
  }
160
160
  }
161
161
  };
@@ -185,7 +185,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
185
185
  $global ? typeof scope == "number" ? lastScopeId += scope : (scopeId = ++lastScopeId, scope.$global = $global, scope.l = scopeId, scopeLookup[scopeId] !== scope && (scopeLookup[scopeId] = Object.assign(
186
186
  scope,
187
187
  scopeLookup[scopeId]
188
- )), branches && branches.o(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.p = 1e6);
188
+ )), branches && branches.p(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.q = 1e6);
189
189
  } finally {
190
190
  isResuming = visits.length = resumes.length = 0;
191
191
  }
@@ -410,6 +410,294 @@ function parseHTML(html2, ns) {
410
410
  return parser.innerHTML = html2, parser.content || parser;
411
411
  }
412
412
 
413
+ // src/dom/scope.ts
414
+ function createScope($global, closestBranch) {
415
+ let scope = {
416
+ l: $global.q++,
417
+ t: 1,
418
+ k: closestBranch,
419
+ $global
420
+ };
421
+ return pendingScopes.push(scope), scope;
422
+ }
423
+ function skipScope(scope) {
424
+ return scope.$global.q++;
425
+ }
426
+ function findBranchWithKey(scope, key) {
427
+ let branch = scope.k;
428
+ for (; branch && !branch[key]; )
429
+ branch = branch.y;
430
+ return branch;
431
+ }
432
+ function destroyBranch(branch) {
433
+ branch.y?.A?.delete(branch), destroyNestedBranches(branch);
434
+ }
435
+ function destroyNestedBranches(branch) {
436
+ branch.B = 1, branch.A?.forEach(destroyNestedBranches), branch.K?.forEach((scope) => {
437
+ for (let id in scope.z)
438
+ scope.z[id]?.abort();
439
+ });
440
+ }
441
+ function removeAndDestroyBranch(branch) {
442
+ destroyBranch(branch), removeChildNodes(branch.h, branch.j);
443
+ }
444
+ function insertBranchBefore(branch, parentNode, nextSibling) {
445
+ insertChildNodes(
446
+ parentNode,
447
+ nextSibling,
448
+ branch.h,
449
+ branch.j
450
+ );
451
+ }
452
+ function tempDetachBranch(branch) {
453
+ let fragment = new DocumentFragment();
454
+ fragment.namespaceURI = branch.h.parentNode.namespaceURI, insertChildNodes(fragment, null, branch.h, branch.j);
455
+ }
456
+
457
+ // src/dom/schedule.ts
458
+ var isScheduled, channel;
459
+ function schedule() {
460
+ isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
461
+ }
462
+ function flushAndWaitFrame() {
463
+ run(), requestAnimationFrame(triggerMacroTask);
464
+ }
465
+ function triggerMacroTask() {
466
+ channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
467
+ isScheduled = 0, run();
468
+ }), channel.port2.postMessage(0);
469
+ }
470
+
471
+ // src/dom/signals.ts
472
+ function state(valueAccessor, fn) {
473
+ if (0)
474
+ var id;
475
+ let valueChangeAccessor = "o" /* TagVariableChange */ + valueAccessor, update = (scope, value2) => {
476
+ scope[valueAccessor] !== value2 && (scope[valueAccessor] = value2, fn(scope, value2));
477
+ };
478
+ return (scope, value2, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value2 || !(valueAccessor in scope)) && (scope[valueAccessor] = value2, fn(scope, value2)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value2) : (schedule(), queueRender(
479
+ scope,
480
+ update,
481
+ valueAccessor,
482
+ value2
483
+ )), value2);
484
+ }
485
+ function value(valueAccessor, fn = () => {
486
+ }) {
487
+ return (scope, value2) => {
488
+ (!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
489
+ };
490
+ }
491
+ function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "l") {
492
+ return (scope) => {
493
+ scope.t ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
494
+ };
495
+ }
496
+ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
497
+ let childSignal = closure(valueAccessor, fn), loopScopeAccessor = "l" /* LoopScopeArray */ + ownerLoopNodeAccessor, loopScopeMapAccessor = "m" /* LoopScopeMap */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
498
+ let scopes = ownerScope[loopScopeAccessor] ||= ownerScope[loopScopeMapAccessor] ? [...ownerScope[loopScopeMapAccessor].values()] : [], [firstScope] = scopes;
499
+ firstScope && queueRender(
500
+ ownerScope,
501
+ () => {
502
+ for (let scope of scopes)
503
+ !scope.t && !scope.B && childSignal(scope);
504
+ },
505
+ -1,
506
+ 0,
507
+ firstScope.l
508
+ );
509
+ };
510
+ return ownerSignal._ = childSignal, ownerSignal;
511
+ }
512
+ function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
513
+ let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
514
+ let ifScope = scope[scopeAccessor];
515
+ ifScope && !ifScope.t && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
516
+ };
517
+ return ownerSignal._ = childSignal, ownerSignal;
518
+ }
519
+ function subscribeToScopeSet(ownerScope, accessor, scope) {
520
+ let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
521
+ subscribers.has(scope) || (subscribers.add(scope), getAbortSignal(scope, -1).addEventListener(
522
+ "abort",
523
+ () => ownerScope[accessor].delete(scope)
524
+ ));
525
+ }
526
+ function dynamicClosure(...closureSignals) {
527
+ let [{ E: ___scopeInstancesAccessor, F: ___signalIndexAccessor }] = closureSignals;
528
+ for (let i = closureSignals.length; i--; )
529
+ closureSignals[i].L = i;
530
+ return (scope) => {
531
+ if (scope[___scopeInstancesAccessor])
532
+ for (let childScope of scope[___scopeInstancesAccessor])
533
+ childScope.t || queueRender(
534
+ childScope,
535
+ closureSignals[childScope[___signalIndexAccessor]],
536
+ -1
537
+ );
538
+ };
539
+ }
540
+ function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
541
+ let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
542
+ scope[closureSignal.F] = closureSignal.L, childSignal(scope), subscribeToScopeSet(
543
+ getOwnerScope ? getOwnerScope(scope) : scope._,
544
+ closureSignal.E,
545
+ scope
546
+ );
547
+ };
548
+ return closureSignal.E = "a" /* ClosureScopes */ + valueAccessor, closureSignal.F = "b" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
549
+ }
550
+ function closure(valueAccessor, fn, getOwnerScope) {
551
+ return (scope) => {
552
+ fn(
553
+ scope,
554
+ (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
555
+ );
556
+ };
557
+ }
558
+ function setTagVar(scope, childAccessor, tagVarSignal2) {
559
+ scope[childAccessor].e = (value2) => tagVarSignal2(scope, value2);
560
+ }
561
+ var tagVarSignal = (scope, value2) => scope.e?.(value2);
562
+ function setTagVarChange(scope, changeHandler) {
563
+ scope.f = changeHandler;
564
+ }
565
+ var tagVarSignalChange = (scope, value2) => scope.f?.(value2), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
566
+ function nextTagId({ $global }) {
567
+ let id = tagIdsByGlobal.get($global) || 0;
568
+ return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
569
+ }
570
+ function effect(id, fn) {
571
+ return register(id, fn), (scope) => {
572
+ queueEffect(scope, fn);
573
+ };
574
+ }
575
+ function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
576
+ if (scope)
577
+ if (Symbol.iterator in scope)
578
+ for (let s of scope instanceof Map ? scope.values() : scope)
579
+ yield* traverseAllHoisted(s, path, curIndex);
580
+ else curIndex ? yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1) : yield scope[path[0]];
581
+ }
582
+ function hoist(...path) {
583
+ return (scope) => {
584
+ let getOne = (...args) => iterator().next().value(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
585
+ return getOne;
586
+ };
587
+ }
588
+
589
+ // src/dom/walker.ts
590
+ var walker = /* @__PURE__ */ document.createTreeWalker(document);
591
+ function walk(startNode, walkCodes, branch) {
592
+ walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
593
+ }
594
+ function walkInternal(currentWalkIndex, walkCodes, scope) {
595
+ let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
596
+ for (; currentWalkIndex < walkCodes.length; )
597
+ if (value2 = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 === 32 /* Get */) {
598
+ let node = walker.currentNode;
599
+ scope[currentScopeIndex] = node, scope["j" /* Getter */ + currentScopeIndex++] = () => node;
600
+ } else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */)
601
+ walker.currentNode.replaceWith(
602
+ walker.currentNode = scope[currentScopeIndex++] = new Text()
603
+ ), value2 === 49 /* DynamicTagWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
604
+ else {
605
+ if (value2 === 38 /* EndChild */)
606
+ return currentWalkIndex;
607
+ if (value2 === 47 /* BeginChild */ || value2 === 48 /* BeginChildWithVar */)
608
+ currentWalkIndex = walkInternal(
609
+ currentWalkIndex,
610
+ walkCodes,
611
+ scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
612
+ ), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
613
+ else if (value2 < 92)
614
+ for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
615
+ walker.nextNode();
616
+ else if (value2 < 107)
617
+ for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
618
+ walker.nextSibling();
619
+ else if (value2 < 117) {
620
+ for (value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */; value2--; )
621
+ walker.parentNode();
622
+ walker.nextSibling();
623
+ } else
624
+ storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
625
+ }
626
+ }
627
+
628
+ // src/dom/renderer.ts
629
+ function createBranch($global, renderer, parentScope, parentNode) {
630
+ let branch = createScope($global), parentBranch = parentScope?.k;
631
+ return branch._ = renderer.u || parentScope, branch.k = branch, parentBranch && (branch.y = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch)), renderer.C?.(
632
+ branch,
633
+ parentNode.namespaceURI
634
+ ), branch;
635
+ }
636
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
637
+ return setupBranch(
638
+ renderer,
639
+ createBranch($global, renderer, parentScope, parentNode)
640
+ );
641
+ }
642
+ function setupBranch(renderer, branch) {
643
+ return renderer.D && queueRender(branch, renderer.D, -1), branch;
644
+ }
645
+ function createContent(id, template, walks, setup, params, dynamicScopesAccessor) {
646
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
647
+ let clone = template ? (branch, ns) => {
648
+ ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
649
+ template,
650
+ ns
651
+ ))(branch, walks);
652
+ } : (branch) => {
653
+ walk(
654
+ branch.h = branch.j = new Text(),
655
+ walks,
656
+ branch
657
+ );
658
+ };
659
+ return (owner) => ({
660
+ l: id,
661
+ C: clone,
662
+ u: owner,
663
+ D: setup,
664
+ m: params,
665
+ n: dynamicScopesAccessor
666
+ });
667
+ }
668
+ function registerContent(id, template, walks, setup, params, dynamicScopesAccessor) {
669
+ return register(
670
+ id,
671
+ createContent(id, template, walks, setup, params, dynamicScopesAccessor)
672
+ );
673
+ }
674
+ function localClosures(renderer, closureFns) {
675
+ let closureSignals = {};
676
+ for (let key in closureFns)
677
+ closureSignals[key] = value(key, closureFns[key]);
678
+ return (owner, closureValues) => {
679
+ let instance = renderer(owner);
680
+ return instance.G = closureSignals, instance.M = closureValues, instance;
681
+ };
682
+ }
683
+ function createRenderer(template, walks, setup, params) {
684
+ return createContent("", template, walks, setup, params)();
685
+ }
686
+ var cloneCache = {};
687
+ function createCloneableHTML(html2, ns) {
688
+ let { firstChild, lastChild } = parseHTML(html2, ns), parent = document.createElementNS(ns, "t");
689
+ return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
690
+ walk(
691
+ branch.h = branch.j = firstChild.cloneNode(!0),
692
+ walks,
693
+ branch
694
+ );
695
+ } : (branch, walks) => {
696
+ let clone = parent.cloneNode(!0);
697
+ walk(clone.firstChild, walks, branch), branch.h = clone.firstChild, branch.j = clone.lastChild;
698
+ };
699
+ }
700
+
413
701
  // src/dom/dom.ts
414
702
  function attr(element, name, value2) {
415
703
  setAttribute(element, name, normalizeAttrValue(value2));
@@ -453,6 +741,9 @@ function attrs(scope, nodeAccessor, nextAttrs) {
453
741
  }
454
742
  attrsInternal(scope, nodeAccessor, nextAttrs);
455
743
  }
744
+ function attrsAndContent(scope, nodeAccessor, nextAttrs) {
745
+ attrs(scope, nodeAccessor, nextAttrs), insertContent(scope, nodeAccessor, nextAttrs?.content);
746
+ }
456
747
  function hasAttrAlias(element, attr2, nextAttrs) {
457
748
  return attr2 === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
458
749
  }
@@ -466,6 +757,9 @@ function partialAttrs(scope, nodeAccessor, nextAttrs, skip) {
466
757
  skip[key] || (partial[key] = nextAttrs[key]);
467
758
  attrsInternal(scope, nodeAccessor, partial);
468
759
  }
760
+ function partialAttrsAndContent(scope, nodeAccessor, nextAttrs, skip) {
761
+ partialAttrs(scope, nodeAccessor, nextAttrs, skip), insertContent(scope, nodeAccessor, nextAttrs?.content);
762
+ }
469
763
  function attrsInternal(scope, nodeAccessor, nextAttrs) {
470
764
  let el = scope[nodeAccessor], events, skip;
471
765
  switch (el.tagName) {
@@ -538,6 +832,14 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
538
832
  }
539
833
  }
540
834
  }
835
+ function insertContent(scope, nodeAccessor, value2) {
836
+ let content = normalizeClientRender(value2), rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
837
+ scope[rendererAccessor] !== (scope[rendererAccessor] = content?.l) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.n && subscribeToScopeSet(
838
+ content.u,
839
+ content.n,
840
+ scope["d" /* ConditionalScope */ + nodeAccessor]
841
+ ));
842
+ }
541
843
  function attrsEvents(scope, nodeAccessor) {
542
844
  let el = scope[nodeAccessor], events = scope["i" /* EventAttributes */ + nodeAccessor];
543
845
  switch (scope["f" /* ControlledType */ + nodeAccessor]) {
@@ -572,6 +874,11 @@ function html(scope, value2, accessor) {
572
874
  scope["h" /* DynamicPlaceholderLastChild */ + accessor] = newContent.lastChild
573
875
  ), removeChildNodes(firstChild, lastChild);
574
876
  }
877
+ function normalizeClientRender(value2) {
878
+ let renderer = normalizeDynamicRenderer(value2);
879
+ if (renderer && renderer.l)
880
+ return renderer;
881
+ }
575
882
  function props(scope, nodeIndex, index) {
576
883
  let nextProps = scope[index], prevProps = scope[index + "-"], node = scope[nodeIndex];
577
884
  if (prevProps)
@@ -596,67 +903,23 @@ function lifecycle(scope, index, thisObj) {
596
903
  ).onabort = () => thisObj.onDestroy?.());
597
904
  }
598
905
  function removeChildNodes(startNode, endNode) {
599
- let stop = endNode.nextSibling, current = startNode;
600
- for (; current !== stop; ) {
601
- let next = current.nextSibling;
602
- current.remove(), current = next;
603
- }
604
- }
605
- function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
606
- parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
607
- }
608
- function toInsertNode(startNode, endNode) {
609
- if (startNode === endNode) return startNode;
610
- let parent = new DocumentFragment(), stop = endNode.nextSibling, current = startNode;
611
- for (; current !== stop; ) {
612
- let next = current.nextSibling;
613
- parent.appendChild(current), current = next;
614
- }
615
- return parent;
616
- }
617
-
618
- // src/dom/scope.ts
619
- function createScope($global, closestBranch) {
620
- let scope = {
621
- l: $global.p++,
622
- q: 1,
623
- k: closestBranch,
624
- $global
625
- };
626
- return pendingScopes.push(scope), scope;
627
- }
628
- function skipScope(scope) {
629
- return scope.$global.p++;
630
- }
631
- function findBranchWithKey(scope, key) {
632
- let branch = scope.k;
633
- for (; branch && !branch[key]; )
634
- branch = branch.u;
635
- return branch;
636
- }
637
- function destroyBranch(branch) {
638
- branch.u?.A?.delete(branch), destroyNestedBranches(branch);
639
- }
640
- function destroyNestedBranches(branch) {
641
- branch.B = 1, branch.A?.forEach(destroyNestedBranches), branch.K?.forEach((scope) => {
642
- for (let id in scope.x)
643
- scope.x[id]?.abort();
644
- });
645
- }
646
- function removeAndDestroyBranch(branch) {
647
- destroyBranch(branch), removeChildNodes(branch.h, branch.j);
648
- }
649
- function insertBranchBefore(branch, parentNode, nextSibling) {
650
- insertChildNodes(
651
- parentNode,
652
- nextSibling,
653
- branch.h,
654
- branch.j
655
- );
906
+ let stop = endNode.nextSibling, current = startNode;
907
+ for (; current !== stop; ) {
908
+ let next = current.nextSibling;
909
+ current.remove(), current = next;
910
+ }
656
911
  }
657
- function tempDetachBranch(branch) {
658
- let fragment = new DocumentFragment();
659
- fragment.namespaceURI = branch.h.parentNode.namespaceURI, insertChildNodes(fragment, null, branch.h, branch.j);
912
+ function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
913
+ parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
914
+ }
915
+ function toInsertNode(startNode, endNode) {
916
+ if (startNode === endNode) return startNode;
917
+ let parent = new DocumentFragment(), stop = endNode.nextSibling, current = startNode;
918
+ for (; current !== stop; ) {
919
+ let next = current.nextSibling;
920
+ parent.appendChild(current), current = next;
921
+ }
922
+ return parent;
660
923
  }
661
924
 
662
925
  // src/dom/reconcile.ts
@@ -734,250 +997,6 @@ function longestIncreasingSubsequence(a) {
734
997
  return result;
735
998
  }
736
999
 
737
- // src/dom/schedule.ts
738
- var isScheduled, channel;
739
- function schedule() {
740
- isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
741
- }
742
- function flushAndWaitFrame() {
743
- run(), requestAnimationFrame(triggerMacroTask);
744
- }
745
- function triggerMacroTask() {
746
- channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
747
- isScheduled = 0, run();
748
- }), channel.port2.postMessage(0);
749
- }
750
-
751
- // src/dom/signals.ts
752
- function state(valueAccessor, fn) {
753
- if (0)
754
- var id;
755
- let valueChangeAccessor = "o" /* TagVariableChange */ + valueAccessor, update = (scope, value2) => {
756
- scope[valueAccessor] !== value2 && (scope[valueAccessor] = value2, fn(scope, value2));
757
- };
758
- return (scope, value2, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value2 || !(valueAccessor in scope)) && (scope[valueAccessor] = value2, fn(scope, value2)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value2) : (schedule(), queueRender(
759
- scope,
760
- update,
761
- valueAccessor,
762
- value2
763
- )), value2);
764
- }
765
- function value(valueAccessor, fn = () => {
766
- }) {
767
- return (scope, value2) => {
768
- (!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
769
- };
770
- }
771
- function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "l") {
772
- return (scope) => {
773
- scope.q ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
774
- };
775
- }
776
- function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
777
- let childSignal = closure(valueAccessor, fn), loopScopeAccessor = "l" /* LoopScopeArray */ + ownerLoopNodeAccessor, loopScopeMapAccessor = "m" /* LoopScopeMap */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
778
- let scopes = ownerScope[loopScopeAccessor] ||= ownerScope[loopScopeMapAccessor] ? [...ownerScope[loopScopeMapAccessor].values()] : [], [firstScope] = scopes;
779
- firstScope && queueRender(
780
- ownerScope,
781
- () => {
782
- for (let scope of scopes)
783
- !scope.q && !scope.B && childSignal(scope);
784
- },
785
- -1,
786
- 0,
787
- firstScope.l
788
- );
789
- };
790
- return ownerSignal._ = childSignal, ownerSignal;
791
- }
792
- function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
793
- let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
794
- let ifScope = scope[scopeAccessor];
795
- ifScope && !ifScope.q && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
796
- };
797
- return ownerSignal._ = childSignal, ownerSignal;
798
- }
799
- function subscribeToScopeSet(ownerScope, accessor, scope) {
800
- let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
801
- subscribers.has(scope) || (subscribers.add(scope), getAbortSignal(scope, -1).addEventListener(
802
- "abort",
803
- () => ownerScope[accessor].delete(scope)
804
- ));
805
- }
806
- function dynamicClosure(...closureSignals) {
807
- let [{ E: ___scopeInstancesAccessor, F: ___signalIndexAccessor }] = closureSignals;
808
- for (let i = closureSignals.length; i--; )
809
- closureSignals[i].L = i;
810
- return (scope) => {
811
- if (scope[___scopeInstancesAccessor])
812
- for (let childScope of scope[___scopeInstancesAccessor])
813
- childScope.q || queueRender(
814
- childScope,
815
- closureSignals[childScope[___signalIndexAccessor]],
816
- -1
817
- );
818
- };
819
- }
820
- function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
821
- let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
822
- scope[closureSignal.F] = closureSignal.L, childSignal(scope), subscribeToScopeSet(
823
- getOwnerScope ? getOwnerScope(scope) : scope._,
824
- closureSignal.E,
825
- scope
826
- );
827
- };
828
- return closureSignal.E = "a" /* ClosureScopes */ + valueAccessor, closureSignal.F = "b" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
829
- }
830
- function closure(valueAccessor, fn, getOwnerScope) {
831
- return (scope) => {
832
- fn(
833
- scope,
834
- (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
835
- );
836
- };
837
- }
838
- function setTagVar(scope, childAccessor, tagVarSignal2) {
839
- scope[childAccessor].e = (value2) => tagVarSignal2(scope, value2);
840
- }
841
- var tagVarSignal = (scope, value2) => scope.e?.(value2);
842
- function setTagVarChange(scope, changeHandler) {
843
- scope.f = changeHandler;
844
- }
845
- var tagVarSignalChange = (scope, value2) => scope.f?.(value2), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
846
- function nextTagId({ $global }) {
847
- let id = tagIdsByGlobal.get($global) || 0;
848
- return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
849
- }
850
- function effect(id, fn) {
851
- return register(id, fn), (scope) => {
852
- queueEffect(scope, fn);
853
- };
854
- }
855
- function* traverseAllHoisted(scope, path, curIndex = path.length - 1) {
856
- if (scope)
857
- if (Symbol.iterator in scope)
858
- for (let s of scope instanceof Map ? scope.values() : scope)
859
- yield* traverseAllHoisted(s, path, curIndex);
860
- else curIndex ? yield* traverseAllHoisted(scope[path[curIndex]], path, curIndex - 1) : yield scope[path[0]];
861
- }
862
- function hoist(...path) {
863
- return (scope) => {
864
- let getOne = (...args) => iterator().next().value(...args), iterator = getOne[Symbol.iterator] = () => traverseAllHoisted(scope, path);
865
- return getOne;
866
- };
867
- }
868
-
869
- // src/dom/walker.ts
870
- var walker = /* @__PURE__ */ document.createTreeWalker(document);
871
- function walk(startNode, walkCodes, branch) {
872
- walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
873
- }
874
- function walkInternal(currentWalkIndex, walkCodes, scope) {
875
- let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
876
- for (; currentWalkIndex < walkCodes.length; )
877
- if (value2 = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 === 32 /* Get */) {
878
- let node = walker.currentNode;
879
- scope[currentScopeIndex] = node, scope["j" /* Getter */ + currentScopeIndex++] = () => node;
880
- } else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */)
881
- walker.currentNode.replaceWith(
882
- walker.currentNode = scope[currentScopeIndex++] = new Text()
883
- ), value2 === 49 /* DynamicTagWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
884
- else {
885
- if (value2 === 38 /* EndChild */)
886
- return currentWalkIndex;
887
- if (value2 === 47 /* BeginChild */ || value2 === 48 /* BeginChildWithVar */)
888
- currentWalkIndex = walkInternal(
889
- currentWalkIndex,
890
- walkCodes,
891
- scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
892
- ), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
893
- else if (value2 < 92)
894
- for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
895
- walker.nextNode();
896
- else if (value2 < 107)
897
- for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
898
- walker.nextSibling();
899
- else if (value2 < 117) {
900
- for (value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */; value2--; )
901
- walker.parentNode();
902
- walker.nextSibling();
903
- } else
904
- storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
905
- }
906
- }
907
-
908
- // src/dom/renderer.ts
909
- function createBranch($global, renderer, parentScope, parentNode) {
910
- let branch = createScope($global), parentBranch = parentScope?.k;
911
- return branch._ = renderer.y || parentScope, branch.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch)), renderer.C?.(
912
- branch,
913
- parentNode.namespaceURI
914
- ), branch;
915
- }
916
- function createAndSetupBranch($global, renderer, parentScope, parentNode) {
917
- return setupBranch(
918
- renderer,
919
- createBranch($global, renderer, parentScope, parentNode)
920
- );
921
- }
922
- function setupBranch(renderer, branch) {
923
- return renderer.D && queueRender(branch, renderer.D, -1), branch;
924
- }
925
- function createContent(id, template, walks, setup, params, dynamicScopesAccessor) {
926
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
927
- let clone = template ? (branch, ns) => {
928
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
929
- template,
930
- ns
931
- ))(branch, walks);
932
- } : (branch) => {
933
- walk(
934
- branch.h = branch.j = new Text(),
935
- walks,
936
- branch
937
- );
938
- };
939
- return (owner) => ({
940
- l: id,
941
- C: clone,
942
- y: owner,
943
- D: setup,
944
- m: params,
945
- z: dynamicScopesAccessor
946
- });
947
- }
948
- function registerContent(id, template, walks, setup, params, dynamicScopesAccessor) {
949
- return register(
950
- id,
951
- createContent(id, template, walks, setup, params, dynamicScopesAccessor)
952
- );
953
- }
954
- function localClosures(renderer, closureFns) {
955
- let closureSignals = {};
956
- for (let key in closureFns)
957
- closureSignals[key] = value(key, closureFns[key]);
958
- return (owner, closureValues) => {
959
- let instance = renderer(owner);
960
- return instance.G = closureSignals, instance.M = closureValues, instance;
961
- };
962
- }
963
- function createRenderer(template, walks, setup, params) {
964
- return createContent("", template, walks, setup, params)();
965
- }
966
- var cloneCache = {};
967
- function createCloneableHTML(html2, ns) {
968
- let { firstChild, lastChild } = parseHTML(html2, ns), parent = document.createElementNS(ns, "t");
969
- return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
970
- walk(
971
- branch.h = branch.j = firstChild.cloneNode(!0),
972
- walks,
973
- branch
974
- );
975
- } : (branch, walks) => {
976
- let clone = parent.cloneNode(!0);
977
- walk(clone.firstChild, walks, branch), branch.h = clone.firstChild, branch.j = clone.lastChild;
978
- };
979
- }
980
-
981
1000
  // src/dom/control-flow.ts
982
1001
  function awaitTag(nodeAccessor, renderer) {
983
1002
  let promiseAccessor = "n" /* Promise */ + nodeAccessor, branchAccessor = "d" /* ConditionalScope */ + nodeAccessor;
@@ -986,8 +1005,8 @@ function awaitTag(nodeAccessor, renderer) {
986
1005
  scope,
987
1006
  "d" /* PlaceholderContent */
988
1007
  ), awaitBranch = scope[branchAccessor];
989
- tryWithPlaceholder ? (placeholderShown.add(pendingEffects), !scope[promiseAccessor] && (tryWithPlaceholder.n = (tryWithPlaceholder.n || 0) + 1) === 1 && requestAnimationFrame(
990
- () => tryWithPlaceholder.n && runEffects(
1008
+ tryWithPlaceholder ? (placeholderShown.add(pendingEffects), !scope[promiseAccessor] && (tryWithPlaceholder.o = (tryWithPlaceholder.o || 0) + 1) === 1 && requestAnimationFrame(
1009
+ () => tryWithPlaceholder.o && runEffects(
991
1010
  prepareEffects(
992
1011
  () => queueRender(
993
1012
  tryWithPlaceholder,
@@ -1027,7 +1046,7 @@ function awaitTag(nodeAccessor, renderer) {
1027
1046
  ),
1028
1047
  referenceNode.parentNode,
1029
1048
  referenceNode
1030
- ), referenceNode.remove()), renderer.m?.(awaitBranch, [data2]), tryWithPlaceholder && (placeholderShown.add(pendingEffects), !--tryWithPlaceholder.n)) {
1049
+ ), referenceNode.remove()), renderer.m?.(awaitBranch, [data2]), tryWithPlaceholder && (placeholderShown.add(pendingEffects), !--tryWithPlaceholder.o)) {
1031
1050
  let placeholderBranch = tryWithPlaceholder.c;
1032
1051
  tryWithPlaceholder.c = 0, placeholderBranch && (placeholderBranch.h.parentNode.insertBefore(
1033
1052
  tryWithPlaceholder.h.parentNode,
@@ -1039,7 +1058,7 @@ function awaitTag(nodeAccessor, renderer) {
1039
1058
  ));
1040
1059
  },
1041
1060
  (error) => {
1042
- thisPromise === scope[promiseAccessor] && (tryWithPlaceholder && (tryWithPlaceholder.n = 0), scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
1061
+ thisPromise === scope[promiseAccessor] && (tryWithPlaceholder && (tryWithPlaceholder.o = 0), scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
1043
1062
  }
1044
1063
  );
1045
1064
  };
@@ -1063,7 +1082,7 @@ function renderCatch(scope, error) {
1063
1082
  let tryWithCatch = findBranchWithKey(scope, "b" /* CatchContent */);
1064
1083
  if (tryWithCatch) {
1065
1084
  let owner = tryWithCatch._, placeholderBranch = tryWithCatch.c;
1066
- placeholderBranch && (tryWithCatch.n = 0, owner["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
1085
+ placeholderBranch && (tryWithCatch.o = 0, owner["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
1067
1086
  owner,
1068
1087
  tryWithCatch.a,
1069
1088
  tryWithCatch.b,
@@ -1107,15 +1126,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1107
1126
  0,
1108
1127
  content,
1109
1128
  createAndSetupBranch
1110
- ), content.z && subscribeToScopeSet(
1111
- content.y,
1112
- content.z,
1129
+ ), content.n && subscribeToScopeSet(
1130
+ content.u,
1131
+ content.n,
1113
1132
  scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
1114
1133
  );
1115
1134
  }
1116
- } else normalizedRenderer?.z && subscribeToScopeSet(
1117
- normalizedRenderer.y,
1118
- normalizedRenderer.z,
1135
+ } else normalizedRenderer?.n && subscribeToScopeSet(
1136
+ normalizedRenderer.u,
1137
+ normalizedRenderer.n,
1119
1138
  scope[childScopeAccessor]
1120
1139
  );
1121
1140
  if (normalizedRenderer) {
@@ -1220,14 +1239,14 @@ function queueRender(scope, signal, signalKey, value2, scopeKey = scope.l) {
1220
1239
  existingRender.I = value2;
1221
1240
  else {
1222
1241
  let render = {
1223
- t: key,
1224
- o: scope,
1242
+ x: key,
1243
+ p: scope,
1225
1244
  N: signal,
1226
1245
  I: value2
1227
1246
  }, i = pendingRenders.push(render) - 1;
1228
1247
  for (; i; ) {
1229
1248
  let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1230
- if (key - parent.t >= 0) break;
1249
+ if (key - parent.x >= 0) break;
1231
1250
  pendingRenders[i] = parent, i = parentIndex;
1232
1251
  }
1233
1252
  signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
@@ -1266,29 +1285,29 @@ function runRenders() {
1266
1285
  for (; pendingRenders.length; ) {
1267
1286
  let render = pendingRenders[0], item = pendingRenders.pop();
1268
1287
  if (render !== item) {
1269
- let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).t;
1288
+ let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).x;
1270
1289
  for (; i < mid; ) {
1271
1290
  let bestChild = (i << 1) + 1, right = bestChild + 1;
1272
- if (right < pendingRenders.length && pendingRenders[right].t - pendingRenders[bestChild].t < 0 && (bestChild = right), pendingRenders[bestChild].t - key >= 0)
1291
+ if (right < pendingRenders.length && pendingRenders[right].x - pendingRenders[bestChild].x < 0 && (bestChild = right), pendingRenders[bestChild].x - key >= 0)
1273
1292
  break;
1274
1293
  pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1275
1294
  }
1276
1295
  pendingRenders[i] = item;
1277
1296
  }
1278
- render.o.k?.B || runRender(render);
1297
+ render.p.k?.B || runRender(render);
1279
1298
  }
1280
1299
  for (let scope of pendingScopes)
1281
- scope.q = 0;
1300
+ scope.t = 0;
1282
1301
  pendingScopes = [];
1283
1302
  }
1284
- var runRender = (render) => render.N(render.o, render.I), enableCatch = () => {
1303
+ var runRender = (render) => render.N(render.p, render.I), enableCatch = () => {
1285
1304
  enableCatch = () => {
1286
1305
  }, enableBranches();
1287
1306
  let handlePendingTry = (fn, scope, branch) => {
1288
1307
  for (; branch; ) {
1289
- if (branch.n)
1308
+ if (branch.o)
1290
1309
  return (branch.H ||= []).push(fn, scope);
1291
- branch = branch.u;
1310
+ branch = branch.y;
1292
1311
  }
1293
1312
  };
1294
1313
  runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
@@ -1302,18 +1321,18 @@ var runRender = (render) => render.N(render.o, render.I), enableCatch = () => {
1302
1321
  try {
1303
1322
  runRender2(render);
1304
1323
  } catch (error) {
1305
- renderCatch(render.o, error);
1324
+ renderCatch(render.p, error);
1306
1325
  }
1307
1326
  })(runRender);
1308
1327
  };
1309
1328
 
1310
1329
  // src/dom/abort-signal.ts
1311
1330
  function resetAbortSignal(scope, id) {
1312
- let ctrl = scope.x?.[id];
1313
- ctrl && (queueEffect(ctrl, abort), scope.x[id] = void 0);
1331
+ let ctrl = scope.z?.[id];
1332
+ ctrl && (queueEffect(ctrl, abort), scope.z[id] = void 0);
1314
1333
  }
1315
1334
  function getAbortSignal(scope, id) {
1316
- return scope.k && (scope.k.K ||= /* @__PURE__ */ new Set()).add(scope), ((scope.x ||= {})[id] ||= new AbortController()).signal;
1335
+ return scope.k && (scope.k.K ||= /* @__PURE__ */ new Set()).add(scope), ((scope.z ||= {})[id] ||= new AbortController()).signal;
1317
1336
  }
1318
1337
  function abort(ctrl) {
1319
1338
  ctrl.abort();
@@ -1375,10 +1394,10 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1375
1394
  normalizedInput[key === "renderBody" ? "content" : key] = input[key];
1376
1395
  }
1377
1396
  if (component.effects = prepareEffects(() => {
1378
- branch ? existing = 1 : (out.global.p ||= 0, branch = component.scope = createAndSetupBranch(
1397
+ branch ? existing = 1 : (out.global.q ||= 0, branch = component.scope = createAndSetupBranch(
1379
1398
  out.global,
1380
1399
  renderer,
1381
- renderer.y,
1400
+ renderer.u,
1382
1401
  document.body
1383
1402
  )), renderer.m?.(branch, renderer._ ? args[0] : args);
1384
1403
  }), !existing)
@@ -1400,12 +1419,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
1400
1419
  function mount(input = {}, reference, position) {
1401
1420
  let branch, parentNode = reference, nextSibling = null, { $global } = input;
1402
1421
  switch ($global ? ({ $global, ...input } = input, $global = {
1403
- p: 0,
1422
+ q: 0,
1404
1423
  runtimeId: DEFAULT_RUNTIME_ID,
1405
1424
  renderId: DEFAULT_RENDER_ID,
1406
1425
  ...$global
1407
1426
  }) : $global = {
1408
- p: 0,
1427
+ q: 0,
1409
1428
  runtimeId: DEFAULT_RUNTIME_ID,
1410
1429
  renderId: DEFAULT_RENDER_ID
1411
1430
  }, position) {
@@ -1458,6 +1477,7 @@ export {
1458
1477
  attrTag,
1459
1478
  attrTags,
1460
1479
  attrs,
1480
+ attrsAndContent,
1461
1481
  attrsEvents,
1462
1482
  awaitTag,
1463
1483
  classAttr,
@@ -1495,6 +1515,7 @@ export {
1495
1515
  hoist,
1496
1516
  html,
1497
1517
  init,
1518
+ insertContent,
1498
1519
  intersection,
1499
1520
  lifecycle,
1500
1521
  localClosures,
@@ -1506,6 +1527,7 @@ export {
1506
1527
  nodeRef,
1507
1528
  on,
1508
1529
  partialAttrs,
1530
+ partialAttrsAndContent,
1509
1531
  props,
1510
1532
  register,
1511
1533
  registerBoundSignal,