@unhead/vue 1.2.2 → 1.3.0-beta.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.
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,9 +1,9 @@
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
+ export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
4
2
  import * as _unhead_schema from '@unhead/schema';
5
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, HeadEntryOptions, ActiveHeadEntry, MetaFlatInput } from '@unhead/schema';
3
+ import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, HeadEntryOptions, ActiveHeadEntry } from '@unhead/schema';
6
4
  export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
5
+ import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseSeoMetaInput } from './schema-84920ead.js';
6
+ export { d as Base, B as BodyAttr, h as BodyAttributes, H as HtmlAttr, g as HtmlAttributes, L as Link, j as MaybeComputedRefOrPromise, i as MaybeReadonlyRef, e as Meta, N as Noscript, f as Script, S as Style, T as Title, c as TitleTemplate } from './schema-84920ead.js';
7
7
  import { Plugin } from 'vue';
8
8
 
9
9
  interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
@@ -16,123 +16,31 @@ interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templ
16
16
  }
17
17
  type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
18
18
 
19
- declare function resolveUnrefHeadInput(ref: any, lastKey?: string | number): any;
19
+ declare function createServerHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): VueHeadClient<T>;
20
+ declare function createHead<T extends MergeHead>(options?: CreateHeadOptions): VueHeadClient<T>;
20
21
 
21
22
  declare const VueHeadMixin: {
22
23
  created(): void;
23
24
  };
24
25
 
25
- declare function VueReactiveUseHeadPlugin(): _unhead_schema.HeadPlugin;
26
-
27
26
  declare const Vue2ProvideUnheadPlugin: Plugin;
28
27
 
28
+ declare const unheadVueComposablesImports: {
29
+ '@unhead/vue': string[];
30
+ };
31
+
32
+ declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
33
+
29
34
  declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
30
35
 
31
36
  declare function useHeadSafe(input: UseHeadSafeInput, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
32
37
 
33
- type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
34
- title?: ReactiveHead['title'];
35
- titleTemplate?: ReactiveHead['titleTemplate'];
36
- };
37
38
  declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
38
39
 
39
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): _unhead_schema.ActiveHeadEntry<UseHeadInput<T>>;
40
+ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): _unhead_schema.ActiveHeadEntry<MaybeComputedRef<ReactiveHead<MergeHead>>>;
40
41
 
41
42
  declare function useServerHeadSafe(input: UseHeadSafeInput, options?: HeadEntryOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadSafeInput>;
42
43
 
43
44
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
44
45
 
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
- };
137
-
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 };
46
+ export { HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, createHead, createServerHead, injectHead, 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-84920ead.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, MetaFlatInput, 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,10 @@ 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
-
108
+ type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
109
+ title?: ReactiveHead['title'];
110
+ titleTemplate?: ReactiveHead['titleTemplate'];
111
+ };
110
112
  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
113
 
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 };
114
+ 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, UseSeoMetaInput as b, TitleTemplate as c, Base as d, Meta as e, Script as f, HtmlAttributes as g, BodyAttributes as h, MaybeReadonlyRef as i, MaybeComputedRefOrPromise as j };
@@ -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.1",
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.1",
42
+ "@unhead/shared": "1.3.0-beta.1",
43
+ "unhead": "1.3.0-beta.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "vue": "^3.3.4"