@antglobal/rlog-sdk 0.0.1755855517-dev.8 → 1.0.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 (127) hide show
  1. package/README.md +192 -432
  2. package/dist/esm/index.d.ts +14 -41
  3. package/dist/esm/index.d.ts.map +1 -1
  4. package/dist/esm/index.js +92 -76
  5. package/dist/esm/lib/api.d.ts +10 -0
  6. package/dist/esm/lib/api.d.ts.map +1 -1
  7. package/dist/esm/lib/api.js +58 -35
  8. package/dist/esm/lib/config.d.ts +14 -16
  9. package/dist/esm/lib/config.d.ts.map +1 -1
  10. package/dist/esm/lib/config.js +61 -33
  11. package/dist/esm/lib/constants.d.ts +89 -0
  12. package/dist/esm/lib/constants.d.ts.map +1 -0
  13. package/dist/esm/lib/constants.js +145 -0
  14. package/dist/esm/lib/drive/indexeddb-adapt.d.ts +12 -0
  15. package/dist/esm/lib/drive/indexeddb-adapt.d.ts.map +1 -1
  16. package/dist/esm/lib/drive/indexeddb-adapt.js +190 -20
  17. package/dist/esm/lib/drive/localstorage-adapt.d.ts +12 -0
  18. package/dist/esm/lib/drive/localstorage-adapt.d.ts.map +1 -1
  19. package/dist/esm/lib/drive/localstorage-adapt.js +179 -36
  20. package/dist/esm/lib/drive/memory-adapt.d.ts +10 -2
  21. package/dist/esm/lib/drive/memory-adapt.d.ts.map +1 -1
  22. package/dist/esm/lib/drive/memory-adapt.js +118 -26
  23. package/dist/esm/lib/drive/safe-storage.d.ts +24 -0
  24. package/dist/esm/lib/drive/safe-storage.d.ts.map +1 -0
  25. package/dist/esm/lib/drive/safe-storage.js +96 -0
  26. package/dist/esm/lib/drive/storage-interface.d.ts +20 -0
  27. package/dist/esm/lib/drive/storage-interface.d.ts.map +1 -1
  28. package/dist/esm/lib/error-trigger.d.ts +73 -0
  29. package/dist/esm/lib/error-trigger.d.ts.map +1 -0
  30. package/dist/esm/lib/error-trigger.js +162 -0
  31. package/dist/esm/lib/error.d.ts +9 -0
  32. package/dist/esm/lib/error.d.ts.map +1 -1
  33. package/dist/esm/lib/error.js +70 -118
  34. package/dist/esm/lib/init.d.ts +0 -4
  35. package/dist/esm/lib/init.d.ts.map +1 -1
  36. package/dist/esm/lib/init.js +148 -47
  37. package/dist/esm/lib/logger.d.ts +27 -0
  38. package/dist/esm/lib/logger.d.ts.map +1 -0
  39. package/dist/esm/lib/logger.js +79 -0
  40. package/dist/esm/lib/net.d.ts +11 -0
  41. package/dist/esm/lib/net.d.ts.map +1 -1
  42. package/dist/esm/lib/net.js +264 -116
  43. package/dist/esm/lib/request.d.ts.map +1 -1
  44. package/dist/esm/lib/request.js +2 -2
  45. package/dist/esm/lib/router-monitor.d.ts.map +1 -1
  46. package/dist/esm/lib/router-monitor.js +135 -49
  47. package/dist/esm/lib/rrweb.d.ts.map +1 -1
  48. package/dist/esm/lib/rrweb.js +31 -24
  49. package/dist/esm/lib/storage-manager.d.ts +12 -0
  50. package/dist/esm/lib/storage-manager.d.ts.map +1 -1
  51. package/dist/esm/lib/storage-manager.js +129 -46
  52. package/dist/esm/lib/upload-worker-manager.d.ts +47 -0
  53. package/dist/esm/lib/upload-worker-manager.d.ts.map +1 -0
  54. package/dist/esm/lib/upload-worker-manager.js +559 -0
  55. package/dist/esm/lib/upload-worker.d.ts +58 -0
  56. package/dist/esm/lib/upload-worker.d.ts.map +1 -0
  57. package/dist/esm/lib/upload-worker.js +28 -0
  58. package/dist/esm/lib/uploader.d.ts +43 -0
  59. package/dist/esm/lib/uploader.d.ts.map +1 -1
  60. package/dist/esm/lib/uploader.js +464 -102
  61. package/dist/esm/lib/utils.d.ts +75 -0
  62. package/dist/esm/lib/utils.d.ts.map +1 -1
  63. package/dist/esm/lib/utils.js +268 -5
  64. package/dist/lib/index.d.ts +14 -41
  65. package/dist/lib/index.d.ts.map +1 -1
  66. package/dist/lib/index.js +81 -63
  67. package/dist/lib/lib/api.d.ts +10 -0
  68. package/dist/lib/lib/api.d.ts.map +1 -1
  69. package/dist/lib/lib/api.js +59 -35
  70. package/dist/lib/lib/config.d.ts +14 -16
  71. package/dist/lib/lib/config.d.ts.map +1 -1
  72. package/dist/lib/lib/config.js +63 -33
  73. package/dist/lib/lib/constants.d.ts +89 -0
  74. package/dist/lib/lib/constants.d.ts.map +1 -0
  75. package/dist/lib/lib/constants.js +151 -0
  76. package/dist/lib/lib/drive/indexeddb-adapt.d.ts +12 -0
  77. package/dist/lib/lib/drive/indexeddb-adapt.d.ts.map +1 -1
  78. package/dist/lib/lib/drive/indexeddb-adapt.js +191 -19
  79. package/dist/lib/lib/drive/localstorage-adapt.d.ts +12 -0
  80. package/dist/lib/lib/drive/localstorage-adapt.d.ts.map +1 -1
  81. package/dist/lib/lib/drive/localstorage-adapt.js +179 -36
  82. package/dist/lib/lib/drive/memory-adapt.d.ts +10 -2
  83. package/dist/lib/lib/drive/memory-adapt.d.ts.map +1 -1
  84. package/dist/lib/lib/drive/memory-adapt.js +117 -26
  85. package/dist/lib/lib/drive/safe-storage.d.ts +24 -0
  86. package/dist/lib/lib/drive/safe-storage.d.ts.map +1 -0
  87. package/dist/lib/lib/drive/safe-storage.js +102 -0
  88. package/dist/lib/lib/drive/storage-interface.d.ts +20 -0
  89. package/dist/lib/lib/drive/storage-interface.d.ts.map +1 -1
  90. package/dist/lib/lib/error-trigger.d.ts +73 -0
  91. package/dist/lib/lib/error-trigger.d.ts.map +1 -0
  92. package/dist/lib/lib/error-trigger.js +167 -0
  93. package/dist/lib/lib/error.d.ts +9 -0
  94. package/dist/lib/lib/error.d.ts.map +1 -1
  95. package/dist/lib/lib/error.js +73 -118
  96. package/dist/lib/lib/init.d.ts +0 -4
  97. package/dist/lib/lib/init.d.ts.map +1 -1
  98. package/dist/lib/lib/init.js +144 -43
  99. package/dist/lib/lib/logger.d.ts +27 -0
  100. package/dist/lib/lib/logger.d.ts.map +1 -0
  101. package/dist/lib/lib/logger.js +84 -0
  102. package/dist/lib/lib/net.d.ts +11 -0
  103. package/dist/lib/lib/net.d.ts.map +1 -1
  104. package/dist/lib/lib/net.js +268 -117
  105. package/dist/lib/lib/request.d.ts.map +1 -1
  106. package/dist/lib/lib/request.js +3 -3
  107. package/dist/lib/lib/router-monitor.d.ts.map +1 -1
  108. package/dist/lib/lib/router-monitor.js +136 -49
  109. package/dist/lib/lib/rrweb.d.ts.map +1 -1
  110. package/dist/lib/lib/rrweb.js +31 -23
  111. package/dist/lib/lib/storage-manager.d.ts +12 -0
  112. package/dist/lib/lib/storage-manager.d.ts.map +1 -1
  113. package/dist/lib/lib/storage-manager.js +130 -46
  114. package/dist/lib/lib/upload-worker-manager.d.ts +47 -0
  115. package/dist/lib/lib/upload-worker-manager.d.ts.map +1 -0
  116. package/dist/lib/lib/upload-worker-manager.js +570 -0
  117. package/dist/lib/lib/upload-worker.d.ts +58 -0
  118. package/dist/lib/lib/upload-worker.d.ts.map +1 -0
  119. package/dist/lib/lib/upload-worker.js +33 -0
  120. package/dist/lib/lib/uploader.d.ts +43 -0
  121. package/dist/lib/lib/uploader.d.ts.map +1 -1
  122. package/dist/lib/lib/uploader.js +468 -101
  123. package/dist/lib/lib/utils.d.ts +75 -0
  124. package/dist/lib/lib/utils.d.ts.map +1 -1
  125. package/dist/lib/lib/utils.js +276 -6
  126. package/dist/rlog-sdk.min.js +1 -1
  127. package/package.json +3 -2
