Skip to content

Commit 40ea562

Browse files
committed
feat: deno platform
1 parent b85c386 commit 40ea562

31 files changed

+1184
-35
lines changed

.vscode/settings.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
"typescript.enablePromptUseWorkspaceTsdk": true,
66
"editor.formatOnSave": true,
77
"editor.defaultFormatter": "dprint.dprint",
8+
"[markdown]": {
9+
"editor.defaultFormatter": "dprint.dprint"
10+
},
11+
"[javascript]": {
12+
"editor.defaultFormatter": "dprint.dprint"
13+
},
14+
"[javascriptreact]": {
15+
"editor.defaultFormatter": "dprint.dprint"
16+
},
17+
"[typescript]": {
18+
"editor.defaultFormatter": "dprint.dprint"
19+
},
20+
"[typescriptreact]": {
21+
"editor.defaultFormatter": "dprint.dprint"
22+
},
823
"editor.formatOnSaveMode": "file",
924
"editor.codeActionsOnSave": {
1025
"source.fixAll.oxc": "explicit"
@@ -23,5 +38,7 @@
2338
"editor.suggestSelection": "recentlyUsed",
2439
"editor.wordBasedSuggestions": "matchingDocuments",
2540
"editor.parameterHints.enabled": true,
26-
"files.insertFinalNewline": true
41+
"files.insertFinalNewline": true,
42+
"deno.enable": true,
43+
"deno.lint": false
2744
}

deno.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/denoland/deno/refs/heads/main/cli/schemas/config-file.v1.json",
33
"nodeModulesDir": "manual",
4-
"unstable": ["bare-node-builtins", "node-globals"],
5-
"workspace": ["./packages/*"],
4+
"unstable": [
5+
"bare-node-builtins",
6+
"node-globals"
7+
],
8+
"workspace": [
9+
"scratchpad",
10+
"scripts",
11+
"packages/*",
12+
"packages/ai/*",
13+
"packages/atom/*",
14+
"packages/sql/*",
15+
"packages/tools/*",
16+
"examples/*"
17+
],
618
"exclude": [
719
"**/*.mjs",
820
"**/*.cjs",

packages/effect/src/Layer.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import type { LazyArg } from "./Function.ts"
2626
import { constant, constTrue, constUndefined, dual, identity } from "./Function.ts"
2727
import * as core from "./internal/core.ts"
2828
import * as internalEffect from "./internal/effect.ts"
29-
import type { ErrorWithStackTraceLimit } from "./internal/tracer.ts"
3029
import * as internalTracer from "./internal/tracer.ts"
3130
import { type Pipeable, pipeArguments } from "./Pipeable.ts"
3231
import { hasProperty } from "./Predicate.ts"
@@ -1776,10 +1775,10 @@ export const mock =
17761775
if (prop in target) {
17771776
return target[prop as keyof S]
17781777
}
1779-
const prevLimit = (Error as ErrorWithStackTraceLimit).stackTraceLimit
1780-
;(Error as ErrorWithStackTraceLimit).stackTraceLimit = 2
1778+
const prevLimit = Error.stackTraceLimit
1779+
Error.stackTraceLimit = 2
17811780
const error = new Error(`${service.key}: Unimplemented method "${prop.toString()}"`)
1782-
;(Error as ErrorWithStackTraceLimit).stackTraceLimit = prevLimit
1781+
Error.stackTraceLimit = prevLimit
17831782
error.name = "UnimplementedError"
17841783
return makeUnimplemented(error)
17851784
},

