@multiplatform.one/router 6.1.0 → 6.3.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.
Files changed (106) hide show
  1. package/README.md +51 -0
  2. package/dist/cjs/hooks/useUrlState.cjs +30 -9
  3. package/dist/cjs/hooks/useUrlState.native.js +32 -9
  4. package/dist/cjs/hooks/useUrlState.native.js.map +1 -1
  5. package/dist/cjs/seam/DomNavigationHost.cjs +122 -0
  6. package/dist/cjs/seam/DomNavigationHost.native.js +186 -0
  7. package/dist/cjs/seam/DomNavigationHost.native.js.map +1 -0
  8. package/dist/cjs/seam/index.cjs +47 -0
  9. package/dist/cjs/seam/index.native.js +50 -0
  10. package/dist/cjs/seam/index.native.js.map +1 -0
  11. package/dist/cjs/seam/navigator.cjs +309 -0
  12. package/dist/cjs/seam/navigator.native.js +479 -0
  13. package/dist/cjs/seam/navigator.native.js.map +1 -0
  14. package/dist/cjs/seam/oneAdapter.cjs +128 -0
  15. package/dist/cjs/seam/oneAdapter.native.js +141 -0
  16. package/dist/cjs/seam/oneAdapter.native.js.map +1 -0
  17. package/dist/esm/hooks/useUrlState.mjs +31 -10
  18. package/dist/esm/hooks/useUrlState.mjs.map +1 -1
  19. package/dist/esm/hooks/useUrlState.native.js +33 -10
  20. package/dist/esm/hooks/useUrlState.native.js.map +1 -1
  21. package/dist/esm/seam/DomNavigationHost.mjs +96 -0
  22. package/dist/esm/seam/DomNavigationHost.mjs.map +1 -0
  23. package/dist/esm/seam/DomNavigationHost.native.js +157 -0
  24. package/dist/esm/seam/DomNavigationHost.native.js.map +1 -0
  25. package/dist/esm/seam/index.mjs +5 -0
  26. package/dist/esm/seam/index.mjs.map +1 -0
  27. package/dist/esm/seam/index.native.js +5 -0
  28. package/dist/esm/seam/index.native.js.map +1 -0
  29. package/dist/esm/seam/navigator.mjs +279 -0
  30. package/dist/esm/seam/navigator.mjs.map +1 -0
  31. package/dist/esm/seam/navigator.native.js +446 -0
  32. package/dist/esm/seam/navigator.native.js.map +1 -0
  33. package/dist/esm/seam/oneAdapter.mjs +90 -0
  34. package/dist/esm/seam/oneAdapter.mjs.map +1 -0
  35. package/dist/esm/seam/oneAdapter.native.js +100 -0
  36. package/dist/esm/seam/oneAdapter.native.js.map +1 -0
  37. package/dist/jsx/hooks/useUrlState.mjs +31 -10
  38. package/dist/jsx/hooks/useUrlState.mjs.map +1 -1
  39. package/dist/jsx/hooks/useUrlState.native.js +32 -9
  40. package/dist/jsx/hooks/useUrlState.native.js.map +1 -1
  41. package/dist/jsx/seam/DomNavigationHost.mjs +96 -0
  42. package/dist/jsx/seam/DomNavigationHost.mjs.map +1 -0
  43. package/dist/jsx/seam/DomNavigationHost.native.js +186 -0
  44. package/dist/jsx/seam/DomNavigationHost.native.js.map +1 -0
  45. package/dist/jsx/seam/index.mjs +5 -0
  46. package/dist/jsx/seam/index.mjs.map +1 -0
  47. package/dist/jsx/seam/index.native.js +50 -0
  48. package/dist/jsx/seam/index.native.js.map +1 -0
  49. package/dist/jsx/seam/navigator.mjs +279 -0
  50. package/dist/jsx/seam/navigator.mjs.map +1 -0
  51. package/dist/jsx/seam/navigator.native.js +479 -0
  52. package/dist/jsx/seam/navigator.native.js.map +1 -0
  53. package/dist/jsx/seam/oneAdapter.mjs +90 -0
  54. package/dist/jsx/seam/oneAdapter.mjs.map +1 -0
  55. package/dist/jsx/seam/oneAdapter.native.js +141 -0
  56. package/dist/jsx/seam/oneAdapter.native.js.map +1 -0
  57. package/package.json +26 -9
  58. package/src/hooks/urlStateEdges.spec.ts +98 -0
  59. package/src/hooks/useUrlState.ts +34 -8
  60. package/src/seam/DomNavigationHost.spec.tsx +78 -0
  61. package/src/seam/DomNavigationHost.tsx +150 -0
  62. package/src/seam/index.ts +41 -0
  63. package/src/seam/navigator.spec.ts +189 -0
  64. package/src/seam/navigator.ts +405 -0
  65. package/src/seam/oneAdapter.tsx +166 -0
  66. package/types/hooks/index.d.ts +2 -0
  67. package/types/hooks/index.d.ts.map +1 -0
  68. package/types/hooks/useUrlState.d.ts +36 -0
  69. package/types/hooks/useUrlState.d.ts.map +1 -0
  70. package/types/index.d.ts +4 -0
  71. package/types/index.d.ts.map +1 -0
  72. package/types/index.storybook.d.ts +4 -0
  73. package/types/index.storybook.d.ts.map +1 -0
  74. package/types/router/EmptyRouter.d.ts +7 -0
  75. package/types/router/EmptyRouter.d.ts.map +1 -0
  76. package/types/router/ReactRouter.d.ts +6 -0
  77. package/types/router/ReactRouter.d.ts.map +1 -0
  78. package/types/router/index.d.ts +2 -0
  79. package/types/router/index.d.ts.map +1 -0
  80. package/types/router/index.storybook-expo.d.ts +2 -0
  81. package/types/router/index.storybook-expo.d.ts.map +1 -0
  82. package/types/router/index.storybook.d.ts +2 -0
  83. package/types/router/index.storybook.d.ts.map +1 -0
  84. package/types/router/index.webext.d.ts +2 -0
  85. package/types/router/index.webext.d.ts.map +1 -0
  86. package/types/seam/DomNavigationHost.d.ts +33 -0
  87. package/types/seam/DomNavigationHost.d.ts.map +1 -0
  88. package/types/seam/index.d.ts +7 -0
  89. package/types/seam/index.d.ts.map +1 -0
  90. package/types/seam/navigator.d.ts +133 -0
  91. package/types/seam/navigator.d.ts.map +1 -0
  92. package/types/seam/oneAdapter.d.ts +57 -0
  93. package/types/seam/oneAdapter.d.ts.map +1 -0
  94. package/types/types.d.ts +40 -0
  95. package/types/types.d.ts.map +1 -0
  96. package/dist/cjs/hooks/useUrlState.spec.cjs +0 -280
  97. package/dist/cjs/hooks/useUrlState.spec.native.js +0 -315
  98. package/dist/cjs/hooks/useUrlState.spec.native.js.map +0 -1
  99. package/dist/esm/hooks/useUrlState.spec.mjs +0 -257
  100. package/dist/esm/hooks/useUrlState.spec.mjs.map +0 -1
  101. package/dist/esm/hooks/useUrlState.spec.native.js +0 -289
  102. package/dist/esm/hooks/useUrlState.spec.native.js.map +0 -1
  103. package/dist/jsx/hooks/useUrlState.spec.mjs +0 -257
  104. package/dist/jsx/hooks/useUrlState.spec.mjs.map +0 -1
  105. package/dist/jsx/hooks/useUrlState.spec.native.js +0 -315
  106. package/dist/jsx/hooks/useUrlState.spec.native.js.map +0 -1
