@hamur/adapter-vue 0.0.0-stage → 0.0.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/LICENSE +22 -0
- package/README.md +32 -2
- package/dist/chunks/browser-index-43pdsfp6.js +69 -0
- package/dist/chunks/browser-index-d1bxd40m.js +320 -0
- package/dist/chunks/browser-index-nhft0ewv.js +161 -0
- package/dist/src/adapter.js +402 -0
- package/dist/src/index.js +1348 -0
- package/dist/src/keepalive.js +6 -0
- package/dist/src/runtime/client.js +20 -0
- package/dist/src/runtime/island.js +45 -0
- package/dist/src/runtime/server.js +238 -0
- package/dist/types/src/adapter.d.ts +2 -0
- package/dist/types/src/async-data.d.ts +14 -0
- package/dist/types/src/client-component.d.ts +12 -0
- package/dist/types/src/client-fallback.d.ts +2 -0
- package/dist/types/src/components/AwaitValue.d.ts +15 -0
- package/dist/types/src/components/ClientFallback.server.d.ts +17 -0
- package/dist/types/src/components/ErrorBoundary.server.d.ts +21 -0
- package/dist/types/src/components/error-code.d.ts +1 -0
- package/dist/types/src/context.d.ts +65 -0
- package/dist/types/src/index.d.ts +329 -0
- package/dist/types/src/island.d.ts +68 -0
- package/dist/types/src/keepalive.d.ts +22 -0
- package/dist/types/src/lazy-hydration.d.ts +10 -0
- package/dist/types/src/markdown-page.d.ts +9 -0
- package/dist/types/src/markdown.d.ts +45 -0
- package/dist/types/src/plugin.d.ts +45 -0
- package/dist/types/src/route-boundary.d.ts +35 -0
- package/dist/types/src/route-boundary.server.d.ts +5 -0
- package/dist/types/src/runtime/client.d.ts +11 -0
- package/dist/types/src/runtime/hydration-dev.d.ts +1 -0
- package/dist/types/src/runtime/hydration.d.ts +8 -0
- package/dist/types/src/runtime/island.d.ts +8 -0
- package/dist/types/src/runtime/server.d.ts +12 -0
- package/dist/types/src/server-island.d.ts +33 -0
- package/dist/types/src/svg.d.ts +10 -0
- package/package.json +46 -4
- package/src/adapter.ts +25 -0
- package/src/async-data.ts +77 -0
- package/src/client-component.ts +39 -0
- package/src/client-fallback.ts +2 -0
- package/src/components/Await.vue +30 -0
- package/src/components/AwaitValue.ts +41 -0
- package/src/components/ClientFallback.server.ts +41 -0
- package/src/components/ClientFallback.vue +31 -0
- package/src/components/ClientOnly.vue +16 -0
- package/src/components/DefaultErrorPage.vue +19 -0
- package/src/components/DevOnly.vue +8 -0
- package/src/components/ErrorBoundary.server.ts +69 -0
- package/src/components/ErrorBoundary.vue +32 -0
- package/src/components/Form.vue +85 -0
- package/src/components/Link.vue +200 -0
- package/src/components/Navigate.vue +16 -0
- package/src/components/Outlet.vue +28 -0
- package/src/components/error-code.ts +7 -0
- package/src/context.ts +391 -0
- package/src/index.ts +1528 -0
- package/src/island.ts +53 -0
- package/src/keepalive.ts +92 -0
- package/src/lazy-hydration.ts +53 -0
- package/src/markdown-page.ts +21 -0
- package/src/markdown.ts +80 -0
- package/src/plugin.ts +398 -0
- package/src/route-boundary.server.ts +29 -0
- package/src/route-boundary.ts +48 -0
- package/src/runtime/client.ts +137 -0
- package/src/runtime/hydration-dev.ts +38 -0
- package/src/runtime/hydration.ts +7 -0
- package/src/runtime/island.ts +60 -0
- package/src/runtime/server.ts +145 -0
- package/src/server-island.ts +38 -0
- package/src/svg.ts +28 -0
- package/src/vue.d.ts +5 -0
- package/src/webmcp.d.ts +18 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clientComponent2,
|
|
3
|
+
rootErrorHandler2,
|
|
4
|
+
hydrate2,
|
|
5
|
+
mount2,
|
|
6
|
+
update2,
|
|
7
|
+
serverComponent2
|
|
8
|
+
} from "../../chunks/browser-index-nhft0ewv.js";
|
|
9
|
+
import {
|
|
10
|
+
installKeepAlive2
|
|
11
|
+
} from "../../chunks/browser-index-d1bxd40m.js";
|
|
12
|
+
export {
|
|
13
|
+
clientComponent2 as clientComponent,
|
|
14
|
+
hydrate2 as hydrate,
|
|
15
|
+
installKeepAlive2 as installKeepAlive,
|
|
16
|
+
mount2 as mount,
|
|
17
|
+
rootErrorHandler2 as rootErrorHandler,
|
|
18
|
+
serverComponent2 as serverComponent,
|
|
19
|
+
update2 as update
|
|
20
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createIslandRoot
|
|
3
|
+
} from "../../chunks/browser-index-d1bxd40m.js";
|
|
4
|
+
import {
|
|
5
|
+
rootErrorHandler2
|
|
6
|
+
} from "../../chunks/browser-index-nhft0ewv.js";
|
|
7
|
+
|
|
8
|
+
// packages/adapter-vue/src/runtime/island.ts
|
|
9
|
+
import { createApp, createSSRApp } from "vue";
|
|
10
|
+
import { setAdapterInstance } from "hamur/adapter";
|
|
11
|
+
var apps = new WeakMap;
|
|
12
|
+
var roots = new WeakMap;
|
|
13
|
+
async function start(create, el, component, props, ctx) {
|
|
14
|
+
const root = createIslandRoot(component, props, ctx);
|
|
15
|
+
const app = create(root.component);
|
|
16
|
+
app.config.idPrefix = ctx.idPrefix;
|
|
17
|
+
app.config.errorHandler = rootErrorHandler2(ctx.app);
|
|
18
|
+
root.install(app);
|
|
19
|
+
apps.set(el, app);
|
|
20
|
+
roots.set(el, root);
|
|
21
|
+
await setAdapterInstance(ctx.app, app);
|
|
22
|
+
if (apps.get(el) === app)
|
|
23
|
+
app.mount(el);
|
|
24
|
+
}
|
|
25
|
+
function hydrateIsland(el, component, props, ctx) {
|
|
26
|
+
return start(createSSRApp, el, component, props, ctx);
|
|
27
|
+
}
|
|
28
|
+
function mountIsland(el, component, props, ctx) {
|
|
29
|
+
el.replaceChildren();
|
|
30
|
+
return start(createApp, el, component, props, ctx);
|
|
31
|
+
}
|
|
32
|
+
function unmountIsland(el) {
|
|
33
|
+
apps.get(el)?.unmount();
|
|
34
|
+
apps.delete(el);
|
|
35
|
+
roots.delete(el);
|
|
36
|
+
}
|
|
37
|
+
function updateIsland(el, props) {
|
|
38
|
+
return roots.get(el)?.setProps(props);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
hydrateIsland,
|
|
42
|
+
mountIsland,
|
|
43
|
+
unmountIsland,
|
|
44
|
+
updateIsland
|
|
45
|
+
};
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import {
|
|
2
|
+
caught,
|
|
3
|
+
RouteBoundary,
|
|
4
|
+
HeadPatchesKey,
|
|
5
|
+
AppKey,
|
|
6
|
+
installKeepAlive2,
|
|
7
|
+
createRoot,
|
|
8
|
+
createIslandRoot
|
|
9
|
+
} from "../../chunks/browser-index-d1bxd40m.js";
|
|
10
|
+
import {
|
|
11
|
+
exports_keepalive
|
|
12
|
+
} from "../../chunks/browser-index-43pdsfp6.js";
|
|
13
|
+
|
|
14
|
+
// packages/adapter-vue/src/runtime/server.ts
|
|
15
|
+
import { createSSRApp, defineComponent, h as h2, useId } from "vue";
|
|
16
|
+
import { renderToString, renderToWebStream } from "vue/server-renderer";
|
|
17
|
+
import {
|
|
18
|
+
publicError as publicError2,
|
|
19
|
+
resetAnnouncerClaims,
|
|
20
|
+
serverComponentAttributes,
|
|
21
|
+
serverComponentProps,
|
|
22
|
+
setAdapterInstance
|
|
23
|
+
} from "hamur/adapter";
|
|
24
|
+
import ClientFallback from "../../../src/components/ClientFallback.vue";
|
|
25
|
+
|
|
26
|
+
// packages/adapter-vue/src/components/ClientFallback.server.ts
|
|
27
|
+
import { ssrRenderSlot as ssrRenderSlot2, ssrRenderSlotInner as ssrRenderSlotInner2 } from "vue/server-renderer";
|
|
28
|
+
import { clientFallback } from "hamur/adapter";
|
|
29
|
+
|
|
30
|
+
// packages/adapter-vue/src/components/ErrorBoundary.server.ts
|
|
31
|
+
import { Fragment, createTextVNode, h, isVNode } from "vue";
|
|
32
|
+
import { publicError } from "hamur/adapter";
|
|
33
|
+
import { ssrRenderSlot, ssrRenderSlotInner, ssrRenderVNode } from "vue/server-renderer";
|
|
34
|
+
async function flatten(item) {
|
|
35
|
+
if (typeof item === "string")
|
|
36
|
+
return item;
|
|
37
|
+
if (Array.isArray(item)) {
|
|
38
|
+
let out = "";
|
|
39
|
+
for (const part of item)
|
|
40
|
+
out += await flatten(part);
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
return flatten(await item);
|
|
44
|
+
}
|
|
45
|
+
function toVNode(value) {
|
|
46
|
+
if (isVNode(value))
|
|
47
|
+
return value;
|
|
48
|
+
return Array.isArray(value) ? h(Fragment, null, value) : createTextVNode(String(value ?? ""));
|
|
49
|
+
}
|
|
50
|
+
var remember = ({ state, key }, error) => {
|
|
51
|
+
if (error instanceof Error)
|
|
52
|
+
state?.set(key, { name: error.name, message: error.message });
|
|
53
|
+
};
|
|
54
|
+
function ssrRender(_ctx, push, instance, _attrs, props, state) {
|
|
55
|
+
const items = [];
|
|
56
|
+
ssrRenderSlotInner(instance.slots, "default", {}, null, (item) => items.push(item), instance);
|
|
57
|
+
push((async () => {
|
|
58
|
+
const html = await flatten(items).catch((error) => {
|
|
59
|
+
state.error = error;
|
|
60
|
+
state.failed = true;
|
|
61
|
+
});
|
|
62
|
+
if (!state.failed)
|
|
63
|
+
return `<!--[-->${html}<!--]-->`;
|
|
64
|
+
const app = instance.appContext.provides[AppKey];
|
|
65
|
+
if (app)
|
|
66
|
+
state.error = publicError(app, state.error);
|
|
67
|
+
remember(state, state.error);
|
|
68
|
+
const buffer = [];
|
|
69
|
+
const out = (item) => buffer.push(item);
|
|
70
|
+
const slotProps = { error: state.error, reset: state.reset };
|
|
71
|
+
if (props.fallback)
|
|
72
|
+
ssrRenderVNode(out, toVNode(props.fallback(slotProps)), instance);
|
|
73
|
+
else
|
|
74
|
+
ssrRenderSlot(instance.slots, "fallback", slotProps, null, out, instance);
|
|
75
|
+
return flatten(buffer);
|
|
76
|
+
})());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// packages/adapter-vue/src/components/ClientFallback.server.ts
|
|
80
|
+
function ssrRender2(_ctx, push, instance, _attrs, props, state) {
|
|
81
|
+
const items = [];
|
|
82
|
+
ssrRenderSlotInner2(instance.slots, "default", {}, null, (item) => items.push(item), instance);
|
|
83
|
+
push((async () => {
|
|
84
|
+
let thrown;
|
|
85
|
+
const html = await flatten(items).catch((error) => void (thrown = { error }));
|
|
86
|
+
if (state.caught.failed)
|
|
87
|
+
thrown = { error: state.caught.error };
|
|
88
|
+
if (!thrown)
|
|
89
|
+
return `<!--[-->${html}<!--]-->`;
|
|
90
|
+
const app = instance.appContext.provides[AppKey];
|
|
91
|
+
if (app)
|
|
92
|
+
clientFallback(app, state.id, thrown.error, props.onSsrError);
|
|
93
|
+
const buffer = [];
|
|
94
|
+
ssrRenderSlot2(instance.slots, "fallback", {}, null, (item) => buffer.push(item), instance);
|
|
95
|
+
return flatten(buffer);
|
|
96
|
+
})());
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// packages/adapter-vue/src/runtime/server.ts
|
|
100
|
+
import ErrorBoundary from "../../../src/components/ErrorBoundary.vue";
|
|
101
|
+
|
|
102
|
+
// packages/adapter-vue/src/route-boundary.server.ts
|
|
103
|
+
import { ssrRenderSlotInner as ssrRenderSlotInner3, ssrRenderVNode as ssrRenderVNode2 } from "vue/server-renderer";
|
|
104
|
+
function ssrRender3(_ctx, push, instance, _attrs, props) {
|
|
105
|
+
const items = [];
|
|
106
|
+
ssrRenderSlotInner3(instance.slots, "default", {}, null, (item) => items.push(item), instance);
|
|
107
|
+
push((async () => {
|
|
108
|
+
let failure;
|
|
109
|
+
const html = await flatten(items).catch((error) => {
|
|
110
|
+
failure = { error };
|
|
111
|
+
});
|
|
112
|
+
failure ??= caught.get(instance);
|
|
113
|
+
if (!failure)
|
|
114
|
+
return `<!--[-->${html}<!--]-->`;
|
|
115
|
+
const buffer = [];
|
|
116
|
+
ssrRenderVNode2((item) => buffer.push(item), toVNode(props.fallback(failure.error)), instance);
|
|
117
|
+
return flatten(buffer);
|
|
118
|
+
})());
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// packages/adapter-vue/src/runtime/server.ts
|
|
122
|
+
installKeepAlive2(exports_keepalive);
|
|
123
|
+
ErrorBoundary.ssrRender = ssrRender;
|
|
124
|
+
ClientFallback.ssrRender = ssrRender2;
|
|
125
|
+
RouteBoundary.ssrRender = ssrRender3;
|
|
126
|
+
async function render(ctx) {
|
|
127
|
+
resetAnnouncerClaims(ctx.app);
|
|
128
|
+
const root = createRoot(ctx);
|
|
129
|
+
const app = createSSRApp(root.component);
|
|
130
|
+
root.install(app);
|
|
131
|
+
const headPatches = [];
|
|
132
|
+
app.provide(HeadPatchesKey, headPatches);
|
|
133
|
+
await setAdapterInstance(ctx.app, app);
|
|
134
|
+
let failed;
|
|
135
|
+
const previous = app.config.errorHandler;
|
|
136
|
+
let shellRead = false;
|
|
137
|
+
app.config.errorHandler = (error, instance, info) => {
|
|
138
|
+
if (shellRead)
|
|
139
|
+
publicError2(ctx.app, error);
|
|
140
|
+
else if (failed)
|
|
141
|
+
console.error(error);
|
|
142
|
+
else
|
|
143
|
+
failed = { error };
|
|
144
|
+
previous?.(error, instance, info);
|
|
145
|
+
};
|
|
146
|
+
const ssrContext = {};
|
|
147
|
+
if (ctx.stream) {
|
|
148
|
+
const body = await afterShell(renderToWebStream(app, ssrContext), (error) => void publicError2(ctx.app, error));
|
|
149
|
+
shellRead = true;
|
|
150
|
+
if (failed) {
|
|
151
|
+
body.cancel();
|
|
152
|
+
throw failed.error;
|
|
153
|
+
}
|
|
154
|
+
for (const patch of headPatches)
|
|
155
|
+
patch();
|
|
156
|
+
return { body };
|
|
157
|
+
}
|
|
158
|
+
const body = await renderToString(app, ssrContext);
|
|
159
|
+
if (failed)
|
|
160
|
+
throw failed.error;
|
|
161
|
+
for (const patch of headPatches)
|
|
162
|
+
patch();
|
|
163
|
+
return ssrContext.teleports && Object.keys(ssrContext.teleports).length ? { body, teleports: ssrContext.teleports } : { body };
|
|
164
|
+
}
|
|
165
|
+
var islandsRendering = new WeakMap;
|
|
166
|
+
async function renderComponent(component, props, ctx) {
|
|
167
|
+
await Promise.resolve();
|
|
168
|
+
const root = createIslandRoot(component, props, ctx);
|
|
169
|
+
const app = createSSRApp(root.component);
|
|
170
|
+
app.config.idPrefix = ctx.idPrefix;
|
|
171
|
+
root.install(app);
|
|
172
|
+
const headPatches = [];
|
|
173
|
+
app.provide(HeadPatchesKey, headPatches);
|
|
174
|
+
let rendering = islandsRendering.get(ctx.app);
|
|
175
|
+
if (!rendering)
|
|
176
|
+
islandsRendering.set(ctx.app, rendering = { page: ctx.app.adapter, count: 0 });
|
|
177
|
+
rendering.count++;
|
|
178
|
+
try {
|
|
179
|
+
await setAdapterInstance(ctx.app, app);
|
|
180
|
+
let failed;
|
|
181
|
+
const previous = app.config.errorHandler;
|
|
182
|
+
app.config.errorHandler = (error, instance, info) => {
|
|
183
|
+
failed ??= { error };
|
|
184
|
+
previous?.(error, instance, info);
|
|
185
|
+
};
|
|
186
|
+
const html = await renderToString(app, {});
|
|
187
|
+
if (failed)
|
|
188
|
+
throw failed.error;
|
|
189
|
+
for (const patch of headPatches)
|
|
190
|
+
patch();
|
|
191
|
+
return { html };
|
|
192
|
+
} finally {
|
|
193
|
+
if (--rendering.count === 0) {
|
|
194
|
+
islandsRendering.delete(ctx.app);
|
|
195
|
+
ctx.app.adapter = rendering.page;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async function afterShell(stream, late) {
|
|
200
|
+
const reader = stream.getReader();
|
|
201
|
+
const first = await reader.read();
|
|
202
|
+
if (first.done)
|
|
203
|
+
return new ReadableStream({ start: (controller) => controller.close() });
|
|
204
|
+
return new ReadableStream({
|
|
205
|
+
start: (controller) => controller.enqueue(first.value),
|
|
206
|
+
async pull(controller) {
|
|
207
|
+
const chunk = await reader.read().catch((error) => (late(error), { done: true, value: undefined }));
|
|
208
|
+
if (chunk.done)
|
|
209
|
+
controller.close();
|
|
210
|
+
else
|
|
211
|
+
controller.enqueue(chunk.value);
|
|
212
|
+
},
|
|
213
|
+
cancel: (reason) => reader.cancel(reason)
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function clientComponent() {
|
|
217
|
+
return defineComponent({ name: "ClientComponent", render: () => null });
|
|
218
|
+
}
|
|
219
|
+
function serverComponent(name, component) {
|
|
220
|
+
return defineComponent({
|
|
221
|
+
name: `${name}.server`,
|
|
222
|
+
inheritAttrs: false,
|
|
223
|
+
setup(_, { attrs, slots }) {
|
|
224
|
+
const uid = useId();
|
|
225
|
+
return () => {
|
|
226
|
+
const props = { ...attrs };
|
|
227
|
+
serverComponentProps(name, props, slots.default !== undefined);
|
|
228
|
+
return h2("hamur-component", { name, uid, ...serverComponentAttributes(name) }, [h2(component, props)]);
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
export {
|
|
234
|
+
clientComponent,
|
|
235
|
+
render,
|
|
236
|
+
renderComponent,
|
|
237
|
+
serverComponent
|
|
238
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter } from "vue";
|
|
2
|
+
import type { AppContext, AsyncDataOptions } from "hamur/app";
|
|
3
|
+
import type { AsyncDataHandler, GetCachedData, GetCachedDataCause } from "hamur/adapter";
|
|
4
|
+
/** Whether head input holds a ref or a getter at any depth (a `titleTemplate` function and a script's `innerHTML` function are plain values). */
|
|
5
|
+
export declare function hasReactive(value: unknown, key?: string, list?: string): boolean;
|
|
6
|
+
/** `toValue` of an option, then every ref nested in plain objects and arrays replaced by its value, in a new object. With `getters` (head input) a nested function is called too, except `titleTemplate`. */
|
|
7
|
+
export declare const deepToValue: (source: MaybeRefOrGetter<unknown>, getters?: boolean) => unknown;
|
|
8
|
+
/** The restored payload entry's data while the app hydrates, else `undefined`. */
|
|
9
|
+
export declare function defaultGetCachedData<T>(key: string, app: AppContext): T | undefined;
|
|
10
|
+
/** `refresh()`, `execute()` and a `watch` change: ask `getCachedData` with their cause, run `handler` when it has nothing. */
|
|
11
|
+
export declare function refreshCached<T, R>(app: AppContext, key: string, handler: AsyncDataHandler<R>, options: AsyncDataOptions<T, R>, getCachedData: GetCachedData<T>, cause: GetCachedDataCause): Promise<void>;
|
|
12
|
+
export declare function keepCached<T>(app: AppContext, key: string, getCachedData: GetCachedData<T>): void;
|
|
13
|
+
/** The run's signal, combined with a `signal` the caller gave to `useFetch`. */
|
|
14
|
+
export declare const signalOf: (own: AbortSignal | undefined, run: AbortSignal) => AbortSignal;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Component, InjectionKey, Slot } from "vue";
|
|
2
|
+
/** Provided by `ClientOnly` with its `fallback` slot; a client-only component below shows it while its chunk loads. */
|
|
3
|
+
export declare const ClientOnlyKey: InjectionKey<{
|
|
4
|
+
fallback: Slot | undefined;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* The client side of a client-only component: a comment in the hydration render, the file's chunk once mounted. A `ref` on it
|
|
8
|
+
* reaches the loaded component's instance through `expose`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function clientComponent(load: () => Promise<Component | {
|
|
11
|
+
default: Component;
|
|
12
|
+
}>): Component;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PropType } from "vue";
|
|
2
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
resolve: {
|
|
4
|
+
type: PropType<unknown>;
|
|
5
|
+
required: true;
|
|
6
|
+
};
|
|
7
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}>[]) | (() => null), {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
10
|
+
resolve: {
|
|
11
|
+
type: PropType<unknown>;
|
|
12
|
+
required: true;
|
|
13
|
+
};
|
|
14
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentInternalInstance } from "vue";
|
|
2
|
+
interface FallbackState {
|
|
3
|
+
id: string;
|
|
4
|
+
caught: {
|
|
5
|
+
error?: unknown;
|
|
6
|
+
failed: boolean;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Vue's server renderer writes output as it goes, so the slot is rendered into a buffer and kept only if nothing in it failed.
|
|
11
|
+
* A failed boundary writes its `fallback` slot and records its id for `payload.clientFallback`; the client hydrates the fallback,
|
|
12
|
+
* then renders the children.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ssrRender(_ctx: unknown, push: (item: unknown) => void, instance: ComponentInternalInstance, _attrs: unknown, props: {
|
|
15
|
+
onSsrError?: (error: unknown) => unknown;
|
|
16
|
+
}, state: FallbackState): void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type State } from "hamur/app";
|
|
2
|
+
import type { ComponentInternalInstance, VNode } from "vue";
|
|
3
|
+
import type { ErrorBoundaryFallbackProps } from "hamur/adapter";
|
|
4
|
+
interface BoundaryState {
|
|
5
|
+
key: string;
|
|
6
|
+
state: State | null;
|
|
7
|
+
failed: boolean;
|
|
8
|
+
error: unknown;
|
|
9
|
+
reset: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function flatten(item: unknown): Promise<string>;
|
|
12
|
+
export declare function toVNode(value: unknown): VNode;
|
|
13
|
+
/**
|
|
14
|
+
* Vue's server renderer writes output as it goes, so the slot is rendered into a buffer and kept only if nothing in it failed.
|
|
15
|
+
* A failed boundary is written under its id to the app state, which the payload carries to the client.
|
|
16
|
+
* The client then starts in the fallback while it hydrates (the markup matches) instead of rendering the child again.
|
|
17
|
+
*/
|
|
18
|
+
export declare function ssrRender(_ctx: unknown, push: (item: unknown) => void, instance: ComponentInternalInstance, _attrs: unknown, props: {
|
|
19
|
+
fallback?: (props: ErrorBoundaryFallbackProps) => unknown;
|
|
20
|
+
}, state: BoundaryState): void;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const codeURL: ((code: string) => string) | undefined;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { App, ComputedRef, InjectionKey, ShallowRef, Slot, VNode } from "vue";
|
|
2
|
+
import type { AppContext, ErrorPageProps, ErrorStore, Head, State } from "hamur/app";
|
|
3
|
+
import { layoutOf, type RouterSource } from "hamur/adapter";
|
|
4
|
+
import type { ClientContext, FormStatusStore, NavigationState, RenderContext, ResolvedRoute, RouteValue, RouterApi } from "hamur/adapter";
|
|
5
|
+
import type { RouteLocation } from "hamur/app";
|
|
6
|
+
export declare const RouteKey: InjectionKey<RouteValue>;
|
|
7
|
+
export declare const RouterKey: InjectionKey<RouterApi>;
|
|
8
|
+
/** Provided as `true` below a `"never"` lazy component, so its async data stays out of the payload. */
|
|
9
|
+
export declare const NeverHydratedKey: InjectionKey<boolean>;
|
|
10
|
+
export declare const BaseURLKey: InjectionKey<string>;
|
|
11
|
+
export declare const HrefKey: InjectionKey<RenderContext["href"]>;
|
|
12
|
+
export declare const DataKey: InjectionKey<ShallowRef<Record<string, unknown>>>;
|
|
13
|
+
export declare const EntryKey: InjectionKey<() => string>;
|
|
14
|
+
export interface ErrorSource {
|
|
15
|
+
store?: ErrorStore;
|
|
16
|
+
initial?: ErrorPageProps;
|
|
17
|
+
}
|
|
18
|
+
export declare const ErrorKey: InjectionKey<ErrorSource>;
|
|
19
|
+
export declare const HeadKey: InjectionKey<Head>;
|
|
20
|
+
export declare const HeadPatchesKey: InjectionKey<Array<() => void>>;
|
|
21
|
+
export declare const StateKey: InjectionKey<State>;
|
|
22
|
+
export interface Submitted {
|
|
23
|
+
/** The `{ id, instance?, value | failure | error }` of a no-JS post to a page. */
|
|
24
|
+
handlerState?: unknown;
|
|
25
|
+
}
|
|
26
|
+
export declare const SubmittedKey: InjectionKey<ShallowRef<Submitted>>;
|
|
27
|
+
export declare const FormStatusKey: InjectionKey<FormStatusStore | null>;
|
|
28
|
+
export declare const AppKey: InjectionKey<AppContext>;
|
|
29
|
+
/** The `href` of the `Link` whose slot renders, read by `useLinkStatus()`. */
|
|
30
|
+
export declare const LinkHrefKey: InjectionKey<ComputedRef<string>>;
|
|
31
|
+
export declare const NavigationKey: InjectionKey<ShallowRef<NavigationState>>;
|
|
32
|
+
export declare const OutletValueKey: InjectionKey<() => unknown>;
|
|
33
|
+
export declare const OutletKey: InjectionKey<ShallowRef<Slot | undefined>>;
|
|
34
|
+
export declare const SlotsKey: InjectionKey<() => Record<string, () => VNode | undefined> | null>;
|
|
35
|
+
export declare const LayoutKey: InjectionKey<ComputedRef<ReturnType<typeof layoutOf>>>;
|
|
36
|
+
export declare function detachedHref(to: string | RouteLocation): string;
|
|
37
|
+
export declare function routerOf(navigator: unknown, baseURL?: string, page?: Omit<RouterSource, "navigator" | "baseURL">): RouterApi;
|
|
38
|
+
export declare function routeValue(ctx: Pick<RenderContext, "route"> & Partial<Pick<RenderContext, "app" | "payload" | "tree">>): RouteValue;
|
|
39
|
+
/** 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. */
|
|
40
|
+
export declare function installKeepAlive(module: typeof import("./keepalive.ts")): void;
|
|
41
|
+
export type Source = Pick<RenderContext | ClientContext, "route" | "tree"> & Pick<RenderContext, "app" | "head"> & Partial<Pick<RenderContext, "payload" | "baseURL">> & Pick<RenderContext, "href"> & {
|
|
42
|
+
navigator?: unknown;
|
|
43
|
+
};
|
|
44
|
+
export declare const dataOf: (ctx: Source) => Record<string, unknown>;
|
|
45
|
+
export interface HamurRoot {
|
|
46
|
+
component: {
|
|
47
|
+
setup(): () => VNode | undefined;
|
|
48
|
+
};
|
|
49
|
+
install(app: App): void;
|
|
50
|
+
/** Resolves after the patch, once every page `Suspense` that went pending in it resolved. */
|
|
51
|
+
update(ctx: Source): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
export declare function createRoot(ctx: Source): HamurRoot;
|
|
54
|
+
/** The root of an island: the app's route, state and head around one entry; a `Link` takes a path, as no route table ships. */
|
|
55
|
+
export declare function createIslandRoot(component: unknown, props: Record<string, unknown>, ctx: {
|
|
56
|
+
app: AppContext;
|
|
57
|
+
route: ResolvedRoute;
|
|
58
|
+
baseURL: string;
|
|
59
|
+
idPrefix: string;
|
|
60
|
+
slots?: {
|
|
61
|
+
default?: string;
|
|
62
|
+
};
|
|
63
|
+
}): HamurRoot & {
|
|
64
|
+
setProps(props: Record<string, unknown>): Promise<void>;
|
|
65
|
+
};
|