effect-start 0.17.0 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/Commander.d.ts +103 -0
  2. package/dist/Commander.js +333 -0
  3. package/dist/ContentNegotiation.d.ts +13 -0
  4. package/dist/ContentNegotiation.js +364 -0
  5. package/dist/Development.d.ts +34 -0
  6. package/dist/Development.js +52 -0
  7. package/dist/Entity.d.ts +47 -0
  8. package/dist/Entity.js +224 -0
  9. package/dist/FileRouter.d.ts +61 -0
  10. package/dist/FileRouter.js +203 -0
  11. package/dist/FileRouterCodegen.d.ts +19 -0
  12. package/dist/FileRouterCodegen.js +176 -0
  13. package/dist/FileRouterPattern.d.ts +9 -0
  14. package/dist/FileRouterPattern.js +35 -0
  15. package/dist/Http.d.ts +37 -0
  16. package/dist/Http.js +92 -0
  17. package/dist/HttpAppExtra.d.ts +7 -0
  18. package/dist/HttpAppExtra.js +320 -0
  19. package/dist/HttpUtils.d.ts +3 -0
  20. package/dist/HttpUtils.js +11 -0
  21. package/dist/PathPattern.d.ts +134 -0
  22. package/dist/PathPattern.js +415 -0
  23. package/dist/Random.d.ts +5 -0
  24. package/dist/Random.js +49 -0
  25. package/dist/Route.d.ts +98 -0
  26. package/dist/Route.js +81 -0
  27. package/dist/RouteBody.d.ts +53 -0
  28. package/dist/RouteBody.js +67 -0
  29. package/dist/RouteHook.d.ts +12 -0
  30. package/dist/RouteHook.js +45 -0
  31. package/dist/RouteHttp.d.ts +21 -0
  32. package/dist/RouteHttp.js +260 -0
  33. package/dist/RouteHttpTracer.d.ts +10 -0
  34. package/dist/RouteHttpTracer.js +62 -0
  35. package/dist/RouteMount.d.ts +119 -0
  36. package/dist/RouteMount.js +77 -0
  37. package/dist/RouteSchema.d.ts +65 -0
  38. package/dist/RouteSchema.js +155 -0
  39. package/dist/RouteSse.d.ts +21 -0
  40. package/dist/RouteSse.js +85 -0
  41. package/dist/RouteTree.d.ts +56 -0
  42. package/dist/RouteTree.js +91 -0
  43. package/dist/RouteTrie.d.ts +20 -0
  44. package/dist/RouteTrie.js +157 -0
  45. package/dist/RouterPattern.d.ts +118 -0
  46. package/dist/RouterPattern.js +269 -0
  47. package/dist/SchemaExtra.d.ts +7 -0
  48. package/dist/SchemaExtra.js +74 -0
  49. package/dist/Start.d.ts +19 -0
  50. package/dist/Start.js +23 -0
  51. package/dist/StartApp.d.ts +19 -0
  52. package/dist/StartApp.js +21 -0
  53. package/dist/StreamExtra.d.ts +28 -0
  54. package/dist/StreamExtra.js +100 -0
  55. package/dist/TuplePathPattern.d.ts +9 -0
  56. package/dist/TuplePathPattern.js +63 -0
  57. package/dist/Values.d.ts +26 -0
  58. package/dist/Values.js +30 -0
  59. package/dist/bun/BunBundle.d.ts +12 -0
  60. package/dist/bun/BunBundle.js +145 -0
  61. package/dist/bun/BunHttpServer.d.ts +44 -0
  62. package/dist/bun/BunHttpServer.js +187 -0
  63. package/dist/bun/BunHttpServer_web.d.ts +60 -0
  64. package/dist/bun/BunHttpServer_web.js +252 -0
  65. package/dist/bun/BunImportTrackerPlugin.d.ts +13 -0
  66. package/dist/bun/BunImportTrackerPlugin.js +71 -0
  67. package/dist/bun/BunRoute.d.ts +49 -0
  68. package/dist/bun/BunRoute.js +131 -0
  69. package/dist/bun/BunRuntime.d.ts +1 -0
  70. package/dist/bun/BunRuntime.js +26 -0
  71. package/dist/bun/BunVirtualFilesPlugin.d.ts +4 -0
  72. package/dist/bun/BunVirtualFilesPlugin.js +40 -0
  73. package/dist/bun/_BunEnhancedResolve.d.ts +45 -0
  74. package/dist/bun/_BunEnhancedResolve.js +104 -0
  75. package/dist/bun/index.d.ts +4 -0
  76. package/dist/bun/index.js +4 -0
  77. package/dist/bundler/Bundle.d.ts +60 -0
  78. package/dist/bundler/Bundle.js +48 -0
  79. package/dist/bundler/BundleFiles.d.ts +13 -0
  80. package/dist/bundler/BundleFiles.js +94 -0
  81. package/dist/bundler/BundleHttp.d.ts +45 -0
  82. package/dist/bundler/BundleHttp.js +176 -0
  83. package/dist/client/Overlay.d.ts +2 -0
  84. package/dist/client/Overlay.js +32 -0
  85. package/dist/client/ScrollState.d.ts +6 -0
  86. package/dist/client/ScrollState.js +98 -0
  87. package/dist/client/index.d.ts +6 -0
  88. package/dist/client/index.js +81 -0
  89. package/dist/experimental/EncryptedCookies.d.ts +51 -0
  90. package/dist/experimental/EncryptedCookies.js +243 -0
  91. package/dist/experimental/SseHttpResponse.d.ts +7 -0
  92. package/dist/experimental/SseHttpResponse.js +28 -0
  93. package/dist/experimental/index.d.ts +2 -0
  94. package/dist/experimental/index.js +2 -0
  95. package/dist/hyper/Hyper.d.ts +32 -0
  96. package/dist/hyper/Hyper.js +34 -0
  97. package/dist/hyper/HyperHtml.d.ts +23 -0
  98. package/dist/hyper/HyperHtml.js +144 -0
  99. package/dist/hyper/HyperNode.d.ts +14 -0
  100. package/dist/hyper/HyperNode.js +11 -0
  101. package/dist/hyper/HyperRoute.d.ts +8 -0
  102. package/dist/hyper/HyperRoute.js +32 -0
  103. package/dist/hyper/HyperRoute.test.d.ts +1 -0
  104. package/dist/hyper/HyperRoute.test.js +72 -0
  105. package/dist/hyper/index.d.ts +4 -0
  106. package/dist/hyper/index.js +4 -0
  107. package/dist/hyper/jsx-runtime.d.ts +7 -0
  108. package/dist/hyper/jsx-runtime.js +8 -0
  109. package/dist/index.d.ts +6 -0
  110. package/dist/index.js +6 -0
  111. package/dist/inference_check.d.ts +1 -0
  112. package/dist/inference_check.js +15 -0
  113. package/dist/middlewares/BasicAuthMiddleware.d.ts +8 -0
  114. package/dist/middlewares/BasicAuthMiddleware.js +22 -0
  115. package/dist/middlewares/index.d.ts +1 -0
  116. package/dist/middlewares/index.js +1 -0
  117. package/dist/node/FileSystem.d.ts +9 -0
  118. package/dist/node/FileSystem.js +440 -0
  119. package/dist/node/Utils.d.ts +1 -0
  120. package/dist/node/Utils.js +19 -0
  121. package/dist/repro_fail.d.ts +1 -0
  122. package/dist/repro_fail.js +14 -0
  123. package/dist/testing/TestHttpClient.d.ts +13 -0
  124. package/dist/testing/TestHttpClient.js +68 -0
  125. package/dist/testing/TestLogger.d.ts +13 -0
  126. package/dist/testing/TestLogger.js +29 -0
  127. package/dist/testing/index.d.ts +3 -0
  128. package/dist/testing/index.js +3 -0
  129. package/dist/testing/utils.d.ts +9 -0
  130. package/dist/testing/utils.js +39 -0
  131. package/dist/x/cloudflare/CloudflareTunnel.d.ts +13 -0
  132. package/dist/x/cloudflare/CloudflareTunnel.js +43 -0
  133. package/dist/x/cloudflare/index.d.ts +1 -0
  134. package/dist/x/cloudflare/index.js +1 -0
  135. package/dist/x/datastar/Datastar.d.ts +6 -0
  136. package/dist/x/datastar/Datastar.js +46 -0
  137. package/dist/x/datastar/index.d.ts +2 -0
  138. package/dist/x/datastar/index.js +2 -0
  139. package/dist/x/tailwind/TailwindPlugin.d.ts +23 -0
  140. package/dist/x/tailwind/TailwindPlugin.js +219 -0
  141. package/dist/x/tailwind/compile.d.ts +19 -0
  142. package/dist/x/tailwind/compile.js +156 -0
  143. package/dist/x/tailwind/plugin.d.ts +2 -0
  144. package/dist/x/tailwind/plugin.js +15 -0
  145. package/package.json +68 -16
  146. package/src/RouteBody.test.ts +18 -0
  147. package/src/RouteBody.ts +126 -2
  148. package/src/x/tailwind/compile.ts +8 -2
