@nokecy/qc-ui 1.0.70 → 1.0.72
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/cjs/ag-grid-plus/ag-gridPlus.js +409 -206
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +30 -5
- package/dist/cjs/ag-grid-plus/context/gridContext.js +6 -1
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.d.ts +36 -0
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.js +143 -0
- package/dist/cjs/ag-grid-plus/errors/index.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/errors/index.js +31 -0
- package/dist/cjs/ag-grid-plus/errors/types.d.ts +71 -0
- package/dist/cjs/ag-grid-plus/errors/types.js +137 -0
- package/dist/cjs/ag-grid-plus/hooks/index.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/hooks/index.js +51 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.d.ts +88 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.js +224 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.d.ts +91 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.js +230 -0
- package/dist/cjs/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +1 -8
- package/dist/cjs/ag-grid-plus/hooks/useGridState.d.ts +153 -0
- package/dist/cjs/ag-grid-plus/hooks/useGridState.js +258 -0
- package/dist/cjs/ag-grid-plus/index.d.ts +5 -0
- package/dist/cjs/ag-grid-plus/index.js +164 -0
- package/dist/cjs/ag-grid-plus/interface.d.ts +37 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +21 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +580 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +86 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.d.ts +5 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.js +12 -0
- package/dist/cjs/ag-grid-plus/querySchemes/constants.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/querySchemes/constants.js +30 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +10 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +65 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +542 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.js +32 -0
- package/dist/cjs/ag-grid-plus/querySchemes/index.d.ts +11 -0
- package/dist/cjs/ag-grid-plus/querySchemes/index.js +113 -0
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +44 -0
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +261 -0
- package/dist/cjs/ag-grid-plus/querySchemes/types.d.ts +143 -0
- package/dist/cjs/ag-grid-plus/querySchemes/types.js +5 -0
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.d.ts +36 -0
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.js +155 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.js +342 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.less +35 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.d.ts +20 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.js +289 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.less +39 -0
- package/dist/cjs/ag-grid-plus/schemes/components/index.d.ts +4 -0
- package/dist/cjs/ag-grid-plus/schemes/components/index.js +19 -0
- package/dist/cjs/ag-grid-plus/schemes/constants.d.ts +23 -0
- package/dist/cjs/ag-grid-plus/schemes/constants.js +39 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.js +542 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.js +32 -0
- package/dist/cjs/ag-grid-plus/schemes/index.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/schemes/index.js +124 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +64 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.js +368 -0
- package/dist/cjs/ag-grid-plus/schemes/types.d.ts +126 -0
- package/dist/cjs/ag-grid-plus/schemes/types.js +5 -0
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.d.ts +27 -0
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.js +113 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +955 -0
- package/dist/cjs/ag-grid-plus/setting/index.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/setting/index.js +74 -111
- package/dist/cjs/ag-grid-plus/shared/hooks/useSchemeManager.d.ts +66 -0
- package/dist/cjs/ag-grid-plus/shared/hooks/useSchemeManager.js +648 -0
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +76 -0
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.js +276 -0
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.d.ts +114 -0
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.js +615 -0
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.d.ts +100 -0
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.js +335 -0
- package/dist/cjs/ag-grid-plus/storage/index.d.ts +8 -0
- package/dist/cjs/ag-grid-plus/storage/index.js +49 -0
- package/dist/cjs/ag-grid-plus/storage/types.d.ts +144 -0
- package/dist/cjs/ag-grid-plus/storage/types.js +5 -0
- package/dist/cjs/ag-grid-plus/types.d.ts +310 -0
- package/dist/cjs/ag-grid-plus/types.js +5 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.d.ts +95 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +265 -0
- package/dist/cjs/ag-grid-plus/utils/constants.d.ts +41 -0
- package/dist/cjs/ag-grid-plus/utils/constants.js +56 -0
- package/dist/cjs/ag-grid-plus/utils/logger.d.ts +34 -0
- package/dist/cjs/ag-grid-plus/utils/logger.js +119 -0
- package/dist/cjs/ag-grid-plus/utils/sanitize.d.ts +15 -0
- package/dist/cjs/ag-grid-plus/utils/sanitize.js +39 -0
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +84 -0
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +410 -206
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +30 -5
- package/dist/esm/ag-grid-plus/context/gridContext.js +6 -1
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.d.ts +36 -0
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.js +137 -0
- package/dist/esm/ag-grid-plus/errors/index.d.ts +3 -0
- package/dist/esm/ag-grid-plus/errors/index.js +2 -0
- package/dist/esm/ag-grid-plus/errors/types.d.ts +71 -0
- package/dist/esm/ag-grid-plus/errors/types.js +135 -0
- package/dist/esm/ag-grid-plus/hooks/index.d.ts +7 -0
- package/dist/esm/ag-grid-plus/hooks/index.js +10 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.d.ts +88 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.js +217 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.d.ts +91 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.js +225 -0
- package/dist/esm/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +1 -8
- package/dist/esm/ag-grid-plus/hooks/useGridState.d.ts +153 -0
- package/dist/esm/ag-grid-plus/hooks/useGridState.js +258 -0
- package/dist/esm/ag-grid-plus/index.d.ts +5 -0
- package/dist/esm/ag-grid-plus/index.js +6 -1
- package/dist/esm/ag-grid-plus/interface.d.ts +37 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +21 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +572 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +86 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/index.d.ts +5 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/index.js +5 -0
- package/dist/esm/ag-grid-plus/querySchemes/constants.d.ts +17 -0
- package/dist/esm/ag-grid-plus/querySchemes/constants.js +24 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +10 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +60 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +6 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +537 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.d.ts +7 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.js +27 -0
- package/dist/esm/ag-grid-plus/querySchemes/index.d.ts +11 -0
- package/dist/esm/ag-grid-plus/querySchemes/index.js +20 -0
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +44 -0
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +256 -0
- package/dist/esm/ag-grid-plus/querySchemes/types.d.ts +143 -0
- package/dist/esm/ag-grid-plus/querySchemes/types.js +1 -0
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.d.ts +36 -0
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.js +144 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.d.ts +16 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.js +334 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.less +35 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.d.ts +20 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.js +281 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.less +39 -0
- package/dist/esm/ag-grid-plus/schemes/components/index.d.ts +4 -0
- package/dist/esm/ag-grid-plus/schemes/components/index.js +2 -0
- package/dist/esm/ag-grid-plus/schemes/constants.d.ts +23 -0
- package/dist/esm/ag-grid-plus/schemes/constants.js +33 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +6 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.js +537 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.d.ts +7 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.js +27 -0
- package/dist/esm/ag-grid-plus/schemes/index.d.ts +16 -0
- package/dist/esm/ag-grid-plus/schemes/index.js +25 -0
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +64 -0
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.js +363 -0
- package/dist/esm/ag-grid-plus/schemes/types.d.ts +126 -0
- package/dist/esm/ag-grid-plus/schemes/types.js +1 -0
- package/dist/esm/ag-grid-plus/schemes/utils/validator.d.ts +27 -0
- package/dist/esm/ag-grid-plus/schemes/utils/validator.js +104 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.d.ts +17 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +946 -0
- package/dist/esm/ag-grid-plus/setting/index.d.ts +1 -1
- package/dist/esm/ag-grid-plus/setting/index.js +69 -107
- package/dist/esm/ag-grid-plus/shared/hooks/useSchemeManager.d.ts +66 -0
- package/dist/esm/ag-grid-plus/shared/hooks/useSchemeManager.js +643 -0
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +76 -0
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.js +273 -0
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.d.ts +114 -0
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.js +609 -0
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.d.ts +100 -0
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.js +321 -0
- package/dist/esm/ag-grid-plus/storage/index.d.ts +8 -0
- package/dist/esm/ag-grid-plus/storage/index.js +9 -0
- package/dist/esm/ag-grid-plus/storage/types.d.ts +144 -0
- package/dist/esm/ag-grid-plus/storage/types.js +1 -0
- package/dist/esm/ag-grid-plus/types.d.ts +310 -0
- package/dist/esm/ag-grid-plus/types.js +1 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.d.ts +95 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +251 -0
- package/dist/esm/ag-grid-plus/utils/constants.d.ts +41 -0
- package/dist/esm/ag-grid-plus/utils/constants.js +50 -0
- package/dist/esm/ag-grid-plus/utils/logger.d.ts +34 -0
- package/dist/esm/ag-grid-plus/utils/logger.js +114 -0
- package/dist/esm/ag-grid-plus/utils/sanitize.d.ts +15 -0
- package/dist/esm/ag-grid-plus/utils/sanitize.js +32 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +8 -2
- package/dist/esm/standardFormDialog/useStandardFormSchema.d.ts +1 -1
- package/dist/esm/standardFormDialog/withStandardForm.d.ts +2 -2
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
/**
|
|
14
|
+
* 方案同步管理器
|
|
15
|
+
* 负责所有与后端的数据同步操作
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 默认配置
|
|
20
|
+
*/
|
|
21
|
+
var DEFAULT_CONFIG = {
|
|
22
|
+
getApiPath: '/api/v1/ag-grid-plus/schemes',
|
|
23
|
+
syncApiPath: '/api/v1/ag-grid-plus/schemes',
|
|
24
|
+
autoSaveDelay: 3000,
|
|
25
|
+
backgroundSyncInterval: 300000,
|
|
26
|
+
// 5分钟
|
|
27
|
+
enableAutoSave: true,
|
|
28
|
+
enableBackgroundSync: true,
|
|
29
|
+
conflictResolution: 'client',
|
|
30
|
+
requestTimeout: 30000,
|
|
31
|
+
maxRetries: 3
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 方案同步管理器类
|
|
36
|
+
*/
|
|
37
|
+
export var SchemeSyncManager = /*#__PURE__*/function () {
|
|
38
|
+
function SchemeSyncManager(config) {
|
|
39
|
+
var _this = this;
|
|
40
|
+
var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
41
|
+
_classCallCheck(this, SchemeSyncManager);
|
|
42
|
+
_defineProperty(this, "config", void 0);
|
|
43
|
+
_defineProperty(this, "events", void 0);
|
|
44
|
+
// 数据存储
|
|
45
|
+
_defineProperty(this, "allData", void 0);
|
|
46
|
+
// 同步状态
|
|
47
|
+
_defineProperty(this, "lastSyncTime", 0);
|
|
48
|
+
_defineProperty(this, "syncing", false);
|
|
49
|
+
_defineProperty(this, "initialized", false);
|
|
50
|
+
// 脏数据跟踪
|
|
51
|
+
_defineProperty(this, "dirtyGrids", new Map());
|
|
52
|
+
// 定时器
|
|
53
|
+
_defineProperty(this, "autoSaveTimer", void 0);
|
|
54
|
+
_defineProperty(this, "backgroundSyncTimer", void 0);
|
|
55
|
+
/**
|
|
56
|
+
* 页面卸载前同步
|
|
57
|
+
*/
|
|
58
|
+
_defineProperty(this, "handleBeforeUnload", function () {
|
|
59
|
+
if (_this.hasDirtyData()) {
|
|
60
|
+
// 使用 Beacon API 发送数据(不阻塞页面卸载)
|
|
61
|
+
var requestData = {
|
|
62
|
+
clientSyncTime: _this.lastSyncTime,
|
|
63
|
+
columnSchemes: _this.allData.columnSchemes,
|
|
64
|
+
querySchemes: _this.allData.querySchemes,
|
|
65
|
+
currentSchemes: _this.allData.currentSchemes
|
|
66
|
+
};
|
|
67
|
+
var blob = new Blob([JSON.stringify(requestData)], {
|
|
68
|
+
type: 'application/json'
|
|
69
|
+
});
|
|
70
|
+
if (navigator.sendBeacon) {
|
|
71
|
+
navigator.sendBeacon(_this.getSyncApiUrl(), blob);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
this.config = _objectSpread(_objectSpread({}, DEFAULT_CONFIG), config);
|
|
76
|
+
this.events = events;
|
|
77
|
+
|
|
78
|
+
// 初始化空数据
|
|
79
|
+
this.allData = {
|
|
80
|
+
columnSchemes: {},
|
|
81
|
+
querySchemes: {},
|
|
82
|
+
currentSchemes: {},
|
|
83
|
+
syncTime: 0,
|
|
84
|
+
version: 1
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// 页面卸载前同步
|
|
88
|
+
if (typeof window !== 'undefined') {
|
|
89
|
+
window.addEventListener('beforeunload', this.handleBeforeUnload);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 获取方案的完整 API URL (GET请求)
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
_createClass(SchemeSyncManager, [{
|
|
98
|
+
key: "getGetApiUrl",
|
|
99
|
+
value: function getGetApiUrl() {
|
|
100
|
+
return "".concat(this.config.apiBaseUrl).concat(this.config.getApiPath);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 同步方案的完整 API URL (PUT请求)
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
}, {
|
|
108
|
+
key: "getSyncApiUrl",
|
|
109
|
+
value: function getSyncApiUrl() {
|
|
110
|
+
return "".concat(this.config.apiBaseUrl).concat(this.config.syncApiPath);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 初始化:从服务器加载所有数据
|
|
115
|
+
*/
|
|
116
|
+
}, {
|
|
117
|
+
key: "initialize",
|
|
118
|
+
value: (function () {
|
|
119
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
120
|
+
var response, data;
|
|
121
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
122
|
+
while (1) switch (_context.prev = _context.next) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (!this.initialized) {
|
|
125
|
+
_context.next = 3;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
console.warn('[SchemeSyncManager] 已经初始化,跳过重复初始化');
|
|
129
|
+
return _context.abrupt("return");
|
|
130
|
+
case 3:
|
|
131
|
+
_context.prev = 3;
|
|
132
|
+
_context.next = 6;
|
|
133
|
+
return this.fetchWithRetry(this.getGetApiUrl(), {
|
|
134
|
+
method: 'GET',
|
|
135
|
+
headers: {
|
|
136
|
+
'Content-Type': 'application/json'
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
case 6:
|
|
140
|
+
response = _context.sent;
|
|
141
|
+
_context.next = 9;
|
|
142
|
+
return response.json();
|
|
143
|
+
case 9:
|
|
144
|
+
data = _context.sent;
|
|
145
|
+
if (data.success) {
|
|
146
|
+
_context.next = 12;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
throw new Error('初始化失败:服务器返回错误');
|
|
150
|
+
case 12:
|
|
151
|
+
this.allData = data.data;
|
|
152
|
+
this.lastSyncTime = data.data.syncTime;
|
|
153
|
+
this.initialized = true;
|
|
154
|
+
|
|
155
|
+
// 启动后台同步
|
|
156
|
+
if (this.config.enableBackgroundSync) {
|
|
157
|
+
this.startBackgroundSync();
|
|
158
|
+
}
|
|
159
|
+
console.log('[SchemeSyncManager] 初始化成功,加载数据:', {
|
|
160
|
+
columnSchemes: Object.keys(this.allData.columnSchemes).length,
|
|
161
|
+
querySchemes: Object.keys(this.allData.querySchemes).length,
|
|
162
|
+
syncTime: new Date(this.lastSyncTime).toISOString()
|
|
163
|
+
});
|
|
164
|
+
_context.next = 23;
|
|
165
|
+
break;
|
|
166
|
+
case 19:
|
|
167
|
+
_context.prev = 19;
|
|
168
|
+
_context.t0 = _context["catch"](3);
|
|
169
|
+
console.error('[SchemeSyncManager] 初始化失败:', _context.t0);
|
|
170
|
+
throw _context.t0;
|
|
171
|
+
case 23:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context.stop();
|
|
174
|
+
}
|
|
175
|
+
}, _callee, this, [[3, 19]]);
|
|
176
|
+
}));
|
|
177
|
+
function initialize() {
|
|
178
|
+
return _initialize.apply(this, arguments);
|
|
179
|
+
}
|
|
180
|
+
return initialize;
|
|
181
|
+
}()
|
|
182
|
+
/**
|
|
183
|
+
* 销毁管理器
|
|
184
|
+
*/
|
|
185
|
+
)
|
|
186
|
+
}, {
|
|
187
|
+
key: "destroy",
|
|
188
|
+
value: function destroy() {
|
|
189
|
+
// 停止所有定时器
|
|
190
|
+
if (this.autoSaveTimer) {
|
|
191
|
+
clearTimeout(this.autoSaveTimer);
|
|
192
|
+
}
|
|
193
|
+
if (this.backgroundSyncTimer) {
|
|
194
|
+
clearInterval(this.backgroundSyncTimer);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// 移除事件监听
|
|
198
|
+
if (typeof window !== 'undefined') {
|
|
199
|
+
window.removeEventListener('beforeunload', this.handleBeforeUnload);
|
|
200
|
+
}
|
|
201
|
+
this.initialized = false;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 获取列方案数据
|
|
206
|
+
*/
|
|
207
|
+
}, {
|
|
208
|
+
key: "getColumnSchemes",
|
|
209
|
+
value: function getColumnSchemes(gridId) {
|
|
210
|
+
return this.allData.columnSchemes[gridId] || [];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 保存列方案数据
|
|
215
|
+
*/
|
|
216
|
+
}, {
|
|
217
|
+
key: "saveColumnSchemes",
|
|
218
|
+
value: function saveColumnSchemes(gridId, schemes) {
|
|
219
|
+
this.allData.columnSchemes[gridId] = schemes;
|
|
220
|
+
this.markDirty(gridId, 'column');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 获取查询方案数据
|
|
225
|
+
*/
|
|
226
|
+
}, {
|
|
227
|
+
key: "getQuerySchemes",
|
|
228
|
+
value: function getQuerySchemes(gridId) {
|
|
229
|
+
return this.allData.querySchemes[gridId] || [];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 保存查询方案数据
|
|
234
|
+
*/
|
|
235
|
+
}, {
|
|
236
|
+
key: "saveQuerySchemes",
|
|
237
|
+
value: function saveQuerySchemes(gridId, schemes) {
|
|
238
|
+
this.allData.querySchemes[gridId] = schemes;
|
|
239
|
+
this.markDirty(gridId, 'query');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 获取当前方案ID
|
|
244
|
+
*/
|
|
245
|
+
}, {
|
|
246
|
+
key: "getCurrentSchemeId",
|
|
247
|
+
value: function getCurrentSchemeId(gridId, type) {
|
|
248
|
+
var current = this.allData.currentSchemes[gridId];
|
|
249
|
+
if (!current) return null;
|
|
250
|
+
return type === 'column' ? current.columnSchemeId || null : current.querySchemeId || null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* 保存当前方案ID
|
|
255
|
+
*/
|
|
256
|
+
}, {
|
|
257
|
+
key: "saveCurrentSchemeId",
|
|
258
|
+
value: function saveCurrentSchemeId(gridId, type, schemeId) {
|
|
259
|
+
if (!this.allData.currentSchemes[gridId]) {
|
|
260
|
+
this.allData.currentSchemes[gridId] = {};
|
|
261
|
+
}
|
|
262
|
+
if (type === 'column') {
|
|
263
|
+
this.allData.currentSchemes[gridId].columnSchemeId = schemeId;
|
|
264
|
+
} else {
|
|
265
|
+
this.allData.currentSchemes[gridId].querySchemeId = schemeId;
|
|
266
|
+
}
|
|
267
|
+
this.markDirty(gridId, 'current');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* 标记数据为脏数据
|
|
272
|
+
*/
|
|
273
|
+
}, {
|
|
274
|
+
key: "markDirty",
|
|
275
|
+
value: function markDirty(gridId, type) {
|
|
276
|
+
if (!this.dirtyGrids.has(gridId)) {
|
|
277
|
+
this.dirtyGrids.set(gridId, new Set());
|
|
278
|
+
}
|
|
279
|
+
this.dirtyGrids.get(gridId).add(type);
|
|
280
|
+
|
|
281
|
+
// 触发自动保存
|
|
282
|
+
if (this.config.enableAutoSave) {
|
|
283
|
+
this.scheduleAutoSave();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* 检查是否有未同步的数据
|
|
289
|
+
*/
|
|
290
|
+
}, {
|
|
291
|
+
key: "hasDirtyData",
|
|
292
|
+
value: function hasDirtyData() {
|
|
293
|
+
return this.dirtyGrids.size > 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* 获取所有脏数据的 gridId 列表
|
|
298
|
+
*/
|
|
299
|
+
}, {
|
|
300
|
+
key: "getDirtyGridIds",
|
|
301
|
+
value: function getDirtyGridIds() {
|
|
302
|
+
return Array.from(this.dirtyGrids.keys());
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* 调度自动保存
|
|
307
|
+
*/
|
|
308
|
+
}, {
|
|
309
|
+
key: "scheduleAutoSave",
|
|
310
|
+
value: function scheduleAutoSave() {
|
|
311
|
+
var _this2 = this;
|
|
312
|
+
if (this.autoSaveTimer) {
|
|
313
|
+
clearTimeout(this.autoSaveTimer);
|
|
314
|
+
}
|
|
315
|
+
this.autoSaveTimer = setTimeout(function () {
|
|
316
|
+
var _this2$events$onAutoS, _this2$events;
|
|
317
|
+
(_this2$events$onAutoS = (_this2$events = _this2.events).onAutoSave) === null || _this2$events$onAutoS === void 0 || _this2$events$onAutoS.call(_this2$events);
|
|
318
|
+
_this2.syncNow().catch(function (error) {
|
|
319
|
+
console.error('[SchemeSyncManager] 自动保存失败:', error);
|
|
320
|
+
});
|
|
321
|
+
}, this.config.autoSaveDelay);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* 启动后台同步
|
|
326
|
+
*/
|
|
327
|
+
}, {
|
|
328
|
+
key: "startBackgroundSync",
|
|
329
|
+
value: function startBackgroundSync() {
|
|
330
|
+
var _this3 = this;
|
|
331
|
+
if (this.backgroundSyncTimer) {
|
|
332
|
+
clearInterval(this.backgroundSyncTimer);
|
|
333
|
+
}
|
|
334
|
+
this.backgroundSyncTimer = setInterval(function () {
|
|
335
|
+
if (_this3.hasDirtyData()) {
|
|
336
|
+
_this3.syncNow().catch(function (error) {
|
|
337
|
+
console.error('[SchemeSyncManager] 后台同步失败:', error);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}, this.config.backgroundSyncInterval);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* 立即同步数据到服务器
|
|
345
|
+
*/
|
|
346
|
+
}, {
|
|
347
|
+
key: "syncNow",
|
|
348
|
+
value: (function () {
|
|
349
|
+
var _syncNow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
350
|
+
var _this$events$onSyncSt,
|
|
351
|
+
_this$events,
|
|
352
|
+
_this4 = this;
|
|
353
|
+
var _this$events$onSyncSu, _this$events3, _result$conflicts, requestData, dirtyColumnGrids, dirtyQueryGrids, dirtyCurrentGrids, response, result, _this$events$onConfli, _this$events2, _this$events$onSyncEr, _this$events4;
|
|
354
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
355
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
356
|
+
case 0:
|
|
357
|
+
if (!this.syncing) {
|
|
358
|
+
_context2.next = 3;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
console.log('[SchemeSyncManager] 正在同步中,跳过重复请求');
|
|
362
|
+
return _context2.abrupt("return");
|
|
363
|
+
case 3:
|
|
364
|
+
if (this.hasDirtyData()) {
|
|
365
|
+
_context2.next = 6;
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
console.log('[SchemeSyncManager] 没有需要同步的数据');
|
|
369
|
+
return _context2.abrupt("return");
|
|
370
|
+
case 6:
|
|
371
|
+
this.syncing = true;
|
|
372
|
+
(_this$events$onSyncSt = (_this$events = this.events).onSyncStart) === null || _this$events$onSyncSt === void 0 || _this$events$onSyncSt.call(_this$events);
|
|
373
|
+
_context2.prev = 8;
|
|
374
|
+
// 构建同步请求数据
|
|
375
|
+
requestData = {
|
|
376
|
+
clientSyncTime: this.lastSyncTime
|
|
377
|
+
};
|
|
378
|
+
dirtyColumnGrids = new Set();
|
|
379
|
+
dirtyQueryGrids = new Set();
|
|
380
|
+
dirtyCurrentGrids = new Set();
|
|
381
|
+
this.dirtyGrids.forEach(function (types, gridId) {
|
|
382
|
+
if (types.has('column')) dirtyColumnGrids.add(gridId);
|
|
383
|
+
if (types.has('query')) dirtyQueryGrids.add(gridId);
|
|
384
|
+
if (types.has('current')) dirtyCurrentGrids.add(gridId);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// 添加列方案数据
|
|
388
|
+
if (dirtyColumnGrids.size > 0) {
|
|
389
|
+
requestData.columnSchemes = {};
|
|
390
|
+
dirtyColumnGrids.forEach(function (gridId) {
|
|
391
|
+
requestData.columnSchemes[gridId] = _this4.allData.columnSchemes[gridId] || [];
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// 添加查询方案数据
|
|
396
|
+
if (dirtyQueryGrids.size > 0) {
|
|
397
|
+
requestData.querySchemes = {};
|
|
398
|
+
dirtyQueryGrids.forEach(function (gridId) {
|
|
399
|
+
requestData.querySchemes[gridId] = _this4.allData.querySchemes[gridId] || [];
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// 添加当前方案数据
|
|
404
|
+
if (dirtyCurrentGrids.size > 0) {
|
|
405
|
+
requestData.currentSchemes = {};
|
|
406
|
+
dirtyCurrentGrids.forEach(function (gridId) {
|
|
407
|
+
requestData.currentSchemes[gridId] = _this4.allData.currentSchemes[gridId] || {};
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// 发送同步请求
|
|
412
|
+
_context2.next = 19;
|
|
413
|
+
return this.fetchWithRetry(this.getSyncApiUrl(), {
|
|
414
|
+
method: 'PUT',
|
|
415
|
+
headers: {
|
|
416
|
+
'Content-Type': 'application/json'
|
|
417
|
+
},
|
|
418
|
+
body: JSON.stringify(requestData)
|
|
419
|
+
});
|
|
420
|
+
case 19:
|
|
421
|
+
response = _context2.sent;
|
|
422
|
+
_context2.next = 22;
|
|
423
|
+
return response.json();
|
|
424
|
+
case 22:
|
|
425
|
+
result = _context2.sent;
|
|
426
|
+
if (result.success) {
|
|
427
|
+
_context2.next = 25;
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
throw new Error(result.error || '同步失败');
|
|
431
|
+
case 25:
|
|
432
|
+
// 处理冲突
|
|
433
|
+
if (result.conflicts && result.conflicts.length > 0) {
|
|
434
|
+
this.handleConflicts(result.conflicts);
|
|
435
|
+
(_this$events$onConfli = (_this$events2 = this.events).onConflict) === null || _this$events$onConfli === void 0 || _this$events$onConfli.call(_this$events2, result.conflicts);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// 更新同步时间
|
|
439
|
+
if (result.syncTime) {
|
|
440
|
+
this.lastSyncTime = result.syncTime;
|
|
441
|
+
this.allData.syncTime = result.syncTime;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// 清除脏数据标记
|
|
445
|
+
this.dirtyGrids.clear();
|
|
446
|
+
(_this$events$onSyncSu = (_this$events3 = this.events).onSyncSuccess) === null || _this$events$onSyncSu === void 0 || _this$events$onSyncSu.call(_this$events3, this.lastSyncTime);
|
|
447
|
+
console.log('[SchemeSyncManager] 同步成功:', {
|
|
448
|
+
syncTime: new Date(this.lastSyncTime).toISOString(),
|
|
449
|
+
conflicts: ((_result$conflicts = result.conflicts) === null || _result$conflicts === void 0 ? void 0 : _result$conflicts.length) || 0
|
|
450
|
+
});
|
|
451
|
+
_context2.next = 37;
|
|
452
|
+
break;
|
|
453
|
+
case 32:
|
|
454
|
+
_context2.prev = 32;
|
|
455
|
+
_context2.t0 = _context2["catch"](8);
|
|
456
|
+
console.error('[SchemeSyncManager] 同步失败:', _context2.t0);
|
|
457
|
+
(_this$events$onSyncEr = (_this$events4 = this.events).onSyncError) === null || _this$events$onSyncEr === void 0 || _this$events$onSyncEr.call(_this$events4, _context2.t0);
|
|
458
|
+
throw _context2.t0;
|
|
459
|
+
case 37:
|
|
460
|
+
_context2.prev = 37;
|
|
461
|
+
this.syncing = false;
|
|
462
|
+
return _context2.finish(37);
|
|
463
|
+
case 40:
|
|
464
|
+
case "end":
|
|
465
|
+
return _context2.stop();
|
|
466
|
+
}
|
|
467
|
+
}, _callee2, this, [[8, 32, 37, 40]]);
|
|
468
|
+
}));
|
|
469
|
+
function syncNow() {
|
|
470
|
+
return _syncNow.apply(this, arguments);
|
|
471
|
+
}
|
|
472
|
+
return syncNow;
|
|
473
|
+
}()
|
|
474
|
+
/**
|
|
475
|
+
* 处理冲突
|
|
476
|
+
*/
|
|
477
|
+
)
|
|
478
|
+
}, {
|
|
479
|
+
key: "handleConflicts",
|
|
480
|
+
value: function handleConflicts(conflicts) {
|
|
481
|
+
var _this5 = this;
|
|
482
|
+
conflicts.forEach(function (conflict) {
|
|
483
|
+
switch (_this5.config.conflictResolution) {
|
|
484
|
+
case 'server':
|
|
485
|
+
// 使用服务器版本
|
|
486
|
+
_this5.applyServerVersion(conflict);
|
|
487
|
+
break;
|
|
488
|
+
case 'client':
|
|
489
|
+
// 保持客户端版本(默认行为)
|
|
490
|
+
console.warn('[SchemeSyncManager] 冲突检测到,保持客户端版本:', conflict);
|
|
491
|
+
break;
|
|
492
|
+
case 'manual':
|
|
493
|
+
// 需要用户手动解决
|
|
494
|
+
console.warn('[SchemeSyncManager] 冲突需要手动解决:', conflict);
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* 应用服务器版本
|
|
502
|
+
*/
|
|
503
|
+
}, {
|
|
504
|
+
key: "applyServerVersion",
|
|
505
|
+
value: function applyServerVersion(conflict) {
|
|
506
|
+
var gridId = conflict.gridId,
|
|
507
|
+
type = conflict.type,
|
|
508
|
+
serverVersion = conflict.serverVersion;
|
|
509
|
+
switch (type) {
|
|
510
|
+
case 'column':
|
|
511
|
+
if (Array.isArray(serverVersion)) {
|
|
512
|
+
this.allData.columnSchemes[gridId] = serverVersion;
|
|
513
|
+
}
|
|
514
|
+
break;
|
|
515
|
+
case 'query':
|
|
516
|
+
if (Array.isArray(serverVersion)) {
|
|
517
|
+
this.allData.querySchemes[gridId] = serverVersion;
|
|
518
|
+
}
|
|
519
|
+
break;
|
|
520
|
+
case 'current':
|
|
521
|
+
this.allData.currentSchemes[gridId] = serverVersion;
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
console.log('[SchemeSyncManager] 已应用服务器版本:', {
|
|
525
|
+
gridId: gridId,
|
|
526
|
+
type: type
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
}, {
|
|
530
|
+
key: "fetchWithRetry",
|
|
531
|
+
value: (
|
|
532
|
+
/**
|
|
533
|
+
* 带重试的 fetch 请求
|
|
534
|
+
*/
|
|
535
|
+
function () {
|
|
536
|
+
var _fetchWithRetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(url, options) {
|
|
537
|
+
var retries,
|
|
538
|
+
controller,
|
|
539
|
+
timeoutId,
|
|
540
|
+
response,
|
|
541
|
+
_args3 = arguments;
|
|
542
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
543
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
544
|
+
case 0:
|
|
545
|
+
retries = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : this.config.maxRetries;
|
|
546
|
+
_context3.prev = 1;
|
|
547
|
+
controller = new AbortController();
|
|
548
|
+
timeoutId = setTimeout(function () {
|
|
549
|
+
return controller.abort();
|
|
550
|
+
}, this.config.requestTimeout);
|
|
551
|
+
_context3.next = 6;
|
|
552
|
+
return fetch(url, _objectSpread(_objectSpread({}, options), {}, {
|
|
553
|
+
signal: controller.signal
|
|
554
|
+
}));
|
|
555
|
+
case 6:
|
|
556
|
+
response = _context3.sent;
|
|
557
|
+
clearTimeout(timeoutId);
|
|
558
|
+
if (response.ok) {
|
|
559
|
+
_context3.next = 10;
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
throw new Error("HTTP ".concat(response.status, ": ").concat(response.statusText));
|
|
563
|
+
case 10:
|
|
564
|
+
return _context3.abrupt("return", response);
|
|
565
|
+
case 13:
|
|
566
|
+
_context3.prev = 13;
|
|
567
|
+
_context3.t0 = _context3["catch"](1);
|
|
568
|
+
if (!(retries > 0)) {
|
|
569
|
+
_context3.next = 20;
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
console.warn("[SchemeSyncManager] \u8BF7\u6C42\u5931\u8D25\uFF0C\u91CD\u8BD5\u4E2D... (\u5269\u4F59 ".concat(retries, " \u6B21)"), _context3.t0);
|
|
573
|
+
_context3.next = 19;
|
|
574
|
+
return new Promise(function (resolve) {
|
|
575
|
+
return setTimeout(resolve, 1000);
|
|
576
|
+
});
|
|
577
|
+
case 19:
|
|
578
|
+
return _context3.abrupt("return", this.fetchWithRetry(url, options, retries - 1));
|
|
579
|
+
case 20:
|
|
580
|
+
throw _context3.t0;
|
|
581
|
+
case 21:
|
|
582
|
+
case "end":
|
|
583
|
+
return _context3.stop();
|
|
584
|
+
}
|
|
585
|
+
}, _callee3, this, [[1, 13]]);
|
|
586
|
+
}));
|
|
587
|
+
function fetchWithRetry(_x, _x2) {
|
|
588
|
+
return _fetchWithRetry.apply(this, arguments);
|
|
589
|
+
}
|
|
590
|
+
return fetchWithRetry;
|
|
591
|
+
}()
|
|
592
|
+
/**
|
|
593
|
+
* 获取同步状态信息
|
|
594
|
+
*/
|
|
595
|
+
)
|
|
596
|
+
}, {
|
|
597
|
+
key: "getSyncStatus",
|
|
598
|
+
value: function getSyncStatus() {
|
|
599
|
+
return {
|
|
600
|
+
initialized: this.initialized,
|
|
601
|
+
syncing: this.syncing,
|
|
602
|
+
lastSyncTime: this.lastSyncTime,
|
|
603
|
+
hasDirtyData: this.hasDirtyData(),
|
|
604
|
+
dirtyGrids: this.getDirtyGridIds()
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
}]);
|
|
608
|
+
return SchemeSyncManager;
|
|
609
|
+
}();
|