@univerjs/network 0.16.1 → 0.17.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.
package/lib/es/index.js CHANGED
@@ -1,16 +1,19 @@
1
- var P = Object.defineProperty;
2
- var S = (e, t, r) => t in e ? P(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var u = (e, t, r) => S(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { createIdentifier as J, Disposable as K, toDisposable as R, remove as z, ILogService as $, Inject as H, Injector as C, IConfigService as T, Plugin as ee, merge as re, Quantity as te, LookUp as ne, registerDependencies as se, mergeOverrideWithDependencies as oe, DisposableCollection as ie } from "@univerjs/core";
5
- import { of as M, firstValueFrom as ce, Observable as m, catchError as ae, throwError as le } from "rxjs";
6
- import { concatMap as B, retry as he, share as b } from "rxjs/operators";
7
- const pe = "network.config", G = {}, O = "application/json";
8
- function de(e) {
1
+ var S = Object.defineProperty;
2
+ var H = (e, t, r) => t in e ? S(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var p = (e, t, r) => H(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { createIdentifier as K, Disposable as z, toDisposable as I, remove as Y, ILogService as $, Inject as C, Injector as T, IConfigService as ee, Plugin as re, merge as te, Quantity as ne, LookUp as se, registerDependencies as oe, mergeOverrideWithDependencies as ie, DisposableCollection as ce } from "@univerjs/core";
5
+ import { of as M, firstValueFrom as ae, Observable as m, catchError as le, throwError as he } from "rxjs";
6
+ import { concatMap as B, retry as pe, share as x } from "rxjs/operators";
7
+ const de = "@univerjs/network", ue = "0.17.0", G = {
8
+ name: de,
9
+ version: ue
10
+ }, ge = "network.config", W = {}, O = "application/json";
11
+ function fe(e) {
9
12
  return Array.isArray(e) ? e.some((t) => t.includes(O)) : e.includes(O);
10
13
  }
11
- class I {
14
+ class b {
12
15
  constructor(t) {
13
- u(this, "_headers", /* @__PURE__ */ new Map());
16
+ p(this, "_headers", /* @__PURE__ */ new Map());
14
17
  typeof t == "string" ? this._handleHeadersString(t) : t instanceof Headers ? this._handleHeaders(t) : t && this._handleHeadersConstructorProps(t);
15
18
  }
16
19
  forEach(t) {
@@ -51,8 +54,8 @@ class I {
51
54
  t.forEach((r, n) => this._setHeader(n, r));
52
55
  }
53
56
  }
54
- const Y = J("network.http-implementation");
55
- class W {
57
+ const Q = K("network.http-implementation");
58
+ class X {
56
59
  constructor(t) {
57
60
  this.params = t;
58
61
  }
@@ -63,10 +66,10 @@ class W {
63
66
  }).join("&") : "";
64
67
  }
65
68
  }
66
- let ue = 0;
67
- class X {
69
+ let ye = 0;
70
+ class V {
68
71
  constructor(t, r, n) {
69
- u(this, "uid", ue++);
72
+ p(this, "uid", ye++);
70
73
  this.method = t, this.url = r, this.requestParams = n;
71
74
  }
72
75
  get headers() {
@@ -86,24 +89,24 @@ class X {
86
89
  getBody() {
87
90
  var n, s;
88
91
  const t = (n = this.headers.get("Content-Type")) != null ? n : O, r = (s = this.requestParams) == null ? void 0 : s.body;
89
- return r instanceof FormData ? r : de(t) && r && typeof r == "object" ? JSON.stringify(r) : r ? `${r}` : null;
92
+ return r instanceof FormData ? r : fe(t) && r && typeof r == "object" ? JSON.stringify(r) : r ? `${r}` : null;
90
93
  }
91
94
  getHeadersInit() {
92
95
  var r;
93
96
  return this.headers.toHeadersInit((r = this.requestParams) == null ? void 0 : r.body);
94
97
  }
95
98
  }
96
- var ge = Object.getOwnPropertyDescriptor, fe = (e, t, r, n) => {
97
- for (var s = n > 1 ? void 0 : n ? ge(t, r) : t, o = e.length - 1, i; o >= 0; o--)
99
+ var we = Object.getOwnPropertyDescriptor, me = (e, t, r, n) => {
100
+ for (var s = n > 1 ? void 0 : n ? we(t, r) : t, o = e.length - 1, i; o >= 0; o--)
98
101
  (i = e[o]) && (s = i(s) || s);
99
102
  return s;
100
- }, ye = (e, t) => (r, n) => t(r, n, e);
101
- let x = class extends K {
103
+ }, ve = (e, t) => (r, n) => t(r, n, e);
104
+ let L = class extends z {
102
105
  constructor(t) {
103
106
  super();
104
- u(this, "_interceptors", []);
107
+ p(this, "_interceptors", []);
105
108
  // eslint-disable-next-line ts/no-explicit-any
106
- u(this, "_pipe");
109
+ p(this, "_pipe");
107
110
  this._http = t;
108
111
  }
109
112
  /**
@@ -118,7 +121,7 @@ let x = class extends K {
118
121
  return this._interceptors.push(t), this._interceptors = this._interceptors.sort((r, n) => {
119
122
  var s, o;
120
123
  return ((s = r.priority) != null ? s : 0) - ((o = n.priority) != null ? o : 0);
121
- }), this._pipe = null, R(() => z(this._interceptors, t));
124
+ }), this._pipe = null, I(() => Y(this._interceptors, t));
122
125
  }
123
126
  get(t, r) {
124
127
  return this.request("GET", t, r);
@@ -145,7 +148,7 @@ let x = class extends K {
145
148
  */
146
149
  async request(t, r, n) {
147
150
  var l, h;
148
- const s = new I(n == null ? void 0 : n.headers), o = new W(n == null ? void 0 : n.params), i = new X(t, r, {
151
+ const s = new b(n == null ? void 0 : n.headers), o = new X(n == null ? void 0 : n.params), i = new V(t, r, {
149
152
  headers: s,
150
153
  params: o,
151
154
  withCredentials: (l = n == null ? void 0 : n.withCredentials) != null ? l : !1,
@@ -155,7 +158,7 @@ let x = class extends K {
155
158
  }), c = M(i).pipe(
156
159
  B((a) => this._runInterceptorsAndImplementation(a))
157
160
  );
158
- return await ce(c);
161
+ return await ae(c);
159
162
  }
160
163
  /**
161
164
  * Send an HTTP request. It returns an observable that emits HTTP events. For example, it can be used to
@@ -179,13 +182,13 @@ let x = class extends K {
179
182
  * @returns An observable of the HTTP event.
180
183
  */
181
184
  getSSE(t, r, n) {
182
- var c, d;
183
- const s = new I(n == null ? void 0 : n.headers), o = new W(n == null ? void 0 : n.params), i = new X(t, r, {
185
+ var c, u;
186
+ const s = new b(n == null ? void 0 : n.headers), o = new X(n == null ? void 0 : n.params), i = new V(t, r, {
184
187
  headers: s,
185
188
  params: o,
186
189
  withCredentials: (c = n == null ? void 0 : n.withCredentials) != null ? c : !1,
187
190
  reportProgress: !0,
188
- responseType: (d = n == null ? void 0 : n.responseType) != null ? d : "json",
191
+ responseType: (u = n == null ? void 0 : n.responseType) != null ? u : "json",
189
192
  body: ["GET", "DELETE"].includes(t) || n == null ? void 0 : n.body
190
193
  });
191
194
  return M(i).pipe(B((l) => this._runInterceptorsAndImplementation(l)));
@@ -193,7 +196,7 @@ let x = class extends K {
193
196
  // eslint-disable-next-line ts/no-explicit-any
194
197
  _runInterceptorsAndImplementation(t) {
195
198
  return this._pipe || (this._pipe = this._interceptors.map((r) => r.interceptor).reduceRight(
196
- (r, n) => we(r, n),
199
+ (r, n) => _e(r, n),
197
200
  (r, n) => n(r)
198
201
  )), this._pipe(
199
202
  t,
@@ -202,14 +205,14 @@ let x = class extends K {
202
205
  );
203
206
  }
204
207
  };
205
- x = fe([
206
- ye(0, Y)
207
- ], x);
208
- function we(e, t) {
208
+ L = me([
209
+ ve(0, Q)
210
+ ], L);
211
+ function _e(e, t) {
209
212
  return (r, n) => t(r, (s) => e(s, n));
210
213
  }
211
- const me = 200, ve = 300;
212
- var L = /* @__PURE__ */ ((e) => (e[e.Continue = 100] = "Continue", e[e.SwitchingProtocols = 101] = "SwitchingProtocols", e[e.Processing = 102] = "Processing", e[e.EarlyHints = 103] = "EarlyHints", e[e.Ok = 200] = "Ok", e[e.Created = 201] = "Created", e[e.Accepted = 202] = "Accepted", e[e.NonAuthoritativeInformation = 203] = "NonAuthoritativeInformation", e[e.NoContent = 204] = "NoContent", e[e.ResetContent = 205] = "ResetContent", e[e.PartialContent = 206] = "PartialContent", e[e.MultiStatus = 207] = "MultiStatus", e[e.AlreadyReported = 208] = "AlreadyReported", e[e.ImUsed = 226] = "ImUsed", e[e.MultipleChoices = 300] = "MultipleChoices", e[e.MovedPermanently = 301] = "MovedPermanently", e[e.Found = 302] = "Found", e[e.SeeOther = 303] = "SeeOther", e[e.NotModified = 304] = "NotModified", e[e.UseProxy = 305] = "UseProxy", e[e.Unused = 306] = "Unused", e[e.TemporaryRedirect = 307] = "TemporaryRedirect", e[e.PermanentRedirect = 308] = "PermanentRedirect", e[e.BadRequest = 400] = "BadRequest", e[e.Unauthorized = 401] = "Unauthorized", e[e.PaymentRequired = 402] = "PaymentRequired", e[e.Forbidden = 403] = "Forbidden", e[e.NotFound = 404] = "NotFound", e[e.MethodNotAllowed = 405] = "MethodNotAllowed", e[e.NotAcceptable = 406] = "NotAcceptable", e[e.ProxyAuthenticationRequired = 407] = "ProxyAuthenticationRequired", e[e.RequestTimeout = 408] = "RequestTimeout", e[e.Conflict = 409] = "Conflict", e[e.Gone = 410] = "Gone", e[e.LengthRequired = 411] = "LengthRequired", e[e.PreconditionFailed = 412] = "PreconditionFailed", e[e.PayloadTooLarge = 413] = "PayloadTooLarge", e[e.UriTooLong = 414] = "UriTooLong", e[e.UnsupportedMediaType = 415] = "UnsupportedMediaType", e[e.RangeNotSatisfiable = 416] = "RangeNotSatisfiable", e[e.ExpectationFailed = 417] = "ExpectationFailed", e[e.ImATeapot = 418] = "ImATeapot", e[e.MisdirectedRequest = 421] = "MisdirectedRequest", e[e.UnprocessableEntity = 422] = "UnprocessableEntity", e[e.Locked = 423] = "Locked", e[e.FailedDependency = 424] = "FailedDependency", e[e.TooEarly = 425] = "TooEarly", e[e.UpgradeRequired = 426] = "UpgradeRequired", e[e.PreconditionRequired = 428] = "PreconditionRequired", e[e.TooManyRequests = 429] = "TooManyRequests", e[e.RequestHeaderFieldsTooLarge = 431] = "RequestHeaderFieldsTooLarge", e[e.UnavailableForLegalReasons = 451] = "UnavailableForLegalReasons", e[e.InternalServerError = 500] = "InternalServerError", e[e.NotImplemented = 501] = "NotImplemented", e[e.BadGateway = 502] = "BadGateway", e[e.ServiceUnavailable = 503] = "ServiceUnavailable", e[e.GatewayTimeout = 504] = "GatewayTimeout", e[e.HttpVersionNotSupported = 505] = "HttpVersionNotSupported", e[e.VariantAlsoNegotiates = 506] = "VariantAlsoNegotiates", e[e.InsufficientStorage = 507] = "InsufficientStorage", e[e.LoopDetected = 508] = "LoopDetected", e[e.NotExtended = 510] = "NotExtended", e[e.NetworkAuthenticationRequired = 511] = "NetworkAuthenticationRequired", e))(L || {}), Q = /* @__PURE__ */ ((e) => (e[e.DownloadProgress = 0] = "DownloadProgress", e[e.Response = 1] = "Response", e))(Q || {});
214
+ const Ee = 200, Re = 300;
215
+ var N = /* @__PURE__ */ ((e) => (e[e.Continue = 100] = "Continue", e[e.SwitchingProtocols = 101] = "SwitchingProtocols", e[e.Processing = 102] = "Processing", e[e.EarlyHints = 103] = "EarlyHints", e[e.Ok = 200] = "Ok", e[e.Created = 201] = "Created", e[e.Accepted = 202] = "Accepted", e[e.NonAuthoritativeInformation = 203] = "NonAuthoritativeInformation", e[e.NoContent = 204] = "NoContent", e[e.ResetContent = 205] = "ResetContent", e[e.PartialContent = 206] = "PartialContent", e[e.MultiStatus = 207] = "MultiStatus", e[e.AlreadyReported = 208] = "AlreadyReported", e[e.ImUsed = 226] = "ImUsed", e[e.MultipleChoices = 300] = "MultipleChoices", e[e.MovedPermanently = 301] = "MovedPermanently", e[e.Found = 302] = "Found", e[e.SeeOther = 303] = "SeeOther", e[e.NotModified = 304] = "NotModified", e[e.UseProxy = 305] = "UseProxy", e[e.Unused = 306] = "Unused", e[e.TemporaryRedirect = 307] = "TemporaryRedirect", e[e.PermanentRedirect = 308] = "PermanentRedirect", e[e.BadRequest = 400] = "BadRequest", e[e.Unauthorized = 401] = "Unauthorized", e[e.PaymentRequired = 402] = "PaymentRequired", e[e.Forbidden = 403] = "Forbidden", e[e.NotFound = 404] = "NotFound", e[e.MethodNotAllowed = 405] = "MethodNotAllowed", e[e.NotAcceptable = 406] = "NotAcceptable", e[e.ProxyAuthenticationRequired = 407] = "ProxyAuthenticationRequired", e[e.RequestTimeout = 408] = "RequestTimeout", e[e.Conflict = 409] = "Conflict", e[e.Gone = 410] = "Gone", e[e.LengthRequired = 411] = "LengthRequired", e[e.PreconditionFailed = 412] = "PreconditionFailed", e[e.PayloadTooLarge = 413] = "PayloadTooLarge", e[e.UriTooLong = 414] = "UriTooLong", e[e.UnsupportedMediaType = 415] = "UnsupportedMediaType", e[e.RangeNotSatisfiable = 416] = "RangeNotSatisfiable", e[e.ExpectationFailed = 417] = "ExpectationFailed", e[e.ImATeapot = 418] = "ImATeapot", e[e.MisdirectedRequest = 421] = "MisdirectedRequest", e[e.UnprocessableEntity = 422] = "UnprocessableEntity", e[e.Locked = 423] = "Locked", e[e.FailedDependency = 424] = "FailedDependency", e[e.TooEarly = 425] = "TooEarly", e[e.UpgradeRequired = 426] = "UpgradeRequired", e[e.PreconditionRequired = 428] = "PreconditionRequired", e[e.TooManyRequests = 429] = "TooManyRequests", e[e.RequestHeaderFieldsTooLarge = 431] = "RequestHeaderFieldsTooLarge", e[e.UnavailableForLegalReasons = 451] = "UnavailableForLegalReasons", e[e.InternalServerError = 500] = "InternalServerError", e[e.NotImplemented = 501] = "NotImplemented", e[e.BadGateway = 502] = "BadGateway", e[e.ServiceUnavailable = 503] = "ServiceUnavailable", e[e.GatewayTimeout = 504] = "GatewayTimeout", e[e.HttpVersionNotSupported = 505] = "HttpVersionNotSupported", e[e.VariantAlsoNegotiates = 506] = "VariantAlsoNegotiates", e[e.InsufficientStorage = 507] = "InsufficientStorage", e[e.LoopDetected = 508] = "LoopDetected", e[e.NotExtended = 510] = "NotExtended", e[e.NetworkAuthenticationRequired = 511] = "NetworkAuthenticationRequired", e))(N || {}), Z = /* @__PURE__ */ ((e) => (e[e.DownloadProgress = 0] = "DownloadProgress", e[e.Response = 1] = "Response", e))(Z || {});
213
216
  class q {
214
217
  constructor({
215
218
  body: t,
@@ -217,21 +220,21 @@ class q {
217
220
  status: n,
218
221
  statusText: s
219
222
  }) {
220
- u(this, "type", 1);
221
- u(this, "body");
222
- u(this, "headers");
223
- u(this, "status");
224
- u(this, "statusText");
223
+ p(this, "type", 1);
224
+ p(this, "body");
225
+ p(this, "headers");
226
+ p(this, "status");
227
+ p(this, "statusText");
225
228
  this.body = t, this.headers = r, this.status = n, this.statusText = s;
226
229
  }
227
230
  }
228
- class _e {
231
+ class Ie {
229
232
  constructor(t, r, n) {
230
- u(this, "type", 0);
233
+ p(this, "type", 0);
231
234
  this.total = t, this.loaded = r, this.partialText = n;
232
235
  }
233
236
  }
234
- class Ee {
237
+ class be {
235
238
  constructor(t, r, n) {
236
239
  this.headers = t, this.status = r, this.statusText = n;
237
240
  }
@@ -244,15 +247,15 @@ class v {
244
247
  statusText: s,
245
248
  error: o
246
249
  }) {
247
- u(this, "request");
248
- u(this, "headers");
249
- u(this, "status");
250
- u(this, "statusText");
251
- u(this, "error");
250
+ p(this, "request");
251
+ p(this, "headers");
252
+ p(this, "status");
253
+ p(this, "statusText");
254
+ p(this, "error");
252
255
  this.request = t, this.headers = r, this.status = n, this.statusText = s, this.error = o;
253
256
  }
254
257
  }
255
- function Z(e) {
258
+ function P(e) {
256
259
  return {
257
260
  method: e.method,
258
261
  headers: e.getHeadersInit(),
@@ -260,12 +263,12 @@ function Z(e) {
260
263
  credentials: e.withCredentials ? "include" : void 0
261
264
  };
262
265
  }
263
- var Re = Object.getOwnPropertyDescriptor, Ie = (e, t, r, n) => {
264
- for (var s = n > 1 ? void 0 : n ? Re(t, r) : t, o = e.length - 1, i; o >= 0; o--)
266
+ var xe = Object.getOwnPropertyDescriptor, Le = (e, t, r, n) => {
267
+ for (var s = n > 1 ? void 0 : n ? xe(t, r) : t, o = e.length - 1, i; o >= 0; o--)
265
268
  (i = e[o]) && (s = i(s) || s);
266
269
  return s;
267
- }, be = (e, t) => (r, n) => t(r, n, e);
268
- let N = class {
270
+ }, Ne = (e, t) => (r, n) => t(r, n, e);
271
+ let k = class {
269
272
  constructor(e) {
270
273
  this._logService = e;
271
274
  }
@@ -284,11 +287,11 @@ let N = class {
284
287
  var l, h;
285
288
  let n;
286
289
  try {
287
- const a = Z(e), g = e.getUrlWithParams(), p = fetch(g, {
290
+ const a = P(e), g = e.getUrlWithParams(), d = fetch(g, {
288
291
  signal: r.signal,
289
292
  ...a
290
293
  });
291
- this._logService.debug(`[FetchHTTPImplementation]: sending request to url ${g} with params ${a}`), n = await p;
294
+ this._logService.debug(`[FetchHTTPImplementation]: sending request to url ${g} with params ${a}`), n = await d;
292
295
  } catch (a) {
293
296
  const g = new v({
294
297
  request: e,
@@ -300,9 +303,9 @@ let N = class {
300
303
  this._logService.error("[FetchHTTPImplementation]: network error", g), t.error(g);
301
304
  return;
302
305
  }
303
- const s = new I(n.headers), o = n.status, i = n.statusText;
306
+ const s = new b(n.headers), o = n.status, i = n.statusText;
304
307
  let c = null;
305
- if (n.body && (c = await this._readBody(e, n, t)), o >= L.Ok && o < L.MultipleChoices)
308
+ if (n.body && (c = await this._readBody(e, n, t)), o >= N.Ok && o < N.MultipleChoices)
306
309
  t.next(new q({
307
310
  body: c,
308
311
  headers: s,
@@ -322,51 +325,51 @@ let N = class {
322
325
  t.complete();
323
326
  }
324
327
  async _readBody(e, t, r) {
325
- var g, p;
328
+ var g, d;
326
329
  const n = [], s = t.body.getReader(), o = t.headers.get("content-length");
327
330
  let i = 0;
328
- const c = (g = e.requestParams) == null ? void 0 : g.reportProgress, d = e.responseType;
331
+ const c = (g = e.requestParams) == null ? void 0 : g.reportProgress, u = e.responseType;
329
332
  let l, h;
330
333
  for (; ; ) {
331
334
  const { done: f, value: y } = await s.read();
332
335
  if (f) break;
333
- n.push(y), i += y.length, c && d === "text" && (l = (l != null ? l : "") + (h != null ? h : h = new TextDecoder()).decode(y, { stream: !0 }), r.next(new _e(
336
+ n.push(y), i += y.length, c && u === "text" && (l = (l != null ? l : "") + (h != null ? h : h = new TextDecoder()).decode(y, { stream: !0 }), r.next(new Ie(
334
337
  o ? Number.parseInt(o, 10) : void 0,
335
338
  i,
336
339
  l
337
340
  )));
338
341
  }
339
- const a = xe(n, i);
342
+ const a = ke(n, i);
340
343
  try {
341
- const f = (p = t.headers.get("content-type")) != null ? p : "";
342
- return Ne(e, a, f);
344
+ const f = (d = t.headers.get("content-type")) != null ? d : "";
345
+ return Fe(e, a, f);
343
346
  } catch (f) {
344
347
  const y = new v({
345
348
  request: e,
346
349
  error: f,
347
350
  status: t.status,
348
351
  statusText: t.statusText,
349
- headers: new I(t.headers)
352
+ headers: new b(t.headers)
350
353
  });
351
354
  return this._logService.error("[FetchHTTPImplementation]: network error", y), r.error(y), null;
352
355
  }
353
356
  }
354
357
  };
355
- N = Ie([
356
- be(0, $)
357
- ], N);
358
- function xe(e, t) {
358
+ k = Le([
359
+ Ne(0, $)
360
+ ], k);
361
+ function ke(e, t) {
359
362
  const r = new Uint8Array(t);
360
363
  let n = 0;
361
364
  for (const s of e)
362
365
  r.set(s, n), n += s.length;
363
366
  return r;
364
367
  }
365
- const Le = /^\)\]\}',?\n/;
366
- function Ne(e, t, r) {
368
+ const Ae = /^\)\]\}',?\n/;
369
+ function Fe(e, t, r) {
367
370
  switch (e.responseType) {
368
371
  case "json":
369
- const n = new TextDecoder().decode(t).replace(Le, "");
372
+ const n = new TextDecoder().decode(t).replace(Ae, "");
370
373
  return n === "" ? null : JSON.parse(n);
371
374
  case "text":
372
375
  return new TextDecoder().decode(t);
@@ -378,39 +381,39 @@ function Ne(e, t, r) {
378
381
  throw new Error(`[FetchHTTPImplementation]: unknown response type: ${e.responseType}.`);
379
382
  }
380
383
  }
381
- var Ae = Object.getOwnPropertyDescriptor, Fe = (e, t, r, n) => {
382
- for (var s = n > 1 ? void 0 : n ? Ae(t, r) : t, o = e.length - 1, i; o >= 0; o--)
384
+ var Ue = Object.getOwnPropertyDescriptor, Oe = (e, t, r, n) => {
385
+ for (var s = n > 1 ? void 0 : n ? Ue(t, r) : t, o = e.length - 1, i; o >= 0; o--)
383
386
  (i = e[o]) && (s = i(s) || s);
384
387
  return s;
385
- }, ke = (e, t) => (r, n) => t(r, n, e);
388
+ }, De = (e, t) => (r, n) => t(r, n, e);
386
389
  let D = class {
387
390
  constructor(e) {
388
391
  this._logService = e;
389
392
  }
390
393
  send(e) {
391
394
  return new m((t) => {
392
- const r = new XMLHttpRequest(), n = e.getUrlWithParams(), s = Z(e), { responseType: o } = e;
395
+ const r = new XMLHttpRequest(), n = e.getUrlWithParams(), s = P(e), { responseType: o } = e;
393
396
  r.open(e.method, n), e.withCredentials && (r.withCredentials = !0), s.headers && Object.entries(s.headers).forEach(([h, a]) => r.setRequestHeader(h, a));
394
397
  const i = () => {
395
- const h = r.statusText || "OK", a = new I(r.getAllResponseHeaders());
396
- return new Ee(a, r.status, h);
398
+ const h = r.statusText || "OK", a = new b(r.getAllResponseHeaders());
399
+ return new be(a, r.status, h);
397
400
  }, c = () => {
398
401
  const { headers: h, statusText: a, status: g } = i();
399
- let p = null, f = null;
400
- g !== L.NoContent && (p = typeof r.response > "u" ? r.responseText : r.response);
401
- let y = g >= me && g < ve;
402
- if (o === "json" && typeof p == "string") {
403
- const w = p;
402
+ let d = null, f = null;
403
+ g !== N.NoContent && (d = typeof r.response > "u" ? r.responseText : r.response);
404
+ let y = g >= Ee && g < Re;
405
+ if (o === "json" && typeof d == "string") {
406
+ const w = d;
404
407
  try {
405
- p = p ? JSON.parse(p) : null;
408
+ d = d ? JSON.parse(d) : null;
406
409
  } catch (_) {
407
- y = !1, p = w, f = _;
410
+ y = !1, d = w, f = _;
408
411
  }
409
412
  }
410
- if (o === "blob" && !(p instanceof Blob) && (y = !1, f = new Error("Response is not a Blob object")), y)
413
+ if (o === "blob" && !(d instanceof Blob) && (y = !1, f = new Error("Response is not a Blob object")), y)
411
414
  t.next(
412
415
  new q({
413
- body: p,
416
+ body: d,
414
417
  headers: h,
415
418
  status: g,
416
419
  statusText: a
@@ -426,7 +429,7 @@ let D = class {
426
429
  });
427
430
  this._logService.error("[XHRHTTPImplementation]: network error", w), t.error(w);
428
431
  }
429
- }, d = (h) => {
432
+ }, u = (h) => {
430
433
  const a = new v({
431
434
  request: e,
432
435
  error: h,
@@ -436,59 +439,59 @@ let D = class {
436
439
  });
437
440
  this._logService.error("[XHRHTTPImplementation]: network error", a), t.error(a);
438
441
  };
439
- r.responseType = o || "", r.addEventListener("load", c), r.addEventListener("error", d), r.addEventListener("abort", d), r.addEventListener("timeout", d);
442
+ r.responseType = o || "", r.addEventListener("load", c), r.addEventListener("error", u), r.addEventListener("abort", u), r.addEventListener("timeout", u);
440
443
  const l = e.getBody();
441
444
  return r.send(l), this._logService.debug("[XHRHTTPImplementation]", `sending request to url ${n} with params ${s}`), () => {
442
- r.readyState !== r.DONE && r.abort(), r.removeEventListener("load", c), r.removeEventListener("error", d), r.removeEventListener("abort", d), r.removeEventListener("timeout", d);
445
+ r.readyState !== r.DONE && r.abort(), r.removeEventListener("load", c), r.removeEventListener("error", u), r.removeEventListener("abort", u), r.removeEventListener("timeout", u);
443
446
  };
444
447
  });
445
448
  }
446
449
  };
447
- D = Fe([
448
- ke(0, $)
450
+ D = Oe([
451
+ De(0, $)
449
452
  ], D);
450
- var Ue = Object.getOwnPropertyDescriptor, Oe = (e, t, r, n) => {
451
- for (var s = n > 1 ? void 0 : n ? Ue(t, r) : t, o = e.length - 1, i; o >= 0; o--)
453
+ var $e = Object.getOwnPropertyDescriptor, qe = (e, t, r, n) => {
454
+ for (var s = n > 1 ? void 0 : n ? $e(t, r) : t, o = e.length - 1, i; o >= 0; o--)
452
455
  (i = e[o]) && (s = i(s) || s);
453
456
  return s;
454
- }, k = (e, t) => (r, n) => t(r, n, e), U;
455
- let V = (U = class extends ee {
456
- constructor(e = G, t, r, n) {
457
+ }, U = (e, t) => (r, n) => t(r, n, e), R;
458
+ let J = (R = class extends re {
459
+ constructor(e = W, t, r, n) {
457
460
  super(), this._config = e, this._logger = t, this._injector = r, this._configService = n;
458
- const { ...s } = re(
461
+ const { ...s } = te(
459
462
  {},
460
- G,
463
+ W,
461
464
  this._config
462
465
  );
463
- this._configService.setConfig(pe, s);
466
+ this._configService.setConfig(ge, s);
464
467
  }
465
468
  onStarting() {
466
469
  var r, n, s;
467
- if (this._injector.get(x, te.OPTIONAL, ne.SKIP_SELF) && !((r = this._config) != null && r.forceUseNewInstance)) {
470
+ if (this._injector.get(L, ne.OPTIONAL, se.SKIP_SELF) && !((r = this._config) != null && r.forceUseNewInstance)) {
468
471
  this._logger.warn(
469
472
  "[UniverNetworkPlugin]",
470
473
  'HTTPService is already registered in an ancestor interceptor. Skipping registration. If you want to force a new instance, set "forceUseNewInstance" to true in the plugin configuration.'
471
474
  );
472
475
  return;
473
476
  }
474
- const t = (n = this._config) != null && n.useFetchImpl ? N : typeof window < "u" ? D : N;
475
- se(this._injector, oe([
476
- [x],
477
- [Y, { useClass: t }]
477
+ const t = (n = this._config) != null && n.useFetchImpl ? k : typeof window < "u" ? D : k;
478
+ oe(this._injector, ie([
479
+ [L],
480
+ [Q, { useClass: t }]
478
481
  ], (s = this._config) == null ? void 0 : s.override));
479
482
  }
480
- }, u(U, "pluginName", "UNIVER_NETWORK_PLUGIN"), U);
481
- V = Oe([
482
- k(1, $),
483
- k(2, H(C)),
484
- k(3, T)
485
- ], V);
486
- const Xe = (e) => {
483
+ }, p(R, "pluginName", "UNIVER_NETWORK_PLUGIN"), p(R, "packageName", G.name), p(R, "version", G.version), R);
484
+ J = qe([
485
+ U(1, $),
486
+ U(2, C(T)),
487
+ U(3, ee)
488
+ ], J);
489
+ const Ke = (e) => {
487
490
  const { errorStatusCodes: t, onAuthError: r } = e;
488
491
  return (s, o) => o(s).pipe(
489
- ae((i) => (i instanceof v && t.some((c) => c === i.status) && r(), le(() => i)))
492
+ le((i) => (i instanceof v && t.some((c) => c === i.status) && r(), he(() => i)))
490
493
  );
491
- }, De = (e = 300) => {
494
+ }, je = (e = 300) => {
492
495
  let r = () => {
493
496
  };
494
497
  return (n) => new Promise((s) => {
@@ -500,8 +503,8 @@ const Xe = (e) => {
500
503
  clearTimeout(o), s(!1);
501
504
  };
502
505
  });
503
- }, $e = () => (e, t) => t.map((r) => ({ config: r, result: e })), Ve = (e, t = {}) => {
504
- const { isMatch: r, getParamsFromRequest: n, mergeParamsToRequest: s } = e, { fetchCheck: o = De(300), distributeResult: i = $e() } = t, c = [], d = (l) => l.map((h) => h.config);
506
+ }, Me = () => (e, t) => t.map((r) => ({ config: r, result: e })), ze = (e, t = {}) => {
507
+ const { isMatch: r, getParamsFromRequest: n, mergeParamsToRequest: s } = e, { fetchCheck: o = je(300), distributeResult: i = Me() } = t, c = [], u = (l) => l.map((h) => h.config);
505
508
  return (l, h) => r(l) ? new m((a) => {
506
509
  const g = n(l);
507
510
  c.push({
@@ -509,20 +512,20 @@ const Xe = (e) => {
509
512
  error: (f) => a.error(f),
510
513
  config: g
511
514
  });
512
- const p = d(c);
515
+ const d = u(c);
513
516
  o(l).then((f) => {
514
517
  if (f) {
515
518
  const y = [];
516
- p.forEach((w) => {
519
+ d.forEach((w) => {
517
520
  const _ = c.findIndex((E) => E.config === w);
518
521
  if (_ >= 0) {
519
522
  const [E] = c.splice(_, 1);
520
523
  y.push(E);
521
524
  }
522
- }), h(s(p, l)).subscribe({
525
+ }), h(s(d, l)).subscribe({
523
526
  next: (w) => {
524
- if (w.type === Q.Response) {
525
- const _ = w.body, E = i(_, p);
527
+ if (w.type === Z.Response) {
528
+ const _ = w.body, E = i(_, d);
526
529
  y.forEach((A) => {
527
530
  const j = E.find((F) => F.config === A.config);
528
531
  if (j) {
@@ -544,11 +547,11 @@ const Xe = (e) => {
544
547
  }
545
548
  });
546
549
  }) : h(l);
547
- }, qe = 3, je = 1e3, Je = (e) => {
550
+ }, Be = 3, Ge = 1e3, Ye = (e) => {
548
551
  var n, s;
549
- const t = (n = e == null ? void 0 : e.maxRetryAttempts) != null ? n : qe, r = (s = e == null ? void 0 : e.delayInterval) != null ? s : je;
550
- return (o, i) => i(o).pipe(he({ delay: r, count: t }));
551
- }, Ke = (e) => {
552
+ const t = (n = e == null ? void 0 : e.maxRetryAttempts) != null ? n : Be, r = (s = e == null ? void 0 : e.delayInterval) != null ? s : Ge;
553
+ return (o, i) => i(o).pipe(pe({ delay: r, count: t }));
554
+ }, Qe = (e) => {
552
555
  const t = [], r = /* @__PURE__ */ new Set(), n = () => {
553
556
  var s;
554
557
  for (; r.size < ((s = e == null ? void 0 : e.maxParallel) != null ? s : 1) && t.length > 0; ) {
@@ -561,16 +564,16 @@ const Xe = (e) => {
561
564
  next: (l) => i.next(l),
562
565
  error: (l) => i.error(l),
563
566
  complete: () => i.complete()
564
- }), d = () => {
565
- r.delete(c), z(t, c), n();
567
+ }), u = () => {
568
+ r.delete(c), Y(t, c), n();
566
569
  };
567
- return t.push(c), n(), d;
570
+ return t.push(c), n(), u;
568
571
  });
569
- }, ze = J("univer.network.socket.service");
570
- class Ye extends K {
572
+ }, Ze = K("univer.network.socket.service");
573
+ class Pe extends z {
571
574
  createSocket(t) {
572
575
  try {
573
- const r = new WebSocket(t), n = new ie();
576
+ const r = new WebSocket(t), n = new ce();
574
577
  return {
575
578
  URL: t,
576
579
  close: (o, i) => {
@@ -581,20 +584,20 @@ class Ye extends K {
581
584
  },
582
585
  open$: new m((o) => {
583
586
  const i = (c) => o.next(c);
584
- r.addEventListener("open", i), n.add(R(() => r.removeEventListener("open", i)));
585
- }).pipe(b()),
587
+ r.addEventListener("open", i), n.add(I(() => r.removeEventListener("open", i)));
588
+ }).pipe(x()),
586
589
  close$: new m((o) => {
587
590
  const i = (c) => o.next(c);
588
- r.addEventListener("close", i), n.add(R(() => r.removeEventListener("close", i)));
589
- }).pipe(b()),
591
+ r.addEventListener("close", i), n.add(I(() => r.removeEventListener("close", i)));
592
+ }).pipe(x()),
590
593
  error$: new m((o) => {
591
594
  const i = (c) => o.next(c);
592
- r.addEventListener("error", i), n.add(R(() => r.removeEventListener("error", i)));
593
- }).pipe(b()),
595
+ r.addEventListener("error", i), n.add(I(() => r.removeEventListener("error", i)));
596
+ }).pipe(x()),
594
597
  message$: new m((o) => {
595
598
  const i = (c) => o.next(c);
596
- r.addEventListener("message", i), n.add(R(() => r.removeEventListener("message", i)));
597
- }).pipe(b())
599
+ r.addEventListener("message", i), n.add(I(() => r.removeEventListener("message", i)));
600
+ }).pipe(x())
598
601
  };
599
602
  } catch (r) {
600
603
  return console.error(r), null;
@@ -602,23 +605,23 @@ class Ye extends K {
602
605
  }
603
606
  }
604
607
  export {
605
- Xe as AuthInterceptorFactory,
606
- N as FetchHTTPImplementation,
607
- Q as HTTPEventType,
608
- I as HTTPHeaders,
609
- _e as HTTPProgress,
610
- X as HTTPRequest,
608
+ Ke as AuthInterceptorFactory,
609
+ k as FetchHTTPImplementation,
610
+ Z as HTTPEventType,
611
+ b as HTTPHeaders,
612
+ Ie as HTTPProgress,
613
+ V as HTTPRequest,
611
614
  q as HTTPResponse,
612
615
  v as HTTPResponseError,
613
- x as HTTPService,
614
- L as HTTPStatusCode,
615
- Y as IHTTPImplementation,
616
- ze as ISocketService,
617
- Ve as MergeInterceptorFactory,
618
- Ee as ResponseHeader,
619
- Je as RetryInterceptorFactory,
620
- Ke as ThresholdInterceptorFactory,
621
- V as UniverNetworkPlugin,
622
- Ye as WebSocketService,
616
+ L as HTTPService,
617
+ N as HTTPStatusCode,
618
+ Q as IHTTPImplementation,
619
+ Ze as ISocketService,
620
+ ze as MergeInterceptorFactory,
621
+ be as ResponseHeader,
622
+ Ye as RetryInterceptorFactory,
623
+ Qe as ThresholdInterceptorFactory,
624
+ J as UniverNetworkPlugin,
625
+ Pe as WebSocketService,
623
626
  D as XHRHTTPImplementation
624
627
  };