Skip to content

Commit

Permalink
feat(primitives): remove atob/btoa implementation (#689)
Browse files Browse the repository at this point in the history
* feat(primitives): remove atob/btoa implementation

* Create violet-carrots-listen.md
  • Loading branch information
Kikobeats authored Nov 2, 2023
1 parent 7a79df9 commit 773f00e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-carrots-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@edge-runtime/primitives": patch
---

feat(primitives): remove atob/btoa implementation, use native implementation.
2 changes: 1 addition & 1 deletion packages/primitives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
],
"scripts": {
"build": "ts-node scripts/build.ts",
"clean:build": "rm -rf dist abort-controller blob console crypto encoding events fetch streams structured-clone url",
"clean:build": "rm -rf dist abort-controller blob console crypto events fetch streams structured-clone url",
"clean:node": "rm -rf node_modules",
"prebuild": "pnpm run clean:build"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/primitives/src/primitives/encoding.js

This file was deleted.

11 changes: 2 additions & 9 deletions packages/primitives/src/primitives/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,13 @@ function requireWithFakeGlobalScope(params) {
export function load(scopedContext = {}) {
/** @type Record<string, any> */
const context = {}
/** @type {import('../../type-definitions/encoding')} */
const encodingImpl = requireWithFakeGlobalScope({
context,
id: 'encoding.js',
sourceCode: injectSourceCode('./encoding.js'),
scopedContext,
})
assign(context, {
TextDecoder,
TextEncoder,
TextEncoderStream,
TextDecoderStream,
atob: encodingImpl.atob,
btoa: encodingImpl.btoa,
atob,
btoa,
})

/** @type {import('../../type-definitions/console')} */
Expand Down
7 changes: 5 additions & 2 deletions packages/primitives/type-definitions/encoding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ declare const TextDecoderConstructor: typeof TextDecoder
export { TextEncoderConstructor as TextEncoder }
export { TextDecoderConstructor as TextDecoder }

export const atob: (encoded: string) => string
export const btoa: (input: any) => string
declare const _atob: typeof atob
declare const _btoa: typeof btoa

export { _atob as atob }
export { _btoa as btoa }
1 change: 0 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"console/**",
"crypto/**",
"dist/**",
"encoding/**",
"events/**",
"fetch/**",
"streams/**",
Expand Down

1 comment on commit 773f00e

@vercel
Copy link

@vercel vercel bot commented on 773f00e Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-runtime – ./

edge-runtime-git-main.vercel.sh
edge-runtime.vercel.sh
edge-runtime.vercel.app

Please sign in to comment.