{"version":3,"file":"remote-entry.mjs","names":[],"sources":["../../src/ui/remote-entry.ts"],"sourcesContent":["import {\n  UI_REMOTE_ENTRY_FILENAME,\n  UI_REMOTE_SERVER_ENTRY_FILENAME,\n} from \"every-plugin/ui/manifest\";\nimport type { BosEnv } from \"../services/resolution/merge\";\n\n/**\n * The host's entry-URL EntryResolver: one pure derivation from a stamped\n * config remote to the URLs each surface loads. `RemoteEntry` is structural —\n * the version-manifest derivation (atomic-deploys 04) stamps exactly these\n * fields onto `RuntimeConfig` remotes, so they satisfy it as-is. Each surface\n * of `entryUrls` resolves (and throws) lazily — a caller reading only `ui`\n * never trips the ssr surface's resolution, and vice versa.\n */\nexport interface RemoteEntry {\n  /** remote identity, verbatim in resolution errors */\n  name: string;\n  url?: string;\n  /** browser-facing base (ADR 0011) — the base rule is publicUrl ?? url, inside this module */\n  publicUrl?: string;\n  /** pin-derived hashed browser entry (absent in development) */\n  entryUrl?: string;\n  ssrUrl?: string;\n  /** pin-derived hashed SSR entry */\n  ssrEntryUrl?: string;\n  integrity?: string;\n  ssrIntegrity?: string;\n  /** dev-only freshness token (localUiRemoteEntry's container mtime) */\n  containerVersion?: string;\n  /** pin-derived hashed browser manifest — absent for local remotes, which no\n   * pin derivation ever stamps (atomic-deploys 08) and the resolver drops\n   * even if one were stamped */\n  browserManifestUrl?: string;\n  localPath?: string;\n}\n\nexport interface EntryUrls {\n  /** browser script src / registration entry — bustered fixed name in dev, hashed in prod */\n  readonly ui: string;\n  /** server container entry; undefined when the remote has no SSR coordinates */\n  readonly ssr?: string;\n  /** pin-derived hashed mf-manifest; undefined ⟺ local remote (atomic-deploys 08, STRUCTURAL) */\n  readonly browserManifest?: string;\n}\n\nconst trimBase = (value: string | undefined): string => (value ?? \"\").replace(/\\/$/, \"\");\n\nconst withBuster = (url: string, buster: string | undefined): string =>\n  buster ? `${url}?v=${encodeURIComponent(buster)}` : url;\n\nfunction requireEntry(\n  entryUrl: string | undefined,\n  env: BosEnv,\n  remote: string,\n  surface: string,\n  devFixed: string,\n): string {\n  if (entryUrl) return entryUrl;\n  if (env === \"development\") return devFixed;\n  throw new Error(\n    `remote \"${remote}\" has no derived ${surface} entry — pins resolve it from the version manifest ` +\n      `(the fixed dev name is development-only)`,\n  );\n}\n\nfunction ssrEntryUrl(remote: RemoteEntry, env: BosEnv): string | undefined {\n  if (remote.ssrEntryUrl) return remote.ssrEntryUrl;\n  if (env === \"development\") {\n    return remote.ssrUrl\n      ? withBuster(\n          `${trimBase(remote.ssrUrl)}/${UI_REMOTE_SERVER_ENTRY_FILENAME}`,\n          remote.ssrIntegrity ?? remote.containerVersion,\n        )\n      : undefined;\n  }\n  if (!remote.ssrUrl) return undefined;\n  throw new Error(\n    `remote \"${remote.name}\" has no derived ssr entry — pins resolve it from the version manifest ` +\n      `(the fixed dev name is development-only)`,\n  );\n}\n\nexport function entryUrls(remote: RemoteEntry, env: BosEnv): EntryUrls {\n  const base = trimBase(remote.publicUrl ?? remote.url);\n  return {\n    get ui() {\n      return requireEntry(\n        remote.entryUrl,\n        env,\n        remote.name,\n        \"ui\",\n        withBuster(`${base}/${UI_REMOTE_ENTRY_FILENAME}`, remote.integrity),\n      );\n    },\n    get ssr() {\n      return ssrEntryUrl(remote, env);\n    },\n    get browserManifest() {\n      return remote.localPath ? undefined : remote.browserManifestUrl;\n    },\n  };\n}\n"],"mappings":";;;AA6CA,MAAM,YAAY,WAAuC,SAAS,GAAE,CAAE,QAAQ,OAAO,EAAE;AAEvF,MAAM,cAAc,KAAa,WAC/B,SAAS,GAAG,IAAI,KAAK,mBAAmB,MAAM,MAAM;AAEtD,SAAS,aACP,UACA,KACA,QACA,SACA,UACQ;CACR,IAAI,UAAU,OAAO;CACrB,IAAI,QAAQ,eAAe,OAAO;CAClC,MAAM,IAAI,MACR,WAAW,OAAO,mBAAmB,QAAQ,4FAE/C;AACF;AAEA,SAAS,YAAY,QAAqB,KAAiC;CACzE,IAAI,OAAO,aAAa,OAAO,OAAO;CACtC,IAAI,QAAQ,eACV,OAAO,OAAO,SACV,WACE,GAAG,SAAS,OAAO,MAAM,EAAE,GAAG,mCAC9B,OAAO,gBAAgB,OAAO,gBAChC,IACA;CAEN,IAAI,CAAC,OAAO,QAAQ,OAAO;CAC3B,MAAM,IAAI,MACR,WAAW,OAAO,KAAK,gHAEzB;AACF;AAEA,SAAgB,UAAU,QAAqB,KAAwB;CACrE,MAAM,OAAO,SAAS,OAAO,aAAa,OAAO,GAAG;CACpD,OAAO;EACL,IAAI,KAAK;GACP,OAAO,aACL,OAAO,UACP,KACA,OAAO,MACP,MACA,WAAW,GAAG,KAAK,GAAG,4BAA4B,OAAO,SAAS,CACpE;EACF;EACA,IAAI,MAAM;GACR,OAAO,YAAY,QAAQ,GAAG;EAChC;EACA,IAAI,kBAAkB;GACpB,OAAO,OAAO,YAAY,SAAY,OAAO;EAC/C;CACF;AACF"}