@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,174 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clientFallbackIds,
|
|
3
|
+
clientComponent2
|
|
4
|
+
} from "../../chunks/browser-index-ncnkshd9.js";
|
|
5
|
+
import {
|
|
6
|
+
AppContext,
|
|
7
|
+
appState,
|
|
8
|
+
installKeepAlive2,
|
|
9
|
+
Root
|
|
10
|
+
} from "../../chunks/browser-index-r4jwfgh7.js";
|
|
11
|
+
import {
|
|
12
|
+
trustTemplates
|
|
13
|
+
} from "../../chunks/browser-index-8rhv2s58.js";
|
|
14
|
+
|
|
15
|
+
// packages/adapter-solid/src/runtime/client.ts
|
|
16
|
+
import {
|
|
17
|
+
Errored,
|
|
18
|
+
createComponent,
|
|
19
|
+
createEffect,
|
|
20
|
+
createMemo,
|
|
21
|
+
createSignal,
|
|
22
|
+
createUniqueId,
|
|
23
|
+
flush,
|
|
24
|
+
omit,
|
|
25
|
+
onCleanup,
|
|
26
|
+
untrack,
|
|
27
|
+
useContext
|
|
28
|
+
} from "solid-js";
|
|
29
|
+
import { dynamic, hydrate as hydrateRoot, render as renderRoot } from "@solidjs/web";
|
|
30
|
+
import { setAdapterInstance } from "hamur/adapter";
|
|
31
|
+
import {
|
|
32
|
+
fetchServerComponent,
|
|
33
|
+
reportClientError,
|
|
34
|
+
serverComponentAttributes,
|
|
35
|
+
serverComponentProps,
|
|
36
|
+
takeServerHTML
|
|
37
|
+
} from "hamur/adapter";
|
|
38
|
+
|
|
39
|
+
// packages/adapter-solid/src/runtime/hydration.ts
|
|
40
|
+
var devHydration = {};
|
|
41
|
+
|
|
42
|
+
// packages/adapter-solid/src/runtime/client.ts
|
|
43
|
+
var setState;
|
|
44
|
+
var remount;
|
|
45
|
+
var remounting;
|
|
46
|
+
var starting;
|
|
47
|
+
var hydrationWatch;
|
|
48
|
+
var hydrationCanBeAborted = true;
|
|
49
|
+
var ServerComponentElement = dynamic(() => "hamur-component", { static: true });
|
|
50
|
+
function guarded(ctx, state) {
|
|
51
|
+
return createComponent(Errored, {
|
|
52
|
+
fallback: (error, reset) => {
|
|
53
|
+
const thrown = untrack(error);
|
|
54
|
+
if (remounting) {
|
|
55
|
+
remounting.error ??= { thrown };
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
hydrationWatch?.failed(thrown);
|
|
59
|
+
queueMicrotask(() => reportClientError(ctx.app, thrown, { render: true }));
|
|
60
|
+
createEffect(state, (current, previous) => {
|
|
61
|
+
if (current !== previous)
|
|
62
|
+
queueMicrotask(reset);
|
|
63
|
+
}, { defer: true });
|
|
64
|
+
return;
|
|
65
|
+
},
|
|
66
|
+
get children() {
|
|
67
|
+
return createComponent(Root, { state });
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function start(ctx, attach) {
|
|
72
|
+
trustTemplates();
|
|
73
|
+
const [state, set] = createSignal(appState(ctx));
|
|
74
|
+
setState = set;
|
|
75
|
+
ctx.app.error?.subscribe?.(() => set((current) => ({ ...current })));
|
|
76
|
+
const node = ctx.root;
|
|
77
|
+
const mountRoot = (attachRoot) => {
|
|
78
|
+
const dispose = attachRoot(() => guarded(ctx, state), node);
|
|
79
|
+
remount = () => {
|
|
80
|
+
dispose();
|
|
81
|
+
node.textContent = "";
|
|
82
|
+
remounting = {};
|
|
83
|
+
try {
|
|
84
|
+
mountRoot((fn, target) => renderRoot(fn, target));
|
|
85
|
+
const failed = remounting.error;
|
|
86
|
+
if (failed)
|
|
87
|
+
throw failed.thrown;
|
|
88
|
+
} finally {
|
|
89
|
+
remounting = undefined;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
mountRoot(attach);
|
|
94
|
+
}
|
|
95
|
+
function remountRoot() {
|
|
96
|
+
remount?.();
|
|
97
|
+
}
|
|
98
|
+
async function hydrate(ctx) {
|
|
99
|
+
await (starting = setAdapterInstance(ctx.app, null));
|
|
100
|
+
for (const portal of document.querySelectorAll("[data-hamur-portal]"))
|
|
101
|
+
portal.remove();
|
|
102
|
+
for (const id of Array.isArray(ctx.payload.clientFallback) ? ctx.payload.clientFallback : [])
|
|
103
|
+
clientFallbackIds.add(String(id));
|
|
104
|
+
hydrationWatch = devHydration.watch?.(ctx.root);
|
|
105
|
+
start(ctx, (fn, node) => hydrateRoot(fn, node));
|
|
106
|
+
hydrationWatch?.done(() => remount?.());
|
|
107
|
+
}
|
|
108
|
+
async function mount(ctx) {
|
|
109
|
+
await (starting = setAdapterInstance(ctx.app, null));
|
|
110
|
+
start(ctx, (fn, node) => renderRoot(fn, node));
|
|
111
|
+
}
|
|
112
|
+
function update(ctx) {
|
|
113
|
+
if (!setState && starting)
|
|
114
|
+
return starting.then(() => update(ctx));
|
|
115
|
+
if (!setState)
|
|
116
|
+
throw new Error("update() called before hydrate() or mount()");
|
|
117
|
+
setState(appState(ctx));
|
|
118
|
+
flush();
|
|
119
|
+
}
|
|
120
|
+
function serverComponent(name) {
|
|
121
|
+
return (props) => {
|
|
122
|
+
const app = useContext(AppContext)().app;
|
|
123
|
+
const uid = createUniqueId();
|
|
124
|
+
const text = createMemo(() => serverComponentProps(name, { ...omit(props, "children") }, props.children !== undefined));
|
|
125
|
+
const taken = takeServerHTML(app, uid, name);
|
|
126
|
+
const [view, setView] = createSignal(taken ?? "");
|
|
127
|
+
const [failed, setFailed] = createSignal();
|
|
128
|
+
let requested = taken === undefined ? undefined : "";
|
|
129
|
+
let head;
|
|
130
|
+
onCleanup(() => head?.dispose());
|
|
131
|
+
createEffect(text, (current) => {
|
|
132
|
+
if (requested === "")
|
|
133
|
+
requested = current;
|
|
134
|
+
if (current === requested)
|
|
135
|
+
return;
|
|
136
|
+
const controller = new AbortController;
|
|
137
|
+
fetchServerComponent(app, name, current, controller.signal).then((next) => {
|
|
138
|
+
if (controller.signal.aborted)
|
|
139
|
+
return;
|
|
140
|
+
head?.dispose();
|
|
141
|
+
head = next.head ? app.head.push(next.head) : undefined;
|
|
142
|
+
requested = current;
|
|
143
|
+
setView(() => next.html);
|
|
144
|
+
}, (error) => {
|
|
145
|
+
if (!controller.signal.aborted)
|
|
146
|
+
setFailed({ error });
|
|
147
|
+
});
|
|
148
|
+
return () => controller.abort();
|
|
149
|
+
});
|
|
150
|
+
return createMemo(() => {
|
|
151
|
+
const thrown = failed();
|
|
152
|
+
if (thrown)
|
|
153
|
+
throw thrown.error;
|
|
154
|
+
return createComponent(ServerComponentElement, {
|
|
155
|
+
name,
|
|
156
|
+
uid,
|
|
157
|
+
...serverComponentAttributes(name),
|
|
158
|
+
get innerHTML() {
|
|
159
|
+
return view();
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export {
|
|
166
|
+
clientComponent2 as clientComponent,
|
|
167
|
+
hydrate,
|
|
168
|
+
hydrationCanBeAborted,
|
|
169
|
+
installKeepAlive2 as installKeepAlive,
|
|
170
|
+
mount,
|
|
171
|
+
remountRoot,
|
|
172
|
+
serverComponent,
|
|
173
|
+
update
|
|
174
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
islandState,
|
|
3
|
+
Root
|
|
4
|
+
} from "../../chunks/browser-index-r4jwfgh7.js";
|
|
5
|
+
import {
|
|
6
|
+
trustTemplates
|
|
7
|
+
} from "../../chunks/browser-index-8rhv2s58.js";
|
|
8
|
+
|
|
9
|
+
// packages/adapter-solid/src/runtime/island.ts
|
|
10
|
+
import { Errored, createComponent, createSignal, untrack } from "solid-js";
|
|
11
|
+
import { hydrate, render } from "@solidjs/web";
|
|
12
|
+
import { reportClientError } from "hamur/adapter";
|
|
13
|
+
var disposers = new WeakMap;
|
|
14
|
+
var updaters = new WeakMap;
|
|
15
|
+
var root = (el, component, props, ctx) => {
|
|
16
|
+
const kept = {};
|
|
17
|
+
const [state, setState] = createSignal(islandState(component, props, ctx, kept));
|
|
18
|
+
updaters.set(el, (own) => setState(islandState(component, own, ctx, kept, true)));
|
|
19
|
+
return () => createComponent(Errored, {
|
|
20
|
+
fallback: (error) => {
|
|
21
|
+
reportClientError(ctx.app, untrack(error), { render: true });
|
|
22
|
+
return;
|
|
23
|
+
},
|
|
24
|
+
get children() {
|
|
25
|
+
return createComponent(Root, { state });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
function hydrateIsland(el, component, props, ctx) {
|
|
30
|
+
trustTemplates();
|
|
31
|
+
const marks = globalThis;
|
|
32
|
+
if (marks._$HY)
|
|
33
|
+
marks._$HY.done = false;
|
|
34
|
+
disposers.set(el, hydrate(root(el, component, props, ctx), el, { renderId: `${ctx.idPrefix}-` }));
|
|
35
|
+
}
|
|
36
|
+
function mountIsland(el, component, props, ctx) {
|
|
37
|
+
trustTemplates();
|
|
38
|
+
el.replaceChildren();
|
|
39
|
+
disposers.set(el, render(root(el, component, props, ctx), el));
|
|
40
|
+
const marks = globalThis;
|
|
41
|
+
const held = el.closest("[_hk]");
|
|
42
|
+
if (held)
|
|
43
|
+
marks._$HY?.completed?.add(held);
|
|
44
|
+
}
|
|
45
|
+
function unmountIsland(el) {
|
|
46
|
+
disposers.get(el)?.();
|
|
47
|
+
disposers.delete(el);
|
|
48
|
+
updaters.delete(el);
|
|
49
|
+
}
|
|
50
|
+
function updateIsland(el, props) {
|
|
51
|
+
updaters.get(el)?.(props);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
hydrateIsland,
|
|
55
|
+
mountIsland,
|
|
56
|
+
unmountIsland,
|
|
57
|
+
updateIsland
|
|
58
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
redirectOf,
|
|
3
|
+
serializableError,
|
|
4
|
+
originalOf,
|
|
5
|
+
appState,
|
|
6
|
+
islandState,
|
|
7
|
+
installKeepAlive2,
|
|
8
|
+
Root
|
|
9
|
+
} from "../../chunks/browser-index-r4jwfgh7.js";
|
|
10
|
+
import {
|
|
11
|
+
exports_keepalive
|
|
12
|
+
} from "../../chunks/browser-index-n80jt19y.js";
|
|
13
|
+
import {
|
|
14
|
+
lazyModules,
|
|
15
|
+
collectingIslands,
|
|
16
|
+
islandsSettled,
|
|
17
|
+
renderSettled
|
|
18
|
+
} from "../../chunks/browser-index-b05qbzsh.js";
|
|
19
|
+
|
|
20
|
+
// packages/adapter-solid/src/runtime/server.ts
|
|
21
|
+
import { Errored, NoHydration, createComponent, createUniqueId, omit, untrack } from "solid-js";
|
|
22
|
+
import { dynamic, generateHydrationScript, markSafeError, renderToStream, renderToString } from "@solidjs/web";
|
|
23
|
+
import { sharedConfig } from "solid-js/internal";
|
|
24
|
+
import {
|
|
25
|
+
cspHash,
|
|
26
|
+
renderInPasses,
|
|
27
|
+
serverComponentAttributes,
|
|
28
|
+
serverComponentProps,
|
|
29
|
+
setAdapterInstance
|
|
30
|
+
} from "hamur/adapter";
|
|
31
|
+
installKeepAlive2(exports_keepalive);
|
|
32
|
+
var ServerComponentElement = dynamic(() => "hamur-component", { static: true });
|
|
33
|
+
var onErrorOf = (app) => (error, { handling }) => handling === "failed" ? undefined : serializableError(app, error);
|
|
34
|
+
var maskedContexts = new WeakSet;
|
|
35
|
+
function maskRejections(app) {
|
|
36
|
+
const context = sharedConfig.context;
|
|
37
|
+
const serialize = context?.serialize;
|
|
38
|
+
if (!context || !serialize || maskedContexts.has(context))
|
|
39
|
+
return;
|
|
40
|
+
maskedContexts.add(context);
|
|
41
|
+
context.serialize = (id, value, ...rest) => {
|
|
42
|
+
const thenable = typeof value === "object" && value !== null && typeof value.then === "function";
|
|
43
|
+
const masked = thenable ? Promise.resolve(value).then(undefined, (error) => Promise.reject(markSafeError(serializableError(app, error)))) : value;
|
|
44
|
+
serialize.call(context, id, masked, ...rest);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function guardedRoot(state) {
|
|
48
|
+
return createComponent(Errored, {
|
|
49
|
+
fallback: (error) => {
|
|
50
|
+
throw originalOf(untrack(error));
|
|
51
|
+
},
|
|
52
|
+
get children() {
|
|
53
|
+
return createComponent(Root, { state });
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function render(ctx) {
|
|
58
|
+
await setAdapterInstance(ctx.app, null);
|
|
59
|
+
const base = appState(ctx);
|
|
60
|
+
const bare = ctx.route?.meta?.scripts === false;
|
|
61
|
+
const options = { ...ctx.nonce ? { nonce: ctx.nonce } : {}, onError: onErrorOf(ctx.app) };
|
|
62
|
+
const head = bare ? "" : generateHydrationScript(ctx.nonce ? { nonce: ctx.nonce } : {});
|
|
63
|
+
const hydration = ctx.scriptHashes && head.match(/^<script>([\s\S]*?)<\/script>/)?.[1];
|
|
64
|
+
if (hydration)
|
|
65
|
+
ctx.scriptHashes.push(await cspHash(hydration));
|
|
66
|
+
try {
|
|
67
|
+
return await renderInPasses({
|
|
68
|
+
app: ctx.app,
|
|
69
|
+
head: base.head,
|
|
70
|
+
async render(tracked) {
|
|
71
|
+
await lazyModules();
|
|
72
|
+
const teleports = {};
|
|
73
|
+
const app = () => {
|
|
74
|
+
maskRejections(ctx.app);
|
|
75
|
+
const root = () => guardedRoot(() => ({ ...base, head: tracked, teleports }));
|
|
76
|
+
return bare ? createComponent(NoHydration, {
|
|
77
|
+
get children() {
|
|
78
|
+
return root();
|
|
79
|
+
}
|
|
80
|
+
}) : root();
|
|
81
|
+
};
|
|
82
|
+
if (!ctx.stream) {
|
|
83
|
+
const pending = [];
|
|
84
|
+
const body = collectingIslands(pending, () => renderToString(app, options));
|
|
85
|
+
await islandsSettled(ctx.app, pending);
|
|
86
|
+
return { body, head, ...Object.keys(teleports).length ? { teleports } : {} };
|
|
87
|
+
}
|
|
88
|
+
const pending = [];
|
|
89
|
+
const body = collectingIslands(pending, () => renderToStream(app, options).readable);
|
|
90
|
+
if (pending.length)
|
|
91
|
+
await islandsSettled(ctx.app, pending);
|
|
92
|
+
return { body, head, teleports };
|
|
93
|
+
},
|
|
94
|
+
drop: ({ body }) => void (typeof body === "string" ? undefined : body.cancel())
|
|
95
|
+
});
|
|
96
|
+
} catch (error) {
|
|
97
|
+
throw redirectOf(error) ?? error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function renderComponent(component, props, ctx) {
|
|
101
|
+
await Promise.resolve();
|
|
102
|
+
await lazyModules();
|
|
103
|
+
const state = islandState(component, props, ctx);
|
|
104
|
+
try {
|
|
105
|
+
const html = await renderSettled(() => renderToString(() => guardedRoot(() => state), {
|
|
106
|
+
renderId: `${ctx.idPrefix}-`,
|
|
107
|
+
...ctx.nonce ? { nonce: ctx.nonce } : {},
|
|
108
|
+
onError: onErrorOf(ctx.app)
|
|
109
|
+
}));
|
|
110
|
+
return { html };
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw redirectOf(error) ?? error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function clientComponent() {
|
|
116
|
+
return () => null;
|
|
117
|
+
}
|
|
118
|
+
function serverComponent(name, component) {
|
|
119
|
+
return (props) => {
|
|
120
|
+
const uid = createUniqueId();
|
|
121
|
+
serverComponentProps(name, { ...omit(props, "children") }, props.children !== undefined);
|
|
122
|
+
return createComponent(ServerComponentElement, {
|
|
123
|
+
name,
|
|
124
|
+
uid,
|
|
125
|
+
...serverComponentAttributes(name),
|
|
126
|
+
get children() {
|
|
127
|
+
return createComponent(component, props);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
clientComponent,
|
|
134
|
+
guardedRoot,
|
|
135
|
+
render,
|
|
136
|
+
renderComponent,
|
|
137
|
+
serverComponent
|
|
138
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export declare function activation(parent: Activation | undefined, hidden: boolean): Activation;
|
|
10
|
+
export declare function detach(own: Activation): void;
|
|
11
|
+
/** Whether a page under `own` is on screen: no wrapper above it is hidden. */
|
|
12
|
+
export declare function shown(own: Activation | undefined): boolean;
|
|
13
|
+
/** 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. */
|
|
14
|
+
export declare function later(isShown: boolean, fn: () => void): void;
|
|
15
|
+
export declare function setHidden(own: Activation, hidden: boolean): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** 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. */
|
|
2
|
+
export declare function assertSolid2(rootDir: string): void;
|
|
3
|
+
declare const _default: import("hamur/adapter").Adapter;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { $Fetch, AppContext, AsyncDataOptions, FetchOptions } from "hamur/app";
|
|
2
|
+
import type { AsyncDataHandler, FetchRequest, GetCachedData, GetCachedDataCause, HandlerReference } from "hamur/adapter";
|
|
3
|
+
export declare const valueOf: <T>(value: T | (() => T)) => T;
|
|
4
|
+
export declare function requestOf({ query, body, ...rest }: FetchRequest): FetchOptions;
|
|
5
|
+
/** A getter `useFetch` key; each key's handler fetches the url and request that key was made from. */
|
|
6
|
+
export declare function fetchSlots<R>(url: string | (() => string), options: FetchRequest, fetcher?: $Fetch, fixedKey?: string): {
|
|
7
|
+
keyOf: () => string;
|
|
8
|
+
handlerFor: (key: string) => AsyncDataHandler<R>;
|
|
9
|
+
};
|
|
10
|
+
/** 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. */
|
|
11
|
+
export declare function handlerSlots<R>(app: AppContext, fn: HandlerReference, input: unknown): {
|
|
12
|
+
keyOf: () => string;
|
|
13
|
+
handlerFor: (key: string) => AsyncDataHandler<R>;
|
|
14
|
+
};
|
|
15
|
+
/** The restored payload entry's data while the app hydrates, else `undefined`. */
|
|
16
|
+
export declare function defaultGetCachedData<T>(key: string, app: AppContext): T | undefined;
|
|
17
|
+
/** `refresh()`, `execute()` and a `watch` change: ask `getCachedData` with their cause, run `handler` when it has nothing. */
|
|
18
|
+
export declare function refreshCached<T, R>(app: AppContext, key: string, handler: AsyncDataHandler<R>, options: AsyncDataOptions<T, R>, getCachedData: GetCachedData<T>, cause: GetCachedDataCause): Promise<void>;
|
|
19
|
+
export declare function keepCached<T>(app: AppContext, key: string, getCachedData: GetCachedData<T>): void;
|
|
20
|
+
/** The run's signal, combined with a `signal` the caller gave to `useFetch`. */
|
|
21
|
+
export declare const signalOf: (own: AbortSignal | undefined, run: AbortSignal) => AbortSignal;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Component } from "solid-js";
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
/** Set by `ClientOnly` around its children; a client-only component below shows its `fallback` while its chunk loads. */
|
|
4
|
+
export declare const ClientOnlyContext: import("solid-js").Context<{
|
|
5
|
+
readonly fallback: JSX.Element;
|
|
6
|
+
} | null>;
|
|
7
|
+
/** The client side of a client-only component: nothing in the hydration render, the file's chunk once mounted. */
|
|
8
|
+
export declare function clientComponent(load: () => Promise<{
|
|
9
|
+
default: Component<Record<string, unknown>>;
|
|
10
|
+
}>): Component<Record<string, unknown>>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Accessor } from "solid-js";
|
|
2
|
+
import { type JSX } from "@solidjs/web";
|
|
3
|
+
import type { AppContext as HamurApp, ErrorPageProps, Head, HamurRedirect } from "hamur/app";
|
|
4
|
+
import type { ClientContext, FormStatusStore, NavigationState, RenderContext, RenderTree, ResolvedRoute, RouteValue, RouterApi } from "hamur/adapter";
|
|
5
|
+
import { type RouterSource } from "hamur/adapter";
|
|
6
|
+
import type { RouteLocation } from "hamur/app";
|
|
7
|
+
import { type Activation } from "./activation.ts";
|
|
8
|
+
import type { TeleportSink } from "./runtime/portal.ts";
|
|
9
|
+
/** A thrown value that is not an `Error` may reach a boundary as the `cause` of one, so a redirect is read back from it. */
|
|
10
|
+
export declare function redirectOf(error: unknown): HamurRedirect | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* What the server render's `onError` returns for a failure Solid handles: the masked error, as a copy with
|
|
13
|
+
* only its public fields, because Solid writes every own property into the hydration script, and Bun adds `stack`,
|
|
14
|
+
* `sourceURL`, `line` and `column`. A boundary's fallback receives this copy, never the error.
|
|
15
|
+
*/
|
|
16
|
+
export declare function serializableError(app: HamurApp, error: unknown): unknown;
|
|
17
|
+
export declare function originalOf(error: unknown): unknown;
|
|
18
|
+
export interface NavigationSource {
|
|
19
|
+
get(): NavigationState;
|
|
20
|
+
subscribe(listener: () => void): () => void;
|
|
21
|
+
}
|
|
22
|
+
export interface AppState {
|
|
23
|
+
route: RouteValue;
|
|
24
|
+
router: RouterApi;
|
|
25
|
+
baseURL: string;
|
|
26
|
+
href: RenderContext["href"];
|
|
27
|
+
components: RenderTree["components"];
|
|
28
|
+
data: Record<string, unknown>;
|
|
29
|
+
handlerState?: unknown;
|
|
30
|
+
tree: RenderTree;
|
|
31
|
+
head: Head;
|
|
32
|
+
navigation: NavigationSource;
|
|
33
|
+
app: HamurApp;
|
|
34
|
+
context: RenderContext | ClientContext;
|
|
35
|
+
/** Server: where `Portal` writes; absent in an island's root. */
|
|
36
|
+
teleports?: TeleportSink;
|
|
37
|
+
}
|
|
38
|
+
export interface Level {
|
|
39
|
+
state: Accessor<AppState>;
|
|
40
|
+
index: number;
|
|
41
|
+
}
|
|
42
|
+
export declare const AppContext: import("solid-js").Context<Accessor<AppState> | null>;
|
|
43
|
+
/** The `href` of the `Link` whose children render, read by `useLinkStatus()`. */
|
|
44
|
+
export declare const LinkHrefContext: import("solid-js").Context<Accessor<string> | null>;
|
|
45
|
+
export declare const FormStatusContext: import("solid-js").Context<FormStatusStore | null>;
|
|
46
|
+
export declare function detachedHref(to: string | RouteLocation): string;
|
|
47
|
+
export declare const LevelContext: import("solid-js").Context<Level | null>;
|
|
48
|
+
export declare const OutletValueContext: import("solid-js").Context<Accessor<unknown> | null>;
|
|
49
|
+
/** `true` below a `"never"` lazy component on the server, so its async data stays out of the payload. */
|
|
50
|
+
export declare const NeverHydratedContext: import("solid-js").Context<boolean>;
|
|
51
|
+
export declare const ActivationContext: import("solid-js").Context<Activation | null>;
|
|
52
|
+
/** The error of the route boundary the component renders in, read by `useError()`. */
|
|
53
|
+
export declare const ErrorScope: import("solid-js").Context<ErrorPageProps | null>;
|
|
54
|
+
export declare function routerOf(navigator: unknown, baseURL?: string, page?: Omit<RouterSource, "navigator" | "baseURL">): RouterApi;
|
|
55
|
+
export declare function navigationOf(navigator: unknown): NavigationSource;
|
|
56
|
+
export declare function routeValue(ctx: Pick<RenderContext, "route"> & Partial<Pick<RenderContext, "app" | "payload" | "tree">>): RouteValue;
|
|
57
|
+
export declare function appState(ctx: Pick<RenderContext | ClientContext, "route" | "tree" | "payload" | "app" | "head" | "href"> & {
|
|
58
|
+
navigator?: unknown;
|
|
59
|
+
baseURL?: string;
|
|
60
|
+
}): AppState;
|
|
61
|
+
export declare function errorOf(state: AppState): ErrorPageProps | undefined;
|
|
62
|
+
export declare function useAppState(name: string): Accessor<AppState>;
|
|
63
|
+
export type Props = {
|
|
64
|
+
state: Accessor<AppState>;
|
|
65
|
+
index: number;
|
|
66
|
+
};
|
|
67
|
+
/** The slot element an island root last made and the node it rendered, which an update reuses only while that node is still in the document. */
|
|
68
|
+
export interface IslandSlot {
|
|
69
|
+
element?: JSX.Element;
|
|
70
|
+
node?: Element;
|
|
71
|
+
}
|
|
72
|
+
export declare function islandState(component: unknown, props: Record<string, unknown>, ctx: {
|
|
73
|
+
app: HamurApp;
|
|
74
|
+
route: ResolvedRoute;
|
|
75
|
+
baseURL: string;
|
|
76
|
+
idPrefix: string;
|
|
77
|
+
slots?: {
|
|
78
|
+
default?: string;
|
|
79
|
+
};
|
|
80
|
+
}, kept?: IslandSlot, update?: boolean): AppState;
|
|
81
|
+
/** The core's keep-alive feature loads the outlet (`Adapter.keepAliveOutlet`) and hands it to `installKeepAlive` before the first tree that holds kept units; it takes what it needs from the object it is built with, so its chunk imports nothing from the base. */
|
|
82
|
+
export declare function installKeepAlive(module: typeof import("./keepalive.ts")): void;
|
|
83
|
+
export declare function Outlet(props?: {
|
|
84
|
+
context?: unknown;
|
|
85
|
+
name?: string;
|
|
86
|
+
}): unknown;
|
|
87
|
+
export declare function Root(props: {
|
|
88
|
+
state: Accessor<AppState>;
|
|
89
|
+
}): import("solid-js").Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DefaultErrorPage as default } from "./index.ts";
|