@zsviczian/excalidraw 0.17.1-obsidian-17 → 0.17.1-obsidian-19

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 (36) hide show
  1. package/dist/excalidraw.development.js +95 -40
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/package.json +1 -1
  4. package/types/excalidraw/components/Toast.d.ts +3 -1
  5. package/types/excalidraw/components/icons.d.ts +1 -0
  6. package/types/excalidraw/data/library.d.ts +60 -8
  7. package/types/excalidraw/element/index.d.ts +8 -0
  8. package/types/excalidraw/element/linearElementEditor.d.ts +1 -1
  9. package/types/excalidraw/element/newElement.d.ts +0 -1
  10. package/types/excalidraw/element/textElement.d.ts +24 -2
  11. package/types/excalidraw/element/types.d.ts +0 -1
  12. package/types/excalidraw/index.d.ts +8 -4
  13. package/types/excalidraw/obsidianUtils.d.ts +1 -0
  14. package/types/excalidraw/queue.d.ts +9 -0
  15. package/types/excalidraw/renderer/helpers.d.ts +13 -0
  16. package/types/excalidraw/renderer/interactiveScene.d.ts +20 -0
  17. package/types/excalidraw/renderer/renderElement.d.ts +3 -4
  18. package/types/excalidraw/renderer/staticScene.d.ts +11 -0
  19. package/types/excalidraw/renderer/staticSvgScene.d.ts +5 -0
  20. package/types/excalidraw/types.d.ts +6 -6
  21. package/types/excalidraw/utility-types.d.ts +2 -0
  22. package/types/excalidraw/utils.d.ts +3 -1
  23. package/types/utils/export.d.ts +0 -6
  24. package/types/utils/index.d.ts +2 -0
  25. package/types/excalidraw/components/LaserTool/LaserPathManager.d.ts +0 -28
  26. package/types/excalidraw/components/LaserTool/LaserPointerButton.d.ts +0 -10
  27. package/types/excalidraw/components/LaserTool/LaserTool.d.ts +0 -7
  28. package/types/excalidraw/element/Hyperlink.d.ts +0 -220
  29. package/types/excalidraw/example/App.d.ts +0 -14
  30. package/types/excalidraw/example/CustomFooter.d.ts +0 -5
  31. package/types/excalidraw/example/MobileFooter.d.ts +0 -5
  32. package/types/excalidraw/example/index.d.ts +0 -1
  33. package/types/excalidraw/example/initialData.d.ts +0 -290
  34. package/types/excalidraw/example/sidebar/ExampleSidebar.d.ts +0 -4
  35. package/types/excalidraw/renderer/renderScene.d.ts +0 -23
  36. package/types/excalidraw/vite.config.d.mts +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zsviczian/excalidraw",
3
- "version": "0.17.1-obsidian-17",
3
+ "version": "0.17.1-obsidian-19",
4
4
  "main": "main.js",
5
5
  "types": "types/excalidraw/index.d.ts",
