@rebask/core 0.3.0 → 0.4.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/dist/components/image.d.ts +16 -3
- package/dist/components/image.d.ts.map +1 -1
- package/dist/components/image.js +50 -68
- package/dist/components/link.d.ts.map +1 -1
- package/dist/components/link.js +6 -2
- package/dist/lib/image-optimization/fetch-remote-image.d.ts +17 -0
- package/dist/lib/image-optimization/fetch-remote-image.d.ts.map +1 -0
- package/dist/lib/image-optimization/fetch-remote-image.js +157 -0
- package/dist/lib/image-optimization/get-img-props.d.ts +3 -5
- package/dist/lib/image-optimization/get-img-props.d.ts.map +1 -1
- package/dist/lib/image-optimization/get-img-props.js +66 -40
- package/dist/lib/image-optimization/handler.d.ts +0 -3
- package/dist/lib/image-optimization/handler.d.ts.map +1 -1
- package/dist/lib/image-optimization/handler.js +339 -124
- package/dist/lib/image-optimization/image-config.d.ts +31 -4
- package/dist/lib/image-optimization/image-config.d.ts.map +1 -1
- package/dist/lib/image-optimization/image-config.js +6 -0
- package/dist/lib/image-optimization/image-error.d.ts +8 -0
- package/dist/lib/image-optimization/image-error.d.ts.map +1 -0
- package/dist/lib/image-optimization/image-error.js +10 -0
- package/dist/lib/image-optimization/image-plugin.d.ts.map +1 -1
- package/dist/lib/image-optimization/image-plugin.js +27 -14
- package/dist/lib/image-optimization/is-private-ip.d.ts +2 -0
- package/dist/lib/image-optimization/is-private-ip.d.ts.map +1 -0
- package/dist/lib/image-optimization/is-private-ip.js +43 -0
- package/dist/lib/image-optimization/match-patterns.d.ts +4 -0
- package/dist/lib/image-optimization/match-patterns.d.ts.map +1 -0
- package/dist/lib/image-optimization/match-patterns.js +39 -0
- package/dist/lib/image-optimization/read-body.d.ts +2 -0
- package/dist/lib/image-optimization/read-body.d.ts.map +1 -0
- package/dist/lib/image-optimization/read-body.js +27 -0
- package/dist/lib/image-optimization/static-image-loader.d.ts +2 -0
- package/dist/lib/image-optimization/static-image-loader.d.ts.map +1 -0
- package/dist/lib/image-optimization/static-image-loader.js +60 -0
- package/dist/lib/server-router/build-entries.d.ts.map +1 -1
- package/dist/lib/server-router/route-entries.js +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +12 -4
- package/package.json +2 -1
- package/dist/__type_probe__.d.ts +0 -2
- package/dist/__type_probe__.d.ts.map +0 -1
- package/dist/__type_probe__.js +0 -4
- package/dist/components/error-boundary-client.d.ts +0 -49
- package/dist/components/error-boundary-client.d.ts.map +0 -1
- package/dist/components/error-boundary-client.js +0 -71
- package/dist/components/error-boundary.browser.d.ts +0 -8
- package/dist/components/error-boundary.browser.d.ts.map +0 -1
- package/dist/components/error-boundary.browser.js +0 -6
- package/dist/components/error.d.ts +0 -2
- package/dist/components/error.d.ts.map +0 -1
- package/dist/components/error.js +0 -5
- package/dist/components/not-found-activator.d.ts +0 -11
- package/dist/components/not-found-activator.d.ts.map +0 -1
- package/dist/components/not-found-activator.js +0 -26
- package/dist/components/not-found-boundary-client.d.ts +0 -3
- package/dist/components/not-found-boundary-client.d.ts.map +0 -1
- package/dist/components/not-found-boundary-client.js +0 -20
- package/dist/components/not-found-boundary.browser.d.ts +0 -8
- package/dist/components/not-found-boundary.browser.d.ts.map +0 -1
- package/dist/components/not-found-boundary.browser.js +0 -4
- package/dist/components/not-found-boundary.d.ts +0 -8
- package/dist/components/not-found-boundary.d.ts.map +0 -1
- package/dist/components/not-found-boundary.js +0 -9
- package/dist/components/not-found-thrower.d.ts +0 -2
- package/dist/components/not-found-thrower.d.ts.map +0 -1
- package/dist/components/not-found-thrower.js +0 -7
- package/dist/components/not-found.d.ts +0 -2
- package/dist/components/not-found.d.ts.map +0 -1
- package/dist/components/not-found.js +0 -5
- package/dist/components/status-page.d.ts +0 -6
- package/dist/components/status-page.d.ts.map +0 -1
- package/dist/components/status-page.js +0 -61
- package/dist/handler.d.ts +0 -12
- package/dist/handler.d.ts.map +0 -1
- package/dist/handler.js +0 -21
- package/dist/handlers/rsc/constants.d.ts +0 -3
- package/dist/handlers/rsc/constants.d.ts.map +0 -1
- package/dist/handlers/rsc/constants.js +0 -2
- package/dist/handlers/rsc/create-response.d.ts +0 -3
- package/dist/handlers/rsc/create-response.d.ts.map +0 -1
- package/dist/handlers/rsc/create-response.js +0 -378
- package/dist/handlers/rsc/render-with-retries.d.ts +0 -4
- package/dist/handlers/rsc/render-with-retries.d.ts.map +0 -1
- package/dist/handlers/rsc/render-with-retries.js +0 -154
- package/dist/handlers/rsc/retry-loop.d.ts +0 -3
- package/dist/handlers/rsc/retry-loop.d.ts.map +0 -1
- package/dist/handlers/rsc/retry-loop.js +0 -145
- package/dist/handlers/rsc/stream-rsc-payload.d.ts +0 -9
- package/dist/handlers/rsc/stream-rsc-payload.d.ts.map +0 -1
- package/dist/handlers/rsc/stream-rsc-payload.js +0 -20
- package/dist/handlers/rsc/types.d.ts +0 -26
- package/dist/handlers/rsc/types.d.ts.map +0 -1
- package/dist/handlers/rsc/types.js +0 -7
- package/dist/handlers/rsc.d.ts +0 -20
- package/dist/handlers/rsc.d.ts.map +0 -1
- package/dist/handlers/rsc.js +0 -872
- package/dist/integration.d.ts +0 -14
- package/dist/integration.d.ts.map +0 -1
- package/dist/integration.js +0 -9
- package/dist/lib/dev-module-load-race.d.ts +0 -8
- package/dist/lib/dev-module-load-race.d.ts.map +0 -1
- package/dist/lib/dev-module-load-race.js +0 -31
- package/dist/lib/dev-page-exports.d.ts +0 -5
- package/dist/lib/dev-page-exports.d.ts.map +0 -1
- package/dist/lib/dev-page-exports.js +0 -14
- package/dist/lib/environment-names.d.ts +0 -11
- package/dist/lib/environment-names.d.ts.map +0 -1
- package/dist/lib/environment-names.js +0 -10
- package/dist/lib/initial-hash-scroll.d.ts.map +0 -1
- package/dist/lib/not-found.d.ts +0 -5
- package/dist/lib/not-found.d.ts.map +0 -1
- package/dist/lib/not-found.js +0 -7
- package/dist/lib/page-exports.d.ts +0 -9
- package/dist/lib/page-exports.d.ts.map +0 -1
- package/dist/lib/page-exports.js +0 -47
- package/dist/lib/pattern-segments.d.ts +0 -8
- package/dist/lib/pattern-segments.d.ts.map +0 -1
- package/dist/lib/pattern-segments.js +0 -22
- package/dist/lib/ppr/cache-status.d.ts +0 -3
- package/dist/lib/ppr/cache-status.d.ts.map +0 -1
- package/dist/lib/ppr/cache-status.js +0 -5
- package/dist/lib/server-router-contract.d.ts +0 -42
- package/dist/lib/server-router-contract.d.ts.map +0 -1
- package/dist/lib/server-router-contract.js +0 -6
- package/dist/lib/server-router-loader.d.ts +0 -10
- package/dist/lib/server-router-loader.d.ts.map +0 -1
- package/dist/lib/server-router-loader.js +0 -180
- package/dist/lib/server-router.d.ts +0 -8
- package/dist/lib/server-router.d.ts.map +0 -1
- package/dist/lib/server-router.js +0 -173
- package/dist/plugins/ppr-upgrade.d.ts +0 -36
- package/dist/plugins/ppr-upgrade.d.ts.map +0 -1
- package/dist/plugins/ppr-upgrade.js +0 -32
- package/dist/plugins/server-router-fallback.d.ts +0 -15
- package/dist/plugins/server-router-fallback.d.ts.map +0 -1
- package/dist/plugins/server-router-fallback.js +0 -30
- package/dist/server.d.ts +0 -10
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -57
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { stat } from "node:fs/promises";
|
|
2
|
-
import { isAbsolute, join } from "node:path";
|
|
2
|
+
import { isAbsolute, join, relative, sep } from "node:path";
|
|
3
3
|
import { imageConfigDefault } from "./image-config.js";
|
|
4
|
+
import { createStaticImageModule } from "./static-image-loader.js";
|
|
4
5
|
const IMAGE_HANDLER_EXTENSIONS = ["ts", "js"];
|
|
6
|
+
const IMAGE_EXTENSIONS = new Set(["jpg", "jpeg", "png", "gif", "webp", "avif", "svg"]);
|
|
5
7
|
/** The `name` of the Vite plugin. */
|
|
6
8
|
export const REBASK_IMAGE_PLUGIN_NAME = "rebask:image";
|
|
7
9
|
async function findImageHandler(root, customPath) {
|
|
@@ -39,7 +41,7 @@ export function rebaskImage(options) {
|
|
|
39
41
|
let resolvedHandlerPath;
|
|
40
42
|
async function resolveHandlerPath() {
|
|
41
43
|
if (resolvedHandlerPath === undefined) {
|
|
42
|
-
resolvedHandlerPath = await findImageHandler(projectRoot, imageConfig.handler);
|
|
44
|
+
resolvedHandlerPath = (await findImageHandler(projectRoot, imageConfig.handler)) ?? null;
|
|
43
45
|
}
|
|
44
46
|
return resolvedHandlerPath;
|
|
45
47
|
}
|
|
@@ -54,25 +56,22 @@ export function rebaskImage(options) {
|
|
|
54
56
|
name: REBASK_IMAGE_PLUGIN_NAME,
|
|
55
57
|
enforce: "pre", // Run before Vite's import analysis to handle virtual module
|
|
56
58
|
api,
|
|
57
|
-
|
|
58
|
-
// Prepare image config for injection
|
|
59
|
-
const clientImageConfig = {
|
|
60
|
-
deviceSizes: imageConfig.deviceSizes,
|
|
61
|
-
imageSizes: imageConfig.imageSizes,
|
|
62
|
-
qualities: imageConfig.qualities,
|
|
63
|
-
path: imageConfig.path,
|
|
64
|
-
unoptimized: imageConfig.unoptimized,
|
|
65
|
-
};
|
|
59
|
+
config() {
|
|
66
60
|
return {
|
|
67
61
|
define: {
|
|
68
|
-
__REBASK_IMAGE_OPTS: JSON.stringify(
|
|
62
|
+
__REBASK_IMAGE_OPTS: JSON.stringify({
|
|
63
|
+
deviceSizes: imageConfig.deviceSizes,
|
|
64
|
+
imageSizes: imageConfig.imageSizes,
|
|
65
|
+
qualities: imageConfig.qualities,
|
|
66
|
+
path: imageConfig.path,
|
|
67
|
+
unoptimized: imageConfig.unoptimized,
|
|
68
|
+
}),
|
|
69
69
|
},
|
|
70
70
|
};
|
|
71
71
|
},
|
|
72
72
|
configResolved(config) {
|
|
73
73
|
projectRoot = config.root;
|
|
74
|
-
|
|
75
|
-
publicDir = config.publicDir;
|
|
74
|
+
publicDir = config.publicDir || undefined;
|
|
76
75
|
},
|
|
77
76
|
resolveId(id) {
|
|
78
77
|
if (id === "virtual:rebask/image-config") {
|
|
@@ -99,6 +98,20 @@ export async function loadImageHandler() {
|
|
|
99
98
|
}
|
|
100
99
|
`;
|
|
101
100
|
}
|
|
101
|
+
// Only unadorned imports are transformed.
|
|
102
|
+
if (id.includes("?"))
|
|
103
|
+
return;
|
|
104
|
+
const extension = id.split(".").pop()?.toLowerCase();
|
|
105
|
+
if (!extension || !IMAGE_EXTENSIONS.has(extension))
|
|
106
|
+
return;
|
|
107
|
+
const relativePath = relative(projectRoot, id);
|
|
108
|
+
if (relativePath === ".." ||
|
|
109
|
+
relativePath.startsWith(`..${sep}`) ||
|
|
110
|
+
isAbsolute(relativePath) ||
|
|
111
|
+
relativePath.split(sep).includes("node_modules")) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
return createStaticImageModule(id, projectRoot);
|
|
102
115
|
},
|
|
103
116
|
};
|
|
104
117
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-private-ip.d.ts","sourceRoot":"","sources":["../../../src/lib/image-optimization/is-private-ip.ts"],"names":[],"mappings":"AAqCA,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAWpD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BlockList, isIP } from "node:net";
|
|
2
|
+
const privateAddresses = new BlockList();
|
|
3
|
+
privateAddresses.addSubnet("0.0.0.0", 8, "ipv4");
|
|
4
|
+
privateAddresses.addSubnet("10.0.0.0", 8, "ipv4");
|
|
5
|
+
privateAddresses.addSubnet("100.64.0.0", 10, "ipv4");
|
|
6
|
+
privateAddresses.addSubnet("127.0.0.0", 8, "ipv4");
|
|
7
|
+
privateAddresses.addSubnet("169.254.0.0", 16, "ipv4");
|
|
8
|
+
privateAddresses.addSubnet("172.16.0.0", 12, "ipv4");
|
|
9
|
+
privateAddresses.addSubnet("192.0.0.0", 24, "ipv4");
|
|
10
|
+
privateAddresses.addSubnet("192.0.2.0", 24, "ipv4");
|
|
11
|
+
privateAddresses.addSubnet("192.31.196.0", 24, "ipv4");
|
|
12
|
+
privateAddresses.addSubnet("192.52.193.0", 24, "ipv4");
|
|
13
|
+
privateAddresses.addSubnet("192.88.99.0", 24, "ipv4");
|
|
14
|
+
privateAddresses.addSubnet("192.168.0.0", 16, "ipv4");
|
|
15
|
+
privateAddresses.addSubnet("192.175.48.0", 24, "ipv4");
|
|
16
|
+
privateAddresses.addSubnet("198.18.0.0", 15, "ipv4");
|
|
17
|
+
privateAddresses.addSubnet("198.51.100.0", 24, "ipv4");
|
|
18
|
+
privateAddresses.addSubnet("203.0.113.0", 24, "ipv4");
|
|
19
|
+
privateAddresses.addSubnet("224.0.0.0", 4, "ipv4");
|
|
20
|
+
privateAddresses.addSubnet("240.0.0.0", 4, "ipv4");
|
|
21
|
+
privateAddresses.addSubnet("::", 96, "ipv6");
|
|
22
|
+
privateAddresses.addSubnet("::ffff:0:0.0.0.0", 96, "ipv6");
|
|
23
|
+
privateAddresses.addSubnet("64:ff9b::", 96, "ipv6");
|
|
24
|
+
privateAddresses.addSubnet("64:ff9b:1::", 48, "ipv6");
|
|
25
|
+
privateAddresses.addSubnet("100::", 64, "ipv6");
|
|
26
|
+
privateAddresses.addSubnet("2001::", 23, "ipv6");
|
|
27
|
+
privateAddresses.addSubnet("2001:db8::", 32, "ipv6");
|
|
28
|
+
privateAddresses.addSubnet("2002::", 16, "ipv6");
|
|
29
|
+
privateAddresses.addSubnet("2620:4f:8000::", 48, "ipv6");
|
|
30
|
+
privateAddresses.addSubnet("fc00::", 7, "ipv6");
|
|
31
|
+
privateAddresses.addSubnet("fec0::", 10, "ipv6");
|
|
32
|
+
privateAddresses.addSubnet("fe80::", 10, "ipv6");
|
|
33
|
+
privateAddresses.addSubnet("ff00::", 8, "ipv6");
|
|
34
|
+
export function isPrivateIp(address) {
|
|
35
|
+
const family = isIP(address);
|
|
36
|
+
if (family === 4) {
|
|
37
|
+
return privateAddresses.check(address, "ipv4");
|
|
38
|
+
}
|
|
39
|
+
if (family === 6) {
|
|
40
|
+
return privateAddresses.check(address, "ipv6");
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LocalPattern, RemotePattern } from "./image-config.js";
|
|
2
|
+
export declare function hasLocalMatch(localPatterns: LocalPattern[] | undefined, pathname: string, search: string): boolean;
|
|
3
|
+
export declare function hasRemoteMatch(remotePatterns: RemotePattern[], url: URL): boolean;
|
|
4
|
+
//# sourceMappingURL=match-patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-patterns.d.ts","sourceRoot":"","sources":["../../../src/lib/image-optimization/match-patterns.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAyBpE,wBAAgB,aAAa,CAC5B,aAAa,EAAE,YAAY,EAAE,GAAG,SAAS,EACzC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACZ,OAAO,CAIT;AAgBD,wBAAgB,cAAc,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAEjF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isHostAllowed } from "../csrf-protection.js";
|
|
2
|
+
function matchPathname(pathname, pattern) {
|
|
3
|
+
const normalized = pattern.startsWith("/") ? pattern : `/${pattern}`;
|
|
4
|
+
let source = "";
|
|
5
|
+
for (const segment of normalized.split("/").slice(1)) {
|
|
6
|
+
if (segment === "**") {
|
|
7
|
+
source += "(?:/.*)?";
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
source += `/${segment.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*")}`;
|
|
11
|
+
}
|
|
12
|
+
return new RegExp(`^${source}$`).test(pathname);
|
|
13
|
+
}
|
|
14
|
+
function matchPathAndSearch(pattern, pathname, search) {
|
|
15
|
+
if (pattern.search !== undefined && pattern.search !== search) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return matchPathname(pathname, pattern.pathname ?? "**");
|
|
19
|
+
}
|
|
20
|
+
export function hasLocalMatch(localPatterns, pathname, search) {
|
|
21
|
+
if (!localPatterns)
|
|
22
|
+
return true;
|
|
23
|
+
return localPatterns.some((pattern) => matchPathAndSearch(pattern, pathname, search));
|
|
24
|
+
}
|
|
25
|
+
function matchRemotePattern(pattern, url) {
|
|
26
|
+
if (pattern.protocol !== undefined && pattern.protocol !== url.protocol.slice(0, -1)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (pattern.port !== undefined && pattern.port !== url.port) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (!isHostAllowed(url.hostname, pattern.hostname)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return matchPathAndSearch(pattern, url.pathname, url.search);
|
|
36
|
+
}
|
|
37
|
+
export function hasRemoteMatch(remotePatterns, url) {
|
|
38
|
+
return remotePatterns.some((pattern) => matchRemotePattern(pattern, url));
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-body.d.ts","sourceRoot":"","sources":["../../../src/lib/image-optimization/read-body.ts"],"names":[],"mappings":"AAEA,wBAAsB,QAAQ,CAC7B,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,EAC/B,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE,WAAW,GACjB,OAAO,CAAC,MAAM,CAAC,CA2BjB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ImageError, INVALID_UPSTREAM, TIMED_OUT } from "./image-error.js";
|
|
2
|
+
export async function readBody(body, maximumResponseBody, signal) {
|
|
3
|
+
const chunks = [];
|
|
4
|
+
let size = 0;
|
|
5
|
+
try {
|
|
6
|
+
for await (const chunk of body) {
|
|
7
|
+
size += chunk.byteLength;
|
|
8
|
+
if (size > maximumResponseBody) {
|
|
9
|
+
throw new ImageError(413, INVALID_UPSTREAM);
|
|
10
|
+
}
|
|
11
|
+
chunks.push(chunk);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (signal.aborted) {
|
|
16
|
+
throw new ImageError(504, TIMED_OUT);
|
|
17
|
+
}
|
|
18
|
+
if (error instanceof ImageError) {
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
throw new ImageError(400, INVALID_UPSTREAM);
|
|
22
|
+
}
|
|
23
|
+
if (size === 0) {
|
|
24
|
+
throw new ImageError(400, INVALID_UPSTREAM);
|
|
25
|
+
}
|
|
26
|
+
return Buffer.concat(chunks, size);
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-image-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/image-optimization/static-image-loader.ts"],"names":[],"mappings":"AAgDA,wBAAsB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA+B7F"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { join, relative, sep } from "node:path";
|
|
4
|
+
const BLUR_IMG_SIZE = 8;
|
|
5
|
+
const BLUR_QUALITY = 70;
|
|
6
|
+
const BLUR_EXTENSIONS = new Set(["jpg", "jpeg", "png", "webp", "avif"]);
|
|
7
|
+
async function getBlurPlaceholder(source, width, height, extension, root) {
|
|
8
|
+
if (!BLUR_EXTENSIONS.has(extension))
|
|
9
|
+
return;
|
|
10
|
+
let sharp;
|
|
11
|
+
try {
|
|
12
|
+
sharp = createRequire(join(root, "package.json"))("sharp");
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// `sharp` is optional. Static imports still work without blur placeholders.
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const blurWidth = width >= height ? BLUR_IMG_SIZE : Math.max(Math.round((width / height) * BLUR_IMG_SIZE), 1);
|
|
19
|
+
const blurHeight = height >= width ? BLUR_IMG_SIZE : Math.max(Math.round((height / width) * BLUR_IMG_SIZE), 1);
|
|
20
|
+
try {
|
|
21
|
+
const buffer = await sharp(source)
|
|
22
|
+
.rotate()
|
|
23
|
+
.resize(blurWidth, blurHeight)
|
|
24
|
+
.webp({ quality: BLUR_QUALITY })
|
|
25
|
+
.toBuffer();
|
|
26
|
+
return {
|
|
27
|
+
dataURL: `data:image/webp;base64,${buffer.toString("base64")}`,
|
|
28
|
+
width: blurWidth,
|
|
29
|
+
height: blurHeight,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export async function createStaticImageModule(filePath, root) {
|
|
37
|
+
const [{ imageSize }, source] = await Promise.all([import("image-size"), readFile(filePath)]);
|
|
38
|
+
const relativePath = relative(root, filePath);
|
|
39
|
+
const extension = filePath.split(".").pop().toLowerCase();
|
|
40
|
+
let size;
|
|
41
|
+
try {
|
|
42
|
+
size = imageSize(source);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
throw new Error(`Could not read the dimensions of "${relativePath}". Static image imports require a supported image format.`);
|
|
46
|
+
}
|
|
47
|
+
if (!size.width || !size.height) {
|
|
48
|
+
throw new Error(`Could not read the dimensions of "${relativePath}". Add width and height to the image.`);
|
|
49
|
+
}
|
|
50
|
+
// EXIF orientations 5-8 rotate by 90 or 270 degrees, swapping the dimensions.
|
|
51
|
+
const rotated = size.orientation !== undefined && size.orientation >= 5;
|
|
52
|
+
const width = rotated ? size.height : size.width;
|
|
53
|
+
const height = rotated ? size.width : size.height;
|
|
54
|
+
const blur = await getBlurPlaceholder(source, width, height, extension, root);
|
|
55
|
+
const data = { width, height, ...(blur ? { blur } : {}) };
|
|
56
|
+
const url = `/${relativePath.split(sep).join("/")}?url`;
|
|
57
|
+
return `import src from ${JSON.stringify(url)}
|
|
58
|
+
export default { ...${JSON.stringify(data)}, src }
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-entries.d.ts","sourceRoot":"","sources":["../../../src/lib/server-router/build-entries.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAExE,KAAK,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"build-entries.d.ts","sourceRoot":"","sources":["../../../src/lib/server-router/build-entries.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAExE,KAAK,OAAO,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE7G,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAA;IACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAA;IACvC,YAAY,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAA;IACnD,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAA;CACvC;AAaD,wBAAgB,YAAY,CAC3B,UAAU,EAAE,SAAS,EAAE,EACvB,kBAAkB,EAAE,iBAAiB,EAAE,EACvC,YAAY,EAAE,WAAW,EAAE,EAC3B,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,IAAI,EAClD,QAAQ,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4EvB"}
|
|
@@ -31,7 +31,7 @@ export function buildRouteEntries(pageRoutes, routeHandlerRoutes, layoutRoutes,
|
|
|
31
31
|
if (imageEntry) {
|
|
32
32
|
entries.set(entryKey(imageEntry.pattern, "GET"), {
|
|
33
33
|
type: "image",
|
|
34
|
-
methods: ["GET"],
|
|
34
|
+
methods: ["GET", "HEAD"],
|
|
35
35
|
pattern: imageEntry.pattern,
|
|
36
36
|
app: imageEntry.handler,
|
|
37
37
|
});
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAKA,OAAO,EAAS,KAAK,MAAM,EAAmB,MAAM,MAAM,CAAA;AAS1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAc1D,OAAO,KAAK,EACX,WAAW,EAEX,KAAK,EACL,iBAAiB,EAEjB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAYhE,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAI7B,KAAK,kBAAkB,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,KAAK,oBAAoB,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,kBAAkB,CAAA;AAEnE,KAAK,oBAAoB,GAAG;IAC3B,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CA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AmB;IACnC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;IACjD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC9B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,wBAAgB,MAAM,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,EAAE,CAkclE"}
|
package/dist/vite.js
CHANGED
|
@@ -267,10 +267,18 @@ export function rebask(options = {}) {
|
|
|
267
267
|
},
|
|
268
268
|
},
|
|
269
269
|
optimizeDeps: {
|
|
270
|
-
// Point Vite's dep scanner at user
|
|
271
|
-
//
|
|
272
|
-
//
|
|
273
|
-
|
|
270
|
+
// Point Vite's dep scanner at user source so it discovers bare imports at startup.
|
|
271
|
+
// App files cover the static route graph. The JSX/TSX glob also covers components
|
|
272
|
+
// reached only through computed imports, which would otherwise trigger a late
|
|
273
|
+
// re-optimization that duplicates React during a client navigation.
|
|
274
|
+
entries: [
|
|
275
|
+
"app/**/*.{tsx,ts,jsx,js}",
|
|
276
|
+
"**/*.{tsx,jsx}",
|
|
277
|
+
"!**/*.test.{tsx,jsx}",
|
|
278
|
+
"!**/*.spec.{tsx,jsx}",
|
|
279
|
+
"!**/__tests__/**",
|
|
280
|
+
BROWSER_ENTRY,
|
|
281
|
+
],
|
|
274
282
|
// Exclude the framework itself so Vite serves it as native ESM instead of pre-bundling
|
|
275
283
|
// it. If `@rebask/core` is pre-bundled, React would be baked into the optimized chunk,
|
|
276
284
|
// resulting in two React copies (one inside the framework chunk, one for app code).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebask/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Vite plugin and runtime for React Server Components",
|
|
5
5
|
"homepage": "https://github.com/lfades/vext#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -145,6 +145,7 @@
|
|
|
145
145
|
"dependencies": {
|
|
146
146
|
"@lfades/atom": "^3.0.0",
|
|
147
147
|
"@opentelemetry/api": "~1.9.1",
|
|
148
|
+
"image-size": "^2.1.0",
|
|
148
149
|
"rou3": "^1.0.0",
|
|
149
150
|
"rsc-html-stream": "^0.0.8"
|
|
150
151
|
},
|
package/dist/__type_probe__.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"__type_probe__.d.ts","sourceRoot":"","sources":["../src/__type_probe__.ts"],"names":[],"mappings":""}
|
package/dist/__type_probe__.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Component, type ReactNode } from "react";
|
|
2
|
-
import type { RevisionSnapshot, RouterCache } from "../lib/router-cache.js";
|
|
3
|
-
type BoundaryRenderProps = {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
fallback: ReactNode;
|
|
6
|
-
hasError?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export type BoundaryClientProps = BoundaryRenderProps & {
|
|
9
|
-
boundaryKey: string;
|
|
10
|
-
};
|
|
11
|
-
type BoundaryCacheState = {
|
|
12
|
-
boundaryKey: string;
|
|
13
|
-
segmentPath: string;
|
|
14
|
-
snapshot: RevisionSnapshot;
|
|
15
|
-
failed: boolean;
|
|
16
|
-
};
|
|
17
|
-
type ErrorBoundaryClientInnerProps = BoundaryRenderProps & BoundaryCacheState;
|
|
18
|
-
type BoundaryCacheStateResult = BoundaryCacheState & {
|
|
19
|
-
acceptsServerError: boolean;
|
|
20
|
-
};
|
|
21
|
-
type ErrorBoundaryClientState = {
|
|
22
|
-
hasError: boolean;
|
|
23
|
-
snapshot: RevisionSnapshot;
|
|
24
|
-
};
|
|
25
|
-
export declare class ErrorBoundaryClientInner extends Component<ErrorBoundaryClientInnerProps, ErrorBoundaryClientState> {
|
|
26
|
-
static contextType: import("react").Context<RouterCache | null>;
|
|
27
|
-
context: RouterCache | null;
|
|
28
|
-
state: ErrorBoundaryClientState;
|
|
29
|
-
constructor(props: ErrorBoundaryClientInnerProps);
|
|
30
|
-
static getDerivedStateFromProps(props: ErrorBoundaryClientInnerProps, state: ErrorBoundaryClientState): {
|
|
31
|
-
hasError: boolean;
|
|
32
|
-
snapshot: RevisionSnapshot;
|
|
33
|
-
} | {
|
|
34
|
-
snapshot?: undefined;
|
|
35
|
-
hasError: boolean;
|
|
36
|
-
} | null;
|
|
37
|
-
static getDerivedStateFromError(error: Error): {
|
|
38
|
-
hasError: boolean;
|
|
39
|
-
};
|
|
40
|
-
componentDidMount(): void;
|
|
41
|
-
componentDidUpdate(_prevProps: ErrorBoundaryClientInnerProps, prevState: ErrorBoundaryClientState): void;
|
|
42
|
-
componentDidCatch(error: Error): void;
|
|
43
|
-
render(): ReactNode;
|
|
44
|
-
protected recordFailure(): void;
|
|
45
|
-
}
|
|
46
|
-
export declare function ErrorBoundaryClient(props: BoundaryClientProps): import("react").JSX.Element;
|
|
47
|
-
export declare function useBoundaryCacheState(boundaryKey: string): BoundaryCacheStateResult;
|
|
48
|
-
export {};
|
|
49
|
-
//# sourceMappingURL=error-boundary-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary-client.d.ts","sourceRoot":"","sources":["../../src/components/error-boundary-client.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAwB,MAAM,OAAO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,QAGtC;IAEQ,MAAM,cAEd;IAED,SAAS,CAAC,aAAa,SAMtB;CACD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,+BAU7D;AAED,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,wBAAwB,CAenF"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Component, useSyncExternalStore } from "react";
|
|
4
|
-
import { isNotFoundError } from "../lib/errors.js";
|
|
5
|
-
import { showViteErrorOverlay } from "../lib/vite-error-overlay.js";
|
|
6
|
-
import { RouterCacheContext, useRouterCache } from "./cache-slot.js";
|
|
7
|
-
import { useSegment } from "./segment-boundary.js";
|
|
8
|
-
export class ErrorBoundaryClientInner extends Component {
|
|
9
|
-
static contextType = RouterCacheContext;
|
|
10
|
-
context = null;
|
|
11
|
-
state;
|
|
12
|
-
constructor(props) {
|
|
13
|
-
super(props);
|
|
14
|
-
this.state = {
|
|
15
|
-
hasError: !!props.hasError || props.failed,
|
|
16
|
-
snapshot: props.snapshot,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
static getDerivedStateFromProps(props, state) {
|
|
20
|
-
if (props.snapshot !== state.snapshot) {
|
|
21
|
-
return { hasError: props.failed, snapshot: props.snapshot };
|
|
22
|
-
}
|
|
23
|
-
if (props.failed && !state.hasError)
|
|
24
|
-
return { hasError: true };
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
static getDerivedStateFromError(error) {
|
|
28
|
-
if (isNotFoundError(error))
|
|
29
|
-
throw error;
|
|
30
|
-
return { hasError: true };
|
|
31
|
-
}
|
|
32
|
-
componentDidMount() {
|
|
33
|
-
if (this.state.hasError)
|
|
34
|
-
this.recordFailure();
|
|
35
|
-
}
|
|
36
|
-
componentDidUpdate(_prevProps, prevState) {
|
|
37
|
-
if (this.state.hasError &&
|
|
38
|
-
(!prevState.hasError || prevState.snapshot !== this.state.snapshot)) {
|
|
39
|
-
this.recordFailure();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
componentDidCatch(error) {
|
|
43
|
-
showViteErrorOverlay(error);
|
|
44
|
-
this.recordFailure();
|
|
45
|
-
}
|
|
46
|
-
render() {
|
|
47
|
-
return this.state.hasError ? this.props.fallback : this.props.children;
|
|
48
|
-
}
|
|
49
|
-
recordFailure() {
|
|
50
|
-
this.context?.markBoundaryFailed(this.props.boundaryKey, this.props.segmentPath, this.state.snapshot);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export function ErrorBoundaryClient(props) {
|
|
54
|
-
const { acceptsServerError, ...cacheProps } = useBoundaryCacheState(props.boundaryKey);
|
|
55
|
-
return (_jsx(ErrorBoundaryClientInner, { ...props, ...cacheProps, hasError: acceptsServerError && props.hasError }));
|
|
56
|
-
}
|
|
57
|
-
export function useBoundaryCacheState(boundaryKey) {
|
|
58
|
-
const cache = useRouterCache();
|
|
59
|
-
const segment = useSegment();
|
|
60
|
-
const segmentPath = segment?.path ?? "";
|
|
61
|
-
const scopedBoundaryKey = `${boundaryKey}|${segmentPath}`;
|
|
62
|
-
const getSnapshot = () => cache.getBoundaryRevisionSnapshot(segmentPath);
|
|
63
|
-
const snapshot = useSyncExternalStore(cache.activePagesAtom.sub, getSnapshot, getSnapshot);
|
|
64
|
-
return {
|
|
65
|
-
acceptsServerError: !cache.hasBoundaryFailureHistory(scopedBoundaryKey),
|
|
66
|
-
boundaryKey: scopedBoundaryKey,
|
|
67
|
-
failed: cache.hasFailedBoundarySnapshot(scopedBoundaryKey, snapshot),
|
|
68
|
-
snapshot,
|
|
69
|
-
segmentPath,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
interface ErrorBoundaryProps {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
fallback: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
export declare function ErrorBoundary({ children, fallback }: ErrorBoundaryProps): import("react").JSX.Element;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=error-boundary.browser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary.browser.d.ts","sourceRoot":"","sources":["../../src/components/error-boundary.browser.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAS,MAAM,OAAO,CAAA;AAG7C,UAAU,kBAAkB;IAC3B,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,EAAE,SAAS,CAAA;CACnB;AAED,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,kBAAkB,+BAMvE"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useId } from "react";
|
|
3
|
-
import { ErrorBoundaryClient } from "./error-boundary-client.js";
|
|
4
|
-
export function ErrorBoundary({ children, fallback }) {
|
|
5
|
-
return (_jsx(ErrorBoundaryClient, { boundaryKey: `error:${useId()}`, fallback: fallback, children: children }));
|
|
6
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/components/error.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,YAAY,gCAOnC"}
|
package/dist/components/error.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { StatusPage } from "./status-page.js";
|
|
3
|
-
export default function DefaultError() {
|
|
4
|
-
return (_jsx(StatusPage, { title: "500 - Internal Server Error", description: "Something went wrong while rendering this page." }));
|
|
5
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Throws `notFound()` so the surrounding `<NotFoundBoundary>` catches and renders its fallback.
|
|
4
|
-
*
|
|
5
|
-
* Useful for action responses that call `notFound()` outside React's render process
|
|
6
|
-
* (e.g in an event handler).
|
|
7
|
-
*/
|
|
8
|
-
export declare function NotFoundActivator({ children }: {
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
}): ReactNode;
|
|
11
|
-
//# sourceMappingURL=not-found-activator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"not-found-activator.d.ts","sourceRoot":"","sources":["../../src/components/not-found-activator.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAA;AAI3D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,aAiBtE"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { notFound } from "../lib/not-found.js";
|
|
4
|
-
import { useRouterCache } from "./cache-slot.js";
|
|
5
|
-
/**
|
|
6
|
-
* Throws `notFound()` so the surrounding `<NotFoundBoundary>` catches and renders its fallback.
|
|
7
|
-
*
|
|
8
|
-
* Useful for action responses that call `notFound()` outside React's render process
|
|
9
|
-
* (e.g in an event handler).
|
|
10
|
-
*/
|
|
11
|
-
export function NotFoundActivator({ children }) {
|
|
12
|
-
const cache = useRouterCache();
|
|
13
|
-
const [throwNow, setThrowNow] = useState(false);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const sub = cache.notFoundFromActionAtom.sub((trigger) => {
|
|
16
|
-
if (trigger > 0)
|
|
17
|
-
setThrowNow(true);
|
|
18
|
-
});
|
|
19
|
-
return () => {
|
|
20
|
-
sub();
|
|
21
|
-
};
|
|
22
|
-
}, [cache]);
|
|
23
|
-
if (throwNow)
|
|
24
|
-
notFound();
|
|
25
|
-
return children;
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"not-found-boundary-client.d.ts","sourceRoot":"","sources":["../../src/components/not-found-boundary-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,4BAA4B,CAAA;AAcnC,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,mBAAmB,+BAShE"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { isNotFoundError } from "../lib/errors.js";
|
|
4
|
-
import { ErrorBoundaryClientInner, useBoundaryCacheState, } from "./error-boundary-client.js";
|
|
5
|
-
class NotFoundBoundaryClientInner extends ErrorBoundaryClientInner {
|
|
6
|
-
static getDerivedStateFromError(error) {
|
|
7
|
-
if (isNotFoundError(error))
|
|
8
|
-
return { hasError: true };
|
|
9
|
-
throw error;
|
|
10
|
-
}
|
|
11
|
-
componentDidCatch(error) {
|
|
12
|
-
if (!isNotFoundError(error))
|
|
13
|
-
throw error;
|
|
14
|
-
this.recordFailure();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export function NotFoundBoundaryClient(props) {
|
|
18
|
-
const { acceptsServerError, ...cacheProps } = useBoundaryCacheState(props.boundaryKey);
|
|
19
|
-
return (_jsx(NotFoundBoundaryClientInner, { ...props, ...cacheProps, hasError: acceptsServerError && props.hasError }));
|
|
20
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
interface NotFoundBoundaryProps {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
fallback: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
export declare function NotFoundBoundary(_props: NotFoundBoundaryProps): never;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=not-found-boundary.browser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"not-found-boundary.browser.d.ts","sourceRoot":"","sources":["../../src/components/not-found-boundary.browser.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,UAAU,qBAAqB;IAC9B,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,EAAE,SAAS,CAAA;CACnB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,GAAG,KAAK,CAKrE"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
interface NotFoundBoundaryProps {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
fallback: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
export declare function NotFoundBoundary({ children, fallback }: NotFoundBoundaryProps): import("react").JSX.Element;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=not-found-boundary.d.ts.map
|