Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TextEncoder and TextDecoder wrappers #31490

Merged
merged 2 commits into from Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 2 additions & 46 deletions packages/next/server/web/sandbox/polyfills.ts
@@ -1,7 +1,5 @@
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'
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/next/server/web/sandbox/sandbox.ts
Expand Up @@ -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,
Expand Down