@zharp/cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +94 -3
- package/dist/cli.js +770 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.mts +292 -0
- package/dist/index.d.ts +292 -0
- package/dist/index.js +786 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +727 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +60 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/api.ts","../src/debug-id.ts","../src/elf.ts","../src/files.ts","../src/log.ts","../src/macho.ts","../src/native.ts","../src/sourcemaps.ts","../src/version.ts","../src/build.ts"],"sourcesContent":["/**\r\n * @zharp/cli as a library: what the `zharp` command and the bundler plugins are made of.\r\n */\r\nexport { DEFAULT_URL, UploadError, artifactsUrl, resolveConnection, uploadArtifact, type Artifact, type ArtifactKind, type Connection } from './api';\r\nexport { DEBUG_ID_COMMENT, debugIdFromContent, existingDebugId, injectCode, injectMap, registrationSnippet, withoutSourceMappingUrl } from './debug-id';\r\nexport { readElf, type ElfInfo } from './elf';\r\nexport { globToRegExp, pathFilter, type Pattern } from './files';\r\nexport { consoleLogger, silentLogger, type Logger } from './log';\r\nexport { readMachO, type MachOImage } from './macho';\r\nexport { findDartSymbols, findDsymImages, findObfuscationMap, type DartSymbolsUploadOptions, uploadDartSymbols, uploadDsyms, uploadProguard, type NativeUploadOptions } from './native';\r\nexport {\r\n deleteSourcemaps,\r\n findSourceFiles,\r\n injectDirectory,\r\n mapFor,\r\n uploadSourcemaps,\r\n type InjectOptions,\r\n type InjectedFile,\r\n type SourceFile,\r\n type UploadOptions,\r\n type UploadResult,\r\n} from './sourcemaps';\r\nexport { VERSION } from './version';\r\nexport { defaultRelease, pluginLogger, processBuildOutput, type ProcessBuildResult, type ZharpPluginOptions } from './build';\r\n","/**\r\n * The artifact upload API: `POST /api/v1/applications/:id/artifacts`, multipart, with a\r\n * workspace API key that has the `artifacts:write` scope.\r\n */\r\nimport { gzipSync } from 'node:zlib';\r\n\r\nexport const DEFAULT_URL = 'https://api.zharp.io';\r\n\r\nexport type ArtifactKind = 'sourcemap' | 'minified-source' | 'proguard' | 'dart-symbols' | 'dart-obfuscation-map' | 'dsym';\r\n\r\nexport interface Connection {\r\n /** The Zharp API's base URL, e.g. https://api.zharp.io. */\r\n url: string;\r\n /** A workspace API key with the `artifacts:write` scope. */\r\n authToken: string;\r\n /** The application's ID, as in the dashboard URL. */\r\n app: string | number;\r\n}\r\n\r\nexport interface Artifact {\r\n kind: ArtifactKind;\r\n debugId: string;\r\n /** The file's path or URL (JS), or file name. */\r\n name: string;\r\n release?: string;\r\n arch?: string;\r\n data: Uint8Array;\r\n /** Send gzipped (large native symbol files). */\r\n gzip?: boolean;\r\n}\r\n\r\nexport class UploadError extends Error {\r\n constructor(\r\n message: string,\r\n readonly status?: number,\r\n /** Retrying will not help: a rejected key, a missing app, a bad request. */\r\n readonly permanent = false,\r\n ) {\r\n super(message);\r\n this.name = 'UploadError';\r\n }\r\n}\r\n\r\n/**\r\n * The connection from options and the environment (`ZHARP_AUTH_TOKEN`, `ZHARP_URL`,\r\n * `ZHARP_APP`). Throws with what is missing.\r\n */\r\nexport function resolveConnection(options: { url?: string; authToken?: string; app?: string | number }): Connection {\r\n const authToken = options.authToken || process.env.ZHARP_AUTH_TOKEN;\r\n const app = options.app ?? process.env.ZHARP_APP;\r\n const missing: string[] = [];\r\n if (!authToken) missing.push('an auth token (ZHARP_AUTH_TOKEN, or the authToken option): a workspace API key with the \"artifacts:write\" scope');\r\n if (app === undefined || app === '') missing.push('the application ID (--app, the app option, or ZHARP_APP)');\r\n if (missing.length) throw new UploadError(`Cannot upload without ${missing.join(' and ')}.`, undefined, true);\r\n return { url: (options.url || process.env.ZHARP_URL || DEFAULT_URL).replace(/\\/+$/, ''), authToken: authToken!, app: app! };\r\n}\r\n\r\nexport function artifactsUrl(connection: Connection): string {\r\n return `${connection.url}/api/v1/applications/${encodeURIComponent(String(connection.app))}/artifacts`;\r\n}\r\n\r\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\r\n\r\n/** Upload one artifact, retrying network failures, 408, 429 and 5xx with backoff. */\r\nexport async function uploadArtifact(\r\n connection: Connection,\r\n artifact: Artifact,\r\n options: { retries?: number; fetch?: typeof fetch; backoffMs?: number } = {},\r\n): Promise<unknown> {\r\n const doFetch = options.fetch ?? fetch;\r\n const retries = options.retries ?? 3;\r\n const backoff = options.backoffMs ?? 1000;\r\n const fileName = (artifact.name.split('/').pop() || 'artifact') + (artifact.gzip ? '.gz' : '');\r\n const payload = artifact.gzip ? gzipSync(artifact.data) : artifact.data;\r\n\r\n for (let attempt = 0; ; attempt++) {\r\n // A fresh body per attempt: a FormData is consumed by the request that sends it.\r\n const form = new FormData();\r\n form.set('kind', artifact.kind);\r\n form.set('debugId', artifact.debugId);\r\n form.set('name', artifact.name);\r\n if (artifact.release) form.set('release', artifact.release);\r\n if (artifact.arch) form.set('arch', artifact.arch);\r\n const type = artifact.gzip ? 'application/gzip' : artifact.kind === 'sourcemap' ? 'application/json' : 'application/octet-stream';\r\n form.set('file', new Blob([payload as Uint8Array<ArrayBuffer>], { type }), fileName);\r\n\r\n let retryAfter = 0;\r\n let error: UploadError;\r\n try {\r\n const response = await doFetch(artifactsUrl(connection), {\r\n method: 'POST',\r\n headers: { Authorization: `Bearer ${connection.authToken}`, 'User-Agent': 'zharp-cli' },\r\n body: form,\r\n });\r\n const text = await response.text().catch(() => '');\r\n if (response.ok) {\r\n try {\r\n return text ? JSON.parse(text) : null;\r\n } catch {\r\n return text;\r\n }\r\n }\r\n error = describeFailure(response.status, text, connection);\r\n retryAfter = Number(response.headers.get('retry-after')) * 1000 || 0;\r\n } catch (cause) {\r\n error = new UploadError(`Could not reach ${connection.url}: ${(cause as Error)?.message ?? cause}`);\r\n }\r\n if (error.permanent || attempt >= retries) throw error;\r\n await sleep(Math.max(retryAfter, backoff * 2 ** attempt));\r\n }\r\n}\r\n\r\nfunction serverMessage(text: string): string {\r\n try {\r\n const body = JSON.parse(text);\r\n const message = body?.message ?? body?.error;\r\n if (typeof message === 'string') return message;\r\n if (Array.isArray(message)) return message.join('; ');\r\n } catch {}\r\n return text.slice(0, 300);\r\n}\r\n\r\nfunction describeFailure(status: number, text: string, connection: Connection): UploadError {\r\n const detail = serverMessage(text);\r\n const retryable = status === 408 || status === 429 || status >= 500;\r\n const explain: Record<number, string> = {\r\n 401: 'The auth token was rejected — check ZHARP_AUTH_TOKEN (a workspace API key, not the app key).',\r\n 403: 'The API key cannot upload here — it needs the \"artifacts:write\" scope, in the workspace that owns the app.',\r\n 404: `Application ${connection.app} was not found — check --app (the ID in the app's dashboard URL) and ZHARP_URL.`,\r\n 413: 'The file is larger than the server accepts.',\r\n };\r\n const message = `${explain[status] ?? `Upload failed with HTTP ${status}.`}${detail ? ` Server said: ${detail}` : ''}`;\r\n return new UploadError(message, status, !retryable);\r\n}\r\n\r\n/** Run `fn` over `items`, `limit` at a time. Stops at the first error. */\r\nexport async function eachLimit<T>(items: T[], limit: number, fn: (item: T, index: number) => Promise<void>): Promise<void> {\r\n let next = 0;\r\n let failed: unknown;\r\n const worker = async () => {\r\n while (failed === undefined && next < items.length) {\r\n const index = next++;\r\n try {\r\n await fn(items[index], index);\r\n } catch (error) {\r\n failed ??= error;\r\n }\r\n }\r\n };\r\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));\r\n if (failed !== undefined) throw failed;\r\n}\r\n","/**\r\n * Debug IDs for JavaScript, after the TC39 source map \"debug ID\" proposal: one UUID per emitted\r\n * file, written into the file (`//# debugId=<uuid>`) and into its source map (`\"debugId\"`), so an\r\n * error's frames can be matched to the exact map whatever URL the file was served from.\r\n *\r\n * Besides the comment, each file gets one line that registers it at runtime — the SDKs read\r\n * `globalThis.__zharpDebugIds` to know which build each file in a stack came from.\r\n */\r\nimport { createHash } from 'node:crypto';\r\n\r\nexport const DEBUG_ID_COMMENT = '//# debugId=';\r\nconst DEBUG_ID_PATTERN = /^\\/\\/# debugId=([0-9a-fA-F-]{36})\\s*$/m;\r\nconst SOURCE_MAPPING_URL = /^\\/\\/[#@] sourceMappingURL=(.*?)\\s*$/;\r\n\r\n/**\r\n * The UUID for a file's content: the first 16 bytes of its SHA-256, with the version and variant\r\n * bits of a v4 UUID. The same output always gets the same ID, so a rebuild of unchanged code\r\n * does not need a new upload.\r\n */\r\nexport function debugIdFromContent(content: string | Uint8Array): string {\r\n const bytes = createHash('sha256').update(content).digest().subarray(0, 16);\r\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\r\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\r\n const hex = bytes.toString('hex');\r\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\r\n}\r\n\r\n/**\r\n * The runtime registration: ES5, so it is safe in any bundle whatever its target, and wrapped in\r\n * a try so it can never break the file it is in. The key is a stack taken inside the file — its\r\n * top frame is the file's own URL or path, as the runtime names it.\r\n */\r\nexport function registrationSnippet(debugId: string): string {\r\n return (\r\n ';!function(){try{var g=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:' +\r\n '\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:{},s=(new Error).stack;' +\r\n `s&&((g.__zharpDebugIds=g.__zharpDebugIds||{})[s]=\"${debugId}\")}catch(e){}}();`\r\n );\r\n}\r\n\r\n/** The debug ID already in a file, if it has one. */\r\nexport function existingDebugId(code: string): string | undefined {\r\n // Only at the end of the file: a bundle may contain another file's comment in its middle.\r\n const lines = code.trimEnd().split('\\n');\r\n for (let i = lines.length - 1; i >= 0 && i >= lines.length - 4; i--) {\r\n const match = DEBUG_ID_PATTERN.exec(lines[i].trim());\r\n if (match) return match[1].toLowerCase();\r\n }\r\n return undefined;\r\n}\r\n\r\n/** Whether the file's tail already registers it at runtime. */\r\nexport function hasRegistration(code: string): boolean {\r\n return code.slice(-2000).includes('.__zharpDebugIds=');\r\n}\r\n\r\n/** The `sourceMappingURL` the file's last line points at, if any (data: URLs included). */\r\nexport function sourceMappingUrl(code: string): string | undefined {\r\n const lines = code.trimEnd().split('\\n');\r\n for (let i = lines.length - 1; i >= 0 && i >= lines.length - 3; i--) {\r\n const match = SOURCE_MAPPING_URL.exec(lines[i].trim());\r\n if (match) return match[1];\r\n }\r\n return undefined;\r\n}\r\n\r\nexport interface InjectedCode {\r\n code: string;\r\n debugId: string;\r\n /** False when the file already had a debug ID: nothing was changed. */\r\n changed: boolean;\r\n}\r\n\r\n/**\r\n * The file with its debug ID: the registration line and the comment, appended after the code —\r\n * before a trailing `sourceMappingURL` comment, if there is one. Appending leaves every existing\r\n * line and column where it was, so the source map stays valid without being rewritten.\r\n *\r\n * A file that already has a debug ID is returned as it is, with that ID.\r\n */\r\nexport function injectCode(code: string, options: { stripSourceMappingUrl?: boolean } = {}): InjectedCode {\r\n const existing = existingDebugId(code);\r\n const eol = code.includes('\\r\\n') ? '\\r\\n' : '\\n';\r\n if (existing) {\r\n let out = code;\r\n // A bundler that writes debug IDs itself (Rollup's sourcemapDebugIds, webpack's\r\n // `-debugids` devtools, Turbopack) adds the comment but not Zharp's registration.\r\n if (!hasRegistration(code)) {\r\n const lines = code.split(/\\r?\\n/);\r\n let at = lines.length - 1;\r\n while (at > 0 && !lines[at].trim().startsWith(DEBUG_ID_COMMENT)) at--;\r\n lines.splice(at, 0, registrationSnippet(existing));\r\n out = lines.join(eol);\r\n }\r\n if (options.stripSourceMappingUrl) out = withoutSourceMappingUrl(out);\r\n return { code: out, debugId: existing, changed: out !== code };\r\n }\r\n const debugId = debugIdFromContent(code);\r\n const lines = code.split(/\\r?\\n/);\r\n // The trailing sourceMappingURL comment (and the blank lines after it) stays last.\r\n let tail: string[] = [];\r\n let end = lines.length;\r\n while (end > 0 && lines[end - 1].trim() === '') end--;\r\n if (end > 0 && SOURCE_MAPPING_URL.test(lines[end - 1].trim())) {\r\n tail = options.stripSourceMappingUrl ? [] : [lines[end - 1]];\r\n end--;\r\n }\r\n const body = lines.slice(0, end);\r\n const out = [...body, registrationSnippet(debugId), `${DEBUG_ID_COMMENT}${debugId}`, ...tail].join(eol) + eol;\r\n return { code: out, debugId, changed: true };\r\n}\r\n\r\n/** The code without its trailing `sourceMappingURL` comment — for maps that are not shipped. */\r\nexport function withoutSourceMappingUrl(code: string): string {\r\n const lines = code.split(/\\r?\\n/);\r\n const eol = code.includes('\\r\\n') ? '\\r\\n' : '\\n';\r\n let end = lines.length;\r\n while (end > 0 && lines[end - 1].trim() === '') end--;\r\n if (end > 0 && SOURCE_MAPPING_URL.test(lines[end - 1].trim())) return lines.slice(0, end - 1).join(eol) + eol;\r\n return code;\r\n}\r\n\r\n/**\r\n * The source map with the debug ID in it, under both spellings in use (`debugId` from the TC39\r\n * proposal, `debug_id` from earlier tooling). Returns the text unchanged when it already matches.\r\n */\r\nexport function injectMap(mapText: string, debugId: string): { text: string; changed: boolean; hasSourcesContent: boolean } {\r\n const map = JSON.parse(mapText);\r\n if (!map || typeof map !== 'object') throw new Error('not a source map');\r\n const hasSourcesContent = Array.isArray(map.sourcesContent) && map.sourcesContent.some((s: unknown) => typeof s === 'string');\r\n if (map.debugId === debugId && map.debug_id === debugId) return { text: mapText, changed: false, hasSourcesContent };\r\n map.debugId = debugId;\r\n map.debug_id = debugId;\r\n return { text: JSON.stringify(map), changed: true, hasSourcesContent };\r\n}\r\n","/**\r\n * The GNU build ID of an ELF file — what a Dart AOT snapshot prints as `build_id: '…'` in an\r\n * obfuscated stack, and what its `--split-debug-info` symbol file carries too.\r\n */\r\n\r\nconst NT_GNU_BUILD_ID = 3;\r\nconst SHT_NOTE = 7;\r\nconst PT_NOTE = 4;\r\n\r\nexport interface ElfInfo {\r\n /** Lowercase hex, as Dart prints it. */\r\n buildId?: string;\r\n bits: 32 | 64;\r\n littleEndian: boolean;\r\n /** e_machine, as an architecture name where known. */\r\n arch?: string;\r\n}\r\n\r\nconst MACHINES: Record<number, string> = { 3: 'x86', 40: 'arm', 62: 'x86_64', 183: 'arm64', 243: 'riscv64' };\r\n\r\nexport function isElf(data: Uint8Array): boolean {\r\n return data.length >= 16 && data[0] === 0x7f && data[1] === 0x45 && data[2] === 0x4c && data[3] === 0x46;\r\n}\r\n\r\n/** Parse just enough of an ELF file to find its GNU build ID. Throws on a file that is not ELF. */\r\nexport function readElf(data: Uint8Array): ElfInfo {\r\n if (!isElf(data)) throw new Error('not an ELF file');\r\n const bits = data[4] === 2 ? 64 : 32;\r\n const littleEndian = data[5] !== 2;\r\n const view = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const u16 = (o: number) => view.getUint16(o, littleEndian);\r\n const u32 = (o: number) => view.getUint32(o, littleEndian);\r\n const addr = (o: number) => (bits === 64 ? Number(view.getBigUint64(o, littleEndian)) : u32(o));\r\n const info: ElfInfo = { bits, littleEndian, arch: MACHINES[u16(18)] };\r\n\r\n const notes = (offset: number, size: number): string | undefined => {\r\n let p = offset;\r\n const end = Math.min(offset + size, data.length);\r\n while (p + 12 <= end) {\r\n const nameSize = u32(p);\r\n const descSize = u32(p + 4);\r\n const type = u32(p + 8);\r\n const nameStart = p + 12;\r\n const descStart = nameStart + align4(nameSize);\r\n if (descStart + descSize > end) break;\r\n const name = String.fromCharCode(...data.subarray(nameStart, nameStart + Math.max(0, nameSize - 1)));\r\n if (name === 'GNU' && type === NT_GNU_BUILD_ID) return hex(data.subarray(descStart, descStart + descSize));\r\n p = descStart + align4(descSize);\r\n }\r\n return undefined;\r\n };\r\n\r\n // Section headers first (symbol files keep them), then program headers (stripped binaries).\r\n const shoff = addr(bits === 64 ? 0x28 : 0x20);\r\n const shentsize = u16(bits === 64 ? 0x3a : 0x2e);\r\n const shnum = u16(bits === 64 ? 0x3c : 0x30);\r\n for (let i = 0; i < shnum && shoff > 0; i++) {\r\n const h = shoff + i * shentsize;\r\n if (h + shentsize > data.length) break;\r\n if (u32(h + 4) !== SHT_NOTE) continue;\r\n const offset = addr(bits === 64 ? h + 0x18 : h + 0x10);\r\n const size = addr(bits === 64 ? h + 0x20 : h + 0x14);\r\n const id = notes(offset, size);\r\n if (id) return { ...info, buildId: id };\r\n }\r\n const phoff = addr(bits === 64 ? 0x20 : 0x1c);\r\n const phentsize = u16(bits === 64 ? 0x36 : 0x2a);\r\n const phnum = u16(bits === 64 ? 0x38 : 0x2c);\r\n for (let i = 0; i < phnum && phoff > 0; i++) {\r\n const h = phoff + i * phentsize;\r\n if (h + phentsize > data.length) break;\r\n if (u32(h) !== PT_NOTE) continue;\r\n const offset = addr(bits === 64 ? h + 0x08 : h + 0x04);\r\n const size = addr(bits === 64 ? h + 0x20 : h + 0x10);\r\n const id = notes(offset, size);\r\n if (id) return { ...info, buildId: id };\r\n }\r\n return info;\r\n}\r\n\r\nconst align4 = (n: number) => (n + 3) & ~3;\r\n\r\nfunction hex(bytes: Uint8Array): string {\r\n let out = '';\r\n for (const b of bytes) out += b.toString(16).padStart(2, '0');\r\n return out;\r\n}\r\n","/** Walking a directory, and include/exclude patterns. */\r\nimport { readdirSync, statSync } from 'node:fs';\r\nimport { join, relative, sep } from 'node:path';\r\n\r\n/** A glob (`**`, `*`, `?`), a regular expression, or a list of them. */\r\nexport type Pattern = string | RegExp | Array<string | RegExp>;\r\n\r\n/** Every file under `dir`, recursively, as absolute paths. `node_modules` is skipped. */\r\nexport function walk(dir: string): string[] {\r\n const out: string[] = [];\r\n const visit = (current: string) => {\r\n for (const entry of readdirSync(current, { withFileTypes: true })) {\r\n const full = join(current, entry.name);\r\n if (entry.isDirectory()) {\r\n if (entry.name !== 'node_modules') visit(full);\r\n } else if (entry.isFile()) out.push(full);\r\n else if (entry.isSymbolicLink()) {\r\n try {\r\n if (statSync(full).isFile()) out.push(full);\r\n } catch {}\r\n }\r\n }\r\n };\r\n visit(dir);\r\n return out.sort();\r\n}\r\n\r\n/** `path` relative to `dir`, with forward slashes. */\r\nexport function relativePath(dir: string, path: string): string {\r\n return relative(dir, path).split(sep).join('/');\r\n}\r\n\r\n/** A glob as a regular expression over a relative path with forward slashes. */\r\nexport function globToRegExp(glob: string): RegExp {\r\n let out = '';\r\n for (let i = 0; i < glob.length; i++) {\r\n const c = glob[i];\r\n if (c === '*') {\r\n if (glob[i + 1] === '*') {\r\n // `**/` matches any number of directories, including none.\r\n const slash = glob[i + 2] === '/';\r\n out += slash ? '(?:.*/)?' : '.*';\r\n i += slash ? 2 : 1;\r\n } else out += '[^/]*';\r\n } else if (c === '?') out += '[^/]';\r\n else out += /[.+^${}()|[\\]\\\\]/.test(c) ? `\\\\${c}` : c;\r\n }\r\n // A pattern without a slash matches a file name at any depth, as .gitignore does.\r\n return new RegExp(glob.includes('/') ? `^${out}$` : `(?:^|/)${out}$`);\r\n}\r\n\r\nfunction toList(pattern: Pattern | undefined): RegExp[] {\r\n if (pattern === undefined) return [];\r\n return (Array.isArray(pattern) ? pattern : [pattern]).map((p) => (typeof p === 'string' ? globToRegExp(p) : p));\r\n}\r\n\r\n/** A filter over relative paths: in `include` (when given) and not in `exclude`. */\r\nexport function pathFilter(include?: Pattern, exclude?: Pattern): (relativePath: string) => boolean {\r\n const inc = toList(include);\r\n const exc = toList(exclude);\r\n return (path) => (inc.length === 0 || inc.some((r) => r.test(path))) && !exc.some((r) => r.test(path));\r\n}\r\n\r\nexport function formatBytes(bytes: number): string {\r\n if (bytes < 1024) return `${bytes} B`;\r\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} kB`;\r\n return `${(bytes / 1024 / 1024).toFixed(1)} MB`;\r\n}\r\n","/** Where progress goes. The CLI prints it; the bundler plugins prefix it with their name. */\r\nexport interface Logger {\r\n info(message: string): void;\r\n warn(message: string): void;\r\n}\r\n\r\nexport const consoleLogger = (prefix = '[zharp]'): Logger => ({\r\n info: (message) => console.log(`${prefix} ${message}`),\r\n warn: (message) => console.warn(`${prefix} ${message}`),\r\n});\r\n\r\nexport const silentLogger: Logger = { info() {}, warn() {} };\r\n","/**\r\n * The LC_UUID of each architecture in a Mach-O file (thin or universal) — the UUID an iOS crash\r\n * report lists for each binary image, and the key its dSYM is found by.\r\n */\r\n\r\nconst LC_UUID = 0x1b;\r\n\r\nexport interface MachOImage {\r\n /** Uppercase with dashes, as the iOS SDK (`UUID.uuidString`) and Apple's tools print it. */\r\n uuid: string;\r\n arch: string;\r\n /** Where the image is in the file: the whole file, or its slice of a universal one. */\r\n offset: number;\r\n size: number;\r\n}\r\n\r\nconst MH_MAGIC = 0xfeedface;\r\nconst MH_MAGIC_64 = 0xfeedfacf;\r\nconst FAT_MAGIC = 0xcafebabe;\r\nconst FAT_MAGIC_64 = 0xcafebabf;\r\n\r\nexport function isMachO(data: Uint8Array): boolean {\r\n if (data.length < 8) return false;\r\n const view = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const be = view.getUint32(0, false);\r\n const le = view.getUint32(0, true);\r\n return be === FAT_MAGIC || be === FAT_MAGIC_64 || [MH_MAGIC, MH_MAGIC_64].includes(le) || [MH_MAGIC, MH_MAGIC_64].includes(be);\r\n}\r\n\r\nexport function archName(cpuType: number, cpuSubtype: number): string {\r\n const sub = cpuSubtype & 0x00ffffff;\r\n switch (cpuType) {\r\n case 0x0100000c:\r\n return sub === 2 ? 'arm64e' : 'arm64';\r\n case 0x0200000c:\r\n return 'arm64_32';\r\n case 0x0000000c:\r\n return sub === 9 ? 'armv7' : sub === 11 ? 'armv7s' : sub === 12 ? 'armv7k' : 'arm';\r\n case 0x01000007:\r\n return sub === 8 ? 'x86_64h' : 'x86_64';\r\n case 0x00000007:\r\n return 'i386';\r\n default:\r\n return `cpu${cpuType}`;\r\n }\r\n}\r\n\r\n/** The images in a Mach-O file: one for a thin file, one per slice for a universal one. */\r\nexport function readMachO(data: Uint8Array): MachOImage[] {\r\n const view = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const magic = view.getUint32(0, false);\r\n if (magic === FAT_MAGIC || magic === FAT_MAGIC_64) {\r\n const wide = magic === FAT_MAGIC_64;\r\n const count = view.getUint32(4, false);\r\n const images: MachOImage[] = [];\r\n for (let i = 0; i < count; i++) {\r\n const h = 8 + i * (wide ? 32 : 20);\r\n const offset = wide ? Number(view.getBigUint64(h + 8, false)) : view.getUint32(h + 8, false);\r\n const size = wide ? Number(view.getBigUint64(h + 16, false)) : view.getUint32(h + 12, false);\r\n images.push(...readThin(data.subarray(offset, offset + size)).map((image) => ({ ...image, offset })));\r\n }\r\n return images;\r\n }\r\n return readThin(data);\r\n}\r\n\r\nfunction readThin(data: Uint8Array): MachOImage[] {\r\n const view = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n let little: boolean;\r\n if ([MH_MAGIC, MH_MAGIC_64].includes(view.getUint32(0, true))) little = true;\r\n else if ([MH_MAGIC, MH_MAGIC_64].includes(view.getUint32(0, false))) little = false;\r\n else throw new Error('not a Mach-O file');\r\n const wide = view.getUint32(0, little) === MH_MAGIC_64;\r\n const cpuType = view.getUint32(4, little);\r\n const cpuSubtype = view.getUint32(8, little);\r\n const ncmds = view.getUint32(16, little);\r\n let p = wide ? 32 : 28;\r\n for (let i = 0; i < ncmds && p + 8 <= data.length; i++) {\r\n const cmd = view.getUint32(p, little);\r\n const size = view.getUint32(p + 4, little);\r\n if (cmd === LC_UUID && p + 24 <= data.length) {\r\n return [{ uuid: formatUuid(data.subarray(p + 8, p + 24)), arch: archName(cpuType, cpuSubtype), offset: 0, size: data.length }];\r\n }\r\n if (size < 8) break;\r\n p += size;\r\n }\r\n return [];\r\n}\r\n\r\nfunction formatUuid(bytes: Uint8Array): string {\r\n let hex = '';\r\n for (const b of bytes) hex += b.toString(16).padStart(2, '0');\r\n hex = hex.toUpperCase();\r\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\r\n}\r\n","/**\r\n * Mobile symbol files: R8/ProGuard mappings (Android), Dart symbol files (Flutter\r\n * `--split-debug-info`) and dSYMs (iOS). Each is uploaded gzipped, keyed by the ID its platform's\r\n * errors carry.\r\n */\r\nimport { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\r\nimport { basename, dirname, join, resolve } from 'node:path';\r\nimport { eachLimit, uploadArtifact, type Artifact, type Connection } from './api';\r\nimport { readElf, isElf } from './elf';\r\nimport { formatBytes, walk } from './files';\r\nimport { consoleLogger, type Logger } from './log';\r\nimport { isMachO, readMachO } from './macho';\r\n\r\nexport interface NativeUploadOptions {\r\n release?: string;\r\n dryRun?: boolean;\r\n logger?: Logger;\r\n fetch?: typeof fetch;\r\n retries?: number;\r\n}\r\n\r\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\r\n\r\nasync function send(connection: Connection | null, artifacts: Artifact[], options: NativeUploadOptions): Promise<Artifact[]> {\r\n const logger = options.logger ?? consoleLogger();\r\n let done = 0;\r\n await eachLimit(artifacts, 2, async (artifact) => {\r\n if (!options.dryRun) {\r\n if (!connection) throw new Error('No connection to upload to.');\r\n await uploadArtifact(connection, artifact, { fetch: options.fetch, retries: options.retries });\r\n }\r\n done += 1;\r\n const extra = artifact.arch ? ` ${artifact.arch}` : '';\r\n logger.info(` [${done}/${artifacts.length}] ${options.dryRun ? 'would upload' : 'uploaded'} ${artifact.kind} ${artifact.name}${extra} (${formatBytes(artifact.data.length)}) ${artifact.debugId}`);\r\n });\r\n return artifacts;\r\n}\r\n\r\n// ── Android ──────────────────────────────────────────────────────────────────\r\n\r\n/** Upload an R8/ProGuard `mapping.txt` under the build's UUID (the one the Gradle plugin put in the app). */\r\nexport async function uploadProguard(mappingFile: string, uuid: string, connection: Connection | null, options: NativeUploadOptions = {}) {\r\n if (!UUID.test(uuid)) throw new Error(`--uuid must be a UUID, got \"${uuid}\".`);\r\n const data = readFileSync(mappingFile);\r\n return send(connection, [{ kind: 'proguard', debugId: uuid.toLowerCase(), name: basename(mappingFile), release: options.release, data, gzip: true }], options);\r\n}\r\n\r\n// ── Flutter ──────────────────────────────────────────────────────────────────\r\n\r\nexport interface DartSymbolFile {\r\n path: string;\r\n buildId: string;\r\n os?: string;\r\n arch?: string;\r\n}\r\n\r\nconst DART_ARCH: Record<string, string> = { x86_64: 'x64', x86: 'ia32' };\r\n\r\n/**\r\n * The Dart symbol files in a `--split-debug-info` directory (`app.android-arm64.symbols`, …), or\r\n * the one file given. The debug ID is the ELF GNU build ID — the `build_id` an obfuscated\r\n * stack prints.\r\n */\r\nexport function findDartSymbols(path: string, logger: Logger = consoleLogger()): DartSymbolFile[] {\r\n const files = statSync(path).isDirectory() ? walk(resolve(path)) : [resolve(path)];\r\n const out: DartSymbolFile[] = [];\r\n for (const file of files) {\r\n const named = /\\.symbols$/.test(file);\r\n const data = readFileSync(file);\r\n if (!isElf(data)) {\r\n if (named) logger.warn(`Skipped ${basename(file)}: not an ELF file.`);\r\n continue;\r\n }\r\n const elf = readElf(data);\r\n if (!elf.buildId) {\r\n logger.warn(`Skipped ${basename(file)}: it has no GNU build ID.`);\r\n continue;\r\n }\r\n const match = /\\.([a-z]+)-([a-z0-9_]+)\\.symbols$/.exec(basename(file));\r\n out.push({ path: file, buildId: elf.buildId, os: match?.[1], arch: match?.[2] ?? (elf.arch && (DART_ARCH[elf.arch] ?? elf.arch)) });\r\n }\r\n return out;\r\n}\r\n\r\n/**\r\n * The obfuscation map Flutter writes with\r\n * `--extra-gen-snapshot-options=--save-obfuscation-map=<file>`: `obfuscation.json` or\r\n * `*.obfuscation.json`, in the symbols directory or the directory next to it.\r\n */\r\nexport function findObfuscationMap(symbolsPath: string): string | undefined {\r\n const dir = statSync(symbolsPath).isDirectory() ? resolve(symbolsPath) : dirname(resolve(symbolsPath));\r\n for (const where of [dir, dirname(dir)]) {\r\n let names: string[];\r\n try {\r\n names = readdirSync(where).sort();\r\n } catch {\r\n continue;\r\n }\r\n const found = names.find((n) => n === 'obfuscation.json') ?? names.find((n) => n.endsWith('.obfuscation.json'));\r\n if (found && statSync(join(where, found)).isFile()) return join(where, found);\r\n }\r\n return undefined;\r\n}\r\n\r\n/** The map's contents, checked: a JSON array of obfuscated/original name pairs (flat or nested). */\r\nfunction readObfuscationMap(file: string): Buffer {\r\n const data = readFileSync(file);\r\n let parsed: unknown;\r\n try {\r\n parsed = JSON.parse(data.toString('utf8'));\r\n } catch (error) {\r\n throw new Error(`${file} is not valid JSON (${(error as Error).message}).`);\r\n }\r\n if (!Array.isArray(parsed)) throw new Error(`${file} is not a Dart obfuscation map: expected a JSON array of [obfuscated, original] names.`);\r\n return data;\r\n}\r\n\r\nexport interface DartSymbolsUploadOptions extends NativeUploadOptions {\r\n /** The obfuscation map to upload with the symbols. Default: found next to them (see findObfuscationMap). */\r\n obfuscationMap?: string;\r\n}\r\n\r\nexport async function uploadDartSymbols(path: string, connection: Connection | null, options: DartSymbolsUploadOptions = {}) {\r\n const logger = options.logger ?? consoleLogger();\r\n const files = findDartSymbols(path, logger);\r\n if (files.length === 0) throw new Error(`No Dart symbol files in ${path} — build with \\`flutter build … --obfuscate --split-debug-info=<dir>\\` and pass that directory.`);\r\n logger.info(`${options.dryRun ? 'Would upload' : 'Uploading'} ${files.length} Dart symbol file(s)`);\r\n const artifacts: Artifact[] = files.map((f) => ({\r\n kind: 'dart-symbols',\r\n debugId: f.buildId,\r\n name: basename(f.path),\r\n arch: f.arch,\r\n release: options.release,\r\n data: readFileSync(f.path),\r\n gzip: true,\r\n }));\r\n if (options.obfuscationMap && !existsSync(options.obfuscationMap)) throw new Error(`${options.obfuscationMap} does not exist.`);\r\n const mapFile = options.obfuscationMap ?? findObfuscationMap(path);\r\n if (mapFile) {\r\n const data = readObfuscationMap(mapFile);\r\n // One map serves every architecture of the build: once per build ID.\r\n const buildIds = [...new Set(files.map((f) => f.buildId))];\r\n logger.info(`With obfuscation map ${basename(mapFile)} for ${buildIds.length} build ID(s)`);\r\n for (const debugId of buildIds) {\r\n artifacts.push({ kind: 'dart-obfuscation-map', debugId, name: basename(mapFile), release: options.release, data, gzip: true });\r\n }\r\n } else {\r\n logger.info('No obfuscation map found (build with --extra-gen-snapshot-options=--save-obfuscation-map=build/obfuscation.json, or pass --obfuscation-map): obfuscated names in error messages stay as they are.');\r\n }\r\n return send(connection, artifacts, options);\r\n}\r\n\r\n// ── iOS ──────────────────────────────────────────────────────────────────────\r\n\r\nexport interface DsymImage {\r\n /** The DWARF file inside the .dSYM bundle. */\r\n path: string;\r\n uuid: string;\r\n arch: string;\r\n offset: number;\r\n size: number;\r\n}\r\n\r\n/**\r\n * The binary images in a .dSYM bundle, a folder of them (Xcode's `$DWARF_DSYM_FOLDER_PATH`), or\r\n * a DWARF file itself. Universal files give one image per architecture.\r\n */\r\nexport function findDsymImages(path: string): DsymImage[] {\r\n const root = resolve(path);\r\n const candidates = statSync(root).isDirectory()\r\n ? walk(root).filter((f) => /[\\\\/]Contents[\\\\/]Resources[\\\\/]DWARF[\\\\/][^\\\\/]+$/.test(f))\r\n : [root];\r\n const out: DsymImage[] = [];\r\n for (const file of candidates) {\r\n const data = readFileSync(file);\r\n if (!isMachO(data)) continue;\r\n for (const image of readMachO(data)) out.push({ path: file, ...image });\r\n }\r\n return out;\r\n}\r\n\r\nexport async function uploadDsyms(path: string, connection: Connection | null, options: NativeUploadOptions = {}) {\r\n const logger = options.logger ?? consoleLogger();\r\n const images = findDsymImages(path);\r\n if (images.length === 0) throw new Error(`No dSYM DWARF files in ${path} — pass a .dSYM bundle or the folder that holds them ($DWARF_DSYM_FOLDER_PATH).`);\r\n logger.info(`${options.dryRun ? 'Would upload' : 'Uploading'} ${images.length} dSYM image(s)`);\r\n const cache = new Map<string, Buffer>();\r\n const artifacts: Artifact[] = images.map((image) => {\r\n let data = cache.get(image.path);\r\n if (!data) cache.set(image.path, (data = readFileSync(image.path)));\r\n return {\r\n kind: 'dsym',\r\n debugId: image.uuid,\r\n name: basename(image.path),\r\n arch: image.arch,\r\n release: options.release,\r\n // One architecture's slice of a universal file is a complete Mach-O file on its own.\r\n data: data.subarray(image.offset, image.offset + image.size),\r\n gzip: true,\r\n };\r\n });\r\n return send(connection, artifacts, options);\r\n}\r\n","/**\r\n * Source maps for JavaScript: inject debug IDs into a build's output, upload each file and its\r\n * map, and delete the maps so they are not served.\r\n */\r\nimport { existsSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';\r\nimport { dirname, isAbsolute, resolve } from 'node:path';\r\nimport { eachLimit, uploadArtifact, type Connection } from './api';\r\nimport { existingDebugId, injectCode, injectMap, sourceMappingUrl, withoutSourceMappingUrl } from './debug-id';\r\nimport { formatBytes, pathFilter, relativePath, walk, type Pattern } from './files';\r\nimport { consoleLogger, type Logger } from './log';\r\n\r\nconst JS_FILE = /\\.(?:js|mjs|cjs)$/;\r\n\r\nexport interface SourceFile {\r\n /** Absolute path of the JavaScript file. */\r\n file: string;\r\n /** Absolute path of its source map. */\r\n map: string;\r\n /** Path of the file relative to the directory, with forward slashes. */\r\n name: string;\r\n mapName: string;\r\n}\r\n\r\nexport interface FindOptions {\r\n include?: Pattern;\r\n exclude?: Pattern;\r\n /** Only these files (absolute paths) — the bundler plugins pass what the build wrote. */\r\n files?: string[];\r\n}\r\n\r\n/** The source map a JS file has: `<file>.map` next to it, or the file its `sourceMappingURL` names. */\r\nexport function mapFor(file: string, code?: string): string | undefined {\r\n const sibling = `${file}.map`;\r\n if (existsSync(sibling)) return sibling;\r\n const url = sourceMappingUrl(code ?? readFileSync(file, 'utf8'));\r\n if (!url || /^[a-z][a-z0-9+.-]*:/i.test(url)) return undefined; // data:, http:… are not files here\r\n let path: string;\r\n try {\r\n path = decodeURIComponent(url.split(/[?#]/)[0]);\r\n } catch {\r\n return undefined;\r\n }\r\n const full = isAbsolute(path) ? path : resolve(dirname(file), path);\r\n return existsSync(full) ? full : undefined;\r\n}\r\n\r\n/** Every JS file under `dir` that has a source map. */\r\nexport function findSourceFiles(dir: string, options: FindOptions = {}): SourceFile[] {\r\n const root = resolve(dir);\r\n const keep = pathFilter(options.include, options.exclude);\r\n const candidates = options.files ? options.files.map((f) => resolve(f)) : walk(root);\r\n const out: SourceFile[] = [];\r\n for (const file of candidates) {\r\n if (!JS_FILE.test(file) || !existsSync(file)) continue;\r\n const name = relativePath(root, file);\r\n if (!keep(name)) continue;\r\n const map = mapFor(file);\r\n if (map) out.push({ file, map, name, mapName: relativePath(root, map) });\r\n }\r\n return out;\r\n}\r\n\r\nexport interface InjectOptions extends FindOptions {\r\n /** Remove the `sourceMappingURL` comment too — for maps that are deleted after upload. */\r\n stripSourceMappingUrl?: boolean;\r\n dryRun?: boolean;\r\n logger?: Logger;\r\n}\r\n\r\nexport interface InjectedFile extends SourceFile {\r\n debugId: string;\r\n /** False when the file already had this debug ID. */\r\n changed: boolean;\r\n}\r\n\r\n/**\r\n * Add a debug ID to every JS file under `dir` that has a source map, and to the map. Running it\r\n * again changes nothing: a file that has a debug ID keeps it.\r\n */\r\nexport function injectDirectory(dir: string, options: InjectOptions = {}): InjectedFile[] {\r\n const logger = options.logger ?? consoleLogger();\r\n const files = findSourceFiles(dir, options);\r\n const out: InjectedFile[] = [];\r\n const noSourcesContent: string[] = [];\r\n for (const source of files) {\r\n const code = readFileSync(source.file, 'utf8');\r\n const injected = injectCode(code, { stripSourceMappingUrl: options.stripSourceMappingUrl });\r\n let map;\r\n try {\r\n map = injectMap(readFileSync(source.map, 'utf8'), injected.debugId);\r\n } catch (error) {\r\n logger.warn(`Skipped ${source.name}: ${source.mapName} is not a readable source map (${(error as Error).message}).`);\r\n continue;\r\n }\r\n if (!options.dryRun) {\r\n if (injected.changed) writeFileSync(source.file, injected.code);\r\n if (map.changed) writeFileSync(source.map, map.text);\r\n }\r\n if (!map.hasSourcesContent) noSourcesContent.push(source.mapName);\r\n const changed = injected.changed || map.changed;\r\n out.push({ ...source, debugId: injected.debugId, changed });\r\n logger.info(`${changed ? (options.dryRun ? 'would inject' : 'injected') : 'already has'} ${injected.debugId} ${source.name}`);\r\n }\r\n if (noSourcesContent.length) {\r\n logger.warn(\r\n `${noSourcesContent.length} source map(s) have no sourcesContent, so Zharp can show original names and lines but not the code around them: ${noSourcesContent.slice(0, 3).join(', ')}${noSourcesContent.length > 3 ? ', …' : ''}`,\r\n );\r\n }\r\n if (out.length === 0) logger.warn(`No JavaScript files with source maps found in ${dir}.`);\r\n return out;\r\n}\r\n\r\nexport interface UploadOptions extends FindOptions {\r\n release?: string;\r\n /** Delete the .map files once they are uploaded. */\r\n deleteAfter?: boolean;\r\n /** Also strip the `sourceMappingURL` comments that pointed at deleted maps. */\r\n stripSourceMappingUrl?: boolean;\r\n dryRun?: boolean;\r\n concurrency?: number;\r\n logger?: Logger;\r\n fetch?: typeof fetch;\r\n retries?: number;\r\n}\r\n\r\nexport interface UploadResult {\r\n files: number;\r\n artifacts: number;\r\n bytes: number;\r\n deleted: string[];\r\n /** Files with a map but no debug ID: run inject first. */\r\n skipped: string[];\r\n}\r\n\r\n/**\r\n * Upload every JS file under `dir` that has a debug ID, with its source map, keyed by that ID.\r\n * `connection` may be null in a dry run.\r\n */\r\nexport async function uploadSourcemaps(dir: string, connection: Connection | null, options: UploadOptions = {}): Promise<UploadResult> {\r\n const logger = options.logger ?? consoleLogger();\r\n const files = findSourceFiles(dir, options);\r\n const result: UploadResult = { files: 0, artifacts: 0, bytes: 0, deleted: [], skipped: [] };\r\n const work: Array<{ source: SourceFile; debugId: string; code: Buffer; map: Buffer }> = [];\r\n for (const source of files) {\r\n const code = readFileSync(source.file);\r\n const debugId = existingDebugId(code.toString('utf8'));\r\n if (!debugId) {\r\n result.skipped.push(source.name);\r\n continue;\r\n }\r\n work.push({ source, debugId, code, map: readFileSync(source.map) });\r\n }\r\n if (result.skipped.length) {\r\n logger.warn(`${result.skipped.length} file(s) have a source map but no debug ID — run \\`zharp sourcemaps inject\\` first: ${result.skipped.slice(0, 3).join(', ')}${result.skipped.length > 3 ? ', …' : ''}`);\r\n }\r\n if (work.length === 0) {\r\n logger.warn(`Nothing to upload in ${dir}.`);\r\n return result;\r\n }\r\n\r\n const total = work.length;\r\n logger.info(`${options.dryRun ? 'Would upload' : 'Uploading'} ${total} file(s) and their source maps${options.release ? ` for release ${options.release}` : ''}${connection ? ` to ${connection.url}, app ${connection.app}` : ''}`);\r\n let done = 0;\r\n await eachLimit(work, options.concurrency ?? 4, async ({ source, debugId, code, map }) => {\r\n const size = code.length + map.length;\r\n if (!options.dryRun) {\r\n if (!connection) throw new Error('No connection to upload to.');\r\n const common = { debugId, release: options.release };\r\n const opts = { fetch: options.fetch, retries: options.retries };\r\n await uploadArtifact(connection, { ...common, kind: 'minified-source', name: source.name, data: code }, opts);\r\n await uploadArtifact(connection, { ...common, kind: 'sourcemap', name: source.mapName, data: map }, opts);\r\n }\r\n done += 1;\r\n result.files += 1;\r\n result.artifacts += 2;\r\n result.bytes += size;\r\n logger.info(` [${done}/${total}] ${options.dryRun ? 'would upload' : 'uploaded'} ${source.name} + ${source.mapName} (${formatBytes(size)}) ${debugId}`);\r\n });\r\n\r\n if (options.deleteAfter && !options.dryRun) {\r\n result.deleted = deleteSourcemaps(work.map((w) => w.source), { stripSourceMappingUrl: options.stripSourceMappingUrl });\r\n logger.info(`Deleted ${result.deleted.length} source map(s) from the output.`);\r\n }\r\n logger.info(`${options.dryRun ? 'Dry run: would have uploaded' : 'Uploaded'} ${result.artifacts} artifact(s), ${formatBytes(result.bytes)}.`);\r\n return result;\r\n}\r\n\r\n/** Delete these files' source maps (and, if asked, the comments pointing at them). */\r\nexport function deleteSourcemaps(files: SourceFile[], options: { stripSourceMappingUrl?: boolean } = {}): string[] {\r\n const deleted: string[] = [];\r\n for (const source of files) {\r\n if (options.stripSourceMappingUrl && existsSync(source.file)) {\r\n const code = readFileSync(source.file, 'utf8');\r\n const stripped = withoutSourceMappingUrl(code);\r\n if (stripped !== code) writeFileSync(source.file, stripped);\r\n }\r\n if (existsSync(source.map)) {\r\n unlinkSync(source.map);\r\n deleted.push(source.mapName);\r\n }\r\n }\r\n return deleted;\r\n}\r\n","export const VERSION = '0.1.0';\r\n","/**\r\n * What every bundler plugin does once the build has written its files: inject debug IDs, upload\r\n * the files and their maps, and delete the maps so they are not deployed.\r\n */\r\nimport { resolveConnection, UploadError } from './api';\r\nimport type { Pattern } from './files';\r\nimport { consoleLogger, silentLogger, type Logger } from './log';\r\nimport { deleteSourcemaps, injectDirectory, uploadSourcemaps, type InjectedFile } from './sourcemaps';\r\n\r\nexport interface ZharpPluginOptions {\r\n /** The application's ID (the number in its dashboard URL). Default `ZHARP_APP`. */\r\n app?: string | number;\r\n /** File the upload under this release. Default `ZHARP_RELEASE`, or the commit SHA CI provides. */\r\n release?: string;\r\n /** A workspace API key with the `artifacts:write` scope. Default `ZHARP_AUTH_TOKEN`. */\r\n authToken?: string;\r\n /** The Zharp API. Default `ZHARP_URL`, or https://api.zharp.io. */\r\n url?: string;\r\n /** Only these output files (globs relative to the output directory, or regular expressions). */\r\n include?: Pattern;\r\n /** Not these output files. */\r\n exclude?: Pattern;\r\n /** Delete the .map files from the output once uploaded, so they are not deployed. Default true. */\r\n deleteSourcemapsAfterUpload?: boolean;\r\n /** Inject debug IDs and report what would be uploaded; upload and delete nothing. */\r\n dryRun?: boolean;\r\n /** Run on every build, not only production ones. */\r\n force?: boolean;\r\n /** Do nothing at all. */\r\n disabled?: boolean;\r\n /** Fail the build when the upload fails. Default false: a warning, and the build goes on. */\r\n failOnError?: boolean;\r\n /** No progress output (warnings still print). */\r\n silent?: boolean;\r\n}\r\n\r\n/** A release name from the options, the environment, or the commit SHA a CI system provides. */\r\nexport function defaultRelease(options: ZharpPluginOptions): string | undefined {\r\n const env = process.env;\r\n return (\r\n options.release ||\r\n env.ZHARP_RELEASE ||\r\n env.VERCEL_GIT_COMMIT_SHA ||\r\n env.GITHUB_SHA ||\r\n env.CI_COMMIT_SHA ||\r\n env.CF_PAGES_COMMIT_SHA ||\r\n env.COMMIT_REF ||\r\n env.RENDER_GIT_COMMIT ||\r\n undefined\r\n );\r\n}\r\n\r\nexport function pluginLogger(name: string, options: ZharpPluginOptions): Logger {\r\n const base = consoleLogger(`[${name}]`);\r\n return options.silent ? { info: silentLogger.info, warn: base.warn } : base;\r\n}\r\n\r\nexport interface ProcessBuildResult {\r\n injected: InjectedFile[];\r\n uploaded: boolean;\r\n deleted: string[];\r\n}\r\n\r\n/**\r\n * Inject, upload, delete — for the files a build just wrote to `dir` (or every file there when\r\n * `files` is not given).\r\n */\r\nexport async function processBuildOutput(\r\n dir: string,\r\n options: ZharpPluginOptions,\r\n context: { files?: string[]; logger?: Logger } = {},\r\n): Promise<ProcessBuildResult> {\r\n const logger = context.logger ?? pluginLogger('zharp', options);\r\n const result: ProcessBuildResult = { injected: [], uploaded: false, deleted: [] };\r\n if (options.disabled) return result;\r\n\r\n result.injected = injectDirectory(dir, { files: context.files, include: options.include, exclude: options.exclude, dryRun: false, logger: quiet(logger) });\r\n if (result.injected.length === 0) return result;\r\n logger.info(`Injected debug IDs into ${result.injected.length} file(s) in ${dir}`);\r\n const release = defaultRelease(options);\r\n\r\n if (options.dryRun) {\r\n await uploadSourcemaps(dir, null, { files: result.injected.map((f) => f.file), release, dryRun: true, logger });\r\n return result;\r\n }\r\n\r\n try {\r\n const connection = resolveConnection(options);\r\n await uploadSourcemaps(dir, connection, { files: result.injected.map((f) => f.file), release, logger });\r\n result.uploaded = true;\r\n } catch (error) {\r\n const message = error instanceof Error ? error.message : String(error);\r\n if (options.failOnError) throw error;\r\n logger.warn(`Source maps were not uploaded: ${message}${error instanceof UploadError && error.permanent ? '' : ' Errors from this build will show minified stacks.'}`);\r\n }\r\n\r\n // The maps go whether or not the upload worked: a deployed map is the source code, public.\r\n if (options.deleteSourcemapsAfterUpload !== false) {\r\n result.deleted = deleteSourcemaps(result.injected, { stripSourceMappingUrl: true });\r\n logger.info(`Deleted ${result.deleted.length} source map(s) from the output.`);\r\n }\r\n return result;\r\n}\r\n\r\n/** Per-file lines are noise inside a bundler's output: keep warnings only. */\r\nfunction quiet(logger: Logger): Logger {\r\n return { info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