jaxs 0.9.2 → 0.9.3

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
@@ -460,6 +460,8 @@ export declare const ListStore: {
460
460
  reset: <T>(store: Store<T[]>) => void
461
461
  includes: <T>(store: Store<T[]>, value: T) => boolean
462
462
  appendIfUnique: <T>(store: Store<T[]>, item: T) => void
463
+ findBy: <T>(store: Store<T[]>, matcherFunction: (value: T) => boolean) => T
464
+ replace: <T>(store: Store<T[]>, original: T, replacement: T) => void
463
465
  }
464
466
 
465
467
  declare const locationChangeEvent = 'navigation:location-change'
@@ -741,6 +743,8 @@ declare class StoreUpdaterList<T> {
741
743
  removeBy(matcherFunction: (value: T) => boolean): void
742
744
  includes(value: T): boolean
743
745
  appendIfUnique(item: T): void
746
+ findBy(matcherFunction: (value: T) => boolean): T
747
+ replace(original: T, replacement: T): void
744
748
  }
745
749
 
746
750
  declare class StoreUpdaterObject<T extends object> {
package/dist/jaxs.js CHANGED
@@ -65,7 +65,7 @@ const f = (e) => new ct(e),
65
65
  isTrue: (e) => f(e).isTrue(),
66
66
  isFalse: (e) => f(e).isFalse(),
67
67
  }
68
- class ht {
68
+ class lt {
69
69
  constructor(t) {
70
70
  this.store = t
71
71
  }
@@ -119,8 +119,16 @@ class ht {
119
119
  const s = this.value
120
120
  $(s, t), this.update(s)
121
121
  }
122
+ findBy(t) {
123
+ return this.value.find(t)
124
+ }
125
+ replace(t, s) {
126
+ const r = this.value,
127
+ n = r.indexOf(t)
128
+ n !== -1 && ((r[n] = s), this.update(r))
129
+ }
122
130
  }
123
- const m = (e) => new ht(e),
131
+ const m = (e) => new lt(e),
124
132
  ze = {
125
133
  push: (e, t) => m(e).push(t),
126
134
  pop: (e) => m(e).pop(),
@@ -133,8 +141,10 @@ const m = (e) => new ht(e),
133
141
  reset: (e) => m(e).reset(),
134
142
  includes: (e, t) => m(e).includes(t),
135
143
  appendIfUnique: (e, t) => m(e).appendIfUnique(t),
144
+ findBy: (e, t) => m(e).findBy(t),
145
+ replace: (e, t, s) => m(e).replace(t, s),
136
146
  }
137
- class lt {
147
+ class ht {
138
148
  constructor(t) {
139
149
  this.store = t
140
150
  }
@@ -173,7 +183,7 @@ class lt {
173
183
  return !!this.value[t]
174
184
  }
175
185
  }
176
- const b = (e) => new lt(e),
186
+ const b = (e) => new ht(e),
177
187
  Ke = {
178
188
  reset: (e) => b(e).reset(),
179
189
  resetAttribute: (e, t) => b(e).resetAttribute(t),
@@ -183,13 +193,13 @@ const b = (e) => new lt(e),
183
193
  },
184
194
  dt = (e) => typeof e == 'boolean',
185
195
  pt = (e) => typeof e == 'number',
186
- D = (e) => typeof e == 'string',
196
+ B = (e) => typeof e == 'string',
187
197
  v = (e) => Array.isArray(e),
188
198
  g = (e) => e !== null && !v(e) && typeof e == 'object',
189
199
  Re = {
190
200
  boolean: dt,
191
201
  number: pt,
192
- string: D,
202
+ string: B,
193
203
  array: v,
194
204
  object: g,
195
205
  },
@@ -202,7 +212,7 @@ const b = (e) => new lt(e),
202
212
  const n = e
203
213
  n.value !== r && (n.value = r)
204
214
  } else
205
- D(r) && r.trim() === '' ? e.removeAttribute(s) : e.setAttribute(s, r)
215
+ B(r) && r.trim() === '' ? e.removeAttribute(s) : e.setAttribute(s, r)
206
216
  }
207
217
  },
