@unhead/react 2.0.0-alpha.9 → 2.0.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/client.d.mts CHANGED
@@ -1,14 +1,13 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import * as _unhead_schema from '@unhead/schema';
4
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
5
- export * from 'unhead/client';
6
- import { R as ReactUnhead } from './shared/react.rDLQhCrM.mjs';
3
+ import * as unhead_types from 'unhead/types';
4
+ import { CreateClientHeadOptions, Unhead } from 'unhead/types';
5
+ export { renderDOMHead } from 'unhead/client';
7
6
 
8
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): 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_schema.Unhead<any> | null>>;
11
+ }): react.FunctionComponentElement<react.ProviderProps<Unhead<unhead_types.ResolvableHead> | 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
- import * as _unhead_schema from '@unhead/schema';
4
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
5
- export * from 'unhead/client';
6
- import { R as ReactUnhead } from './shared/react.rDLQhCrM.js';
3
+ import * as unhead_types from 'unhead/types';
4
+ import { CreateClientHeadOptions, Unhead } from 'unhead/types';
5
+ export { renderDOMHead } from 'unhead/client';
7
6
 
8
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): 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_schema.Unhead<any> | null>>;
11
+ }): react.FunctionComponentElement<react.ProviderProps<Unhead<unhead_types.ResolvableHead> | null>>;
13
12
 
14
13
  export { UnheadProvider, createHead };
package/dist/client.mjs CHANGED
@@ -1,20 +1,14 @@
1
1
  import { createElement } from 'react';
2
2
  import { createHead as createHead$1, createDebouncedFn, renderDOMHead } from 'unhead/client';
3
- export * from 'unhead/client';
3
+ export { renderDOMHead } from 'unhead/client';
4
4
  import { U as UnheadContext } from './shared/react.DF9T1fqs.mjs';
5
- import { R as ReactReactivityPlugin } from './shared/react.D-xyXevh.mjs';
6
- import '@unhead/shared';
7
5
 
8
6
  function createHead(options = {}) {
9
7
  const head = createHead$1({
10
8
  domOptions: {
11
9
  render: createDebouncedFn(() => renderDOMHead(head), (fn) => setTimeout(fn, 0))
12
10
  },
13
- ...options,
14
- plugins: [
15
- ...options.plugins || [],
16
- ReactReactivityPlugin
17
- ]
11
+ ...options
18
12
  });
19
13
  return head;
20
14
  }
package/dist/index.d.mts CHANGED
@@ -1,10 +1,8 @@
1
1
  import react__default, { ReactNode } from 'react';
2
- import * as _unhead_schema from '@unhead/schema';
3
- import { MergeHead, HeadEntryOptions, ActiveHeadEntry, HeadSafe } from '@unhead/schema';
4
- import { U as UseHeadInput, a as UseSeoMetaInput } from './shared/react.rDLQhCrM.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_schema.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_schema from '@unhead/schema';
3
- import { MergeHead, HeadEntryOptions, ActiveHeadEntry, HeadSafe } from '@unhead/schema';
4
- import { U as UseHeadInput, a as UseSeoMetaInput } from './shared/react.rDLQhCrM.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_schema.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,9 +1,15 @@
1
- import { composableNames, whitelistSafeInput, unpackMeta, ValidHeadTags, TagsWithInnerContent, HasElementTags } from '@unhead/shared';
2
- import React, { useContext, useEffect, useRef } from 'react';
1
+ import React, { useEffect, useContext, useState, useRef } from 'react';
2
+ import { ValidHeadTags, TagsWithInnerContent, HasElementTags } from 'unhead/utils';
3
+ import { useScript as useScript$1, useHead as useHead$1, useHeadSafe as useHeadSafe$1, useSeoMeta as useSeoMeta$1 } from 'unhead';
3
4
  import { U as UnheadContext } from './shared/react.DF9T1fqs.mjs';
4
5
 
