effect 3.11.4 → 3.11.5

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.
package/src/SchemaAST.ts CHANGED
@@ -2072,9 +2072,14 @@ export const isTypeLiteralTransformation: (ast: TransformationKind) => ast is Ty
2072
2072
  *
2073
2073
  * @since 3.10.0
2074
2074
  */
2075
- export const annotations = (ast: AST, annotations: Annotations): AST => {
2075
+ export const annotations = (ast: AST, a: Annotations): AST => {
2076
2076
  const d = Object.getOwnPropertyDescriptors(ast)
2077
- d.annotations.value = { ...ast.annotations, ...annotations }
2077
+ const value = { ...ast.annotations, ...a }
2078
+ const surrogate = getSurrogateAnnotation(ast)
2079
+ if (Option.isSome(surrogate)) {
2080
+ value[SurrogateAnnotationId] = annotations(surrogate.value, a)
2081
+ }
2082
+ d.annotations.value = value
2078
2083
  return Object.create(Object.getPrototypeOf(ast), d)
2079
2084
  }
2080
2085
 
@@ -2679,6 +2684,22 @@ function changeMap<A>(as: ReadonlyArray<A>, f: (a: A) => A): ReadonlyArray<A> {
2679
2684
  return changed ? out : as
2680
2685
  }
2681
2686
 
2687
+ /**
2688
+ * Returns the from part of a transformation if it exists
2689
+ *
2690
+ * @internal
2691
+ */
2692
+ export const getTransformationFrom = (ast: AST): AST | undefined => {
2693
+ switch (ast._tag) {
2694
+ case "Transformation":
2695
+ return ast.from
2696
+ case "Refinement":
2697
+ return getTransformationFrom(ast.from)
2698
+ case "Suspend":
2699
+ return getTransformationFrom(ast.f())
2700
+ }
2701
+ }
2702
+
2682
2703
  const encodedAST_ = (ast: AST, isBound: boolean): AST => {
2683
2704
  switch (ast._tag) {
2684
2705
  case "Declaration": {
@@ -2730,14 +2751,17 @@ const encodedAST_ = (ast: AST, isBound: boolean): AST => {
2730
2751
  if (from === ast.from) {
2731
2752
  return ast
2732
2753
  }
2733
- if (!isTransformation(ast.from) && hasStableFilter(ast)) {
2734
- return new Refinement(from, ast.filter)
2754
+ if (getTransformationFrom(ast.from) === undefined && hasStableFilter(ast)) {
2755
+ return new Refinement(from, ast.filter, ast.annotations)
2735
2756
  }
2736
2757
  }
2737
- return from
2758
+ const identifier = createJSONIdentifierAnnotation(ast)
2759
+ return identifier ? annotations(from, identifier) : from
2760
+ }
2761
+ case "Transformation": {
2762
+ const identifier = createJSONIdentifierAnnotation(ast)
2763
+ return encodedAST_(identifier ? annotations(ast.from, identifier) : ast.from, isBound)
2738
2764
  }
2739
- case "Transformation":
2740
- return encodedAST_(ast.from, isBound)
2741
2765
  }
2742
2766
  return ast
2743
2767
  }
@@ -536,8 +536,7 @@ export const asyncInterrupt = <A, E = never, R = never>(
536
536
  blockingOn: FiberId.FiberId = FiberId.none
537
537
  ): Effect.Effect<A, E, R> => suspend(() => unsafeAsync(register, blockingOn))
538
538
 
539
- /* @internal */
540
- export const async = <A, E = never, R = never>(
539
+ const async_ = <A, E = never, R = never>(
541
540
  resume: (
542
541
  callback: (_: Effect.Effect<A, E, R>) => void,
543
542
  signal: AbortSignal
@@ -580,6 +579,10 @@ export const async = <A, E = never, R = never>(
580
579
  effect
581
580
  })
582
581
  }
582
+ export {
583
+ /** @internal */
584
+ async_ as async
585
+ }
583
586
 
584
587
  /* @internal */
585
588
  export const catchAllCause = dual<
@@ -820,7 +823,7 @@ export const andThen: {
820
823
  if (isEffect(b)) {
821
824
  return b
822
825
  } else if (isPromiseLike(b)) {
823
- return async<any, Cause.UnknownException>((resume) => {
826
+ return unsafeAsync<any, Cause.UnknownException>((resume) => {
824
827
  b.then((a) => resume(succeed(a)), (e) => resume(fail(new UnknownException(e))))
825
828
  })
826
829
  }
@@ -1304,7 +1307,7 @@ export const tap = dual<
1304
1307
  if (isEffect(b)) {
1305
1308
  return as(b, a)
1306
1309
  } else if (isPromiseLike(b)) {
1307
- return async<any, Cause.UnknownException>((resume) => {
1310
+ return unsafeAsync<any, Cause.UnknownException>((resume) => {
1308
1311
  b.then((_) => resume(succeed(a)), (e) => resume(fail(new UnknownException(e))))
1309
1312
  })
1310
1313
  }
@@ -1567,7 +1570,7 @@ export const zipWith: {
1567
1570
  ): Effect.Effect<B, E | E2, R | R2> => flatMap(self, (a) => map(that, (b) => f(a, b))))
1568
1571
 
1569
1572
  /* @internal */
1570
- export const never: Effect.Effect<never> = async<never>(() => {
1573
+ export const never: Effect.Effect<never> = asyncInterrupt<never>(() => {
1571
1574
  const interval = setInterval(() => {
1572
1575
  //
1573
1576
  }, 2 ** 31 - 1)
@@ -2842,7 +2845,7 @@ export const deferredMakeAs = <A, E = never>(fiberId: FiberId.FiberId): Effect.E
2842
2845
 
2843
2846
  /* @internal */
2844
2847
  export const deferredAwait = <A, E>(self: Deferred.Deferred<A, E>): Effect.Effect<A, E> =>
2845
- async<A, E>((resume) => {
2848
+ asyncInterrupt<A, E>((resume) => {
2846
2849
  const state = MutableRef.get(self.state)
2847
2850
  switch (state._tag) {
2848
2851
  case DeferredOpCodes.OP_STATE_DONE: {
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.11.4"
1
+ let moduleVersion = "3.11.5"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4