@unhead/vue 0.5.1 → 0.6.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 +20 -15
- package/dist/index.d.ts +31 -26
- package/dist/index.mjs +21 -17
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -239,33 +239,27 @@ function changeKeyCasingDeep(input) {
|
|
|
239
239
|
function clientUseHead(input, options = {}) {
|
|
240
240
|
const head = injectHead();
|
|
241
241
|
const vm = vue.getCurrentInstance();
|
|
242
|
-
if (!vm)
|
|
243
|
-
head.push(input, options);
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
242
|
+
if (!vm)
|
|
243
|
+
return head.push(input, options);
|
|
246
244
|
const resolvedInput = vue.ref({});
|
|
247
245
|
vue.watchEffect(() => {
|
|
248
246
|
resolvedInput.value = resolveUnrefHeadInput(input);
|
|
249
247
|
});
|
|
250
|
-
|
|
251
|
-
vue.watch(resolvedInput, (e) =>
|
|
252
|
-
if (!entry)
|
|
253
|
-
entry = head.push(e, options);
|
|
254
|
-
else
|
|
255
|
-
entry.patch(e);
|
|
256
|
-
}, { immediate: true });
|
|
248
|
+
const entry = head.push(resolvedInput.value, options);
|
|
249
|
+
vue.watch(resolvedInput, (e) => entry.patch(e));
|
|
257
250
|
vue.onBeforeUnmount(() => {
|
|
258
|
-
entry
|
|
251
|
+
entry.dispose();
|
|
259
252
|
});
|
|
253
|
+
return entry;
|
|
260
254
|
}
|
|
261
255
|
|
|
262
256
|
function serverUseHead(input, options = {}) {
|
|
263
257
|
const head = injectHead();
|
|
264
|
-
head.push(input, options);
|
|
258
|
+
return head.push(input, options);
|
|
265
259
|
}
|
|
266
260
|
|
|
267
261
|
function useServerHead(input, options = {}) {
|
|
268
|
-
useHead(input, { ...options, mode: "server" });
|
|
262
|
+
return useHead(input, { ...options, mode: "server" });
|
|
269
263
|
}
|
|
270
264
|
const useServerTagTitle = (title) => useServerHead({ title });
|
|
271
265
|
const useServerTitleTemplate = (titleTemplate) => useServerHead({ titleTemplate });
|
|
@@ -290,7 +284,7 @@ function useHead(input, options = {}) {
|
|
|
290
284
|
const isBrowser = IsBrowser || head.resolvedOptions?.document;
|
|
291
285
|
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
292
286
|
return;
|
|
293
|
-
IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
287
|
+
return IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
294
288
|
}
|
|
295
289
|
const useTagTitle = (title) => useHead({ title });
|
|
296
290
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
|
@@ -310,6 +304,16 @@ const useTagBase = (base) => useHead({ base });
|
|
|
310
304
|
const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
311
305
|
const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
312
306
|
|
|
307
|
+
const coreComposableNames = [
|
|
308
|
+
"injectHead"
|
|
309
|
+
];
|
|
310
|
+
const unheadVueComposablesImports = [
|
|
311
|
+
{
|
|
312
|
+
from: "@unhead/vue",
|
|
313
|
+
imports: [...coreComposableNames, ...unhead.composableNames]
|
|
314
|
+
}
|
|
315
|
+
];
|
|
316
|
+
|
|
313
317
|
exports.Vue2ProvideUnheadPlugin = Vue2ProvideUnheadPlugin;
|
|
314
318
|
exports.VueHeadMixin = VueHeadMixin;
|
|
315
319
|
exports.VueReactiveUseHeadPlugin = VueReactiveUseHeadPlugin;
|
|
@@ -318,6 +322,7 @@ exports.createHead = createHead;
|
|
|
318
322
|
exports.headSymbol = headSymbol;
|
|
319
323
|
exports.injectHead = injectHead;
|
|
320
324
|
exports.resolveUnrefHeadInput = resolveUnrefHeadInput;
|
|
325
|
+
exports.unheadVueComposablesImports = unheadVueComposablesImports;
|
|
321
326
|
exports.useBodyAttrs = useBodyAttrs;
|
|
322
327
|
exports.useHead = useHead;
|
|
323
328
|
exports.useHtmlAttrs = useHtmlAttrs;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MaybeComputedRef, MaybeRef } from '@vueuse/shared';
|
|
2
2
|
export { MaybeComputedRef } from '@vueuse/shared';
|
|
3
3
|
import * as _unhead_schema from '@unhead/schema';
|
|
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, Unhead, CreateHeadOptions, HeadEntryOptions, MetaFlatInput } from '@unhead/schema';
|
|
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, Unhead, CreateHeadOptions, HeadEntryOptions, MetaFlatInput, ActiveHeadEntry } from '@unhead/schema';
|
|
5
5
|
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
|
|
6
6
|
import { Plugin } from 'vue';
|
|
7
7
|
export * from '@unhead/dom';
|
|
@@ -121,30 +121,35 @@ declare const VueReactiveUseHeadPlugin: () => _unhead_schema.HeadPlugin;
|
|
|
121
121
|
|
|
122
122
|
declare const Vue2ProvideUnheadPlugin: Plugin;
|
|
123
123
|
|
|
124
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void
|
|
125
|
-
declare const useServerTagTitle: (title: ReactiveHead['title']) => void
|
|
126
|
-
declare const useServerTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void
|
|
127
|
-
declare const useServerTagMeta: (meta: Arrayable<Meta>) => void
|
|
128
|
-
declare const useServerTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void
|
|
129
|
-
declare const useServerTagLink: (link: Arrayable<Link>) => void
|
|
130
|
-
declare const useServerTagScript: (script: Arrayable<Script>) => void
|
|
131
|
-
declare const useServerTagStyle: (style: Arrayable<Style>) => void
|
|
132
|
-
declare const useServerTagNoscript: (noscript: Arrayable<Noscript>) => void
|
|
133
|
-
declare const useServerTagBase: (base: ReactiveHead['base']) => void
|
|
134
|
-
declare const useServerHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void
|
|
135
|
-
declare const useServerBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void
|
|
124
|
+
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadInput<T>>;
|
|
125
|
+
declare const useServerTagTitle: (title: ReactiveHead['title']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
126
|
+
declare const useServerTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
127
|
+
declare const useServerTagMeta: (meta: Arrayable<Meta>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
128
|
+
declare const useServerTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
129
|
+
declare const useServerTagLink: (link: Arrayable<Link>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
130
|
+
declare const useServerTagScript: (script: Arrayable<Script>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
131
|
+
declare const useServerTagStyle: (style: Arrayable<Style>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
132
|
+
declare const useServerTagNoscript: (noscript: Arrayable<Noscript>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
133
|
+
declare const useServerTagBase: (base: ReactiveHead['base']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
134
|
+
declare const useServerHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
135
|
+
declare const useServerBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
136
136
|
|
|
137
|
-
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void;
|
|
138
|
-
declare const useTagTitle: (title: ReactiveHead['title']) => void
|
|
139
|
-
declare const useTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void
|
|
140
|
-
declare const useTagMeta: (meta: Arrayable<Meta>) => void
|
|
141
|
-
declare const useTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void
|
|
142
|
-
declare const useTagLink: (link: Arrayable<Link>) => void
|
|
143
|
-
declare const useTagScript: (script: Arrayable<Script>) => void
|
|
144
|
-
declare const useTagStyle: (style: Arrayable<Style>) => void
|
|
145
|
-
declare const useTagNoscript: (noscript: Arrayable<Noscript>) => void
|
|
146
|
-
declare const useTagBase: (base: ReactiveHead['base']) => void
|
|
147
|
-
declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void
|
|
148
|
-
declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void
|
|
137
|
+
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
138
|
+
declare const useTagTitle: (title: ReactiveHead['title']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
139
|
+
declare const useTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
140
|
+
declare const useTagMeta: (meta: Arrayable<Meta>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
141
|
+
declare const useTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
142
|
+
declare const useTagLink: (link: Arrayable<Link>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
143
|
+
declare const useTagScript: (script: Arrayable<Script>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
144
|
+
declare const useTagStyle: (style: Arrayable<Style>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
145
|
+
declare const useTagNoscript: (noscript: Arrayable<Noscript>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
146
|
+
declare const useTagBase: (base: ReactiveHead['base']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
147
|
+
declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
148
|
+
declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
declare const unheadVueComposablesImports: {
|
|
151
|
+
from: string;
|
|
152
|
+
imports: string[];
|
|
153
|
+
}[];
|
|
154
|
+
|
|
155
|
+
export { Arrayable, Base, BodyAttributes, HtmlAttributes, Link, MaybeComputedRefEntries, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, UseHeadInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, VueReactiveUseHeadPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, 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,6 +1,6 @@
|
|
|
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 } from 'unhead';
|
|
3
|
+
import { getActiveHead, createHead as createHead$1, defineHeadPlugin, composableNames } from 'unhead';
|
|
4
4
|
export * from '@unhead/dom';
|
|
5
5
|
|
|
6
6
|
function resolveUnrefHeadInput(ref) {
|
|
@@ -237,33 +237,27 @@ function changeKeyCasingDeep(input) {
|
|
|
237
237
|
function clientUseHead(input, options = {}) {
|
|
238
238
|
const head = injectHead();
|
|
239
239
|
const vm = getCurrentInstance();
|
|
240
|
-
if (!vm)
|
|
241
|
-
head.push(input, options);
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
240
|
+
if (!vm)
|
|
241
|
+
return head.push(input, options);
|
|
244
242
|
const resolvedInput = ref({});
|
|
245
243
|
watchEffect(() => {
|
|
246
244
|
resolvedInput.value = resolveUnrefHeadInput(input);
|
|
247
245
|
});
|
|
248
|
-
|
|
249
|
-
watch(resolvedInput, (e) =>
|
|
250
|
-
if (!entry)
|
|
251
|
-
entry = head.push(e, options);
|
|
252
|
-
else
|
|
253
|
-
entry.patch(e);
|
|
254
|
-
}, { immediate: true });
|
|
246
|
+
const entry = head.push(resolvedInput.value, options);
|
|
247
|
+
watch(resolvedInput, (e) => entry.patch(e));
|
|
255
248
|
onBeforeUnmount(() => {
|
|
256
|
-
entry
|
|
249
|
+
entry.dispose();
|
|
257
250
|
});
|
|
251
|
+
return entry;
|
|
258
252
|
}
|
|
259
253
|
|
|
260
254
|
function serverUseHead(input, options = {}) {
|
|
261
255
|
const head = injectHead();
|
|
262
|
-
head.push(input, options);
|
|
256
|
+
return head.push(input, options);
|
|
263
257
|
}
|
|
264
258
|
|
|
265
259
|
function useServerHead(input, options = {}) {
|
|
266
|
-
useHead(input, { ...options, mode: "server" });
|
|
260
|
+
return useHead(input, { ...options, mode: "server" });
|
|
267
261
|
}
|
|
268
262
|
const useServerTagTitle = (title) => useServerHead({ title });
|
|
269
263
|
const useServerTitleTemplate = (titleTemplate) => useServerHead({ titleTemplate });
|
|
@@ -288,7 +282,7 @@ function useHead(input, options = {}) {
|
|
|
288
282
|
const isBrowser = IsBrowser || head.resolvedOptions?.document;
|
|
289
283
|
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
290
284
|
return;
|
|
291
|
-
IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
285
|
+
return IsBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
292
286
|
}
|
|
293
287
|
const useTagTitle = (title) => useHead({ title });
|
|
294
288
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
|
@@ -308,4 +302,14 @@ const useTagBase = (base) => useHead({ base });
|
|
|
308
302
|
const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
309
303
|
const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
310
304
|
|
|
311
|
-
|
|
305
|
+
const coreComposableNames = [
|
|
306
|
+
"injectHead"
|
|
307
|
+
];
|
|
308
|
+
const unheadVueComposablesImports = [
|
|
309
|
+
{
|
|
310
|
+
from: "@unhead/vue",
|
|
311
|
+
imports: [...coreComposableNames, ...composableNames]
|
|
312
|
+
}
|
|
313
|
+
];
|
|
314
|
+
|
|
315
|
+
export { Vue2ProvideUnheadPlugin, VueHeadMixin, VueReactiveUseHeadPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, unheadVueComposablesImports, 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.6.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.6.1",
|
|
37
|
+
"@unhead/schema": "0.6.1",
|
|
38
38
|
"@vueuse/shared": "latest",
|
|
39
|
-
"unhead": "0.
|
|
39
|
+
"unhead": "0.6.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"vue": "^3.2.42"
|