@squadbase/vantage 0.5.1 → 0.5.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/README.md +1 -1
- package/dist/client/index.js +35 -0
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/docs/en/changelog.md +21 -0
- package/docs/ja/changelog.md +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ You write `index.tsx`. Vantage owns routing, React, TanStack Query, Tailwind v4,
|
|
|
7
7
|
the UI kit, the dev server, the optional API server, and the build. There is no
|
|
8
8
|
config file.
|
|
9
9
|
|
|
10
|
-
> **Status: prototype (v0.5.
|
|
10
|
+
> **Status: prototype (v0.5.2).** APIs may still change between releases.
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
13
|
|
package/dist/client/index.js
CHANGED
|
@@ -113,7 +113,42 @@ function layoutDepth(layout, manifest) {
|
|
|
113
113
|
}
|
|
114
114
|
return depth;
|
|
115
115
|
}
|
|
116
|
+
|
|
117
|
+
// src/client/self-heal.ts
|
|
118
|
+
var RELOAD_COOLDOWN_MS = 1e4;
|
|
119
|
+
var RELOAD_STAMP_KEY = "__vantage_chunk_reload_at";
|
|
120
|
+
var DYNAMIC_IMPORT_FAILURE = /Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed/i;
|
|
121
|
+
function reloadOnceForStaleChunk() {
|
|
122
|
+
let last = 0;
|
|
123
|
+
try {
|
|
124
|
+
last = Number(window.sessionStorage.getItem(RELOAD_STAMP_KEY) ?? "0");
|
|
125
|
+
} catch {
|
|
126
|
+
}
|
|
127
|
+
if (Number.isFinite(last) && Date.now() - last < RELOAD_COOLDOWN_MS) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
window.sessionStorage.setItem(RELOAD_STAMP_KEY, String(Date.now()));
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
134
|
+
window.location.reload();
|
|
135
|
+
}
|
|
136
|
+
function registerChunkErrorSelfHeal() {
|
|
137
|
+
if (typeof window === "undefined") return;
|
|
138
|
+
window.addEventListener("vite:preloadError", (event) => {
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
reloadOnceForStaleChunk();
|
|
141
|
+
});
|
|
142
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
143
|
+
const reason = event.reason;
|
|
144
|
+
const message = reason instanceof Error ? reason.message : String(reason ?? "");
|
|
145
|
+
if (DYNAMIC_IMPORT_FAILURE.test(message)) {
|
|
146
|
+
reloadOnceForStaleChunk();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
116
150
|
function bootstrap(manifest) {
|
|
151
|
+
registerChunkErrorSelfHeal();
|
|
117
152
|
setRoutes(manifest);
|
|
118
153
|
const { router } = buildRouter(manifest);
|
|
119
154
|
const queryClient = createQueryClient();
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/states.tsx","../../src/client/error-boundary.tsx","../../src/client/build-router.tsx","../../src/client/bootstrap.tsx"],"names":["jsx"],"mappings":";;;;;;;;;AAIO,SAAS,cAAA,GAA4B;AAC1C,EAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,+CAAA,EAAgD,IAAA,EAAK,QAAA,EAAS,WAAA,EAAU,QAAA,EACrF,QAAA,kBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,wEAAA,EACb,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,WAAU,gFAAA,EAAiF,CAAA;AAAA,IAAE;AAAA,GAAA,EAErG,CAAA,EACF,CAAA;AAEJ;AAEO,SAAS,YAAA,CAAa,EAAE,KAAA,EAAM,EAAkC;AACrE,EAAA,MAAM,UAAU,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA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,CAAU,QAAQ,CAAA;AAElB,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,WAAA,CAAY,QAAQ,CAAA;AACvC,EAAA,MAAM,cAAc,iBAAA,EAAkB;AAItC,EAAA,MAAM,eAAe,QAAA,CAAS,KAAA;AAE9B,EAAA,MAAM,cAAc,MAAM;AACxB,IAAA,IAAI;AAEF,MAAA,MAAM,OAAA,GAAiB,MAAA,CAAO,KAAA,EAAO,OAAA,IAAW,EAAC;AACjD,MAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,OAAA,CAAQ,MAAA,GAAS,CAAC,CAAA;AACvC,MAAA,MAAM,KAAA,GAAQ,MAAM,UAAA,EAAY,KAAA;AAChC,MAAA,QAAA,CAAS,QAAQ,OAAO,KAAA,KAAU,YAAY,KAAA,CAAM,MAAA,GAAS,IAAI,KAAA,GAAQ,YAAA;AAAA,IAC3E,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF,CAAA;AACA,EAAA,MAAA,CAAO,SAAA,GAAY,cAAc,WAAW,CAAA;AAE5C,EAAA,MAAM,EAAA,GAAK,QAAA,CAAS,cAAA,CAAe,MAAM,CAAA;AACzC,EAAA,IAAI,CAAC,EAAA,EAAI;AACP,IAAA,MAAM,IAAI,MAAM,+DAA+D,CAAA;AAAA,EACjF;AAEA,EAAA,UAAA,CAAW,EAAE,CAAA,CAAE,MAAA;AAAA,oBACbA,GAAAA,CAAC,UAAA,EAAA,EACC,QAAA,kBAAAA,GAAAA,CAAC,oBACC,QAAA,kBAAAA,GAAAA,CAAC,mBAAA,EAAA,EAAoB,MAAA,EAAQ,aAC3B,QAAA,kBAAAA,GAAAA,CAAC,kBAAe,MAAA,EAAgB,CAAA,EAClC,GACF,CAAA,EACF;AAAA,GACF;AAEA,EAAA,WAAA,EAAY;AACd","file":"index.js","sourcesContent":["import type { ReactNode } from \"react\"\n\n/** Minimal internal states used as router-level defaults. */\n\nexport function DefaultPending(): ReactNode {\n return (\n <div className=\"flex min-h-[40vh] items-center justify-center\" role=\"status\" aria-live=\"polite\">\n <div className=\"flex items-center gap-3 text-sm text-[var(--muted-foreground,#71717a)]\">\n <span className=\"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent\" />\n Loading…\n </div>\n </div>\n )\n}\n\nexport function DefaultError({ error }: { error: unknown }): ReactNode {\n const message = error instanceof Error ? error.message : String(error)\n return (\n <div className=\"mx-auto max-w-2xl p-6\" role=\"alert\">\n <div className=\"rounded-lg border border-[var(--border,#e4e4e7)] bg-[var(--card,#fff)] p-6\">\n <h2 className=\"text-lg font-semibold text-[var(--foreground,#09090b)]\">Something went wrong</h2>\n <p className=\"mt-2 text-sm text-[var(--muted-foreground,#71717a)]\">{message}</p>\n </div>\n </div>\n )\n}\n\nexport function DefaultNotFound(): ReactNode {\n return (\n <div className=\"mx-auto max-w-2xl p-6 text-center\">\n <p className=\"text-5xl font-bold text-[var(--muted-foreground,#a1a1aa)]\">404</p>\n <h2 className=\"mt-3 text-lg font-semibold text-[var(--foreground,#09090b)]\">Page not found</h2>\n <p className=\"mt-1 text-sm text-[var(--muted-foreground,#71717a)]\">\n The page you are looking for does not exist.\n </p>\n </div>\n )\n}\n","import { Component, type ErrorInfo, type ReactNode } from \"react\"\nimport { DefaultError } from \"./states\"\n\ninterface Props {\n children: ReactNode\n fallback?: (error: unknown) => ReactNode\n}\n\ninterface State {\n error: unknown\n}\n\n/**\n * Top-level error boundary that wraps the entire application (outside the\n * router). Route-level errors are handled by the router's errorComponent; this\n * catches catastrophic render failures in the provider tree.\n */\nexport class AppErrorBoundary extends Component<Props, State> {\n state: State = { error: null }\n\n static getDerivedStateFromError(error: unknown): State {\n return { error }\n }\n\n componentDidCatch(error: unknown, info: ErrorInfo): void {\n // Forwarded to the terminal in dev via the console bridge.\n console.error(\"[vantage] Unhandled application error:\", error, info.componentStack)\n }\n\n render(): ReactNode {\n if (this.state.error != null) {\n return this.props.fallback\n ? this.props.fallback(this.state.error)\n : <DefaultError error={this.state.error} />\n }\n return this.props.children\n }\n}\n","import {\n createRootRoute,\n createRoute,\n createRouter,\n lazyRouteComponent,\n Outlet,\n} from \"@tanstack/react-router\"\nimport type { ClientManifest, Loader } from \"./manifest\"\nimport { DefaultError, DefaultNotFound, DefaultPending } from \"./states\"\n\n// The programmatic route tree fights TanStack's file-route generics, which are\n// designed for codegen. Internal assembly is intentionally untyped; the public\n// surface (pages, definePage) stays fully typed.\n/* eslint-disable @typescript-eslint/no-explicit-any */\ntype AnyRoute = any\n\nfunction RootPassthrough() {\n return <Outlet />\n}\n\nfunction lazyComponent(load: Loader): AnyRoute {\n return lazyRouteComponent(load as () => Promise<{ default: any }>)\n}\n\nfunction lazyErrorComponent(load: Loader): AnyRoute {\n return lazyRouteComponent(load as () => Promise<{ default: any }>)\n}\n\nexport interface BuiltRouter {\n router: AnyRoute\n /** routeId -> page meta, for the title manager. */\n meta: Map<string, { title?: string; description?: string; routePath: string }>\n}\n\n/** Assemble a TanStack Router instance from the generated manifest. */\nexport function buildRouter(manifest: ClientManifest): BuiltRouter {\n const rootRoute = createRootRoute({\n component: manifest.rootLayout ? lazyComponent(manifest.rootLayout) : RootPassthrough,\n errorComponent: manifest.error ? lazyErrorComponent(manifest.error) : DefaultError,\n notFoundComponent: manifest.notFound ? lazyComponent(manifest.notFound) : DefaultNotFound,\n })\n\n const layoutById = new Map<string, AnyRoute>()\n const childrenByParent = new Map<string, AnyRoute[]>()\n const meta = new Map<string, { title?: string; description?: string; routePath: string }>()\n\n const pushChild = (parentKey: string, route: AnyRoute) => {\n const list = childrenByParent.get(parentKey) ?? []\n list.push(route)\n childrenByParent.set(parentKey, list)\n }\n\n // 1. Create layout routes (parents referenced lazily via getParentRoute).\n for (const layout of manifest.layouts) {\n const parentKey = layout.parentId ?? \"__root__\"\n const route: AnyRoute = createRoute({\n getParentRoute: () =>\n layout.parentId ? layoutById.get(layout.parentId)! : rootRoute,\n path: layout.path,\n component: lazyComponent(layout.load),\n } as AnyRoute)\n layoutById.set(layout.id, route)\n pushChild(parentKey, route)\n }\n\n // 2. Create page routes.\n for (const page of manifest.pages) {\n const parentKey = page.parentLayoutId ?? \"__root__\"\n const route: AnyRoute = createRoute({\n getParentRoute: () =>\n page.parentLayoutId ? layoutById.get(page.parentLayoutId)! : rootRoute,\n path: page.path,\n component: lazyComponent(page.load),\n staticData: { title: page.title, description: page.description, routePath: page.routePath },\n } as AnyRoute)\n pushChild(parentKey, route)\n // route.id is finalized after createRouter; index by routePath-derived key\n // is unreliable, so the title manager reads staticData off matches instead.\n }\n\n // 3. Attach children — deepest layouts first so nested trees are built before\n // their parent references them.\n const layoutsDeepFirst = [...manifest.layouts].sort(\n (a, b) => layoutDepth(b, manifest) - layoutDepth(a, manifest),\n )\n for (const layout of layoutsDeepFirst) {\n const route = layoutById.get(layout.id)!\n route.addChildren(childrenByParent.get(layout.id) ?? [])\n }\n rootRoute.addChildren(childrenByParent.get(\"__root__\") ?? [])\n\n const router = createRouter({\n routeTree: rootRoute,\n defaultPendingComponent: DefaultPending,\n defaultErrorComponent: DefaultError,\n defaultNotFoundComponent: DefaultNotFound,\n defaultPreload: \"intent\",\n scrollRestoration: true,\n } as AnyRoute)\n\n return { router, meta }\n}\n\nfunction layoutDepth(layout: { id: string; parentId: string | null }, manifest: ClientManifest): number {\n let depth = 0\n let current: string | null = layout.parentId\n const byId = new Map(manifest.layouts.map((l) => [l.id, l]))\n while (current) {\n depth++\n current = byId.get(current)?.parentId ?? null\n }\n return depth\n}\n","import { StrictMode } from \"react\"\nimport { createRoot } from \"react-dom/client\"\nimport { RouterProvider } from \"@tanstack/react-router\"\nimport { QueryClientProvider } from \"@tanstack/react-query\"\nimport { createQueryClient } from \"../query/client\"\nimport { setRoutes } from \"../router/registry\"\nimport { AppErrorBoundary } from \"./error-boundary\"\nimport { buildRouter } from \"./build-router\"\nimport type { ClientManifest } from \"./manifest\"\n\n/**\n * Client entrypoint. The generated `.vantage/client-entry.tsx` calls this with\n * the route manifest. Owns React root creation and the provider tree:\n *\n * <AppErrorBoundary>\n * <QueryClientProvider>\n * <RouterProvider />\n */\nexport function bootstrap(manifest: ClientManifest): void {\n // Publish the route list before the first render so `useRoutes()` is\n // populated for the very first page, not one paint late.\n setRoutes(manifest)\n\n const { router } = buildRouter(manifest)\n const queryClient = createQueryClient()\n\n // The document's initial title is the fallback for pages without a definePage\n // title, so navigating away from a titled page doesn't leave a stale title.\n const defaultTitle = document.title\n\n const updateTitle = () => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const matches: any[] = router.state?.matches ?? []\n const leaf = matches[matches.length - 1]\n const title = leaf?.staticData?.title\n document.title = typeof title === \"string\" && title.length > 0 ? title : defaultTitle\n } catch {\n /* title updates are best-effort */\n }\n }\n router.subscribe?.(\"onResolved\", updateTitle)\n\n const el = document.getElementById(\"root\")\n if (!el) {\n throw new Error('[vantage] Root element \"#root\" was not found in the document.')\n }\n\n createRoot(el).render(\n <StrictMode>\n <AppErrorBoundary>\n <QueryClientProvider client={queryClient}>\n <RouterProvider router={router} />\n </QueryClientProvider>\n </AppErrorBoundary>\n </StrictMode>,\n )\n\n updateTitle()\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/client/states.tsx","../../src/client/error-boundary.tsx","../../src/client/build-router.tsx","../../src/client/self-heal.ts","../../src/client/bootstrap.tsx"],"names":["jsx"],"mappings":";;;;;;;;;AAIO,SAAS,cAAA,GAA4B;AAC1C,EAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,+CAAA,EAAgD,IAAA,EAAK,QAAA,EAAS,WAAA,EAAU,QAAA,EACrF,QAAA,kBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,wEAAA,EACb,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,WAAU,gFAAA,EAAiF,CAAA;AAAA,IAAE;AAAA,GAAA,EAErG,CAAA,EACF,CAAA;AAEJ;AAEO,SAAS,YAAA,CAAa,EAAE,KAAA,EAAM,EAA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"\n\n/** Minimal internal states used as router-level defaults. */\n\nexport function DefaultPending(): ReactNode {\n return (\n <div className=\"flex min-h-[40vh] items-center justify-center\" role=\"status\" aria-live=\"polite\">\n <div className=\"flex items-center gap-3 text-sm text-[var(--muted-foreground,#71717a)]\">\n <span className=\"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent\" />\n Loading…\n </div>\n </div>\n )\n}\n\nexport function DefaultError({ error }: { error: unknown }): ReactNode {\n const message = error instanceof Error ? error.message : String(error)\n return (\n <div className=\"mx-auto max-w-2xl p-6\" role=\"alert\">\n <div className=\"rounded-lg border border-[var(--border,#e4e4e7)] bg-[var(--card,#fff)] p-6\">\n <h2 className=\"text-lg font-semibold text-[var(--foreground,#09090b)]\">Something went wrong</h2>\n <p className=\"mt-2 text-sm text-[var(--muted-foreground,#71717a)]\">{message}</p>\n </div>\n </div>\n )\n}\n\nexport function DefaultNotFound(): ReactNode {\n return (\n <div className=\"mx-auto max-w-2xl p-6 text-center\">\n <p className=\"text-5xl font-bold text-[var(--muted-foreground,#a1a1aa)]\">404</p>\n <h2 className=\"mt-3 text-lg font-semibold text-[var(--foreground,#09090b)]\">Page not found</h2>\n <p className=\"mt-1 text-sm text-[var(--muted-foreground,#71717a)]\">\n The page you are looking for does not exist.\n </p>\n </div>\n )\n}\n","import { Component, type ErrorInfo, type ReactNode } from \"react\"\nimport { DefaultError } from \"./states\"\n\ninterface Props {\n children: ReactNode\n fallback?: (error: unknown) => ReactNode\n}\n\ninterface State {\n error: unknown\n}\n\n/**\n * Top-level error boundary that wraps the entire application (outside the\n * router). Route-level errors are handled by the router's errorComponent; this\n * catches catastrophic render failures in the provider tree.\n */\nexport class AppErrorBoundary extends Component<Props, State> {\n state: State = { error: null }\n\n static getDerivedStateFromError(error: unknown): State {\n return { error }\n }\n\n componentDidCatch(error: unknown, info: ErrorInfo): void {\n // Forwarded to the terminal in dev via the console bridge.\n console.error(\"[vantage] Unhandled application error:\", error, info.componentStack)\n }\n\n render(): ReactNode {\n if (this.state.error != null) {\n return this.props.fallback\n ? this.props.fallback(this.state.error)\n : <DefaultError error={this.state.error} />\n }\n return this.props.children\n }\n}\n","import {\n createRootRoute,\n createRoute,\n createRouter,\n lazyRouteComponent,\n Outlet,\n} from \"@tanstack/react-router\"\nimport type { ClientManifest, Loader } from \"./manifest\"\nimport { DefaultError, DefaultNotFound, DefaultPending } from \"./states\"\n\n// The programmatic route tree fights TanStack's file-route generics, which are\n// designed for codegen. Internal assembly is intentionally untyped; the public\n// surface (pages, definePage) stays fully typed.\n/* eslint-disable @typescript-eslint/no-explicit-any */\ntype AnyRoute = any\n\nfunction RootPassthrough() {\n return <Outlet />\n}\n\nfunction lazyComponent(load: Loader): AnyRoute {\n return lazyRouteComponent(load as () => Promise<{ default: any }>)\n}\n\nfunction lazyErrorComponent(load: Loader): AnyRoute {\n return lazyRouteComponent(load as () => Promise<{ default: any }>)\n}\n\nexport interface BuiltRouter {\n router: AnyRoute\n /** routeId -> page meta, for the title manager. */\n meta: Map<string, { title?: string; description?: string; routePath: string }>\n}\n\n/** Assemble a TanStack Router instance from the generated manifest. */\nexport function buildRouter(manifest: ClientManifest): BuiltRouter {\n const rootRoute = createRootRoute({\n component: manifest.rootLayout ? lazyComponent(manifest.rootLayout) : RootPassthrough,\n errorComponent: manifest.error ? lazyErrorComponent(manifest.error) : DefaultError,\n notFoundComponent: manifest.notFound ? lazyComponent(manifest.notFound) : DefaultNotFound,\n })\n\n const layoutById = new Map<string, AnyRoute>()\n const childrenByParent = new Map<string, AnyRoute[]>()\n const meta = new Map<string, { title?: string; description?: string; routePath: string }>()\n\n const pushChild = (parentKey: string, route: AnyRoute) => {\n const list = childrenByParent.get(parentKey) ?? []\n list.push(route)\n childrenByParent.set(parentKey, list)\n }\n\n // 1. Create layout routes (parents referenced lazily via getParentRoute).\n for (const layout of manifest.layouts) {\n const parentKey = layout.parentId ?? \"__root__\"\n const route: AnyRoute = createRoute({\n getParentRoute: () =>\n layout.parentId ? layoutById.get(layout.parentId)! : rootRoute,\n path: layout.path,\n component: lazyComponent(layout.load),\n } as AnyRoute)\n layoutById.set(layout.id, route)\n pushChild(parentKey, route)\n }\n\n // 2. Create page routes.\n for (const page of manifest.pages) {\n const parentKey = page.parentLayoutId ?? \"__root__\"\n const route: AnyRoute = createRoute({\n getParentRoute: () =>\n page.parentLayoutId ? layoutById.get(page.parentLayoutId)! : rootRoute,\n path: page.path,\n component: lazyComponent(page.load),\n staticData: { title: page.title, description: page.description, routePath: page.routePath },\n } as AnyRoute)\n pushChild(parentKey, route)\n // route.id is finalized after createRouter; index by routePath-derived key\n // is unreliable, so the title manager reads staticData off matches instead.\n }\n\n // 3. Attach children — deepest layouts first so nested trees are built before\n // their parent references them.\n const layoutsDeepFirst = [...manifest.layouts].sort(\n (a, b) => layoutDepth(b, manifest) - layoutDepth(a, manifest),\n )\n for (const layout of layoutsDeepFirst) {\n const route = layoutById.get(layout.id)!\n route.addChildren(childrenByParent.get(layout.id) ?? [])\n }\n rootRoute.addChildren(childrenByParent.get(\"__root__\") ?? [])\n\n const router = createRouter({\n routeTree: rootRoute,\n defaultPendingComponent: DefaultPending,\n defaultErrorComponent: DefaultError,\n defaultNotFoundComponent: DefaultNotFound,\n defaultPreload: \"intent\",\n scrollRestoration: true,\n } as AnyRoute)\n\n return { router, meta }\n}\n\nfunction layoutDepth(layout: { id: string; parentId: string | null }, manifest: ClientManifest): number {\n let depth = 0\n let current: string | null = layout.parentId\n const byId = new Map(manifest.layouts.map((l) => [l.id, l]))\n while (current) {\n depth++\n current = byId.get(current)?.parentId ?? null\n }\n return depth\n}\n","/**\n * Stale-chunk self-healing.\n *\n * A published app is served build-by-build: its HTML references content-hashed\n * JS chunks that belong to one build. When the app is re-published, an\n * already-open tab can end up requesting a chunk hash that the newly-served\n * build no longer has (the routing pin that keeps a session on one build is\n * short-lived by design), which fails the dynamic import. Vite emits\n * `vite:preloadError` for exactly that case.\n *\n * We reload once to pick up the new build. A short sessionStorage cooldown keeps\n * a genuinely-unreachable chunk (offline, or a build that was garbage-collected)\n * from turning into an infinite reload loop — after the first failed reload the\n * error is allowed to surface to the error boundary instead.\n */\nconst RELOAD_COOLDOWN_MS = 10_000\nconst RELOAD_STAMP_KEY = \"__vantage_chunk_reload_at\"\n\n// Messages browsers use when a dynamic import / module preload fails to load.\nconst DYNAMIC_IMPORT_FAILURE = /Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed/i\n\nfunction reloadOnceForStaleChunk(): void {\n let last = 0\n try {\n last = Number(window.sessionStorage.getItem(RELOAD_STAMP_KEY) ?? \"0\")\n } catch {\n // sessionStorage can throw in private/embedded contexts — treat as \"no prior reload\".\n }\n if (Number.isFinite(last) && Date.now() - last < RELOAD_COOLDOWN_MS) {\n // Already reloaded very recently; the chunk is still unreachable, so stop\n // reloading and let the error surface rather than looping.\n return\n }\n try {\n window.sessionStorage.setItem(RELOAD_STAMP_KEY, String(Date.now()))\n } catch {\n // best-effort — a failed write just means we can't dedupe, not a reason to skip healing.\n }\n window.location.reload()\n}\n\n/**\n * Register global listeners that reload the page when a chunk from a\n * now-replaced build fails to load. Safe to call once at bootstrap; a no-op\n * outside the browser.\n */\nexport function registerChunkErrorSelfHeal(): void {\n if (typeof window === \"undefined\") return\n\n // Vite's canonical signal for a failed dynamic-import preload. Calling\n // preventDefault() stops Vite from re-throwing; we reload instead.\n window.addEventListener(\"vite:preloadError\", (event) => {\n event.preventDefault()\n reloadOnceForStaleChunk()\n })\n\n // Belt-and-suspenders: a dynamic import that fails without a modulepreload\n // surfaces as an unhandled rejection. Only act on the specific stale-module\n // messages so unrelated rejections are left alone.\n window.addEventListener(\"unhandledrejection\", (event) => {\n const reason = event.reason\n const message = reason instanceof Error ? reason.message : String(reason ?? \"\")\n if (DYNAMIC_IMPORT_FAILURE.test(message)) {\n reloadOnceForStaleChunk()\n }\n })\n}\n","import { StrictMode } from \"react\"\nimport { createRoot } from \"react-dom/client\"\nimport { RouterProvider } from \"@tanstack/react-router\"\nimport { QueryClientProvider } from \"@tanstack/react-query\"\nimport { createQueryClient } from \"../query/client\"\nimport { setRoutes } from \"../router/registry\"\nimport { AppErrorBoundary } from \"./error-boundary\"\nimport { buildRouter } from \"./build-router\"\nimport { registerChunkErrorSelfHeal } from \"./self-heal\"\nimport type { ClientManifest } from \"./manifest\"\n\n/**\n * Client entrypoint. The generated `.vantage/client-entry.tsx` calls this with\n * the route manifest. Owns React root creation and the provider tree:\n *\n * <AppErrorBoundary>\n * <QueryClientProvider>\n * <RouterProvider />\n */\nexport function bootstrap(manifest: ClientManifest): void {\n // Recover from stale chunks after a re-publish: reload once when a dynamic\n // import fails because the served build changed under an open tab.\n registerChunkErrorSelfHeal()\n\n // Publish the route list before the first render so `useRoutes()` is\n // populated for the very first page, not one paint late.\n setRoutes(manifest)\n\n const { router } = buildRouter(manifest)\n const queryClient = createQueryClient()\n\n // The document's initial title is the fallback for pages without a definePage\n // title, so navigating away from a titled page doesn't leave a stale title.\n const defaultTitle = document.title\n\n const updateTitle = () => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const matches: any[] = router.state?.matches ?? []\n const leaf = matches[matches.length - 1]\n const title = leaf?.staticData?.title\n document.title = typeof title === \"string\" && title.length > 0 ? title : defaultTitle\n } catch {\n /* title updates are best-effort */\n }\n }\n router.subscribe?.(\"onResolved\", updateTitle)\n\n const el = document.getElementById(\"root\")\n if (!el) {\n throw new Error('[vantage] Root element \"#root\" was not found in the document.')\n }\n\n createRoot(el).render(\n <StrictMode>\n <AppErrorBoundary>\n <QueryClientProvider client={queryClient}>\n <RouterProvider router={router} />\n </QueryClientProvider>\n </AppErrorBoundary>\n </StrictMode>,\n )\n\n updateTitle()\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/define-page.ts","../src/index.ts"],"names":[],"mappings":";;;AAyCO,SAAS,WAAW,MAAA,EAAgC;AACzD,EAAA,OAAO,MAAA;AACT;;;AChCO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import type { ComponentType, ReactNode } from \"react\"\n\n/**\n * Optional per-page configuration. The only required part of a page module is\n * its default-exported component; `definePage` covers everything else.\n */\nexport interface PageConfig {\n /** Document title applied when this route is active. */\n title?: string\n /** Description metadata for the page. */\n description?: string\n /**\n * Short label for navigation built from `useRoutes()`. Defaults to `title`,\n * which is often too long for a nav (\"Overview · Acme Analytics\").\n */\n navLabel?: string\n /**\n * Component rendered while the route is loading.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n pendingComponent?: ComponentType\n /**\n * Component rendered when the route throws.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n errorComponent?: ComponentType<{ error: unknown }>\n /**\n * Validate/transform the URL search params for this route.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n validateSearch?: (search: Record<string, unknown>) => Record<string, unknown>\n}\n\n/**\n * Declare optional page configuration.\n *\n * ```tsx\n * export const page = definePage({ title: \"Monthly Analysis\" })\n * export default function MonthlyAnalysis() { return <div/> }\n * ```\n */\nexport function definePage(config: PageConfig): PageConfig {\n return config\n}\n\n/** Convenience type for a Vantage page component. */\nexport type PageComponent = ComponentType & { (): ReactNode }\n","/**\n * `@squadbase/vantage` — public runtime surface.\n *\n * The only import most pages need. Server state lives in\n * `@squadbase/vantage/query`, navigation in `@squadbase/vantage/router`,\n * UI in `@squadbase/vantage/ui`, and API types in `@squadbase/vantage/server`.\n */\nexport { definePage } from \"./runtime/define-page\"\nexport type { PageConfig, PageComponent } from \"./runtime/define-page\"\n\n/** Framework version, kept in sync with package.json at build time. */\nexport const VERSION = \"0.5.
|
|
1
|
+
{"version":3,"sources":["../src/runtime/define-page.ts","../src/index.ts"],"names":[],"mappings":";;;AAyCO,SAAS,WAAW,MAAA,EAAgC;AACzD,EAAA,OAAO,MAAA;AACT;;;AChCO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import type { ComponentType, ReactNode } from \"react\"\n\n/**\n * Optional per-page configuration. The only required part of a page module is\n * its default-exported component; `definePage` covers everything else.\n */\nexport interface PageConfig {\n /** Document title applied when this route is active. */\n title?: string\n /** Description metadata for the page. */\n description?: string\n /**\n * Short label for navigation built from `useRoutes()`. Defaults to `title`,\n * which is often too long for a nav (\"Overview · Acme Analytics\").\n */\n navLabel?: string\n /**\n * Component rendered while the route is loading.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n pendingComponent?: ComponentType\n /**\n * Component rendered when the route throws.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n errorComponent?: ComponentType<{ error: unknown }>\n /**\n * Validate/transform the URL search params for this route.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n validateSearch?: (search: Record<string, unknown>) => Record<string, unknown>\n}\n\n/**\n * Declare optional page configuration.\n *\n * ```tsx\n * export const page = definePage({ title: \"Monthly Analysis\" })\n * export default function MonthlyAnalysis() { return <div/> }\n * ```\n */\nexport function definePage(config: PageConfig): PageConfig {\n return config\n}\n\n/** Convenience type for a Vantage page component. */\nexport type PageComponent = ComponentType & { (): ReactNode }\n","/**\n * `@squadbase/vantage` — public runtime surface.\n *\n * The only import most pages need. Server state lives in\n * `@squadbase/vantage/query`, navigation in `@squadbase/vantage/router`,\n * UI in `@squadbase/vantage/ui`, and API types in `@squadbase/vantage/server`.\n */\nexport { definePage } from \"./runtime/define-page\"\nexport type { PageConfig, PageComponent } from \"./runtime/define-page\"\n\n/** Framework version, kept in sync with package.json at build time. */\nexport const VERSION = \"0.5.2\"\n"]}
|
package/docs/en/changelog.md
CHANGED
|
@@ -9,6 +9,27 @@ What changed in each Vantage release. Newest is on top.
|
|
|
9
9
|
> minor release may include backwards-incompatible changes. A patch is limited to
|
|
10
10
|
> backwards-compatible additions and bug fixes.
|
|
11
11
|
|
|
12
|
+
## v0.5.2
|
|
13
|
+
|
|
14
|
+
Fixes an already-open tab getting stuck on chunks from a build that is no longer
|
|
15
|
+
served. Anything on `^0.5.0` picks this up as-is.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **A tab left open across a re-publish now follows the new build on its own.**
|
|
20
|
+
A published app is served build by build, and its HTML points at
|
|
21
|
+
content-hashed chunks. Re-publish the app and a tab that stayed open asks for a
|
|
22
|
+
**chunk hash the newly-served build no longer has** — the dynamic import behind
|
|
23
|
+
a page transition fails with `Failed to fetch dynamically imported module`, and
|
|
24
|
+
the screen sits on the error until someone reloads by hand.
|
|
25
|
+
|
|
26
|
+
Vantage now listens for Vite's `vite:preloadError` (and for the same failure
|
|
27
|
+
arriving as an unhandled promise rejection) and **reloads the page once** to
|
|
28
|
+
pick up the new build. A 10-second cooldown in `sessionStorage` keeps that to a
|
|
29
|
+
single attempt, so a chunk that is genuinely unreachable — offline, or a build
|
|
30
|
+
that is gone for good — does not turn into a reload loop: the second failure
|
|
31
|
+
surfaces to the error boundary as before. No app-side change is needed.
|
|
32
|
+
|
|
12
33
|
## v0.5.1
|
|
13
34
|
|
|
14
35
|
Fixes `dark:` utilities not being wired to the same switch as the theme tokens.
|
package/docs/ja/changelog.md
CHANGED
|
@@ -8,6 +8,26 @@ Vantage のリリースごとの変更点です。新しいものが上に来ま
|
|
|
8
8
|
> まだプロトタイプ(**0.x**)です。0.x の間は **minor が実質のメジャー**扱いで、後方互換性の
|
|
9
9
|
> ない変更は minor で入ることがあります。patch は後方互換の機能追加とバグ修正のみです。
|
|
10
10
|
|
|
11
|
+
## v0.5.2
|
|
12
|
+
|
|
13
|
+
再公開でビルドが差し替わったとき、開いたままのタブが古い chunk を取りに行って動かなくなる
|
|
14
|
+
不具合の修正です。`^0.5.0` を指定していればそのまま入ります。
|
|
15
|
+
|
|
16
|
+
### 修正
|
|
17
|
+
|
|
18
|
+
- **再公開したあと、開きっぱなしのタブが自動で新しいビルドに追従するようになりました。**
|
|
19
|
+
公開されたアプリはビルド単位で配信され、HTML は content hash の付いた chunk を指しています。
|
|
20
|
+
アプリを再公開すると、開いたままだったタブは**もう配信されていない古いハッシュの chunk**を
|
|
21
|
+
要求してしまい、ページ遷移(dynamic import)が
|
|
22
|
+
`Failed to fetch dynamically imported module` で失敗していました ― 画面はエラー表示のまま
|
|
23
|
+
止まり、手でリロードするまで戻りません。
|
|
24
|
+
|
|
25
|
+
Vite が出す `vite:preloadError`(と、同じ失敗が未捕捉の Promise リジェクションとして出る
|
|
26
|
+
場合)を捕捉して、**一度だけページをリロード**し、新しいビルドを読み直すようにしました。
|
|
27
|
+
リロードは `sessionStorage` に置いた 10 秒の cooldown で 1 回に制限しているので、chunk が
|
|
28
|
+
本当に取得できないとき(オフライン、あるいは配信から消えたビルド)でもリロードループには
|
|
29
|
+
ならず、2 回目からは従来どおりエラーバウンダリに落ちます。アプリ側の変更は要りません。
|
|
30
|
+
|
|
11
31
|
## v0.5.1
|
|
12
32
|
|
|
13
33
|
`dark:` ユーティリティがテーマトークンと同じスイッチに繋がっていなかった不具合の修正です。
|