@e-infra/react-molstar-wrapper 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/README.md +94 -0
- package/dist/index.cjs.js +1258 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.cjs2.js +8 -0
- package/dist/index.cjs2.js.map +1 -0
- package/dist/index.cjs3.js +8 -0
- package/dist/index.cjs3.js.map +1 -0
- package/dist/index.es.js +1258 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.es2.js +8 -0
- package/dist/index.es2.js.map +1 -0
- package/dist/index.es3.js +8 -0
- package/dist/index.es3.js.map +1 -0
- package/dist/react-molstar-wrapper.css +32 -0
- package/dist/types/components.d.ts +2 -0
- package/dist/types/core/Manager.d.ts +19 -0
- package/dist/types/core/Manager.d.ts.map +1 -0
- package/dist/types/core/Plugin.d.ts +26 -0
- package/dist/types/core/Plugin.d.ts.map +1 -0
- package/dist/types/core/exceptions.d.ts +8 -0
- package/dist/types/core/exceptions.d.ts.map +1 -0
- package/dist/types/core/tree/chopping.d.ts +13 -0
- package/dist/types/core/tree/chopping.d.ts.map +1 -0
- package/dist/types/core/tree/colors.d.ts +14 -0
- package/dist/types/core/tree/colors.d.ts.map +1 -0
- package/dist/types/core/tree/create-mvs.d.ts +6 -0
- package/dist/types/core/tree/create-mvs.d.ts.map +1 -0
- package/dist/types/core/tree/index.d.ts +2 -0
- package/dist/types/core/tree/index.d.ts.map +1 -0
- package/dist/types/core/tree/rendering.d.ts +6 -0
- package/dist/types/core/tree/rendering.d.ts.map +1 -0
- package/dist/types/core/tree/selectors.d.ts +34 -0
- package/dist/types/core/tree/selectors.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +44 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +2 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/react/ErrorView.d.ts +2 -0
- package/dist/types/react/ErrorView.d.ts.map +1 -0
- package/dist/types/react/LoaderView.d.ts +2 -0
- package/dist/types/react/LoaderView.d.ts.map +1 -0
- package/dist/types/react/Viewer.d.ts +86 -0
- package/dist/types/react/Viewer.d.ts.map +1 -0
- package/dist/types/react/types.d.ts +49 -0
- package/dist/types/react/types.d.ts.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Props, ViewerRef } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Viewer
|
|
4
|
+
*
|
|
5
|
+
* React component that embeds a Mol* viewer plugin and exposes a small imperative
|
|
6
|
+
* API via a forwarded ref. The component is responsible for initializing and
|
|
7
|
+
* releasing a shared plugin instance (via Manager), loading structure data (either
|
|
8
|
+
* from raw `proteins` input or from precomputed `mvs`), and exposing convenience
|
|
9
|
+
* controls such as background color and simple animations (spin/rock).
|
|
10
|
+
*
|
|
11
|
+
* Remarks
|
|
12
|
+
* - Exactly one of `proteins` or `mvs` must be provided. Passing both or neither
|
|
13
|
+
* will throw an error during initialization.
|
|
14
|
+
* - The component holds internal loading state: "loading" | "success" | "error".
|
|
15
|
+
* On initialization errors the state becomes "error" and the error is logged to
|
|
16
|
+
* the console.
|
|
17
|
+
* - The plugin instance is created/reused via Manager.getInstance() and is
|
|
18
|
+
* released when the component unmounts (or when the effect cleans up).
|
|
19
|
+
* - UI mode `initialUI` toggles whether control chrome is shown; when set to
|
|
20
|
+
* "minimal" an additional CSS class ("no-controls") is applied to the container.
|
|
21
|
+
*
|
|
22
|
+
* Props
|
|
23
|
+
* @param proteins - Optional raw proteins data used to construct an MVS representation.
|
|
24
|
+
* When provided, the component will call `createMVS(proteins, modelSourceUrls, plugin)`
|
|
25
|
+
* to compute the view state to load into the plugin.
|
|
26
|
+
* @param mvs - Optional precomputed MVS data. If provided, the viewer loads this
|
|
27
|
+
* directly and does not call `createMVS`.
|
|
28
|
+
* @param modelSourceUrls - Optional lookup mapping used by `createMVS` to resolve
|
|
29
|
+
* model source URLs for remote model retrieval when `proteins` is used.
|
|
30
|
+
* Without trailing slashes, e.g. { uniProtId: "https://api.example.com/protein" }.
|
|
31
|
+
* @param initialUI - Which initial UI preset to use for the embedded plugin.
|
|
32
|
+
* Typical values: "standard" | "minimal". Default: "standard".
|
|
33
|
+
* @param bgColor - Background color for the viewer (any valid CSS color). Default: "#ffffff".
|
|
34
|
+
* @param spin - Whether to enable continuous spin animation. Mutually exclusive with `rock`.
|
|
35
|
+
* @param spinSpeed - Speed multiplier for the spin animation. Default: 0.05.
|
|
36
|
+
* @param rock - Whether to enable rock animation (back-and-forth). Mutually exclusive with `spin`.
|
|
37
|
+
* @param rockSpeed - Speed multiplier for the rock animation. Default: 0.2.
|
|
38
|
+
* @param height - Optional explicit height (in pixels) for the outer wrapper. If omitted,
|
|
39
|
+
* the wrapper will fill available height ("100%").
|
|
40
|
+
* @param className - Optional CSS class to apply to the outer wrapper.
|
|
41
|
+
*
|
|
42
|
+
* Forwarded ref (ViewerRef)
|
|
43
|
+
* The component forwards a ref exposing the following async methods:
|
|
44
|
+
* - highlight(domainId: number): Promise<void>
|
|
45
|
+
* Focuses/highlights a domain in the first protein using its choppingData.
|
|
46
|
+
* No-op if plugin or choppingData is not available.
|
|
47
|
+
* - reset(): Promise<void>
|
|
48
|
+
* Resets the plugin's view to its default/original pose.
|
|
49
|
+
* - updateSuperposition(proteinIndex: number, translation?, rotation?): Promise<void>
|
|
50
|
+
* Updates the transform for a loaded structure (protein) without reloading the
|
|
51
|
+
* entire scene. `translation` is an optional [x, y, z] tuple. `rotation` is an
|
|
52
|
+
* optional 3x3 matrix represented as [[r11,r12,r13],[r21,r22,r23],[r31,r32,r33]].
|
|
53
|
+
* This method relies on the Mol* plugin API to update transforms in-place.
|
|
54
|
+
*
|
|
55
|
+
* Behavior & Side Effects
|
|
56
|
+
* - While the component is initializing the plugin and loading data, it renders a
|
|
57
|
+
* LoaderView. If initialization fails, it renders an ErrorView.
|
|
58
|
+
* - When `spin` or `rock` props change (and the component is in "success" state),
|
|
59
|
+
* the corresponding plugin animation is enabled with the provided speed. Passing
|
|
60
|
+
* neither results in animations being turned off.
|
|
61
|
+
* - When `bgColor` changes (and the component is in "success" state), the plugin's
|
|
62
|
+
* background color is updated.
|
|
63
|
+
* - The container element receives a stable id (useId) and CSS class "react-molstar",
|
|
64
|
+
* plus "no-controls" when `initialUI === "minimal"`. The visualization container's
|
|
65
|
+
* opacity animates between loading/success states.
|
|
66
|
+
*
|
|
67
|
+
* Example
|
|
68
|
+
* const ref = useRef<ViewerRef | null>(null);
|
|
69
|
+
* <Viewer
|
|
70
|
+
* ref={ref}
|
|
71
|
+
* proteins={myProteins}
|
|
72
|
+
* initialUI="standard"
|
|
73
|
+
* bgColor="#000"
|
|
74
|
+
* />
|
|
75
|
+
* // later
|
|
76
|
+
* await ref.current?.highlight(3);
|
|
77
|
+
* await ref.current?.updateSuperposition(1, [10,0,0], [[1,0,0],[0,1,0],[0,0,1]]);
|
|
78
|
+
*
|
|
79
|
+
* See also
|
|
80
|
+
* - Manager: plugin lifecycle management used to acquire/release plugin instances.
|
|
81
|
+
* - createMVS: helper to convert raw protein input into an MVS representation accepted
|
|
82
|
+
* by the plugin.
|
|
83
|
+
*/
|
|
84
|
+
declare const Viewer: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<ViewerRef>>;
|
|
85
|
+
export default Viewer;
|
|
86
|
+
//# sourceMappingURL=Viewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Viewer.d.ts","sourceRoot":"","sources":["../../../lib/react/Viewer.tsx"],"names":[],"mappings":"AAWA,OAAO,aAAa,CAAC;AACrB,OAAO,2CAA2C,CAAC;AAMnD,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AACH,QAAA,MAAM,MAAM,6FA6MV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ColorHEX, InitialUI, ModelSourceUrls, Protein } from '../core/types';
|
|
2
|
+
import { MVSData } from 'molstar/lib/extensions/mvs/mvs-data.d.ts';
|
|
3
|
+
export type Props = {} & ({
|
|
4
|
+
proteins: Protein[];
|
|
5
|
+
mvs?: never;
|
|
6
|
+
} | {
|
|
7
|
+
mvs: MVSData;
|
|
8
|
+
proteins?: never;
|
|
9
|
+
}) & {
|
|
10
|
+
modelSourceUrls?: Partial<ModelSourceUrls>;
|
|
11
|
+
initialUI?: InitialUI;
|
|
12
|
+
bgColor?: ColorHEX;
|
|
13
|
+
} & ({
|
|
14
|
+
spin: boolean;
|
|
15
|
+
rock?: never;
|
|
16
|
+
} | {
|
|
17
|
+
rock: boolean;
|
|
18
|
+
spin?: never;
|
|
19
|
+
} | {
|
|
20
|
+
spin?: never;
|
|
21
|
+
rock?: never;
|
|
22
|
+
}) & {
|
|
23
|
+
spinSpeed?: number;
|
|
24
|
+
rockSpeed?: number;
|
|
25
|
+
height?: number;
|
|
26
|
+
className?: React.HTMLAttributes<HTMLDivElement>["className"];
|
|
27
|
+
};
|
|
28
|
+
export type ViewerRef = {
|
|
29
|
+
highlight: (proteinIndex: number, label: string) => Promise<void>;
|
|
30
|
+
reset: () => Promise<void>;
|
|
31
|
+
updateSuperposition: (proteinIndex: number, translation?: [number, number, number], rotation?: [
|
|
32
|
+
[
|
|
33
|
+
number,
|
|
34
|
+
number,
|
|
35
|
+
number
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
number,
|
|
39
|
+
number,
|
|
40
|
+
number
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
number,
|
|
44
|
+
number,
|
|
45
|
+
number
|
|
46
|
+
]
|
|
47
|
+
]) => Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=types.d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O,CAAC,IAAI,CAAC,CAAC;IAC3B,mBAAmB,EAAE,CACnB,YAAY,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACtC,QAAQ,CAAC,EAAE;QACT;YAAC,MAAM;YAAE,MAAM;YAAE,MAAM;SAAC;QACxB;YAAC,MAAM;YAAE,MAAM;YAAE,MAAM;SAAC;QACxB;YAAC,MAAM;YAAE,MAAM;YAAE,MAAM;SAAC;KACzB,KACE,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@e-infra/react-molstar-wrapper",
|
|
3
|
+
"private": false,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"molstar",
|
|
8
|
+
"typescript"
|
|
9
|
+
],
|
|
10
|
+
"description": "A React wrapper for Mol* (Molstar) molecular visualization library.",
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "CERIT-SC"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/xcillik/react-molstar-wrapper"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/xcillik/react-molstar-wrapper/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/xcillik/react-molstar-wrapper",
|
|
23
|
+
"maintainers": [
|
|
24
|
+
"Jakub Čillík <cillik@muni.cz>",
|
|
25
|
+
"Romana Ďuráčiová <duraciova@mail.muni.cz>",
|
|
26
|
+
"Michal Mikuš <mikus@ics.muni.cz>"
|
|
27
|
+
],
|
|
28
|
+
"version": "0.0.8",
|
|
29
|
+
"main": "./dist/index.cjs.js",
|
|
30
|
+
"module": "./dist/index.es.js",
|
|
31
|
+
"types": "./dist/types/index.d.ts",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev:showcase": "vite --config vite.config.showcase.ts",
|
|
34
|
+
"build:showcase": "vite build --config vite.config.showcase.ts",
|
|
35
|
+
"preview": "vite preview --config vite.config.showcase.ts",
|
|
36
|
+
"build:lib": "tsc -b && vite build --config vite.config.lib.ts",
|
|
37
|
+
"lint": "eslint .",
|
|
38
|
+
"lint:fix": "eslint --fix .",
|
|
39
|
+
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\" \"lib/**/*.{ts,tsx,js,jsx,json,css,md}\"",
|
|
40
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,css,md}\" \"lib/**/*.{ts,tsx,js,jsx,json,css,md}\"",
|
|
41
|
+
"type:check": "tsc --noEmit",
|
|
42
|
+
"tsc": "tsc --noEmit --watch",
|
|
43
|
+
"check": "bun run type:check && bun run lint && bun run format:check"
|
|
44
|
+
},
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./dist/types/index.d.ts",
|
|
48
|
+
"import": "./dist/index.es.js",
|
|
49
|
+
"require": "./dist/index.cjs.js"
|
|
50
|
+
},
|
|
51
|
+
"./style.css": "./dist/react-molstar-wrapper.css"
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist",
|
|
55
|
+
"README.md",
|
|
56
|
+
"LICENSE.md"
|
|
57
|
+
],
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/bun": "latest",
|
|
60
|
+
"@types/react": "^19.2.6",
|
|
61
|
+
"@types/react-dom": "^19.2.3",
|
|
62
|
+
"@vitejs/plugin-react-swc": "^4.2.2",
|
|
63
|
+
"typescript": "^5.9.3",
|
|
64
|
+
"prettier": "3.8.0",
|
|
65
|
+
"sass-embedded": "^1.93.3",
|
|
66
|
+
"vite": "^7.2.4",
|
|
67
|
+
"vite-plugin-dts": "^4.5.4",
|
|
68
|
+
"autoprefixer": "^10.4.23",
|
|
69
|
+
"eslint": "^9.39.1",
|
|
70
|
+
"eslint-config-prettier": "^10.1.8",
|
|
71
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
72
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
73
|
+
"typescript-eslint": "^8.46.4",
|
|
74
|
+
"rollup-preserve-directives": "^1.1.3",
|
|
75
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
76
|
+
"ajv": "8.17.1"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"react": "^19.2.0",
|
|
80
|
+
"react-dom": "^19.2.0",
|
|
81
|
+
"molstar": "^5.4.1",
|
|
82
|
+
"tailwindcss": "^4.1.18"
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {}
|
|
85
|
+
}
|