import { HookableCore } from 'hookable'; type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error' | 'removed'; type BaseScriptApi = Record; type HasDiscriminatedParameters = T extends { (first: infer A, ...rest1: any[]): any; (first: infer B, ...rest2: any[]): any; } ? A extends B ? B extends A ? false : true : true : false; type HasDifferentParameterCounts = T extends { (...args: infer A): any; } & { (...args: infer B): any; } ? A['length'] extends B['length'] ? B['length'] extends A['length'] ? false : true : true : false; type IsOverloadedFunction = HasDiscriminatedParameters extends true ? true : HasDifferentParameterCounts extends true ? true : false; type AsVoidFunctions = { [K in keyof T]: T[K] extends any[] ? T[K] : T[K] extends (...args: infer A) => any ? IsOverloadedFunction extends true ? T[K] : (...args: A) => void : T[K] extends Record ? AsVoidFunctions : never; }; type WarmupStrategy = false | 'preload' | 'preconnect' | 'dns-prefetch'; interface UseScriptWaitForResolve { (value: V): V; (value: PromiseLike): PromiseLike; (value: T | PromiseLike): T | PromiseLike; } type UseScriptWaitForInferredResult = [T] extends [void | (() => void)] ? unknown : NonNullable>; interface UseScriptWaitFor { /** * With an explicit result type, setup may use callback-style registration and * return cleanup. Without one, `waitFor(resolve => resolve(value))` infers it. */ (setup: (resolve: UseScriptWaitForResolve<[T] extends [never] ? unknown : T>, reject: (reason?: unknown) => void) => R): Promise<[T] extends [never] ? UseScriptWaitForInferredResult : T>; } interface UseScriptContextOptions { /** * Aborted when the script is removed or fails to load. */ signal: AbortSignal; /** * Wait for an SDK-specific readiness callback. Abort rejection and returned * cleanup are tied to the script lifecycle. */ waitFor: UseScriptWaitFor; } type UseScriptResolver = (ctx: UseScriptContextOptions) => T | PromiseLike | undefined | null; /** * Register a script load trigger. A returned function is treated as cleanup; * other return values are ignored for backwards compatibility. */ type UseScriptTrigger = (load: () => void) => any; interface ScriptInstance { proxy: AsVoidFunctions; instance?: T; id: string; /** * Aborted when the script is removed or fails to load. */ signal: AbortSignal; status: Readonly; entry?: ActiveHeadEntry; load: () => Promise; warmup: (rel: WarmupStrategy) => ActiveHeadEntry; remove: () => boolean; setupTriggerHandler: (trigger: UseScriptOptions['trigger']) => () => void; onLoaded: (fn: (instance: T) => void | Promise, options?: EventHandlerOptions) => () => void; onError: (fn: (err?: Error) => void | Promise, options?: EventHandlerOptions) => () => void; /** * @internal */ _warmupStrategy?: string; /** * @internal */ _loadPromise: Promise; /** * @internal */ _warmupEl: any; /** * @internal */ _triggerAbortController?: AbortController | null; /** * @internal */ _triggerAbortControllers?: Set; /** * @internal */ _triggerPromises?: Promise[]; /** * @internal */ _setupTriggerHandler: (trigger: UseScriptOptions['trigger'], removeOnError?: boolean) => () => void; /** * @internal */ _cbs: { loaded: null | ((instance: T) => void | Promise)[]; error: null | ((err?: Error) => void | Promise)[]; }; } interface EventHandlerOptions { /** * Used to dedupe the event, allowing you to have an event run only a single time. */ key?: string; } interface UseScriptOptions> extends HeadEntryOptions { /** * Create a consumer-owned handle without changing the shared script lifecycle. * Existing callers receive the cached shared script unless this is enabled. */ scope?: boolean; /** * Resolve the script instance from the window. This legacy callback is always * called without arguments. It may return the API asynchronously. */ use?: () => T | PromiseLike | undefined | null; /** * Resolve the script API with lifecycle helpers. Prefer this over `use` when * readiness needs an abort signal or `waitFor()` callback bridge. */ resolve?: UseScriptResolver; /** * The trigger to load the script: * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded. * - `manual` - Load the script manually by calling `$script.load()`, exists only on the client. * - `Promise` - Load the script when the promise resolves, exists only on the client. * - `Function` - Register a callback function to load the script, exists only on the client. It may return a cleanup function. * - `server` - Have the script injected on the server. */ trigger?: 'client' | 'server' | 'manual' | Promise | UseScriptTrigger | null; /** * Add a preload or preconnect link tag before the script is loaded. */ warmupStrategy?: WarmupStrategy; /** * Context to run events with. This is useful in Vue to attach the current instance context before * calling the event, allowing the event to be reactive. */ eventContext?: any; /** * Called before the script is initialized. Will not be triggered when the script is already loaded. This means * this is guaranteed to be called only once, unless the script is removed and re-added. */ beforeInit?: () => void; } type Booleanable = boolean | 'false' | 'true' | ''; type Stringable = string | Booleanable | number; type Falsy = false | null | undefined; type ResolvableValue = T | Falsy | (() => (T | Falsy)); type Prettify = { [K in keyof T]: T[K]; } & {}; type _ResolvablePropertiesRaw = { [K in keyof T as {} extends Pick ? never : K]: ResolvableValue; } & { [K in keyof T as {} extends Pick ? K : never]?: ResolvableValue; }; type ResolvableProperties = Prettify<_ResolvablePropertiesRaw>; interface DataKeys { [key: `data-${string}`]: Stringable; } interface BaseFields { /** * The base URL to be used throughout the document for relative URLs. Absolute and relative URLs are allowed. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base#attr-href */ href?: string; /** * A keyword or author-defined name of the default browsing context to show the results of navigation from ``, * ``, or `
` elements without explicit target attributes. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base#attr-target */ target?: '_blank' | '_self' | '_parent' | '_top' | (string & Record); } /** * The `` HTML element requires at least `href` or `target` to be valid. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base */ type Base = (BaseFields & { href: string; }) | (BaseFields & { target: '_blank' | '_self' | '_parent' | '_top' | (string & Record); }); interface GlobalAttributes { /** * Provides a hint for generating a keyboard shortcut for the current element. This attribute consists of a * space-separated list of characters. The browser should use the first one that exists on the computer keyboard layout. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey */ accesskey?: string; /** * Controls whether and how text input is automatically capitalized as it is entered/edited by the user. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autocapitalize */ autocapitalize?: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters'; /** * Indicates that an element is to be focused on page load, or as soon as the `` it is part of is displayed. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus */ autofocus?: Booleanable; /** * A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access * specific elements via the class selectors or functions like the method Document.getElementsByClassName(). * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class */ class?: Stringable; /** * An enumerated attribute indicating if the element should be editable by the user. * If so, the browser modifies its widget to allow editing. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable */ contenteditable?: Booleanable; /** * An enumerated attribute indicating the directionality of the element's text. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir */ dir?: 'ltr' | 'rtl' | 'auto'; /** * An enumerated attribute indicating whether the element can be dragged, using the Drag and Drop API. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable */ draggable?: Booleanable; /** * Hints what action label (or icon) to present for the enter key on virtual keyboards. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint */ enterkeyhint?: string; /** * Used to transitively export shadow parts from a nested shadow tree into a containing light tree. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts */ exportparts?: string; /** * A Boolean attribute indicates that the element is not yet, or is no longer, relevant. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden */ hidden?: Booleanable; /** * The id global attribute defines a unique identifier (ID) which must be unique in the whole document. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id */ id?: string; /** * Provides a hint to browsers as to the type of virtual keyboard configuration to use when editing this element or its contents. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode */ inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url'; /** * Allows you to specify that a standard HTML element should behave like a registered custom built-in element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/is */ is?: string; /** * The unique, global identifier of an item. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemid */ itemid?: string; /** * Used to add properties to an item. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemprop */ itemprop?: string; /** * Properties that are not descendants of an element with the itemscope attribute can be associated with the item using an itemref. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemref */ itemref?: string; /** * itemscope (usually) works along with itemtype to specify that the HTML contained in a block is about a particular item. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemscope */ itemscope?: string; /** * Specifies the URL of the vocabulary that will be used to define itemprops (item properties) in the data structure. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemtype */ itemtype?: string; /** * Helps define the language of an element: the language that non-editable elements are in, or the language * that editable elements should be written in by the user. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang */ lang?: 'en' | 'en-US' | 'en-GB' | 'de' | 'fr' | 'es' | 'it' | 'ja' | 'ko' | 'nl' | 'pl' | 'pt' | 'pt-BR' | 'ru' | 'zh' | 'zh-CN' | 'zh-TW' | 'ar' | 'hi' | 'id' | 'th' | 'tr' | 'uk' | 'vi' | (string & Record); /** * A cryptographic nonce ("number used once") which can be used by Content Security Policy to determine whether or not * a given fetch will be allowed to proceed. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce */ nonce?: string; /** * A space-separated list of the part names of the element. Part names allows CSS to select and style specific elements * in a shadow tree via the ::part pseudo-element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part */ part?: string; /** * Assigns a slot in a shadow DOM shadow tree to an element: An element with a slot attribute is assigned to the slot * created by the `` element whose name attribute's value matches that slot attribute's value. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/slot */ slot?: string; /** * An enumerated attribute defines whether the element may be checked for spelling errors. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck */ spellcheck?: Booleanable; /** * Contains CSS styling declarations to be applied to the element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/style */ style?: string; /** * An integer attribute indicating if the element can take input focus (is focusable), * if it should participate to sequential keyboard navigation, and if so, at what position. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex */ tabindex?: number; /** * Contains a text representing advisory information related to the element it belongs to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title */ title?: string; /** * An enumerated attribute that is used to specify whether an element's attribute values and the values of its * Text node children are to be translated when the page is localized, or whether to leave them unchanged. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/translate */ translate?: 'yes' | 'no' | ''; } interface BodyEvents { /** * Script to be run after the document is printed */ onafterprint?: string; /** * Script to be run before the document is printed */ onbeforeprint?: string; /** * Script to be run when the document is about to be unloaded */ onbeforeunload?: string; /** * Script to be run when an error occurs */ onerror?: string; /** * Script to be run when there has been changes to the anchor part of the a URL */ onhashchange?: string; /** * Fires after the page is finished loading */ onload?: string; /** * Script to be run when the message is triggered */ onmessage?: string; /** * Script to be run when the browser starts to work offline */ onoffline?: string; /** * Script to be run when the browser starts to work online */ ononline?: string; /** * Script to be run when a user navigates away from a page */ onpagehide?: string; /** * Script to be run when a user navigates to a page */ onpageshow?: string; /** * Script to be run when the window's history changes */ onpopstate?: string; /** * Fires when the browser window is resized */ onresize?: string; /** * Script to be run when a Web Storage area is updated */ onstorage?: string; /** * Fires once a page has unloaded (or the browser window has been closed) */ onunload?: string; } interface BodyAttributesWithoutEvents extends Pick { } interface HtmlAttributes extends Pick { /** * Open-graph protocol prefix. * * @see https://ogp.me/ */ prefix?: 'og: https://ogp.me/ns#' | (string & Record); /** * XML namespace * * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Namespaces_Crash_Course */ xmlns?: string; /** * Custom XML namespace * * @See https://developer.mozilla.org/en-US/docs/Web/SVG/Namespaces_Crash_Course */ [key: `xmlns:${'og' | string}`]: string; } interface HttpEventAttributes { /** * Script to be run on abort */ onabort?: string; /** * Script to be run when an error occurs when the file is being loaded */ onerror?: string; /** * Script to be run when the file is loaded */ onload?: string; /** * The progress event is fired periodically when a request receives more data. */ onprogress?: string; /** * Script to be run just as the file begins to load before anything is actually loaded */ onloadstart?: string; } type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'; /** * Represents the possible blocking tokens for an element. */ type BlockingToken = 'render'; /** * Represents the blocking attribute for an element. * The blocking attribute must have a value that is an unordered set of unique space-separated tokens, * each of which are possible blocking tokens. */ interface Blocking { /** * The blocking attribute indicates that certain operations should be blocked on the fetching of an external resource. * The value is an unordered set of unique space-separated tokens, each of which are possible blocking tokens. * * @example * blocking: "render" */ blocking?: BlockingToken | string; } /** * Events that fire on link elements (load/error) */ type LinkHttpEvents = Pick; /** * Base properties shared by all link types */ interface LinkBase extends Pick, Blocking, DataKeys { /** * Provides a hint of the relative priority to use when fetching a preloaded resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-fetchpriority */ fetchpriority?: 'high' | 'low' | 'auto'; /** * A string indicating which referrer to use when fetching the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-referrerpolicy */ referrerpolicy?: ReferrerPolicy; } /** * Stylesheet-specific link (fires events) */ interface StylesheetLink extends LinkBase, LinkHttpEvents { rel: 'stylesheet'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This attribute specifies the media that the linked resource applies to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-media */ media?: string; /** * Contains inline metadata — a base64-encoded cryptographic hash of the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-integrity */ integrity?: string; /** * This enumerated attribute indicates whether CORS must be used when fetching the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-crossorigin */ crossorigin?: '' | 'anonymous' | 'use-credentials'; /** * The title attribute has special semantics on the `` element. * When used on a `` it defines a default or an alternate stylesheet. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-title */ title?: string; /** * This attribute is used to define the type of the content linked to. * It can be omitted; `text/css` is assumed. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-type */ type?: 'text/css' | (string & Record); /** * Whether the stylesheet is disabled. */ disabled?: boolean; } /** * Base for preload links (fires events) */ interface PreloadLinkBase extends LinkBase, LinkHttpEvents { rel: 'preload'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This enumerated attribute indicates whether CORS must be used when fetching the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-crossorigin */ crossorigin?: '' | 'anonymous' | 'use-credentials'; /** * Contains inline metadata — a base64-encoded cryptographic hash of the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-integrity */ integrity?: string; /** * This attribute specifies the media that the linked resource applies to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-media */ media?: string; } /** * Base fields for image preload links. */ interface PreloadImageLinkFields extends Omit { as: 'image'; /** * This attribute specifies the URL of the linked resource. * Optional for image preloads when using imagesrcset instead. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href?: string; type?: 'image/webp' | 'image/avif' | 'image/png' | 'image/jpeg' | 'image/gif' | 'image/svg+xml' | (string & Record); /** * For rel="preload" and as="image" only, the imagesizes attribute indicates * to preload the appropriate resource used by an img element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-imagesizes */ imagesizes?: string; /** * For rel="preload" and as="image" only, the imagesrcset attribute indicates * to preload the appropriate resource used by an img element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-imagesrcset */ imagesrcset?: string; } /** * Preload: image (has imagesrcset/imagesizes). * Requires at least one of `href` or `imagesrcset`. */ type PreloadImageLink = (PreloadImageLinkFields & { href: string; }) | (PreloadImageLinkFields & { imagesrcset: string; }); /** * Preload: font */ interface PreloadFontLink extends PreloadLinkBase { as: 'font'; type?: 'font/woff2' | 'font/woff' | 'font/ttf' | 'font/otf' | (string & Record); /** * For fonts, crossorigin is required for CORS. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-crossorigin */ crossorigin: '' | 'anonymous' | 'use-credentials'; } /** * Preload: script */ interface PreloadScriptLink extends PreloadLinkBase { as: 'script'; type?: 'text/javascript' | 'module' | (string & Record); } /** * Preload: style */ interface PreloadStyleLink extends PreloadLinkBase { as: 'style'; type?: 'text/css' | (string & Record); } /** * Preload: other types */ interface PreloadOtherLink extends PreloadLinkBase { as: 'audio' | 'document' | 'embed' | 'fetch' | 'object' | 'track' | 'video' | 'worker'; type?: string; } /** * Combined preload union */ type PreloadLink = PreloadImageLink | PreloadFontLink | PreloadScriptLink | PreloadStyleLink | PreloadOtherLink; /** * Modulepreload-specific link (fires events) */ interface ModulepreloadLink extends LinkBase, LinkHttpEvents { rel: 'modulepreload'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * Contains inline metadata — a base64-encoded cryptographic hash of the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-integrity */ integrity?: string; /** * This enumerated attribute indicates whether CORS must be used when fetching the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-crossorigin */ crossorigin?: '' | 'anonymous' | 'use-credentials'; } /** * Prefetch-specific link */ interface PrefetchLink extends LinkBase { rel: 'prefetch'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This attribute is used when rel="prefetch" to specify the type of content being loaded. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as */ as?: 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'video' | 'worker'; /** * This enumerated attribute indicates whether CORS must be used when fetching the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-crossorigin */ crossorigin?: '' | 'anonymous' | 'use-credentials'; } /** * Icon links may be scoped to a media query, most commonly to serve * separate light and dark variants. */ interface IconLinkBase extends LinkBase { /** * This attribute specifies the media that the linked resource applies to, * for example `(prefers-color-scheme: dark)`. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-media */ media?: string; /** * This enumerated attribute indicates whether CORS must be used when fetching the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-crossorigin */ crossorigin?: '' | 'anonymous' | 'use-credentials'; } /** * Favicon link. * * Prefer `rel: 'icon'` over `'shortcut icon'` — the `shortcut` keyword is non-standard * and was only used by older versions of Internet Explorer. */ interface FaviconLink extends IconLinkBase { rel: 'icon' | 'shortcut icon'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This attribute defines the sizes of the icons for visual media contained in the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-sizes */ sizes?: 'any' | '16x16' | '32x32' | '48x48' | '64x64' | '96x96' | '128x128' | '192x192' | '512x512' | (string & Record); /** * This attribute is used to define the type of the content linked to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-type */ type?: 'image/png' | 'image/svg+xml' | 'image/x-icon' | 'image/gif' | 'image/webp' | (string & Record); } /** * Apple touch icon link */ interface AppleTouchIconLink extends IconLinkBase { rel: 'apple-touch-icon'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This attribute defines the sizes of the icons for visual media contained in the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-sizes */ sizes?: '180x180' | '152x152' | '120x120' | '76x76' | (string & Record); /** * This attribute is used to define the type of the content linked to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-type */ type?: 'image/png' | (string & Record); } /** * Mask icon link (Safari pinned tab). Requires `color`. * * @see https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/pinnedTabs/pinnedTabs.html */ interface MaskIconLink extends IconLinkBase { rel: 'mask-icon'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * The color for the mask icon. Required per spec. * * @see https://html.spec.whatwg.org/multipage/semantics.html#attr-link-color */ color: string; } /** * Manifest link */ interface ManifestLink extends LinkBase { rel: 'manifest'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This attribute is used to define the type of the content linked to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-type */ type?: 'application/manifest+json' | (string & Record); /** * This enumerated attribute indicates whether CORS must be used when fetching the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-crossorigin */ crossorigin?: '' | 'anonymous' | 'use-credentials'; } /** * Canonical link */ interface CanonicalLink extends LinkBase { rel: 'canonical'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; } /** * DNS-prefetch link (no events, minimal props) */ interface DnsPrefetchLink extends LinkBase { rel: 'dns-prefetch'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; } /** * Preconnect link (no events) */ interface PreconnectLink extends LinkBase { rel: 'preconnect'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This enumerated attribute indicates whether CORS must be used when fetching the resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-crossorigin */ crossorigin?: '' | 'anonymous' | 'use-credentials'; } /** * Prerender link */ interface PrerenderLink extends LinkBase { rel: 'prerender'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; } /** * Alternate language link (hreflang translations) */ interface AlternateLanguageLink extends LinkBase { rel: 'alternate'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This attribute indicates the language of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-hreflang */ hreflang: 'x-default' | 'en' | 'en-US' | 'en-GB' | 'de' | 'fr' | 'es' | 'it' | 'ja' | 'ko' | 'nl' | 'pl' | 'pt' | 'pt-BR' | 'ru' | 'zh' | 'zh-CN' | 'zh-TW' | 'ar' | 'hi' | 'id' | 'th' | 'tr' | 'uk' | 'vi' | (string & Record); /** * The title attribute defines the title of the link. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-title */ title?: string; /** * This attribute is used to define the type of the content linked to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-type */ type?: string; /** * This attribute specifies the media that the linked resource applies to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-media */ media?: string; } /** * Alternate feed link (RSS, Atom, JSON Feed) */ interface AlternateFeedLink extends LinkBase { rel: 'alternate'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This attribute is used to define the type of the content linked to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-type */ type: 'application/rss+xml' | 'application/atom+xml' | 'application/json' | (string & Record); /** * The title attribute defines the title of the link. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-title */ title?: string; /** * This attribute indicates the language of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-hreflang */ hreflang?: 'x-default' | 'en' | 'en-US' | 'en-GB' | 'de' | 'fr' | 'es' | 'it' | 'ja' | 'ko' | 'nl' | 'pl' | 'pt' | 'pt-BR' | 'ru' | 'zh' | 'zh-CN' | 'zh-TW' | 'ar' | 'hi' | 'id' | 'th' | 'tr' | 'uk' | 'vi' | (string & Record); } /** * Alternate media link (responsive/device-specific) */ interface AlternateMediaLink extends LinkBase { rel: 'alternate'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; /** * This attribute specifies the media that the linked resource applies to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-media */ media: string; /** * The title attribute defines the title of the link. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-title */ title?: string; /** * This attribute is used to define the type of the content linked to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-type */ type?: string; } /** * Bare alternate link without hreflang, type, or media. * Valid HTML, typically used as a fallback or generic alternate. */ interface BareAlternateLink extends LinkBase { rel: 'alternate'; /** * This attribute specifies the URL of the linked resource. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-href */ href: string; } /** * Author link */ interface AuthorLink extends LinkBase { rel: 'author'; href: string; } /** * License link */ interface LicenseLink extends LinkBase { rel: 'license'; href: string; } /** * Help link */ interface HelpLink extends LinkBase { rel: 'help'; href: string; } /** * Search link */ interface SearchLink extends LinkBase { rel: 'search'; href: string; type?: 'application/opensearchdescription+xml' | (string & Record); title?: string; } /** * Prev/Next navigation links */ interface PrevLink extends LinkBase { rel: 'prev'; href: string; } interface NextLink extends LinkBase { rel: 'next'; href: string; } /** * Pingback link */ interface PingbackLink extends LinkBase { rel: 'pingback'; href: string; } /** * Me link. Identifies the resource as representing the current user * (IndieWeb / rel-me verification, Mastodon profile verification). * * @see https://html.spec.whatwg.org/multipage/links.html#link-type-me */ interface MeLink extends LinkBase { rel: 'me'; href: string; } /** * Privacy policy link. * * @see https://html.spec.whatwg.org/multipage/links.html#link-type-privacy-policy */ interface PrivacyPolicyLink extends LinkBase { rel: 'privacy-policy'; href: string; } /** * Terms of service link. * * @see https://html.spec.whatwg.org/multipage/links.html#link-type-terms-of-service */ interface TermsOfServiceLink extends LinkBase { rel: 'terms-of-service'; href: string; } /** * Expect link. Blocks rendering until a named element is present and ready. * * @see https://html.spec.whatwg.org/multipage/links.html#link-type-expect */ interface ExpectLink extends LinkBase { rel: 'expect'; href: string; blocking?: 'render'; } /** * Webmention endpoint link (IndieWeb). * * @see https://www.w3.org/TR/webmention/ */ interface WebmentionLink extends LinkBase { rel: 'webmention'; href: string; } /** * Compression dictionary link (experimental). * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#compression-dictionary */ interface CompressionDictionaryLink extends LinkBase { rel: 'compression-dictionary'; href: string; } /** * Sitemap link. Points to a sitemap for the site. * * @see https://www.iana.org/assignments/link-relations/link-relations.xhtml */ interface SitemapLink extends LinkBase { rel: 'sitemap'; href: string; type?: 'application/xml' | (string & Record); title?: string; } /** * Apple touch startup image link. Specifies a splash screen image for iOS * when a web app is launched from the home screen. * * @see https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html */ interface AppleTouchStartupImageLink extends LinkBase { rel: 'apple-touch-startup-image'; href: string; media?: string; } /** * AMP HTML link. Points to the AMP version of the current document. * * @see https://amp.dev/documentation/guides-and-tutorials/start/create/prepare_for_discovery/ */ interface AmpHtmlLink extends LinkBase { rel: 'amphtml'; href: string; } /** * WebSub hub link. Points to a WebSub hub for real-time content distribution. * * @see https://www.w3.org/TR/websub/ */ interface HubLink extends LinkBase { rel: 'hub'; href: string; } /** * Alternate stylesheet link. User-selectable alternate stylesheet. * Requires a `title` to appear in the browser's stylesheet picker. * * @see https://html.spec.whatwg.org/multipage/semantics.html#rel-alternate-stylesheet */ interface AlternateStylesheetLink extends LinkBase, LinkHttpEvents { rel: 'alternate stylesheet'; href: string; title: string; media?: string; crossorigin?: '' | 'anonymous' | 'use-credentials'; integrity?: string; type?: 'text/css' | (string & Record); disabled?: boolean; } /** * Discriminated union of all link types. * * Each named `rel` value maps to a specific interface that enforces per-`rel` required * attributes. For example, `rel="preload"` requires the `as` attribute (see {@link PreloadLink}), * and `rel="mask-icon"` requires `color` (see {@link MaskIconLink}). * * For non-standard `rel` values not covered by {@link KnownLinkRel}, use {@link defineLink}: * ```ts * import { defineLink } from 'unhead' * useHead({ link: [defineLink({ rel: 'openid2.provider', href: 'https://...' })] }) * ``` * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel */ type Link = StylesheetLink | AlternateStylesheetLink | PreloadLink | ModulepreloadLink | PrefetchLink | FaviconLink | AppleTouchIconLink | MaskIconLink | ManifestLink | CanonicalLink | DnsPrefetchLink | PreconnectLink | PrerenderLink | AlternateLanguageLink | AlternateFeedLink | AlternateMediaLink | BareAlternateLink | AuthorLink | LicenseLink | HelpLink | SearchLink | PrevLink | NextLink | PingbackLink | MeLink | WebmentionLink | PrivacyPolicyLink | TermsOfServiceLink | ExpectLink | CompressionDictionaryLink | SitemapLink | AppleTouchStartupImageLink | AmpHtmlLink | HubLink; /** * Known meta name values */ type MetaNames = 'apple-itunes-app' | 'apple-mobile-web-app-capable' | 'apple-mobile-web-app-status-bar-style' | 'apple-mobile-web-app-title' | 'application-name' | 'author' | 'color-scheme' | 'creator' | 'description' | 'fb:app_id' | 'fediverse:creator' | 'format-detection' | 'generator' | 'google-site-verification' | 'google' | 'googlebot' | 'keywords' | 'mobile-web-app-capable' | 'msapplication-Config' | 'msapplication-TileColor' | 'msapplication-TileImage' | 'publisher' | 'rating' | 'referrer' | 'robots' | 'theme-color' | 'twitter:app:id:googleplay' | 'twitter:app:id:ipad' | 'twitter:app:id:iphone' | 'twitter:app:name:googleplay' | 'twitter:app:name:ipad' | 'twitter:app:name:iphone' | 'twitter:app:url:googleplay' | 'twitter:app:url:ipad' | 'twitter:app:url:iphone' | 'twitter:card' | 'twitter:creator:id' | 'twitter:creator' | 'twitter:data:1' | 'twitter:data:2' | 'twitter:description' | 'twitter:image:alt' | 'twitter:image' | 'twitter:label:1' | 'twitter:label:2' | 'twitter:player:height' | 'twitter:player:stream' | 'twitter:player:width' | 'twitter:player' | 'twitter:site:id' | 'twitter:site' | 'twitter:title' | 'viewport'; /** * Known meta property values (OpenGraph, etc.) */ type MetaProperties = 'article:author' | 'article:expiration_time' | 'article:modified_time' | 'article:published_time' | 'article:section' | 'article:tag' | 'book:author' | 'book:isbn' | 'book:release_date' | 'book:tag' | 'fb:app:id' | 'og:audio:secure_url' | 'og:audio:type' | 'og:audio:url' | 'og:description' | 'og:determiner' | 'og:image:height' | 'og:image:secure_url' | 'og:image:type' | 'og:image:url' | 'og:image:width' | 'og:image' | 'og:locale:alternate' | 'og:locale' | 'og:site:name' | 'og:title' | 'og:type' | 'og:url' | 'og:video:height' | 'og:video:secure_url' | 'og:video:type' | 'og:video:url' | 'og:video:width' | 'og:video' | 'payment:amount' | 'payment:currency' | 'payment:description' | 'payment:expires_at' | 'payment:id' | 'payment:status' | 'payment:success_url' | 'profile:first_name' | 'profile:gender' | 'profile:last_name' | 'profile:username'; /** * Base properties shared by all meta types */ interface MetaBase extends Pick, DataKeys { /** * A valid media query list that can be included to set the media the metadata applies to. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color */ media?: '(prefers-color-scheme: light)' | '(prefers-color-scheme: dark)' | (string & Record); } /** * Name-based meta (description, viewport, robots, etc.) * Mutual exclusion: no property, no http-equiv, no charset */ interface NameMeta extends MetaBase { /** * The name and content attributes can be used together to provide document metadata * in terms of name-value pairs. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-name */ 'name': MetaNames | (string & Record); /** * This attribute contains the value for the name attribute. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-content */ 'content': string | number; 'property'?: never; 'http-equiv'?: never; 'charset'?: never; } /** * Property-based meta (OpenGraph, etc.) * Mutual exclusion: no name, no http-equiv, no charset */ interface PropertyMeta extends MetaBase { /** * The property attribute is used to define a property associated with the content attribute. * Mainly used for og and twitter meta tags. */ 'property': MetaProperties | (string & Record); /** * This attribute contains the value for the property attribute. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-content */ 'content': string | number; 'name'?: never; 'http-equiv'?: never; 'charset'?: never; } /** * HTTP-equiv meta * Mutual exclusion: no name, no property, no charset */ interface HttpEquivMeta extends MetaBase { /** * Defines a pragma directive. The attribute is named http-equiv(alent) because all * the allowed values are names of particular HTTP headers. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-http-equiv */ 'http-equiv': 'content-security-policy' | 'content-type' | 'default-style' | 'x-ua-compatible' | 'refresh' | 'accept-ch' | 'origin-trial' | (string & Record); /** * This attribute contains the value for the http-equiv attribute. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-content */ 'content': string | number; 'name'?: never; 'property'?: never; 'charset'?: never; } /** * Charset meta (standalone, no content) * Mutual exclusion: no name, no property, no http-equiv, no content */ interface CharsetMeta extends MetaBase { /** * This attribute declares the document's character encoding. * If the attribute is present, its value must be an ASCII case-insensitive match for the string "utf-8". * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-charset */ 'charset': 'utf-8' | (string & Record); 'name'?: never; 'property'?: never; 'http-equiv'?: never; 'content'?: never; } /** * Content for noscript elements - either textContent or innerHTML, not both */ type NoscriptContent = { /** * Sets the textContent of an element. Safer for XSS. */ textContent?: string; innerHTML?: never; } | { textContent?: never; /** * Text content of the tag. * * Warning: This is not safe for XSS. Do not use this with user input, use `textContent` instead. */ innerHTML?: string; }; type Noscript = Pick & NoscriptContent; /** * A JSON speculation rule set. * * @see https://html.spec.whatwg.org/multipage/speculative-loading.html#speculation-rules */ interface SpeculationRules { /** Identifies speculative requests through the `Sec-Speculation-Tags` header. */ tag?: string | null; prefetch?: readonly SpeculationRule[]; prerender?: readonly SpeculationRule[]; } type SpeculationRuleEagerness = 'immediate' | 'eager' | 'moderate' | 'conservative' | (string & Record); type SpeculationRuleRequirement = 'anonymous-client-ip-when-cross-origin'; interface SpeculationRuleBase { /** A hint about when the browser should consider the speculative load. */ eagerness?: SpeculationRuleEagerness; /** The referrer policy for the speculative request. */ referrer_policy?: ReferrerPolicy; /** Identifies this rule through the `Sec-Speculation-Tags` header. */ tag?: string | null; /** Required browser capabilities for executing the rule. */ requires?: readonly SpeculationRuleRequirement[]; /** Expected `No-Vary-Search` response header value. */ expects_no_vary_search?: string; /** The browsing context in which a prerendered page is expected to open. */ target_hint?: '_blank' | '_self' | '_parent' | '_top' | (string & Record); } /** An explicit list of URLs to speculate. */ type SpeculationRuleList = SpeculationRuleBase & { source?: 'list'; urls: readonly string[]; where?: never; /** Selects the base URL used to resolve `urls`. */ relative_to?: 'ruleset' | 'document'; }; /** A rule which selects links from the current document. */ type SpeculationRuleDocument = SpeculationRuleBase & { urls?: never; relative_to?: never; } & ({ source: 'document'; where?: SpeculationRuleWhere; } | { source?: never; where: SpeculationRuleWhere; }); type SpeculationRule = SpeculationRuleList | SpeculationRuleDocument; /** The object form accepted by `href_matches`, equivalent to `URLPatternInit`. */ interface SpeculationRuleUrlPattern { baseURL?: string; protocol?: string; username?: string; password?: string; hostname?: string; port?: string; pathname?: string; search?: string; hash?: string; } type SpeculationRuleUrlPatternInput = string | SpeculationRuleUrlPattern; /** * A recursive document rule predicate. Exactly one predicate operator is valid * at each level; only `href_matches` also accepts `relative_to`. */ type SpeculationRuleWhere = { and: readonly SpeculationRuleWhere[]; or?: never; not?: never; href_matches?: never; selector_matches?: never; relative_to?: never; } | { and?: never; or: readonly SpeculationRuleWhere[]; not?: never; href_matches?: never; selector_matches?: never; relative_to?: never; } | { and?: never; or?: never; not: SpeculationRuleWhere; href_matches?: never; selector_matches?: never; relative_to?: never; } | { and?: never; or?: never; not?: never; href_matches: SpeculationRuleUrlPatternInput | readonly SpeculationRuleUrlPatternInput[]; selector_matches?: never; relative_to?: 'ruleset' | 'document'; } | { and?: never; or?: never; not?: never; href_matches?: never; selector_matches: string | readonly string[]; relative_to?: never; }; /** * Events that fire on script elements (load/error) */ type ScriptHttpEvents = Pick; /** * Base properties shared by all script types */ interface ScriptBase extends Pick, Blocking, DataKeys { /** * Provides a hint of the relative priority to use when fetching an external script. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-fetchpriority */ fetchpriority?: 'high' | 'low' | 'auto'; /** * Indicates which referrer to send when fetching the script, or resources fetched by the script. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-referrerpolicy */ referrerpolicy?: ReferrerPolicy; } /** * Props that are invalid on non-loadable script types (data scripts, inline scripts) */ interface NoLoadableScriptProps { src?: never; async?: never; defer?: never; integrity?: never; crossorigin?: never; nomodule?: never; } /** * Content for data scripts — requires exactly one of `textContent` or * `innerHTML`. Data scripts (JSON-LD, speculation rules, application/json) must * carry inline content; an empty payload is invalid. */ type DataScriptTextContent> = { /** * Sets the textContent of an element. Safer for XSS. * Can be a string or an object that will be serialized to JSON. */ textContent: T; innerHTML?: never; } | { textContent?: never; /** * Sets the innerHTML of an element. * Can be a string or an object that will be serialized to JSON. */ innerHTML: T; }; /** * External JavaScript (fires events) */ interface ExternalScript extends ScriptBase, ScriptHttpEvents { /** * This attribute specifies the URI of an external script. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-src */ src: string; /** * This attribute indicates the type of script represented. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type */ type?: '' | 'text/javascript'; /** * For classic scripts, if the async attribute is present, * then the classic script will be fetched in parallel to parsing and evaluated as soon as it is available. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-async */ async?: Booleanable; /** * This Boolean attribute is set to indicate to a browser that the script is meant to be executed after the document * has been parsed, but before firing DOMContentLoaded. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-defer */ defer?: Booleanable; /** * Normal script elements pass minimal information to the window.onerror * for scripts which do not pass the standard CORS checks. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-crossorigin */ crossorigin?: '' | 'anonymous' | 'use-credentials'; /** * This attribute contains inline metadata that a user agent can use to verify * that a fetched resource has been delivered free of unexpected manipulation. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-integrity */ integrity?: string; /** * This Boolean attribute is set to indicate that the script should not be executed in browsers * that support ES modules. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-nomodule */ nomodule?: Booleanable; /** Inline content is ignored when `src` is present. */ textContent?: never; /** Inline content is ignored when `src` is present. */ innerHTML?: never; } /** * ES Module script (fires events) */ interface ModuleScript extends ScriptBase, ScriptHttpEvents { /** * This attribute specifies the URI of an external script. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-src */ src: string; /** * This attribute indicates the type of script represented. * Required discriminant for module scripts. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type */ type: 'module'; /** * For module scripts, if the async attribute is present then the scripts and all their dependencies * will be executed in the defer queue. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-async */ async?: Booleanable; /** * Normal script elements pass minimal information to the window.onerror * for scripts which do not pass the standard CORS checks. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-crossorigin */ crossorigin?: '' | 'anonymous' | 'use-credentials'; /** * This attribute contains inline metadata that a user agent can use to verify * that a fetched resource has been delivered free of unexpected manipulation. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-integrity */ integrity?: string; /** Inline content is ignored when `src` is present. */ textContent?: never; /** Inline content is ignored when `src` is present. */ innerHTML?: never; } /** * Inline JavaScript (no events, no src). * Requires either `textContent` (recommended, XSS-safe) or `innerHTML`. */ type InlineScript = ScriptBase & NoLoadableScriptProps & { /** * This attribute indicates the type of script represented. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type */ type?: '' | 'text/javascript'; } & ({ /** Sets the textContent of an element. Safer for XSS. */ textContent: string; innerHTML?: never; } | { textContent?: never; /** * Sets the innerHTML of an element. * * Warning: not safe for XSS. Prefer `textContent` for inline scripts. */ innerHTML: string | Record; }); /** * Inline ES Module script (no src). * Requires either `textContent` (recommended, XSS-safe) or `innerHTML`. */ type InlineModuleScript = ScriptBase & NoLoadableScriptProps & { /** * This attribute indicates the type of script represented. * Required discriminant for module scripts. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type */ type: 'module'; } & ({ /** Sets the textContent of an element. Safer for XSS. */ textContent: string; innerHTML?: never; } | { textContent?: never; /** * Sets the innerHTML of an element. * * Warning: not safe for XSS. Prefer `textContent` for inline scripts. */ innerHTML: string; }); /** * JSON-LD structured data (uses textContent for XSS safety) * Note: For full schema.org typing, use @unhead/schema-org with useSchemaOrg() */ type JsonLdScript = ScriptBase & NoLoadableScriptProps & DataScriptTextContent & { /** * This attribute indicates the type of script represented. * Required discriminant for JSON-LD scripts. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type */ type: 'application/ld+json'; }; /** * Speculation Rules (uses textContent for safety) */ type SpeculationRulesScript = ScriptBase & NoLoadableScriptProps & DataScriptTextContent & { /** * This attribute indicates the type of script represented. * Required discriminant for speculation rules scripts. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type */ type: 'speculationrules'; }; /** * Import map configuration */ interface ImportMapConfig { imports: Record; scopes?: Record>; } /** * Import map. Requires either `textContent` (recommended) or `innerHTML`. */ type ImportMapScript = ScriptBase & NoLoadableScriptProps & { /** * This attribute indicates the type of script represented. * Required discriminant for import map scripts. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type */ type: 'importmap'; } & ({ /** Import map content as a string or ImportMapConfig object (auto-serialized). */ textContent: string | ImportMapConfig; innerHTML?: never; } | { textContent?: never; /** Import map content as a string or ImportMapConfig object (auto-serialized). */ innerHTML: string | ImportMapConfig; }); /** * Application JSON script (generic JSON data) */ type ApplicationJsonScript = ScriptBase & NoLoadableScriptProps & DataScriptTextContent & { /** * This attribute indicates the type of script represented. * Required discriminant for JSON scripts. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type */ type: 'application/json'; }; /** * Discriminated union of all script types. * * Each `type` value maps to a specific interface that enforces per-type constraints. * For example, inline scripts require `textContent` and forbid `src`/`async`/`defer`. * * For custom or non-standard `type` values, use {@link defineScript}: * ```ts * import { defineScript } from 'unhead' * useHead({ script: [defineScript({ type: 'text/plain', textContent: '...' })] }) * ``` */ type Script = ExternalScript | ModuleScript | InlineScript | InlineModuleScript | JsonLdScript | SpeculationRulesScript | ImportMapScript | ApplicationJsonScript; interface Style extends Pick, Blocking { /** * This attribute defines which media the style should be applied to. * Its value is a media query, which defaults to all if the attribute is missing. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style#attr-media */ media?: string; /** * A cryptographic nonce (number used once) used to allow inline styles in a style-src Content-Security-Policy. * The server must generate a unique nonce value each time it transmits a policy. * It is critical to provide a nonce that cannot be guessed as bypassing a resource's policy is otherwise trivial. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style#attr-nonce */ nonce?: string; /** * This attribute specifies alternative style sheet sets. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style#attr-title */ title?: string; } interface TemplateParamsAugmentations { } interface SchemaAugmentations { title: TagPriority; titleTemplate: TagPriority; base: ResolvesDuplicates & TagPriority; htmlAttrs: ResolvesDuplicates & TagPriority; bodyAttrs: ResolvesDuplicates & TagPriority; link: TagPriority & TagPosition & ResolvesDuplicates & ProcessesTemplateParams; meta: TagPriority & ResolvesDuplicates & ProcessesTemplateParams; style: TagPriority & TagPosition & StringInnerContent & ResolvesDuplicates & ProcessesTemplateParams; script: TagPriority & TagPosition & InnerContent & ResolvesDuplicates & ProcessesTemplateParams; noscript: TagPriority & TagPosition & StringInnerContent & ResolvesDuplicates & ProcessesTemplateParams; } type MaybeArray = T | T[]; interface UnheadBodyAttributesWithoutEvents extends Omit { /** * The class global attribute is a space-separated list of the case-sensitive classes of the element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class */ class?: MaybeArray> | Record>; /** * The style attribute contains CSS styling declarations to be applied to the element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/style */ style?: MaybeArray> | Record>; } interface UnheadHtmlAttributes extends Omit { /** * The class global attribute is a space-separated list of the case-sensitive classes of the element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class */ class?: MaybeArray> | Record>; /** * The style attribute contains CSS styling declarations to be applied to the element. * * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/style */ style?: MaybeArray> | Record>; } /** * Unhead meta with support for array content values. * Content is required (use `null` explicitly to remove a meta tag). */ type UnheadMeta = (Omit & { content: MaybeArray | null; }) | (Omit & { content: MaybeArray | null; }) | (Omit & { content: MaybeArray | null; }) | CharsetMeta; type MaybeEventFnHandlers = { [key in keyof T]?: T[key] | ((e: Event) => void); }; type ResolvableTitle = ResolvableValue | ResolvableProperties<({ textContent: string; } & SchemaAugmentations['title'])>; type ResolvableTitleTemplate = string | ((title?: string) => string | null) | null | ({ textContent: string | ((title?: string) => string | null); } & SchemaAugmentations['titleTemplate']); type ResolvableBase = DistributeResolvable; type DistributeResolvable = T extends any ? ResolvableProperties : never; type DistributeResolvableWithEvents = T extends any ? T extends Events ? ResolvableProperties & Aug> & MaybeEventFnHandlers : ResolvableProperties : never; type ResolvableLink = DistributeResolvableWithEvents; type ResolvableMeta = DistributeResolvable; type ResolvableStyle = ResolvableProperties