@@ -7,6 +7,9 @@ exports.storage = void 0;
7
7
  var _indexeddbAdapt = require("./drive/indexeddb-adapt");
8
8
  var _localstorageAdapt = require("./drive/localstorage-adapt");
9
9
  var _memoryAdapt = require("./drive/memory-adapt");
10
+ var _logger = _interopRequireDefault(require("./logger"));
11
+ var _constants = require("./constants");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
13
  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); }
11
14
  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; }
12
15
  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); } }
@@ -31,33 +34,31 @@ var StorageManager = /*#__PURE__*/function () {
31
34
  key: "selectAdapter",
32
35
  value: function selectAdapter() {
33
36
  // 优先使用IndexedDB
34
- if (typeof window !== 'undefined' && window.indexedDB) {
35
- try {
36
- // 测试IndexedDB是否可用
37
- var test = indexedDB.open('__rlog_test__', 1);
38
- test.onerror = function () {
39
- throw new Error('IndexedDB blocked');
40
- };
41
- test.onsuccess = function () {
42
- test.result.close();
43
- // 清理测试数据库
44
- indexedDB.deleteDatabase('__rlog_test__');
45
- };
46
- return new _indexeddbAdapt.IndexedDBAdapter();
47
- } catch (e) {
48
- console.warn('IndexedDB不可用,降级使用LocalStorage');
49
- }
50
- }
37
+ // if (typeof window !== 'undefined' && window.indexedDB) {
38
+ // try {
39
+ // // 测试IndexedDB是否可用
40
+ // const test = indexedDB.open('__rlog_test__', 1);
41
+ // test.onerror = () => { throw new Error('IndexedDB blocked'); };
42
+ // test.onsuccess = () => {
43
+ // test.result.close();
44
+ // // 清理测试数据库
45
+ // indexedDB.deleteDatabase('__rlog_test__');
46
+ // };
47
+ // return new IndexedDBAdapter();
48
+ // } catch (e) {
49
+ // logger.warn('IndexedDB不可用,降级使用LocalStorage');
50
+ // }
51
+ // }
51
52
 
52
53
  // 其次使用LocalStorage
53
54
  if (typeof window !== 'undefined' && window.localStorage) {
54
55
  try {
55
- var testKey = '__rlog_storage_test__';
56
+ var testKey = _constants.STORAGE_TEST_KEY;
56
57
  window.localStorage.setItem(testKey, 'test');
57
58
  window.localStorage.removeItem(testKey);
58
59
  return new _localstorageAdapt.LocalStorageAdapter();
59
60
  } catch (e) {
60
- console.warn('LocalStorage不可用,降级使用内存缓存');
61
+ _logger.default.warn('LocalStorage不可用,降级使用内存缓存');
61
62
  }
62
63
  }
63
64
 
@@ -82,7 +83,7 @@ var StorageManager = /*#__PURE__*/function () {
82
83
  newOperation = previousOperation.then(function () {
83
84
  return operation();
84
85
  }).catch(function (error) {
85
- console.error('Storage operation failed:', error);
86
+ _logger.default.error('Storage operation failed:', error);
86
87
  throw error;
87
88
  }).finally(function () {
88
89
  // 清理已完成的操作
@@ -203,7 +204,7 @@ var StorageManager = /*#__PURE__*/function () {
203
204
  if (_this6.adapter.clear) {
204
205
  return _this6.adapter.clear(deviceId);
205
206
  }
206
- console.warn('Storage adapter does not support clear operation');
207
+ _logger.default.warn('Storage adapter does not support clear operation');
207
208
  return Promise.resolve();
208
209
  }));
209
210
  case 1:
@@ -217,9 +218,69 @@ var StorageManager = /*#__PURE__*/function () {
217
218
  }
218
219
  return clear;
219
220
  }()
221
+ /**
222
+ * 按时间范围提取事件(用于 error 模式)
223
+ */
224
+ }, {
225
+ key: "pullByTimeRange",
226
+ value: (function () {
227
+ var _pullByTimeRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(deviceId, startTime, endTime) {
228
+ var _this7 = this;
229
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
230
+ while (1) switch (_context7.prev = _context7.next) {
231
+ case 0:
232
+ return _context7.abrupt("return", this.serialize(deviceId, function () {
233
+ if (_this7.adapter.pullByTimeRange) {
234
+ return _this7.adapter.pullByTimeRange(deviceId, startTime, endTime);
235
+ }
236
+ _logger.default.warn('Storage adapter does not support pullByTimeRange operation');
237
+ return Promise.resolve([]);
238
+ }));
239
+ case 1:
240
+ case "end":
241
+ return _context7.stop();
242
+ }
243
+ }, _callee7, this);
244
+ }));
245
+ function pullByTimeRange(_x12, _x13, _x14) {
246
+ return _pullByTimeRange.apply(this, arguments);
247
+ }
248
+ return pullByTimeRange;
249
+ }()
250
+ /**
251
+ * 按时间范围移除事件(用于 error 模式)
252
+ */
253
+ )
254
+ }, {
255
+ key: "removeByTimeRange",
256
+ value: (function () {
257
+ var _removeByTimeRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(deviceId, sinceTime) {
258
+ var _this8 = this;
259
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
260
+ while (1) switch (_context8.prev = _context8.next) {
261
+ case 0:
262
+ return _context8.abrupt("return", this.serialize(deviceId, function () {
263
+ if (_this8.adapter.removeByTimeRange) {
264
+ return _this8.adapter.removeByTimeRange(deviceId, sinceTime);
265
+ }
266
+ _logger.default.warn('Storage adapter does not support removeByTimeRange operation');
267
+ return Promise.resolve();
268
+ }));
269
+ case 1:
270
+ case "end":
271
+ return _context8.stop();
272
+ }
273
+ }, _callee8, this);
274
+ }));
275
+ function removeByTimeRange(_x15, _x16) {
276
+ return _removeByTimeRange.apply(this, arguments);
277
+ }
278
+ return removeByTimeRange;
279
+ }()
220
280
  /**
221
281
  * 获取当前存储适配器类型
222
282
  */
