js-draw 0.17.3 → 0.18.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/.github/workflows/firebase-hosting-merge.yml +2 -0
- package/.github/workflows/firebase-hosting-pull-request.yml +2 -0
- package/.github/workflows/github-pages.yml +2 -0
- package/CHANGELOG.md +10 -1
- package/README.md +17 -8
- package/build_tools/postDist.ts +71 -0
- package/dist/bundle.js +9 -1
- package/dist/cjs/build_tools/BundledFile.js +163 -0
- package/dist/cjs/build_tools/buildTranslationTemplate.js +119 -0
- package/dist/cjs/build_tools/bundle.js +10 -0
- package/dist/cjs/build_tools/postDist.js +72 -0
- package/dist/{src → cjs/src}/Color4.d.ts +1 -0
- package/dist/cjs/src/Color4.js +197 -0
- package/dist/{src → cjs/src}/Editor.d.ts +57 -1
- package/dist/cjs/src/Editor.js +904 -0
- package/dist/{src → cjs/src}/EditorImage.d.ts +4 -2
- package/dist/cjs/src/EditorImage.js +486 -0
- package/dist/cjs/src/EventDispatcher.js +57 -0
- package/dist/cjs/src/Pointer.js +84 -0
- package/dist/{src → cjs/src}/SVGLoader.d.ts +4 -0
- package/dist/cjs/src/SVGLoader.js +472 -0
- package/dist/cjs/src/UndoRedoHistory.js +93 -0
- package/dist/cjs/src/Viewport.js +264 -0
- package/dist/cjs/src/bundle/bundled.js +24 -0
- package/dist/cjs/src/commands/Command.js +34 -0
- package/dist/cjs/src/commands/Duplicate.js +39 -0
- package/dist/cjs/src/commands/Erase.js +63 -0
- package/dist/cjs/src/commands/SerializableCommand.js +42 -0
- package/dist/cjs/src/commands/UnresolvedCommand.js +28 -0
- package/dist/cjs/src/commands/invertCommand.js +49 -0
- package/dist/cjs/src/commands/lib.js +18 -0
- package/dist/cjs/src/commands/localization.js +24 -0
- package/dist/cjs/src/commands/uniteCommands.js +121 -0
- package/dist/cjs/src/components/AbstractComponent.js +258 -0
- package/dist/cjs/src/components/ImageBackground.js +146 -0
- package/dist/cjs/src/components/ImageComponent.js +152 -0
- package/dist/cjs/src/components/RestylableComponent.js +88 -0
- package/dist/cjs/src/components/SVGGlobalAttributesObject.js +65 -0
- package/dist/cjs/src/components/Stroke.js +191 -0
- package/dist/cjs/src/components/TextComponent.js +258 -0
- package/dist/cjs/src/components/UnknownSVGObject.js +50 -0
- package/dist/cjs/src/components/builders/ArrowBuilder.js +117 -0
- package/dist/cjs/src/components/builders/FreehandLineBuilder.js +173 -0
- package/dist/cjs/src/components/builders/LineBuilder.js +89 -0
- package/dist/cjs/src/components/builders/PressureSensitiveFreehandLineBuilder.js +347 -0
- package/dist/cjs/src/components/builders/RectangleBuilder.js +59 -0
- package/dist/cjs/src/components/builders/types.js +2 -0
- package/dist/cjs/src/components/lib.js +43 -0
- package/dist/cjs/src/components/localization.js +13 -0
- package/dist/cjs/src/components/util/StrokeSmoother.js +217 -0
- package/dist/cjs/src/components/util/describeComponentList.js +16 -0
- package/dist/{src → cjs/src}/lib.d.ts +2 -1
- package/dist/cjs/src/lib.js +63 -0
- package/dist/cjs/src/localization.js +13 -0
- package/dist/cjs/src/localizations/de.js +6 -0
- package/dist/cjs/src/localizations/en.js +6 -0
- package/dist/cjs/src/localizations/es.js +20 -0
- package/dist/cjs/src/localizations/getLocalizationTable.js +50 -0
- package/dist/cjs/src/math/LineSegment2.js +131 -0
- package/dist/cjs/src/math/Mat33.js +332 -0
- package/dist/cjs/src/math/Path.js +655 -0
- package/dist/cjs/src/math/Rect2.js +234 -0
- package/dist/cjs/src/math/Triangle.js +22 -0
- package/dist/cjs/src/math/Vec2.js +19 -0
- package/dist/cjs/src/math/Vec3.js +177 -0
- package/dist/cjs/src/math/lib.js +18 -0
- package/dist/cjs/src/math/rounding.js +135 -0
- package/dist/cjs/src/rendering/Display.js +214 -0
- package/dist/cjs/src/rendering/RenderingStyle.js +48 -0
- package/dist/cjs/src/rendering/TextRenderingStyle.js +29 -0
- package/dist/cjs/src/rendering/caching/CacheRecord.js +61 -0
- package/dist/cjs/src/rendering/caching/CacheRecordManager.js +50 -0
- package/dist/cjs/src/rendering/caching/RenderingCache.js +51 -0
- package/dist/cjs/src/rendering/caching/RenderingCacheNode.js +326 -0
- package/dist/cjs/src/rendering/caching/testUtils.js +27 -0
- package/dist/cjs/src/rendering/caching/types.js +2 -0
- package/dist/{src → cjs/src}/rendering/lib.d.ts +2 -0
- package/dist/cjs/src/rendering/lib.js +16 -0
- package/dist/cjs/src/rendering/localization.js +12 -0
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.js +170 -0
- package/dist/{src → cjs/src}/rendering/renderers/CanvasRenderer.d.ts +25 -0
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.js +236 -0
- package/dist/cjs/src/rendering/renderers/DummyRenderer.js +112 -0
- package/dist/{src → cjs/src}/rendering/renderers/SVGRenderer.d.ts +15 -0
- package/dist/cjs/src/rendering/renderers/SVGRenderer.js +311 -0
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.js +63 -0
- package/dist/cjs/src/testing/beforeEachFile.js +12 -0
- package/dist/cjs/src/testing/createEditor.js +14 -0
- package/dist/cjs/src/testing/lib.d.ts +2 -0
- package/dist/cjs/src/testing/lib.js +10 -0
- package/dist/cjs/src/testing/loadExpectExtensions.js +28 -0
- package/dist/cjs/src/testing/sendPenEvent.d.ts +12 -0
- package/dist/cjs/src/testing/sendPenEvent.js +24 -0
- package/dist/cjs/src/testing/sendTouchEvent.d.ts +42 -0
- package/dist/cjs/src/testing/sendTouchEvent.js +87 -0
- package/dist/cjs/src/toolbar/HTMLToolbar.js +383 -0
- package/dist/cjs/src/toolbar/IconProvider.js +660 -0
- package/dist/cjs/src/toolbar/lib.js +24 -0
- package/dist/cjs/src/toolbar/localization.js +51 -0
- package/dist/cjs/src/toolbar/makeColorInput.js +120 -0
- package/dist/cjs/src/toolbar/types.js +2 -0
- package/dist/cjs/src/toolbar/widgets/ActionButtonWidget.js +31 -0
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.js +50 -0
- package/dist/cjs/src/toolbar/widgets/BaseWidget.js +313 -0
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.js +126 -0
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.js +63 -0
- package/dist/cjs/src/toolbar/widgets/HandToolWidget.js +201 -0
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.js +176 -0
- package/dist/cjs/src/toolbar/widgets/OverflowWidget.js +77 -0
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.js +226 -0
- package/dist/cjs/src/toolbar/widgets/SelectionToolWidget.js +153 -0
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.js +115 -0
- package/dist/cjs/src/toolbar/widgets/lib.js +26 -0
- package/dist/cjs/src/tools/BaseTool.js +66 -0
- package/dist/cjs/src/tools/Eraser.js +112 -0
- package/dist/cjs/src/tools/FindTool.js +121 -0
- package/dist/cjs/src/tools/PanZoom.js +421 -0
- package/dist/cjs/src/tools/PasteHandler.js +99 -0
- package/dist/cjs/src/tools/Pen.js +179 -0
- package/dist/cjs/src/tools/PipetteTool.js +45 -0
- package/dist/cjs/src/tools/SelectionTool/SelectAllShortcutHandler.js +28 -0
- package/dist/cjs/src/tools/SelectionTool/Selection.js +488 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionHandle.js +85 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.js +405 -0
- package/dist/cjs/src/tools/SelectionTool/TransformMode.js +107 -0
- package/dist/cjs/src/tools/SelectionTool/types.js +14 -0
- package/dist/cjs/src/tools/TextTool.js +262 -0
- package/dist/cjs/src/tools/ToolController.js +187 -0
- package/dist/cjs/src/tools/ToolEnabledGroup.js +14 -0
- package/dist/cjs/src/tools/ToolSwitcherShortcut.js +38 -0
- package/dist/cjs/src/tools/ToolbarShortcutHandler.js +29 -0
- package/dist/cjs/src/tools/UndoRedoShortcut.js +28 -0
- package/dist/cjs/src/tools/lib.js +36 -0
- package/dist/cjs/src/tools/localization.js +30 -0
- package/dist/cjs/src/types.js +38 -0
- package/dist/cjs/src/util/assertions.js +51 -0
- package/dist/cjs/src/util/fileToBase64.js +15 -0
- package/dist/cjs/src/util/untilNextAnimationFrame.js +9 -0
- package/dist/cjs/src/util/waitForTimeout.js +9 -0
- package/dist/mjs/build_tools/BundledFile.d.ts +13 -0
- package/dist/{build_tools/buildTranslationTemplate.js → mjs/build_tools/buildTranslationTemplate.mjs} +1 -1
- package/dist/{build_tools/bundle.js → mjs/build_tools/bundle.mjs} +1 -1
- package/dist/mjs/build_tools/postDist.d.ts +1 -0
- package/dist/mjs/build_tools/postDist.mjs +67 -0
- package/dist/mjs/src/Color4.d.ts +61 -0
- package/dist/{src/Color4.js → mjs/src/Color4.mjs} +1 -0
- package/dist/mjs/src/Editor.d.ts +308 -0
- package/dist/{src/Editor.js → mjs/src/Editor.mjs} +86 -49
- package/dist/mjs/src/EditorImage.d.ts +97 -0
- package/dist/{src/EditorImage.js → mjs/src/EditorImage.mjs} +12 -10
- package/dist/mjs/src/EventDispatcher.d.ts +30 -0
- package/dist/mjs/src/Pointer.d.ts +24 -0
- package/dist/{src/Pointer.js → mjs/src/Pointer.mjs} +1 -1
- package/dist/mjs/src/SVGLoader.d.ts +48 -0
- package/dist/{src/SVGLoader.js → mjs/src/SVGLoader.mjs} +15 -11
- package/dist/mjs/src/UndoRedoHistory.d.ts +19 -0
- package/dist/{src/UndoRedoHistory.js → mjs/src/UndoRedoHistory.mjs} +1 -1
- package/dist/mjs/src/Viewport.d.ts +71 -0
- package/dist/{src/Viewport.js → mjs/src/Viewport.mjs} +5 -5
- package/dist/mjs/src/bundle/bundled.d.ts +4 -0
- package/dist/{src/bundle/bundled.js → mjs/src/bundle/bundled.mjs} +2 -2
- package/dist/mjs/src/commands/Command.d.ts +16 -0
- package/dist/mjs/src/commands/Duplicate.d.ts +14 -0
- package/dist/{src/commands/Duplicate.js → mjs/src/commands/Duplicate.mjs} +3 -3
- package/dist/mjs/src/commands/Erase.d.ts +14 -0
- package/dist/{src/commands/Erase.js → mjs/src/commands/Erase.mjs} +3 -3
- package/dist/mjs/src/commands/SerializableCommand.d.ts +12 -0
- package/dist/{src/commands/SerializableCommand.js → mjs/src/commands/SerializableCommand.mjs} +1 -1
- package/dist/mjs/src/commands/UnresolvedCommand.d.ts +14 -0
- package/dist/{src/commands/UnresolvedCommand.js → mjs/src/commands/UnresolvedCommand.mjs} +1 -1
- package/dist/mjs/src/commands/invertCommand.d.ts +4 -0
- package/dist/{src/commands/invertCommand.js → mjs/src/commands/invertCommand.mjs} +2 -2
- package/dist/mjs/src/commands/lib.mjs +7 -0
- package/dist/mjs/src/commands/localization.d.ts +23 -0
- package/dist/mjs/src/commands/uniteCommands.d.ts +4 -0
- package/dist/{src/commands/uniteCommands.js → mjs/src/commands/uniteCommands.mjs} +2 -2
- package/dist/mjs/src/components/AbstractComponent.d.ts +73 -0
- package/dist/{src/components/AbstractComponent.js → mjs/src/components/AbstractComponent.mjs} +4 -4
- package/dist/mjs/src/components/ImageBackground.d.ts +42 -0
- package/dist/{src/components/ImageBackground.js → mjs/src/components/ImageBackground.mjs} +5 -5
- package/dist/mjs/src/components/ImageComponent.d.ts +31 -0
- package/dist/{src/components/ImageComponent.js → mjs/src/components/ImageComponent.mjs} +3 -3
- package/dist/mjs/src/components/RestylableComponent.d.ts +24 -0
- package/dist/{src/components/RestylableComponent.js → mjs/src/components/RestylableComponent.mjs} +4 -4
- package/dist/mjs/src/components/SVGGlobalAttributesObject.d.ts +21 -0
- package/dist/{src/components/SVGGlobalAttributesObject.js → mjs/src/components/SVGGlobalAttributesObject.mjs} +3 -3
- package/dist/mjs/src/components/Stroke.d.ts +40 -0
- package/dist/{src/components/Stroke.js → mjs/src/components/Stroke.mjs} +5 -5
- package/dist/mjs/src/components/TextComponent.d.ts +53 -0
- package/dist/{src/components/TextComponent.js → mjs/src/components/TextComponent.mjs} +7 -7
- package/dist/mjs/src/components/UnknownSVGObject.d.ts +18 -0
- package/dist/{src/components/UnknownSVGObject.js → mjs/src/components/UnknownSVGObject.mjs} +3 -3
- package/dist/mjs/src/components/builders/ArrowBuilder.d.ts +19 -0
- package/dist/{src/components/builders/ArrowBuilder.js → mjs/src/components/builders/ArrowBuilder.mjs} +2 -2
- package/dist/mjs/src/components/builders/FreehandLineBuilder.d.ts +33 -0
- package/dist/{src/components/builders/FreehandLineBuilder.js → mjs/src/components/builders/FreehandLineBuilder.mjs} +7 -7
- package/dist/mjs/src/components/builders/LineBuilder.d.ts +18 -0
- package/dist/{src/components/builders/LineBuilder.js → mjs/src/components/builders/LineBuilder.mjs} +2 -2
- package/dist/mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +36 -0
- package/dist/{src/components/builders/PressureSensitiveFreehandLineBuilder.js → mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.mjs} +6 -6
- package/dist/mjs/src/components/builders/RectangleBuilder.d.ts +20 -0
- package/dist/{src/components/builders/RectangleBuilder.js → mjs/src/components/builders/RectangleBuilder.mjs} +4 -4
- package/dist/mjs/src/components/builders/types.d.ts +12 -0
- package/dist/mjs/src/components/builders/types.mjs +1 -0
- package/dist/{src/components/lib.js → mjs/src/components/lib.d.ts} +3 -3
- package/dist/mjs/src/components/lib.mjs +12 -0
- package/dist/mjs/src/components/localization.d.ts +11 -0
- package/dist/mjs/src/components/util/StrokeSmoother.d.ts +35 -0
- package/dist/{src/components/util/StrokeSmoother.js → mjs/src/components/util/StrokeSmoother.mjs} +3 -3
- package/dist/mjs/src/components/util/describeComponentList.d.ts +4 -0
- package/dist/{src/lib.js → mjs/src/lib.d.ts} +4 -3
- package/dist/mjs/src/lib.mjs +34 -0
- package/dist/mjs/src/localization.d.ts +14 -0
- package/dist/{src/localization.js → mjs/src/localization.mjs} +5 -5
- package/dist/mjs/src/localizations/de.d.ts +3 -0
- package/dist/{src/localizations/de.js → mjs/src/localizations/de.mjs} +1 -1
- package/dist/mjs/src/localizations/en.d.ts +3 -0
- package/dist/{src/localizations/en.js → mjs/src/localizations/en.mjs} +1 -1
- package/dist/mjs/src/localizations/es.d.ts +3 -0
- package/dist/{src/localizations/es.js → mjs/src/localizations/es.mjs} +1 -1
- package/dist/mjs/src/localizations/getLocalizationTable.d.ts +3 -0
- package/dist/{src/localizations/getLocalizationTable.js → mjs/src/localizations/getLocalizationTable.mjs} +4 -4
- package/dist/mjs/src/math/LineSegment2.d.ts +24 -0
- package/dist/{src/math/LineSegment2.js → mjs/src/math/LineSegment2.mjs} +2 -2
- package/dist/mjs/src/math/Mat33.d.ts +118 -0
- package/dist/{src/math/Mat33.js → mjs/src/math/Mat33.mjs} +2 -2
- package/dist/mjs/src/math/Path.d.ts +71 -0
- package/dist/{src/math/Path.js → mjs/src/math/Path.mjs} +5 -5
- package/dist/mjs/src/math/Rect2.d.ts +52 -0
- package/dist/{src/math/Rect2.js → mjs/src/math/Rect2.mjs} +2 -2
- package/dist/mjs/src/math/Triangle.d.ts +11 -0
- package/dist/mjs/src/math/Vec2.d.ts +13 -0
- package/dist/{src/math/Vec2.js → mjs/src/math/Vec2.mjs} +1 -1
- package/dist/mjs/src/math/Vec3.d.ts +106 -0
- package/dist/mjs/src/math/lib.mjs +7 -0
- package/dist/mjs/src/math/rounding.d.ts +4 -0
- package/dist/mjs/src/rendering/Display.d.ts +75 -0
- package/dist/{src/rendering/Display.js → mjs/src/rendering/Display.mjs} +7 -7
- package/dist/mjs/src/rendering/RenderingStyle.d.ts +31 -0
- package/dist/{src/rendering/RenderingStyle.js → mjs/src/rendering/RenderingStyle.mjs} +1 -1
- package/dist/mjs/src/rendering/TextRenderingStyle.d.ts +36 -0
- package/dist/{src/rendering/TextRenderingStyle.js → mjs/src/rendering/TextRenderingStyle.mjs} +1 -1
- package/dist/mjs/src/rendering/caching/CacheRecord.d.ts +20 -0
- package/dist/{src/rendering/caching/CacheRecord.js → mjs/src/rendering/caching/CacheRecord.mjs} +1 -1
- package/dist/mjs/src/rendering/caching/CacheRecordManager.d.ts +12 -0
- package/dist/{src/rendering/caching/CacheRecordManager.js → mjs/src/rendering/caching/CacheRecordManager.mjs} +1 -1
- package/dist/mjs/src/rendering/caching/RenderingCache.d.ts +11 -0
- package/dist/{src/rendering/caching/RenderingCache.js → mjs/src/rendering/caching/RenderingCache.mjs} +3 -3
- package/dist/mjs/src/rendering/caching/RenderingCacheNode.d.ts +29 -0
- package/dist/{src/rendering/caching/RenderingCacheNode.js → mjs/src/rendering/caching/RenderingCacheNode.mjs} +3 -3
- package/dist/mjs/src/rendering/caching/testUtils.d.ts +9 -0
- package/dist/{src/rendering/caching/testUtils.js → mjs/src/rendering/caching/testUtils.mjs} +4 -4
- package/dist/mjs/src/rendering/caching/types.d.ts +19 -0
- package/dist/mjs/src/rendering/caching/types.mjs +1 -0
- package/dist/{src/rendering/lib.js → mjs/src/rendering/lib.d.ts} +2 -0
- package/dist/mjs/src/rendering/lib.mjs +5 -0
- package/dist/mjs/src/rendering/localization.d.ts +10 -0
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.d.ts +68 -0
- package/dist/{src/rendering/renderers/AbstractRenderer.js → mjs/src/rendering/renderers/AbstractRenderer.mjs} +3 -3
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.d.ts +63 -0
- package/dist/{src/rendering/renderers/CanvasRenderer.js → mjs/src/rendering/renderers/CanvasRenderer.mjs} +32 -5
- package/dist/mjs/src/rendering/renderers/DummyRenderer.d.ts +35 -0
- package/dist/{src/rendering/renderers/DummyRenderer.js → mjs/src/rendering/renderers/DummyRenderer.mjs} +2 -2
- package/dist/mjs/src/rendering/renderers/SVGRenderer.d.ts +57 -0
- package/dist/{src/rendering/renderers/SVGRenderer.js → mjs/src/rendering/renderers/SVGRenderer.mjs} +33 -7
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.d.ts +29 -0
- package/dist/{src/rendering/renderers/TextOnlyRenderer.js → mjs/src/rendering/renderers/TextOnlyRenderer.mjs} +2 -2
- package/dist/mjs/src/testing/beforeEachFile.d.ts +1 -0
- package/dist/{src/testing/beforeEachFile.js → mjs/src/testing/beforeEachFile.mjs} +1 -1
- package/dist/mjs/src/testing/createEditor.d.ts +4 -0
- package/dist/{src/testing/createEditor.js → mjs/src/testing/createEditor.mjs} +2 -2
- package/dist/mjs/src/testing/lib.d.ts +2 -0
- package/dist/mjs/src/testing/lib.mjs +2 -0
- package/dist/mjs/src/testing/loadExpectExtensions.d.ts +2 -0
- package/dist/mjs/src/testing/sendPenEvent.d.ts +12 -0
- package/dist/mjs/src/testing/sendPenEvent.mjs +19 -0
- package/dist/mjs/src/testing/sendTouchEvent.d.ts +42 -0
- package/dist/mjs/src/testing/sendTouchEvent.mjs +62 -0
- package/dist/mjs/src/toolbar/HTMLToolbar.d.ts +103 -0
- package/dist/{src/toolbar/HTMLToolbar.js → mjs/src/toolbar/HTMLToolbar.mjs} +17 -17
- package/dist/mjs/src/toolbar/IconProvider.d.ts +62 -0
- package/dist/{src/toolbar/IconProvider.js → mjs/src/toolbar/IconProvider.mjs} +4 -4
- package/dist/mjs/src/toolbar/lib.mjs +3 -0
- package/dist/mjs/src/toolbar/localization.d.ts +49 -0
- package/dist/mjs/src/toolbar/makeColorInput.d.ts +6 -0
- package/dist/{src/toolbar/makeColorInput.js → mjs/src/toolbar/makeColorInput.mjs} +3 -3
- package/dist/mjs/src/toolbar/types.d.ts +4 -0
- package/dist/mjs/src/toolbar/types.mjs +1 -0
- package/dist/mjs/src/toolbar/widgets/ActionButtonWidget.d.ts +15 -0
- package/dist/{src/toolbar/widgets/ActionButtonWidget.js → mjs/src/toolbar/widgets/ActionButtonWidget.mjs} +1 -1
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.d.ts +11 -0
- package/dist/{src/toolbar/widgets/BaseToolWidget.js → mjs/src/toolbar/widgets/BaseToolWidget.mjs} +2 -2
- package/dist/mjs/src/toolbar/widgets/BaseWidget.d.ts +72 -0
- package/dist/{src/toolbar/widgets/BaseWidget.js → mjs/src/toolbar/widgets/BaseWidget.mjs} +3 -3
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +18 -0
- package/dist/{src/toolbar/widgets/DocumentPropertiesWidget.js → mjs/src/toolbar/widgets/DocumentPropertiesWidget.mjs} +9 -7
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.d.ts +17 -0
- package/dist/{src/toolbar/widgets/EraserToolWidget.js → mjs/src/toolbar/widgets/EraserToolWidget.mjs} +3 -3
- package/dist/mjs/src/toolbar/widgets/HandToolWidget.d.ts +17 -0
- package/dist/{src/toolbar/widgets/HandToolWidget.js → mjs/src/toolbar/widgets/HandToolWidget.mjs} +7 -7
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.d.ts +19 -0
- package/dist/{src/toolbar/widgets/InsertImageWidget.js → mjs/src/toolbar/widgets/InsertImageWidget.mjs} +8 -8
- package/dist/mjs/src/toolbar/widgets/OverflowWidget.d.ts +25 -0
- package/dist/{src/toolbar/widgets/OverflowWidget.js → mjs/src/toolbar/widgets/OverflowWidget.mjs} +1 -1
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.d.ts +27 -0
- package/dist/{src/toolbar/widgets/PenToolWidget.js → mjs/src/toolbar/widgets/PenToolWidget.mjs} +11 -10
- package/dist/mjs/src/toolbar/widgets/SelectionToolWidget.d.ts +13 -0
- package/dist/{src/toolbar/widgets/SelectionToolWidget.js → mjs/src/toolbar/widgets/SelectionToolWidget.mjs} +8 -8
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.d.ts +16 -0
- package/dist/{src/toolbar/widgets/TextToolWidget.js → mjs/src/toolbar/widgets/TextToolWidget.mjs} +9 -6
- package/dist/mjs/src/toolbar/widgets/lib.mjs +10 -0
- package/dist/mjs/src/tools/BaseTool.d.ts +22 -0
- package/dist/{src/tools/BaseTool.js → mjs/src/tools/BaseTool.mjs} +1 -1
- package/dist/mjs/src/tools/Eraser.d.ts +23 -0
- package/dist/{src/tools/Eraser.js → mjs/src/tools/Eraser.mjs} +8 -8
- package/dist/mjs/src/tools/FindTool.d.ts +21 -0
- package/dist/{src/tools/FindTool.js → mjs/src/tools/FindTool.mjs} +2 -2
- package/dist/mjs/src/tools/PanZoom.d.ts +52 -0
- package/dist/{src/tools/PanZoom.js → mjs/src/tools/PanZoom.mjs} +8 -8
- package/dist/mjs/src/tools/PasteHandler.d.ts +23 -0
- package/dist/{src/tools/PasteHandler.js → mjs/src/tools/PasteHandler.mjs} +7 -7
- package/dist/mjs/src/tools/Pen.d.ts +39 -0
- package/dist/{src/tools/Pen.js → mjs/src/tools/Pen.mjs} +5 -5
- package/dist/mjs/src/tools/PipetteTool.d.ts +18 -0
- package/dist/{src/tools/PipetteTool.js → mjs/src/tools/PipetteTool.mjs} +1 -1
- package/dist/mjs/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +8 -0
- package/dist/{src/tools/SelectionTool/SelectAllShortcutHandler.js → mjs/src/tools/SelectionTool/SelectAllShortcutHandler.mjs} +2 -2
- package/dist/mjs/src/tools/SelectionTool/Selection.d.ts +64 -0
- package/dist/{src/tools/SelectionTool/Selection.js → mjs/src/tools/SelectionTool/Selection.mjs} +12 -12
- package/dist/mjs/src/tools/SelectionTool/SelectionHandle.d.ts +38 -0
- package/dist/{src/tools/SelectionTool/SelectionHandle.js → mjs/src/tools/SelectionTool/SelectionHandle.mjs} +3 -3
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.d.ts +36 -0
- package/dist/{src/tools/SelectionTool/SelectionTool.js → mjs/src/tools/SelectionTool/SelectionTool.mjs} +13 -14
- package/dist/mjs/src/tools/SelectionTool/TransformMode.d.ts +34 -0
- package/dist/{src/tools/SelectionTool/TransformMode.js → mjs/src/tools/SelectionTool/TransformMode.mjs} +4 -4
- package/dist/mjs/src/tools/SelectionTool/types.d.ts +9 -0
- package/dist/mjs/src/tools/TextTool.d.ts +33 -0
- package/dist/{src/tools/TextTool.js → mjs/src/tools/TextTool.mjs} +11 -11
- package/dist/mjs/src/tools/ToolController.d.ts +18 -0
- package/dist/{src/tools/ToolController.js → mjs/src/tools/ToolController.mjs} +16 -16
- package/dist/mjs/src/tools/ToolEnabledGroup.d.ts +6 -0
- package/dist/mjs/src/tools/ToolSwitcherShortcut.d.ts +16 -0
- package/dist/{src/tools/ToolSwitcherShortcut.js → mjs/src/tools/ToolSwitcherShortcut.mjs} +1 -1
- package/dist/mjs/src/tools/ToolbarShortcutHandler.d.ts +12 -0
- package/dist/{src/tools/ToolbarShortcutHandler.js → mjs/src/tools/ToolbarShortcutHandler.mjs} +1 -1
- package/dist/mjs/src/tools/UndoRedoShortcut.d.ts +8 -0
- package/dist/{src/tools/UndoRedoShortcut.js → mjs/src/tools/UndoRedoShortcut.mjs} +1 -1
- package/dist/{src/tools/lib.js → mjs/src/tools/lib.d.ts} +1 -1
- package/dist/mjs/src/tools/lib.mjs +16 -0
- package/dist/mjs/src/tools/localization.d.ts +28 -0
- package/dist/mjs/src/types.d.ts +151 -0
- package/dist/mjs/src/util/assertions.d.ts +23 -0
- package/dist/mjs/src/util/fileToBase64.d.ts +3 -0
- package/dist/mjs/src/util/untilNextAnimationFrame.d.ts +3 -0
- package/dist/mjs/src/util/waitForTimeout.d.ts +2 -0
- package/package.json +34 -33
- package/src/Color4.ts +2 -0
- package/src/Editor.ts +62 -28
- package/src/EditorImage.ts +4 -2
- package/src/SVGLoader.ts +4 -0
- package/src/lib.ts +2 -1
- package/src/rendering/lib.ts +2 -0
- package/src/rendering/renderers/CanvasRenderer.ts +27 -0
- package/src/rendering/renderers/SVGRenderer.ts +32 -1
- package/src/testing/lib.ts +3 -0
- package/src/testing/sendPenEvent.ts +31 -0
- package/src/testing/sendTouchEvent.ts +36 -1
- package/src/toolbar/toolbar.css +5 -0
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +4 -2
- package/src/toolbar/widgets/PenToolWidget.ts +1 -0
- package/src/toolbar/widgets/TextToolWidget.ts +4 -1
- package/src/tools/Eraser.test.ts +11 -10
- package/src/tools/PanZoom.test.ts +1 -1
- package/src/tools/Pen.test.ts +63 -62
- package/src/tools/SelectionTool/SelectionTool.test.ts +15 -14
- package/src/tools/SelectionTool/SelectionTool.ts +5 -7
- package/tsconfig.json +3 -2
- package/tsconfig.mjs.json +9 -0
- package/dist/src/testing/sendTouchEvent.d.ts +0 -6
- package/dist/src/testing/sendTouchEvent.js +0 -26
- /package/dist/{build_tools → cjs/build_tools}/BundledFile.d.ts +0 -0
- /package/dist/{build_tools → cjs/build_tools}/buildTranslationTemplate.d.ts +0 -0
- /package/dist/{build_tools → cjs/build_tools}/bundle.d.ts +0 -0
- /package/dist/{src/components/builders/types.js → cjs/build_tools/postDist.d.ts} +0 -0
- /package/dist/{src → cjs/src}/EventDispatcher.d.ts +0 -0
- /package/dist/{src → cjs/src}/Pointer.d.ts +0 -0
- /package/dist/{src → cjs/src}/UndoRedoHistory.d.ts +0 -0
- /package/dist/{src → cjs/src}/Viewport.d.ts +0 -0
- /package/dist/{src → cjs/src}/bundle/bundled.d.ts +0 -0
- /package/dist/{src → cjs/src}/commands/Command.d.ts +0 -0
- /package/dist/{src → cjs/src}/commands/Duplicate.d.ts +0 -0
- /package/dist/{src → cjs/src}/commands/Erase.d.ts +0 -0
- /package/dist/{src → cjs/src}/commands/SerializableCommand.d.ts +0 -0
- /package/dist/{src → cjs/src}/commands/UnresolvedCommand.d.ts +0 -0
- /package/dist/{src → cjs/src}/commands/invertCommand.d.ts +0 -0
- /package/dist/{src → cjs/src}/commands/lib.d.ts +0 -0
- /package/dist/{src → cjs/src}/commands/localization.d.ts +0 -0
- /package/dist/{src → cjs/src}/commands/uniteCommands.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/AbstractComponent.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/ImageBackground.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/ImageComponent.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/RestylableComponent.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/SVGGlobalAttributesObject.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/Stroke.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/TextComponent.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/UnknownSVGObject.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/builders/ArrowBuilder.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/builders/FreehandLineBuilder.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/builders/LineBuilder.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/builders/RectangleBuilder.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/builders/types.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/lib.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/localization.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/util/StrokeSmoother.d.ts +0 -0
- /package/dist/{src → cjs/src}/components/util/describeComponentList.d.ts +0 -0
- /package/dist/{src → cjs/src}/localization.d.ts +0 -0
- /package/dist/{src → cjs/src}/localizations/de.d.ts +0 -0
- /package/dist/{src → cjs/src}/localizations/en.d.ts +0 -0
- /package/dist/{src → cjs/src}/localizations/es.d.ts +0 -0
- /package/dist/{src → cjs/src}/localizations/getLocalizationTable.d.ts +0 -0
- /package/dist/{src → cjs/src}/math/LineSegment2.d.ts +0 -0
- /package/dist/{src → cjs/src}/math/Mat33.d.ts +0 -0
- /package/dist/{src → cjs/src}/math/Path.d.ts +0 -0
- /package/dist/{src → cjs/src}/math/Rect2.d.ts +0 -0
- /package/dist/{src → cjs/src}/math/Triangle.d.ts +0 -0
- /package/dist/{src → cjs/src}/math/Vec2.d.ts +0 -0
- /package/dist/{src → cjs/src}/math/Vec3.d.ts +0 -0
- /package/dist/{src → cjs/src}/math/lib.d.ts +0 -0
- /package/dist/{src → cjs/src}/math/rounding.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/Display.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/RenderingStyle.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/TextRenderingStyle.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/caching/CacheRecord.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/caching/CacheRecordManager.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/caching/RenderingCache.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/caching/RenderingCacheNode.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/caching/testUtils.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/caching/types.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/localization.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/renderers/AbstractRenderer.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/renderers/DummyRenderer.d.ts +0 -0
- /package/dist/{src → cjs/src}/rendering/renderers/TextOnlyRenderer.d.ts +0 -0
- /package/dist/{src → cjs/src}/testing/beforeEachFile.d.ts +0 -0
- /package/dist/{src → cjs/src}/testing/createEditor.d.ts +0 -0
- /package/dist/{src → cjs/src}/testing/loadExpectExtensions.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/HTMLToolbar.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/IconProvider.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/lib.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/localization.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/makeColorInput.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/types.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/ActionButtonWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/BaseToolWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/BaseWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/DocumentPropertiesWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/EraserToolWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/HandToolWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/InsertImageWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/OverflowWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/PenToolWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/SelectionToolWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/TextToolWidget.d.ts +0 -0
- /package/dist/{src → cjs/src}/toolbar/widgets/lib.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/BaseTool.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/Eraser.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/FindTool.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/PanZoom.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/PasteHandler.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/Pen.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/PipetteTool.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/SelectionTool/SelectAllShortcutHandler.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/SelectionTool/Selection.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/SelectionTool/SelectionHandle.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/SelectionTool/SelectionTool.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/SelectionTool/TransformMode.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/SelectionTool/types.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/TextTool.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/ToolController.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/ToolEnabledGroup.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/ToolSwitcherShortcut.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/ToolbarShortcutHandler.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/UndoRedoShortcut.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/lib.d.ts +0 -0
- /package/dist/{src → cjs/src}/tools/localization.d.ts +0 -0
- /package/dist/{src → cjs/src}/types.d.ts +0 -0
- /package/dist/{src → cjs/src}/util/assertions.d.ts +0 -0
- /package/dist/{src → cjs/src}/util/fileToBase64.d.ts +0 -0
- /package/dist/{src → cjs/src}/util/untilNextAnimationFrame.d.ts +0 -0
- /package/dist/{src → cjs/src}/util/waitForTimeout.d.ts +0 -0
- /package/dist/{build_tools/BundledFile.js → mjs/build_tools/BundledFile.mjs} +0 -0
- /package/dist/{src/rendering/caching/types.js → mjs/build_tools/buildTranslationTemplate.d.ts} +0 -0
- /package/dist/{src/toolbar/types.js → mjs/build_tools/bundle.d.ts} +0 -0
- /package/dist/{src/EventDispatcher.js → mjs/src/EventDispatcher.mjs} +0 -0
- /package/dist/{src/commands/Command.js → mjs/src/commands/Command.mjs} +0 -0
- /package/dist/{src/commands/lib.js → mjs/src/commands/lib.d.ts} +0 -0
- /package/dist/{src/commands/localization.js → mjs/src/commands/localization.mjs} +0 -0
- /package/dist/{src/components/localization.js → mjs/src/components/localization.mjs} +0 -0
- /package/dist/{src/components/util/describeComponentList.js → mjs/src/components/util/describeComponentList.mjs} +0 -0
- /package/dist/{src/math/Triangle.js → mjs/src/math/Triangle.mjs} +0 -0
- /package/dist/{src/math/Vec3.js → mjs/src/math/Vec3.mjs} +0 -0
- /package/dist/{src/math/lib.js → mjs/src/math/lib.d.ts} +0 -0
- /package/dist/{src/math/rounding.js → mjs/src/math/rounding.mjs} +0 -0
- /package/dist/{src/rendering/localization.js → mjs/src/rendering/localization.mjs} +0 -0
- /package/dist/{src/testing/loadExpectExtensions.js → mjs/src/testing/loadExpectExtensions.mjs} +0 -0
- /package/dist/{src/toolbar/lib.js → mjs/src/toolbar/lib.d.ts} +0 -0
- /package/dist/{src/toolbar/localization.js → mjs/src/toolbar/localization.mjs} +0 -0
- /package/dist/{src/toolbar/widgets/lib.js → mjs/src/toolbar/widgets/lib.d.ts} +0 -0
- /package/dist/{src/tools/SelectionTool/types.js → mjs/src/tools/SelectionTool/types.mjs} +0 -0
- /package/dist/{src/tools/ToolEnabledGroup.js → mjs/src/tools/ToolEnabledGroup.mjs} +0 -0
- /package/dist/{src/tools/localization.js → mjs/src/tools/localization.mjs} +0 -0
- /package/dist/{src/types.js → mjs/src/types.mjs} +0 -0
- /package/dist/{src/util/assertions.js → mjs/src/util/assertions.mjs} +0 -0
- /package/dist/{src/util/fileToBase64.js → mjs/src/util/fileToBase64.mjs} +0 -0
- /package/dist/{src/util/untilNextAnimationFrame.js → mjs/src/util/untilNextAnimationFrame.mjs} +0 -0
- /package/dist/{src/util/waitForTimeout.js → mjs/src/util/waitForTimeout.mjs} +0 -0
@@ -0,0 +1,163 @@
|
|
1
|
+
"use strict";
|
2
|
+
// This file is taken from Joplin: https://github.com/laurent22/joplin
|
3
|
+
// js-draw was originally created as a part of a pull request for joplin. This
|
4
|
+
// is part of the functionality from Joplin it requires.
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
12
|
+
});
|
13
|
+
};
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
16
|
+
};
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
+
const path_1 = require("path");
|
19
|
+
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
20
|
+
const webpack_1 = __importDefault(require("webpack"));
|
21
|
+
class BundledFile {
|
22
|
+
constructor(bundleName, sourceFilePath, outputFilepath) {
|
23
|
+
this.bundleName = bundleName;
|
24
|
+
this.sourceFilePath = sourceFilePath;
|
25
|
+
this.rootFileDirectory = (0, path_1.dirname)(sourceFilePath);
|
26
|
+
this.bundleBaseName = (0, path_1.basename)(sourceFilePath, (0, path_1.extname)(sourceFilePath));
|
27
|
+
if (outputFilepath) {
|
28
|
+
this.outputDirectory = (0, path_1.dirname)(outputFilepath);
|
29
|
+
this.outputFilename = (0, path_1.basename)(outputFilepath);
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
this.outputDirectory = this.rootFileDirectory;
|
33
|
+
this.outputFilename = `${this.bundleBaseName}.bundle.js`;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
getWebpackOptions(mode) {
|
37
|
+
const config = {
|
38
|
+
mode,
|
39
|
+
entry: this.sourceFilePath,
|
40
|
+
output: {
|
41
|
+
path: this.outputDirectory,
|
42
|
+
filename: this.outputFilename,
|
43
|
+
library: {
|
44
|
+
type: 'window',
|
45
|
+
name: this.bundleName,
|
46
|
+
},
|
47
|
+
},
|
48
|
+
// See https://webpack.js.org/guides/typescript/
|
49
|
+
module: {
|
50
|
+
rules: [
|
51
|
+
{
|
52
|
+
// Include .tsx to include react components
|
53
|
+
test: /\.tsx?$/i,
|
54
|
+
use: 'ts-loader',
|
55
|
+
exclude: /node_modules/,
|
56
|
+
},
|
57
|
+
{
|
58
|
+
test: /\.css$/i,
|
59
|
+
use: ['style-loader', 'css-loader'],
|
60
|
+
},
|
61
|
+
],
|
62
|
+
},
|
63
|
+
optimization: {
|
64
|
+
minimizer: [
|
65
|
+
// Don't create separate files for comments.
|
66
|
+
// See https://stackoverflow.com/a/65650316/17055750
|
67
|
+
new terser_webpack_plugin_1.default({
|
68
|
+
extractComments: false,
|
69
|
+
}),
|
70
|
+
],
|
71
|
+
},
|
72
|
+
// Increase the minimum size required
|
73
|
+
// to trigger warnings.
|
74
|
+
// See https://stackoverflow.com/a/53517149/17055750
|
75
|
+
performance: {
|
76
|
+
maxAssetSize: 2000000,
|
77
|
+
maxEntrypointSize: 2000000,
|
78
|
+
},
|
79
|
+
resolve: {
|
80
|
+
extensions: ['.tsx', '.ts', '.js'],
|
81
|
+
},
|
82
|
+
};
|
83
|
+
return config;
|
84
|
+
}
|
85
|
+
handleErrors(err, stats) {
|
86
|
+
let failed = false;
|
87
|
+
if (err) {
|
88
|
+
console.error(`Error: ${err.name}`, err.message, err.stack);
|
89
|
+
failed = true;
|
90
|
+
}
|
91
|
+
else if ((stats === null || stats === void 0 ? void 0 : stats.hasErrors()) || (stats === null || stats === void 0 ? void 0 : stats.hasWarnings())) {
|
92
|
+
const data = stats.toJson();
|
93
|
+
if (data.warnings && data.warningsCount) {
|
94
|
+
console.warn('Warnings: ', data.warningsCount);
|
95
|
+
for (const warning of data.warnings) {
|
96
|
+
// Stack contains the message
|
97
|
+
if (warning.stack) {
|
98
|
+
console.warn(warning.stack);
|
99
|
+
}
|
100
|
+
else {
|
101
|
+
console.warn(warning.message);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
if (data.errors && data.errorsCount) {
|
106
|
+
console.error('Errors: ', data.errorsCount);
|
107
|
+
for (const error of data.errors) {
|
108
|
+
if (error.stack) {
|
109
|
+
console.error(error.stack);
|
110
|
+
}
|
111
|
+
else {
|
112
|
+
console.error(error.message);
|
113
|
+
}
|
114
|
+
console.error();
|
115
|
+
}
|
116
|
+
failed = true;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
return failed;
|
120
|
+
}
|
121
|
+
// Create a minified JS file in the same directory as `this.sourceFilePath` with
|
122
|
+
// the same name.
|
123
|
+
build() {
|
124
|
+
const compiler = (0, webpack_1.default)(this.getWebpackOptions('production'));
|
125
|
+
return new Promise((resolve, reject) => {
|
126
|
+
console.info(`Building bundle: ${this.bundleName}...`);
|
127
|
+
compiler.run((err, stats) => {
|
128
|
+
let failed = this.handleErrors(err, stats);
|
129
|
+
// Clean up.
|
130
|
+
compiler.close((error) => __awaiter(this, void 0, void 0, function* () {
|
131
|
+
if (error) {
|
132
|
+
console.error('Error cleaning up:', error);
|
133
|
+
failed = true;
|
134
|
+
}
|
135
|
+
if (!failed) {
|
136
|
+
console.log('☑ Done building! ☑');
|
137
|
+
resolve();
|
138
|
+
}
|
139
|
+
else {
|
140
|
+
reject();
|
141
|
+
}
|
142
|
+
}));
|
143
|
+
});
|
144
|
+
});
|
145
|
+
}
|
146
|
+
startWatching() {
|
147
|
+
const compiler = (0, webpack_1.default)(this.getWebpackOptions('development'));
|
148
|
+
const watchOptions = {
|
149
|
+
ignored: [
|
150
|
+
'**/node_modules',
|
151
|
+
'**/dist',
|
152
|
+
],
|
153
|
+
};
|
154
|
+
console.info('Watching bundle: ', this.bundleName);
|
155
|
+
compiler.watch(watchOptions, (err, stats) => __awaiter(this, void 0, void 0, function* () {
|
156
|
+
const failed = this.handleErrors(err, stats);
|
157
|
+
if (!failed) {
|
158
|
+
console.log('☑ Built! ☑');
|
159
|
+
}
|
160
|
+
}));
|
161
|
+
}
|
162
|
+
}
|
163
|
+
exports.default = BundledFile;
|
@@ -0,0 +1,119 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
const fs = __importStar(require("fs"));
|
27
|
+
const path = __importStar(require("path"));
|
28
|
+
const localization_1 = require("../src/localization");
|
29
|
+
// Adds markdown formatting to format text like code.
|
30
|
+
const codeFormat = (text) => {
|
31
|
+
let maxConsecutiveBackticks = 0;
|
32
|
+
// Find the longest number of consecutive backticks — we need to have more
|
33
|
+
// than that for the delimiters.
|
34
|
+
const backtickRuns = text.matchAll(/[`]+/g);
|
35
|
+
for (const backticks of backtickRuns) {
|
36
|
+
if (backticks.length > maxConsecutiveBackticks) {
|
37
|
+
maxConsecutiveBackticks = backticks.length;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
let codeStartEnd = '';
|
41
|
+
for (let i = 0; i < maxConsecutiveBackticks + 1; i++) {
|
42
|
+
codeStartEnd += '`';
|
43
|
+
}
|
44
|
+
// If the text already starts with a `, add a space to prevent the
|
45
|
+
// markdown parser from treating it as part of the delimiter.
|
46
|
+
if (text.startsWith('`')) {
|
47
|
+
text = ' ' + text;
|
48
|
+
}
|
49
|
+
if (text.endsWith('`')) {
|
50
|
+
text = text + ' ';
|
51
|
+
}
|
52
|
+
return `${codeStartEnd}${text}${codeStartEnd}`;
|
53
|
+
};
|
54
|
+
const collapseSpaces = (text) => text.replace(/\s+/g, ' ');
|
55
|
+
const generateTranslationTemplate = () => {
|
56
|
+
const bodyContentLines = [];
|
57
|
+
const addInput = (type, id, attrs, required = false) => {
|
58
|
+
const lines = [];
|
59
|
+
lines.push(` - type: ${type}`);
|
60
|
+
lines.push(` id: ${id}`);
|
61
|
+
lines.push(' attributes:');
|
62
|
+
for (const key in attrs) {
|
63
|
+
const value = `${attrs[key]}`;
|
64
|
+
const escapedValue = value.replace(/[\\]/g, '\\\\').replace(/"/g, '\\"');
|
65
|
+
lines.push(` ${key}: "${escapedValue}"`);
|
66
|
+
}
|
67
|
+
lines.push(' validations:');
|
68
|
+
lines.push(` required: ${required}`);
|
69
|
+
bodyContentLines.push(...lines);
|
70
|
+
};
|
71
|
+
const addLabel = (text) => {
|
72
|
+
bodyContentLines.push(' - type: markdown');
|
73
|
+
bodyContentLines.push(' attributes:');
|
74
|
+
bodyContentLines.push(' value: |');
|
75
|
+
bodyContentLines.push(' ' + text);
|
76
|
+
};
|
77
|
+
addLabel(collapseSpaces(`
|
78
|
+
Thank you for taking the time to translate \`js-draw\`! If you don't have time to translate
|
79
|
+
all of the strings below, feel free to submit an incomplete translation and edit it later.
|
80
|
+
Use this template to update an existing translation or to create a new translation.
|
81
|
+
`));
|
82
|
+
addLabel(collapseSpaces(`
|
83
|
+
(Optional) If you would like to submit a pull request that applies this translation,
|
84
|
+
note that existing translations are present in
|
85
|
+
[src/localizations/](https://github.com/personalizedrefrigerator/js-draw/tree/main/src/localizations).
|
86
|
+
`));
|
87
|
+
addInput('input', 'language-name', {
|
88
|
+
label: 'Language',
|
89
|
+
description: 'The name of the language to translate to in English (e.g. Spanish)',
|
90
|
+
}, true);
|
91
|
+
for (const key in localization_1.defaultEditorLocalization) {
|
92
|
+
const englishTranslation = `${localization_1.defaultEditorLocalization[key]}`;
|
93
|
+
addInput('input', `translation-${key}`, {
|
94
|
+
label: `${key}`,
|
95
|
+
description: `Translate ${codeFormat(englishTranslation)}.`,
|
96
|
+
placeholder: englishTranslation,
|
97
|
+
});
|
98
|
+
}
|
99
|
+
addInput('textarea', 'additional-comments', {
|
100
|
+
label: 'Additional information',
|
101
|
+
placeholder: 'Any additional information/comments on the translation can go here.',
|
102
|
+
});
|
103
|
+
return `name: Translation
|
104
|
+
# This template is auto-generated by build_tools/buildTranslationTemplate.ts
|
105
|
+
# Do not modify it directly.
|
106
|
+
description: Translate the editor to a new language!
|
107
|
+
title: "[Translation]: <language>"
|
108
|
+
labels: [localization]
|
109
|
+
assignees: []
|
110
|
+
body:
|
111
|
+
${bodyContentLines.join('\n')}`;
|
112
|
+
};
|
113
|
+
const template = generateTranslationTemplate();
|
114
|
+
// According to https://stackoverflow.com/a/13650454, fs should
|
115
|
+
// be able to handle forward and back slashes (both) on Windows (so extra
|
116
|
+
// path logic shouldn't be needed here.)
|
117
|
+
const rootDir = path.dirname(__dirname);
|
118
|
+
const translationTempaltePath = path.join(rootDir, '.github/ISSUE_TEMPLATE/translation.yml');
|
119
|
+
fs.writeFileSync(translationTempaltePath, template);
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const path_1 = require("path");
|
7
|
+
const BundledFile_1 = __importDefault(require("./BundledFile"));
|
8
|
+
const rootDir = (0, path_1.dirname)(__dirname);
|
9
|
+
const mainBundle = new BundledFile_1.default('jsdraw', `${rootDir}/src/bundle/bundled.ts`, `${rootDir}/dist/bundle.js`);
|
10
|
+
void mainBundle.build();
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const promises_1 = require("fs/promises");
|
16
|
+
const path_1 = __importDefault(require("path"));
|
17
|
+
// Script to be run after building JavaScript files from TypeScript.
|
18
|
+
// TODO: This is very hacky.
|
19
|
+
// TODO: [Use the TypeScript Compiler API instead.](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API)
|
20
|
+
// Iterates over every JavaScript file in [directory].
|
21
|
+
const forEachFile = (directory, processFile) => __awaiter(void 0, void 0, void 0, function* () {
|
22
|
+
const files = yield (0, promises_1.readdir)(directory);
|
23
|
+
yield Promise.all(files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
|
24
|
+
const filePath = path_1.default.join(directory, file);
|
25
|
+
const stats = yield (0, promises_1.stat)(filePath);
|
26
|
+
if (stats.isDirectory()) {
|
27
|
+
yield forEachFile(filePath, processFile);
|
28
|
+
}
|
29
|
+
else if (stats.isFile()) {
|
30
|
+
yield processFile(filePath);
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
throw new Error('Unknown file type!');
|
34
|
+
}
|
35
|
+
})));
|
36
|
+
});
|
37
|
+
const removeFiles = (directory, filePattern) => __awaiter(void 0, void 0, void 0, function* () {
|
38
|
+
yield forEachFile(directory, (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
39
|
+
if (!filePath.match(filePattern)) {
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
yield (0, promises_1.unlink)(filePath);
|
43
|
+
}));
|
44
|
+
});
|
45
|
+
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
46
|
+
const rootDir = path_1.default.dirname(__dirname);
|
47
|
+
const cjsPath = `${rootDir}/dist/cjs`;
|
48
|
+
const mjsPath = `${rootDir}/dist/mjs`;
|
49
|
+
const testPattern = /\.test\.js$/;
|
50
|
+
yield removeFiles(cjsPath, testPattern);
|
51
|
+
yield removeFiles(mjsPath, testPattern);
|
52
|
+
// We need to replace imports in ESM files.
|
53
|
+
yield forEachFile(mjsPath, (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
54
|
+
if (!filePath.endsWith('.js')) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
// Rename
|
58
|
+
const newPath = filePath.replace(/\.js$/, '.mjs');
|
59
|
+
yield (0, promises_1.rename)(filePath, newPath);
|
60
|
+
// Change imports from
|
61
|
+
// import foo from './bar'
|
62
|
+
// to
|
63
|
+
// import foo from './bar.mjs'
|
64
|
+
// and exports similarly.
|
65
|
+
let contents = yield (0, promises_1.readFile)(newPath, { encoding: 'utf-8' });
|
66
|
+
// TODO: Switch to using the TypeScript compiler API. This has the danger of changing imports
|
67
|
+
// in multi-line strings.
|
68
|
+
contents = contents.replace(/([\n]|^)(import|export)(.*)from\s+(['"])(\.*\/[^\n]+)(['"])/g, '$1$2 $3 from $4$5.mjs$6');
|
69
|
+
yield (0, promises_1.writeFile)(newPath, contents);
|
70
|
+
}));
|
71
|
+
});
|
72
|
+
main();
|
@@ -0,0 +1,197 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Color4 = void 0;
|
4
|
+
class Color4 {
|
5
|
+
constructor(
|
6
|
+
/** Red component. Should be in the range [0, 1]. */
|
7
|
+
r,
|
8
|
+
/** Green component. `g` ∈ [0, 1] */
|
9
|
+
g,
|
10
|
+
/** Blue component. `b` ∈ [0, 1] */
|
11
|
+
b,
|
12
|
+
/** Alpha/transparent component. `a` ∈ [0, 1]. 0 = transparent */
|
13
|
+
a) {
|
14
|
+
this.r = r;
|
15
|
+
this.g = g;
|
16
|
+
this.b = b;
|
17
|
+
this.a = a;
|
18
|
+
this.hexString = null;
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* Create a color from red, green, blue components. The color is fully opaque (`a = 1.0`).
|
22
|
+
*
|
23
|
+
* Each component should be in the range [0, 1].
|
24
|
+
*/
|
25
|
+
static ofRGB(red, green, blue) {
|
26
|
+
return Color4.ofRGBA(red, green, blue, 1.0);
|
27
|
+
}
|
28
|
+
static ofRGBA(red, green, blue, alpha) {
|
29
|
+
red = Math.max(0, Math.min(red, 1));
|
30
|
+
green = Math.max(0, Math.min(green, 1));
|
31
|
+
blue = Math.max(0, Math.min(blue, 1));
|
32
|
+
alpha = Math.max(0, Math.min(alpha, 1));
|
33
|
+
return new Color4(red, green, blue, alpha);
|
34
|
+
}
|
35
|
+
static fromHex(hexString) {
|
36
|
+
var _a;
|
37
|
+
// Remove starting '#' (if present)
|
38
|
+
hexString = ((_a = hexString.match(/^[#]?(.*)$/)) !== null && _a !== void 0 ? _a : [])[1];
|
39
|
+
hexString = hexString.toUpperCase();
|
40
|
+
if (!hexString.match(/^[0-9A-F]+$/)) {
|
41
|
+
throw new Error(`${hexString} is not in a valid format.`);
|
42
|
+
}
|
43
|
+
// RGBA or RGB
|
44
|
+
if (hexString.length === 3 || hexString.length === 4) {
|
45
|
+
// Each character is a component
|
46
|
+
const components = hexString.split('');
|
47
|
+
// Convert to RRGGBBAA or RRGGBB format
|
48
|
+
hexString = components.map(component => `${component}0`).join('');
|
49
|
+
}
|
50
|
+
if (hexString.length === 6) {
|
51
|
+
// Alpha component
|
52
|
+
hexString += 'FF';
|
53
|
+
}
|
54
|
+
const components = [];
|
55
|
+
for (let i = 2; i <= hexString.length; i += 2) {
|
56
|
+
const chunk = hexString.substring(i - 2, i);
|
57
|
+
components.push(parseInt(chunk, 16) / 255);
|
58
|
+
}
|
59
|
+
if (components.length !== 4) {
|
60
|
+
throw new Error(`Unable to parse ${hexString}: Wrong number of components.`);
|
61
|
+
}
|
62
|
+
return Color4.ofRGBA(components[0], components[1], components[2], components[3]);
|
63
|
+
}
|
64
|
+
/** Like fromHex, but can handle additional colors if an `HTMLCanvasElement` is available. */
|
65
|
+
static fromString(text) {
|
66
|
+
if (text.startsWith('#')) {
|
67
|
+
return Color4.fromHex(text);
|
68
|
+
}
|
69
|
+
if (text === 'none' || text === 'transparent') {
|
70
|
+
return Color4.transparent;
|
71
|
+
}
|
72
|
+
// rgba?: Match both rgb and rgba strings.
|
73
|
+
// ([,0-9.]+): Match any string of only numeric, '.' and ',' characters.
|
74
|
+
const rgbRegex = /^rgba?\(([,0-9.]+)\)$/i;
|
75
|
+
const rgbMatch = text.replace(/\s*/g, '').match(rgbRegex);
|
76
|
+
if (rgbMatch) {
|
77
|
+
const componentsListStr = rgbMatch[1];
|
78
|
+
const componentsList = JSON.parse(`[ ${componentsListStr} ]`);
|
79
|
+
if (componentsList.length === 3) {
|
80
|
+
return Color4.ofRGB(componentsList[0] / 255, componentsList[1] / 255, componentsList[2] / 255);
|
81
|
+
}
|
82
|
+
else if (componentsList.length === 4) {
|
83
|
+
return Color4.ofRGBA(componentsList[0] / 255, componentsList[1] / 255, componentsList[2] / 255, componentsList[3]);
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
throw new Error(`RGB string, ${text}, has wrong number of components: ${componentsList.length}`);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
// Otherwise, try to use an HTMLCanvasElement to determine the color.
|
90
|
+
// Note: We may be unable to create an HTMLCanvasElement if running as a unit test.
|
91
|
+
const canvas = document.createElement('canvas');
|
92
|
+
canvas.width = 1;
|
93
|
+
canvas.height = 1;
|
94
|
+
const ctx = canvas.getContext('2d');
|
95
|
+
ctx.fillStyle = text;
|
96
|
+
ctx.fillRect(0, 0, 1, 1);
|
97
|
+
const data = ctx.getImageData(0, 0, 1, 1);
|
98
|
+
const red = data.data[0] / 255;
|
99
|
+
const green = data.data[1] / 255;
|
100
|
+
const blue = data.data[2] / 255;
|
101
|
+
const alpha = data.data[3] / 255;
|
102
|
+
return Color4.ofRGBA(red, green, blue, alpha);
|
103
|
+
}
|
104
|
+
/** @returns true if `this` and `other` are approximately equal. */
|
105
|
+
eq(other) {
|
106
|
+
if (other == null) {
|
107
|
+
return false;
|
108
|
+
}
|
109
|
+
// If both completely transparent,
|
110
|
+
if (this.a === 0 && other.a === 0) {
|
111
|
+
return true;
|
112
|
+
}
|
113
|
+
return this.toHexString() === other.toHexString();
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* If `fractionTo` is not in the range [0, 1], it will be clamped to the nearest number
|
117
|
+
* in that range. For example, `a.mix(b, -1)` is equivalent to `a.mix(b, 0)`.
|
118
|
+
*
|
119
|
+
* @returns a color `fractionTo` of the way from this color to `other`.
|
120
|
+
*
|
121
|
+
* @example
|
122
|
+
* ```ts
|
123
|
+
* Color4.ofRGB(1, 0, 0).mix(Color4.ofRGB(0, 1, 0), 0.1) // -> Color4(0.9, 0.1, 0)
|
124
|
+
* ```
|
125
|
+
*/
|
126
|
+
mix(other, fractionTo) {
|
127
|
+
fractionTo = Math.min(Math.max(fractionTo, 0), 1);
|
128
|
+
const fractionOfThis = 1 - fractionTo;
|
129
|
+
return new Color4(this.r * fractionOfThis + other.r * fractionTo, this.g * fractionOfThis + other.g * fractionTo, this.b * fractionOfThis + other.b * fractionTo, this.a * fractionOfThis + other.a * fractionTo);
|
130
|
+
}
|
131
|
+
/**
|
132
|
+
* @returns the component-wise average of `colors`, or `Color4.transparent` if `colors` is empty.
|
133
|
+
*/
|
134
|
+
static average(colors) {
|
135
|
+
let averageA = 0;
|
136
|
+
let averageR = 0;
|
137
|
+
let averageG = 0;
|
138
|
+
let averageB = 0;
|
139
|
+
for (const color of colors) {
|
140
|
+
averageA += color.a;
|
141
|
+
averageR += color.r;
|
142
|
+
averageG += color.g;
|
143
|
+
averageB += color.b;
|
144
|
+
}
|
145
|
+
if (colors.length > 0) {
|
146
|
+
averageA /= colors.length;
|
147
|
+
averageR /= colors.length;
|
148
|
+
averageG /= colors.length;
|
149
|
+
averageB /= colors.length;
|
150
|
+
}
|
151
|
+
return new Color4(averageR, averageG, averageB, averageA);
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
* @returns a hexadecimal color string representation of `this`, in the form `#rrggbbaa`.
|
155
|
+
*
|
156
|
+
* @example
|
157
|
+
* ```
|
158
|
+
* Color4.red.toHexString(); // -> #ff0000ff
|
159
|
+
* ```
|
160
|
+
*/
|
161
|
+
toHexString() {
|
162
|
+
if (this.hexString) {
|
163
|
+
return this.hexString;
|
164
|
+
}
|
165
|
+
const componentToHex = (component) => {
|
166
|
+
const res = Math.round(255 * component).toString(16);
|
167
|
+
if (res.length === 1) {
|
168
|
+
return `0${res}`;
|
169
|
+
}
|
170
|
+
return res;
|
171
|
+
};
|
172
|
+
const alpha = componentToHex(this.a);
|
173
|
+
const red = componentToHex(this.r);
|
174
|
+
const green = componentToHex(this.g);
|
175
|
+
const blue = componentToHex(this.b);
|
176
|
+
if (alpha === 'ff') {
|
177
|
+
return `#${red}${green}${blue}`;
|
178
|
+
}
|
179
|
+
this.hexString = `#${red}${green}${blue}${alpha}`;
|
180
|
+
return this.hexString;
|
181
|
+
}
|
182
|
+
toString() {
|
183
|
+
return this.toHexString();
|
184
|
+
}
|
185
|
+
}
|
186
|
+
exports.default = Color4;
|
187
|
+
exports.Color4 = Color4;
|
188
|
+
Color4.transparent = Color4.ofRGBA(0, 0, 0, 0);
|
189
|
+
Color4.red = Color4.ofRGB(1.0, 0.0, 0.0);
|
190
|
+
Color4.green = Color4.ofRGB(0.0, 1.0, 0.0);
|
191
|
+
Color4.blue = Color4.ofRGB(0.0, 0.0, 1.0);
|
192
|
+
Color4.purple = Color4.ofRGB(0.5, 0.2, 0.5);
|
193
|
+
Color4.yellow = Color4.ofRGB(1, 1, 0.1);
|
194
|
+
Color4.clay = Color4.ofRGB(0.8, 0.4, 0.2);
|
195
|
+
Color4.black = Color4.ofRGB(0, 0, 0);
|
196
|
+
Color4.gray = Color4.ofRGB(0.5, 0.5, 0.5);
|
197
|
+
Color4.white = Color4.ofRGB(1, 1, 1);
|
@@ -46,6 +46,9 @@ export interface EditorSettings {
|
|
46
46
|
* // Do something with saveData...
|
47
47
|
* });
|
48
48
|
* ```
|
49
|
+
*
|
50
|
+
* See also
|
51
|
+
* [`docs/example/example.ts`](https://github.com/personalizedrefrigerator/js-draw/blob/main/docs/example/example.ts#L15).
|
49
52
|
*/
|
50
53
|
export declare class Editor {
|
51
54
|
private container;
|
@@ -123,6 +126,8 @@ export declare class Editor {
|
|
123
126
|
*
|
124
127
|
* // Add the default toolbar
|
125
128
|
* const toolbar = editor.addToolbar();
|
129
|
+
*
|
130
|
+
* // Add a save button
|
126
131
|
* toolbar.addActionButton({
|
127
132
|
* label: 'Save'
|
128
133
|
* icon: createSaveIcon(),
|
@@ -138,6 +143,7 @@ export declare class Editor {
|
|
138
143
|
*
|
139
144
|
* @example
|
140
145
|
* ```
|
146
|
+
* // Set the editor's height to 500px
|
141
147
|
* editor.getRootElement().style.height = '500px';
|
142
148
|
* ```
|
143
149
|
*/
|
@@ -146,6 +152,10 @@ export declare class Editor {
|
|
146
152
|
showLoadingWarning(fractionLoaded: number): void;
|
147
153
|
hideLoadingWarning(): void;
|
148
154
|
private previousAccessibilityAnnouncement;
|
155
|
+
/**
|
156
|
+
* Announce `message` for screen readers. If `message` is the same as the previous
|
157
|
+
* message, it is re-announced.
|
158
|
+
*/
|
149
159
|
announceForAccessibility(message: string): void;
|
150
160
|
/**
|
151
161
|
* Creates a toolbar. If `defaultLayout` is true, default buttons are used.
|
@@ -162,6 +172,25 @@ export declare class Editor {
|
|
162
172
|
handleHTMLPointerEvent(eventType: 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel', evt: PointerEvent): boolean;
|
163
173
|
private isEventSink;
|
164
174
|
private handlePaste;
|
175
|
+
/**
|
176
|
+
* Forward pointer events from `elem` to this editor. Such that right-click/right-click drag
|
177
|
+
* events are also forwarded, `elem`'s contextmenu is disabled.
|
178
|
+
*
|
179
|
+
* @example
|
180
|
+
* ```ts
|
181
|
+
* const overlay = document.createElement('div');
|
182
|
+
* editor.createHTMLOverlay(overlay);
|
183
|
+
*
|
184
|
+
* // Send all pointer events that don't have the control key pressed
|
185
|
+
* // to the editor.
|
186
|
+
* editor.handlePointerEventsFrom(overlay, (event) => {
|
187
|
+
* if (event.ctrlKey) {
|
188
|
+
* return false;
|
189
|
+
* }
|
190
|
+
* return true;
|
191
|
+
* });
|
192
|
+
* ```
|
193
|
+
*/
|
165
194
|
handlePointerEventsFrom(elem: HTMLElement, filter?: HTMLPointerEventFilter): void;
|
166
195
|
/** Adds event listners for keypresses to `elem` and forwards those events to the editor. */
|
167
196
|
handleKeyEventsFrom(elem: HTMLElement): void;
|
@@ -200,25 +229,52 @@ export declare class Editor {
|
|
200
229
|
* Schedule a re-render for some time in the near future. Does not schedule an additional
|
201
230
|
* re-render if a re-render is already queued.
|
202
231
|
*
|
203
|
-
* @returns a promise that resolves when
|
232
|
+
* @returns a promise that resolves when re-rendering has completed.
|
204
233
|
*/
|
205
234
|
queueRerender(): Promise<void>;
|
206
235
|
isRerenderQueued(): boolean;
|
236
|
+
/**
|
237
|
+
* Re-renders the entire image.
|
238
|
+
*
|
239
|
+
* @see {@link Editor.queueRerender}
|
240
|
+
*/
|
207
241
|
rerender(showImageBounds?: boolean): void;
|
208
242
|
/**
|
243
|
+
* Draws the given path onto the wet ink renderer. The given path will
|
244
|
+
* be displayed on top of the main image.
|
245
|
+
*
|
209
246
|
* @see {@link Display.getWetInkRenderer} {@link Display.flatten}
|
210
247
|
*/
|
211
248
|
drawWetInk(...path: RenderablePathSpec[]): void;
|
212
249
|
/**
|
250
|
+
* Clears the wet ink display.
|
251
|
+
*
|
213
252
|
* @see {@link Display.getWetInkRenderer}
|
214
253
|
*/
|
215
254
|
clearWetInk(): void;
|
255
|
+
/**
|
256
|
+
* Focuses the region used for text input/key commands.
|
257
|
+
*/
|
216
258
|
focus(): void;
|
259
|
+
/**
|
260
|
+
* Creates an element that will be positioned on top of the dry/wet ink
|
261
|
+
* renderers.
|
262
|
+
*
|
263
|
+
* This is useful for displaying content on top of the rendered content
|
264
|
+
* (e.g. a selection box).
|
265
|
+
*/
|
217
266
|
createHTMLOverlay(overlay: HTMLElement): {
|
218
267
|
remove: () => void;
|
219
268
|
};
|
220
269
|
addStyleSheet(content: string): HTMLStyleElement;
|
221
270
|
sendKeyboardEvent(eventType: InputEvtType.KeyPressEvent | InputEvtType.KeyUpEvent, key: string, ctrlKey?: boolean, altKey?: boolean): void;
|
271
|
+
/**
|
272
|
+
* Dispatch a pen event to the currently selected tool.
|
273
|
+
* Intended primarially for unit tests.
|
274
|
+
*
|
275
|
+
* @deprecated
|
276
|
+
* @see {@link sendPenEvent} {@link sendTouchEvent}
|
277
|
+
*/
|
222
278
|
sendPenEvent(eventType: InputEvtType.PointerDownEvt | InputEvtType.PointerMoveEvt | InputEvtType.PointerUpEvt, point: Point2, allPointers?: Pointer[]): void;
|
223
279
|
addAndCenterComponents(components: AbstractComponent[], selectComponents?: boolean): Promise<void>;
|
224
280
|
toDataURL(format?: 'image/png' | 'image/jpeg' | 'image/webp'): string;
|