@unhead/vue 1.9.16 → 1.10.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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const vue = require('vue');
4
- const injectHead = require('./shared/vue.77729ad4.cjs');
4
+ const injectHead = require('./shared/vue.fe30115b.cjs');
5
5
  require('unhead');
6
6
  require('@unhead/shared');
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, ref, onBeforeUnmount, watchEffect } from 'vue';
2
- import { i as injectHead, V as Vue3 } from './shared/vue.cf295fb1.mjs';
2
+ import { i as injectHead, V as Vue3 } from './shared/vue.40986ab9.mjs';
3
3
  import 'unhead';
4
4
  import '@unhead/shared';
5
5
 
package/dist/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  const unhead = require('unhead');
4
- const injectHead = require('./shared/vue.77729ad4.cjs');
4
+ const injectHead = require('./shared/vue.fe30115b.cjs');
5
5
  const vue = require('vue');
6
- const useHead = require('./shared/vue.af935fad.cjs');
6
+ const useHead = require('./shared/vue.8753d82d.cjs');
7
7
  const shared = require('@unhead/shared');
8
8
 
9
9
  const VueHeadMixin = {
@@ -27,7 +27,7 @@ const VueHeadMixin = {
27
27
  }
28
28
  };
29
29
 
30
- const Vue2ProvideUnheadPlugin = function(_Vue, head) {
30
+ const Vue2ProvideUnheadPlugin = (_Vue, head) => {
31
31
  _Vue.mixin({
32
32
  beforeCreate() {
33
33
  const options = this.$options;
@@ -91,7 +91,7 @@ function useServerHeadSafe(input, options = {}) {
91
91
  }
92
92
 
93
93
  function useServerSeoMeta(input, options) {
94
- return useSeoMeta(input, { ...options || {}, mode: "server" });
94
+ return useSeoMeta(input, { ...options, mode: "server" });
95
95
  }
96
96
 
97
97
  function useScript(_input, _options) {
@@ -100,26 +100,25 @@ function useScript(_input, _options) {
100
100
  const options = _options || {};
101
101
  options.head = head;
102
102
  options.eventContext = vue.getCurrentInstance();
103
- const status = vue.ref("awaitingLoad");
104
- const stubOptions = options.stub;
105
- options.stub = ({ script, fn }) => {
106
- script.status = status;
107
- if (fn === "$script")
108
- return script;
109
- return stubOptions?.({ script, fn });
110
- };
111
- let instance;
112
- const _ = head.hooks.hook("script:updated", ({ script }) => {
113
- if (instance && script.id === instance.$script.id) {
114
- status.value = script.status;
115
- script.status === "removed" && _();
116
- }
117
- });
118
103
  const scope = vue.getCurrentInstance();
119
104
  if (scope && !options.trigger)
120
105
  options.trigger = vue.onMounted;
121
- instance = unhead.useScript(input, options);
122
- return instance;
106
+ const key = unhead.resolveScriptKey(input);
107
+ if (head._scripts?.[key])
108
+ return head._scripts[key];
109
+ let script;
110
+ const status = vue.ref("awaitingLoad");
111
+ const _ = head.hooks.hook("script:updated", ({ script: s }) => {
112
+ if (script && s.id === script.id) {
113
+ status.value = s.status;
114
+ if (s.status === "removed") {
115
+ _();
116
+ }
117
+ }
118
+ });
119
+ script = unhead.useScript(input, options);
120
+ script.status = status;
121
+ return script;
123
122
  }
124
123
 
125
124
  exports.CapoPlugin = unhead.CapoPlugin;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
2
2
  import * as _unhead_schema from '@unhead/schema';
3
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, UseScriptOptions } from '@unhead/schema';
3
+ import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, AsAsyncFunctionValues, UseScriptOptions } from '@unhead/schema';
4
4
  export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
5
5
  import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as UseSeoMetaInput, d as MaybeComputedRefEntriesOnly } from './shared/vue.3d788732.cjs';
6
6
  export { f as Base, B as BodyAttr, j as BodyAttributes, H as HtmlAttr, i as HtmlAttributes, L as Link, l as MaybeComputedRefOrPromise, k as MaybeReadonlyRef, g as Meta, N as Noscript, h as Script, S as Style, T as Title, e as TitleTemplate } from './shared/vue.3d788732.cjs';
@@ -19,7 +19,7 @@ type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
19
19
  declare function createServerHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): VueHeadClient<T>;
20
20
  declare function createHead<T extends MergeHead>(options?: CreateHeadOptions): VueHeadClient<T>;
21
21
 
22
- declare function resolveUnrefHeadInput(ref: any, lastKey?: string | number): any;
22
+ declare function resolveUnrefHeadInput(ref: any): any;
23
23
 
24
24
  declare const VueHeadMixin: {
25
25
  created(): void;
@@ -49,14 +49,18 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
49
49
 
50
50
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
51
51
 
52
- interface VueScriptInstance<T> extends Omit<ScriptInstance<T>, 'status'> {
52
+ interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
53
53
  status: Ref<UseScriptStatus>;
54
54
  }
55
55
  type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
56
56
  src: string;
57
57
  });
58
- declare function useScript<T extends Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): T & {
59
- $script: VueScriptInstance<T> & Promise<T>;
58
+ type UseScriptContext<T extends Record<symbol | string, any>> = (Promise<T> & VueScriptInstance<T>) & AsAsyncFunctionValues<T> & {
59
+ /**
60
+ * @deprecated Use top-level functions instead.
61
+ */
62
+ $script: Promise<T> & VueScriptInstance<T>;
60
63
  };
64
+ declare function useScript<T extends Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<T>;
61
65
 
62
- export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
66
+ export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptContext, type UseScriptInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
2
2
  import * as _unhead_schema from '@unhead/schema';
3
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, UseScriptOptions } from '@unhead/schema';
3
+ import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, AsAsyncFunctionValues, UseScriptOptions } from '@unhead/schema';
4
4
  export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
