This commit is contained in:
MarcWieland
2026-07-26 23:57:23 +02:00
commit 8b613ec0bc
6300 changed files with 1257646 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

+10
View File
@@ -0,0 +1,10 @@
export default class Ajax {
static request(method: any, endPoint: any, headers: any, body: any, timeout: any, ontimeout: any, callback: any): any;
static fetchRequest(method: any, endPoint: any, headers: any, body: any, timeout: any, ontimeout: any, callback: any): AbortController | null;
static xdomainRequest(req: any, method: any, endPoint: any, body: any, timeout: any, ontimeout: any, callback: any): any;
static xhrRequest(req: any, method: any, endPoint: any, headers: any, body: any, timeout: any, ontimeout: any, callback: any): any;
static parseJSON(resp: any): any;
static serialize(obj: any, parentKey: any): any;
static appendParams(url: any, params: any): any;
}
//# sourceMappingURL=ajax.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ajax.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/ajax.js"],"names":[],"mappings":"AAKA;IAEE,sHAaC;IAED,8IAwBC;IAED,yHAcC;IAED,mIAiBC;IAED,iCASC;IAED,gDAaC;IAED,gDAKC;CACF"}
+167
View File
@@ -0,0 +1,167 @@
/**
* @import Socket from "./socket"
* @import { ChannelState, Params, ChannelBindingCallback, ChannelOnMessage, ChannelFilterBindings, ChannelOnErrorCallback, ChannelBinding } from "./types"
*/
export default class Channel {
/**
* @param {string} topic
* @param {Params | (() => Params)} params
* @param {Socket} socket
*/
constructor(topic: string, params: Params | (() => Params), socket: Socket);
/** @type{ChannelState} */
state: ChannelState;
/** @type{string} */
topic: string;
/** @type{() => Params} */
params: () => Params;
/** @type {Socket} */
socket: Socket;
/** @type{ChannelBinding[]} */
bindings: ChannelBinding[];
/** @type{number} */
bindingRef: number;
/** @type{number} */
timeout: number;
/** @type{boolean} */
joinedOnce: boolean;
/** @type{Push} */
joinPush: Push;
/** @type{Push[]} */
pushBuffer: Push[];
/** @type{string[]} */
stateChangeRefs: string[];
/** @type{Timer} */
rejoinTimer: Timer;
/**
* Join the channel
* @param {number} timeout
* @returns {Push}
*/
join(timeout?: number): Push;
/**
* Teardown the channel.
*
* Destroys and stops related timers.
*/
teardown(): void;
/**
* Hook into channel close
* @param {ChannelBindingCallback} callback
*/
onClose(callback: ChannelBindingCallback): void;
/**
* Hook into channel errors
* @param {ChannelOnErrorCallback} callback
* @return {number}
*/
onError(callback: ChannelOnErrorCallback): number;
/**
* Subscribes on channel events
*
* Subscription returns a ref counter, which can be used later to
* unsubscribe the exact event listener
*
* @example
* const ref1 = channel.on("event", do_stuff)
* const ref2 = channel.on("event", do_other_stuff)
* channel.off("event", ref1)
* // Since unsubscription, do_stuff won't fire,
* // while do_other_stuff will keep firing on the "event"
*
* @param {string} event
* @param {ChannelBindingCallback} callback
* @returns {number} ref
*/
on(event: string, callback: ChannelBindingCallback): number;
/**
* Unsubscribes off of channel events
*
* Use the ref returned from a channel.on() to unsubscribe one
* handler, or pass nothing for the ref to unsubscribe all
* handlers for the given event.
*
* @example
* // Unsubscribe the do_stuff handler
* const ref1 = channel.on("event", do_stuff)
* channel.off("event", ref1)
*
* // Unsubscribe all handlers from event
* channel.off("event")
*
* @param {string} event
* @param {number} [ref]
*/
off(event: string, ref?: number): void;
/**
* @private
*/
private canPush;
/**
* Sends a message `event` to phoenix with the payload `payload`.
* Phoenix receives this in the `handle_in(event, payload, socket)`
* function. if phoenix replies or it times out (default 10000ms),
* then optionally the reply can be received.
*
* @example
* channel.push("event")
* .receive("ok", payload => console.log("phoenix replied:", payload))
* .receive("error", err => console.log("phoenix errored", err))
* .receive("timeout", () => console.log("timed out pushing"))
* @param {string} event
* @param {Object} payload
* @param {number} [timeout]
* @returns {Push}
*/
push(event: string, payload: Object, timeout?: number): Push;
/** Leaves the channel
*
* Unsubscribes from server events, and
* instructs channel to terminate on server
*
* Triggers onClose() hooks
*
* To receive leave acknowledgements, use the `receive`
* hook to bind to the server ack, ie:
*
* @example
* channel.leave().receive("ok", () => alert("left!") )
*
* @param {number} timeout
* @returns {Push}
*/
leave(timeout?: number): Push;
onMessage(event: string, payload?: unknown, ref?: string | null, joinRef?: string | null): unknown;
filterBindings(binding: ChannelBinding, payload: unknown, ref?: string | null): boolean;
isMember(topic: any, event: any, payload: any, joinRef: any): boolean;
joinRef(): string | null | undefined;
/**
* @private
*/
private rejoin;
/**
* @param {string} event
* @param {unknown} [payload]
* @param {?string} [ref]
* @param {?string} [joinRef]
*/
trigger(event: string, payload?: unknown, ref?: string | null, joinRef?: string | null): void;
/**
* @param {string} ref
*/
replyEventName(ref: string): string;
isClosed(): boolean;
isErrored(): boolean;
isJoined(): boolean;
isJoining(): boolean;
isLeaving(): boolean;
}
import type { ChannelState } from "./types";
import type { Params } from "./types";
import type Socket from "./socket";
import type { ChannelBinding } from "./types";
import Push from "./push";
import Timer from "./timer";
import type { ChannelBindingCallback } from "./types";
import type { ChannelOnErrorCallback } from "./types";
//# sourceMappingURL=channel.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/channel.js"],"names":[],"mappings":"AASA;;;EAGE;AAEF;IACA;;;;OAIG;IACD,mBAJS,MAAM,UACN,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,UACvB,MAAM,EAsEd;IAnEC,0BAA0B;IAC1B,OADU,YAAY,CACY;IAClC,oBAAoB;IACpB,OADU,MAAM,CACE;IAClB,0BAA0B;IAC1B,QADU,MAAM,MAAM,CACa;IACnC,qBAAqB;IACrB,QADW,MAAM,CACG;IACpB,8BAA8B;IAC9B,UADU,cAAc,EAAE,CACR;IAClB,oBAAoB;IACpB,YADU,MAAM,CACG;IACnB,oBAAoB;IACpB,SADU,MAAM,CACkB;IAClC,qBAAqB;IACrB,YADU,OAAO,CACM;IACvB,kBAAkB;IAClB,UADU,IAAI,CACgE;IAC9E,oBAAoB;IACpB,YADU,IAAI,EAAE,CACI;IACpB,sBAAsB;IACtB,iBADU,MAAM,EAAE,CACO;IAEzB,mBAAmB;IACnB,aADU,KAAK,CAGc;IA2C/B;;;;OAIG;IACH,eAHW,MAAM,GACJ,IAAI,CAWhB;IAED;;;;OAIG;IACH,iBAOC;IAED;;;OAGG;IACH,kBAFW,sBAAsB,QAIhC;IAED;;;;OAIG;IACH,kBAHW,sBAAsB,GACrB,MAAM,CAIjB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,UAJW,MAAM,YACN,sBAAsB,GACpB,MAAM,CAMlB;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,WAHW,MAAM,QACN,MAAM,QAMhB;IAED;;OAEG;IACH,gBAAgE;IAEhE;;;;;;;;;;;;;;;OAeG;IACH,YALW,MAAM,WACN,MAAM,YACN,MAAM,GACJ,IAAI,CAgBhB;IAED;;;;;;;;;;;;;;;OAeG;IACH,gBAHW,MAAM,GACJ,IAAI,CAkBhB;;;IAsBD,sEASC;IAED,qCAAqC;IAErC;;OAEG;IACH,eAKC;IAED;;;;;OAKG;IACH,eALW,MAAM,YACN,OAAO,QACN,MAAM,OAAA,YACN,MAAM,OAAA,QAYjB;IAED;;MAEE;IACF,oBAFU,MAAM,UAEiC;IAEjD,oBAAyD;IAEzD,qBAA2D;IAE3D,oBAAyD;IAEzD,qBAA2D;IAE3D,qBAA2D;CAC5D;kCA/TgJ,SAAS;4BAAT,SAAS;wBADpI,UAAU;oCACiH,SAAS;iBALzI,QAAQ;kBACP,SAAS;4CAIsH,SAAS;4CAAT,SAAS"}
+37
View File
@@ -0,0 +1,37 @@
export const globalSelf: (Window & typeof globalThis) | null;
export const phxWindow: (Window & typeof globalThis) | null;
export const global: typeof globalThis;
export const DEFAULT_VSN: "2.0.0";
export const DEFAULT_TIMEOUT: 10000;
export const WS_CLOSE_NORMAL: 1000;
export const MAX_LONGPOLL_BATCH_SIZE: 100;
export namespace SOCKET_STATES {
let connecting: 0;
let open: 1;
let closing: 2;
let closed: 3;
}
export namespace CHANNEL_STATES {
let closed_1: "closed";
export { closed_1 as closed };
export let errored: "errored";
export let joined: "joined";
export let joining: "joining";
export let leaving: "leaving";
}
export namespace CHANNEL_EVENTS {
let close: "phx_close";
let error: "phx_error";
let join: "phx_join";
let reply: "phx_reply";
let leave: "phx_leave";
}
export namespace TRANSPORTS {
let longpoll: "longpoll";
let websocket: "websocket";
}
export namespace XHR_STATES {
let complete: 4;
}
export const AUTH_TOKEN_PREFIX: "base64url.bearer.phx.";
//# sourceMappingURL=constants.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/constants.js"],"names":[],"mappings":"AAAA,6DAAmE;AACnE,4DAAsE;AACtE,uCAA2D;AAC3D,0BAA2B,OAAO,CAAA;AAClC,8BAA+B,KAAK,CAAA;AACpC,8BAA+B,IAAI,CAAA;AACnC,sCAAuC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6B1C,gCAAiC,uBAAuB,CAAA"}
+10
View File
@@ -0,0 +1,10 @@
export * from "./types";
import Channel from "./channel";
import LongPoll from "./longpoll";
import Presence from "./presence";
import Push from "./push";
import Serializer from "./serializer";
import Socket from "./socket";
import Timer from "./timer";
export { Channel, LongPoll, Presence, Push, Serializer, Socket, Timer };
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/index.js"],"names":[],"mappings":";oBAkMoB,WAAW;qBACV,YAAY;qBACZ,YAAY;iBAIhB,QAAQ;uBAHF,cAAc;mBAClB,UAAU;kBACX,SAAS"}
+29
View File
@@ -0,0 +1,29 @@
export default class LongPoll {
constructor(endPoint: any, protocols: any);
authToken: string | undefined;
endPoint: any;
token: any;
skipHeartbeat: boolean;
reqs: Set<any>;
awaitingBatchAck: boolean;
currentBatch: any[] | null;
currentBatchTimer: NodeJS.Timeout | null;
batchBuffer: any[];
onopen: () => void;
onerror: () => void;
onmessage: () => void;
onclose: () => void;
pollEndpoint: any;
readyState: 0;
normalizeEndpoint(endPoint: any): any;
endpointURL(): any;
closeAndRetry(code: any, reason: any, wasClean: any): void;
ontimeout(): void;
isActive(): boolean;
poll(): void;
send(body: any): void;
batchSend(messages: any, offset?: number): void;
close(code: any, reason: any, wasClean: any): void;
ajax(method: any, headers: any, body: any, onCallerTimeout: any, callback: any): void;
}
//# sourceMappingURL=longpoll.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"longpoll.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/longpoll.js"],"names":[],"mappings":"AAiBA;IAEE,2CAsBC;IAlBG,8BAAmE;IAErE,cAAoB;IACpB,WAAiB;IACjB,uBAAyB;IACzB,eAAqB;IACrB,0BAA6B;IAC7B,2BAAwB;IACxB,yCAA6B;IAC7B,mBAAqB;IACrB,mBAA4B;IAC5B,oBAA6B;IAC7B,sBAA+B;IAC/B,oBAA6B;IAC7B,kBAAoD;IACpD,cAA0C;IAK5C,sCAKC;IAED,mBAEC;IAED,2DAGC;IAED,kBAGC;IAED,oBAA2G;IAE3G,aAiEC;IAMD,sBAaC;IAED,gDAkBC;IAED,mDAYC;IAED,sFAWC;CACF"}
+108
View File
@@ -0,0 +1,108 @@
/**
* @import Channel from "./channel"
* @import { PresenceEvents, PresenceOnJoin, PresenceOnLeave, PresenceOnSync, PresenceState, PresenceDiff, PresenceOptions } from "./types"
*/
export default class Presence {
/**
* Used to sync the list of presences on the server
* with the client's state. An optional `onJoin` and `onLeave` callback can
* be provided to react to changes in the client's local presences across
* disconnects and reconnects with the server.
*
* @param {Record<string, PresenceState>} currentState
* @param {Record<string, PresenceState>} newState
* @param {PresenceOnJoin} onJoin
* @param {PresenceOnLeave} onLeave
*
* @returns {Record<string, PresenceState>}
*/
static syncState(currentState: Record<string, PresenceState>, newState: Record<string, PresenceState>, onJoin: PresenceOnJoin, onLeave: PresenceOnLeave): Record<string, PresenceState>;
/**
*
* Used to sync a diff of presence join and leave
* events from the server, as they happen. Like `syncState`, `syncDiff`
* accepts optional `onJoin` and `onLeave` callbacks to react to a user
* joining or leaving from a device.
*
* @param {Record<string, PresenceState>} state
* @param {PresenceDiff} diff
* @param {PresenceOnJoin} onJoin
* @param {PresenceOnLeave} onLeave
*
* @returns {Record<string, PresenceState>}
*/
static syncDiff(state: Record<string, PresenceState>, diff: PresenceDiff, onJoin: PresenceOnJoin, onLeave: PresenceOnLeave): Record<string, PresenceState>;
/**
* Returns the array of presences, with selected metadata.
*
* @template [T=PresenceState]
* @param {Record<string, PresenceState>} presences
* @param {((key: string, obj: PresenceState) => T)} [chooser]
*
* @returns {T[]}
*/
static list<T = PresenceState>(presences: Record<string, PresenceState>, chooser?: ((key: string, obj: PresenceState) => T)): T[];
/**
* @template T
* @param {Record<string, PresenceState>} obj
* @param {(key: string, obj: PresenceState) => T} func
*/
static map<T>(obj: Record<string, PresenceState>, func: (key: string, obj: PresenceState) => T): T[];
static toNullProtoObj(obj: any): any;
/**
* @template T
* @param {T} obj
* @returns {T}
*/
static clone<T>(obj: T): T;
/**
* Initializes the Presence
* @param {Channel} channel - The Channel
* @param {PresenceOptions} [opts] - The options, for example `{events: {state: "state", diff: "diff"}}`
*/
constructor(channel: Channel, opts?: PresenceOptions);
/** @type{Record<string, PresenceState>} */
state: Record<string, PresenceState>;
/** @type{PresenceDiff[]} */
pendingDiffs: PresenceDiff[];
/** @type{Channel} */
channel: Channel;
/** @type{?number} */
joinRef: number | null;
/** @type{({ onJoin: PresenceOnJoin; onLeave: PresenceOnLeave; onSync: PresenceOnSync })} */
caller: ({
onJoin: PresenceOnJoin;
onLeave: PresenceOnLeave;
onSync: PresenceOnSync;
});
/**
* @param {PresenceOnJoin} callback
*/
onJoin(callback: PresenceOnJoin): void;
/**
* @param {PresenceOnLeave} callback
*/
onLeave(callback: PresenceOnLeave): void;
/**
* @param {PresenceOnSync} callback
*/
onSync(callback: PresenceOnSync): void;
/**
* Returns the array of presences, with selected metadata.
*
* @template [T=PresenceState]
* @param {((key: string, obj: PresenceState) => T)} [by]
*
* @returns {T[]}
*/
list<T = PresenceState>(by?: ((key: string, obj: PresenceState) => T)): T[];
inPendingSyncState(): boolean;
}
import type { PresenceState } from "./types";
import type { PresenceDiff } from "./types";
import type Channel from "./channel";
import type { PresenceOnJoin } from "./types";
import type { PresenceOnLeave } from "./types";
import type { PresenceOnSync } from "./types";
import type { PresenceOptions } from "./types";
//# sourceMappingURL=presence.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/presence.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IAgFE;;;;;;;;;;;;OAYG;IACH,+BAPW,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,YAC7B,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,UAC7B,cAAc,WACd,eAAe,GAEb,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAiCzC;IAED;;;;;;;;;;;;;OAaG;IACH,uBAPW,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,QAC7B,YAAY,UACZ,cAAc,WACd,eAAe,GAEb,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CA+BzC;IAED;;;;;;;;OAQG;IACH,YANc,CAAC,6BACJ,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,YAC7B,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,KAAK,CAAC,CAAC,GAEtC,CAAC,EAAE,CAQf;IAID;;;;MAIE;IACF,WAJY,CAAC,OACH,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,QAC7B,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,KAAK,CAAC,OAI/C;IAQD,qCAOC;IAED;;;;MAIE;IACF,aAJY,CAAC,OACH,CAAC,GACC,CAAC,CAE8C;IAzN3D;;;;OAIG;IACH,qBAHW,OAAO,SACP,eAAe,EA0CzB;IAtCC,2CAA2C;IAC3C,OADU,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CACP;IAChC,4BAA4B;IAC5B,cADU,YAAY,EAAE,CACF;IACtB,qBAAqB;IACrB,SADU,OAAO,CACK;IACtB,qBAAqB;IACrB,SADW,MAAM,OAAA,CACE;IACnB,4FAA4F;IAC5F,QADU,CAAC;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,cAAc,CAAA;KAAE,CAAC,CAKvF;IA2BH;;OAEG;IACH,iBAFW,cAAc,QAEwB;IAEjD;;OAEG;IACH,kBAFW,eAAe,QAEyB;IAEnD;;OAEG;IACH,iBAFW,cAAc,QAEwB;IAEjD;;;;;;;OAOG;IACH,KALc,CAAC,uBACJ,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,KAAK,CAAC,CAAC,GAEtC,CAAC,EAAE,CAEgC;IAEhD,8BAEC;CAgJF;mCA9NiI,SAAS;kCAAT,SAAS;yBADnH,WAAW;oCAC+F,SAAS;qCAAT,SAAS;oCAAT,SAAS;qCAAT,SAAS"}
+70
View File
@@ -0,0 +1,70 @@
/**
* @import Channel from "./channel"
* @import { ChannelEvent } from "./types"
*/
export default class Push {
/**
* Initializes the Push
* @param {Channel} channel - The Channel
* @param {ChannelEvent} event - The event, for example `"phx_join"`
* @param {() => Record<string, unknown>} payload - The payload, for example `{user_id: 123}`
* @param {number} timeout - The push timeout in milliseconds
*/
constructor(channel: Channel, event: ChannelEvent, payload: () => Record<string, unknown>, timeout: number);
/** @type{Channel} */
channel: Channel;
/** @type{ChannelEvent} */
event: ChannelEvent;
/** @type{() => Record<string, unknown>} */
payload: () => Record<string, unknown>;
receivedResp: unknown;
/** @type{number} */
timeout: number;
/** @type{(ReturnType<typeof setTimeout>) | null} */
timeoutTimer: (ReturnType<typeof setTimeout>) | null;
/** @type{{status: string; callback: (response: any) => void}[]} */
recHooks: {
status: string;
callback: (response: any) => void;
}[];
/** @type{boolean} */
sent: boolean;
/** @type{string | null | undefined} */
ref: string | null | undefined;
/**
*
* @param {number} timeout
*/
resend(timeout: number): void;
/**
*
*/
send(): void;
/**
*
* @param {string} status
* @param {(response: any) => void} callback
*/
receive(status: string, callback: (response: any) => void): this;
reset(): void;
refEvent: string | null | undefined;
destroy(): void;
/**
* @private
*/
private matchReceive;
/**
* @private
*/
private cancelRefEvent;
cancelTimeout(): void;
startTimeout(): void;
/**
* @private
*/
private hasReceived;
trigger(status: any, response: any): void;
}
import type Channel from "./channel";
import type { ChannelEvent } from "./types";
//# sourceMappingURL=push.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/push.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IACE;;;;;;OAMG;IACH,qBALW,OAAO,SACP,YAAY,WACZ,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAC7B,MAAM,EAoBhB;IAjBC,qBAAqB;IACrB,SADU,OAAO,CACK;IACtB,0BAA0B;IAC1B,OADU,YAAY,CACJ;IAClB,2CAA2C;IAC3C,SADU,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACW;IAClD,sBAAwB;IACxB,oBAAoB;IACpB,SADU,MAAM,CACM;IACtB,oDAAoD;IACpD,cADU,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,GAAG,IAAI,CACxB;IACxB,mEAAmE;IACnE,UADU;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAA;KAAC,EAAE,CAC7C;IAClB,qBAAqB;IACrB,MADU,OAAO,CACA;IACjB,uCAAuC;IACvC,KADU,MAAM,GAAG,IAAI,GAAG,SAAS,CACf;IAGtB;;;OAGG;IACH,gBAFW,MAAM,QAMhB;IAED;;OAEG;IACH,aAWC;IAED;;;;OAIG;IACH,gBAHW,MAAM,YACN,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,QASjC;IAED,cAMC;IAHC,oCAAoB;IAKtB,gBAGC;IAED;;OAEG;IACH,qBAGC;IAED;;OAEG;IACH,uBAGC;IAED,sBAGC;IAED,qBAeC;IAED;;OAEG;IACH,oBAEC;IAED,0CAEC;CACF;yBApIuB,WAAW;kCACF,SAAS"}
+75
View File
@@ -0,0 +1,75 @@
declare namespace _default {
let HEADER_LENGTH: number;
let META_LENGTH: number;
namespace KINDS {
let push: number;
let reply: number;
let broadcast: number;
}
/**
* @template T
* @param {Message<Record<string, any>>} msg
* @param {(msg: ArrayBuffer | string) => T} callback
* @returns {T}
*/
function encode<T>(msg: Message<Record<string, any>>, callback: (msg: ArrayBuffer | string) => T): T;
/**
* @template T
* @param {ArrayBuffer | string} rawPayload
* @param {(msg: Message<unknown>) => T} callback
* @returns {T}
*/
function decode<T>(rawPayload: ArrayBuffer | string, callback: (msg: Message<unknown>) => T): T;
/** @private */
function binaryEncode(message: any): any;
function assertFieldSize(size: any, name: any): void;
/**
* @private
*/
function binaryDecode(buffer: any): {
join_ref: any;
ref: null;
topic: any;
event: any;
payload: any;
} | {
join_ref: any;
ref: any;
topic: any;
event: "phx_reply";
payload: {
status: any;
response: any;
};
} | undefined;
/** @private */
function decodePush(buffer: any, view: any, decoder: any): {
join_ref: any;
ref: null;
topic: any;
event: any;
payload: any;
};
/** @private */
function decodeReply(buffer: any, view: any, decoder: any): {
join_ref: any;
ref: any;
topic: any;
event: "phx_reply";
payload: {
status: any;
response: any;
};
};
/** @private */
function decodeBroadcast(buffer: any, view: any, decoder: any): {
join_ref: null;
ref: null;
topic: any;
event: any;
payload: any;
};
}
export default _default;
import type { Message } from "./types";
//# sourceMappingURL=serializer.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/serializer.js"],"names":[],"mappings":";;;;;;;;IAcE;;;;;MAKE;IACF,gBALY,CAAC,OACH,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,YAC5B,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,KAAK,CAAC,GAC9B,CAAC,CASZ;IAED;;;;;MAKE;IACF,gBALY,CAAC,cACH,WAAW,GAAG,MAAM,YACpB,CAAC,GAAG,EAAE,QAAQ,OAAO,CAAC,KAAK,CAAC,GAC1B,CAAC,CASZ;IAED,eAAe;IACf,yCAkCC;IAED,qDAIC;IAED;;MAEE;IACF;;;;;;;;;;;;;;;kBASC;IAED,eAAe;IACf;;;;;;MAaC;IAED,eAAe;IACf;;;;;;;;;MAiBC;IAED,eAAe;IACf;;;;;;MAWC;;;6BA/IyB,SAAS"}
+291
View File
@@ -0,0 +1,291 @@
/**
* @import { Encode, Decode, Message, Vsn, SocketTransport, Params, SocketOnOpen, SocketOnClose, SocketOnError, SocketOnMessage, SocketOptions, SocketStateChangeCallbacks, HeartbeatCallback } from "./types"
*/
export default class Socket {
/** Initializes the Socket *
*
* For IE8 support use an ES5-shim (https://github.com/es-shims/es5-shim)
*
* @constructor
* @param {string} endPoint - The string WebSocket endpoint, ie, `"ws://example.com/socket"`,
* `"wss://example.com"`
* `"/socket"` (inherited host & protocol)
* @param {SocketOptions} [opts] - Optional configuration
*/
constructor(endPoint: string, opts?: SocketOptions);
/** @type{SocketStateChangeCallbacks} */
stateChangeCallbacks: SocketStateChangeCallbacks;
/** @type{Channel[]} */
channels: Channel[];
/** @type{(() => void)[]} */
sendBuffer: (() => void)[];
/** @type{number} */
ref: number;
/** @type{?string} */
fallbackRef: string | null;
/** @type{number} */
timeout: number;
/** @type{SocketTransport} */
transport: SocketTransport;
/** @type{InstanceType<SocketTransport> | undefined | null} */
conn: InstanceType<SocketTransport> | undefined | null;
/** @type{boolean} */
primaryPassedHealthCheck: boolean;
/** @type{number | undefined} */
longPollFallbackMs: number | undefined;
/** @type{ReturnType<typeof setTimeout>} */
fallbackTimer: ReturnType<typeof setTimeout>;
/** @type{Storage} */
sessionStore: Storage;
/** @type{number} */
establishedConnections: number;
/** @type{Encode<void>} */
defaultEncoder: Encode<void>;
/** @type{Decode<void>} */
defaultDecoder: Decode<void>;
/** @type{boolean} */
closeWasClean: boolean;
/** @type{boolean} */
disconnecting: boolean;
/** @type{BinaryType} */
binaryType: BinaryType;
/** @type{number} */
connectClock: number;
/** @type{boolean} */
pageHidden: boolean;
/** @type{Encode<void>} */
encode: Encode<void>;
/** @type{Decode<void>} */
decode: Decode<void>;
/** @type{number} */
heartbeatIntervalMs: number;
/** @type{boolean} */
autoSendHeartbeat: boolean;
/** @type{HeartbeatCallback} */
heartbeatCallback: HeartbeatCallback;
/** @type{(tries: number) => number} */
rejoinAfterMs: (tries: number) => number;
/** @type{(tries: number) => number} */
reconnectAfterMs: (tries: number) => number;
/** @type{((kind: string, msg: string, data: any) => void) | null} */
logger: ((kind: string, msg: string, data: any) => void) | null;
/** @type{number} */
longpollerTimeout: number;
/** @type{() => Params} */
params: () => Params;
/** @type{string} */
endPoint: string;
/** @type{Vsn} */
vsn: Vsn;
/** @type{ReturnType<typeof setTimeout>} */
heartbeatTimeoutTimer: ReturnType<typeof setTimeout>;
/** @type{ReturnType<typeof setTimeout>} */
heartbeatTimer: ReturnType<typeof setTimeout>;
/** @type{number | null} */
heartbeatSentAt: number | null;
/** @type{?string} */
pendingHeartbeatRef: string | null;
/** @type{Timer} */
reconnectTimer: Timer;
/** @type{(() => string) | undefined} */
authToken: (() => string) | undefined;
/**
* Returns the LongPoll transport reference
*/
getLongPollTransport(): typeof LongPoll;
/**
* Disconnects and replaces the active transport
*
* @param {SocketTransport} newTransport - The new transport class to instantiate
*
*/
replaceTransport(newTransport: SocketTransport): void;
/**
* Returns the socket protocol
*
* @returns {"wss" | "ws"}
*/
protocol(): "wss" | "ws";
/**
* The fully qualified socket url
*
* @returns {string}
*/
endPointURL(): string;
/**
* Disconnects the socket
*
* See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes for valid status codes.
*
* @param {() => void} [callback] - Optional callback which is called after socket is disconnected.
* @param {number} [code] - A status code for disconnection (Optional).
* @param {string} [reason] - A textual description of the reason to disconnect. (Optional)
*/
disconnect(callback?: () => void, code?: number, reason?: string): void;
/**
* @param {Params} [params] - [DEPRECATED] The params to send when connecting, for example `{user_id: userToken}`
*
* Passing params to connect is deprecated; pass them in the Socket constructor instead:
* `new Socket("/socket", {params: {user_id: userToken}})`.
*/
connect(params?: Params): void;
/**
* Logs the message. Override `this.logger` for specialized logging. noops by default
* @param {string} kind
* @param {string} msg
* @param {Object} data
*/
log(kind: string, msg: string, data: Object): void;
/**
* Returns true if a logger has been set on this socket.
*/
hasLogger(): boolean;
/**
* Registers callbacks for connection open events
*
* @example socket.onOpen(function(){ console.info("the socket was opened") })
*
* @param {SocketOnOpen} callback
*/
onOpen(callback: SocketOnOpen): string;
/**
* Registers callbacks for connection close events
* @param {SocketOnClose} callback
* @returns {string}
*/
onClose(callback: SocketOnClose): string;
/**
* Registers callbacks for connection error events
*
* @example socket.onError(function(error){ alert("An error occurred") })
*
* @param {SocketOnError} callback
* @returns {string}
*/
onError(callback: SocketOnError): string;
/**
* Registers callbacks for connection message events
* @param {SocketOnMessage} callback
* @returns {string}
*/
onMessage(callback: SocketOnMessage): string;
/**
* Sets a callback that receives lifecycle events for internal heartbeat messages.
* Useful for instrumenting connection health (e.g. sent/ok/timeout/disconnected).
* @param {HeartbeatCallback} callback
*/
onHeartbeat(callback: HeartbeatCallback): void;
/**
* Pings the server and invokes the callback with the RTT in milliseconds
* @param {(timeDelta: number) => void} callback
*
* Returns true if the ping was pushed or false if unable to be pushed.
*/
ping(callback: (timeDelta: number) => void): boolean;
/**
* @private
*
* @param {Function}
*/
private transportName;
/**
* @private
*/
private transportConnect;
getSession(key: any): string | null;
storeSession(key: any, val: any): void;
connectWithFallback(fallbackTransport: any, fallbackThreshold?: number): void;
clearHeartbeats(): void;
onConnOpen(): void;
/**
* @private
*/
private heartbeatTimeout;
resetHeartbeat(): void;
teardown(callback: any, code: any, reason: any): any;
waitForBufferDone(conn: any, callback: any, tries?: number): void;
waitForSocketClosed(conn: any, callback: any, tries?: number): void;
/**
* @param {CloseEvent} event
*/
onConnClose(event: CloseEvent): void;
/**
* @private
* @param {Event} error
*/
private onConnError;
/**
* @private
* @param {unknown} [reason] underlying close/error event forwarded to channel error listeners
*/
private triggerChanError;
/**
* @returns {string}
*/
connectionState(): string;
/**
* @returns {boolean}
*/
isConnected(): boolean;
/**
*
* @param {Channel} channel
*/
remove(channel: Channel): void;
/**
* Removes `onOpen`, `onClose`, `onError,` and `onMessage` registrations.
*
* @param {string[]} refs - list of refs returned by calls to
* `onOpen`, `onClose`, `onError,` and `onMessage`
*/
off(refs: string[]): void;
/**
* Initiates a new channel for the given topic
*
* @param {string} topic
* @param {Params | (() => Params)} [chanParams]- Parameters for the channel
* @returns {Channel}
*/
channel(topic: string, chanParams?: Params | (() => Params)): Channel;
/**
* @param {Message<Record<string, any>>} data
*/
push(data: Message<Record<string, any>>): void;
/**
* Return the next message ref, accounting for overflows
* @returns {string}
*/
makeRef(): string;
sendHeartbeat(): void;
flushSendBuffer(): void;
/**
* @param {MessageEvent<any>} rawMessage
*/
onConnMessage(rawMessage: MessageEvent<any>): void;
/**
* @private
* @template {keyof SocketStateChangeCallbacks} K
* @param {K} event
* @param {...Parameters<SocketStateChangeCallbacks[K][number][1]>} args
* @returns {void}
*/
private triggerStateCallbacks;
leaveOpenTopic(topic: any): void;
}
import type { SocketStateChangeCallbacks } from "./types";
import Channel from "./channel";
import type { SocketTransport } from "./types";
import type { Encode } from "./types";
import type { Decode } from "./types";
import type { HeartbeatCallback } from "./types";
import type { Params } from "./types";
import type { Vsn } from "./types";
import Timer from "./timer";
import LongPoll from "./longpoll";
import type { SocketOnOpen } from "./types";
import type { SocketOnClose } from "./types";
import type { SocketOnError } from "./types";
import type { SocketOnMessage } from "./types";
import type { Message } from "./types";
import type { SocketOptions } from "./types";
//# sourceMappingURL=socket.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/socket.js"],"names":[],"mappings":"AAsBA;;EAEE;AAEF;IACE;;;;;;;;;OASG;IACH,sBALW,MAAM,SAGN,aAAa,EAoJvB;IAjJC,wCAAwC;IACxC,sBADU,0BAA0B,CACqC;IACzE,uBAAuB;IACvB,UADU,OAAO,EAAE,CACD;IAClB,4BAA4B;IAC5B,YADU,CAAC,MAAM,IAAI,CAAC,EAAE,CACJ;IACpB,oBAAoB;IACpB,KADU,MAAM,CACJ;IACZ,qBAAqB;IACrB,aADW,MAAM,OAAA,CACM;IACvB,oBAAoB;IACpB,SADU,MAAM,CAC8B;IAC9C,6BAA6B;IAC7B,WADU,eAAe,CACsC;IAC/D,8DAA8D;IAC9D,MADU,YAAY,CAAC,eAAe,CAAC,GAAG,SAAS,GAAG,IAAI,CACrC;IACrB,qBAAqB;IACrB,0BADU,OAAO,CACoB;IACrC,gCAAgC;IAChC,oBADU,MAAM,GAAG,SAAS,CACqB;IACjD,2CAA2C;IAC3C,eADU,UAAU,CAAC,OAAO,UAAU,CAAC,CACd;IAOzB,qBAAqB;IACrB,cADU,OAAO,CAC2C;IAC5D,oBAAoB;IACpB,wBADU,MAAM,CACe;IAC/B,0BAA0B;IAC1B,gBADU,OAAO,IAAI,CAAC,CACkC;IACxD,0BAA0B;IAC1B,gBADU,OAAO,IAAI,CAAC,CACkC;IAIxD,qBAAqB;IACrB,eADU,OAAO,CACQ;IACzB,qBAAqB;IACrB,eADU,OAAO,CACS;IAC1B,wBAAwB;IACxB,YADU,UAAU,CAC8B;IAClD,oBAAoB;IACpB,cADU,MAAM,CACK;IACrB,qBAAqB;IACrB,YADU,OAAO,CACM;IACvB,0BAA0B;I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BAAT,SAAS;4BAAT,SAAS;uCAAT,SAAS;4BAAT,SAAS;yBAAT,SAAS;kBAH3L,SAAS;qBAFN,YAAY;kCAKmK,SAAS;mCAAT,SAAS;mCAAT,SAAS;qCAAT,SAAS;6BAAT,SAAS;mCAAT,SAAS"}
+36
View File
@@ -0,0 +1,36 @@
/**
*
* Creates a timer that accepts a `timerCalc` function to perform
* calculated timeout retries, such as exponential backoff.
*
* @example
* let reconnectTimer = new Timer(() => this.connect(), function(tries){
* return [1000, 5000, 10000][tries - 1] || 10000
* })
* reconnectTimer.scheduleTimeout() // fires after 1000
* reconnectTimer.scheduleTimeout() // fires after 5000
* reconnectTimer.reset()
* reconnectTimer.scheduleTimeout() // fires after 1000
*
*/
export default class Timer {
/**
* @param {() => void} callback
* @param {(tries: number) => number} timerCalc
*/
constructor(callback: () => void, timerCalc: (tries: number) => number);
/** @type {() => void} */
callback: () => void;
/** @type {(tries: number) => number} */
timerCalc: (tries: number) => number;
/** @type {ReturnType<typeof setTimeout> | undefined} */
timer: ReturnType<typeof setTimeout> | undefined;
/** @type {number} */
tries: number;
reset(): void;
/**
* Cancels any previous scheduleTimeout and schedules callback
*/
scheduleTimeout(): void;
}
//# sourceMappingURL=timer.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/timer.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH;IACE;;;MAGE;IACF,sBAHU,MAAM,IAAI,aACV,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAWlC;IARC,yBAAyB;IACzB,UADW,MAAM,IAAI,CACG;IACxB,wCAAwC;IACxC,WADW,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CACV;IAC1B,wDAAwD;IACxD,OADW,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAC9B;IACtB,qBAAqB;IACrB,OADW,MAAM,CACH;IAGhB,cAGC;IAED;;OAEG;IACH,wBAOC;CACF"}
+280
View File
@@ -0,0 +1,280 @@
/**
* MISC
*/
export type Params = Record<string, unknown>;
export type Closure<T> = T | (() => T);
/**
* CHANNEL
*/
export type ChannelBindingCallback = (payload: unknown, ref: string | null | undefined, joinRef: string) => void;
/**
* CHANNEL
*/
export type ChannelOnErrorCallback = (reason: unknown) => void;
/**
* CHANNEL
*/
export type ChannelBinding = ({
event: string;
ref: number;
callback: ChannelBindingCallback;
});
/**
* CHANNEL
*/
export type ChannelOnMessage = (event: string, payload?: unknown, ref?: string | null, joinRef?: string | null) => unknown;
/**
* CHANNEL
*/
export type ChannelFilterBindings = (binding: ChannelBinding, payload: unknown, ref?: string | null) => boolean;
/**
* CONSTANTS
*/
export type Vsn = "1.0.0" | "2.0.0";
/**
* CONSTANTS
*/
export type SocketState = (typeof SOCKET_STATES)[keyof typeof SOCKET_STATES];
/**
* CONSTANTS
*/
export type ChannelState = (typeof CHANNEL_STATES)[keyof typeof CHANNEL_STATES];
/**
* CONSTANTS
*/
export type ChannelEvent = (typeof CHANNEL_EVENTS)[keyof typeof CHANNEL_EVENTS];
/**
* CONSTANTS
*/
export type Transport = (typeof TRANSPORTS)[keyof typeof TRANSPORTS];
/**
* CONSTANTS
*/
export type XhrState = (typeof XHR_STATES)[keyof typeof XHR_STATES];
/**
* PRESENCE
*/
export type PresenceEvents = {
state: string;
diff: string;
};
/**
* PRESENCE
*/
export type PresenceOnJoin = (key: string, currentPresence: PresenceState, newPresence: PresenceState) => void;
/**
* PRESENCE
*/
export type PresenceOnLeave = (key: string, currentPresence: PresenceState, leftPresence: PresenceState) => void;
/**
* PRESENCE
*/
export type PresenceOnSync = () => void;
/**
* PRESENCE
*/
export type PresenceDiff = ({
joins: PresenceState;
leaves: PresenceState;
});
/**
* PRESENCE
*/
export type PresenceState = ({
metas: {
phx_ref?: string;
phx_ref_prev?: string;
[key: string]: any;
}[];
});
/**
* PRESENCE
*/
export type PresenceOptions = {
events?: PresenceEvents | undefined;
};
/**
* SERIALIZER
*/
export type Message<T> = ({
join_ref?: string | null;
ref?: string | null;
event: string;
topic: string;
payload: T;
});
export type Encode<T> = (msg: Message<Record<string, any>>, callback: (result: ArrayBuffer | string) => T) => T;
export type Decode<T> = (rawPayload: ArrayBuffer | string, callback: (msg: Message<unknown>) => T) => T;
/**
* SOCKET
*/
export type SocketTransport = (typeof WebSocket | typeof LongPoll);
/**
* SOCKET
*/
export type SocketOnOpen = () => void;
/**
* SOCKET
*/
export type SocketOnClose = (event: CloseEvent) => void;
/**
* SOCKET
*/
export type SocketOnError = (error: Event, transportBefore: SocketTransport, establishedBefore: number) => void;
/**
* SOCKET
*/
export type SocketOnMessage = (rawMessage: Message<unknown>) => void;
/**
* SOCKET
*/
export type SocketStateChangeCallbacks = ({
open: [string, SocketOnOpen][];
close: [string, SocketOnClose][];
error: [string, SocketOnError][];
message: [string, SocketOnMessage][];
});
/**
* SOCKET
*/
export type HeartbeatStatus = "sent" | "ok" | "error" | "timeout" | "disconnected";
/**
* SOCKET
*/
export type HeartbeatCallback = (status: HeartbeatStatus, latency?: number) => void;
/**
* SOCKET
*/
export type SocketOptions = {
/**
* - The Websocket Transport, for example WebSocket or Phoenix.LongPoll.
*/
transport?: SocketTransport | undefined;
/**
* - The millisecond time to attempt the primary transport
* before falling back to the LongPoll transport. Disabled by default.
*/
longPollFallbackMs?: number | undefined;
/**
* - The millisecond time before LongPoll transport times out. Default 20000.
*/
longpollerTimeout?: number | undefined;
/**
* - When true, enables debug logging. Default false.
*/
debug?: boolean | undefined;
/**
* - The function to encode outgoing messages.
* Defaults to JSON encoder.
*/
encode?: Encode<void> | undefined;
/**
* - The function to decode incoming messages.
* Defaults to JSON:
*
* ```javascript
* (payload, callback) => callback(JSON.parse(payload))
* ```
*/
decode?: Decode<void> | undefined;
/**
* - The default timeout in milliseconds to trigger push timeouts.
* Defaults `DEFAULT_TIMEOUT`
*/
timeout?: number | undefined;
/**
* - The millisec interval to send a heartbeat message
*/
heartbeatIntervalMs?: number | undefined;
/**
* - Whether to automatically send heartbeats after
* connection is established.
*
* Defaults to true.
*/
autoSendHeartbeat?: boolean | undefined;
/**
* - The optional function to handle heartbeat status and latency.
*/
heartbeatCallback?: HeartbeatCallback | undefined;
/**
* - The optional function that returns the
* socket reconnect interval, in milliseconds.
*
* Defaults to stepped backoff of:
*
* ```javascript
* function(tries){
* return [10, 50, 100, 150, 200, 250, 500, 1000, 2000][tries - 1] || 5000
* }
* ````
*/
reconnectAfterMs?: ((tries: number) => number) | undefined;
/**
* - The optional function that returns the millisec
* rejoin interval for individual channels.
*
* ```javascript
* function(tries){
* return [1000, 2000, 5000][tries - 1] || 10000
* }
* ````
*/
rejoinAfterMs?: ((tries: number) => number) | undefined;
/**
* - The optional function for specialized logging, ie:
*
* ```javascript
* function(kind, msg, data) {
* console.log(`${kind}: ${msg}`, data)
* }
* ```
*/
logger?: ((kind: string, msg: string, data: any) => void) | undefined;
/**
* - The optional params to pass when connecting
*/
params?: Closure<Params> | undefined;
/**
* - the optional authentication token to be exposed on the server
* under the `:auth_token` connect_info key. Can be a string or a function that returns a string.
*/
authToken?: Closure<string> | undefined;
/**
* - The binary type to use for binary WebSocket frames.
*
* Defaults to "arraybuffer"
*/
binaryType?: BinaryType | undefined;
/**
* - The serializer's protocol version to send on connect.
*
* Defaults to DEFAULT_VSN.
*/
vsn?: Vsn | undefined;
/**
* - An optional Storage compatible object
* Phoenix uses sessionStorage for longpoll fallback history. Overriding the store is
* useful when Phoenix won't have access to `sessionStorage`. For example, This could
* happen if a site loads a cross-domain channel in an iframe. Example usage:
*
* class InMemoryStorage {
* constructor() { this.storage = {} }
* getItem(keyName) { return this.storage[keyName] || null }
* removeItem(keyName) { delete this.storage[keyName] }
* setItem(keyName, keyValue) { this.storage[keyName] = keyValue }
* }
*/
sessionStorage?: Storage | undefined;
/**
* - Callback ran before socket tries to reconnect.
*/
beforeReconnect?: (() => Promise<void>) | undefined;
};
import type { SOCKET_STATES } from "./constants";
import type { CHANNEL_STATES } from "./constants";
import type { CHANNEL_EVENTS } from "./constants";
import type { TRANSPORTS } from "./constants";
import type { XHR_STATES } from "./constants";
import type LongPoll from "./longpoll";
//# sourceMappingURL=types.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/types.js"],"names":[],"mappings":";;;qBAMa,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;oBAIvB,CAAC,IACD,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;;;;qCAMb,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI;;;;qCAC3E,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI;;;;6BACzB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,sBAAsB,CAAA;CAAC,CAAC;;;;+BAChE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,EAAG,MAAM,OAAA,EAAE,OAAO,CAAC,EAAG,MAAM,OAAA,KAAK,OAAO;;;;oCAC/E,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,EAAG,MAAM,OAAA,KAAK,OAAO;;;;kBAOrE,OAAO,GAAG,OAAO;;;;0BACjB,CAAO,oBAAa,EAAC,MAAa,oBAAa,CAAC;;;;2BAChD,CAAO,qBAAc,EAAC,MAAa,qBAAc,CAAC;;;;2BAClD,CAAO,qBAAc,EAAC,MAAa,qBAAc,CAAC;;;;wBAClD,CAAO,iBAAU,EAAC,MAAa,iBAAU,CAAC;;;;uBAC1C,CAAO,iBAAU,EAAC,MAAa,iBAAU,CAAC;;;;6BAK1C;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC;;;;6BAC7B,CAAC,G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nF,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI;;;;yCACtC,CAAC;IACT,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAA;IAC9B,KAAK,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAA;IAChC,KAAK,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAA;IAChC,OAAO,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,CAAA;CACrC,CAAC;;;;8BACQ,MAAM,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc;;;;gCACpD,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAoC1C,MAAM,KAAK,MAAM;;;;;;;;;;;6BAWjB,MAAM,KAAK,MAAM;;;;;;;;;;qBASlB,MAAM,OAAO,MAAM,QAAQ,GAAG,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAiCxC,OAAO,CAAC,IAAI,CAAC;;mCAzJuD,aAAa;oCAAb,aAAa;oCAAb,aAAa;gCAAb,aAAa;gCAAb,aAAa;0BA1B5E,YAAY"}
+2
View File
@@ -0,0 +1,2 @@
export function closure<T>(value: T | (() => T)): () => T;
//# sourceMappingURL=utils.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../assets/js/phoenix/utils.js"],"names":[],"mappings":"AAQO,wBAJK,CAAC,SACH,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GACX,MAAM,CAAC,CASlB"}