@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/global-runtime.d.ts +3 -2
- package/dist/index.esm.js +17 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17 -13
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/global-runtime.d.ts
CHANGED
|
@@ -6,13 +6,14 @@ import { PropertySyntax } from './css/interfaces';
|
|
|
6
6
|
import type { HTML } from './display-objects';
|
|
7
7
|
import type { GeometryAABBUpdater, SceneGraphSelector, SceneGraphService } from './services';
|
|
8
8
|
import { OffscreenCanvasCreator, TextService } from './services';
|
|
9
|
-
import { Shape } from './types';
|
|
9
|
+
import { CanvasLike, Shape } from './types';
|
|
10
10
|
export declare const runtime: GlobalRuntime;
|
|
11
11
|
export interface GlobalRuntime {
|
|
12
12
|
CameraContribution: new () => Camera;
|
|
13
13
|
AnimationTimeline: any;
|
|
14
14
|
EasingFunction: (...args: any[]) => (t: number) => number;
|
|
15
|
-
|
|
15
|
+
offscreenCanvasCreator: OffscreenCanvasCreator;
|
|
16
|
+
offscreenCanvas: CanvasLike;
|
|
16
17
|
sceneGraphSelector: SceneGraphSelector;
|
|
17
18
|
sceneGraphService: SceneGraphService;
|
|
18
19
|
textService: TextService;
|
package/dist/index.esm.js
CHANGED
|
@@ -4889,16 +4889,16 @@ function convertToPath(object, transform) {
|
|
|
4889
4889
|
var commands = [];
|
|
4890
4890
|
switch (object.nodeName) {
|
|
4891
4891
|
case Shape.LINE:
|
|
4892
|
-
var _a = object.parsedStyle,
|
|
4892
|
+
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;
|
|
4893
4893
|
commands = lineToCommands(x1, y1, x2, y2);
|
|
4894
4894
|
break;
|
|
4895
4895
|
case Shape.CIRCLE: {
|
|
4896
|
-
var
|
|
4896
|
+
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;
|
|
4897
4897
|
commands = ellipseToCommands(r, r, cx, cy);
|
|
4898
4898
|
break;
|
|
4899
4899
|
}
|
|
4900
4900
|
case Shape.ELLIPSE: {
|
|
4901
|
-
var
|
|
4901
|
+
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;
|
|
4902
4902
|
commands = ellipseToCommands(rx, ry, cx, cy);
|
|
4903
4903
|
break;
|
|
4904
4904
|
}
|
|
@@ -4908,7 +4908,7 @@ function convertToPath(object, transform) {
|
|
|
4908
4908
|
commands = polygonToCommands(points.points, object.nodeName === Shape.POLYGON);
|
|
4909
4909
|
break;
|
|
4910
4910
|
case Shape.RECT:
|
|
4911
|
-
var
|
|
4911
|
+
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;
|
|
4912
4912
|
var hasRadius = radius && radius.some(function (r) { return r !== 0; });
|
|
4913
4913
|
commands = rectToCommands(width_1, height_1, x, y, hasRadius &&
|
|
4914
4914
|
radius.map(function (r) {
|
|
@@ -8198,7 +8198,6 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8198
8198
|
TextUpdater.prototype.update = function (parsedStyle, object) {
|
|
8199
8199
|
var _a, _b;
|
|
8200
8200
|
var text = parsedStyle.text, textAlign = parsedStyle.textAlign, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, dx = parsedStyle.dx, dy = parsedStyle.dy;
|
|
8201
|
-
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;
|
|
8202
8201
|
if (!this.isReadyToMeasure(parsedStyle, object)) {
|
|
8203
8202
|
parsedStyle.metrics = {
|
|
8204
8203
|
font: '',
|
|
@@ -8224,6 +8223,7 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8224
8223
|
offsetY: 0,
|
|
8225
8224
|
};
|
|
8226
8225
|
}
|
|
8226
|
+
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;
|
|
8227
8227
|
var metrics = this.globalRuntime.textService.measureText(text, parsedStyle, offscreenCanvas);
|
|
8228
8228
|
parsedStyle.metrics = metrics;
|
|
8229
8229
|
var width = metrics.width, height = metrics.height, lineHeight = metrics.lineHeight, fontProperties = metrics.fontProperties;
|
|
@@ -9889,8 +9889,8 @@ var OffscreenCanvasCreator = /** @class */ (function () {
|
|
|
9889
9889
|
return this.canvas;
|
|
9890
9890
|
}
|
|
9891
9891
|
// user-defined offscreen canvas
|
|
9892
|
-
if (offscreenCanvas) {
|
|
9893
|
-
this.canvas = offscreenCanvas;
|
|
9892
|
+
if (offscreenCanvas || runtime.offscreenCanvas) {
|
|
9893
|
+
this.canvas = offscreenCanvas || runtime.offscreenCanvas;
|
|
9894
9894
|
this.context = this.canvas.getContext('2d', contextAttributes);
|
|
9895
9895
|
}
|
|
9896
9896
|
else {
|
|
@@ -11167,8 +11167,8 @@ var TextService = /** @class */ (function () {
|
|
|
11167
11167
|
descent: 0,
|
|
11168
11168
|
fontSize: 0,
|
|
11169
11169
|
};
|
|
11170
|
-
var canvas = this.runtime.
|
|
11171
|
-
var context = this.runtime.
|
|
11170
|
+
var canvas = this.runtime.offscreenCanvasCreator.getOrCreateCanvas(offscreenCanvas);
|
|
11171
|
+
var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas, {
|
|
11172
11172
|
willReadFrequently: true,
|
|
11173
11173
|
});
|
|
11174
11174
|
context.font = font;
|
|
@@ -11253,7 +11253,7 @@ var TextService = /** @class */ (function () {
|
|
|
11253
11253
|
// fontSize,
|
|
11254
11254
|
// };
|
|
11255
11255
|
// }
|
|
11256
|
-
var context = this.runtime.
|
|
11256
|
+
var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
|
|
11257
11257
|
context.font = font;
|
|
11258
11258
|
// no overflowing by default
|
|
11259
11259
|
parsedStyle.isOverflowing = false;
|
|
@@ -11351,7 +11351,7 @@ var TextService = /** @class */ (function () {
|
|
|
11351
11351
|
TextService.prototype.wordWrap = function (text, parsedStyle, offscreenCanvas) {
|
|
11352
11352
|
var _this = this;
|
|
11353
11353
|
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;
|
|
11354
|
-
var context = this.runtime.
|
|
11354
|
+
var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
|
|
11355
11355
|
var maxWidth = wordWrapWidth + letterSpacing;
|
|
11356
11356
|
var ellipsis = '';
|
|
11357
11357
|
if (textOverflow === 'ellipsis') {
|
|
@@ -11550,10 +11550,10 @@ var getGlobalThis = function () {
|
|
|
11550
11550
|
// @ts-ignore
|
|
11551
11551
|
if (typeof global !== 'undefined')
|
|
11552
11552
|
return global;
|
|
11553
|
+
return {};
|
|
11553
11554
|
// [!] Error: The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
|
|
11554
11555
|
// @see https://rollupjs.org/troubleshooting/#error-this-is-undefined
|
|
11555
11556
|
// if (typeof this !== 'undefined') return this;
|
|
11556
|
-
throw new Error('Unable to locate global `this`');
|
|
11557
11557
|
};
|
|
11558
11558
|
/**
|
|
11559
11559
|
* Camera
|
|
@@ -11565,7 +11565,7 @@ runtime.CameraContribution = Camera;
|
|
|
11565
11565
|
*/
|
|
11566
11566
|
runtime.AnimationTimeline = null;
|
|
11567
11567
|
runtime.EasingFunction = null;
|
|
11568
|
-
runtime.
|
|
11568
|
+
runtime.offscreenCanvasCreator = new OffscreenCanvasCreator();
|
|
11569
11569
|
runtime.nativeHTMLMap = new WeakMap();
|
|
11570
11570
|
runtime.sceneGraphSelector = new DefaultSceneGraphSelector();
|
|
11571
11571
|
runtime.sceneGraphService = new DefaultSceneGraphService(runtime);
|
|
@@ -14897,6 +14897,10 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
14897
14897
|
canvasWidth = width || getWidth(canvas) || canvas.width / dpr;
|
|
14898
14898
|
canvasHeight = height || getHeight(canvas) || canvas.height / dpr;
|
|
14899
14899
|
}
|
|
14900
|
+
// override it in runtime
|
|
14901
|
+
if (offscreenCanvas) {
|
|
14902
|
+
runtime.offscreenCanvas = offscreenCanvas;
|
|
14903
|
+
}
|
|
14900
14904
|
/**
|
|
14901
14905
|
* implements `Window` interface
|
|
14902
14906
|
*/
|