packages/effect/src/ServiceMap.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { constant, dual, type LazyArg } from "./Function.ts"
1616
import * as Hash from "./Hash.ts"
1717
import type { Inspectable } from "./Inspectable.ts"
1818
import { exitSucceed, PipeInspectableProto, withFiber, YieldableProto } from "./internal/core.ts"
19-
import type { ErrorWithStackTraceLimit } from "./internal/tracer.ts"
2019
import * as Option from "./Option.ts"
2120
import type { Pipeable } from "./Pipeable.ts"
2221
import { hasProperty } from "./Predicate.ts"
@@ -145,11 +144,10 @@ export const Service: {
145144
>
146145
& { readonly make: Make }
147146
} = function() {
148-
const prevLimit = (Error as ErrorWithStackTraceLimit).stackTraceLimit
149-
;(Error as ErrorWithStackTraceLimit)
150-
.stackTraceLimit = 2
147+
const prevLimit = Error.stackTraceLimit
148+
Error.stackTraceLimit = 2
151149
const err = new Error()
152-
;(Error as ErrorWithStackTraceLimit).stackTraceLimit = prevLimit
150+
Error.stackTraceLimit = prevLimit
153151
function KeyClass() {}
154152
const self = KeyClass as any as Types.Mutable<Reference<any>>
155153
Object.setPrototypeOf(self, ServiceProto)

packages/effect/src/internal/effect.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ import {
9090
} from "./core.ts"
9191
import * as doNotation from "./doNotation.ts"
9292
import * as InternalMetric from "./metric.ts"
93-
import { addSpanStackTrace, type ErrorWithStackTraceLimit, makeStackCleaner } from "./tracer.ts"
93+
import { addSpanStackTrace, makeStackCleaner } from "./tracer.ts"
9494
import { version } from "./version.ts"
9595

9696
// ----------------------------------------------------------------------------
@@ -310,9 +310,8 @@ export const causePrettyErrors = <E>(self: Cause.Cause<E>): Array<Error> => {
310310
const interrupts: Array<Cause.Interrupt> = []
311311
if (self.failures.length === 0) return errors
312312

313-
const prevStackLimit = (Error as ErrorWithStackTraceLimit).stackTraceLimit
314-
;(Error as ErrorWithStackTraceLimit)
315-
.stackTraceLimit = 1
313+
const prevStackLimit = Error.stackTraceLimit
314+
Error.stackTraceLimit = 1
316315

317316
for (const failure of self.failures) {
318317
if (failure._tag === "Interrupt") {
@@ -336,7 +335,7 @@ export const causePrettyErrors = <E>(self: Cause.Cause<E>): Array<Error> => {
336335
errors.push(causePrettyError(error, interrupts[0].annotations))
337336
}
338337

339-
;(Error as ErrorWithStackTraceLimit).stackTraceLimit = prevStackLimit
338+
Error.stackTraceLimit = prevStackLimit
340339
return errors
341340
}
342341

packages/effect/src/internal/tracer.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import type * as Tracer from "../Tracer.ts"
22

3-
export interface ErrorWithStackTraceLimit {
4-
stackTraceLimit?: number | undefined
5-
}
6-
73
/** @internal */
84
export const addSpanStackTrace = <A extends Tracer.TraceOptions>(
95
options: A | undefined
@@ -13,10 +9,10 @@ export const addSpanStackTrace = <A extends Tracer.TraceOptions>(
139
} else if (options?.captureStackTrace !== undefined && typeof options.captureStackTrace !== "boolean") {
1410
return options
1511
}
16-
const limit = (Error as ErrorWithStackTraceLimit).stackTraceLimit
17-
;(Error as ErrorWithStackTraceLimit).stackTraceLimit = 3
12+
const limit = Error.stackTraceLimit
13+
Error.stackTraceLimit = 3
1814
const traceError = new Error()
19-
;(Error as ErrorWithStackTraceLimit).stackTraceLimit = limit
15+
Error.stackTraceLimit = limit
2016
return {
2117
...options,
2218
captureStackTrace: spanCleaner(() => traceError.stack)

packages/effect/src/unstable/http/FetchHttpClient.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ export class RequestInit extends ServiceMap.Service<RequestInit, globalThis.Requ
2929
const fetch: HttpClient.HttpClient = HttpClient.make((request, url, signal, fiber) => {
3030
const fetch = fiber.getRef(Fetch)
3131
const options: globalThis.RequestInit = fiber.services.mapUnsafe.get(RequestInit.key) ?? {}
32-
const headers = options.headers ? Headers.merge(Headers.fromInput(options.headers), request.headers) : request.headers
32+
const headers = options.headers ?
33+
Headers.merge(
34+
Headers.fromInput(
35+
// TODO: Handle Deno correctly
36+
options.headers as ReadonlyArray<[string, string]>
37+
),
38+
request.headers
39+
) :
40+
request.headers
3341
const send = (body: BodyInit | undefined) =>
3442
Effect.map(
3543
Effect.tryPromise({

packages/effect/src/unstable/workers/Transferable.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,8 @@ export const MessagePort: Transferable<Schema.declare<MessagePort>> = schema(
153153
*/
154154
export const Uint8Array: Transferable<Schema.Uint8Array> = schema(
155155
Schema.Uint8Array,
156-
(_) => [_.buffer]
156+
(_) => [
157+
// TODO: Support SharedArrayBuffer in Schema
158+
_.buffer as ArrayBuffer
159+
]
157160
)

packages/platform-deno/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Effectful Technologies Inc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/platform-deno/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# `@effect/platform-deno`
2+
3+
Provides Deno-specific implementations for the abstractions defined in [`@effect/platform`](https://github.com/Effect-TS/effect/tree/main/packages/platform), allowing you to write platform-independent code that runs smoothly in Deno environments.
4+
5+
## Documentation
6+
7+
- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/platform-deno).

0 commit comments

Comments
 (0)