@hamur/adapter-solid 0.0.0-stage → 0.0.2
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 +22 -0
- package/README.md +35 -2
- package/dist/chunks/browser-index-8rhv2s58.js +14 -0
- package/dist/chunks/browser-index-b05qbzsh.js +165 -0
- package/dist/chunks/browser-index-n80jt19y.js +114 -0
- package/dist/chunks/browser-index-ncnkshd9.js +39 -0
- package/dist/chunks/browser-index-r4jwfgh7.js +407 -0
- package/dist/src/adapter.js +556 -0
- package/dist/src/error-page.js +466 -0
- package/dist/src/index.js +1535 -0
- package/dist/src/keepalive.js +6 -0
- package/dist/src/runtime/client.js +174 -0
- package/dist/src/runtime/island.js +58 -0
- package/dist/src/runtime/server.js +138 -0
- package/dist/types/src/activation.d.ts +15 -0
- package/dist/types/src/adapter.d.ts +4 -0
- package/dist/types/src/async-data.d.ts +21 -0
- package/dist/types/src/client-component.d.ts +10 -0
- package/dist/types/src/client-fallback.d.ts +2 -0
- package/dist/types/src/context.d.ts +89 -0
- package/dist/types/src/error-page.d.ts +1 -0
- package/dist/types/src/index.d.ts +392 -0
- package/dist/types/src/island-html.d.ts +13 -0
- package/dist/types/src/island.d.ts +20 -0
- package/dist/types/src/jsx-locator.d.ts +6 -0
- package/dist/types/src/keepalive.d.ts +30 -0
- package/dist/types/src/lazy-hydration.d.ts +13 -0
- package/dist/types/src/markdown-page.d.ts +9 -0
- package/dist/types/src/markdown.d.ts +13 -0
- package/dist/types/src/plugin.d.ts +44 -0
- package/dist/types/src/runtime/client.d.ts +13 -0
- package/dist/types/src/runtime/hmr-solid.d.ts +5 -0
- package/dist/types/src/runtime/hmr.d.ts +27 -0
- package/dist/types/src/runtime/hydration-dev.d.ts +1 -0
- package/dist/types/src/runtime/hydration.d.ts +10 -0
- package/dist/types/src/runtime/island.d.ts +8 -0
- package/dist/types/src/runtime/portal.d.ts +13 -0
- package/dist/types/src/runtime/server.d.ts +14 -0
- package/dist/types/src/runtime/trusted.d.ts +2 -0
- package/dist/types/src/server-island.d.ts +10 -0
- package/dist/types/src/svg.d.ts +10 -0
- package/package.json +74 -4
- package/src/activation.ts +51 -0
- package/src/adapter.ts +42 -0
- package/src/async-data.ts +105 -0
- package/src/client-component.ts +40 -0
- package/src/client-fallback.ts +2 -0
- package/src/context.ts +495 -0
- package/src/env.d.ts +3 -0
- package/src/error-page.ts +1 -0
- package/src/index.ts +1900 -0
- package/src/island-html.ts +58 -0
- package/src/island.ts +55 -0
- package/src/jsx-locator.ts +199 -0
- package/src/keepalive.ts +147 -0
- package/src/lazy-hydration.ts +146 -0
- package/src/markdown-page.ts +18 -0
- package/src/markdown.ts +70 -0
- package/src/plugin.ts +310 -0
- package/src/runtime/client.ts +175 -0
- package/src/runtime/hmr-solid.ts +19 -0
- package/src/runtime/hmr.ts +231 -0
- package/src/runtime/hydration-dev.ts +41 -0
- package/src/runtime/hydration.ts +9 -0
- package/src/runtime/island.ts +66 -0
- package/src/runtime/portal.ts +64 -0
- package/src/runtime/server.ts +160 -0
- package/src/runtime/trusted.ts +16 -0
- package/src/server-island.ts +47 -0
- package/src/solid.d.ts +4 -0
- package/src/svg.ts +53 -0
- package/src/webmcp.d.ts +20 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Accessor, Component } from "solid-js";
|
|
2
|
+
import type { ComponentRenderContext, RenderContext, RenderResult } from "hamur/adapter";
|
|
3
|
+
import type { AppState } from "../context.ts";
|
|
4
|
+
/** The client's root guard, which the server renders too so the hydration keys agree; here it lets every failure through. */
|
|
5
|
+
export declare function guardedRoot(state: Accessor<AppState>): import("solid-js").Element;
|
|
6
|
+
export declare function render(ctx: RenderContext): Promise<RenderResult>;
|
|
7
|
+
/** `component` as a root of its own, its hydration keys under `<idPrefix>-` as `hydrateIsland` reads them, with each island inside it rendered in place. */
|
|
8
|
+
export declare function renderComponent(component: unknown, props: Record<string, unknown>, ctx: ComponentRenderContext): Promise<{
|
|
9
|
+
html: string;
|
|
10
|
+
}>;
|
|
11
|
+
/** The server side of a client-only component renders nothing. */
|
|
12
|
+
export declare function clientComponent(): Component<Record<string, unknown>>;
|
|
13
|
+
/** The server side of a server-only component: the component itself inside `hamur-component`, its props checked as the client sends them. */
|
|
14
|
+
export declare function serverComponent(name: string, component: Component<Record<string, unknown>>): Component<Record<string, unknown>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
export interface ServerIslandProps<P extends Record<string, unknown> = Record<string, unknown>> {
|
|
3
|
+
/** The name of a component under `app/server-islands/`. */
|
|
4
|
+
name: string;
|
|
5
|
+
props?: P;
|
|
6
|
+
/** Rendered with the page; replaced by the island's HTML once the browser has it. */
|
|
7
|
+
fallback?: JSX.Element;
|
|
8
|
+
}
|
|
9
|
+
/** A component rendered on the server in its own request; the page holds its fallback, the core swaps the answer in, and Solid never renders or hydrates it. */
|
|
10
|
+
export declare function ServerIsland<P extends Record<string, unknown> = Record<string, unknown>>(props: ServerIslandProps<P>): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,76 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hamur/adapter-solid",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/productdevbook/hamur.git",
|
|
9
|
+
"directory": "packages/adapter-solid"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/types/src/index.d.ts",
|
|
14
|
+
"bun": "./src/index.ts",
|
|
15
|
+
"hamur-source": "./src/index.ts",
|
|
16
|
+
"node": "./dist/src/index.js",
|
|
17
|
+
"default": "./src/index.ts"
|
|
18
|
+
},
|
|
19
|
+
"./adapter": {
|
|
20
|
+
"types": "./dist/types/src/adapter.d.ts",
|
|
21
|
+
"bun": "./src/adapter.ts",
|
|
22
|
+
"hamur-source": "./src/adapter.ts",
|
|
23
|
+
"node": "./dist/src/adapter.js",
|
|
24
|
+
"default": "./src/adapter.ts"
|
|
25
|
+
},
|
|
26
|
+
"./runtime/server": {
|
|
27
|
+
"types": "./dist/types/src/runtime/server.d.ts",
|
|
28
|
+
"bun": "./src/runtime/server.ts",
|
|
29
|
+
"hamur-source": "./src/runtime/server.ts",
|
|
30
|
+
"node": "./dist/src/runtime/server.js",
|
|
31
|
+
"default": "./src/runtime/server.ts"
|
|
32
|
+
},
|
|
33
|
+
"./runtime/client": {
|
|
34
|
+
"types": "./dist/types/src/runtime/client.d.ts",
|
|
35
|
+
"bun": "./src/runtime/client.ts",
|
|
36
|
+
"hamur-source": "./src/runtime/client.ts",
|
|
37
|
+
"node": "./dist/src/runtime/client.js",
|
|
38
|
+
"default": "./src/runtime/client.ts"
|
|
39
|
+
},
|
|
40
|
+
"./runtime/keepalive": {
|
|
41
|
+
"types": "./dist/types/src/keepalive.d.ts",
|
|
42
|
+
"bun": "./src/keepalive.ts",
|
|
43
|
+
"hamur-source": "./src/keepalive.ts",
|
|
44
|
+
"node": "./dist/src/keepalive.js",
|
|
45
|
+
"default": "./src/keepalive.ts"
|
|
46
|
+
},
|
|
47
|
+
"./runtime/island": {
|
|
48
|
+
"types": "./dist/types/src/runtime/island.d.ts",
|
|
49
|
+
"bun": "./src/runtime/island.ts",
|
|
50
|
+
"hamur-source": "./src/runtime/island.ts",
|
|
51
|
+
"node": "./dist/src/runtime/island.js",
|
|
52
|
+
"default": "./src/runtime/island.ts"
|
|
53
|
+
},
|
|
54
|
+
"./error-page": {
|
|
55
|
+
"types": "./dist/types/src/error-page.d.ts",
|
|
56
|
+
"bun": "./src/error-page.ts",
|
|
57
|
+
"hamur-source": "./src/error-page.ts",
|
|
58
|
+
"node": "./dist/src/error-page.js",
|
|
59
|
+
"default": "./src/error-page.ts"
|
|
60
|
+
},
|
|
61
|
+
"./package.json": "./package.json"
|
|
62
|
+
},
|
|
63
|
+
"files": [
|
|
64
|
+
"dist",
|
|
65
|
+
"src"
|
|
66
|
+
],
|
|
67
|
+
"dependencies": {},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"solid-js": "^2.0.4",
|
|
70
|
+
"@solidjs/web": "^2.0.4",
|
|
71
|
+
"@solidjs/babel-plugin": "^2.0.3",
|
|
72
|
+
"@babel/core": "^8.1.4",
|
|
73
|
+
"@babel/preset-typescript": "^8.0.7",
|
|
74
|
+
"hamur": "^0.0.2"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** The shown state of one keep-alive wrapper and the `onPageActivated`/`onPageDeactivated` functions under it. */
|
|
2
|
+
export interface Activation {
|
|
3
|
+
hidden: boolean
|
|
4
|
+
readonly parent: Activation | undefined
|
|
5
|
+
readonly children: Set<Activation>
|
|
6
|
+
readonly on: Set<() => void>
|
|
7
|
+
readonly off: Set<() => void>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function activation(parent: Activation | undefined, hidden: boolean): Activation {
|
|
11
|
+
const own: Activation = { hidden, parent, children: new Set(), on: new Set(), off: new Set() }
|
|
12
|
+
parent?.children.add(own)
|
|
13
|
+
return own
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function detach(own: Activation): void {
|
|
17
|
+
own.parent?.children.delete(own)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Whether a page under `own` is on screen: no wrapper above it is hidden. */
|
|
21
|
+
export function shown(own: Activation | undefined): boolean {
|
|
22
|
+
return !own || (!own.hidden && shown(own.parent))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let queue: Array<{ shown: boolean; fn: () => void }> | undefined
|
|
26
|
+
|
|
27
|
+
/** Runs `fn` once the commit is done; within one commit every deactivation runs before any activation, so a hide comes before the show it makes room for. */
|
|
28
|
+
export function later(isShown: boolean, fn: () => void): void {
|
|
29
|
+
if (!queue) {
|
|
30
|
+
queue = []
|
|
31
|
+
queueMicrotask(() => {
|
|
32
|
+
const run = queue!
|
|
33
|
+
queue = undefined
|
|
34
|
+
for (const item of run) if (!item.shown) item.fn()
|
|
35
|
+
for (const item of run) if (item.shown) item.fn()
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
queue.push({ shown: isShown, fn })
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function fire(own: Activation, isShown: boolean): void {
|
|
42
|
+
for (const fn of isShown ? own.on : own.off) later(isShown, fn)
|
|
43
|
+
for (const child of own.children) if (!child.hidden) fire(child, isShown)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function setHidden(own: Activation, hidden: boolean): void {
|
|
47
|
+
if (own.hidden === hidden) return
|
|
48
|
+
const before = shown(own)
|
|
49
|
+
own.hidden = hidden
|
|
50
|
+
if (shown(own) !== before) fire(own, !before)
|
|
51
|
+
}
|
package/src/adapter.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs"
|
|
2
|
+
import { ADAPTER_CONTRACT, defineAdapter } from "hamur/adapter"
|
|
3
|
+
import { clientComponentModule, serverComponentModule } from "hamur/adapter/build"
|
|
4
|
+
import { solidDevBuild, solidHydrationPlugin, solidPlugin } from "./plugin.ts"
|
|
5
|
+
import { svgComponent } from "./svg.ts"
|
|
6
|
+
import { markdownComponent } from "./markdown-page.ts"
|
|
7
|
+
|
|
8
|
+
/** The core's peer check only asks that each peer resolves, so a `solid-js` 1 left in the app would fail late inside the compiler. */
|
|
9
|
+
export function assertSolid2(rootDir: string): void {
|
|
10
|
+
const { version } = JSON.parse(readFileSync(Bun.resolveSync("solid-js/package.json", rootDir), "utf8")) as {
|
|
11
|
+
version: string
|
|
12
|
+
}
|
|
13
|
+
if (version.split(".")[0] === "2") return
|
|
14
|
+
throw new Error(
|
|
15
|
+
`@hamur/adapter-solid supports Solid 2 only: solid-js ${version} is installed in ${rootDir}. Install it with: bun add solid-js@latest @solidjs/web@latest @solidjs/babel-plugin@latest`,
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default defineAdapter({
|
|
20
|
+
name: "solid",
|
|
21
|
+
contract: ADAPTER_CONTRACT,
|
|
22
|
+
extensions: [".tsx", ".jsx"],
|
|
23
|
+
clientEntry: "@hamur/adapter-solid/runtime/client",
|
|
24
|
+
serverEntry: "@hamur/adapter-solid/runtime/server",
|
|
25
|
+
keepAliveOutlet: "@hamur/adapter-solid/runtime/keepalive",
|
|
26
|
+
islandEntry: "@hamur/adapter-solid/runtime/island",
|
|
27
|
+
errorPage: "@hamur/adapter-solid/error-page",
|
|
28
|
+
plugins: (ctx) => {
|
|
29
|
+
assertSolid2(ctx.rootDir)
|
|
30
|
+
return []
|
|
31
|
+
},
|
|
32
|
+
transforms: (ctx) => [
|
|
33
|
+
solidPlugin(ctx),
|
|
34
|
+
...(ctx.dev && ctx.target === "client" ? [solidDevBuild(ctx), solidHydrationPlugin()] : []),
|
|
35
|
+
],
|
|
36
|
+
peers: ["solid-js", "@solidjs/web", "@solidjs/babel-plugin", "@babel/core", "@babel/preset-typescript"],
|
|
37
|
+
trustedTypesPolicies: ["solid-trusted-html"],
|
|
38
|
+
svgComponent,
|
|
39
|
+
markdownComponent,
|
|
40
|
+
serverComponent: { module: (component) => serverComponentModule(component, "@hamur/adapter-solid/runtime") },
|
|
41
|
+
clientComponent: { module: (component) => clientComponentModule(component, "@hamur/adapter-solid/runtime") },
|
|
42
|
+
})
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { asyncDataKey, fetchKey, isPreviewMode } from "hamur/adapter"
|
|
2
|
+
import { $fetch } from "hamur/app"
|
|
3
|
+
import type { $Fetch, AppContext, AsyncDataOptions, FetchOptions } from "hamur/app"
|
|
4
|
+
import type { AsyncDataHandler, FetchRequest, GetCachedData, GetCachedDataCause, HandlerReference } from "hamur/adapter"
|
|
5
|
+
|
|
6
|
+
export const valueOf = <T>(value: T | (() => T)): T => (typeof value === "function" ? (value as () => T)() : value)
|
|
7
|
+
|
|
8
|
+
// A function is never a body to send, so a function `query` or `body` is a getter.
|
|
9
|
+
export function requestOf({ query, body, ...rest }: FetchRequest): FetchOptions {
|
|
10
|
+
const request: FetchOptions = rest
|
|
11
|
+
const resolvedQuery = valueOf(query)
|
|
12
|
+
const resolvedBody = valueOf(body)
|
|
13
|
+
if (resolvedQuery !== undefined) request.query = resolvedQuery
|
|
14
|
+
if (resolvedBody !== undefined) request.body = resolvedBody
|
|
15
|
+
return request
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** A getter `useFetch` key; each key's handler fetches the url and request that key was made from. */
|
|
19
|
+
export function fetchSlots<R>(
|
|
20
|
+
url: string | (() => string),
|
|
21
|
+
options: FetchRequest,
|
|
22
|
+
fetcher: $Fetch = $fetch,
|
|
23
|
+
fixedKey?: string,
|
|
24
|
+
): { keyOf: () => string; handlerFor: (key: string) => AsyncDataHandler<R> } {
|
|
25
|
+
const requests = new Map<string, { url: string; request: FetchOptions }>()
|
|
26
|
+
return {
|
|
27
|
+
keyOf() {
|
|
28
|
+
const target = valueOf(url)
|
|
29
|
+
const request = requestOf(options)
|
|
30
|
+
const key = fixedKey ?? fetchKey(target, request)
|
|
31
|
+
requests.set(key, { url: target, request })
|
|
32
|
+
return key
|
|
33
|
+
},
|
|
34
|
+
handlerFor(key) {
|
|
35
|
+
const { url: target, request } = requests.get(key)!
|
|
36
|
+
return ({ signal }) => fetcher<R>(target, { ...request, signal: signalOf(request.signal, signal) })
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The key of `useAsyncData(fn, input)` for the input as it reads now; each key's handler calls `fn` with the input that key was made from. */
|
|
42
|
+
export function handlerSlots<R>(
|
|
43
|
+
app: AppContext,
|
|
44
|
+
fn: HandlerReference,
|
|
45
|
+
input: unknown,
|
|
46
|
+
): { keyOf: () => string; handlerFor: (key: string) => AsyncDataHandler<R> } {
|
|
47
|
+
const inputs = new Map<string, unknown>()
|
|
48
|
+
return {
|
|
49
|
+
keyOf() {
|
|
50
|
+
const value = valueOf(input)
|
|
51
|
+
const key = asyncDataKey(fn, value)
|
|
52
|
+
inputs.set(key, value)
|
|
53
|
+
return key
|
|
54
|
+
},
|
|
55
|
+
handlerFor(key) {
|
|
56
|
+
const value = inputs.get(key)
|
|
57
|
+
return ({ signal }) =>
|
|
58
|
+
(fn as (input: unknown, init: { signal: AbortSignal; event: AppContext["event"] }) => Promise<R>)(value, {
|
|
59
|
+
signal,
|
|
60
|
+
event: app.event,
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The restored payload entry's data while the app hydrates, else `undefined`. */
|
|
67
|
+
export function defaultGetCachedData<T>(key: string, app: AppContext): T | undefined {
|
|
68
|
+
if (!app.asyncData.hydrating || isPreviewMode(app)) return undefined
|
|
69
|
+
const entry = app.asyncData.get<T>(key)
|
|
70
|
+
return entry?.status === "success" ? entry.data : undefined
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** `refresh()`, `execute()` and a `watch` change: ask `getCachedData` with their cause, run `handler` when it has nothing. */
|
|
74
|
+
export function refreshCached<T, R>(
|
|
75
|
+
app: AppContext,
|
|
76
|
+
key: string,
|
|
77
|
+
handler: AsyncDataHandler<R>,
|
|
78
|
+
options: AsyncDataOptions<T, R>,
|
|
79
|
+
getCachedData: GetCachedData<T>,
|
|
80
|
+
cause: GetCachedDataCause,
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
const cached = getCachedData(key, app, { cause })
|
|
83
|
+
if (cached !== undefined) {
|
|
84
|
+
app.asyncData.fetch<T, R>(key, handler, { ...options, cached })
|
|
85
|
+
return Promise.resolve()
|
|
86
|
+
}
|
|
87
|
+
if (!app.asyncData.has(key)) app.asyncData.fetch<T, R>(key, handler, { ...options, immediate: false })
|
|
88
|
+
return app.asyncData.refresh(key, handler)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const kept = new WeakMap<object, Set<string>>()
|
|
92
|
+
|
|
93
|
+
// Nuxt purges no entry whose caller reads it back through its own getCachedData: the entry is that cache.
|
|
94
|
+
export function keepCached<T>(app: AppContext, key: string, getCachedData: GetCachedData<T>): void {
|
|
95
|
+
if (getCachedData === defaultGetCachedData) return
|
|
96
|
+
let keys = kept.get(app.asyncData)
|
|
97
|
+
if (!keys) kept.set(app.asyncData, (keys = new Set()))
|
|
98
|
+
if (keys.has(key)) return
|
|
99
|
+
keys.add(key)
|
|
100
|
+
app.asyncData.subscribe(key, () => {})
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The run's signal, combined with a `signal` the caller gave to `useFetch`. */
|
|
104
|
+
export const signalOf = (own: AbortSignal | undefined, run: AbortSignal): AbortSignal =>
|
|
105
|
+
own ? AbortSignal.any([own, run]) : run
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Loading,
|
|
3
|
+
createComponent,
|
|
4
|
+
createContext,
|
|
5
|
+
createMemo,
|
|
6
|
+
createSignal,
|
|
7
|
+
lazy,
|
|
8
|
+
onSettled,
|
|
9
|
+
useContext,
|
|
10
|
+
} from "solid-js"
|
|
11
|
+
import type { Component } from "solid-js"
|
|
12
|
+
import type { JSX } from "@solidjs/web"
|
|
13
|
+
|
|
14
|
+
/** Set by `ClientOnly` around its children; a client-only component below shows its `fallback` while its chunk loads. */
|
|
15
|
+
export const ClientOnlyContext = createContext<{ readonly fallback: JSX.Element } | null>(null)
|
|
16
|
+
|
|
17
|
+
/** The client side of a client-only component: nothing in the hydration render, the file's chunk once mounted. */
|
|
18
|
+
export function clientComponent(
|
|
19
|
+
load: () => Promise<{ default: Component<Record<string, unknown>> }>,
|
|
20
|
+
): Component<Record<string, unknown>> {
|
|
21
|
+
const Loaded = lazy(load)
|
|
22
|
+
return (props) => {
|
|
23
|
+
const scope = useContext(ClientOnlyContext)
|
|
24
|
+
const [hydrated, setHydrated] = createSignal(scope !== null)
|
|
25
|
+
onSettled(() => {
|
|
26
|
+
setHydrated(true)
|
|
27
|
+
})
|
|
28
|
+
return createMemo(() => {
|
|
29
|
+
if (!hydrated()) return null
|
|
30
|
+
return createComponent(Loading, {
|
|
31
|
+
get fallback() {
|
|
32
|
+
return scope?.fallback ?? null
|
|
33
|
+
},
|
|
34
|
+
get children() {
|
|
35
|
+
return createComponent(Loaded, props)
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
}) as unknown as JSX.Element
|
|
39
|
+
}
|
|
40
|
+
}
|