API reference
Every export of active-helpers, per entry point - the package's own reference, and every export generated from the source.
Three subpaths, no root entry point. Every module is dependency-free and runs in any JavaScript runtime (browser, Node.js, worker). The source TSDoc is the detailed contract; this page lists every export and what it guarantees.
./ serialization#
Machine serialization for exports. Nothing here depends on a language: a value is written the way a file or a clipboard needs it, not the way a reader reads it.
- Kind
- function
(text: string) => string. Prefixes an apostrophe when a spreadsheet would otherwise execute the value: two or more characters starting with = or @, or with + or - followed by text, or by digits and an operator. A lone sign, and a signed plain number such as -12, stay unchanged.
- Kind
- constant
',': the RFC 4180 delimiter, used when a caller names none.
- Kind
- function
(value: unknown) => string. One CSV field: formula-neutralized and always quoted (embedded quotes doubled, newlines kept), so it is safe with any delimiter. null and undefined become empty text.
- Kind
- function
(values: readonly unknown[], delimiter?: string) => string. The fields of csv joined with delimiter (default DEFAULT_), verbatim: which delimiters a user may choose is the caller's policy.
- Kind
- function
(value: unknown) => string. One TSV field: formula-neutralized, quoted only when a tab, newline or quote would break the structure; never stripped or replaced.
- Kind
- function
(values: readonly unknown[]) => string. The fields of tsv joined with a tab.
- Kind
- function
<T>(obj: T) => T. Replaces every Decimal.js-style instance (an object with to and the fields d, e and s) by to, recursively through arrays and objects, so a query result crosses a server-to-client boundary. Lossy beyond double precision. Date and Reg are returned unchanged.
./ export- fonts#
The backend-neutral mechanics of an embedded-font PDF export with a jsPDF-class backend (no shaping, no bidi, UTF-16 code units). How a product loads, parses and draws fonts stays with the product.
- Kind
- type
'normal' | 'bold' | 'italic' | 'bolditalic': the four styles such a backend registers per family.
- Kind
- constant
Every bucket, regular first.
- Kind
- function
The bucket of a CSS weight and style: weight 600 and up is bold.
- Kind
- function
(available, requested): the bucket a family draws requested in: the exact bucket, else the same style in the other weight, else the same weight in the other style, else regular; undefined when the family has no regular face. Nothing is synthesised.
- Kind
- type
What the leading bytes of a font file say it is.
- Kind
- function
(bytes: Uint8. Classifies by signature without parsing. Only truetype is embeddable; CFF OpenType, WOFF, WOFF2 and collections are recognised so a refusal can name them. Fewer than twelve bytes is unknown.
- Kind
- function
Whether a PDF standard font with WinAnsi encoding can draw a code point.
- Kind
- function
Tab, line feed and carriage return: collapsed to spaces, never drawn.
- Kind
- type
'complex-.
- Kind
- type
The first code point a backend cannot draw, why, the script (for complex-) and, for combining-, whether NFC would remove every mark.
- Kind
- function
(text: string) => Pdf. The first code point that a backend without shaping cannot draw, or null. Never returns the text itself.
- Kind
- type
One run of a text unit, drawn in one bucket.
- Kind
- type
{covered: true; index} or {covered: false; code.
- Kind
- function
(segments, families, covers): the first family, in the host's order, that covers every drawn code point of a unit in the bucket each segment is drawn in. One unit is drawn in one family; there is no per-glyph fallback.
./ menu- items#
The menu item contract and the one resolution every Active menu runs through before it renders. How a menu renders, and what an action receives, stays with the product.
- Kind
- type
'separator': a line between groups.
- Kind
- interface
label, action, icon, variant ('default' | 'destructive'), disabled with disabled, shortcut, keep, visible(arg), separator, children.
- Kind
- type
Menu.
- Kind
- interface
The part of an entry the pipeline reads; a product's own entry type satisfies it structurally.
- Kind
- interface
arg (what visible is evaluated against; absent, visible is not evaluated) and keep(entry) (a product's own filter, asked first).
- Kind
- function
Drops separators that no longer separate anything: no leading, trailing or doubled line. Order is preserved.
- Kind
- function
When a menu ends on destructive entries, puts one line before that tail (within the last segment). Idempotent.
- Kind
- function
The pipeline, at every submenu depth: filter (keep, then visible), expand separator into lines, give the destructive tail its line, clean up the lines. Idempotent. A submenu whose children all filter away keeps its trigger with an empty children.
All exports, from the source#
@workspace/ active- helpers/ serialization#
Functions, hooks and constants
- Type
(value: unknown) => string
Render one CSV field. Always quoted, header fields included, so a header containing the delimiter cannot produce more columns than the data rows. Embedded quotes are doubled per RFC 4180; embedded newlines are legal inside a quoted field and are kept as-is, so multi-line cell content survives the round trip.
Quoting is UNCONDITIONAL and therefore delimiter-independent: a field that contains the separator, a quote or a newline is already safe whichever separator the row ends up joined with. That is why this function takes no delimiter — there is no decision here that depends on one.
Render one CSV row from its fields.
delimiter is the separator between fields and defaults to a comma. It is joined verbatim: the caller owns which separators it permits, because "which delimiter may a user choose" is a product question and this is the serialisation boundary. What the boundary DOES guarantee is that any separator is safe — see csv on unconditional quoting.
(values: readonly unknown[], delimiter?: string) => string- Type
","
The delimiter a CSV row uses when the caller names none: RFC 4180's comma.
- Type
(text: string) => string
Prefix a leading apostrophe when a spreadsheet would otherwise execute the value. Measured: the apostrophe is NOT consumed on either the CSV or the paste route, so it stays visible in the cell. That is accepted — it reads as a deliberate marker, where a leading space would read as a defect.
- Type
(value: unknown) => string
Render one clipboard TSV field.
Quoting on the paste route was MEASURED to be honoured by Excel and to be lossless: "mid<TAB>dle" arrives as one cell containing the tab, a quoted newline stays inside its cell, and "plain" arrives without its quotes. That is why this does not strip or replace anything: collapsing tab, CR or LF to a space would be a silent, lossy data change.
Quoting is MINIMAL: only fields that would otherwise break the structure are quoted, so plain values stay plain when pasted into a text editor. A field containing a " is quoted too — an unquoted field starting with a quote was measured to swallow the following delimiter and merge two columns.
- Type
(values: readonly unknown[]) => string
Render one clipboard TSV row from its fields.
- Type
<T>(obj: T) => T
Recursively convert decimal.js instances (Prisma Decimal) to plain numbers, so a query result can cross the server-to-client boundary, which does not serialize class instances. The conversion is to and therefore lossy beyond double precision; a caller that needs exact digits must convert to a string itself.
Arrays and plain objects are rebuilt recursively (a __ key stays an own property); Date and Reg instances are returned unchanged.
@workspace/ active- helpers/ export- fonts#
Functions, hooks and constants
- Type
readonly PdfFont Bucket[]
Every bucket, regular first.
The bucket of a CSS weight and style: weight 600 and up is bold, the rest normal (the rule the charts' PDF export has kept since FAM-V2-T6).
(weight: number, style: "normal" | "italic") => PdfFontBucketThe bucket a family draws requested in, given the buckets it has: the exact bucket, else the same style in the other weight, else the same weight in the other style, else regular. Nothing is synthesised: a family without bold draws bold text in its regular face. undefined only when the family has no regular face either.
(available: ReadonlySet<PdfFontBucket>, requested: PdfFontBucket) => PdfFontBucket | undefined- Type
(bytes: Uint8Array) => Font Byte Format
Classifies font bytes by their signature, without parsing them. Only truetype (00 01 00 00 or true) is embeddable by a jsPDF-class backend; CFF-flavoured OpenType (OTTO), WOFF, WOFF2 and collections (ttcf) are recognised so a refusal can name them. Fewer than twelve bytes (an sfnt header) is unknown.
- Type
(codePoint: number) => boolean
Whether a PDF standard font (Helvetica, Times, Courier with WinAnsi encoding) can draw code: printable ASCII, U+00A0–U+00FF and the twenty-seven Windows-1252 additions (€, curly quotes, dashes, …).
- Type
(codePoint: number) => boolean
Tab, line feed and carriage return: SVG and table text collapses them to spaces, so they are never drawn and need no glyph.
- Type
(text: string) => PdfText Refusal | null
The first code point of text that a PDF backend without shaping, bidi and supplementary-plane encoding cannot draw correctly, or null.
Refused, in this order per code point: emoji (default emoji presentation, or a supplementary-plane pictograph; a text-presentation pictograph such as ©, ® or ™ stays text), joiners and variation selectors (ZWNJ, ZWJ, VS1–VS256), a complex or right-to-left script (the list above, and conjoining Hangul jamo), any combining mark, and any code point beyond the Basic Multilingual Plane. Everything else is left to glyph coverage.
The analysis reads the text as it will be drawn. NFC is used only to tell the host whether a refused combining mark would compose away.
The first family, in the host's order, that covers EVERY drawn code point of a text unit in the bucket each segment is drawn in. One unit is drawn in one family: there is no per-glyph fallback, so a unit that mixes scripts needs one family that covers all of them.
covers(family, bucket, code answers for the face the family draws bucket in. Collapsed whitespace (tab, LF, CR) needs no glyph.
<F>(segments: readonly PdfTextSegment[], families: readonly F[], covers: (family: F, bucket: PdfFontBucket, codePoint: number) => boolean) => CoveringFamilyResultTypes
The four styles a jsPDF-class backend registers per family.
type PdfFontBucket = 'normal' | 'bold' | 'italic' | 'bolditalic';What the leading bytes of a font file say it is.
type FontByteFormat =
'truetype' | 'cff' | 'woff' | 'woff2' | 'collection' | 'unknown';Why a PDF backend without shaping cannot draw a text.
type PdfTextRefusalReason =
| 'complex-script'
| 'combining-mark'
| 'joiner-or-selector'
| 'emoji'
| 'supplementary-plane';The first code point of a text that a PDF backend cannot draw, and why.
interface PdfTextRefusal {
reason: PdfTextRefusalReason;
codePoint: number;
script?: string;
normalizable?: boolean;
}One run of a text unit, drawn in one requested bucket.
interface PdfTextSegment {
text: string;
bucket: PdfFontBucket;
}The outcome of select.
type CoveringFamilyResult =
| {covered: true; index: number}
| {
covered: false;
codePoint: number;
};