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
@@ -1,56 +0,0 @@
1
- import * as Cause from "effect/Cause"
2
- import * as Effect from "effect/Effect"
3
- import * as FiberId from "effect/FiberId"
4
- import * as FiberRef from "effect/FiberRef"
5
- import * as HashMap from "effect/HashMap"
6
- import * as HashSet from "effect/HashSet"
7
- import * as Layer from "effect/Layer"
8
- import * as List from "effect/List"
9
- import * as Logger from "effect/Logger"
10
- import * as PubSub from "effect/PubSub"
11
- import * as ConsoleStore from "./ConsoleStore.js"
12
-
13
- let logId = 0
14
-
15
- export const layer = Layer.effectDiscard(
16
- Effect.gen(function* () {
17
- const store = yield* ConsoleStore.ConsoleStore
18
-
19
- const logger = Logger.make(
20
- ({ message, logLevel, cause, fiberId, spans, annotations, date }) => {
21
- const levelMap = {
22
- Debug: "DEBUG",
23
- Info: "INFO",
24
- Warning: "WARNING",
25
- Error: "ERROR",
26
- Fatal: "FATAL",
27
- }
28
- const level = levelMap[logLevel._tag] ?? "INFO"
29
- const causeStr = !Cause.isEmpty(cause)
30
- ? Cause.pretty(cause, { renderErrorCause: true })
31
- : undefined
32
- const spanNames = []
33
- List.forEach(spans, (s) => spanNames.push(s.label))
34
- const ann = {}
35
- HashMap.forEach(annotations, (v, k) => {
36
- ann[k] = v
37
- })
38
-
39
- const log = {
40
- id: String(++logId),
41
- date,
42
- level,
43
- message: String(message),
44
- fiberId: FiberId.threadName(fiberId),
45
- cause: causeStr,
46
- spans: spanNames,
47
- annotations: ann,
48
- }
49
- store.logs.push(log)
50
- Effect.runSync(PubSub.publish(store.events, { _tag: "Log", log }))
51
- },
52
- )
53
-
54
- yield* FiberRef.update(FiberRef.currentLoggers, (loggers) => HashSet.add(loggers, logger))
55
- }),
56
- )
@@ -1,72 +0,0 @@
1
- import * as Effect from "effect/Effect"
2
- import * as Layer from "effect/Layer"
3
- import * as Metric from "effect/Metric"
4
- import * as MetricKeyType from "effect/MetricKeyType"
5
- import * as PubSub from "effect/PubSub"
6
- import * as Schedule from "effect/Schedule"
7
- import * as ConsoleStore from "./ConsoleStore.js"
8
-
9
- export const layer = Layer.scopedDiscard(
10
- Effect.gen(function* () {
11
- const store = yield* ConsoleStore.ConsoleStore
12
-
13
- yield* Effect.forkScoped(
14
- Effect.schedule(
15
- Effect.sync(() => {
16
- const pairs = Metric.unsafeSnapshot()
17
- const snapshots = []
18
-
19
- for (const pair of pairs) {
20
- const key = pair.metricKey
21
- const state = pair.metricState
22
- let type = "counter"
23
- let value = 0
24
-
25
- if (MetricKeyType.CounterKeyTypeTypeId in key.keyType) {
26
- type = "counter"
27
- value = state.count
28
- } else if (MetricKeyType.GaugeKeyTypeTypeId in key.keyType) {
29
- type = "gauge"
30
- value = state.value
31
- } else if (MetricKeyType.HistogramKeyTypeTypeId in key.keyType) {
32
- type = "histogram"
33
- value = {
34
- buckets: state.buckets,
35
- count: state.count,
36
- sum: state.sum,
37
- min: state.min,
38
- max: state.max,
39
- }
40
- } else if (MetricKeyType.FrequencyKeyTypeTypeId in key.keyType) {
41
- type = "frequency"
42
- value = Object.fromEntries(state.occurrences)
43
- } else if (MetricKeyType.SummaryKeyTypeTypeId in key.keyType) {
44
- type = "summary"
45
- value = {
46
- quantiles: state.quantiles,
47
- count: state.count,
48
- sum: state.sum,
49
- min: state.min,
50
- max: state.max,
51
- }
52
- }
53
-
54
- snapshots.push({
55
- name: key.name,
56
- type,
57
- value,
58
- tags: key.tags.map((t) => ({ key: t.key, value: t.value })),
59
- timestamp: Date.now(),
60
- })
61
- }
62
-
63
- store.metrics = snapshots
64
- Effect.runSync(
65
- PubSub.publish(store.events, { _tag: "MetricsSnapshot", metrics: snapshots }),
66
- )
67
- }),
68
- Schedule.spaced("2 seconds"),
69
- ),
70
- )
71
- }),
72
- )
@@ -1,59 +0,0 @@
1
- import * as NOS from "node:os"
2
- import * as Effect from "effect/Effect"
3
- import * as Layer from "effect/Layer"
4
- import * as PubSub from "effect/PubSub"
5
- import * as Schedule from "effect/Schedule"
6
- import * as ConsoleStore from "./ConsoleStore.js"
7
-
8
- function snapshot() {
9
- const mem = process.memoryUsage()
10
- const cpu = process.cpuUsage()
11
- const res = process.resourceUsage()
12
- const loadavg = NOS.loadavg()
13
- return {
14
- pid: process.pid,
15
- uptime: process.uptime(),
16
- memory: {
17
- rss: mem.rss,
18
- heapUsed: mem.heapUsed,
19
- heapTotal: mem.heapTotal,
20
- external: mem.external,
21
- arrayBuffers: mem.arrayBuffers,
22
- },
23
- cpu: { user: cpu.user, system: cpu.system },
24
- resourceUsage: {
25
- maxRSS: res.maxRSS,
26
- minorPageFault: res.minorPageFault,
27
- majorPageFault: res.majorPageFault,
28
- fsRead: res.fsRead,
29
- fsWrite: res.fsWrite,
30
- voluntaryContextSwitches: res.voluntaryContextSwitches,
31
- involuntaryContextSwitches: res.involuntaryContextSwitches,
32
- },
33
- system: {
34
- loadavg,
35
- freemem: NOS.freemem(),
36
- totalmem: NOS.totalmem(),
37
- cpuCount: NOS.cpus().length,
38
- platform: NOS.platform(),
39
- arch: NOS.arch(),
40
- },
41
- }
42
- }
43
-
44
- export const layer = Layer.scopedDiscard(
45
- Effect.gen(function* () {
46
- const store = yield* ConsoleStore.ConsoleStore
47
-
48
- yield* Effect.forkScoped(
49
- Effect.schedule(
50
- Effect.sync(() => {
51
- const stats = snapshot()
52
- store.process = stats
53
- Effect.runSync(PubSub.publish(store.events, { _tag: "ProcessSnapshot", stats }))
54
- }),
55
- Schedule.spaced("2 seconds"),
56
- ),
57
- )
58
- }),
59
- )
@@ -1,72 +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 = GlobalValue.globalValue(
9
- Symbol.for("effect-start/ConsoleStore"),
10
- () => ({
11
- prefix: "/console",
12
- spans: new CircularBuffer(1000),
13
- logs: new CircularBuffer(5000),
14
- errors: new CircularBuffer(1000),
15
- metrics: [],
16
- process: undefined,
17
- events: Effect.runSync(PubSub.unbounded()),
18
- fiberParents: new Map(),
19
- fiberContexts: new Map(),
20
- }),
21
- )
22
-
23
- export class CircularBuffer {
24
- buffer
25
- head = 0
26
- count = 0
27
- capacity
28
-
29
- constructor(capacity) {
30
- this.capacity = capacity
31
- this.buffer = Array.from({ length: capacity })
32
- }
33
-
34
- push(item) {
35
- this.buffer[this.head] = item
36
- this.head = (this.head + 1) % this.capacity
37
- if (this.count < this.capacity) this.count++
38
- }
39
-
40
- toArray() {
41
- if (this.count === 0) return []
42
- const result = []
43
- const start = this.count < this.capacity ? 0 : this.head
44
- for (let i = 0; i < this.count; i++) {
45
- result.push(this.buffer[(start + i) % this.capacity])
46
- }
47
- return result
48
- }
49
-
50
- get size() {
51
- return this.count
52
- }
53
- }
54
-
55
- export function fiberIdCounter() {
56
- const counter = GlobalValue.globalValue(Symbol.for("effect/Fiber/Id/_fiberCounter"), () =>
57
- MutableRef.make(0),
58
- )
59
- return MutableRef.get(counter)
60
- }
61
-
62
- export class ConsoleStore extends Context.Tag("effect-start/ConsoleStore")() {}
63
-
64
- export function layer(options) {
65
- if (options?.spanCapacity)
66
- (store).spans = new CircularBuffer(options.spanCapacity)
67
- if (options?.logCapacity)
68
- (store).logs = new CircularBuffer(options.logCapacity)
69
- if (options?.errorCapacity)
70
- (store).errors = new CircularBuffer(options.errorCapacity)
71
- return Layer.sync(ConsoleStore, () => store)
72
- }
@@ -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.js"
10
-
11
- const publish = (store, event) =>
12
- Effect.runSync(PubSub.publish(store.events, event))
13
-
14
- const make = (store) =>
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 = {}
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 = {
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(Object.entries(attributes))
54
- const spanLinks = [...links]
55
-
56
- const span = {
57
- _tag: "Span",
58
- name,
59
- spanId,
60
- traceId,
61
- parent,
62
- context,
63
- get status() {
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)[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.unwrapEffect(
103
- Effect.gen(function* () {
104
- const store = yield* ConsoleStore.ConsoleStore
105
- return Layer.setTracer(make(store))
106
- }),
107
- )