effect 4.1.5 → 4.1.6
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/ai-docs/package.json +2 -2
- package/dist/Channel.d.ts +104 -7
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +73 -4
- package/dist/Channel.js.map +1 -1
- package/dist/Codegen.d.ts +7 -2
- package/dist/Codegen.d.ts.map +1 -1
- package/dist/Codegen.js +7 -2
- package/dist/Codegen.js.map +1 -1
- package/dist/Effect.d.ts +139 -18
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +10 -2
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts +4 -4
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +78 -65
- package/dist/Equal.js.map +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +24 -17
- package/dist/Hash.js.map +1 -1
- package/dist/LayerRef.d.ts +1 -1
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +3 -3
- package/dist/LayerRef.js.map +1 -1
- package/dist/Logger.d.ts +37 -13
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +39 -10
- package/dist/Logger.js.map +1 -1
- package/dist/Match.d.ts +23 -23
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js.map +1 -1
- package/dist/Order.js +1 -1
- package/dist/Order.js.map +1 -1
- package/dist/Schema.d.ts +41 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +51 -390
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +0 -3
- package/dist/SchemaAST.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +6 -4
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Stream.d.ts +128 -5
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +124 -29
- package/dist/Stream.js.map +1 -1
- package/dist/String.js +1 -1
- package/dist/String.js.map +1 -1
- package/dist/Tracer.d.ts +10 -0
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -0
- package/dist/Tracer.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +88 -88
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpServer.d.ts +152 -2
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +8 -2
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +3 -1
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +17 -3
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Skill.d.ts +172 -0
- package/dist/ai/Skill.d.ts.map +1 -0
- package/dist/ai/Skill.js +209 -0
- package/dist/ai/Skill.js.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +155 -83
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +56 -0
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +18 -2
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +45 -22
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/internal/entityActivation.js +2 -0
- package/dist/cluster/internal/entityActivation.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +8 -5
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/encoding/Base64.js +5 -1
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +6 -1
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Xml.d.ts +38 -9
- package/dist/encoding/Xml.d.ts.map +1 -1
- package/dist/encoding/Xml.js +63 -31
- package/dist/encoding/Xml.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +2 -1
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +14 -10
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/Headers.d.ts +201 -3
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +205 -3
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +11 -7
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +1 -0
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +32 -9
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +46 -0
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +15 -0
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpClientResponse.d.ts +132 -0
- package/dist/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/http/HttpClientResponse.js +83 -0
- package/dist/http/HttpClientResponse.js.map +1 -1
- package/dist/http/HttpMiddleware.js +1 -1
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts +118 -0
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +43 -0
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/Multipart.d.ts.map +1 -1
- package/dist/http/Multipart.js +0 -5
- package/dist/http/Multipart.js.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.d.ts +6 -0
- package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.js +1 -1
- package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
- package/dist/http/internal/clientPath.d.ts +2 -0
- package/dist/http/internal/clientPath.d.ts.map +1 -0
- package/dist/http/internal/clientPath.js +24 -0
- package/dist/http/internal/clientPath.js.map +1 -0
- package/dist/http/internal/redactedPath.js +2 -0
- package/dist/http/internal/redactedPath.js.map +1 -1
- package/dist/http/internal/tracing.js +5 -3
- package/dist/http/internal/tracing.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +2 -2
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +30 -7
- package/dist/http-api/HttpApi.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +5 -2
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +23 -6
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/internal/redactedKeys.d.ts +2 -0
- package/dist/http-api/internal/redactedKeys.d.ts.map +1 -0
- package/dist/http-api/internal/redactedKeys.js +37 -0
- package/dist/http-api/internal/redactedKeys.js.map +1 -0
- package/dist/internal/base64.js +34 -2
- package/dist/internal/base64.js.map +1 -1
- package/dist/internal/dateTime.js +35 -17
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +9 -1
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +14 -13
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/hash.js +4 -1
- package/dist/internal/hash.js.map +1 -1
- package/dist/internal/matcher.js +17 -17
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/schema/schemaCodegen.js +3 -2
- package/dist/internal/schema/schemaCodegen.js.map +1 -1
- package/dist/internal/schema/schemaCodegenBuiltIns.d.ts +2 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.d.ts.map +1 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.js +425 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.js.map +1 -0
- package/dist/internal/schema/toEquivalence.js +3 -4
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/jose/JoseError.d.ts +51 -1
- package/dist/jose/JoseError.d.ts.map +1 -1
- package/dist/jose/JoseError.js +25 -18
- package/dist/jose/JoseError.js.map +1 -1
- package/dist/jose/internal/compact.js +10 -5
- package/dist/jose/internal/compact.js.map +1 -1
- package/dist/observability/Otlp.d.ts +19 -0
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +10 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +49 -13
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +135 -54
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts +14 -0
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +10 -2
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +2 -0
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts +14 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +10 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/persistence/KeyValueStore.js +6 -4
- package/dist/persistence/KeyValueStore.js.map +1 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +10 -9
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +32 -1
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcGroup.d.ts +1 -1
- package/dist/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/rpc/RpcGroup.js +4 -0
- package/dist/rpc/RpcGroup.js.map +1 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +2 -5
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +5 -1
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/workflow/Activity.d.ts +18 -0
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow/Activity.js +13 -4
- package/dist/workflow/Activity.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +10 -9
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +33 -22
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +26 -12
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/dist/workflow/internal/retry.d.ts +2 -0
- package/dist/workflow/internal/retry.d.ts.map +1 -0
- package/dist/workflow/internal/retry.js +11 -0
- package/dist/workflow/internal/retry.js.map +1 -0
- package/dist/workflow/internal/scope.d.ts +2 -0
- package/dist/workflow/internal/scope.d.ts.map +1 -0
- package/dist/workflow/internal/scope.js +26 -0
- package/dist/workflow/internal/scope.js.map +1 -0
- package/package.json +3 -3
- package/src/Channel.ts +105 -8
- package/src/Codegen.ts +7 -2
- package/src/Effect.ts +224 -48
- package/src/Equal.ts +85 -79
- package/src/Hash.ts +30 -22
- package/src/LayerRef.ts +6 -4
- package/src/Logger.ts +68 -25
- package/src/Match.ts +78 -50
- package/src/Order.ts +1 -1
- package/src/Schema.ts +79 -296
- package/src/SchemaAST.ts +0 -1
- package/src/ScopedCache.ts +6 -4
- package/src/Stream.ts +167 -33
- package/src/String.ts +1 -1
- package/src/Tracer.ts +10 -0
- package/src/ai/McpServer.ts +161 -4
- package/src/ai/Prompt.ts +20 -3
- package/src/ai/Skill.ts +236 -0
- package/src/ai/index.ts +6 -0
- package/src/cluster/ClusterWorkflowEngine.ts +172 -96
- package/src/cluster/MessageStorage.ts +51 -2
- package/src/cluster/SqlMessageStorage.ts +81 -34
- package/src/cluster/internal/entityActivation.ts +6 -0
- package/src/cluster/internal/entityManager.ts +8 -4
- package/src/encoding/Base64.ts +5 -1
- package/src/encoding/Base64Url.ts +6 -1
- package/src/encoding/Xml.ts +96 -26
- package/src/http/FetchHttpClient.ts +8 -5
- package/src/http/Headers.ts +309 -3
- package/src/http/HttpClient.ts +19 -7
- package/src/http/HttpClientError.ts +42 -9
- package/src/http/HttpClientRequest.ts +51 -0
- package/src/http/HttpClientResponse.ts +156 -0
- package/src/http/HttpMiddleware.ts +1 -1
- package/src/http/HttpServerResponse.ts +126 -0
- package/src/http/Multipart.ts +0 -5
- package/src/http/MultipartParser/internal/contentType.ts +1 -1
- package/src/http/internal/clientPath.ts +39 -0
- package/src/http/internal/redactedPath.ts +4 -0
- package/src/http/internal/tracing.ts +6 -3
- package/src/http-api/HttpApi.ts +29 -8
- package/src/http-api/HttpApiBuilder.ts +7 -2
- package/src/http-api/HttpApiClient.ts +30 -7
- package/src/http-api/internal/redactedKeys.ts +40 -0
- package/src/internal/base64.ts +57 -2
- package/src/internal/dateTime.ts +43 -24
- package/src/internal/effect.ts +31 -102
- package/src/internal/equal.ts +37 -17
- package/src/internal/hash.ts +5 -1
- package/src/internal/matcher.ts +34 -113
- package/src/internal/schema/schemaCodegen.ts +5 -4
- package/src/internal/schema/schemaCodegenBuiltIns.ts +343 -0
- package/src/internal/schema/toEquivalence.ts +3 -5
- package/src/internal/version.ts +1 -1
- package/src/jose/JoseError.ts +34 -0
- package/src/jose/internal/compact.ts +14 -5
- package/src/observability/Otlp.ts +29 -0
- package/src/observability/OtlpExporter.ts +206 -75
- package/src/observability/OtlpLogger.ts +24 -2
- package/src/observability/OtlpMetrics.ts +2 -0
- package/src/observability/OtlpTracer.ts +24 -3
- package/src/persistence/KeyValueStore.ts +17 -14
- package/src/reactivity/Atom.ts +12 -18
- package/src/rpc/RpcClient.ts +26 -1
- package/src/rpc/RpcGroup.ts +4 -1
- package/src/sql/Migrator.ts +2 -11
- package/src/sql/SqlClient.ts +14 -8
- package/src/workflow/Activity.ts +28 -4
- package/src/workflow/Workflow.ts +68 -44
- package/src/workflow/WorkflowEngine.ts +38 -15
- package/src/workflow/internal/retry.ts +12 -0
- package/src/workflow/internal/scope.ts +36 -0
package/src/internal/base64.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface NativeDecodeOptions {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Decodes `str` with native `Uint8Array.fromBase64`.
|
|
7
|
+
* Decodes `str` with native `Uint8Array.fromBase64`, falling back to `Buffer`.
|
|
8
8
|
*
|
|
9
9
|
* Returns `undefined` when native decoding is unavailable or skipped for a
|
|
10
10
|
* short input, and `null` when native decoding rejected the input. In both
|
|
@@ -28,7 +28,17 @@ export const decodeNative = (
|
|
|
28
28
|
const NativeUint8Array = Uint8Array as {
|
|
29
29
|
readonly fromBase64?: (string: string, options?: NativeDecodeOptions) => Uint8Array
|
|
30
30
|
}
|
|
31
|
-
if (typeof NativeUint8Array.fromBase64 !== "function")
|
|
31
|
+
if (typeof NativeUint8Array.fromBase64 !== "function") {
|
|
32
|
+
const Buffer = getBuffer()
|
|
33
|
+
if (Buffer === undefined) return undefined
|
|
34
|
+
const encoding = options?.alphabet ?? "base64"
|
|
35
|
+
const bytes = new Uint8Array(decodedLength)
|
|
36
|
+
const buffer = Buffer.from(bytes.buffer)
|
|
37
|
+
// `Buffer` is permissive (skips invalid chars, mixes alphabets, truncates
|
|
38
|
+
// code units), so accept only input that round-trips identically.
|
|
39
|
+
const canonical = options !== undefined && str.endsWith("=") ? str.slice(0, str.indexOf("=")) : str
|
|
40
|
+
return buffer.write(str, encoding) === decodedLength && buffer.toString(encoding) === canonical ? bytes : null
|
|
41
|
+
}
|
|
32
42
|
try {
|
|
33
43
|
const bytes = NativeUint8Array.fromBase64(str, options)
|
|
34
44
|
return bytes.length === decodedLength ? bytes : null
|
|
@@ -37,6 +47,51 @@ export const decodeNative = (
|
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
49
|
|
|
50
|
+
interface BufferLike {
|
|
51
|
+
write(string: string, encoding: string): number
|
|
52
|
+
toString(encoding: string): string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface BufferConstructorLike {
|
|
56
|
+
from(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BufferLike
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const typedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype)
|
|
60
|
+
const typedArrayBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer")!.get as (
|
|
61
|
+
this: Uint8Array
|
|
62
|
+
) => ArrayBufferLike
|
|
63
|
+
const typedArrayByteOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset")!.get as (
|
|
64
|
+
this: Uint8Array
|
|
65
|
+
) => number
|
|
66
|
+
const typedArrayByteLength = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteLength")!.get as (
|
|
67
|
+
this: Uint8Array
|
|
68
|
+
) => number
|
|
69
|
+
|
|
70
|
+
// Gate on `process.versions.node` to avoid slow browser/RN `Buffer` polyfills;
|
|
71
|
+
// read at call time without importing `node:buffer`.
|
|
72
|
+
const getBuffer = (): BufferConstructorLike | undefined => {
|
|
73
|
+
const global = globalThis as {
|
|
74
|
+
readonly Buffer?: BufferConstructorLike
|
|
75
|
+
readonly process?: { readonly versions?: { readonly node?: unknown } }
|
|
76
|
+
}
|
|
77
|
+
return typeof global.process?.versions?.node === "string" && typeof global.Buffer === "function"
|
|
78
|
+
? global.Buffer
|
|
79
|
+
: undefined
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Encodes `bytes` with `Buffer` ("base64" padded, "base64url" unpadded), or returns `undefined` if unavailable.
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export const encodeBuffer = (bytes: Uint8Array, encoding: "base64" | "base64url"): string | undefined => {
|
|
88
|
+
const Buffer = getBuffer()
|
|
89
|
+
if (Buffer === undefined) return undefined
|
|
90
|
+
const byteLength = typedArrayByteLength.call(bytes)
|
|
91
|
+
if (byteLength < 32) return undefined
|
|
92
|
+
return Buffer.from(typedArrayBuffer.call(bytes), typedArrayByteOffset.call(bytes), byteLength).toString(encoding)
|
|
93
|
+
}
|
|
94
|
+
|
|
40
95
|
/** @internal */
|
|
41
96
|
export const stripCrlf = (str: string): string =>
|
|
42
97
|
str.indexOf("\n") === -1 && str.indexOf("\r") === -1 ? str : str.replace(/[\n\r]/g, "")
|
package/src/internal/dateTime.ts
CHANGED
|
@@ -334,14 +334,22 @@ export const makeZonedUnsafe = (input: DateTime.DateTime.Input, options?: {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
/** @internal */
|
|
337
|
-
export const makeZoned
|
|
337
|
+
export const makeZoned = (
|
|
338
338
|
input: DateTime.DateTime.Input,
|
|
339
339
|
options?: {
|
|
340
340
|
readonly timeZone?: number | string | DateTime.TimeZone | undefined
|
|
341
341
|
readonly adjustForTimeZone?: boolean | undefined
|
|
342
342
|
readonly disambiguation?: DateTime.Disambiguation | undefined
|
|
343
343
|
}
|
|
344
|
-
)
|
|
344
|
+
): Option.Option<DateTime.Zoned> => {
|
|
345
|
+
// Do not pass `makeZonedUnsafe` to a top-level call such as `Option.liftThrowable`,
|
|
346
|
+
// or AOT compilers that prune per function treat `Intl` as reachable whenever this module loads.
|
|
347
|
+
try {
|
|
348
|
+
return Option.some(makeZonedUnsafe(input, options))
|
|
349
|
+
} catch {
|
|
350
|
+
return Option.none()
|
|
351
|
+
}
|
|
352
|
+
}
|
|
345
353
|
|
|
346
354
|
/** @internal */
|
|
347
355
|
export const make: <A extends DateTime.DateTime.Input>(input: A) => Option.Option<DateTime.DateTime.PreserveZone<A>> =
|
|
@@ -475,9 +483,14 @@ export const zoneMakeOffset = (offset: number): DateTime.TimeZone.Offset => {
|
|
|
475
483
|
}
|
|
476
484
|
|
|
477
485
|
/** @internal */
|
|
478
|
-
export const zoneMakeNamed
|
|
479
|
-
|
|
480
|
-
|
|
486
|
+
export const zoneMakeNamed = (zoneId: string): Option.Option<DateTime.TimeZone.Named> => {
|
|
487
|
+
// Plain function for the same reason as `makeZoned`.
|
|
488
|
+
try {
|
|
489
|
+
return Option.some(zoneMakeNamedUnsafe(zoneId))
|
|
490
|
+
} catch {
|
|
491
|
+
return Option.none()
|
|
492
|
+
}
|
|
493
|
+
}
|
|
481
494
|
|
|
482
495
|
/** @internal */
|
|
483
496
|
export const zoneMakeNamedEffect = (zoneId: string): Effect.Effect<DateTime.TimeZone.Named, IllegalArgumentError> =>
|
|
@@ -778,7 +791,7 @@ export const setParts: {
|
|
|
778
791
|
} = dual(
|
|
779
792
|
2,
|
|
780
793
|
(self: DateTime.DateTime, parts: Partial<DateTime.DateTime.PartsWithWeekday>): DateTime.DateTime =>
|
|
781
|
-
|
|
794
|
+
mutateWithOffset(self, (date) => setPartsDate(date, parts))
|
|
782
795
|
)
|
|
783
796
|
|
|
784
797
|
/** @internal */
|
|
@@ -937,6 +950,25 @@ export const mutate: {
|
|
|
937
950
|
return makeZonedFromAdjusted(newAdjustedDate.getTime(), self.zone, options?.disambiguation ?? "compatible")
|
|
938
951
|
})
|
|
939
952
|
|
|
953
|
+
// Keep the input offset when valid for the updated wall-clock time so repeated hours stay in the same occurrence.
|
|
954
|
+
const mutateWithOffset = (
|
|
955
|
+
self: DateTime.DateTime,
|
|
956
|
+
f: (date: Date) => void,
|
|
957
|
+
disambiguation: DateTime.Disambiguation = "compatible"
|
|
958
|
+
): DateTime.DateTime => {
|
|
959
|
+
if (self._tag === "Utc" || self.zone._tag === "Offset") {
|
|
960
|
+
return mutate(self, f, { disambiguation })
|
|
961
|
+
}
|
|
962
|
+
const date = toDate(self)
|
|
963
|
+
const offset = date.getTime() - Math.trunc(self.epochMilliseconds)
|
|
964
|
+
f(date)
|
|
965
|
+
const adjustedMillis = date.getTime()
|
|
966
|
+
const result = makeZonedProto(adjustedMillis - offset, self.zone)
|
|
967
|
+
return zonedOffset(result) === offset
|
|
968
|
+
? result
|
|
969
|
+
: makeZonedFromAdjusted(adjustedMillis, self.zone, disambiguation)
|
|
970
|
+
}
|
|
971
|
+
|
|
940
972
|
/** @internal */
|
|
941
973
|
export const mutateUtc: {
|
|
942
974
|
(f: (date: Date) => void): <A extends DateTime.DateTime>(self: A) => A
|
|
@@ -1089,24 +1121,11 @@ const mutateRounding = (
|
|
|
1089
1121
|
self: DateTime.DateTime,
|
|
1090
1122
|
part: DateTime.DateTime.UnitSingular,
|
|
1091
1123
|
f: (date: Date) => void,
|
|
1092
|
-
disambiguation
|
|
1093
|
-
): DateTime.DateTime =>
|
|
1094
|
-
|
|
1095
|
-
self
|
|
1096
|
-
|
|
1097
|
-
) {
|
|
1098
|
-
return mutate(self, f, { disambiguation })
|
|
1099
|
-
}
|
|
1100
|
-
// keep the input's offset so rounding stays in the same occurrence of a repeated hour
|
|
1101
|
-
const date = toDate(self)
|
|
1102
|
-
const offset = date.getTime() - Math.trunc(self.epochMilliseconds)
|
|
1103
|
-
f(date)
|
|
1104
|
-
const adjustedMillis = date.getTime()
|
|
1105
|
-
const result = makeZonedProto(adjustedMillis - offset, self.zone)
|
|
1106
|
-
return zonedOffset(result) === offset
|
|
1107
|
-
? result
|
|
1108
|
-
: makeZonedFromAdjusted(adjustedMillis, self.zone, disambiguation)
|
|
1109
|
-
}
|
|
1124
|
+
disambiguation?: DateTime.Disambiguation
|
|
1125
|
+
): DateTime.DateTime =>
|
|
1126
|
+
part === "day" || part === "week" || part === "month" || part === "year"
|
|
1127
|
+
? mutate(self, f, { disambiguation })
|
|
1128
|
+
: mutateWithOffset(self, f, disambiguation)
|
|
1110
1129
|
|
|
1111
1130
|
const startOfDate = (date: Date, part: DateTime.DateTime.UnitSingular, options?: {
|
|
1112
1131
|
readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined
|
package/src/internal/effect.ts
CHANGED
|
@@ -3319,108 +3319,29 @@ export const catchReason: {
|
|
|
3319
3319
|
)
|
|
3320
3320
|
|
|
3321
3321
|
/** @internal */
|
|
3322
|
-
export const catchReasons:
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
3342
|
-
) => Effect.Effect<A2, E2, R2>)
|
|
3343
|
-
| undefined
|
|
3344
|
-
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<
|
|
3345
|
-
| A
|
|
3346
|
-
| Exclude<A2, unassigned>
|
|
3347
|
-
| { [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect.Effect<infer A, any, any> ? A : never }[
|
|
3348
|
-
keyof Cases
|
|
3349
|
-
],
|
|
3350
|
-
| ExcludeTag<E, K>
|
|
3351
|
-
| E2
|
|
3352
|
-
| (A2 extends unassigned ? ExtractTag<E, K> : never)
|
|
3353
|
-
| { [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect.Effect<any, infer E, any> ? E : never }[
|
|
3354
|
-
keyof Cases
|
|
3355
|
-
],
|
|
3356
|
-
| R
|
|
3357
|
-
| R2
|
|
3358
|
-
| { [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect.Effect<any, any, infer R> ? R : never }[
|
|
3359
|
-
keyof Cases
|
|
3360
|
-
]
|
|
3361
|
-
>
|
|
3362
|
-
<
|
|
3363
|
-
A,
|
|
3364
|
-
E,
|
|
3365
|
-
R,
|
|
3366
|
-
K extends Tags<E>,
|
|
3367
|
-
Cases extends {
|
|
3368
|
-
[RK in ReasonTags<ExtractTag<E, K>>]+?: (
|
|
3369
|
-
reason: ExtractReason<ExtractTag<E, K>, RK>,
|
|
3370
|
-
error: NarrowReason<ExtractTag<E, K>, RK>
|
|
3371
|
-
) => Effect.Effect<any, any, any>
|
|
3372
|
-
},
|
|
3373
|
-
A2 = unassigned,
|
|
3374
|
-
E2 = never,
|
|
3375
|
-
R2 = never
|
|
3376
|
-
>(
|
|
3377
|
-
self: Effect.Effect<A, E, R>,
|
|
3378
|
-
errorTag: K,
|
|
3379
|
-
cases: Cases,
|
|
3380
|
-
orElse?:
|
|
3381
|
-
| ((
|
|
3382
|
-
reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>,
|
|
3383
|
-
error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>
|
|
3384
|
-
) => Effect.Effect<A2, E2, R2>)
|
|
3385
|
-
| undefined
|
|
3386
|
-
): Effect.Effect<
|
|
3387
|
-
| A
|
|
3388
|
-
| Exclude<A2, unassigned>
|
|
3389
|
-
| { [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect.Effect<infer A, any, any> ? A : never }[
|
|
3390
|
-
keyof Cases
|
|
3391
|
-
],
|
|
3392
|
-
| ExcludeTag<E, K>
|
|
3393
|
-
| E2
|
|
3394
|
-
| (A2 extends unassigned ? ExtractTag<E, K> : never)
|
|
3395
|
-
| { [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect.Effect<any, infer E, any> ? E : never }[
|
|
3396
|
-
keyof Cases
|
|
3397
|
-
],
|
|
3398
|
-
| R
|
|
3399
|
-
| R2
|
|
3400
|
-
| { [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect.Effect<any, any, infer R> ? R : never }[
|
|
3401
|
-
keyof Cases
|
|
3402
|
-
]
|
|
3403
|
-
>
|
|
3404
|
-
} = dual((args) => isEffect(args[0]), (self, errorTag, cases, orElse) => {
|
|
3405
|
-
let keys: Array<string>
|
|
3406
|
-
return catchIf(
|
|
3407
|
-
self,
|
|
3408
|
-
((e: any) =>
|
|
3409
|
-
isTagged(e, errorTag) &&
|
|
3410
|
-
hasProperty(e, "reason") &&
|
|
3411
|
-
hasProperty(e.reason, "_tag") &&
|
|
3412
|
-
isString(e.reason._tag) &&
|
|
3413
|
-
(orElse !== undefined || (keys ??= Object.keys(cases)).includes(e.reason._tag))) as any,
|
|
3414
|
-
(e: any) => {
|
|
3415
|
-
const reason = e.reason
|
|
3416
|
-
keys ??= Object.keys(cases)
|
|
3417
|
-
if (keys.includes(reason._tag)) {
|
|
3418
|
-
return (cases as any)[reason._tag](reason, e)
|
|
3322
|
+
export const catchReasons: typeof Effect.catchReasons = dual(
|
|
3323
|
+
(args) => isEffect(args[0]),
|
|
3324
|
+
(self, errorTag, cases, orElse) => {
|
|
3325
|
+
let keys: Array<string>
|
|
3326
|
+
return catchIf(
|
|
3327
|
+
self,
|
|
3328
|
+
((e: any) =>
|
|
3329
|
+
isTagged(e, errorTag) &&
|
|
3330
|
+
hasProperty(e, "reason") &&
|
|
3331
|
+
hasProperty(e.reason, "_tag") &&
|
|
3332
|
+
isString(e.reason._tag) &&
|
|
3333
|
+
(orElse !== undefined || (keys ??= Object.keys(cases)).includes(e.reason._tag))) as any,
|
|
3334
|
+
(e: any) => {
|
|
3335
|
+
const reason = e.reason
|
|
3336
|
+
keys ??= Object.keys(cases)
|
|
3337
|
+
if (keys.includes(reason._tag)) {
|
|
3338
|
+
return (cases as any)[reason._tag](reason, e)
|
|
3339
|
+
}
|
|
3340
|
+
return orElse ? orElse(reason, e) : fail(e)
|
|
3419
3341
|
}
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
})
|
|
3342
|
+
)
|
|
3343
|
+
}
|
|
3344
|
+
)
|
|
3424
3345
|
|
|
3425
3346
|
/** @internal */
|
|
3426
3347
|
export const unwrapReason: {
|
|
@@ -5645,7 +5566,15 @@ export const forkUnsafe = <FA, FE, A, E, R>(
|
|
|
5645
5566
|
} else {
|
|
5646
5567
|
// Preserve the fork context rather than the dispatcher's context.
|
|
5647
5568
|
child._asyncContext = captureAsyncContext()
|
|
5648
|
-
|
|
5569
|
+
// Cancel the deferred start if an interrupt runs first.
|
|
5570
|
+
let resumed = false
|
|
5571
|
+
child.yieldWith(() => {
|
|
5572
|
+
resumed = true
|
|
5573
|
+
})
|
|
5574
|
+
parentRuntime.currentDispatcher.scheduleTask(() => {
|
|
5575
|
+
if (resumed) return
|
|
5576
|
+
child.evaluate(effect as any)
|
|
5577
|
+
}, 0)
|
|
5649
5578
|
}
|
|
5650
5579
|
return child
|
|
5651
5580
|
}
|
package/src/internal/equal.ts
CHANGED
|
@@ -3,10 +3,18 @@
|
|
|
3
3
|
// created, not what it is.
|
|
4
4
|
const errorSiteKeys = ["line", "column", "sourceURL", "originalLine", "originalColumn"]
|
|
5
5
|
|
|
6
|
+
const ownKeys = (obj: object): Array<PropertyKey> => {
|
|
7
|
+
const names = Object.getOwnPropertyNames(obj)
|
|
8
|
+
const syms = Object.getOwnPropertySymbols(obj)
|
|
9
|
+
return syms.length > 0 ? [...names, ...syms] : names
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
/** @internal */
|
|
7
|
-
export const getAllObjectKeys = (obj: object): Set<PropertyKey> => {
|
|
8
|
-
const
|
|
9
|
-
|
|
13
|
+
export const getAllObjectKeys = (obj: object): Array<PropertyKey> | Set<PropertyKey> => {
|
|
14
|
+
const own = ownKeys(obj)
|
|
15
|
+
const proto = Object.getPrototypeOf(obj)
|
|
16
|
+
if (proto === Object.prototype || proto === null) return own
|
|
17
|
+
const keys = new Set<PropertyKey>(own)
|
|
10
18
|
|
|
11
19
|
if (obj instanceof Error) {
|
|
12
20
|
keys.delete("stack")
|
|
@@ -15,17 +23,12 @@ export const getAllObjectKeys = (obj: object): Set<PropertyKey> => {
|
|
|
15
23
|
}
|
|
16
24
|
}
|
|
17
25
|
|
|
18
|
-
const proto = Object.getPrototypeOf(obj)
|
|
19
26
|
let current = proto
|
|
20
|
-
|
|
21
27
|
while (current !== null && current !== Object.prototype) {
|
|
22
|
-
const
|
|
23
|
-
for (let i = 0; i < ownKeys.length; i++) {
|
|
24
|
-
keys.add(ownKeys[i])
|
|
25
|
-
}
|
|
28
|
+
for (const key of ownKeys(current)) keys.add(key)
|
|
26
29
|
current = Object.getPrototypeOf(current)
|
|
27
30
|
}
|
|
28
|
-
if (
|
|
31
|
+
if (typeof obj.constructor === "function" && proto === obj.constructor.prototype) {
|
|
29
32
|
keys.delete("constructor")
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -36,20 +39,37 @@ export const getAllObjectKeys = (obj: object): Set<PropertyKey> => {
|
|
|
36
39
|
export const byReferenceInstances = new WeakSet<object>()
|
|
37
40
|
|
|
38
41
|
/** @internal */
|
|
39
|
-
export const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
export const objectKind = (u: object): number =>
|
|
43
|
+
Array.isArray(u) ?
|
|
44
|
+
5 :
|
|
45
|
+
ArrayBuffer.isView(u) ?
|
|
46
|
+
(u instanceof DataView ? 7 : 6) :
|
|
47
|
+
Object.getPrototypeOf(u) === Object.prototype ?
|
|
48
|
+
0 :
|
|
49
|
+
u instanceof Date ?
|
|
50
|
+
1 :
|
|
51
|
+
u instanceof RegExp ?
|
|
52
|
+
2 :
|
|
53
|
+
u instanceof Map ?
|
|
54
|
+
3 :
|
|
55
|
+
u instanceof Set ?
|
|
56
|
+
4 :
|
|
57
|
+
u instanceof ArrayBuffer ?
|
|
58
|
+
8 :
|
|
59
|
+
typeof SharedArrayBuffer !== "undefined" && u instanceof SharedArrayBuffer ?
|
|
60
|
+
9 :
|
|
61
|
+
0
|
|
44
62
|
|
|
45
63
|
/**
|
|
46
64
|
* Returns `undefined` for detached buffers, which can no longer be read.
|
|
47
65
|
*
|
|
48
66
|
* @internal
|
|
49
67
|
*/
|
|
50
|
-
export const
|
|
68
|
+
export const toBytes = (u: ArrayBufferLike | DataView, kind: number): Uint8Array | undefined => {
|
|
51
69
|
try {
|
|
52
|
-
return
|
|
70
|
+
return kind === 7 ?
|
|
71
|
+
new Uint8Array((u as DataView).buffer, (u as DataView).byteOffset, (u as DataView).byteLength) :
|
|
72
|
+
new Uint8Array(u as ArrayBufferLike)
|
|
53
73
|
} catch {
|
|
54
74
|
return undefined
|
|
55
75
|
}
|
package/src/internal/hash.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Back-edge count used to avoid caching entry-point-dependent hashes
|
|
2
|
+
* Back-edge count used to avoid caching entry-point-dependent hashes and
|
|
3
|
+
* comparisons.
|
|
3
4
|
*
|
|
4
5
|
* @internal
|
|
5
6
|
*/
|
|
@@ -9,3 +10,6 @@ export let backEdges = 0
|
|
|
9
10
|
export const addBackEdge = (): void => {
|
|
10
11
|
backEdges++
|
|
11
12
|
}
|
|
13
|
+
|
|
14
|
+
/** @internal */
|
|
15
|
+
export const hashCache = new WeakMap<object, number>()
|