@unhead/vue 2.1.2 → 2.1.3

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/client.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createHead as createHead$1, createDebouncedFn, renderDOMHead } from 'unhead/client';
2
2
  export { renderDOMHead } from 'unhead/client';
3
- import { v as vueInstall } from './shared/vue.Bm-NbY4b.mjs';
4
- export { V as VueHeadMixin } from './shared/vue.BVUAdATk.mjs';
3
+ import { v as vueInstall } from './shared/vue.Cr7xSEtD.mjs';
4
+ export { V as VueHeadMixin } from './shared/vue.BM998iwd.mjs';
5
5
  import 'unhead/plugins';
6
6
  import 'unhead/utils';
7
7
  import 'vue';
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, ref, onBeforeUnmount, watchEffect } from 'vue';
2
- import { u as useHead } from './shared/vue.Bm-NbY4b.mjs';
2
+ import { u as useHead } from './shared/vue.Cr7xSEtD.mjs';
3
3
  import 'unhead/plugins';
4
4
  import 'unhead/utils';
5
5
  import './shared/vue.N9zWjxoK.mjs';
package/dist/index.d.mts CHANGED
@@ -6,11 +6,11 @@ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeo
6
6
  export { B as BodyAttr, D as DeepResolvableProperties, H as HtmlAttr, M as MaybeFalsy, l as ReactiveHead, n as ResolvableArray, d as ResolvableBase, k as ResolvableBodyAttributes, j as ResolvableHtmlAttributes, e as ResolvableLink, f as ResolvableMeta, i as ResolvableNoscript, o as ResolvableProperties, h as ResolvableScript, g as ResolvableStyle, R as ResolvableTitle, c as ResolvableTitleTemplate, p as ResolvableUnion, m as ResolvableValue } from './shared/vue.DoxLTFJk.mjs';
7
7
  import { U as UseHeadSafeInput } from './shared/vue.DMlT7xkj.mjs';
8
8
  export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle } from './shared/vue.DMlT7xkj.mjs';
9
+ export { AsVoidFunctions, EventHandlerOptions, RecordingEntry, ScriptInstance, UseFunctionType, UseScriptResolvedInput, UseScriptStatus, WarmupStrategy, createSpyProxy, resolveScriptKey } from 'unhead/scripts';
10
+ export { UseScriptContext, UseScriptInput, UseScriptOptions, UseScriptReturn, VueScriptInstance, useScript } from './scripts.mjs';
9
11
  export { Base, BodyAttributes, HtmlAttributes, Link, Meta, Noscript, Script, Style } from './types.mjs';
10
12
  export { resolveUnrefHeadInput } from './utils.mjs';
11
13
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
12
- export { UseScriptContext, UseScriptInput, UseScriptOptions, UseScriptReturn, VueScriptInstance, useScript } from './scripts.mjs';
13
- export { AsVoidFunctions, EventHandlerOptions, RecordingEntry, ScriptInstance, UseFunctionType, UseScriptResolvedInput, UseScriptStatus, WarmupStrategy, createSpyProxy, resolveScriptKey } from 'unhead/scripts';
14
14
  import 'vue';
15
15
  import 'unhead/utils';
16
16
 
package/dist/index.d.ts CHANGED
@@ -6,11 +6,11 @@ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeo
6
6
  export { B as BodyAttr, D as DeepResolvableProperties, H as HtmlAttr, M as MaybeFalsy, l as ReactiveHead, n as ResolvableArray, d as ResolvableBase, k as ResolvableBodyAttributes, j as ResolvableHtmlAttributes, e as ResolvableLink, f as ResolvableMeta, i as ResolvableNoscript, o as ResolvableProperties, h as ResolvableScript, g as ResolvableStyle, R as ResolvableTitle, c as ResolvableTitleTemplate, p as ResolvableUnion, m as ResolvableValue } from './shared/vue.DoxLTFJk.js';
7
7
  import { U as UseHeadSafeInput } from './shared/vue.CzjZUNjB.js';
8
8
  export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle } from './shared/vue.CzjZUNjB.js';