208
218
  bt = (e, t, s) => {
@@ -311,9 +321,9 @@ class wt {
311
321
  const Nt = (e) => typeof e == 'string' || typeof e == 'number',
312
322
  _t = (e) => new wt(e),
313
323
  St = (e) => (Nt(e) ? _t(e) : e),
314
- P = (e) => Tt(e).map(St).flat(),
324
+ D = (e) => Tt(e).map(St).flat(),
315
325
  Tt = (e) => (Array.isArray(e) ? e.flat() : e ? [e] : []),
316
- B = (e, t = {}) => P(e || t.children || []),
326
+ P = (e, t = {}) => D(e || t.children || []),
317
327
  jt = (e, t = '') => {
318
328
  const s = {},
319
329
  r = {}
@@ -335,7 +345,7 @@ const Nt = (e) => typeof e == 'string' || typeof e == 'number',
335
345
  Ot = (e, t, s = '') => (t == null ? s : t.toString()),
336
346
  Mt = (e, t) => {
337
347
  const s = e || {},
338
- r = B(t, s)
348
+ r = P(t, s)
339
349
  return (s.children = s.children || r), s
340
350
  },
341
351
  F = (e, t, s, r = []) => e.reduce(kt(t, s), r).flat(),
@@ -347,7 +357,7 @@ const Nt = (e) => typeof e == 'string' || typeof e == 'number',
347
357
  : s
348
358
  class V {
349
359
  constructor(t) {
350
- this.collection = P(t)
360
+ this.collection = D(t)
351
361
  }
352
362
  render(t, s) {
353
363
  this.parentElement = s
@@ -389,7 +399,7 @@ class $t {
389
399
  return `${this.type}${t}${s}${r}`
390
400
  }
391
401
  }
392
- class Dt {
402
+ class Bt {
393
403
  constructor(t, s, r = []) {
394
404
  this.type = t
395
405
  const { events: n, attributes: i } = jt(s)
@@ -417,13 +427,13 @@ class Dt {
417
427
  return new $t(this.type, this.attributes).generate()
418
428
  }
419
429
  }
420
- const Pt = (e, t, ...s) =>
421
- typeof e == 'string' ? new Dt(e, t, s) : e(Mt(t, s))
422
- Pt.fragment = (e, t) => {
423
- const s = B(t, e)
430
+ const Dt = (e, t, ...s) =>
431
+ typeof e == 'string' ? new Bt(e, t, s) : e(Mt(t, s))
432
+ Dt.fragment = (e, t) => {
433
+ const s = P(t, e)
424
434
  return new V(s)
425
435
  }
426
- class Bt {
436
+ class Pt {
427
437
  constructor(t, s, r) {
428
438
  ;(this.template = t),
429
439
  (this.selector = s),
@@ -449,7 +459,7 @@ class Bt {
449
459
  }
450
460
  }
451
461
  const Ft = (e, t, s) => {
452
- const r = new Bt(e, t, s)
462
+ const r = new Pt(e, t, s)
453
463
  return r.renderAndAttach(s), r
454
464
  },
455
465
  L = 'go-to-href',
@@ -504,12 +514,12 @@ const Ft = (e, t, s) => {
504
514
  { host: n, pathname: i, search: a } = r.location,
505
515
  c = i,
506
516
  u = I(a),
507
- l = {
517
+ h = {
508
518
  host: n,
509
519
  path: c,
510
520
  query: u,
511
521
  }
512
- t.store('route').update(l), s(K, l)
522
+ t.store('route').update(h), s(K, h)
513
523
  },
514
524
  G = (e) => {
515
525
  const { subscribe: t } = e
@@ -1057,37 +1067,37 @@ const j = (e) => {
1057
1067
  i = n.length,
1058
1068
  a = t.attributes,
1059
1069
  c = a.length
1060
- let u, l, d
1070
+ let u, h, d
1061
1071
  for (u = 0; u < i; u++) {
1062
1072
  d = null
1063
- const h = n.item(u)
1064
- if (h) {
1065
- for (l = 0; l < c; l++) {
1066
- const p = a.item(l)
1067
- if (p && h.name == p.name) {
1073
+ const l = n.item(u)
1074
+ if (l) {
1075
+ for (h = 0; h < c; h++) {
1076
+ const p = a.item(h)
1077
+ if (p && l.name == p.name) {
1068
1078
  d = p
1069
1079
  break
1070
1080
  }
1071
1081
  }
1072
1082
  d
1073
- ? h.value !== d.value &&
1083
+ ? l.value !== d.value &&
1074
1084
  r.push(
1075
1085
  Qt(e, t, {
1076
- name: h.name,
1086
+ name: l.name,
1077
1087
  value: d.value,
1078
1088
  isSvg: s,
1079
1089
  }),
1080
1090
  )
1081
- : r.push(Ht(e, t, { name: h.name, isSvg: s }))
1091
+ : r.push(Ht(e, t, { name: l.name, isSvg: s }))
1082
1092
  }
1083
1093
  }
1084
1094
  for (u = 0; u < c; u++) {
1085
1095
  d = null
1086
- const h = a.item(u)
1087
- if (h) {
1088
- for (l = 0; l < i; l++) {
1089
- const p = n.item(l)
1090
- if (p && p.name == h.name) {
1096
+ const l = a.item(u)
1097
+ if (l) {
1098
+ for (h = 0; h < i; h++) {
1099
+ const p = n.item(h)
1100
+ if (p && p.name == l.name) {
1091
1101
  d = p
1092
1102
  break
1093
1103
  }
@@ -1095,8 +1105,8 @@ const j = (e) => {
1095
1105
  d ||
1096
1106
  r.push(
1097
1107
  Ct(e, t, {
1098
- name: h.name,
1099
- value: h.value,
1108
+ name: l.name,
1109
+ value: l.value,
1100
1110
  isSvg: s,
1101
1111
  }),
1102
1112
  )
@@ -1113,13 +1123,13 @@ const j = (e) => {
1113
1123
  return (
1114
1124
  i.forEach((c) => {
1115
1125
  const u = r[c],
1116
- l = n[c]
1117
- l
1118
- ? l.busEvent !== u.busEvent &&
1126
+ h = n[c]
1127
+ h
1128
+ ? h.busEvent !== u.busEvent &&
1119
1129
  s.push(
1120
1130
  Yt(e, t, {
1121
1131
  name: c,
1122
- targetValue: l.listener,
1132
+ targetValue: h.listener,
1123
1133
  sourceValue: u.listener,
1124
1134
  }),
1125
1135
  )
@@ -1132,12 +1142,12 @@ const j = (e) => {
1132
1142
  }),
1133
1143
  a.forEach((c) => {
1134
1144
  const u = r[c],
1135
- l = n[c]
1145
+ h = n[c]
1136
1146
  u ||
1137
1147
  s.push(
1138
1148
  Xt(e, t, {
1139
- name: l.domEvent,
1140
- value: l.listener,
1149
+ name: h.domEvent,
1150
+ value: h.listener,
1141
1151
  }),
1142
1152
  )
1143
1153
  }),
@@ -1179,17 +1189,17 @@ const j = (e) => {
1179
1189
  },
1180
1190
  ot = (e, t, s) => {
1181
1191
  const r = [],
1182
- n = he(e, t),
1192
+ n = le(e, t),
1183
1193
  i = j(e),
1184
1194
  a = j(t),
1185
1195
  c = []
1186
1196
  let u = 0
1187
1197
  for (; u < n; u++) {
1188
1198
  const d = e[u],
1189
- h = t[u]
1190
- if (h && a.check(h)) {
1191
- const p = i.pullMatch(h)
1192
- a.clear(h),
1199
+ l = t[u]
1200
+ if (l && a.check(l)) {
1201
+ const p = i.pullMatch(l)
1202
+ a.clear(l),
1193
1203
  p.element
1194
1204
  ? (p.index !== u &&
1195
1205
  r.push(
@@ -1200,30 +1210,30 @@ const j = (e) => {
1200
1210
  ),
1201
1211
  c.push({
1202
1212
  source: p.element,
1203
- target: h,
1213
+ target: l,
1204
1214
  }))
1205
1215
  : d
1206
1216
  ? a.check(d)
1207
- ? r.push(A(h, { parent: s, index: u }))
1208
- : (i.clear(d), r.push(Gt(d, h)))
1209
- : r.push(A(h, { parent: s, index: u }))
1217
+ ? r.push(A(l, { parent: s, index: u }))
1218
+ : (i.clear(d), r.push(Gt(d, l)))
1219
+ : r.push(A(l, { parent: s, index: u }))
1210
1220
  } else d && i.pullMatch(d).element && r.push(S(d))
1211
1221
  }
1212
1222
  i.remaining().forEach(({ element: d }) => {
1213
1223
  r.push(S(d))
1214
1224
  })
1215
- const l = c.reduce(
1216
- (d, { source: h, target: p }) => d.concat(ce(h, p, ot)),
1225
+ const h = c.reduce(
1226
+ (d, { source: l, target: p }) => d.concat(ce(l, p, ot)),
1217
1227
  [],
1218
1228
  )
1219
- return r.concat(l).sort(te)
1229
+ return r.concat(h).sort(te)
1220
1230
  },
1221
- he = (e, t) => {
1231
+ le = (e, t) => {
1222
1232
  const s = e.length,
1223
1233
  r = t.length
1224
1234
  return s > r ? s : r
1225
1235
  },
1226
- le = (e, t, s) => {
1236
+ he = (e, t, s) => {
1227
1237
  const r = ot(e, t, s)
1228
1238
  return (
1229
1239
  r.forEach((n) => {
@@ -1370,7 +1380,7 @@ class ke {
1370
1380
  this.parentElement = r
1371
1381
  }
1372
1382
  const t = this.generateDom(this.renderKit),
1373
- s = le(this.dom, t, this.parentElement)
1383
+ s = he(this.dom, t, this.parentElement)
1374
1384
  this.dom = _e(s, this.dom, this.parentElement)
1375
1385
  }
1376
1386
  subscribeForRerender() {
@@ -1384,17 +1394,17 @@ class ke {
1384
1394
  }
1385
1395
  }
1386
1396
  const $e = (e) => e,
1387
- De = ({ Template: e, viewModel: t, subscriptions: s }) => (
1397
+ Be = ({ Template: e, viewModel: t, subscriptions: s }) => (
1388
1398
  (s = s || []),
1389
1399
  (t = t || $e),
1390
1400
  (r) =>
1391
1401
  new ke({ Template: e, viewModel: t, subscriptions: s, attributes: r })
1392
1402
  ),
1393
- Pe =
1403
+ De =
1394
1404
  (e) =>
1395
1405
  ({ path: t }) =>
1396
1406
  t === e,
1397
- Be = () => !0,
1407
+ Pe = () => !0,
1398
1408
  at =
1399
1409
  (e) =>
1400
1410
  ({ route: t }) => {
@@ -1406,8 +1416,8 @@ const $e = (e) => e,
1406
1416
  {
1407
1417
  __proto__: null,
1408
1418
  buildRouter: at,
1409
- catchAll: Be,
1410
- exactPathMatch: Pe,
1419
+ catchAll: Pe,
1420
+ exactPathMatch: De,
1411
1421
  },
1412
1422
  Symbol.toStringTag,
1413
1423
  { value: 'Module' },
@@ -1418,7 +1428,7 @@ const $e = (e) => e,
1418
1428
  }),
1419
1429
  Qe = (e) => {
1420
1430
  const t = at(e)
1421
- return De({
1431
+ return Be({
1422
1432
  Template: ({ route: r }) => (t({ route: r }) || Fe)(),
1423
1433
  subscriptions: ['route'],
1424
1434
  })
@@ -1449,9 +1459,9 @@ export {
1449
1459
  ze as ListStore,
1450
1460
  Ke as RecordStore,
1451
1461
  Ue as appBuilding,
1452
- De as bind,
1462
+ Be as bind,
1453
1463
  Ge as createApp,
1454
- Pt as jsx,
1464
+ Dt as jsx,
1455
1465
  qe as messageBus,
1456
1466
  We as navigation,
1457
1467
  Qe as routedView,
package/dist/jaxs.umd.cjs CHANGED
@@ -122,6 +122,14 @@
122
122
  const s = this.value
123
123
  M(s, t), this.update(s)
124
124
  }
125
+ findBy(t) {
126
+ return this.value.find(t)
127
+ }
128
+ replace(t, s) {
129
+ const r = this.value,
130
+ n = r.indexOf(t)
131
+ n !== -1 && ((r[n] = s), this.update(r))
132
+ }
125
133
  }
126
134
  const m = (e) => new mt(e),
127
135
  bt = {
@@ -136,6 +144,8 @@
136
144
  reset: (e) => m(e).reset(),
137
145
  includes: (e, t) => m(e).includes(t),
138
146
  appendIfUnique: (e, t) => m(e).appendIfUnique(t),
147
+ findBy: (e, t) => m(e).findBy(t),
148
+ replace: (e, t, s) => m(e).replace(t, s),
139
149
  }
140
150
  class vt {
141
151
  constructor(t) {
@@ -302,11 +312,11 @@
302
312
  }
303
313
  }
304
314
  const $t = (e) => typeof e == 'string' || typeof e == 'number',
305
- Dt = (e) => new kt(e),
306
- Pt = (e) => ($t(e) ? Dt(e) : e),
307
- $ = (e) => Bt(e).map(Pt).flat(),
308
- Bt = (e) => (Array.isArray(e) ? e.flat() : e ? [e] : []),
309
- D = (e, t = {}) => $(e || t.children || []),
315
+ Bt = (e) => new kt(e),
316
+ Dt = (e) => ($t(e) ? Bt(e) : e),
317
+ $ = (e) => Pt(e).map(Dt).flat(),
318
+ Pt = (e) => (Array.isArray(e) ? e.flat() : e ? [e] : []),
319
+ B = (e, t = {}) => $(e || t.children || []),
310
320
  Ft = (e, t = '') => {
311
321
  const s = {},
312
322
  r = {}
@@ -325,17 +335,17 @@
325
335
  Vt = (e, t, s = '') => (t == null ? s : t.toString()),
326
336
  Lt = (e, t) => {
327
337
  const s = e || {},
328
- r = D(t, s)
338
+ r = B(t, s)
329
339
  return (s.children = s.children || r), s
330
340
  },
331
- P = (e, t, s, r = []) => e.reduce(zt(t, s), r).flat(),
341
+ D = (e, t, s, r = []) => e.reduce(zt(t, s), r).flat(),
332
342
  zt = (e, t) => (s, r) =>
333
343
  r
334
344
  ? Array.isArray(r)
335
- ? P(r, e, t, s)
345
+ ? D(r, e, t, s)
336
346
  : (r.render(e, t).forEach((n) => s.push(n)), s)
337
347
  : s
338
- class B {
348
+ class P {
339
349
  constructor(t) {
340
350
  this.collection = $(t)
341
351
  }
@@ -345,7 +355,7 @@
345
355
  return this.attachToParent(r), r
346
356
  }
347
357
  generateDom(t) {
348
- return P(this.collection, t, this.parentElement)
358
+ return D(this.collection, t, this.parentElement)
349
359
  }
350
360
  attachToParent(t) {
351
361
  if (this.parentElement === void 0) return
@@ -388,7 +398,7 @@
388
398
  ;(this.events = n),
389
399
  (this.attributes = i),
390
400
  (this.isSvg = Tt(this.type, this.attributes.xmlns)),
391
- (this.children = new B(r))
401
+ (this.children = new P(r))
392
402
  }
393
403
  render(t) {
394
404
  const s = this.generateDom(t)
@@ -412,8 +422,8 @@
412
422
  const F = (e, t, ...s) =>
413
423
  typeof e == 'string' ? new Rt(e, t, s) : e(Lt(t, s))
414
424
  F.fragment = (e, t) => {
415
- const s = D(t, e)
416
- return new B(s)
425
+ const s = B(t, e)
426
+ return new P(s)
417
427
  }
418
428
  class Ut {
419
429
  constructor(t, s, r) {
@@ -1131,19 +1141,19 @@
1131
1141
  $e = (e) => {
1132
1142
  ct(e)
1133
1143
  },
1134
- De = (e) => {
1144
+ Be = (e) => {
1135
1145
  const t = e.data,
1136
1146
  s = e.source,
1137
1147
  { name: r, value: n } = t
1138
1148
  s.removeEventListener(r, n)
1139
1149
  },
1140
- Pe = (e) => {
1150
+ De = (e) => {
1141
1151
  const t = e.data,
1142
1152
  s = e.source,
1143
1153
  { name: r, value: n } = t
1144
1154
  s.addEventListener(r, n)
1145
1155
  },
1146
- Be = (e) => {
1156
+ Pe = (e) => {
1147
1157
  const t = e.data,
1148
1158
  s = e.source,
1149
1159
  { name: r, sourceValue: n, targetValue: i } = t
@@ -1163,9 +1173,9 @@
1163
1173
  [o.removeAttribute]: ke,
1164
1174
  [o.addAttribute]: ct,
1165
1175
  [o.updateAttribute]: $e,
1166
- [o.removeEvent]: De,
1167
- [o.addEvent]: Pe,
1168
- [o.updateEvent]: Be,
1176
+ [o.removeEvent]: Be,
1177
+ [o.addEvent]: De,
1178
+ [o.updateEvent]: Pe,
1169
1179
  [o.changeValue]: Fe,
1170
1180
  },
1171
1181
  Le = (e, t, s) => {
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.9.2",
5
+ "version": "0.9.3",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "vite build; npm run lint",