@unhead/vue 2.0.0-alpha.2 → 2.0.0-alpha.21

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.
Files changed (52) hide show
  1. package/dist/client.d.mts +4 -6
  2. package/dist/client.d.ts +4 -6
  3. package/dist/client.mjs +9 -12
  4. package/dist/components.mjs +8 -5
  5. package/dist/index.d.mts +18 -22
  6. package/dist/index.d.ts +18 -22
  7. package/dist/index.mjs +9 -47
  8. package/dist/legacy.d.mts +12 -39
  9. package/dist/legacy.d.ts +12 -39
  10. package/dist/legacy.mjs +56 -91
  11. package/dist/plugins.d.mts +1 -0
  12. package/dist/plugins.d.ts +1 -0
  13. package/dist/plugins.mjs +1 -0
  14. package/dist/server.d.mts +4 -6
  15. package/dist/server.d.ts +4 -6
  16. package/dist/server.mjs +7 -9
  17. package/dist/shared/{vue.B8gXlHM7.d.cts → vue.C97gXjQS.d.mts} +39 -50
  18. package/dist/shared/{vue.B8gXlHM7.d.mts → vue.C97gXjQS.d.ts} +39 -50
  19. package/dist/shared/{vue.BqrzivMs.mjs → vue.DBXhY4KI.mjs} +1 -1
  20. package/dist/shared/vue.N9zWjxoK.mjs +7 -0
  21. package/dist/shared/vue.j4SPrdI5.mjs +84 -0
  22. package/dist/types.d.mts +66 -0
  23. package/dist/types.d.ts +66 -0
  24. package/dist/types.mjs +1 -0
  25. package/dist/utils.d.mts +11 -0
  26. package/dist/utils.d.ts +11 -0
  27. package/dist/utils.mjs +10 -0
  28. package/legacy.d.ts +1 -0
  29. package/package.json +41 -15
  30. package/plugins.d.ts +1 -0
  31. package/types.d.ts +1 -0
  32. package/utils.d.ts +1 -0
  33. package/dist/client.cjs +0 -36
  34. package/dist/client.d.cts +0 -11
  35. package/dist/components.cjs +0 -64
  36. package/dist/components.d.cts +0 -5
  37. package/dist/index.cjs +0 -66
  38. package/dist/index.d.cts +0 -33
  39. package/dist/legacy.cjs +0 -163
  40. package/dist/legacy.d.cts +0 -51
  41. package/dist/server.cjs +0 -33
  42. package/dist/server.d.cts +0 -11
  43. package/dist/shared/vue.Adq3bKYb.cjs +0 -89
  44. package/dist/shared/vue.B8gXlHM7.d.ts +0 -144
  45. package/dist/shared/vue.BFi59n5j.cjs +0 -15
  46. package/dist/shared/vue.Bjx6RvLp.d.cts +0 -191
  47. package/dist/shared/vue.Bjx6RvLp.d.mts +0 -191
  48. package/dist/shared/vue.Bjx6RvLp.d.ts +0 -191
  49. package/dist/shared/vue.BmaKl8wu.mjs +0 -13
  50. package/dist/shared/vue.DTOQraae.cjs +0 -20
  51. package/dist/shared/vue.DUgB2y83.mjs +0 -83
  52. package/dist/shared/vue.DnywREVF.d.cts +0 -5
