@unhead/vue 2.0.0-alpha.1 → 2.0.0-alpha.11

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.
Files changed (41) hide show
  1. package/dist/client.d.mts +4 -7
  2. package/dist/client.d.ts +4 -7
  3. package/dist/client.mjs +8 -10
  4. package/dist/components.mjs +3 -2
  5. package/dist/index.d.mts +8 -18
  6. package/dist/index.d.ts +8 -18
  7. package/dist/index.mjs +7 -49
  8. package/dist/legacy.d.mts +25 -23
  9. package/dist/legacy.d.ts +25 -23
  10. package/dist/legacy.mjs +86 -35
  11. package/dist/server.d.mts +4 -7
  12. package/dist/server.d.ts +4 -7
  13. package/dist/server.mjs +6 -10
  14. package/dist/shared/vue.0vTsLwbU.mjs +87 -0
  15. package/dist/shared/{vue.O-w7-AFg.mjs → vue.BOii_fac.mjs} +1 -1
  16. package/dist/{shared/vue.B8gXlHM7.d.cts → types.d.mts} +32 -39
  17. package/dist/{shared/vue.B8gXlHM7.d.mts → types.d.ts} +32 -39
  18. package/dist/types.mjs +1 -0
  19. package/legacy.d.ts +1 -0
  20. package/package.json +29 -15
  21. package/types.d.ts +1 -0
  22. package/dist/client.cjs +0 -37
  23. package/dist/client.d.cts +0 -11
  24. package/dist/components.cjs +0 -65
  25. package/dist/components.d.cts +0 -5
  26. package/dist/index.cjs +0 -67
  27. package/dist/index.d.cts +0 -33
  28. package/dist/legacy.cjs +0 -168
  29. package/dist/legacy.d.cts +0 -51
  30. package/dist/server.cjs +0 -34
  31. package/dist/server.d.cts +0 -11
  32. package/dist/shared/vue.3OjaFlxQ.cjs +0 -20
  33. package/dist/shared/vue.B6jdKgLD.mjs +0 -13
  34. package/dist/shared/vue.B8gXlHM7.d.ts +0 -144
  35. package/dist/shared/vue.BwEnMiRq.cjs +0 -91
  36. package/dist/shared/vue.DIPZN3-d.cjs +0 -15
  37. package/dist/shared/vue.DShwsPiO.d.cts +0 -194
  38. package/dist/shared/vue.DShwsPiO.d.mts +0 -194
  39. package/dist/shared/vue.DShwsPiO.d.ts +0 -194
  40. package/dist/shared/vue.DnywREVF.d.cts +0 -5
  41. package/dist/shared/vue.Sg4YunmP.mjs +0 -85
