flemo 1.5.1 → 1.5.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +152 -154
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -24,21 +24,21 @@ function zt() {
24
24
  function o(i) {
25
25
  return i.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
26
26
  }
27
- class c {
27
+ class u {
28
28
  constructor(d, y) {
29
29
  this.tokens = d, this.originalPath = y;
30
30
  }
31
31
  }
32
- H.TokenData = c;
33
- class f extends TypeError {
32
+ H.TokenData = u;
33
+ class h extends TypeError {
34
34
  constructor(d, y) {
35
35
  let m = d;
36
36
  y && (m += `: ${y}`), m += "; visit https://git.new/pathToRegexpError for info", super(m), this.originalPath = y;
37
37
  }
38
38
  }
39
- H.PathError = f;
39
+ H.PathError = h;
40
40
  function l(i, d = {}) {
41
- const { encodePath: y = e } = d, m = [...i], h = [];
41
+ const { encodePath: y = e } = d, m = [...i], f = [];
42
42
  let p = 0, S = 0;
43
43
  function T() {
44
44
  let w = "";
@@ -56,27 +56,27 @@ function zt() {
56
56
  m[p] === "\\" && p++, w += m[p];
57
57
  }
58
58
  if (R)
59
- throw new f(`Unterminated quote at index ${R}`, i);
59
+ throw new h(`Unterminated quote at index ${R}`, i);
60
60
  }
61
61
  if (!w)
62
- throw new f(`Missing parameter name at index ${p}`, i);
62
+ throw new h(`Missing parameter name at index ${p}`, i);
63
63
  return w;
64
64
  }
65
65
  for (; p < m.length; ) {
66
66
  const w = m[p], R = r[w];
67
- R ? h.push({ type: R, index: p++, value: w }) : w === "\\" ? h.push({ type: "escape", index: p++, value: m[p++] }) : w === ":" ? h.push({ type: "param", index: p++, value: T() }) : w === "*" ? h.push({ type: "wildcard", index: p++, value: T() }) : h.push({ type: "char", index: p++, value: w });
67
+ R ? f.push({ type: R, index: p++, value: w }) : w === "\\" ? f.push({ type: "escape", index: p++, value: m[p++] }) : w === ":" ? f.push({ type: "param", index: p++, value: T() }) : w === "*" ? f.push({ type: "wildcard", index: p++, value: T() }) : f.push({ type: "char", index: p++, value: w });
68
68
  }
69
- h.push({ type: "end", index: p, value: "" });
69
+ f.push({ type: "end", index: p, value: "" });
70
70
  function C(w) {
71
71
  const R = [];
72
72
  for (; ; ) {
73
- const N = h[S++];
73
+ const N = f[S++];
74
74
  if (N.type === w)
75
75
  break;
76
76
  if (N.type === "char" || N.type === "escape") {
77
- let O = N.value, j = h[S];
77
+ let O = N.value, j = f[S];
78
78
  for (; j.type === "char" || j.type === "escape"; )
79
- O += j.value, j = h[++S];
79
+ O += j.value, j = f[++S];
80
80
  R.push({
81
81
  type: "text",
82
82
  value: y(O)
@@ -97,14 +97,14 @@ function zt() {
97
97
  });
98
98
  continue;
99
99
  }
100
- throw new f(`Unexpected ${N.type} at index ${N.index}, expected ${w}`, i);
100
+ throw new h(`Unexpected ${N.type} at index ${N.index}, expected ${w}`, i);
101
101
  }
102
102
  return R;
103
103
  }
104
- return new c(C("end"), i);
104
+ return new u(C("end"), i);
105
105
  }
106
106
  function E(i, d = {}) {
107
- const { encode: y = encodeURIComponent, delimiter: m = n } = d, h = typeof i == "object" ? i : l(i, d), p = g(h.tokens, m, y);
107
+ const { encode: y = encodeURIComponent, delimiter: m = n } = d, f = typeof i == "object" ? i : l(i, d), p = g(f.tokens, m, y);
108
108
  return function(T = {}) {
109
109
  const [C, ...w] = p(T);
110
110
  if (w.length)
@@ -113,29 +113,29 @@ function zt() {
113
113
  };
114
114
  }
115
115
  function g(i, d, y) {
116
- const m = i.map((h) => u(h, d, y));
117
- return (h) => {
116
+ const m = i.map((f) => c(f, d, y));
117
+ return (f) => {
118
118
  const p = [""];
119
119
  for (const S of m) {
120
- const [T, ...C] = S(h);
120
+ const [T, ...C] = S(f);
121
121
  p[0] += T, p.push(...C);
122
122
  }
123
123
  return p;
124
124
  };
125
125
  }
126
- function u(i, d, y) {
126
+ function c(i, d, y) {
127
127
  if (i.type === "text")
128
128
  return () => [i.value];
129
129
  if (i.type === "group") {
130
- const h = g(i.tokens, d, y);
130
+ const f = g(i.tokens, d, y);
131
131
  return (p) => {
132
- const [S, ...T] = h(p);
132
+ const [S, ...T] = f(p);
133
133
  return T.length ? [""] : [S];
134
134
  };
135
135
  }
136
136
  const m = y || e;
137
- return i.type === "wildcard" && y !== !1 ? (h) => {
138
- const p = h[i.name];
137
+ return i.type === "wildcard" && y !== !1 ? (f) => {
138
+ const p = f[i.name];
139
139
  if (p == null)
140
140
  return ["", i.name];
141
141
  if (!Array.isArray(p) || p.length === 0)
@@ -147,8 +147,8 @@ function zt() {
147
147
  return m(S);
148
148
  }).join(d)
149
149
  ];
150
- } : (h) => {
151
- const p = h[i.name];
150
+ } : (f) => {
151
+ const p = f[i.name];
152
152
  if (p == null)
153
153
  return ["", i.name];
154
154
  if (typeof p != "string")
@@ -157,9 +157,9 @@ function zt() {
157
157
  };
158
158
  }
159
159
  function L(i, d = {}) {
160
- const { decode: y = decodeURIComponent, delimiter: m = n } = d, { regexp: h, keys: p } = D(i, d), S = p.map((T) => y === !1 ? e : T.type === "param" ? y : (C) => C.split(m).map(y));
160
+ const { decode: y = decodeURIComponent, delimiter: m = n } = d, { regexp: f, keys: p } = D(i, d), S = p.map((T) => y === !1 ? e : T.type === "param" ? y : (C) => C.split(m).map(y));
161
161
  return function(C) {
162
- const w = h.exec(C);
162
+ const w = f.exec(C);
163
163
  if (!w)
164
164
  return !1;
165
165
  const R = w[0], N = /* @__PURE__ */ Object.create(null);
@@ -173,7 +173,7 @@ function zt() {
173
173
  };
174
174
  }
175
175
  function D(i, d = {}) {
176
- const { delimiter: y = n, end: m = !0, sensitive: h = !1, trailing: p = !0 } = d, S = [], T = h ? "" : "i", C = [];
176
+ const { delimiter: y = n, end: m = !0, sensitive: f = !1, trailing: p = !0 } = d, S = [], T = f ? "" : "i", C = [];
177
177
  for (const N of I(i, [])) {
178
178
  const O = typeof N == "object" ? N : l(N, d);
179
179
  for (const j of P(O.tokens, 0, []))
@@ -195,55 +195,55 @@ function zt() {
195
195
  return yield y;
196
196
  const m = i[d];
197
197
  if (m.type === "group")
198
- for (const h of P(m.tokens, 0, y.slice()))
199
- yield* P(i, d + 1, h);
198
+ for (const f of P(m.tokens, 0, y.slice()))
199
+ yield* P(i, d + 1, f);
200
200
  else
201
201
  y.push(m);
202
202
  yield* P(i, d + 1, y);
203
203
  }
204
204
  function M(i, d, y, m) {
205
- let h = "", p = "", S = !0;
205
+ let f = "", p = "", S = !0;
206
206
  for (const T of i) {
207
207
  if (T.type === "text") {
208
- h += o(T.value), p += T.value, S || (S = T.value.includes(d));
208
+ f += o(T.value), p += T.value, S || (S = T.value.includes(d));
209
209
  continue;
210
210
  }
211
211
  if (T.type === "param" || T.type === "wildcard") {
212
212
  if (!S && !p)
213
- throw new f(`Missing text before "${T.name}" ${T.type}`, m);
214
- T.type === "param" ? h += `(${W(d, S ? "" : p)}+)` : h += "([\\s\\S]+)", y.push(T), p = "", S = !1;
213
+ throw new h(`Missing text before "${T.name}" ${T.type}`, m);
214
+ T.type === "param" ? f += `(${W(d, S ? "" : p)}+)` : f += "([\\s\\S]+)", y.push(T), p = "", S = !1;
215
215
  continue;
216
216
  }
217
217
  }
218
- return h;
218
+ return f;
219
219
  }
220
220
  function W(i, d) {
221
221
  return d.length < 2 ? i.length < 2 ? `[^${o(i + d)}]` : `(?:(?!${o(i)})[^${o(d)}])` : i.length < 2 ? `(?:(?!${o(d)})[^${o(i)}])` : `(?:(?!${o(d)}|${o(i)})[\\s\\S])`;
222
222
  }
223
223
  function _(i) {
224
224
  let d = "", y = 0;
225
- function m(h) {
226
- return k(h) && b(i[y]) ? h : JSON.stringify(h);
225
+ function m(f) {
226
+ return k(f) && b(i[y]) ? f : JSON.stringify(f);
227
227
  }
228
228
  for (; y < i.length; ) {
229
- const h = i[y++];
230
- if (h.type === "text") {
231
- d += a(h.value);
229
+ const f = i[y++];
230
+ if (f.type === "text") {
231
+ d += a(f.value);
232
232
  continue;
233
233
  }
234
- if (h.type === "group") {
235
- d += `{${_(h.tokens)}}`;
234
+ if (f.type === "group") {
235
+ d += `{${_(f.tokens)}}`;
236
236
  continue;
237
237
  }
238
- if (h.type === "param") {
239
- d += `:${m(h.name)}`;
238
+ if (f.type === "param") {
239
+ d += `:${m(f.name)}`;
240
240
  continue;
241
241
  }
242
- if (h.type === "wildcard") {
243
- d += `*${m(h.name)}`;
242
+ if (f.type === "wildcard") {
243
+ d += `*${m(f.name)}`;
244
244
  continue;
245
245
  }
246
- throw new TypeError(`Unknown token type: ${h.type}`);
246
+ throw new TypeError(`Unknown token type: ${f.type}`);
247
247
  }
248
248
  return d;
249
249
  }
@@ -261,7 +261,7 @@ function zt() {
261
261
  }
262
262
  var K = zt();
263
263
  function Jt(n, e, t) {
264
- const s = Array.isArray(n) ? n.find((c) => K.pathToRegexp(c).regexp.test(e)) || "" : K.pathToRegexp(n).regexp.test(e) ? n : "", r = K.match(s)(e), a = new URLSearchParams(t), o = Object.fromEntries(a.entries());
264
+ const s = Array.isArray(n) ? n.find((u) => K.pathToRegexp(u).regexp.test(e)) || "" : K.pathToRegexp(n).regexp.test(e) ? n : "", r = K.match(s)(e), a = new URLSearchParams(t), o = Object.fromEntries(a.entries());
265
265
  return r ? { ...r.params, ...o } : {};
266
266
  }
267
267
  function Dt() {
@@ -335,7 +335,7 @@ class Zt {
335
335
  return new Promise((r, a) => {
336
336
  this.taskQueue = this.taskQueue.then(async () => {
337
337
  try {
338
- const { control: o, validate: c, rollback: f, dependencies: l = [], delay: E } = t, g = new AbortController(), u = {
338
+ const { control: o, validate: u, rollback: h, dependencies: l = [], delay: E } = t, g = new AbortController(), c = {
339
339
  id: s,
340
340
  execute: e,
341
341
  timestamp: Date.now(),
@@ -343,31 +343,31 @@ class Zt {
343
343
  status: "PENDING",
344
344
  dependencies: l,
345
345
  instanceId: this.instanceId,
346
- validate: c,
347
- rollback: f,
346
+ validate: u,
347
+ rollback: h,
348
348
  control: o,
349
349
  abortController: g
350
350
  };
351
- this.tasks.set(u.id, u), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(u), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((D) => D.id !== u.id));
351
+ this.tasks.set(c.id, c), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(c), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((D) => D.id !== c.id));
352
352
  try {
353
- if (!await this.acquireLock(u.id))
354
- throw u.status = "FAILED", new Error("FAILED");
353
+ if (!await this.acquireLock(c.id))
354
+ throw c.status = "FAILED", new Error("FAILED");
355
355
  try {
356
- u.status = "PROCESSING";
357
- for (const P of u.dependencies) {
356
+ c.status = "PROCESSING";
357
+ for (const P of c.dependencies) {
358
358
  const M = this.tasks.get(P);
359
359
  if (!M || M.status !== "COMPLETED")
360
- throw u.status = "FAILED", new Error("FAILED");
360
+ throw c.status = "FAILED", new Error("FAILED");
361
361
  }
362
- if (u.validate && !await u.validate())
363
- throw u.status = "FAILED", new Error("FAILED");
362
+ if (c.validate && !await c.validate())
363
+ throw c.status = "FAILED", new Error("FAILED");
364
364
  E && E > 0 && await new Promise((P) => setTimeout(P, E));
365
- const I = await u.execute(u.abortController);
366
- if (u.abortController.signal.aborted) {
367
- u.status = "COMPLETED", await this.onTaskStatusChange(u.id, "COMPLETED"), r({
365
+ const I = await c.execute(c.abortController);
366
+ if (c.abortController.signal.aborted) {
367
+ c.status = "COMPLETED", await this.onTaskStatusChange(c.id, "COMPLETED"), r({
368
368
  success: !0,
369
369
  result: void 0,
370
- taskId: u.id,
370
+ taskId: c.id,
371
371
  timestamp: Date.now(),
372
372
  instanceId: this.instanceId
373
373
  });
@@ -376,34 +376,34 @@ class Zt {
376
376
  if (t.control) {
377
377
  const P = t.control;
378
378
  if (P.delay && P.delay > 0 && await new Promise((M) => setTimeout(M, P.delay)), P.manual) {
379
- u.status = "MANUAL_PENDING", u.manualResolver = { resolve: r, reject: a, result: I }, this.pendingTaskQueue.push(u), await this.onTaskStatusChange(u.id, "MANUAL_PENDING");
379
+ c.status = "MANUAL_PENDING", c.manualResolver = { resolve: r, reject: a, result: I }, this.pendingTaskQueue.push(c), await this.onTaskStatusChange(c.id, "MANUAL_PENDING");
380
380
  return;
381
381
  }
382
382
  if (P.signal) {
383
- u.status = "SIGNAL_PENDING", u.manualResolver = { resolve: r, reject: a, result: I }, this.signalListeners.has(P.signal) || this.signalListeners.set(P.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(P.signal).add(u.id), this.pendingTaskQueue.push(u), await this.onTaskStatusChange(u.id, "SIGNAL_PENDING");
383
+ c.status = "SIGNAL_PENDING", c.manualResolver = { resolve: r, reject: a, result: I }, this.signalListeners.has(P.signal) || this.signalListeners.set(P.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(P.signal).add(c.id), this.pendingTaskQueue.push(c), await this.onTaskStatusChange(c.id, "SIGNAL_PENDING");
384
384
  return;
385
385
  }
386
386
  if (P.condition && !await P.condition()) {
387
- u.status = "MANUAL_PENDING", u.manualResolver = { resolve: r, reject: a, result: I }, this.pendingTaskQueue.push(u), await this.onTaskStatusChange(u.id, "MANUAL_PENDING");
387
+ c.status = "MANUAL_PENDING", c.manualResolver = { resolve: r, reject: a, result: I }, this.pendingTaskQueue.push(c), await this.onTaskStatusChange(c.id, "MANUAL_PENDING");
388
388
  return;
389
389
  }
390
390
  }
391
- u.status = "COMPLETED", await this.onTaskStatusChange(u.id, "COMPLETED"), r({
391
+ c.status = "COMPLETED", await this.onTaskStatusChange(c.id, "COMPLETED"), r({
392
392
  success: !0,
393
393
  result: I,
394
- taskId: u.id,
394
+ taskId: c.id,
395
395
  timestamp: Date.now(),
396
396
  instanceId: this.instanceId
397
397
  });
398
398
  } catch (I) {
399
- if (u.status = "FAILED", u.rollback)
399
+ if (c.status = "FAILED", c.rollback)
400
400
  try {
401
- await u.rollback(), u.status = "ROLLEDBACK";
401
+ await c.rollback(), c.status = "ROLLEDBACK";
402
402
  } catch {
403
403
  }
404
- throw await this.onTaskStatusChange(u.id, u.status), I;
404
+ throw await this.onTaskStatusChange(c.id, c.status), I;
405
405
  } finally {
406
- this.releaseLock(u.id);
406
+ this.releaseLock(c.id);
407
407
  }
408
408
  } catch (D) {
409
409
  a(D);
@@ -445,11 +445,11 @@ const F = new Zt(), It = (n) => {
445
445
  const t = /* @__PURE__ */ new Set(), s = (l, E) => {
446
446
  const g = typeof l == "function" ? l(e) : l;
447
447
  if (!Object.is(g, e)) {
448
- const u = e;
449
- e = E ?? (typeof g != "object" || g === null) ? g : Object.assign({}, e, g), t.forEach((L) => L(e, u));
448
+ const c = e;
449
+ e = E ?? (typeof g != "object" || g === null) ? g : Object.assign({}, e, g), t.forEach((L) => L(e, c));
450
450
  }
451
- }, r = () => e, c = { setState: s, getState: r, getInitialState: () => f, subscribe: (l) => (t.add(l), () => t.delete(l)) }, f = e = n(s, r, c);
452
- return c;
451
+ }, r = () => e, u = { setState: s, getState: r, getInitialState: () => h, subscribe: (l) => (t.add(l), () => t.delete(l)) }, h = e = n(s, r, u);
452
+ return u;
453
453
  }, te = ((n) => n ? It(n) : It), ee = (n) => n;
454
454
  function ne(n, e = ee) {
455
455
  const t = at.useSyncExternalStore(
@@ -487,7 +487,7 @@ function re() {
487
487
  const t = e.state?.id;
488
488
  (await F.addTask(
489
489
  async (s) => {
490
- const r = e.state?.index, a = e.state?.status, o = e.state?.params, c = e.state?.transitionName, f = e.state?.layoutId, l = U.getState().setStatus, { index: E, addHistory: g, popHistory: u } = q.getState(), L = r < E, D = a === "PUSHING" && r > E, I = a === "REPLACING" && r > E, P = window.location.pathname;
490
+ const r = e.state?.index, a = e.state?.status, o = e.state?.params, u = e.state?.transitionName, h = e.state?.layoutId, l = U.getState().setStatus, { index: E, addHistory: g, popHistory: c } = q.getState(), L = r < E, D = a === "PUSHING" && r > E, I = a === "REPLACING" && r > E, P = window.location.pathname;
491
491
  if (!L && !D && !I) {
492
492
  s.abort();
493
493
  return;
@@ -496,16 +496,16 @@ function re() {
496
496
  id: t,
497
497
  pathname: P,
498
498
  params: o,
499
- transitionName: c,
500
- layoutId: f
499
+ transitionName: u,
500
+ layoutId: h
501
501
  })) : I && (l("REPLACING"), g({
502
502
  id: t,
503
503
  pathname: P,
504
504
  params: o,
505
- transitionName: c,
506
- layoutId: f
505
+ transitionName: u,
506
+ layoutId: h
507
507
  })), async () => {
508
- L && u(r + 1), l("COMPLETED");
508
+ L && c(r + 1), l("COMPLETED");
509
509
  };
510
510
  },
511
511
  {
@@ -672,7 +672,7 @@ function ct({
672
672
  enterBack: r,
673
673
  exit: a,
674
674
  exitBack: o,
675
- options: c
675
+ options: u
676
676
  }) {
677
677
  return {
678
678
  name: n,
@@ -689,7 +689,7 @@ function ct({
689
689
  "COMPLETED-false": a,
690
690
  "COMPLETED-true": s
691
691
  },
692
- ...c
692
+ ...u
693
693
  };
694
694
  }
695
695
  const ue = ct({
@@ -746,11 +746,11 @@ const ue = ct({
746
746
  swipeDirection: "x",
747
747
  onSwipeStart: async () => !0,
748
748
  onSwipe: (n, e, { animate: t, currentScreen: s, prevScreen: r, onProgress: a }) => {
749
- const { offset: o } = e, c = o.x, f = bt(c, [0, window.innerWidth], [0, 100]);
750
- return a?.(!0, f), t(
749
+ const { offset: o } = e, u = o.x, h = bt(u, [0, window.innerWidth], [0, 100]);
750
+ return a?.(!0, h), t(
751
751
  s,
752
752
  {
753
- x: Math.max(0, c)
753
+ x: Math.max(0, u)
754
754
  },
755
755
  {
756
756
  duration: 0
@@ -758,15 +758,15 @@ const ue = ct({
758
758
  ), t(
759
759
  r,
760
760
  {
761
- x: -100 + f
761
+ x: -100 + h
762
762
  },
763
763
  {
764
764
  duration: 0
765
765
  }
766
- ), f;
766
+ ), h;
767
767
  },
768
768
  onSwipeEnd: async (n, e, { animate: t, currentScreen: s, prevScreen: r, onStart: a }) => {
769
- const { offset: o, velocity: c } = e, l = o.x > 50 || c.x > 20;
769
+ const { offset: o, velocity: u } = e, l = o.x > 50 || u.x > 20;
770
770
  return a?.(l), await Promise.all([
771
771
  t(
772
772
  s,
@@ -841,12 +841,12 @@ const ue = ct({
841
841
  swipeDirection: "y",
842
842
  onSwipeStart: async () => !0,
843
843
  onSwipe: (n, e, { animate: t, currentScreen: s, onProgress: r }) => {
844
- const { offset: a } = e, o = a.y, c = Math.max(0, Math.min(56, o)), f = bt(c, [0, 56], [1, 0.96]), l = Math.max(0, o - 56), E = Math.min(1, l / 160), g = Math.sqrt(E) * 12, u = Math.max(0, c + g), L = Math.min(56, u);
844
+ const { offset: a } = e, o = a.y, u = Math.max(0, Math.min(56, o)), h = bt(u, [0, 56], [1, 0.96]), l = Math.max(0, o - 56), E = Math.min(1, l / 160), g = Math.sqrt(E) * 12, c = Math.max(0, u + g), L = Math.min(56, c);
845
845
  return r?.(!0, 100), t(
846
846
  s,
847
847
  {
848
- y: u,
849
- opacity: f
848
+ y: c,
849
+ opacity: h
850
850
  },
851
851
  {
852
852
  duration: 0
@@ -854,7 +854,7 @@ const ue = ct({
854
854
  ), L;
855
855
  },
856
856
  onSwipeEnd: async (n, e, { animate: t, currentScreen: s, prevScreen: r, onStart: a }) => {
857
- const { offset: o, velocity: c } = e, l = o.y > 56 || c.y > 20;
857
+ const { offset: o, velocity: u } = e, l = o.y > 56 || u.y > 20;
858
858
  return a?.(l), await Promise.all([
859
859
  t(
860
860
  s,
@@ -932,11 +932,11 @@ const ue = ct({
932
932
  swipeDirection: "y",
933
933
  onSwipeStart: async () => !0,
934
934
  onSwipe: (n, e, { animate: t, currentScreen: s, prevScreen: r, onProgress: a }) => {
935
- const { offset: o } = e, c = o.y, f = Math.max(0, Math.min(56, c)), l = Math.max(0, c - 56), E = Math.min(1, l / 160), g = Math.sqrt(E) * 12, u = Math.max(0, f + g), L = Math.min(56, u);
935
+ const { offset: o } = e, u = o.y, h = Math.max(0, Math.min(56, u)), l = Math.max(0, u - 56), E = Math.min(1, l / 160), g = Math.sqrt(E) * 12, c = Math.max(0, h + g), L = Math.min(56, c);
936
936
  return a?.(!0, L), t(
937
937
  s,
938
938
  {
939
- y: u
939
+ y: c
940
940
  },
941
941
  {
942
942
  duration: 0
@@ -950,7 +950,7 @@ const ue = ct({
950
950
  ), L;
951
951
  },
952
952
  onSwipeEnd: async (n, e, { animate: t, currentScreen: s, prevScreen: r, onStart: a }) => {
953
- const { offset: o, velocity: c } = e, l = o.y > 56 || c.y > 20;
953
+ const { offset: o, velocity: u } = e, l = o.y > 56 || u.y > 20;
954
954
  return a?.(l), await Promise.all([
955
955
  t(
956
956
  s,
@@ -1039,7 +1039,7 @@ function Se({
1039
1039
  id: "root",
1040
1040
  pathname: a,
1041
1041
  params: Jt(
1042
- Mt.toArray(n).map((c) => c.props.path).flat(),
1042
+ Mt.toArray(n).map((u) => u.props.path).flat(),
1043
1043
  a,
1044
1044
  o
1045
1045
  ),
@@ -1048,9 +1048,7 @@ function Se({
1048
1048
  }
1049
1049
  ]
1050
1050
  }), Y(() => {
1051
- if (window.history.state?.index) return;
1052
- const { pathname: c, search: f } = window.location;
1053
- window.history.replaceState(
1051
+ window.history.state?.index || window.history.replaceState(
1054
1052
  {
1055
1053
  id: "root",
1056
1054
  index: 0,
@@ -1060,12 +1058,12 @@ function Se({
1060
1058
  layoutId: null
1061
1059
  },
1062
1060
  "",
1063
- `${c}${f}`
1061
+ window.location.href
1064
1062
  );
1065
1063
  }, [t]), Y(() => {
1066
- s.forEach((c) => et.set(c.name, c));
1064
+ s.forEach((u) => et.set(u.name, u));
1067
1065
  }, [s]), Y(() => {
1068
- r.forEach((c) => Pt.set(c.name, c));
1066
+ r.forEach((u) => Pt.set(u.name, u));
1069
1067
  }, [r]), /* @__PURE__ */ yt(
1070
1068
  "div",
1071
1069
  {
@@ -1089,13 +1087,13 @@ function Pe({ element: n }) {
1089
1087
  function ve() {
1090
1088
  return {
1091
1089
  push: async (s, r, a = {}) => {
1092
- const { status: o, setStatus: c } = U.getState();
1090
+ const { status: o, setStatus: u } = U.getState();
1093
1091
  if (o !== "COMPLETED" && o !== "IDLE")
1094
1092
  return;
1095
- const { index: f, addHistory: l } = q.getState(), E = mt.getState().defaultTransitionName, { transitionName: g = E, layoutId: u = null } = a, L = F.generateTaskId();
1093
+ const { index: h, addHistory: l } = q.getState(), E = mt.getState().defaultTransitionName, { transitionName: g = E, layoutId: c = null } = a, L = F.generateTaskId();
1096
1094
  (await F.addTask(
1097
1095
  async () => {
1098
- c("PUSHING");
1096
+ u("PUSHING");
1099
1097
  const D = K.compile(s), I = Object.fromEntries(
1100
1098
  Object.entries(r).map(([k, b]) => [k, String(b)])
1101
1099
  ), P = D(I), M = K.parse(s).tokens.filter((k) => k.type === "param").map((k) => k.name), W = Object.fromEntries(
@@ -1104,11 +1102,11 @@ function ve() {
1104
1102
  return window.history.pushState(
1105
1103
  {
1106
1104
  id: L,
1107
- index: f + 1,
1105
+ index: h + 1,
1108
1106
  status: "PUSHING",
1109
1107
  params: r,
1110
1108
  transitionName: g,
1111
- layoutId: u
1109
+ layoutId: c
1112
1110
  },
1113
1111
  "",
1114
1112
  Q
@@ -1117,9 +1115,9 @@ function ve() {
1117
1115
  pathname: P,
1118
1116
  params: r,
1119
1117
  transitionName: g,
1120
- layoutId: u
1118
+ layoutId: c
1121
1119
  }), () => {
1122
- c("COMPLETED");
1120
+ u("COMPLETED");
1123
1121
  };
1124
1122
  },
1125
1123
  {
@@ -1131,13 +1129,13 @@ function ve() {
1131
1129
  )).result?.();
1132
1130
  },
1133
1131
  replace: async (s, r, a = {}) => {
1134
- const { status: o, setStatus: c } = U.getState();
1132
+ const { status: o, setStatus: u } = U.getState();
1135
1133
  if (o !== "COMPLETED" && o !== "IDLE")
1136
1134
  return;
1137
- const { index: f, addHistory: l } = q.getState(), E = q.getState().replaceHistory, g = mt.getState().defaultTransitionName, { transitionName: u = g, layoutId: L = null } = a, D = F.generateTaskId();
1135
+ const { index: h, addHistory: l } = q.getState(), E = q.getState().replaceHistory, g = mt.getState().defaultTransitionName, { transitionName: c = g, layoutId: L = null } = a, D = F.generateTaskId();
1138
1136
  (await F.addTask(
1139
1137
  async () => {
1140
- c("REPLACING");
1138
+ u("REPLACING");
1141
1139
  const I = K.compile(s), P = Object.fromEntries(
1142
1140
  Object.entries(r).map(([b, i]) => [b, String(i)])
1143
1141
  ), M = I(P), W = K.parse(s).tokens.filter((b) => b.type === "param").map((b) => b.name), _ = Object.fromEntries(
@@ -1146,10 +1144,10 @@ function ve() {
1146
1144
  return window.history.replaceState(
1147
1145
  {
1148
1146
  id: D,
1149
- index: f,
1147
+ index: h,
1150
1148
  status: "REPLACING",
1151
1149
  params: r,
1152
- transitionName: u,
1150
+ transitionName: c,
1153
1151
  layoutId: L
1154
1152
  },
1155
1153
  "",
@@ -1158,10 +1156,10 @@ function ve() {
1158
1156
  id: D,
1159
1157
  pathname: M,
1160
1158
  params: r,
1161
- transitionName: u,
1159
+ transitionName: c,
1162
1160
  layoutId: L
1163
1161
  }), async () => {
1164
- E(f), c("COMPLETED");
1162
+ E(h), u("COMPLETED");
1165
1163
  };
1166
1164
  },
1167
1165
  {
@@ -1184,7 +1182,7 @@ function Te() {
1184
1182
  pushStep: async (r) => {
1185
1183
  const a = U.getState().status;
1186
1184
  a !== "COMPLETED" && a !== "IDLE" || (await F.addTask(async () => {
1187
- const o = new URLSearchParams(r).toString(), c = `${window.location.pathname}${o ? `?${o}` : ""}`;
1185
+ const o = new URLSearchParams(r).toString(), u = `${window.location.pathname}${o ? `?${o}` : ""}`;
1188
1186
  return window.history.state?.step || window.history.replaceState(
1189
1187
  {
1190
1188
  ...window.history.state,
@@ -1199,14 +1197,14 @@ function Te() {
1199
1197
  params: r
1200
1198
  },
1201
1199
  "",
1202
- c
1200
+ u
1203
1201
  ), async () => n({ type: "SET", params: r });
1204
1202
  })).result?.();
1205
1203
  },
1206
1204
  replaceStep: async (r) => {
1207
1205
  const a = U.getState().status;
1208
1206
  a !== "COMPLETED" && a !== "IDLE" || (await F.addTask(async () => {
1209
- const o = new URLSearchParams(r).toString(), c = `${window.location.pathname}${o ? `?${o}` : ""}`;
1207
+ const o = new URLSearchParams(r).toString(), u = `${window.location.pathname}${o ? `?${o}` : ""}`;
1210
1208
  return window.history.replaceState(
1211
1209
  {
1212
1210
  ...window.history.state,
@@ -1214,7 +1212,7 @@ function Te() {
1214
1212
  params: r
1215
1213
  },
1216
1214
  "",
1217
- c
1215
+ u
1218
1216
  ), async () => n({ type: "SET", params: r });
1219
1217
  })).result?.();
1220
1218
  },
@@ -1235,8 +1233,8 @@ function De({
1235
1233
  pushOnExit: r,
1236
1234
  replaceOnEnter: a,
1237
1235
  replaceOnExit: o,
1238
- popOnEnter: c,
1239
- popOnExit: f,
1236
+ popOnEnter: u,
1237
+ popOnExit: h,
1240
1238
  completedOnExit: l,
1241
1239
  completedOnEnter: E,
1242
1240
  options: g
@@ -1251,8 +1249,8 @@ function De({
1251
1249
  "PUSHING-true": s,
1252
1250
  "REPLACING-false": o,
1253
1251
  "REPLACING-true": a,
1254
- "POPPING-false": f,
1255
- "POPPING-true": c,
1252
+ "POPPING-false": h,
1253
+ "POPPING-true": u,
1256
1254
  "COMPLETED-false": l,
1257
1255
  "COMPLETED-true": E
1258
1256
  },
@@ -1267,8 +1265,8 @@ function Ie({
1267
1265
  pushOnExit: r,
1268
1266
  replaceOnEnter: a,
1269
1267
  replaceOnExit: o,
1270
- popOnEnter: c,
1271
- popOnExit: f,
1268
+ popOnEnter: u,
1269
+ popOnExit: h,
1272
1270
  completedOnEnter: l,
1273
1271
  completedOnExit: E,
1274
1272
  options: g
@@ -1283,8 +1281,8 @@ function Ie({
1283
1281
  "PUSHING-true": s,
1284
1282
  "REPLACING-false": o,
1285
1283
  "REPLACING-true": a,
1286
- "POPPING-false": f,
1287
- "POPPING-true": c,
1284
+ "POPPING-false": h,
1285
+ "POPPING-true": u,
1288
1286
  "COMPLETED-false": E,
1289
1287
  "COMPLETED-true": l
1290
1288
  },
@@ -1299,14 +1297,14 @@ function Nt(n, e) {
1299
1297
  verifyByScroll: a = !1
1300
1298
  } = e ?? {}, o = he(n);
1301
1299
  if (!o) return { element: null, hasMarker: !1 };
1302
- const c = o.closest?.(s);
1303
- if (c instanceof HTMLElement && wt(c, t) && (!a || kt(c, t)))
1304
- return { element: c, hasMarker: !0 };
1305
- let f = o, l = 0;
1306
- for (; f && f !== document.body && l < r; ) {
1307
- if (wt(f, t) && (!a || kt(f, t)))
1308
- return { element: f, hasMarker: !1 };
1309
- f = f.parentElement, l++;
1300
+ const u = o.closest?.(s);
1301
+ if (u instanceof HTMLElement && wt(u, t) && (!a || kt(u, t)))
1302
+ return { element: u, hasMarker: !0 };
1303
+ let h = o, l = 0;
1304
+ for (; h && h !== document.body && l < r; ) {
1305
+ if (wt(h, t) && (!a || kt(h, t)))
1306
+ return { element: h, hasMarker: !1 };
1307
+ h = h.parentElement, l++;
1310
1308
  }
1311
1309
  return { element: null, hasMarker: !1 };
1312
1310
  }
@@ -1343,12 +1341,12 @@ function kt(n, e) {
1343
1341
  function ge({ children: n, ref: e, ...t }) {
1344
1342
  const { isActive: s, transitionName: r } = Z(), [a, o] = Rt();
1345
1343
  Bt(e, () => a.current);
1346
- const c = U((u) => u.status), f = et.get(r), { decoratorName: l } = f, { initial: E, variants: g } = Pt.get(l);
1344
+ const u = U((c) => c.status), h = et.get(r), { decoratorName: l } = h, { initial: E, variants: g } = Pt.get(l);
1347
1345
  return Y(() => {
1348
1346
  if (!a.current) return;
1349
- const { value: u, options: L } = g[`${c}-${s}`];
1350
- o(a.current, u, L);
1351
- }, [c, s, o, g, a]), /* @__PURE__ */ x(
1347
+ const { value: c, options: L } = g[`${u}-${s}`];
1348
+ o(a.current, c, L);
1349
+ }, [u, s, o, g, a]), /* @__PURE__ */ x(
1352
1350
  At.div,
1353
1351
  {
1354
1352
  ref: a,
@@ -1395,15 +1393,15 @@ function Ht({
1395
1393
  systemNavigationBarColor: r,
1396
1394
  sharedAppBar: a,
1397
1395
  sharedNavigationBar: o,
1398
- appBar: c,
1399
- navigationBar: f,
1396
+ appBar: u,
1397
+ navigationBar: h,
1400
1398
  hideStatusBar: l,
1401
1399
  hideSystemNavigationBar: E,
1402
1400
  backgroundColor: g = "white",
1403
- contentScrollable: u = !0,
1401
+ contentScrollable: c = !0,
1404
1402
  ...L
1405
1403
  }) {
1406
- const [D, I] = Rt(), { id: P, isActive: M, isRoot: W, transitionName: _, prevTransitionName: Q } = Z(), k = Xt(), b = U((v) => v.status), i = J((v) => v.dragStatus), d = J.getState().setDragStatus, y = J.getState().setReplaceTransitionStatus, m = et.get(_), { variants: h, initial: p, swipeDirection: S, decoratorName: T } = m, C = Pt.get(T), { viewportScrollHeight: w } = ye(), R = w > 0, [N, O] = ot(0), [j, ut] = ot(0), vt = $(null), nt = $(null), rt = $(null), st = $(null), B = $(!1), tt = $(!1), X = $({
1404
+ const [D, I] = Rt(), { id: P, isActive: M, isRoot: W, transitionName: _, prevTransitionName: Q } = Z(), k = Xt(), b = U((v) => v.status), i = J((v) => v.dragStatus), d = J.getState().setDragStatus, y = J.getState().setReplaceTransitionStatus, m = et.get(_), { variants: f, initial: p, swipeDirection: S, decoratorName: T } = m, C = Pt.get(T), { viewportScrollHeight: w } = ye(), R = w > 0, [N, O] = ot(0), [j, ut] = ot(0), vt = $(null), nt = $(null), rt = $(null), st = $(null), B = $(!1), tt = $(!1), X = $({
1407
1405
  element: null,
1408
1406
  hasMarker: !1
1409
1407
  }), z = $({ element: null, hasMarker: !1 }), lt = $(0), dt = $(0), pt = $(null), ft = $(null), Ut = async (v, G) => {
@@ -1486,7 +1484,7 @@ function Ht({
1486
1484
  };
1487
1485
  }, [D]), Y(() => {
1488
1486
  D.current && (async () => {
1489
- const { value: v, options: G } = h[`${b}-${M}`];
1487
+ const { value: v, options: G } = f[`${b}-${M}`];
1490
1488
  !M && b === "REPLACING" && Q !== _ && (y("PENDING"), await I(D.current, fe, {
1491
1489
  duration: 0.1
1492
1490
  })), M && b === "COMPLETED" && (d("IDLE"), y("IDLE")), await I(D.current, v, G), await F.resolveTask(P);
@@ -1499,7 +1497,7 @@ function Ht({
1499
1497
  _,
1500
1498
  I,
1501
1499
  D,
1502
- h,
1500
+ f,
1503
1501
  d,
1504
1502
  y
1505
1503
  ]), Tt(() => {
@@ -1576,7 +1574,7 @@ function Ht({
1576
1574
  flexDirection: "column",
1577
1575
  height: "100%",
1578
1576
  backgroundColor: g,
1579
- overflowY: u ? void 0 : "auto",
1577
+ overflowY: c ? void 0 : "auto",
1580
1578
  ...L.style
1581
1579
  },
1582
1580
  children: [
@@ -1601,7 +1599,7 @@ function Ht({
1601
1599
  }
1602
1600
  }
1603
1601
  ),
1604
- c,
1602
+ u,
1605
1603
  /* @__PURE__ */ x(
1606
1604
  "div",
1607
1605
  {
@@ -1609,12 +1607,12 @@ function Ht({
1609
1607
  display: "flex",
1610
1608
  flexDirection: "column",
1611
1609
  flexGrow: 1,
1612
- overflowY: u ? "auto" : void 0
1610
+ overflowY: c ? "auto" : void 0
1613
1611
  },
1614
1612
  children: n
1615
1613
  }
1616
1614
  ),
1617
- f,
1615
+ h,
1618
1616
  o && /* @__PURE__ */ x(
1619
1617
  "div",
1620
1618
  {
@@ -1682,11 +1680,11 @@ function Ht({
1682
1680
  );
1683
1681
  }
1684
1682
  function xe({ children: n, ...e }) {
1685
- const { isActive: t, isPrev: s, zIndex: r } = Z(), a = q((g) => g.index), o = U((g) => g.status), c = J((g) => g.dragStatus), f = J((g) => g.replaceTransitionStatus), E = !t && (o === "COMPLETED" && c === "IDLE") || s && a - 2 <= r && f === "IDLE" || s && a - 2 > r;
1683
+ const { isActive: t, isPrev: s, zIndex: r } = Z(), a = q((g) => g.index), o = U((g) => g.status), u = J((g) => g.dragStatus), h = J((g) => g.replaceTransitionStatus), E = !t && (o === "COMPLETED" && u === "IDLE") || s && a - 2 <= r && h === "IDLE" || s && a - 2 > r;
1686
1684
  return /* @__PURE__ */ x(Ht, { ...e, children: /* @__PURE__ */ x(Ct, { mode: E ? "hidden" : "visible", children: n }) });
1687
1685
  }
1688
1686
  function Ne({ children: n, ...e }) {
1689
- const { isActive: t, isPrev: s, zIndex: r } = Z(), a = q((g) => g.index), o = U((g) => g.status), c = J((g) => g.dragStatus), f = J((g) => g.replaceTransitionStatus), E = !t && (o === "COMPLETED" && c === "IDLE") || s && a - 2 <= r && f === "IDLE" || s && a - 2 > r;
1687
+ const { isActive: t, isPrev: s, zIndex: r } = Z(), a = q((g) => g.index), o = U((g) => g.status), u = J((g) => g.dragStatus), h = J((g) => g.replaceTransitionStatus), E = !t && (o === "COMPLETED" && u === "IDLE") || s && a - 2 <= r && h === "IDLE" || s && a - 2 > r;
1690
1688
  return /* @__PURE__ */ x(
1691
1689
  Ht,
1692
1690
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flemo",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "A modern React router library with built-in motion animations and smooth transitions",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",