jaxs 0.7.3 → 0.8.0

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
@@ -96,10 +96,7 @@ declare const buildRouter: (
96
96
 
97
97
  declare type BusEventMatcher = string | RegExp
98
98
 
99
- export declare type BusListener<T> = (
100
- payload: T,
101
- listenerKit: ListenerKit,
102
- ) => void
99
+ export declare type BusListener<T> = (listenerKit: ListenerKit<T>) => void
103
100
 
104
101
  declare const catchAll: RouteMatcher
105
102
 
@@ -273,7 +270,17 @@ declare class JaxsBus {
273
270
  subscribe<T>(matcher: BusEventMatcher, listener: BusListener<T>): Unsubscribe
274
271
  publish<T>(event: string, payload: T): void
275
272
  addListenerOptions(options: AppAdditionListenerOptions): void
276
- listenerOptions(event: string): ListenerKit
273
+ listenerOptions<T>(
274
+ event: string,
275
+ payload: T,
276
+ ): {
277
+ publish: any
278
+ payload: T
279
+ state: State
280
+ document: Document
281
+ window: Window
282
+ eventName: string
283
+ }
277
284
  }
278
285
 
279
286
  declare type JaxsElement = Element & JsxIded & JsxEventMapped
@@ -399,8 +406,14 @@ declare interface JsxIded {
399
406
 
400
407
  declare const linkNavigationEvent = 'go-to-href'
401
408
 
402
- declare type ListenerKit = AppAdditionListenerOptions &
403
- DefaultBusListenerOptions
409
+ declare type ListenerKit<T> = {
410
+ state: State
411
+ document: Document
412
+ window: Window
413
+ publish: PublishFunction
414
+ eventName: string
415
+ payload: T
416
+ }
404
417
 
405
418
  declare const locationChangeEvent = 'navigation:location-change'
406
419
 
@@ -414,7 +427,11 @@ export declare namespace messageBus {
414
427
  }
415
428
  }
416
429
 
417
- declare const navigate: (path: string, { publish, window }: ListenerKit) => void
430
+ declare const navigate: ({
431
+ payload: path,
432
+ publish,
433
+ window,
434
+ }: ListenerKit<string>) => void
418
435
 
419
436
  export declare namespace navigation {
420
437
  export {
@@ -435,9 +452,9 @@ declare type NullInstructionData = Record<string, never>
435
452
 
436
453
  declare type NullValues = null | undefined
437
454
 
438
- declare const onLinkClick: (domEvent: MouseEvent, options: ListenerKit) => void
455
+ declare const onLinkClick: (listenerKit: ListenerKit<MouseEvent>) => void
439
456
 
440
- declare const onLocationChange: (_: null, listenerOptions: ListenerKit) => void
457
+ declare const onLocationChange: (listenerKit: ListenerKit<null>) => void
441
458
 
442
459
  declare interface PeriodicPublisher {
443
460
  event: string
package/dist/jaxs.js CHANGED
@@ -17,7 +17,7 @@ const tt = (e) => typeof e == 'string',
17
17
  const r = {}
18
18
  for (const n in t) {
19
19
  const i = t[n],
20
- a = (l) => s(i, l)
20
+ a = (c) => s(i, c)
21
21
  e.addEventListener(n, a),
22
22
  (r[n] = {
23
23
  domEvent: n,
@@ -288,14 +288,15 @@ const wt = (e, t, s) => {
288
288
  const t = e.closest('[href]')
289
289
  return (t && t.getAttribute('href')) || ''
290
290
  },
291
- E = (e, { publish: t, window: s }) => {
291
+ E = ({ payload: e, publish: t, window: s }) => {
292
292
  s.history.pushState(null, '', e), t(m, null)
293
293
  },
294
- F = (e, t) => {
295
- if (!e || !e.target) return
296
- e.preventDefault()
297
- const s = V(e.target)
298
- E(s, t)
294
+ F = (e) => {
295
+ const t = e.payload
296
+ if (!t || !t.target) return
297
+ t.preventDefault()
298
+ const s = V(t.target)
299
+ E({ ...e, payload: s })
299
300
  },
300
301
  L = (e) =>
301
302
  e
@@ -306,23 +307,23 @@ const wt = (e, t, s) => {
306
307
  const r = s.split('=')
307
308
  return (t[r[0]] = r[1]), t
308
309
  }, {}),
309
- z = (e, t) => {
310
- const { state: s, publish: r, window: n } = t,
311
- { host: i, pathname: a, search: l } = n.location,
312
- u = a,
313
- d = L(l),
314
- c = {
315
- host: i,
316
- path: u,
317
- query: d,
310
+ z = (e) => {
311
+ const { state: t, publish: s, window: r } = e,
312
+ { host: n, pathname: i, search: a } = r.location,
313
+ c = i,
314
+ u = L(a),
315
+ h = {
316
+ host: n,
317
+ path: c,
318
+ query: u,
318
319
  }
319
- s.store('route').update(c), r(D, c)
320
+ t.store('route').update(h), s(D, h)
320
321
  },
321
322
  B = (e) => {
322
323
  const { subscribe: t } = e
323
324
  t(k, F),
324
- t($, (s, r) => {
325
- E(s, r)
325
+ t($, (s) => {
326
+ E(s)
326
327
  })
327
328
  },
328
329
  K = (e) => {
@@ -356,7 +357,7 @@ class C {
356
357
  subscribe: n,
357
358
  bus: i,
358
359
  state: a,
359
- renderKit: l,
360
+ renderKit: c,
360
361
  }) {
361
362
  ;(this.window = t),
362
363
  (this.document = s),
@@ -364,7 +365,7 @@ class C {
364
365
  (this.subscribe = n),
365
366
  (this.bus = i),
366
367
  (this.state = a),
367
- (this.renderKit = l),
368
+ (this.renderKit = c),
368
369
  (this.roots = [])
369
370
  }
370
371
  render(t, s) {
@@ -507,17 +508,18 @@ class J {
507
508
  ]
508
509
  .sort((n, i) => n.index - i.index)
509
510
  .forEach((n) => {
510
- n.listener(s, this.listenerOptions(t))
511
+ n.listener(this.listenerOptions(t, s))
511
512
  })
512
513
  }
513
514
  addListenerOptions(t) {
514
515
  this.options = t
515
516
  }
516
- listenerOptions(t) {
517
+ listenerOptions(t, s) {
517
518
  return {
518
519
  eventName: t,
519
520
  ...this.options,
520
521
  publish: this.publish.bind(this),
522
+ payload: s,
521
523
  }
522
524
  }
523
525
  }
@@ -953,47 +955,47 @@ const S = (e) => {
953
955
  n = e.attributes,
954
956
  i = n.length,
955
957
  a = t.attributes,
956
- l = a.length
957
- let u, d, c
958
+ c = a.length
959
+ let u, h, d
958
960
  for (u = 0; u < i; u++) {
959
- c = null
960
- const h = n.item(u)
961
- if (h) {
962
- for (d = 0; d < l; d++) {
963
- const p = a.item(d)
964
- if (p && h.name == p.name) {
965
- c = p
961
+ d = null
962
+ const l = n.item(u)
963
+ if (l) {
964
+ for (h = 0; h < c; h++) {
965
+ const p = a.item(h)
966
+ if (p && l.name == p.name) {
967
+ d = p
966
968
  break
967
969
  }
968
970
  }
969
- c
970
- ? h.value !== c.value &&
971
+ d
972
+ ? l.value !== d.value &&
971
973
  r.push(
972
974
  qt(e, t, {
973
- name: h.name,
974
- value: c.value,
975
+ name: l.name,
976
+ value: d.value,
975
977
  isSvg: s,
976
978
  }),
977
979
  )
978
- : r.push(Ct(e, t, { name: h.name, isSvg: s }))
980
+ : r.push(Ct(e, t, { name: l.name, isSvg: s }))
979
981
  }
980
982
  }
981
- for (u = 0; u < l; u++) {
982
- c = null
983
- const h = a.item(u)
984
- if (h) {
985
- for (d = 0; d < i; d++) {
986
- const p = n.item(d)
987
- if (p && p.name == h.name) {
988
- c = p
983
+ for (u = 0; u < c; u++) {
984
+ d = null
985
+ const l = a.item(u)
986
+ if (l) {
987
+ for (h = 0; h < i; h++) {
988
+ const p = n.item(h)
989
+ if (p && p.name == l.name) {
990
+ d = p
989
991
  break
990
992
  }
991
993
  }
992
- c ||
994
+ d ||
993
995
  r.push(
994
996
  It(e, t, {
995
- name: h.name,
996
- value: h.value,
997
+ name: l.name,
998
+ value: l.value,
997
999
  isSvg: s,
998
1000
  }),
999
1001
  )
@@ -1008,15 +1010,15 @@ const S = (e) => {
1008
1010
  i = Object.keys(r),
1009
1011
  a = Object.keys(n)
1010
1012
  return (
1011
- i.forEach((l) => {
1012
- const u = r[l],
1013
- d = n[l]
1014
- d
1015
- ? d.busEvent !== u.busEvent &&
1013
+ i.forEach((c) => {
1014
+ const u = r[c],
1015
+ h = n[c]
1016
+ h
1017
+ ? h.busEvent !== u.busEvent &&
1016
1018
  s.push(
1017
1019
  Ht(e, t, {
1018
- name: l,
1019
- targetValue: d.listener,
1020
+ name: c,
1021
+ targetValue: h.listener,
1020
1022
  sourceValue: u.listener,
1021
1023
  }),
1022
1024
  )
@@ -1027,14 +1029,14 @@ const S = (e) => {
1027
1029
  }),
1028
1030
  )
1029
1031
  }),
1030
- a.forEach((l) => {
1031
- const u = r[l],
1032
- d = n[l]
1032
+ a.forEach((c) => {
1033
+ const u = r[c],
1034
+ h = n[c]
1033
1035
  u ||
1034
1036
  s.push(
1035
1037
  Gt(e, t, {
1036
- name: d.domEvent,
1037
- value: d.listener,
1038
+ name: h.domEvent,
1039
+ value: h.listener,
1038
1040
  }),
1039
1041
  )
1040
1042
  }),
@@ -1063,14 +1065,14 @@ const S = (e) => {
1063
1065
  const n = e,
1064
1066
  i = t,
1065
1067
  a = re(n, i),
1066
- l = s(n.childNodes, i.childNodes, n)
1067
- r = a.concat(l)
1068
+ c = s(n.childNodes, i.childNodes, n)
1069
+ r = a.concat(c)
1068
1070
  } else if (e.nodeType === 1) {
1069
1071
  const n = e,
1070
1072
  i = t,
1071
1073
  a = se(n, i),
1072
- l = s(n.childNodes, i.childNodes, n)
1073
- r = a.concat(l)
1074
+ c = s(n.childNodes, i.childNodes, n)
1075
+ r = a.concat(c)
1074
1076
  } else e.nodeType === 3 && (r = ne(e, t))
1075
1077
  return r
1076
1078
  },
@@ -1079,14 +1081,14 @@ const S = (e) => {
1079
1081
  n = oe(e, t),
1080
1082
  i = S(e),
1081
1083
  a = S(t),
1082
- l = []
1084
+ c = []
1083
1085
  let u = 0
1084
1086
  for (; u < n; u++) {
1085
- const c = e[u],
1086
- h = t[u]
1087
- if (h && a.check(h)) {
1088
- const p = i.pullMatch(h)
1089
- a.clear(h),
1087
+ const d = e[u],
1088
+ l = t[u]
1089
+ if (l && a.check(l)) {
1090
+ const p = i.pullMatch(l)
1091
+ a.clear(l),
1090
1092
  p.element
1091
1093
  ? (p.index !== u &&
1092
1094
  r.push(
@@ -1095,25 +1097,25 @@ const S = (e) => {
1095
1097
  index: u,
1096
1098
  }),
1097
1099
  ),
1098
- l.push({
1100
+ c.push({
1099
1101
  source: p.element,
1100
- target: h,
1102
+ target: l,
1101
1103
  }))
1102
- : c
1103
- ? a.check(c)
1104
- ? r.push(b(h, { parent: s, index: u }))
1105
- : (i.clear(c), r.push(Ut(c, h)))
1106
- : r.push(b(h, { parent: s, index: u }))
1107
- } else c && i.pullMatch(c).element && r.push(N(c))
1104
+ : d
1105
+ ? a.check(d)
1106
+ ? r.push(b(l, { parent: s, index: u }))
1107
+ : (i.clear(d), r.push(Ut(d, l)))
1108
+ : r.push(b(l, { parent: s, index: u }))
1109
+ } else d && i.pullMatch(d).element && r.push(N(d))
1108
1110
  }
1109
- i.remaining().forEach(({ element: c }) => {
1110
- r.push(N(c))
1111
+ i.remaining().forEach(({ element: d }) => {
1112
+ r.push(N(d))
1111
1113
  })
1112
- const d = l.reduce(
1113
- (c, { source: h, target: p }) => c.concat(ie(h, p, X)),
1114
+ const h = c.reduce(
1115
+ (d, { source: l, target: p }) => d.concat(ie(l, p, X)),
1114
1116
  [],
1115
1117
  )
1116
- return r.concat(d).sort(Wt)
1118
+ return r.concat(h).sort(Wt)
1117
1119
  },
1118
1120
  oe = (e, t) => {
1119
1121
  const s = e.length,
package/dist/jaxs.umd.cjs CHANGED
@@ -26,7 +26,7 @@
26
26
  const n = {}
27
27
  for (const r in t) {
28
28
  const i = t[r],
29
- a = (l) => s(i, l)
29
+ a = (c) => s(i, c)
30
30
  e.addEventListener(r, a),
31
31
  (n[r] = { domEvent: r, busEvent: i, listener: a })
32
32
  }
@@ -288,14 +288,15 @@
288
288
  const t = e.closest('[href]')
289
289
  return (t && t.getAttribute('href')) || ''
290
290
  },
291
- E = (e, { publish: t, window: s }) => {
291
+ E = ({ payload: e, publish: t, window: s }) => {
292
292
  s.history.pushState(null, '', e), t(b, null)
293
293
  },
294
- F = (e, t) => {
295
- if (!e || !e.target) return
296
- e.preventDefault()
297
- const s = V(e.target)
298
- E(s, t)
294
+ F = (e) => {
295
+ const t = e.payload
296
+ if (!t || !t.target) return
297
+ t.preventDefault()
298
+ const s = V(t.target)
299
+ E({ ...e, payload: s })
299
300
  },
300
301
  L = (e) =>
301
302
  e
@@ -306,19 +307,19 @@
306
307
  const n = s.split('=')
307
308
  return (t[n[0]] = n[1]), t
308
309
  }, {}),
309
- z = (e, t) => {
310
- const { state: s, publish: n, window: r } = t,
311
- { host: i, pathname: a, search: l } = r.location,
312
- u = a,
313
- d = L(l),
314
- c = { host: i, path: u, query: d }
315
- s.store('route').update(c), n(D, c)
310
+ z = (e) => {
311
+ const { state: t, publish: s, window: n } = e,
312
+ { host: r, pathname: i, search: a } = n.location,
313
+ c = i,
314
+ u = L(a),
315
+ h = { host: r, path: c, query: u }
316
+ t.store('route').update(h), s(D, h)
316
317
  },
317
318
  B = (e) => {
318
319
  const { subscribe: t } = e
319
320
  t(k, F),
320
- t($, (s, n) => {
321
- E(s, n)
321
+ t($, (s) => {
322
+ E(s)
322
323
  })
323
324
  },
324
325
  K = (e) => {
@@ -352,7 +353,7 @@
352
353
  subscribe: r,
353
354
  bus: i,
354
355
  state: a,
355
- renderKit: l,
356
+ renderKit: c,
356
357
  }) {
357
358
  ;(this.window = t),
358
359
  (this.document = s),
@@ -360,7 +361,7 @@
360
361
  (this.subscribe = r),
361
362
  (this.bus = i),
362
363
  (this.state = a),
363
- (this.renderKit = l),
364
+ (this.renderKit = c),
364
365
  (this.roots = [])
365
366
  }
366
367
  render(t, s) {
@@ -490,14 +491,19 @@
490
491
  ]
491
492
  .sort((r, i) => r.index - i.index)
492
493
  .forEach((r) => {
493
- r.listener(s, this.listenerOptions(t))
494
+ r.listener(this.listenerOptions(t, s))
494
495
  })
495
496
  }
496
497
  addListenerOptions(t) {
497
498
  this.options = t
498
499
  }
499
- listenerOptions(t) {
500
- return { eventName: t, ...this.options, publish: this.publish.bind(this) }
500
+ listenerOptions(t, s) {
501
+ return {
502
+ eventName: t,
503
+ ...this.options,
504
+ publish: this.publish.bind(this),
505
+ payload: s,
506
+ }
501
507
  }
502
508
  }
503
509
  const G = () => {
@@ -863,37 +869,37 @@
863
869
  r = e.attributes,
864
870
  i = r.length,
865
871
  a = t.attributes,
866
- l = a.length
867
- let u, d, c
872
+ c = a.length
873
+ let u, h, d
868
874
  for (u = 0; u < i; u++) {
869
- c = null
870
- const h = r.item(u)
871
- if (h) {
872
- for (d = 0; d < l; d++) {
873
- const m = a.item(d)
874
- if (m && h.name == m.name) {
875
- c = m
875
+ d = null
876
+ const l = r.item(u)
877
+ if (l) {
878
+ for (h = 0; h < c; h++) {
879
+ const m = a.item(h)
880
+ if (m && l.name == m.name) {
881
+ d = m
876
882
  break
877
883
  }
878
884
  }
879
- c
880
- ? h.value !== c.value &&
881
- n.push(Xt(e, t, { name: h.name, value: c.value, isSvg: s }))
882
- : n.push(Qt(e, t, { name: h.name, isSvg: s }))
885
+ d
886
+ ? l.value !== d.value &&
887
+ n.push(Xt(e, t, { name: l.name, value: d.value, isSvg: s }))
888
+ : n.push(Qt(e, t, { name: l.name, isSvg: s }))
883
889
  }
884
890
  }
885
- for (u = 0; u < l; u++) {
886
- c = null
887
- const h = a.item(u)
888
- if (h) {
889
- for (d = 0; d < i; d++) {
890
- const m = r.item(d)
891
- if (m && m.name == h.name) {
892
- c = m
891
+ for (u = 0; u < c; u++) {
892
+ d = null
893
+ const l = a.item(u)
894
+ if (l) {
895
+ for (h = 0; h < i; h++) {
896
+ const m = r.item(h)
897
+ if (m && m.name == l.name) {
898
+ d = m
893
899
  break
894
900
  }
895
901
  }
896
- c || n.push(Wt(e, t, { name: h.name, value: h.value, isSvg: s }))
902
+ d || n.push(Wt(e, t, { name: l.name, value: l.value, isSvg: s }))
897
903
  }
898
904
  }
899
905
  return n
@@ -905,24 +911,24 @@
905
911
  i = Object.keys(n),
906
912
  a = Object.keys(r)
907
913
  return (
908
- i.forEach((l) => {
909
- const u = n[l],
910
- d = r[l]
911
- d
912
- ? d.busEvent !== u.busEvent &&
914
+ i.forEach((c) => {
915
+ const u = n[c],
916
+ h = r[c]
917
+ h
918
+ ? h.busEvent !== u.busEvent &&
913
919
  s.push(
914
920
  te(e, t, {
915
- name: l,
916
- targetValue: d.listener,
921
+ name: c,
922
+ targetValue: h.listener,
917
923
  sourceValue: u.listener,
918
924
  }),
919
925
  )
920
926
  : s.push(Yt(e, t, { name: u.domEvent, value: u.listener }))
921
927
  }),
922
- a.forEach((l) => {
923
- const u = n[l],
924
- d = r[l]
925
- u || s.push(Zt(e, t, { name: d.domEvent, value: d.listener }))
928
+ a.forEach((c) => {
929
+ const u = n[c],
930
+ h = r[c]
931
+ u || s.push(Zt(e, t, { name: h.domEvent, value: h.listener }))
926
932
  }),
927
933
  s
928
934
  )
@@ -949,14 +955,14 @@
949
955
  const r = e,
950
956
  i = t,
951
957
  a = ce(r, i),
952
- l = s(r.childNodes, i.childNodes, r)
953
- n = a.concat(l)
958
+ c = s(r.childNodes, i.childNodes, r)
959
+ n = a.concat(c)
954
960
  } else if (e.nodeType === 1) {
955
961
  const r = e,
956
962
  i = t,
957
963
  a = ae(r, i),
958
- l = s(r.childNodes, i.childNodes, r)
959
- n = a.concat(l)
964
+ c = s(r.childNodes, i.childNodes, r)
965
+ n = a.concat(c)
960
966
  } else e.nodeType === 3 && (n = le(e, t))
961
967
  return n
962
968
  },
@@ -965,32 +971,32 @@
965
971
  r = de(e, t),
966
972
  i = Y(e),
967
973
  a = Y(t),
968
- l = []
974
+ c = []
969
975
  let u = 0
970
976
  for (; u < r; u++) {
971
- const c = e[u],
972
- h = t[u]
973
- if (h && a.check(h)) {
974
- const m = i.pullMatch(h)
975
- a.clear(h),
977
+ const d = e[u],
978
+ l = t[u]
979
+ if (l && a.check(l)) {
980
+ const m = i.pullMatch(l)
981
+ a.clear(l),
976
982
  m.element
977
983
  ? (m.index !== u && n.push(_(m.element, { parent: s, index: u })),
978
- l.push({ source: m.element, target: h }))
979
- : c
980
- ? a.check(c)
981
- ? n.push(_(h, { parent: s, index: u }))
982
- : (i.clear(c), n.push(Ht(c, h)))
983
- : n.push(_(h, { parent: s, index: u }))
984
- } else c && i.pullMatch(c).element && n.push(W(c))
984
+ c.push({ source: m.element, target: l }))
985
+ : d
986
+ ? a.check(d)
987
+ ? n.push(_(l, { parent: s, index: u }))
988
+ : (i.clear(d), n.push(Ht(d, l)))
989
+ : n.push(_(l, { parent: s, index: u }))
990
+ } else d && i.pullMatch(d).element && n.push(W(d))
985
991
  }
986
- i.remaining().forEach(({ element: c }) => {
987
- n.push(W(c))
992
+ i.remaining().forEach(({ element: d }) => {
993
+ n.push(W(d))
988
994
  })
989
- const d = l.reduce(
990
- (c, { source: h, target: m }) => c.concat(he(h, m, tt)),
995
+ const h = c.reduce(
996
+ (d, { source: l, target: m }) => d.concat(he(l, m, tt)),
991
997
  [],
992
998
  )
993
- return n.concat(d).sort(se)
999
+ return n.concat(h).sort(se)
994
1000
  },
995
1001
  de = (e, t) => {
996
1002
  const s = e.length,
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.3",
5
+ "version": "0.8.0",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "vite build; npm run lint",
@@ -11,7 +11,7 @@
11
11
  "e2e:server": "vite dev --config ./cypress/apps/vite.config.js",
12
12
  "e2e": "cypress open",
13
13
  "e2e:ci": "cypress run",
14
- "lint": "prettier . --write"
14
+ "lint": "prettier . --write && tsc --noEmit"
15
15
  },
16
16
  "files": [
17
17
  "dist"