@ossido-labs/ossido 0.1.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/LICENSE +21 -0
- package/README.md +28 -0
- package/bin/build-config.js +5 -0
- package/bin/build-prod.js +5 -0
- package/bin/dev-ssr.js +5 -0
- package/bin/run-build-hook.js +6 -0
- package/bin/watch.js +5 -0
- package/dist/esm/build/config/create-json-config.d.ts +10 -0
- package/dist/esm/build/config/create-json-config.js +52 -0
- package/dist/esm/build/config/create-json-config.js.map +1 -0
- package/dist/esm/build/config/index.d.ts +2 -0
- package/dist/esm/build/config/load-config.d.ts +2 -0
- package/dist/esm/build/config/load-config.js +20 -0
- package/dist/esm/build/config/load-config.js.map +1 -0
- package/dist/esm/build/config/normalize-config.d.ts +10 -0
- package/dist/esm/build/config/normalize-config.js +75 -0
- package/dist/esm/build/config/normalize-config.js.map +1 -0
- package/dist/esm/build/constants.d.ts +5 -0
- package/dist/esm/build/constants.js +10 -0
- package/dist/esm/build/constants.js.map +1 -0
- package/dist/esm/build/index.d.ts +15 -0
- package/dist/esm/build/index.js +245 -0
- package/dist/esm/build/index.js.map +1 -0
- package/dist/esm/build/logger.d.ts +11 -0
- package/dist/esm/build/logger.js +76 -0
- package/dist/esm/build/logger.js.map +1 -0
- package/dist/esm/build/types.d.ts +29 -0
- package/dist/esm/build/utils.d.ts +6 -0
- package/dist/esm/build/utils.js +40 -0
- package/dist/esm/build/utils.js.map +1 -0
- package/dist/esm/build-client/index.d.ts +1 -0
- package/dist/esm/build-client/index.js +1 -0
- package/dist/esm/client/index.d.ts +92 -0
- package/dist/esm/client/index.js +38 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/config/index.d.ts +1 -0
- package/dist/esm/config/index.js +0 -0
- package/dist/esm/config/types.d.ts +130 -0
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.js +6 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/hydration/browserLogForwarding.d.ts +7 -0
- package/dist/esm/hydration/browserLogForwarding.js +152 -0
- package/dist/esm/hydration/browserLogForwarding.js.map +1 -0
- package/dist/esm/hydration/index.d.ts +4 -0
- package/dist/esm/hydration/index.js +24 -0
- package/dist/esm/hydration/index.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/shared/DevResources.d.ts +7 -0
- package/dist/esm/shared/DevResources.js +45 -0
- package/dist/esm/shared/DevResources.js.map +1 -0
- package/dist/esm/shared/OssidoContext.d.ts +14 -0
- package/dist/esm/shared/OssidoContext.js +28 -0
- package/dist/esm/shared/OssidoContext.js.map +1 -0
- package/dist/esm/shared/OssidoEntryPoint.d.ts +11 -0
- package/dist/esm/shared/OssidoEntryPoint.js +17 -0
- package/dist/esm/shared/OssidoEntryPoint.js.map +1 -0
- package/dist/esm/shared/OssidoScripts.d.ts +2 -0
- package/dist/esm/shared/OssidoScripts.js +34 -0
- package/dist/esm/shared/OssidoScripts.js.map +1 -0
- package/dist/esm/shared/ProdResources.d.ts +7 -0
- package/dist/esm/shared/ProdResources.js +18 -0
- package/dist/esm/shared/ProdResources.js.map +1 -0
- package/dist/esm/shared/RouterContextProviderWrapper.d.ts +14 -0
- package/dist/esm/shared/RouterContextProviderWrapper.js +27 -0
- package/dist/esm/shared/RouterContextProviderWrapper.js.map +1 -0
- package/dist/esm/shared/dynamic/RouteLazyLoading.d.ts +6 -0
- package/dist/esm/shared/dynamic/RouteLazyLoading.js +20 -0
- package/dist/esm/shared/dynamic/RouteLazyLoading.js.map +1 -0
- package/dist/esm/shared/dynamic/dynamic.d.ts +15 -0
- package/dist/esm/shared/dynamic/dynamic.js +57 -0
- package/dist/esm/shared/dynamic/dynamic.js.map +1 -0
- package/dist/esm/shared/dynamic/index.d.ts +2 -0
- package/dist/esm/shared/ossido-context.d.ts +22 -0
- package/dist/esm/shared/ossido-context.js +22 -0
- package/dist/esm/shared/ossido-context.js.map +1 -0
- package/dist/esm/shared/routeHot.d.ts +10 -0
- package/dist/esm/shared/routeHot.js +20 -0
- package/dist/esm/shared/routeHot.js.map +1 -0
- package/dist/esm/ssr/index.d.ts +4 -0
- package/dist/esm/ssr/index.js +6 -0
- package/dist/esm/ssr/polyfills/Event.d.ts +18 -0
- package/dist/esm/ssr/polyfills/Event.js +24 -0
- package/dist/esm/ssr/polyfills/Event.js.map +1 -0
- package/dist/esm/ssr/polyfills/MessageChannel.d.ts +19 -0
- package/dist/esm/ssr/polyfills/MessageChannel.js +50 -0
- package/dist/esm/ssr/polyfills/MessageChannel.js.map +1 -0
- package/dist/esm/ssr/polyfills/MessageEvent.d.ts +12 -0
- package/dist/esm/ssr/polyfills/MessageEvent.js +20 -0
- package/dist/esm/ssr/polyfills/MessageEvent.js.map +1 -0
- package/dist/esm/ssr/polyfills/globalScope.d.ts +30 -0
- package/dist/esm/ssr/polyfills/globalScope.js +5 -0
- package/dist/esm/ssr/polyfills/globalScope.js.map +1 -0
- package/dist/esm/ssr/server.d.ts +40 -0
- package/dist/esm/ssr/server.js +61 -0
- package/dist/esm/ssr/server.js.map +1 -0
- package/dist/esm/ssr/utils.d.ts +19 -0
- package/dist/esm/ssr/utils.js +78 -0
- package/dist/esm/ssr/utils.js.map +1 -0
- package/dist/esm/types.d.ts +34 -0
- package/package.json +110 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserLogForwarding.js","names":[],"sources":["../../../src/hydration/browserLogForwarding.ts"],"sourcesContent":["/**\n * Dev-only: forward browser `console.*` (and uncaught errors) to the Ossido dev\n * server console, where they are printed tagged `[FE]`. The server applies the\n * `logging.browser` level/enabled config. The original console output is kept\n * intact.\n */\n\ninterface ForwardedError {\n name: string;\n message: string;\n stack: Array<string>;\n}\n\ninterface ForwardedEntry {\n level: string;\n message: string;\n error?: ForwardedError;\n /** A client-side navigation event (rather than a `console.*` call). */\n navigation?: boolean;\n /** For a navigation that loaded data: the data response's HTTP status. */\n status?: number;\n /** For a navigation that loaded data: how long the load took, in ms. */\n durationMs?: number;\n}\n\nconst CONSOLE_METHODS = [\n 'log',\n 'info',\n 'warn',\n 'error',\n 'debug',\n 'trace',\n] as const;\n\nconst LOGS_ENDPOINT = '/__ossido/logs';\n// A route's server data is loaded from `/__ossido/data{pathname}{searchStr}`, so\n// the request URL encodes the navigation path — that's how a data load is\n// correlated back to the navigation that triggered it.\nconst DATA_ROUTE_PREFIX = '/__ossido/data';\nconst FLUSH_DELAY_MS = 60;\nconst MAX_FRAMES = 6;\n// Cap the in-flight/recent data-load map so an un-consumed entry (e.g. an error\n// retry that refetches without navigating) can't grow it without bound.\nconst MAX_TRACKED_DATA_LOADS = 50;\n\n/** The outcome of a route's data fetch, correlated to a navigation by path. */\ninterface NavDataLoad {\n status: number;\n durationMs: number;\n}\n\n/** Mirror the backend's status→level mapping so a failed data load stands out. */\nfunction levelForStatus(status: number): string {\n if (status >= 500) return 'error';\n if (status >= 400) return 'warn';\n return 'info';\n}\n\nfunction formatArg(arg: unknown): string {\n if (typeof arg === 'string') return arg;\n if (arg instanceof Error) return `${arg.name}: ${arg.message}`;\n if (arg === undefined) return 'undefined';\n try {\n return JSON.stringify(arg);\n } catch {\n return String(arg);\n }\n}\n\n/** Tidy a browser stack: drop the leading `Name: message` line, trim frames and\n * strip the dev-server origin so paths read like the project source. */\nfunction cleanStack(stack: string | undefined): Array<string> {\n if (!stack) return [];\n const origin = typeof location !== 'undefined' ? location.origin : '';\n return stack\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.startsWith('at ') || line.includes('@'))\n .map((line) =>\n line.replaceAll(`${origin}/`, '').replaceAll('vite-server/', ''),\n )\n .slice(0, MAX_FRAMES);\n}\n\nfunction toEntry(level: string, args: ReadonlyArray<unknown>): ForwardedEntry {\n const message = args.map(formatArg).join(' ');\n const errorArg = args.find((arg): arg is Error => arg instanceof Error);\n const error = errorArg\n ? {\n name: errorArg.name,\n message: errorArg.message,\n stack: cleanStack(errorArg.stack),\n }\n : undefined;\n return { level, message, error };\n}\n\nlet installed = false;\n\nexport function installBrowserLogForwarding(): void {\n if (installed || typeof window === 'undefined') return;\n installed = true;\n\n const queue: Array<ForwardedEntry> = [];\n let scheduled = false;\n\n const flush = (): void => {\n scheduled = false;\n if (queue.length === 0) return;\n const body = JSON.stringify(queue.splice(0, queue.length));\n // A typed Blob makes `sendBeacon` post `application/json` (it defaults to\n // `text/plain`). `sendBeacon` is fire-and-forget and survives page unload;\n // fall back to a keepalive fetch when unavailable or when it rejects.\n const blob = new Blob([body], { type: 'application/json' });\n if (!navigator.sendBeacon?.(LOGS_ENDPOINT, blob)) {\n void fetch(LOGS_ENDPOINT, {\n method: 'POST',\n body,\n headers: { 'Content-Type': 'application/json' },\n keepalive: true,\n }).catch(() => undefined);\n }\n };\n\n const schedule = (): void => {\n if (scheduled) return;\n scheduled = true;\n setTimeout(flush, FLUSH_DELAY_MS);\n };\n\n const enqueue = (level: string, args: ReadonlyArray<unknown>): void => {\n try {\n queue.push(toEntry(level, args));\n schedule();\n } catch {\n // Never let forwarding break the console.\n }\n };\n\n // Curried wrapper: `level -> original console method -> forwarding method`.\n // The wrapped method logs as usual, then forwards the call to the server.\n const withForwarding =\n (level: string) =>\n (original: (...args: Array<unknown>) => void) =>\n (...args: Array<unknown>): void => {\n original(...args);\n enqueue(level, args);\n };\n\n for (const method of CONSOLE_METHODS) {\n console[method] = withForwarding(method)(console[method].bind(console));\n }\n\n window.addEventListener('error', (event) => {\n enqueue('error', [event.error ?? event.message]);\n });\n window.addEventListener('unhandledrejection', (event) => {\n enqueue('error', [event.reason]);\n });\n\n // Observe route data loads so a navigation's log line can carry the load's\n // status + duration (mirroring the backend request log). Keyed by the\n // navigation path — the `/__ossido/data{path}` URL encodes it — and consumed by\n // the matching navigation report.\n const dataLoads = new Map<string, Promise<NavDataLoad | null>>();\n const originalFetch =\n typeof window.fetch === 'function' ? window.fetch.bind(window) : undefined;\n if (originalFetch) {\n window.fetch = (\n input: RequestInfo | URL,\n init?: RequestInit,\n ): Promise<Response> => {\n const request = originalFetch(input, init);\n try {\n const raw =\n typeof input === 'string'\n ? input\n : input instanceof URL\n ? input.href\n : input.url;\n const { pathname, search } = new URL(raw, location.origin);\n if (pathname.startsWith(DATA_ROUTE_PREFIX)) {\n // Strip the prefix to recover the navigation path (`pathname+search`).\n const navPath =\n pathname.slice(DATA_ROUTE_PREFIX.length) + search || '/';\n const start = performance.now();\n if (dataLoads.size >= MAX_TRACKED_DATA_LOADS) {\n const oldest = dataLoads.keys().next().value;\n if (oldest !== undefined) dataLoads.delete(oldest);\n }\n dataLoads.set(\n navPath,\n request.then(\n (res) => ({\n status: res.status,\n durationMs: performance.now() - start,\n }),\n () => null,\n ),\n );\n }\n } catch {\n // Correlation is best-effort; never let it interfere with the fetch.\n }\n return request;\n };\n }\n\n // Report client-side navigations so the dev server logs them too. The router\n // commits every navigation via history.pushState/replaceState; back/forward\n // fire popstate. (The initial load is a normal request the server already\n // logs, and does not go through these.)\n const emitNavigation = async (): Promise<void> => {\n try {\n const path = window.location.pathname + window.location.search;\n const load = dataLoads.get(path);\n dataLoads.delete(path);\n const timing = load ? await load : null;\n queue.push(\n timing\n ? {\n level: levelForStatus(timing.status),\n message: path,\n navigation: true,\n status: timing.status,\n durationMs: timing.durationMs,\n }\n : { level: 'info', message: path, navigation: true },\n );\n schedule();\n } catch {\n // Never let reporting break navigation.\n }\n };\n\n // Defer via a microtask so the router's own popstate handler (which starts the\n // data fetch) has run before we correlate — the fetch is then already tracked.\n const reportNavigation = (): void => {\n queueMicrotask(() => {\n void emitNavigation();\n });\n };\n\n const patchHistory = (method: 'pushState' | 'replaceState'): void => {\n const original = history[method].bind(history);\n history[method] = (...args: Parameters<History['pushState']>): void => {\n original(...args);\n reportNavigation();\n };\n };\n patchHistory('pushState');\n patchHistory('replaceState');\n window.addEventListener('popstate', reportNavigation);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SERVER_PAYLOAD_VARIABLE_NAME } from "../constants.js";
|
|
2
|
+
import { OssidoEntryPoint } from "../shared/OssidoEntryPoint.js";
|
|
3
|
+
import { installBrowserLogForwarding } from "./browserLogForwarding.js";
|
|
4
|
+
import { createRouter, preloadRouteChain } from "@ossido-labs/ossido-router";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { hydrateRoot } from "react-dom/client";
|
|
7
|
+
import { warmDevErrorSource } from "@ossido-labs/ossido-ui";
|
|
8
|
+
|
|
9
|
+
//#region src/hydration/index.tsx
|
|
10
|
+
function hydrate(routeTree) {
|
|
11
|
+
if (window["__OSSIDO_SERVER_PAYLOAD__"]?.mode === "Dev") {
|
|
12
|
+
installBrowserLogForwarding();
|
|
13
|
+
warmDevErrorSource();
|
|
14
|
+
}
|
|
15
|
+
const router = createRouter({ routeTree });
|
|
16
|
+
const initialPathname = window["__OSSIDO_SERVER_PAYLOAD__"]?.location?.pathname ?? window.location.pathname;
|
|
17
|
+
preloadRouteChain(router, initialPathname).finally(() => {
|
|
18
|
+
hydrateRoot(document, /* @__PURE__ */ jsx(OssidoEntryPoint, { router }));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { hydrate };
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hydration/index.tsx"],"sourcesContent":["import { hydrateRoot } from 'react-dom/client';\nimport { createRouter, preloadRouteChain } from '@ossido-labs/ossido-router';\nimport type { createRoute } from '@ossido-labs/ossido-router';\nimport { warmDevErrorSource } from '@ossido-labs/ossido-ui';\n\nimport { OssidoEntryPoint } from '../shared/OssidoEntryPoint';\nimport { SERVER_PAYLOAD_VARIABLE_NAME } from '../constants';\n\nimport { installBrowserLogForwarding } from './browserLogForwarding';\n\ntype RouteTree = ReturnType<typeof createRoute>;\n\nexport function hydrate(routeTree: RouteTree): void {\n // In development, mirror the browser console into the dev server console and\n // prefetch the error-overlay's source-highlighting libraries up front (not on\n // first error), so a highlighted excerpt is ready the moment one is needed.\n if (window[SERVER_PAYLOAD_VARIABLE_NAME]?.mode === 'Dev') {\n installBrowserLogForwarding();\n warmDevErrorSource();\n }\n\n // Create a new router instance\n const router = createRouter({ routeTree });\n\n // Load the matched route's code (page + wrapping layouts) BEFORE hydrating:\n // the server preloads the same chain and renders the page content inline, so\n // the first client render must also resolve it synchronously — hydrating\n // while the `React.lazy` chunk is still loading would mismatch that HTML.\n const initialPathname =\n window[SERVER_PAYLOAD_VARIABLE_NAME]?.location?.pathname ??\n window.location.pathname;\n void preloadRouteChain(router, initialPathname).finally(() => {\n hydrateRoot(document, <OssidoEntryPoint router={router} />);\n });\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,QAAQ,WAA4B;CAIlD,IAAI,mCAAoC,EAAE,SAAS,OAAO;EACxD,4BAA4B;EAC5B,mBAAmB;CACrB;CAGA,MAAM,SAAS,aAAa,EAAE,UAAU,CAAC;CAMzC,MAAM,kBACJ,mCAAoC,EAAE,UAAU,YAChD,OAAO,SAAS;CAClB,AAAK,kBAAkB,QAAQ,eAAe,CAAC,CAAC,cAAc;EAC5D,YAAY,UAAU,oBAAC,kBAAD,EAA0B,OAAS,EAAC;CAC5D,CAAC;AACH"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createRoute, createRootRoute, createRouter, Link, useRouter, } from '@ossido-labs/ossido-router';
|
|
2
|
+
export type { OssidoErrorProps } from '@ossido-labs/ossido-router';
|
|
3
|
+
export { dynamic, RouteLazyLoading as __ossido__internal__lazyLoadRoute, } from './shared/dynamic';
|
|
4
|
+
export { __ossido__internal__applyRouteHot } from './shared/routeHot';
|
|
5
|
+
export { OssidoScripts } from './shared/OssidoScripts';
|
|
6
|
+
export type { OssidoLayoutProps } from './types';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { dynamic } from "./shared/dynamic/dynamic.js";
|
|
2
|
+
import { RouteLazyLoading } from "./shared/dynamic/RouteLazyLoading.js";
|
|
3
|
+
import { __ossido__internal__applyRouteHot } from "./shared/routeHot.js";
|
|
4
|
+
import { OssidoScripts } from "./shared/OssidoScripts.js";
|
|
5
|
+
import { Link, createRootRoute, createRoute, createRouter, useRouter } from "@ossido-labs/ossido-router";
|
|
6
|
+
|
|
7
|
+
export { Link, OssidoScripts, __ossido__internal__applyRouteHot, RouteLazyLoading as __ossido__internal__lazyLoadRoute, createRootRoute, createRoute, createRouter, dynamic, useRouter };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { OssidoConfigServer } from '../config';
|
|
3
|
+
interface DevResourcesProps {
|
|
4
|
+
devServerConfig?: OssidoConfigServer;
|
|
5
|
+
}
|
|
6
|
+
export declare const DevResources: ({ devServerConfig, }: DevResourcesProps) => JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/DevResources.tsx
|
|
4
|
+
const DEFAULT_SERVER_CONFIG = {
|
|
5
|
+
host: "localhost",
|
|
6
|
+
origin: null,
|
|
7
|
+
port: 3e3
|
|
8
|
+
};
|
|
9
|
+
const VITE_PROXY_PATH = "/vite-server";
|
|
10
|
+
const DevResources = ({ devServerConfig }) => {
|
|
11
|
+
const { host, origin, port } = devServerConfig ?? DEFAULT_SERVER_CONFIG;
|
|
12
|
+
const viteBaseUrl = origin != null ? `${origin}${VITE_PROXY_PATH}` : `http://${host}:${port}${VITE_PROXY_PATH}`;
|
|
13
|
+
/**
|
|
14
|
+
* These scripts must execute in order: the react-refresh preamble has to run
|
|
15
|
+
* (and set `__vite_plugin_react_preamble_installed__`) before `client-main`
|
|
16
|
+
* loads any React component, otherwise `@vitejs/plugin-react-swc` throws
|
|
17
|
+
* "can't detect preamble". `type="module"` already defers execution without
|
|
18
|
+
* blocking parsing, so `async` only removes the ordering guarantee and must
|
|
19
|
+
* NOT be used here — it caused an intermittent preamble race.
|
|
20
|
+
*/
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22
|
+
/* @__PURE__ */ jsx("script", {
|
|
23
|
+
type: "module",
|
|
24
|
+
children: [
|
|
25
|
+
`import RefreshRuntime from '${viteBaseUrl}/@react-refresh'`,
|
|
26
|
+
"RefreshRuntime.injectIntoGlobalHook(window)",
|
|
27
|
+
"window.$RefreshReg$ = () => {}",
|
|
28
|
+
"window.$RefreshSig$ = () => (type) => type",
|
|
29
|
+
"window.__vite_plugin_react_preamble_installed__ = true"
|
|
30
|
+
].join("\n")
|
|
31
|
+
}),
|
|
32
|
+
/* @__PURE__ */ jsx("script", {
|
|
33
|
+
type: "module",
|
|
34
|
+
src: `${viteBaseUrl}/@vite/client`
|
|
35
|
+
}),
|
|
36
|
+
/* @__PURE__ */ jsx("script", {
|
|
37
|
+
type: "module",
|
|
38
|
+
src: `${viteBaseUrl}/client-main.tsx`
|
|
39
|
+
})
|
|
40
|
+
] });
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { DevResources };
|
|
45
|
+
//# sourceMappingURL=DevResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevResources.js","names":[],"sources":["../../../src/shared/DevResources.tsx"],"sourcesContent":["import type { JSX } from 'react';\n\nimport type { OssidoConfigServer } from '../config';\n\nconst DEFAULT_SERVER_CONFIG = { host: 'localhost', origin: null, port: 3000 };\nconst VITE_PROXY_PATH = '/vite-server';\n\ninterface DevResourcesProps {\n devServerConfig?: OssidoConfigServer;\n}\n\nexport const DevResources = ({\n devServerConfig,\n}: DevResourcesProps): JSX.Element => {\n const { host, origin, port } = devServerConfig ?? DEFAULT_SERVER_CONFIG;\n\n const viteBaseUrl =\n origin != null\n ? `${origin}${VITE_PROXY_PATH}`\n : `http://${host}:${port}${VITE_PROXY_PATH}`;\n\n /**\n * These scripts must execute in order: the react-refresh preamble has to run\n * (and set `__vite_plugin_react_preamble_installed__`) before `client-main`\n * loads any React component, otherwise `@vitejs/plugin-react-swc` throws\n * \"can't detect preamble\". `type=\"module\"` already defers execution without\n * blocking parsing, so `async` only removes the ordering guarantee and must\n * NOT be used here — it caused an intermittent preamble race.\n */\n return (\n <>\n <script type=\"module\">\n {[\n `import RefreshRuntime from '${viteBaseUrl}/@react-refresh'`,\n 'RefreshRuntime.injectIntoGlobalHook(window)',\n 'window.$RefreshReg$ = () => {}',\n 'window.$RefreshSig$ = () => (type) => type',\n 'window.__vite_plugin_react_preamble_installed__ = true',\n ].join('\\n')}\n </script>\n <script type=\"module\" src={`${viteBaseUrl}/@vite/client`}></script>\n <script type=\"module\" src={`${viteBaseUrl}/client-main.tsx`}></script>\n </>\n );\n};\n"],"mappings":";;;AAIA,MAAM,wBAAwB;CAAE,MAAM;CAAa,QAAQ;CAAM,MAAM;AAAK;AAC5E,MAAM,kBAAkB;AAMxB,MAAa,gBAAgB,EAC3B,sBACoC;CACpC,MAAM,EAAE,MAAM,QAAQ,SAAS,mBAAmB;CAElD,MAAM,cACJ,UAAU,OACN,GAAG,SAAS,oBACZ,UAAU,KAAK,GAAG,OAAO;;;;;;;;;CAU/B,OACE;EACE,oBAAC,UAAD;GAAQ,MAAK;aACV;IACC,+BAA+B,YAAY;IAC3C;IACA;IACA;IACA;GACF,CAAC,CAAC,KAAK,IAAI;EACL;EACR,oBAAC,UAAD;GAAQ,MAAK;GAAS,KAAK,GAAG,YAAY;EAAwB;EAClE,oBAAC,UAAD;GAAQ,MAAK;GAAS,KAAK,GAAG,YAAY;EAA2B;CACrE;AAEN"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
import type { ServerPayload } from '../types';
|
|
3
|
+
interface OssidoContextProviderProps {
|
|
4
|
+
serverPayload?: ServerPayload;
|
|
5
|
+
rawServerPayload?: string;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @warning THIS SHOULD NOT BE EXPOSED TO USERLAND
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/tuono-labs/tuono/issues/410
|
|
12
|
+
*/
|
|
13
|
+
export declare function OssidoContextProvider({ serverPayload, rawServerPayload, children, }: OssidoContextProviderProps): JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SERVER_PAYLOAD_VARIABLE_NAME } from "../constants.js";
|
|
2
|
+
import { OssidoContext } from "./ossido-context.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/shared/OssidoContext.tsx
|
|
7
|
+
const isServerSide = typeof window === "undefined";
|
|
8
|
+
/**
|
|
9
|
+
* @warning THIS SHOULD NOT BE EXPOSED TO USERLAND
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/tuono-labs/tuono/issues/410
|
|
12
|
+
*/
|
|
13
|
+
function OssidoContextProvider({ serverPayload, rawServerPayload, children }) {
|
|
14
|
+
const contextValue = useMemo(() => {
|
|
15
|
+
return {
|
|
16
|
+
serverPayload: isServerSide ? serverPayload : window[SERVER_PAYLOAD_VARIABLE_NAME],
|
|
17
|
+
rawServerPayload
|
|
18
|
+
};
|
|
19
|
+
}, [serverPayload, rawServerPayload]);
|
|
20
|
+
return /* @__PURE__ */ jsx(OssidoContext, {
|
|
21
|
+
value: contextValue,
|
|
22
|
+
children
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { OssidoContextProvider };
|
|
28
|
+
//# sourceMappingURL=OssidoContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OssidoContext.js","names":[],"sources":["../../../src/shared/OssidoContext.tsx"],"sourcesContent":["import type { JSX, ReactNode } from 'react';\nimport { useMemo } from 'react';\n\nimport type { ServerPayload } from '../types';\nimport { SERVER_PAYLOAD_VARIABLE_NAME } from '../constants';\n\nimport { OssidoContext, type OssidoContextValue } from './ossido-context';\n\nconst isServerSide = typeof window === 'undefined';\n\ninterface OssidoContextProviderProps {\n serverPayload?: ServerPayload;\n rawServerPayload?: string;\n\n children: ReactNode;\n}\n\n/**\n * @warning THIS SHOULD NOT BE EXPOSED TO USERLAND\n *\n * @see https://github.com/tuono-labs/tuono/issues/410\n */\nexport function OssidoContextProvider({\n serverPayload,\n rawServerPayload,\n children,\n}: OssidoContextProviderProps): JSX.Element {\n const contextValue: OssidoContextValue = useMemo(() => {\n // At least one of these two should be defined\n const _serverPayload = (\n isServerSide ? serverPayload : window[SERVER_PAYLOAD_VARIABLE_NAME]\n ) as ServerPayload;\n\n return {\n // Maybe this logic should be integrated using defaults\n serverPayload: _serverPayload,\n rawServerPayload,\n };\n }, [serverPayload, rawServerPayload]);\n\n return <OssidoContext value={contextValue}>{children}</OssidoContext>;\n}\n"],"mappings":";;;;;;AAQA,MAAM,eAAe,OAAO,WAAW;;;;;;AAcvC,SAAgB,sBAAsB,EACpC,eACA,kBACA,YAC0C;CAC1C,MAAM,eAAmC,cAAc;EAMrD,OAAO;GAEL,eALA,eAAe,gBAAgB,OAAO;GAMtC;EACF;CACF,GAAG,CAAC,eAAe,gBAAgB,CAAC;CAEpC,OAAO,oBAAC,eAAD;EAAe,OAAO;EAAe;CAAwB;AACtE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { RouterInstanceType } from '@ossido-labs/ossido-router';
|
|
3
|
+
import type { ServerPayload } from '../types';
|
|
4
|
+
interface OssidoEntryPointProps {
|
|
5
|
+
router: RouterInstanceType;
|
|
6
|
+
serverPayload?: ServerPayload;
|
|
7
|
+
/** The raw payload JSON (server render only) — see {@link OssidoContext}. */
|
|
8
|
+
rawServerPayload?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function OssidoEntryPoint({ router, serverPayload, rawServerPayload, }: OssidoEntryPointProps): JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OssidoContextProvider } from "./OssidoContext.js";
|
|
2
|
+
import { RouterContextProviderWrapper } from "./RouterContextProviderWrapper.js";
|
|
3
|
+
import { StrictMode } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/shared/OssidoEntryPoint.tsx
|
|
7
|
+
function OssidoEntryPoint({ router, serverPayload, rawServerPayload }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(OssidoContextProvider, {
|
|
9
|
+
serverPayload,
|
|
10
|
+
rawServerPayload,
|
|
11
|
+
children: /* @__PURE__ */ jsx(RouterContextProviderWrapper, { router })
|
|
12
|
+
}) });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { OssidoEntryPoint };
|
|
17
|
+
//# sourceMappingURL=OssidoEntryPoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OssidoEntryPoint.js","names":[],"sources":["../../../src/shared/OssidoEntryPoint.tsx"],"sourcesContent":["import { StrictMode } from 'react';\nimport type { JSX } from 'react';\nimport type { RouterInstanceType } from '@ossido-labs/ossido-router';\n\nimport type { ServerPayload } from '../types';\n\nimport { OssidoContextProvider } from './OssidoContext';\nimport { RouterContextProviderWrapper } from './RouterContextProviderWrapper';\n\ninterface OssidoEntryPointProps {\n router: RouterInstanceType;\n serverPayload?: ServerPayload;\n /** The raw payload JSON (server render only) — see {@link OssidoContext}. */\n rawServerPayload?: string;\n}\n\nexport function OssidoEntryPoint({\n router,\n serverPayload,\n rawServerPayload,\n}: OssidoEntryPointProps): JSX.Element {\n return (\n <StrictMode>\n <OssidoContextProvider\n serverPayload={serverPayload}\n rawServerPayload={rawServerPayload}\n >\n <RouterContextProviderWrapper router={router} />\n </OssidoContextProvider>\n </StrictMode>\n );\n}\n"],"mappings":";;;;;;AAgBA,SAAgB,iBAAiB,EAC/B,QACA,eACA,oBACqC;CACrC,OACE,oBAAC,YAAD,YACE,oBAAC,uBAAD;EACiB;EACG;YAElB,oBAAC,8BAAD,EAAsC,OAAS;CAC1B,GACb;AAEhB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SERVER_PAYLOAD_VARIABLE_NAME } from "../constants.js";
|
|
2
|
+
import { DevResources } from "./DevResources.js";
|
|
3
|
+
import { ProdResources } from "./ProdResources.js";
|
|
4
|
+
import { useOssidoContextRawServerPayload, useOssidoContextServerPayload } from "./ossido-context.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/shared/OssidoScripts.tsx
|
|
8
|
+
/**
|
|
9
|
+
* The payload is embedded as a JS expression inside a `<script>`, so a string
|
|
10
|
+
* value containing `<\/script>` (or `<!--`) could otherwise break out of the tag.
|
|
11
|
+
* Escaping `<` to its unicode form neutralises that while remaining valid JSON.
|
|
12
|
+
*/
|
|
13
|
+
function escapeForScript(json) {
|
|
14
|
+
return json.replace(/</g, "\\u003c");
|
|
15
|
+
}
|
|
16
|
+
function OssidoScripts() {
|
|
17
|
+
const serverPayload = useOssidoContextServerPayload();
|
|
18
|
+
const payloadJson = useOssidoContextRawServerPayload() ?? JSON.stringify(serverPayload);
|
|
19
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20
|
+
/* @__PURE__ */ jsx("script", {
|
|
21
|
+
suppressHydrationWarning: true,
|
|
22
|
+
dangerouslySetInnerHTML: { __html: `window['${SERVER_PAYLOAD_VARIABLE_NAME}']=${escapeForScript(payloadJson)}` }
|
|
23
|
+
}),
|
|
24
|
+
serverPayload.mode === "Dev" && /* @__PURE__ */ jsx(DevResources, { devServerConfig: serverPayload.devServerConfig }),
|
|
25
|
+
serverPayload.mode === "Prod" && /* @__PURE__ */ jsx(ProdResources, {
|
|
26
|
+
jsBundles: serverPayload.jsBundles,
|
|
27
|
+
cssBundles: serverPayload.cssBundles
|
|
28
|
+
})
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { OssidoScripts };
|
|
34
|
+
//# sourceMappingURL=OssidoScripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OssidoScripts.js","names":[],"sources":["../../../src/shared/OssidoScripts.tsx"],"sourcesContent":["import type { JSX } from 'react';\n\nimport { SERVER_PAYLOAD_VARIABLE_NAME } from '../constants';\n\nimport { DevResources } from './DevResources';\nimport { ProdResources } from './ProdResources';\nimport {\n useOssidoContextRawServerPayload,\n useOssidoContextServerPayload,\n} from './ossido-context';\n\n/**\n * The payload is embedded as a JS expression inside a `<script>`, so a string\n * value containing `</script>` (or `<!--`) could otherwise break out of the tag.\n * Escaping `<` to its unicode form neutralises that while remaining valid JSON.\n */\nfunction escapeForScript(json: string): string {\n return json.replace(/</g, '\\\\u003c');\n}\n\nexport function OssidoScripts(): JSX.Element {\n const serverPayload = useOssidoContextServerPayload();\n const rawServerPayload = useOssidoContextRawServerPayload();\n\n // On the server, reuse the exact JSON the Rust runtime already produced —\n // avoiding a second full `JSON.stringify` of the payload inside V8. On the\n // client the raw string isn't available, so fall back to stringifying the\n // parsed payload; that output is discarded during hydration\n // (`suppressHydrationWarning` keeps the server-rendered script, which has\n // already executed and set `window[...]`).\n const payloadJson = rawServerPayload ?? JSON.stringify(serverPayload);\n\n return (\n <>\n <script\n suppressHydrationWarning\n dangerouslySetInnerHTML={{\n __html: `window['${SERVER_PAYLOAD_VARIABLE_NAME}']=${escapeForScript(payloadJson)}`,\n }}\n />\n {serverPayload.mode === 'Dev' && (\n <DevResources devServerConfig={serverPayload.devServerConfig} />\n )}\n {serverPayload.mode === 'Prod' && (\n <ProdResources\n jsBundles={serverPayload.jsBundles}\n cssBundles={serverPayload.cssBundles}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAS,gBAAgB,MAAsB;CAC7C,OAAO,KAAK,QAAQ,MAAM,SAAS;AACrC;AAEA,SAAgB,gBAA6B;CAC3C,MAAM,gBAAgB,8BAA8B;CASpD,MAAM,cARmB,iCAQU,KAAK,KAAK,UAAU,aAAa;CAEpE,OACE;EACE,oBAAC,UAAD;GACE;GACA,yBAAyB,EACvB,QAAQ,WAAW,6BAA6B,KAAK,gBAAgB,WAAW,IAClF;EACD;EACA,cAAc,SAAS,SACtB,oBAAC,cAAD,EAAc,iBAAiB,cAAc,gBAAkB;EAEhE,cAAc,SAAS,UACtB,oBAAC,eAAD;GACE,WAAW,cAAc;GACzB,YAAY,cAAc;EAC3B;CAEH;AAEN"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/ProdResources.tsx
|
|
4
|
+
const ProdResources = ({ cssBundles, jsBundles }) => {
|
|
5
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [cssBundles?.map((cssHref) => /* @__PURE__ */ jsx("link", {
|
|
6
|
+
rel: "stylesheet",
|
|
7
|
+
precedence: "high",
|
|
8
|
+
type: "text/css",
|
|
9
|
+
href: `/${cssHref}`
|
|
10
|
+
}, cssHref)), jsBundles?.map((scriptSrc) => /* @__PURE__ */ jsx("script", {
|
|
11
|
+
type: "module",
|
|
12
|
+
src: `/${scriptSrc}`
|
|
13
|
+
}, scriptSrc))] });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ProdResources };
|
|
18
|
+
//# sourceMappingURL=ProdResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProdResources.js","names":[],"sources":["../../../src/shared/ProdResources.tsx"],"sourcesContent":["import type { JSX } from 'react';\n\ninterface ProdResourcesProps {\n jsBundles: Array<string> | null;\n cssBundles: Array<string> | null;\n}\n\nexport const ProdResources = ({\n cssBundles,\n jsBundles,\n}: ProdResourcesProps): JSX.Element => {\n return (\n <>\n {cssBundles?.map((cssHref) => (\n <link\n key={cssHref}\n rel=\"stylesheet\"\n precedence=\"high\"\n type=\"text/css\"\n href={`/${cssHref}`}\n />\n ))}\n\n {jsBundles?.map((scriptSrc) => (\n <script key={scriptSrc} type=\"module\" src={`/${scriptSrc}`}></script>\n ))}\n </>\n );\n};\n"],"mappings":";;;AAOA,MAAa,iBAAiB,EAC5B,YACA,gBACqC;CACrC,OACE,4CACG,YAAY,KAAK,YAChB,oBAAC,QAAD;EAEE,KAAI;EACJ,YAAW;EACX,MAAK;EACL,MAAM,IAAI;CACX,GALM,OAKN,CACF,GAEA,WAAW,KAAK,cACf,oBAAC,UAAD;EAAwB,MAAK;EAAS,KAAK,IAAI;CAAqB,GAAvD,SAAuD,CACrE,CACD;AAEN"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { RouterInstanceType } from '@ossido-labs/ossido-router';
|
|
3
|
+
interface RouterContextProviderWrapperProps {
|
|
4
|
+
router: RouterInstanceType;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* This component is needed to get the data from {@link OssidoContext}
|
|
8
|
+
* since the provider is also located in {@link OssidoEntryPoint}
|
|
9
|
+
* hence the context cannot be accessed directly there
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/tuono-labs/tuono/issues/410
|
|
12
|
+
*/
|
|
13
|
+
export declare function RouterContextProviderWrapper({ router, }: RouterContextProviderWrapperProps): JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useOssidoContextServerPayload } from "./ossido-context.js";
|
|
2
|
+
import { RouterProvider } from "@ossido-labs/ossido-router";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/shared/RouterContextProviderWrapper.tsx
|
|
6
|
+
/**
|
|
7
|
+
* This component is needed to get the data from {@link OssidoContext}
|
|
8
|
+
* since the provider is also located in {@link OssidoEntryPoint}
|
|
9
|
+
* hence the context cannot be accessed directly there
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/tuono-labs/tuono/issues/410
|
|
12
|
+
*/
|
|
13
|
+
function RouterContextProviderWrapper({ router }) {
|
|
14
|
+
const serverPayload = useOssidoContextServerPayload();
|
|
15
|
+
return /* @__PURE__ */ jsx(RouterProvider, {
|
|
16
|
+
router,
|
|
17
|
+
serverInitialLocation: serverPayload.location,
|
|
18
|
+
serverInitialData: serverPayload.data,
|
|
19
|
+
serverInitialLayoutData: serverPayload.layoutData,
|
|
20
|
+
serverInitialError: serverPayload.serverError,
|
|
21
|
+
mode: serverPayload.mode
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { RouterContextProviderWrapper };
|
|
27
|
+
//# sourceMappingURL=RouterContextProviderWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterContextProviderWrapper.js","names":[],"sources":["../../../src/shared/RouterContextProviderWrapper.tsx"],"sourcesContent":["import type { JSX } from 'react';\nimport { RouterProvider } from '@ossido-labs/ossido-router';\nimport type { RouterInstanceType } from '@ossido-labs/ossido-router';\n\nimport { useOssidoContextServerPayload } from './ossido-context';\n\ninterface RouterContextProviderWrapperProps {\n router: RouterInstanceType;\n}\n\n/**\n * This component is needed to get the data from {@link OssidoContext}\n * since the provider is also located in {@link OssidoEntryPoint}\n * hence the context cannot be accessed directly there\n *\n * @see https://github.com/tuono-labs/tuono/issues/410\n */\nexport function RouterContextProviderWrapper({\n router,\n}: RouterContextProviderWrapperProps): JSX.Element {\n const serverPayload = useOssidoContextServerPayload();\n\n return (\n <RouterProvider\n router={router}\n serverInitialLocation={serverPayload.location}\n serverInitialData={serverPayload.data}\n serverInitialLayoutData={serverPayload.layoutData}\n serverInitialError={serverPayload.serverError}\n // Read `mode` from the payload context (available on server AND client);\n // the client `hydrateRoot` passes no `serverPayload` prop, so a prop-based\n // mode would be `undefined` during hydration.\n mode={serverPayload.mode}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAgB,6BAA6B,EAC3C,UACiD;CACjD,MAAM,gBAAgB,8BAA8B;CAEpD,OACE,oBAAC,gBAAD;EACU;EACR,uBAAuB,cAAc;EACrC,mBAAmB,cAAc;EACjC,yBAAyB,cAAc;EACvC,oBAAoB,cAAc;EAIlC,MAAM,cAAc;CACrB;AAEL"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createElement, lazy } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/dynamic/RouteLazyLoading.tsx
|
|
4
|
+
const RouteLazyLoading = (factory) => {
|
|
5
|
+
let LoadedComponent;
|
|
6
|
+
const LazyComponent = lazy(factory);
|
|
7
|
+
const loadComponent = () => factory().then((module) => {
|
|
8
|
+
LoadedComponent = module.default;
|
|
9
|
+
});
|
|
10
|
+
const Component = (props) => createElement(LoadedComponent || LazyComponent, props);
|
|
11
|
+
Component.preload = loadComponent;
|
|
12
|
+
if (import.meta.env.DEV) Component.update = (next) => {
|
|
13
|
+
LoadedComponent = next;
|
|
14
|
+
};
|
|
15
|
+
return Component;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { RouteLazyLoading };
|
|
20
|
+
//# sourceMappingURL=RouteLazyLoading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouteLazyLoading.js","names":[],"sources":["../../../../src/shared/dynamic/RouteLazyLoading.tsx"],"sourcesContent":["import { lazy, createElement } from 'react';\nimport type { ReactElement } from 'react';\n\nimport type { RouteComponent } from '@ossido-labs/ossido-router';\n\ntype ImportFn = () => Promise<{ default: RouteComponent }>;\n\nexport const RouteLazyLoading = (factory: ImportFn): RouteComponent => {\n let LoadedComponent: RouteComponent | undefined;\n const LazyComponent = lazy<RouteComponent>(factory);\n\n const loadComponent = (): Promise<void> =>\n factory().then((module) => {\n LoadedComponent = module.default;\n });\n\n const Component = (\n props: React.ComponentProps<RouteComponent>,\n ): ReactElement => createElement(LoadedComponent || LazyComponent, props);\n\n Component.preload = loadComponent;\n\n // Dev-only: HMR swaps the resolved component in place when a route-module edit\n // breaks React Fast Refresh (otherwise vite escalates to a full page reload).\n // The generated route tree calls this from its `import.meta.hot.accept`\n // handler; a router re-render then renders the new component. Absent in prod.\n if (import.meta.env.DEV) {\n Component.update = (next: RouteComponent): void => {\n LoadedComponent = next;\n };\n }\n\n return Component;\n};\n"],"mappings":";;;AAOA,MAAa,oBAAoB,YAAsC;CACrE,IAAI;CACJ,MAAM,gBAAgB,KAAqB,OAAO;CAElD,MAAM,sBACJ,QAAQ,CAAC,CAAC,MAAM,WAAW;EACzB,kBAAkB,OAAO;CAC3B,CAAC;CAEH,MAAM,aACJ,UACiB,cAAc,mBAAmB,eAAe,KAAK;CAExE,UAAU,UAAU;CAMpB,IAAI,YAAY,IAAI,KAClB,UAAU,UAAU,SAA+B;EACjD,kBAAkB;CACpB;CAGF,OAAO;AACT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
interface ComponentModule<T> {
|
|
3
|
+
default: React.ComponentType<T>;
|
|
4
|
+
}
|
|
5
|
+
interface DynamicOptions {
|
|
6
|
+
ssr?: boolean;
|
|
7
|
+
loading?: React.ComponentType<unknown> | null;
|
|
8
|
+
}
|
|
9
|
+
type Loader<T = object> = () => Promise<React.ComponentType<T> | ComponentModule<T>>;
|
|
10
|
+
/**
|
|
11
|
+
* This function lets you dynamically import a component.
|
|
12
|
+
* It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood.
|
|
13
|
+
*/
|
|
14
|
+
export declare function dynamic<T = object>(importFn: Loader<T>, opts?: DynamicOptions): ComponentType<T>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Fragment, Suspense, lazy } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/shared/dynamic/dynamic.tsx
|
|
5
|
+
/**
|
|
6
|
+
* This component is heavily inspired by Next.js dynamic function
|
|
7
|
+
* Link: https://github.com/vercel/next.js/blob/1df81bcea62800198884438a2bb27ba14c9d506a/packages/next/src/shared/lib/dynamic.tsx
|
|
8
|
+
*/
|
|
9
|
+
const isServerSide = typeof window === "undefined";
|
|
10
|
+
const defaultLoaderOptions = {
|
|
11
|
+
ssr: true,
|
|
12
|
+
loading: null,
|
|
13
|
+
loader: () => Promise.resolve(() => null)
|
|
14
|
+
};
|
|
15
|
+
function noSSR(LoadableInitializer, loadableOptions) {
|
|
16
|
+
if (!isServerSide) return LoadableInitializer(loadableOptions);
|
|
17
|
+
if (!loadableOptions.loading) return () => null;
|
|
18
|
+
const Loading = loadableOptions.loading;
|
|
19
|
+
function NoSSRLoading() {
|
|
20
|
+
return /* @__PURE__ */ jsx(Loading, {});
|
|
21
|
+
}
|
|
22
|
+
return NoSSRLoading;
|
|
23
|
+
}
|
|
24
|
+
function Loadable(options) {
|
|
25
|
+
const opts = {
|
|
26
|
+
...defaultLoaderOptions,
|
|
27
|
+
...options
|
|
28
|
+
};
|
|
29
|
+
const Lazy = lazy(() => opts.loader().then());
|
|
30
|
+
const Loading = opts.loading;
|
|
31
|
+
function LoadableComponent(props) {
|
|
32
|
+
return /* @__PURE__ */ jsx(Loading ? Suspense : Fragment, {
|
|
33
|
+
...Loading ? { fallback: Loading ? /* @__PURE__ */ jsx(Loading, {}) : null } : {},
|
|
34
|
+
children: /* @__PURE__ */ jsx(Lazy, { ...props })
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
LoadableComponent.displayName = "LoadableComponent";
|
|
38
|
+
return LoadableComponent;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* This function lets you dynamically import a component.
|
|
42
|
+
* It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood.
|
|
43
|
+
*/
|
|
44
|
+
function dynamic(importFn, opts) {
|
|
45
|
+
if (typeof opts?.ssr === "boolean" && !opts.ssr) return noSSR(Loadable, {
|
|
46
|
+
...opts,
|
|
47
|
+
loader: importFn
|
|
48
|
+
});
|
|
49
|
+
return Loadable({
|
|
50
|
+
...opts,
|
|
51
|
+
loader: importFn
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { dynamic };
|
|
57
|
+
//# sourceMappingURL=dynamic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic.js","names":[],"sources":["../../../../src/shared/dynamic/dynamic.tsx"],"sourcesContent":["/**\n * This component is heavily inspired by Next.js dynamic function\n * Link: https://github.com/vercel/next.js/blob/1df81bcea62800198884438a2bb27ba14c9d506a/packages/next/src/shared/lib/dynamic.tsx\n */\n// This module is a dynamic-import HOC factory: it defines internal components\n// and exports `dynamic` (which returns a component). There is no top-level\n// component here whose state a hot reload would drop, so the Fast Refresh\n// boundary rule doesn't apply.\n/* eslint-disable react-refresh/only-export-components */\nimport { lazy, Suspense, Fragment } from 'react';\nimport type { ComponentType } from 'react';\n\nconst isServerSide = typeof window === 'undefined';\n\ninterface ComponentModule<T> {\n default: React.ComponentType<T>;\n}\n\ninterface DynamicOptions {\n ssr?: boolean;\n loading?: React.ComponentType<unknown> | null;\n}\n\ntype Loader<T = object> = () => Promise<\n React.ComponentType<T> | ComponentModule<T>\n>;\n\ninterface LoadableOptions<T> extends DynamicOptions {\n loader: Loader<T>;\n}\n\ntype LoadableFn = <T = object>(options: LoadableOptions<T>) => ComponentType<T>;\n\nconst defaultLoaderOptions: LoadableOptions<object> = {\n ssr: true,\n loading: null,\n loader: () => Promise.resolve(() => null),\n};\n\nfunction noSSR<T = object>(\n LoadableInitializer: LoadableFn,\n loadableOptions: LoadableOptions<T>,\n): React.ComponentType<T> {\n if (!isServerSide) {\n return LoadableInitializer(loadableOptions);\n }\n\n if (!loadableOptions.loading) return () => null;\n\n const Loading = loadableOptions.loading;\n // This will only be rendered on the server side\n function NoSSRLoading(): React.JSX.Element {\n return <Loading />;\n }\n return NoSSRLoading;\n}\n\nfunction Loadable<T = object>(options: LoadableOptions<T>): ComponentType<T> {\n const opts = { ...defaultLoaderOptions, ...options };\n const Lazy = lazy(() => opts.loader().then());\n const Loading = opts.loading;\n\n function LoadableComponent(props: T): React.JSX.Element {\n const fallbackElement = Loading ? <Loading /> : null;\n\n const Wrap = Loading ? Suspense : Fragment;\n const wrapProps = Loading ? { fallback: fallbackElement } : {};\n\n // TODO: In case ssr = false handle also the assets preloading\n return (\n <Wrap {...wrapProps}>\n <Lazy {...props} />\n </Wrap>\n );\n }\n LoadableComponent.displayName = 'LoadableComponent';\n\n return LoadableComponent;\n}\n\n/**\n * This function lets you dynamically import a component.\n * It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood.\n */\nexport function dynamic<T = object>(\n importFn: Loader<T>,\n opts?: DynamicOptions,\n): ComponentType<T> {\n if (typeof opts?.ssr === 'boolean' && !opts.ssr) {\n return noSSR<T>(Loadable, { ...opts, loader: importFn });\n }\n return Loadable<T>({ ...opts, loader: importFn });\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,eAAe,OAAO,WAAW;AAqBvC,MAAM,uBAAgD;CACpD,KAAK;CACL,SAAS;CACT,cAAc,QAAQ,cAAc,IAAI;AAC1C;AAEA,SAAS,MACP,qBACA,iBACwB;CACxB,IAAI,CAAC,cACH,OAAO,oBAAoB,eAAe;CAG5C,IAAI,CAAC,gBAAgB,SAAS,aAAa;CAE3C,MAAM,UAAU,gBAAgB;CAEhC,SAAS,eAAkC;EACzC,OAAO,oBAAC,SAAD,CAAU;CACnB;CACA,OAAO;AACT;AAEA,SAAS,SAAqB,SAA+C;CAC3E,MAAM,OAAO;EAAE,GAAG;EAAsB,GAAG;CAAQ;CACnD,MAAM,OAAO,WAAW,KAAK,OAAO,CAAC,CAAC,KAAK,CAAC;CAC5C,MAAM,UAAU,KAAK;CAErB,SAAS,kBAAkB,OAA6B;EAOtD,OACE,oBALW,UAAU,WAAW,UAKhC;GAAM,GAJU,UAAU,EAAE,UAHN,UAAU,oBAAC,SAAD,CAAU,KAAI,KAGQ,IAAI,CAAC;aAKzD,oBAAC,MAAD,EAAM,GAAI,MAAQ;EACd;CAEV;CACA,kBAAkB,cAAc;CAEhC,OAAO;AACT;;;;;AAMA,SAAgB,QACd,UACA,MACkB;CAClB,IAAI,OAAO,MAAM,QAAQ,aAAa,CAAC,KAAK,KAC1C,OAAO,MAAS,UAAU;EAAE,GAAG;EAAM,QAAQ;CAAS,CAAC;CAEzD,OAAO,SAAY;EAAE,GAAG;EAAM,QAAQ;CAAS,CAAC;AAClD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ServerPayload } from '../types';
|
|
2
|
+
export interface OssidoContextValue {
|
|
3
|
+
serverPayload: ServerPayload;
|
|
4
|
+
/**
|
|
5
|
+
* The exact JSON string the Rust runtime produced for this render, available
|
|
6
|
+
* only on the server. `OssidoScripts` embeds it verbatim instead of
|
|
7
|
+
* re-`JSON.stringify`-ing the parsed payload inside V8. Undefined on the
|
|
8
|
+
* client (which reads the already-parsed object off `window`).
|
|
9
|
+
*/
|
|
10
|
+
rawServerPayload?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const OssidoContext: import("react").Context<OssidoContextValue>;
|
|
13
|
+
/**
|
|
14
|
+
* @warning THIS SHOULD NOT BE EXPOSED TO USERLAND
|
|
15
|
+
*/
|
|
16
|
+
export declare function useOssidoContextServerPayload(): OssidoContextValue['serverPayload'];
|
|
17
|
+
/**
|
|
18
|
+
* @warning THIS SHOULD NOT BE EXPOSED TO USERLAND
|
|
19
|
+
*
|
|
20
|
+
* The raw server payload JSON (server render only); undefined on the client.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useOssidoContextRawServerPayload(): OssidoContextValue['rawServerPayload'];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/ossido-context.ts
|
|
4
|
+
const OssidoContext = createContext({});
|
|
5
|
+
/**
|
|
6
|
+
* @warning THIS SHOULD NOT BE EXPOSED TO USERLAND
|
|
7
|
+
*/
|
|
8
|
+
function useOssidoContextServerPayload() {
|
|
9
|
+
return useContext(OssidoContext).serverPayload;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @warning THIS SHOULD NOT BE EXPOSED TO USERLAND
|
|
13
|
+
*
|
|
14
|
+
* The raw server payload JSON (server render only); undefined on the client.
|
|
15
|
+
*/
|
|
16
|
+
function useOssidoContextRawServerPayload() {
|
|
17
|
+
return useContext(OssidoContext).rawServerPayload;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { OssidoContext, useOssidoContextRawServerPayload, useOssidoContextServerPayload };
|
|
22
|
+
//# sourceMappingURL=ossido-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ossido-context.js","names":[],"sources":["../../../src/shared/ossido-context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { ServerPayload } from '../types';\n\nexport interface OssidoContextValue {\n serverPayload: ServerPayload;\n /**\n * The exact JSON string the Rust runtime produced for this render, available\n * only on the server. `OssidoScripts` embeds it verbatim instead of\n * re-`JSON.stringify`-ing the parsed payload inside V8. Undefined on the\n * client (which reads the already-parsed object off `window`).\n */\n rawServerPayload?: string;\n}\n\nexport const OssidoContext = createContext({} as OssidoContextValue);\n\n/**\n * @warning THIS SHOULD NOT BE EXPOSED TO USERLAND\n */\nexport function useOssidoContextServerPayload(): OssidoContextValue['serverPayload'] {\n return useContext(OssidoContext).serverPayload;\n}\n\n/**\n * @warning THIS SHOULD NOT BE EXPOSED TO USERLAND\n *\n * The raw server payload JSON (server render only); undefined on the client.\n */\nexport function useOssidoContextRawServerPayload(): OssidoContextValue['rawServerPayload'] {\n return useContext(OssidoContext).rawServerPayload;\n}\n"],"mappings":";;;AAeA,MAAa,gBAAgB,cAAc,CAAC,CAAuB;;;;AAKnE,SAAgB,gCAAqE;CACnF,OAAO,WAAW,aAAa,CAAC,CAAC;AACnC;;;;;;AAOA,SAAgB,mCAA2E;CACzF,OAAO,WAAW,aAAa,CAAC,CAAC;AACnC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-only. Runs the generated route tree's component reassignments (swapping
|
|
3
|
+
* the route components affected by an HMR update), then bumps the router hot
|
|
4
|
+
* store so the match tree re-renders with them.
|
|
5
|
+
*
|
|
6
|
+
* Called from the `import.meta.hot.accept(...)` block the route generator emits.
|
|
7
|
+
* That block is guarded by `if (import.meta.hot)`, so prod builds dead-code
|
|
8
|
+
* eliminate it and tree-shake this helper away.
|
|
9
|
+
*/
|
|
10
|
+
export declare function __ossido__internal__applyRouteHot(apply: () => void): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { notifyRouteHotUpdate } from "@ossido-labs/ossido-router";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/routeHot.ts
|
|
4
|
+
/**
|
|
5
|
+
* Dev-only. Runs the generated route tree's component reassignments (swapping
|
|
6
|
+
* the route components affected by an HMR update), then bumps the router hot
|
|
7
|
+
* store so the match tree re-renders with them.
|
|
8
|
+
*
|
|
9
|
+
* Called from the `import.meta.hot.accept(...)` block the route generator emits.
|
|
10
|
+
* That block is guarded by `if (import.meta.hot)`, so prod builds dead-code
|
|
11
|
+
* eliminate it and tree-shake this helper away.
|
|
12
|
+
*/
|
|
13
|
+
function __ossido__internal__applyRouteHot(apply) {
|
|
14
|
+
apply();
|
|
15
|
+
notifyRouteHotUpdate();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { __ossido__internal__applyRouteHot };
|
|
20
|
+
//# sourceMappingURL=routeHot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeHot.js","names":[],"sources":["../../../src/shared/routeHot.ts"],"sourcesContent":["import { notifyRouteHotUpdate } from '@ossido-labs/ossido-router';\n\n/**\n * Dev-only. Runs the generated route tree's component reassignments (swapping\n * the route components affected by an HMR update), then bumps the router hot\n * store so the match tree re-renders with them.\n *\n * Called from the `import.meta.hot.accept(...)` block the route generator emits.\n * That block is guarded by `if (import.meta.hot)`, so prod builds dead-code\n * eliminate it and tree-shake this helper away.\n */\nexport function __ossido__internal__applyRouteHot(apply: () => void): void {\n apply();\n notifyRouteHotUpdate();\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,kCAAkC,OAAyB;CACzE,MAAM;CACN,qBAAqB;AACvB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MessageChannelPolyfill } from "./polyfills/MessageChannel.js";
|
|
2
|
+
import { serverSideRendering } from "./server.js";
|
|
3
|
+
import { EventPolyfill } from "./polyfills/Event.js";
|
|
4
|
+
import { MessageEventPolyfill } from "./polyfills/MessageEvent.js";
|
|
5
|
+
|
|
6
|
+
export { EventPolyfill, MessageChannelPolyfill, MessageEventPolyfill, serverSideRendering };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://dom.spec.whatwg.org/#interface-event
|
|
3
|
+
*/
|
|
4
|
+
export declare class EventPolyfill implements Event {
|
|
5
|
+
type: string;
|
|
6
|
+
bubbles: boolean;
|
|
7
|
+
cancelable: boolean;
|
|
8
|
+
composed: boolean;
|
|
9
|
+
currentTarget: EventTarget | null;
|
|
10
|
+
defaultPrevented: boolean;
|
|
11
|
+
eventPhase: number;
|
|
12
|
+
isTrusted: boolean;
|
|
13
|
+
target: EventTarget | null;
|
|
14
|
+
timeStamp: number;
|
|
15
|
+
returnValue: boolean;
|
|
16
|
+
srcElement: EventTarget | null;
|
|
17
|
+
constructor(type: string, eventInitDict?: EventInit);
|
|
18
|
+
}
|