unhead 2.0.0-alpha.1 → 2.0.0-alpha.3
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 +2 -6
- package/dist/client.mjs +2 -6
- package/dist/index.cjs +8 -43
- package/dist/index.d.cts +6 -21
- package/dist/index.d.mts +6 -21
- package/dist/index.d.ts +6 -21
- package/dist/index.mjs +10 -39
- package/dist/legacy.cjs +26 -21
- package/dist/legacy.d.cts +13 -5
- package/dist/legacy.d.mts +13 -5
- package/dist/legacy.d.ts +13 -5
- package/dist/legacy.mjs +26 -21
- package/dist/server.cjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/shared/{unhead.CU1QS7En.cjs → unhead.9TKdmFya.cjs} +14 -7
- package/dist/shared/unhead.D--bHScR.d.cts +11 -0
- package/dist/shared/unhead.D--bHScR.d.mts +11 -0
- package/dist/shared/unhead.D--bHScR.d.ts +11 -0
- package/dist/shared/{unhead.DJ2B9fZW.mjs → unhead.q1gkl3A9.mjs} +14 -7
- package/package.json +12 -4
- package/dist/shared/unhead.Bkkr-JOb.d.cts +0 -38
- package/dist/shared/unhead.Bkkr-JOb.d.mts +0 -38
- package/dist/shared/unhead.Bkkr-JOb.d.ts +0 -38
- package/dist/shared/unhead.BxCMBVrg.mjs +0 -15
- package/dist/shared/unhead.DTD44cG0.cjs +0 -19
package/dist/client.cjs
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const shared = require('@unhead/shared');
|
|
4
|
-
const
|
|
5
|
-
const createHead$1 = require('./shared/unhead.CU1QS7En.cjs');
|
|
4
|
+
const createHead$1 = require('./shared/unhead.9TKdmFya.cjs');
|
|
6
5
|
const eventHandlers = require('./shared/unhead.C1knnawv.cjs');
|
|
7
|
-
require('unctx');
|
|
8
6
|
require('hookable');
|
|
9
7
|
require('./shared/unhead.DbMOoWpX.cjs');
|
|
10
8
|
|
|
11
9
|
function createHead(options = {}) {
|
|
12
|
-
|
|
10
|
+
return createHead$1.createHeadCore({
|
|
13
11
|
document: shared.IsBrowser ? document : undefined,
|
|
14
12
|
...options,
|
|
15
13
|
plugins: [
|
|
@@ -18,8 +16,6 @@ function createHead(options = {}) {
|
|
|
18
16
|
eventHandlers.ClientEventHandlerPlugin
|
|
19
17
|
]
|
|
20
18
|
});
|
|
21
|
-
context.unheadCtx.set(head, true);
|
|
22
|
-
return head;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
exports.ClientEventHandlerPlugin = eventHandlers.ClientEventHandlerPlugin;
|
package/dist/client.mjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { IsBrowser } from '@unhead/shared';
|
|
2
|
-
import {
|
|
3
|
-
import { c as createHeadCore } from './shared/unhead.DJ2B9fZW.mjs';
|
|
2
|
+
import { c as createHeadCore } from './shared/unhead.q1gkl3A9.mjs';
|
|
4
3
|
import { D as DomPlugin, C as ClientEventHandlerPlugin } from './shared/unhead.ovi5lkPs.mjs';
|
|
5
4
|
export { d as debouncedRenderDOMHead, r as renderDOMHead } from './shared/unhead.ovi5lkPs.mjs';
|
|
6
|
-
import 'unctx';
|
|
7
5
|
import 'hookable';
|
|
8
6
|
import './shared/unhead.9459P6Us.mjs';
|
|
9
7
|
|
|
10
8
|
function createHead(options = {}) {
|
|
11
|
-
|
|
9
|
+
return createHeadCore({
|
|
12
10
|
document: IsBrowser ? document : undefined,
|
|
13
11
|
...options,
|
|
14
12
|
plugins: [
|
|
@@ -17,8 +15,6 @@ function createHead(options = {}) {
|
|
|
17
15
|
ClientEventHandlerPlugin
|
|
18
16
|
]
|
|
19
17
|
});
|
|
20
|
-
unheadCtx.set(head, true);
|
|
21
|
-
return head;
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
export { ClientEventHandlerPlugin, DomPlugin, createHead };
|
package/dist/index.cjs
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const shared = require('@unhead/shared');
|
|
4
|
-
const
|
|
5
|
-
const createHead = require('./shared/unhead.CU1QS7En.cjs');
|
|
6
|
-
require('unctx');
|
|
4
|
+
const createHead = require('./shared/unhead.9TKdmFya.cjs');
|
|
7
5
|
require('hookable');
|
|
8
6
|
require('./shared/unhead.DbMOoWpX.cjs');
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
from: "unhead",
|
|
13
|
-
imports: shared.composableNames
|
|
14
|
-
}
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
function useHead(input, options = {}) {
|
|
18
|
-
const head = options.head || context.useUnhead();
|
|
19
|
-
return head.push(input, options);
|
|
8
|
+
function useHead(unhead, input, options = {}) {
|
|
9
|
+
return unhead.push(input, options);
|
|
20
10
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return useHead(input, {
|
|
11
|
+
function useHeadSafe(unhead, input, options) {
|
|
12
|
+
return useHead(unhead, input, {
|
|
24
13
|
...options,
|
|
14
|
+
// @ts-expect-error untyped
|
|
25
15
|
transform: shared.whitelistSafeInput
|
|
26
16
|
});
|
|
27
17
|
}
|
|
28
|
-
|
|
29
|
-
function useSeoMeta(input, options) {
|
|
18
|
+
function useSeoMeta(unhead, input, options) {
|
|
30
19
|
const { title, titleTemplate, ...meta } = input;
|
|
31
|
-
return useHead({
|
|
20
|
+
return useHead(unhead, {
|
|
32
21
|
title,
|
|
33
22
|
titleTemplate,
|
|
34
23
|
// we need to input the meta so the reactivity will be resolved
|
|
35
|
-
// @ts-expect-error runtime type
|
|
36
24
|
_flatMeta: meta
|
|
37
25
|
}, {
|
|
38
26
|
...options,
|
|
@@ -48,30 +36,7 @@ function useSeoMeta(input, options) {
|
|
|
48
36
|
});
|
|
49
37
|
}
|
|
50
38
|
|
|
51
|
-
function useServerHead(input, options = {}) {
|
|
52
|
-
return useHead(input, { ...options, mode: "server" });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function useServerHeadSafe(input, options = {}) {
|
|
56
|
-
return useHeadSafe(input, { ...options, mode: "server" });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function useServerSeoMeta(input, options) {
|
|
60
|
-
return useSeoMeta(input, {
|
|
61
|
-
...options,
|
|
62
|
-
mode: "server"
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
exports.composableNames = shared.composableNames;
|
|
67
|
-
exports.tryUseUnhead = context.tryUseUnhead;
|
|
68
|
-
exports.unheadCtx = context.unheadCtx;
|
|
69
|
-
exports.useUnhead = context.useUnhead;
|
|
70
39
|
exports.createHeadCore = createHead.createHeadCore;
|
|
71
|
-
exports.unheadComposablesImports = unheadComposablesImports;
|
|
72
40
|
exports.useHead = useHead;
|
|
73
41
|
exports.useHeadSafe = useHeadSafe;
|
|
74
42
|
exports.useSeoMeta = useSeoMeta;
|
|
75
|
-
exports.useServerHead = useServerHead;
|
|
76
|
-
exports.useServerHeadSafe = useServerHeadSafe;
|
|
77
|
-
exports.useServerSeoMeta = useServerSeoMeta;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
import { MergeHead, Head,
|
|
2
|
-
export { c as createHeadCore
|
|
3
|
-
export { composableNames } from '@unhead/shared';
|
|
4
|
-
import 'unctx/index';
|
|
5
|
-
|
|
6
|
-
declare const unheadComposablesImports: {
|
|
7
|
-
from: string;
|
|
8
|
-
imports: string[];
|
|
9
|
-
}[];
|
|
1
|
+
import { MergeHead, Head, Unhead, HeadEntryOptions, HeadSafe, ActiveHeadEntry, UseSeoMetaInput } from '@unhead/schema';
|
|
2
|
+
export { c as createHeadCore } from './shared/unhead.D--bHScR.cjs';
|
|
10
3
|
|
|
11
4
|
type UseHeadInput<T extends MergeHead> = Head<T>;
|
|
12
|
-
declare function useHead<T extends
|
|
13
|
-
|
|
14
|
-
declare function
|
|
15
|
-
|
|
16
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
17
|
-
|
|
18
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>>;
|
|
19
|
-
|
|
20
|
-
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T>;
|
|
21
|
-
|
|
22
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
5
|
+
declare function useHead<T extends Unhead<any>>(unhead: T, input: Parameters<T['push']>[0], options?: HeadEntryOptions): ReturnType<T['push']>;
|
|
6
|
+
declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
|
7
|
+
declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
23
8
|
|
|
24
|
-
export { type UseHeadInput,
|
|
9
|
+
export { type UseHeadInput, useHead, useHeadSafe, useSeoMeta };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
import { MergeHead, Head,
|
|
2
|
-
export { c as createHeadCore
|
|
3
|
-
export { composableNames } from '@unhead/shared';
|
|
4
|
-
import 'unctx/index';
|
|
5
|
-
|
|
6
|
-
declare const unheadComposablesImports: {
|
|
7
|
-
from: string;
|
|
8
|
-
imports: string[];
|
|
9
|
-
}[];
|
|
1
|
+
import { MergeHead, Head, Unhead, HeadEntryOptions, HeadSafe, ActiveHeadEntry, UseSeoMetaInput } from '@unhead/schema';
|
|
2
|
+
export { c as createHeadCore } from './shared/unhead.D--bHScR.mjs';
|
|
10
3
|
|
|
11
4
|
type UseHeadInput<T extends MergeHead> = Head<T>;
|
|
12
|
-
declare function useHead<T extends
|
|
13
|
-
|
|
14
|
-
declare function
|
|
15
|
-
|
|
16
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
17
|
-
|
|
18
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>>;
|
|
19
|
-
|
|
20
|
-
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T>;
|
|
21
|
-
|
|
22
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
5
|
+
declare function useHead<T extends Unhead<any>>(unhead: T, input: Parameters<T['push']>[0], options?: HeadEntryOptions): ReturnType<T['push']>;
|
|
6
|
+
declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
|
7
|
+
declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
23
8
|
|
|
24
|
-
export { type UseHeadInput,
|
|
9
|
+
export { type UseHeadInput, useHead, useHeadSafe, useSeoMeta };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
import { MergeHead, Head,
|
|
2
|
-
export { c as createHeadCore
|
|
3
|
-
export { composableNames } from '@unhead/shared';
|
|
4
|
-
import 'unctx/index';
|
|
5
|
-
|
|
6
|
-
declare const unheadComposablesImports: {
|
|
7
|
-
from: string;
|
|
8
|
-
imports: string[];
|
|
9
|
-
}[];
|
|
1
|
+
import { MergeHead, Head, Unhead, HeadEntryOptions, HeadSafe, ActiveHeadEntry, UseSeoMetaInput } from '@unhead/schema';
|
|
2
|
+
export { c as createHeadCore } from './shared/unhead.D--bHScR.js';
|
|
10
3
|
|
|
11
4
|
type UseHeadInput<T extends MergeHead> = Head<T>;
|
|
12
|
-
declare function useHead<T extends
|
|
13
|
-
|
|
14
|
-
declare function
|
|
15
|
-
|
|
16
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
17
|
-
|
|
18
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>>;
|
|
19
|
-
|
|
20
|
-
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T>;
|
|
21
|
-
|
|
22
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
5
|
+
declare function useHead<T extends Unhead<any>>(unhead: T, input: Parameters<T['push']>[0], options?: HeadEntryOptions): ReturnType<T['push']>;
|
|
6
|
+
declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
|
7
|
+
declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
23
8
|
|
|
24
|
-
export { type UseHeadInput,
|
|
9
|
+
export { type UseHeadInput, useHead, useHeadSafe, useSeoMeta };
|
package/dist/index.mjs
CHANGED
|
@@ -1,38 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { u as useUnhead } from './shared/unhead.BxCMBVrg.mjs';
|
|
4
|
-
export { t as tryUseUnhead, a as unheadCtx } from './shared/unhead.BxCMBVrg.mjs';
|
|
5
|
-
export { c as createHeadCore } from './shared/unhead.DJ2B9fZW.mjs';
|
|
6
|
-
import 'unctx';
|
|
1
|
+
import { whitelistSafeInput, unpackMeta } from '@unhead/shared';
|
|
2
|
+
export { c as createHeadCore } from './shared/unhead.q1gkl3A9.mjs';
|
|
7
3
|
import 'hookable';
|
|
8
4
|
import './shared/unhead.9459P6Us.mjs';
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
from: "unhead",
|
|
13
|
-
imports: composableNames
|
|
14
|
-
}
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
function useHead(input, options = {}) {
|
|
18
|
-
const head = options.head || useUnhead();
|
|
19
|
-
return head.push(input, options);
|
|
6
|
+
function useHead(unhead, input, options = {}) {
|
|
7
|
+
return unhead.push(input, options);
|
|
20
8
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return useHead(input, {
|
|
9
|
+
function useHeadSafe(unhead, input, options) {
|
|
10
|
+
return useHead(unhead, input, {
|
|
24
11
|
...options,
|
|
12
|
+
// @ts-expect-error untyped
|
|
25
13
|
transform: whitelistSafeInput
|
|
26
14
|
});
|
|
27
15
|
}
|
|
28
|
-
|
|
29
|
-
function useSeoMeta(input, options) {
|
|
16
|
+
function useSeoMeta(unhead, input, options) {
|
|
30
17
|
const { title, titleTemplate, ...meta } = input;
|
|
31
|
-
return useHead({
|
|
18
|
+
return useHead(unhead, {
|
|
32
19
|
title,
|
|
33
20
|
titleTemplate,
|
|
34
21
|
// we need to input the meta so the reactivity will be resolved
|
|
35
|
-
// @ts-expect-error runtime type
|
|
36
22
|
_flatMeta: meta
|
|
37
23
|
}, {
|
|
38
24
|
...options,
|
|
@@ -48,19 +34,4 @@ function useSeoMeta(input, options) {
|
|
|
48
34
|
});
|
|
49
35
|
}
|
|
50
36
|
|
|
51
|
-
|
|
52
|
-
return useHead(input, { ...options, mode: "server" });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function useServerHeadSafe(input, options = {}) {
|
|
56
|
-
return useHeadSafe(input, { ...options, mode: "server" });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function useServerSeoMeta(input, options) {
|
|
60
|
-
return useSeoMeta(input, {
|
|
61
|
-
...options,
|
|
62
|
-
mode: "server"
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { unheadComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta, useUnhead };
|
|
37
|
+
export { useHead, useHeadSafe, useSeoMeta };
|
package/dist/legacy.cjs
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const shared = require('@unhead/shared');
|
|
4
4
|
const eventHandlers = require('./shared/unhead.C1knnawv.cjs');
|
|
5
|
-
const
|
|
6
|
-
const createHead$1 = require('./shared/unhead.CU1QS7En.cjs');
|
|
5
|
+
const createHead$1 = require('./shared/unhead.9TKdmFya.cjs');
|
|
7
6
|
const promises = require('./shared/unhead.DGQq1RAN.cjs');
|
|
8
7
|
const payload = require('./shared/unhead.B1vp-BN3.cjs');
|
|
9
|
-
require('unctx');
|
|
10
8
|
require('hookable');
|
|
11
9
|
require('./shared/unhead.DbMOoWpX.cjs');
|
|
12
10
|
|
|
@@ -221,8 +219,18 @@ function useScript(_input, _options) {
|
|
|
221
219
|
return res;
|
|
222
220
|
}
|
|
223
221
|
|
|
222
|
+
const activeHead = { value: null };
|
|
223
|
+
function getActiveHead() {
|
|
224
|
+
return activeHead?.value;
|
|
225
|
+
}
|
|
226
|
+
const unheadComposablesImports = [
|
|
227
|
+
{
|
|
228
|
+
from: "unhead",
|
|
229
|
+
imports: shared.composableNames
|
|
230
|
+
}
|
|
231
|
+
];
|
|
224
232
|
function createServerHead(options = {}) {
|
|
225
|
-
return createHead$1.createHeadCore({
|
|
233
|
+
return activeHead.value = createHead$1.createHeadCore({
|
|
226
234
|
disableCapoSorting: true,
|
|
227
235
|
...options,
|
|
228
236
|
// @ts-expect-error untyped
|
|
@@ -238,20 +246,17 @@ function createServerHead(options = {}) {
|
|
|
238
246
|
});
|
|
239
247
|
}
|
|
240
248
|
function createHead(options = {}) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
function getActiveHead() {
|
|
254
|
-
return context.tryUseUnhead();
|
|
249
|
+
return activeHead.value = createHead$1.createHeadCore({
|
|
250
|
+
disableCapoSorting: true,
|
|
251
|
+
...options,
|
|
252
|
+
plugins: [
|
|
253
|
+
...options.plugins || [],
|
|
254
|
+
eventHandlers.DomPlugin(),
|
|
255
|
+
promises.DeprecationsPlugin,
|
|
256
|
+
promises.PromisesPlugin,
|
|
257
|
+
eventHandlers.ClientEventHandlerPlugin
|
|
258
|
+
]
|
|
259
|
+
});
|
|
255
260
|
}
|
|
256
261
|
function useHead(input, options = {}) {
|
|
257
262
|
const head = options.head || getActiveHead();
|
|
@@ -299,14 +304,14 @@ function useServerSeoMeta(input, options) {
|
|
|
299
304
|
});
|
|
300
305
|
}
|
|
301
306
|
|
|
302
|
-
exports.
|
|
303
|
-
exports.unheadCtx = context.unheadCtx;
|
|
304
|
-
exports.useUnhead = context.useUnhead;
|
|
307
|
+
exports.composableNames = shared.composableNames;
|
|
305
308
|
exports.createHeadCore = createHead$1.createHeadCore;
|
|
309
|
+
exports.activeHead = activeHead;
|
|
306
310
|
exports.createHead = createHead;
|
|
307
311
|
exports.createServerHead = createServerHead;
|
|
308
312
|
exports.getActiveHead = getActiveHead;
|
|
309
313
|
exports.resolveScriptKey = resolveScriptKey;
|
|
314
|
+
exports.unheadComposablesImports = unheadComposablesImports;
|
|
310
315
|
exports.useHead = useHead;
|
|
311
316
|
exports.useHeadSafe = useHeadSafe;
|
|
312
317
|
exports.useScript = useScript;
|
package/dist/legacy.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Script, ActiveHeadEntry, HeadEntryOptions, Head, CreateHeadOptions,
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import { Script, ActiveHeadEntry, HeadEntryOptions, Unhead, Head, CreateHeadOptions, MergeHead, HeadSafe, UseSeoMetaInput } from '@unhead/schema';
|
|
2
|
+
export { composableNames } from '@unhead/shared';
|
|
3
|
+
export { c as createHeadCore } from './shared/unhead.D--bHScR.cjs';
|
|
4
4
|
|
|
5
5
|
type UseScriptInput = string | (Omit<Script, 'src'> & {
|
|
6
6
|
src: string;
|
|
@@ -93,9 +93,17 @@ type UseFunctionType<T, U> = T extends {
|
|
|
93
93
|
*/
|
|
94
94
|
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
|
|
95
95
|
|
|
96
|
+
declare const activeHead: {
|
|
97
|
+
value: Unhead<any> | null;
|
|
98
|
+
};
|
|
99
|
+
declare function getActiveHead(): Unhead<any> | null;
|
|
100
|
+
declare const unheadComposablesImports: {
|
|
101
|
+
from: string;
|
|
102
|
+
imports: string[];
|
|
103
|
+
}[];
|
|
104
|
+
|
|
96
105
|
declare function createServerHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
97
106
|
declare function createHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
98
|
-
declare function getActiveHead(): Unhead<Head<MergeHead>> | null;
|
|
99
107
|
type UseHeadInput<T extends MergeHead> = Head<T>;
|
|
100
108
|
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
101
109
|
declare function useHeadSafe(input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe> | void;
|
|
@@ -104,4 +112,4 @@ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, opti
|
|
|
104
112
|
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T> | void;
|
|
105
113
|
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
106
114
|
|
|
107
|
-
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type UseHeadInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptResolvedInput, type UseScriptStatus, createHead, createServerHead, getActiveHead, resolveScriptKey, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
|
115
|
+
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type UseHeadInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptResolvedInput, type UseScriptStatus, activeHead, createHead, createServerHead, getActiveHead, resolveScriptKey, unheadComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/legacy.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Script, ActiveHeadEntry, HeadEntryOptions, Head, CreateHeadOptions,
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import { Script, ActiveHeadEntry, HeadEntryOptions, Unhead, Head, CreateHeadOptions, MergeHead, HeadSafe, UseSeoMetaInput } from '@unhead/schema';
|
|
2
|
+
export { composableNames } from '@unhead/shared';
|
|
3
|
+
export { c as createHeadCore } from './shared/unhead.D--bHScR.mjs';
|
|
4
4
|
|
|
5
5
|
type UseScriptInput = string | (Omit<Script, 'src'> & {
|
|
6
6
|
src: string;
|
|
@@ -93,9 +93,17 @@ type UseFunctionType<T, U> = T extends {
|
|
|
93
93
|
*/
|
|
94
94
|
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
|
|
95
95
|
|
|
96
|
+
declare const activeHead: {
|
|
97
|
+
value: Unhead<any> | null;
|
|
98
|
+
};
|
|
99
|
+
declare function getActiveHead(): Unhead<any> | null;
|
|
100
|
+
declare const unheadComposablesImports: {
|
|
101
|
+
from: string;
|
|
102
|
+
imports: string[];
|
|
103
|
+
}[];
|
|
104
|
+
|
|
96
105
|
declare function createServerHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
97
106
|
declare function createHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
98
|
-
declare function getActiveHead(): Unhead<Head<MergeHead>> | null;
|
|
99
107
|
type UseHeadInput<T extends MergeHead> = Head<T>;
|
|
100
108
|
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
101
109
|
declare function useHeadSafe(input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe> | void;
|
|
@@ -104,4 +112,4 @@ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, opti
|
|
|
104
112
|
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T> | void;
|
|
105
113
|
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
106
114
|
|
|
107
|
-
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type UseHeadInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptResolvedInput, type UseScriptStatus, createHead, createServerHead, getActiveHead, resolveScriptKey, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
|
115
|
+
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type UseHeadInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptResolvedInput, type UseScriptStatus, activeHead, createHead, createServerHead, getActiveHead, resolveScriptKey, unheadComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/legacy.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Script, ActiveHeadEntry, HeadEntryOptions, Head, CreateHeadOptions,
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import { Script, ActiveHeadEntry, HeadEntryOptions, Unhead, Head, CreateHeadOptions, MergeHead, HeadSafe, UseSeoMetaInput } from '@unhead/schema';
|
|
2
|
+
export { composableNames } from '@unhead/shared';
|
|
3
|
+
export { c as createHeadCore } from './shared/unhead.D--bHScR.js';
|
|
4
4
|
|
|
5
5
|
type UseScriptInput = string | (Omit<Script, 'src'> & {
|
|
6
6
|
src: string;
|
|
@@ -93,9 +93,17 @@ type UseFunctionType<T, U> = T extends {
|
|
|
93
93
|
*/
|
|
94
94
|
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
|
|
95
95
|
|
|
96
|
+
declare const activeHead: {
|
|
97
|
+
value: Unhead<any> | null;
|
|
98
|
+
};
|
|
99
|
+
declare function getActiveHead(): Unhead<any> | null;
|
|
100
|
+
declare const unheadComposablesImports: {
|
|
101
|
+
from: string;
|
|
102
|
+
imports: string[];
|
|
103
|
+
}[];
|
|
104
|
+
|
|
96
105
|
declare function createServerHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
97
106
|
declare function createHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
98
|
-
declare function getActiveHead(): Unhead<Head<MergeHead>> | null;
|
|
99
107
|
type UseHeadInput<T extends MergeHead> = Head<T>;
|
|
100
108
|
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
101
109
|
declare function useHeadSafe(input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe> | void;
|
|
@@ -104,4 +112,4 @@ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, opti
|
|
|
104
112
|
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T> | void;
|
|
105
113
|
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
106
114
|
|
|
107
|
-
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type UseHeadInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptResolvedInput, type UseScriptStatus, createHead, createServerHead, getActiveHead, resolveScriptKey, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
|
115
|
+
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type UseHeadInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptResolvedInput, type UseScriptStatus, activeHead, createHead, createServerHead, getActiveHead, resolveScriptKey, unheadComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/legacy.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { hashCode, ScriptNetworkEvents,
|
|
1
|
+
import { hashCode, ScriptNetworkEvents, composableNames, whitelistSafeInput, unpackMeta } from '@unhead/shared';
|
|
2
|
+
export { composableNames } from '@unhead/shared';
|
|
2
3
|
import { D as DomPlugin, C as ClientEventHandlerPlugin } from './shared/unhead.ovi5lkPs.mjs';
|
|
3
|
-
import {
|
|
4
|
-
export { u as useUnhead } from './shared/unhead.BxCMBVrg.mjs';
|
|
5
|
-
import { c as createHeadCore } from './shared/unhead.DJ2B9fZW.mjs';
|
|
4
|
+
import { c as createHeadCore } from './shared/unhead.q1gkl3A9.mjs';
|
|
6
5
|
import { D as DeprecationsPlugin, P as PromisesPlugin } from './shared/unhead.YfQbj2z7.mjs';
|
|
7
6
|
import { S as ServerEventHandlerPlugin, P as PayloadPlugin } from './shared/unhead.Dk9EcP_t.mjs';
|
|
8
|
-
import 'unctx';
|
|
9
7
|
import 'hookable';
|
|
10
8
|
import './shared/unhead.9459P6Us.mjs';
|
|
11
9
|
|
|
@@ -220,8 +218,18 @@ function useScript(_input, _options) {
|
|
|
220
218
|
return res;
|
|
221
219
|
}
|
|
222
220
|
|
|
221
|
+
const activeHead = { value: null };
|
|
222
|
+
function getActiveHead() {
|
|
223
|
+
return activeHead?.value;
|
|
224
|
+
}
|
|
225
|
+
const unheadComposablesImports = [
|
|
226
|
+
{
|
|
227
|
+
from: "unhead",
|
|
228
|
+
imports: composableNames
|
|
229
|
+
}
|
|
230
|
+
];
|
|
223
231
|
function createServerHead(options = {}) {
|
|
224
|
-
return createHeadCore({
|
|
232
|
+
return activeHead.value = createHeadCore({
|
|
225
233
|
disableCapoSorting: true,
|
|
226
234
|
...options,
|
|
227
235
|
// @ts-expect-error untyped
|
|
@@ -237,20 +245,17 @@ function createServerHead(options = {}) {
|
|
|
237
245
|
});
|
|
238
246
|
}
|
|
239
247
|
function createHead(options = {}) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
function getActiveHead() {
|
|
253
|
-
return tryUseUnhead();
|
|
248
|
+
return activeHead.value = createHeadCore({
|
|
249
|
+
disableCapoSorting: true,
|
|
250
|
+
...options,
|
|
251
|
+
plugins: [
|
|
252
|
+
...options.plugins || [],
|
|
253
|
+
DomPlugin(),
|
|
254
|
+
DeprecationsPlugin,
|
|
255
|
+
PromisesPlugin,
|
|
256
|
+
ClientEventHandlerPlugin
|
|
257
|
+
]
|
|
258
|
+
});
|
|
254
259
|
}
|
|
255
260
|
function useHead(input, options = {}) {
|
|
256
261
|
const head = options.head || getActiveHead();
|
|
@@ -298,4 +303,4 @@ function useServerSeoMeta(input, options) {
|
|
|
298
303
|
});
|
|
299
304
|
}
|
|
300
305
|
|
|
301
|
-
export { createHead, createHeadCore, createServerHead, getActiveHead, resolveScriptKey,
|
|
306
|
+
export { activeHead, createHead, createHeadCore, createServerHead, getActiveHead, resolveScriptKey, unheadComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/server.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const createHead$1 = require('./shared/unhead.
|
|
3
|
+
const createHead$1 = require('./shared/unhead.9TKdmFya.cjs');
|
|
4
4
|
const payload = require('./shared/unhead.B1vp-BN3.cjs');
|
|
5
5
|
const shared = require('@unhead/shared');
|
|
6
6
|
require('hookable');
|
package/dist/server.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createHeadCore } from './shared/unhead.
|
|
1
|
+
import { c as createHeadCore } from './shared/unhead.q1gkl3A9.mjs';
|
|
2
2
|
import { P as PayloadPlugin, S as ServerEventHandlerPlugin } from './shared/unhead.Dk9EcP_t.mjs';
|
|
3
3
|
import { TagsWithInnerContent, SelfClosingTags } from '@unhead/shared';
|
|
4
4
|
import 'hookable';
|
|
@@ -7,6 +7,17 @@ const xss = require('./unhead.DbMOoWpX.cjs');
|
|
|
7
7
|
function filterMode(mode, ssr) {
|
|
8
8
|
return !mode || mode === "server" && ssr || mode === "client" && !ssr;
|
|
9
9
|
}
|
|
10
|
+
function registerPlugins(head, plugins, ssr) {
|
|
11
|
+
plugins.forEach((p) => {
|
|
12
|
+
const plugin = typeof p === "function" ? p(head) : p;
|
|
13
|
+
if (!plugin.key || !head.plugins.some((existingPlugin) => existingPlugin.key === plugin.key)) {
|
|
14
|
+
head.plugins.push(plugin);
|
|
15
|
+
if (filterMode(plugin.mode, ssr)) {
|
|
16
|
+
head.hooks.addHooks(plugin.hooks || {});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
10
21
|
function createHeadCore(options = {}) {
|
|
11
22
|
const hooks = hookable.createHooks();
|
|
12
23
|
hooks.addHooks(options.hooks || {});
|
|
@@ -28,11 +39,7 @@ function createHeadCore(options = {}) {
|
|
|
28
39
|
return entries;
|
|
29
40
|
},
|
|
30
41
|
use(p) {
|
|
31
|
-
|
|
32
|
-
if (!plugin.key || !plugins.some((p2) => p2.key === plugin.key)) {
|
|
33
|
-
plugins.push(plugin);
|
|
34
|
-
filterMode(plugin.mode, ssr) && hooks.addHooks(plugin.hooks || {});
|
|
35
|
-
}
|
|
42
|
+
registerPlugins(head, [p], ssr);
|
|
36
43
|
},
|
|
37
44
|
push(input, entryOptions) {
|
|
38
45
|
delete entryOptions?.head;
|
|
@@ -81,14 +88,14 @@ function createHeadCore(options = {}) {
|
|
|
81
88
|
return resolveCtx.tags;
|
|
82
89
|
}
|
|
83
90
|
};
|
|
84
|
-
[
|
|
91
|
+
registerPlugins(head, [
|
|
85
92
|
xss.DedupePlugin,
|
|
86
93
|
xss.SortPlugin,
|
|
87
94
|
xss.TemplateParamsPlugin,
|
|
88
95
|
xss.TitleTemplatePlugin,
|
|
89
96
|
xss.XSSPlugin,
|
|
90
97
|
...options?.plugins || []
|
|
91
|
-
]
|
|
98
|
+
], ssr);
|
|
92
99
|
head.hooks.callHook("init", head);
|
|
93
100
|
return head;
|
|
94
101
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Head, CreateHeadOptions, Unhead } from '@unhead/schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
5
|
+
* and does not register DOM plugins.
|
|
6
|
+
*
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
declare function createHeadCore<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
10
|
+
|
|
11
|
+
export { createHeadCore as c };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Head, CreateHeadOptions, Unhead } from '@unhead/schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
5
|
+
* and does not register DOM plugins.
|
|
6
|
+
*
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
declare function createHeadCore<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
10
|
+
|
|
11
|
+
export { createHeadCore as c };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Head, CreateHeadOptions, Unhead } from '@unhead/schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
5
|
+
* and does not register DOM plugins.
|
|
6
|
+
*
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
declare function createHeadCore<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
10
|
+
|
|
11
|
+
export { createHeadCore as c };
|
|
@@ -5,6 +5,17 @@ import { D as DedupePlugin, S as SortPlugin, T as TemplateParamsPlugin, a as Tit
|
|
|
5
5
|
function filterMode(mode, ssr) {
|
|
6
6
|
return !mode || mode === "server" && ssr || mode === "client" && !ssr;
|
|
7
7
|
}
|
|
8
|
+
function registerPlugins(head, plugins, ssr) {
|
|
9
|
+
plugins.forEach((p) => {
|
|
10
|
+
const plugin = typeof p === "function" ? p(head) : p;
|
|
11
|
+
if (!plugin.key || !head.plugins.some((existingPlugin) => existingPlugin.key === plugin.key)) {
|
|
12
|
+
head.plugins.push(plugin);
|
|
13
|
+
if (filterMode(plugin.mode, ssr)) {
|
|
14
|
+
head.hooks.addHooks(plugin.hooks || {});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
8
19
|
function createHeadCore(options = {}) {
|
|
9
20
|
const hooks = createHooks();
|
|
10
21
|
hooks.addHooks(options.hooks || {});
|
|
@@ -26,11 +37,7 @@ function createHeadCore(options = {}) {
|
|
|
26
37
|
return entries;
|
|
27
38
|
},
|
|
28
39
|
use(p) {
|
|
29
|
-
|
|
30
|
-
if (!plugin.key || !plugins.some((p2) => p2.key === plugin.key)) {
|
|
31
|
-
plugins.push(plugin);
|
|
32
|
-
filterMode(plugin.mode, ssr) && hooks.addHooks(plugin.hooks || {});
|
|
33
|
-
}
|
|
40
|
+
registerPlugins(head, [p], ssr);
|
|
34
41
|
},
|
|
35
42
|
push(input, entryOptions) {
|
|
36
43
|
delete entryOptions?.head;
|
|
@@ -79,14 +86,14 @@ function createHeadCore(options = {}) {
|
|
|
79
86
|
return resolveCtx.tags;
|
|
80
87
|
}
|
|
81
88
|
};
|
|
82
|
-
[
|
|
89
|
+
registerPlugins(head, [
|
|
83
90
|
DedupePlugin,
|
|
84
91
|
SortPlugin,
|
|
85
92
|
TemplateParamsPlugin,
|
|
86
93
|
TitleTemplatePlugin,
|
|
87
94
|
XSSPlugin,
|
|
88
95
|
...options?.plugins || []
|
|
89
|
-
]
|
|
96
|
+
], ssr);
|
|
90
97
|
head.hooks.callHook("init", head);
|
|
91
98
|
return head;
|
|
92
99
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unhead",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.3",
|
|
5
5
|
"description": "Full-stack <head> manager built for any framework.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
8
8
|
"email": "harlan@harlanzw.com",
|
|
9
9
|
"url": "https://harlanzw.com/"
|
|
10
10
|
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"tag": "next"
|
|
14
|
+
},
|
|
11
15
|
"license": "MIT",
|
|
12
16
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
13
17
|
"homepage": "https://unhead.unjs.io",
|
|
@@ -40,6 +44,11 @@
|
|
|
40
44
|
"types": "./dist/client.d.ts",
|
|
41
45
|
"import": "./dist/client.mjs",
|
|
42
46
|
"require": "./dist/client.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./legacy": {
|
|
49
|
+
"types": "./dist/legacy.d.ts",
|
|
50
|
+
"import": "./dist/legacy.mjs",
|
|
51
|
+
"require": "./dist/legacy.cjs"
|
|
43
52
|
}
|
|
44
53
|
},
|
|
45
54
|
"main": "dist/index.cjs",
|
|
@@ -70,9 +79,8 @@
|
|
|
70
79
|
],
|
|
71
80
|
"dependencies": {
|
|
72
81
|
"hookable": "^5.5.3",
|
|
73
|
-
"
|
|
74
|
-
"@unhead/
|
|
75
|
-
"@unhead/shared": "2.0.0-alpha.1"
|
|
82
|
+
"@unhead/schema": "2.0.0-alpha.3",
|
|
83
|
+
"@unhead/shared": "2.0.0-alpha.3"
|
|
76
84
|
},
|
|
77
85
|
"scripts": {
|
|
78
86
|
"build": "unbuild .",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as unctx_index from 'unctx/index';
|
|
2
|
-
import { Unhead, Head, MergeHead, CreateHeadOptions } from '@unhead/schema';
|
|
3
|
-
|
|
4
|
-
type UnheadInstance = Unhead<Head<MergeHead>>;
|
|
5
|
-
declare const unheadCtx: unctx_index.UseContext<Unhead<any>>;
|
|
6
|
-
/**
|
|
7
|
-
* Get access to Unhead instance.
|
|
8
|
-
*
|
|
9
|
-
* Throws an error if Unhead instance is unavailable.
|
|
10
|
-
* @example
|
|
11
|
-
* ```js
|
|
12
|
-
* const unhead = useUnhead()
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
declare function useUnhead<T extends UnheadInstance>(): T;
|
|
16
|
-
/**
|
|
17
|
-
* Get access to Unhead instance.
|
|
18
|
-
*
|
|
19
|
-
* Returns null if Unhead instance is unavailable.
|
|
20
|
-
* @example
|
|
21
|
-
* ```js
|
|
22
|
-
* const unhead = tryUseUnhead()
|
|
23
|
-
* if (unhead) {
|
|
24
|
-
* // Do something
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
declare function tryUseUnhead<T extends UnheadInstance>(): T | null;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
32
|
-
* and does not register DOM plugins.
|
|
33
|
-
*
|
|
34
|
-
* @param options
|
|
35
|
-
*/
|
|
36
|
-
declare function createHeadCore<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
37
|
-
|
|
38
|
-
export { useUnhead as a, createHeadCore as c, tryUseUnhead as t, unheadCtx as u };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as unctx_index from 'unctx/index';
|
|
2
|
-
import { Unhead, Head, MergeHead, CreateHeadOptions } from '@unhead/schema';
|
|
3
|
-
|
|
4
|
-
type UnheadInstance = Unhead<Head<MergeHead>>;
|
|
5
|
-
declare const unheadCtx: unctx_index.UseContext<Unhead<any>>;
|
|
6
|
-
/**
|
|
7
|
-
* Get access to Unhead instance.
|
|
8
|
-
*
|
|
9
|
-
* Throws an error if Unhead instance is unavailable.
|
|
10
|
-
* @example
|
|
11
|
-
* ```js
|
|
12
|
-
* const unhead = useUnhead()
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
declare function useUnhead<T extends UnheadInstance>(): T;
|
|
16
|
-
/**
|
|
17
|
-
* Get access to Unhead instance.
|
|
18
|
-
*
|
|
19
|
-
* Returns null if Unhead instance is unavailable.
|
|
20
|
-
* @example
|
|
21
|
-
* ```js
|
|
22
|
-
* const unhead = tryUseUnhead()
|
|
23
|
-
* if (unhead) {
|
|
24
|
-
* // Do something
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
declare function tryUseUnhead<T extends UnheadInstance>(): T | null;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
32
|
-
* and does not register DOM plugins.
|
|
33
|
-
*
|
|
34
|
-
* @param options
|
|
35
|
-
*/
|
|
36
|
-
declare function createHeadCore<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
37
|
-
|
|
38
|
-
export { useUnhead as a, createHeadCore as c, tryUseUnhead as t, unheadCtx as u };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as unctx_index from 'unctx/index';
|
|
2
|
-
import { Unhead, Head, MergeHead, CreateHeadOptions } from '@unhead/schema';
|
|
3
|
-
|
|
4
|
-
type UnheadInstance = Unhead<Head<MergeHead>>;
|
|
5
|
-
declare const unheadCtx: unctx_index.UseContext<Unhead<any>>;
|
|
6
|
-
/**
|
|
7
|
-
* Get access to Unhead instance.
|
|
8
|
-
*
|
|
9
|
-
* Throws an error if Unhead instance is unavailable.
|
|
10
|
-
* @example
|
|
11
|
-
* ```js
|
|
12
|
-
* const unhead = useUnhead()
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
declare function useUnhead<T extends UnheadInstance>(): T;
|
|
16
|
-
/**
|
|
17
|
-
* Get access to Unhead instance.
|
|
18
|
-
*
|
|
19
|
-
* Returns null if Unhead instance is unavailable.
|
|
20
|
-
* @example
|
|
21
|
-
* ```js
|
|
22
|
-
* const unhead = tryUseUnhead()
|
|
23
|
-
* if (unhead) {
|
|
24
|
-
* // Do something
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
declare function tryUseUnhead<T extends UnheadInstance>(): T | null;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
32
|
-
* and does not register DOM plugins.
|
|
33
|
-
*
|
|
34
|
-
* @param options
|
|
35
|
-
*/
|
|
36
|
-
declare function createHeadCore<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
37
|
-
|
|
38
|
-
export { useUnhead as a, createHeadCore as c, tryUseUnhead as t, unheadCtx as u };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getContext } from 'unctx';
|
|
2
|
-
|
|
3
|
-
const unheadCtx = getContext("unhead");
|
|
4
|
-
function useUnhead() {
|
|
5
|
-
const instance = unheadCtx.tryUse();
|
|
6
|
-
if (!instance) {
|
|
7
|
-
throw new Error("Unhead instance is unavailable!");
|
|
8
|
-
}
|
|
9
|
-
return instance;
|
|
10
|
-
}
|
|
11
|
-
function tryUseUnhead() {
|
|
12
|
-
return unheadCtx.tryUse();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { unheadCtx as a, tryUseUnhead as t, useUnhead as u };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const unctx = require('unctx');
|
|
4
|
-
|
|
5
|
-
const unheadCtx = unctx.getContext("unhead");
|
|
6
|
-
function useUnhead() {
|
|
7
|
-
const instance = unheadCtx.tryUse();
|
|
8
|
-
if (!instance) {
|
|
9
|
-
throw new Error("Unhead instance is unavailable!");
|
|
10
|
-
}
|
|
11
|
-
return instance;
|
|
12
|
-
}
|
|
13
|
-
function tryUseUnhead() {
|
|
14
|
-
return unheadCtx.tryUse();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.tryUseUnhead = tryUseUnhead;
|
|
18
|
-
exports.unheadCtx = unheadCtx;
|
|
19
|
-
exports.useUnhead = useUnhead;
|