effect-start 0.25.0 → 0.27.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 (174) hide show
  1. package/package.json +20 -86
  2. package/src/Entity.ts +6 -6
  3. package/src/FileRouterCodegen.ts +4 -4
  4. package/src/FileSystem.ts +4 -8
  5. package/src/RouteHook.ts +1 -1
  6. package/src/RouteSse.ts +3 -3
  7. package/src/SqlIntrospect.ts +2 -2
  8. package/src/Start.ts +102 -2
  9. package/src/Values.ts +11 -0
  10. package/src/bun/BunRoute.ts +1 -1
  11. package/src/bun/BunRuntime.ts +5 -5
  12. package/src/hyper/HyperHtml.ts +11 -7
  13. package/src/hyper/jsx.d.ts +1 -1
  14. package/src/lint/plugin.js +174 -4
  15. package/src/sql/SqlClient.ts +355 -0
  16. package/src/sql/bun/index.ts +117 -50
  17. package/src/sql/index.ts +1 -1
  18. package/src/sql/libsql/index.ts +91 -77
  19. package/src/sql/libsql/libsql.d.ts +4 -1
  20. package/src/sql/mssql/index.ts +141 -108
  21. package/src/sql/mssql/mssql.d.ts +1 -0
  22. package/src/testing/TestLogger.ts +4 -4
  23. package/src/x/tailwind/compile.ts +6 -14
  24. package/dist/ChildProcess.js +0 -42
  25. package/dist/Commander.js +0 -410
  26. package/dist/ContentNegotiation.js +0 -465
  27. package/dist/Cookies.js +0 -371
  28. package/dist/Development.js +0 -94
  29. package/dist/Effectify.js +0 -27
  30. package/dist/Entity.js +0 -289
  31. package/dist/Fetch.js +0 -192
  32. package/dist/FilePathPattern.js +0 -97
  33. package/dist/FileRouter.js +0 -204
  34. package/dist/FileRouterCodegen.js +0 -298
  35. package/dist/FileSystem.js +0 -132
  36. package/dist/Http.js +0 -107
  37. package/dist/PathPattern.js +0 -451
  38. package/dist/PlatformError.js +0 -40
  39. package/dist/PlatformRuntime.js +0 -71
  40. package/dist/Route.js +0 -143
  41. package/dist/RouteBody.js +0 -92
  42. package/dist/RouteError.js +0 -76
  43. package/dist/RouteHook.js +0 -64
  44. package/dist/RouteHttp.js +0 -367
  45. package/dist/RouteHttpTracer.js +0 -90
  46. package/dist/RouteMount.js +0 -86
  47. package/dist/RouteSchema.js +0 -271
  48. package/dist/RouteSse.js +0 -94
  49. package/dist/RouteTree.js +0 -119
  50. package/dist/RouteTrie.js +0 -179
  51. package/dist/SchemaExtra.js +0 -99
  52. package/dist/Socket.js +0 -40
  53. package/dist/SqlIntrospect.js +0 -515
  54. package/dist/Start.js +0 -79
  55. package/dist/StartApp.js +0 -3
  56. package/dist/StreamExtra.js +0 -135
  57. package/dist/System.js +0 -38
  58. package/dist/TuplePathPattern.js +0 -74
  59. package/dist/Unique.js +0 -226
  60. package/dist/Values.js +0 -52
  61. package/dist/bun/BunBundle.js +0 -186
  62. package/dist/bun/BunChildProcessSpawner.js +0 -142
  63. package/dist/bun/BunImportTrackerPlugin.js +0 -91
  64. package/dist/bun/BunRoute.js +0 -157
  65. package/dist/bun/BunRuntime.js +0 -41
  66. package/dist/bun/BunServer.js +0 -285
  67. package/dist/bun/BunVirtualFilesPlugin.js +0 -54
  68. package/dist/bun/_BunEnhancedResolve.js +0 -127
  69. package/dist/bun/index.js +0 -5
  70. package/dist/bundler/Bundle.js +0 -92
  71. package/dist/bundler/BundleFiles.js +0 -154
  72. package/dist/bundler/BundleRoute.js +0 -62
  73. package/dist/client/Overlay.js +0 -33
  74. package/dist/client/ScrollState.js +0 -106
  75. package/dist/client/index.js +0 -97
  76. package/dist/console/Console.js +0 -42
  77. package/dist/console/ConsoleErrors.js +0 -211
  78. package/dist/console/ConsoleLogger.js +0 -56
  79. package/dist/console/ConsoleMetrics.js +0 -72
  80. package/dist/console/ConsoleProcess.js +0 -59
  81. package/dist/console/ConsoleStore.js +0 -72
  82. package/dist/console/ConsoleTracer.js +0 -107
  83. package/dist/console/Simulation.js +0 -784
  84. package/dist/console/index.js +0 -3
  85. package/dist/console/routes/tree.js +0 -30
  86. package/dist/datastar/actions/fetch.js +0 -536
  87. package/dist/datastar/actions/peek.js +0 -13
  88. package/dist/datastar/actions/setAll.js +0 -19
  89. package/dist/datastar/actions/toggleAll.js +0 -19
  90. package/dist/datastar/attributes/attr.js +0 -49
  91. package/dist/datastar/attributes/bind.js +0 -194
  92. package/dist/datastar/attributes/class.js +0 -54
  93. package/dist/datastar/attributes/computed.js +0 -25
  94. package/dist/datastar/attributes/effect.js +0 -10
  95. package/dist/datastar/attributes/indicator.js +0 -33
  96. package/dist/datastar/attributes/init.js +0 -27
  97. package/dist/datastar/attributes/jsonSignals.js +0 -33
  98. package/dist/datastar/attributes/on.js +0 -81
  99. package/dist/datastar/attributes/onIntersect.js +0 -53
  100. package/dist/datastar/attributes/onInterval.js +0 -31
  101. package/dist/datastar/attributes/onSignalPatch.js +0 -51
  102. package/dist/datastar/attributes/ref.js +0 -11
  103. package/dist/datastar/attributes/show.js +0 -32
  104. package/dist/datastar/attributes/signals.js +0 -18
  105. package/dist/datastar/attributes/style.js +0 -57
  106. package/dist/datastar/attributes/text.js +0 -29
  107. package/dist/datastar/engine.js +0 -1145
  108. package/dist/datastar/index.js +0 -25
  109. package/dist/datastar/utils.js +0 -250
  110. package/dist/datastar/watchers/patchElements.js +0 -486
  111. package/dist/datastar/watchers/patchSignals.js +0 -14
  112. package/dist/experimental/EncryptedCookies.js +0 -328
  113. package/dist/experimental/index.js +0 -1
  114. package/dist/hyper/Hyper.js +0 -28
  115. package/dist/hyper/HyperHtml.js +0 -165
  116. package/dist/hyper/HyperNode.js +0 -13
  117. package/dist/hyper/HyperRoute.js +0 -45
  118. package/dist/hyper/html.js +0 -30
  119. package/dist/hyper/index.js +0 -5
  120. package/dist/hyper/jsx-runtime.js +0 -14
  121. package/dist/index.js +0 -8
  122. package/dist/node/NodeFileSystem.js +0 -675
  123. package/dist/node/NodeUtils.js +0 -23
  124. package/dist/sql/Sql.js +0 -8
  125. package/dist/sql/bun/index.js +0 -142
  126. package/dist/sql/index.js +0 -1
  127. package/dist/sql/libsql/index.js +0 -156
  128. package/dist/sql/mssql/docker.js +0 -110
  129. package/dist/sql/mssql/index.js +0 -194
  130. package/dist/testing/TestLogger.js +0 -42
  131. package/dist/testing/index.js +0 -2
  132. package/dist/testing/utils.js +0 -61
  133. package/dist/x/cloudflare/CloudflareTunnel.js +0 -63
  134. package/dist/x/cloudflare/index.js +0 -1
  135. package/dist/x/tailscale/TailscaleTunnel.js +0 -94
  136. package/dist/x/tailscale/index.js +0 -1
  137. package/dist/x/tailwind/TailwindPlugin.js +0 -294
  138. package/dist/x/tailwind/compile.js +0 -210
  139. package/dist/x/tailwind/plugin.js +0 -17
  140. package/src/console/Console.ts +0 -42
  141. package/src/console/ConsoleErrors.ts +0 -213
  142. package/src/console/ConsoleLogger.ts +0 -56
  143. package/src/console/ConsoleMetrics.ts +0 -72
  144. package/src/console/ConsoleProcess.ts +0 -59
  145. package/src/console/ConsoleStore.ts +0 -187
  146. package/src/console/ConsoleTracer.ts +0 -107
  147. package/src/console/Simulation.ts +0 -814
  148. package/src/console/console.html +0 -340
  149. package/src/console/index.ts +0 -3
  150. package/src/console/routes/errors/route.tsx +0 -97
  151. package/src/console/routes/fiberDetail.tsx +0 -54
  152. package/src/console/routes/fibers/route.tsx +0 -45
  153. package/src/console/routes/git/route.tsx +0 -64
  154. package/src/console/routes/layout.tsx +0 -4
  155. package/src/console/routes/logs/route.tsx +0 -77
  156. package/src/console/routes/metrics/route.tsx +0 -36
  157. package/src/console/routes/route.tsx +0 -8
  158. package/src/console/routes/routes/route.tsx +0 -30
  159. package/src/console/routes/services/route.tsx +0 -21
  160. package/src/console/routes/system/route.tsx +0 -43
  161. package/src/console/routes/traceDetail.tsx +0 -22
  162. package/src/console/routes/traces/route.tsx +0 -81
  163. package/src/console/routes/tree.ts +0 -30
  164. package/src/console/ui/Errors.tsx +0 -76
  165. package/src/console/ui/Fibers.tsx +0 -321
  166. package/src/console/ui/Git.tsx +0 -182
  167. package/src/console/ui/Logs.tsx +0 -46
  168. package/src/console/ui/Metrics.tsx +0 -78
  169. package/src/console/ui/Routes.tsx +0 -125
  170. package/src/console/ui/Services.tsx +0 -273
  171. package/src/console/ui/Shell.tsx +0 -62
  172. package/src/console/ui/System.tsx +0 -131
  173. package/src/console/ui/Traces.tsx +0 -426
  174. package/src/sql/Sql.ts +0 -51
