@unhead/vue 1.3.0-beta.0 → 1.3.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import require$$1 from 'unhead';
|
|
2
1
|
export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
|
|
3
2
|
import * as _unhead_schema from '@unhead/schema';
|
|
4
|
-
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, HeadEntryOptions, ActiveHeadEntry
|
|
3
|
+
import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, HeadEntryOptions, ActiveHeadEntry } from '@unhead/schema';
|
|
5
4
|
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
|
|
6
|
-
import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput } from './schema-
|
|
7
|
-
export {
|
|
8
|
-
import
|
|
9
|
-
import require$$2 from '@unhead/shared';
|
|
5
|
+
import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseSeoMetaInput } from './schema-84920ead.js';
|
|
6
|
+
export { d as Base, B as BodyAttr, h as BodyAttributes, H as HtmlAttr, g as HtmlAttributes, L as Link, j as MaybeComputedRefOrPromise, i as MaybeReadonlyRef, e as Meta, N as Noscript, f as Script, S as Style, T as Title, c as TitleTemplate } from './schema-84920ead.js';
|
|
7
|
+
import { Plugin } from 'vue';
|
|
10
8
|
|
|
11
9
|
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
12
10
|
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
@@ -18,238 +16,31 @@ interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templ
|
|
|
18
16
|
}
|
|
19
17
|
type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
|
|
20
18
|
|
|
21
|
-
declare function createServerHead
|
|
22
|
-
declare function createHead
|
|
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>;
|
|
23
21
|
|
|
24
|
-
declare const VueHeadMixin
|
|
22
|
+
declare const VueHeadMixin: {
|
|
25
23
|
created(): void;
|
|
26
24
|
};
|
|
27
25
|
|
|
28
|
-
declare const Vue2ProvideUnheadPlugin
|
|
26
|
+
declare const Vue2ProvideUnheadPlugin: Plugin;
|
|
29
27
|
|
|
30
|
-
declare const unheadVueComposablesImports
|
|
28
|
+
declare const unheadVueComposablesImports: {
|
|
31
29
|
'@unhead/vue': string[];
|
|
32
30
|
};
|
|
33
31
|
|
|
34
|
-
declare function injectHead
|
|
32
|
+
declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var vue_4471084f = {};
|
|
39
|
-
|
|
40
|
-
const vue$1 = require$$0;
|
|
41
|
-
const unhead$1 = require$$1;
|
|
42
|
-
const shared$1 = require$$2;
|
|
43
|
-
|
|
44
|
-
const Vue3 = vue$1.version.startsWith("3");
|
|
45
|
-
|
|
46
|
-
function resolveUnref(r) {
|
|
47
|
-
return typeof r === "function" ? r() : vue$1.unref(r);
|
|
48
|
-
}
|
|
49
|
-
function resolveUnrefHeadInput(ref, lastKey = "") {
|
|
50
|
-
if (ref instanceof Promise)
|
|
51
|
-
return ref;
|
|
52
|
-
const root = resolveUnref(ref);
|
|
53
|
-
if (!ref || !root)
|
|
54
|
-
return root;
|
|
55
|
-
if (Array.isArray(root))
|
|
56
|
-
return root.map((r) => resolveUnrefHeadInput(r, lastKey));
|
|
57
|
-
if (typeof root === "object") {
|
|
58
|
-
return Object.fromEntries(
|
|
59
|
-
Object.entries(root).map(([k, v]) => {
|
|
60
|
-
if (k === "titleTemplate" || k.startsWith("on"))
|
|
61
|
-
return [k, vue$1.unref(v)];
|
|
62
|
-
return [k, resolveUnrefHeadInput(v, k)];
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
return root;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const VueReactivityPlugin = shared$1.defineHeadPlugin({
|
|
70
|
-
hooks: {
|
|
71
|
-
"entries:resolve": function(ctx) {
|
|
72
|
-
for (const entry of ctx.entries)
|
|
73
|
-
entry.resolvedInput = resolveUnrefHeadInput(entry.input);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const headSymbol = "usehead";
|
|
79
|
-
function vueInstall(head) {
|
|
80
|
-
const plugin = {
|
|
81
|
-
install(app) {
|
|
82
|
-
if (Vue3) {
|
|
83
|
-
app.config.globalProperties.$unhead = head;
|
|
84
|
-
app.config.globalProperties.$head = head;
|
|
85
|
-
app.provide(headSymbol, head);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
return plugin.install;
|
|
90
|
-
}
|
|
91
|
-
function createServerHead(options = {}) {
|
|
92
|
-
const head = unhead$1.createServerHead(options);
|
|
93
|
-
head.use(VueReactivityPlugin);
|
|
94
|
-
head.install = vueInstall(head);
|
|
95
|
-
return head;
|
|
96
|
-
}
|
|
97
|
-
function createHead(options = {}) {
|
|
98
|
-
options.domDelayFn = options.domDelayFn || ((fn) => vue$1.nextTick(() => fn()));
|
|
99
|
-
const head = unhead$1.createHead(options);
|
|
100
|
-
head.use(VueReactivityPlugin);
|
|
101
|
-
head.install = vueInstall(head);
|
|
102
|
-
return head;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function injectHead() {
|
|
106
|
-
return vue$1.getCurrentInstance() && vue$1.inject(headSymbol) || unhead$1.getActiveHead();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function useHead$2(input, options = {}) {
|
|
110
|
-
const head = injectHead();
|
|
111
|
-
if (!head.ssr)
|
|
112
|
-
return clientUseHead(head, input, options);
|
|
113
|
-
return head.push(input, options);
|
|
114
|
-
}
|
|
115
|
-
function clientUseHead(head, input, options = {}) {
|
|
116
|
-
const deactivated = vue$1.ref(false);
|
|
117
|
-
const resolvedInput = vue$1.ref({});
|
|
118
|
-
vue$1.watchEffect(() => {
|
|
119
|
-
resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
|
|
120
|
-
});
|
|
121
|
-
const entry = head.push(resolvedInput.value, options);
|
|
122
|
-
vue$1.watch(resolvedInput, (e) => {
|
|
123
|
-
entry.patch(e);
|
|
124
|
-
});
|
|
125
|
-
const vm = vue$1.getCurrentInstance();
|
|
126
|
-
if (vm) {
|
|
127
|
-
vue$1.onBeforeUnmount(() => {
|
|
128
|
-
entry.dispose();
|
|
129
|
-
});
|
|
130
|
-
vue$1.onDeactivated(() => {
|
|
131
|
-
deactivated.value = true;
|
|
132
|
-
});
|
|
133
|
-
vue$1.onActivated(() => {
|
|
134
|
-
deactivated.value = false;
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
return entry;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
vue_4471084f.createHead = createHead;
|
|
141
|
-
vue_4471084f.createServerHead = createServerHead;
|
|
142
|
-
vue_4471084f.headSymbol = headSymbol;
|
|
143
|
-
vue_4471084f.injectHead = injectHead;
|
|
144
|
-
vue_4471084f.resolveUnrefHeadInput = resolveUnrefHeadInput;
|
|
145
|
-
vue_4471084f.useHead = useHead$2;
|
|
146
|
-
|
|
147
|
-
const unhead = require$$1;
|
|
148
|
-
const useHead$1 = vue_4471084f;
|
|
149
|
-
const vue = require$$0;
|
|
150
|
-
const shared = require$$2;
|
|
151
|
-
|
|
152
|
-
const VueHeadMixin = {
|
|
153
|
-
created() {
|
|
154
|
-
const instance = vue.getCurrentInstance();
|
|
155
|
-
if (!instance)
|
|
156
|
-
return;
|
|
157
|
-
const options = instance.type;
|
|
158
|
-
if (!options || !("head" in options))
|
|
159
|
-
return;
|
|
160
|
-
const source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
|
|
161
|
-
useHead$1.useHead(source);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const Vue2ProvideUnheadPlugin = function(_Vue, head) {
|
|
166
|
-
_Vue.mixin({
|
|
167
|
-
beforeCreate() {
|
|
168
|
-
const options = this.$options;
|
|
169
|
-
const origProvide = options.provide;
|
|
170
|
-
options.provide = function() {
|
|
171
|
-
let origProvideResult;
|
|
172
|
-
if (typeof origProvide === "function")
|
|
173
|
-
origProvideResult = origProvide.call(this);
|
|
174
|
-
else
|
|
175
|
-
origProvideResult = origProvide || {};
|
|
176
|
-
return {
|
|
177
|
-
...origProvideResult,
|
|
178
|
-
[useHead$1.headSymbol]: head
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const coreComposableNames = [
|
|
186
|
-
"injectHead"
|
|
187
|
-
];
|
|
188
|
-
const unheadVueComposablesImports = {
|
|
189
|
-
"@unhead/vue": [...coreComposableNames, ...shared.composableNames]
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
function useHeadSafe$1(input, options = {}) {
|
|
193
|
-
return useHead$1.useHead(input, { ...options, transform: shared.whitelistSafeInput });
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function useSeoMeta$1(input, options) {
|
|
197
|
-
const headInput = vue.ref({});
|
|
198
|
-
vue.watchEffect(() => {
|
|
199
|
-
const resolvedMeta = useHead$1.resolveUnrefHeadInput(input);
|
|
200
|
-
const { title, titleTemplate, ...meta } = resolvedMeta;
|
|
201
|
-
headInput.value = {
|
|
202
|
-
title,
|
|
203
|
-
titleTemplate,
|
|
204
|
-
meta: shared.unpackMeta(meta)
|
|
205
|
-
};
|
|
206
|
-
});
|
|
207
|
-
return useHead$1.useHead(headInput, options);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function useServerHead$1(input, options = {}) {
|
|
211
|
-
const head = useHead$1.injectHead();
|
|
212
|
-
return head.push(input, options);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function useServerHeadSafe$1(input, options = {}) {
|
|
216
|
-
return useHeadSafe$1(input, { ...options, mode: "server" });
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function useServerSeoMeta$1(input, options) {
|
|
220
|
-
return useSeoMeta$1(input, { ...options || {}, mode: "server" });
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
dist.CapoPlugin = unhead.CapoPlugin;
|
|
224
|
-
dist.HashHydrationPlugin = unhead.HashHydrationPlugin;
|
|
225
|
-
dist.createHeadCore = unhead.createHeadCore;
|
|
226
|
-
dist.createHead = useHead$1.createHead;
|
|
227
|
-
dist.createServerHead = useHead$1.createServerHead;
|
|
228
|
-
dist.injectHead = useHead$1.injectHead;
|
|
229
|
-
dist.useHead = useHead$1.useHead;
|
|
230
|
-
dist.Vue2ProvideUnheadPlugin = Vue2ProvideUnheadPlugin;
|
|
231
|
-
dist.VueHeadMixin = VueHeadMixin;
|
|
232
|
-
dist.unheadVueComposablesImports = unheadVueComposablesImports;
|
|
233
|
-
dist.useHeadSafe = useHeadSafe$1;
|
|
234
|
-
dist.useSeoMeta = useSeoMeta$1;
|
|
235
|
-
dist.useServerHead = useServerHead$1;
|
|
236
|
-
dist.useServerHeadSafe = useServerHeadSafe$1;
|
|
237
|
-
dist.useServerSeoMeta = useServerSeoMeta$1;
|
|
238
|
-
|
|
239
|
-
declare function useHead<T extends MergeHead>(input: dist.UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<dist.UseHeadInput<T>> | void;
|
|
34
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
240
35
|
|
|
241
36
|
declare function useHeadSafe(input: UseHeadSafeInput, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
|
|
242
37
|
|
|
243
|
-
type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
|
|
244
|
-
title?: ReactiveHead['title'];
|
|
245
|
-
titleTemplate?: ReactiveHead['titleTemplate'];
|
|
246
|
-
};
|
|
247
38
|
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
248
39
|
|
|
249
40
|
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): _unhead_schema.ActiveHeadEntry<MaybeComputedRef<ReactiveHead<MergeHead>>>;
|
|
250
41
|
|
|
251
42
|
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: HeadEntryOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadSafeInput>;
|
|
252
43
|
|
|
253
|
-
declare function useServerSeoMeta(input:
|
|
44
|
+
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
254
45
|
|
|
255
|
-
export { HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin
|
|
46
|
+
export { HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, ReactiveHead, UseHeadInput, UseHeadSafeInput, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, createHead, createServerHead, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/polyfill.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MergeHead, HeadEntryOptions } from '@unhead/schema';
|
|
2
|
-
import { V as VueHeadClient, U as UseHeadInput } from './schema-
|
|
2
|
+
import { V as VueHeadClient, U as UseHeadInput } from './schema-84920ead.js';
|
|
3
3
|
import 'vue';
|
|
4
4
|
|
|
5
5
|
type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
|
|
@@ -1,4 +1,4 @@
|
|
|
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, MaybeFunctionEntries, BodyEvents, MergeHead, Unhead } from '@unhead/schema';
|
|
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, MaybeFunctionEntries, BodyEvents, MergeHead, MetaFlatInput, Unhead } from '@unhead/schema';
|
|
2
2
|
import { ComputedRef, Ref, Plugin } from 'vue';
|
|
3
3
|
|
|
4
4
|
type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
|
|
@@ -105,6 +105,10 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
105
105
|
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
106
106
|
}
|
|
107
107
|
type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
|
|
108
|
+
type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
|
|
109
|
+
title?: ReactiveHead['title'];
|
|
110
|
+
titleTemplate?: ReactiveHead['titleTemplate'];
|
|
111
|
+
};
|
|
108
112
|
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
109
113
|
|
|
110
|
-
export { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a,
|
|
114
|
+
export { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a, UseSeoMetaInput as b, TitleTemplate as c, Base as d, Meta as e, Script as f, HtmlAttributes as g, BodyAttributes as h, MaybeReadonlyRef as i, MaybeComputedRefOrPromise as j };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.0-beta.
|
|
4
|
+
"version": "1.3.0-beta.2",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"hookable": "^5.5.3",
|
|
41
|
-
"@unhead/schema": "1.3.0-beta.
|
|
42
|
-
"@unhead/shared": "1.3.0-beta.
|
|
43
|
-
"unhead": "1.3.0-beta.
|
|
41
|
+
"@unhead/schema": "1.3.0-beta.2",
|
|
42
|
+
"@unhead/shared": "1.3.0-beta.2",
|
|
43
|
+
"unhead": "1.3.0-beta.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"vue": "^3.3.4"
|