Unverified Commit 93754859 authored by Javi Velasco's avatar Javi Velasco Committed by GitHub

Remove TextEncoder and TextDecoder wrappers (#31490)

This PR removes the class wrapper that we have for `TextEncoder` and `TextDecoder`. Since this is merged we will be using directly the Node version in the sandbox.
parent f195650f
import {
Crypto as WebCrypto,
CryptoKey,
} from 'next/dist/compiled/@peculiar/webcrypto'
import { Crypto as WebCrypto } from 'next/dist/compiled/@peculiar/webcrypto'
import { CryptoKey } from 'next/dist/compiled/@peculiar/webcrypto'
import { TransformStream } from 'next/dist/compiled/web-streams-polyfill'
import { v4 as uuid } from 'next/dist/compiled/uuid'
import crypto from 'crypto'
......@@ -14,48 +12,6 @@ export function btoa(str: string) {
return Buffer.from(str, 'binary').toString('base64')
}
class TextEncoderRuntime {
encoder: TextEncoder
constructor() {
this.encoder = new TextEncoder()
}
get encoding() {
return this.encoder.encoding
}
public encode(input: string) {
return this.encoder.encode(input)
}
}
class TextDecoderRuntime {
decoder: TextDecoder
constructor() {
this.decoder = new TextDecoder()
}
get encoding() {
return this.decoder.encoding
}
get fatal() {
return this.decoder.fatal
}
get ignoreBOM() {
return this.decoder.ignoreBOM
}
public decode(input: BufferSource, options?: TextDecodeOptions) {
return this.decoder.decode(input, options)
}
}
export { TextDecoderRuntime as TextDecoder }
export { TextEncoderRuntime as TextEncoder }
export { CryptoKey }
export class Crypto extends WebCrypto {
......
......@@ -82,8 +82,8 @@ export async function run(params: {
ReadableStream: polyfills.ReadableStream,
setInterval,
setTimeout,
TextDecoder: polyfills.TextDecoder,
TextEncoder: polyfills.TextEncoder,
TextDecoder,
TextEncoder,
TransformStream,
URL,
URLSearchParams,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment