@unhead/vue 1.8.0-beta.1 → 1.8.0-beta.10

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
@@ -59,17 +59,24 @@ function useHeadSafe(input, options = {}) {
59
59
  }
60
60
 
61
61
  function useSeoMeta(input, options) {
62
- const headInput = vue.ref({});
63
- vue.watchEffect(() => {
64
- const resolvedMeta = injectHead.resolveUnrefHeadInput(input);
65
- const { title, titleTemplate, ...meta } = resolvedMeta;
66
- headInput.value = {
67
- title,
68
- titleTemplate,
69
- meta: shared.unpackMeta(meta)
70
- };
62
+ const { title, titleTemplate, ...meta } = input;
63
+ return useHead.useHead({
64
+ title,
65
+ titleTemplate,
66
+ // @ts-expect-error runtime type
67
+ _flatMeta: meta
68
+ }, {
69
+ ...options,
70
+ transform(t) {
71
+ const meta2 = shared.unpackMeta({ ...t._flatMeta });
72
+ delete t._flatMeta;
73
+ return {
74
+ // @ts-expect-error runtime type
75
+ ...t,
76
+ meta: meta2
77
+ };
78
+ }
71
79
  });
72
- return useHead.useHead(headInput, options);
73
80
  }
74
81
 
75
82
  function useServerHead(input, options = {}) {
@@ -96,10 +103,9 @@ function useScript(_input, _options) {
96
103
  const status = vue.ref("awaitingLoad");
97
104
  shared.NetworkEvents.forEach((fn) => {
98
105
  const _fn = typeof input[fn] === "function" ? input[fn].bind(ctx) : null;
99
- input[fn] = (e) => {
100
- status.value = fn === "onload" ? "loaded" : fn === "onerror" ? "error" : "loading";
101
- _fn && _fn(e);
102
- };
106
+ if (_fn) {
107
+ input[fn] = (e) => _fn(e);
108
+ }
103
109
  });
104
110
  options.stub = ({ script, fn }) => {
105
111
  if (fn === "$script") {
@@ -110,7 +116,16 @@ function useScript(_input, _options) {
110
116
  };
111
117
  }
112
118
  };
113
- return unhead.useScript(input, options);
119
+ const instance = unhead.useScript(input, options);
120
+ function syncStatus({ script }) {
121
+ if (script.id === instance.$script.id) {
122
+ status.value = script.status;
123
+ if (script.status === "removed")
124
+ head.hooks.removeHook(`script:updated`, syncStatus);
125
+ }
126
+ }
127
+ head.hooks.hook(`script:updated`, syncStatus);
128
+ return instance;
114
129
  }
115
130
 
116
131
  exports.CapoPlugin = unhead.CapoPlugin;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
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, UseScriptStatus, UseScriptInput, UseScriptOptions } from '@unhead/schema';
3
+ import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, UseScriptInput, UseScriptOptions } from '@unhead/schema';
4
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 UseHeadOptions, c as UseSeoMetaInput } from './shared/vue.8eef6ffc.cjs';
6
- export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, f as Meta, N as Noscript, g as Script, S as Style, T as Title, d as TitleTemplate } from './shared/vue.8eef6ffc.cjs';
5
+ import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as UseSeoMetaInput } from './shared/vue.44f175ba.cjs';
6
+ export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, f as Meta, N as Noscript, g as Script, S as Style, T as Title, d as TitleTemplate } from './shared/vue.44f175ba.cjs';
7
7
  import { Plugin, ComputedRef, Ref } from 'vue';
8
8
 
9
9
  interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
@@ -52,10 +52,9 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
52
52
 
53
53
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
54
54
 
55
- interface VueScriptInstance<T> {
55
+ interface VueScriptInstance<T> extends Omit<ScriptInstance<T>, 'loaded' | 'status'> {
56
56
  loaded: ComputedRef<boolean>;
57
57
  status: Ref<UseScriptStatus>;
58
- waitForUse: () => Promise<T>;
59
58
  }
60
59
  declare function useScript<T>(_input: MaybeComputedRefEntries<UseScriptInput>, _options?: UseScriptOptions<T>): T & {
61
60
  $script: VueScriptInstance<T>;
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
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, UseScriptStatus, UseScriptInput, UseScriptOptions } from '@unhead/schema';
3
+ import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, UseScriptInput, UseScriptOptions } from '@unhead/schema';
4
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 UseHeadOptions, c as UseSeoMetaInput } from './shared/vue.8eef6ffc.mjs';
6
- export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, f as Meta, N as Noscript, g as Script, S as Style, T as Title, d as TitleTemplate } from './shared/vue.8eef6ffc.mjs';
5
+ import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as UseSeoMetaInput } from './shared/vue.44f175ba.mjs';
6
+ export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, f as Meta, N as Noscript, g as Script, S as Style, T as Title, d as TitleTemplate } from './shared/vue.44f175ba.mjs';
7
7
  import { Plugin, ComputedRef, Ref } from 'vue';
