@unhead/vue 1.11.3 → 1.11.4
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 +18 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.mts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.mjs +19 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -50,8 +50,25 @@ function useScript(_input, _options) {
|
|
|
50
50
|
options.head = head;
|
|
51
51
|
const scope = vue.getCurrentInstance();
|
|
52
52
|
options.eventContext = scope;
|
|
53
|
-
if (scope && typeof options.trigger === "undefined")
|
|
53
|
+
if (scope && typeof options.trigger === "undefined") {
|
|
54
54
|
options.trigger = vue.onMounted;
|
|
55
|
+
} else if (vue.isRef(options.trigger)) {
|
|
56
|
+
const refTrigger = options.trigger;
|
|
57
|
+
options.trigger = new Promise((resolve) => {
|
|
58
|
+
const off = vue.watch(refTrigger, (val) => {
|
|
59
|
+
if (val) {
|
|
60
|
+
off();
|
|
61
|
+
resolve(true);
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
immediate: true
|
|
65
|
+
});
|
|
66
|
+
vue.onScopeDispose(() => {
|
|
67
|
+
off();
|
|
68
|
+
resolve(false);
|
|
69
|
+
}, true);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
55
72
|
head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
|
|
56
73
|
s._statusRef.value = s.status;
|
|
57
74
|
});
|
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,
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, UseScriptOptions as UseScriptOptions$1, AsAsyncFunctionValues, UseFunctionType } 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 MaybeComputedRefEntriesOnly, d as UseSeoMetaInput } from './shared/vue.71760da0.cjs';
|
|
6
6
|
export { f as Base, B as BodyAttr, j as BodyAttributes, H as HtmlAttr, i as HtmlAttributes, L as Link, l as MaybeComputedRefOrFalsy, m 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.71760da0.cjs';
|
|
@@ -38,6 +38,18 @@ interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit
|
|
|
38
38
|
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
39
39
|
src: string;
|
|
40
40
|
});
|
|
41
|
+
interface UseScriptOptions<T extends Record<symbol | string, any> = {}, U = {}> extends HeadEntryOptions, Pick<UseScriptOptions$1<T, U>, 'use' | 'stub' | 'eventContext' | 'beforeInit'> {
|
|
42
|
+
/**
|
|
43
|
+
* The trigger to load the script:
|
|
44
|
+
* - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
|
|
45
|
+
* - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
|
|
46
|
+
* - `Promise` - Load the script when the promise resolves, exists only on the client.
|
|
47
|
+
* - `Function` - Register a callback function to load the script, exists only on the client.
|
|
48
|
+
* - `server` - Have the script injected on the server.
|
|
49
|
+
* - `ref` - Load the script when the ref is true.
|
|
50
|
+
*/
|
|
51
|
+
trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
|
|
52
|
+
}
|
|
41
53
|
type UseScriptContext<T extends Record<symbol | string, any>> = (Promise<T> & VueScriptInstance<T>) & AsAsyncFunctionValues<T> & {
|
|
42
54
|
/**
|
|
43
55
|
* @deprecated Use top-level functions instead.
|
|
@@ -63,4 +75,4 @@ declare const VueHeadMixin: {
|
|
|
63
75
|
created(): void;
|
|
64
76
|
};
|
|
65
77
|
|
|
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 };
|
|
78
|
+
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, 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,
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, UseScriptOptions as UseScriptOptions$1, AsAsyncFunctionValues, UseFunctionType } 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 MaybeComputedRefEntriesOnly, d as UseSeoMetaInput } from './shared/vue.71760da0.mjs';
|
|
6
6
|
export { f as Base, B as BodyAttr, j as BodyAttributes, H as HtmlAttr, i as HtmlAttributes, L as Link, l as MaybeComputedRefOrFalsy, m 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.71760da0.mjs';
|
|
@@ -38,6 +38,18 @@ interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit
|
|
|
38
38
|
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
39
39
|
src: string;
|
|
40
40
|
});
|
|
41
|
+
interface UseScriptOptions<T extends Record<symbol | string, any> = {}, U = {}> extends HeadEntryOptions, Pick<UseScriptOptions$1<T, U>, 'use' | 'stub' | 'eventContext' | 'beforeInit'> {
|
|
42
|
+
/**
|
|
43
|
+
* The trigger to load the script:
|
|
44
|
+
* - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
|
|
45
|
+
* - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
|
|
46
|
+
* - `Promise` - Load the script when the promise resolves, exists only on the client.
|
|
47
|
+
* - `Function` - Register a callback function to load the script, exists only on the client.
|
|
48
|
+
* - `server` - Have the script injected on the server.
|
|
49
|
+
* - `ref` - Load the script when the ref is true.
|
|
50
|
+
*/
|
|
51
|
+
trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
|
|
52
|
+
}
|
|
41
53
|
type UseScriptContext<T extends Record<symbol | string, any>> = (Promise<T> & VueScriptInstance<T>) & AsAsyncFunctionValues<T> & {
|
|
42
54
|
/**
|
|
43
55
|
* @deprecated Use top-level functions instead.
|
|
@@ -63,4 +75,4 @@ declare const VueHeadMixin: {
|
|
|
63
75
|
created(): void;
|
|
64
76
|
};
|
|
65
77
|
|
|
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 };
|
|
78
|
+
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, 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,
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, UseScriptOptions as UseScriptOptions$1, AsAsyncFunctionValues, UseFunctionType } 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 MaybeComputedRefEntriesOnly, d as UseSeoMetaInput } from './shared/vue.71760da0.js';
|
|
6
6
|
export { f as Base, B as BodyAttr, j as BodyAttributes, H as HtmlAttr, i as HtmlAttributes, L as Link, l as MaybeComputedRefOrFalsy, m 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.71760da0.js';
|
|
@@ -38,6 +38,18 @@ interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit
|
|
|
38
38
|
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
39
39
|
src: string;
|
|
40
40
|
});
|
|
41
|
+
interface UseScriptOptions<T extends Record<symbol | string, any> = {}, U = {}> extends HeadEntryOptions, Pick<UseScriptOptions$1<T, U>, 'use' | 'stub' | 'eventContext' | 'beforeInit'> {
|
|
42
|
+
/**
|
|
43
|
+
* The trigger to load the script:
|
|
44
|
+
* - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
|
|
45
|
+
* - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
|
|
46
|
+
* - `Promise` - Load the script when the promise resolves, exists only on the client.
|
|
47
|
+
* - `Function` - Register a callback function to load the script, exists only on the client.
|
|
48
|
+
* - `server` - Have the script injected on the server.
|
|
49
|
+
* - `ref` - Load the script when the ref is true.
|
|
50
|
+
*/
|
|
51
|
+
trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
|
|
52
|
+
}
|
|
41
53
|
type UseScriptContext<T extends Record<symbol | string, any>> = (Promise<T> & VueScriptInstance<T>) & AsAsyncFunctionValues<T> & {
|
|
42
54
|
/**
|
|
43
55
|
* @deprecated Use top-level functions instead.
|
|
@@ -63,4 +75,4 @@ declare const VueHeadMixin: {
|
|
|
63
75
|
created(): void;
|
|
64
76
|
};
|
|
65
77
|
|
|
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 };
|
|
78
|
+
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { i as injectHead, h as headSymbol, V as Vue3 } from './shared/vue.f49591
|
|
|
4
4
|
export { c as createHead, a as createServerHead, r as resolveUnrefHeadInput, s as setHeadInjectionHandler } from './shared/vue.f49591ad.mjs';
|
|
5
5
|
import { composableNames, whitelistSafeInput, unpackMeta } from '@unhead/shared';
|
|
6
6
|
import { u as useHead } from './shared/vue.8fc199ce.mjs';
|
|
7
|
-
import { getCurrentInstance, onMounted,
|
|
7
|
+
import { getCurrentInstance, onMounted, isRef, watch, onScopeDispose, ref } from 'vue';
|
|
8
8
|
|
|
9
9
|
const coreComposableNames = [
|
|
10
10
|
"injectHead"
|
|
@@ -50,8 +50,25 @@ function useScript(_input, _options) {
|
|
|
50
50
|
options.head = head;
|
|
51
51
|
const scope = getCurrentInstance();
|
|
52
52
|
options.eventContext = scope;
|
|
53
|
-
if (scope && typeof options.trigger === "undefined")
|
|
53
|
+
if (scope && typeof options.trigger === "undefined") {
|
|
54
54
|
options.trigger = onMounted;
|
|
55
|
+
} else if (isRef(options.trigger)) {
|
|
56
|
+
const refTrigger = options.trigger;
|
|
57
|
+
options.trigger = new Promise((resolve) => {
|
|
58
|
+
const off = watch(refTrigger, (val) => {
|
|
59
|
+
if (val) {
|
|
60
|
+
off();
|
|
61
|
+
resolve(true);
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
immediate: true
|
|
65
|
+
});
|
|
66
|
+
onScopeDispose(() => {
|
|
67
|
+
off();
|
|
68
|
+
resolve(false);
|
|
69
|
+
}, true);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
55
72
|
head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
|
|
56
73
|
s._statusRef.value = s.status;
|
|
57
74
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.11.
|
|
4
|
+
"version": "1.11.4",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"defu": "^6.1.4",
|
|
69
69
|
"hookable": "^5.5.3",
|
|
70
|
-
"@unhead/schema": "1.11.
|
|
71
|
-
"
|
|
72
|
-
"unhead": "1.11.
|
|
70
|
+
"@unhead/schema": "1.11.4",
|
|
71
|
+
"unhead": "1.11.4",
|
|
72
|
+
"@unhead/shared": "1.11.4"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "unbuild .",
|