@@ -0,0 +1,166 @@
1
+ // DOM one-shim — One's router API backed by the stack-navigation seam.
2
+ //
3
+ // Alias the `one` package to THIS module in a DOM target's vite config
4
+ // (VS Code webview, webext views) and every consumer — feature screens,
5
+ // @package/layouts, the @multiplatform.one/router facade (whose default
6
+ // implementation re-exports from `one`) — rides the seam instead of One's
7
+ // real router runtime, which needs an address bar + One server runtime
8
+ // those hosts don't have. The GTK equivalent lives in
9
+ // apps/one/gnome/shims/one.ts (it renders Link over a GTK pressable and
10
+ // carries GJS probe instrumentation this DOM shim doesn't need).
11
+ //
12
+ // Exports beyond the router hooks exist to satisfy module resolution for
13
+ // everything the shared graph imports from `one`:
14
+ // - useUserScheme & friends re-export from @vxrn/color-scheme — One's
15
+ // own implementation IS that package, and it's browser-safe
16
+ // (localStorage + matchMedia).
17
+ // - LoadProgressBar/useMatches/Slot are inert placeholders: webview
18
+ // entries never mount One's root layout, but the barrels that reach
19
+ // them must still resolve.
20
+
21
+ import type { AnchorHTMLAttributes, MouseEvent, ReactNode } from "react";
22
+ import { useContext, useSyncExternalStore } from "react";
23
+ import {
24
+ RouteTagContext,
25
+ hrefToString,
26
+ stackNavigator,
27
+ useNavState,
28
+ useRouteParams,
29
+ type Href,
30
+ type NavParams,
31
+ } from "./navigator";
32
+
33
+ export {
34
+ getUserScheme,
35
+ onUserSchemeChange,
36
+ setUserScheme,
37
+ useUserScheme,
38
+ } from "@vxrn/color-scheme";
39
+
40
+ /** Loose stand-in for One's LoaderProps — loaders run through the seam's
41
+ * loader bridge on these targets, with the same shape One passes. */
42
+ export type LoaderProps<Params = Record<string, string | string[] | undefined>> = {
43
+ params: Params;
44
+ request?: Request;
45
+ };
46
+
47
+ export function useLoader<T>(_loader: (...args: never[]) => unknown): T | undefined {
48
+ const tag = useContext(RouteTagContext);
49
+ const fromRoute = useSyncExternalStore(stackNavigator.subscribe, () =>
50
+ stackNavigator.loaderSnapshot(tag),
51
+ );
52
+ return fromRoute as T | undefined;
53
+ }
54
+
55
+ // One's router object is referentially stable — consumers keep it in
56
+ // useCallback/useEffect dep arrays, so this shim's must be too. The surface
57
+ // matches the @multiplatform.one/router facade's Router contract (One's
58
+ // real router is a superset of it).
59
+ const ROUTER = {
60
+ push: stackNavigator.push,
61
+ navigate: stackNavigator.push,
62
+ replace: stackNavigator.replace,
63
+ back: stackNavigator.back,
64
+ canGoBack: () => stackNavigator.getSnapshot().canGoBack,
65
+ dismiss: (count?: number) => {
66
+ for (let i = 0; i < (count ?? 1); i++) stackNavigator.back();
67
+ },
68
+ dismissAll: () => {
69
+ const depth = stackNavigator.getSnapshot().depth;
70
+ for (let i = 1; i < depth; i++) stackNavigator.back();
71
+ },
72
+ canDismiss: () => stackNavigator.getSnapshot().canGoBack,
73
+ setParams: stackNavigator.setParams,
74
+ subscribe: (listener: (state: "success" | "error") => void) => {
75
+ listener("success");
76
+ return () => {};
77
+ },
78
+ onLoadState: (listener: (state: "loading" | "loaded") => void) => {
79
+ listener("loaded");
80
+ return () => {};
81
+ },
82
+ };
83
+
84
+ export function useRouter(): typeof ROUTER {
85
+ return ROUTER;
86
+ }
87
+
88
+ export interface LinkProps extends Omit<
89
+ AnchorHTMLAttributes<HTMLAnchorElement>,
90
+ "href" | "onClick"
91
+ > {
92
+ href?: Href;
93
+ replace?: boolean;
94
+ children?: ReactNode;
95
+ }
96
+
97
+ /** Navigation Link: an anchor that pushes `href` through the seam.
98
+ * Degrades to rendering children in place when no route manifest is
99
+ * configured (single-screen entries — no route stack exists there). */
100
+ export function Link({ href, replace, children, style, ...rest }: LinkProps): ReactNode {
101
+ if (!href || !stackNavigator.isConfigured) return children ?? null;
102
+ const hrefString = hrefToString(href);
103
+ const onClick = (event: MouseEvent<HTMLAnchorElement>) => {
104
+ event.preventDefault();
105
+ if (replace) stackNavigator.replace(href);
106
+ else stackNavigator.push(href);
107
+ };
108
+ return (
109
+ <a
110
+ href={hrefString}
111
+ onClick={onClick}
112
+ // display:contents — the anchor contributes no box, so wrapping
113
+ // arbitrary flex/grid children never disturbs layout (clicks still
114
+ // bubble through it).
115
+ style={{ display: "contents", color: "inherit", textDecoration: "none", ...style }}
116
+ data-seam-link={hrefString}
117
+ {...rest}
118
+ >
119
+ {children}
120
+ </a>
121
+ );
122
+ }
123
+
124
+ /** One's <Slot /> renders the active child route inside a layout. The seam
125
+ * has no nested-layout mounting — every route is its own host page — so
126
+ * layouts that render <Slot /> contribute chrome only; the child screen is
127
+ * mounted by the navigation host instead. Renders nothing by design. */
128
+ export function Slot(_props: Record<string, unknown>): null {
129
+ return null;
130
+ }
131
+
132
+ export function useParams(): NavParams {
133
+ return useRouteParams();
134
+ }
135
+
136
+ export function useLocalSearchParams(): NavParams {
137
+ return useRouteParams();
138
+ }
139
+
140
+ export function usePathname(): string {
141
+ return useNavState().pathname;
142
+ }
143
+
144
+ /** One's history-nav guard. The seam's hosts have no browser history to
145
+ * block (in-app navigation confirms dirty transitions itself), so this is
146
+ * a no-op that always reports "unblocked". Shape matches one/react-router's
147
+ * useBlocker return. */
148
+ export function useBlocker(_shouldBlock?: unknown): {
149
+ state: "unblocked" | "blocked" | "proceeding";
150
+ proceed: () => void;
151
+ reset: () => void;
152
+ } {
153
+ return { state: "unblocked", proceed: () => {}, reset: () => {} };
154
+ }
155
+
156
+ /** Inert stand-in for One's route-transition progress bar (SSR-era chrome
157
+ * with no meaning on a stack host). */
158
+ export function LoadProgressBar(_props: Record<string, unknown>): null {
159
+ return null;
160
+ }
161
+
162
+ /** One's useMatches returns the matched route chain; the seam mounts one
163
+ * page at a time, so consumers get an empty chain. */
164
+ export function useMatches(): unknown[] {
165
+ return [];
166
+ }
@@ -0,0 +1,2 @@
1
+ export { useSearchParams, useUrlState, useShareableUrl, useTypedSearchParams, type SearchParams, type SetSearchParamsOptions, } from "./useUrlState";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC"}
@@ -0,0 +1,36 @@
1
+ export type SearchParams = Record<string, string | string[] | undefined>;
2
+ export interface SetSearchParamsOptions {
3
+ replace?: boolean;
4
+ debounceMs?: number;
5
+ }
6
+ /**
7
+ * Cross-platform hook for managing URL search parameters
8
+ * Works with both React Router (web) and React Navigation (native)
9
+ */
10
+ export declare function useSearchParams(): [
11
+ SearchParams,
12
+ (params: SearchParams | ((prev: SearchParams) => SearchParams), options?: SetSearchParamsOptions) => void
13
+ ];
14
+ /**
15
+ * Hook for syncing form state with URL parameters
16
+ * Provides automatic serialization/deserialization and debouncing
17
+ */
18
+ export declare function useUrlState<T extends Record<string, any>>(defaultValues: T, options?: {
19
+ debounceMs?: number;
20
+ serialize?: (value: T) => SearchParams;
21
+ deserialize?: (params: SearchParams) => T;
22
+ }): [T, (newState: Partial<T> | ((prev: T) => Partial<T>)) => void];
23
+ /**
24
+ * Hook for creating shareable URLs with current state
25
+ */
26
+ export declare function useShareableUrl(): string;
27
+ /**
28
+ * Hook for parsing URL parameters with type safety
29
+ */
30
+ export declare function useTypedSearchParams<T extends Record<string, any>>(schema: {
31
+ [K in keyof T]: {
32
+ default: T[K];
33
+ parse?: (value: string | string[] | undefined) => T[K];
34
+ };
35
+ }): T;
36
+ //# sourceMappingURL=useUrlState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUrlState.d.ts","sourceRoot":"","sources":["../../src/hooks/useUrlState.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAEzE,MAAM,WAAW,sBAAsB;IACrC,OAAO,C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{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { useRouter, usePathname, useParams, Link } from "./router/EmptyRouter";
2
+ export * from "./types";
3
+ export * from "./hooks";
4
+ //# sourceMappingURL=index.storybook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.storybook.d.ts","sourceRoot":"","sources":["../src/index.storybook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC/E,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { LinkComponent, Router } from "../types";
2
+ export declare const useRouter: () => Router;
3
+ export declare const usePathname: () => string;
4
+ export declare const useParams: () => {};
5
+ export declare const Link: LinkComponent;
6
+ export declare function useUrlState<T extends Record<string, any>>(defaultValues: T): [T, (newState: Partial<T> | ((prev: T) => Partial<T>)) => void];
7
+ //# sourceMappingURL=EmptyRouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyRouter.d.ts","sourceRoot":"","sources":["../../src/router/EmptyRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAI5D,eAAO,MAAM,SAAS,QAAO,MAoB5B,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,MAAa,CAAC;AAE7C,eAAO,MAAM,SAAS,UAAa,CAAC;AAEpC,eAAO,MAAM,IAAI,EAAE,aAUlB,CAAC;AAIF,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACvD,aAAa,EAAE,CAAC,GACf,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAGjE"}
@@ -0,0 +1,6 @@
1
+ import type { LinkComponent, Router } from "../types";
2
+ export declare const useRouter: () => Router;
3
+ export declare const usePathname: () => string;
4
+ export declare const useParams: () => Record<string, string | string[] | undefined>;
5
+ export declare const Link: LinkComponent;
6
+ //# sourceMappingURL=ReactRouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactRouter.d.ts","sourceRoot":"","sources":["../../src/router/ReactRouter.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAIV,aAAa,EACb,MAAM,EACP,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,SAAS,QAAO,MAoC5B,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,MAAgC,CAAC;AAGhE,eAAO,MAAM,SAAS,qDAwBrB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,aAIlB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Link, useParams, usePathname, useRouter } from "one";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./EmptyRouter";
2
+ //# sourceMappingURL=index.storybook-expo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.storybook-expo.d.ts","sourceRoot":"","sources":["../../src/router/index.storybook-expo.tsx"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./EmptyRouter";
2
+ //# sourceMappingURL=index.storybook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.storybook.d.ts","sourceRoot":"","sources":["../../src/router/index.storybook.tsx"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./ReactRouter";
2
+ //# sourceMappingURL=index.webext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.webext.d.ts","sourceRoot":"","sources":["../../src/router/index.webext.tsx"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { CSSProperties, ReactNode } from "react";
2
+ import { type Href, type NavStackAdapter, type RouteDef } from "./navigator";
3
+ /** In-memory implementation of the host-stack protocol (the seam's
4
+ * NavStackAdapter mirrors Adw.NavigationView's method surface — see
5
+ * navigator.ts). */
6
+ export declare class DomStackAdapter implements NavStackAdapter {
7
+ private stack;
8
+ private readonly onChanged;
9
+ constructor(rootTag: string, onChanged: () => void);
10
+ push_by_tag(tag: string): void;
11
+ pop(): boolean;
12
+ pop_to_tag(tag: string): boolean;
13
+ replace_with_tags(tags: string[]): void;
14
+ get_navigation_stack(): {
15
+ get_n_items(): number;
16
+ get_item(index: number): {
17
+ get_tag(): string | null;
18
+ } | null;
19
+ };
20
+ }
21
+ export interface DomRouteEntry extends RouteDef {
22
+ element: ReactNode;
23
+ }
24
+ export interface DomNavigationHostProps {
25
+ routes: DomRouteEntry[];
26
+ /** Restore a previous route on mount (e.g. from vscode.getState()) —
27
+ * applied as a root replace, matching MemoryRouter initialEntries
28
+ * semantics (no back stack to it). */
29
+ initialHref?: Href;
30
+ style?: CSSProperties;
31
+ }
32
+ export declare function DomNavigationHost({ routes, initialHref, style, }: DomNavigationHostProps): ReactNode;
33
+ //# sourceMappingURL=DomNavigationHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomNavigationHost.d.ts","sourceRoot":"","sources":["../../src/seam/DomNavigationHost.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAIL,KAAK,IAAI,EACT,KAAK,eAAe,EACpB,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AAErB;;qBAEqB;AACrB,qBAAa,eAAgB,YAAW,eAAe;IACrD,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;gBAE3B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,IAAI;IAKlD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK9B,GAAG,IAAI,OAAO;IAOd,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAQhC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;IAKvC,oBAAoB,IAAI;QACtB,WAAW,IAAI,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG;YAAE,OAAO,IAAI,MAAM,GAAG,IAAI,CAAA;SAAE,GAAG,IAAI,CAAC;KAC9D;CAQF;AAED,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,OAAO,EAAE,SAAS,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB;;2CAEuC;IACvC,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAUD,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,WAAW,EACX,KAAK,GACN,EAAE,sBAAsB,GAAG,SAAS,CAwCpC"}
@@ -0,0 +1,7 @@
1
+ export { RouteTagContext, StackNavigator, hrefToString, stackNavigator, useNavState, useRouteParams, } from "./navigator";
2
+ export type { Href, NavParams, NavSnapshot, NavStackAdapter, RouteDef, RouteLoader, RouteLoaderProps, } from "./navigator";
3
+ export { DomNavigationHost, DomStackAdapter } from "./DomNavigationHost";
4
+ export type { DomNavigationHostProps, DomRouteEntry } from "./DomNavigationHost";
5
+ export { Link, LoadProgressBar, Slot, useBlocker, useLoader, useLocalSearchParams, useMatches, useParams, usePathname, useRouter, } from "./oneAdapter";
6
+ export type { LinkProps, LoaderProps } from "./oneAdapter";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/seam/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,eAAe,EACf,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,IAAI,EACJ,SAAS,EACT,WAAW,EACX,eAAe,EACf,QAAQ,EACR,WAAW,EACX,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,IAAI,EACJ,eAAe,EACf,IAAI,EACJ,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,133 @@
1
+ export type NavParams = Record<string, string | string[] | undefined>;
2
+ export interface RouteLoaderProps {
3
+ /** Resolved pathname, e.g. "/pokemon/bulbasaur". */
4
+ path: string;
5
+ /** Route params (dynamic segments + query). */
6
+ params: NavParams;
7
+ }
8
+ /** One-style route loader. On web, One resolves a route's loader before the
9
+ * client navigation completes; the seam mirrors that contract — see
10
+ * StackNavigator.navigate(). */
11
+ export type RouteLoader = (props: RouteLoaderProps) => unknown | Promise<unknown>;
12
+ export interface RouteDef {
13
+ /** One-style pattern: "/", "/pokemon", "/pokemon/[id]". */
14
+ pattern: string;
15
+ /** Host page tag AND stable route id. */
16
+ tag: string;
17
+ /** Page title (host chrome, e.g. the GTK header bar). */
18
+ title: string;
19
+ /** Optional data loader — resolved BEFORE the page mounts/shows (the
20
+ * loader bridge). Its result is what `useLoader` returns on this
21
+ * route's page. */
22
+ loader?: RouteLoader;
23
+ }
24
+ export type Href = string | {
25
+ pathname: string;
26
+ params?: Record<string, string | number>;
27
+ };
28
+ interface CompiledRoute extends RouteDef {
29
+ segments: {
30
+ literal?: string;
31
+ param?: string;
32
+ }[];
33
+ }
34
+ export interface NavSnapshot {
35
+ pathname: string;
36
+ tag: string;
37
+ depth: number;
38
+ canGoBack: boolean;
39
+ generation: number;
40
+ }
41
+ /** Structural view of the host navigation stack — everything the seam
42
+ * calls. The method names deliberately mirror Adw.NavigationView so the
43
+ * GTK target passes its widget straight through; DOM hosts implement the
44
+ * same protocol over an array (see DomNavigationHost). */
45
+ export interface NavStackAdapter {
46
+ push_by_tag(tag: string): void;
47
+ pop(): boolean;
48
+ pop_to_tag(tag: string): boolean;
49
+ replace_with_tags(tags: string[]): void;
50
+ get_navigation_stack(): {
51
+ get_n_items(): number;
52
+ get_item(index: number): {
53
+ get_tag(): string | null;
54
+ } | null;
55
+ };
56
+ }
57
+ export declare function hrefToString(href: Href): string;
58
+ export declare class StackNavigator {
59
+ private routes;
60
+ private host;
61
+ private listeners;
62
+ /** Stack mirror rebuilt from the host on every pushed/popped/replaced
63
+ * signal. */
64
+ private stackTags;
65
+ private paramsByTag;
66
+ private pathnameByTag;
67
+ /** Tags whose page content has been navigated to at least once. The host
68
+ * gates each page's React content on this (lazy mounting) — a tag enters
69
+ * the set right before its first host push and never leaves (backgrounded
70
+ * pages stay alive, same as One keeping stack screens mounted). */
71
+ private visitedTags;
72
+ /** Route-loader results, per tag (the loader bridge's store). */
73
+ private loaderDataByTag;
74
+ /** Monotonic navigation sequence — a loader that resolves after a NEWER
75
+ * navigation started must not perform its (stale) host action. */
76
+ private navSeq;
77
+ private generation;
78
+ private snapshot;
79
+ get isConfigured(): boolean;
80
+ /** Register the route manifest. The FIRST route is the root page. */
81
+ configure(defs: RouteDef[]): void;
82
+ /** Has this route's page been navigated to (⇒ its content may mount)? */
83
+ isVisited(tag: string | null): boolean;
84
+ /** The route's last loader result (stable identity until the loader runs
85
+ * again). undefined when the route has no loader / hasn't resolved. */
86
+ loaderSnapshot(tag: string | null): unknown;
87
+ /** Resolve a route's loader WITHOUT navigating. For the initial page:
88
+ * entries can `await stackNavigator.preload("/")` during top-level await
89
+ * (where GJS reliably drains promise jobs) so even the root page's first
90
+ * paint has loader data. */
91
+ preload(href: Href): Promise<void>;
92
+ /** Bind the live host stack (an Adw.NavigationView widget on GTK, a
93
+ * DomStackAdapter on DOM targets). */
94
+ attach(host: NavStackAdapter): void;
95
+ detach(): void;
96
+ subscribe: (fn: () => void) => (() => void);
97
+ getSnapshot: () => NavSnapshot;
98
+ paramsSnapshot(tag: string | null): NavParams;
99
+ match(href: Href): {
100
+ route: CompiledRoute;
101
+ pathname: string;
102
+ params: NavParams;
103
+ } | null;
104
+ push: (href: Href) => void;
105
+ replace: (href: Href) => void;
106
+ /** Shared push/replace flow, incl. the loader bridge. When the target
107
+ * route has no loader the whole body runs SYNCHRONOUSLY (an async
108
+ * function only yields at its first await), preserving the original
109
+ * timing. With a loader, the host action waits for the loader to resolve
110
+ * — same contract as One on web, where client navigation completes only
111
+ * after the route's loader data arrived — so the page's first paint has
112
+ * its data (and the lazily-mounted content mounts with it). */
113
+ private navigate;
114
+ back: () => void;
115
+ setParams: (params: Record<string, string>) => void;
116
+ /** Re-read the host navigation stack (called from pushed/popped/replaced
117
+ * signal handlers and attach). The host is the source of truth. */
118
+ syncFromHost: () => void;
119
+ private setRouteState;
120
+ private rebuildSnapshot;
121
+ }
122
+ /** The per-bundle navigator singleton. Every target build (GNOME entry,
123
+ * VS Code webview, webext view) is its own bundle, so module state is
124
+ * naturally per-target. */
125
+ export declare const stackNavigator: StackNavigator;
126
+ /** Set per page by the navigation host — useParams/useLocalSearchParams
127
+ * read the params of the page they render INSIDE, not the top of the
128
+ * stack. */
129
+ export declare const RouteTagContext: import("react").Context<string | null>;
130
+ export declare function useNavState(): NavSnapshot;
131
+ export declare function useRouteParams(): NavParams;
132
+ export {};
133
+ //# sourceMappingURL=navigator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigator.d.ts","sourceRoot":"","sources":["../../src/seam/navigator.ts"],"names":[],"mappings":"AAqCA,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,MAAM,EAAE,SAAS,CAAC;CACnB;AAED;;iCAEiC;AACjC,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAElF,MAAM,WAAW,QAAQ;IACvB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd;;wBAEoB;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;CAAE,CAAC;AAE3F,UAAU,aAAc,SAAQ,QAAQ;IACtC,QAAQ,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClD;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,UAA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IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAYxC;2CACuC;IACvC,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IAKnC,MAAM,IAAI,IAAI;IAId,SAAS,GAAI,IAAI,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAGxC;IAEF,WAAW,QAAO,WAAW,CAAkB;IAE/C,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAK7C,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG;QAAE,KAAK,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAE,GAAG,IAAI;IAyBvF,IAAI,GAAI,MAAM,IAAI,KAAG,IAAI,CAEvB;IAEF,OAAO,GAAI,MAAM,IAAI,KAAG,IAAI,CAE1B;IAEF;;;;;;oEAMgE;YAClD,QAAQ;IA+CtB,IAAI,QAAO,IAAI,CAWb;IAEF,SAAS,GAAI,QAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,IAAI,CAMhD;IAEF;wEACoE;IACpE,YAAY,QAAO,IAAI,CAmBrB;IAEF,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,eAAe;CAaxB;AAED;;4BAE4B;AAC5B,eAAO,MAAM,cAAc,gBAAuB,CAAC;AAEnD;;aAEa;AACb,eAAO,MAAM,eAAe,wCAAqC,CAAC;AAElE,wBAAgB,WAAW,IAAI,WAAW,CAEzC;AAED,wBAAgB,cAAc,IAAI,SAAS,CAG1C"}
@@ -0,0 +1,57 @@
1
+ import type { AnchorHTMLAttributes, ReactNode } from "react";
2
+ import { type Href, type NavParams } from "./navigator";
3
+ export { getUserScheme, onUserSchemeChange, setUserScheme, useUserScheme, } from "@vxrn/color-scheme";
4
+ /** Loose stand-in for One's LoaderProps — loaders run through the seam's
5
+ * loader bridge on these targets, with the same shape One passes. */
6
+ export type LoaderProps<Params = Record<string, string | string[] | undefined>> = {
7
+ params: Params;
8
+ request?: Request;
9
+ };
10
+ export declare function useLoader<T>(_loader: (...args: never[]) => unknown): T | undefined;
11
+ declare const ROUTER: {
12
+ push: (href: Href) => void;
13
+ navigate: (href: Href) => void;
14
+ replace: (href: Href) => void;
15
+ back: () => void;
16
+ canGoBack: () => boolean;
17
+ dismiss: (count?: number) => void;
18
+ dismissAll: () => void;
19
+ canDismiss: () => boolean;
20
+ setParams: (params: Record<string, string>) => void;
21
+ subscribe: (listener: (state: "success" | "error") => void) => () => void;
22
+ onLoadState: (listener: (state: "loading" | "loaded") => void) => () => void;
23
+ };
24
+ export declare function useRouter(): typeof ROUTER;
25
+ export interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href" | "onClick"> {
26
+ href?: Href;
27
+ replace?: boolean;
28
+ children?: ReactNode;
29
+ }
30
+ /** Navigation Link: an anchor that pushes `href` through the seam.
31
+ * Degrades to rendering children in place when no route manifest is
32
+ * configured (single-screen entries — no route stack exists there). */
33
+ export declare function Link({ href, replace, children, style, ...rest }: LinkProps): ReactNode;
34
+ /** One's <Slot /> renders the active child route inside a layout. The seam
35
+ * has no nested-layout mounting — every route is its own host page — so
36
+ * layouts that render <Slot /> contribute chrome only; the child screen is
37
+ * mounted by the navigation host instead. Renders nothing by design. */
38
+ export declare function Slot(_props: Record<string, unknown>): null;
39
+ export declare function useParams(): NavParams;
40
+ export declare function useLocalSearchParams(): NavParams;
41
+ export declare function usePathname(): string;
42
+ /** One's history-nav guard. The seam's hosts have no browser history to
43
+ * block (in-app navigation confirms dirty transitions itself), so this is
44
+ * a no-op that always reports "unblocked". Shape matches one/react-router's
45
+ * useBlocker return. */
46
+ export declare function useBlocker(_shouldBlock?: unknown): {
47
+ state: "unblocked" | "blocked" | "proceeding";
48
+ proceed: () => void;
49
+ reset: () => void;
50
+ };
51
+ /** Inert stand-in for One's route-transition progress bar (SSR-era chrome
52
+ * with no meaning on a stack host). */
53
+ export declare function LoadProgressBar(_props: Record<string, unknown>): null;
54
+ /** One's useMatches returns the matched route chain; the seam mounts one
55
+ * page at a time, so consumers get an empty chain. */
56
+ export declare function useMatches(): unknown[];
57
+ //# sourceMappingURL=oneAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneAdapter.d.ts","sourceRoot":"","sources":["../../src/seam/oneAdapter.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,oBAAoB,EAAc,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EAML,KAAK,IAAI,EACT,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B;sEACsE;AACtE,MAAM,MAAM,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,IAAI;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GAAG,CAAC,GAAG,SAAS,CAMlF;AAMD,QAAA,MAAM,MAAM;;;;;;sBAMQ,MAAM;;;;0BASF,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,KAAK,IAAI;4BAIlC,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ,KAAK,IAAI;CAI9D,CAAC;AAEF,wBAAgB,SAAS,IAAI,OAAO,MAAM,CAEzC;AAED,MAAM,WAAW,SAAU,SAAQ,IAAI,CACrC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,MAAM,GAAG,SAAS,CACnB;IACC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;wEAEwE;AACxE,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,GAAG,SAAS,CAsBtF;AAED;;;yEAGyE;AACzE,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAE1D;AAED,wBAAgB,SAAS,IAAI,SAAS,CAErC;AAED,wBAAgB,oBAAoB,IAAI,SAAS,CAEhD;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;yBAGyB;AACzB,wBAAgB,UAAU,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG;IAClD,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAEA;AAED;wCACwC;AACxC,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAErE;AAED;uDACuD;AACvD,wBAAgB,UAAU,IAAI,OAAO,EAAE,CAEtC"}
@@ -0,0 +1,40 @@
1
+ import type { OneRouter } from "one";
2
+ import type { CSSProperties, ReactElement, ReactNode } from "react";
3
+ export type Href = OneRouter.Href<{
4
+ __branded__: any;
5
+ }>;
6
+ export type LoadingState = "loading" | "loaded" | "error";
7
+ export type ResultState = "success" | "error";
8
+ export type RootStateListener = (state: ResultState) => void;
9
+ export type LoadingStateListener = (state: LoadingState) => void;
10
+ export type InputRouteParamsBlank = OneRouter.InputRouteParamsBlank;
11
+ export type InputRouteParams<T extends string> = OneRouter.InputRouteParams<T>;
12
+ export interface Router {
13
+ back: () => void;
14
+ canGoBack: () => boolean;
15
+ push: (href: Href) => void;
16
+ navigate: (href: Href) => void;
17
+ replace: (href: Href) => void;
18
+ dismiss: (count?: number) => void;
19
+ dismissAll: () => void;
20
+ canDismiss: () => boolean;
21
+ setParams: <T extends string = "">(params?: T extends "" ? InputRouteParamsBlank : InputRouteParams<T>) => void;
22
+ subscribe: (listener: RootStateListener) => () => void;
23
+ onLoadState: (listener: LoadingStateListener) => () => void;
24
+ }
25
+ export type UseRouter = () => Router;
26
+ export type UsePathname = () => string;
27
+ export type UseParams = () => Record<string, string | string[] | undefined>;
28
+ export interface LinkProps {
29
+ href: Href;
30
+ replace?: boolean;
31
+ children?: ReactNode;
32
+ style?: CSSProperties;
33
+ className?: string;
34
+ [key: string]: any;
35
+ }
36
+ export interface LinkComponent {
37
+ (props: LinkProps): ReactElement;
38
+ resolveHref: (href: Href) => string;
39
+ }
40
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpE,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;IAAE,WAAW,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AACxD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAC9C,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;AAC7D,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAEjE,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC,qBAAqB,CAAC;AACpE,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAE/E,MAAM,WAAW,MAAM;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