8
8
 
9
9
  interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
@@ -52,10 +52,9 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
52
52
 
53
53
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
54
54
 
55
- interface VueScriptInstance<T> {
55
+ interface VueScriptInstance<T> extends Omit<ScriptInstance<T>, 'loaded' | 'status'> {
56
56
  loaded: ComputedRef<boolean>;
57
57
  status: Ref<UseScriptStatus>;
58
- waitForUse: () => Promise<T>;
59
58
  }
60
59
  declare function useScript<T>(_input: MaybeComputedRefEntries<UseScriptInput>, _options?: UseScriptOptions<T>): T & {
61
60
  $script: VueScriptInstance<T>;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
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, UseScriptStatus, UseScriptInput, UseScriptOptions } from '@unhead/schema';
3
+ import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, UseScriptInput, UseScriptOptions } from '@unhead/schema';
4
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 UseHeadOptions, c as UseSeoMetaInput } from './shared/vue.8eef6ffc.js';
6
- export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, f as Meta, N as Noscript, g as Script, S as Style, T as Title, d as TitleTemplate } from './shared/vue.8eef6ffc.js';
5
+ import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as UseSeoMetaInput } from './shared/vue.44f175ba.js';
6
+ export { e as Base, B as BodyAttr, i as BodyAttributes, H as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, f as Meta, N as Noscript, g as Script, S as Style, T as Title, d as TitleTemplate } from './shared/vue.44f175ba.js';
7
7
  import { Plugin, ComputedRef, Ref } from 'vue';
8
8
 
9
9
  interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
@@ -52,10 +52,9 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
52
52
 
53
53
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
54
54
 
