@dineug/erd-editor 3.9.0 → 3.9.2

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.
@@ -0,0 +1,29 @@
1
+ export { COLUMN_MIN_WIDTH, MEMO_MIN_HEIGHT, MEMO_MIN_WIDTH, } from '../constants/layout';
2
+ export { BracketType, CanvasType, ColumnOption, ColumnType, Database, Language, NameCase, OrderType, RelationshipType, SaveSettingType, Show, } from '../constants/schema';
3
+ export { type DatabaseVendor, DatabaseVendorList, DatabaseVendorToDatabase, } from '../constants/sql/database';
4
+ export { type ActionType, ChangeActionTypes, SharedFollowingActionTypes, StreamActionTypes, } from '../engine/actions';
5
+ export { createEngineContext, type EngineContext } from '../engine/context';
6
+ export type { GeneratorAction } from '../engine/generator.actions';
7
+ export { actions$ as editorActions$ } from '../engine/modules/editor/generator.actions';
8
+ export { FocusType, SelectType } from '../engine/modules/editor/state';
9
+ export { actions as indexActions } from '../engine/modules/index/atom.actions';
10
+ export { actions$ as indexActions$ } from '../engine/modules/index/generator.actions';
11
+ export { actions as indexColumnActions } from '../engine/modules/index-column/atom.actions';
12
+ export { actions$ as indexColumnActions$ } from '../engine/modules/index-column/generator.actions';
13
+ export { actions as memoActions } from '../engine/modules/memo/atom.actions';
14
+ export { actions$ as memoActions$ } from '../engine/modules/memo/generator.actions';
15
+ export { actions as relationshipActions } from '../engine/modules/relationship/atom.actions';
16
+ export { actions$ as relationshipActions$ } from '../engine/modules/relationship/generator.actions';
17
+ export { actions as settingsActions } from '../engine/modules/settings/atom.actions';
18
+ export { actions$ as settingsActions$ } from '../engine/modules/settings/generator.actions';
19
+ export { actions as tableActions } from '../engine/modules/table/atom.actions';
20
+ export { actions$ as tableActions$ } from '../engine/modules/table/generator.actions';
21
+ export { actions as tableColumnActions } from '../engine/modules/table-column/atom.actions';
22
+ export { actions$ as tableColumnActions$ } from '../engine/modules/table-column/generator.actions';
23
+ export { createPeerStore, type DispatchFocus, type DispatchOptions, type DispatchReport, type PeerStore, PeerStoreError, PeerStoreErrorCode, type PeerStoreOptions, type RevertResult, } from '../engine/peer-store';
24
+ export type { RootState } from '../engine/state';
25
+ export { defaultToWidth } from '../engine/to-width';
26
+ export { bHas } from '../utils/bit';
27
+ export { measureTableSize } from '../utils/calcTable';
28
+ export { createSchemaSQL } from '../utils/schema-sql';
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,230 @@
1
+ import { $i as e, At as t, Bi as n, C as r, Ci as i, F as a, Fn as o, I as s, Ii as c, Ln as l, Qi as u, Qn as d, Rn as f, Rt as p, T as m, V as h, Vi as g, W as _, Xi as v, Zi as y, Zt as b, _ as x, aa as S, an as C, bn as w, ca as T, ci as E, da as D, ea as O, et as ee, fa as k, fn as A, gn as te, h as j, ha as ne, hn as re, ia as ie, j as ae, ln as M, ma as N, nn as P, pa as F, qn as I, qr as L, ra as R, rn as z, ua as B, va as V, wn as H, xa as U, xi as W, y as G, zn as K } from "../store-hooks-DuzDVhPy.js";
2
+ import { c as q, d as J, f as oe, l as se, n as ce, t as le } from "../shared-store-BqPSXAEf.js";
3
+ import { isEmpty as ue } from "es-toolkit/compat";
4
+ //#region src/engine/presence.ts
5
+ var de = w / 3, fe = (e) => {
6
+ e?.unref?.();
7
+ }, pe = [
8
+ "sharedMouseTrackerMap",
9
+ "sharedFocusTrackerMap",
10
+ "sharedSelectionTrackerMap",
11
+ "sharedDragSelectTrackerMap"
12
+ ];
13
+ function me(e) {
14
+ for (let t of pe) {
15
+ let n = e[t];
16
+ for (let e of Object.keys(n)) clearTimeout(n[e].timeoutId), Reflect.deleteProperty(n, e);
17
+ }
18
+ }
19
+ function he(e) {
20
+ let t = "", n = (n) => {
21
+ let r = q(e.state.editor.focusTable), i = se(r);
22
+ i === t && !n || (t = i, e.dispatch(I({ focus: r })));
23
+ }, r = e.subscribe((e) => {
24
+ n(e.some((e) => e.type === K.type));
25
+ }), i = setInterval(() => {
26
+ t && n(!0);
27
+ }, de);
28
+ return fe(i), Object.freeze({ destroy: () => {
29
+ r(), clearInterval(i);
30
+ } });
31
+ }
32
+ //#endregion
33
+ //#region src/engine/stream-flush.ts
34
+ function ge(e, t) {
35
+ return Object.freeze({ flush: () => {
36
+ e.flushStreamBuffers(), t.flushStreamBuffers();
37
+ } });
38
+ }
39
+ //#endregion
40
+ //#region src/engine/to-width.ts
41
+ var _e = 2, Y = 10, X = (e) => Math.round(e.length * Y) + _e, Z = {
42
+ readonly: "readonly",
43
+ destroyed: "destroyed"
44
+ }, ve = {
45
+ readonly: "the document is readonly, so no edit was made",
46
+ destroyed: "this document session was closed; open the document again"
47
+ }, Q = class extends Error {
48
+ constructor(e, t) {
49
+ super(ve[e]), x(this, "code", void 0), x(this, "operation", void 0), this.name = "PeerStoreError", this.code = e, this.operation = t;
50
+ }
51
+ }, $ = v(G), ye = v(m), be = v([
52
+ "table.add",
53
+ "column.add",
54
+ "memo.add",
55
+ "index.add",
56
+ "indexColumn.add",
57
+ "relationship.add"
58
+ ]);
59
+ function xe(e) {
60
+ let t = 0, n = 0;
61
+ return {
62
+ history: Object.freeze({
63
+ get cursor() {
64
+ return e.cursor;
65
+ },
66
+ get size() {
67
+ return e.size;
68
+ },
69
+ hasUndo: e.hasUndo,
70
+ hasRedo: e.hasRedo,
71
+ undo: e.undo,
72
+ redo: e.redo,
73
+ push: (n) => {
74
+ t++, e.push(n);
75
+ },
76
+ clear: e.clear,
77
+ setLimit: (t) => {
78
+ n = t, e.setLimit(t);
79
+ },
80
+ clone: e.clone
81
+ }),
82
+ getPushes: () => t,
83
+ getLimit: () => n
84
+ };
85
+ }
86
+ function Se(e) {
87
+ if (!e) return [];
88
+ let { tableId: t, columnId: n, focusType: r } = e;
89
+ return n === void 0 ? [l({
90
+ tableId: t,
91
+ focusType: r
92
+ })] : [o({
93
+ tableId: t,
94
+ columnId: n,
95
+ focusType: r,
96
+ $mod: !1,
97
+ shiftKey: !1
98
+ })];
99
+ }
100
+ function Ce({ nickname: e, toWidth: t = X, presence: n = !0, readonly: r = !1 }) {
101
+ let i = null, a = J(j({ toWidth: t }), {
102
+ manualStreamFlush: !0,
103
+ observable: !1,
104
+ getHistory: (e) => (i = xe(oe(e)), i.history)
105
+ }), o = () => i?.getPushes() ?? 0, s = () => i?.getLimit() ?? 0, l = le(a, { getNickname: () => e }, { manualStreamFlush: !0 }), u = ge(a, l), d = /* @__PURE__ */ new Set(), p = a.state.editor.id, m = r, h = !1, g = null, _ = !1, v = 0, y = [], b = [], x = null;
106
+ a.dispatchSync(H({
107
+ width: 0,
108
+ height: 0
109
+ }));
110
+ let S = n ? he(a) : null, C = () => {
111
+ g ||= l.subscribe((e) => {
112
+ e.some((e) => $(e.type)) && v++;
113
+ for (let t of Array.from(d)) P(t, e);
114
+ });
115
+ }, w = (e) => {
116
+ if (h) throw new Q(Z.destroyed, e);
117
+ }, T = (e) => {
118
+ if (x) throw Error(`${e} cannot run inside a group`);
119
+ }, E = (e) => {
120
+ if (w(e), m) throw new Q(Z.readonly, e);
121
+ }, D = () => {
122
+ let e = s();
123
+ if (!e) return;
124
+ let t = y.reduce((e, { historyEntries: t }) => e + t, 0);
125
+ for (; t > e;) t -= y.shift().historyEntries;
126
+ for (; y.length > e;) y.splice(y.findIndex(({ historyEntries: e }) => !e), 1);
127
+ }, O = (e, t = {}) => {
128
+ E("dispatch"), C();
129
+ let n = v, r = o(), i = U(a.state, a.context, [...Se(t.focus), ...e]);
130
+ a.dispatchSync(i), i.some((e) => ye(e.type)) && u.flush();
131
+ let s = {
132
+ label: t.label ?? null,
133
+ actions: i.filter((e) => $(e.type)),
134
+ createdIds: i.filter((e) => be(e.type)).map((e) => e.payload.id),
135
+ batches: v - n,
136
+ historyEntries: o() - r
137
+ };
138
+ return x ? (x.unit.historyEntries += s.historyEntries, x.dispatched = !0) : y.push({
139
+ label: s.label,
140
+ historyEntries: s.historyEntries
141
+ }), s.historyEntries && (b = []), x || D(), s;
142
+ }, k = (e, t) => {
143
+ if (E("group"), x) return t();
144
+ let n = {
145
+ unit: {
146
+ label: e,
147
+ historyEntries: 0
148
+ },
149
+ dispatched: !1
150
+ };
151
+ x = n;
152
+ try {
153
+ return t();
154
+ } finally {
155
+ x = null, n.dispatched && (y.push(n.unit), D());
156
+ }
157
+ }, A = (e, t) => {
158
+ for (let n = 0; n < e.historyEntries; n++) t();
159
+ u.flush();
160
+ };
161
+ return Object.freeze({
162
+ editorId: p,
163
+ get value() {
164
+ return V(a.state);
165
+ },
166
+ get state() {
167
+ return a.state;
168
+ },
169
+ get isReadonly() {
170
+ return m;
171
+ },
172
+ get isDestroyed() {
173
+ return h;
174
+ },
175
+ setReadonly: (e) => {
176
+ m = e;
177
+ },
178
+ setInitialValue: (e) => {
179
+ w("setInitialValue"), T("setInitialValue");
180
+ let t = c(e);
181
+ a.dispatchSync(f(), ee(ue(t) ? "{}" : t)), a.resetHistory(), y = [], b = [];
182
+ },
183
+ mergeClock: (e) => {
184
+ a.context.clock.merge(e);
185
+ },
186
+ dispatch: O,
187
+ receive: (e) => {
188
+ h || l.dispatchSync(e);
189
+ },
190
+ group: k,
191
+ undo: () => {
192
+ E("undo"), T("undo"), C();
193
+ let e = [], t = y.pop();
194
+ for (; t && !t.historyEntries;) t.label !== null && e.push(t.label), t = y.pop();
195
+ return t ? (A(t, a.undo), b.push(t), {
196
+ label: t.label,
197
+ entries: t.historyEntries,
198
+ skipped: e
199
+ }) : {
200
+ label: null,
201
+ entries: 0,
202
+ skipped: e
203
+ };
204
+ },
205
+ redo: () => {
206
+ E("redo"), T("redo"), C();
207
+ let e = b.pop();
208
+ return e ? (A(e, a.redo), y.push(e), {
209
+ label: e.label,
210
+ entries: e.historyEntries,
211
+ skipped: []
212
+ }) : {
213
+ label: null,
214
+ entries: 0,
215
+ skipped: []
216
+ };
217
+ },
218
+ subscribe: (e) => (w("subscribe"), d.add(e), _ || (_ = !0, g ? a.dispatchSync(K()) : C()), () => {
219
+ d.delete(e);
220
+ }),
221
+ flushStreamBuffers: () => {
222
+ h || u.flush();
223
+ },
224
+ destroy: () => {
225
+ h || (h = !0, S?.destroy(), g?.(), g = null, d.clear(), l.destroy(), a.destroy(), me(a.state.editor), y = [], b = []);
226
+ }
227
+ });
228
+ }
229
+ //#endregion
230
+ export { O as BracketType, y as COLUMN_MIN_WIDTH, R as CanvasType, G as ChangeActionTypes, ie as ColumnOption, S as ColumnType, T as Database, n as DatabaseVendorList, g as DatabaseVendorToDatabase, W as FocusType, B as Language, u as MEMO_MIN_HEIGHT, e as MEMO_MIN_WIDTH, D as NameCase, k as OrderType, Q as PeerStoreError, Z as PeerStoreErrorCode, F as RelationshipType, N as SaveSettingType, i as SelectType, r as SharedFollowingActionTypes, ne as Show, m as StreamActionTypes, E as bHas, j as createEngineContext, Ce as createPeerStore, ce as createSchemaSQL, X as defaultToWidth, _ as editorActions$, te as indexActions, h as indexActions$, re as indexColumnActions, s as indexColumnActions$, L as measureTableSize, A as memoActions, b as memoActions$, M as relationshipActions, a as relationshipActions$, d as settingsActions, ae as settingsActions$, C as tableActions, p as tableActions$, z as tableColumnActions, t as tableColumnActions$ };
@@ -0,0 +1,38 @@
1
+ import { Xi as e, ba as t, ya as n } from "./store-hooks-DuzDVhPy.js";
2
+ import { DateTime as r } from "luxon";
3
+ //#region src/services/schema-gc/procGC.ts
4
+ function i({ collections: e }, { tableIds: t, tableColumnIds: r, relationshipIds: i, indexIds: a, indexColumnIds: o, memoIds: s }) {
5
+ n(e).collection("tableEntities").removeMany(t), n(e).collection("tableColumnEntities").removeMany(r), n(e).collection("relationshipEntities").removeMany(i), n(e).collection("indexEntities").removeMany(a), n(e).collection("indexColumnEntities").removeMany(o), n(e).collection("memoEntities").removeMany(s);
6
+ }
7
+ //#endregion
8
+ //#region src/services/schema-gc/schemaGCService.ts
9
+ var a = 3, o = class {
10
+ async run(a) {
11
+ let o = JSON.parse(a), c = t(o), { doc: { tableIds: l, memoIds: u, indexIds: d, relationshipIds: f }, collections: p } = c, m = e(l), h = e(u), g = e(d), _ = e(f), v = s(r.now()), y = n(p).collection("tableEntities"), b = n(p).collection("tableColumnEntities"), x = n(p).collection("indexEntities"), S = n(p).collection("indexColumnEntities"), C = n(p).collection("relationshipEntities"), w = n(p).collection("memoEntities"), T = new Set(y.selectAll().filter(v(m)).map(({ id: e }) => e)), E = /* @__PURE__ */ new Set(), D = new Set(C.selectAll().filter(v(_)).map(({ id: e }) => e)), O = new Set(x.selectAll().filter(v(g)).map(({ id: e }) => e)), k = /* @__PURE__ */ new Set(), A = new Set(w.selectAll().filter(v(h)).map(({ id: e }) => e));
12
+ b.selectAll().filter(({ tableId: e }) => T.has(e)).forEach(({ id: e }) => E.add(e)), C.selectAll().filter(({ id: e, start: t, end: n }) => !D.has(e) && (T.has(t.tableId) || T.has(n.tableId))).forEach(({ id: e }) => D.add(e)), x.selectAll().filter(({ id: e, tableId: t }) => !O.has(e) && T.has(t)).forEach(({ id: e }) => O.add(e)), S.selectAll().filter(({ indexId: e }) => O.has(e)).forEach(({ id: e }) => k.add(e)), i(c, {
13
+ tableIds: [...T],
14
+ tableColumnIds: [...E],
15
+ relationshipIds: [...D],
16
+ indexIds: [...O],
17
+ indexColumnIds: [...k],
18
+ memoIds: [...A]
19
+ });
20
+ let j = e(y.selectAll().map(({ id: e }) => e)), M = e(x.selectAll().map(({ id: e }) => e));
21
+ return b.selectAll().filter(({ tableId: e, id: t, meta: n }) => !j(e) && v(() => !1)({
22
+ id: t,
23
+ meta: n
24
+ })).forEach(({ id: e }) => E.add(e)), S.selectAll().filter(({ indexId: e, id: t, meta: n }) => !M(e) && v(() => !1)({
25
+ id: t,
26
+ meta: n
27
+ })).forEach(({ id: e }) => k.add(e)), {
28
+ tableIds: [...T],
29
+ tableColumnIds: [...E],
30
+ relationshipIds: [...D],
31
+ indexIds: [...O],
32
+ indexColumnIds: [...k],
33
+ memoIds: [...A]
34
+ };
35
+ }
36
+ }, s = (e) => (t) => ({ id: n, meta: i }) => !t(n) && a < Math.floor(e.diff(r.fromMillis(i.updateAt), "days").toObject().days ?? 0);
37
+ //#endregion
38
+ export { i as n, o as t };