@unhead/vue 2.0.0-alpha.8 → 2.0.0-beta.1
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.d.mts +5 -4
- package/dist/client.d.ts +5 -4
- package/dist/client.mjs +9 -12
- package/dist/components.mjs +8 -6
- package/dist/index.d.mts +34 -15
- package/dist/index.d.ts +34 -15
- package/dist/index.mjs +13 -7
- package/dist/legacy.d.mts +27 -45
- package/dist/legacy.d.ts +27 -45
- package/dist/legacy.mjs +36 -93
- package/dist/plugins.d.mts +1 -0
- package/dist/plugins.d.ts +1 -0
- package/dist/plugins.mjs +1 -0
- package/dist/scripts.d.mts +32 -0
- package/dist/scripts.d.ts +32 -0
- package/dist/scripts.mjs +7 -0
- package/dist/server.d.mts +5 -4
- package/dist/server.d.ts +5 -4
- package/dist/server.mjs +7 -9
- package/dist/shared/vue.A6QPXQyg.d.ts +63 -0
- package/dist/shared/vue.BYLJNEcq.mjs +83 -0
- package/dist/shared/vue.C1egIkvG.d.mts +134 -0
- package/dist/shared/vue.C1egIkvG.d.ts +134 -0
- package/dist/shared/vue.Ds_C3mXu.d.mts +63 -0
- package/dist/shared/vue.N9zWjxoK.mjs +7 -0
- package/dist/shared/vue.cHBs6zvy.mjs +70 -0
- package/dist/shared/{vue.CNiRntV8.mjs → vue.nvpYXC6D.mjs} +1 -1
- package/dist/types.d.mts +14 -135
- package/dist/types.d.ts +14 -135
- package/dist/utils.d.mts +11 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.mjs +10 -0
- package/package.json +34 -18
- package/plugins.d.ts +1 -0
- package/utils.d.ts +1 -0
- package/dist/client.cjs +0 -36
- package/dist/client.d.cts +0 -8
- package/dist/components.cjs +0 -65
- package/dist/components.d.cts +0 -5
- package/dist/index.cjs +0 -27
- package/dist/index.d.cts +0 -26
- package/dist/legacy.cjs +0 -186
- package/dist/legacy.d.cts +0 -52
- package/dist/server.cjs +0 -33
- package/dist/server.d.cts +0 -8
- package/dist/shared/vue.51u-UkLG.mjs +0 -13
- package/dist/shared/vue.BF-HCrO8.d.cts +0 -3
- package/dist/shared/vue.BF-HCrO8.d.mts +0 -3
- package/dist/shared/vue.BF-HCrO8.d.ts +0 -3
- package/dist/shared/vue.Btxz9wTa.cjs +0 -126
- package/dist/shared/vue.D2UzSD_b.mjs +0 -115
- package/dist/shared/vue.DFf1FJKf.cjs +0 -20
- package/dist/shared/vue.DnywREVF.d.cts +0 -5
- package/dist/shared/vue.rzkVHzqg.cjs +0 -15
- package/dist/types.cjs +0 -2
- package/dist/types.d.cts +0 -137
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useScript as useScript$1 } from 'unhead/scripts';
|
|
2
|
+
import { getCurrentInstance, onMounted, isRef, watch, onScopeDispose, ref } from 'vue';
|
|
3
|
+
import { i as injectHead } from './vue.BYLJNEcq.mjs';
|
|
4
|
+
|
|
5
|
+
function registerVueScopeHandlers(script, scope) {
|
|
6
|
+
if (!scope) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const _registerCb = (key, cb) => {
|
|
10
|
+
if (!script._cbs[key]) {
|
|
11
|
+
cb(script.instance);
|
|
12
|
+
return () => {
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let i = script._cbs[key].push(cb);
|
|
16
|
+
const destroy = () => {
|
|
17
|
+
if (i) {
|
|
18
|
+
script._cbs[key]?.splice(i - 1, 1);
|
|
19
|
+
i = null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
onScopeDispose(destroy);
|
|
23
|
+
return destroy;
|
|
24
|
+
};
|
|
25
|
+
script.onLoaded = (cb) => _registerCb("loaded", cb);
|
|
26
|
+
script.onError = (cb) => _registerCb("error", cb);
|
|
27
|
+
onScopeDispose(() => {
|
|
28
|
+
script._triggerAbortController?.abort();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function useScript(_input, _options) {
|
|
32
|
+
const input = typeof _input === "string" ? { src: _input } : _input;
|
|
33
|
+
const options = _options || {};
|
|
34
|
+
const head = options?.head || injectHead();
|
|
35
|
+
options.head = head;
|
|
36
|
+
const scope = getCurrentInstance();
|
|
37
|
+
options.eventContext = scope;
|
|
38
|
+
if (scope && typeof options.trigger === "undefined") {
|
|
39
|
+
options.trigger = onMounted;
|
|
40
|
+
} else if (isRef(options.trigger)) {
|
|
41
|
+
const refTrigger = options.trigger;
|
|
42
|
+
let off;
|
|
43
|
+
options.trigger = new Promise((resolve) => {
|
|
44
|
+
off = watch(refTrigger, (val) => {
|
|
45
|
+
if (val) {
|
|
46
|
+
resolve(true);
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
immediate: true
|
|
50
|
+
});
|
|
51
|
+
onScopeDispose(() => resolve(false), true);
|
|
52
|
+
}).then((val) => {
|
|
53
|
+
off?.();
|
|
54
|
+
return val;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
|
|
58
|
+
s._statusRef.value = s.status;
|
|
59
|
+
});
|
|
60
|
+
const script = useScript$1(head, input, options);
|
|
61
|
+
script._statusRef = script._statusRef || ref(script.status);
|
|
62
|
+
registerVueScopeHandlers(script, scope);
|
|
63
|
+
return new Proxy(script, {
|
|
64
|
+
get(_, key, a) {
|
|
65
|
+
return Reflect.get(_, key === "status" ? "_statusRef" : key, a);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { useScript as u };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,137 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead,
|
|
3
|
-
|
|
1
|
+
import { RawInput } from 'unhead/types';
|
|
2
|
+
export { ActiveHeadEntry, AriaAttributes, BodyAttributesWithoutEvents, BodyEvents, DataKeys, GlobalAttributes, Head, HeadEntryOptions, HeadTag, HttpEventAttributes, LinkWithoutEvents, MergeHead, MetaFlat, MetaFlatInput, RawInput, RenderSSRHeadOptions, ResolvableHead, ScriptWithoutEvents, SerializableHead, SpeculationRules, Unhead } from 'unhead/types';
|
|
3
|
+
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, U as UseHeadSafeInput } from './shared/vue.Ds_C3mXu.mjs';
|
|
4
|
+
export { B as BodyAttr, 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, m as ResolvableValue, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput, V as VueHeadClient } from './shared/vue.C1egIkvG.mjs';
|
|
5
|
+
import 'vue';
|
|
4
6
|
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type Base = RawInput<'base'>;
|
|
8
|
+
type HtmlAttributes = RawInput<'htmlAttrs'>;
|
|
9
|
+
type Noscript = RawInput<'noscript'>;
|
|
10
|
+
type Style = RawInput<'style'>;
|
|
11
|
+
type Meta = RawInput<'meta'>;
|
|
12
|
+
type Script = RawInput<'script'>;
|
|
13
|
+
type Link = RawInput<'link'>;
|
|
14
|
+
type BodyAttributes = RawInput<'bodyAttrs'>;
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
14
|
-
*
|
|
15
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
16
|
-
*/
|
|
17
|
-
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
|
|
18
|
-
}
|
|
19
|
-
interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
|
|
20
|
-
/**
|
|
21
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
22
|
-
*
|
|
23
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
24
|
-
*/
|
|
25
|
-
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
|
|
26
|
-
/**
|
|
27
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
28
|
-
*
|
|
29
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
30
|
-
*/
|
|
31
|
-
style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
|
|
32
|
-
}
|
|
33
|
-
type Title = MaybeFunction<number | string | Falsey> | ResolvableValues<({
|
|
34
|
-
textContent: string;
|
|
35
|
-
} & SchemaAugmentations['title'])>;
|
|
36
|
-
type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
|
|
37
|
-
type Base<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Base$1 & SchemaAugmentations['base']> & DefinedValueOrEmptyObject<E>;
|
|
38
|
-
type Link<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<LinkBase & DataKeys & SchemaAugmentations['link']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
|
|
39
|
-
type Meta<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<BaseMeta & DataKeys & SchemaAugmentations['meta']> & DefinedValueOrEmptyObject<E>;
|
|
40
|
-
type Style<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Style$1 & DataKeys & SchemaAugmentations['style']> & DefinedValueOrEmptyObject<E>;
|
|
41
|
-
type Script<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<ScriptBase & DataKeys & SchemaAugmentations['script']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
|
|
42
|
-
type Noscript<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Noscript$1 & DataKeys & SchemaAugmentations['noscript']> & DefinedValueOrEmptyObject<E>;
|
|
43
|
-
type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs']> & DefinedValueOrEmptyObject<E>;
|
|
44
|
-
type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs']> & MaybeEventFnHandlers<BodyEvents> & DefinedValueOrEmptyObject<E>;
|
|
45
|
-
interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
46
|
-
/**
|
|
47
|
-
* The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
|
|
48
|
-
* It only contains text; tags within the element are ignored.
|
|
49
|
-
*
|
|
50
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
|
|
51
|
-
*/
|
|
52
|
-
title?: Title;
|
|
53
|
-
/**
|
|
54
|
-
* Generate the title from a template.
|
|
55
|
-
*/
|
|
56
|
-
titleTemplate?: TitleTemplate;
|
|
57
|
-
/**
|
|
58
|
-
* Variables used to substitute in the title and meta content.
|
|
59
|
-
*/
|
|
60
|
-
templateParams?: ResolvableArray<{
|
|
61
|
-
separator?: '|' | '-' | '·' | string;
|
|
62
|
-
} & Record<string, null | string | ResolvableArray<Record<string, null | string>>>>;
|
|
63
|
-
/**
|
|
64
|
-
* The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
|
|
65
|
-
* There can be only one <base> element in a document.
|
|
66
|
-
*
|
|
67
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
|
|
68
|
-
*/
|
|
69
|
-
base?: Base<E['base']>;
|
|
70
|
-
/**
|
|
71
|
-
* The `<link>` HTML element specifies relationships between the current document and an external resource.
|
|
72
|
-
* This element is most commonly used to link to stylesheets, but is also used to establish site icons
|
|
73
|
-
* (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
|
|
74
|
-
*
|
|
75
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
|
|
76
|
-
*/
|
|
77
|
-
link?: ResolvableArray<Link<E['link']>>;
|
|
78
|
-
/**
|
|
79
|
-
* The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
|
|
80
|
-
*
|
|
81
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
|
|
82
|
-
*/
|
|
83
|
-
meta?: ResolvableArray<Meta<E['meta']>>;
|
|
84
|
-
/**
|
|
85
|
-
* The `<style>` HTML element contains style information for a document, or part of a document.
|
|
86
|
-
* It contains CSS, which is applied to the contents of the document containing the `<style>` element.
|
|
87
|
-
*
|
|
88
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
|
|
89
|
-
*/
|
|
90
|
-
style?: ResolvableArray<(Style<E['style']> | string)>;
|
|
91
|
-
/**
|
|
92
|
-
* The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
|
|
93
|
-
*
|
|
94
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
|
|
95
|
-
*/
|
|
96
|
-
script?: ResolvableArray<(Script<E['script']> | string)>;
|
|
97
|
-
/**
|
|
98
|
-
* The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
|
|
99
|
-
* or if scripting is currently turned off in the browser.
|
|
100
|
-
*
|
|
101
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
|
|
102
|
-
*/
|
|
103
|
-
noscript?: ResolvableArray<(Noscript<E['noscript']> | string)>;
|
|
104
|
-
/**
|
|
105
|
-
* Attributes for the `<html>` HTML element.
|
|
106
|
-
*
|
|
107
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
|
|
108
|
-
*/
|
|
109
|
-
htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
|
|
110
|
-
/**
|
|
111
|
-
* Attributes for the `<body>` HTML element.
|
|
112
|
-
*
|
|
113
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
|
|
114
|
-
*/
|
|
115
|
-
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
116
|
-
}
|
|
117
|
-
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
|
|
118
|
-
head?: VueHeadClient<any>;
|
|
119
|
-
};
|
|
120
|
-
type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
|
|
121
|
-
type UseSeoMetaInput = ResolvableProperties<MetaFlatInput> & {
|
|
122
|
-
title?: ReactiveHead['title'];
|
|
123
|
-
titleTemplate?: ReactiveHead['titleTemplate'];
|
|
124
|
-
};
|
|
125
|
-
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
126
|
-
|
|
127
|
-
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
128
|
-
meta?: ResolvableArray<SafeMeta>[];
|
|
129
|
-
link?: ResolvableArray<SafeLink>[];
|
|
130
|
-
noscript?: ResolvableArray<SafeNoscript>[];
|
|
131
|
-
script?: ResolvableArray<SafeScript>[];
|
|
132
|
-
htmlAttrs?: ResolvableArray<SafeHtmlAttr>;
|
|
133
|
-
bodyAttrs?: ResolvableArray<SafeBodyAttr>;
|
|
134
|
-
}
|
|
135
|
-
type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
|
|
136
|
-
|
|
137
|
-
export type { Base, BodyAttr, BodyAttributes, HeadSafe, HtmlAttr, HtmlAttributes, Link, MaybeComputedRef, Meta, Noscript, ReactiveHead, ResolvableArray, ResolvableProperties, Script, Style, Title, TitleTemplate, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient };
|
|
16
|
+
export type { Base, BodyAttributes, HtmlAttributes, Link, Meta, Noscript, Script, Style };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,137 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead,
|
|
3
|
-
|
|
1
|
+
import { RawInput } from 'unhead/types';
|
|
2
|
+
export { ActiveHeadEntry, AriaAttributes, BodyAttributesWithoutEvents, BodyEvents, DataKeys, GlobalAttributes, Head, HeadEntryOptions, HeadTag, HttpEventAttributes, LinkWithoutEvents, MergeHead, MetaFlat, MetaFlatInput, RawInput, RenderSSRHeadOptions, ResolvableHead, ScriptWithoutEvents, SerializableHead, SpeculationRules, Unhead } from 'unhead/types';
|
|
3
|
+
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, U as UseHeadSafeInput } from './shared/vue.A6QPXQyg.js';
|
|
4
|
+
export { B as BodyAttr, 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, m as ResolvableValue, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput, V as VueHeadClient } from './shared/vue.C1egIkvG.js';
|
|
5
|
+
import 'vue';
|
|
4
6
|
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type Base = RawInput<'base'>;
|
|
8
|
+
type HtmlAttributes = RawInput<'htmlAttrs'>;
|
|
9
|
+
type Noscript = RawInput<'noscript'>;
|
|
10
|
+
type Style = RawInput<'style'>;
|
|
11
|
+
type Meta = RawInput<'meta'>;
|
|
12
|
+
type Script = RawInput<'script'>;
|
|
13
|
+
type Link = RawInput<'link'>;
|
|
14
|
+
type BodyAttributes = RawInput<'bodyAttrs'>;
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
14
|
-
*
|
|
15
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
16
|
-
*/
|
|
17
|
-
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
|
|
18
|
-
}
|
|
19
|
-
interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
|
|
20
|
-
/**
|
|
21
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
22
|
-
*
|
|
23
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
24
|
-
*/
|
|
25
|
-
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
|
|
26
|
-
/**
|
|
27
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
28
|
-
*
|
|
29
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
30
|
-
*/
|
|
31
|
-
style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
|
|
32
|
-
}
|
|
33
|
-
type Title = MaybeFunction<number | string | Falsey> | ResolvableValues<({
|
|
34
|
-
textContent: string;
|
|
35
|
-
} & SchemaAugmentations['title'])>;
|
|
36
|
-
type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
|
|
37
|
-
type Base<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Base$1 & SchemaAugmentations['base']> & DefinedValueOrEmptyObject<E>;
|
|
38
|
-
type Link<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<LinkBase & DataKeys & SchemaAugmentations['link']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
|
|
39
|
-
type Meta<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<BaseMeta & DataKeys & SchemaAugmentations['meta']> & DefinedValueOrEmptyObject<E>;
|
|
40
|
-
type Style<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Style$1 & DataKeys & SchemaAugmentations['style']> & DefinedValueOrEmptyObject<E>;
|
|
41
|
-
type Script<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<ScriptBase & DataKeys & SchemaAugmentations['script']> & MaybeEventFnHandlers<HttpEventAttributes> & DefinedValueOrEmptyObject<E>;
|
|
42
|
-
type Noscript<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<Noscript$1 & DataKeys & SchemaAugmentations['noscript']> & DefinedValueOrEmptyObject<E>;
|
|
43
|
-
type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs']> & DefinedValueOrEmptyObject<E>;
|
|
44
|
-
type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = ResolvableProperties<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs']> & MaybeEventFnHandlers<BodyEvents> & DefinedValueOrEmptyObject<E>;
|
|
45
|
-
interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
46
|
-
/**
|
|
47
|
-
* The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
|
|
48
|
-
* It only contains text; tags within the element are ignored.
|
|
49
|
-
*
|
|
50
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
|
|
51
|
-
*/
|
|
52
|
-
title?: Title;
|
|
53
|
-
/**
|
|
54
|
-
* Generate the title from a template.
|
|
55
|
-
*/
|
|
56
|
-
titleTemplate?: TitleTemplate;
|
|
57
|
-
/**
|
|
58
|
-
* Variables used to substitute in the title and meta content.
|
|
59
|
-
*/
|
|
60
|
-
templateParams?: ResolvableArray<{
|
|
61
|
-
separator?: '|' | '-' | '·' | string;
|
|
62
|
-
} & Record<string, null | string | ResolvableArray<Record<string, null | string>>>>;
|
|
63
|
-
/**
|
|
64
|
-
* The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
|
|
65
|
-
* There can be only one <base> element in a document.
|
|
66
|
-
*
|
|
67
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
|
|
68
|
-
*/
|
|
69
|
-
base?: Base<E['base']>;
|
|
70
|
-
/**
|
|
71
|
-
* The `<link>` HTML element specifies relationships between the current document and an external resource.
|
|
72
|
-
* This element is most commonly used to link to stylesheets, but is also used to establish site icons
|
|
73
|
-
* (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
|
|
74
|
-
*
|
|
75
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
|
|
76
|
-
*/
|
|
77
|
-
link?: ResolvableArray<Link<E['link']>>;
|
|
78
|
-
/**
|
|
79
|
-
* The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
|
|
80
|
-
*
|
|
81
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
|
|
82
|
-
*/
|
|
83
|
-
meta?: ResolvableArray<Meta<E['meta']>>;
|
|
84
|
-
/**
|
|
85
|
-
* The `<style>` HTML element contains style information for a document, or part of a document.
|
|
86
|
-
* It contains CSS, which is applied to the contents of the document containing the `<style>` element.
|
|
87
|
-
*
|
|
88
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
|
|
89
|
-
*/
|
|
90
|
-
style?: ResolvableArray<(Style<E['style']> | string)>;
|
|
91
|
-
/**
|
|
92
|
-
* The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
|
|
93
|
-
*
|
|
94
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
|
|
95
|
-
*/
|
|
96
|
-
script?: ResolvableArray<(Script<E['script']> | string)>;
|
|
97
|
-
/**
|
|
98
|
-
* The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
|
|
99
|
-
* or if scripting is currently turned off in the browser.
|
|
100
|
-
*
|
|
101
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
|
|
102
|
-
*/
|
|
103
|
-
noscript?: ResolvableArray<(Noscript<E['noscript']> | string)>;
|
|
104
|
-
/**
|
|
105
|
-
* Attributes for the `<html>` HTML element.
|
|
106
|
-
*
|
|
107
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
|
|
108
|
-
*/
|
|
109
|
-
htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
|
|
110
|
-
/**
|
|
111
|
-
* Attributes for the `<body>` HTML element.
|
|
112
|
-
*
|
|
113
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
|
|
114
|
-
*/
|
|
115
|
-
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
116
|
-
}
|
|
117
|
-
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
|
|
118
|
-
head?: VueHeadClient<any>;
|
|
119
|
-
};
|
|
120
|
-
type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
|
|
121
|
-
type UseSeoMetaInput = ResolvableProperties<MetaFlatInput> & {
|
|
122
|
-
title?: ReactiveHead['title'];
|
|
123
|
-
titleTemplate?: ReactiveHead['titleTemplate'];
|
|
124
|
-
};
|
|
125
|
-
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
126
|
-
|
|
127
|
-
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
128
|
-
meta?: ResolvableArray<SafeMeta>[];
|
|
129
|
-
link?: ResolvableArray<SafeLink>[];
|
|
130
|
-
noscript?: ResolvableArray<SafeNoscript>[];
|
|
131
|
-
script?: ResolvableArray<SafeScript>[];
|
|
132
|
-
htmlAttrs?: ResolvableArray<SafeHtmlAttr>;
|
|
133
|
-
bodyAttrs?: ResolvableArray<SafeBodyAttr>;
|
|
134
|
-
}
|
|
135
|
-
type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
|
|
136
|
-
|
|
137
|
-
export type { Base, BodyAttr, BodyAttributes, HeadSafe, HtmlAttr, HtmlAttributes, Link, MaybeComputedRef, Meta, Noscript, ReactiveHead, ResolvableArray, ResolvableProperties, Script, Style, Title, TitleTemplate, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient };
|
|
16
|
+
export type { Base, BodyAttributes, HtmlAttributes, Link, Meta, Noscript, Script, Style };
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PropResolver } from 'unhead/types';
|
|
2
|
+
export * from 'unhead/utils';
|
|
3
|
+
|
|
4
|
+
declare const VueResolver: PropResolver;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use head.resolveTags() instead
|
|
8
|
+
*/
|
|
9
|
+
declare function resolveUnrefHeadInput<T extends Record<string, any>>(input: T): T;
|
|
10
|
+
|
|
11
|
+
export { VueResolver, resolveUnrefHeadInput };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PropResolver } from 'unhead/types';
|
|
2
|
+
export * from 'unhead/utils';
|
|
3
|
+
|
|
4
|
+
declare const VueResolver: PropResolver;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use head.resolveTags() instead
|
|
8
|
+
*/
|
|
9
|
+
declare function resolveUnrefHeadInput<T extends Record<string, any>>(input: T): T;
|
|
10
|
+
|
|
11
|
+
export { VueResolver, resolveUnrefHeadInput };
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { walkResolver } from 'unhead/utils';
|
|
2
|
+
export * from 'unhead/utils';
|
|
3
|
+
import { V as VueResolver } from './shared/vue.N9zWjxoK.mjs';
|
|
4
|
+
import 'vue';
|
|
5
|
+
|
|
6
|
+
function resolveUnrefHeadInput(input) {
|
|
7
|
+
return walkResolver(input, VueResolver);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { VueResolver, resolveUnrefHeadInput };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-
|
|
4
|
+
"version": "2.0.0-beta.1",
|
|
5
5
|
"description": "Full-stack <head> manager built for Vue.",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -23,36 +23,42 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
|
-
"import": "./dist/index.mjs"
|
|
27
|
-
"require": "./dist/index.cjs"
|
|
26
|
+
"import": "./dist/index.mjs"
|
|
28
27
|
},
|
|
29
28
|
"./components": {
|
|
30
29
|
"types": "./dist/components.d.ts",
|
|
31
|
-
"import": "./dist/components.mjs"
|
|
32
|
-
"require": "./dist/components.cjs"
|
|
30
|
+
"import": "./dist/components.mjs"
|
|
33
31
|
},
|
|
34
32
|
"./server": {
|
|
35
33
|
"types": "./dist/server.d.ts",
|
|
36
|
-
"import": "./dist/server.mjs"
|
|
37
|
-
"require": "./dist/server.cjs"
|
|
34
|
+
"import": "./dist/server.mjs"
|
|
38
35
|
},
|
|
39
36
|
"./client": {
|
|
40
37
|
"types": "./dist/client.d.ts",
|
|
41
|
-
"import": "./dist/client.mjs"
|
|
42
|
-
"require": "./dist/client.cjs"
|
|
38
|
+
"import": "./dist/client.mjs"
|
|
43
39
|
},
|
|
44
40
|
"./types": {
|
|
45
41
|
"types": "./dist/types.d.ts",
|
|
46
|
-
"import": "./dist/types.mjs"
|
|
47
|
-
"require": "./dist/types.cjs"
|
|
42
|
+
"import": "./dist/types.mjs"
|
|
48
43
|
},
|
|
49
44
|
"./legacy": {
|
|
50
45
|
"types": "./dist/legacy.d.ts",
|
|
51
|
-
"import": "./dist/legacy.mjs"
|
|
52
|
-
|
|
46
|
+
"import": "./dist/legacy.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./plugins": {
|
|
49
|
+
"types": "./dist/plugins.d.ts",
|
|
50
|
+
"import": "./dist/plugins.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./utils": {
|
|
53
|
+
"types": "./dist/utils.d.ts",
|
|
54
|
+
"import": "./dist/utils.mjs"
|
|
55
|
+
},
|
|
56
|
+
"./scripts": {
|
|
57
|
+
"types": "./dist/scripts.d.ts",
|
|
58
|
+
"import": "./dist/scripts.mjs"
|
|
53
59
|
}
|
|
54
60
|
},
|
|
55
|
-
"main": "dist/index.
|
|
61
|
+
"main": "dist/index.mjs",
|
|
56
62
|
"module": "dist/index.mjs",
|
|
57
63
|
"types": "dist/index.d.ts",
|
|
58
64
|
"typesVersions": {
|
|
@@ -71,6 +77,15 @@
|
|
|
71
77
|
],
|
|
72
78
|
"legacy": [
|
|
73
79
|
"dist/legacy"
|
|
80
|
+
],
|
|
81
|
+
"plugins": [
|
|
82
|
+
"dist/plugins"
|
|
83
|
+
],
|
|
84
|
+
"utils": [
|
|
85
|
+
"dist/utils"
|
|
86
|
+
],
|
|
87
|
+
"scripts": [
|
|
88
|
+
"dist/scripts"
|
|
74
89
|
]
|
|
75
90
|
}
|
|
76
91
|
},
|
|
@@ -78,8 +93,11 @@
|
|
|
78
93
|
"client.d.ts",
|
|
79
94
|
"dist",
|
|
80
95
|
"legacy.d.ts",
|
|
96
|
+
"plugins.d.ts",
|
|
97
|
+
"scripts.d.ts",
|
|
81
98
|
"server.d.ts",
|
|
82
|
-
"types.d.ts"
|
|
99
|
+
"types.d.ts",
|
|
100
|
+
"utils.d.ts"
|
|
83
101
|
],
|
|
84
102
|
"peerDependencies": {
|
|
85
103
|
"vue": ">=3.5.13"
|
|
@@ -91,9 +109,7 @@
|
|
|
91
109
|
},
|
|
92
110
|
"dependencies": {
|
|
93
111
|
"hookable": "^5.5.3",
|
|
94
|
-
"
|
|
95
|
-
"@unhead/shared": "2.0.0-alpha.8",
|
|
96
|
-
"unhead": "2.0.0-alpha.8"
|
|
112
|
+
"unhead": "2.0.0-beta.1"
|
|
97
113
|
},
|
|
98
114
|
"scripts": {
|
|
99
115
|
"build": "unbuild .",
|
package/plugins.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/plugins'
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/utils'
|
package/dist/client.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const client = require('unhead/client');
|
|
4
|
-
const vue = require('vue');
|
|
5
|
-
const composables = require('./shared/vue.Btxz9wTa.cjs');
|
|
6
|
-
const VueReactivityPlugin = require('./shared/vue.rzkVHzqg.cjs');
|
|
7
|
-
const VueHeadMixin = require('./shared/vue.DFf1FJKf.cjs');
|
|
8
|
-
require('@unhead/shared');
|
|
9
|
-
|
|
10
|
-
function createHead(options = {}) {
|
|
11
|
-
const head = client.createHead({
|
|
12
|
-
domOptions: {
|
|
13
|
-
delayFn: (fn) => vue.nextTick(() => setTimeout(() => fn(), 0))
|
|
14
|
-
},
|
|
15
|
-
...options,
|
|
16
|
-
plugins: [
|
|
17
|
-
...options.plugins || [],
|
|
18
|
-
VueReactivityPlugin.VueReactivityPlugin
|
|
19
|
-
]
|
|
20
|
-
});
|
|
21
|
-
head.install = composables.vueInstall(head);
|
|
22
|
-
return head;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
|
|
26
|
-
exports.createHead = createHead;
|
|
27
|
-
Object.prototype.hasOwnProperty.call(client, '__proto__') &&
|
|
28
|
-
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
29
|
-
Object.defineProperty(exports, '__proto__', {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
value: client['__proto__']
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
Object.keys(client).forEach(function (k) {
|
|
35
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = client[k];
|
|
36
|
-
});
|
package/dist/client.d.cts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
|
|
2
|
-
import { VueHeadClient } from '@unhead/vue';
|
|
3
|
-
export { V as VueHeadMixin } from './shared/vue.DnywREVF.cjs';
|
|
4
|
-
export * from 'unhead/client';
|
|
5
|
-
|
|
6
|
-
declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
|
|
7
|
-
|
|
8
|
-
export { createHead };
|
package/dist/components.cjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const vue = require('vue');
|
|
4
|
-
const composables = require('./shared/vue.Btxz9wTa.cjs');
|
|
5
|
-
require('@unhead/shared');
|
|
6
|
-
|
|
7
|
-
function addVNodeToHeadObj(node, obj) {
|
|
8
|
-
const nodeType = node.type;
|
|
9
|
-
const type = nodeType === "html" ? "htmlAttrs" : nodeType === "body" ? "bodyAttrs" : nodeType;
|
|
10
|
-
if (typeof type !== "string" || !(type in obj))
|
|
11
|
-
return;
|
|
12
|
-
const props = node.props || {};
|
|
13
|
-
if (node.children) {
|
|
14
|
-
const childrenAttr = "children";
|
|
15
|
-
props.children = Array.isArray(node.children) ? node.children[0][childrenAttr] : node[childrenAttr];
|
|
16
|
-
}
|
|
17
|
-
if (Array.isArray(obj[type]))
|
|
18
|
-
obj[type].push(props);
|
|
19
|
-
else if (type === "title")
|
|
20
|
-
obj.title = props.children;
|
|
21
|
-
else
|
|
22
|
-
obj[type] = props;
|
|
23
|
-
}
|
|
24
|
-
function vnodesToHeadObj(nodes) {
|
|
25
|
-
const obj = {
|
|
26
|
-
title: undefined,
|
|
27
|
-
htmlAttrs: undefined,
|
|
28
|
-
bodyAttrs: undefined,
|
|
29
|
-
base: undefined,
|
|
30
|
-
meta: [],
|
|
31
|
-
link: [],
|
|
32
|
-
style: [],
|
|
33
|
-
script: [],
|
|
34
|
-
noscript: []
|
|
35
|
-
};
|
|
36
|
-
for (const node of nodes) {
|
|
37
|
-
if (typeof node.type === "symbol" && Array.isArray(node.children)) {
|
|
38
|
-
for (const childNode of node.children)
|
|
39
|
-
addVNodeToHeadObj(childNode, obj);
|
|
40
|
-
} else {
|
|
41
|
-
addVNodeToHeadObj(node, obj);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return obj;
|
|
45
|
-
}
|
|
46
|
-
const Head = /* @__PURE__ */ vue.defineComponent({
|
|
47
|
-
name: "Head",
|
|
48
|
-
setup(_, { slots }) {
|
|
49
|
-
const obj = vue.ref({});
|
|
50
|
-
const entry = composables.useHead(obj);
|
|
51
|
-
vue.onBeforeUnmount(() => {
|
|
52
|
-
entry.dispose();
|
|
53
|
-
});
|
|
54
|
-
return () => {
|
|
55
|
-
vue.watchEffect(() => {
|
|
56
|
-
if (!slots.default)
|
|
57
|
-
return;
|
|
58
|
-
entry.patch(vnodesToHeadObj(slots.default()));
|
|
59
|
-
});
|
|
60
|
-
return null;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
exports.Head = Head;
|