ocp-viewer-core 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/page.js +13 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocp-viewer-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
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
@@ -302,7 +302,11 @@ export function createPage({
302
302
  * function rather than a listener body.
303
303
  */
304
304
  function resize() {
305
- if (viewer != null) {
305
+ // `ready` and not only null: clear() returns the viewer to its
306
+ // never-rendered state, where resizeCadView throws - a splitter drag
307
+ // over an emptied pane must not be an error. The next show measures
308
+ // the surface for itself, so a skipped resize here loses nothing.
309
+ if (viewer != null && viewer.ready === true) {
306
310
  const displayOptions = getDisplayOptions(_config.theme);
307
311
  viewer.resizeCadView(
308
312
  displayOptions.cadWidth,
@@ -399,6 +403,14 @@ export function createPage({
399
403
  // ever needs to re-render what it already has, that is `showViewer(
400
404
  // _meshData, _config)` guarded on `_meshData` being present.
401
405
  } else if (data.type === "ui") {
406
+ // Nothing on screen is a normal state now that show_clear exists,
407
+ // and most setters read the rendered scene and throw without one.
408
+ // Said rather than silent: in this ecosystem a dropped config is
409
+ // the hardest thing to debug.
410
+ if (viewer == null || viewer.ready !== true) {
411
+ debugLog("ui: no model on screen, config not applied");
412
+ return;
413
+ }
402
414
  if (_config["_splash"]) {
403
415
  return;
404
416
  }