@dineug/erd-editor 3.9.0 → 3.9.1
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.
- package/dist/engine/index.js +14 -13
- package/dist/engine/modules/relationship/fkColumns.d.ts +9 -0
- package/dist/engine/modules/relationship/generator.actions.d.ts +10 -1
- package/dist/engine/modules/table/generator.actions.d.ts +7 -0
- package/dist/engine/peer-store.d.ts +93 -0
- package/dist/engine/presence.d.ts +23 -0
- package/dist/engine/rx-operators/bufferCircuitBreaker.d.ts +5 -0
- package/dist/engine/rx-operators/createSharedStreamActionsCompressor.d.ts +10 -0
- package/dist/engine/rx-operators/flushOnNotifier.d.ts +9 -0
- package/dist/engine/rx-operators/groupByStreamActions.d.ts +3 -1
- package/dist/engine/rx-operators/sharedStreamActionsCompressor.d.ts +2 -3
- package/dist/engine/rx-store.d.ts +13 -1
- package/dist/engine/shared-store.d.ts +11 -1
- package/dist/engine/stream-flush.d.ts +12 -0
- package/dist/engine/to-width.d.ts +7 -0
- package/dist/erd-editor.umd.js +287 -286
- package/dist/index.js +4884 -5933
- package/dist/peer/index.d.ts +29 -0
- package/dist/peer/index.js +230 -0
- package/dist/schemaGCService-_8A8Oh9Q.js +38 -0
- package/dist/shared-store-CtJL8B4I.js +1072 -0
- package/dist/{schemaGCService-CFiz1xOG.js → store-hooks-DuNN9ZKu.js} +3281 -3228
- package/dist/utils/calcTable.d.ts +9 -0
- package/dist/workers/exportPng.shared-worker.js +26 -26
- package/package.json +7 -3
|
@@ -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, $n as t, Bn as n, E as r, G as i, H as a, Hi as o, I as s, In as c, Jn as l, Jr as u, L as d, Li as ee, M as f, Qi as p, Qt as m, Rn as h, Sa as te, Si as g, Tn as _, Vi as v, Zi as y, _n as b, aa as x, b as S, da as C, ea as w, fa as T, g as E, ga as D, gn as O, ha as k, ia as A, in as j, jt as ne, la as re, li as ie, ma as ae, oa as M, on as N, pa as P, pn as F, rn as I, ta as L, tt as R, un as z, v as B, w as V, wi as H, xn as U, ya as W, zn as G, zt as K } from "../store-hooks-DuNN9ZKu.js";
|
|
2
|
+
import { c as q, d as J, f as oe, l as se, n as ce, t as le } from "../shared-store-CtJL8B4I.js";
|
|
3
|
+
import { isEmpty as ue } from "es-toolkit/compat";
|
|
4
|
+
//#region src/engine/presence.ts
|
|
5
|
+
var de = U / 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 = "", r = (n) => {
|
|
21
|
+
let r = q(e.state.editor.focusTable), i = se(r);
|
|
22
|
+
i === t && !n || (t = i, e.dispatch(l({ focus: r })));
|
|
23
|
+
}, i = e.subscribe((e) => {
|
|
24
|
+
r(e.some((e) => e.type === n.type));
|
|
25
|
+
}), a = setInterval(() => {
|
|
26
|
+
t && r(!0);
|
|
27
|
+
}, de);
|
|
28
|
+
return fe(a), Object.freeze({ destroy: () => {
|
|
29
|
+
i(), clearInterval(a);
|
|
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]), B(this, "code", void 0), B(this, "operation", void 0), this.name = "PeerStoreError", this.code = e, this.operation = t;
|
|
50
|
+
}
|
|
51
|
+
}, $ = y(S), ye = y(r), be = y([
|
|
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 ? [h({
|
|
90
|
+
tableId: t,
|
|
91
|
+
focusType: r
|
|
92
|
+
})] : [c({
|
|
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: r = !0, readonly: i = !1 }) {
|
|
101
|
+
let a = null, o = J(E({ toWidth: t }), {
|
|
102
|
+
manualStreamFlush: !0,
|
|
103
|
+
observable: !1,
|
|
104
|
+
getHistory: (e) => (a = xe(oe(e)), a.history)
|
|
105
|
+
}), s = () => a?.getPushes() ?? 0, c = () => a?.getLimit() ?? 0, l = le(o, { getNickname: () => e }, { manualStreamFlush: !0 }), u = ge(o, l), d = /* @__PURE__ */ new Set(), f = o.state.editor.id, p = i, m = !1, h = null, g = !1, v = 0, y = [], b = [], x = null;
|
|
106
|
+
o.dispatchSync(_({
|
|
107
|
+
width: 0,
|
|
108
|
+
height: 0
|
|
109
|
+
}));
|
|
110
|
+
let S = r ? he(o) : null, C = () => {
|
|
111
|
+
h ||= l.subscribe((e) => {
|
|
112
|
+
e.some((e) => $(e.type)) && v++;
|
|
113
|
+
for (let t of Array.from(d)) I(t, e);
|
|
114
|
+
});
|
|
115
|
+
}, w = (e) => {
|
|
116
|
+
if (m) throw new Q(Z.destroyed, e);
|
|
117
|
+
}, T = (e) => {
|
|
118
|
+
if (x) throw Error(`${e} cannot run inside a group`);
|
|
119
|
+
}, D = (e) => {
|
|
120
|
+
if (w(e), p) throw new Q(Z.readonly, e);
|
|
121
|
+
}, O = () => {
|
|
122
|
+
let e = c();
|
|
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
|
+
}, k = (e, t = {}) => {
|
|
128
|
+
D("dispatch"), C();
|
|
129
|
+
let n = v, r = s(), i = te(o.state, o.context, [...Se(t.focus), ...e]);
|
|
130
|
+
o.dispatchSync(i), i.some((e) => ye(e.type)) && u.flush();
|
|
131
|
+
let a = {
|
|
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: s() - r
|
|
137
|
+
};
|
|
138
|
+
return x ? (x.unit.historyEntries += a.historyEntries, x.dispatched = !0) : y.push({
|
|
139
|
+
label: a.label,
|
|
140
|
+
historyEntries: a.historyEntries
|
|
141
|
+
}), a.historyEntries && (b = []), x || O(), a;
|
|
142
|
+
}, A = (e, t) => {
|
|
143
|
+
if (D("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), O());
|
|
156
|
+
}
|
|
157
|
+
}, j = (e, t) => {
|
|
158
|
+
for (let n = 0; n < e.historyEntries; n++) t();
|
|
159
|
+
u.flush();
|
|
160
|
+
};
|
|
161
|
+
return Object.freeze({
|
|
162
|
+
editorId: f,
|
|
163
|
+
get value() {
|
|
164
|
+
return W(o.state);
|
|
165
|
+
},
|
|
166
|
+
get state() {
|
|
167
|
+
return o.state;
|
|
168
|
+
},
|
|
169
|
+
get isReadonly() {
|
|
170
|
+
return p;
|
|
171
|
+
},
|
|
172
|
+
get isDestroyed() {
|
|
173
|
+
return m;
|
|
174
|
+
},
|
|
175
|
+
setReadonly: (e) => {
|
|
176
|
+
p = e;
|
|
177
|
+
},
|
|
178
|
+
setInitialValue: (e) => {
|
|
179
|
+
w("setInitialValue"), T("setInitialValue");
|
|
180
|
+
let t = ee(e);
|
|
181
|
+
o.dispatchSync(G(), R(ue(t) ? "{}" : t)), o.resetHistory(), y = [], b = [];
|
|
182
|
+
},
|
|
183
|
+
mergeClock: (e) => {
|
|
184
|
+
o.context.clock.merge(e);
|
|
185
|
+
},
|
|
186
|
+
dispatch: k,
|
|
187
|
+
receive: (e) => {
|
|
188
|
+
m || l.dispatchSync(e);
|
|
189
|
+
},
|
|
190
|
+
group: A,
|
|
191
|
+
undo: () => {
|
|
192
|
+
D("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 ? (j(t, o.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
|
+
D("redo"), T("redo"), C();
|
|
207
|
+
let e = b.pop();
|
|
208
|
+
return e ? (j(e, o.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), g || (g = !0, h ? o.dispatchSync(n()) : C()), () => {
|
|
219
|
+
d.delete(e);
|
|
220
|
+
}),
|
|
221
|
+
flushStreamBuffers: () => {
|
|
222
|
+
m || u.flush();
|
|
223
|
+
},
|
|
224
|
+
destroy: () => {
|
|
225
|
+
m || (m = !0, S?.destroy(), h?.(), h = null, d.clear(), l.destroy(), o.destroy(), me(o.state.editor), y = [], b = []);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
export { L as BracketType, p as COLUMN_MIN_WIDTH, A as CanvasType, S as ChangeActionTypes, x as ColumnOption, M as ColumnType, re as Database, v as DatabaseVendorList, o as DatabaseVendorToDatabase, g as FocusType, C as Language, e as MEMO_MIN_HEIGHT, w as MEMO_MIN_WIDTH, T as NameCase, P as OrderType, Q as PeerStoreError, Z as PeerStoreErrorCode, ae as RelationshipType, k as SaveSettingType, H as SelectType, V as SharedFollowingActionTypes, D as Show, r as StreamActionTypes, ie as bHas, E as createEngineContext, Ce as createPeerStore, ce as createSchemaSQL, X as defaultToWidth, i as editorActions$, b as indexActions, a as indexActions$, O as indexColumnActions, d as indexColumnActions$, u as measureTableSize, F as memoActions, m as memoActions$, z as relationshipActions, s as relationshipActions$, t as settingsActions, f as settingsActions$, N as tableActions, K as tableActions$, j as tableColumnActions, ne as tableColumnActions$ };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Zi as e, ba as t, xa as n } from "./store-hooks-DuNN9ZKu.js";
|
|
2
|
+
import { DateTime as r } from "luxon";
|
|
3
|
+
//#region src/services/schema-gc/procGC.ts
|
|
4
|
+
function i({ collections: e }, { tableIds: n, tableColumnIds: r, relationshipIds: i, indexIds: a, indexColumnIds: o, memoIds: s }) {
|
|
5
|
+
t(e).collection("tableEntities").removeMany(n), t(e).collection("tableColumnEntities").removeMany(r), t(e).collection("relationshipEntities").removeMany(i), t(e).collection("indexEntities").removeMany(a), t(e).collection("indexColumnEntities").removeMany(o), t(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 = n(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 = t(p).collection("tableEntities"), b = t(p).collection("tableColumnEntities"), x = t(p).collection("indexEntities"), S = t(p).collection("indexColumnEntities"), C = t(p).collection("relationshipEntities"), w = t(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 };
|