flemo 1.0.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/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/Route.d.ts +10 -0
- package/dist/Router.d.ts +11 -0
- package/dist/core/TaskManger.d.ts +56 -0
- package/dist/history/HistoryListener.d.ts +2 -0
- package/dist/history/store.d.ts +16 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.mjs +1041 -0
- package/dist/navigate/store.d.ts +7 -0
- package/dist/navigate/useNavigate.d.ts +11 -0
- package/dist/navigate/useStep.d.ts +6 -0
- package/dist/renderer/Renderer.d.ts +3 -0
- package/dist/screen/ParamsProvider/ParamsContext.d.ts +2 -0
- package/dist/screen/ParamsProvider/ParamsDispatchContext.d.ts +7 -0
- package/dist/screen/ParamsProvider/ParamsProvider.d.ts +6 -0
- package/dist/screen/ParamsProvider/ParamsReducer.d.ts +3 -0
- package/dist/screen/ParamsProvider/useParams.d.ts +2 -0
- package/dist/screen/ParamsProvider/useParamsDispatch.d.ts +1 -0
- package/dist/screen/Screen.d.ts +3 -0
- package/dist/screen/ScreenContext.d.ts +12 -0
- package/dist/screen/ScreenFreeze.d.ts +8 -0
- package/dist/screen/ScreenMotion.d.ts +3 -0
- package/dist/screen/ScreenMotionDecorator.d.ts +3 -0
- package/dist/screen/store.d.ts +6 -0
- package/dist/screen/useScreen.d.ts +1 -0
- package/dist/transition/createRawTransition.d.ts +18 -0
- package/dist/transition/createTransition.d.ts +14 -0
- package/dist/transition/cupertino.d.ts +2 -0
- package/dist/transition/decorator/createDecorator.d.ts +12 -0
- package/dist/transition/decorator/createRawDecorator.d.ts +19 -0
- package/dist/transition/decorator/decorator.d.ts +2 -0
- package/dist/transition/decorator/overlay.d.ts +2 -0
- package/dist/transition/decorator/typing.d.ts +13 -0
- package/dist/transition/material.d.ts +2 -0
- package/dist/transition/none.d.ts +2 -0
- package/dist/transition/store.d.ts +7 -0
- package/dist/transition/transition.d.ts +3 -0
- package/dist/transition/typing.d.ts +38 -0
- package/dist/utils/getParams.d.ts +4 -0
- package/dist/utils/isServer.d.ts +1 -0
- package/dist/vendor-C8cPYUOQ.js +299 -0
- package/package.json +79 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type NavigateStatus = "IDLE" | "PUSHING" | "REPLACING" | "POPPING" | "COMPLETED";
|
|
2
|
+
interface NavigateStore {
|
|
3
|
+
status: NavigateStatus;
|
|
4
|
+
setStatus: (status: NavigateStatus) => void;
|
|
5
|
+
}
|
|
6
|
+
declare const useNavigateStore: import('zustand').UseBoundStore<import('zustand').StoreApi<NavigateStore>>;
|
|
7
|
+
export default useNavigateStore;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RegisterRoute } from '../Route';
|
|
2
|
+
import { TransitionName } from '../transition/typing';
|
|
3
|
+
export default function useNavigate(): {
|
|
4
|
+
push: <T extends keyof RegisterRoute>(path: T, params: RegisterRoute[T], options?: {
|
|
5
|
+
transitionName?: TransitionName;
|
|
6
|
+
}) => Promise<void>;
|
|
7
|
+
replace: <T extends keyof RegisterRoute>(path: T, params: RegisterRoute[T], options?: {
|
|
8
|
+
transitionName?: TransitionName;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
pop: () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useParamsDispatch(): import('react').Dispatch<import('./ParamsDispatchContext').ParamsDispatchContextType>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { History } from '../history/store';
|
|
2
|
+
import { TransitionName } from '../transition/typing';
|
|
3
|
+
export interface ScreenContextProps extends History {
|
|
4
|
+
id: string;
|
|
5
|
+
isActive: boolean;
|
|
6
|
+
isRoot: boolean;
|
|
7
|
+
isPrev: boolean;
|
|
8
|
+
zIndex: number;
|
|
9
|
+
prevTransitionName: TransitionName;
|
|
10
|
+
}
|
|
11
|
+
declare const ScreenContext: import('react').Context<ScreenContextProps>;
|
|
12
|
+
export default ScreenContext;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface ScreenFreezeProps {
|
|
3
|
+
freeze: boolean;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
placeholder?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare function ScreenFreeze({ freeze, children, placeholder }: ScreenFreezeProps): import("react").JSX.Element;
|
|
8
|
+
export default ScreenFreeze;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface ScreenStore {
|
|
2
|
+
transitionStatus: "IDLE" | "PENDING";
|
|
3
|
+
setTransitionStatus: (transitionStatus: "IDLE" | "PENDING") => void;
|
|
4
|
+
}
|
|
5
|
+
declare const useScreenStore: import('zustand').UseBoundStore<import('zustand').StoreApi<ScreenStore>>;
|
|
6
|
+
export default useScreenStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useScreen(): import('./ScreenContext').ScreenContextProps;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TransitionOptions, Transition, TransitionVariantValue, TransitionName } from './typing';
|
|
2
|
+
import { TargetAndTransition } from 'motion';
|
|
3
|
+
interface CreateRawTransitionProps {
|
|
4
|
+
name: TransitionName;
|
|
5
|
+
initial: TargetAndTransition;
|
|
6
|
+
idle: TransitionVariantValue;
|
|
7
|
+
pushOnEnter: TransitionVariantValue;
|
|
8
|
+
pushOnExit: TransitionVariantValue;
|
|
9
|
+
replaceOnEnter: TransitionVariantValue;
|
|
10
|
+
replaceOnExit: TransitionVariantValue;
|
|
11
|
+
popOnEnter: TransitionVariantValue;
|
|
12
|
+
popOnExit: TransitionVariantValue;
|
|
13
|
+
completedOnEnter: TransitionVariantValue;
|
|
14
|
+
completedOnExit: TransitionVariantValue;
|
|
15
|
+
options?: TransitionOptions;
|
|
16
|
+
}
|
|
17
|
+
export default function createRawTransition({ name, initial, idle, pushOnEnter, pushOnExit, replaceOnEnter, replaceOnExit, popOnEnter, popOnExit, completedOnExit, completedOnEnter, options }: CreateRawTransitionProps): Transition;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TransitionOptions, Transition, TransitionVariantValue, TransitionName } from './typing';
|
|
2
|
+
import { TargetAndTransition } from 'motion';
|
|
3
|
+
interface CreateTransitionProps {
|
|
4
|
+
name: TransitionName;
|
|
5
|
+
initial: TargetAndTransition;
|
|
6
|
+
idle: TransitionVariantValue;
|
|
7
|
+
enter: TransitionVariantValue;
|
|
8
|
+
enterBack: TransitionVariantValue;
|
|
9
|
+
exit: TransitionVariantValue;
|
|
10
|
+
exitBack: TransitionVariantValue;
|
|
11
|
+
options?: TransitionOptions;
|
|
12
|
+
}
|
|
13
|
+
export default function createTransition({ name, initial, idle, enter, enterBack, exit, exitBack, options }: CreateTransitionProps): Transition;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DecoratorName, Decorator, DecoratorOptions } from './typing';
|
|
2
|
+
import { TransitionVariantValue } from '../typing';
|
|
3
|
+
import { TargetAndTransition } from 'motion';
|
|
4
|
+
interface CreateDecoratorProps {
|
|
5
|
+
name: DecoratorName;
|
|
6
|
+
initial: TargetAndTransition;
|
|
7
|
+
enter: TransitionVariantValue;
|
|
8
|
+
exit: TransitionVariantValue;
|
|
9
|
+
options?: DecoratorOptions;
|
|
10
|
+
}
|
|
11
|
+
export default function createDecorator({ name, initial, enter, exit, options }: CreateDecoratorProps): Decorator;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TransitionVariantValue } from '../typing';
|
|
2
|
+
import { DecoratorName, Decorator, DecoratorOptions } from './typing';
|
|
3
|
+
import { TargetAndTransition } from 'motion';
|
|
4
|
+
interface CreateRawDecoratorProps {
|
|
5
|
+
name: DecoratorName;
|
|
6
|
+
initial: TargetAndTransition;
|
|
7
|
+
idle: TransitionVariantValue;
|
|
8
|
+
pushOnEnter: TransitionVariantValue;
|
|
9
|
+
pushOnExit: TransitionVariantValue;
|
|
10
|
+
replaceOnEnter: TransitionVariantValue;
|
|
11
|
+
replaceOnExit: TransitionVariantValue;
|
|
12
|
+
popOnEnter: TransitionVariantValue;
|
|
13
|
+
popOnExit: TransitionVariantValue;
|
|
14
|
+
completedOnEnter: TransitionVariantValue;
|
|
15
|
+
completedOnExit: TransitionVariantValue;
|
|
16
|
+
options?: DecoratorOptions;
|
|
17
|
+
}
|
|
18
|
+
export default function createRawDecorator({ name, initial, idle, pushOnEnter, pushOnExit, replaceOnEnter, replaceOnExit, popOnEnter, popOnExit, completedOnEnter, completedOnExit, options }: CreateRawDecoratorProps): Decorator;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseTransition } from '../typing';
|
|
2
|
+
export interface RegisterDecorator {
|
|
3
|
+
}
|
|
4
|
+
export type DecoratorName = RegisterDecorator[keyof RegisterDecorator] | "overlay";
|
|
5
|
+
export type DecoratorOptions = {
|
|
6
|
+
onSwipe?: (progress: number, options: {
|
|
7
|
+
currentDecorator: HTMLDivElement;
|
|
8
|
+
prevDecorator: HTMLDivElement;
|
|
9
|
+
}) => void;
|
|
10
|
+
};
|
|
11
|
+
export interface Decorator extends Omit<BaseTransition, "name">, DecoratorOptions {
|
|
12
|
+
name: DecoratorName;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TransitionName } from './typing';
|
|
2
|
+
interface TransitionStore {
|
|
3
|
+
defaultTransitionName: TransitionName;
|
|
4
|
+
setDefaultTransitionName: (defaultTransitionName: TransitionName) => void;
|
|
5
|
+
}
|
|
6
|
+
declare const useTransitionStore: import('zustand').UseBoundStore<import('zustand').StoreApi<TransitionStore>>;
|
|
7
|
+
export default useTransitionStore;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PanInfo, TargetAndTransition, Target, AnimationOptions, DragControls } from 'motion/react';
|
|
2
|
+
import { NavigateStatus } from '../navigate/store';
|
|
3
|
+
import { DecoratorName } from './decorator/typing';
|
|
4
|
+
export interface RegisterTransition {
|
|
5
|
+
}
|
|
6
|
+
export type TransitionName = RegisterTransition[keyof RegisterTransition] | "none" | "cupertino" | "material";
|
|
7
|
+
export type TransitionVariant = `${NavigateStatus}-${boolean}`;
|
|
8
|
+
export type TransitionVariantValue = {
|
|
9
|
+
value: Target;
|
|
10
|
+
options: AnimationOptions;
|
|
11
|
+
};
|
|
12
|
+
export type TransitionOptions = {
|
|
13
|
+
decoratorName?: DecoratorName;
|
|
14
|
+
swipeDirection: "x" | "y";
|
|
15
|
+
onSwipeStart: (event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo, options: {
|
|
16
|
+
currentScreen: HTMLDivElement;
|
|
17
|
+
prevScreen: HTMLDivElement;
|
|
18
|
+
dragControls: DragControls;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
onSwipe: (event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo, options: {
|
|
21
|
+
currentScreen: HTMLDivElement;
|
|
22
|
+
prevScreen: HTMLDivElement;
|
|
23
|
+
dragControls: DragControls;
|
|
24
|
+
}) => number;
|
|
25
|
+
onSwipeEnd: (event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo, options: {
|
|
26
|
+
currentScreen: HTMLDivElement;
|
|
27
|
+
prevScreen: HTMLDivElement;
|
|
28
|
+
}) => Promise<boolean>;
|
|
29
|
+
} | {
|
|
30
|
+
decoratorName?: DecoratorName;
|
|
31
|
+
swipeDirection?: never;
|
|
32
|
+
};
|
|
33
|
+
export interface BaseTransition {
|
|
34
|
+
name: TransitionName;
|
|
35
|
+
initial: TargetAndTransition;
|
|
36
|
+
variants: Record<TransitionVariant, TransitionVariantValue>;
|
|
37
|
+
}
|
|
38
|
+
export type Transition = BaseTransition & TransitionOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isServer(): boolean;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import C from "react";
|
|
2
|
+
var d = {}, N;
|
|
3
|
+
function H() {
|
|
4
|
+
if (N) return d;
|
|
5
|
+
N = 1, Object.defineProperty(d, "__esModule", { value: !0 }), d.TokenData = void 0, d.parse = m, d.compile = R, d.match = M, d.pathToRegexp = j, d.stringify = k;
|
|
6
|
+
const c = "/", a = (n) => n, l = /^[$_\p{ID_Start}]$/u, h = /^[$\u200c\u200d\p{ID_Continue}]$/u, $ = "https://git.new/pathToRegexpError", b = {
|
|
7
|
+
// Groups.
|
|
8
|
+
"{": "{",
|
|
9
|
+
"}": "}",
|
|
10
|
+
// Reserved.
|
|
11
|
+
"(": "(",
|
|
12
|
+
")": ")",
|
|
13
|
+
"[": "[",
|
|
14
|
+
"]": "]",
|
|
15
|
+
"+": "+",
|
|
16
|
+
"?": "?",
|
|
17
|
+
"!": "!"
|
|
18
|
+
};
|
|
19
|
+
function _(n) {
|
|
20
|
+
return n.replace(/[{}()\[\]+?!:*]/g, "\\$&");
|
|
21
|
+
}
|
|
22
|
+
function f(n) {
|
|
23
|
+
return n.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
|
|
24
|
+
}
|
|
25
|
+
function* I(n) {
|
|
26
|
+
const t = [...n];
|
|
27
|
+
let e = 0;
|
|
28
|
+
function o() {
|
|
29
|
+
let r = "";
|
|
30
|
+
if (l.test(t[++e]))
|
|
31
|
+
for (r += t[e]; h.test(t[++e]); )
|
|
32
|
+
r += t[e];
|
|
33
|
+
else if (t[e] === '"') {
|
|
34
|
+
let s = e;
|
|
35
|
+
for (; e < t.length; ) {
|
|
36
|
+
if (t[++e] === '"') {
|
|
37
|
+
e++, s = 0;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
t[e] === "\\" ? r += t[++e] : r += t[e];
|
|
41
|
+
}
|
|
42
|
+
if (s)
|
|
43
|
+
throw new TypeError(`Unterminated quote at ${s}: ${$}`);
|
|
44
|
+
}
|
|
45
|
+
if (!r)
|
|
46
|
+
throw new TypeError(`Missing parameter name at ${e}: ${$}`);
|
|
47
|
+
return r;
|
|
48
|
+
}
|
|
49
|
+
for (; e < t.length; ) {
|
|
50
|
+
const r = t[e], s = b[r];
|
|
51
|
+
if (s)
|
|
52
|
+
yield { type: s, index: e++, value: r };
|
|
53
|
+
else if (r === "\\")
|
|
54
|
+
yield { type: "ESCAPED", index: e++, value: t[e++] };
|
|
55
|
+
else if (r === ":") {
|
|
56
|
+
const u = o();
|
|
57
|
+
yield { type: "PARAM", index: e, value: u };
|
|
58
|
+
} else if (r === "*") {
|
|
59
|
+
const u = o();
|
|
60
|
+
yield { type: "WILDCARD", index: e, value: u };
|
|
61
|
+
} else
|
|
62
|
+
yield { type: "CHAR", index: e, value: t[e++] };
|
|
63
|
+
}
|
|
64
|
+
return { type: "END", index: e, value: "" };
|
|
65
|
+
}
|
|
66
|
+
class g {
|
|
67
|
+
constructor(t) {
|
|
68
|
+
this.tokens = t;
|
|
69
|
+
}
|
|
70
|
+
peek() {
|
|
71
|
+
if (!this._peek) {
|
|
72
|
+
const t = this.tokens.next();
|
|
73
|
+
this._peek = t.value;
|
|
74
|
+
}
|
|
75
|
+
return this._peek;
|
|
76
|
+
}
|
|
77
|
+
tryConsume(t) {
|
|
78
|
+
const e = this.peek();
|
|
79
|
+
if (e.type === t)
|
|
80
|
+
return this._peek = void 0, e.value;
|
|
81
|
+
}
|
|
82
|
+
consume(t) {
|
|
83
|
+
const e = this.tryConsume(t);
|
|
84
|
+
if (e !== void 0)
|
|
85
|
+
return e;
|
|
86
|
+
const { type: o, index: r } = this.peek();
|
|
87
|
+
throw new TypeError(`Unexpected ${o} at ${r}, expected ${t}: ${$}`);
|
|
88
|
+
}
|
|
89
|
+
text() {
|
|
90
|
+
let t = "", e;
|
|
91
|
+
for (; e = this.tryConsume("CHAR") || this.tryConsume("ESCAPED"); )
|
|
92
|
+
t += e;
|
|
93
|
+
return t;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
class x {
|
|
97
|
+
constructor(t) {
|
|
98
|
+
this.tokens = t;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
d.TokenData = x;
|
|
102
|
+
function m(n, t = {}) {
|
|
103
|
+
const { encodePath: e = a } = t, o = new g(I(n));
|
|
104
|
+
function r(u) {
|
|
105
|
+
const i = [];
|
|
106
|
+
for (; ; ) {
|
|
107
|
+
const p = o.text();
|
|
108
|
+
p && i.push({ type: "text", value: e(p) });
|
|
109
|
+
const y = o.tryConsume("PARAM");
|
|
110
|
+
if (y) {
|
|
111
|
+
i.push({
|
|
112
|
+
type: "param",
|
|
113
|
+
name: y
|
|
114
|
+
});
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const S = o.tryConsume("WILDCARD");
|
|
118
|
+
if (S) {
|
|
119
|
+
i.push({
|
|
120
|
+
type: "wildcard",
|
|
121
|
+
name: S
|
|
122
|
+
});
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (o.tryConsume("{")) {
|
|
126
|
+
i.push({
|
|
127
|
+
type: "group",
|
|
128
|
+
tokens: r("}")
|
|
129
|
+
});
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
return o.consume(u), i;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const s = r("END");
|
|
136
|
+
return new x(s);
|
|
137
|
+
}
|
|
138
|
+
function R(n, t = {}) {
|
|
139
|
+
const { encode: e = encodeURIComponent, delimiter: o = c } = t, r = n instanceof x ? n : m(n, t), s = T(r.tokens, o, e);
|
|
140
|
+
return function(i = {}) {
|
|
141
|
+
const [p, ...y] = s(i);
|
|
142
|
+
if (y.length)
|
|
143
|
+
throw new TypeError(`Missing parameters: ${y.join(", ")}`);
|
|
144
|
+
return p;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function T(n, t, e) {
|
|
148
|
+
const o = n.map((r) => P(r, t, e));
|
|
149
|
+
return (r) => {
|
|
150
|
+
const s = [""];
|
|
151
|
+
for (const u of o) {
|
|
152
|
+
const [i, ...p] = u(r);
|
|
153
|
+
s[0] += i, s.push(...p);
|
|
154
|
+
}
|
|
155
|
+
return s;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function P(n, t, e) {
|
|
159
|
+
if (n.type === "text")
|
|
160
|
+
return () => [n.value];
|
|
161
|
+
if (n.type === "group") {
|
|
162
|
+
const r = T(n.tokens, t, e);
|
|
163
|
+
return (s) => {
|
|
164
|
+
const [u, ...i] = r(s);
|
|
165
|
+
return i.length ? [""] : [u];
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const o = e || a;
|
|
169
|
+
return n.type === "wildcard" && e !== !1 ? (r) => {
|
|
170
|
+
const s = r[n.name];
|
|
171
|
+
if (s == null)
|
|
172
|
+
return ["", n.name];
|
|
173
|
+
if (!Array.isArray(s) || s.length === 0)
|
|
174
|
+
throw new TypeError(`Expected "${n.name}" to be a non-empty array`);
|
|
175
|
+
return [
|
|
176
|
+
s.map((u, i) => {
|
|
177
|
+
if (typeof u != "string")
|
|
178
|
+
throw new TypeError(`Expected "${n.name}/${i}" to be a string`);
|
|
179
|
+
return o(u);
|
|
180
|
+
}).join(t)
|
|
181
|
+
];
|
|
182
|
+
} : (r) => {
|
|
183
|
+
const s = r[n.name];
|
|
184
|
+
if (s == null)
|
|
185
|
+
return ["", n.name];
|
|
186
|
+
if (typeof s != "string")
|
|
187
|
+
throw new TypeError(`Expected "${n.name}" to be a string`);
|
|
188
|
+
return [o(s)];
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function M(n, t = {}) {
|
|
192
|
+
const { decode: e = decodeURIComponent, delimiter: o = c } = t, { regexp: r, keys: s } = j(n, t), u = s.map((i) => e === !1 ? a : i.type === "param" ? e : (p) => p.split(o).map(e));
|
|
193
|
+
return function(p) {
|
|
194
|
+
const y = r.exec(p);
|
|
195
|
+
if (!y)
|
|
196
|
+
return !1;
|
|
197
|
+
const S = y[0], w = /* @__PURE__ */ Object.create(null);
|
|
198
|
+
for (let E = 1; E < y.length; E++) {
|
|
199
|
+
if (y[E] === void 0)
|
|
200
|
+
continue;
|
|
201
|
+
const v = s[E - 1], A = u[E - 1];
|
|
202
|
+
w[v.name] = A(y[E]);
|
|
203
|
+
}
|
|
204
|
+
return { path: S, params: w };
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function j(n, t = {}) {
|
|
208
|
+
const { delimiter: e = c, end: o = !0, sensitive: r = !1, trailing: s = !0 } = t, u = [], i = [], p = r ? "" : "i", S = (Array.isArray(n) ? n : [n]).map((v) => v instanceof x ? v : m(v, t));
|
|
209
|
+
for (const { tokens: v } of S)
|
|
210
|
+
for (const A of D(v, 0, [])) {
|
|
211
|
+
const B = L(A, e, u);
|
|
212
|
+
i.push(B);
|
|
213
|
+
}
|
|
214
|
+
let w = `^(?:${i.join("|")})`;
|
|
215
|
+
return s && (w += `(?:${f(e)}$)?`), w += o ? "$" : `(?=${f(e)}|$)`, { regexp: new RegExp(w, p), keys: u };
|
|
216
|
+
}
|
|
217
|
+
function* D(n, t, e) {
|
|
218
|
+
if (t === n.length)
|
|
219
|
+
return yield e;
|
|
220
|
+
const o = n[t];
|
|
221
|
+
if (o.type === "group") {
|
|
222
|
+
const r = e.slice();
|
|
223
|
+
for (const s of D(o.tokens, 0, r))
|
|
224
|
+
yield* D(n, t + 1, s);
|
|
225
|
+
} else
|
|
226
|
+
e.push(o);
|
|
227
|
+
yield* D(n, t + 1, e);
|
|
228
|
+
}
|
|
229
|
+
function L(n, t, e) {
|
|
230
|
+
let o = "", r = "", s = !0;
|
|
231
|
+
for (let u = 0; u < n.length; u++) {
|
|
232
|
+
const i = n[u];
|
|
233
|
+
if (i.type === "text") {
|
|
234
|
+
o += f(i.value), r += i.value, s || (s = i.value.includes(t));
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (i.type === "param" || i.type === "wildcard") {
|
|
238
|
+
if (!s && !r)
|
|
239
|
+
throw new TypeError(`Missing text after "${i.name}": ${$}`);
|
|
240
|
+
i.type === "param" ? o += `(${q(t, s ? "" : r)}+)` : o += "([\\s\\S]+)", e.push(i), r = "", s = !1;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return o;
|
|
245
|
+
}
|
|
246
|
+
function q(n, t) {
|
|
247
|
+
return t.length < 2 ? n.length < 2 ? `[^${f(n + t)}]` : `(?:(?!${f(n)})[^${f(t)}])` : n.length < 2 ? `(?:(?!${f(t)})[^${f(n)}])` : `(?:(?!${f(t)}|${f(n)})[\\s\\S])`;
|
|
248
|
+
}
|
|
249
|
+
function k(n) {
|
|
250
|
+
return n.tokens.map(function t(e, o, r) {
|
|
251
|
+
if (e.type === "text")
|
|
252
|
+
return _(e.value);
|
|
253
|
+
if (e.type === "group")
|
|
254
|
+
return `{${e.tokens.map(t).join("")}}`;
|
|
255
|
+
const u = F(e.name) && V(r[o + 1]) ? e.name : JSON.stringify(e.name);
|
|
256
|
+
if (e.type === "param")
|
|
257
|
+
return `:${u}`;
|
|
258
|
+
if (e.type === "wildcard")
|
|
259
|
+
return `*${u}`;
|
|
260
|
+
throw new TypeError(`Unexpected token: ${e}`);
|
|
261
|
+
}).join("");
|
|
262
|
+
}
|
|
263
|
+
function F(n) {
|
|
264
|
+
const [t, ...e] = n;
|
|
265
|
+
return l.test(t) ? e.every((o) => h.test(o)) : !1;
|
|
266
|
+
}
|
|
267
|
+
function V(n) {
|
|
268
|
+
return n?.type !== "text" ? !0 : !h.test(n.value[0]);
|
|
269
|
+
}
|
|
270
|
+
return d;
|
|
271
|
+
}
|
|
272
|
+
var z = H();
|
|
273
|
+
const O = (c) => {
|
|
274
|
+
let a;
|
|
275
|
+
const l = /* @__PURE__ */ new Set(), h = (g, x) => {
|
|
276
|
+
const m = typeof g == "function" ? g(a) : g;
|
|
277
|
+
if (!Object.is(m, a)) {
|
|
278
|
+
const R = a;
|
|
279
|
+
a = x ?? (typeof m != "object" || m === null) ? m : Object.assign({}, a, m), l.forEach((T) => T(a, R));
|
|
280
|
+
}
|
|
281
|
+
}, $ = () => a, f = { setState: h, getState: $, getInitialState: () => I, subscribe: (g) => (l.add(g), () => l.delete(g)) }, I = a = c(h, $, f);
|
|
282
|
+
return f;
|
|
283
|
+
}, W = (c) => c ? O(c) : O, G = (c) => c;
|
|
284
|
+
function J(c, a = G) {
|
|
285
|
+
const l = C.useSyncExternalStore(
|
|
286
|
+
c.subscribe,
|
|
287
|
+
C.useCallback(() => a(c.getState()), [c, a]),
|
|
288
|
+
C.useCallback(() => a(c.getInitialState()), [c, a])
|
|
289
|
+
);
|
|
290
|
+
return C.useDebugValue(l), l;
|
|
291
|
+
}
|
|
292
|
+
const U = (c) => {
|
|
293
|
+
const a = W(c), l = (h) => J(a, h);
|
|
294
|
+
return Object.assign(l, a), l;
|
|
295
|
+
}, Q = (c) => c ? U(c) : U;
|
|
296
|
+
export {
|
|
297
|
+
Q as c,
|
|
298
|
+
z as d
|
|
299
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "flemo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A modern React router with smooth motion transitions and a seamless flow between screens",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"keywords": [
|
|
14
|
+
"flemo",
|
|
15
|
+
"react",
|
|
16
|
+
"react-router",
|
|
17
|
+
"motion",
|
|
18
|
+
"transition",
|
|
19
|
+
"page-transition",
|
|
20
|
+
"react-page-transition"
|
|
21
|
+
],
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "kimjh96",
|
|
24
|
+
"email": "kimjhs@kakao.com"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/kimjh96/flemo.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/kimjh96/flemo/issues",
|
|
32
|
+
"email": "kimjhs@kakao.com"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://flemo-web.vercel.app",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build",
|
|
38
|
+
"watch": "vite build --watch",
|
|
39
|
+
"prettier": "prettier --write --config ./.prettierrc \"**/*.{js,mjs,ts,jsx,tsx,mts,json}\"",
|
|
40
|
+
"convention": "pnpm prettier && eslint --fix \"**/*.{js,mjs,ts,jsx,tsx,mts,html}\"",
|
|
41
|
+
"prepare": "husky",
|
|
42
|
+
"prepublishOnly": "pnpm build"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"path-to-regexp": "^8.2.0",
|
|
46
|
+
"zustand": "^5.0.7"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@eslint/js": "^9.33.0",
|
|
50
|
+
"@types/node": "^24.3.0",
|
|
51
|
+
"@types/react": "^19.1.10",
|
|
52
|
+
"@types/react-dom": "^19.1.7",
|
|
53
|
+
"@vitejs/plugin-react-swc": "^4.0.0",
|
|
54
|
+
"eslint": "^9.33.0",
|
|
55
|
+
"eslint-config-prettier": "^10.1.8",
|
|
56
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
57
|
+
"eslint-plugin-import": "^2.32.0",
|
|
58
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
59
|
+
"eslint-plugin-react": "^7.37.5",
|
|
60
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
61
|
+
"globals": "^16.3.0",
|
|
62
|
+
"husky": "^9.1.7",
|
|
63
|
+
"lint-staged": "^16.1.5",
|
|
64
|
+
"prettier": "^3.6.2",
|
|
65
|
+
"typescript": "^5.9.2",
|
|
66
|
+
"typescript-eslint": "^8.39.1",
|
|
67
|
+
"vite": "^7.1.2",
|
|
68
|
+
"vite-plugin-dts": "^4.5.4"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"motion": "^12.0.0",
|
|
72
|
+
"react": "^19.0.0",
|
|
73
|
+
"react-dom": "^19.0.0"
|
|
74
|
+
},
|
|
75
|
+
"lint-staged": {
|
|
76
|
+
"*.{js,mjs,ts,jsx,tsx,mts,json}": "prettier --write",
|
|
77
|
+
"*.{js,mjs,ts,jsx,tsx,mts,html}": "eslint --fix"
|
|
78
|
+
}
|
|
79
|
+
}
|