fibrae 0.2.3 → 0.3.1

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.
Files changed (138) hide show
  1. package/dist/atom-utils.d.ts +52 -0
  2. package/dist/atom-utils.js +64 -0
  3. package/dist/atom-utils.js.map +1 -0
  4. package/dist/cli/build.d.ts +34 -0
  5. package/dist/cli/build.js +92 -0
  6. package/dist/cli/build.js.map +1 -0
  7. package/dist/cli/cli.d.ts +10 -0
  8. package/dist/cli/cli.js +43 -0
  9. package/dist/cli/cli.js.map +1 -0
  10. package/dist/cli/config.d.ts +19 -0
  11. package/dist/cli/config.js +5 -0
  12. package/dist/cli/config.js.map +1 -0
  13. package/dist/cli/html.d.ts +19 -0
  14. package/dist/cli/html.js +95 -0
  15. package/dist/cli/html.js.map +1 -0
  16. package/dist/cli/index.d.ts +6 -0
  17. package/dist/cli/index.js +4 -0
  18. package/dist/cli/index.js.map +1 -0
  19. package/dist/cli/vite-plugin.d.ts +9 -0
  20. package/dist/cli/vite-plugin.js +143 -0
  21. package/dist/cli/vite-plugin.js.map +1 -0
  22. package/dist/components.d.ts +28 -30
  23. package/dist/components.js +35 -53
  24. package/dist/components.js.map +1 -1
  25. package/dist/core.js +7 -10
  26. package/dist/core.js.map +1 -1
  27. package/dist/dom.d.ts +25 -6
  28. package/dist/dom.js +161 -27
  29. package/dist/dom.js.map +1 -1
  30. package/dist/fiber-boundary.d.ts +39 -0
  31. package/dist/fiber-boundary.js +151 -0
  32. package/dist/fiber-boundary.js.map +1 -0
  33. package/dist/fiber-commit.d.ts +27 -0
  34. package/dist/fiber-commit.js +247 -0
  35. package/dist/fiber-commit.js.map +1 -0
  36. package/dist/fiber-render.d.ts +9 -9
  37. package/dist/fiber-render.js +165 -958
  38. package/dist/fiber-render.js.map +1 -1
  39. package/dist/fiber-tree.d.ts +77 -0
  40. package/dist/fiber-tree.js +152 -0
  41. package/dist/fiber-tree.js.map +1 -0
  42. package/dist/fiber-update.d.ts +46 -0
  43. package/dist/fiber-update.js +521 -0
  44. package/dist/fiber-update.js.map +1 -0
  45. package/dist/h.js.map +1 -1
  46. package/dist/index.d.ts +3 -2
  47. package/dist/index.js +4 -2
  48. package/dist/index.js.map +1 -1
  49. package/dist/jsx-runtime/index.d.ts +368 -2
  50. package/dist/live/atom.d.ts +31 -0
  51. package/dist/live/atom.js +33 -0
  52. package/dist/live/atom.js.map +1 -0
  53. package/dist/live/client.d.ts +50 -0
  54. package/dist/live/client.js +90 -0
  55. package/dist/live/client.js.map +1 -0
  56. package/dist/live/codec.d.ts +39 -0
  57. package/dist/live/codec.js +41 -0
  58. package/dist/live/codec.js.map +1 -0
  59. package/dist/live/config.d.ts +13 -0
  60. package/dist/live/config.js +11 -0
  61. package/dist/live/config.js.map +1 -0
  62. package/dist/live/index.d.ts +25 -0
  63. package/dist/live/index.js +19 -0
  64. package/dist/live/index.js.map +1 -0
  65. package/dist/live/server.d.ts +83 -0
  66. package/dist/live/server.js +106 -0
  67. package/dist/live/server.js.map +1 -0
  68. package/dist/live/sse-stream.d.ts +14 -0
  69. package/dist/live/sse-stream.js +30 -0
  70. package/dist/live/sse-stream.js.map +1 -0
  71. package/dist/live/types.d.ts +40 -0
  72. package/dist/live/types.js +20 -0
  73. package/dist/live/types.js.map +1 -0
  74. package/dist/mdx/index.d.ts +125 -0
  75. package/dist/mdx/index.js +137 -0
  76. package/dist/mdx/index.js.map +1 -0
  77. package/dist/mdx/parse.d.ts +42 -0
  78. package/dist/mdx/parse.js +147 -0
  79. package/dist/mdx/parse.js.map +1 -0
  80. package/dist/mdx/render.d.ts +23 -0
  81. package/dist/mdx/render.js +263 -0
  82. package/dist/mdx/render.js.map +1 -0
  83. package/dist/router/Form.d.ts +90 -0
  84. package/dist/router/Form.js +166 -0
  85. package/dist/router/Form.js.map +1 -0
  86. package/dist/router/History.d.ts +4 -9
  87. package/dist/router/History.js +0 -8
  88. package/dist/router/History.js.map +1 -1
  89. package/dist/router/Link.d.ts +27 -28
  90. package/dist/router/Link.js +50 -119
  91. package/dist/router/Link.js.map +1 -1
  92. package/dist/router/Navigator.d.ts +25 -33
  93. package/dist/router/Navigator.js +41 -149
  94. package/dist/router/Navigator.js.map +1 -1
  95. package/dist/router/Route.d.ts +24 -7
  96. package/dist/router/Route.js +42 -27
  97. package/dist/router/Route.js.map +1 -1
  98. package/dist/router/Router.d.ts +27 -19
  99. package/dist/router/Router.js +112 -120
  100. package/dist/router/Router.js.map +1 -1
  101. package/dist/router/RouterBuilder.d.ts +171 -36
  102. package/dist/router/RouterBuilder.js +101 -39
  103. package/dist/router/RouterBuilder.js.map +1 -1
  104. package/dist/router/RouterOutlet.d.ts +1 -18
  105. package/dist/router/RouterOutlet.js +60 -48
  106. package/dist/router/RouterOutlet.js.map +1 -1
  107. package/dist/router/RouterState.d.ts +1 -1
  108. package/dist/router/index.d.ts +8 -5
  109. package/dist/router/index.js +6 -3
  110. package/dist/router/index.js.map +1 -1
  111. package/dist/router/register.d.ts +37 -0
  112. package/dist/router/register.js +18 -0
  113. package/dist/router/register.js.map +1 -0
  114. package/dist/router/utils.d.ts +36 -0
  115. package/dist/router/utils.js +48 -0
  116. package/dist/router/utils.js.map +1 -0
  117. package/dist/runtime.d.ts +11 -8
  118. package/dist/runtime.js +20 -2
  119. package/dist/runtime.js.map +1 -1
  120. package/dist/server.d.ts +2 -2
  121. package/dist/server.js +15 -29
  122. package/dist/server.js.map +1 -1
  123. package/dist/shared.d.ts +61 -62
  124. package/dist/shared.js +51 -13
  125. package/dist/shared.js.map +1 -1
  126. package/dist/tracking.d.ts +4 -3
  127. package/dist/tracking.js +6 -1
  128. package/dist/tracking.js.map +1 -1
  129. package/package.json +45 -7
  130. package/dist/hydration.d.ts +0 -30
  131. package/dist/hydration.js +0 -355
  132. package/dist/hydration.js.map +0 -1
  133. package/dist/render.d.ts +0 -19
  134. package/dist/render.js +0 -285
  135. package/dist/render.js.map +0 -1
  136. package/dist/scope-utils.d.ts +0 -14
  137. package/dist/scope-utils.js +0 -29
  138. package/dist/scope-utils.js.map +0 -1
