effect 3.12.0 → 3.12.2

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 (169) hide show
  1. package/dist/cjs/BigDecimal.js +3 -3
  2. package/dist/cjs/Effect.js +2957 -928
  3. package/dist/cjs/Effect.js.map +1 -1
  4. package/dist/cjs/GlobalValue.js +8 -6
  5. package/dist/cjs/GlobalValue.js.map +1 -1
  6. package/dist/cjs/HashMap.js +2 -2
  7. package/dist/cjs/HashMap.js.map +1 -1
  8. package/dist/cjs/ManagedRuntime.js.map +1 -1
  9. package/dist/cjs/Predicate.js.map +1 -1
  10. package/dist/cjs/Request.js +3 -3
  11. package/dist/cjs/Request.js.map +1 -1
  12. package/dist/cjs/RequestBlock.js +7 -7
  13. package/dist/cjs/RequestBlock.js.map +1 -1
  14. package/dist/cjs/Runtime.js.map +1 -1
  15. package/dist/cjs/Schema.js +5 -8
  16. package/dist/cjs/Schema.js.map +1 -1
  17. package/dist/cjs/Stream.js +5 -5
  18. package/dist/cjs/Stream.js.map +1 -1
  19. package/dist/cjs/internal/channel.js +3 -3
  20. package/dist/cjs/internal/channel.js.map +1 -1
  21. package/dist/cjs/internal/core-effect.js +3 -3
  22. package/dist/cjs/internal/core-effect.js.map +1 -1
  23. package/dist/cjs/internal/core.js +19 -33
  24. package/dist/cjs/internal/core.js.map +1 -1
  25. package/dist/cjs/internal/defaultServices.js +2 -2
  26. package/dist/cjs/internal/defaultServices.js.map +1 -1
  27. package/dist/cjs/internal/effect/circular.js +4 -4
  28. package/dist/cjs/internal/effect/circular.js.map +1 -1
  29. package/dist/cjs/internal/fiberRefs/patch.js +5 -5
  30. package/dist/cjs/internal/fiberRefs/patch.js.map +1 -1
  31. package/dist/cjs/internal/fiberRuntime.js +40 -37
  32. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  33. package/dist/cjs/internal/fiberScope.js.map +1 -1
  34. package/dist/cjs/internal/layer/circular.js +2 -2
  35. package/dist/cjs/internal/layer/circular.js.map +1 -1
  36. package/dist/cjs/internal/logSpan.js +10 -3
  37. package/dist/cjs/internal/logSpan.js.map +1 -1
  38. package/dist/cjs/internal/logger-circular.js +2 -2
  39. package/dist/cjs/internal/logger-circular.js.map +1 -1
  40. package/dist/cjs/internal/logger.js +44 -118
  41. package/dist/cjs/internal/logger.js.map +1 -1
  42. package/dist/cjs/internal/metric.js +3 -3
  43. package/dist/cjs/internal/metric.js.map +1 -1
  44. package/dist/cjs/internal/reloadable.js +7 -7
  45. package/dist/cjs/internal/reloadable.js.map +1 -1
  46. package/dist/cjs/internal/resource.js +2 -2
  47. package/dist/cjs/internal/resource.js.map +1 -1
  48. package/dist/cjs/internal/runtime.js +7 -7
  49. package/dist/cjs/internal/runtime.js.map +1 -1
  50. package/dist/cjs/internal/scopedCache.js +9 -9
  51. package/dist/cjs/internal/scopedCache.js.map +1 -1
  52. package/dist/cjs/internal/stream.js +28 -28
  53. package/dist/cjs/internal/stream.js.map +1 -1
  54. package/dist/cjs/internal/subscriptionRef.js +4 -4
  55. package/dist/cjs/internal/subscriptionRef.js.map +1 -1
  56. package/dist/cjs/internal/synchronizedRef.js.map +1 -1
  57. package/dist/cjs/internal/version.js +1 -1
  58. package/dist/dts/BigDecimal.d.ts +3 -3
  59. package/dist/dts/Effect.d.ts +6541 -2072
  60. package/dist/dts/Effect.d.ts.map +1 -1
  61. package/dist/dts/GlobalValue.d.ts.map +1 -1
  62. package/dist/dts/Layer.d.ts +3 -3
  63. package/dist/dts/Layer.d.ts.map +1 -1
  64. package/dist/dts/ManagedRuntime.d.ts +2 -2
  65. package/dist/dts/ManagedRuntime.d.ts.map +1 -1
  66. package/dist/dts/Predicate.d.ts +1 -1
  67. package/dist/dts/Predicate.d.ts.map +1 -1
  68. package/dist/dts/Runtime.d.ts +2 -2
  69. package/dist/dts/Runtime.d.ts.map +1 -1
  70. package/dist/dts/Schema.d.ts.map +1 -1
  71. package/dist/dts/Utils.d.ts +4 -4
  72. package/dist/dts/Utils.d.ts.map +1 -1
  73. package/dist/dts/internal/core-effect.d.ts.map +1 -1
  74. package/dist/dts/internal/core.d.ts.map +1 -1
  75. package/dist/dts/internal/fiberScope.d.ts.map +1 -1
  76. package/dist/dts/internal/logger.d.ts +1 -1
  77. package/dist/dts/internal/logger.d.ts.map +1 -1
  78. package/dist/esm/BigDecimal.js +3 -3
  79. package/dist/esm/Effect.js +2958 -929
  80. package/dist/esm/Effect.js.map +1 -1
  81. package/dist/esm/GlobalValue.js +8 -6
  82. package/dist/esm/GlobalValue.js.map +1 -1
  83. package/dist/esm/HashMap.js +2 -2
  84. package/dist/esm/HashMap.js.map +1 -1
  85. package/dist/esm/ManagedRuntime.js.map +1 -1
  86. package/dist/esm/Predicate.js.map +1 -1
  87. package/dist/esm/Request.js +3 -3
  88. package/dist/esm/Request.js.map +1 -1
  89. package/dist/esm/RequestBlock.js +7 -7
  90. package/dist/esm/RequestBlock.js.map +1 -1
  91. package/dist/esm/Runtime.js.map +1 -1
  92. package/dist/esm/Schema.js +5 -8
  93. package/dist/esm/Schema.js.map +1 -1
  94. package/dist/esm/Stream.js +5 -5
  95. package/dist/esm/Stream.js.map +1 -1
  96. package/dist/esm/internal/channel.js +3 -3
  97. package/dist/esm/internal/channel.js.map +1 -1
  98. package/dist/esm/internal/core-effect.js +3 -3
  99. package/dist/esm/internal/core-effect.js.map +1 -1
  100. package/dist/esm/internal/core.js +16 -28
  101. package/dist/esm/internal/core.js.map +1 -1
  102. package/dist/esm/internal/defaultServices.js +2 -2
  103. package/dist/esm/internal/defaultServices.js.map +1 -1
  104. package/dist/esm/internal/effect/circular.js +4 -4
  105. package/dist/esm/internal/effect/circular.js.map +1 -1
  106. package/dist/esm/internal/fiberRefs/patch.js +5 -5
  107. package/dist/esm/internal/fiberRefs/patch.js.map +1 -1
  108. package/dist/esm/internal/fiberRuntime.js +40 -37
  109. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  110. package/dist/esm/internal/fiberScope.js.map +1 -1
  111. package/dist/esm/internal/layer/circular.js +2 -2
  112. package/dist/esm/internal/layer/circular.js.map +1 -1
  113. package/dist/esm/internal/logSpan.js +7 -1
  114. package/dist/esm/internal/logSpan.js.map +1 -1
  115. package/dist/esm/internal/logger-circular.js +2 -2
  116. package/dist/esm/internal/logger-circular.js.map +1 -1
  117. package/dist/esm/internal/logger.js +45 -119
  118. package/dist/esm/internal/logger.js.map +1 -1
  119. package/dist/esm/internal/metric.js +3 -3
  120. package/dist/esm/internal/metric.js.map +1 -1
  121. package/dist/esm/internal/reloadable.js +7 -7
  122. package/dist/esm/internal/reloadable.js.map +1 -1
  123. package/dist/esm/internal/resource.js +2 -2
  124. package/dist/esm/internal/resource.js.map +1 -1
  125. package/dist/esm/internal/runtime.js +7 -7
  126. package/dist/esm/internal/runtime.js.map +1 -1
  127. package/dist/esm/internal/scopedCache.js +9 -9
  128. package/dist/esm/internal/scopedCache.js.map +1 -1
  129. package/dist/esm/internal/stream.js +28 -28
  130. package/dist/esm/internal/stream.js.map +1 -1
  131. package/dist/esm/internal/subscriptionRef.js +4 -4
  132. package/dist/esm/internal/subscriptionRef.js.map +1 -1
  133. package/dist/esm/internal/synchronizedRef.js.map +1 -1
  134. package/dist/esm/internal/version.js +1 -1
  135. package/package.json +1 -1
  136. package/src/BigDecimal.ts +3 -3
  137. package/src/Effect.ts +6587 -2108
  138. package/src/GlobalValue.ts +8 -6
  139. package/src/HashMap.ts +2 -2
  140. package/src/Layer.ts +3 -3
  141. package/src/ManagedRuntime.ts +3 -2
  142. package/src/Predicate.ts +2 -2
  143. package/src/Request.ts +3 -3
  144. package/src/RequestBlock.ts +7 -7
  145. package/src/Runtime.ts +2 -5
  146. package/src/Schema.ts +5 -8
  147. package/src/Stream.ts +5 -5
  148. package/src/Utils.ts +4 -4
  149. package/src/internal/channel.ts +3 -3
  150. package/src/internal/core-effect.ts +4 -6
  151. package/src/internal/core.ts +28 -54
  152. package/src/internal/defaultServices.ts +10 -10
  153. package/src/internal/effect/circular.ts +54 -49
  154. package/src/internal/fiberRefs/patch.ts +5 -5
  155. package/src/internal/fiberRuntime.ts +54 -48
  156. package/src/internal/fiberScope.ts +0 -1
  157. package/src/internal/layer/circular.ts +2 -2
  158. package/src/internal/logSpan.ts +8 -1
  159. package/src/internal/logger-circular.ts +2 -2
  160. package/src/internal/logger.ts +54 -145
  161. package/src/internal/metric.ts +3 -3
  162. package/src/internal/reloadable.ts +10 -10
  163. package/src/internal/resource.ts +2 -2
  164. package/src/internal/runtime.ts +8 -8
  165. package/src/internal/scopedCache.ts +23 -23
  166. package/src/internal/stream.ts +30 -30
  167. package/src/internal/subscriptionRef.ts +4 -4
  168. package/src/internal/synchronizedRef.ts +0 -1
  169. package/src/internal/version.ts +1 -1
