{"version":3,"file":"cacheComponents.mjs","names":[],"sources":["../../src/errors/cacheComponents.ts"],"sourcesContent":["import { createGtNextDiagnostic } from './diagnostics';\n\n// ---- WARNINGS ---- //\nexport type CacheComponentsRequestFunction = 'getLocale' | 'getRegion';\n\nexport const createCacheComponentsMissingRequestFunctionsWarning = (\n  requestFunctions: CacheComponentsRequestFunction[]\n) => {\n  const isPlural = requestFunctions.length > 1;\n  const functionNames = requestFunctions\n    .map((requestFunction) => `${requestFunction}()`)\n    .join(' and ');\n  const fileNames = requestFunctions\n    .map((requestFunction) => `${requestFunction}.ts`)\n    .join(' and ');\n  const configKeys = requestFunctions\n    .map((requestFunction) => `${requestFunction}Path`)\n    .join(' and ');\n\n  return createGtNextDiagnostic({\n    whatHappened: `cacheComponents is enabled, but custom ${functionNames} ${isPlural ? 'are' : 'is'} not configured`,\n    wayOut:\n      'cacheComponents requires explicit request functions because request values cannot be inferred safely during prerendering',\n    fix: `Add ${fileNames} ${isPlural ? 'files' : 'file'}, or configure ${configKeys}`,\n  });\n};\n\nexport const cacheComponentsNonLocalTranslationsWarning =\n  createGtNextDiagnostic({\n    severity: 'Warning',\n    whatHappened:\n      'cacheComponents is enabled, but translations are not stored locally',\n    wayOut: 'Prerendering may fail',\n    fix: 'Store translations locally before building cached pages',\n    docsUrl: 'https://generaltranslation.com/en-US/docs/next/guides/local-tx',\n  });\n\nexport const cacheComponentsMissingLoadTranslationsError =\n  createGtNextDiagnostic({\n    severity: 'Error',\n    whatHappened:\n      'cacheComponents is enabled, but custom loadTranslations() is not configured',\n    wayOut:\n      'gt-next cannot safely use the default remote translation loader with Cache Components',\n    fix: 'Add a loadTranslations.ts file, or configure loadTranslationsPath, and mark any dynamic loading with \"use cache\"',\n  });\n\nexport const cacheComponentsDevHotReloadDisabledWarning =\n  createGtNextDiagnostic({\n    severity: 'Warning',\n    whatHappened:\n      'cacheComponents is enabled, so development runtime translation hot reload has been disabled',\n    why: 'development runtime translation performs dynamic requests that are not allowed with Cache Components',\n    fix: 'Use local translations, or disable cacheComponents while using development runtime translation hot reload',\n  });\n"],"mappings":";;AAKA,MAAa,uDACX,qBACG;CACH,MAAM,WAAW,iBAAiB,SAAS;CAC3C,MAAM,gBAAgB,iBACnB,KAAK,oBAAoB,GAAG,gBAAgB,IAAI,CAChD,KAAK,QAAQ;CAChB,MAAM,YAAY,iBACf,KAAK,oBAAoB,GAAG,gBAAgB,KAAK,CACjD,KAAK,QAAQ;CAChB,MAAM,aAAa,iBAChB,KAAK,oBAAoB,GAAG,gBAAgB,MAAM,CAClD,KAAK,QAAQ;AAEhB,QAAO,uBAAuB;EAC5B,cAAc,0CAA0C,cAAc,GAAG,WAAW,QAAQ,KAAK;EACjG,QACE;EACF,KAAK,OAAO,UAAU,GAAG,WAAW,UAAU,OAAO,iBAAiB;EACvE,CAAC;;AAGJ,MAAa,6CACX,uBAAuB;CACrB,UAAU;CACV,cACE;CACF,QAAQ;CACR,KAAK;CACL,SAAS;CACV,CAAC;AAEJ,MAAa,8CACX,uBAAuB;CACrB,UAAU;CACV,cACE;CACF,QACE;CACF,KAAK;CACN,CAAC;AAEJ,MAAa,6CACX,uBAAuB;CACrB,UAAU;CACV,cACE;CACF,KAAK;CACL,KAAK;CACN,CAAC"}