@opra/client 0.27.0 → 0.27.2

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/browser.js CHANGED
@@ -20,7 +20,7 @@ import { OpraURL as OpraURL3 } from "@opra/common";
20
20
  // ../../build/client/esm/impl/http-request-observable.js
21
21
  import { lastValueFrom, Observable } from "rxjs";
22
22
  import { isReadableStreamLike } from "rxjs/internal/util/isReadableStreamLike";
23
- import typeIs from "type-is";
23
+ import typeIs from "@browsery/type-is";
24
24
  import { isBlob, OpraURL as OpraURL2 } from "@opra/common";
25
25
 
26
26
  // ../../build/client/esm/client-error.js
@@ -76,7 +76,6 @@ var HttpRequest = class {
76
76
  this.method = (init?.method || "GET").toUpperCase();
77
77
  this.mode = init?.mode || "cors";
78
78
  this.redirect = init?.redirect || "follow";
79
- this.mode = init?.mode || "cors";
80
79
  this.referrer = init?.referrer || "";
81
80
  this.referrerPolicy = init?.referrerPolicy || "";
82
81
  this.signal = init?.signal || new AbortController().signal;
@@ -113,6 +112,15 @@ var HttpRequestObservable = class extends Observable {
113
112
  }
114
113
  }, (error) => subscriber.error(error), () => subscriber.complete());
115
114
  });
115
+ const url = new OpraURL2(init?.url);
116
+ Object.defineProperty(this, kContext, {
117
+ enumerable: false,
118
+ value: {
119
+ headers: new Headers(init?.headers),
120
+ params: url.searchParams,
121
+ requestInit: { ...init }
122
+ }
123
+ });
116
124
  Object.defineProperty(this, kClient, {
117
125
  enumerable: false,
118
126
  value: client
@@ -278,7 +286,7 @@ var HttpRequestObservable = class extends Observable {
278
286
  } else if (isBlob(request.body)) {
279
287
  contentType = request.body.type || "application/octet-stream";
280
288
  body = request.body;
281
- request.headers.set("Content-Size", String(request.body.length));
289
+ request.headers.set("Content-Size", String(request.body.size));
282
290
  delete request.duplex;
283
291
  } else {
284
292
  contentType = "application/json";
@@ -4,7 +4,7 @@ exports.HttpRequestObservable = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const rxjs_1 = require("rxjs");
6
6
  const isReadableStreamLike_1 = require("rxjs/internal/util/isReadableStreamLike");
7
- const type_is_1 = tslib_1.__importDefault(require("type-is"));
7
+ const type_is_1 = tslib_1.__importDefault(require("@browsery/type-is"));
8
8
  const common_1 = require("@opra/common");
9
9
  const client_error_js_1 = require("../client-error.js");
10
10
  const constants_js_1 = require("../constants.js");
@@ -27,6 +27,15 @@ class HttpRequestObservable extends rxjs_1.Observable {
27
27
  }
28
28
  }, (error) => subscriber.error(error), () => subscriber.complete());
29
29
  });