@@ -2,20 +2,20 @@ import * as Arr from "../Array.js"
2
2
  import * as Context from "../Context.js"
3
3
  import * as FiberRefs from "../FiberRefs.js"
4
4
  import type { LazyArg } from "../Function.js"
5
- import { constVoid, dual, pipe } from "../Function.js"
5
+ import { constVoid, dual } from "../Function.js"
6
6
  import { globalValue } from "../GlobalValue.js"
7
7
  import * as HashMap from "../HashMap.js"
8
8
  import * as Inspectable from "../Inspectable.js"
9
9
  import * as List from "../List.js"
10
10
  import type * as Logger from "../Logger.js"
11
11
  import type * as LogLevel from "../LogLevel.js"
12
- import * as LogSpan from "../LogSpan.js"
13
12
  import * as Option from "../Option.js"
14
13
  import { pipeArguments } from "../Pipeable.js"
15
14
  import * as Cause from "./cause.js"
16
15
  import * as defaultServices from "./defaultServices.js"
17
16
  import { consoleTag } from "./defaultServices/console.js"
18
- import * as _fiberId from "./fiberId.js"
17
+ import * as fiberId_ from "./fiberId.js"
18
+ import * as logSpan_ from "./logSpan.js"
19
19
 
20
20
  /** @internal */
