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