@unhead/react 2.0.0-alpha.16 → 2.0.0-alpha.9
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.cjs +37 -0
- package/dist/client.d.cts +14 -0
- package/dist/client.d.mts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.mjs +6 -8
- package/dist/index.cjs +107 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +18 -19
- package/dist/server.cjs +33 -0
- package/dist/server.d.cts +14 -0
- package/dist/server.d.mts +6 -6
- package/dist/server.d.ts +6 -6
- package/dist/server.mjs +6 -8
- package/dist/shared/react.BtC4o9fJ.cjs +7 -0
- package/dist/shared/react.CBAhBov_.cjs +49 -0
- package/dist/shared/react.D-xyXevh.mjs +47 -0
- package/dist/shared/{react.Cz8ob63p.d.mts → react.rDLQhCrM.d.cts} +2 -6
- package/dist/shared/{react.Cz8ob63p.d.ts → react.rDLQhCrM.d.mts} +2 -6
- package/dist/shared/react.rDLQhCrM.d.ts +126 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +17 -0
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/package.json +13 -7
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
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/client.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import * as
|
|
4
|
-
import { MergeHead, CreateClientHeadOptions } from 'unhead/
|
|
5
|
-
export
|
|
6
|
-
import { R as ReactUnhead } from './shared/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';
|
|
7
7
|
|
|
8
|
-
declare function createHead<T extends MergeHead>(options?:
|
|
8
|
+
declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): ReactUnhead<T>;
|
|
9
9
|
declare function UnheadProvider({ children, head }: {
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
head?: ReturnType<typeof createHead>;
|
|
12
|
-
}): react.FunctionComponentElement<react.ProviderProps<
|
|
12
|
+
}): react.FunctionComponentElement<react.ProviderProps<_unhead_schema.Unhead<any> | null>>;
|
|
13
13
|
|
|
14
14
|
export { UnheadProvider, createHead };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import * as
|
|
4
|
-
import { MergeHead, CreateClientHeadOptions } from 'unhead/
|
|
5
|
-
export
|
|
6
|
-
import { R as ReactUnhead } from './shared/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';
|
|
7
7
|
|
|
8
|
-
declare function createHead<T extends MergeHead>(options?:
|
|
8
|
+
declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): ReactUnhead<T>;
|
|
9
9
|
declare function UnheadProvider({ children, head }: {
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
head?: ReturnType<typeof createHead>;
|
|
12
|
-
}): react.FunctionComponentElement<react.ProviderProps<
|
|
12
|
+
}): react.FunctionComponentElement<react.ProviderProps<_unhead_schema.Unhead<any> | null>>;
|
|
13
13
|
|
|
14
14
|
export { UnheadProvider, createHead };
|
package/dist/client.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { createHead as createHead$1, createDebouncedFn, renderDOMHead } from 'unhead/client';
|
|
3
|
-
export
|
|
3
|
+
export * 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';
|
|
5
7
|
|
|
6
8
|
function createHead(options = {}) {
|
|
7
9
|
const head = createHead$1({
|
|
@@ -9,13 +11,9 @@ function createHead(options = {}) {
|
|
|
9
11
|
render: createDebouncedFn(() => renderDOMHead(head), (fn) => setTimeout(fn, 0))
|
|
10
12
|
},
|
|
11
13
|
...options,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return r.current;
|
|
16
|
-
}
|
|
17
|
-
return r;
|
|
18
|
-
}
|
|
14
|
+
plugins: [
|
|
15
|
+
...options.plugins || [],
|
|
16
|
+
ReactReactivityPlugin
|
|
19
17
|
]
|
|
20
18
|
});
|
|
21
19
|
return head;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import react__default, { ReactNode } from 'react';
|
|
2
|
-
import * as
|
|
3
|
-
import { MergeHead, HeadEntryOptions, ActiveHeadEntry, HeadSafe } from 'unhead/
|
|
4
|
-
import { U as UseHeadInput, a as UseSeoMetaInput } from './shared/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';
|
|
5
5
|
|
|
6
6
|
declare const hookImports: {
|
|
7
7
|
'@unhead/vue': string[];
|
|
@@ -13,7 +13,7 @@ interface HeadProps {
|
|
|
13
13
|
}
|
|
14
14
|
declare const Head: react__default.FC<HeadProps>;
|
|
15
15
|
|
|
16
|
-
declare function useUnhead():
|
|
16
|
+
declare function useUnhead(): _unhead_schema.Unhead<any>;
|
|
17
17
|
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>>;
|
|
18
18
|
declare function useHeadSafe(input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
|
19
19
|
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import react__default, { ReactNode } from 'react';
|
|
2
|
-
import * as
|
|
3
|
-
import { MergeHead, HeadEntryOptions, ActiveHeadEntry, HeadSafe } from 'unhead/
|
|
4
|
-
import { U as UseHeadInput, a as UseSeoMetaInput } from './shared/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';
|
|
5
5
|
|
|
6
6
|
declare const hookImports: {
|
|
7
7
|
'@unhead/vue': string[];
|
|
@@ -13,7 +13,7 @@ interface HeadProps {
|
|
|
13
13
|
}
|
|
14
14
|
declare const Head: react__default.FC<HeadProps>;
|
|
15
15
|
|
|
16
|
-
declare function useUnhead():
|
|
16
|
+
declare function useUnhead(): _unhead_schema.Unhead<any>;
|
|
17
17
|
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>>;
|
|
18
18
|
declare function useHeadSafe(input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
|
19
19
|
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
+
import { composableNames, whitelistSafeInput, unpackMeta, ValidHeadTags, TagsWithInnerContent, HasElementTags } from '@unhead/shared';
|
|
1
2
|
import React, { useContext, useEffect, useRef } from 'react';
|
|
2
|
-
import { ValidHeadTags, TagsWithInnerContent, HasElementTags } from 'unhead/utils';
|
|
3
|
-
import { SafeInputPlugin, FlatMetaPlugin } from 'unhead/plugins';
|
|
4
3
|
import { U as UnheadContext } from './shared/react.DF9T1fqs.mjs';
|
|
5
4
|
|
|
6
5
|
const hookImports = {
|
|
7
|
-
"@unhead/vue": [
|
|
8
|
-
"useUnhead",
|
|
9
|
-
"useHead",
|
|
10
|
-
"useSeoMeta",
|
|
11
|
-
"useHeadSafe",
|
|
12
|
-
"useServerHead",
|
|
13
|
-
"useServerSeoMeta",
|
|
14
|
-
"useServerHeadSafe"
|
|
15
|
-
]
|
|
6
|
+
"@unhead/vue": ["useUnhead", ...composableNames]
|
|
16
7
|
};
|
|
17
8
|
|
|
18
9
|
function useUnhead() {
|
|
@@ -36,20 +27,28 @@ function useHead(input, options = {}) {
|
|
|
36
27
|
return entry;
|
|
37
28
|
}
|
|
38
29
|
function useHeadSafe(input, options = {}) {
|
|
39
|
-
|
|
40
|
-
head.use(SafeInputPlugin);
|
|
41
|
-
options._safe = true;
|
|
42
|
-
return useHead(input, options);
|
|
30
|
+
return useHead(input, { ...options, transform: whitelistSafeInput });
|
|
43
31
|
}
|
|
44
|
-
function useSeoMeta(input, options
|
|
45
|
-
const head = options.head || useUnhead();
|
|
46
|
-
head.use(FlatMetaPlugin);
|
|
32
|
+
function useSeoMeta(input, options) {
|
|
47
33
|
const { title, titleTemplate, ...meta } = input;
|
|
48
34
|
return useHead({
|
|
49
35
|
title,
|
|
50
36
|
titleTemplate,
|
|
37
|
+
// we need to input the meta so the reactivity will be resolved
|
|
38
|
+
// @ts-expect-error runtime type
|
|
51
39
|
_flatMeta: meta
|
|
52
|
-
},
|
|
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
|
+
});
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
const Head = ({ children, titleTemplate }) => {
|
package/dist/server.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
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 };
|
package/dist/server.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import * as
|
|
4
|
-
import { MergeHead,
|
|
5
|
-
export
|
|
6
|
-
import { R as ReactUnhead } from './shared/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';
|
|
7
7
|
|
|
8
|
-
declare function createHead<T extends MergeHead>(options?:
|
|
8
|
+
declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): ReactUnhead<T>;
|
|
9
9
|
declare function UnheadProvider({ children, value }: {
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
value: ReturnType<typeof createHead>;
|
|
12
|
-
}): react.FunctionComponentElement<react.ProviderProps<
|
|
12
|
+
}): react.FunctionComponentElement<react.ProviderProps<_unhead_schema.Unhead<any> | null>>;
|
|
13
13
|
|
|
14
14
|
export { UnheadProvider, createHead };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import * as
|
|
4
|
-
import { MergeHead,
|
|
5
|
-
export
|
|
6
|
-
import { R as ReactUnhead } from './shared/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';
|
|
7
7
|
|
|
8
|
-
declare function createHead<T extends MergeHead>(options?:
|
|
8
|
+
declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): ReactUnhead<T>;
|
|
9
9
|
declare function UnheadProvider({ children, value }: {
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
value: ReturnType<typeof createHead>;
|
|
12
|
-
}): react.FunctionComponentElement<react.ProviderProps<
|
|
12
|
+
}): react.FunctionComponentElement<react.ProviderProps<_unhead_schema.Unhead<any> | null>>;
|
|
13
13
|
|
|
14
14
|
export { UnheadProvider, createHead };
|
package/dist/server.mjs
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { createHead as createHead$1 } from 'unhead/server';
|
|
3
|
-
export
|
|
3
|
+
export * from 'unhead/server';
|
|
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';
|
|
5
7
|
|
|
6
8
|
function createHead(options = {}) {
|
|
7
9
|
return createHead$1({
|
|
8
10
|
...options,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return r.current;
|
|
13
|
-
}
|
|
14
|
-
return r;
|
|
15
|
-
}
|
|
11
|
+
plugins: [
|
|
12
|
+
...options.plugins || [],
|
|
13
|
+
ReactReactivityPlugin
|
|
16
14
|
]
|
|
17
15
|
});
|
|
18
16
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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;
|
|
@@ -0,0 +1,47 @@
|
|
|
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,5 +1,5 @@
|
|
|
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';
|
|
1
2
|
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
3
|
|
|
4
4
|
type MaybeComputedRef<T> = T | (() => T) | RefObject<T>;
|
|
5
5
|
type ResolvableArray<T> = MaybeComputedRef<MaybeComputedRef<T>[]>;
|
|
@@ -29,7 +29,7 @@ interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
|
|
|
29
29
|
*/
|
|
30
30
|
style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
|
|
31
31
|
}
|
|
32
|
-
type Title = MaybeComputedRef<number | string | Falsey> |
|
|
32
|
+
type Title = MaybeComputedRef<number | string | Falsey> | ResolvableValues<({
|
|
33
33
|
textContent: string;
|
|
34
34
|
} & SchemaAugmentations['title'])>;
|
|
35
35
|
type TitleTemplate = TitleTemplate$1 | RefObject<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
|
|
@@ -112,10 +112,6 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
112
112
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
|
|
113
113
|
*/
|
|
114
114
|
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
115
|
-
/**
|
|
116
|
-
* @internal
|
|
117
|
-
*/
|
|
118
|
-
_flatMeta?: ResolvableProperties<MetaFlatInput>;
|
|
119
115
|
}
|
|
120
116
|
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
|
|
121
117
|
head?: ReactUnhead<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
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';
|
|
1
2
|
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
3
|
|
|
4
4
|
type MaybeComputedRef<T> = T | (() => T) | RefObject<T>;
|
|
5
5
|
type ResolvableArray<T> = MaybeComputedRef<MaybeComputedRef<T>[]>;
|
|
@@ -29,7 +29,7 @@ interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
|
|
|
29
29
|
*/
|
|
30
30
|
style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
|
|
31
31
|
}
|
|
32
|
-
type Title = MaybeComputedRef<number | string | Falsey> |
|
|
32
|
+
type Title = MaybeComputedRef<number | string | Falsey> | ResolvableValues<({
|
|
33
33
|
textContent: string;
|
|
34
34
|
} & SchemaAugmentations['title'])>;
|
|
35
35
|
type TitleTemplate = TitleTemplate$1 | RefObject<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
|
|
@@ -112,10 +112,6 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
112
112
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
|
|
113
113
|
*/
|
|
114
114
|
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
115
|
-
/**
|
|
116
|
-
* @internal
|
|
117
|
-
*/
|
|
118
|
-
_flatMeta?: ResolvableProperties<MetaFlatInput>;
|
|
119
115
|
}
|
|
120
116
|
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
|
|
121
117
|
head?: ReactUnhead<any>;
|
|
@@ -0,0 +1,126 @@
|
|
|
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
ADDED
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from 'unhead/
|
|
2
|
-
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from 'unhead/
|
|
3
|
-
import { b as ReactiveHead, c as ResolvableArray, M as MaybeComputedRef } from './shared/react.
|
|
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.
|
|
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
5
|
import 'react';
|
|
6
6
|
|
|
7
7
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from 'unhead/
|
|
2
|
-
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from 'unhead/
|
|
3
|
-
import { b as ReactiveHead, c as ResolvableArray, M as MaybeComputedRef } from './shared/react.
|
|
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.
|
|
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
5
|
import 'react';
|
|
6
6
|
|
|
7
7
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
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.
|
|
4
|
+
"version": "2.0.0-alpha.9",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -18,22 +18,26 @@
|
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
|
-
"import": "./dist/index.mjs"
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
22
23
|
},
|
|
23
24
|
"./server": {
|
|
24
25
|
"types": "./dist/server.d.ts",
|
|
25
|
-
"import": "./dist/server.mjs"
|
|
26
|
+
"import": "./dist/server.mjs",
|
|
27
|
+
"require": "./dist/server.cjs"
|
|
26
28
|
},
|
|
27
29
|
"./client": {
|
|
28
30
|
"types": "./dist/client.d.ts",
|
|
29
|
-
"import": "./dist/client.mjs"
|
|
31
|
+
"import": "./dist/client.mjs",
|
|
32
|
+
"require": "./dist/client.cjs"
|
|
30
33
|
},
|
|
31
34
|
"./types": {
|
|
32
35
|
"types": "./dist/types.d.ts",
|
|
33
|
-
"import": "./dist/types.mjs"
|
|
36
|
+
"import": "./dist/types.mjs",
|
|
37
|
+
"require": "./dist/types.cjs"
|
|
34
38
|
}
|
|
35
39
|
},
|
|
36
|
-
"main": "dist/index.
|
|
40
|
+
"main": "dist/index.cjs",
|
|
37
41
|
"module": "dist/index.mjs",
|
|
38
42
|
"types": "dist/index.d.ts",
|
|
39
43
|
"typesVersions": {
|
|
@@ -64,7 +68,9 @@
|
|
|
64
68
|
]
|
|
65
69
|
},
|
|
66
70
|
"dependencies": {
|
|
67
|
-
"unhead": "2.0.0-alpha.
|
|
71
|
+
"@unhead/schema": "2.0.0-alpha.9",
|
|
72
|
+
"@unhead/shared": "2.0.0-alpha.9",
|
|
73
|
+
"unhead": "2.0.0-alpha.9"
|
|
68
74
|
},
|
|
69
75
|
"devDependencies": {
|
|
70
76
|
"@testing-library/react": "^16.2.0",
|