agora-foundation 3.8.1 → 3.9.0-alpha

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 (91) hide show
  1. package/lib/decorator/log/handler.d.ts +1 -1
  2. package/lib/decorator/log/handler.js +57 -64
  3. package/lib/decorator/log/index.d.ts +26 -1
  4. package/lib/decorator/log/index.js +50 -5
  5. package/lib/decorator/log/log-serializer.d.ts +1 -1
  6. package/lib/decorator/log/log-serializer.js +15 -2
  7. package/lib/decorator/proxy.d.ts +1 -1
  8. package/lib/decorator/proxy.js +16 -16
  9. package/lib/decorator/type.d.ts +3 -2
  10. package/lib/decorator/type.js +2 -2
  11. package/lib/utilities/desc-type.d.ts +1 -0
  12. package/lib/utilities/desc-type.js +1 -1
  13. package/lib/utilities/env.d.ts +2 -1
  14. package/lib/utilities/env.js +1 -0
  15. package/lib/utilities/{agora-error.d.ts → error/agora-error.d.ts} +5 -11
  16. package/lib/utilities/error/agora-error.js +148 -0
  17. package/lib/utilities/error/error-code.d.ts +69 -0
  18. package/lib/utilities/error/error-code.js +81 -0
  19. package/lib/utilities/logger.d.ts +13 -1
  20. package/lib/utilities/logger.js +103 -13
  21. package/lib/utilities/observable.js +1 -0
  22. package/lib/utilities/package-info.d.ts +8 -0
  23. package/lib/utilities/package-info.js +85 -0
  24. package/lib/utilities/regex.d.ts +1 -0
  25. package/lib/utilities/regex.js +14 -0
  26. package/lib/utilities/tools.d.ts +28 -0
  27. package/lib/utilities/tools.js +154 -0
  28. package/lib/worker/worker-factory.js +22 -1
  29. package/lib-es/decorator/bound/index.js +12 -0
  30. package/lib-es/decorator/index.js +4 -0
  31. package/lib-es/decorator/lodash/index.js +34 -0
  32. package/lib-es/decorator/log/handler.js +71 -0
  33. package/lib-es/decorator/log/index.js +73 -0
  34. package/lib-es/decorator/log/log-serializer.js +28 -0
  35. package/lib-es/decorator/proxy.js +149 -0
  36. package/lib-es/decorator/type.js +7 -0
  37. package/lib-es/decorator/validate/index.js +32 -0
  38. package/lib-es/logger/common.js +45 -0
  39. package/lib-es/logger/constants.js +3 -0
  40. package/lib-es/logger/hijack.js +61 -0
  41. package/lib-es/logger/index.js +52 -0
  42. package/lib-es/logger/logger-impl.js +122 -0
  43. package/lib-es/logger/manager-impl.js +63 -0
  44. package/lib-es/logger/type.js +7 -0
  45. package/lib-es/restful-scheduler/scheduler.js +224 -0
  46. package/lib-es/schedule/index.js +3 -0
  47. package/lib-es/schedule/scheduler.js +102 -0
  48. package/lib-es/schedule/task.js +159 -0
  49. package/lib-es/upload/index.js +1 -0
  50. package/lib-es/upload/scheduler.js +145 -0
  51. package/lib-es/upload/type.js +1 -0
  52. package/lib-es/utilities/async-retry.js +177 -0
  53. package/lib-es/utilities/browser.js +20 -0
  54. package/lib-es/utilities/desc-type.js +3 -0
  55. package/lib-es/utilities/env.js +55 -0
  56. package/lib-es/utilities/error/agora-error.js +140 -0
  57. package/lib-es/utilities/error/error-code.js +74 -0
  58. package/lib-es/utilities/events.js +125 -0
  59. package/lib-es/utilities/file-reader.js +15 -0
  60. package/lib-es/utilities/interceptor.js +23 -0
  61. package/lib-es/utilities/logger.js +109 -0
  62. package/lib-es/utilities/misc.js +74 -0
  63. package/lib-es/utilities/observable.js +97 -0
  64. package/lib-es/utilities/package-info.js +78 -0
  65. package/lib-es/utilities/race-condition.js +17 -0
  66. package/lib-es/utilities/regex.js +7 -0
  67. package/lib-es/utilities/safely-remove-child.js +29 -0
  68. package/lib-es/utilities/schema.js +36 -0
  69. package/lib-es/utilities/tools.js +144 -0
  70. package/lib-es/utilities/value-check.js +3 -0
  71. package/lib-es/utilities/zip.js +200 -0
  72. package/lib-es/worker/constants.js +13 -0
  73. package/lib-es/worker/handler/binary.js +157 -0
  74. package/lib-es/worker/handler/db.js +34 -0
  75. package/lib-es/worker/handler/fs-log.js +149 -0
  76. package/lib-es/worker/handler/log-rotate-new.js +230 -0
  77. package/lib-es/worker/handler/log-rotate.js +80 -0
  78. package/lib-es/worker/handler/log.js +291 -0
  79. package/lib-es/worker/handler/reply.js +15 -0
  80. package/lib-es/worker/index.js +8 -0
  81. package/lib-es/worker/interactor.js +435 -0
  82. package/lib-es/worker/mutex.js +57 -0
  83. package/lib-es/worker/type.js +1 -0
  84. package/lib-es/worker/worker-entry.js +3 -0
  85. package/lib-es/worker/worker-factory.js +15 -0
  86. package/lib-es/worker/worker-installer.js +71 -0
  87. package/package.json +8 -4
  88. package/lib/utilities/agora-error.js +0 -128
  89. package/lib/worker/545.worker-factory.js +0 -1
  90. package/lib/worker/847.worker-factory.js +0 -2
  91. package/lib/worker/847.worker-factory.js.LICENSE.txt +0 -24
