@flemo/react 1.7.2 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.mjs CHANGED
@@ -1,20 +1,20 @@
1
- import e, { Activity as t, Children as n, createContext as r, isValidElement as i, useContext as a, useEffect as o, useId as s, useImperativeHandle as c, useInsertionEffect as l, useLayoutEffect as u, useReducer as ee, useRef as d, useState as f } from "react";
2
- import { animHoldKey as te, appendParamsQuery as p, buildRoutePath as m, computeBarRiding as h, computeScreenFreeze as ne, consumeSelfInducedPop as g, createAnimHoldCoordinator as _, createBrowserHistoryDriver as v, createBrowserHistoryDriver as y, createDecorator as b, createHistoryStore as re, createNavigateStore as x, createNavigationController as S, createPartTransition as C, createRawDecorator as w, createRawPartTransition as T, createRawTransition as E, createRouterScope as D, createScreenSelector as O, createScreenStore as k, createStepController as A, createSwipeController as j, createTransition as M, createTransitionEngine as ie, createTransitionStore as ae, decoratorMap as oe, eagerlyDecodeImages as se, ensureScopeHistorySync as ce, enteringInitialStyle as le, getMatchedPathPattern as ue, isOpaqueColor as de, isServer as N, markSelfInducedPop as fe, matchesPathname as pe, observeBarHeight as me, observeViewportScrollHeight as he, partTransitionMap as ge, readStepParams as P, registerTransitionDefinitions as F, releaseScopeHistorySync as _e, resolveTransition as ve, seedRouterEntry as ye, subscribeStepParamsRestore as be } from "@flemo/core";
3
- import { jsx as I, jsxs as xe } from "react/jsx-runtime";
1
+ import e, { Activity as t, Children as n, createContext as r, isValidElement as i, useContext as a, useEffect as o, useId as s, useImperativeHandle as c, useInsertionEffect as l, useLayoutEffect as u, useReducer as d, useRef as f, useState as p } from "react";
2
+ import { animHoldKey as ee, appendParamsQuery as m, buildRoutePath as h, computeBarRiding as g, computeScreenFreeze as te, consumeSelfInducedPop as _, createAnimHoldCoordinator as v, createBrowserHistoryDriver as y, createBrowserHistoryDriver as b, createDecorator as x, createHistoryStore as ne, createNavigateStore as S, createNavigationController as C, createPartTransition as re, createRawDecorator as w, createRawPartTransition as T, createRawTransition as E, createRouterScope as D, createScreenSelector as O, createScreenStore as k, createStepController as A, createSwipeController as j, createTransition as M, createTransitionEngine as ie, createTransitionStore as ae, decoratorMap as oe, eagerlyDecodeImages as se, ensureImageDecodeOffloader as ce, ensureScopeHistorySync as le, enteringInitialStyle as ue, getMatchedPathPattern as N, holdCompositorWarm as de, isOpaqueColor as fe, isServer as pe, markSelfInducedPop as me, matchesPathname as he, observeBarHeight as ge, observeViewportScrollHeight as _e, partTransitionMap as P, readStepParams as ve, registerTransitionDefinitions as ye, releaseScopeHistorySync as be, resolveTransition as xe, seedRouterEntry as F, subscribeStepParamsRestore as I } from "@flemo/core";
3
+ import { jsx as L, jsxs as Se } from "react/jsx-runtime";
4
4
  //#region src/stores/StoreContext.ts
5
- var L = r(null);
5
+ var R = r(null);
6
6
  //#endregion
7
7
  //#region src/stores/useStores.ts
