mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
24 lines
818 B
JavaScript
24 lines
818 B
JavaScript
import "web-streams-polyfill/dist/polyfill.min.js";
|
|
import { TextEncoder, TextDecoder } from "util";
|
|
|
|
global.TextEncoder = TextEncoder;
|
|
global.TextDecoder = TextDecoder;
|
|
|
|
// Polyfill Obsidian's Node.doc / Node.win augmentation so plugin code that
|
|
// reads `element.doc` / `element.win` works under jsdom.
|
|
if (typeof Node !== "undefined" && !Object.prototype.hasOwnProperty.call(Node.prototype, "doc")) {
|
|
Object.defineProperty(Node.prototype, "doc", {
|
|
get() {
|
|
return this.ownerDocument ?? global.document;
|
|
},
|
|
configurable: true,
|
|
});
|
|
}
|
|
if (typeof Node !== "undefined" && !Object.prototype.hasOwnProperty.call(Node.prototype, "win")) {
|
|
Object.defineProperty(Node.prototype, "win", {
|
|
get() {
|
|
return this.ownerDocument?.defaultView ?? global.window;
|
|
},
|
|
configurable: true,
|
|
});
|
|
}
|