6
6
  "files": [
@@ -1,7 +1,9 @@
1
+ import { CSSProperties } from "react";
1
2
  import "./Toast.scss";
2
- export declare const Toast: ({ message, onClose, closable, duration, }: {
3
+ export declare const Toast: ({ message, onClose, closable, duration, style, }: {
3
4
  message: string;
4
5
  onClose: () => void;
5
6
  closable?: boolean | undefined;
6
7
  duration?: number | undefined;
8
+ style?: CSSProperties | undefined;
7
9
  }) => import("react/jsx-runtime").JSX.Element;
@@ -60,6 +60,7 @@ export declare const UndoIcon: import("react/jsx-runtime").JSX.Element;
60
60
  export declare const RedoIcon: import("react/jsx-runtime").JSX.Element;
61
61
  export declare const questionCircle: import("react/jsx-runtime").JSX.Element;
62
62
  export declare const share: import("react/jsx-runtime").JSX.Element;
63
+ export declare const warning: import("react/jsx-runtime").JSX.Element;
63
64
  export declare const shareIOS: import("react/jsx-runtime").JSX.Element;
64
65
  export declare const shareWindows: import("react/jsx-runtime").JSX.Element;
65
66
  export declare const resetZoom: import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,53 @@
1
- import { LibraryItems, ExcalidrawImperativeAPI, LibraryItemsSource } from "../types";
1
+ import { LibraryItems, ExcalidrawImperativeAPI, LibraryItemsSource, LibraryItems_anyVersion } from "../types";
2
2
  import type App from "../components/App";
3
3
  import { ExcalidrawElement } from "../element/types";
4
+ import { MaybePromise } from "../utility-types";
5
+ export type LibraryPersistedData = {
6
+ libraryItems: LibraryItems;
7
+ };
8
+ export type LibraryAdatapterSource = "load" | "save";
9
+ export interface LibraryPersistenceAdapter {
10
+ /**
11
+ * Should load data that were previously saved into the database using the
12
+ * `save` method. Should throw if saving fails.
13
+ *
14
+ * Will be used internally in multiple places, such as during save to
15
+ * in order to reconcile changes with latest store data.
16
+ */
17
+ load(metadata: {
18
+ /**
19
+ * Indicates whether we're loading data for save purposes, or reading
20
+ * purposes, in which case host app can implement more aggressive caching.
21
+ */
22
+ source: LibraryAdatapterSource;
23
+ }): MaybePromise<{
24
+ libraryItems: LibraryItems_anyVersion;
25
+ } | null>;
26
+ /** Should persist to the database as is (do no change the data structure). */
27
+ save(libraryData: LibraryPersistedData): MaybePromise<void>;
28
+ }
29
+ export interface LibraryMigrationAdapter {
30
+ /**
31
+ * loads data from legacy data source. Returns `null` if no data is
32
+ * to be migrated.
33
+ */
34
+ load(): MaybePromise<{
35
+ libraryItems: LibraryItems_anyVersion;
36
+ } | null>;
37
+ /** clears entire storage afterwards */
38
+ clear(): MaybePromise<void>;
39
+ }
4
40
  export declare const libraryItemsAtom: import("jotai").PrimitiveAtom<{
5
41
  status: "loading" | "loaded";
42
+ /** indicates whether library is initialized with library items (has gone
43
+ * through at least one update). Used in UI. Specific to this atom only. */
6
44
  isInitialized: boolean;
7
45
  libraryItems: LibraryItems;
8
46
  }> & {
9
47
  init: {
10
48
  status: "loading" | "loaded";
49
+ /** indicates whether library is initialized with library items (has gone
50
+ * through at least one update). Used in UI. Specific to this atom only. */
11
51
  isInitialized: boolean;
12
52
  libraryItems: LibraryItems;
13
53
  };
@@ -17,10 +57,9 @@ export declare const libraryItemsAtom: import("jotai").PrimitiveAtom<{
17
57
  export declare const mergeLibraryItems: (localItems: LibraryItems, otherItems: LibraryItems) => LibraryItems;
18
58
  declare class Library {
19
59
  /** latest libraryItems */
20
- private lastLibraryItems;
21
- /** indicates whether library is initialized with library items (has gone
22
- * though at least one update) */
23
- private isInitialized;
60
+ private currLibraryItems;
61
+ /** snapshot of library items since last onLibraryChange call */
62
+ private prevLibraryItems;
24
63
  private app;
25
64
  constructor(app: App);
26
65
  private updateQueue;
@@ -48,7 +87,20 @@ export declare const parseLibraryTokensFromUrl: () => {
48
87
  libraryUrl: string;
49
88
  idToken: string | null;
50
89
  } | null;
51
- export declare const useHandleLibrary: ({ excalidrawAPI, getInitialLibraryItems, }: {
90
+ export declare const getLibraryItemsHash: (items: LibraryItems) => number;
91
+ export declare const useHandleLibrary: (opts: {
52
92
  excalidrawAPI: ExcalidrawImperativeAPI | null;
53
- getInitialLibraryItems?: (() => LibraryItemsSource) | undefined;
54
- }) => void;
93
+ } & ({
94
+ /** @deprecated we recommend using `opts.adapter` instead */
95
+ getInitialLibraryItems?: () => MaybePromise<LibraryItemsSource>;
96
+ } | {
97
+ adapter: LibraryPersistenceAdapter;
98
+ /**
99
+ * Adapter that takes care of loading data from legacy data store.
100
+ * Supply this if you want to migrate data on initial load from legacy
101
+ * data store.
102
+ *
103
+ * Can be a different LibraryPersistenceAdapter.
104
+ */
105
+ migrationAdapter?: LibraryMigrationAdapter;
106
+ })) => void;
@@ -10,7 +10,15 @@ export { isTextElement, isExcalidrawElement } from "./typeChecks";
10
10
  export { redrawTextBoundingBox } from "./textElement";
11
11
  export { getPerfectElementSize, getLockedLinearCursorAlignSize, isInvisiblySmallElement, resizePerfectLineForNWHandler, getNormalizedDimensions, } from "./sizeHelpers";
12
12
  export { showSelectedShapeActions } from "./showSelectedShapeActions";
13
+ /**
14
+ * @deprecated unsafe, use hashElementsVersion instead
15
+ */
13
16
  export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) => number;
17
+ /**
18
+ * Hashes elements' versionNonce (using djb2 algo). Order of elements matters.
19
+ */
20
+ export declare const hashElementsVersion: (elements: readonly ExcalidrawElement[]) => number;
21
+ export declare const hashString: (s: string) => number;
14
22
  export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
15
23
  export declare const getNonDeletedElements: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly NonDeleted<T>[];
16
24
  export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
@@ -232,7 +232,7 @@ export declare class LinearElementEditor {
232
232
  offsetLeft: number;
233
233
  fileHandle: import("browser-fs-access").FileSystemHandle | null;
234
234
  collaborators: Map<import("../types").SocketId, Readonly<{
235
- pointer?: import("../types").CollaboratorPointer | undefined; /** indices */
235
+ pointer?: import("../types").CollaboratorPointer | undefined;
236
236
  button?: "up" | "down" | undefined;
237
237
  selectedElementIds?: Readonly<{
238
238
  [id: string]: true;
@@ -33,7 +33,6 @@ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement,
33
33
  y: number;
34
34
  width: number;
35
35
  height: number;
36
- baseline: number;
37
36
  text: string;
38
37
  } | undefined;
39
38
  export declare const updateTextElement: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, elementsMap: ElementsMap, { text, isDeleted, originalText, rawText, link, }: {
@@ -1,7 +1,7 @@
1
1
  import { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./types";
2
2
  import { MaybeTransformHandleType } from "./transformHandles";
3
3
  import { AppState } from "../types";
4
- import { ExtractSetType } from "../utility-types";
4
+ import { ExtractSetType, MakeBrand } from "../utility-types";
5
5
  export declare const normalizeText: (text: string) => string;
6
6
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, elementsMap: ElementsMap) => void;
7
7
  export declare const bindTextToShapeAfterDuplication: (newElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
@@ -14,8 +14,11 @@ export declare const measureText: (text: string, font: FontString, lineHeight: E
14
14
  baseline: number;
15
15
  height: number;
16
16
  width: number;
17
+ } | {
18
+ width: number;
19
+ height: number;
20
+ baseline?: undefined;
17
21
  };
18
- export declare const measureBaseline: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], wrapInContainer?: boolean) => number;
19
22
  /**
20
23
  * To get unitless line-height (if unknown) we can calculate it by dividing
21
24
  * height-per-line by fontSize.
@@ -28,6 +31,10 @@ export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => n
28
31
  * aligning with the W3C spec.
29
32
  */
30
33
  export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
34
+ /**
35
+ * Calculates vertical offset for a text with alphabetic baseline.
36
+ */
37
+ export declare const getVerticalOffset: (fontFamily: ExcalidrawTextElement["fontFamily"], fontSize: ExcalidrawTextElement["fontSize"], lineHeightPx: number) => number;
31
38
  export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
32
39
  export declare const getTextWidth: (text: string, font: FontString) => number;
33
40
  export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
@@ -68,6 +75,21 @@ export declare const computeContainerDimensionForBoundText: (dimension: number,
68
75
  export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElement | null) => number;
69
76
  export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
70
77
  export declare const isMeasureTextSupported: () => boolean;
78
+ /** OS/2 sTypoAscender, https://learn.microsoft.com/en-us/typography/opentype/spec/os2#stypoascender */
79
+ type sTypoAscender = number & MakeBrand<"sTypoAscender">;
80
+ /** OS/2 sTypoDescender, https://learn.microsoft.com/en-us/typography/opentype/spec/os2#stypodescender */
81
+ type sTypoDescender = number & MakeBrand<"sTypoDescender">;
82
+ /**
83
+ * Hardcoded metrics for default fonts, read by https://opentype.js.org/font-inspector.html.
84
+ * For custom fonts, read these metrics from OS/2 table and extend this object.
85
+ *
86
+ * WARN: opentype does NOT open WOFF2 correctly, make sure to convert WOFF2 to TTF first.
87
+ */
88
+ export declare const FONT_METRICS: Record<number, {
89
+ unitsPerEm: number;
90
+ ascender: sTypoAscender;
91
+ descender: sTypoDescender;
92
+ }>;
71
93
  export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
72
94
  _brand: "unitlessLineHeight";
73
95
  };
@@ -137,7 +137,6 @@ export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
137
137
  fontFamily: FontFamilyValues;
138
138
  text: string;
139
139
  rawText: string;
140
- baseline: number;
141
140
  textAlign: TextAlign;
142
141
  verticalAlign: VerticalAlign;
143
142
  containerId: ExcalidrawGenericElement["id"] | null;
@@ -8,10 +8,10 @@ import MainMenu from "./components/main-menu/MainMenu";
8
8
  import WelcomeScreen from "./components/welcome-screen/WelcomeScreen";
9
9
  import LiveCollaborationTrigger from "./components/live-collaboration/LiveCollaborationTrigger";
10
10
  export declare const Excalidraw: React.MemoExoticComponent<(props: ExcalidrawProps) => import("react/jsx-runtime").JSX.Element>;
11
- export { getSceneVersion, isInvisiblySmallElement, getNonDeletedElements, } from "./element";
11
+ export { getSceneVersion, hashElementsVersion, hashString, isInvisiblySmallElement, getNonDeletedElements, } from "./element";
12
12
  export { defaultLang, useI18n, languages } from "./i18n";
13
13
  export { restore, restoreAppState, restoreElements, restoreLibraryItems, } from "./data/restore";
14
- export { exportToCanvas, exportToBlob, exportToSvg, serializeAsJSON, serializeLibraryAsJSON, loadLibraryFromBlob, loadFromBlob, loadSceneOrLibraryFromBlob, getFreeDrawSvgPath, getCommonBoundingBox, //zsviczian
14
+ export { exportToCanvas, exportToBlob, exportToSvg, exportToClipboard, getCommonBoundingBox, //zsviczian
15
15
  getMaximumGroups, //zsviczian
16
16
  intersectElementWithLine, //zsviczian
17
17
  determineFocusDistance, //zsviczian
@@ -20,7 +20,11 @@ getDefaultLineHeight, //zsviczian
20
20
  wrapText, //zsviczian
21
21
  getFontString, //zsviczian
22
22
  getBoundTextMaxWidth, //zsviczian
23
- exportToClipboard, mergeLibraryItems, mermaidToExcalidraw, } from "../utils/export";
23
+ mermaidToExcalidraw, } from "../utils/export";
24
+ export { serializeAsJSON, serializeLibraryAsJSON } from "./data/json";
25
+ export { loadFromBlob, loadSceneOrLibraryFromBlob, loadLibraryFromBlob, } from "./data/blob";
26
+ export { getFreeDrawSvgPath } from "./renderer/renderElement";
27
+ export { mergeLibraryItems, getLibraryItemsHash } from "./data/library";
24
28
  export { isLinearElement } from "./element/typeChecks";
25
29
  export { FONT_FAMILY, THEME, MIME_TYPES, ROUNDNESS } from "./constants";
26
30
  export { mutateElement, newElementWith, bumpVersion, } from "./element/mutateElement";
@@ -41,4 +45,4 @@ export { normalizeLink } from "./data/url";
41
45
  export { zoomToFitBounds } from "./actions/actionCanvas";
42
46
  export { convertToExcalidrawElements } from "./data/transform";
43
47
  export { getCommonBounds, getVisibleSceneBounds } from "./element/bounds";
44
- export { elementsOverlappingBBox, isElementInsideBBox, elementPartiallyOverlapsWithOrContainsBBox, } from "../utils/export";
48
+ export { elementsOverlappingBBox, isElementInsideBBox, elementPartiallyOverlapsWithOrContainsBBox, } from "../utils/withinBounds";
@@ -2,3 +2,4 @@ export declare const getAreaLimit: () => any;
2
2
  export declare const getWidthHeightLimit: () => any;
3
3
  export declare const isExcaliBrainView: () => any;
4
4
  export declare const getExcalidrawContentEl: () => HTMLElement;
5
+ export declare const hideFreedrawPenmodeCursor: () => boolean;
@@ -0,0 +1,9 @@
1
+ import { MaybePromise } from "./utility-types";
2
+ type Job<T, TArgs extends unknown[]> = (...args: TArgs) => MaybePromise<T>;
3
+ export declare class Queue {
4
+ private jobs;
5
+ private running;
6
+ private tick;
7
+ push<TValue, TArgs extends unknown[]>(jobFactory: Job<TValue, TArgs>, ...args: TArgs): Promise<TValue>;
8
+ }
9
+ export {};
@@ -0,0 +1,13 @@
1
+ import { StaticCanvasAppState, AppState } from "../types";
2
+ import { StaticCanvasRenderConfig } from "../scene/types";
3
+ export declare const fillCircle: (context: CanvasRenderingContext2D, cx: number, cy: number, radius: number, stroke?: boolean) => void;
4
+ export declare const getNormalizedCanvasDimensions: (canvas: HTMLCanvasElement, scale: number) => [number, number];
5
+ export declare const bootstrapCanvas: ({ canvas, scale, normalizedWidth, normalizedHeight, theme, isExporting, viewBackgroundColor, }: {
6
+ canvas: HTMLCanvasElement;
7
+ scale: number;
8
+ normalizedWidth: number;
9
+ normalizedHeight: number;
10
+ theme?: import("../element/types").Theme | undefined;
11
+ isExporting?: boolean | undefined;
12
+ viewBackgroundColor?: string | null | undefined;
13
+ }) => CanvasRenderingContext2D;
@@ -0,0 +1,20 @@
1
+ import { InteractiveSceneRenderConfig, RenderableElementsMap } from "../scene/types";
2
+ /** throttled to animation framerate */
3
+ export declare const renderInteractiveSceneThrottled: {
4
+ (config: InteractiveSceneRenderConfig): void;
5
+ flush(): void;
6
+ cancel(): void;
7
+ };
8
+ /**
9
+ * Interactive scene is the ui-canvas where we render bounding boxes, selections
10
+ * and other ui stuff.
11
+ */
12
+ export declare const renderInteractiveScene: <U extends ({ canvas, elementsMap, visibleElements, selectedElements, scale, appState, renderConfig, }: InteractiveSceneRenderConfig) => {
13
+ atLeastOneVisibleElement: boolean;
14
+ elementsMap: RenderableElementsMap;
15
+ scrollBars?: undefined;
16
+ } | {
17
+ scrollBars: import("../scene/types").ScrollBars | undefined;
18
+ atLeastOneVisibleElement: boolean;
19
+ elementsMap: RenderableElementsMap;
20
+ }, T extends boolean = false>(renderConfig: InteractiveSceneRenderConfig, throttle?: T | undefined) => T extends true ? void : ReturnType<U>;
@@ -1,8 +1,8 @@
1
1
  import { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "../element/types";
2
2
  import type { RoughCanvas } from "roughjs/bin/canvas";
3
- import type { RoughSVG } from "roughjs/bin/svg";
4
- import { SVGRenderConfig, StaticCanvasRenderConfig, RenderableElementsMap } from "../scene/types";
5
- import { AppState, StaticCanvasAppState, BinaryFiles, InteractiveCanvasAppState, ElementsPendingErasure } from "../types";
3
+ import { StaticCanvasRenderConfig, RenderableElementsMap } from "../scene/types";
4
+ import { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementsPendingErasure } from "../types";
5
+ export declare const IMAGE_INVERT_FILTER = "invert(100%) hue-rotate(180deg) saturate(1.25)";
6
6
  export declare const getRenderOpacity: (element: ExcalidrawElement, containingFrame: ExcalidrawFrameLikeElement | null, elementsPendingErasure: ElementsPendingErasure) => number;
7
7
  export interface ExcalidrawElementWithCanvas {
8
8
  element: ExcalidrawElement | ExcalidrawTextElement;
@@ -19,7 +19,6 @@ export declare const DEFAULT_LINK_SIZE = 14;
19
19
  export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
20
20
  export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState) => void;
21
21
  export declare const renderElement: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, allElementsMap: NonDeletedSceneElementsMap, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
22
- export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, renderConfig: SVGRenderConfig) => void;
23
22
  export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
24
23
  export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
25
24
  export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
@@ -0,0 +1,11 @@
1
+ import { StaticSceneRenderConfig } from "../scene/types";
2
+ /** throttled to animation framerate */
3
+ export declare const renderStaticSceneThrottled: {
4
+ (config: StaticSceneRenderConfig): void;
5
+ flush(): void;
6
+ cancel(): void;
7
+ };
8
+ /**
9
+ * Static scene is the non-ui canvas where we render elements.
10
+ */
11
+ export declare const renderStaticScene: (renderConfig: StaticSceneRenderConfig, throttle?: boolean) => void;
@@ -0,0 +1,5 @@
1
+ import { RoughSVG } from "roughjs/bin/svg";
2
+ import { NonDeletedExcalidrawElement } from "../element/types";
3
+ import { RenderableElementsMap, SVGRenderConfig } from "../scene/types";
4
+ import { BinaryFiles } from "../types";
5
+ export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], elementsMap: RenderableElementsMap, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, renderConfig: SVGRenderConfig) => void;
@@ -17,7 +17,7 @@ import type { FileSystemHandle } from "./data/filesystem";
17
17
  import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
18
18
  import { ContextMenuItems } from "./components/ContextMenu";
19
19
  import { SnapLine } from "./snapping";
20
- import { Merge, ValueOf } from "./utility-types";
20
+ import { Merge, MaybePromise, ValueOf } from "./utility-types";
21
21
  import { ColorPaletteCustom } from "./colors";
22
22
  export type Point = Readonly<RoughPoint>;
23
23
  export type SocketId = string & {
@@ -341,9 +341,9 @@ export type LibraryItem = {
341
341
  };
342
342
  export type LibraryItems = readonly LibraryItem[];
343
343
  export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
344
- export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
344
+ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePromise<LibraryItems_anyVersion | Blob>) | MaybePromise<LibraryItems_anyVersion | Blob>;
345
345
  export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
346
- libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
346
+ libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
347
347
  }>;
348
348
  export type OnUserFollowedPayload = {
349
349
  userToFollow: UserToFollow;
@@ -351,7 +351,7 @@ export type OnUserFollowedPayload = {
351
351
  };
352
352
  export interface ExcalidrawProps {
353
353
  onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
354
- initialData?: ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>;
354
+ initialData?: MaybePromise<ExcalidrawInitialDataState | null>;
355
355
  excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
356
356
  isCollaborating?: boolean;
357
357
  onPointerUpdate?: (payload: {
@@ -536,7 +536,7 @@ export type PointerDownState = Readonly<{
536
536
  };
537
537
  }>;
538
538
  export type UnsubscribeCallback = () => void;
539
- export type ExcalidrawImperativeAPI = {
539
+ export interface ExcalidrawImperativeAPI {
540
540
  updateScene: InstanceType<typeof App>["updateScene"];
541
541
  updateLibrary: InstanceType<typeof Library>["updateLibrary"];
542
542
  resetScene: InstanceType<typeof App>["resetScene"];
@@ -580,7 +580,7 @@ export type ExcalidrawImperativeAPI = {
580
580
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
581
581
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
582
582
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
583
- };
583
+ }
584
584
  export type Device = Readonly<{
585
585
  viewport: {
586
586
  isMobile: boolean;
@@ -27,3 +27,5 @@ export type ReadonlySetLike<T> = ReadonlySet<T> | readonly T[];
27
27
  export type MakeBrand<T extends string> = {
28
28
  [K in `~brand~${T}`]: T;
29
29
  };
30
+ /** Maybe just promise or already fulfilled one! */
31
+ export type MaybePromise<T> = T | Promise<T>;
@@ -1,6 +1,7 @@
1
1
  import { EVENT } from "./constants";
2
2
  import { FontFamilyValues, FontString } from "./element/types";
3
3
  import { ActiveTool, AppState, ToolType, UnsubscribeCallback, Zoom } from "./types";
4
+ import { MaybePromise } from "./utility-types";
4
5
  export declare const setDateTimeForTests: (dateTime: string) => void;
5
6
  export declare const getDateTime: () => string;
6
7
  export declare const capitalizeString: (str: string) => string;
@@ -137,7 +138,7 @@ export declare const findIndex: <T>(array: readonly T[], cb: (element: T, index:
137
138
  export declare const findLastIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
138
139
  export declare const isTransparent: (color: string) => boolean;
139
140
  export type ResolvablePromise<T> = Promise<T> & {
140
- resolve: [T] extends [undefined] ? (value?: T) => void : (value: T) => void;
141
+ resolve: [T] extends [undefined] ? (value?: MaybePromise<Awaited<T>>) => void : (value: MaybePromise<Awaited<T>>) => void;
141
142
  reject: (error: Error) => void;
142
143
  };
143
144
  export declare const resolvablePromise: <T>() => ResolvablePromise<T>;
@@ -219,4 +220,5 @@ type Unbrand<T> = T extends Map<infer E, infer F> ? Map<E, F> : T extends Set<in
219
220
  * compose branded types which are not composite themselves.)
220
221
  */
221
222
  export declare const toBrandedType: <BrandedType, CurrentType = BrandedType>(value: Unbrand<BrandedType>) => CurrentType & BrandedType;
223
+ export declare const promiseTry: <TValue, TArgs extends unknown[]>(fn: (...args: TArgs) => TValue | PromiseLike<TValue>, ...args: TArgs) => Promise<TValue>;
222
224
  export {};
@@ -31,11 +31,6 @@ export declare const exportToClipboard: (opts: ExportOpts & {
31
31
  quality?: number;
32
32
  type: "png" | "svg" | "json";
33
33
  }) => Promise<void>;
34
- export * from "./bbox";
35
- export { elementsOverlappingBBox, isElementInsideBBox, elementPartiallyOverlapsWithOrContainsBBox, } from "./withinBounds";
36
- export { serializeAsJSON, serializeLibraryAsJSON, } from "../excalidraw/data/json";
37
- export { loadFromBlob, loadSceneOrLibraryFromBlob, loadLibraryFromBlob, } from "../excalidraw/data/blob";
38
- export { getFreeDrawSvgPath } from "../excalidraw/renderer/renderElement";
39
34
  export { getCommonBoundingBox } from "../excalidraw/element/bounds";
40
35
  export { getMaximumGroups } from "../excalidraw/groups";
41
36
  export { intersectElementWithLine } from "../excalidraw/element/collision";
@@ -43,5 +38,4 @@ export { determineFocusDistance } from "../excalidraw/element/collision";
43
38
  export { measureText, wrapText, getDefaultLineHeight, } from "../excalidraw/element/textElement";
44
39
  export { getFontString } from "../excalidraw/utils";
45
40
  export { getBoundTextMaxWidth } from "../excalidraw/element/textElement";
46
- export { mergeLibraryItems } from "../excalidraw/data/library";
47
41
  export { mermaidToExcalidraw } from "../excalidraw/components/TTDDialog/MermaidToExcalidraw";
@@ -1 +1,3 @@
1
1
  export * from "./export";
2
+ export * from "./withinBounds";
3
+ export * from "./bbox";
@@ -1,28 +0,0 @@
1
- import { LaserPointer } from "@excalidraw/laser-pointer";
2
- import App from "../App";
3
- declare global {
4
- interface Window {
5
- LPM: LaserPathManager;
6
- }
7
- }
8
- export declare class LaserPathManager {
9
- private app;
10
- private ownState;
11
- private collaboratorsState;
12
- private rafId;
13
- private isDrawing;
14
- private container;
15
- constructor(app: App);
16
- destroy(): void;
17
- startPath(x: number, y: number): void;
18
- addPointToPath(x: number, y: number): void;
19
- endPath(): void;
20
- private updatePath;
21
- private isRunning;
22
- start(svg?: SVGSVGElement): void;
23
- stop(): void;
24
- loop(): void;
25
- draw(path: LaserPointer): string;
26
- updateCollabolatorsState(): void;
27
- update(): void;
28
- }
@@ -1,10 +0,0 @@
1
- import "../ToolIcon.scss";
2
- type LaserPointerIconProps = {
3
- title?: string;
4
- name?: string;
5
- checked: boolean;
6
- onChange?(): void;
7
- isMobile?: boolean;
8
- };
9
- export declare const LaserPointerButton: (props: LaserPointerIconProps) => import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,7 +0,0 @@
1
- import { LaserPathManager } from "./LaserPathManager";
2
- import "./LaserToolOverlay.scss";
3
- type LaserToolOverlayProps = {
4
- manager: LaserPathManager;
5
- };
6
- export declare const LaserToolOverlay: ({ manager }: LaserToolOverlayProps) => import("react/jsx-runtime").JSX.Element;
7
- export {};