@excalidraw/excalidraw 0.16.1-e8def8d → 0.17.0-7284-25ea35d

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +162 -1
  2. package/dist/excalidraw-assets-dev/{vendor-4d89e0ee30f240211e12.js → vendor-06d9b385f406ee409106.js} +2 -2
  3. package/dist/excalidraw-with-preact.development.js +5883 -0
  4. package/dist/excalidraw-with-preact.production.min.js +2 -0
  5. package/dist/excalidraw-with-preact.production.min.js.LICENSE.txt +21 -0
  6. package/dist/excalidraw.development.js +162 -173
  7. package/dist/excalidraw.production.min.js +1 -1
  8. package/dist/excalidraw.production.min.js.LICENSE.txt +0 -10
  9. package/main.js +7 -1
  10. package/package.json +2 -2
  11. package/types/actions/actionCanvas.d.ts +1 -1
  12. package/types/actions/actionExport.d.ts +1 -1
  13. package/types/actions/actionGroup.d.ts +3 -3
  14. package/types/actions/actionMenu.d.ts +0 -13
  15. package/types/actions/index.d.ts +1 -1
  16. package/types/appState.d.ts +1 -1
  17. package/types/components/Actions.d.ts +3 -2
  18. package/types/components/App.d.ts +18 -9
  19. package/types/components/ImageExportDialog.d.ts +1 -1
  20. package/types/components/LayerUI.d.ts +1 -1
  21. package/types/components/MobileMenu.d.ts +4 -3
  22. package/types/constants.d.ts +6 -1
  23. package/types/data/index.d.ts +10 -2
  24. package/types/element/embeddable.d.ts +1 -1
  25. package/types/element/typeChecks.d.ts +1 -1
  26. package/types/errors.d.ts +5 -0
  27. package/types/frame.d.ts +11 -1
  28. package/types/packages/excalidraw/dist/excalidraw-with-preact.development.d.ts +2 -0
  29. package/types/packages/excalidraw/dist/excalidraw-with-preact.production.min.d.ts +1 -0
  30. package/types/packages/excalidraw/dist/excalidraw.development.d.ts +2 -2
  31. package/types/packages/excalidraw/index.d.ts +3 -3
  32. package/types/packages/excalidraw/webpack.preact.config.d.ts +171 -0
  33. package/types/packages/utils.d.ts +4 -3
  34. package/types/packages/withinBounds.d.ts +2 -2
  35. package/types/renderer/renderElement.d.ts +5 -1
  36. package/types/renderer/renderScene.d.ts +5 -5
  37. package/types/scene/Scene.d.ts +7 -2
  38. package/types/scene/export.d.ts +5 -5
  39. package/types/types.d.ts +16 -15
  40. package/types/utils.d.ts +6 -1
  41. /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-4d89e0ee30f240211e12.d.ts → vendor-06d9b385f406ee409106.d.ts} +0 -0
@@ -18,7 +18,11 @@ export declare const DEFAULT_LINK_SIZE = 14;
18
18
  export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
19
19
  export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState) => void;
20
20
  export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
21
- export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean, exportingFrameId?: string | null, renderEmbeddables?: boolean) => void;
21
+ export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, renderConfig: {
22
+ exportWithDarkMode: boolean;
23
+ renderEmbeddables: boolean;
24
+ frameRendering: AppState["frameRendering"];
25
+ }) => void;
22
26
  export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
23
27
  export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
24
28
  export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
@@ -1,5 +1,5 @@
1
1
  import { RoughSVG } from "roughjs/bin/svg";
2
- import { BinaryFiles } from "../types";
2
+ import { BinaryFiles, AppState } from "../types";
3
3
  import { NonDeletedExcalidrawElement } from "../element/types";
4
4
  import { InteractiveSceneRenderConfig, StaticSceneRenderConfig } from "../scene/types";
5
5
  import "canvas-roundrect-polyfill";
