@jetlinks-web/core 2.2.8 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +8 -3
  2. package/src/fetch.ts +6 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetlinks-web/core",
3
- "version": "2.2.8",
3
+ "version": "2.2.10",
4
4
  "main": "index.ts",
5
5
  "module": "index.ts",
6
6
  "keywords": [
@@ -15,15 +15,20 @@
15
15
  "src",
16
16
  "index.ts"
17
17
  ],
18
+ "sideEffects": [
19
+ "./src/axios.ts",
20
+ "./src/fetch.ts",
21
+ "./src/websocket.ts"
22
+ ],
18
23
  "private": false,
19
24
  "author": "",
20
25
  "license": "ISC",
21
26
  "dependencies": {
22
27
  "axios": "^1.7.4",
23
28
  "rxjs": "^7.8.1",
24
- "@jetlinks-web/types": "^1.0.2",
25
29
  "@jetlinks-web/constants": "^1.0.9",
26
- "@jetlinks-web/utils": "^1.2.8"
30
+ "@jetlinks-web/utils": "^1.2.9",
31
+ "@jetlinks-web/types": "^1.0.2"
27
32
  },
28
33
  "publishConfig": {
29
34
  "registry": "https://registry.npmjs.org/",
package/src/fetch.ts CHANGED
@@ -3,14 +3,13 @@ import {BASE_API, TOKEN_KEY} from "@jetlinks-web/constants";
3
3
  import {isFunction, isObject} from "lodash-es";
4
4
  import { Observable, } from 'rxjs'
5
5
 
6
- const controller = new AbortController();
7
-
8
6
  export class NdJson {
9
7
  options: any = {
10
8
  code: 200,
11
9
  codeKey: 'status'
12
10
  }
13
11
  isRead = false
12
+ controller = null
14
13
  constructor() {}
15
14
 
16
15
  create(options) {
@@ -24,6 +23,8 @@ export class NdJson {
24
23
  get(url, data = '{}', extra = {}) {
25
24
  const _url = this.getUrl(url)
26
25
  const that = this
26
+ const controller = this.controller = new AbortController();
27
+
27
28
  return new Observable(observer => {
28
29
  let reader
29
30
  fetch(
@@ -101,6 +102,7 @@ export class NdJson {
101
102
  post(url, data={}, extra = {}) {
102
103
  const _url = this.getUrl(url)
103
104
  const that = this
105
+ const controller = this.controller = new AbortController();
104
106
 
105
107
  return new Observable(observer => {
106
108
  let reader
@@ -222,7 +224,8 @@ export class NdJson {
222
224
  if (this.isRead) {
223
225
  this.isRead = false
224
226
  }
225
- controller.abort()
227
+
228
+ this.controller.abort()
226
229
  }
227
230
  }
228
231