@ada-cx/messaging-bridge 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,59 @@
1
+ //#region ../../shared/utils/src/browser-polyfills.ts
2
+ /**
3
+ * Defence in depth for engines just below the declared browser floor.
4
+ * The floor is defined in `messaging/vite.browser-targets.mjs`.
5
+ *
6
+ * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from
7
+ * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page
8
+ * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK
9
+ * and bridge. Each fallback defines a member only when it is missing. These
10
+ * fallbacks do not extend browser support below the floor required by the shipped CSS.
11
+ */
12
+ var objectHasOwnProperty = Object.prototype.hasOwnProperty;
13
+ function defineValue(target, name, value) {
14
+ Object.defineProperty(target, name, {
15
+ value,
16
+ configurable: true,
17
+ writable: true
18
+ });
19
+ }
20
+ if (!Object.hasOwn) defineValue(Object, "hasOwn", (object, key) => {
21
+ if (object == null) throw new TypeError("ada browser-polyfills: Cannot convert undefined or null to object");
22
+ return objectHasOwnProperty.call(Object(object), key);
23
+ });
24
+ function at(index) {
25
+ const length = Math.trunc(Number(this.length)) || 0;
26
+ let relativeIndex = Math.trunc(Number(index)) || 0;
27
+ if (relativeIndex < 0) relativeIndex += length;
28
+ return relativeIndex < 0 || relativeIndex >= length ? void 0 : this[relativeIndex];
29
+ }
30
+ function stringAt(index) {
31
+ const value = String(this);
32
+ const length = value.length;
33
+ let relativeIndex = Math.trunc(Number(index)) || 0;
34
+ if (relativeIndex < 0) relativeIndex += length;
35
+ return relativeIndex < 0 || relativeIndex >= length ? void 0 : value.charAt(relativeIndex);
36
+ }
37
+ var typedArrayConstructors = [
38
+ globalThis.Int8Array,
39
+ globalThis.Uint8Array,
40
+ globalThis.Uint8ClampedArray,
41
+ globalThis.Int16Array,
42
+ globalThis.Uint16Array,
43
+ globalThis.Int32Array,
44
+ globalThis.Uint32Array,
45
+ globalThis.Float32Array,
46
+ globalThis.Float64Array,
47
+ globalThis.BigInt64Array,
48
+ globalThis.BigUint64Array
49
+ ].filter(Boolean);
50
+ if (!Array.prototype.at) defineValue(Array.prototype, "at", at);
51
+ if (!String.prototype.at) defineValue(String.prototype, "at", stringAt);
52
+ for (const TypedArrayConstructor of typedArrayConstructors) {
53
+ const prototype = TypedArrayConstructor.prototype;
54
+ if (!prototype.at) defineValue(prototype, "at", at);
55
+ }
56
+ //#endregion
1
57
  //#region \0@oxc-project+runtime@0.122.0/helpers/typeof.js
