@tarojs/plugin-http 4.0.0-canary.7 → 4.0.0-canary.9

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/LICENSE CHANGED
@@ -158,3 +158,17 @@ MIT (stencil-vue2-output-target):
158
158
  The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
159
159
  `/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
160
160
  See `/LICENSE` for details of the license.
161
+
162
+ ==================
163
+
164
+ MIT (weui):
165
+ The following files embed [stencil-vue2-output-target](https://github.com/Tencent/weui) MIT:
166
+ `/packages/taro-components/src/components/*.scss`
167
+ See `/LICENSE.txt` for details of the license.
168
+
169
+ ==================
170
+
171
+ Apache-2.0 (intersection-observer):
172
+ The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
173
+ `/packages/taro-api/src/polyfill/intersection-observer.ts`
174
+ See `/LICENSE.txt` for details of the license.
package/dist/runtime.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { parseUrl, Events, createEvent, window, document } from '@tarojs/runtime';
2
2
  export { document } from '@tarojs/runtime';
3
- import { isString, isFunction, isWebPlatform } from '@tarojs/shared';
4
3
  import { setStorage, getStorageSync, request } from '@tarojs/taro';
4
+ import { isString, isFunction } from '@tarojs/shared';
5
5
 
6
6
  /******************************************************************************
7
7
  Copyright (c) Microsoft Corporation.
@@ -585,6 +585,7 @@ _XMLHttpRequest_method = new WeakMap(), _XMLHttpRequest_url = new WeakMap(), _XM
585
585
  // 头信息
586
586
  const header = Object.assign({}, __classPrivateFieldGet(this, _XMLHttpRequest_header, "f"));
587
587
  // https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Cookies
588
+ // @ts-ignore
588
589
  header.cookie = window.document.$$cookie;
589
590
  if (!this.withCredentials) {
590
591
  // 不同源,要求 withCredentials 为 true 才携带 cookie
@@ -653,7 +654,7 @@ _XMLHttpRequest_method = new WeakMap(), _XMLHttpRequest_url = new WeakMap(), _XM
653
654
  }
654
655
  }, _XMLHttpRequest_requestFail = function _XMLHttpRequest_requestFail(err) {
655
656
  // 微信小程序,无论接口返回200还是其他,响应无论是否有错误,都会进入 success 回调;只有类似超时这种请求错误才会进入 fail 回调
656
- //
657
+ //
657
658
  /**
658
659
  * 阿里系小程序,接口返回非200状态码,会进入 fail 回调, 此时 err 对象结构如下(当错误码为 14 或 19 时,会多返回 status、data、headers。可通过这些字段获取服务端相关错误信息):
659
660
  {
@@ -695,7 +696,7 @@ XMLHttpRequest.HEADERS_RECEIVED = 2;
695
696
  XMLHttpRequest.LOADING = 3;
696
697
  XMLHttpRequest.DONE = 4;
697
698
 
698
- if (!isWebPlatform()) {
699
+ if (process.env.TARO_PLATFORM !== 'web') {
699
700
  if (ENABLE_COOKIE) {
700
701
  const _cookie = createCookieInstance();
701
702
  Object.defineProperties(document, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/plugin-http",
3
- "version": "4.0.0-canary.7",
3
+ "version": "4.0.0-canary.9",
4
4
  "description": "Taro 小程序端支持使用 web 请求 的插件",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -23,12 +23,12 @@
23
23
  },
24
24
  "homepage": "https://github.com/NervJS/taro#readme",
25
25
  "dependencies": {
26
- "@tarojs/runtime": "4.0.0-canary.7",
27
- "@tarojs/service": "4.0.0-canary.7",
28
- "@tarojs/shared": "4.0.0-canary.7"
26
+ "@tarojs/runtime": "4.0.0-canary.9",
27
+ "@tarojs/service": "4.0.0-canary.9",
28
+ "@tarojs/shared": "4.0.0-canary.9"
29
29
  },
30
30
  "devDependencies": {
31
- "@rollup/plugin-json": "^6.0.0",
31
+ "@rollup/plugin-json": "^6.1.0",
32
32
  "@rollup/plugin-node-resolve": "^15.0.1",
33
33
  "jest": "^29.3.1",
34
34
  "jest-cli": "^29.3.1",
@@ -37,13 +37,13 @@
37
37
  "rollup-plugin-node-externals": "^5.0.0",
38
38
  "rollup-plugin-ts": "^3.0.2",
39
39
  "ts-jest": "^29.0.5",
40
- "tslib": "^2.5.0",
40
+ "tslib": "^2.6.2",
41
41
  "typescript": "^4.7.4"
42
42
  },
43
43
  "scripts": {
44
44
  "dev": "rollup -c -w --bundleConfigAsCjs",
45
45
  "build": "rollup -c --bundleConfigAsCjs",
46
46
  "test": "jest",
47
- "test:ci": "jest --ci -i --coverage false"
47
+ "test:ci": "jest --ci -i --coverage --silent"
48
48
  }
49
49
  }
@@ -3,7 +3,7 @@ describe('DOM', () => {
3
3
  const runtime = require('../../dist/runtime')
4
4
  const document = runtime.document
5
5
  global.document = runtime.document
6
-
6
+
7
7
  describe('document', () => {
8
8
 
9
9
  it('document setCookie', async () => {
@@ -15,6 +15,5 @@ describe('DOM', () => {
15
15
  'aaa=1111-2222-33-444-abcdefgasd; bbb=23123-aswe-4a7a-a740-f55dfd296b1d; ccc=69asd3d81234668942'
16
16
  )
17
17
  })
18
-
19
18
  })
20
19
  })
@@ -83,7 +83,7 @@ function createXMLHttpRequestEvent (event: string, target:XMLHttpRequest, loaded
83
83
  })
84
84
  } catch (err) {
85
85
  // no handler
86
- }
86
+ }
87
87
  return e
88
88
  }
89
89
 
@@ -226,6 +226,7 @@ export class XMLHttpRequest extends Events {
226
226
  // 头信息
227
227
  const header = Object.assign({}, this.#header)
228
228
  // https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Cookies
229
+ // @ts-ignore
229
230
  header.cookie = window.document.$$cookie
230
231
  if (!this.withCredentials) {
231
232
  // 不同源,要求 withCredentials 为 true 才携带 cookie
@@ -314,7 +315,7 @@ export class XMLHttpRequest extends Events {
314
315
  */
