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
- Add exposure parameter to renderer
- Only trigger marking when mouse is directly over canvas
- 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
......
......@@ -19,8 +19,11 @@ import { StructureRepresentation3D } from '../../mol-plugin-state/transforms/rep
import { HeadlessPluginContext } from '../../mol-plugin/headless-plugin-context';
import { DefaultPluginSpec } from '../../mol-plugin/spec';
import { STYLIZED_POSTPROCESSING } from '../../mol-plugin/util/headless-screenshot';
import { setFSModule } from '../../mol-util/data-source';
setFSModule(fs);
interface Args {
pdbId: string,
outDirectory: string
......
......@@ -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
// is part of the "browser" build.
// NOTE: a workaround for using this in Node.js
let _fs: (typeof import ('fs')) | undefined = undefined;
function getFS() {
if (_fs) return _fs!;
const req = require; // To fool webpack
_fs = req('fs');
return _fs!;
if (!_fs) {
throw new Error('When running in Node.js and reading from files, call mol-util/data-source\'s setFSModule function first.');
}
return _fs;
}
export function setFSModule(fs: typeof import ('fs')) {
_fs = fs;
}
/** 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