@unhead/schema 0.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 ADDED
@@ -0,0 +1,16 @@
1
+ # `@unhead/schema`
2
+
3
+ Typescript definitions for document `<head>`.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install --save-dev @unhead/schema
9
+
10
+ # Using yarn
11
+ yarn add --dev @unhead/schema
12
+ ```
13
+
14
+ ## Types
15
+
16
+ See [head.ts](./src/head.ts) for the full list of types.
@@ -0,0 +1,185 @@
1
+ import { HeadTag as HeadTag$1, MergeHead, Merge, Base as Base$1, DefinedValueOrEmptyObject, Link as Link$1, DataKeys, Style as Style$1, Script as Script$1, Noscript as Noscript$1, HtmlAttributes as HtmlAttributes$1, BodyAttributes as BodyAttributes$1, Meta as Meta$1, Stringable } from '@zhead/schema';
2
+ export { MergeHead, TagKey } from '@zhead/schema';
3
+
4
+ interface ResolvesDuplicates {
5
+ /**
6
+ * By default, tags which share the same unique key `name, `property` are de-duped. To allow duplicates
7
+ * to be made you can provide a unique key for each entry.
8
+ */
9
+ key?: string;
10
+ /**
11
+ * Specify where to render the tag.
12
+ *
13
+ * @default 'head'
14
+ */
15
+ tagDuplicateStrategy?: 'replace' | 'merge';
16
+ }
17
+ interface TagPosition {
18
+ /**
19
+ * Specify where to render the tag.
20
+ *
21
+ * @default 'head'
22
+ */
23
+ tagPosition?: 'head' | 'bodyClose' | 'bodyOpen';
24
+ }
25
+ interface InnerContent {
26
+ /**
27
+ * Text content of the tag.
28
+ *
29
+ * Alias for children
30
+ */
31
+ innerHTML?: string;
32
+ /**
33
+ * Sets the textContent of an element.
34
+ */
35
+ children?: string;
36
+ /**
37
+ * Sets the textContent of an element. This will be HTML encoded.
38
+ *
39
+ * Alias for children
40
+ */
41
+ textContent?: string;
42
+ }
43
+ interface TagPriority {
44
+ /**
45
+ * The priority for rendering the tag, without this all tags are rendered as they are registered
46
+ * (besides some special tags).
47
+ *
48
+ * The following special tags have default priorities:
49
+ * * -2 <meta charset ...>
50
+ * * -1 <base>
51
+ * * 0 <meta http-equiv="content-security-policy" ...>
52
+ *
53
+ * All other tags have a default priority of 10: <meta>, <script>, <link>, <style>, etc
54
+ */
55
+ tagPriority?: number | `before:${string}` | `after:${string}`;
56
+ }
57
+ declare type TagUserProperties = TagPriority & TagPosition & InnerContent & ResolvesDuplicates;
58
+ interface TagInternalProperties {
59
+ /**
60
+ * Entry ID
61
+ */
62
+ _e?: number;
63
+ /**
64
+ * Position
65
+ */
66
+ _p?: number;
67
+ /**
68
+ * Hash id used as a selector
69
+ */
70
+ _s?: string;
71
+ /**
72
+ * Dedupe key
73
+ */
74
+ _d?: string;
75
+ }
76
+ declare type HeadTag = HeadTag$1 & TagUserProperties & TagInternalProperties;
77
+ declare type HeadTagKeys = (keyof HeadTag)[];
78
+
79
+ declare type Never<T> = {
80
+ [P in keyof T]?: never;
81
+ };
82
+ declare type UserTagConfigWithoutInnerContent = TagPriority & TagPosition & ResolvesDuplicates & Never<InnerContent>;
83
+ declare type UserAttributesConfig = ResolvesDuplicates & Never<InnerContent & TagPriority & TagPosition>;
84
+ interface SchemaAugmentations extends MergeHead {
85
+ base: UserAttributesConfig;
86
+ htmlAttrs: UserAttributesConfig;
87
+ bodyAttrs: UserAttributesConfig;
88
+ link: UserTagConfigWithoutInnerContent;
89
+ meta: UserTagConfigWithoutInnerContent;
90
+ style: TagUserProperties;
91
+ script: TagUserProperties;
92
+ noscript: TagUserProperties;
93
+ }
94
+ declare type MaybeArray<T> = T | T[];
95
+ interface BaseMeta extends Omit<Meta$1, 'content'> {
96
+ /**
97
+ * This attribute contains the value for the http-equiv, name or property attribute, depending on which is used.
98
+ *
99
+ * You can provide an array of values to create multiple tags sharing the same name, property or http-equiv.
100
+ *
101
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-content
102
+ */
103
+ content?: MaybeArray<Stringable>;
104
+ }
105
+ declare type EntryAugmentation = undefined | Record<string, any>;
106
+ declare type Title = string;
107
+ declare type TitleTemplate = string | null | ((title?: string) => string);
108
+ declare type Base<E extends EntryAugmentation = {}> = Partial<Merge<SchemaAugmentations['base'], Base$1>> & DefinedValueOrEmptyObject<E>;
109
+ declare type Link<E extends EntryAugmentation = {}> = Link$1 & DataKeys & SchemaAugmentations['link'] & DefinedValueOrEmptyObject<E>;
110
+ declare type Meta<E extends EntryAugmentation = {}> = BaseMeta & DataKeys & SchemaAugmentations['meta'] & DefinedValueOrEmptyObject<E>;
111
+ declare type Style<E extends EntryAugmentation = {}> = Style$1 & DataKeys & SchemaAugmentations['style'] & DefinedValueOrEmptyObject<E>;
112
+ declare type Script<E extends EntryAugmentation = {}> = Script$1 & DataKeys & SchemaAugmentations['script'] & DefinedValueOrEmptyObject<E>;
113
+ declare type Noscript<E extends EntryAugmentation = {}> = Noscript$1 & DataKeys & SchemaAugmentations['noscript'] & DefinedValueOrEmptyObject<E>;
114
+ declare type HtmlAttributes<E extends EntryAugmentation = {}> = HtmlAttributes$1 & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>;
115
+ declare type BodyAttributes<E extends EntryAugmentation = {}> = BodyAttributes$1 & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>;
116
+ interface Head<E extends MergeHead = SchemaAugmentations> {
117
+ /**
118
+ * The <title> HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
119
+ * It only contains text; tags within the element are ignored.
120
+ *
121
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
122
+ */
123
+ title?: Title;
124
+ /**
125
+ * Generate the title from a template.
126
+ *
127
+ * Should include a `%s` placeholder for the title, for example `%s - My Site`.
128
+ */
129
+ titleTemplate?: TitleTemplate;
130
+ /**
131
+ * The <base> HTML element specifies the base URL to use for all relative URLs in a document.
132
+ * There can be only one <base> element in a document.
133
+ *
134
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
135
+ */
136
+ base?: Base<E['base']>;
137
+ /**
138
+ * The <link> HTML element specifies relationships between the current document and an external resource.
139
+ * This element is most commonly used to link to stylesheets, but is also used to establish site icons
140
+ * (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
141
+ *
142
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
143
+ */
144
+ link?: Link<E['link']>[];
145
+ /**
146
+ * The <meta> element represents metadata that cannot be expressed in other HTML elements, like <link> or <script>.
147
+ *
148
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
149
+ */
150
+ meta?: Meta<E['meta']>[];
151
+ /**
152
+ * The <style> HTML element contains style information for a document, or part of a document.
153
+ * It contains CSS, which is applied to the contents of the document containing the <style> element.
154
+ *
155
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
156
+ */
157
+ style?: Style<E['style']>[];
158
+ /**
159
+ * The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
160
+ *
161
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
162
+ */
163
+ script?: Script<E['script']>[];
164
+ /**
165
+ * The <noscript> HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
166
+ * or if scripting is currently turned off in the browser.
167
+ *
168
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
169
+ */
170
+ noscript?: Noscript<E['noscript']>[];
171
+ /**
172
+ * Attributes for the <html> HTML element.
173
+ *
174
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
175
+ */
176
+ htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
177
+ /**
178
+ * Attributes for the <body> HTML element.
179
+ *
180
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
181
+ */
182
+ bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
183
+ }
184
+
185
+ export { Base, BodyAttributes, EntryAugmentation, Head, HeadTag, HeadTagKeys, HtmlAttributes, InnerContent, Link, Meta, Never, Noscript, ResolvesDuplicates, SchemaAugmentations, Script, Style, TagInternalProperties, TagPosition, TagPriority, TagUserProperties, Title, TitleTemplate, UserAttributesConfig, UserTagConfigWithoutInnerContent };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { MergeHead } from '@zhead/schema';
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@unhead/schema",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "packageManager": "pnpm@7.14.0",
6
+ "author": "Harlan Wilton <harlan@harlanzw.com>",
7
+ "license": "MIT",
8
+ "funding": "https://github.com/sponsors/harlan-zw",
9
+ "homepage": "https://github.com/harlan-zw/unhead#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/harlan-zw/unhead.git",
13
+ "directory": "packages/schema"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/harlan-zw/unhead/issues"
17
+ },
18
+ "keywords": [
19
+ "head",
20
+ "meta tags",
21
+ "types"
22
+ ],
23
+ "sideEffects": false,
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.mjs"
28
+ }
29
+ },
30
+ "module": "dist/index.mjs",
31
+ "types": "dist/index.d.ts",
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "dependencies": {
36
+ "@zhead/schema": "1.0.0-beta.4"
37
+ },
38
+ "scripts": {
39
+ "build": "unbuild .",
40
+ "stub": "unbuild . --stub"
41
+ }
42
+ }