package/package.json CHANGED
@@ -1,32 +1,82 @@
1
1
  {
2
2
  "name": "effect-start",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "exports": {
7
- ".": "./src/index.ts",
8
- "./StartApp": "./src/StartApp.ts",
9
- "./bun": "./src/bun/index.ts",
10
- "./client": "./src/client/index.ts",
11
- "./testing": "./src/testing/index.ts",
12
- "./x/*": "./src/x/*/index.ts",
13
- "./x/tailwind/plugin": "./src/x/tailwind/plugin.ts",
14
- "./middlewares": "./src/middlewares/index.ts",
15
- "./experimental": "./src/experimental/index.ts",
7
+ ".": {
8
+ "bun": "./src/index.ts",
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./StartApp": {
13
+ "bun": "./src/StartApp.ts",
14
+ "types": "./dist/StartApp.d.ts",
15
+ "default": "./dist/StartApp.js"
16
+ },
17
+ "./bun": {
18
+ "bun": "./src/bun/index.ts",
19
+ "types": "./dist/bun/index.d.ts",
20
+ "default": "./dist/bun/index.js"
21
+ },
22
+ "./client": {
23
+ "bun": "./src/client/index.ts",
24
+ "types": "./dist/client/index.d.ts",
25
+ "default": "./dist/client/index.js"
26
+ },
27
+ "./testing": {
28
+ "bun": "./src/testing/index.ts",
29
+ "types": "./dist/testing/index.d.ts",
30
+ "default": "./dist/testing/index.js"
31
+ },
32
+ "./x/*": {
33
+ "bun": "./src/x/*/index.ts",
34
+ "types": "./dist/x/*/index.d.ts",
35
+ "default": "./dist/x/*/index.js"
36
+ },
37
+ "./x/tailwind/plugin": {
38
+ "bun": "./src/x/tailwind/plugin.ts",
39
+ "types": "./dist/x/tailwind/plugin.d.ts",
40
+ "default": "./dist/x/tailwind/plugin.js"
41
+ },
42
+ "./middlewares": {
43
+ "bun": "./src/middlewares/index.ts",
44
+ "types": "./dist/middlewares/index.d.ts",
45
+ "default": "./dist/middlewares/index.js"
46
+ },
47
+ "./experimental": {
48
+ "bun": "./src/experimental/index.ts",
49
+ "types": "./dist/experimental/index.d.ts",
50
+ "default": "./dist/experimental/index.js"
51
+ },
16
52
  "./client/assets.d.ts": "./src/assets.d.ts",
17
- "./hyper": "./src/hyper/index.ts",
18
- "./jsx-runtime": "./src/hyper/jsx-runtime.ts",
19
- "./jsx-dev-runtime": "./src/hyper/jsx-runtime.ts",
53
+ "./hyper": {
54
+ "bun": "./src/hyper/index.ts",
55
+ "types": "./dist/hyper/index.d.ts",
56
+ "default": "./dist/hyper/index.js"
57
+ },
58
+ "./jsx-runtime": {
59
+ "bun": "./src/hyper/jsx-runtime.ts",
60
+ "types": "./dist/hyper/jsx-runtime.d.ts",
61
+ "default": "./dist/hyper/jsx-runtime.js"
62
+ },
63
+ "./jsx-dev-runtime": {
64
+ "bun": "./src/hyper/jsx-runtime.ts",
65
+ "types": "./dist/hyper/jsx-runtime.d.ts",
66
+ "default": "./dist/hyper/jsx-runtime.js"
67
+ },
20
68
  "./package.json": "./package.json"
21
69
  },
22
70
  "scripts": {
71
+ "build": "bunx --bun tsc -p tsconfig.build.json",
72
+ "prepare": "bun run build",
23
73
  "format": "bunx dprint fmt",
24
74
  "test": "bun test ./src/",
25
- "deploy": "bunx npm publish --access public"
75
+ "deploy": "bunx --bun npm publish --access public"
26
76
  },
27
77
  "dependencies": {
28
- "effect": ">=3.16.4",
29
- "@effect/platform": "^0.93.6"
78
+ "effect": ">=3.19.0",
79
+ "@effect/platform": ">=0.93.0"
30
80
  },
31
81
  "peerDependencies": {
32
82
  "typescript": "^5.9.3"
@@ -48,6 +98,8 @@
48
98
  },
49
99
  "files": [
50
100
  "src/",
101
+ "dist/",
102
+ "README.md",
51
103
  "package.json"
52
104
  ]
53
105
  }
