ocp-viewer-core 1.0.3 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocp-viewer-core",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
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",
@@ -11,7 +11,7 @@
11
11
  "src"
12
12
  ],
13
13
  "peerDependencies": {
14
- "three-cad-viewer": ">=5.0.3 <5.1.0"
14
+ "three-cad-viewer": ">=5.1.0 <5.2.0"
15
15
  },
16
16
  "license": "Apache-2.0",
17
17
  "author": "Bernhard Walter <b_walter@arcor.de>",
package/src/notify.js CHANGED
@@ -45,6 +45,9 @@ export const EVENT_KEYS = new Set([
45
45
  "lastPick",
46
46
  "activeTool",
47
47
  "relative_time",
48
+ // three-cad-viewer 5.1: the point Ctrl/Cmd-C copied, for hosts whose page
49
+ // cannot reach the clipboard. A copy, not a property of the viewer.
50
+ "copiedPoint",
48
51
  ]);
49
52
 
50
53
  /**
package/src/page.js CHANGED
@@ -237,9 +237,21 @@ export function createPage({
237
237
  if (getSize != null) {
238
238
  return getSize();
239
239
  }
240
+ // The window, less the container's own offset in it - a page's body
241
+ // margin - above it and, for the same margin, below it. The chrome is
242
+ // measured from the container's top, so an offset of the container
243
+ // itself was counted nowhere: the standalone page keeps the browser's
244
+ // 8px body margin, and its canvas ended 8px under the window edge,
245
+ // cutting the status line pinned to `bottom: 4px` inside it. A VS Code
246
+ // webview's body has no margin, so its offset is 0.
247
+ const element = getContainer();
248
+ const top =
249
+ element == null
250
+ ? 0
251
+ : Math.max(0, Math.round(element.getBoundingClientRect().top));
240
252
  return {
241
253
  width: window.innerWidth,
242
- height: window.innerHeight
254
+ height: window.innerHeight - 2 * top
243
255
  };
244
256
  }
245
257
 
@@ -484,6 +496,17 @@ export function createPage({
484
496
  for (const key of applied) {
485
497
  _config[key] = data.config[key];
486
498
  }
499
+ // Glass and tools decide whether the tree sits over the canvas or
500
+ // beside it, and three-cad-viewer re-lays out with the `cadWidth`
501
+ // it was given: leaving glass mode grows the viewer by `treeWidth`
502
+ // where the canvas should have shrunk by it, so it overflows the
503
+ // pane until something else happens to resize it. The host owns
504
+ // the other two dimensions, so it re-derives all three here, the
505
+ // way a window resize does - `_config` carries the new value by
506
+ // now, which is what `normalizeWidth` reads.
507
+ if (applied.includes("glass") || applied.includes("tools")) {
508
+ resize();
509
+ }
487
510
  } else if (data.type === "animation") {
488
511
  // Explode goes off first: both transform the same objects,
489
512
  // 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.3";
27
+ export const VERSION = "1.1.0";