55
- interface VueScriptInstance<T> {
55
+ interface VueScriptInstance<T> extends Omit<ScriptInstance<T>, 'loaded' | 'status'> {
56
56
  loaded: ComputedRef<boolean>;
57
57
  status: Ref<UseScriptStatus>;
58
- waitForUse: () => Promise<T>;
59
58
  }
60
59
  declare function useScript<T>(_input: MaybeComputedRefEntries<UseScriptInput>, _options?: UseScriptOptions<T>): T & {
61
60
  $script: VueScriptInstance<T>;
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { useScript as useScript$1 } from 'unhead';
2
2
  export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
3
- import { V as Vue3, h as headSymbol, r as resolveUnrefHeadInput, i as injectHead } from './shared/vue.cf295fb1.mjs';
3
+ import { V as Vue3, h as headSymbol, i as injectHead, r as resolveUnrefHeadInput } from './shared/vue.cf295fb1.mjs';
4
4
  export { c as createHead, a as createServerHead, s as setHeadInjectionHandler } from './shared/vue.cf295fb1.mjs';
5
- import { getCurrentInstance, ref, watchEffect, computed } from 'vue';
5
+ import { getCurrentInstance, ref, computed } from 'vue';
6
6
  import { u as useHead } from './shared/vue.f36acd1f.mjs';
7
7
  import { composableNames, whitelistSafeInput, unpackMeta, NetworkEvents } from '@unhead/shared';
8
8
 
@@ -59,17 +59,24 @@ function useHeadSafe(input, options = {}) {
59
59
  }
60
60
 
61
61
  function useSeoMeta(input, options) {
62
- const headInput = ref({});
63
- watchEffect(() => {
64
- const resolvedMeta = resolveUnrefHeadInput(input);
65
- const { title, titleTemplate, ...meta } = resolvedMeta;
66
- headInput.value = {
67
- title,
68
- titleTemplate,
69
- meta: unpackMeta(meta)
70
- };
62
+ const { title, titleTemplate, ...meta } = input;
63
+ return useHead({
64
+ title,
65
+ titleTemplate,
66
+ // @ts-expect-error runtime type
67
+ _flatMeta: meta
68
+ }, {
69
+ ...options,
70
+ transform(t) {
71
+ const meta2 = unpackMeta({ ...t._flatMeta });
72
+ delete t._flatMeta;
73
+ return {
74
+ // @ts-expect-error runtime type
75
+ ...t,
76
+ meta: meta2
77
+ };
78
+ }
71
79
  });
72
- return useHead(headInput, options);
73
80
  }
74
81
 
75
82
  function useServerHead(input, options = {}) {
@@ -96,10 +103,9 @@ function useScript(_input, _options) {
96
103
  const status = ref("awaitingLoad");
97
104
  NetworkEvents.forEach((fn) => {
98
105
  const _fn = typeof input[fn] === "function" ? input[fn].bind(ctx) : null;
99
- input[fn] = (e) => {
100
- status.value = fn === "onload" ? "loaded" : fn === "onerror" ? "error" : "loading";
101
- _fn && _fn(e);
102
- };
106
+ if (_fn) {
107
+ input[fn] = (e) => _fn(e);
108
+ }
103
109
  });
104
110
  options.stub = ({ script, fn }) => {
105
111
  if (fn === "$script") {
@@ -110,7 +116,16 @@ function useScript(_input, _options) {
110
116
  };
111
117
  }
112
118
  };
113
- return useScript$1(input, options);
119
+ const instance = useScript$1(input, options);
120
+ function syncStatus({ script }) {
121
+ if (script.id === instance.$script.id) {
122
+ status.value = script.status;
123
+ if (script.status === "removed")
124
+ head.hooks.removeHook(`script:updated`, syncStatus);
125
+ }
126
+ }
127
+ head.hooks.hook(`script:updated`, syncStatus);
128
+ return instance;
114
129
  }
115
130
 
116
131
  export { Vue2ProvideUnheadPlugin, VueHeadMixin, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
@@ -1,5 +1,5 @@
1
1
  import { MergeHead } from '@unhead/schema';
2
- import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.8eef6ffc.cjs';
2
+ import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.44f175ba.cjs';
3
3
  import 'vue';
4
4
 
5
5
  type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
@@ -1,5 +1,5 @@
1
1
  import { MergeHead } from '@unhead/schema';
2
- import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.8eef6ffc.mjs';
2
+ import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.44f175ba.mjs';
3
3
  import 'vue';
4
4
 
5
5
  type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
@@ -1,5 +1,5 @@
1
1
  import { MergeHead } from '@unhead/schema';
2
- import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.8eef6ffc.js';
2
+ import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.44f175ba.js';
3
3
  import 'vue';
4
4
 
5
5
  type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
@@ -49,7 +49,9 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
49
49
  /**
50
50
  * Variables used to substitute in the title and meta content.
51
51
  */
52
- templateParams?: MaybeComputedRefEntries<Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
52
+ templateParams?: MaybeComputedRefEntries<{
53
+ separator?: '|' | '-' | '·' | string;
54
+ } & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
53
55
  /**
54
56
  * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
55
57
  * There can be only one <base> element in a document.
@@ -49,7 +49,9 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
49
49
  /**
50
50
  * Variables used to substitute in the title and meta content.
51
51
  */
52
- templateParams?: MaybeComputedRefEntries<Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
52
+ templateParams?: MaybeComputedRefEntries<{
53
+ separator?: '|' | '-' | '·' | string;
54
+ } & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
53
55
  /**
54
56
  * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
55
57
  * There can be only one <base> element in a document.
@@ -49,7 +49,9 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
49
49
  /**
50
50
  * Variables used to substitute in the title and meta content.
51
51
  */
52
- templateParams?: MaybeComputedRefEntries<Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
52
+ templateParams?: MaybeComputedRefEntries<{
53
+ separator?: '|' | '-' | '·' | string;
54
+ } & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
53
55
  /**
54
56
  * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
55
57
  * There can be only one <base> element in a document.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "1.8.0-beta.1",
4
+ "version": "1.8.0-beta.10",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -48,9 +48,9 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "hookable": "^5.5.3",
51
- "@unhead/schema": "1.8.0-beta.1",
52
- "@unhead/shared": "1.8.0-beta.1",
53
- "unhead": "1.8.0-beta.1"
51
+ "@unhead/schema": "1.8.0-beta.10",
52
+ "@unhead/shared": "1.8.0-beta.10",
53
+ "unhead": "1.8.0-beta.10"
54
54
  },
55
55
  "devDependencies": {
56
56
  "vue": "^3.3.4"