eclipsa 0.1.8 → 0.1.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/{action-DqgkV3zb.mjs → action-DCc4fBhy.mjs} +258 -19
- package/action-DCc4fBhy.mjs.map +1 -0
- package/{client-DKPmN-wJ.mjs → client--uq9YZzN.mjs} +42 -3
- package/client--uq9YZzN.mjs.map +1 -0
- package/core/client/mod.mjs +3 -3
- package/core/dev-client/mod.mjs +3 -3
- package/core/internal.d.mts +1 -1
- package/core/internal.mjs +1 -1
- package/core/prod-client/mod.mjs +3 -3
- package/core/prod-client/mod.mjs.map +1 -1
- package/{internal-CHYAJznU.d.mts → internal-1QlldZaD.d.mts} +2 -1
- package/jsx/mod.mjs +1 -1
- package/mod.d.mts +2 -2
- package/mod.mjs +3 -3
- package/package.json +2 -2
- package/{signal-DBzloBrN.mjs → signal-DoW9q--8.mjs} +10 -2
- package/{signal-DBzloBrN.mjs.map → signal-DoW9q--8.mjs.map} +1 -1
- package/{ssr-CRg57Wn2.mjs → ssr-lXZqUHZs.mjs} +4 -4
- package/{ssr-CRg57Wn2.mjs.map → ssr-lXZqUHZs.mjs.map} +1 -1
- package/{ssr-D8F-DtCv.d.mts → ssr-wXShLrdB.d.mts} +2 -2
- package/vite/build/runtime.d.mts +9 -3
- package/vite/build/runtime.mjs +3 -3
- package/vite/mod.mjs +73 -41
- package/vite/mod.mjs.map +1 -1
- package/web-utils/mod.mjs +2 -2
- package/action-DqgkV3zb.mjs.map +0 -1
- package/client-DKPmN-wJ.mjs.map +0 -1
package/vite/mod.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bn as createRequestFetch, Fn as applyActionCsrfCookie, In as ensureActionCsrfToken, Jn as runHandleError, L as primeLocationState, Qn as withServerRequestContext, Rn as APP_HOOKS_ELEMENT_ID, Wn as markPublicError, bn as composeRouteMetadata, dn as ROUTE_DATA_REQUEST_HEADER, gn as ROUTE_PREFLIGHT_REQUEST_HEADER, hn as ROUTE_PREFLIGHT_ENDPOINT, pn as ROUTE_MANIFEST_ELEMENT_ID, qn as resolveReroute, un as ROUTE_DATA_ENDPOINT, vn as ROUTE_RPC_URL_HEADER, xn as renderRouteMetadataHead, zn as attachRequestFetch } from "../action-DCc4fBhy.mjs";
|
|
2
2
|
import { a as jsxDEV, t as Fragment } from "../jsx-dev-runtime-DpbWQ4Q0.mjs";
|
|
3
3
|
import { t as RESUME_HMR_EVENT } from "../resume-hmr-qTpLc5o-.mjs";
|
|
4
4
|
import { createServerModuleRunner, transformWithOxc } from "vite";
|
|
@@ -19,6 +19,14 @@ const normalizeRoutePath = (pathname) => {
|
|
|
19
19
|
if (withLeadingSlash.length > 1 && withLeadingSlash.endsWith("/")) return withLeadingSlash.slice(0, -1);
|
|
20
20
|
return withLeadingSlash;
|
|
21
21
|
};
|
|
22
|
+
const decodeRoutePathSegment = (segment) => {
|
|
23
|
+
try {
|
|
24
|
+
return decodeURIComponent(segment);
|
|
25
|
+
} catch {
|
|
26
|
+
return segment;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const splitRoutePath = (pathname) => normalizeRoutePath(pathname).split("/").filter(Boolean).map(decodeRoutePathSegment);
|
|
22
30
|
const createDirectoryEntry = () => ({
|
|
23
31
|
error: null,
|
|
24
32
|
layout: null,
|
|
@@ -149,7 +157,7 @@ const matchSegments = (segments, pathnameSegments, routeIndex = 0, pathIndex = 0
|
|
|
149
157
|
}
|
|
150
158
|
};
|
|
151
159
|
const toMatch = (route, pathname) => {
|
|
152
|
-
const pathnameSegments =
|
|
160
|
+
const pathnameSegments = splitRoutePath(pathname);
|
|
153
161
|
const params = matchSegments(route.segments, pathnameSegments);
|
|
154
162
|
if (!params) return null;
|
|
155
163
|
return {
|
|
@@ -861,6 +869,7 @@ const getRequestUrl = (request) => {
|
|
|
861
869
|
if (proto) url.protocol = `${proto}:`;
|
|
862
870
|
return url;
|
|
863
871
|
};
|
|
872
|
+
const createInternalRouteRequestUrl = (request, targetUrl) => new URL(`${targetUrl.pathname}${targetUrl.search}`, request.url).href;
|
|
864
873
|
const toAppRelativePath = (root, filePath) => {
|
|
865
874
|
const relativePath = path$1.relative(path$1.join(root, "app"), filePath);
|
|
866
875
|
if (relativePath.startsWith("..") || path$1.isAbsolute(relativePath)) return null;
|
|
@@ -1003,7 +1012,13 @@ const createRouteElement = (pathname, params, Page, Layouts, error) => {
|
|
|
1003
1012
|
return children;
|
|
1004
1013
|
};
|
|
1005
1014
|
const scoreSpecialRoute = (route, pathname) => {
|
|
1006
|
-
const pathnameSegments = normalizeRoutePath(pathname).split("/").filter(Boolean)
|
|
1015
|
+
const pathnameSegments = normalizeRoutePath(pathname).split("/").filter(Boolean).map((segment) => {
|
|
1016
|
+
try {
|
|
1017
|
+
return decodeURIComponent(segment);
|
|
1018
|
+
} catch {
|
|
1019
|
+
return segment;
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1007
1022
|
let score = 0;
|
|
1008
1023
|
for (let index = 0; index < route.segments.length && index < pathnameSegments.length; index += 1) {
|
|
1009
1024
|
const segment = route.segments[index];
|
|
@@ -1019,8 +1034,14 @@ const scoreSpecialRoute = (route, pathname) => {
|
|
|
1019
1034
|
return score;
|
|
1020
1035
|
};
|
|
1021
1036
|
const findSpecialRoute = (routes, pathname, kind) => {
|
|
1022
|
-
const
|
|
1037
|
+
const normalizedPath = normalizeRoutePath(pathname);
|
|
1038
|
+
const matched = matchRoute(routes, normalizedPath);
|
|
1023
1039
|
if (matched?.route[kind]) return matched;
|
|
1040
|
+
const rawPathSegments = normalizedPath.split("/").filter(Boolean);
|
|
1041
|
+
for (let length = rawPathSegments.length - 1; length >= 0; length -= 1) {
|
|
1042
|
+
const candidate = matchRoute(routes, length === 0 ? "/" : `/${rawPathSegments.slice(0, length).join("/")}`);
|
|
1043
|
+
if (candidate?.route[kind]) return candidate;
|
|
1044
|
+
}
|
|
1024
1045
|
let best = null;
|
|
1025
1046
|
let bestScore = -1;
|
|
1026
1047
|
for (const route of routes) {
|
|
@@ -1175,6 +1196,7 @@ const createDevApp = async (init) => {
|
|
|
1175
1196
|
return c.text("Not Found", 404);
|
|
1176
1197
|
};
|
|
1177
1198
|
const renderRouteResponse = async (route, pathname, params, c, modulePath, status = 200, options) => {
|
|
1199
|
+
ensureActionCsrfToken(c);
|
|
1178
1200
|
const [_primedModules, modules, { default: SSRRoot }, { escapeJSONScriptText, getStreamingResumeBootstrapScriptContent, renderSSRStream, resolvePendingLoaders, serializeResumePayload, RESUME_FINAL_STATE_ELEMENT_ID }] = await Promise.all([
|
|
1179
1201
|
Promise.all([fileExists$2(modulePath).then((exists) => exists ? primeCompilerCache(modulePath) : void 0), ...route.layouts.map((layout) => fileExists$2(layout.filePath).then((exists) => exists ? primeCompilerCache(layout.filePath) : void 0))]),
|
|
1180
1202
|
Promise.all([init.runner.import(modulePath), ...route.layouts.map((layout) => init.runner.import(layout.filePath))]),
|
|
@@ -1257,7 +1279,7 @@ const createDevApp = async (init) => {
|
|
|
1257
1279
|
});
|
|
1258
1280
|
const { prefix, suffix } = splitHtmlForStreaming(replaceHeadPlaceholder(replaceHeadPlaceholder(replaceHeadPlaceholder(html, RESUME_PAYLOAD_PLACEHOLDER, serializeAppResumePayload(payload)), ROUTE_MANIFEST_PLACEHOLDER, escapeJSONScriptText(JSON.stringify(routeManifest))), APP_HOOKS_PLACEHOLDER, escapeJSONScriptText(JSON.stringify(appHooksManifest))));
|
|
1259
1281
|
const encoder = new TextEncoder();
|
|
1260
|
-
return new Response(new ReadableStream({ start(controller) {
|
|
1282
|
+
return applyActionCsrfCookie(new Response(new ReadableStream({ start(controller) {
|
|
1261
1283
|
controller.enqueue(encoder.encode(prefix));
|
|
1262
1284
|
(async () => {
|
|
1263
1285
|
let latestPayload = payload;
|
|
@@ -1275,7 +1297,7 @@ const createDevApp = async (init) => {
|
|
|
1275
1297
|
} }), {
|
|
1276
1298
|
status,
|
|
1277
1299
|
headers: { "content-type": "text/html; charset=utf-8" }
|
|
1278
|
-
});
|
|
1300
|
+
}), c);
|
|
1279
1301
|
};
|
|
1280
1302
|
const renderMatchedPage = async (match, c, options) => {
|
|
1281
1303
|
const requestUrl = getRequestUrl(c.req.raw);
|
|
@@ -1354,7 +1376,7 @@ const createDevApp = async (init) => {
|
|
|
1354
1376
|
});
|
|
1355
1377
|
const headers = new Headers(c.req.raw.headers);
|
|
1356
1378
|
headers.set(ROUTE_DATA_REQUEST_HEADER, "1");
|
|
1357
|
-
const response = await app.fetch(new Request(
|
|
1379
|
+
const response = await app.fetch(new Request(createInternalRouteRequestUrl(c.req.raw, targetUrl), {
|
|
1358
1380
|
headers,
|
|
1359
1381
|
method: "GET",
|
|
1360
1382
|
redirect: "manual"
|
|
@@ -1379,19 +1401,11 @@ const createDevApp = async (init) => {
|
|
|
1379
1401
|
if (!resolvePreflightTarget(reroutePathname(new Request(targetUrl.href), normalizeRoutePath(targetUrl.pathname), targetUrl.href))) return c.json({ ok: true });
|
|
1380
1402
|
const headers = new Headers(c.req.raw.headers);
|
|
1381
1403
|
headers.set(ROUTE_PREFLIGHT_REQUEST_HEADER, "1");
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
});
|
|
1388
|
-
} catch {
|
|
1389
|
-
response = await app.fetch(new Request(targetUrl.href, {
|
|
1390
|
-
headers,
|
|
1391
|
-
method: "GET",
|
|
1392
|
-
redirect: "manual"
|
|
1393
|
-
}));
|
|
1394
|
-
}
|
|
1404
|
+
const response = await app.fetch(new Request(createInternalRouteRequestUrl(c.req.raw, targetUrl), {
|
|
1405
|
+
headers,
|
|
1406
|
+
method: "GET",
|
|
1407
|
+
redirect: "manual"
|
|
1408
|
+
}));
|
|
1395
1409
|
if (response.status >= 200 && response.status < 300) return c.json({ ok: true });
|
|
1396
1410
|
if (isRedirectResponse(response)) return c.json({
|
|
1397
1411
|
location: new URL(response.headers.get("location"), requestUrl).href,
|
|
@@ -1948,7 +1962,7 @@ const renderAppModule = (actions, appHooksClientUrl, appHooksServerUrl, loaders,
|
|
|
1948
1962
|
const serializedSymbolUrls = JSON.stringify(symbolUrls);
|
|
1949
1963
|
return `import userApp from "./entries/server_entry.mjs";
|
|
1950
1964
|
import SSRRoot from "./entries/ssr_root.mjs";
|
|
1951
|
-
import { ACTION_CONTENT_TYPE, APP_HOOKS_ELEMENT_ID, Fragment, RESUME_FINAL_STATE_ELEMENT_ID, attachRequestFetch, composeRouteMetadata, createRequestFetch, deserializePublicValue, escapeInlineScriptText, escapeJSONScriptText, executeAction, executeLoader, getActionFormSubmissionId, getNormalizedActionInput, getStreamingResumeBootstrapScriptContent, hasAction, hasLoader, jsxDEV, markPublicError, primeActionState, primeLocationState, renderRouteMetadataHead, renderSSRAsync, renderSSRStream, resolvePendingLoaders, resolveReroute, runHandleError, serializeResumePayload, withServerRequestContext } from "./entries/eclipsa_runtime.mjs";
|
|
1965
|
+
import { ACTION_CONTENT_TYPE, APP_HOOKS_ELEMENT_ID, Fragment, RESUME_FINAL_STATE_ELEMENT_ID, applyActionCsrfCookie, attachRequestFetch, composeRouteMetadata, createRequestFetch, deserializePublicValue, ensureActionCsrfToken, escapeInlineScriptText, escapeJSONScriptText, executeAction, executeLoader, getActionFormSubmissionId, getNormalizedActionInput, getStreamingResumeBootstrapScriptContent, hasAction, hasLoader, jsxDEV, markPublicError, primeActionState, primeLocationState, renderRouteMetadataHead, renderSSRAsync, renderSSRStream, resolvePendingLoaders, resolveReroute, runHandleError, serializeResumePayload, withServerRequestContext } from "./entries/eclipsa_runtime.mjs";
|
|
1952
1966
|
|
|
1953
1967
|
const app = userApp;
|
|
1954
1968
|
const actions = {
|
|
@@ -1991,6 +2005,18 @@ const normalizeRoutePath = (pathname) => {
|
|
|
1991
2005
|
: withLeadingSlash;
|
|
1992
2006
|
};
|
|
1993
2007
|
|
|
2008
|
+
const decodeRoutePathSegment = (segment) => {
|
|
2009
|
+
try {
|
|
2010
|
+
return decodeURIComponent(segment);
|
|
2011
|
+
} catch {
|
|
2012
|
+
return segment;
|
|
2013
|
+
}
|
|
2014
|
+
};
|
|
2015
|
+
|
|
2016
|
+
const splitRawRoutePath = (pathname) => normalizeRoutePath(pathname).split("/").filter(Boolean);
|
|
2017
|
+
|
|
2018
|
+
const splitRoutePath = (pathname) => splitRawRoutePath(pathname).map(decodeRoutePathSegment);
|
|
2019
|
+
|
|
1994
2020
|
const getRequestUrl = (request) => {
|
|
1995
2021
|
const url = new URL(request.url);
|
|
1996
2022
|
const host = request.headers.get("x-forwarded-host") ?? request.headers.get("host");
|
|
@@ -2004,6 +2030,9 @@ const getRequestUrl = (request) => {
|
|
|
2004
2030
|
return url;
|
|
2005
2031
|
};
|
|
2006
2032
|
|
|
2033
|
+
const createInternalRouteRequestUrl = (request, targetUrl) =>
|
|
2034
|
+
new URL(targetUrl.pathname + targetUrl.search, request.url).href;
|
|
2035
|
+
|
|
2007
2036
|
const matchSegments = (segments, pathnameSegments, routeIndex = 0, pathIndex = 0, params = {}) => {
|
|
2008
2037
|
if (routeIndex >= segments.length) {
|
|
2009
2038
|
return pathIndex >= pathnameSegments.length ? params : null;
|
|
@@ -2054,7 +2083,7 @@ const matchSegments = (segments, pathnameSegments, routeIndex = 0, pathIndex = 0
|
|
|
2054
2083
|
};
|
|
2055
2084
|
|
|
2056
2085
|
const matchRoute = (pathname) => {
|
|
2057
|
-
const pathnameSegments =
|
|
2086
|
+
const pathnameSegments = splitRoutePath(pathname);
|
|
2058
2087
|
for (const route of routes) {
|
|
2059
2088
|
const params = matchSegments(route.segments, pathnameSegments);
|
|
2060
2089
|
if (params) {
|
|
@@ -2065,7 +2094,7 @@ const matchRoute = (pathname) => {
|
|
|
2065
2094
|
};
|
|
2066
2095
|
|
|
2067
2096
|
const matchRouteManifestEntry = (pathname) => {
|
|
2068
|
-
const pathnameSegments =
|
|
2097
|
+
const pathnameSegments = splitRoutePath(pathname);
|
|
2069
2098
|
for (const entry of routeManifest) {
|
|
2070
2099
|
const params = matchSegments(entry.segments, pathnameSegments);
|
|
2071
2100
|
if (params) {
|
|
@@ -2121,7 +2150,7 @@ const createChunkCacheRegistrationScript = (pathname, payload) => {
|
|
|
2121
2150
|
};
|
|
2122
2151
|
|
|
2123
2152
|
const scoreSpecialRoute = (route, pathname) => {
|
|
2124
|
-
const pathnameSegments =
|
|
2153
|
+
const pathnameSegments = splitRoutePath(pathname);
|
|
2125
2154
|
let score = 0;
|
|
2126
2155
|
for (let index = 0; index < route.segments.length && index < pathnameSegments.length; index += 1) {
|
|
2127
2156
|
const segment = route.segments[index];
|
|
@@ -2142,11 +2171,21 @@ const scoreSpecialRoute = (route, pathname) => {
|
|
|
2142
2171
|
};
|
|
2143
2172
|
|
|
2144
2173
|
const findSpecialRoute = (pathname, kind) => {
|
|
2145
|
-
const
|
|
2174
|
+
const normalizedPath = normalizeRoutePath(pathname);
|
|
2175
|
+
const matched = matchRoute(normalizedPath);
|
|
2146
2176
|
if (matched?.route[kind]) {
|
|
2147
2177
|
return matched;
|
|
2148
2178
|
}
|
|
2149
2179
|
|
|
2180
|
+
const rawPathSegments = splitRawRoutePath(normalizedPath);
|
|
2181
|
+
for (let length = rawPathSegments.length - 1; length >= 0; length -= 1) {
|
|
2182
|
+
const candidatePath = length === 0 ? "/" : "/" + rawPathSegments.slice(0, length).join("/");
|
|
2183
|
+
const candidate = matchRoute(candidatePath);
|
|
2184
|
+
if (candidate?.route[kind]) {
|
|
2185
|
+
return candidate;
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2150
2189
|
let best = null;
|
|
2151
2190
|
let bestScore = -1;
|
|
2152
2191
|
for (const route of routes) {
|
|
@@ -2468,6 +2507,7 @@ const invokeRouteServer = async (moduleUrl, c, params) => {
|
|
|
2468
2507
|
};
|
|
2469
2508
|
|
|
2470
2509
|
const renderRouteResponse = async (route, pathname, params, c, moduleUrl, status = 200, options) => {
|
|
2510
|
+
ensureActionCsrfToken(c);
|
|
2471
2511
|
const [pageModule, ...layoutModules] = await Promise.all([
|
|
2472
2512
|
import(moduleUrl),
|
|
2473
2513
|
...route.layouts.map((layout) => import(layout)),
|
|
@@ -2575,7 +2615,7 @@ const renderRouteResponse = async (route, pathname, params, c, moduleUrl, status
|
|
|
2575
2615
|
);
|
|
2576
2616
|
const { prefix, suffix } = splitHtmlForStreaming(shellHtml);
|
|
2577
2617
|
const encoder = new TextEncoder();
|
|
2578
|
-
return new Response(
|
|
2618
|
+
return applyActionCsrfCookie(new Response(
|
|
2579
2619
|
new ReadableStream({
|
|
2580
2620
|
start(controller) {
|
|
2581
2621
|
controller.enqueue(encoder.encode(prefix));
|
|
@@ -2614,7 +2654,7 @@ const renderRouteResponse = async (route, pathname, params, c, moduleUrl, status
|
|
|
2614
2654
|
},
|
|
2615
2655
|
status,
|
|
2616
2656
|
},
|
|
2617
|
-
);
|
|
2657
|
+
), c);
|
|
2618
2658
|
};
|
|
2619
2659
|
|
|
2620
2660
|
const renderMatchedPage = async (match, c, options) => {
|
|
@@ -2705,7 +2745,7 @@ const resolveRouteData = async (href, c) => {
|
|
|
2705
2745
|
const headers = new Headers(c.req.raw.headers);
|
|
2706
2746
|
headers.set(ROUTE_DATA_REQUEST_HEADER, "1");
|
|
2707
2747
|
const response = await app.fetch(
|
|
2708
|
-
new Request(
|
|
2748
|
+
new Request(createInternalRouteRequestUrl(c.req.raw, targetUrl), {
|
|
2709
2749
|
headers,
|
|
2710
2750
|
method: "GET",
|
|
2711
2751
|
redirect: "manual",
|
|
@@ -2738,21 +2778,13 @@ const resolveRoutePreflight = async (href, c) => {
|
|
|
2738
2778
|
|
|
2739
2779
|
const headers = new Headers(c.req.raw.headers);
|
|
2740
2780
|
headers.set(ROUTE_PREFLIGHT_REQUEST_HEADER, "1");
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
response = await c.var.fetch(targetUrl.href, {
|
|
2781
|
+
const response = await app.fetch(
|
|
2782
|
+
new Request(createInternalRouteRequestUrl(c.req.raw, targetUrl), {
|
|
2744
2783
|
headers,
|
|
2784
|
+
method: "GET",
|
|
2745
2785
|
redirect: "manual",
|
|
2746
|
-
})
|
|
2747
|
-
|
|
2748
|
-
response = await app.fetch(
|
|
2749
|
-
new Request(targetUrl.href, {
|
|
2750
|
-
headers,
|
|
2751
|
-
method: "GET",
|
|
2752
|
-
redirect: "manual",
|
|
2753
|
-
}),
|
|
2754
|
-
);
|
|
2755
|
-
}
|
|
2786
|
+
}),
|
|
2787
|
+
);
|
|
2756
2788
|
|
|
2757
2789
|
if (response.status >= 200 && response.status < 300) {
|
|
2758
2790
|
return c.json({ ok: true });
|