@supabase/realtime-js 2.71.2-canary.29 → 2.71.2-canary.3
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/package.json +1 -1
- package/dist/main/RealtimeChannel.d.ts +0 -235
- package/dist/main/RealtimeChannel.d.ts.map +0 -1
- package/dist/main/RealtimeChannel.js +0 -576
- package/dist/main/RealtimeChannel.js.map +0 -1
- package/dist/main/RealtimeClient.d.ts +0 -196
- package/dist/main/RealtimeClient.d.ts.map +0 -1
- package/dist/main/RealtimeClient.js +0 -736
- package/dist/main/RealtimeClient.js.map +0 -1
- package/dist/main/RealtimePresence.d.ts +0 -68
- package/dist/main/RealtimePresence.d.ts.map +0 -1
- package/dist/main/RealtimePresence.js +0 -229
- package/dist/main/RealtimePresence.js.map +0 -1
- package/dist/main/index.d.ts +0 -6
- package/dist/main/index.d.ts.map +0 -1
- package/dist/main/index.js +0 -53
- package/dist/main/index.js.map +0 -1
- package/dist/main/lib/constants.d.ts +0 -37
- package/dist/main/lib/constants.d.ts.map +0 -1
- package/dist/main/lib/constants.js +0 -46
- package/dist/main/lib/constants.js.map +0 -1
- package/dist/main/lib/push.d.ts +0 -48
- package/dist/main/lib/push.d.ts.map +0 -1
- package/dist/main/lib/push.js +0 -102
- package/dist/main/lib/push.js.map +0 -1
- package/dist/main/lib/serializer.d.ts +0 -7
- package/dist/main/lib/serializer.d.ts.map +0 -1
- package/dist/main/lib/serializer.js +0 -36
- package/dist/main/lib/serializer.js.map +0 -1
- package/dist/main/lib/timer.d.ts +0 -22
- package/dist/main/lib/timer.d.ts.map +0 -1
- package/dist/main/lib/timer.js +0 -39
- package/dist/main/lib/timer.js.map +0 -1
- package/dist/main/lib/transformers.d.ts +0 -109
- package/dist/main/lib/transformers.d.ts.map +0 -1
- package/dist/main/lib/transformers.js +0 -229
- package/dist/main/lib/transformers.js.map +0 -1
- package/dist/main/lib/version.d.ts +0 -2
- package/dist/main/lib/version.d.ts.map +0 -1
- package/dist/main/lib/version.js +0 -5
- package/dist/main/lib/version.js.map +0 -1
- package/dist/main/lib/websocket-factory.d.ts +0 -35
- package/dist/main/lib/websocket-factory.d.ts.map +0 -1
- package/dist/main/lib/websocket-factory.js +0 -90
- package/dist/main/lib/websocket-factory.js.map +0 -1
- package/dist/module/RealtimeChannel.d.ts +0 -235
- package/dist/module/RealtimeChannel.d.ts.map +0 -1
- package/dist/module/RealtimeChannel.js +0 -536
- package/dist/module/RealtimeChannel.js.map +0 -1
- package/dist/module/RealtimeClient.d.ts +0 -196
- package/dist/module/RealtimeClient.d.ts.map +0 -1
- package/dist/module/RealtimeClient.js +0 -698
- package/dist/module/RealtimeClient.js.map +0 -1
- package/dist/module/RealtimePresence.d.ts +0 -68
- package/dist/module/RealtimePresence.d.ts.map +0 -1
- package/dist/module/RealtimePresence.js +0 -225
- package/dist/module/RealtimePresence.js.map +0 -1
- package/dist/module/index.d.ts +0 -6
- package/dist/module/index.d.ts.map +0 -1
- package/dist/module/index.js +0 -6
- package/dist/module/index.js.map +0 -1
- package/dist/module/lib/constants.d.ts +0 -37
- package/dist/module/lib/constants.d.ts.map +0 -1
- package/dist/module/lib/constants.js +0 -43
- package/dist/module/lib/constants.js.map +0 -1
- package/dist/module/lib/push.d.ts +0 -48
- package/dist/module/lib/push.d.ts.map +0 -1
- package/dist/module/lib/push.js +0 -99
- package/dist/module/lib/push.js.map +0 -1
- package/dist/module/lib/serializer.d.ts +0 -7
- package/dist/module/lib/serializer.d.ts.map +0 -1
- package/dist/module/lib/serializer.js +0 -33
- package/dist/module/lib/serializer.js.map +0 -1
- package/dist/module/lib/timer.d.ts +0 -22
- package/dist/module/lib/timer.d.ts.map +0 -1
- package/dist/module/lib/timer.js +0 -36
- package/dist/module/lib/timer.js.map +0 -1
- package/dist/module/lib/transformers.d.ts +0 -109
- package/dist/module/lib/transformers.d.ts.map +0 -1
- package/dist/module/lib/transformers.js +0 -217
- package/dist/module/lib/transformers.js.map +0 -1
- package/dist/module/lib/version.d.ts +0 -2
- package/dist/module/lib/version.d.ts.map +0 -1
- package/dist/module/lib/version.js +0 -2
- package/dist/module/lib/version.js.map +0 -1
- package/dist/module/lib/websocket-factory.d.ts +0 -35
- package/dist/module/lib/websocket-factory.d.ts.map +0 -1
- package/dist/module/lib/websocket-factory.js +0 -86
- package/dist/module/lib/websocket-factory.js.map +0 -1
package/dist/main/lib/push.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const constants_1 = require("../lib/constants");
|
|
4
|
-
class Push {
|
|
5
|
-
/**
|
|
6
|
-
* Initializes the Push
|
|
7
|
-
*
|
|
8
|
-
* @param channel The Channel
|
|
9
|
-
* @param event The event, for example `"phx_join"`
|
|
10
|
-
* @param payload The payload, for example `{user_id: 123}`
|
|
11
|
-
* @param timeout The push timeout in milliseconds
|
|
12
|
-
*/
|
|
13
|
-
constructor(channel, event, payload = {}, timeout = constants_1.DEFAULT_TIMEOUT) {
|
|
14
|
-
this.channel = channel;
|
|
15
|
-
this.event = event;
|
|
16
|
-
this.payload = payload;
|
|
17
|
-
this.timeout = timeout;
|
|
18
|
-
this.sent = false;
|
|
19
|
-
this.timeoutTimer = undefined;
|
|
20
|
-
this.ref = '';
|
|
21
|
-
this.receivedResp = null;
|
|
22
|
-
this.recHooks = [];
|
|
23
|
-
this.refEvent = null;
|
|
24
|
-
}
|
|
25
|
-
resend(timeout) {
|
|
26
|
-
this.timeout = timeout;
|
|
27
|
-
this._cancelRefEvent();
|
|
28
|
-
this.ref = '';
|
|
29
|
-
this.refEvent = null;
|
|
30
|
-
this.receivedResp = null;
|
|
31
|
-
this.sent = false;
|
|
32
|
-
this.send();
|
|
33
|
-
}
|
|
34
|
-
send() {
|
|
35
|
-
if (this._hasReceived('timeout')) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
this.startTimeout();
|
|
39
|
-
this.sent = true;
|
|
40
|
-
this.channel.socket.push({
|
|
41
|
-
topic: this.channel.topic,
|
|
42
|
-
event: this.event,
|
|
43
|
-
payload: this.payload,
|
|
44
|
-
ref: this.ref,
|
|
45
|
-
join_ref: this.channel._joinRef(),
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
updatePayload(payload) {
|
|
49
|
-
this.payload = Object.assign(Object.assign({}, this.payload), payload);
|
|
50
|
-
}
|
|
51
|
-
receive(status, callback) {
|
|
52
|
-
var _a;
|
|
53
|
-
if (this._hasReceived(status)) {
|
|
54
|
-
callback((_a = this.receivedResp) === null || _a === void 0 ? void 0 : _a.response);
|
|
55
|
-
}
|
|
56
|
-
this.recHooks.push({ status, callback });
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
startTimeout() {
|
|
60
|
-
if (this.timeoutTimer) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
this.ref = this.channel.socket._makeRef();
|
|
64
|
-
this.refEvent = this.channel._replyEventName(this.ref);
|
|
65
|
-
const callback = (payload) => {
|
|
66
|
-
this._cancelRefEvent();
|
|
67
|
-
this._cancelTimeout();
|
|
68
|
-
this.receivedResp = payload;
|
|
69
|
-
this._matchReceive(payload);
|
|
70
|
-
};
|
|
71
|
-
this.channel._on(this.refEvent, {}, callback);
|
|
72
|
-
this.timeoutTimer = setTimeout(() => {
|
|
73
|
-
this.trigger('timeout', {});
|
|
74
|
-
}, this.timeout);
|
|
75
|
-
}
|
|
76
|
-
trigger(status, response) {
|
|
77
|
-
if (this.refEvent)
|
|
78
|
-
this.channel._trigger(this.refEvent, { status, response });
|
|
79
|
-
}
|
|
80
|
-
destroy() {
|
|
81
|
-
this._cancelRefEvent();
|
|
82
|
-
this._cancelTimeout();
|
|
83
|
-
}
|
|
84
|
-
_cancelRefEvent() {
|
|
85
|
-
if (!this.refEvent) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
this.channel._off(this.refEvent, {});
|
|
89
|
-
}
|
|
90
|
-
_cancelTimeout() {
|
|
91
|
-
clearTimeout(this.timeoutTimer);
|
|
92
|
-
this.timeoutTimer = undefined;
|
|
93
|
-
}
|
|
94
|
-
_matchReceive({ status, response }) {
|
|
95
|
-
this.recHooks.filter((h) => h.status === status).forEach((h) => h.callback(response));
|
|
96
|
-
}
|
|
97
|
-
_hasReceived(status) {
|
|
98
|
-
return this.receivedResp && this.receivedResp.status === status;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.default = Push;
|
|
102
|
-
//# sourceMappingURL=push.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../src/lib/push.ts"],"names":[],"mappings":";;AAAA,gDAAkD;AAGlD,MAAqB,IAAI;IAcvB;;;;;;;OAOG;IACH,YACS,OAAwB,EACxB,KAAa,EACb,UAAkC,EAAE,EACpC,UAAkB,2BAAe;QAHjC,YAAO,GAAP,OAAO,CAAiB;QACxB,UAAK,GAAL,KAAK,CAAQ;QACb,YAAO,GAAP,OAAO,CAA6B;QACpC,YAAO,GAAP,OAAO,CAA0B;QAzB1C,SAAI,GAAY,KAAK,CAAA;QACrB,iBAAY,GAAuB,SAAS,CAAA;QAC5C,QAAG,GAAW,EAAE,CAAA;QAChB,iBAAY,GAGD,IAAI,CAAA;QACf,aAAQ,GAGF,EAAE,CAAA;QACR,aAAQ,GAAkB,IAAI,CAAA;IAe3B,CAAC;IAEJ,MAAM,CAAC,OAAe;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,eAAe,EAAE,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QACxB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAA;QACjB,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;IAED,IAAI;QACF,IAAI,IAAI,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AAC;IAEO,YAAY,CAAC,MAAc;QACjC,OAAO,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,MAAM,CAAA;IACjE,CAAC;CACF;AArHD,uBAqHC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../../src/lib/serializer.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,aAAa,SAAI;IAEjB,MAAM,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,EAAE,QAAQ,EAAE,QAAQ;IAY3D,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,gBAAgB;CAqBzB"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file draws heavily from https://github.com/phoenixframework/phoenix/commit/cf098e9cf7a44ee6479d31d911a97d3c7430c6fe
|
|
3
|
-
// License: https://github.com/phoenixframework/phoenix/blob/master/LICENSE.md
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
class Serializer {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.HEADER_LENGTH = 1;
|
|
8
|
-
}
|
|
9
|
-
decode(rawPayload, callback) {
|
|
10
|
-
if (rawPayload.constructor === ArrayBuffer) {
|
|
11
|
-
return callback(this._binaryDecode(rawPayload));
|
|
12
|
-
}
|
|
13
|
-
if (typeof rawPayload === 'string') {
|
|
14
|
-
return callback(JSON.parse(rawPayload));
|
|
15
|
-
}
|
|
16
|
-
return callback({});
|
|
17
|
-
}
|
|
18
|
-
_binaryDecode(buffer) {
|
|
19
|
-
const view = new DataView(buffer);
|
|
20
|
-
const decoder = new TextDecoder();
|
|
21
|
-
return this._decodeBroadcast(buffer, view, decoder);
|
|
22
|
-
}
|
|
23
|
-
_decodeBroadcast(buffer, view, decoder) {
|
|
24
|
-
const topicSize = view.getUint8(1);
|
|
25
|
-
const eventSize = view.getUint8(2);
|
|
26
|
-
let offset = this.HEADER_LENGTH + 2;
|
|
27
|
-
const topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
28
|
-
offset = offset + topicSize;
|
|
29
|
-
const event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
30
|
-
offset = offset + eventSize;
|
|
31
|
-
const data = JSON.parse(decoder.decode(buffer.slice(offset, buffer.byteLength)));
|
|
32
|
-
return { ref: null, topic: topic, event: event, payload: data };
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.default = Serializer;
|
|
36
|
-
//# sourceMappingURL=serializer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/lib/serializer.ts"],"names":[],"mappings":";AAAA,2HAA2H;AAC3H,8EAA8E;;AAE9E,MAAqB,UAAU;IAA/B;QACE,kBAAa,GAAG,CAAC,CAAA;IA0CnB,CAAC;IAxCC,MAAM,CAAC,UAAgC,EAAE,QAAkB;QACzD,IAAI,UAAU,CAAC,WAAW,KAAK,WAAW,EAAE,CAAC;YAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAA;QACjD,CAAC;QAED,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAA;QACzC,CAAC;QAED,OAAO,QAAQ,CAAC,EAAE,CAAC,CAAA;IACrB,CAAC;IAEO,aAAa,CAAC,MAAmB;QACvC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAA;QACjC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;QAEjC,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;IAEO,gBAAgB,CACtB,MAAmB,EACnB,IAAc,EACd,OAAoB;QAOpB,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;QAClC,IAAI,MAAM,GAAG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAA;QACnC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;QACtE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;QACtE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAEhF,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IACjE,CAAC;CACF;AA3CD,6BA2CC"}
|
package/dist/main/lib/timer.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a timer that accepts a `timerCalc` function to perform calculated timeout retries, such as exponential backoff.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* let reconnectTimer = new Timer(() => this.connect(), function(tries){
|
|
6
|
-
* return [1000, 5000, 10000][tries - 1] || 10000
|
|
7
|
-
* })
|
|
8
|
-
* reconnectTimer.scheduleTimeout() // fires after 1000
|
|
9
|
-
* reconnectTimer.scheduleTimeout() // fires after 5000
|
|
10
|
-
* reconnectTimer.reset()
|
|
11
|
-
* reconnectTimer.scheduleTimeout() // fires after 1000
|
|
12
|
-
*/
|
|
13
|
-
export default class Timer {
|
|
14
|
-
callback: Function;
|
|
15
|
-
timerCalc: Function;
|
|
16
|
-
timer: number | undefined;
|
|
17
|
-
tries: number;
|
|
18
|
-
constructor(callback: Function, timerCalc: Function);
|
|
19
|
-
reset(): void;
|
|
20
|
-
scheduleTimeout(): void;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=timer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../../src/lib/timer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IAKf,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,QAAQ;IAL5B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAY;IACrC,KAAK,EAAE,MAAM,CAAI;gBAGR,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,QAAQ;IAM5B,KAAK;IAOL,eAAe;CAWhB"}
|
package/dist/main/lib/timer.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Creates a timer that accepts a `timerCalc` function to perform calculated timeout retries, such as exponential backoff.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* let reconnectTimer = new Timer(() => this.connect(), function(tries){
|
|
8
|
-
* return [1000, 5000, 10000][tries - 1] || 10000
|
|
9
|
-
* })
|
|
10
|
-
* reconnectTimer.scheduleTimeout() // fires after 1000
|
|
11
|
-
* reconnectTimer.scheduleTimeout() // fires after 5000
|
|
12
|
-
* reconnectTimer.reset()
|
|
13
|
-
* reconnectTimer.scheduleTimeout() // fires after 1000
|
|
14
|
-
*/
|
|
15
|
-
class Timer {
|
|
16
|
-
constructor(callback, timerCalc) {
|
|
17
|
-
this.callback = callback;
|
|
18
|
-
this.timerCalc = timerCalc;
|
|
19
|
-
this.timer = undefined;
|
|
20
|
-
this.tries = 0;
|
|
21
|
-
this.callback = callback;
|
|
22
|
-
this.timerCalc = timerCalc;
|
|
23
|
-
}
|
|
24
|
-
reset() {
|
|
25
|
-
this.tries = 0;
|
|
26
|
-
clearTimeout(this.timer);
|
|
27
|
-
this.timer = undefined;
|
|
28
|
-
}
|
|
29
|
-
// Cancels any previous scheduleTimeout and schedules callback
|
|
30
|
-
scheduleTimeout() {
|
|
31
|
-
clearTimeout(this.timer);
|
|
32
|
-
this.timer = setTimeout(() => {
|
|
33
|
-
this.tries = this.tries + 1;
|
|
34
|
-
this.callback();
|
|
35
|
-
}, this.timerCalc(this.tries + 1));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.default = Timer;
|
|
39
|
-
//# sourceMappingURL=timer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timer.js","sourceRoot":"","sources":["../../../src/lib/timer.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;GAWG;AACH,MAAqB,KAAK;IAIxB,YACS,QAAkB,EAClB,SAAmB;QADnB,aAAQ,GAAR,QAAQ,CAAU;QAClB,cAAS,GAAT,SAAS,CAAU;QAL5B,UAAK,GAAuB,SAAS,CAAA;QACrC,UAAK,GAAW,CAAC,CAAA;QAMf,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;QACd,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACxB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;IACxB,CAAC;IAED,8DAA8D;IAC9D,eAAe;QACb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAExB,IAAI,CAAC,KAAK,GAAQ,UAAU,CAC1B,GAAG,EAAE;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;YAC3B,IAAI,CAAC,QAAQ,EAAE,CAAA;QACjB,CAAC,EACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAC/B,CAAA;IACH,CAAC;CACF;AA9BD,wBA8BC"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helpers to convert the change Payload into native JS types.
|
|
3
|
-
*/
|
|
4
|
-
export declare enum PostgresTypes {
|
|
5
|
-
abstime = "abstime",
|
|
6
|
-
bool = "bool",
|
|
7
|
-
date = "date",
|
|
8
|
-
daterange = "daterange",
|
|
9
|
-
float4 = "float4",
|
|
10
|
-
float8 = "float8",
|
|
11
|
-
int2 = "int2",
|
|
12
|
-
int4 = "int4",
|
|
13
|
-
int4range = "int4range",
|
|
14
|
-
int8 = "int8",
|
|
15
|
-
int8range = "int8range",
|
|
16
|
-
json = "json",
|
|
17
|
-
jsonb = "jsonb",
|
|
18
|
-
money = "money",
|
|
19
|
-
numeric = "numeric",
|
|
20
|
-
oid = "oid",
|
|
21
|
-
reltime = "reltime",
|
|
22
|
-
text = "text",
|
|
23
|
-
time = "time",
|
|
24
|
-
timestamp = "timestamp",
|
|
25
|
-
timestamptz = "timestamptz",
|
|
26
|
-
timetz = "timetz",
|
|
27
|
-
tsrange = "tsrange",
|
|
28
|
-
tstzrange = "tstzrange"
|
|
29
|
-
}
|
|
30
|
-
type Columns = {
|
|
31
|
-
name: string;
|
|
32
|
-
type: string;
|
|
33
|
-
flags?: string[];
|
|
34
|
-
type_modifier?: number;
|
|
35
|
-
}[];
|
|
36
|
-
type BaseValue = null | string | number | boolean;
|
|
37
|
-
type RecordValue = BaseValue | BaseValue[];
|
|
38
|
-
type Record = {
|
|
39
|
-
[key: string]: RecordValue;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Takes an array of columns and an object of string values then converts each string value
|
|
43
|
-
* to its mapped type.
|
|
44
|
-
*
|
|
45
|
-
* @param {{name: String, type: String}[]} columns
|
|
46
|
-
* @param {Object} record
|
|
47
|
-
* @param {Object} options The map of various options that can be applied to the mapper
|
|
48
|
-
* @param {Array} options.skipTypes The array of types that should not be converted
|
|
49
|
-
*
|
|
50
|
-
* @example convertChangeData([{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age:'33'}, {})
|
|
51
|
-
* //=>{ first_name: 'Paul', age: 33 }
|
|
52
|
-
*/
|
|
53
|
-
export declare const convertChangeData: (columns: Columns, record: Record, options?: {
|
|
54
|
-
skipTypes?: string[];
|
|
55
|
-
}) => Record;
|
|
56
|
-
/**
|
|
57
|
-
* Converts the value of an individual column.
|
|
58
|
-
*
|
|
59
|
-
* @param {String} columnName The column that you want to convert
|
|
60
|
-
* @param {{name: String, type: String}[]} columns All of the columns
|
|
61
|
-
* @param {Object} record The map of string values
|
|
62
|
-
* @param {Array} skipTypes An array of types that should not be converted
|
|
63
|
-
* @return {object} Useless information
|
|
64
|
-
*
|
|
65
|
-
* @example convertColumn('age', [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age: '33'}, [])
|
|
66
|
-
* //=> 33
|
|
67
|
-
* @example convertColumn('age', [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age: '33'}, ['int4'])
|
|
68
|
-
* //=> "33"
|
|
69
|
-
*/
|
|
70
|
-
export declare const convertColumn: (columnName: string, columns: Columns, record: Record, skipTypes: string[]) => RecordValue;
|
|
71
|
-
/**
|
|
72
|
-
* If the value of the cell is `null`, returns null.
|
|
73
|
-
* Otherwise converts the string value to the correct type.
|
|
74
|
-
* @param {String} type A postgres column type
|
|
75
|
-
* @param {String} value The cell value
|
|
76
|
-
*
|
|
77
|
-
* @example convertCell('bool', 't')
|
|
78
|
-
* //=> true
|
|
79
|
-
* @example convertCell('int8', '10')
|
|
80
|
-
* //=> 10
|
|
81
|
-
* @example convertCell('_int4', '{1,2,3,4}')
|
|
82
|
-
* //=> [1,2,3,4]
|
|
83
|
-
*/
|
|
84
|
-
export declare const convertCell: (type: string, value: RecordValue) => RecordValue;
|
|
85
|
-
export declare const toBoolean: (value: RecordValue) => RecordValue;
|
|
86
|
-
export declare const toNumber: (value: RecordValue) => RecordValue;
|
|
87
|
-
export declare const toJson: (value: RecordValue) => RecordValue;
|
|
88
|
-
/**
|
|
89
|
-
* Converts a Postgres Array into a native JS array
|
|
90
|
-
*
|
|
91
|
-
* @example toArray('{}', 'int4')
|
|
92
|
-
* //=> []
|
|
93
|
-
* @example toArray('{"[2021-01-01,2021-12-31)","(2021-01-01,2021-12-32]"}', 'daterange')
|
|
94
|
-
* //=> ['[2021-01-01,2021-12-31)', '(2021-01-01,2021-12-32]']
|
|
95
|
-
* @example toArray([1,2,3,4], 'int4')
|
|
96
|
-
* //=> [1,2,3,4]
|
|
97
|
-
*/
|
|
98
|
-
export declare const toArray: (value: RecordValue, type: string) => RecordValue;
|
|
99
|
-
/**
|
|
100
|
-
* Fixes timestamp to be ISO-8601. Swaps the space between the date and time for a 'T'
|
|
101
|
-
* See https://github.com/supabase/supabase/issues/18
|
|
102
|
-
*
|
|
103
|
-
* @example toTimestampString('2019-09-10 00:00:00')
|
|
104
|
-
* //=> '2019-09-10T00:00:00'
|
|
105
|
-
*/
|
|
106
|
-
export declare const toTimestampString: (value: RecordValue) => RecordValue;
|
|
107
|
-
export declare const httpEndpointURL: (socketUrl: string) => string;
|
|
108
|
-
export {};
|
|
109
|
-
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../src/lib/transformers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,MAAM,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AAW,KAAG,WAQ7C,CAAA;AACD,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,KAAG,WAU3C,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,WAAW,EAAE,MAAM,MAAM,KAAG,WA0B1D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,WAAW,KAAG,WAMtD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,KAAG,MAKnD,CAAA"}
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Helpers to convert the change Payload into native JS types.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.httpEndpointURL = exports.toTimestampString = exports.toArray = exports.toJson = exports.toNumber = exports.toBoolean = exports.convertCell = exports.convertColumn = exports.convertChangeData = exports.PostgresTypes = void 0;
|
|
7
|
-
// Adapted from epgsql (src/epgsql_binary.erl), this module licensed under
|
|
8
|
-
// 3-clause BSD found here: https://raw.githubusercontent.com/epgsql/epgsql/devel/LICENSE
|
|
9
|
-
var PostgresTypes;
|
|
10
|
-
(function (PostgresTypes) {
|
|
11
|
-
PostgresTypes["abstime"] = "abstime";
|
|
12
|
-
PostgresTypes["bool"] = "bool";
|
|
13
|
-
PostgresTypes["date"] = "date";
|
|
14
|
-
PostgresTypes["daterange"] = "daterange";
|
|
15
|
-
PostgresTypes["float4"] = "float4";
|
|
16
|
-
PostgresTypes["float8"] = "float8";
|
|
17
|
-
PostgresTypes["int2"] = "int2";
|
|
18
|
-
PostgresTypes["int4"] = "int4";
|
|
19
|
-
PostgresTypes["int4range"] = "int4range";
|
|
20
|
-
PostgresTypes["int8"] = "int8";
|
|
21
|
-
PostgresTypes["int8range"] = "int8range";
|
|
22
|
-
PostgresTypes["json"] = "json";
|
|
23
|
-
PostgresTypes["jsonb"] = "jsonb";
|
|
24
|
-
PostgresTypes["money"] = "money";
|
|
25
|
-
PostgresTypes["numeric"] = "numeric";
|
|
26
|
-
PostgresTypes["oid"] = "oid";
|
|
27
|
-
PostgresTypes["reltime"] = "reltime";
|
|
28
|
-
PostgresTypes["text"] = "text";
|
|
29
|
-
PostgresTypes["time"] = "time";
|
|
30
|
-
PostgresTypes["timestamp"] = "timestamp";
|
|
31
|
-
PostgresTypes["timestamptz"] = "timestamptz";
|
|
32
|
-
PostgresTypes["timetz"] = "timetz";
|
|
33
|
-
PostgresTypes["tsrange"] = "tsrange";
|
|
34
|
-
PostgresTypes["tstzrange"] = "tstzrange";
|
|
35
|
-
})(PostgresTypes || (exports.PostgresTypes = PostgresTypes = {}));
|
|
36
|
-
/**
|
|
37
|
-
* Takes an array of columns and an object of string values then converts each string value
|
|
38
|
-
* to its mapped type.
|
|
39
|
-
*
|
|
40
|
-
* @param {{name: String, type: String}[]} columns
|
|
41
|
-
* @param {Object} record
|
|
42
|
-
* @param {Object} options The map of various options that can be applied to the mapper
|
|
43
|
-
* @param {Array} options.skipTypes The array of types that should not be converted
|
|
44
|
-
*
|
|
45
|
-
* @example convertChangeData([{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age:'33'}, {})
|
|
46
|
-
* //=>{ first_name: 'Paul', age: 33 }
|
|
47
|
-
*/
|
|
48
|
-
const convertChangeData = (columns, record, options = {}) => {
|
|
49
|
-
var _a;
|
|
50
|
-
const skipTypes = (_a = options.skipTypes) !== null && _a !== void 0 ? _a : [];
|
|
51
|
-
return Object.keys(record).reduce((acc, rec_key) => {
|
|
52
|
-
acc[rec_key] = (0, exports.convertColumn)(rec_key, columns, record, skipTypes);
|
|
53
|
-
return acc;
|
|
54
|
-
}, {});
|
|
55
|
-
};
|
|
56
|
-
exports.convertChangeData = convertChangeData;
|
|
57
|
-
/**
|
|
58
|
-
* Converts the value of an individual column.
|
|
59
|
-
*
|
|
60
|
-
* @param {String} columnName The column that you want to convert
|
|
61
|
-
* @param {{name: String, type: String}[]} columns All of the columns
|
|
62
|
-
* @param {Object} record The map of string values
|
|
63
|
-
* @param {Array} skipTypes An array of types that should not be converted
|
|
64
|
-
* @return {object} Useless information
|
|
65
|
-
*
|
|
66
|
-
* @example convertColumn('age', [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age: '33'}, [])
|
|
67
|
-
* //=> 33
|
|
68
|
-
* @example convertColumn('age', [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age: '33'}, ['int4'])
|
|
69
|
-
* //=> "33"
|
|
70
|
-
*/
|
|
71
|
-
const convertColumn = (columnName, columns, record, skipTypes) => {
|
|
72
|
-
const column = columns.find((x) => x.name === columnName);
|
|
73
|
-
const colType = column === null || column === void 0 ? void 0 : column.type;
|
|
74
|
-
const value = record[columnName];
|
|
75
|
-
if (colType && !skipTypes.includes(colType)) {
|
|
76
|
-
return (0, exports.convertCell)(colType, value);
|
|
77
|
-
}
|
|
78
|
-
return noop(value);
|
|
79
|
-
};
|
|
80
|
-
exports.convertColumn = convertColumn;
|
|
81
|
-
/**
|
|
82
|
-
* If the value of the cell is `null`, returns null.
|
|
83
|
-
* Otherwise converts the string value to the correct type.
|
|
84
|
-
* @param {String} type A postgres column type
|
|
85
|
-
* @param {String} value The cell value
|
|
86
|
-
*
|
|
87
|
-
* @example convertCell('bool', 't')
|
|
88
|
-
* //=> true
|
|
89
|
-
* @example convertCell('int8', '10')
|
|
90
|
-
* //=> 10
|
|
91
|
-
* @example convertCell('_int4', '{1,2,3,4}')
|
|
92
|
-
* //=> [1,2,3,4]
|
|
93
|
-
*/
|
|
94
|
-
const convertCell = (type, value) => {
|
|
95
|
-
// if data type is an array
|
|
96
|
-
if (type.charAt(0) === '_') {
|
|
97
|
-
const dataType = type.slice(1, type.length);
|
|
98
|
-
return (0, exports.toArray)(value, dataType);
|
|
99
|
-
}
|
|
100
|
-
// If not null, convert to correct type.
|
|
101
|
-
switch (type) {
|
|
102
|
-
case PostgresTypes.bool:
|
|
103
|
-
return (0, exports.toBoolean)(value);
|
|
104
|
-
case PostgresTypes.float4:
|
|
105
|
-
case PostgresTypes.float8:
|
|
106
|
-
case PostgresTypes.int2:
|
|
107
|
-
case PostgresTypes.int4:
|
|
108
|
-
case PostgresTypes.int8:
|
|
109
|
-
case PostgresTypes.numeric:
|
|
110
|
-
case PostgresTypes.oid:
|
|
111
|
-
return (0, exports.toNumber)(value);
|
|
112
|
-
case PostgresTypes.json:
|
|
113
|
-
case PostgresTypes.jsonb:
|
|
114
|
-
return (0, exports.toJson)(value);
|
|
115
|
-
case PostgresTypes.timestamp:
|
|
116
|
-
return (0, exports.toTimestampString)(value); // Format to be consistent with PostgREST
|
|
117
|
-
case PostgresTypes.abstime: // To allow users to cast it based on Timezone
|
|
118
|
-
case PostgresTypes.date: // To allow users to cast it based on Timezone
|
|
119
|
-
case PostgresTypes.daterange:
|
|
120
|
-
case PostgresTypes.int4range:
|
|
121
|
-
case PostgresTypes.int8range:
|
|
122
|
-
case PostgresTypes.money:
|
|
123
|
-
case PostgresTypes.reltime: // To allow users to cast it based on Timezone
|
|
124
|
-
case PostgresTypes.text:
|
|
125
|
-
case PostgresTypes.time: // To allow users to cast it based on Timezone
|
|
126
|
-
case PostgresTypes.timestamptz: // To allow users to cast it based on Timezone
|
|
127
|
-
case PostgresTypes.timetz: // To allow users to cast it based on Timezone
|
|
128
|
-
case PostgresTypes.tsrange:
|
|
129
|
-
case PostgresTypes.tstzrange:
|
|
130
|
-
return noop(value);
|
|
131
|
-
default:
|
|
132
|
-
// Return the value for remaining types
|
|
133
|
-
return noop(value);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
exports.convertCell = convertCell;
|
|
137
|
-
const noop = (value) => {
|
|
138
|
-
return value;
|
|
139
|
-
};
|
|
140
|
-
const toBoolean = (value) => {
|
|
141
|
-
switch (value) {
|
|
142
|
-
case 't':
|
|
143
|
-
return true;
|
|
144
|
-
case 'f':
|
|
145
|
-
return false;
|
|
146
|
-
default:
|
|
147
|
-
return value;
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
exports.toBoolean = toBoolean;
|
|
151
|
-
const toNumber = (value) => {
|
|
152
|
-
if (typeof value === 'string') {
|
|
153
|
-
const parsedValue = parseFloat(value);
|
|
154
|
-
if (!Number.isNaN(parsedValue)) {
|
|
155
|
-
return parsedValue;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return value;
|
|
159
|
-
};
|
|
160
|
-
exports.toNumber = toNumber;
|
|
161
|
-
const toJson = (value) => {
|
|
162
|
-
if (typeof value === 'string') {
|
|
163
|
-
try {
|
|
164
|
-
return JSON.parse(value);
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
console.log(`JSON parse error: ${error}`);
|
|
168
|
-
return value;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return value;
|
|
172
|
-
};
|
|
173
|
-
exports.toJson = toJson;
|
|
174
|
-
/**
|
|
175
|
-
* Converts a Postgres Array into a native JS array
|
|
176
|
-
*
|
|
177
|
-
* @example toArray('{}', 'int4')
|
|
178
|
-
* //=> []
|
|
179
|
-
* @example toArray('{"[2021-01-01,2021-12-31)","(2021-01-01,2021-12-32]"}', 'daterange')
|
|
180
|
-
* //=> ['[2021-01-01,2021-12-31)', '(2021-01-01,2021-12-32]']
|
|
181
|
-
* @example toArray([1,2,3,4], 'int4')
|
|
182
|
-
* //=> [1,2,3,4]
|
|
183
|
-
*/
|
|
184
|
-
const toArray = (value, type) => {
|
|
185
|
-
if (typeof value !== 'string') {
|
|
186
|
-
return value;
|
|
187
|
-
}
|
|
188
|
-
const lastIdx = value.length - 1;
|
|
189
|
-
const closeBrace = value[lastIdx];
|
|
190
|
-
const openBrace = value[0];
|
|
191
|
-
// Confirm value is a Postgres array by checking curly brackets
|
|
192
|
-
if (openBrace === '{' && closeBrace === '}') {
|
|
193
|
-
let arr;
|
|
194
|
-
const valTrim = value.slice(1, lastIdx);
|
|
195
|
-
// TODO: find a better solution to separate Postgres array data
|
|
196
|
-
try {
|
|
197
|
-
arr = JSON.parse('[' + valTrim + ']');
|
|
198
|
-
}
|
|
199
|
-
catch (_) {
|
|
200
|
-
// WARNING: splitting on comma does not cover all edge cases
|
|
201
|
-
arr = valTrim ? valTrim.split(',') : [];
|
|
202
|
-
}
|
|
203
|
-
return arr.map((val) => (0, exports.convertCell)(type, val));
|
|
204
|
-
}
|
|
205
|
-
return value;
|
|
206
|
-
};
|
|
207
|
-
exports.toArray = toArray;
|
|
208
|
-
/**
|
|
209
|
-
* Fixes timestamp to be ISO-8601. Swaps the space between the date and time for a 'T'
|
|
210
|
-
* See https://github.com/supabase/supabase/issues/18
|
|
211
|
-
*
|
|
212
|
-
* @example toTimestampString('2019-09-10 00:00:00')
|
|
213
|
-
* //=> '2019-09-10T00:00:00'
|
|
214
|
-
*/
|
|
215
|
-
const toTimestampString = (value) => {
|
|
216
|
-
if (typeof value === 'string') {
|
|
217
|
-
return value.replace(' ', 'T');
|
|
218
|
-
}
|
|
219
|
-
return value;
|
|
220
|
-
};
|
|
221
|
-
exports.toTimestampString = toTimestampString;
|
|
222
|
-
const httpEndpointURL = (socketUrl) => {
|
|
223
|
-
let url = socketUrl;
|
|
224
|
-
url = url.replace(/^ws/i, 'http');
|
|
225
|
-
url = url.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i, '');
|
|
226
|
-
return url.replace(/\/+$/, '') + '/api/broadcast';
|
|
227
|
-
};
|
|
228
|
-
exports.httpEndpointURL = httpEndpointURL;
|
|
229
|
-
//# sourceMappingURL=transformers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.js","sourceRoot":"","sources":["../../../src/lib/transformers.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,0EAA0E;AAC1E,yFAAyF;AAEzF,IAAY,aAyBX;AAzBD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,8BAAa,CA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AG,GAAG,CAAC,CAAA;QACvC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,4DAA4D;YAC5D,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QACzC,CAAC;QAED,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,GAAc,EAAE,EAAE,CAAC,IAAA,mBAAW,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;IAC5D,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AA1BY,QAAA,OAAO,WA0BnB;AAED;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAAkB,EAAe,EAAE;IACnE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAChC,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AANY,QAAA,iBAAiB,qBAM7B;AAEM,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAU,EAAE;IAC3D,IAAI,GAAG,GAAG,SAAS,CAAA;IACnB,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,iDAAiD,EAAE,EAAE,CAAC,CAAA;IACxE,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,gBAAgB,CAAA;AACnD,CAAC,CAAA;AALY,QAAA,eAAe,mBAK3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,oBAAoB,CAAA"}
|
package/dist/main/lib/version.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,iBAAiB,CAAA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export interface WebSocketLike {
|
|
2
|
-
readonly CONNECTING: number;
|
|
3
|
-
readonly OPEN: number;
|
|
4
|
-
readonly CLOSING: number;
|
|
5
|
-
readonly CLOSED: number;
|
|
6
|
-
readonly readyState: number;
|
|
7
|
-
readonly url: string;
|
|
8
|
-
readonly protocol: string;
|
|
9
|
-
close(code?: number, reason?: string): void;
|
|
10
|
-
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
|
|
11
|
-
onopen: ((this: any, ev: Event) => any) | null;
|
|
12
|
-
onmessage: ((this: any, ev: MessageEvent) => any) | null;
|
|
13
|
-
onclose: ((this: any, ev: CloseEvent) => any) | null;
|
|
14
|
-
onerror: ((this: any, ev: Event) => any) | null;
|
|
15
|
-
addEventListener(type: string, listener: EventListener): void;
|
|
16
|
-
removeEventListener(type: string, listener: EventListener): void;
|
|
17
|
-
binaryType?: string;
|
|
18
|
-
bufferedAmount?: number;
|
|
19
|
-
extensions?: string;
|
|
20
|
-
dispatchEvent?: (event: Event) => boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface WebSocketEnvironment {
|
|
23
|
-
type: 'native' | 'ws' | 'cloudflare' | 'unsupported';
|
|
24
|
-
constructor?: any;
|
|
25
|
-
error?: string;
|
|
26
|
-
workaround?: string;
|
|
27
|
-
}
|
|
28
|
-
export declare class WebSocketFactory {
|
|
29
|
-
private static detectEnvironment;
|
|
30
|
-
static getWebSocketConstructor(): typeof WebSocket;
|
|
31
|
-
static createWebSocket(url: string | URL, protocols?: string | string[]): WebSocketLike;
|
|
32
|
-
static isWebSocketSupported(): boolean;
|
|
33
|
-
}
|
|
34
|
-
export default WebSocketFactory;
|
|
35
|
-
//# sourceMappingURL=websocket-factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
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