@unhead/vue 0.6.0 → 0.6.2

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
@@ -43,12 +43,15 @@ function createHead(options = {}) {
43
43
  domDelayFn: (fn) => setTimeout(() => vue.nextTick(() => fn()), 10),
44
44
  plugins
45
45
  });
46
- head.install = (app) => {
47
- if (Vue3) {
48
- app.config.globalProperties.$unhead = head;
49
- app.provide(headSymbol, head);
46
+ const vuePlugin = {
47
+ install(app) {
48
+ if (Vue3) {
49
+ app.config.globalProperties.$unhead = head;
50
+ app.provide(headSymbol, head);
51
+ }
50
52
  }
51
53
  };
54
+ head.install = vuePlugin.install;
52
55
  return head;
53
56
  }
54
57
 
@@ -239,33 +242,27 @@ function changeKeyCasingDeep(input) {
239
242
  function clientUseHead(input, options = {}) {
240
243
  const head = injectHead();
241
244
  const vm = vue.getCurrentInstance();
242
- if (!vm) {
243
- head.push(input, options);
244
- return;
245
- }
245
+ if (!vm)
246
+ return head.push(input, options);
246
247
  const resolvedInput = vue.ref({});
247
248
  vue.watchEffect(() => {
248
249
  resolvedInput.value = resolveUnrefHeadInput(input);
249
250
  });
250
- let entry;
251
- vue.watch(resolvedInput, (e) => {
252
- if (!entry)
253
- entry = head.push(e, options);
254
- else
255
- entry.patch(e);
256
- }, { immediate: true });
251
+ const entry = head.push(resolvedInput.value, options);
252
+ vue.watch(resolvedInput, (e) => entry.patch(e));
257
253
  vue.onBeforeUnmount(() => {
258
- entry?.dispose();
254
+ entry.dispose();
259
255
  });
256
+ return entry;
260
257
  }
261
258
 
262
259
  function serverUseHead(input, options = {}) {
263
260
  const head = injectHead();
264
- head.push(input, options);
261
+ return head.push(input, options);
265
262
  }
266
263
 
267
264
  function useServerHead(input, options = {}) {
268
- useHead(input, { ...options, mode: "server" });
265
+ return useHead(input, { ...options, mode: "server" });
269
266
  }
270
267
  const useServerTagTitle = (title) => useServerHead({ title });
271
268
  const useServerTitleTemplate = (titleTemplate) => useServerHead({ titleTemplate });
@@ -290,7 +287,7 @@ function useHead(input, options = {}) {
290
287
  const isBrowser = IsBrowser || head.resolvedOptions?.document;
291
288
  if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
292
289
  return;
293
- IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
290
+ return IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
294
291
  }
295
292
  const useTagTitle = (title) => useHead({ title });
296
293
  const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { MaybeComputedRef, MaybeRef } from '@vueuse/shared';
2
2
  export { MaybeComputedRef } from '@vueuse/shared';
3
3
  import * as _unhead_schema from '@unhead/schema';
4
- import { 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, MergeHead, BaseHtmlAttr, MaybeArray, BaseBodyAttr, Unhead, CreateHeadOptions, HeadEntryOptions, MetaFlatInput } from '@unhead/schema';
4
+ import { 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, MergeHead, BaseHtmlAttr, MaybeArray, BaseBodyAttr, Unhead, CreateHeadOptions, HeadEntryOptions, MetaFlatInput, ActiveHeadEntry } from '@unhead/schema';
5
5
  export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
6
6
  import { Plugin } from 'vue';
7
7
  export * from '@unhead/dom';
@@ -121,31 +121,31 @@ declare const VueReactiveUseHeadPlugin: () => _unhead_schema.HeadPlugin;
121
121
 
122
122
  declare const Vue2ProvideUnheadPlugin: Plugin;
123
123
 
124
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void;
125
- declare const useServerTagTitle: (title: ReactiveHead['title']) => void;
126
- declare const useServerTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void;
127
- declare const useServerTagMeta: (meta: Arrayable<Meta>) => void;
128
- declare const useServerTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void;
129
- declare const useServerTagLink: (link: Arrayable<Link>) => void;
130
- declare const useServerTagScript: (script: Arrayable<Script>) => void;
131
- declare const useServerTagStyle: (style: Arrayable<Style>) => void;
132
- declare const useServerTagNoscript: (noscript: Arrayable<Noscript>) => void;
133
- declare const useServerTagBase: (base: ReactiveHead['base']) => void;
134
- declare const useServerHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void;
135
- declare const useServerBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void;
124
+ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadInput<T>>;
125
+ declare const useServerTagTitle: (title: ReactiveHead['title']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
126
+ declare const useServerTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
127
+ declare const useServerTagMeta: (meta: Arrayable<Meta>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
128
+ declare const useServerTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
129
+ declare const useServerTagLink: (link: Arrayable<Link>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
130
+ declare const useServerTagScript: (script: Arrayable<Script>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
131
+ declare const useServerTagStyle: (style: Arrayable<Style>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
132
+ declare const useServerTagNoscript: (noscript: Arrayable<Noscript>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
133
+ declare const useServerTagBase: (base: ReactiveHead['base']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
134
+ declare const useServerHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
135
+ declare const useServerBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
136
136
 
137
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void;
138
- declare const useTagTitle: (title: ReactiveHead['title']) => void;
139
- declare const useTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void;
140
- declare const useTagMeta: (meta: Arrayable<Meta>) => void;
141
- declare const useTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void;
142
- declare const useTagLink: (link: Arrayable<Link>) => void;
143
- declare const useTagScript: (script: Arrayable<Script>) => void;
144
- declare const useTagStyle: (style: Arrayable<Style>) => void;
145
- declare const useTagNoscript: (noscript: Arrayable<Noscript>) => void;
146
- declare const useTagBase: (base: ReactiveHead['base']) => void;
147
- declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void;
148
- declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void;
137
+ declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
138
+ declare const useTagTitle: (title: ReactiveHead['title']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
139
+ declare const useTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
140
+ declare const useTagMeta: (meta: Arrayable<Meta>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
141
+ declare const useTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
142
+ declare const useTagLink: (link: Arrayable<Link>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
143
+ declare const useTagScript: (script: Arrayable<Script>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
144
+ declare const useTagStyle: (style: Arrayable<Style>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
145
+ declare const useTagNoscript: (noscript: Arrayable<Noscript>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
146
+ declare const useTagBase: (base: ReactiveHead['base']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
147
+ declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
148
+ declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
149
149
 
150
150
  declare const unheadVueComposablesImports: {
151
151
  from: string;
package/dist/index.mjs CHANGED
@@ -41,12 +41,15 @@ function createHead(options = {}) {
41
41
  domDelayFn: (fn) => setTimeout(() => nextTick(() => fn()), 10),
42
42
  plugins
43
43
  });
44
- head.install = (app) => {
45
- if (Vue3) {
46
- app.config.globalProperties.$unhead = head;
47
- app.provide(headSymbol, head);
44
+ const vuePlugin = {
45
+ install(app) {
46
+ if (Vue3) {
47
+ app.config.globalProperties.$unhead = head;
48
+ app.provide(headSymbol, head);
49
+ }
48
50
  }
49
51
  };
52
+ head.install = vuePlugin.install;
50
53
  return head;
51
54
  }
52
55
 
@@ -237,33 +240,27 @@ function changeKeyCasingDeep(input) {
237
240
  function clientUseHead(input, options = {}) {
238
241
  const head = injectHead();
239
242
  const vm = getCurrentInstance();
240
- if (!vm) {
241
- head.push(input, options);
242
- return;
243
- }
243
+ if (!vm)
244
+ return head.push(input, options);
244
245
  const resolvedInput = ref({});
245
246
  watchEffect(() => {
246
247
  resolvedInput.value = resolveUnrefHeadInput(input);
247
248
  });
248
- let entry;
249
- watch(resolvedInput, (e) => {
250
- if (!entry)
251
- entry = head.push(e, options);
252
- else
253
- entry.patch(e);
254
- }, { immediate: true });
249
+ const entry = head.push(resolvedInput.value, options);
250
+ watch(resolvedInput, (e) => entry.patch(e));
255
251
  onBeforeUnmount(() => {
256
- entry?.dispose();
252
+ entry.dispose();
257
253
  });
254
+ return entry;
258
255
  }
259
256
 
260
257
  function serverUseHead(input, options = {}) {
261
258
  const head = injectHead();
262
- head.push(input, options);
259
+ return head.push(input, options);
263
260
  }
264
261
 
265
262
  function useServerHead(input, options = {}) {
266
- useHead(input, { ...options, mode: "server" });
263
+ return useHead(input, { ...options, mode: "server" });
267
264
  }
268
265
  const useServerTagTitle = (title) => useServerHead({ title });
269
266
  const useServerTitleTemplate = (titleTemplate) => useServerHead({ titleTemplate });
@@ -288,7 +285,7 @@ function useHead(input, options = {}) {
288
285
  const isBrowser = IsBrowser || head.resolvedOptions?.document;
289
286
  if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
290
287
  return;
291
- IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
288
+ return IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
292
289
  }
293
290
  const useTagTitle = (title) => useHead({ title });
294
291
  const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "packageManager": "pnpm@7.14.0",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -33,13 +33,13 @@
33
33
  "vue": ">=2.7 || >=3"
34
34
  },
35
35
  "dependencies": {
36
- "@unhead/dom": "0.6.0",
37
- "@unhead/schema": "0.6.0",
36
+ "@unhead/dom": "0.6.2",
37
+ "@unhead/schema": "0.6.2",
38
38
  "@vueuse/shared": "latest",
39
- "unhead": "0.6.0"
39
+ "unhead": "0.6.2"
40
40
  },
41
41
  "devDependencies": {
42
- "vue": "^3.2.42"
42
+ "vue": "^3.2.45"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "unbuild .",