@unhead/vue 0.6.0 → 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 +9 -15
- package/dist/index.d.ts +25 -25
- package/dist/index.mjs +9 -15
- 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 });
|
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,31 +121,31 @@ 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
151
|
from: string;
|
package/dist/index.mjs
CHANGED
|
@@ -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 });
|
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.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.6.
|
|
37
|
-
"@unhead/schema": "0.6.
|
|
36
|
+
"@unhead/dom": "0.6.1",
|
|
37
|
+
"@unhead/schema": "0.6.1",
|
|
38
38
|
"@vueuse/shared": "latest",
|
|
39
|
-
"unhead": "0.6.
|
|
39
|
+
"unhead": "0.6.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"vue": "^3.2.42"
|