315
316
  #requestFail (err) {
316
317
  // 微信小程序,无论接口返回200还是其他,响应无论是否有错误,都会进入 success 回调;只有类似超时这种请求错误才会进入 fail 回调
317
- //
318
+ //
318
319
  /**
319
320
  * 阿里系小程序,接口返回非200状态码,会进入 fail 回调, 此时 err 对象结构如下(当错误码为 14 或 19 时,会多返回 status、data、headers。可通过这些字段获取服务端相关错误信息):
320
321
  {
@@ -1,15 +1,14 @@
1
1
  import { document, window } from '@tarojs/runtime'
2
- import { isWebPlatform } from '@tarojs/shared'
3
2
 
4
3
  import { Cookie, createCookieInstance } from './Cookie'
5
4
  import { type XMLHttpRequestEvent, XMLHttpRequest } from './XMLHttpRequest'
6
5
 
7
6
  declare const ENABLE_COOKIE: boolean
8
7
 
9
- if (!isWebPlatform()) {
8
+ if (process.env.TARO_PLATFORM !== 'web') {
10
9
  if (ENABLE_COOKIE) {
11
10
  const _cookie = createCookieInstance()
12
-
11
+
13
12
  Object.defineProperties(document, {
14
13
  URL: {
15
14
  get () {