supervision 0.2.0 → 0.2.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.
package/dist/index.js CHANGED
@@ -8501,11 +8501,20 @@ function createPixiInteractionLayer(options) {
8501
8501
  }
8502
8502
  return;
8503
8503
  }
8504
- setHoveredPick(pickFromPointerEvent(event));
8504
+ const hoverChanged = setHoveredPick(pickFromPointerEvent(event));
8505
+ if (!hoverChanged && editingEngine?.hasCreationTool()) {
8506
+ notifyStateChange();
8507
+ }
8505
8508
  }
8506
8509
  function handlePointerOut() {
8510
+ const hadPointer = pointerPoint !== null;
8507
8511
  pointerPoint = null;
8508
- setHoveredPick(null);
8512
+ const hoverChanged = setHoveredPick(null);
8513
+ if (!hoverChanged &&
8514
+ hadPointer &&
8515
+ options.editingEngine?.hasCreationTool()) {
8516
+ notifyStateChange();
8517
+ }
8509
8518
  }
8510
8519
  function handlePointerTap(event) {
8511
8520
  if (!canHandleInteraction()) {
@@ -8731,7 +8740,7 @@ function createPixiInteractionLayer(options) {
8731
8740
  ? hoverCursor(nextPick)
8732
8741
  : resolveIdleCursor();
8733
8742
  }
8734
- return;
8743
+ return false;
8735
8744
  }
8736
8745
  hoveredPick = nextPick;
8737
8746
  hoveredPickKey = nextKey;
@@ -8740,6 +8749,7 @@ function createPixiInteractionLayer(options) {
8740
8749
  }
8741
8750
  options.interaction.onHover?.(nextPick);
8742
8751
  notifyStateChange();
8752
+ return true;
8743
8753
  }
8744
8754
  function setSelectedPick(nextPick) {
8745
8755
  const nextKey = createDetectionPickKey(nextPick);
@@ -11205,6 +11215,8 @@ function createPixiMaskBrushPreview(options) {
11205
11215
  const cursor = new options.Graphics();
11206
11216
  const display = new options.Container();
11207
11217
  let viewportScale = 1;
11218
+ let isDestroyed = false;
11219
+ let invalidationQueued = false;
11208
11220
  sprite.width = editor.canvas.width;
11209
11221
  sprite.height = editor.canvas.height;
11210
11222
  sprite.alpha = options.preview.alpha ?? 0.4;
@@ -11212,9 +11224,13 @@ function createPixiMaskBrushPreview(options) {
11212
11224
  display.addChild(sprite, cursor);
11213
11225
  const updateTexture = () => {
11214
11226
  source.update();
11227
+ scheduleInvalidation();
11215
11228
  };
11216
11229
  const unsubscribeTexture = editor.subscribeTextureUpdates(updateTexture);
11217
- const unsubscribeCursor = editor.subscribeCursorUpdates(drawCursor);
11230
+ const unsubscribeCursor = editor.subscribeCursorUpdates(() => {
11231
+ drawCursor();
11232
+ scheduleInvalidation();
11233
+ });
11218
11234
  drawCursor();
11219
11235
  return {
11220
11236
  display,
@@ -11223,12 +11239,24 @@ function createPixiMaskBrushPreview(options) {
11223
11239
  drawCursor();
11224
11240
  },
11225
11241
  destroy() {
11242
+ isDestroyed = true;
11226
11243
  unsubscribeCursor();
11227
11244
  unsubscribeTexture();
11228
11245
  texture.destroy();
11229
11246
  source.destroy();
11230
11247
  },
11231
11248
  };
11249
+ function scheduleInvalidation() {
11250
+ const onInvalidate = options.onInvalidate;
11251
+ if (!onInvalidate || isDestroyed || invalidationQueued)
11252
+ return;
11253
+ invalidationQueued = true;
11254
+ queueMicrotask(() => {
11255
+ invalidationQueued = false;
11256
+ if (!isDestroyed)
11257
+ onInvalidate();
11258
+ });
11259
+ }
11232
11260
  function drawCursor() {
11233
11261
  cursor.clear();
11234
11262
  const state = editor.getCursor();
@@ -13070,16 +13098,6 @@ async function createPixiMediaScene(options) {
13070
13098
  resolveContextState: (detection) => resolveAnnotationStyleState(detection, currentVisibility),
13071
13099
  });
13072
13100
  const annotationOverlayLayer = createPixiAnnotationOverlayLayer(options.editingEngine, options.annotationOverlayStyle, options.keypointStyle);
13073
- const maskBrushPreview = options.maskBrush
13074
- ? createPixiMaskBrushPreview({
13075
- CanvasSource,
13076
- Container,
13077
- Graphics,
13078
- Sprite,
13079
- Texture,
13080
- preview: options.maskBrush,
13081
- })
13082
- : undefined;
13083
13101
  const initialMaskPreparationStyle = resolveMaskPreparationStyle();
13084
13102
  let maskLayer = initialMaskPreparationStyle
13085
13103
  ? createPixiMaskLayer({
@@ -13135,6 +13153,17 @@ async function createPixiMediaScene(options) {
13135
13153
  throw new Error("Unable to create staging canvas context.");
13136
13154
  }
13137
13155
  const renderScheduler = createSceneRenderScheduler(() => app.render());
13156
+ const maskBrushPreview = options.maskBrush
13157
+ ? createPixiMaskBrushPreview({
13158
+ CanvasSource,
13159
+ Container,
13160
+ Graphics,
13161
+ Sprite,
13162
+ Texture,
13163
+ preview: options.maskBrush,
13164
+ onInvalidate: frameChannel ? renderNow : undefined,
13165
+ })
13166
+ : undefined;
13138
13167
  let appliedPresentation;
13139
13168
  let mediaCompositor;
13140
13169
  let presentedFrameSerial = 0;