@unhead/react 2.0.0-alpha.16 → 2.0.0-alpha.18

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/client.d.mts CHANGED
@@ -1,14 +1,13 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as unhead_types from 'unhead/types';
4
- import { MergeHead, CreateClientHeadOptions } from 'unhead/types';
4
+ import { CreateClientHeadOptions, Unhead } from 'unhead/types';
5
5
  export { renderDOMHead } from 'unhead/client';
6
- import { R as ReactUnhead } from './shared/react.Cz8ob63p.mjs';
7
6
 
8
- declare function createHead<T extends MergeHead>(options?: Omit<CreateClientHeadOptions, 'propResolvers'>): ReactUnhead<T>;
7
+ declare function createHead(options?: CreateClientHeadOptions): Unhead;
9
8
  declare function UnheadProvider({ children, head }: {
10
9
  children: ReactNode;
11
10
  head?: ReturnType<typeof createHead>;
12
- }): react.FunctionComponentElement<react.ProviderProps<unhead_types.Unhead<any> | null>>;
11
+ }): react.FunctionComponentElement<react.ProviderProps<Unhead<unhead_types.Head<unhead_types.SchemaAugmentations>> | null>>;
13
12
 
14
13
  export { UnheadProvider, createHead };
package/dist/client.d.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as unhead_types from 'unhead/types';
4
- import { MergeHead, CreateClientHeadOptions } from 'unhead/types';
4
+ import { CreateClientHeadOptions, Unhead } from 'unhead/types';
5
5
  export { renderDOMHead } from 'unhead/client';
6
- import { R as ReactUnhead } from './shared/react.Cz8ob63p.js';
7
6
 
8
- declare function createHead<T extends MergeHead>(options?: Omit<CreateClientHeadOptions, 'propResolvers'>): ReactUnhead<T>;
7
+ declare function createHead(options?: CreateClientHeadOptions): Unhead;
9
8
  declare function UnheadProvider({ children, head }: {
10
9
  children: ReactNode;
11
10
  head?: ReturnType<typeof createHead>;
12
- }): react.FunctionComponentElement<react.ProviderProps<unhead_types.Unhead<any> | null>>;
11
+ }): react.FunctionComponentElement<react.ProviderProps<Unhead<unhead_types.Head<unhead_types.SchemaAugmentations>> | null>>;
13
12
 
14
13
  export { UnheadProvider, createHead };
package/dist/client.mjs CHANGED
@@ -8,15 +8,7 @@ function createHead(options = {}) {
8
8
  domOptions: {
9
9
  render: createDebouncedFn(() => renderDOMHead(head), (fn) => setTimeout(fn, 0))
10
10
  },
11
- ...options,
12
- propResolvers: [
13
- (_, r) => {
14
- if (typeof r === "object" && "current" in r) {
15
- return r.current;
16
- }
17
- return r;
18
- }
19
- ]
11
+ ...options
20
12
  });
21
13
  return head;
22
14
  }
package/dist/index.d.mts CHANGED
@@ -1,10 +1,8 @@
1
1
  import react__default, { ReactNode } from 'react';
2
- import * as unhead_types from 'unhead/types';
3
- import { MergeHead, HeadEntryOptions, ActiveHeadEntry, HeadSafe } from 'unhead/types';
4
- import { U as UseHeadInput, a as UseSeoMetaInput } from './shared/react.Cz8ob63p.mjs';
2
+ import { UseHeadInput, HeadEntryOptions, ActiveHeadEntry, HeadSafe, UseScriptInput, UseScriptOptions, UseScriptReturn, UseSeoMetaInput, Unhead } from 'unhead/types';
5
3
 
6
4
  declare const hookImports: {
7
- '@unhead/vue': string[];
5
+ '@unhead/react': string[];
8
6
  };
9
7
 