@@ -1,4 +1,5 @@
1
1
  import * as test from "bun:test"
2
+ import * as Context from "effect/Context"
2
3
  import * as Effect from "effect/Effect"
3
4
  import * as ParseResult from "effect/ParseResult"
4
5
  import * as Stream from "effect/Stream"
@@ -211,4 +212,21 @@ test.describe(`${RouteBody.handle.name}()`, () => {
211
212
  .expect(result.body)
212
213
  .toBe("got: next")
213
214
  })
215
+
216
+ test.it("generator type checks missing services", async () => {
217
+ interface ServiceA {
218
+ readonly _: unique symbol
219
+ }
220
+ const ServiceA = Context.GenericTag<ServiceA>("ServiceA")
221
+
222
+ const handler = RouteBody.handle(function*() {
223
+ yield* ServiceA
224
+ return "ok"
225
+ })
226
+
227
+ // This should fail type checking because ServiceA is not provided
228
+ // @ts-expect-error ServiceA is missing
229
+ const promise = Effect.runPromise(handler(ctx, next))
230
+ test.expect(promise).rejects.toThrow(/Service not found: ServiceA/)
231
+ })
214
232
  })
package/src/RouteBody.ts CHANGED
@@ -22,6 +22,21 @@ const formatToContentType: Record<Format, string | undefined> = {
22
22
 
23
23
  type UnwrapStream<T> = T extends Stream.Stream<infer V, any, any> ? V : T
24
24
 
25
+ type YieldError<T> = T extends Utils.YieldWrap<Effect.Effect<any, infer E, any>>
26
+ ? E
27
+ : never
28
+
29
+ type YieldContext<T> = T extends
30
+ Utils.YieldWrap<Effect.Effect<any, any, infer R>> ? R
31
+ : never
32
+
33
+ export type GeneratorHandler<B, A, Y> = (
34
+ context: Values.Simplify<B>,
35
+ next: (
36
+ context?: Partial<B> & Record<string, unknown>,
37
+ ) => Entity.Entity<UnwrapStream<A>>,
38
+ ) => Generator<Y, A | Entity.Entity<A>, unknown>
39
+
25
40
  export type HandlerInput<B, A, E, R> =
26
41
  | A
27
42
  | Entity.Entity<A>
@@ -39,6 +54,16 @@ export type HandlerInput<B, A, E, R> =
39
54
  unknown
40
55
  >)
