UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

99 lines 4.85 kB
export default TinyHtmlScript; /** * TinyHtmlScript is a helper class for creating and managing <script> elements. * Supports both inline and external scripts, with attributes for async, defer, modules, etc. * * @extends TinyHtmlTemplate<HTMLScriptElement> */ declare class TinyHtmlScript extends TinyHtmlTemplate<HTMLScriptElement> { /** * Creates a new TinyHtmlScript instance. * @param {Object} config - Configuration object. * @param {string} [config.src] - URI of an external script. * @param {string} [config.type] - The type of script (e.g., "module", "importmap", "speculationrules", or JS MIME type). * @param {boolean} [config.async=false] - Whether the script should be executed asynchronously (requires src). * @param {boolean} [config.defer=false] - Whether the script should be deferred until after parsing (requires src). * @param {string|string[]|Set<string>} [config.tags=[]] - Initial CSS classes. * @param {string} [config.mainClass=""] - Main CSS class. * @param {string} [config.content=""] - Inline script content (ignored if src is provided). * @param {string|string[]} [config.blocking] - Space-separated list of blocking tokens (currently only "render"). * @param {"anonymous" | "use-credentials"} [config.crossorigin] - CORS setting ("anonymous" or "use-credentials"). * @param {"auto"|"high"|"low"} [config.fetchpriority="auto"] - Fetch priority. * @param {string} [config.integrity] - Subresource integrity hash (only valid with src). * @param {boolean} [config.nomodule=false] - Whether to prevent execution in browsers supporting modules. * @param {string} [config.nonce] - Cryptographic nonce for CSP. * @param {string} [config.referrerpolicy] - Referrer policy. * @param {boolean|string|string[]} [config.attributionsrc] - Boolean or list of URLs for attribution reporting. */ constructor({ src, type, async, defer, tags, mainClass, content, blocking, crossorigin, fetchpriority, integrity, nomodule, nonce, referrerpolicy, attributionsrc, }?: { src?: string | undefined; type?: string | undefined; async?: boolean | undefined; defer?: boolean | undefined; tags?: string | string[] | Set<string> | undefined; mainClass?: string | undefined; content?: string | undefined; blocking?: string | string[] | undefined; crossorigin?: "anonymous" | "use-credentials" | undefined; fetchpriority?: "auto" | "high" | "low" | undefined; integrity?: string | undefined; nomodule?: boolean | undefined; nonce?: string | undefined; referrerpolicy?: string | undefined; attributionsrc?: string | boolean | string[] | undefined; }); /** @param {string} src */ set src(src: string); /** @returns {string|null} */ get src(): string | null; /** @param {string} type */ set type(type: string); /** @returns {string|null} */ get type(): string | null; /** @param {boolean} async */ set async(async: boolean); /** @returns {boolean} */ get async(): boolean; /** @param {boolean} defer */ set defer(defer: boolean); /** @returns {boolean} */ get defer(): boolean; /** @param {string|string[]} blocking */ set blocking(blocking: string | string[]); /** @returns {string[]|null} */ get blocking(): string[] | null; /** @param {"anonymous"|"use-credentials"} crossorigin */ set crossorigin(crossorigin: "anonymous" | "use-credentials"); /** @returns {string|null} */ get crossorigin(): string | null; /** @param {"auto"|"high"|"low"} fetchpriority */ set fetchpriority(fetchpriority: "auto" | "high" | "low"); /** @returns {string|null} */ get fetchpriority(): string | null; /** @param {string} integrity */ set integrity(integrity: string); /** @returns {string|null} */ get integrity(): string | null; /** @param {boolean} nomodule */ set nomodule(nomodule: boolean); /** @returns {boolean} */ get nomodule(): boolean; /** @param {string} nonce */ set nonce(nonce: string); /** @returns {string|null} */ get nonce(): string | null; /** @param {string} referrerpolicy */ set referrerpolicy(referrerpolicy: string); /** @returns {string|null} */ get referrerpolicy(): string | null; /** @param {boolean|string|string[]} attributionsrc */ set attributionsrc(attributionsrc: boolean | string | string[]); /** @returns {boolean|string[]|null} */ get attributionsrc(): boolean | string[] | null; /** @param {string} code */ set content(code: string); /** @returns {string|null} */ get content(): string | null; } import TinyHtmlTemplate from './TinyHtmlTemplate.mjs'; //# sourceMappingURL=TinyHtmlScript.d.mts.map