@azure/web-pubsub-chat-client 1.0.0-beta.1

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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../node_modules/@typespec/ts-http-runtime/src/env.ts", "../node_modules/@azure/abort-controller/src/AbortError.ts", "../node_modules/@azure/core-util/src/createAbortablePromise.ts", "../node_modules/@azure/core-util/src/delay.ts", "../node_modules/@azure/web-pubsub-client/dist/esm/webPubSubClient.js", "../node_modules/@azure/web-pubsub-client/dist/esm/errors/index.js", "../node_modules/@typespec/ts-http-runtime/src/logger/log.ts", "../node_modules/@typespec/ts-http-runtime/src/logger/debug.ts", "../node_modules/@typespec/ts-http-runtime/src/logger/logger.ts", "../node_modules/@azure/logger/src/index.ts", "../node_modules/@azure/web-pubsub-client/dist/esm/logger.js", "../node_modules/@azure/web-pubsub-client/dist/esm/protocols/jsonProtocolBase.js", "../node_modules/@azure/web-pubsub-client/dist/esm/protocols/webPubSubJsonReliableProtocol.js", "../node_modules/@azure/web-pubsub-client/dist/esm/protocols/index.js", "../node_modules/@azure/web-pubsub-client/dist/esm/websocket/websocketClient.js", "../node_modules/@azure/web-pubsub-client/dist/esm/utils/abortablePromise.js", "../node_modules/@azure/web-pubsub-client/dist/esm/ackManager.js", "../node_modules/@azure/web-pubsub-client/dist/esm/invocationManager.js", "../node_modules/tslib/tslib.es6.mjs", "../node_modules/@azure/core-paging/src/getPagedAsyncIterator.ts", "../src/chatClient.ts", "../src/constant.ts", "../src/logger.ts", "../src/utils.ts", "../src/index.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport process from \"node:process\";\n\ndeclare global {\n // Bun and Deno set process.versions with their runtime identifier\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace NodeJS {\n interface ProcessVersions {\n bun?: string;\n deno?: string;\n }\n }\n}\n\n/**\n * Returns the value of the specified environment variable.\n *\n * @internal\n */\nexport function getEnvironmentVariable(name: string): string | undefined {\n return process.env[name];\n}\n\n/**\n * Emits a Node.js process warning.\n *\n * @internal\n */\nexport function emitNodeWarning(warning: string): void {\n process.emitWarning(warning);\n}\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Browser.\n */\nexport const isBrowser: boolean = false;\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Worker.\n */\nexport const isWebWorker: boolean = false;\n\n/**\n * A constant that indicates whether the environment the code is running is Deno.\n */\nexport const isDeno = typeof process.versions.deno === \"string\" && process.versions.deno.length > 0;\n\n/**\n * A constant that indicates whether the environment the code is running is Bun.sh.\n */\nexport const isBun = typeof process.versions.bun === \"string\" && process.versions.bun.length > 0;\n\n/**\n * A constant that indicates whether the environment the code is running is a Node.js compatible environment.\n */\nexport const isNodeLike: boolean = true;\n\n/**\n * A constant that indicates whether the environment the code is running is Node.JS.\n */\nexport const isNodeRuntime = !isBun && !isDeno;\n\n/**\n * A constant that indicates whether the environment the code is running is in React-Native.\n */\nexport const isReactNative: boolean = false;\n", "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * This error is thrown when an asynchronous operation has been aborted.\n * Check for this error by testing the `name` that the name property of the\n * error matches `\"AbortError\"`.\n *\n * @example\n * ```ts\n * const controller = new AbortController();\n * controller.abort();\n * try {\n * doAsyncWork(controller.signal)\n * } catch (e) {\n * if (e.name === 'AbortError') {\n * // handle abort error here.\n * }\n * }\n * ```\n */\nexport class AbortError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"AbortError\";\n }\n}\n", "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError } from \"@azure/abort-controller\";\nimport type { AbortOptions } from \"./aborterUtils.js\";\n\n/**\n * Options for the createAbortablePromise function.\n */\nexport interface CreateAbortablePromiseOptions extends AbortOptions {\n /** A function to be called if the promise was aborted */\n cleanupBeforeAbort?: () => void;\n}\n\n/**\n * Creates an abortable promise.\n * @param buildPromise - A function that takes the resolve and reject functions as parameters.\n * @param options - The options for the abortable promise.\n * @returns A promise that can be aborted.\n */\nexport function createAbortablePromise<T>(\n buildPromise: (\n resolve: (value: T | PromiseLike<T>) => void,\n reject: (reason?: any) => void,\n ) => void,\n options?: CreateAbortablePromiseOptions,\n): Promise<T> {\n const { cleanupBeforeAbort, abortSignal, abortErrorMsg } = options ?? {};\n return new Promise((resolve, reject) => {\n function rejectOnAbort(): void {\n reject(new AbortError(abortErrorMsg ?? \"The operation was aborted.\"));\n }\n function removeListeners(): void {\n abortSignal?.removeEventListener(\"abort\", onAbort);\n }\n function onAbort(): void {\n cleanupBeforeAbort?.();\n removeListeners();\n rejectOnAbort();\n }\n if (abortSignal?.aborted) {\n return rejectOnAbort();\n }\n try {\n buildPromise(\n (x) => {\n removeListeners();\n resolve(x);\n },\n (x) => {\n removeListeners();\n reject(x);\n },\n );\n } catch (err) {\n reject(err);\n }\n abortSignal?.addEventListener(\"abort\", onAbort);\n });\n}\n", "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortOptions } from \"./aborterUtils.js\";\nimport { createAbortablePromise } from \"./createAbortablePromise.js\";\nimport { getRandomIntegerInclusive } from \"@typespec/ts-http-runtime/internal/util\";\n\nconst StandardAbortMessage = \"The delay was aborted.\";\n\n/**\n * Options for support abort functionality for the delay method\n */\nexport interface DelayOptions extends AbortOptions {}\n\n/**\n * A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.\n * @param timeInMs - The number of milliseconds to be delayed.\n * @param options - The options for delay - currently abort options\n * @returns Promise that is resolved after timeInMs\n */\nexport function delay(timeInMs: number, options?: DelayOptions): Promise<void> {\n let token: ReturnType<typeof setTimeout>;\n const { abortSignal, abortErrorMsg } = options ?? {};\n return createAbortablePromise(\n (resolve) => {\n token = setTimeout(resolve, timeInMs);\n },\n {\n cleanupBeforeAbort: () => clearTimeout(token),\n abortSignal,\n abortErrorMsg: abortErrorMsg ?? StandardAbortMessage,\n },\n );\n}\n\n/**\n * Calculates the delay interval for retry attempts using exponential delay with jitter.\n * @param retryAttempt - The current retry attempt number.\n * @param config - The exponential retry configuration.\n * @returns An object containing the calculated retry delay.\n */\nexport function calculateRetryDelay(\n retryAttempt: number,\n config: {\n retryDelayInMs: number;\n maxRetryDelayInMs: number;\n },\n): { retryAfterInMs: number } {\n // Exponentially increase the delay each time\n const exponentialDelay = config.retryDelayInMs * Math.pow(2, retryAttempt);\n\n // Don't let the delay exceed the maximum\n const clampedDelay = Math.min(config.maxRetryDelayInMs, exponentialDelay);\n\n // Allow the final value to have some \"jitter\" (within 50% of the delay size) so\n // that retries across multiple clients don't occur simultaneously.\n const retryAfterInMs = clampedDelay / 2 + getRandomIntegerInclusive(0, clampedDelay / 2);\n\n return { retryAfterInMs };\n}\n", "import { delay } from \"@azure/core-util\";\nimport EventEmitter from \"events\";\nimport { InvocationError, SendMessageError } from \"./errors/index.js\";\nimport { logger } from \"./logger.js\";\nimport { WebPubSubJsonReliableProtocol } from \"./protocols/index.js\";\nimport { WebSocketClientFactory } from \"./websocket/websocketClient.js\";\nimport { AckManager } from \"./ackManager.js\";\nimport { InvocationManager } from \"./invocationManager.js\";\nvar WebPubSubClientState = /* @__PURE__ */ ((WebPubSubClientState2) => {\n WebPubSubClientState2[\"Stopped\"] = \"Stopped\";\n WebPubSubClientState2[\"Disconnected\"] = \"Disconnected\";\n WebPubSubClientState2[\"Connecting\"] = \"Connecting\";\n WebPubSubClientState2[\"Connected\"] = \"Connected\";\n WebPubSubClientState2[\"Recovering\"] = \"Recovering\";\n return WebPubSubClientState2;\n})(WebPubSubClientState || {});\nclass WebPubSubClient {\n _protocol;\n _credential;\n _options;\n _groupMap;\n _ackManager;\n _invocationManager;\n _sequenceId;\n _messageRetryPolicy;\n _reconnectRetryPolicy;\n _quickSequenceAckDiff = 300;\n // The timeout for keep alive\n _keepAliveTimeoutInMs;\n // The interval at which to send keep-alive ping messages to the runtime\n _keepAliveIntervalInMs;\n _emitter = new EventEmitter();\n _state;\n _isStopping = false;\n _pingKeepaliveTask;\n _timeoutMonitorTask;\n // connection lifetime\n _wsClient;\n _uri;\n _lastCloseEvent;\n _lastDisconnectedMessage;\n _connectionId;\n _reconnectionToken;\n _isInitialConnected = false;\n _sequenceAckTask;\n _lastMessageReceived = Date.now();\n constructor(credential, options) {\n if (typeof credential === \"string\") {\n this._credential = { getClientAccessUrl: credential };\n } else {\n this._credential = credential;\n }\n if (options == null) {\n options = {};\n }\n this._buildDefaultOptions(options);\n this._options = options;\n this._messageRetryPolicy = new RetryPolicy(this._options.messageRetryOptions);\n this._reconnectRetryPolicy = new RetryPolicy(this._options.reconnectRetryOptions);\n this._protocol = this._options.protocol;\n this._groupMap = /* @__PURE__ */ new Map();\n this._ackManager = new AckManager();\n this._invocationManager = new InvocationManager();\n this._sequenceId = new SequenceId();\n this._keepAliveTimeoutInMs = this._options.keepAliveTimeoutInMs ?? 12e4;\n this._keepAliveIntervalInMs = this._options.keepAliveIntervalInMs ?? 2e4;\n this._state = \"Stopped\" /* Stopped */;\n }\n /**\n * Start to start to the service.\n * @param abortSignal - The abort signal\n */\n async start(options) {\n if (this._isStopping) {\n throw new Error(\"Can't start a client during stopping\");\n }\n if (this._state !== \"Stopped\" /* Stopped */) {\n throw new Error(\"Client can be only started when it's Stopped\");\n }\n let abortSignal;\n if (options) {\n abortSignal = options.abortSignal;\n }\n if (!this._pingKeepaliveTask && this._keepAliveIntervalInMs > 0) {\n this._pingKeepaliveTask = this._getPingKeepaliveTask();\n }\n if (!this._timeoutMonitorTask && this._keepAliveTimeoutInMs > 0) {\n this._timeoutMonitorTask = this._getTimeoutMonitorTask();\n }\n try {\n await this._startCore(abortSignal);\n } catch (err) {\n this._changeState(\"Stopped\" /* Stopped */);\n this._disposeKeepaliveTasks();\n this._isStopping = false;\n throw err;\n }\n }\n async _startFromRestarting(abortSignal) {\n if (this._state !== \"Disconnected\" /* Disconnected */) {\n throw new Error(\"Client can be only restarted when it's Disconnected\");\n }\n try {\n logger.verbose(\"Staring reconnecting.\");\n await this._startCore(abortSignal);\n } catch (err) {\n this._changeState(\"Disconnected\" /* Disconnected */);\n throw err;\n }\n }\n async _startCore(abortSignal) {\n this._changeState(\"Connecting\" /* Connecting */);\n logger.info(\"Staring a new connection\");\n this._sequenceId.reset();\n this._isInitialConnected = false;\n this._lastCloseEvent = void 0;\n this._lastDisconnectedMessage = void 0;\n this._connectionId = void 0;\n this._reconnectionToken = void 0;\n this._uri = void 0;\n if (typeof this._credential.getClientAccessUrl === \"string\") {\n this._uri = this._credential.getClientAccessUrl;\n } else {\n this._uri = await this._credential.getClientAccessUrl({\n abortSignal\n });\n }\n if (typeof this._uri !== \"string\") {\n throw new Error(\n `The clientAccessUrl must be a string but currently it's ${typeof this._uri}`\n );\n }\n await this._connectCore(this._uri);\n }\n /**\n * Stop the client.\n */\n stop() {\n if (this._state === \"Stopped\" /* Stopped */ || this._isStopping) {\n return;\n }\n this._isStopping = true;\n if (this._wsClient && this._wsClient.isOpen()) {\n this._wsClient.close();\n } else {\n this._isStopping = false;\n }\n this._disposeKeepaliveTasks();\n }\n _disposeKeepaliveTasks() {\n if (this._pingKeepaliveTask) {\n this._pingKeepaliveTask.abort();\n this._pingKeepaliveTask = void 0;\n }\n if (this._timeoutMonitorTask) {\n this._timeoutMonitorTask.abort();\n this._timeoutMonitorTask = void 0;\n }\n }\n on(event, listener) {\n this._emitter.on(event, listener);\n }\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n _emitEvent(event, args) {\n this._emitter.emit(event, args);\n }\n /**\n * Send custom event to server.\n * @param eventName - The event name\n * @param content - The data content\n * @param dataType - The data type\n * @param options - The options\n * @param abortSignal - The abort signal\n */\n async sendEvent(eventName, content, dataType, options) {\n return this._operationExecuteWithRetry(\n () => this._sendEventAttempt(eventName, content, dataType, options),\n options?.abortSignal\n );\n }\n async _sendEventAttempt(eventName, content, dataType, options) {\n const fireAndForget = options?.fireAndForget ?? false;\n if (!fireAndForget) {\n return this._sendMessageWithAckId(\n (id) => {\n return {\n kind: \"sendEvent\",\n dataType,\n data: content,\n ackId: id,\n event: eventName\n };\n },\n options?.ackId,\n options?.abortSignal\n );\n }\n const message = {\n kind: \"sendEvent\",\n dataType,\n data: content,\n event: eventName\n };\n await this._sendMessage(message, options?.abortSignal);\n return { isDuplicated: false };\n }\n async _invokeEventAttempt(eventName, content, dataType, options) {\n const invokeOptions = options ?? {};\n const { invocationId, wait } = this._invocationManager.registerInvocation(\n invokeOptions.invocationId\n );\n const invokeMessage = {\n kind: \"invoke\",\n invocationId,\n target: \"event\",\n event: eventName,\n dataType,\n data: content\n };\n const responsePromise = wait({\n abortSignal: invokeOptions.abortSignal\n });\n try {\n await this._sendMessage(invokeMessage, invokeOptions.abortSignal);\n } catch (err) {\n const invocationError = err instanceof InvocationError ? err : new InvocationError(\n err instanceof Error ? err.message : \"Failed to send invocation message.\",\n {\n invocationId\n }\n );\n this._invocationManager.rejectInvocation(invocationId, invocationError);\n void responsePromise.catch(() => {\n });\n throw invocationError;\n }\n try {\n const response = await responsePromise;\n return this._mapInvokeResponse(response);\n } catch (err) {\n const shouldCancel = err instanceof InvocationError && err.errorDetail == null || invokeOptions.abortSignal?.aborted === true;\n if (shouldCancel) {\n await this._sendCancelInvocation(invocationId).catch(() => {\n });\n }\n throw err;\n } finally {\n this._invocationManager.discard(invocationId);\n }\n }\n /**\n * Invoke an upstream event and wait for the correlated response.\n * @param eventName - The event name\n * @param content - The payload\n * @param dataType - The payload type\n * @param options - Invoke options\n */\n async invokeEvent(eventName, content, dataType, options) {\n return this._operationExecuteWithRetry(\n () => this._invokeEventAttempt(eventName, content, dataType, options),\n options?.abortSignal\n );\n }\n /**\n * Join the client to group\n * @param groupName - The group name\n * @param options - The join group options\n */\n async joinGroup(groupName, options) {\n return this._operationExecuteWithRetry(\n () => this._joinGroupAttempt(groupName, options),\n options?.abortSignal\n );\n }\n async _joinGroupAttempt(groupName, options) {\n const group = this._getOrAddGroup(groupName);\n const result = await this._joinGroupCore(groupName, options);\n group.isJoined = true;\n return result;\n }\n async _joinGroupCore(groupName, options) {\n return this._sendMessageWithAckId(\n (id) => {\n return {\n group: groupName,\n ackId: id,\n kind: \"joinGroup\"\n };\n },\n options?.ackId,\n options?.abortSignal\n );\n }\n /**\n * Leave the client from group\n * @param groupName - The group name\n * @param ackId - The optional ackId. If not specified, client will generate one.\n * @param abortSignal - The abort signal\n */\n async leaveGroup(groupName, options) {\n return this._operationExecuteWithRetry(\n () => this._leaveGroupAttempt(groupName, options),\n options?.abortSignal\n );\n }\n async _leaveGroupAttempt(groupName, options) {\n const group = this._getOrAddGroup(groupName);\n const result = await this._sendMessageWithAckId(\n (id) => {\n return {\n group: groupName,\n ackId: id,\n kind: \"leaveGroup\"\n };\n },\n options?.ackId,\n options?.abortSignal\n );\n group.isJoined = false;\n return result;\n }\n /**\n * Send message to group.\n * @param groupName - The group name\n * @param content - The data content\n * @param dataType - The data type\n * @param options - The options\n * @param abortSignal - The abort signal\n */\n async sendToGroup(groupName, content, dataType, options) {\n return this._operationExecuteWithRetry(\n () => this._sendToGroupAttempt(groupName, content, dataType, options),\n options?.abortSignal\n );\n }\n async _sendToGroupAttempt(groupName, content, dataType, options) {\n const fireAndForget = options?.fireAndForget ?? false;\n const noEcho = options?.noEcho ?? false;\n if (!fireAndForget) {\n return this._sendMessageWithAckId(\n (id) => {\n return {\n kind: \"sendToGroup\",\n group: groupName,\n dataType,\n data: content,\n ackId: id,\n noEcho\n };\n },\n options?.ackId,\n options?.abortSignal\n );\n }\n const message = {\n kind: \"sendToGroup\",\n group: groupName,\n dataType,\n data: content,\n noEcho\n };\n await this._sendMessage(message, options?.abortSignal);\n return { isDuplicated: false };\n }\n _getWebSocketClientFactory() {\n return new WebSocketClientFactory();\n }\n async _trySendSequenceAck() {\n if (!this._protocol.isReliableSubProtocol) {\n return;\n }\n const [isUpdated, seqId] = this._sequenceId.tryGetSequenceId();\n if (isUpdated && seqId !== null && seqId !== void 0) {\n const message = {\n kind: \"sequenceAck\",\n sequenceId: seqId\n };\n try {\n await this._sendMessage(message);\n } catch {\n this._sequenceId.tryUpdate(seqId);\n }\n }\n }\n _connectCore(uri) {\n if (this._isStopping) {\n throw new Error(\"Can't start a client during stopping\");\n }\n return new Promise((resolve, reject) => {\n const client = this._wsClient = this._getWebSocketClientFactory().create(\n uri,\n this._protocol.name\n );\n client.onopen(() => {\n if (this._isStopping) {\n try {\n client.close();\n } catch {\n }\n reject(new Error(`The client is stopped`));\n }\n logger.verbose(\"WebSocket connection has opened\");\n this._lastMessageReceived = Date.now();\n this._changeState(\"Connected\" /* Connected */);\n if (this._protocol.isReliableSubProtocol) {\n if (this._sequenceAckTask != null) {\n this._sequenceAckTask.abort();\n }\n this._sequenceAckTask = new AbortableTask(async () => {\n await this._trySendSequenceAck();\n }, 1e3);\n }\n resolve();\n });\n client.onerror((e) => {\n if (this._sequenceAckTask != null) {\n this._sequenceAckTask.abort();\n }\n reject(e);\n });\n client.onclose((code, reason) => {\n if (this._state === \"Connected\" /* Connected */) {\n logger.verbose(\"WebSocket closed after open\");\n if (this._sequenceAckTask != null) {\n this._sequenceAckTask.abort();\n }\n logger.info(`WebSocket connection closed. Code: ${code}, Reason: ${reason}`);\n this._lastCloseEvent = { code, reason };\n this._handleConnectionClose.call(this);\n } else {\n logger.verbose(\"WebSocket closed before open\");\n reject(new Error(`Failed to start WebSocket: ${code}`));\n }\n });\n client.onmessage((data) => {\n const handleAckMessage = (message) => {\n const isDuplicated = message.error != null && message.error.name === \"Duplicate\";\n if (message.success || isDuplicated) {\n this._ackManager.resolveAck(message.ackId, {\n ackId: message.ackId,\n isDuplicated\n });\n } else {\n this._ackManager.rejectAck(\n message.ackId,\n new SendMessageError(\"Failed to send message.\", {\n ackId: message.ackId,\n errorDetail: message.error\n })\n );\n }\n };\n const handleConnectedMessage = async (message) => {\n this._connectionId = message.connectionId;\n this._reconnectionToken = message.reconnectionToken;\n if (!this._isInitialConnected) {\n this._isInitialConnected = true;\n if (this._options.autoRejoinGroups) {\n const groupPromises = [];\n this._groupMap.forEach((g) => {\n if (g.isJoined) {\n groupPromises.push(\n (async () => {\n try {\n await this._joinGroupCore(g.name);\n } catch (err) {\n this._safeEmitRejoinGroupFailed(g.name, err);\n }\n })()\n );\n }\n });\n await Promise.all(groupPromises).catch(() => {\n });\n }\n this._safeEmitConnected(message.connectionId, message.userId);\n }\n };\n const handleDisconnectedMessage = (message) => {\n this._lastDisconnectedMessage = message;\n };\n const handleGroupDataMessage = (message) => {\n if (message.sequenceId != null) {\n const diff = this._sequenceId.tryUpdate(message.sequenceId);\n if (diff === 0) {\n return;\n }\n if (diff > this._quickSequenceAckDiff) {\n this._trySendSequenceAck();\n }\n }\n this._safeEmitGroupMessage(message);\n };\n const handleServerDataMessage = (message) => {\n if (message.sequenceId != null) {\n const diff = this._sequenceId.tryUpdate(message.sequenceId);\n if (diff === 0) {\n return;\n }\n if (diff > this._quickSequenceAckDiff) {\n this._trySendSequenceAck();\n }\n }\n this._safeEmitServerMessage(message);\n };\n const handleInvokeResponseMessage = (message) => {\n const resolved = this._invocationManager.resolveInvocation(message);\n if (!resolved) {\n logger.verbose(\n `Received invokeResponse for unknown invocationId: ${message.invocationId}`\n );\n }\n };\n this._lastMessageReceived = Date.now();\n let messages;\n try {\n let convertedData;\n if (Array.isArray(data)) {\n convertedData = Buffer.concat(data);\n } else {\n convertedData = data;\n }\n messages = this._protocol.parseMessages(convertedData);\n if (messages === null) {\n return;\n }\n } catch (err) {\n logger.warning(\"An error occurred while parsing the message from service\", err);\n throw err;\n }\n if (!Array.isArray(messages)) {\n messages = [messages];\n }\n messages.forEach((message) => {\n try {\n switch (message.kind) {\n case \"pong\": {\n break;\n }\n case \"ack\": {\n handleAckMessage(message);\n break;\n }\n case \"connected\": {\n handleConnectedMessage(message);\n break;\n }\n case \"disconnected\": {\n handleDisconnectedMessage(message);\n break;\n }\n case \"groupData\": {\n handleGroupDataMessage(message);\n break;\n }\n case \"serverData\": {\n handleServerDataMessage(message);\n break;\n }\n case \"invokeResponse\": {\n handleInvokeResponseMessage(message);\n break;\n }\n }\n } catch (err) {\n logger.warning(\n `An error occurred while handling the message with kind: ${message.kind} from service`,\n err\n );\n }\n });\n });\n });\n }\n async _handleConnectionCloseAndNoRecovery() {\n this._state = \"Disconnected\" /* Disconnected */;\n this._safeEmitDisconnected(this._connectionId, this._lastDisconnectedMessage);\n if (this._options.autoReconnect) {\n await this._autoReconnect();\n } else {\n await this._handleConnectionStopped();\n }\n }\n async _autoReconnect() {\n let isSuccess = false;\n let attempt = 0;\n try {\n while (!this._isStopping) {\n try {\n await this._startFromRestarting();\n isSuccess = true;\n break;\n } catch (err) {\n logger.warning(\"An attempt to reconnect connection failed.\", err);\n attempt++;\n const delayInMs = this._reconnectRetryPolicy.nextRetryDelayInMs(attempt);\n if (delayInMs == null) {\n break;\n }\n logger.verbose(`Delay time for reconnect attempt ${attempt}: ${delayInMs}`);\n await delay(delayInMs).catch(() => {\n });\n }\n }\n } finally {\n if (!isSuccess) {\n this._handleConnectionStopped();\n }\n }\n }\n _handleConnectionStopped() {\n this._isStopping = false;\n this._state = \"Stopped\" /* Stopped */;\n this._disposeKeepaliveTasks();\n this._safeEmitStopped();\n }\n async _trySendPing() {\n if (this._state !== \"Connected\" /* Connected */ || !this._wsClient?.isOpen()) {\n return;\n }\n const message = {\n kind: \"ping\"\n };\n try {\n await this._sendMessage(message);\n } catch {\n logger.warning(\"Failed to send keepalive message to the service\");\n }\n }\n async _checkKeepAliveTimeout() {\n if (this._state !== \"Connected\" /* Connected */ || !this._wsClient?.isOpen()) {\n return;\n }\n const now = Date.now();\n if (now - this._lastMessageReceived > this._keepAliveTimeoutInMs) {\n logger.warning(\n `No messages received for ${now - this._lastMessageReceived} ms. Closing. The keep alive timeout is set to ${this._keepAliveTimeoutInMs} ms.`\n );\n this._wsClient?.close();\n }\n }\n _getPingKeepaliveTask() {\n return new AbortableTask(async () => {\n await this._trySendPing();\n }, this._keepAliveIntervalInMs);\n }\n _getTimeoutMonitorTask() {\n const timeout = this._keepAliveTimeoutInMs;\n const checkInterval = Math.floor(timeout / 3);\n return new AbortableTask(async () => {\n await this._checkKeepAliveTimeout();\n }, checkInterval);\n }\n async _sendMessage(message, abortSignal) {\n if (!this._wsClient || !this._wsClient.isOpen()) {\n throw new Error(\"The connection is not connected.\");\n }\n const payload = this._protocol.writeMessage(message);\n await this._wsClient.send(payload, abortSignal);\n }\n async _sendMessageWithAckId(messageProvider, ackId, abortSignal) {\n const { ackId: resolvedAckId, wait } = this._ackManager.registerAck(ackId);\n const message = messageProvider(resolvedAckId);\n try {\n await this._sendMessage(message, abortSignal);\n } catch (error) {\n this._ackManager.discard(resolvedAckId);\n let errorMessage = \"\";\n if (error instanceof Error) {\n errorMessage = error.message;\n }\n throw new SendMessageError(errorMessage, { ackId: resolvedAckId });\n }\n return wait(abortSignal);\n }\n async _handleConnectionClose() {\n this._ackManager.rejectAll((ackId) => {\n return new SendMessageError(\n \"Connection is disconnected before receive ack from the service\",\n {\n ackId\n }\n );\n });\n this._invocationManager.rejectAll((invocationId) => {\n return new InvocationError(\n \"Connection is disconnected before receiving invoke response from the service\",\n {\n invocationId\n }\n );\n });\n if (this._isStopping) {\n logger.warning(\"The client is stopping state. Stop recovery.\");\n this._handleConnectionCloseAndNoRecovery();\n return;\n }\n if (this._lastCloseEvent && this._lastCloseEvent.code === 1008) {\n logger.warning(\"The websocket close with status code 1008. Stop recovery.\");\n this._handleConnectionCloseAndNoRecovery();\n return;\n }\n if (!this._protocol.isReliableSubProtocol) {\n logger.warning(\"The protocol is not reliable, recovery is not applicable\");\n this._handleConnectionCloseAndNoRecovery();\n return;\n }\n const recoveryUri = this._buildRecoveryUri();\n if (!recoveryUri) {\n logger.warning(\"Connection id or reconnection token is not available\");\n this._handleConnectionCloseAndNoRecovery();\n return;\n }\n let recovered = false;\n this._state = \"Recovering\" /* Recovering */;\n const abortSignal = AbortSignal.timeout(30 * 1e3);\n try {\n while (!abortSignal.aborted || this._isStopping) {\n try {\n await this._connectCore.call(this, recoveryUri);\n recovered = true;\n return;\n } catch {\n await delay(1e3);\n }\n }\n } finally {\n if (!recovered) {\n logger.warning(\"Recovery attempts failed more then 30 seconds or the client is stopping\");\n this._handleConnectionCloseAndNoRecovery();\n }\n }\n }\n _safeEmitConnected(connectionId, userId) {\n this._emitEvent(\"connected\", {\n connectionId,\n userId\n });\n }\n _safeEmitDisconnected(connectionId, lastDisconnectedMessage) {\n this._emitEvent(\"disconnected\", {\n connectionId,\n message: lastDisconnectedMessage\n });\n }\n _safeEmitGroupMessage(message) {\n this._emitEvent(\"group-message\", {\n message\n });\n }\n _safeEmitServerMessage(message) {\n this._emitEvent(\"server-message\", {\n message\n });\n }\n _safeEmitStopped() {\n this._emitEvent(\"stopped\", {});\n }\n _safeEmitRejoinGroupFailed(groupName, err) {\n this._emitEvent(\"rejoin-group-failed\", {\n group: groupName,\n error: err\n });\n }\n _mapInvokeResponse(message) {\n if (message.success !== true) {\n if (message.success === false) {\n throw new InvocationError(message.error?.message ?? \"Invocation failed.\", {\n invocationId: message.invocationId,\n errorDetail: message.error\n });\n }\n throw new InvocationError(\"Unsupported invoke response frame.\", {\n invocationId: message.invocationId\n });\n }\n return {\n invocationId: message.invocationId,\n dataType: message.dataType,\n data: message.data\n };\n }\n async _sendCancelInvocation(invocationId) {\n const message = {\n kind: \"cancelInvocation\",\n invocationId\n };\n try {\n await this._sendMessage(message);\n } catch (err) {\n logger.verbose(`Failed to send cancelInvocation for ${invocationId}`, err);\n }\n }\n _buildDefaultOptions(clientOptions) {\n if (clientOptions.autoReconnect == null) {\n clientOptions.autoReconnect = true;\n }\n if (clientOptions.autoRejoinGroups == null) {\n clientOptions.autoRejoinGroups = true;\n }\n if (clientOptions.protocol == null) {\n clientOptions.protocol = WebPubSubJsonReliableProtocol();\n }\n if (clientOptions.keepAliveTimeoutInMs == null) {\n clientOptions.keepAliveTimeoutInMs = 12e4;\n }\n if (clientOptions.keepAliveTimeoutInMs < 0) {\n throw new RangeError(\"keepAliveTimeoutInMs must be greater than or equal to 0.\");\n }\n if (clientOptions.keepAliveIntervalInMs == null) {\n clientOptions.keepAliveIntervalInMs = 2e4;\n }\n if (clientOptions.keepAliveIntervalInMs < 0) {\n throw new RangeError(\"keepAliveIntervalInMs must be greater than or equal to 0.\");\n }\n this._buildMessageRetryOptions(clientOptions);\n this._buildReconnectRetryOptions(clientOptions);\n return clientOptions;\n }\n _buildMessageRetryOptions(clientOptions) {\n if (!clientOptions.messageRetryOptions) {\n clientOptions.messageRetryOptions = {};\n }\n if (clientOptions.messageRetryOptions.maxRetries == null || clientOptions.messageRetryOptions.maxRetries < 0) {\n clientOptions.messageRetryOptions.maxRetries = 3;\n }\n if (clientOptions.messageRetryOptions.retryDelayInMs == null || clientOptions.messageRetryOptions.retryDelayInMs < 0) {\n clientOptions.messageRetryOptions.retryDelayInMs = 1e3;\n }\n if (clientOptions.messageRetryOptions.maxRetryDelayInMs == null || clientOptions.messageRetryOptions.maxRetryDelayInMs < 0) {\n clientOptions.messageRetryOptions.maxRetryDelayInMs = 3e4;\n }\n if (clientOptions.messageRetryOptions.mode == null) {\n clientOptions.messageRetryOptions.mode = \"Fixed\";\n }\n }\n _buildReconnectRetryOptions(clientOptions) {\n if (!clientOptions.reconnectRetryOptions) {\n clientOptions.reconnectRetryOptions = {};\n }\n if (clientOptions.reconnectRetryOptions.maxRetries == null || clientOptions.reconnectRetryOptions.maxRetries < 0) {\n clientOptions.reconnectRetryOptions.maxRetries = Number.MAX_VALUE;\n }\n if (clientOptions.reconnectRetryOptions.retryDelayInMs == null || clientOptions.reconnectRetryOptions.retryDelayInMs < 0) {\n clientOptions.reconnectRetryOptions.retryDelayInMs = 1e3;\n }\n if (clientOptions.reconnectRetryOptions.maxRetryDelayInMs == null || clientOptions.reconnectRetryOptions.maxRetryDelayInMs < 0) {\n clientOptions.reconnectRetryOptions.maxRetryDelayInMs = 3e4;\n }\n if (clientOptions.reconnectRetryOptions.mode == null) {\n clientOptions.reconnectRetryOptions.mode = \"Fixed\";\n }\n }\n _buildRecoveryUri() {\n if (this._connectionId && this._reconnectionToken && this._uri) {\n const url = new URL(this._uri);\n url.searchParams.append(\"awps_connection_id\", this._connectionId);\n url.searchParams.append(\"awps_reconnection_token\", this._reconnectionToken);\n return url.toString();\n }\n return null;\n }\n _getOrAddGroup(name) {\n if (!this._groupMap.has(name)) {\n this._groupMap.set(name, new WebPubSubGroup(name));\n }\n return this._groupMap.get(name);\n }\n _changeState(newState) {\n logger.verbose(\n `The client state transfer from ${this._state.toString()} to ${newState.toString()}`\n );\n this._state = newState;\n }\n async _operationExecuteWithRetry(inner, signal) {\n let retryAttempt = 0;\n while (true) {\n try {\n return await inner.call(this);\n } catch (err) {\n if (err instanceof InvocationError) {\n throw err;\n }\n retryAttempt++;\n const delayInMs = this._messageRetryPolicy.nextRetryDelayInMs(retryAttempt);\n if (delayInMs == null) {\n throw err;\n }\n await delay(delayInMs);\n if (signal?.aborted) {\n throw err;\n }\n }\n }\n }\n}\nclass RetryPolicy {\n _retryOptions;\n _maxRetriesToGetMaxDelay;\n constructor(retryOptions) {\n this._retryOptions = retryOptions;\n this._maxRetriesToGetMaxDelay = Math.ceil(\n Math.log2(this._retryOptions.maxRetryDelayInMs) - Math.log2(this._retryOptions.retryDelayInMs) + 1\n );\n }\n nextRetryDelayInMs(retryAttempt) {\n if (retryAttempt > this._retryOptions.maxRetries) {\n return null;\n } else {\n if (this._retryOptions.mode === \"Fixed\") {\n return this._retryOptions.retryDelayInMs;\n } else {\n return this._calculateExponentialDelay(retryAttempt);\n }\n }\n }\n _calculateExponentialDelay(attempt) {\n if (attempt >= this._maxRetriesToGetMaxDelay) {\n return this._retryOptions.maxRetryDelayInMs;\n } else {\n return (1 << attempt - 1) * this._retryOptions.retryDelayInMs;\n }\n }\n}\nclass WebPubSubGroup {\n name;\n isJoined = false;\n constructor(name) {\n this.name = name;\n }\n}\nclass SequenceId {\n _sequenceId;\n _isUpdate;\n constructor() {\n this._sequenceId = 0;\n this._isUpdate = false;\n }\n tryUpdate(sequenceId) {\n this._isUpdate = true;\n if (sequenceId > this._sequenceId) {\n const diff = sequenceId - this._sequenceId;\n this._sequenceId = sequenceId;\n return diff;\n }\n return 0;\n }\n tryGetSequenceId() {\n if (this._isUpdate) {\n this._isUpdate = false;\n return [true, this._sequenceId];\n }\n return [false, null];\n }\n reset() {\n this._sequenceId = 0;\n this._isUpdate = false;\n }\n}\nclass AbortableTask {\n _func;\n _abortController;\n _interval;\n _obj;\n constructor(func, interval, obj) {\n this._func = func;\n this._abortController = new AbortController();\n this._interval = interval;\n this._obj = obj;\n this._start();\n }\n abort() {\n try {\n this._abortController.abort();\n } catch {\n }\n }\n async _start() {\n const signal = this._abortController.signal;\n while (!signal.aborted) {\n try {\n await this._func(this._obj);\n } catch {\n } finally {\n await delay(this._interval);\n }\n }\n }\n}\nexport {\n WebPubSubClient\n};\n", "class SendMessageError extends Error {\n /**\n * Error name\n */\n name;\n /**\n * The ack id of the message\n */\n ackId;\n /**\n * The error details from the service\n */\n errorDetail;\n /**\n * Initialize a SendMessageError\n * @param message - The error message\n * @param ackMessage - The ack message\n */\n constructor(message, options) {\n super(message);\n this.name = \"SendMessageError\";\n this.ackId = options.ackId;\n this.errorDetail = options.errorDetail;\n }\n}\nclass InvocationError extends Error {\n /**\n * The invocation id of the request.\n */\n invocationId;\n /**\n * Error details from the service if available.\n */\n errorDetail;\n constructor(message, options) {\n super(message);\n this.name = \"InvocationError\";\n this.invocationId = options.invocationId;\n this.errorDetail = options.errorDetail;\n }\n}\nexport {\n InvocationError,\n SendMessageError\n};\n", "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { EOL } from \"node:os\";\nimport util from \"node:util\";\nimport process from \"node:process\";\n\nexport function log(message: unknown, ...args: any[]): void {\n process.stderr.write(`${util.format(message, ...args)}${EOL}`);\n}\n", "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { log } from \"#platform/log\";\nimport { getEnvironmentVariable } from \"#platform/env\";\n\n/**\n * A simple mechanism for enabling logging.\n * Intended to mimic the publicly available `debug` package.\n */\nexport interface Debug {\n /**\n * Creates a new logger with the given namespace.\n */\n (namespace: string): Debugger;\n /**\n * The default log method (defaults to console)\n */\n log: (...args: any[]) => void;\n /**\n * Enables a particular set of namespaces.\n * To enable multiple separate them with commas, e.g. \"info,debug\".\n * Supports wildcards, e.g. \"typeSpecRuntime:*\"\n * Supports skip syntax, e.g. \"typeSpecRuntime:*,-typeSpecRuntime:storage:*\" will enable\n * everything under typeSpecRuntime except for things under typeSpecRuntime:storage.\n */\n enable: (namespaces: string) => void;\n /**\n * Checks if a particular namespace is enabled.\n */\n enabled: (namespace: string) => boolean;\n /**\n * Disables all logging, returns what was previously enabled.\n */\n disable: () => string;\n}\n\n/**\n * A log function that can be dynamically enabled and redirected.\n */\nexport interface Debugger {\n /**\n * Logs the given arguments to the `log` method.\n */\n (...args: any[]): void;\n /**\n * True if this logger is active and logging.\n */\n enabled: boolean;\n /**\n * Used to cleanup/remove this logger.\n */\n destroy: () => boolean;\n /**\n * The current log method. Can be overridden to redirect output.\n */\n log: (...args: any[]) => void;\n /**\n * The namespace of this logger.\n */\n namespace: string;\n /**\n * Extends this logger with a child namespace.\n * Namespaces are separated with a ':' character.\n */\n extend: (namespace: string) => Debugger;\n}\n\nconst debugEnvVariable = getEnvironmentVariable(\"DEBUG\");\n\nlet enabledString: string | undefined;\nlet enabledNamespaces: string[] = [];\nlet skippedNamespaces: string[] = [];\nconst debuggers: Debugger[] = [];\n\nif (debugEnvVariable) {\n enable(debugEnvVariable);\n}\n\nconst debugObj: Debug = Object.assign(\n (namespace: string): Debugger => {\n return createDebugger(namespace);\n },\n {\n enable,\n enabled,\n disable,\n log,\n },\n);\n\nfunction enable(namespaces: string): void {\n enabledString = namespaces;\n enabledNamespaces = [];\n skippedNamespaces = [];\n const namespaceList = namespaces.split(\",\").map((ns) => ns.trim());\n for (const ns of namespaceList) {\n if (ns.startsWith(\"-\")) {\n skippedNamespaces.push(ns.substring(1));\n } else {\n enabledNamespaces.push(ns);\n }\n }\n for (const instance of debuggers) {\n instance.enabled = enabled(instance.namespace);\n }\n}\n\nfunction enabled(namespace: string): boolean {\n if (namespace.endsWith(\"*\")) {\n return true;\n }\n\n for (const skipped of skippedNamespaces) {\n if (namespaceMatches(namespace, skipped)) {\n return false;\n }\n }\n for (const enabledNamespace of enabledNamespaces) {\n if (namespaceMatches(namespace, enabledNamespace)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Given a namespace, check if it matches a pattern.\n * Patterns only have a single wildcard character which is *.\n * The behavior of * is that it matches zero or more other characters.\n */\nfunction namespaceMatches(namespace: string, patternToMatch: string): boolean {\n // simple case, no pattern matching required\n if (patternToMatch.indexOf(\"*\") === -1) {\n return namespace === patternToMatch;\n }\n\n let pattern = patternToMatch;\n\n // normalize successive * if needed\n if (patternToMatch.indexOf(\"**\") !== -1) {\n const patternParts = [];\n let lastCharacter = \"\";\n for (const character of patternToMatch) {\n if (character === \"*\" && lastCharacter === \"*\") {\n continue;\n } else {\n lastCharacter = character;\n patternParts.push(character);\n }\n }\n pattern = patternParts.join(\"\");\n }\n\n let namespaceIndex = 0;\n let patternIndex = 0;\n const patternLength = pattern.length;\n const namespaceLength = namespace.length;\n let lastWildcard = -1;\n let lastWildcardNamespace = -1;\n\n while (namespaceIndex < namespaceLength && patternIndex < patternLength) {\n if (pattern[patternIndex] === \"*\") {\n lastWildcard = patternIndex;\n patternIndex++;\n if (patternIndex === patternLength) {\n // if wildcard is the last character, it will match the remaining namespace string\n return true;\n }\n // now we let the wildcard eat characters until we match the next literal in the pattern\n while (namespace[namespaceIndex] !== pattern[patternIndex]) {\n namespaceIndex++;\n // reached the end of the namespace without a match\n if (namespaceIndex === namespaceLength) {\n return false;\n }\n }\n\n // now that we have a match, let's try to continue on\n // however, it's possible we could find a later match\n // so keep a reference in case we have to backtrack\n lastWildcardNamespace = namespaceIndex;\n namespaceIndex++;\n patternIndex++;\n continue;\n } else if (pattern[patternIndex] === namespace[namespaceIndex]) {\n // simple case: literal pattern matches so keep going\n patternIndex++;\n namespaceIndex++;\n } else if (lastWildcard >= 0) {\n // special case: we don't have a literal match, but there is a previous wildcard\n // which we can backtrack to and try having the wildcard eat the match instead\n patternIndex = lastWildcard + 1;\n namespaceIndex = lastWildcardNamespace + 1;\n // we've reached the end of the namespace without a match\n if (namespaceIndex === namespaceLength) {\n return false;\n }\n // similar to the previous logic, let's keep going until we find the next literal match\n while (namespace[namespaceIndex] !== pattern[patternIndex]) {\n namespaceIndex++;\n if (namespaceIndex === namespaceLength) {\n return false;\n }\n }\n lastWildcardNamespace = namespaceIndex;\n namespaceIndex++;\n patternIndex++;\n continue;\n } else {\n return false;\n }\n }\n\n const namespaceDone = namespaceIndex === namespace.length;\n const patternDone = patternIndex === pattern.length;\n // this is to detect the case of an unneeded final wildcard\n // e.g. the pattern `ab*` should match the string `ab`\n const trailingWildCard = patternIndex === pattern.length - 1 && pattern[patternIndex] === \"*\";\n return namespaceDone && (patternDone || trailingWildCard);\n}\n\nfunction disable(): string {\n const result = enabledString || \"\";\n enable(\"\");\n return result;\n}\n\nfunction createDebugger(namespace: string): Debugger {\n const newDebugger: Debugger = Object.assign(debug, {\n enabled: enabled(namespace),\n destroy,\n log: debugObj.log,\n namespace,\n extend,\n });\n\n function debug(...args: any[]): void {\n if (!newDebugger.enabled) {\n return;\n }\n if (args.length > 0) {\n args[0] = `${namespace} ${args[0]}`;\n }\n newDebugger.log(...args);\n }\n\n debuggers.push(newDebugger);\n\n return newDebugger;\n}\n\nfunction destroy(this: Debugger): boolean {\n const index = debuggers.indexOf(this);\n if (index >= 0) {\n debuggers.splice(index, 1);\n return true;\n }\n return false;\n}\n\nfunction extend(this: Debugger, namespace: string): Debugger {\n const newDebugger = createDebugger(`${this.namespace}:${namespace}`);\n newDebugger.log = this.log;\n return newDebugger;\n}\n\nexport default debugObj;\n", "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport debug from \"./debug.js\";\nimport { getEnvironmentVariable } from \"#platform/env\";\n\nimport type { Debugger } from \"./debug.js\";\nexport type { Debugger };\n\n/**\n * The log levels supported by the logger.\n * The log levels in order of most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\nexport type TypeSpecRuntimeLogLevel = \"verbose\" | \"info\" | \"warning\" | \"error\";\n\n/**\n * A TypeSpecRuntimeClientLogger is a function that can log to an appropriate severity level.\n */\nexport type TypeSpecRuntimeClientLogger = Debugger;\n\n/**\n * Defines the methods available on the SDK-facing logger.\n */\nexport interface TypeSpecRuntimeLogger {\n /**\n * Used for failures the program is unlikely to recover from,\n * such as Out of Memory.\n */\n error: Debugger;\n /**\n * Used when a function fails to perform its intended task.\n * Usually this means the function will throw an exception.\n * Not used for self-healing events (e.g. automatic retry)\n */\n warning: Debugger;\n /**\n * Used when a function operates normally.\n */\n info: Debugger;\n /**\n * Used for detailed troubleshooting scenarios. This is\n * intended for use by developers / system administrators\n * for diagnosing specific failures.\n */\n verbose: Debugger;\n}\n\n/**\n * todo doc\n */\nexport interface LoggerContext {\n /**\n * Immediately enables logging at the specified log level. If no level is specified, logging is disabled.\n * @param level - The log level to enable for logging.\n * Options from most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\n setLogLevel(logLevel?: TypeSpecRuntimeLogLevel): void;\n\n /**\n * Retrieves the currently specified log level.\n */\n getLogLevel(): TypeSpecRuntimeLogLevel | undefined;\n\n /**\n * Creates a logger for use by the SDKs that inherits from `TypeSpecRuntimeLogger`.\n * @param namespace - The name of the SDK package.\n * @hidden\n */\n createClientLogger(namespace: string): TypeSpecRuntimeLogger;\n\n /**\n * The TypeSpecRuntimeClientLogger provides a mechanism for overriding where logs are output to.\n * By default, logs are sent to stderr.\n * Override the `log` method to redirect logs to another location.\n */\n logger: TypeSpecRuntimeClientLogger;\n}\n\n/**\n * Option for creating a TypeSpecRuntimeLoggerContext.\n */\nexport interface CreateLoggerContextOptions {\n /**\n * The name of the environment variable to check for the log level.\n */\n logLevelEnvVarName: string;\n\n /**\n * The namespace of the logger.\n */\n namespace: string;\n}\n\nconst TYPESPEC_RUNTIME_LOG_LEVELS = [\"verbose\", \"info\", \"warning\", \"error\"];\n\ntype DebuggerWithLogLevel = Debugger & { level: TypeSpecRuntimeLogLevel };\n\nconst levelMap = {\n verbose: 400,\n info: 300,\n warning: 200,\n error: 100,\n};\n\nfunction patchLogMethod(\n parent: TypeSpecRuntimeClientLogger,\n child: TypeSpecRuntimeClientLogger | DebuggerWithLogLevel,\n): void {\n child.log = (...args) => {\n parent.log(...args);\n };\n}\n\nfunction isTypeSpecRuntimeLogLevel(level: string): level is TypeSpecRuntimeLogLevel {\n return TYPESPEC_RUNTIME_LOG_LEVELS.includes(level);\n}\n\n/**\n * Creates a logger context base on the provided options.\n * @param options - The options for creating a logger context.\n * @returns The logger context.\n */\nexport function createLoggerContext(options: CreateLoggerContextOptions): LoggerContext {\n const registeredLoggers = new Set<DebuggerWithLogLevel>();\n const logLevelFromEnv = getEnvironmentVariable(options.logLevelEnvVarName);\n\n let logLevel: TypeSpecRuntimeLogLevel | undefined;\n\n const clientLogger: TypeSpecRuntimeClientLogger = debug(options.namespace);\n clientLogger.log = (...args) => {\n debug.log(...args);\n };\n\n function contextSetLogLevel(level?: TypeSpecRuntimeLogLevel): void {\n if (level && !isTypeSpecRuntimeLogLevel(level)) {\n throw new Error(\n `Unknown log level '${level}'. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(\",\")}`,\n );\n }\n logLevel = level;\n\n const enabledNamespaces = [];\n for (const logger of registeredLoggers) {\n if (shouldEnable(logger)) {\n enabledNamespaces.push(logger.namespace);\n }\n }\n\n debug.enable(enabledNamespaces.join(\",\"));\n }\n\n if (logLevelFromEnv) {\n // avoid calling setLogLevel because we don't want a mis-set environment variable to crash\n if (isTypeSpecRuntimeLogLevel(logLevelFromEnv)) {\n contextSetLogLevel(logLevelFromEnv);\n } else {\n console.error(\n `${options.logLevelEnvVarName} set to unknown log level '${logLevelFromEnv}'; logging is not enabled. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(\n \", \",\n )}.`,\n );\n }\n }\n\n function shouldEnable(logger: DebuggerWithLogLevel): boolean {\n return Boolean(logLevel && levelMap[logger.level] <= levelMap[logLevel]);\n }\n\n function createLogger(\n parent: TypeSpecRuntimeClientLogger,\n level: TypeSpecRuntimeLogLevel,\n ): DebuggerWithLogLevel {\n const logger: DebuggerWithLogLevel = Object.assign(parent.extend(level), {\n level,\n });\n\n patchLogMethod(parent, logger);\n\n if (shouldEnable(logger)) {\n const enabledNamespaces = debug.disable();\n debug.enable(enabledNamespaces + \",\" + logger.namespace);\n }\n\n registeredLoggers.add(logger);\n\n return logger;\n }\n\n function contextGetLogLevel(): TypeSpecRuntimeLogLevel | undefined {\n return logLevel;\n }\n\n function contextCreateClientLogger(namespace: string): TypeSpecRuntimeLogger {\n const clientRootLogger: TypeSpecRuntimeClientLogger = clientLogger.extend(namespace);\n patchLogMethod(clientLogger, clientRootLogger);\n return {\n error: createLogger(clientRootLogger, \"error\"),\n warning: createLogger(clientRootLogger, \"warning\"),\n info: createLogger(clientRootLogger, \"info\"),\n verbose: createLogger(clientRootLogger, \"verbose\"),\n };\n }\n\n return {\n setLogLevel: contextSetLogLevel,\n getLogLevel: contextGetLogLevel,\n createClientLogger: contextCreateClientLogger,\n logger: clientLogger,\n };\n}\n\nconst context = createLoggerContext({\n logLevelEnvVarName: \"TYPESPEC_RUNTIME_LOG_LEVEL\",\n namespace: \"typeSpecRuntime\",\n});\n\n/**\n * Immediately enables logging at the specified log level. If no level is specified, logging is disabled.\n * @param level - The log level to enable for logging.\n * Options from most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const TypeSpecRuntimeLogger: TypeSpecRuntimeClientLogger = context.logger;\n\n/**\n * Retrieves the currently specified log level.\n */\nexport function setLogLevel(logLevel?: TypeSpecRuntimeLogLevel): void {\n context.setLogLevel(logLevel);\n}\n\n/**\n * Retrieves the currently specified log level.\n */\nexport function getLogLevel(): TypeSpecRuntimeLogLevel | undefined {\n return context.getLogLevel();\n}\n\n/**\n * Creates a logger for use by the SDKs that inherits from `TypeSpecRuntimeLogger`.\n * @param namespace - The name of the SDK package.\n * @hidden\n */\nexport function createClientLogger(namespace: string): TypeSpecRuntimeLogger {\n return context.createClientLogger(namespace);\n}\n", "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createLoggerContext } from \"@typespec/ts-http-runtime/internal/logger\";\n\nconst context = createLoggerContext({\n logLevelEnvVarName: \"AZURE_LOG_LEVEL\",\n namespace: \"azure\",\n});\n\n/**\n * The AzureLogger provides a mechanism for overriding where logs are output to.\n * By default, logs are sent to stderr.\n * Override the `log` method to redirect logs to another location.\n */\nexport const AzureLogger: AzureClientLogger = context.logger;\n\n/**\n * Immediately enables logging at the specified log level. If no level is specified, logging is disabled.\n * @param level - The log level to enable for logging.\n * Options from most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\nexport function setLogLevel(level?: AzureLogLevel): void {\n context.setLogLevel(level);\n}\n\n/**\n * Retrieves the currently specified log level.\n */\nexport function getLogLevel(): AzureLogLevel | undefined {\n return context.getLogLevel();\n}\n\n/**\n * Creates a logger for use by the Azure SDKs that inherits from `AzureLogger`.\n * @param namespace - The name of the SDK package.\n * @hidden\n */\nexport function createClientLogger(namespace: string): AzureLogger {\n return context.createClientLogger(namespace);\n}\n\n/**\n * A log function that can be dynamically enabled and redirected.\n */\nexport interface Debugger {\n /**\n * Logs the given arguments to the `log` method.\n */\n (...args: any[]): void;\n /**\n * True if this logger is active and logging.\n */\n enabled: boolean;\n /**\n * Used to cleanup/remove this logger.\n */\n destroy: () => boolean;\n /**\n * The current log method. Can be overridden to redirect output.\n */\n log: (...args: any[]) => void;\n /**\n * The namespace of this logger.\n */\n namespace: string;\n /**\n * Extends this logger with a child namespace.\n * Namespaces are separated with a ':' character.\n */\n extend: (namespace: string) => Debugger;\n}\n\n/**\n * The log levels supported by the logger.\n * The log levels in order of most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\nexport type AzureLogLevel = \"verbose\" | \"info\" | \"warning\" | \"error\";\n\n/**\n * An AzureClientLogger is a function that can log to an appropriate severity level.\n */\nexport type AzureClientLogger = Debugger;\n\n/**\n * Defines the methods available on the SDK-facing logger.\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport interface AzureLogger {\n /**\n * Used for failures the program is unlikely to recover from,\n * such as Out of Memory.\n */\n error: Debugger;\n /**\n * Used when a function fails to perform its intended task.\n * Usually this means the function will throw an exception.\n * Not used for self-healing events (e.g. automatic retry)\n */\n warning: Debugger;\n /**\n * Used when a function operates normally.\n */\n info: Debugger;\n /**\n * Used for detailed troubleshooting scenarios. This is\n * intended for use by developers / system administrators\n * for diagnosing specific failures.\n */\n verbose: Debugger;\n}\n", "import { createClientLogger } from \"@azure/logger\";\nconst logger = createClientLogger(\"web-pubsub-client\");\nexport {\n logger\n};\n", "import { Buffer } from \"buffer\";\nfunction parseMessages(input) {\n if (typeof input !== \"string\") {\n throw new Error(\"Invalid input for JSON hub protocol. Expected a string.\");\n }\n if (!input) {\n throw new Error(\"No input\");\n }\n const parsedMessage = JSON.parse(input);\n const typedMessage = parsedMessage;\n let returnMessage;\n if (typedMessage.type === \"system\") {\n if (typedMessage.event === \"connected\") {\n returnMessage = { ...parsedMessage, kind: \"connected\" };\n } else if (typedMessage.event === \"disconnected\") {\n returnMessage = { ...parsedMessage, kind: \"disconnected\" };\n } else {\n return null;\n }\n } else if (typedMessage.type === \"message\") {\n if (typedMessage.from === \"group\") {\n const data = parsePayload(parsedMessage.data, parsedMessage.dataType);\n if (data === null) {\n return null;\n }\n returnMessage = { ...parsedMessage, data, kind: \"groupData\" };\n } else if (typedMessage.from === \"server\") {\n const data = parsePayload(parsedMessage.data, parsedMessage.dataType);\n if (data === null) {\n return null;\n }\n returnMessage = {\n ...parsedMessage,\n data,\n kind: \"serverData\"\n };\n } else {\n return null;\n }\n } else if (typedMessage.type === \"ack\") {\n returnMessage = { ...parsedMessage, kind: \"ack\" };\n } else if (typedMessage.type === \"invokeResponse\") {\n let data;\n if (parsedMessage.dataType != null) {\n const parsedData = parsePayload(parsedMessage.data, parsedMessage.dataType);\n if (parsedData === null) {\n return null;\n }\n data = parsedData;\n }\n returnMessage = {\n kind: \"invokeResponse\",\n invocationId: parsedMessage.invocationId,\n success: parsedMessage.success,\n dataType: parsedMessage.dataType,\n data,\n error: parsedMessage.error\n };\n } else if (typedMessage.type === \"cancelInvocation\") {\n returnMessage = {\n ...parsedMessage,\n kind: \"cancelInvocation\"\n };\n } else if (typedMessage.type === \"pong\") {\n returnMessage = { ...parsedMessage, kind: \"pong\" };\n } else {\n return null;\n }\n return returnMessage;\n}\nfunction writeMessage(message) {\n let data;\n switch (message.kind) {\n case \"joinGroup\": {\n data = { type: \"joinGroup\", group: message.group, ackId: message.ackId };\n break;\n }\n case \"leaveGroup\": {\n data = { type: \"leaveGroup\", group: message.group, ackId: message.ackId };\n break;\n }\n case \"sendEvent\": {\n data = {\n type: \"event\",\n event: message.event,\n ackId: message.ackId,\n dataType: message.dataType,\n data: getPayload(message.data, message.dataType)\n };\n break;\n }\n case \"sendToGroup\": {\n data = {\n type: \"sendToGroup\",\n group: message.group,\n ackId: message.ackId,\n dataType: message.dataType,\n data: getPayload(message.data, message.dataType),\n noEcho: message.noEcho\n };\n break;\n }\n case \"sequenceAck\": {\n data = { type: \"sequenceAck\", sequenceId: message.sequenceId };\n break;\n }\n case \"invoke\": {\n const invokePayload = {\n type: \"invoke\",\n invocationId: message.invocationId,\n target: message.target,\n event: message.event\n };\n if (message.dataType != null && message.data != null) {\n invokePayload.dataType = message.dataType;\n invokePayload.data = getPayload(message.data, message.dataType);\n }\n data = invokePayload;\n break;\n }\n case \"invokeResponse\": {\n const invokeResponse = {\n type: \"invokeResponse\",\n invocationId: message.invocationId,\n success: message.success,\n error: message.error\n };\n if (message.dataType != null && message.data != null) {\n invokeResponse.dataType = message.dataType;\n invokeResponse.data = getPayload(message.data, message.dataType);\n }\n data = invokeResponse;\n break;\n }\n case \"cancelInvocation\": {\n data = {\n type: \"cancelInvocation\",\n invocationId: message.invocationId\n };\n break;\n }\n case \"ping\": {\n data = { type: \"ping\" };\n break;\n }\n default: {\n throw new Error(`Unsupported type: ${message.kind}`);\n }\n }\n return JSON.stringify(data);\n}\nfunction getPayload(data, dataType) {\n switch (dataType) {\n case \"text\": {\n if (typeof data !== \"string\") {\n throw new TypeError(\"Message must be a string.\");\n }\n return data;\n }\n case \"json\": {\n return data;\n }\n case \"binary\":\n case \"protobuf\": {\n if (data instanceof ArrayBuffer) {\n return Buffer.from(data).toString(\"base64\");\n }\n throw new TypeError(\"Message must be a ArrayBuffer\");\n }\n }\n}\nfunction parsePayload(data, dataType) {\n if (dataType === \"text\") {\n if (typeof data !== \"string\") {\n throw new TypeError(\"Message must be a string when dataType is text\");\n }\n return data;\n } else if (dataType === \"json\") {\n return data;\n } else if (dataType === \"binary\" || dataType === \"protobuf\") {\n const buf = Buffer.from(data, \"base64\");\n return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n } else {\n return null;\n }\n}\nexport {\n parseMessages,\n writeMessage\n};\n", "import * as base from \"./jsonProtocolBase.js\";\nclass WebPubSubJsonReliableProtocolImpl {\n /**\n * True if the protocol supports reliable features\n */\n isReliableSubProtocol = true;\n /**\n * The name of subprotocol. Name will be used in websocket subprotocol\n */\n name = \"json.reliable.webpubsub.azure.v1\";\n /**\n * Creates WebPubSubMessage objects from the specified serialized representation.\n * @param input - The serialized representation\n */\n parseMessages(input) {\n return base.parseMessages(input);\n }\n /**\n * Write WebPubSubMessage to string\n * @param message - The message to be written\n */\n writeMessage(message) {\n return base.writeMessage(message);\n }\n}\nexport {\n WebPubSubJsonReliableProtocolImpl\n};\n", "import { WebPubSubJsonProtocolImpl } from \"./webPubSubJsonProtocol.js\";\nimport { WebPubSubJsonReliableProtocolImpl } from \"./webPubSubJsonReliableProtocol.js\";\nconst WebPubSubJsonProtocol = () => {\n return new WebPubSubJsonProtocolImpl();\n};\nconst WebPubSubJsonReliableProtocol = () => {\n return new WebPubSubJsonReliableProtocolImpl();\n};\nexport {\n WebPubSubJsonProtocol,\n WebPubSubJsonReliableProtocol\n};\n", "import WebSocket from \"ws\";\nclass WebSocketClient {\n _socket;\n constructor(uri, protocolName) {\n this._socket = new WebSocket(uri, protocolName);\n this._socket.binaryType = \"arraybuffer\";\n }\n onopen(fn) {\n this._socket.onopen = fn;\n }\n onclose(fn) {\n this._socket.onclose = (event) => fn(event.code, event.reason);\n }\n onerror(fn) {\n this._socket.onerror = (event) => fn(event.error);\n }\n onmessage(fn) {\n this._socket.onmessage = (event) => fn(event.data);\n }\n close(code, reason) {\n this._socket.close(code, reason);\n }\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n send(data, _) {\n return new Promise((resolve, reject) => {\n this._socket.send(data, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n });\n });\n }\n isOpen() {\n return this._socket.readyState === WebSocket.OPEN;\n }\n}\nclass WebSocketClientFactory {\n create(uri, protocolName) {\n return new WebSocketClient(uri, protocolName);\n }\n}\nexport {\n WebSocketClient,\n WebSocketClientFactory\n};\n", "import { AbortError } from \"@azure/abort-controller\";\nasync function abortablePromise(promise, signal) {\n if (signal.aborted) {\n throw new AbortError(\"The operation was aborted.\");\n }\n let onAbort;\n const p = new Promise((_, reject) => {\n onAbort = () => {\n reject(new AbortError(\"The operation was aborted.\"));\n };\n signal.addEventListener(\"abort\", onAbort);\n });\n try {\n return await Promise.race([promise, p]);\n } finally {\n signal.removeEventListener(\"abort\", onAbort);\n }\n}\nexport {\n abortablePromise\n};\n", "import { SendMessageError } from \"./errors/index.js\";\nimport { abortablePromise } from \"./utils/abortablePromise.js\";\nclass AckManager {\n _ackEntries = /* @__PURE__ */ new Map();\n _ackId;\n constructor(initialAckId = 0) {\n this._ackId = initialAckId;\n }\n registerAck(ackId) {\n const resolvedAckId = ackId ?? this._generateAckId();\n let entry = this._ackEntries.get(resolvedAckId);\n if (!entry) {\n entry = new AckEntity(resolvedAckId);\n this._ackEntries.set(resolvedAckId, entry);\n }\n const ackEntry = entry;\n return {\n ackId: resolvedAckId,\n wait: (abortSignal) => this._waitForEntry(ackEntry, abortSignal)\n };\n }\n resolveAck(ackId, result) {\n const entry = this._ackEntries.get(ackId);\n if (!entry) {\n return false;\n }\n this._ackEntries.delete(ackId);\n entry.resolve(result);\n return true;\n }\n rejectAck(ackId, reason) {\n const entry = this._ackEntries.get(ackId);\n if (!entry) {\n return false;\n }\n this._ackEntries.delete(ackId);\n entry.reject(reason);\n return true;\n }\n discard(ackId) {\n this._ackEntries.delete(ackId);\n }\n rejectAll(createReason) {\n this._ackEntries.forEach((entry, ackId) => {\n if (this._ackEntries.delete(ackId)) {\n entry.reject(createReason(ackId));\n }\n });\n }\n _waitForEntry(entry, abortSignal) {\n if (!abortSignal) {\n return entry.promise();\n }\n return abortablePromise(entry.promise(), abortSignal).catch((err) => {\n if (err instanceof Error && err.name === \"AbortError\") {\n throw new SendMessageError(\"Cancelled by abortSignal\", { ackId: entry.ackId });\n }\n throw err;\n });\n }\n _generateAckId() {\n this._ackId += 1;\n return this._ackId;\n }\n}\nclass AckEntity {\n constructor(ackId) {\n this.ackId = ackId;\n this._promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n }\n _promise;\n _resolve;\n _reject;\n promise() {\n return this._promise;\n }\n resolve(value) {\n const callback = this._resolve;\n if (!callback) {\n return;\n }\n this._resolve = void 0;\n this._reject = void 0;\n callback(value);\n }\n reject(reason) {\n const callback = this._reject;\n if (!callback) {\n return;\n }\n this._resolve = void 0;\n this._reject = void 0;\n callback(reason);\n }\n}\nexport {\n AckManager\n};\n", "import { InvocationError } from \"./errors/index.js\";\nclass InvocationManager {\n _entries = /* @__PURE__ */ new Map();\n _nextId = 0;\n registerInvocation(invocationId) {\n const resolvedId = invocationId ?? this._generateInvocationId();\n if (this._entries.has(resolvedId)) {\n throw new InvocationError(\"Invocation id is already registered.\", {\n invocationId: resolvedId\n });\n }\n const entity = new InvocationEntity(resolvedId);\n this._entries.set(resolvedId, entity);\n return {\n invocationId: resolvedId,\n wait: (options) => this._waitForEntry(entity, options)\n };\n }\n resolveInvocation(message) {\n const entry = this._entries.get(message.invocationId);\n if (!entry) {\n return false;\n }\n this._entries.delete(message.invocationId);\n entry.resolve(message);\n return true;\n }\n rejectInvocation(invocationId, reason) {\n const entry = this._entries.get(invocationId);\n if (!entry) {\n return false;\n }\n this._entries.delete(invocationId);\n entry.reject(reason);\n return true;\n }\n discard(invocationId) {\n this._entries.delete(invocationId);\n }\n rejectAll(createReason) {\n this._entries.forEach((entry, invocationId) => {\n if (this._entries.delete(invocationId)) {\n entry.reject(createReason(invocationId));\n }\n });\n }\n _waitForEntry(entry, options) {\n const waitPromise = entry.promise();\n const abortSignal = options?.abortSignal;\n if (!abortSignal) {\n return waitPromise;\n }\n if (abortSignal.aborted) {\n if (this._entries.delete(entry.invocationId)) {\n entry.reject(this._createAbortError(entry.invocationId));\n }\n return waitPromise;\n }\n return new Promise((resolve, reject) => {\n const onAbort = () => {\n abortSignal.removeEventListener(\"abort\", onAbort);\n if (this._entries.delete(entry.invocationId)) {\n entry.reject(this._createAbortError(entry.invocationId));\n }\n };\n abortSignal.addEventListener(\"abort\", onAbort);\n waitPromise.then((result) => {\n abortSignal.removeEventListener(\"abort\", onAbort);\n return resolve(result);\n }).catch((err) => {\n abortSignal.removeEventListener(\"abort\", onAbort);\n return reject(err);\n });\n });\n }\n _generateInvocationId() {\n this._nextId += 1;\n return this._nextId.toString();\n }\n _createAbortError(invocationId) {\n return new InvocationError(\"Invocation cancelled by abortSignal.\", {\n invocationId\n });\n }\n}\nclass InvocationEntity {\n constructor(invocationId) {\n this.invocationId = invocationId;\n this._promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n }\n _promise;\n _resolve;\n _reject;\n promise() {\n return this._promise;\n }\n resolve(value) {\n const callback = this._resolve;\n if (!callback) {\n return;\n }\n this._resolve = void 0;\n this._reject = void 0;\n callback(value);\n }\n reject(reason) {\n const callback = this._reject;\n if (!callback) {\n return;\n }\n this._resolve = void 0;\n this._reject = void 0;\n callback(reason);\n }\n}\nexport {\n InvocationManager\n};\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n};\n", "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PageSettings, PagedAsyncIterableIterator, PagedResult } from \"./models.js\";\n\n/**\n * returns an async iterator that iterates over results. It also has a `byPage`\n * method that returns pages of items at once.\n *\n * @param pagedResult - an object that specifies how to get pages.\n * @returns a paged async iterator that iterates over results.\n */\n\nexport function getPagedAsyncIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n TLink = string,\n>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {\n const iter = getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(pagedResult);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage:\n pagedResult?.byPage ??\n (((settings?: PageSettings) => {\n const { continuationToken, maxPageSize } = settings ?? {};\n return getPageAsyncIterator(pagedResult, {\n pageLink: continuationToken as unknown as TLink | undefined,\n maxPageSize,\n });\n }) as unknown as (settings?: TPageSettings) => AsyncIterableIterator<TPage>),\n };\n}\n\nasync function* getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n): AsyncIterableIterator<TElement> {\n const pages = getPageAsyncIterator(pagedResult);\n const firstVal = await pages.next();\n // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is\n if (!Array.isArray(firstVal.value)) {\n // can extract elements from this page\n const { toElements } = pagedResult;\n if (toElements) {\n yield* toElements(firstVal.value) as TElement[];\n for await (const page of pages) {\n yield* toElements(page) as TElement[];\n }\n } else {\n yield firstVal.value;\n // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case\n yield* pages as unknown as AsyncIterableIterator<TElement>;\n }\n } else {\n yield* firstVal.value;\n for await (const page of pages) {\n // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,\n // it must be the case that `TPage = TElement[]`\n yield* page as unknown as TElement[];\n }\n }\n}\n\nasync function* getPageAsyncIterator<TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n options: {\n maxPageSize?: number;\n pageLink?: TLink;\n } = {},\n): AsyncIterableIterator<TPage> {\n const { pageLink, maxPageSize } = options;\n let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink, maxPageSize);\n if (!response) {\n return;\n }\n yield response.page;\n while (response.nextPageLink) {\n response = await pagedResult.getPage(response.nextPageLink, maxPageSize);\n if (!response) {\n return;\n }\n yield response.page;\n }\n}\n", "import { InvocationError, WebPubSubClient, WebPubSubClientCredential, WebPubSubDataType } from \"@azure/web-pubsub-client\";\nimport { getPagedAsyncIterator, type PagedAsyncIterableIterator, type PageSettings } from \"@azure/core-paging\";\nimport { EventEmitter } from \"events\";\nimport {\n RoomInfo as WireRoomInfo,\n RoomInfoWithMembers as WireRoomInfoWithMembers,\n UserProfile as WireUserProfile,\n MessageRangeQuery,\n Notification,\n NewMessageNotificationBody,\n NewRoomNotificationBody,\n SendMessageResponse,\n ManageRoomMemberRequest,\n MemberJoinedNotificationBody,\n MemberLeftNotificationBody,\n RoomLeftNotificationBody,\n} from \"./generatedTypes.js\";\nimport type { MessageInfo, RoomInfo, RoomDetail, UserProfile, SendMessageResult } from \"./models.js\";\nimport type {\n ChatMessage,\n OnMemberJoinedArgs,\n OnMemberLeftArgs,\n OnMessageArgs,\n OnRoomJoinedArgs,\n OnRoomLeftArgs,\n OnStartedArgs,\n OnStoppedArgs,\n} from \"./events.js\";\nimport type {\n ListRoomMessagesOptions,\n OperationOptions,\n StartOptions,\n GetRoomDetailOptions,\n CreateRoomOptions,\n SendToRoomOptions,\n GetUserProfileOptions,\n AddUserToRoomOptions,\n RemoveUserFromRoomOptions,\n} from \"./options.js\";\n\nimport { ERRORS, INVOCATION_NAME } from \"./constant.js\";\nimport { logger } from \"./logger.js\";\nimport { isWebPubSubClient } from \"./utils.js\";\n\n/**\n * Error thrown by `ChatClient` operations. Inspect {@link ChatError.code}\n * for a stable, machine-readable error code and compare it against\n * {@link KnownChatErrorCode} members rather than matching on the message.\n */\nclass ChatError extends Error {\n /** Stable, machine-readable error code. Compare against {@link KnownChatErrorCode}. */\n public readonly code: string;\n constructor(message: string, code: string) {\n super(message);\n this.name = \"ChatError\";\n this.code = code;\n }\n}\n\nclass PromiseCompletionSource {\n private readonly promise: Promise<void>;\n private resolvePromise!: () => void;\n\n public constructor() {\n this.promise = new Promise<void>((resolve) => {\n this.resolvePromise = resolve;\n });\n }\n\n public setResult(): void {\n this.resolvePromise();\n }\n\n public wait(): Promise<void> {\n return this.promise;\n }\n}\n\n/**\n * Client for building chat applications on Azure Web PubSub.\n *\n * A `ChatClient` wraps a `WebPubSubClient` and exposes a room-based chat\n * API: create and inspect rooms, manage members, send messages, page\n * through history, and subscribe to real-time chat events. It owns the\n * underlying connection's lifecycle \u2014 call {@link ChatClient.start} to\n * connect and authenticate, and {@link ChatClient.stop} to disconnect.\n *\n * Construct from a `WebPubSubClientCredential`, then call `start()` to\n * connect and authenticate.\n *\n * @example\n * ```ts\n * const client = new ChatClient(credential);\n * await client.start();\n * client.on(\"message\", (e) => console.log(e.message.content.text));\n * const room = await client.createRoom(\"My Room\", [\"bob\"]);\n * await client.sendToRoom(room.roomId, \"Hello!\");\n * ```\n */\nclass ChatClient {\n /** The underlying transport. Private \u2014 `ChatClient` builds and owns it. */\n private readonly _connection: WebPubSubClient;\n\n private readonly _emitter = new EventEmitter();\n private readonly _rooms = new Map<string, WireRoomInfo>();\n private _conversationIds = new Set<string>();\n private _userId: string | undefined;\n private _isStarted = false;\n private _startPromise: Promise<void> | undefined;\n // Created after the underlying connection starts so stop() can wait for the single \"stopped\" event.\n private _connectionStoppedTCS: PromiseCompletionSource | undefined;\n private _isConnectionStopping = false;\n\n /**\n * Create a `ChatClient` from a {@link WebPubSubClientCredential}.\n *\n * `ChatClient` builds and owns the underlying transport: `start()`\n * connects and authenticates, `stop()` disconnects. The instance is\n * created but not started \u2014 call `start()` to connect.\n *\n * @param credential - A `WebPubSubClientCredential` that yields a\n * client-access URL.\n */\n constructor(credential: WebPubSubClientCredential);\n // Implementation also accepts a pre-built connection (test seam); this is\n // not a public overload, so it does not appear in the public API surface.\n constructor(credentialOrConnection: WebPubSubClientCredential | WebPubSubClient) {\n this._connection = isWebPubSubClient(credentialOrConnection)\n ? credentialOrConnection\n : new WebPubSubClient(credentialOrConnection);\n this._connection.on(\"group-message\", (e) => {\n this._handleNotification(e.message.data as Notification);\n });\n this._connection.on(\"server-message\", (e) => {\n this._handleNotification(e.message.data as Notification);\n });\n this._connection.on(\"stopped\", () => {\n this._connectionStoppedTCS?.setResult();\n this._connectionStoppedTCS = undefined;\n this._isConnectionStopping = false;\n this.resetState();\n });\n }\n\n private async _handleNotification(data: Notification): Promise<void> {\n if (!this._isStarted && !this._startPromise) {\n return;\n }\n logger.info(\"Received notification:\", data);\n try {\n const type = data.notificationType;\n switch (type) {\n case \"MessageCreated\": {\n const body = data.body as NewMessageNotificationBody;\n if (!body.conversation.roomId) {\n logger.warning(\n `MessageCreated notification missing roomId; skipping emit. conversationId=${body.conversation.conversationId}`,\n );\n break;\n }\n const event: OnMessageArgs = {\n roomId: body.conversation.roomId,\n message: body.message as ChatMessage,\n };\n this._emitter.emit(\"message\", event);\n break;\n }\n case \"RoomJoined\": {\n const roomInfo = data.body as NewRoomNotificationBody as WireRoomInfo;\n // Add to _rooms first so listeners can use listRoomMessages\n this._rooms.set(roomInfo.roomId, roomInfo);\n const event: OnRoomJoinedArgs = { room: roomInfo };\n this._emitter.emit(\"room-joined\", event);\n break;\n }\n case \"RoomMemberJoined\": {\n const body = data.body as MemberJoinedNotificationBody;\n const event: OnMemberJoinedArgs = { roomId: body.roomId, title: body.title, userId: body.userId };\n this._emitter.emit(\"member-joined\", event);\n break;\n }\n // someone (not self) left a specific room\n case \"RoomMemberLeft\": {\n const body = data.body as MemberLeftNotificationBody;\n const event: OnMemberLeftArgs = { roomId: body.roomId, title: body.title, userId: body.userId };\n this._emitter.emit(\"member-left\", event);\n break;\n }\n // self left a specific room\n case \"RoomLeft\": {\n const body = data.body as RoomLeftNotificationBody;\n if (!this._rooms.has(body.roomId)) {\n break;\n }\n const event: OnRoomLeftArgs = { roomId: body.roomId, title: body.title };\n this._emitter.emit(\"room-left\", event);\n this._rooms.delete(body.roomId);\n break;\n }\n case \"MessageUpdated\":\n case \"MessageDeleted\":\n case \"RoomClosed\":\n case \"AddContact\":\n logger.warning(`Known notification type ${type} received but not implemented yet.`);\n break;\n default:\n logger.warning(`Unknown notification type received: ${type}`);\n }\n }\n catch (err) {\n logger.error(`Error processing notification, error = ${err}, data: `, data);\n }\n }\n\n /** Invoke server event and return typed data */\n private async invokeWithReturnType<T>(\n eventName: string,\n payload: any,\n dataType: WebPubSubDataType,\n options?: OperationOptions,\n ): Promise<T> {\n logger.verbose(`invoke event: '${eventName}', dataType: ${dataType}, payload:`, payload);\n try {\n const rawResponse = await this._connection.invokeEvent(eventName, payload, dataType, {\n abortSignal: options?.abortSignal,\n });\n logger.verbose(`invoke response for '${eventName}':`, rawResponse);\n const data = rawResponse.data as any;\n if (data && typeof data === \"object\" && typeof data.code === \"string\") {\n throw new ChatError(`Invocation of event \"${eventName}\" failed: ${data.code}`, data.code);\n }\n return data as T;\n } catch (e) {\n if (e instanceof ChatError) throw e;\n if (e instanceof InvocationError && e.errorDetail?.name) {\n throw new ChatError(e.message, e.errorDetail.name);\n }\n throw e;\n }\n }\n\n /**\n * Create a `ChatClient` and `start()` it in one step.\n *\n * @param clientAccessUrl - A client-access URL.\n * @param options - Optional cancellation token for the start operation.\n *\n * @example\n * ```ts\n * const chat = await ChatClient.start(clientAccessUrl);\n * ```\n */\n public static async start(clientAccessUrl: string, options?: StartOptions): Promise<ChatClient>;\n /**\n * Create a `ChatClient` and `start()` it in one step.\n *\n * @param credential - A `WebPubSubClientCredential` that yields a\n * client-access URL.\n * @param options - Optional cancellation token for the start operation.\n */\n public static async start(credential: WebPubSubClientCredential, options?: StartOptions): Promise<ChatClient>;\n public static async start(\n clientAccessUrlOrCredential: string | WebPubSubClientCredential,\n options?: StartOptions,\n ): Promise<ChatClient> {\n const credential: WebPubSubClientCredential =\n typeof clientAccessUrlOrCredential === \"string\"\n ? { getClientAccessUrl: async () => clientAccessUrlOrCredential }\n : clientAccessUrlOrCredential;\n const chatClient = new ChatClient(credential);\n await chatClient.start({ abortSignal: options?.abortSignal });\n return chatClient;\n }\n\n /**\n * Connect the underlying transport and authenticate with the chat\n * service.\n *\n * Idempotent: concurrent calls share a single in-flight promise, and\n * calls made on an already-started client resolve immediately. After\n * `stop()` the client can be started again; state from the previous\n * session is reset.\n *\n * @param options - Cancellation token for the start operation. Aborting\n * leaves the client in its initial (not-started) state.\n */\n public async start(options?: StartOptions): Promise<void> {\n if (this._startPromise) return this._startPromise;\n if (this._isStarted) return;\n\n if (this._connectionStoppedTCS && this._isConnectionStopping) {\n await this._connectionStoppedTCS.wait();\n // Another caller waiting on the same stop may have already started the restart.\n if (this._startPromise) return this._startPromise;\n if (this._isStarted) return;\n }\n\n const startPromise = this.startCore(options);\n this._startPromise = startPromise;\n try {\n await startPromise;\n } finally {\n if (this._startPromise === startPromise) {\n this._startPromise = undefined;\n }\n }\n }\n\n private async startCore(options?: StartOptions): Promise<void> {\n this.resetState();\n try {\n await this._connection.start({ abortSignal: options?.abortSignal });\n this._connectionStoppedTCS = new PromiseCompletionSource();\n this._isConnectionStopping = false;\n\n const loginResponse = await this.invokeWithReturnType<WireUserProfile>(\n INVOCATION_NAME.LOGIN,\n \"\",\n \"text\",\n options,\n );\n logger.info(\"loginResponse\", loginResponse);\n const conversationIds = new Set(loginResponse.conversationIds || []);\n const roomInfos = await Promise.all(\n (loginResponse.roomIds || []).map(async (roomId) => {\n const roomInfo = await this.fetchRoomDetail(roomId, {\n abortSignal: options?.abortSignal,\n withMembers: false,\n });\n return { roomId, roomInfo };\n }),\n );\n\n this._userId = loginResponse.userId;\n this._conversationIds = conversationIds;\n roomInfos.forEach(({ roomId, roomInfo }) => {\n this._rooms.set(roomId, roomInfo);\n });\n this._isStarted = true;\n const startedEvent: OnStartedArgs = { userId: loginResponse.userId };\n this._emitter.emit(\"started\", startedEvent);\n } catch (err) {\n this.resetState();\n await this.stopConnection();\n throw err;\n }\n }\n\n private ensureStarted(): void {\n if (!this._isStarted) {\n throw new ChatError(\"Not started. Please call start() first.\", ERRORS.NotStarted);\n }\n }\n\n /**\n * Fetch a user's profile.\n *\n * @param userId - Id of the user to look up.\n * @param options - Optional `{ abortSignal }`.\n */\n public async getUserProfile(userId: string, options?: GetUserProfileOptions): Promise<UserProfile> {\n this.ensureStarted();\n return this.invokeWithReturnType<WireUserProfile>(\n INVOCATION_NAME.GET_USER_PROPERTIES,\n { userId: userId },\n \"json\",\n options,\n );\n }\n\n private async sendToConversation(\n conversationId: string,\n message: string,\n options?: OperationOptions,\n ): Promise<SendMessageResult> {\n this.ensureStarted();\n const payload = {\n conversation: { conversationId: conversationId },\n content: message,\n };\n const resp = await this.invokeWithReturnType<SendMessageResponse>(\n INVOCATION_NAME.SEND_TEXT_MESSAGE,\n payload,\n \"json\",\n options,\n );\n if (!resp || !resp.id) {\n throw new ChatError(\n `Failed to send message to conversation ${conversationId}, got invalid invoke response: ${JSON.stringify(resp)}`,\n ERRORS.InvalidServerResponse,\n );\n }\n const msgId = resp.id;\n const roomId = Array.from(this._rooms.values()).find((r) => r.defaultConversationId === conversationId)?.roomId;\n if (!roomId) {\n logger.warning(\n `Failed to find roomId for conversationId ${conversationId} when sending message; skipping local sender-echo emit.`,\n );\n return { messageId: msgId };\n }\n // sender won't receive conversation message via notification mechanism, so emit event here\n const event: OnMessageArgs = {\n roomId,\n message: {\n messageId: msgId,\n createdBy: this.userId,\n messageBodyType: \"Inline\",\n content: {\n text: message,\n binary: null,\n },\n } as ChatMessage,\n };\n this._emitter.emit(\"message\", event);\n return { messageId: msgId };\n }\n\n /**\n * Send a text message to a room and return the service-assigned message id.\n *\n * The room must be one this client has created or joined. The sender also\n * observes the message through the `\"message\"` event.\n *\n * @param roomId - Target room.\n * @param message - Message text to send.\n * @param options - Optional `{ abortSignal }`.\n * @returns A {@link SendMessageResult} with the service-assigned `messageId`.\n */\n public async sendToRoom(roomId: string, message: string, options?: SendToRoomOptions): Promise<SendMessageResult> {\n this.ensureStarted();\n const conversationId = this._rooms.get(roomId)?.defaultConversationId;\n if (!conversationId) {\n throw new ChatError(`Failed to sendToRoom, not found roomId ${roomId}`, ERRORS.UnknownRoom);\n }\n return await this.sendToConversation(conversationId, message, options);\n }\n\n // Internal: fetch a room's full wire shape (including its conversation id)\n // to populate the local cache. Public callers go through getRoomDetail().\n private async fetchRoomDetail(roomId: string, options?: GetRoomDetailOptions): Promise<WireRoomInfoWithMembers> {\n return this.invokeWithReturnType<WireRoomInfoWithMembers>(\n INVOCATION_NAME.GET_ROOM,\n { id: roomId, withMembers: options?.withMembers ?? false },\n \"json\",\n options,\n );\n }\n\n /**\n * Fetch the detailed view of a room.\n *\n * @param roomId - Room to query.\n * @param options - Optional `{ withMembers, abortSignal }`. Pass\n * `withMembers: true` to populate the returned `members` list; it is\n * left undefined otherwise.\n */\n public async getRoomDetail(roomId: string, options?: GetRoomDetailOptions): Promise<RoomDetail> {\n this.ensureStarted();\n return this.fetchRoomDetail(roomId, options);\n }\n\n /**\n * Create a room and its initial members. The current user is always\n * included in the resulting member list.\n *\n * @param title - Display title for the room.\n * @param members - Other user ids to invite. The caller is added\n * automatically; duplicates are de-duplicated.\n * @param options - Optional `{ roomId, abortSignal }`. Pass `roomId`\n * to choose an id explicitly; omit to let the service assign one.\n */\n public async createRoom(\n title: string,\n members: string[],\n options?: CreateRoomOptions,\n ): Promise<RoomDetail> {\n this.ensureStarted();\n let roomDetails = {\n title: title,\n members: [...new Set([...members, this.userId])], // deduplicate and add self\n } as any;\n if (options?.roomId) {\n roomDetails = { ...roomDetails, roomId: options.roomId };\n }\n const roomInfo = await this.invokeWithReturnType<WireRoomInfoWithMembers>(\n INVOCATION_NAME.CREATE_ROOM,\n roomDetails,\n \"json\",\n options,\n );\n this._rooms.set(roomInfo.roomId, roomInfo);\n const event: OnRoomJoinedArgs = { room: roomInfo };\n this._emitter.emit(\"room-joined\", event);\n return roomInfo;\n }\n\n private async manageRoomMember(\n request: ManageRoomMemberRequest,\n options?: OperationOptions,\n ): Promise<void> {\n await this.invokeWithReturnType<any>(INVOCATION_NAME.MANAGE_ROOM_MEMBER, request, \"json\", options);\n }\n\n private async ensureRoomCached(roomId: string, options?: OperationOptions): Promise<void> {\n if (this._rooms.has(roomId)) {\n return;\n }\n const roomInfo = await this.fetchRoomDetail(roomId, options);\n this._rooms.set(roomId, roomInfo);\n }\n\n /** Add a user to a room. This is an admin operation where one user adds another user to a room. */\n public async addUserToRoom(roomId: string, userId: string, options?: AddUserToRoomOptions): Promise<void> {\n this.ensureStarted();\n const payload: ManageRoomMemberRequest = { roomId: roomId, operation: \"Add\", userId: userId };\n const isSelf = userId === this.userId;\n // If self-add succeeds but no RoomJoined notification arrives, fetch room info\n // from the service so sendToRoom can use its conversation id.\n const shouldCacheRoomAfterSelfAdd = isSelf && !this._rooms.has(roomId);\n try {\n await this.manageRoomMember(payload, options);\n } catch (error) {\n if (!isSelf || !(error instanceof ChatError && error.code === ERRORS.UserAlreadyInRoom)) {\n throw error;\n }\n }\n if (shouldCacheRoomAfterSelfAdd) {\n await this.ensureRoomCached(roomId, options);\n }\n }\n\n /** Remove a user from a room. This is an admin operation where one user removes another user from a room. */\n public async removeUserFromRoom(roomId: string, userId: string, options?: RemoveUserFromRoomOptions): Promise<void> {\n this.ensureStarted();\n const payload: ManageRoomMemberRequest = { roomId: roomId, operation: \"Delete\", userId: userId };\n await this.manageRoomMember(payload, options);\n // RoomLeft notification is not guaranteed for server-managed membership;\n // eagerly clean up local cache and emit RoomLeft so callers see consistent state immediately.\n if (userId === this.userId) {\n const roomInfo = this._rooms.get(roomId);\n if (roomInfo) {\n this._rooms.delete(roomId);\n const event: OnRoomLeftArgs = { roomId, title: roomInfo.title };\n this._emitter.emit(\"room-left\", event);\n }\n }\n }\n\n /**\n * List messages in a room as a paged async iterator.\n *\n * The iterator transparently fetches additional pages from the\n * service as you iterate. For Teams-style infinite scrolling, drive\n * the iterator one page at a time via `byPage(...)`:\n *\n * @example Stream every message (e.g. for export or full sync):\n * ```ts\n * for await (const msg of client.listRoomMessages(roomId)) {\n * console.log(msg.content.text);\n * }\n * ```\n *\n * @example Load history one page at a time (Teams-style scroll-back):\n * ```ts\n * // Load up to 50 messages per page.\n * const pages = client.listRoomMessages(roomId).byPage({ maxPageSize: 50 });\n * const first = await pages.next();\n * displayMessages(first.value);\n * // later, when the user scrolls up:\n * const more = await pages.next();\n * displayMessages(more.value);\n * ```\n *\n * The room must be one this client has created or joined.\n */\n public listRoomMessages(roomId: string, options?: ListRoomMessagesOptions): PagedAsyncIterableIterator<MessageInfo> {\n this.ensureStarted();\n const conversationId = this._rooms.get(roomId)?.defaultConversationId;\n if (!conversationId) {\n throw new ChatError(`Failed to listRoomMessages, not found roomId ${roomId}`, ERRORS.UnknownRoom);\n }\n\n const defaultPageSize = options?.maxPageSize ?? 100;\n const firstPageLink: MessageRangeQuery = {\n conversation: { conversationId },\n start: options?.startId ?? null,\n end: options?.endId ?? null,\n maxCount: defaultPageSize,\n };\n\n const fetchPage = async (\n link: MessageRangeQuery,\n maxPageSize?: number,\n ): Promise<{ page: MessageInfo[]; nextPageLink?: MessageRangeQuery } | undefined> => {\n const query: MessageRangeQuery = {\n ...link,\n maxCount: maxPageSize ?? link.maxCount ?? defaultPageSize,\n };\n const result = await this.invokeWithReturnType<{ messages: MessageInfo[]; nextQuery: MessageRangeQuery | null }>(\n INVOCATION_NAME.LIST_MESSAGES,\n query,\n \"json\",\n { abortSignal: options?.abortSignal },\n );\n if (result.messages.length === 0) {\n return undefined;\n }\n return { page: result.messages, nextPageLink: result.nextQuery ?? undefined };\n };\n\n return getPagedAsyncIterator<MessageInfo, MessageInfo[], PageSettings, MessageRangeQuery>({\n firstPageLink,\n getPage: (link, maxPageSize) => fetchPage(link, maxPageSize),\n });\n }\n\n /** Cached rooms known to the client. */\n public get rooms(): RoomInfo[] {\n return Array.from(this._rooms.values());\n }\n\n /** Whether the current client has the room in its local joined-room cache. */\n public hasJoinedRoom(roomId: string): boolean {\n return this._rooms.has(roomId);\n }\n\n /**\n * The chat-domain identity of this client, established by `start()`.\n *\n * @throws `ChatError` with code `NotStarted` if the client is not started.\n */\n public get userId(): string {\n if (!this._userId) {\n throw new ChatError(\"User ID is not set. Please call start() first.\", ERRORS.NotStarted);\n }\n return this._userId;\n }\n\n /**\n * Subscribe to a chat-client event.\n *\n * Mirrors the underlying `WebPubSubClient.on(event, listener)` shape:\n * one explicit overload per event, returns `void`, paired with\n * `off(event, listener)` for removal. Pass the same callback\n * reference to `off()` to unsubscribe.\n *\n * Chat-lifecycle events `started` and `stopped` are exposed here.\n * Lower-level transport-connection events (`connected`,\n * `disconnected`) are managed internally and are not exposed on the\n * public surface.\n *\n * @example\n * ```ts\n * const onMsg = (e: OnMessageArgs) => console.log(e.message.content.text);\n * client.on(\"message\", onMsg);\n * // later\n * client.off(\"message\", onMsg);\n * ```\n */\n public on(event: \"started\", listener: (e: OnStartedArgs) => void): void;\n /** Subscribe to the `stopped` event, fired when the client transitions from started to not-started. */\n public on(event: \"stopped\", listener: (e: OnStoppedArgs) => void): void;\n /** Subscribe to the `message` event, fired when a message arrives in a joined room. */\n public on(event: \"message\", listener: (e: OnMessageArgs) => void): void;\n /** Subscribe to the `room-joined` event, fired when this client joins a room. */\n public on(event: \"room-joined\", listener: (e: OnRoomJoinedArgs) => void): void;\n /** Subscribe to the `room-left` event, fired when this client leaves a room. */\n public on(event: \"room-left\", listener: (e: OnRoomLeftArgs) => void): void;\n /** Subscribe to the `member-joined` event, fired when another user joins a room this client is in. */\n public on(event: \"member-joined\", listener: (e: OnMemberJoinedArgs) => void): void;\n /** Subscribe to the `member-left` event, fired when another user leaves a room this client is in. */\n public on(event: \"member-left\", listener: (e: OnMemberLeftArgs) => void): void;\n public on(event: string, listener: (e: any) => void): void {\n this._emitter.on(event, listener);\n }\n\n /** Remove a `started` listener previously registered with `on()`. */\n public off(event: \"started\", listener: (e: OnStartedArgs) => void): void;\n /** Remove a `stopped` listener previously registered with `on()`. */\n public off(event: \"stopped\", listener: (e: OnStoppedArgs) => void): void;\n /** Remove a `message` listener previously registered with `on()`. */\n public off(event: \"message\", listener: (e: OnMessageArgs) => void): void;\n /** Remove a `room-joined` listener previously registered with `on()`. */\n public off(event: \"room-joined\", listener: (e: OnRoomJoinedArgs) => void): void;\n /** Remove a `room-left` listener previously registered with `on()`. */\n public off(event: \"room-left\", listener: (e: OnRoomLeftArgs) => void): void;\n /** Remove a `member-joined` listener previously registered with `on()`. */\n public off(event: \"member-joined\", listener: (e: OnMemberJoinedArgs) => void): void;\n /** Remove a `member-left` listener previously registered with `on()`. */\n public off(event: \"member-left\", listener: (e: OnMemberLeftArgs) => void): void;\n public off(event: string, listener: (e: any) => void): void {\n this._emitter.off(event, listener);\n }\n\n /**\n * Stop the underlying connection and reset client state. Idempotent.\n *\n * After resolution the client returns to its initial state and may\n * be started again via `start()`. Callers that want the same identity\n * should keep their authentication source (URL or credential)\n * constant.\n *\n * Stopping is not cancellable: it tears down the transport and clears\n * local state, mirroring the underlying `WebPubSubClient.stop()`, which\n * takes no options.\n */\n public async stop(): Promise<void> {\n const startPromise = this._startPromise;\n if (startPromise) {\n await startPromise.catch(() => undefined);\n }\n this._startPromise = undefined;\n\n this.resetState();\n await this.stopConnection();\n }\n\n /**\n * Reset chat-domain state. Emits `\"stopped\"` exactly once per\n * started \u2192 not-started transition: if `_isStarted` was already\n * false on entry (e.g. the pre-start guard inside `startCore()` or\n * the post-failure rollback), no event fires.\n */\n private resetState(): void {\n const wasStarted = this._isStarted;\n this._isStarted = false;\n this._userId = undefined;\n this._rooms.clear();\n this._conversationIds.clear();\n if (wasStarted) {\n const stoppedEvent: OnStoppedArgs = {};\n this._emitter.emit(\"stopped\", stoppedEvent);\n }\n }\n\n private async stopConnection(): Promise<void> {\n const connectionStoppedTCS = this._connectionStoppedTCS;\n if (!connectionStoppedTCS) {\n return;\n }\n\n if (!this._isConnectionStopping) {\n this._isConnectionStopping = true;\n try {\n this._connection.stop();\n } catch (err) {\n this._isConnectionStopping = false;\n throw err;\n }\n }\n await connectionStoppedTCS.wait();\n }\n}\n\nexport { ChatClient, ChatError };\n", "const INVOCATION_NAME = {\n LOGIN: \"chat.login\",\n LIST_USER_CONVERSATION: \"chat.listUserConversation\",\n GET_USER_PROPERTIES: \"chat.getUserProperties\",\n GET_ROOM: \"chat.getRoom\",\n LIST_MESSAGES: \"chat.queryMessageHistory\",\n SEND_TEXT_MESSAGE: \"chat.sendTextMessage\",\n CREATE_ROOM: \"chat.createRoom\",\n JOIN_ROOM: \"chat.joinRoom\",\n MANAGE_ROOM_MEMBER: \"chat.manageRoomMember\",\n} as const;\n\nconst ERRORS = {\n RoomAlreadyExists: \"RoomAlreadyExists\",\n UserAlreadyInRoom: \"UserAlreadyInRoom\",\n NoPermissionInRoom: \"NoPermissionInRoom\",\n NotStarted: \"NotStarted\",\n UnknownRoom: \"UnknownRoom\",\n InvalidServerResponse: \"InvalidServerResponse\",\n} as const;\n\nexport { INVOCATION_NAME, ERRORS };\n", "import { createClientLogger } from \"@azure/logger\";\n\n/**\n * The \\@azure\\/logger configuration for this package.\n */\nexport const logger = createClientLogger(\"web-pubsub-chat-client:*\");\n", "import { WebPubSubClient } from \"@azure/web-pubsub-client\";\n\nexport function decodeMessageBody(base64: string | null | undefined): string {\n if (!base64) return \"\";\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(base64, 'base64').toString('utf-8');\n }\n // compatibility for browser environment\n return decodeURIComponent(escape(atob(base64))); \n}\n\n\n/**\n * Type guard for WebPubSubClient.\n * We avoid using `instanceof` because it can fail in scenarios with multiple\n * dependency copies (e.g., monorepo with yarn/pnpm link) or across different\n * execution contexts (iframe, worker). Instead, we check for stable public\n * methods to ensure reliable detection.\n */\nexport function isWebPubSubClient(obj: unknown): obj is WebPubSubClient {\n if (typeof obj !== \"object\" || obj === null) return false;\n const anyObj = obj as any;\n return (\n typeof anyObj === \"object\" &&\n (\n typeof anyObj.start === \"function\" || \n typeof anyObj.stop === \"function\" || \n typeof anyObj.on === \"function\"\n )\n );\n}", "import { ChatClient, ChatError } from './chatClient.js';\nimport { ERRORS } from './constant.js';\n\nexport type {\n MessageInfo,\n RoomInfo,\n RoomDetail,\n UserProfile,\n SendMessageResult,\n} from './models.js';\n\nexport type {\n ChatMessage,\n OnMessageArgs,\n OnRoomJoinedArgs,\n OnRoomLeftArgs,\n OnMemberJoinedArgs,\n OnMemberLeftArgs,\n OnStartedArgs,\n OnStoppedArgs,\n} from './events.js';\n\nexport type {\n OperationOptions,\n StartOptions,\n GetRoomDetailOptions,\n CreateRoomOptions,\n SendToRoomOptions,\n GetUserProfileOptions,\n AddUserToRoomOptions,\n RemoveUserFromRoomOptions,\n ListRoomMessagesOptions,\n} from './options.js';\n\n/**\n * Known values of `ChatError.code`. Following the Azure SDK\n * `Known<Name>` convention, this is a runtime constants object whose\n * values are the wire codes returned by the chat service. Compare\n * `error.code` against members of this object rather than against\n * string literals.\n *\n * @example\n * ```ts\n * try {\n * await client.sendToRoom(roomId, \"hi\");\n * } catch (err) {\n * if (err instanceof ChatError && err.code === KnownChatErrorCode.UnknownRoom) {\n * // ...\n * }\n * }\n * ```\n *\n * The service may add codes in newer versions, so always handle the\n * unknown-code case as well.\n */\nexport const KnownChatErrorCode = ERRORS;\n\nexport { ChatClient, ChatError };\n\n"],
5
+ "mappings": ";;;;;AAGA,OAAO,aAAa;AAkBd,SAAU,uBAAuB,MAAY;AACjD,SAAO,QAAQ,IAAI,IAAI;AACzB;AAwBO,IAAM,SAAS,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,SAAS,IAAI,OAAO,QAAQ;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAa,OAAsB;AACjC,UAAM,eAAe,KAAK;AAC1B,QAAI,cAAc;AAChB,YAAM,aAAa,MAAM,MAAM,MAAS;AAAA,IAC1C;AACA,SAAK,gBAAgB;AAErB,SAAK,WAAW;AAChB,UAAM,KAAK,eAAe;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,aAAmB;AACzB,UAAM,aAAa,KAAK;AACxB,SAAK,aAAa;AAClB,SAAK,UAAU;AACf,SAAK,OAAO,MAAM;AAClB,SAAK,iBAAiB,MAAM;AAC5B,QAAI,YAAY;AACd,YAAM,eAA8B,CAAC;AACrC,WAAK,SAAS,KAAK,WAAW,YAAY;AAAA,IAC5C;AAAA,EACF;AAAA,EAEA,MAAc,iBAAgC;AAC5C,UAAM,uBAAuB,KAAK;AAClC,QAAI,CAAC,sBAAsB;AACzB;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,uBAAuB;AAC/B,WAAK,wBAAwB;AAC7B,UAAI;AACF,aAAK,YAAY,KAAK;AAAA,MACxB,SAAS,KAAK;AACZ,aAAK,wBAAwB;AAC7B,cAAM;AAAA,MACR;AAAA,IACF;AACA,UAAM,qBAAqB,KAAK;AAAA,EAClC;AACF;;;AIzrBO,IAAM,qBAAqB;",
6
+ "names": ["process", "enabledNamespaces", "logger", "context", "context", "Buffer", "v", "EventEmitter", "logger", "EventEmitter", "logger"]
7
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The \@azure\/logger configuration for this package.
3
+ */
4
+ export declare const logger: import("@azure/logger").AzureLogger;
5
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,MAAM,qCAAiD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=modelGuards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelGuards.d.ts","sourceRoot":"","sources":["../src/modelGuards.ts"],"names":[],"mappings":""}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Public domain model types for the chat client.
3
+ *
4
+ * These are hand-curated, standalone shapes that make up the SDK's public
5
+ * surface. They expose a curated *subset* of the wire schemas in
6
+ * `generatedTypes.ts` — an internal, auto-generated file — declared
7
+ * independently so the generated OpenAPI aggregates (`components`,
8
+ * `Schemas`, `paths`, ...) never leak into the public API. Internal-only
9
+ * concepts (e.g. conversation ids) are intentionally omitted here even
10
+ * though the wire types still carry them.
11
+ *
12
+ * A compile-time guard in `modelGuards.ts` fails the build if any field
13
+ * these models *do* expose drifts out of sync with the generated wire
14
+ * types, so regenerating the schema (`npm run generate:types`) surfaces
15
+ * shape changes here instead of silently diverging.
16
+ */
17
+ /** A single chat message. */
18
+ export interface MessageInfo {
19
+ /** Service-assigned message id, unique and monotonically increasing within a conversation. */
20
+ messageId: string;
21
+ /** User id of the sender. */
22
+ createdBy?: string;
23
+ /** Creation timestamp, as returned by the service. */
24
+ createdAt?: string;
25
+ /** Body type of the message (service-defined). */
26
+ bodyType?: string;
27
+ /** Concrete body type of the message (service-defined). */
28
+ messageBodyType: string;
29
+ /** Message payload. Text messages populate `text`; binary messages populate `binary`. */
30
+ content: {
31
+ text?: string | null;
32
+ binary?: string | null;
33
+ };
34
+ /** Id of the message this one references (e.g. a reply), when applicable. */
35
+ refMessageId?: string | null;
36
+ }
37
+ /** Metadata describing a room. */
38
+ export interface RoomInfo {
39
+ /** Unique room id. */
40
+ roomId: string;
41
+ /** Display title of the room. */
42
+ title: string;
43
+ /** Free-form room properties, when set. */
44
+ properties?: Record<string, never> | null;
45
+ }
46
+ /**
47
+ * The detailed view of a room: a {@link RoomInfo} plus, optionally, its
48
+ * member list. Returned by `createRoom()` and `getRoomDetail()`. Reserved
49
+ * to grow with further room detail (e.g. conversations) over time.
50
+ */
51
+ export interface RoomDetail extends RoomInfo {
52
+ /**
53
+ * User ids of the room's members. Populated when the members were
54
+ * requested (e.g. `getRoomDetail(..., { withMembers: true })`) and
55
+ * `undefined` otherwise.
56
+ */
57
+ members?: string[];
58
+ }
59
+ /** Profile of a chat user. */
60
+ export interface UserProfile {
61
+ /** The user's id. */
62
+ userId: string;
63
+ /** Ids of rooms the user belongs to. */
64
+ roomIds?: string[];
65
+ }
66
+ /** Result of sending a message, returned by `sendToRoom()`. */
67
+ export interface SendMessageResult {
68
+ /** Service-assigned id of the sent message. */
69
+ messageId: string;
70
+ }
71
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,6BAA6B;AAC7B,MAAM,WAAW,WAAW;IAC1B,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,eAAe,EAAE,MAAM,CAAC;IACxB,yFAAyF;IACzF,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;IACF,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,kCAAkC;AAClC,MAAM,WAAW,QAAQ;IACvB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;CAC3C;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC1C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,8BAA8B;AAC9B,MAAM,WAAW,WAAW;IAC1B,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Options-object types for `ChatClient` methods.
3
+ *
4
+ * Every asynchronous method accepts an options bag extending
5
+ * {@link OperationOptions} with at least an `abortSignal`. Future
6
+ * per-operation knobs (custom headers, retry policy, ...) live on
7
+ * these interfaces too.
8
+ */
9
+ import type { AbortSignalLike } from "@azure/abort-controller";
10
+ /** Base options accepted by every asynchronous `ChatClient` operation. */
11
+ export interface OperationOptions {
12
+ /**
13
+ * Signal used to cancel the operation. Accepts either a browser
14
+ * `AbortSignal` or `@azure/abort-controller`'s polyfill.
15
+ */
16
+ abortSignal?: AbortSignalLike;
17
+ }
18
+ /** Options for `ChatClient.start()`. */
19
+ export interface StartOptions extends OperationOptions {
20
+ }
21
+ /** Options for `ChatClient.getRoomDetail()`. */
22
+ export interface GetRoomDetailOptions extends OperationOptions {
23
+ /**
24
+ * When `true`, the returned {@link RoomDetail}'s `members` array is
25
+ * populated. Defaults to `false`, leaving `members` undefined.
26
+ */
27
+ withMembers?: boolean;
28
+ }
29
+ /** Options for `ChatClient.createRoom()`. */
30
+ export interface CreateRoomOptions extends OperationOptions {
31
+ /**
32
+ * Optional client-chosen room id. If omitted, the service assigns a
33
+ * random id. The id must be unique within the hub; reusing an
34
+ * existing id rejects with `KnownChatErrorCode.RoomAlreadyExists`.
35
+ */
36
+ roomId?: string;
37
+ }
38
+ /** Options for `ChatClient.sendToRoom()`. */
39
+ export interface SendToRoomOptions extends OperationOptions {
40
+ }
41
+ /** Options for `ChatClient.getUserProfile()`. */
42
+ export interface GetUserProfileOptions extends OperationOptions {
43
+ }
44
+ /** Options for `ChatClient.addUserToRoom()`. */
45
+ export interface AddUserToRoomOptions extends OperationOptions {
46
+ }
47
+ /** Options for `ChatClient.removeUserFromRoom()`. */
48
+ export interface RemoveUserFromRoomOptions extends OperationOptions {
49
+ }
50
+ /** Options for `ChatClient.listRoomMessages()`. */
51
+ export interface ListRoomMessagesOptions extends OperationOptions {
52
+ /**
53
+ * Inclusive lower bound on message id; omit to start from the earliest available message.
54
+ */
55
+ startId?: string;
56
+ /**
57
+ * Inclusive upper bound on message id; omit to read up to the latest message.
58
+ */
59
+ endId?: string;
60
+ /**
61
+ * Default maximum number of messages to request per service
62
+ * round-trip when iterating with `for await`. Defaults to 100.
63
+ * Callers using `byPage(...)` can override this per page via
64
+ * `byPage({ maxPageSize })`; the name matches the
65
+ * `@azure/core-paging` `PageSettings.maxPageSize` convention.
66
+ */
67
+ maxPageSize?: number;
68
+ }
69
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED,wCAAwC;AACxC,MAAM,WAAW,YAAa,SAAQ,gBAAgB;CAAG;AAEzD,gDAAgD;AAChD,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,6CAA6C;AAC7C,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,6CAA6C;AAC7C,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;CAAG;AAE9D,iDAAiD;AACjD,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;CAAG;AAElE,gDAAgD;AAChD,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;CAAG;AAEjE,qDAAqD;AACrD,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;CAAG;AAEtE,mDAAmD;AACnD,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC/D;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,11 @@
1
+ import { WebPubSubClient } from "@azure/web-pubsub-client";
2
+ export declare function decodeMessageBody(base64: string | null | undefined): string;
3
+ /**
4
+ * Type guard for WebPubSubClient.
5
+ * We avoid using `instanceof` because it can fail in scenarios with multiple
6
+ * dependency copies (e.g., monorepo with yarn/pnpm link) or across different
7
+ * execution contexts (iframe, worker). Instead, we check for stable public
8
+ * methods to ensure reliable detection.
9
+ */
10
+ export declare function isWebPubSubClient(obj: unknown): obj is WebPubSubClient;
11
+ //# sourceMappingURL=utils.d.ts.map