mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 04:37:23 +00:00
Removes the deferred `"off"` override and rewrites the 55 violations (all in test/mocks/Node-script files) to use `window.*` instead of `global.*`. Production code was already cleaned up in #2401. - 18 test files + __mocks__/obsidian.js + jest.setup.js: mechanical `global.X` → `window.X` (Jest runs under jsdom, so window === globalThis) - scripts/printPromptDebugEntry.ts: inline eslint-disable — Node-only debug script with no window available Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
24 lines
811 B
JavaScript
24 lines
811 B
JavaScript
import "web-streams-polyfill/dist/polyfill.min.js";
|
|
import { TextEncoder, TextDecoder } from "util";
|
|
|
|
window.TextEncoder = TextEncoder;
|
|
window.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 ?? window.document;
|
|
},
|
|
configurable: true,
|
|
});
|
|
}
|
|
if (typeof Node !== "undefined" && !Object.prototype.hasOwnProperty.call(Node.prototype, "win")) {
|
|
Object.defineProperty(Node.prototype, "win", {
|
|
get() {
|
|
return this.ownerDocument?.defaultView ?? window;
|
|
},
|
|
configurable: true,
|
|
});
|
|
}
|