30
+ const url = new common_1.OpraURL(init?.url);
31
+ Object.defineProperty(this, constants_js_1.kContext, {
32
+ enumerable: false,
33
+ value: {
34
+ headers: new Headers(init?.headers),
35
+ params: url.searchParams,
36
+ requestInit: { ...init }
37
+ }
38
+ });
30
39
  Object.defineProperty(this, constants_js_1.kClient, {
31
40
  enumerable: false,
32
41
  value: client
@@ -211,7 +220,7 @@ class HttpRequestObservable extends rxjs_1.Observable {
211
220
  else if ((0, common_1.isBlob)(request.body)) {
212
221
  contentType = request.body.type || 'application/octet-stream';
213
222
  body = request.body;
214
- request.headers.set('Content-Size', String(request.body.length));
223
+ request.headers.set('Content-Size', String(request.body.size));
215
224
  delete request.duplex;
216
225
  }
217
226
  else {
@@ -16,7 +16,6 @@ class HttpRequest {
16
16
  this.method = (init?.method || 'GET').toUpperCase();
17
17
  this.mode = init?.mode || 'cors';
18
18
  this.redirect = init?.redirect || 'follow';
19
- this.mode = init?.mode || 'cors';
20
19
  this.referrer = init?.referrer || '';
21
20
  this.referrerPolicy = init?.referrerPolicy || '';
22
21
  this.signal = init?.signal || new AbortController().signal;
@@ -1,6 +1,6 @@
1
1
  import { lastValueFrom, Observable } from 'rxjs';
2
2
  import { isReadableStreamLike } from 'rxjs/internal/util/isReadableStreamLike';
3
- import typeIs from 'type-is';
3
+ import typeIs from '@browsery/type-is';
4
4
  import { isBlob, OpraURL } from '@opra/common';
5
5
  import { ClientError } from '../client-error.js';
6
6
  import { kClient, kContext } from '../constants.js';
@@ -23,6 +23,15 @@ export class HttpRequestObservable extends Observable {
23
23
  }
24
24
  }, (error) => subscriber.error(error), () => subscriber.complete());
25
25
  });
26
+ const url = new OpraURL(init?.url);
27
+ Object.defineProperty(this, kContext, {
28
+ enumerable: false,
29
+ value: {
30
+ headers: new Headers(init?.headers),
31
+ params: url.searchParams,
32
+ requestInit: { ...init }
33
+ }
34
+ });
26
35
  Object.defineProperty(this, kClient, {
27
36
  enumerable: false,
28
37
  value: client
@@ -207,7 +216,7 @@ export class HttpRequestObservable extends Observable {
207
216
  else if (isBlob(request.body)) {
208
217
  contentType = request.body.type || 'application/octet-stream';
209
218
  body = request.body;
210
- request.headers.set('Content-Size', String(request.body.length));
219
+ request.headers.set('Content-Size', String(request.body.size));
211
220
  delete request.duplex;
212
221
  }
213
222
  else {
@@ -13,7 +13,6 @@ export class HttpRequest {
13
13
  this.method = (init?.method || 'GET').toUpperCase();
14
14
  this.mode = init?.mode || 'cors';
15
15
  this.redirect = init?.redirect || 'follow';
16
- this.mode = init?.mode || 'cors';
17
16
  this.referrer = init?.referrer || '';
18
17
  this.referrerPolicy = init?.referrerPolicy || '';
19
18
  this.signal = init?.signal || new AbortController().signal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/client",
3
- "version": "0.27.0",
3
+ "version": "0.27.2",
4
4
  "description": "Opra Client package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -33,12 +33,13 @@
33
33
  "types": "./types/index.d.ts",
34
34
  "dependencies": {
35
35
  "@browsery/fs": "^0.4.0",
36
- "@browsery/highland": "^0.5.0",
36
+ "@browsery/highland": "^0.6.0",
37
37
  "@browsery/http-parser": "^0.4.0",
38
- "@browsery/i18next": "^0.6.0",
39
- "@browsery/stream": "^0.5.0",
38
+ "@browsery/i18next": "^0.7.2",
39
+ "@browsery/stream": "^0.6.0",
40
+ "@browsery/type-is": "^0.6.3",
40
41
  "@browsery/util": "^0.4.0",
41
- "@opra/common": "^0.27.0",
42
+ "@opra/common": "^0.27.2",
42
43
  "accepts": "^1.3.8",
43
44
  "buffer": "^6.0.3",
44
45
  "cookie": "^0.5.0",
@@ -57,7 +58,6 @@
57
58
  "reflect-metadata": "^0.1.13",
58
59
  "rxjs": "^7.8.1",
59
60
  "ts-lib": "^0.0.5",
60
- "type-is": "^1.6.18",
61
61
  "uid": "^2.0.1"
62
62
  },
63
63
  "sideEffects": false,
@@ -1,19 +1,15 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import type { OpraHttpClient } from '../client.js';
3
- import { kClient } from '../constants.js';
3
+ import { kClient, kContext } from '../constants.js';
4
4
  import { HttpObserveType } from '../enums/index.js';
5
5
  import { HttpEvent } from '../interfaces/index.js';
6
- import { RequestInterceptor, ResponseInterceptor, URLSearchParamsInit } from '../types.js';
6
+ import { URLSearchParamsInit } from '../types.js';
7
7
  import { HttpRequest } from './http-request.js';
8
8
  import { HttpResponse } from './http-response.js';
9
9
  /**
10
10
  * @namespace HttpRequestObservable
11
11
  */
12
12
  export declare namespace HttpRequestObservable {
13
- interface Initiator extends HttpRequest.Initiator {
14
- requestInterceptors?: RequestInterceptor[];
15
- responseInterceptors?: ResponseInterceptor[];
16
- }
17
13
  interface HttpOptions extends Partial<Pick<HttpRequest, 'cache' | 'credentials' | 'destination' | 'integrity' | 'keepalive' | 'mode' | 'redirect' | 'referrer' | 'referrerPolicy'>> {
18
14
  }
19
15
  }
@@ -23,9 +19,14 @@ declare const kIntlObservable: unique symbol;
23
19
  */
24
20
  export declare class HttpRequestObservable<TPayload = any, TResponseExt = {}> extends Observable<TPayload> {
25
21
  [kClient]: OpraHttpClient;
22
+ [kContext]: {
23
+ headers: Headers;
24
+ params: URLSearchParams;
25
+ requestInit: any;
26
+ };
26
27
  [kIntlObservable]: Observable<HttpEvent>;
27
28
  request: HttpRequest;
28
- constructor(client: OpraHttpClient<any>, init?: HttpRequestObservable.Initiator);
29
+ constructor(client: OpraHttpClient<any>, init?: HttpRequest.Initiator);
29
30
  httpOptions(options: HttpRequestObservable.HttpOptions): this;
30
31
  header(headers: HeadersInit): this;
31
32
  header(name: string, value?: string | number | boolean | null): this;