bidi-shaper
Version:
Logical→visual Unicode BiDi (UAX #9) reordering + Arabic contextual shaping for renderers outside the browser (PDF, canvas, WebGL, SVG, terminals, games). Zero dependencies.
31 lines (27 loc) • 1.31 kB
TypeScript
import { R as RenderOptions } from '../render-BhplWt64.js';
/**
* pdfmake adapter (`bidi-shaper/pdfmake`).
*
* Walks a pdfmake document definition and shapes/reorders every text node,
* returning a new definition (the input is never mutated). Container shapes
* handled: strings, `text` (string or array), `content`, `stack`, `columns`,
* `ul` / `ol`, and `table.body` cells. Functions (header/footer callbacks)
* and non-text nodes (images, canvases, QR) pass through untouched.
*/
interface PdfmakeShaperOptions extends RenderOptions {
/**
* When true, text nodes whose content is RTL and that don't already set
* `alignment` get `alignment: 'right'`. Default false.
*/
rtlAlignment?: boolean;
}
/** Shape/reorder a single pdfmake content node (string, array, or object). */
declare function shapeContent<T>(node: T, options?: PdfmakeShaperOptions): T;
/**
* Shape/reorder a whole document definition's `content`, `header`, and
* `footer` (function headers/footers are left for you to wrap yourself).
*
* pdfMake.createPdf(shapeDocDefinition(docDefinition)).download();
*/
declare function shapeDocDefinition<T extends Record<string, unknown>>(docDefinition: T, options?: PdfmakeShaperOptions): T;
export { type PdfmakeShaperOptions, shapeContent, shapeDocDefinition };