diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d82f6aa8e39ca7cd65027c042a6e1f61b8d08d3..959388fa2dd062622bbcecfcc8b8c71e3a8f06a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Note that since we don't clearly distinguish between a public and private interf - Fix issue with outlines and orthographic camera - Reduce over-blurring occlusion at larger view distances - Fix occlusion artefact with non-canvas viewport and pixel-ratio > 1 +- Update nodejs-shims conditionals to handle polyfilled document object in NodeJS environment. ## [v3.31.4] - 2023-02-24 diff --git a/package.json b/package.json index 6755c44df0a4495e468812ab7856d37fcd3297ef..e6c29447fc0bc95b0cc91f31f686fcba2ac0f2c3 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,8 @@ "Ke Ma <mark.ma@rcsb.org>", "Jason Pattle <jpattle@exscientia.co.uk>", "David Williams <dwilliams@nobiastx.com>", - "Zhenyu Zhang <jump2cn@gmail.com>" + "Zhenyu Zhang <jump2cn@gmail.com>", + "Russell Parker <russell@benchling.com>" ], "license": "MIT", "devDependencies": { diff --git a/src/mol-util/nodejs-shims.ts b/src/mol-util/nodejs-shims.ts index fd4304860f5fe386656e28a6f01865dbe54e91e9..0605f3d6bf25f5b777ba22dff1113578f494c97c 100644 --- a/src/mol-util/nodejs-shims.ts +++ b/src/mol-util/nodejs-shims.ts @@ -2,6 +2,7 @@ * Copyright (c) 2018-2023 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Adam Midlik <midlik@gmail.com> + * @author Russell Parker <russell@benchling.com> * * Implements some browser-only global variables for Node.js environment. * These workarounds will also work in browsers as usual. @@ -19,7 +20,7 @@ export const File_ = getFile(); function getXMLHttpRequest(): typeof XMLHttpRequest { - if (typeof document === 'undefined') { + if (typeof XMLHttpRequest === 'undefined' || RUNNING_IN_NODEJS) { return require('xhr2'); } else { return XMLHttpRequest; @@ -27,7 +28,7 @@ function getXMLHttpRequest(): typeof XMLHttpRequest { } function getFile(): typeof File { - if (typeof document === 'undefined') { + if (typeof File === 'undefined' || RUNNING_IN_NODEJS) { class File_NodeJs implements File { private readonly blob: Blob; // Blob fields