@typed/router 0.12.6 → 0.14.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/Link.d.ts +26 -11
- package/dist/Link.d.ts.map +1 -1
- package/dist/Link.js +47 -23
- package/dist/Link.js.map +1 -1
- package/dist/Match.d.ts +33 -0
- package/dist/Match.d.ts.map +1 -0
- package/dist/Match.js +16 -0
- package/dist/Match.js.map +1 -0
- package/dist/Matcher.d.ts +28 -0
- package/dist/Matcher.d.ts.map +1 -0
- package/dist/Matcher.js +24 -0
- package/dist/Matcher.js.map +1 -0
- package/dist/Navigation.d.ts +10 -0
- package/dist/Navigation.d.ts.map +1 -0
- package/dist/Navigation.js +7 -0
- package/dist/Navigation.js.map +1 -0
- package/dist/Redirect.d.ts +27 -0
- package/dist/Redirect.d.ts.map +1 -0
- package/dist/Redirect.js +17 -0
- package/dist/Redirect.js.map +1 -0
- package/dist/RouteOutlet.d.ts +3 -0
- package/dist/RouteOutlet.d.ts.map +1 -0
- package/dist/RouteOutlet.js +2 -0
- package/dist/RouteOutlet.js.map +1 -0
- package/dist/ScrollRestoration.d.ts +19 -0
- package/dist/ScrollRestoration.d.ts.map +1 -0
- package/dist/ScrollRestoration.js +64 -0
- package/dist/ScrollRestoration.js.map +1 -0
- package/dist/cjs/Link.d.ts +26 -11
- package/dist/cjs/Link.d.ts.map +1 -1
- package/dist/cjs/Link.js +47 -22
- package/dist/cjs/Link.js.map +1 -1
- package/dist/cjs/Match.d.ts +33 -0
- package/dist/cjs/Match.d.ts.map +1 -0
- package/dist/cjs/Match.js +43 -0
- package/dist/cjs/Match.js.map +1 -0
- package/dist/cjs/Matcher.d.ts +28 -0
- package/dist/cjs/Matcher.d.ts.map +1 -0
- package/dist/cjs/Matcher.js +52 -0
- package/dist/cjs/Matcher.js.map +1 -0
- package/dist/cjs/Navigation.d.ts +10 -0
- package/dist/cjs/Navigation.d.ts.map +1 -0
- package/dist/cjs/Navigation.js +34 -0
- package/dist/cjs/Navigation.js.map +1 -0
- package/dist/cjs/Redirect.d.ts +27 -0
- package/dist/cjs/Redirect.d.ts.map +1 -0
- package/dist/cjs/Redirect.js +44 -0
- package/dist/cjs/Redirect.js.map +1 -0
- package/dist/cjs/ScrollRestoration.d.ts +19 -0
- package/dist/cjs/ScrollRestoration.d.ts.map +1 -0
- package/dist/cjs/ScrollRestoration.js +91 -0
- package/dist/cjs/ScrollRestoration.js.map +1 -0
- package/dist/cjs/index.d.ts +7 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +7 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/matchRoutes.d.ts +8 -0
- package/dist/cjs/matchRoutes.d.ts.map +1 -0
- package/dist/cjs/matchRoutes.js +77 -0
- package/dist/cjs/matchRoutes.js.map +1 -0
- package/dist/cjs/router.d.ts +24 -63
- package/dist/cjs/router.d.ts.map +1 -1
- package/dist/cjs/router.js +22 -159
- package/dist/cjs/router.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/matchRoutes.d.ts +8 -0
- package/dist/matchRoutes.d.ts.map +1 -0
- package/dist/matchRoutes.js +50 -0
- package/dist/matchRoutes.js.map +1 -0
- package/dist/router.d.ts +24 -63
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +19 -153
- package/dist/router.js.map +1 -1
- package/dist/tsconfig.cjs.build.tsbuildinfo +1 -1
- package/package.json +12 -10
- package/project.json +12 -10
- package/src/Link.ts +129 -39
- package/src/Match.ts +114 -0
- package/src/Matcher.ts +139 -0
- package/src/Navigation.ts +24 -0
- package/src/Redirect.ts +21 -0
- package/src/ScrollRestoration.ts +110 -0
- package/src/index.ts +7 -3
- package/src/matchRoutes.ts +112 -0
- package/src/router.ts +56 -311
- package/tsconfig.build.json +5 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.cjs.build.json +6 -0
- package/tsconfig.json +6 -0
- package/vite.config.js +3 -0
- package/src/RouteMatch.ts +0 -56
- package/src/RouteMatcher.ts +0 -264
package/dist/router.d.ts
CHANGED
|
@@ -1,76 +1,37 @@
|
|
|
1
1
|
import * as Option from '@effect/data/Option';
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import * as Path from '@typed/path';
|
|
11
|
-
import * as Route from '@typed/route';
|
|
12
|
-
export interface Router<out R = never, out E = never, in out P extends string = string> {
|
|
2
|
+
import * as Layer from '@effect/io/Layer';
|
|
3
|
+
import { Tag } from '@typed/context';
|
|
4
|
+
import { GlobalThis, Window, DomServices } from '@typed/dom';
|
|
5
|
+
import { Filtered } from '@typed/fx';
|
|
6
|
+
import * as Navigation from '@typed/navigation';
|
|
7
|
+
import { ParamsOf, PathJoin } from '@typed/path';
|
|
8
|
+
import { Route } from '@typed/route';
|
|
9
|
+
export interface Router<in out P extends string = string> {
|
|
13
10
|
/**
|
|
14
|
-
* The base
|
|
11
|
+
* The base Route for this Router instance.
|
|
15
12
|
*/
|
|
16
|
-
readonly route: Route
|
|
13
|
+
readonly route: Route<P>;
|
|
17
14
|
/**
|
|
18
|
-
* The current
|
|
15
|
+
* The current params for the current path.
|
|
19
16
|
*/
|
|
20
|
-
readonly
|
|
17
|
+
readonly params: Filtered<never, never, ParamsOf<P>>;
|
|
21
18
|
/**
|
|
22
|
-
*
|
|
19
|
+
* Construct a new Router instance by defining a new Route which is concatenated
|
|
20
|
+
* to the current Route.
|
|
23
21
|
*/
|
|
24
|
-
readonly
|
|
22
|
+
readonly define: <P2 extends string>(route: Route<P2>) => Router<PathJoin<[P, P2]>>;
|
|
25
23
|
/**
|
|
26
|
-
* The
|
|
24
|
+
* The parent Router instance if one exists.
|
|
27
25
|
*/
|
|
28
|
-
readonly
|
|
26
|
+
readonly parent: Option.Option<Router<string>>;
|
|
29
27
|
/**
|
|
30
|
-
*
|
|
28
|
+
* The Navigation Service
|
|
31
29
|
*/
|
|
32
|
-
readonly
|
|
33
|
-
Path.Interpolate<Route.PathOf<R>, Route.ParamsOf<R>>,
|
|
34
|
-
Path.Interpolate<Route.PathOf<R2>, P>
|
|
35
|
-
]>>;
|
|
36
|
-
/**
|
|
37
|
-
* Helper for constructing a nested router
|
|
38
|
-
*/
|
|
39
|
-
readonly define: <R2, E2, Path2 extends string>(route: Route.Route<R2, E2, Path2>) => Router<R | R2, E | E2, Path.PathJoin<[P, Path2]>>;
|
|
40
|
-
/**
|
|
41
|
-
* The parent router if one exists
|
|
42
|
-
*/
|
|
43
|
-
readonly parent: Option.Option<Router<any, string>>;
|
|
44
|
-
/**
|
|
45
|
-
* Provide all the resources needed for a Router
|
|
46
|
-
*/
|
|
47
|
-
readonly provideContext: (environment: Context.Context<R>) => Router<never, E, P>;
|
|
48
|
-
}
|
|
49
|
-
export declare const Router: Context.Tag<Router<never, never, string>, Router<never, never, string>> & {
|
|
50
|
-
make: <R = never, E = never, P extends string = string>(route: Route.Route<R, E, P>, currentPath: Fx.RefSubject<never, string>, parent?: Option.Option<Router<any, any, string>>) => Router<R, E, P>;
|
|
51
|
-
};
|
|
52
|
-
export declare const outlet: Fx.Fx<RenderContext | Router, Redirect, html.Renderable>;
|
|
53
|
-
export declare const currentPath: Fx.Fx<Router, never, string>;
|
|
54
|
-
export declare function provideContext<R>(environment: Context.Context<R>): <E, P extends string>(router: Router<R, E, P>) => Router<never, E, P>;
|
|
55
|
-
export interface Redirect {
|
|
56
|
-
readonly _tag: 'Redirect';
|
|
57
|
-
readonly path: string;
|
|
58
|
-
}
|
|
59
|
-
export declare namespace Redirect {
|
|
60
|
-
const make: (path: string) => Redirect;
|
|
61
|
-
const is: (r: unknown) => r is Redirect;
|
|
62
|
-
}
|
|
63
|
-
export declare function redirect(path: string): Effect.Effect<never, Redirect, never>;
|
|
64
|
-
export declare namespace redirect {
|
|
65
|
-
var fx: (path: string) => Fx.Fx<never, Redirect, never>;
|
|
30
|
+
readonly navigation: Navigation.Navigation;
|
|
66
31
|
}
|
|
67
|
-
export declare const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export declare const
|
|
72
|
-
export declare const live: (currentPath?: Fx.RefSubject<never, string>) => Layer.Layer<Location | History | Window | Document, never, Router<never, never, string>>;
|
|
73
|
-
export declare function getCurrentPathFromLocation(location: Location | HTMLAnchorElement | URL): string;
|
|
74
|
-
export declare const getCurrentPath: Effect.Effect<Router<never, never, string>, never, string>;
|
|
75
|
-
export declare const getBasePath: Effect.Effect<Router<never, never, string>, never, string>;
|
|
32
|
+
export declare const Router: Tag<Router<string>, Router<string>>;
|
|
33
|
+
export declare const navigation: Layer.Layer<Navigation.Navigation, never, Router>;
|
|
34
|
+
export declare function getCurrentPathFromUrl(url: URL): string;
|
|
35
|
+
export declare const dom: (options?: Navigation.DomNavigationOptions) => Layer.Layer<GlobalThis | Window, never, DomServices | Navigation.Navigation | Router>;
|
|
36
|
+
export declare const memory: (options: Navigation.MemoryNavigationOptions) => Layer.Layer<never, never, Navigation.Navigation | Router>;
|
|
76
37
|
//# sourceMappingURL=router.d.ts.map
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAA;AAE7C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAA6B,MAAM,YAAY,CAAA;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,UA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AqB,GAAG,MAAM,CACC,CAAA"}
|
package/dist/router.js
CHANGED
|
@@ -1,163 +1,29 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
-
import { pipe } from '@effect/data/Function';
|
|
3
1
|
import * as Option from '@effect/data/Option';
|
|
4
2
|
import * as Effect from '@effect/io/Effect';
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import * as
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const createPath = (other, ...[params]) => Effect.gen(function* ($) {
|
|
16
|
-
const path = yield* $(currentPath.get);
|
|
17
|
-
const baseParams = yield* $(route.match(path));
|
|
18
|
-
if (Option.isNone(baseParams)) {
|
|
19
|
-
return yield* $(Effect.dieMessage(`Can not create path when the parent can not be matched.
|
|
20
|
-
Parent Route: ${route.path}
|
|
21
|
-
Current Route: ${other.path}
|
|
22
|
-
Current Path: ${path}`));
|
|
23
|
-
}
|
|
24
|
-
return route.concat(other).make({ ...baseParams.value, ...params });
|
|
25
|
-
});
|
|
3
|
+
import * as Layer from '@effect/io/Layer';
|
|
4
|
+
import { Tag } from '@typed/context';
|
|
5
|
+
import { domServices, localStorage } from '@typed/dom';
|
|
6
|
+
import * as Navigation from '@typed/navigation';
|
|
7
|
+
import { Route } from '@typed/route';
|
|
8
|
+
export const Router = Tag('Router');
|
|
9
|
+
export const navigation = Router.layer(Effect.gen(function* ($) {
|
|
10
|
+
const navigation = yield* $(Navigation.Navigation);
|
|
11
|
+
const currentPath = navigation.currentEntry.map((destination) => getCurrentPathFromUrl(destination.url));
|
|
12
|
+
function makeRouter(route, parent) {
|
|
26
13
|
const router = {
|
|
27
14
|
route,
|
|
28
|
-
|
|
29
|
-
params:
|
|
30
|
-
|
|
31
|
-
createPath: createPath,
|
|
32
|
-
define: (other) => makeRouter(route.concat(other), currentPath, Option.some(router)),
|
|
33
|
-
provideContext: (env) => provideContext(env)(router),
|
|
15
|
+
navigation,
|
|
16
|
+
params: currentPath.filterMap(route.match),
|
|
17
|
+
define: (other) => makeRouter(route.concat(other), Option.some(router)),
|
|
34
18
|
parent,
|
|
35
19
|
};
|
|
36
20
|
return router;
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
export const outlet = RenderContext.withFx(({ environment }) => Router.withFx((r) => environment === 'browser'
|
|
40
|
-
? r.outlet
|
|
41
|
-
: pipe(r.outlet, Fx.skipUntil((x) => x !== null), Fx.take(1))));
|
|
42
|
-
export const currentPath = Router.withFx((r) => r.currentPath);
|
|
43
|
-
export function provideContext(environment) {
|
|
44
|
-
return (router) => {
|
|
45
|
-
const provided = {
|
|
46
|
-
...router,
|
|
47
|
-
params: pipe(router.params, Fx.provideContext(environment)),
|
|
48
|
-
route: Route.provideContext(environment)(router.route),
|
|
49
|
-
createPath: ((other, ...params) => Effect.provideContext(environment)(router.createPath(other, ...params))),
|
|
50
|
-
provideContext: (env) => provideContext(env)(provided),
|
|
51
|
-
};
|
|
52
|
-
return provided;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
export var Redirect;
|
|
56
|
-
(function (Redirect) {
|
|
57
|
-
Redirect.make = (path) => ({ _tag: 'Redirect', path });
|
|
58
|
-
Redirect.is = (r) => typeof r === 'object' && r !== null && '_tag' in r && r._tag === 'Redirect';
|
|
59
|
-
})(Redirect || (Redirect = {}));
|
|
60
|
-
export function redirect(path) {
|
|
61
|
-
return Effect.fail(Redirect.make(path));
|
|
62
|
-
}
|
|
63
|
-
redirect.fx = (path) => Fx.fail(Redirect.make(path));
|
|
64
|
-
export const redirectTo = (route, ...[params]) => pipe(Router.withEffect((r) => r.createPath(route, params)), Effect.flatMap(redirect));
|
|
65
|
-
redirectTo.fx = (route, ...params) => pipe(Router.withEffect((r) => r.createPath(route, params)), Fx.fromEffect, Fx.switchMap(redirect.fx));
|
|
66
|
-
// TOOD: Add support for reading <base> tag for default Router path.
|
|
67
|
-
export const makeRouter = (currentPath) => Effect.gen(function* ($) {
|
|
68
|
-
const history = yield* $(History);
|
|
69
|
-
const location = yield* $(Location);
|
|
70
|
-
if (!currentPath) {
|
|
71
|
-
currentPath = Fx.RefSubject.unsafeMake(Effect.sync(() => getCurrentPathFromLocation(location)));
|
|
72
|
-
}
|
|
73
|
-
// Patch history events to emit an event when the path changes
|
|
74
|
-
const historyEvents = yield* $(patchHistory);
|
|
75
|
-
// Update the current path when events occur:
|
|
76
|
-
// - popstate
|
|
77
|
-
// - hashchange
|
|
78
|
-
// - history events
|
|
79
|
-
yield* $(Fx.mergeAll(addWindowListener('popstate'), addWindowListener('hashchange'), historyEvents),
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
81
|
-
Fx.switchMapEffect(() => currentPath.set(getCurrentPathFromLocation(location))), Fx.drain, Effect.forkScoped);
|
|
82
|
-
// Listen to path changes and update the current history location, if necessary
|
|
83
|
-
yield* $(pipe(currentPath, Fx.skipRepeats, Fx.observe((path) => Effect.sync(() => {
|
|
84
|
-
if (path !== getCurrentPathFromLocation(location)) {
|
|
85
|
-
history.pushState({}, '', path);
|
|
86
|
-
}
|
|
87
|
-
})), Effect.forkScoped));
|
|
88
|
-
// Find the configured base path
|
|
89
|
-
const document = yield* $(Document);
|
|
90
|
-
const base = document.querySelector('base');
|
|
91
|
-
const baseHref = base ? getBasePathFromHref(base.href) : '/';
|
|
92
|
-
// Make our base router
|
|
93
|
-
return Router.make(Route.Route(baseHref), currentPath);
|
|
94
|
-
});
|
|
95
|
-
export const live = (currentPath) => Router.layerScoped(makeRouter(currentPath));
|
|
96
|
-
export function getCurrentPathFromLocation(location) {
|
|
97
|
-
return location.pathname + location.search + location.hash;
|
|
98
|
-
}
|
|
99
|
-
export const getCurrentPath = Router.withEffect((r) => r.currentPath.get);
|
|
100
|
-
export const getBasePath = Router.with((r) => {
|
|
101
|
-
const routers = [r];
|
|
102
|
-
let current = r;
|
|
103
|
-
while (Option.isSome(current.parent)) {
|
|
104
|
-
current = current.parent.value;
|
|
105
|
-
routers.push(current);
|
|
106
|
-
}
|
|
107
|
-
return routers.reduceRight((acc, r) => Path.pathJoin(r.route.path, acc), '');
|
|
108
|
-
});
|
|
109
|
-
const patchHistory = Effect.gen(function* ($) {
|
|
110
|
-
const history = yield* $(History);
|
|
111
|
-
const historyEvents = Fx.makeSubject();
|
|
112
|
-
const runtime = yield* $(Effect.runtime());
|
|
113
|
-
const runFork = Runtime.runFork(runtime);
|
|
114
|
-
const cleanup = patchHistory_(history, () => runFork(historyEvents.event()));
|
|
115
|
-
// unpatch history upon finalization
|
|
116
|
-
yield* $(Effect.addFinalizer(() => Effect.sync(cleanup)));
|
|
117
|
-
return historyEvents;
|
|
118
|
-
});
|
|
119
|
-
function patchHistory_(history, sendEvent) {
|
|
120
|
-
const pushState = history.pushState.bind(history);
|
|
121
|
-
const replaceState = history.replaceState.bind(history);
|
|
122
|
-
const go = history.go.bind(history);
|
|
123
|
-
const back = history.back.bind(history);
|
|
124
|
-
const forward = history.forward.bind(history);
|
|
125
|
-
history.pushState = function (state, title, url) {
|
|
126
|
-
pushState(state, title, url);
|
|
127
|
-
sendEvent();
|
|
128
|
-
};
|
|
129
|
-
history.replaceState = function (state, title, url) {
|
|
130
|
-
replaceState(state, title, url);
|
|
131
|
-
sendEvent();
|
|
132
|
-
};
|
|
133
|
-
history.go = function (delta) {
|
|
134
|
-
go(delta);
|
|
135
|
-
sendEvent();
|
|
136
|
-
};
|
|
137
|
-
history.back = function () {
|
|
138
|
-
back();
|
|
139
|
-
sendEvent();
|
|
140
|
-
};
|
|
141
|
-
history.forward = function () {
|
|
142
|
-
forward();
|
|
143
|
-
sendEvent();
|
|
144
|
-
};
|
|
145
|
-
// Reset history to original state
|
|
146
|
-
return () => {
|
|
147
|
-
history.pushState = pushState;
|
|
148
|
-
history.replaceState = replaceState;
|
|
149
|
-
history.go = go;
|
|
150
|
-
history.back = back;
|
|
151
|
-
history.forward = forward;
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function getBasePathFromHref(href) {
|
|
155
|
-
try {
|
|
156
|
-
const url = new URL(href);
|
|
157
|
-
return getCurrentPathFromLocation(url);
|
|
158
|
-
}
|
|
159
|
-
catch {
|
|
160
|
-
return href;
|
|
161
21
|
}
|
|
22
|
+
return makeRouter(Route(navigation.base), Option.none());
|
|
23
|
+
}));
|
|
24
|
+
export function getCurrentPathFromUrl(url) {
|
|
25
|
+
return url.pathname + url.search + url.hash;
|
|
162
26
|
}
|
|
27
|
+
export const dom = (options) => Layer.provideMerge(localStorage, Layer.provideMerge(domServices, Layer.provideMerge(Navigation.dom(options), navigation)));
|
|
28
|
+
export const memory = (options) => Layer.provideMerge(Navigation.memory(options), navigation);
|
|
163
29
|
//# sourceMappingURL=router.js.map
|
package/dist/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAmC,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEvF,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AA8BpC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAS,QAAQ,CAAC,CAAA;AAE3C,MAAM,CAAC,MAAM,UAAU,GAAsD,MAAM,CAAC,KAAK,CACvF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;IACrB,MAAM,UAAU,GAAG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