{"version":3,"sources":["../../../../../src/server/lib/incremental-cache/tags-manifest.external.ts"],"sourcesContent":["import type { Timestamp } from '../cache-handlers/types'\n\nexport interface TagManifestEntry {\n  stale?: number\n  expired?: number\n}\n\n// We share the tags manifest between the \"use cache\" handlers and the previous\n// file-system cache.\nexport const tagsManifest = new Map<string, TagManifestEntry>()\n\nexport const areTagsExpired = (tags: string[], timestamp: Timestamp) => {\n  for (const tag of tags) {\n    const entry = tagsManifest.get(tag)\n    const expiredAt = entry?.expired\n\n    if (typeof expiredAt === 'number') {\n      const now = Date.now()\n      // For immediate expiration (expiredAt <= now) and tag was invalidated after entry was created\n      // OR for future expiration that has now passed (expiredAt > timestamp && expiredAt <= now)\n      const isImmediatelyExpired = expiredAt <= now && expiredAt > timestamp\n\n      if (isImmediatelyExpired) {\n        return true\n      }\n    }\n  }\n\n  return false\n}\n\nexport const areTagsStale = (tags: string[], timestamp: Timestamp) => {\n  for (const tag of tags) {\n    const entry = tagsManifest.get(tag)\n    const staleAt = entry?.stale ?? 0\n\n    if (typeof staleAt === 'number' && staleAt > timestamp) {\n      return true\n    }\n  }\n\n  return false\n}\n"],"names":["tagsManifest","Map","areTagsExpired","tags","timestamp","tag","entry","get","expiredAt","expired","now","Date","isImmediatelyExpired","areTagsStale","staleAt","stale"],"mappings":"AAOA,+EAA+E;AAC/E,qBAAqB;AACrB,OAAO,MAAMA,eAAe,IAAIC,MAA+B;AAE/D,OAAO,MAAMC,iBAAiB,CAACC,MAAgBC;IAC7C,KAAK,MAAMC,OAAOF,KAAM;QACtB,MAAMG,QAAQN,aAAaO,GAAG,CAACF;QAC/B,MAAMG,YAAYF,yBAAAA,MAAOG,OAAO;QAEhC,IAAI,OAAOD,cAAc,UAAU;YACjC,MAAME,MAAMC,KAAKD,GAAG;YACpB,8FAA8F;YAC9F,2FAA2F;YAC3F,MAAME,uBAAuBJ,aAAaE,OAAOF,YAAYJ;YAE7D,IAAIQ,sBAAsB;gBACxB,OAAO;YACT;QACF;IACF;IAEA,OAAO;AACT,EAAC;AAED,OAAO,MAAMC,eAAe,CAACV,MAAgBC;IAC3C,KAAK,MAAMC,OAAOF,KAAM;QACtB,MAAMG,QAAQN,aAAaO,GAAG,CAACF;QAC/B,MAAMS,UAAUR,CAAAA,yBAAAA,MAAOS,KAAK,KAAI;QAEhC,IAAI,OAAOD,YAAY,YAAYA,UAAUV,WAAW;YACtD,OAAO;QACT;IACF;IAEA,OAAO;AACT,EAAC","ignoreList":[0]}