Add TextDecoder polyfill
This commit is contained in:
parent
11b6547c21
commit
9ff29c794e
|
@ -9,4 +9,5 @@ packages/backend-core/coverage
|
|||
packages/builder/.routify
|
||||
packages/sdk/sdk
|
||||
packages/pro/coverage
|
||||
**/*.ivm.bundle.js
|
||||
**/*.ivm.bundle.js
|
||||
!**/bson-polyfills.ivm.bundle.js
|
|
@ -1,6 +1,21 @@
|
|||
function atob(...args){
|
||||
return atobCB(...args)
|
||||
function atob(...args) {
|
||||
return atobCB(...args)
|
||||
}
|
||||
function btoa(...args){
|
||||
return btoaCB(...args)
|
||||
function btoa(...args) {
|
||||
return btoaCB(...args)
|
||||
}
|
||||
|
||||
class TextDecoder {
|
||||
constructorArgs
|
||||
|
||||
constructor(...constructorArgs) {
|
||||
this.constructorArgs = constructorArgs
|
||||
}
|
||||
|
||||
decode(...input) {
|
||||
return textDecoderCb({
|
||||
constructorArgs: this.constructorArgs,
|
||||
functionArgs: input,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,6 +161,8 @@ export class IsolatedVM implements VM {
|
|||
|
||||
const bsonSource = loadBundle(BundleType.BSON)
|
||||
|
||||
// "Polyfilling" text decoder and other utils. `bson.deserialize` requires decoding. We are creating a bridge function so we don't need to inject the full library
|
||||
const bsonPolyfills = loadBundle(BundleType.BSON_POLYFILLS)
|
||||
this.addToContext({
|
||||
textDecoderCb: new ivm.Callback(
|
||||
(args: {
|
||||
|
@ -183,9 +185,6 @@ export class IsolatedVM implements VM {
|
|||
}),
|
||||
})
|
||||
|
||||
// "Polyfilling" text decoder and other utils. `bson.deserialize` requires decoding. We are creating a bridge function so we don't need to inject the full library
|
||||
const bsonPolyfills = loadBundle(BundleType.BSON_POLYFILLS)
|
||||
|
||||
const script = this.isolate.compileScriptSync(
|
||||
`${bsonPolyfills};${bsonSource}`
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue