@unhead/vue 0.1.2 → 0.1.4
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 +10 -7
- package/dist/index.d.ts +8 -6
- package/dist/index.mjs +8 -7
- package/package.json +6 -4
package/dist/index.cjs
CHANGED
|
@@ -54,7 +54,7 @@ const VueReactiveInputPlugin = () => {
|
|
|
54
54
|
|
|
55
55
|
const Vue3 = vue.version.startsWith("3");
|
|
56
56
|
vue.version.startsWith("2.");
|
|
57
|
-
const
|
|
57
|
+
const IsBrowser = typeof window !== "undefined";
|
|
58
58
|
|
|
59
59
|
function useHead$2(input, options = {}) {
|
|
60
60
|
const head = injectHead();
|
|
@@ -89,13 +89,13 @@ function useHead$1(input, options = {}) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function useServerHead(input, options = {}) {
|
|
92
|
-
if (!
|
|
92
|
+
if (!IsBrowser)
|
|
93
93
|
useServerHead$1(input, options);
|
|
94
94
|
}
|
|
95
95
|
function useHead(input, options = {}) {
|
|
96
|
-
if (options.mode === "server" &&
|
|
96
|
+
if (options.mode === "server" && IsBrowser || options.mode === "client" && !IsBrowser)
|
|
97
97
|
return;
|
|
98
|
-
|
|
98
|
+
IsBrowser ? useHead$1(input, options) : useHead$2(input, options);
|
|
99
99
|
}
|
|
100
100
|
const useTitle = (title) => useHead({ title });
|
|
101
101
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
|
@@ -108,7 +108,7 @@ const useBase = (base) => useHead({ base });
|
|
|
108
108
|
const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
109
109
|
const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
110
110
|
|
|
111
|
-
const headSymbol = Symbol("
|
|
111
|
+
const headSymbol = Symbol("unhead");
|
|
112
112
|
function injectHead() {
|
|
113
113
|
return vue.getCurrentInstance() && vue.inject(headSymbol) || unhead.getActiveHead();
|
|
114
114
|
}
|
|
@@ -118,7 +118,7 @@ async function createHead(options = {}) {
|
|
|
118
118
|
VueReactiveInputPlugin(),
|
|
119
119
|
...options?.plugins || []
|
|
120
120
|
];
|
|
121
|
-
if (
|
|
121
|
+
if (IsBrowser) {
|
|
122
122
|
const { VueTriggerDomPatchingOnUpdatesPlugin } = await Promise.resolve().then(function () { return vueTriggerDomPatchingOnUpdatesPlugin; });
|
|
123
123
|
plugins.push(VueTriggerDomPatchingOnUpdatesPlugin());
|
|
124
124
|
}
|
|
@@ -140,7 +140,7 @@ async function createHead(options = {}) {
|
|
|
140
140
|
if (!options2 || !("head" in options2))
|
|
141
141
|
return;
|
|
142
142
|
const source = typeof options2.head === "function" ? () => options2.head() : options2.head;
|
|
143
|
-
|
|
143
|
+
useHead(source);
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
}
|
|
@@ -194,3 +194,6 @@ exports.useServerHead = useServerHead;
|
|
|
194
194
|
exports.useStyle = useStyle;
|
|
195
195
|
exports.useTitle = useTitle;
|
|
196
196
|
exports.useTitleTemplate = useTitleTemplate;
|
|
197
|
+
for (const k in dom) {
|
|
198
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = dom[k];
|
|
199
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { MaybeComputedRef, MaybeRef } from '@vueuse/shared';
|
|
2
|
+
export { MaybeComputedRef } from '@vueuse/shared';
|
|
2
3
|
import * as _unhead_schema from '@unhead/schema';
|
|
3
4
|
import { 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, MergeHead, BaseHtmlAttr, MaybeArray, BaseBodyAttr, HeadEntryOptions, HeadClient, CreateHeadOptions } from '@unhead/schema';
|
|
4
|
-
export { HeadTag, MergeHead } from '@unhead/schema';
|
|
5
|
-
import { Plugin
|
|
5
|
+
export { ActiveHeadEntry, Head, HeadClient, HeadEntryOptions, HeadTag, MergeHead } from '@unhead/schema';
|
|
6
|
+
import { Plugin } from 'vue';
|
|
7
|
+
export * from '@unhead/dom';
|
|
6
8
|
|
|
7
9
|
declare type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
|
|
8
10
|
[key in keyof T]?: MaybeComputedRef<T[key]>;
|
|
@@ -123,10 +125,10 @@ declare const useBase: (base: ReactiveHead['base']) => void;
|
|
|
123
125
|
declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void;
|
|
124
126
|
declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void;
|
|
125
127
|
|
|
126
|
-
declare type VueHeadClient = HeadClient<
|
|
127
|
-
declare const headSymbol:
|
|
128
|
-
declare function injectHead(): VueHeadClient
|
|
129
|
-
declare function createHead(options?: CreateHeadOptions): Promise<VueHeadClient
|
|
128
|
+
declare type VueHeadClient<T extends MergeHead> = HeadClient<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
129
|
+
declare const headSymbol: unique symbol;
|
|
130
|
+
declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
|
|
131
|
+
declare function createHead<T extends MergeHead>(options?: CreateHeadOptions): Promise<VueHeadClient<T>>;
|
|
130
132
|
|
|
131
133
|
declare const HeadVuePlugin: Plugin;
|
|
132
134
|
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { resolveUnref } from '@vueuse/shared';
|
|
|
2
2
|
import { unref, nextTick, version, getCurrentInstance, ref, watchEffect, watch, onBeforeUnmount, inject } from 'vue';
|
|
3
3
|
import { defineHeadPlugin, getActiveHead, HydratesStatePlugin, createHead as createHead$1 } from 'unhead';
|
|
4
4
|
import { debouncedRenderDOMHead } from '@unhead/dom';
|
|
5
|
+
export * from '@unhead/dom';
|
|
5
6
|
|
|
6
7
|
function resolveUnrefHeadInput(ref) {
|
|
7
8
|
const root = resolveUnref(ref);
|
|
@@ -52,7 +53,7 @@ const VueReactiveInputPlugin = () => {
|
|
|
52
53
|
|
|
53
54
|
const Vue3 = version.startsWith("3");
|
|
54
55
|
version.startsWith("2.");
|
|
55
|
-
const
|
|
56
|
+
const IsBrowser = typeof window !== "undefined";
|
|
56
57
|
|
|
57
58
|
function useHead$2(input, options = {}) {
|
|
58
59
|
const head = injectHead();
|
|
@@ -87,13 +88,13 @@ function useHead$1(input, options = {}) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
function useServerHead(input, options = {}) {
|
|
90
|
-
if (!
|
|
91
|
+
if (!IsBrowser)
|
|
91
92
|
useServerHead$1(input, options);
|
|
92
93
|
}
|
|
93
94
|
function useHead(input, options = {}) {
|
|
94
|
-
if (options.mode === "server" &&
|
|
95
|
+
if (options.mode === "server" && IsBrowser || options.mode === "client" && !IsBrowser)
|
|
95
96
|
return;
|
|
96
|
-
|
|
97
|
+
IsBrowser ? useHead$1(input, options) : useHead$2(input, options);
|
|
97
98
|
}
|
|
98
99
|
const useTitle = (title) => useHead({ title });
|
|
99
100
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
|
@@ -106,7 +107,7 @@ const useBase = (base) => useHead({ base });
|
|
|
106
107
|
const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
107
108
|
const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
108
109
|
|
|
109
|
-
const headSymbol = Symbol("
|
|
110
|
+
const headSymbol = Symbol("unhead");
|
|
110
111
|
function injectHead() {
|
|
111
112
|
return getCurrentInstance() && inject(headSymbol) || getActiveHead();
|
|
112
113
|
}
|
|
@@ -116,7 +117,7 @@ async function createHead(options = {}) {
|
|
|
116
117
|
VueReactiveInputPlugin(),
|
|
117
118
|
...options?.plugins || []
|
|
118
119
|
];
|
|
119
|
-
if (
|
|
120
|
+
if (IsBrowser) {
|
|
120
121
|
const { VueTriggerDomPatchingOnUpdatesPlugin } = await Promise.resolve().then(function () { return vueTriggerDomPatchingOnUpdatesPlugin; });
|
|
121
122
|
plugins.push(VueTriggerDomPatchingOnUpdatesPlugin());
|
|
122
123
|
}
|
|
@@ -138,7 +139,7 @@ async function createHead(options = {}) {
|
|
|
138
139
|
if (!options2 || !("head" in options2))
|
|
139
140
|
return;
|
|
140
141
|
const source = typeof options2.head === "function" ? () => options2.head() : options2.head;
|
|
141
|
-
|
|
142
|
+
useHead(source);
|
|
142
143
|
}
|
|
143
144
|
});
|
|
144
145
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"packageManager": "pnpm@7.14.0",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
|
+
"require": "./dist/index.cjs",
|
|
22
23
|
"import": "./dist/index.mjs"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
26
|
+
"main": "dist/index.cjs",
|
|
25
27
|
"module": "dist/index.mjs",
|
|
26
28
|
"types": "dist/index.d.ts",
|
|
27
29
|
"files": [
|
|
@@ -31,10 +33,10 @@
|
|
|
31
33
|
"vue": ">=2.7 || >=3"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"@unhead/dom": "0.1.
|
|
35
|
-
"@unhead/schema": "0.1.
|
|
36
|
+
"@unhead/dom": "0.1.4",
|
|
37
|
+
"@unhead/schema": "0.1.4",
|
|
36
38
|
"@vueuse/shared": "latest",
|
|
37
|
-
"unhead": "0.1.
|
|
39
|
+
"unhead": "0.1.4"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"vue": "latest"
|