{"version":3,"file":"application-qclkD26z.js","sources":["../../../node_modules/nanoevents/index.js","../../../node_modules/@anycable/core/protocol/index.js","../../../node_modules/@anycable/core/stringify-params/index.js","../../../node_modules/@anycable/core/channel/index.js","../../../node_modules/@anycable/core/hub/index.js","../../../node_modules/@anycable/core/logger/index.js","../../../node_modules/@anycable/core/encoder/index.js","../../../node_modules/@anycable/core/action_cable/index.js","../../../node_modules/@anycable/core/action_cable_ext/index.js","../../../node_modules/@anycable/core/cable/index.js","../../../node_modules/@anycable/core/monitor/index.js","../../../node_modules/@anycable/core/transport/index.js","../../../node_modules/@anycable/core/websocket/index.js","../../../node_modules/@anycable/core/create-cable/index.js","../../../node_modules/@anycable/web/logger/index.js","../../../node_modules/@anycable/web/monitor/index.js","../../../node_modules/@anycable/web/index.js","../../../app/frontend/entrypoints/application.js"],"sourcesContent":["export let createNanoEvents = () => ({\n events: {},\n emit(event, ...args) {\n let callbacks = this.events[event] || []\n for (let i = 0, length = callbacks.length; i < length; i++) {\n callbacks[i](...args)\n }\n },\n on(event, cb) {\n this.events[event]?.push(cb) || (this.events[event] = [cb])\n return () => {\n this.events[event] = this.events[event]?.filter(i => cb !== i)\n }\n }\n})\n","export class ReasonError extends Error {\n constructor(msg, reason) {\n if (msg instanceof Error) {\n super(msg.message)\n this.cause = msg\n } else {\n super(msg)\n }\n\n this.reason = reason\n this.name = 'ReasonError'\n }\n}\n\nexport class SubscriptionRejectedError extends ReasonError {\n constructor(reason) {\n super('Rejected', reason)\n this.name = 'SubscriptionRejectedError'\n }\n}\n\nexport class SubscriptionTimeoutError extends ReasonError {\n constructor(msg) {\n super(msg || 'Timed out to receive subscription ack')\n this.name = 'SubscriptionTimeoutError'\n }\n}\n\nexport class DisconnectedError extends ReasonError {\n constructor(error, reason) {\n if (reason) {\n super(error, reason)\n } else {\n super('Disconnected', error)\n }\n this.name = 'DisconnectedError'\n }\n}\n\nexport class CommandError extends Error {\n constructor(msg) {\n super(msg)\n this.name = 'CommandError'\n }\n}\n\nexport class StaleConnectionError extends DisconnectedError {\n constructor(msg) {\n super(msg, 'stale_connection')\n this.name = 'StaleConnectionError'\n }\n}\n","export function stringifyParams(params) {\n if (!params) return ''\n\n let parts = Object.keys(params)\n .sort()\n .filter(k => params[k] !== undefined)\n .map(k => {\n let v = JSON.stringify(params[k])\n return `${JSON.stringify(k)}:${v}`\n })\n\n return `{${parts.join(',')}}`\n}\n","/*eslint n/no-unsupported-features/es-syntax: [\"error\", {version: \"14.0\"}] */\nimport { createNanoEvents } from 'nanoevents'\n\nimport { ReasonError } from '../protocol/index.js'\nimport { stringifyParams } from '../stringify-params/index.js'\n\nconst STATE = Symbol('state')\n\nexport class Channel {\n // Unique channel identifier\n // static identifier = ''\n\n constructor(params = {}) {\n this.emitter = createNanoEvents()\n this.params = Object.freeze(params)\n\n this.initialConnect = true\n\n this[STATE] = 'idle'\n }\n\n get identifier() {\n if (this._identifier) return this._identifier\n\n // Use Action Cable identifiers as internal identifiers for channels\n this._identifier = stringifyParams({\n channel: this.channelId,\n ...this.params\n })\n\n return this._identifier\n }\n\n get channelId() {\n return this.constructor.identifier\n }\n\n get state() {\n return this[STATE]\n }\n\n attached(receiver) {\n if (this.receiver) {\n if (this.receiver !== receiver) {\n throw Error('Already connected to a different receiver')\n }\n\n return false\n }\n\n this.receiver = receiver\n return true\n }\n\n connecting() {\n this[STATE] = 'connecting'\n }\n\n connected() {\n if (this.state === 'connected') return\n if (this.state === 'closed') return\n\n this[STATE] = 'connected'\n\n let restored = false\n\n if (this.initialConnect) {\n this.initialConnect = false\n this.emit('connect', { reconnect: false, restored })\n } else {\n this.emit('connect', { reconnect: true, restored })\n }\n }\n\n restored() {\n if (this.state === 'connected') throw Error('Already connected')\n\n this[STATE] = 'connected'\n\n let restored = true\n let reconnect = true\n\n this.initialConnect = false\n\n this.emit('connect', { reconnect, restored })\n }\n\n disconnected(err) {\n if (this.state === 'disconnected' || this.state === 'closed') return\n\n this[STATE] = 'disconnected'\n\n this.emit('disconnect', err)\n }\n\n closed(err) {\n if (this.state === 'closed') return\n\n this[STATE] = 'closed'\n delete this.receiver\n\n this.initialConnect = true\n\n this.emit('close', err)\n }\n\n disconnect() {\n if (this.state === 'idle' || this.state === 'closed') {\n return\n }\n\n this.receiver.unsubscribe(this)\n }\n\n async perform(action, payload) {\n if (this.state === 'idle' || this.state === 'closed') {\n throw Error('Channel is not subscribed')\n }\n\n return this.receiver.perform(this.identifier, action, payload)\n }\n\n async send(payload) {\n return this.perform(undefined, payload)\n }\n\n receive(msg, meta) {\n this.emit('message', msg, meta)\n }\n\n on(event, callback) {\n return this.emitter.on(event, callback)\n }\n\n once(event, callback) {\n let unbind = this.emitter.on(event, (...args) => {\n unbind()\n callback(...args)\n })\n return unbind\n }\n\n emit(event, ...args) {\n return this.emitter.emit(event, ...args)\n }\n\n ensureSubscribed() {\n if (this.state === 'connected') return Promise.resolve()\n\n if (this.state === 'closed') {\n return Promise.reject(Error('Channel is unsubscribed'))\n }\n\n return this.pendingSubscribe()\n }\n\n // This promise resolves when subscription is confirmed\n // and rejects when rejected or closed.\n // It ignores disconnect events.\n pendingSubscribe() {\n if (this._pendingSubscribe) return this._pendingSubscribe\n\n this._pendingSubscribe = new Promise((resolve, reject) => {\n let unbind = [() => delete this._pendingSubscribe]\n\n unbind.push(\n this.on('connect', () => {\n unbind.forEach(clbk => clbk())\n resolve()\n })\n )\n unbind.push(\n this.on('close', err => {\n unbind.forEach(clbk => clbk())\n reject(\n err ||\n new ReasonError(\n 'Channel was disconnected before subscribing',\n 'canceled'\n )\n )\n })\n )\n })\n\n return this._pendingSubscribe\n }\n}\n","export class Subscription {\n constructor(id) {\n this.id = id\n this.intent = 'unsubscribed'\n this.state = 'idle'\n this.channels = []\n this.disposed = false\n this._pendings = []\n }\n\n add(channel) {\n if (this.channels.includes(channel)) return\n\n this.channels.push(channel)\n }\n\n remove(channel) {\n let ind = this.channels.indexOf(channel)\n\n if (ind > -1) this.channels.splice(ind, 1)\n }\n\n notify(state, ...args) {\n // TODO: Should we get rid of restored state completely?\n this.state = state === 'restored' ? 'connected' : state\n\n if (args.length === 1) {\n this.channels.forEach(channel => channel[state](args[0]))\n } else {\n this.channels.forEach(channel => channel[state]())\n }\n }\n\n pending(intent) {\n this._checkIntent(intent)\n\n let nextPending = this._pendings[0]\n\n if (!nextPending || nextPending.intent !== intent) return Promise.resolve()\n\n return nextPending.promise\n }\n\n ensureResubscribed() {\n if (this.disposed) return\n\n this.intent = undefined\n\n this.ensureSubscribed()\n }\n\n ensureSubscribed() {\n if (this.intent === 'subscribed') return\n if (this.disposed) throw Error('Subscription is disposed')\n\n this.intent = 'subscribed'\n\n let merged = this._mergeWithPending('unsubscribed')\n if (merged) return\n\n this.subscriber(this)\n }\n\n maybeUnsubscribe() {\n if (this.disposed) return\n if (this.intent === 'unsubscribed') return\n\n if (this.channels.length > 0) return\n\n this.intent = 'unsubscribed'\n\n let merged = this._mergeWithPending('subscribed')\n if (merged) return\n\n this.unsubscriber(this)\n }\n\n async acquire(intent) {\n this._checkIntent(intent)\n\n let resolver\n let promise = new Promise(resolve => {\n resolver = resolve\n })\n\n let lock = {\n promise,\n intent,\n release: () => {\n this._pendings.splice(this._pendings.indexOf(lock), 1)\n resolver(lock)\n },\n canceled: false,\n acquired: false\n }\n\n let top = this._pendingTop\n\n this._pendings.push(lock)\n\n if (top) {\n await top.promise\n }\n\n if (this.gvl) {\n await this.gvl.acquire(lock, intent)\n }\n\n lock.acquired = true\n return lock\n }\n\n close(err) {\n this.disposed = true\n this.intent = undefined\n this.notify('closed', err)\n }\n\n _checkIntent(event) {\n if (event === 'unsubscribed' || event === 'subscribed') return\n\n throw Error(`Unknown subscription intent: ${event}`)\n }\n\n get _pendingTop() {\n return this._pendings.length\n ? this._pendings[this._pendings.length - 1]\n : undefined\n }\n\n _mergeWithPending(intent) {\n let top = this._pendingTop\n if (!top) return false\n if (top.acquired) return false\n if (top.intent !== intent) return false\n\n this._pendings.pop()\n top.canceled = true\n return true\n }\n}\n\n// Use to limit concurrent actions\nclass GlobalLock {\n constructor() {\n this.queue = []\n }\n\n async acquire(lock, intent) {\n // We currently only limit subscribe commands\n if (intent !== 'subscribed') return\n\n this.queue.push(\n lock.promise.then(() => {\n this.queue.splice(this.queue.indexOf(lock), 1)\n })\n )\n\n if (this.queue.length > 1) {\n await this.queue[this.queue.length - 2]\n }\n }\n}\n\nexport class Subscriptions {\n constructor(opts) {\n if (opts.concurrentSubscribes === false) {\n this.glv = new GlobalLock()\n }\n this._subscriptions = {}\n this._localToRemote = {}\n }\n\n all() {\n return Object.values(this._subscriptions)\n }\n\n get(id) {\n return this._subscriptions[id]\n }\n\n create(id, { subscribe, unsubscribe }) {\n let sub = (this._subscriptions[id] = new Subscription(id))\n sub.remoteId = this._localToRemote[id]\n sub.subscriber = subscribe\n sub.unsubscriber = unsubscribe\n sub.gvl = this.glv\n\n return sub\n }\n\n remove(id) {\n delete this._subscriptions[id]\n delete this._localToRemote[id]\n }\n\n storeRemoteId(localId, remoteId) {\n this._localToRemote[localId] = remoteId\n\n let sub = this.get(localId)\n if (sub) sub.remoteId = remoteId\n }\n}\n\nexport class Hub {\n constructor(opts = {}) {\n this.subscriptions = new Subscriptions(opts)\n this._pendingMessages = []\n this._remoteToLocal = {}\n }\n\n subscribe(localId, remoteId) {\n this._remoteToLocal[remoteId] = localId\n\n this.subscriptions.storeRemoteId(localId, remoteId)\n\n this.flush(remoteId)\n }\n\n unsubscribe(localId) {\n let sub = this.subscriptions.get(localId)\n if (!sub) return\n\n let remoteId = sub.remoteId\n if (remoteId) delete this._remoteToLocal[remoteId]\n\n this.subscriptions.remove(localId)\n }\n\n transmit(id, msg, meta) {\n let localId = this._remoteToLocal[id]\n\n if (!localId) {\n this._pendingMessages.push([id, msg, meta])\n return\n }\n\n let sub = this.subscriptions.get(localId)\n\n if (!sub) return\n\n sub.channels.forEach(channel => {\n channel.receive(msg, meta)\n })\n }\n\n close() {\n this._pendingMessages.length = 0\n }\n\n get size() {\n return this.channels.length\n }\n\n get channels() {\n return this.subscriptions.all().flatMap(sub => sub.channels)\n }\n\n flush(id) {\n let left = []\n\n for (let item of this._pendingMessages) {\n if (item[0] === id) this.transmit(item[0], item[1], item[2])\n else left.push(item)\n }\n\n this._pendingMessages = left\n }\n}\n","const LEVEL_TO_NAME = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3\n}\n\nexport class BaseLogger {\n constructor(level) {\n this.level = level || 'warn'\n }\n\n log(level, msg, details) {\n if (LEVEL_TO_NAME[level] < LEVEL_TO_NAME[this.level]) return\n\n this.writeLogEntry(level, msg, details)\n }\n\n writeLogEntry() {\n throw Error('Not implemented')\n }\n\n debug(msg, details) {\n this.log('debug', msg, details)\n }\n\n info(msg, details) {\n this.log('info', msg, details)\n }\n\n warn(msg, details) {\n this.log('warn', msg, details)\n }\n\n error(msg, details) {\n this.log('error', msg, details)\n }\n}\n\nexport class NoopLogger extends BaseLogger {\n writeLogEntry() {}\n}\n","/* eslint-disable consistent-return */\n\nexport class JSONEncoder {\n encode(msg) {\n return JSON.stringify(msg)\n }\n\n decode(raw) {\n try {\n return JSON.parse(raw)\n } catch (_e) {}\n }\n}\n","import {\n SubscriptionRejectedError,\n SubscriptionTimeoutError,\n DisconnectedError\n} from '../protocol/index.js'\nimport { stringifyParams } from '../stringify-params/index.js'\nimport { NoopLogger } from '../logger/index.js'\n\nlet commandID = 0\n\nexport class ActionCableProtocol {\n constructor(opts = {}) {\n let { logger } = opts\n this.logger = logger || new NoopLogger()\n this.pendingSubscriptions = {}\n this.pendingUnsubscriptions = {}\n // For how long to wait before sending `subscribe` command\n // in case `unsubscribe` was sent for the same identifier\n this.subscribeCooldownInterval = opts.subscribeCooldownInterval || 250\n // For how long to wait for subscription acknoledgement before trying again\n // (just once).\n this.subscribeRetryInterval = opts.subscribeRetryInterval || 5000\n }\n\n attached(cable) {\n this.cable = cable\n }\n\n subscribe(channel, params) {\n let subscriptionPayload = { channel }\n if (params) {\n Object.assign(subscriptionPayload, params)\n }\n\n let identifier = stringifyParams(subscriptionPayload)\n\n if (this.pendingUnsubscriptions[identifier]) {\n let cooldown = this.subscribeCooldownInterval * 1.5\n this.logger.debug(\n `unsubscribed recently, cooldown for ${cooldown}`,\n identifier\n )\n return new Promise(resolve => {\n setTimeout(() => {\n resolve(this.subscribe(channel, params))\n }, cooldown)\n })\n }\n\n if (this.pendingSubscriptions[identifier]) {\n this.logger.warn('subscription is already pending, skipping', identifier)\n return Promise.reject(Error('Already subscribing'))\n }\n\n let retryInterval = this.subscribeRetryInterval\n\n return new Promise((resolve, reject) => {\n let id = ++commandID\n this.pendingSubscriptions[identifier] = {\n resolve,\n reject,\n id\n }\n\n this.cable.send(this.buildSubscribeRequest(identifier))\n\n this.maybeRetrySubscribe(id, identifier, retryInterval)\n })\n }\n\n buildSubscribeRequest(identifier) {\n return {\n command: 'subscribe',\n identifier\n }\n }\n\n maybeRetrySubscribe(id, identifier, retryInterval) {\n setTimeout(() => {\n let sub = this.pendingSubscriptions[identifier]\n if (!sub) return\n if (sub.id !== id) return\n\n this.logger.warn(\n `no subscription ack received in ${retryInterval}ms, retrying subscribe`,\n identifier\n )\n\n this.cable.send(this.buildSubscribeRequest(identifier))\n\n this.maybeExpireSubscribe(id, identifier, retryInterval)\n }, retryInterval)\n }\n\n maybeExpireSubscribe(id, identifier, retryInterval) {\n setTimeout(() => {\n let sub = this.pendingSubscriptions[identifier]\n if (!sub) return\n if (sub.id !== id) return\n\n delete this.pendingSubscriptions[identifier]\n\n sub.reject(\n new SubscriptionTimeoutError(\n `Haven't received subscription ack in ${\n retryInterval * 2\n }ms for ${identifier}`\n )\n )\n }, retryInterval)\n }\n\n unsubscribe(identifier) {\n this.cable.send({\n command: 'unsubscribe',\n identifier\n })\n\n this.pendingUnsubscriptions[identifier] = true\n\n setTimeout(() => {\n delete this.pendingUnsubscriptions[identifier]\n }, this.subscribeCooldownInterval)\n\n return Promise.resolve()\n }\n\n perform(identifier, action, payload) {\n if (!payload) {\n payload = {}\n }\n\n payload.action = action\n\n this.cable.send({\n command: 'message',\n identifier,\n data: JSON.stringify(payload)\n })\n\n return Promise.resolve()\n }\n\n receive(msg) {\n /* eslint-disable consistent-return */\n if (typeof msg !== 'object') {\n this.logger.error('unsupported message format', { message: msg })\n return\n }\n\n let { type, identifier, message, reason, reconnect } = msg\n\n if (type === 'ping') {\n return this.cable.keepalive(msg.message)\n } else {\n // Any incoming message may be considered as a heartbeat\n this.cable.keepalive()\n }\n\n if (type === 'welcome') {\n let sessionId = msg.sid\n\n if (sessionId) this.cable.setSessionId(sessionId)\n\n return this.cable.connected()\n }\n\n if (type === 'disconnect') {\n let err = new DisconnectedError(reason)\n this.reset(err)\n\n if (reconnect === false) {\n this.cable.closed(err)\n } else {\n this.cable.disconnected(err)\n }\n return\n }\n\n if (type === 'confirm_subscription') {\n let subscription = this.pendingSubscriptions[identifier]\n if (!subscription) {\n this.logger.error('subscription not found, unsubscribing', {\n type,\n identifier\n })\n this.unsubscribe(identifier)\n return\n }\n\n delete this.pendingSubscriptions[identifier]\n\n return subscription.resolve(identifier)\n }\n\n if (type === 'reject_subscription') {\n let subscription = this.pendingSubscriptions[identifier]\n if (!subscription) {\n return this.logger.error('subscription not found', { type, identifier })\n }\n\n delete this.pendingSubscriptions[identifier]\n\n return subscription.reject(new SubscriptionRejectedError())\n }\n\n if (message) {\n return { identifier, message }\n }\n\n this.logger.warn(`unknown message type: ${type}`, { message: msg })\n }\n\n reset(err) {\n // Reject pending subscriptions\n for (let identifier in this.pendingSubscriptions) {\n this.pendingSubscriptions[identifier].reject(err)\n }\n\n this.pendingSubscriptions = {}\n }\n\n recoverableClosure() {\n return false\n }\n}\n","import { ActionCableProtocol } from '../action_cable/index.js'\n\nconst now = () => (Date.now() / 1000) | 0\n\nexport class ActionCableExtendedProtocol extends ActionCableProtocol {\n constructor(opts = {}) {\n super(opts)\n\n this.streamsPositions = {}\n this.subscriptionStreams = {}\n this.pendingHistory = {}\n this.restoreSince = opts.historyTimestamp\n if (this.restoreSince === undefined) this.restoreSince = now()\n this.sessionId = undefined\n this.sendPongs = opts.pongs\n }\n\n receive(msg) {\n /* eslint-disable consistent-return */\n if (typeof msg !== 'object') {\n this.logger.error('unsupported message format', { message: msg })\n return\n }\n\n let { type, identifier, message } = msg\n\n // These message types do not require special handling\n if (type === 'disconnect' || type === 'reject_subscription') {\n return super.receive(msg)\n }\n\n if (type === 'confirm_subscription') {\n if (!this.subscriptionStreams[identifier]) {\n this.subscriptionStreams[identifier] = new Set()\n }\n\n return super.receive(msg)\n }\n\n if (type === 'ping') {\n if (!this.restoreSince === false) {\n this.restoreSince = now()\n }\n\n if (this.sendPongs) {\n this.sendPong()\n }\n\n return this.cable.keepalive(msg.message)\n } else {\n // Any incoming message may be considered as a heartbeat\n this.cable.keepalive()\n }\n\n if (type === 'confirm_history') {\n this.logger.debug('history result received', msg)\n return\n }\n\n if (type === 'reject_history') {\n this.logger.warn('failed to retrieve history', msg)\n return\n }\n\n if (type === 'welcome') {\n this.sessionId = msg.sid\n\n if (this.sessionId) this.cable.setSessionId(this.sessionId)\n\n if (msg.restored) {\n let restoredIds =\n msg.restored_ids || Object.keys(this.subscriptionStreams)\n for (let restoredId of restoredIds) {\n this.cable.send({\n identifier: restoredId,\n command: 'history',\n history: this.historyRequestFor(restoredId)\n })\n }\n\n return this.cable.restored(restoredIds)\n }\n\n return this.cable.connected(this.sessionId)\n }\n\n if (message) {\n let meta = this.trackStreamPosition(\n identifier,\n msg.stream_id,\n msg.epoch,\n msg.offset\n )\n return { identifier, message, meta }\n }\n\n this.logger.warn(`unknown message type: ${type}`, { message: msg })\n }\n\n buildSubscribeRequest(identifier) {\n let req = super.buildSubscribeRequest(identifier)\n\n let historyReq = this.historyRequestFor(identifier)\n\n if (historyReq) {\n req.history = historyReq\n\n this.pendingHistory[identifier] = true\n }\n\n return req\n }\n\n // TODO: Which error can be non-recoverable?\n recoverableClosure() {\n return !!this.sessionId\n }\n\n historyRequestFor(identifier) {\n let streams = {}\n let hasStreams = false\n\n if (this.subscriptionStreams[identifier]) {\n for (let stream of this.subscriptionStreams[identifier]) {\n let record = this.streamsPositions[stream]\n if (record) {\n hasStreams = true\n streams[stream] = record\n }\n }\n }\n\n if (!hasStreams && !this.restoreSince) return\n\n return { since: this.restoreSince, streams }\n }\n\n trackStreamPosition(identifier, stream, epoch, offset) {\n if (!stream || !epoch) return\n\n if (!this.subscriptionStreams[identifier]) {\n this.subscriptionStreams[identifier] = new Set()\n }\n\n this.subscriptionStreams[identifier].add(stream)\n\n this.streamsPositions[stream] = { epoch, offset }\n\n return { stream, epoch, offset }\n }\n\n // Send pongs asynchrounously—no need to block the main thread\n async sendPong() {\n await new Promise(resolve => setTimeout(resolve, 0))\n this.cable.send({ command: 'pong' })\n }\n}\n","/*eslint n/no-unsupported-features/es-syntax: [\"error\", {version: \"14.0\"}] */\nimport { createNanoEvents } from 'nanoevents'\n\nimport { Hub } from '../hub/index.js'\nimport {\n ReasonError,\n DisconnectedError,\n SubscriptionRejectedError\n} from '../protocol/index.js'\nimport { NoopLogger } from '../logger/index.js'\nimport { Channel } from '../channel/index.js'\n\nexport class NoConnectionError extends ReasonError {\n constructor() {\n super('No connection', 'closed')\n this.name = 'NoConnectionError'\n }\n}\n\nexport class GhostChannel extends Channel {\n static identifier = '__ghost__'\n constructor(channelId, params) {\n super(params)\n this.channelId = channelId\n }\n\n set channelId(val) {\n this._channelId = val\n }\n\n get channelId() {\n return this._channelId\n }\n}\n\nconst STATE = Symbol('state')\n\nexport class Cable {\n constructor({ transport, protocol, encoder, logger, lazy, hubOptions }) {\n this.emitter = createNanoEvents()\n this.transport = transport\n this.encoder = encoder\n this.logger = logger || new NoopLogger()\n this.protocol = protocol\n\n this.protocol.attached(this)\n\n this.hub = new Hub(hubOptions || {})\n\n this[STATE] = 'idle'\n\n this.handleClose = this.handleClose.bind(this)\n this.handleIncoming = this.handleIncoming.bind(this)\n\n this.transport.on('close', this.handleClose)\n this.transport.on('data', this.handleIncoming)\n\n this.initialConnect = true\n this.recovering = false\n\n if (lazy === false) {\n this.connect().catch(() => {})\n }\n }\n\n get state() {\n return this[STATE]\n }\n\n async connect() {\n if (this.state === 'connected') return Promise.resolve()\n if (this.state === 'connecting') {\n return this.pendingConnect()\n }\n\n this[STATE] = 'connecting'\n let promise = this.pendingConnect()\n\n this.logger.debug('connecting')\n\n try {\n await this.transport.open()\n } catch (err) {\n this.handleClose(err)\n }\n\n return promise\n }\n\n setSessionId(sessionId) {\n this.sessionId = sessionId\n this.transport.setParam('sid', sessionId)\n }\n\n connected() {\n if (this.state === 'connected') return\n\n this.logger.info('connected')\n\n this[STATE] = 'connected'\n\n if (this.recovering) {\n // Make sure channels moved to disconnect state\n this.hub.subscriptions\n .all()\n .forEach(subscription =>\n subscription.notify(\n 'disconnected',\n new DisconnectedError('recovery_failed')\n )\n )\n }\n\n // Re-subscribe channels\n this.hub.subscriptions\n .all()\n .forEach(subscription => this._resubscribe(subscription))\n\n let restored = false\n this.recovering = false\n\n if (this.initialConnect) {\n this.initialConnect = false\n this.emit('connect', { reconnect: false, restored })\n } else {\n this.emit('connect', { reconnect: true, restored })\n }\n }\n\n restored(remoteIds) {\n this.logger.info('connection recovered', { remoteIds })\n\n this[STATE] = 'connected'\n\n this.hub.subscriptions.all().forEach(subscription => {\n if (\n remoteIds &&\n subscription.remoteId &&\n remoteIds.includes(subscription.remoteId)\n ) {\n subscription.notify('restored')\n } else {\n subscription.notify(\n 'disconnected',\n new DisconnectedError('recovery_failed')\n )\n this._resubscribe(subscription)\n }\n })\n\n let reconnect = !this.initialConnect\n let restored = true\n\n this.recovering = false\n this.initialConnect = false\n\n this.emit('connect', { reconnect, restored })\n }\n\n handleClose(err) {\n this.logger.debug('transport closed', { error: err })\n\n this.disconnected(new DisconnectedError(err, 'transport_closed'))\n }\n\n disconnected(err) {\n if (!(this.state === 'connected' || this.state === 'connecting')) {\n return\n }\n\n this.logger.info('disconnected', { reason: err })\n\n this[STATE] = 'disconnected'\n\n this.recovering = this.protocol.recoverableClosure(err)\n\n if (this.recovering) {\n this.hub.subscriptions\n .all()\n .forEach(subscription => subscription.notify('connecting'))\n } else {\n this.hub.subscriptions.all().forEach(subscription => {\n subscription.notify('disconnected', err)\n })\n }\n\n this.protocol.reset(err)\n this.hub.close()\n this.transport.close()\n\n this.emit('disconnect', err)\n }\n\n closed(reason) {\n if (this.state === 'closed' || this.state === 'idle') return\n\n let err\n\n if (reason) {\n err =\n reason instanceof DisconnectedError\n ? reason\n : new DisconnectedError(reason, undefined)\n }\n\n this.logger.info('closed', { reason: reason || 'user' })\n\n this[STATE] = 'closed'\n\n // Channels must transition to the disconnected phase,\n // since they got reconnected as soon as cable reconnects\n let channelErr = err || new DisconnectedError('cable_closed')\n this.hub.subscriptions\n .all()\n .forEach(subscription => subscription.notify('disconnected', channelErr))\n\n this.hub.close()\n this.protocol.reset()\n this.transport.close()\n\n this.initialConnect = true\n\n this.emit('close', err)\n }\n\n disconnect() {\n this.closed()\n }\n\n handleIncoming(raw) {\n if (this.state === 'closed' || this.state === 'idle') {\n return\n }\n\n let data = this.encoder.decode(raw)\n\n if (data === undefined) {\n this.logger.error('failed to decode message', { message: raw })\n return\n }\n\n this.logger.debug('incoming data', data)\n\n let processed = this.protocol.receive(data)\n\n if (processed) {\n this.logger.debug('processed incoming message', processed)\n\n let { identifier, message, meta } = processed\n\n this.hub.transmit(identifier, message, meta)\n }\n }\n\n send(msg) {\n if (this.state === 'closed') {\n throw Error('Cable is closed')\n }\n\n let data = this.encoder.encode(msg)\n\n if (data === undefined) {\n this.logger.error('failed to encode message', { message: msg })\n return\n }\n\n this.logger.debug('outgoing message', msg)\n\n this.transport.send(data)\n }\n\n keepalive(msg) {\n this.emit('keepalive', msg)\n }\n\n subscribeTo(ChannelClass, params) {\n let channel\n let ghostName\n\n if (typeof ChannelClass === 'string') {\n ghostName = ChannelClass\n ChannelClass = GhostChannel\n }\n\n channel = ghostName\n ? new ChannelClass(ghostName, params)\n : new ChannelClass(params)\n\n return this.subscribe(channel)\n }\n\n subscribe(channel) {\n // Return if channel has been already attached to the cable\n if (!channel.attached(this)) return channel\n\n let identifier = channel.identifier\n\n channel.connecting()\n\n let subscription =\n this.hub.subscriptions.get(identifier) ||\n this.hub.subscriptions.create(identifier, {\n subscribe: sub => {\n return this._subscribe(sub, channel.channelId, channel.params)\n },\n unsubscribe: sub => this._unsubscribe(sub)\n })\n\n subscription.add(channel)\n\n if (\n subscription.intent === 'subscribed' &&\n subscription.state === 'connected'\n ) {\n channel.connected()\n }\n\n subscription.ensureSubscribed()\n\n return channel\n }\n\n async _resubscribe(subscription) {\n if (subscription.intent !== 'subscribed') return\n\n let channel = subscription.channels[0]\n\n if (!channel) return\n\n subscription.notify('connecting')\n subscription.ensureResubscribed()\n }\n\n async _subscribe(subscription, channelId, params) {\n let identifier = subscription.id\n\n if (this.state === 'idle') {\n // Trigger connection initialization if it is lazy\n this.connect().catch(() => {})\n }\n\n // We will call _subscribe again as soon as cable connected\n if (this.state !== 'connected') {\n this.logger.debug('cancel subscribe, no connection', { identifier })\n return\n }\n\n this.logger.debug('acquiring subscribe lock', { identifier })\n\n let lock = await subscription.acquire('subscribed')\n if (lock.canceled) {\n this.logger.debug('subscribe lock has been canceled', { identifier })\n lock.release()\n return\n }\n\n this.logger.debug('subscribe lock has been acquired', { identifier })\n\n if (subscription.intent !== 'subscribed') {\n this.logger.debug('cancel subscribe request, already unsubscribed')\n lock.release()\n return\n }\n\n // We need to check one more time after a lock has been acquired\n if (this.state !== 'connected') {\n this.logger.debug('cancel subscribe, no connection', { identifier })\n lock.release()\n return\n }\n\n // Finally, check whether we already connected — then we can skip the action\n if (subscription.state === 'connected') {\n this.logger.debug('already connected, skip subscribe command', {\n identifier\n })\n subscription.notify('connected')\n lock.release()\n return\n }\n\n let channelMeta = {\n identifier: channelId,\n params\n }\n\n this.logger.debug('subscribing', channelMeta)\n\n try {\n let remoteId = await this.protocol.subscribe(channelId, params)\n\n this.hub.subscribe(identifier, remoteId)\n\n this.logger.debug('subscribed', { ...channelMeta, remoteId })\n subscription.notify('connected')\n } catch (err) {\n if (err) {\n if (err instanceof SubscriptionRejectedError) {\n this.logger.warn('rejected', channelMeta)\n }\n\n if (err instanceof DisconnectedError) {\n this.logger.debug(\n 'disconnected during subscription; will retry on connect',\n channelMeta\n )\n lock.release()\n return\n }\n\n this.logger.error('failed to subscribe', {\n error: err,\n ...channelMeta\n })\n }\n\n subscription.close(err)\n this.hub.unsubscribe(identifier)\n }\n\n lock.release()\n }\n\n unsubscribe(channel) {\n let identifier = channel.identifier\n\n let subscription = this.hub.subscriptions.get(identifier)\n\n if (!subscription) {\n throw Error(`Subscription not found: ${identifier}`)\n }\n\n subscription.remove(channel)\n channel.closed()\n\n subscription.maybeUnsubscribe()\n }\n\n async _unsubscribe(subscription) {\n let identifier = subscription.id\n\n this.logger.debug('acquiring unsubscribe lock', { identifier })\n\n let lock = await subscription.acquire('unsubscribed')\n if (lock.canceled) {\n this.logger.debug('unsubscribe lock has been canceled', { identifier })\n lock.release()\n return\n }\n\n this.logger.debug('unsubscribe lock has been acquired', { identifier })\n\n // Check if we still want to unsubscribe\n if (subscription.intent !== 'unsubscribed') {\n this.logger.debug('cancel unsubscribe, no longer needed', {\n identifier,\n intent: subscription.intent\n })\n lock.release()\n return\n }\n\n // Finally, check whether we already disconnected — then we can skip the action\n if (\n subscription.state === 'disconnected' ||\n subscription.state === 'closed'\n ) {\n this.logger.debug(\n `already ${subscription.state} connected, skip unsubscribe command`,\n { identifier }\n )\n lock.release()\n return\n }\n\n let remoteId = subscription.remoteId\n\n this.logger.debug('unsubscribing...', { remoteId })\n\n if (this.state !== 'connected') {\n this.logger.debug('unsubscribe skipped (cable is not connected)', {\n id: identifier\n })\n subscription.close()\n this.hub.unsubscribe(identifier)\n lock.release()\n return\n }\n\n try {\n await this.protocol.unsubscribe(remoteId)\n this.logger.debug('unsubscribed remotely', { id: identifier })\n } catch (err) {\n if (err) {\n // We assume that server unsubscribes subscriptions on disconnect,\n // So we can mark it as closed locally.\n if (err instanceof DisconnectedError) {\n this.logger.debug(\n 'cable disconnected during the unsubscribe command execution',\n { id: identifier, error: err }\n )\n } else {\n this.logger.error('unsubscribe failed', {\n id: identifier,\n error: err\n })\n }\n }\n }\n\n if (subscription.intent === 'unsubscribed') {\n subscription.close()\n this.hub.unsubscribe(identifier)\n } else {\n // We rely on state when performing commands,\n // make sure it's set to closed here (it shouldn't stay connected)\n subscription.state = 'closed'\n }\n\n lock.release()\n }\n\n async perform(identifier, action, payload) {\n if (this.state === 'connecting') {\n await this.pendingConnect()\n }\n\n if (this.state === 'closed' || this.state === 'disconnected') {\n throw new NoConnectionError()\n }\n\n let subscription = this.hub.subscriptions.get(identifier)\n\n if (!subscription) {\n throw Error(`Subscription not found: ${identifier}`)\n }\n\n await subscription.pending('subscribed')\n\n if (subscription.intent !== 'subscribed') {\n throw Error(`Subscription is closed: ${identifier}`)\n }\n\n let remoteId = subscription.remoteId\n\n let performMeta = {\n id: remoteId,\n action,\n payload\n }\n\n this.logger.debug('perform', performMeta)\n\n try {\n let res = await this.protocol.perform(remoteId, action, payload)\n\n if (res) {\n this.logger.debug('perform result', {\n message: res,\n request: performMeta\n })\n }\n\n return res\n } catch (err) {\n this.logger.error('perform failed', {\n error: err,\n request: performMeta\n })\n\n throw err\n }\n }\n\n on(event, callback) {\n return this.emitter.on(event, callback)\n }\n\n once(event, callback) {\n let unbind = this.emitter.on(event, (...args) => {\n unbind()\n callback(...args)\n })\n return unbind\n }\n\n emit(event, ...args) {\n return this.emitter.emit(event, ...args)\n }\n\n pendingConnect() {\n if (this._pendingConnect) return this._pendingConnect\n\n this._pendingConnect = new Promise((resolve, reject) => {\n let unbind = [() => delete this._pendingConnect]\n\n unbind.push(\n this.on('connect', () => {\n unbind.forEach(clbk => clbk())\n resolve()\n })\n )\n unbind.push(\n this.on('close', err => {\n unbind.forEach(clbk => clbk())\n reject(err)\n })\n )\n unbind.push(\n this.on('disconnect', err => {\n unbind.forEach(clbk => clbk())\n reject(err)\n })\n )\n })\n\n return this._pendingConnect\n }\n}\n","/*eslint n/no-unsupported-features/es-syntax: [\"error\", {version: \"14.0\"}] */\nimport { StaleConnectionError } from '../protocol/index.js'\nimport { NoopLogger } from '../logger/index.js'\n\nconst defaults = {\n maxMissingPings: 2,\n maxReconnectAttempts: Infinity\n}\n\nconst now = () => Date.now()\n\nexport const backoffWithJitter = (interval, opts) => {\n opts = opts || {}\n let { backoffRate, jitterRatio, maxInterval } = opts\n backoffRate = backoffRate || 2\n if (jitterRatio === undefined) jitterRatio = 0.5\n\n return attempts => {\n let left = interval * backoffRate ** attempts\n let right = left * backoffRate\n\n let delay = left + (right - left) * Math.random()\n\n let deviation = 2 * (Math.random() - 0.5) * jitterRatio\n\n delay = delay * (1 + deviation)\n\n if (maxInterval && maxInterval < delay) delay = maxInterval\n\n return delay\n }\n}\n\nexport class Monitor {\n constructor({ pingInterval, ...opts }) {\n this.pingInterval = pingInterval\n\n if (!this.pingInterval) {\n throw Error(`Incorrect pingInterval is provided: ${pingInterval}`)\n }\n\n opts = Object.assign({}, defaults, opts)\n\n this.strategy = opts.reconnectStrategy\n if (!this.strategy) {\n throw Error('Reconnect strategy must be provided')\n }\n\n this.maxMissingPings = opts.maxMissingPings\n this.maxReconnectAttempts = opts.maxReconnectAttempts\n this.logger = opts.logger || new NoopLogger()\n\n this.state = 'pending_connect'\n this.attempts = 0\n this.disconnectedAt = now()\n }\n\n watch(target) {\n this.target = target\n this.initListeners()\n }\n\n reconnectNow() {\n if (\n this.state === 'connected' ||\n this.state === 'pending_connect' ||\n this.state === 'closed'\n ) {\n return false\n }\n\n this.cancelReconnect()\n\n this.state = 'pending_connect'\n this.target.connect().catch(err => {\n this.logger.info('Failed at reconnecting: ' + err)\n })\n\n return true\n }\n\n initListeners() {\n this.unbind = []\n\n this.unbind.push(\n this.target.on('connect', () => {\n this.attempts = 0\n this.pingedAt = now()\n this.state = 'connected'\n\n this.cancelReconnect()\n this.startPolling()\n })\n )\n\n this.unbind.push(\n this.target.on('disconnect', () => {\n this.disconnectedAt = now()\n this.state = 'disconnected'\n\n this.stopPolling()\n this.scheduleReconnect()\n })\n )\n\n this.unbind.push(\n this.target.on('close', () => {\n this.disconnectedAt = now()\n this.state = 'closed'\n\n this.cancelReconnect()\n this.stopPolling()\n })\n )\n\n this.unbind.push(\n this.target.on('keepalive', () => {\n this.pingedAt = now()\n })\n )\n\n this.unbind.push(() => {\n this.cancelReconnect()\n this.stopPolling()\n })\n }\n\n dispose() {\n delete this.target\n if (this.unbind) {\n this.unbind.forEach(clbk => clbk())\n }\n delete this.unbind\n }\n\n startPolling() {\n if (this.pollId) {\n clearTimeout(this.pollId)\n }\n\n let pollDelay =\n this.pingInterval + (Math.random() - 0.5) * this.pingInterval * 0.5\n\n this.pollId = setTimeout(() => {\n this.checkStale()\n if (this.state === 'connected') this.startPolling()\n }, pollDelay)\n }\n\n stopPolling() {\n if (this.pollId) {\n clearTimeout(this.pollId)\n }\n }\n\n checkStale() {\n let diff = now() - this.pingedAt\n\n if (diff > this.maxMissingPings * this.pingInterval) {\n this.logger.warn(`Stale connection: ${diff}ms without pings`)\n this.state = 'pending_disconnect'\n this.target.disconnected(new StaleConnectionError())\n }\n }\n\n scheduleReconnect() {\n if (this.attempts >= this.maxReconnectAttempts) {\n this.target.close()\n return\n }\n\n let delay = this.strategy(this.attempts)\n\n this.attempts++\n\n this.logger.info(`Reconnecting in ${delay}ms (${this.attempts} attempt)`)\n\n this.state = 'pending_reconnect'\n\n this.reconnnectId = setTimeout(() => this.reconnectNow(), delay)\n }\n\n cancelReconnect() {\n if (this.reconnnectId) {\n clearTimeout(this.reconnnectId)\n delete this.reconnnectId\n }\n }\n}\n","import { createNanoEvents } from 'nanoevents'\n\nimport { NoopLogger } from '../logger/index.js'\n\nexport class FallbackTransport {\n constructor(transports, opts = {}) {\n this.transports = transports\n this.transport = null\n this.emitter = createNanoEvents()\n this.unbind = []\n\n this.logger = opts.logger || new NoopLogger()\n }\n\n displayName() {\n return 'fallbacked transport'\n }\n\n async open() {\n for (let i = 0; i < this.transports.length; i++) {\n let transport = this.transports[i]\n try {\n this.transport = transport\n this.resetListeners()\n this.logger.debug(`Trying to connect via ${transport.displayName()}`)\n await transport.open()\n this.logger.debug(`Connected via ${transport.displayName()}`)\n return\n } catch (e) {\n this.logger.debug(\n `Failed to connect via ${transport.displayName()}: ${e.message}`\n )\n }\n }\n\n this.transport = null\n this.resetListeners()\n throw new Error(`Couldn't connect via any available transport`)\n }\n\n send(data) {\n if (!this.transport) {\n throw new Error('No transport is open')\n }\n\n this.transport.send(data)\n }\n\n async close() {\n if (!this.transport) {\n throw new Error('No transport is open')\n }\n\n await this.transport.close()\n this.transport = null\n }\n\n setURL() {\n throw new Error('Not implemented. Set URL for each transport separately')\n }\n\n setParam(key, val) {\n this.transports.forEach(transport => {\n transport.setParam(key, val)\n })\n }\n\n on(event, callback) {\n return this.emitter.on(event, callback)\n }\n\n once(event, callback) {\n let unbind = this.emitter.on(event, (...args) => {\n unbind()\n callback(...args)\n })\n return unbind\n }\n\n get url() {\n if (!this.transport) return ''\n\n return this.transport.url\n }\n\n resetListeners() {\n this.unbind.forEach(clbk => clbk())\n this.unbind.length = 0\n\n if (!this.transport) return\n\n this.unbind.push(\n this.transport.on('open', () => {\n this.emitter.emit('open')\n }),\n this.transport.on('data', data => {\n this.emitter.emit('data', data)\n }),\n this.transport.on('close', ev => {\n this.emitter.emit('close', ev)\n }),\n this.transport.on('error', ev => {\n this.emitter.emit('error', ev)\n })\n )\n }\n}\n","import { createNanoEvents } from 'nanoevents'\n\nexport class WebSocketTransport {\n constructor(url, opts = {}) {\n this.url = url\n\n let Impl = opts.websocketImplementation\n\n if (Impl) {\n this.Impl = Impl\n } else if (typeof WebSocket !== 'undefined') {\n this.Impl = WebSocket\n } else {\n throw new Error('No WebSocket support')\n }\n\n this.connected = false\n this.emitter = createNanoEvents()\n\n let { format, subprotocol } = opts\n\n this.format = format || 'text'\n this.connectionOptions = opts.websocketOptions\n this.subprotocol = subprotocol\n }\n\n displayName() {\n return 'WebSocket(' + this.url + ')'\n }\n\n open() {\n if (this.connectionOptions) {\n this.ws = new this.Impl(\n this.url,\n this.subprotocol,\n this.connectionOptions\n )\n } else {\n this.ws = new this.Impl(this.url, this.subprotocol)\n }\n this.ws.binaryType = 'arraybuffer'\n this.initListeners()\n\n return new Promise((resolve, reject) => {\n let unbind = []\n\n unbind.push(\n this.once('open', () => {\n unbind.forEach(clbk => clbk())\n resolve()\n })\n )\n\n unbind.push(\n this.once('close', () => {\n unbind.forEach(clbk => clbk())\n reject(Error('WS connection closed'))\n })\n )\n })\n }\n\n setURL(url) {\n this.url = url\n }\n\n setParam(key, val) {\n let url = new URL(this.url)\n url.searchParams.set(key, val)\n let newURL = `${url.protocol}//${url.host}${url.pathname}?${url.searchParams}`\n this.setURL(newURL)\n }\n\n send(data) {\n if (!this.ws || !this.connected) {\n throw Error('WebSocket is not connected')\n } else {\n this.ws.send(data)\n }\n }\n\n close() {\n if (this.ws && this.connected) {\n this.onclose()\n }\n }\n\n on(event, callback) {\n return this.emitter.on(event, callback)\n }\n\n once(event, callback) {\n let unbind = this.emitter.on(event, (...args) => {\n unbind()\n callback(...args)\n })\n return unbind\n }\n\n initListeners() {\n this.ws.onerror = event => {\n // Only emit errors if the socket hasn't been closed\n if (this.connected) {\n this.emitter.emit('error', event.error || new Error('WS Error'))\n }\n }\n\n this.ws.onclose = () => {\n this.onclose()\n }\n\n this.ws.onmessage = event => {\n let data = event.data\n if (this.format === 'binary') {\n data = new Uint8Array(data)\n }\n\n this.emitter.emit('data', data)\n }\n\n this.ws.onopen = () => {\n this.connected = true\n this.emitter.emit('open')\n }\n }\n\n onclose() {\n this.ws.onclose = undefined\n this.ws.onmessage = undefined\n this.ws.onopen = undefined\n this.ws.close()\n delete this.ws\n this.connected = false\n\n this.emitter.emit('close')\n }\n}\n","import { Cable, GhostChannel } from '../cable/index.js'\nimport { ActionCableProtocol } from '../action_cable/index.js'\nimport { ActionCableExtendedProtocol } from '../action_cable_ext/index.js'\nimport { JSONEncoder } from '../encoder/index.js'\nimport { NoopLogger } from '../logger/index.js'\nimport { WebSocketTransport } from '../websocket/index.js'\nimport { Monitor, backoffWithJitter } from '../monitor/index.js'\nimport { SubscriptionRejectedError } from '../protocol/index.js'\nimport { FallbackTransport } from '../transport/index.js'\n\nexport const DEFAULT_OPTIONS = {\n protocol: 'actioncable-v1-json',\n pingInterval: 3000,\n maxReconnectAttempts: Infinity,\n maxMissingPings: 2,\n logLevel: 'warn',\n lazy: true\n}\n\nexport function createCable(url, opts) {\n if (typeof url === 'object' && typeof opts === 'undefined') {\n opts = url\n url = undefined\n }\n\n opts = opts || {}\n\n if (!url && !opts.transport) throw Error('URL or transport must be specified')\n\n opts = Object.assign({}, DEFAULT_OPTIONS, opts)\n\n let {\n protocol,\n websocketImplementation,\n websocketFormat,\n websocketOptions,\n fallbacks,\n logLevel,\n logger,\n transport,\n encoder,\n lazy,\n monitor,\n pingInterval,\n reconnectStrategy,\n maxMissingPings,\n maxReconnectAttempts,\n subprotocol,\n tokenRefresher,\n historyTimestamp,\n protocolOptions,\n concurrentSubscribes\n } = opts\n\n logger = logger || new NoopLogger(logLevel)\n\n if (typeof protocol === 'string') {\n subprotocol = subprotocol || protocol\n\n // split protocol into two parts by last '-' symbol\n // e.g. actioncable-v1-json -> actioncable-v1, json\n let protocolName = protocol.substring(0, protocol.lastIndexOf('-'))\n let protocolEncoderName = protocol.substring(protocol.lastIndexOf('-') + 1)\n\n protocolOptions = protocolOptions || {}\n\n if (protocolName === 'actioncable-v1') {\n protocol = new ActionCableProtocol({ logger, ...protocolOptions })\n } else if (protocolName === 'actioncable-v1-ext') {\n protocol = new ActionCableExtendedProtocol({\n logger,\n historyTimestamp,\n ...protocolOptions\n })\n } else {\n throw Error(`Protocol is not supported yet: ${protocol}`)\n }\n\n if (protocolEncoderName === 'json') {\n encoder = encoder || new JSONEncoder()\n websocketFormat = websocketFormat || 'text'\n } else if (protocolEncoderName === 'msgpack') {\n websocketFormat = 'binary'\n if (!encoder) {\n throw Error(\n 'Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own'\n )\n }\n } else if (protocolEncoderName === 'protobuf') {\n websocketFormat = websocketFormat || 'binary'\n if (!encoder) {\n throw Error(\n 'Protobuf encoder must be specified explicitly. Use `@anycable/protobuf-encoder` package or build your own'\n )\n }\n } else {\n throw Error(`Protocol is not supported yet: ${protocol}`)\n }\n }\n\n if (!protocol) throw Error('Protocol must be specified')\n\n transport =\n transport ||\n new WebSocketTransport(url, {\n websocketImplementation,\n websocketOptions,\n subprotocol,\n format: websocketFormat\n })\n\n if (fallbacks) {\n transport = new FallbackTransport([transport, ...fallbacks], { logger })\n }\n\n reconnectStrategy = reconnectStrategy || backoffWithJitter(pingInterval)\n\n if (monitor !== false) {\n monitor =\n monitor ||\n new Monitor({\n pingInterval,\n reconnectStrategy,\n maxMissingPings,\n maxReconnectAttempts,\n logger\n })\n }\n\n let hubOptions = { concurrentSubscribes }\n\n let cable = new Cable({\n protocol,\n transport,\n encoder,\n logger,\n lazy,\n hubOptions\n })\n\n if (monitor) {\n monitor.watch(cable)\n cable.monitor = monitor\n }\n\n if (tokenRefresher) {\n watchForExpiredToken(cable, async () => {\n try {\n await tokenRefresher(transport)\n } catch (err) {\n logger.error('Failed to refresh authentication token: ' + err)\n return false\n }\n\n // Initiate cable connection.\n // No need to wait for it to complete, it could\n // fail due to network errors (which is not our responsibility)\n cable.connect().catch(() => {})\n\n return true\n })\n }\n\n return cable\n}\n\nfunction watchForExpiredToken(cable, callback) {\n let attempted = false\n\n cable.on('connect', () => (attempted = false))\n\n cable.on('close', async ev => {\n if (!ev) return\n\n // If we closed by server two times in a row\n if (attempted) {\n cable.logger.warn('Token auto-refresh is disabled', ev)\n return\n }\n\n if (ev.reason === 'token_expired') {\n attempted = true\n\n await callback()\n }\n })\n}\n\n// Wrapper over ActionCableChannel that acts like an Action Cable subscription object\nclass ActionCableSubscription {\n constructor(channel) {\n this.channel = channel\n }\n\n notify(callback, ...args) {\n if (typeof this[callback] !== 'function') return\n\n this[callback](...args)\n }\n\n perform(action, data = {}) {\n this.channel.perform(action, data)\n }\n\n send(data) {\n this.channel.send(data)\n }\n\n get identifier() {\n return this.channel.identifier\n }\n\n unsubscribe() {\n return this.channel.disconnect()\n }\n}\n\nclass ActionCableChannel extends GhostChannel {\n constructor(channelName, params, mixin) {\n super(channelName, params)\n\n this.subscription = new ActionCableSubscription(this)\n Object.assign(this.subscription, mixin)\n\n this.on('connect', () => this.subscription.notify('connected'))\n this.on('disconnect', () =>\n this.subscription.notify('disconnected', { allowReconnect: true })\n )\n this.on('message', val => this.subscription.notify('received', val))\n this.on('close', err => {\n if (err && err instanceof SubscriptionRejectedError) {\n this.subscription.notify('rejected')\n } else {\n this.subscription.notify('disconnected', { allowReconnect: false })\n }\n })\n }\n}\n\nexport class ActionCableSubscriptions {\n constructor(cable) {\n this.cable = cable\n }\n\n create(channel, mixin) {\n let channelName\n let params\n\n if (typeof channel === 'object') {\n channelName = channel.channel\n delete channel.channel\n params = channel\n } else {\n channelName = channel\n params = {}\n }\n\n let cableChannel = new ActionCableChannel(channelName, params, mixin)\n cableChannel.subscription.notify('initialized')\n\n this.cable.subscribe(cableChannel)\n\n return cableChannel.subscription\n }\n\n findAll(identifier) {\n return this.cable.hub.channels\n .filter(channel => channel.identifier === identifier)\n .map(channel => channel.subscription)\n }\n}\n\nexport class ActionCableConsumer {\n constructor(cable) {\n this.cable = cable\n this.subscriptions = new ActionCableSubscriptions(cable)\n }\n}\n\nexport function createConsumer(url, opts) {\n let cable = createCable(url, opts)\n\n return new ActionCableConsumer(cable)\n}\n","import { BaseLogger } from '@anycable/core'\n\n/* eslint-disable no-console */\nexport class Logger extends BaseLogger {\n writeLogEntry(level, msg, details) {\n if (details) {\n console[level](msg, details)\n } else {\n console[level](msg)\n }\n }\n}\n","import { Monitor as BaseMonitor, DisconnectedError } from '@anycable/core'\n\nexport class Monitor extends BaseMonitor {\n watch(cable) {\n super.watch(cable)\n\n this.initActivityListeners()\n }\n\n initActivityListeners() {\n if (\n typeof document !== 'undefined' &&\n typeof window !== 'undefined' &&\n document.addEventListener &&\n window.addEventListener\n ) {\n let visibility = () => {\n if (!document.hidden) {\n if (this.reconnectNow()) {\n this.logger.debug('Trigger reconnect due to visibility change')\n }\n }\n }\n let connect = event => {\n if (this.reconnectNow()) {\n this.logger.debug('Trigger reconnect', { event })\n }\n }\n let disconnectFrozen = () =>\n this.disconnect(new DisconnectedError('page_frozen'))\n\n document.addEventListener('visibilitychange', visibility, false)\n window.addEventListener('focus', connect, false)\n window.addEventListener('online', connect, false)\n window.addEventListener('resume', connect, false)\n window.addEventListener('freeze', disconnectFrozen, false)\n\n this.unbind.push(() => {\n document.removeEventListener('visibilitychange', visibility, false)\n window.removeEventListener('focus', connect, false)\n window.removeEventListener('online', connect, false)\n window.removeEventListener('resume', connect, false)\n window.removeEventListener('freeze', disconnectFrozen, false)\n })\n }\n }\n\n disconnect(err) {\n if (this.state === 'disconnected' || this.state === 'closed') return\n\n this.logger.info('Disconnecting', { reason: err.message })\n\n this.cancelReconnect()\n this.stopPolling()\n\n this.state = 'pending_disconnect'\n this.target.disconnected(err)\n }\n}\n","import {\n createCable as coreCreateCable,\n backoffWithJitter,\n DEFAULT_OPTIONS as DEFAULTS,\n ActionCableConsumer\n} from '@anycable/core'\n\nimport { Logger } from './logger/index.js'\nimport { Monitor } from './monitor/index.js'\n\nexport { Channel } from '@anycable/core'\n\nconst metaPrefixes = ['cable', 'action-cable']\n\nconst defaultUrl = '/cable'\n\n/* eslint-disable consistent-return */\nconst fetchMeta = (doc, key) => {\n for (let prefix of metaPrefixes) {\n let element = doc.head.querySelector(`meta[name='${prefix}-${key}']`)\n\n if (element) {\n return element.getAttribute('content')\n }\n }\n}\n\nconst absoluteWSUrl = path => {\n if (path.match(/wss?:\\/\\//)) return path\n\n if (typeof window !== 'undefined') {\n let proto = window.location.protocol.replace('http', 'ws')\n\n return `${proto}//${window.location.host}${path}`\n }\n\n return path\n}\n\n/* eslint-disable consistent-return */\nconst generateUrlFromDOM = () => {\n if (typeof document !== 'undefined' && document.head) {\n let url = fetchMeta(document, 'url')\n if (url) {\n return absoluteWSUrl(url)\n }\n }\n\n return absoluteWSUrl(defaultUrl)\n}\n\nconst historyTimestampFromMeta = () => {\n if (typeof document !== 'undefined' && document.head) {\n let value = fetchMeta(document, 'history-timestamp')\n\n if (value) {\n return value | 0\n }\n }\n}\n\nexport function createCable(url, opts) {\n if (typeof url === 'object' && typeof opts === 'undefined') {\n opts = url\n url = undefined\n }\n\n url = url || generateUrlFromDOM()\n opts = opts || {}\n\n opts.historyTimestamp ||= historyTimestampFromMeta()\n\n opts = Object.assign({}, DEFAULTS, opts)\n\n let {\n logLevel,\n logger,\n pingInterval,\n reconnectStrategy,\n maxMissingPings,\n maxReconnectAttempts\n } = opts\n\n logger = opts.logger = opts.logger || new Logger(logLevel)\n reconnectStrategy = opts.reconnectStrategy =\n opts.reconnectStrategy || backoffWithJitter(pingInterval)\n\n if (opts.monitor !== false) {\n opts.monitor =\n opts.monitor ||\n new Monitor({\n pingInterval,\n reconnectStrategy,\n maxMissingPings,\n maxReconnectAttempts,\n logger\n })\n }\n\n return coreCreateCable(url, opts)\n}\n\nexport function createConsumer(url, opts) {\n let cable = createCable(url, opts)\n\n return new ActionCableConsumer(cable)\n}\n\nexport function fetchTokenFromHTML(opts) {\n let url = opts ? opts.url : undefined\n\n if (!url) {\n if (typeof window !== 'undefined') {\n url = window.location.href\n } else {\n throw Error('An URL to fetch the HTML with a token MUST be specified')\n }\n }\n\n return async transport => {\n let response = await fetch(url, {\n credentials: 'same-origin',\n cache: 'no-cache',\n headers: {\n 'Accept': 'text/html, application/xhtml+xml',\n 'X-ANYCABLE-OPERATION': 'token-refresh'\n }\n })\n\n if (!response.ok) {\n throw Error(\n 'Failed to fetch a page to refresh a token: ' + response.status\n )\n }\n\n let html = await response.text()\n\n let doc = new DOMParser().parseFromString(html, 'text/html')\n\n let newURL = fetchMeta(doc, 'url')\n\n if (newURL) {\n transport.setURL(newURL)\n } else {\n throw Error(\"Couldn't find a token on the page\")\n }\n }\n}\n","// To see this message, add the following to the `` section in your\n// views/layouts/application.html.erb\n//\n// <%= vite_client_tag %>\n// <%= vite_javascript_tag 'application' %>\nconsole.log('无忧住 ⚡️ 无忧住管理端')\n\n// If using a TypeScript entrypoint file:\n// <%= vite_typescript_tag 'application' %>\n//\n// If you want to use .jsx or .tsx, add the extension:\n// <%= vite_javascript_tag 'application.jsx' %>\n\n// Example: Load Rails libraries in Vite.\n//\n// import * as Turbo from '@hotwired/turbo'\n// Turbo.start()\n//\n// import ActiveStorage from '@rails/activestorage'\n// ActiveStorage.start()\n//\n// // Import all channels.\n// const channels = import.meta.globEager('./**/*_channel.js')\n\n// Example: Import a stylesheet in app/frontend/index.css\n// import '~/index.css'\nimport { createCable } from \"@anycable/web\";\n\nlet cable;\n\nconst _createCable = () => {\n if (!cable) {\n cable = createCable();\n }\n\n return cable;\n};\n\nconst createChannel = (channelOpts, args) => {\n const { channel, ...opts } = channelOpts;\n const cb = _createCable();\n const _channel = cb.subscribeTo(channel, opts)\n if (args.open) {\n _channel.on('open', args.open)\n }\n if (args.received) {\n _channel.on('message', args.received)\n }\n return _channel;\n};\n\n\n(function () {\n window.App || (window.App = {});\n var _ws_url;\n if (window.gon) {\n _ws_url = window.gon.ws_url || \"/cable\";\n } else {\n _ws_url = \"/cable\";\n }\n window.App = {\n createChannel: createChannel,\n }\n}).call(this);"],"names":["createNanoEvents","event","args","callbacks","i","length","cb","_a","ReasonError","msg","reason","SubscriptionRejectedError","SubscriptionTimeoutError","DisconnectedError","error","StaleConnectionError","stringifyParams","params","k","v","STATE","Channel","receiver","restored","reconnect","err","action","payload","meta","callback","unbind","resolve","reject","clbk","Subscription","id","channel","ind","state","intent","nextPending","resolver","lock","top","GlobalLock","Subscriptions","opts","subscribe","unsubscribe","sub","localId","remoteId","Hub","left","item","LEVEL_TO_NAME","BaseLogger","level","details","NoopLogger","JSONEncoder","raw","commandID","ActionCableProtocol","logger","cable","subscriptionPayload","identifier","cooldown","retryInterval","type","message","sessionId","subscription","now","ActionCableExtendedProtocol","restoredIds","restoredId","req","historyReq","streams","hasStreams","stream","record","epoch","offset","NoConnectionError","GhostChannel","channelId","val","__publicField","Cable","transport","protocol","encoder","lazy","hubOptions","promise","remoteIds","channelErr","data","processed","ChannelClass","ghostName","channelMeta","performMeta","res","defaults","backoffWithJitter","interval","backoffRate","jitterRatio","maxInterval","attempts","right","delay","deviation","Monitor$1","pingInterval","target","pollDelay","diff","FallbackTransport","transports","e","key","ev","WebSocketTransport","url","Impl","format","subprotocol","newURL","DEFAULT_OPTIONS","createCable","websocketImplementation","websocketFormat","websocketOptions","fallbacks","logLevel","monitor","reconnectStrategy","maxMissingPings","maxReconnectAttempts","tokenRefresher","historyTimestamp","protocolOptions","concurrentSubscribes","protocolName","protocolEncoderName","Monitor","watchForExpiredToken","attempted","Logger","BaseMonitor","visibility","connect","disconnectFrozen","metaPrefixes","defaultUrl","fetchMeta","doc","prefix","element","absoluteWSUrl","path","generateUrlFromDOM","historyTimestampFromMeta","value","DEFAULTS","coreCreateCable","_createCable","createChannel","channelOpts","_channel","this"],"mappings":"wKAAO,IAAIA,EAAmB,KAAO,CACnC,OAAQ,CAAE,EACV,KAAKC,KAAUC,EAAM,CACnB,IAAIC,EAAY,KAAK,OAAOF,CAAK,GAAK,CAAE,EACxC,QAASG,EAAI,EAAGC,EAASF,EAAU,OAAQC,EAAIC,EAAQD,IACrDD,EAAUC,CAAC,EAAE,GAAGF,CAAI,CAEvB,EACD,GAAGD,EAAOK,EAAI,CART,IAAAC,EASH,OAAAA,EAAA,KAAK,OAAON,CAAK,IAAjB,MAAAM,EAAoB,KAAKD,KAAQ,KAAK,OAAOL,CAAK,EAAI,CAACK,CAAE,GAClD,IAAM,CAVV,IAAAC,EAWD,KAAK,OAAON,CAAK,GAAIM,EAAA,KAAK,OAAON,CAAK,IAAjB,YAAAM,EA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