41
56
 
57
+ export function handle<
58
+ B,
59
+ A,
60
+ Y extends Utils.YieldWrap<Effect.Effect<any, any, any>>,
61
+ >(
62
+ handler: GeneratorHandler<B, A, Y>,
63
+ ): Route.Route.Handler<B, A, YieldError<Y>, YieldContext<Y>>
64
+ export function handle<B, A, E, R>(
65
+ handler: HandlerInput<B, A, E, R>,
66
+ ): Route.Route.Handler<B, A, E, R>
42
67
  export function handle<B, A, E, R>(
43
68
  handler: HandlerInput<B, A, E, R>,
44
69
  ): Route.Route.Handler<B, A, E, R> {
@@ -80,13 +105,67 @@ function normalizeToEntity<A>(value: A | Entity.Entity<A>): Entity.Entity<A> {
80
105
  return Entity.make(value as A, { status: 200 })
81
106
  }
82
107
 
108
+ export interface BuildReturn<
109
+ Value,
110
+ F extends Format,
111
+ > {
112
+ <
113
+ D extends Route.RouteDescriptor.Any,
114
+ B,
115
+ I extends Route.Route.Tuple,
116
+ A extends F extends "json" ? Value
117
+ : Value | Stream.Stream<Value, any, any>,
118
+ Y extends Utils.YieldWrap<Effect.Effect<any, any, any>>,
119
+ >(
120
+ handler: GeneratorHandler<
121
+ NoInfer<D & B & Route.ExtractBindings<I> & { format: F }>,
122
+ A,
123
+ Y
124
+ >,
125
+ ): (
126
+ self: Route.RouteSet.RouteSet<D, B, I>,
127
+ ) => Route.RouteSet.RouteSet<
128
+ D,
129
+ B,
130
+ [
131
+ ...I,
132
+ Route.Route.Route<{ format: F }, {}, A, YieldError<Y>, YieldContext<Y>>,
133
+ ]
134
+ >
135
+
136
+ <
137
+ D extends Route.RouteDescriptor.Any,
138
+ B,
139
+ I extends Route.Route.Tuple,
140
+ A extends F extends "json" ? Value
141
+ : Value | Stream.Stream<Value, any, any>,
142
+ E = never,
143
+ R = never,
144
+ >(
145
+ handler: HandlerInput<
146
+ NoInfer<
147
+ D & B & Route.ExtractBindings<I> & { format: F }
148
+ >,
149
+ A,
150
+ E,
151
+ R
152
+ >,
153
+ ): (
154
+ self: Route.RouteSet.RouteSet<D, B, I>,
155
+ ) => Route.RouteSet.RouteSet<
156
+ D,
157
+ B,
158
+ [...I, Route.Route.Route<{ format: F }, {}, A, E, R>]
159
+ >
160
+ }
161
+
83
162
  export function build<
84
163
  Value,
85
164
  F extends Format,
86
165
  >(
87
166
  descriptors: { format: F },
88
167
  ) {
89
- return function<
168
+ return (function<
90
169
  D extends Route.RouteDescriptor.Any,
91
170
  B extends {},
92
171
  I extends Route.Route.Tuple,
@@ -146,7 +225,7 @@ export function build<
146
225
  Route.descriptor(self),
147
226
  )
148
227
  }
149
- }
228
+ }) as unknown as BuildReturn<Value, F>
150
229
  }