5
6
  const hookImports = {
6
- "@unhead/vue": ["useUnhead", ...composableNames]
7
+ "@unhead/react": [
8
+ "useUnhead",
9
+ "useHead",
10
+ "useSeoMeta",
11
+ "useHeadSafe"
12
+ ]
7
13
  };
8
14
 
9
15
  function useUnhead() {
@@ -13,42 +19,81 @@ function useUnhead() {
13
19
  }
14
20
  return instance;
15
21
  }
16
- function useHead(input, options = {}) {
17
- const head = options.head || useUnhead();
18
- const entry = head.push(input, options);
22
+ function withSideEffects(input, options, fn) {
23
+ const unhead = options.head || useUnhead();
24
+ const [entry] = useState(() => fn(unhead, input, options));
19
25
  useEffect(() => {
20
26
  entry.patch(input);
21
27
  }, [input]);
22
28
  useEffect(() => {
23
29
  return () => {
24
- entry?.dispose();
30
+ entry.dispose();
25
31
  };
26
32
  }, []);
27
33
  return entry;
28
34
  }
29
- function useHeadSafe(input, options = {}) {
30
- return useHead(input, { ...options, transform: whitelistSafeInput });
35
+ function useHead(input = {}, options = {}) {
36
+ return withSideEffects(input, options, useHead$1);
31
37
  }
32
- function useSeoMeta(input, options) {
33
- const { title, titleTemplate, ...meta } = input;
34
- return useHead({
35
- title,
36
- titleTemplate,
37
- // we need to input the meta so the reactivity will be resolved
38
- // @ts-expect-error runtime type
39
- _flatMeta: meta
40
- }, {
41
- ...options,
42
- transform(t) {
43
- const meta2 = unpackMeta({ ...t._flatMeta });
44
- delete t._flatMeta;
45
- return {
46
- // @ts-expect-error runtime type
47
- ...t,
48
- meta: meta2
49
- };
50
- }
51
- });
38
+ function useHeadSafe(input = {}, options = {}) {
39
+ return withSideEffects(input, options, useHeadSafe$1);
40
+ }
41
+ function useSeoMeta(input = {}, options = {}) {
42
+ return withSideEffects(input, options, useSeoMeta$1);
43
+ }
44
+ function useScript(_input, _options) {
45
+ const input = typeof _input === "string" ? { src: _input } : _input;
46
+ const options = _options || {};
47
+ const head = options?.head || useUnhead();
48
+ options.head = head;
49
+ const mountCbs = [];
50
+ let isMounted = false;
51
+ useEffect(() => {
52
+ isMounted = true;
53
+ mountCbs.forEach((i) => i());
54
+ return () => {
55
+ isMounted = false;
56
+ };
57
+ }, []);
58
+ if (typeof options.trigger === "undefined") {
59
+ options.trigger = (load) => {
60
+ if (isMounted) {
61
+ load();
62
+ } else {
63
+ mountCbs.push(load);
64
+ }
65
+ };
66
+ }
67
+ const script = useScript$1(head, input, options);
68
+ const sideEffects = [];
69
+ useEffect(() => {
70
+ return () => {
71
+ script._triggerAbortController?.abort();
72
+ sideEffects.forEach((i) => i());
73
+ };
74
+ }, []);
75
+ const _registerCb = (key, cb) => {
76
+ let i;
77
+ const destroy = () => {
78
+ if (i) {
79
+ script._cbs[key]?.splice(i - 1, 1);
80
+ i = null;
81
+ }
82
+ };
83
+ mountCbs.push(() => {
84
+ if (!script._cbs[key]) {
85
+ cb(script.instance);
86
+ return () => {
87
+ };
88
+ }
89
+ i = script._cbs[key].push(cb);
90
+ sideEffects.push(destroy);
91
+ return destroy;
92
+ });
93
+ };
94
+ script.onLoaded = (cb) => _registerCb("loaded", cb);
95
+ script.onError = (cb) => _registerCb("error", cb);
96
+ return script;
52
97
  }
53
98
 
54
99
  const Head = ({ children, titleTemplate }) => {
@@ -93,4 +138,4 @@ const Head = ({ children, titleTemplate }) => {
93
138
  return null;
94
139
  };
95
140
 
96
- export { Head, hookImports, useHead, useHeadSafe, useSeoMeta, useUnhead };
141
+ 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
- import * as _unhead_schema from '@unhead/schema';
4
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
5
- export * from 'unhead/server';
6
- import { R as ReactUnhead } from './shared/react.rDLQhCrM.mjs';
3
+ import * as unhead_types from 'unhead/types';
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?: CreateClientHeadOptions): ReactUnhead<T>;
9
7
  declare function UnheadProvider({ children, value }: {
10
8
  children: ReactNode;
11
- value: ReturnType<typeof createHead>;
12
- }): react.FunctionComponentElement<react.ProviderProps<_unhead_schema.Unhead<any> | null>>;
9
+ value: Unhead;
10
+ }): react.FunctionComponentElement<react.ProviderProps<Unhead<unhead_types.ResolvableHead> | 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
- import * as _unhead_schema from '@unhead/schema';
4
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
5
- export * from 'unhead/server';
6
- import { R as ReactUnhead } from './shared/react.rDLQhCrM.js';
3
+ import * as unhead_types from 'unhead/types';
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?: CreateClientHeadOptions): ReactUnhead<T>;
9
7
  declare function UnheadProvider({ children, value }: {
10
8
  children: ReactNode;
11
- value: ReturnType<typeof createHead>;
12
- }): react.FunctionComponentElement<react.ProviderProps<_unhead_schema.Unhead<any> | null>>;
9
+ value: Unhead;
10
+ }): react.FunctionComponentElement<react.ProviderProps<Unhead<unhead_types.ResolvableHead> | null>>;
13
11
 
