@unhead/vue 1.8.0-beta.0 → 1.8.0-beta.2
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 +27 -0
- package/dist/index.d.cts +12 -3
- package/dist/index.d.mts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.mjs +30 -3
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -87,6 +87,32 @@ function useServerSeoMeta(input, options) {
|
|
|
87
87
|
return useSeoMeta(input, { ...options || {}, mode: "server" });
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
function useScript(_input, _options) {
|
|
91
|
+
const head = injectHead.injectHead();
|
|
92
|
+
const ctx = vue.getCurrentInstance();
|
|
93
|
+
const input = injectHead.resolveUnrefHeadInput(_input) || {};
|
|
94
|
+
const options = _options || {};
|
|
95
|
+
options.head = head;
|
|
96
|
+
const status = vue.ref("awaitingLoad");
|
|
97
|
+
shared.NetworkEvents.forEach((fn) => {
|
|
98
|
+
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
|
+
};
|
|
103
|
+
});
|
|
104
|
+
options.stub = ({ script, fn }) => {
|
|
105
|
+
if (fn === "$script") {
|
|
106
|
+
return {
|
|
107
|
+
...script,
|
|
108
|
+
status,
|
|
109
|
+
loaded: vue.computed(() => status.value === "loaded")
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return unhead.useScript(input, options);
|
|
114
|
+
}
|
|
115
|
+
|
|
90
116
|
exports.CapoPlugin = unhead.CapoPlugin;
|
|
91
117
|
exports.HashHydrationPlugin = unhead.HashHydrationPlugin;
|
|
92
118
|
exports.createHeadCore = unhead.createHeadCore;
|
|
@@ -100,6 +126,7 @@ exports.Vue2ProvideUnheadPlugin = Vue2ProvideUnheadPlugin;
|
|
|
100
126
|
exports.VueHeadMixin = VueHeadMixin;
|
|
101
127
|
exports.unheadVueComposablesImports = unheadVueComposablesImports;
|
|
102
128
|
exports.useHeadSafe = useHeadSafe;
|
|
129
|
+
exports.useScript = useScript;
|
|
103
130
|
exports.useSeoMeta = useSeoMeta;
|
|
104
131
|
exports.useServerHead = useServerHead;
|
|
105
132
|
exports.useServerHeadSafe = useServerHeadSafe;
|
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 } from '@unhead/schema';
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, UseScriptStatus, UseScriptInput, 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 } from './shared/vue.8eef6ffc.cjs';
|
|
6
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';
|
|
7
|
-
import { Plugin } from 'vue';
|
|
7
|
+
import { Plugin, ComputedRef, Ref } from 'vue';
|
|
8
8
|
|
|
9
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
10
10
|
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
@@ -52,4 +52,13 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
|
|
|
52
52
|
|
|
53
53
|
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
interface VueScriptInstance<T> {
|
|
56
|
+
loaded: ComputedRef<boolean>;
|
|
57
|
+
status: Ref<UseScriptStatus>;
|
|
58
|
+
waitForUse: () => Promise<T>;
|
|
59
|
+
}
|
|
60
|
+
declare function useScript<T>(_input: MaybeComputedRefEntries<UseScriptInput>, _options?: UseScriptOptions<T>): T & {
|
|
61
|
+
$script: VueScriptInstance<T>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, 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,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 } from '@unhead/schema';
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, UseScriptStatus, UseScriptInput, 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 } from './shared/vue.8eef6ffc.mjs';
|
|
6
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';
|
|
7
|
-
import { Plugin } from 'vue';
|
|
7
|
+
import { Plugin, ComputedRef, Ref } from 'vue';
|
|
8
8
|
|
|
9
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
10
10
|
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
@@ -52,4 +52,13 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
|
|
|
52
52
|
|
|
53
53
|
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
interface VueScriptInstance<T> {
|
|
56
|
+
loaded: ComputedRef<boolean>;
|
|
57
|
+
status: Ref<UseScriptStatus>;
|
|
58
|
+
waitForUse: () => Promise<T>;
|
|
59
|
+
}
|
|
60
|
+
declare function useScript<T>(_input: MaybeComputedRefEntries<UseScriptInput>, _options?: UseScriptOptions<T>): T & {
|
|
61
|
+
$script: VueScriptInstance<T>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, 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,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 } from '@unhead/schema';
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, UseScriptStatus, UseScriptInput, 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 } from './shared/vue.8eef6ffc.js';
|
|
6
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';
|
|
7
|
-
import { Plugin } from 'vue';
|
|
7
|
+
import { Plugin, ComputedRef, Ref } from 'vue';
|
|
8
8
|
|
|
9
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
10
10
|
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
@@ -52,4 +52,13 @@ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOpt
|
|
|
52
52
|
|
|
53
53
|
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
interface VueScriptInstance<T> {
|
|
56
|
+
loaded: ComputedRef<boolean>;
|
|
57
|
+
status: Ref<UseScriptStatus>;
|
|
58
|
+
waitForUse: () => Promise<T>;
|
|
59
|
+
}
|
|
60
|
+
declare function useScript<T>(_input: MaybeComputedRefEntries<UseScriptInput>, _options?: UseScriptOptions<T>): T & {
|
|
61
|
+
$script: VueScriptInstance<T>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, 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,10 @@
|
|
|
1
|
+
import { useScript as useScript$1 } from 'unhead';
|
|
1
2
|
export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
|
|
2
3
|
import { V as Vue3, h as headSymbol, r as resolveUnrefHeadInput, i as injectHead } from './shared/vue.cf295fb1.mjs';
|
|
3
4
|
export { c as createHead, a as createServerHead, s as setHeadInjectionHandler } from './shared/vue.cf295fb1.mjs';
|
|
4
|
-
import { getCurrentInstance, ref, watchEffect } from 'vue';
|
|
5
|
+
import { getCurrentInstance, ref, watchEffect, computed } from 'vue';
|
|
5
6
|
import { u as useHead } from './shared/vue.f36acd1f.mjs';
|
|
6
|
-
import { composableNames, whitelistSafeInput, unpackMeta } from '@unhead/shared';
|
|
7
|
+
import { composableNames, whitelistSafeInput, unpackMeta, NetworkEvents } from '@unhead/shared';
|
|
7
8
|
|
|
8
9
|
const VueHeadMixin = {
|
|
9
10
|
created() {
|
|
@@ -86,4 +87,30 @@ function useServerSeoMeta(input, options) {
|
|
|
86
87
|
return useSeoMeta(input, { ...options || {}, mode: "server" });
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
function useScript(_input, _options) {
|
|
91
|
+
const head = injectHead();
|
|
92
|
+
const ctx = getCurrentInstance();
|
|
93
|
+
const input = resolveUnrefHeadInput(_input) || {};
|
|
94
|
+
const options = _options || {};
|
|
95
|
+
options.head = head;
|
|
96
|
+
const status = ref("awaitingLoad");
|
|
97
|
+
NetworkEvents.forEach((fn) => {
|
|
98
|
+
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
|
+
};
|
|
103
|
+
});
|
|
104
|
+
options.stub = ({ script, fn }) => {
|
|
105
|
+
if (fn === "$script") {
|
|
106
|
+
return {
|
|
107
|
+
...script,
|
|
108
|
+
status,
|
|
109
|
+
loaded: computed(() => status.value === "loaded")
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return useScript$1(input, options);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { Vue2ProvideUnheadPlugin, VueHeadMixin, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
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.
|
|
4
|
+
"version": "1.8.0-beta.2",
|
|
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.
|
|
52
|
-
"@unhead/shared": "1.8.0-beta.
|
|
53
|
-
"unhead": "1.8.0-beta.
|
|
51
|
+
"@unhead/schema": "1.8.0-beta.2",
|
|
52
|
+
"@unhead/shared": "1.8.0-beta.2",
|
|
53
|
+
"unhead": "1.8.0-beta.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"vue": "^3.3.4"
|