effect-start 0.23.1 → 0.26.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.
Files changed (351) hide show
  1. package/package.json +18 -86
  2. package/src/Development.ts +3 -1
  3. package/src/Entity.ts +17 -0
  4. package/src/Fetch.ts +271 -0
  5. package/src/SqlIntrospect.ts +64 -70
  6. package/src/Start.ts +21 -24
  7. package/src/StartApp.ts +1 -1
  8. package/src/bun/BunServer.ts +42 -10
  9. package/src/hyper/HyperHtml.ts +0 -1
  10. package/src/sql/bun/index.ts +1 -1
  11. package/src/sql/index.ts +1 -0
  12. package/src/sql/libsql/index.ts +173 -0
  13. package/src/sql/libsql/libsql.d.ts +39 -0
  14. package/src/sql/mssql/index.ts +1 -1
  15. package/dist/BlobStore.d.ts +0 -80
  16. package/dist/BlobStore.js +0 -19
  17. package/dist/ChildProcess.d.ts +0 -60
  18. package/dist/ChildProcess.js +0 -30
  19. package/dist/Commander.d.ts +0 -100
  20. package/dist/Commander.js +0 -326
  21. package/dist/ContentNegotiation.d.ts +0 -12
  22. package/dist/ContentNegotiation.js +0 -359
  23. package/dist/Cookies.d.ts +0 -47
  24. package/dist/Cookies.js +0 -302
  25. package/dist/Development.d.ts +0 -39
  26. package/dist/Development.js +0 -58
  27. package/dist/Effectify.d.ts +0 -209
  28. package/dist/Effectify.js +0 -19
  29. package/dist/Entity.d.ts +0 -47
  30. package/dist/Entity.js +0 -224
  31. package/dist/FilePathPattern.d.ts +0 -29
  32. package/dist/FilePathPattern.js +0 -86
  33. package/dist/FileRouter.d.ts +0 -56
  34. package/dist/FileRouter.js +0 -148
  35. package/dist/FileRouterCodegen.d.ts +0 -18
  36. package/dist/FileRouterCodegen.js +0 -227
  37. package/dist/FileRouterPattern.d.ts +0 -9
  38. package/dist/FileRouterPattern.js +0 -35
  39. package/dist/FileSystem.d.ts +0 -158
  40. package/dist/FileSystem.js +0 -70
  41. package/dist/Http.d.ts +0 -37
  42. package/dist/Http.js +0 -88
  43. package/dist/HttpAppExtra.d.ts +0 -7
  44. package/dist/HttpAppExtra.js +0 -320
  45. package/dist/HttpUtils.d.ts +0 -3
  46. package/dist/HttpUtils.js +0 -11
  47. package/dist/PathPattern.d.ts +0 -134
  48. package/dist/PathPattern.js +0 -413
  49. package/dist/PlatformError.d.ts +0 -38
  50. package/dist/PlatformError.js +0 -25
  51. package/dist/PlatformRuntime.d.ts +0 -27
  52. package/dist/PlatformRuntime.js +0 -46
  53. package/dist/Route.d.ts +0 -97
  54. package/dist/Route.js +0 -100
  55. package/dist/RouteBody.d.ts +0 -47
  56. package/dist/RouteBody.js +0 -67
  57. package/dist/RouteError.d.ts +0 -98
  58. package/dist/RouteError.js +0 -55
  59. package/dist/RouteHook.d.ts +0 -12
  60. package/dist/RouteHook.js +0 -40
  61. package/dist/RouteHttp.d.ts +0 -21
  62. package/dist/RouteHttp.js +0 -258
  63. package/dist/RouteHttpTracer.d.ts +0 -10
  64. package/dist/RouteHttpTracer.js +0 -62
  65. package/dist/RouteMount.d.ts +0 -86
  66. package/dist/RouteMount.js +0 -63
  67. package/dist/RouteSchema.d.ts +0 -86
  68. package/dist/RouteSchema.js +0 -188
  69. package/dist/RouteSse.d.ts +0 -21
  70. package/dist/RouteSse.js +0 -79
  71. package/dist/RouteTree.d.ts +0 -57
  72. package/dist/RouteTree.js +0 -93
  73. package/dist/RouteTrie.d.ts +0 -20
  74. package/dist/RouteTrie.js +0 -152
  75. package/dist/RouterPattern.d.ts +0 -118
  76. package/dist/RouterPattern.js +0 -269
  77. package/dist/SchemaExtra.d.ts +0 -7
  78. package/dist/SchemaExtra.js +0 -74
  79. package/dist/Socket.d.ts +0 -27
  80. package/dist/Socket.js +0 -29
  81. package/dist/Sql.d.ts +0 -34
  82. package/dist/Sql.js +0 -5
  83. package/dist/SqlIntrospect.d.ts +0 -91
  84. package/dist/SqlIntrospect.js +0 -466
  85. package/dist/Start.d.ts +0 -44
  86. package/dist/Start.js +0 -49
  87. package/dist/StartApp.d.ts +0 -19
  88. package/dist/StartApp.js +0 -21
  89. package/dist/StreamExtra.d.ts +0 -28
  90. package/dist/StreamExtra.js +0 -100
  91. package/dist/System.d.ts +0 -7
  92. package/dist/System.js +0 -22
  93. package/dist/TuplePathPattern.d.ts +0 -9
  94. package/dist/TuplePathPattern.js +0 -68
  95. package/dist/Unique.d.ts +0 -50
  96. package/dist/Unique.js +0 -187
  97. package/dist/Values.d.ts +0 -27
  98. package/dist/Values.js +0 -36
  99. package/dist/bun/BunBlobStoreDisk.d.ts +0 -6
  100. package/dist/bun/BunBlobStoreDisk.js +0 -116
  101. package/dist/bun/BunBlobStoreS3.d.ts +0 -11
  102. package/dist/bun/BunBlobStoreS3.js +0 -89
  103. package/dist/bun/BunBlobWatcherDisk.d.ts +0 -6
  104. package/dist/bun/BunBlobWatcherDisk.js +0 -60
  105. package/dist/bun/BunBlobWatcherQueue.d.ts +0 -6
  106. package/dist/bun/BunBlobWatcherQueue.js +0 -17
  107. package/dist/bun/BunBundle.d.ts +0 -11
  108. package/dist/bun/BunBundle.js +0 -137
  109. package/dist/bun/BunChildProcessSpawner.d.ts +0 -3
  110. package/dist/bun/BunChildProcessSpawner.js +0 -103
  111. package/dist/bun/BunHttpServer.d.ts +0 -44
  112. package/dist/bun/BunHttpServer.js +0 -186
  113. package/dist/bun/BunHttpServer_web.d.ts +0 -60
  114. package/dist/bun/BunHttpServer_web.js +0 -252
  115. package/dist/bun/BunImportTrackerPlugin.d.ts +0 -13
  116. package/dist/bun/BunImportTrackerPlugin.js +0 -69
  117. package/dist/bun/BunPlatformHttpServer.d.ts +0 -10
  118. package/dist/bun/BunPlatformHttpServer.js +0 -53
  119. package/dist/bun/BunRoute.d.ts +0 -48
  120. package/dist/bun/BunRoute.js +0 -121
  121. package/dist/bun/BunRuntime.d.ts +0 -2
  122. package/dist/bun/BunRuntime.js +0 -31
  123. package/dist/bun/BunServer.d.ts +0 -40
  124. package/dist/bun/BunServer.js +0 -157
  125. package/dist/bun/BunServerRequest.d.ts +0 -60
  126. package/dist/bun/BunServerRequest.js +0 -252
  127. package/dist/bun/BunSql.d.ts +0 -4
  128. package/dist/bun/BunSql.js +0 -81
  129. package/dist/bun/BunVirtualFilesPlugin.d.ts +0 -4
  130. package/dist/bun/BunVirtualFilesPlugin.js +0 -40
  131. package/dist/bun/_BunEnhancedResolve.d.ts +0 -45
  132. package/dist/bun/_BunEnhancedResolve.js +0 -102
  133. package/dist/bun/index.d.ts +0 -5
  134. package/dist/bun/index.js +0 -5
  135. package/dist/bundler/Bundle.d.ts +0 -61
  136. package/dist/bundler/Bundle.js +0 -48
  137. package/dist/bundler/BundleFiles.d.ts +0 -13
  138. package/dist/bundler/BundleFiles.js +0 -96
  139. package/dist/bundler/BundleHttp.d.ts +0 -45
  140. package/dist/bundler/BundleHttp.js +0 -176
  141. package/dist/bundler/BundleRoute.d.ts +0 -27
  142. package/dist/bundler/BundleRoute.js +0 -51
  143. package/dist/client/Overlay.d.ts +0 -2
  144. package/dist/client/Overlay.js +0 -32
  145. package/dist/client/ScrollState.d.ts +0 -6
  146. package/dist/client/ScrollState.js +0 -94
  147. package/dist/client/index.d.ts +0 -6
  148. package/dist/client/index.js +0 -79
  149. package/dist/console/Console.d.ts +0 -6
  150. package/dist/console/Console.js +0 -26
  151. package/dist/console/ConsoleErrors.d.ts +0 -3
  152. package/dist/console/ConsoleErrors.js +0 -200
  153. package/dist/console/ConsoleLogger.d.ts +0 -3
  154. package/dist/console/ConsoleLogger.js +0 -47
  155. package/dist/console/ConsoleMetrics.d.ts +0 -3
  156. package/dist/console/ConsoleMetrics.js +0 -61
  157. package/dist/console/ConsoleProcess.d.ts +0 -3
  158. package/dist/console/ConsoleProcess.js +0 -49
  159. package/dist/console/ConsoleStore.d.ts +0 -144
  160. package/dist/console/ConsoleStore.js +0 -61
  161. package/dist/console/ConsoleTracer.d.ts +0 -3
  162. package/dist/console/ConsoleTracer.js +0 -94
  163. package/dist/console/Simulation.d.ts +0 -2
  164. package/dist/console/Simulation.js +0 -633
  165. package/dist/console/index.d.ts +0 -3
  166. package/dist/console/index.js +0 -3
  167. package/dist/console/routes/errors/route.d.ts +0 -10
  168. package/dist/console/routes/errors/route.js +0 -47
  169. package/dist/console/routes/fiberDetail.d.ts +0 -16
  170. package/dist/console/routes/fiberDetail.js +0 -38
  171. package/dist/console/routes/fibers/route.d.ts +0 -10
  172. package/dist/console/routes/fibers/route.js +0 -19
  173. package/dist/console/routes/git/route.d.ts +0 -11
  174. package/dist/console/routes/git/route.js +0 -33
  175. package/dist/console/routes/layout.d.ts +0 -9
  176. package/dist/console/routes/layout.js +0 -3
  177. package/dist/console/routes/logs/route.d.ts +0 -10
  178. package/dist/console/routes/logs/route.js +0 -32
  179. package/dist/console/routes/metrics/route.d.ts +0 -10
  180. package/dist/console/routes/metrics/route.js +0 -17
  181. package/dist/console/routes/route.d.ts +0 -6
  182. package/dist/console/routes/route.js +0 -5
  183. package/dist/console/routes/routes/route.d.ts +0 -6
  184. package/dist/console/routes/routes/route.js +0 -20
  185. package/dist/console/routes/services/route.d.ts +0 -6
  186. package/dist/console/routes/services/route.js +0 -12
  187. package/dist/console/routes/system/route.d.ts +0 -10
  188. package/dist/console/routes/system/route.js +0 -18
  189. package/dist/console/routes/traceDetail.d.ts +0 -16
  190. package/dist/console/routes/traceDetail.js +0 -14
  191. package/dist/console/routes/traces/route.d.ts +0 -10
  192. package/dist/console/routes/traces/route.js +0 -39
  193. package/dist/console/routes/tree.d.ts +0 -153
  194. package/dist/console/routes/tree.js +0 -29
  195. package/dist/console/ui/Errors.d.ts +0 -4
  196. package/dist/console/ui/Errors.js +0 -15
  197. package/dist/console/ui/Fibers.d.ts +0 -24
  198. package/dist/console/ui/Fibers.js +0 -121
  199. package/dist/console/ui/Git.d.ts +0 -20
  200. package/dist/console/ui/Git.js +0 -95
  201. package/dist/console/ui/Logs.d.ts +0 -4
  202. package/dist/console/ui/Logs.js +0 -25
  203. package/dist/console/ui/Metrics.d.ts +0 -4
  204. package/dist/console/ui/Metrics.js +0 -26
  205. package/dist/console/ui/Routes.d.ts +0 -8
  206. package/dist/console/ui/Routes.js +0 -70
  207. package/dist/console/ui/Services.d.ts +0 -10
  208. package/dist/console/ui/Services.js +0 -246
  209. package/dist/console/ui/Shell.d.ts +0 -10
  210. package/dist/console/ui/Shell.js +0 -7
  211. package/dist/console/ui/System.d.ts +0 -4
  212. package/dist/console/ui/System.js +0 -35
  213. package/dist/console/ui/Traces.d.ts +0 -12
  214. package/dist/console/ui/Traces.js +0 -179
  215. package/dist/datastar/actions/fetch.d.ts +0 -30
  216. package/dist/datastar/actions/fetch.js +0 -403
  217. package/dist/datastar/actions/peek.d.ts +0 -1
  218. package/dist/datastar/actions/peek.js +0 -13
  219. package/dist/datastar/actions/setAll.d.ts +0 -1
  220. package/dist/datastar/actions/setAll.js +0 -12
  221. package/dist/datastar/actions/toggleAll.d.ts +0 -1
  222. package/dist/datastar/actions/toggleAll.js +0 -12
  223. package/dist/datastar/attributes/attr.d.ts +0 -1
  224. package/dist/datastar/attributes/attr.js +0 -48
  225. package/dist/datastar/attributes/bind.d.ts +0 -1
  226. package/dist/datastar/attributes/bind.js +0 -175
  227. package/dist/datastar/attributes/class.d.ts +0 -1
  228. package/dist/datastar/attributes/class.js +0 -47
  229. package/dist/datastar/attributes/computed.d.ts +0 -1
  230. package/dist/datastar/attributes/computed.js +0 -26
  231. package/dist/datastar/attributes/effect.d.ts +0 -1
  232. package/dist/datastar/attributes/effect.js +0 -9
  233. package/dist/datastar/attributes/indicator.d.ts +0 -1
  234. package/dist/datastar/attributes/indicator.js +0 -30
  235. package/dist/datastar/attributes/init.d.ts +0 -1
  236. package/dist/datastar/attributes/init.js +0 -26
  237. package/dist/datastar/attributes/jsonSignals.d.ts +0 -1
  238. package/dist/datastar/attributes/jsonSignals.js +0 -30
  239. package/dist/datastar/attributes/on.d.ts +0 -1
  240. package/dist/datastar/attributes/on.js +0 -78
  241. package/dist/datastar/attributes/onIntersect.d.ts +0 -1
  242. package/dist/datastar/attributes/onIntersect.js +0 -53
  243. package/dist/datastar/attributes/onInterval.d.ts +0 -1
  244. package/dist/datastar/attributes/onInterval.js +0 -30
  245. package/dist/datastar/attributes/onSignalPatch.d.ts +0 -1
  246. package/dist/datastar/attributes/onSignalPatch.js +0 -42
  247. package/dist/datastar/attributes/ref.d.ts +0 -1
  248. package/dist/datastar/attributes/ref.js +0 -10
  249. package/dist/datastar/attributes/show.d.ts +0 -1
  250. package/dist/datastar/attributes/show.js +0 -31
  251. package/dist/datastar/attributes/signals.d.ts +0 -1
  252. package/dist/datastar/attributes/signals.js +0 -17
  253. package/dist/datastar/attributes/style.d.ts +0 -1
  254. package/dist/datastar/attributes/style.js +0 -50
  255. package/dist/datastar/attributes/text.d.ts +0 -1
  256. package/dist/datastar/attributes/text.js +0 -26
  257. package/dist/datastar/engine.d.ts +0 -162
  258. package/dist/datastar/engine.js +0 -999
  259. package/dist/datastar/happydom.d.ts +0 -1
  260. package/dist/datastar/happydom.js +0 -8
  261. package/dist/datastar/index.d.ts +0 -24
  262. package/dist/datastar/index.js +0 -24
  263. package/dist/datastar/load.d.ts +0 -24
  264. package/dist/datastar/load.js +0 -24
  265. package/dist/datastar/utils.d.ts +0 -51
  266. package/dist/datastar/utils.js +0 -202
  267. package/dist/datastar/watchers/patchElements.d.ts +0 -1
  268. package/dist/datastar/watchers/patchElements.js +0 -399
  269. package/dist/datastar/watchers/patchSignals.d.ts +0 -1
  270. package/dist/datastar/watchers/patchSignals.js +0 -14
  271. package/dist/experimental/EncryptedCookies.d.ts +0 -48
  272. package/dist/experimental/EncryptedCookies.js +0 -212
  273. package/dist/experimental/SseHttpResponse.d.ts +0 -7
  274. package/dist/experimental/SseHttpResponse.js +0 -28
  275. package/dist/experimental/index.d.ts +0 -1
  276. package/dist/experimental/index.js +0 -1
  277. package/dist/hyper/Hyper.d.ts +0 -25
  278. package/dist/hyper/Hyper.js +0 -23
  279. package/dist/hyper/HyperHtml.d.ts +0 -23
  280. package/dist/hyper/HyperHtml.js +0 -150
  281. package/dist/hyper/HyperHtml.test.d.ts +0 -1
  282. package/dist/hyper/HyperHtml.test.js +0 -197
  283. package/dist/hyper/HyperNode.d.ts +0 -14
  284. package/dist/hyper/HyperNode.js +0 -11
  285. package/dist/hyper/HyperRoute.d.ts +0 -8
  286. package/dist/hyper/HyperRoute.js +0 -32
  287. package/dist/hyper/HyperRoute.test.d.ts +0 -1
  288. package/dist/hyper/HyperRoute.test.js +0 -83
  289. package/dist/hyper/html.d.ts +0 -11
  290. package/dist/hyper/html.js +0 -30
  291. package/dist/hyper/index.d.ts +0 -6
  292. package/dist/hyper/index.js +0 -5
  293. package/dist/hyper/jsx-runtime.d.ts +0 -7
  294. package/dist/hyper/jsx-runtime.js +0 -8
  295. package/dist/index.d.ts +0 -8
  296. package/dist/index.js +0 -8
  297. package/dist/inference_check.d.ts +0 -1
  298. package/dist/inference_check.js +0 -15
  299. package/dist/lint/plugin.d.ts +0 -86
  300. package/dist/lint/plugin.js +0 -341
  301. package/dist/middlewares/BasicAuthMiddleware.d.ts +0 -8
  302. package/dist/middlewares/BasicAuthMiddleware.js +0 -22
  303. package/dist/middlewares/index.d.ts +0 -1
  304. package/dist/middlewares/index.js +0 -1
  305. package/dist/node/Effectify.d.ts +0 -209
  306. package/dist/node/Effectify.js +0 -19
  307. package/dist/node/FileSystem.d.ts +0 -7
  308. package/dist/node/FileSystem.js +0 -420
  309. package/dist/node/NodeFileSystem.d.ts +0 -7
  310. package/dist/node/NodeFileSystem.js +0 -410
  311. package/dist/node/NodeUtils.d.ts +0 -2
  312. package/dist/node/NodeUtils.js +0 -20
  313. package/dist/node/PlatformError.d.ts +0 -46
  314. package/dist/node/PlatformError.js +0 -43
  315. package/dist/node/Utils.d.ts +0 -1
  316. package/dist/node/Utils.js +0 -19
  317. package/dist/repro_fail.d.ts +0 -1
  318. package/dist/repro_fail.js +0 -14
  319. package/dist/sql/bun/index.d.ts +0 -3
  320. package/dist/sql/bun/index.js +0 -75
  321. package/dist/sql/mssql/docker.d.ts +0 -2
  322. package/dist/sql/mssql/docker.js +0 -67
  323. package/dist/sql/mssql/index.d.ts +0 -21
  324. package/dist/sql/mssql/index.js +0 -113
  325. package/dist/testing/TestHttpClient.d.ts +0 -13
  326. package/dist/testing/TestHttpClient.js +0 -68
  327. package/dist/testing/TestLogger.d.ts +0 -13
  328. package/dist/testing/TestLogger.js +0 -32
  329. package/dist/testing/index.d.ts +0 -2
  330. package/dist/testing/index.js +0 -2
  331. package/dist/testing/utils.d.ts +0 -9
  332. package/dist/testing/utils.js +0 -39
  333. package/dist/x/cloudflare/CloudflareTunnel.d.ts +0 -10
  334. package/dist/x/cloudflare/CloudflareTunnel.js +0 -30
  335. package/dist/x/cloudflare/index.d.ts +0 -1
  336. package/dist/x/cloudflare/index.js +0 -1
  337. package/dist/x/datastar/Datastar.d.ts +0 -6
  338. package/dist/x/datastar/Datastar.js +0 -47
  339. package/dist/x/datastar/index.d.ts +0 -1
  340. package/dist/x/datastar/index.js +0 -1
  341. package/dist/x/tailscale/TailscaleTunnel.d.ts +0 -15
  342. package/dist/x/tailscale/TailscaleTunnel.js +0 -68
  343. package/dist/x/tailscale/index.d.ts +0 -1
  344. package/dist/x/tailscale/index.js +0 -1
  345. package/dist/x/tailwind/TailwindPlugin.d.ts +0 -23
  346. package/dist/x/tailwind/TailwindPlugin.js +0 -219
  347. package/dist/x/tailwind/compile.d.ts +0 -19
  348. package/dist/x/tailwind/compile.js +0 -154
  349. package/dist/x/tailwind/plugin.d.ts +0 -2
  350. package/dist/x/tailwind/plugin.js +0 -15
  351. /package/src/{Sql.ts → sql/Sql.ts} +0 -0
