@antv/g-lite 1.0.69 → 1.0.70
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/Canvas.d.ts.map +1 -1
- package/dist/index.esm.js +89 -54
- package/dist/index.js +89 -54
- package/dist/index.umd.js +89 -54
- package/dist/index.umd.min.js +1 -1
- package/dist/services/RenderingService.d.ts +3 -2
- package/dist/services/RenderingService.d.ts.map +1 -1
- package/dist/services/TextService.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/tapable/AsyncParallelHook.d.ts +1 -0
- package/dist/utils/tapable/AsyncParallelHook.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -9890,6 +9890,28 @@
|
|
|
9890
9890
|
return [hasFill, hasStroke];
|
|
9891
9891
|
}
|
|
9892
9892
|
|
|
9893
|
+
var AsyncParallelHook = /*#__PURE__*/function () {
|
|
9894
|
+
function AsyncParallelHook() {
|
|
9895
|
+
this.callbacks = [];
|
|
9896
|
+
}
|
|
9897
|
+
var _proto = AsyncParallelHook.prototype;
|
|
9898
|
+
_proto.getCallbacksNum = function getCallbacksNum() {
|
|
9899
|
+
return this.callbacks.length;
|
|
9900
|
+
};
|
|
9901
|
+
_proto.tapPromise = function tapPromise(options, fn) {
|
|
9902
|
+
this.callbacks.push(fn);
|
|
9903
|
+
};
|
|
9904
|
+
_proto.promise = function promise() {
|
|
9905
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9906
|
+
args[_key] = arguments[_key];
|
|
9907
|
+
}
|
|
9908
|
+
return Promise.all(this.callbacks.map(function (callback) {
|
|
9909
|
+
return callback.apply(void 0, args);
|
|
9910
|
+
}));
|
|
9911
|
+
};
|
|
9912
|
+
return AsyncParallelHook;
|
|
9913
|
+
}();
|
|
9914
|
+
|
|
9893
9915
|
var AsyncSeriesWaterfallHook = /*#__PURE__*/function () {
|
|
9894
9916
|
function AsyncSeriesWaterfallHook() {
|
|
9895
9917
|
this.callbacks = [];
|
|
@@ -19288,6 +19310,7 @@
|
|
|
19288
19310
|
* called before any frame rendered
|
|
19289
19311
|
*/
|
|
19290
19312
|
init: new SyncHook(),
|
|
19313
|
+
initAsync: new AsyncParallelHook(),
|
|
19291
19314
|
/**
|
|
19292
19315
|
* only dirty object which has sth changed will be rendered
|
|
19293
19316
|
*/
|
|
@@ -19338,14 +19361,23 @@
|
|
|
19338
19361
|
this.context = context;
|
|
19339
19362
|
}
|
|
19340
19363
|
var _proto = RenderingService.prototype;
|
|
19341
|
-
_proto.init = function init() {
|
|
19364
|
+
_proto.init = function init(callback) {
|
|
19365
|
+
var _this = this;
|
|
19342
19366
|
var context = _extends({}, this.globalRuntime, this.context);
|
|
19343
19367
|
// register rendering plugins
|
|
19344
19368
|
this.context.renderingPlugins.forEach(function (plugin) {
|
|
19345
19369
|
plugin.apply(context, runtime);
|
|
19346
19370
|
});
|
|
19347
19371
|
this.hooks.init.call();
|
|
19348
|
-
this.
|
|
19372
|
+
if (this.hooks.initAsync.getCallbacksNum() === 0) {
|
|
19373
|
+
this.inited = true;
|
|
19374
|
+
callback();
|
|
19375
|
+
} else {
|
|
19376
|
+
this.hooks.initAsync.promise().then(function () {
|
|
19377
|
+
_this.inited = true;
|
|
19378
|
+
callback();
|
|
19379
|
+
});
|
|
19380
|
+
}
|
|
19349
19381
|
};
|
|
19350
19382
|
_proto.getStats = function getStats() {
|
|
19351
19383
|
return this.stats;
|
|
@@ -19362,7 +19394,7 @@
|
|
|
19362
19394
|
return !enableDirtyRectangleRendering || this.context.renderingContext.renderReasons.has(exports.RenderReason.CAMERA_CHANGED);
|
|
19363
19395
|
};
|
|
19364
19396
|
_proto.render = function render(canvasConfig, rerenderCallback) {
|
|
19365
|
-
var
|
|
19397
|
+
var _this2 = this;
|
|
19366
19398
|
this.stats.total = 0;
|
|
19367
19399
|
this.stats.rendered = 0;
|
|
19368
19400
|
this.zIndexCounter = 0;
|
|
@@ -19373,9 +19405,9 @@
|
|
|
19373
19405
|
this.renderDisplayObject(renderingContext.root, canvasConfig, renderingContext);
|
|
19374
19406
|
this.hooks.beginFrame.call();
|
|
19375
19407
|
renderingContext.renderListCurrentFrame.forEach(function (object) {
|
|
19376
|
-
|
|
19377
|
-
|
|
19378
|
-
|
|
19408
|
+
_this2.hooks.beforeRender.call(object);
|
|
19409
|
+
_this2.hooks.render.call(object);
|
|
19410
|
+
_this2.hooks.afterRender.call(object);
|
|
19379
19411
|
});
|
|
19380
19412
|
this.hooks.endFrame.call();
|
|
19381
19413
|
renderingContext.renderListCurrentFrame = [];
|
|
@@ -19385,7 +19417,7 @@
|
|
|
19385
19417
|
// console.log('stats', this.stats);
|
|
19386
19418
|
};
|
|
19387
19419
|
_proto.renderDisplayObject = function renderDisplayObject(displayObject, canvasConfig, renderingContext) {
|
|
19388
|
-
var
|
|
19420
|
+
var _this3 = this;
|
|
19389
19421
|
var _canvasConfig$rendere = canvasConfig.renderer.getConfig(),
|
|
19390
19422
|
enableDirtyCheck = _canvasConfig$rendere.enableDirtyCheck,
|
|
19391
19423
|
enableCulling = _canvasConfig$rendere.enableCulling;
|
|
@@ -19416,7 +19448,7 @@
|
|
|
19416
19448
|
}
|
|
19417
19449
|
// recursive rendering its children
|
|
19418
19450
|
(sortable.sorted || displayObject.childNodes).forEach(function (child) {
|
|
19419
|
-
|
|
19451
|
+
_this3.renderDisplayObject(child, canvasConfig, renderingContext);
|
|
19420
19452
|
});
|
|
19421
19453
|
};
|
|
19422
19454
|
_proto.sort = function sort(displayObject, sortable) {
|
|
@@ -20425,7 +20457,9 @@
|
|
|
20425
20457
|
fontSize: 0
|
|
20426
20458
|
};
|
|
20427
20459
|
var canvas = this.runtime.offscreenCanvas.getOrCreateCanvas(offscreenCanvas);
|
|
20428
|
-
var context = this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas
|
|
20460
|
+
var context = this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas, {
|
|
20461
|
+
willReadFrequently: true
|
|
20462
|
+
});
|
|
20429
20463
|
context.font = font;
|
|
20430
20464
|
var metricsString = TEXT_METRICS.MetricsString + TEXT_METRICS.BaselineSymbol;
|
|
20431
20465
|
var width = Math.ceil(context.measureText(metricsString).width);
|
|
@@ -21797,59 +21831,60 @@
|
|
|
21797
21831
|
this.context.eventService.init();
|
|
21798
21832
|
if (this.context.contextService.init) {
|
|
21799
21833
|
this.context.contextService.init();
|
|
21800
|
-
this.initRenderingService(renderer, firstContentfullPaint);
|
|
21801
|
-
if (firstContentfullPaint) {
|
|
21802
|
-
this.requestAnimationFrame(function () {
|
|
21803
|
-
_this5.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));
|
|
21804
|
-
});
|
|
21805
|
-
if (this.readyPromise) {
|
|
21806
|
-
this.resolveReadyPromise();
|
|
21807
|
-
}
|
|
21808
|
-
} else {
|
|
21809
|
-
this.dispatchEvent(new CustomEvent(exports.CanvasEvent.RENDERER_CHANGED));
|
|
21810
|
-
}
|
|
21834
|
+
this.initRenderingService(renderer, firstContentfullPaint, true);
|
|
21811
21835
|
} else {
|
|
21812
21836
|
this.context.contextService.initAsync().then(function () {
|
|
21813
21837
|
_this5.initRenderingService(renderer, firstContentfullPaint);
|
|
21814
|
-
if (firstContentfullPaint) {
|
|
21815
|
-
_this5.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));
|
|
21816
|
-
if (_this5.readyPromise) {
|
|
21817
|
-
_this5.resolveReadyPromise();
|
|
21818
|
-
}
|
|
21819
|
-
} else {
|
|
21820
|
-
_this5.dispatchEvent(new CustomEvent(exports.CanvasEvent.RENDERER_CHANGED));
|
|
21821
|
-
}
|
|
21822
21838
|
});
|
|
21823
21839
|
}
|
|
21824
21840
|
};
|
|
21825
|
-
_proto.initRenderingService = function initRenderingService(renderer, firstContentfullPaint) {
|
|
21841
|
+
_proto.initRenderingService = function initRenderingService(renderer, firstContentfullPaint, async) {
|
|
21842
|
+
var _this6 = this;
|
|
21826
21843
|
if (firstContentfullPaint === void 0) {
|
|
21827
21844
|
firstContentfullPaint = false;
|
|
21828
21845
|
}
|
|
21829
|
-
|
|
21830
|
-
|
|
21831
|
-
if (!firstContentfullPaint) {
|
|
21832
|
-
this.getRoot().forEach(function (node) {
|
|
21833
|
-
var renderable = node.renderable;
|
|
21834
|
-
if (renderable) {
|
|
21835
|
-
renderable.renderBoundsDirty = true;
|
|
21836
|
-
renderable.boundsDirty = true;
|
|
21837
|
-
renderable.dirty = true;
|
|
21838
|
-
}
|
|
21839
|
-
});
|
|
21840
|
-
}
|
|
21841
|
-
// keep current scenegraph unchanged, just trigger mounted event
|
|
21842
|
-
this.mountChildren(this.getRoot());
|
|
21843
|
-
if (renderer.getConfig().enableAutoRendering) {
|
|
21844
|
-
this.run();
|
|
21846
|
+
if (async === void 0) {
|
|
21847
|
+
async = false;
|
|
21845
21848
|
}
|
|
21849
|
+
this.context.renderingService.init(function () {
|
|
21850
|
+
_this6.inited = true;
|
|
21851
|
+
if (firstContentfullPaint) {
|
|
21852
|
+
if (async) {
|
|
21853
|
+
_this6.requestAnimationFrame(function () {
|
|
21854
|
+
_this6.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));
|
|
21855
|
+
});
|
|
21856
|
+
} else {
|
|
21857
|
+
_this6.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));
|
|
21858
|
+
}
|
|
21859
|
+
if (_this6.readyPromise) {
|
|
21860
|
+
_this6.resolveReadyPromise();
|
|
21861
|
+
}
|
|
21862
|
+
} else {
|
|
21863
|
+
_this6.dispatchEvent(new CustomEvent(exports.CanvasEvent.RENDERER_CHANGED));
|
|
21864
|
+
}
|
|
21865
|
+
if (!firstContentfullPaint) {
|
|
21866
|
+
_this6.getRoot().forEach(function (node) {
|
|
21867
|
+
var renderable = node.renderable;
|
|
21868
|
+
if (renderable) {
|
|
21869
|
+
renderable.renderBoundsDirty = true;
|
|
21870
|
+
renderable.boundsDirty = true;
|
|
21871
|
+
renderable.dirty = true;
|
|
21872
|
+
}
|
|
21873
|
+
});
|
|
21874
|
+
}
|
|
21875
|
+
// keep current scenegraph unchanged, just trigger mounted event
|
|
21876
|
+
_this6.mountChildren(_this6.getRoot());
|
|
21877
|
+
if (renderer.getConfig().enableAutoRendering) {
|
|
21878
|
+
_this6.run();
|
|
21879
|
+
}
|
|
21880
|
+
});
|
|
21846
21881
|
};
|
|
21847
21882
|
_proto.loadRendererContainerModule = function loadRendererContainerModule(renderer) {
|
|
21848
|
-
var
|
|
21883
|
+
var _this7 = this;
|
|
21849
21884
|
// load other container modules provided by g-canvas/g-svg/g-webgl
|
|
21850
21885
|
var plugins = renderer.getPlugins();
|
|
21851
21886
|
plugins.forEach(function (plugin) {
|
|
21852
|
-
plugin.context =
|
|
21887
|
+
plugin.context = _this7.context;
|
|
21853
21888
|
plugin.init(runtime);
|
|
21854
21889
|
});
|
|
21855
21890
|
};
|
|
@@ -21875,10 +21910,10 @@
|
|
|
21875
21910
|
this.getContextService().applyCursorStyle(cursor);
|
|
21876
21911
|
};
|
|
21877
21912
|
_proto.unmountChildren = function unmountChildren(parent) {
|
|
21878
|
-
var
|
|
21913
|
+
var _this8 = this;
|
|
21879
21914
|
// unmountChildren recursively
|
|
21880
21915
|
parent.childNodes.forEach(function (child) {
|
|
21881
|
-
|
|
21916
|
+
_this8.unmountChildren(child);
|
|
21882
21917
|
});
|
|
21883
21918
|
if (this.inited) {
|
|
21884
21919
|
if (parent.isMutationObserved) {
|
|
@@ -21901,7 +21936,7 @@
|
|
|
21901
21936
|
}
|
|
21902
21937
|
};
|
|
21903
21938
|
_proto.mountChildren = function mountChildren(parent) {
|
|
21904
|
-
var
|
|
21939
|
+
var _this9 = this;
|
|
21905
21940
|
if (this.inited) {
|
|
21906
21941
|
if (!parent.isConnected) {
|
|
21907
21942
|
parent.ownerDocument = this.document;
|
|
@@ -21918,7 +21953,7 @@
|
|
|
21918
21953
|
}
|
|
21919
21954
|
// recursively mount children
|
|
21920
21955
|
parent.childNodes.forEach(function (child) {
|
|
21921
|
-
|
|
21956
|
+
_this9.mountChildren(child);
|
|
21922
21957
|
});
|
|
21923
21958
|
// trigger after mounted
|
|
21924
21959
|
if (parent.isCustomElement) {
|
|
@@ -21962,11 +21997,11 @@
|
|
|
21962
21997
|
_createClass(Canvas, [{
|
|
21963
21998
|
key: "ready",
|
|
21964
21999
|
get: function get() {
|
|
21965
|
-
var
|
|
22000
|
+
var _this10 = this;
|
|
21966
22001
|
if (!this.readyPromise) {
|
|
21967
22002
|
this.readyPromise = new Promise(function (resolve) {
|
|
21968
|
-
|
|
21969
|
-
resolve(
|
|
22003
|
+
_this10.resolveReadyPromise = function () {
|
|
22004
|
+
resolve(_this10);
|
|
21970
22005
|
};
|
|
21971
22006
|
});
|
|
21972
22007
|
if (this.inited) {
|