@uibcdf/molsysviewer 0.0.2 → 0.6.0
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/dist/viewer.js +62 -29
- package/dist/viewer.js.map +2 -2
- package/package.json +7 -2
package/dist/viewer.js
CHANGED
|
@@ -140086,7 +140086,7 @@ async function loadStructureFromString(plugin, data, format = "pdb", label2, opt
|
|
|
140086
140086
|
const raw = await plugin.builders.data.rawData({
|
|
140087
140087
|
data,
|
|
140088
140088
|
label: label2 ?? "Structure from string",
|
|
140089
|
-
// extension
|
|
140089
|
+
// Optional extension; helps some parsers.
|
|
140090
140090
|
ext: format
|
|
140091
140091
|
});
|
|
140092
140092
|
const trajectory = await plugin.builders.structure.parseTrajectory(raw, format);
|
|
@@ -140708,7 +140708,7 @@ var PocketBlob3D = MSVTransform({
|
|
|
140708
140708
|
function preparePocketBlobData(options) {
|
|
140709
140709
|
const field = buildPocketBlobField(options);
|
|
140710
140710
|
if (!field) {
|
|
140711
|
-
console.warn("[MolSysViewer] add_pocket_blob
|
|
140711
|
+
console.warn("[MolSysViewer] add_pocket_blob: no valid data");
|
|
140712
140712
|
return void 0;
|
|
140713
140713
|
}
|
|
140714
140714
|
const levels = options.iso_levels && options.iso_levels.length > 0 ? options.iso_levels : [options.iso_level ?? 0.1];
|
|
@@ -140951,7 +140951,7 @@ function prepareChannelTubeData(options) {
|
|
|
140951
140951
|
const built = buildChannelSegments(options);
|
|
140952
140952
|
const segments2 = built.segments;
|
|
140953
140953
|
if (!segments2 || segments2.length === 0) {
|
|
140954
|
-
console.warn("[MolSysViewer] add_channel_tube
|
|
140954
|
+
console.warn("[MolSysViewer] add_channel_tube: no valid segments");
|
|
140955
140955
|
return { radialSegments: built.radialSegments };
|
|
140956
140956
|
}
|
|
140957
140957
|
const alpha = options.alpha ?? 1;
|
|
@@ -141173,7 +141173,7 @@ var AnisotropyEllipsoids3D = MSVTransform({
|
|
|
141173
141173
|
function prepareAnisotropyEllipsoidData(plugin, options) {
|
|
141174
141174
|
const ellipsoids = buildEllipsoidSpecs(plugin, options);
|
|
141175
141175
|
if (ellipsoids.length === 0) {
|
|
141176
|
-
console.warn("[MolSysViewer] add_anisotropy_ellipsoids
|
|
141176
|
+
console.warn("[MolSysViewer] add_anisotropy_ellipsoids: no valid data");
|
|
141177
141177
|
return void 0;
|
|
141178
141178
|
}
|
|
141179
141179
|
const alpha = options.alpha ?? 0.6;
|
|
@@ -141303,7 +141303,7 @@ function preparePharmacophoreData(options) {
|
|
|
141303
141303
|
const centers = options.centers ?? [];
|
|
141304
141304
|
const kinds = options.kinds ?? [];
|
|
141305
141305
|
if (centers.length === 0 || centers.length !== kinds.length) {
|
|
141306
|
-
console.warn("[MolSysViewer] add_pharmacophore_features
|
|
141306
|
+
console.warn("[MolSysViewer] add_pharmacophore_features requires centers and kinds of the same length");
|
|
141307
141307
|
return void 0;
|
|
141308
141308
|
}
|
|
141309
141309
|
const radii = options.radii && options.radii.length === centers.length ? options.radii : new Array(centers.length).fill(0.6);
|
|
@@ -141455,7 +141455,7 @@ function normalizeCoordinatePair(entry) {
|
|
|
141455
141455
|
function expandToList(value, count3, cast, fallback) {
|
|
141456
141456
|
if (Array.isArray(value)) {
|
|
141457
141457
|
if (value.length === count3) return value.map(cast);
|
|
141458
|
-
console.warn(`[MolSysViewer]
|
|
141458
|
+
console.warn(`[MolSysViewer] Expected ${count3} values but got ${value.length}. The first value will be reused.`);
|
|
141459
141459
|
return Array(count3).fill(cast(value[0]));
|
|
141460
141460
|
}
|
|
141461
141461
|
return Array(count3).fill(cast(value ?? fallback));
|
|
@@ -141528,7 +141528,7 @@ function buildLinksFromAtoms(structure, options) {
|
|
|
141528
141528
|
const locA = lookup.get(a8);
|
|
141529
141529
|
const locB = lookup.get(b8);
|
|
141530
141530
|
if (!locA || !locB) {
|
|
141531
|
-
console.warn(`[MolSysViewer] atom_pairs[${i}]
|
|
141531
|
+
console.warn(`[MolSysViewer] atom_pairs[${i}] does not match atoms in the structure`);
|
|
141532
141532
|
continue;
|
|
141533
141533
|
}
|
|
141534
141534
|
locA.unit.conformation.position(locA.elementIndex, positionsStart);
|
|
@@ -141568,7 +141568,7 @@ async function addNetworkLinksFromPython(plugin, options) {
|
|
|
141568
141568
|
const structureRef = plugin.managers.structure.hierarchy.current.structures.slice(-1)[0];
|
|
141569
141569
|
const structure = structureRef?.cell.obj?.data;
|
|
141570
141570
|
if (!structure) {
|
|
141571
|
-
console.warn("[MolSysViewer] add_network_links
|
|
141571
|
+
console.warn("[MolSysViewer] add_network_links: no structure loaded");
|
|
141572
141572
|
return void 0;
|
|
141573
141573
|
}
|
|
141574
141574
|
links = buildLinksFromAtoms(structure, options);
|
|
@@ -141578,7 +141578,7 @@ async function addNetworkLinksFromPython(plugin, options) {
|
|
|
141578
141578
|
name = getNetworkLinksName(links.length);
|
|
141579
141579
|
}
|
|
141580
141580
|
if (links.length === 0) {
|
|
141581
|
-
console.warn("[MolSysViewer] add_network_links
|
|
141581
|
+
console.warn("[MolSysViewer] add_network_links: no valid data");
|
|
141582
141582
|
return void 0;
|
|
141583
141583
|
}
|
|
141584
141584
|
const data = {
|
|
@@ -141784,7 +141784,7 @@ function expandOptionalToList(value, count3, cast) {
|
|
|
141784
141784
|
if (value === void 0) return Array(count3).fill(void 0);
|
|
141785
141785
|
if (Array.isArray(value)) {
|
|
141786
141786
|
if (value.length === count3) return value.map(cast);
|
|
141787
|
-
console.warn(`[MolSysViewer]
|
|
141787
|
+
console.warn(`[MolSysViewer] Expected ${count3} values but got ${value.length}. The first value will be reused.`);
|
|
141788
141788
|
return Array(count3).fill(cast(value[0]));
|
|
141789
141789
|
}
|
|
141790
141790
|
return Array(count3).fill(cast(value));
|
|
@@ -141815,14 +141815,14 @@ function buildTrianglesFromAtoms(structure, options) {
|
|
|
141815
141815
|
for (let i = 0; i < triplets.length; i++) {
|
|
141816
141816
|
const triplet = triplets[i];
|
|
141817
141817
|
if (!Array.isArray(triplet) || triplet.length !== 3) {
|
|
141818
|
-
console.warn(`[MolSysViewer] atom_triplets[${i}]
|
|
141818
|
+
console.warn(`[MolSysViewer] atom_triplets[${i}] is not a valid triplet`);
|
|
141819
141819
|
continue;
|
|
141820
141820
|
}
|
|
141821
141821
|
const locA = lookup.get(triplet[0]);
|
|
141822
141822
|
const locB = lookup.get(triplet[1]);
|
|
141823
141823
|
const locC = lookup.get(triplet[2]);
|
|
141824
141824
|
if (!locA || !locB || !locC) {
|
|
141825
|
-
console.warn(`[MolSysViewer] atom_triplets[${i}]
|
|
141825
|
+
console.warn(`[MolSysViewer] atom_triplets[${i}] does not match atoms in the structure`);
|
|
141826
141826
|
continue;
|
|
141827
141827
|
}
|
|
141828
141828
|
locA.unit.conformation.position(locA.elementIndex, a8);
|
|
@@ -141848,7 +141848,7 @@ function prepareTriangleFacesData(plugin, options) {
|
|
|
141848
141848
|
const structureRef = plugin.managers.structure.hierarchy.current.structures.slice(-1)[0];
|
|
141849
141849
|
const structure = structureRef?.cell.obj?.data;
|
|
141850
141850
|
if (!structure) {
|
|
141851
|
-
console.warn("[MolSysViewer] add_triangle_faces
|
|
141851
|
+
console.warn("[MolSysViewer] add_triangle_faces: atom_triplets provided but no structure loaded");
|
|
141852
141852
|
return void 0;
|
|
141853
141853
|
}
|
|
141854
141854
|
triangles = buildTrianglesFromAtoms(structure, options);
|
|
@@ -141856,7 +141856,7 @@ function prepareTriangleFacesData(plugin, options) {
|
|
|
141856
141856
|
triangles = buildTrianglesFromVertices(options);
|
|
141857
141857
|
}
|
|
141858
141858
|
if (triangles.length === 0) {
|
|
141859
|
-
console.warn("[MolSysViewer] add_triangle_faces
|
|
141859
|
+
console.warn("[MolSysViewer] add_triangle_faces: no valid triangles");
|
|
141860
141860
|
return void 0;
|
|
141861
141861
|
}
|
|
141862
141862
|
const name = triangles.length === 1 ? "Triangle Face" : `${triangles.length} Triangle Faces`;
|
|
@@ -142166,7 +142166,7 @@ function buildTetrahedraFromAtoms(structure, options) {
|
|
|
142166
142166
|
const locC = lookup.get(quad[2]);
|
|
142167
142167
|
const locD = lookup.get(quad[3]);
|
|
142168
142168
|
if (!locA || !locB || !locC || !locD) {
|
|
142169
|
-
console.warn(`[MolSysViewer] atom_quads[${i}]
|
|
142169
|
+
console.warn(`[MolSysViewer] atom_quads[${i}] does not match atoms in the structure`);
|
|
142170
142170
|
continue;
|
|
142171
142171
|
}
|
|
142172
142172
|
locA.unit.conformation.position(locA.elementIndex, a8);
|
|
@@ -142195,7 +142195,7 @@ function prepareTetrahedraData(plugin, options) {
|
|
|
142195
142195
|
const structureRef = plugin.managers.structure.hierarchy.current.structures.slice(-1)[0];
|
|
142196
142196
|
const structure = structureRef?.cell.obj?.data;
|
|
142197
142197
|
if (!structure) {
|
|
142198
|
-
console.warn("[MolSysViewer] add_tetrahedra
|
|
142198
|
+
console.warn("[MolSysViewer] add_tetrahedra: atom_quads provided but no structure loaded");
|
|
142199
142199
|
return void 0;
|
|
142200
142200
|
}
|
|
142201
142201
|
tetrahedra = buildTetrahedraFromAtoms(structure, options);
|
|
@@ -142203,7 +142203,7 @@ function prepareTetrahedraData(plugin, options) {
|
|
|
142203
142203
|
tetrahedra = buildTetrahedraFromCoords(options);
|
|
142204
142204
|
}
|
|
142205
142205
|
if (tetrahedra.length === 0) {
|
|
142206
|
-
console.warn("[MolSysViewer] add_tetrahedra
|
|
142206
|
+
console.warn("[MolSysViewer] add_tetrahedra: no valid tetrahedra");
|
|
142207
142207
|
return void 0;
|
|
142208
142208
|
}
|
|
142209
142209
|
const name = options.name ?? (tetrahedra.length === 1 ? "Tetrahedron" : `${tetrahedra.length} Tetrahedra`);
|
|
@@ -142344,7 +142344,7 @@ function resolveOriginsFromAtoms(plugin, atomIndices) {
|
|
|
142344
142344
|
const structureRef = plugin.managers.structure.hierarchy.current.structures.slice(-1)[0];
|
|
142345
142345
|
const structure = structureRef?.cell.obj?.data;
|
|
142346
142346
|
if (!structure) {
|
|
142347
|
-
console.warn("[MolSysViewer] add_displacement_vectors
|
|
142347
|
+
console.warn("[MolSysViewer] add_displacement_vectors: no structure loaded");
|
|
142348
142348
|
return [];
|
|
142349
142349
|
}
|
|
142350
142350
|
const lookup = buildUnitLookup(structure);
|
|
@@ -142353,7 +142353,7 @@ function resolveOriginsFromAtoms(plugin, atomIndices) {
|
|
|
142353
142353
|
atomIndices.forEach((idx, pos) => {
|
|
142354
142354
|
const loc = lookup.get(idx);
|
|
142355
142355
|
if (!loc) {
|
|
142356
|
-
console.warn(`[MolSysViewer] atom_indices[${pos}]
|
|
142356
|
+
console.warn(`[MolSysViewer] atom_indices[${pos}] does not match atoms in the structure`);
|
|
142357
142357
|
origins.push(void 0);
|
|
142358
142358
|
return;
|
|
142359
142359
|
}
|
|
@@ -142365,12 +142365,12 @@ function resolveOriginsFromAtoms(plugin, atomIndices) {
|
|
|
142365
142365
|
function prepareDisplacementVectorData(plugin, options) {
|
|
142366
142366
|
const vectors = options.vectors ?? [];
|
|
142367
142367
|
if (!vectors || vectors.length === 0) {
|
|
142368
|
-
console.warn("[MolSysViewer] add_displacement_vectors
|
|
142368
|
+
console.warn("[MolSysViewer] add_displacement_vectors: missing vectors");
|
|
142369
142369
|
return void 0;
|
|
142370
142370
|
}
|
|
142371
142371
|
const origins = options.atom_indices && options.atom_indices.length > 0 ? resolveOriginsFromAtoms(plugin, options.atom_indices) : options.origins ?? [];
|
|
142372
142372
|
if (!origins || origins.length === 0) {
|
|
142373
|
-
console.warn("[MolSysViewer] add_displacement_vectors
|
|
142373
|
+
console.warn("[MolSysViewer] add_displacement_vectors: no valid origins");
|
|
142374
142374
|
return void 0;
|
|
142375
142375
|
}
|
|
142376
142376
|
const count3 = Math.min(origins.length, vectors.length);
|
|
@@ -142400,7 +142400,7 @@ function prepareDisplacementVectorData(plugin, options) {
|
|
|
142400
142400
|
});
|
|
142401
142401
|
}
|
|
142402
142402
|
if (processed.length === 0) {
|
|
142403
|
-
console.warn("[MolSysViewer] add_displacement_vectors
|
|
142403
|
+
console.warn("[MolSysViewer] add_displacement_vectors: no usable inputs");
|
|
142404
142404
|
return void 0;
|
|
142405
142405
|
}
|
|
142406
142406
|
const scaledMax = Math.max(...processed.map((p6) => p6.magnitude * lengthScale));
|
|
@@ -142425,7 +142425,7 @@ function prepareDisplacementVectorData(plugin, options) {
|
|
|
142425
142425
|
colorValues.push(value);
|
|
142426
142426
|
}
|
|
142427
142427
|
if (arrows.length === 0) {
|
|
142428
|
-
console.warn("[MolSysViewer] add_displacement_vectors
|
|
142428
|
+
console.warn("[MolSysViewer] add_displacement_vectors: no arrows after filtering");
|
|
142429
142429
|
return void 0;
|
|
142430
142430
|
}
|
|
142431
142431
|
const minValue = Math.min(...colorValues);
|
|
@@ -142634,12 +142634,12 @@ async function addPocketSurfaceFromPython(plugin, options) {
|
|
|
142634
142634
|
const structureRef = plugin.managers.structure.hierarchy.current.structures.slice(-1)[0];
|
|
142635
142635
|
const structure = structureRef?.cell.obj?.data;
|
|
142636
142636
|
if (!structure) {
|
|
142637
|
-
console.warn("[MolSysViewer] add_pocket_surface
|
|
142637
|
+
console.warn("[MolSysViewer] add_pocket_surface: no structure loaded");
|
|
142638
142638
|
return void 0;
|
|
142639
142639
|
}
|
|
142640
142640
|
const subset = createSubsetFromAtomIndices(structure, options.atom_indices);
|
|
142641
142641
|
if (!subset || subset.elementCount === 0) {
|
|
142642
|
-
console.warn("[MolSysViewer] add_pocket_surface
|
|
142642
|
+
console.warn("[MolSysViewer] add_pocket_surface: no selected atoms");
|
|
142643
142643
|
return void 0;
|
|
142644
142644
|
}
|
|
142645
142645
|
const gaussianProps = getDefaultGaussianProps(options);
|
|
@@ -144078,6 +144078,7 @@ var bootPopup = async (loadedModule) => {
|
|
|
144078
144078
|
}
|
|
144079
144079
|
};
|
|
144080
144080
|
const container = document.getElementById("molsysviewer-pop");
|
|
144081
|
+
const loading = document.getElementById("molsysviewer-loading");
|
|
144081
144082
|
let isUserInteracting = false;
|
|
144082
144083
|
let wheelTimeout = null;
|
|
144083
144084
|
container?.addEventListener("pointerdown", () => {
|
|
@@ -144096,6 +144097,22 @@ var bootPopup = async (loadedModule) => {
|
|
|
144096
144097
|
isUserInteracting = false;
|
|
144097
144098
|
}, 200);
|
|
144098
144099
|
}, { passive: true });
|
|
144100
|
+
const revealViewer = () => {
|
|
144101
|
+
if (container) {
|
|
144102
|
+
container.style.opacity = "1";
|
|
144103
|
+
}
|
|
144104
|
+
if (loading) {
|
|
144105
|
+
loading.style.opacity = "0";
|
|
144106
|
+
loading.style.pointerEvents = "none";
|
|
144107
|
+
window.setTimeout(() => {
|
|
144108
|
+
try {
|
|
144109
|
+
loading.remove();
|
|
144110
|
+
} catch (e) {
|
|
144111
|
+
}
|
|
144112
|
+
}, 300);
|
|
144113
|
+
}
|
|
144114
|
+
};
|
|
144115
|
+
const revealTimer = window.setTimeout(revealViewer, 2500);
|
|
144099
144116
|
const popControllerPromise = (async () => {
|
|
144100
144117
|
await new Promise((r) => setTimeout(r, 100));
|
|
144101
144118
|
const ctrl2 = await MolSysViewerController2.create(container, (msg) => {
|
|
@@ -144157,6 +144174,8 @@ var bootPopup = async (loadedModule) => {
|
|
|
144157
144174
|
if (data.isSwingActive) await ctrl2.toggleSwing(true);
|
|
144158
144175
|
if (data.isDarkMode) await ctrl2.toggleBackground("dark");
|
|
144159
144176
|
if (data.autohide !== void 0) updateAutohide(!!data.autohide);
|
|
144177
|
+
window.clearTimeout(revealTimer);
|
|
144178
|
+
revealViewer();
|
|
144160
144179
|
break;
|
|
144161
144180
|
case "molsysviewer-sync-autohide":
|
|
144162
144181
|
updateAutohide(!!data.enabled);
|
|
@@ -144376,6 +144395,16 @@ var PopupHostManager = class {
|
|
|
144376
144395
|
this.close();
|
|
144377
144396
|
return;
|
|
144378
144397
|
}
|
|
144398
|
+
let resolvedModuleUrl = null;
|
|
144399
|
+
if (this.viewerModuleUrl) {
|
|
144400
|
+
try {
|
|
144401
|
+
resolvedModuleUrl = new URL(this.viewerModuleUrl, window.location.href).href;
|
|
144402
|
+
fetch(resolvedModuleUrl, { cache: "force-cache" }).catch(() => {
|
|
144403
|
+
});
|
|
144404
|
+
} catch (e) {
|
|
144405
|
+
resolvedModuleUrl = null;
|
|
144406
|
+
}
|
|
144407
|
+
}
|
|
144379
144408
|
this.popoutWin = window.open("", "_blank", "width=960,height=720");
|
|
144380
144409
|
if (!this.popoutWin) return;
|
|
144381
144410
|
this.isReady = false;
|
|
@@ -144388,8 +144417,11 @@ var PopupHostManager = class {
|
|
|
144388
144417
|
<meta charset="UTF-8" />
|
|
144389
144418
|
<title>MolSysViewer Popout</title>
|
|
144390
144419
|
<style>
|
|
144391
|
-
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #
|
|
144392
|
-
#molsysviewer-pop { position: relative; width: 100%; height: 100%; min-height: 400px; }
|
|
144420
|
+
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #f5f6f8; }
|
|
144421
|
+
#molsysviewer-pop { position: relative; width: 100%; height: 100%; min-height: 400px; opacity: 0; transition: opacity 240ms ease; }
|
|
144422
|
+
#molsysviewer-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #2b2f36; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; letter-spacing: 0.2px; }
|
|
144423
|
+
#molsysviewer-loading .spinner { width: 28px; height: 28px; border-radius: 999px; border: 3px solid rgba(0,0,0,0.12); border-top-color: rgba(0,0,0,0.45); animation: molsysviewer-spin 0.9s linear infinite; }
|
|
144424
|
+
@keyframes molsysviewer-spin { to { transform: rotate(360deg); } }
|
|
144393
144425
|
/* ... (styles kept same as before for brevity, assuming user wants robust logic) ... */
|
|
144394
144426
|
.molsysviewer-controls, .molsysviewer-controls * { user-select: none; -webkit-user-select: none; -moz-user-select: none; }
|
|
144395
144427
|
.molsysviewer-traj-input::-webkit-inner-spin-button,
|
|
@@ -144399,8 +144431,10 @@ var PopupHostManager = class {
|
|
|
144399
144431
|
.molsysviewer-slider::-webkit-slider-runnable-track { background: rgba(200,200,200,0.35) !important; height: 16px; border-radius: 999px; }
|
|
144400
144432
|
.molsysviewer-slider::-webkit-slider-thumb { -webkit-appearance: none !important; width: 16px; height: 16px; border-radius: 50% !important; background: rgba(0,0,0,0.5) !important; margin-top: 0px; }
|
|
144401
144433
|
</style>
|
|
144434
|
+
${resolvedModuleUrl ? `<link rel="modulepreload" href="${resolvedModuleUrl}">` : ""}
|
|
144402
144435
|
</head>
|
|
144403
144436
|
<body>
|
|
144437
|
+
<div id="molsysviewer-loading"><div class="spinner"></div><div>Loading viewer\u2026</div></div>
|
|
144404
144438
|
<div id="molsysviewer-pop"></div>
|
|
144405
144439
|
</body>
|
|
144406
144440
|
</html>
|
|
@@ -144410,11 +144444,10 @@ var PopupHostManager = class {
|
|
|
144410
144444
|
const scriptEl = doc.createElement("script");
|
|
144411
144445
|
scriptEl.type = "module";
|
|
144412
144446
|
if (this.viewerModuleUrl) {
|
|
144413
|
-
const resolved = new URL(this.viewerModuleUrl, window.location.href).href;
|
|
144414
144447
|
scriptEl.textContent = `
|
|
144415
144448
|
(async () => {
|
|
144416
144449
|
try {
|
|
144417
|
-
const module = await import("${
|
|
144450
|
+
const module = await import("${resolvedModuleUrl ?? ""}");
|
|
144418
144451
|
const boot = module.bootPopup || (module.default && module.default.bootPopup);
|
|
144419
144452
|
if (boot) {
|
|
144420
144453
|
boot(module);
|