rari 0.5.22 → 0.5.24
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/dist/client.mjs +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{loading-component-map-BOnrQGu0.mjs → loading-component-map-C1KKbIfe.mjs} +4 -2
- package/dist/{loading-component-map-HAU32ixM.mjs → loading-component-map-DZYu3WJb.mjs} +1 -1
- package/dist/runtime/actions.mjs +1 -1
- package/dist/{runtime-client-DCkfDJpL.mjs → runtime-client-jOuczfIg.mjs} +13 -36
- package/dist/{server-build-DcfL16G4.mjs → server-build-CQpjQCX6.mjs} +13 -12
- package/dist/server-build-DpwAKSJu.mjs +3 -0
- package/dist/{vite-DN7X9A7r.mjs → vite-CXkIpRWF.mjs} +22 -26
- package/dist/vite.mjs +3 -3
- package/package.json +12 -12
- package/src/router/ClientRouter.tsx +2 -6
- package/src/router/LoadingComponentRegistry.ts +5 -16
- package/src/router/StatePreserver.ts +8 -23
- package/src/router/loading-component-map.ts +4 -2
- package/src/router/vite-plugin.ts +2 -20
- package/src/runtime/AppRouterProvider.tsx +5 -14
- package/src/runtime/LayoutWrapper.tsx +2 -31
- package/src/runtime/NavigationProvider.tsx +0 -5
- package/src/runtime/csrf.ts +1 -1
- package/src/runtime/entry-client.js +9 -7
- package/src/runtime/react-server-dom-shim.js +2 -2
- package/src/runtime/rsc-client-runtime.js +53 -107
- package/src/runtime-client.ts +1 -1
- package/src/vite/hmr-client.ts +0 -4
- package/src/vite/index.ts +19 -8
- package/src/vite/loading-component-bundler.ts +2 -1
- package/src/vite/server-build.ts +13 -13
- package/dist/server-build-gKj-XXmS.mjs +0 -3
package/dist/client.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as fetchWithTimeout, S as createNavigationError, _ as LayoutErrorBoundary, a as LoadingSpinner, b as NavigationErrorOverlay, c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, l as createLoadingBoundary, m as extractServerPropsWithCache, n as DefaultLoading, o as NotFound, p as extractServerProps, r as ErrorBoundary, s as createErrorBoundary, t as DefaultError, u as clearPropsCache, v as ClientRouter, w as LayoutManager, x as NavigationErrorHandler, y as StatePreserver } from "./runtime-client-
|
|
1
|
+
import { C as fetchWithTimeout, S as createNavigationError, _ as LayoutErrorBoundary, a as LoadingSpinner, b as NavigationErrorOverlay, c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, l as createLoadingBoundary, m as extractServerPropsWithCache, n as DefaultLoading, o as NotFound, p as extractServerProps, r as ErrorBoundary, s as createErrorBoundary, t as DefaultError, u as clearPropsCache, v as ClientRouter, w as LayoutManager, x as NavigationErrorHandler, y as StatePreserver } from "./runtime-client-jOuczfIg.mjs";
|
|
2
2
|
|
|
3
3
|
export { ClientRouter, DefaultError, DefaultLoading, ErrorBoundary, HttpRuntimeClient, LayoutErrorBoundary, LayoutManager, LoadingSpinner, NavigationErrorHandler, NavigationErrorOverlay, NotFound, StatePreserver, clearPropsCache, clearPropsCacheForComponent, createErrorBoundary, createHttpRuntimeClient, createLoadingBoundary, createNavigationError, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, fetchWithTimeout, hasServerSideDataFetching };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as headers, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, t as defineRariConfig } from "./vite-
|
|
1
|
+
import { a as headers, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, t as defineRariConfig } from "./vite-CXkIpRWF.mjs";
|
|
2
2
|
import { i as writeManifest, n as generateAppRouteManifest, r as loadManifest, t as AppRouteGenerator } from "./app-routes-DZjfJPdB.mjs";
|
|
3
|
-
import { c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, m as extractServerPropsWithCache, p as extractServerProps, u as clearPropsCache } from "./runtime-client-
|
|
4
|
-
import "./server-build-
|
|
3
|
+
import { c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, m as extractServerPropsWithCache, p as extractServerProps, u as clearPropsCache } from "./runtime-client-jOuczfIg.mjs";
|
|
4
|
+
import "./server-build-CQpjQCX6.mjs";
|
|
5
5
|
|
|
6
6
|
export { AppRouteGenerator, HttpRuntimeClient, RariResponse, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, headers, loadManifest, rari, rariRouter, writeManifest };
|
|
@@ -7,7 +7,8 @@ function generateLoadingComponentMap(options) {
|
|
|
7
7
|
export const loadingComponentModules = {}
|
|
8
8
|
|
|
9
9
|
if (typeof globalThis !== 'undefined') {
|
|
10
|
-
globalThis
|
|
10
|
+
if (!globalThis['~rari']) globalThis['~rari'] = {}
|
|
11
|
+
globalThis['~rari'].loadingComponents = new Map()
|
|
11
12
|
}
|
|
12
13
|
`;
|
|
13
14
|
const moduleEntries = [];
|
|
@@ -23,7 +24,8 @@ ${moduleEntries.join(",\n")}
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
if (typeof globalThis !== 'undefined') {
|
|
26
|
-
globalThis
|
|
27
|
+
if (!globalThis['~rari']) globalThis['~rari'] = {}
|
|
28
|
+
globalThis['~rari'].loadingComponents = new Map(Object.entries(loadingComponentModules))
|
|
27
29
|
}
|
|
28
30
|
`;
|
|
29
31
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as getLoadingComponentMapPath, t as generateLoadingComponentMap } from "./loading-component-map-
|
|
1
|
+
import { n as getLoadingComponentMapPath, t as generateLoadingComponentMap } from "./loading-component-map-C1KKbIfe.mjs";
|
|
2
2
|
|
|
3
3
|
export { generateLoadingComponentMap, getLoadingComponentMapPath };
|
package/dist/runtime/actions.mjs
CHANGED
|
@@ -9,7 +9,7 @@ async function refreshCsrfToken() {
|
|
|
9
9
|
try {
|
|
10
10
|
const response = await fetch("/api/rsc/csrf-token");
|
|
11
11
|
if (!response.ok) {
|
|
12
|
-
console.
|
|
12
|
+
console.error("Failed to refresh CSRF token:", response.status);
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
const data = await response.json();
|
|
@@ -774,9 +774,7 @@ var StatePreserver = class {
|
|
|
774
774
|
});
|
|
775
775
|
}
|
|
776
776
|
});
|
|
777
|
-
} catch
|
|
778
|
-
console.warn("Failed to capture scroll positions:", error);
|
|
779
|
-
}
|
|
777
|
+
} catch {}
|
|
780
778
|
return positions;
|
|
781
779
|
}
|
|
782
780
|
captureFormData() {
|
|
@@ -787,9 +785,7 @@ var StatePreserver = class {
|
|
|
787
785
|
const formData = new FormData(form);
|
|
788
786
|
if (Array.from(formData.entries()).length > 0) formDataMap.set(formId, formData);
|
|
789
787
|
});
|
|
790
|
-
} catch
|
|
791
|
-
console.warn("Failed to capture form data:", error);
|
|
792
|
-
}
|
|
788
|
+
} catch {}
|
|
793
789
|
return formDataMap;
|
|
794
790
|
}
|
|
795
791
|
captureFocusedElement() {
|
|
@@ -801,9 +797,7 @@ var StatePreserver = class {
|
|
|
801
797
|
if (activeElement.name) return `[name="${activeElement.name}"]`;
|
|
802
798
|
}
|
|
803
799
|
}
|
|
804
|
-
} catch
|
|
805
|
-
console.warn("Failed to capture focused element:", error);
|
|
806
|
-
}
|
|
800
|
+
} catch {}
|
|
807
801
|
return null;
|
|
808
802
|
}
|
|
809
803
|
storeState(route, state) {
|
|
@@ -854,13 +848,9 @@ var StatePreserver = class {
|
|
|
854
848
|
if (element instanceof HTMLElement) {
|
|
855
849
|
element.scrollLeft = position.x;
|
|
856
850
|
element.scrollTop = position.y;
|
|
857
|
-
} else
|
|
858
|
-
console.warn(`Could not find scrollable element: ${key}`);
|
|
859
|
-
allSucceeded = false;
|
|
860
|
-
}
|
|
851
|
+
} else allSucceeded = false;
|
|
861
852
|
}
|
|
862
|
-
} catch
|
|
863
|
-
console.warn(`Failed to restore scroll position for ${key}:`, error);
|
|
853
|
+
} catch {
|
|
864
854
|
allSucceeded = false;
|
|
865
855
|
}
|
|
866
856
|
});
|
|
@@ -885,17 +875,12 @@ var StatePreserver = class {
|
|
|
885
875
|
});
|
|
886
876
|
else if (elements instanceof HTMLInputElement || elements instanceof HTMLTextAreaElement || elements instanceof HTMLSelectElement) if (elements instanceof HTMLInputElement && (elements.type === "checkbox" || elements.type === "radio")) elements.checked = elements.value === value;
|
|
887
877
|
else elements.value = value;
|
|
888
|
-
} catch
|
|
889
|
-
console.warn(`Failed to restore form field ${key}:`, error);
|
|
878
|
+
} catch {
|
|
890
879
|
allSucceeded = false;
|
|
891
880
|
}
|
|
892
881
|
});
|
|
893
|
-
else
|
|
894
|
-
|
|
895
|
-
allSucceeded = false;
|
|
896
|
-
}
|
|
897
|
-
} catch (error) {
|
|
898
|
-
console.warn(`Failed to restore form data for ${formId}:`, error);
|
|
882
|
+
else allSucceeded = false;
|
|
883
|
+
} catch {
|
|
899
884
|
allSucceeded = false;
|
|
900
885
|
}
|
|
901
886
|
});
|
|
@@ -911,13 +896,9 @@ var StatePreserver = class {
|
|
|
911
896
|
if (element instanceof HTMLElement) requestAnimationFrame(() => {
|
|
912
897
|
try {
|
|
913
898
|
element.focus();
|
|
914
|
-
} catch
|
|
915
|
-
console.warn(`Failed to focus element ${selector}:`, error);
|
|
916
|
-
}
|
|
899
|
+
} catch {}
|
|
917
900
|
});
|
|
918
|
-
} catch
|
|
919
|
-
console.warn(`Failed to restore focus to ${selector}:`, error);
|
|
920
|
-
}
|
|
901
|
+
} catch {}
|
|
921
902
|
}
|
|
922
903
|
};
|
|
923
904
|
|
|
@@ -1050,9 +1031,7 @@ function ClientRouter({ children, manifest, initialRoute }) {
|
|
|
1050
1031
|
onError: (error) => {
|
|
1051
1032
|
console.error("[ClientRouter] Navigation error:", error);
|
|
1052
1033
|
},
|
|
1053
|
-
onRetry: (
|
|
1054
|
-
console.warn(`[ClientRouter] Retry attempt ${attempt} for ${error.url}`);
|
|
1055
|
-
}
|
|
1034
|
+
onRetry: () => {}
|
|
1056
1035
|
}));
|
|
1057
1036
|
const pendingNavigationsRef = useRef(/* @__PURE__ */ new Map());
|
|
1058
1037
|
const navigationQueueRef = useRef([]);
|
|
@@ -1195,9 +1174,7 @@ function ClientRouter({ children, manifest, initialRoute }) {
|
|
|
1195
1174
|
const decodedMetadata = decodeURIComponent(metadataHeader);
|
|
1196
1175
|
updateDocumentMetadata(JSON.parse(decodedMetadata));
|
|
1197
1176
|
}
|
|
1198
|
-
} catch
|
|
1199
|
-
console.warn("[ClientRouter] Failed to extract/apply metadata:", metadataError);
|
|
1200
|
-
}
|
|
1177
|
+
} catch {}
|
|
1201
1178
|
const rscWireFormat = await response.text();
|
|
1202
1179
|
window.dispatchEvent(new CustomEvent("rari:navigate", { detail: {
|
|
1203
1180
|
from: fromRoute,
|
|
@@ -1747,7 +1724,7 @@ var HttpRuntimeClient = class {
|
|
|
1747
1724
|
}
|
|
1748
1725
|
async queueClientComponentRegistration(componentId, filePath, exportName) {
|
|
1749
1726
|
if (!this.initialized) {
|
|
1750
|
-
console.
|
|
1727
|
+
console.error("Runtime client not initialized. Client component registration will be delayed.");
|
|
1751
1728
|
return;
|
|
1752
1729
|
}
|
|
1753
1730
|
const request = {
|
|
@@ -195,8 +195,8 @@ var ServerComponentBuilder = class {
|
|
|
195
195
|
return code.replace(/import\s+(\w+)\s+from\s+['"]\.\.\/components\/(\w+)(?:\.tsx?|\.jsx?)?['"]/g, (match, importName, componentName) => {
|
|
196
196
|
return `// Component reference: ${componentName}
|
|
197
197
|
const ${importName} = (props) => {
|
|
198
|
-
const Component = globalThis
|
|
199
|
-
|| globalThis
|
|
198
|
+
const Component = globalThis['~rsc']?.components?.['components/${componentName}']
|
|
199
|
+
|| globalThis['~rsc']?.modules?.['components/${componentName}']?.default
|
|
200
200
|
|| globalThis['components/${componentName}'];
|
|
201
201
|
if (!Component) {
|
|
202
202
|
throw new Error('Component components/${componentName} not loaded');
|
|
@@ -744,11 +744,12 @@ if (!globalThis["${componentId}"]) {
|
|
|
744
744
|
let mainExport = null;
|
|
745
745
|
const exportedFunctions = {};
|
|
746
746
|
|
|
747
|
-
globalThis
|
|
747
|
+
if (!globalThis['~serverFunctions']) globalThis['~serverFunctions'] = {};
|
|
748
|
+
if (!globalThis['~serverFunctions'].all) globalThis['~serverFunctions'].all = {};
|
|
748
749
|
|
|
749
750
|
${namedExports.map((name) => `if (typeof ${name} !== 'undefined') {
|
|
750
751
|
globalThis.${name} = ${name};
|
|
751
|
-
globalThis.
|
|
752
|
+
globalThis['~serverFunctions'].all['${name}'] = ${name};
|
|
752
753
|
exportedFunctions['${name}'] = ${name};
|
|
753
754
|
}`).join("\n ")}
|
|
754
755
|
|
|
@@ -782,11 +783,12 @@ if (!globalThis["${componentId}"]) {
|
|
|
782
783
|
globalThis[moduleKey] = mainExport;
|
|
783
784
|
}
|
|
784
785
|
|
|
785
|
-
globalThis
|
|
786
|
-
globalThis
|
|
786
|
+
if (!globalThis['~rsc']) globalThis['~rsc'] = {};
|
|
787
|
+
globalThis['~rsc'].components = globalThis['~rsc'].components || {};
|
|
788
|
+
globalThis['~rsc'].components[moduleKey] = mainExport;
|
|
787
789
|
|
|
788
|
-
globalThis.
|
|
789
|
-
globalThis.
|
|
790
|
+
globalThis['~rsc'].modules = globalThis['~rsc'].modules || {};
|
|
791
|
+
globalThis['~rsc'].modules[moduleKey] = { default: mainExport, ...exportedFunctions };
|
|
790
792
|
|
|
791
793
|
if (typeof globalThis.RscModuleManager !== 'undefined' && globalThis.RscModuleManager.register) {
|
|
792
794
|
globalThis.RscModuleManager.register(moduleKey, mainExport, exportedFunctions);
|
|
@@ -843,9 +845,9 @@ function registerClientReference(clientReference, id, exportName) {
|
|
|
843
845
|
});
|
|
844
846
|
|
|
845
847
|
try {
|
|
846
|
-
if (typeof globalThis
|
|
847
|
-
typeof globalThis.
|
|
848
|
-
globalThis.
|
|
848
|
+
if (typeof globalThis['~rari']?.bridge !== 'undefined' &&
|
|
849
|
+
typeof globalThis['~rari'].bridge.registerClientReference === 'function') {
|
|
850
|
+
globalThis['~rari'].bridge.registerClientReference(key, id, exportName);
|
|
849
851
|
}
|
|
850
852
|
} catch (error) {
|
|
851
853
|
console.error('Failed to register client reference with Rust bridge:', error);
|
|
@@ -1062,7 +1064,6 @@ function createServerBuildPlugin(options = {}) {
|
|
|
1062
1064
|
if (!relativePath.startsWith("src/") || !relativePath.match(/\.(tsx?|jsx?)$/)) return;
|
|
1063
1065
|
try {
|
|
1064
1066
|
if ((await fs.promises.readFile(file, "utf-8")).includes("use client")) return;
|
|
1065
|
-
console.warn(`[server-build] Rebuilding server component: ${relativePath}`);
|
|
1066
1067
|
await builder.buildServerComponents();
|
|
1067
1068
|
} catch (error) {
|
|
1068
1069
|
console.error(`[server-build] Error rebuilding ${relativePath}:`, error);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __require } from "./chunk-DFPPfDFE.mjs";
|
|
2
|
-
import { n as createServerBuildPlugin } from "./server-build-
|
|
2
|
+
import { n as createServerBuildPlugin } from "./server-build-CQpjQCX6.mjs";
|
|
3
3
|
import fs, { promises, stat, unwatchFile, watch, watchFile } from "node:fs";
|
|
4
4
|
import * as sp from "node:path";
|
|
5
5
|
import path, { join, relative, resolve, sep } from "node:path";
|
|
@@ -1736,8 +1736,7 @@ async function notifyApiRouteInvalidation(filePath) {
|
|
|
1736
1736
|
return;
|
|
1737
1737
|
}
|
|
1738
1738
|
const result = await response.json();
|
|
1739
|
-
if (result.success) console.
|
|
1740
|
-
else console.error(`[HMR] Failed to invalidate API route cache: ${result.error || "Unknown error"}`);
|
|
1739
|
+
if (!result.success) console.error(`[HMR] Failed to invalidate API route cache: ${result.error || "Unknown error"}`);
|
|
1741
1740
|
} catch (error) {
|
|
1742
1741
|
console.error("Failed to notify API route invalidation:", error);
|
|
1743
1742
|
}
|
|
@@ -1784,17 +1783,14 @@ function rariRouter(options = {}) {
|
|
|
1784
1783
|
try {
|
|
1785
1784
|
const currentRouteFiles = await scanRouteFiles(appDir);
|
|
1786
1785
|
const currentHash = computeRouteStructureHash(currentRouteFiles);
|
|
1787
|
-
if (!forceRegenerate && routeStructureHash === currentHash && cachedManifestContent)
|
|
1788
|
-
console.warn("[Manifest] Route structure unchanged, using cached manifest");
|
|
1789
|
-
return cachedManifestContent;
|
|
1790
|
-
}
|
|
1786
|
+
if (!forceRegenerate && routeStructureHash === currentHash && cachedManifestContent) return cachedManifestContent;
|
|
1791
1787
|
const { generateAppRouteManifest: generateAppRouteManifest$1 } = await import("./app-routes-DZXtLRKV.mjs");
|
|
1792
1788
|
const manifest = await generateAppRouteManifest$1(appDir, { extensions: opts.extensions });
|
|
1793
1789
|
const manifestContent = JSON.stringify(manifest, null, 2);
|
|
1794
1790
|
const outDir = path.resolve(root, opts.outDir);
|
|
1795
1791
|
await promises.mkdir(outDir, { recursive: true });
|
|
1796
1792
|
await promises.writeFile(path.join(outDir, "app-routes.json"), manifestContent, "utf-8");
|
|
1797
|
-
const { generateLoadingComponentMap, getLoadingComponentMapPath } = await import("./loading-component-map-
|
|
1793
|
+
const { generateLoadingComponentMap, getLoadingComponentMapPath } = await import("./loading-component-map-DZYu3WJb.mjs");
|
|
1798
1794
|
const loadingMapCode = generateLoadingComponentMap({
|
|
1799
1795
|
appDir: opts.appDir,
|
|
1800
1796
|
loadingComponents: manifest.loading
|
|
@@ -1823,7 +1819,6 @@ function rariRouter(options = {}) {
|
|
|
1823
1819
|
const isAddOrUnlink = event === "add" || event === "unlink";
|
|
1824
1820
|
const isNewRouteFile = isRouteFile && !routeFiles.has(filePath);
|
|
1825
1821
|
if (isAddOrUnlink || isNewRouteFile) {
|
|
1826
|
-
console.warn(`[Manifest] Route structure changed (${event}: ${path.relative(root, filePath)}), regenerating manifest`);
|
|
1827
1822
|
await generateAppRoutes(root, true);
|
|
1828
1823
|
if (server && filePath.includes(opts.appDir)) server.ws.send({
|
|
1829
1824
|
type: "full-reload",
|
|
@@ -1874,14 +1869,12 @@ function rariRouter(options = {}) {
|
|
|
1874
1869
|
if (extractedMetadata) {
|
|
1875
1870
|
metadata = extractedMetadata;
|
|
1876
1871
|
metadataChanged = true;
|
|
1877
|
-
console.warn(`[HMR] Metadata detected in ${fileType}: ${JSON.stringify(metadata)}`);
|
|
1878
1872
|
}
|
|
1879
1873
|
} catch (error) {
|
|
1880
1874
|
console.error("Failed to extract metadata:", error);
|
|
1881
1875
|
}
|
|
1882
1876
|
if (fileType === "route") try {
|
|
1883
1877
|
methods = detectHttpMethods(await promises.readFile(file, "utf-8"));
|
|
1884
|
-
console.warn(`[HMR] API route methods detected: ${methods.join(", ")}`);
|
|
1885
1878
|
await notifyApiRouteInvalidation(path.relative(appDir, file));
|
|
1886
1879
|
} catch (error) {
|
|
1887
1880
|
console.error("Failed to detect HTTP methods:", error);
|
|
@@ -1902,15 +1895,11 @@ function rariRouter(options = {}) {
|
|
|
1902
1895
|
event: "rari:app-router-updated",
|
|
1903
1896
|
data: hmrData
|
|
1904
1897
|
});
|
|
1905
|
-
const metadataInfo = metadataChanged ? " [metadata updated]" : "";
|
|
1906
|
-
const methodsInfo = methods ? ` [methods: ${methods.join(", ")}]` : "";
|
|
1907
|
-
console.warn(`[HMR] App router ${fileType} changed: ${hmrData.filePath} (affects ${affectedRoutes.length} route${affectedRoutes.length === 1 ? "" : "s"})${metadataInfo}${methodsInfo}`);
|
|
1908
1898
|
}, DEBOUNCE_DELAY);
|
|
1909
1899
|
pendingHMRUpdates.set(file, timer);
|
|
1910
1900
|
return [];
|
|
1911
1901
|
}
|
|
1912
1902
|
cachedManifestContent = await generateAppRoutes(server$1.config.root);
|
|
1913
|
-
console.warn(`App router file changed: ${path.relative(server$1.config.root, file)}`);
|
|
1914
1903
|
return [];
|
|
1915
1904
|
}
|
|
1916
1905
|
},
|
|
@@ -1920,7 +1909,7 @@ function rariRouter(options = {}) {
|
|
|
1920
1909
|
fileName: "app-routes.json",
|
|
1921
1910
|
source: cachedManifestContent
|
|
1922
1911
|
});
|
|
1923
|
-
else console.
|
|
1912
|
+
else console.error("App router manifest not generated, skipping emission");
|
|
1924
1913
|
},
|
|
1925
1914
|
async closeBundle() {
|
|
1926
1915
|
for (const timer of pendingHMRUpdates.values()) clearTimeout(timer);
|
|
@@ -2244,7 +2233,8 @@ ${loadingComponents.map((entry) => {
|
|
|
2244
2233
|
}
|
|
2245
2234
|
|
|
2246
2235
|
if (typeof globalThis !== 'undefined') {
|
|
2247
|
-
globalThis
|
|
2236
|
+
if (!globalThis['~rari']) globalThis['~rari'] = {}
|
|
2237
|
+
globalThis['~rari'].loadingComponents = new Map(Object.entries(loadingComponentModules))
|
|
2248
2238
|
}
|
|
2249
2239
|
`;
|
|
2250
2240
|
}
|
|
@@ -2496,6 +2486,7 @@ if (import.meta.hot) {
|
|
|
2496
2486
|
function getComponentName(importPath) {
|
|
2497
2487
|
return (importPath.split("/").pop() || importPath).replace(/\.[^.]*$/, "");
|
|
2498
2488
|
}
|
|
2489
|
+
let serverComponentBuilder = null;
|
|
2499
2490
|
return [
|
|
2500
2491
|
{
|
|
2501
2492
|
name: "rari",
|
|
@@ -2643,8 +2634,9 @@ if (import.meta.hot) {
|
|
|
2643
2634
|
}
|
|
2644
2635
|
|
|
2645
2636
|
if (typeof globalThis !== 'undefined') {
|
|
2646
|
-
globalThis
|
|
2647
|
-
globalThis.
|
|
2637
|
+
if (!globalThis['~rari']) globalThis['~rari'] = {};
|
|
2638
|
+
globalThis['~rari'].serverComponents = globalThis['~rari'].serverComponents || new Set();
|
|
2639
|
+
globalThis['~rari'].serverComponents.add(${JSON.stringify(id)});
|
|
2648
2640
|
}
|
|
2649
2641
|
|
|
2650
2642
|
${clientTransformedCode}`;
|
|
@@ -2737,10 +2729,9 @@ const ${componentName$1} = registerClientReference(
|
|
|
2737
2729
|
configureServer(server) {
|
|
2738
2730
|
const projectRoot = options.projectRoot || process$1.cwd();
|
|
2739
2731
|
const srcDir = path.join(projectRoot, "src");
|
|
2740
|
-
let serverComponentBuilder = null;
|
|
2741
2732
|
const discoverAndRegisterComponents = async () => {
|
|
2742
2733
|
try {
|
|
2743
|
-
const { ServerComponentBuilder, scanDirectory } = await import("./server-build-
|
|
2734
|
+
const { ServerComponentBuilder, scanDirectory } = await import("./server-build-DpwAKSJu.mjs");
|
|
2744
2735
|
const builder = new ServerComponentBuilder(projectRoot, {
|
|
2745
2736
|
outDir: "dist",
|
|
2746
2737
|
serverDir: "server",
|
|
@@ -2902,7 +2893,7 @@ const ${componentName$1} = registerClientReference(
|
|
|
2902
2893
|
const handleServerComponentHMR = async (filePath) => {
|
|
2903
2894
|
try {
|
|
2904
2895
|
if (!isServerComponent(filePath)) return;
|
|
2905
|
-
const { ServerComponentBuilder } = await import("./server-build-
|
|
2896
|
+
const { ServerComponentBuilder } = await import("./server-build-DpwAKSJu.mjs");
|
|
2906
2897
|
const builder = new ServerComponentBuilder(projectRoot, {
|
|
2907
2898
|
outDir: "dist",
|
|
2908
2899
|
serverDir: "server",
|
|
@@ -3054,15 +3045,15 @@ const ${componentName$1} = registerClientReference(
|
|
|
3054
3045
|
const componentName = `ClientComponent${index}`;
|
|
3055
3046
|
const componentId = path.basename(componentPath, path.extname(componentPath));
|
|
3056
3047
|
return `
|
|
3057
|
-
globalThis
|
|
3048
|
+
globalThis['~clientComponents']["${relativePath}"] = {
|
|
3058
3049
|
id: "${componentId}",
|
|
3059
3050
|
path: "${relativePath}",
|
|
3060
3051
|
type: "client",
|
|
3061
3052
|
component: ${componentName},
|
|
3062
3053
|
registered: true
|
|
3063
3054
|
};
|
|
3064
|
-
globalThis
|
|
3065
|
-
globalThis
|
|
3055
|
+
globalThis['~clientComponents']["${componentId}"] = globalThis['~clientComponents']["${relativePath}"];
|
|
3056
|
+
globalThis['~clientComponentPaths']["${relativePath}"] = "${componentId}";`;
|
|
3066
3057
|
}).join("\n"));
|
|
3067
3058
|
}
|
|
3068
3059
|
if (id === "react-server-dom-rari/server") return await loadReactServerDomShim();
|
|
@@ -3120,12 +3111,17 @@ globalThis.__clientComponentPaths["${relativePath}"] = "${componentId}";`;
|
|
|
3120
3111
|
else if (isLoadingFile) fileType = "loading";
|
|
3121
3112
|
else if (isErrorFile) fileType = "error";
|
|
3122
3113
|
else if (isNotFoundFile) fileType = "not-found";
|
|
3114
|
+
if (serverComponentBuilder && componentType === "server") try {
|
|
3115
|
+
await serverComponentBuilder.rebuildComponent(file);
|
|
3116
|
+
} catch (error) {
|
|
3117
|
+
console.error(`[HMR] Failed to rebuild ${file}:`, error);
|
|
3118
|
+
}
|
|
3123
3119
|
server.hot.send("rari:app-router-updated", {
|
|
3124
3120
|
type: "rari-hmr",
|
|
3125
3121
|
filePath: file,
|
|
3126
3122
|
fileType
|
|
3127
3123
|
});
|
|
3128
|
-
return
|
|
3124
|
+
return;
|
|
3129
3125
|
}
|
|
3130
3126
|
if (componentType === "client") {
|
|
3131
3127
|
if (hmrCoordinator) await hmrCoordinator.handleClientComponentUpdate(file, server);
|
package/dist/vite.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as headers, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, t as defineRariConfig } from "./vite-
|
|
1
|
+
import { a as headers, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, t as defineRariConfig } from "./vite-CXkIpRWF.mjs";
|
|
2
2
|
import { i as writeManifest, n as generateAppRouteManifest, r as loadManifest, t as AppRouteGenerator } from "./app-routes-DZjfJPdB.mjs";
|
|
3
|
-
import { c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, m as extractServerPropsWithCache, p as extractServerProps, u as clearPropsCache } from "./runtime-client-
|
|
4
|
-
import "./server-build-
|
|
3
|
+
import { c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, m as extractServerPropsWithCache, p as extractServerProps, u as clearPropsCache } from "./runtime-client-jOuczfIg.mjs";
|
|
4
|
+
import "./server-build-CQpjQCX6.mjs";
|
|
5
5
|
|
|
6
6
|
export { AppRouteGenerator, HttpRuntimeClient, RariResponse, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, headers, loadManifest, rari, rariRouter, writeManifest };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rari",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.24",
|
|
5
5
|
"description": "Runtime Accelerated Rendering Infrastructure (Rari)",
|
|
6
6
|
"author": "Ryan Skinner",
|
|
7
7
|
"license": "MIT",
|
|
@@ -85,24 +85,24 @@
|
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"acorn": "^8.15.0",
|
|
88
|
-
"esbuild": "^0.27.
|
|
88
|
+
"esbuild": "^0.27.2",
|
|
89
89
|
"picocolors": "^1.1.1"
|
|
90
90
|
},
|
|
91
91
|
"optionalDependencies": {
|
|
92
|
-
"rari-darwin-arm64": "0.5.
|
|
93
|
-
"rari-darwin-x64": "0.5.
|
|
94
|
-
"rari-linux-arm64": "0.5.
|
|
95
|
-
"rari-linux-x64": "0.5.
|
|
96
|
-
"rari-win32-x64": "0.5.
|
|
92
|
+
"rari-darwin-arm64": "0.5.18",
|
|
93
|
+
"rari-darwin-x64": "0.5.18",
|
|
94
|
+
"rari-linux-arm64": "0.5.18",
|
|
95
|
+
"rari-linux-x64": "0.5.18",
|
|
96
|
+
"rari-win32-x64": "0.5.18"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
|
-
"@types/node": "^25.0.
|
|
99
|
+
"@types/node": "^25.0.3",
|
|
100
100
|
"@types/react": "^19.2.7",
|
|
101
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
101
|
+
"@typescript/native-preview": "7.0.0-dev.20251219.1",
|
|
102
102
|
"chokidar": "^5.0.0",
|
|
103
|
-
"eslint": "^9.39.
|
|
104
|
-
"oxlint": "^1.
|
|
105
|
-
"rolldown-vite": "^7.
|
|
103
|
+
"eslint": "^9.39.2",
|
|
104
|
+
"oxlint": "^1.34.0",
|
|
105
|
+
"rolldown-vite": "^7.3.0",
|
|
106
106
|
"tsdown": "^0.17.3"
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -254,9 +254,7 @@ export function ClientRouter({ children, manifest, initialRoute }: ClientRouterP
|
|
|
254
254
|
onError: (error) => {
|
|
255
255
|
console.error('[ClientRouter] Navigation error:', error)
|
|
256
256
|
},
|
|
257
|
-
onRetry: (
|
|
258
|
-
console.warn(`[ClientRouter] Retry attempt ${attempt} for ${error.url}`)
|
|
259
|
-
},
|
|
257
|
+
onRetry: () => {},
|
|
260
258
|
}),
|
|
261
259
|
)
|
|
262
260
|
|
|
@@ -500,9 +498,7 @@ export function ClientRouter({ children, manifest, initialRoute }: ClientRouterP
|
|
|
500
498
|
updateDocumentMetadata(metadata)
|
|
501
499
|
}
|
|
502
500
|
}
|
|
503
|
-
catch
|
|
504
|
-
console.warn('[ClientRouter] Failed to extract/apply metadata:', metadataError)
|
|
505
|
-
}
|
|
501
|
+
catch {}
|
|
506
502
|
|
|
507
503
|
const rscWireFormat = await response.text()
|
|
508
504
|
|
|
@@ -51,8 +51,7 @@ export class LoadingComponentRegistry {
|
|
|
51
51
|
}
|
|
52
52
|
return component
|
|
53
53
|
}
|
|
54
|
-
catch
|
|
55
|
-
console.warn(`[LoadingRegistry] Failed to load component for ${routePath}:`, error)
|
|
54
|
+
catch {
|
|
56
55
|
return null
|
|
57
56
|
}
|
|
58
57
|
finally {
|
|
@@ -62,12 +61,8 @@ export class LoadingComponentRegistry {
|
|
|
62
61
|
|
|
63
62
|
private async loadComponentFromManifest(routePath: string): Promise<React.ComponentType | null> {
|
|
64
63
|
if (!this.loadingModulesInitialized) {
|
|
65
|
-
this.loadingModules = (globalThis as any)
|
|
64
|
+
this.loadingModules = (globalThis as any)['~rari']?.loadingComponents
|
|
66
65
|
this.loadingModulesInitialized = true
|
|
67
|
-
|
|
68
|
-
if (!this.loadingModules) {
|
|
69
|
-
console.warn('[LoadingRegistry] No loading component modules available')
|
|
70
|
-
}
|
|
71
66
|
}
|
|
72
67
|
|
|
73
68
|
if (!this.loadingModules) {
|
|
@@ -91,9 +86,7 @@ export class LoadingComponentRegistry {
|
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
}
|
|
94
|
-
catch
|
|
95
|
-
console.warn(`[LoadingRegistry] Failed to load exact match for ${routePath}:`, error)
|
|
96
|
-
}
|
|
89
|
+
catch {}
|
|
97
90
|
}
|
|
98
91
|
|
|
99
92
|
const segments = routePath.split('/').filter(Boolean)
|
|
@@ -116,9 +109,7 @@ export class LoadingComponentRegistry {
|
|
|
116
109
|
}
|
|
117
110
|
}
|
|
118
111
|
}
|
|
119
|
-
catch
|
|
120
|
-
console.warn(`[LoadingRegistry] Failed to load parent match for ${parentPath}:`, error)
|
|
121
|
-
}
|
|
112
|
+
catch {}
|
|
122
113
|
}
|
|
123
114
|
}
|
|
124
115
|
|
|
@@ -139,9 +130,7 @@ export class LoadingComponentRegistry {
|
|
|
139
130
|
}
|
|
140
131
|
}
|
|
141
132
|
}
|
|
142
|
-
catch
|
|
143
|
-
console.warn('[LoadingRegistry] Failed to load root loading component:', error)
|
|
144
|
-
}
|
|
133
|
+
catch {}
|
|
145
134
|
}
|
|
146
135
|
|
|
147
136
|
return null
|
|
@@ -66,9 +66,7 @@ export class StatePreserver {
|
|
|
66
66
|
}
|
|
67
67
|
})
|
|
68
68
|
}
|
|
69
|
-
catch
|
|
70
|
-
console.warn('Failed to capture scroll positions:', error)
|
|
71
|
-
}
|
|
69
|
+
catch {}
|
|
72
70
|
|
|
73
71
|
return positions
|
|
74
72
|
}
|
|
@@ -89,9 +87,7 @@ export class StatePreserver {
|
|
|
89
87
|
}
|
|
90
88
|
})
|
|
91
89
|
}
|
|
92
|
-
catch
|
|
93
|
-
console.warn('Failed to capture form data:', error)
|
|
94
|
-
}
|
|
90
|
+
catch {}
|
|
95
91
|
|
|
96
92
|
return formDataMap
|
|
97
93
|
}
|
|
@@ -112,9 +108,7 @@ export class StatePreserver {
|
|
|
112
108
|
}
|
|
113
109
|
}
|
|
114
110
|
}
|
|
115
|
-
catch
|
|
116
|
-
console.warn('Failed to capture focused element:', error)
|
|
117
|
-
}
|
|
111
|
+
catch {}
|
|
118
112
|
|
|
119
113
|
return null
|
|
120
114
|
}
|
|
@@ -202,13 +196,11 @@ export class StatePreserver {
|
|
|
202
196
|
element.scrollTop = position.y
|
|
203
197
|
}
|
|
204
198
|
else {
|
|
205
|
-
console.warn(`Could not find scrollable element: ${key}`)
|
|
206
199
|
allSucceeded = false
|
|
207
200
|
}
|
|
208
201
|
}
|
|
209
202
|
}
|
|
210
|
-
catch
|
|
211
|
-
console.warn(`Failed to restore scroll position for ${key}:`, error)
|
|
203
|
+
catch {
|
|
212
204
|
allSucceeded = false
|
|
213
205
|
}
|
|
214
206
|
})
|
|
@@ -257,19 +249,16 @@ export class StatePreserver {
|
|
|
257
249
|
}
|
|
258
250
|
}
|
|
259
251
|
}
|
|
260
|
-
catch
|
|
261
|
-
console.warn(`Failed to restore form field ${key}:`, error)
|
|
252
|
+
catch {
|
|
262
253
|
allSucceeded = false
|
|
263
254
|
}
|
|
264
255
|
})
|
|
265
256
|
}
|
|
266
257
|
else {
|
|
267
|
-
console.warn(`Could not find form: ${formId}`)
|
|
268
258
|
allSucceeded = false
|
|
269
259
|
}
|
|
270
260
|
}
|
|
271
|
-
catch
|
|
272
|
-
console.warn(`Failed to restore form data for ${formId}:`, error)
|
|
261
|
+
catch {
|
|
273
262
|
allSucceeded = false
|
|
274
263
|
}
|
|
275
264
|
})
|
|
@@ -291,14 +280,10 @@ export class StatePreserver {
|
|
|
291
280
|
try {
|
|
292
281
|
element.focus()
|
|
293
282
|
}
|
|
294
|
-
catch
|
|
295
|
-
console.warn(`Failed to focus element ${selector}:`, error)
|
|
296
|
-
}
|
|
283
|
+
catch {}
|
|
297
284
|
})
|
|
298
285
|
}
|
|
299
286
|
}
|
|
300
|
-
catch
|
|
301
|
-
console.warn(`Failed to restore focus to ${selector}:`, error)
|
|
302
|
-
}
|
|
287
|
+
catch {}
|
|
303
288
|
}
|
|
304
289
|
}
|
|
@@ -14,7 +14,8 @@ export function generateLoadingComponentMap(options: LoadingComponentMapOptions)
|
|
|
14
14
|
export const loadingComponentModules = {}
|
|
15
15
|
|
|
16
16
|
if (typeof globalThis !== 'undefined') {
|
|
17
|
-
globalThis
|
|
17
|
+
if (!globalThis['~rari']) globalThis['~rari'] = {}
|
|
18
|
+
globalThis['~rari'].loadingComponents = new Map()
|
|
18
19
|
}
|
|
19
20
|
`
|
|
20
21
|
}
|
|
@@ -36,7 +37,8 @@ ${moduleEntries.join(',\n')}
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
if (typeof globalThis !== 'undefined') {
|
|
39
|
-
globalThis
|
|
40
|
+
if (!globalThis['~rari']) globalThis['~rari'] = {}
|
|
41
|
+
globalThis['~rari'].loadingComponents = new Map(Object.entries(loadingComponentModules))
|
|
40
42
|
}
|
|
41
43
|
`
|
|
42
44
|
|