ocp-viewer-core 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocp-viewer-core",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Shared viewer policy for ocp_vscode, ocp_viewer, Jupyter CadQuery and build123d Studio",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/page.js CHANGED
@@ -455,7 +455,7 @@ export function createPage({
455
455
  }
456
456
  // One dispatch for every key, shared with every other host, so
457
457
  // that a setter cannot exist in one client and not another.
458
- applyConfig(viewer, data.config, {
458
+ const applied = applyConfig(viewer, data.config, {
459
459
  // Only the host knows the other two dimensions, so a
460
460
  // viewport key is a resize rather than a setter.
461
461
  resize: (key, value) => {
@@ -475,6 +475,26 @@ export function createPage({
475
475
  debugLog(`ui: no setter for '${key}'`);
476
476
  }
477
477
  });
478
+ // The viewer changed; _config follows, for exactly the applied
479
+ // keys. Without this the two disagree, and resize() - a window
480
+ // resize, a splitter drag, Studio's pane observer on every Run -
481
+ // re-derives geometry from the value the ui call just replaced:
482
+ // set_viewer_config(glass=False) held until the next resize
483
+ // snapped glass back on. Same family: tools, treeWidth, theme.
484
+ for (const key of applied) {
485
+ _config[key] = data.config[key];
486
+ }
487
+ // Glass and tools decide whether the tree sits over the canvas or
488
+ // beside it, and three-cad-viewer re-lays out with the `cadWidth`
489
+ // it was given: leaving glass mode grows the viewer by `treeWidth`
490
+ // where the canvas should have shrunk by it, so it overflows the
491
+ // pane until something else happens to resize it. The host owns
492
+ // the other two dimensions, so it re-derives all three here, the
493
+ // way a window resize does - `_config` carries the new value by
494
+ // now, which is what `normalizeWidth` reads.
495
+ if (applied.includes("glass") || applied.includes("tools")) {
496
+ resize();
497
+ }
478
498
  } else if (data.type === "animation") {
479
499
  // Explode goes off first: both transform the same objects,
480
500
  // and animating an already-displaced model is wrong.
package/src/version.js CHANGED
@@ -24,4 +24,4 @@
24
24
  limitations under the License.
25
25
  */
26
26
 
27
- export const VERSION = "1.0.2";
27
+ export const VERSION = "1.0.4";