21
21
  const LoggerSymbolKey = "effect/Logger"
@@ -162,136 +162,60 @@ export const zipRight = dual<
162
162
  ) => Logger.Logger<Message & Message2, Output2>
163
163
  >(2, (self, that) => map(zip(self, that), (tuple) => tuple[1]))
164
164
 
165
- /** @internal */
166
- export const stringLogger: Logger.Logger<unknown, string> = makeLogger(
167
- ({ annotations, cause, date, fiberId, logLevel, message, spans }) => {
168
- const nowMillis = date.getTime()
169
-
170
- const outputArray = [
171
- `timestamp=${date.toISOString()}`,
172
- `level=${logLevel.label}`,
173
- `fiber=${_fiberId.threadName(fiberId)}`
174
- ]
175
-
176
- let output = outputArray.join(" ")
177
-
178
- const messageArr = Arr.ensure(message)
179
- for (let i = 0; i < messageArr.length; i++) {
180
- const stringMessage = Inspectable.toStringUnknown(messageArr[i])
181
- if (stringMessage.length > 0) {
182
- output = output + " message="
183
- output = appendQuoted(stringMessage, output)
184
- }
185
- }
186
-
187
- if (cause != null && cause._tag !== "Empty") {
188
- output = output + " cause="
189
- output = appendQuoted(Cause.pretty(cause, { renderErrorCause: true }), output)
190
- }
191
-
192
- if (List.isCons(spans)) {
193
- output = output + " "
194
-
195
- let first = true
196
- for (const span of spans) {
197
- if (first) {
198
- first = false
199
- } else {
200
- output = output + " "
201
- }
202
- output = output + pipe(span, LogSpan.render(nowMillis))
203
- }
204
- }
165
+ /**
166
+ * Match strings that do not contain any whitespace characters, double quotes,
167
+ * or equal signs.
168
+ *
169
+ * @internal
170
+ */
171
+ const textOnly = /^[^\s"=]*$/
172
+
173
+ /**
174
+ * Used by both {@link stringLogger} and {@link logfmtLogger} to render a log
175
+ * message.
176
+ *
177
+ * @internal
178
+ */
179
+ const format = (quoteValue: (s: string) => string, whitespace?: number | string | undefined) =>
180
+ (
181
+ { annotations, cause, date, fiberId, logLevel, message, spans }: Logger.Logger.Options<unknown>
182
+ ): string => {
183
+ const formatValue = (value: string): string => value.match(textOnly) ? value : quoteValue(value)
184
+ const format = (label: string, value: string): string => `${logSpan_.formatLabel(label)}=${formatValue(value)}`
185
+ const append = (label: string, value: string): string => " " + format(label, value)
186
+
187
+ let out = format("timestamp", date.toISOString())
188
+ out += append("level", logLevel.label)
189
+ out += append("fiber", fiberId_.threadName(fiberId))
190
+
191
+ const messages = Arr.ensure(message)
192
+ for (let i = 0; i < messages.length; i++) {
193
+ out += append("message", Inspectable.toStringUnknown(messages[i], whitespace))
194
+ }
205
195
 
206
- if (HashMap.size(annotations) > 0) {
207
- output = output + " "
208
-
209
- let first = true
210
- for (const [key, value] of annotations) {
211
- if (first) {
212
- first = false
213
- } else {
214
- output = output + " "
215
- }
216
- output = output + filterKeyName(key)
217
- output = output + "="
218
- output = appendQuoted(Inspectable.toStringUnknown(value), output)
219
- }
220
- }
196
+ if (!Cause.isEmptyType(cause)) {
197
+ out += append("cause", Cause.pretty(cause, { renderErrorCause: true }))
198
+ }
221
199
 
222
- return output
200
+ for (const span of spans) {
201
+ out += " " + logSpan_.render(date.getTime())(span)
223
202
  }
224
- )
225
203
 
226
- /** @internal */
227
- const escapeDoubleQuotes = (str: string) => `"${str.replace(/\\([\s\S])|(")/g, "\\$1$2")}"`
204
+ for (const [label, value] of annotations) {
205
+ out += append(label, Inspectable.toStringUnknown(value, whitespace))
206
+ }
228
207
 
229
- const textOnly = /^[^\s"=]+$/
208
+ return out
209
+ }
230
210
 
231
211
  /** @internal */
232
- const appendQuoted = (label: string, output: string): string =>
233
- output + (label.match(textOnly) ? label : escapeDoubleQuotes(label))
212
+ const escapeDoubleQuotes = (s: string) => `"${s.replace(/\\([\s\S])|(")/g, "\\$1$2")}"`
234
213
 
235
214
  /** @internal */
236
- export const logfmtLogger = makeLogger<unknown, string>(
237
- ({ annotations, cause, date, fiberId, logLevel, message, spans }) => {
238
- const nowMillis = date.getTime()
215
+ export const stringLogger: Logger.Logger<unknown, string> = makeLogger(format(escapeDoubleQuotes))
239
216
 
240
- const outputArray = [
241
- `timestamp=${date.toISOString()}`,
242
- `level=${logLevel.label}`,
243
- `fiber=${_fiberId.threadName(fiberId)}`
244
- ]
245
-
246
- let output = outputArray.join(" ")
247
-
248
- const messageArr = Arr.ensure(message)
249
- for (let i = 0; i < messageArr.length; i++) {
250
- const stringMessage = Inspectable.toStringUnknown(messageArr[i], 0)
251
- if (stringMessage.length > 0) {
252
- output = output + " message="
253
- output = appendQuotedLogfmt(stringMessage, output)
254
- }
255
- }
256
-
257
- if (cause != null && cause._tag !== "Empty") {
258
- output = output + " cause="
259
- output = appendQuotedLogfmt(Cause.pretty(cause, { renderErrorCause: true }), output)
260
- }
261
-
262
- if (List.isCons(spans)) {
263
- output = output + " "
264
-
265
- let first = true
266
- for (const span of spans) {
267
- if (first) {
268
- first = false
269
- } else {
270
- output = output + " "
271
- }
272
- output = output + pipe(span, renderLogSpanLogfmt(nowMillis))
273
- }
274
- }
275
-
276
- if (HashMap.size(annotations) > 0) {
277
- output = output + " "
278
-
279
- let first = true
280
- for (const [key, value] of annotations) {
281
- if (first) {
282
- first = false
283
- } else {
284
- output = output + " "
285
- }
286
- output = output + filterKeyName(key)
287
- output = output + "="
288
- output = appendQuotedLogfmt(Inspectable.toStringUnknown(value, 0), output)
289
- }
290
- }
291
-
292
- return output
293
- }
294
- )
217
+ /** @internal */
218
+ export const logfmtLogger: Logger.Logger<unknown, string> = makeLogger(format(JSON.stringify, 0))
295
219
 
296
220
  /** @internal */
297
221
  export const structuredLogger = makeLogger<unknown, {
@@ -328,11 +252,12 @@ export const structuredLogger = makeLogger<unknown, {
328
252
  cause: Cause.isEmpty(cause) ? undefined : Cause.pretty(cause, { renderErrorCause: true }),
329
253
  annotations: annotationsObj,
330
254
  spans: spansObj,
331
- fiberId: _fiberId.threadName(fiberId)
255
+ fiberId: fiberId_.threadName(fiberId)
332
256
  }
333
257
  }
334
258
  )
335
259
 
260
+ /** @internal */
336
261
  export const structuredMessage = (u: unknown): unknown => {
337
262
  switch (typeof u) {
338
263
  case "bigint":
@@ -349,22 +274,6 @@ export const structuredMessage = (u: unknown): unknown => {
349
274
  /** @internal */
350
275
  export const jsonLogger = map(structuredLogger, Inspectable.stringifyCircular)
351
276
 
352
- /** @internal */
353
- const filterKeyName = (key: string) => key.replace(/[\s="]/g, "_")
354
-
355
- /** @internal */
356
- const escapeDoubleQuotesLogfmt = (str: string) => JSON.stringify(str)
357
-
358
- /** @internal */
359
- const appendQuotedLogfmt = (label: string, output: string): string =>
360
- output + (label.match(textOnly) ? label : escapeDoubleQuotesLogfmt(label))
361
-
362
- /** @internal */
363
- const renderLogSpanLogfmt = (now: number) => (self: LogSpan.LogSpan): string => {
364
- const label = filterKeyName(self.label)
365
- return `${label}=${now - self.startTime}ms`
366
- }
367
-
368
277
  /** @internal */
369
278
  export const isLogger = (u: unknown): u is Logger.Logger<unknown, unknown> => {
370
279
  return typeof u === "object" && u != null && LoggerTypeId in u
@@ -448,7 +357,7 @@ const prettyLoggerTty = (options: {
448
357
  readonly formatDate: (date: Date) => string
449
358
  }) => {
450
359
  const processIsBun = typeof process === "object" && "isBun" in process && process.isBun === true
451
- const color = options.colors && processStdoutIsTTY ? withColor : withColorNoop
360
+ const color = options.colors ? withColor : withColorNoop
452
361
  return makeLogger<unknown, void>(
453
362
  ({ annotations, cause, context, date, fiberId, logLevel, message: message_, spans }) => {
454
363
  const services = FiberRefs.getOrDefault(context, defaultServices.currentServices)
@@ -459,11 +368,11 @@ const prettyLoggerTty = (options: {
459
368
 
460
369
  let firstLine = color(`[${options.formatDate(date)}]`, colors.white)
461
370
  + ` ${color(logLevel.label, ...logLevelColors[logLevel._tag])}`
462
- + ` (${_fiberId.threadName(fiberId)})`
371
+ + ` (${fiberId_.threadName(fiberId)})`
463
372
 
464
373
  if (List.isCons(spans)) {
465
374
  const now = date.getTime()
466
- const render = renderLogSpanLogfmt(now)
375
+ const render = logSpan_.render(now)
467
376
  for (const span of spans) {
468
377
  firstLine += " " + render(span)
469
378
  }
@@ -519,13 +428,13 @@ const prettyLoggerBrowser = (options: {
519
428
  if (options.colors) {
520
429
  firstParams.push("color:gray")
521
430
  }
522
- firstLine += ` ${color}${logLevel.label}${color} (${_fiberId.threadName(fiberId)})`
431
+ firstLine += ` ${color}${logLevel.label}${color} (${fiberId_.threadName(fiberId)})`
523
432
  if (options.colors) {
524
433
  firstParams.push(logLevelStyle[logLevel._tag], "")
525
434
  }
526
435
  if (List.isCons(spans)) {
527
436
  const now = date.getTime()
528
- const render = renderLogSpanLogfmt(now)
437
+ const render = logSpan_.render(now)
529
438
  for (const span of spans) {
530
439
  firstLine += " " + render(span)
531
440
  }
@@ -16,7 +16,7 @@ import type * as MetricRegistry from "../MetricRegistry.js"
16
16
  import type * as MetricState from "../MetricState.js"
17
17
  import { pipeArguments } from "../Pipeable.js"
18
18
  import * as Cause from "./cause.js"
19
- import * as _effect from "./core-effect.js"
19
+ import * as effect_ from "./core-effect.js"
20
20
  import * as core from "./core.js"
21
21
  import * as metricBoundaries from "./metric/boundaries.js"
22
22
  import * as metricKey from "./metric/key.js"
@@ -411,7 +411,7 @@ export const trackDefectWith = dual<
411
411
  ) => Effect.Effect<A, E, R>
412
412
  >(3, (self, metric, f) => {
413
413
  const updater = (defect: unknown) => update(metric, f(defect))
414
- return _effect.tapDefect(self, (cause) => core.forEachSequentialDiscard(Cause.defects(cause), updater))
414
+ return effect_.tapDefect(self, (cause) => core.forEachSequentialDiscard(Cause.defects(cause), updater))
415
415
  })
416
416
 
417
417
  /* @internal */
@@ -477,7 +477,7 @@ export const trackErrorWith = dual<
477
477
  f: (error: In2) => In
478
478
  ) => {
479
479
  const updater = (error: E): Effect.Effect<void> => update(metric, f(error))
480
- return _effect.tapError(self, updater)
480
+ return effect_.tapError(self, updater)
481
481
  })
482
482
 
483
483
  /* @internal */
@@ -7,8 +7,8 @@ import type * as Schedule from "../Schedule.js"
7
7
  import * as effect from "./core-effect.js"
8
8
  import * as core from "./core.js"
9
9
  import * as fiberRuntime from "./fiberRuntime.js"
10
- import * as _layer from "./layer.js"
11
- import * as _schedule from "./schedule.js"
10
+ import * as layer_ from "./layer.js"
11
+ import * as schedule_ from "./schedule.js"
12
12
  import * as scopedRef from "./scopedRef.js"
13
13
 
14
14
  /** @internal */
@@ -32,17 +32,17 @@ export const auto = <Out extends Context.Tag<any, any>, E, In, R>(
32
32
  readonly schedule: Schedule.Schedule<unknown, unknown, R>
33
33
  }
34
34
  ): Layer.Layer<Reloadable.Reloadable<Context.Tag.Identifier<Out>>, E, R | In> =>
35
- _layer.scoped(
35
+ layer_.scoped(
36
36
  reloadableTag(tag),
37
37
  pipe(
38
- _layer.build(manual(tag, { layer: options.layer })),
38
+ layer_.build(manual(tag, { layer: options.layer })),
39
39
  core.map(Context.unsafeGet(reloadableTag(tag))),
40
40
  core.tap((reloadable) =>
41
41
  fiberRuntime.acquireRelease(
42
42
  pipe(
43
43
  reloadable.reload,
44
44
  effect.ignoreLogged,
45
- _schedule.schedule_Effect(options.schedule),
45
+ schedule_.schedule_Effect(options.schedule),
46
46
  fiberRuntime.forkDaemon
47
47
  ),
48
48
  core.interruptFiber
@@ -59,13 +59,13 @@ export const autoFromConfig = <Out extends Context.Tag<any, any>, E, In, R>(
59
59
  readonly scheduleFromConfig: (context: Context.Context<In>) => Schedule.Schedule<unknown, unknown, R>
60
60
  }
61
61
  ): Layer.Layer<Reloadable.Reloadable<Context.Tag.Identifier<Out>>, E, R | In> =>
62
- _layer.scoped(
62
+ layer_.scoped(
63
63
  reloadableTag(tag),
64
64
  pipe(
65
65
  core.context<In>(),
66
66
  core.flatMap((env) =>
67
67
  pipe(
68
- _layer.build(auto(tag, {
68
+ layer_.build(auto(tag, {
69
69
  layer: options.layer,
70
70
  schedule: options.scheduleFromConfig(env)
71
71
  })),
@@ -91,18 +91,18 @@ export const manual = <Out extends Context.Tag<any, any>, In, E>(
91
91
  readonly layer: Layer.Layer<Context.Tag.Identifier<Out>, E, In>
92
92
  }
93
93
  ): Layer.Layer<Reloadable.Reloadable<Context.Tag.Identifier<Out>>, E, In> =>
94
- _layer.scoped(
94
+ layer_.scoped(
95
95
  reloadableTag(tag),
96
96
  pipe(
97
97
  core.context<In>(),
98
98
  core.flatMap((env) =>
99
99
  pipe(
100
- scopedRef.fromAcquire(pipe(_layer.build(options.layer), core.map(Context.unsafeGet(tag)))),
100
+ scopedRef.fromAcquire(pipe(layer_.build(options.layer), core.map(Context.unsafeGet(tag)))),
101
101
  core.map((ref) => ({
102
102
  [ReloadableTypeId]: reloadableVariance,
103
103
  scopedRef: ref,
104
104
  reload: pipe(
105
- scopedRef.set(ref, pipe(_layer.build(options.layer), core.map(Context.unsafeGet(tag)))),
105
+ scopedRef.set(ref, pipe(layer_.build(options.layer), core.map(Context.unsafeGet(tag)))),
106
106
  core.provideContext(env)
107
107
  )
108
108
  }))
@@ -6,7 +6,7 @@ import type * as Scope from "../Scope.js"
6
6
  import * as core from "./core.js"
7
7
  import * as effectable from "./effectable.js"
8
8
  import * as fiberRuntime from "./fiberRuntime.js"
9
- import * as _schedule from "./schedule.js"
9
+ import * as schedule_ from "./schedule.js"
10
10
  import * as scopedRef from "./scopedRef.js"
11
11
 
12
12
  /** @internal */
@@ -42,7 +42,7 @@ export const auto = <A, E, R, Out, R2>(
42
42
  fiberRuntime.acquireRelease(
43
43
  pipe(
44
44
  refresh(manual),
45
- _schedule.schedule_Effect(policy),
45
+ schedule_.schedule_Effect(policy),
46
46
  core.interruptible,
47
47
  fiberRuntime.forkDaemon
48
48
  ),
@@ -15,8 +15,8 @@ import { pipeArguments } from "../Pipeable.js"
15
15
  import * as Predicate from "../Predicate.js"
16
16
  import type * as Runtime from "../Runtime.js"
17
17
  import type * as RuntimeFlags from "../RuntimeFlags.js"
18
- import * as _scheduler from "../Scheduler.js"
19
- import * as _scope from "../Scope.js"
18
+ import * as scheduler_ from "../Scheduler.js"
19
+ import * as scope_ from "../Scope.js"
20
20
  import * as InternalCause from "./cause.js"
21
21
  import * as core from "./core.js"
22
22
  import * as executionStrategy from "./executionStrategy.js"
@@ -24,7 +24,7 @@ import * as FiberRuntime from "./fiberRuntime.js"
24
24
  import * as fiberScope from "./fiberScope.js"
25
25
  import * as OpCodes from "./opCodes/effect.js"
26
26
  import * as runtimeFlags from "./runtimeFlags.js"
27
- import * as _supervisor from "./supervisor.js"
27
+ import * as supervisor_ from "./supervisor.js"
28
28
 
29
29
  /** @internal */
30
30
  export const unsafeFork = <R>(runtime: Runtime.Runtime<R>) =>
@@ -38,7 +38,7 @@ export const unsafeFork = <R>(runtime: Runtime.Runtime<R>) =>
38
38
  > = [[core.currentContext, [[fiberId, runtime.context]]]]
39
39
 
40
40
  if (options?.scheduler) {
41
- fiberRefUpdates.push([_scheduler.currentScheduler, [[fiberId, options.scheduler]]])
41
+ fiberRefUpdates.push([scheduler_.currentScheduler, [[fiberId, options.scheduler]]])
42
42
  }
43
43
 
44
44
  let fiberRefs = FiberRefs.updateManyAs(runtime.fiberRefs, {
@@ -60,7 +60,7 @@ export const unsafeFork = <R>(runtime: Runtime.Runtime<R>) =>
60
60
 
61
61
  if (options?.scope) {
62
62
  effect = core.flatMap(
63
- _scope.fork(options.scope, executionStrategy.sequential),
63
+ scope_.fork(options.scope, executionStrategy.sequential),
64
64
  (closeableScope) =>
65
65
  core.zipRight(
66
66
  core.scopeAddFinalizer(
@@ -69,7 +69,7 @@ export const unsafeFork = <R>(runtime: Runtime.Runtime<R>) =>
69
69
  equals(id, fiberRuntime.id()) ? core.void : core.interruptAsFiber(fiberRuntime, id)
70
70
  )
71
71
  ),
72
- core.onExit(self, (exit) => _scope.close(closeableScope, exit))
72
+ core.onExit(self, (exit) => scope_.close(closeableScope, exit))
73
73
  )
74
74
  )
75
75
  }
@@ -77,7 +77,7 @@ export const unsafeFork = <R>(runtime: Runtime.Runtime<R>) =>
77
77
  const supervisor = fiberRuntime.currentSupervisor
78
78
 
79
79
  // we can compare by reference here as _supervisor.none is wrapped with globalValue
80
- if (supervisor !== _supervisor.none) {
80
+ if (supervisor !== supervisor_.none) {
81
81
  supervisor.onStart(runtime.context, effect, Option.none(), fiberRuntime)
82
82
 
83
83
  fiberRuntime.addObserver((exit) => supervisor.onEnd(exit, fiberRuntime))
@@ -243,7 +243,7 @@ export const unsafeRunSyncExit =
243
243
  if (op) {
244
244
  return op
245
245
  }
246
- const scheduler = new _scheduler.SyncScheduler()
246
+ const scheduler = new scheduler_.SyncScheduler()
247
247
  const fiberRuntime = unsafeFork(runtime)(effect, { scheduler })
248
248
  scheduler.flush()
249
249
  const result = fiberRuntime.unsafePoll()
@@ -15,7 +15,7 @@ import * as Option from "../Option.js"
15
15
  import { pipeArguments } from "../Pipeable.js"
16
16
  import * as Scope from "../Scope.js"
17
17
  import type * as ScopedCache from "../ScopedCache.js"
18
- import * as _cache from "./cache.js"
18
+ import * as cache_ from "./cache.js"
19
19
  import * as effect from "./core-effect.js"
20
20
  import * as core from "./core.js"
21
21
  import * as fiberRuntime from "./fiberRuntime.js"
@@ -27,8 +27,8 @@ import * as fiberRuntime from "./fiberRuntime.js"
27
27
  */
28
28
  export interface CacheState<in out Key, out Value, out Error = never> {
29
29
  map: MutableHashMap.MutableHashMap<Key, MapValue<Key, Value, Error>> // mutable by design
30
- keys: _cache.KeySet<Key> // mutable by design
31
- accesses: MutableQueue.MutableQueue<_cache.MapKey<Key>> // mutable by design
30
+ keys: cache_.KeySet<Key> // mutable by design
31
+ accesses: MutableQueue.MutableQueue<cache_.MapKey<Key>> // mutable by design
32
32
  updating: MutableRef.MutableRef<boolean> // mutable by design
33
33
  hits: number // mutable by design
34
34
  misses: number // mutable by design
@@ -37,8 +37,8 @@ export interface CacheState<in out Key, out Value, out Error = never> {
37
37
  /** @internal */
38
38
  export const makeCacheState = <Key, Value, Error = never>(
39
39
  map: MutableHashMap.MutableHashMap<Key, MapValue<Key, Value, Error>>,
40
- keys: _cache.KeySet<Key>,
41
- accesses: MutableQueue.MutableQueue<_cache.MapKey<Key>>,
40
+ keys: cache_.KeySet<Key>,
41
+ accesses: MutableQueue.MutableQueue<cache_.MapKey<Key>>,
42
42
  updating: MutableRef.MutableRef<boolean>,
43
43
  hits: number,
44
44
  misses: number
@@ -59,7 +59,7 @@ export const makeCacheState = <Key, Value, Error = never>(
59
59
  export const initialCacheState = <Key, Value, Error = never>(): CacheState<Key, Value, Error> =>
60
60
  makeCacheState(
61
61
  MutableHashMap.empty(),
62
- _cache.makeKeySet(),
62
+ cache_.makeKeySet(),
63
63
  MutableQueue.unbounded(),
64
64
  MutableRef.make(false),
65
65
  0,
@@ -82,7 +82,7 @@ export type MapValue<Key, Value, Error> =
82
82
  /** @internal */
83
83
  export interface Complete<out Key, out Value, out Error> {
84
84
  readonly _tag: "Complete"
85
- readonly key: _cache.MapKey<Key>
85
+ readonly key: cache_.MapKey<Key>
86
86
  readonly exit: Exit.Exit<readonly [Value, Scope.Scope.Finalizer], Error>
87
87
  readonly ownerCount: MutableRef.MutableRef<number>
88
88
  readonly entryStats: Cache.EntryStats
@@ -92,7 +92,7 @@ export interface Complete<out Key, out Value, out Error> {
92
92
  /** @internal */
93
93
  export interface Pending<out Key, out Value, out Error> {
94
94
  readonly _tag: "Pending"
95
- readonly key: _cache.MapKey<Key>
95
+ readonly key: cache_.MapKey<Key>
96
96
  readonly scoped: Effect.Effect<Effect.Effect<Value, Error, Scope.Scope>>
97
97
  }
98
98
 
@@ -105,7 +105,7 @@ export interface Refreshing<out Key, out Value, out Error> {
105
105
 
106
106
  /** @internal */
107
107
  export const complete = <Key, Value, Error = never>(
108
- key: _cache.MapKey<Key>,
108
+ key: cache_.MapKey<Key>,
109
109
  exit: Exit.Exit<readonly [Value, Scope.Scope.Finalizer], Error>,
110
110
  ownerCount: MutableRef.MutableRef<number>,
111
111
  entryStats: Cache.EntryStats,
@@ -122,7 +122,7 @@ export const complete = <Key, Value, Error = never>(
122
122
 
123
123
  /** @internal */
124
124
  export const pending = <Key, Value, Error = never>(
125
- key: _cache.MapKey<Key>,
125
+ key: cache_.MapKey<Key>,
126
126
  scoped: Effect.Effect<Effect.Effect<Value, Error, Scope.Scope>>
127
127
  ): Pending<Key, Value, Error> =>
128
128
  Data.struct({
@@ -206,7 +206,7 @@ class ScopedCacheImpl<in out Key, in out Environment, in out Error, in out Value
206
206
 
207
207
  get cacheStats(): Effect.Effect<Cache.CacheStats> {
208
208
  return core.sync(() =>
209
- _cache.makeCacheStats({
209
+ cache_.makeCacheStats({
210
210
  hits: this.cacheState.hits,
211
211
  misses: this.cacheState.misses,
212
212
  size: MutableHashMap.size(this.cacheState.map)
@@ -245,13 +245,13 @@ class ScopedCacheImpl<in out Key, in out Environment, in out Error, in out Value
245
245
  }
246
246
  switch (value._tag) {
247
247
  case "Complete": {
248
- return Option.some(_cache.makeEntryStats(value.entryStats.loadedMillis))
248
+ return Option.some(cache_.makeEntryStats(value.entryStats.loadedMillis))
249
249
  }
250
250
  case "Pending": {
251
251
  return Option.none()
252
252
  }
253
253
  case "Refreshing": {
254
- return Option.some(_cache.makeEntryStats(value.complete.entryStats.loadedMillis))
254
+ return Option.some(cache_.makeEntryStats(value.complete.entryStats.loadedMillis))
255
255
  }
256
256
  }
257
257
  })
@@ -263,10 +263,10 @@ class ScopedCacheImpl<in out Key, in out Environment, in out Error, in out Value
263
263
  effect.memoize,
264
264
  core.flatMap((lookupValue) =>
265
265
  core.suspend(() => {
266
- let k: _cache.MapKey<Key> | undefined = undefined
266
+ let k: cache_.MapKey<Key> | undefined = undefined
267
267
  let value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, key))
268
268
  if (value === undefined) {
269
- k = _cache.makeMapKey(key)
269
+ k = cache_.makeMapKey(key)
270
270
  if (MutableHashMap.has(this.cacheState.map, key)) {
271
271
  value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, key))
272
272
  } else {
@@ -341,9 +341,9 @@ class ScopedCacheImpl<in out Key, in out Environment, in out Error, in out Value
341
341
  effect.memoize,
342
342
  core.flatMap((scoped) => {
343
343
  let value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, key))
344
- let newKey: _cache.MapKey<Key> | undefined = undefined
344
+ let newKey: cache_.MapKey<Key> | undefined = undefined
345
345
  if (value === undefined) {
346
- newKey = _cache.makeMapKey(key)
346
+ newKey = cache_.makeMapKey(key)
347
347
  if (MutableHashMap.has(this.cacheState.map, key)) {
348
348
  value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, key))
349
349
  } else {
@@ -460,10 +460,10 @@ class ScopedCacheImpl<in out Key, in out Environment, in out Error, in out Value
460
460
  release
461
461
  ])
462
462
  const completedResult = complete<Key, Value, Error>(
463
- _cache.makeMapKey(key),
463
+ cache_.makeMapKey(key),
464
464
  exitWithFinalizer,
465
465
  MutableRef.make(1),
466
- _cache.makeEntryStats(now),
466
+ cache_.makeEntryStats(now),
467
467
  expiredAt
468
468
  )
469
469
  let previousValue: MapValue<Key, Value, Error> | undefined = undefined
@@ -482,10 +482,10 @@ class ScopedCacheImpl<in out Key, in out Environment, in out Error, in out Value
482
482
  }
483
483
  case "Failure": {
484
484
  const completedResult = complete<Key, Value, Error>(
485
- _cache.makeMapKey(key),
485
+ cache_.makeMapKey(key),
486
486
  exit as Exit.Exit<readonly [Value, Scope.Scope.Finalizer], Error>,
487
487
  MutableRef.make(0),
488
- _cache.makeEntryStats(now),
488
+ cache_.makeEntryStats(now),
489
489
  expiredAt
490
490
  )
491
491
  let previousValue: MapValue<Key, Value, Error> | undefined = undefined
@@ -524,7 +524,7 @@ class ScopedCacheImpl<in out Key, in out Environment, in out Error, in out Value
524
524
  this.cacheState.misses = this.cacheState.misses + 1
525
525
  }
526
526
 
527
- trackAccess(key: _cache.MapKey<Key>): Array<MapValue<Key, Value, Error>> {
527
+ trackAccess(key: cache_.MapKey<Key>): Array<MapValue<Key, Value, Error>> {
528
528
  const cleanedKeys: Array<MapValue<Key, Value, Error>> = []
529
529
  MutableQueue.offer(this.cacheState.accesses, key)
530
530
  if (MutableRef.compareAndSet(this.cacheState.updating, false, true)) {
@@ -575,7 +575,7 @@ class ScopedCacheImpl<in out Key, in out Environment, in out Error, in out Value
575
575
  }
576
576
  }
577
577
 
578
- ensureMapSizeNotExceeded(key: _cache.MapKey<Key>): Effect.Effect<void> {
578
+ ensureMapSizeNotExceeded(key: cache_.MapKey<Key>): Effect.Effect<void> {
579
579
  return fiberRuntime.forEachConcurrentDiscard(
580
580
  this.trackAccess(key),
581
581
  (cleanedMapValue) => this.cleanMapValue(cleanedMapValue),