geoiq-frontend-ui-kit 2.0.0 → 2.0.2
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/components/atoms/badge/badge.styles.d.ts +2 -2
- package/dist/components/atoms/button/button.styles.d.ts +2 -2
- package/dist/components/atoms/checkbox/checkbox.styles.d.ts +2 -2
- package/dist/components/atoms/switch/switch.styles.d.ts +2 -2
- package/dist/components/molecules/alert/alert.styles.d.ts +1 -1
- package/dist/components/molecules/creatable-multi-combobox/creatable-multi-combobox.d.ts +4 -0
- package/dist/components/molecules/creatable-multi-combobox/creatable-multi-combobox.d.ts.map +1 -0
- package/dist/components/molecules/creatable-multi-combobox/creatable-multi-combobox.types.d.ts +49 -0
- package/dist/components/molecules/creatable-multi-combobox/creatable-multi-combobox.types.d.ts.map +1 -0
- package/dist/components/molecules/creatable-multi-combobox/index.d.ts +4 -0
- package/dist/components/molecules/creatable-multi-combobox/index.d.ts.map +1 -0
- package/dist/components/molecules/single-select/index.d.ts.map +1 -1
- package/dist/components/molecules/single-select/single-select-components.d.ts +3 -1
- package/dist/components/molecules/single-select/single-select-components.d.ts.map +1 -1
- package/dist/components/molecules/single-select/single-select.types.d.ts +9 -0
- package/dist/components/molecules/single-select/single-select.types.d.ts.map +1 -1
- package/dist/components/molecules/split-button/split-button.styles.d.ts +3 -3
- package/dist/components/molecules/swatch-grid/index.d.ts +3 -0
- package/dist/components/molecules/swatch-grid/index.d.ts.map +1 -0
- package/dist/components/molecules/swatch-grid/swatch-grid.d.ts +4 -0
- package/dist/components/molecules/swatch-grid/swatch-grid.d.ts.map +1 -0
- package/dist/components/molecules/swatch-grid/swatch-grid.types.d.ts +17 -0
- package/dist/components/molecules/swatch-grid/swatch-grid.types.d.ts.map +1 -0
- package/dist/components/molecules/tabs/tabs.d.ts.map +1 -1
- package/dist/components/molecules/tabs/tabs.styles.d.ts +2 -2
- package/dist/components/molecules/tabs/tabs.types.d.ts +1 -0
- package/dist/components/molecules/tabs/tabs.types.d.ts.map +1 -1
- package/dist/components/organisms/dialog/dialog.d.ts +1 -1
- package/dist/components/organisms/dialog/dialog.d.ts.map +1 -1
- package/dist/components/organisms/dialog/dialog.types.d.ts +9 -0
- package/dist/components/organisms/dialog/dialog.types.d.ts.map +1 -1
- package/dist/components/organisms/image-editor/components/color-picker.d.ts +7 -0
- package/dist/components/organisms/image-editor/components/color-picker.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/layers-list.d.ts +9 -0
- package/dist/components/organisms/image-editor/components/layers-list.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/panel-adjust.d.ts +9 -0
- package/dist/components/organisms/image-editor/components/panel-adjust.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/panel-crop.d.ts +9 -0
- package/dist/components/organisms/image-editor/components/panel-crop.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/panel-insert.d.ts +9 -0
- package/dist/components/organisms/image-editor/components/panel-insert.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/panel-selected.d.ts +9 -0
- package/dist/components/organisms/image-editor/components/panel-selected.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/panel.d.ts +9 -0
- package/dist/components/organisms/image-editor/components/panel.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/portal-context.d.ts +3 -0
- package/dist/components/organisms/image-editor/components/portal-context.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/ribbon.d.ts +9 -0
- package/dist/components/organisms/image-editor/components/ribbon.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/shape-icons.d.ts +4 -0
- package/dist/components/organisms/image-editor/components/shape-icons.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/stage.d.ts +18 -0
- package/dist/components/organisms/image-editor/components/stage.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/components/status-bar.d.ts +6 -0
- package/dist/components/organisms/image-editor/components/status-bar.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/image-editor-modal.d.ts +10 -0
- package/dist/components/organisms/image-editor/image-editor-modal.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/image-editor.d.ts +5 -0
- package/dist/components/organisms/image-editor/image-editor.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/image-editor.types.d.ts +182 -0
- package/dist/components/organisms/image-editor/image-editor.types.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/index.d.ts +4 -0
- package/dist/components/organisms/image-editor/index.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/native-bridge.d.ts +3 -0
- package/dist/components/organisms/image-editor/native-bridge.d.ts.map +1 -0
- package/dist/components/organisms/image-editor/picture-studio-engine.d.ts +16 -0
- package/dist/components/organisms/image-editor/use-image-editor.d.ts +4 -0
- package/dist/components/organisms/image-editor/use-image-editor.d.ts.map +1 -0
- package/dist/components/organisms/navbar/navbar-desktop.d.ts.map +1 -1
- package/dist/components/organisms/navbar/navbar-extended.d.ts.map +1 -1
- package/dist/components/organisms/navbar/navbar-mobile.d.ts.map +1 -1
- package/dist/components/organisms/navbar/navbar.types.d.ts +17 -0
- package/dist/components/organisms/navbar/navbar.types.d.ts.map +1 -1
- package/dist/components/organisms/sheet/sheet.d.ts +1 -1
- package/dist/components/organisms/sheet/sheet.d.ts.map +1 -1
- package/dist/components/organisms/sheet/sheet.types.d.ts +1 -0
- package/dist/components/organisms/sheet/sheet.types.d.ts.map +1 -1
- package/dist/components/organisms/sidebar/sidebar-components.d.ts +1 -1
- package/dist/components/ui/brand-switcher/brand-switcher.d.ts +5 -0
- package/dist/components/ui/brand-switcher/brand-switcher.d.ts.map +1 -0
- package/dist/components/ui/brand-switcher/brand-switcher.types.d.ts +29 -0
- package/dist/components/ui/brand-switcher/brand-switcher.types.d.ts.map +1 -0
- package/dist/components/ui/brand-switcher/index.d.ts +3 -0
- package/dist/components/ui/brand-switcher/index.d.ts.map +1 -0
- package/dist/components/ui/credit-sheet/credit-sheet.d.ts.map +1 -1
- package/dist/components/ui/credit-sheet/credit-sheet.types.d.ts +3 -0
- package/dist/components/ui/credit-sheet/credit-sheet.types.d.ts.map +1 -1
- package/dist/components/ui/credits-indicator/credits-indicator.d.ts +6 -0
- package/dist/components/ui/credits-indicator/credits-indicator.d.ts.map +1 -0
- package/dist/components/ui/credits-indicator/credits-indicator.styles.d.ts +7 -0
- package/dist/components/ui/credits-indicator/credits-indicator.styles.d.ts.map +1 -0
- package/dist/components/ui/credits-indicator/credits-indicator.types.d.ts +14 -0
- package/dist/components/ui/credits-indicator/credits-indicator.types.d.ts.map +1 -0
- package/dist/components/ui/credits-indicator/index.d.ts +3 -0
- package/dist/components/ui/credits-indicator/index.d.ts.map +1 -0
- package/dist/components/ui/form-renderer/components/form-fields/components/multi-image-picker/index.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/components/form-fields/components/single-image-picker/index.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/components/form-fields/components/taggable-multi-image-picker/index.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/components/form-fields/components/taggable-multi-image-picker-with-input/index.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/components/form-fields/index.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/components/form-read-only-view.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/context/form-values/form-values.context.d.ts +4 -0
- package/dist/components/ui/form-renderer/context/form-values/form-values.context.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/context/form-values/form-values.provider.d.ts +2 -0
- package/dist/components/ui/form-renderer/context/form-values/form-values.provider.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/form-renderer.d.ts +10 -0
- package/dist/components/ui/form-renderer/form-renderer.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/form.enums.d.ts +1 -0
- package/dist/components/ui/form-renderer/form.enums.d.ts.map +1 -1
- package/dist/components/ui/form-renderer/form.types.d.ts +20 -1
- package/dist/components/ui/form-renderer/form.types.d.ts.map +1 -1
- package/dist/components/ui/map-marker-hover-card/components/map-cluster-hover-card.d.ts +1 -1
- package/dist/components/ui/map-marker-hover-card/components/map-cluster-hover-card.d.ts.map +1 -1
- package/dist/components/ui/report-snippet-view/report-snippet-view-components.d.ts.map +1 -1
- package/dist/components/ui/request-credits-view/component/request-credit-dialog.d.ts.map +1 -1
- package/dist/components/ui/request-credits-view/component/request-credit-dialog.types.d.ts +3 -0
- package/dist/components/ui/request-credits-view/component/request-credit-dialog.types.d.ts.map +1 -1
- package/dist/components/ui/request-credits-view/index.d.ts +1 -0
- package/dist/components/ui/request-credits-view/index.d.ts.map +1 -1
- package/dist/components/ui/request-credits-view/request-credits-view.d.ts.map +1 -1
- package/dist/components/ui/request-credits-view/request-credits-view.types.d.ts +3 -0
- package/dist/components/ui/request-credits-view/request-credits-view.types.d.ts.map +1 -1
- package/dist/components/unstyled/spinner/spinner.styles.d.ts +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +210 -193
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +30 -23
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es100.js +120 -10
- package/dist/index.es100.js.map +1 -1
- package/dist/index.es101.js +16 -97
- package/dist/index.es101.js.map +1 -1
- package/dist/index.es102.js +41 -60
- package/dist/index.es102.js.map +1 -1
- package/dist/index.es103.js +13 -54
- package/dist/index.es103.js.map +1 -1
- package/dist/index.es104.js +68 -5
- package/dist/index.es104.js.map +1 -1
- package/dist/index.es105.js +32 -9
- package/dist/index.es105.js.map +1 -1
- package/dist/index.es106.js +19 -32
- package/dist/index.es106.js.map +1 -1
- package/dist/index.es107.js +18 -61
- package/dist/index.es107.js.map +1 -1
- package/dist/index.es108.js +12 -22
- package/dist/index.es108.js.map +1 -1
- package/dist/index.es109.js +98 -22
- package/dist/index.es109.js.map +1 -1
- package/dist/index.es11.js +77 -25
- package/dist/index.es11.js.map +1 -1
- package/dist/index.es110.js +62 -21
- package/dist/index.es110.js.map +1 -1
- package/dist/index.es111.js +48 -174
- package/dist/index.es111.js.map +1 -1
- package/dist/index.es112.js +39 -37
- package/dist/index.es112.js.map +1 -1
- package/dist/index.es113.js +10 -40
- package/dist/index.es113.js.map +1 -1
- package/dist/index.es114.js +88 -37
- package/dist/index.es114.js.map +1 -1
- package/dist/index.es115.js +15 -13
- package/dist/index.es115.js.map +1 -1
- package/dist/index.es116.js +88 -261
- package/dist/index.es116.js.map +1 -1
- package/dist/index.es117.js +14 -9
- package/dist/index.es117.js.map +1 -1
- package/dist/index.es118.js +101 -67
- package/dist/index.es118.js.map +1 -1
- package/dist/index.es119.js +23 -185
- package/dist/index.es119.js.map +1 -1
- package/dist/index.es12.js +26 -14
- package/dist/index.es12.js.map +1 -1
- package/dist/index.es120.js +25 -23
- package/dist/index.es120.js.map +1 -1
- package/dist/index.es121.js +22 -177
- package/dist/index.es121.js.map +1 -1
- package/dist/index.es122.js +43 -7
- package/dist/index.es122.js.map +1 -1
- package/dist/index.es123.js +32 -84
- package/dist/index.es123.js.map +1 -1
- package/dist/index.es124.js +63 -37
- package/dist/index.es124.js.map +1 -1
- package/dist/index.es125.js +180 -11
- package/dist/index.es125.js.map +1 -1
- package/dist/index.es126.js +13 -35
- package/dist/index.es126.js.map +1 -1
- package/dist/index.es127.js +9 -16
- package/dist/index.es127.js.map +1 -1
- package/dist/index.es128.js +68 -5
- package/dist/index.es128.js.map +1 -1
- package/dist/index.es129.js +185 -10
- package/dist/index.es129.js.map +1 -1
- package/dist/index.es13.js +27 -19
- package/dist/index.es13.js.map +1 -1
- package/dist/index.es130.js +22 -10
- package/dist/index.es130.js.map +1 -1
- package/dist/index.es131.js +203 -2
- package/dist/index.es131.js.map +1 -1
- package/dist/index.es132.js +40 -22
- package/dist/index.es132.js.map +1 -1
- package/dist/index.es133.js +11 -257
- package/dist/index.es133.js.map +1 -1
- package/dist/index.es134.js +7 -35
- package/dist/index.es134.js.map +1 -1
- package/dist/index.es135.js +34 -8
- package/dist/index.es135.js.map +1 -1
- package/dist/index.es136.js +36 -78
- package/dist/index.es136.js.map +1 -1
- package/dist/index.es137.js +2 -76
- package/dist/index.es137.js.map +1 -1
- package/dist/index.es138.js +21 -110
- package/dist/index.es138.js.map +1 -1
- package/dist/index.es139.js +14 -107
- package/dist/index.es139.js.map +1 -1
- package/dist/index.es14.js +16 -46
- package/dist/index.es14.js.map +1 -1
- package/dist/index.es140.js +7 -87
- package/dist/index.es140.js.map +1 -1
- package/dist/index.es141.js +21 -128
- package/dist/index.es141.js.map +1 -1
- package/dist/index.es142.js +155 -114
- package/dist/index.es142.js.map +1 -1
- package/dist/index.es143.js +82 -6
- package/dist/index.es143.js.map +1 -1
- package/dist/index.es144.js +8 -0
- package/dist/index.es144.js.map +1 -0
- package/dist/index.es145.js +59 -0
- package/dist/index.es145.js.map +1 -0
- package/dist/index.es146.js +120 -0
- package/dist/index.es146.js.map +1 -0
- package/dist/index.es147.js +325 -0
- package/dist/index.es147.js.map +1 -0
- package/dist/index.es148.js +31 -0
- package/dist/index.es148.js.map +1 -0
- package/dist/index.es149.js +71 -0
- package/dist/index.es149.js.map +1 -0
- package/dist/index.es15.js +18 -21
- package/dist/index.es15.js.map +1 -1
- package/dist/index.es150.js +35 -0
- package/dist/index.es150.js.map +1 -0
- package/dist/index.es151.js +28 -0
- package/dist/index.es151.js.map +1 -0
- package/dist/index.es152.js +41 -0
- package/dist/index.es152.js.map +1 -0
- package/dist/index.es153.js +146 -0
- package/dist/index.es153.js.map +1 -0
- package/dist/index.es154.js +147 -0
- package/dist/index.es154.js.map +1 -0
- package/dist/index.es155.js +50 -0
- package/dist/index.es155.js.map +1 -0
- package/dist/index.es156.js +15 -0
- package/dist/index.es156.js.map +1 -0
- package/dist/index.es157.js +47 -0
- package/dist/index.es157.js.map +1 -0
- package/dist/index.es158.js +8 -0
- package/dist/index.es158.js.map +1 -0
- package/dist/index.es159.js +14 -0
- package/dist/index.es159.js.map +1 -0
- package/dist/index.es16.js +44 -22
- package/dist/index.es16.js.map +1 -1
- package/dist/index.es160.js +14 -0
- package/dist/index.es160.js.map +1 -0
- package/dist/index.es161.js +5 -0
- package/dist/index.es161.js.map +1 -0
- package/dist/index.es162.js +94 -0
- package/dist/index.es162.js.map +1 -0
- package/dist/index.es163.js +216 -0
- package/dist/index.es163.js.map +1 -0
- package/dist/index.es164.js +57 -0
- package/dist/index.es164.js.map +1 -0
- package/dist/index.es165.js +39 -0
- package/dist/index.es165.js.map +1 -0
- package/dist/index.es166.js +36 -0
- package/dist/index.es166.js.map +1 -0
- package/dist/index.es167.js +36 -0
- package/dist/index.es167.js.map +1 -0
- package/dist/index.es168.js +94 -0
- package/dist/index.es168.js.map +1 -0
- package/dist/index.es169.js +120 -0
- package/dist/index.es169.js.map +1 -0
- package/dist/index.es17.js +22 -20
- package/dist/index.es17.js.map +1 -1
- package/dist/index.es170.js +289 -0
- package/dist/index.es170.js.map +1 -0
- package/dist/index.es171.js +38 -0
- package/dist/index.es171.js.map +1 -0
- package/dist/index.es172.js +14 -0
- package/dist/index.es172.js.map +1 -0
- package/dist/index.es173.js +87 -0
- package/dist/index.es173.js.map +1 -0
- package/dist/index.es174.js +79 -0
- package/dist/index.es174.js.map +1 -0
- package/dist/index.es175.js +118 -0
- package/dist/index.es175.js.map +1 -0
- package/dist/index.es176.js +112 -0
- package/dist/index.es176.js.map +1 -0
- package/dist/index.es177.js +90 -0
- package/dist/index.es177.js.map +1 -0
- package/dist/index.es178.js +133 -0
- package/dist/index.es178.js.map +1 -0
- package/dist/index.es179.js +133 -0
- package/dist/index.es179.js.map +1 -0
- package/dist/index.es18.js +23 -73
- package/dist/index.es18.js.map +1 -1
- package/dist/index.es180.js +29 -0
- package/dist/index.es180.js.map +1 -0
- package/dist/index.es181.js +27 -0
- package/dist/index.es181.js.map +1 -0
- package/dist/index.es182.js +9 -0
- package/dist/index.es182.js.map +1 -0
- package/dist/index.es19.js +18 -48
- package/dist/index.es19.js.map +1 -1
- package/dist/index.es2.js +120 -22
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es20.js +70 -45
- package/dist/index.es20.js.map +1 -1
- package/dist/index.es21.js +43 -122
- package/dist/index.es21.js.map +1 -1
- package/dist/index.es22.js +39 -96
- package/dist/index.es22.js.map +1 -1
- package/dist/index.es23.js +113 -152
- package/dist/index.es23.js.map +1 -1
- package/dist/index.es24.js +98 -64
- package/dist/index.es24.js.map +1 -1
- package/dist/index.es25.js +160 -77
- package/dist/index.es25.js.map +1 -1
- package/dist/index.es26.js +69 -51
- package/dist/index.es26.js.map +1 -1
- package/dist/index.es27.js +82 -17
- package/dist/index.es27.js.map +1 -1
- package/dist/index.es28.js +274 -2
- package/dist/index.es28.js.map +1 -1
- package/dist/index.es29.js +55 -5
- package/dist/index.es29.js.map +1 -1
- package/dist/index.es3.js +40 -41
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es30.js +16 -75
- package/dist/index.es30.js.map +1 -1
- package/dist/index.es31.js +2 -28
- package/dist/index.es31.js.map +1 -1
- package/dist/index.es32.js +4 -84
- package/dist/index.es32.js.map +1 -1
- package/dist/index.es33.js +72 -43
- package/dist/index.es33.js.map +1 -1
- package/dist/index.es34.js +25 -68
- package/dist/index.es34.js.map +1 -1
- package/dist/index.es35.js +85 -12
- package/dist/index.es35.js.map +1 -1
- package/dist/index.es36.js +47 -85
- package/dist/index.es36.js.map +1 -1
- package/dist/index.es37.js +63 -32
- package/dist/index.es37.js.map +1 -1
- package/dist/index.es38.js +49 -40
- package/dist/index.es38.js.map +1 -1
- package/dist/index.es39.js +12 -98
- package/dist/index.es39.js.map +1 -1
- package/dist/index.es4.js +17 -17
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es40.js +81 -156
- package/dist/index.es40.js.map +1 -1
- package/dist/index.es41.js +39 -226
- package/dist/index.es41.js.map +1 -1
- package/dist/index.es42.js +40 -269
- package/dist/index.es42.js.map +1 -1
- package/dist/index.es43.js +97 -21
- package/dist/index.es43.js.map +1 -1
- package/dist/index.es44.js +15 -9
- package/dist/index.es44.js.map +1 -1
- package/dist/index.es45.js +64 -20
- package/dist/index.es45.js.map +1 -1
- package/dist/index.es46.js +159 -61
- package/dist/index.es46.js.map +1 -1
- package/dist/index.es47.js +226 -123
- package/dist/index.es47.js.map +1 -1
- package/dist/index.es48.js +300 -109
- package/dist/index.es48.js.map +1 -1
- package/dist/index.es49.js +19 -31
- package/dist/index.es49.js.map +1 -1
- package/dist/index.es5.js +33 -31
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es50.js +8 -142
- package/dist/index.es50.js.map +1 -1
- package/dist/index.es51.js +18 -70
- package/dist/index.es51.js.map +1 -1
- package/dist/index.es52.js +69 -21
- package/dist/index.es52.js.map +1 -1
- package/dist/index.es53.js +143 -103
- package/dist/index.es53.js.map +1 -1
- package/dist/index.es54.js +123 -11
- package/dist/index.es54.js.map +1 -1
- package/dist/index.es55.js +103 -18
- package/dist/index.es55.js.map +1 -1
- package/dist/index.es56.js +73 -11
- package/dist/index.es56.js.map +1 -1
- package/dist/index.es57.js +141 -16
- package/dist/index.es57.js.map +1 -1
- package/dist/index.es58.js +67 -40
- package/dist/index.es58.js.map +1 -1
- package/dist/index.es59.js +22 -86
- package/dist/index.es59.js.map +1 -1
- package/dist/index.es6.js +19 -23
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es60.js +104 -7
- package/dist/index.es60.js.map +1 -1
- package/dist/index.es61.js +11 -41
- package/dist/index.es61.js.map +1 -1
- package/dist/index.es62.js +19 -79
- package/dist/index.es62.js.map +1 -1
- package/dist/index.es63.js +10 -35
- package/dist/index.es63.js.map +1 -1
- package/dist/index.es64.js +16 -86
- package/dist/index.es64.js.map +1 -1
- package/dist/index.es65.js +43 -58
- package/dist/index.es65.js.map +1 -1
- package/dist/index.es66.js +86 -69
- package/dist/index.es66.js.map +1 -1
- package/dist/index.es67.js +7 -32
- package/dist/index.es67.js.map +1 -1
- package/dist/index.es68.js +39 -65
- package/dist/index.es68.js.map +1 -1
- package/dist/index.es69.js +79 -28
- package/dist/index.es69.js.map +1 -1
- package/dist/index.es7.js +38 -43
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es70.js +66 -84
- package/dist/index.es70.js.map +1 -1
- package/dist/index.es71.js +88 -11
- package/dist/index.es71.js.map +1 -1
- package/dist/index.es72.js +59 -46
- package/dist/index.es72.js.map +1 -1
- package/dist/index.es73.js +65 -108
- package/dist/index.es73.js.map +1 -1
- package/dist/index.es74.js +30 -15
- package/dist/index.es74.js.map +1 -1
- package/dist/index.es75.js +56 -35
- package/dist/index.es75.js.map +1 -1
- package/dist/index.es76.js +18 -19
- package/dist/index.es76.js.map +1 -1
- package/dist/index.es77.js +30 -38
- package/dist/index.es77.js.map +1 -1
- package/dist/index.es78.js +85 -28
- package/dist/index.es78.js.map +1 -1
- package/dist/index.es79.js +10 -94
- package/dist/index.es79.js.map +1 -1
- package/dist/index.es8.js +26 -33
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es80.js +47 -2
- package/dist/index.es80.js.map +1 -1
- package/dist/index.es81.js +113 -6
- package/dist/index.es81.js.map +1 -1
- package/dist/index.es82.js +16 -26
- package/dist/index.es82.js.map +1 -1
- package/dist/index.es83.js +42 -109
- package/dist/index.es83.js.map +1 -1
- package/dist/index.es84.js +27 -22
- package/dist/index.es84.js.map +1 -1
- package/dist/index.es85.js +39 -18
- package/dist/index.es85.js.map +1 -1
- package/dist/index.es86.js +27 -18
- package/dist/index.es86.js.map +1 -1
- package/dist/index.es87.js +94 -18
- package/dist/index.es87.js.map +1 -1
- package/dist/index.es88.js +1 -18
- package/dist/index.es88.js.map +1 -1
- package/dist/index.es89.js +6 -49
- package/dist/index.es89.js.map +1 -1
- package/dist/index.es9.js +37 -72
- package/dist/index.es9.js.map +1 -1
- package/dist/index.es90.js +23 -84
- package/dist/index.es90.js.map +1 -1
- package/dist/index.es91.js +96 -99
- package/dist/index.es91.js.map +1 -1
- package/dist/index.es92.js +24 -16
- package/dist/index.es92.js.map +1 -1
- package/dist/index.es93.js +16 -22
- package/dist/index.es93.js.map +1 -1
- package/dist/index.es94.js +17 -100
- package/dist/index.es94.js.map +1 -1
- package/dist/index.es95.js +16 -71
- package/dist/index.es95.js.map +1 -1
- package/dist/index.es96.js +16 -42
- package/dist/index.es96.js.map +1 -1
- package/dist/index.es97.js +9 -32
- package/dist/index.es97.js.map +1 -1
- package/dist/index.es98.js +269 -15
- package/dist/index.es98.js.map +1 -1
- package/dist/index.es99.js +85 -17
- package/dist/index.es99.js.map +1 -1
- package/dist/lib/constants.d.ts +2 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/styles.css +363 -31
- package/dist/ui-kit-preset.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { FONTS as a, VERSION as i } from "./index.es145.js";
|
|
2
|
+
const d = 30;
|
|
3
|
+
function o() {
|
|
4
|
+
const e = document.createElement("canvas");
|
|
5
|
+
return e.width = 0, e.height = 0, e;
|
|
6
|
+
}
|
|
7
|
+
function g(e) {
|
|
8
|
+
return {
|
|
9
|
+
config: e,
|
|
10
|
+
stickers: e.stickers || [],
|
|
11
|
+
listeners: { open: [], close: [], save: [], change: [], load: [] },
|
|
12
|
+
notify: () => {
|
|
13
|
+
},
|
|
14
|
+
sourceCanvas: o(),
|
|
15
|
+
originalCanvas: null,
|
|
16
|
+
layers: [],
|
|
17
|
+
selectedId: null,
|
|
18
|
+
nextId: 1,
|
|
19
|
+
undoStack: [],
|
|
20
|
+
redoStack: [],
|
|
21
|
+
mode: "select",
|
|
22
|
+
viewScale: 1,
|
|
23
|
+
zoom: 1,
|
|
24
|
+
fitScale: 1,
|
|
25
|
+
selectedShapeType: "rect",
|
|
26
|
+
shapeFill: "stroke",
|
|
27
|
+
shapeWidth: 6,
|
|
28
|
+
brushSize: 8,
|
|
29
|
+
brushStyle: "round",
|
|
30
|
+
textFont: a[0].value,
|
|
31
|
+
textSize: 64,
|
|
32
|
+
textColor: "#111111",
|
|
33
|
+
shapeColor: "#111111",
|
|
34
|
+
drawColor: "#111111",
|
|
35
|
+
cropRatio: "free",
|
|
36
|
+
isSaving: !1,
|
|
37
|
+
isLoadingImage: !1,
|
|
38
|
+
statusText: "Ready",
|
|
39
|
+
adj: {
|
|
40
|
+
brightness: 100,
|
|
41
|
+
contrast: 100,
|
|
42
|
+
saturate: 100,
|
|
43
|
+
sepia: 0,
|
|
44
|
+
blur: 0,
|
|
45
|
+
hue: 0,
|
|
46
|
+
filter: "none"
|
|
47
|
+
},
|
|
48
|
+
stickerImageCache: /* @__PURE__ */ new Map(),
|
|
49
|
+
canvasEl: null,
|
|
50
|
+
overlayEl: null,
|
|
51
|
+
textEditorEl: null,
|
|
52
|
+
stageEl: null,
|
|
53
|
+
ctx: null,
|
|
54
|
+
octx: null,
|
|
55
|
+
mounted: !1,
|
|
56
|
+
editingLayer: null,
|
|
57
|
+
editingSelectAll: !1,
|
|
58
|
+
dragMode: null,
|
|
59
|
+
dragStart: null,
|
|
60
|
+
dragOrig: null,
|
|
61
|
+
dragRect: null,
|
|
62
|
+
resizeCorner: null,
|
|
63
|
+
resizeAnchor: null,
|
|
64
|
+
resizeCenter: null,
|
|
65
|
+
resizeAnchorWorld: null,
|
|
66
|
+
rotateStart: null,
|
|
67
|
+
activePointerId: null,
|
|
68
|
+
pendingShape: null,
|
|
69
|
+
pendingStroke: null,
|
|
70
|
+
cropRect: null,
|
|
71
|
+
cropStart: null,
|
|
72
|
+
isOpenFlag: !1
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function s(e, n, l) {
|
|
76
|
+
(e.listeners[n] || []).forEach((r) => {
|
|
77
|
+
try {
|
|
78
|
+
r(l);
|
|
79
|
+
} catch (t) {
|
|
80
|
+
console.error(t);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function h(e) {
|
|
85
|
+
s(e, "change", { state: u(e) }), e.notify();
|
|
86
|
+
}
|
|
87
|
+
function S(e) {
|
|
88
|
+
return e.selectedId != null ? e.layers.find((n) => n.id === e.selectedId) : null;
|
|
89
|
+
}
|
|
90
|
+
function f(e) {
|
|
91
|
+
e.adj.brightness = 100, e.adj.contrast = 100, e.adj.saturate = 100, e.adj.sepia = 0, e.adj.blur = 0, e.adj.hue = 0, e.adj.filter = "none";
|
|
92
|
+
}
|
|
93
|
+
function u(e) {
|
|
94
|
+
return e.sourceCanvas.width ? {
|
|
95
|
+
version: i,
|
|
96
|
+
image: e.sourceCanvas.toDataURL("image/png"),
|
|
97
|
+
width: e.sourceCanvas.width,
|
|
98
|
+
height: e.sourceCanvas.height,
|
|
99
|
+
adjustments: { ...e.adj },
|
|
100
|
+
layers: JSON.parse(
|
|
101
|
+
JSON.stringify(
|
|
102
|
+
e.layers.map((n) => {
|
|
103
|
+
const l = { ...n };
|
|
104
|
+
return delete l._editing, l;
|
|
105
|
+
})
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
} : null;
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
d as MAX_HISTORY,
|
|
112
|
+
g as createState,
|
|
113
|
+
s as emit,
|
|
114
|
+
h as emitChange,
|
|
115
|
+
o as emptySourceCanvas,
|
|
116
|
+
S as getSel,
|
|
117
|
+
u as getState,
|
|
118
|
+
f as resetAdjValues
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=index.es146.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es146.js","sources":["../src/components/organisms/image-editor/engine/state.js"],"sourcesContent":["import { FONTS, VERSION } from './constants.js'\n\nexport const MAX_HISTORY = 30\n\nexport function emptySourceCanvas() {\n const c = document.createElement('canvas')\n c.width = 0\n c.height = 0\n return c\n}\n\nexport function createState(config) {\n return {\n config,\n stickers: config.stickers || [],\n listeners: { open: [], close: [], save: [], change: [], load: [] },\n notify: () => {},\n\n sourceCanvas: emptySourceCanvas(),\n originalCanvas: null,\n layers: [],\n selectedId: null,\n nextId: 1,\n undoStack: [],\n redoStack: [],\n\n mode: 'select',\n viewScale: 1,\n zoom: 1,\n fitScale: 1,\n selectedShapeType: 'rect',\n shapeFill: 'stroke',\n shapeWidth: 6,\n brushSize: 8,\n brushStyle: 'round',\n textFont: FONTS[0].value,\n textSize: 64,\n textColor: '#111111',\n shapeColor: '#111111',\n drawColor: '#111111',\n cropRatio: 'free',\n isSaving: false,\n isLoadingImage: false,\n statusText: 'Ready',\n adj: {\n brightness: 100,\n contrast: 100,\n saturate: 100,\n sepia: 0,\n blur: 0,\n hue: 0,\n filter: 'none',\n },\n stickerImageCache: new Map(),\n\n canvasEl: null,\n overlayEl: null,\n textEditorEl: null,\n stageEl: null,\n ctx: null,\n octx: null,\n mounted: false,\n\n editingLayer: null,\n editingSelectAll: false,\n\n dragMode: null,\n dragStart: null,\n dragOrig: null,\n dragRect: null,\n resizeCorner: null,\n resizeAnchor: null,\n resizeCenter: null,\n resizeAnchorWorld: null,\n rotateStart: null,\n activePointerId: null,\n pendingShape: null,\n pendingStroke: null,\n cropRect: null,\n cropStart: null,\n\n isOpenFlag: false,\n }\n}\n\nexport function emit(state, ev, payload) {\n ;(state.listeners[ev] || []).forEach((fn) => {\n try {\n fn(payload)\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(e)\n }\n })\n}\n\nexport function emitChange(state) {\n emit(state, 'change', { state: getState(state) })\n state.notify()\n}\n\nexport function getSel(state) {\n return state.selectedId != null\n ? state.layers.find((l) => l.id === state.selectedId)\n : null\n}\n\nexport function resetAdjValues(state) {\n state.adj.brightness = 100\n state.adj.contrast = 100\n state.adj.saturate = 100\n state.adj.sepia = 0\n state.adj.blur = 0\n state.adj.hue = 0\n state.adj.filter = 'none'\n}\n\nexport function getState(state) {\n if (!state.sourceCanvas.width) return null\n return {\n version: VERSION,\n image: state.sourceCanvas.toDataURL('image/png'),\n width: state.sourceCanvas.width,\n height: state.sourceCanvas.height,\n adjustments: { ...state.adj },\n layers: JSON.parse(\n JSON.stringify(\n state.layers.map((L) => {\n const c = { ...L }\n delete c._editing\n return c\n })\n )\n ),\n }\n}\n"],"names":["MAX_HISTORY","emptySourceCanvas","c","createState","config","FONTS","emit","state","ev","payload","fn","e","emitChange","getState","getSel","l","resetAdjValues","VERSION","L"],"mappings":";AAEY,MAACA,IAAc;AAEpB,SAASC,IAAoB;AAClC,QAAMC,IAAI,SAAS,cAAc,QAAQ;AACzC,SAAAA,EAAE,QAAQ,GACVA,EAAE,SAAS,GACJA;AACT;AAEO,SAASC,EAAYC,GAAQ;AAClC,SAAO;AAAA,IACL,QAAAA;AAAA,IACA,UAAUA,EAAO,YAAY,CAAA;AAAA,IAC7B,WAAW,EAAE,MAAM,CAAA,GAAI,OAAO,CAAA,GAAI,MAAM,CAAA,GAAI,QAAQ,IAAI,MAAM,CAAA,EAAE;AAAA,IAChE,QAAQ,MAAM;AAAA,IAAC;AAAA,IAEf,cAAcH,EAAiB;AAAA,IAC/B,gBAAgB;AAAA,IAChB,QAAQ,CAAA;AAAA,IACR,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,WAAW,CAAA;AAAA,IACX,WAAW,CAAA;AAAA,IAEX,MAAM;AAAA,IACN,WAAW;AAAA,IACX,MAAM;AAAA,IACN,UAAU;AAAA,IACV,mBAAmB;AAAA,IACnB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,UAAUI,EAAM,CAAC,EAAE;AAAA,IACnB,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,KAAK;AAAA,MACH,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,UAAU;AAAA,MACV,OAAO;AAAA,MACP,MAAM;AAAA,MACN,KAAK;AAAA,MACL,QAAQ;AAAA,IACd;AAAA,IACI,mBAAmB,oBAAI,IAAG;AAAA,IAE1B,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IACd,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,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EAAM,IAAG;AAAA,IAC3B,QAAQ,KAAK;AAAA,MACX,KAAK;AAAA,QACHA,EAAM,OAAO,IAAI,CAACW,MAAM;AACtB,gBAAMhB,IAAI,EAAE,GAAGgB,EAAC;AAChB,wBAAOhB,EAAE,UACFA;AAAA,QACT,CAAC;AAAA,MACT;AAAA,IACA;AAAA,EACA,IAhBwC;AAiBxC;"}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { supportsContextFilter as k } from "./index.es162.js";
|
|
2
|
+
import { FILTER_CSS as T } from "./index.es145.js";
|
|
3
|
+
function C(t) {
|
|
4
|
+
const { adj: e } = t;
|
|
5
|
+
let n = `brightness(${e.brightness}%) contrast(${e.contrast}%) saturate(${e.saturate}%) sepia(${e.sepia}%) blur(${e.blur}px) hue-rotate(${e.hue}deg)`;
|
|
6
|
+
return e.filter !== "none" && (n += " " + T[e.filter]), n.trim();
|
|
7
|
+
}
|
|
8
|
+
const R = 0.25, A = 4, m = 1.25;
|
|
9
|
+
function v(t) {
|
|
10
|
+
const n = Math.min(
|
|
11
|
+
(t.stageEl.clientWidth - 48) / t.sourceCanvas.width,
|
|
12
|
+
(t.stageEl.clientHeight - 48) / t.sourceCanvas.height,
|
|
13
|
+
1
|
|
14
|
+
);
|
|
15
|
+
t.fitScale = n;
|
|
16
|
+
const o = n * t.zoom;
|
|
17
|
+
t.viewScale = o;
|
|
18
|
+
const a = Math.round(t.sourceCanvas.width * o), r = Math.round(t.sourceCanvas.height * o);
|
|
19
|
+
t.canvasEl.style.width = t.overlayEl.style.width = a + "px", t.canvasEl.style.height = t.overlayEl.style.height = r + "px";
|
|
20
|
+
}
|
|
21
|
+
function u(t, e) {
|
|
22
|
+
if (t.zoom = Math.min(A, Math.max(R, e)), !t.mounted || !t.sourceCanvas.width) {
|
|
23
|
+
t.notify();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
v(t), I(t), t.notify();
|
|
27
|
+
}
|
|
28
|
+
function J(t) {
|
|
29
|
+
u(t, t.zoom * m);
|
|
30
|
+
}
|
|
31
|
+
function V(t) {
|
|
32
|
+
u(t, t.zoom / m);
|
|
33
|
+
}
|
|
34
|
+
function j(t) {
|
|
35
|
+
u(t, 1);
|
|
36
|
+
}
|
|
37
|
+
function q(t) {
|
|
38
|
+
t.canvasEl.width = t.overlayEl.width = t.sourceCanvas.width, t.canvasEl.height = t.overlayEl.height = t.sourceCanvas.height, v(t);
|
|
39
|
+
}
|
|
40
|
+
function H(t) {
|
|
41
|
+
const { ctx: e, canvasEl: n, sourceCanvas: o } = t;
|
|
42
|
+
e.clearRect(0, 0, n.width, n.height);
|
|
43
|
+
const a = C(t);
|
|
44
|
+
if (k()) {
|
|
45
|
+
n.style.filter = "", e.filter = a, e.drawImage(o, 0, 0), e.filter = "none";
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
n.style.filter = a, e.drawImage(o, 0, 0);
|
|
49
|
+
}
|
|
50
|
+
function U(t) {
|
|
51
|
+
!t.mounted || !t.sourceCanvas.width || (H(t), I(t));
|
|
52
|
+
}
|
|
53
|
+
const g = 1.1;
|
|
54
|
+
function S(t, e) {
|
|
55
|
+
t.octx.font = `${e.size}px ${e.font}`;
|
|
56
|
+
const n = Math.max(e.boxWidth, 1), o = [];
|
|
57
|
+
return e.text.split(`
|
|
58
|
+
`).forEach((a) => {
|
|
59
|
+
const r = a.split(" ");
|
|
60
|
+
let i = "";
|
|
61
|
+
r.forEach((h) => {
|
|
62
|
+
const s = i ? i + " " + h : h;
|
|
63
|
+
i && t.octx.measureText(s).width > n ? (o.push(i), i = h) : i = s;
|
|
64
|
+
}), o.push(i);
|
|
65
|
+
}), o;
|
|
66
|
+
}
|
|
67
|
+
function c(t, e) {
|
|
68
|
+
if (e.type === "text") {
|
|
69
|
+
const n = S(t, e);
|
|
70
|
+
return {
|
|
71
|
+
x: e.x,
|
|
72
|
+
y: e.y,
|
|
73
|
+
w: e.boxWidth,
|
|
74
|
+
h: n.length * e.size * g
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (e.type === "shape" || e.type === "sticker")
|
|
78
|
+
return {
|
|
79
|
+
x: Math.min(e.x, e.x + e.w),
|
|
80
|
+
y: Math.min(e.y, e.y + e.h),
|
|
81
|
+
w: Math.abs(e.w),
|
|
82
|
+
h: Math.abs(e.h)
|
|
83
|
+
};
|
|
84
|
+
if (e.type === "stroke") {
|
|
85
|
+
let n = 1 / 0, o = 1 / 0, a = -1 / 0, r = -1 / 0;
|
|
86
|
+
e.points.forEach((h) => {
|
|
87
|
+
n = Math.min(n, h.x), o = Math.min(o, h.y), a = Math.max(a, h.x), r = Math.max(r, h.y);
|
|
88
|
+
});
|
|
89
|
+
const i = e.width / 2;
|
|
90
|
+
return { x: n - i, y: o - i, w: a - n + i * 2, h: r - o + i * 2 };
|
|
91
|
+
}
|
|
92
|
+
return { x: 0, y: 0, w: 0, h: 0 };
|
|
93
|
+
}
|
|
94
|
+
function K(t, e) {
|
|
95
|
+
if (e.type !== "text") return;
|
|
96
|
+
const n = t.sourceCanvas.height - e.y;
|
|
97
|
+
for (; e.size > 10 && c(t, e).h > n && n > 0; )
|
|
98
|
+
e.size -= 1;
|
|
99
|
+
}
|
|
100
|
+
function Q(t, e) {
|
|
101
|
+
if (e.type !== "text") return;
|
|
102
|
+
const n = t.sourceCanvas.width - e.x;
|
|
103
|
+
e.boxWidth = Math.round(Math.max(20, Math.min(e.boxWidth, n)));
|
|
104
|
+
}
|
|
105
|
+
function E(t) {
|
|
106
|
+
return [
|
|
107
|
+
{ corner: "tl", x: t.x, y: t.y },
|
|
108
|
+
{ corner: "tr", x: t.x + t.w, y: t.y },
|
|
109
|
+
{ corner: "bl", x: t.x, y: t.y + t.h },
|
|
110
|
+
{ corner: "br", x: t.x + t.w, y: t.y + t.h }
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
const w = [
|
|
114
|
+
"line",
|
|
115
|
+
"dashedLine",
|
|
116
|
+
"arrow",
|
|
117
|
+
"dashedArrow",
|
|
118
|
+
"doubleArrow",
|
|
119
|
+
"dashedDoubleArrow"
|
|
120
|
+
], z = ["dashedLine", "dashedArrow", "dashedDoubleArrow"], D = {
|
|
121
|
+
arrow: ["end"],
|
|
122
|
+
dashedArrow: ["end"],
|
|
123
|
+
doubleArrow: ["end", "start"],
|
|
124
|
+
dashedDoubleArrow: ["end", "start"]
|
|
125
|
+
};
|
|
126
|
+
function W(t) {
|
|
127
|
+
const e = Math.max(1, t || 1);
|
|
128
|
+
return [Math.max(6, e * 2.5), Math.max(4, e * 1.75)];
|
|
129
|
+
}
|
|
130
|
+
function M(t, e, n, o, a) {
|
|
131
|
+
t.beginPath(), t.moveTo(e, n), t.lineTo(
|
|
132
|
+
e - a * Math.cos(o - Math.PI / 6),
|
|
133
|
+
n - a * Math.sin(o - Math.PI / 6)
|
|
134
|
+
), t.moveTo(e, n), t.lineTo(
|
|
135
|
+
e - a * Math.cos(o + Math.PI / 6),
|
|
136
|
+
n - a * Math.sin(o + Math.PI / 6)
|
|
137
|
+
), t.stroke();
|
|
138
|
+
}
|
|
139
|
+
const _ = 26, O = 6;
|
|
140
|
+
function y(t, e) {
|
|
141
|
+
const n = c(t, e);
|
|
142
|
+
return { x: n.x + n.w / 2, y: n.y + n.h / 2 };
|
|
143
|
+
}
|
|
144
|
+
function d(t, e, n) {
|
|
145
|
+
if (!n) return { x: t.x, y: t.y };
|
|
146
|
+
const o = n * Math.PI / 180, a = Math.cos(o), r = Math.sin(o), i = t.x - e.x, h = t.y - e.y;
|
|
147
|
+
return { x: e.x + i * a - h * r, y: e.y + i * r + h * a };
|
|
148
|
+
}
|
|
149
|
+
function X(t, e, n, o) {
|
|
150
|
+
const a = e.rotation || 0;
|
|
151
|
+
if (!a) {
|
|
152
|
+
o();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const r = d(n, y(t, e), a);
|
|
156
|
+
o();
|
|
157
|
+
const i = d(n, y(t, e), a);
|
|
158
|
+
e.x += r.x - i.x, e.y += r.y - i.y;
|
|
159
|
+
}
|
|
160
|
+
function $(t, e, n) {
|
|
161
|
+
return d(n, y(t, e), -(e.rotation || 0));
|
|
162
|
+
}
|
|
163
|
+
function b(t, e) {
|
|
164
|
+
const n = c(t, e);
|
|
165
|
+
return {
|
|
166
|
+
x: n.x + n.w / 2,
|
|
167
|
+
y: n.y + n.h + _ / t.viewScale
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function N(t, e) {
|
|
171
|
+
const n = b(t, e);
|
|
172
|
+
return d(n, y(t, e), e.rotation || 0);
|
|
173
|
+
}
|
|
174
|
+
function Y(t, e, n) {
|
|
175
|
+
const o = N(t, n);
|
|
176
|
+
return Math.hypot(e.x - o.x, e.y - o.y) <= 14 / t.viewScale;
|
|
177
|
+
}
|
|
178
|
+
function L(t, e, n) {
|
|
179
|
+
if (n.type === "stroke") return null;
|
|
180
|
+
const o = 12 / t.viewScale, a = $(t, n, e);
|
|
181
|
+
if (n.type === "shape" && w.includes(n.shape)) {
|
|
182
|
+
const s = [
|
|
183
|
+
{ corner: "start", x: n.x, y: n.y },
|
|
184
|
+
{ corner: "end", x: n.x + n.w, y: n.y + n.h }
|
|
185
|
+
].find(
|
|
186
|
+
(l) => Math.abs(a.x - l.x) < o && Math.abs(a.y - l.y) < o
|
|
187
|
+
);
|
|
188
|
+
return s ? s.corner : null;
|
|
189
|
+
}
|
|
190
|
+
const r = c(t, n), i = E(r).find(
|
|
191
|
+
(h) => Math.abs(a.x - h.x) < o && Math.abs(a.y - h.y) < o
|
|
192
|
+
);
|
|
193
|
+
return i ? i.corner : null;
|
|
194
|
+
}
|
|
195
|
+
function p(t, e, n) {
|
|
196
|
+
if (!n._editing) {
|
|
197
|
+
if (e.save(), n.type !== "stroke" || n.rotation) {
|
|
198
|
+
const o = c(t, n), a = o.x + o.w / 2, r = o.y + o.h / 2;
|
|
199
|
+
e.translate(a, r), n.rotation && e.rotate(n.rotation * Math.PI / 180), (n.flipH || n.flipV) && e.scale(n.flipH ? -1 : 1, n.flipV ? -1 : 1), e.translate(-a, -r);
|
|
200
|
+
}
|
|
201
|
+
if (n.type === "text") {
|
|
202
|
+
e.font = `${n.size}px ${n.font}`, e.fillStyle = n.color, e.textBaseline = "top", e.shadowColor = "rgba(0,0,0,.22)", e.shadowBlur = n.size * 0.05, e.shadowOffsetY = n.size * 0.02;
|
|
203
|
+
const o = n.size * g;
|
|
204
|
+
S(t, n).forEach((a, r) => {
|
|
205
|
+
e.fillText(a, n.x, n.y + r * o);
|
|
206
|
+
});
|
|
207
|
+
} else if (n.type === "shape") {
|
|
208
|
+
e.strokeStyle = n.color, e.fillStyle = n.color, e.lineWidth = n.width, e.lineCap = "round", e.lineJoin = "round";
|
|
209
|
+
const o = n.x, a = n.y, r = n.w, i = n.h;
|
|
210
|
+
if (n.shape === "rect")
|
|
211
|
+
n.fill === "fill" ? e.fillRect(o, a, r, i) : e.strokeRect(o, a, r, i);
|
|
212
|
+
else if (n.shape === "ellipse")
|
|
213
|
+
e.beginPath(), e.ellipse(
|
|
214
|
+
o + r / 2,
|
|
215
|
+
a + i / 2,
|
|
216
|
+
Math.abs(r / 2),
|
|
217
|
+
Math.abs(i / 2),
|
|
218
|
+
0,
|
|
219
|
+
0,
|
|
220
|
+
Math.PI * 2
|
|
221
|
+
), n.fill === "fill" ? e.fill() : e.stroke();
|
|
222
|
+
else if (n.shape === "circle") {
|
|
223
|
+
const h = Math.min(Math.abs(r), Math.abs(i)) / 2;
|
|
224
|
+
e.beginPath(), e.arc(o + r / 2, a + i / 2, h, 0, Math.PI * 2), n.fill === "fill" ? e.fill() : e.stroke();
|
|
225
|
+
} else if (w.includes(n.shape)) {
|
|
226
|
+
const h = o + r, s = a + i, l = z.includes(n.shape);
|
|
227
|
+
l && (e.lineCap = "butt", e.setLineDash(W(n.width))), e.beginPath(), e.moveTo(o, a), e.lineTo(h, s), e.stroke(), l && (e.setLineDash([]), e.lineCap = "round");
|
|
228
|
+
const x = Math.atan2(i, r), f = Math.max(14, n.width * 3);
|
|
229
|
+
(D[n.shape] || []).forEach((P) => {
|
|
230
|
+
P === "end" ? M(e, h, s, x, f) : M(e, o, a, x + Math.PI, f);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
} else if (n.type === "stroke")
|
|
234
|
+
e.strokeStyle = n.color, e.lineWidth = n.width, e.lineCap = "round", e.lineJoin = "round", e.globalAlpha = n.style === "highlight" ? 0.35 : 1, e.beginPath(), n.points.forEach(
|
|
235
|
+
(o, a) => a === 0 ? e.moveTo(o.x, o.y) : e.lineTo(o.x, o.y)
|
|
236
|
+
), n.points.length === 1 && e.lineTo(n.points[0].x + 0.1, n.points[0].y + 0.1), e.stroke();
|
|
237
|
+
else if (n.type === "sticker") {
|
|
238
|
+
const o = t.stickerImageCache.get(n.src);
|
|
239
|
+
o && o.complete && o.naturalWidth && e.drawImage(o, n.x, n.y, n.w, n.h);
|
|
240
|
+
}
|
|
241
|
+
e.restore();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function B(t) {
|
|
245
|
+
return {
|
|
246
|
+
x: Math.min(t.x, t.x + t.w),
|
|
247
|
+
y: Math.min(t.y, t.y + t.h),
|
|
248
|
+
w: Math.abs(t.w),
|
|
249
|
+
h: Math.abs(t.h)
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function F(t) {
|
|
253
|
+
const { cropRect: e, overlayEl: n, octx: o, sourceCanvas: a } = t;
|
|
254
|
+
if (!e) return;
|
|
255
|
+
const r = B(e), i = n.width, h = n.height;
|
|
256
|
+
o.save(), o.fillStyle = "rgba(0,0,0,.45)", o.fillRect(0, 0, i, Math.max(0, r.y)), o.fillRect(0, Math.min(h, r.y + r.h), i, Math.max(0, h - (r.y + r.h))), o.fillRect(0, r.y, Math.max(0, r.x), r.h), o.fillRect(Math.min(i, r.x + r.w), r.y, Math.max(0, i - (r.x + r.w)), r.h), o.strokeStyle = "#fff", o.lineWidth = Math.max(1, a.width / 500), o.setLineDash([8, 6]), o.strokeRect(r.x, r.y, r.w, r.h), o.restore();
|
|
257
|
+
}
|
|
258
|
+
function I(t) {
|
|
259
|
+
const { octx: e, overlayEl: n, layers: o, mode: a, selectedId: r } = t;
|
|
260
|
+
if (e.clearRect(0, 0, n.width, n.height), o.forEach((i) => {
|
|
261
|
+
try {
|
|
262
|
+
p(t, e, i);
|
|
263
|
+
} catch (h) {
|
|
264
|
+
console.error("[image-editor] failed to paint layer", i.id, i.type, h);
|
|
265
|
+
}
|
|
266
|
+
}), a === "select" && r != null) {
|
|
267
|
+
const i = o.find((h) => h.id === r);
|
|
268
|
+
if (i) {
|
|
269
|
+
const h = c(t, i);
|
|
270
|
+
if (e.save(), i.rotation) {
|
|
271
|
+
const l = y(t, i);
|
|
272
|
+
e.translate(l.x, l.y), e.rotate(i.rotation * Math.PI / 180), e.translate(-l.x, -l.y);
|
|
273
|
+
}
|
|
274
|
+
if (e.strokeStyle = "#2f5fd2", e.lineWidth = Math.max(1.2, 1.5 / t.viewScale), e.setLineDash([6 / t.viewScale, 4 / t.viewScale]), e.strokeRect(h.x - 4, h.y - 4, h.w + 8, h.h + 8), e.setLineDash([]), i.type !== "stroke") {
|
|
275
|
+
const l = 9 / t.viewScale;
|
|
276
|
+
e.fillStyle = "#fff", e.strokeStyle = "#2f5fd2", (i.type === "shape" && w.includes(i.shape) ? [
|
|
277
|
+
{ x: i.x, y: i.y },
|
|
278
|
+
{ x: i.x + i.w, y: i.y + i.h }
|
|
279
|
+
] : E(h)).forEach((f) => {
|
|
280
|
+
e.fillRect(f.x - l / 2, f.y - l / 2, l, l), e.strokeRect(f.x - l / 2, f.y - l / 2, l, l);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
const s = b(t, i);
|
|
284
|
+
e.strokeStyle = "#2f5fd2", e.fillStyle = "#fff", e.beginPath(), e.moveTo(s.x, h.y + h.h + 4), e.lineTo(s.x, s.y), e.stroke(), e.beginPath(), e.arc(
|
|
285
|
+
s.x,
|
|
286
|
+
s.y,
|
|
287
|
+
O / t.viewScale,
|
|
288
|
+
0,
|
|
289
|
+
Math.PI * 2
|
|
290
|
+
), e.fill(), e.stroke(), e.restore();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
t.pendingShape && p(t, e, t.pendingShape), a === "crop" && t.cropRect && F(t);
|
|
294
|
+
}
|
|
295
|
+
export {
|
|
296
|
+
w as DIRECTIONAL_SHAPES,
|
|
297
|
+
g as TEXT_LINE_HEIGHT,
|
|
298
|
+
A as ZOOM_MAX,
|
|
299
|
+
R as ZOOM_MIN,
|
|
300
|
+
u as applyZoom,
|
|
301
|
+
C as baseFilter,
|
|
302
|
+
Q as clampBoxWidth,
|
|
303
|
+
K as clampTextSize,
|
|
304
|
+
E as cornerPoints,
|
|
305
|
+
F as drawCropOverlay,
|
|
306
|
+
v as fitStage,
|
|
307
|
+
X as keepingFixed,
|
|
308
|
+
c as layerBounds,
|
|
309
|
+
y as layerCenter,
|
|
310
|
+
B as normRect,
|
|
311
|
+
L as onResizeHandle,
|
|
312
|
+
Y as onRotateHandle,
|
|
313
|
+
p as paintLayer,
|
|
314
|
+
U as render,
|
|
315
|
+
H as renderBase,
|
|
316
|
+
I as renderOverlay,
|
|
317
|
+
d as rotatePoint,
|
|
318
|
+
q as syncCanvasSize,
|
|
319
|
+
$ as toLayerSpace,
|
|
320
|
+
S as wrapTextLines,
|
|
321
|
+
J as zoomIn,
|
|
322
|
+
V as zoomOut,
|
|
323
|
+
j as zoomToFit
|
|
324
|
+
};
|
|
325
|
+
//# sourceMappingURL=index.es147.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es147.js","sources":["../src/components/organisms/image-editor/engine/rendering.js"],"sourcesContent":["import { supportsContextFilter } from './canvas-filter.js'\nimport { FILTER_CSS } from './constants.js'\n\nexport function baseFilter(state) {\n const { adj } = state\n let f = `brightness(${adj.brightness}%) contrast(${adj.contrast}%) saturate(${adj.saturate}%) sepia(${adj.sepia}%) blur(${adj.blur}px) hue-rotate(${adj.hue}deg)`\n if (adj.filter !== 'none') f += ' ' + FILTER_CSS[adj.filter]\n return f.trim()\n}\n\nexport const ZOOM_MIN = 0.25\nexport const ZOOM_MAX = 4\nconst ZOOM_STEP = 1.25\n\nexport function fitStage(state) {\n const pad = 48\n const fitScale = Math.min(\n (state.stageEl.clientWidth - pad) / state.sourceCanvas.width,\n (state.stageEl.clientHeight - pad) / state.sourceCanvas.height,\n 1\n )\n state.fitScale = fitScale\n const scale = fitScale * state.zoom\n state.viewScale = scale\n const w = Math.round(state.sourceCanvas.width * scale),\n h = Math.round(state.sourceCanvas.height * scale)\n state.canvasEl.style.width = state.overlayEl.style.width = w + 'px'\n state.canvasEl.style.height = state.overlayEl.style.height = h + 'px'\n}\n\nexport function applyZoom(state, zoom) {\n state.zoom = Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, zoom))\n if (!state.mounted || !state.sourceCanvas.width) {\n state.notify()\n return\n }\n fitStage(state)\n renderOverlay(state)\n state.notify()\n}\n\nexport function zoomIn(state) {\n applyZoom(state, state.zoom * ZOOM_STEP)\n}\n\nexport function zoomOut(state) {\n applyZoom(state, state.zoom / ZOOM_STEP)\n}\n\nexport function zoomToFit(state) {\n applyZoom(state, 1)\n}\n\nexport function syncCanvasSize(state) {\n state.canvasEl.width = state.overlayEl.width = state.sourceCanvas.width\n state.canvasEl.height = state.overlayEl.height = state.sourceCanvas.height\n fitStage(state)\n}\n\nexport function renderBase(state) {\n const { ctx, canvasEl, sourceCanvas } = state\n ctx.clearRect(0, 0, canvasEl.width, canvasEl.height)\n const filter = baseFilter(state)\n\n if (supportsContextFilter()) {\n canvasEl.style.filter = ''\n ctx.filter = filter\n ctx.drawImage(sourceCanvas, 0, 0)\n ctx.filter = 'none'\n return\n }\n\n canvasEl.style.filter = filter\n ctx.drawImage(sourceCanvas, 0, 0)\n}\n\nexport function render(state) {\n if (!state.mounted || !state.sourceCanvas.width) return\n renderBase(state)\n renderOverlay(state)\n}\n\nexport const TEXT_LINE_HEIGHT = 1.1\n\nexport function wrapTextLines(state, L) {\n state.octx.font = `${L.size}px ${L.font}`\n const maxWidth = Math.max(L.boxWidth, 1)\n const lines = []\n // Split on hard breaks first, then word-wrap each paragraph in the box.\n L.text.split('\\n').forEach((paragraph) => {\n const words = paragraph.split(' ')\n let current = ''\n words.forEach((word) => {\n const test = current ? current + ' ' + word : word\n if (current && state.octx.measureText(test).width > maxWidth) {\n lines.push(current)\n current = word\n } else {\n current = test\n }\n })\n lines.push(current)\n })\n return lines\n}\n\nexport function layerBounds(state, L) {\n if (L.type === 'text') {\n const lines = wrapTextLines(state, L)\n return {\n x: L.x,\n y: L.y,\n w: L.boxWidth,\n h: lines.length * L.size * TEXT_LINE_HEIGHT,\n }\n }\n if (L.type === 'shape' || L.type === 'sticker') {\n return {\n x: Math.min(L.x, L.x + L.w),\n y: Math.min(L.y, L.y + L.h),\n w: Math.abs(L.w),\n h: Math.abs(L.h),\n }\n }\n if (L.type === 'stroke') {\n let a = Infinity,\n b = Infinity,\n cc = -Infinity,\n d = -Infinity\n L.points.forEach((p) => {\n a = Math.min(a, p.x)\n b = Math.min(b, p.y)\n cc = Math.max(cc, p.x)\n d = Math.max(d, p.y)\n })\n const pad = L.width / 2\n return { x: a - pad, y: b - pad, w: cc - a + pad * 2, h: d - b + pad * 2 }\n }\n return { x: 0, y: 0, w: 0, h: 0 }\n}\n\nexport function clampTextSize(state, L) {\n if (L.type !== 'text') return\n const availH = state.sourceCanvas.height - L.y\n while (L.size > 10 && layerBounds(state, L).h > availH && availH > 0) {\n L.size -= 1\n }\n}\n\nexport function clampBoxWidth(state, L) {\n if (L.type !== 'text') return\n const availW = state.sourceCanvas.width - L.x\n L.boxWidth = Math.round(Math.max(20, Math.min(L.boxWidth, availW)))\n}\n\nexport function cornerPoints(b) {\n return [\n { corner: 'tl', x: b.x, y: b.y },\n { corner: 'tr', x: b.x + b.w, y: b.y },\n { corner: 'bl', x: b.x, y: b.y + b.h },\n { corner: 'br', x: b.x + b.w, y: b.y + b.h },\n ]\n}\n\nexport const DIRECTIONAL_SHAPES = [\n 'line',\n 'dashedLine',\n 'arrow',\n 'dashedArrow',\n 'doubleArrow',\n 'dashedDoubleArrow',\n]\n\nconst DASHED_SHAPES = ['dashedLine', 'dashedArrow', 'dashedDoubleArrow']\n\n// Which ends of the shaft get an arrow head.\nconst ARROW_HEAD_ENDS = {\n arrow: ['end'],\n dashedArrow: ['end'],\n doubleArrow: ['end', 'start'],\n dashedDoubleArrow: ['end', 'start'],\n}\n\n// Dash and gap scale with stroke width; the floors keep hairlines visible.\nfunction dashedLineDash(width) {\n const w = Math.max(1, width || 1)\n return [Math.max(6, w * 2.5), Math.max(4, w * 1.75)]\n}\n\nfunction drawArrowHead(c, tipX, tipY, ang, head) {\n c.beginPath()\n c.moveTo(tipX, tipY)\n c.lineTo(\n tipX - head * Math.cos(ang - Math.PI / 6),\n tipY - head * Math.sin(ang - Math.PI / 6)\n )\n c.moveTo(tipX, tipY)\n c.lineTo(\n tipX - head * Math.cos(ang + Math.PI / 6),\n tipY - head * Math.sin(ang + Math.PI / 6)\n )\n c.stroke()\n}\n\nconst ROTATE_HANDLE_GAP = 26\nconst ROTATE_HANDLE_RADIUS = 6\n\nexport function layerCenter(state, L) {\n const b = layerBounds(state, L)\n return { x: b.x + b.w / 2, y: b.y + b.h / 2 }\n}\n\n// Canvas convention: y grows downward, so a positive angle turns clockwise.\nexport function rotatePoint(p, c, deg) {\n if (!deg) return { x: p.x, y: p.y }\n const rad = (deg * Math.PI) / 180\n const cos = Math.cos(rad),\n sin = Math.sin(rad)\n const dx = p.x - c.x,\n dy = p.y - c.y\n return { x: c.x + dx * cos - dy * sin, y: c.y + dx * sin + dy * cos }\n}\n\n// Resize without swinging a rotated layer: `local` stays put on screen.\nexport function keepingFixed(state, L, local, mutate) {\n const rot = L.rotation || 0\n if (!rot) {\n mutate()\n return\n }\n const before = rotatePoint(local, layerCenter(state, L), rot)\n mutate()\n const after = rotatePoint(local, layerCenter(state, L), rot)\n L.x += before.x - after.x\n L.y += before.y - after.y\n}\n\n// A pointer in the layer's own unrotated frame, where x/y/w/h are stored.\nexport function toLayerSpace(state, L, p) {\n return rotatePoint(p, layerCenter(state, L), -(L.rotation || 0))\n}\n\n// Local frame; the overlay's transform is what makes the grip orbit.\nfunction rotateHandleLocalPoint(state, L) {\n const b = layerBounds(state, L)\n return {\n x: b.x + b.w / 2,\n y: b.y + b.h + ROTATE_HANDLE_GAP / state.viewScale,\n }\n}\n\nfunction rotateHandlePoint(state, L) {\n const local = rotateHandleLocalPoint(state, L)\n return rotatePoint(local, layerCenter(state, L), L.rotation || 0)\n}\n\nexport function onRotateHandle(state, p, L) {\n const rp = rotateHandlePoint(state, L)\n return Math.hypot(p.x - rp.x, p.y - rp.y) <= 14 / state.viewScale\n}\n\nexport function onResizeHandle(state, p, L) {\n if (L.type === 'stroke') return null\n const hs = 12 / state.viewScale\n const q = toLayerSpace(state, L, p)\n if (L.type === 'shape' && DIRECTIONAL_SHAPES.includes(L.shape)) {\n const ends = [\n { corner: 'start', x: L.x, y: L.y },\n { corner: 'end', x: L.x + L.w, y: L.y + L.h },\n ]\n const hit = ends.find(\n (ep) => Math.abs(q.x - ep.x) < hs && Math.abs(q.y - ep.y) < hs\n )\n return hit ? hit.corner : null\n }\n const b = layerBounds(state, L)\n const hit = cornerPoints(b).find(\n (cp) => Math.abs(q.x - cp.x) < hs && Math.abs(q.y - cp.y) < hs\n )\n return hit ? hit.corner : null\n}\n\nexport function paintLayer(state, c, L) {\n if (L._editing) return\n c.save()\n // Strokes only need the transform once they carry a rotation.\n if (L.type !== 'stroke' || L.rotation) {\n const b = layerBounds(state, L)\n const cx = b.x + b.w / 2,\n cy = b.y + b.h / 2\n c.translate(cx, cy)\n if (L.rotation) c.rotate((L.rotation * Math.PI) / 180)\n if (L.flipH || L.flipV) c.scale(L.flipH ? -1 : 1, L.flipV ? -1 : 1)\n c.translate(-cx, -cy)\n }\n if (L.type === 'text') {\n c.font = `${L.size}px ${L.font}`\n c.fillStyle = L.color\n c.textBaseline = 'top'\n c.shadowColor = 'rgba(0,0,0,.22)'\n c.shadowBlur = L.size * 0.05\n c.shadowOffsetY = L.size * 0.02\n const lineHeight = L.size * TEXT_LINE_HEIGHT\n wrapTextLines(state, L).forEach((line, i) => {\n c.fillText(line, L.x, L.y + i * lineHeight)\n })\n } else if (L.type === 'shape') {\n c.strokeStyle = L.color\n c.fillStyle = L.color\n c.lineWidth = L.width\n c.lineCap = 'round'\n c.lineJoin = 'round'\n const x = L.x,\n y = L.y,\n w = L.w,\n h = L.h\n if (L.shape === 'rect') {\n L.fill === 'fill' ? c.fillRect(x, y, w, h) : c.strokeRect(x, y, w, h)\n } else if (L.shape === 'ellipse') {\n c.beginPath()\n c.ellipse(\n x + w / 2,\n y + h / 2,\n Math.abs(w / 2),\n Math.abs(h / 2),\n 0,\n 0,\n Math.PI * 2\n )\n L.fill === 'fill' ? c.fill() : c.stroke()\n } else if (L.shape === 'circle') {\n const r = Math.min(Math.abs(w), Math.abs(h)) / 2\n c.beginPath()\n c.arc(x + w / 2, y + h / 2, r, 0, Math.PI * 2)\n L.fill === 'fill' ? c.fill() : c.stroke()\n } else if (DIRECTIONAL_SHAPES.includes(L.shape)) {\n const ex = x + w,\n ey = y + h\n const dashed = DASHED_SHAPES.includes(L.shape)\n if (dashed) {\n // Butt caps keep dashes crisp; round caps bleed into the gaps.\n c.lineCap = 'butt'\n c.setLineDash(dashedLineDash(L.width))\n }\n c.beginPath()\n c.moveTo(x, y)\n c.lineTo(ex, ey)\n c.stroke()\n if (dashed) {\n // Heads draw solid: a dash pattern would fragment them into stubs.\n c.setLineDash([])\n c.lineCap = 'round'\n }\n const ang = Math.atan2(h, w),\n head = Math.max(14, L.width * 3)\n ;(ARROW_HEAD_ENDS[L.shape] || []).forEach((which) => {\n if (which === 'end') drawArrowHead(c, ex, ey, ang, head)\n else drawArrowHead(c, x, y, ang + Math.PI, head)\n })\n }\n } else if (L.type === 'stroke') {\n c.strokeStyle = L.color\n c.lineWidth = L.width\n c.lineCap = 'round'\n c.lineJoin = 'round'\n c.globalAlpha = L.style === 'highlight' ? 0.35 : 1\n c.beginPath()\n L.points.forEach((pt, i) =>\n i === 0 ? c.moveTo(pt.x, pt.y) : c.lineTo(pt.x, pt.y)\n )\n if (L.points.length === 1)\n c.lineTo(L.points[0].x + 0.1, L.points[0].y + 0.1)\n c.stroke()\n } else if (L.type === 'sticker') {\n const img = state.stickerImageCache.get(L.src)\n if (img && img.complete && img.naturalWidth)\n c.drawImage(img, L.x, L.y, L.w, L.h)\n }\n c.restore()\n}\n\nexport function normRect(r) {\n return {\n x: Math.min(r.x, r.x + r.w),\n y: Math.min(r.y, r.y + r.h),\n w: Math.abs(r.w),\n h: Math.abs(r.h),\n }\n}\n\nexport function drawCropOverlay(state) {\n const { cropRect, overlayEl, octx, sourceCanvas } = state\n if (!cropRect) return\n const r = normRect(cropRect)\n const W = overlayEl.width,\n H = overlayEl.height\n octx.save()\n octx.fillStyle = 'rgba(0,0,0,.45)'\n octx.fillRect(0, 0, W, Math.max(0, r.y))\n octx.fillRect(0, Math.min(H, r.y + r.h), W, Math.max(0, H - (r.y + r.h)))\n octx.fillRect(0, r.y, Math.max(0, r.x), r.h)\n octx.fillRect(Math.min(W, r.x + r.w), r.y, Math.max(0, W - (r.x + r.w)), r.h)\n octx.strokeStyle = '#fff'\n octx.lineWidth = Math.max(1, sourceCanvas.width / 500)\n octx.setLineDash([8, 6])\n octx.strokeRect(r.x, r.y, r.w, r.h)\n octx.restore()\n}\n\nexport function renderOverlay(state) {\n const { octx, overlayEl, layers, mode, selectedId } = state\n octx.clearRect(0, 0, overlayEl.width, overlayEl.height)\n layers.forEach((L) => {\n try {\n paintLayer(state, octx, L)\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('[image-editor] failed to paint layer', L.id, L.type, err)\n }\n })\n if (mode === 'select' && selectedId != null) {\n const L = layers.find((l) => l.id === selectedId)\n if (L) {\n const b = layerBounds(state, L)\n octx.save()\n // The layer's frame, so box, handles and grip all tilt with it.\n if (L.rotation) {\n const c = layerCenter(state, L)\n octx.translate(c.x, c.y)\n octx.rotate((L.rotation * Math.PI) / 180)\n octx.translate(-c.x, -c.y)\n }\n octx.strokeStyle = '#2f5fd2'\n octx.lineWidth = Math.max(1.2, 1.5 / state.viewScale)\n octx.setLineDash([6 / state.viewScale, 4 / state.viewScale])\n octx.strokeRect(b.x - 4, b.y - 4, b.w + 8, b.h + 8)\n octx.setLineDash([])\n if (L.type !== 'stroke') {\n const hs = 9 / state.viewScale\n octx.fillStyle = '#fff'\n octx.strokeStyle = '#2f5fd2'\n const handlePoints =\n L.type === 'shape' && DIRECTIONAL_SHAPES.includes(L.shape)\n ? [\n { x: L.x, y: L.y },\n { x: L.x + L.w, y: L.y + L.h },\n ]\n : cornerPoints(b)\n handlePoints.forEach((cp) => {\n octx.fillRect(cp.x - hs / 2, cp.y - hs / 2, hs, hs)\n octx.strokeRect(cp.x - hs / 2, cp.y - hs / 2, hs, hs)\n })\n }\n // Rotate grip: every layer type gets one, strokes included.\n const rp = rotateHandleLocalPoint(state, L)\n octx.strokeStyle = '#2f5fd2'\n octx.fillStyle = '#fff'\n octx.beginPath()\n octx.moveTo(rp.x, b.y + b.h + 4)\n octx.lineTo(rp.x, rp.y)\n octx.stroke()\n octx.beginPath()\n octx.arc(\n rp.x,\n rp.y,\n ROTATE_HANDLE_RADIUS / state.viewScale,\n 0,\n Math.PI * 2\n )\n octx.fill()\n octx.stroke()\n octx.restore()\n }\n }\n if (state.pendingShape) paintLayer(state, octx, state.pendingShape)\n if (mode === 'crop' && state.cropRect) drawCropOverlay(state)\n}\n"],"names":["baseFilter","state","adj","f","FILTER_CSS","ZOOM_MIN","ZOOM_MAX","ZOOM_STEP","fitStage","fitScale","scale","w","h","applyZoom","zoom","renderOverlay","zoomIn","zoomOut","zoomToFit","syncCanvasSize","renderBase","ctx","canvasEl","sourceCanvas","filter","supportsContextFilter","render","TEXT_LINE_HEIGHT","wrapTextLines","L","maxWidth","lines","paragraph","words","current","word","test","layerBounds","a","b","cc","d","p","pad","clampTextSize","availH","clampBoxWidth","availW","cornerPoints","DIRECTIONAL_SHAPES","DASHED_SHAPES","ARROW_HEAD_ENDS","dashedLineDash","width","drawArrowHead","c","tipX","tipY","ang","head","ROTATE_HANDLE_GAP","ROTATE_HANDLE_RADIUS","layerCenter","rotatePoint","deg","rad","cos","sin","dx","dy","keepingFixed","local","mutate","rot","before","after","toLayerSpace","rotateHandleLocalPoint","rotateHandlePoint","onRotateHandle","rp","onResizeHandle","hs","q","hit","ep","cp","paintLayer","cx","cy","lineHeight","line","i","x","y","r","ex","ey","dashed","which","pt","img","normRect","drawCropOverlay","cropRect","overlayEl","octx","W","H","layers","mode","selectedId","err","l"],"mappings":";;AAGO,SAASA,EAAWC,GAAO;AAChC,QAAM,EAAE,KAAAC,EAAG,IAAKD;AAChB,MAAIE,IAAI,cAAcD,EAAI,UAAU,eAAeA,EAAI,QAAQ,eAAeA,EAAI,QAAQ,YAAYA,EAAI,KAAK,WAAWA,EAAI,IAAI,kBAAkBA,EAAI,GAAG;AAC3J,SAAIA,EAAI,WAAW,WAAQC,KAAK,MAAMC,EAAWF,EAAI,MAAM,IACpDC,EAAE,KAAI;AACf;AAEY,MAACE,IAAW,MACXC,IAAW,GAClBC,IAAY;AAEX,SAASC,EAASP,GAAO;AAE9B,QAAMQ,IAAW,KAAK;AAAA,KACnBR,EAAM,QAAQ,cAAc,MAAOA,EAAM,aAAa;AAAA,KACtDA,EAAM,QAAQ,eAAe,MAAOA,EAAM,aAAa;AAAA,IACxD;AAAA,EACJ;AACE,EAAAA,EAAM,WAAWQ;AACjB,QAAMC,IAAQD,IAAWR,EAAM;AAC/B,EAAAA,EAAM,YAAYS;AAClB,QAAMC,IAAI,KAAK,MAAMV,EAAM,aAAa,QAAQS,CAAK,GACnDE,IAAI,KAAK,MAAMX,EAAM,aAAa,SAASS,CAAK;AAClD,EAAAT,EAAM,SAAS,MAAM,QA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EAAE,IAAIA,EAAE,GAAG,GAAGA,EAAE,IAAIA,EAAE,EAAC;AAAA,QAC5C,IACcmB,EAAaT,CAAC,GACP,QAAQ,CAAC+C,MAAO;AAC3B,UAAAoB,EAAK,SAASpB,EAAG,IAAIJ,IAAK,GAAGI,EAAG,IAAIJ,IAAK,GAAGA,GAAIA,CAAE,GAClDwB,EAAK,WAAWpB,EAAG,IAAIJ,IAAK,GAAGI,EAAG,IAAIJ,IAAK,GAAGA,GAAIA,CAAE;AAAA,QACtD,CAAC;AAAA,MACH;AAEA,YAAMF,IAAKH,EAAuB5E,GAAO4B,CAAC;AAC1C,MAAA6E,EAAK,cAAc,WACnBA,EAAK,YAAY,QACjBA,EAAK,UAAS,GACdA,EAAK,OAAO1B,EAAG,GAAGzC,EAAE,IAAIA,EAAE,IAAI,CAAC,GAC/BmE,EAAK,OAAO1B,EAAG,GAAGA,EAAG,CAAC,GACtB0B,EAAK,OAAM,GACXA,EAAK,UAAS,GACdA,EAAK;AAAA,QACH1B,EAAG;AAAA,QACHA,EAAG;AAAA,QACHnB,IAAuB5D,EAAM;AAAA,QAC7B;AAAA,QACA,KAAK,KAAK;AAAA,MAClB,GACMyG,EAAK,KAAI,GACTA,EAAK,OAAM,GACXA,EAAK,QAAO;AAAA,IACd;AAAA,EACF;AACA,EAAIzG,EAAM,gBAAcsF,EAAWtF,GAAOyG,GAAMzG,EAAM,YAAY,GAC9D6G,MAAS,UAAU7G,EAAM,YAAUsG,EAAgBtG,CAAK;AAC9D;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { emitChange as o, MAX_HISTORY as c } from "./index.es146.js";
|
|
2
|
+
import { syncCanvasSize as u, render as i } from "./index.es147.js";
|
|
3
|
+
function d(n) {
|
|
4
|
+
const r = document.createElement("canvas");
|
|
5
|
+
return r.width = n.sourceCanvas.width, r.height = n.sourceCanvas.height, r.getContext("2d").drawImage(n.sourceCanvas, 0, 0), {
|
|
6
|
+
raster: r,
|
|
7
|
+
layers: JSON.parse(JSON.stringify(n.layers)),
|
|
8
|
+
adj: { ...n.adj },
|
|
9
|
+
sel: n.selectedId
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function p(n) {
|
|
13
|
+
n.undoStack.push(d(n)), n.undoStack.length > c && n.undoStack.shift(), n.redoStack = [], o(n);
|
|
14
|
+
}
|
|
15
|
+
function e(n, r) {
|
|
16
|
+
n.sourceCanvas.width = r.raster.width, n.sourceCanvas.height = r.raster.height, n.sourceCanvas.getContext("2d").drawImage(r.raster, 0, 0), n.layers = JSON.parse(JSON.stringify(r.layers)), Object.assign(n.adj, r.adj), n.selectedId = r.sel, u(n), i(n);
|
|
17
|
+
}
|
|
18
|
+
function S(n) {
|
|
19
|
+
n.undoStack.length && (n.redoStack.push(d(n)), e(n, n.undoStack.pop()), n.statusText = "Undo", o(n));
|
|
20
|
+
}
|
|
21
|
+
function g(n) {
|
|
22
|
+
n.redoStack.length && (n.undoStack.push(d(n)), e(n, n.redoStack.pop()), n.statusText = "Redo", o(n));
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
e as applySnapshot,
|
|
26
|
+
p as pushHistory,
|
|
27
|
+
g as redo,
|
|
28
|
+
d as snapshot,
|
|
29
|
+
S as undo
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.es148.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es148.js","sources":["../src/components/organisms/image-editor/engine/history.js"],"sourcesContent":["import { MAX_HISTORY, emitChange } from './state.js'\nimport { render, syncCanvasSize } from './rendering.js'\n\nexport function snapshot(state) {\n const c = document.createElement('canvas')\n c.width = state.sourceCanvas.width\n c.height = state.sourceCanvas.height\n c.getContext('2d').drawImage(state.sourceCanvas, 0, 0)\n return {\n raster: c,\n layers: JSON.parse(JSON.stringify(state.layers)),\n adj: { ...state.adj },\n sel: state.selectedId,\n }\n}\n\nexport function pushHistory(state) {\n state.undoStack.push(snapshot(state))\n if (state.undoStack.length > MAX_HISTORY) state.undoStack.shift()\n state.redoStack = []\n emitChange(state)\n}\n\nexport function applySnapshot(state, s) {\n state.sourceCanvas.width = s.raster.width\n state.sourceCanvas.height = s.raster.height\n state.sourceCanvas.getContext('2d').drawImage(s.raster, 0, 0)\n state.layers = JSON.parse(JSON.stringify(s.layers))\n Object.assign(state.adj, s.adj)\n state.selectedId = s.sel\n syncCanvasSize(state)\n render(state)\n}\n\nexport function undo(state) {\n if (!state.undoStack.length) return\n state.redoStack.push(snapshot(state))\n applySnapshot(state, state.undoStack.pop())\n state.statusText = 'Undo'\n emitChange(state)\n}\n\nexport function redo(state) {\n if (!state.redoStack.length) return\n state.undoStack.push(snapshot(state))\n applySnapshot(state, state.redoStack.pop())\n state.statusText = 'Redo'\n emitChange(state)\n}\n"],"names":["snapshot","state","c","pushHistory","MAX_HISTORY","emitChange","applySnapshot","s","syncCanvasSize","render","undo","redo"],"mappings":";;AAGO,SAASA,EAASC,GAAO;AAC9B,QAAMC,IAAI,SAAS,cAAc,QAAQ;AACzC,SAAAA,EAAE,QAAQD,EAAM,aAAa,OAC7BC,EAAE,SAASD,EAAM,aAAa,QAC9BC,EAAE,WAAW,IAAI,EAAE,UAAUD,EAAM,cAAc,GAAG,CAAC,GAC9C;AAAA,IACL,QAAQC;AAAA,IACR,QAAQ,KAAK,MAAM,KAAK,UAAUD,EAAM,MAAM,CAAC;AAAA,IAC/C,KAAK,EAAE,GAAGA,EAAM,IAAG;AAAA,IACnB,KAAKA,EAAM;AAAA,EACf;AACA;AAEO,SAASE,EAAYF,GAAO;AACjC,EAAAA,EAAM,UAAU,KAAKD,EAASC,CAAK,CAAC,GAChCA,EAAM,UAAU,SAASG,KAAaH,EAAM,UAAU,MAAK,GAC/DA,EAAM,YAAY,CAAA,GAClBI,EAAWJ,CAAK;AAClB;AAEO,SAASK,EAAcL,GAAOM,GAAG;AACtC,EAAAN,EAAM,aAAa,QAAQM,EAAE,OAAO,OACpCN,EAAM,aAAa,SAASM,EAAE,OAAO,QACrCN,EAAM,aAAa,WAAW,IAAI,EAAE,UAAUM,EAAE,QAAQ,GAAG,CAAC,GAC5DN,EAAM,SAAS,KAAK,MAAM,KAAK,UAAUM,EAAE,MAAM,CAAC,GAClD,OAAO,OAAON,EAAM,KAAKM,EAAE,GAAG,GAC9BN,EAAM,aAAaM,EAAE,KACrBC,EAAeP,CAAK,GACpBQ,EAAOR,CAAK;AACd;AAEO,SAASS,EAAKT,GAAO;AAC1B,EAAKA,EAAM,UAAU,WACrBA,EAAM,UAAU,KAAKD,EAASC,CAAK,CAAC,GACpCK,EAAcL,GAAOA,EAAM,UAAU,IAAG,CAAE,GAC1CA,EAAM,aAAa,QACnBI,EAAWJ,CAAK;AAClB;AAEO,SAASU,EAAKV,GAAO;AAC1B,EAAKA,EAAM,UAAU,WACrBA,EAAM,UAAU,KAAKD,EAASC,CAAK,CAAC,GACpCK,EAAcL,GAAOA,EAAM,UAAU,IAAG,CAAE,GAC1CA,EAAM,aAAa,QACnBI,EAAWJ,CAAK;AAClB;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { pushHistory as d } from "./index.es148.js";
|
|
2
|
+
import { emitChange as u, resetAdjValues as v } from "./index.es146.js";
|
|
3
|
+
import { syncCanvasSize as C, render as x, normRect as w, layerBounds as R } from "./index.es147.js";
|
|
4
|
+
import { setMode as g } from "./index.es150.js";
|
|
5
|
+
function m(o, n, t) {
|
|
6
|
+
const r = R(o, n), a = { x: r.x + r.w / 2, y: r.y + r.h / 2 }, c = t(a);
|
|
7
|
+
return { x: c.x - a.x, y: c.y - a.y };
|
|
8
|
+
}
|
|
9
|
+
function T(o, n) {
|
|
10
|
+
d(o);
|
|
11
|
+
const t = n * Math.PI / 180, r = o.sourceCanvas.width, a = o.sourceCanvas.height, c = a, h = r, p = document.createElement("canvas");
|
|
12
|
+
p.width = c, p.height = h;
|
|
13
|
+
const e = p.getContext("2d");
|
|
14
|
+
e.translate(c / 2, h / 2), e.rotate(t), e.drawImage(o.sourceCanvas, -r / 2, -a / 2), o.sourceCanvas.width = c, o.sourceCanvas.height = h, o.sourceCanvas.getContext("2d").drawImage(p, 0, 0);
|
|
15
|
+
const s = (i, l) => {
|
|
16
|
+
const y = i - r / 2, f = l - a / 2;
|
|
17
|
+
return {
|
|
18
|
+
x: y * Math.cos(t) - f * Math.sin(t) + c / 2,
|
|
19
|
+
y: y * Math.sin(t) + f * Math.cos(t) + h / 2
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
o.layers.forEach((i) => {
|
|
23
|
+
if (i.type === "text" || i.type === "shape" || i.type === "sticker") {
|
|
24
|
+
const l = m(o, i, (y) => s(y.x, y.y));
|
|
25
|
+
i.x += l.x, i.y += l.y, i.rotation = (((i.rotation || 0) + n) % 360 + 360) % 360;
|
|
26
|
+
} else i.type === "stroke" && (i.points = i.points.map((l) => s(l.x, l.y)));
|
|
27
|
+
}), C(o), x(o), o.statusText = n < 0 ? "Rotated left" : "Rotated right", u(o);
|
|
28
|
+
}
|
|
29
|
+
function b(o, n) {
|
|
30
|
+
d(o);
|
|
31
|
+
const t = o.sourceCanvas.width, r = o.sourceCanvas.height, a = document.createElement("canvas");
|
|
32
|
+
a.width = t, a.height = r;
|
|
33
|
+
const c = a.getContext("2d");
|
|
34
|
+
n ? (c.translate(t, 0), c.scale(-1, 1)) : (c.translate(0, r), c.scale(1, -1)), c.drawImage(o.sourceCanvas, 0, 0), o.sourceCanvas.getContext("2d").clearRect(0, 0, t, r), o.sourceCanvas.getContext("2d").drawImage(a, 0, 0);
|
|
35
|
+
const h = (e) => n ? t - e : e, p = (e) => n ? e : r - e;
|
|
36
|
+
o.layers.forEach((e) => {
|
|
37
|
+
if (e.type === "text" || e.type === "shape" || e.type === "sticker") {
|
|
38
|
+
const s = m(o, e, (i) => ({ x: h(i.x), y: p(i.y) }));
|
|
39
|
+
e.x += s.x, e.y += s.y, e.rotation = (360 - (e.rotation || 0) % 360) % 360, n ? e.flipH = !e.flipH : e.flipV = !e.flipV;
|
|
40
|
+
} else e.type === "stroke" && (e.points = e.points.map((s) => ({ x: h(s.x), y: p(s.y) })));
|
|
41
|
+
}), x(o), o.statusText = n ? "Flipped horizontally" : "Flipped vertically", u(o);
|
|
42
|
+
}
|
|
43
|
+
function H(o) {
|
|
44
|
+
if (!o.cropRect || Math.abs(o.cropRect.w) < 4 || Math.abs(o.cropRect.h) < 4) {
|
|
45
|
+
o.statusText = "Draw a crop box first", o.notify();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
d(o);
|
|
49
|
+
const n = w(o.cropRect), t = document.createElement("canvas");
|
|
50
|
+
t.width = Math.round(n.w), t.height = Math.round(n.h), t.getContext("2d").drawImage(o.sourceCanvas, n.x, n.y, n.w, n.h, 0, 0, n.w, n.h), o.sourceCanvas.width = t.width, o.sourceCanvas.height = t.height, o.sourceCanvas.getContext("2d").drawImage(t, 0, 0), o.layers.forEach((r) => {
|
|
51
|
+
r.type === "text" || r.type === "shape" || r.type === "sticker" ? (r.x -= n.x, r.y -= n.y) : r.type === "stroke" && (r.points = r.points.map((a) => ({ x: a.x - n.x, y: a.y - n.y })));
|
|
52
|
+
}), o.cropRect = null, g(o, "select"), C(o), x(o), o.statusText = "Cropped", u(o);
|
|
53
|
+
}
|
|
54
|
+
function V(o) {
|
|
55
|
+
g(o, "select");
|
|
56
|
+
}
|
|
57
|
+
function D(o, n) {
|
|
58
|
+
o.cropRatio = n, o.notify();
|
|
59
|
+
}
|
|
60
|
+
function F(o) {
|
|
61
|
+
o.originalCanvas && (d(o), o.sourceCanvas.width = o.originalCanvas.width, o.sourceCanvas.height = o.originalCanvas.height, o.sourceCanvas.getContext("2d").drawImage(o.originalCanvas, 0, 0), o.layers = [], o.selectedId = null, o.zoom = 1, v(o), C(o), x(o), o.statusText = "Reset to original", u(o));
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
H as applyCrop,
|
|
65
|
+
V as cancelCrop,
|
|
66
|
+
b as flip,
|
|
67
|
+
F as resetToOriginal,
|
|
68
|
+
T as rotate,
|
|
69
|
+
D as setCropRatio
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=index.es149.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es149.js","sources":["../src/components/organisms/image-editor/engine/geometry.js"],"sourcesContent":["import { pushHistory } from './history.js'\nimport { emitChange, resetAdjValues } from './state.js'\nimport { render, syncCanvasSize, normRect, layerBounds } from './rendering.js'\nimport { setMode } from './mode.js'\n\nfunction centerDelta(state, L, mapCenter) {\n const b = layerBounds(state, L)\n const oldCenter = { x: b.x + b.w / 2, y: b.y + b.h / 2 }\n const newCenter = mapCenter(oldCenter)\n return { x: newCenter.x - oldCenter.x, y: newCenter.y - oldCenter.y }\n}\n\nexport function rotate(state, deg) {\n pushHistory(state)\n const rad = (deg * Math.PI) / 180,\n ow = state.sourceCanvas.width,\n oh = state.sourceCanvas.height,\n nw = oh,\n nh = ow\n const tmp = document.createElement('canvas')\n tmp.width = nw\n tmp.height = nh\n const t = tmp.getContext('2d')\n t.translate(nw / 2, nh / 2)\n t.rotate(rad)\n t.drawImage(state.sourceCanvas, -ow / 2, -oh / 2)\n state.sourceCanvas.width = nw\n state.sourceCanvas.height = nh\n state.sourceCanvas.getContext('2d').drawImage(tmp, 0, 0)\n const rot = (x, y) => {\n const dx = x - ow / 2,\n dy = y - oh / 2\n return {\n x: dx * Math.cos(rad) - dy * Math.sin(rad) + nw / 2,\n y: dx * Math.sin(rad) + dy * Math.cos(rad) + nh / 2,\n }\n }\n state.layers.forEach((L) => {\n if (L.type === 'text' || L.type === 'shape' || L.type === 'sticker') {\n const delta = centerDelta(state, L, (c) => rot(c.x, c.y))\n L.x += delta.x\n L.y += delta.y\n L.rotation = ((((L.rotation || 0) + deg) % 360) + 360) % 360\n } else if (L.type === 'stroke') {\n L.points = L.points.map((pt) => rot(pt.x, pt.y))\n }\n })\n syncCanvasSize(state)\n render(state)\n state.statusText = deg < 0 ? 'Rotated left' : 'Rotated right'\n emitChange(state)\n}\n\nexport function flip(state, hz) {\n pushHistory(state)\n const w = state.sourceCanvas.width,\n h = state.sourceCanvas.height\n const tmp = document.createElement('canvas')\n tmp.width = w\n tmp.height = h\n const t = tmp.getContext('2d')\n if (hz) {\n t.translate(w, 0)\n t.scale(-1, 1)\n } else {\n t.translate(0, h)\n t.scale(1, -1)\n }\n t.drawImage(state.sourceCanvas, 0, 0)\n state.sourceCanvas.getContext('2d').clearRect(0, 0, w, h)\n state.sourceCanvas.getContext('2d').drawImage(tmp, 0, 0)\n const fx = (x) => (hz ? w - x : x),\n fy = (y) => (hz ? y : h - y)\n state.layers.forEach((L) => {\n if (L.type === 'text' || L.type === 'shape' || L.type === 'sticker') {\n const delta = centerDelta(state, L, (c) => ({ x: fx(c.x), y: fy(c.y) }))\n L.x += delta.x\n L.y += delta.y\n L.rotation = (360 - ((L.rotation || 0) % 360)) % 360\n if (hz) L.flipH = !L.flipH\n else L.flipV = !L.flipV\n } else if (L.type === 'stroke') {\n L.points = L.points.map((pt) => ({ x: fx(pt.x), y: fy(pt.y) }))\n }\n })\n render(state)\n state.statusText = hz ? 'Flipped horizontally' : 'Flipped vertically'\n emitChange(state)\n}\n\nexport function applyCrop(state) {\n if (\n !state.cropRect ||\n Math.abs(state.cropRect.w) < 4 ||\n Math.abs(state.cropRect.h) < 4\n ) {\n state.statusText = 'Draw a crop box first'\n state.notify()\n return\n }\n pushHistory(state)\n const r = normRect(state.cropRect)\n const tmp = document.createElement('canvas')\n tmp.width = Math.round(r.w)\n tmp.height = Math.round(r.h)\n tmp\n .getContext('2d')\n .drawImage(state.sourceCanvas, r.x, r.y, r.w, r.h, 0, 0, r.w, r.h)\n state.sourceCanvas.width = tmp.width\n state.sourceCanvas.height = tmp.height\n state.sourceCanvas.getContext('2d').drawImage(tmp, 0, 0)\n state.layers.forEach((L) => {\n if (L.type === 'text' || L.type === 'shape' || L.type === 'sticker') {\n L.x -= r.x\n L.y -= r.y\n } else if (L.type === 'stroke') {\n L.points = L.points.map((p) => ({ x: p.x - r.x, y: p.y - r.y }))\n }\n })\n state.cropRect = null\n setMode(state, 'select')\n syncCanvasSize(state)\n render(state)\n state.statusText = 'Cropped'\n emitChange(state)\n}\n\nexport function cancelCrop(state) {\n setMode(state, 'select')\n}\n\nexport function setCropRatio(state, v) {\n state.cropRatio = v\n state.notify()\n}\n\nexport function resetToOriginal(state) {\n if (!state.originalCanvas) return\n pushHistory(state)\n state.sourceCanvas.width = state.originalCanvas.width\n state.sourceCanvas.height = state.originalCanvas.height\n state.sourceCanvas.getContext('2d').drawImage(state.originalCanvas, 0, 0)\n state.layers = []\n state.selectedId = null\n state.zoom = 1\n resetAdjValues(state)\n syncCanvasSize(state)\n render(state)\n state.statusText = 'Reset to original'\n emitChange(state)\n}\n"],"names":["centerDelta","state","L","mapCenter","b","layerBounds","oldCenter","newCenter","rotate","deg","pushHistory","rad","ow","oh","nw","nh","tmp","t","rot","x","y","dx","dy","delta","c","pt","syncCanvasSize","render","emitChange","flip","hz","w","h","fx","fy","applyCrop","r","normRect","p","setMode","cancelCrop","setCropRatio","v","resetToOriginal","resetAdjValues"],"mappings":";;;;AAKA,SAASA,EAAYC,GAAOC,GAAGC,GAAW;AACxC,QAAMC,IAAIC,EAAYJ,GAAOC,CAAC,GACxBI,IAAY,EAAE,GAAGF,EAAE,IAAIA,EAAE,IAAI,GAAG,GAAGA,EAAE,IAAIA,EAAE,IAAI,EAAC,GAChDG,IAAYJ,EAAUG,CAAS;AACrC,SAAO,EAAE,GAAGC,EAAU,IAAID,EAAU,GAAG,GAAGC,EAAU,IAAID,EAAU,EAAC;AACrE;AAEO,SAASE,EAAOP,GAAOQ,GAAK;AACjC,EAAAC,EAAYT,CAAK;AACjB,QAAMU,IAAOF,IAAM,KAAK,KAAM,KAC5BG,IAAKX,EAAM,aAAa,OACxBY,IAAKZ,EAAM,aAAa,QACxBa,IAAKD,GACLE,IAAKH,GACDI,IAAM,SAAS,cAAc,QAAQ;AAC3C,EAAA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