@unhead/vue 0.4.7 → 0.5.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/index.cjs +68 -68
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +69 -70
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -29,6 +29,73 @@ function asArray(value) {
|
|
|
29
29
|
const Vue3 = vue.version.startsWith("3");
|
|
30
30
|
const IsBrowser = typeof window !== "undefined";
|
|
31
31
|
|
|
32
|
+
const headSymbol = "usehead";
|
|
33
|
+
function injectHead() {
|
|
34
|
+
return vue.getCurrentInstance() && vue.inject(headSymbol) || unhead.getActiveHead();
|
|
35
|
+
}
|
|
36
|
+
function createHead(options = {}) {
|
|
37
|
+
const plugins = [
|
|
38
|
+
VueReactiveUseHeadPlugin(),
|
|
39
|
+
...options?.plugins || []
|
|
40
|
+
];
|
|
41
|
+
const head = unhead.createHead({
|
|
42
|
+
...options,
|
|
43
|
+
domDelayFn: (fn) => setTimeout(() => vue.nextTick(() => fn()), 10),
|
|
44
|
+
plugins
|
|
45
|
+
});
|
|
46
|
+
head.install = (app) => {
|
|
47
|
+
if (Vue3) {
|
|
48
|
+
app.config.globalProperties.$unhead = head;
|
|
49
|
+
app.provide(headSymbol, head);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return head;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const VueHeadMixin = {
|
|
56
|
+
created() {
|
|
57
|
+
const instance = vue.getCurrentInstance();
|
|
58
|
+
if (!instance)
|
|
59
|
+
return;
|
|
60
|
+
const options = instance.type;
|
|
61
|
+
if (!options || !("head" in options))
|
|
62
|
+
return;
|
|
63
|
+
const source = typeof options.head === "function" ? () => options.head() : options.head;
|
|
64
|
+
useHead(source);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const VueReactiveUseHeadPlugin = () => {
|
|
69
|
+
return unhead.defineHeadPlugin({
|
|
70
|
+
hooks: {
|
|
71
|
+
"entries:resolve": function(ctx) {
|
|
72
|
+
for (const entry of ctx.entries)
|
|
73
|
+
entry.input = resolveUnrefHeadInput(entry.input);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const Vue2ProvideUnheadPlugin = function(_Vue, head) {
|
|
80
|
+
_Vue.mixin({
|
|
81
|
+
beforeCreate() {
|
|
82
|
+
const options = this.$options;
|
|
83
|
+
const origProvide = options.provide;
|
|
84
|
+
options.provide = function() {
|
|
85
|
+
let origProvideResult;
|
|
86
|
+
if (typeof origProvide === "function")
|
|
87
|
+
origProvideResult = origProvide.call(this);
|
|
88
|
+
else
|
|
89
|
+
origProvideResult = origProvide || {};
|
|
90
|
+
return {
|
|
91
|
+
...origProvideResult,
|
|
92
|
+
[headSymbol]: head
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
32
99
|
function unpackToArray(input, options) {
|
|
33
100
|
const unpacked = [];
|
|
34
101
|
const kFn = options.resolveKeyData || ((ctx) => ctx.key);
|
|
@@ -243,75 +310,8 @@ const useTagBase = (base) => useHead({ base });
|
|
|
243
310
|
const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
244
311
|
const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
245
312
|
|
|
246
|
-
const headSymbol = "usehead";
|
|
247
|
-
function injectHead() {
|
|
248
|
-
return vue.getCurrentInstance() && vue.inject(headSymbol) || unhead.getActiveHead();
|
|
249
|
-
}
|
|
250
|
-
function createHead(options = {}) {
|
|
251
|
-
const plugins = [
|
|
252
|
-
VueReactiveUseHeadPlugin(),
|
|
253
|
-
...options?.plugins || []
|
|
254
|
-
];
|
|
255
|
-
const head = unhead.createHead({
|
|
256
|
-
...options,
|
|
257
|
-
domDelayFn: (fn) => setTimeout(() => vue.nextTick(() => fn()), 10),
|
|
258
|
-
plugins
|
|
259
|
-
});
|
|
260
|
-
head.install = (app) => {
|
|
261
|
-
if (Vue3) {
|
|
262
|
-
app.config.globalProperties.$unhead = head;
|
|
263
|
-
app.provide(headSymbol, head);
|
|
264
|
-
} else {
|
|
265
|
-
app.options.$unhead = head;
|
|
266
|
-
}
|
|
267
|
-
app.mixin({
|
|
268
|
-
created() {
|
|
269
|
-
const instance = vue.getCurrentInstance();
|
|
270
|
-
if (!instance)
|
|
271
|
-
return;
|
|
272
|
-
const options2 = Vue3 ? instance.type : instance.proxy.$options;
|
|
273
|
-
if (!options2 || !("head" in options2))
|
|
274
|
-
return;
|
|
275
|
-
const source = typeof options2.head === "function" ? () => options2.head() : options2.head;
|
|
276
|
-
useHead(source);
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
};
|
|
280
|
-
return head;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const VueReactiveUseHeadPlugin = () => {
|
|
284
|
-
return unhead.defineHeadPlugin({
|
|
285
|
-
hooks: {
|
|
286
|
-
"entries:resolve": function(ctx) {
|
|
287
|
-
for (const entry of ctx.entries)
|
|
288
|
-
entry.input = resolveUnrefHeadInput(entry.input);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
const Vue2ProvideUnheadPlugin = function(_Vue, head) {
|
|
295
|
-
_Vue.mixin({
|
|
296
|
-
beforeCreate() {
|
|
297
|
-
const options = this.$options;
|
|
298
|
-
const origProvide = options.provide;
|
|
299
|
-
options.provide = function() {
|
|
300
|
-
let origProvideResult;
|
|
301
|
-
if (typeof origProvide === "function")
|
|
302
|
-
origProvideResult = origProvide.call(this);
|
|
303
|
-
else
|
|
304
|
-
origProvideResult = origProvide || {};
|
|
305
|
-
return {
|
|
306
|
-
...origProvideResult,
|
|
307
|
-
[headSymbol]: head
|
|
308
|
-
};
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
};
|
|
313
|
-
|
|
314
313
|
exports.Vue2ProvideUnheadPlugin = Vue2ProvideUnheadPlugin;
|
|
314
|
+
exports.VueHeadMixin = VueHeadMixin;
|
|
315
315
|
exports.VueReactiveUseHeadPlugin = VueReactiveUseHeadPlugin;
|
|
316
316
|
exports.asArray = asArray;
|
|
317
317
|
exports.createHead = createHead;
|
package/dist/index.d.ts
CHANGED
|
@@ -113,6 +113,10 @@ declare const headSymbol = "usehead";
|
|
|
113
113
|
declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
|
|
114
114
|
declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn'>): VueHeadClient<T>;
|
|
115
115
|
|
|
116
|
+
declare const VueHeadMixin: {
|
|
117
|
+
created(): void;
|
|
118
|
+
};
|
|
119
|
+
|
|
116
120
|
declare const VueReactiveUseHeadPlugin: () => _unhead_schema.HeadPlugin;
|
|
117
121
|
|
|
118
122
|
declare const Vue2ProvideUnheadPlugin: Plugin;
|
|
@@ -143,4 +147,4 @@ declare const useTagBase: (base: ReactiveHead['base']) => void;
|
|
|
143
147
|
declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void;
|
|
144
148
|
declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void;
|
|
145
149
|
|
|
146
|
-
export { Arrayable, Base, BodyAttributes, HtmlAttributes, Link, MaybeComputedRefEntries, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, UseHeadInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueReactiveUseHeadPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBodyAttrs, useHead, useHtmlAttrs, useServerBodyAttrs, useServerHead, useServerHtmlAttrs, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
|
|
150
|
+
export { Arrayable, Base, BodyAttributes, HtmlAttributes, Link, MaybeComputedRefEntries, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, UseHeadInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, VueReactiveUseHeadPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBodyAttrs, useHead, useHtmlAttrs, useServerBodyAttrs, useServerHead, useServerHtmlAttrs, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveUnref } from '@vueuse/shared';
|
|
2
|
-
import { unref, version, getCurrentInstance, ref, watchEffect, watch, onBeforeUnmount
|
|
2
|
+
import { unref, version, getCurrentInstance, inject, nextTick, ref, watchEffect, watch, onBeforeUnmount } from 'vue';
|
|
3
3
|
import { getActiveHead, createHead as createHead$1, defineHeadPlugin } from 'unhead';
|
|
4
4
|
export * from '@unhead/dom';
|
|
5
5
|
|
|
@@ -27,6 +27,73 @@ function asArray(value) {
|
|
|
27
27
|
const Vue3 = version.startsWith("3");
|
|
28
28
|
const IsBrowser = typeof window !== "undefined";
|
|
29
29
|
|
|
30
|
+
const headSymbol = "usehead";
|
|
31
|
+
function injectHead() {
|
|
32
|
+
return getCurrentInstance() && inject(headSymbol) || getActiveHead();
|
|
33
|
+
}
|
|
34
|
+
function createHead(options = {}) {
|
|
35
|
+
const plugins = [
|
|
36
|
+
VueReactiveUseHeadPlugin(),
|
|
37
|
+
...options?.plugins || []
|
|
38
|
+
];
|
|
39
|
+
const head = createHead$1({
|
|
40
|
+
...options,
|
|
41
|
+
domDelayFn: (fn) => setTimeout(() => nextTick(() => fn()), 10),
|
|
42
|
+
plugins
|
|
43
|
+
});
|
|
44
|
+
head.install = (app) => {
|
|
45
|
+
if (Vue3) {
|
|
46
|
+
app.config.globalProperties.$unhead = head;
|
|
47
|
+
app.provide(headSymbol, head);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return head;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const VueHeadMixin = {
|
|
54
|
+
created() {
|
|
55
|
+
const instance = getCurrentInstance();
|
|
56
|
+
if (!instance)
|
|
57
|
+
return;
|
|
58
|
+
const options = instance.type;
|
|
59
|
+
if (!options || !("head" in options))
|
|
60
|
+
return;
|
|
61
|
+
const source = typeof options.head === "function" ? () => options.head() : options.head;
|
|
62
|
+
useHead(source);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const VueReactiveUseHeadPlugin = () => {
|
|
67
|
+
return defineHeadPlugin({
|
|
68
|
+
hooks: {
|
|
69
|
+
"entries:resolve": function(ctx) {
|
|
70
|
+
for (const entry of ctx.entries)
|
|
71
|
+
entry.input = resolveUnrefHeadInput(entry.input);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const Vue2ProvideUnheadPlugin = function(_Vue, head) {
|
|
78
|
+
_Vue.mixin({
|
|
79
|
+
beforeCreate() {
|
|
80
|
+
const options = this.$options;
|
|
81
|
+
const origProvide = options.provide;
|
|
82
|
+
options.provide = function() {
|
|
83
|
+
let origProvideResult;
|
|
84
|
+
if (typeof origProvide === "function")
|
|
85
|
+
origProvideResult = origProvide.call(this);
|
|
86
|
+
else
|
|
87
|
+
origProvideResult = origProvide || {};
|
|
88
|
+
return {
|
|
89
|
+
...origProvideResult,
|
|
90
|
+
[headSymbol]: head
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
30
97
|
function unpackToArray(input, options) {
|
|
31
98
|
const unpacked = [];
|
|
32
99
|
const kFn = options.resolveKeyData || ((ctx) => ctx.key);
|
|
@@ -241,72 +308,4 @@ const useTagBase = (base) => useHead({ base });
|
|
|
241
308
|
const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
242
309
|
const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
243
310
|
|
|
244
|
-
|
|
245
|
-
function injectHead() {
|
|
246
|
-
return getCurrentInstance() && inject(headSymbol) || getActiveHead();
|
|
247
|
-
}
|
|
248
|
-
function createHead(options = {}) {
|
|
249
|
-
const plugins = [
|
|
250
|
-
VueReactiveUseHeadPlugin(),
|
|
251
|
-
...options?.plugins || []
|
|
252
|
-
];
|
|
253
|
-
const head = createHead$1({
|
|
254
|
-
...options,
|
|
255
|
-
domDelayFn: (fn) => setTimeout(() => nextTick(() => fn()), 10),
|
|
256
|
-
plugins
|
|
257
|
-
});
|
|
258
|
-
head.install = (app) => {
|
|
259
|
-
if (Vue3) {
|
|
260
|
-
app.config.globalProperties.$unhead = head;
|
|
261
|
-
app.provide(headSymbol, head);
|
|
262
|
-
} else {
|
|
263
|
-
app.options.$unhead = head;
|
|
264
|
-
}
|
|
265
|
-
app.mixin({
|
|
266
|
-
created() {
|
|
267
|
-
const instance = getCurrentInstance();
|
|
268
|
-
if (!instance)
|
|
269
|
-
return;
|
|
270
|
-
const options2 = Vue3 ? instance.type : instance.proxy.$options;
|
|
271
|
-
if (!options2 || !("head" in options2))
|
|
272
|
-
return;
|
|
273
|
-
const source = typeof options2.head === "function" ? () => options2.head() : options2.head;
|
|
274
|
-
useHead(source);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
return head;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const VueReactiveUseHeadPlugin = () => {
|
|
282
|
-
return defineHeadPlugin({
|
|
283
|
-
hooks: {
|
|
284
|
-
"entries:resolve": function(ctx) {
|
|
285
|
-
for (const entry of ctx.entries)
|
|
286
|
-
entry.input = resolveUnrefHeadInput(entry.input);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
const Vue2ProvideUnheadPlugin = function(_Vue, head) {
|
|
293
|
-
_Vue.mixin({
|
|
294
|
-
beforeCreate() {
|
|
295
|
-
const options = this.$options;
|
|
296
|
-
const origProvide = options.provide;
|
|
297
|
-
options.provide = function() {
|
|
298
|
-
let origProvideResult;
|
|
299
|
-
if (typeof origProvide === "function")
|
|
300
|
-
origProvideResult = origProvide.call(this);
|
|
301
|
-
else
|
|
302
|
-
origProvideResult = origProvide || {};
|
|
303
|
-
return {
|
|
304
|
-
...origProvideResult,
|
|
305
|
-
[headSymbol]: head
|
|
306
|
-
};
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
export { Vue2ProvideUnheadPlugin, VueReactiveUseHeadPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBodyAttrs, useHead, useHtmlAttrs, useServerBodyAttrs, useServerHead, useServerHtmlAttrs, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
|
|
311
|
+
export { Vue2ProvideUnheadPlugin, VueHeadMixin, VueReactiveUseHeadPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBodyAttrs, useHead, useHtmlAttrs, useServerBodyAttrs, useServerHead, useServerHtmlAttrs, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"packageManager": "pnpm@7.14.0",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"vue": ">=2.7 || >=3"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@unhead/dom": "0.
|
|
37
|
-
"@unhead/schema": "0.
|
|
36
|
+
"@unhead/dom": "0.5.1",
|
|
37
|
+
"@unhead/schema": "0.5.1",
|
|
38
38
|
"@vueuse/shared": "latest",
|
|
39
|
-
"unhead": "0.
|
|
39
|
+
"unhead": "0.5.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"vue": "^3.2.42"
|