@flemo/react 1.0.4 → 1.0.6

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 +46 -46
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { jsx as N, jsxs as Ht, Fragment as fe } from "react/jsx-runtime";
2
- import Pt, { useEffect as dt, createContext as Gt, useContext as Yt, useReducer as me, Children as te, useInsertionEffect as ye, useRef as L, useImperativeHandle as he, useState as bt, useLayoutEffect as xt } from "react";
2
+ import xt, { useEffect as ht, createContext as Gt, useContext as Yt, useReducer as me, Children as te, useInsertionEffect as ye, useRef as L, useImperativeHandle as he, useState as bt, useLayoutEffect as ft } from "react";
3
3
  import { consumeSelfInducedPop as ge, TaskManger as G, useNavigateStore as W, useHistoryStore as O, getMatchedPathPattern as we, transitionMap as ct, decoratorMap as yt, isServer as Mt, compileTransitionStyles as Se, useTransitionStore as Ot, getParams as ve, markSelfInducedPop as ee, targetToDecls as Te, easingToCss as Ee, variantHasAnimation as Pe, animationName as xe, findScrollable as qt, collectAnimatedProperties as be } from "@flemo/core";
4
4
  import { createDecorator as tn, createRawDecorator as en, createRawTransition as nn, createTransition as rn } from "@flemo/core";