2
58
  function _typeof(o) {
3
59
  "@babel/helpers - typeof";
@@ -235,4 +291,4 @@ function loadMessagingBridge(options = {}) {
235
291
  //#endregion
236
292
  export { resolveBridgeCdnUrl as i, MessagingBridgeLoadError as n, loadMessagingBridge as r, FALLBACK_CDN_BASE as t };
237
293
 
238
- //# sourceMappingURL=loader-C2p-SBqp.js.map
294
+ //# sourceMappingURL=loader-BjjKuT42.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-BjjKuT42.js","names":[],"sources":["../../../shared/utils/src/browser-polyfills.ts","../src/npm/loader.ts"],"sourcesContent":["/**\n * Defence in depth for engines just below the declared browser floor.\n * The floor is defined in `messaging/vite.browser-targets.mjs`.\n *\n * Internal Ada code should prefer direct helpers, such as `hasOwn(...)` from\n * `guards.ts`. Every Ada bundle includes these fallbacks, including the host-page\n * SDK. These fallbacks also ship inside the customer-held npm tarballs of the SDK\n * and bridge. Each fallback defines a member only when it is missing. These\n * fallbacks do not extend browser support below the floor required by the shipped CSS.\n */\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction defineValue(\n\ttarget: object,\n\tname: PropertyKey,\n\tvalue: (...args: unknown[]) => unknown,\n): void {\n\tObject.defineProperty(target, name, {\n\t\tvalue,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n}\n\nif (!Object.hasOwn) {\n\tdefineValue(Object, \"hasOwn\", (object: unknown, key: unknown) => {\n\t\tif (object == null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"ada browser-polyfills: Cannot convert undefined or null to object\",\n\t\t\t);\n\t\t}\n\t\treturn objectHasOwnProperty.call(Object(object), key as PropertyKey);\n\t});\n}\n\nfunction at<T>(\n\tthis: { length: number; [index: number]: T },\n\tindex: unknown,\n): T | undefined {\n\tconst length = Math.trunc(Number(this.length)) || 0;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: this[relativeIndex];\n}\n\nfunction stringAt(this: string, index: unknown): string | undefined {\n\tconst value = String(this);\n\tconst length = value.length;\n\tlet relativeIndex = Math.trunc(Number(index)) || 0;\n\tif (relativeIndex < 0) {\n\t\trelativeIndex += length;\n\t}\n\treturn relativeIndex < 0 || relativeIndex >= length\n\t\t? undefined\n\t\t: value.charAt(relativeIndex);\n}\n\nconst typedArrayConstructors = [\n\tglobalThis.Int8Array,\n\tglobalThis.Uint8Array,\n\tglobalThis.Uint8ClampedArray,\n\tglobalThis.Int16Array,\n\tglobalThis.Uint16Array,\n\tglobalThis.Int32Array,\n\tglobalThis.Uint32Array,\n\tglobalThis.Float32Array,\n\tglobalThis.Float64Array,\n\tglobalThis.BigInt64Array,\n\tglobalThis.BigUint64Array,\n].filter(Boolean);\n\nif (!Array.prototype.at) {\n\tdefineValue(Array.prototype, \"at\", at);\n}\n\nif (!String.prototype.at) {\n\tdefineValue(String.prototype, \"at\", stringAt);\n}\n\nfor (const TypedArrayConstructor of typedArrayConstructors) {\n\tconst prototype = TypedArrayConstructor.prototype;\n\tif (!prototype.at) {\n\t\tdefineValue(prototype, \"at\", at);\n\t}\n}\n","import type { createBridgeClient } from \"../contract/bridge-client\";\nimport type {\n\tfilterDisplayable,\n\tfindFirstUnread,\n\tgroupMessages,\n\tisAgentTyping,\n\tisConnectivityLost,\n\tisHistoricalRow,\n\tmessageKey,\n\tresolveBotName,\n\tresolveDisplayBotName,\n\tselectUnread,\n} from \"../contract/derive\";\nimport type { STATE } from \"../contract/state-keys\";\n\nconst DEFAULT_CDN_BASE = \"https://messaging-assets.ada.support\";\nexport const FALLBACK_CDN_BASE = \"https://static.ada.support/messaging/\";\n// Keep aligned with packages/core/src/app-bridge.ts; pinned by\n// scripts/core-html-contract.test.mjs.\nconst CUSTOM_APP_FRAME_NAME = \"ada-custom-app\";\nconst BRIDGE_ENTRY_PATH = \"bridge/bridge.js\";\nconst DEV_BUILD_MARKER = \"dev\";\n\n// Only canonical build identifiers may become part of an executable asset URL.\nconst PINNED_BUILD_SHA_PATTERN = /^[0-9a-f]{40}$/i;\n// Deliberately narrower than scripts/sdk.js parseVersionOverride (7-40 hex,\n// case-insensitive): deployed keys are always lowercase `pr-<N>`, and a short\n// SHA never names an uploaded tree, so the narrower grammar loses no reachable\n// build while keeping the executable-path grammar minimal.\nconst PR_BUILD_ALIAS_PATTERN = /^pr-\\d+$/;\n\n/** Why a {@link MessagingBridgeLoadError} was raised. */\nexport type MessagingBridgeLoadErrorCode =\n\t/** The `cdnBase` option violates the HTTPS or loopback HTTP policy. */\n\t| \"invalid_cdn_base\"\n\t/** The frame's `window.name` carries no core build marker. */\n\t| \"missing_build_sha\"\n\t/** The frame-name marker is not a supported bare build identifier. */\n\t| \"invalid_build_sha\"\n\t/** The `dev` marker was paired with a non-loopback CDN base. */\n\t| \"dev_marker_not_loopback\"\n\t/** The dynamic import of the CDN asset failed. */\n\t| \"bridge_import_failed\"\n\t/** The imported module does not expose the Ada bridge surface. */\n\t| \"bridge_module_invalid\";\n\n/** Typed failure raised by {@link loadMessagingBridge}. */\nexport class MessagingBridgeLoadError extends Error {\n\treadonly code: MessagingBridgeLoadErrorCode;\n\tdeclare readonly fallbackCause?: MessagingBridgeLoadError;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: MessagingBridgeLoadErrorCode,\n\t\tcause?: unknown,\n\t\tfallbackCause?: MessagingBridgeLoadError,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"MessagingBridgeLoadError\";\n\t\tthis.code = code;\n\t\tif (cause !== undefined) {\n\t\t\tthis.cause = cause;\n\t\t}\n\t\tif (fallbackCause !== undefined) {\n\t\t\tObject.defineProperty(this, \"fallbackCause\", {\n\t\t\t\tvalue: fallbackCause,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\t}\n}\n\n/** The module shape served by the SHA-matched bridge CDN asset. */\nexport interface MessagingBridgeModule {\n\tcreateBridgeClient: typeof createBridgeClient;\n\tSTATE: typeof STATE;\n\tmessageKey: typeof messageKey;\n\tisHistoricalRow: typeof isHistoricalRow;\n\tfindFirstUnread: typeof findFirstUnread;\n\tselectUnread: typeof selectUnread;\n\tgroupMessages: typeof groupMessages;\n\tfilterDisplayable: typeof filterDisplayable;\n\tresolveBotName: typeof resolveBotName;\n\t/**\n\t * Absent on a CDN build published before this helper existed. The npm\n\t * version does not choose the runtime, so guard before calling it.\n\t */\n\tresolveDisplayBotName?: typeof resolveDisplayBotName;\n\tisAgentTyping: typeof isAgentTyping;\n\tisConnectivityLost: typeof isConnectivityLost;\n}\n\ntype ImportBridgeModule = (url: string) => Promise<unknown>;\n\n/** Options for {@link loadMessagingBridge}. */\nexport interface LoadMessagingBridgeOptions {\n\t/**\n\t * Asset base for the bridge runtime. It must use HTTPS. Plain HTTP is\n\t * accepted only for loopback hosts. An explicit value, including\n\t * {@link FALLBACK_CDN_BASE}, disables the automatic static-root fallback.\n\t */\n\tcdnBase?: string;\n\t/** Import seam for unit tests. */\n\timportModule?: ImportBridgeModule;\n}\n\n// Both annotations are load-bearing. Customer bundlers must leave the\n// browser-resolved CDN URL untouched.\nconst defaultImportModule: ImportBridgeModule = (url) =>\n\timport(/* webpackIgnore: true */ /* @vite-ignore */ url);\n\ninterface BridgeLoaderState {\n\timports: Map<string, Promise<MessagingBridgeModule>>;\n\tdefaultLoads: Map<string, Promise<MessagingBridgeModule>>;\n}\n\nconst loadsByImporter = new WeakMap<ImportBridgeModule, BridgeLoaderState>();\n\n// Share the warning across independently bundled copies of this loader.\nconst FALLBACK_WARNING_KEY = Symbol.for(\"ada.messaging.bridge.fallbackWarning\");\nconst warningScope = globalThis as typeof globalThis & {\n\t[FALLBACK_WARNING_KEY]?: boolean;\n};\n\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\", \"::1\"]);\n\nfunction isLoopbackHostname(hostname: string): boolean {\n\tconst normalized = hostname.trim().toLowerCase();\n\treturn LOOPBACK_HOSTS.has(normalized) || normalized.endsWith(\".localhost\");\n}\n\nfunction trimTrailingSlashes(value: string): string {\n\tlet end = value.length;\n\twhile (end > 0 && value[end - 1] === \"/\") {\n\t\tend -= 1;\n\t}\n\treturn value.slice(0, end);\n}\n\ntype BridgeBuild =\n\t| { kind: \"sha\"; identifier: string }\n\t| { kind: \"alias\"; identifier: string }\n\t| { kind: \"dev\" };\n\nfunction bridgeFrameOnlyMessage(message: string): string {\n\treturn `${message} The bridge only runs inside an Ada-mounted custom-app frame.`;\n}\n\nconst FRAME_NAME_MARKER_PREFIX = `${CUSTOM_APP_FRAME_NAME}:`;\n\nfunction frameNameCarriesBuild(name: string): boolean {\n\treturn name.startsWith(FRAME_NAME_MARKER_PREFIX);\n}\n\n/**\n * Read the build marker core stamps into the frame's `window.name`\n * (`ada-custom-app:<marker>`). The name is Ada-owned for this frame, so the\n * marker never touches customer-owned URL state such as a hash route.\n */\nexport function resolveBridgeBuildFromFrameName(name: string): BridgeBuild {\n\tif (name === CUSTOM_APP_FRAME_NAME) {\n\t\tthrow new MessagingBridgeLoadError(\n\t\t\t\"The mounting Ada core predates build-marker delivery, so it cannot select a versioned bridge. The Ada core rollout must include the marker-stamping core before the npm bridge can load.\",\n\t\t\t\"missing_build_sha\",\n\t\t);\n\t}\n\tif (!frameNameCarriesBuild(name)) {\n\t\tthrow new MessagingBridgeLoadError(\n\t\t\t`${bridgeFrameOnlyMessage(\n\t\t\t\t\"This document was not mounted by an Ada core frame: window.name carries no ada-custom-app build marker.\",\n\t\t\t)} If this frame is Ada-mounted, make sure @ada-cx/messaging-bridge (or its /react entry) is imported from a module your page evaluates at startup — a lazily loaded chunk evaluates after customer code could overwrite window.name.`,\n\t\t\t\"missing_build_sha\",\n\t\t);\n\t}\n\tconst value = name.slice(FRAME_NAME_MARKER_PREFIX.length);\n\tif (value === DEV_BUILD_MARKER) {\n\t\treturn { kind: \"dev\" };\n\t}\n\tif (PR_BUILD_ALIAS_PATTERN.test(value)) {\n\t\treturn { kind: \"alias\", identifier: value };\n\t}\n\tif (!PINNED_BUILD_SHA_PATTERN.test(value)) {\n\t\tthrow new MessagingBridgeLoadError(\n\t\t\tbridgeFrameOnlyMessage(\n\t\t\t\t`The window.name build marker must be exactly a bare 40-character hex git SHA or a lowercase pr-<N> alias. URLs and paths are not allowed: \"${value}\".`,\n\t\t\t),\n\t\t\t\"invalid_build_sha\",\n\t\t);\n\t}\n\treturn { kind: \"sha\", identifier: value.toLowerCase() };\n}\n\n// Latch window.name at module evaluation: core stamps the marker on the\n// frame element before the document loads, and customer code — for example a\n// library that uses window.name as a storage channel — could overwrite it\n// after boot. The latch therefore only holds when this package is imported\n// from the page's entry module rather than a lazily loaded chunk — the\n// boundary README_NPM.md documents and the snapshot tests in loader.test.ts\n// pin.\nconst initialFrameName = typeof window === \"undefined\" ? \"\" : window.name;\nconst initialFrameNameHasBuild = frameNameCarriesBuild(initialFrameName);\n\nfunction currentFrameName(): string {\n\tif (initialFrameNameHasBuild) {\n\t\treturn initialFrameName;\n\t}\n\treturn typeof window === \"undefined\" ? \"\" : window.name;\n}\n\nfunction resolveCdnBase(cdnBase: string | undefined): {\n\tbase: string;\n\thostname: string;\n} {\n\tconst base = trimTrailingSlashes((cdnBase ?? DEFAULT_CDN_BASE).trim());\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(base);\n\t} catch (cause) {\n\t\tthrow new MessagingBridgeLoadError(\n\t\t\t`The cdnBase option is not a valid URL: \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t\tcause,\n\t\t);\n\t}\n\tconst isHttps = url.protocol === \"https:\";\n\tconst isLoopbackHttp =\n\t\turl.protocol === \"http:\" && isLoopbackHostname(url.hostname);\n\tif (!isHttps && !isLoopbackHttp) {\n\t\tthrow new MessagingBridgeLoadError(\n\t\t\t`The cdnBase option must use https (plain http is allowed only for loopback hosts): \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t);\n\t}\n\treturn { base, hostname: url.hostname };\n}\n\n/**\n * Resolve the bridge asset URL from this frame's name marker and the CDN\n * base. Production builds always resolve the immutable SHA-rooted asset.\n * PR aliases stay under the configured CDN base. A production-base alias that\n * does not exist fails closed through the normal bridge import error.\n * Local development resolves `/bridge/bridge.js` only on a loopback base.\n * This reports the configured root only, not the root a fallback load used.\n */\nexport function resolveBridgeCdnUrl(\n\toptions?: Pick<LoadMessagingBridgeOptions, \"cdnBase\">,\n): string {\n\tconst build = resolveBridgeBuildFromFrameName(currentFrameName());\n\tconst { base, hostname } = resolveCdnBase(options?.cdnBase);\n\tif (build.kind === \"dev\" && !isLoopbackHostname(hostname)) {\n\t\tthrow new MessagingBridgeLoadError(\n\t\t\tbridgeFrameOnlyMessage(\n\t\t\t\t`The ${FRAME_NAME_MARKER_PREFIX}${DEV_BUILD_MARKER} frame-name marker requires a loopback cdnBase.`,\n\t\t\t),\n\t\t\t\"dev_marker_not_loopback\",\n\t\t);\n\t}\n\tconst assetPath =\n\t\tbuild.kind === \"dev\"\n\t\t\t? `/${BRIDGE_ENTRY_PATH}`\n\t\t\t: `/${build.identifier}/${BRIDGE_ENTRY_PATH}`;\n\treturn new URL(`${base}${assetPath}`).toString();\n}\n\n// A partial CDN module (mid-deploy, or a rolled-back build missing a newer\n// export) must fail here as a typed bridge_module_invalid error, not later as\n// a TypeError on the first missing call — so every export is checked. The\n// `satisfies` clause rejects names that are not interface members; the\n// exhaustiveness type below is what forces this list to grow with it.\n//\n// This list is the set published with 1.0.0, and adding to it is a breaking\n// change even though adding an export is not. A page's runtime build comes from\n// the core frame's `window.name`, never from the installed npm version, so a\n// 1.x consumer legitimately resolves an older bridge — during a rollout, behind\n// an `?ada-messaging-version` pin, or after a CDN revert. Requiring a newer\n// export would turn every one of those into \"no bridge at all\" for a customer\n// who never calls it. Declare a helper added after 1.0.0 optional on\n// `MessagingBridgeModule` and exempt it below instead.\nconst REQUIRED_BRIDGE_FUNCTION_EXPORTS = [\n\t\"createBridgeClient\",\n\t\"messageKey\",\n\t\"isHistoricalRow\",\n\t\"findFirstUnread\",\n\t\"selectUnread\",\n\t\"groupMessages\",\n\t\"filterDisplayable\",\n\t\"resolveBotName\",\n\t\"isAgentTyping\",\n\t\"isConnectivityLost\",\n] as const satisfies readonly (keyof MessagingBridgeModule)[];\n\ntype MissingRequiredBridgeExport = Exclude<\n\tkeyof MessagingBridgeModule,\n\t| (typeof REQUIRED_BRIDGE_FUNCTION_EXPORTS)[number]\n\t| \"STATE\"\n\t// Optional by design: added after 1.0.0, so an older runtime will not have\n\t// it. Callers get `undefined` and degrade; they do not lose the bridge.\n\t| \"resolveDisplayBotName\"\n>;\n// Compile-time exhaustiveness: adding a MessagingBridgeModule member without\n// listing it in REQUIRED_BRIDGE_FUNCTION_EXPORTS (or checking it explicitly,\n// like STATE) makes the Exclude non-`never`, so the `true` assignment below\n// stops compiling.\ntype AllBridgeExportsListed = MissingRequiredBridgeExport extends never\n\t? true\n\t: never;\nconst _allBridgeExportsListed: AllBridgeExportsListed = true;\nvoid _allBridgeExportsListed;\n\nfunction isMessagingBridgeModule(\n\tvalue: unknown,\n): value is MessagingBridgeModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst candidate = value as Record<string, unknown>;\n\t// STATE is a constant object, not a function, so it gets a presence check.\n\treturn (\n\t\tcandidate.STATE != null &&\n\t\tREQUIRED_BRIDGE_FUNCTION_EXPORTS.every(\n\t\t\t(key) => typeof candidate[key] === \"function\",\n\t\t)\n\t);\n}\n\n// A rejection can be any value, including one that throws on String(); a\n// diagnostic must never turn a successful fallback into a rejected load.\nfunction describeRejection(cause: unknown): string {\n\ttry {\n\t\treturn cause instanceof Error\n\t\t\t? `${cause.name}: ${cause.message}`\n\t\t\t: String(cause);\n\t} catch {\n\t\treturn \"unknown error\";\n\t}\n}\n\nasync function importBridgeModule(\n\turl: string,\n\timportModule: ImportBridgeModule,\n): Promise<MessagingBridgeModule> {\n\tlet loaded: unknown;\n\ttry {\n\t\tloaded = await importModule(url);\n\t} catch (cause) {\n\t\tthrow new MessagingBridgeLoadError(\n\t\t\t`The Ada bridge runtime failed to load from ${url}.`,\n\t\t\t\"bridge_import_failed\",\n\t\t\tcause,\n\t\t);\n\t}\n\tif (!isMessagingBridgeModule(loaded)) {\n\t\tthrow new MessagingBridgeLoadError(\n\t\t\t`The module at ${url} does not expose the full Ada bridge surface; it is not a complete Ada bridge build.`,\n\t\t\t\"bridge_module_invalid\",\n\t\t);\n\t}\n\treturn loaded;\n}\n\nfunction memoizeLoad(\n\tcache: Map<string, Promise<MessagingBridgeModule>>,\n\turl: string,\n\tload: () => Promise<MessagingBridgeModule>,\n): Promise<MessagingBridgeModule> {\n\tconst existing = cache.get(url);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst pending = load();\n\tcache.set(url, pending);\n\tpending.catch(() => {\n\t\tif (cache.get(url) === pending) {\n\t\t\tcache.delete(url);\n\t\t}\n\t});\n\treturn pending;\n}\n\n/**\n * Load the bridge runtime that matches the mounting core frame. Loads are\n * memoized per resolved URL and importer. A failed load is evicted for retry.\n * Without `cdnBase`, an import failure at the default root is retried once\n * from {@link FALLBACK_CDN_BASE}.\n */\nexport function loadMessagingBridge(\n\toptions: LoadMessagingBridgeOptions = {},\n): Promise<MessagingBridgeModule> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tlet url: string;\n\tlet fallbackUrl: string | undefined;\n\ttry {\n\t\turl = resolveBridgeCdnUrl(options);\n\t\tif (options.cdnBase === undefined) {\n\t\t\tfallbackUrl = resolveBridgeCdnUrl({ cdnBase: FALLBACK_CDN_BASE });\n\t\t}\n\t} catch (error) {\n\t\treturn Promise.reject(error);\n\t}\n\n\tconst state = loadsByImporter.get(importModule) ?? {\n\t\timports: new Map<string, Promise<MessagingBridgeModule>>(),\n\t\tdefaultLoads: new Map<string, Promise<MessagingBridgeModule>>(),\n\t};\n\tloadsByImporter.set(importModule, state);\n\tconst load = (entryUrl: string) =>\n\t\tmemoizeLoad(state.imports, entryUrl, () =>\n\t\t\timportBridgeModule(entryUrl, importModule),\n\t\t);\n\tif (fallbackUrl === undefined) {\n\t\treturn load(url);\n\t}\n\n\tconst retryUrl = fallbackUrl;\n\treturn memoizeLoad(state.defaultLoads, url, () =>\n\t\tload(url).catch(async (error: unknown) => {\n\t\t\tif (\n\t\t\t\t!(error instanceof MessagingBridgeLoadError) ||\n\t\t\t\terror.code !== \"bridge_import_failed\"\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tlet module: MessagingBridgeModule;\n\t\t\ttry {\n\t\t\t\tmodule = await load(retryUrl);\n\t\t\t} catch (cause) {\n\t\t\t\tif (!(cause instanceof MessagingBridgeLoadError)) {\n\t\t\t\t\tthrow cause;\n\t\t\t\t}\n\t\t\t\tthrow new MessagingBridgeLoadError(\n\t\t\t\t\tcause.code === \"bridge_import_failed\"\n\t\t\t\t\t\t? `The Ada bridge runtime failed to load from both ${url} and ${retryUrl}.`\n\t\t\t\t\t\t: cause.message,\n\t\t\t\t\tcause.code,\n\t\t\t\t\terror,\n\t\t\t\t\tcause,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!warningScope[FALLBACK_WARNING_KEY]) {\n\t\t\t\twarningScope[FALLBACK_WARNING_KEY] = true;\n\t\t\t\tconst cause = error.cause;\n\t\t\t\ttry {\n\t\t\t\t\t// Browsers reject blocked, unreachable, or missing imports with TypeError.\n\t\t\t\t\t// An evaluation-time TypeError still looks like a fetch failure, as before;\n\t\t\t\t\t// this heuristic narrows diagnostic noise but cannot prove the cause.\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\tcause instanceof TypeError\n\t\t\t\t\t\t\t? `[Ada] Loaded the Messaging bridge from ${FALLBACK_CDN_BASE} because the default root ${DEFAULT_CDN_BASE}/ was blocked or unavailable. Add ${DEFAULT_CDN_BASE} to script-src, connect-src and frame-src, or pass cdnBase: \"${FALLBACK_CDN_BASE}\".`\n\t\t\t\t\t\t\t: `[Ada] Loaded the Messaging bridge from ${FALLBACK_CDN_BASE} because the module at ${url} failed to evaluate (${describeRejection(cause)}). This is an Ada-side problem, not your host's CSP. Report it to Ada.`,\n\t\t\t\t\t\tcause,\n\t\t\t\t\t);\n\t\t\t\t} catch {\n\t\t\t\t\t// A host may replace console methods; diagnostics must not throw.\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn module;\n\t\t}),\n\t);\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAM,uBAAuB,OAAO,UAAU;AAE9C,SAAS,YACR,QACA,MACA,OACO;AACP,QAAO,eAAe,QAAQ,MAAM;EACnC;EACA,cAAc;EACd,UAAU;EACV,CAAC;;AAGH,IAAI,CAAC,OAAO,OACX,aAAY,QAAQ,WAAW,QAAiB,QAAiB;AAChE,KAAI,UAAU,KACb,OAAM,IAAI,UACT,oEACA;AAEF,QAAO,qBAAqB,KAAK,OAAO,OAAO,EAAE,IAAmB;EACnE;AAGH,SAAS,GAER,OACgB;CAChB,MAAM,SAAS,KAAK,MAAM,OAAO,KAAK,OAAO,CAAC,IAAI;CAClD,IAAI,gBAAgB,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI;AACjD,KAAI,gBAAgB,EACnB,kBAAiB;AAElB,QAAO,gBAAgB,KAAK,iBAAiB,SAC1C,KAAA,IACA,KAAK;;AAGT,SAAS,SAAuB,OAAoC;CACnE,MAAM,QAAQ,OAAO,KAAK;CAC1B,MAAM,SAAS,MAAM;CACr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;AAEF,MAAI,CAAC,aAAa,uBAAuB;AACxC,gBAAa,wBAAwB;GACrC,MAAM,QAAQ,MAAM;AACpB,OAAI;AAIH,YAAQ,KACP,iBAAiB,YACd,0CAA0C,kBAAkB,4BAA4B,iBAAiB,oCAAoC,iBAAiB,+DAA+D,kBAAkB,MAC/O,0CAA0C,kBAAkB,yBAAyB,IAAI,uBAAuB,kBAAkB,MAAM,CAAC,yEAC5I,MACA;WACM;;AAIT,SAAO;GACN,CACF"}
@@ -1,2 +1,2 @@
1
- import { i as resolveBridgeCdnUrl, n as MessagingBridgeLoadError, r as loadMessagingBridge, t as FALLBACK_CDN_BASE } from "../loader-C2p-SBqp.js";
1
+ import { i as resolveBridgeCdnUrl, n as MessagingBridgeLoadError, r as loadMessagingBridge, t as FALLBACK_CDN_BASE } from "../loader-BjjKuT42.js";
2
2
  export { FALLBACK_CDN_BASE, MessagingBridgeLoadError, loadMessagingBridge, resolveBridgeCdnUrl };
@@ -1,4 +1,4 @@
1
- import { i as resolveBridgeCdnUrl, n as MessagingBridgeLoadError, r as loadMessagingBridge, t as FALLBACK_CDN_BASE } from "../loader-C2p-SBqp.js";
1
+ import { i as resolveBridgeCdnUrl, n as MessagingBridgeLoadError, r as loadMessagingBridge, t as FALLBACK_CDN_BASE } from "../loader-BjjKuT42.js";
2
2
  import { createContext, useCallback, useContext, useEffect, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { Fragment, jsx } from "react/jsx-runtime";
4
4
  //#region src/npm/bridge-react.tsx