151
230
 
152
231
  export type RenderValue =
@@ -154,6 +233,51 @@ export type RenderValue =
154
233
  | Uint8Array
155
234
  | Stream.Stream<string | Uint8Array, any, any>
156
235
 
236
+ export function render<
237
+ D extends Route.RouteDescriptor.Any,
238
+ B extends {},
239
+ I extends Route.Route.Tuple,
240
+ A extends RenderValue,
241
+ Y extends Utils.YieldWrap<Effect.Effect<any, any, any>>,
242
+ >(
243
+ handler: GeneratorHandler<
244
+ NoInfer<D & B & Route.ExtractBindings<I> & { format: "*" }>,
245
+ A,
246
+ Y
247
+ >,
248
+ ): (
249
+ self: Route.RouteSet.RouteSet<D, B, I>,
250
+ ) => Route.RouteSet.RouteSet<
251
+ D,
252
+ B,
253
+ [
254
+ ...I,
255
+ Route.Route.Route<{ format: "*" }, {}, A, YieldError<Y>, YieldContext<Y>>,
256
+ ]
257
+ >
258
+ export function render<
259
+ D extends Route.RouteDescriptor.Any,
260
+ B extends {},
261
+ I extends Route.Route.Tuple,
262
+ A extends RenderValue,
263
+ E = never,
264
+ R = never,
265
+ >(
266
+ handler: HandlerInput<
267
+ NoInfer<
268
+ D & B & Route.ExtractBindings<I> & { format: "*" }
269
+ >,
270
+ A,
271
+ E,
272
+ R
273
+ >,
274
+ ): (
275
+ self: Route.RouteSet.RouteSet<D, B, I>,
276
+ ) => Route.RouteSet.RouteSet<
277
+ D,
278
+ B,
279
+ [...I, Route.Route.Route<{ format: "*" }, {}, A, E, R>]
280
+ >
157
281
  export function render<
158
282
  D extends Route.RouteDescriptor.Any,
159
283
  B extends {},
@@ -88,13 +88,19 @@ async function ensureSourceDetectionRootExists(compiler: {
88
88
  }
89
89
  }
90
90
 
91
- export async function compileAst(ast: AstNode[], options: CompileOptions) {
91
+ export async function compileAst(
92
+ ast: AstNode[],
93
+ options: CompileOptions,
94
+ ): ReturnType<typeof _compileAst> {
92
95
  let compiler = await _compileAst(ast, createCompileOptions(options))
93
96
  await ensureSourceDetectionRootExists(compiler)
94
97
  return compiler
95
98
  }
96
99
 
97
- export async function compile(css: string, options: CompileOptions) {
100
+ export async function compile(
101
+ css: string,
102
+ options: CompileOptions,
103
+ ): ReturnType<typeof _compile> {
98
104
  let compiler = await _compile(css, createCompileOptions(options))
99
105
  await ensureSourceDetectionRootExists(compiler)
100
106
  return compiler