@leapfrog/interactive-canvas 2.0.21 → 2.0.22-beta-2

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.
@@ -1,6 +1,7 @@
1
1
  import _, { round, each, values, reduce, clone, max, isEqual } from 'lodash';
2
2
  import { BehaviorSubject, Subject } from 'rxjs';
3
3
  import * as fabric from 'fabric';
4
+ import { StaticCanvas } from 'fabric/node';
4
5
 
5
6
  const PIXELS_PER_MM$2 = 3.937;
6
7
  class MillimeterDimensions {
@@ -3735,7 +3736,12 @@ class SelectionData {
3735
3736
 
3736
3737
  class HeadlessInteractiveCanvas extends AbstractInteractiveCanvas {
3737
3738
  constructor() {
3738
- super(fabric, new fabric.StaticCanvas(undefined, { width: 640, height: 480 }), 0);
3739
+ //super(fabric, new StaticCanvas(null as any, {width: 640, height: 480}) as unknown as Canvas, 0);
3740
+ const isNode = typeof window === "undefined";
3741
+ const canvas = isNode
3742
+ ? new StaticCanvas(null, { width: 640, height: 480 })
3743
+ : new fabric.StaticCanvas(undefined, { width: 640, height: 480 });
3744
+ super(fabric, canvas, 0);
3739
3745
  this.headless = true;
3740
3746
  }
3741
3747
  /**
@@ -3,6 +3,7 @@
3
3
  var _ = require('lodash');
4
4
  var rxjs = require('rxjs');
5
5
  var fabric = require('fabric');
6
+ var node = require('fabric/node');
6
7
 
7
8
  function _interopNamespaceDefault(e) {
8
9
  var n = Object.create(null);
@@ -3756,7 +3757,12 @@ class SelectionData {
3756
3757
 
3757
3758
  class HeadlessInteractiveCanvas extends AbstractInteractiveCanvas {
3758
3759
  constructor() {
3759
- super(fabric__namespace, new fabric__namespace.StaticCanvas(undefined, { width: 640, height: 480 }), 0);
3760
+ //super(fabric, new StaticCanvas(null as any, {width: 640, height: 480}) as unknown as Canvas, 0);
3761
+ const isNode = typeof window === "undefined";
3762
+ const canvas = isNode
3763
+ ? new node.StaticCanvas(null, { width: 640, height: 480 })
3764
+ : new fabric__namespace.StaticCanvas(undefined, { width: 640, height: 480 });
3765
+ super(fabric__namespace, canvas, 0);
3760
3766
  this.headless = true;
3761
3767
  }
3762
3768
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leapfrog/interactive-canvas",
3
- "version": "2.0.21",
3
+ "version": "2.0.22-beta-2",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"