react-smart-copy 1.10.0 → 1.12.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code.cjs","names":[],"sources":["../src/core/errors.ts","../src/code/inspect.ts","../src/code/lines.ts","../src/code/normalize.ts","../src/code/element.ts","../src/code/payload.ts","../src/core/text-field.ts","../src/code/paste.ts"],"sourcesContent":["import type { PasteSource } from './paste-reader';\n\n/**\n * Every way a clipboard operation can fail, as a closed union.\n *\n * `CopyError.message` is developer-facing (logs, telemetry). For user-facing\n * text use {@link describeCopyError} / {@link describePasteError}, or map\n * `type` through your own i18n layer.\n */\nexport type CopyErrorType =\n /** No Clipboard API (old browser, server, locked-down webview). Not retryable. */\n | 'unsupported'\n /** Page is not served over HTTPS/localhost. Not retryable. */\n | 'insecure-context'\n /** Browser or user blocked the operation. Also what Safari reports for a missing user gesture. */\n | 'permission-denied'\n /** The document lost focus mid-operation (Chromium). Retrying after refocus usually works. */\n | 'not-focused'\n /** Empty or malformed payload, or a lazy source that threw. Caught before touching the clipboard. */\n | 'invalid-payload'\n /** The browser cannot handle this MIME type (e.g. non-PNG image, HTML without ClipboardItem). */\n | 'unsupported-format'\n /** A lazy image source (or capture) threw, rejected or did not produce a Blob. */\n | 'blob-generation-failed'\n /** `retry()` was called after `maxRetries` was reached. Terminal. */\n | 'max-retries-exceeded'\n /** Paste: the clipboard held nothing matching `accept`. */\n | 'no-content'\n /** Content exceeded a configured safety limit (bytes, items or pixels). Not retryable. */\n | 'too-large'\n /** An operation did not settle within its deadline. Retryable. */\n | 'timeout'\n /** The caller aborted the operation through an `AbortSignal`. Not retryable. */\n | 'aborted'\n /** Anything the platform threw that we could not classify. */\n | 'unknown';\n\n/** Which clipboard direction failed; only changes developer-facing messages. */\nexport type ClipboardOperation = 'write' | 'read';\n\nexport interface CopyError {\n readonly type: CopyErrorType;\n readonly message: string;\n readonly cause?: unknown;\n}\n\nexport function createCopyError(type: CopyErrorType, message: string, cause?: unknown): CopyError {\n return cause === undefined ? { type, message } : { type, message, cause };\n}\n\nconst RETRYABLE_ERRORS: ReadonlySet<CopyErrorType> = /* @__PURE__ */ new Set<CopyErrorType>([\n 'permission-denied',\n 'not-focused',\n 'blob-generation-failed',\n 'timeout',\n 'unknown',\n]);\n\n/** Whether retrying the same payload could plausibly succeed. */\nexport function isRetryableError(error: CopyError): boolean {\n return RETRYABLE_ERRORS.has(error.type);\n}\n\n/**\n * Branded (not `instanceof`) so failures stay recognisable even when the core\n * is bundled twice, e.g. `react-smart-copy` and `react-smart-copy/core` together.\n */\nconst COPY_FAILURE_BRAND = Symbol.for('react-smart-copy.CopyFailure');\n\n/** Error thrown by adapters to carry a fully classified {@link CopyError}. */\nexport class CopyFailure extends Error {\n readonly copyError: CopyError;\n readonly [COPY_FAILURE_BRAND] = true;\n\n constructor(copyError: CopyError) {\n super(copyError.message);\n this.name = 'CopyFailure';\n this.copyError = copyError;\n }\n}\n\nexport function isCopyFailure(value: unknown): value is CopyFailure {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<PropertyKey, unknown>)[COPY_FAILURE_BRAND] === true\n );\n}\n\n/** Shorthand for throwing a classified failure. */\nexport function copyFailure(type: CopyErrorType, message: string, cause?: unknown): CopyFailure {\n return new CopyFailure(createCopyError(type, message, cause));\n}\n\nfunction readString(value: unknown, key: string): string | undefined {\n if (typeof value !== 'object' || value === null) return undefined;\n const field = (value as Record<string, unknown>)[key];\n return typeof field === 'string' ? field : undefined;\n}\n\n/**\n * Classifies anything thrown by the platform or an adapter into a {@link CopyError}.\n * `operation` only tailors the developer-facing message.\n */\nexport function toCopyError(cause: unknown, operation: ClipboardOperation = 'write'): CopyError {\n if (isCopyFailure(cause)) return cause.copyError;\n\n const name = readString(cause, 'name');\n const message = readString(cause, 'message') ?? '';\n const verb = operation === 'read' ? 'read' : 'write';\n\n switch (name) {\n case 'NotAllowedError':\n return /focus/i.test(message)\n ? createCopyError('not-focused', `The document was not focused during the clipboard ${verb}.`, cause)\n : createCopyError('permission-denied', `Clipboard ${verb} permission was denied.`, cause);\n case 'SecurityError':\n return createCopyError('insecure-context', 'The clipboard is blocked in this context.', cause);\n case 'NotSupportedError':\n case 'DataError':\n return createCopyError('unsupported-format', 'The browser rejected this clipboard format.', cause);\n case 'AbortError':\n return createCopyError('aborted', `The clipboard ${verb} was aborted.`, cause);\n case 'TimeoutError':\n return createCopyError('timeout', `The clipboard ${verb} timed out.`, cause);\n default:\n return createCopyError('unknown', message || `The clipboard ${verb} failed for an unknown reason.`, cause);\n }\n}\n\nconst COPY_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Copying isn't supported in this browser.\",\n 'insecure-context': 'Copying requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while copying. Try again.',\n 'invalid-payload': 'There is nothing to copy.',\n 'unsupported-format': \"This content can't be copied in this browser.\",\n 'blob-generation-failed': \"The image couldn't be prepared for copying.\",\n 'max-retries-exceeded': 'Copying failed after several attempts.',\n 'no-content': 'There is nothing to copy.',\n 'too-large': 'This content is too large to copy.',\n timeout: 'Copying took too long. Try again.',\n aborted: 'Copying was cancelled.',\n unknown: \"Couldn't copy to the clipboard. Try again.\",\n};\n\nconst PASTE_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Pasting isn't supported in this browser.\",\n 'insecure-context': 'Pasting requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while pasting. Try again.',\n 'invalid-payload': \"The clipboard content couldn't be read.\",\n 'unsupported-format': \"This clipboard content isn't supported here.\",\n 'blob-generation-failed': \"The pasted image couldn't be read.\",\n 'max-retries-exceeded': 'Pasting failed after several attempts.',\n 'no-content': \"The clipboard doesn't contain anything that can be pasted here.\",\n 'too-large': 'The clipboard content is too large to paste.',\n timeout: 'Pasting took too long. Try again.',\n aborted: 'Pasting was cancelled.',\n unknown: \"Couldn't read the clipboard. Try again.\",\n};\n\n/** Default English, user-facing sentence for a copy error. Replace for i18n. */\nexport function describeCopyError(error: CopyError): string {\n return COPY_DESCRIPTIONS[error.type];\n}\n\n/** Drops can only fail in these ways; the rest of the paste wording would mention the clipboard. */\nconst DROP_DESCRIPTIONS: Readonly<Partial<Record<CopyErrorType, string>>> = {\n 'invalid-payload': \"The dropped content couldn't be read.\",\n 'no-content': 'Nothing that was dropped can be used here.',\n 'too-large': 'The dropped content is too large.',\n unknown: \"Couldn't read the dropped content. Try again.\",\n};\n\n/**\n * Default English, user-facing sentence for a paste error. Pass the error\n * state's `source` to word drag-and-drop failures as drops. Replace for i18n.\n */\nexport function describePasteError(error: CopyError, source?: PasteSource): string {\n return (source === 'drop' ? DROP_DESCRIPTIONS[error.type] : undefined) ?? PASTE_DESCRIPTIONS[error.type];\n}\n","import { copyFailure } from '../core/errors';\n\n/**\n * What a character in code can be suspicious for.\n *\n * - `bidi-control`: reorders how text is displayed (Trojan Source, CVE-2021-42574).\n * - `invisible`: renders as nothing (zero-width spaces, tag characters, Hangul fillers).\n * - `control`: a control character other than tab, line feed, carriage return or form feed.\n * - `unusual-space`: a space that is not U+0020 (no-break, em, ideographic and similar spaces).\n * - `confusable-punctuation`: typographic punctuation in place of ASCII, as word\n * processors and chat apps write it (curly quotes, dashes, a Greek question mark).\n * - `mixed-script`: a Cyrillic or Greek letter inside a Latin word (a homoglyph attack).\n */\nexport type CodeFindingKind = 'bidi-control' | 'invisible' | 'control' | 'unusual-space' | 'confusable-punctuation' | 'mixed-script';\n\n/** Every finding kind, in a stable order. */\nexport const CODE_FINDING_KINDS: readonly CodeFindingKind[] = Object.freeze([\n 'bidi-control',\n 'invisible',\n 'control',\n 'unusual-space',\n 'confusable-punctuation',\n 'mixed-script',\n]);\n\n/**\n * `danger`: the code can run differently from how it reads (a bidi override, an\n * invisible identifier, a lookalike letter). `warning`: likely a copy artifact\n * that breaks the code or hides in it (curly quotes, a zero-width space).\n */\nexport type CodeFindingSeverity = 'danger' | 'warning';\n\nexport interface CodeFinding {\n readonly kind: CodeFindingKind;\n readonly severity: CodeFindingSeverity;\n /** Offset in the inspected text, in UTF-16 code units (as `String.prototype.slice` counts). */\n readonly index: number;\n /** Length in UTF-16 code units: 1, or 2 for a character outside the Basic Multilingual Plane. */\n readonly length: number;\n /** 1-based line. Lines end at `\\n`, `\\r\\n` or `\\r`. */\n readonly line: number;\n /** 1-based column in UTF-16 code units, as most editors count it. */\n readonly column: number;\n readonly codePoint: number;\n /** Developer-facing, e.g. `U+202E RIGHT-TO-LEFT OVERRIDE`. */\n readonly label: string;\n /** The safe replacement `cleanCode` writes (`''` removes it), or `null` when there is none to guess. */\n readonly replacement: string | null;\n}\n\nexport interface InspectCodeOptions {\n /** Which kinds to look for. Default: all of {@link CODE_FINDING_KINDS}. */\n readonly kinds?: readonly CodeFindingKind[];\n /** Stop after this many findings and set `truncated`. Default {@link DEFAULT_CODE_MAX_FINDINGS}. */\n readonly maxFindings?: number;\n}\n\nexport interface CodeInspection {\n /** In order of position. */\n readonly findings: readonly CodeFinding[];\n /** Whether any finding is `danger`. */\n readonly danger: boolean;\n /** Whether `maxFindings` stopped the scan early. */\n readonly truncated: boolean;\n}\n\nexport const DEFAULT_CODE_MAX_FINDINGS = 1000;\n\n/* ------------------------------------------------------------ Character table */\n\ninterface Rule {\n readonly kind: CodeFindingKind;\n readonly severity: CodeFindingSeverity;\n readonly replacement: string | null;\n readonly name: string;\n}\n\nconst rule = (kind: CodeFindingKind, severity: CodeFindingSeverity, replacement: string | null, name: string): Rule => ({\n kind,\n severity,\n replacement,\n name,\n});\n\n/** Characters with a fixed verdict. Ranges and context-dependent ones are handled in `classify`. */\nconst TABLE = /* @__PURE__ */ new Map<number, Rule>([\n // Explicit embeddings, overrides and isolates: what Trojan Source uses.\n [0x202a, rule('bidi-control', 'danger', '', 'LEFT-TO-RIGHT EMBEDDING')],\n [0x202b, rule('bidi-control', 'danger', '', 'RIGHT-TO-LEFT EMBEDDING')],\n [0x202c, rule('bidi-control', 'danger', '', 'POP DIRECTIONAL FORMATTING')],\n [0x202d, rule('bidi-control', 'danger', '', 'LEFT-TO-RIGHT OVERRIDE')],\n [0x202e, rule('bidi-control', 'danger', '', 'RIGHT-TO-LEFT OVERRIDE')],\n [0x2066, rule('bidi-control', 'danger', '', 'LEFT-TO-RIGHT ISOLATE')],\n [0x2067, rule('bidi-control', 'danger', '', 'RIGHT-TO-LEFT ISOLATE')],\n [0x2068, rule('bidi-control', 'danger', '', 'FIRST STRONG ISOLATE')],\n [0x2069, rule('bidi-control', 'danger', '', 'POP DIRECTIONAL ISOLATE')],\n // Implicit marks: they nudge the display order of neutral characters, but cannot reorder tokens.\n [0x200e, rule('bidi-control', 'warning', '', 'LEFT-TO-RIGHT MARK')],\n [0x200f, rule('bidi-control', 'warning', '', 'RIGHT-TO-LEFT MARK')],\n [0x061c, rule('bidi-control', 'warning', '', 'ARABIC LETTER MARK')],\n // Letters that render as blank space: an identifier made of them is invisible.\n [0x115f, rule('invisible', 'danger', '', 'HANGUL CHOSEONG FILLER')],\n [0x1160, rule('invisible', 'danger', '', 'HANGUL JUNGSEONG FILLER')],\n [0x3164, rule('invisible', 'danger', '', 'HANGUL FILLER')],\n [0xffa0, rule('invisible', 'danger', '', 'HALFWIDTH HANGUL FILLER')],\n [0x200b, rule('invisible', 'warning', '', 'ZERO WIDTH SPACE')],\n [0x2060, rule('invisible', 'warning', '', 'WORD JOINER')],\n [0x2061, rule('invisible', 'warning', '', 'FUNCTION APPLICATION')],\n [0x2062, rule('invisible', 'warning', '', 'INVISIBLE TIMES')],\n [0x2063, rule('invisible', 'warning', '', 'INVISIBLE SEPARATOR')],\n [0x2064, rule('invisible', 'warning', '', 'INVISIBLE PLUS')],\n [0xfeff, rule('invisible', 'warning', '', 'ZERO WIDTH NO-BREAK SPACE')],\n [0x00ad, rule('invisible', 'warning', '', 'SOFT HYPHEN')],\n [0x034f, rule('invisible', 'warning', '', 'COMBINING GRAPHEME JOINER')],\n [0x180e, rule('invisible', 'warning', '', 'MONGOLIAN VOWEL SEPARATOR')],\n [0x17b4, rule('invisible', 'warning', '', 'KHMER VOWEL INHERENT AQ')],\n [0x17b5, rule('invisible', 'warning', '', 'KHMER VOWEL INHERENT AA')],\n // Line and paragraph separators end a line in JavaScript but not in most editors.\n [0x2028, rule('control', 'warning', '\\n', 'LINE SEPARATOR')],\n [0x2029, rule('control', 'warning', '\\n', 'PARAGRAPH SEPARATOR')],\n [0x0085, rule('control', 'warning', '\\n', 'NEXT LINE')],\n [0x00a0, rule('unusual-space', 'warning', ' ', 'NO-BREAK SPACE')],\n [0x1680, rule('unusual-space', 'warning', ' ', 'OGHAM SPACE MARK')],\n [0x202f, rule('unusual-space', 'warning', ' ', 'NARROW NO-BREAK SPACE')],\n [0x205f, rule('unusual-space', 'warning', ' ', 'MEDIUM MATHEMATICAL SPACE')],\n [0x3000, rule('unusual-space', 'warning', ' ', 'IDEOGRAPHIC SPACE')],\n [0x2018, rule('confusable-punctuation', 'warning', \"'\", 'LEFT SINGLE QUOTATION MARK')],\n [0x2019, rule('confusable-punctuation', 'warning', \"'\", 'RIGHT SINGLE QUOTATION MARK')],\n [0x201a, rule('confusable-punctuation', 'warning', \"'\", 'SINGLE LOW-9 QUOTATION MARK')],\n [0x201b, rule('confusable-punctuation', 'warning', \"'\", 'SINGLE HIGH-REVERSED-9 QUOTATION MARK')],\n [0x2032, rule('confusable-punctuation', 'warning', \"'\", 'PRIME')],\n [0x02bc, rule('confusable-punctuation', 'warning', \"'\", 'MODIFIER LETTER APOSTROPHE')],\n [0x201c, rule('confusable-punctuation', 'warning', '\"', 'LEFT DOUBLE QUOTATION MARK')],\n [0x201d, rule('confusable-punctuation', 'warning', '\"', 'RIGHT DOUBLE QUOTATION MARK')],\n [0x201e, rule('confusable-punctuation', 'warning', '\"', 'DOUBLE LOW-9 QUOTATION MARK')],\n [0x201f, rule('confusable-punctuation', 'warning', '\"', 'DOUBLE HIGH-REVERSED-9 QUOTATION MARK')],\n [0x2033, rule('confusable-punctuation', 'warning', '\"', 'DOUBLE PRIME')],\n [0x2010, rule('confusable-punctuation', 'warning', '-', 'HYPHEN')],\n [0x2011, rule('confusable-punctuation', 'warning', '-', 'NON-BREAKING HYPHEN')],\n [0x2012, rule('confusable-punctuation', 'warning', '-', 'FIGURE DASH')],\n [0x2013, rule('confusable-punctuation', 'warning', '-', 'EN DASH')],\n [0x2212, rule('confusable-punctuation', 'warning', '-', 'MINUS SIGN')],\n // Word and macOS turn \"--\" into an em dash: \"--force\" comes back as \"\\u2014force\".\n [0x2014, rule('confusable-punctuation', 'warning', '--', 'EM DASH')],\n [0x2015, rule('confusable-punctuation', 'warning', '--', 'HORIZONTAL BAR')],\n [0x2026, rule('confusable-punctuation', 'warning', '...', 'HORIZONTAL ELLIPSIS')],\n [0x2044, rule('confusable-punctuation', 'warning', '/', 'FRACTION SLASH')],\n [0x2215, rule('confusable-punctuation', 'warning', '/', 'DIVISION SLASH')],\n [0x037e, rule('confusable-punctuation', 'warning', ';', 'GREEK QUESTION MARK')],\n]);\n\n/**\n * Latin lookalikes for Cyrillic and Greek letters: these make a homoglyph attack.\n * Pairs of (letter, lookalike), written as escapes so this file holds no homoglyphs itself.\n */\nconst LOOKALIKE_PAIRS =\n '\\u0430a\\u0435e\\u0456i\\u0458j\\u043eo\\u0440p\\u0441c\\u0443y\\u0445x\\u0455s' +\n '\\u0501d\\u051bq\\u051dw\\u04bbh\\u04cfl\\u0410A\\u0412B\\u0415E\\u041aK\\u041cM' +\n '\\u041dH\\u041eO\\u0420P\\u0421C\\u0422T\\u0425X\\u0423Y\\u0406I\\u0408J\\u0405S' +\n '\\u0500D\\u051aQ\\u051cW\\u04baH\\u04c0I\\u03b1a\\u03bfo\\u03bdv\\u03c1p\\u03b9i' +\n '\\u03c5u\\u03c7x\\u0391A\\u0392B\\u0395E\\u0396Z\\u0397H\\u0399I\\u039aK\\u039cM' +\n '\\u039dN\\u039fO\\u03a1P\\u03a4T\\u03a5Y\\u03a7X';\nconst LOOKALIKES = /* @__PURE__ */ new Map<string, string>(\n /* @__PURE__ */ Array.from({ length: LOOKALIKE_PAIRS.length / 2 }, (_, at): [string, string] => [\n LOOKALIKE_PAIRS.charAt(at * 2),\n LOOKALIKE_PAIRS.charAt(at * 2 + 1),\n ]),\n);\n\nconst LATIN = /\\p{Script=Latin}/u;\nconst FOREIGN = /[\\p{Script=Cyrillic}\\p{Script=Greek}]/u;\nconst FOREIGN_LETTER = /^[\\p{Script=Cyrillic}\\p{Script=Greek}]$/u;\n/** Identifier-like runs: letters, marks, digits, `_` and `$`. */\nconst WORD = /[\\p{L}\\p{M}\\p{Nd}_$]+/gu;\n/** Joiners are part of emoji sequences and of Arabic and Indic spelling. */\nconst JOINS = /[\\p{L}\\p{M}\\p{Extended_Pictographic}]/u;\nconst JOINS_ASCII = /[\\0-\\x7f]/;\nconst CJK = /[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\p{Script=Hangul}\\u3000-\\u303f\\uff00-\\uffef]/u;\n\n/** A character with a glyph: not a space, a control or a format character. */\nconst VISIBLE = /^[^\\s\\p{Cc}\\p{Cf}\\p{Zs}]/u;\n\nconst hex = (codePoint: number): string => `U+${codePoint.toString(16).toUpperCase().padStart(4, '0')}`;\n\nconst isSelector = (codePoint: number): boolean => (codePoint >= 0xfe00 && codePoint <= 0xfe0f) || (codePoint >= 0xe0100 && codePoint <= 0xe01ef);\n\nconst joinsHere = (char: string | undefined): boolean => char !== undefined && !JOINS_ASCII.test(char) && JOINS.test(char);\n\n/** The verdict for one character, given its neighbours (code points, `undefined` at the text's edges). */\nfunction classify(codePoint: number, before: number | undefined, after: number | undefined): Rule | null {\n const fixed = TABLE.get(codePoint);\n if (fixed !== undefined) return fixed;\n if (codePoint === 0x200c || codePoint === 0x200d) {\n // Inside a word or an emoji sequence (both sides non-ASCII letters, marks or pictographs) a joiner is spelling.\n const charBefore = before === undefined ? undefined : String.fromCodePoint(before);\n const charAfter = after === undefined ? undefined : String.fromCodePoint(after);\n if (joinsHere(charBefore) && joinsHere(charAfter)) return null;\n return rule('invisible', 'warning', '', codePoint === 0x200c ? 'ZERO WIDTH NON-JOINER' : 'ZERO WIDTH JOINER');\n }\n if (isSelector(codePoint)) {\n // One selector after a visible character picks its glyph (an emoji's colour form); a run of them smuggles data,\n // and after a space, a control or nothing at all a selector selects nothing.\n const base = before === undefined ? '' : String.fromCodePoint(before);\n if (VISIBLE.test(base) && !isSelector(before as number) && (after === undefined || !isSelector(after))) return null;\n return rule('invisible', 'warning', '', 'VARIATION SELECTOR');\n }\n // Tag characters spell invisible ASCII (\"ASCII smuggling\", hidden prompt text).\n if (codePoint >= 0xe0000 && codePoint <= 0xe007f) return rule('invisible', 'danger', '', 'TAG CHARACTER');\n if (codePoint === 0x09 || codePoint === 0x0a || codePoint === 0x0c || codePoint === 0x0d) return null;\n if (codePoint < 0x20 || (codePoint >= 0x7f && codePoint <= 0x9f)) return rule('control', 'warning', '', 'CONTROL CHARACTER');\n if (codePoint >= 0x2000 && codePoint <= 0x200a) return rule('unusual-space', 'warning', ' ', 'SPACE');\n if (codePoint >= 0xff01 && codePoint <= 0xff5e) {\n // Full-width punctuation is normal next to CJK text, as in a Chinese or Japanese comment.\n const charBefore = before === undefined ? '' : String.fromCodePoint(before);\n const charAfter = after === undefined ? '' : String.fromCodePoint(after);\n if (CJK.test(charBefore) || CJK.test(charAfter)) return null;\n return rule('confusable-punctuation', 'warning', String.fromCharCode(codePoint - 0xfee0), 'FULLWIDTH FORM');\n }\n return null;\n}\n\n/* ----------------------------------------------------------------- Scanning */\n\nexport interface RawFinding {\n readonly index: number;\n readonly length: number;\n readonly codePoint: number;\n readonly rule: Rule;\n}\n\nconst ALL = /* @__PURE__ */ new Set<CodeFindingKind>(CODE_FINDING_KINDS);\n\nexport function kindSet(kinds: readonly CodeFindingKind[] | undefined, name: string): ReadonlySet<CodeFindingKind> {\n if (kinds === undefined) return ALL;\n if (!Array.isArray(kinds) || !(kinds as readonly unknown[]).every((kind) => ALL.has(kind as CodeFindingKind))) {\n throw copyFailure('invalid-payload', `\\`${name}\\` must be a list of: ${CODE_FINDING_KINDS.join(', ')}.`);\n }\n return new Set(kinds);\n}\n\n/** Every suspicious character in `text`, in order of position. Stops once `limit` are found. */\nexport function scan(text: string, kinds: ReadonlySet<CodeFindingKind>, limit: number): RawFinding[] {\n const found: RawFinding[] = [];\n let before: number | undefined;\n for (let index = 0; index < text.length && found.length < limit; ) {\n const codePoint = text.codePointAt(index) as number;\n const length = codePoint > 0xffff ? 2 : 1;\n // Only characters outside printable ASCII can be suspicious; skip the rest fast.\n if (codePoint < 0x20 || codePoint >= 0x7f) {\n const verdict = classify(codePoint, before, text.codePointAt(index + length));\n if (verdict !== null && kinds.has(verdict.kind)) found.push({ index, length, codePoint, rule: verdict });\n }\n before = codePoint;\n index += length;\n }\n if (kinds.has('mixed-script') && FOREIGN.test(text)) {\n const mixed: RawFinding[] = [];\n for (const match of text.matchAll(WORD)) {\n const word = match[0];\n if (!LATIN.test(word) || !FOREIGN.test(word)) continue;\n let offset = 0;\n for (const char of word) {\n if (FOREIGN_LETTER.test(char)) {\n const lookalike = LOOKALIKES.get(char);\n const codePoint = char.codePointAt(0) as number;\n mixed.push({\n index: (match.index) + offset,\n length: char.length,\n codePoint,\n rule:\n lookalike === undefined\n ? rule('mixed-script', 'warning', null, 'NON-LATIN LETTER IN A LATIN WORD')\n : rule('mixed-script', 'danger', lookalike, `LOOKALIKE OF \"${lookalike}\"`),\n });\n }\n offset += char.length;\n }\n }\n return merge(found, mixed).slice(0, limit);\n }\n return found;\n}\n\nfunction merge(a: readonly RawFinding[], b: readonly RawFinding[]): RawFinding[] {\n if (b.length === 0) return [...a];\n const out: RawFinding[] = [];\n let i = 0;\n let j = 0;\n while (i < a.length || j < b.length) {\n const next = j >= b.length || (i < a.length && (a[i] as RawFinding).index < (b[j] as RawFinding).index) ? a[i++] : b[j++];\n out.push(next as RawFinding);\n }\n return out;\n}\n\n/** Offsets where each line starts. */\nfunction lineStarts(text: string): number[] {\n const starts = [0];\n for (let index = 0; index < text.length; index += 1) {\n const char = text.charCodeAt(index);\n if (char === 0x0a || (char === 0x0d && text.charCodeAt(index + 1) !== 0x0a)) starts.push(index + 1);\n }\n return starts;\n}\n\nexport function toFindings(text: string, raw: readonly RawFinding[]): CodeFinding[] {\n if (raw.length === 0) return [];\n const starts = lineStarts(text);\n return raw.map(({ index, length, codePoint, rule: { kind, severity, replacement, name } }) => {\n let low = 0;\n let high = starts.length - 1;\n while (low < high) {\n const mid = (low + high + 1) >> 1;\n if ((starts[mid] as number) <= index) low = mid;\n else high = mid - 1;\n }\n return {\n kind,\n severity,\n index,\n length,\n line: low + 1,\n column: index - (starts[low] as number) + 1,\n codePoint,\n label: `${hex(codePoint)} ${name}`,\n replacement,\n };\n });\n}\n\nexport function positiveLimit(value: number | undefined, fallback: number, name: string): number {\n if (value === undefined) return fallback;\n if (value === Infinity || (Number.isInteger(value) && value > 0)) return value;\n throw copyFailure('invalid-payload', `\\`${name}\\` must be a positive integer or Infinity (received ${String(value)}).`);\n}\n\n/**\n * Finds characters that make code read differently from how it runs, or that a\n * copy through a word processor or chat app slipped in: bidirectional overrides\n * (Trojan Source), invisible characters and identifiers, control characters,\n * unusual spaces, curly quotes and dashes, and Cyrillic or Greek lookalikes inside\n * Latin words. Works anywhere, including on the server.\n *\n * @example\n * const { danger, findings } = inspectCode(pasted);\n * if (danger) warn(findings.map((f) => `${f.line}:${f.column} ${f.label}`));\n */\nexport function inspectCode(code: string, options: InspectCodeOptions = {}): CodeInspection {\n const kinds = kindSet(options.kinds, 'kinds');\n const max = positiveLimit(options.maxFindings, DEFAULT_CODE_MAX_FINDINGS, 'maxFindings');\n // One past the limit tells whether more were left.\n const raw = scan(code, kinds, max === Infinity ? Infinity : max + 1);\n const truncated = raw.length > max;\n const findings = toFindings(code, truncated ? raw.slice(0, max) : raw);\n return { findings, danger: findings.some((finding) => finding.severity === 'danger'), truncated };\n}\n\nexport interface CleanCodeOptions {\n /** Which kinds to fix. Default: all. Findings without a `replacement` are never changed. */\n readonly kinds?: readonly CodeFindingKind[];\n}\n\nexport interface CleanCode {\n readonly code: string;\n /** What was replaced or removed, in order, with positions in the original text. */\n readonly fixed: readonly CodeFinding[];\n /** What is still in `code` (positions in `code`): findings without a safe replacement. */\n readonly remaining: readonly CodeFinding[];\n}\n\n/** Applies the replacement of each (fixable) finding, from the end so earlier offsets stay valid. */\nfunction applyFixes(text: string, fixable: readonly RawFinding[]): string {\n let out = text;\n for (let at = fixable.length - 1; at >= 0; at -= 1) {\n const { index, length, rule: verdict } = fixable[at] as RawFinding;\n out = out.slice(0, index) + (verdict.replacement as string) + out.slice(index + length);\n }\n return out;\n}\n\nconst fixableIn = (text: string, kinds: ReadonlySet<CodeFindingKind>): RawFinding[] =>\n scan(text, kinds, Infinity).filter((finding) => finding.rule.replacement !== null);\n\n/**\n * Maps an offset in the text after `fixes` back to the text they were applied to.\n * The offset is never inside a replacement: replacements are ASCII (or a line\n * feed), which is never suspicious, so a later pass can't find anything in them.\n */\nfunction beforeFixes(index: number, fixes: readonly RawFinding[]): number {\n let shift = 0;\n for (const { index: at, length, rule: verdict } of fixes) {\n if (index < at + shift) break;\n shift += (verdict.replacement as string).length - length;\n }\n return index - shift;\n}\n\n/**\n * Fixes until nothing fixable is left: removing a character can expose another\n * finding (a zero-width space between `a` and a Cyrillic letter hides a mixed\n * word). Every pass removes or replaces suspicious characters with ASCII, which is\n * never suspicious, so this ends. Returns what was fixed, positioned in `text`.\n */\nexport function fixAll(text: string, kinds: ReadonlySet<CodeFindingKind>): { readonly text: string; readonly fixed: readonly RawFinding[] } {\n const passes: RawFinding[][] = [];\n let out = text;\n for (let fixable = fixableIn(out, kinds); fixable.length > 0; fixable = fixableIn(out, kinds)) {\n passes.push(fixable);\n out = applyFixes(out, fixable);\n }\n const fixed = passes.flatMap((found, pass) =>\n found.map((finding) => {\n let index = finding.index;\n for (let earlier = pass - 1; earlier >= 0; earlier -= 1) index = beforeFixes(index, passes[earlier] as RawFinding[]);\n return { ...finding, index };\n }),\n );\n return { text: out, fixed: fixed.sort((x, y) => x.index - y.index) };\n}\n\n/**\n * Replaces what {@link inspectCode} finds with safe ASCII: removes bidi controls,\n * invisible and control characters, turns unusual spaces into spaces, curly quotes\n * and dashes into `'` `\"` `-`, and lookalike letters into the Latin letters they\n * imitate. Letters with no lookalike are reported in `remaining`, never guessed.\n *\n * @example\n * cleanCode('const s = \\u201Chi\\u201D;').code; // 'const s = \"hi\";'\n */\nexport function cleanCode(code: string, options: CleanCodeOptions = {}): CleanCode {\n const kinds = kindSet(options.kinds, 'kinds');\n const { text, fixed } = fixAll(code, kinds);\n return { code: text, fixed: toFindings(code, fixed), remaining: toFindings(text, scan(text, kinds, Infinity)) };\n}\n","/**\n * Code as lines of styled runs. Plain text is one unstyled run per line; a\n * highlighted element keeps each token's colour. Every transform works on this\n * one model, so the plain text and the HTML of a copy always hold the same code.\n */\n\nexport interface Run {\n readonly text: string;\n /** Inline CSS for the run, `''` for none. */\n readonly style: string;\n}\n\nexport type Line = readonly Run[];\n\n/** Line breaks: CRLF, LF, CR, and the Unicode line and paragraph separators and NEL. */\nconst BREAK = /\\r\\n|[\\n\\r\\u2028\\u2029\\u0085]/;\n\nexport const lineText = (line: Line): string => line.map((run) => run.text).join('');\n\n/** Splits runs into lines. */\nexport function toLines(runs: readonly Run[]): Line[] {\n const lines: Run[][] = [[]];\n let carriageReturn = false;\n for (const run of runs) {\n // A CRLF split across two runs is one line break.\n const text = carriageReturn && run.text.startsWith('\\n') ? run.text.slice(1) : run.text;\n if (run.text !== '') carriageReturn = run.text.endsWith('\\r');\n const parts = text.split(BREAK);\n parts.forEach((part, at) => {\n if (at > 0) lines.push([]);\n if (part !== '') (lines[lines.length - 1] as Run[]).push({ text: part, style: run.style });\n });\n }\n return lines;\n}\n\n/** The characters of a line from `from` to `to` (UTF-16 offsets), with their styles. */\nexport function slice(line: Line, from: number, to = Infinity): Line {\n const out: Run[] = [];\n let offset = 0;\n for (const run of line) {\n const start = Math.max(from - offset, 0);\n const end = Math.min(to - offset, run.text.length);\n if (start < end) out.push(start === 0 && end === run.text.length ? run : { text: run.text.slice(start, end), style: run.style });\n offset += run.text.length;\n }\n return out;\n}\n\nexport interface Edit {\n readonly index: number;\n readonly length: number;\n readonly text: string;\n}\n\n/** Applies non-overlapping replacements of at least one character, sorted by `index`; the new text keeps the style of what it replaces. */\nexport function edit(line: Line, edits: readonly Edit[]): Line {\n if (edits.length === 0) return line;\n const out: Run[] = [];\n let at = 0;\n for (const { index, length, text } of edits) {\n out.push(...slice(line, at, index));\n if (text !== '') out.push({ text, style: (slice(line, index, index + length)[0] as Run).style });\n at = index + length;\n }\n out.push(...slice(line, at));\n return out;\n}\n","import { copyFailure } from '../core/errors';\nimport { fixAll, kindSet, type CodeFindingKind } from './inspect';\nimport { edit, lineText, slice, toLines, type Line } from './lines';\n\n/** Built-in prompt styles for terminal and REPL sessions. */\nexport type PromptStyle = 'shell' | 'powershell' | 'cmd' | 'python' | 'ipython' | 'node';\n\n/** Every built-in prompt style. `'auto'` tries all but `node`, whose `> ` is too common to guess. */\nexport const PROMPT_STYLES: readonly PromptStyle[] = Object.freeze(['shell', 'powershell', 'cmd', 'python', 'ipython', 'node']);\n\n/**\n * A custom prompt. `command` matches the prompt at the start of a command line,\n * `continuation` the prompt of the lines that continue it. Matches must start at\n * the beginning of the line; the `g` and `y` flags are ignored.\n */\nexport interface PromptPattern {\n readonly command: RegExp;\n readonly continuation?: RegExp;\n}\n\nexport interface CodeTextOptions {\n /**\n * Copy a terminal or REPL session as the commands to run: prompts are removed\n * and output lines are dropped. `'auto'` (the default for copying) does this only\n * when the first line starts with a `$`, `PS>`, `C:\\>`, `>>>` or `In [1]:`\n * prompt; `false` keeps the text as it is.\n */\n readonly prompt?: 'auto' | false | PromptStyle | PromptPattern;\n /** Copy a unified diff as the code after (`'after'`) or before (`'before'`) the change. Default `false`. */\n readonly diff?: false | 'after' | 'before';\n /**\n * Remove line numbers typed into the text (`1: code`, ` 12 | code`). Only\n * applied when every line starts with a number and the numbers count up by one.\n * Default `false`.\n */\n readonly lineNumbers?: boolean;\n /** Remove the indentation every line shares. Default `true`. */\n readonly dedent?: boolean;\n /** Default `true`. */\n readonly trimTrailingWhitespace?: boolean;\n /** Remove blank lines at the start and the end. Default `true`. */\n readonly trimBlankLines?: boolean;\n /** Default `'lf'`. */\n readonly lineEnding?: 'lf' | 'crlf';\n /** End with a line break. Default `false`. */\n readonly finalNewline?: boolean;\n /**\n * Fix what `inspectCode` finds (see `cleanCode`): `true` for every kind, or a\n * list of kinds. Default `false` when copying, `true` when pasting.\n */\n readonly clean?: boolean | readonly CodeFindingKind[];\n}\n\nexport interface Resolved {\n readonly prompt: Prompt | 'auto' | null;\n readonly diff: 'after' | 'before' | null;\n readonly lineNumbers: boolean;\n readonly dedent: boolean;\n readonly trimTrailingWhitespace: boolean;\n readonly trimBlankLines: boolean;\n readonly eol: string;\n readonly finalNewline: boolean;\n readonly clean: ReadonlySet<CodeFindingKind> | null;\n}\n\n/* ------------------------------------------------------------------ Prompts */\n\ninterface Prompt {\n readonly command: RegExp;\n readonly continuation: RegExp | null;\n /** Shell rules: a line continues after `\\`, inside a heredoc or an open quote, with an optional `> ` prompt. */\n readonly shell: boolean;\n}\n\nconst PROMPTS: Readonly<Record<PromptStyle, Prompt>> = {\n // `$` after an optional `(venv) `, `user@host`, and a `~/path`; `#` and `%` are left out: they start comments.\n shell: { command: /^(?:\\([^()\\s]{1,64}\\) )?(?:[\\w.-]{1,64}@[\\w.-]{1,253}:?)?(?:[~/][^\\s$]{0,1024})? ?\\$(?: |$)/, continuation: null, shell: true },\n powershell: { command: /^PS(?: [^>\\r\\n]{0,1024})?> ?/, continuation: /^>> ?/, shell: false },\n cmd: { command: /^[A-Za-z]:\\\\[^>\\r\\n]{0,1024}> ?/, continuation: /^More\\? ?/, shell: false },\n python: { command: /^>>>(?: |$)/, continuation: /^\\.\\.\\.(?: |$)/, shell: false },\n ipython: { command: /^In \\[\\d{0,9}\\]: ?/, continuation: /^ {0,64}\\.{3,}: ?/, shell: false },\n node: { command: /^>(?: |$)/, continuation: /^\\.\\.\\.(?: |$)/, shell: false },\n};\n\nconst AUTO: readonly PromptStyle[] = ['powershell', 'cmd', 'ipython', 'python', 'shell'];\n\n/** A user pattern without `g` / `y`, so `exec` is stateless. */\nfunction stateless(pattern: unknown, name: string): RegExp {\n if (!(pattern instanceof RegExp)) throw copyFailure('invalid-payload', `\\`prompt.${name}\\` must be a RegExp.`);\n return new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, ''));\n}\n\nfunction resolvePrompt(prompt: CodeTextOptions['prompt'], fallback: 'auto' | false): Prompt | 'auto' | null {\n const value = prompt ?? fallback;\n if (value === false) return null;\n if (value === 'auto') return 'auto';\n if (typeof value === 'string') {\n if (!Object.prototype.hasOwnProperty.call(PROMPTS, value)) {\n throw copyFailure('invalid-payload', `\\`prompt\\` must be 'auto', false, a PromptPattern or one of: ${PROMPT_STYLES.join(', ')}.`);\n }\n return PROMPTS[value];\n }\n // Plain-JS callers can pass anything.\n if (typeof (value as unknown) !== 'object' || (value as unknown) === null) {\n throw copyFailure('invalid-payload', `\\`prompt\\` must be 'auto', false, a PromptPattern or one of: ${PROMPT_STYLES.join(', ')}.`);\n }\n return {\n command: stateless(value.command, 'command'),\n continuation: value.continuation === undefined ? null : stateless(value.continuation, 'continuation'),\n shell: false,\n };\n}\n\n/** The length of the prompt at the start of `text`, or -1. */\nfunction promptLength(pattern: RegExp, text: string): number {\n const match = pattern.exec(text);\n return match?.index === 0 ? match[0].length : -1;\n}\n\n/** Whether a shell command goes on to the next line: a trailing `\\`, an open heredoc or an open quote. */\ninterface ShellState {\n quote: '\"' | \"'\" | null;\n heredoc: string | null;\n /** The next line continues because this one ended with an unescaped `\\`. */\n escaped: boolean;\n}\n\nconst HEREDOC = /<<-?[ \\t]*(['\"]?)([A-Za-z_][\\w-]{0,63})\\1/;\n\nfunction readShell(text: string, state: ShellState): void {\n if (state.heredoc !== null) {\n if (text.replace(/^\\t+/, '') === state.heredoc) state.heredoc = null;\n state.escaped = false;\n return;\n }\n let escaped = false;\n for (let at = 0; at < text.length; at += 1) {\n const char = text.charAt(at);\n if (escaped) escaped = false;\n else if (char === '\\\\' && state.quote !== \"'\") escaped = true;\n else if (state.quote === null && (char === '\"' || char === \"'\")) state.quote = char;\n else if (char === state.quote) state.quote = null;\n else if (state.quote !== null) continue;\n else if (char === '#') break; // A comment: quotes after it don't count.\n else if (char === '<' && state.heredoc === null) {\n const heredoc = HEREDOC.exec(text.slice(at));\n if (heredoc?.index === 0) state.heredoc = heredoc[2] as string;\n }\n }\n state.escaped = escaped;\n}\n\nconst continues = (state: ShellState): boolean => state.escaped || state.quote !== null || state.heredoc !== null;\n\nfunction firstNonBlank(lines: readonly Line[]): string {\n for (const line of lines) {\n const text = lineText(line);\n if (text.trim() !== '') return text;\n }\n return '';\n}\n\n/** Keeps the commands of a session, without prompts; drops its output. */\nfunction stripPrompts(lines: readonly Line[], setting: Prompt | 'auto'): Line[] {\n let prompt: Prompt;\n if (setting === 'auto') {\n const first = firstNonBlank(lines);\n const style = AUTO.find((name) => promptLength(PROMPTS[name].command, first) >= 0);\n if (style === undefined) return [...lines];\n prompt = PROMPTS[style];\n } else {\n prompt = setting;\n }\n const out: Line[] = [];\n const shell: ShellState = { quote: null, heredoc: null, escaped: false };\n let inCommand = false;\n /** Shell continuation lines carry a `> ` prompt (PS2) when the first one does. */\n let ps2: boolean | null = null;\n for (const line of lines) {\n const text = lineText(line);\n if (prompt.shell && continues(shell)) {\n if (ps2 === null) ps2 = /^>(?: |$)/.test(text);\n const cut = ps2 ? (text.startsWith('> ') ? 2 : text === '>' ? 1 : 0) : 0;\n const rest = slice(line, cut);\n out.push(rest);\n readShell(lineText(rest), shell);\n continue;\n }\n const command = promptLength(prompt.command, text);\n if (command >= 0) {\n const rest = slice(line, command);\n out.push(rest);\n inCommand = true;\n ps2 = null;\n if (prompt.shell) readShell(lineText(rest), shell);\n continue;\n }\n const continuation = inCommand && prompt.continuation !== null ? promptLength(prompt.continuation, text) : -1;\n if (continuation >= 0) {\n out.push(slice(line, continuation));\n continue;\n }\n inCommand = false; // Output.\n }\n return out;\n}\n\n/* --------------------------------------------------------------------- Diff */\n\nconst DIFF_HEADER = /^(?:diff |index |--- |\\+\\+\\+ |new file mode|deleted file mode|old mode|new mode|similarity index|dissimilarity index|rename from|rename to|copy from|copy to|Binary files)/;\n\n/** Keeps one side of a unified diff, without the `+`, `-` and space markers. */\nfunction pickSide(lines: readonly Line[], side: 'after' | 'before'): Line[] {\n const keep = side === 'after' ? '+' : '-';\n const drop = side === 'after' ? '-' : '+';\n const out: Line[] = [];\n // A diff that starts with file headers stays in the header until its first hunk.\n let header = /^(?:diff |--- |index )/.test(firstNonBlank(lines));\n for (const line of lines) {\n const text = lineText(line);\n if (text.startsWith('diff --git ')) header = true;\n if (header) {\n if (text.startsWith('@@')) header = false;\n else if (DIFF_HEADER.test(text) || text.trim() === '') continue;\n else header = false; // Not a header after all: the hunk starts here.\n }\n if (text.startsWith('@@') || text.startsWith('\\\\ ')) continue;\n const marker = text.charAt(0);\n if (marker === drop) continue;\n out.push(marker === keep || marker === ' ' ? slice(line, 1) : line);\n }\n return out;\n}\n\n/* ------------------------------------------------------------- Line numbers */\n\nconst NUMBERED = /^[ \\t]*(\\d{1,9})(?:[ \\t]*[:|\\u2502](?: |$)|[ \\t]+|$)/;\n\nfunction stripLineNumbers(lines: readonly Line[]): Line[] {\n const cuts: number[] = [];\n let expected: number | null = null;\n for (const line of lines) {\n const match = NUMBERED.exec(lineText(line));\n if (match === null) return [...lines];\n const number = Number(match[1]);\n if (expected !== null && number !== expected) return [...lines];\n expected = number + 1;\n cuts.push(match[0].length);\n }\n // A single line can't show that the numbers count.\n if (cuts.length < 2) return [...lines];\n return lines.map((line, at) => slice(line, cuts[at] as number));\n}\n\n/* ------------------------------------------------------------ Whitespace */\n\nfunction trimEnd(line: Line): Line {\n const text = lineText(line);\n const end = text.replace(/[ \\t]+$/, '').length;\n return end === text.length ? line : slice(line, 0, end);\n}\n\nfunction dedentLines(lines: readonly Line[]): Line[] {\n let common: string | null = null;\n for (const line of lines) {\n const text = lineText(line);\n if (text.trim() === '') continue;\n const indent = /^[ \\t]*/.exec(text)?.[0] as string;\n if (common === null) {\n common = indent;\n } else {\n let shared = 0;\n while (shared < common.length && shared < indent.length && common[shared] === indent[shared]) shared += 1;\n common = common.slice(0, shared);\n }\n if (common === '') return [...lines];\n }\n if (common === null) return [...lines];\n const width = common.length;\n return lines.map((line) => slice(line, Math.min(width, /^[ \\t]*/.exec(lineText(line))?.[0].length as number)));\n}\n\n/* ------------------------------------------------------------------ Options */\n\nconst oneOf = <const T extends string | boolean>(value: unknown, allowed: readonly T[], fallback: NoInfer<T>, name: string): T => {\n if (value === undefined) return fallback;\n if ((allowed as readonly unknown[]).includes(value)) return value as T;\n throw copyFailure('invalid-payload', `\\`${name}\\` must be one of: ${allowed.map((option) => JSON.stringify(option)).join(', ')}.`);\n};\n\nconst flag = (value: unknown, fallback: boolean, name: string): boolean => oneOf(value, [true, false], fallback, name);\n\nexport interface Defaults {\n readonly prompt: 'auto' | false;\n readonly clean: boolean;\n}\n\nexport function resolveText(options: CodeTextOptions, defaults: Defaults): Resolved {\n const clean = options.clean ?? defaults.clean;\n return {\n prompt: resolvePrompt(options.prompt, defaults.prompt),\n diff: oneOf(options.diff, [false, 'after', 'before'], false, 'diff') || null,\n lineNumbers: flag(options.lineNumbers, false, 'lineNumbers'),\n dedent: flag(options.dedent, true, 'dedent'),\n trimTrailingWhitespace: flag(options.trimTrailingWhitespace, true, 'trimTrailingWhitespace'),\n trimBlankLines: flag(options.trimBlankLines, true, 'trimBlankLines'),\n eol: oneOf(options.lineEnding, ['lf', 'crlf'], 'lf', 'lineEnding') === 'crlf' ? '\\r\\n' : '\\n',\n finalNewline: flag(options.finalNewline, false, 'finalNewline'),\n clean: clean === false ? null : kindSet(clean === true ? undefined : clean, 'clean'),\n };\n}\n\n/* ----------------------------------------------------------------- Pipeline */\n\nexport interface Transformed {\n readonly lines: readonly Line[];\n /** How many characters `clean` replaced or removed. */\n readonly fixed: number;\n}\n\nexport function transform(input: readonly Line[], options: Resolved): Transformed {\n let lines: Line[] = [...input];\n let fixed = 0;\n const kinds = options.clean;\n if (kinds !== null) {\n lines = lines.map((line) => {\n const { fixed: found } = fixAll(lineText(line), kinds);\n fixed += found.length;\n return edit(\n line,\n found.map(({ index, length, rule: { replacement } }) => ({ index, length, text: replacement as string })),\n );\n });\n }\n if (options.diff !== null) lines = pickSide(lines, options.diff);\n // Prompts are found after the shared indentation, as in a session indented inside a list.\n if (options.prompt !== null) lines = stripPrompts(options.dedent ? dedentLines(lines) : lines, options.prompt);\n if (options.lineNumbers) lines = stripLineNumbers(lines);\n if (options.trimTrailingWhitespace) lines = lines.map(trimEnd);\n if (options.trimBlankLines) {\n const blank = (line: Line) => lineText(line).trim() === '';\n let start = 0;\n let end = lines.length;\n while (start < end && blank(lines[start] as Line)) start += 1;\n while (end > start && blank(lines[end - 1] as Line)) end -= 1;\n lines = lines.slice(start, end);\n }\n if (options.dedent) lines = dedentLines(lines);\n return { lines, fixed };\n}\n\n/** The text of transformed lines. */\nexport function render(lines: readonly Line[], options: Pick<Resolved, 'eol' | 'finalNewline'>): string {\n const text = lines.map(lineText).join(options.eol);\n return options.finalNewline && text !== '' ? text + options.eol : text;\n}\n\n/**\n * Code as it should be copied or saved: a terminal session becomes its commands,\n * a diff one side of the change, typed line numbers and shared indentation are\n * removed, line endings are normalised. Works anywhere, including on the server.\n *\n * @example\n * normalizeCode('$ npm install react-smart-copy\\nadded 1 package'); // 'npm install react-smart-copy'\n */\nexport function normalizeCode(code: string, options: CodeTextOptions = {}): string {\n const resolved = resolveText(options, { prompt: 'auto', clean: false });\n return render(transform(toLines([{ text: code, style: '' }]), resolved).lines, resolved);\n}\n","import { copyFailure } from '../core/errors';\nimport type { Run } from './lines';\n\n/** Never code: scripts, embedded content, form controls (the block's own Copy button) and media. */\nconst SKIP = new Set([\n 'script', 'style', 'template', 'noscript', 'head', 'button', 'input', 'textarea', 'select', 'option', 'datalist',\n 'dialog', 'svg', 'math', 'canvas', 'iframe', 'object', 'embed', 'img', 'picture', 'video', 'audio', 'source', 'track',\n]);\n\n/** Elements that start their own line. */\nconst BLOCK = new Set([\n 'address', 'article', 'aside', 'blockquote', 'dd', 'details', 'div', 'dl', 'dt', 'figcaption', 'figure', 'footer',\n 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'li', 'main', 'nav', 'ol', 'p', 'pre', 'section',\n 'summary', 'table', 'tbody', 'tfoot', 'thead', 'tr', 'ul',\n]);\n\n/**\n * Line-number gutters by the class names highlighters give them (Prism, highlight.js,\n * Rouge, Pygments, react-syntax-highlighter, CodeMirror and others).\n */\n/** Whitespace between table rows and cells is never rendered. */\nconst TABLE_PARTS = new Set(['table', 'thead', 'tbody', 'tfoot', 'tr', 'colgroup']);\n\nconst GUTTER = /(?:^|[\\s_-])(?:gutter|linenos?|lineno|line-?numbers?|ln-numbers?|line-?nums?)(?:$|[\\s_-])/i;\nconst NO_SELECT = /(?:^|;)\\s*(?:-webkit-)?user-select\\s*:\\s*none/i;\n\n/** Colours as browsers serialise them. Anything else (`url(...)`, `var(...)`) is never copied into the HTML. */\nconst SAFE_COLOR =\n /^(?:#[\\da-f]{3,8}|[a-z]{3,20}|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch)\\([\\d\\s.,%/+-]{1,80}\\)|color\\([a-z\\d-]{1,24}[\\d\\s.,%/+-]{1,80}\\))$/i;\nconst TRANSPARENT = /^(?:transparent|rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\))$/i;\n\nexport interface ExtractOptions {\n /** A CSS selector for more parts to leave out. */\n readonly ignore?: string | undefined;\n /** Keep each token's colour and weight, for the HTML flavour. */\n readonly styles: boolean;\n}\n\nexport interface Extracted {\n readonly runs: readonly Run[];\n /** The block's own text and background colour, as CSS. */\n readonly blockStyle: string;\n}\n\ninterface Look {\n readonly color: string;\n readonly bold: boolean;\n readonly italic: boolean;\n readonly decoration: string;\n}\n\nexport function assertElement(value: unknown, name: string): asserts value is Element {\n if (typeof value !== 'object' || value === null || (value as { nodeType?: unknown }).nodeType !== 1) {\n throw copyFailure('invalid-payload', `\\`${name}\\` must be a string or an Element.`);\n }\n}\n\nfunction lookOf(style: CSSStyleDeclaration): Look {\n const weight = style.fontWeight;\n const decoration = `${style.textDecorationLine || style.textDecoration} `;\n return {\n color: SAFE_COLOR.test(style.color) ? style.color : '',\n bold: weight === 'bold' || weight === 'bolder' || Number(weight) >= 600,\n italic: style.fontStyle === 'italic' || style.fontStyle.startsWith('oblique'),\n decoration: ['underline', 'line-through'].filter((line) => decoration.includes(line)).join(' '),\n };\n}\n\n/**\n * The code a rendered block shows, as styled runs: line-number gutters, hidden\n * and unselectable parts (`user-select: none`), `aria-hidden` decorations,\n * buttons and anything marked `data-copy-ignore` are left out.\n */\nexport function extract(root: Element, options: ExtractOptions): Extracted {\n const { ignore } = options;\n if (ignore !== undefined) {\n try {\n root.matches(ignore);\n } catch (cause) {\n throw copyFailure('invalid-payload', `\\`ignore\\` is not a valid CSS selector: ${ignore}`, cause);\n }\n }\n const view = root.ownerDocument.defaultView;\n const computed = (element: Element): CSSStyleDeclaration | null => (view === null ? null : view.getComputedStyle(element));\n const rootStyle = computed(root);\n const base: Look = rootStyle === null ? { color: '', bold: false, italic: false, decoration: '' } : lookOf(rootStyle);\n const runs: Run[] = [];\n const styles = new Map<Element, string>();\n let last = '';\n\n const push = (text: string, style: string): void => {\n if (text === '') return;\n const previous = runs[runs.length - 1];\n if (previous?.style === style) runs[runs.length - 1] = { text: previous.text + text, style };\n else runs.push({ text, style });\n last = text.charAt(text.length - 1);\n };\n const breakLine = (): void => {\n if (last !== '' && last !== '\\n') push('\\n', '');\n };\n\n const styleOf = (element: Element): string => {\n let style = styles.get(element);\n if (style === undefined) {\n const declared = computed(element);\n style = '';\n if (declared !== null) {\n const look = lookOf(declared);\n if (look.color !== '' && look.color !== base.color) style += `color:${look.color};`;\n if (look.bold && !base.bold) style += 'font-weight:bold;';\n if (look.italic && !base.italic) style += 'font-style:italic;';\n if (look.decoration !== '' && look.decoration !== base.decoration) style += `text-decoration:${look.decoration};`;\n }\n styles.set(element, style);\n }\n return style;\n };\n\n const leftOut = (element: Element): boolean => {\n if (SKIP.has(element.localName)) return true;\n if (element.hasAttribute('hidden') || element.hasAttribute('data-copy-ignore') || element.getAttribute('aria-hidden') === 'true') return true;\n if (GUTTER.test(element.getAttribute('class') ?? '') || NO_SELECT.test(element.getAttribute('style') ?? '')) return true;\n if (ignore !== undefined && element.matches(ignore)) return true;\n const style = computed(element);\n return style !== null && (style.display === 'none' || style.userSelect === 'none' || style.getPropertyValue('-webkit-user-select') === 'none');\n };\n\n const walk = (parent: Element): void => {\n for (let node = parent.firstChild; node !== null; node = node.nextSibling) {\n if (node.nodeType === 3) {\n const { data } = node as Text;\n if (TABLE_PARTS.has(parent.localName) && data.trim() === '') continue;\n push(data, options.styles ? styleOf(parent) : '');\n } else if (node.nodeType === 1) {\n const element = node as Element;\n if (leftOut(element)) continue;\n if (element.localName === 'br') {\n push('\\n', '');\n } else if (BLOCK.has(element.localName)) {\n breakLine();\n walk(element);\n breakLine();\n } else {\n walk(element);\n }\n }\n }\n };\n walk(root);\n\n let blockStyle = '';\n if (options.styles && rootStyle !== null) {\n if (base.color !== '') blockStyle += `color:${base.color};`;\n const background = rootStyle.backgroundColor;\n if (SAFE_COLOR.test(background) && !TRANSPARENT.test(background)) blockStyle += `background-color:${background};`;\n }\n return { runs, blockStyle };\n}\n","import { copyFailure } from '../core/errors';\nimport type { HtmlPayload, TextPayload } from '../core/payload';\nimport { assertElement, extract } from './element';\nimport { toLines, type Line } from './lines';\nimport { render, resolveText, transform, type CodeTextOptions } from './normalize';\n\n/** Code to copy: a string, or a rendered (and possibly highlighted) code block. */\nexport type CodeSource = string | Element;\n\nexport interface CodeFromElementOptions extends CodeTextOptions {\n /**\n * A CSS selector for more parts of the block to leave out. Gutters, hidden and\n * `user-select: none` parts, `aria-hidden` decorations, buttons and anything with\n * `data-copy-ignore` are always left out.\n */\n readonly ignore?: string;\n}\n\nexport interface CodePayloadOptions extends CodeFromElementOptions {\n /**\n * Add an HTML flavour (`<pre><code>`), so the code stays monospaced when pasted\n * into Google Docs, Word, Slack, Teams or a mail; from an element, with its\n * syntax colours. Editors and terminals still paste the plain text. Default `true`.\n */\n readonly html?: boolean;\n /** Written as `class=\"language-<name>\"` on the `<code>` element. Letters, digits and `_ + # . -` only. */\n readonly language?: string;\n}\n\nconst LANGUAGE = /^[A-Za-z0-9_+#.-]{1,64}$/;\nconst MONOSPACE = \"font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,'Liberation Mono',monospace;white-space:pre;\";\n\n/** HTML can't hold U+0000: parsers turn it into U+FFFD, so the HTML says so itself (the text flavour keeps it). */\nconst escapeHtml = (text: string): string =>\n text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;').replace(/\\0/g, '\\uFFFD');\n\nfunction toHtml(lines: readonly Line[], blockStyle: string, language: string | undefined): string {\n const body = lines\n .map((line) => line.map(({ text, style }) => (style === '' ? escapeHtml(text) : `<span style=\"${escapeHtml(style)}\">${escapeHtml(text)}</span>`)).join(''))\n .join('\\n');\n const cls = language === undefined ? '' : ` class=\"language-${language}\"`;\n return `<pre style=\"${escapeHtml(MONOSPACE + blockStyle)}\"><code${cls}>${body}</code></pre>`;\n}\n\n/**\n * The code a rendered block shows, ready to run or save: see {@link extract} for\n * what is left out, and {@link CodeTextOptions} for prompts, diffs and whitespace.\n *\n * @example\n * codeFromElement(preRef.current, { prompt: 'shell' });\n */\nexport function codeFromElement(element: Element, options: CodeFromElementOptions = {}): string {\n assertElement(element, 'element');\n const resolved = resolveText(options, { prompt: 'auto', clean: false });\n const { runs } = extract(element, { ignore: options.ignore, styles: false });\n return render(transform(toLines(runs), resolved).lines, resolved);\n}\n\n/**\n * A copy payload for code: plain text for editors and terminals, plus\n * monospaced HTML (with the block's syntax colours when you pass the element)\n * for documents and chat. A terminal session is copied as its commands\n * (`prompt: 'auto'`). Code that ends up empty gives an empty text payload, which\n * `copy()` reports as an `invalid-payload` error.\n *\n * @example\n * const { copy } = useCopy();\n * <button onClick={() => copy(() => codePayload(preRef.current!, { language: 'tsx' }))}>Copy</button>\n */\nexport function codePayload(source: CodeSource, options: CodePayloadOptions = {}): HtmlPayload | TextPayload {\n const resolved = resolveText(options, { prompt: 'auto', clean: false });\n const withHtml = options.html ?? true;\n if (typeof withHtml !== 'boolean') throw copyFailure('invalid-payload', '`html` must be a boolean.');\n const { language } = options;\n if (language !== undefined && (typeof language !== 'string' || !LANGUAGE.test(language))) {\n throw copyFailure('invalid-payload', '`language` may only hold letters, digits and _ + # . - (at most 64).');\n }\n let lines: Line[];\n let blockStyle = '';\n if (typeof source === 'string') {\n lines = toLines([{ text: source, style: '' }]);\n } else {\n assertElement(source, 'source');\n const extracted = extract(source, { ignore: options.ignore, styles: withHtml });\n lines = toLines(extracted.runs);\n blockStyle = extracted.blockStyle;\n }\n const out = transform(lines, resolved).lines;\n const text = render(out, resolved);\n if (!withHtml || text === '') return { kind: 'text', value: text };\n return { kind: 'html', text, html: toHtml(out, blockStyle, language) };\n}\n","/**\n * Text-field helpers shared by the paste handlers of the opt-in entry points.\n * Internal: not part of `react-smart-copy/core`'s public API.\n */\n\n/** Text fields `setRangeText` and `execCommand('insertText')` both support. */\nexport type TextField = HTMLTextAreaElement | HTMLInputElement;\n\nconst TEXT_INPUTS = new Set(['text', 'search', 'url', 'tel', 'password']);\n\nexport function asTextField(target: EventTarget | null): TextField | null {\n if (typeof target !== 'object' || target === null) return null;\n const element = target as Partial<Element> & { type?: unknown };\n if (element.nodeName === 'TEXTAREA') return target as HTMLTextAreaElement;\n if (element.nodeName === 'INPUT' && typeof element.type === 'string' && TEXT_INPUTS.has(element.type)) return target as HTMLInputElement;\n return null;\n}\n\n/**\n * Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the\n * selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still\n * works, `input` events fire (so React and other frameworks see the change),\n * and `maxlength` is respected. Returns `false` for disabled or read-only fields.\n */\nexport function insertText(field: TextField, text: string): boolean {\n if (field.disabled || field.readOnly) return false;\n // An <input> holds one line: each run of line breaks (a paragraph break too) becomes one space.\n const value = field.nodeName === 'INPUT' ? text.replace(/[ \\t]*(?:\\r\\n|\\r|\\n)+[ \\t]*/g, ' ') : text;\n const doc = field.ownerDocument;\n field.focus();\n // `null` for inputs without a selection API (email, number): the text is appended.\n const start = field.selectionStart;\n const end = field.selectionEnd;\n try {\n // Re-applying the selection ends the current typing run, so the paste gets its own undo step\n // (as a native paste does) instead of merging with what was typed just before.\n if (start !== null && end !== null) field.setSelectionRange(start, end);\n // The only way to keep the native undo stack; supported for text fields in every current browser.\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- no replacement keeps undo history\n if (doc.activeElement === field && doc.execCommand('insertText', false, value)) return true;\n } catch {\n // Fall through to the manual insertion.\n }\n const from = start ?? field.value.length;\n const to = end ?? from;\n let insert = value;\n if (field.maxLength >= 0) {\n const room = Math.max(0, field.maxLength - (field.value.length - (to - from)));\n insert = insert.slice(0, room);\n // Never leave half of a surrogate pair (an emoji) behind.\n if (/[\\ud800-\\udbff]$/.test(insert)) insert = insert.slice(0, -1);\n }\n if (start === null) setNativeValue(field, field.value + insert);\n else field.setRangeText(insert, from, to, 'end');\n const view = doc.defaultView;\n const event =\n view !== null && typeof view.InputEvent === 'function'\n ? new view.InputEvent('input', { bubbles: true, inputType: 'insertFromPaste', data: insert })\n : new Event('input', { bubbles: true });\n field.dispatchEvent(event);\n return true;\n}\n\n/**\n * Sets a field's value through the prototype's setter. React tracks the value\n * set on the element itself; going around it lets React see the change and\n * call `onChange` for the `input` event that follows.\n */\nfunction setNativeValue(field: TextField, next: string): void {\n const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field) as object, 'value');\n // eslint-disable-next-line @typescript-eslint/unbound-method -- it is called right below with the field as `this`\n const setter = descriptor?.set;\n if (setter) setter.call(field, next);\n else field.value = next;\n}\n","import { CopyFailure, copyFailure } from '../core/errors';\nimport { asTextField, insertText } from '../core/text-field';\nimport { extract } from './element';\nimport { inspectCode, positiveLimit, type CodeFinding } from './inspect';\nimport { lineText, toLines, type Line } from './lines';\nimport { render, resolveText, transform, type CodeTextOptions } from './normalize';\n\nexport const DEFAULT_CODE_MAX_LENGTH = 2_000_000;\n\nexport interface PasteToCodeOptions extends Omit<CodeTextOptions, 'finalNewline'> {\n /**\n * Indentation for every line after the first, which lands where the cursor is.\n * `pasteAsCode` sets it to the cursor line's indentation.\n */\n readonly indent?: string;\n /**\n * Longest paste to process, in UTF-16 code units. Longer pastes throw a\n * `too-large` error (`pasteAsCode` leaves them to the browser): code is never cut.\n * Default {@link DEFAULT_CODE_MAX_LENGTH}.\n */\n readonly maxLength?: number;\n}\n\nexport interface PasteCode {\n readonly code: string;\n /** `text` for the plain-text flavour; `html` when only HTML was on the clipboard. */\n readonly source: 'text' | 'html';\n /** What the pasted text held, before anything was fixed (positions in the pasted text, at most 1000). */\n readonly findings: readonly CodeFinding[];\n /** How many characters `clean` replaced or removed. */\n readonly fixed: number;\n /** What is still in `code` (positions in `code`), e.g. a non-Latin letter with no lookalike. */\n readonly remaining: readonly CodeFinding[];\n /** Whether `remaining` holds a `danger` finding. */\n readonly danger: boolean;\n}\n\n/** The clipboard flavours: a `PasteResult` from `usePaste`, or anything with `text` / `html`. */\nexport interface CodePasteSource {\n readonly text?: string | null;\n readonly html?: string | null;\n}\n\nconst INDENT = /^[ \\t]*$/;\n\nfunction indentLines(lines: readonly Line[], indent: string): Line[] {\n if (indent === '') return [...lines];\n return lines.map((line, at) => (at === 0 || lineText(line) === '' ? line : [{ text: indent, style: '' }, ...line]));\n}\n\n/**\n * Code for what was pasted: the plain text (or, when only HTML was copied, the\n * text of its code), cleaned of invisible and lookalike characters, curly quotes\n * and odd spaces, dedented, and re-indented with `indent`. Every finding is\n * reported. Returns `null` when there is nothing to paste.\n *\n * @example\n * usePaste({ accept: ['text'], onPaste: (result) => {\n * const pasted = pasteToCode(result);\n * if (pasted?.danger) showWarning(pasted.remaining);\n * } });\n */\nexport function pasteToCode(source: CodePasteSource, options: PasteToCodeOptions = {}): PasteCode | null {\n const resolved = resolveText(options, { prompt: false, clean: true });\n const maxLength = positiveLimit(options.maxLength, DEFAULT_CODE_MAX_LENGTH, 'maxLength');\n const indent = options.indent ?? '';\n if (typeof indent !== 'string' || !INDENT.test(indent)) throw copyFailure('invalid-payload', '`indent` may only hold spaces and tabs.');\n let text = source.text ?? '';\n let from: PasteCode['source'] = 'text';\n if (text === '' && typeof source.html === 'string' && source.html.trim() !== '' && typeof DOMParser !== 'undefined') {\n if (source.html.length > maxLength) throw copyFailure('too-large', `The pasted HTML is longer than maxLength (${String(maxLength)}).`);\n // An inert document: scripts never run and nothing is fetched.\n const body = new DOMParser().parseFromString(source.html, 'text/html').body;\n text = extract(body, { styles: false }).runs.map((run) => run.text).join('');\n from = 'html';\n }\n if (text.length > maxLength) throw copyFailure('too-large', `The pasted text is longer than maxLength (${String(maxLength)}).`);\n if (text.trim() === '') return null;\n const { lines, fixed } = transform(toLines([{ text, style: '' }]), resolved);\n const code = render(indentLines(lines, indent), { eol: resolved.eol, finalNewline: false });\n const remaining = inspectCode(code, { maxFindings: Infinity }).findings;\n return {\n code,\n source: from,\n findings: inspectCode(text).findings,\n fixed,\n remaining,\n danger: remaining.some((finding) => finding.severity === 'danger'),\n };\n}\n\n/** Structural paste event: a DOM `ClipboardEvent` and React's `onPaste` event both fit. */\nexport interface CodePasteEvent {\n readonly clipboardData: { getData(format: string): string } | null;\n readonly currentTarget: EventTarget | null;\n readonly target: EventTarget | null;\n readonly defaultPrevented: boolean;\n preventDefault(): void;\n}\n\nexport interface PasteAsCodeOptions extends Omit<PasteToCodeOptions, 'indent'> {\n /** Indent the pasted lines to the cursor line's indentation, as code editors do. Default `true`. */\n readonly indentToCursor?: boolean;\n /**\n * Called before the code is inserted. Return `false` to cancel the paste, e.g.\n * when `danger` is set and the user declines.\n */\n // eslint-disable-next-line @typescript-eslint/no-invalid-void-type -- the callback may return nothing\n readonly onPaste?: (result: PasteCode) => boolean | void;\n}\n\n/**\n * A paste handler for code fields (`<textarea>`, or a text `<input>` for one-line\n * commands): pastes the code from {@link pasteToCode} at the cursor with the\n * browser's undo intact. Returns whether it took over the paste: `false` leaves\n * the paste to the browser (nothing to paste, a field it can't write to, invalid\n * options, or a paste past `maxLength`).\n *\n * @example\n * <textarea onPaste={pasteAsCode} />\n * <textarea onPaste={(event) => pasteAsCode(event, { onPaste: (r) => !r.danger || confirm('Paste anyway?') })} />\n */\nexport function pasteAsCode(event: CodePasteEvent, options: PasteAsCodeOptions = {}): boolean {\n if (event.defaultPrevented || event.clipboardData === null) return false;\n const field = asTextField(event.currentTarget) ?? asTextField(event.target);\n if (field === null || field.disabled || field.readOnly) return false;\n const { indentToCursor, onPaste, ...rest } = options;\n let indent = '';\n if (indentToCursor !== false && field.nodeName === 'TEXTAREA' && field.selectionStart !== null) {\n const before = field.value.slice(0, field.selectionStart);\n indent = /^[ \\t]*/.exec(before.slice(before.lastIndexOf('\\n') + 1))?.[0] as string;\n }\n let result: PasteCode | null;\n try {\n result = pasteToCode({ text: event.clipboardData.getData('text/plain'), html: event.clipboardData.getData('text/html') }, { ...rest, indent });\n } catch (error) {\n if (error instanceof CopyFailure) return false; // Invalid options or too large: the native paste still happens.\n throw error;\n }\n if (result === null) return false;\n event.preventDefault();\n if (onPaste?.(result) === false) return true;\n insertText(field, result.code);\n return true;\n}\n"],"mappings":";;AA8CA,SAAgB,gBAAgB,MAAqB,SAAiB,OAA4B;CAChG,OAAO,UAAU,KAA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-0,0 +1,292 @@
1
+ //#region src/code/inspect.d.ts
2
+ /**
3
+ * What a character in code can be suspicious for.
4
+ *
5
+ * - `bidi-control`: reorders how text is displayed (Trojan Source, CVE-2021-42574).
6
+ * - `invisible`: renders as nothing (zero-width spaces, tag characters, Hangul fillers).
7
+ * - `control`: a control character other than tab, line feed, carriage return or form feed.
8
+ * - `unusual-space`: a space that is not U+0020 (no-break, em, ideographic and similar spaces).
9
+ * - `confusable-punctuation`: typographic punctuation in place of ASCII, as word
10
+ * processors and chat apps write it (curly quotes, dashes, a Greek question mark).
11
+ * - `mixed-script`: a Cyrillic or Greek letter inside a Latin word (a homoglyph attack).
12
+ */
13
+ type CodeFindingKind = 'bidi-control' | 'invisible' | 'control' | 'unusual-space' | 'confusable-punctuation' | 'mixed-script';
14
+ /** Every finding kind, in a stable order. */
15
+ export declare const CODE_FINDING_KINDS: readonly CodeFindingKind[];
16
+ /**
17
+ * `danger`: the code can run differently from how it reads (a bidi override, an
18
+ * invisible identifier, a lookalike letter). `warning`: likely a copy artifact
19
+ * that breaks the code or hides in it (curly quotes, a zero-width space).
20
+ */
21
+ type CodeFindingSeverity = 'danger' | 'warning';
22
+ interface CodeFinding {
23
+ readonly kind: CodeFindingKind;
24
+ readonly severity: CodeFindingSeverity;
25
+ /** Offset in the inspected text, in UTF-16 code units (as `String.prototype.slice` counts). */
26
+ readonly index: number;
27
+ /** Length in UTF-16 code units: 1, or 2 for a character outside the Basic Multilingual Plane. */
28
+ readonly length: number;
29
+ /** 1-based line. Lines end at `\n`, `\r\n` or `\r`. */
30
+ readonly line: number;
31
+ /** 1-based column in UTF-16 code units, as most editors count it. */
32
+ readonly column: number;
33
+ readonly codePoint: number;
34
+ /** Developer-facing, e.g. `U+202E RIGHT-TO-LEFT OVERRIDE`. */
35
+ readonly label: string;
36
+ /** The safe replacement `cleanCode` writes (`''` removes it), or `null` when there is none to guess. */
37
+ readonly replacement: string | null;
38
+ }
39
+ interface InspectCodeOptions {
40
+ /** Which kinds to look for. Default: all of {@link CODE_FINDING_KINDS}. */
41
+ readonly kinds?: readonly CodeFindingKind[];
42
+ /** Stop after this many findings and set `truncated`. Default {@link DEFAULT_CODE_MAX_FINDINGS}. */
43
+ readonly maxFindings?: number;
44
+ }
45
+ interface CodeInspection {
46
+ /** In order of position. */
47
+ readonly findings: readonly CodeFinding[];
48
+ /** Whether any finding is `danger`. */
49
+ readonly danger: boolean;
50
+ /** Whether `maxFindings` stopped the scan early. */
51
+ readonly truncated: boolean;
52
+ }
53
+ export declare const DEFAULT_CODE_MAX_FINDINGS = 1000;
54
+ /**
55
+ * Finds characters that make code read differently from how it runs, or that a
56
+ * copy through a word processor or chat app slipped in: bidirectional overrides
57
+ * (Trojan Source), invisible characters and identifiers, control characters,
58
+ * unusual spaces, curly quotes and dashes, and Cyrillic or Greek lookalikes inside
59
+ * Latin words. Works anywhere, including on the server.
60
+ *
61
+ * @example
62
+ * const { danger, findings } = inspectCode(pasted);
63
+ * if (danger) warn(findings.map((f) => `${f.line}:${f.column} ${f.label}`));
64
+ */
65
+ export declare function inspectCode(code: string, options?: InspectCodeOptions): CodeInspection;
66
+ interface CleanCodeOptions {
67
+ /** Which kinds to fix. Default: all. Findings without a `replacement` are never changed. */
68
+ readonly kinds?: readonly CodeFindingKind[];
69
+ }
70
+ interface CleanCode {
71
+ readonly code: string;
72
+ /** What was replaced or removed, in order, with positions in the original text. */
73
+ readonly fixed: readonly CodeFinding[];
74
+ /** What is still in `code` (positions in `code`): findings without a safe replacement. */
75
+ readonly remaining: readonly CodeFinding[];
76
+ }
77
+ /**
78
+ * Replaces what {@link inspectCode} finds with safe ASCII: removes bidi controls,
79
+ * invisible and control characters, turns unusual spaces into spaces, curly quotes
80
+ * and dashes into `'` `"` `-`, and lookalike letters into the Latin letters they
81
+ * imitate. Letters with no lookalike are reported in `remaining`, never guessed.
82
+ *
83
+ * @example
84
+ * cleanCode('const s = \u201Chi\u201D;').code; // 'const s = "hi";'
85
+ */
86
+ export declare function cleanCode(code: string, options?: CleanCodeOptions): CleanCode;
87
+ //#endregion
88
+ //#region src/code/normalize.d.ts
89
+ /** Built-in prompt styles for terminal and REPL sessions. */
90
+ type PromptStyle = 'shell' | 'powershell' | 'cmd' | 'python' | 'ipython' | 'node';
91
+ /** Every built-in prompt style. `'auto'` tries all but `node`, whose `> ` is too common to guess. */
92
+ export declare const PROMPT_STYLES: readonly PromptStyle[];
93
+ /**
94
+ * A custom prompt. `command` matches the prompt at the start of a command line,
95
+ * `continuation` the prompt of the lines that continue it. Matches must start at
96
+ * the beginning of the line; the `g` and `y` flags are ignored.
97
+ */
98
+ interface PromptPattern {
99
+ readonly command: RegExp;
100
+ readonly continuation?: RegExp;
101
+ }
102
+ interface CodeTextOptions {
103
+ /**
104
+ * Copy a terminal or REPL session as the commands to run: prompts are removed
105
+ * and output lines are dropped. `'auto'` (the default for copying) does this only
106
+ * when the first line starts with a `$`, `PS>`, `C:\>`, `>>>` or `In [1]:`
107
+ * prompt; `false` keeps the text as it is.
108
+ */
109
+ readonly prompt?: 'auto' | false | PromptStyle | PromptPattern;
110
+ /** Copy a unified diff as the code after (`'after'`) or before (`'before'`) the change. Default `false`. */
111
+ readonly diff?: false | 'after' | 'before';
112
+ /**
113
+ * Remove line numbers typed into the text (`1: code`, ` 12 | code`). Only
114
+ * applied when every line starts with a number and the numbers count up by one.
115
+ * Default `false`.
116
+ */
117
+ readonly lineNumbers?: boolean;
118
+ /** Remove the indentation every line shares. Default `true`. */
119
+ readonly dedent?: boolean;
120
+ /** Default `true`. */
121
+ readonly trimTrailingWhitespace?: boolean;
122
+ /** Remove blank lines at the start and the end. Default `true`. */
123
+ readonly trimBlankLines?: boolean;
124
+ /** Default `'lf'`. */
125
+ readonly lineEnding?: 'lf' | 'crlf';
126
+ /** End with a line break. Default `false`. */
127
+ readonly finalNewline?: boolean;
128
+ /**
129
+ * Fix what `inspectCode` finds (see `cleanCode`): `true` for every kind, or a
130
+ * list of kinds. Default `false` when copying, `true` when pasting.
131
+ */
132
+ readonly clean?: boolean | readonly CodeFindingKind[];
133
+ }
134
+ /**
135
+ * Code as it should be copied or saved: a terminal session becomes its commands,
136
+ * a diff one side of the change, typed line numbers and shared indentation are
137
+ * removed, line endings are normalised. Works anywhere, including on the server.
138
+ *
139
+ * @example
140
+ * normalizeCode('$ npm install react-smart-copy\nadded 1 package'); // 'npm install react-smart-copy'
141
+ */
142
+ export declare function normalizeCode(code: string, options?: CodeTextOptions): string;
143
+ //#endregion
144
+ //#region src/core/payload.d.ts
145
+ interface TextPayload {
146
+ readonly kind: 'text';
147
+ readonly value: string;
148
+ }
149
+ interface HtmlPayload {
150
+ readonly kind: 'html';
151
+ readonly html: string;
152
+ /** Required plain-text fallback for targets that don't understand HTML. */
153
+ readonly text: string;
154
+ }
155
+ //#endregion
156
+ //#region src/code/payload.d.ts
157
+ /** Code to copy: a string, or a rendered (and possibly highlighted) code block. */
158
+ type CodeSource = string | Element;
159
+ interface CodeFromElementOptions extends CodeTextOptions {
160
+ /**
161
+ * A CSS selector for more parts of the block to leave out. Gutters, hidden and
162
+ * `user-select: none` parts, `aria-hidden` decorations, buttons and anything with
163
+ * `data-copy-ignore` are always left out.
164
+ */
165
+ readonly ignore?: string;
166
+ }
167
+ interface CodePayloadOptions extends CodeFromElementOptions {
168
+ /**
169
+ * Add an HTML flavour (`<pre><code>`), so the code stays monospaced when pasted
170
+ * into Google Docs, Word, Slack, Teams or a mail; from an element, with its
171
+ * syntax colours. Editors and terminals still paste the plain text. Default `true`.
172
+ */
173
+ readonly html?: boolean;
174
+ /** Written as `class="language-<name>"` on the `<code>` element. Letters, digits and `_ + # . -` only. */
175
+ readonly language?: string;
176
+ }
177
+ /**
178
+ * The code a rendered block shows, ready to run or save: see {@link extract} for
179
+ * what is left out, and {@link CodeTextOptions} for prompts, diffs and whitespace.
180
+ *
181
+ * @example
182
+ * codeFromElement(preRef.current, { prompt: 'shell' });
183
+ */
184
+ export declare function codeFromElement(element: Element, options?: CodeFromElementOptions): string;
185
+ /**
186
+ * A copy payload for code: plain text for editors and terminals, plus
187
+ * monospaced HTML (with the block's syntax colours when you pass the element)
188
+ * for documents and chat. A terminal session is copied as its commands
189
+ * (`prompt: 'auto'`). Code that ends up empty gives an empty text payload, which
190
+ * `copy()` reports as an `invalid-payload` error.
191
+ *
192
+ * @example
193
+ * const { copy } = useCopy();
194
+ * <button onClick={() => copy(() => codePayload(preRef.current!, { language: 'tsx' }))}>Copy</button>
195
+ */
196
+ export declare function codePayload(source: CodeSource, options?: CodePayloadOptions): HtmlPayload | TextPayload;
197
+ //#endregion
198
+ //#region src/code/paste.d.ts
199
+ export declare const DEFAULT_CODE_MAX_LENGTH = 2000000;
200
+ interface PasteToCodeOptions extends Omit<CodeTextOptions, 'finalNewline'> {
201
+ /**
202
+ * Indentation for every line after the first, which lands where the cursor is.
203
+ * `pasteAsCode` sets it to the cursor line's indentation.
204
+ */
205
+ readonly indent?: string;
206
+ /**
207
+ * Longest paste to process, in UTF-16 code units. Longer pastes throw a
208
+ * `too-large` error (`pasteAsCode` leaves them to the browser): code is never cut.
209
+ * Default {@link DEFAULT_CODE_MAX_LENGTH}.
210
+ */
211
+ readonly maxLength?: number;
212
+ }
213
+ interface PasteCode {
214
+ readonly code: string;
215
+ /** `text` for the plain-text flavour; `html` when only HTML was on the clipboard. */
216
+ readonly source: 'text' | 'html';
217
+ /** What the pasted text held, before anything was fixed (positions in the pasted text, at most 1000). */
218
+ readonly findings: readonly CodeFinding[];
219
+ /** How many characters `clean` replaced or removed. */
220
+ readonly fixed: number;
221
+ /** What is still in `code` (positions in `code`), e.g. a non-Latin letter with no lookalike. */
222
+ readonly remaining: readonly CodeFinding[];
223
+ /** Whether `remaining` holds a `danger` finding. */
224
+ readonly danger: boolean;
225
+ }
226
+ /** The clipboard flavours: a `PasteResult` from `usePaste`, or anything with `text` / `html`. */
227
+ interface CodePasteSource {
228
+ readonly text?: string | null;
229
+ readonly html?: string | null;
230
+ }
231
+ /**
232
+ * Code for what was pasted: the plain text (or, when only HTML was copied, the
233
+ * text of its code), cleaned of invisible and lookalike characters, curly quotes
234
+ * and odd spaces, dedented, and re-indented with `indent`. Every finding is
235
+ * reported. Returns `null` when there is nothing to paste.
236
+ *
237
+ * @example
238
+ * usePaste({ accept: ['text'], onPaste: (result) => {
239
+ * const pasted = pasteToCode(result);
240
+ * if (pasted?.danger) showWarning(pasted.remaining);
241
+ * } });
242
+ */
243
+ export declare function pasteToCode(source: CodePasteSource, options?: PasteToCodeOptions): PasteCode | null;
244
+ /** Structural paste event: a DOM `ClipboardEvent` and React's `onPaste` event both fit. */
245
+ interface CodePasteEvent {
246
+ readonly clipboardData: {
247
+ getData(format: string): string;
248
+ } | null;
249
+ readonly currentTarget: EventTarget | null;
250
+ readonly target: EventTarget | null;
251
+ readonly defaultPrevented: boolean;
252
+ preventDefault(): void;
253
+ }
254
+ interface PasteAsCodeOptions extends Omit<PasteToCodeOptions, 'indent'> {
255
+ /** Indent the pasted lines to the cursor line's indentation, as code editors do. Default `true`. */
256
+ readonly indentToCursor?: boolean;
257
+ /**
258
+ * Called before the code is inserted. Return `false` to cancel the paste, e.g.
259
+ * when `danger` is set and the user declines.
260
+ */
261
+ readonly onPaste?: (result: PasteCode) => boolean | void;
262
+ }
263
+ /**
264
+ * A paste handler for code fields (`<textarea>`, or a text `<input>` for one-line
265
+ * commands): pastes the code from {@link pasteToCode} at the cursor with the
266
+ * browser's undo intact. Returns whether it took over the paste: `false` leaves
267
+ * the paste to the browser (nothing to paste, a field it can't write to, invalid
268
+ * options, or a paste past `maxLength`).
269
+ *
270
+ * @example
271
+ * <textarea onPaste={pasteAsCode} />
272
+ * <textarea onPaste={(event) => pasteAsCode(event, { onPaste: (r) => !r.danger || confirm('Paste anyway?') })} />
273
+ */
274
+ export declare function pasteAsCode(event: CodePasteEvent, options?: PasteAsCodeOptions): boolean;
275
+ //#endregion
276
+ //#region src/core/text-field.d.ts
277
+ /**
278
+ * Text-field helpers shared by the paste handlers of the opt-in entry points.
279
+ * Internal: not part of `react-smart-copy/core`'s public API.
280
+ */
281
+ /** Text fields `setRangeText` and `execCommand('insertText')` both support. */
282
+ type TextField = HTMLTextAreaElement | HTMLInputElement;
283
+ /**
284
+ * Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the
285
+ * selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still
286
+ * works, `input` events fire (so React and other frameworks see the change),
287
+ * and `maxlength` is respected. Returns `false` for disabled or read-only fields.
288
+ */
289
+ export declare function insertText(field: TextField, text: string): boolean;
290
+ //#endregion
291
+ export type { CleanCode, CleanCodeOptions, CodeFinding, CodeFindingKind, CodeFindingSeverity, CodeFromElementOptions, CodeInspection, CodePasteEvent, CodePasteSource, CodePayloadOptions, CodeSource, CodeTextOptions, InspectCodeOptions, PasteAsCodeOptions, PasteCode, PasteToCodeOptions, PromptPattern, PromptStyle };
292
+ //# sourceMappingURL=code.d.cts.map