@solidjs/start 2.0.0-beta.0 → 2.0.0-beta.10
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/CHANGELOG.md +71 -0
- package/dist/config/boundary-modules.d.ts +14 -0
- package/dist/config/boundary-modules.js +41 -0
- package/dist/config/dev-server.d.ts +3 -1
- package/dist/config/dev-server.js +25 -5
- package/dist/config/env.js +16 -12
- package/dist/config/fs-router.d.ts +1 -1
- package/dist/config/fs-router.js +28 -21
- package/dist/config/fs-routes/router.d.ts +2 -1
- package/dist/config/fs-routes/router.js +8 -10
- package/dist/config/index.js +42 -7
- package/dist/directives/index.js +39 -7
- package/dist/fns/handler.js +40 -4
- package/dist/fns/registration.d.ts +2 -1
- package/dist/fns/registration.js +4 -1
- package/dist/http/http.d.ts +81 -0
- package/dist/http/http.js +129 -0
- package/dist/http/index.d.ts +2 -81
- package/dist/http/index.js +6 -129
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.js +1 -0
- package/dist/server/StartServer.jsx +1 -1
- package/dist/server/handler.d.ts +3 -61
- package/dist/server/handler.js +4 -8
- package/dist/server/spa/StartServer.jsx +1 -1
- package/dist/server/spa/handler.d.ts +2 -30
- package/dist/server/web-stream.d.ts +9 -0
- package/dist/server/web-stream.js +26 -0
- package/dist/shared/HttpHeader.jsx +1 -1
- package/env.d.ts +12 -0
- package/package.json +14 -8
- package/scripts/build.js +0 -15
- package/scripts/validate-imports.js +0 -316
- package/src/client/StartClient.tsx +0 -34
- package/src/client/index.tsx +0 -2
- package/src/client/mount.ts +0 -1
- package/src/client/spa/index.tsx +0 -9
- package/src/config/constants.ts +0 -19
- package/src/config/dev-server.ts +0 -157
- package/src/config/env.ts +0 -105
- package/src/config/fs-router.ts +0 -162
- package/src/config/fs-routes/fs-watcher.ts +0 -66
- package/src/config/fs-routes/index.ts +0 -136
- package/src/config/fs-routes/router.ts +0 -184
- package/src/config/fs-routes/tree-shake.ts +0 -324
- package/src/config/index.ts +0 -239
- package/src/config/lazy.ts +0 -132
- package/src/config/manifest.ts +0 -120
- package/src/config/utils.ts +0 -5
- package/src/config/vite-utils.ts +0 -113
- package/src/directives/bubble-function-declaration.ts +0 -33
- package/src/directives/compile.ts +0 -54
- package/src/directives/generate-unique-name.ts +0 -22
- package/src/directives/get-descriptive-name.ts +0 -39
- package/src/directives/get-import-identifier.ts +0 -34
- package/src/directives/get-root-statement-path.ts +0 -14
- package/src/directives/index.ts +0 -233
- package/src/directives/is-statement-top-level.ts +0 -13
- package/src/directives/paths.ts +0 -63
- package/src/directives/plugin.ts +0 -389
- package/src/directives/remove-unused-variables.ts +0 -70
- package/src/directives/types.ts +0 -12
- package/src/directives/xxhash32.ts +0 -214
- package/src/env.d.ts +0 -17
- package/src/fns/client.ts +0 -141
- package/src/fns/handler.spec.ts +0 -85
- package/src/fns/handler.ts +0 -287
- package/src/fns/registration.ts +0 -19
- package/src/fns/serialization.ts +0 -250
- package/src/fns/server.ts +0 -46
- package/src/fns/shared.ts +0 -116
- package/src/http/index.ts +0 -216
- package/src/index.tsx +0 -7
- package/src/internal.d.ts +0 -14
- package/src/middleware/index.ts +0 -92
- package/src/router.tsx +0 -37
- package/src/server/StartServer.tsx +0 -58
- package/src/server/assets/PatchVirtualDevStyles.tsx +0 -31
- package/src/server/assets/index.ts +0 -70
- package/src/server/assets/render.tsx +0 -46
- package/src/server/collect-styles.ts +0 -70
- package/src/server/fetchEvent.spec.ts +0 -85
- package/src/server/fetchEvent.ts +0 -36
- package/src/server/handler.ts +0 -261
- package/src/server/index.tsx +0 -29
- package/src/server/manifest/client-manifest.ts +0 -8
- package/src/server/manifest/dev-client-manifest.ts +0 -21
- package/src/server/manifest/dev-ssr-manifest.ts +0 -23
- package/src/server/manifest/prod-client-manifest.ts +0 -21
- package/src/server/manifest/prod-ssr-manifest.ts +0 -109
- package/src/server/manifest/ssr-manifest.ts +0 -10
- package/src/server/routes.ts +0 -126
- package/src/server/spa/StartServer.tsx +0 -42
- package/src/server/spa/handler.ts +0 -29
- package/src/server/spa/index.tsx +0 -5
- package/src/server/types.ts +0 -82
- package/src/server/util.ts +0 -12
- package/src/shared/ErrorBoundary.tsx +0 -52
- package/src/shared/GET.ts +0 -8
- package/src/shared/HttpHeader.tsx +0 -42
- package/src/shared/HttpStatusCode.ts +0 -27
- package/src/shared/clientOnly.ts +0 -44
- package/src/shared/dev-overlay/CodeView.tsx +0 -90
- package/src/shared/dev-overlay/DevOverlayDialog.tsx +0 -316
- package/src/shared/dev-overlay/createStackFrame.ts +0 -74
- package/src/shared/dev-overlay/download.ts +0 -6
- package/src/shared/dev-overlay/env.d.ts +0 -4
- package/src/shared/dev-overlay/get-source-map.ts +0 -33
- package/src/shared/dev-overlay/icons.tsx +0 -456
- package/src/shared/dev-overlay/index.tsx +0 -63
- package/src/shared/dev-overlay/styles.css +0 -292
- package/src/shared/lazy.ts +0 -52
- package/src/shared/serverFunction.ts +0 -10
- package/src/utils/debounce.ts +0 -10
- package/src/virtual.d.ts +0 -27
- package/tsconfig.json +0 -24
- package/vitest.config.ts +0 -9
package/dist/fns/handler.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
1
9
|
import { parseSetCookie } from "cookie-es";
|
|
2
10
|
import { parseCookies } from "h3";
|
|
3
11
|
import { sharedConfig } from "solid-js";
|
|
@@ -6,9 +14,9 @@ import { provideRequestEvent } from "solid-js/web/storage";
|
|
|
6
14
|
import { getFetchEvent, mergeResponseHeaders } from "../server/fetchEvent.js";
|
|
7
15
|
import { createPageEvent } from "../server/handler.js";
|
|
8
16
|
import { deserializeFromJSONString, serializeToJSONStream, serializeToJSStream, } from "./serialization.js";
|
|
9
|
-
import { BODY_FORMAT_KEY, BodyFormat, extractBody, getHeadersAndBody
|
|
17
|
+
import { BODY_FORMAT_KEY, BodyFormat, extractBody, getHeadersAndBody } from "./shared.js";
|
|
10
18
|
import "solid-start:server-fn-manifest";
|
|
11
|
-
import { getServerFunction } from "./registration.js";
|
|
19
|
+
import { getServerFunction, hasServerFunction } from "./registration.js";
|
|
12
20
|
import { getExpectedRedirectStatus } from "../server/util.js";
|
|
13
21
|
export async function handleServerFunction(h3Event) {
|
|
14
22
|
const event = getFetchEvent(h3Event);
|
|
@@ -30,6 +38,23 @@ export async function handleServerFunction(h3Event) {
|
|
|
30
38
|
: new Response(null, { status: 404 });
|
|
31
39
|
}
|
|
32
40
|
}
|
|
41
|
+
if (import.meta.env.DEV && !hasServerFunction(functionId)) {
|
|
42
|
+
// The module that owns this function has not been evaluated in the server
|
|
43
|
+
// environment yet (e.g. the route was reached by client-side navigation, so
|
|
44
|
+
// it was only ever loaded in the browser). Ask the dev server to resolve the
|
|
45
|
+
// function id back to its owning module and import it, which registers it.
|
|
46
|
+
// Resolved by the "solid-start:server-functions/preload" plugin.
|
|
47
|
+
try {
|
|
48
|
+
// the /@id/ prefix routes the request through the plugin container so the
|
|
49
|
+
// virtual module can be resolved (bare ids get node-resolved by the runner)
|
|
50
|
+
await import(__rewriteRelativeImportExtension(
|
|
51
|
+
/* @vite-ignore */ `/@id/solid-start:server-fn-lookup?id=${encodeURIComponent(functionId)}`, true));
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
// fall through to getServerFunction, which reports the missing function
|
|
55
|
+
console.error("[solid-start] server function lookup failed:", error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
33
58
|
const serverFunction = getServerFunction(functionId);
|
|
34
59
|
let parsed = [];
|
|
35
60
|
// grab bound arguments from url when no JS
|
|
@@ -119,7 +144,7 @@ export async function handleServerFunction(h3Event) {
|
|
|
119
144
|
}
|
|
120
145
|
else if (instance) {
|
|
121
146
|
const error = x instanceof Error ? x.message : typeof x === "string" ? x : "true";
|
|
122
|
-
h3Event.res.headers.set("X-Error", error
|
|
147
|
+
h3Event.res.headers.set("X-Error", toHeaderValue(error));
|
|
123
148
|
}
|
|
124
149
|
else {
|
|
125
150
|
x = handleNoJS(x, request, parsed, true);
|
|
@@ -133,7 +158,7 @@ export async function handleServerFunction(h3Event) {
|
|
|
133
158
|
headers.set("X-Error", errorHeader);
|
|
134
159
|
}
|
|
135
160
|
return new Response(body.body, {
|
|
136
|
-
headers
|
|
161
|
+
headers,
|
|
137
162
|
});
|
|
138
163
|
}
|
|
139
164
|
h3Event.res.headers.set(BODY_FORMAT_KEY, BodyFormat.Seroval);
|
|
@@ -147,6 +172,17 @@ export async function handleServerFunction(h3Event) {
|
|
|
147
172
|
return x;
|
|
148
173
|
}
|
|
149
174
|
}
|
|
175
|
+
// header values must be ByteString-safe (no chars > 0xFF), otherwise Headers.set throws
|
|
176
|
+
function toHeaderValue(value) {
|
|
177
|
+
const stripped = value.replace(/[\r\n]+/g, "");
|
|
178
|
+
try {
|
|
179
|
+
return /[^\x00-\xFF]/.test(stripped) ? encodeURIComponent(stripped) : stripped;
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// encodeURIComponent throws on lone surrogates
|
|
183
|
+
return "true";
|
|
184
|
+
}
|
|
185
|
+
}
|
|
150
186
|
function handleNoJS(result, request, parsed, thrown) {
|
|
151
187
|
const url = new URL(request.url);
|
|
152
188
|
const isError = result instanceof Error;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare function registerServerFunction<T extends any[], R>(id: string, callback: (...args: T) => Promise<R>): (...args: T) => Promise<R>;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function hasServerFunction(id: string): boolean;
|
|
3
|
+
export declare function getServerFunction<T extends any[], R>(id: string): (...args: T) => Promise<R>;
|
package/dist/fns/registration.js
CHANGED
|
@@ -3,10 +3,13 @@ export function registerServerFunction(id, callback) {
|
|
|
3
3
|
REGISTRATIONS.set(id, callback);
|
|
4
4
|
return callback;
|
|
5
5
|
}
|
|
6
|
+
export function hasServerFunction(id) {
|
|
7
|
+
return REGISTRATIONS.has(id);
|
|
8
|
+
}
|
|
6
9
|
export function getServerFunction(id) {
|
|
7
10
|
const fn = REGISTRATIONS.get(id);
|
|
8
11
|
if (fn) {
|
|
9
12
|
return fn;
|
|
10
13
|
}
|
|
11
|
-
throw new Error(
|
|
14
|
+
throw new Error("invalid server function: " + id);
|
|
12
15
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { H3Event, HTTPEvent, InferEventInput } from "h3";
|
|
2
|
+
import * as h3 from "h3";
|
|
3
|
+
declare function _setContext(event: H3Event, key: string, value: any): void;
|
|
4
|
+
declare function _getContext(event: H3Event, key: string): unknown;
|
|
5
|
+
export declare function getWebRequest(): Request;
|
|
6
|
+
export declare const HTTPEventSymbol: unique symbol;
|
|
7
|
+
export declare function isEvent(obj: any): obj is h3.H3Event | {
|
|
8
|
+
[HTTPEventSymbol]: h3.H3Event;
|
|
9
|
+
};
|
|
10
|
+
type Tail<T> = T extends [any, ...infer U] ? U : never;
|
|
11
|
+
type PrependOverload<TOriginal extends (...args: Array<any>) => any, TOverload extends (...args: Array<any>) => any> = TOverload & TOriginal;
|
|
12
|
+
type WrapFunction<TFn extends (...args: Array<any>) => any> = PrependOverload<TFn, (...args: Parameters<TFn> extends [h3.HTTPEvent<any> | h3.H3Event<any>, ...infer TArgs] ? TArgs : Parameters<TFn>) => ReturnType<TFn>>;
|
|
13
|
+
type WrappedReadBody = <T, TEventInput = InferEventInput<"body", H3Event, T>>(...args: Tail<Parameters<typeof h3.readBody<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.readBody<T, h3.H3Event, TEventInput>>;
|
|
14
|
+
export declare const readBody: PrependOverload<typeof h3.readBody, WrappedReadBody>;
|
|
15
|
+
type WrappedGetQuery = <T, TEventInput = Exclude<InferEventInput<"query", H3Event, T>, undefined>>(...args: Tail<Parameters<typeof h3.getQuery<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.getQuery<T, H3Event, TEventInput>>;
|
|
16
|
+
export declare const getQuery: PrependOverload<typeof h3.getQuery, WrappedGetQuery>;
|
|
17
|
+
export declare const isMethod: WrapFunction<typeof h3.isMethod>;
|
|
18
|
+
export declare const isPreflightRequest: WrapFunction<typeof h3.isPreflightRequest>;
|
|
19
|
+
type WrappedGetValidatedQuery = <T extends HTTPEvent, TEventInput = InferEventInput<"query", H3Event, T>>(...args: Tail<Parameters<typeof h3.getValidatedQuery<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.getValidatedQuery<T, H3Event, TEventInput>>;
|
|
20
|
+
export declare const getValidatedQuery: PrependOverload<typeof h3.getValidatedQuery, WrappedGetValidatedQuery>;
|
|
21
|
+
export declare const getRouterParams: WrapFunction<typeof h3.getRouterParams>;
|
|
22
|
+
export declare const getRouterParam: WrapFunction<typeof h3.getRouterParam>;
|
|
23
|
+
type WrappedGetValidatedRouterParams = <T extends HTTPEvent, TEventInput = InferEventInput<"routerParams", H3Event, T>>(...args: Tail<Parameters<typeof h3.getValidatedRouterParams<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.getValidatedRouterParams<T, H3Event, TEventInput>>;
|
|
24
|
+
export declare const getValidatedRouterParams: PrependOverload<typeof h3.getValidatedRouterParams, WrappedGetValidatedRouterParams>;
|
|
25
|
+
export declare const assertMethod: WrapFunction<typeof h3.assertMethod>;
|
|
26
|
+
export declare const getRequestHeaders: WrapFunction<typeof h3.getRequestHeaders>;
|
|
27
|
+
export declare const getRequestHeader: WrapFunction<typeof h3.getRequestHeader>;
|
|
28
|
+
export declare const getRequestURL: WrapFunction<typeof h3.getRequestURL>;
|
|
29
|
+
export declare const getRequestHost: WrapFunction<typeof h3.getRequestHost>;
|
|
30
|
+
export declare const getRequestProtocol: WrapFunction<typeof h3.getRequestProtocol>;
|
|
31
|
+
export declare const getRequestIP: WrapFunction<typeof h3.getRequestIP>;
|
|
32
|
+
export declare const setResponseStatus: (code?: number, text?: string) => void;
|
|
33
|
+
export declare const getResponseStatus: () => number | undefined;
|
|
34
|
+
export declare const getResponseStatusText: () => string | undefined;
|
|
35
|
+
export declare const getResponseHeaders: () => {
|
|
36
|
+
[k: string]: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const getResponseHeader: (name: string) => string | null;
|
|
39
|
+
export declare const setResponseHeaders: (values: Record<string, string>) => void;
|
|
40
|
+
export declare const setResponseHeader: (name: string, value: string | string[]) => void;
|
|
41
|
+
export declare const appendResponseHeaders: (values: Record<string, string>) => void;
|
|
42
|
+
export declare const appendResponseHeader: (name: string, value: string | string[]) => void;
|
|
43
|
+
export declare const defaultContentType: (type: string) => void;
|
|
44
|
+
export declare const proxyRequest: WrapFunction<typeof h3.proxyRequest>;
|
|
45
|
+
export declare const fetchWithEvent: WrapFunction<typeof h3.fetchWithEvent>;
|
|
46
|
+
export declare const getProxyRequestHeaders: WrapFunction<typeof h3.getProxyRequestHeaders>;
|
|
47
|
+
export declare const parseCookies: WrapFunction<typeof h3.parseCookies>;
|
|
48
|
+
export declare const getCookie: WrapFunction<typeof h3.getCookie>;
|
|
49
|
+
export declare const setCookie: WrapFunction<typeof h3.setCookie>;
|
|
50
|
+
export declare const deleteCookie: WrapFunction<typeof h3.deleteCookie>;
|
|
51
|
+
type SessionDataT = Record<string, any>;
|
|
52
|
+
type WrappedUseSession = <T extends SessionDataT>(...args: Tail<Parameters<typeof h3.useSession<T>>>) => ReturnType<typeof h3.useSession<T>>;
|
|
53
|
+
export declare const useSession: WrappedUseSession;
|
|
54
|
+
type WrappedGetSession = <T extends SessionDataT>(...args: Tail<Parameters<typeof h3.getSession<T>>>) => ReturnType<typeof h3.getSession<T>>;
|
|
55
|
+
export declare const getSession: WrappedGetSession;
|
|
56
|
+
type WrappedUpdateSession = <T extends SessionDataT>(...args: Tail<Parameters<typeof h3.updateSession<T>>>) => ReturnType<typeof h3.updateSession<T>>;
|
|
57
|
+
export declare const updateSession: WrappedUpdateSession;
|
|
58
|
+
type WrappedSealSession = <T extends SessionDataT>(...args: Tail<Parameters<typeof h3.sealSession<T>>>) => ReturnType<typeof h3.sealSession<T>>;
|
|
59
|
+
export declare const sealSession: WrappedSealSession;
|
|
60
|
+
export declare const unsealSession: WrapFunction<typeof h3.unsealSession>;
|
|
61
|
+
export declare const clearSession: WrapFunction<typeof h3.clearSession>;
|
|
62
|
+
export declare const handleCacheHeaders: WrapFunction<typeof h3.handleCacheHeaders>;
|
|
63
|
+
export declare const handleCors: WrapFunction<typeof h3.handleCors>;
|
|
64
|
+
export declare const appendCorsHeaders: WrapFunction<typeof h3.appendCorsHeaders>;
|
|
65
|
+
export declare const appendCorsPreflightHeaders: WrapFunction<typeof h3.appendCorsPreflightHeaders>;
|
|
66
|
+
export declare const appendHeader: typeof appendResponseHeader;
|
|
67
|
+
export declare const appendHeaders: typeof appendResponseHeaders;
|
|
68
|
+
export declare const setHeader: typeof setResponseHeader;
|
|
69
|
+
export declare const setHeaders: typeof setResponseHeaders;
|
|
70
|
+
export declare const getHeader: WrapFunction<typeof h3.getRequestHeader>;
|
|
71
|
+
export declare const getHeaders: WrapFunction<typeof h3.getRequestHeaders>;
|
|
72
|
+
export declare const getRequestFingerprint: WrapFunction<typeof h3.getRequestFingerprint>;
|
|
73
|
+
export declare const getRequestWebStream: () => ReadableStream<Uint8Array<ArrayBuffer>> | null;
|
|
74
|
+
export declare const readFormData: () => Promise<FormData>;
|
|
75
|
+
type WrappedReadValidatedBody = <T extends HTTPEvent, TEventInput = InferEventInput<"body", H3Event, T>>(...args: Tail<Parameters<typeof h3.readValidatedBody<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.readValidatedBody<T, H3Event, TEventInput>>;
|
|
76
|
+
export declare const readValidatedBody: PrependOverload<typeof h3.readValidatedBody, WrappedReadValidatedBody>;
|
|
77
|
+
export declare const getContext: WrapFunction<typeof _getContext>;
|
|
78
|
+
export declare const setContext: WrapFunction<typeof _setContext>;
|
|
79
|
+
export declare const removeResponseHeader: (name: string) => void;
|
|
80
|
+
export declare const clearResponseHeaders: (headerNames?: string[]) => void;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as h3 from "h3";
|
|
2
|
+
import { getRequestEvent } from "solid-js/web";
|
|
3
|
+
function _setContext(event, key, value) {
|
|
4
|
+
event.context[key] = value;
|
|
5
|
+
}
|
|
6
|
+
function _getContext(event, key) {
|
|
7
|
+
return event.context[key];
|
|
8
|
+
}
|
|
9
|
+
function getEvent() {
|
|
10
|
+
return getRequestEvent().nativeEvent;
|
|
11
|
+
}
|
|
12
|
+
export function getWebRequest() {
|
|
13
|
+
return getEvent().req;
|
|
14
|
+
}
|
|
15
|
+
export const HTTPEventSymbol = Symbol("$HTTPEvent");
|
|
16
|
+
export function isEvent(obj) {
|
|
17
|
+
return (typeof obj === "object" &&
|
|
18
|
+
(obj instanceof h3.H3Event ||
|
|
19
|
+
obj?.[HTTPEventSymbol] instanceof h3.H3Event ||
|
|
20
|
+
obj?.__is_event__ === true));
|
|
21
|
+
// Implement logic to check if obj is an H3Event
|
|
22
|
+
}
|
|
23
|
+
function createWrapperFunction(h3Function) {
|
|
24
|
+
return ((...args) => {
|
|
25
|
+
const event = args[0];
|
|
26
|
+
if (!isEvent(event)) {
|
|
27
|
+
args.unshift(getEvent());
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
args[0] =
|
|
31
|
+
event instanceof h3.H3Event || event.__is_event__ ? event : event[HTTPEventSymbol];
|
|
32
|
+
}
|
|
33
|
+
return h3Function(...args);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export const readBody = createWrapperFunction(h3.readBody);
|
|
37
|
+
export const getQuery = createWrapperFunction(h3.getQuery);
|
|
38
|
+
export const isMethod = createWrapperFunction(h3.isMethod);
|
|
39
|
+
export const isPreflightRequest = createWrapperFunction(h3.isPreflightRequest);
|
|
40
|
+
export const getValidatedQuery = createWrapperFunction(h3.getValidatedQuery);
|
|
41
|
+
export const getRouterParams = createWrapperFunction(h3.getRouterParams);
|
|
42
|
+
export const getRouterParam = createWrapperFunction(h3.getRouterParam);
|
|
43
|
+
export const getValidatedRouterParams = createWrapperFunction(h3.getValidatedRouterParams);
|
|
44
|
+
export const assertMethod = createWrapperFunction(h3.assertMethod);
|
|
45
|
+
export const getRequestHeaders = createWrapperFunction(h3.getRequestHeaders);
|
|
46
|
+
export const getRequestHeader = createWrapperFunction(h3.getRequestHeader);
|
|
47
|
+
export const getRequestURL = createWrapperFunction(h3.getRequestURL);
|
|
48
|
+
export const getRequestHost = createWrapperFunction(h3.getRequestHost);
|
|
49
|
+
export const getRequestProtocol = createWrapperFunction(h3.getRequestProtocol);
|
|
50
|
+
export const getRequestIP = createWrapperFunction(h3.getRequestIP);
|
|
51
|
+
export const setResponseStatus = (code, text) => {
|
|
52
|
+
const e = getEvent();
|
|
53
|
+
if (e.res.status !== undefined)
|
|
54
|
+
e.res.status = code;
|
|
55
|
+
if (e.res.statusText !== undefined)
|
|
56
|
+
e.res.statusText = text;
|
|
57
|
+
};
|
|
58
|
+
export const getResponseStatus = () => getEvent().res.status;
|
|
59
|
+
export const getResponseStatusText = () => getEvent().res.statusText;
|
|
60
|
+
export const getResponseHeaders = () => Object.fromEntries(getEvent().res.headers.entries());
|
|
61
|
+
export const getResponseHeader = (name) => getEvent().res.headers.get(name);
|
|
62
|
+
export const setResponseHeaders = (values) => {
|
|
63
|
+
const headers = getEvent().res.headers;
|
|
64
|
+
for (const [name, value] of Object.entries(values)) {
|
|
65
|
+
headers.set(name, value);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export const setResponseHeader = (name, value) => {
|
|
69
|
+
const headers = getEvent().res.headers;
|
|
70
|
+
(Array.isArray(value) ? value : [value]).forEach(value => {
|
|
71
|
+
headers.set(name, value);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
export const appendResponseHeaders = (values) => {
|
|
75
|
+
const headers = getEvent().res.headers;
|
|
76
|
+
for (const [name, value] of Object.entries(values)) {
|
|
77
|
+
headers.append(name, value);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const appendResponseHeader = (name, value) => {
|
|
81
|
+
const headers = getEvent().res.headers;
|
|
82
|
+
(Array.isArray(value) ? value : [value]).forEach(value => {
|
|
83
|
+
headers.append(name, value);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
export const defaultContentType = (type) => getEvent().res.headers.set("content-type", type);
|
|
87
|
+
export const proxyRequest = createWrapperFunction(h3.proxyRequest);
|
|
88
|
+
export const fetchWithEvent = createWrapperFunction(h3.fetchWithEvent);
|
|
89
|
+
export const getProxyRequestHeaders = createWrapperFunction(h3.getProxyRequestHeaders);
|
|
90
|
+
export const parseCookies = createWrapperFunction(h3.parseCookies);
|
|
91
|
+
export const getCookie = createWrapperFunction(h3.getCookie);
|
|
92
|
+
export const setCookie = createWrapperFunction(h3.setCookie);
|
|
93
|
+
export const deleteCookie = createWrapperFunction(h3.deleteCookie);
|
|
94
|
+
export const useSession = createWrapperFunction(h3.useSession);
|
|
95
|
+
export const getSession = createWrapperFunction(h3.getSession);
|
|
96
|
+
export const updateSession = createWrapperFunction(h3.updateSession);
|
|
97
|
+
export const sealSession = createWrapperFunction(h3.sealSession);
|
|
98
|
+
export const unsealSession = createWrapperFunction(h3.unsealSession);
|
|
99
|
+
export const clearSession = createWrapperFunction(h3.clearSession);
|
|
100
|
+
export const handleCacheHeaders = createWrapperFunction(h3.handleCacheHeaders);
|
|
101
|
+
export const handleCors = createWrapperFunction(h3.handleCors);
|
|
102
|
+
export const appendCorsHeaders = createWrapperFunction(h3.appendCorsHeaders);
|
|
103
|
+
export const appendCorsPreflightHeaders = createWrapperFunction(h3.appendCorsPreflightHeaders);
|
|
104
|
+
export const appendHeader = appendResponseHeader;
|
|
105
|
+
export const appendHeaders = appendResponseHeaders;
|
|
106
|
+
export const setHeader = setResponseHeader;
|
|
107
|
+
export const setHeaders = setResponseHeaders;
|
|
108
|
+
export const getHeader = getRequestHeader;
|
|
109
|
+
export const getHeaders = getRequestHeaders;
|
|
110
|
+
export const getRequestFingerprint = createWrapperFunction(h3.getRequestFingerprint);
|
|
111
|
+
export const getRequestWebStream = () => getEvent().req.body;
|
|
112
|
+
export const readFormData = () => getEvent().req.formData();
|
|
113
|
+
export const readValidatedBody = createWrapperFunction(h3.readValidatedBody);
|
|
114
|
+
export const getContext = createWrapperFunction(_getContext);
|
|
115
|
+
export const setContext = createWrapperFunction(_setContext);
|
|
116
|
+
export const removeResponseHeader = (name) => getEvent().res.headers.delete(name);
|
|
117
|
+
export const clearResponseHeaders = (headerNames) => {
|
|
118
|
+
const headers = getEvent().res.headers;
|
|
119
|
+
if (headerNames && headerNames.length > 0) {
|
|
120
|
+
for (const name of headerNames) {
|
|
121
|
+
headers.delete(name);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
for (const name of headers.keys()) {
|
|
126
|
+
headers.delete(name);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,81 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare function _setContext(event: H3Event, key: string, value: any): void;
|
|
4
|
-
declare function _getContext(event: H3Event, key: string): unknown;
|
|
5
|
-
export declare function getWebRequest(): Request;
|
|
6
|
-
export declare const HTTPEventSymbol: unique symbol;
|
|
7
|
-
export declare function isEvent(obj: any): obj is h3.H3Event | {
|
|
8
|
-
[HTTPEventSymbol]: h3.H3Event;
|
|
9
|
-
};
|
|
10
|
-
type Tail<T> = T extends [any, ...infer U] ? U : never;
|
|
11
|
-
type PrependOverload<TOriginal extends (...args: Array<any>) => any, TOverload extends (...args: Array<any>) => any> = TOverload & TOriginal;
|
|
12
|
-
type WrapFunction<TFn extends (...args: Array<any>) => any> = PrependOverload<TFn, (...args: Parameters<TFn> extends [h3.HTTPEvent<any> | h3.H3Event<any>, ...infer TArgs] ? TArgs : Parameters<TFn>) => ReturnType<TFn>>;
|
|
13
|
-
type WrappedReadBody = <T, TEventInput = InferEventInput<"body", H3Event, T>>(...args: Tail<Parameters<typeof h3.readBody<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.readBody<T, h3.H3Event, TEventInput>>;
|
|
14
|
-
export declare const readBody: PrependOverload<typeof h3.readBody, WrappedReadBody>;
|
|
15
|
-
type WrappedGetQuery = <T, TEventInput = Exclude<InferEventInput<"query", H3Event, T>, undefined>>(...args: Tail<Parameters<typeof h3.getQuery<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.getQuery<T, H3Event, TEventInput>>;
|
|
16
|
-
export declare const getQuery: PrependOverload<typeof h3.getQuery, WrappedGetQuery>;
|
|
17
|
-
export declare const isMethod: WrapFunction<typeof h3.isMethod>;
|
|
18
|
-
export declare const isPreflightRequest: WrapFunction<typeof h3.isPreflightRequest>;
|
|
19
|
-
type WrappedGetValidatedQuery = <T extends HTTPEvent, TEventInput = InferEventInput<"query", H3Event, T>>(...args: Tail<Parameters<typeof h3.getValidatedQuery<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.getValidatedQuery<T, H3Event, TEventInput>>;
|
|
20
|
-
export declare const getValidatedQuery: PrependOverload<typeof h3.getValidatedQuery, WrappedGetValidatedQuery>;
|
|
21
|
-
export declare const getRouterParams: WrapFunction<typeof h3.getRouterParams>;
|
|
22
|
-
export declare const getRouterParam: WrapFunction<typeof h3.getRouterParam>;
|
|
23
|
-
type WrappedGetValidatedRouterParams = <T extends HTTPEvent, TEventInput = InferEventInput<"routerParams", H3Event, T>>(...args: Tail<Parameters<typeof h3.getValidatedRouterParams<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.getValidatedRouterParams<T, H3Event, TEventInput>>;
|
|
24
|
-
export declare const getValidatedRouterParams: PrependOverload<typeof h3.getValidatedRouterParams, WrappedGetValidatedRouterParams>;
|
|
25
|
-
export declare const assertMethod: WrapFunction<typeof h3.assertMethod>;
|
|
26
|
-
export declare const getRequestHeaders: WrapFunction<typeof h3.getRequestHeaders>;
|
|
27
|
-
export declare const getRequestHeader: WrapFunction<typeof h3.getRequestHeader>;
|
|
28
|
-
export declare const getRequestURL: WrapFunction<typeof h3.getRequestURL>;
|
|
29
|
-
export declare const getRequestHost: WrapFunction<typeof h3.getRequestHost>;
|
|
30
|
-
export declare const getRequestProtocol: WrapFunction<typeof h3.getRequestProtocol>;
|
|
31
|
-
export declare const getRequestIP: WrapFunction<typeof h3.getRequestIP>;
|
|
32
|
-
export declare const setResponseStatus: (code?: number, text?: string) => void;
|
|
33
|
-
export declare const getResponseStatus: () => number | undefined;
|
|
34
|
-
export declare const getResponseStatusText: () => string | undefined;
|
|
35
|
-
export declare const getResponseHeaders: () => {
|
|
36
|
-
[k: string]: string;
|
|
37
|
-
};
|
|
38
|
-
export declare const getResponseHeader: (name: string) => string | null;
|
|
39
|
-
export declare const setResponseHeaders: (values: Record<string, string>) => void;
|
|
40
|
-
export declare const setResponseHeader: (name: string, value: string | string[]) => void;
|
|
41
|
-
export declare const appendResponseHeaders: (values: Record<string, string>) => void;
|
|
42
|
-
export declare const appendResponseHeader: (name: string, value: string | string[]) => void;
|
|
43
|
-
export declare const defaultContentType: (type: string) => void;
|
|
44
|
-
export declare const proxyRequest: WrapFunction<typeof h3.proxyRequest>;
|
|
45
|
-
export declare const fetchWithEvent: WrapFunction<typeof h3.fetchWithEvent>;
|
|
46
|
-
export declare const getProxyRequestHeaders: WrapFunction<typeof h3.getProxyRequestHeaders>;
|
|
47
|
-
export declare const parseCookies: WrapFunction<typeof h3.parseCookies>;
|
|
48
|
-
export declare const getCookie: WrapFunction<typeof h3.getCookie>;
|
|
49
|
-
export declare const setCookie: WrapFunction<typeof h3.setCookie>;
|
|
50
|
-
export declare const deleteCookie: WrapFunction<typeof h3.deleteCookie>;
|
|
51
|
-
type SessionDataT = Record<string, any>;
|
|
52
|
-
type WrappedUseSession = <T extends SessionDataT>(...args: Tail<Parameters<typeof h3.useSession<T>>>) => ReturnType<typeof h3.useSession<T>>;
|
|
53
|
-
export declare const useSession: WrappedUseSession;
|
|
54
|
-
type WrappedGetSession = <T extends SessionDataT>(...args: Tail<Parameters<typeof h3.getSession<T>>>) => ReturnType<typeof h3.getSession<T>>;
|
|
55
|
-
export declare const getSession: WrappedGetSession;
|
|
56
|
-
type WrappedUpdateSession = <T extends SessionDataT>(...args: Tail<Parameters<typeof h3.updateSession<T>>>) => ReturnType<typeof h3.updateSession<T>>;
|
|
57
|
-
export declare const updateSession: WrappedUpdateSession;
|
|
58
|
-
type WrappedSealSession = <T extends SessionDataT>(...args: Tail<Parameters<typeof h3.sealSession<T>>>) => ReturnType<typeof h3.sealSession<T>>;
|
|
59
|
-
export declare const sealSession: WrappedSealSession;
|
|
60
|
-
export declare const unsealSession: WrapFunction<typeof h3.unsealSession>;
|
|
61
|
-
export declare const clearSession: WrapFunction<typeof h3.clearSession>;
|
|
62
|
-
export declare const handleCacheHeaders: WrapFunction<typeof h3.handleCacheHeaders>;
|
|
63
|
-
export declare const handleCors: WrapFunction<typeof h3.handleCors>;
|
|
64
|
-
export declare const appendCorsHeaders: WrapFunction<typeof h3.appendCorsHeaders>;
|
|
65
|
-
export declare const appendCorsPreflightHeaders: WrapFunction<typeof h3.appendCorsPreflightHeaders>;
|
|
66
|
-
export declare const appendHeader: (name: string, value: string | string[]) => void;
|
|
67
|
-
export declare const appendHeaders: (values: Record<string, string>) => void;
|
|
68
|
-
export declare const setHeader: (name: string, value: string | string[]) => void;
|
|
69
|
-
export declare const setHeaders: (values: Record<string, string>) => void;
|
|
70
|
-
export declare const getHeader: WrapFunction<typeof h3.getRequestHeader>;
|
|
71
|
-
export declare const getHeaders: WrapFunction<typeof h3.getRequestHeaders>;
|
|
72
|
-
export declare const getRequestFingerprint: WrapFunction<typeof h3.getRequestFingerprint>;
|
|
73
|
-
export declare const getRequestWebStream: () => ReadableStream<Uint8Array<ArrayBuffer>> | null;
|
|
74
|
-
export declare const readFormData: () => Promise<FormData>;
|
|
75
|
-
type WrappedReadValidatedBody = <T extends HTTPEvent, TEventInput = InferEventInput<"body", H3Event, T>>(...args: Tail<Parameters<typeof h3.readValidatedBody<T, H3Event, TEventInput>>>) => ReturnType<typeof h3.readValidatedBody<T, H3Event, TEventInput>>;
|
|
76
|
-
export declare const readValidatedBody: PrependOverload<typeof h3.readValidatedBody, WrappedReadValidatedBody>;
|
|
77
|
-
export declare const getContext: WrapFunction<typeof _getContext>;
|
|
78
|
-
export declare const setContext: WrapFunction<typeof _setContext>;
|
|
79
|
-
export declare const removeResponseHeader: (name: string) => void;
|
|
80
|
-
export declare const clearResponseHeaders: (headerNames?: string[]) => void;
|
|
81
|
-
export {};
|
|
1
|
+
import "server-only";
|
|
2
|
+
export * from "./http.ts";
|
package/dist/http/index.js
CHANGED
|
@@ -1,129 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return event.context[key];
|
|
8
|
-
}
|
|
9
|
-
function getEvent() {
|
|
10
|
-
return getRequestEvent().nativeEvent;
|
|
11
|
-
}
|
|
12
|
-
export function getWebRequest() {
|
|
13
|
-
return getEvent().req;
|
|
14
|
-
}
|
|
15
|
-
export const HTTPEventSymbol = Symbol("$HTTPEvent");
|
|
16
|
-
export function isEvent(obj) {
|
|
17
|
-
return (typeof obj === "object" &&
|
|
18
|
-
(obj instanceof h3.H3Event ||
|
|
19
|
-
obj?.[HTTPEventSymbol] instanceof h3.H3Event ||
|
|
20
|
-
obj?.__is_event__ === true));
|
|
21
|
-
// Implement logic to check if obj is an H3Event
|
|
22
|
-
}
|
|
23
|
-
function createWrapperFunction(h3Function) {
|
|
24
|
-
return ((...args) => {
|
|
25
|
-
const event = args[0];
|
|
26
|
-
if (!isEvent(event)) {
|
|
27
|
-
args.unshift(getEvent());
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
args[0] =
|
|
31
|
-
event instanceof h3.H3Event || event.__is_event__ ? event : event[HTTPEventSymbol];
|
|
32
|
-
}
|
|
33
|
-
return h3Function(...args);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
export const readBody = createWrapperFunction(h3.readBody);
|
|
37
|
-
export const getQuery = createWrapperFunction(h3.getQuery);
|
|
38
|
-
export const isMethod = createWrapperFunction(h3.isMethod);
|
|
39
|
-
export const isPreflightRequest = createWrapperFunction(h3.isPreflightRequest);
|
|
40
|
-
export const getValidatedQuery = createWrapperFunction(h3.getValidatedQuery);
|
|
41
|
-
export const getRouterParams = createWrapperFunction(h3.getRouterParams);
|
|
42
|
-
export const getRouterParam = createWrapperFunction(h3.getRouterParam);
|
|
43
|
-
export const getValidatedRouterParams = createWrapperFunction(h3.getValidatedRouterParams);
|
|
44
|
-
export const assertMethod = createWrapperFunction(h3.assertMethod);
|
|
45
|
-
export const getRequestHeaders = createWrapperFunction(h3.getRequestHeaders);
|
|
46
|
-
export const getRequestHeader = createWrapperFunction(h3.getRequestHeader);
|
|
47
|
-
export const getRequestURL = createWrapperFunction(h3.getRequestURL);
|
|
48
|
-
export const getRequestHost = createWrapperFunction(h3.getRequestHost);
|
|
49
|
-
export const getRequestProtocol = createWrapperFunction(h3.getRequestProtocol);
|
|
50
|
-
export const getRequestIP = createWrapperFunction(h3.getRequestIP);
|
|
51
|
-
export const setResponseStatus = (code, text) => {
|
|
52
|
-
const e = getEvent();
|
|
53
|
-
if (e.res.status !== undefined)
|
|
54
|
-
e.res.status = code;
|
|
55
|
-
if (e.res.statusText !== undefined)
|
|
56
|
-
e.res.statusText = text;
|
|
57
|
-
};
|
|
58
|
-
export const getResponseStatus = () => getEvent().res.status;
|
|
59
|
-
export const getResponseStatusText = () => getEvent().res.statusText;
|
|
60
|
-
export const getResponseHeaders = () => Object.fromEntries(getEvent().res.headers.entries());
|
|
61
|
-
export const getResponseHeader = (name) => getEvent().res.headers.get(name);
|
|
62
|
-
export const setResponseHeaders = (values) => {
|
|
63
|
-
const headers = getEvent().res.headers;
|
|
64
|
-
for (const [name, value] of Object.entries(values)) {
|
|
65
|
-
headers.set(name, value);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
export const setResponseHeader = (name, value) => {
|
|
69
|
-
const headers = getEvent().res.headers;
|
|
70
|
-
(Array.isArray(value) ? value : [value]).forEach(value => {
|
|
71
|
-
headers.set(name, value);
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
export const appendResponseHeaders = (values) => {
|
|
75
|
-
const headers = getEvent().res.headers;
|
|
76
|
-
for (const [name, value] of Object.entries(values)) {
|
|
77
|
-
headers.append(name, value);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
export const appendResponseHeader = (name, value) => {
|
|
81
|
-
const headers = getEvent().res.headers;
|
|
82
|
-
(Array.isArray(value) ? value : [value]).forEach(value => {
|
|
83
|
-
headers.append(name, value);
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
export const defaultContentType = (type) => getEvent().res.headers.set("content-type", type);
|
|
87
|
-
export const proxyRequest = createWrapperFunction(h3.proxyRequest);
|
|
88
|
-
export const fetchWithEvent = createWrapperFunction(h3.fetchWithEvent);
|
|
89
|
-
export const getProxyRequestHeaders = createWrapperFunction(h3.getProxyRequestHeaders);
|
|
90
|
-
export const parseCookies = createWrapperFunction(h3.parseCookies);
|
|
91
|
-
export const getCookie = createWrapperFunction(h3.getCookie);
|
|
92
|
-
export const setCookie = createWrapperFunction(h3.setCookie);
|
|
93
|
-
export const deleteCookie = createWrapperFunction(h3.deleteCookie);
|
|
94
|
-
export const useSession = createWrapperFunction(h3.useSession);
|
|
95
|
-
export const getSession = createWrapperFunction(h3.getSession);
|
|
96
|
-
export const updateSession = createWrapperFunction(h3.updateSession);
|
|
97
|
-
export const sealSession = createWrapperFunction(h3.sealSession);
|
|
98
|
-
export const unsealSession = createWrapperFunction(h3.unsealSession);
|
|
99
|
-
export const clearSession = createWrapperFunction(h3.clearSession);
|
|
100
|
-
export const handleCacheHeaders = createWrapperFunction(h3.handleCacheHeaders);
|
|
101
|
-
export const handleCors = createWrapperFunction(h3.handleCors);
|
|
102
|
-
export const appendCorsHeaders = createWrapperFunction(h3.appendCorsHeaders);
|
|
103
|
-
export const appendCorsPreflightHeaders = createWrapperFunction(h3.appendCorsPreflightHeaders);
|
|
104
|
-
export const appendHeader = appendResponseHeader;
|
|
105
|
-
export const appendHeaders = appendResponseHeaders;
|
|
106
|
-
export const setHeader = setResponseHeader;
|
|
107
|
-
export const setHeaders = setResponseHeaders;
|
|
108
|
-
export const getHeader = getRequestHeader;
|
|
109
|
-
export const getHeaders = getRequestHeaders;
|
|
110
|
-
export const getRequestFingerprint = createWrapperFunction(h3.getRequestFingerprint);
|
|
111
|
-
export const getRequestWebStream = () => getEvent().req.body;
|
|
112
|
-
export const readFormData = () => getEvent().req.formData();
|
|
113
|
-
export const readValidatedBody = createWrapperFunction(h3.readValidatedBody);
|
|
114
|
-
export const getContext = createWrapperFunction(_getContext);
|
|
115
|
-
export const setContext = createWrapperFunction(_setContext);
|
|
116
|
-
export const removeResponseHeader = (name) => getEvent().res.headers.delete(name);
|
|
117
|
-
export const clearResponseHeaders = (headerNames) => {
|
|
118
|
-
const headers = getEvent().res.headers;
|
|
119
|
-
if (headerNames && headerNames.length > 0) {
|
|
120
|
-
for (const name of headerNames) {
|
|
121
|
-
headers.delete(name);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
for (const name of headers.keys()) {
|
|
126
|
-
headers.delete(name);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
1
|
+
// The public `@solidjs/start/http` entry is server-only: importing it from
|
|
2
|
+
// client-reachable code fails at resolve time (#2068). Internal isomorphic
|
|
3
|
+
// code (e.g. `<HttpHeader>`) imports `./http.ts` directly, since it only
|
|
4
|
+
// touches these helpers behind an `isServer` check.
|
|
5
|
+
import "server-only";
|
|
6
|
+
export * from "./http.js";
|
package/dist/middleware/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export function StartServer(props) {
|
|
|
19
19
|
<TopErrorBoundary>
|
|
20
20
|
<props.document assets={<HydrationScript />} scripts={<>
|
|
21
21
|
<PatchVirtualDevStyles nonce={nonce}/>
|
|
22
|
-
<script type="module" nonce={nonce} async src={getSsrManifest("client").path(import.meta.env.
|
|
22
|
+
<script type="module" nonce={nonce} async src={getSsrManifest("client").path(import.meta.env.START_CLIENT_ENTRY_URL)}/>
|
|
23
23
|
</>}>
|
|
24
24
|
{!import.meta.env.START_ISLANDS ? (<Hydration>
|
|
25
25
|
<ErrorBoundary>
|
package/dist/server/handler.d.ts
CHANGED
|
@@ -1,64 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H3 } from "h3/generic";
|
|
2
2
|
import type { JSX } from "solid-js";
|
|
3
3
|
import type { FetchEvent, HandlerOptions, PageEvent } from "./types.ts";
|
|
4
|
-
export declare function createBaseHandler(createPageEvent: (e: FetchEvent) => Promise<PageEvent>, fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)):
|
|
5
|
-
|
|
6
|
-
request(request: import("srvx").ServerRequest | URL | string, options?: RequestInit, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
7
|
-
use(route: string, handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
8
|
-
use(handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
9
|
-
on(method: import("h3").HTTPMethod | Lowercase<import("h3").HTTPMethod> | "", route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
10
|
-
register(plugin: import("h3").H3Plugin): /*elided*/ any;
|
|
11
|
-
mount(base: string, input: import("srvx").FetchHandler | {
|
|
12
|
-
fetch: import("srvx").FetchHandler;
|
|
13
|
-
} | /*elided*/ any): /*elided*/ any;
|
|
14
|
-
all(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
15
|
-
get(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
16
|
-
post(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
17
|
-
put(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
18
|
-
delete(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
19
|
-
patch(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
20
|
-
head(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
21
|
-
options(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
22
|
-
connect(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
23
|
-
trace(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
24
|
-
readonly config: import("h3").H3Config;
|
|
25
|
-
"~middleware": import("h3").Middleware[];
|
|
26
|
-
"~routes": import("h3").H3Route[];
|
|
27
|
-
fetch(_request: import("srvx").ServerRequest): Response | Promise<Response>;
|
|
28
|
-
handler(event: H3Event): unknown | Promise<unknown>;
|
|
29
|
-
"~request"(request: import("srvx").ServerRequest, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
30
|
-
"~findRoute"(_event: H3Event): import("h3").MatchedRoute<import("h3").H3Route> | void;
|
|
31
|
-
"~getMiddleware"(event: H3Event, route: import("h3").MatchedRoute<import("h3").H3Route> | undefined): import("h3").Middleware[];
|
|
32
|
-
"~addRoute"(_route: import("h3").H3Route): void;
|
|
33
|
-
};
|
|
34
|
-
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)): {
|
|
35
|
-
"~rou3": import("h3").RouterContext;
|
|
36
|
-
request(request: import("srvx").ServerRequest | URL | string, options?: RequestInit, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
37
|
-
use(route: string, handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
38
|
-
use(handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
39
|
-
on(method: import("h3").HTTPMethod | Lowercase<import("h3").HTTPMethod> | "", route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
40
|
-
register(plugin: import("h3").H3Plugin): /*elided*/ any;
|
|
41
|
-
mount(base: string, input: import("srvx").FetchHandler | {
|
|
42
|
-
fetch: import("srvx").FetchHandler;
|
|
43
|
-
} | /*elided*/ any): /*elided*/ any;
|
|
44
|
-
all(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
45
|
-
get(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
46
|
-
post(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
47
|
-
put(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
48
|
-
delete(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
49
|
-
patch(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
50
|
-
head(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
51
|
-
options(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
52
|
-
connect(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
53
|
-
trace(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
54
|
-
readonly config: import("h3").H3Config;
|
|
55
|
-
"~middleware": import("h3").Middleware[];
|
|
56
|
-
"~routes": import("h3").H3Route[];
|
|
57
|
-
fetch(_request: import("srvx").ServerRequest): Response | Promise<Response>;
|
|
58
|
-
handler(event: H3Event): unknown | Promise<unknown>;
|
|
59
|
-
"~request"(request: import("srvx").ServerRequest, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
60
|
-
"~findRoute"(_event: H3Event): import("h3").MatchedRoute<import("h3").H3Route> | void;
|
|
61
|
-
"~getMiddleware"(event: H3Event, route: import("h3").MatchedRoute<import("h3").H3Route> | undefined): import("h3").Middleware[];
|
|
62
|
-
"~addRoute"(_route: import("h3").H3Route): void;
|
|
63
|
-
};
|
|
4
|
+
export declare function createBaseHandler(createPageEvent: (e: FetchEvent) => Promise<PageEvent>, fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)): H3;
|
|
5
|
+
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)): H3;
|
|
64
6
|
export declare function createPageEvent(ctx: FetchEvent): Promise<PageEvent>;
|