283
+ )
223
284
  }, {
224
285
  key: "getAdapterType",
225
286
  value: function getAdapterType() {
@@ -233,48 +294,71 @@ var StorageManager = /*#__PURE__*/function () {
233
294
  return 'Unknown';
234
295
  }
235
296
 
297
+ /**
298
+ * 获取存储的事件数量(非破坏性只读操作)
299
+ */
300
+ }, {
301
+ key: "count",
302
+ value: (function () {
303
+ var _count = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(deviceId) {
304
+ var _this9 = this;
305
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
306
+ while (1) switch (_context9.prev = _context9.next) {
307
+ case 0:
308
+ return _context9.abrupt("return", this.serialize(deviceId, function () {
309
+ if (_this9.adapter.count) {
310
+ return _this9.adapter.count(deviceId);
311
+ }
312
+ _logger.default.warn('Storage adapter does not support count operation');
313
+ return Promise.resolve(0);
314
+ }));
315
+ case 1:
316
+ case "end":
317
+ return _context9.stop();
318
+ }
319
+ }, _callee9, this);
320
+ }));
321
+ function count(_x17) {
322
+ return _count.apply(this, arguments);
323
+ }
324
+ return count;
325
+ }()
236
326
  /**
237
327
  * 获取存储状态(调试用)
238
328
  */