9
+ export { AsVoidFunctions, EventHandlerOptions, RecordingEntry, ScriptInstance, UseFunctionType, UseScriptResolvedInput, UseScriptStatus, WarmupStrategy, createSpyProxy, resolveScriptKey } from 'unhead/scripts';
10
+ export { UseScriptContext, UseScriptInput, UseScriptOptions, UseScriptReturn, VueScriptInstance, useScript } from './scripts.js';
9
11
  export { Base, BodyAttributes, HtmlAttributes, Link, Meta, Noscript, Script, Style } from './types.js';
10
12
  export { resolveUnrefHeadInput } from './utils.js';
11
13
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
12
- export { UseScriptContext, UseScriptInput, UseScriptOptions, UseScriptReturn, VueScriptInstance, useScript } from './scripts.js';
13
- export { AsVoidFunctions, EventHandlerOptions, RecordingEntry, ScriptInstance, UseFunctionType, UseScriptResolvedInput, UseScriptStatus, WarmupStrategy, createSpyProxy, resolveScriptKey } from 'unhead/scripts';
14
14
  import 'vue';
15
15
  import 'unhead/utils';
16
16
 
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { createUnhead } from 'unhead';
2
2
  export { createUnhead } from 'unhead';
3
- export { h as headSymbol, i as injectHead, u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/vue.Bm-NbY4b.mjs';
3
+ export { h as headSymbol, i as injectHead, u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/vue.Cr7xSEtD.mjs';
4
4
  export { resolveUnrefHeadInput } from './utils.mjs';
5
- export { V as VueHeadMixin } from './shared/vue.BVUAdATk.mjs';
6
- export { u as useScript } from './shared/vue.CeCEzk2b.mjs';
5
+ export { V as VueHeadMixin } from './shared/vue.BM998iwd.mjs';
6
+ export { u as useScript } from './shared/vue.eRs8ydhm.mjs';
7
7
  import 'unhead/plugins';
8
8
  import 'unhead/utils';
9
9
  import 'vue';
package/dist/legacy.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import { createUnhead } from 'unhead';
2
2
  import { inject, ref, watchEffect, unref, watch, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
3
3
  import { createHead as createHead$1 } from './client.mjs';
4
- import { h as headSymbol } from './shared/vue.Bm-NbY4b.mjs';
4
+ import { h as headSymbol } from './shared/vue.Cr7xSEtD.mjs';
5
5
  import { V as VueResolver } from './shared/vue.N9zWjxoK.mjs';
6
6
  import { createHead as createHead$2 } from './server.mjs';
7
7
  import { walkResolver } from 'unhead/utils';
8
8
  import { defineHeadPlugin, DeprecationsPlugin, PromisesPlugin, TemplateParamsPlugin, AliasSortingPlugin, SafeInputPlugin, FlatMetaPlugin } from 'unhead/plugins';
9
9
  import 'unhead/client';
10
- import './shared/vue.BVUAdATk.mjs';
10
+ import './shared/vue.BM998iwd.mjs';
11
11
  import 'unhead/server';
12
12
 
13
13
  const createHeadCore = createUnhead;
@@ -18,9 +18,10 @@ interface UseScriptOptions<T extends Record<symbol | string, any> = Record<strin
18
18
  * - `Promise` - Load the script when the promise resolves, exists only on the client.
19
19
  * - `Function` - Register a callback function to load the script, exists only on the client.
20
20
  * - `server` - Have the script injected on the server.
21
- * - `ref` - Load the script when the ref is true.
21
+ * - `Ref<boolean>` - Load the script when the ref becomes true.
22
+ * - `() => boolean` - Getter function, load the script when return value becomes true.
22
23
  */
23
- trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
24
+ trigger?: UseScriptOptions$1['trigger'] | Ref<boolean> | (() => boolean);
24
25
  /**
25
26
  * Unhead instance.
26
27
  */
package/dist/scripts.d.ts CHANGED
@@ -18,9 +18,10 @@ interface UseScriptOptions<T extends Record<symbol | string, any> = Record<strin
18
18
  * - `Promise` - Load the script when the promise resolves, exists only on the client.
19
19
  * - `Function` - Register a callback function to load the script, exists only on the client.
20
20
  * - `server` - Have the script injected on the server.
21
- * - `ref` - Load the script when the ref is true.
21
+ * - `Ref<boolean>` - Load the script when the ref becomes true.
22
+ * - `() => boolean` - Getter function, load the script when return value becomes true.
22
23
  */
23
- trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
24
+ trigger?: UseScriptOptions$1['trigger'] | Ref<boolean> | (() => boolean);
24
25
  /**
25
26
  * Unhead instance.
26
27
  */
package/dist/scripts.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createSpyProxy, resolveScriptKey } from 'unhead/scripts';
2
- export { u as useScript } from './shared/vue.CeCEzk2b.mjs';
2
+ export { u as useScript } from './shared/vue.eRs8ydhm.mjs';
3
3
  import 'vue';
4
- import './shared/vue.Bm-NbY4b.mjs';
4
+ import './shared/vue.Cr7xSEtD.mjs';
5
5
  import 'unhead/plugins';
6
6
  import 'unhead/utils';
7
7
  import './shared/vue.N9zWjxoK.mjs';
package/dist/server.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createHead as createHead$1 } from 'unhead/server';
2
2
  export { extractUnheadInputFromHtml, propsToString, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
3
- import { v as vueInstall } from './shared/vue.Bm-NbY4b.mjs';
3
+ import { v as vueInstall } from './shared/vue.Cr7xSEtD.mjs';
4
4
  import { V as VueResolver } from './shared/vue.N9zWjxoK.mjs';
5
- export { V as VueHeadMixin } from './shared/vue.BVUAdATk.mjs';
5
+ export { V as VueHeadMixin } from './shared/vue.BM998iwd.mjs';
6
6
  import 'unhead/plugins';
7
7
  import 'unhead/utils';
8
8
  import 'vue';
@@ -1,5 +1,5 @@
1
1
  import { getCurrentInstance } from 'vue';
2
- import { u as useHead } from './vue.Bm-NbY4b.mjs';
2
+ import { u as useHead } from './vue.Cr7xSEtD.mjs';
3
3
 
4
4
  const VueHeadMixin = {
5
5
  created() {
@@ -20,10 +20,9 @@ function vueInstall(head) {
20
20
  function injectHead() {
21
21
  if (hasInjectionContext()) {
22
22
  const instance = inject(headSymbol);
23
- if (!instance) {
24
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
23
+ if (instance) {
24
+ return instance;
25
25
  }
26
- return instance;
27
26
  }
28
27
  throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
29
28
  }
@@ -1,6 +1,6 @@
1
1
  import { useScript as useScript$1 } from 'unhead/scripts';
2
2
  import { getCurrentInstance, onMounted, isRef, watch, onScopeDispose, ref } from 'vue';
3
- import { i as injectHead } from './vue.Bm-NbY4b.mjs';
3
+ import { i as injectHead } from './vue.Cr7xSEtD.mjs';
4
4
 
5
5
  function registerVueScopeHandlers(script, scope) {
6
6
  if (!scope) {
@@ -37,11 +37,11 @@ function useScript(_input, _options) {
37
37
  options.eventContext = scope;
38
38
  if (scope && typeof options.trigger === "undefined") {
39
39
  options.trigger = onMounted;
40
- } else if (isRef(options.trigger)) {
41
- const refTrigger = options.trigger;
40
+ } else if (isRef(options.trigger) || typeof options.trigger === "function" && options.trigger.length === 0) {
41
+ const trigger = options.trigger;
42
42
  let off;
43
43
  options.trigger = new Promise((resolve) => {
44
- off = watch(refTrigger, (val) => {
44
+ off = watch(trigger, (val) => {
45
45
  if (val) {
46
46
  resolve(true);
47
47
  }
@@ -55,7 +55,9 @@ function useScript(_input, _options) {
55
55
  });
56
56
  }
57
57
  head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
58
- s._statusRef.value = s.status;
58
+ if (s._statusRef) {
59
+ s._statusRef.value = s.status;
60
+ }
59
61
  });
60
62
  const script = useScript$1(head, input, options);
61
63
  script._statusRef = script._statusRef || ref(script.status);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "2.1.2",
4
+ "version": "2.1.3",
5
5
  "description": "Full-stack <head> manager built for Vue.",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -103,7 +103,7 @@
103
103
  },
104
104
  "dependencies": {
105
105
  "hookable": "^6.0.1",
106
- "unhead": "2.1.2"
106
+ "unhead": "2.1.3"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@vue/server-renderer": "^3.5.26",