@dineug/erd-editor
Version:
Entity-Relationship Diagram Editor
54 lines (53 loc) • 1.64 kB
JavaScript
import { Z as x, D as w, E as A, w as E, O as G, F as d, J as I, s as O, bv as h, I as l, Y as T, V, d6 as $, bu as j, aB as k, cX as F, da as J, db as R, dc as z } from "./schemaGCService-CLe8cLsy.js";
/*!
* @dineug/erd-editor
* @version 3.3.0 | Wed May 07 2025
* @author SeungHwan-Lee <dineug2@gmail.com>
* @license MIT
*/
const B = {
change: "change"
};
function H(p) {
const o = /* @__PURE__ */ new Set(), b = x(p), t = w(b, !1), u = A(t), c = new E(), m = new G(
(e) => t.subscribe((n) => e.next(n))
).pipe(d(l), I(200)), a = /* @__PURE__ */ new Set(), S = new F(), g = (e) => (a.has(e) || a.add(e), () => {
a.delete(e);
}), f = (e, n) => {
a.forEach((s) => {
const r = Reflect.get(s, e);
T(r, n);
});
}, y = (e) => {
const n = $(e);
t.dispatchSync(
j(k(n) ? "{}" : n)
), S.run(h(t.state)).then((s) => {
(s.tableIds.length || s.tableColumnIds.length || s.relationshipIds.length || s.indexIds.length || s.indexColumnIds.length || s.memoIds.length) && (J(t.state, s), t.dispatchSync(R()));
});
}, i = (e) => {
c.next([e].flat());
}, C = (e) => {
V(() => i(e));
}, v = () => {
Array.from(o).forEach((e) => e.unsubscribe()), o.clear(), a.clear(), t.destroy(), u.destroy();
};
return o.add(m.subscribe(() => f(B.change, void 0))).add(
c.pipe(
d(l),
O((e) => e.map((n) => z(n, "tags")))
).subscribe(t.dispatchSync)
), Object.freeze({
get value() {
return h(t.state);
},
on: g,
setInitialValue: y,
dispatch: C,
dispatchSync: i,
destroy: v
});
}
export {
H as createReplicationStore
};