@@ -22,10 +22,10 @@ export declare const renderInteractiveScene: <U extends ({ canvas, elements, vis
22
22
  */
23
23
  export declare const renderStaticScene: (renderConfig: StaticSceneRenderConfig, throttle?: boolean) => void;
24
24
  export declare const cancelRender: () => void;
25
- export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, exportingFrameId, renderEmbeddables, }?: {
25
+ export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, renderEmbeddables, frameRendering, }: {
26
26
  offsetX?: number | undefined;
27
27
  offsetY?: number | undefined;
28
- exportWithDarkMode?: boolean | undefined;
29
- exportingFrameId?: string | null | undefined;
30
- renderEmbeddables?: boolean | undefined;
28
+ exportWithDarkMode: boolean;
29
+ renderEmbeddables: boolean;
30
+ frameRendering: AppState["frameRendering"];
31
31
  }) => void;
@@ -9,7 +9,12 @@ export type ExcalidrawElementsIncludingDeleted = readonly ExcalidrawElement[];
9
9
  declare class Scene {
10
10
  private static sceneMapByElement;
11
11
  private static sceneMapById;
12
- static mapElementToScene(elementKey: ElementKey, scene: Scene): void;
12
+ static mapElementToScene(elementKey: ElementKey, scene: Scene,
13
+ /**
14
+ * needed because of frame exporting hack.
15
+ * elementId:Scene mapping will be removed completely, soon.
16
+ */
17
+ mapElementIds?: boolean): void;
13
18
  static getScene(elementKey: ElementKey): Scene | null;
14
19
  private callbacks;
15
20
  private nonDeletedElements;
@@ -50,7 +55,7 @@ declare class Scene {
50
55
  * @returns whether a change was made
51
56
  */
52
57
  mapElements(iteratee: (element: ExcalidrawElement) => ExcalidrawElement): boolean;
53
- replaceAllElements(nextElements: readonly ExcalidrawElement[]): void;
58
+ replaceAllElements(nextElements: readonly ExcalidrawElement[], mapElementIds?: boolean): void;
54
59
  informMutation(): void;
55
60
  addCallback(cb: SceneStateCallback): SceneStateCallbackRemover;
56
61
  destroy(): void;
@@ -1,10 +1,10 @@
1
- import { NonDeletedExcalidrawElement } from "../element/types";
1
+ import { ExcalidrawFrameElement, NonDeletedExcalidrawElement } from "../element/types";
2
2
  import { AppState, BinaryFiles } from "../types";
3
- import { serializeAsJSON } from "../data/json";
4
- export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, }: {
3
+ export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, exportingFrame, }: {
5
4
  exportBackground: boolean;
6
5
  exportPadding?: number | undefined;
7
6
  viewBackgroundColor: string;
7
+ exportingFrame?: ExcalidrawFrameElement | null | undefined;
8
8
  }, createCanvas?: (width: number, height: number) => {
9
9
  canvas: HTMLCanvasElement;
10
10
  scale: number;
@@ -16,9 +16,9 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
16
16
  viewBackgroundColor: string;
17
17
  exportWithDarkMode?: boolean;
18
18
  exportEmbedScene?: boolean;
19
- renderFrame?: boolean;
19
+ frameRendering?: AppState["frameRendering"];
20
20
  }, files: BinaryFiles | null, opts?: {
21
- serializeAsJSON?: () => string;
22
21
  renderEmbeddables?: boolean;
22
+ exportingFrame?: ExcalidrawFrameElement | null;
23
23
  }) => Promise<SVGSVGElement>;
24
24
  export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[], exportPadding: number, scale: number) => [number, number];
package/types/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import { LinearElementEditor } from "./element/linearElementEditor";
5
5
  import { SuggestedBinding } from "./element/binding";
6
6
  import { ImportedDataState } from "./data/types";
7
7
  import type App from "./components/App";
8
- import type { ResolvablePromise, throttleRAF } from "./utils";
8
+ import type { throttleRAF } from "./utils";
9
9
  import { Spreadsheet } from "./charts";
10
10
  import { Language } from "./i18n";
11
11
  import { ClipboardData } from "./clipboard";
@@ -16,7 +16,7 @@ import type { FileSystemHandle } from "./data/filesystem";
16
16
  import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
17
17
  import { ContextMenuItems } from "./components/ContextMenu";
18
18
  import { SnapLine } from "./snapping";
19
- import { Merge, ForwardRef, ValueOf } from "./utility-types";
19
+ import { Merge, ValueOf } from "./utility-types";
20
20
  export type Point = Readonly<RoughPoint>;
21
21
  export type Collaborator = {
22
22
  pointer?: CollaboratorPointer;
@@ -283,17 +283,13 @@ export type LibraryItem = {
283
283
  export type LibraryItems = readonly LibraryItem[];
284
284
  export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
285
285
  export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
286
- export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
287
- readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
288
- ready?: false;
289
- };
290
286
  export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
291
287
  libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
292
288
  }>;
293
289
  export interface ExcalidrawProps {
294
290
  onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
295
291
  initialData?: ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>;
296
- excalidrawRef?: ForwardRef<ExcalidrawAPIRefValue>;
292
+ excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
297
293
  isCollaborating?: boolean;
298
294
  onPointerUpdate?: (payload: {
299
295
  pointer: {
@@ -346,7 +342,7 @@ export type ExportOpts = {
346
342
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => void;
347
343
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
348
344
  };
349
- type CanvasActions = Partial<{
345
+ export type CanvasActions = Partial<{
350
346
  changeViewBackgroundColor: boolean;
351
347
  clearCanvas: boolean;
352
348
  export: false | ExportOpts;
@@ -355,9 +351,12 @@ type CanvasActions = Partial<{
355
351
  toggleTheme: boolean | null;
356
352
  saveAsImage: boolean;
357
353
  }>;
358
- type UIOptions = Partial<{
354
+ export type UIOptions = Partial<{
359
355
  dockedSidebarBreakpoint: number;
360
356
  canvasActions: CanvasActions;
357
+ tools: {
358
+ image: boolean;
359
+ };
361
360
  /** @deprecated does nothing. Will be removed in 0.15 */
362
361
  welcomeScreen?: boolean;
363
362
  }>;
@@ -475,8 +474,6 @@ export type ExcalidrawImperativeAPI = {
475
474
  refresh: InstanceType<typeof App>["refresh"];
476
475
  setToast: InstanceType<typeof App>["setToast"];
477
476
  addFiles: (data: BinaryFileData[]) => void;
478
- readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>;
479
- ready: true;
480
477
  id: string;
481
478
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
482
479
  setCursor: InstanceType<typeof App>["setCursor"];
@@ -493,11 +490,15 @@ export type ExcalidrawImperativeAPI = {
493
490
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
494
491
  };
495
492
  export type Device = Readonly<{
496
- isSmScreen: boolean;
497
- isMobile: boolean;
493
+ viewport: {
494
+ isMobile: boolean;
495
+ isLandscape: boolean;
496
+ };
497
+ editor: {
498
+ isMobile: boolean;
499
+ canFitSidebar: boolean;
500
+ };
498
501
  isTouchScreen: boolean;
499
- canDeviceFitSidebar: boolean;
500
- isLandscape: boolean;
501
502
  }>;
502
503
  type FrameNameBounds = {
503
504
  x: number;
package/types/utils.d.ts CHANGED
@@ -187,7 +187,11 @@ export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E
187
187
  checkForDefaultPrevented?: boolean | undefined;
188
188
  }) => (event: E) => void;
189
189
  export declare const isOnlyExportingSingleFrame: (elements: readonly NonDeletedExcalidrawElement[]) => boolean;
190
- export declare const assertNever: (value: never, message: string, softAssert?: boolean) => never;
190
+ /**
191
+ * supply `null` as message if non-never value is valid, you just need to
192
+ * typecheck against it
193
+ */
194
+ export declare const assertNever: (value: never, message: string | null, softAssert?: boolean) => never;
191
195
  /**
192
196
  * Memoizes on values of `opts` object (strict equality).
193
197
  */
@@ -197,3 +201,4 @@ export declare const memoize: <T extends Record<string, any>, R extends unknown>
197
201
  export declare const isRenderThrottlingEnabled: () => boolean;
198
202
  /** Checks if value is inside given collection. Useful for type-safety. */
199
203
  export declare const isMemberOf: <T extends string>(collection: Set<T> | Record<T, any> | Map<T, any> | readonly T[], value: string) => value is T;
204
+ export declare const cloneJSON: <T>(obj: T) => T;