React 19 modernization: forwardRef removal, Compiler, ErrorBoundary, Suspense, native <script>

Adopt React 19 idioms across the codebase. The runtime was already on
react@19.2.5 but no React 19 APIs were in use.

- forwardRef -> ref-as-prop in 7 layout/component files
  (NitroInput/Button/ItemCountBadge/Card×5/InfiniteGridItem,
  ToolbarItemView, AvatarEditorIcon)
- <Ctx.Provider> -> <Ctx> in 6 contexts (CatalogAdmin, FloorplanEditor,
  UiSettings, GridContext, NitroCardContext, NitroCardAccordionContext)
- Native <script> hoisting for Turnstile, ExternalPluginLoader, GoogleAdsView
  (React 19 dedupes by src; removes manual document.head.appendChild +
  module-level promise caches)
- React Compiler enabled at build time via babel-plugin-react-compiler
  in vite.config.mjs (target: '19'), plus eslint-plugin-react-compiler
  in lint mode
- Global <ErrorBoundary> + <Suspense> in src/index.tsx using
  react-error-boundary, with LoadingView as fallback
- BackgroundsView migrated to use(promise) as a demonstrator pattern
  for Suspense-driven config loading
- ESLint react setting bumped 18.3.1 -> 19.2; legacy
  @typescript-eslint/ban-types replaced with no-restricted-types
  (the old rule was removed in @typescript-eslint v8)
- Refresh public/configuration/{asset-loader,bootstrap}.js to match
  current write-asset-loader.mjs output

Phase 3 (login forms -> useActionState/useFormStatus) deferred:
LoginView is 1623 lines with lockout + Turnstile + heartbeat
interleaving; safer as its own PR.

https://claude.ai/code/session_01GrR87LAqnAEyKG2ZbmQt5Q
This commit is contained in:
simoleo89
2026-05-11 16:31:50 +00:00
parent 2137d23ac0
commit a1bee1d825
24 changed files with 354 additions and 258 deletions
+25 -2
View File
@@ -44,6 +44,11 @@
return new URL(".", source);
};
const getDeployBase = () => {
try { return new URL("..", getBase()); }
catch { return new URL("/", location.href); }
};
const withCacheBust = (url) => {
url.searchParams.set("v", Date.now().toString(36));
return url;
@@ -71,9 +76,14 @@
const resolveAssetCandidates = (path) => {
const base = getBase();
const deploy = getDeployBase();
const normalized = path.replace(/^\.\//, "");
const file = normalized.split("/").pop();
const relative = normalized.replace(/^\//, "");
const urls = [
new URL("src/assets/" + file, deploy),
new URL("assets/" + file, deploy),
new URL(relative, deploy),
new URL("./src/assets/" + file, base),
new URL("./assets/" + file, base),
new URL("/src/assets/" + file, base.origin),
@@ -205,7 +215,10 @@
const fetchManifest = async () => {
const base = getBase();
const deploy = getDeployBase();
const candidates = [
new URL(".vite/manifest.json", deploy),
new URL("manifest.json", deploy),
new URL(".vite/manifest.json", base.origin + "/"),
new URL("manifest.json", base.origin + "/"),
new URL(".vite/manifest.json", base),
@@ -221,7 +234,11 @@
const json = await response.json();
if(json && typeof json === "object") {
debug("loader: manifest from " + candidate.href);
return { manifest: json, base: new URL(".", candidate.href) };
let manifestBase = new URL(".", candidate.href);
if(/\/\.vite\/manifest\.json$/.test(candidate.pathname)) {
manifestBase = new URL("..", manifestBase);
}
return { manifest: json, base: manifestBase };
}
} catch {}
}
@@ -247,18 +264,24 @@
const resolveManifestPath = (manifestBase, file) => {
if(/^https?:\/\//i.test(file)) return file;
if(file.startsWith("/")) return file;
return new URL(file, manifestBase.origin + "/").pathname;
return new URL(file, manifestBase).pathname;
};
const isLoaderUrl = (href) => /(?:^|\/)bootstrap\.js(?:$|\?|#)/i.test(href) || /(?:^|\/)asset-loader\.js(?:$|\?|#)/i.test(href);
const fetchEntryFromIndexHtml = async () => {
const base = getBase();
const deploy = getDeployBase();
const candidates = [
new URL("index.html", deploy),
new URL("./", deploy),
new URL("/index.html", base.origin + "/"),
new URL("/", base.origin + "/")
];
const seen = new Set();
for(const candidate of candidates) {
if(seen.has(candidate.href)) continue;
seen.add(candidate.href);
try {
const response = await fetch(withCacheBust(new URL(candidate.href)), { cache: "no-store" });
if(!response.ok) continue;