@rm-graph/core 0.1.6 → 0.1.7

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.mjs CHANGED
@@ -448,17 +448,32 @@ var Surface3DChart = class {
448
448
  * Create the SciChart 3D surface
449
449
  */
450
450
  async createSurface() {
451
- if (!this.container) {
452
- throw new Error("Container not set");
451
+ if (this.isDestroyed || !this.container) {
452
+ return;
453
453
  }
454
454
  if (!this.container.id) {
455
455
  this.container.id = this.id;
456
456
  }
457
- const { sciChart3DSurface, wasmContext } = await SciChart3DSurface.create(
458
- this.container.id
459
- );
460
- if (this.isDestroyed) {
461
- sciChart3DSurface.delete();
457
+ if (!document.body.contains(this.container)) {
458
+ return;
459
+ }
460
+ let sciChart3DSurface;
461
+ let wasmContext;
462
+ try {
463
+ const result = await SciChart3DSurface.create(
464
+ this.container.id
465
+ );
466
+ sciChart3DSurface = result.sciChart3DSurface;
467
+ wasmContext = result.wasmContext;
468
+ } catch (e) {
469
+ console.warn("Surface3DChart: Failed to create surface", e);
470
+ return;
471
+ }
472
+ if (this.isDestroyed || !this.container) {
473
+ try {
474
+ sciChart3DSurface.delete();
475
+ } catch (e) {
476
+ }
462
477
  return;
463
478
  }
464
479
  this.surface = sciChart3DSurface;
@@ -668,20 +683,35 @@ var Column3DChart = class {
668
683
  * Create the SciChart 3D surface
669
684
  */
670
685
  async createSurface() {
671
- if (!this.container) {
672
- throw new Error("Container not set");
686
+ if (this.isDestroyed || !this.container) {
687
+ return;
673
688
  }
674
689
  if (!this.container.id) {
675
690
  this.container.id = this.id;
676
691
  }
677
- const { sciChart3DSurface, wasmContext } = await SciChart3DSurface.create(
678
- this.container.id,
679
- {
680
- isZYPlaneVisible: false
692
+ if (!document.body.contains(this.container)) {
693
+ return;
694
+ }
695
+ let sciChart3DSurface;
696
+ let wasmContext;
697
+ try {
698
+ const result = await SciChart3DSurface.create(
699
+ this.container.id,
700
+ {
701
+ isZYPlaneVisible: false
702
+ }
703
+ );
704
+ sciChart3DSurface = result.sciChart3DSurface;
705
+ wasmContext = result.wasmContext;
706
+ } catch (e) {
707
+ console.warn("Column3DChart: Failed to create surface", e);
708
+ return;
709
+ }
710
+ if (this.isDestroyed || !this.container) {
711
+ try {
712
+ sciChart3DSurface.delete();
713
+ } catch (e) {
681
714
  }
682
- );
683
- if (this.isDestroyed) {
684
- sciChart3DSurface.delete();
685
715
  return;
686
716
  }
687
717
  this.surface = sciChart3DSurface;
@@ -1077,15 +1107,34 @@ var PRPDChart = class {
1077
1107
  * Create the SciChart surface
1078
1108
  */
1079
1109
  async createSurface() {
1080
- if (!this.container || !this.chartHost) {
1081
- throw new Error("Container not set");
1110
+ if (this.isDestroyed || !this.container || !this.chartHost) {
1111
+ return;
1112
+ }
1113
+ if (!document.body.contains(this.container)) {
1114
+ return;
1082
1115
  }
1083
1116
  configureSciChartCDN();
1084
1117
  const theme = createPRPDTheme();
1085
- const { sciChartSurface, wasmContext } = await SciChartSurface.create(
1086
- this.chartHost,
1087
- { theme }
1088
- );
1118
+ let sciChartSurface;
1119
+ let wasmContext;
1120
+ try {
1121
+ const result = await SciChartSurface.create(
1122
+ this.chartHost,
1123
+ { theme }
1124
+ );
1125
+ sciChartSurface = result.sciChartSurface;
1126
+ wasmContext = result.wasmContext;
1127
+ } catch (e) {
1128
+ console.warn("PRPDChart: Failed to create surface", e);
1129
+ return;
1130
+ }
1131
+ if (this.isDestroyed || !this.container) {
1132
+ try {
1133
+ sciChartSurface.delete();
1134
+ } catch (e) {
1135
+ }
1136
+ return;
1137
+ }
1089
1138
  this.surface = sciChartSurface;
1090
1139
  this.wasmContext = wasmContext;
1091
1140
  const verticalScaleMax = this.config.maxPeak || VERTICAL_SCALE_MAX_DEFAULT;