@@ -1,28 +0,0 @@
1
- import * as HttpServerResponse from "@effect/platform/HttpServerResponse";
2
- import * as Duration from "effect/Duration";
3
- import * as Effect from "effect/Effect";
4
- import * as Function from "effect/Function";
5
- import * as Schedule from "effect/Schedule";
6
- import * as Stream from "effect/Stream";
7
- import * as StreamExtra from "../StreamExtra.js";
8
- const DefaultHeartbeatInterval = Duration.seconds(5);
9
- export const make = (stream, options) => Effect.gen(function* () {
10
- const heartbeat = Stream.repeat(Stream.succeed(null), Schedule.spaced(options?.heartbeatInterval ?? DefaultHeartbeatInterval));
11
- const encoder = new TextEncoder();
12
- const events = Function.pipe(Stream.merge(heartbeat.pipe(Stream.map(() => ":\n\n")), stream.pipe(Stream.map(event => `data: ${JSON.stringify(event)}\n\n`))),
13
- // without Stream.tap, only two events are sent
14
- // Effect.fork(Stream.runDrain) doesn't seem to work.
15
- // Asked for help here: [2025-04-09]
16
- // https://discord.com/channels/795981131316985866/1359523331400929341
17
- Stream.tap(v => Effect.gen(function* () { })), Stream.map(str => encoder.encode(str)));
18
- const toStream = StreamExtra.toReadableStreamRuntimePatched(yield* Effect.runtime());
19
- // see toStream to understand why we're not using
20
- // HttpServerResponse.stream here.
21
- return HttpServerResponse.raw(toStream(events), {
22
- headers: {
23
- "Content-Type": "text/event-stream",
24
- "Cache-Control": "no-cache",
25
- "Connection": "keep-alive",
26
- },
27
- });
28
- });
@@ -1 +0,0 @@
1
- export * as EncryptedCookies from "./EncryptedCookies.ts";
@@ -1 +0,0 @@
1
- export * as EncryptedCookies from "./EncryptedCookies.js";
@@ -1,25 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import type { JSX } from "./jsx.d.ts";
3
- type Elements = JSX.IntrinsicElements;
4
- type Children = JSX.Children;
5
- export type { Children, Elements, JSX };
6
- declare const Hyper_base: Context.TagClass<Hyper, "Hyper", {}>;
7
- export declare class Hyper extends Hyper_base {
8
- }
9
- type Primitive = string | number | boolean | null | undefined;
10
- export type HyperType = string | HyperComponent;
11
- export type HyperProps = {
12
- [key: string]: Primitive | ReadonlyArray<Primitive> | HyperNode | HyperNode[] | null | undefined;
13
- };
14
- export type HyperComponent = (props: HyperProps) => HyperNode | Primitive;
15
- export interface HyperNode {
16
- type: HyperType;
17
- props: HyperProps;
18
- }
19
- export declare function h(type: HyperType, props: HyperProps): HyperNode;
20
- export declare function unsafeUse<Value>(tag: Context.Tag<any, Value>): Value;
21
- export type GenericJsxObject = {
22
- type: any;
23
- props: any;
24
- };
25
- export declare function isGenericJsxObject(value: unknown): value is GenericJsxObject;
@@ -1,23 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import * as Fiber from "effect/Fiber";
3
- import * as Option from "effect/Option";
4
- export class Hyper extends Context.Tag("Hyper")() {
5
- }
6
- const NoChildren = Object.freeze([]);
7
- export function h(type, props) {
8
- return {
9
- type,
10
- props: {
11
- ...props,
12
- children: props.children ?? NoChildren,
13
- },
14
- };
15
- }
16
- export function unsafeUse(tag) {
17
- const currentFiber = Option.getOrThrow(Fiber.getCurrentFiber());
18
- const context = currentFiber.currentContext;
19
- return Context.unsafeGet(context, tag);
20
- }
21
- export function isGenericJsxObject(value) {
22
- return typeof value === "object" && value !== null && "type" in value && "props" in value;
23
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Renders Hyper JSX nodes to HTML.
3
- *
4
- * Effect Start comes with {@link Hyper} and {@link JsxRuntime} to enable
5
- * JSX support. The advantage of using JSX over HTML strings or templates
6
- * is type safety and better editor support.
7
- *
8
- * JSX nodes are compatible with React's and Solid's.
9
-
10
- * You can enable JSX support by updating `tsconfig.json`:
11
- *
12
- * {
13
- * compilerOptions: {
14
- * jsx: "react-jsx",
15
- * jsxImportSource: "effect-start" | "react" | "praect" // etc.
16
- * }
17
- * }
18
- */
19
- import type * as HyperNode from "./HyperNode.ts";
20
- import type { JSX } from "./jsx.d.ts";
21
- export declare function renderToString(node: JSX.Children, hooks?: {
22
- onNode?: (node: HyperNode.HyperNode) => void;
23
- }): string;
@@ -1,150 +0,0 @@
1
- /**
2
- * Renders Hyper JSX nodes to HTML.
3
- *
4
- * Effect Start comes with {@link Hyper} and {@link JsxRuntime} to enable
5
- * JSX support. The advantage of using JSX over HTML strings or templates
6
- * is type safety and better editor support.
7
- *
8
- * JSX nodes are compatible with React's and Solid's.
9
-
10
- * You can enable JSX support by updating `tsconfig.json`:
11
- *
12
- * {
13
- * compilerOptions: {
14
- * jsx: "react-jsx",
15
- * jsxImportSource: "effect-start" | "react" | "praect" // etc.
16
- * }
17
- * }
18
- */
19
- const EMPTY_TAGS = [
20
- "area",
21
- "base",
22
- "br",
23
- "col",
24
- "command",
25
- "embed",
26
- "hr",
27
- "img",
28
- "input",
29
- "keygen",
30
- "link",
31
- "meta",
32
- "param",
33
- "source",
34
- "track",
35
- "wbr",
36
- ];
37
- let esc = (str) => String(str).replace(/[&<>"']/g, (s) => `&${map[s]};`);
38
- let escSQ = (str) => String(str).replace(/[&<>']/g, (s) => `&${map[s]};`);
39
- let map = {
40
- "&": "amp",
41
- "<": "lt",
42
- ">": "gt",
43
- '"': "quot",
44
- "'": "#39",
45
- };
46
- const RAW_TEXT_TAGS = ["script", "style"];
47
- export function renderToString(node, hooks) {
48
- const stack = [node];
49
- let result = "";
50
- while (stack.length > 0) {
51
- const current = stack.pop();
52
- if (typeof current === "string") {
53
- if (current.startsWith("<") && current.endsWith(">")) {
54
- // This is a closing tag, don't escape it
55
- result += current;
56
- }
57
- else {
58
- result += esc(current);
59
- }
60
- continue;
61
- }
62
- if (typeof current === "number") {
63
- result += esc(current);
64
- continue;
65
- }
66
- if (typeof current === "boolean") {
67
- // React-like behavior: booleans render nothing
68
- continue;
69
- }
70
- if (current === null || current === undefined) {
71
- // React-like behavior: null/undefined render nothing
72
- continue;
73
- }
74
- if (Array.isArray(current)) {
75
- // Handle arrays by pushing all items to stack in reverse order
76
- for (let i = current.length - 1; i >= 0; i--) {
77
- stack.push(current[i]);
78
- }
79
- continue;
80
- }
81
- if (current && typeof current === "object" && current.type) {
82
- hooks?.onNode?.(current);
83
- if (typeof current.type === "function") {
84
- const componentResult = current.type(current.props);
85
- if (componentResult != null) {
86
- stack.push(componentResult);
87
- }
88
- continue;
89
- }
90
- const { type, props } = current;
91
- result += `<${type}`;
92
- for (const key in props) {
93
- if (key !== "children" &&
94
- key !== "innerHTML" && // Solid-specific
95
- key !== "dangerouslySetInnerHTML" && // React-specific
96
- props[key] !== false &&
97
- props[key] != null) {
98
- if (props[key] === true) {
99
- result += ` ${esc(key)}`;
100
- }
101
- else {
102
- const resolvedKey = key === "className" ? "class" : key;
103
- const value = props[key];
104
- if (key.startsWith("data-") && typeof value === "function") {
105
- result += ` ${esc(resolvedKey)}="${esc(value.toString())}"`;
106
- }
107
- else if (key.startsWith("data-") && typeof value === "object") {
108
- result += ` ${esc(resolvedKey)}='${escSQ(JSON.stringify(value))}'`;
109
- }
110
- else {
111
- result += ` ${esc(resolvedKey)}="${esc(value)}"`;
112
- }
113
- }
114
- }
115
- }
116
- result += ">";
117
- if (!EMPTY_TAGS.includes(type)) {
118
- stack.push(`</${type}>`);
119
- // React-specific
120
- const html = props.dangerouslySetInnerHTML?.__html ?? props.innerHTML;
121
- if (html) {
122
- result += html;
123
- }
124
- else {
125
- const children = props.children;
126
- if (type === "script" && typeof children === "function") {
127
- result += `(${children.toString()})(window)`;
128
- }
129
- else if (RAW_TEXT_TAGS.includes(type) && children != null) {
130
- result += Array.isArray(children) ? children.join("") : children;
131
- }
132
- else if (Array.isArray(children)) {
133
- for (let i = children.length - 1; i >= 0; i--) {
134
- stack.push(children[i]);
135
- }
136
- }
137
- else if (children != null) {
138
- stack.push(children);
139
- }
140
- }
141
- }
142
- }
143
- else if (current && typeof current === "object") {
144
- // Handle objects without type property - convert to string or ignore
145
- // This prevents [object Object] from appearing
146
- continue;
147
- }
148
- }
149
- return result;
150
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,197 +0,0 @@
1
- import { jsx as _jsx } from "effect-start/jsx-runtime";
2
- /** @jsxImportSource effect-start */
3
- import * as test from "bun:test";
4
- import * as HyperHtml from "./HyperHtml.js";
5
- import * as HyperNode from "./HyperNode.js";
6
- test.it("boolean true attributes render without value (React-like)", () => {
7
- const node = HyperNode.make("div", {
8
- hidden: true,
9
- disabled: true,
10
- "data-active": true,
11
- });
12
- const html = HyperHtml.renderToString(node);
13
- test.expect(html).toBe("<div hidden disabled data-active></div>");
14
- });
15
- test.it("boolean false attributes are omitted", () => {
16
- const node = HyperNode.make("div", {
17
- hidden: false,
18
- disabled: false,
19
- "data-active": false,
20
- });
21
- const html = HyperHtml.renderToString(node);
22
- test.expect(html).toBe("<div></div>");
23
- });
24
- test.it("string attributes render with values", () => {
25
- const node = HyperNode.make("div", {
26
- id: "test",
27
- class: "my-class",
28
- "data-value": "hello",
29
- });
30
- const html = HyperHtml.renderToString(node);
31
- test.expect(html).toBe('<div id="test" class="my-class" data-value="hello"></div>');
32
- });
33
- test.it("number attributes render with values", () => {
34
- const node = HyperNode.make("input", {
35
- type: "number",
36
- min: 0,
37
- max: 100,
38
- value: 50,
39
- });
40
- const html = HyperHtml.renderToString(node);
41
- test.expect(html).toBe('<input type="number" min="0" max="100" value="50">');
42
- });
43
- test.it("null and undefined attributes are omitted", () => {
44
- const node = HyperNode.make("div", {
45
- id: null,
46
- class: undefined,
47
- "data-test": "value",
48
- });
49
- const html = HyperHtml.renderToString(node);
50
- test.expect(html).toBe('<div data-test="value"></div>');
51
- });
52
- test.it("mixed boolean and string attributes", () => {
53
- const node = HyperNode.make("input", {
54
- type: "checkbox",
55
- checked: true,
56
- disabled: false,
57
- name: "test",
58
- value: "on",
59
- });
60
- const html = HyperHtml.renderToString(node);
61
- test.expect(html).toBe('<input type="checkbox" checked name="test" value="on">');
62
- });
63
- test.it("data-* attributes with object values use single-quoted JSON", () => {
64
- const node = HyperNode.make("div", {
65
- "data-signals": {
66
- draft: "",
67
- pendingDraft: "",
68
- username: "User123",
69
- },
70
- });
71
- const html = HyperHtml.renderToString(node);
72
- test
73
- .expect(html)
74
- .toBe(`<div data-signals='{"draft":"","pendingDraft":"","username":"User123"}'></div>`);
75
- });
76
- test.it("data-* attributes with array values use single-quoted JSON", () => {
77
- const node = HyperNode.make("div", {
78
- "data-items": [1, 2, 3],
79
- });
80
- const html = HyperHtml.renderToString(node);
81
- test.expect(html).toBe("<div data-items='[1,2,3]'></div>");
82
- });
83
- test.it("data-* attributes with nested object values use single-quoted JSON", () => {
84
- const node = HyperNode.make("div", {
85
- "data-config": {
86
- user: { name: "John", active: true },
87
- settings: { theme: "dark" },
88
- },
89
- });
90
- const html = HyperHtml.renderToString(node);
91
- test
92
- .expect(html)
93
- .toBe(`<div data-config='{"user":{"name":"John","active":true},"settings":{"theme":"dark"}}'></div>`);
94
- });
95
- test.it("data-* object values with single quotes in values are escaped", () => {
96
- const node = HyperNode.make("div", {
97
- "data-signals": {
98
- message: "it's a test",
99
- name: "O'Brien",
100
- },
101
- });
102
- const html = HyperHtml.renderToString(node);
103
- test
104
- .expect(html)
105
- .toBe(`<div data-signals='{"message":"it&#39;s a test","name":"O&#39;Brien"}'></div>`);
106
- });
107
- test.it("data-* string values are not JSON stringified", () => {
108
- const node = HyperNode.make("div", {
109
- "data-value": "hello world",
110
- });
111
- const html = HyperHtml.renderToString(node);
112
- test.expect(html).toBe('<div data-value="hello world"></div>');
113
- });
114
- test.it("non-data attributes with object values are not JSON stringified", () => {
115
- const node = HyperNode.make("div", {
116
- style: "color: red",
117
- });
118
- const html = HyperHtml.renderToString(node);
119
- test.expect(html).toBe('<div style="color: red"></div>');
120
- });
121
- test.it("script with function child renders as IIFE", () => {
122
- const handler = (window) => {
123
- console.log("Hello from", window.document.title);
124
- };
125
- const node = HyperNode.make("script", {
126
- children: handler,
127
- });
128
- const html = HyperHtml.renderToString(node);
129
- test.expect(html).toBe(`<script>(${handler.toString()})(window)</script>`);
130
- });
131
- test.it("script with arrow function child renders as IIFE", () => {
132
- const node = HyperNode.make("script", {
133
- children: (window) => {
134
- window.alert("test");
135
- },
136
- });
137
- const html = HyperHtml.renderToString(node);
138
- test.expect(html).toContain("<script>(");
139
- test.expect(html).toContain(")(window)</script>");
140
- test.expect(html).toContain("window.alert");
141
- });
142
- test.it("script with string child renders without escaping", () => {
143
- const node = HyperNode.make("script", {
144
- children: "console.log('hello')",
145
- });
146
- const html = HyperHtml.renderToString(node);
147
- test.expect(html).toBe("<script>console.log('hello')</script>");
148
- });
149
- test.it("script with string child preserves ampersands and quotes", () => {
150
- const node = HyperNode.make("script", {
151
- children: 'if (a && b) { console.log("yes") }',
152
- });
153
- const html = HyperHtml.renderToString(node);
154
- test.expect(html).toBe('<script>if (a && b) { console.log("yes") }</script>');
155
- });
156
- test.it("style tag content is not escaped", () => {
157
- const node = HyperNode.make("style", {
158
- children: ".foo > .bar { content: '&'; }",
159
- });
160
- const html = HyperHtml.renderToString(node);
161
- test.expect(html).toBe("<style>.foo > .bar { content: '&'; }</style>");
162
- });
163
- test.it("script with attributes and no children", () => {
164
- const node = HyperNode.make("script", {
165
- type: "module",
166
- src: "https://example.com/app.js",
167
- });
168
- const html = HyperHtml.renderToString(node);
169
- test.expect(html).toBe('<script type="module" src="https://example.com/app.js"></script>');
170
- });
171
- test.it("normal tag string content is escaped", () => {
172
- const node = HyperNode.make("div", {
173
- children: "a && b",
174
- });
175
- const html = HyperHtml.renderToString(node);
176
- test.expect(html).toBe("<div>a &amp;&amp; b</div>");
177
- });
178
- test.it("data-* function values are serialized with toString", () => {
179
- const node = HyperNode.make("div", {
180
- "data-on-click": () => console.log("clicked"),
181
- });
182
- const html = HyperHtml.renderToString(node);
183
- test.expect(html).toContain("data-on-click=");
184
- test.expect(html).toContain("console.log");
185
- });
186
- test.it("data-* object values don't render as [object Object]", () => {
187
- const html = HyperHtml.renderToString(_jsx("div", { "data-signals": { isOpen: false, count: 42 }, children: "content" }));
188
- test.expect(html).toBe(`<div data-signals='{"isOpen":false,"count":42}'>content</div>`);
189
- test.expect(html).not.toContain("[object Object]");
190
- });
191
- test.it("JSX component with data-* object values", () => {
192
- function TestComponent() {
193
- return (_jsx("div", { "data-signals": { isOpen: false }, children: _jsx("span", { children: "nested" }) }));
194
- }
195
- const html = HyperHtml.renderToString(_jsx(TestComponent, {}));
196
- test.expect(html).toBe(`<div data-signals='{"isOpen":false}'><span>nested</span></div>`);
197
- });
@@ -1,14 +0,0 @@
1
- export declare const TypeId: unique symbol;
2
- export type TypeId = typeof TypeId;
3
- type Primitive = string | number | boolean | null | undefined;
4
- export type Type = string | HyperComponent;
5
- export type Props = {
6
- [key: string]: Primitive | HyperNode | Iterable<Primitive | HyperNode> | Record<string, unknown> | ((window: Window) => void);
7
- };
8
- export type HyperComponent = (props: Props) => HyperNode | Primitive;
9
- export interface HyperNode {
10
- type: Type;
11
- props: Props;
12
- }
13
- export declare function make(type: Type, props: Props): HyperNode;
14
- export {};
@@ -1,11 +0,0 @@
1
- export const TypeId = Symbol.for("effect-start/HyperNode");
2
- const NoChildren = Object.freeze([]);
3
- export function make(type, props) {
4
- return {
5
- type,
6
- props: {
7
- ...props,
8
- children: props.children ?? NoChildren,
9
- },
10
- };
11
- }
@@ -1,8 +0,0 @@
1
- import * as Route from "../Route.ts";
2
- import type * as RouteBody from "../RouteBody.ts";
3
- import type { JSX } from "./jsx.d.ts";
4
- export declare function html<D extends Route.RouteDescriptor.Any, B extends {}, I extends Route.Route.Tuple, E = never, R = never>(handler: RouteBody.HandlerInput<NoInfer<D & B & Route.ExtractBindings<I> & {
5
- format: "html";
6
- }>, JSX.Children, E, R>): (self: Route.RouteSet.RouteSet<D, B, I>) => Route.RouteSet.RouteSet<D, B, [...I, Route.Route.Route<{
7
- format: "html";
8
- }, {}, string, E, R>]>;
@@ -1,32 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Entity from "../Entity.js";
3
- import * as Route from "../Route.js";
4
- import * as HyperHtml from "./HyperHtml.js";
5
- function renderValue(value) {
6
- if (Entity.isEntity(value)) {
7
- return Entity.make(HyperHtml.renderToString(value.body), {
8
- status: value.status,
9
- url: value.url,
10
- headers: value.headers,
11
- });
12
- }
13
- return HyperHtml.renderToString(value);
14
- }
15
- function normalizeToEffect(handler, context, next) {
16
- if (Effect.isEffect(handler)) {
17
- return handler;
18
- }
19
- if (typeof handler === "function") {
20
- const result = handler(context, next);
21
- if (Effect.isEffect(result)) {
22
- return result;
23
- }
24
- return Effect.gen(function* () {
25
- return yield* result;
26
- });
27
- }
28
- return Effect.succeed(handler);
29
- }
30
- export function html(handler) {
31
- return Route.html((context, next) => Effect.map(normalizeToEffect(handler, context, next), renderValue));
32
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,83 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "effect-start/jsx-runtime";
2
- /** @jsxImportSource effect-start */
3
- import * as test from "bun:test";
4
- import * as Effect from "effect/Effect";
5
- import * as Entity from "../Entity.js";
6
- import * as Http from "../Http.js";
7
- import * as Route from "../Route.js";
8
- import * as RouteHttp from "../RouteHttp.js";
9
- import * as HyperRoute from "./HyperRoute.js";
10
- test.describe("HyperRoute.html", () => {
11
- test.it("renders JSX to HTML string", async () => {
12
- const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html(_jsx("div", { children: "Hello World" }))));
13
- const response = await Http.fetch(handler, { path: "/" });
14
- test.expect(response.status).toBe(200);
15
- test.expect(response.headers.get("Content-Type")).toBe("text/html; charset=utf-8");
16
- test.expect(await response.text()).toBe("<div>Hello World</div>");
17
- });
18
- test.it("renders nested JSX elements", async () => {
19
- const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html(_jsxs("div", { class: "container", children: [_jsx("h1", { children: "Title" }), _jsx("p", { children: "Paragraph" })] }))));
20
- const response = await Http.fetch(handler, { path: "/" });
21
- test
22
- .expect(await response.text())
23
- .toBe('<div class="container"><h1>Title</h1><p>Paragraph</p></div>');
24
- });
25
- test.it("renders JSX from Effect", async () => {
26
- const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html(Effect.succeed(_jsx("span", { children: "From Effect" })))));
27
- const response = await Http.fetch(handler, { path: "/" });
28
- test.expect(await response.text()).toBe("<span>From Effect</span>");
29
- });
30
- test.it("renders JSX from generator function", async () => {
31
- const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html(Effect.gen(function* () {
32
- const name = yield* Effect.succeed("World");
33
- return _jsxs("div", { children: ["Hello ", name] });
34
- }))));
35
- const response = await Http.fetch(handler, { path: "/" });
36
- test.expect(await response.text()).toBe("<div>Hello World</div>");
37
- });
38
- test.it("renders JSX from handler function", async () => {
39
- const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html((context) => Effect.succeed(_jsx("div", { children: "Request received" })))));
40
- const response = await Http.fetch(handler, { path: "/" });
41
- test.expect(await response.text()).toBe("<div>Request received</div>");
42
- });
43
- test.it("renders JSX with dynamic content", async () => {
44
- const items = ["Apple", "Banana", "Cherry"];
45
- const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html(_jsx("ul", { children: items.map((item) => (_jsx("li", { children: item }))) }))));
46
- const response = await Http.fetch(handler, { path: "/" });
47
- test.expect(await response.text()).toBe("<ul><li>Apple</li><li>Banana</li><li>Cherry</li></ul>");
48
- });
49
- test.it("handles Entity with JSX body", async () => {
50
- const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html(Entity.make(_jsx("div", { children: "With Entity" }), { status: 201 }))));
51
- const response = await Http.fetch(handler, { path: "/" });
52
- test.expect(response.status).toBe(201);
53
- test.expect(await response.text()).toBe("<div>With Entity</div>");
54
- });
55
- test.it("renders data-* attributes with object values as JSON", async () => {
56
- const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html(_jsx("div", { "data-signals": {
57
- draft: "",
58
- pendingDraft: "",
59
- username: "User123",
60
- }, children: "Content" }))));
61
- const response = await Http.fetch(handler, { path: "/" });
62
- test
63
- .expect(await response.text())
64
- .toBe(`<div data-signals='{"draft":"","pendingDraft":"","username":"User123"}'>Content</div>`);
65
- });
66
- test.it("data-on-click function argument is typed as DataEvent", () => {
67
- const node = (_jsx("button", { "data-on:click": (e) => {
68
- test.expectTypeOf(e).toEqualTypeOf();
69
- test.expectTypeOf(e.window).toEqualTypeOf();
70
- } }));
71
- test.expect(node).toBeDefined();
72
- });
73
- test.it("renders script with function child as IIFE", async () => {
74
- const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html(_jsx("script", { children: (window) => {
75
- console.log("Hello from", window.document.title);
76
- } }))));
77
- const response = await Http.fetch(handler, { path: "/" });
78
- const text = await response.text();
79
- test.expect(text).toContain("<script>(");
80
- test.expect(text).toContain(")(window)</script>");
81
- test.expect(text).toContain("window.document.title");
82
- });
83
- });
@@ -1,11 +0,0 @@
1
- declare const HtmlStringSymbol: unique symbol;
2
- export interface HtmlString {
3
- readonly [HtmlStringSymbol]: true;
4
- readonly value: string;
5
- }
6
- export type HtmlValue = string | number | bigint | boolean | null | undefined | HtmlString | Function | Record<string, unknown> | ReadonlyArray<HtmlValue>;
7
- export declare const html: {
8
- (strings: TemplateStringsArray, ...values: Array<HtmlValue>): HtmlString;
9
- raw(value: string): HtmlString;
10
- };
11
- export {};
@@ -1,30 +0,0 @@
1
- const HtmlStringSymbol = Symbol.for("HtmlString");
2
- const makeHtmlString = (value) => ({
3
- [HtmlStringSymbol]: true,
4
- value,
5
- });
6
- const isHtmlString = (value) => typeof value === "object" && value !== null && HtmlStringSymbol in value;
7
- const resolveValue = (value) => {
8
- if (value === null || value === undefined || value === false || value === true)
9
- return "";
10
- if (isHtmlString(value))
11
- return value.value;
12
- if (Array.isArray(value))
13
- return value.map(resolveValue).join("");
14
- if (typeof value === "function")
15
- return value.toString();
16
- if (typeof value === "object")
17
- return JSON.stringify(value);
18
- if (typeof value === "string")
19
- return value;
20
- return String(value);
21
- };
22
- export const html = (strings, ...values) => {
23
- let result = strings[0];
24
- for (let i = 0; i < values.length; i++) {
25
- result += resolveValue(values[i]);
26
- result += strings[i + 1];
27
- }
28
- return makeHtmlString(result);
29
- };
30
- html.raw = (value) => makeHtmlString(value);