@@ -1,187 +0,0 @@
1
- import * as Context from "effect/Context"
2
- import * as Effect from "effect/Effect"
3
- import * as GlobalValue from "effect/GlobalValue"
4
- import * as Layer from "effect/Layer"
5
- import * as MutableRef from "effect/MutableRef"
6
- import * as PubSub from "effect/PubSub"
7
-
8
- export const store: ConsoleStoreShape = GlobalValue.globalValue(
9
- Symbol.for("effect-start/ConsoleStore"),
10
- () => ({
11
- prefix: "/console",
12
- spans: new CircularBuffer<ConsoleSpan>(1000),
13
- logs: new CircularBuffer<ConsoleLog>(5000),
14
- errors: new CircularBuffer<ConsoleError>(1000),
15
- metrics: [] as Array<ConsoleMetricSnapshot>,
16
- process: undefined as ProcessStats | undefined,
17
- events: Effect.runSync(PubSub.unbounded<ConsoleEvent>()),
18
- fiberParents: new Map<string, string>(),
19
- fiberContexts: new Map<string, FiberContext>(),
20
- }),
21
- )
22
-
23
- export interface ConsoleSpan {
24
- readonly spanId: string
25
- readonly traceId: string
26
- readonly name: string
27
- readonly kind: string
28
- readonly parentSpanId: string | undefined
29
- startTime: bigint
30
- endTime: bigint | undefined
31
- durationMs: number | undefined
32
- status: "started" | "ok" | "error"
33
- readonly attributes: Record<string, unknown>
34
- readonly events: Array<{ name: string; startTime: bigint; attributes?: Record<string, unknown> }>
35
- }
36
-
37
- export interface ConsoleLog {
38
- readonly id: string
39
- readonly date: Date
40
- readonly level: "DEBUG" | "INFO" | "WARNING" | "ERROR" | "FATAL"
41
- readonly message: string
42
- readonly fiberId: string
43
- readonly cause: string | undefined
44
- readonly spans: Array<string>
45
- readonly annotations: Record<string, unknown>
46
- }
47
-
48
- export interface ProcessStats {
49
- readonly pid: number
50
- readonly uptime: number
51
- readonly memory: {
52
- readonly rss: number
53
- readonly heapUsed: number
54
- readonly heapTotal: number
55
- readonly external: number
56
- readonly arrayBuffers: number
57
- }
58
- readonly cpu: { readonly user: number; readonly system: number }
59
- readonly resourceUsage: {
60
- readonly maxRSS: number
61
- readonly minorPageFault: number
62
- readonly majorPageFault: number
63
- readonly fsRead: number
64
- readonly fsWrite: number
65
- readonly voluntaryContextSwitches: number
66
- readonly involuntaryContextSwitches: number
67
- }
68
- readonly system: {
69
- readonly loadavg: readonly [number, number, number]
70
- readonly freemem: number
71
- readonly totalmem: number
72
- readonly cpuCount: number
73
- readonly platform: string
74
- readonly arch: string
75
- }
76
- }
77
-
78
- export interface ConsoleErrorDetail {
79
- readonly kind: "fail" | "die"
80
- readonly tag: string | undefined
81
- readonly message: string
82
- readonly properties: Record<string, unknown>
83
- readonly span: string | undefined
84
- }
85
-
86
- export interface ConsoleError {
87
- readonly id: string
88
- readonly date: Date
89
- readonly fiberId: string
90
- readonly interrupted: boolean
91
- readonly prettyPrint: string
92
- readonly details: Array<ConsoleErrorDetail>
93
- }
94
-
95
- export interface ConsoleMetricSnapshot {
96
- readonly name: string
97
- readonly type: "counter" | "gauge" | "histogram" | "summary" | "frequency"
98
- readonly value: unknown
99
- readonly tags: ReadonlyArray<{ key: string; value: string }>
100
- readonly timestamp: number
101
- }
102
-
103
- export type ConsoleEvent =
104
- | { readonly _tag: "SpanStart"; readonly span: ConsoleSpan }
105
- | { readonly _tag: "SpanEnd"; readonly span: ConsoleSpan }
106
- | { readonly _tag: "Log"; readonly log: ConsoleLog }
107
- | { readonly _tag: "Error"; readonly error: ConsoleError }
108
- | { readonly _tag: "MetricsSnapshot"; readonly metrics: Array<ConsoleMetricSnapshot> }
109
- | { readonly _tag: "ProcessSnapshot"; readonly stats: ProcessStats }
110
-
111
- export class CircularBuffer<T> {
112
- private buffer: Array<T | undefined>
113
- private head = 0
114
- private count = 0
115
- capacity: number
116
-
117
- constructor(capacity: number) {
118
- this.capacity = capacity
119
- this.buffer = Array.from({ length: capacity })
120
- }
121
-
122
- push(item: T): void {
123
- this.buffer[this.head] = item
124
- this.head = (this.head + 1) % this.capacity
125
- if (this.count < this.capacity) this.count++
126
- }
127
-
128
- toArray(): Array<T> {
129
- if (this.count === 0) return []
130
- const result: Array<T> = []
131
- const start = this.count < this.capacity ? 0 : this.head
132
- for (let i = 0; i < this.count; i++) {
133
- result.push(this.buffer[(start + i) % this.capacity]!)
134
- }
135
- return result
136
- }
137
-
138
- get size(): number {
139
- return this.count
140
- }
141
- }
142
-
143
- export interface FiberContext {
144
- readonly spanName: string | undefined
145
- readonly traceId: string | undefined
146
- readonly annotations: Record<string, unknown>
147
- }
148
-
149
- export interface ConsoleStoreShape {
150
- prefix: string
151
- readonly spans: CircularBuffer<ConsoleSpan>
152
- readonly logs: CircularBuffer<ConsoleLog>
153
- readonly errors: CircularBuffer<ConsoleError>
154
- metrics: Array<ConsoleMetricSnapshot>
155
- process: ProcessStats | undefined
156
- readonly events: PubSub.PubSub<ConsoleEvent>
157
- readonly fiberParents: Map<string, string>
158
- readonly fiberContexts: Map<string, FiberContext>
159
- }
160
-
161
- export function fiberIdCounter(): number {
162
- const counter = GlobalValue.globalValue(Symbol.for("effect/Fiber/Id/_fiberCounter"), () =>
163
- MutableRef.make(0),
164
- )
165
- return MutableRef.get(counter)
166
- }
167
-
168
- export class ConsoleStore extends Context.Tag("effect-start/ConsoleStore")<
169
- ConsoleStore,
170
- ConsoleStoreShape
171
- >() {}
172
-
173
- export interface ConsoleStoreOptions {
174
- readonly spanCapacity?: number
175
- readonly logCapacity?: number
176
- readonly errorCapacity?: number
177
- }
178
-
179
- export function layer(options?: ConsoleStoreOptions): Layer.Layer<ConsoleStore> {
180
- if (options?.spanCapacity)
181
- (store as any).spans = new CircularBuffer<ConsoleSpan>(options.spanCapacity)
182
- if (options?.logCapacity)
183
- (store as any).logs = new CircularBuffer<ConsoleLog>(options.logCapacity)
184
- if (options?.errorCapacity)
185
- (store as any).errors = new CircularBuffer<ConsoleError>(options.errorCapacity)
186
- return Layer.sync(ConsoleStore, () => store)
187
- }
@@ -1,107 +0,0 @@
1
- import * as Effect from "effect/Effect"
2
- import * as Exit from "effect/Exit"
3
- import * as Fiber from "effect/Fiber"
4
- import * as FiberId from "effect/FiberId"
5
- import * as Layer from "effect/Layer"
6
- import * as Option from "effect/Option"
7
- import * as PubSub from "effect/PubSub"
8
- import * as Tracer from "effect/Tracer"
9
- import * as ConsoleStore from "./ConsoleStore.ts"
10
-
11
- const publish = (store: ConsoleStore.ConsoleStoreShape, event: ConsoleStore.ConsoleEvent) =>
12
- Effect.runSync(PubSub.publish(store.events, event))
13
-
14
- const make = (store: ConsoleStore.ConsoleStoreShape): Tracer.Tracer =>
15
- Tracer.make({
16
- span(name, parent, context, links, startTime, kind, options) {
17
- const parentSpanId =
18
- Option.isSome(parent) && parent.value._tag === "Span" ? parent.value.spanId : undefined
19
- const traceId = Option.isSome(parent)
20
- ? parent.value.traceId
21
- : Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2)
22
- const spanId = Math.random().toString(36).slice(2)
23
-
24
- const attributes: Record<string, unknown> = {}
25
- const currentFiber = Fiber.getCurrentFiber()
26
- if (Option.isSome(currentFiber)) {
27
- attributes["fiber.id"] = FiberId.threadName(currentFiber.value.id())
28
- }
29
- if (typeof options?.captureStackTrace === "function") {
30
- const stacktrace = options.captureStackTrace()
31
- if (stacktrace) {
32
- attributes["code.stacktrace"] = stacktrace
33
- }
34
- }
35
-
36
- const consoleSpan: ConsoleStore.ConsoleSpan = {
37
- spanId,
38
- traceId,
39
- name,
40
- kind,
41
- parentSpanId,
42
- startTime,
43
- endTime: undefined,
44
- durationMs: undefined,
45
- status: "started",
46
- attributes,
47
- events: [],
48
- }
49
-
50
- store.spans.push(consoleSpan)
51
- publish(store, { _tag: "SpanStart", span: consoleSpan })
52
-
53
- const attrs = new Map<string, unknown>(Object.entries(attributes))
54
- const spanLinks = [...links]
55
-
56
- const span: Tracer.Span = {
57
- _tag: "Span",
58
- name,
59
- spanId,
60
- traceId,
61
- parent,
62
- context,
63
- get status(): Tracer.SpanStatus {
64
- if (consoleSpan.endTime != null) {
65
- return {
66
- _tag: "Ended",
67
- startTime: consoleSpan.startTime,
68
- endTime: consoleSpan.endTime,
69
- exit: Exit.void,
70
- }
71
- }
72
- return { _tag: "Started", startTime: consoleSpan.startTime }
73
- },
74
- attributes: attrs,
75
- links: spanLinks,
76
- sampled: true,
77
- kind,
78
- end(endTime, exit) {
79
- consoleSpan.endTime = endTime
80
- consoleSpan.durationMs = Number(endTime - consoleSpan.startTime) / 1_000_000
81
- consoleSpan.status = Exit.isSuccess(exit) ? "ok" : "error"
82
- publish(store, { _tag: "SpanEnd", span: consoleSpan })
83
- },
84
- attribute(key, value) {
85
- attrs.set(key, value)
86
- ;(consoleSpan.attributes as Record<string, unknown>)[key] = value
87
- },
88
- event(name, startTime, attributes) {
89
- consoleSpan.events.push({ name, startTime, attributes })
90
- },
91
- addLinks(newLinks) {
92
- spanLinks.push(...newLinks)
93
- },
94
- }
95
- return span
96
- },
97
- context(f) {
98
- return f()
99
- },
100
- })
101
-
102
- export const layer: Layer.Layer<never, never, ConsoleStore.ConsoleStore> = Layer.unwrapEffect(
103
- Effect.gen(function* () {
104
- const store = yield* ConsoleStore.ConsoleStore
105
- return Layer.setTracer(make(store))
106
- }),
107
- )