@visactor/vrender-core 1.1.0-alpha.24 → 1.1.0-alpha.25
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/cjs/allocator/bounds-allocate.js +1 -2
- package/cjs/canvas/constants.js +2 -1
- package/cjs/common/bezier-utils.js +1 -2
- package/cjs/common/event-transformer.js +2 -1
- package/cjs/common/performance-raf.js +1 -2
- package/cjs/common/polygon.js +2 -2
- package/cjs/common/rect-utils.js +1 -1
- package/cjs/common/render-area.js +1 -1
- package/cjs/common/render-command-list.js +1 -1
- package/cjs/common/render-curve.js +1 -1
- package/cjs/common/render-utils.js +1 -1
- package/cjs/common/seg-context.js +1 -1
- package/cjs/container.d.ts +2 -0
- package/cjs/container.js +50 -0
- package/cjs/container.js.map +1 -0
- package/cjs/core/application.js +1 -1
- package/cjs/core/camera.js +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/core-modules.js +1 -1
- package/cjs/core/global-module.js +2 -0
- package/cjs/core/global.js +1 -1
- package/cjs/core/graphic-utils.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/layer-service.js +2 -1
- package/cjs/core/layer.js +1 -1
- package/cjs/core/light.js +1 -1
- package/cjs/core/stage.d.ts +0 -9
- package/cjs/core/stage.js +12 -30
- package/cjs/core/stage.js.map +1 -1
- package/cjs/core/window.js +1 -1
- package/cjs/entries/miniapp.d.ts +0 -1
- package/cjs/entries/miniapp.js +1 -5
- package/cjs/entries/miniapp.js.map +1 -1
- package/cjs/entries/node.d.ts +0 -1
- package/cjs/entries/node.js +1 -5
- package/cjs/entries/node.js.map +1 -1
- package/cjs/env.d.ts +1 -0
- package/cjs/env.js +25 -0
- package/cjs/env.js.map +1 -0
- package/cjs/event/public-constant.d.ts +7 -0
- package/cjs/event/public-constant.js +100 -0
- package/cjs/event/public-constant.js.map +1 -0
- package/cjs/event/util.d.ts +1 -1
- package/cjs/graphic/base.d.ts +2 -0
- package/cjs/graphic/base.js +15 -0
- package/cjs/graphic/base.js.map +1 -0
- package/cjs/graphic/creator.d.ts +16 -0
- package/cjs/graphic/creator.js +160 -0
- package/cjs/graphic/creator.js.map +1 -0
- package/cjs/graphic/glyph.js +4 -8
- package/cjs/graphic/glyph.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +19 -29
- package/cjs/graphic/graphic.js +121 -199
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.d.ts +1 -3
- package/cjs/graphic/group.js +22 -28
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/modules.d.ts +16 -0
- package/cjs/graphic/modules.js +150 -0
- package/cjs/graphic/modules.js.map +1 -0
- package/cjs/graphic/node-tree.d.ts +3 -3
- package/cjs/graphic/node-tree.js +1 -0
- package/cjs/graphic/node-tree.js.map +1 -1
- package/cjs/graphic/state/shared-state-refresh.js +11 -32
- package/cjs/graphic/state/shared-state-refresh.js.map +1 -1
- package/cjs/graphic/state/shared-state-scope.d.ts +2 -5
- package/cjs/graphic/state/shared-state-scope.js +8 -27
- package/cjs/graphic/state/shared-state-scope.js.map +1 -1
- package/cjs/graphic/state/state-definition-compiler.js +4 -5
- package/cjs/graphic/state/state-definition-compiler.js.map +1 -1
- package/cjs/graphic/state/state-definition.d.ts +2 -5
- package/cjs/graphic/state/state-definition.js.map +1 -1
- package/cjs/graphic/state/state-engine.d.ts +0 -5
- package/cjs/graphic/state/state-engine.js +20 -70
- package/cjs/graphic/state/state-engine.js.map +1 -1
- package/cjs/graphic/state/state-transition-orchestrator.d.ts +7 -9
- package/cjs/graphic/state/state-transition-orchestrator.js +10 -13
- package/cjs/graphic/state/state-transition-orchestrator.js.map +1 -1
- package/cjs/interface/graphic/group.d.ts +0 -2
- package/cjs/interface/graphic/group.js.map +1 -1
- package/cjs/interface/graphic.d.ts +1 -5
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/index.js.map +1 -1
- package/cjs/interface/node-tree.d.ts +3 -0
- package/cjs/interface/node-tree.js.map +1 -1
- package/cjs/interface/stage.d.ts +0 -7
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/interpolate.d.ts +2 -0
- package/cjs/interpolate.js +34 -0
- package/cjs/interpolate.js.map +1 -0
- package/cjs/modules.js.map +1 -1
- package/cjs/path.d.ts +4 -0
- package/cjs/path.js +33 -0
- package/cjs/path.js.map +1 -0
- package/cjs/plugin/3d.d.ts +3 -0
- package/cjs/plugin/3d.js +33 -0
- package/cjs/plugin/3d.js.map +1 -0
- package/cjs/plugin/attribute.d.ts +2 -0
- package/cjs/plugin/attribute.js +24 -0
- package/cjs/plugin/attribute.js.map +1 -0
- package/cjs/plugin/flex-layout.d.ts +1 -0
- package/cjs/plugin/flex-layout.js +15 -0
- package/cjs/plugin/flex-layout.js.map +1 -0
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js +8 -8
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/cjs/plugins/index.d.ts +0 -4
- package/cjs/plugins/index.js +1 -3
- package/cjs/plugins/index.js.map +1 -1
- package/cjs/plugins/plugin-service.d.ts +0 -1
- package/cjs/plugins/plugin-service.js +2 -3
- package/cjs/plugins/plugin-service.js.map +1 -1
- package/cjs/plugins/types.d.ts +1 -8
- package/cjs/plugins/types.js.map +1 -1
- package/cjs/register/graphic.d.ts +19 -0
- package/cjs/register/graphic.js +177 -0
- package/cjs/register/graphic.js.map +1 -0
- package/cjs/registry/contribution-registry.d.ts +0 -1
- package/cjs/registry/contribution-registry.js +0 -3
- package/cjs/registry/contribution-registry.js.map +1 -1
- package/cjs/registry/picker-registry.d.ts +0 -1
- package/cjs/registry/picker-registry.js +0 -3
- package/cjs/registry/picker-registry.js.map +1 -1
- package/cjs/registry/renderer-registry.d.ts +0 -1
- package/cjs/registry/renderer-registry.js +0 -3
- package/cjs/registry/renderer-registry.js.map +1 -1
- package/cjs/registry/types.d.ts +0 -3
- package/cjs/registry/types.js.map +1 -1
- package/cjs/svg.d.ts +1 -0
- package/cjs/svg.js +15 -0
- package/cjs/svg.js.map +1 -0
- package/cjs/text.d.ts +2 -0
- package/cjs/text.js +29 -0
- package/cjs/text.js.map +1 -0
- package/dist/index.es.js +279 -1591
- package/es/allocator/bounds-allocate.js +1 -2
- package/es/canvas/constants.js +2 -1
- package/es/common/bezier-utils.js +1 -2
- package/es/common/event-transformer.js +2 -1
- package/es/common/performance-raf.js +1 -2
- package/es/common/polygon.js +1 -1
- package/es/common/rect-utils.js +1 -1
- package/es/common/render-area.js +1 -1
- package/es/common/render-command-list.js +1 -1
- package/es/common/render-curve.js +1 -1
- package/es/common/render-utils.js +1 -1
- package/es/common/seg-context.js +1 -1
- package/es/container.d.ts +2 -0
- package/es/container.js +2 -0
- package/es/container.js.map +1 -0
- package/es/core/application.js +1 -1
- package/es/core/camera.js +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/core-modules.js +1 -1
- package/es/core/global-module.js +2 -0
- package/es/core/global.js +1 -1
- package/es/core/graphic-utils.js +1 -1
- package/es/core/index.js +1 -1
- package/es/core/layer-service.js +2 -1
- package/es/core/layer.js +1 -1
- package/es/core/light.js +1 -1
- package/es/core/stage.d.ts +0 -9
- package/es/core/stage.js +10 -31
- package/es/core/stage.js.map +1 -1
- package/es/core/window.js +1 -1
- package/es/entries/miniapp.d.ts +0 -1
- package/es/entries/miniapp.js +1 -5
- package/es/entries/miniapp.js.map +1 -1
- package/es/entries/node.d.ts +0 -1
- package/es/entries/node.js +1 -5
- package/es/entries/node.js.map +1 -1
- package/es/env.d.ts +1 -0
- package/es/env.js +2 -0
- package/es/env.js.map +1 -0
- package/es/event/public-constant.d.ts +7 -0
- package/es/event/public-constant.js +12 -0
- package/es/event/public-constant.js.map +1 -0
- package/es/event/util.d.ts +1 -1
- package/es/graphic/base.d.ts +2 -0
- package/es/graphic/base.js +2 -0
- package/es/graphic/base.js.map +1 -0
- package/es/graphic/creator.d.ts +16 -0
- package/es/graphic/creator.js +32 -0
- package/es/graphic/creator.js.map +1 -0
- package/es/graphic/glyph.js +4 -8
- package/es/graphic/glyph.js.map +1 -1
- package/es/graphic/graphic.d.ts +19 -29
- package/es/graphic/graphic.js +120 -204
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.d.ts +1 -3
- package/es/graphic/group.js +22 -28
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/modules.d.ts +16 -0
- package/es/graphic/modules.js +32 -0
- package/es/graphic/modules.js.map +1 -0
- package/es/graphic/node-tree.d.ts +3 -3
- package/es/graphic/node-tree.js +1 -0
- package/es/graphic/node-tree.js.map +1 -1
- package/es/graphic/state/shared-state-refresh.js +8 -28
- package/es/graphic/state/shared-state-refresh.js.map +1 -1
- package/es/graphic/state/shared-state-scope.d.ts +2 -5
- package/es/graphic/state/shared-state-scope.js +7 -28
- package/es/graphic/state/shared-state-scope.js.map +1 -1
- package/es/graphic/state/state-definition-compiler.js +4 -5
- package/es/graphic/state/state-definition-compiler.js.map +1 -1
- package/es/graphic/state/state-definition.d.ts +2 -5
- package/es/graphic/state/state-definition.js.map +1 -1
- package/es/graphic/state/state-engine.d.ts +0 -5
- package/es/graphic/state/state-engine.js +17 -67
- package/es/graphic/state/state-engine.js.map +1 -1
- package/es/graphic/state/state-transition-orchestrator.d.ts +7 -9
- package/es/graphic/state/state-transition-orchestrator.js +10 -13
- package/es/graphic/state/state-transition-orchestrator.js.map +1 -1
- package/es/interface/graphic/group.d.ts +0 -2
- package/es/interface/graphic/group.js.map +1 -1
- package/es/interface/graphic.d.ts +1 -5
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/index.js.map +1 -1
- package/es/interface/node-tree.d.ts +3 -0
- package/es/interface/node-tree.js.map +1 -1
- package/es/interface/stage.d.ts +0 -7
- package/es/interface/stage.js.map +1 -1
- package/es/interpolate.d.ts +2 -0
- package/es/interpolate.js +4 -0
- package/es/interpolate.js.map +1 -0
- package/es/modules.js.map +1 -1
- package/es/path.d.ts +4 -0
- package/es/path.js +6 -0
- package/es/path.js.map +1 -0
- package/es/plugin/3d.d.ts +3 -0
- package/es/plugin/3d.js +6 -0
- package/es/plugin/3d.js.map +1 -0
- package/es/plugin/attribute.d.ts +2 -0
- package/es/plugin/attribute.js +4 -0
- package/es/plugin/attribute.js.map +1 -0
- package/es/plugin/flex-layout.d.ts +1 -0
- package/es/plugin/flex-layout.js +2 -0
- package/es/plugin/flex-layout.js.map +1 -0
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js +8 -8
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/es/plugins/index.d.ts +0 -4
- package/es/plugins/index.js +0 -8
- package/es/plugins/index.js.map +1 -1
- package/es/plugins/plugin-service.d.ts +0 -1
- package/es/plugins/plugin-service.js +2 -3
- package/es/plugins/plugin-service.js.map +1 -1
- package/es/plugins/types.d.ts +1 -8
- package/es/plugins/types.js.map +1 -1
- package/es/register/graphic.d.ts +19 -0
- package/es/register/graphic.js +38 -0
- package/es/register/graphic.js.map +1 -0
- package/es/registry/contribution-registry.d.ts +0 -1
- package/es/registry/contribution-registry.js +0 -3
- package/es/registry/contribution-registry.js.map +1 -1
- package/es/registry/picker-registry.d.ts +0 -1
- package/es/registry/picker-registry.js +0 -3
- package/es/registry/picker-registry.js.map +1 -1
- package/es/registry/renderer-registry.d.ts +0 -1
- package/es/registry/renderer-registry.js +0 -3
- package/es/registry/renderer-registry.js.map +1 -1
- package/es/registry/types.d.ts +0 -3
- package/es/registry/types.js.map +1 -1
- package/es/svg.d.ts +1 -0
- package/es/svg.js +2 -0
- package/es/svg.js.map +1 -0
- package/es/text.d.ts +2 -0
- package/es/text.js +4 -0
- package/es/text.js.map +1 -0
- package/package.json +247 -3
- package/cjs/graphic/state/state-batch-scheduler.d.ts +0 -42
- package/cjs/graphic/state/state-batch-scheduler.js +0 -285
- package/cjs/graphic/state/state-batch-scheduler.js.map +0 -1
- package/cjs/graphic/state/state-model.d.ts +0 -43
- package/cjs/graphic/state/state-model.js +0 -143
- package/cjs/graphic/state/state-model.js.map +0 -1
- package/cjs/graphic/state/state-perf-monitor.d.ts +0 -120
- package/cjs/graphic/state/state-perf-monitor.js +0 -224
- package/cjs/graphic/state/state-perf-monitor.js.map +0 -1
- package/cjs/graphic/state/state-style-resolver.d.ts +0 -13
- package/cjs/graphic/state/state-style-resolver.js +0 -50
- package/cjs/graphic/state/state-style-resolver.js.map +0 -1
- package/cjs/interface/animate.d.ts +0 -1
- package/cjs/interface/animate.js +0 -3
- package/cjs/interface/animate.js.map +0 -1
- package/cjs/plugins/base-plugin.d.ts +0 -8
- package/cjs/plugins/base-plugin.js +0 -15
- package/cjs/plugins/base-plugin.js.map +0 -1
- package/cjs/plugins/browser-env-plugin.d.ts +0 -8
- package/cjs/plugins/browser-env-plugin.js +0 -24
- package/cjs/plugins/browser-env-plugin.js.map +0 -1
- package/cjs/plugins/picker-plugin.d.ts +0 -7
- package/cjs/plugins/picker-plugin.js +0 -19
- package/cjs/plugins/picker-plugin.js.map +0 -1
- package/cjs/plugins/renderer-plugin.d.ts +0 -7
- package/cjs/plugins/renderer-plugin.js +0 -19
- package/cjs/plugins/renderer-plugin.js.map +0 -1
- package/es/graphic/state/state-batch-scheduler.d.ts +0 -42
- package/es/graphic/state/state-batch-scheduler.js +0 -278
- package/es/graphic/state/state-batch-scheduler.js.map +0 -1
- package/es/graphic/state/state-model.d.ts +0 -43
- package/es/graphic/state/state-model.js +0 -135
- package/es/graphic/state/state-model.js.map +0 -1
- package/es/graphic/state/state-perf-monitor.d.ts +0 -120
- package/es/graphic/state/state-perf-monitor.js +0 -214
- package/es/graphic/state/state-perf-monitor.js.map +0 -1
- package/es/graphic/state/state-style-resolver.d.ts +0 -13
- package/es/graphic/state/state-style-resolver.js +0 -42
- package/es/graphic/state/state-style-resolver.js.map +0 -1
- package/es/interface/animate.d.ts +0 -1
- package/es/interface/animate.js +0 -3
- package/es/interface/animate.js.map +0 -1
- package/es/plugins/base-plugin.d.ts +0 -8
- package/es/plugins/base-plugin.js +0 -7
- package/es/plugins/base-plugin.js.map +0 -1
- package/es/plugins/browser-env-plugin.d.ts +0 -8
- package/es/plugins/browser-env-plugin.js +0 -16
- package/es/plugins/browser-env-plugin.js.map +0 -1
- package/es/plugins/picker-plugin.d.ts +0 -7
- package/es/plugins/picker-plugin.js +0 -11
- package/es/plugins/picker-plugin.js.map +0 -1
- package/es/plugins/renderer-plugin.d.ts +0 -7
- package/es/plugins/renderer-plugin.js +0 -11
- package/es/plugins/renderer-plugin.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin/attribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAC9F,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC","file":"attribute.js","sourcesContent":["export { registerHtmlAttributePlugin } from '../plugins/builtin-plugin/html-attribute-plugin';\nexport { registerReactAttributePlugin } from '../plugins/builtin-plugin/react-attribute-plugin';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { registerFlexLayoutPlugin } from '../plugins/builtin-plugin/flex-layout-plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin/flex-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC","file":"flex-layout.js","sourcesContent":["export { registerFlexLayoutPlugin } from '../plugins/builtin-plugin/flex-layout-plugin';\n"]}
|
|
@@ -10,30 +10,30 @@ export class DirtyBoundsPlugin {
|
|
|
10
10
|
constructor() {
|
|
11
11
|
this.name = "DirtyBoundsPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(),
|
|
12
12
|
this.key = this.name + this._uid, this.dirtyBoundsHooksRegistered = !1, this.handlePaintOnlyUpdate = graphic => {
|
|
13
|
-
var _a
|
|
13
|
+
var _a;
|
|
14
14
|
const stage = this.pluginService.stage;
|
|
15
15
|
if (!stage || stage !== graphic.stage || !stage.renderCount) return;
|
|
16
16
|
const owner = null !== (_a = graphic.glyphHost) && void 0 !== _a ? _a : graphic;
|
|
17
17
|
if (!(owner._updateTag & UpdateTag.UPDATE_PAINT) || owner._updateTag & UpdateTag.UPDATE_BOUNDS) return;
|
|
18
18
|
const ownerBounds = this.ensurePaintDirtyBoundsCache(owner);
|
|
19
|
-
ownerBounds && !ownerBounds.empty() && stage.dirty(ownerBounds),
|
|
19
|
+
ownerBounds && !ownerBounds.empty() && stage.dirty(ownerBounds), owner.clearUpdatePaintTag();
|
|
20
20
|
const shadowRoot = owner.shadowRoot;
|
|
21
21
|
if (!shadowRoot) return;
|
|
22
22
|
const shadowBounds = this.ensurePaintDirtyBoundsCache(shadowRoot);
|
|
23
|
-
shadowBounds && !shadowBounds.empty() && stage.dirty(shadowBounds),
|
|
23
|
+
shadowBounds && !shadowBounds.empty() && stage.dirty(shadowBounds), shadowRoot.clearUpdatePaintTag();
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
ensurePaintDirtyBoundsCache(graphic) {
|
|
27
|
-
var _a
|
|
27
|
+
var _a;
|
|
28
28
|
const owner = graphic;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return owner._AABBBounds.empty() && owner.doUpdateAABBBounds("imprecise" === (null === (_a = owner.attribute) || void 0 === _a ? void 0 : _a.boundsMode)),
|
|
30
|
+
owner._globalAABBBounds && !owner._globalAABBBounds.empty() || owner.tryUpdateGlobalAABBBounds(),
|
|
31
|
+
owner._globalAABBBounds;
|
|
32
32
|
}
|
|
33
33
|
getRemoveDirtyBounds(graphic) {
|
|
34
34
|
var _a;
|
|
35
35
|
const cachedBounds = (null !== (_a = graphic.glyphHost) && void 0 !== _a ? _a : graphic)._globalAABBBounds;
|
|
36
|
-
if (cachedBounds &&
|
|
36
|
+
if (cachedBounds && !cachedBounds.empty()) return cachedBounds;
|
|
37
37
|
}
|
|
38
38
|
registerDirtyBoundsHooks(stage) {
|
|
39
39
|
this.dirtyBoundsHooksRegistered || (stage.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handlePaintOnlyUpdate),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/dirty-bounds-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,MAAM,YAAY,GAAG,IAAI,UAAU,EAAE,CAAC;AAEtC,MAAM,OAAO,iBAAiB;IAA9B;QACE,SAAI,GAAwB,mBAAmB,CAAC;QAChD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,+BAA0B,GAAY,KAAK,CAAC;QA6B5C,0BAAqB,GAAG,CAAC,OAAiB,EAAE,EAAE;;YACtD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;YACvC,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,WAAW,CAAC,EAAE;gBAC5D,OAAO;aACR;YAED,MAAM,KAAK,GAAG,CAAC,MAAA,OAAO,CAAC,SAAS,mCAAI,OAAO,CAAQ,CAAC;YACpD,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,GAAG,SAAS,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,UAAU,GAAG,SAAS,CAAC,aAAa,EAAE;gBAC9F,OAAO;aACR;YAED,MAAM,WAAW,GAAG,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;YAC5D,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE;gBACvC,KAAK,CAAC,KAA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utils';\nimport { UpdateTag } from '../../common/enums';\nimport { Generator } from '../../common/generator';\nimport type { IGraphic, IStage, IPlugin, IPluginService } from '../../interface';\n\nconst globalBounds = new AABBBounds();\n\nexport class DirtyBoundsPlugin implements IPlugin {\n name: 'DirtyBoundsPlugin' = 'DirtyBoundsPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n protected dirtyBoundsHooksRegistered: boolean = false;\n\n protected ensurePaintDirtyBoundsCache(graphic: IGraphic): IAABBBounds {\n const owner = graphic as any;\n const hasLocalBounds =\n owner._AABBBounds && typeof owner._AABBBounds.empty === 'function' && !owner._AABBBounds.empty();\n if (!hasLocalBounds && typeof owner.doUpdateAABBBounds === 'function') {\n owner.doUpdateAABBBounds(owner.attribute?.boundsMode === 'imprecise');\n }\n\n const hasGlobalBounds =\n owner._globalAABBBounds &&\n typeof owner._globalAABBBounds.empty === 'function' &&\n !owner._globalAABBBounds.empty();\n if (!hasGlobalBounds && typeof owner.tryUpdateGlobalAABBBounds === 'function') {\n owner.tryUpdateGlobalAABBBounds();\n }\n\n return owner._globalAABBBounds ?? owner.globalAABBBounds;\n }\n\n protected getRemoveDirtyBounds(graphic: IGraphic): IAABBBounds | undefined {\n const owner = (graphic.glyphHost ?? graphic) as any;\n const cachedBounds = owner._globalAABBBounds as IAABBBounds | undefined;\n if (cachedBounds && typeof cachedBounds.empty === 'function' && !cachedBounds.empty()) {\n return cachedBounds;\n }\n }\n\n protected handlePaintOnlyUpdate = (graphic: IGraphic) => {\n const stage = this.pluginService.stage;\n if (!(stage && stage === graphic.stage && stage.renderCount)) {\n return;\n }\n\n const owner = (graphic.glyphHost ?? graphic) as any;\n if (!(owner._updateTag & UpdateTag.UPDATE_PAINT) || owner._updateTag & UpdateTag.UPDATE_BOUNDS) {\n return;\n }\n\n const ownerBounds = this.ensurePaintDirtyBoundsCache(owner);\n if (ownerBounds && !ownerBounds.empty()) {\n stage.dirty(ownerBounds);\n }\n owner.clearUpdatePaintTag?.();\n\n const shadowRoot = owner.shadowRoot as IGraphic | undefined;\n if (!shadowRoot) {\n return;\n }\n\n const shadowBounds = this.ensurePaintDirtyBoundsCache(shadowRoot);\n if (shadowBounds && !shadowBounds.empty()) {\n stage.dirty(shadowBounds);\n }\n (shadowRoot as any).clearUpdatePaintTag?.();\n };\n\n protected registerDirtyBoundsHooks(stage: IStage): void {\n if (this.dirtyBoundsHooksRegistered) {\n return;\n }\n stage.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handlePaintOnlyUpdate);\n stage.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds()) {\n return;\n }\n if (willUpdate) {\n globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2);\n stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix);\n }\n }\n );\n stage.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !selfChange) {\n return;\n }\n stage.dirty(params.globalAABBBounds);\n }\n );\n stage.graphicService.hooks.clearAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, bounds: IAABBBounds) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(bounds);\n }\n }\n );\n stage.graphicService.hooks.onRemove.tap(this.key, (graphic: IGraphic) => {\n const stage = graphic.stage;\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n const bounds = this.getRemoveDirtyBounds(graphic);\n if (bounds && !bounds.empty()) {\n stage.dirty(bounds);\n }\n });\n this.dirtyBoundsHooksRegistered = true;\n }\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n stage.dirtyBounds.clear();\n this.registerDirtyBoundsHooks(stage);\n });\n const stage = this.pluginService.stage;\n if (!stage) {\n return;\n }\n if (stage.renderCount) {\n this.registerDirtyBoundsHooks(stage);\n }\n }\n deactivate(context: IPluginService): void {\n const stage = this.pluginService.stage;\n if (!stage) {\n return;\n }\n stage.graphicService.hooks.onAttributeUpdate.taps = stage.graphicService.hooks.onAttributeUpdate.taps.filter(\n item => {\n return item.name !== this.key;\n }\n );\n this.dirtyBoundsHooksRegistered = false;\n stage.graphicService.hooks.beforeUpdateAABBBounds.taps =\n stage.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n stage.graphicService.hooks.afterUpdateAABBBounds.taps =\n stage.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n stage.graphicService.hooks.clearAABBBounds.taps = stage.graphicService.hooks.clearAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n stage.hooks.afterRender.taps = stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n stage.graphicService.hooks.onRemove.taps = stage.graphicService.hooks.onRemove.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugins/builtin-plugin/dirty-bounds-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE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ACH,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACxE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAChG,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","file":"dirty-bounds-plugin.js","sourcesContent":["import { AABBBounds, type IAABBBounds } from '@visactor/vutils';\nimport { UpdateTag } from '../../common/enums';\nimport { Generator } from '../../common/generator';\nimport type { IGraphic, IStage, IPlugin, IPluginService } from '../../interface';\n\nconst globalBounds = new AABBBounds();\n\nexport class DirtyBoundsPlugin implements IPlugin {\n name: 'DirtyBoundsPlugin' = 'DirtyBoundsPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n protected dirtyBoundsHooksRegistered = false;\n\n protected ensurePaintDirtyBoundsCache(graphic: IGraphic): IAABBBounds {\n const owner = graphic as any;\n if (owner._AABBBounds.empty()) {\n owner.doUpdateAABBBounds(owner.attribute?.boundsMode === 'imprecise');\n }\n\n if (!owner._globalAABBBounds || owner._globalAABBBounds.empty()) {\n owner.tryUpdateGlobalAABBBounds();\n }\n\n return owner._globalAABBBounds;\n }\n\n protected getRemoveDirtyBounds(graphic: IGraphic): IAABBBounds | undefined {\n const owner = (graphic.glyphHost ?? graphic) as any;\n const cachedBounds = owner._globalAABBBounds as IAABBBounds | undefined;\n if (cachedBounds && !cachedBounds.empty()) {\n return cachedBounds;\n }\n }\n\n protected handlePaintOnlyUpdate = (graphic: IGraphic) => {\n const stage = this.pluginService.stage;\n if (!(stage && stage === graphic.stage && stage.renderCount)) {\n return;\n }\n\n const owner = (graphic.glyphHost ?? graphic) as any;\n if (!(owner._updateTag & UpdateTag.UPDATE_PAINT) || owner._updateTag & UpdateTag.UPDATE_BOUNDS) {\n return;\n }\n\n const ownerBounds = this.ensurePaintDirtyBoundsCache(owner);\n if (ownerBounds && !ownerBounds.empty()) {\n stage.dirty(ownerBounds);\n }\n owner.clearUpdatePaintTag();\n\n const shadowRoot = owner.shadowRoot as IGraphic | undefined;\n if (!shadowRoot) {\n return;\n }\n\n const shadowBounds = this.ensurePaintDirtyBoundsCache(shadowRoot);\n if (shadowBounds && !shadowBounds.empty()) {\n stage.dirty(shadowBounds);\n }\n (shadowRoot as any).clearUpdatePaintTag();\n };\n\n protected registerDirtyBoundsHooks(stage: IStage): void {\n if (this.dirtyBoundsHooksRegistered) {\n return;\n }\n stage.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handlePaintOnlyUpdate);\n stage.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds()) {\n return;\n }\n if (willUpdate) {\n globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2);\n stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix);\n }\n }\n );\n stage.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !selfChange) {\n return;\n }\n stage.dirty(params.globalAABBBounds);\n }\n );\n stage.graphicService.hooks.clearAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, bounds: IAABBBounds) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(bounds);\n }\n }\n );\n stage.graphicService.hooks.onRemove.tap(this.key, (graphic: IGraphic) => {\n const stage = graphic.stage;\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n const bounds = this.getRemoveDirtyBounds(graphic);\n if (bounds && !bounds.empty()) {\n stage.dirty(bounds);\n }\n });\n this.dirtyBoundsHooksRegistered = true;\n }\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n stage.dirtyBounds.clear();\n this.registerDirtyBoundsHooks(stage);\n });\n const stage = this.pluginService.stage;\n if (!stage) {\n return;\n }\n if (stage.renderCount) {\n this.registerDirtyBoundsHooks(stage);\n }\n }\n deactivate(context: IPluginService): void {\n const stage = this.pluginService.stage;\n if (!stage) {\n return;\n }\n stage.graphicService.hooks.onAttributeUpdate.taps = stage.graphicService.hooks.onAttributeUpdate.taps.filter(\n item => {\n return item.name !== this.key;\n }\n );\n this.dirtyBoundsHooksRegistered = false;\n stage.graphicService.hooks.beforeUpdateAABBBounds.taps =\n stage.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n stage.graphicService.hooks.afterUpdateAABBBounds.taps =\n stage.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n stage.graphicService.hooks.clearAABBBounds.taps = stage.graphicService.hooks.clearAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n stage.hooks.afterRender.taps = stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n stage.graphicService.hooks.onRemove.taps = stage.graphicService.hooks.onRemove.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n"]}
|
package/es/plugins/index.d.ts
CHANGED
package/es/plugins/index.js
CHANGED
package/es/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC
|
|
1
|
+
{"version":3,"sources":["../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC","file":"index.js","sourcesContent":["export * from './types';\n"]}
|
|
@@ -7,7 +7,6 @@ interface ILegacyPluginRegistry {
|
|
|
7
7
|
}
|
|
8
8
|
interface IPluginServiceDeps {
|
|
9
9
|
pluginRegistry?: ILegacyPluginRegistry;
|
|
10
|
-
autoEnablePlugins?: IContributionProvider<IPlugin>;
|
|
11
10
|
}
|
|
12
11
|
export declare class DefaultPluginService implements IPluginService {
|
|
13
12
|
protected autoEnablePlugins: IContributionProvider<IPlugin>;
|
|
@@ -6,10 +6,9 @@ const EMPTY_AUTO_ENABLE_PROVIDER = {
|
|
|
6
6
|
|
|
7
7
|
export class DefaultPluginService {
|
|
8
8
|
constructor(autoEnablePlugins = EMPTY_AUTO_ENABLE_PROVIDER, deps = {}) {
|
|
9
|
-
var _a
|
|
9
|
+
var _a;
|
|
10
10
|
this.autoEnablePlugins = autoEnablePlugins, this.onStartupFinishedPlugin = [], this.onRegisterPlugin = [],
|
|
11
|
-
this.actived = !1, this.pluginRegistry = null !== (_a = deps.pluginRegistry) && void 0 !== _a ? _a : new PluginRegistry
|
|
12
|
-
this.autoEnablePlugins = null !== (_c = null !== (_b = deps.autoEnablePlugins) && void 0 !== _b ? _b : this.autoEnablePlugins) && void 0 !== _c ? _c : EMPTY_AUTO_ENABLE_PROVIDER;
|
|
11
|
+
this.actived = !1, this.pluginRegistry = null !== (_a = deps.pluginRegistry) && void 0 !== _a ? _a : new PluginRegistry;
|
|
13
12
|
}
|
|
14
13
|
active(stage, params) {
|
|
15
14
|
this.stage = stage, this.actived = !0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/plugin-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/plugins/plugin-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAa7C,MAAM,0BAA0B,GAAmC;IACjE,gBAAgB,EAAE,GAAG,EAAE,CAAC,EAAE;CAC3B,CAAC;AAEF,MAAM,OAAO,oBAAoB;IAO/B,YACY,oBAAoD,0BAA0B,EACxF,OAA2B,EAAE;;QADnB,sBAAiB,GAAjB,iBAAiB,CAA6D;QAGxF,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,MAAA,IAAI,CAAC,cAAc,mCAAK,IAAI,cAAc,EAAuC,CAAC;IAC1G,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,MAAiC;QACrD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAGpB,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAC9B,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,EAAE;YACtB,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;gBACpD,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;oBAC/B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACjB;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED,iBAAiB,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.js","sourcesContent":["import type { IContributionProvider, IPlugin, IPluginService, IStage } from '../interface';\nimport { PluginRegistry } from '../registry';\n\ninterface ILegacyPluginRegistry {\n install: (plugin: IPlugin) => void;\n uninstall: (name: string) => void;\n get: (name: string) => IPlugin | undefined;\n clear: () => void;\n}\n\ninterface IPluginServiceDeps {\n pluginRegistry?: ILegacyPluginRegistry;\n}\n\nconst EMPTY_AUTO_ENABLE_PROVIDER: IContributionProvider<IPlugin> = {\n getContributions: () => []\n};\n\nexport class DefaultPluginService implements IPluginService {\n declare onStartupFinishedPlugin: IPlugin[];\n declare onRegisterPlugin: IPlugin[];\n declare stage: IStage;\n declare actived: boolean;\n readonly pluginRegistry: ILegacyPluginRegistry;\n\n constructor(\n protected autoEnablePlugins: IContributionProvider<IPlugin> = EMPTY_AUTO_ENABLE_PROVIDER,\n deps: IPluginServiceDeps = {}\n ) {\n this.onStartupFinishedPlugin = [];\n this.onRegisterPlugin = [];\n this.actived = false;\n this.pluginRegistry = deps.pluginRegistry ?? (new PluginRegistry() as unknown as ILegacyPluginRegistry);\n }\n\n active(stage: IStage, params: { pluginList?: string[] }) {\n this.stage = stage;\n this.actived = true;\n\n // 启动插件\n const { pluginList } = params;\n if (pluginList?.length) {\n this.autoEnablePlugins.getContributions().forEach(p => {\n if (pluginList.includes(p.name)) {\n this.install(p);\n }\n });\n }\n }\n\n findPluginsByName(name: string): IPlugin[] {\n const arr: IPlugin[] = [];\n this.onStartupFinishedPlugin.forEach(plugin => {\n if (plugin.name === name) {\n arr.push(plugin);\n }\n });\n this.onRegisterPlugin.forEach(plugin => {\n if (plugin.name === name) {\n arr.push(plugin);\n }\n });\n return arr;\n }\n\n install(plugin: IPlugin) {\n this.register(plugin);\n }\n\n uninstall(name: string) {\n const plugins = this.findPluginsByName(name);\n plugins.forEach(plugin => {\n this.unRegister(plugin);\n });\n this.pluginRegistry.uninstall(name);\n }\n\n register(plugin: IPlugin) {\n this.pluginRegistry.install(plugin);\n if (plugin.activeEvent === 'onStartupFinished') {\n if (!this.onStartupFinishedPlugin.includes(plugin)) {\n this.onStartupFinishedPlugin.push(plugin);\n }\n } else if (plugin.activeEvent === 'onRegister') {\n if (!this.onRegisterPlugin.includes(plugin)) {\n this.onRegisterPlugin.push(plugin);\n plugin.activate(this);\n }\n }\n }\n unRegister(plugin: IPlugin) {\n if (plugin.activeEvent === 'onStartupFinished') {\n this.onStartupFinishedPlugin = this.onStartupFinishedPlugin.filter(item => item !== plugin);\n } else if (plugin.activeEvent === 'onRegister') {\n this.onRegisterPlugin = this.onRegisterPlugin.filter(item => item !== plugin);\n }\n if (this.pluginRegistry.get(plugin.name) === plugin) {\n this.pluginRegistry.uninstall(plugin.name);\n }\n plugin.deactivate(this);\n }\n\n release(...params: any): void {\n this.onStartupFinishedPlugin.forEach(plugin => {\n plugin.deactivate(this);\n });\n this.onStartupFinishedPlugin = [];\n this.onRegisterPlugin.forEach(plugin => {\n plugin.deactivate(this);\n });\n this.onRegisterPlugin = [];\n this.pluginRegistry.clear();\n }\n}\n"]}
|
package/es/plugins/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { IGraphicPicker } from '../interface/picker';
|
|
2
1
|
import type { IGraphicFactory, ILayerFactory, IStageFactory } from '../factory';
|
|
3
|
-
import type { IContributionRegistry, IPickerRegistry, IPluginRegistry, IRendererRegistry
|
|
2
|
+
import type { IContributionRegistry, IPickerRegistry, IPluginRegistry, IRendererRegistry } from '../registry';
|
|
4
3
|
export interface IPlugin {
|
|
5
4
|
readonly name: string;
|
|
6
5
|
readonly version: string;
|
|
@@ -20,9 +19,3 @@ export interface IPluginContext {
|
|
|
20
19
|
graphic: IGraphicFactory;
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
|
-
export interface IBrowserEnvPluginHooks {
|
|
24
|
-
install?: (context: IPluginContext) => void;
|
|
25
|
-
uninstall?: () => void;
|
|
26
|
-
}
|
|
27
|
-
export type IRendererPluginEntries = Iterable<[RegistryKey, IRendererRegistryEntry]>;
|
|
28
|
-
export type IPickerPluginEntries = Iterable<[RegistryKey, IGraphicPicker]>;
|
package/es/plugins/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/types.ts"],"names":[],"mappings":"","file":"types.js","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/plugins/types.ts"],"names":[],"mappings":"","file":"types.js","sourcesContent":["import type { IGraphicFactory, ILayerFactory, IStageFactory } from '../factory';\nimport type { IContributionRegistry, IPickerRegistry, IPluginRegistry, IRendererRegistry } from '../registry';\n\nexport interface IPlugin {\n readonly name: string;\n readonly version: string;\n install: (context: IPluginContext) => void;\n uninstall?: () => void;\n}\n\nexport interface IPluginContext {\n registry: {\n renderer: IRendererRegistry;\n picker: IPickerRegistry;\n contribution: IContributionRegistry;\n plugin: IPluginRegistry;\n };\n factory: {\n stage: IStageFactory;\n layer: ILayerFactory;\n graphic: IGraphicFactory;\n };\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { registerArcGraphic } from './register-arc';
|
|
2
|
+
export { registerArc3dGraphic } from './register-arc3d';
|
|
3
|
+
export { registerAreaGraphic } from './register-area';
|
|
4
|
+
export { registerCircleGraphic } from './register-circle';
|
|
5
|
+
export { registerGlyphGraphic } from './register-glyph';
|
|
6
|
+
export { registerGroupGraphic } from './register-group';
|
|
7
|
+
export { registerImageGraphic } from './register-image';
|
|
8
|
+
export { registerLineGraphic } from './register-line';
|
|
9
|
+
export { registerPathGraphic } from './register-path';
|
|
10
|
+
export { registerPolygonGraphic } from './register-polygon';
|
|
11
|
+
export { registerPyramid3dGraphic } from './register-pyramid3d';
|
|
12
|
+
export { registerRectGraphic } from './register-rect';
|
|
13
|
+
export { registerRect3dGraphic } from './register-rect3d';
|
|
14
|
+
export { registerRichtextGraphic } from './register-richtext';
|
|
15
|
+
export { registerShadowRootGraphic } from './register-shadowRoot';
|
|
16
|
+
export { registerStarGraphic } from './register-star';
|
|
17
|
+
export { registerSymbolGraphic } from './register-symbol';
|
|
18
|
+
export { registerTextGraphic } from './register-text';
|
|
19
|
+
export { registerWrapTextGraphic } from './register-wraptext';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { registerArcGraphic } from "./register-arc";
|
|
2
|
+
|
|
3
|
+
export { registerArc3dGraphic } from "./register-arc3d";
|
|
4
|
+
|
|
5
|
+
export { registerAreaGraphic } from "./register-area";
|
|
6
|
+
|
|
7
|
+
export { registerCircleGraphic } from "./register-circle";
|
|
8
|
+
|
|
9
|
+
export { registerGlyphGraphic } from "./register-glyph";
|
|
10
|
+
|
|
11
|
+
export { registerGroupGraphic } from "./register-group";
|
|
12
|
+
|
|
13
|
+
export { registerImageGraphic } from "./register-image";
|
|
14
|
+
|
|
15
|
+
export { registerLineGraphic } from "./register-line";
|
|
16
|
+
|
|
17
|
+
export { registerPathGraphic } from "./register-path";
|
|
18
|
+
|
|
19
|
+
export { registerPolygonGraphic } from "./register-polygon";
|
|
20
|
+
|
|
21
|
+
export { registerPyramid3dGraphic } from "./register-pyramid3d";
|
|
22
|
+
|
|
23
|
+
export { registerRectGraphic } from "./register-rect";
|
|
24
|
+
|
|
25
|
+
export { registerRect3dGraphic } from "./register-rect3d";
|
|
26
|
+
|
|
27
|
+
export { registerRichtextGraphic } from "./register-richtext";
|
|
28
|
+
|
|
29
|
+
export { registerShadowRootGraphic } from "./register-shadowRoot";
|
|
30
|
+
|
|
31
|
+
export { registerStarGraphic } from "./register-star";
|
|
32
|
+
|
|
33
|
+
export { registerSymbolGraphic } from "./register-symbol";
|
|
34
|
+
|
|
35
|
+
export { registerTextGraphic } from "./register-text";
|
|
36
|
+
|
|
37
|
+
export { registerWrapTextGraphic } from "./register-wraptext";
|
|
38
|
+
//# sourceMappingURL=graphic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/register/graphic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC","file":"graphic.js","sourcesContent":["export { registerArcGraphic } from './register-arc';\nexport { registerArc3dGraphic } from './register-arc3d';\nexport { registerAreaGraphic } from './register-area';\nexport { registerCircleGraphic } from './register-circle';\nexport { registerGlyphGraphic } from './register-glyph';\nexport { registerGroupGraphic } from './register-group';\nexport { registerImageGraphic } from './register-image';\nexport { registerLineGraphic } from './register-line';\nexport { registerPathGraphic } from './register-path';\nexport { registerPolygonGraphic } from './register-polygon';\nexport { registerPyramid3dGraphic } from './register-pyramid3d';\nexport { registerRectGraphic } from './register-rect';\nexport { registerRect3dGraphic } from './register-rect3d';\nexport { registerRichtextGraphic } from './register-richtext';\nexport { registerShadowRootGraphic } from './register-shadowRoot';\nexport { registerStarGraphic } from './register-star';\nexport { registerSymbolGraphic } from './register-symbol';\nexport { registerTextGraphic } from './register-text';\nexport { registerWrapTextGraphic } from './register-wraptext';\n"]}
|
|
@@ -2,7 +2,6 @@ import type { IContributionRegistry, RegistryKey } from './types';
|
|
|
2
2
|
export declare class ContributionRegistry<T = unknown> implements IContributionRegistry<T> {
|
|
3
3
|
private readonly entries;
|
|
4
4
|
register(key: RegistryKey, contribution: T): void;
|
|
5
|
-
registerMany(entries: Iterable<[RegistryKey, T]>): void;
|
|
6
5
|
get(key: RegistryKey): T[];
|
|
7
6
|
getAll(): T[];
|
|
8
7
|
clear(key?: RegistryKey): void;
|
|
@@ -7,9 +7,6 @@ export class ContributionRegistry {
|
|
|
7
7
|
const current = null !== (_a = this.entries.get(key)) && void 0 !== _a ? _a : [];
|
|
8
8
|
current.push(contribution), this.entries.set(key, current);
|
|
9
9
|
}
|
|
10
|
-
registerMany(entries) {
|
|
11
|
-
for (const [key, contribution] of entries) this.register(key, contribution);
|
|
12
|
-
}
|
|
13
10
|
get(key) {
|
|
14
11
|
var _a;
|
|
15
12
|
return [ ...null !== (_a = this.entries.get(key)) && void 0 !== _a ? _a : [] ];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/registry/contribution-registry.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,oBAAoB;IAAjC;QACmB,YAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/registry/contribution-registry.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,oBAAoB;IAAjC;QACmB,YAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IA0BzD,CAAC;IAxBC,QAAQ,CAAC,GAAgB,EAAE,YAAe;;QACxC,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,GAAG,CAAC,GAAgB;;QAClB,OAAO,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAM,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;YACpE,GAAG,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;YACrB,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;IAED,KAAK,CAAC,GAAiB;QACrB,IAAI,GAAG,IAAI,IAAI,EAAE;YACf,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,OAAO;SACR;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF","file":"contribution-registry.js","sourcesContent":["import type { IContributionRegistry, RegistryKey } from './types';\n\nexport class ContributionRegistry<T = unknown> implements IContributionRegistry<T> {\n private readonly entries = new Map<RegistryKey, T[]>();\n\n register(key: RegistryKey, contribution: T): void {\n const current = this.entries.get(key) ?? [];\n current.push(contribution);\n this.entries.set(key, current);\n }\n\n get(key: RegistryKey): T[] {\n return [...(this.entries.get(key) ?? [])];\n }\n\n getAll(): T[] {\n return Array.from(this.entries.values()).reduce<T[]>((all, current) => {\n all.push(...current);\n return all;\n }, []);\n }\n\n clear(key?: RegistryKey): void {\n if (key == null) {\n this.entries.clear();\n return;\n }\n this.entries.delete(key);\n }\n}\n"]}
|
|
@@ -3,7 +3,6 @@ import type { IPickerRegistry, RegistryKey } from './types';
|
|
|
3
3
|
export declare class PickerRegistry implements IPickerRegistry {
|
|
4
4
|
private readonly entries;
|
|
5
5
|
register(key: RegistryKey, picker: IGraphicPicker): void;
|
|
6
|
-
registerMany(entries: Iterable<[RegistryKey, IGraphicPicker]>): void;
|
|
7
6
|
get(key: RegistryKey): IGraphicPicker | undefined;
|
|
8
7
|
getAll(): IGraphicPicker[];
|
|
9
8
|
clear(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/registry/picker-registry.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IAA3B;QACmB,YAAO,GAAG,IAAI,GAAG,EAA+B,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/registry/picker-registry.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IAA3B;QACmB,YAAO,GAAG,IAAI,GAAG,EAA+B,CAAC;IAiBpE,CAAC;IAfC,QAAQ,CAAC,GAAgB,EAAE,MAAsB;QAC/C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,GAAG,CAAC,GAAgB;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF","file":"picker-registry.js","sourcesContent":["import type { IGraphicPicker } from '../interface/picker';\nimport type { IPickerRegistry, RegistryKey } from './types';\n\nexport class PickerRegistry implements IPickerRegistry {\n private readonly entries = new Map<RegistryKey, IGraphicPicker>();\n\n register(key: RegistryKey, picker: IGraphicPicker): void {\n this.entries.set(key, picker);\n }\n\n get(key: RegistryKey): IGraphicPicker | undefined {\n return this.entries.get(key);\n }\n\n getAll(): IGraphicPicker[] {\n return Array.from(this.entries.values());\n }\n\n clear(): void {\n this.entries.clear();\n }\n}\n"]}
|
|
@@ -4,7 +4,6 @@ export declare class RendererRegistry implements IRendererRegistry {
|
|
|
4
4
|
private readonly entries;
|
|
5
5
|
private readonly cache;
|
|
6
6
|
register(key: RegistryKey, renderer: IRendererRegistryEntry): void;
|
|
7
|
-
registerMany(entries: Iterable<[RegistryKey, IRendererRegistryEntry]>): void;
|
|
8
7
|
get(key: RegistryKey): IGraphicRender | undefined;
|
|
9
8
|
getAll(): IGraphicRender[];
|
|
10
9
|
clear(): void;
|
|
@@ -9,9 +9,6 @@ export class RendererRegistry {
|
|
|
9
9
|
register(key, renderer) {
|
|
10
10
|
this.entries.set(key, renderer), this.cache.delete(key);
|
|
11
11
|
}
|
|
12
|
-
registerMany(entries) {
|
|
13
|
-
for (const [key, renderer] of entries) this.register(key, renderer);
|
|
14
|
-
}
|
|
15
12
|
get(key) {
|
|
16
13
|
if (this.cache.has(key)) return this.cache.get(key);
|
|
17
14
|
const entry = this.entries.get(key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/registry/renderer-registry.ts"],"names":[],"mappings":"AAGA,SAAS,iBAAiB,CAAC,KAA6B;IACtD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED,MAAM,OAAO,gBAAgB;IAA7B;QACmB,YAAO,GAAG,IAAI,GAAG,EAAuC,CAAC;QACzD,UAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/registry/renderer-registry.ts"],"names":[],"mappings":"AAGA,SAAS,iBAAiB,CAAC,KAA6B;IACtD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED,MAAM,O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js","sourcesContent":["import type { IGraphicRender } from '../interface/render';\nimport type { IRendererRegistry, IRendererRegistryEntry, RegistryKey } from './types';\n\nfunction isRendererFactory(entry: IRendererRegistryEntry): entry is () => IGraphicRender {\n return typeof entry === 'function';\n}\n\nexport class RendererRegistry implements IRendererRegistry {\n private readonly entries = new Map<RegistryKey, IRendererRegistryEntry>();\n private readonly cache = new Map<RegistryKey, IGraphicRender>();\n\n register(key: RegistryKey, renderer: IRendererRegistryEntry): void {\n this.entries.set(key, renderer);\n this.cache.delete(key);\n }\n\n get(key: RegistryKey): IGraphicRender | undefined {\n if (this.cache.has(key)) {\n return this.cache.get(key);\n }\n\n const entry = this.entries.get(key);\n if (!entry) {\n return undefined;\n }\n\n const renderer = isRendererFactory(entry) ? entry() : entry;\n this.cache.set(key, renderer);\n return renderer;\n }\n\n getAll(): IGraphicRender[] {\n return Array.from(this.entries.keys())\n .map(key => this.get(key))\n .filter((renderer): renderer is IGraphicRender => !!renderer);\n }\n\n clear(): void {\n this.entries.clear();\n this.cache.clear();\n }\n}\n"]}
|
package/es/registry/types.d.ts
CHANGED
|
@@ -6,14 +6,12 @@ export type IRendererFactory = () => IGraphicRender;
|
|
|
6
6
|
export type IRendererRegistryEntry = IGraphicRender | IRendererFactory;
|
|
7
7
|
export interface IRendererRegistry {
|
|
8
8
|
register: (key: RegistryKey, renderer: IRendererRegistryEntry) => void;
|
|
9
|
-
registerMany: (entries: Iterable<[RegistryKey, IRendererRegistryEntry]>) => void;
|
|
10
9
|
get: (key: RegistryKey) => IGraphicRender | undefined;
|
|
11
10
|
getAll: () => IGraphicRender[];
|
|
12
11
|
clear: () => void;
|
|
13
12
|
}
|
|
14
13
|
export interface IPickerRegistry {
|
|
15
14
|
register: (key: RegistryKey, picker: IGraphicPicker) => void;
|
|
16
|
-
registerMany: (entries: Iterable<[RegistryKey, IGraphicPicker]>) => void;
|
|
17
15
|
get: (key: RegistryKey) => IGraphicPicker | undefined;
|
|
18
16
|
getAll: () => IGraphicPicker[];
|
|
19
17
|
clear: () => void;
|
|
@@ -27,7 +25,6 @@ export interface IPluginRegistry {
|
|
|
27
25
|
}
|
|
28
26
|
export interface IContributionRegistry<T = unknown> {
|
|
29
27
|
register: (key: RegistryKey, contribution: T) => void;
|
|
30
|
-
registerMany: (entries: Iterable<[RegistryKey, T]>) => void;
|
|
31
28
|
get: (key: RegistryKey) => T[];
|
|
32
29
|
getAll: () => T[];
|
|
33
30
|
clear: (key?: RegistryKey) => void;
|
package/es/registry/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/registry/types.ts"],"names":[],"mappings":"","file":"types.js","sourcesContent":["import type { IGraphicPicker } from '../interface/picker';\nimport type { IGraphicRender } from '../interface/render';\nimport type { IPlugin } from '../plugins/types';\n\nexport type RegistryKey = string | symbol | number;\n\nexport type IRendererFactory = () => IGraphicRender;\nexport type IRendererRegistryEntry = IGraphicRender | IRendererFactory;\n\nexport interface IRendererRegistry {\n register: (key: RegistryKey, renderer: IRendererRegistryEntry) => void;\n
|
|
1
|
+
{"version":3,"sources":["../src/registry/types.ts"],"names":[],"mappings":"","file":"types.js","sourcesContent":["import type { IGraphicPicker } from '../interface/picker';\nimport type { IGraphicRender } from '../interface/render';\nimport type { IPlugin } from '../plugins/types';\n\nexport type RegistryKey = string | symbol | number;\n\nexport type IRendererFactory = () => IGraphicRender;\nexport type IRendererRegistryEntry = IGraphicRender | IRendererFactory;\n\nexport interface IRendererRegistry {\n register: (key: RegistryKey, renderer: IRendererRegistryEntry) => void;\n get: (key: RegistryKey) => IGraphicRender | undefined;\n getAll: () => IGraphicRender[];\n clear: () => void;\n}\n\nexport interface IPickerRegistry {\n register: (key: RegistryKey, picker: IGraphicPicker) => void;\n get: (key: RegistryKey) => IGraphicPicker | undefined;\n getAll: () => IGraphicPicker[];\n clear: () => void;\n}\n\nexport interface IPluginRegistry {\n install: (plugin: IPlugin) => void;\n uninstall: (name: string) => void;\n get: (name: string) => IPlugin | undefined;\n getAll: () => IPlugin[];\n clear: () => void;\n}\n\nexport interface IContributionRegistry<T = unknown> {\n register: (key: RegistryKey, contribution: T) => void;\n get: (key: RegistryKey) => T[];\n getAll: () => T[];\n clear: (key?: RegistryKey) => void;\n}\n"]}
|
package/es/svg.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GradientParser } from './common/color-utils';
|
package/es/svg.js
ADDED
package/es/svg.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC","file":"svg.js","sourcesContent":["export { GradientParser } from './common/color-utils';\n"]}
|
package/es/text.d.ts
ADDED
package/es/text.js
ADDED
package/es/text.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC","file":"text.js","sourcesContent":["export { getRichTextBounds, getTextBounds } from './graphic/bounds';\nexport { calculateLineHeight } from './common/utils';\n"]}
|