{"version":3,"file":"global.cjs","names":[],"sources":["../../src/common/global.ts"],"sourcesContent":["/* eslint-disable no-restricted-globals */\n\n/**\n * Global context for Zeed, used for cross-module state.\n * @category Global\n */\n\n// Export the global context type so TypeDoc includes it in the docs.\nexport interface ZeedGlobalContext {\n  [key: string]: any\n}\n\ndeclare global {\n  interface ZeedGlobalContext {}\n}\n\ninterface ZeedGlobalIntegration {\n  _zeedGlobal?: ZeedGlobalContext\n}\n\n/** Identify the right global for the environment. Might be obsolete these days, due to globalThis. */\nfunction _global(): ZeedGlobalIntegration {\n  if (typeof self !== 'undefined')\n    return self as ZeedGlobalIntegration\n  if (typeof window !== 'undefined')\n    return window as ZeedGlobalIntegration\n  if (typeof global !== 'undefined')\n    return global as ZeedGlobalIntegration\n  if (typeof globalThis !== 'undefined')\n    return globalThis as ZeedGlobalIntegration\n  throw new Error('unable to locate global object')\n}\n\n/** Global object to work across module boundaries as well. Internally already used for logger and emitter. */\nexport function getGlobalContext<T = ZeedGlobalContext>(defaultValue = {}): T {\n  const gcontext = _global()\n  gcontext._zeedGlobal ??= defaultValue\n  return gcontext._zeedGlobal as T\n}\n\n/// Last resort hack to extend the globalThis object.\nexport const globalAny = globalThis as any\n"],"mappings":";;;;AAqBA,SAAS,UAAiC;AACxC,KAAI,OAAO,SAAS,YAClB,QAAO;AACT,KAAI,OAAO,WAAW,YACpB,QAAO;AACT,KAAI,OAAO,WAAW,YACpB,QAAO;AACT,KAAI,OAAO,eAAe,YACxB,QAAO;AACT,OAAM,IAAI,MAAM,iCAAiC;;;AAInD,SAAgB,iBAAwC,eAAe,EAAE,EAAK;CAC5E,MAAM,WAAW,SAAS;AAC1B,UAAS,gBAAgB;AACzB,QAAO,SAAS;;AAIlB,MAAa,YAAY"}