UNPKG

@kbss-cvut/s-forms

Version:

Semantic forms generator and processor

54 lines (53 loc) 2.29 kB
/** * * Utility class providing helper functions for media asset. */ export default class MediaAssetViewerUtils { /** * Determines the media kind and MIME type based on the source URL. * * @param {string} source - Media source URL. * @returns {{ kind: "video" | "image" | "iframe", type: string | null }} * Object describing the media kind and optional MIME type. * * @remarks * - Video formats are mapped to Video.js-compatible MIME types * - Unsupported or unknown formats fall back to iframe rendering */ static getMediaKindFromSource(source: string): { kind: "video" | "image" | "iframe"; type: string | null; }; /** * Converts normalized annotation points into viewport pixel coordinates. * * Input points are expected to be normalized (range 0–1) and encoded as * an SVG-compatible string (e.g. "0.1,0.2 0.3,0.4"). * * @param {string} pointsString - Normalized SVG point string. * @param {number} mediaWidth - Media viewport width in pixels. * @param {number} mediaHeight - Media viewport height in pixels. * @returns {string} Denormalized SVG point string in pixel space. */ static denormalizePointsFromStringToString(pointsString: string, mediaWidth: number, mediaHeight: number): string; /** * Parses an SVG-compatible points string into a numeric coordinate array. * * @param {string} pointsString - SVG point string (e.g. "100,200 300,400"). * @returns {number[][]} Array of coordinate pairs [[x, y], ...]. * * @remarks * - Assumes input is already denormalized into pixel space */ static getArrayPointsFromString(pointsString: string): number[][]; static stripExpandedLiterals(input: any): any; static castLiteral(value: any, type: any): any; /** * Normalizes the HAS_MEDIA_CONTENT value into a uniform array of media objects. * Accepts: * - A plain URL string wrapped into a single-element array with HAS_SOURCE set * - An array of strings/objects: strings are wrapped, objects are passed through * - A single object is wrapped into a single-element array */ static normalizeMediaContents(mediaContents: any, hasSourceKey: any): any[]; }