@atproto/oauth-client 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atproto/oauth-client
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2710](https://github.com/bluesky-social/atproto/pull/2710) [`04112783d`](https://github.com/bluesky-social/atproto/commit/04112783db17f865c9e2b673190f77dd0b7461e3) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add CustomEvent ponyfill for enviroments that don't provide it
8
+
3
9
  ## 0.1.3
4
10
 
5
11
  ### Patch Changes
package/dist/util.d.ts CHANGED
@@ -7,10 +7,14 @@ export declare const timeoutSignal: (timeout: number, options?: {
7
7
  signal?: AbortSignal;
8
8
  }) => AbortSignal & Disposable;
9
9
  export declare function contentMime(headers: Headers): string | undefined;
10
+ /**
11
+ * Ponyfill for `CustomEvent` constructor.
12
+ */
13
+ export declare const CustomEvent: typeof globalThis.CustomEvent;
10
14
  export declare class CustomEventTarget<EventDetailMap extends Record<string, unknown>> {
11
15
  readonly eventTarget: EventTarget;
12
16
  addEventListener<T extends Extract<keyof EventDetailMap, string>>(type: T, callback: (event: CustomEvent<EventDetailMap[T]>) => void, options?: AddEventListenerOptions | boolean): void;
13
17
  removeEventListener<T extends Extract<keyof EventDetailMap, string>>(type: T, callback: (event: CustomEvent<EventDetailMap[T]>) => void, options?: EventListenerOptions | boolean): void;
14
- dispatchCustomEvent<T extends Extract<keyof EventDetailMap, string>>(type: T, detail: EventDetailMap[T]): boolean;
18
+ dispatchCustomEvent<T extends Extract<keyof EventDetailMap, string>>(type: T, detail: EventDetailMap[T], init?: EventInit): boolean;
15
19
  }
16
20
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAA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,UAmChB,CAAA;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEhE;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,UAAU,CAAC,WA4BtC,CAAA;AAEN,qBAAa,iBAAiB,CAAC,cAAc,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3E,QAAQ,CAAC,WAAW,cAAoB;IAExC,gBAAgB,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,cAAc,EAAE,MAAM,CAAC,EAC9D,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EACzD,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,GAC1C,IAAI;IAIP,mBAAmB,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,cAAc,EAAE,MAAM,CAAC,EACjE,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EACzD,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,GACvC,IAAI;IAQP,mBAAmB,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,cAAc,EAAE,MAAM,CAAC,EACjE,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,EACzB,IAAI,CAAC,EAAE,SAAS,GACf,OAAO;CAKX"}
package/dist/util.js CHANGED
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomEventTarget = exports.contentMime = exports.timeoutSignal = void 0;
14
+ exports.CustomEventTarget = exports.CustomEvent = exports.contentMime = exports.timeoutSignal = void 0;
4
15
  // @ts-expect-error
5
16
  Symbol.dispose ?? (Symbol.dispose = Symbol('@@dispose'));
6
17
  /**
@@ -32,6 +43,38 @@ function contentMime(headers) {
32
43
  return headers.get('content-type')?.split(';')[0].trim();
33
44
  }
34
45
  exports.contentMime = contentMime;
46
+ /**
47
+ * Ponyfill for `CustomEvent` constructor.
48
+ */
49
+ exports.CustomEvent = globalThis.CustomEvent ??
50
+ (() => {
51
+ var _CustomEvent_detail;
52
+ class CustomEvent extends Event {
53
+ constructor(type, options) {
54
+ if (!arguments.length)
55
+ throw new TypeError('type argument is required');
56
+ super(type, options);
57
+ _CustomEvent_detail.set(this, void 0);
58
+ __classPrivateFieldSet(this, _CustomEvent_detail, options?.detail ?? null, "f");
59
+ }
60
+ get detail() {
61
+ return __classPrivateFieldGet(this, _CustomEvent_detail, "f");
62
+ }
63
+ }
64
+ _CustomEvent_detail = new WeakMap();
65
+ Object.defineProperties(CustomEvent.prototype, {
66
+ [Symbol.toStringTag]: {
67
+ writable: false,
68
+ enumerable: false,
69
+ configurable: true,
70
+ value: 'CustomEvent',
71
+ },
72
+ detail: {
73
+ enumerable: true,
74
+ },
75
+ });
76
+ return CustomEvent;
77
+ })();
35
78
  class CustomEventTarget {
36
79
  constructor() {
37
80
  Object.defineProperty(this, "eventTarget", {
@@ -47,8 +90,8 @@ class CustomEventTarget {
47
90
  removeEventListener(type, callback, options) {
48
91
  this.eventTarget.removeEventListener(type, callback, options);
49
92
  }
50
- dispatchCustomEvent(type, detail) {
51
- return this.eventTarget.dispatchEvent(new CustomEvent(type, { detail }));
93
+ dispatchCustomEvent(type, detail, init) {
94
+ return this.eventTarget.dispatchEvent(new exports.CustomEvent(type, { ...init, detail }));
52
95
  }
53
96
  }
54
97
  exports.CustomEventTarget = CustomEventTarget;
package/dist/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAEA,mBAAmB;AACnB,MAAM,CAAC,OAAO,KAAd,MAAM,CAAC,OAAO,GAAK,MAAM,CAAC,WAAW,CAAC,EAAA;AAEtC;;GAEG;AACI,MAAM,aAAa,GAAG,CAC3B,OAAe,EACf,OAAkC,EACR,EAAE;IAC5B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CAAC,6BAA6B,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA;IAEjC,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;IACxC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IAE7B,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAC/B,OAAO,EACP,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,EACpC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CACvB,CAAA;IAED,MAAM,SAAS,GAAG,UAAU,CAC1B,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAC9B,OAAO;IACP,iDAAiD;IACjD,IAAI,KAAK,CAAC,SAAS,CAAC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,CAAC;IAED,mBAAmB,CACjB,IAAO,EACP,QAAyD,EACzD,OAAwC;QAExC,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAClC,IAAI,EACJ,QAAyB,EACzB,OAAO,CACR,CAAA;IACH,CAAC;IAED,mBAAmB,CACjB,IAAO,EACP,MAAyB,EACzB,IAAgB;QAEhB,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CACnC,IAAI,mBAAW,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAC3C,CAAA;IACH,CAAC;CACF;AAhCD,8CAgCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/oauth-client",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "description": "OAuth client for ATPROTO PDS. This package serves as common base for environment-specific implementations (NodeJS, Browser, React-Native).",
6
6
  "keywords": [
package/src/util.ts CHANGED
@@ -50,6 +50,39 @@ export function contentMime(headers: Headers): string | undefined {
50
50
  return headers.get('content-type')?.split(';')[0]!.trim()
51
51
  }
52
52
 
53
+ /**
54
+ * Ponyfill for `CustomEvent` constructor.
55
+ */
56
+ export const CustomEvent: typeof globalThis.CustomEvent =
57
+ globalThis.CustomEvent ??
58
+ (() => {
59
+ class CustomEvent<T> extends Event {
60
+ #detail: T | null
61
+ constructor(type: string, options?: CustomEventInit<T>) {
62
+ if (!arguments.length) throw new TypeError('type argument is required')
63
+ super(type, options)
64
+ this.#detail = options?.detail ?? null
65
+ }
66
+ get detail() {
67
+ return this.#detail
68
+ }
69
+ }
70
+
71
+ Object.defineProperties(CustomEvent.prototype, {
72
+ [Symbol.toStringTag]: {
73
+ writable: false,
74
+ enumerable: false,
75
+ configurable: true,
76
+ value: 'CustomEvent',
77
+ },
78
+ detail: {
79
+ enumerable: true,
80
+ },
81
+ })
82
+
83
+ return CustomEvent
84
+ })()
85
+
53
86
  export class CustomEventTarget<EventDetailMap extends Record<string, unknown>> {
54
87
  readonly eventTarget = new EventTarget()
55
88
 
@@ -76,7 +109,10 @@ export class CustomEventTarget<EventDetailMap extends Record<string, unknown>> {
76
109
  dispatchCustomEvent<T extends Extract<keyof EventDetailMap, string>>(
77
110
  type: T,
78
111
  detail: EventDetailMap[T],
112
+ init?: EventInit,
79
113
  ): boolean {
80
- return this.eventTarget.dispatchEvent(new CustomEvent(type, { detail }))
114
+ return this.eventTarget.dispatchEvent(
115
+ new CustomEvent(type, { ...init, detail }),
116
+ )
81
117
  }
82
118
  }