flemo 1.5.0 → 1.5.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.
Files changed (2) hide show
  1. package/dist/index.mjs +154 -152
  2. package/package.json +8 -10
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 u {
27
+ class c {
28
28
  constructor(d, y) {
29
29
  this.tokens = d, this.originalPath = y;
30
30
  }
31
31
  }
32
- H.TokenData = u;
33
- class h extends TypeError {
32
+ H.TokenData = c;
33
+ class f 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 = h;
39
+ H.PathError = f;
40
40
  function l(i, d = {}) {
41
- const { encodePath: y = e } = d, m = [...i], f = [];
41
+ const { encodePath: y = e } = d, m = [...i], h = [];
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 h(`Unterminated quote at index ${R}`, i);
59
+ throw new f(`Unterminated quote at index ${R}`, i);
60
60
  }
61
61
  if (!w)
62
- throw new h(`Missing parameter name at index ${p}`, i);
62
+ throw new f(`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 ? 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 });
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 });
68
68
  }
69
- f.push({ type: "end", index: p, value: "" });
69
+ h.push({ type: "end", index: p, value: "" });
70
70
  function C(w) {
71
71
  const R = [];
72
72
  for (; ; ) {
73
- const N = f[S++];
73
+ const N = h[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 = f[S];
77
+ let O = N.value, j = h[S];
78
78
  for (; j.type === "char" || j.type === "escape"; )
79
- O += j.value, j = f[++S];
79
+ O += j.value, j = h[++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 h(`Unexpected ${N.type} at index ${N.index}, expected ${w}`, i);
100
+ throw new f(`Unexpected ${N.type} at index ${N.index}, expected ${w}`, i);
101
101
  }
102
102
  return R;
103
103
  }
104
- return new u(C("end"), i);
104
+ return new c(C("end"), i);
105
105
  }
106
106
  function E(i, d = {}) {
107
- const { encode: y = encodeURIComponent, delimiter: m = n } = d, f = typeof i == "object" ? i : l(i, d), p = g(f.tokens, m, y);
107
+ const { encode: y = encodeURIComponent, delimiter: m = n } = d, h = typeof i == "object" ? i : l(i, d), p = g(h.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((f) => c(f, d, y));
117
- return (f) => {
116
+ const m = i.map((h) => u(h, d, y));
117
+ return (h) => {
118
118
  const p = [""];
119
119
  for (const S of m) {
120
- const [T, ...C] = S(f);
120
+ const [T, ...C] = S(h);
121
121
  p[0] += T, p.push(...C);
122
122
  }
123
123
  return p;
124
124
  };
125
125
  }
126
- function c(i, d, y) {
126
+ function u(i, d, y) {
127
127
  if (i.type === "text")
128
128
  return () => [i.value];
129
129
  if (i.type === "group") {
130
- const f = g(i.tokens, d, y);
130
+ const h = g(i.tokens, d, y);
131
131
  return (p) => {
132
- const [S, ...T] = f(p);
132
+ const [S, ...T] = h(p);
133
133
  return T.length ? [""] : [S];
134
134
  };
135
135
  }
136
136
  const m = y || e;
137
- return i.type === "wildcard" && y !== !1 ? (f) => {
138
- const p = f[i.name];
137
+ return i.type === "wildcard" && y !== !1 ? (h) => {
138
+ const p = h[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
- } : (f) => {
151
- const p = f[i.name];
150
+ } : (h) => {
151
+ const p = h[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: f, 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: h, 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 = f.exec(C);
162
+ const w = h.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: f = !1, trailing: p = !0 } = d, S = [], T = f ? "" : "i", C = [];
176
+ const { delimiter: y = n, end: m = !0, sensitive: h = !1, trailing: p = !0 } = d, S = [], T = h ? "" : "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 f of P(m.tokens, 0, y.slice()))
199
- yield* P(i, d + 1, f);
198
+ for (const h of P(m.tokens, 0, y.slice()))
199
+ yield* P(i, d + 1, h);
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 f = "", p = "", S = !0;
205
+ let h = "", p = "", S = !0;
206
206
  for (const T of i) {
207
207
  if (T.type === "text") {
208
- f += o(T.value), p += T.value, S || (S = T.value.includes(d));
208
+ h += 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 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;
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;
215
215
  continue;
216
216
  }
217
217
  }
218
- return f;
218
+ return h;
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(f) {
226
- return k(f) && b(i[y]) ? f : JSON.stringify(f);
225
+ function m(h) {
226
+ return k(h) && b(i[y]) ? h : JSON.stringify(h);
227
227
  }
228
228
  for (; y < i.length; ) {
229
- const f = i[y++];
230
- if (f.type === "text") {
231
- d += a(f.value);
229
+ const h = i[y++];
230
+ if (h.type === "text") {
231
+ d += a(h.value);
232
232
  continue;
233
233
  }
234
- if (f.type === "group") {
235
- d += `{${_(f.tokens)}}`;
234
+ if (h.type === "group") {
235
+ d += `{${_(h.tokens)}}`;
236
236
  continue;
237
237
  }
238
- if (f.type === "param") {
239
- d += `:${m(f.name)}`;
238
+ if (h.type === "param") {
239
+ d += `:${m(h.name)}`;
240
240
  continue;
241
241
  }
242
- if (f.type === "wildcard") {
243
- d += `*${m(f.name)}`;
242
+ if (h.type === "wildcard") {
243
+ d += `*${m(h.name)}`;
244
244
  continue;
245
245
  }
246
- throw new TypeError(`Unknown token type: ${f.type}`);
246
+ throw new TypeError(`Unknown token type: ${h.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((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());
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());
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: u, rollback: h, dependencies: l = [], delay: E } = t, g = new AbortController(), c = {
338
+ const { control: o, validate: c, rollback: f, dependencies: l = [], delay: E } = t, g = new AbortController(), u = {
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: u,
347
- rollback: h,
346
+ validate: c,
347
+ rollback: f,
348
348
  control: o,
349
349
  abortController: g
350
350
  };
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));
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));
352
352
  try {
353
- if (!await this.acquireLock(c.id))
354
- throw c.status = "FAILED", new Error("FAILED");
353
+ if (!await this.acquireLock(u.id))
354
+ throw u.status = "FAILED", new Error("FAILED");
355
355
  try {
356
- c.status = "PROCESSING";
357
- for (const P of c.dependencies) {
356
+ u.status = "PROCESSING";
357
+ for (const P of u.dependencies) {
358
358
  const M = this.tasks.get(P);
359
359
  if (!M || M.status !== "COMPLETED")
360
- throw c.status = "FAILED", new Error("FAILED");
360
+ throw u.status = "FAILED", new Error("FAILED");
361
361
  }
362
- if (c.validate && !await c.validate())
363
- throw c.status = "FAILED", new Error("FAILED");
362
+ if (u.validate && !await u.validate())
363
+ throw u.status = "FAILED", new Error("FAILED");
364
364
  E && E > 0 && await new Promise((P) => setTimeout(P, E));
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({
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({
368
368
  success: !0,
369
369
  result: void 0,
370
- taskId: c.id,
370
+ taskId: u.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
- c.status = "MANUAL_PENDING", c.manualResolver = { resolve: r, reject: a, result: I }, this.pendingTaskQueue.push(c), await this.onTaskStatusChange(c.id, "MANUAL_PENDING");
379
+ u.status = "MANUAL_PENDING", u.manualResolver = { resolve: r, reject: a, result: I }, this.pendingTaskQueue.push(u), await this.onTaskStatusChange(u.id, "MANUAL_PENDING");
380
380
  return;
381
381
  }
382
382
  if (P.signal) {
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");
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");
384
384
  return;
385
385
  }
386
386
  if (P.condition && !await P.condition()) {
387
- c.status = "MANUAL_PENDING", c.manualResolver = { resolve: r, reject: a, result: I }, this.pendingTaskQueue.push(c), await this.onTaskStatusChange(c.id, "MANUAL_PENDING");
387
+ u.status = "MANUAL_PENDING", u.manualResolver = { resolve: r, reject: a, result: I }, this.pendingTaskQueue.push(u), await this.onTaskStatusChange(u.id, "MANUAL_PENDING");
388
388
  return;
389
389
  }
390
390
  }
391
- c.status = "COMPLETED", await this.onTaskStatusChange(c.id, "COMPLETED"), r({
391
+ u.status = "COMPLETED", await this.onTaskStatusChange(u.id, "COMPLETED"), r({
392
392
  success: !0,
393
393
  result: I,
394
- taskId: c.id,
394
+ taskId: u.id,
395
395
  timestamp: Date.now(),
396
396
  instanceId: this.instanceId
397
397
  });
398
398
  } catch (I) {
399
- if (c.status = "FAILED", c.rollback)
399
+ if (u.status = "FAILED", u.rollback)
400
400
  try {
401
- await c.rollback(), c.status = "ROLLEDBACK";
401
+ await u.rollback(), u.status = "ROLLEDBACK";
402
402
  } catch {
403
403
  }
404
- throw await this.onTaskStatusChange(c.id, c.status), I;
404
+ throw await this.onTaskStatusChange(u.id, u.status), I;
405
405
  } finally {
406
- this.releaseLock(c.id);
406
+ this.releaseLock(u.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 c = e;
449
- e = E ?? (typeof g != "object" || g === null) ? g : Object.assign({}, e, g), t.forEach((L) => L(e, c));
448
+ const u = e;
449
+ e = E ?? (typeof g != "object" || g === null) ? g : Object.assign({}, e, g), t.forEach((L) => L(e, u));
450
450
  }
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;
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;
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, 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;
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;
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: u,
500
- layoutId: h
499
+ transitionName: c,
500
+ layoutId: f
501
501
  })) : I && (l("REPLACING"), g({
502
502
  id: t,
503
503
  pathname: P,
504
504
  params: o,
505
- transitionName: u,
506
- layoutId: h
505
+ transitionName: c,
506
+ layoutId: f
507
507
  })), async () => {
508
- L && c(r + 1), l("COMPLETED");
508
+ L && u(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: u
675
+ options: c
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
- ...u
692
+ ...c
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, u = o.x, h = bt(u, [0, window.innerWidth], [0, 100]);
750
- return a?.(!0, h), t(
749
+ const { offset: o } = e, c = o.x, f = bt(c, [0, window.innerWidth], [0, 100]);
750
+ return a?.(!0, f), t(
751
751
  s,
752
752
  {
753
- x: Math.max(0, u)
753
+ x: Math.max(0, c)
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 + h
761
+ x: -100 + f
762
762
  },
763
763
  {
764
764
  duration: 0
765
765
  }
766
- ), h;
766
+ ), f;
767
767
  },
768
768
  onSwipeEnd: async (n, e, { animate: t, currentScreen: s, prevScreen: r, onStart: a }) => {
769
- const { offset: o, velocity: u } = e, l = o.x > 50 || u.x > 20;
769
+ const { offset: o, velocity: c } = e, l = o.x > 50 || c.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, 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);
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);
845
845
  return r?.(!0, 100), t(
846
846
  s,
847
847
  {
848
- y: c,
849
- opacity: h
848
+ y: u,
849
+ opacity: f
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: u } = e, l = o.y > 56 || u.y > 20;
857
+ const { offset: o, velocity: c } = e, l = o.y > 56 || c.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, 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);
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);
936
936
  return a?.(!0, L), t(
937
937
  s,
938
938
  {
939
- y: c
939
+ y: u
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: u } = e, l = o.y > 56 || u.y > 20;
953
+ const { offset: o, velocity: c } = e, l = o.y > 56 || c.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((u) => u.props.path).flat(),
1042
+ Mt.toArray(n).map((c) => c.props.path).flat(),
1043
1043
  a,
1044
1044
  o
1045
1045
  ),
@@ -1048,7 +1048,9 @@ function Se({
1048
1048
  }
1049
1049
  ]
1050
1050
  }), Y(() => {
1051
- window.history.state?.index || window.history.replaceState(
1051
+ if (window.history.state?.index) return;
1052
+ const { pathname: c, search: f } = window.location;
1053
+ window.history.replaceState(
1052
1054
  {
1053
1055
  id: "root",
1054
1056
  index: 0,
@@ -1058,12 +1060,12 @@ function Se({
1058
1060
  layoutId: null
1059
1061
  },
1060
1062
  "",
1061
- window.location.pathname
1063
+ `${c}${f}`
1062
1064
  );
1063
1065
  }, [t]), Y(() => {
1064
- s.forEach((u) => et.set(u.name, u));
1066
+ s.forEach((c) => et.set(c.name, c));
1065
1067
  }, [s]), Y(() => {
1066
- r.forEach((u) => Pt.set(u.name, u));
1068
+ r.forEach((c) => Pt.set(c.name, c));
1067
1069
  }, [r]), /* @__PURE__ */ yt(
1068
1070
  "div",
1069
1071
  {
@@ -1087,13 +1089,13 @@ function Pe({ element: n }) {
1087
1089
  function ve() {
1088
1090
  return {
1089
1091
  push: async (s, r, a = {}) => {
1090
- const { status: o, setStatus: u } = U.getState();
1092
+ const { status: o, setStatus: c } = U.getState();
1091
1093
  if (o !== "COMPLETED" && o !== "IDLE")
1092
1094
  return;
1093
- const { index: h, addHistory: l } = q.getState(), E = mt.getState().defaultTransitionName, { transitionName: g = E, layoutId: c = null } = a, L = F.generateTaskId();
1095
+ const { index: f, addHistory: l } = q.getState(), E = mt.getState().defaultTransitionName, { transitionName: g = E, layoutId: u = null } = a, L = F.generateTaskId();
1094
1096
  (await F.addTask(
1095
1097
  async () => {
1096
- u("PUSHING");
1098
+ c("PUSHING");
1097
1099
  const D = K.compile(s), I = Object.fromEntries(
1098
1100
  Object.entries(r).map(([k, b]) => [k, String(b)])
1099
1101
  ), P = D(I), M = K.parse(s).tokens.filter((k) => k.type === "param").map((k) => k.name), W = Object.fromEntries(
@@ -1102,11 +1104,11 @@ function ve() {
1102
1104
  return window.history.pushState(
1103
1105
  {
1104
1106
  id: L,
1105
- index: h + 1,
1107
+ index: f + 1,
1106
1108
  status: "PUSHING",
1107
1109
  params: r,
1108
1110
  transitionName: g,
1109
- layoutId: c
1111
+ layoutId: u
1110
1112
  },
1111
1113
  "",
1112
1114
  Q
@@ -1115,9 +1117,9 @@ function ve() {
1115
1117
  pathname: P,
1116
1118
  params: r,
1117
1119
  transitionName: g,
1118
- layoutId: c
1120
+ layoutId: u
1119
1121
  }), () => {
1120
- u("COMPLETED");
1122
+ c("COMPLETED");
1121
1123
  };
1122
1124
  },
1123
1125
  {
@@ -1129,13 +1131,13 @@ function ve() {
1129
1131
  )).result?.();
1130
1132
  },
1131
1133
  replace: async (s, r, a = {}) => {
1132
- const { status: o, setStatus: u } = U.getState();
1134
+ const { status: o, setStatus: c } = U.getState();
1133
1135
  if (o !== "COMPLETED" && o !== "IDLE")
1134
1136
  return;
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();
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();
1136
1138
  (await F.addTask(
1137
1139
  async () => {
1138
- u("REPLACING");
1140
+ c("REPLACING");
1139
1141
  const I = K.compile(s), P = Object.fromEntries(
1140
1142
  Object.entries(r).map(([b, i]) => [b, String(i)])
1141
1143
  ), M = I(P), W = K.parse(s).tokens.filter((b) => b.type === "param").map((b) => b.name), _ = Object.fromEntries(
@@ -1144,10 +1146,10 @@ function ve() {
1144
1146
  return window.history.replaceState(
1145
1147
  {
1146
1148
  id: D,
1147
- index: h,
1149
+ index: f,
1148
1150
  status: "REPLACING",
1149
1151
  params: r,
1150
- transitionName: c,
1152
+ transitionName: u,
1151
1153
  layoutId: L
1152
1154
  },
1153
1155
  "",
@@ -1156,10 +1158,10 @@ function ve() {
1156
1158
  id: D,
1157
1159
  pathname: M,
1158
1160
  params: r,
1159
- transitionName: c,
1161
+ transitionName: u,
1160
1162
  layoutId: L
1161
1163
  }), async () => {
1162
- E(h), u("COMPLETED");
1164
+ E(f), c("COMPLETED");
1163
1165
  };
1164
1166
  },
1165
1167
  {
@@ -1182,7 +1184,7 @@ function Te() {
1182
1184
  pushStep: async (r) => {
1183
1185
  const a = U.getState().status;
1184
1186
  a !== "COMPLETED" && a !== "IDLE" || (await F.addTask(async () => {
1185
- const o = new URLSearchParams(r).toString(), u = `${window.location.pathname}${o ? `?${o}` : ""}`;
1187
+ const o = new URLSearchParams(r).toString(), c = `${window.location.pathname}${o ? `?${o}` : ""}`;
1186
1188
  return window.history.state?.step || window.history.replaceState(
1187
1189
  {
1188
1190
  ...window.history.state,
@@ -1197,14 +1199,14 @@ function Te() {
1197
1199
  params: r
1198
1200
  },
1199
1201
  "",
1200
- u
1202
+ c
1201
1203
  ), async () => n({ type: "SET", params: r });
1202
1204
  })).result?.();
1203
1205
  },
1204
1206
  replaceStep: async (r) => {
1205
1207
  const a = U.getState().status;
1206
1208
  a !== "COMPLETED" && a !== "IDLE" || (await F.addTask(async () => {
1207
- const o = new URLSearchParams(r).toString(), u = `${window.location.pathname}${o ? `?${o}` : ""}`;
1209
+ const o = new URLSearchParams(r).toString(), c = `${window.location.pathname}${o ? `?${o}` : ""}`;
1208
1210
  return window.history.replaceState(
1209
1211
  {
1210
1212
  ...window.history.state,
@@ -1212,7 +1214,7 @@ function Te() {
1212
1214
  params: r
1213
1215
  },
1214
1216
  "",
1215
- u
1217
+ c
1216
1218
  ), async () => n({ type: "SET", params: r });
1217
1219
  })).result?.();
1218
1220
  },
@@ -1233,8 +1235,8 @@ function De({
1233
1235
  pushOnExit: r,
1234
1236
  replaceOnEnter: a,
1235
1237
  replaceOnExit: o,
1236
- popOnEnter: u,
1237
- popOnExit: h,
1238
+ popOnEnter: c,
1239
+ popOnExit: f,
1238
1240
  completedOnExit: l,
1239
1241
  completedOnEnter: E,
1240
1242
  options: g
@@ -1249,8 +1251,8 @@ function De({
1249
1251
  "PUSHING-true": s,
1250
1252
  "REPLACING-false": o,
1251
1253
  "REPLACING-true": a,
1252
- "POPPING-false": h,
1253
- "POPPING-true": u,
1254
+ "POPPING-false": f,
1255
+ "POPPING-true": c,
1254
1256
  "COMPLETED-false": l,
1255
1257
  "COMPLETED-true": E
1256
1258
  },
@@ -1265,8 +1267,8 @@ function Ie({
1265
1267
  pushOnExit: r,
1266
1268
  replaceOnEnter: a,
1267
1269
  replaceOnExit: o,
1268
- popOnEnter: u,
1269
- popOnExit: h,
1270
+ popOnEnter: c,
1271
+ popOnExit: f,
1270
1272
  completedOnEnter: l,
1271
1273
  completedOnExit: E,
1272
1274
  options: g
@@ -1281,8 +1283,8 @@ function Ie({
1281
1283
  "PUSHING-true": s,
1282
1284
  "REPLACING-false": o,
1283
1285
  "REPLACING-true": a,
1284
- "POPPING-false": h,
1285
- "POPPING-true": u,
1286
+ "POPPING-false": f,
1287
+ "POPPING-true": c,
1286
1288
  "COMPLETED-false": E,
1287
1289
  "COMPLETED-true": l
1288
1290
  },
@@ -1297,14 +1299,14 @@ function Nt(n, e) {
1297
1299
  verifyByScroll: a = !1
1298
1300
  } = e ?? {}, o = he(n);
1299
1301
  if (!o) return { element: null, hasMarker: !1 };
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++;
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++;
1308
1310
  }
1309
1311
  return { element: null, hasMarker: !1 };
1310
1312
  }
@@ -1341,12 +1343,12 @@ function kt(n, e) {
1341
1343
  function ge({ children: n, ref: e, ...t }) {
1342
1344
  const { isActive: s, transitionName: r } = Z(), [a, o] = Rt();
1343
1345
  Bt(e, () => a.current);
1344
- const u = U((c) => c.status), h = et.get(r), { decoratorName: l } = h, { initial: E, variants: g } = Pt.get(l);
1346
+ const c = U((u) => u.status), f = et.get(r), { decoratorName: l } = f, { initial: E, variants: g } = Pt.get(l);
1345
1347
  return Y(() => {
1346
1348
  if (!a.current) return;
1347
- const { value: c, options: L } = g[`${u}-${s}`];
1348
- o(a.current, c, L);
1349
- }, [u, s, o, g, a]), /* @__PURE__ */ x(
1349
+ const { value: u, options: L } = g[`${c}-${s}`];
1350
+ o(a.current, u, L);
1351
+ }, [c, s, o, g, a]), /* @__PURE__ */ x(
1350
1352
  At.div,
1351
1353
  {
1352
1354
  ref: a,
@@ -1393,15 +1395,15 @@ function Ht({
1393
1395
  systemNavigationBarColor: r,
1394
1396
  sharedAppBar: a,
1395
1397
  sharedNavigationBar: o,
1396
- appBar: u,
1397
- navigationBar: h,
1398
+ appBar: c,
1399
+ navigationBar: f,
1398
1400
  hideStatusBar: l,
1399
1401
  hideSystemNavigationBar: E,
1400
1402
  backgroundColor: g = "white",
1401
- contentScrollable: c = !0,
1403
+ contentScrollable: u = !0,
1402
1404
  ...L
1403
1405
  }) {
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 = $({
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 = $({
1405
1407
  element: null,
1406
1408
  hasMarker: !1
1407
1409
  }), z = $({ element: null, hasMarker: !1 }), lt = $(0), dt = $(0), pt = $(null), ft = $(null), Ut = async (v, G) => {
@@ -1484,7 +1486,7 @@ function Ht({
1484
1486
  };
1485
1487
  }, [D]), Y(() => {
1486
1488
  D.current && (async () => {
1487
- const { value: v, options: G } = f[`${b}-${M}`];
1489
+ const { value: v, options: G } = h[`${b}-${M}`];
1488
1490
  !M && b === "REPLACING" && Q !== _ && (y("PENDING"), await I(D.current, fe, {
1489
1491
  duration: 0.1
1490
1492
  })), M && b === "COMPLETED" && (d("IDLE"), y("IDLE")), await I(D.current, v, G), await F.resolveTask(P);
@@ -1497,7 +1499,7 @@ function Ht({
1497
1499
  _,
1498
1500
  I,
1499
1501
  D,
1500
- f,
1502
+ h,
1501
1503
  d,
1502
1504
  y
1503
1505
  ]), Tt(() => {
@@ -1574,7 +1576,7 @@ function Ht({
1574
1576
  flexDirection: "column",
1575
1577
  height: "100%",
1576
1578
  backgroundColor: g,
1577
- overflowY: c ? void 0 : "auto",
1579
+ overflowY: u ? void 0 : "auto",
1578
1580
  ...L.style
1579
1581
  },
1580
1582
  children: [
@@ -1599,7 +1601,7 @@ function Ht({
1599
1601
  }
1600
1602
  }
1601
1603
  ),
1602
- u,
1604
+ c,
1603
1605
  /* @__PURE__ */ x(
1604
1606
  "div",
1605
1607
  {
@@ -1607,12 +1609,12 @@ function Ht({
1607
1609
  display: "flex",
1608
1610
  flexDirection: "column",
1609
1611
  flexGrow: 1,
1610
- overflowY: c ? "auto" : void 0
1612
+ overflowY: u ? "auto" : void 0
1611
1613
  },
1612
1614
  children: n
1613
1615
  }
1614
1616
  ),
1615
- h,
1617
+ f,
1616
1618
  o && /* @__PURE__ */ x(
1617
1619
  "div",
1618
1620
  {
@@ -1680,11 +1682,11 @@ function Ht({
1680
1682
  );
1681
1683
  }
1682
1684
  function xe({ children: n, ...e }) {
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;
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;
1684
1686
  return /* @__PURE__ */ x(Ht, { ...e, children: /* @__PURE__ */ x(Ct, { mode: E ? "hidden" : "visible", children: n }) });
1685
1687
  }
1686
1688
  function Ne({ children: n, ...e }) {
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;
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;
1688
1690
  return /* @__PURE__ */ x(
1689
1691
  Ht,
1690
1692
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flemo",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
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",
@@ -33,14 +33,6 @@
33
33
  },
34
34
  "homepage": "https://flemo-dev.lovable.app",
35
35
  "license": "MIT",
36
- "scripts": {
37
- "build": "vite build",
38
- "watch": "vite build --watch",
39
- "prettier": "prettier --write --config ./.prettierrc \"**/*.{js,mjs,ts,jsx,tsx,mts,json}\"",
40
- "convention": "pnpm prettier && eslint --fix \"**/*.{js,mjs,ts,jsx,tsx,mts,html}\"",
41
- "prepare": "husky",
42
- "prepublishOnly": "pnpm build"
43
- },
44
36
  "dependencies": {
45
37
  "path-to-regexp": "^8.2.0",
46
38
  "zustand": "^5.0.11"
@@ -75,5 +67,11 @@
75
67
  "lint-staged": {
76
68
  "*.{js,mjs,ts,jsx,tsx,mts,json}": "prettier --write",
77
69
  "*.{js,mjs,ts,jsx,tsx,mts,html}": "eslint --fix"
70
+ },
71
+ "scripts": {
72
+ "build": "vite build",
73
+ "watch": "vite build --watch",
74
+ "prettier": "prettier --write --config ./.prettierrc \"**/*.{js,mjs,ts,jsx,tsx,mts,json}\"",
75
+ "convention": "pnpm prettier && eslint --fix \"**/*.{js,mjs,ts,jsx,tsx,mts,html}\""
78
76
  }
79
- }
77
+ }