bard-legends-framework 0.10.9 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions-performance.test.d.ts +1 -0
- package/dist/actions-performance.test.js +83 -0
- package/dist/game-entities/controller/controller.d.ts +2 -3
- package/dist/game-entities/controller/controller.js +9 -8
- package/dist/game-entities/controller/controller.test.js +2 -2
- package/dist/game-entities/entity/entity.d.ts +11 -9
- package/dist/game-entities/entity/entity.js +20 -16
- package/dist/game-entities/entity/entity.test.js +116 -147
- package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +6 -9
- package/dist/game-entities/entity/helpers/entity-store.helper.js +22 -57
- package/dist/game-entities/entity/helpers/entity-store.helper.test.d.ts +1 -0
- package/dist/game-entities/entity/helpers/entity-store.helper.test.js +136 -0
- package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +7 -7
- package/dist/game-entities/entity/helpers/entity-views.helper.js +28 -23
- package/dist/game-entities/entity/singleton-entity.d.ts +3 -3
- package/dist/game-entities/entity/singleton-entity.js +1 -1
- package/dist/game-entities/entity/singleton-entity.test.js +9 -31
- package/dist/game-entities/hard-reset.d.ts +5 -0
- package/dist/game-entities/hard-reset.js +14 -0
- package/dist/game-entities/index.d.ts +1 -3
- package/dist/game-entities/index.js +3 -7
- package/dist/game-entities/scene/scene.d.ts +15 -15
- package/dist/game-entities/scene/scene.js +61 -60
- package/dist/game-entities/scene/scene.test.js +97 -67
- package/dist/game-entities/service/service.d.ts +1 -4
- package/dist/game-entities/service/service.js +15 -14
- package/dist/game-entities/service/service.test.js +33 -38
- package/dist/game-entities/unit-test.helper.d.ts +5 -0
- package/dist/game-entities/unit-test.helper.js +14 -0
- package/dist/game-entities/update-cycle.d.ts +10 -9
- package/dist/game-entities/update-cycle.js +34 -23
- package/dist/game-entities/view/view.d.ts +10 -11
- package/dist/game-entities/view/view.js +17 -35
- package/dist/game-entities/view/view.test.js +73 -250
- package/dist/physics/entity-types/immovable-physics-entity.d.ts +2 -4
- package/dist/physics/entity-types/immovable-physics-entity.js +4 -6
- package/dist/physics/entity-types/movable-entity.d.ts +1 -1
- package/dist/physics/entity-types/movable-entity.js +6 -6
- package/dist/physics/entity-types/movable-physics-entity.d.ts +10 -11
- package/dist/physics/entity-types/movable-physics-entity.js +31 -32
- package/dist/physics/entity-types/physics-entity.d.ts +12 -15
- package/dist/physics/entity-types/physics-entity.js +30 -28
- package/dist/physics/interfaces.d.ts +6 -6
- package/dist/physics/interfaces.js +4 -4
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js +22 -22
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +20 -20
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js +30 -30
- package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +10 -10
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.js +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +11 -11
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js +18 -18
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.js +11 -11
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/creation/border.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/creation/border.service.js +9 -9
- package/dist/physics/module//360/237/223/220services/creation/materials.service.d.ts +7 -7
- package/dist/physics/module//360/237/223/220services/creation/materials.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.d.ts +11 -11
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +28 -27
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.js +13 -13
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +19 -19
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.js +20 -20
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.d.ts +1 -1
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.js +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.js +3 -3
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +13 -13
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +13 -13
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.d.ts +1 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.js +7 -15
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +60 -49
- package/dist/physics/module//360/237/247/212entities/border.entity.d.ts +1 -1
- package/dist/physics/module//360/237/247/212entities/border.entity.js +3 -3
- package/dist/physics/module//360/237/247/212entities/physics-world.entity.js +2 -2
- package/dist/pixi/components/display-object-array.d.ts +5 -5
- package/dist/pixi/components/display-object-array.js +14 -14
- package/dist/pixi/components/helpers/smooth-scroller.d.ts +7 -7
- package/dist/pixi/components/helpers/smooth-scroller.js +23 -23
- package/dist/pixi/components/helpers/smooth-scroller.test.js +14 -14
- package/dist/pixi/components/menu/menu-entity.d.ts +14 -0
- package/dist/pixi/components/menu/menu-entity.js +48 -0
- package/dist/pixi/components/menu/menu.ui.d.ts +23 -0
- package/dist/pixi/components/menu/menu.ui.js +97 -0
- package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +4 -3
- package/dist/pixi/components/mouse-wheel-listener.ui.js +15 -14
- package/dist/pixi/components/scroll-area.ui.d.ts +1 -1
- package/dist/pixi/components/scroll-area.ui.js +9 -9
- package/dist/pixi/components/scroll-mask.ui.d.ts +9 -8
- package/dist/pixi/components/scroll-mask.ui.js +25 -24
- package/dist/pixi/display-object/container-attributes.d.ts +24 -26
- package/dist/pixi/display-object/container-attributes.js +27 -28
- package/dist/pixi/display-object/container.d.ts +3 -6
- package/dist/pixi/display-object/container.js +2 -12
- package/dist/pixi/display-object/filters/base-filters/blur.filter.d.ts +9 -9
- package/dist/pixi/display-object/filters/base-filters/blur.filter.js +25 -25
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.d.ts +7 -7
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +17 -17
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.d.ts +6 -6
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.js +10 -11
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.d.ts +2 -2
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.js +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +8 -8
- package/dist/pixi/display-object/filters/templates/plane.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/plane.template.js +7 -7
- package/dist/pixi/display-object/filters.d.ts +7 -7
- package/dist/pixi/display-object/filters.js +34 -34
- package/dist/pixi/display-object/index.d.ts +1 -1
- package/dist/pixi/display-object/objects/graphics/graphics.d.ts +9 -9
- package/dist/pixi/display-object/objects/graphics/graphics.js +25 -25
- package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
- package/dist/pixi/display-object/objects/placeholder.js +7 -7
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.d.ts +9 -9
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +29 -26
- package/dist/pixi/display-object/objects/sprite/sprite.d.ts +10 -9
- package/dist/pixi/display-object/objects/sprite/sprite.js +62 -53
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.d.ts +4 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.d.ts +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +16 -16
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +28 -28
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.d.ts +1 -1
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.js +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.d.ts +17 -17
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.js +62 -62
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.js +2 -2
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.d.ts +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.js +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.js +12 -12
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +2 -2
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.js +5 -5
- package/dist/pixi/display-object/objects/text/rich-text.d.ts +0 -1
- package/dist/pixi/display-object/objects/text/rich-text.js +0 -1
- package/dist/pixi/display-object/objects/text/text.d.ts +9 -10
- package/dist/pixi/display-object/objects/text/text.js +34 -35
- package/dist/pixi/game.d.ts +26 -17
- package/dist/pixi/game.js +53 -39
- package/dist/pixi/helpers/game-assets.d.ts +5 -5
- package/dist/pixi/helpers/game-assets.js +14 -11
- package/dist/pixi/helpers/position-conversion.helper.d.ts +4 -4
- package/dist/pixi/helpers/position-conversion.helper.js +3 -3
- package/dist/pixi/index.d.ts +3 -37
- package/dist/pixi/index.js +6 -22
- package/dist/pixi/modules/CAMERA/camera.d.ts +5 -4
- package/dist/pixi/modules/CAMERA/camera.js +9 -9
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.js +1 -1
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.js +5 -5
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.d.ts +3 -3
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.js +7 -7
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +8 -8
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.js +8 -8
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.d.ts +2 -2
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.js +12 -12
- package/dist/pixi/modules/CAMERA//360/237/247/212entities/camera.entity.js +4 -4
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +17 -16
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +50 -49
- package/dist/pixi/pixi-definitions.d.ts +38 -0
- package/dist/pixi/pixi-definitions.js +37 -0
- package/dist/pixi/services/keyboard/keyboard.d.ts +6 -4
- package/dist/pixi/services/keyboard/keyboard.js +15 -13
- package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +12 -11
- package/dist/pixi/services/mouse/mouse-target-focus.service.js +31 -30
- package/dist/pixi/services/mouse/mouse.service.d.ts +16 -6
- package/dist/pixi/services/mouse/mouse.service.js +42 -22
- package/dist/utilities/animator/animating-content/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/animating-content/fade-in-content.js +37 -0
- package/dist/utilities/animator/animating-content/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/animating-content/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/animating-content/slide-in-content.js +99 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/animations.d.ts +45 -0
- package/dist/utilities/animator/animations.js +92 -0
- package/dist/utilities/animator/animator/animator.d.ts +44 -0
- package/dist/utilities/animator/animator/animator.js +234 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.performance.test.js +116 -0
- package/dist/utilities/animator/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.test.js +1046 -0
- package/dist/utilities/animator/animator.d.ts +60 -0
- package/dist/utilities/animator/animator.js +322 -0
- package/dist/utilities/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator.performance.test.js +46 -0
- package/dist/utilities/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator.test.js +928 -0
- package/dist/utilities/animator/animator2/animator.d.ts +42 -0
- package/dist/utilities/animator/animator2/animator.js +222 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator2/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.performance.test.js +65 -0
- package/dist/utilities/animator/animator2/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.test.js +1007 -0
- package/dist/utilities/animator/animator_old/animator.d.ts +60 -0
- package/dist/utilities/animator/animator_old/animator.js +337 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.js +121 -0
- package/dist/utilities/animator/animator_old/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.test.js +996 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.d.ts +38 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.js +208 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.js +439 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.d.ts +41 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.js +107 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.js +138 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.js +307 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.d.ts +37 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.js +170 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.js +340 -0
- package/dist/utilities/animator/index.d.ts +7 -0
- package/dist/utilities/animator/index.js +24 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.js +431 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.js +100 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/state-animation.d.ts +33 -0
- package/dist/utilities/animator/state-animation/state-animation.js +146 -0
- package/dist/utilities/animator/state-animation/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/state-animation.test.js +335 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +431 -0
- package/dist/utilities/data-structures/vector-set/vector-set.d.ts +7 -0
- package/dist/utilities/data-structures/vector-set/vector-set.js +26 -0
- package/dist/utilities/delta-time/delta-time.d.ts +3 -0
- package/dist/utilities/delta-time/delta-time.js +10 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +6 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +55 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +100 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.d.ts +8 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.js +98 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +155 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.d.ts +6 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.js +17 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +18 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +129 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +254 -0
- package/dist/utilities/index.d.ts +6 -6
- package/dist/utilities/index.js +6 -6
- package/package.json +8 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Radian, RGBColor } from 'helpers-lib';
|
|
2
|
-
import * as
|
|
2
|
+
import * as Pixi from 'pixi.js';
|
|
3
3
|
export interface DropShadowOptions {
|
|
4
4
|
readonly blur: number;
|
|
5
5
|
readonly angle: Radian;
|
|
@@ -7,9 +7,10 @@ export interface DropShadowOptions {
|
|
|
7
7
|
readonly color: RGBColor;
|
|
8
8
|
readonly alpha: number;
|
|
9
9
|
}
|
|
10
|
+
export type TextAlignment = 'center' | 'left' | 'right';
|
|
10
11
|
export interface TextOptions {
|
|
11
12
|
readonly color: RGBColor;
|
|
12
|
-
readonly align:
|
|
13
|
+
readonly align: TextAlignment;
|
|
13
14
|
readonly fontFamily: string;
|
|
14
15
|
readonly fontSize: number;
|
|
15
16
|
readonly fontStyle: 'normal' | 'italic' | 'oblique';
|
|
@@ -21,7 +22,7 @@ export interface TextOptions {
|
|
|
21
22
|
export type PartialTextOptions = Partial<Omit<TextOptions, 'dropShadow'>> & {
|
|
22
23
|
dropShadow?: Partial<DropShadowOptions> | true;
|
|
23
24
|
};
|
|
24
|
-
export interface ExtendedPixiTextStyle extends Partial<
|
|
25
|
+
export interface ExtendedPixiTextStyle extends Partial<Pixi.ITextStyle> {
|
|
25
26
|
readonly lineThrough: boolean;
|
|
26
27
|
}
|
|
27
28
|
export declare class TextStyleConverter {
|
|
@@ -10,10 +10,10 @@ export interface TagsWithStyles {
|
|
|
10
10
|
}
|
|
11
11
|
export declare class RichTextDataInConverter {
|
|
12
12
|
static process(text: string, options: RichTextOptions): ChunkData[][];
|
|
13
|
-
private static
|
|
14
|
-
private static
|
|
15
|
-
private static
|
|
16
|
-
private static
|
|
17
|
-
private static
|
|
18
|
-
private static
|
|
13
|
+
private static _includeStylesToTags;
|
|
14
|
+
private static _getCombinedStyle;
|
|
15
|
+
private static _combineStyles;
|
|
16
|
+
private static _applyNewLines;
|
|
17
|
+
private static _splitIntoChunks;
|
|
18
|
+
private static _splitToChunks;
|
|
19
19
|
}
|
|
@@ -24,19 +24,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.RichTextDataInConverter = void 0;
|
|
27
|
-
const
|
|
27
|
+
const Pixi = __importStar(require("pixi.js"));
|
|
28
28
|
const script_engine_lib_1 = require("script-engine-lib");
|
|
29
29
|
const pixi_text_style_converter_1 = require("./pixi-text-style-converter");
|
|
30
30
|
class RichTextDataInConverter {
|
|
31
31
|
static process(text, options) {
|
|
32
32
|
let styleNameSet = new Set(options.styles ? Object.keys(options.styles) : []);
|
|
33
33
|
let textSegments = script_engine_lib_1.RichTextSeparator.process(text, styleNameSet);
|
|
34
|
-
let tagsWithStyles = this.
|
|
35
|
-
let lines = this.
|
|
36
|
-
let chunks = this.
|
|
34
|
+
let tagsWithStyles = this._includeStylesToTags(textSegments, options);
|
|
35
|
+
let lines = this._applyNewLines(tagsWithStyles);
|
|
36
|
+
let chunks = this._splitIntoChunks(lines);
|
|
37
37
|
return chunks;
|
|
38
38
|
}
|
|
39
|
-
static
|
|
39
|
+
static _includeStylesToTags(textSegments, options) {
|
|
40
40
|
let styleCache = new Map();
|
|
41
41
|
let pixiStyleCache = new Map();
|
|
42
42
|
const GetPixiStyle = (style, cacheKey) => {
|
|
@@ -48,9 +48,9 @@ class RichTextDataInConverter {
|
|
|
48
48
|
return pixiStyle;
|
|
49
49
|
};
|
|
50
50
|
let tagsWithStyles = textSegments.map(segment => {
|
|
51
|
-
let { style, cacheKey } = this.
|
|
51
|
+
let { style, cacheKey } = this._getCombinedStyle(segment.tags, options, styleCache);
|
|
52
52
|
let pixiStyle = GetPixiStyle(style, cacheKey);
|
|
53
|
-
let spaceMeasurement =
|
|
53
|
+
let spaceMeasurement = Pixi.TextMetrics.measureText(' ', new Pixi.TextStyle(pixiStyle), false);
|
|
54
54
|
let data = {
|
|
55
55
|
text: segment.text,
|
|
56
56
|
cacheKey,
|
|
@@ -62,16 +62,16 @@ class RichTextDataInConverter {
|
|
|
62
62
|
});
|
|
63
63
|
return tagsWithStyles;
|
|
64
64
|
}
|
|
65
|
-
static
|
|
65
|
+
static _getCombinedStyle(tags, options, styleCache) {
|
|
66
66
|
let cacheKey = tags.join('+');
|
|
67
67
|
if (styleCache.has(cacheKey)) {
|
|
68
68
|
return { style: styleCache.get(cacheKey), cacheKey };
|
|
69
69
|
}
|
|
70
|
-
let result = this.
|
|
70
|
+
let result = this._combineStyles(tags, options);
|
|
71
71
|
styleCache.set(cacheKey, result);
|
|
72
72
|
return { style: result, cacheKey };
|
|
73
73
|
}
|
|
74
|
-
static
|
|
74
|
+
static _combineStyles(tags, options) {
|
|
75
75
|
let result = { ...options.default };
|
|
76
76
|
for (let tag of tags) {
|
|
77
77
|
if (options.styles && options.styles[tag]) {
|
|
@@ -81,7 +81,7 @@ class RichTextDataInConverter {
|
|
|
81
81
|
let { wordWrapWidth: _wordWrapWidth, align: _align, dropShadow: _dropShadow, ...supportedStyles } = result;
|
|
82
82
|
return supportedStyles;
|
|
83
83
|
}
|
|
84
|
-
static
|
|
84
|
+
static _applyNewLines(tokens) {
|
|
85
85
|
let result = [];
|
|
86
86
|
let currentLine = [];
|
|
87
87
|
tokens.forEach((token, index) => {
|
|
@@ -103,17 +103,17 @@ class RichTextDataInConverter {
|
|
|
103
103
|
result.push(currentLine);
|
|
104
104
|
return result;
|
|
105
105
|
}
|
|
106
|
-
static
|
|
106
|
+
static _splitIntoChunks(tagsWithStyles) {
|
|
107
107
|
let chunks = [];
|
|
108
108
|
tagsWithStyles.forEach(line => {
|
|
109
109
|
if (line.length === 0) {
|
|
110
110
|
throw new Error('Internal Error: Line is unexpectedly empty');
|
|
111
111
|
}
|
|
112
112
|
let chunkData = line.flatMap(data => {
|
|
113
|
-
let chunkStrings = this.
|
|
113
|
+
let chunkStrings = this._splitToChunks(data.text);
|
|
114
114
|
return chunkStrings.map(chunkString => {
|
|
115
|
-
let pixiStyle = new
|
|
116
|
-
let metrics =
|
|
115
|
+
let pixiStyle = new Pixi.TextStyle(data.pixiStyle);
|
|
116
|
+
let metrics = Pixi.TextMetrics.measureText(chunkString, pixiStyle, false);
|
|
117
117
|
let chunkDatum = {
|
|
118
118
|
text: chunkString,
|
|
119
119
|
whitespace: chunkString.trim() === '',
|
|
@@ -135,7 +135,7 @@ class RichTextDataInConverter {
|
|
|
135
135
|
});
|
|
136
136
|
return chunks;
|
|
137
137
|
}
|
|
138
|
-
static
|
|
138
|
+
static _splitToChunks(str) {
|
|
139
139
|
if (str === '') {
|
|
140
140
|
return [''];
|
|
141
141
|
}
|
|
@@ -35,7 +35,7 @@ const ExpectedPixiStyles = {
|
|
|
35
35
|
(0, vitest_1.test)('should handle plain text without tags', () => {
|
|
36
36
|
let text = 'Simple text without any tags';
|
|
37
37
|
let textSegments = script_engine_lib_1.RichTextSeparator.process(text, StyleNames);
|
|
38
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
38
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_includeStylesToTags'](textSegments, DefaultRichTextOptions);
|
|
39
39
|
(0, vitest_1.expect)(result).toEqual([
|
|
40
40
|
{
|
|
41
41
|
text: 'Simple text without any tags',
|
|
@@ -49,7 +49,7 @@ const ExpectedPixiStyles = {
|
|
|
49
49
|
(0, vitest_1.test)('should handle single style tag correctly', () => {
|
|
50
50
|
let text = '<style1>Styled text</style1>';
|
|
51
51
|
let textSegments = script_engine_lib_1.RichTextSeparator.process(text, StyleNames);
|
|
52
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
52
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_includeStylesToTags'](textSegments, DefaultRichTextOptions);
|
|
53
53
|
(0, vitest_1.expect)(result).toEqual([
|
|
54
54
|
{
|
|
55
55
|
text: 'Styled text',
|
|
@@ -63,7 +63,7 @@ const ExpectedPixiStyles = {
|
|
|
63
63
|
(0, vitest_1.test)('should handle text with surrounding styles', () => {
|
|
64
64
|
let text = 'plain text <style1>styled text</style1> more plain text';
|
|
65
65
|
let textSegments = script_engine_lib_1.RichTextSeparator.process(text, StyleNames);
|
|
66
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
66
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_includeStylesToTags'](textSegments, DefaultRichTextOptions);
|
|
67
67
|
(0, vitest_1.expect)(result).toEqual([
|
|
68
68
|
{
|
|
69
69
|
text: 'plain text ',
|
|
@@ -91,7 +91,7 @@ const ExpectedPixiStyles = {
|
|
|
91
91
|
(0, vitest_1.test)('should handle multiple styles', () => {
|
|
92
92
|
let text = '<style1>Text with style1</style1> plain text <style2>text with style2</style2>';
|
|
93
93
|
let textSegments = script_engine_lib_1.RichTextSeparator.process(text, StyleNames);
|
|
94
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
94
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_includeStylesToTags'](textSegments, DefaultRichTextOptions);
|
|
95
95
|
(0, vitest_1.expect)(result).toEqual([
|
|
96
96
|
{
|
|
97
97
|
text: 'Text with style1',
|
|
@@ -119,7 +119,7 @@ const ExpectedPixiStyles = {
|
|
|
119
119
|
(0, vitest_1.test)('should handle nested styles', () => {
|
|
120
120
|
let text = 'Text <style1>with <style2>nested</style2> styles</style1>';
|
|
121
121
|
let textSegments = script_engine_lib_1.RichTextSeparator.process(text, StyleNames);
|
|
122
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
122
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_includeStylesToTags'](textSegments, DefaultRichTextOptions);
|
|
123
123
|
(0, vitest_1.expect)(result).toEqual([
|
|
124
124
|
{
|
|
125
125
|
text: 'Text ',
|
|
@@ -164,7 +164,7 @@ const ExpectedPixiStyles = {
|
|
|
164
164
|
(0, vitest_1.test)('should not accept "default" as a valid tag', () => {
|
|
165
165
|
let text = 'Text with no default tag';
|
|
166
166
|
let textSegments = script_engine_lib_1.RichTextSeparator.process(text, StyleNames);
|
|
167
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
167
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_includeStylesToTags'](textSegments, DefaultRichTextOptions);
|
|
168
168
|
(0, vitest_1.expect)(result).toEqual([
|
|
169
169
|
{
|
|
170
170
|
text: 'Text with no default tag',
|
|
@@ -178,7 +178,7 @@ const ExpectedPixiStyles = {
|
|
|
178
178
|
(0, vitest_1.test)('should match the example in comments', () => {
|
|
179
179
|
let text = 'This is a sample <style1>Hello</style1><style2>World</style2> text';
|
|
180
180
|
let textSegments = script_engine_lib_1.RichTextSeparator.process(text, StyleNames);
|
|
181
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
181
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_includeStylesToTags'](textSegments, DefaultRichTextOptions);
|
|
182
182
|
(0, vitest_1.expect)(result).toEqual([
|
|
183
183
|
{
|
|
184
184
|
text: 'This is a sample ',
|
|
@@ -234,31 +234,31 @@ const ExpectedPixiStyles = {
|
|
|
234
234
|
};
|
|
235
235
|
(0, vitest_1.test)('empty text', () => {
|
|
236
236
|
let text = '';
|
|
237
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
237
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_applyNewLines']([GetTagsWithStyles(text)]);
|
|
238
238
|
(0, vitest_1.expect)(result).toEqual([[GetTagsWithStyles('')]]);
|
|
239
239
|
});
|
|
240
240
|
(0, vitest_1.test)('plane text', () => {
|
|
241
241
|
let text = 'Simple text without styles';
|
|
242
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
242
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_applyNewLines']([GetTagsWithStyles(text)]);
|
|
243
243
|
(0, vitest_1.expect)(result).toEqual([[GetTagsWithStyles('Simple text without styles')]]);
|
|
244
244
|
});
|
|
245
245
|
(0, vitest_1.test)('text with newlines', () => {
|
|
246
246
|
let text = 'Line 1\nLine 2\nLine 3';
|
|
247
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
247
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_applyNewLines']([GetTagsWithStyles(text)]);
|
|
248
248
|
(0, vitest_1.expect)(result).toEqual([[GetTagsWithStyles('Line 1')], [GetTagsWithStyles('Line 2')], [GetTagsWithStyles('Line 3')]]);
|
|
249
249
|
});
|
|
250
250
|
(0, vitest_1.test)('text with empty starting line', () => {
|
|
251
251
|
let text = '\n0123';
|
|
252
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
252
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_applyNewLines']([GetTagsWithStyles(text)]);
|
|
253
253
|
(0, vitest_1.expect)(result).toEqual([[GetTagsWithStyles('')], [GetTagsWithStyles('0123')]]);
|
|
254
254
|
});
|
|
255
255
|
(0, vitest_1.test)('text with empty ending line', () => {
|
|
256
256
|
let text = '0123\n';
|
|
257
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
257
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_applyNewLines']([GetTagsWithStyles(text)]);
|
|
258
258
|
(0, vitest_1.expect)(result).toEqual([[GetTagsWithStyles('0123')], [GetTagsWithStyles('')]]);
|
|
259
259
|
});
|
|
260
260
|
(0, vitest_1.test)('text with styles', () => {
|
|
261
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
261
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_applyNewLines']([
|
|
262
262
|
GetTagsWithStyles('Regular text '),
|
|
263
263
|
GetTagsWithStyles('red text', 'red'),
|
|
264
264
|
GetTagsWithStyles(' back to regular')
|
|
@@ -268,7 +268,7 @@ const ExpectedPixiStyles = {
|
|
|
268
268
|
]);
|
|
269
269
|
});
|
|
270
270
|
(0, vitest_1.test)('text with styles and newlines', () => {
|
|
271
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
271
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_applyNewLines']([
|
|
272
272
|
GetTagsWithStyles('Regular text '),
|
|
273
273
|
GetTagsWithStyles('red text\nnew line still red', 'red'),
|
|
274
274
|
GetTagsWithStyles(' back to regular')
|
|
@@ -279,11 +279,11 @@ const ExpectedPixiStyles = {
|
|
|
279
279
|
]);
|
|
280
280
|
});
|
|
281
281
|
(0, vitest_1.test)('should handle CRLF newlines', () => {
|
|
282
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
282
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_applyNewLines']([GetTagsWithStyles('Line 1\r\nLine 2\r\nLine 3')]);
|
|
283
283
|
(0, vitest_1.expect)(result).toEqual([[GetTagsWithStyles('Line 1')], [GetTagsWithStyles('Line 2')], [GetTagsWithStyles('Line 3')]]);
|
|
284
284
|
});
|
|
285
285
|
(0, vitest_1.test)('should handle empty lines', () => {
|
|
286
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
286
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_applyNewLines']([GetTagsWithStyles('Line 1\n\nLine 3')]);
|
|
287
287
|
(0, vitest_1.expect)(result).toEqual([[GetTagsWithStyles('Line 1')], [GetTagsWithStyles('')], [GetTagsWithStyles('Line 3')]]);
|
|
288
288
|
});
|
|
289
289
|
});
|
|
@@ -297,17 +297,17 @@ const ExpectedPixiStyles = {
|
|
|
297
297
|
});
|
|
298
298
|
(0, vitest_1.test)('empty string', () => {
|
|
299
299
|
let nonWrappedTextData = [[GetNonWrappedTextData('')]];
|
|
300
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
300
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitIntoChunks'](nonWrappedTextData);
|
|
301
301
|
(0, vitest_1.expect)(result).toEqual([[(0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('')]]);
|
|
302
302
|
});
|
|
303
303
|
(0, vitest_1.test)('single word', () => {
|
|
304
304
|
let nonWrappedTextData = [[GetNonWrappedTextData('Hello')]];
|
|
305
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
305
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitIntoChunks'](nonWrappedTextData);
|
|
306
306
|
(0, vitest_1.expect)(result).toEqual([[(0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('Hello')]]);
|
|
307
307
|
});
|
|
308
308
|
(0, vitest_1.test)('multiple words with spaces', () => {
|
|
309
309
|
let nonWrappedTextData = [[GetNonWrappedTextData('Hello World')]];
|
|
310
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
310
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitIntoChunks'](nonWrappedTextData);
|
|
311
311
|
(0, vitest_1.expect)(result).toEqual([[(0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('Hello'), (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' '), (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('World')]]);
|
|
312
312
|
});
|
|
313
313
|
(0, vitest_1.test)('multiple lines', () => {
|
|
@@ -315,7 +315,7 @@ const ExpectedPixiStyles = {
|
|
|
315
315
|
[GetNonWrappedTextData('Line 1')],
|
|
316
316
|
[GetNonWrappedTextData('Line 2', { fontSize: 24 })]
|
|
317
317
|
];
|
|
318
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
318
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitIntoChunks'](nonWrappedTextData);
|
|
319
319
|
(0, vitest_1.expect)(result).toEqual([
|
|
320
320
|
[(0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('Line'), (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' '), (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('1')],
|
|
321
321
|
[
|
|
@@ -327,43 +327,43 @@ const ExpectedPixiStyles = {
|
|
|
327
327
|
});
|
|
328
328
|
(0, vitest_1.test)('empty line throws error', () => {
|
|
329
329
|
let nonWrappedTextData = [[]];
|
|
330
|
-
(0, vitest_1.expect)(() => rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
330
|
+
(0, vitest_1.expect)(() => rich_text_data_in_converter_1.RichTextDataInConverter['_splitIntoChunks'](nonWrappedTextData)).toThrow('Internal Error: Line is unexpectedly empty');
|
|
331
331
|
});
|
|
332
332
|
});
|
|
333
333
|
(0, vitest_1.describe)('splitToChunks', () => {
|
|
334
334
|
(0, vitest_1.test)('empty string', () => {
|
|
335
335
|
let text = '';
|
|
336
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
336
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitToChunks'](text);
|
|
337
337
|
(0, vitest_1.expect)(result).toEqual(['']);
|
|
338
338
|
});
|
|
339
339
|
(0, vitest_1.test)('no spaces', () => {
|
|
340
340
|
let text = 'helloworld';
|
|
341
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
341
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitToChunks'](text);
|
|
342
342
|
(0, vitest_1.expect)(result).toEqual(['helloworld']);
|
|
343
343
|
});
|
|
344
344
|
(0, vitest_1.test)('only spaces', () => {
|
|
345
345
|
let text = ' ';
|
|
346
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
346
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitToChunks'](text);
|
|
347
347
|
(0, vitest_1.expect)(result).toEqual([' ']);
|
|
348
348
|
});
|
|
349
349
|
(0, vitest_1.test)('spaces at start', () => {
|
|
350
350
|
let text = ' hello world';
|
|
351
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
351
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitToChunks'](text);
|
|
352
352
|
(0, vitest_1.expect)(result).toEqual([' ', 'hello', ' ', 'world']);
|
|
353
353
|
});
|
|
354
354
|
(0, vitest_1.test)('spaces at end', () => {
|
|
355
355
|
let text = 'hello world ';
|
|
356
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
356
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitToChunks'](text);
|
|
357
357
|
(0, vitest_1.expect)(result).toEqual(['hello', ' ', 'world', ' ']);
|
|
358
358
|
});
|
|
359
359
|
(0, vitest_1.test)('multiple spaces in between', () => {
|
|
360
360
|
let text = 'hello world';
|
|
361
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
361
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitToChunks'](text);
|
|
362
362
|
(0, vitest_1.expect)(result).toEqual(['hello', ' ', 'world']);
|
|
363
363
|
});
|
|
364
364
|
(0, vitest_1.test)('should handle text with alternating spaces and words', () => {
|
|
365
365
|
let text = ' a b c d ';
|
|
366
|
-
let result = rich_text_data_in_converter_1.RichTextDataInConverter['
|
|
366
|
+
let result = rich_text_data_in_converter_1.RichTextDataInConverter['_splitToChunks'](text);
|
|
367
367
|
(0, vitest_1.expect)(result).toEqual([' ', 'a', ' ', 'b', ' ', 'c', ' ', 'd', ' ']);
|
|
368
368
|
});
|
|
369
369
|
});
|
|
@@ -2,5 +2,5 @@ import { ChunkData } from '../../rich-text-to-plane-text';
|
|
|
2
2
|
import { PositionedChunk, RichTextTypewriter } from './rich-text-typewriter';
|
|
3
3
|
export declare class ConsistentSpaceTextWrapper {
|
|
4
4
|
static wrapText(sheet: ChunkData[][], typewriter: RichTextTypewriter): PositionedChunk[][];
|
|
5
|
-
private static
|
|
5
|
+
private static _wrapSpaces;
|
|
6
6
|
}
|
|
@@ -13,7 +13,7 @@ class ConsistentSpaceTextWrapper {
|
|
|
13
13
|
typewriter.insertWord(chunk);
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
this.
|
|
16
|
+
this._wrapSpaces(chunk, typewriter);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
@@ -25,7 +25,7 @@ class ConsistentSpaceTextWrapper {
|
|
|
25
25
|
typewriter.insertWord(chunk);
|
|
26
26
|
}
|
|
27
27
|
else if (chunk.whitespace) {
|
|
28
|
-
this.
|
|
28
|
+
this._wrapSpaces(chunk, typewriter);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
typewriter.newLine();
|
|
@@ -37,7 +37,7 @@ class ConsistentSpaceTextWrapper {
|
|
|
37
37
|
});
|
|
38
38
|
return typewriter.print();
|
|
39
39
|
}
|
|
40
|
-
static
|
|
40
|
+
static _wrapSpaces(chunk, typewriter) {
|
|
41
41
|
let spacesThatCanFit = Math.max(0, Math.floor(typewriter.remainingWidth / chunk.style.spaceWidth));
|
|
42
42
|
let spacesToInsert = Math.max(0, Math.min(spacesThatCanFit, chunk.text.length - 1));
|
|
43
43
|
if (spacesToInsert > 0) {
|
|
@@ -11,27 +11,27 @@ export interface RichTextTypewriterOptions {
|
|
|
11
11
|
readonly verticalAlignment?: 'top' | 'center' | 'bottom';
|
|
12
12
|
}
|
|
13
13
|
export declare class RichTextTypewriter {
|
|
14
|
-
private readonly
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private readonly
|
|
21
|
-
private readonly
|
|
22
|
-
private readonly
|
|
14
|
+
private readonly _wordWrapWidth;
|
|
15
|
+
private _lines;
|
|
16
|
+
private _currentLine;
|
|
17
|
+
private _cursorPosition;
|
|
18
|
+
private _linePosition;
|
|
19
|
+
private _currentLineHeight;
|
|
20
|
+
private readonly _cut?;
|
|
21
|
+
private readonly _horizontalAlignment;
|
|
22
|
+
private readonly _verticalAlignment;
|
|
23
23
|
get lineIsEmpty(): boolean;
|
|
24
24
|
get remainingWidth(): number;
|
|
25
|
-
constructor(
|
|
25
|
+
constructor(_wordWrapWidth: number, options?: RichTextTypewriterOptions);
|
|
26
26
|
isSpaceAvailable(size: Vector): boolean;
|
|
27
27
|
insertWord(chunk: ChunkData): void;
|
|
28
28
|
newLine(): void;
|
|
29
29
|
print(): PositionedChunk[][];
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
private
|
|
34
|
-
private
|
|
35
|
-
private
|
|
36
|
-
private
|
|
30
|
+
private _flushCurrentLine;
|
|
31
|
+
private _alignLine;
|
|
32
|
+
private _horizontallyAlign;
|
|
33
|
+
private _verticallyAlign;
|
|
34
|
+
private _getLineStart;
|
|
35
|
+
private _getLineEnd;
|
|
36
|
+
private _convertRectangleCut;
|
|
37
37
|
}
|
|
@@ -4,83 +4,83 @@ exports.RichTextTypewriter = void 0;
|
|
|
4
4
|
const helpers_lib_1 = require("helpers-lib");
|
|
5
5
|
class RichTextTypewriter {
|
|
6
6
|
get lineIsEmpty() {
|
|
7
|
-
return this.
|
|
7
|
+
return this._currentLine.length === 0;
|
|
8
8
|
}
|
|
9
9
|
get remainingWidth() {
|
|
10
|
-
return this.
|
|
10
|
+
return this._wordWrapWidth - this._cursorPosition;
|
|
11
11
|
}
|
|
12
|
-
constructor(
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
12
|
+
constructor(_wordWrapWidth, options) {
|
|
13
|
+
this._wordWrapWidth = _wordWrapWidth;
|
|
14
|
+
this._lines = [];
|
|
15
|
+
this._currentLine = [];
|
|
16
|
+
this._cursorPosition = 0;
|
|
17
|
+
this._linePosition = new helpers_lib_1.Vector(0, 0);
|
|
18
|
+
this._currentLineHeight = 0;
|
|
19
|
+
this._horizontalAlignment = options?.horizontalAlignment ?? 'left';
|
|
20
|
+
this._verticalAlignment = options?.verticalAlignment ?? 'bottom';
|
|
21
21
|
if (options?.rectangleCutOption) {
|
|
22
22
|
if (options.rectangleCutOption.position.x < 0 ||
|
|
23
|
-
options.rectangleCutOption.position.x >= this.
|
|
23
|
+
options.rectangleCutOption.position.x >= this._wordWrapWidth ||
|
|
24
24
|
options.rectangleCutOption.position.y < 0) {
|
|
25
25
|
throw new Error('Rectangle cut position is out of bounds');
|
|
26
26
|
}
|
|
27
|
-
this.
|
|
27
|
+
this._cut = {
|
|
28
28
|
direction: options.rectangleCutOption.direction,
|
|
29
|
-
rectangle: this.
|
|
29
|
+
rectangle: this._convertRectangleCut(options.rectangleCutOption)
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
isSpaceAvailable(size) {
|
|
34
|
-
let lineHeightToBe = Math.max(this.
|
|
35
|
-
let lineEnd = this.
|
|
36
|
-
let cursorToBe = this.
|
|
34
|
+
let lineHeightToBe = Math.max(this._currentLineHeight, size.y);
|
|
35
|
+
let lineEnd = this._getLineEnd(this._linePosition.y, this._linePosition.y + lineHeightToBe);
|
|
36
|
+
let cursorToBe = this._cursorPosition + size.x;
|
|
37
37
|
return cursorToBe <= lineEnd;
|
|
38
38
|
}
|
|
39
39
|
insertWord(chunk) {
|
|
40
|
-
let lineHeightToBe = Math.max(this.
|
|
41
|
-
if (this.
|
|
42
|
-
let lineStart = this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
40
|
+
let lineHeightToBe = Math.max(this._currentLineHeight, chunk.style.height);
|
|
41
|
+
if (this._currentLine.length === 0) {
|
|
42
|
+
let lineStart = this._getLineStart(this._linePosition.y, this._linePosition.y + lineHeightToBe);
|
|
43
|
+
this._linePosition = new helpers_lib_1.Vector(lineStart, this._linePosition.y);
|
|
44
|
+
this._cursorPosition = this._linePosition.x;
|
|
45
45
|
}
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
46
|
+
this._currentLine.push({ chunk, position: new helpers_lib_1.Vector(this._cursorPosition, this._linePosition.y) });
|
|
47
|
+
this._currentLineHeight = lineHeightToBe;
|
|
48
|
+
this._cursorPosition += chunk.style.width;
|
|
49
49
|
}
|
|
50
50
|
newLine() {
|
|
51
|
-
let lineY = this.
|
|
52
|
-
let lineX = this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
51
|
+
let lineY = this._linePosition.y + this._currentLineHeight;
|
|
52
|
+
let lineX = this._getLineStart(lineY, lineY);
|
|
53
|
+
this._flushCurrentLine();
|
|
54
|
+
this._linePosition = new helpers_lib_1.Vector(lineX, lineY);
|
|
55
|
+
this._cursorPosition = this._linePosition.x;
|
|
56
|
+
this._currentLineHeight = 0;
|
|
57
57
|
}
|
|
58
58
|
print() {
|
|
59
|
-
this.
|
|
60
|
-
return this.
|
|
59
|
+
this._flushCurrentLine();
|
|
60
|
+
return this._lines;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
if (this.
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
62
|
+
_flushCurrentLine() {
|
|
63
|
+
if (this._currentLine.length > 0) {
|
|
64
|
+
this._lines.push(this._alignLine(this._currentLine));
|
|
65
|
+
this._currentLine = [];
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
line = this.
|
|
70
|
-
line = this.
|
|
68
|
+
_alignLine(line) {
|
|
69
|
+
line = this._verticallyAlign(line);
|
|
70
|
+
line = this._horizontallyAlign(line);
|
|
71
71
|
return line;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
if (this.
|
|
73
|
+
_horizontallyAlign(line) {
|
|
74
|
+
if (this._horizontalAlignment === 'left') {
|
|
75
75
|
return line;
|
|
76
76
|
}
|
|
77
|
-
let linePositionEnd = this.
|
|
78
|
-
let lineStart = this.
|
|
79
|
-
let lineEnd = this.
|
|
77
|
+
let linePositionEnd = this._linePosition.y + this._currentLineHeight;
|
|
78
|
+
let lineStart = this._getLineStart(this._linePosition.y, linePositionEnd);
|
|
79
|
+
let lineEnd = this._getLineEnd(this._linePosition.y, linePositionEnd);
|
|
80
80
|
let lineWidth = lineEnd - lineStart;
|
|
81
81
|
let totalWidth = Math.min(lineWidth, line.reduce((acc, chunk) => acc + chunk.chunk.style.width, 0));
|
|
82
82
|
let offset;
|
|
83
|
-
if (this.
|
|
83
|
+
if (this._horizontalAlignment === 'center') {
|
|
84
84
|
offset = (lineWidth - totalWidth) / 2;
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
@@ -94,12 +94,12 @@ class RichTextTypewriter {
|
|
|
94
94
|
return positionedChunk;
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
_verticallyAlign(line) {
|
|
98
98
|
let maxAscent = Math.max(...line.map(chunk => chunk.chunk.style.ascent));
|
|
99
99
|
let maxDescent = Math.max(...line.map(chunk => chunk.chunk.style.descent));
|
|
100
100
|
return line.map(positionedChunk => {
|
|
101
101
|
let offset;
|
|
102
|
-
switch (this.
|
|
102
|
+
switch (this._verticalAlignment) {
|
|
103
103
|
case 'top':
|
|
104
104
|
offset = maxDescent - positionedChunk.chunk.style.descent;
|
|
105
105
|
break;
|
|
@@ -117,31 +117,31 @@ class RichTextTypewriter {
|
|
|
117
117
|
return positionedChunk;
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
if (this.
|
|
122
|
-
if (this.
|
|
123
|
-
let intersectingWithCut = this.
|
|
124
|
-
this.
|
|
120
|
+
_getLineStart(heightStart, heightEnd) {
|
|
121
|
+
if (this._cut) {
|
|
122
|
+
if (this._cut.direction === 'topLeft' || this._cut.direction === 'bottomLeft') {
|
|
123
|
+
let intersectingWithCut = this._cut.rectangle.isPointInside(new helpers_lib_1.Vector(0, heightStart), { includeEdges: false }) ||
|
|
124
|
+
this._cut.rectangle.isPointInside(new helpers_lib_1.Vector(0, heightEnd), { includeEdges: false });
|
|
125
125
|
if (intersectingWithCut) {
|
|
126
|
-
return this.
|
|
126
|
+
return this._cut.rectangle.bottomRight.x;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
return 0;
|
|
131
131
|
}
|
|
132
|
-
|
|
133
|
-
if (this.
|
|
134
|
-
if (this.
|
|
135
|
-
let intersectingWithCut = this.
|
|
136
|
-
this.
|
|
132
|
+
_getLineEnd(heightStart, heightEnd) {
|
|
133
|
+
if (this._cut) {
|
|
134
|
+
if (this._cut.direction === 'topRight' || this._cut.direction === 'bottomRight') {
|
|
135
|
+
let intersectingWithCut = this._cut.rectangle.isPointInside(new helpers_lib_1.Vector(this._wordWrapWidth, heightStart), { includeEdges: false }) ||
|
|
136
|
+
this._cut.rectangle.isPointInside(new helpers_lib_1.Vector(this._wordWrapWidth, heightEnd), { includeEdges: false });
|
|
137
137
|
if (intersectingWithCut) {
|
|
138
|
-
return this.
|
|
138
|
+
return this._cut.rectangle.topLeft.x;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
return this.
|
|
142
|
+
return this._wordWrapWidth;
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
_convertRectangleCut(rectangleCut) {
|
|
145
145
|
let topLeft;
|
|
146
146
|
let bottomRight;
|
|
147
147
|
switch (rectangleCut.direction) {
|
|
@@ -30,12 +30,12 @@ const rich_text_typewriter_1 = require("./rich-text-typewriter");
|
|
|
30
30
|
typewriter.newLine();
|
|
31
31
|
typewriter.insertWord((0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('123', { fontSize: 15 }));
|
|
32
32
|
typewriter.newLine();
|
|
33
|
-
(0, vitest_1.expect)(typewriter['
|
|
33
|
+
(0, vitest_1.expect)(typewriter['_linePosition']).toEqual(new helpers_lib_1.Vector(0, 35));
|
|
34
34
|
});
|
|
35
35
|
(0, vitest_1.test)('insertWord should insert word even if it does not fit', () => {
|
|
36
36
|
const Chunk = (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('01234567890123456789');
|
|
37
37
|
typewriter.insertWord(Chunk);
|
|
38
|
-
(0, vitest_1.expect)(typewriter['
|
|
38
|
+
(0, vitest_1.expect)(typewriter['_currentLine']).toEqual([
|
|
39
39
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('01234567890123456789'), position: new helpers_lib_1.Vector(0, 0) }
|
|
40
40
|
]);
|
|
41
41
|
});
|