@farm.js/plugin 0.1.51-beta.3 → 0.1.61
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/middleware/index.d.ts +1 -8
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +10 -16
- package/dist/middleware/matching.d.ts +2 -4
- package/dist/middleware/matching.d.ts.map +1 -1
- package/dist/middleware/matching.js +47 -7
- package/dist/rsc/entries/client.d.ts.map +1 -1
- package/dist/rsc/entries/client.js +9 -22
- package/dist/rsc/entries/rsc.d.ts.map +1 -1
- package/dist/rsc/entries/rsc.js +40 -533
- package/dist/rsc/entries/ssr.d.ts.map +1 -1
- package/dist/rsc/entries/ssr.js +6 -7
- package/dist/rsc/index.d.ts +2 -35
- package/dist/rsc/index.d.ts.map +1 -1
- package/dist/rsc/index.js +290 -238
- package/dist/rsc/middleware-config-module.d.ts +0 -3
- package/dist/rsc/middleware-config-module.d.ts.map +1 -1
- package/dist/rsc/middleware-config-module.js +28 -41
- package/dist/rsc/nitro-build.d.ts.map +1 -1
- package/dist/rsc/nitro-build.js +81 -259
- package/dist/rsc/server-fn-transform.d.ts +5 -1
- package/dist/rsc/server-fn-transform.d.ts.map +1 -1
- package/dist/rsc/server-fn-transform.js +338 -3
- package/dist/rsc/types.d.ts +0 -28
- package/dist/rsc/types.d.ts.map +1 -1
- package/dist/rsc/vite-plugin-nitro.d.ts +0 -2
- package/dist/rsc/vite-plugin-nitro.d.ts.map +1 -1
- package/dist/rsc/vite-plugin-nitro.js +2 -12
- package/package.json +3 -3
- package/dist/rsc/client-sourcemaps.d.ts +0 -13
- package/dist/rsc/client-sourcemaps.d.ts.map +0 -1
- package/dist/rsc/client-sourcemaps.js +0 -52
- package/dist/rsc/document-layouts.d.ts +0 -16
- package/dist/rsc/document-layouts.d.ts.map +0 -1
- package/dist/rsc/document-layouts.js +0 -82
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ export interface CookieOptions {
|
|
|
40
40
|
export interface CookieJar {
|
|
41
41
|
get(name: string): string | undefined;
|
|
42
42
|
set(name: string, value: string, options?: CookieOptions): void;
|
|
43
|
-
delete(name: string
|
|
43
|
+
delete(name: string): void;
|
|
44
44
|
getAll(): Record<string, string>;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -50,14 +50,7 @@ export interface MiddlewareContext {
|
|
|
50
50
|
request: IncomingMessage;
|
|
51
51
|
response: ServerResponse;
|
|
52
52
|
url: URL;
|
|
53
|
-
/** Request pathname as received: still percent-encoded. */
|
|
54
53
|
pathname: string;
|
|
55
|
-
/**
|
|
56
|
-
* The pathname the router matches: each segment decoded once, as core's
|
|
57
|
-
* `ctx.routePathname`. `.when()` conditions and function matchers also see it,
|
|
58
|
-
* so `/%61dmin` cannot skip a check written for `/admin`. Updated by `rewrite()`.
|
|
59
|
-
*/
|
|
60
|
-
readonly routePathname: string;
|
|
61
54
|
searchParams: URLSearchParams;
|
|
62
55
|
method: string;
|
|
63
56
|
params: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;GAcG;AAEH,O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;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC9B,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KACtB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE1B,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EACF,iBAAiB,GACjB;QAAE,KAAK,EAAE,MAAM;YAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAA;SAAE,CAAC;QAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;IAC7F,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAuKD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAoUlF;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/middleware/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { _withAfterNodeMiddleware } from "@farm.js/core/after";
|
|
4
4
|
import { devServableFileExists } from "../dev-static.js";
|
|
5
5
|
import { resolveDevRequestURL, resolveViteHtmlFallbackUrl } from "../dev-request.js";
|
|
6
|
-
import {
|
|
6
|
+
import { matchesMiddlewareConfig } from "@farm.js/core/middleware";
|
|
7
7
|
import { middlewareMatchesPath, parseCookies, serializeCookie } from "./matching.js";
|
|
8
8
|
// Create require for ESM compatibility
|
|
9
9
|
const require_ = createRequire(import.meta.url);
|
|
@@ -37,27 +37,24 @@ const getColors = () => {
|
|
|
37
37
|
*/
|
|
38
38
|
function createCookieJar(req, res) {
|
|
39
39
|
const cookies = parseCookies(req.headers.cookie);
|
|
40
|
-
|
|
41
|
-
const existing = res.getHeader("Set-Cookie");
|
|
42
|
-
const setCookies = Array.isArray(existing)
|
|
43
|
-
? existing.map(String)
|
|
44
|
-
: existing === undefined
|
|
45
|
-
? []
|
|
46
|
-
: [String(existing)];
|
|
40
|
+
const setCookies = [];
|
|
47
41
|
return {
|
|
48
42
|
get(name) {
|
|
49
43
|
return cookies[name];
|
|
50
44
|
},
|
|
51
45
|
set(name, value, options = {}) {
|
|
52
46
|
cookies[name] = value;
|
|
53
|
-
|
|
47
|
+
const cookieString = serializeCookie(name, value, options);
|
|
48
|
+
setCookies.push(cookieString);
|
|
54
49
|
res.setHeader("Set-Cookie", setCookies);
|
|
55
50
|
},
|
|
56
|
-
delete(name
|
|
51
|
+
delete(name) {
|
|
57
52
|
delete cookies[name];
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
const cookieString = serializeCookie(name, "", {
|
|
54
|
+
maxAge: 0,
|
|
55
|
+
expires: new Date(0),
|
|
56
|
+
});
|
|
57
|
+
setCookies.push(cookieString);
|
|
61
58
|
res.setHeader("Set-Cookie", setCookies);
|
|
62
59
|
},
|
|
63
60
|
getAll() {
|
|
@@ -94,8 +91,6 @@ function createContext(req, res, viteServer) {
|
|
|
94
91
|
response: res,
|
|
95
92
|
url,
|
|
96
93
|
pathname: url.pathname,
|
|
97
|
-
// Vite has already removed its base from the URL, so this is the app's path.
|
|
98
|
-
routePathname: canonicalizeRequestPathname(url.pathname),
|
|
99
94
|
searchParams: url.searchParams,
|
|
100
95
|
method: req.method || "GET",
|
|
101
96
|
params: {},
|
|
@@ -130,7 +125,6 @@ function createContext(req, res, viteServer) {
|
|
|
130
125
|
const newUrl = new URL(rewriteUrl, `http://${req.headers.host || "localhost"}`);
|
|
131
126
|
ctx.url = newUrl;
|
|
132
127
|
ctx.pathname = newUrl.pathname;
|
|
133
|
-
ctx.routePathname = canonicalizeRequestPathname(newUrl.pathname);
|
|
134
128
|
ctx.searchParams = newUrl.searchParams;
|
|
135
129
|
// Update the original request URL
|
|
136
130
|
req.url = rewriteUrl;
|
|
@@ -6,8 +6,7 @@ import type { CookieOptions } from "./index.js";
|
|
|
6
6
|
* (a latin-1 value from an old link, a crawler, or a bare `%`) must not take
|
|
7
7
|
* the whole map down: an unguarded `decodeURIComponent` throws `URIError`,
|
|
8
8
|
* which fails the request before any middleware runs. Decoding falls back to
|
|
9
|
-
* the raw value per entry instead.
|
|
10
|
-
* agree on which duplicate wins.
|
|
9
|
+
* the raw value per entry instead.
|
|
11
10
|
*/
|
|
12
11
|
export declare function parseCookies(cookieHeader?: string): Record<string, string>;
|
|
13
12
|
/**
|
|
@@ -29,8 +28,7 @@ export declare function middlewareMatchesPath(pathname: string, middlewarePath:
|
|
|
29
28
|
*
|
|
30
29
|
* `Max-Age=0` is the canonical immediate-expiry directive, so the attribute is
|
|
31
30
|
* emitted whenever `maxAge` is provided — a `0` must not be dropped the way a
|
|
32
|
-
* plain truthiness check would drop it.
|
|
33
|
-
* Set-Cookie carries the attributes a browser requires, as production does.
|
|
31
|
+
* plain truthiness check would drop it.
|
|
34
32
|
*/
|
|
35
33
|
export declare function serializeCookie(name: string, value: string, options?: CookieOptions): string;
|
|
36
34
|
//# sourceMappingURL=matching.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matching.d.ts","sourceRoot":"","sources":["../../src/middleware/matching.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"matching.d.ts","sourceRoot":"","sources":["../../src/middleware/matching.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAc1E;AAUD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAMvF;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAkChG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { canonicalizeRequestPathSegments
|
|
1
|
+
import { canonicalizeRequestPathSegments } from "@farm.js/core/middleware";
|
|
2
2
|
/**
|
|
3
3
|
* Parse cookies from a Cookie header.
|
|
4
4
|
*
|
|
@@ -6,11 +6,27 @@ import { canonicalizeRequestPathSegments, parseMiddlewareCookieHeader, serialize
|
|
|
6
6
|
* (a latin-1 value from an old link, a crawler, or a bare `%`) must not take
|
|
7
7
|
* the whole map down: an unguarded `decodeURIComponent` throws `URIError`,
|
|
8
8
|
* which fails the request before any middleware runs. Decoding falls back to
|
|
9
|
-
* the raw value per entry instead.
|
|
10
|
-
* agree on which duplicate wins.
|
|
9
|
+
* the raw value per entry instead.
|
|
11
10
|
*/
|
|
12
11
|
export function parseCookies(cookieHeader) {
|
|
13
|
-
|
|
12
|
+
if (!cookieHeader)
|
|
13
|
+
return {};
|
|
14
|
+
return cookieHeader.split(";").reduce((cookies, cookie) => {
|
|
15
|
+
const [name, ...rest] = cookie.split("=");
|
|
16
|
+
const value = rest.join("=").trim();
|
|
17
|
+
if (name && value) {
|
|
18
|
+
cookies[name.trim()] = decodeCookieValue(value);
|
|
19
|
+
}
|
|
20
|
+
return cookies;
|
|
21
|
+
}, {});
|
|
22
|
+
}
|
|
23
|
+
function decodeCookieValue(value) {
|
|
24
|
+
try {
|
|
25
|
+
return decodeURIComponent(value);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
14
30
|
}
|
|
15
31
|
/**
|
|
16
32
|
* Whether a middleware registered at `middlewarePath` applies to `pathname`.
|
|
@@ -39,9 +55,33 @@ export function middlewareMatchesPath(pathname, middlewarePath) {
|
|
|
39
55
|
*
|
|
40
56
|
* `Max-Age=0` is the canonical immediate-expiry directive, so the attribute is
|
|
41
57
|
* emitted whenever `maxAge` is provided — a `0` must not be dropped the way a
|
|
42
|
-
* plain truthiness check would drop it.
|
|
43
|
-
* Set-Cookie carries the attributes a browser requires, as production does.
|
|
58
|
+
* plain truthiness check would drop it.
|
|
44
59
|
*/
|
|
45
60
|
export function serializeCookie(name, value, options = {}) {
|
|
46
|
-
|
|
61
|
+
let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
|
|
62
|
+
if (options.maxAge != null) {
|
|
63
|
+
cookie += `; Max-Age=${options.maxAge}`;
|
|
64
|
+
}
|
|
65
|
+
if (options.expires) {
|
|
66
|
+
cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
67
|
+
}
|
|
68
|
+
if (options.path) {
|
|
69
|
+
cookie += `; Path=${options.path}`;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
cookie += "; Path=/";
|
|
73
|
+
}
|
|
74
|
+
if (options.domain) {
|
|
75
|
+
cookie += `; Domain=${options.domain}`;
|
|
76
|
+
}
|
|
77
|
+
if (options.secure) {
|
|
78
|
+
cookie += "; Secure";
|
|
79
|
+
}
|
|
80
|
+
if (options.httpOnly) {
|
|
81
|
+
cookie += "; HttpOnly";
|
|
82
|
+
}
|
|
83
|
+
if (options.sameSite) {
|
|
84
|
+
cookie += `; SameSite=${options.sameSite.charAt(0).toUpperCase() + options.sameSite.slice(1)}`;
|
|
85
|
+
}
|
|
86
|
+
return cookie;
|
|
47
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,mCAAmC,62BA6B9C,CAAC;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,mCAAmC,62BA6B9C,CAAC;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAyT7D"}
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
`;
|
|
64
64
|
if (ctx.actionsEnabled) {
|
|
65
65
|
imports += `import { setServerCallback, encodeReply, createTemporaryReferenceSet } from '@vitejs/plugin-rsc/browser';
|
|
66
|
-
import { applyFarmCacheInvalidations } from '@farm.js/core/
|
|
66
|
+
import { applyFarmCacheInvalidations } from '@farm.js/core/cache';
|
|
67
67
|
import {
|
|
68
68
|
beginFarmServerQueryAction,
|
|
69
69
|
completeFarmServerQueryAction,
|
|
@@ -177,10 +177,9 @@ async function main() {
|
|
|
177
177
|
|
|
178
178
|
debug('Starting client hydration');
|
|
179
179
|
|
|
180
|
-
// Clean duplicate DOM as early as possible (server may have sent two blocks)
|
|
181
|
-
// wrapper: an app that owns the document can have an element with id="root" in its content.
|
|
180
|
+
// Clean duplicate DOM as early as possible (server may have sent two blocks)
|
|
182
181
|
const rootEl = document.getElementById('root');
|
|
183
|
-
if (rootEl
|
|
182
|
+
if (rootEl) {
|
|
184
183
|
while (rootEl.children.length > 1) rootEl.lastElementChild.remove();
|
|
185
184
|
while (rootEl.nextElementSibling) rootEl.nextElementSibling.remove();
|
|
186
185
|
}
|
|
@@ -281,13 +280,8 @@ async function main() {
|
|
|
281
280
|
debug('Fetching RSC for:', url);
|
|
282
281
|
|
|
283
282
|
try {
|
|
284
|
-
// Request
|
|
285
|
-
|
|
286
|
-
const payloadUrl = new URL(url, location.href);
|
|
287
|
-
payloadUrl.pathname = payloadUrl.pathname.endsWith('/')
|
|
288
|
-
? payloadUrl.pathname + 'index.rsc'
|
|
289
|
-
: payloadUrl.pathname + '.rsc';
|
|
290
|
-
const res = await fetch(payloadUrl, {
|
|
283
|
+
// Request RSC format instead of HTML
|
|
284
|
+
const res = await fetch(url, {
|
|
291
285
|
headers: createFarmDeploymentRequestHeaders(farmDeploymentId, {
|
|
292
286
|
Accept: 'text/x-component',
|
|
293
287
|
}),
|
|
@@ -311,10 +305,6 @@ async function main() {
|
|
|
311
305
|
// reflect the page actually rendered (auth gates redirect this way).
|
|
312
306
|
if (res.redirected && res.url) {
|
|
313
307
|
const dest = new URL(res.url);
|
|
314
|
-
if (dest.pathname.endsWith('.rsc')) {
|
|
315
|
-
const page = dest.pathname.slice(0, -'.rsc'.length);
|
|
316
|
-
dest.pathname = page.endsWith('/index') ? page.slice(0, -'index'.length) : page;
|
|
317
|
-
}
|
|
318
308
|
if (dest.origin === location.origin) {
|
|
319
309
|
const target = dest.pathname + dest.search + dest.hash;
|
|
320
310
|
if (target !== location.pathname + location.search + location.hash) {
|
|
@@ -331,17 +321,14 @@ async function main() {
|
|
|
331
321
|
location.href = url;
|
|
332
322
|
}
|
|
333
323
|
}
|
|
334
|
-
|
|
335
|
-
const rootElForHydrate = initial.ownsDocument ? document : document.getElementById('root');
|
|
324
|
+
const rootElForHydrate = document.getElementById('root');
|
|
336
325
|
if (!rootElForHydrate) {
|
|
337
326
|
console.error('[Farm.js] #root element not found');
|
|
338
327
|
return;
|
|
339
328
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
while (rootElForHydrate.nextElementSibling) rootElForHydrate.nextElementSibling.remove();
|
|
344
|
-
}
|
|
329
|
+
// Final cleanup pass before hydrate (in case DOM changed during async)
|
|
330
|
+
while (rootElForHydrate.children.length > 1) rootElForHydrate.lastElementChild.remove();
|
|
331
|
+
while (rootElForHydrate.nextElementSibling) rootElForHydrate.nextElementSibling.remove();
|
|
345
332
|
debug('Hydrating application');
|
|
346
333
|
globalThis.__FARM_RSC_HYDRATED = true;
|
|
347
334
|
hydrateRoot(rootElForHydrate, React.createElement(BrowserRoot), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/rsc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/rsc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAe5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAy+B1D"}
|