Skip to content

Commit

Permalink
enhance: expose abortcontroller to extensions (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyChen777 authored Jun 29, 2024
1 parent 9c97327 commit 6a90837
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/extension/manager/plugin-vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,18 @@ export class PluginVm {
// `var app = exports = module.exports = {};` notation
const iifeCode = `
(function(exports){
globalThis.AbortController = globalThis['_AC'];
globalThis.AbortSignal = globalThis['_AS'];
${code}
}(module.exports));`;

const vmOptions = { displayErrors: true, filename: filePath };
const script = new vm.Script(iifeCode, vmOptions);

moduleContext._AC = AbortController;
moduleContext.global._AC = AbortController;
moduleContext._AS = AbortSignal;
moduleContext.global._AS = AbortSignal;
script.runInContext(moduleContext, vmOptions);
}

Expand Down

0 comments on commit 6a90837

Please sign in to comment.