@myoc/common 0.19.510 → 0.19.511

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 (61) hide show
  1. package/dist/dev/index.js +4 -27
  2. package/dist/dev/index.js.map +2 -2
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/src/constants.d.ts +1 -16
  5. package/dist/types/excalidraw/actions/actionBoundText.d.ts +0 -4
  6. package/dist/types/excalidraw/actions/actionCanvas.d.ts +0 -22
  7. package/dist/types/excalidraw/actions/actionClipboard.d.ts +0 -4
  8. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +0 -2
  9. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +0 -6
  10. package/dist/types/excalidraw/actions/actionDeselect.d.ts +0 -2
  11. package/dist/types/excalidraw/actions/actionElementLock.d.ts +0 -4
  12. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -2
  13. package/dist/types/excalidraw/actions/actionExport.d.ts +0 -4
  14. package/dist/types/excalidraw/actions/actionFrame.d.ts +0 -8
  15. package/dist/types/excalidraw/actions/actionGroup.d.ts +0 -4
  16. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +0 -4
  17. package/dist/types/excalidraw/actions/actionLink.d.ts +0 -2
  18. package/dist/types/excalidraw/actions/actionProperties.d.ts +0 -4
  19. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +0 -2
  20. package/dist/types/excalidraw/actions/actionStyles.d.ts +0 -2
  21. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +0 -2
  22. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +0 -2
  23. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +0 -2
  24. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +0 -2
  25. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +0 -2
  26. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +0 -2
  27. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +0 -2
  28. package/dist/types/excalidraw/actions/index.d.ts +0 -1
  29. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  30. package/dist/types/excalidraw/actions/types.d.ts +2 -2
  31. package/dist/types/excalidraw/components/App.d.ts +2 -4
  32. package/dist/types/excalidraw/components/MobileToolBar.d.ts +3 -1
  33. package/dist/types/excalidraw/components/icons.d.ts +0 -1
  34. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +0 -6
  35. package/dist/types/excalidraw/data/blob.d.ts +3 -184
  36. package/dist/types/excalidraw/data/json.d.ts +2 -7
  37. package/dist/types/excalidraw/data/restore.d.ts +1 -2
  38. package/dist/types/excalidraw/data/types.d.ts +1 -16
  39. package/dist/types/excalidraw/types.d.ts +3 -30
  40. package/package.json +1 -1
  41. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +0 -512
  42. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +0 -19
  43. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +0 -19
  44. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +0 -2
  45. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +0 -24
  46. package/dist/types/excalidraw/components/ConfirmDialog.d.ts +0 -10
  47. package/dist/types/excalidraw/components/LibraryMenu.d.ts +0 -10
  48. package/dist/types/excalidraw/components/LibraryMenuBrowseButton.d.ts +0 -7
  49. package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +0 -9
  50. package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +0 -17
  51. package/dist/types/excalidraw/components/LibraryMenuItems.d.ts +0 -14
  52. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +0 -23
  53. package/dist/types/excalidraw/components/LibraryUnit.d.ts +0 -14
  54. package/dist/types/excalidraw/components/PublishLibrary.d.ts +0 -17
  55. package/dist/types/excalidraw/data/EditorLocalStorage.d.ts +0 -8
  56. package/dist/types/excalidraw/data/library.d.ts +0 -127
  57. package/dist/types/excalidraw/deburr.d.ts +0 -1
  58. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +0 -11
  59. package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +0 -1
  60. package/dist/types/excalidraw/hooks/useStableCallback.d.ts +0 -4
  61. package/dist/types/excalidraw/hooks/useTransition.d.ts +0 -2
