@unhead/schema 2.0.0-alpha.9 → 2.0.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/README.md +6 -12
- package/dist/index.d.mts +1 -555
- package/dist/index.d.ts +1 -555
- package/package.json +3 -8
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +0 -555
package/README.md
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
# `@unhead/schema`
|
|
1
|
+
# Deprecated: `@unhead/schema`
|
|
2
2
|
|
|
3
|
-
Typescript definitions for document `<head>`.
|
|
3
|
+
Typescript definitions for document `<head>`. This is deprecated and only acts as alias of `unhead/types`.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Migration
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Using yarn
|
|
11
|
-
yarn add --dev @unhead/schema
|
|
7
|
+
```diff
|
|
8
|
+
-import { Head } from '@unhead/schema'
|
|
9
|
+
+import { Head } from 'unhead/types'
|
|
12
10
|
```
|
|
13
|
-
|
|
14
|
-
## Types
|
|
15
|
-
|
|
16
|
-
See [head.ts](./src/head.ts) for the full list of types.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,555 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { MergeHead, BaseBodyAttributes, HtmlAttributes as HtmlAttributes$1, Meta as Meta$1, Stringable, Base as Base$1, DefinedValueOrEmptyObject, LinkBase, DataKeys, HttpEventAttributes, Style as Style$1, ScriptBase, Noscript as Noscript$1, BodyEvents, Merge, MetaFlatInput } from 'zhead';
|
|
3
|
-
export { BodyEvents, DataKeys, DefinedValueOrEmptyObject, HttpEventAttributes, LinkBase, MergeHead, MetaFlatInput, ScriptBase, SpeculationRules } from 'zhead';
|
|
4
|
-
|
|
5
|
-
type Never<T> = {
|
|
6
|
-
[P in keyof T]?: never;
|
|
7
|
-
};
|
|
8
|
-
type MaybeFunction<T> = T | (() => T);
|
|
9
|
-
type Falsey = false | null | undefined;
|
|
10
|
-
type ResolvableValues<T> = {
|
|
11
|
-
[key in keyof T]?: MaybeFunction<T[key] | Falsey>;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type UserTagConfigWithoutInnerContent = TagPriority & TagPosition & ResolvesDuplicates & Never<InnerContent> & {
|
|
15
|
-
processTemplateParams?: false;
|
|
16
|
-
};
|
|
17
|
-
type UserAttributesConfig = ResolvesDuplicates & TagPriority & Never<InnerContent & TagPosition>;
|
|
18
|
-
interface SchemaAugmentations extends MergeHead {
|
|
19
|
-
title: TagPriority;
|
|
20
|
-
titleTemplate: TagPriority;
|
|
21
|
-
base: UserAttributesConfig;
|
|
22
|
-
htmlAttrs: UserAttributesConfig;
|
|
23
|
-
bodyAttrs: UserAttributesConfig;
|
|
24
|
-
link: UserTagConfigWithoutInnerContent;
|
|
25
|
-
meta: UserTagConfigWithoutInnerContent;
|
|
26
|
-
style: TagUserProperties;
|
|
27
|
-
script: TagUserProperties;
|
|
28
|
-
noscript: TagUserProperties;
|
|
29
|
-
}
|
|
30
|
-
interface ResolvedSchemaAugmentations extends MergeHead {
|
|
31
|
-
title: TagPriority;
|
|
32
|
-
titleTemplate: TagPriority;
|
|
33
|
-
base: ResolvesDuplicates & TagPriority & Never<InnerContent & TagPosition>;
|
|
34
|
-
htmlAttrs: ResolvesDuplicates & TagPriority & Never<InnerContent & TagPosition>;
|
|
35
|
-
bodyAttrs: ResolvesDuplicates & TagPriority & Never<InnerContent & TagPosition>;
|
|
36
|
-
link: TagPriority & TagPosition & ResolvesDuplicates & Never<InnerContent> & {
|
|
37
|
-
processTemplateParams?: false;
|
|
38
|
-
};
|
|
39
|
-
meta: TagPriority & TagPosition & ResolvesDuplicates & Never<InnerContent> & {
|
|
40
|
-
processTemplateParams?: false;
|
|
41
|
-
};
|
|
42
|
-
style: TagPriority & TagPosition & InnerContent & ResolvesDuplicates & ProcessesTemplateParams;
|
|
43
|
-
script: TagPriority & TagPosition & InnerContent & ResolvesDuplicates & ProcessesTemplateParams;
|
|
44
|
-
noscript: TagPriority & TagPosition & InnerContent & ResolvesDuplicates & ProcessesTemplateParams;
|
|
45
|
-
}
|
|
46
|
-
type MaybeArray<T> = T | T[];
|
|
47
|
-
type BaseBodyAttr = BaseBodyAttributes;
|
|
48
|
-
type BaseHtmlAttr = HtmlAttributes$1;
|
|
49
|
-
interface BodyAttr extends Omit<BaseBodyAttr, 'class'> {
|
|
50
|
-
/**
|
|
51
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
52
|
-
*
|
|
53
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
54
|
-
*/
|
|
55
|
-
class?: MaybeArray<string> | Record<string, boolean>;
|
|
56
|
-
}
|
|
57
|
-
interface HtmlAttr extends Omit<HtmlAttributes$1, 'class'> {
|
|
58
|
-
/**
|
|
59
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
60
|
-
*
|
|
61
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
62
|
-
*/
|
|
63
|
-
class?: MaybeArray<string> | Record<string, boolean>;
|
|
64
|
-
}
|
|
65
|
-
interface BaseMeta extends Omit<Meta$1, 'content'> {
|
|
66
|
-
/**
|
|
67
|
-
* This attribute contains the value for the http-equiv, name or property attribute, depending on which is used.
|
|
68
|
-
*
|
|
69
|
-
* You can provide an array of values to create multiple tags sharing the same name, property or http-equiv.
|
|
70
|
-
*
|
|
71
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-content
|
|
72
|
-
*/
|
|
73
|
-
content?: MaybeArray<Stringable> | null;
|
|
74
|
-
}
|
|
75
|
-
type EntryAugmentation = undefined | Record<string, any>;
|
|
76
|
-
type MaybeEventFnHandlers<T> = {
|
|
77
|
-
[key in keyof T]?: T[key] | ((e: Event) => void);
|
|
78
|
-
};
|
|
79
|
-
type TitleTemplateResolver = string | ((title?: string) => string | null);
|
|
80
|
-
type Title = MaybeFunction<number | string | Falsey> | ResolvableValues<({
|
|
81
|
-
textContent: string;
|
|
82
|
-
} & SchemaAugmentations['title'])>;
|
|
83
|
-
type TitleTemplate = TitleTemplateResolver | null | ({
|
|
84
|
-
textContent: TitleTemplateResolver;
|
|
85
|
-
} & SchemaAugmentations['titleTemplate']);
|
|
86
|
-
type Base<E extends EntryAugmentation = Record<string, any>> = ResolvableValues<Base$1 & SchemaAugmentations['base']> & DefinedValueOrEmptyObject<E>;
|
|
87
|
-
type Link<E extends EntryAugmentation = Record<string, any>> = ResolvableValues<LinkBase & DataKeys & SchemaAugmentations['link']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
|
|
88
|
-
type Meta<E extends EntryAugmentation = Record<string, any>> = ResolvableValues<BaseMeta & DataKeys & SchemaAugmentations['meta']> & DefinedValueOrEmptyObject<E>;
|
|
89
|
-
type Style<E extends EntryAugmentation = Record<string, any>> = ResolvableValues<Style$1 & DataKeys & SchemaAugmentations['style']> & DefinedValueOrEmptyObject<E>;
|
|
90
|
-
type Script<E extends EntryAugmentation = Record<string, any>> = ResolvableValues<ScriptBase & DataKeys & SchemaAugmentations['script']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
|
|
91
|
-
type Noscript<E extends EntryAugmentation = Record<string, any>> = ResolvableValues<Noscript$1 & DataKeys & SchemaAugmentations['noscript']> & DefinedValueOrEmptyObject<E>;
|
|
92
|
-
type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableValues<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs']> & DefinedValueOrEmptyObject<E>;
|
|
93
|
-
type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableValues<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs']> & MaybeEventFnHandlers<BodyEvents> & DefinedValueOrEmptyObject<E>;
|
|
94
|
-
type ResolvedTitle = ({
|
|
95
|
-
textContent: string;
|
|
96
|
-
} & ResolvedSchemaAugmentations['title']);
|
|
97
|
-
type ResolvedTitleTemplate = TitleTemplateResolver | null | ({
|
|
98
|
-
textContent: TitleTemplateResolver;
|
|
99
|
-
} & ResolvedSchemaAugmentations['titleTemplate']);
|
|
100
|
-
type ResolvedBase<E extends EntryAugmentation = Record<string, any>> = Partial<Merge<ResolvedSchemaAugmentations['base'], Base$1>> & DefinedValueOrEmptyObject<E>;
|
|
101
|
-
type ResolvedLink<E extends EntryAugmentation = Record<string, any>> = LinkBase & MaybeEventFnHandlers<HttpEventAttributes> & DataKeys & ResolvedSchemaAugmentations['link'] & DefinedValueOrEmptyObject<E>;
|
|
102
|
-
type ResolvedMeta<E extends EntryAugmentation = Record<string, any>> = BaseMeta & DataKeys & SchemaAugmentations['meta'] & DefinedValueOrEmptyObject<E>;
|
|
103
|
-
type ResolvedStyle<E extends EntryAugmentation = Record<string, any>> = Style$1 & DataKeys & ResolvedSchemaAugmentations['style'] & DefinedValueOrEmptyObject<E>;
|
|
104
|
-
type ResolvedScript<E extends EntryAugmentation = Record<string, any>> = ScriptBase & MaybeEventFnHandlers<HttpEventAttributes> & DataKeys & ResolvedSchemaAugmentations['script'] & DefinedValueOrEmptyObject<E>;
|
|
105
|
-
type ResolvedNoscript<E extends EntryAugmentation = Record<string, any>> = Noscript$1 & DataKeys & ResolvedSchemaAugmentations['noscript'] & DefinedValueOrEmptyObject<E>;
|
|
106
|
-
type ResolvedHtmlAttributes<E extends EntryAugmentation = Record<string, any>> = HtmlAttr & DataKeys & ResolvedSchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>;
|
|
107
|
-
type ResolvedBodyAttributes<E extends EntryAugmentation = Record<string, any>> = BodyAttr & MaybeEventFnHandlers<BodyEvents> & DataKeys & ResolvedSchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>;
|
|
108
|
-
interface HeadUtils {
|
|
109
|
-
/**
|
|
110
|
-
* Generate the title from a template.
|
|
111
|
-
*
|
|
112
|
-
* Should include a `%s` placeholder for the title, for example `%s - My Site`.
|
|
113
|
-
*/
|
|
114
|
-
titleTemplate?: TitleTemplate;
|
|
115
|
-
/**
|
|
116
|
-
* Variables used to substitute in the title and meta content.
|
|
117
|
-
*/
|
|
118
|
-
templateParams?: TemplateParams;
|
|
119
|
-
}
|
|
120
|
-
interface Head<E extends MergeHead = SchemaAugmentations> extends HeadUtils {
|
|
121
|
-
/**
|
|
122
|
-
* The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
|
|
123
|
-
* It only contains text; tags within the element are ignored.
|
|
124
|
-
*
|
|
125
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
|
|
126
|
-
*/
|
|
127
|
-
title?: Title;
|
|
128
|
-
/**
|
|
129
|
-
* The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
|
|
130
|
-
* There can be only one <base> element in a document.
|
|
131
|
-
*
|
|
132
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
|
|
133
|
-
*/
|
|
134
|
-
base?: Base<E['base']>;
|
|
135
|
-
/**
|
|
136
|
-
* The `<link>` HTML element specifies relationships between the current document and an external resource.
|
|
137
|
-
* This element is most commonly used to link to stylesheets, but is also used to establish site icons
|
|
138
|
-
* (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
|
|
139
|
-
*
|
|
140
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
|
|
141
|
-
*/
|
|
142
|
-
link?: Link<E['link']>[];
|
|
143
|
-
/**
|
|
144
|
-
* The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
|
|
145
|
-
*
|
|
146
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
|
|
147
|
-
*/
|
|
148
|
-
meta?: Meta<E['meta']>[];
|
|
149
|
-
/**
|
|
150
|
-
* The `<style>` HTML element contains style information for a document, or part of a document.
|
|
151
|
-
* It contains CSS, which is applied to the contents of the document containing the `<style>` element.
|
|
152
|
-
*
|
|
153
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
|
|
154
|
-
*/
|
|
155
|
-
style?: (Style<E['style']> | string)[];
|
|
156
|
-
/**
|
|
157
|
-
* The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
|
|
158
|
-
*
|
|
159
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
|
|
160
|
-
*/
|
|
161
|
-
script?: (Script<E['script']> | string)[];
|
|
162
|
-
/**
|
|
163
|
-
* The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
|
|
164
|
-
* or if scripting is currently turned off in the browser.
|
|
165
|
-
*
|
|
166
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
|
|
167
|
-
*/
|
|
168
|
-
noscript?: (Noscript<E['noscript']> | string)[];
|
|
169
|
-
/**
|
|
170
|
-
* Attributes for the `<html>` HTML element.
|
|
171
|
-
*
|
|
172
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
|
|
173
|
-
*/
|
|
174
|
-
htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
|
|
175
|
-
/**
|
|
176
|
-
* Attributes for the `<body>` HTML element.
|
|
177
|
-
*
|
|
178
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
|
|
179
|
-
*/
|
|
180
|
-
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
181
|
-
}
|
|
182
|
-
interface ResolvedHead<E extends MergeHead = ResolvedSchemaAugmentations> extends HeadUtils {
|
|
183
|
-
title?: ResolvedTitle;
|
|
184
|
-
base?: ResolvedBase<E['base']>;
|
|
185
|
-
link?: ResolvedLink<E['link']>[];
|
|
186
|
-
meta?: ResolvedMeta<E['meta']>[];
|
|
187
|
-
style?: (ResolvedStyle<E['style']> | string)[];
|
|
188
|
-
script?: (ResolvedScript<E['script']> | string)[];
|
|
189
|
-
noscript?: (ResolvedNoscript<E['noscript']> | string)[];
|
|
190
|
-
htmlAttrs?: ResolvedHtmlAttributes<E['htmlAttrs']>;
|
|
191
|
-
bodyAttrs?: ResolvedBodyAttributes<E['bodyAttrs']>;
|
|
192
|
-
}
|
|
193
|
-
type UseSeoMetaInput = MetaFlatInput & {
|
|
194
|
-
title?: Title;
|
|
195
|
-
titleTemplate?: TitleTemplate;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
interface ResolvesDuplicates {
|
|
199
|
-
/**
|
|
200
|
-
* By default, tags which share the same unique key `name`, `property` are de-duped. To allow duplicates
|
|
201
|
-
* to be made you can provide a unique key for each entry.
|
|
202
|
-
*/
|
|
203
|
-
key?: string;
|
|
204
|
-
/**
|
|
205
|
-
* The strategy to use when a duplicate tag is encountered.
|
|
206
|
-
*
|
|
207
|
-
* - `replace` - Replace the existing tag with the new tag
|
|
208
|
-
* - `merge` - Merge the existing tag with the new tag
|
|
209
|
-
*
|
|
210
|
-
* @default 'replace' (some tags will default to 'merge', such as htmlAttr)
|
|
211
|
-
*/
|
|
212
|
-
tagDuplicateStrategy?: 'replace' | 'merge';
|
|
213
|
-
}
|
|
214
|
-
type ValidTagPositions = 'head' | 'bodyClose' | 'bodyOpen';
|
|
215
|
-
interface TagPosition {
|
|
216
|
-
/**
|
|
217
|
-
* Specify where to render the tag.
|
|
218
|
-
*
|
|
219
|
-
* @default 'head'
|
|
220
|
-
*/
|
|
221
|
-
tagPosition?: ValidTagPositions;
|
|
222
|
-
}
|
|
223
|
-
type InnerContentVal = string | Record<string, any>;
|
|
224
|
-
interface InnerContent {
|
|
225
|
-
/**
|
|
226
|
-
* Text content of the tag.
|
|
227
|
-
*
|
|
228
|
-
* Warning: This is not safe for XSS. Do not use this with user input, use `textContent` instead.
|
|
229
|
-
*/
|
|
230
|
-
innerHTML?: InnerContentVal;
|
|
231
|
-
/**
|
|
232
|
-
* Sets the textContent of an element. Safer for XSS.
|
|
233
|
-
*/
|
|
234
|
-
textContent?: InnerContentVal;
|
|
235
|
-
}
|
|
236
|
-
interface TagPriority {
|
|
237
|
-
/**
|
|
238
|
-
* The priority for rendering the tag, without this all tags are rendered as they are registered
|
|
239
|
-
* (besides some special tags).
|
|
240
|
-
*
|
|
241
|
-
* The following special tags have default priorities:
|
|
242
|
-
* -2 `<meta charset ...>`
|
|
243
|
-
* -1 `<base>`
|
|
244
|
-
* 0 `<meta http-equiv="content-security-policy" ...>`
|
|
245
|
-
*
|
|
246
|
-
* All other tags have a default priority of 10: `<meta>`, `<script>`, `<link>`, `<style>`, etc
|
|
247
|
-
*/
|
|
248
|
-
tagPriority?: number | 'critical' | 'high' | 'low' | `before:${string}` | `after:${string}`;
|
|
249
|
-
}
|
|
250
|
-
type TagUserProperties = ResolvableValues<TagPriority & TagPosition & InnerContent & ResolvesDuplicates & ProcessesTemplateParams>;
|
|
251
|
-
type TagKey = keyof Head;
|
|
252
|
-
type TemplateParams = {
|
|
253
|
-
separator?: '|' | '-' | '·' | string;
|
|
254
|
-
} & Record<string, null | string | Record<string, string>>;
|
|
255
|
-
interface ProcessesTemplateParams {
|
|
256
|
-
processTemplateParams?: boolean;
|
|
257
|
-
}
|
|
258
|
-
interface HasTemplateParams {
|
|
259
|
-
templateParams?: TemplateParams;
|
|
260
|
-
}
|
|
261
|
-
interface HeadTag extends TagPriority, TagPosition, ResolvesDuplicates, HasTemplateParams {
|
|
262
|
-
tag: TagKey;
|
|
263
|
-
props: Record<string, string>;
|
|
264
|
-
processTemplateParams?: boolean;
|
|
265
|
-
innerHTML?: string;
|
|
266
|
-
textContent?: string;
|
|
267
|
-
/**
|
|
268
|
-
* Entry ID
|
|
269
|
-
* @internal
|
|
270
|
-
*/
|
|
271
|
-
_e?: number;
|
|
272
|
-
/**
|
|
273
|
-
* Position
|
|
274
|
-
* @internal
|
|
275
|
-
*/
|
|
276
|
-
_p?: number;
|
|
277
|
-
/**
|
|
278
|
-
* Dedupe key
|
|
279
|
-
* @internal
|
|
280
|
-
*/
|
|
281
|
-
_d?: string;
|
|
282
|
-
/**
|
|
283
|
-
* Hash code used to represent the tag.
|
|
284
|
-
* @internal
|
|
285
|
-
*/
|
|
286
|
-
_h?: string;
|
|
287
|
-
/**
|
|
288
|
-
* @internal
|
|
289
|
-
*/
|
|
290
|
-
_m?: RuntimeMode;
|
|
291
|
-
/**
|
|
292
|
-
* @internal
|
|
293
|
-
*/
|
|
294
|
-
_eventHandlers?: Record<string, ((e: Event) => Record<string, any> | void)>;
|
|
295
|
-
}
|
|
296
|
-
type HeadTagKeys = (keyof HeadTag)[];
|
|
297
|
-
|
|
298
|
-
type HookResult = Promise<void> | void;
|
|
299
|
-
interface SSRHeadPayload {
|
|
300
|
-
headTags: string;
|
|
301
|
-
bodyTags: string;
|
|
302
|
-
bodyTagsOpen: string;
|
|
303
|
-
htmlAttrs: string;
|
|
304
|
-
bodyAttrs: string;
|
|
305
|
-
}
|
|
306
|
-
interface RenderSSRHeadOptions {
|
|
307
|
-
omitLineBreaks?: boolean;
|
|
308
|
-
}
|
|
309
|
-
interface EntryResolveCtx<T> {
|
|
310
|
-
tags: HeadTag[];
|
|
311
|
-
entries: HeadEntry<T>[];
|
|
312
|
-
}
|
|
313
|
-
interface DomRenderTagContext {
|
|
314
|
-
id: string;
|
|
315
|
-
$el: Element;
|
|
316
|
-
shouldRender: boolean;
|
|
317
|
-
tag: HeadTag;
|
|
318
|
-
entry?: HeadEntry<any>;
|
|
319
|
-
markSideEffect: (key: string, fn: () => void) => void;
|
|
320
|
-
}
|
|
321
|
-
interface DomBeforeRenderCtx extends ShouldRenderContext {
|
|
322
|
-
/**
|
|
323
|
-
* @deprecated will always be empty, prefer other hooks
|
|
324
|
-
*/
|
|
325
|
-
tags: DomRenderTagContext[];
|
|
326
|
-
}
|
|
327
|
-
interface ShouldRenderContext {
|
|
328
|
-
shouldRender: boolean;
|
|
329
|
-
}
|
|
330
|
-
interface SSRRenderContext {
|
|
331
|
-
tags: HeadTag[];
|
|
332
|
-
html: SSRHeadPayload;
|
|
333
|
-
}
|
|
334
|
-
interface HeadHooks {
|
|
335
|
-
'init': (ctx: Unhead<any>) => HookResult;
|
|
336
|
-
'entries:updated': (ctx: Unhead<any>) => HookResult;
|
|
337
|
-
'entries:resolve': (ctx: EntryResolveCtx<any>) => HookResult;
|
|
338
|
-
'tag:normalise': (ctx: {
|
|
339
|
-
tag: HeadTag;
|
|
340
|
-
entry: HeadEntry<any>;
|
|
341
|
-
resolvedOptions: CreateClientHeadOptions;
|
|
342
|
-
}) => HookResult;
|
|
343
|
-
'tags:beforeResolve': (ctx: {
|
|
344
|
-
tags: HeadTag[];
|
|
345
|
-
}) => HookResult;
|
|
346
|
-
'tags:resolve': (ctx: {
|
|
347
|
-
tags: HeadTag[];
|
|
348
|
-
}) => HookResult;
|
|
349
|
-
'tags:afterResolve': (ctx: {
|
|
350
|
-
tags: HeadTag[];
|
|
351
|
-
}) => HookResult;
|
|
352
|
-
'dom:beforeRender': (ctx: DomBeforeRenderCtx) => HookResult;
|
|
353
|
-
'dom:renderTag': (ctx: DomRenderTagContext, document: Document, track: any) => HookResult;
|
|
354
|
-
'dom:rendered': (ctx: {
|
|
355
|
-
renders: DomRenderTagContext[];
|
|
356
|
-
}) => HookResult;
|
|
357
|
-
'ssr:beforeRender': (ctx: ShouldRenderContext) => HookResult;
|
|
358
|
-
'ssr:render': (ctx: {
|
|
359
|
-
tags: HeadTag[];
|
|
360
|
-
}) => HookResult;
|
|
361
|
-
'ssr:rendered': (ctx: SSRRenderContext) => HookResult;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
interface RenderDomHeadOptions {
|
|
365
|
-
/**
|
|
366
|
-
* Document to use for rendering. Allows stubbing for testing.
|
|
367
|
-
*/
|
|
368
|
-
document?: Document;
|
|
369
|
-
}
|
|
370
|
-
interface DomPluginOptions extends RenderDomHeadOptions {
|
|
371
|
-
render: ((head: Unhead<any>) => void);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Side effects are mapped with a key and their cleanup function.
|
|
376
|
-
*
|
|
377
|
-
* For example, `meta:data-h-4h46h465`: () => { document.querySelector('meta[data-h-4h46h465]').remove() }
|
|
378
|
-
*/
|
|
379
|
-
type SideEffectsRecord = Record<string, () => void>;
|
|
380
|
-
type RuntimeMode = 'server' | 'client';
|
|
381
|
-
interface HeadEntry<Input> {
|
|
382
|
-
/**
|
|
383
|
-
* User provided input for the entry.
|
|
384
|
-
*/
|
|
385
|
-
input: Input;
|
|
386
|
-
/**
|
|
387
|
-
* Optional resolved input which will be used if set.
|
|
388
|
-
*/
|
|
389
|
-
resolvedInput?: Input;
|
|
390
|
-
/**
|
|
391
|
-
* The mode that the entry should be used in.
|
|
392
|
-
*
|
|
393
|
-
* @internal
|
|
394
|
-
*/
|
|
395
|
-
mode?: RuntimeMode;
|
|
396
|
-
/**
|
|
397
|
-
* Transformer function for the entry.
|
|
398
|
-
*
|
|
399
|
-
* @internal
|
|
400
|
-
*/
|
|
401
|
-
transform?: (input: Input) => Input;
|
|
402
|
-
/**
|
|
403
|
-
* Head entry index
|
|
404
|
-
*
|
|
405
|
-
* @internal
|
|
406
|
-
*/
|
|
407
|
-
_i: number;
|
|
408
|
-
/**
|
|
409
|
-
* Default tag position.
|
|
410
|
-
*
|
|
411
|
-
* @internal
|
|
412
|
-
*/
|
|
413
|
-
tagPosition?: TagPosition['tagPosition'];
|
|
414
|
-
/**
|
|
415
|
-
* Default tag priority.
|
|
416
|
-
*
|
|
417
|
-
* @internal
|
|
418
|
-
*/
|
|
419
|
-
tagPriority?: TagPriority['tagPriority'];
|
|
420
|
-
}
|
|
421
|
-
type HeadPluginOptions = Omit<CreateHeadOptions, 'plugins'> & {
|
|
422
|
-
mode?: RuntimeMode;
|
|
423
|
-
};
|
|
424
|
-
type HeadPluginInput = (HeadPluginOptions & {
|
|
425
|
-
key?: string;
|
|
426
|
-
}) | ((head: Unhead) => HeadPluginOptions & {
|
|
427
|
-
key?: string;
|
|
428
|
-
});
|
|
429
|
-
type HeadPlugin = HeadPluginOptions & {
|
|
430
|
-
key?: string;
|
|
431
|
-
};
|
|
432
|
-
/**
|
|
433
|
-
* An active head entry provides an API to manipulate it.
|
|
434
|
-
*/
|
|
435
|
-
interface ActiveHeadEntry<Input> {
|
|
436
|
-
/**
|
|
437
|
-
* Updates the entry with new input.
|
|
438
|
-
*
|
|
439
|
-
* Will first clear any side effects for previous input.
|
|
440
|
-
*/
|
|
441
|
-
patch: (input: Input) => void;
|
|
442
|
-
/**
|
|
443
|
-
* Dispose the entry, removing it from the active head.
|
|
444
|
-
*
|
|
445
|
-
* Will queue side effects for removal.
|
|
446
|
-
*/
|
|
447
|
-
dispose: () => void;
|
|
448
|
-
}
|
|
449
|
-
interface CreateHeadOptions {
|
|
450
|
-
document?: Document;
|
|
451
|
-
plugins?: HeadPluginInput[];
|
|
452
|
-
hooks?: NestedHooks<HeadHooks>;
|
|
453
|
-
/**
|
|
454
|
-
* Disable the Capo.js tag sorting algorithm.
|
|
455
|
-
*
|
|
456
|
-
* This is added to make the v1 -> v2 migration easier allowing users to opt-out of the new sorting algorithm.
|
|
457
|
-
*/
|
|
458
|
-
disableCapoSorting?: boolean;
|
|
459
|
-
}
|
|
460
|
-
interface CreateClientHeadOptions extends CreateHeadOptions {
|
|
461
|
-
/**
|
|
462
|
-
* Options to pass to the DomPlugin.
|
|
463
|
-
*/
|
|
464
|
-
domOptions?: DomPluginOptions;
|
|
465
|
-
}
|
|
466
|
-
interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplateParams, ResolvesDuplicates {
|
|
467
|
-
mode?: RuntimeMode;
|
|
468
|
-
transform?: (input: unknown) => unknown;
|
|
469
|
-
head?: Unhead;
|
|
470
|
-
}
|
|
471
|
-
interface Unhead<Input extends Record<string, any> = Head> {
|
|
472
|
-
/**
|
|
473
|
-
* Registered plugins.
|
|
474
|
-
*/
|
|
475
|
-
plugins: HeadPlugin[];
|
|
476
|
-
/**
|
|
477
|
-
* The active head entries.
|
|
478
|
-
*/
|
|
479
|
-
headEntries: () => HeadEntry<Input>[];
|
|
480
|
-
/**
|
|
481
|
-
* Create a new head entry.
|
|
482
|
-
*/
|
|
483
|
-
push: (entry: Input, options?: HeadEntryOptions) => ActiveHeadEntry<Input>;
|
|
484
|
-
/**
|
|
485
|
-
* Resolve tags from head entries.
|
|
486
|
-
*/
|
|
487
|
-
resolveTags: () => Promise<HeadTag[]>;
|
|
488
|
-
/**
|
|
489
|
-
* Exposed hooks for easier extension.
|
|
490
|
-
*/
|
|
491
|
-
hooks: Hookable<HeadHooks>;
|
|
492
|
-
/**
|
|
493
|
-
* Resolved options
|
|
494
|
-
*/
|
|
495
|
-
resolvedOptions: CreateHeadOptions;
|
|
496
|
-
/**
|
|
497
|
-
* Use a head plugin, loads the plugins hooks.
|
|
498
|
-
*/
|
|
499
|
-
use: (plugin: HeadPluginInput) => void;
|
|
500
|
-
/**
|
|
501
|
-
* Is it a server-side render context.
|
|
502
|
-
*/
|
|
503
|
-
ssr: boolean;
|
|
504
|
-
/**
|
|
505
|
-
* @internal
|
|
506
|
-
*/
|
|
507
|
-
_dom?: DomState;
|
|
508
|
-
/**
|
|
509
|
-
* @internal
|
|
510
|
-
*/
|
|
511
|
-
_domUpdatePromise?: Promise<void>;
|
|
512
|
-
/**
|
|
513
|
-
* @internal
|
|
514
|
-
*/
|
|
515
|
-
dirty: boolean;
|
|
516
|
-
/**
|
|
517
|
-
* @internal
|
|
518
|
-
*/
|
|
519
|
-
_scripts?: Record<string, any>;
|
|
520
|
-
/**
|
|
521
|
-
* @internal
|
|
522
|
-
*/
|
|
523
|
-
_templateParams?: TemplateParams;
|
|
524
|
-
/**
|
|
525
|
-
* @internal
|
|
526
|
-
*/
|
|
527
|
-
_separator?: string;
|
|
528
|
-
}
|
|
529
|
-
interface DomState {
|
|
530
|
-
pendingSideEffects: SideEffectsRecord;
|
|
531
|
-
sideEffects: SideEffectsRecord;
|
|
532
|
-
elMap: Record<string, Element>;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
type SafeBodyAttr = Pick<BodyAttr, 'id' | 'class'> & DataKeys;
|
|
536
|
-
type SafeHtmlAttr = Pick<HtmlAttr, 'id' | 'class' | 'lang' | 'dir'> & DataKeys;
|
|
537
|
-
type SafeMeta = Pick<Meta, 'id' | 'name' | 'property' | 'content' | 'charset'> & DataKeys;
|
|
538
|
-
type SafeLink = Pick<Link, 'color' | 'crossorigin' | 'fetchpriority' | 'href' | 'hreflang' | 'imagesizes' | 'imagesrcset' | 'integrity' | 'media' | 'referrerpolicy' | 'sizes' | 'id'> & {
|
|
539
|
-
rel?: Omit<Link['rel'], 'stylesheet' | 'canonical' | 'modulepreload' | 'prerender' | 'preload' | 'prefetch'>;
|
|
540
|
-
type?: 'audio/aac' | 'application/x-abiword' | 'application/x-freearc' | 'image/avif' | 'video/x-msvideo' | 'application/vnd.amazon.ebook' | 'application/octet-stream' | 'image/bmp' | 'application/x-bzip' | 'application/x-bzip2' | 'application/x-cdf' | 'application/x-csh' | 'text/csv' | 'application/msword' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.ms-fontobject' | 'application/epub+zip' | 'application/gzip' | 'image/gif' | 'image/vnd.microsoft.icon' | 'text/calendar' | 'application/java-archive' | 'image/jpeg' | 'application/json' | 'application/ld+json' | 'audio/midi' | 'audio/x-midi' | 'audio/mpeg' | 'video/mp4' | 'video/mpeg' | 'application/vnd.apple.installer+xml' | 'application/vnd.oasis.opendocument.presentation' | 'application/vnd.oasis.opendocument.spreadsheet' | 'application/vnd.oasis.opendocument.text' | 'audio/ogg' | 'video/ogg' | 'application/ogg' | 'audio/opus' | 'font/otf' | 'image/png' | 'application/pdf' | 'application/x-httpd-php' | 'application/vnd.ms-powerpoint' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 'application/vnd.rar' | 'application/rtf' | 'application/x-sh' | 'image/svg+xml' | 'application/x-tar' | 'image/tiff' | 'video/mp2t' | 'font/ttf' | 'text/plain' | 'application/vnd.visio' | 'audio/wav' | 'audio/webm' | 'video/webm' | 'image/webp' | 'font/woff' | 'font/woff2' | 'application/xhtml+xml' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'text/xml' | 'application/atom+xml' | 'application/xml' | 'application/vnd.mozilla.xul+xml' | 'application/zip' | 'video/3gpp' | 'audio/3gpp' | 'video/3gpp2' | 'audio/3gpp2' | (string & Record<never, never>);
|
|
541
|
-
} & DataKeys;
|
|
542
|
-
type SafeScript = Pick<Script, 'id' | 'textContent'> & {
|
|
543
|
-
type: 'application/json' | 'application/ld+json';
|
|
544
|
-
} & DataKeys;
|
|
545
|
-
type SafeNoscript = Pick<Noscript, 'id' | 'textContent'> & DataKeys;
|
|
546
|
-
interface HeadSafe extends Pick<Head, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
547
|
-
meta?: SafeMeta[];
|
|
548
|
-
link?: SafeLink[];
|
|
549
|
-
noscript?: SafeNoscript[];
|
|
550
|
-
script?: SafeScript[];
|
|
551
|
-
htmlAttrs?: SafeHtmlAttr;
|
|
552
|
-
bodyAttrs?: SafeBodyAttr;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
export type { ActiveHeadEntry, Base, BaseBodyAttr, BaseHtmlAttr, BaseMeta, BodyAttr, BodyAttributes, CreateClientHeadOptions, CreateHeadOptions, DomBeforeRenderCtx, DomPluginOptions, DomRenderTagContext, DomState, EntryAugmentation, EntryResolveCtx, Falsey, HasTemplateParams, Head, HeadEntry, HeadEntryOptions, HeadHooks, HeadPlugin, HeadPluginInput, HeadPluginOptions, HeadSafe, HeadTag, HeadTagKeys, HeadUtils, HookResult, HtmlAttr, HtmlAttributes, InnerContent, InnerContentVal, Link, MaybeArray, MaybeEventFnHandlers, MaybeFunction, Meta, Never, Noscript, ProcessesTemplateParams, RenderDomHeadOptions, RenderSSRHeadOptions, ResolvableValues, ResolvedBase, ResolvedBodyAttributes, ResolvedHead, ResolvedHtmlAttributes, ResolvedLink, ResolvedMeta, ResolvedNoscript, ResolvedSchemaAugmentations, ResolvedScript, ResolvedStyle, ResolvedTitle, ResolvedTitleTemplate, ResolvesDuplicates, RuntimeMode, SSRHeadPayload, SSRRenderContext, SafeBodyAttr, SafeHtmlAttr, SafeLink, SafeMeta, SafeNoscript, SafeScript, SchemaAugmentations, Script, ShouldRenderContext, SideEffectsRecord, Style, TagKey, TagPosition, TagPriority, TagUserProperties, TemplateParams, Title, TitleTemplate, Unhead, UseSeoMetaInput, UserAttributesConfig, UserTagConfigWithoutInnerContent, ValidTagPositions };
|
|
1
|
+
export * from 'unhead/types';
|