@univerjs/network 0.21.1 → 0.22.0-insiders.20260513-09bbeca

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/README.md CHANGED
@@ -1,33 +1,38 @@
1
1
  # @univerjs/network
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@univerjs/network?style=flat-square)](https://npmjs.com/package/@univerjs/network)
4
+ [![license](https://img.shields.io/npm/l/@univerjs/network?style=flat-square)](https://npmjs.com/package/@univerjs/network)
5
+ [![downloads](https://img.shields.io/npm/dm/@univerjs/network?style=flat-square)](https://npmjs.com/package/@univerjs/network)
6
+
7
+ `@univerjs/network` provides basic network service abstractions for Univer runtimes, especially collaboration-oriented integrations.
8
+
3
9
  ## Package Overview
4
10
 
5
- | Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
6
- | --- | --- | --- | --- | --- | :---: | :---: |
7
- | `@univerjs/network` | `UniverNetwork` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
11
+ | Package | UMD global | CSS | Locales | Facade entry |
12
+ | --- | --- | :---: | :---: | :---: |
13
+ | `@univerjs/network` | `UniverNetwork` | No | No | Yes |
8
14
 
9
- ## Introduction
15
+ ## Installation
10
16
 
11
- The `@univerjs/network` library provides basic network service capabilities, primarily for use in collaborative editing scenarios.
17
+ ```sh
18
+ pnpm add @univerjs/network
19
+ # or
20
+ npm install @univerjs/network
21
+ ```
12
22
 
13
- ## Usage
23
+ Keep all `@univerjs/*` packages on the same version.
14
24
 
15
- ### Installation
25
+ ## Usage
16
26
 
17
- ```shell
18
- # Using npm
19
- npm install @univerjs/network
27
+ ```ts
28
+ import { UniverNetworkPlugin } from '@univerjs/network';
20
29
 
21
- # Using pnpm
22
- pnpm add @univerjs/network
30
+ univer.registerPlugin(UniverNetworkPlugin);
23
31
  ```
24
32
 
25
- ## Credit
33
+ ## Resources
26
34
 
27
- This package is inspired by [Angular's implementation](https://github.com/angular/angular/tree/main/packages/common/http). Removed zone.js dependency and features that are not necessary for Univer.
35
+ - [Documentation](https://docs.univer.ai)
36
+ - [NPM package](https://npmjs.com/package/@univerjs/network)
37
+ - [GitHub repository](https://github.com/dream-num/univer)
28
38
 
29
- <!-- Links -->
30
- [npm-version-shield]: https://img.shields.io/npm/v/@univerjs/network?style=flat-square
31
- [npm-version-link]: https://npmjs.com/package/@univerjs/network
32
- [npm-license-shield]: https://img.shields.io/npm/l/@univerjs/network?style=flat-square
33
- [npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/network?style=flat-square
package/lib/cjs/facade.js CHANGED
@@ -2,7 +2,7 @@ let _univerjs_core_facade = require("@univerjs/core/facade");
2
2
  let _univerjs_network = require("@univerjs/network");
3
3
  let _univerjs_core = require("@univerjs/core");
4
4
 
5
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
5
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
6
6
  function __decorateParam(paramIndex, decorator) {
7
7
  return function(target, key) {
8
8
  decorator(target, key, paramIndex);
@@ -10,7 +10,7 @@ function __decorateParam(paramIndex, decorator) {
10
10
  }
11
11
 
12
12
  //#endregion
13
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
13
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
14
14
  function __decorate(decorators, target, key, desc) {
15
15
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
16
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/lib/cjs/index.js CHANGED
@@ -5,7 +5,7 @@ let rxjs_operators = require("rxjs/operators");
5
5
 
6
6
  //#region package.json
7
7
  var name = "@univerjs/network";
8
- var version = "0.21.1";
8
+ var version = "0.22.0-insiders.20260513-09bbeca";
9
9
 
10
10
  //#endregion
11
11
  //#region src/config/config.ts
@@ -14,7 +14,7 @@ const configSymbol = Symbol(NETWORK_PLUGIN_CONFIG_KEY);
14
14
  const defaultPluginConfig = {};
15
15
 
16
16
  //#endregion
17
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
17
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
18
18
  function _typeof(o) {
19
19
  "@babel/helpers - typeof";
20
20
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -25,7 +25,7 @@ function _typeof(o) {
25
25
  }
26
26
 
27
27
  //#endregion
28
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
28
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
29
29
  function toPrimitive(t, r) {
30
30
  if ("object" != _typeof(t) || !t) return t;
31
31
  var e = t[Symbol.toPrimitive];
@@ -38,14 +38,14 @@ function toPrimitive(t, r) {
38
38
  }
39
39
 
40
40
  //#endregion
41
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
41
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
42
42
  function toPropertyKey(t) {
43
43
  var i = toPrimitive(t, "string");
44
44
  return "symbol" == _typeof(i) ? i : i + "";
45
45
  }
46
46
 
47
47
  //#endregion
48
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
48
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
49
49
  function _defineProperty(e, r, t) {
50
50
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
51
51
  value: t,
@@ -182,7 +182,7 @@ var HTTPRequest = class {
182
182
  };
183
183
 
184
184
  //#endregion
185
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
185
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
186
186
  function __decorateParam(paramIndex, decorator) {
187
187
  return function(target, key) {
188
188
  decorator(target, key, paramIndex);
@@ -190,7 +190,7 @@ function __decorateParam(paramIndex, decorator) {
190
190
  }
191
191
 
192
192
  //#endregion
193
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
193
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
194
194
  function __decorate(decorators, target, key, desc) {
195
195
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
196
196
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -384,7 +384,7 @@ let HTTPEventType = /* @__PURE__ */ function(HTTPEventType) {
384
384
  */
385
385
  var HTTPResponse = class {
386
386
  constructor({ body, headers, status, statusText }) {
387
- _defineProperty(this, "type", HTTPEventType.Response);
387
+ _defineProperty(this, "type", 1);
388
388
  _defineProperty(this, "body", void 0);
389
389
  _defineProperty(this, "headers", void 0);
390
390
  _defineProperty(this, "status", void 0);
@@ -403,7 +403,7 @@ var HTTPProgress = class {
403
403
  this.total = total;
404
404
  this.loaded = loaded;
405
405
  this.partialText = partialText;
406
- _defineProperty(this, "type", HTTPEventType.DownloadProgress);
406
+ _defineProperty(this, "type", 0);
407
407
  }
408
408
  };
409
409
  var ResponseHeader = class {
@@ -486,7 +486,7 @@ let FetchHTTPImplementation = class FetchHTTPImplementation {
486
486
  const statusText = response.statusText;
487
487
  let body = null;
488
488
  if (response.body) body = await this._readBody(request, response, subscriber);
489
- if (status >= HTTPStatusCode.Ok && status < HTTPStatusCode.MultipleChoices) subscriber.next(new HTTPResponse({
489
+ if (status >= 200 && status < 300) subscriber.next(new HTTPResponse({
490
490
  body,
491
491
  headers: responseHeaders,
492
492
  status,
@@ -590,7 +590,7 @@ let XHRHTTPImplementation = class XHRHTTPImplementation {
590
590
  const { headers, statusText, status } = buildResponseHeader();
591
591
  let body = null;
592
592
  let error = null;
593
- if (status !== HTTPStatusCode.NoContent) body = typeof xhr.response === "undefined" ? xhr.responseText : xhr.response;
593
+ if (status !== 204) body = typeof xhr.response === "undefined" ? xhr.responseText : xhr.response;
594
594
  let success = status >= 200 && status < 300;
595
595
  if (responseType === "json" && typeof body === "string") {
596
596
  const originalBody = body;
@@ -752,7 +752,7 @@ const MergeInterceptorFactory = (config, options = {}) => {
752
752
  });
753
753
  next(mergeParamsToRequest(list, requestConfig)).subscribe({
754
754
  next: (e) => {
755
- if (e.type === HTTPEventType.Response) {
755
+ if (e.type === 1) {
756
756
  const body = e.body;
757
757
  const configList = distributeResult(body, list);
758
758
  currentHookList.forEach((hookItem) => {
package/lib/es/facade.js CHANGED
@@ -2,7 +2,7 @@ import { FBase, FUniver } from "@univerjs/core/facade";
2
2
  import { HTTPService, WebSocketService } from "@univerjs/network";
3
3
  import { Inject, Injector } from "@univerjs/core";
4
4
 
5
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
5
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
6
6
  function __decorateParam(paramIndex, decorator) {
7
7
  return function(target, key) {
8
8
  decorator(target, key, paramIndex);
@@ -10,7 +10,7 @@ function __decorateParam(paramIndex, decorator) {
10
10
  }
11
11
 
12
12
  //#endregion
13
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
13
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
14
14
  function __decorate(decorators, target, key, desc) {
15
15
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
16
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/lib/es/index.js CHANGED
@@ -4,7 +4,7 @@ import { concatMap, retry, share } from "rxjs/operators";
4
4
 
5
5
  //#region package.json
6
6
  var name = "@univerjs/network";
7
- var version = "0.21.1";
7
+ var version = "0.22.0-insiders.20260513-09bbeca";
8
8
 
9
9
  //#endregion
10
10
  //#region src/config/config.ts
@@ -13,7 +13,7 @@ const configSymbol = Symbol(NETWORK_PLUGIN_CONFIG_KEY);
13
13
  const defaultPluginConfig = {};
14
14
 
15
15
  //#endregion
16
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
16
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
17
17
  function _typeof(o) {
18
18
  "@babel/helpers - typeof";
19
19
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -24,7 +24,7 @@ function _typeof(o) {
24
24
  }
25
25
 
26
26
  //#endregion
27
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
27
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
28
28
  function toPrimitive(t, r) {
29
29
  if ("object" != _typeof(t) || !t) return t;
30
30
  var e = t[Symbol.toPrimitive];
@@ -37,14 +37,14 @@ function toPrimitive(t, r) {
37
37
  }
38
38
 
39
39
  //#endregion
40
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
40
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
41
41
  function toPropertyKey(t) {
42
42
  var i = toPrimitive(t, "string");
43
43
  return "symbol" == _typeof(i) ? i : i + "";
44
44
  }
45
45
 
46
46
  //#endregion
47
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
47
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
48
48
  function _defineProperty(e, r, t) {
49
49
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
50
50
  value: t,
@@ -181,7 +181,7 @@ var HTTPRequest = class {
181
181
  };
182
182
 
183
183
  //#endregion
184
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
184
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
185
185
  function __decorateParam(paramIndex, decorator) {
186
186
  return function(target, key) {
187
187
  decorator(target, key, paramIndex);
@@ -189,7 +189,7 @@ function __decorateParam(paramIndex, decorator) {
189
189
  }
190
190
 
191
191
  //#endregion
192
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
192
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
193
193
  function __decorate(decorators, target, key, desc) {
194
194
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
195
195
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -383,7 +383,7 @@ let HTTPEventType = /* @__PURE__ */ function(HTTPEventType) {
383
383
  */
384
384
  var HTTPResponse = class {
385
385
  constructor({ body, headers, status, statusText }) {
386
- _defineProperty(this, "type", HTTPEventType.Response);
386
+ _defineProperty(this, "type", 1);
387
387
  _defineProperty(this, "body", void 0);
388
388
  _defineProperty(this, "headers", void 0);
389
389
  _defineProperty(this, "status", void 0);
@@ -402,7 +402,7 @@ var HTTPProgress = class {
402
402
  this.total = total;
403
403
  this.loaded = loaded;
404
404
  this.partialText = partialText;
405
- _defineProperty(this, "type", HTTPEventType.DownloadProgress);
405
+ _defineProperty(this, "type", 0);
406
406
  }
407
407
  };
408
408
  var ResponseHeader = class {
@@ -485,7 +485,7 @@ let FetchHTTPImplementation = class FetchHTTPImplementation {
485
485
  const statusText = response.statusText;
486
486
  let body = null;
487
487
  if (response.body) body = await this._readBody(request, response, subscriber);
488
- if (status >= HTTPStatusCode.Ok && status < HTTPStatusCode.MultipleChoices) subscriber.next(new HTTPResponse({
488
+ if (status >= 200 && status < 300) subscriber.next(new HTTPResponse({
489
489
  body,
490
490
  headers: responseHeaders,
491
491
  status,
@@ -589,7 +589,7 @@ let XHRHTTPImplementation = class XHRHTTPImplementation {
589
589
  const { headers, statusText, status } = buildResponseHeader();
590
590
  let body = null;
591
591
  let error = null;
592
- if (status !== HTTPStatusCode.NoContent) body = typeof xhr.response === "undefined" ? xhr.responseText : xhr.response;
592
+ if (status !== 204) body = typeof xhr.response === "undefined" ? xhr.responseText : xhr.response;
593
593
  let success = status >= 200 && status < 300;
594
594
  if (responseType === "json" && typeof body === "string") {
595
595
  const originalBody = body;
@@ -751,7 +751,7 @@ const MergeInterceptorFactory = (config, options = {}) => {
751
751
  });
752
752
  next(mergeParamsToRequest(list, requestConfig)).subscribe({
753
753
  next: (e) => {
754
- if (e.type === HTTPEventType.Response) {
754
+ if (e.type === 1) {
755
755
  const body = e.body;
756
756
  const configList = distributeResult(body, list);
757
757
  currentHookList.forEach((hookItem) => {
package/lib/facade.js CHANGED
@@ -2,7 +2,7 @@ import { FBase, FUniver } from "@univerjs/core/facade";
2
2
  import { HTTPService, WebSocketService } from "@univerjs/network";
3
3
  import { Inject, Injector } from "@univerjs/core";
4
4
 
5
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
5
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
6
6
  function __decorateParam(paramIndex, decorator) {
7
7
  return function(target, key) {
8
8
  decorator(target, key, paramIndex);
@@ -10,7 +10,7 @@ function __decorateParam(paramIndex, decorator) {
10
10
  }
11
11
 
12
12
  //#endregion
13
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
13
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
14
14
  function __decorate(decorators, target, key, desc) {
15
15
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
16
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@ import { concatMap, retry, share } from "rxjs/operators";
4
4
 
5
5
  //#region package.json
6
6
  var name = "@univerjs/network";
7
- var version = "0.21.1";
7
+ var version = "0.22.0-insiders.20260513-09bbeca";
8
8
 
9
9
  //#endregion
10
10
  //#region src/config/config.ts
@@ -13,7 +13,7 @@ const configSymbol = Symbol(NETWORK_PLUGIN_CONFIG_KEY);
13
13
  const defaultPluginConfig = {};
14
14
 
15
15
  //#endregion
16
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
16
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
17
17
  function _typeof(o) {
18
18
  "@babel/helpers - typeof";
19
19
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -24,7 +24,7 @@ function _typeof(o) {
24
24
  }
25
25
 
26
26
  //#endregion
27
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
27
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
28
28
  function toPrimitive(t, r) {
29
29
  if ("object" != _typeof(t) || !t) return t;
30
30
  var e = t[Symbol.toPrimitive];
@@ -37,14 +37,14 @@ function toPrimitive(t, r) {
37
37
  }
38
38
 
39
39
  //#endregion
40
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
40
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
41
41
  function toPropertyKey(t) {
42
42
  var i = toPrimitive(t, "string");
43
43
  return "symbol" == _typeof(i) ? i : i + "";
44
44
  }
45
45
 
46
46
  //#endregion
47
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
47
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
48
48
  function _defineProperty(e, r, t) {
49
49
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
50
50
  value: t,
@@ -181,7 +181,7 @@ var HTTPRequest = class {
181
181
  };
182
182
 
183
183
  //#endregion
184
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
184
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
185
185
  function __decorateParam(paramIndex, decorator) {
186
186
  return function(target, key) {
187
187
  decorator(target, key, paramIndex);
@@ -189,7 +189,7 @@ function __decorateParam(paramIndex, decorator) {
189
189
  }
190
190
 
191
191
  //#endregion
192
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
192
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
193
193
  function __decorate(decorators, target, key, desc) {
194
194
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
195
195
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -383,7 +383,7 @@ let HTTPEventType = /* @__PURE__ */ function(HTTPEventType) {
383
383
  */
384
384
  var HTTPResponse = class {
385
385
  constructor({ body, headers, status, statusText }) {
386
- _defineProperty(this, "type", HTTPEventType.Response);
386
+ _defineProperty(this, "type", 1);
387
387
  _defineProperty(this, "body", void 0);
388
388
  _defineProperty(this, "headers", void 0);
389
389
  _defineProperty(this, "status", void 0);
@@ -402,7 +402,7 @@ var HTTPProgress = class {
402
402
  this.total = total;
403
403
  this.loaded = loaded;
404
404
  this.partialText = partialText;
405
- _defineProperty(this, "type", HTTPEventType.DownloadProgress);
405
+ _defineProperty(this, "type", 0);
406
406
  }
407
407
  };
408
408
  var ResponseHeader = class {
@@ -485,7 +485,7 @@ let FetchHTTPImplementation = class FetchHTTPImplementation {
485
485
  const statusText = response.statusText;
486
486
  let body = null;
487
487
  if (response.body) body = await this._readBody(request, response, subscriber);
488
- if (status >= HTTPStatusCode.Ok && status < HTTPStatusCode.MultipleChoices) subscriber.next(new HTTPResponse({
488
+ if (status >= 200 && status < 300) subscriber.next(new HTTPResponse({
489
489
  body,
490
490
  headers: responseHeaders,
491
491
  status,
@@ -589,7 +589,7 @@ let XHRHTTPImplementation = class XHRHTTPImplementation {
589
589
  const { headers, statusText, status } = buildResponseHeader();
590
590
  let body = null;
591
591
  let error = null;
592
- if (status !== HTTPStatusCode.NoContent) body = typeof xhr.response === "undefined" ? xhr.responseText : xhr.response;
592
+ if (status !== 204) body = typeof xhr.response === "undefined" ? xhr.responseText : xhr.response;
593
593
  let success = status >= 200 && status < 300;
594
594
  if (responseType === "json" && typeof body === "string") {
595
595
  const originalBody = body;
@@ -751,7 +751,7 @@ const MergeInterceptorFactory = (config, options = {}) => {
751
751
  });
752
752
  next(mergeParamsToRequest(list, requestConfig)).subscribe({
753
753
  next: (e) => {
754
- if (e.type === HTTPEventType.Response) {
754
+ if (e.type === 1) {
755
755
  const body = e.body;
756
756
  const configList = distributeResult(body, list);
757
757
  currentHookList.forEach((hookItem) => {
package/lib/umd/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`rxjs`),require(`rxjs/operators`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`,`rxjs/operators`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverNetwork={},e.UniverCore,e.rxjs,e.rxjs.operators))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=`@univerjs/network`,a=`0.21.1`;let o=`network.config`;Symbol(o);let s={};function c(e){"@babel/helpers - typeof";return c=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let f=`application/json`;function p(e){return Array.isArray(e)?e.some(e=>e.includes(f)):e.includes(f)}var m=class{constructor(e){d(this,`_headers`,new Map),typeof e==`string`?this._handleHeadersString(e):e instanceof Headers?this._handleHeaders(e):e&&this._handleHeadersConstructorProps(e)}forEach(e){this._headers.forEach((t,n)=>e(n,t))}has(e){return!!this._headers.has(e.toLowerCase())}get(e){let t=e.toLowerCase();return this._headers.has(t)?this._headers.get(t):null}set(e,t){this._setHeader(e,t)}toHeadersInit(e){let t={};return this._headers.forEach((e,n)=>{t[n]=e.join(`,`)}),t.accept!=null||(t.accept=`application/json, text/plain, */*`),!(e instanceof FormData)&&(t[`content-type`]!=null||(t[`content-type`]=`application/json;charset=UTF-8`)),t}_setHeader(e,t){let n=e.toLowerCase();this._headers.has(n)?this._headers.get(n).push(t.toString()):this._headers.set(n,[t.toString()])}_handleHeadersString(e){e.split(`
2
- `).forEach(e=>{let[t,n]=e.split(`:`);t&&n&&this._setHeader(t,n)})}_handleHeadersConstructorProps(e){Object.entries(e).forEach(([e,t])=>this._setHeader(e,t))}_handleHeaders(e){e.forEach((e,t)=>this._setHeader(t,e))}};let h=(0,t.createIdentifier)(`network.http-implementation`);var g=class{constructor(e){this.params=e}toString(){return this.params?Object.keys(this.params).map(e=>{let t=this.params[e];return Array.isArray(t)?t.map(t=>`${e}=${t}`).join(`&`):`${e}=${t}`}).join(`&`):``}};let _=0;var v=class{get headers(){return this.requestParams.headers}get withCredentials(){return this.requestParams.withCredentials}get responseType(){return this.requestParams.responseType}constructor(e,t,n){this.method=e,this.url=t,this.requestParams=n,d(this,`uid`,_++)}getUrlWithParams(){var e;let t=(e=this.requestParams)==null||(e=e.params)==null?void 0:e.toString();return t?`${this.url}${this.url.includes(`?`)?`&`:`?`}${t}`:this.url}getBody(){var e,t;let n=(e=this.headers.get(`Content-Type`))==null?f:e,r=(t=this.requestParams)==null?void 0:t.body;return r instanceof FormData?r:p(n)&&r&&typeof r==`object`?JSON.stringify(r):r?`${r}`:null}getHeadersInit(){var e;return this.headers.toHeadersInit((e=this.requestParams)==null?void 0:e.body)}};function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let x=class extends t.Disposable{constructor(e){super(),this._http=e,d(this,`_interceptors`,[]),d(this,`_pipe`,void 0)}registerHTTPInterceptor(e){if(this._interceptors.indexOf(e)!==-1)throw Error(`[HTTPService]: The interceptor has already been registered!`);return this._interceptors.push(e),this._interceptors=this._interceptors.sort((e,t)=>{var n,r;return((n=e.priority)==null?0:n)-((r=t.priority)==null?0:r)}),this._pipe=null,(0,t.toDisposable)(()=>(0,t.remove)(this._interceptors,e))}get(e,t){return this.request(`GET`,e,t)}post(e,t){return this.request(`POST`,e,t)}put(e,t){return this.request(`PUT`,e,t)}delete(e,t){return this.request(`DELETE`,e,t)}patch(e,t){return this.request(`PATCH`,e,t)}async request(e,t,i){var a,o;return await(0,n.firstValueFrom)((0,n.of)(new v(e,t,{headers:new m(i==null?void 0:i.headers),params:new g(i==null?void 0:i.params),withCredentials:(a=i==null?void 0:i.withCredentials)==null?!1:a,responseType:(o=i==null?void 0:i.responseType)==null?`json`:o,body:[`GET`,`DELETE`].includes(e)||i==null?void 0:i.body})).pipe((0,r.concatMap)(e=>this._runInterceptorsAndImplementation(e))))}stream(e,t,n){return this.getSSE(e,t,n)}getSSE(e,t,i){var a,o;return(0,n.of)(new v(e,t,{headers:new m(i==null?void 0:i.headers),params:new g(i==null?void 0:i.params),withCredentials:(a=i==null?void 0:i.withCredentials)==null?!1:a,reportProgress:!0,responseType:(o=i==null?void 0:i.responseType)==null?`json`:o,body:[`GET`,`DELETE`].includes(e)||i==null?void 0:i.body})).pipe((0,r.concatMap)(e=>this._runInterceptorsAndImplementation(e)))}_runInterceptorsAndImplementation(e){return this._pipe||(this._pipe=this._interceptors.map(e=>e.interceptor).reduceRight((e,t)=>S(e,t),(e,t)=>t(e))),this._pipe(e,e=>this._http.send(e))}};x=b([y(0,h)],x);function S(e,t){return(n,r)=>t(n,t=>e(t,r))}let C=function(e){return 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}({}),w=function(e){return e[e.DownloadProgress=0]=`DownloadProgress`,e[e.Response=1]=`Response`,e}({});var T=class{constructor({body:e,headers:t,status:n,statusText:r}){d(this,`type`,w.Response),d(this,`body`,void 0),d(this,`headers`,void 0),d(this,`status`,void 0),d(this,`statusText`,void 0),this.body=e,this.headers=t,this.status=n,this.statusText=r}},E=class{constructor(e,t,n){this.total=e,this.loaded=t,this.partialText=n,d(this,`type`,w.DownloadProgress)}},D=class{constructor(e,t,n){this.headers=e,this.status=t,this.statusText=n}},O=class{constructor({request:e,headers:t,status:n,statusText:r,error:i}){d(this,`request`,void 0),d(this,`headers`,void 0),d(this,`status`,void 0),d(this,`statusText`,void 0),d(this,`error`,void 0),this.request=e,this.headers=t,this.status=n,this.statusText=r,this.error=i}};function k(e){return{method:e.method,headers:e.getHeadersInit(),body:e.getBody(),credentials:e.withCredentials?`include`:void 0}}let A=class{constructor(e){this._logService=e}send(e){return new n.Observable(t=>{let n=new AbortController;return this._send(e,t,n).catch(n=>{t.error(new O({error:n,request:e}))}),()=>n.abort()})}async _send(e,t,n){let r;try{let t=k(e),i=e.getUrlWithParams(),a=fetch(i,{signal:n.signal,...t});this._logService.debug(`[FetchHTTPImplementation]: sending request to url ${i} with params ${t}`),r=await a}catch(n){var i,a;let r=new O({request:e,error:n,status:(i=n.status)==null?0:i,statusText:(a=n.statusText)==null?`Unknown Error`:a,headers:n.headers});this._logService.error(`[FetchHTTPImplementation]: network error`,r),t.error(r);return}let o=new m(r.headers),s=r.status,c=r.statusText,l=null;if(r.body&&(l=await this._readBody(e,r,t)),s>=C.Ok&&s<C.MultipleChoices)t.next(new T({body:l,headers:o,status:s,statusText:c}));else{let n=new O({request:e,error:l,status:s,statusText:c,headers:o});this._logService.error(`[FetchHTTPImplementation]: network error`,n),t.error(n)}t.complete()}async _readBody(e,t,n){var r;let i=[],a=t.body.getReader(),o=t.headers.get(`content-length`),s=0,c=(r=e.requestParams)==null?void 0:r.reportProgress,l=e.responseType,u,d;for(;;){let{done:e,value:t}=await a.read();if(e)break;if(i.push(t),s+=t.length,c&&l===`text`){var f,p;u=((f=u)==null?``:f)+((p=d)==null?d=new TextDecoder:p).decode(t,{stream:!0}),n.next(new E(o?Number.parseInt(o,10):void 0,s,u))}}let h=j(i,s);try{var g;return N(e,h,(g=t.headers.get(`content-type`))==null?``:g)}catch(r){let i=new O({request:e,error:r,status:t.status,statusText:t.statusText,headers:new m(t.headers)});return this._logService.error(`[FetchHTTPImplementation]: network error`,i),n.error(i),null}}};A=b([y(0,t.ILogService)],A);function j(e,t){let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let M=/^\)\]\}',?\n/;function N(e,t,n){switch(e.responseType){case`json`:let r=new TextDecoder().decode(t).replace(M,``);return r===``?null:JSON.parse(r);case`text`:return new TextDecoder().decode(t);case`blob`:return new Blob([t.buffer],{type:n});case`arraybuffer`:return t.buffer;default:throw Error(`[FetchHTTPImplementation]: unknown response type: ${e.responseType}.`)}}let P=class{constructor(e){this._logService=e}send(e){return new n.Observable(t=>{let n=new XMLHttpRequest,r=e.getUrlWithParams(),i=k(e),{responseType:a}=e;n.open(e.method,r),e.withCredentials&&(n.withCredentials=!0),i.headers&&Object.entries(i.headers).forEach(([e,t])=>n.setRequestHeader(e,t));let o=()=>{let e=n.statusText||`OK`;return new D(new m(n.getAllResponseHeaders()),n.status,e)},s=()=>{let{headers:r,statusText:i,status:s}=o(),c=null,l=null;s!==C.NoContent&&(c=n.response===void 0?n.responseText:n.response);let u=s>=200&&s<300;if(a===`json`&&typeof c==`string`){let e=c;try{c=c?JSON.parse(c):null}catch(t){u=!1,c=e,l=t}}if(a===`blob`&&!(c instanceof Blob)&&(u=!1,l=Error(`Response is not a Blob object`)),u)t.next(new T({body:c,headers:r,status:s,statusText:i}));else{let n=new O({request:e,error:l,headers:r,status:s,statusText:i});this._logService.error(`[XHRHTTPImplementation]: network error`,n),t.error(n)}},c=r=>{let i=new O({request:e,error:r,status:n.status||0,statusText:n.statusText||`Unknown Error`,headers:o().headers});this._logService.error(`[XHRHTTPImplementation]: network error`,i),t.error(i)};n.responseType=a||``,n.addEventListener(`load`,s),n.addEventListener(`error`,c),n.addEventListener(`abort`,c),n.addEventListener(`timeout`,c);let l=e.getBody();return n.send(l),this._logService.debug(`[XHRHTTPImplementation]`,`sending request to url ${r} with params ${i}`),()=>{n.readyState!==n.DONE&&n.abort(),n.removeEventListener(`load`,s),n.removeEventListener(`error`,c),n.removeEventListener(`abort`,c),n.removeEventListener(`timeout`,c)}})}};P=b([y(0,t.ILogService)],P);let F=class extends t.Plugin{constructor(e=s,n,r,i){super(),this._config=e,this._logger=n,this._injector=r,this._configService=i;let{...a}=(0,t.merge)({},s,this._config);this._configService.setConfig(o,a)}onStarting(){var e,n,r;if(this._injector.get(x,t.Quantity.OPTIONAL,t.LookUp.SKIP_SELF)&&!((e=this._config)!=null&&e.forceUseNewInstance)){this._logger.warn(`[UniverNetworkPlugin]`,`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.`);return}let i=(n=this._config)!=null&&n.useFetchImpl?A:typeof window<`u`?P:A;(0,t.registerDependencies)(this._injector,(0,t.mergeOverrideWithDependencies)([[x],[h,{useClass:i}]],(r=this._config)==null?void 0:r.override))}};d(F,`pluginName`,`UNIVER_NETWORK_PLUGIN`),d(F,`packageName`,i),d(F,`version`,a),F=b([y(1,t.ILogService),y(2,(0,t.Inject)(t.Injector)),y(3,t.IConfigService)],F);let I=e=>{let{errorStatusCodes:t,onAuthError:r}=e;return(e,i)=>i(e).pipe((0,n.catchError)(e=>(e instanceof O&&t.some(t=>t===e.status)&&r(),(0,n.throwError)(()=>e))))},L=(e=300)=>{let t=()=>{};return n=>new Promise(n=>{t();let r=setTimeout(()=>{n(!0)},e);t=()=>{clearTimeout(r),n(!1)}})},R=()=>(e,t)=>t.map(t=>({config:t,result:e})),z=(e,t={})=>{let{isMatch:r,getParamsFromRequest:i,mergeParamsToRequest:a}=e,{fetchCheck:o=L(300),distributeResult:s=R()}=t,c=[],l=e=>e.map(e=>e.config);return(e,t)=>r(e)?new n.Observable(n=>{let r=i(e);c.push({next:e=>n.next(e),error:e=>n.error(e),config:r});let u=l(c);o(e).then(r=>{if(r){let r=[];u.forEach(e=>{let t=c.findIndex(t=>t.config===e);if(t>=0){let[e]=c.splice(t,1);r.push(e)}}),t(a(u,e)).subscribe({next:e=>{if(e.type===w.Response){let t=e.body,n=s(t,u);r.forEach(t=>{let r=n.find(e=>e.config===t.config);if(r){let n=new T({body:r.result,headers:e.headers,status:e.status,statusText:e.statusText});t.next(n)}else t.error(`batch error`)})}},complete:()=>n.complete(),error:e=>n.error(e)})}})}):t(e)},B=e=>{var t,n;let i=(t=e==null?void 0:e.maxRetryAttempts)==null?3:t,a=(n=e==null?void 0:e.delayInterval)==null?1e3:n;return(e,t)=>t(e).pipe((0,r.retry)({delay:a,count:i}))},V=e=>{let r=[],i=new Set,a=()=>{for(var t;i.size<((t=e==null?void 0:e.maxParallel)==null?1:t)&&r.length>0;){let e=r.shift();i.add(e),e()}};return(e,o)=>new n.Observable(n=>{let s=()=>o(e).subscribe({next:e=>n.next(e),error:e=>n.error(e),complete:()=>n.complete()});return r.push(s),a(),()=>{i.delete(s),(0,t.remove)(r,s),a()}})},H=(0,t.createIdentifier)(`univer.network.socket.service`);var U=class extends t.Disposable{createSocket(e){try{let i=new WebSocket(e),a=new t.DisposableCollection;return{URL:e,close:(e,t)=>{i.close(e,t),a.dispose()},send:e=>{i.send(e)},open$:new n.Observable(e=>{let n=t=>e.next(t);i.addEventListener(`open`,n),a.add((0,t.toDisposable)(()=>i.removeEventListener(`open`,n)))}).pipe((0,r.share)()),close$:new n.Observable(e=>{let n=t=>e.next(t);i.addEventListener(`close`,n),a.add((0,t.toDisposable)(()=>i.removeEventListener(`close`,n)))}).pipe((0,r.share)()),error$:new n.Observable(e=>{let n=t=>e.next(t);i.addEventListener(`error`,n),a.add((0,t.toDisposable)(()=>i.removeEventListener(`error`,n)))}).pipe((0,r.share)()),message$:new n.Observable(e=>{let n=t=>e.next(t);i.addEventListener(`message`,n),a.add((0,t.toDisposable)(()=>i.removeEventListener(`message`,n)))}).pipe((0,r.share)())}}catch(e){return console.error(e),null}}};e.AuthInterceptorFactory=I,Object.defineProperty(e,`FetchHTTPImplementation`,{enumerable:!0,get:function(){return A}}),e.HTTPEventType=w,e.HTTPHeaders=m,e.HTTPProgress=E,e.HTTPRequest=v,e.HTTPResponse=T,e.HTTPResponseError=O,Object.defineProperty(e,`HTTPService`,{enumerable:!0,get:function(){return x}}),e.HTTPStatusCode=C,e.IHTTPImplementation=h,e.ISocketService=H,e.MergeInterceptorFactory=z,e.ResponseHeader=D,e.RetryInterceptorFactory=B,e.ThresholdInterceptorFactory=V,Object.defineProperty(e,`UniverNetworkPlugin`,{enumerable:!0,get:function(){return F}}),e.WebSocketService=U,Object.defineProperty(e,`XHRHTTPImplementation`,{enumerable:!0,get:function(){return P}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`rxjs`),require(`rxjs/operators`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`,`rxjs/operators`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverNetwork={},e.UniverCore,e.rxjs,e.rxjs.operators))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=`@univerjs/network`,a=`0.22.0-insiders.20260513-09bbeca`;let o=`network.config`;Symbol(o);let s={};function c(e){"@babel/helpers - typeof";return c=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let f=`application/json`;function p(e){return Array.isArray(e)?e.some(e=>e.includes(f)):e.includes(f)}var m=class{constructor(e){d(this,`_headers`,new Map),typeof e==`string`?this._handleHeadersString(e):e instanceof Headers?this._handleHeaders(e):e&&this._handleHeadersConstructorProps(e)}forEach(e){this._headers.forEach((t,n)=>e(n,t))}has(e){return!!this._headers.has(e.toLowerCase())}get(e){let t=e.toLowerCase();return this._headers.has(t)?this._headers.get(t):null}set(e,t){this._setHeader(e,t)}toHeadersInit(e){let t={};return this._headers.forEach((e,n)=>{t[n]=e.join(`,`)}),t.accept!=null||(t.accept=`application/json, text/plain, */*`),!(e instanceof FormData)&&(t[`content-type`]!=null||(t[`content-type`]=`application/json;charset=UTF-8`)),t}_setHeader(e,t){let n=e.toLowerCase();this._headers.has(n)?this._headers.get(n).push(t.toString()):this._headers.set(n,[t.toString()])}_handleHeadersString(e){e.split(`
2
+ `).forEach(e=>{let[t,n]=e.split(`:`);t&&n&&this._setHeader(t,n)})}_handleHeadersConstructorProps(e){Object.entries(e).forEach(([e,t])=>this._setHeader(e,t))}_handleHeaders(e){e.forEach((e,t)=>this._setHeader(t,e))}};let h=(0,t.createIdentifier)(`network.http-implementation`);var g=class{constructor(e){this.params=e}toString(){return this.params?Object.keys(this.params).map(e=>{let t=this.params[e];return Array.isArray(t)?t.map(t=>`${e}=${t}`).join(`&`):`${e}=${t}`}).join(`&`):``}};let _=0;var v=class{get headers(){return this.requestParams.headers}get withCredentials(){return this.requestParams.withCredentials}get responseType(){return this.requestParams.responseType}constructor(e,t,n){this.method=e,this.url=t,this.requestParams=n,d(this,`uid`,_++)}getUrlWithParams(){var e;let t=(e=this.requestParams)==null||(e=e.params)==null?void 0:e.toString();return t?`${this.url}${this.url.includes(`?`)?`&`:`?`}${t}`:this.url}getBody(){var e,t;let n=(e=this.headers.get(`Content-Type`))==null?f:e,r=(t=this.requestParams)==null?void 0:t.body;return r instanceof FormData?r:p(n)&&r&&typeof r==`object`?JSON.stringify(r):r?`${r}`:null}getHeadersInit(){var e;return this.headers.toHeadersInit((e=this.requestParams)==null?void 0:e.body)}};function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let x=class extends t.Disposable{constructor(e){super(),this._http=e,d(this,`_interceptors`,[]),d(this,`_pipe`,void 0)}registerHTTPInterceptor(e){if(this._interceptors.indexOf(e)!==-1)throw Error(`[HTTPService]: The interceptor has already been registered!`);return this._interceptors.push(e),this._interceptors=this._interceptors.sort((e,t)=>{var n,r;return((n=e.priority)==null?0:n)-((r=t.priority)==null?0:r)}),this._pipe=null,(0,t.toDisposable)(()=>(0,t.remove)(this._interceptors,e))}get(e,t){return this.request(`GET`,e,t)}post(e,t){return this.request(`POST`,e,t)}put(e,t){return this.request(`PUT`,e,t)}delete(e,t){return this.request(`DELETE`,e,t)}patch(e,t){return this.request(`PATCH`,e,t)}async request(e,t,i){var a,o;return await(0,n.firstValueFrom)((0,n.of)(new v(e,t,{headers:new m(i==null?void 0:i.headers),params:new g(i==null?void 0:i.params),withCredentials:(a=i==null?void 0:i.withCredentials)==null?!1:a,responseType:(o=i==null?void 0:i.responseType)==null?`json`:o,body:[`GET`,`DELETE`].includes(e)||i==null?void 0:i.body})).pipe((0,r.concatMap)(e=>this._runInterceptorsAndImplementation(e))))}stream(e,t,n){return this.getSSE(e,t,n)}getSSE(e,t,i){var a,o;return(0,n.of)(new v(e,t,{headers:new m(i==null?void 0:i.headers),params:new g(i==null?void 0:i.params),withCredentials:(a=i==null?void 0:i.withCredentials)==null?!1:a,reportProgress:!0,responseType:(o=i==null?void 0:i.responseType)==null?`json`:o,body:[`GET`,`DELETE`].includes(e)||i==null?void 0:i.body})).pipe((0,r.concatMap)(e=>this._runInterceptorsAndImplementation(e)))}_runInterceptorsAndImplementation(e){return this._pipe||(this._pipe=this._interceptors.map(e=>e.interceptor).reduceRight((e,t)=>S(e,t),(e,t)=>t(e))),this._pipe(e,e=>this._http.send(e))}};x=b([y(0,h)],x);function S(e,t){return(n,r)=>t(n,t=>e(t,r))}let C=function(e){return 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}({}),w=function(e){return e[e.DownloadProgress=0]=`DownloadProgress`,e[e.Response=1]=`Response`,e}({});var T=class{constructor({body:e,headers:t,status:n,statusText:r}){d(this,`type`,1),d(this,`body`,void 0),d(this,`headers`,void 0),d(this,`status`,void 0),d(this,`statusText`,void 0),this.body=e,this.headers=t,this.status=n,this.statusText=r}},E=class{constructor(e,t,n){this.total=e,this.loaded=t,this.partialText=n,d(this,`type`,0)}},D=class{constructor(e,t,n){this.headers=e,this.status=t,this.statusText=n}},O=class{constructor({request:e,headers:t,status:n,statusText:r,error:i}){d(this,`request`,void 0),d(this,`headers`,void 0),d(this,`status`,void 0),d(this,`statusText`,void 0),d(this,`error`,void 0),this.request=e,this.headers=t,this.status=n,this.statusText=r,this.error=i}};function k(e){return{method:e.method,headers:e.getHeadersInit(),body:e.getBody(),credentials:e.withCredentials?`include`:void 0}}let A=class{constructor(e){this._logService=e}send(e){return new n.Observable(t=>{let n=new AbortController;return this._send(e,t,n).catch(n=>{t.error(new O({error:n,request:e}))}),()=>n.abort()})}async _send(e,t,n){let r;try{let t=k(e),i=e.getUrlWithParams(),a=fetch(i,{signal:n.signal,...t});this._logService.debug(`[FetchHTTPImplementation]: sending request to url ${i} with params ${t}`),r=await a}catch(n){var i,a;let r=new O({request:e,error:n,status:(i=n.status)==null?0:i,statusText:(a=n.statusText)==null?`Unknown Error`:a,headers:n.headers});this._logService.error(`[FetchHTTPImplementation]: network error`,r),t.error(r);return}let o=new m(r.headers),s=r.status,c=r.statusText,l=null;if(r.body&&(l=await this._readBody(e,r,t)),s>=200&&s<300)t.next(new T({body:l,headers:o,status:s,statusText:c}));else{let n=new O({request:e,error:l,status:s,statusText:c,headers:o});this._logService.error(`[FetchHTTPImplementation]: network error`,n),t.error(n)}t.complete()}async _readBody(e,t,n){var r;let i=[],a=t.body.getReader(),o=t.headers.get(`content-length`),s=0,c=(r=e.requestParams)==null?void 0:r.reportProgress,l=e.responseType,u,d;for(;;){let{done:e,value:t}=await a.read();if(e)break;if(i.push(t),s+=t.length,c&&l===`text`){var f,p;u=((f=u)==null?``:f)+((p=d)==null?d=new TextDecoder:p).decode(t,{stream:!0}),n.next(new E(o?Number.parseInt(o,10):void 0,s,u))}}let h=j(i,s);try{var g;return N(e,h,(g=t.headers.get(`content-type`))==null?``:g)}catch(r){let i=new O({request:e,error:r,status:t.status,statusText:t.statusText,headers:new m(t.headers)});return this._logService.error(`[FetchHTTPImplementation]: network error`,i),n.error(i),null}}};A=b([y(0,t.ILogService)],A);function j(e,t){let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let M=/^\)\]\}',?\n/;function N(e,t,n){switch(e.responseType){case`json`:let r=new TextDecoder().decode(t).replace(M,``);return r===``?null:JSON.parse(r);case`text`:return new TextDecoder().decode(t);case`blob`:return new Blob([t.buffer],{type:n});case`arraybuffer`:return t.buffer;default:throw Error(`[FetchHTTPImplementation]: unknown response type: ${e.responseType}.`)}}let P=class{constructor(e){this._logService=e}send(e){return new n.Observable(t=>{let n=new XMLHttpRequest,r=e.getUrlWithParams(),i=k(e),{responseType:a}=e;n.open(e.method,r),e.withCredentials&&(n.withCredentials=!0),i.headers&&Object.entries(i.headers).forEach(([e,t])=>n.setRequestHeader(e,t));let o=()=>{let e=n.statusText||`OK`;return new D(new m(n.getAllResponseHeaders()),n.status,e)},s=()=>{let{headers:r,statusText:i,status:s}=o(),c=null,l=null;s!==204&&(c=n.response===void 0?n.responseText:n.response);let u=s>=200&&s<300;if(a===`json`&&typeof c==`string`){let e=c;try{c=c?JSON.parse(c):null}catch(t){u=!1,c=e,l=t}}if(a===`blob`&&!(c instanceof Blob)&&(u=!1,l=Error(`Response is not a Blob object`)),u)t.next(new T({body:c,headers:r,status:s,statusText:i}));else{let n=new O({request:e,error:l,headers:r,status:s,statusText:i});this._logService.error(`[XHRHTTPImplementation]: network error`,n),t.error(n)}},c=r=>{let i=new O({request:e,error:r,status:n.status||0,statusText:n.statusText||`Unknown Error`,headers:o().headers});this._logService.error(`[XHRHTTPImplementation]: network error`,i),t.error(i)};n.responseType=a||``,n.addEventListener(`load`,s),n.addEventListener(`error`,c),n.addEventListener(`abort`,c),n.addEventListener(`timeout`,c);let l=e.getBody();return n.send(l),this._logService.debug(`[XHRHTTPImplementation]`,`sending request to url ${r} with params ${i}`),()=>{n.readyState!==n.DONE&&n.abort(),n.removeEventListener(`load`,s),n.removeEventListener(`error`,c),n.removeEventListener(`abort`,c),n.removeEventListener(`timeout`,c)}})}};P=b([y(0,t.ILogService)],P);let F=class extends t.Plugin{constructor(e=s,n,r,i){super(),this._config=e,this._logger=n,this._injector=r,this._configService=i;let{...a}=(0,t.merge)({},s,this._config);this._configService.setConfig(o,a)}onStarting(){var e,n,r;if(this._injector.get(x,t.Quantity.OPTIONAL,t.LookUp.SKIP_SELF)&&!((e=this._config)!=null&&e.forceUseNewInstance)){this._logger.warn(`[UniverNetworkPlugin]`,`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.`);return}let i=(n=this._config)!=null&&n.useFetchImpl?A:typeof window<`u`?P:A;(0,t.registerDependencies)(this._injector,(0,t.mergeOverrideWithDependencies)([[x],[h,{useClass:i}]],(r=this._config)==null?void 0:r.override))}};d(F,`pluginName`,`UNIVER_NETWORK_PLUGIN`),d(F,`packageName`,i),d(F,`version`,a),F=b([y(1,t.ILogService),y(2,(0,t.Inject)(t.Injector)),y(3,t.IConfigService)],F);let I=e=>{let{errorStatusCodes:t,onAuthError:r}=e;return(e,i)=>i(e).pipe((0,n.catchError)(e=>(e instanceof O&&t.some(t=>t===e.status)&&r(),(0,n.throwError)(()=>e))))},L=(e=300)=>{let t=()=>{};return n=>new Promise(n=>{t();let r=setTimeout(()=>{n(!0)},e);t=()=>{clearTimeout(r),n(!1)}})},R=()=>(e,t)=>t.map(t=>({config:t,result:e})),z=(e,t={})=>{let{isMatch:r,getParamsFromRequest:i,mergeParamsToRequest:a}=e,{fetchCheck:o=L(300),distributeResult:s=R()}=t,c=[],l=e=>e.map(e=>e.config);return(e,t)=>r(e)?new n.Observable(n=>{let r=i(e);c.push({next:e=>n.next(e),error:e=>n.error(e),config:r});let u=l(c);o(e).then(r=>{if(r){let r=[];u.forEach(e=>{let t=c.findIndex(t=>t.config===e);if(t>=0){let[e]=c.splice(t,1);r.push(e)}}),t(a(u,e)).subscribe({next:e=>{if(e.type===1){let t=e.body,n=s(t,u);r.forEach(t=>{let r=n.find(e=>e.config===t.config);if(r){let n=new T({body:r.result,headers:e.headers,status:e.status,statusText:e.statusText});t.next(n)}else t.error(`batch error`)})}},complete:()=>n.complete(),error:e=>n.error(e)})}})}):t(e)},B=e=>{var t,n;let i=(t=e==null?void 0:e.maxRetryAttempts)==null?3:t,a=(n=e==null?void 0:e.delayInterval)==null?1e3:n;return(e,t)=>t(e).pipe((0,r.retry)({delay:a,count:i}))},V=e=>{let r=[],i=new Set,a=()=>{for(var t;i.size<((t=e==null?void 0:e.maxParallel)==null?1:t)&&r.length>0;){let e=r.shift();i.add(e),e()}};return(e,o)=>new n.Observable(n=>{let s=()=>o(e).subscribe({next:e=>n.next(e),error:e=>n.error(e),complete:()=>n.complete()});return r.push(s),a(),()=>{i.delete(s),(0,t.remove)(r,s),a()}})},H=(0,t.createIdentifier)(`univer.network.socket.service`);var U=class extends t.Disposable{createSocket(e){try{let i=new WebSocket(e),a=new t.DisposableCollection;return{URL:e,close:(e,t)=>{i.close(e,t),a.dispose()},send:e=>{i.send(e)},open$:new n.Observable(e=>{let n=t=>e.next(t);i.addEventListener(`open`,n),a.add((0,t.toDisposable)(()=>i.removeEventListener(`open`,n)))}).pipe((0,r.share)()),close$:new n.Observable(e=>{let n=t=>e.next(t);i.addEventListener(`close`,n),a.add((0,t.toDisposable)(()=>i.removeEventListener(`close`,n)))}).pipe((0,r.share)()),error$:new n.Observable(e=>{let n=t=>e.next(t);i.addEventListener(`error`,n),a.add((0,t.toDisposable)(()=>i.removeEventListener(`error`,n)))}).pipe((0,r.share)()),message$:new n.Observable(e=>{let n=t=>e.next(t);i.addEventListener(`message`,n),a.add((0,t.toDisposable)(()=>i.removeEventListener(`message`,n)))}).pipe((0,r.share)())}}catch(e){return console.error(e),null}}};e.AuthInterceptorFactory=I,Object.defineProperty(e,`FetchHTTPImplementation`,{enumerable:!0,get:function(){return A}}),e.HTTPEventType=w,e.HTTPHeaders=m,e.HTTPProgress=E,e.HTTPRequest=v,e.HTTPResponse=T,e.HTTPResponseError=O,Object.defineProperty(e,`HTTPService`,{enumerable:!0,get:function(){return x}}),e.HTTPStatusCode=C,e.IHTTPImplementation=h,e.ISocketService=H,e.MergeInterceptorFactory=z,e.ResponseHeader=D,e.RetryInterceptorFactory=B,e.ThresholdInterceptorFactory=V,Object.defineProperty(e,`UniverNetworkPlugin`,{enumerable:!0,get:function(){return F}}),e.WebSocketService=U,Object.defineProperty(e,`XHRHTTPImplementation`,{enumerable:!0,get:function(){return P}})});
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@univerjs/network",
3
- "version": "0.21.1",
3
+ "version": "0.22.0-insiders.20260513-09bbeca",
4
4
  "private": false,
5
- "author": "DreamNum <developer@univer.ai>",
5
+ "description": "Network service abstractions for Univer runtime integrations.",
6
+ "author": "DreamNum Co., Ltd. <developer@univer.ai>",
6
7
  "license": "Apache-2.0",
7
8
  "funding": {
8
9
  "type": "opencollective",
@@ -17,7 +18,11 @@
17
18
  "url": "https://github.com/dream-num/univer/issues"
18
19
  },
19
20
  "keywords": [
20
- "univer"
21
+ "univer",
22
+ "network",
23
+ "http",
24
+ "collaboration",
25
+ "plugin"
21
26
  ],
22
27
  "exports": {
23
28
  ".": {
@@ -57,13 +62,13 @@
57
62
  "rxjs": ">=7.0.0"
58
63
  },
59
64
  "dependencies": {
60
- "@univerjs/core": "0.21.1"
65
+ "@univerjs/core": "0.22.0-insiders.20260513-09bbeca"
61
66
  },
62
67
  "devDependencies": {
63
68
  "rxjs": "^7.8.2",
64
- "typescript": "^6.0.2",
65
- "vitest": "^4.1.4",
66
- "@univerjs-infra/shared": "0.21.1"
69
+ "typescript": "^6.0.3",
70
+ "vitest": "^4.1.5",
71
+ "@univerjs-infra/shared": "0.22.0"
67
72
  },
68
73
  "scripts": {
69
74
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS