@dineug/erd-editor 3.0.4 → 3.1.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.
Files changed (36) hide show
  1. package/README.md +5 -3
  2. package/dist/components/erd/Erd.d.ts +1 -0
  3. package/dist/components/erd/canvas/shared-mouse-tracker/SharedMouseTracker.d.ts +4 -0
  4. package/dist/components/erd/canvas/shared-mouse-tracker/shared-mouse-cursor/SharedMouseCursor.d.ts +7 -0
  5. package/dist/components/erd/canvas/shared-mouse-tracker/shared-mouse-cursor/SharedMouseCursor.styles.d.ts +1 -0
  6. package/dist/components/erd-editor/ErdEditor.d.ts +5 -0
  7. package/dist/components/erd-editor/useErdEditorAttachElement.d.ts +3 -1
  8. package/dist/components/toolbar/Toolbar.d.ts +1 -0
  9. package/dist/engine/actions.d.ts +3 -0
  10. package/dist/engine/history.actions.d.ts +1 -1
  11. package/dist/engine/index.d.ts +1 -0
  12. package/dist/engine/modules/editor/actions.d.ts +5 -0
  13. package/dist/engine/modules/editor/atom.actions.d.ts +23 -0
  14. package/dist/engine/modules/editor/state.d.ts +9 -0
  15. package/dist/engine/replication-store.d.ts +23 -0
  16. package/dist/engine/rx-operators/bufferCircuitBreaker.d.ts +3 -0
  17. package/dist/engine/rx-operators/groupByStreamActions.d.ts +2 -2
  18. package/dist/engine/rx-operators/ignoreTagFilter.d.ts +1 -1
  19. package/dist/engine/rx-operators/index.d.ts +2 -0
  20. package/dist/engine/rx-operators/readonlyIgnoreFilter.d.ts +1 -1
  21. package/dist/engine/rx-operators/sharedStreamActionsCompressor.d.ts +3 -0
  22. package/dist/engine/shared-store.d.ts +15 -0
  23. package/dist/engine/store.d.ts +1 -1
  24. package/dist/engine/tag.d.ts +5 -2
  25. package/dist/engine.js +44 -0
  26. package/dist/erd-editor.js +14030 -30285
  27. package/dist/schemaGCService-gIQm27aj.js +15936 -0
  28. package/dist/utils/device-detect/index.d.ts +8 -7
  29. package/dist/utils/emitter.d.ts +15 -0
  30. package/dist/utils/globalEmitter.d.ts +2 -0
  31. package/dist/utils/globalEventObservable.d.ts +4 -0
  32. package/package.json +9 -10
  33. package/dist/erd-editor.min.js +0 -7133
  34. /package/dist/engine/{store.hooks.d.ts → store-hooks.d.ts} +0 -0
  35. /package/dist/{workers → services/schema-gc}/schemaGC.shared-worker.d.ts +0 -0
  36. /package/dist/{workers → services/schema-gc}/schemaGC.worker.d.ts +0 -0
package/README.md CHANGED
@@ -33,7 +33,7 @@ const editor = document.createElement('erd-editor');
33
33
  const editor = document.createElement('erd-editor');
34
34
  </script>
35
35
  <!-- or -->
36
- <script src="https://cdn.jsdelivr.net/npm/@dineug/erd-editor/dist/erd-editor.min.js"></script>
36
+ <script type="module" src="https://esm.run/@dineug/erd-editor"></script>
37
37
  ```
38
38
 
39
39
  ## ErdEditorElement
@@ -47,12 +47,14 @@ interface ErdEditorElement extends HTMLElement {
47
47
  focus: () => void;
48
48
  blur: () => void;
49
49
  clear: () => void;
50
+ destroy: () => void;
50
51
  setInitialValue: (value: string) => void;
51
52
  setPresetTheme: (themeOptions: Partial<ThemeOptions>) => void;
52
53
  setTheme: (theme: Partial<Theme>) => void;
53
54
  setKeyBindingMap: (keyBindingMap: Partial<KeyBindingMap>) => void;
54
55
  setSchemaSQL: (value: string) => void;
55
56
  getSchemaSQL: (databaseVendor?: DatabaseVendor) => string;
57
+ getSharedStore: (config?: SharedStoreConfig) => SharedStore;
56
58
  }
57
59
  ```
58
60
 
@@ -343,6 +345,6 @@ editor.setTheme({...});
343
345
 
344
346
  ## Document
345
347
 
