@unhead/vue 1.11.15 → 2.0.0-alpha.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/client.d.ts +1 -0
- package/dist/client.cjs +37 -0
- package/dist/client.d.cts +11 -0
- package/dist/client.d.mts +11 -0
- package/dist/client.d.ts +11 -0
- package/dist/client.mjs +25 -0
- package/dist/components.cjs +9 -18
- package/dist/components.mjs +9 -18
- package/dist/index.cjs +11 -123
- package/dist/index.d.cts +16 -61
- package/dist/index.d.mts +16 -61
- package/dist/index.d.ts +16 -61
- package/dist/index.mjs +9 -117
- package/dist/legacy.cjs +168 -0
- package/dist/legacy.d.cts +51 -0
- package/dist/legacy.d.mts +51 -0
- package/dist/legacy.d.ts +51 -0
- package/dist/legacy.mjs +154 -0
- package/dist/server.cjs +34 -0
- package/dist/server.d.cts +11 -0
- package/dist/server.d.mts +11 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.mjs +22 -0
- package/dist/shared/vue.3OjaFlxQ.cjs +20 -0
- package/dist/shared/vue.B6jdKgLD.mjs +13 -0
- package/dist/shared/{vue.fwis0K4Q.d.cts → vue.B8gXlHM7.d.cts} +25 -13
- package/dist/shared/{vue.fwis0K4Q.d.mts → vue.B8gXlHM7.d.mts} +25 -13
- package/dist/shared/{vue.fwis0K4Q.d.ts → vue.B8gXlHM7.d.ts} +25 -13
- package/dist/shared/vue.BwEnMiRq.cjs +91 -0
- package/dist/shared/vue.DIPZN3-d.cjs +15 -0
- package/dist/shared/vue.DShwsPiO.d.cts +194 -0
- package/dist/shared/vue.DShwsPiO.d.mts +194 -0
- package/dist/shared/vue.DShwsPiO.d.ts +194 -0
- package/dist/shared/vue.DnywREVF.d.cts +5 -0
- package/dist/shared/vue.DnywREVF.d.mts +5 -0
- package/dist/shared/vue.DnywREVF.d.ts +5 -0
- package/dist/shared/vue.O-w7-AFg.mjs +18 -0
- package/dist/shared/vue.Sg4YunmP.mjs +85 -0
- package/package.json +23 -22
- package/server.d.ts +1 -0
- package/dist/polyfill.cjs +0 -30
- package/dist/polyfill.d.cts +0 -40
- package/dist/polyfill.d.mts +0 -40
- package/dist/polyfill.d.ts +0 -40
- package/dist/polyfill.mjs +0 -28
- package/dist/shared/vue.-sixQ7xP.mjs +0 -37
- package/dist/shared/vue.BmMjB48i.cjs +0 -39
- package/dist/shared/vue.DWlmwWrc.cjs +0 -94
- package/dist/shared/vue.ziyDaVMR.mjs +0 -86
- package/dist/vue2.cjs +0 -46
- package/dist/vue2.d.cts +0 -5
- package/dist/vue2.d.mts +0 -5
- package/dist/vue2.d.ts +0 -5
- package/dist/vue2.mjs +0 -44
package/dist/index.d.ts
CHANGED
|
@@ -1,78 +1,33 @@
|
|
|
1
|
-
export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
|
|
2
1
|
import * as _unhead_schema from '@unhead/schema';
|
|
3
|
-
import {
|
|
2
|
+
import { Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
|
|
4
3
|
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
11
|
-
link?: MaybeComputedRefEntries<SafeLink>[];
|
|
12
|
-
noscript?: MaybeComputedRefEntries<SafeNoscript>[];
|
|
13
|
-
script?: MaybeComputedRefEntries<SafeScript>[];
|
|
14
|
-
htmlAttrs?: MaybeComputedRefEntries<SafeHtmlAttr>;
|
|
15
|
-
bodyAttrs?: MaybeComputedRefEntries<SafeBodyAttr>;
|
|
16
|
-
}
|
|
17
|
-
type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
|
|
18
|
-
|
|
19
|
-
declare function createServerHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): VueHeadClient<T>;
|
|
20
|
-
declare function createHead<T extends MergeHead>(options?: CreateHeadOptions): VueHeadClient<T>;
|
|
21
|
-
|
|
22
|
-
declare function resolveUnrefHeadInput(ref: any): any;
|
|
4
|
+
export { createHeadCore, unheadCtx } from 'unhead';
|
|
5
|
+
import { U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.js';
|
|
6
|
+
export { f as Base, B as BodyAttr, i as BodyAttributes, H as HeadSafe, d as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRef, n as MaybeComputedRefEntries, o as MaybeComputedRefEntriesOnly, l as MaybeComputedRefOrFalsy, m as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, M as Meta, N as Noscript, R as ReactiveHead, g as Script, S as Style, T as Title, e as TitleTemplate, V as VueHeadClient, r as resolveUnrefHeadInput } from './shared/vue.B8gXlHM7.js';
|
|
7
|
+
export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
|
|
8
|
+
import 'vue';
|
|
23
9
|
|
|
24
10
|
declare const unheadVueComposablesImports: {
|
|
25
11
|
'@unhead/vue': string[];
|
|
26
12
|
};
|
|
27
13
|
|
|
28
|
-
declare function
|
|
29
|
-
declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
|
|
14
|
+
declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | Unhead<_unhead_schema.Head<_unhead_schema.MergeHead>>;
|
|
30
15
|
|
|
31
|
-
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T
|
|
16
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
|
|
32
17
|
|
|
33
|
-
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<
|
|
18
|
+
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
|
|
34
19
|
|
|
35
|
-
|
|
36
|
-
status: Ref<UseScriptStatus>;
|
|
37
|
-
}
|
|
38
|
-
type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
39
|
-
src: string;
|
|
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
|
-
}
|
|
53
|
-
type UseScriptContext<T extends Record<symbol | string, any>> = (Promise<T> & VueScriptInstance<T>) & AsAsyncFunctionValues<T> & {
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated Use top-level functions instead.
|
|
56
|
-
*/
|
|
57
|
-
$script: Promise<T> & VueScriptInstance<T>;
|
|
58
|
-
};
|
|
59
|
-
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>, U = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T, U>): UseScriptContext<UseFunctionType<UseScriptOptions<T, U>, T>>;
|
|
20
|
+
declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
|
|
60
21
|
|
|
61
|
-
declare function
|
|
22
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
|
|
62
23
|
|
|
63
|
-
declare function
|
|
24
|
+
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
|
|
64
25
|
|
|
65
|
-
declare function
|
|
66
|
-
|
|
67
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
26
|
+
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
|
|
68
27
|
|
|
69
28
|
/**
|
|
70
|
-
* @deprecated
|
|
29
|
+
* @deprecated TODO remove
|
|
71
30
|
*/
|
|
72
|
-
declare const
|
|
73
|
-
|
|
74
|
-
declare const VueHeadMixin: {
|
|
75
|
-
created(): void;
|
|
76
|
-
};
|
|
31
|
+
declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
|
|
77
32
|
|
|
78
|
-
export {
|
|
33
|
+
export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import { getCurrentInstance, onMounted, isRef, watch, onScopeDispose, ref } from 'vue';
|
|
1
|
+
import { composableNames, whitelistSafeInput, unpackMeta, defineHeadPlugin } from '@unhead/shared';
|
|
2
|
+
export { createHeadCore, unheadCtx } from 'unhead';
|
|
3
|
+
import { u as useHead } from './shared/vue.Sg4YunmP.mjs';
|
|
4
|
+
export { i as injectHead, r as resolveUnrefHeadInput } from './shared/vue.Sg4YunmP.mjs';
|
|
5
|
+
export { V as VueHeadMixin } from './shared/vue.O-w7-AFg.mjs';
|
|
6
|
+
import 'vue';
|
|
8
7
|
|
|
9
8
|
const coreComposableNames = [
|
|
10
9
|
"injectHead"
|
|
@@ -17,71 +16,6 @@ function useHeadSafe(input, options = {}) {
|
|
|
17
16
|
return useHead(input, { ...options, transform: whitelistSafeInput });
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
function registerVueScopeHandlers(script, scope) {
|
|
21
|
-
if (!scope) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const _registerCb = (key, cb) => {
|
|
25
|
-
if (!script._cbs[key]) {
|
|
26
|
-
cb(script.instance);
|
|
27
|
-
return () => {
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
let i = script._cbs[key].push(cb);
|
|
31
|
-
const destroy = () => {
|
|
32
|
-
if (i) {
|
|
33
|
-
script._cbs[key]?.splice(i - 1, 1);
|
|
34
|
-
i = null;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
onScopeDispose(destroy);
|
|
38
|
-
return destroy;
|
|
39
|
-
};
|
|
40
|
-
script.onLoaded = (cb) => _registerCb("loaded", cb);
|
|
41
|
-
script.onError = (cb) => _registerCb("error", cb);
|
|
42
|
-
onScopeDispose(() => {
|
|
43
|
-
script._triggerAbortController?.abort();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function useScript(_input, _options) {
|
|
47
|
-
const input = typeof _input === "string" ? { src: _input } : _input;
|
|
48
|
-
const options = _options || {};
|
|
49
|
-
const head = options?.head || injectHead();
|
|
50
|
-
options.head = head;
|
|
51
|
-
const scope = getCurrentInstance();
|
|
52
|
-
options.eventContext = scope;
|
|
53
|
-
if (scope && typeof options.trigger === "undefined") {
|
|
54
|
-
options.trigger = onMounted;
|
|
55
|
-
} else if (isRef(options.trigger)) {
|
|
56
|
-
const refTrigger = options.trigger;
|
|
57
|
-
let off;
|
|
58
|
-
options.trigger = new Promise((resolve) => {
|
|
59
|
-
off = watch(refTrigger, (val) => {
|
|
60
|
-
if (val) {
|
|
61
|
-
resolve(true);
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
immediate: true
|
|
65
|
-
});
|
|
66
|
-
onScopeDispose(() => resolve(false), true);
|
|
67
|
-
}).then((val) => {
|
|
68
|
-
off?.();
|
|
69
|
-
return val;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
|
|
73
|
-
s._statusRef.value = s.status;
|
|
74
|
-
});
|
|
75
|
-
const script = useScript$1(input, options);
|
|
76
|
-
script._statusRef = script._statusRef || ref(script.status);
|
|
77
|
-
registerVueScopeHandlers(script, scope);
|
|
78
|
-
return new Proxy(script, {
|
|
79
|
-
get(_, key, a) {
|
|
80
|
-
return Reflect.get(_, key === "status" ? "_statusRef" : key, a);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
19
|
function useSeoMeta(input, options) {
|
|
86
20
|
const { title, titleTemplate, ...meta } = input;
|
|
87
21
|
return useHead({
|
|
@@ -104,10 +38,7 @@ function useSeoMeta(input, options) {
|
|
|
104
38
|
}
|
|
105
39
|
|
|
106
40
|
function useServerHead(input, options = {}) {
|
|
107
|
-
|
|
108
|
-
delete options.head;
|
|
109
|
-
if (head)
|
|
110
|
-
return head.push(input, { ...options, mode: "server" });
|
|
41
|
+
return useHead(input, { ...options, mode: "server" });
|
|
111
42
|
}
|
|
112
43
|
|
|
113
44
|
function useServerHeadSafe(input, options = {}) {
|
|
@@ -118,45 +49,6 @@ function useServerSeoMeta(input, options) {
|
|
|
118
49
|
return useSeoMeta(input, { ...options, mode: "server" });
|
|
119
50
|
}
|
|
120
51
|
|
|
121
|
-
const
|
|
122
|
-
_Vue.mixin({
|
|
123
|
-
beforeCreate() {
|
|
124
|
-
const options = this.$options;
|
|
125
|
-
const origProvide = options.provide;
|
|
126
|
-
options.provide = function() {
|
|
127
|
-
let origProvideResult;
|
|
128
|
-
if (typeof origProvide === "function")
|
|
129
|
-
origProvideResult = origProvide.call(this);
|
|
130
|
-
else
|
|
131
|
-
origProvideResult = origProvide || {};
|
|
132
|
-
return {
|
|
133
|
-
...origProvideResult,
|
|
134
|
-
[headSymbol]: head
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const VueHeadMixin = {
|
|
142
|
-
created() {
|
|
143
|
-
let source = false;
|
|
144
|
-
if (Vue3) {
|
|
145
|
-
const instance = getCurrentInstance();
|
|
146
|
-
if (!instance)
|
|
147
|
-
return;
|
|
148
|
-
const options = instance.type;
|
|
149
|
-
if (!options || !("head" in options))
|
|
150
|
-
return;
|
|
151
|
-
source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
|
|
152
|
-
} else {
|
|
153
|
-
const head = this.$options.head;
|
|
154
|
-
if (head) {
|
|
155
|
-
source = typeof head === "function" ? () => head.call(this) : head;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
source && useHead(source);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
52
|
+
const CapoPlugin = () => defineHeadPlugin({});
|
|
161
53
|
|
|
162
|
-
export {
|
|
54
|
+
export { CapoPlugin, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/legacy.cjs
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const shared = require('@unhead/shared');
|
|
4
|
+
const unhead = require('unhead');
|
|
5
|
+
const vue = require('vue');
|
|
6
|
+
const client = require('./client.cjs');
|
|
7
|
+
const useHead$1 = require('./shared/vue.BwEnMiRq.cjs');
|
|
8
|
+
const server = require('./server.cjs');
|
|
9
|
+
const legacy = require('unhead/legacy');
|
|
10
|
+
require('unhead/client');
|
|
11
|
+
require('./shared/vue.DIPZN3-d.cjs');
|
|
12
|
+
require('./shared/vue.3OjaFlxQ.cjs');
|
|
13
|
+
require('unhead/server');
|
|
14
|
+
|
|
15
|
+
function registerVueScopeHandlers(script, scope) {
|
|
16
|
+
if (!scope) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const _registerCb = (key, cb) => {
|
|
20
|
+
if (!script._cbs[key]) {
|
|
21
|
+
cb(script.instance);
|
|
22
|
+
return () => {
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
let i = script._cbs[key].push(cb);
|
|
26
|
+
const destroy = () => {
|
|
27
|
+
if (i) {
|
|
28
|
+
script._cbs[key]?.splice(i - 1, 1);
|
|
29
|
+
i = null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
vue.onScopeDispose(destroy);
|
|
33
|
+
return destroy;
|
|
34
|
+
};
|
|
35
|
+
script.onLoaded = (cb) => _registerCb("loaded", cb);
|
|
36
|
+
script.onError = (cb) => _registerCb("error", cb);
|
|
37
|
+
vue.onScopeDispose(() => {
|
|
38
|
+
script._triggerAbortController?.abort();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function useScript(_input, _options) {
|
|
42
|
+
const input = typeof _input === "string" ? { src: _input } : _input;
|
|
43
|
+
const options = _options || {};
|
|
44
|
+
const head = options?.head || injectHead();
|
|
45
|
+
options.head = head;
|
|
46
|
+
const scope = vue.getCurrentInstance();
|
|
47
|
+
options.eventContext = scope;
|
|
48
|
+
if (scope && typeof options.trigger === "undefined") {
|
|
49
|
+
options.trigger = vue.onMounted;
|
|
50
|
+
} else if (vue.isRef(options.trigger)) {
|
|
51
|
+
const refTrigger = options.trigger;
|
|
52
|
+
let off;
|
|
53
|
+
options.trigger = new Promise((resolve) => {
|
|
54
|
+
off = vue.watch(refTrigger, (val) => {
|
|
55
|
+
if (val) {
|
|
56
|
+
resolve(true);
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
immediate: true
|
|
60
|
+
});
|
|
61
|
+
vue.onScopeDispose(() => resolve(false), true);
|
|
62
|
+
}).then((val) => {
|
|
63
|
+
off?.();
|
|
64
|
+
return val;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
|
|
68
|
+
s._statusRef.value = s.status;
|
|
69
|
+
});
|
|
70
|
+
const script = legacy.useScript(input, options);
|
|
71
|
+
script._statusRef = script._statusRef || vue.ref(script.status);
|
|
72
|
+
registerVueScopeHandlers(script, scope);
|
|
73
|
+
return new Proxy(script, {
|
|
74
|
+
get(_, key, a) {
|
|
75
|
+
return Reflect.get(_, key === "status" ? "_statusRef" : key, a);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const CapoPlugin = () => shared.defineHeadPlugin({});
|
|
81
|
+
function setHeadInjectionHandler(handler) {
|
|
82
|
+
unhead.unheadCtx.set(handler(), true);
|
|
83
|
+
}
|
|
84
|
+
function injectHead() {
|
|
85
|
+
const ctx = unhead.tryUseUnhead();
|
|
86
|
+
if (ctx) {
|
|
87
|
+
return ctx;
|
|
88
|
+
}
|
|
89
|
+
return vue.inject(useHead$1.headSymbol);
|
|
90
|
+
}
|
|
91
|
+
function useHead(input, options = {}) {
|
|
92
|
+
const head = options.head || injectHead();
|
|
93
|
+
if (head) {
|
|
94
|
+
return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function clientUseHead(head, input, options = {}) {
|
|
98
|
+
const deactivated = vue.ref(false);
|
|
99
|
+
const resolvedInput = vue.ref({});
|
|
100
|
+
vue.watchEffect(() => {
|
|
101
|
+
resolvedInput.value = deactivated.value ? {} : useHead$1.resolveUnrefHeadInput(input);
|
|
102
|
+
});
|
|
103
|
+
const entry = head.push(resolvedInput.value, options);
|
|
104
|
+
vue.watch(resolvedInput, (e) => {
|
|
105
|
+
entry.patch(e);
|
|
106
|
+
});
|
|
107
|
+
const vm = vue.getCurrentInstance();
|
|
108
|
+
if (vm) {
|
|
109
|
+
vue.onBeforeUnmount(() => {
|
|
110
|
+
entry.dispose();
|
|
111
|
+
});
|
|
112
|
+
vue.onDeactivated(() => {
|
|
113
|
+
deactivated.value = true;
|
|
114
|
+
});
|
|
115
|
+
vue.onActivated(() => {
|
|
116
|
+
deactivated.value = false;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return entry;
|
|
120
|
+
}
|
|
121
|
+
function useHeadSafe(input, options = {}) {
|
|
122
|
+
return useHead(input, { ...options, transform: shared.whitelistSafeInput });
|
|
123
|
+
}
|
|
124
|
+
function useSeoMeta(input, options) {
|
|
125
|
+
const { title, titleTemplate, ...meta } = input;
|
|
126
|
+
return useHead({
|
|
127
|
+
title,
|
|
128
|
+
titleTemplate,
|
|
129
|
+
// @ts-expect-error runtime type
|
|
130
|
+
_flatMeta: meta
|
|
131
|
+
}, {
|
|
132
|
+
...options,
|
|
133
|
+
transform(t) {
|
|
134
|
+
const meta2 = shared.unpackMeta({ ...t._flatMeta });
|
|
135
|
+
delete t._flatMeta;
|
|
136
|
+
return {
|
|
137
|
+
// @ts-expect-error runtime type
|
|
138
|
+
...t,
|
|
139
|
+
meta: meta2
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function useServerHead(input, options = {}) {
|
|
145
|
+
return useHead(input, { ...options, mode: "server" });
|
|
146
|
+
}
|
|
147
|
+
function useServerHeadSafe(input, options = {}) {
|
|
148
|
+
return useHeadSafe(input, { ...options, mode: "server" });
|
|
149
|
+
}
|
|
150
|
+
function useServerSeoMeta(input, options) {
|
|
151
|
+
return useSeoMeta(input, { ...options, mode: "server" });
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
exports.createHeadCore = unhead.createHeadCore;
|
|
155
|
+
exports.createHead = client.createHead;
|
|
156
|
+
exports.resolveUnrefHeadInput = useHead$1.resolveUnrefHeadInput;
|
|
157
|
+
exports.createServerHead = server.createHead;
|
|
158
|
+
exports.resolveScriptKey = legacy.resolveScriptKey;
|
|
159
|
+
exports.CapoPlugin = CapoPlugin;
|
|
160
|
+
exports.injectHead = injectHead;
|
|
161
|
+
exports.setHeadInjectionHandler = setHeadInjectionHandler;
|
|
162
|
+
exports.useHead = useHead;
|
|
163
|
+
exports.useHeadSafe = useHeadSafe;
|
|
164
|
+
exports.useScript = useScript;
|
|
165
|
+
exports.useSeoMeta = useSeoMeta;
|
|
166
|
+
exports.useServerHead = useServerHead;
|
|
167
|
+
exports.useServerHeadSafe = useServerHeadSafe;
|
|
168
|
+
exports.useServerSeoMeta = useServerSeoMeta;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _unhead_schema from '@unhead/schema';
|
|
2
|
+
import { ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
|
|
3
|
+
import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.cjs';
|
|
4
|
+
export { r as resolveUnrefHeadInput } from './shared/vue.B8gXlHM7.cjs';
|
|
5
|
+
export { createHeadCore } from 'unhead';
|
|
6
|
+
export { createHead } from './client.cjs';
|
|
7
|
+
export { createHead as createServerHead } from './server.cjs';
|
|
8
|
+
import { d as distExports } from './shared/vue.DShwsPiO.cjs';
|
|
9
|
+
import { ScriptInstance, UseScriptStatus, UseScriptOptions as UseScriptOptions$1, UseFunctionType } from 'unhead/legacy';
|
|
10
|
+
export { UseFunctionType, resolveScriptKey } from 'unhead/legacy';
|
|
11
|
+
import { Ref } from 'vue';
|
|
12
|
+
import './shared/vue.DnywREVF.cjs';
|
|
13
|
+
import 'unhead/client';
|
|
14
|
+
import 'unhead/server';
|
|
15
|
+
import '@unhead/shared';
|
|
16
|
+
|
|
17
|
+
interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
|
|
18
|
+
status: Ref<UseScriptStatus>;
|
|
19
|
+
}
|
|
20
|
+
type UseScriptInput = string | (distExports.MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
21
|
+
src: string;
|
|
22
|
+
});
|
|
23
|
+
interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends HeadEntryOptions, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
|
|
24
|
+
/**
|
|
25
|
+
* The trigger to load the script:
|
|
26
|
+
* - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
|
|
27
|
+
* - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
|
|
28
|
+
* - `Promise` - Load the script when the promise resolves, exists only on the client.
|
|
29
|
+
* - `Function` - Register a callback function to load the script, exists only on the client.
|
|
30
|
+
* - `server` - Have the script injected on the server.
|
|
31
|
+
* - `ref` - Load the script when the ref is true.
|
|
32
|
+
*/
|
|
33
|
+
trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
|
|
34
|
+
}
|
|
35
|
+
type UseScriptContext<T extends Record<symbol | string, any>> = Promise<T> & VueScriptInstance<T>;
|
|
36
|
+
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
|
|
37
|
+
|
|
38
|
+
declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Please switch to non-legacy version
|
|
41
|
+
*/
|
|
42
|
+
declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
|
|
43
|
+
declare function injectHead(): Unhead<_unhead_schema.Head<MergeHead>> | Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | undefined;
|
|
44
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
45
|
+
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
|
|
46
|
+
declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
47
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
48
|
+
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
49
|
+
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
50
|
+
|
|
51
|
+
export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type VueScriptInstance, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _unhead_schema from '@unhead/schema';
|
|
2
|
+
import { ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
|
|
3
|
+
import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.mjs';
|
|
4
|
+
export { r as resolveUnrefHeadInput } from './shared/vue.B8gXlHM7.mjs';
|
|
5
|
+
export { createHeadCore } from 'unhead';
|
|
6
|
+
export { createHead } from './client.mjs';
|
|
7
|
+
export { createHead as createServerHead } from './server.mjs';
|
|
8
|
+
import { d as distExports } from './shared/vue.DShwsPiO.mjs';
|
|
9
|
+
import { ScriptInstance, UseScriptStatus, UseScriptOptions as UseScriptOptions$1, UseFunctionType } from 'unhead/legacy';
|
|
10
|
+
export { UseFunctionType, resolveScriptKey } from 'unhead/legacy';
|
|
11
|
+
import { Ref } from 'vue';
|
|
12
|
+
import './shared/vue.DnywREVF.mjs';
|
|
13
|
+
import 'unhead/client';
|
|
14
|
+
import 'unhead/server';
|
|
15
|
+
import '@unhead/shared';
|
|
16
|
+
|
|
17
|
+
interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
|
|
18
|
+
status: Ref<UseScriptStatus>;
|
|
19
|
+
}
|
|
20
|
+
type UseScriptInput = string | (distExports.MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
21
|
+
src: string;
|
|
22
|
+
});
|
|
23
|
+
interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends HeadEntryOptions, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
|
|
24
|
+
/**
|
|
25
|
+
* The trigger to load the script:
|
|
26
|
+
* - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
|
|
27
|
+
* - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
|
|
28
|
+
* - `Promise` - Load the script when the promise resolves, exists only on the client.
|
|
29
|
+
* - `Function` - Register a callback function to load the script, exists only on the client.
|
|
30
|
+
* - `server` - Have the script injected on the server.
|
|
31
|
+
* - `ref` - Load the script when the ref is true.
|
|
32
|
+
*/
|
|
33
|
+
trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
|
|
34
|
+
}
|
|
35
|
+
type UseScriptContext<T extends Record<symbol | string, any>> = Promise<T> & VueScriptInstance<T>;
|
|
36
|
+
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
|
|
37
|
+
|
|
38
|
+
declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Please switch to non-legacy version
|
|
41
|
+
*/
|
|
42
|
+
declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
|
|
43
|
+
declare function injectHead(): Unhead<_unhead_schema.Head<MergeHead>> | Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | undefined;
|
|
44
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
45
|
+
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
|
|
46
|
+
declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
47
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
48
|
+
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
49
|
+
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
50
|
+
|
|
51
|
+
export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type VueScriptInstance, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/legacy.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _unhead_schema from '@unhead/schema';
|
|
2
|
+
import { ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
|
|
3
|
+
import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.js';
|
|
4
|
+
export { r as resolveUnrefHeadInput } from './shared/vue.B8gXlHM7.js';
|
|
5
|
+
export { createHeadCore } from 'unhead';
|
|
6
|
+
export { createHead } from './client.js';
|
|
7
|
+
export { createHead as createServerHead } from './server.js';
|
|
8
|
+
import { d as distExports } from './shared/vue.DShwsPiO.js';
|
|
9
|
+
import { ScriptInstance, UseScriptStatus, UseScriptOptions as UseScriptOptions$1, UseFunctionType } from 'unhead/legacy';
|
|
10
|
+
export { UseFunctionType, resolveScriptKey } from 'unhead/legacy';
|
|
11
|
+
import { Ref } from 'vue';
|
|
12
|
+
import './shared/vue.DnywREVF.js';
|
|
13
|
+
import 'unhead/client';
|
|
14
|
+
import 'unhead/server';
|
|
15
|
+
import '@unhead/shared';
|
|
16
|
+
|
|
17
|
+
interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
|
|
18
|
+
status: Ref<UseScriptStatus>;
|
|
19
|
+
}
|
|
20
|
+
type UseScriptInput = string | (distExports.MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
|
|
21
|
+
src: string;
|
|
22
|
+
});
|
|
23
|
+
interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends HeadEntryOptions, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
|
|
24
|
+
/**
|
|
25
|
+
* The trigger to load the script:
|
|
26
|
+
* - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
|
|
27
|
+
* - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
|
|
28
|
+
* - `Promise` - Load the script when the promise resolves, exists only on the client.
|
|
29
|
+
* - `Function` - Register a callback function to load the script, exists only on the client.
|
|
30
|
+
* - `server` - Have the script injected on the server.
|
|
31
|
+
* - `ref` - Load the script when the ref is true.
|
|
32
|
+
*/
|
|
33
|
+
trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
|
|
34
|
+
}
|
|
35
|
+
type UseScriptContext<T extends Record<symbol | string, any>> = Promise<T> & VueScriptInstance<T>;
|
|
36
|
+
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
|
|
37
|
+
|
|
38
|
+
declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Please switch to non-legacy version
|
|
41
|
+
*/
|
|
42
|
+
declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
|
|
43
|
+
declare function injectHead(): Unhead<_unhead_schema.Head<MergeHead>> | Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | undefined;
|
|
44
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
45
|
+
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
|
|
46
|
+
declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
47
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
48
|
+
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
49
|
+
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
50
|
+
|
|
51
|
+
export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type VueScriptInstance, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|