effective-rsc 0.1.3 → 0.1.4
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/LLMS.md +17 -0
- package/README.md +5 -5
- package/dist/application/routes.d.ts +10 -10
- package/dist/application/routes.js.map +1 -1
- package/dist/build/dev.d.ts +4 -4
- package/dist/build/dev.js +22 -7
- package/dist/build/dev.js.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/client/browser-renderer.d.ts +25 -25
- package/dist/client/browser-renderer.js +80 -94
- package/dist/client/browser-renderer.js.map +1 -1
- package/dist/client/call-server.js +7 -5
- package/dist/client/call-server.js.map +1 -1
- package/dist/client/client-router.js +23 -7
- package/dist/client/client-router.js.map +1 -1
- package/dist/client/flight-client.js +3 -4
- package/dist/client/flight-client.js.map +1 -1
- package/dist/client/react-dom-renderer.js +2 -1
- package/dist/client/react-dom-renderer.js.map +1 -1
- package/dist/client/route-refresh.d.ts +2 -2
- package/dist/client/route-refresh.js +54 -39
- package/dist/client/route-refresh.js.map +1 -1
- package/dist/dev/panel.js +14 -14
- package/dist/dev/panel.js.map +1 -1
- package/dist/server/application.d.ts +2 -1
- package/dist/server/application.js +8 -6
- package/dist/server/application.js.map +1 -1
- package/docs/03-advanced/02-client-navigation/index.md +17 -0
- package/package.json +19 -19
package/LLMS.md
CHANGED
|
@@ -279,6 +279,23 @@ These types describe only the first publication. Suspense content that resolves
|
|
|
279
279
|
separate, untyped React Transition. Applications should use their own Suspense-specific
|
|
280
280
|
`<ViewTransition>` boundaries and styling for those reveals.
|
|
281
281
|
|
|
282
|
+
#### Application transition types
|
|
283
|
+
|
|
284
|
+
Add whitespace-separated application transition types to a native link with
|
|
285
|
+
`data-ersc-transition-types`:
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
<a href='/photos/2' data-ersc-transition-types='photo-next'>
|
|
289
|
+
Next photo
|
|
290
|
+
</a>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
These are added alongside ERSC's built-in types for that push or replace navigation and can be
|
|
294
|
+
used in your `<ViewTransition>` type maps. They are not replayed on Back/Forward.
|
|
295
|
+
|
|
296
|
+
The names `navigation`, `navigation-*`, `server-function`, and `hmr-refresh` are reserved for ERSC
|
|
297
|
+
and ignored in the attribute.
|
|
298
|
+
|
|
282
299
|
## Server Function execution and refresh
|
|
283
300
|
|
|
284
301
|
Hydrated invocations and progressively enhanced forms execute the same request-scoped Effect
|
package/README.md
CHANGED
|
@@ -65,11 +65,11 @@ mkdir my-effective-rsc-app
|
|
|
65
65
|
cd my-effective-rsc-app
|
|
66
66
|
bun init -y
|
|
67
67
|
bun add effective-rsc \
|
|
68
|
-
effect@4.0.0-rc.
|
|
69
|
-
@effect/platform-browser@4.0.0-rc.
|
|
70
|
-
@effect/platform-bun@4.0.0-rc.
|
|
71
|
-
react@19.3.0-canary-
|
|
72
|
-
react-dom@19.3.0-canary-
|
|
68
|
+
effect@4.0.0-rc.113 \
|
|
69
|
+
@effect/platform-browser@4.0.0-rc.113 \
|
|
70
|
+
@effect/platform-bun@4.0.0-rc.113 \
|
|
71
|
+
react@19.3.0-canary-1d34f91d-20260909 \
|
|
72
|
+
react-dom@19.3.0-canary-1d34f91d-20260909 \
|
|
73
73
|
react-server-dom-rspack@0.1.0
|
|
74
74
|
bun add --dev \
|
|
75
75
|
typescript@7.0.2 \
|
|
@@ -6,14 +6,14 @@ import type { AnyMiddleware } from './middleware.js';
|
|
|
6
6
|
import { type AnyPageDefinition, type PageConcern } from './page.js';
|
|
7
7
|
import { type AbsolutePath, type JoinPath, type RouteParamNames, type RouteShape, type ValidRoutePath } from './route-path.js';
|
|
8
8
|
declare const RoutesContractTypeId: unique symbol;
|
|
9
|
-
type RoutesState<HasLayout extends boolean, Paths extends AbsolutePath> = {
|
|
9
|
+
type RoutesState<HasLayout extends boolean, Paths extends AbsolutePath, Shapes extends AbsolutePath> = {
|
|
10
10
|
readonly hasLayout: Types.Covariant<HasLayout>;
|
|
11
11
|
readonly paths: Types.Covariant<Paths>;
|
|
12
|
+
readonly shapes: Types.Covariant<Shapes>;
|
|
12
13
|
};
|
|
13
14
|
type MountedPaths<Prefix extends AbsolutePath, Child> = RoutesPaths<Child> extends infer Path extends AbsolutePath ? JoinPath<Prefix, Path> : never;
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
Extract<RouteShapes<Current>, RouteShapes<Added>>
|
|
15
|
+
type NoPathCollision<CurrentShapes extends AbsolutePath, Added extends AbsolutePath> = [
|
|
16
|
+
Extract<RouteShape<Added>, CurrentShapes>
|
|
17
17
|
] extends [never] ? unknown : never;
|
|
18
18
|
type PageParamNames<Page> = Page extends PageConcern<infer ParamNames, infer _Mode> ? ParamNames : never;
|
|
19
19
|
type PageMode<Page> = Page extends PageConcern<infer _ParamNames, infer Mode> ? Mode : never;
|
|
@@ -23,14 +23,14 @@ type ExactPageParamNames<Path extends AbsolutePath, Page> = [RouteParamNames<Pat
|
|
|
23
23
|
type MatchingPageParams<Path extends AbsolutePath, Page> = PageMode<Page> extends 'Static' ? [RouteParamNames<Path>] extends [never] ? unknown : never : PageMode<Page> extends 'Parameterized' ? [RouteParamNames<Path>] extends [never] ? never : ExactPageParamNames<Path, Page> : never;
|
|
24
24
|
type StaticMountPath<Path extends AbsolutePath> = [RouteParamNames<Path>] extends [never] ? unknown : never;
|
|
25
25
|
type KnownNonEmptyRoutes<Definition> = AbsolutePath extends RoutesPaths<Definition> ? never : [RoutesPaths<Definition>] extends [never] ? never : unknown;
|
|
26
|
-
export interface RoutesDefinition<Services, out HasLayout extends boolean, out Paths extends AbsolutePath
|
|
27
|
-
readonly [RoutesContractTypeId]: RoutesState<HasLayout, Paths>;
|
|
28
|
-
page<const Path extends AbsolutePath, const Page extends AnyPageDefinition<Services>>(path: Path & ValidRoutePath<Path> & NoPathCollision<
|
|
29
|
-
mount<const Prefix extends AbsolutePath, const Child extends AnyRoutes<Services>>(path: Prefix & ValidRoutePath<Prefix> & StaticMountPath<Prefix>, routes: Child & KnownNonEmptyRoutes<Child> & NoPathCollision<
|
|
26
|
+
export interface RoutesDefinition<Services, out HasLayout extends boolean, out Paths extends AbsolutePath, out Shapes extends AbsolutePath = RouteShape<Paths>> extends ERSCStatefulMember<Services, 'Routes', RoutesImplementationState<Services>> {
|
|
27
|
+
readonly [RoutesContractTypeId]: RoutesState<HasLayout, Paths, Shapes>;
|
|
28
|
+
page<const Path extends AbsolutePath, const Page extends AnyPageDefinition<Services>>(path: Path & ValidRoutePath<Path> & NoPathCollision<Shapes, Path>, page: Page & MatchingPageParams<Path, Page>): RoutesDefinition<Services, HasLayout, Paths | Path, Shapes | RouteShape<Path>>;
|
|
29
|
+
mount<const Prefix extends AbsolutePath, const Child extends AnyRoutes<Services>>(path: Prefix & ValidRoutePath<Prefix> & StaticMountPath<Prefix>, routes: Child & KnownNonEmptyRoutes<Child> & NoPathCollision<Shapes, MountedPaths<Prefix, Child>>): RoutesDefinition<Services, HasLayout, Paths | MountedPaths<Prefix, Child>, Shapes | RouteShape<MountedPaths<Prefix, Child>>>;
|
|
30
30
|
}
|
|
31
31
|
export type AnyRoutes<Services> = RoutesDefinition<Services, boolean, AbsolutePath>;
|
|
32
|
-
export type RoutesHasLayout<Definition> = Definition extends RoutesDefinition<infer _Services, infer HasLayout, infer _Paths> ? HasLayout : never;
|
|
33
|
-
export type RoutesPaths<Definition> = Definition extends RoutesDefinition<infer _Services, infer _HasLayout, infer Paths> ? Paths : never;
|
|
32
|
+
export type RoutesHasLayout<Definition> = Definition extends RoutesDefinition<infer _Services, infer HasLayout, infer _Paths, infer _Shapes> ? HasLayout : never;
|
|
33
|
+
export type RoutesPaths<Definition> = Definition extends RoutesDefinition<infer _Services, infer _HasLayout, infer Paths, infer _Shapes> ? Paths : never;
|
|
34
34
|
type RoutesPage<Services> = {
|
|
35
35
|
readonly page: AnyPageDefinition<Services>;
|
|
36
36
|
readonly path: AbsolutePath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application/routes.js","sources":["../../src/application/routes.ts"],"sourcesContent":["import { type Types } from 'effect';\n\nimport {\n type ERSCIdentity,\n ERSCIdentityTypeId,\n ERSCMemberKindTypeId,\n type ERSCStatefulMember,\n ERSCStateTypeId,\n getERSCIdentity,\n isERSCMember,\n} from './ersc-identity';\nimport type { LayoutComponent } from './layout';\nimport type { LoadingComponent } from './loading';\nimport type { AnyMiddleware } from './middleware';\nimport { type AnyPageDefinition, getPageState, type PageConcern } from './page';\nimport {\n type AbsolutePath,\n analyzeRoutePath,\n joinRoutePaths,\n type JoinPath,\n type RouteParamNames,\n type RouteShape,\n type ValidRoutePath,\n} from './route-path';\n\ndeclare const RoutesContractTypeId: unique symbol;\n\ntype RoutesState<HasLayout extends boolean, Paths extends AbsolutePath> = {\n readonly hasLayout: Types.Covariant<HasLayout>;\n readonly paths: Types.Covariant<Paths>;\n};\n\ntype MountedPaths<Prefix extends AbsolutePath, Child> =\n RoutesPaths<Child> extends infer Path extends AbsolutePath ? JoinPath<Prefix, Path> : never;\n\ntype RouteShapes<Paths extends AbsolutePath> = Paths extends AbsolutePath\n ? RouteShape<Paths>\n : never;\n\ntype NoPathCollision<Current extends AbsolutePath, Added extends AbsolutePath> = [\n Extract<RouteShapes<Current>, RouteShapes<Added>>,\n] extends [never]\n ? unknown\n : never;\n\ntype PageParamNames<Page> =\n Page extends PageConcern<infer ParamNames, infer _Mode> ? ParamNames : never;\n\ntype PageMode<Page> = Page extends PageConcern<infer _ParamNames, infer Mode> ? Mode : never;\n\ntype ExactPageParamNames<Path extends AbsolutePath, Page> = [RouteParamNames<Path>] extends [\n PageParamNames<Page>,\n]\n ? [PageParamNames<Page>] extends [RouteParamNames<Path>]\n ? unknown\n : never\n : never;\n\ntype MatchingPageParams<Path extends AbsolutePath, Page> =\n PageMode<Page> extends 'Static'\n ? [RouteParamNames<Path>] extends [never]\n ? unknown\n : never\n : PageMode<Page> extends 'Parameterized'\n ? [RouteParamNames<Path>] extends [never]\n ? never\n : ExactPageParamNames<Path, Page>\n : never;\n\ntype StaticMountPath<Path extends AbsolutePath> = [RouteParamNames<Path>] extends [never]\n ? unknown\n : never;\n\ntype KnownNonEmptyRoutes<Definition> =\n AbsolutePath extends RoutesPaths<Definition>\n ? never\n : [RoutesPaths<Definition>] extends [never]\n ? never\n : unknown;\n\nexport interface RoutesDefinition<\n Services,\n out HasLayout extends boolean,\n out Paths extends AbsolutePath,\n> extends ERSCStatefulMember<Services, 'Routes', RoutesImplementationState<Services>> {\n readonly [RoutesContractTypeId]: RoutesState<HasLayout, Paths>;\n\n page<const Path extends AbsolutePath, const Page extends AnyPageDefinition<Services>>(\n path: Path & ValidRoutePath<Path> & NoPathCollision<Paths, Path>,\n page: Page & MatchingPageParams<Path, Page>,\n ): RoutesDefinition<Services, HasLayout, Paths | Path>;\n\n mount<const Prefix extends AbsolutePath, const Child extends AnyRoutes<Services>>(\n path: Prefix & ValidRoutePath<Prefix> & StaticMountPath<Prefix>,\n routes: Child &\n KnownNonEmptyRoutes<Child> &\n NoPathCollision<Paths, MountedPaths<Prefix, Child>>,\n ): RoutesDefinition<Services, HasLayout, Paths | MountedPaths<Prefix, Child>>;\n}\n\nexport type AnyRoutes<Services> = RoutesDefinition<Services, boolean, AbsolutePath>;\n\nexport type RoutesHasLayout<Definition> =\n Definition extends RoutesDefinition<infer _Services, infer HasLayout, infer _Paths>\n ? HasLayout\n : never;\n\nexport type RoutesPaths<Definition> =\n Definition extends RoutesDefinition<infer _Services, infer _HasLayout, infer Paths>\n ? Paths\n : never;\n\ntype RoutesPage<Services> = {\n readonly page: AnyPageDefinition<Services>;\n readonly path: AbsolutePath;\n};\n\ntype RoutesMount<Services> = {\n readonly path: AbsolutePath;\n readonly routes: AnyRoutes<Services>;\n};\n\nexport type RoutesImplementationState<Services> = {\n readonly layout: LayoutComponent<Services> | null;\n readonly loading: LoadingComponent<Services> | null;\n readonly middleware: ReadonlyArray<AnyMiddleware<Services>>;\n readonly mounts: ReadonlyArray<RoutesMount<Services>>;\n readonly pages: ReadonlyArray<RoutesPage<Services>>;\n readonly paths: ReadonlyArray<AbsolutePath>;\n readonly scopeId: number;\n};\n\ntype RoutesOptions<Services> = {\n readonly layout?: LayoutComponent<Services>;\n readonly loading?: LoadingComponent<Services>;\n};\n\ntype HasLayoutFromOptions<Options> = Options extends { readonly layout: unknown } ? true : false;\n\ntype RuntimeRoutesOptions<Services> = RoutesImplementationState<Services> & {\n readonly routeShapes: ReadonlySet<string>;\n};\n\nclass RoutesDefinitionImpl<\n Services,\n HasLayout extends boolean,\n Paths extends AbsolutePath,\n> implements RoutesDefinition<Services, HasLayout, Paths> {\n declare readonly [RoutesContractTypeId]: RoutesState<HasLayout, Paths>;\n readonly [ERSCIdentityTypeId]: ERSCIdentity<Services>;\n readonly [ERSCMemberKindTypeId] = 'Routes' as const;\n get [ERSCStateTypeId](): RoutesImplementationState<Services> {\n return this;\n }\n\n readonly layout: LayoutComponent<Services> | null;\n readonly loading: LoadingComponent<Services> | null;\n readonly middleware: ReadonlyArray<AnyMiddleware<Services>>;\n readonly mounts: ReadonlyArray<RoutesMount<Services>>;\n readonly pages: ReadonlyArray<RoutesPage<Services>>;\n readonly paths: ReadonlyArray<AbsolutePath>;\n readonly scopeId: number;\n readonly #routeShapes: ReadonlySet<string>;\n\n constructor(\n identity: ERSCIdentity<Services>,\n {\n layout,\n loading,\n middleware,\n mounts,\n pages,\n paths,\n routeShapes,\n scopeId,\n }: RuntimeRoutesOptions<Services>,\n ) {\n this[ERSCIdentityTypeId] = identity;\n this.layout = layout;\n this.loading = loading;\n this.middleware = middleware;\n this.mounts = mounts;\n this.pages = pages;\n this.paths = paths;\n this.scopeId = scopeId;\n this.#routeShapes = routeShapes;\n Object.freeze(this);\n }\n\n page<const Path extends AbsolutePath, const Page extends AnyPageDefinition<Services>>(\n path: Path & ValidRoutePath<Path> & NoPathCollision<Paths, Path>,\n page: Page & MatchingPageParams<Path, Page>,\n ): RoutesDefinitionImpl<Services, HasLayout, Paths | Path> {\n const route = analyzeRoutePath(path);\n if (this.#routeShapes.has(route.shape)) {\n throw new TypeError(`Route \"${path}\" conflicts with an existing route pattern.`);\n }\n const pageState = getPageState(page);\n if (getERSCIdentity(page) !== this[ERSCIdentityTypeId]) {\n throw new TypeError(`Page for \"${path}\" was created by a different ERSC module.`);\n }\n\n if (route._tag === 'ParameterFree' && pageState.paramsSchema !== null) {\n throw new TypeError(`Parameterized Page for \"${path}\" requires route parameters.`);\n }\n if (route._tag === 'Parameterized' && pageState.paramsSchema === null) {\n throw new TypeError(`Page for \"${path}\" must declare a parameter Schema.`);\n }\n\n const routeShapes = new Set(this.#routeShapes);\n routeShapes.add(route.shape);\n\n return new RoutesDefinitionImpl(this[ERSCIdentityTypeId], {\n layout: this.layout,\n loading: this.loading,\n middleware: this.middleware,\n mounts: this.mounts,\n pages: Object.freeze([...this.pages, Object.freeze({ page, path })]),\n paths: Object.freeze([...this.paths, path]),\n routeShapes,\n scopeId: this.scopeId,\n });\n }\n\n mount<const Prefix extends AbsolutePath, const Child extends AnyRoutes<Services>>(\n path: Prefix & ValidRoutePath<Prefix> & StaticMountPath<Prefix>,\n routes: Child &\n KnownNonEmptyRoutes<Child> &\n NoPathCollision<Paths, MountedPaths<Prefix, Child>>,\n ): RoutesDefinitionImpl<Services, HasLayout, Paths | MountedPaths<Prefix, Child>> {\n const route = analyzeRoutePath(path);\n if (route._tag === 'Parameterized') {\n throw new TypeError(`Routes cannot be mounted beneath parameterized path \"${path}\".`);\n }\n const routesState = getRoutesState(routes);\n if (routesState.paths.length === 0) {\n throw new TypeError(`Cannot mount empty Routes at \"${path}\".`);\n }\n if (getERSCIdentity(routes) !== this[ERSCIdentityTypeId]) {\n throw new TypeError(`Routes mounted at \"${path}\" were created by a different ERSC module.`);\n }\n\n const mountedPaths = routesState.paths.map((childPath) => joinRoutePaths(path, childPath));\n const routeShapes = new Set(this.#routeShapes);\n for (const mountedPath of mountedPaths) {\n const shape = analyzeRoutePath(mountedPath).shape;\n if (routeShapes.has(shape)) {\n throw new TypeError(`Route \"${mountedPath}\" conflicts with an existing route pattern.`);\n }\n routeShapes.add(shape);\n }\n\n return new RoutesDefinitionImpl(this[ERSCIdentityTypeId], {\n layout: this.layout,\n loading: this.loading,\n middleware: this.middleware,\n mounts: Object.freeze([...this.mounts, Object.freeze({ path, routes })]),\n pages: this.pages,\n paths: Object.freeze([...this.paths, ...mountedPaths]),\n routeShapes,\n scopeId: this.scopeId,\n });\n }\n}\n\nexport const getRoutesState = <Services>(\n routes: AnyRoutes<Services>,\n): RoutesImplementationState<Services> => {\n if (!isERSCMember(routes, 'Routes')) {\n throw new TypeError('Routes must be created with ERSC.Routes.make.');\n }\n return routes[ERSCStateTypeId];\n};\n\nexport type RoutesFactory<Services> = {\n readonly make: {\n (): RoutesDefinition<Services, false, never>;\n <Options extends RoutesOptions<Services>>(\n options: Options,\n ): RoutesDefinition<Services, HasLayoutFromOptions<Options>, never>;\n };\n};\n\nexport const makeRoutesFactory = <Services>(\n identity: ERSCIdentity<Services>,\n middleware: ReadonlyArray<AnyMiddleware<Services>>,\n allocateScopeId: () => number,\n): RoutesFactory<Services> => {\n function make(): RoutesDefinition<Services, false, never>;\n function make<Options extends RoutesOptions<Services>>(\n options: Options,\n ): RoutesDefinition<Services, HasLayoutFromOptions<Options>, never>;\n function make(options: RoutesOptions<Services> = {}): AnyRoutes<Services> {\n if (options.layout !== undefined) {\n if (!isERSCMember(options.layout, 'Layout')) {\n throw new TypeError('Layout must be created with ERSC.Layout.make.');\n }\n if (getERSCIdentity(options.layout) !== identity) {\n throw new TypeError('Layout was created by a different ERSC module.');\n }\n }\n if (options.loading !== undefined) {\n if (!isERSCMember(options.loading, 'Loading')) {\n throw new TypeError('Loading must be created with ERSC.Loading.make.');\n }\n if (getERSCIdentity(options.loading) !== identity) {\n throw new TypeError('Loading was created by a different ERSC module.');\n }\n }\n const scopeId = allocateScopeId();\n\n return new RoutesDefinitionImpl(identity, {\n layout: options.layout ?? null,\n loading: options.loading ?? null,\n middleware,\n mounts: Object.freeze([]),\n pages: Object.freeze([]),\n paths: Object.freeze([]),\n routeShapes: new Set(),\n scopeId,\n });\n }\n\n return { make };\n};\n"],"names":["ERSCIdentityTypeId","ERSCMemberKindTypeId","ERSCStateTypeId","getERSCIdentity","isERSCMember","getPageState","analyzeRoutePath","joinRoutePaths","RoutesDefinitionImpl","identity","layout","loading","middleware","mounts","pages","paths","routeShapes","scopeId","Object","path","page","route","TypeError","pageState","Set","routes","routesState","getRoutesState","mountedPaths","childPath","mountedPath","shape","makeRoutesFactory","allocateScopeId","make","options","undefined"],"mappings":";;;;;;;AAUyB;AAIuD;AAS1D;AAwHtB,MAAMQ,oBAAoBA;IAMf,CAACR,kBAAkBA,CAAC,CAAyB;IAC7C,CAACC,oBAAoBA,CAAC,GAAG,SAAkB;IACpD,IAAI,CAACC,eAAeA,CAAC,GAAwC;QAC3D,OAAO,IAAI;IACb;IAES,OAAyC;IACzC,QAA2C;IAC3C,WAAmD;IACnD,OAA6C;IAC7C,MAA2C;IAC3C,MAAmC;IACnC,QAAgB;IAChB,YAAY,CAAsB;IAE3C,YACEO,QAAgC,EAChC,EACEC,MAAM,EACNC,OAAO,EACPC,UAAU,EACVC,MAAM,EACNC,KAAK,EACLC,KAAK,EACLC,WAAW,EACXC,OAAO,EACwB,CACjC;QACA,IAAI,CAACjB,kBAAkBA,CAAC,GAAGS;QAC3B,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,OAAO,GAAGC;QACf,IAAI,CAAC,UAAU,GAAGC;QAClB,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,KAAK,GAAGC;QACb,IAAI,CAAC,KAAK,GAAGC;QACb,IAAI,CAAC,OAAO,GAAGE;QACf,IAAI,CAAC,YAAY,GAAGD;QACpBE,OAAO,MAAM,CAAC,IAAI;IACpB;IAEA,KACEC,IAAgE,EAChEC,IAA2C,EACc;QACzD,MAAMC,QAAQf,gBAAgBA,CAACa;QAC/B,IAAI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MAAM,IAAIH,UAAU;IACtB;IACA,OAAOG,MAAM,CAACvB,eAAeA,CAAC;AAChC,EAAE;AAWK,MAAM8B,iBAAiBA,GAAG,CAC/BvB,UACAG,YACAqB;IAMA,SAASC,KAAKC,UAAmC,CAAC,CAAC;QACjD,IAAIA,QAAQ,MAAM,KAAKC,WAAW;YAChC,IAAI,CAAChC,YAAYA,CAAC+B,QAAQ,MAAM,EAAE,WAAW;gBAC3C,MAAM,IAAIb,UAAU;YACtB;YACA,IAAInB,eAAeA,CAACgC,QAAQ,MAAM,MAAM1B,UAAU;gBAChD,MAAM,IAAIa,UAAU;YACtB;QACF;QACA,IAAIa,QAAQ,OAAO,KAAKC,WAAW;YACjC,IAAI,CAAChC,YAAYA,CAAC+B,QAAQ,OAAO,EAAE,YAAY;gBAC7C,MAAM,IAAIb,UAAU;YACtB;YACA,IAAInB,eAAeA,CAACgC,QAAQ,OAAO,MAAM1B,UAAU;gBACjD,MAAM,IAAIa,UAAU;YACtB;QACF;QACA,MAAML,UAAUgB;QAEhB,OAAO,IAAIzB,oBAAoBA,CAACC,UAAU;YACxC,QAAQ0B,QAAQ,MAAM,IAAI;YAC1B,SAASA,QAAQ,OAAO,IAAI;YAC5BvB;YACA,QAAQM,OAAO,MAAM,CAAC,EAAE;YACxB,OAAOA,OAAO,MAAM,CAAC,EAAE;YACvB,OAAOA,OAAO,MAAM,CAAC,EAAE;YACvB,aAAa,IAAIM;YACjBP;QACF;IACF;IAEA,OAAO;QAAEiB;IAAK;AAChB,EAAE"}
|
|
1
|
+
{"version":3,"file":"application/routes.js","sources":["../../src/application/routes.ts"],"sourcesContent":["import { type Types } from 'effect';\n\nimport {\n type ERSCIdentity,\n ERSCIdentityTypeId,\n ERSCMemberKindTypeId,\n type ERSCStatefulMember,\n ERSCStateTypeId,\n getERSCIdentity,\n isERSCMember,\n} from './ersc-identity';\nimport type { LayoutComponent } from './layout';\nimport type { LoadingComponent } from './loading';\nimport type { AnyMiddleware } from './middleware';\nimport { type AnyPageDefinition, getPageState, type PageConcern } from './page';\nimport {\n type AbsolutePath,\n analyzeRoutePath,\n joinRoutePaths,\n type JoinPath,\n type RouteParamNames,\n type RouteShape,\n type ValidRoutePath,\n} from './route-path';\n\ndeclare const RoutesContractTypeId: unique symbol;\n\ntype RoutesState<\n HasLayout extends boolean,\n Paths extends AbsolutePath,\n Shapes extends AbsolutePath,\n> = {\n readonly hasLayout: Types.Covariant<HasLayout>;\n readonly paths: Types.Covariant<Paths>;\n readonly shapes: Types.Covariant<Shapes>;\n};\n\ntype MountedPaths<Prefix extends AbsolutePath, Child> =\n RoutesPaths<Child> extends infer Path extends AbsolutePath ? JoinPath<Prefix, Path> : never;\n\ntype NoPathCollision<CurrentShapes extends AbsolutePath, Added extends AbsolutePath> = [\n Extract<RouteShape<Added>, CurrentShapes>,\n] extends [never]\n ? unknown\n : never;\n\ntype PageParamNames<Page> =\n Page extends PageConcern<infer ParamNames, infer _Mode> ? ParamNames : never;\n\ntype PageMode<Page> = Page extends PageConcern<infer _ParamNames, infer Mode> ? Mode : never;\n\ntype ExactPageParamNames<Path extends AbsolutePath, Page> = [RouteParamNames<Path>] extends [\n PageParamNames<Page>,\n]\n ? [PageParamNames<Page>] extends [RouteParamNames<Path>]\n ? unknown\n : never\n : never;\n\ntype MatchingPageParams<Path extends AbsolutePath, Page> =\n PageMode<Page> extends 'Static'\n ? [RouteParamNames<Path>] extends [never]\n ? unknown\n : never\n : PageMode<Page> extends 'Parameterized'\n ? [RouteParamNames<Path>] extends [never]\n ? never\n : ExactPageParamNames<Path, Page>\n : never;\n\ntype StaticMountPath<Path extends AbsolutePath> = [RouteParamNames<Path>] extends [never]\n ? unknown\n : never;\n\ntype KnownNonEmptyRoutes<Definition> =\n AbsolutePath extends RoutesPaths<Definition>\n ? never\n : [RoutesPaths<Definition>] extends [never]\n ? never\n : unknown;\n\nexport interface RoutesDefinition<\n Services,\n out HasLayout extends boolean,\n out Paths extends AbsolutePath,\n // Retain each matcher shape so additions do not recompute every earlier path's shape.\n out Shapes extends AbsolutePath = RouteShape<Paths>,\n> extends ERSCStatefulMember<Services, 'Routes', RoutesImplementationState<Services>> {\n readonly [RoutesContractTypeId]: RoutesState<HasLayout, Paths, Shapes>;\n\n page<const Path extends AbsolutePath, const Page extends AnyPageDefinition<Services>>(\n path: Path & ValidRoutePath<Path> & NoPathCollision<Shapes, Path>,\n page: Page & MatchingPageParams<Path, Page>,\n ): RoutesDefinition<Services, HasLayout, Paths | Path, Shapes | RouteShape<Path>>;\n\n mount<const Prefix extends AbsolutePath, const Child extends AnyRoutes<Services>>(\n path: Prefix & ValidRoutePath<Prefix> & StaticMountPath<Prefix>,\n routes: Child &\n KnownNonEmptyRoutes<Child> &\n NoPathCollision<Shapes, MountedPaths<Prefix, Child>>,\n ): RoutesDefinition<\n Services,\n HasLayout,\n Paths | MountedPaths<Prefix, Child>,\n Shapes | RouteShape<MountedPaths<Prefix, Child>>\n >;\n}\n\nexport type AnyRoutes<Services> = RoutesDefinition<Services, boolean, AbsolutePath>;\n\nexport type RoutesHasLayout<Definition> =\n Definition extends RoutesDefinition<infer _Services, infer HasLayout, infer _Paths, infer _Shapes>\n ? HasLayout\n : never;\n\nexport type RoutesPaths<Definition> =\n Definition extends RoutesDefinition<infer _Services, infer _HasLayout, infer Paths, infer _Shapes>\n ? Paths\n : never;\n\ntype RoutesPage<Services> = {\n readonly page: AnyPageDefinition<Services>;\n readonly path: AbsolutePath;\n};\n\ntype RoutesMount<Services> = {\n readonly path: AbsolutePath;\n readonly routes: AnyRoutes<Services>;\n};\n\nexport type RoutesImplementationState<Services> = {\n readonly layout: LayoutComponent<Services> | null;\n readonly loading: LoadingComponent<Services> | null;\n readonly middleware: ReadonlyArray<AnyMiddleware<Services>>;\n readonly mounts: ReadonlyArray<RoutesMount<Services>>;\n readonly pages: ReadonlyArray<RoutesPage<Services>>;\n readonly paths: ReadonlyArray<AbsolutePath>;\n readonly scopeId: number;\n};\n\ntype RoutesOptions<Services> = {\n readonly layout?: LayoutComponent<Services>;\n readonly loading?: LoadingComponent<Services>;\n};\n\ntype HasLayoutFromOptions<Options> = Options extends { readonly layout: unknown } ? true : false;\n\ntype RuntimeRoutesOptions<Services> = RoutesImplementationState<Services> & {\n readonly routeShapes: ReadonlySet<string>;\n};\n\nclass RoutesDefinitionImpl<\n Services,\n HasLayout extends boolean,\n Paths extends AbsolutePath,\n Shapes extends AbsolutePath = RouteShape<Paths>,\n> implements RoutesDefinition<Services, HasLayout, Paths, Shapes> {\n declare readonly [RoutesContractTypeId]: RoutesState<HasLayout, Paths, Shapes>;\n readonly [ERSCIdentityTypeId]: ERSCIdentity<Services>;\n readonly [ERSCMemberKindTypeId] = 'Routes' as const;\n get [ERSCStateTypeId](): RoutesImplementationState<Services> {\n return this;\n }\n\n readonly layout: LayoutComponent<Services> | null;\n readonly loading: LoadingComponent<Services> | null;\n readonly middleware: ReadonlyArray<AnyMiddleware<Services>>;\n readonly mounts: ReadonlyArray<RoutesMount<Services>>;\n readonly pages: ReadonlyArray<RoutesPage<Services>>;\n readonly paths: ReadonlyArray<AbsolutePath>;\n readonly scopeId: number;\n readonly #routeShapes: ReadonlySet<string>;\n\n constructor(\n identity: ERSCIdentity<Services>,\n {\n layout,\n loading,\n middleware,\n mounts,\n pages,\n paths,\n routeShapes,\n scopeId,\n }: RuntimeRoutesOptions<Services>,\n ) {\n this[ERSCIdentityTypeId] = identity;\n this.layout = layout;\n this.loading = loading;\n this.middleware = middleware;\n this.mounts = mounts;\n this.pages = pages;\n this.paths = paths;\n this.scopeId = scopeId;\n this.#routeShapes = routeShapes;\n Object.freeze(this);\n }\n\n page<const Path extends AbsolutePath, const Page extends AnyPageDefinition<Services>>(\n path: Path & ValidRoutePath<Path> & NoPathCollision<Shapes, Path>,\n page: Page & MatchingPageParams<Path, Page>,\n ): RoutesDefinitionImpl<Services, HasLayout, Paths | Path, Shapes | RouteShape<Path>> {\n const route = analyzeRoutePath(path);\n if (this.#routeShapes.has(route.shape)) {\n throw new TypeError(`Route \"${path}\" conflicts with an existing route pattern.`);\n }\n const pageState = getPageState(page);\n if (getERSCIdentity(page) !== this[ERSCIdentityTypeId]) {\n throw new TypeError(`Page for \"${path}\" was created by a different ERSC module.`);\n }\n\n if (route._tag === 'ParameterFree' && pageState.paramsSchema !== null) {\n throw new TypeError(`Parameterized Page for \"${path}\" requires route parameters.`);\n }\n if (route._tag === 'Parameterized' && pageState.paramsSchema === null) {\n throw new TypeError(`Page for \"${path}\" must declare a parameter Schema.`);\n }\n\n const routeShapes = new Set(this.#routeShapes);\n routeShapes.add(route.shape);\n\n return new RoutesDefinitionImpl(this[ERSCIdentityTypeId], {\n layout: this.layout,\n loading: this.loading,\n middleware: this.middleware,\n mounts: this.mounts,\n pages: Object.freeze([...this.pages, Object.freeze({ page, path })]),\n paths: Object.freeze([...this.paths, path]),\n routeShapes,\n scopeId: this.scopeId,\n });\n }\n\n mount<const Prefix extends AbsolutePath, const Child extends AnyRoutes<Services>>(\n path: Prefix & ValidRoutePath<Prefix> & StaticMountPath<Prefix>,\n routes: Child &\n KnownNonEmptyRoutes<Child> &\n NoPathCollision<Shapes, MountedPaths<Prefix, Child>>,\n ): RoutesDefinitionImpl<\n Services,\n HasLayout,\n Paths | MountedPaths<Prefix, Child>,\n Shapes | RouteShape<MountedPaths<Prefix, Child>>\n > {\n const route = analyzeRoutePath(path);\n if (route._tag === 'Parameterized') {\n throw new TypeError(`Routes cannot be mounted beneath parameterized path \"${path}\".`);\n }\n const routesState = getRoutesState(routes);\n if (routesState.paths.length === 0) {\n throw new TypeError(`Cannot mount empty Routes at \"${path}\".`);\n }\n if (getERSCIdentity(routes) !== this[ERSCIdentityTypeId]) {\n throw new TypeError(`Routes mounted at \"${path}\" were created by a different ERSC module.`);\n }\n\n const mountedPaths = routesState.paths.map((childPath) => joinRoutePaths(path, childPath));\n const routeShapes = new Set(this.#routeShapes);\n for (const mountedPath of mountedPaths) {\n const shape = analyzeRoutePath(mountedPath).shape;\n if (routeShapes.has(shape)) {\n throw new TypeError(`Route \"${mountedPath}\" conflicts with an existing route pattern.`);\n }\n routeShapes.add(shape);\n }\n\n return new RoutesDefinitionImpl(this[ERSCIdentityTypeId], {\n layout: this.layout,\n loading: this.loading,\n middleware: this.middleware,\n mounts: Object.freeze([...this.mounts, Object.freeze({ path, routes })]),\n pages: this.pages,\n paths: Object.freeze([...this.paths, ...mountedPaths]),\n routeShapes,\n scopeId: this.scopeId,\n });\n }\n}\n\nexport const getRoutesState = <Services>(\n routes: AnyRoutes<Services>,\n): RoutesImplementationState<Services> => {\n if (!isERSCMember(routes, 'Routes')) {\n throw new TypeError('Routes must be created with ERSC.Routes.make.');\n }\n return routes[ERSCStateTypeId];\n};\n\nexport type RoutesFactory<Services> = {\n readonly make: {\n (): RoutesDefinition<Services, false, never>;\n <Options extends RoutesOptions<Services>>(\n options: Options,\n ): RoutesDefinition<Services, HasLayoutFromOptions<Options>, never>;\n };\n};\n\nexport const makeRoutesFactory = <Services>(\n identity: ERSCIdentity<Services>,\n middleware: ReadonlyArray<AnyMiddleware<Services>>,\n allocateScopeId: () => number,\n): RoutesFactory<Services> => {\n function make(): RoutesDefinition<Services, false, never>;\n function make<Options extends RoutesOptions<Services>>(\n options: Options,\n ): RoutesDefinition<Services, HasLayoutFromOptions<Options>, never>;\n function make(options: RoutesOptions<Services> = {}): AnyRoutes<Services> {\n if (options.layout !== undefined) {\n if (!isERSCMember(options.layout, 'Layout')) {\n throw new TypeError('Layout must be created with ERSC.Layout.make.');\n }\n if (getERSCIdentity(options.layout) !== identity) {\n throw new TypeError('Layout was created by a different ERSC module.');\n }\n }\n if (options.loading !== undefined) {\n if (!isERSCMember(options.loading, 'Loading')) {\n throw new TypeError('Loading must be created with ERSC.Loading.make.');\n }\n if (getERSCIdentity(options.loading) !== identity) {\n throw new TypeError('Loading was created by a different ERSC module.');\n }\n }\n const scopeId = allocateScopeId();\n\n return new RoutesDefinitionImpl(identity, {\n layout: options.layout ?? null,\n loading: options.loading ?? null,\n middleware,\n mounts: Object.freeze([]),\n pages: Object.freeze([]),\n paths: Object.freeze([]),\n routeShapes: new Set(),\n scopeId,\n });\n }\n\n return { make };\n};\n"],"names":["ERSCIdentityTypeId","ERSCMemberKindTypeId","ERSCStateTypeId","getERSCIdentity","isERSCMember","getPageState","analyzeRoutePath","joinRoutePaths","RoutesDefinitionImpl","identity","layout","loading","middleware","mounts","pages","paths","routeShapes","scopeId","Object","path","page","route","TypeError","pageState","Set","routes","routesState","getRoutesState","mountedPaths","childPath","mountedPath","shape","makeRoutesFactory","allocateScopeId","make","options","undefined"],"mappings":";;;;;;;AAUyB;AAIuD;AAS1D;AAgItB,MAAMQ,oBAAoBA;IAOf,CAACR,kBAAkBA,CAAC,CAAyB;IAC7C,CAACC,oBAAoBA,CAAC,GAAG,SAAkB;IACpD,IAAI,CAACC,eAAeA,CAAC,GAAwC;QAC3D,OAAO,IAAI;IACb;IAES,OAAyC;IACzC,QAA2C;IAC3C,WAAmD;IACnD,OAA6C;IAC7C,MAA2C;IAC3C,MAAmC;IACnC,QAAgB;IAChB,YAAY,CAAsB;IAE3C,YACEO,QAAgC,EAChC,EACEC,MAAM,EACNC,OAAO,EACPC,UAAU,EACVC,MAAM,EACNC,KAAK,EACLC,KAAK,EACLC,WAAW,EACXC,OAAO,EACwB,CACjC;QACA,IAAI,CAACjB,kBAAkBA,CAAC,GAAGS;QAC3B,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,OAAO,GAAGC;QACf,IAAI,CAAC,UAAU,GAAGC;QAClB,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,KAAK,GAAGC;QACb,IAAI,CAAC,KAAK,GAAGC;QACb,IAAI,CAAC,OAAO,GAAGE;QACf,IAAI,CAAC,YAAY,GAAGD;QACpBE,OAAO,MAAM,CAAC,IAAI;IACpB;IAEA,KACEC,IAAiE,EACjEC,IAA2C,EACyC;QACpF,MAAMC,QAAQf,gBAAgBA,CAACa;QAC/B,IAAI,IAAI,CAAC,YAAY,C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tB;IACA,OAAOG,MAAM,CAACvB,eAAeA,CAAC;AAChC,EAAE;AAWK,MAAM8B,iBAAiBA,GAAG,CAC/BvB,UACAG,YACAqB;IAMA,SAASC,KAAKC,UAAmC,CAAC,CAAC;QACjD,IAAIA,QAAQ,MAAM,KAAKC,WAAW;YAChC,IAAI,CAAChC,YAAYA,CAAC+B,QAAQ,MAAM,EAAE,WAAW;gBAC3C,MAAM,IAAIb,UAAU;YACtB;YACA,IAAInB,eAAeA,CAACgC,QAAQ,MAAM,MAAM1B,UAAU;gBAChD,MAAM,IAAIa,UAAU;YACtB;QACF;QACA,IAAIa,QAAQ,OAAO,KAAKC,WAAW;YACjC,IAAI,CAAChC,YAAYA,CAAC+B,QAAQ,OAAO,EAAE,YAAY;gBAC7C,MAAM,IAAIb,UAAU;YACtB;YACA,IAAInB,eAAeA,CAACgC,QAAQ,OAAO,MAAM1B,UAAU;gBACjD,MAAM,IAAIa,UAAU;YACtB;QACF;QACA,MAAML,UAAUgB;QAEhB,OAAO,IAAIzB,oBAAoBA,CAACC,UAAU;YACxC,QAAQ0B,QAAQ,MAAM,IAAI;YAC1B,SAASA,QAAQ,OAAO,IAAI;YAC5BvB;YACA,QAAQM,OAAO,MAAM,CAAC,EAAE;YACxB,OAAOA,OAAO,MAAM,CAAC,EAAE;YACvB,OAAOA,OAAO,MAAM,CAAC,EAAE;YACvB,aAAa,IAAIM;YACjBP;QACF;IACF;IAEA,OAAO;QAAEiB;IAAK;AAChB,EAAE"}
|
package/dist/build/dev.d.ts
CHANGED
|
@@ -30,12 +30,12 @@ export declare const makeDevGenerationStore: (options: DevGenerationOptions) =>
|
|
|
30
30
|
export declare const makeDevApplication: (args_0: DevGenerationOptions) => Effect.Effect<{
|
|
31
31
|
closeDevChannel: Effect.Effect<void, never, never>;
|
|
32
32
|
httpEffect: Effect.Effect<HttpServerResponse.HttpServerResponse, import("./compiled-server.js").CompiledServerError | DevGenerationError | import("effect/unstable/http/HttpServerError").HttpServerError | RspackError, import("effect/unstable/http/HttpServerRequest").HttpServerRequest | Scope.Scope>;
|
|
33
|
-
watch: Effect.Effect<void,
|
|
33
|
+
watch: Effect.Effect<void, DevGenerationFailure, FileSystem.FileSystem | Path.Path>;
|
|
34
34
|
}, import("./build.js").BuildEntryError | import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path | Rspack | Scope.Scope>;
|
|
35
35
|
export declare const launchDevApplication: (application: {
|
|
36
36
|
closeDevChannel: Effect.Effect<void, never, never>;
|
|
37
37
|
httpEffect: Effect.Effect<HttpServerResponse.HttpServerResponse, import("./compiled-server.js").CompiledServerError | DevGenerationError | import("effect/unstable/http/HttpServerError").HttpServerError | RspackError, import("effect/unstable/http/HttpServerRequest").HttpServerRequest | Scope.Scope>;
|
|
38
|
-
watch: Effect.Effect<void,
|
|
39
|
-
}) => Effect.Effect<void,
|
|
40
|
-
export declare const devApplication: (options: DevGenerationOptions) => Effect.Effect<void, import("./build.js").BuildEntryError | import("
|
|
38
|
+
watch: Effect.Effect<void, DevGenerationFailure, FileSystem.FileSystem | Path.Path>;
|
|
39
|
+
}) => Effect.Effect<void, DevGenerationFailure, FileSystem.FileSystem | HttpServer.HttpServer | Path.Path>;
|
|
40
|
+
export declare const devApplication: (options: DevGenerationOptions) => Effect.Effect<void, import("./build.js").BuildEntryError | import("effect/PlatformError").PlatformError | DevGenerationFailure, FileSystem.FileSystem | HttpServer.HttpServer | Path.Path | Scope.Scope>;
|
|
41
41
|
export {};
|
package/dist/build/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cause, Deferred, Effect, Fiber, FileSystem, Layer, Path, Ref, Schema, Scope, ScopedRef, Stream } from "effect";
|
|
1
|
+
import { Cause, Deferred, Effect, Fiber, FiberHandle, FileSystem, Layer, Path, Ref, Schema, Scope, ScopedRef, Stream } from "effect";
|
|
2
2
|
import { HttpBody, HttpRouter, HttpServer, HttpServerResponse } from "effect/unstable/http";
|
|
3
3
|
import package_0 from "../../package.json" with {"type":"json"};
|
|
4
4
|
import { DevChannelPath } from "../dev/channel.js";
|
|
@@ -79,6 +79,7 @@ const makeDevGenerationStore = Effect.fnUntraced(function*(options) {
|
|
|
79
79
|
}));
|
|
80
80
|
const initialCompilation = yield* Deferred.make();
|
|
81
81
|
const compilation = yield* Ref.make(initialCompilation);
|
|
82
|
+
// Only acquisition can be cancelled; installation must also release waiting requests.
|
|
82
83
|
const update = Effect.fnUntraced(function*(event) {
|
|
83
84
|
const current = yield* Ref.get(compilation);
|
|
84
85
|
switch(event._tag){
|
|
@@ -112,7 +113,7 @@ const makeDevGenerationStore = Effect.fnUntraced(function*(options) {
|
|
|
112
113
|
yield* Deferred.succeed(current, ready.generation);
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
});
|
|
116
|
+
}, Effect.uninterruptible);
|
|
116
117
|
const httpEffect = Ref.get(compilation).pipe(Effect.flatMap(Deferred["await"]), Effect.flatMap((ready)=>ready.httpEffect));
|
|
117
118
|
return {
|
|
118
119
|
httpEffect,
|
|
@@ -167,11 +168,25 @@ const makeDevApplication = Effect.fnUntraced(function*({ hostname, port, root })
|
|
|
167
168
|
}), Effect["catch"]((error)=>channel.publishBuildFailure(Cause.pretty(Cause.fail(error))).pipe(Effect.andThen(Effect.logError(error)))));
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
|
-
});
|
|
171
|
-
const watch =
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
}, Effect.uninterruptible);
|
|
172
|
+
const watch = Effect.scoped(Effect.gen(function*() {
|
|
173
|
+
const startup = yield* FiberHandle.make();
|
|
174
|
+
const events = rspack.watch(makeRspackDevConfig(applicationRoot, entries, {
|
|
175
|
+
onCompilationStart: channel.onCompilationStart,
|
|
176
|
+
onServerComponentChanges: channel.onServerComponentChanges
|
|
177
|
+
})).pipe(Stream.runForEach(Effect.fnUntraced(function*(event) {
|
|
178
|
+
// Finish obsolete startup cleanup before handling the next build event.
|
|
179
|
+
yield* FiberHandle.clear(startup);
|
|
180
|
+
if (event._tag === 'Compiled') {
|
|
181
|
+
yield* FiberHandle.run(startup, update(event), {
|
|
182
|
+
startImmediately: true
|
|
183
|
+
});
|
|
184
|
+
} else {
|
|
185
|
+
yield* update(event);
|
|
186
|
+
}
|
|
187
|
+
})), Effect.andThen(FiberHandle.awaitEmpty(startup)));
|
|
188
|
+
yield* Effect.raceFirst(events, FiberHandle.join(startup));
|
|
189
|
+
}));
|
|
175
190
|
const httpEffect = yield* HttpRouter.toHttpEffect(HttpRouter.addAll([
|
|
176
191
|
HttpRouter.route('GET', DevChannelPath, channel.httpEffect),
|
|
177
192
|
HttpRouter.route('*', '/*', generationStore.httpEffect)
|
package/dist/build/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build/dev.js","sources":["../../src/build/dev.ts"],"sourcesContent":["import {\n Cause,\n Deferred,\n Effect,\n Fiber,\n FileSystem,\n Layer,\n Path,\n Ref,\n Schema,\n Scope,\n ScopedRef,\n Stream,\n} from 'effect';\nimport { HttpBody, HttpRouter, HttpServer, HttpServerResponse } from 'effect/unstable/http';\n\nimport PackageJson from '../../package.json' with { type: 'json' };\nimport { DevChannelPath } from '../dev/channel';\nimport { resolveApplicationBuild } from './build';\nimport { loadServerBundle, makeRunnableHttpLayer } from './compiled-server';\nimport { DevOutputDir, EnvironmentConfig } from './contract';\nimport { makeDevChannel } from './dev-channel';\nimport { Rspack, type RspackError, type RspackWatchEvent } from './rspack';\nimport { makeRspackDevConfig } from './rspack-config';\nimport { formatDuration, Terminal } from './terminal';\n\ntype RspackCompilation = Extract<RspackWatchEvent, { readonly _tag: 'Compiled' }>;\n\nexport class DevGenerationError extends Schema.TaggedError<DevGenerationError>()(\n 'DevGenerationError',\n {\n message: Schema.String,\n cause: Schema.Defect(),\n },\n) {}\n\ntype AcquireDevGenerationOptions = {\n readonly compilation: RspackCompilation;\n readonly hostname: string;\n readonly port: number;\n readonly root: string;\n};\n\ntype DevGenerationOptions = Omit<AcquireDevGenerationOptions, 'compilation'>;\n\nexport type DevApplicationOptions = DevGenerationOptions;\n\nexport const acquireDevGeneration = Effect.fnUntraced(function* ({\n compilation,\n hostname,\n port,\n root,\n}: AcquireDevGenerationOptions) {\n const path = yield* Path.Path;\n const bundle = yield* loadServerBundle(\n path.resolve(compilation.serverBundle.outputPath, compilation.serverBundle.filename),\n );\n const HttpLayer = yield* makeRunnableHttpLayer({\n bundle,\n clientAssetsCacheControl: EnvironmentConfig.development.clientAssetsCacheControl,\n clientOutputDir: EnvironmentConfig.development.clientOutputDir,\n hostname,\n port,\n root,\n });\n const httpEffect = yield* HttpRouter.toHttpEffect(HttpLayer).pipe(\n Effect.mapError(\n (cause) =>\n new DevGenerationError({\n message: `Failed to start development generation ${compilation.hash}.`,\n cause,\n }),\n ),\n );\n\n // Close request work before the generation's application services.\n const generationScope = yield* Effect.scope;\n const requests = yield* Scope.fork(generationScope, 'parallel');\n const ownRequest = Effect.withFiber((fiber) => {\n Fiber.runIn(fiber, requests);\n return Effect.void;\n });\n\n return {\n hash: compilation.hash,\n httpEffect: Effect.gen(function* () {\n yield* ownRequest;\n const response = yield* httpEffect;\n const body = response.body;\n if (body._tag !== 'Stream') {\n return response;\n }\n\n // Bun consumes the response body on a separate fiber after the handler returns.\n return HttpServerResponse.setBody(\n response,\n HttpBody.stream(\n Stream.onStart(body.stream, ownRequest),\n body.contentType,\n body.contentLength,\n ),\n );\n }),\n };\n});\n\ntype DevGeneration = Effect.Success<ReturnType<typeof acquireDevGeneration>>;\ntype DevGenerationFailure = Effect.Error<ReturnType<typeof acquireDevGeneration>> | RspackError;\n\ntype DevGenerationState =\n | { readonly _tag: 'Unavailable' }\n | { readonly _tag: 'Ready'; readonly generation: DevGeneration };\n\nexport const makeDevGenerationStore = Effect.fnUntraced(function* (options: DevGenerationOptions) {\n const generation = yield* ScopedRef.make<DevGenerationState>(() => ({ _tag: 'Unavailable' }));\n const initialCompilation = yield* Deferred.make<DevGeneration, DevGenerationFailure>();\n const compilation = yield* Ref.make(initialCompilation);\n const update = Effect.fnUntraced(function* (event: RspackWatchEvent) {\n const current = yield* Ref.get(compilation);\n\n switch (event._tag) {\n case 'Building': {\n const compilationCompleted = yield* Deferred.isDone(current);\n if (compilationCompleted) {\n const next = yield* Deferred.make<DevGeneration, DevGenerationFailure>();\n yield* Ref.set(compilation, next);\n }\n return;\n }\n case 'Failed': {\n yield* Deferred.fail(current, event.error);\n return;\n }\n case 'Compiled': {\n yield* ScopedRef.set(\n generation,\n acquireDevGeneration({ ...options, compilation: event }).pipe(\n Effect.interruptible,\n Effect.map((ready): DevGenerationState => ({\n _tag: 'Ready',\n generation: ready,\n })),\n Effect.tapError((error) => Deferred.fail(current, error)),\n ),\n );\n const ready = yield* ScopedRef.get(generation);\n if (ready._tag === 'Unavailable') {\n return yield* Effect.die(\n new TypeError('Expected the completed development generation to be available.'),\n );\n }\n yield* Deferred.succeed(current, ready.generation);\n }\n }\n });\n const httpEffect = Ref.get(compilation).pipe(\n Effect.flatMap(Deferred.await),\n Effect.flatMap((ready) => ready.httpEffect),\n );\n\n return {\n httpEffect,\n update,\n };\n});\n\nexport const makeDevApplication = Effect.fnUntraced(function* ({\n hostname,\n port,\n root,\n}: DevApplicationOptions) {\n const { applicationRoot, entries } = yield* resolveApplicationBuild({ root });\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const rspack = yield* Rspack;\n const channel = yield* makeDevChannel;\n\n yield* fileSystem.remove(path.join(applicationRoot, DevOutputDir), {\n force: true,\n recursive: true,\n });\n\n const generationStore = yield* makeDevGenerationStore({\n hostname,\n port,\n root: applicationRoot,\n });\n const update = Effect.fnUntraced(function* (event: RspackWatchEvent) {\n switch (event._tag) {\n case 'Building': {\n yield* generationStore.update(event);\n const firstChangedFile =\n event.changedFiles.find((file) => path.basename(file).includes('.')) ??\n event.changedFiles[0];\n const changedPath =\n firstChangedFile === undefined\n ? undefined\n : path.relative(applicationRoot, firstChangedFile);\n const subject = changedPath ?? 'application';\n\n yield* Effect.logInfo(`${Terminal.cyan('●')} Compiling ${subject}...`);\n return;\n }\n case 'Failed': {\n yield* generationStore.update(event);\n yield* channel.publishBuildFailure(event.diagnostics);\n yield* Effect.logError(event.error);\n return;\n }\n case 'Compiled': {\n if (event.warnings !== undefined) {\n yield* Effect.logWarning(event.warnings);\n }\n yield* generationStore.update(event).pipe(\n Effect.andThen(channel.publishCompilation(event.clientHash)),\n Effect.tap(() => {\n const duration =\n event.duration === undefined ? '' : ` in ${formatDuration(event.duration)}`;\n const compilers = event.compilers\n .map(({ duration, name }) =>\n duration === undefined ? name : `${name} ${formatDuration(duration)}`,\n )\n .join(' · ');\n const details = compilers.length === 0 ? '' : ` ${Terminal.dim(compilers)}`;\n\n return Effect.logInfo(`${Terminal.green('✓')} Ready${duration}${details}`);\n }),\n Effect.catch((error) =>\n channel\n .publishBuildFailure(Cause.pretty(Cause.fail(error)))\n .pipe(Effect.andThen(Effect.logError(error))),\n ),\n );\n }\n }\n });\n const watch = rspack\n .watch(\n makeRspackDevConfig(applicationRoot, entries, {\n onCompilationStart: channel.onCompilationStart,\n onServerComponentChanges: channel.onServerComponentChanges,\n }),\n )\n .pipe(Stream.runForEach(update));\n const httpEffect = yield* HttpRouter.toHttpEffect(\n HttpRouter.addAll([\n HttpRouter.route('GET', DevChannelPath, channel.httpEffect),\n HttpRouter.route('*', '/*', generationStore.httpEffect),\n ]),\n );\n\n return {\n closeDevChannel: channel.close,\n httpEffect,\n watch,\n };\n});\n\ntype DevApplication = Effect.Success<ReturnType<typeof makeDevApplication>>;\n\nexport const launchDevApplication = Effect.fnUntraced(function* (application: DevApplication) {\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const server = yield* Layer.launch(HttpServer.serve(application.httpEffect)).pipe(\n Effect.forkScoped({ startImmediately: true }),\n );\n yield* Effect.addFinalizer(() => application.closeDevChannel);\n const watch = HttpServer.addressFormattedWith((address) =>\n Effect.logInfo(\n `${Terminal.magenta('▌')} effective-rsc ${Terminal.dim(PackageJson.version)} ${address}`,\n ),\n ).pipe(Effect.andThen(application.watch));\n\n return yield* Effect.raceFirst(watch, Fiber.join(server));\n }),\n );\n});\n\nexport const devApplication = Effect.fn('ersc/build/devApplication')(function* (\n options: DevApplicationOptions,\n) {\n const application = yield* makeDevApplication(options).pipe(Effect.provide(Rspack.layer));\n\n return yield* launchDevApplication(application);\n});\n"],"names":["Cause","Deferred","Effect","Fiber","FileSystem","Layer","Path","Ref","Schema","Scope","ScopedRef","Stream","HttpBody","HttpRouter","HttpServer","HttpServerResponse","PackageJson","DevChannelPath","resolveApplicationBuild","loadServerBundle","makeRunnableHttpLayer","DevOutputDir","EnvironmentConfig","makeDevChannel","Rspack","makeRspackDevConfig","formatDuration","Terminal","DevGenerationError","acquireDevGeneration","compilation","hostname","port","root","path","bundle","HttpLayer","httpEffect","cause","generationScope","requests","ownRequest","fiber","response","body","makeDevGenerationStore","options","generation","initialCompilation","update","event","current","compilationCompleted","next","ready","error","TypeError","makeDevApplication","applicationRoot","entries","fileSystem","rspack","channel","generationStore","firstChangedFile","file","changedPath","undefined","subject","duration","compilers","name","details","watch","launchDevApplication","application","server","address","devApplication"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAagB;AAC4E;AAEzB;AACnB;AACE;AAC0B;AACf;AACd;AAC4B;AACrB;AACA;AAI/C,MAAM4B,kBAAkBA,SAASpB,kBAAkB,GACxD,sBACA;IACE,SAASA,aAAa;IACtB,OAAOA,aAAa;AACtB;AACC;AAaI,MAAMqB,oBAAoBA,GAAG3B,iBAAiB,CAAC,UAAW,EAC/D4B,WAAW,EACXC,QAAQ,EACRC,IAAI,EACJC,IAAI,EACwB;IAC5B,MAAMC,OAAO,OAAO5B,SAAS;IAC7B,MAAM6B,SAAS,OAAOhB,gBAAgBA,CACpCe,KAAK,OAAO,CAACJ,YAAY,YAAY,CAAC,UAAU,EAAEA,YAAY,YAAY,CAAC,QAAQ;IAErF,MAAMM,YAAY,OAAOhB,qBA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AS,GAE3F,IAAI,CAAC3E,cAAc,CAACyE,YAAY,KAAK;QAEvC,OAAO,OAAOzE,gBAAgB,CAACuE,OAAOtE,UAAU,CAACyE;IACnD;AAEJ,GAAG;AAEI,MAAME,cAAcA,GAAG5E,SAAS,CAAC,6BAA6B,UACnE4C,OAA8B;IAE9B,MAAM6B,cAAc,OAAOlB,kBAAkBA,CAACX,SAAS,IAAI,CAAC5C,cAAc,CAACsB,YAAY;IAEvF,OAAO,OAAOkD,oBAAoBA,CAACC;AACrC,GAAG"}
|
|
1
|
+
{"version":3,"file":"build/dev.js","sources":["../../src/build/dev.ts"],"sourcesContent":["import {\n Cause,\n Deferred,\n Effect,\n Fiber,\n FiberHandle,\n FileSystem,\n Layer,\n Path,\n Ref,\n Schema,\n Scope,\n ScopedRef,\n Stream,\n} from 'effect';\nimport { HttpBody, HttpRouter, HttpServer, HttpServerResponse } from 'effect/unstable/http';\n\nimport PackageJson from '../../package.json' with { type: 'json' };\nimport { DevChannelPath } from '../dev/channel';\nimport { resolveApplicationBuild } from './build';\nimport { loadServerBundle, makeRunnableHttpLayer } from './compiled-server';\nimport { DevOutputDir, EnvironmentConfig } from './contract';\nimport { makeDevChannel } from './dev-channel';\nimport { Rspack, type RspackError, type RspackWatchEvent } from './rspack';\nimport { makeRspackDevConfig } from './rspack-config';\nimport { formatDuration, Terminal } from './terminal';\n\ntype RspackCompilation = Extract<RspackWatchEvent, { readonly _tag: 'Compiled' }>;\n\nexport class DevGenerationError extends Schema.TaggedError<DevGenerationError>()(\n 'DevGenerationError',\n {\n message: Schema.String,\n cause: Schema.Defect(),\n },\n) {}\n\ntype AcquireDevGenerationOptions = {\n readonly compilation: RspackCompilation;\n readonly hostname: string;\n readonly port: number;\n readonly root: string;\n};\n\ntype DevGenerationOptions = Omit<AcquireDevGenerationOptions, 'compilation'>;\n\nexport type DevApplicationOptions = DevGenerationOptions;\n\nexport const acquireDevGeneration = Effect.fnUntraced(function* ({\n compilation,\n hostname,\n port,\n root,\n}: AcquireDevGenerationOptions) {\n const path = yield* Path.Path;\n const bundle = yield* loadServerBundle(\n path.resolve(compilation.serverBundle.outputPath, compilation.serverBundle.filename),\n );\n const HttpLayer = yield* makeRunnableHttpLayer({\n bundle,\n clientAssetsCacheControl: EnvironmentConfig.development.clientAssetsCacheControl,\n clientOutputDir: EnvironmentConfig.development.clientOutputDir,\n hostname,\n port,\n root,\n });\n const httpEffect = yield* HttpRouter.toHttpEffect(HttpLayer).pipe(\n Effect.mapError(\n (cause) =>\n new DevGenerationError({\n message: `Failed to start development generation ${compilation.hash}.`,\n cause,\n }),\n ),\n );\n\n // Close request work before the generation's application services.\n const generationScope = yield* Effect.scope;\n const requests = yield* Scope.fork(generationScope, 'parallel');\n const ownRequest = Effect.withFiber((fiber) => {\n Fiber.runIn(fiber, requests);\n return Effect.void;\n });\n\n return {\n hash: compilation.hash,\n httpEffect: Effect.gen(function* () {\n yield* ownRequest;\n const response = yield* httpEffect;\n const body = response.body;\n if (body._tag !== 'Stream') {\n return response;\n }\n\n // Bun consumes the response body on a separate fiber after the handler returns.\n return HttpServerResponse.setBody(\n response,\n HttpBody.stream(\n Stream.onStart(body.stream, ownRequest),\n body.contentType,\n body.contentLength,\n ),\n );\n }),\n };\n});\n\ntype DevGeneration = Effect.Success<ReturnType<typeof acquireDevGeneration>>;\ntype DevGenerationFailure = Effect.Error<ReturnType<typeof acquireDevGeneration>> | RspackError;\n\ntype DevGenerationState =\n | { readonly _tag: 'Unavailable' }\n | { readonly _tag: 'Ready'; readonly generation: DevGeneration };\n\nexport const makeDevGenerationStore = Effect.fnUntraced(function* (options: DevGenerationOptions) {\n const generation = yield* ScopedRef.make<DevGenerationState>(() => ({ _tag: 'Unavailable' }));\n const initialCompilation = yield* Deferred.make<DevGeneration, DevGenerationFailure>();\n const compilation = yield* Ref.make(initialCompilation);\n // Only acquisition can be cancelled; installation must also release waiting requests.\n const update = Effect.fnUntraced(function* (event: RspackWatchEvent) {\n const current = yield* Ref.get(compilation);\n\n switch (event._tag) {\n case 'Building': {\n const compilationCompleted = yield* Deferred.isDone(current);\n if (compilationCompleted) {\n const next = yield* Deferred.make<DevGeneration, DevGenerationFailure>();\n yield* Ref.set(compilation, next);\n }\n return;\n }\n case 'Failed': {\n yield* Deferred.fail(current, event.error);\n return;\n }\n case 'Compiled': {\n yield* ScopedRef.set(\n generation,\n acquireDevGeneration({ ...options, compilation: event }).pipe(\n Effect.interruptible,\n Effect.map((ready): DevGenerationState => ({\n _tag: 'Ready',\n generation: ready,\n })),\n Effect.tapError((error) => Deferred.fail(current, error)),\n ),\n );\n const ready = yield* ScopedRef.get(generation);\n if (ready._tag === 'Unavailable') {\n return yield* Effect.die(\n new TypeError('Expected the completed development generation to be available.'),\n );\n }\n yield* Deferred.succeed(current, ready.generation);\n }\n }\n }, Effect.uninterruptible);\n const httpEffect = Ref.get(compilation).pipe(\n Effect.flatMap(Deferred.await),\n Effect.flatMap((ready) => ready.httpEffect),\n );\n\n return {\n httpEffect,\n update,\n };\n});\n\nexport const makeDevApplication = Effect.fnUntraced(function* ({\n hostname,\n port,\n root,\n}: DevApplicationOptions) {\n const { applicationRoot, entries } = yield* resolveApplicationBuild({ root });\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const rspack = yield* Rspack;\n const channel = yield* makeDevChannel;\n\n yield* fileSystem.remove(path.join(applicationRoot, DevOutputDir), {\n force: true,\n recursive: true,\n });\n\n const generationStore = yield* makeDevGenerationStore({\n hostname,\n port,\n root: applicationRoot,\n });\n const update = Effect.fnUntraced(function* (event: RspackWatchEvent) {\n switch (event._tag) {\n case 'Building': {\n yield* generationStore.update(event);\n const firstChangedFile =\n event.changedFiles.find((file) => path.basename(file).includes('.')) ??\n event.changedFiles[0];\n const changedPath =\n firstChangedFile === undefined\n ? undefined\n : path.relative(applicationRoot, firstChangedFile);\n const subject = changedPath ?? 'application';\n\n yield* Effect.logInfo(`${Terminal.cyan('●')} Compiling ${subject}...`);\n return;\n }\n case 'Failed': {\n yield* generationStore.update(event);\n yield* channel.publishBuildFailure(event.diagnostics);\n yield* Effect.logError(event.error);\n return;\n }\n case 'Compiled': {\n if (event.warnings !== undefined) {\n yield* Effect.logWarning(event.warnings);\n }\n yield* generationStore.update(event).pipe(\n Effect.andThen(channel.publishCompilation(event.clientHash)),\n Effect.tap(() => {\n const duration =\n event.duration === undefined ? '' : ` in ${formatDuration(event.duration)}`;\n const compilers = event.compilers\n .map(({ duration, name }) =>\n duration === undefined ? name : `${name} ${formatDuration(duration)}`,\n )\n .join(' · ');\n const details = compilers.length === 0 ? '' : ` ${Terminal.dim(compilers)}`;\n\n return Effect.logInfo(`${Terminal.green('✓')} Ready${duration}${details}`);\n }),\n Effect.catch((error) =>\n channel\n .publishBuildFailure(Cause.pretty(Cause.fail(error)))\n .pipe(Effect.andThen(Effect.logError(error))),\n ),\n );\n }\n }\n }, Effect.uninterruptible);\n const watch = Effect.scoped(\n Effect.gen(function* () {\n const startup = yield* FiberHandle.make<void, DevGenerationFailure>();\n const events = rspack\n .watch(\n makeRspackDevConfig(applicationRoot, entries, {\n onCompilationStart: channel.onCompilationStart,\n onServerComponentChanges: channel.onServerComponentChanges,\n }),\n )\n .pipe(\n Stream.runForEach(\n Effect.fnUntraced(function* (event) {\n // Finish obsolete startup cleanup before handling the next build event.\n yield* FiberHandle.clear(startup);\n if (event._tag === 'Compiled') {\n yield* FiberHandle.run(startup, update(event), { startImmediately: true });\n } else {\n yield* update(event);\n }\n }),\n ),\n Effect.andThen(FiberHandle.awaitEmpty(startup)),\n );\n\n yield* Effect.raceFirst(events, FiberHandle.join(startup));\n }),\n );\n const httpEffect = yield* HttpRouter.toHttpEffect(\n HttpRouter.addAll([\n HttpRouter.route('GET', DevChannelPath, channel.httpEffect),\n HttpRouter.route('*', '/*', generationStore.httpEffect),\n ]),\n );\n\n return {\n closeDevChannel: channel.close,\n httpEffect,\n watch,\n };\n});\n\ntype DevApplication = Effect.Success<ReturnType<typeof makeDevApplication>>;\n\nexport const launchDevApplication = Effect.fnUntraced(function* (application: DevApplication) {\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const server = yield* Layer.launch(HttpServer.serve(application.httpEffect)).pipe(\n Effect.forkScoped({ startImmediately: true }),\n );\n yield* Effect.addFinalizer(() => application.closeDevChannel);\n const watch = HttpServer.addressFormattedWith((address) =>\n Effect.logInfo(\n `${Terminal.magenta('▌')} effective-rsc ${Terminal.dim(PackageJson.version)} ${address}`,\n ),\n ).pipe(Effect.andThen(application.watch));\n\n return yield* Effect.raceFirst(watch, Fiber.join(server));\n }),\n );\n});\n\nexport const devApplication = Effect.fn('ersc/build/devApplication')(function* (\n options: DevApplicationOptions,\n) {\n const application = yield* makeDevApplication(options).pipe(Effect.provide(Rspack.layer));\n\n return yield* launchDevApplication(application);\n});\n"],"names":["Cause","Deferred","Effect","Fiber","FiberHandle","FileSystem","Layer","Path","Ref","Schema","Scope","ScopedRef","Stream","HttpBody","HttpRouter","HttpServer","HttpServerResponse","PackageJson","DevChannelPath","resolveApplicationBuild","loadServerBundle","makeRunnableHttpLayer","DevOutputDir","EnvironmentConfig","makeDevChannel","Rspack","makeRspackDevConfig","formatDuration","Terminal","DevGenerationError","acquireDevGeneration","compilation","hostname","port","root","path","bundle","HttpLayer","httpEffect","cause","generationScope","requests","ownRequest","fiber","response","body","makeDevGenerationStore","options","generation","initialCompilation","update","event","current","compilationCompleted","next","ready","error","TypeError","makeDevApplication","applicationRoot","entries","fileSystem","rspack","channel","generationStore","firstChangedFile","file","changedPath","undefined","subject","duration","compilers","name","details","watch","startup","events","launchDevApplication","application","server","address","devApplication"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAcgB;AAC4E;AAEzB;AACnB;AACE;AAC0B;AACf;AACd;AAC4B;AACrB;AACA;AAI/C,MAAM6B,kBAAkBA,SAASpB,kBAAkB,GACxD,sBACA;IACE,SAASA,aAAa;IACtB,OAAOA,aAAa;AACtB;AACC;AAaI,MAAMqB,oBAAoBA,GAAG5B,iBAAiB,CA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0E,QAAQxE,gBAAgB,CAACuE;IACnD;IAEF,MAAMrC,aAAa,OAAOxB,uBAAuB,CAC/CA,iBAAiB,CAAC;QAChBA,gBAAgB,CAAC,OAAOI,cAAcA,EAAE6C,QAAQ,UAAU;QAC1DjD,gBAAgB,CAAC,KAAK,MAAMkD,gBAAgB,UAAU;KACvD;IAGH,OAAO;QACL,iBAAiBD,QAAQ,KAAK;QAC9BzB;QACAoC;IACF;AACF,GAAG;AAII,MAAMG,oBAAoBA,GAAG3E,iBAAiB,CAAC,UAAW4E,WAA2B;IAC1F,OAAO,OAAO5E,aAAa,CACzBA,UAAU,CAAC;QACT,MAAM6E,SAAS,OAAOzE,YAAY,CAACS,gBAAgB,CAAC+D,YAAY,UAAU,GAAG,IAAI,CAC/E5E,iBAAiB,CAAC;YAAE,kBAAkB;QAAK;QAE7C,OAAOA,mBAAmB,CAAC,IAAM4E,YAAY,eAAe;QAC5D,MAAMJ,QAAQ3D,+BAA+B,CAAC,CAACiE,UAC7C9E,cAAc,CACZ,GAAG0B,gBAAgB,CAAC,KAAK,eAAe,EAAEA,YAAY,CAACX,iBAAmB,EAAE,EAAE,EAAE+D,SAAS,GAE3F,IAAI,CAAC9E,cAAc,CAAC4E,YAAY,KAAK;QAEvC,OAAO,OAAO5E,gBAAgB,CAACwE,OAAOvE,UAAU,CAAC4E;IACnD;AAEJ,GAAG;AAEI,MAAME,cAAcA,GAAG/E,SAAS,CAAC,6BAA6B,UACnE6C,OAA8B;IAE9B,MAAM+B,cAAc,OAAOpB,kBAAkBA,CAACX,SAAS,IAAI,CAAC7C,cAAc,CAACuB,YAAY;IAEvF,OAAO,OAAOoD,oBAAoBA,CAACC;AACrC,GAAG"}
|
package/dist/cli.js
CHANGED
|
@@ -49,12 +49,12 @@ const runBuild = Effect.fnUntraced(function*({ adapter }) {
|
|
|
49
49
|
adapter
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
-
const cli_adapter = __rspack_external_effect_unstable_cli_Flag_7320ac06.
|
|
52
|
+
const cli_adapter = __rspack_external_effect_unstable_cli_Flag_7320ac06.String('adapter').pipe(__rspack_external_effect_unstable_cli_Flag_7320ac06.withDescription('Installed deployment adapter package to run after compilation'), __rspack_external_effect_unstable_cli_Flag_7320ac06.withSchema(Schema.NonEmptyString), __rspack_external_effect_unstable_cli_Flag_7320ac06.optional);
|
|
53
53
|
const buildCommand = __rspack_external_effect_unstable_cli_Command_ef1b8bde.make('build', {
|
|
54
54
|
adapter: cli_adapter
|
|
55
55
|
}).pipe(__rspack_external_effect_unstable_cli_Command_ef1b8bde.withDescription('Compile an effective-rsc application with Rspack.'), __rspack_external_effect_unstable_cli_Command_ef1b8bde.withHandler(runBuild));
|
|
56
|
-
const cli_hostname = __rspack_external_effect_unstable_cli_Flag_7320ac06.
|
|
57
|
-
const cli_port = __rspack_external_effect_unstable_cli_Flag_7320ac06.
|
|
56
|
+
const cli_hostname = __rspack_external_effect_unstable_cli_Flag_7320ac06.String('hostname').pipe(__rspack_external_effect_unstable_cli_Flag_7320ac06.withDescription('Hostname to bind (defaults to HOST or localhost)'), __rspack_external_effect_unstable_cli_Flag_7320ac06.withFallbackConfig(Config.String('HOST').pipe(Config.withDefault(DefaultApplicationHostname))), __rspack_external_effect_unstable_cli_Flag_7320ac06.withSchema(Schema.NonEmptyString));
|
|
57
|
+
const cli_port = __rspack_external_effect_unstable_cli_Flag_7320ac06.Int('port').pipe(__rspack_external_effect_unstable_cli_Flag_7320ac06.withDescription(`Port to bind (defaults to PORT or ${DefaultApplicationPort})`), __rspack_external_effect_unstable_cli_Flag_7320ac06.withFallbackConfig(Config.Int('PORT').pipe(Config.withDefault(DefaultApplicationPort))), __rspack_external_effect_unstable_cli_Flag_7320ac06.withSchema(Schema.Int.check(Schema.isBetween({
|
|
58
58
|
minimum: 1,
|
|
59
59
|
maximum: 65535
|
|
60
60
|
}))));
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["import * as BunHttpServer from '@effect/platform-bun/BunHttpServer';\nimport * as BunRuntime from '@effect/platform-bun/BunRuntime';\nimport * as BunServices from '@effect/platform-bun/BunServices';\nimport { Config, Effect, Option, Schema } from 'effect';\nimport * as Command from 'effect/unstable/cli/Command';\nimport * as Flag from 'effect/unstable/cli/Flag';\n\nimport PackageJson from '../package.json' with { type: 'json' };\nimport { serve } from './server/serve';\nimport {\n ApplicationIdleTimeoutSeconds,\n ApplicationMaxRequestBodySizeBytes,\n DefaultApplicationHostname,\n DefaultApplicationPort,\n} from './server/server-config';\n\nexport class BuildModuleLoadError extends Schema.TaggedError<BuildModuleLoadError>()(\n 'BuildModuleLoadError',\n {\n message: Schema.String,\n cause: Schema.Defect(),\n },\n) {}\n\nexport class DevModuleLoadError extends Schema.TaggedError<DevModuleLoadError>()(\n 'DevModuleLoadError',\n {\n message: Schema.String,\n cause: Schema.Defect(),\n },\n) {}\n\nconst runBuild = Effect.fnUntraced(function* ({\n adapter,\n}: {\n readonly adapter: Option.Option<string>;\n}) {\n const { buildApplication } = yield* Effect.tryPromise({\n try: () => import('./build/build'),\n catch: (cause) =>\n new BuildModuleLoadError({\n message: 'Failed to load the effective-rsc application compiler.',\n cause,\n }),\n });\n\n yield* buildApplication({ root: process.cwd(), adapter });\n});\n\nconst adapter = Flag.
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["import * as BunHttpServer from '@effect/platform-bun/BunHttpServer';\nimport * as BunRuntime from '@effect/platform-bun/BunRuntime';\nimport * as BunServices from '@effect/platform-bun/BunServices';\nimport { Config, Effect, Option, Schema } from 'effect';\nimport * as Command from 'effect/unstable/cli/Command';\nimport * as Flag from 'effect/unstable/cli/Flag';\n\nimport PackageJson from '../package.json' with { type: 'json' };\nimport { serve } from './server/serve';\nimport {\n ApplicationIdleTimeoutSeconds,\n ApplicationMaxRequestBodySizeBytes,\n DefaultApplicationHostname,\n DefaultApplicationPort,\n} from './server/server-config';\n\nexport class BuildModuleLoadError extends Schema.TaggedError<BuildModuleLoadError>()(\n 'BuildModuleLoadError',\n {\n message: Schema.String,\n cause: Schema.Defect(),\n },\n) {}\n\nexport class DevModuleLoadError extends Schema.TaggedError<DevModuleLoadError>()(\n 'DevModuleLoadError',\n {\n message: Schema.String,\n cause: Schema.Defect(),\n },\n) {}\n\nconst runBuild = Effect.fnUntraced(function* ({\n adapter,\n}: {\n readonly adapter: Option.Option<string>;\n}) {\n const { buildApplication } = yield* Effect.tryPromise({\n try: () => import('./build/build'),\n catch: (cause) =>\n new BuildModuleLoadError({\n message: 'Failed to load the effective-rsc application compiler.',\n cause,\n }),\n });\n\n yield* buildApplication({ root: process.cwd(), adapter });\n});\n\nconst adapter = Flag.String('adapter').pipe(\n Flag.withDescription('Installed deployment adapter package to run after compilation'),\n Flag.withSchema(Schema.NonEmptyString),\n Flag.optional,\n);\n\nconst buildCommand = Command.make('build', { adapter }).pipe(\n Command.withDescription('Compile an effective-rsc application with Rspack.'),\n Command.withHandler(runBuild),\n);\n\nconst hostname = Flag.String('hostname').pipe(\n Flag.withDescription('Hostname to bind (defaults to HOST or localhost)'),\n Flag.withFallbackConfig(\n Config.String('HOST').pipe(Config.withDefault(DefaultApplicationHostname)),\n ),\n Flag.withSchema(Schema.NonEmptyString),\n);\n\nconst port = Flag.Int('port').pipe(\n Flag.withDescription(`Port to bind (defaults to PORT or ${DefaultApplicationPort})`),\n Flag.withFallbackConfig(Config.Int('PORT').pipe(Config.withDefault(DefaultApplicationPort))),\n Flag.withSchema(\n Schema.Int.check(\n Schema.isBetween({\n minimum: 1,\n maximum: 65_535,\n }),\n ),\n ),\n);\n\nconst runDev = Effect.fnUntraced(function* ({\n hostname,\n port,\n}: {\n readonly hostname: string;\n readonly port: number;\n}) {\n const { devApplication } = yield* Effect.tryPromise({\n try: () => import('./build/dev'),\n catch: (cause) =>\n new DevModuleLoadError({\n message: 'Failed to load the effective-rsc development compiler.',\n cause,\n }),\n });\n\n yield* devApplication({\n hostname,\n port,\n root: process.cwd(),\n }).pipe(\n Effect.provide(\n BunHttpServer.layer({\n development: true,\n // Explicit dev shutdown interrupts request scopes before releasing their generations.\n disablePreemptiveShutdown: true,\n hostname,\n idleTimeout: ApplicationIdleTimeoutSeconds,\n maxRequestBodySize: ApplicationMaxRequestBodySizeBytes,\n port,\n }),\n ),\n Effect.scoped,\n );\n});\n\nconst devCommand = Command.make('dev', { hostname, port }).pipe(\n Command.withDescription('Start an effective-rsc application in development mode.'),\n Command.withHandler(runDev),\n);\n\nconst startCommand = Command.make('start', { hostname, port }).pipe(\n Command.withDescription('Start the compiled application with Bun.'),\n Command.withHandler(({ hostname, port }) =>\n serve({ hostname, port, root: process.cwd() }).pipe(\n Effect.andThen(Effect.never),\n Effect.scoped,\n ),\n ),\n);\n\nconst cli = Command.make('ersc').pipe(\n Command.withDescription('Build and run an effective-rsc application.'),\n Command.withSubcommands([devCommand, buildCommand, startCommand]),\n);\n\nconst program = Command.run(cli, { version: PackageJson.version }).pipe(\n Effect.provide(BunServices.layer),\n);\n\nBunRuntime.runMain(program);\n"],"names":["BunHttpServer","BunRuntime","BunServices","Config","Effect","Schema","Command","Flag","PackageJson","serve","ApplicationIdleTimeoutSeconds","ApplicationMaxRequestBodySizeBytes","DefaultApplicationHostname","DefaultApplicationPort","BuildModuleLoadError","DevModuleLoadError","runBuild","adapter","buildApplication","cause","process","buildCommand","hostname","port","runDev","devApplication","devCommand","startCommand","cli","program"],"mappings":";;;;;;;;;;;;;;;;;;;AAAoE;AACN;AACE;AACR;AACD;AACN;AAEe;AACzB;AAMP;AAEzB,MAAMc,oBAAoBA,SAAST,kBAAkB,GAC1D,wBACA;IACE,SAASA,aAAa;IACtB,OAAOA,aAAa;AACtB;AACC;AAEI,MAAMU,kBAAkBA,SAASV,kBAAkB,GACxD,sBACA;IACE,SAASA,aAAa;IACtB,OAAOA,aAAa;AACtB;AACC;AAEH,MAAMW,QAAQA,GAAGZ,iBAAiB,CAAC,UA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EA,OAAOM,eAAe;QACpBH;QACAC;QACA,MAAMH,QAAQ,GAAG;IACnB,GAAG,IAAI,CACLhB,cAAc,CACZJ,mEAAmB,CAAC;QAClB,aAAa;QACb,sFAAsF;QACtF,2BAA2B;QAC3BsB;QACA,aAAaZ,6BAA6BA;QAC1C,oBAAoBC,kCAAkCA;QACtDY;IACF,KAEFnB,aAAa;AAEjB;AAEA,MAAMsB,UAAUA,GAAGpB,2DAAY,CAAC,OAAO;IAAEgB,sBAAQA;IAAEC,cAAIA;AAAC,GAAG,IAAI,CAC7DjB,sEAAuB,CAAC,4DACxBA,kEAAmB,CAACkB,MAAMA;AAG5B,MAAMG,YAAYA,GAAGrB,2DAAY,CAAC,SAAS;IAAEgB,sBAAQA;IAAEC,cAAIA;AAAC,GAAG,IAAI,CACjEjB,sEAAuB,CAAC,6CACxBA,kEAAmB,CAAC,CAAC,EAAEgB,QAAQ,EAAEC,IAAI,EAAE,GACrCd,KAAKA,CAAC;QAAEa;QAAUC;QAAM,MAAMH,QAAQ,GAAG;IAAG,GAAG,IAAI,CACjDhB,cAAc,CAACA,YAAY,GAC3BA,aAAa;AAKnB,MAAMwB,GAAGA,GAAGtB,2DAAY,CAAC,QAAQ,IAAI,CACnCA,sEAAuB,CAAC,gDACxBA,sEAAuB,CAAC;IAACoB,UAAUA;IAAEL,YAAYA;IAAEM,YAAYA;CAAC;AAGlE,MAAME,OAAOA,GAAGvB,0DAAW,CAACsB,GAAGA,EAAE;IAAE,SAASpB,iBAAmB;AAAC,GAAG,IAAI,CACrEJ,cAAc,CAACF,iEAAiB;AAGlCD,kEAAkB,CAAC4B,OAAOA"}
|
|
@@ -5,33 +5,21 @@ export type BrowserRendererNavigation = {
|
|
|
5
5
|
readonly discard: () => Promise<void>;
|
|
6
6
|
readonly retired: Promise<void>;
|
|
7
7
|
};
|
|
8
|
-
type
|
|
8
|
+
type InitialRender = {
|
|
9
|
+
readonly _tag: 'Initial';
|
|
10
|
+
readonly routeTree: RouteTreeModel;
|
|
11
|
+
};
|
|
12
|
+
type RouteRender = {
|
|
13
|
+
readonly _tag: 'Navigation' | 'Refresh';
|
|
14
|
+
readonly order: number;
|
|
9
15
|
readonly committed: PromiseWithResolvers<void>;
|
|
10
16
|
readonly retired: PromiseWithResolvers<void>;
|
|
11
17
|
readonly routeTree: RouteTreeModel;
|
|
12
18
|
};
|
|
13
|
-
type
|
|
14
|
-
readonly _tag: 'Stable';
|
|
15
|
-
} | {
|
|
16
|
-
readonly _tag: 'Navigation';
|
|
17
|
-
readonly navigation: BrowserRenderNavigationState;
|
|
18
|
-
};
|
|
19
|
-
export type BrowserRender = {
|
|
20
|
-
readonly _tag: 'Initial';
|
|
21
|
-
readonly routeTree: RouteTreeModel;
|
|
22
|
-
} | {
|
|
23
|
-
readonly _tag: 'Navigation';
|
|
24
|
-
readonly navigation: BrowserRenderNavigationState;
|
|
25
|
-
readonly routeTree: RouteTreeModel;
|
|
26
|
-
} | {
|
|
19
|
+
export type BrowserRender = InitialRender | RouteRender | {
|
|
27
20
|
readonly _tag: 'Discard';
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
30
|
-
readonly visible: BrowserRenderOwner;
|
|
31
|
-
} | {
|
|
32
|
-
readonly _tag: 'Refresh';
|
|
33
|
-
readonly committed: PromiseWithResolvers<void>;
|
|
34
|
-
readonly routeTree: RouteTreeModel;
|
|
21
|
+
readonly order: number;
|
|
22
|
+
readonly restore: InitialRender | RouteRender;
|
|
35
23
|
};
|
|
36
24
|
declare const BrowserRenderer_base: Context.ServiceClass<BrowserRenderer, "ersc/client/BrowserRenderer", {
|
|
37
25
|
commit: (render: BrowserRender) => void;
|
|
@@ -41,7 +29,11 @@ declare const BrowserRenderer_base: Context.ServiceClass<BrowserRenderer, "ersc/
|
|
|
41
29
|
discard: () => Promise<void>;
|
|
42
30
|
retired: Promise<void>;
|
|
43
31
|
};
|
|
44
|
-
refresh: (routeTree: RouteTreeModel) =>
|
|
32
|
+
refresh: (routeTree: RouteTreeModel) => {
|
|
33
|
+
committed: Promise<void>;
|
|
34
|
+
discard: () => Promise<void>;
|
|
35
|
+
retired: Promise<void>;
|
|
36
|
+
};
|
|
45
37
|
}> & {
|
|
46
38
|
readonly make: Effect.Effect<{
|
|
47
39
|
commit: (render: BrowserRender) => void;
|
|
@@ -51,7 +43,11 @@ declare const BrowserRenderer_base: Context.ServiceClass<BrowserRenderer, "ersc/
|
|
|
51
43
|
discard: () => Promise<void>;
|
|
52
44
|
retired: Promise<void>;
|
|
53
45
|
};
|
|
54
|
-
refresh: (routeTree: RouteTreeModel) =>
|
|
46
|
+
refresh: (routeTree: RouteTreeModel) => {
|
|
47
|
+
committed: Promise<void>;
|
|
48
|
+
discard: () => Promise<void>;
|
|
49
|
+
retired: Promise<void>;
|
|
50
|
+
};
|
|
55
51
|
}, never, never>;
|
|
56
52
|
};
|
|
57
53
|
export declare class BrowserRenderer extends BrowserRenderer_base {
|
|
@@ -64,7 +60,11 @@ export declare class BrowserRenderer extends BrowserRenderer_base {
|
|
|
64
60
|
discard: () => Promise<void>;
|
|
65
61
|
retired: Promise<void>;
|
|
66
62
|
};
|
|
67
|
-
refresh: (routeTree: RouteTreeModel) =>
|
|
63
|
+
refresh: (routeTree: RouteTreeModel) => {
|
|
64
|
+
committed: Promise<void>;
|
|
65
|
+
discard: () => Promise<void>;
|
|
66
|
+
retired: Promise<void>;
|
|
67
|
+
};
|
|
68
68
|
}) => Layer.Layer<BrowserRenderer, never, never>;
|
|
69
69
|
}
|
|
70
70
|
export {};
|