@unhead/vue 1.4.0 → 1.5.0
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/index.cjs +4 -2
- package/dist/index.d.cts +11 -10
- package/dist/index.d.mts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.mjs +4 -3
- package/dist/polyfill.cjs +1 -1
- package/dist/polyfill.d.cts +3 -3
- package/dist/polyfill.d.mts +3 -3
- package/dist/polyfill.d.ts +3 -3
- package/dist/polyfill.mjs +1 -1
- package/dist/shared/{vue.b3743d94.cjs → vue.16aedff8.cjs} +17 -3
- package/dist/shared/{vue.c0307a01.d.cts → vue.8eef6ffc.d.cts} +5 -2
- package/dist/shared/{vue.c0307a01.d.mts → vue.8eef6ffc.d.mts} +5 -2
- package/dist/shared/{vue.c0307a01.d.ts → vue.8eef6ffc.d.ts} +5 -2
- package/dist/shared/{vue.e88efe84.mjs → vue.fc184c2f.mjs} +18 -5
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const unhead = require('unhead');
|
|
4
|
-
const useHead = require('./shared/vue.
|
|
4
|
+
const useHead = require('./shared/vue.16aedff8.cjs');
|
|
5
5
|
const vue = require('vue');
|
|
6
6
|
const shared = require('@unhead/shared');
|
|
7
7
|
|
|
@@ -72,7 +72,8 @@ function useSeoMeta(input, options) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
function useServerHead(input, options = {}) {
|
|
75
|
-
const head = useHead.injectHead();
|
|
75
|
+
const head = options.head || useHead.injectHead();
|
|
76
|
+
delete options.head;
|
|
76
77
|
if (head)
|
|
77
78
|
return head.push(input, { ...options, mode: "server" });
|
|
78
79
|
}
|
|
@@ -92,6 +93,7 @@ exports.createHead = useHead.createHead;
|
|
|
92
93
|
exports.createServerHead = useHead.createServerHead;
|
|
93
94
|
exports.injectHead = useHead.injectHead;
|
|
94
95
|
exports.resolveUnrefHeadInput = useHead.resolveUnrefHeadInput;
|
|
96
|
+
exports.setFailedInjectionHandler = useHead.setFailedInjectionHandler;
|
|
95
97
|
exports.useHead = useHead.useHead;
|
|
96
98
|
exports.Vue2ProvideUnheadPlugin = Vue2ProvideUnheadPlugin;
|
|
97
99
|
exports.VueHeadMixin = VueHeadMixin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
|
|
2
2
|
import * as _unhead_schema from '@unhead/schema';
|
|
3
|
-
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions,
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry } from '@unhead/schema';
|
|
4
4
|
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
|
|
5
|
-
import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseSeoMetaInput } from './shared/vue.
|
|
6
|
-
export {
|
|
5
|
+
import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as UseSeoMetaInput } from './shared/vue.8eef6ffc.cjs';
|
|
6
|
+
export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, f as Meta, N as Noscript, g as Script, S as Style, T as Title, d as TitleTemplate } from './shared/vue.8eef6ffc.cjs';
|
|
7
7
|
import { Plugin } from 'vue';
|
|
8
8
|
|
|
9
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
@@ -31,18 +31,19 @@ declare const unheadVueComposablesImports: {
|
|
|
31
31
|
'@unhead/vue': string[];
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
declare function setFailedInjectionHandler(handler: () => void): void;
|
|
34
35
|
declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
|
|
35
36
|
|
|
36
|
-
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?:
|
|
37
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
37
38
|
|
|
38
|
-
declare function useHeadSafe(input: UseHeadSafeInput, options?:
|
|
39
|
+
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
|
|
39
40
|
|
|
40
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?:
|
|
41
|
+
declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
41
42
|
|
|
42
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?:
|
|
43
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): _unhead_schema.ActiveHeadEntry<MaybeComputedRef<ReactiveHead<any>>> | undefined;
|
|
43
44
|
|
|
44
|
-
declare function useServerHeadSafe(input: UseHeadSafeInput, options?:
|
|
45
|
+
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadSafeInput>;
|
|
45
46
|
|
|
46
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?:
|
|
47
|
+
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
47
48
|
|
|
48
|
-
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, type UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
|
49
|
+
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setFailedInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
|
|
2
2
|
import * as _unhead_schema from '@unhead/schema';
|
|
3
|
-
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions,
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry } from '@unhead/schema';
|
|
4
4
|
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
|
|
5
|
-
import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseSeoMetaInput } from './shared/vue.
|
|
6
|
-
export {
|
|
5
|
+
import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as UseSeoMetaInput } from './shared/vue.8eef6ffc.mjs';
|
|
6
|
+
export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, f as Meta, N as Noscript, g as Script, S as Style, T as Title, d as TitleTemplate } from './shared/vue.8eef6ffc.mjs';
|
|
7
7
|
import { Plugin } from 'vue';
|
|
8
8
|
|
|
9
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
@@ -31,18 +31,19 @@ declare const unheadVueComposablesImports: {
|
|
|
31
31
|
'@unhead/vue': string[];
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
declare function setFailedInjectionHandler(handler: () => void): void;
|
|
34
35
|
declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
|
|
35
36
|
|
|
36
|
-
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?:
|
|
37
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
37
38
|
|
|
38
|
-
declare function useHeadSafe(input: UseHeadSafeInput, options?:
|
|
39
|
+
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
|
|
39
40
|
|
|
40
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?:
|
|
41
|
+
declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
41
42
|
|
|
42
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?:
|
|
43
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): _unhead_schema.ActiveHeadEntry<MaybeComputedRef<ReactiveHead<any>>> | undefined;
|
|
43
44
|
|
|
44
|
-
declare function useServerHeadSafe(input: UseHeadSafeInput, options?:
|
|
45
|
+
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadSafeInput>;
|
|
45
46
|
|
|
46
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?:
|
|
47
|
+
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
47
48
|
|
|
48
|
-
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, type UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
|
49
|
+
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setFailedInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
|
|
2
2
|
import * as _unhead_schema from '@unhead/schema';
|
|
3
|
-
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions,
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry } from '@unhead/schema';
|
|
4
4
|
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
|
|
5
|
-
import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseSeoMetaInput } from './shared/vue.
|
|
6
|
-
export {
|
|
5
|
+
import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as UseSeoMetaInput } from './shared/vue.8eef6ffc.js';
|
|
6
|
+
export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, f as Meta, N as Noscript, g as Script, S as Style, T as Title, d as TitleTemplate } from './shared/vue.8eef6ffc.js';
|
|
7
7
|
import { Plugin } from 'vue';
|
|
8
8
|
|
|
9
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
@@ -31,18 +31,19 @@ declare const unheadVueComposablesImports: {
|
|
|
31
31
|
'@unhead/vue': string[];
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
declare function setFailedInjectionHandler(handler: () => void): void;
|
|
34
35
|
declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
|
|
35
36
|
|
|
36
|
-
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?:
|
|
37
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
37
38
|
|
|
38
|
-
declare function useHeadSafe(input: UseHeadSafeInput, options?:
|
|
39
|
+
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
|
|
39
40
|
|
|
40
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?:
|
|
41
|
+
declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
41
42
|
|
|
42
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?:
|
|
43
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): _unhead_schema.ActiveHeadEntry<MaybeComputedRef<ReactiveHead<any>>> | undefined;
|
|
43
44
|
|
|
44
|
-
declare function useServerHeadSafe(input: UseHeadSafeInput, options?:
|
|
45
|
+
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadSafeInput>;
|
|
45
46
|
|
|
46
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?:
|
|
47
|
+
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
47
48
|
|
|
48
|
-
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, type UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
|
49
|
+
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setFailedInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
|
|
2
|
-
import { V as Vue3, u as useHead, h as headSymbol, r as resolveUnrefHeadInput, i as injectHead } from './shared/vue.
|
|
3
|
-
export { c as createHead, a as createServerHead } from './shared/vue.
|
|
2
|
+
import { V as Vue3, u as useHead, h as headSymbol, r as resolveUnrefHeadInput, i as injectHead } from './shared/vue.fc184c2f.mjs';
|
|
3
|
+
export { c as createHead, a as createServerHead, s as setFailedInjectionHandler } from './shared/vue.fc184c2f.mjs';
|
|
4
4
|
import { getCurrentInstance, ref, watchEffect } from 'vue';
|
|
5
5
|
import { composableNames, whitelistSafeInput, unpackMeta } from '@unhead/shared';
|
|
6
6
|
|
|
@@ -71,7 +71,8 @@ function useSeoMeta(input, options) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
function useServerHead(input, options = {}) {
|
|
74
|
-
const head = injectHead();
|
|
74
|
+
const head = options.head || injectHead();
|
|
75
|
+
delete options.head;
|
|
75
76
|
if (head)
|
|
76
77
|
return head.push(input, { ...options, mode: "server" });
|
|
77
78
|
}
|
package/dist/polyfill.cjs
CHANGED
package/dist/polyfill.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MergeHead
|
|
2
|
-
import { V as VueHeadClient, U as UseHeadInput } from './shared/vue.
|
|
1
|
+
import { MergeHead } from '@unhead/schema';
|
|
2
|
+
import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.8eef6ffc.cjs';
|
|
3
3
|
import 'vue';
|
|
4
4
|
|
|
5
5
|
type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
|
|
@@ -18,7 +18,7 @@ type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
|
|
|
18
18
|
/**
|
|
19
19
|
* @deprecated use `useHead`
|
|
20
20
|
*/
|
|
21
|
-
addReactiveEntry: (input: UseHeadInput<T>, options?:
|
|
21
|
+
addReactiveEntry: (input: UseHeadInput<T>, options?: UseHeadOptions) => (() => void);
|
|
22
22
|
/**
|
|
23
23
|
* @deprecated Use useHead API.
|
|
24
24
|
*/
|
package/dist/polyfill.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MergeHead
|
|
2
|
-
import { V as VueHeadClient, U as UseHeadInput } from './shared/vue.
|
|
1
|
+
import { MergeHead } from '@unhead/schema';
|
|
2
|
+
import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.8eef6ffc.mjs';
|
|
3
3
|
import 'vue';
|
|
4
4
|
|
|
5
5
|
type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
|
|
@@ -18,7 +18,7 @@ type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
|
|
|
18
18
|
/**
|
|
19
19
|
* @deprecated use `useHead`
|
|
20
20
|
*/
|
|
21
|
-
addReactiveEntry: (input: UseHeadInput<T>, options?:
|
|
21
|
+
addReactiveEntry: (input: UseHeadInput<T>, options?: UseHeadOptions) => (() => void);
|
|
22
22
|
/**
|
|
23
23
|
* @deprecated Use useHead API.
|
|
24
24
|
*/
|
package/dist/polyfill.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MergeHead
|
|
2
|
-
import { V as VueHeadClient, U as UseHeadInput } from './shared/vue.
|
|
1
|
+
import { MergeHead } from '@unhead/schema';
|
|
2
|
+
import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.8eef6ffc.js';
|
|
3
3
|
import 'vue';
|
|
4
4
|
|
|
5
5
|
type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
|
|
@@ -18,7 +18,7 @@ type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
|
|
|
18
18
|
/**
|
|
19
19
|
* @deprecated use `useHead`
|
|
20
20
|
*/
|
|
21
|
-
addReactiveEntry: (input: UseHeadInput<T>, options?:
|
|
21
|
+
addReactiveEntry: (input: UseHeadInput<T>, options?: UseHeadOptions) => (() => void);
|
|
22
22
|
/**
|
|
23
23
|
* @deprecated Use useHead API.
|
|
24
24
|
*/
|
package/dist/polyfill.mjs
CHANGED
|
@@ -58,19 +58,32 @@ function createServerHead(options = {}) {
|
|
|
58
58
|
return head;
|
|
59
59
|
}
|
|
60
60
|
function createHead(options = {}) {
|
|
61
|
-
options.domDelayFn = options.domDelayFn || ((fn) => vue.nextTick(() => fn()));
|
|
61
|
+
options.domDelayFn = options.domDelayFn || ((fn) => vue.nextTick(() => setTimeout(() => fn(), 0)));
|
|
62
62
|
const head = unhead.createHead(options);
|
|
63
63
|
head.use(VueReactivityPlugin);
|
|
64
64
|
head.install = vueInstall(head);
|
|
65
65
|
return head;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
69
|
+
const globalKey = "__unhead_failed_injection_handler__";
|
|
70
|
+
function setFailedInjectionHandler(handler) {
|
|
71
|
+
_global[globalKey] = handler;
|
|
72
|
+
}
|
|
73
|
+
function callFailedInjectHandler() {
|
|
74
|
+
if (globalKey in _global)
|
|
75
|
+
return _global[globalKey]();
|
|
76
|
+
if (process.env.NODE_ENV !== "production")
|
|
77
|
+
console.warn("Unhead is missing Vue context, falling back to shared context. This may have unexpected results.");
|
|
78
|
+
}
|
|
68
79
|
function injectHead() {
|
|
69
|
-
|
|
80
|
+
const injectedHead = vue.inject(headSymbol);
|
|
81
|
+
!injectedHead && callFailedInjectHandler();
|
|
82
|
+
return injectedHead || unhead.getActiveHead();
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
function useHead(input, options = {}) {
|
|
73
|
-
const head = injectHead();
|
|
86
|
+
const head = options.head || injectHead();
|
|
74
87
|
if (head) {
|
|
75
88
|
if (!head.ssr)
|
|
76
89
|
return clientUseHead(head, input, options);
|
|
@@ -108,4 +121,5 @@ exports.createServerHead = createServerHead;
|
|
|
108
121
|
exports.headSymbol = headSymbol;
|
|
109
122
|
exports.injectHead = injectHead;
|
|
110
123
|
exports.resolveUnrefHeadInput = resolveUnrefHeadInput;
|
|
124
|
+
exports.setFailedInjectionHandler = setFailedInjectionHandler;
|
|
111
125
|
exports.useHead = useHead;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MaybeFunctionEntries, BodyEvents, MergeHead, MetaFlatInput, Unhead } from '@unhead/schema';
|
|
1
|
+
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MaybeFunctionEntries, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead } from '@unhead/schema';
|
|
2
2
|
import { ComputedRef, Ref, Plugin } from 'vue';
|
|
3
3
|
|
|
4
4
|
type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
|
|
@@ -104,6 +104,9 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
104
104
|
*/
|
|
105
105
|
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
106
106
|
}
|
|
107
|
+
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
|
|
108
|
+
head?: VueHeadClient<any>;
|
|
109
|
+
};
|
|
107
110
|
type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
|
|
108
111
|
type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
|
|
109
112
|
title?: ReactiveHead['title'];
|
|
@@ -111,4 +114,4 @@ type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
|
|
|
111
114
|
};
|
|
112
115
|
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
113
116
|
|
|
114
|
-
export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a,
|
|
117
|
+
export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a, UseHeadOptions as b, UseSeoMetaInput as c, TitleTemplate as d, Base as e, Meta as f, Script as g, HtmlAttributes as h, BodyAttributes as i, MaybeReadonlyRef as j, MaybeComputedRefOrPromise as k };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MaybeFunctionEntries, BodyEvents, MergeHead, MetaFlatInput, Unhead } from '@unhead/schema';
|
|
1
|
+
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MaybeFunctionEntries, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead } from '@unhead/schema';
|
|
2
2
|
import { ComputedRef, Ref, Plugin } from 'vue';
|
|
3
3
|
|
|
4
4
|
type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
|
|
@@ -104,6 +104,9 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
104
104
|
*/
|
|
105
105
|
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
106
106
|
}
|
|
107
|
+
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
|
|
108
|
+
head?: VueHeadClient<any>;
|
|
109
|
+
};
|
|
107
110
|
type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
|
|
108
111
|
type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
|
|
109
112
|
title?: ReactiveHead['title'];
|
|
@@ -111,4 +114,4 @@ type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
|
|
|
111
114
|
};
|
|
112
115
|
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
113
116
|
|
|
114
|
-
export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a,
|
|
117
|
+
export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a, UseHeadOptions as b, UseSeoMetaInput as c, TitleTemplate as d, Base as e, Meta as f, Script as g, HtmlAttributes as h, BodyAttributes as i, MaybeReadonlyRef as j, MaybeComputedRefOrPromise as k };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MaybeFunctionEntries, BodyEvents, MergeHead, MetaFlatInput, Unhead } from '@unhead/schema';
|
|
1
|
+
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MaybeFunctionEntries, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead } from '@unhead/schema';
|
|
2
2
|
import { ComputedRef, Ref, Plugin } from 'vue';
|
|
3
3
|
|
|
4
4
|
type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
|
|
@@ -104,6 +104,9 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
104
104
|
*/
|
|
105
105
|
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
106
106
|
}
|
|
107
|
+
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
|
|
108
|
+
head?: VueHeadClient<any>;
|
|
109
|
+
};
|
|
107
110
|
type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
|
|
108
111
|
type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
|
|
109
112
|
title?: ReactiveHead['title'];
|
|
@@ -111,4 +114,4 @@ type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
|
|
|
111
114
|
};
|
|
112
115
|
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
113
116
|
|
|
114
|
-
export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a,
|
|
117
|
+
export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a, UseHeadOptions as b, UseSeoMetaInput as c, TitleTemplate as d, Base as e, Meta as f, Script as g, HtmlAttributes as h, BodyAttributes as i, MaybeReadonlyRef as j, MaybeComputedRefOrPromise as k };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { version, unref, nextTick,
|
|
1
|
+
import { version, unref, nextTick, inject, ref, watchEffect, watch, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
|
|
2
2
|
import { createServerHead as createServerHead$1, createHead as createHead$1, getActiveHead } from 'unhead';
|
|
3
3
|
import { defineHeadPlugin } from '@unhead/shared';
|
|
4
4
|
|
|
@@ -56,19 +56,32 @@ function createServerHead(options = {}) {
|
|
|
56
56
|
return head;
|
|
57
57
|
}
|
|
58
58
|
function createHead(options = {}) {
|
|
59
|
-
options.domDelayFn = options.domDelayFn || ((fn) => nextTick(() => fn()));
|
|
59
|
+
options.domDelayFn = options.domDelayFn || ((fn) => nextTick(() => setTimeout(() => fn(), 0)));
|
|
60
60
|
const head = createHead$1(options);
|
|
61
61
|
head.use(VueReactivityPlugin);
|
|
62
62
|
head.install = vueInstall(head);
|
|
63
63
|
return head;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
67
|
+
const globalKey = "__unhead_failed_injection_handler__";
|
|
68
|
+
function setFailedInjectionHandler(handler) {
|
|
69
|
+
_global[globalKey] = handler;
|
|
70
|
+
}
|
|
71
|
+
function callFailedInjectHandler() {
|
|
72
|
+
if (globalKey in _global)
|
|
73
|
+
return _global[globalKey]();
|
|
74
|
+
if (process.env.NODE_ENV !== "production")
|
|
75
|
+
console.warn("Unhead is missing Vue context, falling back to shared context. This may have unexpected results.");
|
|
76
|
+
}
|
|
66
77
|
function injectHead() {
|
|
67
|
-
|
|
78
|
+
const injectedHead = inject(headSymbol);
|
|
79
|
+
!injectedHead && callFailedInjectHandler();
|
|
80
|
+
return injectedHead || getActiveHead();
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
function useHead(input, options = {}) {
|
|
71
|
-
const head = injectHead();
|
|
84
|
+
const head = options.head || injectHead();
|
|
72
85
|
if (head) {
|
|
73
86
|
if (!head.ssr)
|
|
74
87
|
return clientUseHead(head, input, options);
|
|
@@ -100,4 +113,4 @@ function clientUseHead(head, input, options = {}) {
|
|
|
100
113
|
return entry;
|
|
101
114
|
}
|
|
102
115
|
|
|
103
|
-
export { Vue3 as V, createServerHead as a, createHead as c, headSymbol as h, injectHead as i, resolveUnrefHeadInput as r, useHead as u };
|
|
116
|
+
export { Vue3 as V, createServerHead as a, createHead as c, headSymbol as h, injectHead as i, resolveUnrefHeadInput as r, setFailedInjectionHandler as s, useHead as u };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"hookable": "^5.5.3",
|
|
41
|
-
"@unhead/schema": "1.
|
|
42
|
-
"@unhead/shared": "1.
|
|
43
|
-
"unhead": "1.
|
|
41
|
+
"@unhead/schema": "1.5.0",
|
|
42
|
+
"@unhead/shared": "1.5.0",
|
|
43
|
+
"unhead": "1.5.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"vue": "^3.3.4"
|