@funstack/static 0.0.1-alpha.0 → 0.0.2
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/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/build/buildApp.mjs +34 -0
- package/dist/build/buildApp.mjs.map +1 -0
- package/dist/build/contentHash.mjs +14 -0
- package/dist/build/contentHash.mjs.map +1 -0
- package/dist/build/dependencyGraph.mjs +46 -0
- package/dist/build/dependencyGraph.mjs.map +1 -0
- package/dist/build/rscPath.mjs +17 -0
- package/dist/build/rscPath.mjs.map +1 -0
- package/dist/build/rscProcessor.mjs +66 -0
- package/dist/build/rscProcessor.mjs.map +1 -0
- package/dist/client/entry.mjs +53 -0
- package/dist/client/entry.mjs.map +1 -0
- package/dist/client/error-boundary.mjs +48 -0
- package/dist/client/error-boundary.mjs.map +1 -0
- package/dist/client/globals.mjs +10 -0
- package/dist/client/globals.mjs.map +1 -0
- package/dist/entries/client.d.mts +1 -0
- package/dist/entries/client.mjs +3 -0
- package/dist/entries/rsc-client.d.mts +3 -0
- package/dist/entries/rsc-client.mjs +6 -0
- package/dist/entries/rsc.d.mts +3 -0
- package/dist/entries/rsc.mjs +4 -0
- package/dist/entries/server.d.mts +2 -0
- package/dist/entries/server.mjs +3 -0
- package/dist/entries/ssr.d.mts +2 -0
- package/dist/entries/ssr.mjs +3 -0
- package/dist/index.d.mts +2 -30
- package/dist/index.mjs +2 -6082
- package/dist/plugin/getRSCEntryPoint.mjs +16 -0
- package/dist/plugin/getRSCEntryPoint.mjs.map +1 -0
- package/dist/plugin/index.d.mts +30 -0
- package/dist/plugin/index.d.mts.map +1 -0
- package/dist/plugin/index.mjs +61 -0
- package/dist/plugin/index.mjs.map +1 -0
- package/dist/plugin/server.mjs +64 -0
- package/dist/plugin/server.mjs.map +1 -0
- package/dist/rsc/defer.d.mts +50 -0
- package/dist/rsc/defer.d.mts.map +1 -0
- package/dist/rsc/defer.mjs +124 -0
- package/dist/rsc/defer.mjs.map +1 -0
- package/dist/rsc/entry.d.mts +30 -0
- package/dist/rsc/entry.d.mts.map +1 -0
- package/dist/rsc/entry.mjs +94 -0
- package/dist/rsc/entry.mjs.map +1 -0
- package/dist/rsc/marker.mjs +15 -0
- package/dist/rsc/marker.mjs.map +1 -0
- package/dist/rsc/request.mjs +9 -0
- package/dist/rsc/request.mjs.map +1 -0
- package/dist/rsc/rscModule.mjs +25 -0
- package/dist/rsc/rscModule.mjs.map +1 -0
- package/dist/rsc-client/clientWrapper.d.mts +12 -0
- package/dist/rsc-client/clientWrapper.d.mts.map +1 -0
- package/dist/rsc-client/clientWrapper.mjs +44 -0
- package/dist/rsc-client/clientWrapper.mjs.map +1 -0
- package/dist/rsc-client/entry.d.mts +1 -0
- package/dist/rsc-client/entry.mjs +5 -0
- package/dist/ssr/entry.d.mts +15 -0
- package/dist/ssr/entry.d.mts.map +1 -0
- package/dist/ssr/entry.mjs +53 -0
- package/dist/ssr/entry.mjs.map +1 -0
- package/dist/util/basePath.mjs +28 -0
- package/dist/util/basePath.mjs.map +1 -0
- package/dist/util/drainStream.mjs +12 -0
- package/dist/util/drainStream.mjs.map +1 -0
- package/package.json +22 -7
- package/dist/build-BhjMQ5b5.mjs +0 -5
- package/dist/build2-BFobw-wK.mjs +0 -5269
- package/dist/build2-BFobw-wK.mjs.map +0 -1
- package/dist/chunk-CVYhg9ik.mjs +0 -45
- package/dist/chunk-ezxmLbPQ-BTJgBwYB.mjs +0 -29
- package/dist/chunk-ezxmLbPQ-BTJgBwYB.mjs.map +0 -1
- package/dist/chunk-yG6w5hYl.mjs +0 -41
- package/dist/chunk-yG6w5hYl.mjs.map +0 -1
- package/dist/config-ChWWLT6T.mjs +0 -41331
- package/dist/config-ChWWLT6T.mjs.map +0 -1
- package/dist/dist-CijqjcI1.mjs +0 -6699
- package/dist/dist-CijqjcI1.mjs.map +0 -1
- package/dist/false-CW0Ab7Sy.mjs +0 -6
- package/dist/false-CW0Ab7Sy.mjs.map +0 -1
- package/dist/false-CoaQMKhH.mjs +0 -3
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/lib-BY2rcZzh.mjs +0 -366
- package/dist/lib-BY2rcZzh.mjs.map +0 -1
- package/dist/node-entry-Elsz8XBx.mjs +0 -18443
- package/dist/node-entry-Elsz8XBx.mjs.map +0 -1
- package/dist/parseAst-C9pD5vU6.mjs +0 -2109
- package/dist/parseAst-C9pD5vU6.mjs.map +0 -1
- package/dist/picocolors-BxaHL81J-CyL9Yrra.mjs +0 -74
- package/dist/picocolors-BxaHL81J-CyL9Yrra.mjs.map +0 -1
- package/dist/postcss-CQ0jlpM-.mjs +0 -5439
- package/dist/postcss-CQ0jlpM-.mjs.map +0 -1
- package/dist/postcss-import-D8PxJXZF.mjs +0 -452
- package/dist/postcss-import-D8PxJXZF.mjs.map +0 -1
- package/dist/rollup-Cs2z7Zqk.mjs +0 -9
- package/dist/rollup-Cs2z7Zqk.mjs.map +0 -1
- package/dist/watch-70G_ECVN.mjs +0 -7044
- package/dist/watch-70G_ECVN.mjs.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getModulePathFor } from "../rsc/rscModule.mjs";
|
|
2
|
+
import { withBasePath } from "../util/basePath.mjs";
|
|
3
|
+
import { createFromFetch, createFromReadableStream } from "@vitejs/plugin-rsc/browser";
|
|
4
|
+
import React, { createContext, use } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/rsc-client/clientWrapper.tsx
|
|
7
|
+
const RegistryContext = createContext(void 0);
|
|
8
|
+
const ClientWrapper = ({ moduleID }) => {
|
|
9
|
+
const registry = use(RegistryContext);
|
|
10
|
+
const modulePath = getModulePathFor(moduleID);
|
|
11
|
+
if (registry) {
|
|
12
|
+
const entry = registry.load(moduleID);
|
|
13
|
+
if (!entry) throw new Error(`Module entry not found for ID '${moduleID}'`);
|
|
14
|
+
return getRSCStreamFromRegistry(entry);
|
|
15
|
+
}
|
|
16
|
+
return use(getClientRSCStream(withBasePath(modulePath)));
|
|
17
|
+
};
|
|
18
|
+
const moduleToStreamMap = /* @__PURE__ */ new Map();
|
|
19
|
+
async function getRSCStreamFromRegistry(entry) {
|
|
20
|
+
switch (entry.state.state) {
|
|
21
|
+
case "streaming": return createFromReadableStream(entry.state.stream);
|
|
22
|
+
case "ready": {
|
|
23
|
+
const { readable, writable } = new TransformStream();
|
|
24
|
+
const writer = writable.getWriter();
|
|
25
|
+
const encoder = new TextEncoder();
|
|
26
|
+
await writer.write(encoder.encode(entry.state.data));
|
|
27
|
+
await writer.close();
|
|
28
|
+
return createFromReadableStream(readable);
|
|
29
|
+
}
|
|
30
|
+
case "error": return Promise.reject(entry.state.error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function getClientRSCStream(modulePath) {
|
|
34
|
+
let stream = moduleToStreamMap.get(modulePath);
|
|
35
|
+
if (!stream) {
|
|
36
|
+
stream = createFromFetch(fetch(modulePath));
|
|
37
|
+
moduleToStreamMap.set(modulePath, stream);
|
|
38
|
+
}
|
|
39
|
+
return stream;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ClientWrapper, RegistryContext };
|
|
44
|
+
//# sourceMappingURL=clientWrapper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientWrapper.mjs","names":[],"sources":["../../src/rsc-client/clientWrapper.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n createFromFetch,\n createFromReadableStream,\n} from \"@vitejs/plugin-rsc/browser\";\nimport { getModulePathFor } from \"../rsc/rscModule\";\nimport { createContext, use } from \"react\";\nimport type { LoadedDeferEntry, DeferRegistry } from \"../rsc/defer\";\nimport { withBasePath } from \"../util/basePath\";\n\nexport const RegistryContext = createContext<DeferRegistry | undefined>(\n undefined,\n);\n\ninterface ClientWrapperProps {\n moduleID: string;\n}\n\nexport const ClientWrapper: React.FC<ClientWrapperProps> = ({ moduleID }) => {\n const registry = use(RegistryContext);\n const modulePath = getModulePathFor(moduleID);\n if (registry) {\n const entry = registry.load(moduleID);\n if (!entry) {\n throw new Error(`Module entry not found for ID '${moduleID}'`);\n }\n return getRSCStreamFromRegistry(entry);\n }\n const stream = getClientRSCStream(withBasePath(modulePath));\n return use(stream);\n};\n\nconst moduleToStreamMap = new Map<string, Promise<React.ReactNode>>();\n\nasync function getRSCStreamFromRegistry(\n entry: LoadedDeferEntry,\n): Promise<React.ReactNode> {\n switch (entry.state.state) {\n case \"streaming\": {\n return createFromReadableStream<React.ReactNode>(entry.state.stream);\n }\n case \"ready\": {\n const { readable, writable } = new TransformStream<\n Uint8Array,\n Uint8Array\n >();\n const writer = writable.getWriter();\n const encoder = new TextEncoder();\n await writer.write(encoder.encode(entry.state.data));\n await writer.close();\n return createFromReadableStream<React.ReactNode>(readable);\n }\n case \"error\": {\n return Promise.reject(entry.state.error);\n }\n }\n}\n\nfunction getClientRSCStream(modulePath: string) {\n let stream = moduleToStreamMap.get(modulePath);\n if (!stream) {\n stream = createFromFetch<React.ReactNode>(fetch(modulePath));\n moduleToStreamMap.set(modulePath, stream);\n }\n return stream;\n}\n"],"mappings":";;;;;;AAUA,MAAa,kBAAkB,cAC7B,OACD;AAMD,MAAa,iBAA+C,EAAE,eAAe;CAC3E,MAAM,WAAW,IAAI,gBAAgB;CACrC,MAAM,aAAa,iBAAiB,SAAS;AAC7C,KAAI,UAAU;EACZ,MAAM,QAAQ,SAAS,KAAK,SAAS;AACrC,MAAI,CAAC,MACH,OAAM,IAAI,MAAM,kCAAkC,SAAS,GAAG;AAEhE,SAAO,yBAAyB,MAAM;;AAGxC,QAAO,IADQ,mBAAmB,aAAa,WAAW,CAAC,CACzC;;AAGpB,MAAM,oCAAoB,IAAI,KAAuC;AAErE,eAAe,yBACb,OAC0B;AAC1B,SAAQ,MAAM,MAAM,OAApB;EACE,KAAK,YACH,QAAO,yBAA0C,MAAM,MAAM,OAAO;EAEtE,KAAK,SAAS;GACZ,MAAM,EAAE,UAAU,aAAa,IAAI,iBAGhC;GACH,MAAM,SAAS,SAAS,WAAW;GACnC,MAAM,UAAU,IAAI,aAAa;AACjC,SAAM,OAAO,MAAM,QAAQ,OAAO,MAAM,MAAM,KAAK,CAAC;AACpD,SAAM,OAAO,OAAO;AACpB,UAAO,yBAA0C,SAAS;;EAE5D,KAAK,QACH,QAAO,QAAQ,OAAO,MAAM,MAAM,MAAM;;;AAK9C,SAAS,mBAAmB,YAAoB;CAC9C,IAAI,SAAS,kBAAkB,IAAI,WAAW;AAC9C,KAAI,CAAC,QAAQ;AACX,WAAS,gBAAiC,MAAM,WAAW,CAAC;AAC5D,oBAAkB,IAAI,YAAY,OAAO;;AAE3C,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { ClientWrapper, RegistryContext } from "./clientWrapper.mjs";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DeferRegistry } from "../rsc/defer.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/ssr/entry.d.ts
|
|
4
|
+
declare function renderHTML(rscStream: ReadableStream<Uint8Array>, options: {
|
|
5
|
+
appEntryMarker: string;
|
|
6
|
+
build: boolean;
|
|
7
|
+
nonce?: string;
|
|
8
|
+
deferRegistry?: DeferRegistry;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
stream: ReadableStream<Uint8Array>;
|
|
11
|
+
status?: number;
|
|
12
|
+
}>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { renderHTML };
|
|
15
|
+
//# sourceMappingURL=entry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.mts","names":[],"sources":["../../src/ssr/entry.tsx"],"sourcesContent":[],"mappings":";;;iBAWsB,UAAA,YACT,eAAe;;EADN,KAAA,EAAA,OAAU;EACJ,KAAA,CAAA,EAAA,MAAA;EAAf,aAAA,CAAA,EAKO,aALP;CAKO,CAAA,EAEjB,OAFiB,CAAA;EAEgB,MAAA,EAAf,cAAe,CAAA,UAAA,CAAA;EAAf,MAAA,CAAA,EAAA,MAAA;CAAlB,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { rscPayloadPlaceholder } from "../build/rscPath.mjs";
|
|
2
|
+
import { appClientManifestVar } from "../client/globals.mjs";
|
|
3
|
+
import { use } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { RegistryContext } from "#rsc-client";
|
|
6
|
+
import { createFromReadableStream } from "@vitejs/plugin-rsc/ssr";
|
|
7
|
+
import { renderToReadableStream } from "react-dom/server.edge";
|
|
8
|
+
import { injectRSCPayload } from "rsc-html-stream/server";
|
|
9
|
+
import { preload } from "react-dom";
|
|
10
|
+
|
|
11
|
+
//#region src/ssr/entry.tsx
|
|
12
|
+
async function renderHTML(rscStream, options) {
|
|
13
|
+
const [rscStream1, rscStream2] = rscStream.tee();
|
|
14
|
+
let payload;
|
|
15
|
+
function SsrRoot() {
|
|
16
|
+
payload ??= createFromReadableStream(rscStream1);
|
|
17
|
+
if (options.build) preload(rscPayloadPlaceholder, {
|
|
18
|
+
crossOrigin: "anonymous",
|
|
19
|
+
as: "fetch"
|
|
20
|
+
});
|
|
21
|
+
return /* @__PURE__ */ jsx(RegistryContext, {
|
|
22
|
+
value: options.deferRegistry,
|
|
23
|
+
children: use(payload).root
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
let bootstrapScriptContent = "";
|
|
27
|
+
if (options.build) bootstrapScriptContent += `globalThis.${appClientManifestVar}={marker:"${options.appEntryMarker}",stream:"${rscPayloadPlaceholder}"};\n`;
|
|
28
|
+
bootstrapScriptContent += await import.meta.viteRsc.loadBootstrapScriptContent("index");
|
|
29
|
+
let htmlStream;
|
|
30
|
+
let status;
|
|
31
|
+
try {
|
|
32
|
+
htmlStream = await renderToReadableStream(/* @__PURE__ */ jsx(SsrRoot, {}), {
|
|
33
|
+
bootstrapScriptContent,
|
|
34
|
+
nonce: options?.nonce
|
|
35
|
+
});
|
|
36
|
+
} catch (e) {
|
|
37
|
+
status = 500;
|
|
38
|
+
htmlStream = await renderToReadableStream(/* @__PURE__ */ jsx("html", { children: /* @__PURE__ */ jsx("body", { children: /* @__PURE__ */ jsx("noscript", { children: "Internal Server Error: SSR failed" }) }) }), {
|
|
39
|
+
bootstrapScriptContent: `globalThis.__NO_HYDRATE=1;` + bootstrapScriptContent,
|
|
40
|
+
nonce: options?.nonce
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
let responseStream = htmlStream;
|
|
44
|
+
if (!options.build) responseStream = responseStream.pipeThrough(injectRSCPayload(rscStream2, { nonce: options?.nonce }));
|
|
45
|
+
return {
|
|
46
|
+
stream: responseStream,
|
|
47
|
+
status
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { renderHTML };
|
|
53
|
+
//# sourceMappingURL=entry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.mjs","names":[],"sources":["../../src/ssr/entry.tsx"],"sourcesContent":["import { createFromReadableStream } from \"@vitejs/plugin-rsc/ssr\";\nimport { use } from \"react\";\nimport { renderToReadableStream } from \"react-dom/server.edge\";\nimport { injectRSCPayload } from \"rsc-html-stream/server\";\nimport type { RscPayload } from \"../rsc/entry\";\nimport { appClientManifestVar } from \"../client/globals\";\nimport { rscPayloadPlaceholder } from \"../build/rscPath\";\nimport { preload } from \"react-dom\";\nimport type { DeferRegistry } from \"../rsc/defer\";\nimport { RegistryContext } from \"#rsc-client\";\n\nexport async function renderHTML(\n rscStream: ReadableStream<Uint8Array>,\n options: {\n appEntryMarker: string;\n build: boolean;\n nonce?: string;\n deferRegistry?: DeferRegistry;\n },\n): Promise<{ stream: ReadableStream<Uint8Array>; status?: number }> {\n const [rscStream1, rscStream2] = rscStream.tee();\n\n let payload: Promise<RscPayload> | undefined;\n function SsrRoot() {\n // Tip: calling `createFromReadableStream` inside a component\n // makes `preinit`/`preload` work properly.\n payload ??= createFromReadableStream<RscPayload>(rscStream1);\n if (options.build) {\n preload(rscPayloadPlaceholder, {\n crossOrigin: \"anonymous\",\n as: \"fetch\",\n });\n }\n return (\n <RegistryContext value={options.deferRegistry}>\n {use(payload).root}\n </RegistryContext>\n );\n }\n\n let bootstrapScriptContent: string = \"\";\n if (options.build) {\n bootstrapScriptContent += `globalThis.${appClientManifestVar}={marker:\"${options.appEntryMarker}\",stream:\"${rscPayloadPlaceholder}\"};\\n`;\n }\n bootstrapScriptContent +=\n await import.meta.viteRsc.loadBootstrapScriptContent(\"index\");\n\n let htmlStream: ReadableStream<Uint8Array>;\n let status: number | undefined;\n try {\n htmlStream = await renderToReadableStream(<SsrRoot />, {\n bootstrapScriptContent,\n nonce: options?.nonce,\n });\n } catch (e) {\n // In this case, RSC payload is still sent to client and we let client render from scratch anyway.\n // This triggers the error boundary on client side.\n status = 500;\n htmlStream = await renderToReadableStream(\n <html>\n <body>\n <noscript>Internal Server Error: SSR failed</noscript>\n </body>\n </html>,\n {\n bootstrapScriptContent:\n `globalThis.__NO_HYDRATE=1;` + bootstrapScriptContent,\n nonce: options?.nonce,\n },\n );\n }\n\n let responseStream = htmlStream;\n\n if (!options.build) {\n responseStream = responseStream.pipeThrough(\n injectRSCPayload(rscStream2, {\n nonce: options?.nonce,\n }),\n );\n }\n\n return { stream: responseStream, status };\n}\n"],"mappings":";;;;;;;;;;;AAWA,eAAsB,WACpB,WACA,SAMkE;CAClE,MAAM,CAAC,YAAY,cAAc,UAAU,KAAK;CAEhD,IAAI;CACJ,SAAS,UAAU;AAGjB,cAAY,yBAAqC,WAAW;AAC5D,MAAI,QAAQ,MACV,SAAQ,uBAAuB;GAC7B,aAAa;GACb,IAAI;GACL,CAAC;AAEJ,SACE,oBAAC;GAAgB,OAAO,QAAQ;aAC7B,IAAI,QAAQ,CAAC;IACE;;CAItB,IAAI,yBAAiC;AACrC,KAAI,QAAQ,MACV,2BAA0B,cAAc,qBAAqB,YAAY,QAAQ,eAAe,YAAY,sBAAsB;AAEpI,2BACE,MAAM,OAAO,KAAK,QAAQ,2BAA2B,QAAQ;CAE/D,IAAI;CACJ,IAAI;AACJ,KAAI;AACF,eAAa,MAAM,uBAAuB,oBAAC,YAAU,EAAE;GACrD;GACA,OAAO,SAAS;GACjB,CAAC;UACK,GAAG;AAGV,WAAS;AACT,eAAa,MAAM,uBACjB,oBAAC,oBACC,oBAAC,oBACC,oBAAC,wBAAS,sCAA4C,GACjD,GACF,EACP;GACE,wBACE,+BAA+B;GACjC,OAAO,SAAS;GACjB,CACF;;CAGH,IAAI,iBAAiB;AAErB,KAAI,CAAC,QAAQ,MACX,kBAAiB,eAAe,YAC9B,iBAAiB,YAAY,EAC3B,OAAO,SAAS,OACjB,CAAC,CACH;AAGH,QAAO;EAAE,QAAQ;EAAgB;EAAQ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/util/basePath.ts
|
|
2
|
+
/**
|
|
3
|
+
* Strips the base path from a pathname if present.
|
|
4
|
+
* Used on server-side to normalize incoming request paths.
|
|
5
|
+
*/
|
|
6
|
+
function stripBasePath(pathname) {
|
|
7
|
+
const base = import.meta.env.BASE_URL;
|
|
8
|
+
if (base === "/") return pathname;
|
|
9
|
+
const normalizedBase = base.endsWith("/") ? base.slice(0, -1) : base;
|
|
10
|
+
if (pathname.startsWith(normalizedBase)) {
|
|
11
|
+
const stripped = pathname.slice(normalizedBase.length);
|
|
12
|
+
return stripped.startsWith("/") ? stripped : "/" + stripped;
|
|
13
|
+
}
|
|
14
|
+
return pathname;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Prepends the base path to a path.
|
|
18
|
+
* Used on client-side when making fetch requests.
|
|
19
|
+
*/
|
|
20
|
+
function withBasePath(path) {
|
|
21
|
+
const base = import.meta.env.BASE_URL;
|
|
22
|
+
if (base === "/") return path;
|
|
23
|
+
return (base.endsWith("/") ? base.slice(0, -1) : base) + path;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { stripBasePath, withBasePath };
|
|
28
|
+
//# sourceMappingURL=basePath.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basePath.mjs","names":[],"sources":["../../src/util/basePath.ts"],"sourcesContent":["/**\n * Strips the base path from a pathname if present.\n * Used on server-side to normalize incoming request paths.\n */\nexport function stripBasePath(pathname: string): string {\n const base = import.meta.env.BASE_URL;\n if (base === \"/\") return pathname;\n // Handle base with or without trailing slash\n const normalizedBase = base.endsWith(\"/\") ? base.slice(0, -1) : base;\n if (pathname.startsWith(normalizedBase)) {\n const stripped = pathname.slice(normalizedBase.length);\n return stripped.startsWith(\"/\") ? stripped : \"/\" + stripped;\n }\n return pathname;\n}\n\n/**\n * Prepends the base path to a path.\n * Used on client-side when making fetch requests.\n */\nexport function withBasePath(path: string): string {\n const base = import.meta.env.BASE_URL;\n if (base === \"/\") return path;\n const normalizedBase = base.endsWith(\"/\") ? base.slice(0, -1) : base;\n return normalizedBase + path;\n}\n"],"mappings":";;;;;AAIA,SAAgB,cAAc,UAA0B;CACtD,MAAM,OAAO,OAAO,KAAK,IAAI;AAC7B,KAAI,SAAS,IAAK,QAAO;CAEzB,MAAM,iBAAiB,KAAK,SAAS,IAAI,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG;AAChE,KAAI,SAAS,WAAW,eAAe,EAAE;EACvC,MAAM,WAAW,SAAS,MAAM,eAAe,OAAO;AACtD,SAAO,SAAS,WAAW,IAAI,GAAG,WAAW,MAAM;;AAErD,QAAO;;;;;;AAOT,SAAgB,aAAa,MAAsB;CACjD,MAAM,OAAO,OAAO,KAAK,IAAI;AAC7B,KAAI,SAAS,IAAK,QAAO;AAEzB,SADuB,KAAK,SAAS,IAAI,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,QACxC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/util/drainStream.ts
|
|
2
|
+
async function drainStream(stream) {
|
|
3
|
+
const decoder = new TextDecoder();
|
|
4
|
+
const chunks = [];
|
|
5
|
+
for await (const chunk of stream) chunks.push(decoder.decode(chunk, { stream: true }));
|
|
6
|
+
chunks.push(decoder.decode());
|
|
7
|
+
return chunks.join("");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { drainStream };
|
|
12
|
+
//# sourceMappingURL=drainStream.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drainStream.mjs","names":[],"sources":["../../src/util/drainStream.ts"],"sourcesContent":["export async function drainStream(\n stream: ReadableStream<Uint8Array>,\n): Promise<string> {\n const decoder = new TextDecoder();\n const chunks = [];\n for await (const chunk of stream) {\n chunks.push(decoder.decode(chunk, { stream: true }));\n }\n chunks.push(decoder.decode());\n return chunks.join(\"\");\n}\n"],"mappings":";AAAA,eAAsB,YACpB,QACiB;CACjB,MAAM,UAAU,IAAI,aAAa;CACjC,MAAM,SAAS,EAAE;AACjB,YAAW,MAAM,SAAS,OACxB,QAAO,KAAK,QAAQ,OAAO,OAAO,EAAE,QAAQ,MAAM,CAAC,CAAC;AAEtD,QAAO,KAAK,QAAQ,QAAQ,CAAC;AAC7B,QAAO,OAAO,KAAK,GAAG"}
|
package/package.json
CHANGED
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funstack/static",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "FUNSTACK static library",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/uhyo/funstack-static.git",
|
|
9
|
+
"directory": "packages/static"
|
|
10
|
+
},
|
|
6
11
|
"exports": {
|
|
7
12
|
".": {
|
|
8
13
|
"types": "./dist/index.d.mts",
|
|
9
14
|
"import": "./dist/index.mjs"
|
|
10
15
|
},
|
|
16
|
+
"./server": {
|
|
17
|
+
"types": "./dist/entries/server.d.mts",
|
|
18
|
+
"import": "./dist/entries/server.mjs"
|
|
19
|
+
},
|
|
11
20
|
"./entries/*": "./dist/entries/*.mjs"
|
|
12
21
|
},
|
|
22
|
+
"imports": {
|
|
23
|
+
"#rsc-client": {
|
|
24
|
+
"types": "./src/entries/rsc-client.ts",
|
|
25
|
+
"default": "./dist/entries/rsc-client.mjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
13
28
|
"files": [
|
|
14
29
|
"dist"
|
|
15
30
|
],
|
|
16
31
|
"author": "uhyo <uhyo@uhy.ooo>",
|
|
17
32
|
"license": "MIT",
|
|
18
33
|
"devDependencies": {
|
|
19
|
-
"@types/node": "^25.0.
|
|
34
|
+
"@types/node": "^25.0.9",
|
|
20
35
|
"@types/react": "^19.2.8",
|
|
21
36
|
"@types/react-dom": "^19.2.3",
|
|
22
37
|
"jsdom": "^27.3.0",
|
|
23
38
|
"react": "^19.2.3",
|
|
24
39
|
"react-dom": "^19.2.3",
|
|
25
|
-
"tsdown": "^0.
|
|
26
|
-
"typescript": "^5.
|
|
40
|
+
"tsdown": "^0.19.0",
|
|
41
|
+
"typescript": "^5.9.3",
|
|
27
42
|
"vite": "^7.3.1",
|
|
28
|
-
"vitest": "^4.0.
|
|
43
|
+
"vitest": "^4.0.17"
|
|
29
44
|
},
|
|
30
45
|
"dependencies": {
|
|
31
|
-
"@vitejs/plugin-rsc": "^0.5.
|
|
32
|
-
"react-error-boundary": "^6.0
|
|
46
|
+
"@vitejs/plugin-rsc": "^0.5.14",
|
|
47
|
+
"react-error-boundary": "^6.1.0",
|
|
33
48
|
"rsc-html-stream": "^0.0.7",
|
|
34
49
|
"srvx": "^0.10.0"
|
|
35
50
|
},
|