{"version":3,"file":"node-builtins-DYfhPBnz.mjs","names":[],"sources":["../../shared/src/node-builtins.ts"],"sourcesContent":["import { isBuiltin } from \"node:module\";\n\n/**\n * Node-only ambient globals that the Tailor Platform runtime never defines.\n * The SDK derives the same set from the `globals` package at runtime and pins\n * it to this list in its tests, so the lint plugin can ship the names without\n * depending on `globals`.\n */\nexport const NODE_ONLY_GLOBAL_NAMES: readonly string[] = [\n  \"__dirname\",\n  \"__filename\",\n  \"Buffer\",\n  \"clearImmediate\",\n  \"exports\",\n  \"global\",\n  \"module\",\n  \"process\",\n  \"require\",\n  \"setImmediate\",\n];\n\nconst SUGGESTIONS: Record<string, string> = {\n  crypto: \"Use the Web Crypto API (globalThis.crypto) instead.\",\n  buffer: \"Use Uint8Array or ArrayBuffer instead.\",\n  fs: \"File system access is not available in the Tailor Platform runtime.\",\n  \"fs/promises\": \"File system access is not available in the Tailor Platform runtime.\",\n  path: \"Use URL or URLPattern for path manipulation.\",\n  http: \"Use the Fetch API (globalThis.fetch) for HTTP requests instead.\",\n  https: \"Use the Fetch API (globalThis.fetch) for HTTPS requests instead.\",\n  url: \"Use the URL and URLSearchParams Web APIs instead.\",\n  util: \"Use Web Standard APIs instead.\",\n  stream: \"Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.\",\n  \"stream/web\": \"Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.\",\n  events: \"Use EventTarget instead.\",\n  zlib: \"Use CompressionStream and DecompressionStream Web APIs instead.\",\n  querystring: \"Use URLSearchParams instead.\",\n  string_decoder: \"Use TextDecoder instead.\",\n};\n\n// Friendly suggestions for the most common members of NODE_ONLY_GLOBAL_NAMES.\n// A name without an entry here still gets flagged, just with the generic\n// message below instead of a targeted one.\nconst GLOBAL_SUGGESTIONS: Record<string, string> = {\n  process:\n    \"Use `defineConfig({ env })` and the `env` argument passed into the body function instead.\",\n  Buffer: \"Use Uint8Array or ArrayBuffer instead.\",\n  global: \"Use globalThis instead.\",\n  __dirname: \"File system paths are not available in the Tailor Platform runtime.\",\n  __filename: \"File system paths are not available in the Tailor Platform runtime.\",\n  require: \"Use a static `import` instead.\",\n  module: \"CommonJS module semantics are not available in the Tailor Platform runtime.\",\n  exports: \"CommonJS module semantics are not available in the Tailor Platform runtime.\",\n  setImmediate: \"Use setTimeout instead.\",\n  clearImmediate: \"Use clearTimeout instead.\",\n};\n\nexport function describeUnavailable(name: string): string {\n  return `\"${name}\" is not available in the Tailor Platform runtime.`;\n}\n\nfunction withSuggestion(name: string, suggestion: string | undefined): string {\n  const base = describeUnavailable(name);\n  return suggestion ? `${base} ${suggestion}` : base;\n}\n\nexport function isNodeBuiltinImport(specifier: string): boolean {\n  return isBuiltin(specifier);\n}\n\nexport function getNodeBuiltinMessage(specifier: string): string {\n  const bare = specifier.startsWith(\"node:\") ? specifier.slice(5) : specifier;\n  return withSuggestion(specifier, SUGGESTIONS[bare]);\n}\n\nexport function getForbiddenGlobalMessage(name: string): string {\n  return withSuggestion(\n    name,\n    Object.hasOwn(GLOBAL_SUGGESTIONS, name) ? GLOBAL_SUGGESTIONS[name] : undefined,\n  );\n}\n"],"mappings":"wCAqBA,MAAM,EAAsC,CAC1C,OAAQ,sDACR,OAAQ,yCACR,GAAI,sEACJ,cAAe,sEACf,KAAM,+CACN,KAAM,kEACN,MAAO,mEACP,IAAK,oDACL,KAAM,iCACN,OAAQ,iFACR,aAAc,iFACd,OAAQ,2BACR,KAAM,kEACN,YAAa,+BACb,eAAgB,0BAClB,EAKM,EAA6C,CACjD,QACE,4FACF,OAAQ,yCACR,OAAQ,0BACR,UAAW,sEACX,WAAY,sEACZ,QAAS,iCACT,OAAQ,8EACR,QAAS,8EACT,aAAc,0BACd,eAAgB,2BAClB,EAEA,SAAgB,oBAAoB,EAAsB,CACxD,MAAO,IAAI,EAAK,mDAClB,CAEA,SAAS,eAAe,EAAc,EAAwC,CAC5E,IAAM,EAAO,oBAAoB,CAAI,EACrC,OAAO,EAAa,GAAG,EAAK,GAAG,IAAe,CAChD,CAEA,SAAgB,oBAAoB,EAA4B,CAC9D,OAAO,EAAU,CAAS,CAC5B,CAEA,SAAgB,sBAAsB,EAA2B,CAC/D,IAAM,EAAO,EAAU,WAAW,OAAO,EAAI,EAAU,MAAM,CAAC,EAAI,EAClE,OAAO,eAAe,EAAW,EAAY,EAAK,CACpD,CAEA,SAAgB,0BAA0B,EAAsB,CAC9D,OAAO,eACL,EACA,OAAO,OAAO,EAAoB,CAAI,EAAI,EAAmB,GAAQ,IAAA,EACvE,CACF"}