rari 0.5.4 → 0.5.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rari",
3
3
  "type": "module",
4
- "version": "0.5.4",
4
+ "version": "0.5.5",
5
5
  "description": "Runtime Accelerated Rendering Infrastructure (Rari)",
6
6
  "author": "Ryan Skinner",
7
7
  "license": "MIT",
@@ -89,11 +89,11 @@
89
89
  "picocolors": "^1.1.1"
90
90
  },
91
91
  "optionalDependencies": {
92
- "rari-darwin-arm64": "0.5.0",
93
- "rari-darwin-x64": "0.5.0",
94
- "rari-linux-arm64": "0.5.0",
95
- "rari-linux-x64": "0.5.0",
96
- "rari-win32-x64": "0.5.0"
92
+ "rari-darwin-arm64": "0.5.1",
93
+ "rari-darwin-x64": "0.5.1",
94
+ "rari-linux-arm64": "0.5.1",
95
+ "rari-linux-x64": "0.5.1",
96
+ "rari-win32-x64": "0.5.1"
97
97
  },
98
98
  "devDependencies": {
99
99
  "@types/node": "^24.10.1",
@@ -53,7 +53,6 @@ export function AppRouterProvider({ children, initialPayload, onNavigate }: AppR
53
53
  })
54
54
 
55
55
  const loadingRegistryRef = useRef<LoadingComponentRegistry>(new LoadingComponentRegistry())
56
- const layoutInstancesRef = useRef<Map<string, React.ReactElement>>(new Map())
57
56
  const pendingFetchesRef = useRef<Map<string, Promise<any>>>(new Map())
58
57
  const failureHistoryRef = useRef<HMRFailure[]>([])
59
58
  const lastSuccessfulPayloadRef = useRef<string | null>(null)
@@ -183,35 +182,37 @@ export function AppRouterProvider({ children, initialPayload, onNavigate }: AppR
183
182
 
184
183
  if (Array.isArray(rsc)) {
185
184
  if (rsc.length >= 4 && rsc[0] === '$') {
186
- const [, type, key, props] = rsc
185
+ const [, type, serverKey, props] = rsc
187
186
 
188
187
  if (typeof type === 'string' && type.startsWith('$L')) {
189
188
  const moduleInfo = modules.get(type)
190
- if (moduleInfo) {
191
- const Component = (globalThis as any).__clientComponents?.[moduleInfo.id]?.component
192
- if (Component) {
193
- const isLayout = moduleInfo.id.includes('layout')
194
- const stableKey = isLayout ? `layout-${moduleInfo.id}` : key
195
-
196
- const childProps = {
197
- ...props,
198
- children: props.children ? rscToReact(props.children, modules, isLayout ? moduleInfo.id : layoutPath) : undefined,
199
- }
200
189
 
201
- const element = React.createElement(Component, { key: stableKey, ...childProps })
190
+ if (!moduleInfo) {
191
+ console.warn('[AppRouterProvider] Module info not found for type:', type, '- skipping component')
192
+ return null
193
+ }
202
194
 
203
- if (isLayout) {
204
- layoutInstancesRef.current.set(stableKey, true as any)
205
- }
195
+ const Component = (globalThis as any).__clientComponents?.[moduleInfo.id]?.component
206
196
 
207
- return element
208
- }
197
+ if (!Component) {
198
+ console.warn('[AppRouterProvider] Component not loaded for module:', moduleInfo.id, '- skipping component')
199
+ return null
209
200
  }
210
- return null
201
+
202
+ const effectiveKey = serverKey || `fallback-${Math.random()}`
203
+
204
+ const childProps = {
205
+ ...props,
206
+ children: props.children ? rscToReact(props.children, modules, layoutPath) : undefined,
207
+ }
208
+
209
+ const element = React.createElement(Component, { key: effectiveKey, ...childProps })
210
+
211
+ return element
211
212
  }
212
213
 
213
214
  const processedProps = processProps(props, modules, layoutPath)
214
- return React.createElement(type, key ? { ...processedProps, key } : processedProps)
215
+ return React.createElement(type, serverKey ? { ...processedProps, key: serverKey } : processedProps)
215
216
  }
216
217
  return rsc.map(child => rscToReact(child, modules, layoutPath))
217
218
  }
@@ -420,20 +421,6 @@ export function AppRouterProvider({ children, initialPayload, onNavigate }: AppR
420
421
  throw error
421
422
  }
422
423
 
423
- if (layoutDiff && layoutDiff.unmountLayouts.length > 0) {
424
- layoutDiff.unmountLayouts.forEach((layout) => {
425
- const keysToRemove: string[] = []
426
- layoutInstancesRef.current.forEach((_, key) => {
427
- if (key.includes(layout.path)) {
428
- keysToRemove.push(key)
429
- }
430
- })
431
- keysToRemove.forEach((key) => {
432
- layoutInstancesRef.current.delete(key)
433
- })
434
- })
435
- }
436
-
437
424
  setRscPayload(parsedPayload)
438
425
 
439
426
  lastSuccessfulPayloadRef.current = rscWireFormat