@@ -1,24 +0,0 @@
1
- import type { ActionManager } from "../../actions/manager";
2
- import type { Action } from "../../actions/types";
3
- export type CommandPaletteItem = {
4
- label: string;
5
- /** additional keywords to match against
6
- * (appended to haystack, not displayed) */
7
- keywords?: string[];
8
- /**
9
- * string we should match against when searching
10
- * (deburred name + keywords)
11
- */
12
- haystack?: string;
13
- icon?: Action["icon"];
14
- category: string;
15
- order?: number;
16
- predicate?: boolean | Action["predicate"];
17
- shortcut?: string | null;
18
- /** if false, command will not show while in view mode */
19
- viewMode?: boolean;
20
- perform: (data: {
21
- actionManager: ActionManager;
22
- event: React.MouseEvent | React.KeyboardEvent | KeyboardEvent;
23
- }) => void;
24
- };
@@ -1,10 +0,0 @@
1
- import "./ConfirmDialog.scss";
2
- import type { DialogProps } from "./Dialog";
3
- interface Props extends Omit<DialogProps, "onCloseRequest"> {
4
- onConfirm: () => void;
5
- onCancel: () => void;
6
- confirmText?: string;
7
- cancelText?: string;
8
- }
9
- declare const ConfirmDialog: (props: Props) => import("react/jsx-runtime").JSX.Element;
10
- export default ConfirmDialog;
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import "./LibraryMenu.scss";
3
- export declare const isLibraryMenuOpenAtom: import("jotai/vanilla/atom").PrimitiveAtom<boolean> & {
4
- init: boolean;
5
- };
6
- /**
7
- * This component is meant to be rendered inside <Sidebar.Tab/> inside our
8
- * <DefaultSidebar/> or host apps Sidebar components.
9
- */
10
- export declare const LibraryMenu: React.MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
@@ -1,7 +0,0 @@
1
- import type { ExcalidrawProps, UIAppState } from "../types";
2
- declare const LibraryMenuBrowseButton: ({ theme, id, libraryReturnUrl, }: {
3
- libraryReturnUrl: ExcalidrawProps["libraryReturnUrl"];
4
- theme: UIAppState["theme"];
5
- id: string;
6
- }) => import("react/jsx-runtime").JSX.Element;
7
- export default LibraryMenuBrowseButton;
@@ -1,9 +0,0 @@
1
- import type { ExcalidrawProps, UIAppState } from "../types";
2
- export declare const LibraryMenuControlButtons: ({ libraryReturnUrl, theme, id, style, children, className, }: {
3
- libraryReturnUrl: ExcalidrawProps["libraryReturnUrl"];
4
- theme: UIAppState["theme"];
5
- id: string;
6
- style: React.CSSProperties;
7
- children?: React.ReactNode;
8
- className?: string;
9
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,17 +0,0 @@
1
- import type Library from "../data/library";
2
- import type { LibraryItem, UIAppState } from "../types";
3
- export declare const LibraryDropdownMenuButton: React.FC<{
4
- setAppState: React.Component<any, UIAppState>["setState"];
5
- selectedItems: LibraryItem["id"][];
6
- library: Library;
7
- onRemoveFromLibrary: () => void;
8
- resetLibrary: () => void;
9
- onSelectItems: (items: LibraryItem["id"][]) => void;
10
- appState: UIAppState;
11
- className?: string;
12
- }>;
13
- export declare const LibraryDropdownMenu: ({ selectedItems, onSelectItems, className, }: {
14
- selectedItems: LibraryItem["id"][];
15
- onSelectItems: (id: LibraryItem["id"][]) => void;
16
- className?: string;
17
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,14 +0,0 @@
1
- import "./LibraryMenuItems.scss";
2
- import type { ExcalidrawProps, LibraryItem, LibraryItems, UIAppState } from "../types";
3
- export default function LibraryMenuItems({ isLoading, libraryItems, onAddToLibrary, onInsertLibraryItems, pendingElements, theme, id, libraryReturnUrl, onSelectItems, selectedItems, }: {
4
- isLoading: boolean;
5
- libraryItems: LibraryItems;
6
- pendingElements: LibraryItem["elements"];
7
- onInsertLibraryItems: (libraryItems: LibraryItems) => void;
8
- onAddToLibrary: (elements: LibraryItem["elements"]) => void;
9
- libraryReturnUrl: ExcalidrawProps["libraryReturnUrl"];
10
- theme: UIAppState["theme"];
11
- id: string;
12
- selectedItems: LibraryItem["id"][];
13
- onSelectItems: (id: LibraryItem["id"][]) => void;
14
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,23 +0,0 @@
1
- import React from "react";
2
- import type { ExcalidrawElement, NonDeleted } from "@excalidraw/element/types";
3
- import type { SvgCache } from "../hooks/useLibraryItemSvg";
4
- import type { LibraryItem } from "../types";
5
- import type { ReactNode } from "react";
6
- type LibraryOrPendingItem = readonly (LibraryItem | /* pending library item */ {
7
- id: null;
8
- elements: readonly NonDeleted<ExcalidrawElement>[];
9
- })[];
10
- interface Props {
11
- items: LibraryOrPendingItem;
12
- onClick: (id: LibraryItem["id"] | null) => void;
13
- onItemSelectToggle: (id: LibraryItem["id"], event: React.MouseEvent) => void;
14
- onItemDrag: (id: LibraryItem["id"], event: React.DragEvent) => void;
15
- isItemSelected: (id: LibraryItem["id"] | null) => boolean;
16
- svgCache: SvgCache;
17
- itemsRenderedPerBatch: number;
18
- }
19
- export declare const LibraryMenuSectionGrid: ({ children, }: {
20
- children: ReactNode;
21
- }) => import("react/jsx-runtime").JSX.Element;
22
- export declare const LibraryMenuSection: React.MemoExoticComponent<({ items, onItemSelectToggle, onItemDrag, isItemSelected, onClick, svgCache, itemsRenderedPerBatch, }: Props) => import("react/jsx-runtime").JSX.Element>;
23
- export {};
@@ -1,14 +0,0 @@
1
- import "./LibraryUnit.scss";
2
- import type { LibraryItem } from "../types";
3
- import type { SvgCache } from "../hooks/useLibraryItemSvg";
4
- export declare const LibraryUnit: import("react").MemoExoticComponent<({ id, elements, isPending, onClick, selected, onToggle, onDrag, svgCache, }: {
5
- id: LibraryItem["id"] | /** for pending item */ null;
6
- elements?: LibraryItem["elements"];
7
- isPending?: boolean;
8
- onClick: (id: LibraryItem["id"] | null) => void;
9
- selected: boolean;
10
- onToggle: (id: string, event: React.MouseEvent) => void;
11
- onDrag: (id: string, event: React.DragEvent) => void;
12
- svgCache: SvgCache;
13
- }) => import("react/jsx-runtime").JSX.Element>;
14
- export declare const EmptyLibraryUnit: () => import("react/jsx-runtime").JSX.Element;
@@ -1,17 +0,0 @@
1
- import "./PublishLibrary.scss";
2
- import type { CompressImageFile, LibraryItems, UIAppState } from "../types";
3
- declare const PublishLibrary: ({ onClose, libraryItems, appState, onSuccess, onError, updateItemsInStorage, onRemove, compressImageFile, }: {
4
- onClose: () => void;
5
- libraryItems: LibraryItems;
6
- appState: UIAppState;
7
- onSuccess: (data: {
8
- url: string;
9
- authorName: string;
10
- items: LibraryItems;
11
- }) => void;
12
- onError: (error: Error) => void;
13
- updateItemsInStorage: (items: LibraryItems) => void;
14
- onRemove: (id: string) => void;
15
- compressImageFile: CompressImageFile;
16
- }) => import("react/jsx-runtime").JSX.Element;
17
- export default PublishLibrary;
@@ -1,8 +0,0 @@
1
- import type { EDITOR_LS_KEYS } from "@excalidraw/common";
2
- import type { JSONValue } from "../types";
3
- export declare class EditorLocalStorage {
4
- static has(key: typeof EDITOR_LS_KEYS[keyof typeof EDITOR_LS_KEYS]): boolean;
5
- static get<T extends JSONValue>(key: typeof EDITOR_LS_KEYS[keyof typeof EDITOR_LS_KEYS]): T | null;
6
- static set: (key: (typeof EDITOR_LS_KEYS)[keyof typeof EDITOR_LS_KEYS], value: JSONValue) => boolean;
7
- static delete: (name: (typeof EDITOR_LS_KEYS)[keyof typeof EDITOR_LS_KEYS]) => void;
8
- }
@@ -1,127 +0,0 @@
1
- import type { ExcalidrawElement } from "@excalidraw/element/types";
2
- import type { MaybePromise } from "@excalidraw/common/utility-types";
3
- import type App from "../components/App";
4
- import type { LibraryItems, ExcalidrawImperativeAPI, LibraryItemsSource, LibraryItems_anyVersion } from "../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
- }
40
- export declare const libraryItemsAtom: import("jotai/vanilla/atom").PrimitiveAtom<{
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. */
44
- isInitialized: boolean;
45
- libraryItems: LibraryItems;
46
- }> & {
47
- init: {
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. */
51
- isInitialized: boolean;
52
- libraryItems: LibraryItems;
53
- };
54
- };
55
- /** Merges otherItems into localItems. Unique items in otherItems array are
56
- sorted first. */
57
- export declare const mergeLibraryItems: (localItems: LibraryItems, otherItems: LibraryItems) => LibraryItems;
58
- declare class Library {
59
- /** latest libraryItems */
60
- private currLibraryItems;
61
- /** snapshot of library items since last onLibraryChange call */
62
- private prevLibraryItems;
63
- private app;
64
- constructor(app: App);
65
- private updateQueue;
66
- private getLastUpdateTask;
67
- private notifyListeners;
68
- /** call on excalidraw instance unmount */
69
- destroy: () => void;
70
- resetLibrary: () => Promise<LibraryItems>;
71
- /**
72
- * @returns latest cloned libraryItems. Awaits all in-progress updates first.
73
- */
74
- getLatestLibrary: () => Promise<LibraryItems>;
75
- updateLibrary: ({ libraryItems, prompt, merge, openLibraryMenu, defaultStatus, }: {
76
- libraryItems: LibraryItemsSource;
77
- merge?: boolean;
78
- prompt?: boolean;
79
- openLibraryMenu?: boolean;
80
- defaultStatus?: "unpublished" | "published";
81
- }) => Promise<LibraryItems>;
82
- setLibrary: (
83
- /**
84
- * LibraryItems that will replace current items. Can be a function which
85
- * will be invoked after all previous tasks are resolved
86
- * (this is the prefered way to update the library to avoid race conditions,
87
- * but you'll want to manually merge the library items in the callback
88
- * - which is what we're doing in Library.importLibrary()).
89
- *
90
- * If supplied promise is rejected with AbortError, we swallow it and
91
- * do not update the library.
92
- */
93
- libraryItems: LibraryItems | Promise<LibraryItems> | ((latestLibraryItems: LibraryItems) => LibraryItems | Promise<LibraryItems>)) => Promise<LibraryItems>;
94
- }
95
- export default Library;
96
- export declare const distributeLibraryItemsOnSquareGrid: (libraryItems: LibraryItems) => ExcalidrawElement[];
97
- export declare const validateLibraryUrl: (libraryUrl: string,
98
- /**
99
- * @returns `true` if the URL is valid, throws otherwise.
100
- */
101
- validator?: ((libraryUrl: string) => boolean) | string[]) => true;
102
- export declare const parseLibraryTokensFromUrl: () => {
103
- libraryUrl: string;
104
- idToken: string | null;
105
- } | null;
106
- export declare const getLibraryItemsHash: (items: LibraryItems) => number;
107
- export declare const useHandleLibrary: (opts: {
108
- excalidrawAPI: ExcalidrawImperativeAPI | null;
109
- /**
110
- * Return `true` if the library install url should be allowed.
111
- * If not supplied, only the excalidraw.com base domain is allowed.
112
- */
113
- validateLibraryUrl?: (libraryUrl: string) => boolean;
114
- } & ({
115
- /** @deprecated we recommend using `opts.adapter` instead */
116
- getInitialLibraryItems?: () => MaybePromise<LibraryItemsSource>;
117
- } | {
118
- adapter: LibraryPersistenceAdapter;
119
- /**
120
- * Adapter that takes care of loading data from legacy data store.
121
- * Supply this if you want to migrate data on initial load from legacy
122
- * data store.
123
- *
124
- * Can be a different LibraryPersistenceAdapter.
125
- */
126
- migrationAdapter?: LibraryMigrationAdapter;
127
- })) => void;
@@ -1 +0,0 @@
1
- export declare const deburr: (str: string) => string;
@@ -1,11 +0,0 @@
1
- import type { LibraryItem } from "../types";
2
- export type SvgCache = Map<LibraryItem["id"], SVGSVGElement>;
3
- export declare const libraryItemSvgsCache: import("jotai/vanilla/atom").PrimitiveAtom<SvgCache> & {
4
- init: SvgCache;
5
- };
6
- export declare const useLibraryItemSvg: (id: LibraryItem["id"] | null, elements: LibraryItem["elements"] | undefined, svgCache: SvgCache, ref: React.RefObject<HTMLDivElement | null>) => SVGSVGElement | undefined;
7
- export declare const useLibraryCache: () => {
8
- clearLibraryCache: () => void;
9
- deleteItemsFromLibraryCache: (items: LibraryItem["id"][]) => void;
10
- svgCache: SvgCache;
11
- };
@@ -1 +0,0 @@
1
- export declare const useScrollPosition: <T extends HTMLElement>(elementRef: React.RefObject<T | null>) => number;
@@ -1,4 +0,0 @@
1
- /**
2
- * Returns a stable function of the same type.
3
- */
4
- export declare const useStableCallback: <T extends (...args: any[]) => any>(userFn: T) => T;
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const useTransition: typeof React.useTransition;