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,51 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Layer from "effect/Layer";
3
- import * as Option from "effect/Option";
4
- import * as Entity from "../Entity.js";
5
- import * as PathPattern from "../PathPattern.js";
6
- import * as Route from "../Route.js";
7
- import * as RouteTree from "../RouteTree.js";
8
- import * as Values from "../Values.js";
9
- import * as Bundle from "./Bundle.js";
10
- /**
11
- * Creates a GET route that serves bundle artifacts.
12
- * Mount at a path with a wildcard param (any name works).
13
- *
14
- * ```ts
15
- * RouteTree.make({
16
- * "/_bundle/:path+": BundleRoute.make(Bundle.ClientBundle),
17
- * })
18
- * ```
19
- */
20
- export const make = (tag) => Route.get(Route.render(function* (ctx) {
21
- const bundle = yield* tag;
22
- const url = new URL(ctx.request.url);
23
- const mountPath = ctx.path ?? "/";
24
- const params = PathPattern.match(mountPath, url.pathname);
25
- const artifactPath = params ? Values.firstValue(params) : undefined;
26
- if (!artifactPath) {
27
- return Entity.make(new Uint8Array(0), { status: 404 });
28
- }
29
- const blob = bundle.getArtifact(artifactPath);
30
- if (!blob) {
31
- return Entity.make(new Uint8Array(0), { status: 404 });
32
- }
33
- const bytes = new Uint8Array(yield* Effect.promise(() => blob.arrayBuffer()));
34
- return Entity.make(bytes, {
35
- headers: {
36
- "content-type": blob.type || "application/octet-stream",
37
- "cache-control": "public, max-age=31536000, immutable",
38
- },
39
- });
40
- }));
41
- export const client = () => make(Bundle.ClientBundle);
42
- export const layer = (options) => Layer.effect(Route.Routes, Effect.gen(function* () {
43
- const existing = yield* Effect.serviceOption(Route.Routes).pipe(Effect.andThen(Option.getOrUndefined));
44
- const path = options?.path ?? "/_bundle/:path+";
45
- const bundleTree = Route.tree({
46
- [path]: make(options?.bundle ?? Bundle.ClientBundle),
47
- });
48
- if (!existing)
49
- return bundleTree;
50
- return RouteTree.merge(existing, bundleTree);
51
- }));
@@ -1,2 +0,0 @@
1
- export declare function getOverlay(): HTMLPreElement;
2
- export declare function showBuildError(message: string): void;
@@ -1,32 +0,0 @@
1
- const OVERLAY_ID = "_bundler_error_overlay";
2
- export function getOverlay() {
3
- let overlay = document.getElementById(OVERLAY_ID);
4
- if (!overlay) {
5
- overlay = document.createElement("pre");
6
- overlay.id = OVERLAY_ID;
7
- Object.assign(overlay.style, {
8
- position: "fixed",
9
- top: "0",
10
- left: "0",
11
- right: "0",
12
- maxHeight: "40%",
13
- overflowY: "auto",
14
- margin: "0",
15
- padding: "4px",
16
- background: "black",
17
- color: "red",
18
- fontFamily: "monospace",
19
- zIndex: "2147483647",
20
- whiteSpace: "pre-wrap",
21
- });
22
- document.body.appendChild(overlay);
23
- }
24
- return overlay;
25
- }
26
- export function showBuildError(message) {
27
- const overlay = getOverlay();
28
- const atBottom = overlay.scrollTop + overlay.clientHeight >= overlay.scrollHeight - 1;
29
- overlay.textContent += message + "\n";
30
- if (atBottom)
31
- overlay.scrollTop = overlay.scrollHeight;
32
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Persist current scroll state to session storage.
3
- * Scroll state is saved relatively to visible elements.
4
- */
5
- export declare function persist(): void;
6
- export declare function restore(): void;
@@ -1,94 +0,0 @@
1
- const ScrollKey = "_BUNDLER_SCROLL";
2
- /**
3
- * Persist current scroll state to session storage.
4
- * Scroll state is saved relatively to visible elements.
5
- */
6
- export function persist() {
7
- const anchors = [];
8
- const step = window.innerHeight / 4;
9
- for (let i = 1; i <= 3; i++) {
10
- const y = step * i;
11
- const element = document.elementFromPoint(0, y);
12
- if (!element)
13
- continue;
14
- const target = element.id ? element : (element.closest("[id]") ?? element);
15
- anchors.push({
16
- selector: selectorFromElement(target),
17
- offset: target.getBoundingClientRect().top,
18
- });
19
- }
20
- const state = {
21
- anchors,
22
- scrollY: window.scrollY,
23
- };
24
- sessionStorage.setItem(ScrollKey, JSON.stringify(state));
25
- }
26
- export function restore() {
27
- const timeout = 3000;
28
- const tick = 50;
29
- const raw = sessionStorage.getItem(ScrollKey);
30
- if (!raw)
31
- return;
32
- sessionStorage.removeItem(ScrollKey);
33
- const state = JSON.parse(raw);
34
- const apply = () => {
35
- for (const anchor of state.anchors) {
36
- const element = document.querySelector(anchor.selector);
37
- if (element) {
38
- const rect = element.getBoundingClientRect();
39
- const top = window.scrollY + rect.top - anchor.offset;
40
- window.scrollTo({
41
- top,
42
- });
43
- return;
44
- }
45
- }
46
- window.scrollTo({
47
- top: state.scrollY,
48
- });
49
- };
50
- let observer;
51
- let stableTimer;
52
- const deadline = setTimeout(() => {
53
- observer.disconnect();
54
- if (stableTimer)
55
- clearTimeout(stableTimer);
56
- apply();
57
- }, timeout);
58
- observer = new MutationObserver(() => {
59
- if (stableTimer)
60
- clearTimeout(stableTimer);
61
- stableTimer = setTimeout(() => {
62
- observer.disconnect();
63
- clearTimeout(deadline);
64
- apply();
65
- }, tick);
66
- });
67
- observer.observe(document.body, {
68
- subtree: true,
69
- childList: true,
70
- attributes: true,
71
- characterData: true,
72
- });
73
- stableTimer = setTimeout(() => {
74
- observer.disconnect();
75
- clearTimeout(deadline);
76
- apply();
77
- }, tick);
78
- }
79
- function selectorFromElement(element) {
80
- if (element.id) {
81
- return `#${CSS.escape(element.id)}`;
82
- }
83
- const parts = [];
84
- let current = element;
85
- while (current && current !== document.body) {
86
- const parent = current.parentElement;
87
- if (!parent)
88
- break;
89
- const index = Array.from(parent.children).indexOf(current) + 1;
90
- parts.unshift(`${current.tagName.toLowerCase()}:nth-child(${index})`);
91
- current = parent;
92
- }
93
- return parts.join(" > ");
94
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * This module is intended to be imported in a browser bundle in a development.
3
- * It is responsible for live reloading the page when bundle changes.
4
- * When NODE_ENV=production, it does nothing.
5
- */
6
- export {};
@@ -1,79 +0,0 @@
1
- /**
2
- * This module is intended to be imported in a browser bundle in a development.
3
- * It is responsible for live reloading the page when bundle changes.
4
- * When NODE_ENV=production, it does nothing.
5
- */
6
- import * as Overlay from "./Overlay.js";
7
- import * as ScrollState from "./ScrollState.js";
8
- const BUNDLE_URL = globalThis._BUNDLE_URL ?? "/_bundle";
9
- function reload() {
10
- ScrollState.persist();
11
- window.location.reload();
12
- }
13
- async function loadAllEntrypoints() {
14
- const manifest = await fetch(`/${BUNDLE_URL}/manifest.json`).then((v) => v.json());
15
- manifest.artifacts
16
- .filter((v) => v.path.endsWith(".js"))
17
- .forEach((artifact) => {
18
- console.log(artifact.path);
19
- const script = document.createElement("script");
20
- script.src = `${BUNDLE_URL}/${artifact.path}`;
21
- script.type = "module";
22
- script.onload = () => {
23
- console.debug("Bundle reloaded");
24
- };
25
- document.body.appendChild(script);
26
- });
27
- }
28
- function handleBundleEvent(event) {
29
- switch (event._tag) {
30
- case "Change":
31
- console.debug("Bundle change detected...");
32
- reload();
33
- break;
34
- case "BuildError":
35
- Overlay.showBuildError(event.error);
36
- break;
37
- }
38
- }
39
- function listen() {
40
- const eventSource = new EventSource(`${BUNDLE_URL}/events`);
41
- eventSource.addEventListener("message", (event) => {
42
- try {
43
- reloadAllMetaLinks();
44
- const data = JSON.parse(event.data);
45
- handleBundleEvent(data);
46
- }
47
- catch (error) {
48
- console.error("Error parsing SSE event", {
49
- error,
50
- event,
51
- });
52
- }
53
- });
54
- eventSource.addEventListener("error", (error) => {
55
- console.error("SSE connection error:", error);
56
- });
57
- return () => {
58
- eventSource.close();
59
- };
60
- }
61
- function reloadAllMetaLinks() {
62
- for (const link of document.getElementsByTagName("link")) {
63
- const url = new URL(link.href);
64
- if (url.host === window.location.host) {
65
- const next = link.cloneNode();
66
- // TODO: this won't work when link already has query params
67
- next.href = next.href + "?" + Math.random().toString(36).slice(2);
68
- next.onload = () => link.remove();
69
- link.parentNode.insertBefore(next, link.nextSibling);
70
- return;
71
- }
72
- }
73
- }
74
- if (process.env.NODE_ENV !== "production") {
75
- window.addEventListener("load", () => {
76
- ScrollState.restore();
77
- listen();
78
- });
79
- }
@@ -1,6 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import * as Route from "../Route.ts";
3
- import * as ConsoleStore from "./ConsoleStore.ts";
4
- export { ConsoleStore } from "./ConsoleStore.ts";
5
- export declare function layer(options?: ConsoleStore.ConsoleStoreOptions): Layer.Layer<ConsoleStore.ConsoleStore>;
6
- export declare function routeLayer(prefix: string): Layer.Layer<Route.Routes, never, Route.Routes | ConsoleStore.ConsoleStore>;
@@ -1,26 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Layer from "effect/Layer";
3
- import * as Route from "../Route.js";
4
- import * as RouteTree from "../RouteTree.js";
5
- import * as ConsoleErrors from "./ConsoleErrors.js";
6
- import * as ConsoleLogger from "./ConsoleLogger.js";
7
- import * as ConsoleMetrics from "./ConsoleMetrics.js";
8
- import * as ConsoleProcess from "./ConsoleProcess.js";
9
- import * as ConsoleStore from "./ConsoleStore.js";
10
- import * as ConsoleTracer from "./ConsoleTracer.js";
11
- import consoleRoutes from "./routes/tree.js";
12
- export { ConsoleStore } from "./ConsoleStore.js";
13
- export function layer(options) {
14
- const store = ConsoleStore.layer(options);
15
- return Layer.mergeAll(ConsoleTracer.layer, ConsoleLogger.layer, ConsoleMetrics.layer, ConsoleErrors.layer, ConsoleProcess.layer).pipe(Layer.provideMerge(store));
16
- }
17
- export function routeLayer(prefix) {
18
- return Layer.effect(Route.Routes, Effect.gen(function* () {
19
- const existing = yield* Route.Routes;
20
- ConsoleStore.store.prefix = prefix;
21
- const tree = Route.tree({
22
- [prefix]: consoleRoutes,
23
- });
24
- return RouteTree.merge(existing, tree);
25
- }));
26
- }
@@ -1,3 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import * as ConsoleStore from "./ConsoleStore.ts";
3
- export declare const layer: Layer.Layer<never, never, ConsoleStore.ConsoleStore>;
@@ -1,200 +0,0 @@
1
- import * as Cause from "effect/Cause";
2
- import * as Chunk from "effect/Chunk";
3
- import * as Effect from "effect/Effect";
4
- import * as Exit from "effect/Exit";
5
- import * as FiberId from "effect/FiberId";
6
- import * as FiberRef from "effect/FiberRef";
7
- import * as HashMap from "effect/HashMap";
8
- import * as Layer from "effect/Layer";
9
- import * as Option from "effect/Option";
10
- import * as PubSub from "effect/PubSub";
11
- import * as Supervisor from "effect/Supervisor";
12
- import * as ConsoleStore from "./ConsoleStore.js";
13
- let errorId = 0;
14
- function safeSerialize(value, depth = 0) {
15
- if (depth > 4)
16
- return "<deep>";
17
- if (value === null || value === undefined)
18
- return value;
19
- if (typeof value === "bigint")
20
- return `${value}n`;
21
- if (typeof value === "function")
22
- return undefined;
23
- if (typeof value === "symbol")
24
- return value.toString();
25
- if (typeof value !== "object")
26
- return value;
27
- if (value instanceof Date)
28
- return value.toISOString();
29
- if (value instanceof Error)
30
- return value.message;
31
- if (Array.isArray(value))
32
- return value.slice(0, 20).map((v) => safeSerialize(v, depth + 1));
33
- const proto = Object.getPrototypeOf(value);
34
- if (proto !== null && proto !== Object.prototype) {
35
- if (typeof value._tag === "string") {
36
- return serializeTaggedObject(value, depth);
37
- }
38
- return `<${proto.constructor?.name ?? "object"}>`;
39
- }
40
- return serializePlainObject(value, depth);
41
- }
42
- function serializePlainObject(obj, depth) {
43
- const out = {};
44
- let count = 0;
45
- for (const [k, v] of Object.entries(obj)) {
46
- if (count >= 20)
47
- break;
48
- if (typeof v === "function")
49
- continue;
50
- const serialized = safeSerialize(v, depth + 1);
51
- if (serialized !== undefined) {
52
- out[k] = serialized;
53
- count++;
54
- }
55
- }
56
- return out;
57
- }
58
- function serializeTaggedObject(obj, depth) {
59
- const out = { _tag: obj._tag };
60
- let count = 0;
61
- for (const [k, v] of Object.entries(obj)) {
62
- if (count >= 20)
63
- break;
64
- if (k === "_tag")
65
- continue;
66
- if (typeof v === "function")
67
- continue;
68
- if (k === "stack" || k === "name")
69
- continue;
70
- const serialized = safeSerialize(v, depth + 1);
71
- if (serialized !== undefined) {
72
- out[k] = serialized;
73
- count++;
74
- }
75
- }
76
- return out;
77
- }
78
- function extractTag(error) {
79
- if (error !== null &&
80
- typeof error === "object" &&
81
- "_tag" in error &&
82
- typeof error._tag === "string") {
83
- return error._tag;
84
- }
85
- return undefined;
86
- }
87
- function extractMessage(error) {
88
- if (error instanceof Error)
89
- return error.message;
90
- if (typeof error === "string")
91
- return error;
92
- const tag = extractTag(error);
93
- if (tag)
94
- return tag;
95
- try {
96
- return String(error);
97
- }
98
- catch {
99
- return "<unknown>";
100
- }
101
- }
102
- function extractProperties(error) {
103
- if (error === null || error === undefined || typeof error !== "object")
104
- return {};
105
- const out = {};
106
- let count = 0;
107
- for (const [k, v] of Object.entries(error)) {
108
- if (count >= 20)
109
- break;
110
- if (k === "_tag" || k === "stack" || k === "name")
111
- continue;
112
- if (typeof v === "function")
113
- continue;
114
- const serialized = safeSerialize(v, 0);
115
- if (serialized !== undefined) {
116
- out[k] = serialized;
117
- count++;
118
- }
119
- }
120
- return out;
121
- }
122
- const spanSymbol = Symbol.for("effect/SpanAnnotation");
123
- function extractSpanName(error) {
124
- if (error !== null && typeof error === "object" && spanSymbol in error) {
125
- const span = error[spanSymbol];
126
- return typeof span?.name === "string" ? span.name : undefined;
127
- }
128
- return undefined;
129
- }
130
- function extractDetails(cause) {
131
- const details = [];
132
- const failures = Chunk.toArray(Cause.failures(cause));
133
- for (const error of failures) {
134
- details.push({
135
- kind: "fail",
136
- tag: extractTag(error),
137
- message: extractMessage(error),
138
- properties: extractProperties(error),
139
- span: extractSpanName(error),
140
- });
141
- }
142
- const defects = Chunk.toArray(Cause.defects(cause));
143
- for (const defect of defects) {
144
- details.push({
145
- kind: "die",
146
- tag: extractTag(defect),
147
- message: extractMessage(defect),
148
- properties: extractProperties(defect),
149
- span: extractSpanName(defect),
150
- });
151
- }
152
- return details;
153
- }
154
- function make(store) {
155
- return new (class extends Supervisor.AbstractSupervisor {
156
- value = Effect.void;
157
- onStart(_context, _effect, parent, fiber) {
158
- const childId = FiberId.threadName(fiber.id());
159
- if (Option.isSome(parent)) {
160
- const parentId = FiberId.threadName(parent.value.id());
161
- if (childId !== parentId) {
162
- store.fiberParents.set(childId, parentId);
163
- }
164
- }
165
- const span = fiber.currentSpan;
166
- const annotations = {};
167
- const spanAnnotations = fiber.getFiberRef(FiberRef.currentTracerSpanAnnotations);
168
- HashMap.forEach(spanAnnotations, (value, key) => {
169
- annotations[key] = value;
170
- });
171
- const logAnnotations = fiber.getFiberRef(FiberRef.currentLogAnnotations);
172
- HashMap.forEach(logAnnotations, (value, key) => {
173
- annotations[key] = value;
174
- });
175
- store.fiberContexts.set(childId, {
176
- spanName: span?._tag === "Span" ? span.name : undefined,
177
- traceId: span ? span.traceId : undefined,
178
- annotations,
179
- });
180
- }
181
- onEnd(exit, fiber) {
182
- if (Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause)) {
183
- const error = {
184
- id: String(++errorId),
185
- date: new Date(),
186
- fiberId: FiberId.threadName(fiber.id()),
187
- interrupted: Cause.isInterrupted(exit.cause),
188
- prettyPrint: Cause.pretty(exit.cause, { renderErrorCause: true }),
189
- details: extractDetails(exit.cause),
190
- };
191
- store.errors.push(error);
192
- Effect.runSync(PubSub.publish(store.events, { _tag: "Error", error }));
193
- }
194
- }
195
- })();
196
- }
197
- export const layer = Layer.unwrapEffect(Effect.gen(function* () {
198
- const store = yield* ConsoleStore.ConsoleStore;
199
- return Supervisor.addSupervisor(make(store));
200
- }));
@@ -1,3 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import * as ConsoleStore from "./ConsoleStore.ts";
3
- export declare const layer: Layer.Layer<never, never, ConsoleStore.ConsoleStore>;
@@ -1,47 +0,0 @@
1
- import * as Cause from "effect/Cause";
2
- import * as Effect from "effect/Effect";
3
- import * as FiberId from "effect/FiberId";
4
- import * as FiberRef from "effect/FiberRef";
5
- import * as HashMap from "effect/HashMap";
6
- import * as HashSet from "effect/HashSet";
7
- import * as Layer from "effect/Layer";
8
- import * as List from "effect/List";
9
- import * as Logger from "effect/Logger";
10
- import * as PubSub from "effect/PubSub";
11
- import * as ConsoleStore from "./ConsoleStore.js";
12
- let logId = 0;
13
- export const layer = Layer.effectDiscard(Effect.gen(function* () {
14
- const store = yield* ConsoleStore.ConsoleStore;
15
- const logger = Logger.make(({ message, logLevel, cause, fiberId, spans, annotations, date }) => {
16
- const levelMap = {
17
- Debug: "DEBUG",
18
- Info: "INFO",
19
- Warning: "WARNING",
20
- Error: "ERROR",
21
- Fatal: "FATAL",
22
- };
23
- const level = levelMap[logLevel._tag] ?? "INFO";
24
- const causeStr = !Cause.isEmpty(cause)
25
- ? Cause.pretty(cause, { renderErrorCause: true })
26
- : undefined;
27
- const spanNames = [];
28
- List.forEach(spans, (s) => spanNames.push(s.label));
29
- const ann = {};
30
- HashMap.forEach(annotations, (v, k) => {
31
- ann[k] = v;
32
- });
33
- const log = {
34
- id: String(++logId),
35
- date,
36
- level,
37
- message: String(message),
38
- fiberId: FiberId.threadName(fiberId),
39
- cause: causeStr,
40
- spans: spanNames,
41
- annotations: ann,
42
- };
43
- store.logs.push(log);
44
- Effect.runSync(PubSub.publish(store.events, { _tag: "Log", log }));
45
- });
46
- yield* FiberRef.update(FiberRef.currentLoggers, (loggers) => HashSet.add(loggers, logger));
47
- }));
@@ -1,3 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import * as ConsoleStore from "./ConsoleStore.ts";
3
- export declare const layer: Layer.Layer<never, never, ConsoleStore.ConsoleStore>;
@@ -1,61 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Layer from "effect/Layer";
3
- import * as Metric from "effect/Metric";
4
- import * as MetricKeyType from "effect/MetricKeyType";
5
- import * as PubSub from "effect/PubSub";
6
- import * as Schedule from "effect/Schedule";
7
- import * as ConsoleStore from "./ConsoleStore.js";
8
- export const layer = Layer.scopedDiscard(Effect.gen(function* () {
9
- const store = yield* ConsoleStore.ConsoleStore;
10
- yield* Effect.forkScoped(Effect.schedule(Effect.sync(() => {
11
- const pairs = Metric.unsafeSnapshot();
12
- const snapshots = [];
13
- for (const pair of pairs) {
14
- const key = pair.metricKey;
15
- const state = pair.metricState;
16
- let type = "counter";
17
- let value = 0;
18
- if (MetricKeyType.CounterKeyTypeTypeId in key.keyType) {
19
- type = "counter";
20
- value = state.count;
21
- }
22
- else if (MetricKeyType.GaugeKeyTypeTypeId in key.keyType) {
23
- type = "gauge";
24
- value = state.value;
25
- }
26
- else if (MetricKeyType.HistogramKeyTypeTypeId in key.keyType) {
27
- type = "histogram";
28
- value = {
29
- buckets: state.buckets,
30
- count: state.count,
31
- sum: state.sum,
32
- min: state.min,
33
- max: state.max,
34
- };
35
- }
36
- else if (MetricKeyType.FrequencyKeyTypeTypeId in key.keyType) {
37
- type = "frequency";
38
- value = Object.fromEntries(state.occurrences);
39
- }
40
- else if (MetricKeyType.SummaryKeyTypeTypeId in key.keyType) {
41
- type = "summary";
42
- value = {
43
- quantiles: state.quantiles,
44
- count: state.count,
45
- sum: state.sum,
46
- min: state.min,
47
- max: state.max,
48
- };
49
- }
50
- snapshots.push({
51
- name: key.name,
52
- type,
53
- value,
54
- tags: key.tags.map((t) => ({ key: t.key, value: t.value })),
55
- timestamp: Date.now(),
56
- });
57
- }
58
- store.metrics = snapshots;
59
- Effect.runSync(PubSub.publish(store.events, { _tag: "MetricsSnapshot", metrics: snapshots }));
60
- }), Schedule.spaced("2 seconds")));
61
- }));
@@ -1,3 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import * as ConsoleStore from "./ConsoleStore.ts";
3
- export declare const layer: Layer.Layer<never, never, ConsoleStore.ConsoleStore>;