@visactor/vrender-core 1.1.0-alpha.24 → 1.1.0-alpha.26
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/common/event-listener-manager.js +1 -2
- package/cjs/common/event-transformer.js +2 -1
- package/cjs/common/performance-raf.js +1 -1
- package/cjs/common/xml/is-xml.d.ts +2 -0
- package/cjs/common/xml/is-xml.js +14 -0
- package/cjs/common/xml/is-xml.js.map +1 -0
- package/cjs/common/xml/parser.d.ts +2 -2
- package/cjs/common/xml/parser.js +14 -11
- package/cjs/common/xml/parser.js.map +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/graphic-utils.js +1 -2
- package/cjs/core/layer-service.js +2 -1
- package/cjs/core/stage.d.ts +0 -9
- package/cjs/core/stage.js +11 -29
- package/cjs/core/stage.js.map +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-service/graphic-service.d.ts +0 -1
- package/cjs/graphic/graphic-service/graphic-service.js +1 -8
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +19 -29
- package/cjs/graphic/graphic.js +123 -201
- 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/graphic/tools.js +3 -3
- package/cjs/graphic/tools.js.map +1 -1
- package/cjs/index.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 +897 -2213
- package/es/common/event-listener-manager.js +1 -2
- package/es/common/event-transformer.js +2 -1
- package/es/common/performance-raf.js +1 -1
- package/es/common/xml/is-xml.d.ts +2 -0
- package/es/common/xml/is-xml.js +8 -0
- package/es/common/xml/is-xml.js.map +1 -0
- package/es/common/xml/parser.d.ts +2 -2
- package/es/common/xml/parser.js +3 -7
- package/es/common/xml/parser.js.map +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/graphic-utils.js +1 -2
- package/es/core/layer-service.js +2 -1
- package/es/core/stage.d.ts +0 -9
- package/es/core/stage.js +9 -30
- package/es/core/stage.js.map +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-service/graphic-service.d.ts +0 -1
- package/es/graphic/graphic-service/graphic-service.js +0 -10
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/graphic.d.ts +19 -29
- package/es/graphic/graphic.js +123 -207
- 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/graphic/tools.js +3 -3
- package/es/graphic/tools.js.map +1 -1
- package/es/index.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 +245 -1
- package/cjs/allocator/constants.d.ts +0 -9
- package/cjs/allocator/constants.js +0 -11
- package/cjs/allocator/constants.js.map +0 -1
- package/cjs/common/Reflect-metadata.d.ts +0 -2
- package/cjs/common/Reflect-metadata.js +0 -182
- package/cjs/common/Reflect-metadata.js.map +0 -1
- package/cjs/common/segment/curve/arc.d.ts +0 -17
- package/cjs/common/segment/curve/arc.js +0 -38
- package/cjs/common/segment/curve/arc.js.map +0 -1
- package/cjs/common/segment/curve/ellipse.d.ts +0 -21
- package/cjs/common/segment/curve/ellipse.js +0 -39
- package/cjs/common/segment/curve/ellipse.js.map +0 -1
- package/cjs/common/segment/curve/move.d.ts +0 -16
- package/cjs/common/segment/curve/move.js +0 -37
- package/cjs/common/segment/curve/move.js.map +0 -1
- package/cjs/common/store.d.ts +0 -2
- package/cjs/common/store.js +0 -2
- package/cjs/common/store.js.map +0 -1
- package/cjs/core/application.d.ts +0 -1
- package/cjs/core/application.js +0 -6
- package/cjs/core/application.js.map +0 -1
- package/cjs/core/global-module.d.ts +0 -1
- package/cjs/core/global-module.js +0 -1
- package/cjs/core/global-module.js.map +0 -1
- package/cjs/export.d.ts +0 -1
- package/cjs/export.js +0 -1
- package/cjs/export.js.map +0 -1
- 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/interface/creator.d.ts +0 -4
- package/cjs/interface/creator.js +0 -6
- package/cjs/interface/creator.js.map +0 -1
- package/cjs/interface/graphic/dynamic-path.d.ts +0 -1
- package/cjs/interface/graphic/dynamic-path.js +0 -3
- package/cjs/interface/graphic/dynamic-path.js.map +0 -1
- package/cjs/interface/graphic-utils.d.ts +0 -1
- package/cjs/interface/graphic-utils.js +0 -3
- package/cjs/interface/graphic-utils.js.map +0 -1
- package/cjs/interface/theme-service.d.ts +0 -1
- package/cjs/interface/theme-service.js +0 -3
- package/cjs/interface/theme-service.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/builtin-plugin/poptip-plugin.d.ts +0 -1
- package/cjs/plugins/builtin-plugin/poptip-plugin.js +0 -3
- package/cjs/plugins/builtin-plugin/poptip-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/cjs/render/contributions/render/clear-screen.d.ts +0 -1
- package/cjs/render/contributions/render/clear-screen.js +0 -3
- package/cjs/render/contributions/render/clear-screen.js.map +0 -1
- package/cjs/render/contributions/render/render-slector.d.ts +0 -1
- package/cjs/render/contributions/render/render-slector.js +0 -3
- package/cjs/render/contributions/render/render-slector.js.map +0 -1
- package/es/allocator/constants.d.ts +0 -9
- package/es/allocator/constants.js +0 -18
- package/es/allocator/constants.js.map +0 -1
- package/es/common/Reflect-metadata.d.ts +0 -2
- package/es/common/Reflect-metadata.js +0 -178
- package/es/common/Reflect-metadata.js.map +0 -1
- package/es/common/segment/curve/arc.d.ts +0 -17
- package/es/common/segment/curve/arc.js +0 -31
- package/es/common/segment/curve/arc.js.map +0 -1
- package/es/common/segment/curve/ellipse.d.ts +0 -21
- package/es/common/segment/curve/ellipse.js +0 -33
- package/es/common/segment/curve/ellipse.js.map +0 -1
- package/es/common/segment/curve/move.d.ts +0 -16
- package/es/common/segment/curve/move.js +0 -31
- package/es/common/segment/curve/move.js.map +0 -1
- package/es/common/store.d.ts +0 -2
- package/es/common/store.js +0 -2
- package/es/common/store.js.map +0 -1
- package/es/core/application.d.ts +0 -1
- package/es/core/application.js +0 -2
- package/es/core/application.js.map +0 -1
- package/es/core/global-module.d.ts +0 -1
- package/es/core/global-module.js +0 -1
- package/es/core/global-module.js.map +0 -1
- package/es/export.d.ts +0 -1
- package/es/export.js +0 -1
- package/es/export.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/interface/creator.d.ts +0 -4
- package/es/interface/creator.js +0 -2
- package/es/interface/creator.js.map +0 -1
- package/es/interface/graphic/dynamic-path.d.ts +0 -1
- package/es/interface/graphic/dynamic-path.js +0 -3
- package/es/interface/graphic/dynamic-path.js.map +0 -1
- package/es/interface/graphic-utils.d.ts +0 -1
- package/es/interface/graphic-utils.js +0 -3
- package/es/interface/graphic-utils.js.map +0 -1
- package/es/interface/theme-service.d.ts +0 -1
- package/es/interface/theme-service.js +0 -3
- package/es/interface/theme-service.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/builtin-plugin/poptip-plugin.d.ts +0 -1
- package/es/plugins/builtin-plugin/poptip-plugin.js +0 -3
- package/es/plugins/builtin-plugin/poptip-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
- package/es/render/contributions/render/clear-screen.d.ts +0 -1
- package/es/render/contributions/render/clear-screen.js +0 -3
- package/es/render/contributions/render/clear-screen.js.map +0 -1
- package/es/render/contributions/render/render-slector.d.ts +0 -1
- package/es/render/contributions/render/render-slector.js +0 -3
- package/es/render/contributions/render/render-slector.js.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -698,6 +698,9 @@ class Node extends EventEmitter {
|
|
|
698
698
|
this.parent = null;
|
|
699
699
|
this._count = 1;
|
|
700
700
|
}
|
|
701
|
+
onParentSharedStateTreeChanged(_stage, _layer) {
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
701
704
|
forEachChildren(cb, reverse = false) {
|
|
702
705
|
if (reverse) {
|
|
703
706
|
let child = this._lastChild;
|
|
@@ -5981,439 +5984,138 @@ const builtInSymbolStrMap = {
|
|
|
5981
5984
|
roundLine: 'M 1.2392 -0.258 L -1.3432 -0.258 C -1.4784 -0.258 -1.588 -0.1436 -1.588 -0.002 c 0 0.1416 0.1096 0.256 0.2448 0.256 l 2.5824 0 c 0.1352 0 0.2448 -0.1144 0.2448 -0.256 C 1.484 -0.1436 1.3744 -0.258 1.2392 -0.258 z'
|
|
5982
5985
|
};
|
|
5983
5986
|
|
|
5984
|
-
function
|
|
5985
|
-
|
|
5986
|
-
let match = regex.exec(string);
|
|
5987
|
-
while (match) {
|
|
5988
|
-
const allmatches = [];
|
|
5989
|
-
allmatches.startIndex = regex.lastIndex - match[0].length;
|
|
5990
|
-
const len = match.length;
|
|
5991
|
-
for (let index = 0; index < len; index++) {
|
|
5992
|
-
allmatches.push(match[index]);
|
|
5993
|
-
}
|
|
5994
|
-
matches.push(allmatches);
|
|
5995
|
-
match = regex.exec(string);
|
|
5996
|
-
}
|
|
5997
|
-
return matches;
|
|
5987
|
+
function isSvg(str) {
|
|
5988
|
+
return str.startsWith('<svg') || str.startsWith('<?xml');
|
|
5998
5989
|
}
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
constructor(tagname) {
|
|
6002
|
-
this.tagname = tagname;
|
|
6003
|
-
this.child = [];
|
|
6004
|
-
this[':@'] = {};
|
|
6005
|
-
}
|
|
6006
|
-
add(key, val) {
|
|
6007
|
-
if (key === '__proto__') {
|
|
6008
|
-
key = '#__proto__';
|
|
6009
|
-
}
|
|
6010
|
-
this.child.push({ [key]: val });
|
|
6011
|
-
}
|
|
6012
|
-
addChild(node) {
|
|
6013
|
-
if (node.tagname === '__proto__') {
|
|
6014
|
-
node.tagname = '#__proto__';
|
|
6015
|
-
}
|
|
6016
|
-
if (node[':@'] && Object.keys(node[':@']).length > 0) {
|
|
6017
|
-
this.child.push({ [node.tagname]: node.child, [':@']: node[':@'] });
|
|
6018
|
-
}
|
|
6019
|
-
else {
|
|
6020
|
-
this.child.push({ [node.tagname]: node.child });
|
|
6021
|
-
}
|
|
6022
|
-
}
|
|
5990
|
+
function isXML(str) {
|
|
5991
|
+
return str.startsWith('<');
|
|
6023
5992
|
}
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
}
|
|
6029
|
-
else {
|
|
6030
|
-
return closingIndex + str.length - 1;
|
|
6031
|
-
}
|
|
5993
|
+
|
|
5994
|
+
const loadXMLParser$1 = () => require('../common/xml/parser');
|
|
5995
|
+
function incrementalAddTo(group, graphic) {
|
|
5996
|
+
group.incrementalAppendChild(graphic);
|
|
6032
5997
|
}
|
|
6033
|
-
function
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
5998
|
+
function waitForAllSubLayers(stage) {
|
|
5999
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6000
|
+
const promiseList = [];
|
|
6001
|
+
const layers = stage.getChildren();
|
|
6002
|
+
yield new Promise(resolve => {
|
|
6003
|
+
application.global.getRequestAnimationFrame()(() => {
|
|
6004
|
+
resolve(null);
|
|
6005
|
+
});
|
|
6006
|
+
});
|
|
6007
|
+
layers.forEach(l => {
|
|
6008
|
+
if (l.subLayers.size) {
|
|
6009
|
+
l.subLayers.forEach(sl => {
|
|
6010
|
+
if (sl.drawContribution && sl.drawContribution.hooks && sl.drawContribution.rendering) {
|
|
6011
|
+
promiseList.push(new Promise(resolve => {
|
|
6012
|
+
sl.drawContribution.hooks.completeDraw.tap('outWait', () => {
|
|
6013
|
+
sl.drawContribution.hooks.completeDraw.taps = sl.drawContribution.hooks.completeDraw.taps.filter(i => {
|
|
6014
|
+
return i.name !== 'outWait';
|
|
6015
|
+
});
|
|
6016
|
+
resolve(null);
|
|
6017
|
+
});
|
|
6018
|
+
}));
|
|
6019
|
+
}
|
|
6020
|
+
});
|
|
6041
6021
|
}
|
|
6042
|
-
}
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6022
|
+
});
|
|
6023
|
+
yield Promise.all(promiseList);
|
|
6024
|
+
});
|
|
6025
|
+
}
|
|
6026
|
+
function boundStroke(bounds, halfW, miter, pad = 0) {
|
|
6027
|
+
bounds.expand(halfW + (pad / 2 + (miter ? miterAdjustment(miter, halfW) : 0)));
|
|
6028
|
+
return bounds;
|
|
6029
|
+
}
|
|
6030
|
+
function miterAdjustment(miter, strokeWidth) {
|
|
6031
|
+
return miter ? strokeWidth : 0;
|
|
6032
|
+
}
|
|
6033
|
+
let NUMBER_TYPE = 0;
|
|
6034
|
+
function genNumberType() {
|
|
6035
|
+
return NUMBER_TYPE++;
|
|
6036
|
+
}
|
|
6037
|
+
var TextDirection;
|
|
6038
|
+
(function (TextDirection) {
|
|
6039
|
+
TextDirection[TextDirection["HORIZONTAL"] = 0] = "HORIZONTAL";
|
|
6040
|
+
TextDirection[TextDirection["VERTICAL"] = 1] = "VERTICAL";
|
|
6041
|
+
})(TextDirection || (TextDirection = {}));
|
|
6042
|
+
function verticalLayout(text) {
|
|
6043
|
+
const nextCharacter = [];
|
|
6044
|
+
let flag = 0;
|
|
6045
|
+
let currStr = '';
|
|
6046
|
+
for (let i = 0; i < text.length; i++) {
|
|
6047
|
+
if (rotateText(text[i])) {
|
|
6048
|
+
if (flag) {
|
|
6049
|
+
currStr += text[i];
|
|
6054
6050
|
}
|
|
6055
6051
|
else {
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
index: index
|
|
6059
|
-
};
|
|
6052
|
+
flag = 1;
|
|
6053
|
+
currStr = text[i];
|
|
6060
6054
|
}
|
|
6061
6055
|
}
|
|
6062
|
-
else
|
|
6063
|
-
|
|
6056
|
+
else {
|
|
6057
|
+
if (flag) {
|
|
6058
|
+
nextCharacter.push({
|
|
6059
|
+
text: currStr,
|
|
6060
|
+
direction: TextDirection.VERTICAL
|
|
6061
|
+
});
|
|
6062
|
+
currStr = '';
|
|
6063
|
+
flag = 0;
|
|
6064
|
+
}
|
|
6065
|
+
nextCharacter.push({
|
|
6066
|
+
text: text[i],
|
|
6067
|
+
direction: TextDirection.HORIZONTAL
|
|
6068
|
+
});
|
|
6064
6069
|
}
|
|
6065
|
-
tagExp += ch;
|
|
6066
6070
|
}
|
|
6071
|
+
if (currStr) {
|
|
6072
|
+
nextCharacter.push({
|
|
6073
|
+
text: currStr,
|
|
6074
|
+
direction: TextDirection.VERTICAL
|
|
6075
|
+
});
|
|
6076
|
+
}
|
|
6077
|
+
return nextCharacter;
|
|
6067
6078
|
}
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6079
|
+
const rotateCharList = ['…', '(', ')', '—', '【', '】', '「', '」', '《', '》'];
|
|
6080
|
+
const rotateCharMap = new Map();
|
|
6081
|
+
rotateCharList.forEach(c => rotateCharMap.set(c, true));
|
|
6082
|
+
const noRotateCharList = [''];
|
|
6083
|
+
const noRotateCharMap = new Map();
|
|
6084
|
+
noRotateCharList.forEach(c => noRotateCharMap.set(c, true));
|
|
6085
|
+
function rotateText(c) {
|
|
6086
|
+
if (rotateCharMap.has(c)) {
|
|
6087
|
+
return true;
|
|
6072
6088
|
}
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
const separatorIndex = tagExp.search(/\s/);
|
|
6076
|
-
let tagName = tagExp;
|
|
6077
|
-
let attrExpPresent = true;
|
|
6078
|
-
if (separatorIndex !== -1) {
|
|
6079
|
-
tagName = tagExp.substr(0, separatorIndex).replace(/\s\s*$/, '');
|
|
6080
|
-
tagExp = tagExp.substr(separatorIndex + 1);
|
|
6089
|
+
if (noRotateCharMap.has(c)) {
|
|
6090
|
+
return false;
|
|
6081
6091
|
}
|
|
6082
|
-
const
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
tagName = tagName.substr(colonIndex + 1);
|
|
6087
|
-
attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
|
|
6088
|
-
}
|
|
6092
|
+
const cp = c.codePointAt(0);
|
|
6093
|
+
let rotate = false;
|
|
6094
|
+
if (cp < 256) {
|
|
6095
|
+
rotate = true;
|
|
6089
6096
|
}
|
|
6090
|
-
return
|
|
6091
|
-
tagName: tagName,
|
|
6092
|
-
tagExp: tagExp,
|
|
6093
|
-
closeIndex: closeIndex,
|
|
6094
|
-
attrExpPresent: attrExpPresent,
|
|
6095
|
-
rawTagName: rawTagName
|
|
6096
|
-
};
|
|
6097
|
+
return rotate;
|
|
6097
6098
|
}
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
this.tagsNodeStack = [];
|
|
6104
|
-
this.docTypeEntities = {};
|
|
6105
|
-
}
|
|
6106
|
-
addChild(currentNode, childNode, jPath) {
|
|
6107
|
-
const result = childNode.tagname;
|
|
6108
|
-
if (typeof result === 'string') {
|
|
6109
|
-
childNode.tagname = result;
|
|
6110
|
-
currentNode.addChild(childNode);
|
|
6111
|
-
}
|
|
6112
|
-
else {
|
|
6113
|
-
currentNode.addChild(childNode);
|
|
6114
|
-
}
|
|
6099
|
+
function xul(str) {
|
|
6100
|
+
const xmlStr = isArray(str) ? str[0] : str;
|
|
6101
|
+
const config = [];
|
|
6102
|
+
if (!xmlStr) {
|
|
6103
|
+
return config;
|
|
6115
6104
|
}
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
const oldVal = matches[i][4];
|
|
6126
|
-
const aName = attrName;
|
|
6127
|
-
if (attrName) {
|
|
6128
|
-
if (oldVal !== undefined) {
|
|
6129
|
-
attrs[aName] = isNaN(oldVal) ? oldVal : Number(oldVal);
|
|
6105
|
+
const valid = isXML(xmlStr);
|
|
6106
|
+
if (valid === true) {
|
|
6107
|
+
const { XMLParser } = loadXMLParser$1();
|
|
6108
|
+
const parser = new XMLParser();
|
|
6109
|
+
const data = parser.parse(xmlStr);
|
|
6110
|
+
data.tc &&
|
|
6111
|
+
Object.keys(data.tc).forEach(k => {
|
|
6112
|
+
if (k === 'text') {
|
|
6113
|
+
config.push(parseRTTextXML(data.tc[k]));
|
|
6130
6114
|
}
|
|
6131
6115
|
else {
|
|
6132
|
-
|
|
6116
|
+
config.push(parseRTImageXML(data.tc[k]));
|
|
6133
6117
|
}
|
|
6134
|
-
}
|
|
6135
|
-
}
|
|
6136
|
-
return attrs;
|
|
6137
|
-
}
|
|
6138
|
-
parseXml(xmlData) {
|
|
6139
|
-
xmlData = xmlData.replace(/\r\n?/g, '\n');
|
|
6140
|
-
const xmlObj = new XmlNode('!xml');
|
|
6141
|
-
let currentNode = xmlObj;
|
|
6142
|
-
let textData = '';
|
|
6143
|
-
let jPath = '';
|
|
6144
|
-
for (let i = 0; i < xmlData.length; i++) {
|
|
6145
|
-
const ch = xmlData[i];
|
|
6146
|
-
if (ch === '<') {
|
|
6147
|
-
if (xmlData[i + 1] === '/') {
|
|
6148
|
-
const closeIndex = findClosingIndex(xmlData, '>', i, 'Closing Tag is not closed.');
|
|
6149
|
-
const propIndex = jPath.lastIndexOf('.');
|
|
6150
|
-
jPath = jPath.substring(0, propIndex);
|
|
6151
|
-
currentNode = this.tagsNodeStack.pop();
|
|
6152
|
-
if (currentNode && currentNode.child && textData) {
|
|
6153
|
-
currentNode.child[currentNode.child.length - 1][':@'] &&
|
|
6154
|
-
(currentNode.child[currentNode.child.length - 1][':@'].text = textData);
|
|
6155
|
-
}
|
|
6156
|
-
textData = '';
|
|
6157
|
-
i = closeIndex;
|
|
6158
|
-
}
|
|
6159
|
-
else if (xmlData[i + 1] === '?') {
|
|
6160
|
-
const tagData = readTagExp(xmlData, i, false, '?>');
|
|
6161
|
-
i = tagData.closeIndex + 1;
|
|
6162
|
-
}
|
|
6163
|
-
else if (xmlData.substr(i + 1, 3) === '!--') {
|
|
6164
|
-
const endIndex = findClosingIndex(xmlData, '-->', i + 4, 'Comment is not closed.');
|
|
6165
|
-
i = endIndex;
|
|
6166
|
-
}
|
|
6167
|
-
else {
|
|
6168
|
-
const result = readTagExp(xmlData, i, false);
|
|
6169
|
-
let tagName = result.tagName;
|
|
6170
|
-
let tagExp = result.tagExp;
|
|
6171
|
-
const attrExpPresent = result.attrExpPresent;
|
|
6172
|
-
const closeIndex = result.closeIndex;
|
|
6173
|
-
if (tagName !== xmlObj.tagname) {
|
|
6174
|
-
jPath += jPath ? '.' + tagName : tagName;
|
|
6175
|
-
}
|
|
6176
|
-
if (tagExp.length > 0 && tagExp.lastIndexOf('/') === tagExp.length - 1) {
|
|
6177
|
-
if (tagName[tagName.length - 1] === '/') {
|
|
6178
|
-
tagName = tagName.substr(0, tagName.length - 1);
|
|
6179
|
-
jPath = jPath.substr(0, jPath.length - 1);
|
|
6180
|
-
tagExp = tagName;
|
|
6181
|
-
}
|
|
6182
|
-
else {
|
|
6183
|
-
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
6184
|
-
}
|
|
6185
|
-
const childNode = new XmlNode(tagName);
|
|
6186
|
-
if (tagName !== tagExp && attrExpPresent) {
|
|
6187
|
-
childNode[':@'] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
6188
|
-
}
|
|
6189
|
-
this.addChild(currentNode, childNode, jPath);
|
|
6190
|
-
jPath = jPath.substr(0, jPath.lastIndexOf('.'));
|
|
6191
|
-
}
|
|
6192
|
-
else {
|
|
6193
|
-
const childNode = new XmlNode(tagName);
|
|
6194
|
-
this.tagsNodeStack.push(currentNode);
|
|
6195
|
-
if (tagName !== tagExp && attrExpPresent) {
|
|
6196
|
-
childNode[':@'] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
6197
|
-
}
|
|
6198
|
-
this.addChild(currentNode, childNode, jPath);
|
|
6199
|
-
currentNode = childNode;
|
|
6200
|
-
}
|
|
6201
|
-
textData = '';
|
|
6202
|
-
i = closeIndex;
|
|
6203
|
-
}
|
|
6204
|
-
}
|
|
6205
|
-
else {
|
|
6206
|
-
textData += xmlData[i];
|
|
6207
|
-
}
|
|
6208
|
-
}
|
|
6209
|
-
return xmlObj.child;
|
|
6210
|
-
}
|
|
6211
|
-
}
|
|
6212
|
-
|
|
6213
|
-
function prettify(node, options) {
|
|
6214
|
-
return compress(node);
|
|
6215
|
-
}
|
|
6216
|
-
function compress(arr, jPath) {
|
|
6217
|
-
const compressedObj = {};
|
|
6218
|
-
for (let i = 0; i < arr.length; i++) {
|
|
6219
|
-
const tagObj = arr[i];
|
|
6220
|
-
const property = propName(tagObj);
|
|
6221
|
-
if (property === undefined) {
|
|
6222
|
-
continue;
|
|
6223
|
-
}
|
|
6224
|
-
else if (tagObj[property]) {
|
|
6225
|
-
const val = compress(tagObj[property]);
|
|
6226
|
-
isLeafTag(val);
|
|
6227
|
-
if (tagObj[':@']) {
|
|
6228
|
-
assignAttributes(val, tagObj[':@']);
|
|
6229
|
-
}
|
|
6230
|
-
if (compressedObj[property] !== undefined && compressedObj.hasOwnProperty(property)) {
|
|
6231
|
-
if (!Array.isArray(compressedObj[property])) {
|
|
6232
|
-
compressedObj[property] = [compressedObj[property]];
|
|
6233
|
-
}
|
|
6234
|
-
compressedObj[property].push(val);
|
|
6235
|
-
}
|
|
6236
|
-
else {
|
|
6237
|
-
compressedObj[property] = val;
|
|
6238
|
-
}
|
|
6239
|
-
}
|
|
6240
|
-
}
|
|
6241
|
-
return compressedObj;
|
|
6242
|
-
}
|
|
6243
|
-
function propName(obj) {
|
|
6244
|
-
const keys = Object.keys(obj);
|
|
6245
|
-
for (let i = 0; i < keys.length; i++) {
|
|
6246
|
-
const key = keys[i];
|
|
6247
|
-
if (key !== ':@') {
|
|
6248
|
-
return key;
|
|
6249
|
-
}
|
|
6250
|
-
}
|
|
6251
|
-
}
|
|
6252
|
-
function assignAttributes(obj, attrMap, jpath) {
|
|
6253
|
-
if (attrMap) {
|
|
6254
|
-
const keys = Object.keys(attrMap);
|
|
6255
|
-
const len = keys.length;
|
|
6256
|
-
for (let i = 0; i < len; i++) {
|
|
6257
|
-
const atrrName = keys[i];
|
|
6258
|
-
obj[atrrName] = attrMap[atrrName];
|
|
6259
|
-
}
|
|
6260
|
-
}
|
|
6261
|
-
}
|
|
6262
|
-
function isLeafTag(obj) {
|
|
6263
|
-
const propCount = Object.keys(obj).length;
|
|
6264
|
-
if (propCount === 0) {
|
|
6265
|
-
return true;
|
|
6266
|
-
}
|
|
6267
|
-
return false;
|
|
6268
|
-
}
|
|
6269
|
-
|
|
6270
|
-
class XMLParser {
|
|
6271
|
-
constructor(options) {
|
|
6272
|
-
this.options = Object.assign({}, XMLParser.defaultOptions, options);
|
|
6273
|
-
}
|
|
6274
|
-
valid(xml) {
|
|
6275
|
-
return xml.startsWith('<');
|
|
6276
|
-
}
|
|
6277
|
-
parse(xmlData) {
|
|
6278
|
-
if (!this.valid) {
|
|
6279
|
-
return false;
|
|
6280
|
-
}
|
|
6281
|
-
const orderedObjParser = new OrderedObjParser(this.options);
|
|
6282
|
-
const orderedResult = orderedObjParser.parseXml(xmlData);
|
|
6283
|
-
return prettify(orderedResult, this.options);
|
|
6284
|
-
}
|
|
6285
|
-
}
|
|
6286
|
-
XMLParser.defaultOptions = {};
|
|
6287
|
-
function isSvg(str) {
|
|
6288
|
-
return str.startsWith('<svg') || str.startsWith('<?xml');
|
|
6289
|
-
}
|
|
6290
|
-
function isXML(str) {
|
|
6291
|
-
return str.startsWith('<');
|
|
6292
|
-
}
|
|
6293
|
-
|
|
6294
|
-
function incrementalAddTo(group, graphic) {
|
|
6295
|
-
group.incrementalAppendChild(graphic);
|
|
6296
|
-
}
|
|
6297
|
-
function waitForAllSubLayers(stage) {
|
|
6298
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
6299
|
-
const promiseList = [];
|
|
6300
|
-
const layers = stage.getChildren();
|
|
6301
|
-
yield new Promise(resolve => {
|
|
6302
|
-
application.global.getRequestAnimationFrame()(() => {
|
|
6303
|
-
resolve(null);
|
|
6304
|
-
});
|
|
6305
|
-
});
|
|
6306
|
-
layers.forEach(l => {
|
|
6307
|
-
if (l.subLayers.size) {
|
|
6308
|
-
l.subLayers.forEach(sl => {
|
|
6309
|
-
if (sl.drawContribution && sl.drawContribution.hooks && sl.drawContribution.rendering) {
|
|
6310
|
-
promiseList.push(new Promise(resolve => {
|
|
6311
|
-
sl.drawContribution.hooks.completeDraw.tap('outWait', () => {
|
|
6312
|
-
sl.drawContribution.hooks.completeDraw.taps = sl.drawContribution.hooks.completeDraw.taps.filter(i => {
|
|
6313
|
-
return i.name !== 'outWait';
|
|
6314
|
-
});
|
|
6315
|
-
resolve(null);
|
|
6316
|
-
});
|
|
6317
|
-
}));
|
|
6318
|
-
}
|
|
6319
|
-
});
|
|
6320
|
-
}
|
|
6321
|
-
});
|
|
6322
|
-
yield Promise.all(promiseList);
|
|
6323
|
-
});
|
|
6324
|
-
}
|
|
6325
|
-
function boundStroke(bounds, halfW, miter, pad = 0) {
|
|
6326
|
-
bounds.expand(halfW + (pad / 2 + (miter ? miterAdjustment(miter, halfW) : 0)));
|
|
6327
|
-
return bounds;
|
|
6328
|
-
}
|
|
6329
|
-
function miterAdjustment(miter, strokeWidth) {
|
|
6330
|
-
return miter ? strokeWidth : 0;
|
|
6331
|
-
}
|
|
6332
|
-
let NUMBER_TYPE = 0;
|
|
6333
|
-
function genNumberType() {
|
|
6334
|
-
return NUMBER_TYPE++;
|
|
6335
|
-
}
|
|
6336
|
-
var TextDirection;
|
|
6337
|
-
(function (TextDirection) {
|
|
6338
|
-
TextDirection[TextDirection["HORIZONTAL"] = 0] = "HORIZONTAL";
|
|
6339
|
-
TextDirection[TextDirection["VERTICAL"] = 1] = "VERTICAL";
|
|
6340
|
-
})(TextDirection || (TextDirection = {}));
|
|
6341
|
-
function verticalLayout(text) {
|
|
6342
|
-
const nextCharacter = [];
|
|
6343
|
-
let flag = 0;
|
|
6344
|
-
let currStr = '';
|
|
6345
|
-
for (let i = 0; i < text.length; i++) {
|
|
6346
|
-
if (rotateText(text[i])) {
|
|
6347
|
-
if (flag) {
|
|
6348
|
-
currStr += text[i];
|
|
6349
|
-
}
|
|
6350
|
-
else {
|
|
6351
|
-
flag = 1;
|
|
6352
|
-
currStr = text[i];
|
|
6353
|
-
}
|
|
6354
|
-
}
|
|
6355
|
-
else {
|
|
6356
|
-
if (flag) {
|
|
6357
|
-
nextCharacter.push({
|
|
6358
|
-
text: currStr,
|
|
6359
|
-
direction: TextDirection.VERTICAL
|
|
6360
|
-
});
|
|
6361
|
-
currStr = '';
|
|
6362
|
-
flag = 0;
|
|
6363
|
-
}
|
|
6364
|
-
nextCharacter.push({
|
|
6365
|
-
text: text[i],
|
|
6366
|
-
direction: TextDirection.HORIZONTAL
|
|
6367
|
-
});
|
|
6368
|
-
}
|
|
6369
|
-
}
|
|
6370
|
-
if (currStr) {
|
|
6371
|
-
nextCharacter.push({
|
|
6372
|
-
text: currStr,
|
|
6373
|
-
direction: TextDirection.VERTICAL
|
|
6374
|
-
});
|
|
6375
|
-
}
|
|
6376
|
-
return nextCharacter;
|
|
6377
|
-
}
|
|
6378
|
-
const rotateCharList = ['…', '(', ')', '—', '【', '】', '「', '」', '《', '》'];
|
|
6379
|
-
const rotateCharMap = new Map();
|
|
6380
|
-
rotateCharList.forEach(c => rotateCharMap.set(c, true));
|
|
6381
|
-
const noRotateCharList = [''];
|
|
6382
|
-
const noRotateCharMap = new Map();
|
|
6383
|
-
noRotateCharList.forEach(c => noRotateCharMap.set(c, true));
|
|
6384
|
-
function rotateText(c) {
|
|
6385
|
-
if (rotateCharMap.has(c)) {
|
|
6386
|
-
return true;
|
|
6387
|
-
}
|
|
6388
|
-
if (noRotateCharMap.has(c)) {
|
|
6389
|
-
return false;
|
|
6390
|
-
}
|
|
6391
|
-
const cp = c.codePointAt(0);
|
|
6392
|
-
let rotate = false;
|
|
6393
|
-
if (cp < 256) {
|
|
6394
|
-
rotate = true;
|
|
6395
|
-
}
|
|
6396
|
-
return rotate;
|
|
6397
|
-
}
|
|
6398
|
-
function xul(str) {
|
|
6399
|
-
const xmlStr = isArray(str) ? str[0] : str;
|
|
6400
|
-
const config = [];
|
|
6401
|
-
if (!xmlStr) {
|
|
6402
|
-
return config;
|
|
6403
|
-
}
|
|
6404
|
-
const valid = isXML(xmlStr);
|
|
6405
|
-
if (valid === true) {
|
|
6406
|
-
const parser = new XMLParser();
|
|
6407
|
-
const data = parser.parse(xmlStr);
|
|
6408
|
-
data.tc &&
|
|
6409
|
-
Object.keys(data.tc).forEach(k => {
|
|
6410
|
-
if (k === 'text') {
|
|
6411
|
-
config.push(parseRTTextXML(data.tc[k]));
|
|
6412
|
-
}
|
|
6413
|
-
else {
|
|
6414
|
-
config.push(parseRTImageXML(data.tc[k]));
|
|
6415
|
-
}
|
|
6416
|
-
});
|
|
6118
|
+
});
|
|
6417
6119
|
}
|
|
6418
6120
|
return config;
|
|
6419
6121
|
}
|
|
@@ -9024,7 +8726,7 @@ function createConicalGradient(context, stops, x, y, deltaAngle, startAngle, end
|
|
|
9024
8726
|
return pattern;
|
|
9025
8727
|
}
|
|
9026
8728
|
|
|
9027
|
-
const FULL_DEFINITION_KEYS
|
|
8729
|
+
const FULL_DEFINITION_KEYS = new Set([
|
|
9028
8730
|
'name',
|
|
9029
8731
|
'patch',
|
|
9030
8732
|
'priority',
|
|
@@ -9033,7 +8735,7 @@ const FULL_DEFINITION_KEYS$1 = new Set([
|
|
|
9033
8735
|
'resolver',
|
|
9034
8736
|
'declaredAffectedKeys'
|
|
9035
8737
|
]);
|
|
9036
|
-
function isPlainObject$
|
|
8738
|
+
function isPlainObject$1(value) {
|
|
9037
8739
|
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
9038
8740
|
}
|
|
9039
8741
|
function normalizePatch(value) {
|
|
@@ -9095,453 +8797,81 @@ class StateDefinitionCompiler {
|
|
|
9095
8797
|
patch: undefined
|
|
9096
8798
|
};
|
|
9097
8799
|
}
|
|
9098
|
-
const keys = isPlainObject$
|
|
9099
|
-
const hasFullKey = keys.some(key => FULL_DEFINITION_KEYS
|
|
8800
|
+
const keys = isPlainObject$1(value) ? Object.keys(value) : [];
|
|
8801
|
+
const hasFullKey = keys.some(key => FULL_DEFINITION_KEYS.has(key));
|
|
9100
8802
|
if (hasFullKey) {
|
|
9101
8803
|
const definition = value;
|
|
9102
8804
|
return {
|
|
9103
8805
|
name: (_a = definition.name) !== null && _a !== void 0 ? _a : name,
|
|
9104
8806
|
priority: (_b = definition.priority) !== null && _b !== void 0 ? _b : 0,
|
|
9105
|
-
rank: definition.rank,
|
|
9106
8807
|
patch: normalizePatch(definition.patch),
|
|
9107
8808
|
resolver: definition.resolver,
|
|
9108
8809
|
declaredAffectedKeys: definition.declaredAffectedKeys,
|
|
9109
|
-
exclude: definition.exclude,
|
|
9110
|
-
suppress: definition.suppress
|
|
9111
|
-
};
|
|
9112
|
-
}
|
|
9113
|
-
return {
|
|
9114
|
-
name,
|
|
9115
|
-
priority: 0,
|
|
9116
|
-
patch: value
|
|
9117
|
-
};
|
|
9118
|
-
}
|
|
9119
|
-
expandRelationClosure(compiled, relation) {
|
|
9120
|
-
const rawRelationMap = new Map();
|
|
9121
|
-
compiled.forEach((definition, name) => {
|
|
9122
|
-
rawRelationMap.set(name, new Set(definition[relation]));
|
|
9123
|
-
});
|
|
9124
|
-
compiled.forEach((definition, origin) => {
|
|
9125
|
-
const closure = new Set();
|
|
9126
|
-
const walk = (stateName, stack) => {
|
|
9127
|
-
const nextStates = rawRelationMap.get(stateName);
|
|
9128
|
-
if (!nextStates || !nextStates.size) {
|
|
9129
|
-
return;
|
|
9130
|
-
}
|
|
9131
|
-
nextStates.forEach(nextState => {
|
|
9132
|
-
if (nextState === origin) {
|
|
9133
|
-
console.warn(`[StateDefinitionCompiler] circular ${relation} relation detected: ${stack.join(' -> ')} -> ${origin}`);
|
|
9134
|
-
return;
|
|
9135
|
-
}
|
|
9136
|
-
if (stack.includes(nextState)) {
|
|
9137
|
-
console.warn(`[StateDefinitionCompiler] circular ${relation} relation detected: ${stack.join(' -> ')} -> ${nextState}`);
|
|
9138
|
-
return;
|
|
9139
|
-
}
|
|
9140
|
-
if (closure.has(nextState)) {
|
|
9141
|
-
return;
|
|
9142
|
-
}
|
|
9143
|
-
closure.add(nextState);
|
|
9144
|
-
walk(nextState, stack.concat(nextState));
|
|
9145
|
-
});
|
|
9146
|
-
};
|
|
9147
|
-
walk(origin, [origin]);
|
|
9148
|
-
definition[relation] = closure;
|
|
9149
|
-
});
|
|
9150
|
-
}
|
|
9151
|
-
}
|
|
9152
|
-
|
|
9153
|
-
var UpdateCategory;
|
|
9154
|
-
(function (UpdateCategory) {
|
|
9155
|
-
UpdateCategory[UpdateCategory["NONE"] = 0] = "NONE";
|
|
9156
|
-
UpdateCategory[UpdateCategory["PAINT"] = 1] = "PAINT";
|
|
9157
|
-
UpdateCategory[UpdateCategory["SHAPE"] = 2] = "SHAPE";
|
|
9158
|
-
UpdateCategory[UpdateCategory["BOUNDS"] = 4] = "BOUNDS";
|
|
9159
|
-
UpdateCategory[UpdateCategory["TRANSFORM"] = 8] = "TRANSFORM";
|
|
9160
|
-
UpdateCategory[UpdateCategory["LAYOUT"] = 16] = "LAYOUT";
|
|
9161
|
-
UpdateCategory[UpdateCategory["PICK"] = 32] = "PICK";
|
|
9162
|
-
})(UpdateCategory || (UpdateCategory = {}));
|
|
9163
|
-
const ATTRIBUTE_CATEGORY = {
|
|
9164
|
-
fill: UpdateCategory.PAINT,
|
|
9165
|
-
opacity: UpdateCategory.PAINT,
|
|
9166
|
-
fillOpacity: UpdateCategory.PAINT,
|
|
9167
|
-
strokeOpacity: UpdateCategory.PAINT,
|
|
9168
|
-
lineDash: UpdateCategory.PAINT,
|
|
9169
|
-
lineDashOffset: UpdateCategory.PAINT,
|
|
9170
|
-
lineCap: UpdateCategory.PAINT,
|
|
9171
|
-
lineJoin: UpdateCategory.PAINT,
|
|
9172
|
-
miterLimit: UpdateCategory.PAINT,
|
|
9173
|
-
shadowColor: UpdateCategory.PAINT,
|
|
9174
|
-
x: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9175
|
-
y: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9176
|
-
scaleX: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9177
|
-
scaleY: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9178
|
-
angle: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9179
|
-
anchor: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9180
|
-
anchor3d: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9181
|
-
postMatrix: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9182
|
-
layout: UpdateCategory.LAYOUT,
|
|
9183
|
-
zIndex: UpdateCategory.PAINT,
|
|
9184
|
-
visible: UpdateCategory.PAINT | UpdateCategory.PICK,
|
|
9185
|
-
lineWidth: UpdateCategory.SHAPE | UpdateCategory.BOUNDS | UpdateCategory.PICK,
|
|
9186
|
-
width: UpdateCategory.SHAPE | UpdateCategory.BOUNDS,
|
|
9187
|
-
height: UpdateCategory.SHAPE | UpdateCategory.BOUNDS
|
|
9188
|
-
};
|
|
9189
|
-
const ATTRIBUTE_DELTA_CLASSIFIER = {
|
|
9190
|
-
stroke: (prev, next) => {
|
|
9191
|
-
const prevEnabled = prev != null && prev !== false;
|
|
9192
|
-
const nextEnabled = next != null && next !== false;
|
|
9193
|
-
if (prevEnabled !== nextEnabled) {
|
|
9194
|
-
return UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK;
|
|
9195
|
-
}
|
|
9196
|
-
return UpdateCategory.PAINT;
|
|
9197
|
-
},
|
|
9198
|
-
shadowBlur: (prev, next) => {
|
|
9199
|
-
const prevBlur = Number(prev !== null && prev !== void 0 ? prev : 0);
|
|
9200
|
-
const nextBlur = Number(next !== null && next !== void 0 ? next : 0);
|
|
9201
|
-
if (prevBlur !== nextBlur && (prevBlur > 0 || nextBlur > 0)) {
|
|
9202
|
-
return UpdateCategory.PAINT | UpdateCategory.BOUNDS;
|
|
9203
|
-
}
|
|
9204
|
-
return UpdateCategory.PAINT;
|
|
9205
|
-
}
|
|
9206
|
-
};
|
|
9207
|
-
function classifyAttributeDelta(key, prev, next) {
|
|
9208
|
-
var _a;
|
|
9209
|
-
const dynamicClassifier = ATTRIBUTE_DELTA_CLASSIFIER[key];
|
|
9210
|
-
if (dynamicClassifier) {
|
|
9211
|
-
return dynamicClassifier(prev, next);
|
|
9212
|
-
}
|
|
9213
|
-
return (_a = ATTRIBUTE_CATEGORY[key]) !== null && _a !== void 0 ? _a : UpdateCategory.PAINT;
|
|
9214
|
-
}
|
|
9215
|
-
function classifyAffectedKeyConservatively(key) {
|
|
9216
|
-
var _a;
|
|
9217
|
-
if (key === 'stroke') {
|
|
9218
|
-
return UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK;
|
|
9219
|
-
}
|
|
9220
|
-
if (key === 'shadowBlur') {
|
|
9221
|
-
return UpdateCategory.PAINT | UpdateCategory.BOUNDS;
|
|
9222
|
-
}
|
|
9223
|
-
return (_a = ATTRIBUTE_CATEGORY[key]) !== null && _a !== void 0 ? _a : UpdateCategory.PAINT;
|
|
9224
|
-
}
|
|
9225
|
-
function classifyAffectedKeys(keys) {
|
|
9226
|
-
let category = UpdateCategory.NONE;
|
|
9227
|
-
for (const key of keys) {
|
|
9228
|
-
category |= classifyAffectedKeyConservatively(key);
|
|
9229
|
-
}
|
|
9230
|
-
return category;
|
|
9231
|
-
}
|
|
9232
|
-
|
|
9233
|
-
const DEFAULT_MAX_EVENT_RECORDS = 100;
|
|
9234
|
-
const STAGE_PERF_MONITOR = Symbol('vrender.statePerfMonitor');
|
|
9235
|
-
function createReasonBreakdown() {
|
|
9236
|
-
return {
|
|
9237
|
-
config_disabled: 0,
|
|
9238
|
-
context_disabled: 0,
|
|
9239
|
-
non_batch_operation: 0,
|
|
9240
|
-
mixed_update_category: 0,
|
|
9241
|
-
resolver_unstable_keys: 0,
|
|
9242
|
-
graphic_unavailable: 0
|
|
9243
|
-
};
|
|
9244
|
-
}
|
|
9245
|
-
function createEmptyStatePerfSnapshot() {
|
|
9246
|
-
return {
|
|
9247
|
-
counters: {
|
|
9248
|
-
stateCommits: 0,
|
|
9249
|
-
sharedRefreshCommits: 0,
|
|
9250
|
-
deferredJobsCreated: 0,
|
|
9251
|
-
deferredJobsCompleted: 0,
|
|
9252
|
-
deferredJobsCancelled: 0,
|
|
9253
|
-
deferredJobsCoalesced: 0,
|
|
9254
|
-
deferredGraphicsCommitted: 0,
|
|
9255
|
-
deferredBudgetYields: 0,
|
|
9256
|
-
deferredIneligibleGraphics: 0
|
|
9257
|
-
},
|
|
9258
|
-
deferredIneligibleByReason: createReasonBreakdown(),
|
|
9259
|
-
categoryBreakdown: {
|
|
9260
|
-
paint: 0,
|
|
9261
|
-
transform: 0,
|
|
9262
|
-
shape: 0,
|
|
9263
|
-
bounds: 0,
|
|
9264
|
-
layout: 0,
|
|
9265
|
-
pick: 0
|
|
9266
|
-
},
|
|
9267
|
-
refresh: {
|
|
9268
|
-
queuedGraphics: 0,
|
|
9269
|
-
flushedGraphics: 0,
|
|
9270
|
-
ensureFreshCalls: 0,
|
|
9271
|
-
renderScheduled: 0
|
|
9272
|
-
},
|
|
9273
|
-
resolver: {
|
|
9274
|
-
cacheHits: 0,
|
|
9275
|
-
cacheMisses: 0,
|
|
9276
|
-
invalidations: 0
|
|
9277
|
-
},
|
|
9278
|
-
cost: {
|
|
9279
|
-
resolverTotalMs: 0,
|
|
9280
|
-
resolverMaxMs: 0,
|
|
9281
|
-
patchTotalMs: 0,
|
|
9282
|
-
patchMaxMs: 0,
|
|
9283
|
-
sharedRefreshTotalMs: 0,
|
|
9284
|
-
sharedRefreshMaxMs: 0,
|
|
9285
|
-
batchSliceTotalMs: 0,
|
|
9286
|
-
batchSliceMaxMs: 0
|
|
9287
|
-
},
|
|
9288
|
-
allocationHints: {
|
|
9289
|
-
patchObjectsCreated: 0,
|
|
9290
|
-
batchEntriesCreated: 0,
|
|
9291
|
-
refreshQueuePushes: 0
|
|
9292
|
-
},
|
|
9293
|
-
batch: {
|
|
9294
|
-
pendingJobs: 0,
|
|
9295
|
-
maxPendingJobs: 0,
|
|
9296
|
-
maxGraphicsInJob: 0,
|
|
9297
|
-
maxFrameSliceCost: 0
|
|
9298
|
-
},
|
|
9299
|
-
events: []
|
|
9300
|
-
};
|
|
9301
|
-
}
|
|
9302
|
-
function cloneSnapshot(snapshot) {
|
|
9303
|
-
return {
|
|
9304
|
-
counters: Object.assign({}, snapshot.counters),
|
|
9305
|
-
deferredIneligibleByReason: Object.assign({}, snapshot.deferredIneligibleByReason),
|
|
9306
|
-
categoryBreakdown: Object.assign({}, snapshot.categoryBreakdown),
|
|
9307
|
-
refresh: Object.assign({}, snapshot.refresh),
|
|
9308
|
-
resolver: Object.assign({}, snapshot.resolver),
|
|
9309
|
-
cost: Object.assign({}, snapshot.cost),
|
|
9310
|
-
allocationHints: Object.assign({}, snapshot.allocationHints),
|
|
9311
|
-
batch: Object.assign({}, snapshot.batch),
|
|
9312
|
-
events: snapshot.events ? snapshot.events.slice() : []
|
|
9313
|
-
};
|
|
9314
|
-
}
|
|
9315
|
-
function isDeferredStateContextConfig(value) {
|
|
9316
|
-
return (!!value &&
|
|
9317
|
-
(Object.prototype.hasOwnProperty.call(value, 'deferred') ||
|
|
9318
|
-
Object.prototype.hasOwnProperty.call(value, 'localEnabled')));
|
|
9319
|
-
}
|
|
9320
|
-
function normalizeDeferredStateOwnerConfig(value) {
|
|
9321
|
-
if (!value) {
|
|
9322
|
-
return undefined;
|
|
9323
|
-
}
|
|
9324
|
-
if (isDeferredStateContextConfig(value)) {
|
|
9325
|
-
return value;
|
|
9326
|
-
}
|
|
9327
|
-
return {
|
|
9328
|
-
deferred: value
|
|
9329
|
-
};
|
|
9330
|
-
}
|
|
9331
|
-
function normalizeDeferredStateConfig(config) {
|
|
9332
|
-
var _a, _b, _c;
|
|
9333
|
-
return {
|
|
9334
|
-
enabled: (_a = config === null || config === void 0 ? void 0 : config.enabled) !== null && _a !== void 0 ? _a : false,
|
|
9335
|
-
frameBudget: (_b = config === null || config === void 0 ? void 0 : config.frameBudget) !== null && _b !== void 0 ? _b : 8,
|
|
9336
|
-
maxGraphicsPerFrame: (_c = config === null || config === void 0 ? void 0 : config.maxGraphicsPerFrame) !== null && _c !== void 0 ? _c : 100
|
|
9337
|
-
};
|
|
9338
|
-
}
|
|
9339
|
-
function fingerprintDeferredStateConfig(config) {
|
|
9340
|
-
return `${config.enabled ? 1 : 0}:${config.frameBudget}:${config.maxGraphicsPerFrame}`;
|
|
9341
|
-
}
|
|
9342
|
-
class StatePerfMonitor {
|
|
9343
|
-
constructor(configSource) {
|
|
9344
|
-
this.configSource = configSource;
|
|
9345
|
-
this.snapshot = createEmptyStatePerfSnapshot();
|
|
9346
|
-
}
|
|
9347
|
-
setConfig(config) {
|
|
9348
|
-
this.configSource = config;
|
|
9349
|
-
}
|
|
9350
|
-
getSnapshot() {
|
|
9351
|
-
return cloneSnapshot(this.snapshot);
|
|
9352
|
-
}
|
|
9353
|
-
reset() {
|
|
9354
|
-
const next = createEmptyStatePerfSnapshot();
|
|
9355
|
-
Object.assign(this.snapshot.counters, next.counters);
|
|
9356
|
-
Object.assign(this.snapshot.deferredIneligibleByReason, next.deferredIneligibleByReason);
|
|
9357
|
-
Object.assign(this.snapshot.categoryBreakdown, next.categoryBreakdown);
|
|
9358
|
-
Object.assign(this.snapshot.refresh, next.refresh);
|
|
9359
|
-
Object.assign(this.snapshot.resolver, next.resolver);
|
|
9360
|
-
Object.assign(this.snapshot.cost, next.cost);
|
|
9361
|
-
Object.assign(this.snapshot.allocationHints, next.allocationHints);
|
|
9362
|
-
Object.assign(this.snapshot.batch, next.batch);
|
|
9363
|
-
this.snapshot.events = [];
|
|
9364
|
-
}
|
|
9365
|
-
incrementCounter(key, delta = 1) {
|
|
9366
|
-
if (!this.isEnabled()) {
|
|
9367
|
-
return;
|
|
9368
|
-
}
|
|
9369
|
-
this.snapshot.counters[key] += delta;
|
|
9370
|
-
}
|
|
9371
|
-
recordDeferredIneligible(reason, delta = 1) {
|
|
9372
|
-
if (!this.isEnabled()) {
|
|
9373
|
-
return;
|
|
9374
|
-
}
|
|
9375
|
-
this.snapshot.deferredIneligibleByReason[reason] += delta;
|
|
9376
|
-
this.snapshot.counters.deferredIneligibleGraphics += delta;
|
|
9377
|
-
this.recordEvent('deferred-ineligible', { reason, count: delta });
|
|
9378
|
-
}
|
|
9379
|
-
recordCategory(category) {
|
|
9380
|
-
if (!this.isEnabled()) {
|
|
9381
|
-
return;
|
|
9382
|
-
}
|
|
9383
|
-
if (category & UpdateCategory.PAINT) {
|
|
9384
|
-
this.snapshot.categoryBreakdown.paint += 1;
|
|
9385
|
-
}
|
|
9386
|
-
if (category & UpdateCategory.TRANSFORM) {
|
|
9387
|
-
this.snapshot.categoryBreakdown.transform += 1;
|
|
9388
|
-
}
|
|
9389
|
-
if (category & UpdateCategory.SHAPE) {
|
|
9390
|
-
this.snapshot.categoryBreakdown.shape += 1;
|
|
9391
|
-
}
|
|
9392
|
-
if (category & UpdateCategory.BOUNDS) {
|
|
9393
|
-
this.snapshot.categoryBreakdown.bounds += 1;
|
|
9394
|
-
}
|
|
9395
|
-
if (category & UpdateCategory.LAYOUT) {
|
|
9396
|
-
this.snapshot.categoryBreakdown.layout += 1;
|
|
9397
|
-
}
|
|
9398
|
-
if (category & UpdateCategory.PICK) {
|
|
9399
|
-
this.snapshot.categoryBreakdown.pick += 1;
|
|
9400
|
-
}
|
|
9401
|
-
}
|
|
9402
|
-
recordRefresh(key, delta = 1) {
|
|
9403
|
-
if (!this.isEnabled()) {
|
|
9404
|
-
return;
|
|
9405
|
-
}
|
|
9406
|
-
this.snapshot.refresh[key] += delta;
|
|
9407
|
-
}
|
|
9408
|
-
recordResolver(key, delta = 1) {
|
|
9409
|
-
if (!this.isEnabled()) {
|
|
9410
|
-
return;
|
|
9411
|
-
}
|
|
9412
|
-
this.snapshot.resolver[key] += delta;
|
|
9413
|
-
}
|
|
9414
|
-
recordCost(kind, durationMs) {
|
|
9415
|
-
if (!this.isEnabled()) {
|
|
9416
|
-
return;
|
|
9417
|
-
}
|
|
9418
|
-
if (kind === 'resolver') {
|
|
9419
|
-
this.snapshot.cost.resolverTotalMs += durationMs;
|
|
9420
|
-
this.snapshot.cost.resolverMaxMs = Math.max(this.snapshot.cost.resolverMaxMs, durationMs);
|
|
9421
|
-
return;
|
|
9422
|
-
}
|
|
9423
|
-
if (kind === 'patch') {
|
|
9424
|
-
this.snapshot.cost.patchTotalMs += durationMs;
|
|
9425
|
-
this.snapshot.cost.patchMaxMs = Math.max(this.snapshot.cost.patchMaxMs, durationMs);
|
|
9426
|
-
return;
|
|
9427
|
-
}
|
|
9428
|
-
if (kind === 'sharedRefresh') {
|
|
9429
|
-
this.snapshot.cost.sharedRefreshTotalMs += durationMs;
|
|
9430
|
-
this.snapshot.cost.sharedRefreshMaxMs = Math.max(this.snapshot.cost.sharedRefreshMaxMs, durationMs);
|
|
9431
|
-
return;
|
|
9432
|
-
}
|
|
9433
|
-
this.snapshot.cost.batchSliceTotalMs += durationMs;
|
|
9434
|
-
this.snapshot.cost.batchSliceMaxMs = Math.max(this.snapshot.cost.batchSliceMaxMs, durationMs);
|
|
9435
|
-
this.snapshot.batch.maxFrameSliceCost = Math.max(this.snapshot.batch.maxFrameSliceCost, durationMs);
|
|
9436
|
-
}
|
|
9437
|
-
recordAllocation(key, delta = 1) {
|
|
9438
|
-
if (!this.isEnabled()) {
|
|
9439
|
-
return;
|
|
9440
|
-
}
|
|
9441
|
-
this.snapshot.allocationHints[key] += delta;
|
|
9442
|
-
}
|
|
9443
|
-
updateBatchPending(pendingJobs) {
|
|
9444
|
-
if (!this.isEnabled()) {
|
|
9445
|
-
return;
|
|
9446
|
-
}
|
|
9447
|
-
this.snapshot.batch.pendingJobs = pendingJobs;
|
|
9448
|
-
this.snapshot.batch.maxPendingJobs = Math.max(this.snapshot.batch.maxPendingJobs, pendingJobs);
|
|
9449
|
-
}
|
|
9450
|
-
updateMaxGraphicsInJob(count) {
|
|
9451
|
-
if (!this.isEnabled()) {
|
|
9452
|
-
return;
|
|
9453
|
-
}
|
|
9454
|
-
this.snapshot.batch.maxGraphicsInJob = Math.max(this.snapshot.batch.maxGraphicsInJob, count);
|
|
9455
|
-
}
|
|
9456
|
-
recordEvent(type, detail) {
|
|
9457
|
-
var _a, _b, _c;
|
|
9458
|
-
if (!this.shouldRecordEvents()) {
|
|
9459
|
-
return;
|
|
9460
|
-
}
|
|
9461
|
-
const events = (_a = this.snapshot.events) !== null && _a !== void 0 ? _a : (this.snapshot.events = []);
|
|
9462
|
-
events.push({
|
|
9463
|
-
type,
|
|
9464
|
-
at: Date.now(),
|
|
9465
|
-
detail
|
|
9466
|
-
});
|
|
9467
|
-
const max = (_c = (_b = this.getConfig()) === null || _b === void 0 ? void 0 : _b.maxEventRecords) !== null && _c !== void 0 ? _c : DEFAULT_MAX_EVENT_RECORDS;
|
|
9468
|
-
if (events.length > max) {
|
|
9469
|
-
events.splice(0, events.length - max);
|
|
8810
|
+
exclude: definition.exclude,
|
|
8811
|
+
suppress: definition.suppress
|
|
8812
|
+
};
|
|
9470
8813
|
}
|
|
8814
|
+
return {
|
|
8815
|
+
name,
|
|
8816
|
+
priority: 0,
|
|
8817
|
+
patch: value
|
|
8818
|
+
};
|
|
9471
8819
|
}
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
}
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
}
|
|
9497
|
-
function getActiveStageStatePerfMonitor(stage) {
|
|
9498
|
-
var _a;
|
|
9499
|
-
if (!stage) {
|
|
9500
|
-
return undefined;
|
|
9501
|
-
}
|
|
9502
|
-
const current = getStageStatePerfMonitor(stage);
|
|
9503
|
-
if (current) {
|
|
9504
|
-
return current;
|
|
8820
|
+
expandRelationClosure(compiled, relation) {
|
|
8821
|
+
const rawRelationMap = new Map();
|
|
8822
|
+
compiled.forEach((definition, name) => {
|
|
8823
|
+
rawRelationMap.set(name, new Set(definition[relation]));
|
|
8824
|
+
});
|
|
8825
|
+
compiled.forEach((definition, origin) => {
|
|
8826
|
+
const closure = new Set();
|
|
8827
|
+
const walk = (stateName, visiting) => {
|
|
8828
|
+
const nextStates = rawRelationMap.get(stateName);
|
|
8829
|
+
if (!nextStates || !nextStates.size) {
|
|
8830
|
+
return;
|
|
8831
|
+
}
|
|
8832
|
+
nextStates.forEach(nextState => {
|
|
8833
|
+
if (nextState === origin || visiting.has(nextState) || closure.has(nextState)) {
|
|
8834
|
+
return;
|
|
8835
|
+
}
|
|
8836
|
+
closure.add(nextState);
|
|
8837
|
+
visiting.add(nextState);
|
|
8838
|
+
walk(nextState, visiting);
|
|
8839
|
+
visiting.delete(nextState);
|
|
8840
|
+
});
|
|
8841
|
+
};
|
|
8842
|
+
walk(origin, new Set([origin]));
|
|
8843
|
+
definition[relation] = closure;
|
|
8844
|
+
});
|
|
9505
8845
|
}
|
|
9506
|
-
return ((_a = stage.statePerfConfig) === null || _a === void 0 ? void 0 : _a.enabled) === true ? ensureStageStatePerfMonitor(stage) : undefined;
|
|
9507
8846
|
}
|
|
9508
8847
|
|
|
9509
|
-
function isPlainObject
|
|
8848
|
+
function isPlainObject(value) {
|
|
9510
8849
|
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
9511
8850
|
}
|
|
9512
|
-
function cloneValue
|
|
9513
|
-
if (!isPlainObject
|
|
8851
|
+
function cloneValue(value) {
|
|
8852
|
+
if (!isPlainObject(value)) {
|
|
9514
8853
|
return value;
|
|
9515
8854
|
}
|
|
9516
8855
|
const clone = {};
|
|
9517
8856
|
Object.keys(value).forEach(key => {
|
|
9518
|
-
clone[key] = cloneValue
|
|
8857
|
+
clone[key] = cloneValue(value[key]);
|
|
9519
8858
|
});
|
|
9520
8859
|
return clone;
|
|
9521
8860
|
}
|
|
9522
|
-
function deepMerge
|
|
8861
|
+
function deepMerge(base, value) {
|
|
9523
8862
|
var _a;
|
|
9524
|
-
const result = (_a = cloneValue
|
|
8863
|
+
const result = (_a = cloneValue(base)) !== null && _a !== void 0 ? _a : {};
|
|
9525
8864
|
Object.keys(value).forEach(key => {
|
|
9526
8865
|
const nextValue = value[key];
|
|
9527
8866
|
const previousValue = result[key];
|
|
9528
|
-
if (isPlainObject
|
|
9529
|
-
result[key] = deepMerge
|
|
8867
|
+
if (isPlainObject(previousValue) && isPlainObject(nextValue)) {
|
|
8868
|
+
result[key] = deepMerge(previousValue, nextValue);
|
|
9530
8869
|
return;
|
|
9531
8870
|
}
|
|
9532
|
-
result[key] = cloneValue
|
|
8871
|
+
result[key] = cloneValue(nextValue);
|
|
9533
8872
|
});
|
|
9534
8873
|
return result;
|
|
9535
8874
|
}
|
|
9536
|
-
const FULL_DEFINITION_KEYS = new Set([
|
|
9537
|
-
'name',
|
|
9538
|
-
'patch',
|
|
9539
|
-
'priority',
|
|
9540
|
-
'exclude',
|
|
9541
|
-
'suppress',
|
|
9542
|
-
'resolver',
|
|
9543
|
-
'declaredAffectedKeys'
|
|
9544
|
-
]);
|
|
9545
8875
|
class StateEngine {
|
|
9546
8876
|
constructor(options) {
|
|
9547
8877
|
var _a;
|
|
@@ -9555,9 +8885,6 @@ class StateEngine {
|
|
|
9555
8885
|
this.baseAttributes = {};
|
|
9556
8886
|
this.compiledDefinitions = options.compiledDefinitions;
|
|
9557
8887
|
this.stateSort = options.stateSort;
|
|
9558
|
-
this.stateProxy = options.stateProxy;
|
|
9559
|
-
this.stateProxyEligibility = options.stateProxyEligibility;
|
|
9560
|
-
this.states = options.states;
|
|
9561
8888
|
this.mergeMode = (_a = options.mergeMode) !== null && _a !== void 0 ? _a : 'shallow';
|
|
9562
8889
|
}
|
|
9563
8890
|
get activeStates() {
|
|
@@ -9656,11 +8983,9 @@ class StateEngine {
|
|
|
9656
8983
|
};
|
|
9657
8984
|
}
|
|
9658
8985
|
invalidateResolverCache() {
|
|
9659
|
-
var _a, _b;
|
|
9660
8986
|
this.resolverPatchCache.clear();
|
|
9661
8987
|
this.resolverCacheKey = '';
|
|
9662
8988
|
this.resolverCacheValid = false;
|
|
9663
|
-
(_b = getActiveStageStatePerfMonitor((_a = this.graphic) === null || _a === void 0 ? void 0 : _a.stage)) === null || _b === void 0 ? void 0 : _b.recordResolver('invalidations');
|
|
9664
8989
|
}
|
|
9665
8990
|
hasState(stateName) {
|
|
9666
8991
|
if (!this._activeStates.length) {
|
|
@@ -9671,28 +8996,6 @@ class StateEngine {
|
|
|
9671
8996
|
}
|
|
9672
8997
|
return this._activeStates.includes(stateName);
|
|
9673
8998
|
}
|
|
9674
|
-
getCompatPatch(stateName) {
|
|
9675
|
-
var _a, _b, _c;
|
|
9676
|
-
const targetStates = this._activeStates.length ? this._activeStates : this._effectiveStates;
|
|
9677
|
-
const canUseStateProxy = this.canUseStateProxy(stateName);
|
|
9678
|
-
const proxyPatch = canUseStateProxy ? (_a = this.stateProxy) === null || _a === void 0 ? void 0 : _a.call(this, stateName, targetStates) : undefined;
|
|
9679
|
-
if (this.stateProxy && canUseStateProxy) {
|
|
9680
|
-
return proxyPatch !== null && proxyPatch !== void 0 ? proxyPatch : undefined;
|
|
9681
|
-
}
|
|
9682
|
-
const value = (_b = this.states) === null || _b === void 0 ? void 0 : _b[stateName];
|
|
9683
|
-
if (value == null) {
|
|
9684
|
-
return undefined;
|
|
9685
|
-
}
|
|
9686
|
-
if (!isPlainObject$1(value)) {
|
|
9687
|
-
return value;
|
|
9688
|
-
}
|
|
9689
|
-
const keys = Object.keys(value);
|
|
9690
|
-
const hasFullKey = keys.some(key => FULL_DEFINITION_KEYS.has(key));
|
|
9691
|
-
if (!hasFullKey) {
|
|
9692
|
-
return value;
|
|
9693
|
-
}
|
|
9694
|
-
return cloneValue$1(((_c = value.patch) !== null && _c !== void 0 ? _c : undefined));
|
|
9695
|
-
}
|
|
9696
8999
|
sortStates(states) {
|
|
9697
9000
|
const withDefinition = [];
|
|
9698
9001
|
const withoutDefinition = [];
|
|
@@ -9713,364 +9016,105 @@ class StateEngine {
|
|
|
9713
9016
|
if (leftDefinition.priority !== rightDefinition.priority) {
|
|
9714
9017
|
return leftDefinition.priority - rightDefinition.priority;
|
|
9715
9018
|
}
|
|
9716
|
-
return leftDefinition.rank - rightDefinition.rank;
|
|
9717
|
-
});
|
|
9718
|
-
if (this.stateSort && withoutDefinition.length > 1) {
|
|
9719
|
-
withoutDefinition.sort(this.stateSort);
|
|
9720
|
-
}
|
|
9721
|
-
return withDefinition.concat(withoutDefinition);
|
|
9722
|
-
}
|
|
9723
|
-
adjudicate(sortedStates) {
|
|
9724
|
-
const candidate = sortedStates.slice();
|
|
9725
|
-
const suppressedSet = new Set();
|
|
9726
|
-
for (let index = candidate.length - 1; index >= 0; index--) {
|
|
9727
|
-
const stateName = candidate[index];
|
|
9728
|
-
const definition = this.compiledDefinitions.get(stateName);
|
|
9729
|
-
if (!definition) {
|
|
9730
|
-
continue;
|
|
9731
|
-
}
|
|
9732
|
-
definition.exclude.forEach(excludedState => {
|
|
9733
|
-
const excludedIndex = candidate.indexOf(excludedState);
|
|
9734
|
-
if (excludedIndex === -1) {
|
|
9735
|
-
return;
|
|
9736
|
-
}
|
|
9737
|
-
candidate.splice(excludedIndex, 1);
|
|
9738
|
-
if (excludedIndex < index) {
|
|
9739
|
-
index -= 1;
|
|
9740
|
-
}
|
|
9741
|
-
});
|
|
9742
|
-
definition.suppress.forEach(suppressedState => {
|
|
9743
|
-
suppressedSet.add(suppressedState);
|
|
9744
|
-
});
|
|
9745
|
-
}
|
|
9746
|
-
return {
|
|
9747
|
-
active: candidate,
|
|
9748
|
-
suppressedSet
|
|
9749
|
-
};
|
|
9750
|
-
}
|
|
9751
|
-
recomputePatch(effectiveStates) {
|
|
9752
|
-
var _a;
|
|
9753
|
-
const perfMonitor = getActiveStageStatePerfMonitor((_a = this.graphic) === null || _a === void 0 ? void 0 : _a.stage);
|
|
9754
|
-
const patchStart = perfMonitor ? performance.now() : 0;
|
|
9755
|
-
let resolverCost = 0;
|
|
9756
|
-
const cacheKey = effectiveStates.join(',');
|
|
9757
|
-
const nextPatch = {};
|
|
9758
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.recordAllocation('patchObjectsCreated');
|
|
9759
|
-
if (this.resolverCacheValid && this.resolverCacheKey === cacheKey) {
|
|
9760
|
-
effectiveStates.forEach(stateName => {
|
|
9761
|
-
var _a;
|
|
9762
|
-
const canUseStateProxy = this.canUseStateProxy(stateName);
|
|
9763
|
-
const proxyPatch = canUseStateProxy ? (_a = this.stateProxy) === null || _a === void 0 ? void 0 : _a.call(this, stateName, effectiveStates) : undefined;
|
|
9764
|
-
if (this.stateProxy && canUseStateProxy) {
|
|
9765
|
-
if (proxyPatch != null) {
|
|
9766
|
-
this.mergeInto(nextPatch, proxyPatch);
|
|
9767
|
-
}
|
|
9768
|
-
return;
|
|
9769
|
-
}
|
|
9770
|
-
const definition = this.compiledDefinitions.get(stateName);
|
|
9771
|
-
if (!definition) {
|
|
9772
|
-
const compatPatch = this.getCompatPatch(stateName);
|
|
9773
|
-
if (compatPatch) {
|
|
9774
|
-
this.mergeInto(nextPatch, compatPatch);
|
|
9775
|
-
}
|
|
9776
|
-
return;
|
|
9777
|
-
}
|
|
9778
|
-
if (definition.patch) {
|
|
9779
|
-
this.mergeInto(nextPatch, definition.patch);
|
|
9780
|
-
}
|
|
9781
|
-
if (definition.hasResolver) {
|
|
9782
|
-
const cachedPatch = this.resolverPatchCache.get(stateName);
|
|
9783
|
-
if (cachedPatch) {
|
|
9784
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.recordResolver('cacheHits');
|
|
9785
|
-
this.mergeInto(nextPatch, cachedPatch);
|
|
9786
|
-
}
|
|
9787
|
-
}
|
|
9788
|
-
});
|
|
9789
|
-
}
|
|
9790
|
-
else {
|
|
9791
|
-
this.resolverPatchCache.clear();
|
|
9792
|
-
this.resolverCacheKey = cacheKey;
|
|
9793
|
-
effectiveStates.forEach(stateName => {
|
|
9794
|
-
var _a;
|
|
9795
|
-
const canUseStateProxy = this.canUseStateProxy(stateName);
|
|
9796
|
-
const proxyPatch = canUseStateProxy ? (_a = this.stateProxy) === null || _a === void 0 ? void 0 : _a.call(this, stateName, effectiveStates) : undefined;
|
|
9797
|
-
if (this.stateProxy && canUseStateProxy) {
|
|
9798
|
-
if (proxyPatch != null) {
|
|
9799
|
-
this.mergeInto(nextPatch, proxyPatch);
|
|
9800
|
-
}
|
|
9801
|
-
return;
|
|
9802
|
-
}
|
|
9803
|
-
const definition = this.compiledDefinitions.get(stateName);
|
|
9804
|
-
if (!definition) {
|
|
9805
|
-
const compatPatch = this.getCompatPatch(stateName);
|
|
9806
|
-
if (compatPatch) {
|
|
9807
|
-
this.mergeInto(nextPatch, compatPatch);
|
|
9808
|
-
}
|
|
9809
|
-
return;
|
|
9810
|
-
}
|
|
9811
|
-
if (definition.patch) {
|
|
9812
|
-
this.mergeInto(nextPatch, definition.patch);
|
|
9813
|
-
}
|
|
9814
|
-
if (definition.hasResolver && definition.resolver) {
|
|
9815
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.recordResolver('cacheMisses');
|
|
9816
|
-
const resolverStart = perfMonitor ? performance.now() : 0;
|
|
9817
|
-
const resolverPatch = definition.resolver({
|
|
9818
|
-
graphic: this.graphic,
|
|
9819
|
-
activeStates: this._activeStates,
|
|
9820
|
-
effectiveStates: this._effectiveStates,
|
|
9821
|
-
baseAttributes: this.baseAttributes,
|
|
9822
|
-
resolvedPatch: nextPatch
|
|
9823
|
-
});
|
|
9824
|
-
if (perfMonitor) {
|
|
9825
|
-
const duration = performance.now() - resolverStart;
|
|
9826
|
-
resolverCost += duration;
|
|
9827
|
-
perfMonitor.recordCost('resolver', duration);
|
|
9828
|
-
}
|
|
9829
|
-
if (resolverPatch) {
|
|
9830
|
-
this.resolverPatchCache.set(stateName, resolverPatch);
|
|
9831
|
-
this.mergeInto(nextPatch, resolverPatch);
|
|
9832
|
-
}
|
|
9833
|
-
}
|
|
9834
|
-
});
|
|
9835
|
-
this.resolverCacheValid = true;
|
|
9836
|
-
}
|
|
9837
|
-
this._resolvedPatch = nextPatch;
|
|
9838
|
-
if (perfMonitor) {
|
|
9839
|
-
const totalCost = performance.now() - patchStart;
|
|
9840
|
-
perfMonitor.recordCost('patch', Math.max(0, totalCost - resolverCost));
|
|
9841
|
-
}
|
|
9842
|
-
}
|
|
9843
|
-
mergeInto(target, patch) {
|
|
9844
|
-
if (this.mergeMode === 'deep') {
|
|
9845
|
-
Object.keys(patch).forEach(key => {
|
|
9846
|
-
var _a;
|
|
9847
|
-
const nextValue = patch[key];
|
|
9848
|
-
const previousValue = target[key];
|
|
9849
|
-
const baseValue = (_a = this.baseAttributes) === null || _a === void 0 ? void 0 : _a[key];
|
|
9850
|
-
if (isPlainObject$1(previousValue) && isPlainObject$1(nextValue)) {
|
|
9851
|
-
target[key] = deepMerge$1(previousValue, nextValue);
|
|
9852
|
-
return;
|
|
9853
|
-
}
|
|
9854
|
-
if (!isPlainObject$1(previousValue) && isPlainObject$1(baseValue) && isPlainObject$1(nextValue)) {
|
|
9855
|
-
target[key] = deepMerge$1(baseValue, nextValue);
|
|
9856
|
-
return;
|
|
9857
|
-
}
|
|
9858
|
-
target[key] = cloneValue$1(nextValue);
|
|
9859
|
-
});
|
|
9860
|
-
return;
|
|
9861
|
-
}
|
|
9862
|
-
Object.keys(patch).forEach(key => {
|
|
9863
|
-
target[key] = cloneValue$1(patch[key]);
|
|
9864
|
-
});
|
|
9865
|
-
}
|
|
9866
|
-
sameArray(left, right) {
|
|
9867
|
-
if (left.length !== right.length) {
|
|
9868
|
-
return false;
|
|
9869
|
-
}
|
|
9870
|
-
for (let index = 0; index < left.length; index++) {
|
|
9871
|
-
if (left[index] !== right[index]) {
|
|
9872
|
-
return false;
|
|
9873
|
-
}
|
|
9874
|
-
}
|
|
9875
|
-
return true;
|
|
9876
|
-
}
|
|
9877
|
-
canUseStateProxy(stateName) {
|
|
9878
|
-
if (!this.stateProxy) {
|
|
9879
|
-
return false;
|
|
9880
|
-
}
|
|
9881
|
-
return this.stateProxyEligibility ? this.stateProxyEligibility(stateName) : true;
|
|
9882
|
-
}
|
|
9883
|
-
}
|
|
9884
|
-
|
|
9885
|
-
class StateModel {
|
|
9886
|
-
constructor(options = {}) {
|
|
9887
|
-
var _a;
|
|
9888
|
-
this.exclusiveGroupMap = new Map();
|
|
9889
|
-
this.exclusiveGroups = new Map();
|
|
9890
|
-
this.states = options.states;
|
|
9891
|
-
this.currentStates = options.currentStates ? [...options.currentStates] : undefined;
|
|
9892
|
-
this.stateSort = options.stateSort;
|
|
9893
|
-
this.stateProxy = options.stateProxy;
|
|
9894
|
-
this.stateEngine = options.stateEngine;
|
|
9895
|
-
if (this.stateEngine &&
|
|
9896
|
-
options.currentStates &&
|
|
9897
|
-
!this.sameStates(this.stateEngine.activeStates, options.currentStates)) {
|
|
9898
|
-
this.stateEngine.applyStates(options.currentStates);
|
|
9899
|
-
}
|
|
9900
|
-
const exclusiveGroups = (_a = options.exclusiveGroups) !== null && _a !== void 0 ? _a : {};
|
|
9901
|
-
for (const groupName in exclusiveGroups) {
|
|
9902
|
-
if (!Object.prototype.hasOwnProperty.call(exclusiveGroups, groupName)) {
|
|
9903
|
-
continue;
|
|
9904
|
-
}
|
|
9905
|
-
this.registerExclusiveGroup(groupName, exclusiveGroups[groupName]);
|
|
9906
|
-
}
|
|
9907
|
-
}
|
|
9908
|
-
getCurrentStates() {
|
|
9909
|
-
return this.currentStates ? [...this.currentStates] : [];
|
|
9910
|
-
}
|
|
9911
|
-
hasState(stateName) {
|
|
9912
|
-
if (this.stateEngine) {
|
|
9913
|
-
return this.stateEngine.hasState(stateName);
|
|
9914
|
-
}
|
|
9915
|
-
if (!this.currentStates || !this.currentStates.length) {
|
|
9916
|
-
return false;
|
|
9917
|
-
}
|
|
9918
|
-
if (stateName == null) {
|
|
9919
|
-
return true;
|
|
9920
|
-
}
|
|
9921
|
-
return this.currentStates.includes(stateName);
|
|
9922
|
-
}
|
|
9923
|
-
getState(stateName) {
|
|
9924
|
-
var _a;
|
|
9925
|
-
return (_a = this.states) === null || _a === void 0 ? void 0 : _a[stateName];
|
|
9926
|
-
}
|
|
9927
|
-
useStates(states) {
|
|
9928
|
-
var _a;
|
|
9929
|
-
if (this.stateEngine) {
|
|
9930
|
-
const result = this.stateEngine.applyStates(states);
|
|
9931
|
-
this.currentStates = [...result.activeStates];
|
|
9932
|
-
return {
|
|
9933
|
-
changed: result.changed,
|
|
9934
|
-
states: [...result.activeStates],
|
|
9935
|
-
effectiveStates: [...result.effectiveStates]
|
|
9936
|
-
};
|
|
9937
|
-
}
|
|
9938
|
-
if (!states.length) {
|
|
9939
|
-
return this.clearStates();
|
|
9940
|
-
}
|
|
9941
|
-
const previousStates = (_a = this.currentStates) !== null && _a !== void 0 ? _a : [];
|
|
9942
|
-
const changed = previousStates.length !== states.length || states.some((stateName, index) => previousStates[index] !== stateName);
|
|
9943
|
-
const nextStates = this.sortStates(states);
|
|
9944
|
-
if (changed) {
|
|
9945
|
-
this.currentStates = nextStates;
|
|
9946
|
-
}
|
|
9947
|
-
return {
|
|
9948
|
-
changed,
|
|
9949
|
-
states: changed ? [...nextStates] : [...previousStates]
|
|
9950
|
-
};
|
|
9951
|
-
}
|
|
9952
|
-
clearStates() {
|
|
9953
|
-
if (this.stateEngine) {
|
|
9954
|
-
const result = this.stateEngine.clearStates();
|
|
9955
|
-
this.currentStates = [];
|
|
9956
|
-
return {
|
|
9957
|
-
changed: result.changed,
|
|
9958
|
-
states: [],
|
|
9959
|
-
effectiveStates: []
|
|
9960
|
-
};
|
|
9961
|
-
}
|
|
9962
|
-
const changed = this.hasState();
|
|
9963
|
-
this.currentStates = [];
|
|
9964
|
-
return {
|
|
9965
|
-
changed,
|
|
9966
|
-
states: []
|
|
9967
|
-
};
|
|
9968
|
-
}
|
|
9969
|
-
addState(stateName, keepCurrentStates) {
|
|
9970
|
-
var _a;
|
|
9971
|
-
if (this.stateEngine) {
|
|
9972
|
-
const result = this.stateEngine.addState(stateName, keepCurrentStates);
|
|
9973
|
-
this.currentStates = [...result.activeStates];
|
|
9974
|
-
return {
|
|
9975
|
-
changed: result.changed,
|
|
9976
|
-
states: [...result.activeStates],
|
|
9977
|
-
effectiveStates: [...result.effectiveStates]
|
|
9978
|
-
};
|
|
9979
|
-
}
|
|
9980
|
-
if (this.currentStates &&
|
|
9981
|
-
this.currentStates.includes(stateName) &&
|
|
9982
|
-
(keepCurrentStates || this.currentStates.length === 1)) {
|
|
9983
|
-
return {
|
|
9984
|
-
changed: false,
|
|
9985
|
-
states: this.getCurrentStates()
|
|
9986
|
-
};
|
|
9987
|
-
}
|
|
9988
|
-
const nextStates = keepCurrentStates && ((_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.length) ? this.currentStates.concat([stateName]) : [stateName];
|
|
9989
|
-
return this.useStates(nextStates);
|
|
9990
|
-
}
|
|
9991
|
-
removeState(stateName) {
|
|
9992
|
-
if (this.stateEngine) {
|
|
9993
|
-
const result = this.stateEngine.removeState(stateName);
|
|
9994
|
-
this.currentStates = [...result.activeStates];
|
|
9995
|
-
return {
|
|
9996
|
-
changed: result.changed,
|
|
9997
|
-
states: [...result.activeStates],
|
|
9998
|
-
effectiveStates: [...result.effectiveStates]
|
|
9999
|
-
};
|
|
10000
|
-
}
|
|
10001
|
-
if (!this.currentStates) {
|
|
10002
|
-
return {
|
|
10003
|
-
changed: false,
|
|
10004
|
-
states: []
|
|
10005
|
-
};
|
|
10006
|
-
}
|
|
10007
|
-
const filter = Array.isArray(stateName) ? (s) => !stateName.includes(s) : (s) => s !== stateName;
|
|
10008
|
-
const nextStates = this.currentStates.filter(filter);
|
|
10009
|
-
if (nextStates.length === this.currentStates.length) {
|
|
10010
|
-
return {
|
|
10011
|
-
changed: false,
|
|
10012
|
-
states: this.getCurrentStates()
|
|
10013
|
-
};
|
|
9019
|
+
return leftDefinition.rank - rightDefinition.rank;
|
|
9020
|
+
});
|
|
9021
|
+
if (this.stateSort && withoutDefinition.length > 1) {
|
|
9022
|
+
withoutDefinition.sort(this.stateSort);
|
|
10014
9023
|
}
|
|
10015
|
-
return
|
|
9024
|
+
return withDefinition.concat(withoutDefinition);
|
|
10016
9025
|
}
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
}
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
9026
|
+
adjudicate(sortedStates) {
|
|
9027
|
+
const candidate = sortedStates.slice();
|
|
9028
|
+
const suppressedSet = new Set();
|
|
9029
|
+
for (let index = candidate.length - 1; index >= 0; index--) {
|
|
9030
|
+
const stateName = candidate[index];
|
|
9031
|
+
const definition = this.compiledDefinitions.get(stateName);
|
|
9032
|
+
if (!definition) {
|
|
9033
|
+
continue;
|
|
9034
|
+
}
|
|
9035
|
+
definition.exclude.forEach(excludedState => {
|
|
9036
|
+
const excludedIndex = candidate.indexOf(excludedState);
|
|
9037
|
+
if (excludedIndex === -1) {
|
|
9038
|
+
return;
|
|
9039
|
+
}
|
|
9040
|
+
candidate.splice(excludedIndex, 1);
|
|
9041
|
+
if (excludedIndex < index) {
|
|
9042
|
+
index -= 1;
|
|
9043
|
+
}
|
|
9044
|
+
});
|
|
9045
|
+
definition.suppress.forEach(suppressedState => {
|
|
9046
|
+
suppressedSet.add(suppressedState);
|
|
9047
|
+
});
|
|
10033
9048
|
}
|
|
10034
|
-
return
|
|
9049
|
+
return {
|
|
9050
|
+
active: candidate,
|
|
9051
|
+
suppressedSet
|
|
9052
|
+
};
|
|
10035
9053
|
}
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
9054
|
+
recomputePatch(effectiveStates) {
|
|
9055
|
+
const cacheKey = effectiveStates.join(',');
|
|
9056
|
+
const nextPatch = {};
|
|
9057
|
+
const useResolverCache = this.resolverCacheValid && this.resolverCacheKey === cacheKey;
|
|
9058
|
+
if (!useResolverCache) {
|
|
9059
|
+
this.resolverPatchCache.clear();
|
|
9060
|
+
this.resolverCacheKey = cacheKey;
|
|
10039
9061
|
}
|
|
10040
|
-
|
|
10041
|
-
|
|
9062
|
+
effectiveStates.forEach(stateName => {
|
|
9063
|
+
var _a;
|
|
9064
|
+
const definition = this.compiledDefinitions.get(stateName);
|
|
9065
|
+
if (!definition) {
|
|
9066
|
+
return;
|
|
9067
|
+
}
|
|
9068
|
+
if (definition.patch) {
|
|
9069
|
+
this.mergeInto(nextPatch, definition.patch);
|
|
9070
|
+
}
|
|
9071
|
+
if (definition.hasResolver) {
|
|
9072
|
+
const resolverPatch = useResolverCache
|
|
9073
|
+
? this.resolverPatchCache.get(stateName)
|
|
9074
|
+
: (_a = definition.resolver) === null || _a === void 0 ? void 0 : _a.call(definition, {
|
|
9075
|
+
graphic: this.graphic,
|
|
9076
|
+
activeStates: this._activeStates,
|
|
9077
|
+
effectiveStates: this._effectiveStates,
|
|
9078
|
+
baseAttributes: this.baseAttributes,
|
|
9079
|
+
resolvedPatch: nextPatch
|
|
9080
|
+
});
|
|
9081
|
+
if (resolverPatch) {
|
|
9082
|
+
if (!useResolverCache) {
|
|
9083
|
+
this.resolverPatchCache.set(stateName, resolverPatch);
|
|
9084
|
+
}
|
|
9085
|
+
this.mergeInto(nextPatch, resolverPatch);
|
|
9086
|
+
}
|
|
9087
|
+
}
|
|
9088
|
+
});
|
|
9089
|
+
if (!useResolverCache) {
|
|
9090
|
+
this.resolverCacheValid = true;
|
|
10042
9091
|
}
|
|
10043
|
-
|
|
10044
|
-
}
|
|
10045
|
-
registerExclusiveGroup(groupName, states) {
|
|
10046
|
-
const uniqueStates = Array.from(new Set(states));
|
|
10047
|
-
this.exclusiveGroups.set(groupName, uniqueStates);
|
|
10048
|
-
uniqueStates.forEach(stateName => this.exclusiveGroupMap.set(stateName, groupName));
|
|
10049
|
-
}
|
|
10050
|
-
getExclusiveGroup(stateName) {
|
|
10051
|
-
return this.exclusiveGroupMap.get(stateName);
|
|
9092
|
+
this._resolvedPatch = nextPatch;
|
|
10052
9093
|
}
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
9094
|
+
mergeInto(target, patch) {
|
|
9095
|
+
if (this.mergeMode === 'deep') {
|
|
9096
|
+
Object.keys(patch).forEach(key => {
|
|
9097
|
+
var _a;
|
|
9098
|
+
const nextValue = patch[key];
|
|
9099
|
+
const previousValue = target[key];
|
|
9100
|
+
const baseValue = (_a = this.baseAttributes) === null || _a === void 0 ? void 0 : _a[key];
|
|
9101
|
+
if (isPlainObject(previousValue) && isPlainObject(nextValue)) {
|
|
9102
|
+
target[key] = deepMerge(previousValue, nextValue);
|
|
9103
|
+
return;
|
|
9104
|
+
}
|
|
9105
|
+
if (!isPlainObject(previousValue) && isPlainObject(baseValue) && isPlainObject(nextValue)) {
|
|
9106
|
+
target[key] = deepMerge(baseValue, nextValue);
|
|
9107
|
+
return;
|
|
9108
|
+
}
|
|
9109
|
+
target[key] = cloneValue(nextValue);
|
|
9110
|
+
});
|
|
9111
|
+
return;
|
|
10058
9112
|
}
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
const groupName = this.getExclusiveGroup(stateA);
|
|
10063
|
-
return !!groupName && groupName === this.getExclusiveGroup(stateB) && stateA !== stateB;
|
|
10064
|
-
}
|
|
10065
|
-
get effectiveStates() {
|
|
10066
|
-
var _a, _b, _c;
|
|
10067
|
-
return (_c = (_b = (_a = this.stateEngine) === null || _a === void 0 ? void 0 : _a.effectiveStates) !== null && _b !== void 0 ? _b : this.currentStates) !== null && _c !== void 0 ? _c : [];
|
|
10068
|
-
}
|
|
10069
|
-
get resolvedPatch() {
|
|
10070
|
-
var _a;
|
|
10071
|
-
return (_a = this.stateEngine) === null || _a === void 0 ? void 0 : _a.resolvedPatch;
|
|
9113
|
+
Object.keys(patch).forEach(key => {
|
|
9114
|
+
target[key] = cloneValue(patch[key]);
|
|
9115
|
+
});
|
|
10072
9116
|
}
|
|
10073
|
-
|
|
9117
|
+
sameArray(left, right) {
|
|
10074
9118
|
if (left.length !== right.length) {
|
|
10075
9119
|
return false;
|
|
10076
9120
|
}
|
|
@@ -10083,76 +9127,67 @@ class StateModel {
|
|
|
10083
9127
|
}
|
|
10084
9128
|
}
|
|
10085
9129
|
|
|
10086
|
-
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
9130
|
+
var UpdateCategory;
|
|
9131
|
+
(function (UpdateCategory) {
|
|
9132
|
+
UpdateCategory[UpdateCategory["NONE"] = 0] = "NONE";
|
|
9133
|
+
UpdateCategory[UpdateCategory["PAINT"] = 1] = "PAINT";
|
|
9134
|
+
UpdateCategory[UpdateCategory["SHAPE"] = 2] = "SHAPE";
|
|
9135
|
+
UpdateCategory[UpdateCategory["BOUNDS"] = 4] = "BOUNDS";
|
|
9136
|
+
UpdateCategory[UpdateCategory["TRANSFORM"] = 8] = "TRANSFORM";
|
|
9137
|
+
UpdateCategory[UpdateCategory["LAYOUT"] = 16] = "LAYOUT";
|
|
9138
|
+
UpdateCategory[UpdateCategory["PICK"] = 32] = "PICK";
|
|
9139
|
+
})(UpdateCategory || (UpdateCategory = {}));
|
|
9140
|
+
const ATTRIBUTE_CATEGORY = {
|
|
9141
|
+
fill: UpdateCategory.PAINT,
|
|
9142
|
+
opacity: UpdateCategory.PAINT,
|
|
9143
|
+
fillOpacity: UpdateCategory.PAINT,
|
|
9144
|
+
strokeOpacity: UpdateCategory.PAINT,
|
|
9145
|
+
lineDash: UpdateCategory.PAINT,
|
|
9146
|
+
lineDashOffset: UpdateCategory.PAINT,
|
|
9147
|
+
lineCap: UpdateCategory.PAINT,
|
|
9148
|
+
lineJoin: UpdateCategory.PAINT,
|
|
9149
|
+
miterLimit: UpdateCategory.PAINT,
|
|
9150
|
+
shadowColor: UpdateCategory.PAINT,
|
|
9151
|
+
x: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9152
|
+
y: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9153
|
+
scaleX: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9154
|
+
scaleY: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9155
|
+
angle: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9156
|
+
anchor: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9157
|
+
anchor3d: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9158
|
+
postMatrix: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9159
|
+
layout: UpdateCategory.LAYOUT,
|
|
9160
|
+
zIndex: UpdateCategory.PAINT,
|
|
9161
|
+
visible: UpdateCategory.PAINT | UpdateCategory.PICK,
|
|
9162
|
+
lineWidth: UpdateCategory.SHAPE | UpdateCategory.BOUNDS | UpdateCategory.PICK,
|
|
9163
|
+
width: UpdateCategory.SHAPE | UpdateCategory.BOUNDS,
|
|
9164
|
+
height: UpdateCategory.SHAPE | UpdateCategory.BOUNDS
|
|
9165
|
+
};
|
|
9166
|
+
const ATTRIBUTE_DELTA_CLASSIFIER = {
|
|
9167
|
+
stroke: (prev, next) => {
|
|
9168
|
+
const prevEnabled = prev != null && prev !== false;
|
|
9169
|
+
const nextEnabled = next != null && next !== false;
|
|
9170
|
+
if (prevEnabled !== nextEnabled) {
|
|
9171
|
+
return UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK;
|
|
10112
9172
|
}
|
|
10113
|
-
|
|
10114
|
-
|
|
9173
|
+
return UpdateCategory.PAINT;
|
|
9174
|
+
},
|
|
9175
|
+
shadowBlur: (prev, next) => {
|
|
9176
|
+
const prevBlur = Number(prev !== null && prev !== void 0 ? prev : 0);
|
|
9177
|
+
const nextBlur = Number(next !== null && next !== void 0 ? next : 0);
|
|
9178
|
+
if (prevBlur !== nextBlur && (prevBlur > 0 || nextBlur > 0)) {
|
|
9179
|
+
return UpdateCategory.PAINT | UpdateCategory.BOUNDS;
|
|
10115
9180
|
}
|
|
9181
|
+
return UpdateCategory.PAINT;
|
|
10116
9182
|
}
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
resolve(normalAttrs, states, stateProxy, currentStates, stateSort) {
|
|
10124
|
-
var _a;
|
|
10125
|
-
const mergeMode = (_a = this.options.mergeMode) !== null && _a !== void 0 ? _a : 'shallow';
|
|
10126
|
-
const sortedStates = stateSort ? currentStates.slice().sort(stateSort) : currentStates.slice();
|
|
10127
|
-
const resolvedAttrs = {};
|
|
10128
|
-
sortedStates.forEach(stateName => {
|
|
10129
|
-
const attrs = stateProxy ? stateProxy(stateName, sortedStates) : states === null || states === void 0 ? void 0 : states[stateName];
|
|
10130
|
-
if (attrs == null) {
|
|
10131
|
-
return;
|
|
10132
|
-
}
|
|
10133
|
-
for (const key in attrs) {
|
|
10134
|
-
if (!Object.prototype.hasOwnProperty.call(attrs, key)) {
|
|
10135
|
-
continue;
|
|
10136
|
-
}
|
|
10137
|
-
const nextValue = attrs[key];
|
|
10138
|
-
if (mergeMode === 'deep' &&
|
|
10139
|
-
isPlainObject(nextValue) &&
|
|
10140
|
-
(isPlainObject(resolvedAttrs[key]) ||
|
|
10141
|
-
isPlainObject(normalAttrs[key]))) {
|
|
10142
|
-
const baseValue = isPlainObject(resolvedAttrs[key])
|
|
10143
|
-
? resolvedAttrs[key]
|
|
10144
|
-
: isPlainObject(normalAttrs[key])
|
|
10145
|
-
? normalAttrs[key]
|
|
10146
|
-
: {};
|
|
10147
|
-
resolvedAttrs[key] = deepMerge(baseValue, nextValue);
|
|
10148
|
-
}
|
|
10149
|
-
else {
|
|
10150
|
-
resolvedAttrs[key] = cloneValue(nextValue);
|
|
10151
|
-
}
|
|
10152
|
-
}
|
|
10153
|
-
});
|
|
10154
|
-
return resolvedAttrs;
|
|
9183
|
+
};
|
|
9184
|
+
function classifyAttributeDelta(key, prev, next) {
|
|
9185
|
+
var _a;
|
|
9186
|
+
const dynamicClassifier = ATTRIBUTE_DELTA_CLASSIFIER[key];
|
|
9187
|
+
if (dynamicClassifier) {
|
|
9188
|
+
return dynamicClassifier(prev, next);
|
|
10155
9189
|
}
|
|
9190
|
+
return (_a = ATTRIBUTE_CATEGORY[key]) !== null && _a !== void 0 ? _a : UpdateCategory.PAINT;
|
|
10156
9191
|
}
|
|
10157
9192
|
|
|
10158
9193
|
function hasOwnKeys(value) {
|
|
@@ -10176,13 +9211,11 @@ function normalizeNoAnimateAttrConfig(config) {
|
|
|
10176
9211
|
}, {});
|
|
10177
9212
|
}
|
|
10178
9213
|
class StateTransitionOrchestrator {
|
|
10179
|
-
analyzeTransition(
|
|
9214
|
+
analyzeTransition(targetAttrs, hasAnimation, options = {}) {
|
|
10180
9215
|
var _a, _b;
|
|
10181
9216
|
const plan = {
|
|
10182
|
-
stateNames,
|
|
10183
9217
|
targetAttrs: Object.assign({}, targetAttrs),
|
|
10184
9218
|
animateAttrs: {},
|
|
10185
|
-
jumpAttrs: {},
|
|
10186
9219
|
noAnimateAttrs: {}
|
|
10187
9220
|
};
|
|
10188
9221
|
if (!hasAnimation) {
|
|
@@ -10191,10 +9224,10 @@ class StateTransitionOrchestrator {
|
|
|
10191
9224
|
const noWorkAnimateAttr = Object.assign(Object.assign({}, ((_a = options.noWorkAnimateAttr) !== null && _a !== void 0 ? _a : {})), normalizeNoAnimateAttrConfig((_b = options.animateConfig) === null || _b === void 0 ? void 0 : _b.noAnimateAttrs));
|
|
10192
9225
|
const isClear = options.isClear === true;
|
|
10193
9226
|
const getDefaultAttribute = options.getDefaultAttribute;
|
|
9227
|
+
const readDefaultAttribute = getDefaultAttribute;
|
|
10194
9228
|
const shouldSkipDefaultAttribute = options.shouldSkipDefaultAttribute;
|
|
10195
9229
|
const assignTransitionAttr = (key, value) => {
|
|
10196
9230
|
if (noWorkAnimateAttr[key]) {
|
|
10197
|
-
plan.jumpAttrs[key] = value;
|
|
10198
9231
|
plan.noAnimateAttrs[key] = value;
|
|
10199
9232
|
return;
|
|
10200
9233
|
}
|
|
@@ -10202,7 +9235,7 @@ class StateTransitionOrchestrator {
|
|
|
10202
9235
|
if (shouldSkipDefaultAttribute === null || shouldSkipDefaultAttribute === void 0 ? void 0 : shouldSkipDefaultAttribute(key, targetAttrs)) {
|
|
10203
9236
|
return;
|
|
10204
9237
|
}
|
|
10205
|
-
plan.animateAttrs[key] =
|
|
9238
|
+
plan.animateAttrs[key] = readDefaultAttribute(key);
|
|
10206
9239
|
return;
|
|
10207
9240
|
}
|
|
10208
9241
|
plan.animateAttrs[key] = value;
|
|
@@ -10256,13 +9289,13 @@ class StateTransitionOrchestrator {
|
|
|
10256
9289
|
graphic._emitCustomEvent('afterStateUpdate', { type: AttributeUpdateType.STATE });
|
|
10257
9290
|
return plan;
|
|
10258
9291
|
}
|
|
10259
|
-
applyClearTransition(graphic, targetAttrs, hasAnimation,
|
|
10260
|
-
var _a
|
|
10261
|
-
const plan = this.analyzeTransition(
|
|
10262
|
-
noWorkAnimateAttr:
|
|
9292
|
+
applyClearTransition(graphic, targetAttrs, hasAnimation, options = {}) {
|
|
9293
|
+
var _a;
|
|
9294
|
+
const plan = this.analyzeTransition(targetAttrs, hasAnimation, {
|
|
9295
|
+
noWorkAnimateAttr: graphic.getNoWorkAnimateAttr(),
|
|
10263
9296
|
isClear: true,
|
|
10264
|
-
getDefaultAttribute:
|
|
10265
|
-
shouldSkipDefaultAttribute: (
|
|
9297
|
+
getDefaultAttribute: graphic.getDefaultAttribute.bind(graphic),
|
|
9298
|
+
shouldSkipDefaultAttribute: (_a = options.shouldSkipDefaultAttribute) !== null && _a !== void 0 ? _a : graphic.shouldSkipStateTransitionDefaultAttribute.bind(graphic),
|
|
10266
9299
|
animateConfig: options.animateConfig,
|
|
10267
9300
|
extraAnimateAttrs: options.extraAnimateAttrs
|
|
10268
9301
|
});
|
|
@@ -10271,33 +9304,11 @@ class StateTransitionOrchestrator {
|
|
|
10271
9304
|
}
|
|
10272
9305
|
|
|
10273
9306
|
const compiler = new StateDefinitionCompiler();
|
|
10274
|
-
function copyDefinitions(definitions) {
|
|
10275
|
-
return definitions ? Object.assign({}, definitions) : {};
|
|
10276
|
-
}
|
|
10277
9307
|
function buildEffectiveSourceDefinitions(parentScope, localStateDefinitions, themeStateDefinitions) {
|
|
10278
|
-
|
|
10279
|
-
? copyDefinitions(parentScope.effectiveSourceDefinitions)
|
|
10280
|
-
: copyDefinitions(themeStateDefinitions);
|
|
10281
|
-
if (localStateDefinitions) {
|
|
10282
|
-
Object.keys(localStateDefinitions).forEach(stateName => {
|
|
10283
|
-
merged[stateName] = localStateDefinitions[stateName];
|
|
10284
|
-
});
|
|
10285
|
-
}
|
|
10286
|
-
return merged;
|
|
10287
|
-
}
|
|
10288
|
-
function initializeScope(scope, revision = 0) {
|
|
10289
|
-
var _a;
|
|
10290
|
-
const effectiveSourceDefinitions = buildEffectiveSourceDefinitions(scope.parentScope, scope.localStateDefinitions, scope.themeStateDefinitions);
|
|
10291
|
-
scope.effectiveSourceDefinitions = effectiveSourceDefinitions;
|
|
10292
|
-
scope.effectiveCompiledDefinitions = compiler.compile(effectiveSourceDefinitions);
|
|
10293
|
-
scope.parentRevisionAtBuild = (_a = scope.parentScope) === null || _a === void 0 ? void 0 : _a.revision;
|
|
10294
|
-
scope.revision = revision;
|
|
10295
|
-
scope.dirty = false;
|
|
10296
|
-
return scope;
|
|
9308
|
+
return Object.assign({}, parentScope ? parentScope.effectiveSourceDefinitions : themeStateDefinitions, localStateDefinitions);
|
|
10297
9309
|
}
|
|
10298
9310
|
function createRootSharedStateScope(stage, themeStateDefinitions) {
|
|
10299
|
-
return
|
|
10300
|
-
ownerKind: 'root',
|
|
9311
|
+
return rebuildSharedStateScope({
|
|
10301
9312
|
ownerStage: stage,
|
|
10302
9313
|
themeStateDefinitions,
|
|
10303
9314
|
effectiveSourceDefinitions: {},
|
|
@@ -10308,9 +9319,7 @@ function createRootSharedStateScope(stage, themeStateDefinitions) {
|
|
|
10308
9319
|
}, 0);
|
|
10309
9320
|
}
|
|
10310
9321
|
function createGroupSharedStateScope(group, parentScope, localStateDefinitions) {
|
|
10311
|
-
return
|
|
10312
|
-
ownerKind: 'group',
|
|
10313
|
-
ownerGroup: group,
|
|
9322
|
+
return rebuildSharedStateScope({
|
|
10314
9323
|
ownerStage: group.stage,
|
|
10315
9324
|
parentScope,
|
|
10316
9325
|
localStateDefinitions,
|
|
@@ -10345,22 +9354,20 @@ function setRootSharedStateScopeThemeDefinitions(scope, themeStateDefinitions) {
|
|
|
10345
9354
|
rebuildSharedStateScope(scope);
|
|
10346
9355
|
return true;
|
|
10347
9356
|
}
|
|
10348
|
-
function rebuildSharedStateScope(scope) {
|
|
9357
|
+
function rebuildSharedStateScope(scope, revision = scope.revision + 1) {
|
|
10349
9358
|
var _a;
|
|
10350
9359
|
const effectiveSourceDefinitions = buildEffectiveSourceDefinitions(scope.parentScope, scope.localStateDefinitions, scope.themeStateDefinitions);
|
|
10351
9360
|
scope.effectiveSourceDefinitions = effectiveSourceDefinitions;
|
|
10352
9361
|
scope.effectiveCompiledDefinitions = compiler.compile(effectiveSourceDefinitions);
|
|
10353
9362
|
scope.parentRevisionAtBuild = (_a = scope.parentScope) === null || _a === void 0 ? void 0 : _a.revision;
|
|
10354
|
-
scope.revision
|
|
9363
|
+
scope.revision = revision;
|
|
10355
9364
|
scope.dirty = false;
|
|
10356
9365
|
return scope;
|
|
10357
9366
|
}
|
|
10358
9367
|
function ensureSharedStateScopeFresh(scope) {
|
|
10359
|
-
var _a;
|
|
10360
9368
|
if (!scope) {
|
|
10361
9369
|
return undefined;
|
|
10362
9370
|
}
|
|
10363
|
-
(_a = getActiveStageStatePerfMonitor(scope.ownerStage)) === null || _a === void 0 ? void 0 : _a.recordRefresh('ensureFreshCalls');
|
|
10364
9371
|
if (scope.parentScope) {
|
|
10365
9372
|
ensureSharedStateScopeFresh(scope.parentScope);
|
|
10366
9373
|
}
|
|
@@ -10380,11 +9387,9 @@ function collectSharedStateScopeChain(scope) {
|
|
|
10380
9387
|
}
|
|
10381
9388
|
|
|
10382
9389
|
function scheduleStageSharedStateRefresh(stage) {
|
|
10383
|
-
var _a;
|
|
10384
9390
|
if (!stage || stage.releaseStatus === 'released') {
|
|
10385
9391
|
return;
|
|
10386
9392
|
}
|
|
10387
|
-
(_a = getActiveStageStatePerfMonitor(stage)) === null || _a === void 0 ? void 0 : _a.recordRefresh('renderScheduled');
|
|
10388
9393
|
stage.renderNextFrame();
|
|
10389
9394
|
}
|
|
10390
9395
|
function enqueueGraphicSharedStateRefresh(stage, graphic) {
|
|
@@ -10393,36 +9398,27 @@ function enqueueGraphicSharedStateRefresh(stage, graphic) {
|
|
|
10393
9398
|
return;
|
|
10394
9399
|
}
|
|
10395
9400
|
const pending = (_a = stage._pendingSharedStateRefreshGraphics) !== null && _a !== void 0 ? _a : (stage._pendingSharedStateRefreshGraphics = new Set());
|
|
10396
|
-
|
|
10397
|
-
pending.add(graphic);
|
|
10398
|
-
const perfMonitor = getActiveStageStatePerfMonitor(stage);
|
|
10399
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.recordRefresh('queuedGraphics');
|
|
10400
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.recordAllocation('refreshQueuePushes');
|
|
10401
|
-
}
|
|
9401
|
+
pending.add(graphic);
|
|
10402
9402
|
}
|
|
10403
9403
|
function markScopeActiveDescendantsDirty(scope, stage) {
|
|
10404
|
-
|
|
9404
|
+
if (!scope.subtreeActiveDescendants.size) {
|
|
9405
|
+
return;
|
|
9406
|
+
}
|
|
10405
9407
|
scope.subtreeActiveDescendants.forEach(graphic => {
|
|
10406
9408
|
var _a;
|
|
10407
9409
|
graphic.sharedStateDirty = true;
|
|
10408
9410
|
const ownerStage = (_a = stage !== null && stage !== void 0 ? stage : graphic.stage) !== null && _a !== void 0 ? _a : scope.ownerStage;
|
|
10409
9411
|
enqueueGraphicSharedStateRefresh(ownerStage, graphic);
|
|
10410
|
-
marked = true;
|
|
10411
9412
|
});
|
|
10412
|
-
|
|
10413
|
-
scheduleStageSharedStateRefresh(stage !== null && stage !== void 0 ? stage : scope.ownerStage);
|
|
10414
|
-
}
|
|
9413
|
+
scheduleStageSharedStateRefresh(stage !== null && stage !== void 0 ? stage : scope.ownerStage);
|
|
10415
9414
|
}
|
|
10416
9415
|
function flushStageSharedStateRefresh(stage) {
|
|
10417
9416
|
const pending = stage._pendingSharedStateRefreshGraphics;
|
|
10418
9417
|
if (!pending || !pending.size) {
|
|
10419
9418
|
return;
|
|
10420
9419
|
}
|
|
10421
|
-
const perfMonitor = getActiveStageStatePerfMonitor(stage);
|
|
10422
|
-
const start = perfMonitor ? performance.now() : 0;
|
|
10423
9420
|
const graphics = Array.from(pending.values());
|
|
10424
9421
|
pending.clear();
|
|
10425
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.recordRefresh('flushedGraphics', graphics.length);
|
|
10426
9422
|
graphics.forEach(graphic => {
|
|
10427
9423
|
if (graphic.releaseStatus === 'released') {
|
|
10428
9424
|
return;
|
|
@@ -10433,23 +9429,13 @@ function flushStageSharedStateRefresh(stage) {
|
|
|
10433
9429
|
if (!graphic.sharedStateDirty) {
|
|
10434
9430
|
return;
|
|
10435
9431
|
}
|
|
10436
|
-
|
|
10437
|
-
if (typeof refresh === 'function') {
|
|
10438
|
-
refresh.call(graphic);
|
|
10439
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.incrementCounter('sharedRefreshCommits');
|
|
10440
|
-
}
|
|
9432
|
+
graphic.refreshSharedStateBeforeRender();
|
|
10441
9433
|
});
|
|
10442
|
-
if (perfMonitor) {
|
|
10443
|
-
perfMonitor.recordCost('sharedRefresh', performance.now() - start);
|
|
10444
|
-
perfMonitor.recordEvent('shared-refresh-flush', {
|
|
10445
|
-
stageId: stage._uid,
|
|
10446
|
-
flushedGraphics: graphics.length
|
|
10447
|
-
});
|
|
10448
|
-
}
|
|
10449
9434
|
}
|
|
10450
9435
|
|
|
10451
9436
|
const _tempBounds$1 = new AABBBounds();
|
|
10452
9437
|
const loadShadowRootFactory = () => require('./shadow-root');
|
|
9438
|
+
const loadXMLParser = () => require('../common/xml/parser');
|
|
10453
9439
|
const tempMatrix = new Matrix();
|
|
10454
9440
|
const PURE_STYLE_KEY = [
|
|
10455
9441
|
'stroke',
|
|
@@ -10485,18 +9471,8 @@ const builtinTextureTypes = new Set([
|
|
|
10485
9471
|
'grid',
|
|
10486
9472
|
'wave'
|
|
10487
9473
|
]);
|
|
10488
|
-
const FULL_STATE_DEFINITION_KEYS = new Set([
|
|
10489
|
-
'name',
|
|
10490
|
-
'patch',
|
|
10491
|
-
'priority',
|
|
10492
|
-
'exclude',
|
|
10493
|
-
'suppress',
|
|
10494
|
-
'resolver',
|
|
10495
|
-
'declaredAffectedKeys'
|
|
10496
|
-
]);
|
|
10497
9474
|
const point = new Point();
|
|
10498
9475
|
const EMPTY_STATE_NAMES = [];
|
|
10499
|
-
const deprecatedLocalStateFallbackWarningStateNames = new Set();
|
|
10500
9476
|
const BROAD_UPDATE_CATEGORY = UpdateCategory.PAINT |
|
|
10501
9477
|
UpdateCategory.SHAPE |
|
|
10502
9478
|
UpdateCategory.BOUNDS |
|
|
@@ -10650,18 +9626,6 @@ class Graphic extends Node {
|
|
|
10650
9626
|
getAttributes() {
|
|
10651
9627
|
return this.attribute;
|
|
10652
9628
|
}
|
|
10653
|
-
getStateStyleResolver(mergeMode) {
|
|
10654
|
-
if (mergeMode === 'deep') {
|
|
10655
|
-
if (!this.deepStateStyleResolver) {
|
|
10656
|
-
this.deepStateStyleResolver = new StateStyleResolver({ mergeMode: 'deep' });
|
|
10657
|
-
}
|
|
10658
|
-
return this.deepStateStyleResolver;
|
|
10659
|
-
}
|
|
10660
|
-
if (!this.stateStyleResolver) {
|
|
10661
|
-
this.stateStyleResolver = new StateStyleResolver();
|
|
10662
|
-
}
|
|
10663
|
-
return this.stateStyleResolver;
|
|
10664
|
-
}
|
|
10665
9629
|
getStateTransitionOrchestrator() {
|
|
10666
9630
|
if (!this.stateTransitionOrchestrator) {
|
|
10667
9631
|
this.stateTransitionOrchestrator = new StateTransitionOrchestrator();
|
|
@@ -10688,12 +9652,10 @@ class Graphic extends Node {
|
|
|
10688
9652
|
}
|
|
10689
9653
|
this.boundSharedStateScope = nextScope;
|
|
10690
9654
|
this.boundSharedStateRevision = undefined;
|
|
10691
|
-
this.localFallbackCompiledDefinitions = undefined;
|
|
10692
9655
|
this.compiledStateDefinitions = undefined;
|
|
10693
9656
|
this.compiledStateDefinitionsCacheKey = undefined;
|
|
10694
9657
|
this.stateEngine = undefined;
|
|
10695
9658
|
this.stateEngineCompiledDefinitions = undefined;
|
|
10696
|
-
this.stateEngineStateProxyModeKey = undefined;
|
|
10697
9659
|
this.syncSharedStateActiveRegistrations();
|
|
10698
9660
|
if (markDirty && ((_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
10699
9661
|
this.markSharedStateDirty();
|
|
@@ -10776,20 +9738,9 @@ class Graphic extends Node {
|
|
|
10776
9738
|
var _a, _b;
|
|
10777
9739
|
if (this.localStateDefinitionsSource !== this.states) {
|
|
10778
9740
|
this.localStateDefinitionsSource = this.states;
|
|
10779
|
-
this.
|
|
10780
|
-
}
|
|
10781
|
-
return (_b = this.localFallbackVersion) !== null && _b !== void 0 ? _b : 0;
|
|
10782
|
-
}
|
|
10783
|
-
warnDeprecatedLocalStatesFallback(stateNames) {
|
|
10784
|
-
for (let index = 0; index < stateNames.length; index++) {
|
|
10785
|
-
const stateName = stateNames[index];
|
|
10786
|
-
if (deprecatedLocalStateFallbackWarningStateNames.has(stateName)) {
|
|
10787
|
-
continue;
|
|
10788
|
-
}
|
|
10789
|
-
deprecatedLocalStateFallbackWarningStateNames.add(stateName);
|
|
10790
|
-
console.warn(`[VRender] graphic.states fallback for missing shared state definition "${stateName}" is deprecated. ` +
|
|
10791
|
-
'Move the state definition to sharedStateDefinitions or use stateProxy for dynamic per-graphic styles.');
|
|
9741
|
+
this.localStateDefinitionsVersion = ((_a = this.localStateDefinitionsVersion) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
10792
9742
|
}
|
|
9743
|
+
return (_b = this.localStateDefinitionsVersion) !== null && _b !== void 0 ? _b : 0;
|
|
10793
9744
|
}
|
|
10794
9745
|
resolveEffectiveCompiledDefinitions() {
|
|
10795
9746
|
this.syncSharedStateScopeBindingFromTree(false);
|
|
@@ -10802,8 +9753,7 @@ class Graphic extends Node {
|
|
|
10802
9753
|
if (!boundScope) {
|
|
10803
9754
|
if (!hasStates) {
|
|
10804
9755
|
return {
|
|
10805
|
-
compiledDefinitions: undefined
|
|
10806
|
-
stateProxyModeKey: 'none'
|
|
9756
|
+
compiledDefinitions: undefined
|
|
10807
9757
|
};
|
|
10808
9758
|
}
|
|
10809
9759
|
const localStatesVersion = this.getLocalStatesVersion();
|
|
@@ -10813,53 +9763,12 @@ class Graphic extends Node {
|
|
|
10813
9763
|
this.compiledStateDefinitionsCacheKey = cacheKey;
|
|
10814
9764
|
}
|
|
10815
9765
|
return {
|
|
10816
|
-
compiledDefinitions: this.compiledStateDefinitions
|
|
10817
|
-
stateProxyModeKey: this.stateProxy ? 'legacy-all' : 'none'
|
|
9766
|
+
compiledDefinitions: this.compiledStateDefinitions
|
|
10818
9767
|
};
|
|
10819
9768
|
}
|
|
10820
9769
|
const sharedCompiledDefinitions = boundScope.effectiveCompiledDefinitions;
|
|
10821
|
-
const sharedStateProxyModeKey = this.stateProxy ? 'shared-missing-only' : 'none';
|
|
10822
|
-
const sharedStateProxyEligibility = this.stateProxy
|
|
10823
|
-
? (stateName) => !sharedCompiledDefinitions.has(stateName)
|
|
10824
|
-
: undefined;
|
|
10825
|
-
if (!hasStates) {
|
|
10826
|
-
this.localFallbackCompiledDefinitions = undefined;
|
|
10827
|
-
return {
|
|
10828
|
-
compiledDefinitions: sharedCompiledDefinitions,
|
|
10829
|
-
stateProxyModeKey: sharedStateProxyModeKey,
|
|
10830
|
-
stateProxyEligibility: sharedStateProxyEligibility
|
|
10831
|
-
};
|
|
10832
|
-
}
|
|
10833
|
-
const localStates = this.states;
|
|
10834
|
-
const missingLocalStateDefinitions = {};
|
|
10835
|
-
const missingStateNames = [];
|
|
10836
|
-
Object.keys(localStates).forEach(stateName => {
|
|
10837
|
-
if (sharedCompiledDefinitions.has(stateName)) {
|
|
10838
|
-
return;
|
|
10839
|
-
}
|
|
10840
|
-
missingLocalStateDefinitions[stateName] = localStates[stateName];
|
|
10841
|
-
missingStateNames.push(stateName);
|
|
10842
|
-
});
|
|
10843
|
-
if (!missingStateNames.length) {
|
|
10844
|
-
this.localFallbackCompiledDefinitions = undefined;
|
|
10845
|
-
return {
|
|
10846
|
-
compiledDefinitions: sharedCompiledDefinitions,
|
|
10847
|
-
stateProxyModeKey: sharedStateProxyModeKey,
|
|
10848
|
-
stateProxyEligibility: sharedStateProxyEligibility
|
|
10849
|
-
};
|
|
10850
|
-
}
|
|
10851
|
-
this.warnDeprecatedLocalStatesFallback(missingStateNames);
|
|
10852
|
-
const localStatesVersion = this.getLocalStatesVersion();
|
|
10853
|
-
const stateProxyModeKey = this.stateProxy ? `missing:${missingStateNames.sort().join('|')}` : 'none';
|
|
10854
|
-
const cacheKey = `shared:${boundScope.revision}:fallback:${localStatesVersion}:${stateProxyModeKey}`;
|
|
10855
|
-
if (!this.localFallbackCompiledDefinitions || this.compiledStateDefinitionsCacheKey !== cacheKey) {
|
|
10856
|
-
this.localFallbackCompiledDefinitions = new StateDefinitionCompiler().compile(Object.assign(Object.assign({}, boundScope.effectiveSourceDefinitions), missingLocalStateDefinitions));
|
|
10857
|
-
this.compiledStateDefinitionsCacheKey = cacheKey;
|
|
10858
|
-
}
|
|
10859
9770
|
return {
|
|
10860
|
-
compiledDefinitions:
|
|
10861
|
-
stateProxyModeKey,
|
|
10862
|
-
stateProxyEligibility: sharedStateProxyEligibility
|
|
9771
|
+
compiledDefinitions: sharedCompiledDefinitions
|
|
10863
9772
|
};
|
|
10864
9773
|
}
|
|
10865
9774
|
recomputeCurrentStatePatch() {
|
|
@@ -10871,11 +9780,9 @@ class Graphic extends Node {
|
|
|
10871
9780
|
return;
|
|
10872
9781
|
}
|
|
10873
9782
|
const stateResolveBaseAttrs = this.getStateResolveBaseAttrs();
|
|
10874
|
-
const
|
|
10875
|
-
const transition = stateModel.useStates(this.currentStates);
|
|
9783
|
+
const transition = this.resolveUseStatesTransition(this.currentStates, stateResolveBaseAttrs);
|
|
10876
9784
|
const effectiveStates = (_b = transition.effectiveStates) !== null && _b !== void 0 ? _b : transition.states;
|
|
10877
|
-
const resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions
|
|
10878
|
-
? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
|
|
9785
|
+
const resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : {};
|
|
10879
9786
|
this.currentStates = transition.states;
|
|
10880
9787
|
this.effectiveStates = [...effectiveStates];
|
|
10881
9788
|
this.resolvedStatePatch = resolvedStateAttrs;
|
|
@@ -10984,19 +9891,12 @@ class Graphic extends Node {
|
|
|
10984
9891
|
return category | nextCategory;
|
|
10985
9892
|
}
|
|
10986
9893
|
submitUpdateByCategory(category, forceUpdateTag = false) {
|
|
10987
|
-
var _a;
|
|
10988
9894
|
if (forceUpdateTag) {
|
|
10989
9895
|
this.addUpdateShapeAndBoundsTag();
|
|
10990
9896
|
this.addUpdatePositionTag();
|
|
10991
9897
|
this.addUpdateLayoutTag();
|
|
10992
9898
|
return;
|
|
10993
9899
|
}
|
|
10994
|
-
if (category !== UpdateCategory.NONE) {
|
|
10995
|
-
const stage = this.stage;
|
|
10996
|
-
if (stage) {
|
|
10997
|
-
(_a = getActiveStageStatePerfMonitor(stage)) === null || _a === void 0 ? void 0 : _a.recordCategory(category);
|
|
10998
|
-
}
|
|
10999
|
-
}
|
|
11000
9900
|
if ((category & BROAD_UPDATE_CATEGORY) === BROAD_UPDATE_CATEGORY) {
|
|
11001
9901
|
this.addBroadUpdateTag();
|
|
11002
9902
|
return;
|
|
@@ -11399,6 +10299,7 @@ class Graphic extends Node {
|
|
|
11399
10299
|
symbolType = _symbolType || symbolType;
|
|
11400
10300
|
const valid = isSvg(symbolType);
|
|
11401
10301
|
if (valid === true) {
|
|
10302
|
+
const { XMLParser } = loadXMLParser();
|
|
11402
10303
|
const parser = new XMLParser();
|
|
11403
10304
|
const { svg } = parser.parse(symbolType);
|
|
11404
10305
|
if (!svg) {
|
|
@@ -11949,159 +10850,141 @@ class Graphic extends Node {
|
|
|
11949
10850
|
(_a = this.stateEngine) === null || _a === void 0 ? void 0 : _a.setResolveContext(this, stateResolveBaseAttrs);
|
|
11950
10851
|
return stateResolveBaseAttrs;
|
|
11951
10852
|
}
|
|
11952
|
-
|
|
11953
|
-
const { compiledDefinitions
|
|
10853
|
+
ensureStateEngine(stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
|
|
10854
|
+
const { compiledDefinitions } = this.resolveEffectiveCompiledDefinitions();
|
|
11954
10855
|
this.compiledStateDefinitions = compiledDefinitions;
|
|
11955
10856
|
if (!compiledDefinitions) {
|
|
11956
10857
|
this.stateEngine = undefined;
|
|
11957
10858
|
this.stateEngineCompiledDefinitions = undefined;
|
|
11958
|
-
this.stateEngineStateProxyModeKey = undefined;
|
|
11959
10859
|
}
|
|
11960
10860
|
else if (!this.stateEngine ||
|
|
11961
10861
|
this.stateEngineCompiledDefinitions !== compiledDefinitions ||
|
|
11962
|
-
this.stateEngineStateProxy !== this.stateProxy ||
|
|
11963
10862
|
this.stateEngineStateSort !== this.stateSort ||
|
|
11964
|
-
this.stateEngineMergeMode !== this.stateMergeMode
|
|
11965
|
-
this.stateEngineStateProxyModeKey !== stateProxyModeKey) {
|
|
10863
|
+
this.stateEngineMergeMode !== this.stateMergeMode) {
|
|
11966
10864
|
this.stateEngine = new StateEngine({
|
|
11967
10865
|
compiledDefinitions,
|
|
11968
10866
|
stateSort: this.stateSort,
|
|
11969
|
-
stateProxy: this.stateProxy,
|
|
11970
|
-
stateProxyEligibility,
|
|
11971
|
-
states: this.states,
|
|
11972
10867
|
mergeMode: this.stateMergeMode
|
|
11973
10868
|
});
|
|
11974
10869
|
this.stateEngineCompiledDefinitions = compiledDefinitions;
|
|
11975
|
-
this.stateEngineStateProxy = this.stateProxy;
|
|
11976
10870
|
this.stateEngineStateSort = this.stateSort;
|
|
11977
10871
|
this.stateEngineMergeMode = this.stateMergeMode;
|
|
11978
|
-
this.stateEngineStateProxyModeKey = stateProxyModeKey;
|
|
11979
10872
|
}
|
|
11980
10873
|
this.syncStateResolveContext(stateResolveBaseAttrs);
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
11985
|
-
|
|
11986
|
-
|
|
11987
|
-
|
|
10874
|
+
if (this.stateEngine &&
|
|
10875
|
+
this.currentStates &&
|
|
10876
|
+
!this.sameStateNames(this.stateEngine.activeStates, this.currentStates)) {
|
|
10877
|
+
this.stateEngine.applyStates(this.currentStates);
|
|
10878
|
+
}
|
|
10879
|
+
return this.stateEngine;
|
|
10880
|
+
}
|
|
10881
|
+
toGraphicStateTransition(result) {
|
|
10882
|
+
return {
|
|
10883
|
+
changed: result.changed,
|
|
10884
|
+
states: [...result.activeStates],
|
|
10885
|
+
effectiveStates: [...result.effectiveStates]
|
|
10886
|
+
};
|
|
10887
|
+
}
|
|
10888
|
+
sortLocalStates(states) {
|
|
10889
|
+
return this.stateSort ? [...states].sort(this.stateSort) : [...states];
|
|
10890
|
+
}
|
|
10891
|
+
resolveLocalUseStatesTransition(states) {
|
|
10892
|
+
var _a;
|
|
10893
|
+
if (!states.length) {
|
|
10894
|
+
return this.resolveLocalClearStatesTransition();
|
|
10895
|
+
}
|
|
10896
|
+
const previousStates = (_a = this.currentStates) !== null && _a !== void 0 ? _a : EMPTY_STATE_NAMES;
|
|
10897
|
+
const changed = previousStates.length !== states.length || states.some((stateName, index) => previousStates[index] !== stateName);
|
|
10898
|
+
const nextStates = this.sortLocalStates(states);
|
|
10899
|
+
return {
|
|
10900
|
+
changed,
|
|
10901
|
+
states: changed ? nextStates : [...previousStates]
|
|
10902
|
+
};
|
|
11988
10903
|
}
|
|
11989
|
-
|
|
10904
|
+
resolveLocalClearStatesTransition() {
|
|
10905
|
+
return {
|
|
10906
|
+
changed: this.hasState(),
|
|
10907
|
+
states: []
|
|
10908
|
+
};
|
|
10909
|
+
}
|
|
10910
|
+
resolveUseStatesTransition(states, stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
|
|
10911
|
+
const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
|
|
10912
|
+
return stateEngine
|
|
10913
|
+
? this.toGraphicStateTransition(stateEngine.applyStates(states))
|
|
10914
|
+
: this.resolveLocalUseStatesTransition(states);
|
|
10915
|
+
}
|
|
10916
|
+
resolveClearStatesTransition() {
|
|
10917
|
+
const stateEngine = this.ensureStateEngine();
|
|
10918
|
+
return stateEngine
|
|
10919
|
+
? this.toGraphicStateTransition(stateEngine.clearStates())
|
|
10920
|
+
: this.resolveLocalClearStatesTransition();
|
|
10921
|
+
}
|
|
10922
|
+
resolveAddStateTransition(stateName, keepCurrentStates) {
|
|
11990
10923
|
var _a;
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
this.
|
|
11994
|
-
this.stateMergeMode === 'deep' ||
|
|
11995
|
-
this.parent ||
|
|
11996
|
-
((_a = this.stage) === null || _a === void 0 ? void 0 : _a.rootSharedStateScope) ||
|
|
11997
|
-
this.boundSharedStateScope) {
|
|
11998
|
-
return null;
|
|
10924
|
+
const stateEngine = this.ensureStateEngine();
|
|
10925
|
+
if (stateEngine) {
|
|
10926
|
+
return this.toGraphicStateTransition(stateEngine.addState(stateName, keepCurrentStates));
|
|
11999
10927
|
}
|
|
12000
|
-
if (
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
const nextStates = [stateName];
|
|
12004
|
-
const changed = !this.sameStateNames(previousStates, nextStates);
|
|
12005
|
-
const resolvedStateAttrs = {};
|
|
12006
|
-
if (hasDefinition) {
|
|
12007
|
-
const attrs = this.states[stateName];
|
|
12008
|
-
if (attrs != null) {
|
|
12009
|
-
if (!isPlainObjectValue(attrs)) {
|
|
12010
|
-
return null;
|
|
12011
|
-
}
|
|
12012
|
-
const keys = Object.keys(attrs);
|
|
12013
|
-
for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
|
|
12014
|
-
const key = keys[keyIndex];
|
|
12015
|
-
if (FULL_STATE_DEFINITION_KEYS.has(key)) {
|
|
12016
|
-
return null;
|
|
12017
|
-
}
|
|
12018
|
-
const attrValue = attrs[key];
|
|
12019
|
-
resolvedStateAttrs[key] = isPlainObjectValue(attrValue)
|
|
12020
|
-
? cloneAttributeValue(attrValue)
|
|
12021
|
-
: attrValue;
|
|
12022
|
-
}
|
|
12023
|
-
}
|
|
12024
|
-
}
|
|
10928
|
+
if (this.currentStates &&
|
|
10929
|
+
this.currentStates.includes(stateName) &&
|
|
10930
|
+
(keepCurrentStates || this.currentStates.length === 1)) {
|
|
12025
10931
|
return {
|
|
12026
|
-
changed,
|
|
12027
|
-
states:
|
|
12028
|
-
effectiveStates: nextStates,
|
|
12029
|
-
resolvedStateAttrs
|
|
10932
|
+
changed: false,
|
|
10933
|
+
states: [...this.currentStates]
|
|
12030
10934
|
};
|
|
12031
10935
|
}
|
|
12032
|
-
const
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
}
|
|
12040
|
-
else {
|
|
12041
|
-
withoutDefinition.push(stateName);
|
|
12042
|
-
}
|
|
10936
|
+
const nextStates = keepCurrentStates && ((_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.length) ? this.currentStates.concat([stateName]) : [stateName];
|
|
10937
|
+
return this.resolveLocalUseStatesTransition(nextStates);
|
|
10938
|
+
}
|
|
10939
|
+
resolveRemoveStateTransition(stateName) {
|
|
10940
|
+
const stateEngine = this.ensureStateEngine();
|
|
10941
|
+
if (stateEngine) {
|
|
10942
|
+
return this.toGraphicStateTransition(stateEngine.removeState(stateName));
|
|
12043
10943
|
}
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
const stateName = nextStates[i];
|
|
12050
|
-
const hasDefinition = Object.prototype.hasOwnProperty.call(this.states, stateName);
|
|
12051
|
-
if (!hasDefinition) {
|
|
12052
|
-
continue;
|
|
12053
|
-
}
|
|
12054
|
-
const attrs = this.states[stateName];
|
|
12055
|
-
if (attrs == null) {
|
|
12056
|
-
continue;
|
|
12057
|
-
}
|
|
12058
|
-
if (!isPlainObjectValue(attrs)) {
|
|
12059
|
-
return null;
|
|
12060
|
-
}
|
|
12061
|
-
const keys = Object.keys(attrs);
|
|
12062
|
-
for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
|
|
12063
|
-
const key = keys[keyIndex];
|
|
12064
|
-
if (FULL_STATE_DEFINITION_KEYS.has(key)) {
|
|
12065
|
-
return null;
|
|
12066
|
-
}
|
|
12067
|
-
const attrValue = attrs[key];
|
|
12068
|
-
resolvedStateAttrs[key] = isPlainObjectValue(attrValue)
|
|
12069
|
-
? cloneAttributeValue(attrValue)
|
|
12070
|
-
: attrValue;
|
|
12071
|
-
}
|
|
10944
|
+
if (!this.currentStates) {
|
|
10945
|
+
return {
|
|
10946
|
+
changed: false,
|
|
10947
|
+
states: []
|
|
10948
|
+
};
|
|
12072
10949
|
}
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
10950
|
+
const filter = Array.isArray(stateName) ? (s) => !stateName.includes(s) : (s) => s !== stateName;
|
|
10951
|
+
const nextStates = this.currentStates.filter(filter);
|
|
10952
|
+
if (nextStates.length === this.currentStates.length) {
|
|
10953
|
+
return {
|
|
10954
|
+
changed: false,
|
|
10955
|
+
states: [...this.currentStates]
|
|
10956
|
+
};
|
|
10957
|
+
}
|
|
10958
|
+
return this.resolveLocalUseStatesTransition(nextStates);
|
|
12079
10959
|
}
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
let resolvedStateAttrs;
|
|
12085
|
-
if (transition) {
|
|
12086
|
-
resolvedStateAttrs = transition.resolvedStateAttrs;
|
|
10960
|
+
resolveToggleStateTransition(stateName) {
|
|
10961
|
+
const stateEngine = this.ensureStateEngine();
|
|
10962
|
+
if (stateEngine) {
|
|
10963
|
+
return this.toGraphicStateTransition(stateEngine.toggleState(stateName));
|
|
12087
10964
|
}
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
const stateModel = this.createStateModel(stateResolveBaseAttrs);
|
|
12091
|
-
if (forceResolverRefresh) {
|
|
12092
|
-
(_a = this.stateEngine) === null || _a === void 0 ? void 0 : _a.invalidateResolverCache();
|
|
12093
|
-
}
|
|
12094
|
-
transition = stateModel.useStates(states);
|
|
12095
|
-
resolvedStateAttrs =
|
|
12096
|
-
this.stateEngine && this.compiledStateDefinitions
|
|
12097
|
-
? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
|
|
10965
|
+
if (this.hasState(stateName)) {
|
|
10966
|
+
return this.resolveRemoveStateTransition(stateName);
|
|
12098
10967
|
}
|
|
12099
|
-
const
|
|
10968
|
+
const nextStates = this.currentStates ? this.currentStates.slice() : [];
|
|
10969
|
+
nextStates.push(stateName);
|
|
10970
|
+
return this.resolveLocalUseStatesTransition(nextStates);
|
|
10971
|
+
}
|
|
10972
|
+
resolveGraphicStateTransition(states, forceResolverRefresh = false) {
|
|
10973
|
+
var _a;
|
|
10974
|
+
const stateResolveBaseAttrs = this.getStateResolveBaseAttrs();
|
|
10975
|
+
const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
|
|
10976
|
+
if (forceResolverRefresh) {
|
|
10977
|
+
stateEngine === null || stateEngine === void 0 ? void 0 : stateEngine.invalidateResolverCache();
|
|
10978
|
+
}
|
|
10979
|
+
const transition = stateEngine
|
|
10980
|
+
? this.toGraphicStateTransition(stateEngine.applyStates(states))
|
|
10981
|
+
: this.resolveLocalUseStatesTransition(states);
|
|
10982
|
+
const resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : {};
|
|
10983
|
+
const effectiveStates = (_a = transition.effectiveStates) !== null && _a !== void 0 ? _a : transition.states;
|
|
12100
10984
|
return {
|
|
12101
10985
|
transition,
|
|
12102
10986
|
effectiveStates: effectiveStates,
|
|
12103
|
-
resolvedStateAttrs
|
|
12104
|
-
isSimpleLocalTransition
|
|
10987
|
+
resolvedStateAttrs
|
|
12105
10988
|
};
|
|
12106
10989
|
}
|
|
12107
10990
|
normalizeSetStatesOptions(options) {
|
|
@@ -12138,28 +11021,20 @@ class Graphic extends Node {
|
|
|
12138
11021
|
var _a;
|
|
12139
11022
|
const previousStates = (_a = this.currentStates) !== null && _a !== void 0 ? _a : EMPTY_STATE_NAMES;
|
|
12140
11023
|
const previousResolvedStatePatch = this.resolvedStatePatch;
|
|
12141
|
-
const { transition, effectiveStates, resolvedStateAttrs
|
|
11024
|
+
const { transition, effectiveStates, resolvedStateAttrs } = this.resolveGraphicStateTransition(states, true);
|
|
12142
11025
|
const patchChanged = !this.sameStatePatches(previousResolvedStatePatch, resolvedStateAttrs);
|
|
12143
11026
|
if (patchChanged &&
|
|
12144
11027
|
!this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, false)) {
|
|
12145
11028
|
return;
|
|
12146
11029
|
}
|
|
12147
11030
|
this.currentStates = transition.states;
|
|
12148
|
-
this.effectiveStates =
|
|
11031
|
+
this.effectiveStates = [...effectiveStates];
|
|
12149
11032
|
this.resolvedStatePatch = resolvedStateAttrs;
|
|
12150
11033
|
this.sharedStateDirty = false;
|
|
12151
11034
|
this.syncSharedStateActiveRegistrations();
|
|
12152
11035
|
if (!patchChanged) {
|
|
12153
11036
|
return;
|
|
12154
11037
|
}
|
|
12155
|
-
if (this.stage) {
|
|
12156
|
-
const perfMonitor = getActiveStageStatePerfMonitor(this.stage);
|
|
12157
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.incrementCounter('stateCommits');
|
|
12158
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.recordEvent('state-commit', {
|
|
12159
|
-
graphicId: this._uid,
|
|
12160
|
-
targetStates: [...transition.states]
|
|
12161
|
-
});
|
|
12162
|
-
}
|
|
12163
11038
|
if (hasAnimation && animateSameStatePatchChange) {
|
|
12164
11039
|
this._syncFinalAttributeFromStaticTruth();
|
|
12165
11040
|
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, false, undefined, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch));
|
|
@@ -12191,10 +11066,10 @@ class Graphic extends Node {
|
|
|
12191
11066
|
}
|
|
12192
11067
|
: undefined;
|
|
12193
11068
|
if (isClear) {
|
|
12194
|
-
this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation,
|
|
11069
|
+
this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, transitionOptions);
|
|
12195
11070
|
return;
|
|
12196
11071
|
}
|
|
12197
|
-
const plan = this.getStateTransitionOrchestrator().analyzeTransition(
|
|
11072
|
+
const plan = this.getStateTransitionOrchestrator().analyzeTransition(attrs, hasAnimation, {
|
|
12198
11073
|
noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
|
|
12199
11074
|
animateConfig: resolvedAnimateConfig,
|
|
12200
11075
|
extraAnimateAttrs: extraAnimateAttrs,
|
|
@@ -12227,19 +11102,11 @@ class Graphic extends Node {
|
|
|
12227
11102
|
});
|
|
12228
11103
|
stateAnimates.forEach(animate => animate.stop(type));
|
|
12229
11104
|
}
|
|
12230
|
-
getNormalAttribute(key) {
|
|
12231
|
-
var _a, _b;
|
|
12232
|
-
const value = this.attribute[key];
|
|
12233
|
-
if (this.hasAnyTrackedAnimate()) {
|
|
12234
|
-
return (_a = this.finalAttribute) === null || _a === void 0 ? void 0 : _a[key];
|
|
12235
|
-
}
|
|
12236
|
-
return value !== null && value !== void 0 ? value : (_b = this.finalAttribute) === null || _b === void 0 ? void 0 : _b[key];
|
|
12237
|
-
}
|
|
12238
11105
|
clearStates(hasAnimation) {
|
|
12239
11106
|
var _a, _b, _c;
|
|
12240
11107
|
const previousStates = (_a = this.currentStates) !== null && _a !== void 0 ? _a : EMPTY_STATE_NAMES;
|
|
12241
11108
|
const previousResolvedStatePatch = this.resolvedStatePatch;
|
|
12242
|
-
const transition = this.
|
|
11109
|
+
const transition = this.resolveClearStatesTransition();
|
|
12243
11110
|
if (!transition.changed && previousStates.length === 0) {
|
|
12244
11111
|
this.currentStates = [];
|
|
12245
11112
|
this.effectiveStates = [];
|
|
@@ -12260,14 +11127,6 @@ class Graphic extends Node {
|
|
|
12260
11127
|
this.resolvedStatePatch = undefined;
|
|
12261
11128
|
this.sharedStateDirty = false;
|
|
12262
11129
|
this.clearSharedStateActiveRegistrations();
|
|
12263
|
-
if (this.stage) {
|
|
12264
|
-
const perfMonitor = getActiveStageStatePerfMonitor(this.stage);
|
|
12265
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.incrementCounter('stateCommits');
|
|
12266
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.recordEvent('state-commit', {
|
|
12267
|
-
graphicId: this._uid,
|
|
12268
|
-
targetStates: []
|
|
12269
|
-
});
|
|
12270
|
-
}
|
|
12271
11130
|
if (hasAnimation) {
|
|
12272
11131
|
this._syncFinalAttributeFromStaticTruth();
|
|
12273
11132
|
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, true, undefined, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch));
|
|
@@ -12286,19 +11145,19 @@ class Graphic extends Node {
|
|
|
12286
11145
|
}
|
|
12287
11146
|
}
|
|
12288
11147
|
removeState(stateName, hasAnimation) {
|
|
12289
|
-
const transition = this.
|
|
11148
|
+
const transition = this.resolveRemoveStateTransition(stateName);
|
|
12290
11149
|
if (transition.changed) {
|
|
12291
11150
|
this.useStates(transition.states, hasAnimation);
|
|
12292
11151
|
}
|
|
12293
11152
|
}
|
|
12294
11153
|
toggleState(stateName, hasAnimation) {
|
|
12295
|
-
const transition = this.
|
|
11154
|
+
const transition = this.resolveToggleStateTransition(stateName);
|
|
12296
11155
|
if (transition.changed) {
|
|
12297
11156
|
this.useStates(transition.states, hasAnimation);
|
|
12298
11157
|
}
|
|
12299
11158
|
}
|
|
12300
11159
|
addState(stateName, keepCurrentStates, hasAnimation) {
|
|
12301
|
-
const transition = this.
|
|
11160
|
+
const transition = this.resolveAddStateTransition(stateName, keepCurrentStates);
|
|
12302
11161
|
if (!transition.changed) {
|
|
12303
11162
|
return;
|
|
12304
11163
|
}
|
|
@@ -12339,7 +11198,7 @@ class Graphic extends Node {
|
|
|
12339
11198
|
}
|
|
12340
11199
|
const previousStates = (_a = this.currentStates) !== null && _a !== void 0 ? _a : EMPTY_STATE_NAMES;
|
|
12341
11200
|
const previousResolvedStatePatch = this.resolvedStatePatch;
|
|
12342
|
-
const { transition, effectiveStates, resolvedStateAttrs
|
|
11201
|
+
const { transition, effectiveStates, resolvedStateAttrs } = this.resolveGraphicStateTransition(states);
|
|
12343
11202
|
if (!transition.changed && this.sameStateNames(previousStates, transition.states)) {
|
|
12344
11203
|
return;
|
|
12345
11204
|
}
|
|
@@ -12347,18 +11206,10 @@ class Graphic extends Node {
|
|
|
12347
11206
|
return;
|
|
12348
11207
|
}
|
|
12349
11208
|
this.currentStates = transition.states;
|
|
12350
|
-
this.effectiveStates =
|
|
11209
|
+
this.effectiveStates = [...effectiveStates];
|
|
12351
11210
|
this.resolvedStatePatch = resolvedStateAttrs;
|
|
12352
11211
|
this.sharedStateDirty = false;
|
|
12353
11212
|
this.syncSharedStateActiveRegistrations();
|
|
12354
|
-
if (this.stage) {
|
|
12355
|
-
const perfMonitor = getActiveStageStatePerfMonitor(this.stage);
|
|
12356
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.incrementCounter('stateCommits');
|
|
12357
|
-
perfMonitor === null || perfMonitor === void 0 ? void 0 : perfMonitor.recordEvent('state-commit', {
|
|
12358
|
-
graphicId: this._uid,
|
|
12359
|
-
targetStates: [...transition.states]
|
|
12360
|
-
});
|
|
12361
|
-
}
|
|
12362
11213
|
if (hasAnimation) {
|
|
12363
11214
|
this._syncFinalAttributeFromStaticTruth();
|
|
12364
11215
|
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, false, undefined, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch));
|
|
@@ -12622,12 +11473,10 @@ class Graphic extends Node {
|
|
|
12622
11473
|
}
|
|
12623
11474
|
this.boundSharedStateScope = undefined;
|
|
12624
11475
|
this.boundSharedStateRevision = undefined;
|
|
12625
|
-
this.localFallbackCompiledDefinitions = undefined;
|
|
12626
11476
|
this.compiledStateDefinitions = undefined;
|
|
12627
11477
|
this.compiledStateDefinitionsCacheKey = undefined;
|
|
12628
11478
|
this.stateEngine = undefined;
|
|
12629
11479
|
this.stateEngineCompiledDefinitions = undefined;
|
|
12630
|
-
this.stateEngineStateProxyModeKey = undefined;
|
|
12631
11480
|
this.sharedStateDirty = false;
|
|
12632
11481
|
this.stage = null;
|
|
12633
11482
|
this.layer = null;
|
|
@@ -14616,23 +13465,15 @@ class Glyph extends Graphic {
|
|
|
14616
13465
|
states = states.sort(this.stateSort);
|
|
14617
13466
|
}
|
|
14618
13467
|
const stateAttrs = {};
|
|
14619
|
-
const subAttrs = this.subGraphic.map(() => ({}));
|
|
14620
13468
|
states.forEach(stateName => {
|
|
14621
|
-
var _a;
|
|
14622
13469
|
const attrs = this.glyphStateProxy ? this.glyphStateProxy(stateName, states) : this.glyphStates[stateName];
|
|
14623
13470
|
if (attrs) {
|
|
14624
13471
|
Object.assign(stateAttrs, attrs.attributes);
|
|
14625
|
-
if ((_a = attrs.subAttributes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
14626
|
-
subAttrs.forEach((subAttrs, index) => {
|
|
14627
|
-
Object.assign(subAttrs, attrs.subAttributes[index]);
|
|
14628
|
-
});
|
|
14629
|
-
}
|
|
14630
13472
|
}
|
|
14631
13473
|
});
|
|
14632
13474
|
if (!this.beforeStateUpdate(stateAttrs, previousStates, states, hasAnimation, false)) {
|
|
14633
13475
|
return;
|
|
14634
13476
|
}
|
|
14635
|
-
this.updateNormalAttrs(stateAttrs);
|
|
14636
13477
|
this.currentStates = states;
|
|
14637
13478
|
this.applyStateAttrs(stateAttrs, states, hasAnimation);
|
|
14638
13479
|
}
|
|
@@ -14649,7 +13490,6 @@ class Glyph extends Graphic {
|
|
|
14649
13490
|
else {
|
|
14650
13491
|
this.currentStates = [];
|
|
14651
13492
|
}
|
|
14652
|
-
this.normalAttrs = null;
|
|
14653
13493
|
}
|
|
14654
13494
|
clone() {
|
|
14655
13495
|
const glyph = new Glyph(Object.assign({}, this.attribute));
|
|
@@ -17091,7 +15931,6 @@ class Group extends Graphic {
|
|
|
17091
15931
|
this.type = 'group';
|
|
17092
15932
|
this.parent = null;
|
|
17093
15933
|
this.isContainer = true;
|
|
17094
|
-
this._hasSharedStateDefinitions = false;
|
|
17095
15934
|
this.numberType = GROUP_NUMBER_TYPE;
|
|
17096
15935
|
this._childUpdateTag = UpdateTag.UPDATE_BOUNDS;
|
|
17097
15936
|
}
|
|
@@ -17104,7 +15943,6 @@ class Group extends Graphic {
|
|
|
17104
15943
|
}
|
|
17105
15944
|
const previousScope = this.sharedStateScope;
|
|
17106
15945
|
this._sharedStateDefinitions = value;
|
|
17107
|
-
this._hasSharedStateDefinitions = !!value && Object.keys(value).length > 0;
|
|
17108
15946
|
this.ensureSharedStateScopeBound();
|
|
17109
15947
|
if (this.sharedStateScope) {
|
|
17110
15948
|
setSharedStateScopeLocalDefinitions(this.sharedStateScope, value);
|
|
@@ -17249,13 +16087,7 @@ class Group extends Graphic {
|
|
|
17249
16087
|
incrementalAppendChild(node) {
|
|
17250
16088
|
const data = super.appendChild(node);
|
|
17251
16089
|
if (data) {
|
|
17252
|
-
|
|
17253
|
-
(data.stage !== this.stage || data.layer !== this.layer)) {
|
|
17254
|
-
data.setStage(this.stage, this.layer);
|
|
17255
|
-
}
|
|
17256
|
-
else if (data.onParentSharedStateTreeChanged) {
|
|
17257
|
-
data.onParentSharedStateTreeChanged(this.stage, this.layer);
|
|
17258
|
-
}
|
|
16090
|
+
this.syncChildSharedStateTreeBinding(data);
|
|
17259
16091
|
}
|
|
17260
16092
|
this.addUpdateBoundTag();
|
|
17261
16093
|
this.getGraphicService().onAddIncremental(node, this, this.stage);
|
|
@@ -17269,12 +16101,7 @@ class Group extends Graphic {
|
|
|
17269
16101
|
}
|
|
17270
16102
|
_updateChildToStage(child) {
|
|
17271
16103
|
if (child) {
|
|
17272
|
-
|
|
17273
|
-
child.setStage(this.stage, this.layer);
|
|
17274
|
-
}
|
|
17275
|
-
else if (child.onParentSharedStateTreeChanged) {
|
|
17276
|
-
child.onParentSharedStateTreeChanged(this.stage, this.layer);
|
|
17277
|
-
}
|
|
16104
|
+
this.syncChildSharedStateTreeBinding(child);
|
|
17278
16105
|
}
|
|
17279
16106
|
this.addUpdateBoundTag();
|
|
17280
16107
|
return child;
|
|
@@ -17282,13 +16109,8 @@ class Group extends Graphic {
|
|
|
17282
16109
|
appendChild(node, addStage = true) {
|
|
17283
16110
|
const data = super.appendChild(node);
|
|
17284
16111
|
if (data) {
|
|
17285
|
-
if (addStage
|
|
17286
|
-
this.
|
|
17287
|
-
(data.stage !== this.stage || data.layer !== this.layer)) {
|
|
17288
|
-
data.setStage(this.stage, this.layer);
|
|
17289
|
-
}
|
|
17290
|
-
else if (data.onParentSharedStateTreeChanged) {
|
|
17291
|
-
data.onParentSharedStateTreeChanged(this.stage, this.layer);
|
|
16112
|
+
if (addStage) {
|
|
16113
|
+
this.syncChildSharedStateTreeBinding(data);
|
|
17292
16114
|
}
|
|
17293
16115
|
}
|
|
17294
16116
|
this.addUpdateBoundTag();
|
|
@@ -17304,13 +16126,12 @@ class Group extends Graphic {
|
|
|
17304
16126
|
return this._updateChildToStage(super.insertInto(newNode, idx));
|
|
17305
16127
|
}
|
|
17306
16128
|
removeChild(child, highPerformance = false) {
|
|
17307
|
-
var _a;
|
|
17308
16129
|
const data = super.removeChild(child);
|
|
17309
16130
|
if (!data) {
|
|
17310
16131
|
return data;
|
|
17311
16132
|
}
|
|
17312
16133
|
if (highPerformance) {
|
|
17313
|
-
|
|
16134
|
+
child.detachStageForRelease();
|
|
17314
16135
|
return data;
|
|
17315
16136
|
}
|
|
17316
16137
|
this.getGraphicService().onRemove(child);
|
|
@@ -17335,7 +16156,7 @@ class Group extends Graphic {
|
|
|
17335
16156
|
setStage(stage, layer) {
|
|
17336
16157
|
var _a, _b, _c, _d, _e, _f;
|
|
17337
16158
|
const graphicService = (_c = (_a = stage === null || stage === void 0 ? void 0 : stage.graphicService) !== null && _a !== void 0 ? _a : (_b = this.stage) === null || _b === void 0 ? void 0 : _b.graphicService) !== null && _c !== void 0 ? _c : application.graphicService;
|
|
17338
|
-
const needsSharedStateTreeSync = this.
|
|
16159
|
+
const needsSharedStateTreeSync = this.hasSharedStateDefinitions() ||
|
|
17339
16160
|
this.sharedStateScope ||
|
|
17340
16161
|
((_d = this.currentStates) === null || _d === void 0 ? void 0 : _d.length) ||
|
|
17341
16162
|
this.boundSharedStateScope ||
|
|
@@ -17351,9 +16172,7 @@ class Group extends Graphic {
|
|
|
17351
16172
|
this.setStageToShadowRoot(stage, layer);
|
|
17352
16173
|
this._onSetStage && this._onSetStage(this, stage, layer);
|
|
17353
16174
|
(_f = graphicService === null || graphicService === void 0 ? void 0 : graphicService.onSetStage) === null || _f === void 0 ? void 0 : _f.call(graphicService, this, stage);
|
|
17354
|
-
this.
|
|
17355
|
-
item.setStage(stage, this.layer);
|
|
17356
|
-
});
|
|
16175
|
+
this.notifyChildrenSharedStateTreeChanged();
|
|
17357
16176
|
return;
|
|
17358
16177
|
}
|
|
17359
16178
|
const layerChanged = this.layer !== layer;
|
|
@@ -17366,11 +16185,7 @@ class Group extends Graphic {
|
|
|
17366
16185
|
this.notifyChildrenSharedStateTreeChanged();
|
|
17367
16186
|
}
|
|
17368
16187
|
else if (layerChanged) {
|
|
17369
|
-
this.
|
|
17370
|
-
if (item.onParentSharedStateTreeChanged) {
|
|
17371
|
-
item.onParentSharedStateTreeChanged(stage, this.layer);
|
|
17372
|
-
}
|
|
17373
|
-
});
|
|
16188
|
+
this.notifyChildrenSharedStateTreeChanged();
|
|
17374
16189
|
}
|
|
17375
16190
|
}
|
|
17376
16191
|
addUpdatePositionTag() {
|
|
@@ -17442,8 +16257,7 @@ class Group extends Graphic {
|
|
|
17442
16257
|
super.detachStageForRelease();
|
|
17443
16258
|
this.sharedStateScope = undefined;
|
|
17444
16259
|
this.forEachChildren((item) => {
|
|
17445
|
-
|
|
17446
|
-
(_a = item.detachStageForRelease) === null || _a === void 0 ? void 0 : _a.call(item);
|
|
16260
|
+
item.detachStageForRelease();
|
|
17447
16261
|
});
|
|
17448
16262
|
}
|
|
17449
16263
|
ensureSharedStateScopeBound() {
|
|
@@ -17457,7 +16271,6 @@ class Group extends Graphic {
|
|
|
17457
16271
|
this.sharedStateScope = createGroupSharedStateScope(this, parentScope, this._sharedStateDefinitions);
|
|
17458
16272
|
return;
|
|
17459
16273
|
}
|
|
17460
|
-
this.sharedStateScope.ownerGroup = this;
|
|
17461
16274
|
this.sharedStateScope.ownerStage = this.stage;
|
|
17462
16275
|
setSharedStateScopeParent(this.sharedStateScope, parentScope);
|
|
17463
16276
|
if (this.sharedStateScope.localStateDefinitions !== this._sharedStateDefinitions) {
|
|
@@ -17465,15 +16278,16 @@ class Group extends Graphic {
|
|
|
17465
16278
|
}
|
|
17466
16279
|
}
|
|
17467
16280
|
hasSharedStateDefinitions() {
|
|
17468
|
-
return this.
|
|
16281
|
+
return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
|
|
17469
16282
|
}
|
|
17470
16283
|
notifyChildrenSharedStateTreeChanged() {
|
|
17471
16284
|
this.forEachChildren(item => {
|
|
17472
|
-
|
|
17473
|
-
item.onParentSharedStateTreeChanged(this.stage, this.layer);
|
|
17474
|
-
}
|
|
16285
|
+
this.syncChildSharedStateTreeBinding(item);
|
|
17475
16286
|
});
|
|
17476
16287
|
}
|
|
16288
|
+
syncChildSharedStateTreeBinding(child) {
|
|
16289
|
+
child.onParentSharedStateTreeChanged(this.stage, this.layer);
|
|
16290
|
+
}
|
|
17477
16291
|
onParentSharedStateTreeChanged(stage, layer) {
|
|
17478
16292
|
var _a;
|
|
17479
16293
|
if (this.stage !== stage || this.layer !== layer) {
|
|
@@ -17974,15 +16788,6 @@ class DefaultGraphicService {
|
|
|
17974
16788
|
this.hooks.clearAABBBounds.call(graphic, stage, b);
|
|
17975
16789
|
}
|
|
17976
16790
|
}
|
|
17977
|
-
updatePathProxyAABBBounds(aabbBounds, graphic) {
|
|
17978
|
-
const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
17979
|
-
if (!path) {
|
|
17980
|
-
return false;
|
|
17981
|
-
}
|
|
17982
|
-
const boundsContext = new BoundsContext(aabbBounds);
|
|
17983
|
-
renderCommandList(path.commandList, boundsContext, 0, 0);
|
|
17984
|
-
return true;
|
|
17985
|
-
}
|
|
17986
16791
|
updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
|
|
17987
16792
|
const { textAlign, textBaseline } = attribute;
|
|
17988
16793
|
if (attribute.forceBoundsHeight != null) {
|
|
@@ -19574,11 +18379,6 @@ class RendererRegistry {
|
|
|
19574
18379
|
this.entries.set(key, renderer);
|
|
19575
18380
|
this.cache.delete(key);
|
|
19576
18381
|
}
|
|
19577
|
-
registerMany(entries) {
|
|
19578
|
-
for (const [key, renderer] of entries) {
|
|
19579
|
-
this.register(key, renderer);
|
|
19580
|
-
}
|
|
19581
|
-
}
|
|
19582
18382
|
get(key) {
|
|
19583
18383
|
if (this.cache.has(key)) {
|
|
19584
18384
|
return this.cache.get(key);
|
|
@@ -19609,11 +18409,6 @@ class PickerRegistry {
|
|
|
19609
18409
|
register(key, picker) {
|
|
19610
18410
|
this.entries.set(key, picker);
|
|
19611
18411
|
}
|
|
19612
|
-
registerMany(entries) {
|
|
19613
|
-
for (const [key, picker] of entries) {
|
|
19614
|
-
this.register(key, picker);
|
|
19615
|
-
}
|
|
19616
|
-
}
|
|
19617
18412
|
get(key) {
|
|
19618
18413
|
return this.entries.get(key);
|
|
19619
18414
|
}
|
|
@@ -19656,11 +18451,6 @@ class ContributionRegistry {
|
|
|
19656
18451
|
current.push(contribution);
|
|
19657
18452
|
this.entries.set(key, current);
|
|
19658
18453
|
}
|
|
19659
|
-
registerMany(entries) {
|
|
19660
|
-
for (const [key, contribution] of entries) {
|
|
19661
|
-
this.register(key, contribution);
|
|
19662
|
-
}
|
|
19663
|
-
}
|
|
19664
18454
|
get(key) {
|
|
19665
18455
|
var _a;
|
|
19666
18456
|
return [...((_a = this.entries.get(key)) !== null && _a !== void 0 ? _a : [])];
|
|
@@ -19685,13 +18475,12 @@ const EMPTY_AUTO_ENABLE_PROVIDER = {
|
|
|
19685
18475
|
};
|
|
19686
18476
|
class DefaultPluginService {
|
|
19687
18477
|
constructor(autoEnablePlugins = EMPTY_AUTO_ENABLE_PROVIDER, deps = {}) {
|
|
19688
|
-
var _a
|
|
18478
|
+
var _a;
|
|
19689
18479
|
this.autoEnablePlugins = autoEnablePlugins;
|
|
19690
18480
|
this.onStartupFinishedPlugin = [];
|
|
19691
18481
|
this.onRegisterPlugin = [];
|
|
19692
18482
|
this.actived = false;
|
|
19693
18483
|
this.pluginRegistry = (_a = deps.pluginRegistry) !== null && _a !== void 0 ? _a : new PluginRegistry();
|
|
19694
|
-
this.autoEnablePlugins = (_c = (_b = deps.autoEnablePlugins) !== null && _b !== void 0 ? _b : this.autoEnablePlugins) !== null && _c !== void 0 ? _c : EMPTY_AUTO_ENABLE_PROVIDER;
|
|
19695
18484
|
}
|
|
19696
18485
|
active(stage, params) {
|
|
19697
18486
|
this.stage = stage;
|
|
@@ -19963,7 +18752,7 @@ class DirtyBoundsPlugin {
|
|
|
19963
18752
|
this.key = this.name + this._uid;
|
|
19964
18753
|
this.dirtyBoundsHooksRegistered = false;
|
|
19965
18754
|
this.handlePaintOnlyUpdate = (graphic) => {
|
|
19966
|
-
var _a
|
|
18755
|
+
var _a;
|
|
19967
18756
|
const stage = this.pluginService.stage;
|
|
19968
18757
|
if (!(stage && stage === graphic.stage && stage.renderCount)) {
|
|
19969
18758
|
return;
|
|
@@ -19976,7 +18765,7 @@ class DirtyBoundsPlugin {
|
|
|
19976
18765
|
if (ownerBounds && !ownerBounds.empty()) {
|
|
19977
18766
|
stage.dirty(ownerBounds);
|
|
19978
18767
|
}
|
|
19979
|
-
|
|
18768
|
+
owner.clearUpdatePaintTag();
|
|
19980
18769
|
const shadowRoot = owner.shadowRoot;
|
|
19981
18770
|
if (!shadowRoot) {
|
|
19982
18771
|
return;
|
|
@@ -19985,29 +18774,25 @@ class DirtyBoundsPlugin {
|
|
|
19985
18774
|
if (shadowBounds && !shadowBounds.empty()) {
|
|
19986
18775
|
stage.dirty(shadowBounds);
|
|
19987
18776
|
}
|
|
19988
|
-
|
|
18777
|
+
shadowRoot.clearUpdatePaintTag();
|
|
19989
18778
|
};
|
|
19990
18779
|
}
|
|
19991
18780
|
ensurePaintDirtyBoundsCache(graphic) {
|
|
19992
|
-
var _a
|
|
18781
|
+
var _a;
|
|
19993
18782
|
const owner = graphic;
|
|
19994
|
-
|
|
19995
|
-
if (!hasLocalBounds && typeof owner.doUpdateAABBBounds === 'function') {
|
|
18783
|
+
if (owner._AABBBounds.empty()) {
|
|
19996
18784
|
owner.doUpdateAABBBounds(((_a = owner.attribute) === null || _a === void 0 ? void 0 : _a.boundsMode) === 'imprecise');
|
|
19997
18785
|
}
|
|
19998
|
-
|
|
19999
|
-
typeof owner._globalAABBBounds.empty === 'function' &&
|
|
20000
|
-
!owner._globalAABBBounds.empty();
|
|
20001
|
-
if (!hasGlobalBounds && typeof owner.tryUpdateGlobalAABBBounds === 'function') {
|
|
18786
|
+
if (!owner._globalAABBBounds || owner._globalAABBBounds.empty()) {
|
|
20002
18787
|
owner.tryUpdateGlobalAABBBounds();
|
|
20003
18788
|
}
|
|
20004
|
-
return
|
|
18789
|
+
return owner._globalAABBBounds;
|
|
20005
18790
|
}
|
|
20006
18791
|
getRemoveDirtyBounds(graphic) {
|
|
20007
18792
|
var _a;
|
|
20008
18793
|
const owner = ((_a = graphic.glyphHost) !== null && _a !== void 0 ? _a : graphic);
|
|
20009
18794
|
const cachedBounds = owner._globalAABBBounds;
|
|
20010
|
-
if (cachedBounds &&
|
|
18795
|
+
if (cachedBounds && !cachedBounds.empty()) {
|
|
20011
18796
|
return cachedBounds;
|
|
20012
18797
|
}
|
|
20013
18798
|
}
|
|
@@ -20107,422 +18892,41 @@ class DirtyBoundsPlugin {
|
|
|
20107
18892
|
}
|
|
20108
18893
|
|
|
20109
18894
|
let _isBrowserEnv;
|
|
20110
|
-
function initIsBrowserEnv() {
|
|
20111
|
-
if (_isBrowserEnv != null) {
|
|
20112
|
-
return;
|
|
20113
|
-
}
|
|
20114
|
-
try {
|
|
20115
|
-
const canvas = document.createElement('canvas');
|
|
20116
|
-
const ctx = canvas.getContext('2d');
|
|
20117
|
-
_isBrowserEnv = !!(window &&
|
|
20118
|
-
!!canvas.getBoundingClientRect &&
|
|
20119
|
-
!!requestAnimationFrame &&
|
|
20120
|
-
!!window.devicePixelRatio &&
|
|
20121
|
-
ctx &&
|
|
20122
|
-
!!ctx.isPointInPath &&
|
|
20123
|
-
!!ctx.isPointInStroke);
|
|
20124
|
-
if (_isBrowserEnv) {
|
|
20125
|
-
_isBrowserEnv = !!document.createElement;
|
|
20126
|
-
}
|
|
20127
|
-
}
|
|
20128
|
-
catch (err) {
|
|
20129
|
-
_isBrowserEnv = false;
|
|
20130
|
-
}
|
|
20131
|
-
}
|
|
20132
|
-
function isBrowserEnv() {
|
|
20133
|
-
initIsBrowserEnv();
|
|
20134
|
-
const env = application.global && application.global.env;
|
|
20135
|
-
return env ? env === 'browser' : _isBrowserEnv;
|
|
20136
|
-
}
|
|
20137
|
-
function isNodeEnv() {
|
|
20138
|
-
initIsBrowserEnv();
|
|
20139
|
-
const env = application.global && application.global.env;
|
|
20140
|
-
return env ? env === 'node' : !_isBrowserEnv;
|
|
20141
|
-
}
|
|
20142
|
-
function getCurrentEnv() {
|
|
20143
|
-
return isBrowserEnv() ? 'browser' : 'node';
|
|
20144
|
-
}
|
|
20145
|
-
|
|
20146
|
-
function isRenderableGraphic(graphic) {
|
|
20147
|
-
return !!graphic.stage && graphic.releaseStatus !== 'released';
|
|
20148
|
-
}
|
|
20149
|
-
function createTargetStatesKey(targetStates) {
|
|
20150
|
-
return targetStates.length ? targetStates.join('|') : '__clear__';
|
|
20151
|
-
}
|
|
20152
|
-
function createIntentKey(contextOwnerId, configFingerprint, targetStatesKey) {
|
|
20153
|
-
return `${contextOwnerId}:${configFingerprint}:${targetStatesKey}`;
|
|
20154
|
-
}
|
|
20155
|
-
function hasMeaningfulDeferredConfig(config) {
|
|
20156
|
-
const normalized = normalizeDeferredStateOwnerConfig(config);
|
|
20157
|
-
return !!normalized && (normalized.localEnabled != null || normalized.deferred != null);
|
|
20158
|
-
}
|
|
20159
|
-
function getGraphicCompiledDefinitions(graphic) {
|
|
20160
|
-
const graphicAny = graphic;
|
|
20161
|
-
if (typeof graphicAny.resolveEffectiveCompiledDefinitions === 'function') {
|
|
20162
|
-
const result = graphicAny.resolveEffectiveCompiledDefinitions();
|
|
20163
|
-
return {
|
|
20164
|
-
compiledDefinitions: result.compiledDefinitions,
|
|
20165
|
-
stateProxyEligibility: result.stateProxyEligibility
|
|
20166
|
-
};
|
|
20167
|
-
}
|
|
20168
|
-
return {};
|
|
20169
|
-
}
|
|
20170
|
-
function getCurrentStateNames(graphic) {
|
|
20171
|
-
var _a, _b;
|
|
20172
|
-
return (_b = (_a = graphic.currentStates) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
|
|
20173
|
-
}
|
|
20174
|
-
class StateBatchScheduler {
|
|
20175
|
-
constructor(stage, perfMonitor) {
|
|
20176
|
-
this.stage = stage;
|
|
20177
|
-
this.perfMonitor = perfMonitor;
|
|
20178
|
-
this.jobsByIntentKey = new Map();
|
|
20179
|
-
this.pendingIntentByGraphic = new Map();
|
|
20180
|
-
this.nextJobId = 1;
|
|
20181
|
-
this.runningJobs = new Map();
|
|
20182
|
-
}
|
|
20183
|
-
schedule(graphics, targetStates) {
|
|
20184
|
-
const batchOperation = graphics.length > 1;
|
|
20185
|
-
graphics.forEach(graphic => {
|
|
20186
|
-
const eligibility = this.resolveEligibility(graphic, targetStates, batchOperation, true);
|
|
20187
|
-
if ('reason' in eligibility) {
|
|
20188
|
-
this.removeGraphicFromPending(graphic);
|
|
20189
|
-
if (eligibility.reason !== 'graphic_unavailable') {
|
|
20190
|
-
this.commitSynchronously(graphic, targetStates);
|
|
20191
|
-
}
|
|
20192
|
-
return;
|
|
20193
|
-
}
|
|
20194
|
-
this.enqueueDeferredIntent(graphic, targetStates, eligibility.context, eligibility.targetStatesKey);
|
|
20195
|
-
});
|
|
20196
|
-
}
|
|
20197
|
-
release() {
|
|
20198
|
-
var _a;
|
|
20199
|
-
this.jobsByIntentKey.forEach(job => {
|
|
20200
|
-
job.status = 'cancelled';
|
|
20201
|
-
});
|
|
20202
|
-
this.jobsByIntentKey.clear();
|
|
20203
|
-
this.pendingIntentByGraphic.clear();
|
|
20204
|
-
this.runningJobs.clear();
|
|
20205
|
-
(_a = this.perfMonitor) === null || _a === void 0 ? void 0 : _a.updateBatchPending(0);
|
|
20206
|
-
}
|
|
20207
|
-
resolveEligibility(graphic, targetStates, batchOperation, recordObservability) {
|
|
20208
|
-
var _a, _b, _c, _d, _e, _f;
|
|
20209
|
-
if (!isRenderableGraphic(graphic)) {
|
|
20210
|
-
if (recordObservability) {
|
|
20211
|
-
(_a = this.perfMonitor) === null || _a === void 0 ? void 0 : _a.recordDeferredIneligible('graphic_unavailable');
|
|
20212
|
-
}
|
|
20213
|
-
return { eligible: false, reason: 'graphic_unavailable' };
|
|
20214
|
-
}
|
|
20215
|
-
if (!batchOperation) {
|
|
20216
|
-
if (recordObservability) {
|
|
20217
|
-
(_b = this.perfMonitor) === null || _b === void 0 ? void 0 : _b.recordDeferredIneligible('non_batch_operation');
|
|
20218
|
-
}
|
|
20219
|
-
return { eligible: false, reason: 'non_batch_operation' };
|
|
20220
|
-
}
|
|
20221
|
-
const context = this.resolveDeferredContext(graphic);
|
|
20222
|
-
if (!context) {
|
|
20223
|
-
if (recordObservability) {
|
|
20224
|
-
(_c = this.perfMonitor) === null || _c === void 0 ? void 0 : _c.recordDeferredIneligible('graphic_unavailable');
|
|
20225
|
-
}
|
|
20226
|
-
return { eligible: false, reason: 'graphic_unavailable' };
|
|
20227
|
-
}
|
|
20228
|
-
if (!context.config.enabled) {
|
|
20229
|
-
const normalizedOwnerConfig = normalizeDeferredStateOwnerConfig(context.contextOwner.deferredStateConfig);
|
|
20230
|
-
const reason = (normalizedOwnerConfig === null || normalizedOwnerConfig === void 0 ? void 0 : normalizedOwnerConfig.localEnabled) === false ? 'context_disabled' : 'config_disabled';
|
|
20231
|
-
if (recordObservability) {
|
|
20232
|
-
(_d = this.perfMonitor) === null || _d === void 0 ? void 0 : _d.recordDeferredIneligible(reason);
|
|
20233
|
-
}
|
|
20234
|
-
return { eligible: false, reason };
|
|
20235
|
-
}
|
|
20236
|
-
const classification = this.classifyGraphicTargetStates(graphic, targetStates);
|
|
20237
|
-
if (classification.reason) {
|
|
20238
|
-
if (recordObservability) {
|
|
20239
|
-
(_e = this.perfMonitor) === null || _e === void 0 ? void 0 : _e.recordDeferredIneligible(classification.reason);
|
|
20240
|
-
}
|
|
20241
|
-
return { eligible: false, reason: classification.reason };
|
|
20242
|
-
}
|
|
20243
|
-
if (classification.category !== UpdateCategory.PAINT) {
|
|
20244
|
-
if (recordObservability) {
|
|
20245
|
-
(_f = this.perfMonitor) === null || _f === void 0 ? void 0 : _f.recordDeferredIneligible('mixed_update_category');
|
|
20246
|
-
}
|
|
20247
|
-
return { eligible: false, reason: 'mixed_update_category' };
|
|
20248
|
-
}
|
|
20249
|
-
return {
|
|
20250
|
-
eligible: true,
|
|
20251
|
-
context,
|
|
20252
|
-
targetStatesKey: createTargetStatesKey(targetStates)
|
|
20253
|
-
};
|
|
20254
|
-
}
|
|
20255
|
-
resolveDeferredContext(graphic) {
|
|
20256
|
-
var _a;
|
|
20257
|
-
const stage = graphic.stage;
|
|
20258
|
-
if (!stage) {
|
|
20259
|
-
return undefined;
|
|
20260
|
-
}
|
|
20261
|
-
let owner = stage;
|
|
20262
|
-
let config = normalizeDeferredStateConfig(undefined);
|
|
20263
|
-
const ownerConfigs = [stage];
|
|
20264
|
-
const parents = [];
|
|
20265
|
-
let parent = graphic.parent;
|
|
20266
|
-
while (parent && parent !== stage) {
|
|
20267
|
-
parents.push(parent);
|
|
20268
|
-
parent = parent.parent;
|
|
20269
|
-
}
|
|
20270
|
-
parents.reverse().forEach(current => ownerConfigs.push(current));
|
|
20271
|
-
ownerConfigs.forEach(current => {
|
|
20272
|
-
const deferredStateConfig = normalizeDeferredStateOwnerConfig(current.deferredStateConfig);
|
|
20273
|
-
if (!deferredStateConfig) {
|
|
20274
|
-
return;
|
|
20275
|
-
}
|
|
20276
|
-
if (deferredStateConfig.deferred) {
|
|
20277
|
-
config = Object.assign(Object.assign({}, config), deferredStateConfig.deferred);
|
|
20278
|
-
}
|
|
20279
|
-
if (deferredStateConfig.localEnabled != null) {
|
|
20280
|
-
config.enabled = deferredStateConfig.localEnabled;
|
|
20281
|
-
}
|
|
20282
|
-
if (hasMeaningfulDeferredConfig(current.deferredStateConfig)) {
|
|
20283
|
-
owner = current;
|
|
20284
|
-
}
|
|
20285
|
-
});
|
|
20286
|
-
const normalized = normalizeDeferredStateConfig(config);
|
|
20287
|
-
return {
|
|
20288
|
-
contextOwner: owner,
|
|
20289
|
-
contextOwnerId: (_a = owner._uid) !== null && _a !== void 0 ? _a : 0,
|
|
20290
|
-
config: normalized,
|
|
20291
|
-
configFingerprint: fingerprintDeferredStateConfig(normalized)
|
|
20292
|
-
};
|
|
20293
|
-
}
|
|
20294
|
-
classifyGraphicTargetStates(graphic, targetStates) {
|
|
20295
|
-
const { compiledDefinitions, stateProxyEligibility } = getGraphicCompiledDefinitions(graphic);
|
|
20296
|
-
const candidateStates = Array.from(new Set([...getCurrentStateNames(graphic), ...targetStates]));
|
|
20297
|
-
let category = UpdateCategory.NONE;
|
|
20298
|
-
candidateStates.forEach(stateName => {
|
|
20299
|
-
if (stateProxyEligibility === null || stateProxyEligibility === void 0 ? void 0 : stateProxyEligibility(stateName)) {
|
|
20300
|
-
category = UpdateCategory.NONE;
|
|
20301
|
-
return;
|
|
20302
|
-
}
|
|
20303
|
-
const definition = compiledDefinitions === null || compiledDefinitions === void 0 ? void 0 : compiledDefinitions.get(stateName);
|
|
20304
|
-
if (!definition) {
|
|
20305
|
-
return;
|
|
20306
|
-
}
|
|
20307
|
-
if (definition.hasResolver && definition.affectedKeys.size === 0) {
|
|
20308
|
-
category = UpdateCategory.NONE;
|
|
20309
|
-
return;
|
|
20310
|
-
}
|
|
20311
|
-
category |= classifyAffectedKeys(definition.affectedKeys);
|
|
20312
|
-
});
|
|
20313
|
-
if (candidateStates.some(stateName => stateProxyEligibility === null || stateProxyEligibility === void 0 ? void 0 : stateProxyEligibility(stateName)) ||
|
|
20314
|
-
candidateStates.some(stateName => {
|
|
20315
|
-
const definition = compiledDefinitions === null || compiledDefinitions === void 0 ? void 0 : compiledDefinitions.get(stateName);
|
|
20316
|
-
return !!(definition === null || definition === void 0 ? void 0 : definition.hasResolver) && definition.affectedKeys.size === 0;
|
|
20317
|
-
})) {
|
|
20318
|
-
return {
|
|
20319
|
-
category: UpdateCategory.NONE,
|
|
20320
|
-
reason: 'resolver_unstable_keys'
|
|
20321
|
-
};
|
|
20322
|
-
}
|
|
20323
|
-
return {
|
|
20324
|
-
category: category === UpdateCategory.NONE ? UpdateCategory.PAINT : category
|
|
20325
|
-
};
|
|
20326
|
-
}
|
|
20327
|
-
enqueueDeferredIntent(graphic, targetStates, context, targetStatesKey) {
|
|
20328
|
-
var _a, _b, _c, _d, _e, _f;
|
|
20329
|
-
const nextIntentKey = createIntentKey(context.contextOwnerId, context.configFingerprint, targetStatesKey);
|
|
20330
|
-
const prevIntentKey = this.pendingIntentByGraphic.get(graphic);
|
|
20331
|
-
if (prevIntentKey === nextIntentKey) {
|
|
20332
|
-
(_a = this.perfMonitor) === null || _a === void 0 ? void 0 : _a.incrementCounter('deferredJobsCoalesced');
|
|
20333
|
-
return;
|
|
20334
|
-
}
|
|
20335
|
-
if (prevIntentKey) {
|
|
20336
|
-
this.removeGraphicFromIntentJob(graphic, prevIntentKey);
|
|
20337
|
-
}
|
|
20338
|
-
let job = this.jobsByIntentKey.get(nextIntentKey);
|
|
20339
|
-
if (!job) {
|
|
20340
|
-
job = {
|
|
20341
|
-
id: this.nextJobId++,
|
|
20342
|
-
kind: 'apply_states',
|
|
20343
|
-
intentKey: nextIntentKey,
|
|
20344
|
-
status: 'pending',
|
|
20345
|
-
targetStates: [...targetStates],
|
|
20346
|
-
targetStatesKey,
|
|
20347
|
-
pendingGraphics: new Set(),
|
|
20348
|
-
orderedGraphics: [],
|
|
20349
|
-
config: context.config,
|
|
20350
|
-
contextOwner: context.contextOwner,
|
|
20351
|
-
contextOwnerId: context.contextOwnerId,
|
|
20352
|
-
configFingerprint: context.configFingerprint,
|
|
20353
|
-
createdAt: Date.now(),
|
|
20354
|
-
processedCount: 0
|
|
20355
|
-
};
|
|
20356
|
-
this.jobsByIntentKey.set(nextIntentKey, job);
|
|
20357
|
-
(_b = this.perfMonitor) === null || _b === void 0 ? void 0 : _b.incrementCounter('deferredJobsCreated');
|
|
20358
|
-
(_c = this.perfMonitor) === null || _c === void 0 ? void 0 : _c.updateBatchPending(this.jobsByIntentKey.size);
|
|
20359
|
-
}
|
|
20360
|
-
else {
|
|
20361
|
-
(_d = this.perfMonitor) === null || _d === void 0 ? void 0 : _d.incrementCounter('deferredJobsCoalesced');
|
|
20362
|
-
}
|
|
20363
|
-
if (!job.pendingGraphics.has(graphic)) {
|
|
20364
|
-
job.pendingGraphics.add(graphic);
|
|
20365
|
-
job.orderedGraphics.push(graphic);
|
|
20366
|
-
this.pendingIntentByGraphic.set(graphic, nextIntentKey);
|
|
20367
|
-
(_e = this.perfMonitor) === null || _e === void 0 ? void 0 : _e.recordAllocation('batchEntriesCreated');
|
|
20368
|
-
(_f = this.perfMonitor) === null || _f === void 0 ? void 0 : _f.updateMaxGraphicsInJob(job.pendingGraphics.size);
|
|
20369
|
-
}
|
|
20370
|
-
this.ensureJobRunning(job);
|
|
20371
|
-
}
|
|
20372
|
-
removeGraphicFromPending(graphic) {
|
|
20373
|
-
const prevIntentKey = this.pendingIntentByGraphic.get(graphic);
|
|
20374
|
-
if (!prevIntentKey) {
|
|
20375
|
-
return;
|
|
20376
|
-
}
|
|
20377
|
-
this.removeGraphicFromIntentJob(graphic, prevIntentKey);
|
|
20378
|
-
}
|
|
20379
|
-
removeGraphicFromIntentJob(graphic, intentKey) {
|
|
20380
|
-
var _a, _b, _c;
|
|
20381
|
-
const job = this.jobsByIntentKey.get(intentKey);
|
|
20382
|
-
if (!job) {
|
|
20383
|
-
this.pendingIntentByGraphic.delete(graphic);
|
|
20384
|
-
return;
|
|
20385
|
-
}
|
|
20386
|
-
job.pendingGraphics.delete(graphic);
|
|
20387
|
-
if (this.pendingIntentByGraphic.get(graphic) === intentKey) {
|
|
20388
|
-
this.pendingIntentByGraphic.delete(graphic);
|
|
20389
|
-
}
|
|
20390
|
-
if (job.pendingGraphics.size === 0 && job.status !== 'completed') {
|
|
20391
|
-
job.status = 'cancelled';
|
|
20392
|
-
this.jobsByIntentKey.delete(intentKey);
|
|
20393
|
-
(_a = this.perfMonitor) === null || _a === void 0 ? void 0 : _a.incrementCounter('deferredJobsCancelled');
|
|
20394
|
-
(_b = this.perfMonitor) === null || _b === void 0 ? void 0 : _b.recordEvent('deferred-job-cancel', {
|
|
20395
|
-
intentKey,
|
|
20396
|
-
jobId: job.id
|
|
20397
|
-
});
|
|
20398
|
-
(_c = this.perfMonitor) === null || _c === void 0 ? void 0 : _c.updateBatchPending(this.jobsByIntentKey.size);
|
|
20399
|
-
}
|
|
20400
|
-
}
|
|
20401
|
-
ensureJobRunning(job) {
|
|
20402
|
-
if (this.runningJobs.has(job.intentKey)) {
|
|
20403
|
-
return;
|
|
20404
|
-
}
|
|
20405
|
-
const runner = this.runJob(job).then(() => {
|
|
20406
|
-
this.runningJobs.delete(job.intentKey);
|
|
20407
|
-
}, () => {
|
|
20408
|
-
this.runningJobs.delete(job.intentKey);
|
|
20409
|
-
});
|
|
20410
|
-
this.runningJobs.set(job.intentKey, runner);
|
|
20411
|
-
}
|
|
20412
|
-
runJob(job) {
|
|
20413
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
20414
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20415
|
-
if (job.status === 'cancelled') {
|
|
20416
|
-
return;
|
|
20417
|
-
}
|
|
20418
|
-
yield this.waitForNextFrame();
|
|
20419
|
-
if (job.status === 'cancelled') {
|
|
20420
|
-
return;
|
|
20421
|
-
}
|
|
20422
|
-
job.status = 'running';
|
|
20423
|
-
(_a = this.perfMonitor) === null || _a === void 0 ? void 0 : _a.recordEvent('deferred-job-start', {
|
|
20424
|
-
intentKey: job.intentKey,
|
|
20425
|
-
jobId: job.id
|
|
20426
|
-
});
|
|
20427
|
-
let index = 0;
|
|
20428
|
-
let frameStart = performance.now();
|
|
20429
|
-
let processedInFrame = 0;
|
|
20430
|
-
let committedInSlice = 0;
|
|
20431
|
-
while (index < job.orderedGraphics.length) {
|
|
20432
|
-
if (job.status === 'cancelled') {
|
|
20433
|
-
return;
|
|
20434
|
-
}
|
|
20435
|
-
if (processedInFrame > 0 &&
|
|
20436
|
-
(processedInFrame >= job.config.maxGraphicsPerFrame || performance.now() - frameStart >= job.config.frameBudget)) {
|
|
20437
|
-
(_b = this.perfMonitor) === null || _b === void 0 ? void 0 : _b.incrementCounter('deferredBudgetYields');
|
|
20438
|
-
(_c = this.perfMonitor) === null || _c === void 0 ? void 0 : _c.recordCost('batchSlice', performance.now() - frameStart);
|
|
20439
|
-
(_d = this.perfMonitor) === null || _d === void 0 ? void 0 : _d.recordEvent('deferred-job-yield', {
|
|
20440
|
-
intentKey: job.intentKey,
|
|
20441
|
-
jobId: job.id,
|
|
20442
|
-
processedInFrame
|
|
20443
|
-
});
|
|
20444
|
-
if (committedInSlice > 0) {
|
|
20445
|
-
this.stage.renderNextFrame();
|
|
20446
|
-
}
|
|
20447
|
-
yield this.waitForNextFrame();
|
|
20448
|
-
frameStart = performance.now();
|
|
20449
|
-
processedInFrame = 0;
|
|
20450
|
-
committedInSlice = 0;
|
|
20451
|
-
}
|
|
20452
|
-
const graphic = job.orderedGraphics[index++];
|
|
20453
|
-
if (!job.pendingGraphics.has(graphic)) {
|
|
20454
|
-
continue;
|
|
20455
|
-
}
|
|
20456
|
-
if (!isRenderableGraphic(graphic)) {
|
|
20457
|
-
job.pendingGraphics.delete(graphic);
|
|
20458
|
-
if (this.pendingIntentByGraphic.get(graphic) === job.intentKey) {
|
|
20459
|
-
this.pendingIntentByGraphic.delete(graphic);
|
|
20460
|
-
}
|
|
20461
|
-
continue;
|
|
20462
|
-
}
|
|
20463
|
-
if (this.pendingIntentByGraphic.get(graphic) !== job.intentKey) {
|
|
20464
|
-
job.pendingGraphics.delete(graphic);
|
|
20465
|
-
continue;
|
|
20466
|
-
}
|
|
20467
|
-
const nextEligibility = this.resolveEligibility(graphic, job.targetStates, true, false);
|
|
20468
|
-
if (!nextEligibility.eligible) {
|
|
20469
|
-
job.pendingGraphics.delete(graphic);
|
|
20470
|
-
this.pendingIntentByGraphic.delete(graphic);
|
|
20471
|
-
this.commitSynchronously(graphic, job.targetStates);
|
|
20472
|
-
continue;
|
|
20473
|
-
}
|
|
20474
|
-
const nextIntentKey = createIntentKey(nextEligibility.context.contextOwnerId, nextEligibility.context.configFingerprint, nextEligibility.targetStatesKey);
|
|
20475
|
-
if (nextIntentKey !== job.intentKey) {
|
|
20476
|
-
job.pendingGraphics.delete(graphic);
|
|
20477
|
-
this.pendingIntentByGraphic.delete(graphic);
|
|
20478
|
-
this.enqueueDeferredIntent(graphic, job.targetStates, nextEligibility.context, nextEligibility.targetStatesKey);
|
|
20479
|
-
continue;
|
|
20480
|
-
}
|
|
20481
|
-
this.commitSynchronously(graphic, job.targetStates);
|
|
20482
|
-
job.pendingGraphics.delete(graphic);
|
|
20483
|
-
this.pendingIntentByGraphic.delete(graphic);
|
|
20484
|
-
job.processedCount += 1;
|
|
20485
|
-
processedInFrame += 1;
|
|
20486
|
-
committedInSlice += 1;
|
|
20487
|
-
(_e = this.perfMonitor) === null || _e === void 0 ? void 0 : _e.incrementCounter('deferredGraphicsCommitted');
|
|
20488
|
-
}
|
|
20489
|
-
if (processedInFrame > 0) {
|
|
20490
|
-
(_f = this.perfMonitor) === null || _f === void 0 ? void 0 : _f.recordCost('batchSlice', performance.now() - frameStart);
|
|
20491
|
-
this.stage.renderNextFrame();
|
|
20492
|
-
}
|
|
20493
|
-
if (job.pendingGraphics.size === 0 && this.jobsByIntentKey.get(job.intentKey) === job) {
|
|
20494
|
-
job.status = 'completed';
|
|
20495
|
-
this.jobsByIntentKey.delete(job.intentKey);
|
|
20496
|
-
(_g = this.perfMonitor) === null || _g === void 0 ? void 0 : _g.incrementCounter('deferredJobsCompleted');
|
|
20497
|
-
(_h = this.perfMonitor) === null || _h === void 0 ? void 0 : _h.recordEvent('deferred-job-complete', {
|
|
20498
|
-
intentKey: job.intentKey,
|
|
20499
|
-
jobId: job.id,
|
|
20500
|
-
processedCount: job.processedCount
|
|
20501
|
-
});
|
|
20502
|
-
(_j = this.perfMonitor) === null || _j === void 0 ? void 0 : _j.updateBatchPending(this.jobsByIntentKey.size);
|
|
20503
|
-
}
|
|
20504
|
-
});
|
|
18895
|
+
function initIsBrowserEnv() {
|
|
18896
|
+
if (_isBrowserEnv != null) {
|
|
18897
|
+
return;
|
|
20505
18898
|
}
|
|
20506
|
-
|
|
20507
|
-
const
|
|
20508
|
-
|
|
20509
|
-
|
|
18899
|
+
try {
|
|
18900
|
+
const canvas = document.createElement('canvas');
|
|
18901
|
+
const ctx = canvas.getContext('2d');
|
|
18902
|
+
_isBrowserEnv = !!(window &&
|
|
18903
|
+
!!canvas.getBoundingClientRect &&
|
|
18904
|
+
!!requestAnimationFrame &&
|
|
18905
|
+
!!window.devicePixelRatio &&
|
|
18906
|
+
ctx &&
|
|
18907
|
+
!!ctx.isPointInPath &&
|
|
18908
|
+
!!ctx.isPointInStroke);
|
|
18909
|
+
if (_isBrowserEnv) {
|
|
18910
|
+
_isBrowserEnv = !!document.createElement;
|
|
20510
18911
|
}
|
|
20511
|
-
return new Promise(resolve => {
|
|
20512
|
-
stageGlobal === null || stageGlobal === void 0 ? void 0 : stageGlobal.getSpecifiedRequestAnimationFrame(this.stage.rafId)(() => resolve());
|
|
20513
|
-
});
|
|
20514
18912
|
}
|
|
20515
|
-
|
|
20516
|
-
|
|
20517
|
-
return;
|
|
20518
|
-
}
|
|
20519
|
-
if (!targetStates.length) {
|
|
20520
|
-
graphic.clearStates(false);
|
|
20521
|
-
return;
|
|
20522
|
-
}
|
|
20523
|
-
graphic.useStates(targetStates, false);
|
|
18913
|
+
catch (err) {
|
|
18914
|
+
_isBrowserEnv = false;
|
|
20524
18915
|
}
|
|
20525
18916
|
}
|
|
18917
|
+
function isBrowserEnv() {
|
|
18918
|
+
initIsBrowserEnv();
|
|
18919
|
+
const env = application.global && application.global.env;
|
|
18920
|
+
return env ? env === 'browser' : _isBrowserEnv;
|
|
18921
|
+
}
|
|
18922
|
+
function isNodeEnv() {
|
|
18923
|
+
initIsBrowserEnv();
|
|
18924
|
+
const env = application.global && application.global.env;
|
|
18925
|
+
return env ? env === 'node' : !_isBrowserEnv;
|
|
18926
|
+
}
|
|
18927
|
+
function getCurrentEnv() {
|
|
18928
|
+
return isBrowserEnv() ? 'browser' : 'node';
|
|
18929
|
+
}
|
|
20526
18930
|
|
|
20527
18931
|
const DefaultConfig = {
|
|
20528
18932
|
WIDTH: 500,
|
|
@@ -20704,14 +19108,12 @@ class Stage extends Group {
|
|
|
20704
19108
|
this.theme.onStateDefinitionsChange = () => {
|
|
20705
19109
|
var _a;
|
|
20706
19110
|
const definitions = (_a = this.theme) === null || _a === void 0 ? void 0 : _a.stateDefinitions;
|
|
20707
|
-
|
|
20708
|
-
|
|
20709
|
-
|
|
20710
|
-
|
|
20711
|
-
}
|
|
19111
|
+
const rootScope = definitions && Object.keys(definitions).length
|
|
19112
|
+
? this.ensureRootSharedStateScope(definitions)
|
|
19113
|
+
: this.rootSharedStateScope;
|
|
19114
|
+
if (!rootScope) {
|
|
20712
19115
|
return;
|
|
20713
19116
|
}
|
|
20714
|
-
const rootScope = this.ensureRootSharedStateScope(definitions);
|
|
20715
19117
|
setRootSharedStateScopeThemeDefinitions(rootScope, definitions);
|
|
20716
19118
|
markScopeActiveDescendantsDirty(rootScope, this);
|
|
20717
19119
|
};
|
|
@@ -21143,21 +19545,6 @@ class Stage extends Group {
|
|
|
21143
19545
|
this.rootSharedStateScope.ownerStage = this;
|
|
21144
19546
|
return this.rootSharedStateScope;
|
|
21145
19547
|
}
|
|
21146
|
-
getStateBatchScheduler() {
|
|
21147
|
-
if (!this._stateBatchScheduler) {
|
|
21148
|
-
this._stateBatchScheduler = new StateBatchScheduler(this, ensureStageStatePerfMonitor(this));
|
|
21149
|
-
}
|
|
21150
|
-
return this._stateBatchScheduler;
|
|
21151
|
-
}
|
|
21152
|
-
scheduleStateBatch(graphics, targetStates) {
|
|
21153
|
-
this.getStateBatchScheduler().schedule(graphics, targetStates);
|
|
21154
|
-
}
|
|
21155
|
-
getStatePerfSnapshot() {
|
|
21156
|
-
return ensureStageStatePerfMonitor(this).getSnapshot();
|
|
21157
|
-
}
|
|
21158
|
-
resetStatePerfSnapshot() {
|
|
21159
|
-
ensureStageStatePerfMonitor(this).reset();
|
|
21160
|
-
}
|
|
21161
19548
|
_doRenderInThisFrame() {
|
|
21162
19549
|
if (this.releaseStatus === 'released') {
|
|
21163
19550
|
return;
|
|
@@ -21291,8 +19678,7 @@ class Stage extends Group {
|
|
|
21291
19678
|
throw new Error('暂不支持');
|
|
21292
19679
|
}
|
|
21293
19680
|
release() {
|
|
21294
|
-
var _a, _b, _d
|
|
21295
|
-
(_a = this._stateBatchScheduler) === null || _a === void 0 ? void 0 : _a.release();
|
|
19681
|
+
var _a, _b, _d;
|
|
21296
19682
|
super.release();
|
|
21297
19683
|
this.hooks.beforeRender.unTap('constructor', this.beforeRender);
|
|
21298
19684
|
this.hooks.afterRender.unTap('constructor', this.afterRender);
|
|
@@ -21310,10 +19696,10 @@ class Stage extends Group {
|
|
|
21310
19696
|
this.interactiveLayer.release();
|
|
21311
19697
|
}
|
|
21312
19698
|
this.window.release();
|
|
21313
|
-
(
|
|
21314
|
-
(
|
|
19699
|
+
(_a = this._ticker) === null || _a === void 0 ? void 0 : _a.remTimeline(this === null || this === void 0 ? void 0 : this.timeline);
|
|
19700
|
+
(_b = this._ticker) === null || _b === void 0 ? void 0 : _b.removeListener('tick', this.afterTickCb);
|
|
21315
19701
|
if (!this.params.ticker) {
|
|
21316
|
-
(
|
|
19702
|
+
(_d = this._ticker) === null || _d === void 0 ? void 0 : _d.release();
|
|
21317
19703
|
}
|
|
21318
19704
|
this.renderService.renderTreeRoots = [];
|
|
21319
19705
|
}
|
|
@@ -27609,18 +25995,12 @@ function createBrowserApp(options = {}) {
|
|
|
27609
25995
|
}
|
|
27610
25996
|
|
|
27611
25997
|
class NodeEntry extends BrowserEntry {
|
|
27612
|
-
constructor(options = {}) {
|
|
27613
|
-
super(options);
|
|
27614
|
-
}
|
|
27615
25998
|
}
|
|
27616
25999
|
function createNodeApp(options = {}) {
|
|
27617
26000
|
return new NodeEntry(options);
|
|
27618
26001
|
}
|
|
27619
26002
|
|
|
27620
26003
|
class MiniappEntry extends BrowserEntry {
|
|
27621
|
-
constructor(options = {}) {
|
|
27622
|
-
super(options);
|
|
27623
|
-
}
|
|
27624
26004
|
}
|
|
27625
26005
|
function createMiniappApp(options = {}) {
|
|
27626
26006
|
return new MiniappEntry(options);
|
|
@@ -30038,111 +28418,415 @@ class DefaultCircleAllocate extends DefaultGraphicAllocate {
|
|
|
30038
28418
|
if (!this.pools.length) {
|
|
30039
28419
|
return application.graphicService.creator.circle(area.attribute);
|
|
30040
28420
|
}
|
|
30041
|
-
const g = this.pools.pop();
|
|
30042
|
-
g.initAttributes(area.attribute);
|
|
30043
|
-
return g;
|
|
28421
|
+
const g = this.pools.pop();
|
|
28422
|
+
g.initAttributes(area.attribute);
|
|
28423
|
+
return g;
|
|
28424
|
+
}
|
|
28425
|
+
}
|
|
28426
|
+
const defaultCircleAllocate = new DefaultCircleAllocate();
|
|
28427
|
+
class DefaultLineAllocate extends DefaultGraphicAllocate {
|
|
28428
|
+
allocate(attribute) {
|
|
28429
|
+
if (!this.pools.length) {
|
|
28430
|
+
return application.graphicService.creator.line(attribute);
|
|
28431
|
+
}
|
|
28432
|
+
const g = this.pools.pop();
|
|
28433
|
+
g.initAttributes(attribute);
|
|
28434
|
+
return g;
|
|
28435
|
+
}
|
|
28436
|
+
allocateByObj(line) {
|
|
28437
|
+
if (!this.pools.length) {
|
|
28438
|
+
return application.graphicService.creator.line(line.attribute);
|
|
28439
|
+
}
|
|
28440
|
+
const g = this.pools.pop();
|
|
28441
|
+
g.initAttributes(line.attribute);
|
|
28442
|
+
return g;
|
|
28443
|
+
}
|
|
28444
|
+
}
|
|
28445
|
+
const defaultLineAllocate = new DefaultLineAllocate();
|
|
28446
|
+
class DefaultPathAllocate extends DefaultGraphicAllocate {
|
|
28447
|
+
allocate(attribute) {
|
|
28448
|
+
if (!this.pools.length) {
|
|
28449
|
+
return application.graphicService.creator.path(attribute);
|
|
28450
|
+
}
|
|
28451
|
+
const g = this.pools.pop();
|
|
28452
|
+
g.initAttributes(attribute);
|
|
28453
|
+
return g;
|
|
28454
|
+
}
|
|
28455
|
+
allocateByObj(path) {
|
|
28456
|
+
if (!this.pools.length) {
|
|
28457
|
+
return application.graphicService.creator.path(path.attribute);
|
|
28458
|
+
}
|
|
28459
|
+
const g = this.pools.pop();
|
|
28460
|
+
g.initAttributes(path.attribute);
|
|
28461
|
+
return g;
|
|
28462
|
+
}
|
|
28463
|
+
}
|
|
28464
|
+
const defaultPathAllocate = new DefaultPathAllocate();
|
|
28465
|
+
class DefaultSymbolAllocate extends DefaultGraphicAllocate {
|
|
28466
|
+
allocate(attribute) {
|
|
28467
|
+
if (!this.pools.length) {
|
|
28468
|
+
return application.graphicService.creator.symbol(attribute);
|
|
28469
|
+
}
|
|
28470
|
+
const g = this.pools.pop();
|
|
28471
|
+
g.initAttributes(attribute);
|
|
28472
|
+
return g;
|
|
28473
|
+
}
|
|
28474
|
+
allocateByObj(symbol) {
|
|
28475
|
+
if (!this.pools.length) {
|
|
28476
|
+
return application.graphicService.creator.symbol(symbol.attribute);
|
|
28477
|
+
}
|
|
28478
|
+
const g = this.pools.pop();
|
|
28479
|
+
g.initAttributes(symbol.attribute);
|
|
28480
|
+
return g;
|
|
28481
|
+
}
|
|
28482
|
+
}
|
|
28483
|
+
const defaultSymbolAllocate = new DefaultSymbolAllocate();
|
|
28484
|
+
class DefaultTextAllocate extends DefaultGraphicAllocate {
|
|
28485
|
+
allocate(attribute) {
|
|
28486
|
+
if (!this.pools.length) {
|
|
28487
|
+
return application.graphicService.creator.text(attribute);
|
|
28488
|
+
}
|
|
28489
|
+
const g = this.pools.pop();
|
|
28490
|
+
g.initAttributes(attribute);
|
|
28491
|
+
return g;
|
|
28492
|
+
}
|
|
28493
|
+
allocateByObj(text) {
|
|
28494
|
+
if (!this.pools.length) {
|
|
28495
|
+
return application.graphicService.creator.text(text.attribute);
|
|
28496
|
+
}
|
|
28497
|
+
const g = this.pools.pop();
|
|
28498
|
+
g.initAttributes(text.attribute);
|
|
28499
|
+
return g;
|
|
28500
|
+
}
|
|
28501
|
+
}
|
|
28502
|
+
const defaultTextAllocate = new DefaultTextAllocate();
|
|
28503
|
+
class DefaultGraphicMemoryManager {
|
|
28504
|
+
constructor() {
|
|
28505
|
+
this.map = {
|
|
28506
|
+
text: defaultTextAllocate,
|
|
28507
|
+
symbol: defaultSymbolAllocate
|
|
28508
|
+
};
|
|
28509
|
+
}
|
|
28510
|
+
gc(g) {
|
|
28511
|
+
if (g.isContainer) {
|
|
28512
|
+
g.forEachChildren(i => this.gc(i));
|
|
28513
|
+
}
|
|
28514
|
+
else {
|
|
28515
|
+
this.gcItem(g);
|
|
28516
|
+
}
|
|
28517
|
+
}
|
|
28518
|
+
gcItem(g) {
|
|
28519
|
+
const allocate = this.map[g.type];
|
|
28520
|
+
if (allocate) {
|
|
28521
|
+
allocate.free(g);
|
|
28522
|
+
}
|
|
28523
|
+
}
|
|
28524
|
+
}
|
|
28525
|
+
const defaultGraphicMemoryManager = new DefaultGraphicMemoryManager();
|
|
28526
|
+
|
|
28527
|
+
function getAllMatches(string, regex) {
|
|
28528
|
+
const matches = [];
|
|
28529
|
+
let match = regex.exec(string);
|
|
28530
|
+
while (match) {
|
|
28531
|
+
const allmatches = [];
|
|
28532
|
+
allmatches.startIndex = regex.lastIndex - match[0].length;
|
|
28533
|
+
const len = match.length;
|
|
28534
|
+
for (let index = 0; index < len; index++) {
|
|
28535
|
+
allmatches.push(match[index]);
|
|
28536
|
+
}
|
|
28537
|
+
matches.push(allmatches);
|
|
28538
|
+
match = regex.exec(string);
|
|
28539
|
+
}
|
|
28540
|
+
return matches;
|
|
28541
|
+
}
|
|
28542
|
+
|
|
28543
|
+
class XmlNode {
|
|
28544
|
+
constructor(tagname) {
|
|
28545
|
+
this.tagname = tagname;
|
|
28546
|
+
this.child = [];
|
|
28547
|
+
this[':@'] = {};
|
|
28548
|
+
}
|
|
28549
|
+
add(key, val) {
|
|
28550
|
+
if (key === '__proto__') {
|
|
28551
|
+
key = '#__proto__';
|
|
28552
|
+
}
|
|
28553
|
+
this.child.push({ [key]: val });
|
|
28554
|
+
}
|
|
28555
|
+
addChild(node) {
|
|
28556
|
+
if (node.tagname === '__proto__') {
|
|
28557
|
+
node.tagname = '#__proto__';
|
|
28558
|
+
}
|
|
28559
|
+
if (node[':@'] && Object.keys(node[':@']).length > 0) {
|
|
28560
|
+
this.child.push({ [node.tagname]: node.child, [':@']: node[':@'] });
|
|
28561
|
+
}
|
|
28562
|
+
else {
|
|
28563
|
+
this.child.push({ [node.tagname]: node.child });
|
|
28564
|
+
}
|
|
28565
|
+
}
|
|
28566
|
+
}
|
|
28567
|
+
function findClosingIndex(xmlData, str, i, errMsg) {
|
|
28568
|
+
const closingIndex = xmlData.indexOf(str, i);
|
|
28569
|
+
if (closingIndex === -1) {
|
|
28570
|
+
throw new Error(errMsg);
|
|
28571
|
+
}
|
|
28572
|
+
else {
|
|
28573
|
+
return closingIndex + str.length - 1;
|
|
28574
|
+
}
|
|
28575
|
+
}
|
|
28576
|
+
function tagExpWithClosingIndex(xmlData, i, closingChar = '>') {
|
|
28577
|
+
let attrBoundary;
|
|
28578
|
+
let tagExp = '';
|
|
28579
|
+
for (let index = i; index < xmlData.length; index++) {
|
|
28580
|
+
let ch = xmlData[index];
|
|
28581
|
+
if (attrBoundary) {
|
|
28582
|
+
if (ch === attrBoundary) {
|
|
28583
|
+
attrBoundary = '';
|
|
28584
|
+
}
|
|
28585
|
+
}
|
|
28586
|
+
else if (ch === '"' || ch === "'") {
|
|
28587
|
+
attrBoundary = ch;
|
|
28588
|
+
}
|
|
28589
|
+
else if (ch === closingChar[0]) {
|
|
28590
|
+
if (closingChar[1]) {
|
|
28591
|
+
if (xmlData[index + 1] === closingChar[1]) {
|
|
28592
|
+
return {
|
|
28593
|
+
data: tagExp,
|
|
28594
|
+
index: index
|
|
28595
|
+
};
|
|
28596
|
+
}
|
|
28597
|
+
}
|
|
28598
|
+
else {
|
|
28599
|
+
return {
|
|
28600
|
+
data: tagExp,
|
|
28601
|
+
index: index
|
|
28602
|
+
};
|
|
28603
|
+
}
|
|
28604
|
+
}
|
|
28605
|
+
else if (ch === '\t') {
|
|
28606
|
+
ch = ' ';
|
|
28607
|
+
}
|
|
28608
|
+
tagExp += ch;
|
|
28609
|
+
}
|
|
28610
|
+
}
|
|
28611
|
+
function readTagExp(xmlData, i, removeNSPrefix, closingChar = '>') {
|
|
28612
|
+
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
|
|
28613
|
+
if (!result) {
|
|
28614
|
+
return;
|
|
28615
|
+
}
|
|
28616
|
+
let tagExp = result.data;
|
|
28617
|
+
const closeIndex = result.index;
|
|
28618
|
+
const separatorIndex = tagExp.search(/\s/);
|
|
28619
|
+
let tagName = tagExp;
|
|
28620
|
+
let attrExpPresent = true;
|
|
28621
|
+
if (separatorIndex !== -1) {
|
|
28622
|
+
tagName = tagExp.substr(0, separatorIndex).replace(/\s\s*$/, '');
|
|
28623
|
+
tagExp = tagExp.substr(separatorIndex + 1);
|
|
28624
|
+
}
|
|
28625
|
+
const rawTagName = tagName;
|
|
28626
|
+
if (removeNSPrefix) {
|
|
28627
|
+
const colonIndex = tagName.indexOf(':');
|
|
28628
|
+
if (colonIndex !== -1) {
|
|
28629
|
+
tagName = tagName.substr(colonIndex + 1);
|
|
28630
|
+
attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
|
|
28631
|
+
}
|
|
30044
28632
|
}
|
|
28633
|
+
return {
|
|
28634
|
+
tagName: tagName,
|
|
28635
|
+
tagExp: tagExp,
|
|
28636
|
+
closeIndex: closeIndex,
|
|
28637
|
+
attrExpPresent: attrExpPresent,
|
|
28638
|
+
rawTagName: rawTagName
|
|
28639
|
+
};
|
|
30045
28640
|
}
|
|
30046
|
-
const
|
|
30047
|
-
class
|
|
30048
|
-
|
|
30049
|
-
|
|
30050
|
-
|
|
30051
|
-
|
|
30052
|
-
|
|
30053
|
-
g.initAttributes(attribute);
|
|
30054
|
-
return g;
|
|
28641
|
+
const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm');
|
|
28642
|
+
class OrderedObjParser {
|
|
28643
|
+
constructor(options) {
|
|
28644
|
+
this.currentNode = null;
|
|
28645
|
+
this.options = options;
|
|
28646
|
+
this.tagsNodeStack = [];
|
|
28647
|
+
this.docTypeEntities = {};
|
|
30055
28648
|
}
|
|
30056
|
-
|
|
30057
|
-
|
|
30058
|
-
|
|
28649
|
+
addChild(currentNode, childNode, jPath) {
|
|
28650
|
+
const result = childNode.tagname;
|
|
28651
|
+
if (typeof result === 'string') {
|
|
28652
|
+
childNode.tagname = result;
|
|
28653
|
+
currentNode.addChild(childNode);
|
|
28654
|
+
}
|
|
28655
|
+
else {
|
|
28656
|
+
currentNode.addChild(childNode);
|
|
30059
28657
|
}
|
|
30060
|
-
const g = this.pools.pop();
|
|
30061
|
-
g.initAttributes(line.attribute);
|
|
30062
|
-
return g;
|
|
30063
28658
|
}
|
|
30064
|
-
|
|
30065
|
-
const
|
|
30066
|
-
|
|
30067
|
-
|
|
30068
|
-
if (!this.pools.length) {
|
|
30069
|
-
return application.graphicService.creator.path(attribute);
|
|
28659
|
+
buildAttributesMap(attrStr, jPath, tagName) {
|
|
28660
|
+
const attrs = {};
|
|
28661
|
+
if (!attrStr) {
|
|
28662
|
+
return;
|
|
30070
28663
|
}
|
|
30071
|
-
const
|
|
30072
|
-
|
|
30073
|
-
|
|
28664
|
+
const matches = getAllMatches(attrStr, attrsRegx);
|
|
28665
|
+
const len = matches.length;
|
|
28666
|
+
for (let i = 0; i < len; i++) {
|
|
28667
|
+
const attrName = matches[i][1];
|
|
28668
|
+
const oldVal = matches[i][4];
|
|
28669
|
+
const aName = attrName;
|
|
28670
|
+
if (attrName) {
|
|
28671
|
+
if (oldVal !== undefined) {
|
|
28672
|
+
attrs[aName] = isNaN(oldVal) ? oldVal : Number(oldVal);
|
|
28673
|
+
}
|
|
28674
|
+
else {
|
|
28675
|
+
attrs[aName] = true;
|
|
28676
|
+
}
|
|
28677
|
+
}
|
|
28678
|
+
}
|
|
28679
|
+
return attrs;
|
|
30074
28680
|
}
|
|
30075
|
-
|
|
30076
|
-
|
|
30077
|
-
|
|
28681
|
+
parseXml(xmlData) {
|
|
28682
|
+
xmlData = xmlData.replace(/\r\n?/g, '\n');
|
|
28683
|
+
const xmlObj = new XmlNode('!xml');
|
|
28684
|
+
let currentNode = xmlObj;
|
|
28685
|
+
let textData = '';
|
|
28686
|
+
let jPath = '';
|
|
28687
|
+
for (let i = 0; i < xmlData.length; i++) {
|
|
28688
|
+
const ch = xmlData[i];
|
|
28689
|
+
if (ch === '<') {
|
|
28690
|
+
if (xmlData[i + 1] === '/') {
|
|
28691
|
+
const closeIndex = findClosingIndex(xmlData, '>', i, 'Closing Tag is not closed.');
|
|
28692
|
+
const propIndex = jPath.lastIndexOf('.');
|
|
28693
|
+
jPath = jPath.substring(0, propIndex);
|
|
28694
|
+
currentNode = this.tagsNodeStack.pop();
|
|
28695
|
+
if (currentNode && currentNode.child && textData) {
|
|
28696
|
+
currentNode.child[currentNode.child.length - 1][':@'] &&
|
|
28697
|
+
(currentNode.child[currentNode.child.length - 1][':@'].text = textData);
|
|
28698
|
+
}
|
|
28699
|
+
textData = '';
|
|
28700
|
+
i = closeIndex;
|
|
28701
|
+
}
|
|
28702
|
+
else if (xmlData[i + 1] === '?') {
|
|
28703
|
+
const tagData = readTagExp(xmlData, i, false, '?>');
|
|
28704
|
+
i = tagData.closeIndex + 1;
|
|
28705
|
+
}
|
|
28706
|
+
else if (xmlData.substr(i + 1, 3) === '!--') {
|
|
28707
|
+
const endIndex = findClosingIndex(xmlData, '-->', i + 4, 'Comment is not closed.');
|
|
28708
|
+
i = endIndex;
|
|
28709
|
+
}
|
|
28710
|
+
else {
|
|
28711
|
+
const result = readTagExp(xmlData, i, false);
|
|
28712
|
+
let tagName = result.tagName;
|
|
28713
|
+
let tagExp = result.tagExp;
|
|
28714
|
+
const attrExpPresent = result.attrExpPresent;
|
|
28715
|
+
const closeIndex = result.closeIndex;
|
|
28716
|
+
if (tagName !== xmlObj.tagname) {
|
|
28717
|
+
jPath += jPath ? '.' + tagName : tagName;
|
|
28718
|
+
}
|
|
28719
|
+
if (tagExp.length > 0 && tagExp.lastIndexOf('/') === tagExp.length - 1) {
|
|
28720
|
+
if (tagName[tagName.length - 1] === '/') {
|
|
28721
|
+
tagName = tagName.substr(0, tagName.length - 1);
|
|
28722
|
+
jPath = jPath.substr(0, jPath.length - 1);
|
|
28723
|
+
tagExp = tagName;
|
|
28724
|
+
}
|
|
28725
|
+
else {
|
|
28726
|
+
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
28727
|
+
}
|
|
28728
|
+
const childNode = new XmlNode(tagName);
|
|
28729
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
28730
|
+
childNode[':@'] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
28731
|
+
}
|
|
28732
|
+
this.addChild(currentNode, childNode, jPath);
|
|
28733
|
+
jPath = jPath.substr(0, jPath.lastIndexOf('.'));
|
|
28734
|
+
}
|
|
28735
|
+
else {
|
|
28736
|
+
const childNode = new XmlNode(tagName);
|
|
28737
|
+
this.tagsNodeStack.push(currentNode);
|
|
28738
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
28739
|
+
childNode[':@'] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
28740
|
+
}
|
|
28741
|
+
this.addChild(currentNode, childNode, jPath);
|
|
28742
|
+
currentNode = childNode;
|
|
28743
|
+
}
|
|
28744
|
+
textData = '';
|
|
28745
|
+
i = closeIndex;
|
|
28746
|
+
}
|
|
28747
|
+
}
|
|
28748
|
+
else {
|
|
28749
|
+
textData += xmlData[i];
|
|
28750
|
+
}
|
|
30078
28751
|
}
|
|
30079
|
-
|
|
30080
|
-
g.initAttributes(path.attribute);
|
|
30081
|
-
return g;
|
|
28752
|
+
return xmlObj.child;
|
|
30082
28753
|
}
|
|
30083
28754
|
}
|
|
30084
|
-
|
|
30085
|
-
|
|
30086
|
-
|
|
30087
|
-
|
|
30088
|
-
|
|
28755
|
+
|
|
28756
|
+
function prettify(node, options) {
|
|
28757
|
+
return compress(node);
|
|
28758
|
+
}
|
|
28759
|
+
function compress(arr, jPath) {
|
|
28760
|
+
const compressedObj = {};
|
|
28761
|
+
for (let i = 0; i < arr.length; i++) {
|
|
28762
|
+
const tagObj = arr[i];
|
|
28763
|
+
const property = propName(tagObj);
|
|
28764
|
+
if (property === undefined) {
|
|
28765
|
+
continue;
|
|
30089
28766
|
}
|
|
30090
|
-
|
|
30091
|
-
|
|
30092
|
-
|
|
30093
|
-
|
|
30094
|
-
|
|
30095
|
-
|
|
30096
|
-
|
|
28767
|
+
else if (tagObj[property]) {
|
|
28768
|
+
const val = compress(tagObj[property]);
|
|
28769
|
+
isLeafTag(val);
|
|
28770
|
+
if (tagObj[':@']) {
|
|
28771
|
+
assignAttributes(val, tagObj[':@']);
|
|
28772
|
+
}
|
|
28773
|
+
if (compressedObj[property] !== undefined && compressedObj.hasOwnProperty(property)) {
|
|
28774
|
+
if (!Array.isArray(compressedObj[property])) {
|
|
28775
|
+
compressedObj[property] = [compressedObj[property]];
|
|
28776
|
+
}
|
|
28777
|
+
compressedObj[property].push(val);
|
|
28778
|
+
}
|
|
28779
|
+
else {
|
|
28780
|
+
compressedObj[property] = val;
|
|
28781
|
+
}
|
|
30097
28782
|
}
|
|
30098
|
-
const g = this.pools.pop();
|
|
30099
|
-
g.initAttributes(symbol.attribute);
|
|
30100
|
-
return g;
|
|
30101
28783
|
}
|
|
28784
|
+
return compressedObj;
|
|
30102
28785
|
}
|
|
30103
|
-
|
|
30104
|
-
|
|
30105
|
-
|
|
30106
|
-
|
|
30107
|
-
|
|
28786
|
+
function propName(obj) {
|
|
28787
|
+
const keys = Object.keys(obj);
|
|
28788
|
+
for (let i = 0; i < keys.length; i++) {
|
|
28789
|
+
const key = keys[i];
|
|
28790
|
+
if (key !== ':@') {
|
|
28791
|
+
return key;
|
|
30108
28792
|
}
|
|
30109
|
-
const g = this.pools.pop();
|
|
30110
|
-
g.initAttributes(attribute);
|
|
30111
|
-
return g;
|
|
30112
28793
|
}
|
|
30113
|
-
|
|
30114
|
-
|
|
30115
|
-
|
|
28794
|
+
}
|
|
28795
|
+
function assignAttributes(obj, attrMap, jpath) {
|
|
28796
|
+
if (attrMap) {
|
|
28797
|
+
const keys = Object.keys(attrMap);
|
|
28798
|
+
const len = keys.length;
|
|
28799
|
+
for (let i = 0; i < len; i++) {
|
|
28800
|
+
const atrrName = keys[i];
|
|
28801
|
+
obj[atrrName] = attrMap[atrrName];
|
|
30116
28802
|
}
|
|
30117
|
-
const g = this.pools.pop();
|
|
30118
|
-
g.initAttributes(text.attribute);
|
|
30119
|
-
return g;
|
|
30120
28803
|
}
|
|
30121
28804
|
}
|
|
30122
|
-
|
|
30123
|
-
|
|
30124
|
-
|
|
30125
|
-
|
|
30126
|
-
text: defaultTextAllocate,
|
|
30127
|
-
symbol: defaultSymbolAllocate
|
|
30128
|
-
};
|
|
28805
|
+
function isLeafTag(obj) {
|
|
28806
|
+
const propCount = Object.keys(obj).length;
|
|
28807
|
+
if (propCount === 0) {
|
|
28808
|
+
return true;
|
|
30129
28809
|
}
|
|
30130
|
-
|
|
30131
|
-
|
|
30132
|
-
|
|
30133
|
-
|
|
30134
|
-
|
|
30135
|
-
|
|
30136
|
-
}
|
|
28810
|
+
return false;
|
|
28811
|
+
}
|
|
28812
|
+
|
|
28813
|
+
class XMLParser {
|
|
28814
|
+
constructor(options) {
|
|
28815
|
+
this.options = Object.assign({}, XMLParser.defaultOptions, options);
|
|
30137
28816
|
}
|
|
30138
|
-
|
|
30139
|
-
|
|
30140
|
-
|
|
30141
|
-
|
|
28817
|
+
valid(xml) {
|
|
28818
|
+
return xml.startsWith('<');
|
|
28819
|
+
}
|
|
28820
|
+
parse(xmlData) {
|
|
28821
|
+
if (!this.valid) {
|
|
28822
|
+
return false;
|
|
30142
28823
|
}
|
|
28824
|
+
const orderedObjParser = new OrderedObjParser(this.options);
|
|
28825
|
+
const orderedResult = orderedObjParser.parseXml(xmlData);
|
|
28826
|
+
return prettify(orderedResult, this.options);
|
|
30143
28827
|
}
|
|
30144
28828
|
}
|
|
30145
|
-
|
|
28829
|
+
XMLParser.defaultOptions = {};
|
|
30146
28830
|
|
|
30147
28831
|
function describeServiceIdentifier(serviceIdentifier) {
|
|
30148
28832
|
if (typeof serviceIdentifier === 'string') {
|