@unhead/vue 1.11.15 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +13 -0
  2. package/client.d.ts +1 -0
  3. package/dist/client.cjs +37 -0
  4. package/dist/client.d.cts +11 -0
  5. package/dist/client.d.mts +11 -0
  6. package/dist/client.d.ts +11 -0
  7. package/dist/client.mjs +25 -0
  8. package/dist/components.cjs +9 -18
  9. package/dist/components.mjs +9 -18
  10. package/dist/index.cjs +11 -123
  11. package/dist/index.d.cts +16 -61
  12. package/dist/index.d.mts +16 -61
  13. package/dist/index.d.ts +16 -61
  14. package/dist/index.mjs +9 -117
  15. package/dist/legacy.cjs +168 -0
  16. package/dist/legacy.d.cts +51 -0
  17. package/dist/legacy.d.mts +51 -0
  18. package/dist/legacy.d.ts +51 -0
  19. package/dist/legacy.mjs +154 -0
  20. package/dist/server.cjs +34 -0
  21. package/dist/server.d.cts +11 -0
  22. package/dist/server.d.mts +11 -0
  23. package/dist/server.d.ts +11 -0
  24. package/dist/server.mjs +22 -0
  25. package/dist/shared/vue.3OjaFlxQ.cjs +20 -0
  26. package/dist/shared/vue.B6jdKgLD.mjs +13 -0
  27. package/dist/shared/{vue.fwis0K4Q.d.cts → vue.B8gXlHM7.d.cts} +25 -13
  28. package/dist/shared/{vue.fwis0K4Q.d.mts → vue.B8gXlHM7.d.mts} +25 -13
  29. package/dist/shared/{vue.fwis0K4Q.d.ts → vue.B8gXlHM7.d.ts} +25 -13
  30. package/dist/shared/vue.BwEnMiRq.cjs +91 -0
  31. package/dist/shared/vue.DIPZN3-d.cjs +15 -0
  32. package/dist/shared/vue.DShwsPiO.d.cts +194 -0
  33. package/dist/shared/vue.DShwsPiO.d.mts +194 -0
  34. package/dist/shared/vue.DShwsPiO.d.ts +194 -0
  35. package/dist/shared/vue.DnywREVF.d.cts +5 -0
  36. package/dist/shared/vue.DnywREVF.d.mts +5 -0
  37. package/dist/shared/vue.DnywREVF.d.ts +5 -0
  38. package/dist/shared/vue.O-w7-AFg.mjs +18 -0
  39. package/dist/shared/vue.Sg4YunmP.mjs +85 -0
  40. package/package.json +24 -22
  41. package/server.d.ts +1 -0
  42. package/dist/polyfill.cjs +0 -30
  43. package/dist/polyfill.d.cts +0 -40
  44. package/dist/polyfill.d.mts +0 -40
  45. package/dist/polyfill.d.ts +0 -40
  46. package/dist/polyfill.mjs +0 -28
  47. package/dist/shared/vue.-sixQ7xP.mjs +0 -37
  48. package/dist/shared/vue.BmMjB48i.cjs +0 -39
  49. package/dist/shared/vue.DWlmwWrc.cjs +0 -94
  50. package/dist/shared/vue.ziyDaVMR.mjs +0 -86
  51. package/dist/vue2.cjs +0 -46
  52. package/dist/vue2.d.cts +0 -5
  53. package/dist/vue2.d.mts +0 -5
  54. package/dist/vue2.d.ts +0 -5
  55. package/dist/vue2.mjs +0 -44
@@ -0,0 +1,154 @@
1
+ import { defineHeadPlugin, whitelistSafeInput, unpackMeta } from '@unhead/shared';
2
+ import { unheadCtx, tryUseUnhead } from 'unhead';
3
+ export { createHeadCore } from 'unhead';
4
+ import { getCurrentInstance, onMounted, isRef, watch, onScopeDispose, ref, inject, watchEffect, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
5
+ export { createHead } from './client.mjs';
6
+ import { h as headSymbol, r as resolveUnrefHeadInput } from './shared/vue.Sg4YunmP.mjs';
7
+ export { createHead as createServerHead } from './server.mjs';
8
+ import { useScript as useScript$1 } from 'unhead/legacy';
9
+ export { resolveScriptKey } from 'unhead/legacy';
10
+ import 'unhead/client';
11
+ import './shared/vue.B6jdKgLD.mjs';
12
+ import './shared/vue.O-w7-AFg.mjs';
13
+ import 'unhead/server';
14
+
15
+ function registerVueScopeHandlers(script, scope) {
16
+ if (!scope) {
17
+ return;
18
+ }
19
+ const _registerCb = (key, cb) => {
20
+ if (!script._cbs[key]) {
21
+ cb(script.instance);
22
+ return () => {
23
+ };
24
+ }
25
+ let i = script._cbs[key].push(cb);
26
+ const destroy = () => {
27
+ if (i) {
28
+ script._cbs[key]?.splice(i - 1, 1);
29
+ i = null;
30
+ }
31
+ };
32
+ onScopeDispose(destroy);
33
+ return destroy;
34
+ };
35
+ script.onLoaded = (cb) => _registerCb("loaded", cb);
36
+ script.onError = (cb) => _registerCb("error", cb);
37
+ onScopeDispose(() => {
38
+ script._triggerAbortController?.abort();
39
+ });
40
+ }
41
+ function useScript(_input, _options) {
42
+ const input = typeof _input === "string" ? { src: _input } : _input;
43
+ const options = _options || {};
44
+ const head = options?.head || injectHead();
45
+ options.head = head;
46
+ const scope = getCurrentInstance();
47
+ options.eventContext = scope;
48
+ if (scope && typeof options.trigger === "undefined") {
49
+ options.trigger = onMounted;
50
+ } else if (isRef(options.trigger)) {
51
+ const refTrigger = options.trigger;
52
+ let off;
53
+ options.trigger = new Promise((resolve) => {
54
+ off = watch(refTrigger, (val) => {
55
+ if (val) {
56
+ resolve(true);
57
+ }
58
+ }, {
59
+ immediate: true
60
+ });
61
+ onScopeDispose(() => resolve(false), true);
62
+ }).then((val) => {
63
+ off?.();
64
+ return val;
65
+ });
66
+ }
67
+ head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
68
+ s._statusRef.value = s.status;
69
+ });
70
+ const script = useScript$1(input, options);
71
+ script._statusRef = script._statusRef || ref(script.status);
72
+ registerVueScopeHandlers(script, scope);
73
+ return new Proxy(script, {
74
+ get(_, key, a) {
75
+ return Reflect.get(_, key === "status" ? "_statusRef" : key, a);
76
+ }
77
+ });
78
+ }
79
+
80
+ const CapoPlugin = () => defineHeadPlugin({});
81
+ function setHeadInjectionHandler(handler) {
82
+ unheadCtx.set(handler(), true);
83
+ }
84
+ function injectHead() {
85
+ const ctx = tryUseUnhead();
86
+ if (ctx) {
87
+ return ctx;
88
+ }
89
+ return inject(headSymbol);
90
+ }
91
+ function useHead(input, options = {}) {
92
+ const head = options.head || injectHead();
93
+ if (head) {
94
+ return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
95
+ }
96
+ }
97
+ function clientUseHead(head, input, options = {}) {
98
+ const deactivated = ref(false);
99
+ const resolvedInput = ref({});
100
+ watchEffect(() => {
101
+ resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
102
+ });
103
+ const entry = head.push(resolvedInput.value, options);
104
+ watch(resolvedInput, (e) => {
105
+ entry.patch(e);
106
+ });
107
+ const vm = getCurrentInstance();
108
+ if (vm) {
109
+ onBeforeUnmount(() => {
110
+ entry.dispose();
111
+ });
112
+ onDeactivated(() => {
113
+ deactivated.value = true;
114
+ });
115
+ onActivated(() => {
116
+ deactivated.value = false;
117
+ });
118
+ }
119
+ return entry;
120
+ }
121
+ function useHeadSafe(input, options = {}) {
122
+ return useHead(input, { ...options, transform: whitelistSafeInput });
123
+ }
124
+ function useSeoMeta(input, options) {
125
+ const { title, titleTemplate, ...meta } = input;
126
+ return useHead({
127
+ title,
128
+ titleTemplate,
129
+ // @ts-expect-error runtime type
130
+ _flatMeta: meta
131
+ }, {
132
+ ...options,
133
+ transform(t) {
134
+ const meta2 = unpackMeta({ ...t._flatMeta });
135
+ delete t._flatMeta;
136
+ return {
137
+ // @ts-expect-error runtime type
138
+ ...t,
139
+ meta: meta2
140
+ };
141
+ }
142
+ });
143
+ }
144
+ function useServerHead(input, options = {}) {
145
+ return useHead(input, { ...options, mode: "server" });
146
+ }
147
+ function useServerHeadSafe(input, options = {}) {
148
+ return useHeadSafe(input, { ...options, mode: "server" });
149
+ }
150
+ function useServerSeoMeta(input, options) {
151
+ return useSeoMeta(input, { ...options, mode: "server" });
152
+ }
153
+
154
+ export { CapoPlugin, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ const server = require('unhead/server');
4
+ const useHead = require('./shared/vue.BwEnMiRq.cjs');
5
+ const VueReactivityPlugin = require('./shared/vue.DIPZN3-d.cjs');
6
+ const VueHeadMixin = require('./shared/vue.3OjaFlxQ.cjs');
7
+ require('vue');
8
+ require('unhead');
9
+ require('@unhead/shared');
10
+
11
+ function createHead(options = {}) {
12
+ const head = server.createHead({
13
+ ...options,
14
+ plugins: [
15
+ ...options.plugins || [],
16
+ VueReactivityPlugin.VueReactivityPlugin
17
+ ]
18
+ });
19
+ head.install = useHead.vueInstall(head);
20
+ return head;
21
+ }
22
+
23
+ exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
24
+ exports.createHead = createHead;
25
+ Object.prototype.hasOwnProperty.call(server, '__proto__') &&
26
+ !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
27
+ Object.defineProperty(exports, '__proto__', {
28
+ enumerable: true,
29
+ value: server['__proto__']
30
+ });
31
+
32
+ Object.keys(server).forEach(function (k) {
33
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = server[k];
34
+ });
@@ -0,0 +1,11 @@
1
+ import { MergeHead, CreateHeadOptions } from '@unhead/schema';
2
+ import { d as distExports } from './shared/vue.DShwsPiO.cjs';
3
+ export { V as VueHeadMixin } from './shared/vue.DnywREVF.cjs';
4
+ export * from 'unhead/server';
5
+ import '@unhead/shared';
6
+ import 'unhead';
7
+ import 'vue';
8
+
9
+ declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): distExports.VueHeadClient<T>;
10
+
11
+ export { createHead };
@@ -0,0 +1,11 @@
1
+ import { MergeHead, CreateHeadOptions } from '@unhead/schema';
2
+ import { d as distExports } from './shared/vue.DShwsPiO.mjs';
3
+ export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
4
+ export * from 'unhead/server';
5
+ import '@unhead/shared';
6
+ import 'unhead';
7
+ import 'vue';
8
+
9
+ declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): distExports.VueHeadClient<T>;
10
+
11
+ export { createHead };
@@ -0,0 +1,11 @@
1
+ import { MergeHead, CreateHeadOptions } from '@unhead/schema';
2
+ import { d as distExports } from './shared/vue.DShwsPiO.js';
3
+ export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
4
+ export * from 'unhead/server';
5
+ import '@unhead/shared';
6
+ import 'unhead';
7
+ import 'vue';
8
+
9
+ declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): distExports.VueHeadClient<T>;
10
+
11
+ export { createHead };
@@ -0,0 +1,22 @@
1
+ import { createHead as createHead$1 } from 'unhead/server';
2
+ export * from 'unhead/server';
3
+ import { v as vueInstall } from './shared/vue.Sg4YunmP.mjs';
4
+ import { V as VueReactivityPlugin } from './shared/vue.B6jdKgLD.mjs';
5
+ export { V as VueHeadMixin } from './shared/vue.O-w7-AFg.mjs';
6
+ import 'vue';
7
+ import 'unhead';
8
+ import '@unhead/shared';
9
+
10
+ function createHead(options = {}) {
11
+ const head = createHead$1({
12
+ ...options,
13
+ plugins: [
14
+ ...options.plugins || [],
15
+ VueReactivityPlugin
16
+ ]
17
+ });
18
+ head.install = vueInstall(head);
19
+ return head;
20
+ }
21
+
22
+ export { createHead };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ const vue = require('vue');
4
+ const useHead = require('./vue.BwEnMiRq.cjs');
5
+
6
+ const VueHeadMixin = {
7
+ created() {
8
+ let source = false;
9
+ const instance = vue.getCurrentInstance();
10
+ if (!instance)
11
+ return;
12
+ const options = instance.type;
13
+ if (!options || !("head" in options))
14
+ return;
15
+ source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
16
+ source && useHead.useHead(source);
17
+ }
18
+ };
19
+
20
+ exports.VueHeadMixin = VueHeadMixin;
@@ -0,0 +1,13 @@
1
+ import { defineHeadPlugin } from '@unhead/shared';
2
+ import { r as resolveUnrefHeadInput } from './vue.Sg4YunmP.mjs';
3
+
4
+ const VueReactivityPlugin = defineHeadPlugin({
5
+ hooks: {
6
+ "entries:resolve": (ctx) => {
7
+ for (const entry of ctx.entries)
8
+ entry.resolvedInput = resolveUnrefHeadInput(entry.input);
9
+ }
10
+ }
11
+ });
12
+
13
+ export { VueReactivityPlugin as V };
@@ -1,9 +1,11 @@
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';
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
2
  import { ComputedRef, Ref, Plugin } from 'vue';
3
3
 
4
- type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
4
+ declare function resolveUnrefHeadInput(ref: any): any;
5
+
6
+ type MaybeReadonlyRef<T> = ComputedRef<T>;
5
7
  type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
6
- type MaybeComputedRefOrFalsy<T> = undefined | false | null | T | MaybeReadonlyRef<T> | Ref<T>;
8
+ type MaybeComputedRefOrFalsy<T> = T | MaybeReadonlyRef<T> | Ref<T>;
7
9
  /**
8
10
  * @deprecated Use MaybeComputedRefOrFalsy
9
11
  */
@@ -39,14 +41,14 @@ interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
39
41
  }
40
42
  type Title = MaybeComputedRef<Title$1>;
41
43
  type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
42
- type Base<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
43
- type Link<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Link$1<E>>;
44
- type Meta<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Meta$1<E>>;
45
- type Style<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Style$1<E>>;
46
- type Script<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Script$1<E>>;
47
- type Noscript<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Noscript$1<E>>;
48
- type HtmlAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
49
- type BodyAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeFunctionEntries<BodyEvents>>;
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>>;
50
52
  interface ReactiveHead<E extends MergeHead = MergeHead> {
51
53
  /**
52
54
  * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
@@ -122,11 +124,21 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
122
124
  type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
123
125
  head?: VueHeadClient<any>;
124
126
  };
125
- type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
127
+ type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
126
128
  type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
127
129
  title?: ReactiveHead['title'];
128
130
  titleTemplate?: ReactiveHead['titleTemplate'];
129
131
  };
130
132
  type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
131
133
 
132
- 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, MaybeComputedRefEntriesOnly as c, UseSeoMetaInput as d, TitleTemplate as e, Base as f, Meta as g, Script as h, HtmlAttributes as i, BodyAttributes as j, MaybeReadonlyRef as k, MaybeComputedRefOrFalsy as l, MaybeComputedRefOrPromise as m };
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,9 +1,11 @@
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';
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
2
  import { ComputedRef, Ref, Plugin } from 'vue';
3
3
 
4
- type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
4
+ declare function resolveUnrefHeadInput(ref: any): any;
5
+
6
+ type MaybeReadonlyRef<T> = ComputedRef<T>;
5
7
  type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
6
- type MaybeComputedRefOrFalsy<T> = undefined | false | null | T | MaybeReadonlyRef<T> | Ref<T>;
8
+ type MaybeComputedRefOrFalsy<T> = T | MaybeReadonlyRef<T> | Ref<T>;
7
9
  /**
8
10
  * @deprecated Use MaybeComputedRefOrFalsy
9
11
  */
@@ -39,14 +41,14 @@ interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
39
41
  }
40
42
  type Title = MaybeComputedRef<Title$1>;
41
43
  type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
42
- type Base<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
43
- type Link<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Link$1<E>>;
44
- type Meta<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Meta$1<E>>;
45
- type Style<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Style$1<E>>;
46
- type Script<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Script$1<E>>;
47
- type Noscript<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Noscript$1<E>>;
48
- type HtmlAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
49
- type BodyAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeFunctionEntries<BodyEvents>>;
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>>;
50
52
  interface ReactiveHead<E extends MergeHead = MergeHead> {
51
53
  /**
52
54
  * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
@@ -122,11 +124,21 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
122
124
  type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
123
125
  head?: VueHeadClient<any>;
124
126
  };
125
- type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
127
+ type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
126
128
  type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
127
129
  title?: ReactiveHead['title'];
128
130
  titleTemplate?: ReactiveHead['titleTemplate'];
129
131
  };
130
132
  type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
131
133
 
132
- 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, MaybeComputedRefEntriesOnly as c, UseSeoMetaInput as d, TitleTemplate as e, Base as f, Meta as g, Script as h, HtmlAttributes as i, BodyAttributes as j, MaybeReadonlyRef as k, MaybeComputedRefOrFalsy as l, MaybeComputedRefOrPromise as m };
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,9 +1,11 @@
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';
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
2
  import { ComputedRef, Ref, Plugin } from 'vue';
3
3
 
4
- type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
4
+ declare function resolveUnrefHeadInput(ref: any): any;
5
+
6
+ type MaybeReadonlyRef<T> = ComputedRef<T>;
5
7
  type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
6
- type MaybeComputedRefOrFalsy<T> = undefined | false | null | T | MaybeReadonlyRef<T> | Ref<T>;
8
+ type MaybeComputedRefOrFalsy<T> = T | MaybeReadonlyRef<T> | Ref<T>;
7
9
  /**
8
10
  * @deprecated Use MaybeComputedRefOrFalsy
9
11
  */
@@ -39,14 +41,14 @@ interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
39
41
  }
40
42
  type Title = MaybeComputedRef<Title$1>;
41
43
  type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
42
- type Base<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
43
- type Link<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Link$1<E>>;
44
- type Meta<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Meta$1<E>>;
45
- type Style<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Style$1<E>>;
46
- type Script<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Script$1<E>>;
47
- type Noscript<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Noscript$1<E>>;
48
- type HtmlAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
49
- type BodyAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeFunctionEntries<BodyEvents>>;
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>>;
50
52
  interface ReactiveHead<E extends MergeHead = MergeHead> {
51
53
  /**
52
54
  * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
@@ -122,11 +124,21 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
122
124
  type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
123
125
  head?: VueHeadClient<any>;
124
126
  };
125
- type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
127
+ type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
126
128
  type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
127
129
  title?: ReactiveHead['title'];
128
130
  titleTemplate?: ReactiveHead['titleTemplate'];
129
131
  };
130
132
  type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
131
133
 
132
- 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, MaybeComputedRefEntriesOnly as c, UseSeoMetaInput as d, TitleTemplate as e, Base as f, Meta as g, Script as h, HtmlAttributes as i, BodyAttributes as j, MaybeReadonlyRef as k, MaybeComputedRefOrFalsy as l, MaybeComputedRefOrPromise as m };
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 };
@@ -0,0 +1,91 @@
1
+ 'use strict';
2
+
3
+ const vue = require('vue');
4
+ const unhead = require('unhead');
5
+
6
+ function resolveUnref(r) {
7
+ return typeof r === "function" ? r() : vue.unref(r);
8
+ }
9
+ function resolveUnrefHeadInput(ref) {
10
+ if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
11
+ return ref;
12
+ const root = resolveUnref(ref);
13
+ if (!ref || !root)
14
+ return root;
15
+ if (Array.isArray(root))
16
+ return root.map((r) => resolveUnrefHeadInput(r));
17
+ if (typeof root === "object") {
18
+ const resolved = {};
19
+ for (const k in root) {
20
+ if (!Object.prototype.hasOwnProperty.call(root, k)) {
21
+ continue;
22
+ }
23
+ if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
24
+ resolved[k] = vue.unref(root[k]);
25
+ continue;
26
+ }
27
+ resolved[k] = resolveUnrefHeadInput(root[k]);
28
+ }
29
+ return resolved;
30
+ }
31
+ return root;
32
+ }
33
+
34
+ const headSymbol = "usehead";
35
+ function vueInstall(head) {
36
+ const plugin = {
37
+ install(app) {
38
+ app.config.globalProperties.$unhead = head;
39
+ app.config.globalProperties.$head = head;
40
+ app.provide(headSymbol, head);
41
+ }
42
+ };
43
+ return plugin.install;
44
+ }
45
+
46
+ function injectHead() {
47
+ const ctx = unhead.tryUseUnhead();
48
+ if (ctx) {
49
+ return ctx;
50
+ }
51
+ const instance = vue.inject(headSymbol);
52
+ if (!instance) {
53
+ throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
54
+ }
55
+ return instance;
56
+ }
57
+
58
+ function useHead(input, options = {}) {
59
+ const head = options.head || injectHead();
60
+ return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
61
+ }
62
+ function clientUseHead(head, input, options = {}) {
63
+ const deactivated = vue.ref(false);
64
+ const resolvedInput = vue.ref({});
65
+ vue.watchEffect(() => {
66
+ resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
67
+ });
68
+ const entry = head.push(resolvedInput.value, options);
69
+ vue.watch(resolvedInput, (e) => {
70
+ entry.patch(e);
71
+ });
72
+ const vm = vue.getCurrentInstance();
73
+ if (vm) {
74
+ vue.onBeforeUnmount(() => {
75
+ entry.dispose();
76
+ });
77
+ vue.onDeactivated(() => {
78
+ deactivated.value = true;
79
+ });
80
+ vue.onActivated(() => {
81
+ deactivated.value = false;
82
+ });
83
+ }
84
+ return entry;
85
+ }
86
+
87
+ exports.headSymbol = headSymbol;
88
+ exports.injectHead = injectHead;
89
+ exports.resolveUnrefHeadInput = resolveUnrefHeadInput;
90
+ exports.useHead = useHead;
91
+ exports.vueInstall = vueInstall;
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ const shared = require('@unhead/shared');
4
+ const useHead = require('./vue.BwEnMiRq.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;