hyperbrew / bolt-cep

A lightning-fast boilerplate for building Adobe CEP Extensions in React, Vue, or Svelte built on Vite + TypeScript + Sass
MIT License
318 stars 40 forks source link

Cannot call a class as a function #133

Open njho opened 4 months ago

njho commented 4 months ago

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 commented 4 months ago

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