@antv/g-lite 1.0.68 → 1.0.69
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 +4 -2
- package/dist/Canvas.d.ts.map +1 -1
- package/dist/index.esm.js +115 -178
- package/dist/index.js +115 -178
- package/dist/index.umd.js +115 -178
- package/dist/index.umd.min.js +1 -1
- package/dist/plugins/PrepareRendererPlugin.d.ts.map +1 -1
- package/dist/services/ContextService.d.ts +2 -1
- package/dist/services/ContextService.d.ts.map +1 -1
- package/dist/services/RenderingService.d.ts +3 -3
- package/dist/services/RenderingService.d.ts.map +1 -1
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/Canvas.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export declare enum CanvasEvent {
|
|
|
16
16
|
BEFORE_DESTROY = "beforedestroy",
|
|
17
17
|
AFTER_DESTROY = "afterdestroy",
|
|
18
18
|
RESIZE = "resize",
|
|
19
|
-
DIRTY_RECTANGLE = "dirtyrectangle"
|
|
19
|
+
DIRTY_RECTANGLE = "dirtyrectangle",
|
|
20
|
+
RENDERER_CHANGED = "rendererchanged"
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* can be treated like Window in DOM
|
|
@@ -125,8 +126,9 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
125
126
|
render(): void;
|
|
126
127
|
private run;
|
|
127
128
|
private initRenderer;
|
|
129
|
+
private initRenderingService;
|
|
128
130
|
private loadRendererContainerModule;
|
|
129
|
-
setRenderer(renderer: IRenderer):
|
|
131
|
+
setRenderer(renderer: IRenderer): void;
|
|
130
132
|
setCursor(cursor: Cursor): void;
|
|
131
133
|
unmountChildren(parent: DisplayObject): void;
|
|
132
134
|
mountChildren(parent: DisplayObject): void;
|
package/dist/Canvas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","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GAAG,SAAS;IAI7C,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS;IAI7C,eAAe,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS;IAI/C,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS;IAI7C;;;OAGG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS;IAI7D;;;OAGG;IACH,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS;CAGlD"}
|
package/dist/index.esm.js
CHANGED
|
@@ -3251,25 +3251,6 @@ function isFillOrStrokeAffected(pointerEvents, fill, stroke) {
|
|
|
3251
3251
|
return [hasFill, hasStroke];
|
|
3252
3252
|
}
|
|
3253
3253
|
|
|
3254
|
-
var AsyncParallelHook = /*#__PURE__*/function () {
|
|
3255
|
-
function AsyncParallelHook() {
|
|
3256
|
-
this.callbacks = [];
|
|
3257
|
-
}
|
|
3258
|
-
var _proto = AsyncParallelHook.prototype;
|
|
3259
|
-
_proto.tapPromise = function tapPromise(options, fn) {
|
|
3260
|
-
this.callbacks.push(fn);
|
|
3261
|
-
};
|
|
3262
|
-
_proto.promise = function promise() {
|
|
3263
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3264
|
-
args[_key] = arguments[_key];
|
|
3265
|
-
}
|
|
3266
|
-
return Promise.all(this.callbacks.map(function (callback) {
|
|
3267
|
-
return callback.apply(void 0, args);
|
|
3268
|
-
}));
|
|
3269
|
-
};
|
|
3270
|
-
return AsyncParallelHook;
|
|
3271
|
-
}();
|
|
3272
|
-
|
|
3273
3254
|
var AsyncSeriesWaterfallHook = /*#__PURE__*/function () {
|
|
3274
3255
|
function AsyncSeriesWaterfallHook() {
|
|
3275
3256
|
this.callbacks = [];
|
|
@@ -12340,7 +12321,7 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
12340
12321
|
/**
|
|
12341
12322
|
* called before any frame rendered
|
|
12342
12323
|
*/
|
|
12343
|
-
init: new
|
|
12324
|
+
init: new SyncHook(),
|
|
12344
12325
|
/**
|
|
12345
12326
|
* only dirty object which has sth changed will be rendered
|
|
12346
12327
|
*/
|
|
@@ -12391,32 +12372,15 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
12391
12372
|
this.context = context;
|
|
12392
12373
|
}
|
|
12393
12374
|
var _proto = RenderingService.prototype;
|
|
12394
|
-
_proto.init =
|
|
12395
|
-
var
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
});
|
|
12404
|
-
// await this.hooks.init.callPromise();
|
|
12405
|
-
_context.next = 4;
|
|
12406
|
-
return this.hooks.init.promise();
|
|
12407
|
-
case 4:
|
|
12408
|
-
this.inited = true;
|
|
12409
|
-
case 5:
|
|
12410
|
-
case "end":
|
|
12411
|
-
return _context.stop();
|
|
12412
|
-
}
|
|
12413
|
-
}, _callee, this);
|
|
12414
|
-
}));
|
|
12415
|
-
function init() {
|
|
12416
|
-
return _init.apply(this, arguments);
|
|
12417
|
-
}
|
|
12418
|
-
return init;
|
|
12419
|
-
}();
|
|
12375
|
+
_proto.init = function init() {
|
|
12376
|
+
var context = _extends({}, this.globalRuntime, this.context);
|
|
12377
|
+
// register rendering plugins
|
|
12378
|
+
this.context.renderingPlugins.forEach(function (plugin) {
|
|
12379
|
+
plugin.apply(context, runtime);
|
|
12380
|
+
});
|
|
12381
|
+
this.hooks.init.call();
|
|
12382
|
+
this.inited = true;
|
|
12383
|
+
};
|
|
12420
12384
|
_proto.getStats = function getStats() {
|
|
12421
12385
|
return this.stats;
|
|
12422
12386
|
}
|
|
@@ -14417,20 +14381,12 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
14417
14381
|
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
14418
14382
|
renderingService.dirtify();
|
|
14419
14383
|
};
|
|
14420
|
-
renderingService.hooks.init.
|
|
14421
|
-
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
canvas.addEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
14427
|
-
canvas.addEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
14428
|
-
case 4:
|
|
14429
|
-
case "end":
|
|
14430
|
-
return _context.stop();
|
|
14431
|
-
}
|
|
14432
|
-
}, _callee);
|
|
14433
|
-
})));
|
|
14384
|
+
renderingService.hooks.init.tap(PrepareRendererPlugin.tag, function () {
|
|
14385
|
+
canvas.addEventListener(ElementEvent.MOUNTED, handleMounted);
|
|
14386
|
+
canvas.addEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
|
|
14387
|
+
canvas.addEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
14388
|
+
canvas.addEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
14389
|
+
});
|
|
14434
14390
|
renderingService.hooks.destroy.tap(PrepareRendererPlugin.tag, function () {
|
|
14435
14391
|
canvas.removeEventListener(ElementEvent.MOUNTED, handleMounted);
|
|
14436
14392
|
canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
|
|
@@ -14518,6 +14474,7 @@ var CanvasEvent;
|
|
|
14518
14474
|
CanvasEvent["AFTER_DESTROY"] = "afterdestroy";
|
|
14519
14475
|
CanvasEvent["RESIZE"] = "resize";
|
|
14520
14476
|
CanvasEvent["DIRTY_RECTANGLE"] = "dirtyrectangle";
|
|
14477
|
+
CanvasEvent["RENDERER_CHANGED"] = "rendererchanged";
|
|
14521
14478
|
})(CanvasEvent || (CanvasEvent = {}));
|
|
14522
14479
|
var DEFAULT_CAMERA_Z = 500;
|
|
14523
14480
|
var DEFAULT_CAMERA_NEAR = 0.1;
|
|
@@ -14666,23 +14623,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
14666
14623
|
alwaysTriggerPointerEventOnCanvas: alwaysTriggerPointerEventOnCanvas
|
|
14667
14624
|
});
|
|
14668
14625
|
_this.initDefaultCamera(canvasWidth, canvasHeight);
|
|
14669
|
-
|
|
14670
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14671
|
-
while (1) switch (_context.prev = _context.next) {
|
|
14672
|
-
case 0:
|
|
14673
|
-
_context.next = 2;
|
|
14674
|
-
return _this.initRenderer(renderer);
|
|
14675
|
-
case 2:
|
|
14676
|
-
_this.dispatchEvent(new CustomEvent(CanvasEvent.READY));
|
|
14677
|
-
if (_this.readyPromise) {
|
|
14678
|
-
_this.resolveReadyPromise();
|
|
14679
|
-
}
|
|
14680
|
-
case 4:
|
|
14681
|
-
case "end":
|
|
14682
|
-
return _context.stop();
|
|
14683
|
-
}
|
|
14684
|
-
}, _callee);
|
|
14685
|
-
}))();
|
|
14626
|
+
_this.initRenderer(renderer, true);
|
|
14686
14627
|
return _this;
|
|
14687
14628
|
}
|
|
14688
14629
|
var _proto = Canvas.prototype;
|
|
@@ -14860,123 +14801,119 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
14860
14801
|
var _this4 = this;
|
|
14861
14802
|
var tick = function tick() {
|
|
14862
14803
|
_this4.render();
|
|
14863
|
-
_this4.frameId = requestAnimationFrame(tick);
|
|
14804
|
+
_this4.frameId = _this4.requestAnimationFrame(tick);
|
|
14864
14805
|
};
|
|
14865
14806
|
tick();
|
|
14866
14807
|
};
|
|
14867
|
-
_proto.initRenderer =
|
|
14868
|
-
var
|
|
14869
|
-
|
|
14870
|
-
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
this.inited = true;
|
|
14902
|
-
this.getRoot().forEach(function (node) {
|
|
14903
|
-
var renderable = node.renderable;
|
|
14904
|
-
if (renderable) {
|
|
14905
|
-
renderable.renderBoundsDirty = true;
|
|
14906
|
-
renderable.boundsDirty = true;
|
|
14907
|
-
renderable.dirty = true;
|
|
14908
|
-
}
|
|
14909
|
-
});
|
|
14910
|
-
// keep current scenegraph unchanged, just trigger mounted event
|
|
14911
|
-
this.mountChildren(this.getRoot());
|
|
14912
|
-
if (renderer.getConfig().enableAutoRendering) {
|
|
14913
|
-
this.run();
|
|
14914
|
-
}
|
|
14915
|
-
case 20:
|
|
14916
|
-
case "end":
|
|
14917
|
-
return _context2.stop();
|
|
14808
|
+
_proto.initRenderer = function initRenderer(renderer, firstContentfullPaint) {
|
|
14809
|
+
var _this5 = this;
|
|
14810
|
+
if (firstContentfullPaint === void 0) {
|
|
14811
|
+
firstContentfullPaint = false;
|
|
14812
|
+
}
|
|
14813
|
+
if (!renderer) {
|
|
14814
|
+
throw new Error('Renderer is required.');
|
|
14815
|
+
}
|
|
14816
|
+
// reset
|
|
14817
|
+
this.inited = false;
|
|
14818
|
+
this.readyPromise = undefined;
|
|
14819
|
+
// FIXME: should re-create here?
|
|
14820
|
+
this.context.rBushRoot = new RBush();
|
|
14821
|
+
// reset rendering plugins
|
|
14822
|
+
this.context.renderingPlugins = [];
|
|
14823
|
+
this.context.renderingPlugins.push(new EventPlugin(), new PrepareRendererPlugin(), new DirtyCheckPlugin(), new CullingPlugin([new FrustumCullingStrategy()]));
|
|
14824
|
+
//
|
|
14825
|
+
this.loadRendererContainerModule(renderer);
|
|
14826
|
+
// init context service
|
|
14827
|
+
this.context.contextService = new this.context.ContextService(_extends({}, runtime, this.context));
|
|
14828
|
+
// init rendering service
|
|
14829
|
+
this.context.renderingService = new RenderingService(runtime, this.context);
|
|
14830
|
+
// init event service
|
|
14831
|
+
this.context.eventService = new EventService(runtime, this.context);
|
|
14832
|
+
this.context.eventService.init();
|
|
14833
|
+
if (this.context.contextService.init) {
|
|
14834
|
+
this.context.contextService.init();
|
|
14835
|
+
this.initRenderingService(renderer, firstContentfullPaint);
|
|
14836
|
+
if (firstContentfullPaint) {
|
|
14837
|
+
this.requestAnimationFrame(function () {
|
|
14838
|
+
_this5.dispatchEvent(new CustomEvent(CanvasEvent.READY));
|
|
14839
|
+
});
|
|
14840
|
+
if (this.readyPromise) {
|
|
14841
|
+
this.resolveReadyPromise();
|
|
14918
14842
|
}
|
|
14919
|
-
}
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14843
|
+
} else {
|
|
14844
|
+
this.dispatchEvent(new CustomEvent(CanvasEvent.RENDERER_CHANGED));
|
|
14845
|
+
}
|
|
14846
|
+
} else {
|
|
14847
|
+
this.context.contextService.initAsync().then(function () {
|
|
14848
|
+
_this5.initRenderingService(renderer, firstContentfullPaint);
|
|
14849
|
+
if (firstContentfullPaint) {
|
|
14850
|
+
_this5.dispatchEvent(new CustomEvent(CanvasEvent.READY));
|
|
14851
|
+
if (_this5.readyPromise) {
|
|
14852
|
+
_this5.resolveReadyPromise();
|
|
14853
|
+
}
|
|
14854
|
+
} else {
|
|
14855
|
+
_this5.dispatchEvent(new CustomEvent(CanvasEvent.RENDERER_CHANGED));
|
|
14856
|
+
}
|
|
14857
|
+
});
|
|
14923
14858
|
}
|
|
14924
|
-
|
|
14925
|
-
|
|
14859
|
+
};
|
|
14860
|
+
_proto.initRenderingService = function initRenderingService(renderer, firstContentfullPaint) {
|
|
14861
|
+
if (firstContentfullPaint === void 0) {
|
|
14862
|
+
firstContentfullPaint = false;
|
|
14863
|
+
}
|
|
14864
|
+
this.context.renderingService.init();
|
|
14865
|
+
this.inited = true;
|
|
14866
|
+
if (!firstContentfullPaint) {
|
|
14867
|
+
this.getRoot().forEach(function (node) {
|
|
14868
|
+
var renderable = node.renderable;
|
|
14869
|
+
if (renderable) {
|
|
14870
|
+
renderable.renderBoundsDirty = true;
|
|
14871
|
+
renderable.boundsDirty = true;
|
|
14872
|
+
renderable.dirty = true;
|
|
14873
|
+
}
|
|
14874
|
+
});
|
|
14875
|
+
}
|
|
14876
|
+
// keep current scenegraph unchanged, just trigger mounted event
|
|
14877
|
+
this.mountChildren(this.getRoot());
|
|
14878
|
+
if (renderer.getConfig().enableAutoRendering) {
|
|
14879
|
+
this.run();
|
|
14880
|
+
}
|
|
14881
|
+
};
|
|
14926
14882
|
_proto.loadRendererContainerModule = function loadRendererContainerModule(renderer) {
|
|
14927
|
-
var
|
|
14883
|
+
var _this6 = this;
|
|
14928
14884
|
// load other container modules provided by g-canvas/g-svg/g-webgl
|
|
14929
14885
|
var plugins = renderer.getPlugins();
|
|
14930
14886
|
plugins.forEach(function (plugin) {
|
|
14931
|
-
plugin.context =
|
|
14887
|
+
plugin.context = _this6.context;
|
|
14932
14888
|
plugin.init(runtime);
|
|
14933
14889
|
});
|
|
14934
14890
|
};
|
|
14935
|
-
_proto.setRenderer =
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
|
|
14940
|
-
case 0:
|
|
14941
|
-
// update canvas' config
|
|
14942
|
-
canvasConfig = this.getConfig();
|
|
14943
|
-
if (!(canvasConfig.renderer === renderer)) {
|
|
14944
|
-
_context3.next = 3;
|
|
14945
|
-
break;
|
|
14946
|
-
}
|
|
14947
|
-
return _context3.abrupt("return");
|
|
14948
|
-
case 3:
|
|
14949
|
-
oldRenderer = canvasConfig.renderer;
|
|
14950
|
-
canvasConfig.renderer = renderer;
|
|
14951
|
-
// keep all children undestroyed
|
|
14952
|
-
this.destroy(false, true);
|
|
14953
|
-
// destroy all plugins, reverse will mutate origin array
|
|
14954
|
-
[].concat(oldRenderer === null || oldRenderer === void 0 ? void 0 : oldRenderer.getPlugins()).reverse().forEach(function (plugin) {
|
|
14955
|
-
plugin.destroy(runtime);
|
|
14956
|
-
});
|
|
14957
|
-
_context3.next = 9;
|
|
14958
|
-
return this.initRenderer(renderer);
|
|
14959
|
-
case 9:
|
|
14960
|
-
case "end":
|
|
14961
|
-
return _context3.stop();
|
|
14962
|
-
}
|
|
14963
|
-
}, _callee3, this);
|
|
14964
|
-
}));
|
|
14965
|
-
function setRenderer(_x2) {
|
|
14966
|
-
return _setRenderer.apply(this, arguments);
|
|
14891
|
+
_proto.setRenderer = function setRenderer(renderer) {
|
|
14892
|
+
// update canvas' config
|
|
14893
|
+
var canvasConfig = this.getConfig();
|
|
14894
|
+
if (canvasConfig.renderer === renderer) {
|
|
14895
|
+
return;
|
|
14967
14896
|
}
|
|
14968
|
-
|
|
14969
|
-
|
|
14897
|
+
var oldRenderer = canvasConfig.renderer;
|
|
14898
|
+
canvasConfig.renderer = renderer;
|
|
14899
|
+
// keep all children undestroyed
|
|
14900
|
+
this.destroy(false, true);
|
|
14901
|
+
// destroy all plugins, reverse will mutate origin array
|
|
14902
|
+
[].concat(oldRenderer === null || oldRenderer === void 0 ? void 0 : oldRenderer.getPlugins()).reverse().forEach(function (plugin) {
|
|
14903
|
+
plugin.destroy(runtime);
|
|
14904
|
+
});
|
|
14905
|
+
this.initRenderer(renderer);
|
|
14906
|
+
};
|
|
14970
14907
|
_proto.setCursor = function setCursor(cursor) {
|
|
14971
14908
|
var canvasConfig = this.getConfig();
|
|
14972
14909
|
canvasConfig.cursor = cursor;
|
|
14973
14910
|
this.getContextService().applyCursorStyle(cursor);
|
|
14974
14911
|
};
|
|
14975
14912
|
_proto.unmountChildren = function unmountChildren(parent) {
|
|
14976
|
-
var
|
|
14913
|
+
var _this7 = this;
|
|
14977
14914
|
// unmountChildren recursively
|
|
14978
14915
|
parent.childNodes.forEach(function (child) {
|
|
14979
|
-
|
|
14916
|
+
_this7.unmountChildren(child);
|
|
14980
14917
|
});
|
|
14981
14918
|
if (this.inited) {
|
|
14982
14919
|
if (parent.isMutationObserved) {
|
|
@@ -14999,7 +14936,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
14999
14936
|
}
|
|
15000
14937
|
};
|
|
15001
14938
|
_proto.mountChildren = function mountChildren(parent) {
|
|
15002
|
-
var
|
|
14939
|
+
var _this8 = this;
|
|
15003
14940
|
if (this.inited) {
|
|
15004
14941
|
if (!parent.isConnected) {
|
|
15005
14942
|
parent.ownerDocument = this.document;
|
|
@@ -15016,7 +14953,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
15016
14953
|
}
|
|
15017
14954
|
// recursively mount children
|
|
15018
14955
|
parent.childNodes.forEach(function (child) {
|
|
15019
|
-
|
|
14956
|
+
_this8.mountChildren(child);
|
|
15020
14957
|
});
|
|
15021
14958
|
// trigger after mounted
|
|
15022
14959
|
if (parent.isCustomElement) {
|
|
@@ -15060,11 +14997,11 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
15060
14997
|
_createClass(Canvas, [{
|
|
15061
14998
|
key: "ready",
|
|
15062
14999
|
get: function get() {
|
|
15063
|
-
var
|
|
15000
|
+
var _this9 = this;
|
|
15064
15001
|
if (!this.readyPromise) {
|
|
15065
15002
|
this.readyPromise = new Promise(function (resolve) {
|
|
15066
|
-
|
|
15067
|
-
resolve(
|
|
15003
|
+
_this9.resolveReadyPromise = function () {
|
|
15004
|
+
resolve(_this9);
|
|
15068
15005
|
};
|
|
15069
15006
|
});
|
|
15070
15007
|
if (this.inited) {
|