5
5
  function Ie() {
6
- return dt(() => {
6
+ return ht(() => {
7
7
  const n = async (e) => {
8
8
  if (ge())
9
9
  return;
@@ -47,7 +47,7 @@ function Ie() {
47
47
  var j = {}, zt;
48
48
  function Re() {
49
49
  if (zt) return j;
50
- zt = 1, Object.defineProperty(j, "__esModule", { value: !0 }), j.PathError = j.TokenData = void 0, j.parse = m, j.compile = x, j.match = $, j.pathToRegexp = C, j.stringify = gt;
50
+ zt = 1, Object.defineProperty(j, "__esModule", { value: !0 }), j.PathError = j.TokenData = void 0, j.parse = m, j.compile = x, j.match = $, j.pathToRegexp = C, j.stringify = wt;
51
51
  const n = "/", e = (o) => o, r = /^[$_\p{ID_Start}]$/u, a = /^[$\u200c\u200d\p{ID_Continue}]$/u, u = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;
52
52
  function i(o) {
53
53
  return o.replace(/[{}()\[\]+?!:*\\]/g, "\\$&");
@@ -295,7 +295,7 @@ function Re() {
295
295
  }
296
296
  return y;
297
297
  }
298
- function gt(o) {
298
+ function wt(o) {
299
299
  return Y(o.tokens, 0);
300
300
  }
301
301
  function B(o, c) {
@@ -317,7 +317,7 @@ const ne = Gt({
317
317
  layoutId: null,
318
318
  routePath: ""
319
319
  });
320
- function ht() {
320
+ function gt() {
321
321
  return Yt(ne);
322
322
  }
323
323
  const re = Gt({}), oe = Gt(() => {
@@ -326,8 +326,8 @@ function De(n, e) {
326
326
  return e.type === "SET" ? e.params : n;
327
327
  }
328
328
  function Le({ children: n }) {
329
- const { isActive: e, params: r } = ht(), [a, u] = me(De, r);
330
- return dt(() => {
329
+ const { isActive: e, params: r } = gt(), [a, u] = me(De, r);
330
+ return ht(() => {
331
331
  const i = async (s) => {
332
332
  s.state?.step && await G.addTask(async () => {
333
333
  u({ type: "SET", params: s.state?.params || {} });
@@ -413,7 +413,7 @@ function Fe({
413
413
  layoutId: null
414
414
  }
415
415
  ]
416
- }), $e(a, u), dt(() => {
416
+ }), $e(a, u), ht(() => {
417
417
  window.history.state?.index || window.history.replaceState(
418
418
  {
419
419
  id: "root",
@@ -547,7 +547,7 @@ function ze() {
547
547
  };
548
548
  }
549
549
  function Ke() {
550
- const { routePath: n } = ht(), e = Yt(oe);
550
+ const { routePath: n } = gt(), e = Yt(oe);
551
551
  return {
552
552
  pushStep: async (i) => {
553
553
  (await G.addTask(async () => {
@@ -641,7 +641,7 @@ function Ce({ freeze: n, children: e }) {
641
641
  );
642
642
  }
643
643
  function He({ ref: n, style: e, ...r }) {
644
- const { isActive: a, transitionName: u } = ht(), i = L(null);
644
+ const { isActive: a, transitionName: u } = gt(), i = L(null);
645
645
  he(n, () => i.current);
646
646
  const s = W((x) => x.status), T = ct.get(u) ?? ct.get("none"), { decoratorName: E } = T, m = yt.get(E);
647
647
  return m ? /* @__PURE__ */ N(
@@ -678,12 +678,12 @@ const Jt = (n) => {
678
678
  return T;
679
679
  }, Me = ((n) => n ? Jt(n) : Jt), Oe = (n) => n;
680
680
  function Be(n, e = Oe) {
681
- const r = Pt.useSyncExternalStore(
681
+ const r = xt.useSyncExternalStore(
682
682
  n.subscribe,
683
- Pt.useCallback(() => e(n.getState()), [n, e]),
684
- Pt.useCallback(() => e(n.getInitialState()), [n, e])
683
+ xt.useCallback(() => e(n.getState()), [n, e]),
684
+ xt.useCallback(() => e(n.getInitialState()), [n, e])
685
685
  );
686
- return Pt.useDebugValue(r), r;
686
+ return xt.useDebugValue(r), r;
687
687
  }
688
688
  const Qt = (n) => {
689
689
  const e = Me(n), r = (a) => Be(e, a);
@@ -703,7 +703,7 @@ const Qt = (n) => {
703
703
  let Ct = 0;
704
704
  function Ge() {
705
705
  const [n, e] = bt(0), [r, a] = bt(0);
706
- return dt(() => {
706
+ return ht(() => {
707
707
  let u = 0;
708
708
  const i = () => {
709
709
  cancelAnimationFrame(u), u = requestAnimationFrame(() => {
@@ -772,14 +772,14 @@ function Ve({
772
772
  contentScrollable: R = !0,
773
773
  ...$
774
774
  }) {
775
- const { id: C, isActive: D, isRoot: q, zIndex: M, transitionName: Y, prevTransitionName: gt } = ht(), B = pt((t) => t.status), o = Q((t) => t.dragStatus), c = Q.getState().setDragStatus, y = Q.getState().setReplaceTransitionStatus, p = O((t) => t.index), l = ct.get(Y) ?? ct.get("none"), { initial: g, swipeDirection: d, decoratorName: P } = l, w = yt.get(P), { viewportScrollHeight: I } = Ge(), b = I > 0, [U, S] = bt(0), [H, _] = bt(0), Vt = L(null), V = L(null), Z = L(null), z = L(null), ut = L(null), J = L({
775
+ const { id: C, isActive: D, isRoot: q, zIndex: M, transitionName: Y, prevTransitionName: wt } = gt(), B = pt((t) => t.status), o = Q((t) => t.dragStatus), c = Q.getState().setDragStatus, y = Q.getState().setReplaceTransitionStatus, p = O((t) => t.index), l = ct.get(Y) ?? ct.get("none"), { initial: g, swipeDirection: d, decoratorName: P } = l, w = yt.get(P), { viewportScrollHeight: I } = Ge(), b = I > 0, [U, S] = bt(0), [H, _] = bt(0), Vt = L(null), V = L(null), Z = L(null), z = L(null), ut = L(null), J = L({
776
776
  current: [],
777
777
  prev: []
778
- }), tt = L(!1), ft = L(!1), rt = L(!1), ae = L(0), Rt = L({ x: 0, y: 0 }), wt = L({ x: 0, y: 0 }), Dt = L(0), Lt = L({ x: 0, y: 0 }), et = L({
778
+ }), tt = L(!1), dt = L(!1), rt = L(!1), ae = L(0), Rt = L({ x: 0, y: 0 }), St = L({ x: 0, y: 0 }), Dt = L(0), Lt = L({ x: 0, y: 0 }), et = L({
779
779
  element: null,
780
780
  hasMarker: !1
781
781
  }), ot = L({ element: null, hasMarker: !1 }), Nt = L(0), $t = L(0), at = L(null), it = L(null), At = (t) => {
782
- const f = wt.current;
782
+ const f = St.current;
783
783
  return {
784
784
  point: { x: t.clientX, y: t.clientY },
785
785
  offset: {
@@ -790,11 +790,11 @@ function Ve({
790
790
  velocity: Lt.current
791
791
  };
792
792
  }, ie = (t) => {
793
- const f = t.timeStamp, v = Math.max(1, f - Dt.current), k = wt.current;
793
+ const f = t.timeStamp, v = Math.max(1, f - Dt.current), k = St.current;
794
794
  Lt.current = {
795
795
  x: (t.clientX - k.x) / v * 1e3,
796
796
  y: (t.clientY - k.y) / v * 1e3
797
- }, wt.current = { x: t.clientX, y: t.clientY }, Dt.current = f;
797
+ }, St.current = { x: t.clientX, y: t.clientY }, Dt.current = f;
798
798
  }, kt = (t, f, v) => {
799
799
  const k = lt(t, f, v);
800
800
  if (t === V.current)
@@ -806,29 +806,29 @@ function Ve({
806
806
  return k;
807
807
  }, se = (t) => {
808
808
  const f = D ? O.getState().histories[p - 1]?.id : O.getState().histories[p]?.id, v = f ? Q.getState().sharedBars[f] : void 0, k = [], A = at.current, st = it.current;
809
- A && vt && !v?.appBar && k.push(A), st && Tt && !v?.navigationBar && k.push(st);
809
+ A && Tt && !v?.appBar && k.push(A), st && Et && !v?.navigationBar && k.push(st);
810
810
  const X = [];
811
811
  if (t) {
812
812
  const nt = t.querySelector('[data-flemo-bar="app"]'), Ft = t.querySelector('[data-flemo-bar="nav"]');
813
- nt && !vt && X.push(nt), Ft && !Tt && X.push(Ft);
813
+ nt && !Tt && X.push(nt), Ft && !Et && X.push(Ft);
814
814
  }
815
815
  J.current = { current: k, prev: X };
816
- const Et = be(l).join(", ");
817
- for (const nt of k) nt.style.willChange = Et;
818
- for (const nt of X) nt.style.willChange = Et;
816
+ const Pt = be(l).join(", ");
817
+ for (const nt of k) nt.style.willChange = Pt;
818
+ for (const nt of X) nt.style.willChange = Pt;
819
819
  }, _t = () => {
820
820
  for (const t of J.current.current)
821
821
  F(t), t.style.removeProperty("will-change");
822
822
  for (const t of J.current.prev)
823
823
  F(t), t.style.removeProperty("will-change");
824
824
  J.current = { current: [], prev: [] };
825
- }, St = async (t) => {
825
+ }, vt = async (t) => {
826
826
  if (!d || I > 10) return;
827
827
  const f = V.current;
828
828
  if (!f) return;
829
829
  const v = Vt.current?.parentElement?.previousElementSibling;
830
830
  if (Z.current = v?.querySelector("[data-flemo-screen]") ?? null, ut.current = v?.querySelector("[data-flemo-decorator]") ?? null, !Z.current) return;
831
- rt.current = !0, ae.current = t.timeStamp, Rt.current = { x: t.clientX, y: t.clientY }, wt.current = { x: t.clientX, y: t.clientY }, Dt.current = t.timeStamp, Lt.current = { x: 0, y: 0 }, f.setPointerCapture(t.pointerId), se(v), await l?.onSwipeStart(t, At(t), {
831
+ rt.current = !0, ae.current = t.timeStamp, Rt.current = { x: t.clientX, y: t.clientY }, St.current = { x: t.clientX, y: t.clientY }, Dt.current = t.timeStamp, Lt.current = { x: 0, y: 0 }, f.setPointerCapture(t.pointerId), se(v), await l?.onSwipeStart(t, At(t), {
832
832
  animate: kt,
833
833
  currentScreen: f,
834
834
  prevScreen: Z.current,
@@ -892,30 +892,30 @@ function Ve({
892
892
  }
893
893
  const f = !et.current.element && !ot.current.element;
894
894
  if (tt.current && f) {
895
- tt.current = !1, ft.current = !0;
895
+ tt.current = !1, dt.current = !0;
896
896
  const v = t.clientY - $t.current, k = t.clientX - Nt.current;
897
- (d === "y" && v > 0 || d === "x" && k > 0) && St(t.nativeEvent);
897
+ (d === "y" && v > 0 || d === "x" && k > 0) && vt(t.nativeEvent);
898
898
  } else if (tt.current && !f) {
899
899
  const v = t.clientX - Nt.current, k = t.clientY - $t.current, A = ot.current.element && ot.current.element.scrollTop <= 0, st = et.current.element && et.current.element.scrollLeft <= 0 && et.current.hasMarker;
900
- (d === "y" && (A || et.current.element) && k > 0 && Math.abs(v) < 2 || d === "x" && (st || ot.current.element) && v > 0 && Math.abs(k) < 2) && (tt.current = !1, ft.current = !0, St(t.nativeEvent));
900
+ (d === "y" && (A || et.current.element) && k > 0 && Math.abs(v) < 2 || d === "x" && (st || ot.current.element) && v > 0 && Math.abs(k) < 2) && (tt.current = !1, dt.current = !0, vt(t.nativeEvent));
901
901
  }
902
902
  }, jt = (t) => {
903
- tt.current = !1, ft.current = !1, rt.current && ue(t.nativeEvent);
903
+ tt.current = !1, dt.current = !1, rt.current && ue(t.nativeEvent);
904
904
  };
905
- dt(() => {
905
+ ht(() => {
906
906
  const t = V.current;
907
907
  if (!t) return;
908
908
  const f = (v) => {
909
- ft.current && v.preventDefault(), v.target?.dataset.swipeAtEdgeBar === "true" && v.preventDefault();
909
+ dt.current && v.preventDefault(), v.target?.dataset.swipeAtEdgeBar === "true" && v.preventDefault();
910
910
  };
911
911
  return t.addEventListener("touchmove", f, {
912
912
  passive: !1
913
913
  }), () => {
914
914
  t.removeEventListener("touchmove", f);
915
915
  };
916
- }, []), dt(() => {
916
+ }, []), ft(() => {
917
917
  if (!D) {
918
- B === "REPLACING" && gt !== Y && y("PENDING");
918
+ B === "REPLACING" && wt !== Y && y("PENDING");
919
919
  return;
920
920
  }
921
921
  if (B === "COMPLETED") {
@@ -943,12 +943,12 @@ function Ve({
943
943
  B,
944
944
  D,
945
945
  C,
946
- gt,
946
+ wt,
947
947
  Y,
948
948
  l,
949
949
  c,
950
950
  y
951
- ]), xt(() => {
951
+ ]), ft(() => {
952
952
  const t = at.current;
953
953
  if (!t) {
954
954
  S(0);
@@ -961,7 +961,7 @@ function Ve({
961
961
  return f.observe(t), () => {
962
962
  f.disconnect();
963
963
  };
964
- }, [i]), xt(() => {
964
+ }, [i]), ft(() => {
965
965
  const t = it.current;
966
966
  if (!t) {
967
967
  _(0);
@@ -974,15 +974,15 @@ function Ve({
974
974
  return f.observe(t), () => {
975
975
  f.disconnect();
976
976
  };
977
- }, [s]), xt(() => {
977
+ }, [s]), ft(() => {
978
978
  const { registerSharedBars: t, unregisterSharedBars: f } = Q.getState();
979
979
  return t(C, {
980
980
  appBar: !!i,
981
981
  navigationBar: !!s
982
982
  }), () => f(C);
983
983
  }, [C, i, s]);
984
- const Xt = D || M === p - 1, vt = !!i, Tt = !!s;
985
- xt(() => {
984
+ const Xt = D || M === p - 1, Tt = !!i, Et = !!s;
985
+ ft(() => {
986
986
  const t = at.current, f = it.current;
987
987
  if (!t && !f) return;
988
988
  const v = () => {
@@ -990,15 +990,15 @@ function Ve({
990
990
  t?.removeAttribute("data-flemo-bar-riding"), f?.removeAttribute("data-flemo-bar-riding");
991
991
  return;
992
992
  }
993
- const X = D ? O.getState().histories[p - 1]?.id : O.getState().histories[p]?.id, K = X ? Q.getState().sharedBars[X] : void 0, Et = vt && !K?.appBar, nt = Tt && !K?.navigationBar;
994
- t && t.setAttribute("data-flemo-bar-riding", Et ? "true" : "false"), f && f.setAttribute("data-flemo-bar-riding", nt ? "true" : "false");
993
+ const X = D ? O.getState().histories[p - 1]?.id : O.getState().histories[p]?.id, K = X ? Q.getState().sharedBars[X] : void 0, Pt = Tt && !K?.appBar, nt = Et && !K?.navigationBar;
994
+ t && t.setAttribute("data-flemo-bar-riding", Pt ? "true" : "false"), f && f.setAttribute("data-flemo-bar-riding", nt ? "true" : "false");
995
995
  };
996
996
  v();
997
997
  const k = Q.subscribe(v), A = pt.subscribe(v);
998
998
  return () => {
999
999
  k(), A(), t?.removeAttribute("data-flemo-bar-riding"), f?.removeAttribute("data-flemo-bar-riding");
1000
1000
  };
1001
- }, [Xt, D, p, vt, Tt]);
1001
+ }, [Xt, D, p, Tt, Et]);
1002
1002
  const de = (() => {
1003
1003
  if (!D) return {};
1004
1004
  if (B !== "PUSHING" && B !== "REPLACING") return {};
@@ -1190,7 +1190,7 @@ function Ve({
1190
1190
  );
1191
1191
  }
1192
1192
  function Je({ children: n, ...e }) {
1193
- const { isActive: r, isPrev: a, zIndex: u } = ht(), i = O((h) => h.index), s = W((h) => h.status), T = Q((h) => h.dragStatus), E = Q((h) => h.replaceTransitionStatus), x = !r && (s === "COMPLETED" && T === "IDLE") || a && i - 2 <= u && E === "IDLE" || a && i - 2 > u;
1193
+ const { isActive: r, isPrev: a, zIndex: u } = gt(), i = O((h) => h.index), s = W((h) => h.status), T = Q((h) => h.dragStatus), E = Q((h) => h.replaceTransitionStatus), x = !r && (s === "COMPLETED" && T === "IDLE") || a && i - 2 <= u && E === "IDLE" || a && i - 2 > u;
1194
1194
  return /* @__PURE__ */ N(Ce, { freeze: x, children: /* @__PURE__ */ N(Ve, { ...e, children: n }) });
1195
1195
  }
1196
1196
  export {
@@ -1207,7 +1207,7 @@ export {
1207
1207
  rn as createTransition,
1208
1208
  ze as useNavigate,
1209
1209
  We as useParams,
1210
- ht as useScreen,
1210
+ gt as useScreen,
1211
1211
  Q as useScreenStore,
1212
1212
  Ke as useStep,
1213
1213
  Ge as useViewportScrollHeight
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemo/react",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "React bindings for flemo — Router, Route, Screen, and the screen-transition runtime.",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "path-to-regexp": "^8.2.0",
38
38
  "zustand": "^5.0.11",
39
- "@flemo/core": "1.1.0"
39
+ "@flemo/core": "1.1.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@testing-library/jest-dom": "^6.6.3",