@@ -0,0 +1,521 @@
1
+ /**
2
+ * Fiber update and reconciliation functions.
3
+ *
4
+ * Contains the core update logic for function components and host components,
5
+ * the work-loop's performUnitOfWork dispatcher, fiber scope management
6
+ * (resubscribeFiber), atom/live-atom subscription wiring, and key-based
7
+ * child reconciliation. Extracted from fiber-render.ts.
8
+ */
9
+ import * as Effect from "effect/Effect";
10
+ import * as Stream from "effect/Stream";
11
+ import * as Scope from "effect/Scope";
12
+ import * as Ref from "effect/Ref";
13
+ import * as Exit from "effect/Exit";
14
+ import * as Option from "effect/Option";
15
+ import * as Deferred from "effect/Deferred";
16
+ import * as Context from "effect/Context";
17
+ import * as FiberRef from "effect/FiberRef";
18
+ import * as Cause from "effect/Cause";
19
+ import * as Schema from "effect/Schema";
20
+ import * as RcMap from "effect/RcMap";
21
+ import { Atom, Registry as AtomRegistry, Result } from "@effect-atom/atom";
22
+ import { ComponentScope, StreamError, isStream, } from "./shared.js";
23
+ import { FibraeRuntime } from "./runtime.js";
24
+ import { normalizeToStream, makeTrackingRegistry } from "./tracking.js";
25
+ import {} from "./live/atom.js";
26
+ import { LiveConfig } from "./live/config.js";
27
+ import { createFiber, fiberTypeIs, fiberTypeIsFunction, fiberIsVirtualElement, getComponentScopeOrDie, getComponentScopeService, linkFibersAsSiblings, findNextSibling, getSuspenseThreshold, queueFiberForRerender, } from "./fiber-tree.js";
28
+ import { handleFiberError, handleFiberSuspension, signalFiberReady, signalBoundaryRecovery, } from "./fiber-boundary.js";
29
+ import { createDom } from "./fiber-commit.js";
30
+ // =============================================================================
31
+ // Stream Subscription Helper
32
+ // =============================================================================
33
+ /**
34
+ * Subscribe to a component's output stream, handling first value and subsequent emissions.
35
+ *
36
+ * Returns a deferred that will be completed with the first emitted value.
37
+ * Subsequent emissions update latestStreamValue and queue re-renders.
38
+ * Errors are forwarded to handleFiberError.
39
+ *
40
+ * @param stream - The component's output stream
41
+ * @param fiberRef - Mutable reference to the current fiber (for re-renders after reconciliation)
42
+ * @param scope - Scope to fork the subscription into
43
+ *
44
+ * @typeParam E - Error type for the deferred (use `never` for die mode, stream error type for fail mode)
45
+ */
46
+ export const subscribeComponentStream = (stream, fiberRef, scope) => Effect.gen(function* () {
47
+ const firstValueDeferred = yield* Deferred.make();
48
+ const subscription = Stream.runForEach(stream, (vElement) => Effect.gen(function* () {
49
+ const done = yield* Deferred.isDone(firstValueDeferred);
50
+ const currentFiber = fiberRef.current;
51
+ if (!done) {
52
+ yield* Deferred.succeed(firstValueDeferred, vElement);
53
+ }
54
+ else {
55
+ // Subsequent emissions - queue re-render
56
+ currentFiber.latestStreamValue = Option.some(vElement);
57
+ if (currentFiber.isParked) {
58
+ // Parked under an error boundary — signal recovery
59
+ yield* signalBoundaryRecovery(currentFiber);
60
+ }
61
+ else {
62
+ yield* queueFiberForRerender(currentFiber);
63
+ }
64
+ }
65
+ })).pipe(Effect.catchAllCause((cause) => Effect.gen(function* () {
66
+ const done = yield* Deferred.isDone(firstValueDeferred);
67
+ const streamError = new StreamError({
68
+ cause: Cause.squash(cause),
69
+ phase: done ? "after-first-emission" : "before-first-emission",
70
+ });
71
+ if (!done) {
72
+ // Fail the deferred with StreamError so awaiting code gets the typed error
73
+ yield* Deferred.fail(firstValueDeferred, streamError);
74
+ }
75
+ const currentFiber = fiberRef.current;
76
+ yield* handleFiberError(currentFiber, streamError);
77
+ })));
78
+ yield* Effect.forkIn(subscription, scope);
79
+ return firstValueDeferred;
80
+ });
81
+ // =============================================================================
82
+ // Update Function Component
83
+ // =============================================================================
84
+ export const updateFunctionComponent = (fiber, runtime) => Effect.gen(function* () {
85
+ // Initialize deferred for child first commit signaling
86
+ if (Option.isNone(fiber.childFirstCommitDeferred)) {
87
+ fiber.childFirstCommitDeferred = Option.some(yield* Deferred.make());
88
+ }
89
+ // Capture current context during render phase for event handlers in commit phase
90
+ // This includes services like Navigator, RouterHandlers, etc.
91
+ const currentContext = yield* FiberRef.get(FiberRef.currentContext);
92
+ fiber.renderContext = Option.some(currentContext);
93
+ // Check if we can reuse cached stream value from alternate
94
+ const hasAlternate = Option.isSome(fiber.alternate);
95
+ const hasCachedValue = fiber.alternate.pipe(Option.map((alt) => Option.isSome(alt.latestStreamValue) && alt.isMultiEmissionStream), Option.getOrElse(() => false));
96
+ if (hasAlternate && hasCachedValue) {
97
+ // Reuse cached value from alternate (stream component that emitted multiple values)
98
+ const alt = Option.getOrThrow(fiber.alternate);
99
+ const vElement = Option.getOrThrow(alt.latestStreamValue);
100
+ fiber.latestStreamValue = alt.latestStreamValue;
101
+ fiber.accessedAtoms = alt.accessedAtoms;
102
+ fiber.componentScope = alt.componentScope;
103
+ alt.componentScope = Option.none(); // Transfer ownership
104
+ fiber.fiberRef = alt.fiberRef;
105
+ fiber.fiberRef.pipe(Option.map((ref) => {
106
+ ref.current = fiber;
107
+ }));
108
+ fiber.isMultiEmissionStream = alt.isMultiEmissionStream;
109
+ yield* reconcileChildren(fiber, [vElement]);
110
+ return;
111
+ }
112
+ // Check if this fiber is being restored from parked (suspended) state
113
+ // If so, skip re-execution and use the cached latestStreamValue
114
+ if (fiber.isUnparking && Option.isSome(fiber.latestStreamValue)) {
115
+ fiber.isUnparking = false; // Clear flag
116
+ const vElement = Option.getOrThrow(fiber.latestStreamValue);
117
+ yield* reconcileChildren(fiber, [vElement]);
118
+ return;
119
+ }
120
+ // Create scope for this component FIRST so it's available in context
121
+ yield* resubscribeFiber(fiber);
122
+ const componentScopeService = yield* getComponentScopeService(fiber, "Expected componentScope to be created by resubscribeFiber");
123
+ // Set up atom tracking
124
+ const accessedAtoms = new Set();
125
+ const accessedLiveAtoms = new Set();
126
+ const trackingRegistry = makeTrackingRegistry(runtime.registry, accessedAtoms, accessedLiveAtoms);
127
+ fiber.accessedAtoms = Option.some(accessedAtoms);
128
+ // Build context with tracking registry AND ComponentScope
129
+ // This allows Effect components to yield* ComponentScope for cleanup registration
130
+ const contextWithTracking = Context.add(Context.add(currentContext, ComponentScope, componentScopeService), AtomRegistry.AtomRegistry, trackingRegistry);
131
+ // Invoke the component
132
+ const output = yield* Option.match(fiber.type, {
133
+ onNone: () => Effect.die("updateFunctionComponent called with no type"),
134
+ onSome: (type) => {
135
+ if (typeof type !== "function") {
136
+ return Effect.die("updateFunctionComponent called with non-function type");
137
+ }
138
+ const component = type;
139
+ return Effect.sync(() => component(fiber.props));
140
+ },
141
+ });
142
+ // Fast path: if component returns a plain VElement (not Effect/Stream),
143
+ // and it's a special element type, just reconcile directly without stream machinery.
144
+ // This handles wrapper components like Suspense and ErrorBoundary efficiently.
145
+ if (!Effect.isEffect(output) && !isStream(output)) {
146
+ const vElement = output;
147
+ if (typeof vElement === "object" && vElement !== null && "type" in vElement) {
148
+ const elementType = vElement.type;
149
+ if (elementType === "SUSPENSE" || elementType === "FRAGMENT") {
150
+ // Simple wrapper component - just reconcile with the VElement directly
151
+ yield* reconcileChildren(fiber, [vElement]);
152
+ return;
153
+ }
154
+ }
155
+ }
156
+ // Check if it's a multi-emission stream
157
+ fiber.isMultiEmissionStream = isStream(output);
158
+ // Normalize to stream and provide context
159
+ const stream = normalizeToStream(output).pipe(Stream.provideContext(contextWithTracking));
160
+ // Set up fiber ref for stream subscriptions
161
+ const fiberRef = fiber.fiberRef.pipe(Option.getOrElse(() => ({ current: fiber })));
162
+ fiber.fiberRef = Option.some(fiberRef);
163
+ // Subscribe to component stream - errors become defects via "die" mode
164
+ const firstValueDeferred = yield* subscribeComponentStream(stream, fiberRef, componentScopeService.scope);
165
+ // Get threshold from nearest Suspense boundary
166
+ const threshold = getSuspenseThreshold(fiber);
167
+ if (threshold > 0) {
168
+ // Race first value vs threshold
169
+ const result = yield* Effect.race(Deferred.await(firstValueDeferred).pipe(Effect.map((v) => ({ _tag: "value", value: v }))), Effect.sleep(`${threshold} millis`).pipe(Effect.map(() => ({ _tag: "timeout" }))));
170
+ if (result._tag === "timeout") {
171
+ // Threshold expired - signal suspension to boundary
172
+ yield* handleFiberSuspension(fiber);
173
+ // Fork background work: wait for value, subscribe atoms, then signal ready
174
+ // This allows the render loop to continue and show fallback
175
+ yield* Effect.forkIn(Effect.gen(function* () {
176
+ const value = yield* Deferred.await(firstValueDeferred);
177
+ const currentFiber = fiberRef.current;
178
+ currentFiber.latestStreamValue = Option.some(value);
179
+ // Subscribe to atom changes — the Effect has completed by now,
180
+ // so accessedAtoms is fully populated from the tracking registry
181
+ yield* subscribeFiberAtoms(currentFiber, accessedAtoms, runtime);
182
+ if (accessedLiveAtoms.size > 0) {
183
+ yield* activateLiveAtoms(accessedLiveAtoms, currentContext, runtime, componentScopeService.scope);
184
+ }
185
+ yield* signalFiberReady(currentFiber);
186
+ }), componentScopeService.scope);
187
+ // Return early - don't reconcile children yet
188
+ // The Suspense boundary will show fallback via queued re-render
189
+ return;
190
+ }
191
+ else {
192
+ // Value arrived before threshold - no suspension
193
+ fiber.latestStreamValue = Option.some(result.value);
194
+ yield* reconcileChildren(fiber, [result.value]);
195
+ }
196
+ }
197
+ else {
198
+ // No threshold (0) - wait indefinitely, no suspension possible
199
+ const firstVElement = yield* Deferred.await(firstValueDeferred);
200
+ fiber.latestStreamValue = Option.some(firstVElement);
201
+ yield* reconcileChildren(fiber, [firstVElement]);
202
+ }
203
+ // Subscribe to atom changes
204
+ yield* subscribeFiberAtoms(fiber, accessedAtoms, runtime);
205
+ // Activate SSE connections for any live atoms
206
+ if (accessedLiveAtoms.size > 0) {
207
+ yield* activateLiveAtoms(accessedLiveAtoms, currentContext, runtime, componentScopeService.scope);
208
+ }
209
+ });
210
+ // =============================================================================
211
+ // Perform Unit of Work
212
+ // =============================================================================
213
+ export const performUnitOfWork = (fiber, runtime) => Effect.gen(function* () {
214
+ const isFunctionComponent = fiberTypeIsFunction(fiber);
215
+ const eff = isFunctionComponent
216
+ ? updateFunctionComponent(fiber, runtime)
217
+ : updateHostComponent(fiber, runtime);
218
+ const exited = yield* Effect.exit(eff);
219
+ if (Exit.isFailure(exited)) {
220
+ // handleFiberError returns the next fiber to process (if recovery happened)
221
+ return yield* handleFiberError(fiber, exited.cause);
222
+ }
223
+ // Return next unit of work: child → sibling → uncle (walk up to find sibling)
224
+ return fiber.child.pipe(Option.orElse(() => findNextSibling(fiber)));
225
+ });
226
+ // =============================================================================
227
+ // Atom Subscription
228
+ // =============================================================================
229
+ export const resubscribeFiber = (fiber) => Effect.gen(function* () {
230
+ // Close old scope if exists
231
+ yield* Option.match(fiber.componentScope, {
232
+ onNone: () => Effect.void,
233
+ onSome: (scope) => Scope.close(scope, Exit.void),
234
+ });
235
+ // Create new scope and mounted deferred
236
+ const newScope = yield* Scope.make();
237
+ const newMounted = yield* Deferred.make();
238
+ fiber.componentScope = Option.some(newScope);
239
+ fiber.mountedDeferred = Option.some(newMounted);
240
+ });
241
+ export const subscribeFiberAtoms = (fiber, accessedAtoms, runtime) => Effect.gen(function* () {
242
+ const scope = yield* getComponentScopeOrDie(fiber, "subscribeFiberAtoms requires an existing componentScope");
243
+ // Use registry.subscribe directly — simpler and more efficient than
244
+ // toStream + drop(1) + runForEach. Cleanup via scope finalizers.
245
+ // unsafeOffer is synchronous, no need for runForkWithRuntime.
246
+ yield* Effect.forEach(accessedAtoms, (atom) => Effect.gen(function* () {
247
+ const unsubscribe = runtime.registry.subscribe(atom, () => {
248
+ runtime.renderMailbox.unsafeOffer(fiber);
249
+ });
250
+ yield* Scope.addFinalizer(scope, Effect.sync(unsubscribe));
251
+ }), { discard: true });
252
+ });
253
+ // =============================================================================
254
+ // Live Atom SSE Activation
255
+ // =============================================================================
256
+ /**
257
+ * Activate SSE connections for live atoms using the runtime's RcMap.
258
+ *
259
+ * EventSources are shared by URL via RcMap — ref-counted and automatically
260
+ * closed when the last consumer's scope closes. Each atom adds its own
261
+ * listener to the shared EventSource.
262
+ */
263
+ export const activateLiveAtoms = (liveAtoms, currentContext, runtime, scope) => {
264
+ // Skip on server
265
+ if (typeof window === "undefined")
266
+ return Effect.void;
267
+ // Try to get LiveConfig from context
268
+ const configOption = Context.getOption(currentContext, LiveConfig);
269
+ if (Option.isNone(configOption))
270
+ return Effect.void;
271
+ const config = configOption.value;
272
+ return Effect.gen(function* () {
273
+ // Ensure withCredentials is set before any RcMap lookups create EventSources
274
+ yield* Ref.set(runtime.sseWithCredentials, config.withCredentials ?? false);
275
+ yield* Effect.forEach(liveAtoms, (atom) => Effect.gen(function* () {
276
+ const url = LiveConfig.resolve(config, atom._live.event);
277
+ const decode = Schema.decodeUnknownSync(Schema.parseJson(atom._live.schema));
278
+ // Get shared EventSource for this URL (ref-counted via RcMap).
279
+ // Scope.extend binds the reference to the component scope —
280
+ // when the component unmounts, the ref count decrements.
281
+ const es = yield* RcMap.get(runtime.sseConnections, url).pipe(Scope.extend(scope));
282
+ const handler = (e) => {
283
+ try {
284
+ runtime.registry.set(atom, Result.success(decode(e.data)));
285
+ }
286
+ catch {
287
+ // Decode errors silently skipped
288
+ }
289
+ };
290
+ es.addEventListener(atom._live.event, handler);
291
+ // Clean up this atom's listener when the component unmounts
292
+ yield* Scope.addFinalizer(scope, Effect.sync(() => es.removeEventListener(atom._live.event, handler)));
293
+ }), { discard: true });
294
+ });
295
+ };
296
+ // =============================================================================
297
+ // Update Host Component
298
+ // =============================================================================
299
+ export const updateHostComponent = (fiber, runtime) => Effect.gen(function* () {
300
+ // Inherit renderContext from parent fiber (function components capture it during render)
301
+ // This propagates Navigator, RouterHandlers, etc. down to host elements for event handlers
302
+ if (Option.isNone(fiber.renderContext) && Option.isSome(fiber.parent)) {
303
+ fiber.renderContext = fiber.parent.value.renderContext;
304
+ }
305
+ // Handle BOUNDARY specially (Effect-native error boundary API)
306
+ const isBoundary = fiberTypeIs(fiber, "BOUNDARY");
307
+ if (isBoundary) {
308
+ const boundaryId = fiber.props.boundaryId;
309
+ const fallbackFn = fiber.props.fallback;
310
+ // Inherit boundary state from alternate (previous render) if present
311
+ // This preserves hasError state across re-renders
312
+ if (Option.isNone(fiber.boundary) && Option.isSome(fiber.alternate)) {
313
+ const alt = fiber.alternate.value;
314
+ if (Option.isSome(alt.boundary)) {
315
+ fiber.boundary = alt.boundary;
316
+ }
317
+ }
318
+ // Initialize boundary config if not already set
319
+ if (Option.isNone(fiber.boundary)) {
320
+ fiber.boundary = Option.some({
321
+ boundaryId,
322
+ fallback: fallbackFn,
323
+ hasError: false,
324
+ error: Option.none(),
325
+ parkedFiber: Option.none(),
326
+ currentFiber: Option.none(),
327
+ });
328
+ }
329
+ const cfg = Option.getOrThrow(fiber.boundary);
330
+ // Always update the current fiber reference (survives alternate swaps)
331
+ cfg.currentFiber = Option.some(fiber);
332
+ if (cfg.hasError && Option.isSome(cfg.error)) {
333
+ // Error state — render fallback, children are parked
334
+ const fallbackElement = cfg.fallback(cfg.error.value);
335
+ yield* reconcileChildren(fiber, [fallbackElement]);
336
+ }
337
+ else if (Option.isSome(cfg.parkedFiber)) {
338
+ // Recovering from error — close parked scopes and re-create children fresh.
339
+ // The parked tree served only to keep the stream subscription alive long enough
340
+ // to detect the next emission (route change). Now we rebuild from scratch.
341
+ const closeParkedTree = (f) => Effect.gen(function* () {
342
+ f.isParked = false;
343
+ if (Option.isSome(f.componentScope)) {
344
+ yield* Scope.close(f.componentScope.value, Exit.void);
345
+ }
346
+ if (Option.isSome(f.child))
347
+ yield* closeParkedTree(f.child.value);
348
+ if (Option.isSome(f.sibling))
349
+ yield* closeParkedTree(f.sibling.value);
350
+ });
351
+ yield* closeParkedTree(cfg.parkedFiber.value);
352
+ cfg.parkedFiber = Option.none();
353
+ // Re-create children from the original props
354
+ const children = fiber.props.children;
355
+ yield* reconcileChildren(fiber, children || []);
356
+ }
357
+ else {
358
+ // Normal rendering — show children
359
+ const children = fiber.props.children;
360
+ yield* reconcileChildren(fiber, children || []);
361
+ }
362
+ return;
363
+ }
364
+ // Handle SUSPENSE specially
365
+ const isSuspense = fiberTypeIs(fiber, "SUSPENSE");
366
+ if (isSuspense) {
367
+ const fallback = fiber.props.fallback;
368
+ const threshold = fiber.props.threshold ?? 100;
369
+ const children = fiber.props.children;
370
+ // Initialize suspense config if not already set
371
+ if (Option.isNone(fiber.suspense)) {
372
+ fiber.suspense = Option.some({
373
+ fallback,
374
+ threshold,
375
+ showingFallback: false,
376
+ parkedFiber: Option.none(),
377
+ parkedComplete: Option.none(),
378
+ });
379
+ }
380
+ const config = Option.getOrThrow(fiber.suspense);
381
+ // Check if parked fiber has completed (signaled via signalFiberReady)
382
+ const parkedDone = yield* config.parkedComplete.pipe(Option.map((d) => Deferred.isDone(d)), Option.getOrElse(() => Effect.succeed(false)));
383
+ if (parkedDone && config.showingFallback) {
384
+ // Parked fiber is ready - switch back to showing its content
385
+ config.showingFallback = false;
386
+ // Mark the fallback child from alternate (previous render) for deletion
387
+ // The fallback fiber is in the alternate's child, not the current fiber's child
388
+ yield* Option.match(fiber.alternate, {
389
+ onNone: () => Effect.void,
390
+ onSome: (alt) => Option.match(alt.child, {
391
+ onNone: () => Effect.void,
392
+ onSome: (fallbackChild) => Effect.gen(function* () {
393
+ fallbackChild.effectTag = Option.some("DELETION");
394
+ yield* Ref.update(runtime.fiberState, (s) => ({
395
+ ...s,
396
+ deletions: [...s.deletions, fallbackChild],
397
+ }));
398
+ }),
399
+ }),
400
+ });
401
+ // Reuse the parked fiber directly - it already has latestStreamValue
402
+ const parkedFiber = Option.getOrThrow(config.parkedFiber);
403
+ // Re-parent the parked fiber under this suspense boundary
404
+ parkedFiber.parent = Option.some(fiber);
405
+ parkedFiber.sibling = Option.none();
406
+ parkedFiber.effectTag = Option.some("PLACEMENT");
407
+ // Mark as unparking - this tells updateFunctionComponent to skip re-execution
408
+ parkedFiber.isUnparking = true;
409
+ // Set as child of this boundary
410
+ fiber.child = Option.some(parkedFiber);
411
+ // Clear parked state
412
+ config.parkedFiber = Option.none();
413
+ config.parkedComplete = Option.none();
414
+ // Don't reconcile here - let performUnitOfWork handle it
415
+ // The work loop will process parkedFiber next, and updateFunctionComponent
416
+ // will see isUnparking=true and use the cached latestStreamValue
417
+ return;
418
+ }
419
+ if (config.showingFallback) {
420
+ // Show fallback while children are suspended
421
+ yield* reconcileChildren(fiber, [fallback]);
422
+ }
423
+ else {
424
+ // Show children normally (they'll race against threshold in updateFunctionComponent)
425
+ yield* reconcileChildren(fiber, children || []);
426
+ }
427
+ return;
428
+ }
429
+ // Virtual element types don't create DOM - just reconcile children
430
+ const isVirtualElement = fiberIsVirtualElement(fiber);
431
+ if (!isVirtualElement && Option.isNone(fiber.dom)) {
432
+ fiber.dom = Option.some(yield* createDom(fiber, runtime));
433
+ }
434
+ const children = fiber.props.children;
435
+ yield* reconcileChildren(fiber, children || []);
436
+ });
437
+ // =============================================================================
438
+ // Reconcile Children (key-based diffing)
439
+ // =============================================================================
440
+ export const reconcileChildren = (wipFiber, elements) => Effect.gen(function* () {
441
+ const runtime = yield* FibraeRuntime;
442
+ const stateRef = runtime.fiberState;
443
+ // Collect old children from alternate by walking the sibling chain
444
+ const collectSiblings = (start) => {
445
+ const result = [];
446
+ let current = start;
447
+ while (Option.isSome(current)) {
448
+ result.push(current.value);
449
+ current = current.value.sibling;
450
+ }
451
+ return result;
452
+ };
453
+ const oldChildren = wipFiber.alternate.pipe(Option.map((alt) => collectSiblings(alt.child)), Option.getOrElse(() => []));
454
+ const getKey = (props) => Option.fromNullable(props?.key);
455
+ // Build maps for keyed and unkeyed old fibers
456
+ const { keyed: oldByKey, unkeyed: oldUnkeyed } = oldChildren.reduce((acc, f) => {
457
+ Option.match(getKey(f.props), {
458
+ onNone: () => acc.unkeyed.push(f),
459
+ onSome: (key) => acc.keyed.set(key, f),
460
+ });
461
+ return acc;
462
+ }, { keyed: new Map(), unkeyed: [] });
463
+ // Match each element against old fibers by key, then by type
464
+ const matchOldFiber = (element) => {
465
+ // Try keyed match first
466
+ const keyMatch = getKey(element.props).pipe(Option.flatMap((key) => {
467
+ const found = Option.fromNullable(oldByKey.get(key));
468
+ found.pipe(Option.map(() => oldByKey.delete(key)));
469
+ return found;
470
+ }));
471
+ if (Option.isSome(keyMatch))
472
+ return keyMatch;
473
+ // Fall back to type matching for unkeyed elements
474
+ const idx = oldUnkeyed.findIndex((f) => f.type.pipe(Option.map((fType) => fType === element.type), Option.getOrElse(() => false)));
475
+ if (idx >= 0) {
476
+ const matched = oldUnkeyed[idx];
477
+ oldUnkeyed.splice(idx, 1);
478
+ return Option.some(matched);
479
+ }
480
+ return Option.none();
481
+ };
482
+ // Reconcile each element against its matched old fiber
483
+ const newFibers = yield* Effect.forEach(elements, (element) => {
484
+ const matchedOldOpt = matchOldFiber(element);
485
+ return matchedOldOpt.pipe(Option.match({
486
+ onNone: () => Effect.succeed(createFiber(Option.some(element.type), element.props, Option.some(wipFiber), Option.none(), Option.some("PLACEMENT"))),
487
+ onSome: (matched) => Effect.gen(function* () {
488
+ const typeMatches = matched.type.pipe(Option.map((mType) => mType === element.type), Option.getOrElse(() => false));
489
+ if (typeMatches) {
490
+ // UPDATE - reuse DOM, update props
491
+ const fiber = createFiber(matched.type, element.props, Option.some(wipFiber), matchedOldOpt, Option.some("UPDATE"));
492
+ fiber.dom = matched.dom;
493
+ fiber.boundary = matched.boundary;
494
+ fiber.suspense = matched.suspense;
495
+ return fiber;
496
+ }
497
+ else {
498
+ // Type changed - delete old, create new
499
+ matched.effectTag = Option.some("DELETION");
500
+ yield* Ref.update(stateRef, (s) => ({
501
+ ...s,
502
+ deletions: [...s.deletions, matched],
503
+ }));
504
+ return createFiber(Option.some(element.type), element.props, Option.some(wipFiber), Option.none(), Option.some("PLACEMENT"));
505
+ }
506
+ }),
507
+ }));
508
+ });
509
+ // Mark leftover old fibers for deletion
510
+ const leftovers = [...oldByKey.values(), ...oldUnkeyed];
511
+ yield* Effect.forEach(leftovers, (leftover) => Effect.gen(function* () {
512
+ leftover.effectTag = Option.some("DELETION");
513
+ yield* Ref.update(stateRef, (s) => ({
514
+ ...s,
515
+ deletions: [...s.deletions, leftover],
516
+ }));
517
+ }), { discard: true });
518
+ // Link new fibers as child/sibling chain
519
+ linkFibersAsSiblings(newFibers, wipFiber);
520
+ });
521
+ //# sour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ACb;CACF,CAAC,CAAC;AAeH,MAAM,UAAU,CAAC,CACf,IAAoB,EACpB,KAAK,GAA+B,EAAE,EACtC,QAAQ,GAAa,EAAE;IAEvB,OAAO;QACL,IAAI,EAAE,IAAmB;QACzB,KAAK,EAAE;YACL,GAAG,KAAK;YACR,QAAQ,EAAE,QAAQ;iBACf,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;iBAC3E,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBACb,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACvD,OAAO,KAAiB,CAAC;gBAC3B,CAAC;gBACD,gEAAgE;gBAChE,OAAO,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;SACL;KACF,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,7 +4,8 @@ export { Suspense, ErrorBoundary } from "./components.js";
4
4
  export { h, createTextElement } from "./h.js";
