@unhead/schema 1.10.0-beta.1 → 1.10.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -521,7 +521,7 @@ type UseScriptResolvedInput = Omit<Script, 'src'> & {
521
521
  };
522
522
  type BaseScriptApi = Record<symbol | string, any>;
523
523
  type AsAsyncFunctionValues<T extends BaseScriptApi> = {
524
- [key in keyof T]: T[key] extends any[] ? T[key] : T[key] extends object ? AsAsyncFunctionValues<T[key]> : T[key] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : () => Promise<T[key]>;
524
+ [key in keyof T]: T[key] extends any[] ? T[key] : T[key] extends (...args: infer A) => infer R ? (...args: A) => R extends Promise<any> ? R : Promise<R> : T[key] extends Record<any, any> ? AsAsyncFunctionValues<T[key]> : never;
525
525
  };
526
526
  interface ScriptInstance<T extends BaseScriptApi> {
527
527
  proxy: AsAsyncFunctionValues<T>;
@@ -531,8 +531,20 @@ interface ScriptInstance<T extends BaseScriptApi> {
531
531
  entry?: ActiveHeadEntry<any>;
532
532
  load: () => Promise<T>;
533
533
  remove: () => boolean;
534
+ onLoaded: (fn: (instance: T) => void | Promise<void>) => void;
535
+ onError: (fn: (err?: Error) => void | Promise<void>) => void;
536
+ /**
537
+ * @internal
538
+ */
539
+ _cbs: {
540
+ loaded: ((instance: T) => void | Promise<void>)[];
541
+ error: ((err?: Error) => void | Promise<void>)[];
542
+ };
534
543
  }
535
- interface UseScriptOptions<T extends BaseScriptApi> extends HeadEntryOptions {
544
+ type UseFunctionType<T, U> = T extends {
545
+ use: infer V;
546
+ } ? V extends () => infer W ? W : U : U;
547
+ interface UseScriptOptions<T extends BaseScriptApi = {}, U = {}> extends HeadEntryOptions {
536
548
  /**
537
549
  * Resolve the script instance from the window.
538
550
  */
@@ -565,4 +577,4 @@ interface UseScriptOptions<T extends BaseScriptApi> extends HeadEntryOptions {
565
577
  beforeInit?: () => void;
566
578
  }
567
579
 
568
- export type { ActiveHeadEntry, AsAsyncFunctionValues, 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, MaybePromiseOrFalseProps, 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 };
580
+ export type { ActiveHeadEntry, AsAsyncFunctionValues, 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, MaybePromiseOrFalseProps, 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, UseFunctionType, UseScriptInput, UseScriptOptions, UseScriptResolvedInput, UseScriptStatus, UseSeoMetaInput, UserAttributesConfig, UserTagConfigWithoutInnerContent, ValidTagPositions };
package/dist/index.d.mts CHANGED
@@ -521,7 +521,7 @@ type UseScriptResolvedInput = Omit<Script, 'src'> & {
521
521
  };
522
522
  type BaseScriptApi = Record<symbol | string, any>;
523
523
  type AsAsyncFunctionValues<T extends BaseScriptApi> = {
524
- [key in keyof T]: T[key] extends any[] ? T[key] : T[key] extends object ? AsAsyncFunctionValues<T[key]> : T[key] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : () => Promise<T[key]>;
524
+ [key in keyof T]: T[key] extends any[] ? T[key] : T[key] extends (...args: infer A) => infer R ? (...args: A) => R extends Promise<any> ? R : Promise<R> : T[key] extends Record<any, any> ? AsAsyncFunctionValues<T[key]> : never;
525
525
  };
526
526
  interface ScriptInstance<T extends BaseScriptApi> {
527
527
  proxy: AsAsyncFunctionValues<T>;
@@ -531,8 +531,20 @@ interface ScriptInstance<T extends BaseScriptApi> {
531
531
  entry?: ActiveHeadEntry<any>;
532
532
  load: () => Promise<T>;
533
533
  remove: () => boolean;
534
+ onLoaded: (fn: (instance: T) => void | Promise<void>) => void;
535
+ onError: (fn: (err?: Error) => void | Promise<void>) => void;
536
+ /**
537
+ * @internal
538
+ */
539
+ _cbs: {
540
+ loaded: ((instance: T) => void | Promise<void>)[];
541
+ error: ((err?: Error) => void | Promise<void>)[];
542
+ };
534
543
  }
535
- interface UseScriptOptions<T extends BaseScriptApi> extends HeadEntryOptions {
544
+ type UseFunctionType<T, U> = T extends {
545
+ use: infer V;
546
+ } ? V extends () => infer W ? W : U : U;
547
+ interface UseScriptOptions<T extends BaseScriptApi = {}, U = {}> extends HeadEntryOptions {
536
548
  /**
537
549
  * Resolve the script instance from the window.
538
550
  */
@@ -565,4 +577,4 @@ interface UseScriptOptions<T extends BaseScriptApi> extends HeadEntryOptions {
565
577
  beforeInit?: () => void;
566
578
  }
567
579
 
568
- export type { ActiveHeadEntry, AsAsyncFunctionValues, 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, MaybePromiseOrFalseProps, 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 };
580
+ export type { ActiveHeadEntry, AsAsyncFunctionValues, 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, MaybePromiseOrFalseProps, 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, UseFunctionType, UseScriptInput, UseScriptOptions, UseScriptResolvedInput, UseScriptStatus, UseSeoMetaInput, UserAttributesConfig, UserTagConfigWithoutInnerContent, ValidTagPositions };
package/dist/index.d.ts CHANGED
@@ -521,7 +521,7 @@ type UseScriptResolvedInput = Omit<Script, 'src'> & {
521
521
  };
522
522
  type BaseScriptApi = Record<symbol | string, any>;
523
523
  type AsAsyncFunctionValues<T extends BaseScriptApi> = {
524
- [key in keyof T]: T[key] extends any[] ? T[key] : T[key] extends object ? AsAsyncFunctionValues<T[key]> : T[key] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : () => Promise<T[key]>;
524
+ [key in keyof T]: T[key] extends any[] ? T[key] : T[key] extends (...args: infer A) => infer R ? (...args: A) => R extends Promise<any> ? R : Promise<R> : T[key] extends Record<any, any> ? AsAsyncFunctionValues<T[key]> : never;
525
525
  };
526
526
  interface ScriptInstance<T extends BaseScriptApi> {
527
527
  proxy: AsAsyncFunctionValues<T>;
@@ -531,8 +531,20 @@ interface ScriptInstance<T extends BaseScriptApi> {
531
531
  entry?: ActiveHeadEntry<any>;
532
532
  load: () => Promise<T>;
533
533
  remove: () => boolean;
534
+ onLoaded: (fn: (instance: T) => void | Promise<void>) => void;
535
+ onError: (fn: (err?: Error) => void | Promise<void>) => void;
536
+ /**
537
+ * @internal
538
+ */
539
+ _cbs: {
540
+ loaded: ((instance: T) => void | Promise<void>)[];
541
+ error: ((err?: Error) => void | Promise<void>)[];
542
+ };
534
543
  }
535
- interface UseScriptOptions<T extends BaseScriptApi> extends HeadEntryOptions {
544
+ type UseFunctionType<T, U> = T extends {
545
+ use: infer V;
546
+ } ? V extends () => infer W ? W : U : U;
547
+ interface UseScriptOptions<T extends BaseScriptApi = {}, U = {}> extends HeadEntryOptions {
536
548
  /**
537
549
  * Resolve the script instance from the window.
538
550
  */
@@ -565,4 +577,4 @@ interface UseScriptOptions<T extends BaseScriptApi> extends HeadEntryOptions {
565
577
  beforeInit?: () => void;
566
578
  }
567
579
 
568
- export type { ActiveHeadEntry, AsAsyncFunctionValues, 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, MaybePromiseOrFalseProps, 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 };
580
+ export type { ActiveHeadEntry, AsAsyncFunctionValues, 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, MaybePromiseOrFalseProps, 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, UseFunctionType, UseScriptInput, UseScriptOptions, UseScriptResolvedInput, UseScriptStatus, UseSeoMetaInput, UserAttributesConfig, UserTagConfigWithoutInnerContent, ValidTagPositions };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/schema",
3
3
  "type": "module",
4
- "version": "1.10.0-beta.1",
4
+ "version": "1.10.0-beta.2",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",