@jk2908/solas 0.5.4 → 0.6.0
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 +24 -0
- package/README.md +81 -85
- package/dist/config.d.ts +25 -0
- package/dist/config.js +152 -0
- package/dist/events.d.ts +4 -0
- package/dist/events.js +5 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +59 -37
- package/dist/internal/boundary-error.d.ts +4 -0
- package/dist/internal/boundary-error.js +8 -0
- package/dist/internal/browser-router/history.d.ts +1 -1
- package/dist/internal/browser-router/link.d.ts +1 -1
- package/dist/internal/browser-router/link.js +1 -1
- package/dist/internal/browser-router/router.d.ts +2 -2
- package/dist/internal/browser-router/router.js +5 -5
- package/dist/internal/browser-router/shared.d.ts +182 -184
- package/dist/internal/browser-router/shared.js +49 -56
- package/dist/internal/browser-router/use-router.d.ts +1 -1
- package/dist/internal/browser-router/use-search-params.js +3 -3
- package/dist/internal/build.d.ts +108 -110
- package/dist/internal/build.js +569 -581
- package/dist/internal/codegen/config.js +3 -3
- package/dist/internal/codegen/environments.js +5 -6
- package/dist/internal/codegen/format.d.ts +6 -0
- package/dist/internal/codegen/format.js +24 -0
- package/dist/internal/codegen/manifest.js +2 -2
- package/dist/internal/codegen/maps.d.ts +1 -1
- package/dist/internal/codegen/maps.js +2 -2
- package/dist/internal/codegen/types.js +4 -4
- package/dist/internal/codegen/utils.js +2 -2
- package/dist/internal/env/request-context.js +1 -1
- package/dist/internal/env/rsc.d.ts +3 -2
- package/dist/internal/env/rsc.js +26 -25
- package/dist/internal/env/ssr.js +4 -4
- package/dist/internal/http-router/router.js +8 -8
- package/dist/internal/metadata.d.ts +1 -1
- package/dist/internal/metadata.js +1 -1
- package/dist/internal/navigation/http-exception-boundary.d.ts +1 -1
- package/dist/internal/navigation/redirect-boundary.d.ts +1 -1
- package/dist/internal/navigation/redirect.js +6 -6
- package/dist/internal/postbuild.js +18 -17
- package/dist/internal/prerender.d.ts +130 -138
- package/dist/internal/prerender.js +326 -354
- package/dist/internal/public-files.js +2 -4
- package/dist/internal/render/head.js +2 -2
- package/dist/internal/resolver.js +1 -1
- package/dist/internal/server/actions.js +2 -2
- package/dist/internal/ui/error-boundary.d.ts +1 -1
- package/dist/manifest.d.ts +7 -0
- package/dist/manifest.js +85 -0
- package/dist/prerender.d.ts +1 -1
- package/dist/prerender.js +1 -1
- package/dist/solas.d.ts +2 -46
- package/dist/solas.js +6 -266
- package/dist/types.d.ts +14 -21
- package/dist/types.js +1 -1
- package/dist/utils/base-path.d.ts +12 -14
- package/dist/utils/base-path.js +75 -82
- package/dist/utils/compress.d.ts +9 -11
- package/dist/utils/compress.js +59 -64
- package/dist/utils/context.d.ts +4 -6
- package/dist/utils/context.js +17 -22
- package/dist/utils/logger.js +2 -2
- package/dist/utils/time.d.ts +2 -4
- package/dist/utils/time.js +23 -29
- package/package.json +18 -8
|
@@ -1,140 +1,132 @@
|
|
|
1
1
|
import type { BuildContext } from '../types.js';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* Custom error class to indicate that prerendering has been postponed to request-time
|
|
78
|
-
*/
|
|
79
|
-
class Postponed extends Error {
|
|
80
|
-
constructor(message?: string);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Type guard to check if an error is a Postponed error, including wrapped errors like
|
|
84
|
-
* AbortError or TimeoutError
|
|
85
|
-
*/
|
|
86
|
-
function isPostponed(error: unknown): boolean;
|
|
87
|
-
}
|
|
88
|
-
namespace Build {
|
|
89
|
-
/**
|
|
90
|
-
* Get the prerender concurrency value from the environment variable, or return the default
|
|
91
|
-
* if it's not set or invalid
|
|
92
|
-
*/
|
|
93
|
-
function getConcurrency(): number;
|
|
94
|
-
/**
|
|
95
|
-
* Extract the prerendering mode ('full', 'ppr', or false) from the source code of a route module, by
|
|
96
|
-
* looking for an exported `prerender` binding and validating its value
|
|
97
|
-
*/
|
|
98
|
-
function getStaticFlag(filePath: string, buildContext: BuildContext): Promise<"full" | "ppr" | false | undefined>;
|
|
99
|
-
/**
|
|
100
|
-
* Get the list of static parameters for a dynamic route, by looking for an exported `params` function
|
|
101
|
-
* in the route module and calling it to get the list of parameter objects
|
|
102
|
-
*/
|
|
103
|
-
function getStaticParams(filePath: string, buildContext: BuildContext): Promise<Record<string, string | number | (string | number)[]>[]>;
|
|
104
|
-
/**
|
|
105
|
-
* Generate the list of prerenderable routes for a dynamic route, by combining the static parameters obtained from
|
|
106
|
-
* the route module with the route pattern, and filtering out any routes that still contain dynamic segments
|
|
107
|
-
*/
|
|
108
|
-
function getDynamicRouteList(route: string, paramNames: string[], staticParams: Record<string, string | number | (string | number)[]>[]): string[];
|
|
109
|
-
/**
|
|
110
|
-
* Function to prerender a single route by making a request to the route with special headers, and returning the
|
|
111
|
-
* result which includes either the prerender artifact or an error/status code if the prerendering failed or was
|
|
112
|
-
* postponed to request-time
|
|
113
|
-
*/
|
|
114
|
-
function get(app: {
|
|
115
|
-
fetch: (req: Request) => Promise<Response>;
|
|
116
|
-
}, route: string, opts: {
|
|
117
|
-
origin?: string;
|
|
118
|
-
base?: string;
|
|
119
|
-
}): Promise<{
|
|
120
|
-
route: string;
|
|
121
|
-
status: number;
|
|
122
|
-
artifact?: undefined;
|
|
123
|
-
} | {
|
|
124
|
-
status?: undefined;
|
|
125
|
-
route: string;
|
|
126
|
-
artifact: any;
|
|
127
|
-
}>;
|
|
128
|
-
/**
|
|
129
|
-
* Run the prerendering process for a list of routes with a specified concurrency limit,
|
|
130
|
-
* by calling the 'get' function for each route and yielding the results as they become available
|
|
131
|
-
*/
|
|
132
|
-
function run(app: {
|
|
133
|
-
fetch: (req: Request) => Promise<Response>;
|
|
134
|
-
}, routes: string[], opts: {
|
|
135
|
-
concurrency?: number;
|
|
136
|
-
origin?: string;
|
|
137
|
-
base?: string;
|
|
138
|
-
}): AsyncGenerator<Result, void, unknown>;
|
|
139
|
-
}
|
|
2
|
+
export type Mode = 'full' | 'ppr';
|
|
3
|
+
export type File = 'html' | 'prelude' | 'postponed' | 'metadata';
|
|
4
|
+
export type Value = {
|
|
5
|
+
schema: string;
|
|
6
|
+
route: string;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
mode: Mode;
|
|
9
|
+
html: string;
|
|
10
|
+
postponed?: unknown;
|
|
11
|
+
};
|
|
12
|
+
export type Metadata = Pick<Value, 'schema' | 'route' | 'createdAt' | 'mode'>;
|
|
13
|
+
export type Artifact = {
|
|
14
|
+
mode: Mode;
|
|
15
|
+
files?: readonly File[];
|
|
16
|
+
};
|
|
17
|
+
export type ArtifactManifest = Record<string, Artifact>;
|
|
18
|
+
/**
|
|
19
|
+
* Get the root directory path where prerender artifacts are stored,
|
|
20
|
+
* based on the output directory specified in the configuration
|
|
21
|
+
*/
|
|
22
|
+
export declare function getArtifactRootPath(outDir: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get the file system path for storing prerender artifacts for a given route
|
|
25
|
+
*/
|
|
26
|
+
export declare function getArtifactPath(outDir: string, pathname: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get the file system path for a single prerender artifact file under a route directory
|
|
29
|
+
*/
|
|
30
|
+
export declare function getArtifactFilePath(outDir: string, pathname: string, fileName: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* File name used for saved full-prerender html inside each route artifact directory
|
|
33
|
+
*/
|
|
34
|
+
export declare const FULL_PRERENDER_FILENAME = "prerendered.html";
|
|
35
|
+
/**
|
|
36
|
+
* Load the postponed state for a given route from the file system, if it exists
|
|
37
|
+
*/
|
|
38
|
+
export declare function loadPostponedState(outDir: string, pathname: string): Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* Load the prelude HTML for a given route from the file system, if it exists
|
|
41
|
+
*/
|
|
42
|
+
export declare function loadPrelude(outDir: string, pathname: string): Promise<string | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Load the prerender artifact metadata for a given route from the file system, if it exists and is valid
|
|
45
|
+
*/
|
|
46
|
+
export declare function loadMetadata(outDir: string, pathname: string): Promise<{
|
|
47
|
+
schema: string;
|
|
48
|
+
route: string;
|
|
49
|
+
createdAt: number;
|
|
50
|
+
mode: "full" | "ppr";
|
|
51
|
+
} | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a prerender artifact is compatible with the current application version and route,
|
|
54
|
+
* based on its metadata
|
|
55
|
+
*/
|
|
56
|
+
export declare function isCompatible(artifactMetadata: Metadata, pathname: string, mode: Mode): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Compose the prelude HTML and the resume stream into a single HTML stream, by injecting the resume stream
|
|
59
|
+
* into the prelude at the appropriate location (before </body> or </html>)
|
|
60
|
+
*/
|
|
61
|
+
export declare function composePreludeAndResume(prelude: string, resumeStream: ReadableStream<Uint8Array>): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
62
|
+
export type Result = {
|
|
63
|
+
route: string;
|
|
64
|
+
artifact: Value;
|
|
65
|
+
} | {
|
|
66
|
+
route: string;
|
|
67
|
+
status: number;
|
|
68
|
+
} | {
|
|
69
|
+
route: string;
|
|
70
|
+
error: unknown;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Custom error class to indicate that prerendering has been postponed to request-time
|
|
74
|
+
*/
|
|
75
|
+
export declare class Postponed extends Error {
|
|
76
|
+
constructor(message?: string);
|
|
140
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Type guard to check if an error is a Postponed error, including wrapped errors like
|
|
80
|
+
* AbortError or TimeoutError
|
|
81
|
+
*/
|
|
82
|
+
export declare function isPostponed(error: unknown): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Get the prerender concurrency value from the environment variable, or return the default
|
|
85
|
+
* if it's not set or invalid
|
|
86
|
+
*/
|
|
87
|
+
export declare function getConcurrency(): number;
|
|
88
|
+
/**
|
|
89
|
+
* Extract the prerendering mode ('full', 'ppr', or false) from the source code of a route module, by
|
|
90
|
+
* looking for an exported `prerender` binding and validating its value
|
|
91
|
+
*/
|
|
92
|
+
export declare function getStaticFlag(filePath: string, buildContext: BuildContext): Promise<"full" | "ppr" | false | undefined>;
|
|
93
|
+
/**
|
|
94
|
+
* Get the list of static parameters for a dynamic route, by looking for an exported `params` function
|
|
95
|
+
* in the route module and calling it to get the list of parameter objects
|
|
96
|
+
*/
|
|
97
|
+
export declare function getStaticParams(filePath: string, buildContext: BuildContext): Promise<Record<string, string | number | (string | number)[]>[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Generate the list of prerenderable routes for a dynamic route, by combining the static parameters obtained from
|
|
100
|
+
* the route module with the route pattern, and filtering out any routes that still contain dynamic segments
|
|
101
|
+
*/
|
|
102
|
+
export declare function getDynamicRouteList(route: string, paramNames: string[], staticParams: Record<string, string | number | (string | number)[]>[]): string[];
|
|
103
|
+
/**
|
|
104
|
+
* Function to prerender a single route by making a request to the route with special headers, and returning the
|
|
105
|
+
* result which includes either the prerender artifact or an error/status code if the prerendering failed or was
|
|
106
|
+
* postponed to request-time
|
|
107
|
+
*/
|
|
108
|
+
export declare function get(app: {
|
|
109
|
+
fetch: (req: Request) => Promise<Response>;
|
|
110
|
+
}, route: string, opts: {
|
|
111
|
+
origin?: string;
|
|
112
|
+
base?: string;
|
|
113
|
+
}): Promise<{
|
|
114
|
+
route: string;
|
|
115
|
+
status: number;
|
|
116
|
+
artifact?: undefined;
|
|
117
|
+
} | {
|
|
118
|
+
status?: undefined;
|
|
119
|
+
route: string;
|
|
120
|
+
artifact: any;
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Run the prerendering process for a list of routes with a specified concurrency limit,
|
|
124
|
+
* by calling the 'get' function for each route and yielding the results as they become available
|
|
125
|
+
*/
|
|
126
|
+
export declare function run(app: {
|
|
127
|
+
fetch: (req: Request) => Promise<Response>;
|
|
128
|
+
}, routes: string[], opts: {
|
|
129
|
+
concurrency?: number;
|
|
130
|
+
origin?: string;
|
|
131
|
+
base?: string;
|
|
132
|
+
}): AsyncGenerator<Result, void, unknown>;
|