kiru 0.50.0-preview.0 → 0.50.0-preview.1
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/components/lazy.d.ts.map +1 -1
- package/dist/components/lazy.js +11 -136
- package/dist/components/lazy.js.map +1 -1
- package/dist/components/suspense.d.ts +7 -6
- package/dist/components/suspense.d.ts.map +1 -1
- package/dist/components/suspense.js +1 -4
- package/dist/components/suspense.js.map +1 -1
- package/dist/constants.d.ts +1 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -2
- package/dist/constants.js.map +1 -1
- package/dist/hmr.d.ts +1 -0
- package/dist/hmr.d.ts.map +1 -1
- package/dist/hmr.js +7 -0
- package/dist/hmr.js.map +1 -1
- package/dist/recursiveRender.d.ts +6 -0
- package/dist/recursiveRender.d.ts.map +1 -0
- package/dist/recursiveRender.js +109 -0
- package/dist/recursiveRender.js.map +1 -0
- package/dist/renderToString.d.ts.map +1 -1
- package/dist/renderToString.js +6 -112
- package/dist/renderToString.js.map +1 -1
- package/dist/router/config.d.ts +3 -0
- package/dist/router/config.d.ts.map +1 -0
- package/dist/router/config.js +13 -0
- package/dist/router/config.js.map +1 -0
- package/dist/router/context.d.ts +15 -0
- package/dist/router/context.d.ts.map +1 -0
- package/dist/router/context.js +11 -0
- package/dist/router/context.js.map +1 -0
- package/dist/router/errors.d.ts +4 -0
- package/dist/router/errors.d.ts.map +1 -0
- package/dist/router/errors.js +7 -0
- package/dist/router/errors.js.map +1 -0
- package/dist/router/fileRouter.d.ts +48 -0
- package/dist/router/fileRouter.d.ts.map +1 -0
- package/dist/router/fileRouter.js +311 -0
- package/dist/router/fileRouter.js.map +1 -0
- package/dist/router/globals.d.ts +5 -0
- package/dist/router/globals.d.ts.map +1 -0
- package/dist/router/globals.js +4 -0
- package/dist/router/globals.js.map +1 -0
- package/dist/router/index.d.ts +7 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +7 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/link.d.ts +8 -0
- package/dist/router/link.d.ts.map +1 -0
- package/dist/router/link.js +15 -0
- package/dist/router/link.js.map +1 -0
- package/dist/router/types.d.ts +63 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.internal.d.ts +12 -0
- package/dist/router/types.internal.d.ts.map +1 -0
- package/dist/router/types.internal.js +2 -0
- package/dist/router/types.internal.js.map +1 -0
- package/dist/router/types.js +2 -0
- package/dist/router/types.js.map +1 -0
- package/dist/ssr/server.d.ts.map +1 -1
- package/dist/ssr/server.js +5 -109
- package/dist/ssr/server.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.utils.d.ts +1 -8
- package/dist/types.utils.d.ts.map +1 -1
- package/dist/utils/vdom.d.ts.map +1 -1
- package/dist/utils/vdom.js +2 -5
- package/dist/utils/vdom.js.map +1 -1
- package/package.json +4 -8
- package/src/components/lazy.ts +12 -169
- package/src/components/suspense.ts +8 -10
- package/src/constants.ts +0 -2
- package/src/hmr.ts +8 -0
- package/src/recursiveRender.ts +127 -0
- package/src/renderToString.ts +7 -137
- package/src/router/config.ts +15 -0
- package/src/router/context.ts +23 -0
- package/src/router/errors.ts +6 -0
- package/src/router/fileRouter.ts +475 -0
- package/src/router/globals.ts +5 -0
- package/src/router/index.ts +6 -0
- package/src/router/link.ts +32 -0
- package/src/router/types.internal.ts +14 -0
- package/src/router/types.ts +81 -0
- package/src/ssr/server.ts +6 -136
- package/src/types.ts +0 -2
- package/src/types.utils.ts +1 -14
- package/src/utils/vdom.ts +1 -5
- package/dist/components/router/index.d.ts +0 -3
- package/dist/components/router/index.d.ts.map +0 -1
- package/dist/components/router/index.js +0 -3
- package/dist/components/router/index.js.map +0 -1
- package/dist/components/router/route.d.ts +0 -46
- package/dist/components/router/route.d.ts.map +0 -1
- package/dist/components/router/route.js +0 -8
- package/dist/components/router/route.js.map +0 -1
- package/dist/components/router/router.d.ts +0 -62
- package/dist/components/router/router.d.ts.map +0 -1
- package/dist/components/router/router.js +0 -177
- package/dist/components/router/router.js.map +0 -1
- package/dist/components/router/routerUtils.d.ts +0 -5
- package/dist/components/router/routerUtils.d.ts.map +0 -1
- package/dist/components/router/routerUtils.js +0 -39
- package/dist/components/router/routerUtils.js.map +0 -1
- package/dist/ssr/hydrationBoundary.d.ts +0 -27
- package/dist/ssr/hydrationBoundary.d.ts.map +0 -1
- package/dist/ssr/hydrationBoundary.js +0 -30
- package/dist/ssr/hydrationBoundary.js.map +0 -1
- package/dist/ssr/index.d.ts +0 -2
- package/dist/ssr/index.d.ts.map +0 -1
- package/dist/ssr/index.js +0 -2
- package/dist/ssr/index.js.map +0 -1
- package/src/components/router/index.ts +0 -2
- package/src/components/router/route.ts +0 -51
- package/src/components/router/router.ts +0 -273
- package/src/components/router/routerUtils.ts +0 -49
- package/src/ssr/hydrationBoundary.ts +0 -63
- package/src/ssr/index.ts +0 -1
package/src/ssr/server.ts
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
1
1
|
import { Readable } from "node:stream"
|
|
2
2
|
import { Fragment } from "../element.js"
|
|
3
|
-
import { renderMode
|
|
4
|
-
import {
|
|
5
|
-
isVNode,
|
|
6
|
-
encodeHtmlEntities,
|
|
7
|
-
propsToElementAttributes,
|
|
8
|
-
isExoticType,
|
|
9
|
-
assertValidElementProps,
|
|
10
|
-
} from "../utils/index.js"
|
|
11
|
-
import { Signal } from "../signals/base.js"
|
|
12
|
-
import {
|
|
13
|
-
$HYDRATION_BOUNDARY,
|
|
14
|
-
$ERROR_BOUNDARY,
|
|
15
|
-
PREFETCHED_DATA_EVENT,
|
|
16
|
-
voidElements,
|
|
17
|
-
} from "../constants.js"
|
|
18
|
-
import { HYDRATION_BOUNDARY_MARKER } from "./hydrationBoundary.js"
|
|
3
|
+
import { renderMode } from "../globals.js"
|
|
4
|
+
import { PREFETCHED_DATA_EVENT } from "../constants.js"
|
|
19
5
|
import { __DEV__ } from "../env.js"
|
|
20
|
-
import
|
|
21
|
-
import { isSuspenseThrowValue } from "../components/suspense.js"
|
|
22
|
-
|
|
23
|
-
interface ServerRenderContext {
|
|
24
|
-
write: (chunk: string) => void
|
|
25
|
-
queuePendingData: (data: Kiru.StatefulPromise<unknown>[]) => void
|
|
26
|
-
}
|
|
6
|
+
import { recursiveRender, RecursiveRenderContext } from "../recursiveRender.js"
|
|
27
7
|
|
|
28
8
|
const PREFETCH_EVENTS_SETUP = `
|
|
29
9
|
<script type="text/javascript">
|
|
@@ -52,9 +32,9 @@ export function renderToReadableStream(element: JSX.Element): {
|
|
|
52
32
|
|
|
53
33
|
let immediate = ""
|
|
54
34
|
|
|
55
|
-
const ctx:
|
|
35
|
+
const ctx: RecursiveRenderContext = {
|
|
56
36
|
write: (chunk) => (immediate += chunk),
|
|
57
|
-
|
|
37
|
+
onPending(data) {
|
|
58
38
|
for (const promise of data) {
|
|
59
39
|
if (prefetchPromises.has(promise)) continue
|
|
60
40
|
prefetchPromises.add(promise)
|
|
@@ -76,7 +56,7 @@ export function renderToReadableStream(element: JSX.Element): {
|
|
|
76
56
|
|
|
77
57
|
const prev = renderMode.current
|
|
78
58
|
renderMode.current = "stream"
|
|
79
|
-
|
|
59
|
+
recursiveRender(ctx, rootNode, null, 0)
|
|
80
60
|
renderMode.current = prev
|
|
81
61
|
|
|
82
62
|
if (pendingWritePromises.length > 0) {
|
|
@@ -90,113 +70,3 @@ export function renderToReadableStream(element: JSX.Element): {
|
|
|
90
70
|
|
|
91
71
|
return { immediate, stream }
|
|
92
72
|
}
|
|
93
|
-
|
|
94
|
-
function renderToStream_internal(
|
|
95
|
-
ctx: ServerRenderContext,
|
|
96
|
-
el: unknown,
|
|
97
|
-
parent: Kiru.VNode | null,
|
|
98
|
-
idx: number
|
|
99
|
-
): void {
|
|
100
|
-
if (el === null || el === undefined || typeof el === "boolean") return
|
|
101
|
-
if (typeof el === "string") return ctx.write(encodeHtmlEntities(el))
|
|
102
|
-
if (typeof el === "number" || typeof el === "bigint")
|
|
103
|
-
return ctx.write(el.toString())
|
|
104
|
-
if (el instanceof Array)
|
|
105
|
-
return el.forEach((c, i) => renderToStream_internal(ctx, c, parent, i))
|
|
106
|
-
if (Signal.isSignal(el)) return ctx.write(String(el.peek()))
|
|
107
|
-
if (!isVNode(el)) return ctx.write(String(el))
|
|
108
|
-
|
|
109
|
-
el.parent = parent
|
|
110
|
-
el.depth = (parent?.depth ?? -1) + 1
|
|
111
|
-
el.index = idx
|
|
112
|
-
const { type, props = {} } = el
|
|
113
|
-
const children = props.children
|
|
114
|
-
|
|
115
|
-
if (type === "#text")
|
|
116
|
-
return ctx.write(encodeHtmlEntities(props.nodeValue ?? ""))
|
|
117
|
-
|
|
118
|
-
if (isExoticType(type)) {
|
|
119
|
-
if (type === $HYDRATION_BOUNDARY) {
|
|
120
|
-
ctx.write(`<!--${HYDRATION_BOUNDARY_MARKER}-->`)
|
|
121
|
-
renderToStream_internal(ctx, children, el, idx)
|
|
122
|
-
ctx.write(`<!--/${HYDRATION_BOUNDARY_MARKER}-->`)
|
|
123
|
-
return
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (type === $ERROR_BOUNDARY) {
|
|
127
|
-
let boundaryBuffer = ""
|
|
128
|
-
const localPromises = new Set<Kiru.StatefulPromise<unknown>>()
|
|
129
|
-
|
|
130
|
-
const boundaryCtx: ServerRenderContext = {
|
|
131
|
-
write(chunk) {
|
|
132
|
-
boundaryBuffer += chunk
|
|
133
|
-
},
|
|
134
|
-
queuePendingData(data) {
|
|
135
|
-
data.forEach((p) => localPromises.add(p))
|
|
136
|
-
},
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
renderToStream_internal(boundaryCtx, children, el, idx)
|
|
141
|
-
// flush successful render
|
|
142
|
-
ctx.write(boundaryBuffer)
|
|
143
|
-
// merge local promises into global queue
|
|
144
|
-
ctx.queuePendingData([...localPromises])
|
|
145
|
-
} catch (error) {
|
|
146
|
-
if (isSuspenseThrowValue(error)) {
|
|
147
|
-
throw error
|
|
148
|
-
}
|
|
149
|
-
const e = error instanceof Error ? error : new Error(String(error))
|
|
150
|
-
const { fallback, onError } = props as ErrorBoundaryNode["props"]
|
|
151
|
-
onError?.(e)
|
|
152
|
-
const fallbackContent =
|
|
153
|
-
typeof fallback === "function" ? fallback(e) : fallback
|
|
154
|
-
renderToStream_internal(ctx, fallbackContent, el, 0)
|
|
155
|
-
}
|
|
156
|
-
return
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// other exotic types
|
|
160
|
-
return renderToStream_internal(ctx, children, el, idx)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (typeof type !== "string") {
|
|
164
|
-
try {
|
|
165
|
-
hookIndex.current = 0
|
|
166
|
-
node.current = el
|
|
167
|
-
const res = type(props)
|
|
168
|
-
return renderToStream_internal(ctx, res, el, idx)
|
|
169
|
-
} catch (error) {
|
|
170
|
-
if (isSuspenseThrowValue(error)) {
|
|
171
|
-
const { fallback, pendingData } = error
|
|
172
|
-
if (pendingData) ctx.queuePendingData(pendingData)
|
|
173
|
-
renderToStream_internal(ctx, fallback, el, 0)
|
|
174
|
-
return
|
|
175
|
-
}
|
|
176
|
-
throw error
|
|
177
|
-
} finally {
|
|
178
|
-
node.current = null
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (__DEV__) assertValidElementProps(el)
|
|
183
|
-
const attrs = propsToElementAttributes(props)
|
|
184
|
-
ctx.write(`<${type}${attrs.length ? ` ${attrs}` : ""}>`)
|
|
185
|
-
|
|
186
|
-
if (voidElements.has(type)) return
|
|
187
|
-
|
|
188
|
-
if ("innerHTML" in props) {
|
|
189
|
-
ctx.write(
|
|
190
|
-
String(
|
|
191
|
-
Signal.isSignal(props.innerHTML)
|
|
192
|
-
? props.innerHTML.peek()
|
|
193
|
-
: props.innerHTML
|
|
194
|
-
)
|
|
195
|
-
)
|
|
196
|
-
} else if (Array.isArray(children)) {
|
|
197
|
-
children.forEach((c, i) => renderToStream_internal(ctx, c, el, i))
|
|
198
|
-
} else {
|
|
199
|
-
renderToStream_internal(ctx, children, el, 0)
|
|
200
|
-
}
|
|
201
|
-
ctx.write(`</${type}>`)
|
|
202
|
-
}
|
package/src/types.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
$CONTEXT_PROVIDER,
|
|
5
5
|
$ERROR_BOUNDARY,
|
|
6
6
|
$FRAGMENT,
|
|
7
|
-
$HYDRATION_BOUNDARY,
|
|
8
7
|
} from "./constants"
|
|
9
8
|
import type { KiruGlobalContext } from "./globalContext"
|
|
10
9
|
import type {
|
|
@@ -187,7 +186,6 @@ declare global {
|
|
|
187
186
|
| typeof $FRAGMENT
|
|
188
187
|
| typeof $CONTEXT_PROVIDER
|
|
189
188
|
| typeof $ERROR_BOUNDARY
|
|
190
|
-
| typeof $HYDRATION_BOUNDARY
|
|
191
189
|
|
|
192
190
|
interface VNode {
|
|
193
191
|
app?: AppContext
|
package/src/types.utils.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
$CONTEXT_PROVIDER,
|
|
3
|
-
$ERROR_BOUNDARY,
|
|
4
|
-
$FRAGMENT,
|
|
5
|
-
$HYDRATION_BOUNDARY,
|
|
6
|
-
} from "./constants"
|
|
7
|
-
import type { HydrationBoundaryMode } from "./ssr/hydrationBoundary"
|
|
1
|
+
import type { $CONTEXT_PROVIDER, $ERROR_BOUNDARY, $FRAGMENT } from "./constants"
|
|
8
2
|
import type { Signal } from "./signals"
|
|
9
3
|
import type { ErrorBoundaryProps } from "./components/errorBoundary"
|
|
10
4
|
|
|
@@ -41,13 +35,6 @@ export interface ErrorBoundaryNode extends Kiru.VNode {
|
|
|
41
35
|
error?: Error
|
|
42
36
|
}
|
|
43
37
|
|
|
44
|
-
export interface HydrationBoundaryNode extends Kiru.VNode {
|
|
45
|
-
type: typeof $HYDRATION_BOUNDARY
|
|
46
|
-
props: Kiru.VNode["props"] & {
|
|
47
|
-
mode: HydrationBoundaryMode
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
38
|
export interface FragmentNode extends Kiru.VNode {
|
|
52
39
|
type: typeof $FRAGMENT
|
|
53
40
|
}
|
package/src/utils/vdom.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
FLAG_DELETION,
|
|
4
4
|
$FRAGMENT,
|
|
5
5
|
$CONTEXT_PROVIDER,
|
|
6
|
-
$HYDRATION_BOUNDARY,
|
|
7
6
|
FLAG_PLACEMENT,
|
|
8
7
|
FLAG_UPDATE,
|
|
9
8
|
$ERROR_BOUNDARY,
|
|
@@ -57,10 +56,7 @@ function isVNode(thing: unknown): thing is Kiru.VNode {
|
|
|
57
56
|
|
|
58
57
|
function isExoticType(type: Kiru.VNode["type"]): type is Kiru.ExoticSymbol {
|
|
59
58
|
return (
|
|
60
|
-
type === $FRAGMENT ||
|
|
61
|
-
type === $CONTEXT_PROVIDER ||
|
|
62
|
-
type === $ERROR_BOUNDARY ||
|
|
63
|
-
type === $HYDRATION_BOUNDARY
|
|
59
|
+
type === $FRAGMENT || type === $CONTEXT_PROVIDER || type === $ERROR_BOUNDARY
|
|
64
60
|
)
|
|
65
61
|
}
|
|
66
62
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
interface RouteProps {
|
|
2
|
-
/**
|
|
3
|
-
* The path to match.
|
|
4
|
-
* @example
|
|
5
|
-
* ```tsx
|
|
6
|
-
* <Router>
|
|
7
|
-
* <Route path="/" element={<h1>Home</h1>} />
|
|
8
|
-
* <Route path="/:id" element={<UserProfile />} />
|
|
9
|
-
* </Router>
|
|
10
|
-
* //
|
|
11
|
-
* const UserProfile = () => {
|
|
12
|
-
* const router = useRouter()
|
|
13
|
-
* const { id } = router.params
|
|
14
|
-
* return <h1>{id}</h1>
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
path: string;
|
|
19
|
-
/**
|
|
20
|
-
* Allow url with additional segments being matched. Useful with nested routers.
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* <Route path="/profile" fallthrough element={<UserProfile />} />
|
|
24
|
-
* //
|
|
25
|
-
* const UserProfile = () => {
|
|
26
|
-
* return (
|
|
27
|
-
* <Router>
|
|
28
|
-
* <Route path="/" element={<UserDetails />} />
|
|
29
|
-
* <Route path="/update" element={<UserUpdateForm />} />
|
|
30
|
-
* </Router>
|
|
31
|
-
* )
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
fallthrough?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* The element to render.
|
|
38
|
-
*/
|
|
39
|
-
element: JSX.Element;
|
|
40
|
-
}
|
|
41
|
-
export declare function Route({ element }: RouteProps): JSX.Element;
|
|
42
|
-
export declare function isRoute(thing: unknown): thing is Kiru.VNode & {
|
|
43
|
-
props: RouteProps;
|
|
44
|
-
};
|
|
45
|
-
export {};
|
|
46
|
-
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/components/router/route.ts"],"names":[],"mappings":"AAEA,UAAU,UAAU;IAClB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC,OAAO,CAAA;CACrB;AACD,wBAAgB,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,UAAU,eAE5C;AAED,wBAAgB,OAAO,CACrB,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,IAAI,CAAC,KAAK,GAAG;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,CAE7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../src/components/router/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AA0C9C,MAAM,UAAU,KAAK,CAAC,EAAE,OAAO,EAAc;IAC3C,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,KAAc;IAEd,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAA;AAC/C,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { ElementProps } from "../../types.js";
|
|
2
|
-
export interface LinkProps extends Omit<ElementProps<"a">, "href"> {
|
|
3
|
-
/**
|
|
4
|
-
* The relative path to navigate to. If `inherit` is true,
|
|
5
|
-
* the path will be relative to the parent <Route> component.
|
|
6
|
-
*/
|
|
7
|
-
to: string;
|
|
8
|
-
/**
|
|
9
|
-
* Event handler called when the link is clicked.
|
|
10
|
-
* If you call `e.preventDefault()`, the navigation will not happen.
|
|
11
|
-
*/
|
|
12
|
-
onclick?: (e: Event) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Specifies whether to replace the current history entry
|
|
15
|
-
* instead of adding a new one.
|
|
16
|
-
*/
|
|
17
|
-
replace?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* If true, the path used for `to` will be relative to the parent <Route> component.
|
|
20
|
-
* @default false
|
|
21
|
-
*/
|
|
22
|
-
inherit?: boolean;
|
|
23
|
-
}
|
|
24
|
-
export declare function Link({ to, onclick, replace, inherit, ...props }: LinkProps): Kiru.VNode;
|
|
25
|
-
declare function setQuery(query: Record<string, string>): void;
|
|
26
|
-
/**
|
|
27
|
-
* Gets state and methods provided by a parent <Router>.
|
|
28
|
-
*
|
|
29
|
-
* @see https://kirujs.dev/docs/api/routing
|
|
30
|
-
*/
|
|
31
|
-
export declare function useRouter(): {
|
|
32
|
-
viewTransition: Kiru.RefObject<ViewTransition>;
|
|
33
|
-
params: Record<string, string>;
|
|
34
|
-
query: Record<string, string>;
|
|
35
|
-
setQuery: typeof setQuery;
|
|
36
|
-
};
|
|
37
|
-
export declare function navigate(to: string, options?: {
|
|
38
|
-
replace?: boolean;
|
|
39
|
-
}): null;
|
|
40
|
-
export interface RouterProps {
|
|
41
|
-
/**
|
|
42
|
-
* Base path for all routes in this router. Use this
|
|
43
|
-
* to add a prefix to all routes
|
|
44
|
-
*/
|
|
45
|
-
basePath?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Enable ViewTransition API for navigations
|
|
48
|
-
*/
|
|
49
|
-
transition?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Children to render - the only supported children are <Route> components
|
|
52
|
-
*/
|
|
53
|
-
children?: JSX.Children;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Main router component.
|
|
57
|
-
*
|
|
58
|
-
* @see https://kirujs.dev/docs/api/routing
|
|
59
|
-
*/
|
|
60
|
-
export declare function Router(props: RouterProps): JSX.Element;
|
|
61
|
-
export {};
|
|
62
|
-
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/components/router/router.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAQlD,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAChE;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IAC5B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AACD,wBAAgB,IAAI,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,cAuB1E;AAqBD,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAK9C;AAED;;;;GAIG;AACH,wBAAgB,SAAS;;;;;EAGxB;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,QAwBnE;AAED,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAA;CACxB;AAMD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,eAqHxC"}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { createElement } from "../../element.js";
|
|
2
|
-
import { useState, useMemo, useContext, useLayoutEffect, useRef, } from "../../hooks/index.js";
|
|
3
|
-
import { __DEV__ } from "../../env.js";
|
|
4
|
-
import { createContext } from "../../context.js";
|
|
5
|
-
import { isRoute } from "./route.js";
|
|
6
|
-
import { noop } from "../../utils/index.js";
|
|
7
|
-
import { node } from "../../globals.js";
|
|
8
|
-
import { flushSync, nextIdle } from "../../scheduler.js";
|
|
9
|
-
import { parsePathParams, parseSearchParams, routeMatchesPath, } from "./routerUtils.js";
|
|
10
|
-
export function Link({ to, onclick, replace, inherit, ...props }) {
|
|
11
|
-
const router = useContext(RouterContext, false);
|
|
12
|
-
const href = useMemo(() => {
|
|
13
|
-
if (!inherit || router.isDefault)
|
|
14
|
-
return to;
|
|
15
|
-
const parentPath = Object.entries(router.params).reduce((acc, [k, v]) => acc.replace(`:${k}`, v), router.routePath);
|
|
16
|
-
if (to === "/")
|
|
17
|
-
return parentPath;
|
|
18
|
-
return (parentPath + to).replaceAll(/\/+/g, "/");
|
|
19
|
-
}, [router.params, to, inherit]);
|
|
20
|
-
return createElement("a", {
|
|
21
|
-
...props,
|
|
22
|
-
href,
|
|
23
|
-
onclick: (e) => {
|
|
24
|
-
onclick?.(e);
|
|
25
|
-
if (e.defaultPrevented)
|
|
26
|
-
return;
|
|
27
|
-
e.preventDefault();
|
|
28
|
-
navigate(href, { replace });
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
const RouterContext = createContext({
|
|
33
|
-
viewTransition: { current: null },
|
|
34
|
-
queueSyncNav: noop,
|
|
35
|
-
params: {},
|
|
36
|
-
query: {},
|
|
37
|
-
routePath: "/",
|
|
38
|
-
isDefault: true,
|
|
39
|
-
});
|
|
40
|
-
RouterContext.displayName = "Router";
|
|
41
|
-
function setQuery(query) {
|
|
42
|
-
const url = new URL(window.location.href);
|
|
43
|
-
Object.entries(query).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
44
|
-
window.history.pushState({}, "", url.toString());
|
|
45
|
-
window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Gets state and methods provided by a parent <Router>.
|
|
49
|
-
*
|
|
50
|
-
* @see https://kirujs.dev/docs/api/routing
|
|
51
|
-
*/
|
|
52
|
-
export function useRouter() {
|
|
53
|
-
const { viewTransition, params, query } = useContext(RouterContext);
|
|
54
|
-
return { viewTransition, params, query, setQuery };
|
|
55
|
-
}
|
|
56
|
-
export function navigate(to, options) {
|
|
57
|
-
const doNav = () => {
|
|
58
|
-
window.history[options?.replace ? "replaceState" : "pushState"]({}, "", to);
|
|
59
|
-
window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
60
|
-
};
|
|
61
|
-
// not called during render, just do the navigation
|
|
62
|
-
if (!node.current)
|
|
63
|
-
return doNav(), null;
|
|
64
|
-
const routerCtx = useContext(RouterContext, false);
|
|
65
|
-
if (routerCtx.isDefault) {
|
|
66
|
-
/**
|
|
67
|
-
* called from a non-router-decendant - postpone
|
|
68
|
-
* until next tick to avoid race conditions
|
|
69
|
-
*/
|
|
70
|
-
return nextIdle(doNav), null;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* set the value of our router's syncNavCallback,
|
|
74
|
-
* causing it to be executed synchronously
|
|
75
|
-
* during the router's useLayoutEffect.
|
|
76
|
-
* consecutive calls to navigate will overwrite
|
|
77
|
-
* the previous value.
|
|
78
|
-
*/
|
|
79
|
-
return routerCtx.queueSyncNav(doNav), null;
|
|
80
|
-
}
|
|
81
|
-
const initLoc = () => ({
|
|
82
|
-
pathname: window.location.pathname,
|
|
83
|
-
search: window.location.search,
|
|
84
|
-
});
|
|
85
|
-
/**
|
|
86
|
-
* Main router component.
|
|
87
|
-
*
|
|
88
|
-
* @see https://kirujs.dev/docs/api/routing
|
|
89
|
-
*/
|
|
90
|
-
export function Router(props) {
|
|
91
|
-
const viewTransition = useRef(null);
|
|
92
|
-
const syncNavCallback = useRef(null);
|
|
93
|
-
const parentRouterContext = useContext(RouterContext, false);
|
|
94
|
-
const dynamicParentPath = parentRouterContext.isDefault
|
|
95
|
-
? null
|
|
96
|
-
: parentRouterContext.routePath;
|
|
97
|
-
const dynamicParentPathSegments = useMemo(() => dynamicParentPath?.split("/").filter(Boolean) || [], [dynamicParentPath]);
|
|
98
|
-
const [loc, setLoc] = useState(initLoc);
|
|
99
|
-
const query = useMemo(() => parseSearchParams(loc.search), [loc.search]);
|
|
100
|
-
const realPathSegments = useMemo(() => loc.pathname.split("/").filter(Boolean), [loc.pathname]);
|
|
101
|
-
useLayoutEffect(() => {
|
|
102
|
-
const handler = () => {
|
|
103
|
-
if (!document.startViewTransition || !props.transition) {
|
|
104
|
-
return setLoc({
|
|
105
|
-
pathname: window.location.pathname,
|
|
106
|
-
search: window.location.search,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
viewTransition.current = document.startViewTransition(() => {
|
|
110
|
-
setLoc({
|
|
111
|
-
pathname: window.location.pathname,
|
|
112
|
-
search: window.location.search,
|
|
113
|
-
});
|
|
114
|
-
flushSync();
|
|
115
|
-
});
|
|
116
|
-
viewTransition.current.finished.then(() => {
|
|
117
|
-
viewTransition.current = null;
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
window.addEventListener("popstate", handler);
|
|
121
|
-
return () => window.removeEventListener("popstate", handler);
|
|
122
|
-
}, []);
|
|
123
|
-
useLayoutEffect(() => {
|
|
124
|
-
if (syncNavCallback.current) {
|
|
125
|
-
syncNavCallback.current();
|
|
126
|
-
syncNavCallback.current = null;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
let fallbackRoute;
|
|
130
|
-
let route;
|
|
131
|
-
const _children = (Array.isArray(props.children) ? props.children : [props.children]).flat();
|
|
132
|
-
for (const child of _children) {
|
|
133
|
-
if (!isRoute(child))
|
|
134
|
-
continue;
|
|
135
|
-
if (child.props.path === "*") {
|
|
136
|
-
if (__DEV__) {
|
|
137
|
-
if (fallbackRoute) {
|
|
138
|
-
console.warn("[kiru]: More than one fallback route defined. Only the last one will be used.");
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
fallbackRoute = child;
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
const dynamicChildPathSegments = ((props.basePath || "") + child.props.path)
|
|
145
|
-
.split("/")
|
|
146
|
-
.filter(Boolean);
|
|
147
|
-
if (routeMatchesPath(dynamicParentPathSegments.concat(dynamicChildPathSegments), realPathSegments, child.props.fallthrough)) {
|
|
148
|
-
route = child;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
let parsedParams = {};
|
|
153
|
-
if (route) {
|
|
154
|
-
const dynamicChildPathSegments = ((props.basePath || "") + route.props.path)
|
|
155
|
-
.split("/")
|
|
156
|
-
.filter(Boolean);
|
|
157
|
-
parsedParams = parsePathParams(dynamicParentPathSegments.concat(dynamicChildPathSegments), realPathSegments);
|
|
158
|
-
}
|
|
159
|
-
const params = { ...parentRouterContext.params, ...parsedParams };
|
|
160
|
-
return RouterContext.Provider({
|
|
161
|
-
value: {
|
|
162
|
-
params,
|
|
163
|
-
query,
|
|
164
|
-
routePath: (dynamicParentPath || "") +
|
|
165
|
-
(props.basePath || "") +
|
|
166
|
-
(route?.props.path || ""),
|
|
167
|
-
basePath: props.basePath,
|
|
168
|
-
isDefault: false,
|
|
169
|
-
queueSyncNav: (callback) => {
|
|
170
|
-
syncNavCallback.current = callback;
|
|
171
|
-
},
|
|
172
|
-
viewTransition: viewTransition,
|
|
173
|
-
},
|
|
174
|
-
children: route ?? fallbackRoute ?? null,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
//# sourceMappingURL=router.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/components/router/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EACL,QAAQ,EACR,OAAO,EACP,UAAU,EACV,eAAe,EACf,MAAM,GACP,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,kB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dynamicPathSegments: string[], realPathSegments: string[], fallthrough?: boolean): boolean;
|
|
3
|
-
declare function parsePathParams(dynamicPathSegments: string[], realPathSegments: string[]): Record<string, string>;
|
|
4
|
-
declare function parseSearchParams(search: string): Record<string, string>;
|
|
5
|
-
//# sourceMappingURL=routerUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routerUtils.d.ts","sourceRoot":"","sources":["../../../src/components/router/routerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAA;AAE/D,iBAAS,gBAAgB,CACvB,mBAAmB,EAAE,MAAM,EAAE,EAC7B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,WAAW,CAAC,EAAE,OAAO,WAgBtB;AAED,iBAAS,eAAe,CACtB,mBAAmB,EAAE,MAAM,EAAE,EAC7B,gBAAgB,EAAE,MAAM,EAAE,0BAU3B;AAED,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,0BAWxC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export { routeMatchesPath, parsePathParams, parseSearchParams };
|
|
2
|
-
function routeMatchesPath(dynamicPathSegments, realPathSegments, fallthrough) {
|
|
3
|
-
if (!fallthrough && dynamicPathSegments.length < realPathSegments.length) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
for (let i = 0; i < dynamicPathSegments.length; i++) {
|
|
7
|
-
const segment = dynamicPathSegments[i];
|
|
8
|
-
if (segment.startsWith(":")) {
|
|
9
|
-
continue;
|
|
10
|
-
}
|
|
11
|
-
else if (segment !== realPathSegments[i]) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
function parsePathParams(dynamicPathSegments, realPathSegments) {
|
|
18
|
-
const params = {};
|
|
19
|
-
for (let i = 0; i < dynamicPathSegments.length; i++) {
|
|
20
|
-
const segment = dynamicPathSegments[i];
|
|
21
|
-
if (segment.startsWith(":")) {
|
|
22
|
-
params[segment.slice(1)] = realPathSegments[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return params;
|
|
26
|
-
}
|
|
27
|
-
function parseSearchParams(search) {
|
|
28
|
-
const parsed = {};
|
|
29
|
-
const str = search.split("?")[1];
|
|
30
|
-
if (!str || str === "")
|
|
31
|
-
return parsed;
|
|
32
|
-
const parts = str.split("&");
|
|
33
|
-
for (let i = 0; i < parts.length; i++) {
|
|
34
|
-
const [key, val] = parts[i].split("=");
|
|
35
|
-
parsed[key] = val;
|
|
36
|
-
}
|
|
37
|
-
return parsed;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=routerUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routerUtils.js","sourceRoot":"","sources":["../../../src/components/router/routerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAA;AAE/D,SAAS,gBAAgB,CACvB,mBAA6B,EAC7B,gBAA0B,EAC1B,WAAqB;IAErB,IAAI,CAAC,WAAW,IAAI,mBAAmB,CAAC,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC;QACzE,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpD,MAAM,OAAO,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;QACtC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,SAAQ;QACV,CAAC;aAAM,IAAI,OAAO,KAAK,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3C,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,eAAe,CACtB,mBAA6B,EAC7B,gBAA0B;IAE1B,MAAM,MAAM,GAA2B,EAAE,CAAA;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpD,MAAM,OAAO,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;QACtC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,MAAM,GAA2B,EAAE,CAAA;IACzC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAChC,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,MAAM,CAAA;IAErC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACtC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;IACnB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
type EventsArray = (keyof GlobalEventHandlersEventMap)[];
|
|
2
|
-
export declare const HYDRATION_BOUNDARY_MARKER = "kiru:h-boundary";
|
|
3
|
-
export declare const DEFAULT_INTERACTION_EVENTS: ["pointerdown", "keydown", "focus", "input"];
|
|
4
|
-
export type HydrationBoundaryMode = "eager" | "interaction";
|
|
5
|
-
export type HydrationBoundaryProps<T extends HydrationBoundaryMode> = {
|
|
6
|
-
/**
|
|
7
|
-
* Determines the strategy to use when hydrating the boundary.
|
|
8
|
-
* - `eager`: hydrate immediately.
|
|
9
|
-
* - `interaction`: hydrate upon the first user interaction.
|
|
10
|
-
* @default "eager"
|
|
11
|
-
*/
|
|
12
|
-
mode?: T;
|
|
13
|
-
children: JSX.Children;
|
|
14
|
-
} & (T extends "interaction" ? {
|
|
15
|
-
/**
|
|
16
|
-
* List of events that will trigger the hydration.
|
|
17
|
-
* @default ["pointerdown", "keydown", "focus", "input"]
|
|
18
|
-
*/
|
|
19
|
-
events?: EventsArray;
|
|
20
|
-
} : {});
|
|
21
|
-
export declare const HydrationBoundaryContext: Kiru.Context<{
|
|
22
|
-
mode: HydrationBoundaryMode;
|
|
23
|
-
events: string[];
|
|
24
|
-
}>;
|
|
25
|
-
export declare function Experimental_HydrationBoundary<T extends HydrationBoundaryMode>(props: HydrationBoundaryProps<T>): Kiru.VNode;
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=hydrationBoundary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hydrationBoundary.d.ts","sourceRoot":"","sources":["../../src/ssr/hydrationBoundary.ts"],"names":[],"mappings":"AAKA,KAAK,WAAW,GAAG,CAAC,MAAM,2BAA2B,CAAC,EAAE,CAAA;AAExD,eAAO,MAAM,yBAAyB,oBAAoB,CAAA;AAC1D,eAAO,MAAM,0BAA0B,8CAKP,CAAA;AAEhC,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,aAAa,CAAA;AAC3D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,qBAAqB,IAAI;IACpE;;;;;OAKG;IACH,IAAI,CAAC,EAAE,CAAC,CAAA;IACR,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAA;CACvB,GAAG,CAAC,CAAC,SAAS,aAAa,GACxB;IACE;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GACD,EAAE,CAAC,CAAA;AAEP,eAAO,MAAM,wBAAwB;UAC7B,qBAAqB;YACnB,MAAM,EAAE;EACT,CAAA;AAET,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,qBAAqB,EAC5E,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,cAqBjC"}
|