@@ -0,0 +1,97 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import "core-js/modules/es.array.concat.js";
5
+ import "core-js/modules/es.array.for-each.js";
6
+ import "core-js/modules/es.array.iterator.js";
7
+ import "core-js/modules/es.object.keys.js";
8
+ import "core-js/modules/es.object.to-string.js";
9
+ import "core-js/modules/es.set.js";
10
+ import "core-js/modules/es.string.iterator.js";
11
+ import "core-js/modules/esnext.iterator.constructor.js";
12
+ import "core-js/modules/esnext.iterator.for-each.js";
13
+ import "core-js/modules/esnext.set.add-all.js";
14
+ import "core-js/modules/esnext.set.delete-all.js";
15
+ import "core-js/modules/esnext.set.difference.v2.js";
16
+ import "core-js/modules/esnext.set.difference.js";
17
+ import "core-js/modules/esnext.set.every.js";
18
+ import "core-js/modules/esnext.set.filter.js";
19
+ import "core-js/modules/esnext.set.find.js";
20
+ import "core-js/modules/esnext.set.intersection.v2.js";
21
+ import "core-js/modules/esnext.set.intersection.js";
22
+ import "core-js/modules/esnext.set.is-disjoint-from.v2.js";
23
+ import "core-js/modules/esnext.set.is-disjoint-from.js";
24
+ import "core-js/modules/esnext.set.is-subset-of.v2.js";
25
+ import "core-js/modules/esnext.set.is-subset-of.js";
26
+ import "core-js/modules/esnext.set.is-superset-of.v2.js";
27
+ import "core-js/modules/esnext.set.is-superset-of.js";
28
+ import "core-js/modules/esnext.set.join.js";
29
+ import "core-js/modules/esnext.set.map.js";
30
+ import "core-js/modules/esnext.set.reduce.js";
31
+ import "core-js/modules/esnext.set.some.js";
32
+ import "core-js/modules/esnext.set.symmetric-difference.v2.js";
33
+ import "core-js/modules/esnext.set.symmetric-difference.js";
34
+ import "core-js/modules/esnext.set.union.v2.js";
35
+ import "core-js/modules/esnext.set.union.js";
36
+ import "core-js/modules/web.dom-collections.for-each.js";
37
+ import "core-js/modules/web.dom-collections.iterator.js";
38
+ import { AgoraEventEmitter } from './events';
39
+ export var AgoraObservable = /*#__PURE__*/function () {
40
+ function AgoraObservable() {
41
+ _classCallCheck(this, AgoraObservable);
42
+ _defineProperty(this, "_eventBus", new AgoraEventEmitter());
43
+ _defineProperty(this, "_observers", 0);
44
+ _defineProperty(this, "_observerSet", new Set());
45
+ }
46
+ return _createClass(AgoraObservable, [{
47
+ key: "addObserver",
48
+ value: function addObserver(observer) {
49
+ var _this = this;
50
+ if (this._observerSet.has(observer)) {
51
+ return;
52
+ }
53
+ var eventKeys = Object.keys(observer);
54
+ eventKeys.forEach(function (eventKey) {
55
+ if (typeof observer[eventKey] === 'function') {
56
+ _this._eventBus.on(eventKey, observer[eventKey]);
57
+ }
58
+ });
59
+ this._observers++;
60
+ this._observerSet.add(observer);
61
+ }
62
+ }, {
63
+ key: "removeObserver",
64
+ value: function removeObserver(observer) {
65
+ var _this2 = this;
66
+ var eventKeys = Object.keys(observer);
67
+ eventKeys.forEach(function (eventKey) {
68
+ if (typeof observer[eventKey] === 'function') {
69
+ _this2._eventBus.off(eventKey, observer[eventKey]);
70
+ }
71
+ });
72
+ this._observers--;
73
+ this._observerSet["delete"](observer);
74
+ }
75
+ }, {
76
+ key: "notifyObservers",
77
+ value: function notifyObservers(eventName) {
78
+ var _this$_eventBus;
79
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
80
+ args[_key - 1] = arguments[_key];
81
+ }
82
+ (_this$_eventBus = this._eventBus).emit.apply(_this$_eventBus, [eventName].concat(args));
83
+ }
84
+ }, {
85
+ key: "countOfObservers",
86
+ value: function countOfObservers() {
87
+ return this._observers;
88
+ }
89
+ }, {
90
+ key: "removeAllObservers",
91
+ value: function removeAllObservers() {
92
+ this._observers = 0;
93
+ this._observerSet.clear();
94
+ this._eventBus.removeAllEventListeners();
95
+ }
96
+ }]);
97
+ }();
@@ -0,0 +1,78 @@
1
+ import "core-js/modules/es.symbol.js";
2
+ import "core-js/modules/es.symbol.description.js";
3
+ import "core-js/modules/es.symbol.to-primitive.js";
4
+ import "core-js/modules/es.error.cause.js";
5
+ import "core-js/modules/es.error.to-string.js";
6
+ import "core-js/modules/es.array.is-array.js";
7
+ import "core-js/modules/es.array.iterator.js";
8
+ import "core-js/modules/es.array.push.js";
9
+ import "core-js/modules/es.date.to-primitive.js";
10
+ import "core-js/modules/es.function.bind.js";
11
+ import "core-js/modules/es.function.name.js";
12
+ import "core-js/modules/es.map.js";
13
+ import "core-js/modules/es.number.constructor.js";
14
+ import "core-js/modules/es.object.create.js";
15
+ import "core-js/modules/es.object.define-property.js";
16
+ import "core-js/modules/es.object.get-own-property-descriptor.js";
17
+ import "core-js/modules/es.object.to-string.js";
18
+ import "core-js/modules/es.string.iterator.js";
19
+ import "core-js/modules/esnext.function.metadata.js";
20
+ import "core-js/modules/esnext.map.delete-all.js";
21
+ import "core-js/modules/esnext.map.emplace.js";
22
+ import "core-js/modules/esnext.map.every.js";
23
+ import "core-js/modules/esnext.map.filter.js";
24
+ import "core-js/modules/esnext.map.find.js";
25
+ import "core-js/modules/esnext.map.find-key.js";
26
+ import "core-js/modules/esnext.map.includes.js";
27
+ import "core-js/modules/esnext.map.key-of.js";
28
+ import "core-js/modules/esnext.map.map-keys.js";
29
+ import "core-js/modules/esnext.map.map-values.js";
30
+ import "core-js/modules/esnext.map.merge.js";
31
+ import "core-js/modules/esnext.map.reduce.js";
32
+ import "core-js/modules/esnext.map.some.js";
33
+ import "core-js/modules/esnext.map.update.js";
34
+ import "core-js/modules/esnext.symbol.metadata.js";
35
+ import "core-js/modules/web.dom-collections.iterator.js";
36
+ import _typeof from "@babel/runtime/helpers/typeof";
37
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
38
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
39
+ import _createClass from "@babel/runtime/helpers/createClass";
40
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
41
+ var _PackageInfo;
42
+ var _initProto;
43
+ function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function set(e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O["static"] = l, O["private"] = f, f ? 2 === o ? k = function k(e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function k(e) { return e[n]; }, (o < 2 || 4 === o) && (F = function F(e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == _typeof(P) && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol["for"]("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol["for"]("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function s(t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
44
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
45
+ 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); }
46
+ function _setFunctionName(e, t, n) { "symbol" == _typeof(t) && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
47
+ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? _typeof(e) : "null")); return e; }
48
+ import { bound } from '../decorator/bound';
49
+ export var PackageInfo = /*#__PURE__*/function () {
50
+ function PackageInfo(packageInfo) {
51
+ _classCallCheck(this, PackageInfo);
52
+ _defineProperty(this, "_packageInfo", void _initProto(this));
53
+ this._packageInfo = packageInfo;
54
+ }
55
+ return _createClass(PackageInfo, [{
56
+ key: "getVersion",
57
+ value: function getVersion() {
58
+ return this._packageInfo.version || '';
59
+ }
60
+ }, {
61
+ key: "getDependenciesInfo",
62
+ value: function getDependenciesInfo(packageName) {
63
+ var _this$_packageInfo$de;
64
+ return ((_this$_packageInfo$de = this._packageInfo.dependencies) === null || _this$_packageInfo$de === void 0 ? void 0 : _this$_packageInfo$de[packageName]) || '';
65
+ }
66
+ }, {
67
+ key: "getDevDependenciesInfo",
68
+ value: function getDevDependenciesInfo(packageName) {
69
+ var _this$_packageInfo$de2;
70
+ return ((_this$_packageInfo$de2 = this._packageInfo.devDependencies) === null || _this$_packageInfo$de2 === void 0 ? void 0 : _this$_packageInfo$de2[packageName]) || '';
71
+ }
72
+ }]);
73
+ }();
74
+ _PackageInfo = PackageInfo;
75
+ var _applyDecs$e = _applyDecs(_PackageInfo, [[bound, 2, "getVersion"], [bound, 2, "getDependenciesInfo"], [bound, 2, "getDevDependenciesInfo"]], []).e;
76
+ var _applyDecs$e2 = _slicedToArray(_applyDecs$e, 1);
77
+ _initProto = _applyDecs$e2[0];
78
+ _applyDecs$e;
@@ -0,0 +1,17 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ import "core-js/modules/es.error.to-string.js";
3
+ import "core-js/modules/es.array.iterator.js";
4
+ import "core-js/modules/es.object.to-string.js";
5
+ import "core-js/modules/es.promise.js";
6
+ import "core-js/modules/es.string.iterator.js";
7
+ import "core-js/modules/web.dom-collections.iterator.js";
8
+ import "core-js/modules/web.timers.js";
9
+ export var timeout = function timeout(p, ms) {
10
+ return Promise.race([p, new Promise(function (_, reject) {
11
+ setTimeout(function () {
12
+ return reject(new Error('race condition timeout', {
13
+ cause: 'timeout'
14
+ }));
15
+ }, ms);
16
+ })]);
17
+ };
@@ -0,0 +1,7 @@
1
+ import "core-js/modules/es.regexp.exec.js";
2
+ import "core-js/modules/es.regexp.test.js";
3
+ export var isPhoneNumber = function isPhoneNumber(invitePhoneNumber) {
4
+ if (typeof invitePhoneNumber !== 'string') return false;
5
+ var reg = /^1[3-9]\d{9}$/;
6
+ return reg.test(invitePhoneNumber);
7
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 安全地使用 Node.removeChild 移除子节点
3
+ * @param parent 父节点
4
+ * @param child 要移除的子节点
5
+ * @returns 移除的节点,如果失败返回 null
6
+ */
7
+
8
+ import { getLogger } from '../logger';
9
+ var logger = getLogger();
10
+ export function safelyRemoveChild(parent, child) {
11
+ // 参数检查
12
+ if (!parent || !child) {
13
+ return null;
14
+ }
15
+ try {
16
+ // 检查父子关系
17
+ if (parent.contains(child)) {
18
+ return parent.removeChild(child);
19
+ } else {
20
+ // 子节点不属于该父节点
21
+ logger.warn('safelyRemoveChild: The node to be removed is not a child of this node');
22
+ return null;
23
+ }
24
+ } catch (error) {
25
+ // 捕获其他可能的错误
26
+ logger.error('safelyRemoveChild: Failed to remove child node', error);
27
+ return null;
28
+ }
29
+ }
@@ -0,0 +1,36 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ import "core-js/modules/es.error.to-string.js";
3
+ import { z } from 'zod';
4
+
5
+ // 基础类型 Schema
6
+ export var stringSchema = z.string();
7
+ export var booleanSchema = z["boolean"]();
8
+ export var numberSchema = z.number();
9
+ export var unknownSchema = z.unknown();
10
+ export var objectSchema = z.object({});
11
+ export var anySchema = z.any();
12
+ export var createUnionSchema = function createUnionSchema(schemas) {
13
+ if (schemas.length <= 1) {
14
+ throw new Error('[createUnionSchema] At least two Zod Schemas are required to be provided');
15
+ }
16
+ return z.union(schemas);
17
+ };
18
+ export function createArraySchema(elementSchema) {
19
+ return z.array(elementSchema);
20
+ }
21
+ export function createRecordSchemaWithKey(keySchema, valueSchema) {
22
+ return z.record(keySchema, valueSchema);
23
+ }
24
+
25
+ // 自定义校验 Schema
26
+ export var fcrRenderViewSchema = z.custom().refine(function (element) {
27
+ var hasStringTagName = typeof element.tagName === 'string';
28
+ return element instanceof HTMLElement || hasStringTagName;
29
+ }, {
30
+ message: 'Element must be a valid DOM HTMLElement'
31
+ });
32
+ export var positiveIntegerSchema = z.number()["int"]('must be an integer') // 校验是否为整数
33
+ .min(1, 'must be greater than or equal to 1') // 最小值为 1
34
+ .max(999, 'must be less than or equal to 999'); // 最大值为 999
35
+
36
+ export { z, ZodError } from 'zod';
@@ -0,0 +1,144 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import "core-js/modules/es.array.reduce.js";
4
+ import "core-js/modules/es.array.slice.js";
5
+ import "core-js/modules/es.number.constructor.js";
6
+ import "core-js/modules/es.number.to-fixed.js";
7
+ import "core-js/modules/es.object.to-string.js";
8
+ import "core-js/modules/es.regexp.exec.js";
9
+ import "core-js/modules/es.regexp.test.js";
10
+ import "core-js/modules/es.string.ends-with.js";
11
+ import "core-js/modules/es.string.match.js";
12
+ import "core-js/modules/es.string.replace.js";
13
+ import "core-js/modules/es.string.starts-with.js";
14
+ var LocalStorage = /*#__PURE__*/function () {
15
+ function LocalStorage() {
16
+ _classCallCheck(this, LocalStorage);
17
+ }
18
+ return _createClass(LocalStorage, [{
19
+ key: "set",
20
+ value: function set(key, value) {
21
+ localStorage.setItem(key, value);
22
+ }
23
+ }, {
24
+ key: "get",
25
+ value: function get(key) {
26
+ return localStorage.getItem(key);
27
+ }
28
+ }, {
29
+ key: "remove",
30
+ value: function remove(key) {
31
+ localStorage.removeItem(key);
32
+ }
33
+ }, {
34
+ key: "clear",
35
+ value: function clear() {
36
+ localStorage.clear();
37
+ }
38
+ }]);
39
+ }();
40
+ export var storage = new LocalStorage();
41
+ export var ASIDE_WIDTH = 'aside_width';
42
+ export var PARTICIPANT_POSITION = 'participant_position';
43
+ export var convertToFixedNumber = function convertToFixedNumber(value) {
44
+ var divisor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
45
+ var fractionDigits = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
46
+ return Number((value / divisor).toFixed(fractionDigits));
47
+ };
48
+ var virtualSoundCardPatternList = [/BlackHole/i, /SoundFlower/i, /AgoraALD/i];
49
+ export var matchVirtualSoundCardPattern = function matchVirtualSoundCardPattern(deviceName) {
50
+ return virtualSoundCardPatternList.reduce(function (prev, pattern) {
51
+ pattern.test(deviceName) && (prev = true);
52
+ return prev;
53
+ }, false);
54
+ };
55
+ export var isZipUrl = function isZipUrl(url) {
56
+ if (!url || typeof url !== 'string') return false;
57
+ var regex = /^https?:\/\/.+\.(zip)(\?.*)?$/i;
58
+ return regex.test(url);
59
+ };
60
+ export var isPngOrJpg = function isPngOrJpg(path) {
61
+ if (!path || typeof path !== 'string') return false;
62
+ return path.endsWith('.png') || path.endsWith('.jpg');
63
+ };
64
+ export var isMp4 = function isMp4(path) {
65
+ if (!path || typeof path !== 'string') return false;
66
+ return path.endsWith('.mp4');
67
+ };
68
+ export var isMp3OrWavUrl = function isMp3OrWavUrl(url) {
69
+ if (!url || typeof url !== 'string') return false;
70
+ var regex = /^https?:\/\/.+\.(mp3|wav)(\?.*)?$/i;
71
+ return regex.test(url);
72
+ };
73
+ export var isMp3OrWav = function isMp3OrWav(path) {
74
+ if (!path || typeof path !== 'string') return false;
75
+ return path.endsWith('.mp3') || path.endsWith('.wav');
76
+ };
77
+ export function getFileNameWithoutExtension(filePath) {
78
+ var match = filePath.match(/([^\\/]+)(?=\.\w+$)/);
79
+ var result = match ? match[1] : '';
80
+ return result !== null && result !== void 0 ? result : '';
81
+ }
82
+ export var setLanguage = function setLanguage(language) {
83
+ storage.set('$$fcr_language', language);
84
+ };
85
+ export var getLanguage = function getLanguage() {
86
+ return storage.get('$$fcr_language');
87
+ };
88
+ export var getBrowserLanguage = function getBrowserLanguage() {
89
+ var usrlang = navigator.language;
90
+ if (usrlang.startsWith('zh')) {
91
+ return 'zh';
92
+ }
93
+ return 'en';
94
+ };
95
+ export var uint8ArrayToImageData = function uint8ArrayToImageData(target) {
96
+ var _target$buffer;
97
+ if (!target || !(target !== null && target !== void 0 && (_target$buffer = target.buffer) !== null && _target$buffer !== void 0 && _target$buffer.length)) {
98
+ return '';
99
+ }
100
+ var canvas = document.createElement('canvas');
101
+ var ctx = canvas.getContext('2d');
102
+ if (!ctx) return '';
103
+ var width = canvas.width = target.width;
104
+ var height = canvas.height = target.height;
105
+ var rowBytes = width * 4;
106
+ for (var row = 0; row < height; row++) {
107
+ var srow = row;
108
+ var imageData = ctx.createImageData(width, 1);
109
+ var start = srow * width * 4;
110
+ if (target.isWindows) {
111
+ for (var i = 0; i < rowBytes; i += 4) {
112
+ imageData.data[i] = target.buffer[start + i + 2];
113
+ imageData.data[i + 1] = target.buffer[start + i + 1];
114
+ imageData.data[i + 2] = target.buffer[start + i];
115
+ imageData.data[i + 3] = target.buffer[start + i + 3];
116
+ }
117
+ } else {
118
+ for (var _i = 0; _i < rowBytes; ++_i) {
119
+ imageData.data[_i] = target.buffer[start + _i];
120
+ }
121
+ }
122
+ ctx.putImageData(imageData, 0, row);
123
+ }
124
+ return canvas.toDataURL('image/png');
125
+ };
126
+ export var renderMeetingId = function renderMeetingId(meetingId, roomId) {
127
+ var renderMeetingId = '';
128
+ if (meetingId) {
129
+ // 检查meetingId是否为纯数字
130
+ var isNumeric = /^\d+$/.test(meetingId);
131
+ if (!isNumeric) {
132
+ renderMeetingId = meetingId;
133
+ } else {
134
+ renderMeetingId = meetingId.replace(/(.{3})/g, '$1 ');
135
+ }
136
+ } else {
137
+ if (roomId.endsWith('-waiting')) {
138
+ renderMeetingId = roomId.slice(0, -8).replace(/(.{3})/g, '$1 ');
139
+ } else {
140
+ renderMeetingId = roomId.replace(/(.{3})/g, '$1 ');
141
+ }
142
+ }
143
+ return renderMeetingId;
144
+ };
@@ -0,0 +1,3 @@
1
+ export var isTrueValue = function isTrueValue(value) {
2
+ return value === 'true' || !!value;
3
+ };
@@ -0,0 +1,200 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
4
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
6
+ import "core-js/modules/es.array.concat.js";
7
+ import "core-js/modules/es.date.to-iso-string.js";
8
+ import "core-js/modules/es.date.to-string.js";
9
+ import "core-js/modules/es.object.to-string.js";
10
+ import "core-js/modules/es.symbol.js";
11
+ import "core-js/modules/es.symbol.description.js";
12
+ import "core-js/modules/es.symbol.iterator.js";
13
+ import "core-js/modules/es.error.cause.js";
14
+ import "core-js/modules/es.error.to-string.js";
15
+ import "core-js/modules/es.array.from.js";
16
+ import "core-js/modules/es.array.is-array.js";
17
+ import "core-js/modules/es.array.iterator.js";
18
+ import "core-js/modules/es.array.slice.js";
19
+ import "core-js/modules/es.function.name.js";
20
+ import "core-js/modules/es.promise.js";
21
+ import "core-js/modules/es.regexp.test.js";
22
+ import "core-js/modules/es.regexp.to-string.js";
23
+ import "core-js/modules/es.string.iterator.js";
24
+ import "core-js/modules/web.dom-collections.iterator.js";
25
+ import "core-js/modules/es.regexp.exec.js";
26
+ import "core-js/modules/es.string.replace.js";
27
+ import JSZip from 'jszip';
28
+ import isFunction from 'lodash/isFunction';
29
+ var COMPRESSION_LEVEL = 9;
30
+ export var zipDir = function zipDir(dirPath, filter) {
31
+ return new Promise(function (resolve) {
32
+ try {
33
+ var fs = window.require('fs');
34
+ fs.readdir(dirPath, /*#__PURE__*/function () {
35
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(err, files) {
36
+ var zip, _iterator, _step, _file, filePath, logsStr, blob, buffer, now, datefmt, file, _t;
37
+ return _regeneratorRuntime.wrap(function (_context) {
38
+ while (1) switch (_context.prev = _context.next) {
39
+ case 0:
40
+ if (!err) {
41
+ _context.next = 1;
42
+ break;
43
+ }
44
+ console.error("failed to read dir.", err);
45
+ _context.next = 14;
46
+ break;
47
+ case 1:
48
+ if (!(files.length === 0)) {
49
+ _context.next = 2;
50
+ break;
51
+ }
52
+ resolve(null);
53
+ _context.next = 14;
54
+ break;
55
+ case 2:
56
+ zip = new JSZip();
57
+ _iterator = _createForOfIteratorHelper(files);
58
+ _context.prev = 3;
59
+ _iterator.s();
60
+ case 4:
61
+ if ((_step = _iterator.n()).done) {
62
+ _context.next = 8;
63
+ break;
64
+ }
65
+ _file = _step.value;
66
+ if (!(isFunction(filter) && !filter(_file))) {
67
+ _context.next = 5;
68
+ break;
69
+ }
70
+ return _context.abrupt("continue", 7);
71
+ case 5:
72
+ filePath = "".concat(dirPath, "/").concat(_file); // check if filePath pointed to a regular file
73
+ _context.next = 6;
74
+ return isFile(filePath);
75
+ case 6:
76
+ if (!_context.sent) {
77
+ _context.next = 7;
78
+ break;
79
+ }
80
+ logsStr = fs.readFileSync(filePath, 'utf8');
81
+ zip.file(_file, logsStr);
82
+ case 7:
83
+ _context.next = 4;
84
+ break;
85
+ case 8:
86
+ _context.next = 10;
87
+ break;
88
+ case 9:
89
+ _context.prev = 9;
90
+ _t = _context["catch"](3);
91
+ _iterator.e(_t);
92
+ case 10:
93
+ _context.prev = 10;
94
+ _iterator.f();
95
+ return _context.finish(10);
96
+ case 11:
97
+ _context.next = 12;
98
+ return zip.generateAsync({
99
+ type: 'blob',
100
+ compression: 'DEFLATE',
101
+ compressionOptions: {
102
+ level: COMPRESSION_LEVEL
103
+ }
104
+ });
105
+ case 12:
106
+ blob = _context.sent;
107
+ _context.next = 13;
108
+ return blob.arrayBuffer();
109
+ case 13:
110
+ buffer = _context.sent;
111
+ // 使用 JavaScript 内置 Date 对象格式化日期
112
+ now = new Date();
113
+ datefmt = now.toISOString().replace(/\.\d{3}Z$/, 'Z') + 'Z';
114
+ file = new File([buffer], "logs-".concat(datefmt, ".zip"), {
115
+ type: 'application/zip'
116
+ });
117
+ resolve(file);
118
+ case 14:
119
+ case "end":
120
+ return _context.stop();
121
+ }
122
+ }, _callee, null, [[3, 9, 10, 11]]);
123
+ }));
124
+ return function (_x, _x2) {
125
+ return _ref.apply(this, arguments);
126
+ };
127
+ }());
128
+ } catch (e) {
129
+ console.error("failed to get buffer.", e);
130
+ resolve(null);
131
+ }
132
+ });
133
+ };
134
+ var isFile = /*#__PURE__*/function () {
135
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(filePath) {
136
+ var fs;
137
+ return _regeneratorRuntime.wrap(function (_context2) {
138
+ while (1) switch (_context2.prev = _context2.next) {
139
+ case 0:
140
+ fs = window.require('fs');
141
+ return _context2.abrupt("return", new Promise(function (resolve, reject) {
142
+ fs.stat(filePath, function (err, stats) {
143
+ if (err) reject(err);
144
+ if (!stats) {
145
+ resolve(false);
146
+ } else {
147
+ resolve(stats.isFile());
148
+ }
149
+ });
150
+ }));
151
+ case 1:
152
+ case "end":
153
+ return _context2.stop();
154
+ }
155
+ }, _callee2);
156
+ }));
157
+ return function isFile(_x3) {
158
+ return _ref2.apply(this, arguments);
159
+ };
160
+ }();
161
+ export var createMultiEntryZip = function createMultiEntryZip() {
162
+ var zip = new JSZip();
163
+ return {
164
+ addFile: function addFile(fileName, content) {
165
+ zip.file(fileName, content);
166
+ },
167
+ finish: function () {
168
+ var _finish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
169
+ var blob, buffer;
170
+ return _regeneratorRuntime.wrap(function (_context3) {
171
+ while (1) switch (_context3.prev = _context3.next) {
172
+ case 0:
173
+ _context3.next = 1;
174
+ return zip.generateAsync({
175
+ type: 'blob',
176
+ compression: 'DEFLATE',
177
+ compressionOptions: {
178
+ level: COMPRESSION_LEVEL
179
+ }
180
+ });
181
+ case 1:
182
+ blob = _context3.sent;
183
+ _context3.next = 2;
184
+ return blob.arrayBuffer();
185
+ case 2:
186
+ buffer = _context3.sent;
187
+ return _context3.abrupt("return", buffer);
188
+ case 3:
189
+ case "end":
190
+ return _context3.stop();
191
+ }
192
+ }, _callee3);
193
+ }));
194
+ function finish() {
195
+ return _finish.apply(this, arguments);
196
+ }
197
+ return finish;
198
+ }()
199
+ };
200
+ };
@@ -0,0 +1,13 @@
1
+ export var WorkerDirectives = /*#__PURE__*/function (WorkerDirectives) {
2
+ WorkerDirectives["SET_MAX_RECORDS"] = "set-max-records";
3
+ WorkerDirectives["WRITE_LOG"] = "writeLog";
4
+ WorkerDirectives["COLLECT_LOGS"] = "collectLogs";
5
+ WorkerDirectives["DELETE_LOGS"] = "deleteLogs";
6
+ WorkerDirectives["PERSIST_BUFFER"] = "persistBuffer";
7
+ WorkerDirectives["UNPERSIST_BUFFER"] = "unpersistBuffer";
8
+ WorkerDirectives["GET_BUFFER"] = "getBuffer";
9
+ WorkerDirectives["CLEAR_TEMP_LOGS"] = "clearTempLogs";
10
+ WorkerDirectives["COLLECT_LOGS_ON_FS"] = "collectLogsOnFs";
11
+ WorkerDirectives["ADD_FS_LOGGER"] = "addFsLogger";
12
+ return WorkerDirectives;
13
+ }({});