@@ -1,89 +0,0 @@
1
- 'use strict';
2
-
3
- const vue = require('vue');
4
-
5
- function resolveUnref(r) {
6
- return typeof r === "function" ? r() : vue.unref(r);
7
- }
8
- function resolveUnrefHeadInput(ref) {
9
- if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
10
- return ref;
11
- const root = resolveUnref(ref);
12
- if (!ref || !root)
13
- return root;
14
- if (Array.isArray(root))
15
- return root.map((r) => resolveUnrefHeadInput(r));
16
- if (typeof root === "object") {
17
- const resolved = {};
18
- for (const k in root) {
19
- if (!Object.prototype.hasOwnProperty.call(root, k)) {
20
- continue;
21
- }
22
- if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
23
- resolved[k] = vue.unref(root[k]);
24
- continue;
25
- }
26
- resolved[k] = resolveUnrefHeadInput(root[k]);
27
- }
28
- return resolved;
29
- }
30
- return root;
31
- }
32
-
33
- const headSymbol = "usehead";
34
- function vueInstall(head) {
35
- const plugin = {
36
- install(app) {
37
- app.config.globalProperties.$unhead = head;
38
- app.config.globalProperties.$head = head;
39
- app.provide(headSymbol, head);
40
- }
41
- };
42
- return plugin.install;
43
- }
44
-
45
- function injectHead() {
46
- if (vue.hasInjectionContext()) {
47
- const instance = vue.inject(headSymbol);
48
- if (!instance) {
49
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
50
- }
51
- return instance;
52
- }
53
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
54
- }
55
-
56
- function useHead(input, options = {}) {
57
- const head = options.head || injectHead();
58
- return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
59
- }
60
- function clientUseHead(head, input, options = {}) {
61
- const deactivated = vue.ref(false);
62
- const resolvedInput = vue.ref({});
63
- vue.watchEffect(() => {
64
- resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
65
- });
66
- const entry = head.push(resolvedInput.value, options);
67
- vue.watch(resolvedInput, (e) => {
68
- entry.patch(e);
69
- });
70
- const vm = vue.getCurrentInstance();
71
- if (vm) {
72
- vue.onBeforeUnmount(() => {
73
- entry.dispose();
74
- });
75
- vue.onDeactivated(() => {
76
- deactivated.value = true;
77
- });
78
- vue.onActivated(() => {
79
- deactivated.value = false;
80
- });
81
- }
82
- return entry;
83
- }
84
-
85
- exports.headSymbol = headSymbol;
86
- exports.injectHead = injectHead;
87
- exports.resolveUnrefHeadInput = resolveUnrefHeadInput;
88
- exports.useHead = useHead;
89
- exports.vueInstall = vueInstall;
@@ -1,144 +0,0 @@
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, MaybeEventFnHandlers, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead, SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from '@unhead/schema';
2
- import { ComputedRef, Ref, Plugin } from 'vue';
3
-
4
- declare function resolveUnrefHeadInput(ref: any): any;
5
-
6
- type MaybeReadonlyRef<T> = ComputedRef<T>;
7
- type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
8
- type MaybeComputedRefOrFalsy<T> = T | MaybeReadonlyRef<T> | Ref<T>;
9
- /**
10
- * @deprecated Use MaybeComputedRefOrFalsy
11
- */
12
- type MaybeComputedRefOrPromise<T> = MaybeComputedRefOrFalsy<T>;
13
- type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
14
- [key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
15
- };
16
- type MaybeComputedRefEntriesOnly<T> = {
17
- [key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
18
- };
19
-
20
- interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
21
- /**
22
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
23
- *
24
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
25
- */
26
- class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
27
- }
28
- interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
29
- /**
30
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
31
- *
32
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
33
- */
34
- class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
35
- /**
36
- * The class global attribute is a space-separated list of the case-sensitive classes of the element.
37
- *
38
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
39
- */
40
- style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
41
- }
42
- type Title = MaybeComputedRef<Title$1>;
43
- type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
44
- type Base<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
45
- type Link<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Link$1<E>>;
46
- type Meta<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Meta$1<E>>;
47
- type Style<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Style$1<E>>;
48
- type Script<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Script$1<E>>;
49
- type Noscript<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Noscript$1<E>>;
50
- type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
51
- type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeEventFnHandlers<BodyEvents>>;
52
- interface ReactiveHead<E extends MergeHead = MergeHead> {
53
- /**
54
- * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
55
- * It only contains text; tags within the element are ignored.
56
- *
57
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
58
- */
59
- title?: Title;
60
- /**
61
- * Generate the title from a template.
62
- */
63
- titleTemplate?: TitleTemplate;
64
- /**
65
- * Variables used to substitute in the title and meta content.
66
- */
67
- templateParams?: MaybeComputedRefEntries<{
68
- separator?: '|' | '-' | '·' | string;
69
- } & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
70
- /**
71
- * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
72
- * There can be only one <base> element in a document.
73
- *
74
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
75
- */
76
- base?: Base<E['base']>;
77
- /**
78
- * The `<link>` HTML element specifies relationships between the current document and an external resource.
79
- * This element is most commonly used to link to stylesheets, but is also used to establish site icons
80
- * (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
81
- *
82
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
83
- */
84
- link?: MaybeComputedRef<Link<E['link']>[]>;
85
- /**
86
- * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
87
- *
88
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
89
- */
90
- meta?: MaybeComputedRef<Meta<E['meta']>[]>;
91
- /**
92
- * The `<style>` HTML element contains style information for a document, or part of a document.
93
- * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
94
- *
95
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
96
- */
97
- style?: MaybeComputedRef<(Style<E['style']> | string)[]>;
98
- /**
99
- * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
100
- *
101
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
102
- */
103
- script?: MaybeComputedRef<(Script<E['script']> | string)[]>;
104
- /**
105
- * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
106
- * or if scripting is currently turned off in the browser.
107
- *
108
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
109
- */
110
- noscript?: MaybeComputedRef<(Noscript<E['noscript']> | string)[]>;
111
- /**
112
- * Attributes for the `<html>` HTML element.
113
- *
114
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
115
- */
116
- htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
117
- /**
118
- * Attributes for the `<body>` HTML element.
119
- *
120
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
121
- */
122
- bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
123
- }
124
- type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
125
- head?: VueHeadClient<any>;
126
- };
127
- type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
128
- type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
129
- title?: ReactiveHead['title'];
130
- titleTemplate?: ReactiveHead['titleTemplate'];
131
- };
132
- type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
133
-
134
- interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
135
- meta?: MaybeComputedRefEntries<SafeMeta>[];
136
- link?: MaybeComputedRefEntries<SafeLink>[];
137
- noscript?: MaybeComputedRefEntries<SafeNoscript>[];
138
- script?: MaybeComputedRefEntries<SafeScript>[];
139
- htmlAttrs?: MaybeComputedRefEntries<SafeHtmlAttr>;
140
- bodyAttrs?: MaybeComputedRefEntries<SafeBodyAttr>;
141
- }
142
- type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
143
-
144
- export { type BodyAttr as B, type HeadSafe as H, type Link as L, type Meta as M, type Noscript as N, type ReactiveHead as R, type Style as S, type Title as T, type UseHeadInput as U, type VueHeadClient as V, type UseHeadOptions as a, type UseHeadSafeInput as b, type UseSeoMetaInput as c, type HtmlAttr as d, type TitleTemplate as e, type Base as f, type Script as g, type HtmlAttributes as h, type BodyAttributes as i, type MaybeReadonlyRef as j, type MaybeComputedRef as k, type MaybeComputedRefOrFalsy as l, type MaybeComputedRefOrPromise as m, type MaybeComputedRefEntries as n, type MaybeComputedRefEntriesOnly as o, resolveUnrefHeadInput as r };
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- const shared = require('@unhead/shared');
4
- const useHead = require('./vue.Adq3bKYb.cjs');
5
-
6
- const VueReactivityPlugin = shared.defineHeadPlugin({
7
- hooks: {
8
- "entries:resolve": (ctx) => {
9
- for (const entry of ctx.entries)
10
- entry.resolvedInput = useHead.resolveUnrefHeadInput(entry.input);
11
- }
12
- }
13
- });
14
-
15
- exports.VueReactivityPlugin = VueReactivityPlugin;
@@ -1,191 +0,0 @@
1
- import require$$0$1 from '@unhead/shared';
2
- import require$$1 from 'unhead';
3
- import require$$0 from 'vue';
4
-
5
- var dist = {};
6
-
7
- var vue_Adq3bKYb = {};
8
-
9
- var hasRequiredVue_Adq3bKYb;
10
-
11
- function requireVue_Adq3bKYb () {
12
- if (hasRequiredVue_Adq3bKYb) return vue_Adq3bKYb;
13
- hasRequiredVue_Adq3bKYb = 1;
14
- const vue = require$$0;
15
- function resolveUnref(r) {
16
- return typeof r === "function" ? r() : vue.unref(r);
17
- }
18
- function resolveUnrefHeadInput(ref) {
19
- if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
20
- return ref;
21
- const root = resolveUnref(ref);
22
- if (!ref || !root)
23
- return root;
24
- if (Array.isArray(root))
25
- return root.map((r) => resolveUnrefHeadInput(r));
26
- if (typeof root === "object") {
27
- const resolved = {};
28
- for (const k in root) {
29
- if (!Object.prototype.hasOwnProperty.call(root, k)) {
30
- continue;
31
- }
32
- if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
33
- resolved[k] = vue.unref(root[k]);
34
- continue;
35
- }
36
- resolved[k] = resolveUnrefHeadInput(root[k]);
37
- }
38
- return resolved;
39
- }
40
- return root;
41
- }
42
- const headSymbol = "usehead";
43
- function vueInstall(head) {
44
- const plugin = {
45
- install(app) {
46
- app.config.globalProperties.$unhead = head;
47
- app.config.globalProperties.$head = head;
48
- app.provide(headSymbol, head);
49
- }
50
- };
51
- return plugin.install;
52
- }
53
- function injectHead() {
54
- if (vue.hasInjectionContext()) {
55
- const instance = vue.inject(headSymbol);
56
- if (!instance) {
57
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
58
- }
59
- return instance;
60
- }
61
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
62
- }
63
- function useHead(input, options = {}) {
64
- const head = options.head || injectHead();
65
- return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
66
- }
67
- function clientUseHead(head, input, options = {}) {
68
- const deactivated = vue.ref(false);
69
- const resolvedInput = vue.ref({});
70
- vue.watchEffect(() => {
71
- resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
72
- });
73
- const entry = head.push(resolvedInput.value, options);
74
- vue.watch(resolvedInput, (e) => {
75
- entry.patch(e);
76
- });
77
- const vm = vue.getCurrentInstance();
78
- if (vm) {
79
- vue.onBeforeUnmount(() => {
80
- entry.dispose();
81
- });
82
- vue.onDeactivated(() => {
83
- deactivated.value = true;
84
- });
85
- vue.onActivated(() => {
86
- deactivated.value = false;
87
- });
88
- }
89
- return entry;
90
- }
91
- vue_Adq3bKYb.headSymbol = headSymbol;
92
- vue_Adq3bKYb.injectHead = injectHead;
93
- vue_Adq3bKYb.resolveUnrefHeadInput = resolveUnrefHeadInput;
94
- vue_Adq3bKYb.useHead = useHead;
95
- vue_Adq3bKYb.vueInstall = vueInstall;
96
- return vue_Adq3bKYb;
97
- }
98
-
99
- var vue_DTOQraae = {};
100
-
101
- var hasRequiredVue_DTOQraae;
102
-
103
- function requireVue_DTOQraae () {
104
- if (hasRequiredVue_DTOQraae) return vue_DTOQraae;
105
- hasRequiredVue_DTOQraae = 1;
106
- const vue = require$$0;
107
- const useHead = requireVue_Adq3bKYb();
108
- const VueHeadMixin = {
109
- created() {
110
- let source = false;
111
- const instance = vue.getCurrentInstance();
112
- if (!instance)
113
- return;
114
- const options = instance.type;
115
- if (!options || !("head" in options))
116
- return;
117
- source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
118
- source && useHead.useHead(source);
119
- }
120
- };
121
- vue_DTOQraae.VueHeadMixin = VueHeadMixin;
122
- return vue_DTOQraae;
123
- }
124
-
125
- var hasRequiredDist;
126
-
127
- function requireDist () {
128
- if (hasRequiredDist) return dist;
129
- hasRequiredDist = 1;
130
- const shared = require$$0$1;
131
- const unhead = require$$1;
132
- const useHead = requireVue_Adq3bKYb();
133
- const VueHeadMixin = requireVue_DTOQraae();
134
-
135
- const coreComposableNames = [
136
- "injectHead"
137
- ];
138
- const unheadVueComposablesImports = {
139
- "@unhead/vue": [...coreComposableNames, ...shared.composableNames]
140
- };
141
- function useHeadSafe(input, options = {}) {
142
- return useHead.useHead(input, { ...options, transform: shared.whitelistSafeInput });
143
- }
144
- function useSeoMeta(input, options) {
145
- const { title, titleTemplate, ...meta } = input;
146
- return useHead.useHead({
147
- title,
148
- titleTemplate,
149
- // @ts-expect-error runtime type
150
- _flatMeta: meta
151
- }, {
152
- ...options,
153
- transform(t) {
154
- const meta2 = shared.unpackMeta({ ...t._flatMeta });
155
- delete t._flatMeta;
156
- return {
157
- // @ts-expect-error runtime type
158
- ...t,
159
- meta: meta2
160
- };
161
- }
162
- });
163
- }
164
- function useServerHead(input, options = {}) {
165
- return useHead.useHead(input, { ...options, mode: "server" });
166
- }
167
- function useServerHeadSafe(input, options = {}) {
168
- return useHeadSafe(input, { ...options, mode: "server" });
169
- }
170
- function useServerSeoMeta(input, options) {
171
- return useSeoMeta(input, { ...options, mode: "server" });
172
- }
173
- const CapoPlugin = () => shared.defineHeadPlugin({});
174
- dist.createHeadCore = unhead.createHeadCore;
175
- dist.injectHead = useHead.injectHead;
176
- dist.resolveUnrefHeadInput = useHead.resolveUnrefHeadInput;
177
- dist.useHead = useHead.useHead;
178
- dist.VueHeadMixin = VueHeadMixin.VueHeadMixin;
179
- dist.CapoPlugin = CapoPlugin;
180
- dist.unheadVueComposablesImports = unheadVueComposablesImports;
181
- dist.useHeadSafe = useHeadSafe;
182
- dist.useSeoMeta = useSeoMeta;
183
- dist.useServerHead = useServerHead;
184
- dist.useServerHeadSafe = useServerHeadSafe;
185
- dist.useServerSeoMeta = useServerSeoMeta;
186
- return dist;
187
- }
188
-
189
- var distExports = requireDist();
190
-
191
- export { distExports as d };
@@ -1,191 +0,0 @@
1
- import require$$0$1 from '@unhead/shared';
2
- import require$$1 from 'unhead';
3
- import require$$0 from 'vue';
4
-
5
- var dist = {};
6
-
7
- var vue_Adq3bKYb = {};
8
-
9
- var hasRequiredVue_Adq3bKYb;
10
-
11
- function requireVue_Adq3bKYb () {
12
- if (hasRequiredVue_Adq3bKYb) return vue_Adq3bKYb;
13
- hasRequiredVue_Adq3bKYb = 1;
14
- const vue = require$$0;
15
- function resolveUnref(r) {
16
- return typeof r === "function" ? r() : vue.unref(r);
17
- }
18
- function resolveUnrefHeadInput(ref) {
19
- if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
20
- return ref;
21
- const root = resolveUnref(ref);
22
- if (!ref || !root)
23
- return root;
24
- if (Array.isArray(root))
25
- return root.map((r) => resolveUnrefHeadInput(r));
26
- if (typeof root === "object") {
27
- const resolved = {};
28
- for (const k in root) {
29
- if (!Object.prototype.hasOwnProperty.call(root, k)) {
30
- continue;
31
- }
32
- if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
33
- resolved[k] = vue.unref(root[k]);
34
- continue;
35
- }
36
- resolved[k] = resolveUnrefHeadInput(root[k]);
37
- }
38
- return resolved;
39
- }
40
- return root;
41
- }
42
- const headSymbol = "usehead";
43
- function vueInstall(head) {
44
- const plugin = {
45
- install(app) {
46
- app.config.globalProperties.$unhead = head;
47
- app.config.globalProperties.$head = head;
48
- app.provide(headSymbol, head);
49
- }
50
- };
51
- return plugin.install;
52
- }
53
- function injectHead() {
54
- if (vue.hasInjectionContext()) {
55
- const instance = vue.inject(headSymbol);
56
- if (!instance) {
57
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
58
- }
59
- return instance;
60
- }
61
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
62
- }
63
- function useHead(input, options = {}) {
64
- const head = options.head || injectHead();
65
- return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
66
- }
67
- function clientUseHead(head, input, options = {}) {
68
- const deactivated = vue.ref(false);
69
- const resolvedInput = vue.ref({});
70
- vue.watchEffect(() => {
71
- resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
72
- });
73
- const entry = head.push(resolvedInput.value, options);
74
- vue.watch(resolvedInput, (e) => {
75
- entry.patch(e);
76
- });
77
- const vm = vue.getCurrentInstance();
78
- if (vm) {
79
- vue.onBeforeUnmount(() => {
80
- entry.dispose();
81
- });
82
- vue.onDeactivated(() => {
83
- deactivated.value = true;
84
- });
85
- vue.onActivated(() => {
86
- deactivated.value = false;
87
- });
88
- }
89
- return entry;
90
- }
91
- vue_Adq3bKYb.headSymbol = headSymbol;
92
- vue_Adq3bKYb.injectHead = injectHead;
93
- vue_Adq3bKYb.resolveUnrefHeadInput = resolveUnrefHeadInput;
94
- vue_Adq3bKYb.useHead = useHead;
95
- vue_Adq3bKYb.vueInstall = vueInstall;
96
- return vue_Adq3bKYb;
97
- }
98
-
99
- var vue_DTOQraae = {};
100
-
101
- var hasRequiredVue_DTOQraae;
102
-
103
- function requireVue_DTOQraae () {
104
- if (hasRequiredVue_DTOQraae) return vue_DTOQraae;
105
- hasRequiredVue_DTOQraae = 1;
106
- const vue = require$$0;
107
- const useHead = requireVue_Adq3bKYb();
108
- const VueHeadMixin = {
109
- created() {
110
- let source = false;
111
- const instance = vue.getCurrentInstance();
112
- if (!instance)
113
- return;
114
- const options = instance.type;
115
- if (!options || !("head" in options))
116
- return;
117
- source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
118
- source && useHead.useHead(source);
119
- }
120
- };
121
- vue_DTOQraae.VueHeadMixin = VueHeadMixin;
122
- return vue_DTOQraae;
123
- }
124
-
125
- var hasRequiredDist;
126
-
127
- function requireDist () {
128
- if (hasRequiredDist) return dist;
129
- hasRequiredDist = 1;
130
- const shared = require$$0$1;
131
- const unhead = require$$1;
132
- const useHead = requireVue_Adq3bKYb();
133
- const VueHeadMixin = requireVue_DTOQraae();
134
-
135
- const coreComposableNames = [
136
- "injectHead"
137
- ];
138
- const unheadVueComposablesImports = {
139
- "@unhead/vue": [...coreComposableNames, ...shared.composableNames]
140
- };
141
- function useHeadSafe(input, options = {}) {
142
- return useHead.useHead(input, { ...options, transform: shared.whitelistSafeInput });
143
- }
144
- function useSeoMeta(input, options) {
145
- const { title, titleTemplate, ...meta } = input;
146
- return useHead.useHead({
147
- title,
148
- titleTemplate,
149
- // @ts-expect-error runtime type
150
- _flatMeta: meta
151
- }, {
152
- ...options,
153
- transform(t) {
154
- const meta2 = shared.unpackMeta({ ...t._flatMeta });
155
- delete t._flatMeta;
156
- return {
157
- // @ts-expect-error runtime type
158
- ...t,
159
- meta: meta2
160
- };
161
- }
162
- });
163
- }
164
- function useServerHead(input, options = {}) {
165
- return useHead.useHead(input, { ...options, mode: "server" });
166
- }
167
- function useServerHeadSafe(input, options = {}) {
168
- return useHeadSafe(input, { ...options, mode: "server" });
169
- }
170
- function useServerSeoMeta(input, options) {
171
- return useSeoMeta(input, { ...options, mode: "server" });
172
- }
173
- const CapoPlugin = () => shared.defineHeadPlugin({});
174
- dist.createHeadCore = unhead.createHeadCore;
175
- dist.injectHead = useHead.injectHead;
176
- dist.resolveUnrefHeadInput = useHead.resolveUnrefHeadInput;
177
- dist.useHead = useHead.useHead;
178
- dist.VueHeadMixin = VueHeadMixin.VueHeadMixin;
179
- dist.CapoPlugin = CapoPlugin;
180
- dist.unheadVueComposablesImports = unheadVueComposablesImports;
181
- dist.useHeadSafe = useHeadSafe;
182
- dist.useSeoMeta = useSeoMeta;
183
- dist.useServerHead = useServerHead;
184
- dist.useServerHeadSafe = useServerHeadSafe;
185
- dist.useServerSeoMeta = useServerSeoMeta;
186
- return dist;
187
- }
188
-
189
- var distExports = requireDist();
190
-
191
- export { distExports as d };