@unhead/schema 1.10.3 → 1.11.0-beta.1

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.ts CHANGED
@@ -1,6 +1,270 @@
1
- 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';
2
- export { BodyEvents, DataKeys, DefinedValueOrEmptyObject, MergeHead, MetaFlatInput, ScriptBase, SpeculationRules } from 'zhead';
3
1
  import { NestedHooks, Hookable } from 'hookable';
2
+ import { 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';
3
+ export { BodyEvents, DataKeys, DefinedValueOrEmptyObject, MergeHead, MetaFlatInput, ScriptBase, SpeculationRules } from 'zhead';
4
+
5
+ type Never<T> = {
6
+ [P in keyof T]?: never;
7
+ };
8
+ type FalsyEntries<T> = {
9
+ [key in keyof T]?: T[key] | null | false | undefined;
10
+ };
11
+
12
+ type UserTagConfigWithoutInnerContent = TagPriority & TagPosition & ResolvesDuplicates & Never<InnerContent> & {
13
+ processTemplateParams?: false;
14
+ };
15
+ type UserAttributesConfig = ResolvesDuplicates & TagPriority & Never<InnerContent & TagPosition>;
16
+ interface SchemaAugmentations extends MergeHead {
17
+ title: TagPriority;
18
+ titleTemplate: TagPriority;
19
+ base: UserAttributesConfig;
20
+ htmlAttrs: UserAttributesConfig;
21
+ bodyAttrs: UserAttributesConfig;
22
+ link: UserTagConfigWithoutInnerContent;
23
+ meta: UserTagConfigWithoutInnerContent;
24
+ style: TagUserProperties;
25
+ script: TagUserProperties;
26
+ noscript: TagUserProperties;
27
+ }
28
+ type MaybeArray<T> = T | T[];
29
+ type BaseBodyAttr = BaseBodyAttributes;
30
+ type BaseHtmlAttr = HtmlAttributes$1;
31
+ interface BodyAttr extends Omit<BaseBodyAttr, 'class'> {
32
+ /**
33
+ * The class global attribute is a space-separated list of the case-sensitive classes of the element.
34
+ *
35
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
36
+ */
37
+ class?: MaybeArray<string> | Record<string, boolean>;
38
+ }
39
+ interface HtmlAttr extends Omit<HtmlAttributes$1, 'class'> {
40
+ /**
41
+ * The class global attribute is a space-separated list of the case-sensitive classes of the element.
42
+ *
43
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
44
+ */
45
+ class?: MaybeArray<string> | Record<string, boolean>;
46
+ }
47
+ interface BaseMeta extends Omit<Meta$1, 'content'> {
48
+ /**
49
+ * This attribute contains the value for the http-equiv, name or property attribute, depending on which is used.
50
+ *
51
+ * You can provide an array of values to create multiple tags sharing the same name, property or http-equiv.
52
+ *
53
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-content
54
+ */
55
+ content?: MaybeArray<Stringable> | null;
56
+ }
57
+ type EntryAugmentation = undefined | Record<string, any>;
58
+ type MaybeFunctionEntries<T> = {
59
+ [key in keyof T]?: T[key] | ((e: Event) => void);
60
+ };
61
+ type TitleTemplateResolver = string | ((title?: string) => string | null);
62
+ type Title = string | FalsyEntries<({
63
+ textContent: string;
64
+ } & SchemaAugmentations['title']) | null>;
65
+ type TitleTemplate = TitleTemplateResolver | null | ({
66
+ textContent: TitleTemplateResolver;
67
+ } & SchemaAugmentations['titleTemplate']);
68
+ type Base<E extends EntryAugmentation = Record<string, any>> = Partial<Merge<SchemaAugmentations['base'], FalsyEntries<Base$1>>> & DefinedValueOrEmptyObject<E>;
69
+ type Link<E extends EntryAugmentation = Record<string, any>> = FalsyEntries<LinkBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['link'] & DefinedValueOrEmptyObject<E>;
70
+ type Meta<E extends EntryAugmentation = Record<string, any>> = FalsyEntries<BaseMeta> & DataKeys & SchemaAugmentations['meta'] & DefinedValueOrEmptyObject<E>;
71
+ type Style<E extends EntryAugmentation = Record<string, any>> = FalsyEntries<Style$1> & DataKeys & SchemaAugmentations['style'] & DefinedValueOrEmptyObject<E>;
72
+ type Script<E extends EntryAugmentation = Record<string, any>> = FalsyEntries<ScriptBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['script'] & DefinedValueOrEmptyObject<E>;
73
+ type Noscript<E extends EntryAugmentation = Record<string, any>> = FalsyEntries<Noscript$1> & DataKeys & SchemaAugmentations['noscript'] & DefinedValueOrEmptyObject<E>;
74
+ type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = FalsyEntries<HtmlAttr> & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>;
75
+ type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = FalsyEntries<BodyAttr> & MaybeFunctionEntries<BodyEvents> & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>;
76
+ interface HeadUtils {
77
+ /**
78
+ * Generate the title from a template.
79
+ *
80
+ * Should include a `%s` placeholder for the title, for example `%s - My Site`.
81
+ */
82
+ titleTemplate?: TitleTemplate;
83
+ /**
84
+ * Variables used to substitute in the title and meta content.
85
+ */
86
+ templateParams?: TemplateParams;
87
+ }
88
+ interface Head<E extends MergeHead = SchemaAugmentations> extends HeadUtils {
89
+ /**
90
+ * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
91
+ * It only contains text; tags within the element are ignored.
92
+ *
93
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
94
+ */
95
+ title?: Title;
96
+ /**
97
+ * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
98
+ * There can be only one <base> element in a document.
99
+ *
100
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
101
+ */
102
+ base?: Base<E['base']>;
103
+ /**
104
+ * The `<link>` HTML element specifies relationships between the current document and an external resource.
105
+ * This element is most commonly used to link to stylesheets, but is also used to establish site icons
106
+ * (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
107
+ *
108
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
109
+ */
110
+ link?: Link<E['link']>[];
111
+ /**
112
+ * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
113
+ *
114
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
115
+ */
116
+ meta?: Meta<E['meta']>[];
117
+ /**
118
+ * The `<style>` HTML element contains style information for a document, or part of a document.
119
+ * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
120
+ *
121
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
122
+ */
123
+ style?: (Style<E['style']> | string)[];
124
+ /**
125
+ * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
126
+ *
127
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
128
+ */
129
+ script?: (Script<E['script']> | string)[];
130
+ /**
131
+ * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
132
+ * or if scripting is currently turned off in the browser.
133
+ *
134
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
135
+ */
136
+ noscript?: (Noscript<E['noscript']> | string)[];
137
+ /**
138
+ * Attributes for the `<html>` HTML element.
139
+ *
140
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
141
+ */
142
+ htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
143
+ /**
144
+ * Attributes for the `<body>` HTML element.
145
+ *
146
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
147
+ */
148
+ bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
149
+ }
150
+ type UseSeoMetaInput = MetaFlatInput & {
151
+ title?: Title;
152
+ titleTemplate?: TitleTemplate;
153
+ };
154
+
155
+ interface ResolvesDuplicates {
156
+ /**
157
+ * By default, tags which share the same unique key `name`, `property` are de-duped. To allow duplicates
158
+ * to be made you can provide a unique key for each entry.
159
+ */
160
+ key?: string;
161
+ /**
162
+ * The strategy to use when a duplicate tag is encountered.
163
+ *
164
+ * - `replace` - Replace the existing tag with the new tag
165
+ * - `merge` - Merge the existing tag with the new tag
166
+ *
167
+ * @default 'replace' (some tags will default to 'merge', such as htmlAttr)
168
+ */
169
+ tagDuplicateStrategy?: 'replace' | 'merge';
170
+ /**
171
+ * @deprecated Use `key` instead
172
+ */
173
+ hid?: string;
174
+ /**
175
+ * @deprecated Use `key` instead
176
+ */
177
+ vmid?: string;
178
+ }
179
+ type ValidTagPositions = 'head' | 'bodyClose' | 'bodyOpen';
180
+ interface TagPosition {
181
+ /**
182
+ * Specify where to render the tag.
183
+ *
184
+ * @default 'head'
185
+ */
186
+ tagPosition?: ValidTagPositions;
187
+ }
188
+ type InnerContentVal = string | Record<string, any>;
189
+ interface InnerContent {
190
+ /**
191
+ * Text content of the tag.
192
+ *
193
+ * Warning: This is not safe for XSS. Do not use this with user input, use `textContent` instead.
194
+ */
195
+ innerHTML?: InnerContentVal;
196
+ /**
197
+ * Sets the textContent of an element. Safer for XSS.
198
+ */
199
+ textContent?: InnerContentVal;
200
+ /**
201
+ * Sets the textContent of an element.
202
+ *
203
+ * @deprecated Use `textContent` or `innerHTML`.
204
+ */
205
+ children?: InnerContentVal;
206
+ }
207
+ interface TagPriority {
208
+ /**
209
+ * The priority for rendering the tag, without this all tags are rendered as they are registered
210
+ * (besides some special tags).
211
+ *
212
+ * The following special tags have default priorities:
213
+ * -2 `<meta charset ...>`
214
+ * -1 `<base>`
215
+ * 0 `<meta http-equiv="content-security-policy" ...>`
216
+ *
217
+ * All other tags have a default priority of 10: `<meta>`, `<script>`, `<link>`, `<style>`, etc
218
+ */
219
+ tagPriority?: number | 'critical' | 'high' | 'low' | `before:${string}` | `after:${string}`;
220
+ }
221
+ type TagUserProperties = FalsyEntries<TagPriority & TagPosition & InnerContent & ResolvesDuplicates & ProcessesTemplateParams>;
222
+ type TagKey = keyof Head;
223
+ type TemplateParams = {
224
+ separator?: '|' | '-' | '·' | string;
225
+ } & Record<string, null | string | Record<string, string>>;
226
+ interface ProcessesTemplateParams {
227
+ processTemplateParams?: boolean;
228
+ }
229
+ interface HasTemplateParams {
230
+ templateParams?: TemplateParams;
231
+ }
232
+ interface HeadTag extends TagPriority, TagPosition, ResolvesDuplicates, HasTemplateParams {
233
+ tag: TagKey;
234
+ props: Record<string, string>;
235
+ processTemplateParams?: boolean;
236
+ innerHTML?: string;
237
+ textContent?: string;
238
+ /**
239
+ * Entry ID
240
+ * @internal
241
+ */
242
+ _e?: number;
243
+ /**
244
+ * Position
245
+ * @internal
246
+ */
247
+ _p?: number;
248
+ /**
249
+ * Dedupe key
250
+ * @internal
251
+ */
252
+ _d?: string;
253
+ /**
254
+ * Hash code used to represent the tag.
255
+ * @internal
256
+ */
257
+ _h?: string;
258
+ /**
259
+ * @internal
260
+ */
261
+ _m?: RuntimeMode;
262
+ /**
263
+ * @internal
264
+ */
265
+ _eventHandlers?: Record<string, ((e: Event) => {})>;
266
+ }
267
+ type HeadTagKeys = (keyof HeadTag)[];
4
268
 
5
269
  type HookResult = Promise<void> | void;
6
270
  interface SSRHeadPayload {
@@ -203,6 +467,10 @@ interface Unhead<Input extends {} = Head> {
203
467
  * @internal
204
468
  */
205
469
  _domUpdatePromise?: Promise<void>;
470
+ /**
471
+ * @internal
472
+ */
473
+ _domDebouncedUpdatePromise?: Promise<void>;
206
474
  /**
207
475
  * @internal
208
476
  */
@@ -226,269 +494,6 @@ interface DomState {
226
494
  elMap: Record<string, Element>;
227
495
  }
228
496
 
229
- interface ResolvesDuplicates {
230
- /**
231
- * By default, tags which share the same unique key `name`, `property` are de-duped. To allow duplicates
232
- * to be made you can provide a unique key for each entry.
233
- */
234
- key?: string;
235
- /**
236
- * The strategy to use when a duplicate tag is encountered.
237
- *
238
- * - `replace` - Replace the existing tag with the new tag
239
- * - `merge` - Merge the existing tag with the new tag
240
- *
241
- * @default 'replace' (some tags will default to 'merge', such as htmlAttr)
242
- */
243
- tagDuplicateStrategy?: 'replace' | 'merge';
244
- /**
245
- * @deprecated Use `key` instead
246
- */
247
- hid?: string;
248
- /**
249
- * @deprecated Use `key` instead
250
- */
251
- vmid?: string;
252
- }
253
- type ValidTagPositions = 'head' | 'bodyClose' | 'bodyOpen';
254
- interface TagPosition {
255
- /**
256
- * Specify where to render the tag.
257
- *
258
- * @default 'head'
259
- */
260
- tagPosition?: ValidTagPositions;
261
- }
262
- type InnerContentVal = string | Record<string, any>;
263
- interface InnerContent {
264
- /**
265
- * Text content of the tag.
266
- *
267
- * Warning: This is not safe for XSS. Do not use this with user input, use `textContent` instead.
268
- */
269
- innerHTML?: InnerContentVal;
270
- /**
271
- * Sets the textContent of an element. Safer for XSS.
272
- */
273
- textContent?: InnerContentVal;
274
- /**
275
- * Sets the textContent of an element.
276
- *
277
- * @deprecated Use `textContent` or `innerHTML`.
278
- */
279
- children?: InnerContentVal;
280
- }
281
- interface TagPriority {
282
- /**
283
- * The priority for rendering the tag, without this all tags are rendered as they are registered
284
- * (besides some special tags).
285
- *
286
- * The following special tags have default priorities:
287
- * -2 `<meta charset ...>`
288
- * -1 `<base>`
289
- * 0 `<meta http-equiv="content-security-policy" ...>`
290
- *
291
- * All other tags have a default priority of 10: `<meta>`, `<script>`, `<link>`, `<style>`, etc
292
- */
293
- tagPriority?: number | 'critical' | 'high' | 'low' | `before:${string}` | `after:${string}`;
294
- }
295
- type TagUserProperties = TagPriority & TagPosition & MaybePromiseProps<InnerContent> & ResolvesDuplicates & ProcessesTemplateParams;
296
- type TagKey = keyof Head;
297
- type TemplateParams = {
298
- separator?: '|' | '-' | '·' | string;
299
- } & Record<string, null | string | Record<string, string>>;
300
- interface ProcessesTemplateParams {
301
- processTemplateParams?: boolean;
302
- }
303
- interface HasTemplateParams {
304
- templateParams?: TemplateParams;
305
- }
306
- interface HeadTag extends TagPriority, TagPosition, ResolvesDuplicates, HasTemplateParams {
307
- tag: TagKey;
308
- props: Record<string, string>;
309
- processTemplateParams?: boolean;
310
- innerHTML?: string;
311
- textContent?: string;
312
- /**
313
- * Entry ID
314
- * @internal
315
- */
316
- _e?: number;
317
- /**
318
- * Position
319
- * @internal
320
- */
321
- _p?: number;
322
- /**
323
- * Dedupe key
324
- * @internal
325
- */
326
- _d?: string;
327
- /**
328
- * Hash code used to represent the tag.
329
- * @internal
330
- */
331
- _h?: string;
332
- /**
333
- * @internal
334
- */
335
- _m?: RuntimeMode;
336
- /**
337
- * @internal
338
- */
339
- _eventHandlers?: Record<string, ((e: Event) => {})>;
340
- }
341
- type HeadTagKeys = (keyof HeadTag)[];
342
-
343
- type Never<T> = {
344
- [P in keyof T]?: never;
345
- };
346
- type MaybePromiseOrFalseProps<T> = {
347
- [key in keyof T]?: T[key] | Promise<T[key]> | false;
348
- };
349
- type UserTagConfigWithoutInnerContent = TagPriority & TagPosition & ResolvesDuplicates & Never<InnerContent> & {
350
- processTemplateParams?: false;
351
- };
352
- type UserAttributesConfig = ResolvesDuplicates & TagPriority & Never<InnerContent & TagPosition>;
353
- interface SchemaAugmentations extends MergeHead {
354
- title: TagPriority;
355
- titleTemplate: TagPriority;
356
- base: UserAttributesConfig;
357
- htmlAttrs: UserAttributesConfig;
358
- bodyAttrs: UserAttributesConfig;
359
- link: UserTagConfigWithoutInnerContent;
360
- meta: UserTagConfigWithoutInnerContent;
361
- style: TagUserProperties;
362
- script: TagUserProperties;
363
- noscript: TagUserProperties;
364
- }
365
- type MaybeArray<T> = T | T[];
366
- type BaseBodyAttr = BaseBodyAttributes;
367
- type BaseHtmlAttr = HtmlAttributes$1;
368
- interface BodyAttr extends Omit<BaseBodyAttr, 'class'> {
369
- /**
370
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
371
- *
372
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
373
- */
374
- class?: MaybeArray<string> | Record<string, boolean>;
375
- }
376
- interface HtmlAttr extends Omit<HtmlAttributes$1, 'class'> {
377
- /**
378
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
379
- *
380
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
381
- */
382
- class?: MaybeArray<string> | Record<string, boolean>;
383
- }
384
- interface BaseMeta extends Omit<Meta$1, 'content'> {
385
- /**
386
- * This attribute contains the value for the http-equiv, name or property attribute, depending on which is used.
387
- *
388
- * You can provide an array of values to create multiple tags sharing the same name, property or http-equiv.
389
- *
390
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-content
391
- */
392
- content?: MaybeArray<Stringable> | null;
393
- }
394
- type EntryAugmentation = undefined | Record<string, any>;
395
- type MaybeFunctionEntries<T> = {
396
- [key in keyof T]?: T[key] | ((e: Event) => void);
397
- };
398
- type TitleTemplateResolver = string | ((title?: string) => string | null);
399
- type Title = string | MaybePromiseOrFalseProps<({
400
- textContent: string;
401
- } & SchemaAugmentations['title']) | null>;
402
- type TitleTemplate = TitleTemplateResolver | null | ({
403
- textContent: TitleTemplateResolver;
404
- } & SchemaAugmentations['titleTemplate']);
405
- type Base<E extends EntryAugmentation = Record<string, any>> = Partial<Merge<SchemaAugmentations['base'], MaybePromiseOrFalseProps<Base$1>>> & DefinedValueOrEmptyObject<E>;
406
- type Link<E extends EntryAugmentation = Record<string, any>> = MaybePromiseOrFalseProps<LinkBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['link'] & DefinedValueOrEmptyObject<E>;
407
- type Meta<E extends EntryAugmentation = Record<string, any>> = MaybePromiseOrFalseProps<BaseMeta> & DataKeys & SchemaAugmentations['meta'] & DefinedValueOrEmptyObject<E>;
408
- type Style<E extends EntryAugmentation = Record<string, any>> = MaybePromiseOrFalseProps<Style$1> & DataKeys & SchemaAugmentations['style'] & DefinedValueOrEmptyObject<E>;
409
- type Script<E extends EntryAugmentation = Record<string, any>> = MaybePromiseOrFalseProps<ScriptBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['script'] & DefinedValueOrEmptyObject<E>;
410
- type Noscript<E extends EntryAugmentation = Record<string, any>> = MaybePromiseOrFalseProps<Noscript$1> & DataKeys & SchemaAugmentations['noscript'] & DefinedValueOrEmptyObject<E>;
411
- type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = MaybePromiseOrFalseProps<HtmlAttr> & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>;
412
- type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = MaybePromiseOrFalseProps<BodyAttr> & MaybeFunctionEntries<BodyEvents> & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>;
413
- interface HeadUtils {
414
- /**
415
- * Generate the title from a template.
416
- *
417
- * Should include a `%s` placeholder for the title, for example `%s - My Site`.
418
- */
419
- titleTemplate?: TitleTemplate;
420
- /**
421
- * Variables used to substitute in the title and meta content.
422
- */
423
- templateParams?: TemplateParams;
424
- }
425
- interface Head<E extends MergeHead = SchemaAugmentations> extends HeadUtils {
426
- /**
427
- * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
428
- * It only contains text; tags within the element are ignored.
429
- *
430
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
431
- */
432
- title?: Title | Promise<Title>;
433
- /**
434
- * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
435
- * There can be only one <base> element in a document.
436
- *
437
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
438
- */
439
- base?: Base<E['base']>;
440
- /**
441
- * The `<link>` HTML element specifies relationships between the current document and an external resource.
442
- * This element is most commonly used to link to stylesheets, but is also used to establish site icons
443
- * (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
444
- *
445
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
446
- */
447
- link?: Link<E['link']>[];
448
- /**
449
- * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
450
- *
451
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
452
- */
453
- meta?: Meta<E['meta']>[];
454
- /**
455
- * The `<style>` HTML element contains style information for a document, or part of a document.
456
- * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
457
- *
458
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
459
- */
460
- style?: (Style<E['style']> | string)[];
461
- /**
462
- * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
463
- *
464
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
465
- */
466
- script?: (Script<E['script']> | string)[];
467
- /**
468
- * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
469
- * or if scripting is currently turned off in the browser.
470
- *
471
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
472
- */
473
- noscript?: (Noscript<E['noscript']> | string)[];
474
- /**
475
- * Attributes for the `<html>` HTML element.
476
- *
477
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
478
- */
479
- htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
480
- /**
481
- * Attributes for the `<body>` HTML element.
482
- *
483
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
484
- */
485
- bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
486
- }
487
- type UseSeoMetaInput = MetaFlatInput & {
488
- title?: Title;
489
- titleTemplate?: TitleTemplate;
490
- };
491
-
492
497
  type SafeBodyAttr = Pick<BodyAttr, 'id' | 'class'> & DataKeys;
493
498
  type SafeHtmlAttr = Pick<HtmlAttr, 'id' | 'class' | 'lang' | 'dir'> & DataKeys;
494
499
  type SafeMeta = Pick<Meta, 'id' | 'name' | 'property' | 'content' | 'charset'> & DataKeys;
@@ -531,13 +536,17 @@ interface ScriptInstance<T extends BaseScriptApi> {
531
536
  entry?: ActiveHeadEntry<any>;
532
537
  load: () => Promise<T>;
533
538
  remove: () => boolean;
534
- updateTrigger: (trigger: UseScriptOptions['trigger']) => void;
539
+ setupTriggerHandler: (trigger: UseScriptOptions['trigger']) => void;
535
540
  onLoaded: (fn: (instance: T) => void | Promise<void>) => void;
536
541
  onError: (fn: (err?: Error) => void | Promise<void>) => void;
537
542
  /**
538
543
  * @internal
539
544
  */
540
545
  _triggerAbortController?: AbortController;
546
+ /**
547
+ * @internal
548
+ */
549
+ _triggerPromises?: Promise<void>[];
541
550
  /**
542
551
  * @internal
543
552
  */
@@ -582,4 +591,4 @@ interface UseScriptOptions<T extends BaseScriptApi = {}, U = {}> extends HeadEnt
582
591
  beforeInit?: () => void;
583
592
  }
584
593
 
585
- 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 };
594
+ 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, Meta, 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.3",
4
+ "version": "1.11.0-beta.1",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",