@unhead/schema
Advanced tools
Comparing version 1.8.14 to 1.8.15
@@ -16,30 +16,2 @@ import { MaybePromiseProps, MergeHead, BaseBodyAttributes, HtmlAttributes as HtmlAttributes$1, Meta as Meta$1, Stringable, Merge, Base as Base$1, DefinedValueOrEmptyObject, LinkBase, HttpEventAttributes, DataKeys, Style as Style$1, ScriptBase, Noscript as Noscript$1, BodyEvents, MetaFlatInput } from 'zhead'; | ||
} | ||
type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error' | 'removed'; | ||
interface ScriptInstance<T> { | ||
id: string; | ||
entry?: ActiveHeadEntry<any>; | ||
loaded: boolean; | ||
status: UseScriptStatus; | ||
load: () => Promise<T>; | ||
waitForLoad: () => Promise<T>; | ||
remove: () => boolean; | ||
} | ||
interface UseScriptOptions<T> extends Omit<HeadEntryOptions, 'transform'> { | ||
/** | ||
* Should the `dns-prefetch` tag be skipped. | ||
* | ||
* Useful if loading the script through a local proxy. | ||
*/ | ||
skipEarlyConnections?: boolean; | ||
use?: () => T | undefined | null; | ||
stub?: ((ctx: { | ||
script: ScriptInstance<T>; | ||
fn: string | symbol; | ||
}) => any); | ||
transform?: (script: UseScriptInput) => Promise<UseScriptInput> | UseScriptInput; | ||
trigger?: 'idle' | 'manual' | Promise<void>; | ||
} | ||
type UseScriptInput = Omit<Script, 'src'> & { | ||
src: string; | ||
}; | ||
interface EntryResolveCtx<T> { | ||
@@ -99,3 +71,3 @@ tags: HeadTag[]; | ||
'script:transform': (ctx: { | ||
script: UseScriptInput; | ||
script: UseScriptResolvedInput; | ||
}) => HookResult; | ||
@@ -430,10 +402,10 @@ 'script:updated': (ctx: { | ||
} & SchemaAugmentations['titleTemplate']); | ||
type Base<E extends EntryAugmentation = {}> = Partial<Merge<SchemaAugmentations['base'], MaybePromiseProps<Base$1>>> & DefinedValueOrEmptyObject<E>; | ||
type Link<E extends EntryAugmentation = {}> = MaybePromiseProps<LinkBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['link'] & DefinedValueOrEmptyObject<E>; | ||
type Meta<E extends EntryAugmentation = {}> = MaybePromiseProps<BaseMeta> & DataKeys & SchemaAugmentations['meta'] & DefinedValueOrEmptyObject<E>; | ||
type Style<E extends EntryAugmentation = {}> = MaybePromiseProps<Style$1> & DataKeys & SchemaAugmentations['style'] & DefinedValueOrEmptyObject<E>; | ||
type Script<E extends EntryAugmentation = {}> = MaybePromiseProps<ScriptBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['script'] & DefinedValueOrEmptyObject<E>; | ||
type Noscript<E extends EntryAugmentation = {}> = MaybePromiseProps<Noscript$1> & DataKeys & SchemaAugmentations['noscript'] & DefinedValueOrEmptyObject<E>; | ||
type HtmlAttributes<E extends EntryAugmentation = {}> = MaybePromiseProps<HtmlAttr> & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>; | ||
type BodyAttributes<E extends EntryAugmentation = {}> = MaybePromiseProps<BodyAttr> & MaybeFunctionEntries<BodyEvents> & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>; | ||
type Base<E extends EntryAugmentation = Record<string, any>> = Partial<Merge<SchemaAugmentations['base'], MaybePromiseProps<Base$1>>> & DefinedValueOrEmptyObject<E>; | ||
type Link<E extends EntryAugmentation = Record<string, any>> = MaybePromiseProps<LinkBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['link'] & DefinedValueOrEmptyObject<E>; | ||
type Meta<E extends EntryAugmentation = Record<string, any>> = MaybePromiseProps<BaseMeta> & DataKeys & SchemaAugmentations['meta'] & DefinedValueOrEmptyObject<E>; | ||
type Style<E extends EntryAugmentation = Record<string, any>> = MaybePromiseProps<Style$1> & DataKeys & SchemaAugmentations['style'] & DefinedValueOrEmptyObject<E>; | ||
type Script<E extends EntryAugmentation = Record<string, any>> = MaybePromiseProps<ScriptBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['script'] & DefinedValueOrEmptyObject<E>; | ||
type Noscript<E extends EntryAugmentation = Record<string, any>> = MaybePromiseProps<Noscript$1> & DataKeys & SchemaAugmentations['noscript'] & DefinedValueOrEmptyObject<E>; | ||
type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = MaybePromiseProps<HtmlAttr> & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>; | ||
type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = MaybePromiseProps<BodyAttr> & MaybeFunctionEntries<BodyEvents> & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>; | ||
interface HeadUtils { | ||
@@ -538,2 +510,52 @@ /** | ||
export type { ActiveHeadEntry, Base, BaseBodyAttr, BaseHtmlAttr, BaseMeta, BodyAttr, BodyAttributes, CreateHeadOptions, DomBeforeRenderCtx, DomRenderTagContext, DomState, EntryAugmentation, EntryResolveCtx, HasTemplateParams, Head, HeadEntry, HeadEntryOptions, HeadHooks, HeadPlugin, HeadPluginInput, HeadPluginOptions, HeadSafe, HeadTag, HeadTagKeys, HeadUtils, HookResult, HtmlAttr, HtmlAttributes, InnerContent, InnerContentVal, Link, MaybeArray, MaybeFunctionEntries, Meta, Never, Noscript, ProcessesTemplateParams, RenderSSRHeadOptions, ResolvesDuplicates, RuntimeMode, SSRHeadPayload, SSRRenderContext, SafeBodyAttr, SafeHtmlAttr, SafeLink, SafeMeta, SafeNoscript, SafeScript, SchemaAugmentations, Script, ScriptInstance, ShouldRenderContext, SideEffectsRecord, Style, TagKey, TagPosition, TagPriority, TagUserProperties, TemplateParams, Title, TitleTemplate, Unhead, UseScriptInput, UseScriptOptions, UseScriptStatus, UseSeoMetaInput, UserAttributesConfig, UserTagConfigWithoutInnerContent, ValidTagPositions }; | ||
type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error' | 'removed'; | ||
/** | ||
* Either a string source for the script or full script properties. | ||
*/ | ||
type UseScriptInput = string | (Omit<Script, 'src'> & { | ||
src: string; | ||
}); | ||
type UseScriptResolvedInput = Omit<Script, 'src'> & { | ||
src: string; | ||
}; | ||
interface ScriptInstance<T> { | ||
id: string; | ||
entry?: ActiveHeadEntry<any>; | ||
loaded: boolean; | ||
status: UseScriptStatus; | ||
load: () => Promise<T>; | ||
waitForLoad: () => Promise<T>; | ||
remove: () => boolean; | ||
} | ||
interface UseScriptOptions<T> extends Omit<HeadEntryOptions, 'transform'> { | ||
/** | ||
* Should the `dns-prefetch` tag be skipped. | ||
* | ||
* Useful if loading the script through a local proxy. | ||
*/ | ||
skipEarlyConnections?: boolean; | ||
/** | ||
* Resolve the script instance from the window. | ||
*/ | ||
use?: () => T | undefined | null; | ||
/** | ||
* Stub the script instance. Useful for SSR or testing. | ||
*/ | ||
stub?: ((ctx: { | ||
script: ScriptInstance<T>; | ||
fn: string | symbol; | ||
}) => any); | ||
/** | ||
* Transform the script instance before it's resolved. | ||
*/ | ||
transform?: (script: UseScriptResolvedInput) => Promise<UseScriptResolvedInput> | UseScriptResolvedInput; | ||
/** | ||
* The trigger to load the script: | ||
* - `idle` - Load the script when the browser is idle. | ||
* - `manual` - Load the script manually by calling `$script.load()` or `$script.waitForLoad()`. | ||
* - `Promise` - Load the script when the promise resolves. | ||
*/ | ||
trigger?: 'idle' | 'manual' | Promise<void>; | ||
} | ||
export type { ActiveHeadEntry, Base, BaseBodyAttr, BaseHtmlAttr, BaseMeta, BodyAttr, BodyAttributes, CreateHeadOptions, DomBeforeRenderCtx, DomRenderTagContext, DomState, EntryAugmentation, EntryResolveCtx, HasTemplateParams, Head, HeadEntry, HeadEntryOptions, HeadHooks, HeadPlugin, HeadPluginInput, HeadPluginOptions, HeadSafe, HeadTag, HeadTagKeys, HeadUtils, HookResult, HtmlAttr, HtmlAttributes, InnerContent, InnerContentVal, Link, MaybeArray, MaybeFunctionEntries, Meta, Never, Noscript, ProcessesTemplateParams, RenderSSRHeadOptions, ResolvesDuplicates, RuntimeMode, SSRHeadPayload, SSRRenderContext, SafeBodyAttr, SafeHtmlAttr, SafeLink, SafeMeta, SafeNoscript, SafeScript, SchemaAugmentations, Script, ScriptInstance, ShouldRenderContext, SideEffectsRecord, Style, TagKey, TagPosition, TagPriority, TagUserProperties, TemplateParams, Title, TitleTemplate, Unhead, UseScriptInput, UseScriptOptions, UseScriptResolvedInput, UseScriptStatus, UseSeoMetaInput, UserAttributesConfig, UserTagConfigWithoutInnerContent, ValidTagPositions }; |
{ | ||
"name": "@unhead/schema", | ||
"type": "module", | ||
"version": "1.8.14", | ||
"version": "1.8.15", | ||
"author": "Harlan Wilton <harlan@harlanzw.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
66873
561