@unhead/vue 0.1.3 → 0.2.0
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 +15 -13
- package/dist/index.d.ts +12 -7
- package/dist/index.mjs +15 -14
- package/dist/runtime/server/useHead.d.ts +2 -2
- package/dist/runtime/server/useServerHead.d.ts +2 -2
- package/dist/runtimes/client/useHead.d.ts +2 -2
- package/dist/runtimes/client/useServerHead.d.ts +2 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -26,21 +26,16 @@ function asArray(value) {
|
|
|
26
26
|
return Array.isArray(value) ? value : [value];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const VueTriggerDomPatchingOnUpdatesPlugin = () => {
|
|
29
|
+
const VueTriggerDomPatchingOnUpdatesPlugin = (options) => {
|
|
30
30
|
return unhead.defineHeadPlugin({
|
|
31
31
|
hooks: {
|
|
32
32
|
"entries:updated": function(head) {
|
|
33
|
-
dom.debouncedRenderDOMHead(vue.nextTick, head);
|
|
33
|
+
dom.debouncedRenderDOMHead(vue.nextTick, head, { document: options?.document });
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const vueTriggerDomPatchingOnUpdatesPlugin = {
|
|
40
|
-
__proto__: null,
|
|
41
|
-
VueTriggerDomPatchingOnUpdatesPlugin: VueTriggerDomPatchingOnUpdatesPlugin
|
|
42
|
-
};
|
|
43
|
-
|
|
44
39
|
const VueReactiveInputPlugin = () => {
|
|
45
40
|
return unhead.defineHeadPlugin({
|
|
46
41
|
hooks: {
|
|
@@ -112,17 +107,13 @@ const headSymbol = Symbol("unhead");
|
|
|
112
107
|
function injectHead() {
|
|
113
108
|
return vue.getCurrentInstance() && vue.inject(headSymbol) || unhead.getActiveHead();
|
|
114
109
|
}
|
|
115
|
-
|
|
110
|
+
function createHead(options = {}) {
|
|
116
111
|
const plugins = [
|
|
117
112
|
unhead.HydratesStatePlugin(),
|
|
118
113
|
VueReactiveInputPlugin(),
|
|
119
114
|
...options?.plugins || []
|
|
120
115
|
];
|
|
121
|
-
|
|
122
|
-
const { VueTriggerDomPatchingOnUpdatesPlugin } = await Promise.resolve().then(function () { return vueTriggerDomPatchingOnUpdatesPlugin; });
|
|
123
|
-
plugins.push(VueTriggerDomPatchingOnUpdatesPlugin());
|
|
124
|
-
}
|
|
125
|
-
const head = await unhead.createHead({
|
|
116
|
+
const head = unhead.createHead({
|
|
126
117
|
...options,
|
|
127
118
|
plugins
|
|
128
119
|
});
|
|
@@ -148,6 +139,16 @@ async function createHead(options = {}) {
|
|
|
148
139
|
return { ...vuePlugin, ...head };
|
|
149
140
|
}
|
|
150
141
|
|
|
142
|
+
function createDomHead(options = {}) {
|
|
143
|
+
return createHead({
|
|
144
|
+
...options,
|
|
145
|
+
plugins: [
|
|
146
|
+
VueTriggerDomPatchingOnUpdatesPlugin({ document: options?.document }),
|
|
147
|
+
...options.plugins || []
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
151
152
|
const HeadVuePlugin = function(_Vue) {
|
|
152
153
|
_Vue.mixin({
|
|
153
154
|
beforeCreate() {
|
|
@@ -178,6 +179,7 @@ exports.HeadVuePlugin = HeadVuePlugin;
|
|
|
178
179
|
exports.VueReactiveInputPlugin = VueReactiveInputPlugin;
|
|
179
180
|
exports.VueTriggerDomPatchingOnUpdatesPlugin = VueTriggerDomPatchingOnUpdatesPlugin;
|
|
180
181
|
exports.asArray = asArray;
|
|
182
|
+
exports.createDomHead = createDomHead;
|
|
181
183
|
exports.createHead = createHead;
|
|
182
184
|
exports.headSymbol = headSymbol;
|
|
183
185
|
exports.injectHead = injectHead;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export { MaybeComputedRef } from '@vueuse/shared';
|
|
|
3
3
|
import * as _unhead_schema from '@unhead/schema';
|
|
4
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';
|
|
5
5
|
export { ActiveHeadEntry, Head, HeadClient, HeadEntryOptions, HeadTag, MergeHead } from '@unhead/schema';
|
|
6
|
-
import {
|
|
6
|
+
import { RenderDomHeadOptions } from '@unhead/dom';
|
|
7
7
|
export * from '@unhead/dom';
|
|
8
|
+
import { Plugin } from 'vue';
|
|
8
9
|
|
|
9
10
|
declare type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
|
|
10
11
|
[key in keyof T]?: MaybeComputedRef<T[key]>;
|
|
@@ -103,17 +104,17 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
103
104
|
*/
|
|
104
105
|
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
105
106
|
}
|
|
106
|
-
declare type UseHeadInput = MaybeComputedRef<ReactiveHead
|
|
107
|
+
declare type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
|
|
107
108
|
|
|
108
109
|
declare function resolveUnrefHeadInput(ref: any): any;
|
|
109
110
|
declare function asArray<T>(value: Arrayable<T>): T[];
|
|
110
111
|
|
|
111
|
-
declare const VueTriggerDomPatchingOnUpdatesPlugin: () => _unhead_schema.HeadPlugin;
|
|
112
|
+
declare const VueTriggerDomPatchingOnUpdatesPlugin: (options?: RenderDomHeadOptions) => _unhead_schema.HeadPlugin;
|
|
112
113
|
|
|
113
114
|
declare const VueReactiveInputPlugin: () => _unhead_schema.HeadPlugin;
|
|
114
115
|
|
|
115
|
-
declare function useServerHead(input:
|
|
116
|
-
declare function useHead(input: UseHeadInput
|
|
116
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void;
|
|
117
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void;
|
|
117
118
|
declare const useTitle: (title: ReactiveHead['title']) => void;
|
|
118
119
|
declare const useTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void;
|
|
119
120
|
declare const useMeta: (meta: Arrayable<Meta>) => void;
|
|
@@ -128,8 +129,12 @@ declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void;
|
|
|
128
129
|
declare type VueHeadClient<T extends MergeHead> = HeadClient<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
129
130
|
declare const headSymbol: unique symbol;
|
|
130
131
|
declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
|
|
131
|
-
declare function createHead<T extends MergeHead>(options?: CreateHeadOptions):
|
|
132
|
+
declare function createHead<T extends MergeHead>(options?: CreateHeadOptions): VueHeadClient<T>;
|
|
133
|
+
|
|
134
|
+
declare function createDomHead<T extends MergeHead>(options?: CreateHeadOptions & {
|
|
135
|
+
document?: Document;
|
|
136
|
+
}): VueHeadClient<T>;
|
|
132
137
|
|
|
133
138
|
declare const HeadVuePlugin: Plugin;
|
|
134
139
|
|
|
135
|
-
export { Arrayable, Base, BodyAttributes, HeadVuePlugin, HtmlAttributes, Link, MaybeComputedRefEntries, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, UseHeadInput, VueHeadClient, VueReactiveInputPlugin, VueTriggerDomPatchingOnUpdatesPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
|
|
140
|
+
export { Arrayable, Base, BodyAttributes, HeadVuePlugin, HtmlAttributes, Link, MaybeComputedRefEntries, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, UseHeadInput, VueHeadClient, VueReactiveInputPlugin, VueTriggerDomPatchingOnUpdatesPlugin, asArray, createDomHead, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
|
package/dist/index.mjs
CHANGED
|
@@ -25,21 +25,16 @@ function asArray(value) {
|
|
|
25
25
|
return Array.isArray(value) ? value : [value];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const VueTriggerDomPatchingOnUpdatesPlugin = () => {
|
|
28
|
+
const VueTriggerDomPatchingOnUpdatesPlugin = (options) => {
|
|
29
29
|
return defineHeadPlugin({
|
|
30
30
|
hooks: {
|
|
31
31
|
"entries:updated": function(head) {
|
|
32
|
-
debouncedRenderDOMHead(nextTick, head);
|
|
32
|
+
debouncedRenderDOMHead(nextTick, head, { document: options?.document });
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
const vueTriggerDomPatchingOnUpdatesPlugin = {
|
|
39
|
-
__proto__: null,
|
|
40
|
-
VueTriggerDomPatchingOnUpdatesPlugin: VueTriggerDomPatchingOnUpdatesPlugin
|
|
41
|
-
};
|
|
42
|
-
|
|
43
38
|
const VueReactiveInputPlugin = () => {
|
|
44
39
|
return defineHeadPlugin({
|
|
45
40
|
hooks: {
|
|
@@ -111,17 +106,13 @@ const headSymbol = Symbol("unhead");
|
|
|
111
106
|
function injectHead() {
|
|
112
107
|
return getCurrentInstance() && inject(headSymbol) || getActiveHead();
|
|
113
108
|
}
|
|
114
|
-
|
|
109
|
+
function createHead(options = {}) {
|
|
115
110
|
const plugins = [
|
|
116
111
|
HydratesStatePlugin(),
|
|
117
112
|
VueReactiveInputPlugin(),
|
|
118
113
|
...options?.plugins || []
|
|
119
114
|
];
|
|
120
|
-
|
|
121
|
-
const { VueTriggerDomPatchingOnUpdatesPlugin } = await Promise.resolve().then(function () { return vueTriggerDomPatchingOnUpdatesPlugin; });
|
|
122
|
-
plugins.push(VueTriggerDomPatchingOnUpdatesPlugin());
|
|
123
|
-
}
|
|
124
|
-
const head = await createHead$1({
|
|
115
|
+
const head = createHead$1({
|
|
125
116
|
...options,
|
|
126
117
|
plugins
|
|
127
118
|
});
|
|
@@ -147,6 +138,16 @@ async function createHead(options = {}) {
|
|
|
147
138
|
return { ...vuePlugin, ...head };
|
|
148
139
|
}
|
|
149
140
|
|
|
141
|
+
function createDomHead(options = {}) {
|
|
142
|
+
return createHead({
|
|
143
|
+
...options,
|
|
144
|
+
plugins: [
|
|
145
|
+
VueTriggerDomPatchingOnUpdatesPlugin({ document: options?.document }),
|
|
146
|
+
...options.plugins || []
|
|
147
|
+
]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
150
151
|
const HeadVuePlugin = function(_Vue) {
|
|
151
152
|
_Vue.mixin({
|
|
152
153
|
beforeCreate() {
|
|
@@ -173,4 +174,4 @@ const HeadVuePlugin = function(_Vue) {
|
|
|
173
174
|
});
|
|
174
175
|
};
|
|
175
176
|
|
|
176
|
-
export { HeadVuePlugin, VueReactiveInputPlugin, VueTriggerDomPatchingOnUpdatesPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
|
|
177
|
+
export { HeadVuePlugin, VueReactiveInputPlugin, VueTriggerDomPatchingOnUpdatesPlugin, asArray, createDomHead, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { HeadEntryOptions } from '@unhead/schema';
|
|
1
|
+
import type { HeadEntryOptions, MergeHead } from '@unhead/schema';
|
|
2
2
|
import type { UseHeadInput } from '../..';
|
|
3
|
-
export declare function useHead(input: UseHeadInput
|
|
3
|
+
export declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { HeadEntryOptions } from '@unhead/schema';
|
|
1
|
+
import type { HeadEntryOptions, MergeHead } from '@unhead/schema';
|
|
2
2
|
import type { UseHeadInput } from '../../types';
|
|
3
|
-
export declare function useServerHead(input: UseHeadInput
|
|
3
|
+
export declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { HeadEntryOptions } from '@unhead/schema';
|
|
1
|
+
import type { HeadEntryOptions, MergeHead } from '@unhead/schema';
|
|
2
2
|
import type { UseHeadInput } from '../../index';
|
|
3
|
-
export declare function useHead(input: UseHeadInput
|
|
3
|
+
export declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { HeadEntryOptions } from '@unhead/schema';
|
|
1
|
+
import type { HeadEntryOptions, MergeHead } from '@unhead/schema';
|
|
2
2
|
import type { UseHeadInput } from '../../types';
|
|
3
|
-
export declare function useServerHead(input: UseHeadInput
|
|
3
|
+
export declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void;
|
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.2.0",
|
|
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.2.0",
|
|
37
|
+
"@unhead/schema": "0.2.0",
|
|
38
38
|
"@vueuse/shared": "latest",
|
|
39
|
-
"unhead": "0.
|
|
39
|
+
"unhead": "0.2.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"vue": "latest"
|