@unhead/vue 0.6.1 → 0.6.3
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 +14 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +15 -9
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -5,20 +5,23 @@ const vue = require('vue');
|
|
|
5
5
|
const unhead = require('unhead');
|
|
6
6
|
const dom = require('@unhead/dom');
|
|
7
7
|
|
|
8
|
-
function resolveUnrefHeadInput(ref) {
|
|
8
|
+
function resolveUnrefHeadInput(ref, lastKey = "") {
|
|
9
9
|
const root = shared.resolveUnref(ref);
|
|
10
10
|
if (!ref || !root)
|
|
11
11
|
return root;
|
|
12
12
|
if (Array.isArray(root))
|
|
13
|
-
return root.map(resolveUnrefHeadInput);
|
|
13
|
+
return root.map((r) => resolveUnrefHeadInput(r, lastKey));
|
|
14
14
|
if (typeof root === "object") {
|
|
15
|
-
|
|
15
|
+
const unrefdObj = Object.fromEntries(
|
|
16
16
|
Object.entries(root).map(([key, value]) => {
|
|
17
17
|
if (key === "titleTemplate" || key.startsWith("on"))
|
|
18
18
|
return [key, vue.unref(value)];
|
|
19
|
-
return [key, resolveUnrefHeadInput(value)];
|
|
19
|
+
return [key, resolveUnrefHeadInput(value, key)];
|
|
20
20
|
})
|
|
21
21
|
);
|
|
22
|
+
if (unhead.HasElementTags.includes(String(lastKey)) && JSON.stringify(unrefdObj) !== JSON.stringify(root))
|
|
23
|
+
unrefdObj._dynamic = true;
|
|
24
|
+
return unrefdObj;
|
|
22
25
|
}
|
|
23
26
|
return root;
|
|
24
27
|
}
|
|
@@ -43,12 +46,15 @@ function createHead(options = {}) {
|
|
|
43
46
|
domDelayFn: (fn) => setTimeout(() => vue.nextTick(() => fn()), 10),
|
|
44
47
|
plugins
|
|
45
48
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
const vuePlugin = {
|
|
50
|
+
install(app) {
|
|
51
|
+
if (Vue3) {
|
|
52
|
+
app.config.globalProperties.$unhead = head;
|
|
53
|
+
app.provide(headSymbol, head);
|
|
54
|
+
}
|
|
50
55
|
}
|
|
51
56
|
};
|
|
57
|
+
head.install = vuePlugin.install;
|
|
52
58
|
return head;
|
|
53
59
|
}
|
|
54
60
|
|
package/dist/index.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
105
105
|
}
|
|
106
106
|
declare type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
|
|
107
107
|
|
|
108
|
-
declare function resolveUnrefHeadInput(ref: any): any;
|
|
108
|
+
declare function resolveUnrefHeadInput(ref: any, lastKey?: string | number): any;
|
|
109
109
|
declare function asArray<T>(value: Arrayable<T>): T[];
|
|
110
110
|
|
|
111
111
|
declare type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { resolveUnref } from '@vueuse/shared';
|
|
2
2
|
import { unref, version, getCurrentInstance, inject, nextTick, ref, watchEffect, watch, onBeforeUnmount } from 'vue';
|
|
3
|
-
import { getActiveHead, createHead as createHead$1, defineHeadPlugin, composableNames } from 'unhead';
|
|
3
|
+
import { HasElementTags, getActiveHead, createHead as createHead$1, defineHeadPlugin, composableNames } from 'unhead';
|
|
4
4
|
export * from '@unhead/dom';
|
|
5
5
|
|
|
6
|
-
function resolveUnrefHeadInput(ref) {
|
|
6
|
+
function resolveUnrefHeadInput(ref, lastKey = "") {
|
|
7
7
|
const root = resolveUnref(ref);
|
|
8
8
|
if (!ref || !root)
|
|
9
9
|
return root;
|
|
10
10
|
if (Array.isArray(root))
|
|
11
|
-
return root.map(resolveUnrefHeadInput);
|
|
11
|
+
return root.map((r) => resolveUnrefHeadInput(r, lastKey));
|
|
12
12
|
if (typeof root === "object") {
|
|
13
|
-
|
|
13
|
+
const unrefdObj = Object.fromEntries(
|
|
14
14
|
Object.entries(root).map(([key, value]) => {
|
|
15
15
|
if (key === "titleTemplate" || key.startsWith("on"))
|
|
16
16
|
return [key, unref(value)];
|
|
17
|
-
return [key, resolveUnrefHeadInput(value)];
|
|
17
|
+
return [key, resolveUnrefHeadInput(value, key)];
|
|
18
18
|
})
|
|
19
19
|
);
|
|
20
|
+
if (HasElementTags.includes(String(lastKey)) && JSON.stringify(unrefdObj) !== JSON.stringify(root))
|
|
21
|
+
unrefdObj._dynamic = true;
|
|
22
|
+
return unrefdObj;
|
|
20
23
|
}
|
|
21
24
|
return root;
|
|
22
25
|
}
|
|
@@ -41,12 +44,15 @@ function createHead(options = {}) {
|
|
|
41
44
|
domDelayFn: (fn) => setTimeout(() => nextTick(() => fn()), 10),
|
|
42
45
|
plugins
|
|
43
46
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
const vuePlugin = {
|
|
48
|
+
install(app) {
|
|
49
|
+
if (Vue3) {
|
|
50
|
+
app.config.globalProperties.$unhead = head;
|
|
51
|
+
app.provide(headSymbol, head);
|
|
52
|
+
}
|
|
48
53
|
}
|
|
49
54
|
};
|
|
55
|
+
head.install = vuePlugin.install;
|
|
50
56
|
return head;
|
|
51
57
|
}
|
|
52
58
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.3",
|
|
5
5
|
"packageManager": "pnpm@7.14.0",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"vue": ">=2.7 || >=3"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@unhead/dom": "0.6.
|
|
37
|
-
"@unhead/schema": "0.6.
|
|
36
|
+
"@unhead/dom": "0.6.3",
|
|
37
|
+
"@unhead/schema": "0.6.3",
|
|
38
38
|
"@vueuse/shared": "latest",
|
|
39
|
-
"unhead": "0.6.
|
|
39
|
+
"unhead": "0.6.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"vue": "^3.2.
|
|
42
|
+
"vue": "^3.2.45"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "unbuild .",
|