5
5
  import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as UseSeoMetaInput, d as MaybeComputedRefEntriesOnly } from './shared/vue.3d788732.mjs';
6
6
  export { f as Base, B as BodyAttr, j as BodyAttributes, H as HtmlAttr, i as HtmlAttributes, L as Link, l as MaybeComputedRefOrPromise, k as MaybeReadonlyRef, g as Meta, N as Noscript, h as Script, S as Style, T as Title, e as TitleTemplate } from './shared/vue.3d788732.mjs';
@@ -19,7 +19,7 @@ type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
19
19
  declare function createServerHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): VueHeadClient<T>;
20
20
  declare function createHead<T extends MergeHead>(options?: CreateHeadOptions): VueHeadClient<T>;
21
21
 
22
- declare function resolveUnrefHeadInput(ref: any, lastKey?: string | number): any;
22
+ declare function resolveUnrefHeadInput(ref: any): any;
23
23
 
24
24
  declare const VueHeadMixin: {
25
25
  created(): void;
@@ -49,14 +49,18 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
49
49
 
50
50
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
51
51
 
52
- interface VueScriptInstance<T> extends Omit<ScriptInstance<T>, 'status'> {
52
+ interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
53
53
  status: Ref<UseScriptStatus>;
54
54
  }
55
55
  type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
56
56
  src: string;
57
57
  });
58
- declare function useScript<T extends Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): T & {
59
- $script: VueScriptInstance<T> & Promise<T>;
58
+ type UseScriptContext<T extends Record<symbol | string, any>> = (Promise<T> & VueScriptInstance<T>) & AsAsyncFunctionValues<T> & {
59
+ /**
60
+ * @deprecated Use top-level functions instead.
61
+ */
62
+ $script: Promise<T> & VueScriptInstance<T>;
60
63
  };
64
+ declare function useScript<T extends Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<T>;
61
65
 
62
- export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
66
+ export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptContext, type UseScriptInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
2
2
  import * as _unhead_schema from '@unhead/schema';
3
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, UseScriptOptions } from '@unhead/schema';
3
+ import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, AsAsyncFunctionValues, UseScriptOptions } from '@unhead/schema';
4
4
  export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
5
5
  import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as UseSeoMetaInput, d as MaybeComputedRefEntriesOnly } from './shared/vue.3d788732.js';
6
6
  export { f as Base, B as BodyAttr, j as BodyAttributes, H as HtmlAttr, i as HtmlAttributes, L as Link, l as MaybeComputedRefOrPromise, k as MaybeReadonlyRef, g as Meta, N as Noscript, h as Script, S as Style, T as Title, e as TitleTemplate } from './shared/vue.3d788732.js';
@@ -19,7 +19,7 @@ type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
19
19
  declare function createServerHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): VueHeadClient<T>;
20
20
  declare function createHead<T extends MergeHead>(options?: CreateHeadOptions): VueHeadClient<T>;
