@unhead/vue 1.8.19 → 1.9.0
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 +6 -14
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +8 -16
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -97,23 +97,15 @@ function useServerSeoMeta(input, options) {
|
|
|
97
97
|
function useScript(_input, _options) {
|
|
98
98
|
const input = typeof _input === "string" ? { src: _input } : _input;
|
|
99
99
|
const head = injectHead.injectHead();
|
|
100
|
-
const ctx = vue.getCurrentInstance();
|
|
101
100
|
const options = _options || {};
|
|
102
101
|
options.head = head;
|
|
102
|
+
options.eventContext = vue.getCurrentInstance();
|
|
103
103
|
const status = vue.ref("awaitingLoad");
|
|
104
|
-
shared.NetworkEvents.forEach((fn) => {
|
|
105
|
-
const _fn = typeof input[fn] === "function" ? input[fn].bind(ctx) : null;
|
|
106
|
-
if (_fn) {
|
|
107
|
-
input[fn] = (e) => _fn(e);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
104
|
options.stub = ({ script, fn }) => {
|
|
111
105
|
if (fn === "$script") {
|
|
112
|
-
return {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
loaded: vue.computed(() => status.value === "loaded")
|
|
116
|
-
};
|
|
106
|
+
return Object.assign(script, {
|
|
107
|
+
status
|
|
108
|
+
});
|
|
117
109
|
}
|
|
118
110
|
};
|
|
119
111
|
const instance = unhead.useScript(input, options);
|
|
@@ -121,10 +113,10 @@ function useScript(_input, _options) {
|
|
|
121
113
|
if (script.id === instance.$script.id) {
|
|
122
114
|
status.value = script.status;
|
|
123
115
|
if (script.status === "removed")
|
|
124
|
-
head.hooks.removeHook(
|
|
116
|
+
head.hooks.removeHook("script:updated", syncStatus);
|
|
125
117
|
}
|
|
126
118
|
}
|
|
127
|
-
head.hooks.hook(
|
|
119
|
+
head.hooks.hook("script:updated", syncStatus);
|
|
128
120
|
return instance;
|
|
129
121
|
}
|
|
130
122
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, SchemaAugmentations, UseScriptOptions } from '@unhead/schema';
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, 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.8de2bbfa.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.8de2bbfa.cjs';
|
|
7
|
-
import { Plugin,
|
|
7
|
+
import { Plugin, Ref } from 'vue';
|
|
8
8
|
|
|
9
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
10
10
|
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
@@ -50,10 +50,9 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
|
|
|
50
50
|
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
51
51
|
|
|
52
52
|
interface VueScriptInstance<T> extends Omit<ScriptInstance<T>, 'loaded' | 'status'> {
|
|
53
|
-
loaded: ComputedRef<boolean>;
|
|
54
53
|
status: Ref<UseScriptStatus>;
|
|
55
54
|
}
|
|
56
|
-
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & SchemaAugmentations['script'], 'src'>> & {
|
|
55
|
+
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
57
56
|
src: string;
|
|
58
57
|
});
|
|
59
58
|
declare function useScript<T>(_input: UseScriptInput, _options?: UseScriptOptions<T>): T & {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, SchemaAugmentations, UseScriptOptions } from '@unhead/schema';
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, 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.8de2bbfa.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.8de2bbfa.mjs';
|
|
7
|
-
import { Plugin,
|
|
7
|
+
import { Plugin, Ref } from 'vue';
|
|
8
8
|
|
|
9
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
10
10
|
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
@@ -50,10 +50,9 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
|
|
|
50
50
|
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
51
51
|
|
|
52
52
|
interface VueScriptInstance<T> extends Omit<ScriptInstance<T>, 'loaded' | 'status'> {
|
|
53
|
-
loaded: ComputedRef<boolean>;
|
|
54
53
|
status: Ref<UseScriptStatus>;
|
|
55
54
|
}
|
|
56
|
-
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & SchemaAugmentations['script'], 'src'>> & {
|
|
55
|
+
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
57
56
|
src: string;
|
|
58
57
|
});
|
|
59
58
|
declare function useScript<T>(_input: UseScriptInput, _options?: UseScriptOptions<T>): T & {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, SchemaAugmentations, UseScriptOptions } from '@unhead/schema';
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, 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.8de2bbfa.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.8de2bbfa.js';
|
|
7
|
-
import { Plugin,
|
|
7
|
+
import { Plugin, Ref } from 'vue';
|
|
8
8
|
|
|
9
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
10
10
|
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
@@ -50,10 +50,9 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
|
|
|
50
50
|
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
51
51
|
|
|
52
52
|
interface VueScriptInstance<T> extends Omit<ScriptInstance<T>, 'loaded' | 'status'> {
|
|
53
|
-
loaded: ComputedRef<boolean>;
|
|
54
53
|
status: Ref<UseScriptStatus>;
|
|
55
54
|
}
|
|
56
|
-
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & SchemaAugmentations['script'], 'src'>> & {
|
|
55
|
+
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
57
56
|
src: string;
|
|
58
57
|
});
|
|
59
58
|
declare function useScript<T>(_input: UseScriptInput, _options?: UseScriptOptions<T>): T & {
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { useScript as useScript$1 } from 'unhead';
|
|
|
2
2
|
export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
|
|
3
3
|
import { V as Vue3, h as headSymbol, i as injectHead } from './shared/vue.cf295fb1.mjs';
|
|
4
4
|
export { c as createHead, a as createServerHead, r as resolveUnrefHeadInput, s as setHeadInjectionHandler } from './shared/vue.cf295fb1.mjs';
|
|
5
|
-
import { getCurrentInstance, ref
|
|
5
|
+
import { getCurrentInstance, ref } from 'vue';
|
|
6
6
|
import { u as useHead } from './shared/vue.f36acd1f.mjs';
|
|
7
|
-
import { composableNames, whitelistSafeInput, unpackMeta
|
|
7
|
+
import { composableNames, whitelistSafeInput, unpackMeta } from '@unhead/shared';
|
|
8
8
|
|
|
9
9
|
const VueHeadMixin = {
|
|
10
10
|
created() {
|
|
@@ -97,23 +97,15 @@ function useServerSeoMeta(input, options) {
|
|
|
97
97
|
function useScript(_input, _options) {
|
|
98
98
|
const input = typeof _input === "string" ? { src: _input } : _input;
|
|
99
99
|
const head = injectHead();
|
|
100
|
-
const ctx = getCurrentInstance();
|
|
101
100
|
const options = _options || {};
|
|
102
101
|
options.head = head;
|
|
102
|
+
options.eventContext = getCurrentInstance();
|
|
103
103
|
const status = ref("awaitingLoad");
|
|
104
|
-
NetworkEvents.forEach((fn) => {
|
|
105
|
-
const _fn = typeof input[fn] === "function" ? input[fn].bind(ctx) : null;
|
|
106
|
-
if (_fn) {
|
|
107
|
-
input[fn] = (e) => _fn(e);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
104
|
options.stub = ({ script, fn }) => {
|
|
111
105
|
if (fn === "$script") {
|
|
112
|
-
return {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
loaded: computed(() => status.value === "loaded")
|
|
116
|
-
};
|
|
106
|
+
return Object.assign(script, {
|
|
107
|
+
status
|
|
108
|
+
});
|
|
117
109
|
}
|
|
118
110
|
};
|
|
119
111
|
const instance = useScript$1(input, options);
|
|
@@ -121,10 +113,10 @@ function useScript(_input, _options) {
|
|
|
121
113
|
if (script.id === instance.$script.id) {
|
|
122
114
|
status.value = script.status;
|
|
123
115
|
if (script.status === "removed")
|
|
124
|
-
head.hooks.removeHook(
|
|
116
|
+
head.hooks.removeHook("script:updated", syncStatus);
|
|
125
117
|
}
|
|
126
118
|
}
|
|
127
|
-
head.hooks.hook(
|
|
119
|
+
head.hooks.hook("script:updated", syncStatus);
|
|
128
120
|
return instance;
|
|
129
121
|
}
|
|
130
122
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"hookable": "^5.5.3",
|
|
64
|
-
"
|
|
65
|
-
"@unhead/shared": "1.
|
|
66
|
-
"unhead": "1.
|
|
64
|
+
"unhead": "1.9.0",
|
|
65
|
+
"@unhead/shared": "1.9.0",
|
|
66
|
+
"@unhead/schema": "1.9.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"vue": "^3.4.21"
|