@@ -0,0 +1,87 @@
1
+ import { SafeInputPlugin, FlatMetaPlugin } from 'unhead/plugins';
2
+ import { walkResolver } from 'unhead/utils';
3
+ import { isRef, toValue, hasInjectionContext, inject, ref, watchEffect, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
4
+
5
+ const headSymbol = "usehead";
6
+ function vueInstall(head) {
7
+ const plugin = {
8
+ install(app) {
9
+ app.config.globalProperties.$unhead = head;
10
+ app.config.globalProperties.$head = head;
11
+ app.provide(headSymbol, head);
12
+ }
13
+ };
14
+ return plugin.install;
15
+ }
16
+
17
+ const VueResolver = (_, value) => {
18
+ return isRef(value) ? toValue(value) : value;
19
+ };
20
+
21
+ function injectHead() {
22
+ if (hasInjectionContext()) {
23
+ const instance = inject(headSymbol);
24
+ if (!instance) {
25
+ throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
26
+ }
27
+ return instance;
28
+ }
29
+ throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
30
+ }
31
+ function useHead(input, options = {}) {
32
+ const head = options.head || injectHead();
33
+ return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
34
+ }
35
+ function clientUseHead(head, input, options = {}) {
36
+ const deactivated = ref(false);
37
+ let entry;
38
+ watchEffect(() => {
39
+ const i = deactivated.value ? {} : walkResolver(input, VueResolver);
40
+ if (entry) {
41
+ entry.patch(i);
42
+ } else {
43
+ entry = head.push(i, options);
44
+ }
45
+ });
46
+ const vm = getCurrentInstance();
47
+ if (vm) {
48
+ onBeforeUnmount(() => {
49
+ entry.dispose();
50
+ });
51
+ onDeactivated(() => {
52
+ deactivated.value = true;
53
+ });
54
+ onActivated(() => {
55
+ deactivated.value = false;
56
+ });
57
+ }
58
+ return entry;
59
+ }
60
+ function useHeadSafe(input, options = {}) {
61
+ const head = options.head || injectHead();
62
+ head.use(SafeInputPlugin);
63
+ options._safe = true;
64
+ return useHead(input, options);
65
+ }
66
+ function useSeoMeta(input, options = {}) {
67
+ const head = options.head || injectHead();
68
+ head.use(FlatMetaPlugin);
69
+ const { title, titleTemplate, ...meta } = input;
70
+ return useHead({
71
+ title,
72
+ titleTemplate,
73
+ // @ts-expect-error runtime type
74
+ _flatMeta: meta
75
+ }, options);
76
+ }
77
+ function useServerHead(input, options = {}) {
78
+ return useHead(input, { ...options, mode: "server" });
79
+ }
80
+ function useServerHeadSafe(input, options = {}) {
81
+ return useHeadSafe(input, { ...options, mode: "server" });
82
+ }
83
+ function useServerSeoMeta(input, options) {
84
+ return useSeoMeta(input, { ...options, mode: "server" });
85
+ }
86
+
87
+ export { VueResolver as V, useHeadSafe as a, useSeoMeta as b, useServerHead as c, useServerHeadSafe as d, useServerSeoMeta as e, headSymbol as h, injectHead as i, useHead as u, vueInstall as v };
@@ -1,5 +1,5 @@
1
1
  import { getCurrentInstance } from 'vue';
2
- import { u as useHead } from './vue.Sg4YunmP.mjs';
2
+ import { u as useHead } from './vue.0vTsLwbU.mjs';
3
3
 
4
4
  const VueHeadMixin = {
5
5
  created() {
@@ -1,20 +1,11 @@
1
- import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MaybeEventFnHandlers, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead, SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from '@unhead/schema';
1
+ import { Falsey, BaseHtmlAttr, MaybeArray, BaseBodyAttr, MaybeFunction, ResolvableValues, SchemaAugmentations, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, DefinedValueOrEmptyObject, LinkBase, DataKeys, MaybeEventFnHandlers, HttpEventAttributes, BaseMeta, Style as Style$1, ScriptBase, Noscript as Noscript$1, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead, SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from 'unhead/types';
2
+ export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from 'unhead/types';
2
3
  import { ComputedRef, Ref, Plugin } from 'vue';
3
4
 
4
- declare function resolveUnrefHeadInput(ref: any): any;
5
-
6
- type MaybeReadonlyRef<T> = ComputedRef<T>;
7
- type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
8
- type MaybeComputedRefOrFalsy<T> = T | MaybeReadonlyRef<T> | Ref<T>;
9
- /**
10
- * @deprecated Use MaybeComputedRefOrFalsy
11
- */
12
- type MaybeComputedRefOrPromise<T> = MaybeComputedRefOrFalsy<T>;
13
- type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
14
- [key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
15
- };
16
- type MaybeComputedRefEntriesOnly<T> = {
17
- [key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
5
+ type MaybeComputedRef<T> = T | (() => T) | ComputedRef<T> | Ref<T>;
6
+ type ResolvableArray<T> = MaybeComputedRef<MaybeComputedRef<T>[]>;
7
+ type ResolvableProperties<T> = {
8
+ [key in keyof T]?: MaybeComputedRef<T[key] | Falsey>;
18
9
  };
19
10
 
20
11
  interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
@@ -39,16 +30,18 @@ interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
39
30
  */
40
31
  style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
41
32
  }
42
- type Title = MaybeComputedRef<Title$1>;
33
+ type Title = MaybeFunction<number | string | Falsey> | ResolvableValues<({
34
+ textContent: string;
35
+ } & SchemaAugmentations['title'])>;
43
36
  type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
44
- type Base<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
45
- type Link<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Link$1<E>>;
46
- type Meta<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Meta$1<E>>;
47
- type Style<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Style$1<E>>;
48
- type Script<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Script$1<E>>;
49
- type Noscript<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Noscript$1<E>>;
50
- type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
51
- type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeEventFnHandlers<BodyEvents>>;
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>;
52
45
  interface ReactiveHead<E extends MergeHead = MergeHead> {
53
46
  /**
54
47
  * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
@@ -64,9 +57,9 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
64
57
  /**
65
58
  * Variables used to substitute in the title and meta content.
66
59
  */
67
- templateParams?: MaybeComputedRefEntries<{
60
+ templateParams?: ResolvableArray<{
68
61
  separator?: '|' | '-' | '·' | string;
69
- } & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
62
+ } & Record<string, null | string | ResolvableArray<Record<string, null | string>>>>;
70
63
  /**
71
64
  * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
72
65
  * There can be only one <base> element in a document.
@@ -81,33 +74,33 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
81
74
  *
82
75
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
83
76
  */
84
- link?: MaybeComputedRef<Link<E['link']>[]>;
77
+ link?: ResolvableArray<Link<E['link']>>;
85
78
  /**
86
79
  * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
87
80
  *
88
81
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
89
82
  */
90
- meta?: MaybeComputedRef<Meta<E['meta']>[]>;
83
+ meta?: ResolvableArray<Meta<E['meta']>>;
91
84
  /**
92
85
  * The `<style>` HTML element contains style information for a document, or part of a document.
93
86
  * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
94
87
  *
95
88
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
96
89
  */
97
- style?: MaybeComputedRef<(Style<E['style']> | string)[]>;
90
+ style?: ResolvableArray<(Style<E['style']> | string)>;
98
91
  /**
99
92
  * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
100
93
  *
101
94
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
102
95
  */
103
- script?: MaybeComputedRef<(Script<E['script']> | string)[]>;
96
+ script?: ResolvableArray<(Script<E['script']> | string)>;
104
97
  /**
105
98
  * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
106
99
  * or if scripting is currently turned off in the browser.
107
100
  *
108
101
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
109
102
  */
110
- noscript?: MaybeComputedRef<(Noscript<E['noscript']> | string)[]>;
103
+ noscript?: ResolvableArray<(Noscript<E['noscript']> | string)>;
111
104
  /**
112
105
  * Attributes for the `<html>` HTML element.
113
106
  *
@@ -125,20 +118,20 @@ type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
125
118
  head?: VueHeadClient<any>;
126
119
  };
127
120
  type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
128
- type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
121
+ type UseSeoMetaInput = ResolvableProperties<MetaFlatInput> & {
129
122
  title?: ReactiveHead['title'];
130
123
  titleTemplate?: ReactiveHead['titleTemplate'];
131
124
  };
132
125
  type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
133
126
 
134
127
  interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
135
- meta?: MaybeComputedRefEntries<SafeMeta>[];
136
- link?: MaybeComputedRefEntries<SafeLink>[];
137
- noscript?: MaybeComputedRefEntries<SafeNoscript>[];
138
- script?: MaybeComputedRefEntries<SafeScript>[];
139
- htmlAttrs?: MaybeComputedRefEntries<SafeHtmlAttr>;
140
- bodyAttrs?: MaybeComputedRefEntries<SafeBodyAttr>;
128
+ meta?: ResolvableArray<SafeMeta>[];
129
+ link?: ResolvableArray<SafeLink>[];
130
+ noscript?: ResolvableArray<SafeNoscript>[];
131
+ script?: ResolvableArray<SafeScript>[];
132
+ htmlAttrs?: ResolvableArray<SafeHtmlAttr>;
133
+ bodyAttrs?: ResolvableArray<SafeBodyAttr>;
141
134
  }
142
135
  type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
143
136
 
144
- export { type BodyAttr as B, type HeadSafe as H, type Link as L, type Meta as M, type Noscript as N, type ReactiveHead as R, type Style as S, type Title as T, type UseHeadInput as U, type VueHeadClient as V, type UseHeadOptions as a, type UseHeadSafeInput as b, type UseSeoMetaInput as c, type HtmlAttr as d, type TitleTemplate as e, type Base as f, type Script as g, type HtmlAttributes as h, type BodyAttributes as i, type MaybeReadonlyRef as j, type MaybeComputedRef as k, type MaybeComputedRefOrFalsy as l, type MaybeComputedRefOrPromise as m, type MaybeComputedRefEntries as n, type MaybeComputedRefEntriesOnly as o, resolveUnrefHeadInput as r };
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 };
@@ -1,20 +1,11 @@
1
- import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MaybeEventFnHandlers, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead, SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from '@unhead/schema';
1
+ import { Falsey, BaseHtmlAttr, MaybeArray, BaseBodyAttr, MaybeFunction, ResolvableValues, SchemaAugmentations, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, DefinedValueOrEmptyObject, LinkBase, DataKeys, MaybeEventFnHandlers, HttpEventAttributes, BaseMeta, Style as Style$1, ScriptBase, Noscript as Noscript$1, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead, SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from 'unhead/types';
2
+ export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from 'unhead/types';
2
3
  import { ComputedRef, Ref, Plugin } from 'vue';
3
4
 
4
- declare function resolveUnrefHeadInput(ref: any): any;
5
-
6
- type MaybeReadonlyRef<T> = ComputedRef<T>;
7
- type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
8
- type MaybeComputedRefOrFalsy<T> = T | MaybeReadonlyRef<T> | Ref<T>;
9
- /**
10
- * @deprecated Use MaybeComputedRefOrFalsy
11
- */
12
- type MaybeComputedRefOrPromise<T> = MaybeComputedRefOrFalsy<T>;
13
- type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
14
- [key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
15
- };
16
- type MaybeComputedRefEntriesOnly<T> = {
17
- [key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
5
+ type MaybeComputedRef<T> = T | (() => T) | ComputedRef<T> | Ref<T>;
6
+ type ResolvableArray<T> = MaybeComputedRef<MaybeComputedRef<T>[]>;
7
+ type ResolvableProperties<T> = {
8
+ [key in keyof T]?: MaybeComputedRef<T[key] | Falsey>;
18
9
  };
19
10
 
20
11
  interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
@@ -39,16 +30,18 @@ interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
39
30
  */
40
31
  style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
41
32
  }
42
- type Title = MaybeComputedRef<Title$1>;
33
+ type Title = MaybeFunction<number | string | Falsey> | ResolvableValues<({
34
+ textContent: string;
35
+ } & SchemaAugmentations['title'])>;
43
36
  type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
44
- type Base<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
45
- type Link<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Link$1<E>>;
46
- type Meta<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Meta$1<E>>;
47
- type Style<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Style$1<E>>;
48
- type Script<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Script$1<E>>;
49
- type Noscript<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Noscript$1<E>>;
50
- type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
51
- type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeEventFnHandlers<BodyEvents>>;
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>;
52
45
  interface ReactiveHead<E extends MergeHead = MergeHead> {
53
46
  /**
54
47
  * The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
@@ -64,9 +57,9 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
64
57
  /**
65
58
  * Variables used to substitute in the title and meta content.
66
59
  */
67
- templateParams?: MaybeComputedRefEntries<{
60
+ templateParams?: ResolvableArray<{
68
61
  separator?: '|' | '-' | '·' | string;
69
- } & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
62
+ } & Record<string, null | string | ResolvableArray<Record<string, null | string>>>>;
70
63
  /**
71
64
  * The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
72
65
  * There can be only one <base> element in a document.
@@ -81,33 +74,33 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
81
74
  *
82
75
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
83
76
  */
84
- link?: MaybeComputedRef<Link<E['link']>[]>;
77
+ link?: ResolvableArray<Link<E['link']>>;
85
78
  /**
86
79
  * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
87
80
  *
88
81
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
89
82
  */
90
- meta?: MaybeComputedRef<Meta<E['meta']>[]>;
83
+ meta?: ResolvableArray<Meta<E['meta']>>;
91
84
  /**
92
85
  * The `<style>` HTML element contains style information for a document, or part of a document.
93
86
  * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
94
87
  *
95
88
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
96
89
  */
97
- style?: MaybeComputedRef<(Style<E['style']> | string)[]>;
90
+ style?: ResolvableArray<(Style<E['style']> | string)>;
98
91
  /**
99
92
  * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
100
93
  *
101
94
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
102
95
  */
103
- script?: MaybeComputedRef<(Script<E['script']> | string)[]>;
96
+ script?: ResolvableArray<(Script<E['script']> | string)>;
104
97
  /**
105
98
  * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
106
99
  * or if scripting is currently turned off in the browser.
107
100
  *
108
101
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
109
102
  */
110
- noscript?: MaybeComputedRef<(Noscript<E['noscript']> | string)[]>;
103
+ noscript?: ResolvableArray<(Noscript<E['noscript']> | string)>;
111
104
  /**
112
105
  * Attributes for the `<html>` HTML element.
113
106
  *
@@ -125,20 +118,20 @@ type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
125
118
  head?: VueHeadClient<any>;
126
119
  };
127
120
  type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
128
- type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
121
+ type UseSeoMetaInput = ResolvableProperties<MetaFlatInput> & {
129
122
  title?: ReactiveHead['title'];
130
123
  titleTemplate?: ReactiveHead['titleTemplate'];
131
124
  };
132
125
  type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
133
126
 
134
127
  interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
135
- meta?: MaybeComputedRefEntries<SafeMeta>[];
136
- link?: MaybeComputedRefEntries<SafeLink>[];
137
- noscript?: MaybeComputedRefEntries<SafeNoscript>[];
138
- script?: MaybeComputedRefEntries<SafeScript>[];
139
- htmlAttrs?: MaybeComputedRefEntries<SafeHtmlAttr>;
140
- bodyAttrs?: MaybeComputedRefEntries<SafeBodyAttr>;
128
+ meta?: ResolvableArray<SafeMeta>[];
129
+ link?: ResolvableArray<SafeLink>[];
130
+ noscript?: ResolvableArray<SafeNoscript>[];
131
+ script?: ResolvableArray<SafeScript>[];
132
+ htmlAttrs?: ResolvableArray<SafeHtmlAttr>;
133
+ bodyAttrs?: ResolvableArray<SafeBodyAttr>;
141
134
  }
142
135
  type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
143
136
 
144
- export { type BodyAttr as B, type HeadSafe as H, type Link as L, type Meta as M, type Noscript as N, type ReactiveHead as R, type Style as S, type Title as T, type UseHeadInput as U, type VueHeadClient as V, type UseHeadOptions as a, type UseHeadSafeInput as b, type UseSeoMetaInput as c, type HtmlAttr as d, type TitleTemplate as e, type Base as f, type Script as g, type HtmlAttributes as h, type BodyAttributes as i, type MaybeReadonlyRef as j, type MaybeComputedRef as k, type MaybeComputedRefOrFalsy as l, type MaybeComputedRefOrPromise as m, type MaybeComputedRefEntries as n, type MaybeComputedRefEntriesOnly as o, resolveUnrefHeadInput as r };
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 };
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+
package/legacy.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/legacy'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "2.0.0-alpha.1",
4
+ "version": "2.0.0-alpha.11",
5
5
  "description": "Full-stack <head> manager built for Vue.",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -12,6 +12,10 @@
12
12
  "url": "git+https://github.com/unjs/unhead.git",
13
13
  "directory": "packages/vue"
14
14
  },
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "tag": "next"
18
+ },
15
19
  "bugs": {
16
20
  "url": "https://github.com/unjs/unhead/issues"
17
21
  },
@@ -19,26 +23,30 @@
19
23
  "exports": {
20
24
  ".": {
21
25
  "types": "./dist/index.d.ts",
22
- "import": "./dist/index.mjs",
23
- "require": "./dist/index.cjs"
26
+ "import": "./dist/index.mjs"
24
27
  },
25
28
  "./components": {
26
29
  "types": "./dist/components.d.ts",
27
- "import": "./dist/components.mjs",
28
- "require": "./dist/components.cjs"
30
+ "import": "./dist/components.mjs"
29
31
  },
30
32
  "./server": {
31
33
  "types": "./dist/server.d.ts",
32
- "import": "./dist/server.mjs",
33
- "require": "./dist/server.cjs"
34
+ "import": "./dist/server.mjs"
34
35
  },
35
36
  "./client": {
36
37
  "types": "./dist/client.d.ts",
37
- "import": "./dist/client.mjs",
38
- "require": "./dist/client.cjs"
38
+ "import": "./dist/client.mjs"
39
+ },
40
+ "./types": {
41
+ "types": "./dist/types.d.ts",
42
+ "import": "./dist/types.mjs"
43
+ },
44
+ "./legacy": {
45
+ "types": "./dist/legacy.d.ts",
46
+ "import": "./dist/legacy.mjs"
39
47
  }
40
48
  },
41
- "main": "dist/index.cjs",
49
+ "main": "dist/index.mjs",
42
50
  "module": "dist/index.mjs",
43
51
  "types": "dist/index.d.ts",
44
52
  "typesVersions": {
@@ -51,16 +59,24 @@
51
59
  ],
52
60
  "client": [
53
61
  "dist/client"
62
+ ],
63
+ "types": [
64
+ "dist/types"
65
+ ],
66
+ "legacy": [
67
+ "dist/legacy"
54
68
  ]
55
69
  }
56
70
  },
57
71
  "files": [
58
72
  "client.d.ts",
59
73
  "dist",
60
- "server.d.ts"
74
+ "legacy.d.ts",
75
+ "server.d.ts",
76
+ "types.d.ts"
61
77
  ],
62
78
  "peerDependencies": {
63
- "vue": ">=3"
79
+ "vue": ">=3.5.13"
64
80
  },
65
81
  "build": {
66
82
  "external": [
@@ -69,9 +85,7 @@
69
85
  },
70
86
  "dependencies": {
71
87
  "hookable": "^5.5.3",
72
- "@unhead/schema": "2.0.0-alpha.1",
73
- "@unhead/shared": "2.0.0-alpha.1",
74
- "unhead": "2.0.0-alpha.1"
88
+ "unhead": "2.0.0-alpha.11"
75
89
  },
76
90
  "scripts": {
77
91
  "build": "unbuild .",
package/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/types'
package/dist/client.cjs DELETED
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- const client = require('unhead/client');
4
- const vue = require('vue');
5
- const useHead = require('./shared/vue.BwEnMiRq.cjs');
6
- const VueReactivityPlugin = require('./shared/vue.DIPZN3-d.cjs');
7
- const VueHeadMixin = require('./shared/vue.3OjaFlxQ.cjs');
8
- require('unhead');
9
- require('@unhead/shared');
10
-
11
- function createHead(options = {}) {
12
- const head = client.createHead({
13
- domOptions: {
14
- delayFn: (fn) => vue.nextTick(() => setTimeout(() => fn(), 0))
15
- },
16
- ...options,
17
- plugins: [
18
- ...options.plugins || [],
19
- VueReactivityPlugin.VueReactivityPlugin
20
- ]
21
- });
22
- head.install = useHead.vueInstall(head);
23
- return head;
24
- }
25
-
26
- exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
27
- exports.createHead = createHead;
28
- Object.prototype.hasOwnProperty.call(client, '__proto__') &&
29
- !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
30
- Object.defineProperty(exports, '__proto__', {
31
- enumerable: true,
32
- value: client['__proto__']
33
- });
34
-
35
- Object.keys(client).forEach(function (k) {
36
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = client[k];
37
- });
package/dist/client.d.cts DELETED
@@ -1,11 +0,0 @@
1
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
- import { d as distExports } from './shared/vue.DShwsPiO.cjs';
3
- export { V as VueHeadMixin } from './shared/vue.DnywREVF.cjs';
4
- export * from 'unhead/client';
5
- import '@unhead/shared';
6
- import 'unhead';
7
- import 'vue';
8
-
9
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): distExports.VueHeadClient<T>;
10
-
11
- export { createHead };
@@ -1,65 +0,0 @@
1
- 'use strict';
2
-
3
- const vue = require('vue');
4
- const useHead = require('./shared/vue.BwEnMiRq.cjs');
5
- require('unhead');
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 = useHead.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;
@@ -1,5 +0,0 @@
1
- import { DefineComponent } from 'vue';
2
-
3
- declare const Head: DefineComponent;
4
-
5
- export { Head };