jaxs 0.7.0 → 0.7.1

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/jaxs.d.ts CHANGED
@@ -42,11 +42,14 @@ declare module "state/store-updater" {
42
42
  declare module "state/updaters/object" {
43
43
  import { Store } from "types";
44
44
  import { StoreUpdaterBase } from "state/store-updater";
45
- export class StoreUpdaterObject<T> extends StoreUpdaterBase<T> {
45
+ export class StoreUpdaterObject<T extends object> extends StoreUpdaterBase<T> {
46
46
  updateAttribute(name: keyof T, value: T[keyof T]): void;
47
+ updateDynamicAttribute(name: string, value: any): void;
48
+ isKey(key: string): boolean;
49
+ isValueType(key: keyof T, value: any): boolean;
47
50
  resetAttribute(name: keyof T): void;
48
51
  }
49
- export const objectUpdater: <T>(store: Store<T>) => StoreUpdaterObject<T>;
52
+ export const objectUpdater: <T extends Object>(store: Store<T>) => StoreUpdaterObject<T>;
50
53
  }
51
54
  declare module "state/updaters/list" {
52
55
  import { StoreListSorterFunction, Store } from "types";
@@ -76,7 +79,7 @@ declare module "state/updaters/boolean" {
76
79
  }
77
80
  declare module "state/updaters" {
78
81
  export const updaters: {
79
- object: <T>(store: import("state").Store<T>) => import("state/updaters/object").StoreUpdaterObject<T>;
82
+ object: <T extends Object>(store: import("state").Store<T>) => import("state/updaters/object").StoreUpdaterObject<T>;
80
83
  list: <T>(store: import("state").Store<T[]>) => import("state/updaters/list").StoreUpdaterList<T>;
81
84
  boolean: (store: import("state").Store<boolean>) => import("state/updaters/boolean").StoreUpdaterBoolean;
82
85
  };
@@ -263,7 +266,7 @@ declare module "types" {
263
266
  import type { StoreUpdaterObject } from "state/updaters/object";
264
267
  export type { App } from "app/index";
265
268
  export { State, Store, StoreUpdaterBase, StoreUpdaterBoolean, StoreUpdaterList, StoreUpdaterObject, };
266
- export type StoreUpdater<T> = StoreUpdaterBase<T> | StoreUpdaterObject<T> | StoreUpdaterBoolean | StoreUpdaterList<T>;
269
+ export type StoreUpdater<T> = StoreUpdaterBase<T> | StoreUpdaterObject<T extends object ? T : never> | StoreUpdaterBoolean | StoreUpdaterList<T>;
267
270
  export type TextValue = string | number;
268
271
  export interface JsxIded {
269
272
  __jsx?: string;
package/dist/jaxs.js CHANGED
@@ -11,10 +11,10 @@ const Z = (e, t) => t.createElement(e), tt = (e, t) => {
11
11
  }, et = (e, t, s) => {
12
12
  const r = {};
13
13
  for (const n in t) {
14
- const o = t[n], a = (l) => s(o, l);
14
+ const i = t[n], a = (l) => s(i, l);
15
15
  e.addEventListener(n, a), r[n] = {
16
16
  domEvent: n,
17
- busEvent: o,
17
+ busEvent: i,
18
18
  listener: a
19
19
  };
20
20
  }
@@ -85,12 +85,12 @@ const Z = (e, t) => t.createElement(e), tt = (e, t) => {
85
85
  tspan: !0,
86
86
  use: !0,
87
87
  view: !0
88
- }, nt = (e, t) => !!(rt[e] || e === "a" && t === y), ot = (e, t, s) => {
88
+ }, nt = (e, t) => !!(rt[e] || e === "a" && t === y), it = (e, t, s) => {
89
89
  const r = s.createElementNS(y, e);
90
90
  for (const n in t)
91
91
  n === "__self" || n === "xmlns" || r.setAttributeNS(null, n, t[n].toString());
92
92
  return r;
93
- }, it = (e) => e.namespaceURI === y, ut = (e, t) => t.createTextNode(e);
93
+ }, ot = (e) => e.namespaceURI === y, ut = (e, t) => t.createTextNode(e);
94
94
  class at {
95
95
  constructor(t) {
96
96
  this.value = t.toString();
@@ -103,13 +103,13 @@ class at {
103
103
  const ct = (e) => typeof e == "string" || typeof e == "number", lt = (e) => new at(e), ht = (e) => ct(e) ? lt(e) : e, dt = (e) => pt(e).map(ht).flat(), pt = (e) => Array.isArray(e) ? e.flat() : e ? [e] : [], T = (e, t = {}) => e || t.children || [], mt = (e, t = "") => {
104
104
  const s = {}, r = {};
105
105
  for (const n in e) {
106
- const o = e[n];
106
+ const i = e[n];
107
107
  if (n.match(/^on.+/i)) {
108
108
  const a = n.slice(2).toLowerCase();
109
- r[a] = o ? o.toString() : "";
109
+ r[a] = i ? i.toString() : "";
110
110
  } else {
111
- if (o === !1) continue;
112
- n === "__source" ? s.__source = e.__source : s[n] = ft(n, o, t);
111
+ if (i === !1) continue;
112
+ n === "__source" ? s.__source = e.__source : s[n] = ft(n, i, t);
113
113
  }
114
114
  }
115
115
  return {
@@ -164,8 +164,8 @@ class gt {
164
164
  class yt {
165
165
  constructor(t, s, r = []) {
166
166
  this.type = t;
167
- const { events: n, attributes: o } = mt(s);
168
- this.events = n, this.attributes = o, this.isSvg = nt(this.type, this.attributes.xmlns), this.children = new O(r);
167
+ const { events: n, attributes: i } = mt(s);
168
+ this.events = n, this.attributes = i, this.isSvg = nt(this.type, this.attributes.xmlns), this.children = new O(r);
169
169
  }
170
170
  render(t) {
171
171
  const s = this.generateDom(t);
@@ -184,7 +184,7 @@ class yt {
184
184
  return s.__jsx = this.jsxKey(), s;
185
185
  }
186
186
  generateSvgDom(t) {
187
- const s = ot(this.type, this.attributes, t.document);
187
+ const s = it(this.type, this.attributes, t.document);
188
188
  return s.__jsx = this.jsxKey(), s;
189
189
  }
190
190
  jsxKey() {
@@ -235,44 +235,44 @@ const At = (e, t, s) => {
235
235
  return t && t.getAttribute("href") || "";
236
236
  }, E = (e, { publish: t, window: s }) => {
237
237
  s.history.pushState(null, "", e), t(m, null);
238
- }, F = (e, t) => {
238
+ }, V = (e, t) => {
239
239
  if (!e || !e.target) return;
240
240
  e.preventDefault();
241
241
  const s = P(e.target);
242
242
  E(s, t);
243
- }, L = (e) => e.replace(/^\?/, "").split("&").reduce((t, s) => {
243
+ }, F = (e) => e.replace(/^\?/, "").split("&").reduce((t, s) => {
244
244
  if (!s) return t;
245
245
  const r = s.split("=");
246
246
  return t[r[0]] = r[1], t;
247
- }, {}), z = (e, t) => {
248
- const { state: s, publish: r, window: n } = t, { host: o, pathname: a, search: l } = n.location, u = a, d = L(l), c = {
249
- host: o,
247
+ }, {}), L = (e, t) => {
248
+ const { state: s, publish: r, window: n } = t, { host: i, pathname: a, search: l } = n.location, u = a, d = F(l), c = {
249
+ host: i,
250
250
  path: u,
251
251
  query: d
252
252
  };
253
253
  s.store("route").update(c), r($, c);
254
- }, B = (e) => {
254
+ }, z = (e) => {
255
255
  const { subscribe: t } = e;
256
- t(M, F), t(k, (s, r) => {
256
+ t(M, V), t(k, (s, r) => {
257
257
  E(s, r);
258
258
  });
259
- }, V = (e) => {
259
+ }, B = (e) => {
260
260
  const { publish: t, subscribe: s, state: r, window: n } = e;
261
- D(r), n.addEventListener("popstate", () => t(m, null)), s(m, z);
261
+ D(r), n.addEventListener("popstate", () => t(m, null)), s(m, L);
262
262
  }, K = (e) => {
263
263
  setTimeout(() => e.publish(m, null), 0);
264
264
  }, R = (e) => {
265
- V(e), B(e), K(e);
265
+ B(e), z(e), K(e);
266
266
  }, Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
267
267
  __proto__: null,
268
268
  publishLocation: K,
269
269
  startNavigation: R,
270
- subscribeToHistoryChange: V,
271
- subscribeToNavigation: B
270
+ subscribeToHistoryChange: B,
271
+ subscribeToNavigation: z
272
272
  }, Symbol.toStringTag, { value: "Module" }));
273
273
  class U {
274
- constructor({ window: t, document: s, publish: r, subscribe: n, bus: o, state: a, renderKit: l }) {
275
- this.window = t, this.document = s, this.publish = r, this.subscribe = n, this.bus = o, this.state = a, this.renderKit = l, this.roots = [];
274
+ constructor({ window: t, document: s, publish: r, subscribe: n, bus: i, state: a, renderKit: l }) {
275
+ this.window = t, this.document = s, this.publish = r, this.subscribe = n, this.bus = i, this.state = a, this.renderKit = l, this.roots = [];
276
276
  }
277
277
  render(t, s) {
278
278
  const r = At(t, s, this.renderKit);
@@ -396,7 +396,7 @@ class q {
396
396
  [
397
397
  ...this.exactSubscriptions.matches(t),
398
398
  ...this.fuzzySubscriptions.matches(t)
399
- ].sort((n, o) => n.index - o.index).forEach((n) => {
399
+ ].sort((n, i) => n.index - i.index).forEach((n) => {
400
400
  n.listener(s, this.listenerOptions(t));
401
401
  });
402
402
  }
@@ -478,6 +478,15 @@ class $t extends A {
478
478
  const r = { ...this.value };
479
479
  r[t] = s, this.update(r);
480
480
  }
481
+ updateDynamicAttribute(t, s) {
482
+ this.isKey(t) && this.isValueType(t, s) && this.updateAttribute(t, s);
483
+ }
484
+ isKey(t) {
485
+ return t in this.store.initialValue;
486
+ }
487
+ isValueType(t, s) {
488
+ return typeof this.store.initialValue[t] == typeof s;
489
+ }
481
490
  resetAttribute(t) {
482
491
  const s = { ...this.value }, r = this.store.initialValue[t];
483
492
  s[t] = r, this.update(s);
@@ -523,8 +532,8 @@ class Pt extends A {
523
532
  this.update(s);
524
533
  }
525
534
  }
526
- const Ft = (e) => new Pt(e);
527
- class Lt extends A {
535
+ const Vt = (e) => new Pt(e);
536
+ class Ft extends A {
528
537
  toggle() {
529
538
  const t = !this.value;
530
539
  this.update(t);
@@ -536,10 +545,10 @@ class Lt extends A {
536
545
  this.update(!1);
537
546
  }
538
547
  }
539
- const zt = (e) => new Lt(e), Bt = {
548
+ const Lt = (e) => new Ft(e), zt = {
540
549
  object: Dt,
541
- list: Ft,
542
- boolean: zt
550
+ list: Vt,
551
+ boolean: Lt
543
552
  }, w = "state";
544
553
  class G {
545
554
  constructor(t) {
@@ -596,9 +605,9 @@ const H = (e) => new G(e), Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Ob
596
605
  Store: g,
597
606
  createState: H,
598
607
  eventName: w,
599
- updaters: Bt
608
+ updaters: zt
600
609
  }, Symbol.toStringTag, { value: "Module" }));
601
- class Vt {
610
+ class Bt {
602
611
  constructor(t) {
603
612
  this.setupDomEnvironment(t);
604
613
  }
@@ -640,70 +649,70 @@ class Vt {
640
649
  };
641
650
  }
642
651
  }
643
- const Fe = (e = {}) => {
644
- const s = new Vt(e).setup();
652
+ const Ve = (e = {}) => {
653
+ const s = new Bt(e).setup();
645
654
  return s.startNavigation(), s;
646
655
  };
647
- var i = /* @__PURE__ */ ((e) => (e[e.removeNode = 0] = "removeNode", e[e.insertNode = 1] = "insertNode", e[e.replaceNode = 2] = "replaceNode", e[e.removeAttribute = 3] = "removeAttribute", e[e.addAttribute = 4] = "addAttribute", e[e.updateAttribute = 5] = "updateAttribute", e[e.removeEvent = 6] = "removeEvent", e[e.addEvent = 7] = "addEvent", e[e.updateEvent = 8] = "updateEvent", e[e.changeValue = 9] = "changeValue", e[e.changeText = 10] = "changeText", e))(i || {});
648
- const Le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
656
+ var o = /* @__PURE__ */ ((e) => (e[e.removeNode = 0] = "removeNode", e[e.insertNode = 1] = "insertNode", e[e.replaceNode = 2] = "replaceNode", e[e.removeAttribute = 3] = "removeAttribute", e[e.addAttribute = 4] = "addAttribute", e[e.updateAttribute = 5] = "updateAttribute", e[e.removeEvent = 6] = "removeEvent", e[e.addEvent = 7] = "addEvent", e[e.updateEvent = 8] = "updateEvent", e[e.changeValue = 9] = "changeValue", e[e.changeText = 10] = "changeText", e))(o || {});
657
+ const Fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
649
658
  __proto__: null,
650
- ChangeInstructionTypes: i
659
+ ChangeInstructionTypes: o
651
660
  }, Symbol.toStringTag, { value: "Module" })), Kt = (e, t) => ({
652
661
  source: e,
653
662
  target: t,
654
- type: i.changeText,
663
+ type: o.changeText,
655
664
  data: {}
656
665
  }), Rt = (e, t) => ({
657
666
  source: e,
658
667
  target: t,
659
- type: i.replaceNode,
668
+ type: o.replaceNode,
660
669
  data: {}
661
670
  }), Ut = (e, t, s) => ({
662
671
  source: e,
663
672
  target: t,
664
673
  data: s,
665
- type: i.removeAttribute
674
+ type: o.removeAttribute
666
675
  }), Ct = (e, t, s) => ({
667
676
  source: e,
668
677
  target: t,
669
678
  data: s,
670
- type: i.addAttribute
679
+ type: o.addAttribute
671
680
  }), It = (e, t, s) => ({
672
681
  source: e,
673
682
  target: t,
674
683
  data: s,
675
- type: i.updateAttribute
684
+ type: o.updateAttribute
676
685
  }), qt = (e, t, s) => ({
677
686
  source: e,
678
687
  target: t,
679
688
  data: s,
680
- type: i.removeEvent
689
+ type: o.removeEvent
681
690
  }), Jt = (e, t, s) => ({
682
691
  source: e,
683
692
  target: t,
684
693
  data: s,
685
- type: i.addEvent
694
+ type: o.addEvent
686
695
  }), Gt = (e, t, s) => ({
687
696
  source: e,
688
697
  target: t,
689
698
  data: s,
690
- type: i.updateEvent
699
+ type: o.updateEvent
691
700
  }), N = (e) => ({
692
701
  source: e,
693
702
  target: e,
694
703
  // for type crap only
695
- type: i.removeNode,
704
+ type: o.removeNode,
696
705
  data: {}
697
706
  }), b = (e, t) => ({
698
707
  target: e,
699
708
  source: e,
700
709
  // for type crap only
701
- type: i.insertNode,
710
+ type: o.insertNode,
702
711
  data: t
703
712
  }), Ht = (e, t, s) => ({
704
713
  source: e,
705
714
  target: t,
706
- type: i.changeValue,
715
+ type: o.changeValue,
707
716
  data: s
708
717
  }), Qt = (e, t) => e.type > t.type ? 1 : e.type < t.type ? -1 : 0, _ = { index: -1 };
709
718
  class Wt {
@@ -727,7 +736,7 @@ class Wt {
727
736
  const s = t && t.__jsx;
728
737
  if (!(s && this.map[s] && this.map[s].length)) return;
729
738
  const r = this.map[s];
730
- this.map[s] = r.reduce((n, o) => (o.element !== t && n.push(o), n), []);
739
+ this.map[s] = r.reduce((n, i) => (i.element !== t && n.push(i), n), []);
731
740
  }
732
741
  check(t) {
733
742
  const s = t && t.__jsx;
@@ -741,9 +750,9 @@ const S = (e) => {
741
750
  const t = new Wt();
742
751
  return t.populate(e), t;
743
752
  }, Q = (e, t, s = !1) => {
744
- const r = [], n = e.attributes, o = n.length, a = t.attributes, l = a.length;
753
+ const r = [], n = e.attributes, i = n.length, a = t.attributes, l = a.length;
745
754
  let u, d, c;
746
- for (u = 0; u < o; u++) {
755
+ for (u = 0; u < i; u++) {
747
756
  c = null;
748
757
  const h = n.item(u);
749
758
  if (h) {
@@ -769,7 +778,7 @@ const S = (e) => {
769
778
  c = null;
770
779
  const h = a.item(u);
771
780
  if (h) {
772
- for (d = 0; d < o; d++) {
781
+ for (d = 0; d < i; d++) {
773
782
  const p = n.item(d);
774
783
  if (p && p.name == h.name) {
775
784
  c = p;
@@ -787,8 +796,8 @@ const S = (e) => {
787
796
  }
788
797
  return r;
789
798
  }, Xt = (e, t) => {
790
- const s = [], r = e.eventMaps, n = t.eventMaps, o = Object.keys(r), a = Object.keys(n);
791
- return o.forEach((l) => {
799
+ const s = [], r = e.eventMaps, n = t.eventMaps, i = Object.keys(r), a = Object.keys(n);
800
+ return i.forEach((l) => {
792
801
  const u = r[l], d = n[l];
793
802
  d ? d.busEvent !== u.busEvent && s.push(
794
803
  Gt(e, t, {
@@ -821,29 +830,29 @@ const S = (e) => {
821
830
  return s.concat(r).concat(n);
822
831
  }, se = (e, t) => Q(e, t, !0), re = (e, t) => e.textContent !== t.textContent ? [Kt(e, t)] : [], ne = (e, t, s) => {
823
832
  let r = [];
824
- if (e.nodeType === 1 && it(e)) {
825
- const n = e, o = t, a = se(n, o), l = s(
833
+ if (e.nodeType === 1 && ot(e)) {
834
+ const n = e, i = t, a = se(n, i), l = s(
826
835
  n.childNodes,
827
- o.childNodes,
836
+ i.childNodes,
828
837
  n
829
838
  );
830
839
  r = a.concat(l);
831
840
  } else if (e.nodeType === 1) {
832
- const n = e, o = t, a = ee(n, o), l = s(
841
+ const n = e, i = t, a = ee(n, i), l = s(
833
842
  n.childNodes,
834
- o.childNodes,
843
+ i.childNodes,
835
844
  n
836
845
  );
837
846
  r = a.concat(l);
838
847
  } else e.nodeType === 3 && (r = re(e, t));
839
848
  return r;
840
849
  }, W = (e, t, s) => {
841
- const r = [], n = oe(e, t), o = S(e), a = S(t), l = [];
850
+ const r = [], n = ie(e, t), i = S(e), a = S(t), l = [];
842
851
  let u = 0;
843
852
  for (; u < n; u++) {
844
853
  const c = e[u], h = t[u];
845
854
  if (h && a.check(h)) {
846
- const p = o.pullMatch(h);
855
+ const p = i.pullMatch(h);
847
856
  a.clear(h), p.element ? (p.index !== u && r.push(
848
857
  b(p.element, {
849
858
  parent: s,
@@ -854,14 +863,14 @@ const S = (e) => {
854
863
  target: h
855
864
  })) : c ? a.check(c) ? r.push(
856
865
  b(h, { parent: s, index: u })
857
- ) : (o.clear(c), r.push(
866
+ ) : (i.clear(c), r.push(
858
867
  Rt(c, h)
859
868
  )) : r.push(
860
869
  b(h, { parent: s, index: u })
861
870
  );
862
- } else c && o.pullMatch(c).element && r.push(N(c));
871
+ } else c && i.pullMatch(c).element && r.push(N(c));
863
872
  }
864
- o.remaining().forEach(({ element: c }) => {
873
+ i.remaining().forEach(({ element: c }) => {
865
874
  r.push(N(c));
866
875
  });
867
876
  const d = l.reduce(
@@ -871,10 +880,10 @@ const S = (e) => {
871
880
  []
872
881
  );
873
882
  return r.concat(d).sort(Qt);
874
- }, oe = (e, t) => {
883
+ }, ie = (e, t) => {
875
884
  const s = e.length, r = t.length;
876
885
  return s > r ? s : r;
877
- }, ie = (e, t, s) => {
886
+ }, oe = (e, t, s) => {
878
887
  const r = W(e, t, s);
879
888
  return r.forEach((n) => {
880
889
  ue(n);
@@ -889,8 +898,8 @@ const S = (e) => {
889
898
  const { source: t } = e;
890
899
  t.remove();
891
900
  }, he = (e) => {
892
- const { target: t, data: s } = e, { parent: r, index: n } = s, o = r.childNodes[n];
893
- o ? o && o !== t && r.insertBefore(t, o) : r.appendChild(t);
901
+ const { target: t, data: s } = e, { parent: r, index: n } = s, i = r.childNodes[n];
902
+ i ? i && i !== t && r.insertBefore(t, i) : r.appendChild(t);
894
903
  }, de = (e) => {
895
904
  const { source: t, target: s } = e;
896
905
  t.replaceWith(s);
@@ -898,8 +907,8 @@ const S = (e) => {
898
907
  const { source: t, data: s } = e, { name: r, isSvg: n } = s;
899
908
  n ? t.removeAttributeNS(null, r) : t.removeAttribute(r);
900
909
  }, X = (e) => {
901
- const { source: t, data: s } = e, { name: r, value: n, isSvg: o } = s;
902
- o ? t.setAttributeNS(null, r, n) : t.setAttribute(r, n);
910
+ const { source: t, data: s } = e, { name: r, value: n, isSvg: i } = s;
911
+ i ? t.setAttributeNS(null, r, n) : t.setAttribute(r, n);
903
912
  }, me = (e) => {
904
913
  X(e);
905
914
  }, fe = (e) => {
@@ -909,23 +918,23 @@ const S = (e) => {
909
918
  const t = e.data, s = e.source, { name: r, value: n } = t;
910
919
  s.addEventListener(r, n);
911
920
  }, ve = (e) => {
912
- const t = e.data, s = e.source, { name: r, sourceValue: n, targetValue: o } = t;
913
- s.removeEventListener(r, n), s.addEventListener(r, o);
921
+ const t = e.data, s = e.source, { name: r, sourceValue: n, targetValue: i } = t;
922
+ s.removeEventListener(r, n), s.addEventListener(r, i);
914
923
  }, ge = (e) => {
915
924
  const t = e.data, s = e.source, { value: r } = t;
916
925
  s.value = r;
917
926
  }, ye = {
918
- [i.changeText]: ce,
919
- [i.removeNode]: le,
920
- [i.insertNode]: he,
921
- [i.replaceNode]: de,
922
- [i.removeAttribute]: pe,
923
- [i.addAttribute]: X,
924
- [i.updateAttribute]: me,
925
- [i.removeEvent]: fe,
926
- [i.addEvent]: be,
927
- [i.updateEvent]: ve,
928
- [i.changeValue]: ge
927
+ [o.changeText]: ce,
928
+ [o.removeNode]: le,
929
+ [o.insertNode]: he,
930
+ [o.replaceNode]: de,
931
+ [o.removeAttribute]: pe,
932
+ [o.addAttribute]: X,
933
+ [o.updateAttribute]: me,
934
+ [o.removeEvent]: fe,
935
+ [o.addEvent]: be,
936
+ [o.updateEvent]: ve,
937
+ [o.changeValue]: ge
929
938
  }, Ee = (e, t, s) => {
930
939
  const r = [...t];
931
940
  return e.forEach((n) => {
@@ -938,15 +947,15 @@ const S = (e) => {
938
947
  const { source: s } = e, r = t.indexOf(s);
939
948
  r >= 0 && t.splice(r, 1);
940
949
  }, we = (e, t, s) => {
941
- const { target: r } = e, n = e.data, { index: o, parent: a } = n;
942
- s === a && t.splice(o, 0, r);
950
+ const { target: r } = e, n = e.data, { index: i, parent: a } = n;
951
+ s === a && t.splice(i, 0, r);
943
952
  }, Ne = (e, t) => {
944
953
  const { target: s, source: r } = e, n = t.indexOf(r);
945
954
  n >= 0 && (t[n] = s);
946
955
  }, _e = {
947
- [i.removeNode]: Ae,
948
- [i.insertNode]: we,
949
- [i.replaceNode]: Ne
956
+ [o.removeNode]: Ae,
957
+ [o.insertNode]: we,
958
+ [o.replaceNode]: Ne
950
959
  };
951
960
  class Se {
952
961
  constructor({ Template: t, subscriptions: s, attributes: r, viewModel: n }) {
@@ -969,7 +978,7 @@ class Se {
969
978
  const r = this.dom[0].parentElement;
970
979
  this.parentElement = r;
971
980
  }
972
- const t = this.generateDom(this.renderKit), s = ie(
981
+ const t = this.generateDom(this.renderKit), s = oe(
973
982
  this.dom,
974
983
  t,
975
984
  this.parentElement
@@ -994,39 +1003,39 @@ const Te = (e) => e, je = ({
994
1003
  Template: e,
995
1004
  viewModel: t,
996
1005
  subscriptions: s
997
- }) => (s = s || [], t = t || Te, (r) => new Se({ Template: e, viewModel: t, subscriptions: s, attributes: r })), ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1006
+ }) => (s = s || [], t = t || Te, (r) => new Se({ Template: e, viewModel: t, subscriptions: s, attributes: r })), Le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
998
1007
  __proto__: null,
999
1008
  createRouteState: D,
1000
1009
  events: wt,
1001
- extractQueryParams: L,
1010
+ extractQueryParams: F,
1002
1011
  findHref: P,
1003
1012
  navigate: E,
1004
- onLinkClick: F,
1005
- onLocationChange: z,
1013
+ onLinkClick: V,
1014
+ onLocationChange: L,
1006
1015
  start: Nt
1007
1016
  }, Symbol.toStringTag, { value: "Module" })), Oe = (e) => ({ path: t }) => t === e, Me = () => !0, Y = (e) => ({ route: t }) => {
1008
1017
  const s = e.find((r) => r.match(t));
1009
1018
  return s && s.Partial;
1010
- }, Be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1019
+ }, ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1011
1020
  __proto__: null,
1012
1021
  buildRouter: Y,
1013
1022
  catchAll: Me,
1014
1023
  exactPathMatch: Oe
1015
1024
  }, Symbol.toStringTag, { value: "Module" })), ke = () => ({
1016
1025
  render: (e, t) => []
1017
- }), Ve = (e) => {
1026
+ }), Be = (e) => {
1018
1027
  const t = Y(e);
1019
1028
  return je({ Template: ({ route: r }) => (t({ route: r }) || ke)(), subscriptions: ["route"] });
1020
1029
  };
1021
1030
  export {
1022
- Le as JaxsTypes,
1031
+ Fe as JaxsTypes,
1023
1032
  $e as appBuilding,
1024
1033
  je as bind,
1025
- Fe as createApp,
1034
+ Ve as createApp,
1026
1035
  Et as jsx,
1027
1036
  De as messageBus,
1028
- ze as navigation,
1029
- Ve as routedView,
1030
- Be as routing,
1037
+ Le as navigation,
1038
+ Be as routedView,
1039
+ ze as routing,
1031
1040
  Pe as state
1032
1041
  };
package/dist/jaxs.umd.cjs CHANGED
@@ -1 +1 @@
1
- (function(p,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(p=typeof globalThis<"u"?globalThis:p||self,f(p.jaxs={}))})(this,function(p){"use strict";const f=(e,t)=>t.createElement(e),nt=(e,t)=>{for(const s in t){if(s==="__self")continue;const n=t[s].toString();if(s==="value"){const r=e;r.value!==n&&(r.value=n)}else e.setAttribute(s,n)}},rt=(e,t,s)=>{const n={};for(const r in t){const i=t[r],a=l=>s(i,l);e.addEventListener(r,a),n[r]={domEvent:r,busEvent:i,listener:a}}e.eventMaps=n},it=(e,t,s,n)=>{const r=f(e,n.document);return nt(r,t),rt(r,s,n.publish),r},g="http://www.w3.org/2000/svg",ot={animate:!0,animateMotion:!0,animateTransform:!0,circle:!0,clipPath:!0,defs:!0,desc:!0,ellipse:!0,feBlend:!0,feColorMatrix:!0,feComponentTransfer:!0,feComposite:!0,feConvolveMatrix:!0,feDiffuseLighting:!0,feDisplacementMap:!0,feDistantLight:!0,feDropShadow:!0,feFlood:!0,feFuncA:!0,feFuncB:!0,feFuncG:!0,feFuncR:!0,feGaussianBlur:!0,feImage:!0,feMerge:!0,feMergeNode:!0,feMorphology:!0,feOffset:!0,fePointLight:!0,feSpecularLighting:!0,feSpotLight:!0,feTile:!0,feTurbulence:!0,filter:!0,foreignObject:!0,g:!0,image:!0,line:!0,linearGradient:!0,marker:!0,mask:!0,metadata:!0,mpath:!0,path:!0,pattern:!0,polygon:!0,polyline:!0,radialGradient:!0,rect:!0,script:!0,set:!0,stop:!0,style:!0,svg:!0,switch:!0,symbol:!0,text:!0,textPath:!0,title:!0,tspan:!0,use:!0,view:!0},ut=(e,t)=>!!(ot[e]||e==="a"&&t===g),at=(e,t,s)=>{const n=s.createElementNS(g,e);for(const r in t)r==="__self"||r==="xmlns"||n.setAttributeNS(null,r,t[r].toString());return n},ct=e=>e.namespaceURI===g,lt=(e,t)=>t.createTextNode(e);class ht{constructor(t){this.value=t.toString()}render(t){const s=lt(this.value,t.document);return s.__jsx="TextNode",[s]}}const dt=e=>typeof e=="string"||typeof e=="number",pt=e=>new ht(e),mt=e=>dt(e)?pt(e):e,ft=e=>bt(e).map(mt).flat(),bt=e=>Array.isArray(e)?e.flat():e?[e]:[],S=(e,t={})=>e||t.children||[],vt=(e,t="")=>{const s={},n={};for(const r in e){const i=e[r];if(r.match(/^on.+/i)){const a=r.slice(2).toLowerCase();n[a]=i?i.toString():""}else{if(i===!1)continue;r==="__source"?s.__source=e.__source:s[r]=gt(r,i,t)}}return{attributes:s,events:n}},gt=(e,t,s="")=>t==null?s:t.toString(),yt=(e,t)=>{const s=e||{},n=S(t,s);return s.children=s.children||n,s},T=(e,t,s,n=[])=>e.reduce(Et(t,s),n).flat(),Et=(e,t)=>(s,n)=>n?Array.isArray(n)?T(n,e,t,s):(n.render(e,t).forEach(r=>s.push(r)),s):s;class j{constructor(t){this.collection=ft(t)}render(t,s){this.parentElement=s;const n=this.generateDom(t);return this.attachToParent(n),n}generateDom(t){return T(this.collection,t,this.parentElement)}attachToParent(t){if(this.parentElement===void 0)return;const s=this.parentElement;t.forEach(n=>s.appendChild(n))}}class xt{constructor(t,s){this.type=t,this.attributes=s}generate(){return this.attributes.key||this.sourceKey()||this.createKeyFromAttributes()}sourceKey(){if(this.attributes.__source){const{fileName:t,lineNumber:s,columnNumber:n}=this.attributes.__source;return`${t}:${s}:${n}`}}createKeyFromAttributes(){const t=this.attributes.id?`#${this.attributes.id}`:"",s=this.attributes.type?`[type=${this.attributes.type}]`:"",n=this.attributes.name?`[name=${this.attributes.name}]`:"";return`${this.type}${t}${s}${n}`}}class At{constructor(t,s,n=[]){this.type=t;const{events:r,attributes:i}=vt(s);this.events=r,this.attributes=i,this.isSvg=ut(this.type,this.attributes.xmlns),this.children=new j(n)}render(t){const s=this.generateDom(t);return s?(this.children.render(t,s),[s]):[]}generateDom(t){return this.isSvg?this.generateSvgDom(t):this.generateHtmlDom(t)}generateHtmlDom(t){const s=it(this.type,this.attributes,this.events,t);return s.__jsx=this.jsxKey(),s}generateSvgDom(t){const s=at(this.type,this.attributes,t.document);return s.__jsx=this.jsxKey(),s}jsxKey(){return new xt(this.type,this.attributes).generate()}}const O=(e,t,...s)=>typeof e=="string"?new At(e,t,s):e(yt(t,s));O.fragment=(e,t)=>{const s=S(t,e);return new j(s)};class wt{constructor(t,s,n){this.template=t,this.selector=s,this.renderKit=n,this.dom=[]}renderAndAttach(t){this.parentElement=this.getParentElement(),this.dom=this.render({...t,parent:this.parentElement}),this.parentElement&&this.attach()}render(t){return this.template.render(t)}attach(){this.parentElement&&(this.parentElement.innerHTML=""),this.dom.forEach(t=>{this.parentElement&&this.parentElement.appendChild(t)})}getParentElement(){return this.renderKit.document.querySelector(this.selector)}}const Nt=(e,t,s)=>{const n=new wt(e,t,s);return n.renderAndAttach(s),n},M="go-to-href",k="go-to",b="navigation:location-change",$="navigation:route-change",_t=Object.freeze(Object.defineProperty({__proto__:null,linkNavigationEvent:M,locationChangeEvent:b,navigationEvent:k,routeChangeEvent:$},Symbol.toStringTag,{value:"Module"})),P=e=>{e.create("route",{host:"",path:"",query:{}})},D=e=>{const t=e.closest("[href]");return t&&t.getAttribute("href")||""},y=(e,{publish:t,window:s})=>{s.history.pushState(null,"",e),t(b,null)},F=(e,t)=>{if(!e||!e.target)return;e.preventDefault();const s=D(e.target);y(s,t)},L=e=>e.replace(/^\?/,"").split("&").reduce((t,s)=>{if(!s)return t;const n=s.split("=");return t[n[0]]=n[1],t},{}),z=(e,t)=>{const{state:s,publish:n,window:r}=t,{host:i,pathname:a,search:l}=r.location,u=a,d=L(l),c={host:i,path:u,query:d};s.store("route").update(c),n($,c)},B=e=>{const{subscribe:t}=e;t(M,F),t(k,(s,n)=>{y(s,n)})},V=e=>{const{publish:t,subscribe:s,state:n,window:r}=e;P(n),r.addEventListener("popstate",()=>t(b,null)),s(b,z)},K=e=>{setTimeout(()=>e.publish(b,null),0)},R=e=>{V(e),B(e),K(e)},St=Object.freeze(Object.defineProperty({__proto__:null,publishLocation:K,startNavigation:R,subscribeToHistoryChange:V,subscribeToNavigation:B},Symbol.toStringTag,{value:"Module"}));class U{constructor({window:t,document:s,publish:n,subscribe:r,bus:i,state:a,renderKit:l}){this.window=t,this.document=s,this.publish=n,this.subscribe=r,this.bus=i,this.state=a,this.renderKit=l,this.roots=[]}render(t,s){const n=Nt(t,s,this.renderKit);return this.roots.push(n),n}startNavigation(){R(this)}}const Tt=Object.freeze(Object.defineProperty({__proto__:null,App:U},Symbol.toStringTag,{value:"Module"}));class C{constructor(){this.lookup={}}add(t,s,n){this.ensureArrayFor(t);const r={listener:s,index:n,matcher:t};return this.lookup[t].push(r),()=>this.remove(r)}remove(t){this.lookup[t.matcher]&&(this.lookup[t.matcher]=this.lookup[t.matcher].reduce((s,n)=>(n!==t&&s.push(n),s),[]))}matches(t){return this.lookup[t]||[]}ensureArrayFor(t){this.lookup[t]||(this.lookup[t]=[])}}class I{constructor(){this.lookup=[]}add(t,s,n){const r={listener:s,index:n,matcher:t};return this.lookup.push(r),()=>this.remove(r)}remove(t){this.lookup=this.lookup.reduce((s,n)=>(n!==t&&s.push(n),s),[])}matches(t){return this.lookup.filter(s=>s.matcher.test(t))}}class jt{constructor({publish:t,event:s,payload:n,timer:r}){this.setNewTimeout=()=>{this.stopped||setTimeout(()=>{this.publishEvent(),this.setNewTimeout()},this.calculateNextTime())},this.calculateNextTime=()=>this.timer({timeDiff:this.diff(),callCount:this.callCount,stop:this.stop}),this.publish=t,this.event=s,this.payload=n||null,this.stop=this.stopTimeout.bind(this),this.stopped=!1,this.timer=r,this.startedAt=new Date().getTime(),this.callCount=0}start(){this.setNewTimeout()}diff(){return new Date().getTime()-this.startedAt}stopTimeout(){this.stopped=!0,this.timeoutId&&clearTimeout(this.timeoutId)}publishEvent(){this.stopped||(this.callCount+=1,this.publish(this.event,this.payload))}}const Ot=e=>{const{offset:t,period:s}=e,n=({callCount:r})=>t&&r==0?t:s;return{event:e.event,publish:e.publish,payload:e.payload,timer:n}},Mt=e=>{let t;"timer"in e?t=e:t=Ot(e);const s=new jt(t);return s.start(),s.stop};class q{constructor(){this.exactSubscriptions=new C,this.fuzzySubscriptions=new I,this.currentIndex=0}subscribe(t,s){let n;return typeof t=="string"?n=this.exactSubscriptions.add(t,s,this.currentIndex):n=this.fuzzySubscriptions.add(t,s,this.currentIndex),this.currentIndex+=1,n}publish(t,s){[...this.exactSubscriptions.matches(t),...this.fuzzySubscriptions.matches(t)].sort((r,i)=>r.index-i.index).forEach(r=>{r.listener(s,this.listenerOptions(t))})}addListenerOptions(t){this.options=t}listenerOptions(t){return{eventName:t,...this.options,publish:this.publish.bind(this)}}}const J=()=>{const e=new q;return{bus:e,publish:(n,r)=>e.publish(n,r),subscribe:(n,r)=>e.subscribe(n,r)}},kt=Object.freeze(Object.defineProperty({__proto__:null,ExactSubscriptions:C,FuzzySubscriptions:I,JaxsBus:q,createBus:J,publishPeriodically:Mt},Symbol.toStringTag,{value:"Module"})),v=e=>Array.isArray(e),E=e=>e!==null&&!v(e)&&typeof e=="object",$t=(e,t)=>e===t,Pt=(e,t)=>Object.keys(e).length===Object.keys(t).length,Dt=(e,t)=>!(E(e)&&E(t))||!Pt(e,t)?!1:Object.keys(e).every(s=>{const n=e[s],r=t[s];return x(n,r)}),Ft=(e,t)=>!(v(e)&&v(t))||e.length!==t.length?!1:e.every((s,n)=>{const r=t[n];return x(s,r)}),x=(e,t)=>E(e)?Dt(e,t):v(e)?Ft(e,t):$t(e,t);class A{constructor(t){this.name=t.name,this.parent=t.parent,this._value=t.value,this.initialValue=structuredClone(t.value)}get value(){return this._value}set value(t){throw new Error("Cannot set value directly. Use an updater!")}reset(){this._value=this.initialValue}update(t){if(typeof t=="function"){const s=this.getUpdatedValue(t);this.updateValue(s)}else this.updateValue(t)}updateValue(t){x(this._value,t)||(this._value=t,this.parent.notify(this.name))}getUpdatedValue(t){return t(this.value)}}class w{constructor(t){this.store=t}update(t){this.store.update(t)}reset(){this.store.update(this.store.initialValue)}get value(){return this.store.value}}class Lt extends w{updateAttribute(t,s){const n={...this.value};n[t]=s,this.update(n)}resetAttribute(t){const s={...this.value},n=this.store.initialValue[t];s[t]=n,this.update(s)}}const zt=e=>new Lt(e);class Bt extends w{push(t){const s=[...this.value,t];this.update(s)}pop(){const t=[...this.value],s=t.pop();return this.update(t),s}unshift(t){const s=[t,...this.value];this.update(s)}shift(){const t=[...this.value],s=t.shift();return this.update(t),s}addSorter(t,s){this[t]=()=>{this.sortBy(s)}}sortBy(t){const s=[...this.value];s.sort(t),this.update(s)}insertAt(t,s){const n=[...this.value];n.splice(t,0,s),this.update(n)}remove(t){const s=this.value.reduce((n,r)=>(r!==t&&n.push(r),n),[]);this.update(s)}removeBy(t){const s=this.value.reduce((n,r)=>(t(r)||n.push(r),n),[]);this.update(s)}}const Vt=e=>new Bt(e);class Kt extends w{toggle(){const t=!this.value;this.update(t)}setTrue(){this.update(!0)}setFalse(){this.update(!1)}}const Rt={object:zt,list:Vt,boolean:e=>new Kt(e)},N="state";class G{constructor(t){this.publisher=t,this.stores={},this.eventNamePrefix=N,this.notifications=new Set,this.inTransaction=!1}create(t,s){const n=new A({name:t,parent:this,value:s});return this.stores[t]=n,n}store(t){return this.stores[t]||new A({name:t,parent:this,value:void 0})}get(t){return this.store(t).value}getAll(t){return t.reduce((s,n)=>(s[n]=this.get(n),s),{})}notify(t){this.inTransaction?this.notifications.add(t):this.publish(t)}update(t,s){this.store(t).update(s)}transaction(t){this.inTransaction=!0,t(this.stores),this.inTransaction=!1,this.publishAll()}publishAll(){this.notifications.forEach(t=>{this.publish(t)}),this.notifications.clear()}publish(t){this.publisher(this.event(t),{state:this,store:this.store(t)})}event(t){return`${this.eventNamePrefix}:${t}`}}const H=e=>new G(e),Ut=Object.freeze(Object.defineProperty({__proto__:null,State:G,Store:A,createState:H,eventName:N,updaters:Rt},Symbol.toStringTag,{value:"Module"}));class Ct{constructor(t){this.setupDomEnvironment(t)}setup(){return this.setupBus(),this.setupState(),this.addBusOptions(),this.setRenderKit(),new U({window:this.window,document:this.document,publish:this.publish,subscribe:this.subscribe,bus:this.bus,state:this.state,renderKit:this.renderKit})}setupDomEnvironment(t){t.window?(this.window=t.window,this.document=this.window.document):t.document?(this.window=t.document.defaultView,this.document=t.document):(this.window=window,this.document=document)}setupBus(){const{publish:t,subscribe:s,bus:n}=J();this.publish=t,this.subscribe=s,this.bus=n}setupState(){this.state=H(this.publish)}addBusOptions(){this.bus.addListenerOptions({state:this.state,document:this.document,window:this.window})}setRenderKit(){this.renderKit={publish:this.publish,subscribe:this.subscribe,state:this.state,document:this.document,window:this.window}}}const It=(e={})=>{const s=new Ct(e).setup();return s.startNavigation(),s};var o=(e=>(e[e.removeNode=0]="removeNode",e[e.insertNode=1]="insertNode",e[e.replaceNode=2]="replaceNode",e[e.removeAttribute=3]="removeAttribute",e[e.addAttribute=4]="addAttribute",e[e.updateAttribute=5]="updateAttribute",e[e.removeEvent=6]="removeEvent",e[e.addEvent=7]="addEvent",e[e.updateEvent=8]="updateEvent",e[e.changeValue=9]="changeValue",e[e.changeText=10]="changeText",e))(o||{});const qt=Object.freeze(Object.defineProperty({__proto__:null,ChangeInstructionTypes:o},Symbol.toStringTag,{value:"Module"})),Jt=(e,t)=>({source:e,target:t,type:o.changeText,data:{}}),Gt=(e,t)=>({source:e,target:t,type:o.replaceNode,data:{}}),Ht=(e,t,s)=>({source:e,target:t,data:s,type:o.removeAttribute}),Qt=(e,t,s)=>({source:e,target:t,data:s,type:o.addAttribute}),Wt=(e,t,s)=>({source:e,target:t,data:s,type:o.updateAttribute}),Xt=(e,t,s)=>({source:e,target:t,data:s,type:o.removeEvent}),Yt=(e,t,s)=>({source:e,target:t,data:s,type:o.addEvent}),Zt=(e,t,s)=>({source:e,target:t,data:s,type:o.updateEvent}),Q=e=>({source:e,target:e,type:o.removeNode,data:{}}),_=(e,t)=>({target:e,source:e,type:o.insertNode,data:t}),te=(e,t,s)=>({source:e,target:t,type:o.changeValue,data:s}),ee=(e,t)=>e.type>t.type?1:e.type<t.type?-1:0,W={index:-1};class se{constructor(){this.map={}}populate(t){t.forEach((s,n)=>{const r=s.__jsx;r&&(this.map[r]=this.map[r]||[],this.map[r].push({element:s,index:n}))})}pullMatch(t){const s=t&&t.__jsx;return!s||!(this.map[s]&&this.map[s].length)?W:this.map[s].shift()}clear(t){const s=t&&t.__jsx;if(!(s&&this.map[s]&&this.map[s].length))return;const n=this.map[s];this.map[s]=n.reduce((r,i)=>(i.element!==t&&r.push(i),r),[])}check(t){const s=t&&t.__jsx;return s&&this.map[s]?this.map[s].length>0:!1}remaining(){return Object.values(this.map).flat()}}const X=e=>{const t=new se;return t.populate(e),t},Y=(e,t,s=!1)=>{const n=[],r=e.attributes,i=r.length,a=t.attributes,l=a.length;let u,d,c;for(u=0;u<i;u++){c=null;const h=r.item(u);if(h){for(d=0;d<l;d++){const m=a.item(d);if(m&&h.name==m.name){c=m;break}}c?h.value!==c.value&&n.push(Wt(e,t,{name:h.name,value:c.value,isSvg:s})):n.push(Ht(e,t,{name:h.name,isSvg:s}))}}for(u=0;u<l;u++){c=null;const h=a.item(u);if(h){for(d=0;d<i;d++){const m=r.item(d);if(m&&m.name==h.name){c=m;break}}c||n.push(Qt(e,t,{name:h.name,value:h.value,isSvg:s}))}}return n},ne=(e,t)=>{const s=[],n=e.eventMaps,r=t.eventMaps,i=Object.keys(n),a=Object.keys(r);return i.forEach(l=>{const u=n[l],d=r[l];d?d.busEvent!==u.busEvent&&s.push(Zt(e,t,{name:l,targetValue:d.listener,sourceValue:u.listener})):s.push(Xt(e,t,{name:u.domEvent,value:u.listener}))}),a.forEach(l=>{const u=n[l],d=r[l];u||s.push(Yt(e,t,{name:d.domEvent,value:d.listener}))}),s},re=e=>e.tagName!=="INPUT",ie=(e,t)=>e.value===t.value,oe=(e,t)=>{if(re(e)||ie(e,t))return[];const s=e,n=t;return[te(s,n,{name:"value",value:n.value})]},ue=(e,t)=>{const s=Y(e,t),n=ne(e,t),r=oe(e,t);return s.concat(n).concat(r)},ae=(e,t)=>Y(e,t,!0),ce=(e,t)=>e.textContent!==t.textContent?[Jt(e,t)]:[],le=(e,t,s)=>{let n=[];if(e.nodeType===1&&ct(e)){const r=e,i=t,a=ae(r,i),l=s(r.childNodes,i.childNodes,r);n=a.concat(l)}else if(e.nodeType===1){const r=e,i=t,a=ue(r,i),l=s(r.childNodes,i.childNodes,r);n=a.concat(l)}else e.nodeType===3&&(n=ce(e,t));return n},Z=(e,t,s)=>{const n=[],r=he(e,t),i=X(e),a=X(t),l=[];let u=0;for(;u<r;u++){const c=e[u],h=t[u];if(h&&a.check(h)){const m=i.pullMatch(h);a.clear(h),m.element?(m.index!==u&&n.push(_(m.element,{parent:s,index:u})),l.push({source:m.element,target:h})):c?a.check(c)?n.push(_(h,{parent:s,index:u})):(i.clear(c),n.push(Gt(c,h))):n.push(_(h,{parent:s,index:u}))}else c&&i.pullMatch(c).element&&n.push(Q(c))}i.remaining().forEach(({element:c})=>{n.push(Q(c))});const d=l.reduce((c,{source:h,target:m})=>c.concat(le(h,m,Z)),[]);return n.concat(d).sort(ee)},he=(e,t)=>{const s=e.length,n=t.length;return s>n?s:n},de=(e,t,s)=>{const n=Z(e,t,s);return n.forEach(r=>{pe(r)}),n},pe=e=>{(_e[e.type]||me)(e)},me=e=>{},fe=e=>{const{source:t,target:s}=e;t.nodeValue=s.textContent},be=e=>{const{source:t}=e;t.remove()},ve=e=>{const{target:t,data:s}=e,{parent:n,index:r}=s,i=n.childNodes[r];i?i&&i!==t&&n.insertBefore(t,i):n.appendChild(t)},ge=e=>{const{source:t,target:s}=e;t.replaceWith(s)},ye=e=>{const{source:t,data:s}=e,{name:n,isSvg:r}=s;r?t.removeAttributeNS(null,n):t.removeAttribute(n)},tt=e=>{const{source:t,data:s}=e,{name:n,value:r,isSvg:i}=s;i?t.setAttributeNS(null,n,r):t.setAttribute(n,r)},Ee=e=>{tt(e)},xe=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.removeEventListener(n,r)},Ae=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.addEventListener(n,r)},we=e=>{const t=e.data,s=e.source,{name:n,sourceValue:r,targetValue:i}=t;s.removeEventListener(n,r),s.addEventListener(n,i)},Ne=e=>{const t=e.data,s=e.source,{value:n}=t;s.value=n},_e={[o.changeText]:fe,[o.removeNode]:be,[o.insertNode]:ve,[o.replaceNode]:ge,[o.removeAttribute]:ye,[o.addAttribute]:tt,[o.updateAttribute]:Ee,[o.removeEvent]:xe,[o.addEvent]:Ae,[o.updateEvent]:we,[o.changeValue]:Ne},Se=(e,t,s)=>{const n=[...t];return e.forEach(r=>{Te(r,n,s)}),n},Te=(e,t,s)=>{const n=ke[e.type];n&&n(e,t,s)},je=(e,t)=>{const{source:s}=e,n=t.indexOf(s);n>=0&&t.splice(n,1)},Oe=(e,t,s)=>{const{target:n}=e,r=e.data,{index:i,parent:a}=r;s===a&&t.splice(i,0,n)},Me=(e,t)=>{const{target:s,source:n}=e,r=t.indexOf(n);r>=0&&(t[r]=s)},ke={[o.removeNode]:je,[o.insertNode]:Oe,[o.replaceNode]:Me};class $e{constructor({Template:t,subscriptions:s,attributes:n,viewModel:r}){this.Template=t,this.viewModel=r,this.attributes=n,this.subscriptions=s,this.dom=[],this.parentElement=null}render(t){return this.parentElement=t.parent,this.renderKit=t,this.subscribeForRerender(),this.dom=this.generateDom(t),this.dom}generateDom(t){const s={...this.attributes,...this.viewModel(t.state.getAll(this.subscriptions))},n=this.Template(s);return n?n.render(t):[]}rerender(){if(!this.parentElement&&this.dom[0]){const n=this.dom[0].parentElement;this.parentElement=n}const t=this.generateDom(this.renderKit),s=de(this.dom,t,this.parentElement);this.dom=Se(s,this.dom,this.parentElement)}subscribeForRerender(){const{subscribe:t}=this.renderKit;this.subscriptions.forEach(s=>{t(this.eventName(s),()=>this.rerender())})}eventName(t){return`${N}:${t}`}}const Pe=e=>e,et=({Template:e,viewModel:t,subscriptions:s})=>(s=s||[],t=t||Pe,n=>new $e({Template:e,viewModel:t,subscriptions:s,attributes:n})),De=Object.freeze(Object.defineProperty({__proto__:null,createRouteState:P,events:_t,extractQueryParams:L,findHref:D,navigate:y,onLinkClick:F,onLocationChange:z,start:St},Symbol.toStringTag,{value:"Module"})),Fe=e=>({path:t})=>t===e,Le=()=>!0,st=e=>({route:t})=>{const s=e.find(n=>n.match(t));return s&&s.Partial},ze=Object.freeze(Object.defineProperty({__proto__:null,buildRouter:st,catchAll:Le,exactPathMatch:Fe},Symbol.toStringTag,{value:"Module"})),Be=()=>({render:(e,t)=>[]}),Ve=e=>{const t=st(e);return et({Template:({route:n})=>(t({route:n})||Be)(),subscriptions:["route"]})};p.JaxsTypes=qt,p.appBuilding=Tt,p.bind=et,p.createApp=It,p.jsx=O,p.messageBus=kt,p.navigation=De,p.routedView=Ve,p.routing=ze,p.state=Ut,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
1
+ (function(p,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(p=typeof globalThis<"u"?globalThis:p||self,f(p.jaxs={}))})(this,function(p){"use strict";const f=(e,t)=>t.createElement(e),nt=(e,t)=>{for(const s in t){if(s==="__self")continue;const n=t[s].toString();if(s==="value"){const r=e;r.value!==n&&(r.value=n)}else e.setAttribute(s,n)}},rt=(e,t,s)=>{const n={};for(const r in t){const i=t[r],a=l=>s(i,l);e.addEventListener(r,a),n[r]={domEvent:r,busEvent:i,listener:a}}e.eventMaps=n},it=(e,t,s,n)=>{const r=f(e,n.document);return nt(r,t),rt(r,s,n.publish),r},g="http://www.w3.org/2000/svg",ot={animate:!0,animateMotion:!0,animateTransform:!0,circle:!0,clipPath:!0,defs:!0,desc:!0,ellipse:!0,feBlend:!0,feColorMatrix:!0,feComponentTransfer:!0,feComposite:!0,feConvolveMatrix:!0,feDiffuseLighting:!0,feDisplacementMap:!0,feDistantLight:!0,feDropShadow:!0,feFlood:!0,feFuncA:!0,feFuncB:!0,feFuncG:!0,feFuncR:!0,feGaussianBlur:!0,feImage:!0,feMerge:!0,feMergeNode:!0,feMorphology:!0,feOffset:!0,fePointLight:!0,feSpecularLighting:!0,feSpotLight:!0,feTile:!0,feTurbulence:!0,filter:!0,foreignObject:!0,g:!0,image:!0,line:!0,linearGradient:!0,marker:!0,mask:!0,metadata:!0,mpath:!0,path:!0,pattern:!0,polygon:!0,polyline:!0,radialGradient:!0,rect:!0,script:!0,set:!0,stop:!0,style:!0,svg:!0,switch:!0,symbol:!0,text:!0,textPath:!0,title:!0,tspan:!0,use:!0,view:!0},ut=(e,t)=>!!(ot[e]||e==="a"&&t===g),at=(e,t,s)=>{const n=s.createElementNS(g,e);for(const r in t)r==="__self"||r==="xmlns"||n.setAttributeNS(null,r,t[r].toString());return n},ct=e=>e.namespaceURI===g,lt=(e,t)=>t.createTextNode(e);class ht{constructor(t){this.value=t.toString()}render(t){const s=lt(this.value,t.document);return s.__jsx="TextNode",[s]}}const dt=e=>typeof e=="string"||typeof e=="number",pt=e=>new ht(e),mt=e=>dt(e)?pt(e):e,ft=e=>bt(e).map(mt).flat(),bt=e=>Array.isArray(e)?e.flat():e?[e]:[],S=(e,t={})=>e||t.children||[],vt=(e,t="")=>{const s={},n={};for(const r in e){const i=e[r];if(r.match(/^on.+/i)){const a=r.slice(2).toLowerCase();n[a]=i?i.toString():""}else{if(i===!1)continue;r==="__source"?s.__source=e.__source:s[r]=gt(r,i,t)}}return{attributes:s,events:n}},gt=(e,t,s="")=>t==null?s:t.toString(),yt=(e,t)=>{const s=e||{},n=S(t,s);return s.children=s.children||n,s},T=(e,t,s,n=[])=>e.reduce(Et(t,s),n).flat(),Et=(e,t)=>(s,n)=>n?Array.isArray(n)?T(n,e,t,s):(n.render(e,t).forEach(r=>s.push(r)),s):s;class j{constructor(t){this.collection=ft(t)}render(t,s){this.parentElement=s;const n=this.generateDom(t);return this.attachToParent(n),n}generateDom(t){return T(this.collection,t,this.parentElement)}attachToParent(t){if(this.parentElement===void 0)return;const s=this.parentElement;t.forEach(n=>s.appendChild(n))}}class At{constructor(t,s){this.type=t,this.attributes=s}generate(){return this.attributes.key||this.sourceKey()||this.createKeyFromAttributes()}sourceKey(){if(this.attributes.__source){const{fileName:t,lineNumber:s,columnNumber:n}=this.attributes.__source;return`${t}:${s}:${n}`}}createKeyFromAttributes(){const t=this.attributes.id?`#${this.attributes.id}`:"",s=this.attributes.type?`[type=${this.attributes.type}]`:"",n=this.attributes.name?`[name=${this.attributes.name}]`:"";return`${this.type}${t}${s}${n}`}}class xt{constructor(t,s,n=[]){this.type=t;const{events:r,attributes:i}=vt(s);this.events=r,this.attributes=i,this.isSvg=ut(this.type,this.attributes.xmlns),this.children=new j(n)}render(t){const s=this.generateDom(t);return s?(this.children.render(t,s),[s]):[]}generateDom(t){return this.isSvg?this.generateSvgDom(t):this.generateHtmlDom(t)}generateHtmlDom(t){const s=it(this.type,this.attributes,this.events,t);return s.__jsx=this.jsxKey(),s}generateSvgDom(t){const s=at(this.type,this.attributes,t.document);return s.__jsx=this.jsxKey(),s}jsxKey(){return new At(this.type,this.attributes).generate()}}const O=(e,t,...s)=>typeof e=="string"?new xt(e,t,s):e(yt(t,s));O.fragment=(e,t)=>{const s=S(t,e);return new j(s)};class wt{constructor(t,s,n){this.template=t,this.selector=s,this.renderKit=n,this.dom=[]}renderAndAttach(t){this.parentElement=this.getParentElement(),this.dom=this.render({...t,parent:this.parentElement}),this.parentElement&&this.attach()}render(t){return this.template.render(t)}attach(){this.parentElement&&(this.parentElement.innerHTML=""),this.dom.forEach(t=>{this.parentElement&&this.parentElement.appendChild(t)})}getParentElement(){return this.renderKit.document.querySelector(this.selector)}}const Nt=(e,t,s)=>{const n=new wt(e,t,s);return n.renderAndAttach(s),n},M="go-to-href",k="go-to",b="navigation:location-change",$="navigation:route-change",_t=Object.freeze(Object.defineProperty({__proto__:null,linkNavigationEvent:M,locationChangeEvent:b,navigationEvent:k,routeChangeEvent:$},Symbol.toStringTag,{value:"Module"})),D=e=>{e.create("route",{host:"",path:"",query:{}})},P=e=>{const t=e.closest("[href]");return t&&t.getAttribute("href")||""},y=(e,{publish:t,window:s})=>{s.history.pushState(null,"",e),t(b,null)},V=(e,t)=>{if(!e||!e.target)return;e.preventDefault();const s=P(e.target);y(s,t)},F=e=>e.replace(/^\?/,"").split("&").reduce((t,s)=>{if(!s)return t;const n=s.split("=");return t[n[0]]=n[1],t},{}),L=(e,t)=>{const{state:s,publish:n,window:r}=t,{host:i,pathname:a,search:l}=r.location,u=a,d=F(l),c={host:i,path:u,query:d};s.store("route").update(c),n($,c)},z=e=>{const{subscribe:t}=e;t(M,V),t(k,(s,n)=>{y(s,n)})},B=e=>{const{publish:t,subscribe:s,state:n,window:r}=e;D(n),r.addEventListener("popstate",()=>t(b,null)),s(b,L)},K=e=>{setTimeout(()=>e.publish(b,null),0)},R=e=>{B(e),z(e),K(e)},St=Object.freeze(Object.defineProperty({__proto__:null,publishLocation:K,startNavigation:R,subscribeToHistoryChange:B,subscribeToNavigation:z},Symbol.toStringTag,{value:"Module"}));class U{constructor({window:t,document:s,publish:n,subscribe:r,bus:i,state:a,renderKit:l}){this.window=t,this.document=s,this.publish=n,this.subscribe=r,this.bus=i,this.state=a,this.renderKit=l,this.roots=[]}render(t,s){const n=Nt(t,s,this.renderKit);return this.roots.push(n),n}startNavigation(){R(this)}}const Tt=Object.freeze(Object.defineProperty({__proto__:null,App:U},Symbol.toStringTag,{value:"Module"}));class C{constructor(){this.lookup={}}add(t,s,n){this.ensureArrayFor(t);const r={listener:s,index:n,matcher:t};return this.lookup[t].push(r),()=>this.remove(r)}remove(t){this.lookup[t.matcher]&&(this.lookup[t.matcher]=this.lookup[t.matcher].reduce((s,n)=>(n!==t&&s.push(n),s),[]))}matches(t){return this.lookup[t]||[]}ensureArrayFor(t){this.lookup[t]||(this.lookup[t]=[])}}class I{constructor(){this.lookup=[]}add(t,s,n){const r={listener:s,index:n,matcher:t};return this.lookup.push(r),()=>this.remove(r)}remove(t){this.lookup=this.lookup.reduce((s,n)=>(n!==t&&s.push(n),s),[])}matches(t){return this.lookup.filter(s=>s.matcher.test(t))}}class jt{constructor({publish:t,event:s,payload:n,timer:r}){this.setNewTimeout=()=>{this.stopped||setTimeout(()=>{this.publishEvent(),this.setNewTimeout()},this.calculateNextTime())},this.calculateNextTime=()=>this.timer({timeDiff:this.diff(),callCount:this.callCount,stop:this.stop}),this.publish=t,this.event=s,this.payload=n||null,this.stop=this.stopTimeout.bind(this),this.stopped=!1,this.timer=r,this.startedAt=new Date().getTime(),this.callCount=0}start(){this.setNewTimeout()}diff(){return new Date().getTime()-this.startedAt}stopTimeout(){this.stopped=!0,this.timeoutId&&clearTimeout(this.timeoutId)}publishEvent(){this.stopped||(this.callCount+=1,this.publish(this.event,this.payload))}}const Ot=e=>{const{offset:t,period:s}=e,n=({callCount:r})=>t&&r==0?t:s;return{event:e.event,publish:e.publish,payload:e.payload,timer:n}},Mt=e=>{let t;"timer"in e?t=e:t=Ot(e);const s=new jt(t);return s.start(),s.stop};class q{constructor(){this.exactSubscriptions=new C,this.fuzzySubscriptions=new I,this.currentIndex=0}subscribe(t,s){let n;return typeof t=="string"?n=this.exactSubscriptions.add(t,s,this.currentIndex):n=this.fuzzySubscriptions.add(t,s,this.currentIndex),this.currentIndex+=1,n}publish(t,s){[...this.exactSubscriptions.matches(t),...this.fuzzySubscriptions.matches(t)].sort((r,i)=>r.index-i.index).forEach(r=>{r.listener(s,this.listenerOptions(t))})}addListenerOptions(t){this.options=t}listenerOptions(t){return{eventName:t,...this.options,publish:this.publish.bind(this)}}}const J=()=>{const e=new q;return{bus:e,publish:(n,r)=>e.publish(n,r),subscribe:(n,r)=>e.subscribe(n,r)}},kt=Object.freeze(Object.defineProperty({__proto__:null,ExactSubscriptions:C,FuzzySubscriptions:I,JaxsBus:q,createBus:J,publishPeriodically:Mt},Symbol.toStringTag,{value:"Module"})),v=e=>Array.isArray(e),E=e=>e!==null&&!v(e)&&typeof e=="object",$t=(e,t)=>e===t,Dt=(e,t)=>Object.keys(e).length===Object.keys(t).length,Pt=(e,t)=>!(E(e)&&E(t))||!Dt(e,t)?!1:Object.keys(e).every(s=>{const n=e[s],r=t[s];return A(n,r)}),Vt=(e,t)=>!(v(e)&&v(t))||e.length!==t.length?!1:e.every((s,n)=>{const r=t[n];return A(s,r)}),A=(e,t)=>E(e)?Pt(e,t):v(e)?Vt(e,t):$t(e,t);class x{constructor(t){this.name=t.name,this.parent=t.parent,this._value=t.value,this.initialValue=structuredClone(t.value)}get value(){return this._value}set value(t){throw new Error("Cannot set value directly. Use an updater!")}reset(){this._value=this.initialValue}update(t){if(typeof t=="function"){const s=this.getUpdatedValue(t);this.updateValue(s)}else this.updateValue(t)}updateValue(t){A(this._value,t)||(this._value=t,this.parent.notify(this.name))}getUpdatedValue(t){return t(this.value)}}class w{constructor(t){this.store=t}update(t){this.store.update(t)}reset(){this.store.update(this.store.initialValue)}get value(){return this.store.value}}class Ft extends w{updateAttribute(t,s){const n={...this.value};n[t]=s,this.update(n)}updateDynamicAttribute(t,s){this.isKey(t)&&this.isValueType(t,s)&&this.updateAttribute(t,s)}isKey(t){return t in this.store.initialValue}isValueType(t,s){return typeof this.store.initialValue[t]==typeof s}resetAttribute(t){const s={...this.value},n=this.store.initialValue[t];s[t]=n,this.update(s)}}const Lt=e=>new Ft(e);class zt extends w{push(t){const s=[...this.value,t];this.update(s)}pop(){const t=[...this.value],s=t.pop();return this.update(t),s}unshift(t){const s=[t,...this.value];this.update(s)}shift(){const t=[...this.value],s=t.shift();return this.update(t),s}addSorter(t,s){this[t]=()=>{this.sortBy(s)}}sortBy(t){const s=[...this.value];s.sort(t),this.update(s)}insertAt(t,s){const n=[...this.value];n.splice(t,0,s),this.update(n)}remove(t){const s=this.value.reduce((n,r)=>(r!==t&&n.push(r),n),[]);this.update(s)}removeBy(t){const s=this.value.reduce((n,r)=>(t(r)||n.push(r),n),[]);this.update(s)}}const Bt=e=>new zt(e);class Kt extends w{toggle(){const t=!this.value;this.update(t)}setTrue(){this.update(!0)}setFalse(){this.update(!1)}}const Rt={object:Lt,list:Bt,boolean:e=>new Kt(e)},N="state";class G{constructor(t){this.publisher=t,this.stores={},this.eventNamePrefix=N,this.notifications=new Set,this.inTransaction=!1}create(t,s){const n=new x({name:t,parent:this,value:s});return this.stores[t]=n,n}store(t){return this.stores[t]||new x({name:t,parent:this,value:void 0})}get(t){return this.store(t).value}getAll(t){return t.reduce((s,n)=>(s[n]=this.get(n),s),{})}notify(t){this.inTransaction?this.notifications.add(t):this.publish(t)}update(t,s){this.store(t).update(s)}transaction(t){this.inTransaction=!0,t(this.stores),this.inTransaction=!1,this.publishAll()}publishAll(){this.notifications.forEach(t=>{this.publish(t)}),this.notifications.clear()}publish(t){this.publisher(this.event(t),{state:this,store:this.store(t)})}event(t){return`${this.eventNamePrefix}:${t}`}}const H=e=>new G(e),Ut=Object.freeze(Object.defineProperty({__proto__:null,State:G,Store:x,createState:H,eventName:N,updaters:Rt},Symbol.toStringTag,{value:"Module"}));class Ct{constructor(t){this.setupDomEnvironment(t)}setup(){return this.setupBus(),this.setupState(),this.addBusOptions(),this.setRenderKit(),new U({window:this.window,document:this.document,publish:this.publish,subscribe:this.subscribe,bus:this.bus,state:this.state,renderKit:this.renderKit})}setupDomEnvironment(t){t.window?(this.window=t.window,this.document=this.window.document):t.document?(this.window=t.document.defaultView,this.document=t.document):(this.window=window,this.document=document)}setupBus(){const{publish:t,subscribe:s,bus:n}=J();this.publish=t,this.subscribe=s,this.bus=n}setupState(){this.state=H(this.publish)}addBusOptions(){this.bus.addListenerOptions({state:this.state,document:this.document,window:this.window})}setRenderKit(){this.renderKit={publish:this.publish,subscribe:this.subscribe,state:this.state,document:this.document,window:this.window}}}const It=(e={})=>{const s=new Ct(e).setup();return s.startNavigation(),s};var o=(e=>(e[e.removeNode=0]="removeNode",e[e.insertNode=1]="insertNode",e[e.replaceNode=2]="replaceNode",e[e.removeAttribute=3]="removeAttribute",e[e.addAttribute=4]="addAttribute",e[e.updateAttribute=5]="updateAttribute",e[e.removeEvent=6]="removeEvent",e[e.addEvent=7]="addEvent",e[e.updateEvent=8]="updateEvent",e[e.changeValue=9]="changeValue",e[e.changeText=10]="changeText",e))(o||{});const qt=Object.freeze(Object.defineProperty({__proto__:null,ChangeInstructionTypes:o},Symbol.toStringTag,{value:"Module"})),Jt=(e,t)=>({source:e,target:t,type:o.changeText,data:{}}),Gt=(e,t)=>({source:e,target:t,type:o.replaceNode,data:{}}),Ht=(e,t,s)=>({source:e,target:t,data:s,type:o.removeAttribute}),Qt=(e,t,s)=>({source:e,target:t,data:s,type:o.addAttribute}),Wt=(e,t,s)=>({source:e,target:t,data:s,type:o.updateAttribute}),Xt=(e,t,s)=>({source:e,target:t,data:s,type:o.removeEvent}),Yt=(e,t,s)=>({source:e,target:t,data:s,type:o.addEvent}),Zt=(e,t,s)=>({source:e,target:t,data:s,type:o.updateEvent}),Q=e=>({source:e,target:e,type:o.removeNode,data:{}}),_=(e,t)=>({target:e,source:e,type:o.insertNode,data:t}),te=(e,t,s)=>({source:e,target:t,type:o.changeValue,data:s}),ee=(e,t)=>e.type>t.type?1:e.type<t.type?-1:0,W={index:-1};class se{constructor(){this.map={}}populate(t){t.forEach((s,n)=>{const r=s.__jsx;r&&(this.map[r]=this.map[r]||[],this.map[r].push({element:s,index:n}))})}pullMatch(t){const s=t&&t.__jsx;return!s||!(this.map[s]&&this.map[s].length)?W:this.map[s].shift()}clear(t){const s=t&&t.__jsx;if(!(s&&this.map[s]&&this.map[s].length))return;const n=this.map[s];this.map[s]=n.reduce((r,i)=>(i.element!==t&&r.push(i),r),[])}check(t){const s=t&&t.__jsx;return s&&this.map[s]?this.map[s].length>0:!1}remaining(){return Object.values(this.map).flat()}}const X=e=>{const t=new se;return t.populate(e),t},Y=(e,t,s=!1)=>{const n=[],r=e.attributes,i=r.length,a=t.attributes,l=a.length;let u,d,c;for(u=0;u<i;u++){c=null;const h=r.item(u);if(h){for(d=0;d<l;d++){const m=a.item(d);if(m&&h.name==m.name){c=m;break}}c?h.value!==c.value&&n.push(Wt(e,t,{name:h.name,value:c.value,isSvg:s})):n.push(Ht(e,t,{name:h.name,isSvg:s}))}}for(u=0;u<l;u++){c=null;const h=a.item(u);if(h){for(d=0;d<i;d++){const m=r.item(d);if(m&&m.name==h.name){c=m;break}}c||n.push(Qt(e,t,{name:h.name,value:h.value,isSvg:s}))}}return n},ne=(e,t)=>{const s=[],n=e.eventMaps,r=t.eventMaps,i=Object.keys(n),a=Object.keys(r);return i.forEach(l=>{const u=n[l],d=r[l];d?d.busEvent!==u.busEvent&&s.push(Zt(e,t,{name:l,targetValue:d.listener,sourceValue:u.listener})):s.push(Xt(e,t,{name:u.domEvent,value:u.listener}))}),a.forEach(l=>{const u=n[l],d=r[l];u||s.push(Yt(e,t,{name:d.domEvent,value:d.listener}))}),s},re=e=>e.tagName!=="INPUT",ie=(e,t)=>e.value===t.value,oe=(e,t)=>{if(re(e)||ie(e,t))return[];const s=e,n=t;return[te(s,n,{name:"value",value:n.value})]},ue=(e,t)=>{const s=Y(e,t),n=ne(e,t),r=oe(e,t);return s.concat(n).concat(r)},ae=(e,t)=>Y(e,t,!0),ce=(e,t)=>e.textContent!==t.textContent?[Jt(e,t)]:[],le=(e,t,s)=>{let n=[];if(e.nodeType===1&&ct(e)){const r=e,i=t,a=ae(r,i),l=s(r.childNodes,i.childNodes,r);n=a.concat(l)}else if(e.nodeType===1){const r=e,i=t,a=ue(r,i),l=s(r.childNodes,i.childNodes,r);n=a.concat(l)}else e.nodeType===3&&(n=ce(e,t));return n},Z=(e,t,s)=>{const n=[],r=he(e,t),i=X(e),a=X(t),l=[];let u=0;for(;u<r;u++){const c=e[u],h=t[u];if(h&&a.check(h)){const m=i.pullMatch(h);a.clear(h),m.element?(m.index!==u&&n.push(_(m.element,{parent:s,index:u})),l.push({source:m.element,target:h})):c?a.check(c)?n.push(_(h,{parent:s,index:u})):(i.clear(c),n.push(Gt(c,h))):n.push(_(h,{parent:s,index:u}))}else c&&i.pullMatch(c).element&&n.push(Q(c))}i.remaining().forEach(({element:c})=>{n.push(Q(c))});const d=l.reduce((c,{source:h,target:m})=>c.concat(le(h,m,Z)),[]);return n.concat(d).sort(ee)},he=(e,t)=>{const s=e.length,n=t.length;return s>n?s:n},de=(e,t,s)=>{const n=Z(e,t,s);return n.forEach(r=>{pe(r)}),n},pe=e=>{(_e[e.type]||me)(e)},me=e=>{},fe=e=>{const{source:t,target:s}=e;t.nodeValue=s.textContent},be=e=>{const{source:t}=e;t.remove()},ve=e=>{const{target:t,data:s}=e,{parent:n,index:r}=s,i=n.childNodes[r];i?i&&i!==t&&n.insertBefore(t,i):n.appendChild(t)},ge=e=>{const{source:t,target:s}=e;t.replaceWith(s)},ye=e=>{const{source:t,data:s}=e,{name:n,isSvg:r}=s;r?t.removeAttributeNS(null,n):t.removeAttribute(n)},tt=e=>{const{source:t,data:s}=e,{name:n,value:r,isSvg:i}=s;i?t.setAttributeNS(null,n,r):t.setAttribute(n,r)},Ee=e=>{tt(e)},Ae=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.removeEventListener(n,r)},xe=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.addEventListener(n,r)},we=e=>{const t=e.data,s=e.source,{name:n,sourceValue:r,targetValue:i}=t;s.removeEventListener(n,r),s.addEventListener(n,i)},Ne=e=>{const t=e.data,s=e.source,{value:n}=t;s.value=n},_e={[o.changeText]:fe,[o.removeNode]:be,[o.insertNode]:ve,[o.replaceNode]:ge,[o.removeAttribute]:ye,[o.addAttribute]:tt,[o.updateAttribute]:Ee,[o.removeEvent]:Ae,[o.addEvent]:xe,[o.updateEvent]:we,[o.changeValue]:Ne},Se=(e,t,s)=>{const n=[...t];return e.forEach(r=>{Te(r,n,s)}),n},Te=(e,t,s)=>{const n=ke[e.type];n&&n(e,t,s)},je=(e,t)=>{const{source:s}=e,n=t.indexOf(s);n>=0&&t.splice(n,1)},Oe=(e,t,s)=>{const{target:n}=e,r=e.data,{index:i,parent:a}=r;s===a&&t.splice(i,0,n)},Me=(e,t)=>{const{target:s,source:n}=e,r=t.indexOf(n);r>=0&&(t[r]=s)},ke={[o.removeNode]:je,[o.insertNode]:Oe,[o.replaceNode]:Me};class $e{constructor({Template:t,subscriptions:s,attributes:n,viewModel:r}){this.Template=t,this.viewModel=r,this.attributes=n,this.subscriptions=s,this.dom=[],this.parentElement=null}render(t){return this.parentElement=t.parent,this.renderKit=t,this.subscribeForRerender(),this.dom=this.generateDom(t),this.dom}generateDom(t){const s={...this.attributes,...this.viewModel(t.state.getAll(this.subscriptions))},n=this.Template(s);return n?n.render(t):[]}rerender(){if(!this.parentElement&&this.dom[0]){const n=this.dom[0].parentElement;this.parentElement=n}const t=this.generateDom(this.renderKit),s=de(this.dom,t,this.parentElement);this.dom=Se(s,this.dom,this.parentElement)}subscribeForRerender(){const{subscribe:t}=this.renderKit;this.subscriptions.forEach(s=>{t(this.eventName(s),()=>this.rerender())})}eventName(t){return`${N}:${t}`}}const De=e=>e,et=({Template:e,viewModel:t,subscriptions:s})=>(s=s||[],t=t||De,n=>new $e({Template:e,viewModel:t,subscriptions:s,attributes:n})),Pe=Object.freeze(Object.defineProperty({__proto__:null,createRouteState:D,events:_t,extractQueryParams:F,findHref:P,navigate:y,onLinkClick:V,onLocationChange:L,start:St},Symbol.toStringTag,{value:"Module"})),Ve=e=>({path:t})=>t===e,Fe=()=>!0,st=e=>({route:t})=>{const s=e.find(n=>n.match(t));return s&&s.Partial},Le=Object.freeze(Object.defineProperty({__proto__:null,buildRouter:st,catchAll:Fe,exactPathMatch:Ve},Symbol.toStringTag,{value:"Module"})),ze=()=>({render:(e,t)=>[]}),Be=e=>{const t=st(e);return et({Template:({route:n})=>(t({route:n})||ze)(),subscriptions:["route"]})};p.JaxsTypes=qt,p.appBuilding=Tt,p.bind=et,p.createApp=It,p.jsx=O,p.messageBus=kt,p.navigation=Pe,p.routedView=Be,p.routing=Le,p.state=Ut,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "jaxs",
3
3
  "description": "Modular J/TSX application framework",
4
4
  "private": false,
5
- "version": "0.7.0",
5
+ "version": "0.7.1",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "vite build && npm run build:types",