@antv/g-lite 1.2.4 → 1.2.6

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.js CHANGED
@@ -4910,16 +4910,16 @@ function convertToPath(object, transform) {
4910
4910
  var commands = [];
4911
4911
  switch (object.nodeName) {
4912
4912
  case exports.Shape.LINE:
4913
- var _a = object.parsedStyle, x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
4913
+ var _a = object.parsedStyle, _b = _a.x1, x1 = _b === void 0 ? 0 : _b, _c = _a.y1, y1 = _c === void 0 ? 0 : _c, _d = _a.x2, x2 = _d === void 0 ? 0 : _d, _e = _a.y2, y2 = _e === void 0 ? 0 : _e;
4914
4914
  commands = lineToCommands(x1, y1, x2, y2);
4915
4915
  break;
4916
4916
  case exports.Shape.CIRCLE: {
4917
- var _b = object.parsedStyle, r = _b.r, cx = _b.cx, cy = _b.cy;
4917
+ var _f = object.parsedStyle, _g = _f.r, r = _g === void 0 ? 0 : _g, _h = _f.cx, cx = _h === void 0 ? 0 : _h, _j = _f.cy, cy = _j === void 0 ? 0 : _j;
4918
4918
  commands = ellipseToCommands(r, r, cx, cy);
4919
4919
  break;
4920
4920
  }
4921
4921
  case exports.Shape.ELLIPSE: {
4922
- var _c = object.parsedStyle, rx = _c.rx, ry = _c.ry, cx = _c.cx, cy = _c.cy;
4922
+ var _k = object.parsedStyle, _l = _k.rx, rx = _l === void 0 ? 0 : _l, _m = _k.ry, ry = _m === void 0 ? 0 : _m, _o = _k.cx, cx = _o === void 0 ? 0 : _o, _p = _k.cy, cy = _p === void 0 ? 0 : _p;
4923
4923
  commands = ellipseToCommands(rx, ry, cx, cy);
4924
4924
  break;
4925
4925
  }
@@ -4929,7 +4929,7 @@ function convertToPath(object, transform) {
4929
4929
  commands = polygonToCommands(points.points, object.nodeName === exports.Shape.POLYGON);
4930
4930
  break;
4931
4931
  case exports.Shape.RECT:
4932
- var _d = object.parsedStyle, width_1 = _d.width, height_1 = _d.height, x = _d.x, y = _d.y, radius = _d.radius;
4932
+ var _q = object.parsedStyle, _r = _q.width, width_1 = _r === void 0 ? 0 : _r, _s = _q.height, height_1 = _s === void 0 ? 0 : _s, _t = _q.x, x = _t === void 0 ? 0 : _t, _u = _q.y, y = _u === void 0 ? 0 : _u, radius = _q.radius;
4933
4933
  var hasRadius = radius && radius.some(function (r) { return r !== 0; });
4934
4934
  commands = rectToCommands(width_1, height_1, x, y, hasRadius &&
4935
4935
  radius.map(function (r) {
@@ -8219,7 +8219,6 @@ var TextUpdater = /** @class */ (function () {
8219
8219
  TextUpdater.prototype.update = function (parsedStyle, object) {
8220
8220
  var _a, _b;
8221
8221
  var text = parsedStyle.text, textAlign = parsedStyle.textAlign, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, dx = parsedStyle.dx, dy = parsedStyle.dy;
8222
- var offscreenCanvas = (((_b = (_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getConfig()) || {}).offscreenCanvas;
8223
8222
  if (!this.isReadyToMeasure(parsedStyle, object)) {
8224
8223
  parsedStyle.metrics = {
8225
8224
  font: '',
@@ -8245,6 +8244,7 @@ var TextUpdater = /** @class */ (function () {
8245
8244
  offsetY: 0,
8246
8245
  };
8247
8246
  }
8247
+ var offscreenCanvas = (((_b = (_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getConfig()) || {}).offscreenCanvas;
8248
8248
  var metrics = this.globalRuntime.textService.measureText(text, parsedStyle, offscreenCanvas);
8249
8249
  parsedStyle.metrics = metrics;
8250
8250
  var width = metrics.width, height = metrics.height, lineHeight = metrics.lineHeight, fontProperties = metrics.fontProperties;
@@ -9910,8 +9910,8 @@ var OffscreenCanvasCreator = /** @class */ (function () {
9910
9910
  return this.canvas;
9911
9911
  }
9912
9912
  // user-defined offscreen canvas
9913
- if (offscreenCanvas) {
9914
- this.canvas = offscreenCanvas;
9913
+ if (offscreenCanvas || runtime.offscreenCanvas) {
9914
+ this.canvas = offscreenCanvas || runtime.offscreenCanvas;
9915
9915
  this.context = this.canvas.getContext('2d', contextAttributes);
9916
9916
  }
9917
9917
  else {
@@ -11188,8 +11188,8 @@ var TextService = /** @class */ (function () {
11188
11188
  descent: 0,
11189
11189
  fontSize: 0,
11190
11190
  };
11191
- var canvas = this.runtime.offscreenCanvas.getOrCreateCanvas(offscreenCanvas);
11192
- var context = this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas, {
11191
+ var canvas = this.runtime.offscreenCanvasCreator.getOrCreateCanvas(offscreenCanvas);
11192
+ var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas, {
11193
11193
  willReadFrequently: true,
11194
11194
  });
11195
11195
  context.font = font;
@@ -11274,7 +11274,7 @@ var TextService = /** @class */ (function () {
11274
11274
  // fontSize,
11275
11275
  // };
11276
11276
  // }
11277
- var context = this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);
11277
+ var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
11278
11278
  context.font = font;
11279
11279
  // no overflowing by default
11280
11280
  parsedStyle.isOverflowing = false;
@@ -11372,7 +11372,7 @@ var TextService = /** @class */ (function () {
11372
11372
  TextService.prototype.wordWrap = function (text, parsedStyle, offscreenCanvas) {
11373
11373
  var _this = this;
11374
11374
  var _a = parsedStyle.wordWrapWidth, wordWrapWidth = _a === void 0 ? 0 : _a, letterSpacing = parsedStyle.letterSpacing, _b = parsedStyle.maxLines, maxLines = _b === void 0 ? Infinity : _b, textOverflow = parsedStyle.textOverflow;
11375
- var context = this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);
11375
+ var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
11376
11376
  var maxWidth = wordWrapWidth + letterSpacing;
11377
11377
  var ellipsis = '';
11378
11378
  if (textOverflow === 'ellipsis') {
@@ -11571,10 +11571,10 @@ var getGlobalThis = function () {
11571
11571
  // @ts-ignore
11572
11572
  if (typeof global !== 'undefined')
11573
11573
  return global;
11574
+ return {};
11574
11575
  // [!] Error: The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
11575
11576
  // @see https://rollupjs.org/troubleshooting/#error-this-is-undefined
11576
11577
  // if (typeof this !== 'undefined') return this;
11577
- throw new Error('Unable to locate global `this`');
11578
11578
  };
11579
11579
  /**
11580
11580
  * Camera
@@ -11586,7 +11586,7 @@ runtime.CameraContribution = Camera;
11586
11586
  */
11587
11587
  runtime.AnimationTimeline = null;
11588
11588
  runtime.EasingFunction = null;
11589
- runtime.offscreenCanvas = new OffscreenCanvasCreator();
11589
+ runtime.offscreenCanvasCreator = new OffscreenCanvasCreator();
11590
11590
  runtime.nativeHTMLMap = new WeakMap();
11591
11591
  runtime.sceneGraphSelector = new DefaultSceneGraphSelector();
11592
11592
  runtime.sceneGraphService = new DefaultSceneGraphService(runtime);
@@ -14918,6 +14918,10 @@ var Canvas = /** @class */ (function (_super) {
14918
14918
  canvasWidth = width || getWidth(canvas) || canvas.width / dpr;
14919
14919
  canvasHeight = height || getHeight(canvas) || canvas.height / dpr;
14920
14920
  }
14921
+ // override it in runtime
14922
+ if (offscreenCanvas) {
14923
+ runtime.offscreenCanvas = offscreenCanvas;
14924
+ }
14921
14925
  /**
14922
14926
  * implements `Window` interface
14923
14927
  */