@quiltt/core 3.3.1 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/api/graphql/index.cjs +1 -1
- package/dist/api/graphql/index.cjs.map +1 -1
- package/dist/api/graphql/index.js +1 -1
- package/dist/api/graphql/index.js.map +1 -1
- package/dist/api/graphql/links/actioncable/index.cjs.map +1 -1
- package/dist/api/graphql/links/actioncable/index.js.map +1 -1
- package/dist/api/graphql/links/index.cjs +1 -1
- package/dist/api/graphql/links/index.cjs.map +1 -1
- package/dist/api/graphql/links/index.js +1 -1
- package/dist/api/graphql/links/index.js.map +1 -1
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/rest/index.cjs.map +1 -1
- package/dist/api/rest/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/api/graphql/links/actioncable/adapters.ts","../../../../../package.json","../../../../../src/configuration.ts","../../../../../src/api/graphql/links/actioncable/logger.ts","../../../../../src/api/graphql/links/actioncable/connection_monitor.ts","../../../../../src/api/graphql/links/actioncable/internal.ts","../../../../../src/api/graphql/links/actioncable/connection.ts","../../../../../src/api/graphql/links/actioncable/subscription.ts","../../../../../src/api/graphql/links/actioncable/subscription_guarantor.ts","../../../../../src/api/graphql/links/actioncable/subscriptions.ts","../../../../../src/api/graphql/links/actioncable/consumer.ts","../../../../../src/api/graphql/links/actioncable/index.ts"],"names":["adapters_default","name","version","QUILTT_API_INSECURE","e","QUILTT_API_DOMAIN","QUILTT_DEBUG","domain","protocolHttp","protocolWebsockets","debugging","endpointAuth","endpointGraphQL","endpointWebsockets","Logger","__publicField","messages","logger","logger_default","now","secondsSince","time","ConnectionMonitor","connection","staleThreshold","reconnectionBackoffRate","backoff","jitter","connection_monitor_default","INTERNAL","internal_default","message_types","protocols","supportedProtocols","indexOf","Connection","consumer","data","socketProtocols","allowReconnect","error","states","state","eventName","handler","event","identifier","message","reason","reconnect","type","_event","connection_default","extend","object","properties","key","value","Subscription","params","mixin","action","subscription_default","SubscriptionGuarantor","subscriptions","subscription","s","subscription_guarantor_default","Subscriptions","channelName","channel","callbackName","args","command","subscriptions_default","Consumer","url","createWebSocketURL","subprotocol","a","consumer_default","createConsumer","getConfig","element"],"mappings":"qLAAA,IAAOA,EAAQ,CACb,OAAQ,OAAO,YAAe,YAAc,WAAW,QAAU,OACjE,UAAW,OAAO,YAAe,YAAc,WAAW,UAAY,MACxE,ECFE,IAAAC,EAAQ,eACRC,EAAW,QCAb,IAAMC,GAAuB,IAAM,CACjC,GAAI,CACF,OAAO,QAAQ,IAAI,mBACrB,OAAQC,EAAN,CACA,MACF,CACF,GAAG,EAEGC,GAAqB,IAAM,CAC/B,GAAI,CACF,OAAO,QAAQ,IAAI,iBACrB,OAAQD,EAAN,CACA,MACF,CACF,GAAG,EAEGE,GAAgB,IAAM,CAC1B,GAAI,CACF,MAAO,CAAC,CAAC,QAAQ,IAAI,cAAgB,QAAQ,IAAI,WAAa,YAChE,OAAQF,EAAN,CACA,MAAO,EACT,CACF,GAAG,EAEGG,EAASF,GAAqB,YAC9BG,EAAe,OAAOL,EAAsB,GAAK,MACjDM,EAAqB,KAAKJ,EAAoB,GAAK,MAE5CK,EAAYJ,EACZK,EAAe,GAAGH,YAAuBD,qBACzCK,EAAkB,GAAGJ,WAAsBD,eAC3CM,EAAqB,GAAGJ,WAA4BF,eACpDL,EAAU,GAAGD,OAAiBC,IC/B3C,IAAMY,EAAN,KAAa,CAAb,cACEC,EAAA,eAAUL,GAEV,OAAOM,EAAyB,CAC1BhB,EAAS,QAAU,KAAK,UAC1BgB,EAAS,KAAK,KAAK,IAAI,EAAE,SAAS,C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AsC,CAKvE,GAJI,OAAOA,GAAQ,aACjBA,EAAMA,EAAI,GAGRA,GAAO,CAAC,UAAU,KAAKA,CAAG,EAAG,CAC/B,IAAMG,EAAI,SAAS,cAAc,GAAG,EACpC,OAAAA,EAAE,KAAOH,EAETG,EAAE,KAAOA,EAAE,KACXA,EAAE,SAAWA,EAAE,SAAS,QAAQ,OAAQ,IAAI,EACrCA,EAAE,SAET,QAAOH,CAEX,CAEA,IAAOI,EAAQL,EC7DR,SAASM,GAAeL,EAAMM,EAAU,KAAK,GAAKpD,EAAS,mBAAoB,CACpF,OAAO,IAAIkD,EAASJ,CAAG,CACzB,CAEO,SAASM,EAAUjF,EAAc,CACtC,IAAMkF,EAAU,SAAS,KAAK,cAAc,2BAA2BlF,KAAQ,EAC/E,GAAIkF,EACF,OAAOA,EAAQ,aAAa,SAAS,CAEzC","sourcesContent":["export default {\n logger: typeof globalThis !== 'undefined' ? globalThis.console : undefined,\n WebSocket: typeof globalThis !== 'undefined' ? globalThis.WebSocket : undefined,\n}\n","{\n \"name\": \"@quiltt/core\",\n \"version\": \"3.3.1\",\n \"description\": \"Javascript API client and utilities for Quiltt\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/quiltt/quiltt-public.git\",\n \"directory\": \"ECMAScript/core\"\n },\n \"homepage\": \"https://github.com/quiltt/quiltt-public/tree/main/ECMAScript/core#readme\",\n \"keywords\": [\n \"quiltt\",\n \"typescript\"\n ],\n \"license\": \"MIT\",\n \"sideEffects\": [\n \"./src/Storage/Local.ts\",\n \"./src/api/graphql/links/SubscriptionLink.ts\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist/**\",\n \"src/**\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf .turbo dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"TIMING=1 eslint --ext .js,.jsx,.ts,.tsx src/ --fix\",\n \"typecheck\": \"tsc --project tsconfig.json --noEmit\"\n },\n \"dependencies\": {\n \"@apollo/client\": \"^3.7.16\",\n \"axios\": \"^1.4.0\",\n \"cross-fetch\": \"^3.1.8\",\n \"graphql\": \"^16.8.1\",\n \"graphql-ruby-client\": \"^1.11.8\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"4.1.1\",\n \"@types/node\": \"18.16.18\",\n \"@types/react\": \"18.2.7\",\n \"@typescript-eslint/eslint-plugin\": \"5.60.1\",\n \"@typescript-eslint/parser\": \"5.60.1\",\n \"eslint\": \"8.43.0\",\n \"eslint-config-prettier\": \"8.8.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"prettier\": \"2.8.8\",\n \"tsup\": \"6.7.0\",\n \"typescript\": \"5.1.3\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import { name as packageName, version as packageVersion } from '../package.json'\n\nconst QUILTT_API_INSECURE = (() => {\n try {\n return process.env.QUILTT_API_INSECURE\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_API_DOMAIN = (() => {\n try {\n return process.env.QUILTT_API_DOMAIN\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_DEBUG = (() => {\n try {\n return !!process.env.QUILTT_DEBUG || process.env.NODE_ENV !== 'production'\n } catch {\n return false\n }\n})()\n\nconst domain = QUILTT_API_DOMAIN || 'quiltt.io'\nconst protocolHttp = `http${QUILTT_API_INSECURE ? '' : 's'}`\nconst protocolWebsockets = `ws${QUILTT_API_DOMAIN ? '' : 's'}`\n\nexport const debugging = QUILTT_DEBUG\nexport const endpointAuth = `${protocolHttp}://auth.${domain}/v1/users/session`\nexport const endpointGraphQL = `${protocolHttp}://api.${domain}/v1/graphql`\nexport const endpointWebsockets = `${protocolWebsockets}://api.${domain}/websockets`\nexport const version = `${packageName}: v${packageVersion}`\n\nconst Config = {\n debugging,\n endpointAuth,\n endpointGraphQL,\n endpointWebsockets,\n version,\n}\n\nexport default Config\n","import { debugging } from '../../../../configuration'\nimport adapters from './adapters'\n\nclass Logger {\n enabled = debugging\n\n log(...messages: Array<string>) {\n if (adapters.logger && this.enabled) {\n messages.push(Date.now().toString())\n adapters.logger.log('[ActionCable]', ...messages)\n }\n }\n}\n\nexport const logger = new Logger()\nexport default logger\n","// @ts-nocheck\nimport logger from './logger'\n\n// Responsible for ensuring the cable connection is in good health by validating the heartbeat pings sent from the server, and attempting\n// revival reconnections if things go astray. Internal class, not intended for direct user manipulation.\n\nconst now = () => new Date().getTime()\n\nconst secondsSince = (time) => (now() - time) / 1000\n\nclass ConnectionMonitor {\n constructor(connection) {\n this.visibilityDidChange = this.visibilityDidChange.bind(this)\n this.connection = connection\n this.reconnectAttempts = 0\n }\n\n start() {\n if (!this.isRunning()) {\n this.startedAt = now()\n delete this.stoppedAt\n this.startPolling()\n addEventListener('visibilitychange', this.visibilityDidChange)\n logger.log(\n `ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`\n )\n }\n }\n\n stop() {\n if (this.isRunning()) {\n this.stoppedAt = now()\n this.stopPolling()\n removeEventListener('visibilitychange', this.visibilityDidChange)\n logger.log('ConnectionMonitor stopped')\n }\n }\n\n isRunning() {\n return this.startedAt && !this.stoppedAt\n }\n\n recordPing() {\n this.pingedAt = now()\n }\n\n recordConnect() {\n this.reconnectAttempts = 0\n this.recordPing()\n delete this.disconnectedAt\n logger.log('ConnectionMonitor recorded connect')\n }\n\n recordDisconnect() {\n this.disconnectedAt = now()\n logger.log('ConnectionMonitor recorded disconnect')\n }\n\n // Private\n\n startPolling() {\n this.stopPolling()\n this.poll()\n }\n\n stopPolling() {\n clearTimeout(this.pollTimeout)\n }\n\n poll() {\n this.pollTimeout = setTimeout(() => {\n this.reconnectIfStale()\n this.poll()\n }, this.getPollInterval())\n }\n\n getPollInterval() {\n const { staleThreshold, reconnectionBackoffRate } = this.constructor\n const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10))\n const jitterMax = this.reconnectAttempts === 0 ? 1.0 : reconnectionBackoffRate\n const jitter = jitterMax * Math.random()\n return staleThreshold * 1000 * backoff * (1 + jitter)\n }\n\n reconnectIfStale() {\n if (this.connectionIsStale()) {\n logger.log(\n `ConnectionMonitor detected stale connection. reconnectAttempts = ${\n this.reconnectAttempts\n }, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${\n this.constructor.staleThreshold\n } s`\n )\n this.reconnectAttempts++\n if (this.disconnectedRecently()) {\n logger.log(\n `ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(\n this.disconnectedAt\n )} s`\n )\n } else {\n logger.log('ConnectionMonitor reopening')\n this.connection.reopen()\n }\n }\n }\n\n get refreshedAt() {\n return this.pingedAt ? this.pingedAt : this.startedAt\n }\n\n connectionIsStale() {\n return secondsSince(this.refreshedAt) > this.constructor.staleThreshold\n }\n\n disconnectedRecently() {\n return (\n this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold\n )\n }\n\n visibilityDidChange() {\n if (document.visibilityState === 'visible') {\n setTimeout(() => {\n if (this.connectionIsStale() || !this.connection.isOpen()) {\n logger.log(\n `ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`\n )\n this.connection.reopen()\n }\n }, 200)\n }\n }\n}\n\nConnectionMonitor.staleThreshold = 6 // Server::Connections::BEAT_INTERVAL * 2 (missed two pings)\nConnectionMonitor.reconnectionBackoffRate = 0.15\n\nexport default ConnectionMonitor\n","const INTERNAL = {\n message_types: {\n welcome: 'welcome',\n disconnect: 'disconnect',\n ping: 'ping',\n confirmation: 'confirm_subscription',\n rejection: 'reject_subscription',\n },\n disconnect_reasons: {\n unauthorized: 'unauthorized',\n invalid_request: 'invalid_request',\n server_restart: 'server_restart',\n remote: 'remote',\n },\n default_mount_path: '/cable',\n protocols: ['actioncable-v1-json', 'actioncable-unsupported'],\n}\n\nexport default INTERNAL\n","// @ts-nocheck\nimport adapters from './adapters'\nimport ConnectionMonitor from './connection_monitor'\nimport INTERNAL from './internal'\nimport logger from './logger'\n\n// Encapsulate the cable connection held by the consumer. This is an internal class not intended for direct user manipulation.\n\nconst { message_types, protocols } = INTERNAL\nconst supportedProtocols = protocols.slice(0, protocols.length - 1)\n\nconst indexOf = [].indexOf\n\nclass Connection {\n constructor(consumer) {\n this.open = this.open.bind(this)\n this.consumer = consumer\n this.subscriptions = this.consumer.subscriptions\n this.monitor = new ConnectionMonitor(this)\n this.disconnected = true\n }\n\n send(data) {\n if (this.isOpen()) {\n this.webSocket.send(JSON.stringify(data))\n return true\n } else {\n return false\n }\n }\n\n open() {\n if (this.isActive()) {\n logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`)\n return false\n } else {\n const socketProtocols = [...protocols, ...(this.consumer.subprotocols || [])]\n logger.log(\n `Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`\n )\n if (this.webSocket) {\n this.uninstallEventHandlers()\n }\n this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols)\n this.installEventHandlers()\n this.monitor.start()\n return true\n }\n }\n\n close({ allowReconnect } = { allowReconnect: true }) {\n if (!allowReconnect) {\n this.monitor.stop()\n }\n // Avoid closing websockets in a \"connecting\" state due to Safari 15.1+ bug. See: https://github.com/rails/rails/issues/43835#issuecomment-1002288478\n if (this.isOpen()) {\n return this.webSocket.close()\n }\n }\n\n reopen() {\n logger.log(`Reopening WebSocket, current state is ${this.getState()}`)\n if (this.isActive()) {\n try {\n return this.close()\n } catch (error) {\n logger.log('Failed to reopen WebSocket', error)\n } finally {\n logger.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`)\n setTimeout(this.open, this.constructor.reopenDelay)\n }\n } else {\n return this.open()\n }\n }\n\n getProtocol() {\n if (this.webSocket) {\n return this.webSocket.protocol\n }\n }\n\n isOpen() {\n return this.isState('open')\n }\n\n isActive() {\n return this.isState('open', 'connecting')\n }\n\n triedToReconnect() {\n return this.monitor.reconnectAttempts > 0\n }\n\n // Private\n\n isProtocolSupported() {\n return indexOf.call(supportedProtocols, this.getProtocol()) >= 0\n }\n\n isState(...states) {\n return indexOf.call(states, this.getState()) >= 0\n }\n\n getState() {\n if (this.webSocket) {\n for (const state in adapters.WebSocket) {\n if (adapters.WebSocket[state] === this.webSocket.readyState) {\n return state.toLowerCase()\n }\n }\n }\n return null\n }\n\n installEventHandlers() {\n for (const eventName in this.events) {\n const handler = this.events[eventName].bind(this)\n this.webSocket[`on${eventName}`] = handler\n }\n }\n\n uninstallEventHandlers() {\n for (const eventName in this.events) {\n this.webSocket[`on${eventName}`] = function () {}\n }\n }\n}\n\nConnection.reopenDelay = 500\n\nConnection.prototype.events = {\n message(event) {\n if (!this.isProtocolSupported()) {\n return\n }\n const { identifier, message, reason, reconnect, type } = JSON.parse(event.data)\n switch (type) {\n case message_types.welcome:\n if (this.triedToReconnect()) {\n this.reconnectAttempted = true\n }\n this.monitor.recordConnect()\n return this.subscriptions.reload()\n case message_types.disconnect:\n logger.log(`Disconnecting. Reason: ${reason}`)\n return this.close({ allowReconnect: reconnect })\n case message_types.ping:\n return this.monitor.recordPing()\n case message_types.confirmation:\n this.subscriptions.confirmSubscription(identifier)\n if (this.reconnectAttempted) {\n this.reconnectAttempted = false\n return this.subscriptions.notify(identifier, 'connected', { reconnected: true })\n } else {\n return this.subscriptions.notify(identifier, 'connected', { reconnected: false })\n }\n case message_types.rejection:\n return this.subscriptions.reject(identifier)\n default:\n return this.subscriptions.notify(identifier, 'received', message)\n }\n },\n\n open() {\n logger.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`)\n this.disconnected = false\n if (!this.isProtocolSupported()) {\n logger.log('Protocol is unsupported. Stopping monitor and disconnecting.')\n return this.close({ allowReconnect: false })\n }\n },\n\n close(_event) {\n logger.log('WebSocket onclose event')\n if (this.disconnected) {\n return\n }\n this.disconnected = true\n this.monitor.recordDisconnect()\n return this.subscriptions.notifyAll('disconnected', {\n willAttemptReconnect: this.monitor.isRunning(),\n })\n },\n\n error() {\n logger.log('WebSocket onerror event')\n },\n}\n\nexport default Connection\n","import type { Consumer } from './consumer'\n\nexport type Data = { [id: string]: string | object | null | undefined }\n\nconst extend = function (object: Data, properties: Data) {\n if (properties !== null) {\n for (const key in properties) {\n const value = properties[key]\n object[key] = value\n }\n }\n return object\n}\n\nexport class Subscription {\n consumer: Consumer\n identifier: string\n\n constructor(consumer: Consumer, params: Data = {}, mixin: Data) {\n this.consumer = consumer\n this.identifier = JSON.stringify(params)\n extend(this as unknown as Data, mixin)\n }\n\n // Perform a channel action with the optional data passed as an attribute\n perform(action: string, data: Data = {}) {\n data.action = action\n return this.send(data)\n }\n\n send(data: object) {\n return this.consumer.send({\n command: 'message',\n identifier: this.identifier,\n data: JSON.stringify(data),\n })\n }\n\n unsubscribe() {\n return this.consumer.subscriptions.remove(this)\n }\n}\n\nexport default Subscription\n","import logger from './logger'\nimport type { Subscription } from './subscription'\nimport type { Subscriptions } from './subscriptions'\n\n// Responsible for ensuring channel subscribe command is confirmed, retrying until confirmation is received.\n// Internal class, not intended for direct user manipulation.\n\nclass SubscriptionGuarantor {\n subscriptions: Subscriptions\n pendingSubscriptions: Array<Subscription>\n retryTimeout: ReturnType<typeof setTimeout> | undefined\n\n constructor(subscriptions: Subscriptions) {\n this.subscriptions = subscriptions\n this.pendingSubscriptions = []\n }\n\n guarantee(subscription: Subscription) {\n if (this.pendingSubscriptions.indexOf(subscription) == -1) {\n logger.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`)\n this.pendingSubscriptions.push(subscription)\n } else {\n logger.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`)\n }\n this.startGuaranteeing()\n }\n\n forget(subscription: Subscription) {\n logger.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`)\n this.pendingSubscriptions = this.pendingSubscriptions.filter((s) => s !== subscription)\n }\n\n startGuaranteeing() {\n this.stopGuaranteeing()\n this.retrySubscribing()\n }\n\n stopGuaranteeing() {\n clearTimeout(this.retryTimeout)\n }\n\n retrySubscribing() {\n this.retryTimeout = setTimeout(() => {\n if (this.subscriptions && typeof this.subscriptions.subscribe === 'function') {\n this.pendingSubscriptions.map((subscription) => {\n logger.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`)\n this.subscriptions.subscribe(subscription)\n })\n }\n }, 500)\n }\n}\n\nexport default SubscriptionGuarantor\n","import type { Consumer } from './consumer'\nimport logger from './logger'\nimport type { Data } from './subscription'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\n\n// Collection class for creating (and internally managing) channel subscriptions.\n// The only method intended to be triggered by the user is ActionCable.Subscriptions#create,\n// and it should be called through the consumer like so:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n\nexport class Subscriptions {\n consumer: Consumer\n guarantor: SubscriptionGuarantor\n subscriptions: Array<Subscription>\n\n constructor(consumer: Consumer) {\n this.consumer = consumer\n this.guarantor = new SubscriptionGuarantor(this)\n this.subscriptions = []\n }\n\n create(channelName: string, mixin: Data) {\n const channel = channelName\n const params = typeof channel === 'object' ? channel : { channel }\n const subscription = new Subscription(this.consumer, params, mixin)\n return this.add(subscription)\n }\n\n // Private\n\n add(subscription: Subscription) {\n this.subscriptions.push(subscription)\n this.consumer.ensureActiveConnection()\n this.notify(subscription, 'initialized')\n this.subscribe(subscription)\n return subscription\n }\n\n remove(subscription: Subscription) {\n this.forget(subscription)\n if (!this.findAll(subscription.identifier).length) {\n this.sendCommand(subscription, 'unsubscribe')\n }\n return subscription\n }\n\n reject(identifier: string) {\n return this.findAll(identifier).map((subscription) => {\n this.forget(subscription)\n this.notify(subscription, 'rejected')\n return subscription\n })\n }\n\n forget(subscription: Subscription) {\n this.guarantor.forget(subscription)\n this.subscriptions = this.subscriptions.filter((s) => s !== subscription)\n return subscription\n }\n\n findAll(identifier: string) {\n return this.subscriptions.filter((s) => s.identifier === identifier)\n }\n\n reload() {\n return this.subscriptions.map((subscription) => this.subscribe(subscription))\n }\n\n notifyAll(callbackName: string, ...args: any[]) {\n return this.subscriptions.map((subscription) =>\n this.notify(subscription, callbackName, ...args)\n )\n }\n\n notify(subscription: Subscription, callbackName: string, ...args: any[]) {\n let subscriptions\n if (typeof subscription === 'string') {\n subscriptions = this.findAll(subscription)\n } else {\n subscriptions = [subscription]\n }\n\n return subscriptions.map((subscription: any) =>\n typeof subscription[callbackName] === 'function'\n ? subscription[callbackName](...args)\n : undefined\n )\n }\n\n subscribe(subscription: Subscription) {\n if (this.sendCommand(subscription, 'subscribe')) {\n this.guarantor.guarantee(subscription)\n }\n }\n\n confirmSubscription(identifier: string) {\n logger.log(`Subscription confirmed ${identifier}`)\n this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription))\n }\n\n sendCommand(subscription: Subscription, command: string) {\n const { identifier } = subscription\n return this.consumer.send({ command, identifier })\n }\n}\n\nexport default Subscriptions\n","import Connection from './connection'\nimport Subscriptions from './subscriptions'\n\n// The ActionCable.Consumer establishes the connection to a server-side Ruby Connection object. Once established,\n// the ActionCable.ConnectionMonitor will ensure that its properly maintained through heartbeats and checking for stale updates.\n// The Consumer instance is also the gateway to establishing subscriptions to desired channels through the #createSubscription\n// method.\n//\n// The following example shows how this can be set up:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n//\n// When a consumer is created, it automatically connects with the server.\n//\n// To disconnect from the server, call\n//\n// App.cable.disconnect()\n//\n// and to restart the connection:\n//\n// App.cable.connect()\n//\n// Any channel subscriptions which existed prior to disconnecting will\n// automatically resubscribe.\n\nexport class Consumer {\n _url: string\n subscriptions: Subscriptions\n connection: Connection\n subprotocols: Array<string>\n\n constructor(url: string) {\n this._url = url\n this.subscriptions = new Subscriptions(this)\n this.connection = new Connection(this)\n this.subprotocols = []\n }\n\n get url() {\n return createWebSocketURL(this._url)\n }\n\n send(data: object) {\n return this.connection.send(data)\n }\n\n connect() {\n return this.connection.open()\n }\n\n disconnect() {\n return this.connection.close({ allowReconnect: false })\n }\n\n ensureActiveConnection() {\n if (!this.connection.isActive()) {\n return this.connection.open()\n }\n }\n\n addSubProtocol(subprotocol: string) {\n this.subprotocols = [...this.subprotocols, subprotocol]\n }\n}\n\nexport function createWebSocketURL(url: string | (() => string)): string {\n if (typeof url === 'function') {\n url = url()\n }\n\n if (url && !/^wss?:/i.test(url)) {\n const a = document.createElement('a')\n a.href = url\n // eslint-disable-next-line no-self-assign\n a.href = a.href\n a.protocol = a.protocol.replace('http', 'ws')\n return a.href\n } else {\n return url\n }\n}\n\nexport default Consumer\n","'use client'\n\nimport adapters from './adapters'\nimport Connection from './connection'\nimport ConnectionMonitor from './connection_monitor'\nimport Consumer, { createWebSocketURL } from './consumer'\nimport INTERNAL from './internal'\nimport logger from './logger'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\nimport Subscriptions from './subscriptions'\n\nexport {\n Connection,\n ConnectionMonitor,\n Consumer,\n INTERNAL,\n Subscription,\n Subscriptions,\n SubscriptionGuarantor,\n adapters,\n createWebSocketURL,\n logger,\n}\n\nexport function createConsumer(url = getConfig('url') || INTERNAL.default_mount_path) {\n return new Consumer(url)\n}\n\nexport function getConfig(name: string) {\n const element = document.head.querySelector(`meta[name='action-cable-${name}']`)\n if (element) {\n return element.getAttribute('content')\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/api/graphql/links/actioncable/adapters.ts","../../../../../package.json","../../../../../src/configuration.ts","../../../../../src/api/graphql/links/actioncable/logger.ts","../../../../../src/api/graphql/links/actioncable/connection_monitor.ts","../../../../../src/api/graphql/links/actioncable/internal.ts","../../../../../src/api/graphql/links/actioncable/connection.ts","../../../../../src/api/graphql/links/actioncable/subscription.ts","../../../../../src/api/graphql/links/actioncable/subscription_guarantor.ts","../../../../../src/api/graphql/links/actioncable/subscriptions.ts","../../../../../src/api/graphql/links/actioncable/consumer.ts","../../../../../src/api/graphql/links/actioncable/index.ts"],"names":["adapters_default","name","version","QUILTT_API_INSECURE","e","QUILTT_API_DOMAIN","QUILTT_DEBUG","domain","protocolHttp","protocolWebsockets","debugging","endpointAuth","endpointGraphQL","endpointWebsockets","Logger","__publicField","messages","logger","logger_default","now","secondsSince","time","ConnectionMonitor","connection","staleThreshold","reconnectionBackoffRate","backoff","jitter","connection_monitor_default","INTERNAL","internal_default","message_types","protocols","supportedProtocols","indexOf","Connection","consumer","data","socketProtocols","allowReconnect","error","states","state","eventName","handler","event","identifier","message","reason","reconnect","type","_event","connection_default","extend","object","properties","key","value","Subscription","params","mixin","action","subscription_default","SubscriptionGuarantor","subscriptions","subscription","s","subscription_guarantor_default","Subscriptions","channelName","channel","callbackName","args","command","subscriptions_default","Consumer","url","createWebSocketURL","subprotocol","a","consumer_default","createConsumer","getConfig","element"],"mappings":"qLAAA,IAAOA,EAAQ,CACb,OAAQ,OAAO,YAAe,YAAc,WAAW,QAAU,OACjE,UAAW,OAAO,YAAe,YAAc,WAAW,UAAY,MACxE,ECFE,IAAAC,EAAQ,eACRC,EAAW,QCAb,IAAMC,GAAuB,IAAM,CACjC,GAAI,CACF,OAAO,QAAQ,IAAI,mBACrB,OAAQC,EAAN,CACA,MACF,CACF,GAAG,EAEGC,GAAqB,IAAM,CAC/B,GAAI,CACF,OAAO,QAAQ,IAAI,iBACrB,OAAQD,EAAN,CACA,MACF,CACF,GAAG,EAEGE,GAAgB,IAAM,CAC1B,GAAI,CACF,MAAO,CAAC,CAAC,QAAQ,IAAI,cAAgB,QAAQ,IAAI,WAAa,YAChE,OAAQF,EAAN,CACA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AmB,KAAK,IAAI,CACrC,CAEA,KAAKxC,EAAc,CACjB,OAAO,KAAK,WAAW,KAAKA,CAAI,CAClC,CAEA,SAAU,CACR,OAAO,KAAK,WAAW,KAAK,CAC9B,CAEA,YAAa,CACX,OAAO,KAAK,WAAW,MAAM,CAAE,eAAgB,EAAM,CAAC,CACxD,CAEA,wBAAyB,CACvB,GAAI,CAAC,KAAK,WAAW,SAAS,EAC5B,OAAO,KAAK,WAAW,KAAK,CAEhC,CAEA,eAAeyC,EAAqB,CAClC,KAAK,aAAe,CAAC,GAAG,KAAK,aAAcA,CAAW,CACxD,CACF,EAEO,SAASD,EAAmBD,EAAsC,CAKvE,GAJI,OAAOA,GAAQ,aACjBA,EAAMA,EAAI,GAGRA,GAAO,CAAC,UAAU,KAAKA,CAAG,EAAG,CAC/B,IAAMG,EAAI,SAAS,cAAc,GAAG,EACpC,OAAAA,EAAE,KAAOH,EAETG,EAAE,KAAOA,EAAE,KACXA,EAAE,SAAWA,EAAE,SAAS,QAAQ,OAAQ,IAAI,EACrCA,EAAE,SAET,QAAOH,CAEX,CAEA,IAAOI,EAAQL,EC7DR,SAASM,GAAeL,EAAMM,EAAU,KAAK,GAAKpD,EAAS,mBAAoB,CACpF,OAAO,IAAIkD,EAASJ,CAAG,CACzB,CAEO,SAASM,EAAUjF,EAAc,CACtC,IAAMkF,EAAU,SAAS,KAAK,cAAc,2BAA2BlF,KAAQ,EAC/E,GAAIkF,EACF,OAAOA,EAAQ,aAAa,SAAS,CAEzC","sourcesContent":["export default {\n logger: typeof globalThis !== 'undefined' ? globalThis.console : undefined,\n WebSocket: typeof globalThis !== 'undefined' ? globalThis.WebSocket : undefined,\n}\n","{\n \"name\": \"@quiltt/core\",\n \"version\": \"3.3.3\",\n \"description\": \"Javascript API client and utilities for Quiltt\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/quiltt/quiltt-public.git\",\n \"directory\": \"ECMAScript/core\"\n },\n \"homepage\": \"https://github.com/quiltt/quiltt-public/tree/main/ECMAScript/core#readme\",\n \"keywords\": [\n \"quiltt\",\n \"typescript\"\n ],\n \"license\": \"MIT\",\n \"sideEffects\": [\n \"./src/Storage/Local.ts\",\n \"./src/api/graphql/links/SubscriptionLink.ts\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist/**\",\n \"src/**\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf .turbo dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"TIMING=1 eslint --ext .js,.jsx,.ts,.tsx src/ --fix\",\n \"typecheck\": \"tsc --project tsconfig.json --noEmit\"\n },\n \"dependencies\": {\n \"@apollo/client\": \"^3.7.16\",\n \"axios\": \"^1.4.0\",\n \"cross-fetch\": \"^3.1.8\",\n \"graphql\": \"^16.8.1\",\n \"graphql-ruby-client\": \"^1.11.8\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"4.1.1\",\n \"@types/node\": \"18.16.18\",\n \"@types/react\": \"18.2.7\",\n \"@typescript-eslint/eslint-plugin\": \"5.60.1\",\n \"@typescript-eslint/parser\": \"5.60.1\",\n \"eslint\": \"8.43.0\",\n \"eslint-config-prettier\": \"8.8.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"prettier\": \"2.8.8\",\n \"tsup\": \"6.7.0\",\n \"typescript\": \"5.1.3\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import { name as packageName, version as packageVersion } from '../package.json'\n\nconst QUILTT_API_INSECURE = (() => {\n try {\n return process.env.QUILTT_API_INSECURE\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_API_DOMAIN = (() => {\n try {\n return process.env.QUILTT_API_DOMAIN\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_DEBUG = (() => {\n try {\n return !!process.env.QUILTT_DEBUG || process.env.NODE_ENV !== 'production'\n } catch {\n return false\n }\n})()\n\nconst domain = QUILTT_API_DOMAIN || 'quiltt.io'\nconst protocolHttp = `http${QUILTT_API_INSECURE ? '' : 's'}`\nconst protocolWebsockets = `ws${QUILTT_API_DOMAIN ? '' : 's'}`\n\nexport const debugging = QUILTT_DEBUG\nexport const endpointAuth = `${protocolHttp}://auth.${domain}/v1/users/session`\nexport const endpointGraphQL = `${protocolHttp}://api.${domain}/v1/graphql`\nexport const endpointWebsockets = `${protocolWebsockets}://api.${domain}/websockets`\nexport const version = `${packageName}: v${packageVersion}`\n\nconst Config = {\n debugging,\n endpointAuth,\n endpointGraphQL,\n endpointWebsockets,\n version,\n}\n\nexport default Config\n","import { debugging } from '../../../../configuration'\nimport adapters from './adapters'\n\nclass Logger {\n enabled = debugging\n\n log(...messages: Array<string>) {\n if (adapters.logger && this.enabled) {\n messages.push(Date.now().toString())\n adapters.logger.log('[ActionCable]', ...messages)\n }\n }\n}\n\nexport const logger = new Logger()\nexport default logger\n","// @ts-nocheck\nimport logger from './logger'\n\n// Responsible for ensuring the cable connection is in good health by validating the heartbeat pings sent from the server, and attempting\n// revival reconnections if things go astray. Internal class, not intended for direct user manipulation.\n\nconst now = () => new Date().getTime()\n\nconst secondsSince = (time) => (now() - time) / 1000\n\nclass ConnectionMonitor {\n constructor(connection) {\n this.visibilityDidChange = this.visibilityDidChange.bind(this)\n this.connection = connection\n this.reconnectAttempts = 0\n }\n\n start() {\n if (!this.isRunning()) {\n this.startedAt = now()\n delete this.stoppedAt\n this.startPolling()\n addEventListener('visibilitychange', this.visibilityDidChange)\n logger.log(\n `ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`\n )\n }\n }\n\n stop() {\n if (this.isRunning()) {\n this.stoppedAt = now()\n this.stopPolling()\n removeEventListener('visibilitychange', this.visibilityDidChange)\n logger.log('ConnectionMonitor stopped')\n }\n }\n\n isRunning() {\n return this.startedAt && !this.stoppedAt\n }\n\n recordPing() {\n this.pingedAt = now()\n }\n\n recordConnect() {\n this.reconnectAttempts = 0\n this.recordPing()\n delete this.disconnectedAt\n logger.log('ConnectionMonitor recorded connect')\n }\n\n recordDisconnect() {\n this.disconnectedAt = now()\n logger.log('ConnectionMonitor recorded disconnect')\n }\n\n // Private\n\n startPolling() {\n this.stopPolling()\n this.poll()\n }\n\n stopPolling() {\n clearTimeout(this.pollTimeout)\n }\n\n poll() {\n this.pollTimeout = setTimeout(() => {\n this.reconnectIfStale()\n this.poll()\n }, this.getPollInterval())\n }\n\n getPollInterval() {\n const { staleThreshold, reconnectionBackoffRate } = this.constructor\n const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10))\n const jitterMax = this.reconnectAttempts === 0 ? 1.0 : reconnectionBackoffRate\n const jitter = jitterMax * Math.random()\n return staleThreshold * 1000 * backoff * (1 + jitter)\n }\n\n reconnectIfStale() {\n if (this.connectionIsStale()) {\n logger.log(\n `ConnectionMonitor detected stale connection. reconnectAttempts = ${\n this.reconnectAttempts\n }, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${\n this.constructor.staleThreshold\n } s`\n )\n this.reconnectAttempts++\n if (this.disconnectedRecently()) {\n logger.log(\n `ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(\n this.disconnectedAt\n )} s`\n )\n } else {\n logger.log('ConnectionMonitor reopening')\n this.connection.reopen()\n }\n }\n }\n\n get refreshedAt() {\n return this.pingedAt ? this.pingedAt : this.startedAt\n }\n\n connectionIsStale() {\n return secondsSince(this.refreshedAt) > this.constructor.staleThreshold\n }\n\n disconnectedRecently() {\n return (\n this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold\n )\n }\n\n visibilityDidChange() {\n if (document.visibilityState === 'visible') {\n setTimeout(() => {\n if (this.connectionIsStale() || !this.connection.isOpen()) {\n logger.log(\n `ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`\n )\n this.connection.reopen()\n }\n }, 200)\n }\n }\n}\n\nConnectionMonitor.staleThreshold = 6 // Server::Connections::BEAT_INTERVAL * 2 (missed two pings)\nConnectionMonitor.reconnectionBackoffRate = 0.15\n\nexport default ConnectionMonitor\n","const INTERNAL = {\n message_types: {\n welcome: 'welcome',\n disconnect: 'disconnect',\n ping: 'ping',\n confirmation: 'confirm_subscription',\n rejection: 'reject_subscription',\n },\n disconnect_reasons: {\n unauthorized: 'unauthorized',\n invalid_request: 'invalid_request',\n server_restart: 'server_restart',\n remote: 'remote',\n },\n default_mount_path: '/cable',\n protocols: ['actioncable-v1-json', 'actioncable-unsupported'],\n}\n\nexport default INTERNAL\n","// @ts-nocheck\nimport adapters from './adapters'\nimport ConnectionMonitor from './connection_monitor'\nimport INTERNAL from './internal'\nimport logger from './logger'\n\n// Encapsulate the cable connection held by the consumer. This is an internal class not intended for direct user manipulation.\n\nconst { message_types, protocols } = INTERNAL\nconst supportedProtocols = protocols.slice(0, protocols.length - 1)\n\nconst indexOf = [].indexOf\n\nclass Connection {\n constructor(consumer) {\n this.open = this.open.bind(this)\n this.consumer = consumer\n this.subscriptions = this.consumer.subscriptions\n this.monitor = new ConnectionMonitor(this)\n this.disconnected = true\n }\n\n send(data) {\n if (this.isOpen()) {\n this.webSocket.send(JSON.stringify(data))\n return true\n } else {\n return false\n }\n }\n\n open() {\n if (this.isActive()) {\n logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`)\n return false\n } else {\n const socketProtocols = [...protocols, ...(this.consumer.subprotocols || [])]\n logger.log(\n `Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`\n )\n if (this.webSocket) {\n this.uninstallEventHandlers()\n }\n this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols)\n this.installEventHandlers()\n this.monitor.start()\n return true\n }\n }\n\n close({ allowReconnect } = { allowReconnect: true }) {\n if (!allowReconnect) {\n this.monitor.stop()\n }\n // Avoid closing websockets in a \"connecting\" state due to Safari 15.1+ bug. See: https://github.com/rails/rails/issues/43835#issuecomment-1002288478\n if (this.isOpen()) {\n return this.webSocket.close()\n }\n }\n\n reopen() {\n logger.log(`Reopening WebSocket, current state is ${this.getState()}`)\n if (this.isActive()) {\n try {\n return this.close()\n } catch (error) {\n logger.log('Failed to reopen WebSocket', error)\n } finally {\n logger.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`)\n setTimeout(this.open, this.constructor.reopenDelay)\n }\n } else {\n return this.open()\n }\n }\n\n getProtocol() {\n if (this.webSocket) {\n return this.webSocket.protocol\n }\n }\n\n isOpen() {\n return this.isState('open')\n }\n\n isActive() {\n return this.isState('open', 'connecting')\n }\n\n triedToReconnect() {\n return this.monitor.reconnectAttempts > 0\n }\n\n // Private\n\n isProtocolSupported() {\n return indexOf.call(supportedProtocols, this.getProtocol()) >= 0\n }\n\n isState(...states) {\n return indexOf.call(states, this.getState()) >= 0\n }\n\n getState() {\n if (this.webSocket) {\n for (const state in adapters.WebSocket) {\n if (adapters.WebSocket[state] === this.webSocket.readyState) {\n return state.toLowerCase()\n }\n }\n }\n return null\n }\n\n installEventHandlers() {\n for (const eventName in this.events) {\n const handler = this.events[eventName].bind(this)\n this.webSocket[`on${eventName}`] = handler\n }\n }\n\n uninstallEventHandlers() {\n for (const eventName in this.events) {\n this.webSocket[`on${eventName}`] = function () {}\n }\n }\n}\n\nConnection.reopenDelay = 500\n\nConnection.prototype.events = {\n message(event) {\n if (!this.isProtocolSupported()) {\n return\n }\n const { identifier, message, reason, reconnect, type } = JSON.parse(event.data)\n switch (type) {\n case message_types.welcome:\n if (this.triedToReconnect()) {\n this.reconnectAttempted = true\n }\n this.monitor.recordConnect()\n return this.subscriptions.reload()\n case message_types.disconnect:\n logger.log(`Disconnecting. Reason: ${reason}`)\n return this.close({ allowReconnect: reconnect })\n case message_types.ping:\n return this.monitor.recordPing()\n case message_types.confirmation:\n this.subscriptions.confirmSubscription(identifier)\n if (this.reconnectAttempted) {\n this.reconnectAttempted = false\n return this.subscriptions.notify(identifier, 'connected', { reconnected: true })\n } else {\n return this.subscriptions.notify(identifier, 'connected', { reconnected: false })\n }\n case message_types.rejection:\n return this.subscriptions.reject(identifier)\n default:\n return this.subscriptions.notify(identifier, 'received', message)\n }\n },\n\n open() {\n logger.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`)\n this.disconnected = false\n if (!this.isProtocolSupported()) {\n logger.log('Protocol is unsupported. Stopping monitor and disconnecting.')\n return this.close({ allowReconnect: false })\n }\n },\n\n close(_event) {\n logger.log('WebSocket onclose event')\n if (this.disconnected) {\n return\n }\n this.disconnected = true\n this.monitor.recordDisconnect()\n return this.subscriptions.notifyAll('disconnected', {\n willAttemptReconnect: this.monitor.isRunning(),\n })\n },\n\n error() {\n logger.log('WebSocket onerror event')\n },\n}\n\nexport default Connection\n","import type { Consumer } from './consumer'\n\nexport type Data = { [id: string]: string | object | null | undefined }\n\nconst extend = function (object: Data, properties: Data) {\n if (properties !== null) {\n for (const key in properties) {\n const value = properties[key]\n object[key] = value\n }\n }\n return object\n}\n\nexport class Subscription {\n consumer: Consumer\n identifier: string\n\n constructor(consumer: Consumer, params: Data = {}, mixin: Data) {\n this.consumer = consumer\n this.identifier = JSON.stringify(params)\n extend(this as unknown as Data, mixin)\n }\n\n // Perform a channel action with the optional data passed as an attribute\n perform(action: string, data: Data = {}) {\n data.action = action\n return this.send(data)\n }\n\n send(data: object) {\n return this.consumer.send({\n command: 'message',\n identifier: this.identifier,\n data: JSON.stringify(data),\n })\n }\n\n unsubscribe() {\n return this.consumer.subscriptions.remove(this)\n }\n}\n\nexport default Subscription\n","import logger from './logger'\nimport type { Subscription } from './subscription'\nimport type { Subscriptions } from './subscriptions'\n\n// Responsible for ensuring channel subscribe command is confirmed, retrying until confirmation is received.\n// Internal class, not intended for direct user manipulation.\n\nclass SubscriptionGuarantor {\n subscriptions: Subscriptions\n pendingSubscriptions: Array<Subscription>\n retryTimeout: ReturnType<typeof setTimeout> | undefined\n\n constructor(subscriptions: Subscriptions) {\n this.subscriptions = subscriptions\n this.pendingSubscriptions = []\n }\n\n guarantee(subscription: Subscription) {\n if (this.pendingSubscriptions.indexOf(subscription) == -1) {\n logger.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`)\n this.pendingSubscriptions.push(subscription)\n } else {\n logger.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`)\n }\n this.startGuaranteeing()\n }\n\n forget(subscription: Subscription) {\n logger.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`)\n this.pendingSubscriptions = this.pendingSubscriptions.filter((s) => s !== subscription)\n }\n\n startGuaranteeing() {\n this.stopGuaranteeing()\n this.retrySubscribing()\n }\n\n stopGuaranteeing() {\n clearTimeout(this.retryTimeout)\n }\n\n retrySubscribing() {\n this.retryTimeout = setTimeout(() => {\n if (this.subscriptions && typeof this.subscriptions.subscribe === 'function') {\n this.pendingSubscriptions.map((subscription) => {\n logger.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`)\n this.subscriptions.subscribe(subscription)\n })\n }\n }, 500)\n }\n}\n\nexport default SubscriptionGuarantor\n","import type { Consumer } from './consumer'\nimport logger from './logger'\nimport type { Data } from './subscription'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\n\n// Collection class for creating (and internally managing) channel subscriptions.\n// The only method intended to be triggered by the user is ActionCable.Subscriptions#create,\n// and it should be called through the consumer like so:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n\nexport class Subscriptions {\n consumer: Consumer\n guarantor: SubscriptionGuarantor\n subscriptions: Array<Subscription>\n\n constructor(consumer: Consumer) {\n this.consumer = consumer\n this.guarantor = new SubscriptionGuarantor(this)\n this.subscriptions = []\n }\n\n create(channelName: string, mixin: Data) {\n const channel = channelName\n const params = typeof channel === 'object' ? channel : { channel }\n const subscription = new Subscription(this.consumer, params, mixin)\n return this.add(subscription)\n }\n\n // Private\n\n add(subscription: Subscription) {\n this.subscriptions.push(subscription)\n this.consumer.ensureActiveConnection()\n this.notify(subscription, 'initialized')\n this.subscribe(subscription)\n return subscription\n }\n\n remove(subscription: Subscription) {\n this.forget(subscription)\n if (!this.findAll(subscription.identifier).length) {\n this.sendCommand(subscription, 'unsubscribe')\n }\n return subscription\n }\n\n reject(identifier: string) {\n return this.findAll(identifier).map((subscription) => {\n this.forget(subscription)\n this.notify(subscription, 'rejected')\n return subscription\n })\n }\n\n forget(subscription: Subscription) {\n this.guarantor.forget(subscription)\n this.subscriptions = this.subscriptions.filter((s) => s !== subscription)\n return subscription\n }\n\n findAll(identifier: string) {\n return this.subscriptions.filter((s) => s.identifier === identifier)\n }\n\n reload() {\n return this.subscriptions.map((subscription) => this.subscribe(subscription))\n }\n\n notifyAll(callbackName: string, ...args: any[]) {\n return this.subscriptions.map((subscription) =>\n this.notify(subscription, callbackName, ...args)\n )\n }\n\n notify(subscription: Subscription, callbackName: string, ...args: any[]) {\n let subscriptions\n if (typeof subscription === 'string') {\n subscriptions = this.findAll(subscription)\n } else {\n subscriptions = [subscription]\n }\n\n return subscriptions.map((subscription: any) =>\n typeof subscription[callbackName] === 'function'\n ? subscription[callbackName](...args)\n : undefined\n )\n }\n\n subscribe(subscription: Subscription) {\n if (this.sendCommand(subscription, 'subscribe')) {\n this.guarantor.guarantee(subscription)\n }\n }\n\n confirmSubscription(identifier: string) {\n logger.log(`Subscription confirmed ${identifier}`)\n this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription))\n }\n\n sendCommand(subscription: Subscription, command: string) {\n const { identifier } = subscription\n return this.consumer.send({ command, identifier })\n }\n}\n\nexport default Subscriptions\n","import Connection from './connection'\nimport Subscriptions from './subscriptions'\n\n// The ActionCable.Consumer establishes the connection to a server-side Ruby Connection object. Once established,\n// the ActionCable.ConnectionMonitor will ensure that its properly maintained through heartbeats and checking for stale updates.\n// The Consumer instance is also the gateway to establishing subscriptions to desired channels through the #createSubscription\n// method.\n//\n// The following example shows how this can be set up:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n//\n// When a consumer is created, it automatically connects with the server.\n//\n// To disconnect from the server, call\n//\n// App.cable.disconnect()\n//\n// and to restart the connection:\n//\n// App.cable.connect()\n//\n// Any channel subscriptions which existed prior to disconnecting will\n// automatically resubscribe.\n\nexport class Consumer {\n _url: string\n subscriptions: Subscriptions\n connection: Connection\n subprotocols: Array<string>\n\n constructor(url: string) {\n this._url = url\n this.subscriptions = new Subscriptions(this)\n this.connection = new Connection(this)\n this.subprotocols = []\n }\n\n get url() {\n return createWebSocketURL(this._url)\n }\n\n send(data: object) {\n return this.connection.send(data)\n }\n\n connect() {\n return this.connection.open()\n }\n\n disconnect() {\n return this.connection.close({ allowReconnect: false })\n }\n\n ensureActiveConnection() {\n if (!this.connection.isActive()) {\n return this.connection.open()\n }\n }\n\n addSubProtocol(subprotocol: string) {\n this.subprotocols = [...this.subprotocols, subprotocol]\n }\n}\n\nexport function createWebSocketURL(url: string | (() => string)): string {\n if (typeof url === 'function') {\n url = url()\n }\n\n if (url && !/^wss?:/i.test(url)) {\n const a = document.createElement('a')\n a.href = url\n // eslint-disable-next-line no-self-assign\n a.href = a.href\n a.protocol = a.protocol.replace('http', 'ws')\n return a.href\n } else {\n return url\n }\n}\n\nexport default Consumer\n","'use client'\n\nimport adapters from './adapters'\nimport Connection from './connection'\nimport ConnectionMonitor from './connection_monitor'\nimport Consumer, { createWebSocketURL } from './consumer'\nimport INTERNAL from './internal'\nimport logger from './logger'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\nimport Subscriptions from './subscriptions'\n\nexport {\n Connection,\n ConnectionMonitor,\n Consumer,\n INTERNAL,\n Subscription,\n Subscriptions,\n SubscriptionGuarantor,\n adapters,\n createWebSocketURL,\n logger,\n}\n\nexport function createConsumer(url = getConfig('url') || INTERNAL.default_mount_path) {\n return new Consumer(url)\n}\n\nexport function getConfig(name: string) {\n const element = document.head.querySelector(`meta[name='action-cable-${name}']`)\n if (element) {\n return element.getAttribute('content')\n }\n}\n"]}
|
|
@@ -13,7 +13,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
13
13
|
|
|
14
14
|
var bt__default = /*#__PURE__*/_interopDefault(bt);
|
|
15
15
|
|
|
16
|
-
var nt=Object.defineProperty,ct=Object.defineProperties;var at=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var lt=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var A=(r,t,e)=>t in r?nt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,b=(r,t)=>{for(var e in t||(t={}))lt.call(t,e)&&A(r,e,t[e]);if(D)for(var e of D(t))pt.call(t,e)&&A(r,e,t[e]);return r},g=(r,t)=>ct(r,at(t));var o=(r,t,e)=>(A(r,typeof t!="symbol"?t+"":t,e),e);var v=class{constructor(){o(this,"observers",{});o(this,"isEnabled",()=>{try{return localStorage.setItem("quiltt.ping","pong"),localStorage.removeItem("quiltt.ping"),!0}catch(t){return !1}});o(this,"isDisabled",()=>!this.isEnabled());o(this,"get",t=>{if(!(typeof window=="undefined"||window.expo))try{let e=window.localStorage.getItem(`quiltt.${t}`);return e&&JSON.parse(e)}catch(e){console.warn(`localStorage Error: "quiltt.${t}"`,e);return}});o(this,"set",(t,e)=>{if(!(typeof window=="undefined"||window.expo))try{e?window.localStorage.setItem(`quiltt.${t}`,JSON.stringify(e)):window.localStorage.removeItem(`quiltt.${t}`);}catch(i){console.warn(`localStorage Error: "quiltt.${t}"`,i);}});o(this,"remove",t=>{try{window.localStorage.removeItem(`quiltt.${t}`);}catch(e){console.warn(`localStorage Error: "quiltt.${t}">`,e);}});o(this,"subscribe",(t,e)=>{this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e);});o(this,"unsubscribe",(t,e)=>{var i;this.observers[t]=(i=this.observers[t])==null?void 0:i.filter(s=>s!==e);});o(this,"handleStorageEvent",t=>{if(t.key&&t.key.includes("quiltt.")){let e=t.newValue?JSON.parse(t.newValue):null;this.observers[t.key]&&this.observers[t.key].forEach(i=>i(e));}else Object.entries(this.observers).forEach(([e,i])=>{i.forEach(s=>s(this.get(e)));});});typeof window!="undefined"&&!(window!=null&&window.expo)&&window.addEventListener("storage",this.handleStorageEvent.bind(this));}};var u=class{constructor(t){o(this,"state");o(this,"observers",[]);o(this,"get",()=>this.state);o(this,"set",t=>{this.state!==t&&(this.state=t,this.observers.forEach(e=>e(t)));});o(this,"subscribe",t=>{this.observers.push(t);});o(this,"unsubscribe",t=>{this.observers=this.observers.filter(e=>e!==t);});this.state=t;}};var S=class{constructor(){o(this,"observables",{});o(this,"get",t=>{if(this.observables[t])return this.observables[t].get()});o(this,"set",(t,e)=>{this.observables[t]?this.observables[t].set(e):this.observables[t]=new u(e);});o(this,"subscribe",(t,e)=>{this.observables[t]||(this.observables[t]=new u),this.observables[t].subscribe(e);});o(this,"unsubscribe",(t,e)=>{this.observables[t]&&this.observables[t].unsubscribe(e);});}};var C=class{constructor(){o(this,"memoryStore",new S);o(this,"localStore",new v);o(this,"observers",{});o(this,"monitors",new Set);o(this,"get",t=>{this.monitorLocalStorageChanges(t);let e=this.memoryStore.get(t);return e===void 0&&(e=this.localStore.get(t)),e});o(this,"set",(t,e)=>{var i;this.monitorLocalStorageChanges(t),this.localStore.set(t,e),this.memoryStore.set(t,e),(i=this.observers[t])==null||i.forEach(s=>s(e));});o(this,"subscribe",(t,e)=>{this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e);});o(this,"unsubscribe",(t,e)=>{var i;this.observers[t]=(i=this.observers[t])==null?void 0:i.filter(s=>s!==e);});o(this,"monitorLocalStorageChanges",t=>{this.monitors.has(t)||(this.monitors.add(t),this.localStore.subscribe(t,e=>{var c;let i=this.memoryStore.get(t),s=e instanceof Function?e(i):e;this.memoryStore.set(t,s),(c=this.observers[t])==null||c.forEach(T=>T(s));}));});}},p=new C;var j=class extends index_js$2.ApolloLink{request(t,e){let i=p.get("session");return i?(t.setContext(({headers:s={}})=>({headers:g(b({},s),{authorization:`Bearer ${i}`})})),e(t)):(console.warn("QuilttLink attempted to send an unauthenticated Query"),null)}};var G="@quiltt/core",W="3.3.1";var ht=(()=>{try{return process.env.QUILTT_API_INSECURE}catch(r){return}})(),Q=(()=>{try{return process.env.QUILTT_API_DOMAIN}catch(r){return}})(),dt=(()=>{try{return !!process.env.QUILTT_DEBUG||process.env.NODE_ENV!=="production"}catch(r){return !1}})(),k=Q||"quiltt.io",H=`http${ht?"":"s"}`,mt=`ws${Q?"":"s"}`,U=dt,y=`${H}://api.${k}/v1/graphql`,J=`${mt}://api.${k}/websockets`,B=`${G}: v${W}`;var oe=new index_js.BatchHttpLink({uri:y,fetch:bt__default.default});var ce=index_js$1.onError(({graphQLErrors:r,networkError:t})=>{r&&r.forEach(({message:e,locations:i,path:s})=>{console.log(`[GraphQL error]: Message: ${e}, Location: ${i}, Path: ${s}`);}),t&&(t.statusCode===401?(console.warn("[Authentication error]:",t),p.set("session",null)):console.warn("[Network error]:",t));});var pe=new index_js$2.ApolloLink((r,t)=>t(r));var fe=new index_js$3.HttpLink({uri:y,fetch:bt__default.default});var ve=new index_js$4.RetryLink({attempts:{retryIf:(r,t)=>r.statusCode>=500}});var l={logger:typeof globalThis!="undefined"?globalThis.console:void 0,WebSocket:typeof globalThis!="undefined"?globalThis.WebSocket:void 0};var O=class{constructor(){o(this,"enabled",U);}log(...t){l.logger&&this.enabled&&(t.push(Date.now().toString()),l.logger.log("[ActionCable]",...t));}},wt=new O,n=wt;var h=()=>new Date().getTime(),x=r=>(h()-r)/1e3,d=class{constructor(t){this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=t,this.reconnectAttempts=0;}start(){this.isRunning()||(this.startedAt=h(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),n.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`));}stop(){this.isRunning()&&(this.stoppedAt=h(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),n.log("ConnectionMonitor stopped"));}isRunning(){return this.startedAt&&!this.stoppedAt}recordPing(){this.pingedAt=h();}recordConnect(){this.reconnectAttempts=0,this.recordPing(),delete this.disconnectedAt,n.log("ConnectionMonitor recorded connect");}recordDisconnect(){this.disconnectedAt=h(),n.log("ConnectionMonitor recorded disconnect");}startPolling(){this.stopPolling(),this.poll();}stopPolling(){clearTimeout(this.pollTimeout);}poll(){this.pollTimeout=setTimeout(()=>{this.reconnectIfStale(),this.poll();},this.getPollInterval());}getPollInterval(){let{staleThreshold:t,reconnectionBackoffRate:e}=this.constructor,i=Math.pow(1+e,Math.min(this.reconnectAttempts,10)),c=(this.reconnectAttempts===0?1:e)*Math.random();return t*1e3*i*(1+c)}reconnectIfStale(){this.connectionIsStale()&&(n.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${x(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`),this.reconnectAttempts++,this.disconnectedRecently()?n.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${x(this.disconnectedAt)} s`):(n.log("ConnectionMonitor reopening"),this.connection.reopen()));}get refreshedAt(){return this.pingedAt?this.pingedAt:this.startedAt}connectionIsStale(){return x(this.refreshedAt)>this.constructor.staleThreshold}disconnectedRecently(){return this.disconnectedAt&&x(this.disconnectedAt)<this.constructor.staleThreshold}visibilityDidChange(){document.visibilityState==="visible"&&setTimeout(()=>{(this.connectionIsStale()||!this.connection.isOpen())&&(n.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`),this.connection.reopen());},200);}};d.staleThreshold=6;d.reconnectionBackoffRate=.15;var F=d;var Tt={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},disconnect_reasons:{unauthorized:"unauthorized",invalid_request:"invalid_request",server_restart:"server_restart",remote:"remote"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]},w=Tt;var{message_types:m,protocols:L}=w,At=L.slice(0,L.length-1),V=[].indexOf,f=class{constructor(t){this.open=this.open.bind(this),this.consumer=t,this.subscriptions=this.consumer.subscriptions,this.monitor=new F(this),this.disconnected=!0;}send(t){return this.isOpen()?(this.webSocket.send(JSON.stringify(t)),!0):!1}open(){if(this.isActive())return n.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`),!1;{let t=[...L,...this.consumer.subprotocols||[]];return n.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${t}`),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new l.WebSocket(this.consumer.url,t),this.installEventHandlers(),this.monitor.start(),!0}}close({allowReconnect:t}={allowReconnect:!0}){if(t||this.monitor.stop(),this.isOpen())return this.webSocket.close()}reopen(){if(n.log(`Reopening WebSocket, current state is ${this.getState()}`),this.isActive())try{return this.close()}catch(t){n.log("Failed to reopen WebSocket",t);}finally{n.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`),setTimeout(this.open,this.constructor.reopenDelay);}else return this.open()}getProtocol(){if(this.webSocket)return this.webSocket.protocol}isOpen(){return this.isState("open")}isActive(){return this.isState("open","connecting")}triedToReconnect(){return this.monitor.reconnectAttempts>0}isProtocolSupported(){return V.call(At,this.getProtocol())>=0}isState(...t){return V.call(t,this.getState())>=0}getState(){if(this.webSocket){for(let t in l.WebSocket)if(l.WebSocket[t]===this.webSocket.readyState)return t.toLowerCase()}return null}installEventHandlers(){for(let t in this.events){let e=this.events[t].bind(this);this.webSocket[`on${t}`]=e;}}uninstallEventHandlers(){for(let t in this.events)this.webSocket[`on${t}`]=function(){};}};f.reopenDelay=500;f.prototype.events={message(r){if(!this.isProtocolSupported())return;let{identifier:t,message:e,reason:i,reconnect:s,type:c}=JSON.parse(r.data);switch(c){case m.welcome:return this.triedToReconnect()&&(this.reconnectAttempted=!0),this.monitor.recordConnect(),this.subscriptions.reload();case m.disconnect:return n.log(`Disconnecting. Reason: ${i}`),this.close({allowReconnect:s});case m.ping:return this.monitor.recordPing();case m.confirmation:return this.subscriptions.confirmSubscription(t),this.reconnectAttempted?(this.reconnectAttempted=!1,this.subscriptions.notify(t,"connected",{reconnected:!0})):this.subscriptions.notify(t,"connected",{reconnected:!1});case m.rejection:return this.subscriptions.reject(t);default:return this.subscriptions.notify(t,"received",e)}},open(){if(n.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`),this.disconnected=!1,!this.isProtocolSupported())return n.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close(r){if(n.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error(){n.log("WebSocket onerror event");}};var z=f;var Ct=function(r,t){if(t!==null)for(let e in t){let i=t[e];r[e]=i;}return r},$=class{constructor(t,e={},i){o(this,"consumer");o(this,"identifier");this.consumer=t,this.identifier=JSON.stringify(e),Ct(this,i);}perform(t,e={}){return e.action=t,this.send(e)}send(t){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(t)})}unsubscribe(){return this.consumer.subscriptions.remove(this)}},K=$;var N=class{constructor(t){o(this,"subscriptions");o(this,"pendingSubscriptions");o(this,"retryTimeout");this.subscriptions=t,this.pendingSubscriptions=[];}guarantee(t){this.pendingSubscriptions.indexOf(t)==-1?(n.log(`SubscriptionGuarantor guaranteeing ${t.identifier}`),this.pendingSubscriptions.push(t)):n.log(`SubscriptionGuarantor already guaranteeing ${t.identifier}`),this.startGuaranteeing();}forget(t){n.log(`SubscriptionGuarantor forgetting ${t.identifier}`),this.pendingSubscriptions=this.pendingSubscriptions.filter(e=>e!==t);}startGuaranteeing(){this.stopGuaranteeing(),this.retrySubscribing();}stopGuaranteeing(){clearTimeout(this.retryTimeout);}retrySubscribing(){this.retryTimeout=setTimeout(()=>{this.subscriptions&&typeof this.subscriptions.subscribe=="function"&&this.pendingSubscriptions.map(t=>{n.log(`SubscriptionGuarantor resubscribing ${t.identifier}`),this.subscriptions.subscribe(t);});},500);}},X=N;var E=class{constructor(t){o(this,"consumer");o(this,"guarantor");o(this,"subscriptions");this.consumer=t,this.guarantor=new X(this),this.subscriptions=[];}create(t,e){let i=t,s=typeof i=="object"?i:{channel:i},c=new K(this.consumer,s,e);return this.add(c)}add(t){return this.subscriptions.push(t),this.consumer.ensureActiveConnection(),this.notify(t,"initialized"),this.subscribe(t),t}remove(t){return this.forget(t),this.findAll(t.identifier).length||this.sendCommand(t,"unsubscribe"),t}reject(t){return this.findAll(t).map(e=>(this.forget(e),this.notify(e,"rejected"),e))}forget(t){return this.guarantor.forget(t),this.subscriptions=this.subscriptions.filter(e=>e!==t),t}findAll(t){return this.subscriptions.filter(e=>e.identifier===t)}reload(){return this.subscriptions.map(t=>this.subscribe(t))}notifyAll(t,...e){return this.subscriptions.map(i=>this.notify(i,t,...e))}notify(t,e,...i){let s;return typeof t=="string"?s=this.findAll(t):s=[t],s.map(c=>typeof c[e]=="function"?c[e](...i):void 0)}subscribe(t){this.sendCommand(t,"subscribe")&&this.guarantor.guarantee(t);}confirmSubscription(t){n.log(`Subscription confirmed ${t}`),this.findAll(t).map(e=>this.guarantor.forget(e));}sendCommand(t,e){let{identifier:i}=t;return this.consumer.send({command:e,identifier:i})}},Y=E;var R=class{constructor(t){o(this,"_url");o(this,"subscriptions");o(this,"connection");o(this,"subprotocols");this._url=t,this.subscriptions=new Y(this),this.connection=new z(this),this.subprotocols=[];}get url(){return Z(this._url)}send(t){return this.connection.send(t)}connect(){return this.connection.open()}disconnect(){return this.connection.close({allowReconnect:!1})}ensureActiveConnection(){if(!this.connection.isActive())return this.connection.open()}addSubProtocol(t){this.subprotocols=[...this.subprotocols,t];}};function Z(r){if(typeof r=="function"&&(r=r()),r&&!/^wss?:/i.test(r)){let t=document.createElement("a");return t.href=r,t.href=t.href,t.protocol=t.protocol.replace("http","ws"),t.href}else return r}var tt=R;function et(r=kt("url")||w.default_mount_path){return new tt(r)}function kt(r){let t=document.head.querySelector(`meta[name='action-cable-${r}']`);if(t)return t.getAttribute("content")}var I=class extends index_js$5.ApolloLink{constructor(e){super();o(this,"cables");o(this,"channelName");o(this,"actionName");o(this,"connectionParams");this.cables={},this.channelName=e.channelName||"GraphqlChannel",this.actionName=e.actionName||"execute",this.connectionParams=e.connectionParams||{};}request(e,i){let s=p.get("session");return s?(this.cables[s]||(this.cables[s]=et(J+(s?`?token=${s}`:""))),new index_js$5.Observable(c=>{let T=Math.round(Date.now()+Math.random()*1e5).toString(16),it=this.actionName,st=typeof this.connectionParams=="function"?this.connectionParams(e):this.connectionParams,P=this.cables[s].subscriptions.create(Object.assign({},{channel:this.channelName,channelId:T},st),{connected:()=>{P.perform(it,{query:e.query?graphql.print(e.query):null,variables:e.variables,operationId:e.operationId,operationName:e.operationName});},received:a=>{var M,q;((M=a==null?void 0:a.result)!=null&&M.data||(q=a==null?void 0:a.result)!=null&&q.errors)&&c.next(a.result),a.more||c.complete();}});return Object.assign(P,{closed:!1})})):(console.warn("QuilttLink attempted to send an unauthenticated Subscription"),null)}},rt=I;var ot=class extends rt{constructor(){super({channelName:"GraphQLChannel"});}};var nr=new index_js$2.ApolloLink(()=>null);var pr=new index_js$2.ApolloLink((r,t)=>(r.setContext(({headers:e={}})=>({headers:g(b({},e),{"Quiltt-Client-Version":B})})),t(r)));
|
|
16
|
+
var nt=Object.defineProperty,ct=Object.defineProperties;var at=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var lt=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var A=(r,t,e)=>t in r?nt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,b=(r,t)=>{for(var e in t||(t={}))lt.call(t,e)&&A(r,e,t[e]);if(D)for(var e of D(t))pt.call(t,e)&&A(r,e,t[e]);return r},g=(r,t)=>ct(r,at(t));var o=(r,t,e)=>(A(r,typeof t!="symbol"?t+"":t,e),e);var v=class{constructor(){o(this,"observers",{});o(this,"isEnabled",()=>{try{return localStorage.setItem("quiltt.ping","pong"),localStorage.removeItem("quiltt.ping"),!0}catch(t){return !1}});o(this,"isDisabled",()=>!this.isEnabled());o(this,"get",t=>{if(!(typeof window=="undefined"||window.expo))try{let e=window.localStorage.getItem(`quiltt.${t}`);return e&&JSON.parse(e)}catch(e){console.warn(`localStorage Error: "quiltt.${t}"`,e);return}});o(this,"set",(t,e)=>{if(!(typeof window=="undefined"||window.expo))try{e?window.localStorage.setItem(`quiltt.${t}`,JSON.stringify(e)):window.localStorage.removeItem(`quiltt.${t}`);}catch(i){console.warn(`localStorage Error: "quiltt.${t}"`,i);}});o(this,"remove",t=>{try{window.localStorage.removeItem(`quiltt.${t}`);}catch(e){console.warn(`localStorage Error: "quiltt.${t}">`,e);}});o(this,"subscribe",(t,e)=>{this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e);});o(this,"unsubscribe",(t,e)=>{var i;this.observers[t]=(i=this.observers[t])==null?void 0:i.filter(s=>s!==e);});o(this,"handleStorageEvent",t=>{if(t.key&&t.key.includes("quiltt.")){let e=t.newValue?JSON.parse(t.newValue):null;this.observers[t.key]&&this.observers[t.key].forEach(i=>i(e));}else Object.entries(this.observers).forEach(([e,i])=>{i.forEach(s=>s(this.get(e)));});});typeof window!="undefined"&&!(window!=null&&window.expo)&&window.addEventListener("storage",this.handleStorageEvent.bind(this));}};var u=class{constructor(t){o(this,"state");o(this,"observers",[]);o(this,"get",()=>this.state);o(this,"set",t=>{this.state!==t&&(this.state=t,this.observers.forEach(e=>e(t)));});o(this,"subscribe",t=>{this.observers.push(t);});o(this,"unsubscribe",t=>{this.observers=this.observers.filter(e=>e!==t);});this.state=t;}};var S=class{constructor(){o(this,"observables",{});o(this,"get",t=>{if(this.observables[t])return this.observables[t].get()});o(this,"set",(t,e)=>{this.observables[t]?this.observables[t].set(e):this.observables[t]=new u(e);});o(this,"subscribe",(t,e)=>{this.observables[t]||(this.observables[t]=new u),this.observables[t].subscribe(e);});o(this,"unsubscribe",(t,e)=>{this.observables[t]&&this.observables[t].unsubscribe(e);});}};var C=class{constructor(){o(this,"memoryStore",new S);o(this,"localStore",new v);o(this,"observers",{});o(this,"monitors",new Set);o(this,"get",t=>{this.monitorLocalStorageChanges(t);let e=this.memoryStore.get(t);return e===void 0&&(e=this.localStore.get(t)),e});o(this,"set",(t,e)=>{var i;this.monitorLocalStorageChanges(t),this.localStore.set(t,e),this.memoryStore.set(t,e),(i=this.observers[t])==null||i.forEach(s=>s(e));});o(this,"subscribe",(t,e)=>{this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e);});o(this,"unsubscribe",(t,e)=>{var i;this.observers[t]=(i=this.observers[t])==null?void 0:i.filter(s=>s!==e);});o(this,"monitorLocalStorageChanges",t=>{this.monitors.has(t)||(this.monitors.add(t),this.localStore.subscribe(t,e=>{var c;let i=this.memoryStore.get(t),s=e instanceof Function?e(i):e;this.memoryStore.set(t,s),(c=this.observers[t])==null||c.forEach(T=>T(s));}));});}},p=new C;var j=class extends index_js$2.ApolloLink{request(t,e){let i=p.get("session");return i?(t.setContext(({headers:s={}})=>({headers:g(b({},s),{authorization:`Bearer ${i}`})})),e(t)):(console.warn("QuilttLink attempted to send an unauthenticated Query"),null)}};var G="@quiltt/core",W="3.3.3";var ht=(()=>{try{return process.env.QUILTT_API_INSECURE}catch(r){return}})(),Q=(()=>{try{return process.env.QUILTT_API_DOMAIN}catch(r){return}})(),dt=(()=>{try{return !!process.env.QUILTT_DEBUG||process.env.NODE_ENV!=="production"}catch(r){return !1}})(),k=Q||"quiltt.io",H=`http${ht?"":"s"}`,mt=`ws${Q?"":"s"}`,U=dt,y=`${H}://api.${k}/v1/graphql`,J=`${mt}://api.${k}/websockets`,B=`${G}: v${W}`;var oe=new index_js.BatchHttpLink({uri:y,fetch:bt__default.default});var ce=index_js$1.onError(({graphQLErrors:r,networkError:t})=>{r&&r.forEach(({message:e,locations:i,path:s})=>{console.log(`[GraphQL error]: Message: ${e}, Location: ${i}, Path: ${s}`);}),t&&(t.statusCode===401?(console.warn("[Authentication error]:",t),p.set("session",null)):console.warn("[Network error]:",t));});var pe=new index_js$2.ApolloLink((r,t)=>t(r));var fe=new index_js$3.HttpLink({uri:y,fetch:bt__default.default});var ve=new index_js$4.RetryLink({attempts:{retryIf:(r,t)=>r.statusCode>=500}});var l={logger:typeof globalThis!="undefined"?globalThis.console:void 0,WebSocket:typeof globalThis!="undefined"?globalThis.WebSocket:void 0};var O=class{constructor(){o(this,"enabled",U);}log(...t){l.logger&&this.enabled&&(t.push(Date.now().toString()),l.logger.log("[ActionCable]",...t));}},wt=new O,n=wt;var h=()=>new Date().getTime(),x=r=>(h()-r)/1e3,d=class{constructor(t){this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=t,this.reconnectAttempts=0;}start(){this.isRunning()||(this.startedAt=h(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),n.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`));}stop(){this.isRunning()&&(this.stoppedAt=h(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),n.log("ConnectionMonitor stopped"));}isRunning(){return this.startedAt&&!this.stoppedAt}recordPing(){this.pingedAt=h();}recordConnect(){this.reconnectAttempts=0,this.recordPing(),delete this.disconnectedAt,n.log("ConnectionMonitor recorded connect");}recordDisconnect(){this.disconnectedAt=h(),n.log("ConnectionMonitor recorded disconnect");}startPolling(){this.stopPolling(),this.poll();}stopPolling(){clearTimeout(this.pollTimeout);}poll(){this.pollTimeout=setTimeout(()=>{this.reconnectIfStale(),this.poll();},this.getPollInterval());}getPollInterval(){let{staleThreshold:t,reconnectionBackoffRate:e}=this.constructor,i=Math.pow(1+e,Math.min(this.reconnectAttempts,10)),c=(this.reconnectAttempts===0?1:e)*Math.random();return t*1e3*i*(1+c)}reconnectIfStale(){this.connectionIsStale()&&(n.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${x(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`),this.reconnectAttempts++,this.disconnectedRecently()?n.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${x(this.disconnectedAt)} s`):(n.log("ConnectionMonitor reopening"),this.connection.reopen()));}get refreshedAt(){return this.pingedAt?this.pingedAt:this.startedAt}connectionIsStale(){return x(this.refreshedAt)>this.constructor.staleThreshold}disconnectedRecently(){return this.disconnectedAt&&x(this.disconnectedAt)<this.constructor.staleThreshold}visibilityDidChange(){document.visibilityState==="visible"&&setTimeout(()=>{(this.connectionIsStale()||!this.connection.isOpen())&&(n.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`),this.connection.reopen());},200);}};d.staleThreshold=6;d.reconnectionBackoffRate=.15;var F=d;var Tt={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},disconnect_reasons:{unauthorized:"unauthorized",invalid_request:"invalid_request",server_restart:"server_restart",remote:"remote"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]},w=Tt;var{message_types:m,protocols:L}=w,At=L.slice(0,L.length-1),V=[].indexOf,f=class{constructor(t){this.open=this.open.bind(this),this.consumer=t,this.subscriptions=this.consumer.subscriptions,this.monitor=new F(this),this.disconnected=!0;}send(t){return this.isOpen()?(this.webSocket.send(JSON.stringify(t)),!0):!1}open(){if(this.isActive())return n.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`),!1;{let t=[...L,...this.consumer.subprotocols||[]];return n.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${t}`),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new l.WebSocket(this.consumer.url,t),this.installEventHandlers(),this.monitor.start(),!0}}close({allowReconnect:t}={allowReconnect:!0}){if(t||this.monitor.stop(),this.isOpen())return this.webSocket.close()}reopen(){if(n.log(`Reopening WebSocket, current state is ${this.getState()}`),this.isActive())try{return this.close()}catch(t){n.log("Failed to reopen WebSocket",t);}finally{n.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`),setTimeout(this.open,this.constructor.reopenDelay);}else return this.open()}getProtocol(){if(this.webSocket)return this.webSocket.protocol}isOpen(){return this.isState("open")}isActive(){return this.isState("open","connecting")}triedToReconnect(){return this.monitor.reconnectAttempts>0}isProtocolSupported(){return V.call(At,this.getProtocol())>=0}isState(...t){return V.call(t,this.getState())>=0}getState(){if(this.webSocket){for(let t in l.WebSocket)if(l.WebSocket[t]===this.webSocket.readyState)return t.toLowerCase()}return null}installEventHandlers(){for(let t in this.events){let e=this.events[t].bind(this);this.webSocket[`on${t}`]=e;}}uninstallEventHandlers(){for(let t in this.events)this.webSocket[`on${t}`]=function(){};}};f.reopenDelay=500;f.prototype.events={message(r){if(!this.isProtocolSupported())return;let{identifier:t,message:e,reason:i,reconnect:s,type:c}=JSON.parse(r.data);switch(c){case m.welcome:return this.triedToReconnect()&&(this.reconnectAttempted=!0),this.monitor.recordConnect(),this.subscriptions.reload();case m.disconnect:return n.log(`Disconnecting. Reason: ${i}`),this.close({allowReconnect:s});case m.ping:return this.monitor.recordPing();case m.confirmation:return this.subscriptions.confirmSubscription(t),this.reconnectAttempted?(this.reconnectAttempted=!1,this.subscriptions.notify(t,"connected",{reconnected:!0})):this.subscriptions.notify(t,"connected",{reconnected:!1});case m.rejection:return this.subscriptions.reject(t);default:return this.subscriptions.notify(t,"received",e)}},open(){if(n.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`),this.disconnected=!1,!this.isProtocolSupported())return n.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close(r){if(n.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error(){n.log("WebSocket onerror event");}};var z=f;var Ct=function(r,t){if(t!==null)for(let e in t){let i=t[e];r[e]=i;}return r},$=class{constructor(t,e={},i){o(this,"consumer");o(this,"identifier");this.consumer=t,this.identifier=JSON.stringify(e),Ct(this,i);}perform(t,e={}){return e.action=t,this.send(e)}send(t){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(t)})}unsubscribe(){return this.consumer.subscriptions.remove(this)}},K=$;var N=class{constructor(t){o(this,"subscriptions");o(this,"pendingSubscriptions");o(this,"retryTimeout");this.subscriptions=t,this.pendingSubscriptions=[];}guarantee(t){this.pendingSubscriptions.indexOf(t)==-1?(n.log(`SubscriptionGuarantor guaranteeing ${t.identifier}`),this.pendingSubscriptions.push(t)):n.log(`SubscriptionGuarantor already guaranteeing ${t.identifier}`),this.startGuaranteeing();}forget(t){n.log(`SubscriptionGuarantor forgetting ${t.identifier}`),this.pendingSubscriptions=this.pendingSubscriptions.filter(e=>e!==t);}startGuaranteeing(){this.stopGuaranteeing(),this.retrySubscribing();}stopGuaranteeing(){clearTimeout(this.retryTimeout);}retrySubscribing(){this.retryTimeout=setTimeout(()=>{this.subscriptions&&typeof this.subscriptions.subscribe=="function"&&this.pendingSubscriptions.map(t=>{n.log(`SubscriptionGuarantor resubscribing ${t.identifier}`),this.subscriptions.subscribe(t);});},500);}},X=N;var E=class{constructor(t){o(this,"consumer");o(this,"guarantor");o(this,"subscriptions");this.consumer=t,this.guarantor=new X(this),this.subscriptions=[];}create(t,e){let i=t,s=typeof i=="object"?i:{channel:i},c=new K(this.consumer,s,e);return this.add(c)}add(t){return this.subscriptions.push(t),this.consumer.ensureActiveConnection(),this.notify(t,"initialized"),this.subscribe(t),t}remove(t){return this.forget(t),this.findAll(t.identifier).length||this.sendCommand(t,"unsubscribe"),t}reject(t){return this.findAll(t).map(e=>(this.forget(e),this.notify(e,"rejected"),e))}forget(t){return this.guarantor.forget(t),this.subscriptions=this.subscriptions.filter(e=>e!==t),t}findAll(t){return this.subscriptions.filter(e=>e.identifier===t)}reload(){return this.subscriptions.map(t=>this.subscribe(t))}notifyAll(t,...e){return this.subscriptions.map(i=>this.notify(i,t,...e))}notify(t,e,...i){let s;return typeof t=="string"?s=this.findAll(t):s=[t],s.map(c=>typeof c[e]=="function"?c[e](...i):void 0)}subscribe(t){this.sendCommand(t,"subscribe")&&this.guarantor.guarantee(t);}confirmSubscription(t){n.log(`Subscription confirmed ${t}`),this.findAll(t).map(e=>this.guarantor.forget(e));}sendCommand(t,e){let{identifier:i}=t;return this.consumer.send({command:e,identifier:i})}},Y=E;var R=class{constructor(t){o(this,"_url");o(this,"subscriptions");o(this,"connection");o(this,"subprotocols");this._url=t,this.subscriptions=new Y(this),this.connection=new z(this),this.subprotocols=[];}get url(){return Z(this._url)}send(t){return this.connection.send(t)}connect(){return this.connection.open()}disconnect(){return this.connection.close({allowReconnect:!1})}ensureActiveConnection(){if(!this.connection.isActive())return this.connection.open()}addSubProtocol(t){this.subprotocols=[...this.subprotocols,t];}};function Z(r){if(typeof r=="function"&&(r=r()),r&&!/^wss?:/i.test(r)){let t=document.createElement("a");return t.href=r,t.href=t.href,t.protocol=t.protocol.replace("http","ws"),t.href}else return r}var tt=R;function et(r=kt("url")||w.default_mount_path){return new tt(r)}function kt(r){let t=document.head.querySelector(`meta[name='action-cable-${r}']`);if(t)return t.getAttribute("content")}var I=class extends index_js$5.ApolloLink{constructor(e){super();o(this,"cables");o(this,"channelName");o(this,"actionName");o(this,"connectionParams");this.cables={},this.channelName=e.channelName||"GraphqlChannel",this.actionName=e.actionName||"execute",this.connectionParams=e.connectionParams||{};}request(e,i){let s=p.get("session");return s?(this.cables[s]||(this.cables[s]=et(J+(s?`?token=${s}`:""))),new index_js$5.Observable(c=>{let T=Math.round(Date.now()+Math.random()*1e5).toString(16),it=this.actionName,st=typeof this.connectionParams=="function"?this.connectionParams(e):this.connectionParams,P=this.cables[s].subscriptions.create(Object.assign({},{channel:this.channelName,channelId:T},st),{connected:()=>{P.perform(it,{query:e.query?graphql.print(e.query):null,variables:e.variables,operationId:e.operationId,operationName:e.operationName});},received:a=>{var M,q;((M=a==null?void 0:a.result)!=null&&M.data||(q=a==null?void 0:a.result)!=null&&q.errors)&&c.next(a.result),a.more||c.complete();}});return Object.assign(P,{closed:!1})})):(console.warn("QuilttLink attempted to send an unauthenticated Subscription"),null)}},rt=I;var ot=class extends rt{constructor(){super({channelName:"GraphQLChannel"});}};var nr=new index_js$2.ApolloLink(()=>null);var pr=new index_js$2.ApolloLink((r,t)=>(r.setContext(({headers:e={}})=>({headers:g(b({},e),{"Quiltt-Client-Version":B})})),t(r)));
|
|
17
17
|
|
|
18
18
|
exports.AuthLink = j;
|
|
19
19
|
exports.BatchHttpLink = oe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/graphql/links/AuthLink.ts","../../../../src/Storage/Local.ts","../../../../src/Observable.ts","../../../../src/Storage/Memory.ts","../../../../src/Storage/index.ts","../../../../src/api/graphql/links/BatchHttpLink.ts","../../../../package.json","../../../../src/configuration.ts","../../../../src/api/graphql/links/ErrorLink.ts","../../../../src/api/graphql/links/ForwardableLink.ts","../../../../src/api/graphql/links/HttpLink.ts","../../../../src/api/graphql/links/RetryLink.ts","../../../../src/api/graphql/links/ActionCableLink.ts","../../../../src/api/graphql/links/actioncable/adapters.ts","../../../../src/api/graphql/links/actioncable/logger.ts","../../../../src/api/graphql/links/actioncable/connection_monitor.ts","../../../../src/api/graphql/links/actioncable/internal.ts","../../../../src/api/graphql/links/actioncable/connection.ts","../../../../src/api/graphql/links/actioncable/subscription.ts","../../../../src/api/graphql/links/actioncable/subscription_guarantor.ts","../../../../src/api/graphql/links/actioncable/subscriptions.ts","../../../../src/api/graphql/links/actioncable/consumer.ts","../../../../src/api/graphql/links/actioncable/index.ts","../../../../src/api/graphql/links/SubscriptionLink.ts","../../../../src/api/graphql/links/TerminatingLink.ts","../../../../src/api/graphql/links/VersionLink.ts"],"names":["ApolloLink","LocalStorage","__publicField","error","key","state","observer","_a","update","event","newState","observers","Observable","initalState","nextState","MemoryStorage","Storage","prevValue","GlobalStorage","AuthLink","operation","forward","token","headers","__spreadProps","__spreadValues","ApolloHttpLink","fetch","name","version","QUILTT_API_INSECURE","e","QUILTT_API_DOMAIN","QUILTT_DEBUG","domain","protocolHttp","protocolWebsockets","debugging","endpointAuth","endpointGraphQL","endpointWebsockets","BatchHttpLink","onError","ErrorLink","graphQLErrors","networkError","message","locations","path","ForwardableLink","HttpLink","ApolloRetryLink","RetryLink","_operation","print","adapters_default","Logger","messages","logger","logger_default","now","secondsSince","time","ConnectionMonitor","connection","staleThreshold","reconnectionBackoffRate","backoff","jitter","connection_monitor_default","INTERNAL","internal_default","message_types","protocols","supportedProtocols","indexOf","Connection","consumer","data","socketProtocols","allowReconnect","states","eventName","handler","identifier","reason","reconnect","type","_event","connection_default","extend","object","properties","value","Subscription","params","mixin","action","subscription_default","SubscriptionGuarantor","subscriptions","subscription","s","subscription_guarantor_default","Subscriptions","channelName","channel","callbackName","args","command","subscriptions_default","Consumer","url","createWebSocketURL","subprotocol","a","consumer_default","createConsumer","getConfig","element","ActionCableLink","options","_next","channelId","actionName","connectionParams","payload","_b","ActionCableLink_default","SubscriptionLink","TerminatingLink","VersionLink"],"mappings":"2eACA,OAAS,cAAAA,OAAkB,0BCQpB,IAAMC,EAAN,KAAsB,CAG3B,aAAc,CAFdC,EAAA,KAAQ,YAA8C,CAAC,GAQvDA,EAAA,iBAAY,IAAe,CACzB,GAAI,CACF,oBAAa,QAAQ,cAAe,MAAM,EAC1C,aAAa,WAAW,aAAa,EAC9B,EACT,OAASC,EAAP,CACA,MAAO,EACT,CACF,GAEAD,EAAA,kBAAa,IAAe,CAAC,KAAK,UAAU,GAE5CA,EAA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AAK,YACd,UAAWqG,CACb,EACAE,EACF,EACA,CACE,UAAW,IAAM,CACfnB,EAAQ,QAAQkB,GAAY,CAC1B,MAAOxG,EAAU,MAAQkC,GAAMlC,EAAU,KAAK,EAAI,KAClD,UAAWA,EAAU,UAErB,YAAcA,EAAuC,YACrD,cAAeA,EAAU,aAC3B,CAAC,CACH,EAEA,SAAW0G,GAAkD,CA3EvE,IAAAvH,EAAAwH,IA4EgBxH,EAAAuH,GAAA,YAAAA,EAAS,SAAT,MAAAvH,EAAiB,OAAQwH,EAAAD,GAAA,YAAAA,EAAS,SAAT,MAAAC,EAAiB,SAC5CzH,EAAS,KAAKwH,EAAQ,MAAM,EAGzBA,EAAQ,MACXxH,EAAS,SAAS,CAEtB,CACF,CACF,EAEA,OAAO,OAAO,OAAOoG,EAAS,CAAE,OAAQ,EAAM,CAAC,CACjD,CAAC,IAjDC,QAAQ,KAAK,8DAA8D,EACpE,KAiDX,CACF,EAEOsB,GAAQR,EWxFR,IAAMS,GAAN,cAA+BD,EAAgB,CACpD,aAAc,CACZ,MAAM,CAAE,YAAa,gBAAiB,CAAC,CACzC,CACF,ECRA,OAAS,cAAAhI,OAAkB,0BAEpB,IAAMkI,GAAkB,IAAIlI,GAAW,IAAM,IAAI,ECFxD,OAAS,cAAAA,OAAkB,0BAIpB,IAAMmI,GAAc,IAAInI,GAAW,CAACoB,EAAWC,KACpDD,EAAU,WAAW,CAAC,CAAE,QAAAG,EAAU,CAAC,CAAE,KAAO,CAC1C,QAASC,EAAAC,EAAA,GACJF,GADI,CAEP,wBAAyBM,CAC3B,EACF,EAAE,EACKR,EAAQD,CAAS,EACzB","sourcesContent":["import type { FetchResult, NextLink, Observable, Operation } from '@apollo/client/index.js'\nimport { ApolloLink } from '@apollo/client/index.js'\n\nimport { GlobalStorage } from '@/Storage'\n\n/**\n * unauthorizedCallback only triggers in the event the token is present, and\n * returns the token; This allows sessions to be forgotten without race conditions\n * causing null sessions to kill valid sessions, or invalid sessions for killing\n * valid sessions during rotation and networking weirdness.\n */\nexport class AuthLink extends ApolloLink {\n request(operation: Operation, forward: NextLink): Observable<FetchResult> | null {\n const token = GlobalStorage.get('session')\n\n if (!token) {\n console.warn(`QuilttLink attempted to send an unauthenticated Query`)\n return null\n }\n\n operation.setContext(({ headers = {} }) => ({\n headers: {\n ...headers,\n authorization: `Bearer ${token}`,\n },\n }))\n\n return forward(operation)\n }\n}\n\nexport default AuthLink\n","import type { Maybe } from '../types'\nimport type { Observer } from '../Observable'\n\n/**\n * An error and type safe wrapper for localStorage.\n * It allows you to subscribe to changes;\n * but localStorage changes only fire with another\n * window updates the record.\n */\nexport class LocalStorage<T> {\n private observers: { [key: string]: Observer<T>[] } = {}\n\n constructor() {\n if (typeof window !== 'undefined' && !window?.expo) {\n window.addEventListener('storage', this.handleStorageEvent.bind(this))\n }\n }\n\n isEnabled = (): boolean => {\n try {\n localStorage.setItem(`quiltt.ping`, 'pong')\n localStorage.removeItem(`quiltt.ping`)\n return true\n } catch (error) {\n return false\n }\n }\n\n isDisabled = (): boolean => !this.isEnabled()\n\n get = (key: string): Maybe<T> | undefined => {\n if (typeof window === 'undefined' || !!window.expo) return undefined\n\n try {\n const state = window.localStorage.getItem(`quiltt.${key}`)\n return state ? JSON.parse(state) : state\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\"`, error)\n return undefined\n }\n }\n\n set = (key: string, state: Maybe<T> | undefined): void => {\n if (typeof window === 'undefined' || !!window.expo) return\n\n try {\n if (state) {\n window.localStorage.setItem(`quiltt.${key}`, JSON.stringify(state))\n } else {\n window.localStorage.removeItem(`quiltt.${key}`)\n }\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\"`, error)\n }\n }\n\n remove = (key: string) => {\n try {\n window.localStorage.removeItem(`quiltt.${key}`)\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\">`, error)\n }\n }\n\n subscribe = (key: string, observer: Observer<T>) => {\n if (!this.observers[key]) this.observers[key] = []\n\n this.observers[key].push(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>) => {\n this.observers[key] = this.observers[key]?.filter((update) => update !== observer)\n }\n\n // if there is a key, then trigger the related updates. If there is not key\n // it means that a record has been removed and everything needs to be rechecked.\n private handleStorageEvent = (event: StorageEvent) => {\n if (event.key && event.key.includes('quiltt.')) {\n const newState = event.newValue ? JSON.parse(event.newValue) : null\n\n if (this.observers[event.key]) {\n this.observers[event.key].forEach((update) => update(newState))\n }\n } else {\n Object.entries(this.observers).forEach(([key, observers]) => {\n observers.forEach((update) => update(this.get(key)))\n })\n }\n }\n}\n\nexport default LocalStorage\n","import type { Dispatch, SetStateAction } from 'react'\nimport type { Maybe } from './types'\n\nexport type Observer<T> = Dispatch<SetStateAction<Maybe<T> | undefined>>\n\n/**\n * This is designed to support singletons to share the memory states across all\n * instance of hooks to ensure that updates only process once, by storing a value\n * then notifying all subscribers when it's updated.\n */\nexport class Observable<T> {\n private state?: Maybe<T>\n private observers: Observer<T>[] = []\n\n constructor(initalState?: Maybe<T>) {\n this.state = initalState\n }\n\n get = () => {\n return this.state\n }\n\n set = (nextState: Maybe<T> | undefined) => {\n if (this.state === nextState) return\n\n this.state = nextState\n this.observers.forEach((update) => update(nextState))\n }\n\n subscribe = (observer: Observer<T>) => {\n this.observers.push(observer)\n }\n\n unsubscribe = (observer: Observer<T>) => {\n this.observers = this.observers.filter((update) => update !== observer)\n }\n}\n\nexport default Observable\n","import type { Maybe } from '../types'\n\nimport { Observable } from '../Observable'\nimport type { Observer } from '../Observable'\n\n/**\n * This is designed to support effectively an in memory key value store singleton,\n * similar to localstorage, but allows you to subscribe to changes within the current\n * window.\n */\nexport class MemoryStorage<T> {\n private observables: { [key: string]: Observable<T> } = {}\n\n get = (key: string) => {\n if (this.observables[key]) {\n return this.observables[key].get()\n } else {\n return undefined\n }\n }\n\n set = (key: string, state: Maybe<T> | undefined): void => {\n if (!this.observables[key]) {\n this.observables[key] = new Observable<T>(state)\n } else {\n this.observables[key].set(state)\n }\n }\n\n subscribe = (key: string, observer: Observer<T>): void => {\n if (!this.observables[key]) this.observables[key] = new Observable<T>()\n\n this.observables[key].subscribe(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>): void => {\n if (this.observables[key]) {\n this.observables[key].unsubscribe(observer)\n }\n }\n}\n\nexport default MemoryStorage\n","import type { Maybe } from '../types'\n\nimport type { Observer } from '../Observable'\nimport { LocalStorage } from './Local'\nimport { MemoryStorage } from './Memory'\n\n/**\n * This is wraps both local and memory storage to create a unified interface, that\n * allows you to subscribe to all either changes made within this window, or changes\n * made by other windows.\n */\nexport class Storage<T> {\n private memoryStore = new MemoryStorage<T>()\n private localStore = new LocalStorage<T>()\n private observers: { [key: string]: Observer<T>[] } = {}\n private monitors: Set<string> = new Set()\n\n /**\n * Checks memoryStorage before falling back to localStorage.\n */\n get = (key: string): Maybe<T> | undefined => {\n this.monitorLocalStorageChanges(key)\n\n let state = this.memoryStore.get(key)\n\n if (state === undefined) {\n state = this.localStore.get(key)\n }\n\n return state\n }\n\n /**\n * We don't trust localStorage to always be present, so we can't rely on it to\n * update memoryStorage based on emitted changes. So we manage our own\n * emitting while using the underlying events to keep memoryStore in sync with\n * localStore.\n */\n set = (key: string, newState: Maybe<T> | undefined) => {\n this.monitorLocalStorageChanges(key)\n\n this.localStore.set(key, newState)\n this.memoryStore.set(key, newState)\n\n this.observers[key]?.forEach((update) => update(newState))\n }\n\n /**\n * Allows you to subscribe to all changes in memory or local storage as a\n * single event.\n */\n subscribe = (key: string, observer: Observer<T>) => {\n if (!this.observers[key]) this.observers[key] = []\n\n this.observers[key].push(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>) => {\n this.observers[key] = this.observers[key]?.filter((update) => update !== observer)\n }\n\n /**\n * Sets bubble the changes down the stack starting with memoryStore and then\n * localStore. memoryStore will emit changes to everything within the current\n * window context, while localStore will emit changes to every other window\n * context.\n *\n * To ensure that the other windows are updated correctly, changes to localStore\n * need to be subscribed and updated to in memory store, which then may be subscribed\n * to outside of storage.\n */\n private monitorLocalStorageChanges = (key: string) => {\n if (this.monitors.has(key)) return\n this.monitors.add(key)\n\n this.localStore.subscribe(key, (nextState) => {\n const prevValue = this.memoryStore.get(key)\n const newState = nextState instanceof Function ? nextState(prevValue) : nextState\n\n this.memoryStore.set(key, newState)\n this.observers[key]?.forEach((update) => update(newState))\n })\n }\n}\n\nexport * from './Local'\nexport * from './Memory'\n\n/**\n * This is an singleton to share the memory states across all instances; This\n * basically acts like shared memory when there is no localStorage.\n */\nexport const GlobalStorage = new Storage<any>()\n","import { BatchHttpLink as ApolloHttpLink } from '@apollo/client/link/batch-http/index.js'\n\nimport fetch from 'cross-fetch'\n\nimport { endpointGraphQL } from '../../../configuration'\n\nexport const BatchHttpLink = new ApolloHttpLink({\n uri: endpointGraphQL,\n fetch,\n})\n\nexport default BatchHttpLink\n","{\n \"name\": \"@quiltt/core\",\n \"version\": \"3.3.1\",\n \"description\": \"Javascript API client and utilities for Quiltt\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/quiltt/quiltt-public.git\",\n \"directory\": \"ECMAScript/core\"\n },\n \"homepage\": \"https://github.com/quiltt/quiltt-public/tree/main/ECMAScript/core#readme\",\n \"keywords\": [\n \"quiltt\",\n \"typescript\"\n ],\n \"license\": \"MIT\",\n \"sideEffects\": [\n \"./src/Storage/Local.ts\",\n \"./src/api/graphql/links/SubscriptionLink.ts\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist/**\",\n \"src/**\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf .turbo dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"TIMING=1 eslint --ext .js,.jsx,.ts,.tsx src/ --fix\",\n \"typecheck\": \"tsc --project tsconfig.json --noEmit\"\n },\n \"dependencies\": {\n \"@apollo/client\": \"^3.7.16\",\n \"axios\": \"^1.4.0\",\n \"cross-fetch\": \"^3.1.8\",\n \"graphql\": \"^16.8.1\",\n \"graphql-ruby-client\": \"^1.11.8\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"4.1.1\",\n \"@types/node\": \"18.16.18\",\n \"@types/react\": \"18.2.7\",\n \"@typescript-eslint/eslint-plugin\": \"5.60.1\",\n \"@typescript-eslint/parser\": \"5.60.1\",\n \"eslint\": \"8.43.0\",\n \"eslint-config-prettier\": \"8.8.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"prettier\": \"2.8.8\",\n \"tsup\": \"6.7.0\",\n \"typescript\": \"5.1.3\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import { name as packageName, version as packageVersion } from '../package.json'\n\nconst QUILTT_API_INSECURE = (() => {\n try {\n return process.env.QUILTT_API_INSECURE\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_API_DOMAIN = (() => {\n try {\n return process.env.QUILTT_API_DOMAIN\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_DEBUG = (() => {\n try {\n return !!process.env.QUILTT_DEBUG || process.env.NODE_ENV !== 'production'\n } catch {\n return false\n }\n})()\n\nconst domain = QUILTT_API_DOMAIN || 'quiltt.io'\nconst protocolHttp = `http${QUILTT_API_INSECURE ? '' : 's'}`\nconst protocolWebsockets = `ws${QUILTT_API_DOMAIN ? '' : 's'}`\n\nexport const debugging = QUILTT_DEBUG\nexport const endpointAuth = `${protocolHttp}://auth.${domain}/v1/users/session`\nexport const endpointGraphQL = `${protocolHttp}://api.${domain}/v1/graphql`\nexport const endpointWebsockets = `${protocolWebsockets}://api.${domain}/websockets`\nexport const version = `${packageName}: v${packageVersion}`\n\nconst Config = {\n debugging,\n endpointAuth,\n endpointGraphQL,\n endpointWebsockets,\n version,\n}\n\nexport default Config\n","import { GlobalStorage } from '@/Storage'\n\nimport type { ServerError } from '@apollo/client/index.js'\nimport { onError } from '@apollo/client/link/error/index.js'\n\nexport const ErrorLink = onError(({ graphQLErrors, networkError }) => {\n if (graphQLErrors) {\n graphQLErrors.forEach(({ message, locations, path }) => {\n console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`)\n })\n }\n\n if (networkError) {\n if ((networkError as ServerError).statusCode === 401) {\n console.warn('[Authentication error]:', networkError)\n GlobalStorage.set('session', null)\n } else {\n console.warn('[Network error]:', networkError)\n }\n }\n})\n\nexport default ErrorLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nexport const ForwardableLink = new ApolloLink((operation, forward) => forward(operation))\n\nexport default ForwardableLink\n","import { HttpLink as ApolloHttpLink } from '@apollo/client/link/http/index.js'\n\nimport fetch from 'cross-fetch'\n\nimport { endpointGraphQL } from '../../../configuration'\n\nexport const HttpLink = new ApolloHttpLink({\n uri: endpointGraphQL,\n fetch,\n})\n\nexport default HttpLink\n","import type { ServerError } from '@apollo/client/index.js'\nimport { RetryLink as ApolloRetryLink } from '@apollo/client/link/retry/index.js'\n\nexport const RetryLink = new ApolloRetryLink({\n attempts: {\n retryIf: (error: ServerError, _operation) => error.statusCode >= 500,\n },\n})\n\nexport default RetryLink\n","import { GlobalStorage } from '@/Storage'\nimport type { FetchResult, NextLink, Operation } from '@apollo/client/core/index.js'\nimport { ApolloLink, Observable } from '@apollo/client/core/index.js'\nimport { print } from 'graphql'\nimport { endpointWebsockets } from '../../../configuration'\nimport type { Consumer } from './actioncable'\nimport { createConsumer } from './actioncable'\n\ntype RequestResult = FetchResult<\n { [key: string]: unknown },\n Record<string, unknown>,\n Record<string, unknown>\n>\ntype ConnectionParams = object | ((operation: Operation) => object)\n\nclass ActionCableLink extends ApolloLink {\n cables: { [id: string]: Consumer }\n channelName: string\n actionName: string\n connectionParams: ConnectionParams\n\n constructor(options: {\n channelName?: string\n actionName?: string\n connectionParams?: ConnectionParams\n }) {\n super()\n this.cables = {}\n this.channelName = options.channelName || 'GraphqlChannel'\n this.actionName = options.actionName || 'execute'\n this.connectionParams = options.connectionParams || {}\n }\n\n // Interestingly, this link does _not_ call through to `next` because\n // instead, it sends the request to ActionCable.\n request(operation: Operation, _next: NextLink): Observable<RequestResult> | null {\n const token = GlobalStorage.get('session')\n\n if (!token) {\n console.warn(`QuilttLink attempted to send an unauthenticated Subscription`)\n return null\n }\n\n if (!this.cables[token]) {\n this.cables[token] = createConsumer(endpointWebsockets + (token ? `?token=${token}` : ''))\n }\n\n return new Observable((observer) => {\n const channelId = Math.round(Date.now() + Math.random() * 100000).toString(16)\n const actionName = this.actionName\n const connectionParams =\n typeof this.connectionParams === 'function'\n ? this.connectionParams(operation)\n : this.connectionParams\n\n const channel = this.cables[token].subscriptions.create(\n Object.assign(\n {},\n {\n channel: this.channelName,\n channelId: channelId,\n },\n connectionParams\n ),\n {\n connected: () => {\n channel.perform(actionName, {\n query: operation.query ? print(operation.query) : null,\n variables: operation.variables,\n // This is added for persisted operation support:\n operationId: (operation as { operationId?: string }).operationId,\n operationName: operation.operationName,\n })\n },\n\n received: (payload: { result: RequestResult; more: any }) => {\n if (payload?.result?.data || payload?.result?.errors) {\n observer.next(payload.result)\n }\n\n if (!payload.more) {\n observer.complete()\n }\n },\n }\n )\n // Make the ActionCable subscription behave like an Apollo subscription\n return Object.assign(channel, { closed: false })\n })\n }\n}\n\nexport default ActionCableLink\n","export default {\n logger: typeof globalThis !== 'undefined' ? globalThis.console : undefined,\n WebSocket: typeof globalThis !== 'undefined' ? globalThis.WebSocket : undefined,\n}\n","import { debugging } from '../../../../configuration'\nimport adapters from './adapters'\n\nclass Logger {\n enabled = debugging\n\n log(...messages: Array<string>) {\n if (adapters.logger && this.enabled) {\n messages.push(Date.now().toString())\n adapters.logger.log('[ActionCable]', ...messages)\n }\n }\n}\n\nexport const logger = new Logger()\nexport default logger\n","// @ts-nocheck\nimport logger from './logger'\n\n// Responsible for ensuring the cable connection is in good health by validating the heartbeat pings sent from the server, and attempting\n// revival reconnections if things go astray. Internal class, not intended for direct user manipulation.\n\nconst now = () => new Date().getTime()\n\nconst secondsSince = (time) => (now() - time) / 1000\n\nclass ConnectionMonitor {\n constructor(connection) {\n this.visibilityDidChange = this.visibilityDidChange.bind(this)\n this.connection = connection\n this.reconnectAttempts = 0\n }\n\n start() {\n if (!this.isRunning()) {\n this.startedAt = now()\n delete this.stoppedAt\n this.startPolling()\n addEventListener('visibilitychange', this.visibilityDidChange)\n logger.log(\n `ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`\n )\n }\n }\n\n stop() {\n if (this.isRunning()) {\n this.stoppedAt = now()\n this.stopPolling()\n removeEventListener('visibilitychange', this.visibilityDidChange)\n logger.log('ConnectionMonitor stopped')\n }\n }\n\n isRunning() {\n return this.startedAt && !this.stoppedAt\n }\n\n recordPing() {\n this.pingedAt = now()\n }\n\n recordConnect() {\n this.reconnectAttempts = 0\n this.recordPing()\n delete this.disconnectedAt\n logger.log('ConnectionMonitor recorded connect')\n }\n\n recordDisconnect() {\n this.disconnectedAt = now()\n logger.log('ConnectionMonitor recorded disconnect')\n }\n\n // Private\n\n startPolling() {\n this.stopPolling()\n this.poll()\n }\n\n stopPolling() {\n clearTimeout(this.pollTimeout)\n }\n\n poll() {\n this.pollTimeout = setTimeout(() => {\n this.reconnectIfStale()\n this.poll()\n }, this.getPollInterval())\n }\n\n getPollInterval() {\n const { staleThreshold, reconnectionBackoffRate } = this.constructor\n const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10))\n const jitterMax = this.reconnectAttempts === 0 ? 1.0 : reconnectionBackoffRate\n const jitter = jitterMax * Math.random()\n return staleThreshold * 1000 * backoff * (1 + jitter)\n }\n\n reconnectIfStale() {\n if (this.connectionIsStale()) {\n logger.log(\n `ConnectionMonitor detected stale connection. reconnectAttempts = ${\n this.reconnectAttempts\n }, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${\n this.constructor.staleThreshold\n } s`\n )\n this.reconnectAttempts++\n if (this.disconnectedRecently()) {\n logger.log(\n `ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(\n this.disconnectedAt\n )} s`\n )\n } else {\n logger.log('ConnectionMonitor reopening')\n this.connection.reopen()\n }\n }\n }\n\n get refreshedAt() {\n return this.pingedAt ? this.pingedAt : this.startedAt\n }\n\n connectionIsStale() {\n return secondsSince(this.refreshedAt) > this.constructor.staleThreshold\n }\n\n disconnectedRecently() {\n return (\n this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold\n )\n }\n\n visibilityDidChange() {\n if (document.visibilityState === 'visible') {\n setTimeout(() => {\n if (this.connectionIsStale() || !this.connection.isOpen()) {\n logger.log(\n `ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`\n )\n this.connection.reopen()\n }\n }, 200)\n }\n }\n}\n\nConnectionMonitor.staleThreshold = 6 // Server::Connections::BEAT_INTERVAL * 2 (missed two pings)\nConnectionMonitor.reconnectionBackoffRate = 0.15\n\nexport default ConnectionMonitor\n","const INTERNAL = {\n message_types: {\n welcome: 'welcome',\n disconnect: 'disconnect',\n ping: 'ping',\n confirmation: 'confirm_subscription',\n rejection: 'reject_subscription',\n },\n disconnect_reasons: {\n unauthorized: 'unauthorized',\n invalid_request: 'invalid_request',\n server_restart: 'server_restart',\n remote: 'remote',\n },\n default_mount_path: '/cable',\n protocols: ['actioncable-v1-json', 'actioncable-unsupported'],\n}\n\nexport default INTERNAL\n","// @ts-nocheck\nimport adapters from './adapters'\nimport ConnectionMonitor from './connection_monitor'\nimport INTERNAL from './internal'\nimport logger from './logger'\n\n// Encapsulate the cable connection held by the consumer. This is an internal class not intended for direct user manipulation.\n\nconst { message_types, protocols } = INTERNAL\nconst supportedProtocols = protocols.slice(0, protocols.length - 1)\n\nconst indexOf = [].indexOf\n\nclass Connection {\n constructor(consumer) {\n this.open = this.open.bind(this)\n this.consumer = consumer\n this.subscriptions = this.consumer.subscriptions\n this.monitor = new ConnectionMonitor(this)\n this.disconnected = true\n }\n\n send(data) {\n if (this.isOpen()) {\n this.webSocket.send(JSON.stringify(data))\n return true\n } else {\n return false\n }\n }\n\n open() {\n if (this.isActive()) {\n logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`)\n return false\n } else {\n const socketProtocols = [...protocols, ...(this.consumer.subprotocols || [])]\n logger.log(\n `Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`\n )\n if (this.webSocket) {\n this.uninstallEventHandlers()\n }\n this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols)\n this.installEventHandlers()\n this.monitor.start()\n return true\n }\n }\n\n close({ allowReconnect } = { allowReconnect: true }) {\n if (!allowReconnect) {\n this.monitor.stop()\n }\n // Avoid closing websockets in a \"connecting\" state due to Safari 15.1+ bug. See: https://github.com/rails/rails/issues/43835#issuecomment-1002288478\n if (this.isOpen()) {\n return this.webSocket.close()\n }\n }\n\n reopen() {\n logger.log(`Reopening WebSocket, current state is ${this.getState()}`)\n if (this.isActive()) {\n try {\n return this.close()\n } catch (error) {\n logger.log('Failed to reopen WebSocket', error)\n } finally {\n logger.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`)\n setTimeout(this.open, this.constructor.reopenDelay)\n }\n } else {\n return this.open()\n }\n }\n\n getProtocol() {\n if (this.webSocket) {\n return this.webSocket.protocol\n }\n }\n\n isOpen() {\n return this.isState('open')\n }\n\n isActive() {\n return this.isState('open', 'connecting')\n }\n\n triedToReconnect() {\n return this.monitor.reconnectAttempts > 0\n }\n\n // Private\n\n isProtocolSupported() {\n return indexOf.call(supportedProtocols, this.getProtocol()) >= 0\n }\n\n isState(...states) {\n return indexOf.call(states, this.getState()) >= 0\n }\n\n getState() {\n if (this.webSocket) {\n for (const state in adapters.WebSocket) {\n if (adapters.WebSocket[state] === this.webSocket.readyState) {\n return state.toLowerCase()\n }\n }\n }\n return null\n }\n\n installEventHandlers() {\n for (const eventName in this.events) {\n const handler = this.events[eventName].bind(this)\n this.webSocket[`on${eventName}`] = handler\n }\n }\n\n uninstallEventHandlers() {\n for (const eventName in this.events) {\n this.webSocket[`on${eventName}`] = function () {}\n }\n }\n}\n\nConnection.reopenDelay = 500\n\nConnection.prototype.events = {\n message(event) {\n if (!this.isProtocolSupported()) {\n return\n }\n const { identifier, message, reason, reconnect, type } = JSON.parse(event.data)\n switch (type) {\n case message_types.welcome:\n if (this.triedToReconnect()) {\n this.reconnectAttempted = true\n }\n this.monitor.recordConnect()\n return this.subscriptions.reload()\n case message_types.disconnect:\n logger.log(`Disconnecting. Reason: ${reason}`)\n return this.close({ allowReconnect: reconnect })\n case message_types.ping:\n return this.monitor.recordPing()\n case message_types.confirmation:\n this.subscriptions.confirmSubscription(identifier)\n if (this.reconnectAttempted) {\n this.reconnectAttempted = false\n return this.subscriptions.notify(identifier, 'connected', { reconnected: true })\n } else {\n return this.subscriptions.notify(identifier, 'connected', { reconnected: false })\n }\n case message_types.rejection:\n return this.subscriptions.reject(identifier)\n default:\n return this.subscriptions.notify(identifier, 'received', message)\n }\n },\n\n open() {\n logger.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`)\n this.disconnected = false\n if (!this.isProtocolSupported()) {\n logger.log('Protocol is unsupported. Stopping monitor and disconnecting.')\n return this.close({ allowReconnect: false })\n }\n },\n\n close(_event) {\n logger.log('WebSocket onclose event')\n if (this.disconnected) {\n return\n }\n this.disconnected = true\n this.monitor.recordDisconnect()\n return this.subscriptions.notifyAll('disconnected', {\n willAttemptReconnect: this.monitor.isRunning(),\n })\n },\n\n error() {\n logger.log('WebSocket onerror event')\n },\n}\n\nexport default Connection\n","import type { Consumer } from './consumer'\n\nexport type Data = { [id: string]: string | object | null | undefined }\n\nconst extend = function (object: Data, properties: Data) {\n if (properties !== null) {\n for (const key in properties) {\n const value = properties[key]\n object[key] = value\n }\n }\n return object\n}\n\nexport class Subscription {\n consumer: Consumer\n identifier: string\n\n constructor(consumer: Consumer, params: Data = {}, mixin: Data) {\n this.consumer = consumer\n this.identifier = JSON.stringify(params)\n extend(this as unknown as Data, mixin)\n }\n\n // Perform a channel action with the optional data passed as an attribute\n perform(action: string, data: Data = {}) {\n data.action = action\n return this.send(data)\n }\n\n send(data: object) {\n return this.consumer.send({\n command: 'message',\n identifier: this.identifier,\n data: JSON.stringify(data),\n })\n }\n\n unsubscribe() {\n return this.consumer.subscriptions.remove(this)\n }\n}\n\nexport default Subscription\n","import logger from './logger'\nimport type { Subscription } from './subscription'\nimport type { Subscriptions } from './subscriptions'\n\n// Responsible for ensuring channel subscribe command is confirmed, retrying until confirmation is received.\n// Internal class, not intended for direct user manipulation.\n\nclass SubscriptionGuarantor {\n subscriptions: Subscriptions\n pendingSubscriptions: Array<Subscription>\n retryTimeout: ReturnType<typeof setTimeout> | undefined\n\n constructor(subscriptions: Subscriptions) {\n this.subscriptions = subscriptions\n this.pendingSubscriptions = []\n }\n\n guarantee(subscription: Subscription) {\n if (this.pendingSubscriptions.indexOf(subscription) == -1) {\n logger.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`)\n this.pendingSubscriptions.push(subscription)\n } else {\n logger.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`)\n }\n this.startGuaranteeing()\n }\n\n forget(subscription: Subscription) {\n logger.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`)\n this.pendingSubscriptions = this.pendingSubscriptions.filter((s) => s !== subscription)\n }\n\n startGuaranteeing() {\n this.stopGuaranteeing()\n this.retrySubscribing()\n }\n\n stopGuaranteeing() {\n clearTimeout(this.retryTimeout)\n }\n\n retrySubscribing() {\n this.retryTimeout = setTimeout(() => {\n if (this.subscriptions && typeof this.subscriptions.subscribe === 'function') {\n this.pendingSubscriptions.map((subscription) => {\n logger.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`)\n this.subscriptions.subscribe(subscription)\n })\n }\n }, 500)\n }\n}\n\nexport default SubscriptionGuarantor\n","import type { Consumer } from './consumer'\nimport logger from './logger'\nimport type { Data } from './subscription'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\n\n// Collection class for creating (and internally managing) channel subscriptions.\n// The only method intended to be triggered by the user is ActionCable.Subscriptions#create,\n// and it should be called through the consumer like so:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n\nexport class Subscriptions {\n consumer: Consumer\n guarantor: SubscriptionGuarantor\n subscriptions: Array<Subscription>\n\n constructor(consumer: Consumer) {\n this.consumer = consumer\n this.guarantor = new SubscriptionGuarantor(this)\n this.subscriptions = []\n }\n\n create(channelName: string, mixin: Data) {\n const channel = channelName\n const params = typeof channel === 'object' ? channel : { channel }\n const subscription = new Subscription(this.consumer, params, mixin)\n return this.add(subscription)\n }\n\n // Private\n\n add(subscription: Subscription) {\n this.subscriptions.push(subscription)\n this.consumer.ensureActiveConnection()\n this.notify(subscription, 'initialized')\n this.subscribe(subscription)\n return subscription\n }\n\n remove(subscription: Subscription) {\n this.forget(subscription)\n if (!this.findAll(subscription.identifier).length) {\n this.sendCommand(subscription, 'unsubscribe')\n }\n return subscription\n }\n\n reject(identifier: string) {\n return this.findAll(identifier).map((subscription) => {\n this.forget(subscription)\n this.notify(subscription, 'rejected')\n return subscription\n })\n }\n\n forget(subscription: Subscription) {\n this.guarantor.forget(subscription)\n this.subscriptions = this.subscriptions.filter((s) => s !== subscription)\n return subscription\n }\n\n findAll(identifier: string) {\n return this.subscriptions.filter((s) => s.identifier === identifier)\n }\n\n reload() {\n return this.subscriptions.map((subscription) => this.subscribe(subscription))\n }\n\n notifyAll(callbackName: string, ...args: any[]) {\n return this.subscriptions.map((subscription) =>\n this.notify(subscription, callbackName, ...args)\n )\n }\n\n notify(subscription: Subscription, callbackName: string, ...args: any[]) {\n let subscriptions\n if (typeof subscription === 'string') {\n subscriptions = this.findAll(subscription)\n } else {\n subscriptions = [subscription]\n }\n\n return subscriptions.map((subscription: any) =>\n typeof subscription[callbackName] === 'function'\n ? subscription[callbackName](...args)\n : undefined\n )\n }\n\n subscribe(subscription: Subscription) {\n if (this.sendCommand(subscription, 'subscribe')) {\n this.guarantor.guarantee(subscription)\n }\n }\n\n confirmSubscription(identifier: string) {\n logger.log(`Subscription confirmed ${identifier}`)\n this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription))\n }\n\n sendCommand(subscription: Subscription, command: string) {\n const { identifier } = subscription\n return this.consumer.send({ command, identifier })\n }\n}\n\nexport default Subscriptions\n","import Connection from './connection'\nimport Subscriptions from './subscriptions'\n\n// The ActionCable.Consumer establishes the connection to a server-side Ruby Connection object. Once established,\n// the ActionCable.ConnectionMonitor will ensure that its properly maintained through heartbeats and checking for stale updates.\n// The Consumer instance is also the gateway to establishing subscriptions to desired channels through the #createSubscription\n// method.\n//\n// The following example shows how this can be set up:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n//\n// When a consumer is created, it automatically connects with the server.\n//\n// To disconnect from the server, call\n//\n// App.cable.disconnect()\n//\n// and to restart the connection:\n//\n// App.cable.connect()\n//\n// Any channel subscriptions which existed prior to disconnecting will\n// automatically resubscribe.\n\nexport class Consumer {\n _url: string\n subscriptions: Subscriptions\n connection: Connection\n subprotocols: Array<string>\n\n constructor(url: string) {\n this._url = url\n this.subscriptions = new Subscriptions(this)\n this.connection = new Connection(this)\n this.subprotocols = []\n }\n\n get url() {\n return createWebSocketURL(this._url)\n }\n\n send(data: object) {\n return this.connection.send(data)\n }\n\n connect() {\n return this.connection.open()\n }\n\n disconnect() {\n return this.connection.close({ allowReconnect: false })\n }\n\n ensureActiveConnection() {\n if (!this.connection.isActive()) {\n return this.connection.open()\n }\n }\n\n addSubProtocol(subprotocol: string) {\n this.subprotocols = [...this.subprotocols, subprotocol]\n }\n}\n\nexport function createWebSocketURL(url: string | (() => string)): string {\n if (typeof url === 'function') {\n url = url()\n }\n\n if (url && !/^wss?:/i.test(url)) {\n const a = document.createElement('a')\n a.href = url\n // eslint-disable-next-line no-self-assign\n a.href = a.href\n a.protocol = a.protocol.replace('http', 'ws')\n return a.href\n } else {\n return url\n }\n}\n\nexport default Consumer\n","'use client'\n\nimport adapters from './adapters'\nimport Connection from './connection'\nimport ConnectionMonitor from './connection_monitor'\nimport Consumer, { createWebSocketURL } from './consumer'\nimport INTERNAL from './internal'\nimport logger from './logger'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\nimport Subscriptions from './subscriptions'\n\nexport {\n Connection,\n ConnectionMonitor,\n Consumer,\n INTERNAL,\n Subscription,\n Subscriptions,\n SubscriptionGuarantor,\n adapters,\n createWebSocketURL,\n logger,\n}\n\nexport function createConsumer(url = getConfig('url') || INTERNAL.default_mount_path) {\n return new Consumer(url)\n}\n\nexport function getConfig(name: string) {\n const element = document.head.querySelector(`meta[name='action-cable-${name}']`)\n if (element) {\n return element.getAttribute('content')\n }\n}\n","'use client'\n\nimport ActionCableLink from './ActionCableLink'\n\nexport class SubscriptionLink extends ActionCableLink {\n constructor() {\n super({ channelName: 'GraphQLChannel' })\n }\n}\n\nexport default SubscriptionLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nexport const TerminatingLink = new ApolloLink(() => null)\n\nexport default TerminatingLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nimport { version } from '../../../configuration'\n\nexport const VersionLink = new ApolloLink((operation, forward) => {\n operation.setContext(({ headers = {} }) => ({\n headers: {\n ...headers,\n 'Quiltt-Client-Version': version,\n },\n }))\n return forward(operation)\n})\n\nexport default VersionLink\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/graphql/links/AuthLink.ts","../../../../src/Storage/Local.ts","../../../../src/Observable.ts","../../../../src/Storage/Memory.ts","../../../../src/Storage/index.ts","../../../../src/api/graphql/links/BatchHttpLink.ts","../../../../package.json","../../../../src/configuration.ts","../../../../src/api/graphql/links/ErrorLink.ts","../../../../src/api/graphql/links/ForwardableLink.ts","../../../../src/api/graphql/links/HttpLink.ts","../../../../src/api/graphql/links/RetryLink.ts","../../../../src/api/graphql/links/ActionCableLink.ts","../../../../src/api/graphql/links/actioncable/adapters.ts","../../../../src/api/graphql/links/actioncable/logger.ts","../../../../src/api/graphql/links/actioncable/connection_monitor.ts","../../../../src/api/graphql/links/actioncable/internal.ts","../../../../src/api/graphql/links/actioncable/connection.ts","../../../../src/api/graphql/links/actioncable/subscription.ts","../../../../src/api/graphql/links/actioncable/subscription_guarantor.ts","../../../../src/api/graphql/links/actioncable/subscriptions.ts","../../../../src/api/graphql/links/actioncable/consumer.ts","../../../../src/api/graphql/links/actioncable/index.ts","../../../../src/api/graphql/links/SubscriptionLink.ts","../../../../src/api/graphql/links/TerminatingLink.ts","../../../../src/api/graphql/links/VersionLink.ts"],"names":["ApolloLink","LocalStorage","__publicField","error","key","state","observer","_a","update","event","newState","observers","Observable","initalState","nextState","MemoryStorage","Storage","prevValue","GlobalStorage","AuthLink","operation","forward","token","headers","__spreadProps","__spreadValues","ApolloHttpLink","fetch","name","version","QUILTT_API_INSECURE","e","QUILTT_API_DOMAIN","QUILTT_DEBUG","domain","protocolHttp","protocolWebsockets","debugging","endpointAuth","endpointGraphQL","endpointWebsockets","BatchHttpLink","onError","ErrorLink","graphQLErrors","networkError","message","locations","path","ForwardableLink","HttpLink","ApolloRetryLink","RetryLink","_operation","print","adapters_default","Logger","messages","logger","logger_default","now","secondsSince","time","ConnectionMonitor","connection","staleThreshold","reconnectionBackoffRate","backoff","jitter","connection_monitor_default","INTERNAL","internal_default","message_types","protocols","supportedProtocols","indexOf","Connection","consumer","data","socketProtocols","allowReconnect","states","eventName","handler","identifier","reason","reconnect","type","_event","connection_default","extend","object","properties","value","Subscription","params","mixin","action","subscription_default","SubscriptionGuarantor","subscriptions","subscription","s","subscription_guarantor_default","Subscriptions","channelName","channel","callbackName","args","command","subscriptions_default","Consumer","url","createWebSocketURL","subprotocol","a","consumer_default","createConsumer","getConfig","element","ActionCableLink","options","_next","channelId","actionName","connectionParams","payload","_b","ActionCableLink_default","SubscriptionLink","TerminatingLink","VersionLink"],"mappings":"2eACA,OAAS,cAAAA,OAAkB,0BCQpB,IAAMC,EAAN,KAAsB,CAG3B,aAAc,CAFdC,EAAA,KAAQ,YAA8C,CAAC,GAQvDA,EAAA,iBAAY,IAAe,CACzB,GAAI,CACF,oBAAa,QAAQ,cAAe,MAAM,EAC1C,aAAa,WAAW,aAAa,EAC9B,EACT,OAASC,EAAP,CACA,MAAO,EACT,CACF,GAEAD,EAAA,kBAAa,IAAe,CAAC,KAAK,UAAU,GAE5CA,EAAA,WAAOE,GAAsC,CAC3C,GAAI,SAAO,QAAW,aAAiB,OAAO,MAE9C,GAAI,CACF,IAAMC,EAAQ,OAAO,aAAa,QAAQ,UAAUD,GAAK,EACzD,OAAOC,GAAQ,KAAK,MAAMA,CAAK,CACjC,OAASF,EAAP,CACA,QAAQ,KAAK,+BAA+BC,KAAQD,CAAK,EACzD,MACF,CACF,GAEAD,EAAA,WAAM,CAACE,EAAaC,IAAsC,CACxD,GAAI,SAAO,QAAW,aAAiB,OAAO,MAE9C,GAAI,CACEA,EACF,OAAO,aAAa,QAAQ,UAAUD,IAAO,KAAK,UAAUC,CAAK,CAAC,EAElE,OAAO,aAAa,WAAW,UAAUD,GAAK,CAElD,OAASD,EAAP,CACA,QAAQ,KAAK,+BAA+BC,KAAQD,CAAK,CAC3D,CACF,GAEAD,EAAA,cAAUE,GAAgB,CACxB,GAAI,CACF,OAAO,aAAa,WAAW,UAAUA,GAAK,CAChD,OAASD,EAAP,CACA,QAAQ,KAAK,+BAA+BC,MAASD,CAAK,CAC5D,CACF,GAEAD,EAAA,iBAAY,CAACE,EAAaE,IAA0B,CAC7C,KAAK,UAA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OAAS,cAAAhI,OAAkB,0BAEpB,IAAMkI,GAAkB,IAAIlI,GAAW,IAAM,IAAI,ECFxD,OAAS,cAAAA,OAAkB,0BAIpB,IAAMmI,GAAc,IAAInI,GAAW,CAACoB,EAAWC,KACpDD,EAAU,WAAW,CAAC,CAAE,QAAAG,EAAU,CAAC,CAAE,KAAO,CAC1C,QAASC,EAAAC,EAAA,GACJF,GADI,CAEP,wBAAyBM,CAC3B,EACF,EAAE,EACKR,EAAQD,CAAS,EACzB","sourcesContent":["import type { FetchResult, NextLink, Observable, Operation } from '@apollo/client/index.js'\nimport { ApolloLink } from '@apollo/client/index.js'\n\nimport { GlobalStorage } from '@/Storage'\n\n/**\n * unauthorizedCallback only triggers in the event the token is present, and\n * returns the token; This allows sessions to be forgotten without race conditions\n * causing null sessions to kill valid sessions, or invalid sessions for killing\n * valid sessions during rotation and networking weirdness.\n */\nexport class AuthLink extends ApolloLink {\n request(operation: Operation, forward: NextLink): Observable<FetchResult> | null {\n const token = GlobalStorage.get('session')\n\n if (!token) {\n console.warn(`QuilttLink attempted to send an unauthenticated Query`)\n return null\n }\n\n operation.setContext(({ headers = {} }) => ({\n headers: {\n ...headers,\n authorization: `Bearer ${token}`,\n },\n }))\n\n return forward(operation)\n }\n}\n\nexport default AuthLink\n","import type { Maybe } from '../types'\nimport type { Observer } from '../Observable'\n\n/**\n * An error and type safe wrapper for localStorage.\n * It allows you to subscribe to changes;\n * but localStorage changes only fire with another\n * window updates the record.\n */\nexport class LocalStorage<T> {\n private observers: { [key: string]: Observer<T>[] } = {}\n\n constructor() {\n if (typeof window !== 'undefined' && !window?.expo) {\n window.addEventListener('storage', this.handleStorageEvent.bind(this))\n }\n }\n\n isEnabled = (): boolean => {\n try {\n localStorage.setItem(`quiltt.ping`, 'pong')\n localStorage.removeItem(`quiltt.ping`)\n return true\n } catch (error) {\n return false\n }\n }\n\n isDisabled = (): boolean => !this.isEnabled()\n\n get = (key: string): Maybe<T> | undefined => {\n if (typeof window === 'undefined' || !!window.expo) return undefined\n\n try {\n const state = window.localStorage.getItem(`quiltt.${key}`)\n return state ? JSON.parse(state) : state\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\"`, error)\n return undefined\n }\n }\n\n set = (key: string, state: Maybe<T> | undefined): void => {\n if (typeof window === 'undefined' || !!window.expo) return\n\n try {\n if (state) {\n window.localStorage.setItem(`quiltt.${key}`, JSON.stringify(state))\n } else {\n window.localStorage.removeItem(`quiltt.${key}`)\n }\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\"`, error)\n }\n }\n\n remove = (key: string) => {\n try {\n window.localStorage.removeItem(`quiltt.${key}`)\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\">`, error)\n }\n }\n\n subscribe = (key: string, observer: Observer<T>) => {\n if (!this.observers[key]) this.observers[key] = []\n\n this.observers[key].push(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>) => {\n this.observers[key] = this.observers[key]?.filter((update) => update !== observer)\n }\n\n // if there is a key, then trigger the related updates. If there is not key\n // it means that a record has been removed and everything needs to be rechecked.\n private handleStorageEvent = (event: StorageEvent) => {\n if (event.key && event.key.includes('quiltt.')) {\n const newState = event.newValue ? JSON.parse(event.newValue) : null\n\n if (this.observers[event.key]) {\n this.observers[event.key].forEach((update) => update(newState))\n }\n } else {\n Object.entries(this.observers).forEach(([key, observers]) => {\n observers.forEach((update) => update(this.get(key)))\n })\n }\n }\n}\n\nexport default LocalStorage\n","import type { Dispatch, SetStateAction } from 'react'\nimport type { Maybe } from './types'\n\nexport type Observer<T> = Dispatch<SetStateAction<Maybe<T> | undefined>>\n\n/**\n * This is designed to support singletons to share the memory states across all\n * instance of hooks to ensure that updates only process once, by storing a value\n * then notifying all subscribers when it's updated.\n */\nexport class Observable<T> {\n private state?: Maybe<T>\n private observers: Observer<T>[] = []\n\n constructor(initalState?: Maybe<T>) {\n this.state = initalState\n }\n\n get = () => {\n return this.state\n }\n\n set = (nextState: Maybe<T> | undefined) => {\n if (this.state === nextState) return\n\n this.state = nextState\n this.observers.forEach((update) => update(nextState))\n }\n\n subscribe = (observer: Observer<T>) => {\n this.observers.push(observer)\n }\n\n unsubscribe = (observer: Observer<T>) => {\n this.observers = this.observers.filter((update) => update !== observer)\n }\n}\n\nexport default Observable\n","import type { Maybe } from '../types'\n\nimport { Observable } from '../Observable'\nimport type { Observer } from '../Observable'\n\n/**\n * This is designed to support effectively an in memory key value store singleton,\n * similar to localstorage, but allows you to subscribe to changes within the current\n * window.\n */\nexport class MemoryStorage<T> {\n private observables: { [key: string]: Observable<T> } = {}\n\n get = (key: string) => {\n if (this.observables[key]) {\n return this.observables[key].get()\n } else {\n return undefined\n }\n }\n\n set = (key: string, state: Maybe<T> | undefined): void => {\n if (!this.observables[key]) {\n this.observables[key] = new Observable<T>(state)\n } else {\n this.observables[key].set(state)\n }\n }\n\n subscribe = (key: string, observer: Observer<T>): void => {\n if (!this.observables[key]) this.observables[key] = new Observable<T>()\n\n this.observables[key].subscribe(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>): void => {\n if (this.observables[key]) {\n this.observables[key].unsubscribe(observer)\n }\n }\n}\n\nexport default MemoryStorage\n","import type { Maybe } from '../types'\n\nimport type { Observer } from '../Observable'\nimport { LocalStorage } from './Local'\nimport { MemoryStorage } from './Memory'\n\n/**\n * This is wraps both local and memory storage to create a unified interface, that\n * allows you to subscribe to all either changes made within this window, or changes\n * made by other windows.\n */\nexport class Storage<T> {\n private memoryStore = new MemoryStorage<T>()\n private localStore = new LocalStorage<T>()\n private observers: { [key: string]: Observer<T>[] } = {}\n private monitors: Set<string> = new Set()\n\n /**\n * Checks memoryStorage before falling back to localStorage.\n */\n get = (key: string): Maybe<T> | undefined => {\n this.monitorLocalStorageChanges(key)\n\n let state = this.memoryStore.get(key)\n\n if (state === undefined) {\n state = this.localStore.get(key)\n }\n\n return state\n }\n\n /**\n * We don't trust localStorage to always be present, so we can't rely on it to\n * update memoryStorage based on emitted changes. So we manage our own\n * emitting while using the underlying events to keep memoryStore in sync with\n * localStore.\n */\n set = (key: string, newState: Maybe<T> | undefined) => {\n this.monitorLocalStorageChanges(key)\n\n this.localStore.set(key, newState)\n this.memoryStore.set(key, newState)\n\n this.observers[key]?.forEach((update) => update(newState))\n }\n\n /**\n * Allows you to subscribe to all changes in memory or local storage as a\n * single event.\n */\n subscribe = (key: string, observer: Observer<T>) => {\n if (!this.observers[key]) this.observers[key] = []\n\n this.observers[key].push(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>) => {\n this.observers[key] = this.observers[key]?.filter((update) => update !== observer)\n }\n\n /**\n * Sets bubble the changes down the stack starting with memoryStore and then\n * localStore. memoryStore will emit changes to everything within the current\n * window context, while localStore will emit changes to every other window\n * context.\n *\n * To ensure that the other windows are updated correctly, changes to localStore\n * need to be subscribed and updated to in memory store, which then may be subscribed\n * to outside of storage.\n */\n private monitorLocalStorageChanges = (key: string) => {\n if (this.monitors.has(key)) return\n this.monitors.add(key)\n\n this.localStore.subscribe(key, (nextState) => {\n const prevValue = this.memoryStore.get(key)\n const newState = nextState instanceof Function ? nextState(prevValue) : nextState\n\n this.memoryStore.set(key, newState)\n this.observers[key]?.forEach((update) => update(newState))\n })\n }\n}\n\nexport * from './Local'\nexport * from './Memory'\n\n/**\n * This is an singleton to share the memory states across all instances; This\n * basically acts like shared memory when there is no localStorage.\n */\nexport const GlobalStorage = new Storage<any>()\n","import { BatchHttpLink as ApolloHttpLink } from '@apollo/client/link/batch-http/index.js'\n\nimport fetch from 'cross-fetch'\n\nimport { endpointGraphQL } from '../../../configuration'\n\nexport const BatchHttpLink = new ApolloHttpLink({\n uri: endpointGraphQL,\n fetch,\n})\n\nexport default BatchHttpLink\n","{\n \"name\": \"@quiltt/core\",\n \"version\": \"3.3.3\",\n \"description\": \"Javascript API client and utilities for Quiltt\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/quiltt/quiltt-public.git\",\n \"directory\": \"ECMAScript/core\"\n },\n \"homepage\": \"https://github.com/quiltt/quiltt-public/tree/main/ECMAScript/core#readme\",\n \"keywords\": [\n \"quiltt\",\n \"typescript\"\n ],\n \"license\": \"MIT\",\n \"sideEffects\": [\n \"./src/Storage/Local.ts\",\n \"./src/api/graphql/links/SubscriptionLink.ts\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist/**\",\n \"src/**\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf .turbo dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"TIMING=1 eslint --ext .js,.jsx,.ts,.tsx src/ --fix\",\n \"typecheck\": \"tsc --project tsconfig.json --noEmit\"\n },\n \"dependencies\": {\n \"@apollo/client\": \"^3.7.16\",\n \"axios\": \"^1.4.0\",\n \"cross-fetch\": \"^3.1.8\",\n \"graphql\": \"^16.8.1\",\n \"graphql-ruby-client\": \"^1.11.8\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"4.1.1\",\n \"@types/node\": \"18.16.18\",\n \"@types/react\": \"18.2.7\",\n \"@typescript-eslint/eslint-plugin\": \"5.60.1\",\n \"@typescript-eslint/parser\": \"5.60.1\",\n \"eslint\": \"8.43.0\",\n \"eslint-config-prettier\": \"8.8.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"prettier\": \"2.8.8\",\n \"tsup\": \"6.7.0\",\n \"typescript\": \"5.1.3\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import { name as packageName, version as packageVersion } from '../package.json'\n\nconst QUILTT_API_INSECURE = (() => {\n try {\n return process.env.QUILTT_API_INSECURE\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_API_DOMAIN = (() => {\n try {\n return process.env.QUILTT_API_DOMAIN\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_DEBUG = (() => {\n try {\n return !!process.env.QUILTT_DEBUG || process.env.NODE_ENV !== 'production'\n } catch {\n return false\n }\n})()\n\nconst domain = QUILTT_API_DOMAIN || 'quiltt.io'\nconst protocolHttp = `http${QUILTT_API_INSECURE ? '' : 's'}`\nconst protocolWebsockets = `ws${QUILTT_API_DOMAIN ? '' : 's'}`\n\nexport const debugging = QUILTT_DEBUG\nexport const endpointAuth = `${protocolHttp}://auth.${domain}/v1/users/session`\nexport const endpointGraphQL = `${protocolHttp}://api.${domain}/v1/graphql`\nexport const endpointWebsockets = `${protocolWebsockets}://api.${domain}/websockets`\nexport const version = `${packageName}: v${packageVersion}`\n\nconst Config = {\n debugging,\n endpointAuth,\n endpointGraphQL,\n endpointWebsockets,\n version,\n}\n\nexport default Config\n","import { GlobalStorage } from '@/Storage'\n\nimport type { ServerError } from '@apollo/client/index.js'\nimport { onError } from '@apollo/client/link/error/index.js'\n\nexport const ErrorLink = onError(({ graphQLErrors, networkError }) => {\n if (graphQLErrors) {\n graphQLErrors.forEach(({ message, locations, path }) => {\n console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`)\n })\n }\n\n if (networkError) {\n if ((networkError as ServerError).statusCode === 401) {\n console.warn('[Authentication error]:', networkError)\n GlobalStorage.set('session', null)\n } else {\n console.warn('[Network error]:', networkError)\n }\n }\n})\n\nexport default ErrorLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nexport const ForwardableLink = new ApolloLink((operation, forward) => forward(operation))\n\nexport default ForwardableLink\n","import { HttpLink as ApolloHttpLink } from '@apollo/client/link/http/index.js'\n\nimport fetch from 'cross-fetch'\n\nimport { endpointGraphQL } from '../../../configuration'\n\nexport const HttpLink = new ApolloHttpLink({\n uri: endpointGraphQL,\n fetch,\n})\n\nexport default HttpLink\n","import type { ServerError } from '@apollo/client/index.js'\nimport { RetryLink as ApolloRetryLink } from '@apollo/client/link/retry/index.js'\n\nexport const RetryLink = new ApolloRetryLink({\n attempts: {\n retryIf: (error: ServerError, _operation) => error.statusCode >= 500,\n },\n})\n\nexport default RetryLink\n","import { GlobalStorage } from '@/Storage'\nimport type { FetchResult, NextLink, Operation } from '@apollo/client/core/index.js'\nimport { ApolloLink, Observable } from '@apollo/client/core/index.js'\nimport { print } from 'graphql'\nimport { endpointWebsockets } from '../../../configuration'\nimport type { Consumer } from './actioncable'\nimport { createConsumer } from './actioncable'\n\ntype RequestResult = FetchResult<\n { [key: string]: unknown },\n Record<string, unknown>,\n Record<string, unknown>\n>\ntype ConnectionParams = object | ((operation: Operation) => object)\n\nclass ActionCableLink extends ApolloLink {\n cables: { [id: string]: Consumer }\n channelName: string\n actionName: string\n connectionParams: ConnectionParams\n\n constructor(options: {\n channelName?: string\n actionName?: string\n connectionParams?: ConnectionParams\n }) {\n super()\n this.cables = {}\n this.channelName = options.channelName || 'GraphqlChannel'\n this.actionName = options.actionName || 'execute'\n this.connectionParams = options.connectionParams || {}\n }\n\n // Interestingly, this link does _not_ call through to `next` because\n // instead, it sends the request to ActionCable.\n request(operation: Operation, _next: NextLink): Observable<RequestResult> | null {\n const token = GlobalStorage.get('session')\n\n if (!token) {\n console.warn(`QuilttLink attempted to send an unauthenticated Subscription`)\n return null\n }\n\n if (!this.cables[token]) {\n this.cables[token] = createConsumer(endpointWebsockets + (token ? `?token=${token}` : ''))\n }\n\n return new Observable((observer) => {\n const channelId = Math.round(Date.now() + Math.random() * 100000).toString(16)\n const actionName = this.actionName\n const connectionParams =\n typeof this.connectionParams === 'function'\n ? this.connectionParams(operation)\n : this.connectionParams\n\n const channel = this.cables[token].subscriptions.create(\n Object.assign(\n {},\n {\n channel: this.channelName,\n channelId: channelId,\n },\n connectionParams\n ),\n {\n connected: () => {\n channel.perform(actionName, {\n query: operation.query ? print(operation.query) : null,\n variables: operation.variables,\n // This is added for persisted operation support:\n operationId: (operation as { operationId?: string }).operationId,\n operationName: operation.operationName,\n })\n },\n\n received: (payload: { result: RequestResult; more: any }) => {\n if (payload?.result?.data || payload?.result?.errors) {\n observer.next(payload.result)\n }\n\n if (!payload.more) {\n observer.complete()\n }\n },\n }\n )\n // Make the ActionCable subscription behave like an Apollo subscription\n return Object.assign(channel, { closed: false })\n })\n }\n}\n\nexport default ActionCableLink\n","export default {\n logger: typeof globalThis !== 'undefined' ? globalThis.console : undefined,\n WebSocket: typeof globalThis !== 'undefined' ? globalThis.WebSocket : undefined,\n}\n","import { debugging } from '../../../../configuration'\nimport adapters from './adapters'\n\nclass Logger {\n enabled = debugging\n\n log(...messages: Array<string>) {\n if (adapters.logger && this.enabled) {\n messages.push(Date.now().toString())\n adapters.logger.log('[ActionCable]', ...messages)\n }\n }\n}\n\nexport const logger = new Logger()\nexport default logger\n","// @ts-nocheck\nimport logger from './logger'\n\n// Responsible for ensuring the cable connection is in good health by validating the heartbeat pings sent from the server, and attempting\n// revival reconnections if things go astray. Internal class, not intended for direct user manipulation.\n\nconst now = () => new Date().getTime()\n\nconst secondsSince = (time) => (now() - time) / 1000\n\nclass ConnectionMonitor {\n constructor(connection) {\n this.visibilityDidChange = this.visibilityDidChange.bind(this)\n this.connection = connection\n this.reconnectAttempts = 0\n }\n\n start() {\n if (!this.isRunning()) {\n this.startedAt = now()\n delete this.stoppedAt\n this.startPolling()\n addEventListener('visibilitychange', this.visibilityDidChange)\n logger.log(\n `ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`\n )\n }\n }\n\n stop() {\n if (this.isRunning()) {\n this.stoppedAt = now()\n this.stopPolling()\n removeEventListener('visibilitychange', this.visibilityDidChange)\n logger.log('ConnectionMonitor stopped')\n }\n }\n\n isRunning() {\n return this.startedAt && !this.stoppedAt\n }\n\n recordPing() {\n this.pingedAt = now()\n }\n\n recordConnect() {\n this.reconnectAttempts = 0\n this.recordPing()\n delete this.disconnectedAt\n logger.log('ConnectionMonitor recorded connect')\n }\n\n recordDisconnect() {\n this.disconnectedAt = now()\n logger.log('ConnectionMonitor recorded disconnect')\n }\n\n // Private\n\n startPolling() {\n this.stopPolling()\n this.poll()\n }\n\n stopPolling() {\n clearTimeout(this.pollTimeout)\n }\n\n poll() {\n this.pollTimeout = setTimeout(() => {\n this.reconnectIfStale()\n this.poll()\n }, this.getPollInterval())\n }\n\n getPollInterval() {\n const { staleThreshold, reconnectionBackoffRate } = this.constructor\n const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10))\n const jitterMax = this.reconnectAttempts === 0 ? 1.0 : reconnectionBackoffRate\n const jitter = jitterMax * Math.random()\n return staleThreshold * 1000 * backoff * (1 + jitter)\n }\n\n reconnectIfStale() {\n if (this.connectionIsStale()) {\n logger.log(\n `ConnectionMonitor detected stale connection. reconnectAttempts = ${\n this.reconnectAttempts\n }, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${\n this.constructor.staleThreshold\n } s`\n )\n this.reconnectAttempts++\n if (this.disconnectedRecently()) {\n logger.log(\n `ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(\n this.disconnectedAt\n )} s`\n )\n } else {\n logger.log('ConnectionMonitor reopening')\n this.connection.reopen()\n }\n }\n }\n\n get refreshedAt() {\n return this.pingedAt ? this.pingedAt : this.startedAt\n }\n\n connectionIsStale() {\n return secondsSince(this.refreshedAt) > this.constructor.staleThreshold\n }\n\n disconnectedRecently() {\n return (\n this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold\n )\n }\n\n visibilityDidChange() {\n if (document.visibilityState === 'visible') {\n setTimeout(() => {\n if (this.connectionIsStale() || !this.connection.isOpen()) {\n logger.log(\n `ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`\n )\n this.connection.reopen()\n }\n }, 200)\n }\n }\n}\n\nConnectionMonitor.staleThreshold = 6 // Server::Connections::BEAT_INTERVAL * 2 (missed two pings)\nConnectionMonitor.reconnectionBackoffRate = 0.15\n\nexport default ConnectionMonitor\n","const INTERNAL = {\n message_types: {\n welcome: 'welcome',\n disconnect: 'disconnect',\n ping: 'ping',\n confirmation: 'confirm_subscription',\n rejection: 'reject_subscription',\n },\n disconnect_reasons: {\n unauthorized: 'unauthorized',\n invalid_request: 'invalid_request',\n server_restart: 'server_restart',\n remote: 'remote',\n },\n default_mount_path: '/cable',\n protocols: ['actioncable-v1-json', 'actioncable-unsupported'],\n}\n\nexport default INTERNAL\n","// @ts-nocheck\nimport adapters from './adapters'\nimport ConnectionMonitor from './connection_monitor'\nimport INTERNAL from './internal'\nimport logger from './logger'\n\n// Encapsulate the cable connection held by the consumer. This is an internal class not intended for direct user manipulation.\n\nconst { message_types, protocols } = INTERNAL\nconst supportedProtocols = protocols.slice(0, protocols.length - 1)\n\nconst indexOf = [].indexOf\n\nclass Connection {\n constructor(consumer) {\n this.open = this.open.bind(this)\n this.consumer = consumer\n this.subscriptions = this.consumer.subscriptions\n this.monitor = new ConnectionMonitor(this)\n this.disconnected = true\n }\n\n send(data) {\n if (this.isOpen()) {\n this.webSocket.send(JSON.stringify(data))\n return true\n } else {\n return false\n }\n }\n\n open() {\n if (this.isActive()) {\n logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`)\n return false\n } else {\n const socketProtocols = [...protocols, ...(this.consumer.subprotocols || [])]\n logger.log(\n `Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`\n )\n if (this.webSocket) {\n this.uninstallEventHandlers()\n }\n this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols)\n this.installEventHandlers()\n this.monitor.start()\n return true\n }\n }\n\n close({ allowReconnect } = { allowReconnect: true }) {\n if (!allowReconnect) {\n this.monitor.stop()\n }\n // Avoid closing websockets in a \"connecting\" state due to Safari 15.1+ bug. See: https://github.com/rails/rails/issues/43835#issuecomment-1002288478\n if (this.isOpen()) {\n return this.webSocket.close()\n }\n }\n\n reopen() {\n logger.log(`Reopening WebSocket, current state is ${this.getState()}`)\n if (this.isActive()) {\n try {\n return this.close()\n } catch (error) {\n logger.log('Failed to reopen WebSocket', error)\n } finally {\n logger.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`)\n setTimeout(this.open, this.constructor.reopenDelay)\n }\n } else {\n return this.open()\n }\n }\n\n getProtocol() {\n if (this.webSocket) {\n return this.webSocket.protocol\n }\n }\n\n isOpen() {\n return this.isState('open')\n }\n\n isActive() {\n return this.isState('open', 'connecting')\n }\n\n triedToReconnect() {\n return this.monitor.reconnectAttempts > 0\n }\n\n // Private\n\n isProtocolSupported() {\n return indexOf.call(supportedProtocols, this.getProtocol()) >= 0\n }\n\n isState(...states) {\n return indexOf.call(states, this.getState()) >= 0\n }\n\n getState() {\n if (this.webSocket) {\n for (const state in adapters.WebSocket) {\n if (adapters.WebSocket[state] === this.webSocket.readyState) {\n return state.toLowerCase()\n }\n }\n }\n return null\n }\n\n installEventHandlers() {\n for (const eventName in this.events) {\n const handler = this.events[eventName].bind(this)\n this.webSocket[`on${eventName}`] = handler\n }\n }\n\n uninstallEventHandlers() {\n for (const eventName in this.events) {\n this.webSocket[`on${eventName}`] = function () {}\n }\n }\n}\n\nConnection.reopenDelay = 500\n\nConnection.prototype.events = {\n message(event) {\n if (!this.isProtocolSupported()) {\n return\n }\n const { identifier, message, reason, reconnect, type } = JSON.parse(event.data)\n switch (type) {\n case message_types.welcome:\n if (this.triedToReconnect()) {\n this.reconnectAttempted = true\n }\n this.monitor.recordConnect()\n return this.subscriptions.reload()\n case message_types.disconnect:\n logger.log(`Disconnecting. Reason: ${reason}`)\n return this.close({ allowReconnect: reconnect })\n case message_types.ping:\n return this.monitor.recordPing()\n case message_types.confirmation:\n this.subscriptions.confirmSubscription(identifier)\n if (this.reconnectAttempted) {\n this.reconnectAttempted = false\n return this.subscriptions.notify(identifier, 'connected', { reconnected: true })\n } else {\n return this.subscriptions.notify(identifier, 'connected', { reconnected: false })\n }\n case message_types.rejection:\n return this.subscriptions.reject(identifier)\n default:\n return this.subscriptions.notify(identifier, 'received', message)\n }\n },\n\n open() {\n logger.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`)\n this.disconnected = false\n if (!this.isProtocolSupported()) {\n logger.log('Protocol is unsupported. Stopping monitor and disconnecting.')\n return this.close({ allowReconnect: false })\n }\n },\n\n close(_event) {\n logger.log('WebSocket onclose event')\n if (this.disconnected) {\n return\n }\n this.disconnected = true\n this.monitor.recordDisconnect()\n return this.subscriptions.notifyAll('disconnected', {\n willAttemptReconnect: this.monitor.isRunning(),\n })\n },\n\n error() {\n logger.log('WebSocket onerror event')\n },\n}\n\nexport default Connection\n","import type { Consumer } from './consumer'\n\nexport type Data = { [id: string]: string | object | null | undefined }\n\nconst extend = function (object: Data, properties: Data) {\n if (properties !== null) {\n for (const key in properties) {\n const value = properties[key]\n object[key] = value\n }\n }\n return object\n}\n\nexport class Subscription {\n consumer: Consumer\n identifier: string\n\n constructor(consumer: Consumer, params: Data = {}, mixin: Data) {\n this.consumer = consumer\n this.identifier = JSON.stringify(params)\n extend(this as unknown as Data, mixin)\n }\n\n // Perform a channel action with the optional data passed as an attribute\n perform(action: string, data: Data = {}) {\n data.action = action\n return this.send(data)\n }\n\n send(data: object) {\n return this.consumer.send({\n command: 'message',\n identifier: this.identifier,\n data: JSON.stringify(data),\n })\n }\n\n unsubscribe() {\n return this.consumer.subscriptions.remove(this)\n }\n}\n\nexport default Subscription\n","import logger from './logger'\nimport type { Subscription } from './subscription'\nimport type { Subscriptions } from './subscriptions'\n\n// Responsible for ensuring channel subscribe command is confirmed, retrying until confirmation is received.\n// Internal class, not intended for direct user manipulation.\n\nclass SubscriptionGuarantor {\n subscriptions: Subscriptions\n pendingSubscriptions: Array<Subscription>\n retryTimeout: ReturnType<typeof setTimeout> | undefined\n\n constructor(subscriptions: Subscriptions) {\n this.subscriptions = subscriptions\n this.pendingSubscriptions = []\n }\n\n guarantee(subscription: Subscription) {\n if (this.pendingSubscriptions.indexOf(subscription) == -1) {\n logger.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`)\n this.pendingSubscriptions.push(subscription)\n } else {\n logger.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`)\n }\n this.startGuaranteeing()\n }\n\n forget(subscription: Subscription) {\n logger.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`)\n this.pendingSubscriptions = this.pendingSubscriptions.filter((s) => s !== subscription)\n }\n\n startGuaranteeing() {\n this.stopGuaranteeing()\n this.retrySubscribing()\n }\n\n stopGuaranteeing() {\n clearTimeout(this.retryTimeout)\n }\n\n retrySubscribing() {\n this.retryTimeout = setTimeout(() => {\n if (this.subscriptions && typeof this.subscriptions.subscribe === 'function') {\n this.pendingSubscriptions.map((subscription) => {\n logger.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`)\n this.subscriptions.subscribe(subscription)\n })\n }\n }, 500)\n }\n}\n\nexport default SubscriptionGuarantor\n","import type { Consumer } from './consumer'\nimport logger from './logger'\nimport type { Data } from './subscription'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\n\n// Collection class for creating (and internally managing) channel subscriptions.\n// The only method intended to be triggered by the user is ActionCable.Subscriptions#create,\n// and it should be called through the consumer like so:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n\nexport class Subscriptions {\n consumer: Consumer\n guarantor: SubscriptionGuarantor\n subscriptions: Array<Subscription>\n\n constructor(consumer: Consumer) {\n this.consumer = consumer\n this.guarantor = new SubscriptionGuarantor(this)\n this.subscriptions = []\n }\n\n create(channelName: string, mixin: Data) {\n const channel = channelName\n const params = typeof channel === 'object' ? channel : { channel }\n const subscription = new Subscription(this.consumer, params, mixin)\n return this.add(subscription)\n }\n\n // Private\n\n add(subscription: Subscription) {\n this.subscriptions.push(subscription)\n this.consumer.ensureActiveConnection()\n this.notify(subscription, 'initialized')\n this.subscribe(subscription)\n return subscription\n }\n\n remove(subscription: Subscription) {\n this.forget(subscription)\n if (!this.findAll(subscription.identifier).length) {\n this.sendCommand(subscription, 'unsubscribe')\n }\n return subscription\n }\n\n reject(identifier: string) {\n return this.findAll(identifier).map((subscription) => {\n this.forget(subscription)\n this.notify(subscription, 'rejected')\n return subscription\n })\n }\n\n forget(subscription: Subscription) {\n this.guarantor.forget(subscription)\n this.subscriptions = this.subscriptions.filter((s) => s !== subscription)\n return subscription\n }\n\n findAll(identifier: string) {\n return this.subscriptions.filter((s) => s.identifier === identifier)\n }\n\n reload() {\n return this.subscriptions.map((subscription) => this.subscribe(subscription))\n }\n\n notifyAll(callbackName: string, ...args: any[]) {\n return this.subscriptions.map((subscription) =>\n this.notify(subscription, callbackName, ...args)\n )\n }\n\n notify(subscription: Subscription, callbackName: string, ...args: any[]) {\n let subscriptions\n if (typeof subscription === 'string') {\n subscriptions = this.findAll(subscription)\n } else {\n subscriptions = [subscription]\n }\n\n return subscriptions.map((subscription: any) =>\n typeof subscription[callbackName] === 'function'\n ? subscription[callbackName](...args)\n : undefined\n )\n }\n\n subscribe(subscription: Subscription) {\n if (this.sendCommand(subscription, 'subscribe')) {\n this.guarantor.guarantee(subscription)\n }\n }\n\n confirmSubscription(identifier: string) {\n logger.log(`Subscription confirmed ${identifier}`)\n this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription))\n }\n\n sendCommand(subscription: Subscription, command: string) {\n const { identifier } = subscription\n return this.consumer.send({ command, identifier })\n }\n}\n\nexport default Subscriptions\n","import Connection from './connection'\nimport Subscriptions from './subscriptions'\n\n// The ActionCable.Consumer establishes the connection to a server-side Ruby Connection object. Once established,\n// the ActionCable.ConnectionMonitor will ensure that its properly maintained through heartbeats and checking for stale updates.\n// The Consumer instance is also the gateway to establishing subscriptions to desired channels through the #createSubscription\n// method.\n//\n// The following example shows how this can be set up:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n//\n// When a consumer is created, it automatically connects with the server.\n//\n// To disconnect from the server, call\n//\n// App.cable.disconnect()\n//\n// and to restart the connection:\n//\n// App.cable.connect()\n//\n// Any channel subscriptions which existed prior to disconnecting will\n// automatically resubscribe.\n\nexport class Consumer {\n _url: string\n subscriptions: Subscriptions\n connection: Connection\n subprotocols: Array<string>\n\n constructor(url: string) {\n this._url = url\n this.subscriptions = new Subscriptions(this)\n this.connection = new Connection(this)\n this.subprotocols = []\n }\n\n get url() {\n return createWebSocketURL(this._url)\n }\n\n send(data: object) {\n return this.connection.send(data)\n }\n\n connect() {\n return this.connection.open()\n }\n\n disconnect() {\n return this.connection.close({ allowReconnect: false })\n }\n\n ensureActiveConnection() {\n if (!this.connection.isActive()) {\n return this.connection.open()\n }\n }\n\n addSubProtocol(subprotocol: string) {\n this.subprotocols = [...this.subprotocols, subprotocol]\n }\n}\n\nexport function createWebSocketURL(url: string | (() => string)): string {\n if (typeof url === 'function') {\n url = url()\n }\n\n if (url && !/^wss?:/i.test(url)) {\n const a = document.createElement('a')\n a.href = url\n // eslint-disable-next-line no-self-assign\n a.href = a.href\n a.protocol = a.protocol.replace('http', 'ws')\n return a.href\n } else {\n return url\n }\n}\n\nexport default Consumer\n","'use client'\n\nimport adapters from './adapters'\nimport Connection from './connection'\nimport ConnectionMonitor from './connection_monitor'\nimport Consumer, { createWebSocketURL } from './consumer'\nimport INTERNAL from './internal'\nimport logger from './logger'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\nimport Subscriptions from './subscriptions'\n\nexport {\n Connection,\n ConnectionMonitor,\n Consumer,\n INTERNAL,\n Subscription,\n Subscriptions,\n SubscriptionGuarantor,\n adapters,\n createWebSocketURL,\n logger,\n}\n\nexport function createConsumer(url = getConfig('url') || INTERNAL.default_mount_path) {\n return new Consumer(url)\n}\n\nexport function getConfig(name: string) {\n const element = document.head.querySelector(`meta[name='action-cable-${name}']`)\n if (element) {\n return element.getAttribute('content')\n }\n}\n","'use client'\n\nimport ActionCableLink from './ActionCableLink'\n\nexport class SubscriptionLink extends ActionCableLink {\n constructor() {\n super({ channelName: 'GraphQLChannel' })\n }\n}\n\nexport default SubscriptionLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nexport const TerminatingLink = new ApolloLink(() => null)\n\nexport default TerminatingLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nimport { version } from '../../../configuration'\n\nexport const VersionLink = new ApolloLink((operation, forward) => {\n operation.setContext(({ headers = {} }) => ({\n headers: {\n ...headers,\n 'Quiltt-Client-Version': version,\n },\n }))\n return forward(operation)\n})\n\nexport default VersionLink\n"]}
|