openvibe-sdk/svg

Generated at from openvibe-contracts v0.443.0 and openvibe-sdk v0.177.0.

From types/svg.d.ts (server only). Declarations are shown verbatim.

type SanitizeResult

sanitize(): the drawing rebuilt from the allowlist, or why it was refused.

export type SanitizeResult = { ok: true; svg: string } | { ok: false; why: string };

function sanitize

Rebuilds an SVG from the elements and attributes a drawing may have; refuses scripts, links, external references, entities and anything that is not well-formed.

export declare function sanitize(markup: string): SanitizeResult;

const ELEMENTS

The elements a drawing may have, by lower-cased name, to the spelling SVG gives them.

export declare const ELEMENTS: Map<string, string>;

const ATTRIBUTES

The attributes each element may keep.

export declare const ATTRIBUTES: Record<string, string[] | readonly string[]>;

const NEVER

Attribute names never kept (event handlers, links, sources …).

export declare const NEVER: RegExp;

const MAX_BYTES

The largest SVG sanitize() reads, in bytes.

export declare const MAX_BYTES: number;

function safeValue

export declare function safeValue(value: string): string | null;

function safeStyle

export declare function safeStyle(value: string): string | null;

function safePoints

export declare function safePoints(value: string): string | null;

function safePathData

export declare function safePathData(value: string): string | null;

interface PathSegment

One absolute path command (M L C Q Z) with its numbers.

export interface PathSegment { type: 'M' | 'L' | 'C' | 'Q' | 'Z'; args: number[] }

interface PathBox

export interface PathBox { x1: number; y1: number; x2: number; y2: number }

type ParseResult

export type ParseResult = { ok: true; segments: PathSegment[] } | { ok: false; why: string };

const path

SVG path data: parsed to absolute commands (arcs become cubics), measured, and written back.

export declare const path: {
    parse(d: string): ParseResult;
    bbox(segments: PathSegment[]): PathBox;
    subpaths(segments: PathSegment[]): PathSegment[][];
    closed(segments: PathSegment[]): boolean;
    toData(segments: PathSegment[]): string;
    round(n: number): number;
    numText(n: number): string;
    scan(d: string): string[];
};