10
8
  interface HeadProps {
@@ -13,9 +11,10 @@ interface HeadProps {
13
11
  }
14
12
  declare const Head: react__default.FC<HeadProps>;
15
13
 
16
- declare function useUnhead(): unhead_types.Unhead<any>;
17
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>>;
18
- declare function useHeadSafe(input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
19
- declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
14
+ declare function useUnhead(): Unhead;
15
+ declare function useHead(input?: UseHeadInput, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput>;
16
+ declare function useHeadSafe(input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
17
+ declare function useSeoMeta(input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
18
+ declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptReturn<T>;
20
19
 
21
- export { Head, hookImports, useHead, useHeadSafe, useSeoMeta, useUnhead };
20
+ export { Head, hookImports, useHead, useHeadSafe, useScript, useSeoMeta, useUnhead };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import react__default, { ReactNode } from 'react';
2
- import * as unhead_types from 'unhead/types';
3
- import { MergeHead, HeadEntryOptions, ActiveHeadEntry, HeadSafe } from 'unhead/types';
4
- import { U as UseHeadInput, a as UseSeoMetaInput } from './shared/react.Cz8ob63p.js';
2
+ import { UseHeadInput, HeadEntryOptions, ActiveHeadEntry, HeadSafe, UseScriptInput, UseScriptOptions, UseScriptReturn, UseSeoMetaInput, Unhead } from 'unhead/types';
5
3
 
6
4
  declare const hookImports: {
7
- '@unhead/vue': string[];
5
+ '@unhead/react': string[];
8
6
  };
9
7
 
10
8
  interface HeadProps {
@@ -13,9 +11,10 @@ interface HeadProps {
13
11
  }
14
12
  declare const Head: react__default.FC<HeadProps>;
15
13
 
16
- declare function useUnhead(): unhead_types.Unhead<any>;
17
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>>;
18
- declare function useHeadSafe(input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
19
- declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
14
+ declare function useUnhead(): Unhead;
15
+ declare function useHead(input?: UseHeadInput, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput>;
16
+ declare function useHeadSafe(input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
17
+ declare function useSeoMeta(input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
18
+ declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptReturn<T>;
20
19
 
21
- export { Head, hookImports, useHead, useHeadSafe, useSeoMeta, useUnhead };
20
+ export { Head, hookImports, useHead, useHeadSafe, useScript, useSeoMeta, useUnhead };
package/dist/index.mjs CHANGED
@@ -1,17 +1,15 @@
1
- import React, { useContext, useEffect, useRef } from 'react';
1
+ import React, { useEffect, useContext, useState, useRef } from 'react';
2
2
  import { ValidHeadTags, TagsWithInnerContent, HasElementTags } from 'unhead/utils';
3
- import { SafeInputPlugin, FlatMetaPlugin } from 'unhead/plugins';
3
+ import { useScript as useScript$1, useHead as useHead$1, useHeadSafe as useHeadSafe$1, useSeoMeta as useSeoMeta$1 } from 'unhead';
4
4
  import { U as UnheadContext } from './shared/react.DF9T1fqs.mjs';
5
5
 
6
6
  const hookImports = {
7
- "@unhead/vue": [
7
+ "@unhead/react": [
8
8
  "useUnhead",
9
9
  "useHead",
10
10
  "useSeoMeta",
11
11
  "useHeadSafe",
12
- "useServerHead",
13
- "useServerSeoMeta",
14
- "useServerHeadSafe"
12
+ "useServerHead"
15
13
  ]
16
14
  };
17
15
 
@@ -22,34 +20,81 @@ function useUnhead() {
22
20
  }
23
21
  return instance;
24
22
  }
25
- function useHead(input, options = {}) {
26
- const head = options.head || useUnhead();
27
- const entry = head.push(input, options);
23
+ function withSideEffects(input, options, fn) {
24
+ const unhead = options.head || useUnhead();
25
+ const [entry] = useState(() => fn(unhead, input, options));
28
26
  useEffect(() => {
29
27
  entry.patch(input);
30
28
  }, [input]);
31
29
  useEffect(() => {
32
30
  return () => {
33
- entry?.dispose();
31
+ entry.dispose();
34
32
  };
35
33
  }, []);
36
34
  return entry;
37
35
  }
38
- function useHeadSafe(input, options = {}) {
39
- const head = options.head || useUnhead();
40
- head.use(SafeInputPlugin);
41
- options._safe = true;
42
- return useHead(input, options);
36
+ function useHead(input = {}, options = {}) {
37
+ return withSideEffects(input, options, useHead$1);
43
38
  }
44
- function useSeoMeta(input, options = {}) {
45
- const head = options.head || useUnhead();
46
- head.use(FlatMetaPlugin);
47
- const { title, titleTemplate, ...meta } = input;
48
- return useHead({
49
- title,
50
- titleTemplate,
51
- _flatMeta: meta
52
- }, options);
39
+ function useHeadSafe(input = {}, options = {}) {
40
+ return withSideEffects(input, options, useHeadSafe$1);
41
+ }
42
+ function useSeoMeta(input = {}, options = {}) {
43
+ return withSideEffects(input, options, useSeoMeta$1);
44
+ }
45
+ function useScript(_input, _options) {
46
+ const input = typeof _input === "string" ? { src: _input } : _input;
47
+ const options = _options || {};
48
+ const head = options?.head || useUnhead();
49
+ options.head = head;
50
+ const mountCbs = [];
51
+ let isMounted = false;
52
+ useEffect(() => {
53
+ isMounted = true;
54
+ mountCbs.forEach((i) => i());
55
+ return () => {
56
+ isMounted = false;
57
+ };
58
+ }, []);
59
+ if (typeof options.trigger === "undefined") {
60
+ options.trigger = (load) => {
61
+ if (isMounted) {
62
+ load();
63
+ } else {
64
+ mountCbs.push(load);
65
+ }
66
+ };
67
+ }
68
+ const script = useScript$1(head, input, options);
69
+ const sideEffects = [];
70
+ useEffect(() => {
71
+ return () => {
72
+ script._triggerAbortController?.abort();
73
+ sideEffects.forEach((i) => i());
74
+ };
75
+ }, []);
76
+ const _registerCb = (key, cb) => {
77
+ let i;
78
+ const destroy = () => {
79
+ if (i) {
80
+ script._cbs[key]?.splice(i - 1, 1);
81
+ i = null;
82
+ }
83
+ };
84
+ mountCbs.push(() => {
85
+ if (!script._cbs[key]) {
86
+ cb(script.instance);
87
+ return () => {
88
+ };
89
+ }
90
+ i = script._cbs[key].push(cb);
91
+ sideEffects.push(destroy);
92
+ return destroy;
93
+ });
94
+ };
95
+ script.onLoaded = (cb) => _registerCb("loaded", cb);
96
+ script.onError = (cb) => _registerCb("error", cb);
97
+ return script;
53
98
  }
54
99
 
55
100
  const Head = ({ children, titleTemplate }) => {
@@ -94,4 +139,4 @@ const Head = ({ children, titleTemplate }) => {
94
139
  return null;
95
140
  };
96
141
 
97
- export { Head, hookImports, useHead, useHeadSafe, useSeoMeta, useUnhead };
142
+ export { Head, hookImports, useHead, useHeadSafe, useScript, useSeoMeta, useUnhead };
@@ -0,0 +1 @@
1
+ export * from 'unhead/plugins';
@@ -0,0 +1 @@
1
+ export * from 'unhead/plugins';
@@ -0,0 +1 @@
1
+ export * from 'unhead/plugins';
package/dist/server.d.mts CHANGED
@@ -1,14 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as unhead_types from 'unhead/types';
4
- import { MergeHead, CreateServerHeadOptions } from 'unhead/types';
5
- export { SSRHeadPayload, extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
6
- import { R as ReactUnhead } from './shared/react.Cz8ob63p.mjs';
4
+ import { Unhead } from 'unhead/types';
5
+ export { SSRHeadPayload, createHead, extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
7
6
 
8
- declare function createHead<T extends MergeHead>(options?: Omit<CreateServerHeadOptions, 'propResolvers'>): ReactUnhead<T>;
9
7
  declare function UnheadProvider({ children, value }: {
10
8
  children: ReactNode;
11
- value: ReturnType<typeof createHead>;
12
- }): react.FunctionComponentElement<react.ProviderProps<unhead_types.Unhead<any> | null>>;
9
+ value: Unhead;
10
+ }): react.FunctionComponentElement<react.ProviderProps<Unhead<unhead_types.Head<unhead_types.SchemaAugmentations>> | null>>;
13
11
 
14
- export { UnheadProvider, createHead };
12
+ export { UnheadProvider };
package/dist/server.d.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as unhead_types from 'unhead/types';
4
- import { MergeHead, CreateServerHeadOptions } from 'unhead/types';
5
- export { SSRHeadPayload, extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
6
- import { R as ReactUnhead } from './shared/react.Cz8ob63p.js';
4
+ import { Unhead } from 'unhead/types';
5
+ export { SSRHeadPayload, createHead, extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
7
6
 
8
- declare function createHead<T extends MergeHead>(options?: Omit<CreateServerHeadOptions, 'propResolvers'>): ReactUnhead<T>;
9
7
  declare function UnheadProvider({ children, value }: {
10
8
  children: ReactNode;
11
- value: ReturnType<typeof createHead>;
12
- }): react.FunctionComponentElement<react.ProviderProps<unhead_types.Unhead<any> | null>>;
9
+ value: Unhead;
10
+ }): react.FunctionComponentElement<react.ProviderProps<Unhead<unhead_types.Head<unhead_types.SchemaAugmentations>> | null>>;
13
11
 
14
- export { UnheadProvider, createHead };
12
+ export { UnheadProvider };
package/dist/server.mjs CHANGED
@@ -1,23 +1,9 @@
1
1
  import { createElement } from 'react';
2
- import { createHead as createHead$1 } from 'unhead/server';
3
- export { extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
4
2
  import { U as UnheadContext } from './shared/react.DF9T1fqs.mjs';
3
+ export { createHead, extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
5
4
 
6
- function createHead(options = {}) {
7
- return createHead$1({
8
- ...options,
9
- propResolvers: [
10
- (_, r) => {
11
- if (typeof r === "object" && "current" in r) {
12
- return r.current;
13
- }
14
- return r;
15
- }
16
- ]
17
- });
18
- }
19
5
  function UnheadProvider({ children, value }) {
20
6
  return createElement(UnheadContext.Provider, { value }, children);
21
7
  }
22
8
 
23
- export { UnheadProvider, createHead };
9
+ export { UnheadProvider };
@@ -0,0 +1,2 @@
1
+ export * from 'unhead/utils';
2
+ import 'unhead/plugins';
@@ -0,0 +1,2 @@
1
+ export * from 'unhead/utils';
2
+ import 'unhead/plugins';
package/dist/utils.mjs ADDED
@@ -0,0 +1 @@
1
+ export * from 'unhead/utils';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/react",
3
3
  "type": "module",
4
- "version": "2.0.0-alpha.16",
4
+ "version": "2.0.0-alpha.18",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -28,9 +28,13 @@
28
28
  "types": "./dist/client.d.ts",
29
29
  "import": "./dist/client.mjs"
30
30
  },
31
- "./types": {
32
- "types": "./dist/types.d.ts",
33
- "import": "./dist/types.mjs"
31
+ "./utils": {
32
+ "types": "./dist/utils.d.ts",
33
+ "import": "./dist/utils.mjs"
34
+ },
35
+ "./plugins": {
36
+ "types": "./dist/plugins.d.ts",
37
+ "import": "./dist/plugins.mjs"
34
38
  }
35
39
  },
36
40
  "main": "dist/index.mjs",
@@ -44,16 +48,20 @@
44
48
  "client": [
45
49
  "dist/client"
46
50
  ],
47
- "types": [
48
- "dist/types"
51
+ "plugins": [
52
+ "dist/plugins"
53
+ ],
54
+ "utils": [
55
+ "dist/utils"
49
56
  ]
50
57
  }
51
58
  },
52
59
  "files": [
53
60
  "client.d.ts",
54
61
  "dist",
62
+ "plugins.d.ts",
55
63
  "server.d.ts",
56
- "types.d.ts"
64
+ "utils.d.ts"
57
65
  ],
58
66
  "peerDependencies": {
59
67
  "react": ">=19"
@@ -64,7 +72,7 @@
64
72
  ]
65
73
  },
66
74
  "dependencies": {
67
- "unhead": "2.0.0-alpha.16"
75
+ "unhead": "2.0.0-alpha.18"
68
76
  },
69
77
  "devDependencies": {
70
78
  "@testing-library/react": "^16.2.0",
package/plugins.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/plugins'
package/utils.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/utils'
@@ -1,130 +0,0 @@
1
- import { RefObject } from 'react';
2
- import { Falsey, BaseHtmlAttr, MaybeArray, BaseBodyAttr, SchemaAugmentations, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, DefinedValueOrEmptyObject, LinkBase, DataKeys, MaybeEventFnHandlers, HttpEventAttributes, BaseMeta, Style as Style$1, ScriptBase, Noscript as Noscript$1, BodyEvents, MergeHead, MetaFlatInput, HeadEntryOptions, Unhead } from 'unhead/types';
3
-
4
- type MaybeComputedRef<T> = T | (() => T) | RefObject<T>;
5
- type ResolvableArray<T> = MaybeComputedRef<MaybeComputedRef<T>[]>;
6
- type ResolvableProperties<T> = {
7
- [key in keyof T]?: MaybeComputedRef<T[key] | Falsey>;
8
- };
9
-
10
- interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
11
- /**
12
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
13
- *
14
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
15
- */
16
- class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
17
- }
18
- interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
19
- /**
20
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
21
- *
22
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
23
- */
24
- class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
25
- /**
26
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
27
- *
28
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
29
- */
30
- style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
31
- }
32
- type Title = MaybeComputedRef<number | string | Falsey> | ResolvableProperties<({
33
- textContent: string;
34
- } & SchemaAugmentations['title'])>;
35
- type TitleTemplate = TitleTemplate$1 | RefObject<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
36
- type Base<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Base$1 & SchemaAugmentations['base']> & DefinedValueOrEmptyObject<E>;
37
- type Link<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<LinkBase & DataKeys & SchemaAugmentations['link']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
38
- type Meta<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<BaseMeta & DataKeys & SchemaAugmentations['meta']> & DefinedValueOrEmptyObject<E>;
39
- type Style<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Style$1 & DataKeys & SchemaAugmentations['style']> & DefinedValueOrEmptyObject<E>;
40
- type Script<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<ScriptBase & DataKeys & SchemaAugmentations['script']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
41
- type Noscript<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Noscript$1 & DataKeys & SchemaAugmentations['noscript']> & DefinedValueOrEmptyObject<E>;
42
- type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs']> & DefinedValueOrEmptyObject<E>;
43
- type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs']> & MaybeEventFnHandlers<BodyEvents> & DefinedValueOrEmptyObject<E>;
44
- interface ReactiveHead<E extends MergeHead = MergeHead> {
45
- /**
46
- * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
47
- * It only contains text; tags within the element are ignored.
48
- *
49
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
50
- */
51
- title?: Title;
52
- /**
53
- * Generate the title from a template.
54
- */
55
- titleTemplate?: TitleTemplate;
56
- /**
57
- * Variables used to substitute in the title and meta content.
58
- */
59
- templateParams?: ResolvableArray<{
60
- separator?: '|' | '-' | '·' | string;
61
- } & Record<string, null | string | ResolvableArray<Record<string, null | string>>>>;
62
- /**
63
- * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
64
- * There can be only one <base> element in a document.
65
- *
66
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
67
- */
68
- base?: Base<E['base']>;
69
- /**
70
- * The `<link>` HTML element specifies relationships between the current document and an external resource.
71
- * This element is most commonly used to link to stylesheets, but is also used to establish site icons
72
- * (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
73
- *
74
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
75
- */
76
- link?: ResolvableArray<Link<E['link']>>;
77
- /**
78
- * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
79
- *
80
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
81
- */
82
- meta?: ResolvableArray<Meta<E['meta']>>;
83
- /**
84
- * The `<style>` HTML element contains style information for a document, or part of a document.
85
- * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
86
- *
87
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
88
- */
89
- style?: ResolvableArray<(Style<E['style']> | string)>;
90
- /**
91
- * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
92
- *
93
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
94
- */
95
- script?: ResolvableArray<(Script<E['script']> | string)>;
96
- /**
97
- * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
98
- * or if scripting is currently turned off in the browser.
99
- *
100
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
101
- */
102
- noscript?: ResolvableArray<(Noscript<E['noscript']> | string)>;
103
- /**
104
- * Attributes for the `<html>` HTML element.
105
- *
106
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
107
- */
108
- htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
109
- /**
110
- * Attributes for the `<body>` HTML element.
111
- *
112
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
113
- */
114
- bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
115
- /**
116
- * @internal
117
- */
118
- _flatMeta?: ResolvableProperties<MetaFlatInput>;
119
- }
120
- type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
121
- head?: ReactUnhead<any>;
122
- };
123
- type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
124
- type UseSeoMetaInput = ResolvableProperties<MetaFlatInput> & {
125
- title?: ReactiveHead['title'];
126
- titleTemplate?: ReactiveHead['titleTemplate'];
127
- };
128
- type ReactUnhead<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>>;
129
-
130
- export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRef as M, Noscript as N, ReactUnhead as R, Style as S, Title as T, UseHeadInput as U, UseSeoMetaInput as a, ReactiveHead as b, ResolvableArray as c, TitleTemplate as d, Base as e, Meta as f, Script as g, HtmlAttributes as h, BodyAttributes as i, UseHeadOptions as j, ResolvableProperties as k };
@@ -1,130 +0,0 @@
1
- import { RefObject } from 'react';
2
- import { Falsey, BaseHtmlAttr, MaybeArray, BaseBodyAttr, SchemaAugmentations, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, DefinedValueOrEmptyObject, LinkBase, DataKeys, MaybeEventFnHandlers, HttpEventAttributes, BaseMeta, Style as Style$1, ScriptBase, Noscript as Noscript$1, BodyEvents, MergeHead, MetaFlatInput, HeadEntryOptions, Unhead } from 'unhead/types';
3
-
4
- type MaybeComputedRef<T> = T | (() => T) | RefObject<T>;
5
- type ResolvableArray<T> = MaybeComputedRef<MaybeComputedRef<T>[]>;
6
- type ResolvableProperties<T> = {
7
- [key in keyof T]?: MaybeComputedRef<T[key] | Falsey>;
8
- };
9
-
10
- interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
11
- /**
12
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
13
- *
14
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
15
- */
16
- class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
17
- }
18
- interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
19
- /**
20
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
21
- *
22
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
23
- */
24
- class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
25
- /**
26
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
27
- *
28
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
29
- */
30
- style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
31
- }
32
- type Title = MaybeComputedRef<number | string | Falsey> | ResolvableProperties<({
33
- textContent: string;
34
- } & SchemaAugmentations['title'])>;
35
- type TitleTemplate = TitleTemplate$1 | RefObject<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
36
- type Base<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Base$1 & SchemaAugmentations['base']> & DefinedValueOrEmptyObject<E>;
37
- type Link<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<LinkBase & DataKeys & SchemaAugmentations['link']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
38
- type Meta<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<BaseMeta & DataKeys & SchemaAugmentations['meta']> & DefinedValueOrEmptyObject<E>;
39
- type Style<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Style$1 & DataKeys & SchemaAugmentations['style']> & DefinedValueOrEmptyObject<E>;
40
- type Script<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<ScriptBase & DataKeys & SchemaAugmentations['script']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
41
- type Noscript<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Noscript$1 & DataKeys & SchemaAugmentations['noscript']> & DefinedValueOrEmptyObject<E>;
42
- type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs']> & DefinedValueOrEmptyObject<E>;
43
- type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs']> & MaybeEventFnHandlers<BodyEvents> & DefinedValueOrEmptyObject<E>;
44
- interface ReactiveHead<E extends MergeHead = MergeHead> {
45
- /**
46
- * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
47
- * It only contains text; tags within the element are ignored.
48
- *
49
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
50
- */
51
- title?: Title;
52
- /**
53
- * Generate the title from a template.
54
- */
55
- titleTemplate?: TitleTemplate;
56
- /**
57
- * Variables used to substitute in the title and meta content.
58
- */
59
- templateParams?: ResolvableArray<{
60
- separator?: '|' | '-' | '·' | string;
61
- } & Record<string, null | string | ResolvableArray<Record<string, null | string>>>>;
62
- /**
63
- * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
64
- * There can be only one <base> element in a document.
65
- *
66
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
67
- */
68
- base?: Base<E['base']>;
69
- /**
70
- * The `<link>` HTML element specifies relationships between the current document and an external resource.
71
- * This element is most commonly used to link to stylesheets, but is also used to establish site icons
72
- * (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
73
- *
74
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
75
- */
76
- link?: ResolvableArray<Link<E['link']>>;
77
- /**
78
- * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
79
- *
80
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
81
- */
82
- meta?: ResolvableArray<Meta<E['meta']>>;
83
- /**
84
- * The `<style>` HTML element contains style information for a document, or part of a document.
85
- * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
86
- *
87
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
88
- */
89
- style?: ResolvableArray<(Style<E['style']> | string)>;
90
- /**
91
- * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
92
- *
93
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
94
- */
95
- script?: ResolvableArray<(Script<E['script']> | string)>;
96
- /**
97
- * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
98
- * or if scripting is currently turned off in the browser.
99
- *
100
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
101
- */
102
- noscript?: ResolvableArray<(Noscript<E['noscript']> | string)>;
103
- /**
104
- * Attributes for the `<html>` HTML element.
105
- *
106
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
107
- */
108
- htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
109
- /**
110
- * Attributes for the `<body>` HTML element.
111
- *
112
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
113
- */
114
- bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
115
- /**
116
- * @internal
117
- */
118
- _flatMeta?: ResolvableProperties<MetaFlatInput>;
119
- }
120
- type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
121
- head?: ReactUnhead<any>;
122
- };
123
- type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
124
- type UseSeoMetaInput = ResolvableProperties<MetaFlatInput> & {
125
- title?: ReactiveHead['title'];
126
- titleTemplate?: ReactiveHead['titleTemplate'];
127
- };
128
- type ReactUnhead<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>>;
129
-
130
- export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRef as M, Noscript as N, ReactUnhead as R, Style as S, Title as T, UseHeadInput as U, UseSeoMetaInput as a, ReactiveHead as b, ResolvableArray as c, TitleTemplate as d, Base as e, Meta as f, Script as g, HtmlAttributes as h, BodyAttributes as i, UseHeadOptions as j, ResolvableProperties as k };
package/dist/types.d.mts DELETED
@@ -1,17 +0,0 @@
1
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from 'unhead/types';
2
- export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from 'unhead/types';
3
- import { b as ReactiveHead, c as ResolvableArray, M as MaybeComputedRef } from './shared/react.Cz8ob63p.mjs';
4
- export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, f as Meta, N as Noscript, R as ReactUnhead, k as ResolvableProperties, g as Script, S as Style, T as Title, d as TitleTemplate, U as UseHeadInput, j as UseHeadOptions, a as UseSeoMetaInput } from './shared/react.Cz8ob63p.mjs';
5
- import 'react';
6
-
7
- interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
8
- meta?: ResolvableArray<SafeMeta>[];
9
- link?: ResolvableArray<SafeLink>[];
10
- noscript?: ResolvableArray<SafeNoscript>[];
11
- script?: ResolvableArray<SafeScript>[];
12
- htmlAttrs?: ResolvableArray<SafeHtmlAttr>;
13
- bodyAttrs?: ResolvableArray<SafeBodyAttr>;
14
- }
15
- type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
16
-
17
- export { type HeadSafe, MaybeComputedRef, ReactiveHead, ResolvableArray, type UseHeadSafeInput };
package/dist/types.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from 'unhead/types';
2
- export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from 'unhead/types';
3
- import { b as ReactiveHead, c as ResolvableArray, M as MaybeComputedRef } from './shared/react.Cz8ob63p.js';
4
- export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, f as Meta, N as Noscript, R as ReactUnhead, k as ResolvableProperties, g as Script, S as Style, T as Title, d as TitleTemplate, U as UseHeadInput, j as UseHeadOptions, a as UseSeoMetaInput } from './shared/react.Cz8ob63p.js';
5
- import 'react';
6
-
7
- interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
8
- meta?: ResolvableArray<SafeMeta>[];
9
- link?: ResolvableArray<SafeLink>[];
10
- noscript?: ResolvableArray<SafeNoscript>[];
11
- script?: ResolvableArray<SafeScript>[];
12
- htmlAttrs?: ResolvableArray<SafeHtmlAttr>;
13
- bodyAttrs?: ResolvableArray<SafeBodyAttr>;
14
- }
15
- type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
16
-
17
- export { type HeadSafe, MaybeComputedRef, ReactiveHead, ResolvableArray, type UseHeadSafeInput };
package/dist/types.mjs DELETED
@@ -1 +0,0 @@
1
-
package/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/types'