/** * Public-facing type definitions exposed in the main API. * These form the contract between the library and consumers. */ type CreateControllerOptions = { root?: ParentNode; /** Callback invoked when the Web Previews plugin requests navigation to a different URL */ onNavigateTo?: (path: string) => void; /** Hue (0–359) of the overlay accent color. Default: 17 (orange). */ hue?: number; /** * Whether to strip stega-encoded invisible characters from text content after stamping. * Default: false (preserves stega encoding in the DOM) * * When false (default): * - Stega encoding remains in the DOM (invisible to users) * - Controller can be disposed and recreated on the same page * - Content source of truth is preserved * * When true: * - Stega encoding is permanently removed from text nodes * - Text content becomes clean but controller cannot be recreated * - Useful if you need clean textContent for programmatic access */ stripStega?: boolean; /** * Whether to suppress package diagnostic warnings in the console. * Default: false. */ silenceWarnings?: boolean; }; type StampSummary = { scope: ParentNode; appliedStamps: Map; }; type Controller = { dispose(): void; isDisposed(): boolean; /** Notify the Web Previews plugin of the current URL (for client-side routing) */ setCurrentPath(url: string): void; /** Enable click-to-edit functionality */ enableClickToEdit(flashAll?: { scrollToNearestTarget: boolean; }): void; /** Disable click-to-edit functionality */ disableClickToEdit(): void; /** Whether click-to-edit is currently enabled */ isClickToEditEnabled(): boolean; /** Briefly highlight all editable elements with an animated effect */ flashAll(scrollToNearestTarget?: boolean): void; }; type State = { enabled: boolean; disposed: boolean; }; /** * Boot the click-to-edit runtime. When executed in a browser it returns a live * controller; on the server we hand back a no-op implementation so callers * don't have to guard their usage. */ declare function createController(options?: CreateControllerOptions): Controller; /** * Canonical metadata extracted from a stega payload. Most properties are * optional because the upstream string might not provide them, but we always * surface the raw payload for debugging purposes. */ type DecodedInfo = { origin: string; href: string; }; /** * Steganography helpers built on top of @vercel/stega. * These utilities decode the zero-width encoded metadata that DatoCMS embeds * into strings (text content, alt attributes, etc.) and normalize the result * into the strongly typed structure consumed by the rest of the SDK. */ /** * Decodes stega-encoded metadata from a string and returns structured information. * * This function extracts and decodes the FIRST stega-encoded segment found in the input, * returning a structured DecodedInfo object containing origin and href information. * If the input contains multiple stega encodings, only the first one is decoded. * * @param {string} input - The string potentially containing stega-encoded data * @param {ReturnType} [split] - Optional pre-split result from splitStega. * If provided, avoids re-splitting the input. Useful for performance when you've already * called splitStega on the same input. * @returns {DecodedInfo | null} The decoded metadata object with `origin` and `href` properties, * or null if: * - Input is empty/falsy * - No stega encoding found * - Decoding fails (invalid encoding) * - Decoded data doesn't match DecodedInfo structure * * @example * // Decode stega from a string * const info = decodeStega("Hello[U+200E]World"); * if (info) { * console.log(info.origin); // e.g., "https://example.com" * console.log(info.href); // e.g., "/path/to/content" * } */ declare function decodeStega(input: string): DecodedInfo | null; /** * Completely removes ALL stega encodings from any JavaScript value. * * This function works with any data type (strings, objects, arrays, primitives) by: * 1. Converting the input to a JSON string * 2. Removing all stega-encoded segments using the global VERCEL_STEGA_REGEX * 3. Parsing the cleaned JSON back to its original type * * Unlike splitStega which only works with strings, stripStega handles complex nested * structures and removes ALL stega encodings throughout the entire value. * * @template T - The type of the input value * @param {T} input - Any JavaScript value (string, object, array, number, etc.) * @returns {T} The same value with all stega encodings removed * * @example * // Works with strings * stripStega("Hello[U+200E]World") // "HelloWorld" * * @example * // Works with objects * stripStega({ name: "John[U+200E]", age: 30 }) * * @example * // Works with nested structures - removes ALL stega encodings * stripStega({ * users: [ * { name: "Alice[U+200E]", email: "alice[U+200E]@example.com" }, * { name: "Bob[U+200E]", email: "bob[U+200E]@example.com" } * ] * }) * * @example * // Works with arrays * stripStega(["First[U+200E]", "Second[U+200E]", "Third[U+200E]"]) */ declare function stripStega(input: T): T; /** * Replaces invisible stega-encoded segments with visible markers, making it * easy to spot which strings in a GraphQL response (or any other value) * carry Visual Editing metadata. * * Works exactly like {@link stripStega} — accepts any JSON-serialisable value * (string, object, array, etc.) — but instead of silently removing the hidden * characters it replaces each occurrence with a human-readable tag: * * ``` * [STEGA:/editor/item_types/123/items/456] * ``` * * @template T - The type of the input value * @param {T} input - Any JavaScript value (string, object, array, number, etc.) * @returns {T} The same value with stega encodings replaced by visible markers * * @example * revealStega("Hello world") * // "Hello [STEGA:/editor/item_types/123/items/456]world" * * @example * // Works with entire GraphQL responses * revealStega(graphqlResponse) */ declare function revealStega(input: T): T; export { type Controller, type CreateControllerOptions, type DecodedInfo, type StampSummary, type State, createController, decodeStega, revealStega, stripStega };