Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call a class as a function #133

Open
njho opened this issue Jul 5, 2024 · 1 comment
Open

Cannot call a class as a function #133

njho opened this issue Jul 5, 2024 · 1 comment

Comments

@njho
Copy link

njho commented Jul 5, 2024

Hi,

Have any of you bumped into issue with Classes returning cannot call a class as a function?
The odd thing is that it works on my Mac and PC, but when I send the ZXP to a coworker, it catches with this error: 'Cannot call a class as a function'

Compiled Code

  function _classCallCheck(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
      throw new TypeError('Cannot call a class as a function');
    }
  }
  var CoordPair = /*#__PURE__*/ _createClass(function CoordPair(coordPair) {
  _classCallCheck(this, CoordPair);
  _defineProperty$1(this, 'coordPoints', void 0);
  _defineProperty$1(this, 'type', void 0);
  _defineProperty$1(this, 'id', void 0);
  _defineProperty$1(this, 'snap', void 0);
  _defineProperty$1(this, 'start', void 0);
  _defineProperty$1(this, 'end', void 0);
  _defineProperty$1(this, 'scale', void 0);
  _defineProperty$1(this, 'threeStack', void 0);
  _defineProperty$1(this, 'scaleHold', void 0);
  _defineProperty$1(this, 'twoStack', void 0);
  _defineProperty$1(this, 'positionHold', void 0);
  // ['lin' | 'bez', string, number[], number, boolean, boolean, any]
  var type = coordPair.type,
    id = coordPair.id,
    coord1 = coordPair.coord1,
    coord2 = coordPair.coord2,
    scale = coordPair.scale,
    three_stack = coordPair.three_stack;
  var coordPoints = [];
  if (type === 'bez') {
    var handle1 = coordPair.handle1,
      handle2 = coordPair.handle2;
    coordPoints.push(
      new BezPt({
        coord: coord1,
        handle: handle1,
      }),
    );
    coordPoints.push(
      new BezPt({
        coord: coord2,
        handle: handle2,
      }),
    );
  } else {
    coordPoints.push(new LinPt(coord1));
    coordPoints.push(new LinPt(coord2));
  }
  this.id = id;
  this.type = type;
  this.snap = false;
  this.coordPoints = coordPoints;
  this.scale = scale;
  this.threeStack = three_stack; // Needs to be set
  this.twoStack = false; // Needs to be set
  this.scaleHold = true; // Needs to be set
  this.positionHold = false; // Needs to be set
  this.start = coordPoints[0];
  this.end = coordPoints[1];
});

CoordPair.ts


export class CoordPair {
coordPoints: any;
type: 'lin' | 'bez';
id: string;
snap: boolean;
start: BezPt | LinPt;
end: BezPt | LinPt;
scale: number;
threeStack: boolean;
scaleHold: boolean;
twoStack: boolean;
positionHold: boolean;

constructor(
  coordPair:
    | DBType.Scene.AEData.LinCoordPair
    | DBType.Scene.AEData.BezCoordPair,
) {
  // ['lin' | 'bez', string, number[], number, boolean, boolean, any]
  const { type, id, coord1, coord2, scale, three_stack } = coordPair;

  let coordPoints = [];

  if (type === 'bez') {
    const { handle1, handle2 } = coordPair;
    coordPoints.push(
      new BezPt({
        coord: coord1,
        handle: handle1,
      }),
    );
    coordPoints.push(
      new BezPt({
        coord: coord2,
        handle: handle2,
      }),
    );
  } else {
    coordPoints.push(new LinPt(coord1));
    coordPoints.push(new LinPt(coord2));
  }

  this.id = id;
  this.type = type;
  this.snap = false;
  this.coordPoints = coordPoints;
  this.scale = scale;
  this.threeStack = three_stack; // Needs to be set
  this.twoStack = false; // Needs to be set
  this.scaleHold = true; // Needs to be set
  this.positionHold = false; // Needs to be set
  this.start = coordPoints[0];
  this.end = coordPoints[1];
}
}

Thank you

@justintaylor-dev
Copy link
Contributor

Likely Babel settings in vite.es.config.ts need to be tweaked to allow this sort of OOP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants