import type { ConvertedSerial, FontVariant, ImageGraphicType } from './idml2serial.js'; /** * Environment-agnostic asset matching for the IDML import flow. * * This is the resolution logic that used to live in bx-studio's `idmlImport.ts`, * lifted into the module so every consumer shares one matcher. It deals only in * `{ name, bytes }` pairs (no browser `File`), so it works in the studio, in * Node/CI, and anywhere else. {@link IdmlSerialConverter} drives it; callers that * want the low-level matchers can use them directly. */ /** The minimum a file needs for the matchers — its base name. `matchImageFile` / * `matchFontFiles` are generic over this, so a consumer can pass its own richer * file shape (e.g. bx-studio's `{ name, path, file: File }`) and get that same * object back, instead of duplicating the matching logic. */ export type NamedFile = { name: string; }; /** A provided asset file: its name (for matching) and its bytes (for use). */ export type AssetFile = NamedFile & { bytes: ArrayBuffer; }; declare function extensionOf(name: string): string; declare function baseNameOf(path: string): string; declare function stripExtension(name: string): string; /** Collapse to a comparison key: lower-case, alnum only (drops spaces, dashes…). */ declare function normalize(value: string): string; /** * Best-effort resolution of a linked image URI against provided files, limited to * recognized image formats. Exact base-name match (incl. extension) first, then * base name without extension — catching the common case where InDesign wrote an * absolute `file:///…/Links/foo.png` but the user supplied the package folder. */ export declare function matchImageFile(linkURI: string | undefined, files: T[]): T | undefined; /** * Resolution of a required font against provided font files (typically an * InDesign `Document fonts/` folder). * * `expectedFileNames` are the on-disk file names the IDML's XMP metadata recorded * for this family's variants (e.g. `DINBd_.ttf`), surfaced on each * {@link FontVariant.fontFileName}. When present they give an EXACT match even * though "DINBd_" bears no resemblance to the family "DIN-Bold". Only when the * metadata gave nothing do we fall back to the fuzzy family-name heuristic. */ export declare function matchFontFiles(family: string, expectedFileNames: string[], files: T[]): T[]; export interface AggregatedImage { imageId: string; linkURI?: string; /** true → bytes are embedded in the IDML (always uploadable). */ embedded: boolean; data?: ArrayBuffer; /** IDML source tag: 'Image' (raster incl. TIFF/PSD) | PDF | EPS | WMF | SVG. */ graphicType: ImageGraphicType; /** true when the bytes a browser can't render (PDF/EPS/WMF, and TIFF/PSD) — bx-files * must rasterize before display. Best-effort for still-missing images (no bytes to * sniff): keyed off graphicType only. */ needsConversion: boolean; /** Every serial element that references this image (patch targets). */ occurrences: { serialIndex: number; elementId: string; }[]; } export interface AggregatedFont { family: string; variants: FontVariant[]; /** On-disk file names (from the IDML XMP metadata) for exact folder matching. */ fileNames: string[]; serialIndices: number[]; } export interface AggregatedAssets { images: AggregatedImage[]; fonts: AggregatedFont[]; } /** Merge the per-serial `SerialAssets` into one de-duplicated work list. */ export declare function collectAssets(serials: ConvertedSerial[]): AggregatedAssets; export declare const _assetInternals: { normalize: typeof normalize; baseNameOf: typeof baseNameOf; stripExtension: typeof stripExtension; extensionOf: typeof extensionOf; FONT_EXTENSIONS: string[]; IMAGE_EXTENSIONS: string[]; }; export {}; //# sourceMappingURL=assets.d.ts.map