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