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,67 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Stream from "effect/Stream";
3
- import * as System from "../../System.js";
4
- import * as BunChildProcessSpawner from "../../bun/BunChildProcessSpawner.js";
5
- const PORT = 1433;
6
- const PASSWORD = "TestPass123";
7
- const CONTAINER = "effect-start-mssql";
8
- const exec = (...args) => Effect.scoped(Effect.gen(function* () {
9
- const handle = yield* System.spawn("docker", args, {
10
- stdout: "ignore",
11
- stderr: "inherit",
12
- });
13
- return yield* handle.exitCode;
14
- }));
15
- const execStdout = (...args) => Effect.scoped(Effect.gen(function* () {
16
- const handle = yield* System.spawn("docker", args, {
17
- stdout: "pipe",
18
- stderr: "inherit",
19
- });
20
- const [stdout] = yield* Effect.all([handle.stdout.pipe(Stream.decodeText("utf-8"), Stream.mkString), handle.exitCode], { concurrency: 2 });
21
- return stdout;
22
- }));
23
- const containerRunning = execStdout("ps", "-q", "-f", `name=${CONTAINER}`).pipe(Effect.map((stdout) => stdout.trim().length > 0));
24
- const removeContainer = exec("rm", "-f", CONTAINER).pipe(Effect.ignore);
25
- const loadMssql = () => import("mssql");
26
- const canConnect = Effect.tryPromise({
27
- try: async () => {
28
- const { ConnectionPool } = await loadMssql();
29
- const pool = new ConnectionPool({
30
- server: "localhost",
31
- user: "sa",
32
- password: PASSWORD,
33
- port: PORT,
34
- options: { encrypt: true, trustServerCertificate: true, connectTimeout: 3000 },
35
- });
36
- await pool.connect();
37
- await pool.close();
38
- return true;
39
- },
40
- catch: () => false,
41
- }).pipe(Effect.orElseSucceed(() => false));
42
- const waitReady = Effect.gen(function* () {
43
- const deadline = Date.now() + 60_000;
44
- while (Date.now() < deadline) {
45
- if (yield* canConnect)
46
- return;
47
- yield* Effect.sleep("2 seconds");
48
- }
49
- return yield* Effect.fail(new Error("Timed out waiting for MSSQL"));
50
- });
51
- const program = Effect.gen(function* () {
52
- if (yield* containerRunning) {
53
- yield* Effect.log("MSSQL container already running");
54
- return;
55
- }
56
- yield* removeContainer;
57
- yield* Effect.log("Starting MSSQL container...");
58
- const code = yield* exec("run", "-d", "--name", CONTAINER, "-p", `${PORT}:1433`, "-e", "ACCEPT_EULA=Y", "-e", `MSSQL_SA_PASSWORD=${PASSWORD}`, "mcr.microsoft.com/azure-sql-edge");
59
- if (code !== 0) {
60
- return yield* Effect.fail(new Error(`docker run exited with code ${code}`));
61
- }
62
- yield* waitReady;
63
- yield* Effect.log("MSSQL ready");
64
- });
65
- const run = (effect) => Effect.runPromise(Effect.provide(effect, BunChildProcessSpawner.layer));
66
- export const start = () => run(program);
67
- export const stop = () => run(removeContainer);
@@ -1,21 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import * as Sql from "../../Sql.ts";
3
- export interface MssqlConfig {
4
- readonly server: string;
5
- readonly database?: string;
6
- readonly user?: string;
7
- readonly password?: string;
8
- readonly port?: number;
9
- readonly pool?: {
10
- readonly max?: number;
11
- readonly min?: number;
12
- readonly idleTimeoutMillis?: number;
13
- };
14
- readonly options?: {
15
- readonly encrypt?: boolean;
16
- readonly trustServerCertificate?: boolean;
17
- readonly requestTimeout?: number;
18
- readonly connectionTimeout?: number;
19
- };
20
- }
21
- export declare const layer: (config: MssqlConfig) => Layer.Layer<Sql.SqlClient, Sql.SqlError>;
@@ -1,113 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Exit from "effect/Exit";
3
- import * as FiberRef from "effect/FiberRef";
4
- import * as GlobalValue from "effect/GlobalValue";
5
- import * as Layer from "effect/Layer";
6
- import * as Option from "effect/Option";
7
- import * as Sql from "../../Sql.js";
8
- const wrapError = (error) => new Sql.SqlError({
9
- code: error?.code ??
10
- (error?.number != null ? String(error.number) : "UNKNOWN"),
11
- message: error instanceof Error ? error.message : String(error),
12
- cause: error,
13
- });
14
- const makeValues = (obj, ...columns) => {
15
- const items = Array.isArray(obj) ? obj : [obj];
16
- const cols = columns.length > 0 ? columns : Object.keys(items[0]);
17
- return { value: items, columns: cols };
18
- };
19
- const buildQuery = (strings, values) => {
20
- let text = strings[0];
21
- for (let i = 0; i < values.length; i++)
22
- text += `@p${i + 1}` + strings[i + 1];
23
- return { text, values };
24
- };
25
- const addInputs = (request, values) => {
26
- for (let i = 0; i < values.length; i++) {
27
- request.input(`p${i + 1}`, values[i]);
28
- }
29
- };
30
- const loadMssql = () => import("mssql");
31
- const currentTransaction = GlobalValue.globalValue(Symbol.for("effect-start/sql/mssql/currentTransaction"), () => FiberRef.unsafeMake(Option.none()));
32
- const executeQuery = (pool, text, values) => Effect.flatMap(FiberRef.get(currentTransaction), (txOpt) => {
33
- const request = Option.isSome(txOpt) ? txOpt.value.transaction.request() : pool.request();
34
- addInputs(request, values);
35
- return Effect.tryPromise({
36
- try: () => request.query(text),
37
- catch: wrapError,
38
- }).pipe(Effect.map((result) => result.recordset ?? []));
39
- });
40
- const runQuery = (pool, strings, values) => {
41
- const { text, values: params } = buildQuery(strings, values);
42
- return executeQuery(pool, text, params);
43
- };
44
- const runUnsafe = (pool, query, values) => Effect.flatMap(FiberRef.get(currentTransaction), (txOpt) => {
45
- const request = Option.isSome(txOpt) ? txOpt.value.transaction.request() : pool.request();
46
- if (values)
47
- addInputs(request, values);
48
- return Effect.tryPromise({
49
- try: () => request.query(query),
50
- catch: wrapError,
51
- }).pipe(Effect.map((result) => result.recordset ?? []));
52
- });
53
- const makeWithTransaction = (pool) => (self) => Effect.uninterruptibleMask((restore) => Effect.flatMap(FiberRef.get(currentTransaction), (txOpt) => {
54
- if (Option.isSome(txOpt)) {
55
- const { transaction, depth } = txOpt.value;
56
- const name = `sp_${depth}`;
57
- return Effect.gen(function* () {
58
- const req = transaction.request();
59
- yield* Effect.tryPromise({
60
- try: () => req.query(`SAVE TRANSACTION ${name}`),
61
- catch: wrapError,
62
- });
63
- const exit = yield* Effect.exit(restore(Effect.locally(self, currentTransaction, Option.some({ transaction, depth: depth + 1 }))));
64
- if (Exit.isSuccess(exit)) {
65
- return exit.value;
66
- }
67
- const rbReq = transaction.request();
68
- yield* Effect.tryPromise({
69
- try: () => rbReq.query(`ROLLBACK TRANSACTION ${name}`),
70
- catch: wrapError,
71
- }).pipe(Effect.orDie);
72
- return yield* exit;
73
- });
74
- }
75
- return Effect.gen(function* () {
76
- const transaction = pool.transaction();
77
- yield* Effect.tryPromise({ try: () => transaction.begin(), catch: wrapError });
78
- const exit = yield* Effect.exit(restore(Effect.locally(self, currentTransaction, Option.some({ transaction, depth: 1 }))));
79
- if (Exit.isSuccess(exit)) {
80
- yield* Effect.tryPromise({ try: () => transaction.commit(), catch: wrapError });
81
- return exit.value;
82
- }
83
- yield* Effect.tryPromise({ try: () => transaction.rollback(), catch: wrapError }).pipe(Effect.orDie);
84
- return yield* exit;
85
- });
86
- }));
87
- export const layer = (config) => Layer.scoped(Sql.SqlClient, Effect.acquireRelease(Effect.tryPromise({
88
- try: async () => {
89
- const mssql = await loadMssql();
90
- const pool = await new mssql.ConnectionPool(config).connect();
91
- return { mssql, pool };
92
- },
93
- catch: wrapError,
94
- }).pipe(Effect.map(({ mssql, pool }) => {
95
- const use = (fn) => Effect.tryPromise({ try: () => Promise.resolve(fn(pool)), catch: wrapError });
96
- return Object.assign((strings, ...values) => runQuery(pool, strings, values), {
97
- unsafe: (query, values) => runUnsafe(pool, query, values),
98
- values: makeValues,
99
- withTransaction: makeWithTransaction(pool),
100
- reserve: Effect.acquireRelease(Effect.tryPromise({
101
- try: () => new mssql.ConnectionPool({
102
- ...config,
103
- pool: { max: 1, min: 1 },
104
- }).connect(),
105
- catch: wrapError,
106
- }), (reserved) => Effect.tryPromise({ try: () => reserved.close(), catch: () => void 0 }).pipe(Effect.asVoid, Effect.orDie)).pipe(Effect.map((reserved) => Object.assign((strings, ...values) => runQuery(reserved, strings, values), {
107
- unsafe: (query, values) => runUnsafe(reserved, query, values),
108
- values: makeValues,
109
- }))),
110
- close: () => use((pool) => pool.close()),
111
- use,
112
- });
113
- })), (client) => client.close().pipe(Effect.orDie)));
@@ -1,13 +0,0 @@
1
- import * as HttpApp from "@effect/platform/HttpApp";
2
- import * as HttpClient from "@effect/platform/HttpClient";
3
- import * as HttpClientError from "@effect/platform/HttpClientError";
4
- import * as HttpClientResponse from "@effect/platform/HttpClientResponse";
5
- import { RouteNotFound } from "@effect/platform/HttpServerError";
6
- import * as HttpServerRequest from "@effect/platform/HttpServerRequest";
7
- import * as Effect from "effect/Effect";
8
- export type FetchHandler = (req: Request) => Response | Promise<Response>;
9
- export declare const isFetchHandler: (app: unknown) => app is FetchHandler;
10
- export declare const make: <E, R>(appOrHandler: HttpApp.Default<E, R> | FetchHandler, opts?: {
11
- baseUrl?: string | null;
12
- handleRouteNotFound?: (e: RouteNotFound) => Effect.Effect<HttpClientResponse.HttpClientResponse> | null;
13
- }) => HttpClient.HttpClient.With<HttpClientError.HttpClientError | E, Exclude<R, HttpServerRequest.HttpServerRequest>>;
@@ -1,68 +0,0 @@
1
- import * as HttpClient from "@effect/platform/HttpClient";
2
- import * as HttpClientRequest from "@effect/platform/HttpClientRequest";
3
- import * as HttpClientResponse from "@effect/platform/HttpClientResponse";
4
- import { RouteNotFound } from "@effect/platform/HttpServerError";
5
- import * as HttpServerRequest from "@effect/platform/HttpServerRequest";
6
- import * as HttpServerResponse from "@effect/platform/HttpServerResponse";
7
- import * as UrlParams from "@effect/platform/UrlParams";
8
- import * as Effect from "effect/Effect";
9
- import * as Either from "effect/Either";
10
- import * as Function from "effect/Function";
11
- import * as Stream from "effect/Stream";
12
- const WebHeaders = globalThis.Headers;
13
- export const isFetchHandler = (app) => typeof app === "function" && !Effect.isEffect(app);
14
- const fromFetchHandler = (handler) => Effect.gen(function* () {
15
- const serverRequest = yield* HttpServerRequest.HttpServerRequest;
16
- const webRequest = serverRequest.source;
17
- const response = yield* Effect.promise(async () => handler(webRequest));
18
- const body = yield* Effect.promise(() => response.arrayBuffer());
19
- return HttpServerResponse.raw(new Uint8Array(body), {
20
- status: response.status,
21
- statusText: response.statusText,
22
- headers: Object.fromEntries(response.headers.entries()),
23
- });
24
- });
25
- export const make = (appOrHandler, opts) => {
26
- const httpApp = isFetchHandler(appOrHandler)
27
- ? fromFetchHandler(appOrHandler)
28
- : appOrHandler;
29
- const execute = (request) => {
30
- const urlResult = UrlParams.makeUrl(request.url, request.urlParams, request.hash);
31
- if (Either.isLeft(urlResult)) {
32
- return Effect.die(urlResult.left);
33
- }
34
- const url = urlResult.right;
35
- const controller = new AbortController();
36
- const signal = controller.signal;
37
- const send = (body) => {
38
- const serverRequest = HttpServerRequest.fromWeb(new Request(url.toString(), {
39
- method: request.method,
40
- headers: new WebHeaders(request.headers),
41
- body,
42
- duplex: request.body._tag === "Stream" ? "half" : undefined,
43
- signal,
44
- }));
45
- return Function.pipe(httpApp, Effect.provideService(HttpServerRequest.HttpServerRequest, serverRequest), Effect.andThen(HttpServerResponse.toWeb), Effect.andThen(res => HttpClientResponse.fromWeb(request, res)), opts?.handleRouteNotFound === null
46
- ? Function.identity
47
- : Effect.catchAll((e) => e instanceof RouteNotFound
48
- ? Effect.succeed(HttpClientResponse.fromWeb(request, new Response("Failed with RouteNotFound", {
49
- status: 404,
50
- })))
51
- : Effect.fail(e)));
52
- };
53
- switch (request.body._tag) {
54
- case "Raw":
55
- case "Uint8Array":
56
- return send(request.body.body);
57
- case "FormData":
58
- return send(request.body.formData);
59
- case "Stream":
60
- return Effect.flatMap(Stream.toReadableStreamEffect(request.body.stream), send);
61
- }
62
- return send(undefined);
63
- };
64
- const client = HttpClient.makeWith((requestEffect) => Effect.flatMap(requestEffect, execute), (request) => Effect.succeed(request));
65
- return client.pipe(opts?.baseUrl === null
66
- ? Function.identity
67
- : HttpClient.mapRequest(HttpClientRequest.prependUrl(opts?.baseUrl ?? "http://localhost")));
68
- };
@@ -1,13 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
4
- import * as Ref from "effect/Ref";
5
- export type TestLoggerContext = {
6
- messages: Ref.Ref<Array<string>>;
7
- };
8
- declare const TestLogger_base: Context.TagClass<TestLogger, "effect-start/TestLogger", TestLoggerContext>;
9
- export declare class TestLogger extends TestLogger_base {
10
- }
11
- export declare function layer(): Layer.Layer<TestLogger>;
12
- export declare const messages: Effect.Effect<Array<string>, never, TestLogger>;
13
- export {};
@@ -1,32 +0,0 @@
1
- import * as Cause from "effect/Cause";
2
- import * as Context from "effect/Context";
3
- import * as Effect from "effect/Effect";
4
- import * as FiberRef from "effect/FiberRef";
5
- import * as HashSet from "effect/HashSet";
6
- import * as Layer from "effect/Layer";
7
- import * as Logger from "effect/Logger";
8
- import * as MutableRef from "effect/MutableRef";
9
- import * as Ref from "effect/Ref";
10
- export class TestLogger extends Context.Tag("effect-start/TestLogger")() {
11
- }
12
- export function layer() {
13
- return Layer.effect(TestLogger, Effect.gen(function* () {
14
- const messages = yield* Ref.make([]);
15
- const mutableRef = messages.ref;
16
- const customLogger = Logger.make(({ message, logLevel, cause }) => {
17
- const causeStr = !Cause.isEmpty(cause)
18
- ? ` ${Cause.pretty(cause, { renderErrorCause: true })}`
19
- : "";
20
- MutableRef.update(mutableRef, (msgs) => [
21
- ...msgs,
22
- `[${logLevel._tag}] ${String(message)}${causeStr}`,
23
- ]);
24
- });
25
- yield* FiberRef.update(FiberRef.currentLoggers, (loggers) => HashSet.add(HashSet.remove(loggers, Logger.defaultLogger), customLogger));
26
- return { messages };
27
- }));
28
- }
29
- export const messages = Effect.gen(function* () {
30
- const logger = yield* TestLogger;
31
- return yield* Ref.get(logger.messages);
32
- });
@@ -1,2 +0,0 @@
1
- export * as TestLogger from "./TestLogger.ts";
2
- export * from "./utils.ts";
@@ -1,2 +0,0 @@
1
- export * as TestLogger from "./TestLogger.js";
2
- export * from "./utils.js";
@@ -1,9 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Layer from "effect/Layer";
3
- import type * as Scope from "effect/Scope";
4
- import type * as Utils from "effect/Utils";
5
- /**
6
- * Creates a scoped Effects and runs is asynchronously.
7
- * Useful for testing.
8
- */
9
- export declare const effectFn: <RL>(layer?: Layer.Layer<RL, any>) => <Eff extends Utils.YieldWrap<Effect.Effect<any, any, RE>>, AEff, RE extends RL | Scope.Scope>(f: () => Generator<Eff, AEff, never>) => Promise<void>;
@@ -1,39 +0,0 @@
1
- import * as Array from "effect/Array";
2
- import * as Effect from "effect/Effect";
3
- import * as Function from "effect/Function";
4
- import * as Layer from "effect/Layer";
5
- import * as Logger from "effect/Logger";
6
- /**
7
- * Creates a scoped Effects and runs is asynchronously.
8
- * Useful for testing.
9
- */
10
- export const effectFn = (layer) => (f) => Function.pipe(Effect.gen(f), Effect.scoped, Effect.provide(Logger.pretty), Effect.provide(layer ?? Layer.empty),
11
- // @ts-expect-error will have to figure out how to clear deps
12
- Effect.runPromise, (v) => v.then(() => { }, clearStackTraces));
13
- /*
14
- * When effect fails, instead of throwing FiberFailure,
15
- * throw a plain Error with the strack trace and hides
16
- * effect internals.
17
- * Otherwise, at least on Bun, the strack trace is repeated,
18
- * with some junks in between taking half of the screen.
19
- *
20
- * Direct children that starts with a dot are excluded because
21
- * some tools, like effect-start, use it to generate temporary
22
- * files that are then loaded into a runtime.
23
- */
24
- const clearStackTraces = (err) => {
25
- const ExternalStackTraceLineRegexp = /\(.*\/node_modules\/[^.]/;
26
- const message = err instanceof Error
27
- ? err.message
28
- : typeof err === "object" && err !== null && "message" in err
29
- ? String(err.message)
30
- : String(err);
31
- const stack = err instanceof Error
32
- ? (err.stack ?? "")
33
- : typeof err === "object" && err !== null && "stack" in err
34
- ? String(err.stack)
35
- : "";
36
- const newErr = new Error(message);
37
- newErr.stack = Function.pipe(stack.split("\n"), Array.takeWhile((s) => !ExternalStackTraceLineRegexp.test(s)), Array.join("\n"));
38
- throw newErr;
39
- };
@@ -1,10 +0,0 @@
1
- import { Effect, Layer, LogLevel } from "effect";
2
- export declare const start: (opts: {
3
- command?: string;
4
- tunnelName: string;
5
- tunnelUrl?: string;
6
- cleanLogs?: false;
7
- logLevel?: LogLevel.LogLevel;
8
- logPrefix?: string;
9
- }) => Effect.Effect<void, import("../../PlatformError.ts").PlatformError, import("../../ChildProcess.ts").ChildProcessSpawner | import("effect/Scope").Scope>;
10
- export declare const layer: () => Layer.Layer<never, import("effect/ConfigError").ConfigError, import("../../ChildProcess.ts").ChildProcessSpawner>;
@@ -1,30 +0,0 @@
1
- import * as System from "../../System.js";
2
- import { Config, Effect, Layer, LogLevel, Option, pipe, Stream, String } from "effect";
3
- export const start = (opts) => Effect.gen(function* () {
4
- const command = opts.command ?? "cloudflared";
5
- yield* System.which(command);
6
- const logPrefix = String.isString(opts.logPrefix) ? opts.logPrefix : "CloudflareTunnel: ";
7
- const args = [
8
- "tunnel",
9
- "run",
10
- opts.tunnelUrl ? ["--url", opts.tunnelUrl] : [],
11
- opts.tunnelName,
12
- ].flatMap((v) => v);
13
- const proc = yield* System.spawn(command, args);
14
- yield* Effect.logInfo(`Cloudflare tunnel started name=${opts.tunnelName} pid=${proc.pid} tunnelUrl=${opts.tunnelUrl ?? "<empty>"}`);
15
- yield* pipe(Stream.merge(proc.stdout, proc.stderr), Stream.decodeText("utf-8"), Stream.splitLines, (opts.cleanLogs ?? true)
16
- ? Stream.map((v) => v.replace(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z\s\w+\s/, ""))
17
- : (s) => s, logPrefix ? Stream.map((v) => logPrefix + v) : (s) => s, Stream.runForEach((v) => Effect.logWithLevel(opts.logLevel ?? LogLevel.Debug, v)));
18
- });
19
- export const layer = () => Layer.scopedDiscard(Effect.gen(function* () {
20
- const tunnelName = yield* pipe(Config.string("CLOUDFLARE_TUNNEL_NAME"), Config.option, Effect.andThen(Option.getOrUndefined));
21
- const tunnelUrl = yield* pipe(Config.string("CLOUDFLARE_TUNNEL_URL"), Config.option, Effect.andThen(Option.getOrUndefined));
22
- if (!tunnelName) {
23
- yield* Effect.logWarning("CLOUDFLARE_TUNNEL_NAME not provided. Skipping.");
24
- return;
25
- }
26
- yield* Effect.forkScoped(start({
27
- tunnelName,
28
- tunnelUrl,
29
- }).pipe(Effect.catchAll((err) => Effect.logError("Cloudflare tunnel failed", err))));
30
- }));
@@ -1 +0,0 @@
1
- export * as CloudflareTunnel from "./CloudflareTunnel.ts";
@@ -1 +0,0 @@
1
- export * as CloudflareTunnel from "./CloudflareTunnel.js";
@@ -1,6 +0,0 @@
1
- import type * as HyperNode from "../../hyper/HyperNode.ts";
2
- export declare const HyperHooks: {
3
- readonly onNode: typeof onNode;
4
- };
5
- declare function onNode(node: HyperNode.HyperNode): void;
6
- export {};
@@ -1,47 +0,0 @@
1
- export const HyperHooks = {
2
- onNode,
3
- };
4
- function onNode(node) {
5
- const { "data-signals": dataSignals, "data-class": dataClass, "data-attr": dataAttr, "data-style": dataStyle, "data-show": dataShow, "data-ignore": dataIgnore, "data-ignore-morph": dataIgnoreMorph, } = node.props;
6
- if (typeof dataSignals === "object" && dataSignals !== null) {
7
- node.props["data-signals"] = JSON.stringify(dataSignals);
8
- }
9
- if (typeof dataClass === "function") {
10
- node.props["data-class"] = dataClass.toString();
11
- }
12
- else if (typeof dataClass === "object" && dataClass !== null) {
13
- node.props["data-class"] = JSON.stringify(dataClass);
14
- }
15
- if (typeof dataAttr === "function") {
16
- node.props["data-attr"] = dataAttr.toString();
17
- }
18
- else if (typeof dataAttr === "object" && dataAttr !== null) {
19
- node.props["data-attr"] = JSON.stringify(dataAttr);
20
- }
21
- if (typeof dataStyle === "function") {
22
- node.props["data-style"] = dataStyle.toString();
23
- }
24
- else if (typeof dataStyle === "object" && dataStyle !== null) {
25
- node.props["data-style"] = JSON.stringify(dataStyle);
26
- }
27
- if (typeof dataShow === "function") {
28
- node.props["data-show"] = dataShow.toString();
29
- }
30
- else if (typeof dataShow === "boolean") {
31
- node.props["data-show"] = dataShow.toString();
32
- }
33
- if (dataIgnore !== true && dataIgnore !== undefined) {
34
- delete node.props["data-ignore"];
35
- }
36
- if (dataIgnoreMorph !== true && dataIgnoreMorph !== undefined) {
37
- delete node.props["data-ignore-morph"];
38
- }
39
- for (const [key, value] of Object.entries(node.props)) {
40
- if (key.startsWith("data-signals-") && typeof value === "object" && value !== null) {
41
- node.props[key] = JSON.stringify(value);
42
- }
43
- if (key.startsWith("data-") && key !== "data-signals" && typeof value === "function") {
44
- node.props[key] = value.toString();
45
- }
46
- }
47
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import * as BunServer from "../../bun/BunServer.ts";
2
- import * as PlatformError from "../../PlatformError.ts";
3
- import * as Effect from "effect/Effect";
4
- import * as Layer from "effect/Layer";
5
- import * as LogLevel from "effect/LogLevel";
6
- export declare const start: (opts: {
7
- command?: string;
8
- port: number;
9
- public?: boolean;
10
- logLevel?: LogLevel.LogLevel;
11
- logPrefix?: string;
12
- }) => Effect.Effect<void, PlatformError.PlatformError, import("../../ChildProcess.ts").ChildProcessSpawner | import("effect/Scope").Scope>;
13
- export declare const layer: (opts?: {
14
- public?: boolean;
15
- }) => Layer.Layer<never, never, import("../../ChildProcess.ts").ChildProcessSpawner | BunServer.BunServer>;
@@ -1,68 +0,0 @@
1
- import * as BunServer from "../../bun/BunServer.js";
2
- import * as PlatformError from "../../PlatformError.js";
3
- import * as System from "../../System.js";
4
- import * as Deferred from "effect/Deferred";
5
- import * as Effect from "effect/Effect";
6
- import * as Fiber from "effect/Fiber";
7
- import * as Layer from "effect/Layer";
8
- import * as LogLevel from "effect/LogLevel";
9
- import * as Stream from "effect/Stream";
10
- import * as Function from "effect/Function";
11
- const getStatus = (command) => Effect.gen(function* () {
12
- const proc = yield* System.spawn(command, ["status", "--json"]);
13
- const exitCode = yield* proc.exitCode;
14
- if (exitCode !== 0) {
15
- const stderr = yield* proc.stderr.pipe(Stream.decodeText("utf-8"), Stream.mkString);
16
- return yield* new PlatformError.SystemError({
17
- reason: "Unknown",
18
- module: "TailscaleTunnel",
19
- method: "getStatus",
20
- description: `tailscale status exited with code ${exitCode}: ${stderr}`,
21
- });
22
- }
23
- const stdout = yield* proc.stdout.pipe(Stream.decodeText("utf-8"), Stream.mkString);
24
- const json = JSON.parse(stdout);
25
- if (json.BackendState !== "Running") {
26
- return yield* new PlatformError.SystemError({
27
- reason: "Unknown",
28
- module: "TailscaleTunnel",
29
- method: "getStatus",
30
- description: `tailscale is in state "${json.BackendState}", expected "Running"`,
31
- });
32
- }
33
- return json;
34
- });
35
- const serve = (opts) => Effect.gen(function* () {
36
- const logPrefix = opts.logPrefix ?? "TailscaleTunnel: ";
37
- const args = [opts.public ? "funnel" : "serve", String(opts.port)];
38
- const proc = yield* System.spawn(opts.command, args);
39
- yield* Function.pipe(Stream.merge(proc.stdout, proc.stderr), Stream.decodeText("utf-8"), Stream.splitLines, logPrefix ? Stream.map((v) => logPrefix + v) : (s) => s, Stream.runForEach((v) => Effect.logWithLevel(opts.logLevel ?? LogLevel.Debug, v)));
40
- });
41
- export const start = (opts) => Effect.gen(function* () {
42
- const command = opts.command ?? "tailscale";
43
- yield* System.which(command);
44
- const status = yield* getStatus(command);
45
- const dnsName = status.Self?.DNSName?.replace(/\.$/, "");
46
- yield* serve({ ...opts, command, dnsName });
47
- });
48
- export const layer = (opts) => Layer.scopedDiscard(Effect.gen(function* () {
49
- const { server } = yield* BunServer.BunServer;
50
- const port = server.port;
51
- const command = "tailscale";
52
- const ready = yield* Deferred.make();
53
- const fiber = yield* Effect.forkScoped(Effect.gen(function* () {
54
- yield* System.which(command);
55
- const status = yield* getStatus(command);
56
- const dnsName = status.Self?.DNSName?.replace(/\.$/, "");
57
- const serveUrl = dnsName ? `https://${dnsName}` : undefined;
58
- yield* Effect.logInfo(`Tailscale ${opts?.public ? "funnel" : "serve"}${serveUrl ? ` url=${serveUrl}` : ""}`);
59
- yield* Deferred.succeed(ready, void 0);
60
- yield* serve({
61
- command,
62
- port,
63
- dnsName,
64
- public: opts?.public,
65
- });
66
- }).pipe(Effect.orDie));
67
- yield* Fiber.join(fiber).pipe(Effect.raceFirst(Deferred.await(ready)));
68
- }));
@@ -1 +0,0 @@
1
- export * as TailscaleTunnel from "./TailscaleTunnel.ts";
@@ -1 +0,0 @@
1
- export * as TailscaleTunnel from "./TailscaleTunnel.js";
@@ -1,23 +0,0 @@
1
- import type { BunPlugin } from "bun";
2
- export declare const make: (opts?: {
3
- /**
4
- * Pattern to match component and HTML files for class name extraction.
5
- */
6
- filesPattern?: RegExp;
7
- /**
8
- * Pattern to match CSS files that import Tailwind.
9
- */
10
- cssPattern?: RegExp;
11
- /**
12
- * Scan a path for candidates.
13
- * By default, only class names found in files that are part of the import graph
14
- * that imports tailwind are considered.
15
- *
16
- * This option scans the provided path and ensures that class names found under this path
17
- * are includedd, even if they are not part of the import graph.
18
- * Useful when we want to scan clientside code which is not imported directly on serverside.
19
- */
20
- scanPath?: string;
21
- target?: "browser" | "bun" | "node";
22
- }) => BunPlugin;
23
- export declare function extractClassNames(source: string): Set<string>;