8
- function R() {
9
- let e = a(L);
8
+ function z() {
9
+ let e = a(R);
10
10
  if (!e) throw Error("flemo stores are missing. Render inside a <Router>.");
11
11
  return e;
12
12
  }
13
13
  //#endregion
14
14
  //#region src/history/HistoryListener.tsx
15
- function z() {
16
- let e = R();
17
- return o(() => (ce(e), () => _e(e)), [e]), null;
15
+ function Ce() {
16
+ let e = z();
17
+ return o(() => (le(e), () => be(e)), [e]), null;
18
18
  }
19
19
  //#endregion
20
20
  //#region src/screen/ScreenContext.ts
@@ -38,10 +38,10 @@ function V() {
38
38
  }
39
39
  //#endregion
40
40
  //#region src/screen/ParamsProvider/ParamsContext.ts
41
- var Se = r({}), H = r(() => {});
41
+ var we = r({}), Te = r(() => {});
42
42
  //#endregion
43
43
  //#region src/screen/ParamsProvider/ParamsReducer.ts
44
- function Ce(e, t) {
44
+ function Ee(e, t) {
45
45
  switch (t.type) {
46
46
  case "SET": return t.params;
47
47
  default: return e;
@@ -49,10 +49,10 @@ function Ce(e, t) {
49
49
  }
50
50
  //#endregion
51
51
  //#region src/screen/ParamsProvider/ParamsProvider.tsx
52
- function we({ children: e }) {
53
- let { isActive: t, params: n } = V(), { driver: r } = R(), [i, a] = ee(Ce, n);
52
+ function H({ children: e }) {
53
+ let { isActive: t, params: n } = V(), { driver: r } = z(), [i, a] = d(Ee, n);
54
54
  return o(() => {
55
- if (t) return be(r, (e) => a({
55
+ if (t) return I(r, (e) => a({
56
56
  type: "SET",
57
57
  params: e
58
58
  }));
@@ -60,9 +60,9 @@ function we({ children: e }) {
60
60
  t,
61
61
  a,
62
62
  r
63
- ]), /* @__PURE__ */ I(H.Provider, {
63
+ ]), /* @__PURE__ */ L(Te.Provider, {
64
64
  value: a,
65
- children: /* @__PURE__ */ I(Se.Provider, {
65
+ children: /* @__PURE__ */ L(we.Provider, {
66
66
  value: i,
67
67
  children: e
68
68
  })
@@ -70,42 +70,42 @@ function we({ children: e }) {
70
70
  }
71
71
  //#endregion
72
72
  //#region ../../node_modules/.pnpm/zustand@5.0.14_@types+react@19.2.17_react@19.2.7/node_modules/zustand/esm/react.mjs
73
- var Te = (e) => e;
74
- function U(t, n = Te) {
73
+ var De = (e) => e;
74
+ function U(t, n = De) {
75
75
  let r = e.useSyncExternalStore(t.subscribe, e.useCallback(() => n(t.getState()), [t, n]), e.useCallback(() => n(t.getInitialState()), [t, n]));
76
76
  return e.useDebugValue(r), r;
77
77
  }
78
78
  //#endregion
79
79
  //#region src/stores/useHistoryStore.ts
80
80
  function W(e) {
81
- return U(R().history, e);
81
+ return U(z().history, e);
82
82
  }
83
83
  //#endregion
84
84
  //#region src/renderer/Renderer.tsx
85
85
  function G({ children: e }) {
86
- let t = W((e) => e.index), r = W((e) => e.histories), i = R();
86
+ let t = W((e) => e.index), r = W((e) => e.histories), i = z();
87
87
  return O(r, t).map((t) => {
88
- let [r] = n.toArray(e).filter((e) => pe(e.props.path, t.pathname));
89
- return r ? /* @__PURE__ */ I(B.Provider, {
88
+ let [r] = n.toArray(e).filter((e) => he(e.props.path, t.pathname));
89
+ return r ? /* @__PURE__ */ L(B.Provider, {
90
90
  value: {
91
91
  ...t,
92
92
  navigateStore: i.navigate,
93
- routePath: ue(r.props.path, t.pathname)
93
+ routePath: N(r.props.path, t.pathname)
94
94
  },
95
- children: /* @__PURE__ */ I(we, { children: r })
95
+ children: /* @__PURE__ */ L(H, { children: r })
96
96
  }, t.id) : null;
97
97
  });
98
98
  }
99
99
  //#endregion
100
100
  //#region src/screen/ScreenViewportContext.ts
101
101
  var K = r({ contained: !1 });
102
- function Ee() {
102
+ function Oe() {
103
103
  return a(K);
104
104
  }
105
105
  //#endregion
106
106
  //#region src/transition/styles.ts
107
- function q(e, t, n = []) {
108
- l(() => F(e, t, n), [
107
+ function ke(e, t, n = []) {
108
+ l(() => ye(e, t, n), [
109
109
  e,
110
110
  t,
111
111
  n
@@ -113,109 +113,131 @@ function q(e, t, n = []) {
113
113
  }
114
114
  //#endregion
115
115
  //#region src/RouterDepthContext.ts
116
- var J = r(0), De = { contained: !0 };
117
- function Y({ children: e, className: t, style: n }) {
118
- return /* @__PURE__ */ I("div", {
116
+ var q = r(0), Ae = { contained: !0 };
117
+ function je({ children: e, className: t, style: n }) {
118
+ return /* @__PURE__ */ L("div", {
119
119
  className: t,
120
120
  style: {
121
121
  position: "relative",
122
122
  overflow: "hidden",
123
123
  ...n
124
124
  },
125
- children: /* @__PURE__ */ I(K.Provider, {
126
- value: De,
127
- children: /* @__PURE__ */ I(G, { children: e })
125
+ children: /* @__PURE__ */ L(K.Provider, {
126
+ value: Ae,
127
+ children: /* @__PURE__ */ L(G, { children: e })
128
128
  })
129
129
  });
130
130
  }
131
131
  //#endregion
132
132
  //#region src/Router.tsx
133
- function Oe(e) {
133
+ function Me(e) {
134
134
  let t = null;
135
135
  return n.forEach(e, (e) => {
136
136
  if (t || !i(e)) return;
137
- if (e.type === Y) {
137
+ if (e.type === je) {
138
138
  t = n.toArray(e.props.children).filter(i);
139
139
  return;
140
140
  }
141
141
  let r = e.props.children;
142
142
  if (r) {
143
- let e = Oe(r);
143
+ let e = Me(r);
144
144
  e && (t = e);
145
145
  }
146
146
  }), t;
147
147
  }
148
- var ke = typeof window > "u" ? o : u, Ae = [], je = [], Me = [], Ne = { contained: !0 };
149
- function X({ children: e, initPath: t = "/", defaultTransitionName: r = "cupertino", transitions: i = Ae, decorators: c = je, partTransitions: l = Me, history: u = "browser", createDriver: ee, className: d, style: te }) {
150
- let p = a(J), m = p > 0, h = u === "memory", ne = s(), g = a(B), _ = a(L), v = m && g.id ? `_F_${_?.routerKey ?? ""}${g.id}_` : ne, b = Oe(e), re = b !== null, x = m ? null : _, S = x !== null, C = ee ?? y, [w] = f(() => h ? null : C(S ? void 0 : v)), T = !m && !h && !N(), E = T && w ? w.readPathname() : t || "/", O = E.indexOf("?"), k = (O >= 0 ? E.slice(0, O) : E) || "/", A = T ? window.location.search : O >= 0 ? E.slice(O) : "", [j] = f(() => D({
151
- routePaths: (b ?? n.toArray(e)).map((e) => e.props.path).flat(),
148
+ var Ne = typeof window > "u" ? o : u, Pe = [], Fe = [], J = [], Ie = { contained: !0 }, Le = 500, Re = 3e3;
149
+ function Y({ children: e, initPath: t = "/", defaultTransitionName: r = "cupertino", transitions: i = Pe, decorators: c = Fe, partTransitions: l = J, history: u = "browser", createDriver: d, className: f, style: ee }) {
150
+ let m = a(q), h = m > 0, g = u === "memory", te = s(), _ = a(B), v = a(R), y = h && _.id ? `_F_${v?.routerKey ?? ""}${_.id}_` : te, x = Me(e), ne = x !== null, S = h ? null : v, C = S !== null, re = d ?? b, [w] = p(() => g ? null : re(C ? void 0 : y)), T = !h && !g && !pe(), E = T && w ? w.readPathname() : t || "/", O = E.indexOf("?"), k = (O >= 0 ? E.slice(0, O) : E) || "/", A = T ? window.location.search : O >= 0 ? E.slice(O) : "", [j] = p(() => D({
151
+ routePaths: (x ?? n.toArray(e)).map((e) => e.props.path).flat(),
152
152
  pathname: k,
153
153
  search: A,
154
154
  defaultTransitionName: r,
155
- memory: h,
155
+ memory: g,
156
156
  browserDriver: w,
157
- hostedScope: x,
158
- routerKey: S ? void 0 : v,
159
- zoneEntryId: m && !S && g.id || void 0,
160
- persistKey: m && !h && !S ? v : void 0
157
+ hostedScope: S,
158
+ routerKey: C ? void 0 : y,
159
+ zoneEntryId: h && !C && _.id || void 0,
160
+ persistKey: h && !g && !C ? y : void 0
161
161
  }));
162
- j.transition.setState({ defaultTransitionName: r }), ke(() => (j.life.alive = !0, () => {
162
+ j.transition.setState({ defaultTransitionName: r }), Ne(() => (j.life.alive = !0, () => {
163
163
  j.life.alive = !1;
164
- }), [j]), q(i, c, l), o(() => {
165
- h || !w || ye({
164
+ }), [j]), ke(i, c, l), o(() => ce(), []), o(() => {
165
+ if (typeof document > "u") return;
166
+ let e = null, t = null, n = 0, r = () => {
167
+ let r = Date.now();
168
+ if (r - n < Le) return;
169
+ n = r, t && clearTimeout(t);
170
+ let i = e;
171
+ e = de(), i?.(), t = setTimeout(() => {
172
+ t = null, e?.(), e = null;
173
+ }, Re);
174
+ }, i = [
175
+ "pointerdown",
176
+ "pointermove",
177
+ "wheel",
178
+ "touchstart",
179
+ "keydown"
180
+ ];
181
+ for (let e of i) document.addEventListener(e, r, { passive: !0 });
182
+ return () => {
183
+ for (let e of i) document.removeEventListener(e, r);
184
+ t && clearTimeout(t), e?.();
185
+ };
186
+ }, []), o(() => {
187
+ g || !w || F({
166
188
  driver: w,
167
- routerKey: S ? null : v,
168
- nested: m && !S,
189
+ routerKey: C ? null : y,
190
+ nested: h && !C,
169
191
  seedPathname: k,
170
192
  defaultTransitionName: r,
171
193
  rootParams: j.history.getState().histories[0]?.params ?? {}
172
194
  });
173
195
  }, [
196
+ g,
197
+ C,
174
198
  h,
175
- S,
176
- m,
177
- v,
199
+ y,
178
200
  k,
179
201
  r,
180
202
  j.history,
181
203
  w
182
204
  ]);
183
- let M = re ? e : /* @__PURE__ */ I(G, { children: e }), ie = /* @__PURE__ */ I(J.Provider, {
184
- value: p + 1,
185
- children: /* @__PURE__ */ xe(L.Provider, {
205
+ let M = ne ? e : /* @__PURE__ */ L(G, { children: e }), ie = /* @__PURE__ */ L(q.Provider, {
206
+ value: m + 1,
207
+ children: /* @__PURE__ */ Se(R.Provider, {
186
208
  value: j,
187
- children: [!h && /* @__PURE__ */ I(z, {}), m ? /* @__PURE__ */ I(K.Provider, {
188
- value: Ne,
209
+ children: [!g && /* @__PURE__ */ L(Ce, {}), h ? /* @__PURE__ */ L(K.Provider, {
210
+ value: Ie,
189
211
  children: M
190
212
  }) : M]
191
213
  })
192
214
  });
193
- return m ? /* @__PURE__ */ I("div", {
194
- className: d,
215
+ return h ? /* @__PURE__ */ L("div", {
216
+ className: f,
195
217
  style: {
196
218
  position: "relative",
197
219
  overflow: "hidden",
198
- ...te
220
+ ...ee
199
221
  },
200
222
  children: ie
201
223
  }) : ie;
202
224
  }
203
225
  //#endregion
204
226
  //#region src/Route.tsx
205
- function Pe({ element: e }) {
227
+ function ze({ element: e }) {
206
228
  return e;
207
229
  }
208
230
  //#endregion
209
231
  //#region src/utils/buildRoutePath.ts
210
- function Fe(e, t) {
211
- return m(e, t);
232
+ function X(e, t) {
233
+ return h(e, t);
212
234
  }
213
235
  //#endregion
214
236
  //#region src/navigate/useNavigate.ts
215
- function Ie() {
216
- let e = R(), t = S({
237
+ function Z() {
238
+ let e = z(), t = C({
217
239
  stores: e,
218
- buildPathname: (e, t) => Fe(e, t),
240
+ buildPathname: (e, t) => X(e, t),
219
241
  driver: e.driver,
220
242
  markSelfInduced: e.markSelfInduced
221
243
  });
@@ -227,21 +249,21 @@ function Ie() {
227
249
  }
228
250
  //#endregion
229
251
  //#region src/navigate/usePathname.ts
230
- function Le() {
252
+ function Be() {
231
253
  return W((e) => e.histories[e.pendingIndex]?.pathname ?? "/");
232
254
  }
233
255
  //#endregion
234
256
  //#region src/navigate/useStep.ts
235
- function Re() {
236
- let { routePath: e } = V(), t = R(), n = a(H), { driver: r, markSelfInduced: i } = t, [s, c] = f(null);
257
+ function Ve() {
258
+ let { routePath: e } = V(), t = z(), n = a(Te), { driver: r, markSelfInduced: i } = t, [s, c] = p(null);
237
259
  o(() => {
238
- if (!e) return c(P(r.readState())), r.subscribe((e) => c(P(e.state)));
260
+ if (!e) return c(ve(r.readState())), r.subscribe((e) => c(ve(e.state)));
239
261
  }, [e, r]);
240
262
  let l = A({
241
263
  stores: t,
242
264
  driver: r,
243
265
  markSelfInduced: i,
244
- buildStepPathname: (t) => e ? Fe(e, t).pathname : p(r.readPathname(), t),
266
+ buildStepPathname: (t) => e ? X(e, t).pathname : m(r.readPathname(), t),
245
267
  applyParams: (t) => {
246
268
  n({
247
269
  type: "SET",
@@ -258,36 +280,36 @@ function Re() {
258
280
  }
259
281
  //#endregion
260
282
  //#region src/screen/ParamsProvider/useParams.ts
261
- function Z() {
262
- return a(Se);
283
+ function He() {
284
+ return a(we);
263
285
  }
264
286
  //#endregion
265
287
  //#region src/screen/ScreenFreeze.tsx
266
- function Q({ freeze: e, children: n }) {
267
- return /* @__PURE__ */ I(t, {
288
+ function Ue({ freeze: e, children: n }) {
289
+ return /* @__PURE__ */ L(t, {
268
290
  mode: e ? "hidden" : "visible",
269
291
  children: n
270
292
  });
271
293
  }
272
294
  //#endregion
273
295
  //#region src/screen/scopeAnimHoldCoordinator.ts
274
- var ze = /* @__PURE__ */ new WeakMap();
275
- function Be(e) {
276
- let t = ze.get(e);
277
- return t || (t = _(), ze.set(e, t)), t;
296
+ var We = /* @__PURE__ */ new WeakMap();
297
+ function Ge(e) {
298
+ let t = We.get(e);
299
+ return t || (t = v(), We.set(e, t)), t;
278
300
  }
279
301
  //#endregion
280
302
  //#region src/stores/useNavigateStore.ts
281
- function Ve(e) {
282
- return U(R().navigate, e);
303
+ function Q(e) {
304
+ return U(z().navigate, e);
283
305
  }
284
306
  //#endregion
285
307
  //#region src/screen/ScreenDecorator.tsx
286
- function He({ ref: e, style: t, ...n }) {
287
- let { isActive: r, transitionName: i } = V(), a = d(null);
308
+ function Ke({ ref: e, style: t, ...n }) {
309
+ let { isActive: r, transitionName: i } = V(), a = f(null);
288
310
  c(e, () => a.current);
289
- let o = Ve((e) => e.status), { decoratorName: s } = ve(i), l = oe.get(s);
290
- return l ? /* @__PURE__ */ I("div", {
311
+ let o = Q((e) => e.status), { decoratorName: s } = xe(i), l = oe.get(s);
312
+ return l ? /* @__PURE__ */ L("div", {
291
313
  ref: a,
292
314
  "data-flemo-decorator": !0,
293
315
  "data-flemo-decorator-name": l.name,
@@ -308,9 +330,9 @@ function He({ ref: e, style: t, ...n }) {
308
330
  }
309
331
  //#endregion
310
332
  //#region src/screen/useViewportScrollHeight.ts
311
- function Ue() {
312
- let [e, t] = f(0), [n, r] = f(0);
313
- return o(() => he((e, n) => {
333
+ function qe() {
334
+ let [e, t] = p(0), [n, r] = p(0);
335
+ return o(() => _e((e, n) => {
314
336
  r(n), t(e);
315
337
  }), []), {
316
338
  viewportScrollHeight: e,
@@ -320,184 +342,192 @@ function Ue() {
320
342
  //#endregion
321
343
  //#region src/stores/useScreenStore.ts
322
344
  function $(e) {
323
- return U(R().screen, e);
345
+ return U(z().screen, e);
324
346
  }
325
347
  //#endregion
326
348
  //#region src/screen/ScreenMotion.tsx
327
- function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigationBarHeight: r, systemNavigationBarColor: i, sharedTopBar: a, sharedBottomBar: s, topBar: c, bottomBar: l, hideStatusBar: ee, hideSystemNavigationBar: p, backgroundColor: m = "white", contentScrollable: g = !0, ..._ }) {
328
- let { id: v, isActive: y, isRoot: b, isPrev: re, zIndex: x, transitionName: S, prevTransitionName: C } = V(), { contained: w } = Ee(), T = w ? "absolute" : "fixed", E = R(), D = W((e) => e.index), O = W((e) => e.histories), k = y || x === D - 1, A = Ve((e) => k ? e.status : "COMPLETED"), M = $((e) => e.dragStatus), ae = $((e) => e.replaceTransitionStatus), ce = E.screen.getState().setDragStatus, ue = E.screen.getState().setReplaceTransitionStatus, N = y ? O[D - 1]?.id : O[D]?.id, fe = $((e) => N ? e.sharedBars[N] : void 0), pe = $((e) => N ? e.screenSurfaces[N] : void 0), he = d(null);
329
- he.current ||= ie({
349
+ function Je({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigationBarHeight: r, systemNavigationBarColor: i, sharedTopBar: a, sharedBottomBar: s, topBar: c, bottomBar: l, hideStatusBar: d, hideSystemNavigationBar: m, backgroundColor: h = "white", contentScrollable: _ = !0, ...v }) {
350
+ let { id: y, isActive: b, isRoot: x, isPrev: ne, zIndex: S, transitionName: C, prevTransitionName: re } = V(), { contained: w } = Oe(), T = w ? "absolute" : "fixed", E = z(), D = W((e) => e.index), O = W((e) => e.histories), k = b || S === D - 1, A = Q((e) => k ? e.status : "COMPLETED"), M = $((e) => e.dragStatus), ae = $((e) => e.replaceTransitionStatus), ce = E.screen.getState().setDragStatus, le = E.screen.getState().setReplaceTransitionStatus, N = b ? O[D - 1]?.id : O[D]?.id, de = $((e) => N ? e.sharedBars[N] : void 0), pe = $((e) => N ? e.screenSurfaces[N] : void 0), me = f(null);
351
+ me.current ||= ie({
330
352
  getTransitionTaskId: () => E.navigate.getState().transitionTaskId,
331
353
  setDragStatus: ce,
332
- setReplaceTransitionStatus: ue
354
+ setReplaceTransitionStatus: le
333
355
  });
334
- let ge = he.current, P = d(null);
335
- P.current ||= Be(E.navigate);
336
- let F = ve(S), { initial: _e, swipeDirection: ye, decoratorName: be } = F, L = oe.get(be), { viewportScrollHeight: z } = Ue(), B = z > 0, [Se, H] = f(0), [Ce, we] = f(0), Te = d(null), U = d(null), G = d(null), K = d(null), q = d(null), J = d({
337
- transition: F,
338
- decorator: L,
356
+ let he = me.current, _e = f(null);
357
+ _e.current ||= Ge(E.navigate);
358
+ let P = xe(C), { initial: ve, swipeDirection: ye, decoratorName: be } = P, F = oe.get(be), { viewportScrollHeight: I } = qe(), R = I > 0, [Ce, B] = p(0), [we, Te] = p(0), Ee = f(null), H = f(null), De = f(null), U = f(null), G = f(null), K = f({
359
+ transition: P,
360
+ decorator: F,
339
361
  hasSharedTopBar: !!a,
340
362
  hasSharedBottomBar: !!s,
341
- viewportScrollHeight: z,
342
- isRoot: b,
343
- isActive: y,
363
+ viewportScrollHeight: I,
364
+ isRoot: x,
365
+ isActive: b,
344
366
  status: A,
345
367
  dragStatus: M,
346
368
  index: D
347
369
  });
348
- J.current = {
349
- transition: F,
350
- decorator: L,
370
+ K.current = {
371
+ transition: P,
372
+ decorator: F,
351
373
  hasSharedTopBar: !!a,
352
374
  hasSharedBottomBar: !!s,
353
- viewportScrollHeight: z,
354
- isRoot: b,
355
- isActive: y,
375
+ viewportScrollHeight: I,
376
+ isRoot: x,
377
+ isActive: b,
356
378
  status: A,
357
379
  dragStatus: M,
358
380
  index: D
359
381
  };
360
- let De = d(null);
361
- De.current ||= j({
362
- getTransition: () => J.current.transition,
363
- getDecorator: () => J.current.decorator,
382
+ let ke = f(null);
383
+ ke.current ||= j({
384
+ getTransition: () => K.current.transition,
385
+ getDecorator: () => K.current.decorator,
364
386
  getElements: () => ({
365
- scope: U.current,
366
- screenContainer: Te.current,
367
- decorator: G.current,
368
- sharedTopBar: K.current,
369
- sharedBottomBar: q.current
387
+ scope: H.current,
388
+ screenContainer: Ee.current,
389
+ decorator: De.current,
390
+ sharedTopBar: U.current,
391
+ sharedBottomBar: G.current
370
392
  }),
371
- hasSharedTopBar: () => J.current.hasSharedTopBar,
372
- hasSharedBottomBar: () => J.current.hasSharedBottomBar,
373
- getViewportScrollHeight: () => J.current.viewportScrollHeight,
393
+ hasSharedTopBar: () => K.current.hasSharedTopBar,
394
+ hasSharedBottomBar: () => K.current.hasSharedBottomBar,
395
+ getViewportScrollHeight: () => K.current.viewportScrollHeight,
374
396
  isReadyForDrag: () => {
375
- let e = J.current;
397
+ let e = K.current;
376
398
  return !e.isRoot && e.isActive && e.status === "COMPLETED" && e.dragStatus === "IDLE" && !!e.transition.swipeDirection && e.viewportScrollHeight < 10;
377
399
  },
378
400
  getPartnerBars: () => {
379
- let e = J.current, t = E.history.getState().histories, n = e.isActive ? t[e.index - 1]?.id : t[e.index]?.id;
401
+ let e = K.current, t = E.history.getState().histories, n = e.isActive ? t[e.index - 1]?.id : t[e.index]?.id;
380
402
  return n ? E.screen.getState().sharedBars[n] : void 0;
381
403
  },
382
404
  setDragStatus: ce,
383
405
  back: () => window.history.back()
384
406
  });
385
- let Y = De.current, Oe = (e) => Y.pointerDown(e.nativeEvent), ke = (e) => Y.pointerMove(e.nativeEvent), Ae = (e) => Y.pointerUp(e.nativeEvent);
407
+ let q = ke.current, Ae = (e) => q.pointerDown(e.nativeEvent), je = (e) => q.pointerMove(e.nativeEvent), Me = (e) => q.pointerUp(e.nativeEvent);
386
408
  o(() => {
387
- se(U.current);
409
+ se(H.current);
388
410
  }, []), o(() => {
389
- let e = U.current;
411
+ let e = H.current;
390
412
  if (!e) return;
391
413
  let t = (e) => {
392
- Y.shouldPreventTouch() && e.preventDefault(), e.target?.dataset.swipeAtEdgeBar === "true" && e.preventDefault();
414
+ q.shouldPreventTouch() && e.preventDefault(), e.target?.dataset.swipeAtEdgeBar === "true" && e.preventDefault();
393
415
  };
394
416
  return e.addEventListener("touchmove", t, { passive: !1 }), () => {
395
417
  e.removeEventListener("touchmove", t);
396
418
  };
397
- }, [Y]), u(() => {
398
- let e = K.current;
419
+ }, [q]), u(() => {
420
+ let e = U.current;
399
421
  if (!e) {
400
- H(0);
422
+ B(0);
401
423
  return;
402
424
  }
403
- return me(e, H);
425
+ return ge(e, B);
404
426
  }, [a]), u(() => {
405
- let e = q.current;
427
+ let e = G.current;
406
428
  if (!e) {
407
- we(0);
429
+ Te(0);
408
430
  return;
409
431
  }
410
- return me(e, we);
432
+ return ge(e, Te);
411
433
  }, [s]), u(() => {
412
434
  let { registerSharedBars: e, unregisterSharedBars: t } = E.screen.getState();
413
- return e(v, {
435
+ return e(y, {
414
436
  topBar: !!a,
415
437
  bottomBar: !!s
416
- }), () => t(v);
438
+ }), () => t(y);
417
439
  }, [
418
- v,
440
+ y,
419
441
  a,
420
442
  s,
421
443
  E.screen
422
444
  ]), u(() => {
423
- let e = U.current;
445
+ let e = H.current;
424
446
  if (!e) return;
425
447
  let { registerScreenSurface: t, unregisterScreenSurface: n } = E.screen.getState();
426
- return t(v, { opaqueBackground: de(getComputedStyle(e).backgroundColor) }), () => n(v);
448
+ return t(y, { opaqueBackground: fe(getComputedStyle(e).backgroundColor) }), () => n(y);
427
449
  }, [
428
- v,
429
- m,
450
+ y,
451
+ h,
430
452
  A,
431
453
  E.screen
432
454
  ]);
433
- let je = k, { app: Me, nav: Ne } = h({
455
+ let Ne = k, { app: Pe, nav: Fe } = g({
434
456
  status: A,
435
- isTopOrTopPrev: je,
457
+ isTopOrTopPrev: Ne,
436
458
  hasTopBar: !!a,
437
459
  hasNavBar: !!s,
438
- partnerBars: fe
439
- }), X = te({
460
+ partnerBars: de
461
+ }), J = ee({
440
462
  status: A,
441
- isTopOrTopPrev: je,
442
- transitionName: S
443
- }), Pe = ne({
444
- isActive: y,
445
- isPrev: re,
446
- zIndex: x,
463
+ isTopOrTopPrev: Ne,
464
+ transitionName: C
465
+ }), Ie = te({
466
+ isActive: b,
467
+ isPrev: ne,
468
+ zIndex: S,
447
469
  index: D,
448
470
  status: A,
449
471
  dragStatus: M,
450
472
  replaceTransitionStatus: ae
451
- }), Fe = d(Pe), Ie = d(X !== null && Pe), [Le, Re] = f({
452
- key: X,
453
- released: X === null
473
+ }), Le = f(Ie), Re = f(J !== null && Ie), [Y, ze] = p({
474
+ key: J,
475
+ released: J === null
454
476
  });
455
- Le.key !== X && (Re({
456
- key: X,
457
- released: X === null
458
- }), Ie.current = X !== null && Fe.current), Fe.current = Pe;
459
- let Z = X !== null && Le.key === X && !Le.released, Q = Z ? !y && pe?.opaqueBackground ? "park" : y && (A === "PUSHING" || A === "REPLACING") && pe?.opaqueBackground ? "park-under" : "true" : "false";
460
- u(() => ge.driveScreenLifecycle({
477
+ Y.key !== J && (ze({
478
+ key: J,
479
+ released: J === null
480
+ }), Re.current = J !== null && Le.current), Le.current = Ie;
481
+ let X = J !== null && Y.key === J && !Y.released, Z = X ? !b && pe?.opaqueBackground ? "park" : b && (A === "PUSHING" || A === "REPLACING") && pe?.opaqueBackground ? "park-under" : "true" : "false";
482
+ u(() => he.driveScreenLifecycle({
461
483
  getElements: () => ({
462
- scope: U.current,
463
- decorator: G.current,
464
- bars: [K.current, q.current]
484
+ scope: H.current,
485
+ decorator: De.current,
486
+ bars: [U.current, G.current]
465
487
  }),
466
- transitionName: S,
467
- prevTransitionName: C,
488
+ transitionName: C,
489
+ prevTransitionName: re,
468
490
  status: A,
469
- isActive: y,
470
- animHoldReleased: !Z
491
+ isActive: b,
492
+ animHoldReleased: !X
471
493
  }), [
472
- ge,
494
+ he,
473
495
  A,
474
- y,
496
+ b,
497
+ re,
475
498
  C,
476
- S,
477
- Z
499
+ X
478
500
  ]), o(() => {
479
- if (!Z || X === null) return;
480
- let e = X, t = E.navigate.getState().transitionTaskId, n = t === null ? e : `${e}#${t}`;
481
- return P.current.join(n, () => Re((t) => t.key === e && !t.released ? {
501
+ if (!X || J === null) return;
502
+ let e = J, t = E.navigate.getState().transitionTaskId, n = t === null ? e : `${e}#${t}`;
503
+ return _e.current.join(n, () => ze((t) => t.key === e && !t.released ? {
482
504
  key: e,
483
505
  released: !0
484
506
  } : t), {
485
- scope: U.current,
486
- decodeWait: Ie.current
507
+ scope: H.current,
508
+ decodeWait: Re.current,
509
+ contentSettle: b && A === "PUSHING" ? {
510
+ graceMs: 150,
511
+ firstWaitMs: 400,
512
+ capMs: 900,
513
+ minNodes: 30
514
+ } : void 0
487
515
  });
488
516
  }, [
489
- Z,
490
517
  X,
491
- Q,
518
+ J,
519
+ Z,
520
+ b,
521
+ A,
492
522
  E.navigate
493
523
  ]);
494
- let ze = Q === "park-under" ? {} : le({
495
- initial: _e,
496
- isActive: y,
524
+ let Be = Z === "park-under" ? {} : ue({
525
+ initial: ve,
526
+ isActive: b,
497
527
  status: A
498
528
  });
499
- return /* @__PURE__ */ xe("div", {
500
- ref: Te,
529
+ return /* @__PURE__ */ Se("div", {
530
+ ref: Ee,
501
531
  style: {
502
532
  position: T,
503
533
  top: 0,
@@ -505,14 +535,14 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
505
535
  width: "100%",
506
536
  height: "100%",
507
537
  display: "flex",
508
- zIndex: Q === "park-under" ? -1 : void 0,
538
+ zIndex: Z === "park-under" ? -1 : void 0,
509
539
  contain: "layout style",
510
540
  flexDirection: "column",
511
541
  boxSizing: "border-box",
512
542
  overscrollBehavior: "contain"
513
543
  },
514
544
  children: [
515
- /* @__PURE__ */ I("div", {
545
+ /* @__PURE__ */ L("div", {
516
546
  "data-swipe-at-edge-bar": !0,
517
547
  style: {
518
548
  position: T,
@@ -523,32 +553,32 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
523
553
  zIndex: 1
524
554
  }
525
555
  }),
526
- /* @__PURE__ */ xe("div", {
527
- ref: U,
528
- ..._,
529
- onPointerDown: Oe,
530
- onPointerMove: ke,
531
- onPointerUp: Ae,
532
- onPointerCancel: Ae,
556
+ /* @__PURE__ */ Se("div", {
557
+ ref: H,
558
+ ...v,
559
+ onPointerDown: Ae,
560
+ onPointerMove: je,
561
+ onPointerUp: Me,
562
+ onPointerCancel: Me,
533
563
  "data-flemo-screen": !0,
534
- "data-flemo-transition": S,
564
+ "data-flemo-transition": C,
535
565
  "data-flemo-status": A,
536
- "data-flemo-active": y ? "true" : "false",
537
- "data-flemo-anim-hold": Q,
566
+ "data-flemo-active": b ? "true" : "false",
567
+ "data-flemo-anim-hold": Z,
538
568
  style: {
539
569
  display: "flex",
540
570
  flexDirection: "column",
541
571
  height: "100%",
542
- backgroundColor: m,
543
- overflowY: g ? void 0 : "auto",
572
+ backgroundColor: h,
573
+ overflowY: _ ? void 0 : "auto",
544
574
  touchAction: ye === "x" ? "pan-y" : ye === "y" ? "pan-x" : "auto",
545
- ...ze,
546
- ..._.style
575
+ ...Be,
576
+ ...v.style
547
577
  },
548
578
  children: [
549
- !ee && t && /* @__PURE__ */ I("div", {
579
+ !d && t && /* @__PURE__ */ L("div", {
550
580
  style: { minHeight: t },
551
- children: /* @__PURE__ */ I("div", { style: {
581
+ children: /* @__PURE__ */ L("div", { style: {
552
582
  position: T,
553
583
  top: 0,
554
584
  width: "100%",
@@ -556,32 +586,32 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
556
586
  backgroundColor: n
557
587
  } })
558
588
  }),
559
- a && /* @__PURE__ */ I("div", { style: {
589
+ a && /* @__PURE__ */ L("div", { style: {
560
590
  width: "100%",
561
- minHeight: Se
591
+ minHeight: Ce
562
592
  } }),
563
593
  c,
564
- /* @__PURE__ */ I("div", {
594
+ /* @__PURE__ */ L("div", {
565
595
  style: {
566
596
  display: "flex",
567
597
  flexDirection: "column",
568
598
  flexGrow: 1,
569
- overflowY: g ? "auto" : void 0
599
+ overflowY: _ ? "auto" : void 0
570
600
  },
571
601
  children: e
572
602
  }),
573
603
  l,
574
- s && /* @__PURE__ */ I("div", { style: {
575
- display: B ? "none" : void 0,
604
+ s && /* @__PURE__ */ L("div", { style: {
605
+ display: R ? "none" : void 0,
576
606
  width: "100%",
577
- minHeight: Ce
607
+ minHeight: we
578
608
  } }),
579
- !p && r && /* @__PURE__ */ I("div", {
609
+ !m && r && /* @__PURE__ */ L("div", {
580
610
  style: {
581
- display: B ? "none" : void 0,
611
+ display: R ? "none" : void 0,
582
612
  minHeight: r
583
613
  },
584
- children: /* @__PURE__ */ I("div", { style: {
614
+ children: /* @__PURE__ */ L("div", { style: {
585
615
  position: T,
586
616
  bottom: 0,
587
617
  width: "100%",
@@ -591,46 +621,46 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
591
621
  })
592
622
  ]
593
623
  }),
594
- a && /* @__PURE__ */ I("div", {
595
- ref: K,
624
+ a && /* @__PURE__ */ L("div", {
625
+ ref: U,
596
626
  "data-flemo-bar": "app",
597
- "data-flemo-bar-transition": S,
627
+ "data-flemo-bar-transition": C,
598
628
  "data-flemo-bar-status": A,
599
- "data-flemo-bar-active": y ? "true" : "false",
600
- "data-flemo-bar-riding": Me ? "true" : "false",
601
- "data-flemo-anim-hold": Q,
629
+ "data-flemo-bar-active": b ? "true" : "false",
630
+ "data-flemo-bar-riding": Pe ? "true" : "false",
631
+ "data-flemo-anim-hold": Z,
602
632
  style: {
603
633
  position: T,
604
- top: ee ? 0 : t,
634
+ top: d ? 0 : t,
605
635
  left: 0,
606
636
  width: "100%",
607
637
  zIndex: 1
608
638
  },
609
639
  children: a
610
640
  }),
611
- s && /* @__PURE__ */ I("div", {
612
- ref: q,
641
+ s && /* @__PURE__ */ L("div", {
642
+ ref: G,
613
643
  "data-flemo-bar": "nav",
614
- "data-flemo-bar-transition": S,
644
+ "data-flemo-bar-transition": C,
615
645
  "data-flemo-bar-status": A,
616
- "data-flemo-bar-active": y ? "true" : "false",
617
- "data-flemo-bar-riding": Ne ? "true" : "false",
618
- "data-flemo-anim-hold": Q,
646
+ "data-flemo-bar-active": b ? "true" : "false",
647
+ "data-flemo-bar-riding": Fe ? "true" : "false",
648
+ "data-flemo-anim-hold": Z,
619
649
  style: {
620
- display: B ? "none" : void 0,
650
+ display: R ? "none" : void 0,
621
651
  position: T,
622
- bottom: p ? 0 : r,
652
+ bottom: m ? 0 : r,
623
653
  left: 0,
624
654
  width: "100%",
625
655
  zIndex: 1
626
656
  },
627
657
  children: s
628
658
  }),
629
- L && /* @__PURE__ */ I(He, {
630
- ref: G,
631
- "data-flemo-anim-hold": Q
659
+ F && /* @__PURE__ */ L(Ke, {
660
+ ref: De,
661
+ "data-flemo-anim-hold": Z
632
662
  }),
633
- /* @__PURE__ */ I("div", {
663
+ /* @__PURE__ */ L("div", {
634
664
  "data-swipe-at-edge-bar": !0,
635
665
  style: {
636
666
  position: T,
@@ -646,29 +676,38 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
646
676
  }
647
677
  //#endregion
648
678
  //#region src/screen/Screen.tsx
649
- function Ge({ children: e, ...t }) {
650
- let { isActive: n, isPrev: r, zIndex: i } = V();
651
- return /* @__PURE__ */ I(Q, {
652
- freeze: ne({
653
- isActive: n,
654
- isPrev: r,
655
- zIndex: i,
656
- index: W((e) => e.index),
657
- status: Ve((e) => e.status),
658
- dragStatus: $((e) => e.dragStatus),
659
- replaceTransitionStatus: $((e) => e.replaceTransitionStatus)
660
- }),
661
- children: /* @__PURE__ */ I(We, {
679
+ function Ye({ children: e, ...t }) {
680
+ let { isActive: n, isPrev: r, zIndex: i } = V(), a = W((e) => e.index), s = Q((e) => e.status), c = te({
681
+ isActive: n,
682
+ isPrev: r,
683
+ zIndex: i,
684
+ index: a,
685
+ status: s,
686
+ dragStatus: $((e) => e.dragStatus),
687
+ replaceTransitionStatus: $((e) => e.replaceTransitionStatus)
688
+ }), [l, u] = p(c);
689
+ return !c && l && u(!1), o(() => {
690
+ if (!c || l || s !== "COMPLETED") return;
691
+ let e = setTimeout(() => u(!0), Xe);
692
+ return () => clearTimeout(e);
693
+ }, [
694
+ c,
695
+ l,
696
+ s
697
+ ]), /* @__PURE__ */ L(Ue, {
698
+ freeze: l,
699
+ children: /* @__PURE__ */ L(Je, {
662
700
  ...t,
663
701
  children: e
664
702
  })
665
703
  });
666
704
  }
705
+ var Xe = 600;
667
706
  //#endregion
668
707
  //#region src/screen/Part.tsx
669
- function Ke({ ref: e, name: t, style: n, children: r, ...i }) {
670
- let { isActive: a, navigateStore: o } = V(), s = R();
671
- return /* @__PURE__ */ I("div", {
708
+ function Ze({ ref: e, name: t, style: n, children: r, ...i }) {
709
+ let { isActive: a, navigateStore: o } = V(), s = z();
710
+ return /* @__PURE__ */ L("div", {
672
711
  ref: e,
673
712
  "data-flemo-part-name": t,
674
713
  "data-flemo-status": U(o ?? s.navigate, (e) => e.status),
@@ -680,21 +719,21 @@ function Ke({ ref: e, name: t, style: n, children: r, ...i }) {
680
719
  }
681
720
  //#endregion
682
721
  //#region src/stores/RouterScopeProvider.tsx
683
- function qe({ children: e }) {
684
- let [t] = f(() => ({
685
- history: re(),
686
- navigate: x(),
722
+ function Qe({ children: e }) {
723
+ let [t] = p(() => ({
724
+ history: ne(),
725
+ navigate: S(),
687
726
  transition: ae(),
688
727
  screen: k(),
689
- driver: y(),
690
- markSelfInduced: fe,
691
- consume: g,
728
+ driver: b(),
729
+ markSelfInduced: me,
730
+ consume: _,
692
731
  life: { alive: !0 }
693
732
  }));
694
- return /* @__PURE__ */ I(L.Provider, {
733
+ return /* @__PURE__ */ L(R.Provider, {
695
734
  value: t,
696
735
  children: e
697
736
  });
698
737
  }
699
738
  //#endregion
700
- export { Ke as Part, Pe as Route, X as Router, qe as RouterScopeProvider, Ge as Screen, B as ScreenContext, He as ScreenDecorator, Q as ScreenFreeze, We as ScreenMotion, Y as Slot, v as createBrowserHistoryDriver, b as createDecorator, C as createPartTransition, w as createRawDecorator, T as createRawPartTransition, E as createRawTransition, M as createTransition, ge as partTransitionMap, W as useHistoryStore, Ie as useNavigate, Ve as useNavigateStore, Z as useParams, Le as usePathname, V as useScreen, $ as useScreenStore, Re as useStep, R as useStores, Ue as useViewportScrollHeight };
739
+ export { Ze as Part, ze as Route, Y as Router, Qe as RouterScopeProvider, Ye as Screen, B as ScreenContext, Ke as ScreenDecorator, Ue as ScreenFreeze, Je as ScreenMotion, je as Slot, y as createBrowserHistoryDriver, x as createDecorator, re as createPartTransition, w as createRawDecorator, T as createRawPartTransition, E as createRawTransition, M as createTransition, P as partTransitionMap, W as useHistoryStore, Z as useNavigate, Q as useNavigateStore, He as useParams, Be as usePathname, V as useScreen, $ as useScreenStore, Ve as useStep, z as useStores, qe as useViewportScrollHeight };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemo/react",
3
- "version": "1.7.2",
3
+ "version": "1.8.0",
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.4.2",
38
38
  "zustand": "^5.0.14",
39
- "@flemo/core": "1.20.0"
39
+ "@flemo/core": "1.21.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@testing-library/jest-dom": "^6.9.1",
@@ -44,16 +44,16 @@
44
44
  "@types/node": "^24.13.1",
45
45
  "@types/react": "^19.2.17",
46
46
  "@types/react-dom": "^19.2.3",
47
- "@vitejs/plugin-react-swc": "^4.3.1",
48
- "@vitest/coverage-v8": "^4.1.9",
47
+ "@vitejs/plugin-react-swc": "^4.3.2",
48
+ "@vitest/coverage-v8": "^4.1.10",
49
49
  "eslint": "^9.39.4",
50
50
  "jsdom": "^29.1.1",
51
51
  "react": "^19.2.7",
52
52
  "react-dom": "^19.2.7",
53
53
  "typescript": "^6.0.3",
54
- "vite": "^8.0.16",
55
- "vite-plugin-dts": "^5.0.2",
56
- "vitest": "^4.1.9",
54
+ "vite": "^8.1.5",
55
+ "vite-plugin-dts": "^5.0.3",
56
+ "vitest": "^4.1.10",
57
57
  "@flemo/eslint-config": "0.0.0",
58
58
  "@flemo/tsconfig": "0.0.0"
59
59
  },