Skip to content
Snippets Groups Projects
Unverified Commit 01cb23f5 authored by David Sehnal's avatar David Sehnal Committed by GitHub
Browse files

add setFSModule (#755)

parent fe8a9799
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ Note that since we don't clearly distinguish between a public and private interf ...@@ -16,6 +16,7 @@ Note that since we don't clearly distinguish between a public and private interf
- Add exposure parameter to renderer - Add exposure parameter to renderer
- Only trigger marking when mouse is directly over canvas - Only trigger marking when mouse is directly over canvas
- Fix blurry occlusion in screenshots - Fix blurry occlusion in screenshots
- [breaking] Add `setFSModule` to `mol-util/data-source` instead of trying to trick WebPack
## [v3.31.4] - 2023-02-24 ## [v3.31.4] - 2023-02-24
......
...@@ -19,8 +19,11 @@ import { StructureRepresentation3D } from '../../mol-plugin-state/transforms/rep ...@@ -19,8 +19,11 @@ import { StructureRepresentation3D } from '../../mol-plugin-state/transforms/rep
import { HeadlessPluginContext } from '../../mol-plugin/headless-plugin-context'; import { HeadlessPluginContext } from '../../mol-plugin/headless-plugin-context';
import { DefaultPluginSpec } from '../../mol-plugin/spec'; import { DefaultPluginSpec } from '../../mol-plugin/spec';
import { STYLIZED_POSTPROCESSING } from '../../mol-plugin/util/headless-screenshot'; import { STYLIZED_POSTPROCESSING } from '../../mol-plugin/util/headless-screenshot';
import { setFSModule } from '../../mol-util/data-source';
setFSModule(fs);
interface Args { interface Args {
pdbId: string, pdbId: string,
outDirectory: string outDirectory: string
......
...@@ -300,14 +300,17 @@ function ajaxGetInternal<T extends DataType>(title: string | undefined, url: str ...@@ -300,14 +300,17 @@ function ajaxGetInternal<T extends DataType>(title: string | undefined, url: str
}); });
} }
// NOTE: lazy imports cannot be used here because WebPack complains since this // NOTE: a workaround for using this in Node.js
// is part of the "browser" build.
let _fs: (typeof import ('fs')) | undefined = undefined; let _fs: (typeof import ('fs')) | undefined = undefined;
function getFS() { function getFS() {
if (_fs) return _fs!; if (!_fs) {
const req = require; // To fool webpack throw new Error('When running in Node.js and reading from files, call mol-util/data-source\'s setFSModule function first.');
_fs = req('fs'); }
return _fs!; return _fs;
}
export function setFSModule(fs: typeof import ('fs')) {
_fs = fs;
} }
/** Alternative implementation of ajaxGetInternal (because xhr2 does not support file:// protocol) */ /** Alternative implementation of ajaxGetInternal (because xhr2 does not support file:// protocol) */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment