@unhead/vue 1.2.2 → 1.3.0-beta.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const unhead = require('unhead');
4
- const useHead = require('./shared/vue.a57702be.cjs');
4
+ const useHead = require('./shared/vue.4471084f.cjs');
5
5
  const vue = require('vue');
6
6
  const shared = require('@unhead/shared');
7
7
 
@@ -38,8 +38,15 @@ const Vue2ProvideUnheadPlugin = function(_Vue, head) {
38
38
  });
39
39
  };
40
40
 
41
+ const coreComposableNames = [
42
+ "injectHead"
43
+ ];
44
+ const unheadVueComposablesImports = {
45
+ "@unhead/vue": [...coreComposableNames, ...shared.composableNames]
46
+ };
47
+
41
48
  function useHeadSafe(input, options = {}) {
42
- return useHead.useHead(input, { ...options, transform: unhead.whitelistSafeInput });
49
+ return useHead.useHead(input, { ...options, transform: shared.whitelistSafeInput });
43
50
  }
44
51
 
45
52
  function useSeoMeta(input, options) {
@@ -50,14 +57,15 @@ function useSeoMeta(input, options) {
50
57
  headInput.value = {
51
58
  title,
52
59
  titleTemplate,
53
- meta: unhead.unpackMeta(meta)
60
+ meta: shared.unpackMeta(meta)
54
61
  };
55
62
  });
56
63
  return useHead.useHead(headInput, options);
57
64
  }
58
65
 
59
66
  function useServerHead(input, options = {}) {
60
- return useHead.serverUseHead(input, { ...options, mode: "server" });
67
+ const head = useHead.injectHead();
68
+ return head.push(input, options);
61
69
  }
62
70
 
63
71
  function useServerHeadSafe(input, options = {}) {
@@ -68,124 +76,18 @@ function useServerSeoMeta(input, options) {
68
76
  return useSeoMeta(input, { ...options || {}, mode: "server" });
69
77
  }
70
78
 
71
- function useTagTitle(title) {
72
- return useHead.useHead({ title });
73
- }
74
- function useTitleTemplate(titleTemplate) {
75
- return useHead.useHead({ titleTemplate });
76
- }
77
- function useTagMeta(meta) {
78
- return useHead.useHead({ meta: shared.asArray(meta) });
79
- }
80
- function useTagMetaFlat(meta) {
81
- const input = vue.ref({});
82
- vue.watchEffect(() => {
83
- input.value = unhead.unpackMeta(useHead.resolveUnrefHeadInput(meta));
84
- });
85
- return useHead.useHead({ meta: input });
86
- }
87
- function useTagLink(link) {
88
- return useHead.useHead({ link: shared.asArray(link) });
89
- }
90
- function useTagScript(script) {
91
- return useHead.useHead({ script: shared.asArray(script) });
92
- }
93
- function useTagStyle(style) {
94
- return useHead.useHead({ style: shared.asArray(style) });
95
- }
96
- function useTagNoscript(noscript) {
97
- return useHead.useHead({ noscript: shared.asArray(noscript) });
98
- }
99
- function useTagBase(base) {
100
- return useHead.useHead({ base });
101
- }
102
- function useHtmlAttrs(attrs) {
103
- return useHead.useHead({ htmlAttrs: attrs });
104
- }
105
- function useBodyAttrs(attrs) {
106
- return useHead.useHead({ bodyAttrs: attrs });
107
- }
108
- function useServerTagTitle(title) {
109
- return useServerHead({ title });
110
- }
111
- function useServerTitleTemplate(titleTemplate) {
112
- return useServerHead({ titleTemplate });
113
- }
114
- function useServerTagMeta(meta) {
115
- return useServerHead({ meta: shared.asArray(meta) });
116
- }
117
- function useServerTagMetaFlat(meta) {
118
- const input = vue.ref({});
119
- vue.watchEffect(() => {
120
- input.value = unhead.unpackMeta(useHead.resolveUnrefHeadInput(meta));
121
- });
122
- return useServerHead({ meta: input });
123
- }
124
- function useServerTagLink(link) {
125
- return useServerHead({ link: shared.asArray(link) });
126
- }
127
- function useServerTagScript(script) {
128
- return useServerHead({ script: shared.asArray(script) });
129
- }
130
- function useServerTagStyle(style) {
131
- return useServerHead({ style: shared.asArray(style) });
132
- }
133
- function useServerTagNoscript(noscript) {
134
- return useServerHead({ noscript: shared.asArray(noscript) });
135
- }
136
- function useServerTagBase(base) {
137
- return useServerHead({ base });
138
- }
139
- function useServerHtmlAttrs(attrs) {
140
- return useServerHead({ htmlAttrs: attrs });
141
- }
142
- function useServerBodyAttrs(attrs) {
143
- return useHead.useHead({ bodyAttrs: attrs });
144
- }
145
-
146
- const coreComposableNames = [
147
- "injectHead"
148
- ];
149
- const unheadVueComposablesImports = {
150
- "@unhead/vue": [...coreComposableNames, ...unhead.composableNames]
151
- };
152
-
153
79
  exports.CapoPlugin = unhead.CapoPlugin;
80
+ exports.HashHydrationPlugin = unhead.HashHydrationPlugin;
154
81
  exports.createHeadCore = unhead.createHeadCore;
155
- exports.VueReactiveUseHeadPlugin = useHead.VueReactiveUseHeadPlugin;
156
82
  exports.createHead = useHead.createHead;
157
83
  exports.createServerHead = useHead.createServerHead;
158
- exports.headSymbol = useHead.headSymbol;
159
84
  exports.injectHead = useHead.injectHead;
160
- exports.resolveUnrefHeadInput = useHead.resolveUnrefHeadInput;
161
85
  exports.useHead = useHead.useHead;
162
86
  exports.Vue2ProvideUnheadPlugin = Vue2ProvideUnheadPlugin;
163
87
  exports.VueHeadMixin = VueHeadMixin;
164
88
  exports.unheadVueComposablesImports = unheadVueComposablesImports;
165
- exports.useBodyAttrs = useBodyAttrs;
166
89
  exports.useHeadSafe = useHeadSafe;
167
- exports.useHtmlAttrs = useHtmlAttrs;
168
90
  exports.useSeoMeta = useSeoMeta;
169
- exports.useServerBodyAttrs = useServerBodyAttrs;
170
91
  exports.useServerHead = useServerHead;
171
92
  exports.useServerHeadSafe = useServerHeadSafe;
172
- exports.useServerHtmlAttrs = useServerHtmlAttrs;
173
93
  exports.useServerSeoMeta = useServerSeoMeta;
174
- exports.useServerTagBase = useServerTagBase;
175
- exports.useServerTagLink = useServerTagLink;
176
- exports.useServerTagMeta = useServerTagMeta;
177
- exports.useServerTagMetaFlat = useServerTagMetaFlat;
178
- exports.useServerTagNoscript = useServerTagNoscript;
179
- exports.useServerTagScript = useServerTagScript;
180
- exports.useServerTagStyle = useServerTagStyle;
181
- exports.useServerTagTitle = useServerTagTitle;
182
- exports.useServerTitleTemplate = useServerTitleTemplate;
183
- exports.useTagBase = useTagBase;
184
- exports.useTagLink = useTagLink;
185
- exports.useTagMeta = useTagMeta;
186
- exports.useTagMetaFlat = useTagMetaFlat;
187
- exports.useTagNoscript = useTagNoscript;
188
- exports.useTagScript = useTagScript;
189
- exports.useTagStyle = useTagStyle;
190
- exports.useTagTitle = useTagTitle;
191
- exports.useTitleTemplate = useTitleTemplate;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
- export { CapoPlugin, createHeadCore } from 'unhead';
2
- import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, U as UseHeadInput, A as Arrayable, b as Meta, L as Link, S as Script, c as Style, N as Noscript } from './createHead-197548ae.js';
3
- export { e as Base, B as BodyAttr, g as BodyAttributes, H as HtmlAttr, f as HtmlAttributes, i as MaybeComputedRefOrPromise, h as MaybeReadonlyRef, T as Title, d as TitleTemplate, V as VueHeadClient, m as createHead, l as createServerHead, j as headSymbol, k as injectHead } from './createHead-197548ae.js';
1
+ import require$$1 from 'unhead';
2
+ export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
4
3
  import * as _unhead_schema from '@unhead/schema';
5
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, HeadEntryOptions, ActiveHeadEntry, MetaFlatInput } from '@unhead/schema';
4
+ import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, HeadEntryOptions, ActiveHeadEntry, MetaFlatInput } from '@unhead/schema';
6
5
  export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
7
- import { Plugin } from 'vue';
6
+ import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput } from './schema-f7f2c0b4.js';
7
+ export { c as Base, B as BodyAttr, g as BodyAttributes, H as HtmlAttr, f as HtmlAttributes, L as Link, i as MaybeComputedRefOrPromise, h as MaybeReadonlyRef, d as Meta, N as Noscript, e as Script, S as Style, T as Title, b as TitleTemplate } from './schema-f7f2c0b4.js';
8
+ import require$$0, { Plugin } from 'vue';
9
+ import require$$2 from '@unhead/shared';
8
10
 
9
11
  interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
10
12
  meta?: MaybeComputedRefEntries<SafeMeta>[];
@@ -16,17 +18,225 @@ interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templ
16
18
  }
17
19
  type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
18
20
 
19
- declare function resolveUnrefHeadInput(ref: any, lastKey?: string | number): any;
21
+ declare function createServerHead$1<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): VueHeadClient<T>;
22
+ declare function createHead$1<T extends MergeHead>(options?: CreateHeadOptions): VueHeadClient<T>;
20
23
 
21
- declare const VueHeadMixin: {
24
+ declare const VueHeadMixin$1: {
22
25
  created(): void;
23
26
  };
24
27
 
25
- declare function VueReactiveUseHeadPlugin(): _unhead_schema.HeadPlugin;
28
+ declare const Vue2ProvideUnheadPlugin$1: Plugin;
26
29
 
27
- declare const Vue2ProvideUnheadPlugin: Plugin;
30
+ declare const unheadVueComposablesImports$1: {
31
+ '@unhead/vue': string[];
32
+ };
33
+
34
+ declare function injectHead$1<T extends MergeHead>(): VueHeadClient<T>;
35
+
36
+ var dist = {};
37
+
38
+ var vue_4471084f = {};
39
+
40
+ const vue$1 = require$$0;
41
+ const unhead$1 = require$$1;
42
+ const shared$1 = require$$2;
43
+
44
+ const Vue3 = vue$1.version.startsWith("3");
45
+
46
+ function resolveUnref(r) {
47
+ return typeof r === "function" ? r() : vue$1.unref(r);
48
+ }
49
+ function resolveUnrefHeadInput(ref, lastKey = "") {
50
+ if (ref instanceof Promise)
51
+ return ref;
52
+ const root = resolveUnref(ref);
53
+ if (!ref || !root)
54
+ return root;
55
+ if (Array.isArray(root))
56
+ return root.map((r) => resolveUnrefHeadInput(r, lastKey));
57
+ if (typeof root === "object") {
58
+ return Object.fromEntries(
59
+ Object.entries(root).map(([k, v]) => {
60
+ if (k === "titleTemplate" || k.startsWith("on"))
61
+ return [k, vue$1.unref(v)];
62
+ return [k, resolveUnrefHeadInput(v, k)];
63
+ })
64
+ );
65
+ }
66
+ return root;
67
+ }
68
+
69
+ const VueReactivityPlugin = shared$1.defineHeadPlugin({
70
+ hooks: {
71
+ "entries:resolve": function(ctx) {
72
+ for (const entry of ctx.entries)
73
+ entry.resolvedInput = resolveUnrefHeadInput(entry.input);
74
+ }
75
+ }
76
+ });
77
+
78
+ const headSymbol = "usehead";
79
+ function vueInstall(head) {
80
+ const plugin = {
81
+ install(app) {
82
+ if (Vue3) {
83
+ app.config.globalProperties.$unhead = head;
84
+ app.config.globalProperties.$head = head;
85
+ app.provide(headSymbol, head);
86
+ }
87
+ }
88
+ };
89
+ return plugin.install;
90
+ }
91
+ function createServerHead(options = {}) {
92
+ const head = unhead$1.createServerHead(options);
93
+ head.use(VueReactivityPlugin);
94
+ head.install = vueInstall(head);
95
+ return head;
96
+ }
97
+ function createHead(options = {}) {
98
+ options.domDelayFn = options.domDelayFn || ((fn) => vue$1.nextTick(() => fn()));
99
+ const head = unhead$1.createHead(options);
100
+ head.use(VueReactivityPlugin);
101
+ head.install = vueInstall(head);
102
+ return head;
103
+ }
104
+
105
+ function injectHead() {
106
+ return vue$1.getCurrentInstance() && vue$1.inject(headSymbol) || unhead$1.getActiveHead();
107
+ }
108
+
109
+ function useHead$2(input, options = {}) {
110
+ const head = injectHead();
111
+ if (!head.ssr)
112
+ return clientUseHead(head, input, options);
113
+ return head.push(input, options);
114
+ }
115
+ function clientUseHead(head, input, options = {}) {
116
+ const deactivated = vue$1.ref(false);
117
+ const resolvedInput = vue$1.ref({});
118
+ vue$1.watchEffect(() => {
119
+ resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
120
+ });
121
+ const entry = head.push(resolvedInput.value, options);
122
+ vue$1.watch(resolvedInput, (e) => {
123
+ entry.patch(e);
124
+ });
125
+ const vm = vue$1.getCurrentInstance();
126
+ if (vm) {
127
+ vue$1.onBeforeUnmount(() => {
128
+ entry.dispose();
129
+ });
130
+ vue$1.onDeactivated(() => {
131
+ deactivated.value = true;
132
+ });
133
+ vue$1.onActivated(() => {
134
+ deactivated.value = false;
135
+ });
136
+ }
137
+ return entry;
138
+ }
139
+
140
+ vue_4471084f.createHead = createHead;
141
+ vue_4471084f.createServerHead = createServerHead;
142
+ vue_4471084f.headSymbol = headSymbol;
143
+ vue_4471084f.injectHead = injectHead;
144
+ vue_4471084f.resolveUnrefHeadInput = resolveUnrefHeadInput;
145
+ vue_4471084f.useHead = useHead$2;
28
146
 
29
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
147
+ const unhead = require$$1;
148
+ const useHead$1 = vue_4471084f;
149
+ const vue = require$$0;
150
+ const shared = require$$2;
151
+
152
+ const VueHeadMixin = {
153
+ created() {
154
+ const instance = vue.getCurrentInstance();
155
+ if (!instance)
156
+ return;
157
+ const options = instance.type;
158
+ if (!options || !("head" in options))
159
+ return;
160
+ const source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
161
+ useHead$1.useHead(source);
162
+ }
163
+ };
164
+
165
+ const Vue2ProvideUnheadPlugin = function(_Vue, head) {
166
+ _Vue.mixin({
167
+ beforeCreate() {
168
+ const options = this.$options;
169
+ const origProvide = options.provide;
170
+ options.provide = function() {
171
+ let origProvideResult;
172
+ if (typeof origProvide === "function")
173
+ origProvideResult = origProvide.call(this);
174
+ else
175
+ origProvideResult = origProvide || {};
176
+ return {
177
+ ...origProvideResult,
178
+ [useHead$1.headSymbol]: head
179
+ };
180
+ };
181
+ }
182
+ });
183
+ };
184
+
185
+ const coreComposableNames = [
186
+ "injectHead"
187
+ ];
188
+ const unheadVueComposablesImports = {
189
+ "@unhead/vue": [...coreComposableNames, ...shared.composableNames]
190
+ };
191
+
192
+ function useHeadSafe$1(input, options = {}) {
193
+ return useHead$1.useHead(input, { ...options, transform: shared.whitelistSafeInput });
194
+ }
195
+
196
+ function useSeoMeta$1(input, options) {
197
+ const headInput = vue.ref({});
198
+ vue.watchEffect(() => {
199
+ const resolvedMeta = useHead$1.resolveUnrefHeadInput(input);
200
+ const { title, titleTemplate, ...meta } = resolvedMeta;
201
+ headInput.value = {
202
+ title,
203
+ titleTemplate,
204
+ meta: shared.unpackMeta(meta)
205
+ };
206
+ });
207
+ return useHead$1.useHead(headInput, options);
208
+ }
209
+
210
+ function useServerHead$1(input, options = {}) {
211
+ const head = useHead$1.injectHead();
212
+ return head.push(input, options);
213
+ }
214
+
215
+ function useServerHeadSafe$1(input, options = {}) {
216
+ return useHeadSafe$1(input, { ...options, mode: "server" });
217
+ }
218
+
219
+ function useServerSeoMeta$1(input, options) {
220
+ return useSeoMeta$1(input, { ...options || {}, mode: "server" });
221
+ }
222
+
223
+ dist.CapoPlugin = unhead.CapoPlugin;
224
+ dist.HashHydrationPlugin = unhead.HashHydrationPlugin;
225
+ dist.createHeadCore = unhead.createHeadCore;
226
+ dist.createHead = useHead$1.createHead;
227
+ dist.createServerHead = useHead$1.createServerHead;
228
+ dist.injectHead = useHead$1.injectHead;
229
+ dist.useHead = useHead$1.useHead;
230
+ dist.Vue2ProvideUnheadPlugin = Vue2ProvideUnheadPlugin;
231
+ dist.VueHeadMixin = VueHeadMixin;
232
+ dist.unheadVueComposablesImports = unheadVueComposablesImports;
233
+ dist.useHeadSafe = useHeadSafe$1;
234
+ dist.useSeoMeta = useSeoMeta$1;
235
+ dist.useServerHead = useServerHead$1;
236
+ dist.useServerHeadSafe = useServerHeadSafe$1;
237
+ dist.useServerSeoMeta = useServerSeoMeta$1;
238
+
239
+ declare function useHead<T extends MergeHead>(input: dist.UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<dist.UseHeadInput<T>> | void;
30
240
 
31
241
  declare function useHeadSafe(input: UseHeadSafeInput, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
32
242
 
@@ -36,103 +246,10 @@ type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
36
246
  };
37
247
  declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
38
248
 
39
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): _unhead_schema.ActiveHeadEntry<UseHeadInput<T>>;
249
+ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): _unhead_schema.ActiveHeadEntry<MaybeComputedRef<ReactiveHead<MergeHead>>>;
40
250
 