14
- export { UnheadProvider, createHead };
12
+ export { UnheadProvider };
package/dist/server.mjs CHANGED
@@ -1,21 +1,9 @@
1
1
  import { createElement } from 'react';
2
- import { createHead as createHead$1 } from 'unhead/server';
3
- export * from 'unhead/server';
4
2
  import { U as UnheadContext } from './shared/react.DF9T1fqs.mjs';
5
- import { R as ReactReactivityPlugin } from './shared/react.D-xyXevh.mjs';
6
- import '@unhead/shared';
3
+ export { createHead, extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
7
4
 
8
- function createHead(options = {}) {
9
- return createHead$1({
10
- ...options,
11
- plugins: [
12
- ...options.plugins || [],
13
- ReactReactivityPlugin
14
- ]
15
- });
16
- }
17
5
  function UnheadProvider({ children, value }) {
18
6
  return createElement(UnheadContext.Provider, { value }, children);
19
7
  }
20
8
 
21
- 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.9",
4
+ "version": "2.0.0-beta.1",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -18,26 +18,26 @@
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/index.d.ts",
21
- "import": "./dist/index.mjs",
22
- "require": "./dist/index.cjs"
21
+ "import": "./dist/index.mjs"
23
22
  },
24
23
  "./server": {
25
24
  "types": "./dist/server.d.ts",
26
- "import": "./dist/server.mjs",
27
- "require": "./dist/server.cjs"
25
+ "import": "./dist/server.mjs"
28
26
  },
29
27
  "./client": {
30
28
  "types": "./dist/client.d.ts",
31
- "import": "./dist/client.mjs",
32
- "require": "./dist/client.cjs"
29
+ "import": "./dist/client.mjs"
33
30
  },
34
- "./types": {
35
- "types": "./dist/types.d.ts",
36
- "import": "./dist/types.mjs",
37
- "require": "./dist/types.cjs"
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"
38
38
  }
39
39
  },
40
- "main": "dist/index.cjs",
40
+ "main": "dist/index.mjs",
41
41
  "module": "dist/index.mjs",
