@unhead/schema 1.8.0-beta.1 → 1.8.0-beta.11

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
@@ -10,12 +10,15 @@ interface SSRHeadPayload {
10
10
  htmlAttrs: string;
11
11
  bodyAttrs: string;
12
12
  }
13
- type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error';
13
+ type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error' | 'removed';
14
14
  interface ScriptInstance<T> {
15
+ id: string;
16
+ entry?: ActiveHeadEntry<any>;
15
17
  loaded: boolean;
16
18
  status: UseScriptStatus;
17
19
  load: () => Promise<T>;
18
20
  waitForUse: () => Promise<T>;
21
+ remove: () => boolean;
19
22
  }
20
23
  interface UseScriptOptions<T> extends Omit<HeadEntryOptions, 'transform'> {
21
24
  use?: () => T | undefined | null;
@@ -23,7 +26,7 @@ interface UseScriptOptions<T> extends Omit<HeadEntryOptions, 'transform'> {
23
26
  script: ScriptInstance<T>;
24
27
  fn: string | symbol;
25
28
  }) => any);
26
- transform?: (script: Script) => Script;
29
+ transform?: (script: Script) => Promise<Script> | Script;
27
30
  trigger?: 'idle' | 'manual' | Promise<void>;
28
31
  }
29
32
  type UseScriptInput = Omit<Script, 'src'> & {
@@ -82,13 +85,7 @@ interface HeadHooks {
82
85
  'script:transform': (ctx: {
83
86
  script: Script;
84
87
  }) => HookResult;
85
- 'script:loaded': (ctx: {
86
- script: ScriptInstance<any>;
87
- }) => HookResult;
88
- 'script:error': (ctx: {
89
- script: ScriptInstance<any>;
90
- }) => HookResult;
91
- 'script:loading': (ctx: {
88
+ 'script:updated': (ctx: {
92
89
  script: ScriptInstance<any>;
93
90
  }) => HookResult;
94
91
  }
@@ -143,7 +140,14 @@ interface HeadEntry<Input> {
143
140
  type HeadPluginOptions = Omit<CreateHeadOptions, 'plugins'> & {
144
141
  mode?: RuntimeMode;
145
142
  };
146
- type HeadPlugin = HeadPluginOptions | ((head: Unhead) => HeadPluginOptions);
143
+ type HeadPluginInput = (HeadPluginOptions & {
144
+ key?: string;
145
+ }) | ((head: Unhead) => HeadPluginOptions & {
146
+ key?: string;
147
+ });
148
+ type HeadPlugin = HeadPluginOptions & {
149
+ key?: string;
150
+ };
147
151
  /**
148
152
  * An active head entry provides an API to manipulate it.
149
153
  */
@@ -164,7 +168,7 @@ interface ActiveHeadEntry<Input> {
164
168
  interface CreateHeadOptions {
165
169
  domDelayFn?: (fn: () => void) => void;
166
170
  document?: Document;
167
- plugins?: HeadPlugin[];
171
+ plugins?: HeadPluginInput[];
168
172
  hooks?: NestedHooks<HeadHooks>;
169
173
  }
170
174
  interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplateParams {
@@ -173,6 +177,10 @@ interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplatePa
173
177
  head?: Unhead;
174
178
  }
175
179
  interface Unhead<Input extends {} = Head> {
180
+ /**
181
+ * Registered plugins.
182
+ */
183
+ plugins: HeadPlugin[];
176
184
  /**
177
185
  * The active head entries.
178
186
  */
@@ -196,7 +204,7 @@ interface Unhead<Input extends {} = Head> {
196
204
  /**
197
205
  * Use a head plugin, loads the plugins hooks.
198
206
  */
199
- use: (plugin: HeadPlugin) => void;
207
+ use: (plugin: HeadPluginInput) => void;
200
208
  /**
201
209
  * Is it a server-side render context.
202
210
  */
@@ -293,7 +301,7 @@ interface TagPriority {
293
301
  type TagUserProperties = TagPriority & TagPosition & MaybePromiseProps<InnerContent> & ResolvesDuplicates & ProcessesTemplateParams;
294
302
  type TagKey = keyof Head;
295
303
  type TemplateParams = {
296
- separator?: string;
304
+ separator?: '|' | '-' | '·' | string;
297
305
  } & Record<string, null | string | Record<string, string>>;
298
306
  interface ProcessesTemplateParams {
299
307
  processTemplateParams?: boolean;
@@ -504,4 +512,4 @@ interface HeadSafe extends Pick<Head, 'title' | 'titleTemplate' | 'templateParam
504
512
  bodyAttrs?: SafeBodyAttr;
505
513
  }
506
514
 
507
- export type { ActiveHeadEntry, Base, BaseBodyAttr, BaseHtmlAttr, BaseMeta, BodyAttr, BodyAttributes, CreateHeadOptions, DomBeforeRenderCtx, DomRenderTagContext, DomState, EntryAugmentation, EntryResolveCtx, HasTemplateParams, Head, HeadEntry, HeadEntryOptions, HeadHooks, HeadPlugin, HeadPluginOptions, HeadSafe, HeadTag, HeadTagKeys, HeadUtils, HookResult, HtmlAttr, HtmlAttributes, InnerContent, InnerContentVal, Link, MaybeArray, MaybeFunctionEntries, Meta, Never, Noscript, ProcessesTemplateParams, 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 };
515
+ 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, 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 };
package/dist/index.d.mts CHANGED
@@ -10,12 +10,15 @@ interface SSRHeadPayload {
10
10
  htmlAttrs: string;
11
11
  bodyAttrs: string;
12
12
  }
13
- type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error';
13
+ type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error' | 'removed';
14
14
  interface ScriptInstance<T> {
15
+ id: string;
16
+ entry?: ActiveHeadEntry<any>;
15
17
  loaded: boolean;
16
18
  status: UseScriptStatus;
17
19
  load: () => Promise<T>;
18
20
  waitForUse: () => Promise<T>;
21
+ remove: () => boolean;
19
22
  }
20
23
  interface UseScriptOptions<T> extends Omit<HeadEntryOptions, 'transform'> {
21
24
  use?: () => T | undefined | null;
@@ -23,7 +26,7 @@ interface UseScriptOptions<T> extends Omit<HeadEntryOptions, 'transform'> {
23
26
  script: ScriptInstance<T>;
24
27
  fn: string | symbol;
25
28
  }) => any);
26
- transform?: (script: Script) => Script;
29
+ transform?: (script: Script) => Promise<Script> | Script;
27
30
  trigger?: 'idle' | 'manual' | Promise<void>;
28
31
  }
29
32
  type UseScriptInput = Omit<Script, 'src'> & {
@@ -82,13 +85,7 @@ interface HeadHooks {
82
85
  'script:transform': (ctx: {
83
86
  script: Script;
84
87
  }) => HookResult;
85
- 'script:loaded': (ctx: {
86
- script: ScriptInstance<any>;
87
- }) => HookResult;
88
- 'script:error': (ctx: {
89
- script: ScriptInstance<any>;
90
- }) => HookResult;
91
- 'script:loading': (ctx: {
88
+ 'script:updated': (ctx: {
92
89
  script: ScriptInstance<any>;
93
90
  }) => HookResult;
94
91
  }
@@ -143,7 +140,14 @@ interface HeadEntry<Input> {
143
140
  type HeadPluginOptions = Omit<CreateHeadOptions, 'plugins'> & {
144
141
  mode?: RuntimeMode;
145
142
  };
146
- type HeadPlugin = HeadPluginOptions | ((head: Unhead) => HeadPluginOptions);
143
+ type HeadPluginInput = (HeadPluginOptions & {
144
+ key?: string;
145
+ }) | ((head: Unhead) => HeadPluginOptions & {
146
+ key?: string;
147
+ });
148
+ type HeadPlugin = HeadPluginOptions & {
149
+ key?: string;
150
+ };
147
151
  /**
148
152
  * An active head entry provides an API to manipulate it.
149
153
  */
@@ -164,7 +168,7 @@ interface ActiveHeadEntry<Input> {
164
168
  interface CreateHeadOptions {
165
169
  domDelayFn?: (fn: () => void) => void;
166
170
  document?: Document;
167
- plugins?: HeadPlugin[];
171
+ plugins?: HeadPluginInput[];
168
172
  hooks?: NestedHooks<HeadHooks>;
169
173
  }
170
174
  interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplateParams {
@@ -173,6 +177,10 @@ interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplatePa
173
177
  head?: Unhead;
174
178
  }
175
179
  interface Unhead<Input extends {} = Head> {
180
+ /**
181
+ * Registered plugins.
182
+ */
183
+ plugins: HeadPlugin[];
176
184
  /**
177
185
  * The active head entries.
178
186
  */
@@ -196,7 +204,7 @@ interface Unhead<Input extends {} = Head> {
196
204
  /**
197
205
  * Use a head plugin, loads the plugins hooks.
198
206
  */
199
- use: (plugin: HeadPlugin) => void;
207
+ use: (plugin: HeadPluginInput) => void;
200
208
  /**
201
209
  * Is it a server-side render context.
202
210
  */
@@ -293,7 +301,7 @@ interface TagPriority {
293
301
  type TagUserProperties = TagPriority & TagPosition & MaybePromiseProps<InnerContent> & ResolvesDuplicates & ProcessesTemplateParams;
294
302
  type TagKey = keyof Head;
295
303
  type TemplateParams = {
296
- separator?: string;
304
+ separator?: '|' | '-' | '·' | string;
297
305
  } & Record<string, null | string | Record<string, string>>;
298
306
  interface ProcessesTemplateParams {
299
307
  processTemplateParams?: boolean;
@@ -504,4 +512,4 @@ interface HeadSafe extends Pick<Head, 'title' | 'titleTemplate' | 'templateParam
504
512
  bodyAttrs?: SafeBodyAttr;
505
513
  }
506
514
 
507
- export type { ActiveHeadEntry, Base, BaseBodyAttr, BaseHtmlAttr, BaseMeta, BodyAttr, BodyAttributes, CreateHeadOptions, DomBeforeRenderCtx, DomRenderTagContext, DomState, EntryAugmentation, EntryResolveCtx, HasTemplateParams, Head, HeadEntry, HeadEntryOptions, HeadHooks, HeadPlugin, HeadPluginOptions, HeadSafe, HeadTag, HeadTagKeys, HeadUtils, HookResult, HtmlAttr, HtmlAttributes, InnerContent, InnerContentVal, Link, MaybeArray, MaybeFunctionEntries, Meta, Never, Noscript, ProcessesTemplateParams, 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 };
515
+ 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, 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 };
package/dist/index.d.ts CHANGED
@@ -10,12 +10,15 @@ interface SSRHeadPayload {
10
10
  htmlAttrs: string;
11
11
  bodyAttrs: string;
12
12
  }
13
- type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error';
13
+ type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error' | 'removed';
14
14
  interface ScriptInstance<T> {
15
+ id: string;
16
+ entry?: ActiveHeadEntry<any>;
15
17
  loaded: boolean;
16
18
  status: UseScriptStatus;
17
19
  load: () => Promise<T>;
18
20
  waitForUse: () => Promise<T>;
21
+ remove: () => boolean;
19
22
  }
20
23
  interface UseScriptOptions<T> extends Omit<HeadEntryOptions, 'transform'> {
21
24
  use?: () => T | undefined | null;
@@ -23,7 +26,7 @@ interface UseScriptOptions<T> extends Omit<HeadEntryOptions, 'transform'> {
23
26
  script: ScriptInstance<T>;
24
27
  fn: string | symbol;
25
28
  }) => any);
26
- transform?: (script: Script) => Script;
29
+ transform?: (script: Script) => Promise<Script> | Script;
27
30
  trigger?: 'idle' | 'manual' | Promise<void>;
28
31
  }
29
32
  type UseScriptInput = Omit<Script, 'src'> & {
@@ -82,13 +85,7 @@ interface HeadHooks {
82
85
  'script:transform': (ctx: {
83
86
  script: Script;
84
87
  }) => HookResult;
85
- 'script:loaded': (ctx: {
86
- script: ScriptInstance<any>;
87
- }) => HookResult;
88
- 'script:error': (ctx: {
89
- script: ScriptInstance<any>;
90
- }) => HookResult;
91
- 'script:loading': (ctx: {
88
+ 'script:updated': (ctx: {
92
89
  script: ScriptInstance<any>;
93
90
  }) => HookResult;
94
91
  }
@@ -143,7 +140,14 @@ interface HeadEntry<Input> {
143
140
  type HeadPluginOptions = Omit<CreateHeadOptions, 'plugins'> & {
144
141
  mode?: RuntimeMode;
145
142
  };
146
- type HeadPlugin = HeadPluginOptions | ((head: Unhead) => HeadPluginOptions);
143
+ type HeadPluginInput = (HeadPluginOptions & {
144
+ key?: string;
145
+ }) | ((head: Unhead) => HeadPluginOptions & {
146
+ key?: string;
147
+ });
148
+ type HeadPlugin = HeadPluginOptions & {
149
+ key?: string;
150
+ };
147
151
  /**
148
152
  * An active head entry provides an API to manipulate it.
149
153
  */
@@ -164,7 +168,7 @@ interface ActiveHeadEntry<Input> {
164
168
  interface CreateHeadOptions {
165
169
  domDelayFn?: (fn: () => void) => void;
166
170
  document?: Document;
167
- plugins?: HeadPlugin[];
171
+ plugins?: HeadPluginInput[];
168
172
  hooks?: NestedHooks<HeadHooks>;
169
173
  }
170
174
  interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplateParams {
@@ -173,6 +177,10 @@ interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplatePa
173
177
  head?: Unhead;
174
178
  }
175
179
  interface Unhead<Input extends {} = Head> {
180
+ /**
181
+ * Registered plugins.
182
+ */
183
+ plugins: HeadPlugin[];
176
184
  /**
177
185
  * The active head entries.
178
186
  */
@@ -196,7 +204,7 @@ interface Unhead<Input extends {} = Head> {
196
204
  /**
197
205
  * Use a head plugin, loads the plugins hooks.
198
206
  */
199
- use: (plugin: HeadPlugin) => void;
207
+ use: (plugin: HeadPluginInput) => void;
200
208
  /**
201
209
  * Is it a server-side render context.
202
210
  */
@@ -293,7 +301,7 @@ interface TagPriority {
293
301
  type TagUserProperties = TagPriority & TagPosition & MaybePromiseProps<InnerContent> & ResolvesDuplicates & ProcessesTemplateParams;
294
302
  type TagKey = keyof Head;
295
303
  type TemplateParams = {
296
- separator?: string;
304
+ separator?: '|' | '-' | '·' | string;
297
305
  } & Record<string, null | string | Record<string, string>>;
298
306
  interface ProcessesTemplateParams {
299
307
  processTemplateParams?: boolean;
@@ -504,4 +512,4 @@ interface HeadSafe extends Pick<Head, 'title' | 'titleTemplate' | 'templateParam
504
512
  bodyAttrs?: SafeBodyAttr;
505
513
  }
506
514
 
507
- export type { ActiveHeadEntry, Base, BaseBodyAttr, BaseHtmlAttr, BaseMeta, BodyAttr, BodyAttributes, CreateHeadOptions, DomBeforeRenderCtx, DomRenderTagContext, DomState, EntryAugmentation, EntryResolveCtx, HasTemplateParams, Head, HeadEntry, HeadEntryOptions, HeadHooks, HeadPlugin, HeadPluginOptions, HeadSafe, HeadTag, HeadTagKeys, HeadUtils, HookResult, HtmlAttr, HtmlAttributes, InnerContent, InnerContentVal, Link, MaybeArray, MaybeFunctionEntries, Meta, Never, Noscript, ProcessesTemplateParams, 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 };
515
+ 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, 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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/schema",
3
3
  "type": "module",
4
- "version": "1.8.0-beta.1",
4
+ "version": "1.8.0-beta.11",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",