21
21
 
22
- declare function resolveUnrefHeadInput(ref: any, lastKey?: string | number): any;
22
+ declare function resolveUnrefHeadInput(ref: any): any;
23
23
 
24
24
  declare const VueHeadMixin: {
25
25
  created(): void;
@@ -49,14 +49,18 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
49
49
 
50
50
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
51
51
 
52
- interface VueScriptInstance<T> extends Omit<ScriptInstance<T>, 'status'> {
52
+ interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
53
53
  status: Ref<UseScriptStatus>;
54
54
  }
55
55
  type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
56
56
  src: string;
57
57
  });
58
- declare function useScript<T extends Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): T & {
59
- $script: VueScriptInstance<T> & Promise<T>;
58
+ type UseScriptContext<T extends Record<symbol | string, any>> = (Promise<T> & VueScriptInstance<T>) & AsAsyncFunctionValues<T> & {
59
+ /**
60
+ * @deprecated Use top-level functions instead.
61
+ */
62
+ $script: Promise<T> & VueScriptInstance<T>;
60
63
  };
64
+ declare function useScript<T extends Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<T>;
61
65
 
62
- export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
66
+ export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptContext, type UseScriptInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { useScript as useScript$1 } from 'unhead';
1
+ import { resolveScriptKey, useScript as useScript$1 } from 'unhead';
2
2
  export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
3
- import { V as Vue3, h as headSymbol, i as injectHead } from './shared/vue.cf295fb1.mjs';
4
- export { c as createHead, a as createServerHead, r as resolveUnrefHeadInput, s as setHeadInjectionHandler } from './shared/vue.cf295fb1.mjs';
5
- import { getCurrentInstance, ref, onMounted } from 'vue';
6
- import { u as useHead } from './shared/vue.f36acd1f.mjs';
3
+ import { V as Vue3, h as headSymbol, i as injectHead } from './shared/vue.40986ab9.mjs';
4
+ export { c as createHead, a as createServerHead, r as resolveUnrefHeadInput, s as setHeadInjectionHandler } from './shared/vue.40986ab9.mjs';
5
+ import { getCurrentInstance, onMounted, ref } from 'vue';
6
+ import { u as useHead } from './shared/vue.65b7bcda.mjs';
7
7
  import { composableNames, whitelistSafeInput, unpackMeta } from '@unhead/shared';
8
8
 
9
9
  const VueHeadMixin = {
@@ -27,7 +27,7 @@ const VueHeadMixin = {
27
27
  }
28
28
  };
29
29
 
30
- const Vue2ProvideUnheadPlugin = function(_Vue, head) {
30
+ const Vue2ProvideUnheadPlugin = (_Vue, head) => {
31
31
  _Vue.mixin({
32
32
  beforeCreate() {
33
33
  const options = this.$options;
@@ -91,7 +91,7 @@ function useServerHeadSafe(input, options = {}) {
91
91
  }
92
92
 
93
93
  function useServerSeoMeta(input, options) {
94
- return useSeoMeta(input, { ...options || {}, mode: "server" });
94
+ return useSeoMeta(input, { ...options, mode: "server" });
95
95
  }
96
96
 
97
97
  function useScript(_input, _options) {
@@ -100,26 +100,25 @@ function useScript(_input, _options) {
100
100
  const options = _options || {};
101
101
  options.head = head;
102
102
  options.eventContext = getCurrentInstance();
103
- const status = ref("awaitingLoad");
104
- const stubOptions = options.stub;
105
- options.stub = ({ script, fn }) => {
106
- script.status = status;
107
- if (fn === "$script")
108
- return script;
109
- return stubOptions?.({ script, fn });
110
- };
111
- let instance;
112
- const _ = head.hooks.hook("script:updated", ({ script }) => {
113
- if (instance && script.id === instance.$script.id) {
114
- status.value = script.status;
115
- script.status === "removed" && _();
116
- }
117
- });
118
103
  const scope = getCurrentInstance();
119
104
  if (scope && !options.trigger)
120
105
  options.trigger = onMounted;
121
- instance = useScript$1(input, options);
122
- return instance;
106
+ const key = resolveScriptKey(input);
107
+ if (head._scripts?.[key])
108
+ return head._scripts[key];
109
+ let script;
110
+ const status = ref("awaitingLoad");
111
+ const _ = head.hooks.hook("script:updated", ({ script: s }) => {
112
+ if (script && s.id === script.id) {
113
+ status.value = s.status;
114
+ if (s.status === "removed") {
115
+ _();
116
+ }
117
+ }
118
+ });
119
+ script = useScript$1(input, options);
120
+ script.status = status;
121
+ return script;
123
122
  }
124
123
 
125
124
  export { Vue2ProvideUnheadPlugin, VueHeadMixin, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/polyfill.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const useHead = require('./shared/vue.af935fad.cjs');
3
+ const useHead = require('./shared/vue.8753d82d.cjs');
4
4
  require('vue');
5
- require('./shared/vue.77729ad4.cjs');
5
+ require('./shared/vue.fe30115b.cjs');
6
6
  require('unhead');
7
7
  require('@unhead/shared');
8
8
 
@@ -13,7 +13,7 @@ function polyfillAsVueUseHead(head) {
13
13
  polyfilled.addHeadObjs = head.push;
14
14
  polyfilled.addReactiveEntry = (input, options) => {
15
15
  const api = useHead.useHead(input, options);
16
- if (typeof api !== "undefined")
16
+ if (api !== void 0)
17
17
  return api.dispose;
18
18
  return () => {
19
19
  };
package/dist/polyfill.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { u as useHead } from './shared/vue.f36acd1f.mjs';
1
+ import { u as useHead } from './shared/vue.65b7bcda.mjs';
2
2
  import 'vue';
3
- import './shared/vue.cf295fb1.mjs';
3
+ import './shared/vue.40986ab9.mjs';
4
4
  import 'unhead';
5
5
  import '@unhead/shared';
6
6
 
@@ -11,7 +11,7 @@ function polyfillAsVueUseHead(head) {
11
11
  polyfilled.addHeadObjs = head.push;
12
12
  polyfilled.addReactiveEntry = (input, options) => {
13
13
  const api = useHead(input, options);
14
- if (typeof api !== "undefined")
14
+ if (api !== void 0)
15
15
  return api.dispose;
16
16
  return () => {
17
17
  };
@@ -2,34 +2,39 @@ import { version, unref, nextTick, inject } from 'vue';
2
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");
5
+ const Vue3 = version[0] === "3";
6
6
 
7
7
  function resolveUnref(r) {
8
8
  return typeof r === "function" ? r() : unref(r);
9
9
  }
10
- function resolveUnrefHeadInput(ref, lastKey = "") {
10
+ function resolveUnrefHeadInput(ref) {
11
11
  if (ref instanceof Promise)
12
12
  return ref;
13
13
  const root = resolveUnref(ref);
14
14
  if (!ref || !root)
15
15
  return root;
16
16
  if (Array.isArray(root))
17
- return root.map((r) => resolveUnrefHeadInput(r, lastKey));
17
+ return root.map((r) => resolveUnrefHeadInput(r));
18
18
  if (typeof root === "object") {
19
- return Object.fromEntries(
20
- Object.entries(root).map(([k, v]) => {
21
- if (k === "titleTemplate" || k.startsWith("on"))
22
- return [k, unref(v)];
23
- return [k, resolveUnrefHeadInput(v, k)];
24
- })
25
- );
19
+ const resolved = {};
20
+ for (const k in root) {
21
+ if (!Object.prototype.hasOwnProperty.call(root, k)) {
22
+ continue;
23
+ }
24
+ if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
25
+ resolved[k] = unref(root[k]);
26
+ continue;
27
+ }
28
+ resolved[k] = resolveUnrefHeadInput(root[k]);
29
+ }
30
+ return resolved;
26
31
  }
27
32
  return root;
28
33
  }
29
34
 
30
35
  const VueReactivityPlugin = defineHeadPlugin({
31
36
  hooks: {
32
- "entries:resolve": function(ctx) {
37
+ "entries:resolve": (ctx) => {
33
38
  for (const entry of ctx.entries)
34
39
  entry.resolvedInput = resolveUnrefHeadInput(entry.input);
35
40
  }
@@ -1,5 +1,5 @@
1
1
  import { ref, watchEffect, watch, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
2
- import { i as injectHead, r as resolveUnrefHeadInput } from './vue.cf295fb1.mjs';
2
+ import { i as injectHead, r as resolveUnrefHeadInput } from './vue.40986ab9.mjs';
3
3
 
4
4
  function useHead(input, options = {}) {
5
5
  const head = options.head || injectHead();
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const vue = require('vue');
4
- const injectHead = require('./vue.77729ad4.cjs');
4
+ const injectHead = require('./vue.fe30115b.cjs');
5
5
 
6
6
  function useHead(input, options = {}) {
7
7
  const head = options.head || injectHead.injectHead();
@@ -4,34 +4,39 @@ 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");
7
+ const Vue3 = vue.version[0] === "3";
8
8
 
9
9
  function resolveUnref(r) {
10
10
  return typeof r === "function" ? r() : vue.unref(r);
11
11
  }
12
- function resolveUnrefHeadInput(ref, lastKey = "") {
12
+ function resolveUnrefHeadInput(ref) {
13
13
  if (ref instanceof Promise)
14
14
  return ref;
15
15
  const root = resolveUnref(ref);
16
16
  if (!ref || !root)
17
17
  return root;
18
18
  if (Array.isArray(root))
19
- return root.map((r) => resolveUnrefHeadInput(r, lastKey));
19
+ return root.map((r) => resolveUnrefHeadInput(r));
20
20
  if (typeof root === "object") {
21
- return Object.fromEntries(
22
- Object.entries(root).map(([k, v]) => {
23
- if (k === "titleTemplate" || k.startsWith("on"))
24
- return [k, vue.unref(v)];
25
- return [k, resolveUnrefHeadInput(v, k)];
26
- })
27
- );
21
+ const resolved = {};
22
+ for (const k in root) {
23
+ if (!Object.prototype.hasOwnProperty.call(root, k)) {
24
+ continue;
25
+ }
26
+ if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
27
+ resolved[k] = vue.unref(root[k]);
28
+ continue;
29
+ }
30
+ resolved[k] = resolveUnrefHeadInput(root[k]);
31
+ }
32
+ return resolved;
28
33
  }
29
34
  return root;
30
35
  }
31
36
 
32
37
  const VueReactivityPlugin = shared.defineHeadPlugin({
33
38
  hooks: {
34
- "entries:resolve": function(ctx) {
39
+ "entries:resolve": (ctx) => {
35
40
  for (const entry of ctx.entries)
36
41
  entry.resolvedInput = resolveUnrefHeadInput(entry.input);
37
42
  }
package/dist/vue2.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const vue = require('vue');
4
- const injectHead = require('./shared/vue.77729ad4.cjs');
5
- const useHead = require('./shared/vue.af935fad.cjs');
4
+ const injectHead = require('./shared/vue.fe30115b.cjs');
5
+ const useHead = require('./shared/vue.8753d82d.cjs');
6
6
  require('unhead');
7
7
  require('@unhead/shared');
8
8
 
9
- const UnheadPlugin = function(_Vue) {
9
+ const UnheadPlugin = (_Vue) => {
10
10
  _Vue.mixin({
11
11
  created() {
12
12
  let source = false;
package/dist/vue2.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { getCurrentInstance } from 'vue';
2
- import { V as Vue3, h as headSymbol } from './shared/vue.cf295fb1.mjs';
3
- import { u as useHead } from './shared/vue.f36acd1f.mjs';
2
+ import { V as Vue3, h as headSymbol } from './shared/vue.40986ab9.mjs';
3
+ import { u as useHead } from './shared/vue.65b7bcda.mjs';
4
4
  import 'unhead';
5
5
  import '@unhead/shared';
6
6
 
7
- const UnheadPlugin = function(_Vue) {
7
+ const UnheadPlugin = (_Vue) => {
8
8
  _Vue.mixin({
9
9
  created() {
10
10
  let source = false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "1.9.16",
4
+ "version": "1.10.0-beta.1",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -59,14 +59,16 @@
59
59
  "peerDependencies": {
60
60
  "vue": ">=2.7 || >=3"
61
61
  },
62
+ "build": {
63
+ "external": [
64
+ "vue"
65
+ ]
66
+ },
62
67
  "dependencies": {
63
68
  "hookable": "^5.5.3",
64
- "@unhead/shared": "1.9.16",
65
- "@unhead/schema": "1.9.16",
66
- "unhead": "1.9.16"
67
- },
68
- "devDependencies": {
69
- "vue": "^3.4.31"
69
+ "@unhead/schema": "1.10.0-beta.1",
70
+ "@unhead/shared": "1.10.0-beta.1",
71
+ "unhead": "1.10.0-beta.1"
70
72
  },
71
73
  "scripts": {
72
74
  "build": "unbuild .",