@flemo/react 1.6.6 → 1.6.8

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