@idetik/core 0.26.0 → 0.27.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/index.d.ts CHANGED
@@ -386,6 +386,7 @@ declare abstract class Layer {
386
386
  abstract readonly type: string;
387
387
  private objects_;
388
388
  private state_;
389
+ private attached_;
389
390
  private readonly callbacks_;
390
391
  private opacity_;
391
392
  blendMode: BlendMode;
@@ -394,8 +395,10 @@ declare abstract class Layer {
394
395
  set opacity(value: number);
395
396
  abstract update(context?: RenderContext): void;
396
397
  onEvent(_: EventContext): void;
397
- onAttached(_context: IdetikContext): void;
398
- onDetached(_context: IdetikContext): void;
398
+ onAttached(context: IdetikContext): void;
399
+ onDetached(context: IdetikContext): void;
400
+ protected attach(_context: IdetikContext): void;
401
+ protected detach(_context: IdetikContext): void;
399
402
  get objects(): RenderableObject[];
400
403
  get state(): LayerState;
401
404
  addStateChangeCallback(callback: StateChangeCallback): void;
@@ -1365,8 +1368,8 @@ declare class ImageLayer extends Layer implements ChannelsEnabled {
1365
1368
  private lastPresentationTimeCoord_?;
1366
1369
  private readonly wireframeColors_;
1367
1370
  constructor({ source, sliceCoords, policy, channelProps, onPickValue, ...layerOptions }: ImageLayerProps);
1368
- onAttached(context: IdetikContext): void;
1369
- onDetached(_context: IdetikContext): void;
1371
+ protected attach(context: IdetikContext): void;
1372
+ protected detach(_context: IdetikContext): void;
1370
1373
  update(context?: RenderContext): void;
1371
1374
  private updateChunks;
1372
1375
  hasMultipleLODs(): boolean;
@@ -1432,8 +1435,8 @@ declare class VolumeLayer extends Layer implements ChannelsEnabled {
1432
1435
  removeChannelChangeCallback(callback: () => void): void;
1433
1436
  constructor({ source, sliceCoords, policy, channelProps }: VolumeLayerProps);
1434
1437
  private getOrCreateVolume;
1435
- onAttached(context: IdetikContext): void;
1436
- onDetached(_context: IdetikContext): void;
1438
+ protected attach(context: IdetikContext): void;
1439
+ protected detach(_context: IdetikContext): void;
1437
1440
  private updateChunks;
1438
1441
  private updateVolumeTransform;
1439
1442
  private releaseAndRemoveVolume;
@@ -1476,8 +1479,8 @@ declare class LabelLayer extends Layer {
1476
1479
  private lastPresentationTimeStamp_?;
1477
1480
  private lastPresentationTimeCoord_?;
1478
1481
  constructor({ source, sliceCoords, policy, colorMap, onPickValue, outlineSelected, ...layerOptions }: LabelLayerProps);
1479
- onAttached(context: IdetikContext): void;
1480
- onDetached(_context: IdetikContext): void;
1482
+ protected attach(context: IdetikContext): void;
1483
+ protected detach(_context: IdetikContext): void;
1481
1484
  update(context?: RenderContext): void;
1482
1485
  private updateChunks;
1483
1486
  private isPresentationStale;
package/dist/index.js CHANGED
@@ -9439,7 +9439,7 @@ class Oo {
9439
9439
  return this.layers_;
9440
9440
  }
9441
9441
  addLayer(A) {
9442
- this.layers_.push(A), A.onAttached(this.context_);
9442
+ A.onAttached(this.context_), this.layers_.push(A);
9443
9443
  }
9444
9444
  removeLayer(A) {
9445
9445
  const I = this.layers_.indexOf(A);
@@ -18455,6 +18455,7 @@ class MI {
18455
18455
  class Jg {
18456
18456
  objects_ = [];
18457
18457
  state_ = "initialized";
18458
+ attached_ = !1;
18458
18459
  callbacks_ = [];
18459
18460
  opacity_;
18460
18461
  blendMode;
@@ -18473,8 +18474,18 @@ class Jg {
18473
18474
  onEvent(A) {
18474
18475
  }
18475
18476
  onAttached(A) {
18477
+ if (this.attached_)
18478
+ throw new Error(
18479
+ `${this.type} cannot be attached to multiple viewports simultaneously.`
18480
+ );
18481
+ this.attach(A), this.attached_ = !0;
18476
18482
  }
18477
18483
  onDetached(A) {
18484
+ this.attached_ && (this.detach(A), this.attached_ = !1);
18485
+ }
18486
+ attach(A) {
18487
+ }
18488
+ detach(A) {
18478
18489
  }
18479
18490
  get objects() {
18480
18491
  return this.objects_;
@@ -18953,11 +18964,7 @@ class DE extends Jg {
18953
18964
  }) {
18954
18965
  super(E), this.setState("initialized"), this.source_ = A, this.policy_ = g, this.sliceCoords_ = I, this.channelProps_ = B, this.initialChannelProps_ = B, this.onPickValue_ = Q;
18955
18966
  }
18956
- onAttached(A) {
18957
- if (this.chunkStoreView_)
18958
- throw new Error(
18959
- "ImageLayer cannot be attached to multiple viewports simultaneously."
18960
- );
18967
+ attach(A) {
18961
18968
  this.chunkStoreView_ = A.chunkManager.addView(
18962
18969
  this.source_,
18963
18970
  this.policy_
@@ -18968,8 +18975,8 @@ class DE extends Jg {
18968
18975
  `ImageLayer requires exactly one channel in sliceCoords.c for multi-channel sources (found ${I} channels). Use one layer per channel.`
18969
18976
  );
18970
18977
  }
18971
- onDetached(A) {
18972
- this.chunkStoreView_ && (this.releaseAndRemoveChunks(this.visibleChunks_.keys()), this.clearObjects(), this.chunkStoreView_.dispose(), this.chunkStoreView_ = void 0);
18978
+ detach(A) {
18979
+ this.releaseAndRemoveChunks(this.visibleChunks_.keys()), this.clearObjects(), this.chunkStoreView_?.dispose(), this.chunkStoreView_ = void 0;
18973
18980
  }
18974
18981
  update(A) {
18975
18982
  if (!(!A || !this.chunkStoreView_)) {
@@ -19377,11 +19384,7 @@ class Ua extends Jg {
19377
19384
  for (const E of I) Q.updateVolumeWithChunk(E);
19378
19385
  return this.updateVolumeTransform(Q, I[0]), Q;
19379
19386
  }
19380
- onAttached(A) {
19381
- if (this.chunkStoreView_)
19382
- throw new Error(
19383
- "VolumeLayer cannot be attached to multiple viewports simultaneously."
19384
- );
19387
+ attach(A) {
19385
19388
  this.chunkStoreView_ = A.chunkManager.addView(
19386
19389
  this.source_,
19387
19390
  this.sourcePolicy_
@@ -19390,12 +19393,10 @@ class Ua extends Jg {
19390
19393
  this.chunkStoreView_.channelCount
19391
19394
  );
19392
19395
  }
19393
- onDetached(A) {
19394
- if (this.chunkStoreView_) {
19395
- for (const I of this.currentVolumes_.values())
19396
- this.releaseAndRemoveVolume(I);
19397
- this.clearObjects(), this.chunkStoreView_.dispose(), this.chunkStoreView_ = void 0;
19398
- }
19396
+ detach(A) {
19397
+ for (const I of this.currentVolumes_.values())
19398
+ this.releaseAndRemoveVolume(I);
19399
+ this.clearObjects(), this.chunkStoreView_?.dispose(), this.chunkStoreView_ = void 0;
19399
19400
  }
19400
19401
  updateChunks() {
19401
19402
  if (!this.chunkStoreView_) return;
@@ -19633,11 +19634,7 @@ class hE extends Jg {
19633
19634
  }) {
19634
19635
  super(i), this.setState("initialized"), this.source_ = A, this.policy_ = g, this.sliceCoords_ = I, this.colorMap_ = new aQ(B), this.onPickValue_ = Q, this.outlineSelected_ = E;
19635
19636
  }
19636
- onAttached(A) {
19637
- if (this.chunkStoreView_)
19638
- throw new Error(
19639
- "LabelLayer cannot be attached to multiple viewports simultaneously."
19640
- );
19637
+ attach(A) {
19641
19638
  if (this.chunkStoreView_ = A.chunkManager.addView(
19642
19639
  this.source_,
19643
19640
  this.policy_
@@ -19646,8 +19643,8 @@ class hE extends Jg {
19646
19643
  `LabelLayer does not support multi-channel sources (found ${this.chunkStoreView_.channelCount} channels). Label data must be single-channel.`
19647
19644
  );
19648
19645
  }
19649
- onDetached(A) {
19650
- this.chunkStoreView_ && (this.releaseAndRemoveChunks(this.visibleChunks_.keys()), this.clearObjects(), this.chunkStoreView_.dispose(), this.chunkStoreView_ = void 0);
19646
+ detach(A) {
19647
+ this.releaseAndRemoveChunks(this.visibleChunks_.keys()), this.clearObjects(), this.chunkStoreView_?.dispose(), this.chunkStoreView_ = void 0;
19651
19648
  }
19652
19649
  update(A) {
19653
19650
  if (!(!A || !this.chunkStoreView_)) {