329
+ )
239
330
  }, {
240
331
  key: "getStorageState",
241
332
  value: (function () {
242
- var _getStorageState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(deviceId) {
243
- var adapterType, events;
244
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
245
- while (1) switch (_context7.prev = _context7.next) {
333
+ var _getStorageState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(deviceId) {
334
+ var adapterType, eventCount;
335
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
336
+ while (1) switch (_context10.prev = _context10.next) {
246
337
  case 0:
247
338
  adapterType = this.getAdapterType();
248
- _context7.prev = 1;
249
- _context7.next = 4;
250
- return this.pull(deviceId, 10000);
339
+ _context10.prev = 1;
340
+ _context10.next = 4;
341
+ return this.count(deviceId);
251
342
  case 4:
252
- events = _context7.sent;
253
- if (!(events.length > 0)) {
254
- _context7.next = 8;
255
- break;
256
- }
257
- _context7.next = 8;
258
- return this.unshiftBatch(deviceId, events);
259
- case 8:
260
- return _context7.abrupt("return", {
343
+ eventCount = _context10.sent;
344
+ return _context10.abrupt("return", {
261
345
  adapterType: adapterType,
262
- eventCount: events.length
346
+ eventCount: eventCount
263
347
  });
264
- case 11:
265
- _context7.prev = 11;
266
- _context7.t0 = _context7["catch"](1);
267
- return _context7.abrupt("return", {
348
+ case 8:
349
+ _context10.prev = 8;
350
+ _context10.t0 = _context10["catch"](1);
351
+ return _context10.abrupt("return", {
268
352
  adapterType: adapterType,
269
353
  eventCount: -1
270
354
  });
271
- case 14:
355
+ case 11:
272
356
  case "end":
273
- return _context7.stop();
357
+ return _context10.stop();
274
358
  }
275
- }, _callee7, this, [[1, 11]]);
359
+ }, _callee10, this, [[1, 8]]);
276
360
  }));
277
- function getStorageState(_x12) {
361
+ function getStorageState(_x18) {
278
362
  return _getStorageState.apply(this, arguments);
279
363
  }
280
364
  return getStorageState;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Upload Worker 管理器
3
+ *
4
+ * 职责:
5
+ * - Worker 生命周期管理(创建、销毁、降级)
6
+ * - 将 Worker 脚本以 inline Blob 方式加载
7
+ * - 封装 postMessage/onmessage 通信
8
+ * - 处理 Worker 回传的消息,调用对应的主线程逻辑
9
+ * - 提供与现有 uploader.ts 相同的对外 API
10
+ */
11
+ import type { WorkerConfig } from './upload-worker';
12
+ /**
13
+ * 设置 SDK 取消回调(由 init.ts 在启动上传循环前注入)
14
+ */
15
+ export declare function setWorkerCancelCallback(callback: (() => void) | null): void;
16
+ /**
17
+ * 设置 Worker 降级回调
18
+ * @param callback 降级回调函数
19
+ */
20
+ export declare function setWorkerFallbackCallback(callback: (() => void) | null): void;
21
+ /**
22
+ * 尝试初始化 Worker 模式
23
+ * @returns 是否成功启用 Worker 模式
24
+ */
25
+ export declare function initWorkerUpload(serv: string, appId: string): boolean;
26
+ /**
27
+ * 销毁 Worker
28
+ * @param triggerFallback 是否触发降级回调
29
+ */
30
+ export declare function destroyWorker(triggerFallback?: boolean): void;
31
+ /**
32
+ * 是否正在使用 Worker 模式
33
+ */
34
+ export declare function isUsingWorkerMode(): boolean;
35
+ /**
36
+ * 设置错误模式上传状态(Worker 模式)
37
+ */
38
+ export declare function setWorkerErrorModeUploading(uploading: boolean): void;
39
+ /**
40
+ * 设置错误模式上传时间窗口起点(Worker 模式)
41
+ */
42
+ export declare function setWorkerErrorModeWindowStart(startTime: number): void;
43
+ /**
44
+ * 更新 Worker 配置
45
+ */
46
+ export declare function updateWorkerConfig(config: Partial<WorkerConfig>): void;
47
+ //# sourceMappingURL=upload-worker-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-worker-manager.d.ts","sourceRoot":"","sources":["../../../src/lib/upload-worker-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAgC,MAAM,iBAAiB,CAAC;AA+ClF;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAE3E;AA6SD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAE7E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAwCrE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,eAAe,UAAQ,GAAG,IAAI,CA6B3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAQpE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAKtE"}