42
42
  "types": "dist/index.d.ts",
43
43
  "typesVersions": {
@@ -48,16 +48,20 @@
48
48
  "client": [
49
49
  "dist/client"
50
50
  ],
51
- "types": [
52
- "dist/types"
51
+ "plugins": [
52
+ "dist/plugins"
53
+ ],
54
+ "utils": [
55
+ "dist/utils"
53
56
  ]
54
57
  }
55
58
  },
56
59
  "files": [
57
60
  "client.d.ts",
58
61
  "dist",
62
+ "plugins.d.ts",
59
63
  "server.d.ts",
60
- "types.d.ts"
64
+ "utils.d.ts"
61
65
  ],
62
66
  "peerDependencies": {
63
67
  "react": ">=19"
@@ -68,9 +72,7 @@
68
72
  ]
69
73
  },
70
74
  "dependencies": {
71
- "@unhead/schema": "2.0.0-alpha.9",
72
- "@unhead/shared": "2.0.0-alpha.9",
73
- "unhead": "2.0.0-alpha.9"
75
+ "unhead": "2.0.0-beta.1"
74
76
  },
75
77
  "devDependencies": {
76
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'
package/dist/client.cjs DELETED
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- const React = require('react');
4
- const client = require('unhead/client');
5
- const context = require('./shared/react.BtC4o9fJ.cjs');
6
- const ReactReactivityPlugin = require('./shared/react.CBAhBov_.cjs');
7
- require('@unhead/shared');
8
-
9
- function createHead(options = {}) {
10
- const head = client.createHead({
11
- domOptions: {
12
- render: client.createDebouncedFn(() => client.renderDOMHead(head), (fn) => setTimeout(fn, 0))
13
- },
14
- ...options,
15
- plugins: [
16
- ...options.plugins || [],
17
- ReactReactivityPlugin.ReactReactivityPlugin
18
- ]
19
- });
20
- return head;
21
- }
22
- function UnheadProvider({ children, head }) {
23
- return React.createElement(context.UnheadContext.Provider, { value: head || createHead() }, children);
24
- }
25
-
26
- exports.UnheadProvider = UnheadProvider;
27
- exports.createHead = createHead;
28
- Object.prototype.hasOwnProperty.call(client, '__proto__') &&
29
- !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
30
- Object.defineProperty(exports, '__proto__', {
31
- enumerable: true,
32
- value: client['__proto__']
33
- });
34
-
35
- Object.keys(client).forEach(function (k) {
36
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = client[k];
37
- });
package/dist/client.d.cts DELETED
@@ -1,14 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import * as _unhead_schema from '@unhead/schema';
4
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
5
- export * from 'unhead/client';
6
- import { R as ReactUnhead } from './shared/react.rDLQhCrM.cjs';
7
-
8
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): ReactUnhead<T>;
9
- declare function UnheadProvider({ children, head }: {
10
- children: ReactNode;
11
- head?: ReturnType<typeof createHead>;
12
- }): react.FunctionComponentElement<react.ProviderProps<_unhead_schema.Unhead<any> | null>>;
13
-
14
- export { UnheadProvider, createHead };
package/dist/index.cjs DELETED
@@ -1,107 +0,0 @@
1
- 'use strict';
2
-
3
- const shared = require('@unhead/shared');
4
- const React = require('react');
5
- const context = require('./shared/react.BtC4o9fJ.cjs');
6
-
7
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
8
-
9
- const React__default = /*#__PURE__*/_interopDefaultCompat(React);
10
-
11
- const hookImports = {
12
- "@unhead/vue": ["useUnhead", ...shared.composableNames]
13
- };
14
-
15
- function useUnhead() {
16
- const instance = React.useContext(context.UnheadContext);
17
- if (!instance) {
18
- throw new Error("useHead() was called without provide context.");
19
- }
20
- return instance;
21
- }
22
- function useHead(input, options = {}) {
23
- const head = options.head || useUnhead();
24
- const entry = head.push(input, options);
25
- React.useEffect(() => {
26
- entry.patch(input);
27
- }, [input]);
28
- React.useEffect(() => {
29
- return () => {
30
- entry?.dispose();
31
- };
32
- }, []);
33
- return entry;
34
- }
35
- function useHeadSafe(input, options = {}) {
36
- return useHead(input, { ...options, transform: shared.whitelistSafeInput });
37
- }
38
- function useSeoMeta(input, options) {
39
- const { title, titleTemplate, ...meta } = input;
40
- return useHead({
41
- title,
42
- titleTemplate,
43
- // we need to input the meta so the reactivity will be resolved
44
- // @ts-expect-error runtime type
45
- _flatMeta: meta
46
- }, {
47
- ...options,
48
- transform(t) {
49
- const meta2 = shared.unpackMeta({ ...t._flatMeta });
50
- delete t._flatMeta;
51
- return {
52
- // @ts-expect-error runtime type
53
- ...t,
54
- meta: meta2
55
- };
56
- }
57
- });
58
- }
59
-
60
- const Head = ({ children, titleTemplate }) => {
61
- const headRef = React.useRef(null);
62
- const head = useUnhead();
63
- React.useEffect(() => {
64
- return () => {
65
- if (headRef.current?.dispose()) {
66
- headRef.current.dispose();
67
- }
68
- headRef.current = null;
69
- };
70
- }, []);
71
- React.useEffect(() => {
72
- const input = {
73
- titleTemplate
74
- };
75
- const elements = React__default.Children.toArray(children).filter(React__default.isValidElement);
76
- elements.forEach((element) => {
77
- const { type, props } = element;
78
- if (!shared.ValidHeadTags.has(type)) {
79
- return;
80
- }
81
- const data = { ...typeof props === "object" ? props : {} };
82
- if (shared.TagsWithInnerContent.has(type) && data.children) {
83
- data[type === "script" ? "innerHTML" : "textContent"] = Array.isArray(data.children) ? data.children.map(String).join("") : data.children;
84
- }
85
- delete data.children;
86
- if (shared.HasElementTags.has(type)) {
87
- input[type] = input[type] || [];
88
- input[type].push(data);
89
- } else {
90
- input[type] = data;
91
- }
92
- });
93
- if (!headRef.current) {
94
- headRef.current = head.push(input);
95
- } else {
96
- headRef.current.patch(input);
97
- }
98
- }, [children, titleTemplate]);
99
- return null;
100
- };
101
-
102
- exports.Head = Head;
103
- exports.hookImports = hookImports;
104
- exports.useHead = useHead;
105
- exports.useHeadSafe = useHeadSafe;
106
- exports.useSeoMeta = useSeoMeta;
107
- exports.useUnhead = useUnhead;
package/dist/index.d.cts DELETED
@@ -1,21 +0,0 @@
1
- import react__default, { ReactNode } from 'react';
2
- import * as _unhead_schema from '@unhead/schema';
3
- import { MergeHead, HeadEntryOptions, ActiveHeadEntry, HeadSafe } from '@unhead/schema';
4
- import { U as UseHeadInput, a as UseSeoMetaInput } from './shared/react.rDLQhCrM.cjs';
5
-
6
- declare const hookImports: {
7
- '@unhead/vue': string[];
8
- };
9
-
10
- interface HeadProps {
11
- children: ReactNode;
12
- titleTemplate?: string;
13
- }
14
- declare const Head: react__default.FC<HeadProps>;
15
-
16
- declare function useUnhead(): _unhead_schema.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>;
20
-
21
- export { Head, hookImports, useHead, useHeadSafe, useSeoMeta, useUnhead };
package/dist/server.cjs DELETED
@@ -1,33 +0,0 @@
1
- 'use strict';
2
-
3
- const React = require('react');
4
- const server = require('unhead/server');
5
- const context = require('./shared/react.BtC4o9fJ.cjs');
6
- const ReactReactivityPlugin = require('./shared/react.CBAhBov_.cjs');
7
- require('@unhead/shared');
8
-
9
- function createHead(options = {}) {
10
- return server.createHead({
11
- ...options,
12
- plugins: [
13
- ...options.plugins || [],
14
- ReactReactivityPlugin.ReactReactivityPlugin
15
- ]
16
- });
17
- }
18
- function UnheadProvider({ children, value }) {
19
- return React.createElement(context.UnheadContext.Provider, { value }, children);
20
- }
21
-
22
- exports.UnheadProvider = UnheadProvider;
23
- exports.createHead = createHead;
24
- Object.prototype.hasOwnProperty.call(server, '__proto__') &&
25
- !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
26
- Object.defineProperty(exports, '__proto__', {
27
- enumerable: true,
28
- value: server['__proto__']
29
- });
30
-
31
- Object.keys(server).forEach(function (k) {
32
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = server[k];
33
- });
package/dist/server.d.cts DELETED
@@ -1,14 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import * as _unhead_schema from '@unhead/schema';
4
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
5
- export * from 'unhead/server';
6
- import { R as ReactUnhead } from './shared/react.rDLQhCrM.cjs';
7
-
8
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): ReactUnhead<T>;
9
- declare function UnheadProvider({ children, value }: {
10
- children: ReactNode;
11
- value: ReturnType<typeof createHead>;
12
- }): react.FunctionComponentElement<react.ProviderProps<_unhead_schema.Unhead<any> | null>>;
13
-
14
- export { UnheadProvider, createHead };
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- const React = require('react');
4
-
5
- const UnheadContext = React.createContext(null);
6
-
7
- exports.UnheadContext = UnheadContext;
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- const shared = require('@unhead/shared');
4
- const React = require('react');
5
-
6
- function resolveUnref(r) {
7
- if (typeof r === "function") {
8
- return r();
9
- }
10
- if (typeof r === "object" && "current" in r) {
11
- return r.current;
12
- }
13
- return r;
14
- }
15
- function resolveUnrefHeadInput(ref) {
16
- if (typeof ref === "string" || ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
17
- return ref;
18
- const root = resolveUnref(ref);
19
- if (!ref || !root)
20
- return root;
21
- if (Array.isArray(root))
22
- return root.map((r) => resolveUnrefHeadInput(r));
23
- if (typeof root === "object" && !React.isValidElement(root)) {
24
- const resolved = {};
25
- for (const k in root) {
26
- if (!Object.prototype.hasOwnProperty.call(root, k)) {
27
- continue;
28
- }
29
- if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
30
- resolved[k] = resolveUnref(root[k]);
31
- continue;
32
- }
33
- resolved[k] = resolveUnrefHeadInput(root[k]);
34
- }
35
- return resolved;
36
- }
37
- return root;
38
- }
39
-
40
- const ReactReactivityPlugin = shared.defineHeadPlugin({
41
- hooks: {
42
- "entries:resolve": (ctx) => {
43
- for (const entry of ctx.entries)
44
- entry.resolvedInput = resolveUnrefHeadInput(entry.input);
45
- }
46
- }
47
- });
48
-
49
- exports.ReactReactivityPlugin = ReactReactivityPlugin;
@@ -1,47 +0,0 @@
1
- import { defineHeadPlugin } from '@unhead/shared';
2
- import { isValidElement } from 'react';
3
-
4
- function resolveUnref(r) {
5
- if (typeof r === "function") {
6
- return r();
7
- }
8
- if (typeof r === "object" && "current" in r) {
9
- return r.current;
10
- }
11
- return r;
12
- }
13
- function resolveUnrefHeadInput(ref) {
14
- if (typeof ref === "string" || ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
15
- return ref;
16
- const root = resolveUnref(ref);
17
- if (!ref || !root)
18
- return root;
19
- if (Array.isArray(root))
20
- return root.map((r) => resolveUnrefHeadInput(r));
21
- if (typeof root === "object" && !isValidElement(root)) {
22
- const resolved = {};
23
- for (const k in root) {
24
- if (!Object.prototype.hasOwnProperty.call(root, k)) {
25
- continue;
26
- }
27
- if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
28
- resolved[k] = resolveUnref(root[k]);
29
- continue;
30
- }
31
- resolved[k] = resolveUnrefHeadInput(root[k]);
32
- }
33
- return resolved;
34
- }
35
- return root;
36
- }
37
-
38
- const ReactReactivityPlugin = defineHeadPlugin({
39
- hooks: {
40
- "entries:resolve": (ctx) => {
41
- for (const entry of ctx.entries)
42
- entry.resolvedInput = resolveUnrefHeadInput(entry.input);
43
- }
44
- }
45
- });
46
-
47
- export { ReactReactivityPlugin as R };
@@ -1,126 +0,0 @@
1
- import { Falsey, BaseHtmlAttr, MaybeArray, BaseBodyAttr, ResolvableValues, 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, HeadEntryOptions, MetaFlatInput, Unhead } from '@unhead/schema';
2
- import { RefObject } from 'react';
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> | ResolvableValues<({
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
- type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
117
- head?: ReactUnhead<any>;
118
- };
119
- type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
120
- type UseSeoMetaInput = ResolvableProperties<MetaFlatInput> & {
121
- title?: ReactiveHead['title'];
122
- titleTemplate?: ReactiveHead['titleTemplate'];
123
- };
124
- type ReactUnhead<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>>;
125
-
126
- 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,126 +0,0 @@
1
- import { Falsey, BaseHtmlAttr, MaybeArray, BaseBodyAttr, ResolvableValues, 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, HeadEntryOptions, MetaFlatInput, Unhead } from '@unhead/schema';
2
- import { RefObject } from 'react';
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> | ResolvableValues<({
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
- type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
117
- head?: ReactUnhead<any>;
118
- };
119
- type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
120
- type UseSeoMetaInput = ResolvableProperties<MetaFlatInput> & {
121
- title?: ReactiveHead['title'];
122
- titleTemplate?: ReactiveHead['titleTemplate'];
123
- };
124
- type ReactUnhead<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>>;
125
-
126
- 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,126 +0,0 @@
1
- import { Falsey, BaseHtmlAttr, MaybeArray, BaseBodyAttr, ResolvableValues, 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, HeadEntryOptions, MetaFlatInput, Unhead } from '@unhead/schema';
2
- import { RefObject } from 'react';
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> | ResolvableValues<({
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
- type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
117
- head?: ReactUnhead<any>;
118
- };
119
- type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
120
- type UseSeoMetaInput = ResolvableProperties<MetaFlatInput> & {
121
- title?: ReactiveHead['title'];
122
- titleTemplate?: ReactiveHead['titleTemplate'];
123
- };
124
- type ReactUnhead<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>>;
125
-
126
- 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.cjs DELETED
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-
package/dist/types.d.cts DELETED
@@ -1,17 +0,0 @@
1
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from '@unhead/schema';
2
- export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from '@unhead/schema';
3
- import { b as ReactiveHead, c as ResolvableArray, M as MaybeComputedRef } from './shared/react.rDLQhCrM.cjs';
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.rDLQhCrM.cjs';
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.mts DELETED
@@ -1,17 +0,0 @@
1
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from '@unhead/schema';
2
- export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from '@unhead/schema';
3
- import { b as ReactiveHead, c as ResolvableArray, M as MaybeComputedRef } from './shared/react.rDLQhCrM.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.rDLQhCrM.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/schema';
2
- export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from '@unhead/schema';
3
- import { b as ReactiveHead, c as ResolvableArray, M as MaybeComputedRef } from './shared/react.rDLQhCrM.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.rDLQhCrM.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'