fibrae 0.2.2 → 0.3.0
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/cli/build.d.ts +34 -0
- package/dist/cli/build.js +92 -0
- package/dist/cli/build.js.map +1 -0
- package/dist/cli/cli.d.ts +10 -0
- package/dist/cli/cli.js +43 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/config.d.ts +19 -0
- package/dist/cli/config.js +5 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/html.d.ts +13 -0
- package/dist/cli/html.js +101 -0
- package/dist/cli/html.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/vite-plugin.d.ts +9 -0
- package/dist/cli/vite-plugin.js +143 -0
- package/dist/cli/vite-plugin.js.map +1 -0
- package/dist/components.d.ts +27 -29
- package/dist/components.js +32 -52
- package/dist/components.js.map +1 -1
- package/dist/core.js +7 -10
- package/dist/core.js.map +1 -1
- package/dist/dom.d.ts +13 -4
- package/dist/dom.js +91 -26
- package/dist/dom.js.map +1 -1
- package/dist/fiber-boundary.d.ts +39 -0
- package/dist/fiber-boundary.js +151 -0
- package/dist/fiber-boundary.js.map +1 -0
- package/dist/fiber-commit.d.ts +27 -0
- package/dist/fiber-commit.js +243 -0
- package/dist/fiber-commit.js.map +1 -0
- package/dist/fiber-render.d.ts +9 -9
- package/dist/fiber-render.js +165 -958
- package/dist/fiber-render.js.map +1 -1
- package/dist/fiber-tree.d.ts +77 -0
- package/dist/fiber-tree.js +152 -0
- package/dist/fiber-tree.js.map +1 -0
- package/dist/fiber-update.d.ts +46 -0
- package/dist/fiber-update.js +515 -0
- package/dist/fiber-update.js.map +1 -0
- package/dist/h.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/dist/jsx-runtime/index.d.ts +253 -2
- package/dist/live/atom.d.ts +31 -0
- package/dist/live/atom.js +33 -0
- package/dist/live/atom.js.map +1 -0
- package/dist/live/client.d.ts +50 -0
- package/dist/live/client.js +90 -0
- package/dist/live/client.js.map +1 -0
- package/dist/live/codec.d.ts +39 -0
- package/dist/live/codec.js +41 -0
- package/dist/live/codec.js.map +1 -0
- package/dist/live/config.d.ts +13 -0
- package/dist/live/config.js +11 -0
- package/dist/live/config.js.map +1 -0
- package/dist/live/index.d.ts +25 -0
- package/dist/live/index.js +19 -0
- package/dist/live/index.js.map +1 -0
- package/dist/live/server.d.ts +83 -0
- package/dist/live/server.js +106 -0
- package/dist/live/server.js.map +1 -0
- package/dist/live/sse-stream.d.ts +14 -0
- package/dist/live/sse-stream.js +30 -0
- package/dist/live/sse-stream.js.map +1 -0
- package/dist/live/types.d.ts +40 -0
- package/dist/live/types.js +20 -0
- package/dist/live/types.js.map +1 -0
- package/dist/router/History.d.ts +2 -2
- package/dist/router/History.js.map +1 -1
- package/dist/router/Link.d.ts +8 -4
- package/dist/router/Link.js +13 -34
- package/dist/router/Link.js.map +1 -1
- package/dist/router/Navigator.d.ts +12 -1
- package/dist/router/Navigator.js +31 -68
- package/dist/router/Navigator.js.map +1 -1
- package/dist/router/Route.d.ts +16 -3
- package/dist/router/Route.js +32 -25
- package/dist/router/Route.js.map +1 -1
- package/dist/router/Router.d.ts +27 -19
- package/dist/router/Router.js +78 -101
- package/dist/router/Router.js.map +1 -1
- package/dist/router/RouterBuilder.d.ts +106 -34
- package/dist/router/RouterBuilder.js +78 -39
- package/dist/router/RouterBuilder.js.map +1 -1
- package/dist/router/RouterOutlet.d.ts +1 -18
- package/dist/router/RouterOutlet.js +25 -8
- package/dist/router/RouterOutlet.js.map +1 -1
- package/dist/router/RouterState.d.ts +1 -1
- package/dist/router/index.d.ts +4 -4
- package/dist/router/index.js +4 -2
- package/dist/router/index.js.map +1 -1
- package/dist/router/utils.d.ts +36 -0
- package/dist/router/utils.js +48 -0
- package/dist/router/utils.js.map +1 -0
- package/dist/runtime.d.ts +10 -7
- package/dist/runtime.js +20 -2
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +15 -29
- package/dist/server.js.map +1 -1
- package/dist/shared.d.ts +58 -59
- package/dist/shared.js +51 -13
- package/dist/shared.js.map +1 -1
- package/dist/tracking.d.ts +4 -3
- package/dist/tracking.js +6 -1
- package/dist/tracking.js.map +1 -1
- package/package.json +32 -7
- package/dist/hydration.d.ts +0 -30
- package/dist/hydration.js +0 -355
- package/dist/hydration.js.map +0 -1
- package/dist/render.d.ts +0 -19
- package/dist/render.js +0 -285
- package/dist/render.js.map +0 -1
- package/dist/scope-utils.d.ts +0 -14
- package/dist/scope-utils.js +0 -29
- package/dist/scope-utils.js.map +0 -1
|
@@ -10,6 +10,9 @@ import * as Effect from "effect/Effect";
|
|
|
10
10
|
import * as Context from "effect/Context";
|
|
11
11
|
import * as Layer from "effect/Layer";
|
|
12
12
|
import * as Option from "effect/Option";
|
|
13
|
+
import { RouterError } from "./Router.js";
|
|
14
|
+
/** Normalize a LoaderResult (value or Effect) into an Effect. No type erasure. */
|
|
15
|
+
const liftLoader = (value) => Effect.isEffect(value) ? value : Effect.succeed(value);
|
|
13
16
|
/**
|
|
14
17
|
* Tag for the RouterHandlers service.
|
|
15
18
|
* Provides access to all registered handlers.
|
|
@@ -18,6 +21,7 @@ export class RouterHandlers extends Context.Tag("fibrae/RouterHandlers")() {
|
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Create handlers builder for a route group.
|
|
24
|
+
* RouteNames is threaded through to constrain handle() calls.
|
|
21
25
|
*/
|
|
22
26
|
function makeGroupHandlers(groupName, grp) {
|
|
23
27
|
const routesByName = new Map(grp.routes.map((r) => [r.name, r]));
|
|
@@ -27,22 +31,34 @@ function makeGroupHandlers(groupName, grp) {
|
|
|
27
31
|
handle(routeName, config) {
|
|
28
32
|
const maybeRoute = Option.fromNullable(routesByName.get(routeName));
|
|
29
33
|
if (Option.isNone(maybeRoute)) {
|
|
30
|
-
throw new
|
|
34
|
+
throw new RouterError({
|
|
35
|
+
message: `Route "${routeName}" not found in group "${groupName}"`,
|
|
36
|
+
});
|
|
31
37
|
}
|
|
32
38
|
const route = maybeRoute.value;
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
// Type-erasure boundary: loader/head/getStaticPaths are stored with R = never
|
|
40
|
+
// because their actual requirements (R2) are captured by the Layer's R type parameter.
|
|
41
|
+
// Casts to LoaderContext<PathParams, SearchParams> are safe — RouterOutlet always
|
|
42
|
+
// passes correctly-typed params decoded from the route schema.
|
|
43
|
+
const loader = (ctx) => (config.loader
|
|
44
|
+
? liftLoader(config.loader(ctx))
|
|
45
|
+
: Effect.succeed(null));
|
|
46
|
+
const head = Option.fromNullable(config.head).pipe(Option.map((fn) => (ctx) => {
|
|
47
|
+
const result = fn(ctx);
|
|
39
48
|
return (Effect.isEffect(result) ? result : Effect.succeed(result));
|
|
40
|
-
};
|
|
49
|
+
}));
|
|
50
|
+
const getStaticPaths = Option.fromNullable(config.getStaticPaths).pipe(Option.map((fn) => () => {
|
|
51
|
+
const result = fn();
|
|
52
|
+
return (Effect.isEffect(result) ? result : Effect.succeed(result));
|
|
53
|
+
}));
|
|
41
54
|
const handler = {
|
|
42
55
|
routeName,
|
|
43
56
|
route,
|
|
44
|
-
loader
|
|
57
|
+
loader,
|
|
45
58
|
component: config.component,
|
|
59
|
+
head,
|
|
60
|
+
prerender: config.prerender ?? false,
|
|
61
|
+
getStaticPaths,
|
|
46
62
|
};
|
|
47
63
|
return buildHandlers([...handlers, handler]);
|
|
48
64
|
},
|
|
@@ -51,9 +67,10 @@ function makeGroupHandlers(groupName, grp) {
|
|
|
51
67
|
}
|
|
52
68
|
/**
|
|
53
69
|
* Create handlers builder for a layout group.
|
|
70
|
+
* RouteNames is threaded through to constrain handle() calls.
|
|
54
71
|
*/
|
|
55
|
-
function makeLayoutGroupHandlers(groupName,
|
|
56
|
-
const routesByName = new Map(
|
|
72
|
+
function makeLayoutGroupHandlers(groupName, layoutGrp) {
|
|
73
|
+
const routesByName = new Map(layoutGrp.routes.map((r) => [r.name, r]));
|
|
57
74
|
const buildHandlers = (handlers, layoutHandler) => ({
|
|
58
75
|
groupName,
|
|
59
76
|
handlers,
|
|
@@ -67,44 +84,51 @@ function makeLayoutGroupHandlers(groupName, layoutGroup) {
|
|
|
67
84
|
handle(routeName, config) {
|
|
68
85
|
const maybeRoute = Option.fromNullable(routesByName.get(routeName));
|
|
69
86
|
if (Option.isNone(maybeRoute)) {
|
|
70
|
-
throw new
|
|
87
|
+
throw new RouterError({
|
|
88
|
+
message: `Route "${routeName}" not found in layout group "${groupName}"`,
|
|
89
|
+
});
|
|
71
90
|
}
|
|
72
91
|
const route = maybeRoute.value;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
// Type-erasure boundary: loader/head/getStaticPaths are stored with R = never
|
|
93
|
+
// because their actual requirements (R2) are captured by the Layer's R type parameter.
|
|
94
|
+
// Casts to LoaderContext<PathParams, SearchParams> are safe — RouterOutlet always
|
|
95
|
+
// passes correctly-typed params decoded from the route schema.
|
|
96
|
+
const loader = (ctx) => (config.loader
|
|
97
|
+
? liftLoader(config.loader(ctx))
|
|
98
|
+
: Effect.succeed(null));
|
|
99
|
+
const head = Option.fromNullable(config.head).pipe(Option.map((fn) => (ctx) => {
|
|
100
|
+
const result = fn(ctx);
|
|
78
101
|
return (Effect.isEffect(result) ? result : Effect.succeed(result));
|
|
79
|
-
};
|
|
102
|
+
}));
|
|
103
|
+
const getStaticPaths = Option.fromNullable(config.getStaticPaths).pipe(Option.map((fn) => () => {
|
|
104
|
+
const result = fn();
|
|
105
|
+
return (Effect.isEffect(result) ? result : Effect.succeed(result));
|
|
106
|
+
}));
|
|
80
107
|
const handler = {
|
|
81
108
|
routeName,
|
|
82
109
|
route,
|
|
83
|
-
loader
|
|
110
|
+
loader,
|
|
84
111
|
component: config.component,
|
|
112
|
+
head,
|
|
113
|
+
prerender: config.prerender ?? false,
|
|
114
|
+
getStaticPaths,
|
|
85
115
|
};
|
|
86
116
|
return buildHandlers([...handlers, handler], layoutHandler);
|
|
87
117
|
},
|
|
88
118
|
});
|
|
89
119
|
return buildHandlers([], null);
|
|
90
120
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*/
|
|
94
|
-
function findGroup(appRouter, groupName) {
|
|
95
|
-
const maybeGroup = Option.fromNullable(appRouter.groups.find((g) => g.name === groupName));
|
|
96
|
-
if (Option.isNone(maybeGroup)) {
|
|
97
|
-
throw new Error(`Group "${groupName}" not found in router "${appRouter.name}"`);
|
|
98
|
-
}
|
|
99
|
-
return maybeGroup.value;
|
|
100
|
-
}
|
|
101
|
-
export function group(appRouter, groupName, build) {
|
|
102
|
-
const routeGroup = findGroup(appRouter, groupName);
|
|
103
|
-
// Check if it's a layout group - if so, throw helpful error
|
|
121
|
+
export function group(_appRouter, routeGroup, build) {
|
|
122
|
+
// Validate it's not a layout group (runtime safety net — types should prevent this)
|
|
104
123
|
if (routeGroup._tag === "LayoutGroup") {
|
|
105
|
-
|
|
124
|
+
return Layer.effect(RouterHandlers, Effect.die(new RouterError({
|
|
125
|
+
message: `Group "${routeGroup.name}" is a LayoutGroup. Use RouterBuilder.layoutGroup() instead.`,
|
|
126
|
+
})));
|
|
106
127
|
}
|
|
107
|
-
const initialHandlers = makeGroupHandlers(
|
|
128
|
+
const initialHandlers = makeGroupHandlers(routeGroup.name, routeGroup);
|
|
129
|
+
// The Layer construction only needs the build callback's R2. The loader requirements (R)
|
|
130
|
+
// are needed at execution time (when serverLayer/browserLayer call handler.loader).
|
|
131
|
+
// We widen the type to include R so consumers must provide loader dependencies.
|
|
108
132
|
return Layer.effect(RouterHandlers, Effect.gen(function* () {
|
|
109
133
|
const result = build(initialHandlers);
|
|
110
134
|
const builtHandlers = Effect.isEffect(result) ? yield* result : result;
|
|
@@ -122,12 +146,14 @@ export function group(appRouter, groupName, build) {
|
|
|
122
146
|
};
|
|
123
147
|
}));
|
|
124
148
|
}
|
|
125
|
-
export function layoutGroup(
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
149
|
+
export function layoutGroup(_appRouter, layoutGrp, build) {
|
|
150
|
+
// Runtime safety net — types should prevent this
|
|
151
|
+
if (layoutGrp._tag !== "LayoutGroup") {
|
|
152
|
+
return Layer.effect(RouterHandlers, Effect.die(new RouterError({
|
|
153
|
+
message: `Group "${layoutGrp.name}" is not a LayoutGroup. Use RouterBuilder.group() instead.`,
|
|
154
|
+
})));
|
|
129
155
|
}
|
|
130
|
-
const initialHandlers = makeLayoutGroupHandlers(
|
|
156
|
+
const initialHandlers = makeLayoutGroupHandlers(layoutGrp.name, layoutGrp);
|
|
131
157
|
return Layer.effect(RouterHandlers, Effect.gen(function* () {
|
|
132
158
|
const result = build(initialHandlers);
|
|
133
159
|
const builtHandlers = Effect.isEffect(result) ? yield* result : result;
|
|
@@ -188,4 +214,17 @@ export function executeRoute(handler, ctx) {
|
|
|
188
214
|
});
|
|
189
215
|
});
|
|
190
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Extract all prerender routes with their static path parameters.
|
|
219
|
+
*
|
|
220
|
+
* For each route with `prerender: true`:
|
|
221
|
+
* - If `getStaticPaths` is defined, calls it to enumerate all param sets
|
|
222
|
+
* - Otherwise, defaults to `[{}]` (a single page with no params)
|
|
223
|
+
*/
|
|
224
|
+
export const getPrerenderRoutes = (handlers) => Effect.all(Array.from(handlers.handlers.values())
|
|
225
|
+
.filter((h) => h.prerender)
|
|
226
|
+
.map((handler) => Option.match(handler.getStaticPaths, {
|
|
227
|
+
onNone: () => Effect.succeed([{}]),
|
|
228
|
+
onSome: (fn) => fn(),
|
|
229
|
+
}).pipe(Effect.map((paramSets) => ({ handler, paramSets })))));
|
|
191
230
|
//# sourceMappingURL=RouterBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterBuilder.js","sourceRoot":"","sources":["../../src/router/RouterBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"RouterBuilder.js","sourceRoot":"","sources":["../../src/router/RouterBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAmC1C,kFAAkF;AAClF,MAAM,UAAU,GAAG,CAAU,KAA4B,EAA0B,EAAE,CACnF,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAoLzD;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAQrE;CAAG;AAEN;;;GAGG;AACH,SAAS,iBAAiB,CACxB,SAAoB,EACpB,GAAsC;IAEtC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAgB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhF,MAAM,aAAa,GAAG,CACpB,QAAiC,EACK,EAAE,CAAC,CAAC;QAC1C,SAAS;QACT,QAAQ;QACR,MAAM,CAOJ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OAAqB,EACrB,GAAkB;IAElB,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzB,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9C,OAAO,OAAO,CAAC,SAAS,CAAC;YACvB,UAAU;YACV,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,YAAY,EAAE,GAAG,CAAC,YAAY;SAC/B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAUD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAElC,EAAyD,EAAE,CAC1D,MAAM,CAAC,GAAG,CACR,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;KACnC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;KAC1B,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACf,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE;IACnC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAA2C,CAAC;IAC5E,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE;CACrB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAkB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAC7E,CACJ,CAAC"}
|
|
@@ -46,23 +46,6 @@ declare const OutletDepth_base: Context.TagClass<OutletDepth, "fibrae/OutletDept
|
|
|
46
46
|
*/
|
|
47
47
|
export declare class OutletDepth extends OutletDepth_base {
|
|
48
48
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Props for RouterOutlet component.
|
|
51
|
-
*
|
|
52
|
-
* @deprecated Props are no longer needed - SSR hydration is handled via RouterStateAtom.
|
|
53
|
-
*/
|
|
54
|
-
export interface RouterOutletProps {
|
|
55
|
-
/**
|
|
56
|
-
* @deprecated Use RouterStateAtom hydration instead.
|
|
57
|
-
* Initial loader data from SSR - skips loader on first render.
|
|
58
|
-
*/
|
|
59
|
-
readonly initialLoaderData?: unknown;
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated Use RouterStateAtom hydration instead.
|
|
62
|
-
* Initial route name from SSR - used with initialLoaderData.
|
|
63
|
-
*/
|
|
64
|
-
readonly initialRouteName?: string;
|
|
65
|
-
}
|
|
66
49
|
/**
|
|
67
50
|
* RouterOutlet component for reactive route rendering.
|
|
68
51
|
*
|
|
@@ -77,5 +60,5 @@ export interface RouterOutletProps {
|
|
|
77
60
|
* For SSR hydration, the RouterStateAtom is pre-populated by the server,
|
|
78
61
|
* so the first render uses that data and skips the loader.
|
|
79
62
|
*/
|
|
80
|
-
export declare function RouterOutlet(
|
|
63
|
+
export declare function RouterOutlet(): Stream.Stream<VElement, never, Navigator | RouterHandlers | AtomRegistry.AtomRegistry>;
|
|
81
64
|
export {};
|
|
@@ -37,10 +37,25 @@ import * as Effect from "effect/Effect";
|
|
|
37
37
|
import * as Stream from "effect/Stream";
|
|
38
38
|
import * as Option from "effect/Option";
|
|
39
39
|
import * as Context from "effect/Context";
|
|
40
|
+
import * as Cause from "effect/Cause";
|
|
40
41
|
import { Registry as AtomRegistry } from "@effect-atom/atom";
|
|
41
42
|
import { Navigator } from "./Navigator.js";
|
|
42
43
|
import { RouterHandlers } from "./RouterBuilder.js";
|
|
43
44
|
import { RouterStateAtom } from "./RouterState.js";
|
|
45
|
+
/**
|
|
46
|
+
* Component that re-throws a caught error during render.
|
|
47
|
+
* Used by RouterOutlet to bubble per-route errors to ErrorBoundary
|
|
48
|
+
* without killing the route-change stream.
|
|
49
|
+
*/
|
|
50
|
+
const ErrorBubble = (cause) => {
|
|
51
|
+
const error = Cause.squash(cause);
|
|
52
|
+
return {
|
|
53
|
+
type: (() => {
|
|
54
|
+
throw error;
|
|
55
|
+
}),
|
|
56
|
+
props: { children: [] },
|
|
57
|
+
};
|
|
58
|
+
};
|
|
44
59
|
/**
|
|
45
60
|
* Context for tracking outlet depth in nested layouts.
|
|
46
61
|
* Each nested RouterOutlet increments the depth.
|
|
@@ -64,7 +79,7 @@ export class OutletDepth extends Context.Tag("fibrae/OutletDepth")() {
|
|
|
64
79
|
* For SSR hydration, the RouterStateAtom is pre-populated by the server,
|
|
65
80
|
* so the first render uses that data and skips the loader.
|
|
66
81
|
*/
|
|
67
|
-
export function RouterOutlet(
|
|
82
|
+
export function RouterOutlet() {
|
|
68
83
|
// Track if this is the first render (for SSR hydration)
|
|
69
84
|
let isFirstRender = true;
|
|
70
85
|
return Stream.unwrap(Effect.gen(function* () {
|
|
@@ -77,8 +92,11 @@ export function RouterOutlet(_props = {}) {
|
|
|
77
92
|
const hydratedState = registry.get(RouterStateAtom);
|
|
78
93
|
// Create a stream from the currentRoute atom (navigation trigger)
|
|
79
94
|
const routeStream = AtomRegistry.toStream(registry, navigator.currentRoute);
|
|
80
|
-
// Map route changes to rendered VElements
|
|
81
|
-
|
|
95
|
+
// Map route changes to rendered VElements.
|
|
96
|
+
// Errors are caught per-route so the stream stays alive for navigation recovery.
|
|
97
|
+
// A failing route emits a component that re-throws during render, allowing
|
|
98
|
+
// ErrorBoundary to catch it while keeping this stream alive for the next route.
|
|
99
|
+
return routeStream.pipe(Stream.mapEffect((currentRoute) => Effect.gen(function* () {
|
|
82
100
|
if (Option.isNone(currentRoute)) {
|
|
83
101
|
// No route matched - clear router state and render 404
|
|
84
102
|
registry.set(RouterStateAtom, Option.none());
|
|
@@ -116,10 +134,6 @@ export function RouterOutlet(_props = {}) {
|
|
|
116
134
|
},
|
|
117
135
|
};
|
|
118
136
|
}
|
|
119
|
-
// The layout component renders its own <RouterOutlet /> which will
|
|
120
|
-
// have depth = currentDepth + 1. We need to provide the incremented
|
|
121
|
-
// depth via context - this is handled by the rendering system
|
|
122
|
-
// that provides OutletDepth = currentDepth + 1 to nested outlets.
|
|
123
137
|
return layoutHandler.value.component();
|
|
124
138
|
}
|
|
125
139
|
// At the deepest level - render the actual route component
|
|
@@ -177,7 +191,10 @@ export function RouterOutlet(_props = {}) {
|
|
|
177
191
|
searchParams,
|
|
178
192
|
});
|
|
179
193
|
return element;
|
|
180
|
-
})
|
|
194
|
+
}).pipe(
|
|
195
|
+
// Catch per-route errors so the stream stays alive for navigation recovery.
|
|
196
|
+
// Emit a component that re-throws during render — ErrorBoundary catches it.
|
|
197
|
+
Effect.catchAllCause((cause) => Effect.succeed(ErrorBubble(cause))))));
|
|
181
198
|
}));
|
|
182
199
|
}
|
|
183
200
|
//# sourceMappingURL=RouterOutlet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterOutlet.js","sourceRoot":"","sources":["../../src/router/RouterOutlet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAoB,MAAM,kBAAkB,CAAC;AAGrE;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAuB;CAAG;
|
|
1
|
+
{"version":3,"file":"RouterOutlet.js","sourceRoot":"","sources":["../../src/router/RouterOutlet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C;gBACN,iBAAiB;gBACjB,MAAM,SAAS,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;gBACjD,UAAU,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAEpD,6BAA6B;gBAC7B,WAAW,GAAG;oBACZ,SAAS;oBACT,MAAM;oBACN,YAAY;oBACZ,UAAU;iBACX,CAAC;gBAEF,6DAA6D;gBAC7D,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;YAC1D,CAAC;YAED,6BAA6B;YAC7B,aAAa,GAAG,KAAK,CAAC;YAEtB,iDAAiD;YACjD,wDAAwD;YACxD,uEAAuE;YACvE,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;gBACtC,UAAU;gBACV,IAAI,EAAE,MAAM;gBACZ,YAAY;aACb,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC,IAAI;QACL,4EAA4E;QAC5E,4EAA4E;QAC5E,MAAM,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAa,CAAC,CAAC,CAChF,CACF,CACF,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -93,7 +93,7 @@ export declare const getRouterState: Effect.Effect<Option.Option<RouterState>, n
|
|
|
93
93
|
* Get the current loader data (typed by the caller).
|
|
94
94
|
* Returns None if no route is matched.
|
|
95
95
|
*/
|
|
96
|
-
export declare const getLoaderData: <T>() => Effect.Effect<Option.Option<T>, never,
|
|
96
|
+
export declare const getLoaderData: <T>() => Effect.Effect<Option.Option<T>, never, AtomRegistry.AtomRegistry | RouterStateService>;
|
|
97
97
|
/**
|
|
98
98
|
* Get the current route params.
|
|
99
99
|
* Returns None if no route is matched.
|
package/dist/router/index.d.ts
CHANGED
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
* - Type-safe navigation
|
|
9
9
|
*/
|
|
10
10
|
export * as Route from "./Route.js";
|
|
11
|
+
export { RouteError } from "./Route.js";
|
|
11
12
|
export * as Router from "./Router.js";
|
|
12
13
|
export * as RouterBuilder from "./RouterBuilder.js";
|
|
13
14
|
export * as History from "./History.js";
|
|
14
15
|
export * as Navigator from "./Navigator.js";
|
|
15
16
|
export * as RouterState from "./RouterState.js";
|
|
16
|
-
export type { LoaderContext, ComponentProps, HandlerConfig, RouteHandler, GroupHandlers, LayoutGroupHandlers, LayoutHandler, } from "./RouterBuilder.js";
|
|
17
|
-
export { RouterHandlers } from "./RouterBuilder.js";
|
|
17
|
+
export type { LoaderContext, ComponentProps, HandlerConfig, RouteHandler, GroupHandlers, LayoutGroupHandlers, LayoutHandler, PrerenderRoute, HeadData, HeadContext, MetaDescriptor, } from "./RouterBuilder.js";
|
|
18
|
+
export { RouterHandlers, getPrerenderRoutes } from "./RouterBuilder.js";
|
|
18
19
|
export type { HistoryLocation, HistoryService } from "./History.js";
|
|
19
20
|
export { History as HistoryTag, BrowserHistoryLive, MemoryHistoryLive } from "./History.js";
|
|
20
21
|
export type { CurrentRoute, NavigateOptions, NavigatorService } from "./Navigator.js";
|
|
21
|
-
export { Navigator as NavigatorTag, NavigatorLive } from "./Navigator.js";
|
|
22
|
+
export { Navigator as NavigatorTag, NavigatorLive, createGo } from "./Navigator.js";
|
|
22
23
|
export type { LinkProps } from "./Link.js";
|
|
23
24
|
export { createLink } from "./Link.js";
|
|
24
|
-
export type { RouterOutletProps } from "./RouterOutlet.js";
|
|
25
25
|
export { RouterOutlet, OutletDepth } from "./RouterOutlet.js";
|
|
26
26
|
export type { ServerLayerOptions, BrowserLayerOptions, DehydratedRouterState, SSRRouteResult, RouteMatch, LayoutGroup, RouteGroup, AnyGroup, } from "./Router.js";
|
|
27
27
|
export { CurrentRouteElement } from "./Router.js";
|
package/dist/router/index.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
// Route declaration
|
|
11
11
|
export * as Route from "./Route.js";
|
|
12
|
+
export { RouteError } from "./Route.js";
|
|
12
13
|
// Router and groups
|
|
13
14
|
export * as Router from "./Router.js";
|
|
14
15
|
// Handler implementation
|
|
@@ -19,10 +20,11 @@ export * as History from "./History.js";
|
|
|
19
20
|
export * as Navigator from "./Navigator.js";
|
|
20
21
|
// Router state (unified serializable state)
|
|
21
22
|
export * as RouterState from "./RouterState.js";
|
|
22
|
-
export { RouterHandlers } from "./RouterBuilder.js";
|
|
23
|
+
export { RouterHandlers, getPrerenderRoutes } from "./RouterBuilder.js";
|
|
23
24
|
export { History as HistoryTag, BrowserHistoryLive, MemoryHistoryLive } from "./History.js";
|
|
24
|
-
export { Navigator as NavigatorTag, NavigatorLive } from "./Navigator.js";
|
|
25
|
+
export { Navigator as NavigatorTag, NavigatorLive, createGo } from "./Navigator.js";
|
|
25
26
|
export { createLink } from "./Link.js";
|
|
27
|
+
// Re-export RouterOutlet component
|
|
26
28
|
export { RouterOutlet, OutletDepth } from "./RouterOutlet.js";
|
|
27
29
|
export { CurrentRouteElement } from "./Router.js";
|
|
28
30
|
// Re-export RouterState utilities for convenience
|
package/dist/router/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,oBAAoB;AACpB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,oBAAoB;AACpB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,oBAAoB;AACpB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,yBAAyB;AACzB,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AAEpD,kBAAkB;AAClB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,oBAAoB;AACpB,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAE5C,4CAA4C;AAC5C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAiBhD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAI5F,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,mCAAmC;AACnC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAa9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,kDAAkD;AAClD,yEAAyE;AACzE,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,GACf,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared router utilities.
|
|
3
|
+
*
|
|
4
|
+
* Consolidates duplicated helpers from Router, Navigator, and Link modules.
|
|
5
|
+
*/
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import type { Route } from "./Route.js";
|
|
8
|
+
import type { Router, AnyGroup } from "./Router.js";
|
|
9
|
+
/**
|
|
10
|
+
* Parse URL search string to a record.
|
|
11
|
+
* Handles both "?foo=bar" and "foo=bar" formats.
|
|
12
|
+
*/
|
|
13
|
+
export declare const parseSearchParams: (search: string) => Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* Build a search string from a params record.
|
|
16
|
+
* Returns "" if no params, or "?key=value&..." otherwise.
|
|
17
|
+
* Filters out null and undefined values.
|
|
18
|
+
*/
|
|
19
|
+
export declare const buildSearchString: (params: Record<string, unknown>) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Strip basePath prefix from pathname for route matching.
|
|
22
|
+
* Returns "/" (not "") when pathname exactly equals basePath.
|
|
23
|
+
*/
|
|
24
|
+
export declare const stripBasePath: (pathname: string, basePath: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Find a route by name across all groups in a router.
|
|
27
|
+
* Returns the route and its group's basePath (empty string for non-layout groups).
|
|
28
|
+
*/
|
|
29
|
+
export declare const findRouteByName: (router: Router<string, never>, name: string) => Option.Option<{
|
|
30
|
+
route: Route<string, Record<string, unknown>, Record<string, unknown>>;
|
|
31
|
+
group: AnyGroup;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the basePath for a group (layout groups have one, regular groups don't).
|
|
35
|
+
*/
|
|
36
|
+
export declare const groupBasePath: (group: AnyGroup) => string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared router utilities.
|
|
3
|
+
*
|
|
4
|
+
* Consolidates duplicated helpers from Router, Navigator, and Link modules.
|
|
5
|
+
*/
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
/**
|
|
8
|
+
* Parse URL search string to a record.
|
|
9
|
+
* Handles both "?foo=bar" and "foo=bar" formats.
|
|
10
|
+
*/
|
|
11
|
+
export const parseSearchParams = (search) => Object.fromEntries(new URLSearchParams(search));
|
|
12
|
+
/**
|
|
13
|
+
* Build a search string from a params record.
|
|
14
|
+
* Returns "" if no params, or "?key=value&..." otherwise.
|
|
15
|
+
* Filters out null and undefined values.
|
|
16
|
+
*/
|
|
17
|
+
export const buildSearchString = (params) => {
|
|
18
|
+
const entries = Object.entries(params).filter(([, v]) => v !== undefined && v !== null);
|
|
19
|
+
if (entries.length === 0)
|
|
20
|
+
return "";
|
|
21
|
+
const sp = new URLSearchParams(entries.map(([k, v]) => [k, String(v)]));
|
|
22
|
+
return `?${sp.toString()}`;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Strip basePath prefix from pathname for route matching.
|
|
26
|
+
* Returns "/" (not "") when pathname exactly equals basePath.
|
|
27
|
+
*/
|
|
28
|
+
export const stripBasePath = (pathname, basePath) => {
|
|
29
|
+
if (!basePath || basePath === "/")
|
|
30
|
+
return pathname;
|
|
31
|
+
const normalizedBase = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
|
|
32
|
+
if (pathname.startsWith(normalizedBase)) {
|
|
33
|
+
return pathname.slice(normalizedBase.length) || "/";
|
|
34
|
+
}
|
|
35
|
+
return pathname;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Find a route by name across all groups in a router.
|
|
39
|
+
* Returns the route and its group's basePath (empty string for non-layout groups).
|
|
40
|
+
*/
|
|
41
|
+
export const findRouteByName = (router, name) => Option.fromNullable(router.groups
|
|
42
|
+
.flatMap((group) => group.routes.filter((route) => route.name === name).map((route) => ({ route, group })))
|
|
43
|
+
.at(0));
|
|
44
|
+
/**
|
|
45
|
+
* Get the basePath for a group (layout groups have one, regular groups don't).
|
|
46
|
+
*/
|
|
47
|
+
export const groupBasePath = (group) => group._tag === "LayoutGroup" ? group.basePath : "";
|
|
48
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/router/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAA0B,EAAE,CAC1E,MAAM,CAAC,WAAW,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,i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AAK,EAAE,EAAE,CACjB,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CACvF;KACA,EAAE,CAAC,CAAC,CAAC,CACT,CAAC;AAEJ;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAe,EAAU,EAAE,CACvD,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import * as Layer from "effect/Layer";
|
|
|
5
5
|
import * as Ref from "effect/Ref";
|
|
6
6
|
import * as Option from "effect/Option";
|
|
7
7
|
import * as Context from "effect/Context";
|
|
8
|
+
import * as Mailbox from "effect/Mailbox";
|
|
9
|
+
import * as RcMap from "effect/RcMap";
|
|
8
10
|
import type * as EffectFiber from "effect/Fiber";
|
|
9
11
|
import type * as Runtime from "effect/Runtime";
|
|
10
12
|
import { Atom, Registry as AtomRegistry, Result } from "@effect-atom/atom";
|
|
@@ -15,8 +17,6 @@ export interface FiberState {
|
|
|
15
17
|
wipRoot: Option.Option<Fiber>;
|
|
16
18
|
nextUnitOfWork: Option.Option<Fiber>;
|
|
17
19
|
deletions: Fiber[];
|
|
18
|
-
renderQueue: Set<Fiber>;
|
|
19
|
-
batchScheduled: boolean;
|
|
20
20
|
listenerStore: WeakMap<HTMLElement, Record<string, EventListener>>;
|
|
21
21
|
}
|
|
22
22
|
export declare const makeFiberState: () => FiberState;
|
|
@@ -32,14 +32,17 @@ declare const FibraeRuntime_base: Effect.Service.Class<FibraeRuntime, "FibraeRun
|
|
|
32
32
|
update: <R, W>(atom: Atom.Writable<R, W>, f: (_: R) => W) => void;
|
|
33
33
|
modify: <R, W, A>(atom: Atom.Writable<R, W>, f: (_: R) => [returnValue: A, nextValue: W]) => A;
|
|
34
34
|
getResult: <A, E>(atom: Atom.Atom<Result.Result<A, E>>, options?: {
|
|
35
|
-
readonly suspendOnWaiting?: boolean;
|
|
36
|
-
}) => Effect.Effect<A, E>;
|
|
37
|
-
toStreamResult: <A, E>(atom: Atom.Atom<Result.Result<A, E>>) => Stream.Stream<A, E>;
|
|
35
|
+
readonly suspendOnWaiting?: boolean | undefined;
|
|
36
|
+
} | undefined) => Effect.Effect<A, E, never>;
|
|
37
|
+
toStreamResult: <A, E>(atom: Atom.Atom<Result.Result<A, E>>) => Stream.Stream<A, E, never>;
|
|
38
38
|
refresh: <A>(atom: Atom.Atom<A>) => void;
|
|
39
39
|
};
|
|
40
40
|
fiberState: Ref.Ref<FiberState>;
|
|
41
|
-
fullContextRef: Ref.Ref<Context.Context<
|
|
42
|
-
|
|
41
|
+
fullContextRef: Ref.Ref<Context.Context<never>>;
|
|
42
|
+
renderMailbox: Mailbox.Mailbox<Fiber, never>;
|
|
43
|
+
sseConnections: RcMap.RcMap<string, EventSource, never>;
|
|
44
|
+
sseWithCredentials: Ref.Ref<boolean>;
|
|
45
|
+
}, never, AtomRegistry.AtomRegistry | Scope.Scope>;
|
|
43
46
|
}>;
|
|
44
47
|
export declare class FibraeRuntime extends FibraeRuntime_base {
|
|
45
48
|
static Live: Layer.Layer<FibraeRuntime, never, AtomRegistry.AtomRegistry>;
|
package/dist/runtime.js
CHANGED
|
@@ -6,6 +6,8 @@ import * as Layer from "effect/Layer";
|
|
|
6
6
|
import * as Ref from "effect/Ref";
|
|
7
7
|
import * as Option from "effect/Option";
|
|
8
8
|
import * as Context from "effect/Context";
|
|
9
|
+
import * as Mailbox from "effect/Mailbox";
|
|
10
|
+
import * as RcMap from "effect/RcMap";
|
|
9
11
|
import { Atom, Registry as AtomRegistry, Result } from "@effect-atom/atom";
|
|
10
12
|
import * as RegistryModule from "@effect-atom/atom/Registry";
|
|
11
13
|
export const makeFiberState = () => ({
|
|
@@ -13,8 +15,6 @@ export const makeFiberState = () => ({
|
|
|
13
15
|
wipRoot: Option.none(),
|
|
14
16
|
nextUnitOfWork: Option.none(),
|
|
15
17
|
deletions: [],
|
|
16
|
-
renderQueue: new Set(),
|
|
17
|
-
batchScheduled: false,
|
|
18
18
|
listenerStore: new WeakMap(),
|
|
19
19
|
});
|
|
20
20
|
// =============================================================================
|
|
@@ -33,6 +33,17 @@ export class FibraeRuntime extends Effect.Service()("FibraeRuntime", {
|
|
|
33
33
|
const fullContextRef = yield* Ref.make(Context.empty());
|
|
34
34
|
// Each render tree gets its own fiber state
|
|
35
35
|
const fiberState = yield* Ref.make(makeFiberState());
|
|
36
|
+
// Mailbox for batching re-render requests (replaces manual Set + queueMicrotask)
|
|
37
|
+
const renderMailbox = yield* Mailbox.make();
|
|
38
|
+
// Reference-counted SSE connections: shared EventSources keyed by URL.
|
|
39
|
+
// Automatically closes EventSource when last consumer releases.
|
|
40
|
+
const sseWithCredentials = yield* Ref.make(false);
|
|
41
|
+
const sseConnections = yield* RcMap.make({
|
|
42
|
+
lookup: (url) => Effect.gen(function* () {
|
|
43
|
+
const withCredentials = yield* Ref.get(sseWithCredentials);
|
|
44
|
+
return yield* Effect.acquireRelease(Effect.sync(() => new EventSource(url, { withCredentials })), (es) => Effect.sync(() => es.close()));
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
36
47
|
const AtomOps = {
|
|
37
48
|
get: (atom) => registry.get(atom),
|
|
38
49
|
set: (atom, value) => registry.set(atom, value),
|
|
@@ -49,6 +60,9 @@ export class FibraeRuntime extends Effect.Service()("FibraeRuntime", {
|
|
|
49
60
|
AtomOps,
|
|
50
61
|
fiberState,
|
|
51
62
|
fullContextRef,
|
|
63
|
+
renderMailbox,
|
|
64
|
+
sseConnections,
|
|
65
|
+
sseWithCredentials,
|
|
52
66
|
};
|
|
53
67
|
}),
|
|
54
68
|
}) {
|
|
@@ -67,6 +81,10 @@ export class FibraeRuntime extends Effect.Service()("FibraeRuntime", {
|
|
|
67
81
|
*
|
|
68
82
|
* IMPORTANT: fullContextRef must be set by render() before this is called.
|
|
69
83
|
*/
|
|
84
|
+
// fullContextRef holds the dynamically-assembled context (FibraeRuntime + user layers).
|
|
85
|
+
// Its static type is Context<never> because the full set of services isn't known until
|
|
86
|
+
// render() composes all layers. The casts below are load-bearing — they bridge the gap
|
|
87
|
+
// between the dynamic context and the type system's static requirements.
|
|
70
88
|
export const runForkWithRuntime = (runtime) => (effect) => {
|
|
71
89
|
const withContext = Effect.gen(function* () {
|
|
72
90
|
const fullContext = yield* Ref.get(runtime.fullContextRef);
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,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