346
- - [vscode extension](https://marketplace.visualstudio.com/items?itemName=dineug.vuerd-vscode)
348
+ - [Web App](https://erd-editor.io)
349
+ - [VSCode Extension](https://marketplace.visualstudio.com/items?itemName=dineug.vuerd-vscode)
347
350
  - [Editing Guide](https://docs.erd-editor.io/docs/category/guides)
348
- - [Import Schema SQL Support Syntax](https://github.com/dineug/erd-editor/blob/main/packages/schema-sql-parser/src/schema_sql_test_case.md)
@@ -1,6 +1,7 @@
1
1
  import { FC } from '@dineug/r-html';
2
2
  export type ErdProps = {
3
3
  isDarkMode: boolean;
4
+ mouseTracking: boolean;
4
5
  };
5
6
  declare const Erd: FC<ErdProps>;
6
7
  export default Erd;
@@ -0,0 +1,4 @@
1
+ import { FC } from '@dineug/r-html';
2
+ export type SharedMouseTrackerProps = {};
3
+ declare const SharedMouseTracker: FC<SharedMouseTrackerProps>;
4
+ export default SharedMouseTracker;
@@ -0,0 +1,7 @@
1
+ import { FC } from '@dineug/r-html';
2
+ import { SharedMouseTracker } from "../../../../../engine/modules/editor/state";
3
+ export type SharedMouseCursorProps = {
4
+ tracker: SharedMouseTracker;
5
+ };
6
+ declare const SharedMouseCursor: FC<SharedMouseCursorProps>;
7
+ export default SharedMouseCursor;
@@ -0,0 +1 @@
1
+ export declare const cursor: import("@dineug/r-html").CSSTemplateLiterals;
@@ -1,4 +1,5 @@
1
1
  import { DatabaseVendor } from "../../constants/sql/database";
2
+ import { SharedStore, SharedStoreConfig } from "../../engine/shared-store";
2
3
  import { ThemeOptions } from "../../themes/radix-ui-theme";
3
4
  import { Theme as ThemeType } from "../../themes/tokens";
4
5
  import { KeyBindingMap, KeyBindingName } from "../../utils/keyboard-shortcut";
@@ -17,10 +18,14 @@ export interface ErdEditorElement extends ErdEditorProps, HTMLElement {
17
18
  focus: () => void;
18
19
  blur: () => void;
19
20
  clear: () => void;
21
+ destroy: () => void;
20
22
  setInitialValue: (value: string) => void;
21
23
  setPresetTheme: (themeOptions: Partial<ThemeOptions>) => void;
22
24
  setTheme: (theme: Partial<ThemeType>) => void;
23
25
  setKeyBindingMap: (keyBindingMap: Partial<Omit<KeyBindingMap, typeof KeyBindingName.edit | typeof KeyBindingName.stop | typeof KeyBindingName.search | typeof KeyBindingName.undo | typeof KeyBindingName.redo | typeof KeyBindingName.zoomIn | typeof KeyBindingName.zoomOut>>) => void;
24
26
  setSchemaSQL: (value: string) => void;
25
27
  getSchemaSQL: (databaseVendor?: DatabaseVendor) => string;
28
+ getSharedStore: (config?: SharedStoreConfig & {
29
+ mouseTracker?: boolean;
30
+ }) => SharedStore;
26
31
  }
@@ -1,5 +1,6 @@
1
1
  import { Ref } from '@dineug/r-html';
2
2
  import { AppContext } from "../appContext";
3
+ import { Unsubscribe } from "../../internal-types";
3
4
  import { ThemeOptions } from "../../themes/radix-ui-theme";
4
5
  import { Theme } from "../../themes/tokens";
5
6
  import { ErdEditorElement, ErdEditorProps } from './ErdEditor';
@@ -9,13 +10,14 @@ type Props = {
9
10
  app: AppContext;
10
11
  root: Ref<HTMLDivElement>;
11
12
  };
12
- export declare function useErdEditorAttachElement({ props, ctx, app: { store, keyBindingMap, emitter }, root, }: Props): {
13
+ export declare function useErdEditorAttachElement({ props, ctx, app: { store, keyBindingMap, emitter, shortcut$, keydown$ }, root, }: Props): {
13
14
  theme: Theme;
14
15
  themeState: {
15
16
  options: ThemeOptions;
16
17
  preset: Theme;
17
18
  custom: Partial<Theme>;
18
19
  };
20
+ destroySet: Set<Unsubscribe>;
19
21
  hasDarkMode: () => boolean;
20
22
  };
21
23
  export {};
@@ -1,6 +1,7 @@
1
1
  import { FC } from '@dineug/r-html';
2
2
  export type ToolbarProps = {
3
3
  enableThemeBuilder: boolean;
4
+ readonly: boolean;
4
5
  };
5
6
  declare const Toolbar: FC<ToolbarProps>;
6
7
  export default Toolbar;
@@ -28,6 +28,9 @@ export type ActionType = keyof RootActionMap;
28
28
  export declare const actions: Actions;
29
29
  export declare const ChangeActionTypes: ReadonlyArray<ActionType>;
30
30
  export declare const ReadonlyIgnoreActionTypes: ReadonlyArray<ActionType>;
31
+ export declare const SharedStreamActionTypes: ReadonlyArray<ActionType>;
32
+ export declare const SharedActionTypes: ReadonlyArray<ActionType>;
33
+ export declare const SharedFollowingActionTypes: ReadonlyArray<ActionType>;
31
34
  export declare const StreamRegroupMoveActionTypes: ReadonlyArray<ActionType>;
32
35
  export declare const StreamRegroupColorActionTypes: ReadonlyArray<ActionType>;
33
36
  export declare const StreamRegroupScrollActionTypes: ReadonlyArray<ActionType>;
@@ -3,7 +3,7 @@ import { History } from "./history";
3
3
  import { RootState } from "./state";
4
4
  import { Store } from "./store";
5
5
  export type PushUndoHistory = (undoActions: AnyAction[], action: AnyAction, state: RootState) => void;
6
- export type PushStreamHistory = (undoActions: AnyAction[], redoActions: AnyAction[], actions: AnyAction[], state: RootState) => void;
6
+ export type PushStreamHistory = (undoActions: AnyAction[], redoActions: AnyAction[], actions: AnyAction[]) => void;
7
7
  export declare const pushUndoHistoryMap: Record<string, PushUndoHistory>;
8
8
  export declare const pushStreamHistoryMap: Record<string, PushStreamHistory>;
9
9
  export declare const pushHistory: (store: Store, history: History) => (actions: AnyAction[]) => void;
@@ -0,0 +1 @@
1
+ export { createReplicationStore, type ReplicationStore, } from './replication-store';
@@ -28,6 +28,7 @@ export declare const ActionType: {
28
28
  readonly changeOpenMap: "editor.changeOpenMap";
29
29
  readonly dragstartColumn: "editor.dragstartColumn";
30
30
  readonly dragendColumn: "editor.dragendColumn";
31
+ readonly sharedMouseTracker: "editor.sharedMouseTracker";
31
32
  };
32
33
  export type ActionType = ValuesType<typeof ActionType>;
33
34
  export type ActionMap = {
@@ -89,5 +90,9 @@ export type ActionMap = {
89
90
  columnIds: string[];
90
91
  };
91
92
  [ActionType.dragendColumn]: void;
93
+ [ActionType.sharedMouseTracker]: {
94
+ x: number;
95
+ y: number;
96
+ };
92
97
  };
93
98
  export type ReducerType<T extends keyof ActionMap> = Reducer<RootState, T, ActionMap, EngineContext>;
@@ -188,6 +188,17 @@ export declare const dragendColumnAction: {
188
188
  toString(): string;
189
189
  type: string;
190
190
  };
191
+ export declare const sharedMouseTrackerAction: {
192
+ (payload: {
193
+ x: number;
194
+ y: number;
195
+ }): import("@dineug/r-html").AnyAction<{
196
+ x: number;
197
+ y: number;
198
+ }>;
199
+ toString(): string;
200
+ type: string;
201
+ };
191
202
  export declare const editorReducers: {
192
203
  "editor.changeHasHistory": ReducerType<"editor.changeHasHistory">;
193
204
  "editor.selectAll": ReducerType<"editor.selectAll">;
@@ -213,6 +224,7 @@ export declare const editorReducers: {
213
224
  "editor.changeOpenMap": ReducerType<"editor.changeOpenMap">;
214
225
  "editor.dragstartColumn": ReducerType<"editor.dragstartColumn">;
215
226
  "editor.dragendColumn": ReducerType<"editor.dragendColumn">;
227
+ "editor.sharedMouseTracker": ReducerType<"editor.sharedMouseTracker">;
216
228
  };
217
229
  export declare const actions: {
218
230
  changeHasHistoryAction: {
@@ -403,4 +415,15 @@ export declare const actions: {
403
415
  toString(): string;
404
416
  type: string;
405
417
  };
418
+ sharedMouseTrackerAction: {
419
+ (payload: {
420
+ x: number;
421
+ y: number;
422
+ }): import("@dineug/r-html").AnyAction<{
423
+ x: number;
424
+ y: number;
425
+ }>;
426
+ toString(): string;
427
+ type: string;
428
+ };
406
429
  };
@@ -1,5 +1,6 @@
1
1
  import { Point, ValuesType } from "../../../internal-types";
2
2
  export type Editor = {
3
+ id: string;
3
4
  selectedMap: Record<string, SelectType>;
4
5
  hasUndo: boolean;
5
6
  hasRedo: boolean;
@@ -10,6 +11,7 @@ export type Editor = {
10
11
  openMap: Record<string, boolean>;
11
12
  draggableColumn: DraggableColumn | null;
12
13
  draggingColumnMap: Record<string, boolean>;
14
+ sharedMouseTrackerMap: Record<string, SharedMouseTracker>;
13
15
  };
14
16
  export type Viewport = {
15
17
  width: number;
@@ -34,6 +36,13 @@ export type DraggableColumn = {
34
36
  tableId: string;
35
37
  columnIds: string[];
36
38
  };
39
+ export type SharedMouseTracker = {
40
+ id: string;
41
+ x: number;
42
+ y: number;
43
+ nickname: string;
44
+ timeoutId: any;
45
+ };
37
46
  export declare const SelectType: {
38
47
  readonly table: "table";
39
48
  readonly memo: "memo";
@@ -0,0 +1,23 @@
1
+ import { AnyAction } from '@dineug/r-html';
2
+ import { EngineContext } from "./context";
3
+ import { Unsubscribe, ValuesType } from "../internal-types";
4
+ type ReducerRecord = {
5
+ [P in keyof InternalActionMap]: (payload: InternalActionMap[P]) => void;
6
+ };
7
+ declare const InternalActionType: {
8
+ readonly change: "change";
9
+ };
10
+ type InternalActionType = ValuesType<typeof InternalActionType>;
11
+ type InternalActionMap = {
12
+ [InternalActionType.change]: void;
13
+ };
14
+ export type ReplicationStore = {
15
+ readonly value: string;
16
+ on: (reducers: Partial<ReducerRecord>) => Unsubscribe;
17
+ setInitialValue: (value: string) => void;
18
+ dispatch: (actions: Array<AnyAction> | AnyAction) => void;
19
+ dispatchSync: (actions: Array<AnyAction> | AnyAction) => void;
20
+ destroy: () => void;
21
+ };
22
+ export declare function createReplicationStore(context: EngineContext): ReplicationStore;
23
+ export {};
@@ -0,0 +1,3 @@
1
+ import { AnyAction } from '@dineug/r-html';
2
+ import { Observable } from 'rxjs';
3
+ export declare const bufferCircuitBreaker: (openingNotifier$: Observable<any>, closingNotifier$: Observable<any>) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
@@ -1,5 +1,5 @@
1
1
  import { AnyAction } from '@dineug/r-html';
2
- import { Observable } from 'rxjs';
2
+ import { MonoTypeOperatorFunction, Observable } from 'rxjs';
3
3
  type Regroup = [string, Array<string> | ReadonlyArray<string>];
4
- export declare const groupByStreamActions: (streamActionTypes: Array<string> | ReadonlyArray<string>, regroups?: Regroup[]) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
4
+ export declare const groupByStreamActions: (streamActionTypes: Array<string> | ReadonlyArray<string>, regroups?: Regroup[], bufferClosingNotifierOperator?: MonoTypeOperatorFunction<Array<AnyAction>>) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
5
5
  export {};
@@ -1,3 +1,3 @@
1
1
  import { AnyAction } from '@dineug/r-html';
2
2
  import { Observable } from 'rxjs';
3
- export declare const ignoreTagFilter: (tag: number) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
3
+ export declare const ignoreTagFilter: (tags: number[]) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
@@ -1,4 +1,6 @@
1
1
  export * from './actionsFilter';
2
+ export * from './bufferCircuitBreaker';
2
3
  export * from './groupByStreamActions';
3
4
  export * from './ignoreTagFilter';
4
5
  export * from './notEmptyActions';
6
+ export * from './sharedStreamActionsCompressor';
@@ -1,3 +1,3 @@
1
1
  import { AnyAction } from '@dineug/r-html';
2
2
  import { Observable } from 'rxjs';
3
- export declare const readonlyIgnoreFilter: (getReadonly: () => boolean) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
3
+ export declare const readonlyIgnoreFilter: (getReadonly: () => boolean, passTags?: number[]) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
@@ -0,0 +1,3 @@
1
+ import { AnyAction } from '@dineug/r-html';
2
+ import { Observable } from 'rxjs';
3
+ export declare const sharedStreamActionsCompressor: (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
@@ -0,0 +1,15 @@
1
+ import { AnyAction } from '@dineug/r-html';
2
+ import { RxStore } from "./rx-store";
3
+ import { Unsubscribe } from "../internal-types";
4
+ export type SharedStore = {
5
+ connection: () => void;
6
+ disconnect: () => void;
7
+ dispatch: (actions: Array<AnyAction> | AnyAction) => void;
8
+ dispatchSync: (actions: Array<AnyAction> | AnyAction) => void;
9
+ subscribe: (fn: (value: AnyAction[]) => void) => Unsubscribe;
10
+ destroy: () => void;
11
+ };
12
+ export type SharedStoreConfig = {
13
+ getNickname?: () => string;
14
+ };
15
+ export declare function createSharedStore(store: RxStore, config?: SharedStoreConfig): SharedStore;
@@ -2,4 +2,4 @@ import { Store as StoreType } from '@dineug/r-html';
2
2
  import { EngineContext } from "./context";
3
3
  import { RootState } from "./state";
4
4
  export type Store = StoreType<RootState, EngineContext>;
5
- export declare function createStore(context: EngineContext): Store;
5
+ export declare function createStore(context: EngineContext, enableObservable?: boolean): Store;
@@ -2,6 +2,9 @@ import { AnyAction, CompositionActions } from '@dineug/r-html';
2
2
  import { GeneratorAction } from "./generator.actions";
3
3
  export declare const Tag: {
4
4
  readonly shared: 1;
5
+ readonly changeOnly: 2;
6
+ readonly following: 4;
5
7
  };
6
- export declare function attachActionTag(tag: number, actions: AnyAction[]): AnyAction[];
7
- export declare const attachSharedTag$: (...compositionActions: CompositionActions) => GeneratorAction;
8
+ export declare function attachActionTag(tag: number, action: AnyAction): AnyAction;
9
+ export declare function attachActionsTag(tag: number, actions: AnyAction[]): AnyAction[];
10
+ export declare const attachChangeOnlyTag$: (...compositionActions: CompositionActions) => GeneratorAction;
package/dist/engine.js ADDED
@@ -0,0 +1,44 @@
1
+ import { D as A, E as w, u as x, O as E, F as l, J as $, p as G, bs as d, I as p, Y as I, c$ as O, br as T, aA as j, d5 as k, U as F, cY as J, cS as R } from "./schemaGCService-gIQm27aj.js";
2
+ /*!
3
+ * @dineug/erd-editor
4
+ * @version 3.1.0 | Sat Jan 06 2024
5
+ * @author SeungHwan-Lee <dineug2@gmail.com>
6
+ * @license MIT
7
+ */
8
+ const b = {
9
+ change: "change"
10
+ };
11
+ function Y(u) {
12
+ const o = /* @__PURE__ */ new Set(), s = A(u, !1), m = w(s), c = new x(), S = new E((e) => s.subscribe((a) => e.next(a))).pipe(l(p), $(200)), n = /* @__PURE__ */ new Set(), f = new R(), g = (e) => (n.has(e) || n.add(e), () => {
13
+ n.delete(e);
14
+ }), i = (e, a) => {
15
+ n.forEach((t) => {
16
+ const h = Reflect.get(t, e);
17
+ I(h, a);
18
+ });
19
+ }, y = (e) => {
20
+ const a = O(e);
21
+ s.dispatchSync(T(j(a) ? "{}" : a)), f.run(d(s.state)).then((t) => {
22
+ (t.tableIds.length || t.tableColumnIds.length || t.relationshipIds.length || t.indexIds.length || t.indexColumnIds.length || t.memoIds.length) && (k(s.state, t), i(b.change, void 0));
23
+ });
24
+ }, r = (e) => {
25
+ c.next([e].flat());
26
+ }, C = (e) => {
27
+ F(() => r(e));
28
+ }, v = () => {
29
+ Array.from(o).forEach((e) => e.unsubscribe()), o.clear(), n.clear(), s.destroy(), m.destroy();
30
+ };
31
+ return o.add(S.subscribe(() => i(b.change, void 0))).add(c.pipe(l(p), G((e) => e.map((a) => J(a, "tags")))).subscribe(s.dispatchSync)), Object.freeze({
32
+ get value() {
33
+ return d(s.state);
34
+ },
35
+ on: g,
36
+ setInitialValue: y,
37
+ dispatch: C,
38
+ dispatchSync: r,
39
+ destroy: v
40
+ });
41
+ }
42
+ export {
43
+ Y as createReplicationStore
44
+ };