{"version":3,"file":"metadata.mjs","sources":["../src/metadata/format-build-time.ts","../src/metadata/register-build-metadata.ts"],"sourcesContent":["/**\n * Formats a build timestamp for human-readable logging output.\n *\n * Returns the original value when the input is blank or cannot be parsed as a valid date.\n * Valid timestamps are formatted as `DD-MM-YYYY HH:mm:ss (TZ)` using the `en-GB` locale.\n */\nexport function formatBuildTime(buildTime: string): string {\n  if (!buildTime.trim()) {\n    return buildTime;\n  }\n\n  const date = new Date(buildTime);\n\n  if (Number.isNaN(date.getTime())) {\n    return buildTime;\n  }\n\n  const parts = new Intl.DateTimeFormat('en-GB', {\n    day: '2-digit',\n    month: '2-digit',\n    year: 'numeric',\n    hour: '2-digit',\n    minute: '2-digit',\n    second: '2-digit',\n    hour12: false,\n    timeZoneName: 'short',\n  }).formatToParts(date);\n\n  const getPart = (type: Intl.DateTimeFormatPartTypes) => parts.find((part) => part.type === type)?.value ?? '';\n\n  return `${getPart('day')}-${getPart('month')}-${getPart('year')} ${getPart('hour')}:${getPart('minute')}:${getPart('second')} (${getPart('timeZoneName')})`;\n}\n","import { formatBuildTime } from './format-build-time';\n\ntype B2XVersions = Record<string, string>;\n\n/**\n * Build metadata registered under a package namespace in the global B2X version registry.\n */\ntype RegisterBuildMetadataOptions = {\n  namespace: string;\n  buildTime: string;\n  version: string;\n};\n\ntype BuildMetadataHost = typeof globalThis & {\n  B2X_VERSIONS?: B2XVersions;\n};\n\ndeclare global {\n  var B2X_VERSIONS: B2XVersions | undefined;\n\n  interface Window {\n    B2X_VERSIONS?: B2XVersions;\n  }\n}\n\n/**\n * Registers package build metadata in the global B2X version registry.\n * Existing namespace entries are preserved.\n */\nfunction registerBuildMetadata({ namespace, buildTime, version }: RegisterBuildMetadataOptions): void {\n  const targetHost = (globalThis.window ?? globalThis) as BuildMetadataHost;\n  const currentVersions = targetHost.B2X_VERSIONS ?? {};\n  const formattedBuildTime = formatBuildTime(buildTime);\n\n  if (currentVersions[namespace]) {\n    return;\n  }\n\n  targetHost.B2X_VERSIONS = {\n    [namespace]: `${namespace}@${version}-${formattedBuildTime}`,\n    ...currentVersions,\n  };\n}\n\nexport { registerBuildMetadata };\nexport type { RegisterBuildMetadataOptions };\n"],"names":["formatBuildTime","buildTime","date","parts","getPart","type","part","registerBuildMetadata","namespace","version","targetHost","currentVersions","formattedBuildTime"],"mappings":"AAMO,SAASA,EAAgBC,GAA2B;AACzD,MAAI,CAACA,EAAU;AACb,WAAOA;AAGT,QAAMC,IAAO,IAAI,KAAKD,CAAS;AAE/B,MAAI,OAAO,MAAMC,EAAK,QAAA,CAAS;AAC7B,WAAOD;AAGT,QAAME,IAAQ,IAAI,KAAK,eAAe,SAAS;AAAA,IAC7C,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,cAAc;AAAA,EAAA,CACf,EAAE,cAAcD,CAAI,GAEfE,IAAU,CAACC,MAAuCF,EAAM,KAAK,CAACG,MAASA,EAAK,SAASD,CAAI,GAAG,SAAS;AAE3G,SAAO,GAAGD,EAAQ,KAAK,CAAC,IAAIA,EAAQ,OAAO,CAAC,IAAIA,EAAQ,MAAM,CAAC,IAAIA,EAAQ,MAAM,CAAC,IAAIA,EAAQ,QAAQ,CAAC,IAAIA,EAAQ,QAAQ,CAAC,KAAKA,EAAQ,cAAc,CAAC;AAC1J;ACFA,SAASG,EAAsB,EAAE,WAAAC,GAAW,WAAAP,GAAW,SAAAQ,KAA+C;AACpG,QAAMC,IAAc,WAAW,UAAU,YACnCC,IAAkBD,EAAW,gBAAgB,CAAA,GAC7CE,IAAqBZ,EAAgBC,CAAS;AAEpD,EAAIU,EAAgBH,CAAS,MAI7BE,EAAW,eAAe;AAAA,IACxB,CAACF,CAAS,GAAG,GAAGA,CAAS,IAAIC,CAAO,IAAIG,CAAkB;AAAA,IAC1D,GAAGD;AAAA,EAAA;AAEP;"}