@flemo/react 1.11.1 → 1.12.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/Router.d.ts +3 -1
- package/dist/RouterScopeContext.d.ts +12 -0
- package/dist/RouterTarget.d.ts +24 -0
- package/dist/__tests__/RouterTarget.test.d.ts +9 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +416 -279
- package/dist/navigate/__tests__/useNavigate.routerTarget.test.d.ts +22 -0
- package/dist/navigate/useNavigate.d.ts +10 -5
- package/dist/utils/devDiagnostics.d.ts +3 -0
- package/package.json +3 -3
package/dist/Router.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CSSProperties, PropsWithChildren } from 'react';
|
|
2
2
|
import { HistoryDriver, PartTransition, Decorator, Transition, TransitionName } from '@flemo/core';
|
|
3
3
|
interface RouterProps {
|
|
4
|
+
name?: string;
|
|
5
|
+
strictRoutes?: boolean;
|
|
4
6
|
initPath?: string;
|
|
5
7
|
defaultTransitionName?: TransitionName;
|
|
6
8
|
transitions?: Transition[];
|
|
@@ -11,5 +13,5 @@ interface RouterProps {
|
|
|
11
13
|
className?: string;
|
|
12
14
|
style?: CSSProperties;
|
|
13
15
|
}
|
|
14
|
-
declare function Router({ children, initPath, defaultTransitionName, transitions, decorators, partTransitions, history, createDriver, className, style }: PropsWithChildren<RouterProps>): import("react").JSX.Element;
|
|
16
|
+
declare function Router({ children, name, strictRoutes, initPath, defaultTransitionName, transitions, decorators, partTransitions, history, createDriver, className, style }: PropsWithChildren<RouterProps>): import("react").JSX.Element;
|
|
15
17
|
export default Router;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FlemoStores } from '@flemo/core';
|
|
2
|
+
import { Path } from 'path-to-regexp';
|
|
3
|
+
export interface RouterScopeNode {
|
|
4
|
+
name?: string;
|
|
5
|
+
stores: FlemoStores;
|
|
6
|
+
routePaths: Path[];
|
|
7
|
+
strictRoutes: boolean;
|
|
8
|
+
parent: RouterScopeNode | null;
|
|
9
|
+
depth: number;
|
|
10
|
+
}
|
|
11
|
+
declare const RouterScopeContext: import('react').Context<RouterScopeNode | null>;
|
|
12
|
+
export default RouterScopeContext;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RouterScopeNode } from './RouterScopeContext';
|
|
2
|
+
export interface RegisterRouter {
|
|
3
|
+
}
|
|
4
|
+
export type RouterScopeKeyword = "current" | "parent" | "root" | "nearest-owner";
|
|
5
|
+
export type RouterName = keyof RegisterRouter extends never ? string & {} : keyof RegisterRouter;
|
|
6
|
+
export type RouterTarget = RouterScopeKeyword | RouterName | {
|
|
7
|
+
name: RouterName;
|
|
8
|
+
} | {
|
|
9
|
+
scope: RouterScopeKeyword;
|
|
10
|
+
};
|
|
11
|
+
export interface ResolveRouterTargetInput {
|
|
12
|
+
from: RouterScopeNode;
|
|
13
|
+
target?: RouterTarget;
|
|
14
|
+
path?: string;
|
|
15
|
+
pathname?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface RouterTargetResolution {
|
|
18
|
+
node: RouterScopeNode | null;
|
|
19
|
+
message: string | null;
|
|
20
|
+
}
|
|
21
|
+
export declare function ownsRoute(node: RouterScopeNode, path: string, pathname?: string): boolean;
|
|
22
|
+
export declare function describeAncestry(from: RouterScopeNode): string;
|
|
23
|
+
export default function resolveRouterTarget({ from, target, path, pathname }: ResolveRouterTargetInput): RouterTargetResolution;
|
|
24
|
+
export declare function findDuplicateNamedAncestor(node: RouterScopeNode): RouterScopeNode | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { default as Router } from './Router';
|
|
2
2
|
export { default as Route, type RegisterRoute } from './Route';
|
|
3
3
|
export { default as Slot, type SlotProps } from './Slot';
|
|
4
|
-
export { default as useNavigate } from './navigate/useNavigate';
|
|
4
|
+
export { default as useNavigate, type UseNavigateOptions } from './navigate/useNavigate';
|
|
5
|
+
export { type RegisterRouter, type RouterName, type RouterScopeKeyword, type RouterTarget } from './RouterTarget';
|
|
6
|
+
export { type RouterScopeNode } from './RouterScopeContext';
|
|
5
7
|
export { default as usePathname } from './navigate/usePathname';
|
|
6
8
|
export { default as useStep } from './navigate/useStep';
|
|
7
9
|
export { default as useScreen } from './screen/useScreen';
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e, { Activity as t, Children as n, createContext as r, isValidElement as i, useCallback as a, useContext as o, useEffect as s, useId as c, useImperativeHandle as l, useInsertionEffect as u, useLayoutEffect as d, useReducer as f, useRef as p, useState as m, useSyncExternalStore as ee } from "react";
|
|
2
|
-
import { animHoldKey as te, appendParamsQuery as ne, buildRoutePath as re, computeBarRiding as ie, computeScreenFreeze as
|
|
2
|
+
import { animHoldKey as te, appendParamsQuery as ne, buildRoutePath as re, computeBarRiding as ie, computeScreenFreeze as ae, computeScreenFreezeMode as oe, consumeSelfInducedPop as se, createAnimHoldCoordinator as h, createBrowserHistoryDriver as g, createBrowserHistoryDriver as _, createDecorator as v, createHistoryStore as y, createNavigateStore as ce, createNavigationController as b, createPartTransition as x, createRawDecorator as le, createRawPartTransition as S, createRawTransition as C, createRouterScope as w, createScreenSelector as T, createScreenStore as E, createStepController as D, createSwipeController as ue, createTransition as O, createTransitionEngine as de, createTransitionStore as k, decoratorMap as fe, detectBlinkEngine as A, eagerlyDecodeImages as pe, ensureGpuPipelinePrewarm as me, ensureImageDecodeOffloader as he, ensureScopeHistorySync as j, enteringInitialStyle as ge, getMatchedPathPattern as _e, governedCompiledActive as ve, holdCompositorWarm as M, isLegacyAndroidBlink as ye, isOpaqueColor as be, isServer as N, markSelfInducedPop as xe, matchesPathname as Se, observeBarHeight as Ce, observeViewportScrollHeight as we, partTransitionMap as Te, readImageOffloadOverride as Ee, readLayerPromotionFlag as De, readPrerasterFlag as Oe, readSettleGateFlag as ke, readStepParams as Ae, registerTransitionDefinitions as je, releaseScopeHistorySync as Me, resolveTransition as Ne, seedRouterEntry as Pe, sharedBarsMatch as Fe, steadySixtyPlayerEligible as Ie, subscribeStepParamsRestore as Le } from "@flemo/core";
|
|
3
3
|
import { jsx as P, jsxs as Re } from "react/jsx-runtime";
|
|
4
4
|
import { flushSync as ze } from "react-dom";
|
|
5
5
|
//#region src/stores/StoreContext.ts
|
|
@@ -15,7 +15,7 @@ function I() {
|
|
|
15
15
|
//#region src/history/HistoryListener.tsx
|
|
16
16
|
function L() {
|
|
17
17
|
let e = I();
|
|
18
|
-
return s(() => (
|
|
18
|
+
return s(() => (j(e), () => Me(e)), [e]), null;
|
|
19
19
|
}
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/screen/ScreenContext.ts
|
|
@@ -39,10 +39,10 @@ function z() {
|
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/screen/ParamsProvider/ParamsContext.ts
|
|
42
|
-
var B = r({}),
|
|
42
|
+
var B = r({}), Be = r(() => {});
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/screen/ParamsProvider/ParamsReducer.ts
|
|
45
|
-
function
|
|
45
|
+
function Ve(e, t) {
|
|
46
46
|
switch (t.type) {
|
|
47
47
|
case "SET": return t.params;
|
|
48
48
|
default: return e;
|
|
@@ -50,8 +50,8 @@ function Be(e, t) {
|
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/screen/ParamsProvider/ParamsProvider.tsx
|
|
53
|
-
function
|
|
54
|
-
let { isActive: t, params: n } = z(), { driver: r } = I(), [i, a] = f(
|
|
53
|
+
function He({ children: e }) {
|
|
54
|
+
let { isActive: t, params: n } = z(), { driver: r } = I(), [i, a] = f(Ve, n);
|
|
55
55
|
return s(() => {
|
|
56
56
|
if (t) return Le(r, (e) => a({
|
|
57
57
|
type: "SET",
|
|
@@ -61,7 +61,7 @@ function Ve({ children: e }) {
|
|
|
61
61
|
t,
|
|
62
62
|
a,
|
|
63
63
|
r
|
|
64
|
-
]), /* @__PURE__ */ P(
|
|
64
|
+
]), /* @__PURE__ */ P(Be.Provider, {
|
|
65
65
|
value: a,
|
|
66
66
|
children: /* @__PURE__ */ P(B.Provider, {
|
|
67
67
|
value: i,
|
|
@@ -71,24 +71,24 @@ function Ve({ children: e }) {
|
|
|
71
71
|
}
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region ../../node_modules/.pnpm/zustand@5.0.14_@types+react@19.2.18_react@19.2.8/node_modules/zustand/esm/react.mjs
|
|
74
|
-
var
|
|
75
|
-
function
|
|
74
|
+
var Ue = (e) => e;
|
|
75
|
+
function V(t, n = Ue) {
|
|
76
76
|
let r = e.useSyncExternalStore(t.subscribe, e.useCallback(() => n(t.getState()), [t, n]), e.useCallback(() => n(t.getInitialState()), [t, n]));
|
|
77
77
|
return e.useDebugValue(r), r;
|
|
78
78
|
}
|
|
79
79
|
//#endregion
|
|
80
80
|
//#region src/stores/useHistoryStore.ts
|
|
81
|
-
function
|
|
82
|
-
return
|
|
81
|
+
function H(e) {
|
|
82
|
+
return V(I().history, e);
|
|
83
83
|
}
|
|
84
84
|
//#endregion
|
|
85
85
|
//#region src/RouterIdContext.ts
|
|
86
|
-
var
|
|
86
|
+
var We = r(null);
|
|
87
87
|
//#endregion
|
|
88
88
|
//#region src/renderer/Renderer.tsx
|
|
89
|
-
function
|
|
90
|
-
let t =
|
|
91
|
-
return
|
|
89
|
+
function Ge({ children: e }) {
|
|
90
|
+
let t = H((e) => e.index), r = H((e) => e.histories), i = I(), a = o(R), s = o(We);
|
|
91
|
+
return T(r, t).map((t) => {
|
|
92
92
|
let [r] = n.toArray(e).filter((e) => Se(e.props.path, t.pathname));
|
|
93
93
|
return r ? /* @__PURE__ */ P(R.Provider, {
|
|
94
94
|
value: {
|
|
@@ -98,19 +98,19 @@ function We({ children: e }) {
|
|
|
98
98
|
routerId: s ?? void 0,
|
|
99
99
|
routePath: _e(r.props.path, t.pathname)
|
|
100
100
|
},
|
|
101
|
-
children: /* @__PURE__ */ P(
|
|
101
|
+
children: /* @__PURE__ */ P(He, { children: r })
|
|
102
102
|
}, t.id) : null;
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/screen/ScreenViewportContext.ts
|
|
107
|
-
var
|
|
108
|
-
function
|
|
109
|
-
return o(
|
|
107
|
+
var Ke = r({ contained: !1 });
|
|
108
|
+
function qe() {
|
|
109
|
+
return o(Ke);
|
|
110
110
|
}
|
|
111
111
|
//#endregion
|
|
112
112
|
//#region src/transition/styles.ts
|
|
113
|
-
function
|
|
113
|
+
function Je(e, t, n = []) {
|
|
114
114
|
u(() => je(e, t, n), [
|
|
115
115
|
e,
|
|
116
116
|
t,
|
|
@@ -118,9 +118,97 @@ function qe(e, t, n = []) {
|
|
|
118
118
|
]);
|
|
119
119
|
}
|
|
120
120
|
//#endregion
|
|
121
|
+
//#region src/utils/devDiagnostics.ts
|
|
122
|
+
function Ye() {
|
|
123
|
+
return typeof process < "u" && process.env.NODE_ENV !== "production";
|
|
124
|
+
}
|
|
125
|
+
function Xe(e) {
|
|
126
|
+
!Ye() || typeof console > "u" || console.error(`[flemo] ${e}`);
|
|
127
|
+
}
|
|
128
|
+
function Ze(e) {
|
|
129
|
+
if (Ye()) throw Error(`[flemo] ${e}`);
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
121
132
|
//#region src/RouterDepthContext.ts
|
|
122
|
-
var
|
|
123
|
-
|
|
133
|
+
var Qe = r(0), U = r(null), W = [
|
|
134
|
+
"current",
|
|
135
|
+
"parent",
|
|
136
|
+
"root",
|
|
137
|
+
"nearest-owner"
|
|
138
|
+
], $e = (e) => W.includes(e), G = (e) => {
|
|
139
|
+
let t = [];
|
|
140
|
+
for (let n = e; n; n = n.parent) t.push(n);
|
|
141
|
+
return t;
|
|
142
|
+
};
|
|
143
|
+
function et(e, t, n) {
|
|
144
|
+
return e.routePaths.length === 0 || e.routePaths.some((e) => e === t) ? !0 : n ? Se(e.routePaths, n) : !1;
|
|
145
|
+
}
|
|
146
|
+
function K(e) {
|
|
147
|
+
return G(e).map((e, t) => {
|
|
148
|
+
let n = t === 0 ? "current" : `${t} level(s) up`;
|
|
149
|
+
return e.name ? `"${e.name}" (${n})` : `<unnamed> (${n})`;
|
|
150
|
+
}).join(", ");
|
|
151
|
+
}
|
|
152
|
+
function q({ from: e, target: t, path: n, pathname: r }) {
|
|
153
|
+
if (t === void 0) return {
|
|
154
|
+
node: e,
|
|
155
|
+
message: null
|
|
156
|
+
};
|
|
157
|
+
let i = null, a = null;
|
|
158
|
+
if (typeof t == "string" ? $e(t) ? i = t : a = t : "scope" in t ? i = t.scope : a = t.name, a !== null) {
|
|
159
|
+
let t = G(e).find((e) => e.name === a);
|
|
160
|
+
return t ? {
|
|
161
|
+
node: t,
|
|
162
|
+
message: null
|
|
163
|
+
} : {
|
|
164
|
+
node: null,
|
|
165
|
+
message: `no <Router name="${a}"> encloses this call. Routers in scope: ${K(e)}.`
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
switch (i) {
|
|
169
|
+
case "parent": return e.parent ? {
|
|
170
|
+
node: e.parent,
|
|
171
|
+
message: null
|
|
172
|
+
} : {
|
|
173
|
+
node: null,
|
|
174
|
+
message: "router: \"parent\" was requested, but the enclosing <Router> is the outermost one (it has no parent Router)."
|
|
175
|
+
};
|
|
176
|
+
case "root": {
|
|
177
|
+
let t = G(e);
|
|
178
|
+
return {
|
|
179
|
+
node: t[t.length - 1],
|
|
180
|
+
message: null
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
case "nearest-owner": {
|
|
184
|
+
if (!n) return {
|
|
185
|
+
node: e,
|
|
186
|
+
message: "router: \"nearest-owner\" needs a route to search for, and pop() carries none. Falling back to \"current\" — name the Router explicitly for a cross-Router pop."
|
|
187
|
+
};
|
|
188
|
+
let t = G(e).find((e) => et(e, n, r));
|
|
189
|
+
return t ? {
|
|
190
|
+
node: t,
|
|
191
|
+
message: null
|
|
192
|
+
} : {
|
|
193
|
+
node: null,
|
|
194
|
+
message: `no <Router> in scope declares a <Route path="${n}">. Routers in scope: ${K(e)}.`
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
default: return {
|
|
198
|
+
node: e,
|
|
199
|
+
message: null
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function tt(e) {
|
|
204
|
+
if (!e.name) return null;
|
|
205
|
+
for (let t = e.parent; t; t = t.parent) if (t.name === e.name) return t;
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/Slot.tsx
|
|
210
|
+
var nt = { contained: !0 };
|
|
211
|
+
function rt({ children: e, className: t, style: n }) {
|
|
124
212
|
return /* @__PURE__ */ P("div", {
|
|
125
213
|
className: t,
|
|
126
214
|
style: {
|
|
@@ -128,63 +216,75 @@ function Xe({ children: e, className: t, style: n }) {
|
|
|
128
216
|
overflow: "hidden",
|
|
129
217
|
...n
|
|
130
218
|
},
|
|
131
|
-
children: /* @__PURE__ */ P(
|
|
132
|
-
value:
|
|
133
|
-
children: /* @__PURE__ */ P(
|
|
219
|
+
children: /* @__PURE__ */ P(Ke.Provider, {
|
|
220
|
+
value: nt,
|
|
221
|
+
children: /* @__PURE__ */ P(Ge, { children: e })
|
|
134
222
|
})
|
|
135
223
|
});
|
|
136
224
|
}
|
|
137
225
|
//#endregion
|
|
138
226
|
//#region src/Router.tsx
|
|
139
|
-
function
|
|
227
|
+
function it(e) {
|
|
140
228
|
let t = null;
|
|
141
229
|
return n.forEach(e, (e) => {
|
|
142
230
|
if (t || !i(e)) return;
|
|
143
|
-
if (e.type ===
|
|
231
|
+
if (e.type === rt) {
|
|
144
232
|
t = n.toArray(e.props.children).filter(i);
|
|
145
233
|
return;
|
|
146
234
|
}
|
|
147
235
|
let r = e.props.children;
|
|
148
236
|
if (r) {
|
|
149
|
-
let e =
|
|
237
|
+
let e = it(r);
|
|
150
238
|
e && (t = e);
|
|
151
239
|
}
|
|
152
240
|
}), t;
|
|
153
241
|
}
|
|
154
|
-
var
|
|
155
|
-
function
|
|
156
|
-
let
|
|
157
|
-
s(() =>
|
|
158
|
-
let
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
242
|
+
var J = typeof window > "u" ? s : d, at = typeof window > "u" ? s : u, Y = [], ot = [], st = [], ct = { contained: !0 }, lt = 500, ut = 3e3;
|
|
243
|
+
function dt({ children: e, name: t, strictRoutes: r = !1, initPath: a = "/", defaultTransitionName: l = "cupertino", transitions: u = Y, decorators: d = ot, partTransitions: f = st, history: p = "browser", createDriver: ee, className: te, style: ne }) {
|
|
244
|
+
let re = o(Qe), ie = c(), [ae, oe] = m(!1);
|
|
245
|
+
s(() => oe(!0), []);
|
|
246
|
+
let se = ae ? ie : null, h = re > 0, g = p === "memory", v = c(), y = o(R), ce = o(F), b = h && y.id ? `_F_${ce?.routerKey ?? ""}${y.id}_` : v, x = it(e), le = x !== null, S = (x ?? n.toArray(e).filter(i)).flatMap((e) => e.props?.path ? [e.props.path].flat() : []), C = h ? null : ce, T = C !== null, E = ee ?? _, [D] = m(() => g ? null : E(T ? void 0 : b)), ue = !h && !g && !N(), O = ue && D ? D.readPathname() : a || "/", de = O.indexOf("?"), k = (de >= 0 ? O.slice(0, de) : O) || "/", fe = ue ? window.location.search : de >= 0 ? O.slice(de) : "", [A] = m(() => w({
|
|
247
|
+
routePaths: S,
|
|
248
|
+
pathname: k,
|
|
249
|
+
search: fe,
|
|
250
|
+
defaultTransitionName: l,
|
|
251
|
+
memory: g,
|
|
252
|
+
browserDriver: D,
|
|
253
|
+
hostedScope: C,
|
|
254
|
+
routerKey: T ? void 0 : b,
|
|
255
|
+
zoneEntryId: h && !T && y.id || void 0,
|
|
256
|
+
persistKey: h && !g && !T ? b : void 0
|
|
257
|
+
}));
|
|
258
|
+
J(() => {
|
|
259
|
+
A.transition.getState().defaultTransitionName !== l && A.transition.setState({ defaultTransitionName: l });
|
|
172
260
|
});
|
|
173
|
-
|
|
261
|
+
let pe = o(U), [j] = m(() => ({
|
|
262
|
+
name: t,
|
|
263
|
+
stores: A,
|
|
264
|
+
routePaths: S,
|
|
265
|
+
strictRoutes: r,
|
|
266
|
+
parent: pe,
|
|
267
|
+
depth: re
|
|
268
|
+
}));
|
|
269
|
+
at(() => {
|
|
270
|
+
j.name = t, j.stores = A, j.routePaths = S, j.strictRoutes = r, j.parent = pe;
|
|
271
|
+
}), s(() => {
|
|
272
|
+
tt(j) && Xe(`duplicate <Router name="${j.name}">: an enclosing <Router> already uses that name, so \`router\` targets resolve to the nearer one. Give each nested Router a unique name.`);
|
|
273
|
+
}, [j, t]), J(() => (A.life.alive = !0, () => {
|
|
174
274
|
A.life.alive = !1;
|
|
175
|
-
}), [A]),
|
|
275
|
+
}), [A]), Je(u, d, f), s(() => {
|
|
176
276
|
let e = Ee();
|
|
177
|
-
if (e !== "off") return e === "on" || ye() ?
|
|
178
|
-
}, []), s(() =>
|
|
277
|
+
if (e !== "off") return e === "on" || ye() ? he() : void 0;
|
|
278
|
+
}, []), s(() => me(), []), s(() => {
|
|
179
279
|
if (typeof document > "u") return;
|
|
180
280
|
let e = null, t = null, n = 0, r = () => {
|
|
181
281
|
let r = Date.now();
|
|
182
|
-
if (r - n <
|
|
282
|
+
if (r - n < lt) return;
|
|
183
283
|
n = r, t && clearTimeout(t);
|
|
184
284
|
let i = e;
|
|
185
285
|
e = M(), i?.(), t = setTimeout(() => {
|
|
186
286
|
t = null, e?.(), e = null;
|
|
187
|
-
},
|
|
287
|
+
}, ut);
|
|
188
288
|
}, i = [
|
|
189
289
|
"pointerdown",
|
|
190
290
|
"pointermove",
|
|
@@ -198,89 +298,126 @@ function nt({ children: e, initPath: t = "/", defaultTransitionName: r = "cupert
|
|
|
198
298
|
t && clearTimeout(t), e?.();
|
|
199
299
|
};
|
|
200
300
|
}, []), s(() => {
|
|
201
|
-
g || !
|
|
202
|
-
driver:
|
|
203
|
-
routerKey:
|
|
204
|
-
nested: h && !
|
|
301
|
+
g || !D || Pe({
|
|
302
|
+
driver: D,
|
|
303
|
+
routerKey: T ? null : b,
|
|
304
|
+
nested: h && !T,
|
|
205
305
|
seedPathname: k,
|
|
206
|
-
defaultTransitionName:
|
|
306
|
+
defaultTransitionName: l,
|
|
207
307
|
rootParams: A.history.getState().histories[0]?.params ?? {}
|
|
208
308
|
});
|
|
209
309
|
}, [
|
|
210
310
|
g,
|
|
211
|
-
|
|
311
|
+
T,
|
|
212
312
|
h,
|
|
213
313
|
b,
|
|
214
314
|
k,
|
|
215
|
-
|
|
315
|
+
l,
|
|
216
316
|
A.history,
|
|
217
|
-
|
|
317
|
+
D
|
|
218
318
|
]);
|
|
219
|
-
let
|
|
220
|
-
value:
|
|
221
|
-
children: /* @__PURE__ */ P(
|
|
222
|
-
value:
|
|
223
|
-
children: /* @__PURE__ */
|
|
224
|
-
value:
|
|
225
|
-
children:
|
|
226
|
-
value:
|
|
227
|
-
children:
|
|
228
|
-
|
|
319
|
+
let ge = le ? e : /* @__PURE__ */ P(Ge, { children: e }), _e = /* @__PURE__ */ P(We.Provider, {
|
|
320
|
+
value: se,
|
|
321
|
+
children: /* @__PURE__ */ P(Qe.Provider, {
|
|
322
|
+
value: re + 1,
|
|
323
|
+
children: /* @__PURE__ */ P(U.Provider, {
|
|
324
|
+
value: j,
|
|
325
|
+
children: /* @__PURE__ */ Re(F.Provider, {
|
|
326
|
+
value: A,
|
|
327
|
+
children: [!g && /* @__PURE__ */ P(L, {}), h ? /* @__PURE__ */ P(Ke.Provider, {
|
|
328
|
+
value: ct,
|
|
329
|
+
children: ge
|
|
330
|
+
}) : ge]
|
|
331
|
+
})
|
|
229
332
|
})
|
|
230
333
|
})
|
|
231
334
|
});
|
|
232
335
|
return h ? /* @__PURE__ */ P("div", {
|
|
233
|
-
className:
|
|
336
|
+
className: te,
|
|
234
337
|
style: {
|
|
235
338
|
position: "relative",
|
|
236
339
|
overflow: "hidden",
|
|
237
|
-
...
|
|
340
|
+
...ne
|
|
238
341
|
},
|
|
239
|
-
children:
|
|
240
|
-
}) :
|
|
342
|
+
children: _e
|
|
343
|
+
}) : _e;
|
|
241
344
|
}
|
|
242
345
|
//#endregion
|
|
243
346
|
//#region src/Route.tsx
|
|
244
|
-
function
|
|
347
|
+
function ft({ element: e }) {
|
|
245
348
|
return e;
|
|
246
349
|
}
|
|
247
350
|
//#endregion
|
|
248
351
|
//#region src/utils/buildRoutePath.ts
|
|
249
|
-
function
|
|
352
|
+
function pt(e, t) {
|
|
250
353
|
return re(e, t);
|
|
251
354
|
}
|
|
252
355
|
//#endregion
|
|
253
356
|
//#region src/navigate/useNavigate.ts
|
|
254
|
-
function
|
|
255
|
-
let
|
|
256
|
-
stores:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
357
|
+
function X(e) {
|
|
358
|
+
let t = I(), n = o(U) ?? {
|
|
359
|
+
stores: t,
|
|
360
|
+
routePaths: [],
|
|
361
|
+
strictRoutes: !1,
|
|
362
|
+
parent: null,
|
|
363
|
+
depth: 0
|
|
364
|
+
}, r = (t, r, i) => {
|
|
365
|
+
let a = t ?? e?.router, o;
|
|
366
|
+
if (r) try {
|
|
367
|
+
o = pt(r, i).toPathname;
|
|
368
|
+
} catch {
|
|
369
|
+
o = void 0;
|
|
370
|
+
}
|
|
371
|
+
let { node: s, message: c } = q({
|
|
372
|
+
from: n,
|
|
373
|
+
target: a,
|
|
374
|
+
path: r,
|
|
375
|
+
pathname: o
|
|
376
|
+
});
|
|
377
|
+
if (!s) return Ze(c ?? "the requested Router could not be resolved."), null;
|
|
378
|
+
if (c && Xe(c), r && !et(s, r, o)) {
|
|
379
|
+
let e = `"${r}" is not declared by ${s.name ? `<Router name="${s.name}">` : "the target <Router>"}, so the navigation cannot mount a screen there. Declare a matching <Route>, target the Router that owns it, or use \`router: "nearest-owner"\`.`;
|
|
380
|
+
a !== void 0 || s.strictRoutes ? Ze(e) : Xe(e);
|
|
381
|
+
}
|
|
382
|
+
return b({
|
|
383
|
+
stores: s.stores,
|
|
384
|
+
buildPathname: (e, t) => pt(e, t),
|
|
385
|
+
driver: s.stores.driver,
|
|
386
|
+
markSelfInduced: s.stores.markSelfInduced
|
|
387
|
+
});
|
|
388
|
+
};
|
|
261
389
|
return {
|
|
262
|
-
push: (e,
|
|
263
|
-
|
|
264
|
-
|
|
390
|
+
push: (e, t, n) => {
|
|
391
|
+
let i = r(n?.router, e, t ?? {});
|
|
392
|
+
return i ? i.push(e, t ?? {}, n) : Promise.resolve();
|
|
393
|
+
},
|
|
394
|
+
replace: (e, t, n) => {
|
|
395
|
+
let i = r(n?.router, e, t ?? {});
|
|
396
|
+
return i ? i.replace(e, t ?? {}, n) : Promise.resolve();
|
|
397
|
+
},
|
|
398
|
+
pop: (e) => {
|
|
399
|
+
let t = r(e?.router);
|
|
400
|
+
return t ? t.pop(e) : Promise.resolve();
|
|
401
|
+
}
|
|
265
402
|
};
|
|
266
403
|
}
|
|
267
404
|
//#endregion
|
|
268
405
|
//#region src/navigate/usePathname.ts
|
|
269
|
-
function
|
|
270
|
-
return
|
|
406
|
+
function mt() {
|
|
407
|
+
return H((e) => e.histories[e.pendingIndex]?.pathname ?? "/");
|
|
271
408
|
}
|
|
272
409
|
//#endregion
|
|
273
410
|
//#region src/navigate/useStep.ts
|
|
274
|
-
function
|
|
275
|
-
let { routePath: e } = z(), t = I(), n = o(
|
|
411
|
+
function ht() {
|
|
412
|
+
let { routePath: e } = z(), t = I(), n = o(Be), { driver: r, markSelfInduced: i } = t, [a, c] = m(null);
|
|
276
413
|
s(() => {
|
|
277
414
|
if (!e) return c(Ae(r.readState())), r.subscribe((e) => c(Ae(e.state)));
|
|
278
415
|
}, [e, r]);
|
|
279
|
-
let l =
|
|
416
|
+
let l = D({
|
|
280
417
|
stores: t,
|
|
281
418
|
driver: r,
|
|
282
419
|
markSelfInduced: i,
|
|
283
|
-
buildStepPathname: (t) => e ?
|
|
420
|
+
buildStepPathname: (t) => e ? pt(e, t).pathname : ne(r.readPathname(), t),
|
|
284
421
|
applyParams: (t) => {
|
|
285
422
|
n({
|
|
286
423
|
type: "SET",
|
|
@@ -297,13 +434,13 @@ function at() {
|
|
|
297
434
|
}
|
|
298
435
|
//#endregion
|
|
299
436
|
//#region src/screen/ParamsProvider/useParams.ts
|
|
300
|
-
function
|
|
437
|
+
function gt() {
|
|
301
438
|
return o(B);
|
|
302
439
|
}
|
|
303
440
|
//#endregion
|
|
304
441
|
//#region src/screen/ScreenFreeze.tsx
|
|
305
|
-
var
|
|
306
|
-
function
|
|
442
|
+
var _t = 3e3;
|
|
443
|
+
function vt({ freeze: e, children: n }) {
|
|
307
444
|
let [r, i] = m(e), a = p(null);
|
|
308
445
|
return !e && r && i(!1), s(() => {
|
|
309
446
|
if (!(!e || r)) {
|
|
@@ -313,7 +450,7 @@ function st({ freeze: e, children: n }) {
|
|
|
313
450
|
}
|
|
314
451
|
return a.current = setTimeout(() => {
|
|
315
452
|
a.current = null, i(!0);
|
|
316
|
-
},
|
|
453
|
+
}, _t), () => {
|
|
317
454
|
a.current !== null && (clearTimeout(a.current), a.current = null);
|
|
318
455
|
};
|
|
319
456
|
}
|
|
@@ -324,22 +461,22 @@ function st({ freeze: e, children: n }) {
|
|
|
324
461
|
}
|
|
325
462
|
//#endregion
|
|
326
463
|
//#region src/screen/scopeAnimHoldCoordinator.ts
|
|
327
|
-
var
|
|
328
|
-
function
|
|
329
|
-
let t =
|
|
330
|
-
return t || (t =
|
|
464
|
+
var Z = /* @__PURE__ */ new WeakMap();
|
|
465
|
+
function yt(e) {
|
|
466
|
+
let t = Z.get(e);
|
|
467
|
+
return t || (t = h(), Z.set(e, t)), t;
|
|
331
468
|
}
|
|
332
469
|
//#endregion
|
|
333
470
|
//#region src/stores/useNavigateStore.ts
|
|
334
|
-
function
|
|
335
|
-
return
|
|
471
|
+
function bt(e) {
|
|
472
|
+
return V(I().navigate, e);
|
|
336
473
|
}
|
|
337
474
|
//#endregion
|
|
338
475
|
//#region src/screen/ScreenDecorator.tsx
|
|
339
|
-
function
|
|
476
|
+
function xt({ ref: e, style: t, ...n }) {
|
|
340
477
|
let { isActive: r, isPrev: i, transitionName: a } = z(), o = p(null);
|
|
341
478
|
l(e, () => o.current);
|
|
342
|
-
let s =
|
|
479
|
+
let s = bt((e) => i ? "COMPLETED" : e.status), { decoratorName: c } = Ne(a), u = fe.get(c);
|
|
343
480
|
return u ? /* @__PURE__ */ P("div", {
|
|
344
481
|
ref: o,
|
|
345
482
|
"data-flemo-decorator": !0,
|
|
@@ -361,7 +498,7 @@ function dt({ ref: e, style: t, ...n }) {
|
|
|
361
498
|
}
|
|
362
499
|
//#endregion
|
|
363
500
|
//#region src/screen/useViewportScrollHeight.ts
|
|
364
|
-
function
|
|
501
|
+
function St() {
|
|
365
502
|
let [e, t] = m(0), [n, r] = m(0);
|
|
366
503
|
return s(() => we((e, n) => {
|
|
367
504
|
r(n), t(e);
|
|
@@ -372,61 +509,61 @@ function ft() {
|
|
|
372
509
|
}
|
|
373
510
|
//#endregion
|
|
374
511
|
//#region src/utils/useHydrationSafeFlag.ts
|
|
375
|
-
var
|
|
376
|
-
function
|
|
377
|
-
return ee(
|
|
512
|
+
var Q = () => () => {}, Ct = () => !1;
|
|
513
|
+
function wt(e) {
|
|
514
|
+
return ee(Q, e, Ct);
|
|
378
515
|
}
|
|
379
516
|
//#endregion
|
|
380
517
|
//#region src/stores/useScreenStore.ts
|
|
381
|
-
function
|
|
382
|
-
return
|
|
518
|
+
function $(e) {
|
|
519
|
+
return V(I().screen, e);
|
|
383
520
|
}
|
|
384
521
|
//#endregion
|
|
385
522
|
//#region src/screen/ScreenMotion.tsx
|
|
386
|
-
function
|
|
387
|
-
let { id:
|
|
388
|
-
Se.current ||=
|
|
389
|
-
getTransitionTaskId: () =>
|
|
390
|
-
setDragStatus:
|
|
523
|
+
function Tt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigationBarHeight: r, systemNavigationBarColor: i, sharedTopBar: c, sharedTopBarId: l, sharedBottomBar: u, sharedBottomBarId: f, topBar: ee, bottomBar: ne, hideStatusBar: re, hideSystemNavigationBar: oe, backgroundColor: se = "white", contentScrollable: h = !0, ...g }) {
|
|
524
|
+
let { id: _, isActive: v, isRoot: y, isPrev: ce, zIndex: b, transitionName: x, prevTransitionName: le } = z(), { contained: S } = qe(), C = S ? "absolute" : "fixed", w = I(), T = o(We), E = H((e) => e.index), D = H((e) => e.histories), O = v || b === E - 1, k = bt((e) => O ? e.status : "COMPLETED"), me = $((e) => e.dragStatus), he = $((e) => e.replaceTransitionStatus), j = w.screen.getState().setDragStatus, _e = w.screen.getState().setReplaceTransitionStatus, M = v ? D[E - 1]?.id : D[E]?.id, ye = $((e) => M ? e.sharedBars[M] : void 0), N = $((e) => M ? e.sharedBarMetadata[M] : void 0), xe = $((e) => M ? e.screenSurfaces[M] : void 0), Se = p(null);
|
|
525
|
+
Se.current ||= de({
|
|
526
|
+
getTransitionTaskId: () => w.navigate.getState().transitionTaskId,
|
|
527
|
+
setDragStatus: j,
|
|
391
528
|
setReplaceTransitionStatus: _e
|
|
392
529
|
});
|
|
393
530
|
let we = Se.current, Te = p(null);
|
|
394
|
-
Te.current ||=
|
|
395
|
-
let Ee = Ne(
|
|
531
|
+
Te.current ||= yt(w.navigate);
|
|
532
|
+
let Ee = Ne(x), { initial: Ae, swipeDirection: je, decoratorName: Me } = Ee, Pe = fe.get(Me), { viewportScrollHeight: Ie } = St(), Le = Ie > 0, F = !!c, L = !!u, R = F ? `${typeof l}:${String(l)}` : null, B = L ? `${typeof f}:${String(f)}` : null, [Be, Ve] = m({
|
|
396
533
|
key: R,
|
|
397
534
|
height: 0
|
|
398
|
-
}), [
|
|
535
|
+
}), [He, Ue] = m({
|
|
399
536
|
key: B,
|
|
400
537
|
height: 0
|
|
401
|
-
}),
|
|
402
|
-
e <= 0 || R === null || (
|
|
538
|
+
}), V = p(Be), Ge = p(He), Ke = Be.key === R ? Be.height : 0, Je = He.key === B ? He.height : 0, Ye = Fe(F ? { id: l } : void 0, N?.topBar) ? N?.topBar?.height ?? 0 : 0, Xe = Fe(L ? { id: f } : void 0, N?.bottomBar) ? N?.bottomBar?.height ?? 0 : 0, Ze = Ke || Ye, Qe = Je || Xe, U = p(null), W = p(null), $e = p(null), G = p(null), et = p(null), K = p(null), q = p(null), tt = a((e) => {
|
|
539
|
+
e <= 0 || R === null || (G.current && (G.current.style.minHeight = `${e}px`), V.current = {
|
|
403
540
|
key: R,
|
|
404
541
|
height: e
|
|
405
|
-
},
|
|
542
|
+
}, Ve((t) => t.key === R && t.height === e ? t : {
|
|
406
543
|
key: R,
|
|
407
544
|
height: e
|
|
408
|
-
}),
|
|
545
|
+
}), w.screen.getState().updateSharedBarHeight(_, "topBar", e));
|
|
409
546
|
}, [
|
|
410
|
-
|
|
411
|
-
|
|
547
|
+
_,
|
|
548
|
+
w.screen,
|
|
412
549
|
R
|
|
413
|
-
]),
|
|
414
|
-
e <= 0 || B === null || (
|
|
550
|
+
]), nt = a((e) => {
|
|
551
|
+
e <= 0 || B === null || (et.current && (et.current.style.minHeight = `${e}px`), Ge.current = {
|
|
415
552
|
key: B,
|
|
416
553
|
height: e
|
|
417
|
-
},
|
|
554
|
+
}, Ue((t) => t.key === B && t.height === e ? t : {
|
|
418
555
|
key: B,
|
|
419
556
|
height: e
|
|
420
|
-
}),
|
|
557
|
+
}), w.screen.getState().updateSharedBarHeight(_, "bottomBar", e));
|
|
421
558
|
}, [
|
|
422
559
|
B,
|
|
423
|
-
|
|
424
|
-
|
|
560
|
+
_,
|
|
561
|
+
w.screen
|
|
425
562
|
]), rt = a((e) => {
|
|
426
|
-
|
|
427
|
-
}, [
|
|
428
|
-
|
|
429
|
-
}, [
|
|
563
|
+
K.current = e, e?.offsetHeight && tt(e.offsetHeight);
|
|
564
|
+
}, [tt]), it = a((e) => {
|
|
565
|
+
q.current = e, e?.offsetHeight && nt(e.offsetHeight);
|
|
566
|
+
}, [nt]), J = p({
|
|
430
567
|
transition: Ee,
|
|
431
568
|
decorator: Pe,
|
|
432
569
|
hasSharedTopBar: !!c,
|
|
@@ -434,11 +571,11 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
434
571
|
sharedTopBarId: l,
|
|
435
572
|
sharedBottomBarId: f,
|
|
436
573
|
viewportScrollHeight: Ie,
|
|
437
|
-
isRoot:
|
|
438
|
-
isActive:
|
|
439
|
-
status:
|
|
440
|
-
dragStatus:
|
|
441
|
-
index:
|
|
574
|
+
isRoot: y,
|
|
575
|
+
isActive: v,
|
|
576
|
+
status: k,
|
|
577
|
+
dragStatus: me,
|
|
578
|
+
index: E
|
|
442
579
|
});
|
|
443
580
|
J.current = {
|
|
444
581
|
transition: Ee,
|
|
@@ -448,22 +585,22 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
448
585
|
sharedTopBarId: l,
|
|
449
586
|
sharedBottomBarId: f,
|
|
450
587
|
viewportScrollHeight: Ie,
|
|
451
|
-
isRoot:
|
|
452
|
-
isActive:
|
|
453
|
-
status:
|
|
454
|
-
dragStatus:
|
|
455
|
-
index:
|
|
588
|
+
isRoot: y,
|
|
589
|
+
isActive: v,
|
|
590
|
+
status: k,
|
|
591
|
+
dragStatus: me,
|
|
592
|
+
index: E
|
|
456
593
|
};
|
|
457
594
|
let at = p(null);
|
|
458
|
-
at.current ||=
|
|
595
|
+
at.current ||= ue({
|
|
459
596
|
getTransition: () => J.current.transition,
|
|
460
597
|
getDecorator: () => J.current.decorator,
|
|
461
598
|
getElements: () => ({
|
|
462
599
|
scope: W.current,
|
|
463
|
-
screenContainer:
|
|
600
|
+
screenContainer: U.current,
|
|
464
601
|
decorator: $e.current,
|
|
465
|
-
sharedTopBar:
|
|
466
|
-
sharedBottomBar:
|
|
602
|
+
sharedTopBar: K.current,
|
|
603
|
+
sharedBottomBar: q.current
|
|
467
604
|
}),
|
|
468
605
|
hasSharedTopBar: () => J.current.hasSharedTopBar,
|
|
469
606
|
hasSharedBottomBar: () => J.current.hasSharedBottomBar,
|
|
@@ -475,21 +612,21 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
475
612
|
return !e.isRoot && e.isActive && e.status === "COMPLETED" && e.dragStatus === "IDLE" && !!e.transition.swipeDirection && e.viewportScrollHeight < 10;
|
|
476
613
|
},
|
|
477
614
|
getPartnerBars: () => {
|
|
478
|
-
let e = J.current, t =
|
|
479
|
-
return n ?
|
|
615
|
+
let e = J.current, t = w.history.getState().histories, n = e.isActive ? t[e.index - 1]?.id : t[e.index]?.id;
|
|
616
|
+
return n ? w.screen.getState().sharedBars[n] : void 0;
|
|
480
617
|
},
|
|
481
618
|
getPartnerBarMetadata: () => {
|
|
482
|
-
let e = J.current, t =
|
|
483
|
-
return n ?
|
|
619
|
+
let e = J.current, t = w.history.getState().histories, n = e.isActive ? t[e.index - 1]?.id : t[e.index]?.id;
|
|
620
|
+
return n ? w.screen.getState().sharedBarMetadata[n] : void 0;
|
|
484
621
|
},
|
|
485
|
-
setDragStatus:
|
|
622
|
+
setDragStatus: j,
|
|
486
623
|
back: () => window.history.back()
|
|
487
624
|
});
|
|
488
|
-
let Y = at.current, ot = (e) => Y.pointerDown(e.nativeEvent), st = (e) => Y.pointerMove(e.nativeEvent), ct = (e) => Y.pointerUp(e.nativeEvent),
|
|
489
|
-
(
|
|
625
|
+
let Y = at.current, ot = (e) => Y.pointerDown(e.nativeEvent), st = (e) => Y.pointerMove(e.nativeEvent), ct = (e) => Y.pointerUp(e.nativeEvent), lt = (e) => Y.pointerCancel(e.nativeEvent), ut = (e) => {
|
|
626
|
+
(k === "PUSHING" || k === "REPLACING") && (e.preventDefault(), e.stopPropagation());
|
|
490
627
|
};
|
|
491
628
|
s(() => {
|
|
492
|
-
|
|
629
|
+
pe(W.current);
|
|
493
630
|
}, []), s(() => {
|
|
494
631
|
let e = W.current;
|
|
495
632
|
if (!e) return;
|
|
@@ -500,8 +637,8 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
500
637
|
e.removeEventListener("touchmove", t);
|
|
501
638
|
};
|
|
502
639
|
}, [Y]), d(() => {
|
|
503
|
-
let { registerSharedBars: e, unregisterSharedBars: t } =
|
|
504
|
-
return e(
|
|
640
|
+
let { registerSharedBars: e, unregisterSharedBars: t } = w.screen.getState(), n = V.current, r = Ge.current;
|
|
641
|
+
return e(_, {
|
|
505
642
|
topBar: F,
|
|
506
643
|
bottomBar: L
|
|
507
644
|
}, {
|
|
@@ -513,133 +650,133 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
513
650
|
id: f,
|
|
514
651
|
height: r.key === B ? r.height : void 0
|
|
515
652
|
} : void 0
|
|
516
|
-
}), () => t(
|
|
653
|
+
}), () => t(_);
|
|
517
654
|
}, [
|
|
518
655
|
B,
|
|
519
656
|
L,
|
|
520
657
|
F,
|
|
521
|
-
|
|
658
|
+
_,
|
|
522
659
|
f,
|
|
523
660
|
l,
|
|
524
|
-
|
|
661
|
+
w.screen,
|
|
525
662
|
R
|
|
526
663
|
]), d(() => {
|
|
527
|
-
let e = G.current;
|
|
528
|
-
if (e) return Ce(e, nt);
|
|
529
|
-
}, [nt, c]), d(() => {
|
|
530
664
|
let e = K.current;
|
|
531
|
-
if (e) return Ce(e,
|
|
532
|
-
}, [
|
|
665
|
+
if (e) return Ce(e, tt);
|
|
666
|
+
}, [tt, c]), d(() => {
|
|
667
|
+
let e = q.current;
|
|
668
|
+
if (e) return Ce(e, nt);
|
|
669
|
+
}, [nt, u]), d(() => {
|
|
533
670
|
let e = W.current;
|
|
534
671
|
if (!e) return;
|
|
535
|
-
let { registerScreenSurface: t, unregisterScreenSurface: n } =
|
|
536
|
-
return t(
|
|
672
|
+
let { registerScreenSurface: t, unregisterScreenSurface: n } = w.screen.getState();
|
|
673
|
+
return t(_, { opaqueBackground: be(getComputedStyle(e).backgroundColor) }), () => n(_);
|
|
537
674
|
}, [
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
675
|
+
_,
|
|
676
|
+
se,
|
|
677
|
+
k,
|
|
678
|
+
w.screen
|
|
542
679
|
]);
|
|
543
|
-
let
|
|
544
|
-
status:
|
|
545
|
-
isTopOrTopPrev:
|
|
680
|
+
let dt = O, { app: ft, nav: pt } = ie({
|
|
681
|
+
status: k,
|
|
682
|
+
isTopOrTopPrev: dt,
|
|
546
683
|
hasTopBar: F,
|
|
547
684
|
hasNavBar: L,
|
|
548
685
|
topBarId: l,
|
|
549
686
|
bottomBarId: f,
|
|
550
687
|
partnerBars: ye,
|
|
551
688
|
partnerMetadata: N
|
|
552
|
-
}),
|
|
553
|
-
status:
|
|
554
|
-
isTopOrTopPrev:
|
|
555
|
-
transitionName:
|
|
556
|
-
}),
|
|
557
|
-
isActive:
|
|
558
|
-
isPrev:
|
|
559
|
-
zIndex:
|
|
560
|
-
index:
|
|
561
|
-
status:
|
|
562
|
-
dragStatus:
|
|
563
|
-
replaceTransitionStatus:
|
|
564
|
-
}),
|
|
565
|
-
key:
|
|
566
|
-
released:
|
|
689
|
+
}), X = te({
|
|
690
|
+
status: k,
|
|
691
|
+
isTopOrTopPrev: dt,
|
|
692
|
+
transitionName: x
|
|
693
|
+
}), mt = ae({
|
|
694
|
+
isActive: v,
|
|
695
|
+
isPrev: ce,
|
|
696
|
+
zIndex: b,
|
|
697
|
+
index: E,
|
|
698
|
+
status: k,
|
|
699
|
+
dragStatus: me,
|
|
700
|
+
replaceTransitionStatus: he
|
|
701
|
+
}), ht = p(mt), gt = p(X !== null && mt), [_t, vt] = m({
|
|
702
|
+
key: X,
|
|
703
|
+
released: X === null
|
|
567
704
|
});
|
|
568
|
-
|
|
569
|
-
key:
|
|
570
|
-
released:
|
|
571
|
-
}),
|
|
572
|
-
let
|
|
705
|
+
_t.key !== X && (vt({
|
|
706
|
+
key: X,
|
|
707
|
+
released: X === null
|
|
708
|
+
}), gt.current = X !== null && ht.current), ht.current = mt;
|
|
709
|
+
let Z = X !== null && _t.key === X && !_t.released, Q = Z ? !v && xe?.opaqueBackground ? "park" : v && (k === "PUSHING" || k === "REPLACING") && xe?.opaqueBackground ? Oe() ? "park-over" : "park-under" : "true" : "false", Ct = wt(De);
|
|
573
710
|
d(() => we.driveScreenLifecycle({
|
|
574
711
|
getElements: () => ({
|
|
575
712
|
scope: W.current,
|
|
576
713
|
decorator: $e.current,
|
|
577
|
-
bars: [
|
|
714
|
+
bars: [K.current, q.current]
|
|
578
715
|
}),
|
|
579
|
-
transitionName:
|
|
580
|
-
prevTransitionName:
|
|
581
|
-
status:
|
|
582
|
-
isActive:
|
|
583
|
-
animHoldReleased: !
|
|
716
|
+
transitionName: x,
|
|
717
|
+
prevTransitionName: le,
|
|
718
|
+
status: k,
|
|
719
|
+
isActive: v,
|
|
720
|
+
animHoldReleased: !Z
|
|
584
721
|
}), [
|
|
585
722
|
we,
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
723
|
+
k,
|
|
724
|
+
v,
|
|
725
|
+
le,
|
|
726
|
+
x,
|
|
727
|
+
Z
|
|
591
728
|
]), s(() => {
|
|
592
|
-
if (!
|
|
593
|
-
let e =
|
|
729
|
+
if (!Z || X === null) return;
|
|
730
|
+
let e = X, t = w.navigate.getState().transitionTaskId, n = t === null ? e : `${e}#${t}`;
|
|
594
731
|
return Te.current.join(n, () => {
|
|
595
|
-
if ((J.current.transition.driver === "native" || ve()) && !
|
|
732
|
+
if ((J.current.transition.driver === "native" || ve()) && !A()) {
|
|
596
733
|
for (let e of [
|
|
597
734
|
W.current,
|
|
598
|
-
G.current,
|
|
599
735
|
K.current,
|
|
736
|
+
q.current,
|
|
600
737
|
$e.current
|
|
601
738
|
]) e?.isConnected && e.getAttribute("data-flemo-anim-hold") !== null && e.setAttribute("data-flemo-anim-hold", "false");
|
|
602
|
-
|
|
739
|
+
U.current && (U.current.style.zIndex = "");
|
|
603
740
|
}
|
|
604
|
-
ze(() =>
|
|
741
|
+
ze(() => vt((t) => t.key === e && !t.released ? {
|
|
605
742
|
key: e,
|
|
606
743
|
released: !0
|
|
607
744
|
} : t));
|
|
608
745
|
}, {
|
|
609
746
|
scope: W.current,
|
|
610
|
-
decodeWait:
|
|
611
|
-
contentSettle: ke() && (
|
|
747
|
+
decodeWait: gt.current,
|
|
748
|
+
contentSettle: ke() && (v && k === "PUSHING" || k === "POPPING") ? {
|
|
612
749
|
firstWaitMs: 120,
|
|
613
750
|
capMs: 700,
|
|
614
751
|
graceMs: 60,
|
|
615
|
-
minNodes:
|
|
752
|
+
minNodes: v ? 30 : 1,
|
|
616
753
|
renderSettleOnly: !0
|
|
617
754
|
} : void 0
|
|
618
755
|
});
|
|
619
756
|
}, [
|
|
620
|
-
Q,
|
|
621
757
|
Z,
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
758
|
+
X,
|
|
759
|
+
Q,
|
|
760
|
+
v,
|
|
761
|
+
k,
|
|
762
|
+
w.navigate
|
|
626
763
|
]);
|
|
627
|
-
let Tt =
|
|
764
|
+
let Tt = Q === "park-under" || Q === "park-over" ? {} : ge({
|
|
628
765
|
initial: Ae,
|
|
629
|
-
isActive:
|
|
630
|
-
status:
|
|
766
|
+
isActive: v,
|
|
767
|
+
status: k
|
|
631
768
|
});
|
|
632
769
|
return /* @__PURE__ */ Re("div", {
|
|
633
|
-
ref:
|
|
634
|
-
onClickCapture:
|
|
770
|
+
ref: U,
|
|
771
|
+
onClickCapture: ut,
|
|
635
772
|
style: {
|
|
636
|
-
position:
|
|
773
|
+
position: C,
|
|
637
774
|
top: 0,
|
|
638
775
|
left: 0,
|
|
639
776
|
width: "100%",
|
|
640
777
|
height: "100%",
|
|
641
778
|
display: "flex",
|
|
642
|
-
zIndex:
|
|
779
|
+
zIndex: Q === "park-under" ? -1 : void 0,
|
|
643
780
|
contain: "layout style",
|
|
644
781
|
flexDirection: "column",
|
|
645
782
|
boxSizing: "border-box",
|
|
@@ -648,33 +785,33 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
648
785
|
children: [
|
|
649
786
|
/* @__PURE__ */ Re("div", {
|
|
650
787
|
ref: W,
|
|
651
|
-
...
|
|
788
|
+
...g,
|
|
652
789
|
onPointerDown: ot,
|
|
653
790
|
onPointerMove: st,
|
|
654
791
|
onPointerUp: ct,
|
|
655
|
-
onPointerCancel:
|
|
792
|
+
onPointerCancel: lt,
|
|
656
793
|
"data-flemo-screen": !0,
|
|
657
|
-
"data-flemo-router":
|
|
658
|
-
"data-flemo-transition":
|
|
659
|
-
"data-flemo-status":
|
|
660
|
-
"data-flemo-active":
|
|
661
|
-
"data-flemo-anim-hold":
|
|
794
|
+
"data-flemo-router": T ?? void 0,
|
|
795
|
+
"data-flemo-transition": x,
|
|
796
|
+
"data-flemo-status": k,
|
|
797
|
+
"data-flemo-active": v ? "true" : "false",
|
|
798
|
+
"data-flemo-anim-hold": Q,
|
|
662
799
|
style: {
|
|
663
800
|
display: "flex",
|
|
664
801
|
flexDirection: "column",
|
|
665
802
|
height: "100%",
|
|
666
|
-
backgroundColor:
|
|
667
|
-
overflowY:
|
|
803
|
+
backgroundColor: se,
|
|
804
|
+
overflowY: h ? void 0 : "auto",
|
|
668
805
|
touchAction: je === "x" ? "pan-y" : je === "y" ? "pan-x" : "auto",
|
|
669
|
-
...
|
|
806
|
+
...Ct && (Q !== "false" || b === E && !S) ? { willChange: "transform" } : {},
|
|
670
807
|
...Tt,
|
|
671
|
-
...
|
|
808
|
+
...g.style
|
|
672
809
|
},
|
|
673
810
|
children: [
|
|
674
811
|
!re && t && /* @__PURE__ */ P("div", {
|
|
675
812
|
style: { minHeight: t },
|
|
676
813
|
children: /* @__PURE__ */ P("div", { style: {
|
|
677
|
-
position:
|
|
814
|
+
position: C,
|
|
678
815
|
top: 0,
|
|
679
816
|
width: "100%",
|
|
680
817
|
minHeight: t,
|
|
@@ -682,11 +819,11 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
682
819
|
} })
|
|
683
820
|
}),
|
|
684
821
|
c && /* @__PURE__ */ P("div", {
|
|
685
|
-
ref:
|
|
822
|
+
ref: G,
|
|
686
823
|
"data-flemo-bar-spacer": "app",
|
|
687
824
|
style: {
|
|
688
825
|
width: "100%",
|
|
689
|
-
minHeight:
|
|
826
|
+
minHeight: Ze
|
|
690
827
|
}
|
|
691
828
|
}),
|
|
692
829
|
ee,
|
|
@@ -695,27 +832,27 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
695
832
|
display: "flex",
|
|
696
833
|
flexDirection: "column",
|
|
697
834
|
flexGrow: 1,
|
|
698
|
-
overflowY:
|
|
835
|
+
overflowY: h ? "auto" : void 0
|
|
699
836
|
},
|
|
700
837
|
children: e
|
|
701
838
|
}),
|
|
702
839
|
ne,
|
|
703
840
|
u && /* @__PURE__ */ P("div", {
|
|
704
|
-
ref:
|
|
841
|
+
ref: et,
|
|
705
842
|
"data-flemo-bar-spacer": "nav",
|
|
706
843
|
style: {
|
|
707
844
|
display: Le ? "none" : void 0,
|
|
708
845
|
width: "100%",
|
|
709
|
-
minHeight:
|
|
846
|
+
minHeight: Qe
|
|
710
847
|
}
|
|
711
848
|
}),
|
|
712
|
-
!
|
|
849
|
+
!oe && r && /* @__PURE__ */ P("div", {
|
|
713
850
|
style: {
|
|
714
851
|
display: Le ? "none" : void 0,
|
|
715
852
|
minHeight: r
|
|
716
853
|
},
|
|
717
854
|
children: /* @__PURE__ */ P("div", { style: {
|
|
718
|
-
position:
|
|
855
|
+
position: C,
|
|
719
856
|
bottom: 0,
|
|
720
857
|
width: "100%",
|
|
721
858
|
minHeight: r,
|
|
@@ -729,14 +866,14 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
729
866
|
"data-flemo-bar": "app",
|
|
730
867
|
"data-flemo-bar-id": l,
|
|
731
868
|
"data-flemo-bar-id-type": l === void 0 ? void 0 : typeof l,
|
|
732
|
-
"data-flemo-router":
|
|
733
|
-
"data-flemo-bar-transition":
|
|
734
|
-
"data-flemo-bar-status":
|
|
735
|
-
"data-flemo-bar-active":
|
|
736
|
-
"data-flemo-bar-riding":
|
|
737
|
-
"data-flemo-anim-hold":
|
|
869
|
+
"data-flemo-router": T ?? void 0,
|
|
870
|
+
"data-flemo-bar-transition": x,
|
|
871
|
+
"data-flemo-bar-status": k,
|
|
872
|
+
"data-flemo-bar-active": v ? "true" : "false",
|
|
873
|
+
"data-flemo-bar-riding": ft ? "true" : "false",
|
|
874
|
+
"data-flemo-anim-hold": Q,
|
|
738
875
|
style: {
|
|
739
|
-
position:
|
|
876
|
+
position: C,
|
|
740
877
|
top: re ? 0 : t,
|
|
741
878
|
left: 0,
|
|
742
879
|
width: "100%",
|
|
@@ -749,33 +886,33 @@ function gt({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
749
886
|
"data-flemo-bar": "nav",
|
|
750
887
|
"data-flemo-bar-id": f,
|
|
751
888
|
"data-flemo-bar-id-type": f === void 0 ? void 0 : typeof f,
|
|
752
|
-
"data-flemo-router":
|
|
753
|
-
"data-flemo-bar-transition":
|
|
754
|
-
"data-flemo-bar-status":
|
|
755
|
-
"data-flemo-bar-active":
|
|
756
|
-
"data-flemo-bar-riding":
|
|
757
|
-
"data-flemo-anim-hold":
|
|
889
|
+
"data-flemo-router": T ?? void 0,
|
|
890
|
+
"data-flemo-bar-transition": x,
|
|
891
|
+
"data-flemo-bar-status": k,
|
|
892
|
+
"data-flemo-bar-active": v ? "true" : "false",
|
|
893
|
+
"data-flemo-bar-riding": pt ? "true" : "false",
|
|
894
|
+
"data-flemo-anim-hold": Q,
|
|
758
895
|
style: {
|
|
759
896
|
display: Le ? "none" : void 0,
|
|
760
|
-
position:
|
|
761
|
-
bottom:
|
|
897
|
+
position: C,
|
|
898
|
+
bottom: oe ? 0 : r,
|
|
762
899
|
left: 0,
|
|
763
900
|
width: "100%",
|
|
764
901
|
zIndex: 1
|
|
765
902
|
},
|
|
766
903
|
children: u
|
|
767
904
|
}),
|
|
768
|
-
Pe && /* @__PURE__ */ P(
|
|
905
|
+
Pe && /* @__PURE__ */ P(xt, {
|
|
769
906
|
ref: $e,
|
|
770
|
-
"data-flemo-anim-hold":
|
|
907
|
+
"data-flemo-anim-hold": Q
|
|
771
908
|
})
|
|
772
909
|
]
|
|
773
910
|
});
|
|
774
911
|
}
|
|
775
912
|
//#endregion
|
|
776
913
|
//#region src/screen/Screen.tsx
|
|
777
|
-
function
|
|
778
|
-
let { isActive: n, isPrev: r, zIndex: i } = z(), a =
|
|
914
|
+
function Et({ children: e, ...t }) {
|
|
915
|
+
let { isActive: n, isPrev: r, zIndex: i } = z(), a = H((e) => e.index), o = bt((e) => e.status), c = $((e) => e.dragStatus), l = $((e) => e.replaceTransitionStatus), u = oe({
|
|
779
916
|
isActive: n,
|
|
780
917
|
isPrev: r,
|
|
781
918
|
zIndex: i,
|
|
@@ -786,21 +923,21 @@ function _t({ children: e, ...t }) {
|
|
|
786
923
|
}), [d, f] = m(u !== "live");
|
|
787
924
|
return u === "live" && d && f(!1), u === "immediate" && !d && f(!0), s(() => {
|
|
788
925
|
if (u !== "deferred" || d) return;
|
|
789
|
-
let e = setTimeout(() => f(!0),
|
|
926
|
+
let e = setTimeout(() => f(!0), Dt);
|
|
790
927
|
return () => clearTimeout(e);
|
|
791
|
-
}, [u, d]), /* @__PURE__ */ P(
|
|
928
|
+
}, [u, d]), /* @__PURE__ */ P(vt, {
|
|
792
929
|
freeze: d,
|
|
793
|
-
children: /* @__PURE__ */ P(
|
|
930
|
+
children: /* @__PURE__ */ P(Tt, {
|
|
794
931
|
...t,
|
|
795
932
|
children: e
|
|
796
933
|
})
|
|
797
934
|
});
|
|
798
935
|
}
|
|
799
|
-
var
|
|
936
|
+
var Dt = 600;
|
|
800
937
|
//#endregion
|
|
801
938
|
//#region src/screen/Part.tsx
|
|
802
|
-
function
|
|
803
|
-
let { isActive: a, isPrev: s, navigateStore: c, routerId: l } = z(), u = o(
|
|
939
|
+
function Ot({ ref: e, name: t, style: n, children: r, ...i }) {
|
|
940
|
+
let { isActive: a, isPrev: s, navigateStore: c, routerId: l } = z(), u = o(We), d = l ?? u ?? void 0, f = I(), p = V(c ?? f.navigate, (e) => s ? "COMPLETED" : e.status);
|
|
804
941
|
return /* @__PURE__ */ P("div", {
|
|
805
942
|
ref: e,
|
|
806
943
|
"data-flemo-part-name": t,
|
|
@@ -814,15 +951,15 @@ function Z({ ref: e, name: t, style: n, children: r, ...i }) {
|
|
|
814
951
|
}
|
|
815
952
|
//#endregion
|
|
816
953
|
//#region src/stores/RouterScopeProvider.tsx
|
|
817
|
-
function
|
|
954
|
+
function kt({ children: e }) {
|
|
818
955
|
let [t] = m(() => ({
|
|
819
|
-
history:
|
|
820
|
-
navigate:
|
|
821
|
-
transition:
|
|
822
|
-
screen:
|
|
823
|
-
driver:
|
|
956
|
+
history: y(),
|
|
957
|
+
navigate: ce(),
|
|
958
|
+
transition: k(),
|
|
959
|
+
screen: E(),
|
|
960
|
+
driver: _(),
|
|
824
961
|
markSelfInduced: xe,
|
|
825
|
-
consume:
|
|
962
|
+
consume: se,
|
|
826
963
|
life: { alive: !0 }
|
|
827
964
|
}));
|
|
828
965
|
return /* @__PURE__ */ P(F.Provider, {
|
|
@@ -831,4 +968,4 @@ function yt({ children: e }) {
|
|
|
831
968
|
});
|
|
832
969
|
}
|
|
833
970
|
//#endregion
|
|
834
|
-
export {
|
|
971
|
+
export { Ot as Part, ft as Route, dt as Router, kt as RouterScopeProvider, Et as Screen, R as ScreenContext, xt as ScreenDecorator, vt as ScreenFreeze, Tt as ScreenMotion, rt as Slot, g as createBrowserHistoryDriver, v as createDecorator, x as createPartTransition, le as createRawDecorator, S as createRawPartTransition, C as createRawTransition, O as createTransition, Te as partTransitionMap, H as useHistoryStore, X as useNavigate, bt as useNavigateStore, gt as useParams, mt as usePathname, z as useScreen, $ as useScreenStore, ht as useStep, I as useStores, St as useViewportScrollHeight };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare module '../../Route' {
|
|
2
|
+
interface RegisterRoute {
|
|
3
|
+
"/": Record<string, never>;
|
|
4
|
+
"/members/:id": {
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
"/region": Record<string, never>;
|
|
8
|
+
"/region/people": Record<string, never>;
|
|
9
|
+
"/inner": Record<string, never>;
|
|
10
|
+
"/inner/detail": Record<string, never>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
declare module "../../RouterTarget" {
|
|
14
|
+
interface RegisterRouter {
|
|
15
|
+
app: true;
|
|
16
|
+
region: true;
|
|
17
|
+
inner: true;
|
|
18
|
+
sidebar: true;
|
|
19
|
+
"next-name": true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { TransitionName } from '@flemo/core';
|
|
2
|
+
import { RouterTarget } from '../RouterTarget';
|
|
2
3
|
import { RegisterRoute } from '../Route';
|
|
3
4
|
interface DistanceOptions {
|
|
4
5
|
skip?: number;
|
|
5
6
|
until?: keyof RegisterRoute;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
export interface UseNavigateOptions {
|
|
9
|
+
router?: RouterTarget;
|
|
10
|
+
}
|
|
11
|
+
type RouteOptions = DistanceOptions & UseNavigateOptions & {
|
|
8
12
|
layoutId?: string | number;
|
|
9
13
|
transitionName?: TransitionName;
|
|
10
14
|
};
|
|
11
|
-
|
|
15
|
+
type PopRouteOptions = DistanceOptions & UseNavigateOptions & {
|
|
16
|
+
transitionName?: TransitionName;
|
|
17
|
+
};
|
|
18
|
+
export default function useNavigate(defaults?: UseNavigateOptions): {
|
|
12
19
|
push: <T extends keyof RegisterRoute>(path: T, params?: RegisterRoute[T], options?: RouteOptions) => Promise<void>;
|
|
13
20
|
replace: <T extends keyof RegisterRoute>(path: T, params?: RegisterRoute[T], options?: RouteOptions) => Promise<void>;
|
|
14
|
-
pop: (options?:
|
|
15
|
-
transitionName?: TransitionName;
|
|
16
|
-
}) => Promise<void>;
|
|
21
|
+
pop: (options?: PopRouteOptions) => Promise<void>;
|
|
17
22
|
};
|
|
18
23
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flemo/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.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",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"vite": "^8.2.1",
|
|
55
55
|
"vite-plugin-dts": "^5.0.3",
|
|
56
56
|
"vitest": "^4.1.10",
|
|
57
|
-
"@flemo/
|
|
58
|
-
"@flemo/
|
|
57
|
+
"@flemo/tsconfig": "0.0.0",
|
|
58
|
+
"@flemo/eslint-config": "0.0.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"react": "^19.2.8",
|