@flemo/react 1.7.0 → 1.7.2

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