effect-start 0.22.1 → 0.23.1

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 (314) hide show
  1. package/dist/BlobStore.d.ts +80 -0
  2. package/dist/BlobStore.js +19 -0
  3. package/dist/ChildProcess.d.ts +60 -0
  4. package/dist/ChildProcess.js +30 -0
  5. package/dist/Commander.d.ts +3 -6
  6. package/dist/Commander.js +6 -13
  7. package/dist/ContentNegotiation.d.ts +8 -9
  8. package/dist/ContentNegotiation.js +32 -37
  9. package/dist/Cookies.d.ts +47 -0
  10. package/dist/Cookies.js +273 -363
  11. package/dist/Development.d.ts +2 -2
  12. package/dist/Development.js +3 -4
  13. package/dist/Effectify.d.ts +1 -4
  14. package/dist/FilePathPattern.d.ts +3 -3
  15. package/dist/FileRouter.d.ts +5 -8
  16. package/dist/FileRouter.js +9 -10
  17. package/dist/FileRouterCodegen.d.ts +1 -1
  18. package/dist/FileRouterCodegen.js +33 -13
  19. package/dist/FileSystem.d.ts +158 -0
  20. package/dist/FileSystem.js +64 -125
  21. package/dist/Http.js +2 -6
  22. package/dist/PathPattern.d.ts +7 -7
  23. package/dist/PathPattern.js +1 -3
  24. package/dist/PlatformError.d.ts +24 -32
  25. package/dist/PlatformError.js +3 -21
  26. package/dist/PlatformRuntime.js +5 -10
  27. package/dist/Route.d.ts +14 -19
  28. package/dist/Route.js +8 -11
  29. package/dist/RouteBody.d.ts +6 -12
  30. package/dist/RouteBody.js +2 -2
  31. package/dist/RouteError.d.ts +98 -0
  32. package/dist/RouteError.js +55 -0
  33. package/dist/RouteHook.js +6 -11
  34. package/dist/RouteHttp.d.ts +3 -3
  35. package/dist/RouteHttp.js +27 -22
  36. package/dist/RouteMount.d.ts +16 -50
  37. package/dist/RouteMount.js +6 -20
  38. package/dist/RouteSchema.d.ts +22 -1
  39. package/dist/RouteSchema.js +33 -0
  40. package/dist/RouteSse.js +4 -10
  41. package/dist/RouteTree.d.ts +2 -1
  42. package/dist/RouteTree.js +17 -15
  43. package/dist/RouteTrie.d.ts +2 -2
  44. package/dist/RouteTrie.js +4 -9
  45. package/dist/SchemaExtra.d.ts +1 -1
  46. package/dist/Socket.d.ts +27 -0
  47. package/dist/Socket.js +20 -28
  48. package/dist/Sql.d.ts +34 -0
  49. package/dist/Sql.js +5 -0
  50. package/dist/SqlIntrospect.d.ts +91 -0
  51. package/dist/SqlIntrospect.js +466 -0
  52. package/dist/Start.d.ts +4 -6
  53. package/dist/Start.js +10 -2
  54. package/dist/StreamExtra.d.ts +1 -1
  55. package/dist/StreamExtra.js +9 -9
  56. package/dist/System.d.ts +7 -0
  57. package/dist/System.js +22 -0
  58. package/dist/TuplePathPattern.js +55 -50
  59. package/dist/Unique.js +7 -7
  60. package/dist/Values.d.ts +2 -1
  61. package/dist/Values.js +19 -13
  62. package/dist/bun/BunBlobStoreDisk.d.ts +6 -0
  63. package/dist/bun/BunBlobStoreDisk.js +116 -0
  64. package/dist/bun/BunBlobStoreS3.d.ts +11 -0
  65. package/dist/bun/BunBlobStoreS3.js +89 -0
  66. package/dist/bun/BunBlobWatcherDisk.d.ts +6 -0
  67. package/dist/bun/BunBlobWatcherDisk.js +60 -0
  68. package/dist/bun/BunBlobWatcherQueue.d.ts +6 -0
  69. package/dist/bun/BunBlobWatcherQueue.js +17 -0
  70. package/dist/bun/BunBundle.d.ts +5 -6
  71. package/dist/bun/BunBundle.js +7 -15
  72. package/dist/bun/BunChildProcessSpawner.d.ts +3 -0
  73. package/dist/bun/BunChildProcessSpawner.js +103 -0
  74. package/dist/bun/BunImportTrackerPlugin.d.ts +1 -1
  75. package/dist/bun/BunImportTrackerPlugin.js +3 -5
  76. package/dist/bun/BunRoute.d.ts +3 -2
  77. package/dist/bun/BunRoute.js +5 -7
  78. package/dist/bun/BunRuntime.js +1 -1
  79. package/dist/bun/BunServer.d.ts +11 -4
  80. package/dist/bun/BunServer.js +35 -11
  81. package/dist/bun/BunSql.d.ts +4 -0
  82. package/dist/bun/BunSql.js +81 -0
  83. package/dist/bun/_BunEnhancedResolve.d.ts +3 -3
  84. package/dist/bun/_BunEnhancedResolve.js +2 -4
  85. package/dist/bun/index.d.ts +1 -0
  86. package/dist/bun/index.js +1 -0
  87. package/dist/bundler/Bundle.d.ts +2 -1
  88. package/dist/bundler/Bundle.js +1 -1
  89. package/dist/bundler/BundleFiles.d.ts +5 -5
  90. package/dist/bundler/BundleFiles.js +10 -8
  91. package/dist/bundler/BundleRoute.d.ts +27 -0
  92. package/dist/bundler/BundleRoute.js +51 -0
  93. package/dist/client/ScrollState.js +2 -6
  94. package/dist/client/index.js +6 -8
  95. package/dist/console/Console.d.ts +6 -0
  96. package/dist/console/Console.js +26 -0
  97. package/dist/console/ConsoleErrors.d.ts +3 -0
  98. package/dist/console/ConsoleErrors.js +200 -0
  99. package/dist/console/ConsoleLogger.d.ts +3 -0
  100. package/dist/console/ConsoleLogger.js +47 -0
  101. package/dist/console/ConsoleMetrics.d.ts +3 -0
  102. package/dist/console/ConsoleMetrics.js +61 -0
  103. package/dist/console/ConsoleProcess.d.ts +3 -0
  104. package/dist/console/ConsoleProcess.js +49 -0
  105. package/dist/console/ConsoleStore.d.ts +144 -0
  106. package/dist/console/ConsoleStore.js +61 -0
  107. package/dist/console/ConsoleTracer.d.ts +3 -0
  108. package/dist/console/ConsoleTracer.js +94 -0
  109. package/dist/console/Simulation.d.ts +2 -0
  110. package/dist/console/Simulation.js +633 -0
  111. package/dist/console/index.d.ts +3 -0
  112. package/dist/console/index.js +3 -0
  113. package/dist/console/routes/errors/route.d.ts +10 -0
  114. package/dist/console/routes/errors/route.js +47 -0
  115. package/dist/console/routes/fiberDetail.d.ts +16 -0
  116. package/dist/console/routes/fiberDetail.js +38 -0
  117. package/dist/console/routes/fibers/route.d.ts +10 -0
  118. package/dist/console/routes/fibers/route.js +19 -0
  119. package/dist/console/routes/git/route.d.ts +11 -0
  120. package/dist/console/routes/git/route.js +33 -0
  121. package/dist/console/routes/layout.d.ts +9 -0
  122. package/dist/console/routes/layout.js +3 -0
  123. package/dist/console/routes/logs/route.d.ts +10 -0
  124. package/dist/console/routes/logs/route.js +32 -0
  125. package/dist/console/routes/metrics/route.d.ts +10 -0
  126. package/dist/console/routes/metrics/route.js +17 -0
  127. package/dist/console/routes/route.d.ts +6 -0
  128. package/dist/console/routes/route.js +5 -0
  129. package/dist/console/routes/routes/route.d.ts +6 -0
  130. package/dist/console/routes/routes/route.js +20 -0
  131. package/dist/console/routes/services/route.d.ts +6 -0
  132. package/dist/console/routes/services/route.js +12 -0
  133. package/dist/console/routes/system/route.d.ts +10 -0
  134. package/dist/console/routes/system/route.js +18 -0
  135. package/dist/console/routes/traceDetail.d.ts +16 -0
  136. package/dist/console/routes/traceDetail.js +14 -0
  137. package/dist/console/routes/traces/route.d.ts +10 -0
  138. package/dist/console/routes/traces/route.js +39 -0
  139. package/dist/console/routes/tree.d.ts +153 -0
  140. package/dist/console/routes/tree.js +29 -0
  141. package/dist/console/ui/Errors.d.ts +4 -0
  142. package/dist/console/ui/Errors.js +15 -0
  143. package/dist/console/ui/Fibers.d.ts +24 -0
  144. package/dist/console/ui/Fibers.js +121 -0
  145. package/dist/console/ui/Git.d.ts +20 -0
  146. package/dist/console/ui/Git.js +95 -0
  147. package/dist/console/ui/Logs.d.ts +4 -0
  148. package/dist/console/ui/Logs.js +25 -0
  149. package/dist/console/ui/Metrics.d.ts +4 -0
  150. package/dist/console/ui/Metrics.js +26 -0
  151. package/dist/console/ui/Routes.d.ts +8 -0
  152. package/dist/console/ui/Routes.js +70 -0
  153. package/dist/console/ui/Services.d.ts +10 -0
  154. package/dist/console/ui/Services.js +246 -0
  155. package/dist/console/ui/Shell.d.ts +10 -0
  156. package/dist/console/ui/Shell.js +7 -0
  157. package/dist/console/ui/System.d.ts +4 -0
  158. package/dist/console/ui/System.js +35 -0
  159. package/dist/console/ui/Traces.d.ts +12 -0
  160. package/dist/console/ui/Traces.js +179 -0
  161. package/dist/datastar/actions/fetch.d.ts +1 -1
  162. package/dist/datastar/actions/fetch.js +10 -18
  163. package/dist/datastar/actions/peek.js +1 -2
  164. package/dist/datastar/actions/setAll.js +1 -2
  165. package/dist/datastar/actions/toggleAll.js +1 -2
  166. package/dist/datastar/attributes/attr.js +1 -2
  167. package/dist/datastar/attributes/bind.js +10 -18
  168. package/dist/datastar/attributes/class.js +2 -5
  169. package/dist/datastar/attributes/computed.js +2 -3
  170. package/dist/datastar/attributes/effect.js +1 -2
  171. package/dist/datastar/attributes/indicator.js +2 -4
  172. package/dist/datastar/attributes/init.js +2 -3
  173. package/dist/datastar/attributes/jsonSignals.js +1 -2
  174. package/dist/datastar/attributes/on.js +41 -22
  175. package/dist/datastar/attributes/onIntersect.js +2 -3
  176. package/dist/datastar/attributes/onInterval.js +2 -3
  177. package/dist/datastar/attributes/onSignalPatch.js +2 -4
  178. package/dist/datastar/attributes/ref.js +1 -2
  179. package/dist/datastar/attributes/show.js +1 -2
  180. package/dist/datastar/attributes/signals.js +1 -2
  181. package/dist/datastar/attributes/style.js +6 -12
  182. package/dist/datastar/attributes/text.js +1 -2
  183. package/dist/datastar/engine.d.ts +13 -7
  184. package/dist/datastar/engine.js +76 -48
  185. package/dist/datastar/happydom.d.ts +1 -0
  186. package/dist/datastar/happydom.js +8 -0
  187. package/dist/datastar/index.d.ts +1 -1
  188. package/dist/datastar/index.js +1 -1
  189. package/dist/datastar/utils.js +4 -7
  190. package/dist/datastar/watchers/patchElements.js +24 -45
  191. package/dist/datastar/watchers/patchSignals.js +1 -2
  192. package/dist/experimental/EncryptedCookies.d.ts +2 -5
  193. package/dist/experimental/EncryptedCookies.js +17 -48
  194. package/dist/experimental/index.d.ts +0 -1
  195. package/dist/experimental/index.js +0 -1
  196. package/dist/hyper/Hyper.d.ts +2 -9
  197. package/dist/hyper/Hyper.js +1 -12
  198. package/dist/hyper/HyperHtml.d.ts +1 -1
  199. package/dist/hyper/HyperHtml.js +18 -12
  200. package/dist/hyper/HyperHtml.test.d.ts +1 -0
  201. package/dist/hyper/HyperHtml.test.js +197 -0
  202. package/dist/hyper/HyperRoute.test.js +14 -3
  203. package/dist/hyper/html.d.ts +11 -0
  204. package/dist/hyper/html.js +30 -0
  205. package/dist/hyper/index.d.ts +2 -0
  206. package/dist/hyper/index.js +1 -0
  207. package/dist/hyper/jsx-runtime.d.ts +1 -1
  208. package/dist/hyper/jsx-runtime.js +1 -1
  209. package/dist/index.d.ts +1 -0
  210. package/dist/index.js +1 -0
  211. package/dist/lint/plugin.d.ts +86 -0
  212. package/dist/lint/plugin.js +341 -0
  213. package/dist/node/NodeFileSystem.d.ts +2 -2
  214. package/dist/node/NodeFileSystem.js +4 -14
  215. package/dist/sql/bun/index.d.ts +3 -0
  216. package/dist/sql/bun/index.js +75 -0
  217. package/dist/sql/mssql/docker.d.ts +2 -0
  218. package/dist/sql/mssql/docker.js +67 -0
  219. package/dist/sql/mssql/index.d.ts +21 -0
  220. package/dist/sql/mssql/index.js +113 -0
  221. package/dist/testing/TestLogger.js +4 -1
  222. package/dist/testing/index.d.ts +0 -1
  223. package/dist/testing/index.js +0 -1
  224. package/dist/testing/utils.d.ts +3 -3
  225. package/dist/testing/utils.js +4 -4
  226. package/dist/x/cloudflare/CloudflareTunnel.d.ts +2 -5
  227. package/dist/x/cloudflare/CloudflareTunnel.js +14 -27
  228. package/dist/x/datastar/Datastar.d.ts +1 -1
  229. package/dist/x/datastar/Datastar.js +13 -12
  230. package/dist/x/datastar/index.d.ts +1 -2
  231. package/dist/x/datastar/index.js +1 -2
  232. package/dist/x/tailscale/TailscaleTunnel.d.ts +15 -0
  233. package/dist/x/tailscale/TailscaleTunnel.js +68 -0
  234. package/dist/x/tailscale/index.d.ts +1 -0
  235. package/dist/x/tailscale/index.js +1 -0
  236. package/dist/x/tailwind/TailwindPlugin.js +19 -19
  237. package/dist/x/tailwind/compile.d.ts +2 -2
  238. package/dist/x/tailwind/compile.js +2 -4
  239. package/package.json +22 -9
  240. package/src/ChildProcess.ts +145 -0
  241. package/src/PlatformError.ts +27 -50
  242. package/src/Route.ts +2 -2
  243. package/src/RouteError.ts +76 -0
  244. package/src/RouteHttp.ts +13 -5
  245. package/src/RouteSchema.ts +96 -1
  246. package/src/RouteTree.ts +12 -0
  247. package/src/Sql.ts +51 -0
  248. package/src/SqlIntrospect.ts +620 -0
  249. package/src/Start.ts +29 -12
  250. package/src/StartApp.ts +11 -0
  251. package/src/System.ts +43 -0
  252. package/src/Values.ts +7 -0
  253. package/src/bun/BunChildProcessSpawner.ts +143 -0
  254. package/src/bun/BunRoute.ts +5 -2
  255. package/src/bun/BunServer.ts +69 -7
  256. package/src/bun/index.ts +1 -0
  257. package/src/bundler/BundleRoute.ts +66 -0
  258. package/src/console/Console.ts +42 -0
  259. package/src/console/ConsoleErrors.ts +213 -0
  260. package/src/console/ConsoleLogger.ts +56 -0
  261. package/src/console/ConsoleMetrics.ts +72 -0
  262. package/src/console/ConsoleProcess.ts +59 -0
  263. package/src/console/ConsoleStore.ts +187 -0
  264. package/src/console/ConsoleTracer.ts +107 -0
  265. package/src/console/Simulation.ts +814 -0
  266. package/src/console/console.html +340 -0
  267. package/src/console/index.ts +3 -0
  268. package/src/console/routes/errors/route.tsx +97 -0
  269. package/src/console/routes/fiberDetail.tsx +54 -0
  270. package/src/console/routes/fibers/route.tsx +45 -0
  271. package/src/console/routes/git/route.tsx +64 -0
  272. package/src/console/routes/layout.tsx +4 -0
  273. package/src/console/routes/logs/route.tsx +77 -0
  274. package/src/console/routes/metrics/route.tsx +36 -0
  275. package/src/console/routes/route.tsx +8 -0
  276. package/src/console/routes/routes/route.tsx +30 -0
  277. package/src/console/routes/services/route.tsx +21 -0
  278. package/src/console/routes/system/route.tsx +43 -0
  279. package/src/console/routes/traceDetail.tsx +22 -0
  280. package/src/console/routes/traces/route.tsx +81 -0
  281. package/src/console/routes/tree.ts +30 -0
  282. package/src/console/ui/Errors.tsx +76 -0
  283. package/src/console/ui/Fibers.tsx +321 -0
  284. package/src/console/ui/Git.tsx +182 -0
  285. package/src/console/ui/Logs.tsx +46 -0
  286. package/src/console/ui/Metrics.tsx +78 -0
  287. package/src/console/ui/Routes.tsx +125 -0
  288. package/src/console/ui/Services.tsx +273 -0
  289. package/src/console/ui/Shell.tsx +62 -0
  290. package/src/console/ui/System.tsx +131 -0
  291. package/src/console/ui/Traces.tsx +426 -0
  292. package/src/datastar/README.md +6 -1
  293. package/src/datastar/actions/fetch.ts +0 -1
  294. package/src/datastar/attributes/on.ts +40 -20
  295. package/src/datastar/engine.ts +51 -0
  296. package/src/datastar/jsx.d.ts +79 -0
  297. package/src/hyper/Hyper.ts +1 -16
  298. package/src/hyper/HyperHtml.ts +6 -4
  299. package/src/hyper/HyperRoute.ts +2 -1
  300. package/src/hyper/html.ts +47 -0
  301. package/src/hyper/index.ts +2 -0
  302. package/src/hyper/jsx.d.ts +5 -3
  303. package/src/index.ts +1 -0
  304. package/src/lint/plugin.js +129 -0
  305. package/src/sql/bun/index.ts +147 -0
  306. package/src/sql/mssql/docker.ts +117 -0
  307. package/src/sql/mssql/index.ts +223 -0
  308. package/src/sql/mssql/mssql.d.ts +41 -0
  309. package/src/x/cloudflare/CloudflareTunnel.ts +8 -36
  310. package/src/x/tailscale/TailscaleTunnel.ts +115 -0
  311. package/src/x/tailscale/index.ts +1 -0
  312. package/src/x/datastar/Datastar.ts +0 -61
  313. package/src/x/datastar/index.ts +0 -2
  314. package/src/x/datastar/jsx-datastar.d.ts +0 -60