5
5
  export type { VElement, ElementType, Primitive } from "./shared.js";
6
6
  export type { VElement as VNode } from "./shared.js";
7
- export { RenderError, StreamError, EventHandlerError, type ComponentError, } from "./shared.js";
7
+ export { RenderError, StreamError, EventHandlerError, type ComponentError } from "./shared.js";
8
8
  export { ComponentScope } from "./shared.js";
9
9
  export { HydrationState, HydrationStateLive, HydrationStateEmpty } from "./hydration-state.js";
10
- export { Atom, Registry as AtomRegistry, Result } from "@effect-atom/atom";
10
+ export { Atom, AtomHttpApi, AtomRef, AtomRpc, Hydration, Registry as AtomRegistry, Result, } from "@effect-atom/atom";
11
+ export { mountAtom, subscribeAtom } from "./atom-utils.js";
package/dist/index.js CHANGED
@@ -10,12 +10,14 @@ export { Suspense, ErrorBoundary } from "./components.js";
10
10
  // Element creation (JSX factory)
11
11
  export { h, createTextElement } from "./h.js";
12
12
  // Error types
13
- export { RenderError, StreamError, EventHandlerError, } from "./shared.js";
13
+ export { RenderError, StreamError, EventHandlerError } from "./shared.js";
14
14
  // Component lifecycle
15
15
  export { ComponentScope } from "./shared.js";
16
16
  // Hydration state service
17
17
  export { HydrationState, HydrationStateLive, HydrationStateEmpty } from "./hydration-state.js";
18
18
  // Re-export upstream Effect Atom APIs for consumers
19
- export { Atom, Registry as AtomRegistry, Result } from "@effect-atom/atom";
19
+ export { Atom, AtomHttpApi, AtomRef, AtomRpc, Hydration, Registry as AtomRegistry, Result, } from "@effect-atom/atom";
20
+ // Component-scoped atom utilities
21
+ export { mountAtom, subscribeAtom } from "./atom-utils.js";
20
22
  // Router available via "fibrae/router" import
21
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,aAAa;AACb,gFAAgF;AAEhF,uBAAuB;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,UAAU;AACV,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEtE,sBAAsB;AACtB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1D,iCAAiC;AACjC,OAAO,EAAE,CAAC,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAM9C,cAAc;AACd,OAAO,EACL,WAAW,EACX,WAAW,EACX,iBAAiB,GAElB,MAAM,aAAa,CAAC;AAErB,sBAAsB;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,0BAA0B;AAC1B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE/F,oDAAoD;AACpD,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,YAAY,E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