@unhead/vue 1.0.3 → 1.0.5
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 +12 -10
- package/dist/index.mjs +12 -10
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,8 @@ const setAttrs = (ctx, markSideEffect) => {
|
|
|
44
44
|
value = String(value);
|
|
45
45
|
const attrSdeKey = `attr:${k}`;
|
|
46
46
|
if (k === "class") {
|
|
47
|
+
if (!value)
|
|
48
|
+
return;
|
|
47
49
|
for (const c of value.split(" ")) {
|
|
48
50
|
const classSdeKey = `${attrSdeKey}:${c}`;
|
|
49
51
|
if (markSideEffect)
|
|
@@ -582,7 +584,7 @@ const TagEntityBits = 10;
|
|
|
582
584
|
|
|
583
585
|
async function normaliseEntryTags(e) {
|
|
584
586
|
const tagPromises = [];
|
|
585
|
-
Object.entries(e.input).filter(([k, v]) => typeof v !== "undefined" && ValidHeadTags.includes(k)).forEach(([k, value]) => {
|
|
587
|
+
Object.entries(e.resolvedInput || e.input).filter(([k, v]) => typeof v !== "undefined" && ValidHeadTags.includes(k)).forEach(([k, value]) => {
|
|
586
588
|
const v = asArray$1(value);
|
|
587
589
|
tagPromises.push(...v.map((props) => normaliseTag(k, props)).flat());
|
|
588
590
|
});
|
|
@@ -798,7 +800,7 @@ const VueReactiveUseHeadPlugin = () => {
|
|
|
798
800
|
hooks: {
|
|
799
801
|
"entries:resolve": function(ctx) {
|
|
800
802
|
for (const entry of ctx.entries)
|
|
801
|
-
entry.
|
|
803
|
+
entry.resolvedInput = resolveUnrefHeadInput(entry.input);
|
|
802
804
|
}
|
|
803
805
|
}
|
|
804
806
|
});
|
|
@@ -966,18 +968,18 @@ function changeKeyCasingDeep(input) {
|
|
|
966
968
|
|
|
967
969
|
function clientUseHead(input, options = {}) {
|
|
968
970
|
const head = injectHead();
|
|
969
|
-
const vm = vue.getCurrentInstance();
|
|
970
|
-
if (!vm)
|
|
971
|
-
return head.push(input, options);
|
|
972
971
|
const resolvedInput = vue.ref({});
|
|
973
972
|
vue.watchEffect(() => {
|
|
974
973
|
resolvedInput.value = resolveUnrefHeadInput(input);
|
|
975
974
|
});
|
|
976
975
|
const entry = head.push(resolvedInput.value, options);
|
|
977
976
|
vue.watch(resolvedInput, (e) => entry.patch(e));
|
|
978
|
-
vue.
|
|
979
|
-
|
|
980
|
-
|
|
977
|
+
const vm = vue.getCurrentInstance();
|
|
978
|
+
if (vm) {
|
|
979
|
+
vue.onBeforeUnmount(() => {
|
|
980
|
+
entry.dispose();
|
|
981
|
+
});
|
|
982
|
+
}
|
|
981
983
|
return entry;
|
|
982
984
|
}
|
|
983
985
|
|
|
@@ -1009,10 +1011,10 @@ const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
|
1009
1011
|
|
|
1010
1012
|
function useHead(input, options = {}) {
|
|
1011
1013
|
const head = injectHead();
|
|
1012
|
-
const isBrowser = IsBrowser || head.resolvedOptions?.document;
|
|
1014
|
+
const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
|
|
1013
1015
|
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
1014
1016
|
return;
|
|
1015
|
-
return
|
|
1017
|
+
return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
1016
1018
|
}
|
|
1017
1019
|
const useTagTitle = (title) => useHead({ title });
|
|
1018
1020
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
package/dist/index.mjs
CHANGED
|
@@ -42,6 +42,8 @@ const setAttrs = (ctx, markSideEffect) => {
|
|
|
42
42
|
value = String(value);
|
|
43
43
|
const attrSdeKey = `attr:${k}`;
|
|
44
44
|
if (k === "class") {
|
|
45
|
+
if (!value)
|
|
46
|
+
return;
|
|
45
47
|
for (const c of value.split(" ")) {
|
|
46
48
|
const classSdeKey = `${attrSdeKey}:${c}`;
|
|
47
49
|
if (markSideEffect)
|
|
@@ -580,7 +582,7 @@ const TagEntityBits = 10;
|
|
|
580
582
|
|
|
581
583
|
async function normaliseEntryTags(e) {
|
|
582
584
|
const tagPromises = [];
|
|
583
|
-
Object.entries(e.input).filter(([k, v]) => typeof v !== "undefined" && ValidHeadTags.includes(k)).forEach(([k, value]) => {
|
|
585
|
+
Object.entries(e.resolvedInput || e.input).filter(([k, v]) => typeof v !== "undefined" && ValidHeadTags.includes(k)).forEach(([k, value]) => {
|
|
584
586
|
const v = asArray$1(value);
|
|
585
587
|
tagPromises.push(...v.map((props) => normaliseTag(k, props)).flat());
|
|
586
588
|
});
|
|
@@ -796,7 +798,7 @@ const VueReactiveUseHeadPlugin = () => {
|
|
|
796
798
|
hooks: {
|
|
797
799
|
"entries:resolve": function(ctx) {
|
|
798
800
|
for (const entry of ctx.entries)
|
|
799
|
-
entry.
|
|
801
|
+
entry.resolvedInput = resolveUnrefHeadInput(entry.input);
|
|
800
802
|
}
|
|
801
803
|
}
|
|
802
804
|
});
|
|
@@ -964,18 +966,18 @@ function changeKeyCasingDeep(input) {
|
|
|
964
966
|
|
|
965
967
|
function clientUseHead(input, options = {}) {
|
|
966
968
|
const head = injectHead();
|
|
967
|
-
const vm = getCurrentInstance();
|
|
968
|
-
if (!vm)
|
|
969
|
-
return head.push(input, options);
|
|
970
969
|
const resolvedInput = ref({});
|
|
971
970
|
watchEffect(() => {
|
|
972
971
|
resolvedInput.value = resolveUnrefHeadInput(input);
|
|
973
972
|
});
|
|
974
973
|
const entry = head.push(resolvedInput.value, options);
|
|
975
974
|
watch(resolvedInput, (e) => entry.patch(e));
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
975
|
+
const vm = getCurrentInstance();
|
|
976
|
+
if (vm) {
|
|
977
|
+
onBeforeUnmount(() => {
|
|
978
|
+
entry.dispose();
|
|
979
|
+
});
|
|
980
|
+
}
|
|
979
981
|
return entry;
|
|
980
982
|
}
|
|
981
983
|
|
|
@@ -1007,10 +1009,10 @@ const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
|
1007
1009
|
|
|
1008
1010
|
function useHead(input, options = {}) {
|
|
1009
1011
|
const head = injectHead();
|
|
1010
|
-
const isBrowser = IsBrowser || head.resolvedOptions?.document;
|
|
1012
|
+
const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
|
|
1011
1013
|
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
1012
1014
|
return;
|
|
1013
|
-
return
|
|
1015
|
+
return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
1014
1016
|
}
|
|
1015
1017
|
const useTagTitle = (title) => useHead({ title });
|
|
1016
1018
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"packageManager": "pnpm@7.17.
|
|
4
|
+
"version": "1.0.5",
|
|
5
|
+
"packageManager": "pnpm@7.17.1",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"hookable": "^5.4.2",
|
|
37
|
-
"@unhead/schema": "1.0.
|
|
37
|
+
"@unhead/schema": "1.0.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"vue": "^3.2.45",
|
|
41
|
-
"unhead": "1.0.
|
|
41
|
+
"unhead": "1.0.5"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "unbuild .",
|