Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/silly-keys-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@effect/platform-browser": patch
"@effect/platform-node": patch
"@effect/experimental": patch
"effect": patch
---

Support building under TypeScript 5.9
4 changes: 2 additions & 2 deletions packages/effect/test/Match.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,11 @@ describe("Match", () => {
const match = pipe(
M.type<Uint8Array | Uint16Array>(),
M.when(M.instanceOf(Uint8Array), (_) => {
assertType<Uint8Array>()(_) satisfies true
assertType<Uint8Array<ArrayBuffer>>()(_) satisfies true
return "uint8"
}),
M.when(M.instanceOf(Uint16Array), (_) => {
assertType<Uint16Array>()(_) satisfies true
assertType<Uint16Array<ArrayBuffer>>()(_) satisfies true
return "uint16"
}),
M.orElse((_) => {
Expand Down
8 changes: 5 additions & 3 deletions packages/experimental/src/EventJournal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export const makeIndexedDb = (options?: {
if (state.done) return
const remoteEntry = state.value
const entry = remoteEntry.entry
entries.get(entry.id).onsuccess = (event) => {
entries.get(entry.id as Uint8Array<ArrayBuffer>).onsuccess = (event) => {
if ((event.target as any).result) {
remotes.put({
remoteId: options.remoteId,
Expand Down Expand Up @@ -516,7 +516,7 @@ export const makeIndexedDb = (options?: {
const remotesStore = tx.objectStore("remotes")
const remoteEntryIdStore = tx.objectStore("remoteEntryId")

remoteEntryIdStore.get(remoteId).onsuccess = (event) => {
remoteEntryIdStore.get(remoteId as Uint8Array<ArrayBuffer>).onsuccess = (event) => {
const startEntryId = (event.target as any).result?.entryId
const entryCursor = entriesStore.index("id").openCursor(
startEntryId ? IDBKeyRange.lowerBound(startEntryId, true) : null,
Expand All @@ -526,7 +526,9 @@ export const makeIndexedDb = (options?: {
const cursor = entryCursor.result
if (!cursor) return
const entry = decodeEntryIdb(cursor.value)
remotesStore.get([remoteId, entry.id]).onsuccess = (event) => {
remotesStore.get([remoteId as Uint8Array<ArrayBuffer>, entry.id as Uint8Array<ArrayBuffer>]).onsuccess = (
event
) => {
if (!(event.target as any).result) entries.push(entry)
cursor.continue()
}
Expand Down
14 changes: 8 additions & 6 deletions packages/experimental/src/EventLogEncryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const makeEncryptionSubtle = (crypto: Crypto): Effect.Effect<typeof Event
return Effect.promise(() =>
crypto.subtle.importKey(
"raw",
Redacted.value(identity.privateKey),
Redacted.value(identity.privateKey) as Uint8Array<ArrayBuffer>,
"AES-GCM",
true,
["encrypt", "decrypt"]
Expand All @@ -93,7 +93,9 @@ export const makeEncryptionSubtle = (crypto: Crypto): Effect.Effect<typeof Event
const iv = crypto.getRandomValues(new Uint8Array(12))
const encryptedEntries = yield* Effect.promise(() =>
Promise.all(
data.map((entry) => crypto.subtle.encrypt({ name: "AES-GCM", iv, tagLength: 128 }, key, entry))
data.map((entry) =>
crypto.subtle.encrypt({ name: "AES-GCM", iv, tagLength: 128 }, key, entry as Uint8Array<ArrayBuffer>)
)
)
)
return {
Expand All @@ -107,22 +109,22 @@ export const makeEncryptionSubtle = (crypto: Crypto): Effect.Effect<typeof Event
const decryptedData = (yield* Effect.promise(() =>
Promise.all(entries.map((data) =>
crypto.subtle.decrypt(
{ name: "AES-GCM", iv: data.iv, tagLength: 128 },
{ name: "AES-GCM", iv: data.iv as Uint8Array<ArrayBuffer>, tagLength: 128 },
key,
data.encryptedEntry
data.encryptedEntry as Uint8Array<ArrayBuffer>
)
))
)).map((buffer) => new Uint8Array(buffer))
const decoded = yield* Effect.orDie(Entry.decodeArray(decryptedData))
return decoded.map((entry, i) => new RemoteEntry({ remoteSequence: entries[i].sequence, entry }))
}),
sha256: (data) =>
Effect.promise(() => crypto.subtle.digest("SHA-256", data)).pipe(
Effect.promise(() => crypto.subtle.digest("SHA-256", data as Uint8Array<ArrayBuffer>)).pipe(
Effect.map((hash) => new Uint8Array(hash))
),
sha256String: (data) =>
Effect.map(
Effect.promise(() => crypto.subtle.digest("SHA-256", data)),
Effect.promise(() => crypto.subtle.digest("SHA-256", data as Uint8Array<ArrayBuffer>)),
(hash) => {
const hashArray = Array.from(new Uint8Array(hash))
const hashHex = hashArray
Expand Down
4 changes: 2 additions & 2 deletions packages/platform-browser/src/internal/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const sendBody = (
case "Raw":
return Effect.sync(() => xhr.send(body.body as any))
case "Uint8Array":
return Effect.sync(() => xhr.send(body.body))
return Effect.sync(() => xhr.send(body.body as Uint8Array<ArrayBuffer>))
case "FormData":
return Effect.sync(() => xhr.send(body.formData))
case "Stream":
Expand Down Expand Up @@ -274,7 +274,7 @@ export abstract class IncomingMessageImpl<E> extends Inspectable.Class
}).pipe(
Effect.map((response) => {
if (typeof response === "string") {
return encoder.encode(response).buffer
return encoder.encode(response).buffer as ArrayBuffer
}
return response
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export abstract class HttpIncomingMessageImpl<E> extends Inspectable.Class
NodeStream.toUint8Array(() => this.source, {
onFailure: this.onError,
maxBytes: Option.getOrUndefined(maxBodySize)
})
}).pipe(Effect.map((_) => _.buffer as ArrayBuffer))
)
}
}
Loading