41
251
  declare function useServerHeadSafe(input: UseHeadSafeInput, options?: HeadEntryOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadSafeInput>;
42
252
 
43
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
44
-
45
- /**
46
- * @deprecated Use `useHead`
47
- */
48
- declare function useTagTitle(title: ReactiveHead['title']): ActiveHeadEntry<any> | void;
49
- /**
50
- * @deprecated Use `useHead`
51
- */
52
- declare function useTitleTemplate(titleTemplate: ReactiveHead['titleTemplate']): ActiveHeadEntry<any> | void;
53
- /**
54
- * @deprecated Use `useHead`
55
- */
56
- declare function useTagMeta(meta: Arrayable<Meta>): ActiveHeadEntry<any> | void;
57
- /**
58
- * @deprecated Use `useHead`
59
- */
60
- declare function useTagMetaFlat(meta: MaybeComputedRefEntries<MetaFlatInput>): ActiveHeadEntry<any> | void;
61
- /**
62
- * @deprecated Use `useHead`
63
- */
64
- declare function useTagLink(link: Arrayable<Link>): ActiveHeadEntry<any> | void;
65
- /**
66
- * @deprecated Use `useHead`
67
- */
68
- declare function useTagScript(script: Arrayable<Script>): ActiveHeadEntry<any> | void;
69
- /**
70
- * @deprecated Use `useHead`
71
- */
72
- declare function useTagStyle(style: Arrayable<Style>): ActiveHeadEntry<any> | void;
73
- /**
74
- * @deprecated Use `useHead`
75
- */
76
- declare function useTagNoscript(noscript: Arrayable<Noscript>): ActiveHeadEntry<any> | void;
77
- /**
78
- * @deprecated Use `useHead`
79
- */
80
- declare function useTagBase(base: ReactiveHead['base']): ActiveHeadEntry<any> | void;
81
- /**
82
- * @deprecated Use `useHead`
83
- */
84
- declare function useHtmlAttrs(attrs: ReactiveHead['htmlAttrs']): ActiveHeadEntry<any> | void;
85
- /**
86
- * @deprecated Use `useHead`
87
- */
88
- declare function useBodyAttrs(attrs: ReactiveHead['bodyAttrs']): ActiveHeadEntry<any> | void;
89
- /**
90
- * @deprecated Use `useHead`
91
- */
92
- declare function useServerTagTitle(title: ReactiveHead['title']): ActiveHeadEntry<any> | void;
93
- /**
94
- * @deprecated Use `useHead`
95
- */
96
- declare function useServerTitleTemplate(titleTemplate: ReactiveHead['titleTemplate']): ActiveHeadEntry<any> | void;
97
- /**
98
- * @deprecated Use `useHead`
99
- */
100
- declare function useServerTagMeta(meta: Arrayable<Meta>): ActiveHeadEntry<any> | void;
101
- /**
102
- * @deprecated Use `useHead`
103
- */
104
- declare function useServerTagMetaFlat(meta: MaybeComputedRefEntries<MetaFlatInput>): ActiveHeadEntry<any> | void;
105
- /**
106
- * @deprecated Use `useHead`
107
- */
108
- declare function useServerTagLink(link: Arrayable<Link>): ActiveHeadEntry<any> | void;
109
- /**
110
- * @deprecated Use `useHead`
111
- */
112
- declare function useServerTagScript(script: Arrayable<Script>): ActiveHeadEntry<any> | void;
113
- /**
114
- * @deprecated Use `useHead`
115
- */
116
- declare function useServerTagStyle(style: Arrayable<Style>): ActiveHeadEntry<any> | void;
117
- /**
118
- * @deprecated Use `useHead`
119
- */
120
- declare function useServerTagNoscript(noscript: Arrayable<Noscript>): ActiveHeadEntry<any> | void;
121
- /**
122
- * @deprecated Use `useHead`
123
- */
124
- declare function useServerTagBase(base: ReactiveHead['base']): ActiveHeadEntry<any> | void;
125
- /**
126
- * @deprecated Use `useHead`
127
- */
128
- declare function useServerHtmlAttrs(attrs: ReactiveHead['htmlAttrs']): ActiveHeadEntry<any> | void;
129
- /**
130
- * @deprecated Use `useHead`
131
- */
132
- declare function useServerBodyAttrs(attrs: ReactiveHead['bodyAttrs']): ActiveHeadEntry<any> | void;
133
-
134
- declare const unheadVueComposablesImports: {
135
- '@unhead/vue': string[];
136
- };
253
+ declare function useServerSeoMeta(input: dist.UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
137
254
 
138
- export { Arrayable, HeadSafe, Link, MaybeComputedRef, MaybeComputedRefEntries, Meta, Noscript, ReactiveHead, Script, Style, UseHeadInput, UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadMixin, VueReactiveUseHeadPlugin, resolveUnrefHeadInput, unheadVueComposablesImports, useBodyAttrs, useHead, useHeadSafe, useHtmlAttrs, useSeoMeta, useServerBodyAttrs, useServerHead, useServerHeadSafe, useServerHtmlAttrs, useServerSeoMeta, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
255
+ export { HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin$1 as Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin$1 as VueHeadMixin, createHead$1 as createHead, createServerHead$1 as createServerHead, injectHead$1 as injectHead, unheadVueComposablesImports$1 as unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.mjs CHANGED
@@ -1,9 +1,8 @@
1
- import { whitelistSafeInput, unpackMeta, composableNames } from 'unhead';
2
- export { CapoPlugin, createHeadCore } from 'unhead';
3
- import { u as useHead, h as headSymbol, r as resolveUnrefHeadInput, s as serverUseHead } from './shared/vue.505b826e.mjs';
4
- export { V as VueReactiveUseHeadPlugin, a as createHead, c as createServerHead, i as injectHead } from './shared/vue.505b826e.mjs';
1
+ export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
2
+ import { u as useHead, h as headSymbol, r as resolveUnrefHeadInput, i as injectHead } from './shared/vue.9fbebdf0.mjs';
3
+ export { c as createHead, a as createServerHead } from './shared/vue.9fbebdf0.mjs';
5
4
  import { getCurrentInstance, ref, watchEffect } from 'vue';
6
- import { asArray } from '@unhead/shared';
5
+ import { composableNames, whitelistSafeInput, unpackMeta } from '@unhead/shared';
7
6
 
8
7
  const VueHeadMixin = {
9
8
  created() {
@@ -38,6 +37,13 @@ const Vue2ProvideUnheadPlugin = function(_Vue, head) {
38
37
  });
39
38
  };
40
39
 
40
+ const coreComposableNames = [
41
+ "injectHead"
42
+ ];
43
+ const unheadVueComposablesImports = {
44
+ "@unhead/vue": [...coreComposableNames, ...composableNames]
45
+ };
46
+
41
47
  function useHeadSafe(input, options = {}) {
42
48
  return useHead(input, { ...options, transform: whitelistSafeInput });
43
49
  }
@@ -57,7 +63,8 @@ function useSeoMeta(input, options) {
57
63
  }
58
64
 
59
65
  function useServerHead(input, options = {}) {
60
- return serverUseHead(input, { ...options, mode: "server" });
66
+ const head = injectHead();
67
+ return head.push(input, options);
61
68
  }
62
69
 
63
70
  function useServerHeadSafe(input, options = {}) {
@@ -68,86 +75,4 @@ function useServerSeoMeta(input, options) {
68
75
  return useSeoMeta(input, { ...options || {}, mode: "server" });
69
76
  }
70
77
 
71
- function useTagTitle(title) {
72
- return useHead({ title });
73
- }
74
- function useTitleTemplate(titleTemplate) {
75
- return useHead({ titleTemplate });
76
- }
77
- function useTagMeta(meta) {
78
- return useHead({ meta: asArray(meta) });
79
- }
80
- function useTagMetaFlat(meta) {
81
- const input = ref({});
82
- watchEffect(() => {
83
- input.value = unpackMeta(resolveUnrefHeadInput(meta));
84
- });
85
- return useHead({ meta: input });
86
- }
87
- function useTagLink(link) {
88
- return useHead({ link: asArray(link) });
89
- }
90
- function useTagScript(script) {
91
- return useHead({ script: asArray(script) });
92
- }
93
- function useTagStyle(style) {
94
- return useHead({ style: asArray(style) });
95
- }
96
- function useTagNoscript(noscript) {
97
- return useHead({ noscript: asArray(noscript) });
98
- }
99
- function useTagBase(base) {
100
- return useHead({ base });
101
- }
102
- function useHtmlAttrs(attrs) {
103
- return useHead({ htmlAttrs: attrs });
104
- }
105
- function useBodyAttrs(attrs) {
106
- return useHead({ bodyAttrs: attrs });
107
- }
108
- function useServerTagTitle(title) {
109
- return useServerHead({ title });
110
- }
111
- function useServerTitleTemplate(titleTemplate) {
112
- return useServerHead({ titleTemplate });
113
- }
114
- function useServerTagMeta(meta) {
115
- return useServerHead({ meta: asArray(meta) });
116
- }
117
- function useServerTagMetaFlat(meta) {
118
- const input = ref({});
119
- watchEffect(() => {
120
- input.value = unpackMeta(resolveUnrefHeadInput(meta));
121
- });
122
- return useServerHead({ meta: input });
123
- }
124
- function useServerTagLink(link) {
125
- return useServerHead({ link: asArray(link) });
126
- }
127
- function useServerTagScript(script) {
128
- return useServerHead({ script: asArray(script) });
129
- }
130
- function useServerTagStyle(style) {
131
- return useServerHead({ style: asArray(style) });
132
- }
133
- function useServerTagNoscript(noscript) {
134
- return useServerHead({ noscript: asArray(noscript) });
135
- }
136
- function useServerTagBase(base) {
137
- return useServerHead({ base });
138
- }
139
- function useServerHtmlAttrs(attrs) {
140
- return useServerHead({ htmlAttrs: attrs });
141
- }
142
- function useServerBodyAttrs(attrs) {
143
- return useHead({ bodyAttrs: attrs });
144
- }
145
-
146
- const coreComposableNames = [
147
- "injectHead"
148
- ];
149
- const unheadVueComposablesImports = {
150
- "@unhead/vue": [...coreComposableNames, ...composableNames]
151
- };
152
-
153
- export { Vue2ProvideUnheadPlugin, VueHeadMixin, headSymbol, resolveUnrefHeadInput, unheadVueComposablesImports, useBodyAttrs, useHead, useHeadSafe, useHtmlAttrs, useSeoMeta, useServerBodyAttrs, useServerHead, useServerHeadSafe, useServerHtmlAttrs, useServerSeoMeta, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
78
+ export { Vue2ProvideUnheadPlugin, VueHeadMixin, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/polyfill.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const useHead = require('./shared/vue.a57702be.cjs');
3
+ const useHead = require('./shared/vue.4471084f.cjs');
4
4
  require('vue');
5
5
  require('unhead');
6
6
  require('@unhead/shared');
@@ -1,5 +1,5 @@
1
1
  import { MergeHead, HeadEntryOptions } from '@unhead/schema';
2
- import { V as VueHeadClient, U as UseHeadInput } from './createHead-197548ae.js';
2
+ import { V as VueHeadClient, U as UseHeadInput } from './schema-f7f2c0b4.js';
3
3
  import 'vue';
4
4
 
5
5
  type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
package/dist/polyfill.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { u as useHead } from './shared/vue.505b826e.mjs';
1
+ import { u as useHead } from './shared/vue.9fbebdf0.mjs';
2
2
  import 'vue';
3
3
  import 'unhead';
4
4
  import '@unhead/shared';
@@ -1,5 +1,5 @@
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, Unhead } from '@unhead/schema';
1
2
  import { ComputedRef, Ref, Plugin } from 'vue';
2
- 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, Unhead, CreateHeadOptions } from '@unhead/schema';
3
3
 
4
4
  type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
5
5
  type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
@@ -7,7 +7,6 @@ type MaybeComputedRefOrPromise<T> = T | MaybeReadonlyRef<T> | Ref<T> | Promise<T
7
7
  type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
8
8
  [key in keyof T]?: MaybeComputedRefOrPromise<T[key]>;
9
9
  };
10
- type Arrayable<T> = T | Array<T>;
11
10
 
12
11
  interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
13
12
  /**
@@ -106,11 +105,6 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
106
105
  bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
107
106
  }
108
107
  type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
109
-
110
108
  type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
111
- declare const headSymbol = "usehead";
112
- declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
113
- declare function createServerHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): VueHeadClient<T>;
114
- declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn'>): VueHeadClient<T>;
115
109
 
116
- export { Arrayable as A, BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Script as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a, Meta as b, Style as c, TitleTemplate as d, Base as e, HtmlAttributes as f, BodyAttributes as g, MaybeReadonlyRef as h, MaybeComputedRefOrPromise as i, headSymbol as j, injectHead as k, createServerHead as l, createHead as m };
110
+ export { 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, TitleTemplate as b, Base as c, Meta as d, Script as e, HtmlAttributes as f, BodyAttributes as g, MaybeReadonlyRef as h, MaybeComputedRefOrPromise as i };
@@ -4,6 +4,8 @@ const vue = require('vue');
4
4
  const unhead = require('unhead');
5
5
  const shared = require('@unhead/shared');
6
6
 
7
+ const Vue3 = vue.version.startsWith("3");
8
+
7
9
  function resolveUnref(r) {
8
10
  return typeof r === "function" ? r() : vue.unref(r);
9
11
  }
@@ -27,13 +29,16 @@ function resolveUnrefHeadInput(ref, lastKey = "") {
27
29
  return root;
28
30
  }
29
31
 
30
- const Vue3 = vue.version.startsWith("3");
31
- const IsBrowser = typeof window !== "undefined";
32
+ const VueReactivityPlugin = shared.defineHeadPlugin({
33
+ hooks: {
34
+ "entries:resolve": function(ctx) {
35
+ for (const entry of ctx.entries)
36
+ entry.resolvedInput = resolveUnrefHeadInput(entry.input);
37
+ }
38
+ }
39
+ });
32
40
 
33
41
  const headSymbol = "usehead";
34
- function injectHead() {
35
- return vue.getCurrentInstance() && vue.inject(headSymbol) || unhead.getActiveHead();
36
- }
37
42
  function vueInstall(head) {
38
43
  const plugin = {
39
44
  install(app) {
@@ -47,43 +52,30 @@ function vueInstall(head) {
47
52
  return plugin.install;
48
53
  }
49
54
  function createServerHead(options = {}) {
50
- const head = unhead.createServerHead({
51
- ...options,
52
- plugins: [
53
- VueReactiveUseHeadPlugin(),
54
- ...options?.plugins || []
55
- ]
56
- });
55
+ const head = unhead.createServerHead(options);
56
+ head.use(VueReactivityPlugin);
57
57
  head.install = vueInstall(head);
58
58
  return head;
59
59
  }
60
60
  function createHead(options = {}) {
61
- const head = unhead.createHead({
62
- ...options,
63
- // arbitrary delay the dom update for batch updates
64
- domDelayFn: (fn) => setTimeout(() => vue.nextTick(() => fn()), 10),
65
- plugins: [
66
- VueReactiveUseHeadPlugin(),
67
- ...options?.plugins || []
68
- ]
69
- });
61
+ options.domDelayFn = options.domDelayFn || ((fn) => vue.nextTick(() => fn()));
62
+ const head = unhead.createHead(options);
63
+ head.use(VueReactivityPlugin);
70
64
  head.install = vueInstall(head);
71
65
  return head;
72
66
  }
73
67
 
74
- function VueReactiveUseHeadPlugin() {
75
- return shared.defineHeadPlugin({
76
- hooks: {
77
- "entries:resolve": function(ctx) {
78
- for (const entry of ctx.entries)
79
- entry.resolvedInput = resolveUnrefHeadInput(entry.input);
80
- }
81
- }
82
- });
68
+ function injectHead() {
69
+ return vue.getCurrentInstance() && vue.inject(headSymbol) || unhead.getActiveHead();
83
70
  }
84
71
 
85
- function clientUseHead(input, options = {}) {
72
+ function useHead(input, options = {}) {
86
73
  const head = injectHead();
74
+ if (!head.ssr)
75
+ return clientUseHead(head, input, options);
76
+ return head.push(input, options);
77
+ }
78
+ function clientUseHead(head, input, options = {}) {
87
79
  const deactivated = vue.ref(false);
88
80
  const resolvedInput = vue.ref({});
89
81
  vue.watchEffect(() => {
@@ -108,26 +100,9 @@ function clientUseHead(input, options = {}) {
108
100
  return entry;
109
101
  }
110
102
 
111
- function serverUseHead(input, options = {}) {
112
- const head = injectHead();
113
- return head.push(input, options);
114
- }
115
-
116
- function useHead(input, options = {}) {
117
- const head = injectHead();
118
- if (head) {
119
- const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
120
- if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
121
- return;
122
- return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
123
- }
124
- }
125
-
126
- exports.VueReactiveUseHeadPlugin = VueReactiveUseHeadPlugin;
127
103
  exports.createHead = createHead;
128
104
  exports.createServerHead = createServerHead;
129
105
  exports.headSymbol = headSymbol;
130
106
  exports.injectHead = injectHead;
131
107
  exports.resolveUnrefHeadInput = resolveUnrefHeadInput;
132
- exports.serverUseHead = serverUseHead;
133
108
  exports.useHead = useHead;
@@ -1,7 +1,9 @@
1
- import { unref, version, getCurrentInstance, inject, nextTick, ref, watchEffect, watch, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
2
- import { getActiveHead, createServerHead as createServerHead$1, createHead as createHead$1 } from 'unhead';
1
+ import { version, unref, nextTick, getCurrentInstance, inject, ref, watchEffect, watch, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
2
+ import { createServerHead as createServerHead$1, createHead as createHead$1, getActiveHead } from 'unhead';
3
3
  import { defineHeadPlugin } from '@unhead/shared';
4
4
 
5
+ const Vue3 = version.startsWith("3");
6
+
5
7
  function resolveUnref(r) {
6
8
  return typeof r === "function" ? r() : unref(r);
7
9
  }
@@ -25,13 +27,16 @@ function resolveUnrefHeadInput(ref, lastKey = "") {
25
27
  return root;
26
28
  }
27
29
 
28
- const Vue3 = version.startsWith("3");
29
- const IsBrowser = typeof window !== "undefined";
30
+ const VueReactivityPlugin = defineHeadPlugin({
31
+ hooks: {
32
+ "entries:resolve": function(ctx) {
33
+ for (const entry of ctx.entries)
34
+ entry.resolvedInput = resolveUnrefHeadInput(entry.input);
35
+ }
36
+ }
37
+ });
30
38
 
31
39
  const headSymbol = "usehead";
32
- function injectHead() {
33
- return getCurrentInstance() && inject(headSymbol) || getActiveHead();
34
- }
35
40
  function vueInstall(head) {
36
41
  const plugin = {
37
42
  install(app) {
@@ -45,43 +50,30 @@ function vueInstall(head) {
45
50
  return plugin.install;
46
51
  }
47
52
  function createServerHead(options = {}) {
48
- const head = createServerHead$1({
49
- ...options,
50
- plugins: [
51
- VueReactiveUseHeadPlugin(),
52
- ...options?.plugins || []
53
- ]
54
- });
53
+ const head = createServerHead$1(options);
54
+ head.use(VueReactivityPlugin);
55
55
  head.install = vueInstall(head);
56
56
  return head;
57
57
  }
58
58
  function createHead(options = {}) {
59
- const head = createHead$1({
60
- ...options,
61
- // arbitrary delay the dom update for batch updates
62
- domDelayFn: (fn) => setTimeout(() => nextTick(() => fn()), 10),
63
- plugins: [
64
- VueReactiveUseHeadPlugin(),
65
- ...options?.plugins || []
66
- ]
67
- });
59
+ options.domDelayFn = options.domDelayFn || ((fn) => nextTick(() => fn()));
60
+ const head = createHead$1(options);
61
+ head.use(VueReactivityPlugin);
68
62
  head.install = vueInstall(head);
69
63
  return head;
70
64
  }
71
65
 
72
- function VueReactiveUseHeadPlugin() {
73
- return defineHeadPlugin({
74
- hooks: {
75
- "entries:resolve": function(ctx) {
76
- for (const entry of ctx.entries)
77
- entry.resolvedInput = resolveUnrefHeadInput(entry.input);
78
- }
79
- }
80
- });
66
+ function injectHead() {
67
+ return getCurrentInstance() && inject(headSymbol) || getActiveHead();
81
68
  }
82
69
 
83
- function clientUseHead(input, options = {}) {
70
+ function useHead(input, options = {}) {
84
71
  const head = injectHead();
72
+ if (!head.ssr)
73
+ return clientUseHead(head, input, options);
74
+ return head.push(input, options);
75
+ }
76
+ function clientUseHead(head, input, options = {}) {
85
77
  const deactivated = ref(false);
86
78
  const resolvedInput = ref({});
87
79
  watchEffect(() => {
@@ -106,19 +98,4 @@ function clientUseHead(input, options = {}) {
106
98
  return entry;
107
99
  }
108
100
 
109
- function serverUseHead(input, options = {}) {
110
- const head = injectHead();
111
- return head.push(input, options);
112
- }
113
-
114
- function useHead(input, options = {}) {
115
- const head = injectHead();
116
- if (head) {
117
- const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
118
- if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
119
- return;
120
- return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
121
- }
122
- }
123
-
124
- export { VueReactiveUseHeadPlugin as V, createHead as a, createServerHead as c, headSymbol as h, injectHead as i, resolveUnrefHeadInput as r, serverUseHead as s, useHead as u };
101
+ export { createServerHead as a, createHead as c, headSymbol as h, injectHead as i, resolveUnrefHeadInput as r, 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.2.2",
4
+ "version": "1.3.0-beta.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.2.2",
42
- "@unhead/shared": "1.2.2",
43
- "unhead": "1.2.2"
41
+ "@unhead/schema": "1.3.0-beta.0",
42
+ "@unhead/shared": "1.3.0-beta.0",
43
+ "unhead": "1.3.0-beta.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "vue": "^3.3.4"