package/dist/Cookies.js CHANGED
@@ -2,391 +2,301 @@
2
2
  * Minimal Cookies management adapted from @effect/platform
3
3
  * We'll aim for full compatbility when it stabilizes.
4
4
  */
5
- import * as Duration from "effect/Duration"
6
- import * as Inspectable from "effect/Inspectable"
7
- import * as Option from "effect/Option"
8
- import * as Pipeable from "effect/Pipeable"
9
- import * as Predicate from "effect/Predicate"
10
-
11
- export const TypeId = Symbol.for(
12
- "effect-start/Cookies",
13
- )
14
-
15
- export const isCookies = (u) =>
16
- Predicate.hasProperty(u, TypeId)
17
-
18
- export const CookieTypeId = Symbol.for(
19
- "effect-start/Cookies/Cookie",
20
- )
21
-
5
+ import * as Duration from "effect/Duration";
6
+ import * as Inspectable from "effect/Inspectable";
7
+ import * as Option from "effect/Option";
8
+ import * as Pipeable from "effect/Pipeable";
9
+ import * as Predicate from "effect/Predicate";
10
+ export const TypeId = Symbol.for("effect-start/Cookies");
11
+ export const isCookies = (u) => Predicate.hasProperty(u, TypeId);
12
+ export const CookieTypeId = Symbol.for("effect-start/Cookies/Cookie");
22
13
  const CookiesProto = {
23
- [TypeId]: TypeId,
24
- ...Inspectable.BaseProto,
25
- toJSON() {
26
- return {
27
- _id: "effect-start/Cookies",
28
- cookies: Object.fromEntries(
29
- Object.entries(this.cookies).map(([k, v]) => [k, v.toJSON()]),
30
- ),
31
- }
32
- },
33
- pipe() {
34
- return Pipeable.pipeArguments(this, arguments)
35
- },
36
- }
37
-
14
+ [TypeId]: TypeId,
15
+ ...Inspectable.BaseProto,
16
+ toJSON() {
17
+ return {
18
+ _id: "effect-start/Cookies",
19
+ cookies: Object.fromEntries(Object.entries(this.cookies).map(([k, v]) => [k, v.toJSON()])),
20
+ };
21
+ },
22
+ pipe() {
23
+ return Pipeable.pipeArguments(this, arguments);
24
+ },
25
+ };
38
26
  const CookieProto = {
39
- [CookieTypeId]: CookieTypeId,
40
- ...Inspectable.BaseProto,
41
- toJSON() {
42
- return {
43
- _id: "effect-start/Cookies/Cookie",
44
- name: this.name,
45
- value: this.value,
46
- options: this.options,
47
- }
48
- },
49
- }
50
-
51
- const makeCookiesFromRecord = (
52
- cookies,
53
- ) => {
54
- const self = Object.create(CookiesProto)
55
- self.cookies = cookies
56
- return self
57
- }
58
-
59
- const cookieFromParts = (
60
- name,
61
- value,
62
- valueEncoded,
63
- options,
64
- ) =>
65
- Object.assign(Object.create(CookieProto), {
27
+ [CookieTypeId]: CookieTypeId,
28
+ ...Inspectable.BaseProto,
29
+ toJSON() {
30
+ return {
31
+ _id: "effect-start/Cookies/Cookie",
32
+ name: this.name,
33
+ value: this.value,
34
+ options: this.options,
35
+ };
36
+ },
37
+ };
38
+ const makeCookiesFromRecord = (cookies) => {
39
+ const self = Object.create(CookiesProto);
40
+ self.cookies = cookies;
41
+ return self;
42
+ };
43
+ const cookieFromParts = (name, value, valueEncoded, options) => Object.assign(Object.create(CookieProto), {
66
44
  name,
67
45
  value,
68
46
  valueEncoded,
69
47
  options,
70
- })
71
-
72
- export const empty = makeCookiesFromRecord({})
73
-
48
+ });
49
+ export const empty = makeCookiesFromRecord({});
74
50
  export const fromIterable = (cookies) => {
75
- const record = {}
76
- for (const cookie of cookies) {
77
- record[cookie.name] = cookie
78
- }
79
- return makeCookiesFromRecord(record)
80
- }
81
-
82
- export const fromSetCookie = (
83
- headers,
84
- ) => {
85
- const arrayHeaders = typeof headers === "string" ? [headers] : headers
86
- const cookies = []
87
- for (const header of arrayHeaders) {
88
- const cookie = parseSetCookie(header.trim())
89
- if (Option.isSome(cookie)) {
90
- cookies.push(cookie.value)
51
+ const record = {};
52
+ for (const cookie of cookies) {
53
+ record[cookie.name] = cookie;
91
54
  }
92
- }
93
- return fromIterable(cookies)
94
- }
95
-
96
- export const unsafeMakeCookie = (
97
- name,
98
- value,
99
- options,
100
- ) => cookieFromParts(name, value, encodeURIComponent(value), options)
101
-
55
+ return makeCookiesFromRecord(record);
56
+ };
57
+ export const fromSetCookie = (headers) => {
58
+ const arrayHeaders = typeof headers === "string" ? [headers] : headers;
59
+ const cookies = [];
60
+ for (const header of arrayHeaders) {
61
+ const cookie = parseSetCookie(header.trim());
62
+ if (Option.isSome(cookie)) {
63
+ cookies.push(cookie.value);
64
+ }
65
+ }
66
+ return fromIterable(cookies);
67
+ };
68
+ export const unsafeMakeCookie = (name, value, options) => cookieFromParts(name, value, encodeURIComponent(value), options);
102
69
  export const isEmpty = (self) => {
103
- for (const _ in self.cookies) return false
104
- return true
105
- }
106
-
107
- export const get = (
108
- self,
109
- name,
110
- ) =>
111
- name in self.cookies ? Option.some(self.cookies[name]) : Option.none()
112
-
113
- export const getValue = (
114
- self,
115
- name,
116
- ) =>
117
- Option.map(get(self, name), (cookie) => cookie.value)
118
-
119
- export const setCookie = (self, cookie) =>
120
- makeCookiesFromRecord({ ...self.cookies, [cookie.name]: cookie })
121
-
122
- export const unsafeSet = (
123
- self,
124
- name,
125
- value,
126
- options,
127
- ) => setCookie(self, unsafeMakeCookie(name, value, options))
128
-
129
- export const unsafeSetAll = (
130
- self,
131
- cookies,
132
- ) => {
133
- const record = { ...self.cookies }
134
- for (const [name, value, options] of cookies) {
135
- record[name] = unsafeMakeCookie(name, value, options)
136
- }
137
- return makeCookiesFromRecord(record)
138
- }
139
-
70
+ for (const _ in self.cookies)
71
+ return false;
72
+ return true;
73
+ };
74
+ export const get = (self, name) => name in self.cookies ? Option.some(self.cookies[name]) : Option.none();
75
+ export const getValue = (self, name) => Option.map(get(self, name), (cookie) => cookie.value);
76
+ export const setCookie = (self, cookie) => makeCookiesFromRecord({ ...self.cookies, [cookie.name]: cookie });
77
+ export const unsafeSet = (self, name, value, options) => setCookie(self, unsafeMakeCookie(name, value, options));
78
+ export const unsafeSetAll = (self, cookies) => {
79
+ const record = { ...self.cookies };
80
+ for (const [name, value, options] of cookies) {
81
+ record[name] = unsafeMakeCookie(name, value, options);
82
+ }
83
+ return makeCookiesFromRecord(record);
84
+ };
140
85
  export const remove = (self, name) => {
141
- const { [name]: _, ...rest } = self.cookies
142
- return makeCookiesFromRecord(rest)
143
- }
144
-
145
- export const merge = (self, that) =>
146
- makeCookiesFromRecord({ ...self.cookies, ...that.cookies })
147
-
86
+ const { [name]: _, ...rest } = self.cookies;
87
+ return makeCookiesFromRecord(rest);
88
+ };
89
+ export const merge = (self, that) => makeCookiesFromRecord({ ...self.cookies, ...that.cookies });
148
90
  export function serializeCookie(self) {
149
- let str = self.name + "=" + self.valueEncoded
150
-
151
- if (self.options === undefined) {
152
- return str
153
- }
154
- const options = self.options
155
-
156
- if (options.maxAge !== undefined) {
157
- const maxAge = Duration.toSeconds(options.maxAge)
158
- str += "; Max-Age=" + Math.trunc(maxAge)
159
- }
160
-
161
- if (options.domain !== undefined) {
162
- str += "; Domain=" + options.domain
163
- }
164
-
165
- if (options.path !== undefined) {
166
- str += "; Path=" + options.path
167
- }
168
-
169
- if (options.priority !== undefined) {
170
- switch (options.priority) {
171
- case "low":
172
- str += "; Priority=Low"
173
- break
174
- case "medium":
175
- str += "; Priority=Medium"
176
- break
177
- case "high":
178
- str += "; Priority=High"
179
- break
91
+ let str = self.name + "=" + self.valueEncoded;
92
+ if (self.options === undefined) {
93
+ return str;
94
+ }
95
+ const options = self.options;
96
+ if (options.maxAge !== undefined) {
97
+ const maxAge = Duration.toSeconds(options.maxAge);
98
+ str += "; Max-Age=" + Math.trunc(maxAge);
99
+ }
100
+ if (options.domain !== undefined) {
101
+ str += "; Domain=" + options.domain;
102
+ }
103
+ if (options.path !== undefined) {
104
+ str += "; Path=" + options.path;
105
+ }
106
+ if (options.priority !== undefined) {
107
+ switch (options.priority) {
108
+ case "low":
109
+ str += "; Priority=Low";
110
+ break;
111
+ case "medium":
112
+ str += "; Priority=Medium";
113
+ break;
114
+ case "high":
115
+ str += "; Priority=High";
116
+ break;
117
+ }
180
118
  }
181
- }
182
-
183
- if (options.expires !== undefined) {
184
- str += "; Expires=" + options.expires.toUTCString()
185
- }
186
-
187
- if (options.httpOnly) {
188
- str += "; HttpOnly"
189
- }
190
-
191
- if (options.secure) {
192
- str += "; Secure"
193
- }
194
-
195
- if (options.partitioned) {
196
- str += "; Partitioned"
197
- }
198
-
199
- if (options.sameSite !== undefined) {
200
- switch (options.sameSite) {
201
- case "lax":
202
- str += "; SameSite=Lax"
203
- break
204
- case "strict":
205
- str += "; SameSite=Strict"
206
- break
207
- case "none":
208
- str += "; SameSite=None"
209
- break
119
+ if (options.expires !== undefined) {
120
+ str += "; Expires=" + options.expires.toUTCString();
210
121
  }
211
- }
212
-
213
- return str
122
+ if (options.httpOnly) {
123
+ str += "; HttpOnly";
124
+ }
125
+ if (options.secure) {
126
+ str += "; Secure";
127
+ }
128
+ if (options.partitioned) {
129
+ str += "; Partitioned";
130
+ }
131
+ if (options.sameSite !== undefined) {
132
+ switch (options.sameSite) {
133
+ case "lax":
134
+ str += "; SameSite=Lax";
135
+ break;
136
+ case "strict":
137
+ str += "; SameSite=Strict";
138
+ break;
139
+ case "none":
140
+ str += "; SameSite=None";
141
+ break;
142
+ }
143
+ }
144
+ return str;
214
145
  }
215
-
216
- export const toCookieHeader = (self) =>
217
- Object
218
- .values(self.cookies)
146
+ export const toCookieHeader = (self) => Object.values(self.cookies)
219
147
  .map((cookie) => `${cookie.name}=${cookie.valueEncoded}`)
220
- .join("; ")
221
-
148
+ .join("; ");
222
149
  export const toRecord = (self) => {
223
- const record = {}
224
- for (const cookie of Object.values(self.cookies)) {
225
- record[cookie.name] = cookie.value
226
- }
227
- return record
228
- }
229
-
230
- export const toSetCookieHeaders = (self) =>
231
- Object.values(self.cookies).map(serializeCookie)
232
-
233
- export function parseHeader(header) {
234
- const result = {}
235
-
236
- const strLen = header.length
237
- let pos = 0
238
- let terminatorPos = 0
239
-
240
- while (true) {
241
- if (terminatorPos === strLen) break
242
- terminatorPos = header.indexOf(";", pos)
243
- if (terminatorPos === -1) terminatorPos = strLen
244
-
245
- let eqIdx = header.indexOf("=", pos)
246
- if (eqIdx === -1) break
247
- if (eqIdx > terminatorPos) {
248
- pos = terminatorPos + 1
249
- continue
150
+ const record = {};
151
+ for (const cookie of Object.values(self.cookies)) {
152
+ record[cookie.name] = cookie.value;
250
153
  }
251
-
252
- const key = header.substring(pos, eqIdx++).trim()
253
- if (result[key] === undefined) {
254
- const val = header.charCodeAt(eqIdx) === 0x22
255
- ? header.substring(eqIdx + 1, terminatorPos - 1).trim()
256
- : header.substring(eqIdx, terminatorPos).trim()
257
-
258
- result[key] = !(val.indexOf("%") === -1)
259
- ? tryDecodeURIComponent(val)
260
- : val
154
+ return record;
155
+ };
156
+ export const toSetCookieHeaders = (self) => Object.values(self.cookies).map(serializeCookie);
157
+ export function parseHeader(header) {
158
+ const result = {};
159
+ const strLen = header.length;
160
+ let pos = 0;
161
+ let terminatorPos = 0;
162
+ while (true) {
163
+ if (terminatorPos === strLen)
164
+ break;
165
+ terminatorPos = header.indexOf(";", pos);
166
+ if (terminatorPos === -1)
167
+ terminatorPos = strLen;
168
+ let eqIdx = header.indexOf("=", pos);
169
+ if (eqIdx === -1)
170
+ break;
171
+ if (eqIdx > terminatorPos) {
172
+ pos = terminatorPos + 1;
173
+ continue;
174
+ }
175
+ const key = header.substring(pos, eqIdx++).trim();
176
+ if (result[key] === undefined) {
177
+ const val = header.charCodeAt(eqIdx) === 0x22
178
+ ? header.substring(eqIdx + 1, terminatorPos - 1).trim()
179
+ : header.substring(eqIdx, terminatorPos).trim();
180
+ result[key] = !(val.indexOf("%") === -1) ? tryDecodeURIComponent(val) : val;
181
+ }
182
+ pos = terminatorPos + 1;
261
183
  }
262
-
263
- pos = terminatorPos + 1
264
- }
265
-
266
- return result
184
+ return result;
267
185
  }
268
-
269
186
  // eslint-disable-next-line no-control-regex
270
- const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/
271
-
187
+ const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
272
188
  function parseSetCookie(header) {
273
- const parts = header
274
- .split(";")
275
- .map((_) => _.trim())
276
- .filter((_) => _ !== "")
277
- if (parts.length === 0) {
278
- return Option.none()
279
- }
280
-
281
- const firstEqual = parts[0].indexOf("=")
282
- if (firstEqual === -1) {
283
- return Option.none()
284
- }
285
- const name = parts[0].slice(0, firstEqual)
286
- if (!fieldContentRegExp.test(name)) {
287
- return Option.none()
288
- }
289
-
290
- const valueEncoded = parts[0].slice(firstEqual + 1)
291
- const value = tryDecodeURIComponent(valueEncoded)
292
-
293
- if (parts.length === 1) {
294
- return Option.some(cookieFromParts(name, value, valueEncoded))
295
- }
296
-
297
- const options = {}
298
-
299
- for (let i = 1; i < parts.length; i++) {
300
- const part = parts[i]
301
- const equalIndex = part.indexOf("=")
302
- const key = equalIndex === -1 ? part : part.slice(0, equalIndex).trim()
303
- const value = equalIndex === -1
304
- ? undefined
305
- : part.slice(equalIndex + 1).trim()
306
-
307
- switch (key.toLowerCase()) {
308
- case "domain": {
309
- if (value === undefined) break
310
- const domain = value.trim().replace(/^\./, "")
311
- if (domain) options.domain = domain
312
- break
313
- }
314
- case "expires": {
315
- if (value === undefined) break
316
- const date = new Date(value)
317
- if (!isNaN(date.getTime())) options.expires = date
318
- break
319
- }
320
- case "max-age": {
321
- if (value === undefined) break
322
- const maxAge = parseInt(value, 10)
323
- if (!isNaN(maxAge)) options.maxAge = Duration.seconds(maxAge)
324
- break
325
- }
326
- case "path": {
327
- if (value === undefined) break
328
- if (value[0] === "/") options.path = value
329
- break
330
- }
331
- case "priority": {
332
- if (value === undefined) break
333
- switch (value.toLowerCase()) {
334
- case "low":
335
- options.priority = "low"
336
- break
337
- case "medium":
338
- options.priority = "medium"
339
- break
340
- case "high":
341
- options.priority = "high"
342
- break
343
- }
344
- break
345
- }
346
- case "httponly": {
347
- options.httpOnly = true
348
- break
349
- }
350
- case "secure": {
351
- options.secure = true
352
- break
353
- }
354
- case "partitioned": {
355
- options.partitioned = true
356
- break
357
- }
358
- case "samesite": {
359
- if (value === undefined) break
360
- switch (value.toLowerCase()) {
361
- case "lax":
362
- options.sameSite = "lax"
363
- break
364
- case "strict":
365
- options.sameSite = "strict"
366
- break
367
- case "none":
368
- options.sameSite = "none"
369
- break
189
+ const parts = header
190
+ .split(";")
191
+ .map((_) => _.trim())
192
+ .filter((_) => _ !== "");
193
+ if (parts.length === 0) {
194
+ return Option.none();
195
+ }
196
+ const firstEqual = parts[0].indexOf("=");
197
+ if (firstEqual === -1) {
198
+ return Option.none();
199
+ }
200
+ const name = parts[0].slice(0, firstEqual);
201
+ if (!fieldContentRegExp.test(name)) {
202
+ return Option.none();
203
+ }
204
+ const valueEncoded = parts[0].slice(firstEqual + 1);
205
+ const value = tryDecodeURIComponent(valueEncoded);
206
+ if (parts.length === 1) {
207
+ return Option.some(cookieFromParts(name, value, valueEncoded));
208
+ }
209
+ const options = {};
210
+ for (let i = 1; i < parts.length; i++) {
211
+ const part = parts[i];
212
+ const equalIndex = part.indexOf("=");
213
+ const key = equalIndex === -1 ? part : part.slice(0, equalIndex).trim();
214
+ const value = equalIndex === -1 ? undefined : part.slice(equalIndex + 1).trim();
215
+ switch (key.toLowerCase()) {
216
+ case "domain": {
217
+ if (value === undefined)
218
+ break;
219
+ const domain = value.trim().replace(/^\./, "");
220
+ if (domain)
221
+ options.domain = domain;
222
+ break;
223
+ }
224
+ case "expires": {
225
+ if (value === undefined)
226
+ break;
227
+ const date = new Date(value);
228
+ if (!isNaN(date.getTime()))
229
+ options.expires = date;
230
+ break;
231
+ }
232
+ case "max-age": {
233
+ if (value === undefined)
234
+ break;
235
+ const maxAge = parseInt(value, 10);
236
+ if (!isNaN(maxAge))
237
+ options.maxAge = Duration.seconds(maxAge);
238
+ break;
239
+ }
240
+ case "path": {
241
+ if (value === undefined)
242
+ break;
243
+ if (value[0] === "/")
244
+ options.path = value;
245
+ break;
246
+ }
247
+ case "priority": {
248
+ if (value === undefined)
249
+ break;
250
+ switch (value.toLowerCase()) {
251
+ case "low":
252
+ options.priority = "low";
253
+ break;
254
+ case "medium":
255
+ options.priority = "medium";
256
+ break;
257
+ case "high":
258
+ options.priority = "high";
259
+ break;
260
+ }
261
+ break;
262
+ }
263
+ case "httponly": {
264
+ options.httpOnly = true;
265
+ break;
266
+ }
267
+ case "secure": {
268
+ options.secure = true;
269
+ break;
270
+ }
271
+ case "partitioned": {
272
+ options.partitioned = true;
273
+ break;
274
+ }
275
+ case "samesite": {
276
+ if (value === undefined)
277
+ break;
278
+ switch (value.toLowerCase()) {
279
+ case "lax":
280
+ options.sameSite = "lax";
281
+ break;
282
+ case "strict":
283
+ options.sameSite = "strict";
284
+ break;
285
+ case "none":
286
+ options.sameSite = "none";
287
+ break;
288
+ }
289
+ break;
290
+ }
370
291
  }
371
- break
372
- }
373
292
  }
374
- }
375
-
376
- return Option.some(
377
- cookieFromParts(
378
- name,
379
- value,
380
- valueEncoded,
381
- Object.keys(options).length > 0 ? options : undefined,
382
- ),
383
- )
293
+ return Option.some(cookieFromParts(name, value, valueEncoded, Object.keys(options).length > 0 ? options : undefined));
384
294
  }
385
-
386
295
  const tryDecodeURIComponent = (str) => {
387
- try {
388
- return decodeURIComponent(str)
389
- } catch {
390
- return str
391
- }
392
- }
296
+ try {
297
+ return decodeURIComponent(str);
298
+ }
299
+ catch {
300
+ return str;
301
+ }
302
+ };
@@ -1,10 +1,10 @@
1
- import * as FileSystem from "@effect/platform/FileSystem";
1
+ import * as FileSystem from "./FileSystem.ts";
2
2
  import * as Context from "effect/Context";
3
3
  import * as Effect from "effect/Effect";
4
4
  import * as Layer from "effect/Layer";
5
5
  import * as PubSub from "effect/PubSub";
6
6
  import * as Stream from "effect/Stream";
7
- import * as PlatformError from "./PlatformError.ts";
7
+ import type * as PlatformError from "./PlatformError.ts";
8
8
  export type DevelopmentEvent = FileSystem.WatchEvent | {
9
9
  readonly _tag: "Reload";
10
10
  };