@torpor/build 0.2.0 → 0.3.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/CHANGELOG.md +42 -0
- package/dist/RouteType-g8Ce5gOd.js +107 -0
- package/dist/RouteType-g8Ce5gOd.js.map +1 -0
- package/dist/Server-CSpY_-Ba.d.ts +78 -0
- package/dist/Server-CSpY_-Ba.d.ts.map +1 -0
- package/dist/ServerEvent-2-CnAy1W.js +74 -0
- package/dist/ServerEvent-2-CnAy1W.js.map +1 -0
- package/dist/Site-D4x1l0p5.d.ts +67 -0
- package/dist/Site-D4x1l0p5.d.ts.map +1 -0
- package/dist/_page-Cv6YWocY.js +33 -0
- package/dist/_page-Cv6YWocY.js.map +1 -0
- package/dist/bin/index.d.ts +1 -1
- package/dist/bin/index.js +14 -19
- package/dist/bin/index.js.map +1 -1
- package/dist/connectMiddleware-DbLj0St1.js +252 -0
- package/dist/connectMiddleware-DbLj0St1.js.map +1 -0
- package/dist/index.d.ts +188 -179
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -145
- package/dist/index.js.map +1 -1
- package/dist/nav.d.ts +14 -0
- package/dist/nav.d.ts.map +1 -0
- package/dist/nav.js +206 -0
- package/dist/nav.js.map +1 -0
- package/dist/pathToRegex-CTgx7hQP.js +11 -0
- package/dist/pathToRegex-CTgx7hQP.js.map +1 -0
- package/dist/response-D-XpIuMH.js +307 -0
- package/dist/response-D-XpIuMH.js.map +1 -0
- package/dist/response.d.ts +336 -151
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +4 -37
- package/dist/run-CVKpO0HO.js +331 -0
- package/dist/run-CVKpO0HO.js.map +1 -0
- package/dist/run.d.ts +11 -8
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +8 -18
- package/dist/seeOther-BmehiI4C.js +110 -0
- package/dist/seeOther-BmehiI4C.js.map +1 -0
- package/dist/server.d.ts +12 -11
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +5 -18
- package/dist/state.d.ts +14 -10
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +3 -7
- package/dist/test.d.ts +12 -11
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +152 -225
- package/dist/test.js.map +1 -1
- package/package.json +25 -29
- package/src/bin/index.ts +9 -11
- package/src/index.ts +3 -0
- package/src/nav/formSubmit.ts +48 -0
- package/src/nav/load.ts +9 -0
- package/src/nav/loadData.ts +121 -0
- package/src/nav/navigate.ts +163 -0
- package/src/nav/reload.ts +9 -0
- package/src/nav.ts +4 -0
- package/src/response/badRequest.ts +9 -4
- package/src/response/created.ts +10 -3
- package/src/response/forbidden.ts +11 -4
- package/src/response/found.ts +30 -0
- package/src/response/methodNotAllowed.ts +8 -4
- package/src/response/movedPermanently.ts +25 -0
- package/src/response/notFound.ts +14 -7
- package/src/response/notModified.ts +24 -4
- package/src/response/ok.ts +19 -10
- package/src/response/permanentRedirect.ts +30 -0
- package/src/response/seeOther.ts +9 -3
- package/src/response/serverError.ts +14 -2
- package/src/response/temporaryRedirect.ts +31 -0
- package/src/response/unauthorized.ts +11 -4
- package/src/response/unprocessable.ts +8 -2
- package/src/response.ts +8 -4
- package/src/{site → run}/prepareTemplate.ts +1 -1
- package/src/{site → run}/run.ts +1 -1
- package/src/{site → run}/runBuild.ts +2 -2
- package/src/{site → run}/runDev.ts +2 -2
- package/src/{site → run}/runPreview.ts +1 -1
- package/src/run.ts +4 -4
- package/src/server/Routerx.ts +3 -3
- package/src/server/Server.ts +3 -3
- package/src/server/connect/connectMiddleware.ts +2 -1
- package/src/server/connect/nodeMessageToNodeResponse.ts +2 -2
- package/src/site/Router.ts +3 -3
- package/src/site/clientEntry.ts +16 -269
- package/src/site/defaultAdapter.ts +1 -1
- package/src/site/serverEntry.ts +86 -45
- package/src/state/$page.ts +3 -12
- package/src/state/client.ts +6 -0
- package/src/state/internal.ts +45 -0
- package/src/test/runTest.ts +1 -1
- package/src/types/Adapter.ts +2 -4
- package/src/types/ClientState.ts +8 -0
- package/src/types/InternalState.ts +7 -0
- package/src/types/LayoutHandler.ts +2 -4
- package/src/types/LayoutPath.ts +10 -0
- package/src/types/ManifestRoute.ts +2 -4
- package/src/types/PageEndPoint.ts +2 -4
- package/src/types/PageLoadEvent.ts +2 -4
- package/src/types/PageServerEndPoint.ts +2 -4
- package/src/types/PageState.ts +8 -0
- package/src/types/RouteHandler.ts +2 -4
- package/src/types/RouteLayoutHandler.ts +2 -4
- package/src/types/RouteMatchResult.ts +2 -4
- package/src/types/ServerHook.ts +3 -7
- package/src/types/ServerLoadEvent.ts +2 -4
- package/src/{site → utils}/pathToRegex.ts +1 -1
- package/{tsup.config.ts → tsdown.config.ts} +3 -4
- package/dist/Server-CNZWh5ca.d.cts +0 -71
- package/dist/Server-CNZWh5ca.d.ts +0 -71
- package/dist/Site-C2020GV_.d.ts +0 -63
- package/dist/Site-DQojGpE-.d.cts +0 -63
- package/dist/bin/index.cjs +0 -778
- package/dist/bin/index.cjs.map +0 -1
- package/dist/bin/index.d.cts +0 -1
- package/dist/chunk-565UOT3F.js +0 -18
- package/dist/chunk-565UOT3F.js.map +0 -1
- package/dist/chunk-B2UNTYN5.js +0 -68
- package/dist/chunk-B2UNTYN5.js.map +0 -1
- package/dist/chunk-CZHJQCPI.js +0 -286
- package/dist/chunk-CZHJQCPI.js.map +0 -1
- package/dist/chunk-PTVHEJZ5.js +0 -152
- package/dist/chunk-PTVHEJZ5.js.map +0 -1
- package/dist/chunk-SJVHHGVW.js +0 -13
- package/dist/chunk-SJVHHGVW.js.map +0 -1
- package/dist/chunk-TDOXEXG6.js +0 -85
- package/dist/chunk-TDOXEXG6.js.map +0 -1
- package/dist/chunk-WVXAN4IV.js +0 -50
- package/dist/chunk-WVXAN4IV.js.map +0 -1
- package/dist/chunk-YRBEYKQM.js +0 -372
- package/dist/chunk-YRBEYKQM.js.map +0 -1
- package/dist/index.cjs +0 -322
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -199
- package/dist/metafile-cjs.json +0 -1
- package/dist/metafile-esm.json +0 -1
- package/dist/response.cjs +0 -150
- package/dist/response.cjs.map +0 -1
- package/dist/response.d.cts +0 -166
- package/dist/response.js.map +0 -1
- package/dist/run.cjs +0 -787
- package/dist/run.cjs.map +0 -1
- package/dist/run.d.cts +0 -14
- package/dist/run.js.map +0 -1
- package/dist/server.cjs +0 -398
- package/dist/server.cjs.map +0 -1
- package/dist/server.d.cts +0 -17
- package/dist/server.js.map +0 -1
- package/dist/state.cjs +0 -44
- package/dist/state.cjs.map +0 -1
- package/dist/state.d.cts +0 -11
- package/dist/state.js.map +0 -1
- package/dist/test.cjs +0 -538
- package/dist/test.cjs.map +0 -1
- package/dist/test.d.cts +0 -15
- package/src/response/moved.ts +0 -16
- package/src/response/redirect.ts +0 -17
- package/src/state/Page.ts +0 -8
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { SerializeOptions } from 'cookie';
|
|
2
|
-
|
|
3
|
-
declare class CookieHelper {
|
|
4
|
-
request: Request;
|
|
5
|
-
cookies: Map<string, string>;
|
|
6
|
-
constructor(request: Request);
|
|
7
|
-
get(name: string): string | undefined;
|
|
8
|
-
set(name: string, value: string, options?: SerializeOptions): void;
|
|
9
|
-
delete(name: string, options?: SerializeOptions): void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare class HeaderHelper {
|
|
13
|
-
request: Request;
|
|
14
|
-
headers: Map<string, string>;
|
|
15
|
-
constructor(request: Request);
|
|
16
|
-
get(name: string): string | undefined;
|
|
17
|
-
set(name: string, value: string): void;
|
|
18
|
-
delete(name: string): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
declare class ServerEvent {
|
|
22
|
-
request: Request;
|
|
23
|
-
response: Response | undefined | void;
|
|
24
|
-
params?: Record<string, string>;
|
|
25
|
-
adapter: any;
|
|
26
|
-
cookies: CookieHelper;
|
|
27
|
-
headers: HeaderHelper;
|
|
28
|
-
constructor(request: Request, params?: Record<string, string>);
|
|
29
|
-
addHeaders(): void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type MiddlewareFunction = (ev: ServerEvent, next: () => void | Promise<void>) => void | Promise<void>;
|
|
33
|
-
|
|
34
|
-
type ServerFunction = (e: ServerEvent) => Response | undefined | void | Promise<Response | undefined | void>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* A Fetch API Request/Response server.
|
|
38
|
-
*/
|
|
39
|
-
declare class Server {
|
|
40
|
-
#private;
|
|
41
|
-
routes: RouteHandler[];
|
|
42
|
-
middleware: MiddlewareFunction[];
|
|
43
|
-
constructor();
|
|
44
|
-
/**
|
|
45
|
-
* The standard Fetch API method that should work in any runtime (including
|
|
46
|
-
* Node with polyfills).
|
|
47
|
-
* @returns
|
|
48
|
-
*/
|
|
49
|
-
fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
50
|
-
/**
|
|
51
|
-
* Adds a server function at a route path.
|
|
52
|
-
* @param path The route path pattern.
|
|
53
|
-
* @param fn The function to call when the pattern is matched.
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
add(path: string, fn: ServerFunction): Server;
|
|
57
|
-
match(path: string): Match | undefined;
|
|
58
|
-
use(...fn: MiddlewareFunction[]): Server;
|
|
59
|
-
}
|
|
60
|
-
declare class RouteHandler {
|
|
61
|
-
path: string;
|
|
62
|
-
regex: RegExp;
|
|
63
|
-
fn: ServerFunction;
|
|
64
|
-
constructor(path: string, fn: ServerFunction);
|
|
65
|
-
}
|
|
66
|
-
type Match = {
|
|
67
|
-
fn: ServerFunction;
|
|
68
|
-
params?: Record<string, string>;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export { CookieHelper as C, HeaderHelper as H, type MiddlewareFunction as M, Server as S, ServerEvent as a };
|
package/dist/Site-C2020GV_.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Plugin, UserConfig } from 'vite';
|
|
2
|
-
import { S as Server } from './Server-CNZWh5ca.js';
|
|
3
|
-
|
|
4
|
-
type Adapter = {
|
|
5
|
-
prebuild?: (site: Site) => Promise<void> | void;
|
|
6
|
-
postbuild?: (site: Site) => Promise<void> | void;
|
|
7
|
-
serve: (server: Server, site: Site) => void;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
declare const PAGE_ROUTE = 0;
|
|
11
|
-
declare const PAGE_SERVER_ROUTE = 1;
|
|
12
|
-
declare const SERVER_ROUTE = 3;
|
|
13
|
-
declare const LAYOUT_ROUTE = 4;
|
|
14
|
-
declare const LAYOUT_SERVER_ROUTE = 5;
|
|
15
|
-
declare const HOOK_ROUTE = 6;
|
|
16
|
-
declare const HOOK_SERVER_ROUTE = 7;
|
|
17
|
-
declare const ERROR_ROUTE = 8;
|
|
18
|
-
type RouteType = typeof PAGE_ROUTE | typeof PAGE_SERVER_ROUTE | typeof SERVER_ROUTE | typeof LAYOUT_ROUTE | typeof LAYOUT_SERVER_ROUTE | typeof HOOK_ROUTE | typeof HOOK_SERVER_ROUTE | typeof ERROR_ROUTE | -1;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The Site class contains the information necessary to setup a @torpor/build
|
|
22
|
-
* site, including routes, plugins, and options.
|
|
23
|
-
*/
|
|
24
|
-
declare class Site {
|
|
25
|
-
#private;
|
|
26
|
-
root: string;
|
|
27
|
-
routes: {
|
|
28
|
-
path: string;
|
|
29
|
-
file: string;
|
|
30
|
-
type: RouteType;
|
|
31
|
-
}[];
|
|
32
|
-
plugins: Plugin[];
|
|
33
|
-
adapter: Adapter;
|
|
34
|
-
/**
|
|
35
|
-
* Extra inputs, as absolute file paths, that will be compiled with the
|
|
36
|
-
* output. What you do with them after that is up to you. File paths ending
|
|
37
|
-
* with server.ts/js will only be compiled with the server output
|
|
38
|
-
*/
|
|
39
|
-
inputs: string[];
|
|
40
|
-
/**
|
|
41
|
-
* Vite config options to merge with the standard Torpor build options.
|
|
42
|
-
* `plugins` and `build.rollupOptions.input` will be overridden, so you
|
|
43
|
-
* should set `Site.plugins` and `Site.inputs` instead. Other options may be
|
|
44
|
-
* overridden or incompatible, so experimentation may be required
|
|
45
|
-
*/
|
|
46
|
-
viteConfig?: UserConfig;
|
|
47
|
-
constructor();
|
|
48
|
-
/**
|
|
49
|
-
* Adds a folder of routes, based on the names of the files in the folder
|
|
50
|
-
* @param folder The folder containing the routes
|
|
51
|
-
*/
|
|
52
|
-
addRouteFolder(folder: string): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Adds a file route, which can have a standard name (e.g. +page.ts) or any
|
|
55
|
-
* name if you pass the type
|
|
56
|
-
* @param path The route path
|
|
57
|
-
* @param file The file
|
|
58
|
-
* @param type The file type (if the file name is non-standard)
|
|
59
|
-
*/
|
|
60
|
-
addRouteFile(path: string, file: string, type?: "+page" | "+page.server" | "+server" | "_layout" | "_layout.server" | "_hook" | "_hook.server" | "_error"): void;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { type Adapter as A, Site as S };
|
package/dist/Site-DQojGpE-.d.cts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Plugin, UserConfig } from 'vite';
|
|
2
|
-
import { S as Server } from './Server-CNZWh5ca.cjs';
|
|
3
|
-
|
|
4
|
-
type Adapter = {
|
|
5
|
-
prebuild?: (site: Site) => Promise<void> | void;
|
|
6
|
-
postbuild?: (site: Site) => Promise<void> | void;
|
|
7
|
-
serve: (server: Server, site: Site) => void;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
declare const PAGE_ROUTE = 0;
|
|
11
|
-
declare const PAGE_SERVER_ROUTE = 1;
|
|
12
|
-
declare const SERVER_ROUTE = 3;
|
|
13
|
-
declare const LAYOUT_ROUTE = 4;
|
|
14
|
-
declare const LAYOUT_SERVER_ROUTE = 5;
|
|
15
|
-
declare const HOOK_ROUTE = 6;
|
|
16
|
-
declare const HOOK_SERVER_ROUTE = 7;
|
|
17
|
-
declare const ERROR_ROUTE = 8;
|
|
18
|
-
type RouteType = typeof PAGE_ROUTE | typeof PAGE_SERVER_ROUTE | typeof SERVER_ROUTE | typeof LAYOUT_ROUTE | typeof LAYOUT_SERVER_ROUTE | typeof HOOK_ROUTE | typeof HOOK_SERVER_ROUTE | typeof ERROR_ROUTE | -1;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The Site class contains the information necessary to setup a @torpor/build
|
|
22
|
-
* site, including routes, plugins, and options.
|
|
23
|
-
*/
|
|
24
|
-
declare class Site {
|
|
25
|
-
#private;
|
|
26
|
-
root: string;
|
|
27
|
-
routes: {
|
|
28
|
-
path: string;
|
|
29
|
-
file: string;
|
|
30
|
-
type: RouteType;
|
|
31
|
-
}[];
|
|
32
|
-
plugins: Plugin[];
|
|
33
|
-
adapter: Adapter;
|
|
34
|
-
/**
|
|
35
|
-
* Extra inputs, as absolute file paths, that will be compiled with the
|
|
36
|
-
* output. What you do with them after that is up to you. File paths ending
|
|
37
|
-
* with server.ts/js will only be compiled with the server output
|
|
38
|
-
*/
|
|
39
|
-
inputs: string[];
|
|
40
|
-
/**
|
|
41
|
-
* Vite config options to merge with the standard Torpor build options.
|
|
42
|
-
* `plugins` and `build.rollupOptions.input` will be overridden, so you
|
|
43
|
-
* should set `Site.plugins` and `Site.inputs` instead. Other options may be
|
|
44
|
-
* overridden or incompatible, so experimentation may be required
|
|
45
|
-
*/
|
|
46
|
-
viteConfig?: UserConfig;
|
|
47
|
-
constructor();
|
|
48
|
-
/**
|
|
49
|
-
* Adds a folder of routes, based on the names of the files in the folder
|
|
50
|
-
* @param folder The folder containing the routes
|
|
51
|
-
*/
|
|
52
|
-
addRouteFolder(folder: string): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Adds a file route, which can have a standard name (e.g. +page.ts) or any
|
|
55
|
-
* name if you pass the type
|
|
56
|
-
* @param path The route path
|
|
57
|
-
* @param file The file
|
|
58
|
-
* @param type The file type (if the file name is non-standard)
|
|
59
|
-
*/
|
|
60
|
-
addRouteFile(path: string, file: string, type?: "+page" | "+page.server" | "+server" | "_layout" | "_layout.server" | "_hook" | "_hook.server" | "_error"): void;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { type Adapter as A, Site as S };
|