feature: vor und nachteile

This commit is contained in:
Hikyu
2026-05-31 13:54:31 +02:00
parent 552a947a1c
commit e3dad17446
23270 changed files with 3024794 additions and 200 deletions
+37
View File
@@ -0,0 +1,37 @@
import { ref, watchEffect, watch, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
import { i as injectHead, r as resolveUnrefHeadInput } from './vue.ziyDaVMR.mjs';
function useHead(input, options = {}) {
const head = options.head || injectHead();
if (head) {
if (!head.ssr)
return clientUseHead(head, input, options);
return head.push(input, options);
}
}
function clientUseHead(head, input, options = {}) {
const deactivated = ref(false);
const resolvedInput = ref({});
watchEffect(() => {
resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
});
const entry = head.push(resolvedInput.value, options);
watch(resolvedInput, (e) => {
entry.patch(e);
});
const vm = getCurrentInstance();
if (vm) {
onBeforeUnmount(() => {
entry.dispose();
});
onDeactivated(() => {
deactivated.value = true;
});
onActivated(() => {
deactivated.value = false;
});
}
return entry;
}
export { useHead as u };
+39
View File
@@ -0,0 +1,39 @@
'use strict';
const vue = require('vue');
const injectHead = require('./vue.DWlmwWrc.cjs');
function useHead(input, options = {}) {
const head = options.head || injectHead.injectHead();
if (head) {
if (!head.ssr)
return clientUseHead(head, input, options);
return head.push(input, options);
}
}
function clientUseHead(head, input, options = {}) {
const deactivated = vue.ref(false);
const resolvedInput = vue.ref({});
vue.watchEffect(() => {
resolvedInput.value = deactivated.value ? {} : injectHead.resolveUnrefHeadInput(input);
});
const entry = head.push(resolvedInput.value, options);
vue.watch(resolvedInput, (e) => {
entry.patch(e);
});
const vm = vue.getCurrentInstance();
if (vm) {
vue.onBeforeUnmount(() => {
entry.dispose();
});
vue.onDeactivated(() => {
deactivated.value = true;
});
vue.onActivated(() => {
deactivated.value = false;
});
}
return entry;
}
exports.useHead = useHead;
+94
View File
@@ -0,0 +1,94 @@
'use strict';
const unhead = require('unhead');
const vue = require('vue');
const shared = require('@unhead/shared');
const Vue3 = vue.version[0] === "3";
function resolveUnref(r) {
return typeof r === "function" ? r() : vue.unref(r);
}
function resolveUnrefHeadInput(ref) {
if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
return ref;
const root = resolveUnref(ref);
if (!ref || !root)
return root;
if (Array.isArray(root))
return root.map((r) => resolveUnrefHeadInput(r));
if (typeof root === "object") {
const resolved = {};
for (const k in root) {
if (!Object.prototype.hasOwnProperty.call(root, k)) {
continue;
}
if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
resolved[k] = vue.unref(root[k]);
continue;
}
resolved[k] = resolveUnrefHeadInput(root[k]);
}
return resolved;
}
return root;
}
const VueReactivityPlugin = shared.defineHeadPlugin({
hooks: {
"entries:resolve": (ctx) => {
for (const entry of ctx.entries)
entry.resolvedInput = resolveUnrefHeadInput(entry.input);
}
}
});
const headSymbol = "usehead";
function vueInstall(head) {
const plugin = {
install(app) {
if (Vue3) {
app.config.globalProperties.$unhead = head;
app.config.globalProperties.$head = head;
app.provide(headSymbol, head);
}
}
};
return plugin.install;
}
function createServerHead(options = {}) {
const head = unhead.createServerHead(options);
head.use(VueReactivityPlugin);
head.install = vueInstall(head);
return head;
}
function createHead(options = {}) {
options.domDelayFn = options.domDelayFn || ((fn) => vue.nextTick(() => setTimeout(() => fn(), 0)));
const head = unhead.createHead(options);
head.use(VueReactivityPlugin);
head.install = vueInstall(head);
return head;
}
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
const globalKey = "__unhead_injection_handler__";
function setHeadInjectionHandler(handler) {
_global[globalKey] = handler;
}
function injectHead() {
if (globalKey in _global) {
return _global[globalKey]();
}
const head = vue.inject(headSymbol);
if (!head && process.env.NODE_ENV !== "production")
console.warn("Unhead is missing Vue context, falling back to shared context. This may have unexpected results.");
return head || unhead.getActiveHead();
}
exports.Vue3 = Vue3;
exports.createHead = createHead;
exports.createServerHead = createServerHead;
exports.headSymbol = headSymbol;
exports.injectHead = injectHead;
exports.resolveUnrefHeadInput = resolveUnrefHeadInput;
exports.setHeadInjectionHandler = setHeadInjectionHandler;
+132
View File
@@ -0,0 +1,132 @@
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, 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, MaybeFunctionEntries, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead } from '@unhead/schema';
import { ComputedRef, Ref, Plugin } from 'vue';
type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
type MaybeComputedRefOrFalsy<T> = undefined | false | null | T | MaybeReadonlyRef<T> | Ref<T>;
/**
* @deprecated Use MaybeComputedRefOrFalsy
*/
type MaybeComputedRefOrPromise<T> = MaybeComputedRefOrFalsy<T>;
type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
[key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
};
type MaybeComputedRefEntriesOnly<T> = {
[key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
};
interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
/**
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
*/
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
}
interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
/**
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
*/
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
/**
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
*/
style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
}
type Title = MaybeComputedRef<Title$1>;
type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
type Base<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
type Link<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Link$1<E>>;
type Meta<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Meta$1<E>>;
type Style<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Style$1<E>>;
type Script<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Script$1<E>>;
type Noscript<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Noscript$1<E>>;
type HtmlAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
type BodyAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeFunctionEntries<BodyEvents>>;
interface ReactiveHead<E extends MergeHead = MergeHead> {
/**
* The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
* It only contains text; tags within the element are ignored.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
*/
title?: Title;
/**
* Generate the title from a template.
*/
titleTemplate?: TitleTemplate;
/**
* Variables used to substitute in the title and meta content.
*/
templateParams?: MaybeComputedRefEntries<{
separator?: '|' | '-' | '·' | string;
} & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
/**
* The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
* There can be only one <base> element in a document.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
*/
base?: Base<E['base']>;
/**
* The `<link>` HTML element specifies relationships between the current document and an external resource.
* This element is most commonly used to link to stylesheets, but is also used to establish site icons
* (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
*/
link?: MaybeComputedRef<Link<E['link']>[]>;
/**
* The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
*/
meta?: MaybeComputedRef<Meta<E['meta']>[]>;
/**
* The `<style>` HTML element contains style information for a document, or part of a document.
* It contains CSS, which is applied to the contents of the document containing the `<style>` element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
*/
style?: MaybeComputedRef<(Style<E['style']> | string)[]>;
/**
* The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
*/
script?: MaybeComputedRef<(Script<E['script']> | string)[]>;
/**
* The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
* or if scripting is currently turned off in the browser.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
*/
noscript?: MaybeComputedRef<(Noscript<E['noscript']> | string)[]>;
/**
* Attributes for the `<html>` HTML element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
*/
htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
/**
* Attributes for the `<body>` HTML element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
*/
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
}
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
head?: VueHeadClient<any>;
};
type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
title?: ReactiveHead['title'];
titleTemplate?: ReactiveHead['titleTemplate'];
};
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a, UseHeadOptions as b, MaybeComputedRefEntriesOnly as c, UseSeoMetaInput as d, TitleTemplate as e, Base as f, Meta as g, Script as h, HtmlAttributes as i, BodyAttributes as j, MaybeReadonlyRef as k, MaybeComputedRefOrFalsy as l, MaybeComputedRefOrPromise as m };
+132
View File
@@ -0,0 +1,132 @@
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, 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, MaybeFunctionEntries, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead } from '@unhead/schema';
import { ComputedRef, Ref, Plugin } from 'vue';
type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
type MaybeComputedRefOrFalsy<T> = undefined | false | null | T | MaybeReadonlyRef<T> | Ref<T>;
/**
* @deprecated Use MaybeComputedRefOrFalsy
*/
type MaybeComputedRefOrPromise<T> = MaybeComputedRefOrFalsy<T>;
type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
[key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
};
type MaybeComputedRefEntriesOnly<T> = {
[key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
};
interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
/**
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
*/
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
}
interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
/**
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
*/
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
/**
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
*/
style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
}
type Title = MaybeComputedRef<Title$1>;
type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
type Base<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
type Link<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Link$1<E>>;
type Meta<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Meta$1<E>>;
type Style<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Style$1<E>>;
type Script<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Script$1<E>>;
type Noscript<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Noscript$1<E>>;
type HtmlAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
type BodyAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeFunctionEntries<BodyEvents>>;
interface ReactiveHead<E extends MergeHead = MergeHead> {
/**
* The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
* It only contains text; tags within the element are ignored.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
*/
title?: Title;
/**
* Generate the title from a template.
*/
titleTemplate?: TitleTemplate;
/**
* Variables used to substitute in the title and meta content.
*/
templateParams?: MaybeComputedRefEntries<{
separator?: '|' | '-' | '·' | string;
} & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
/**
* The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
* There can be only one <base> element in a document.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
*/
base?: Base<E['base']>;
/**
* The `<link>` HTML element specifies relationships between the current document and an external resource.
* This element is most commonly used to link to stylesheets, but is also used to establish site icons
* (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
*/
link?: MaybeComputedRef<Link<E['link']>[]>;
/**
* The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
*/
meta?: MaybeComputedRef<Meta<E['meta']>[]>;
/**
* The `<style>` HTML element contains style information for a document, or part of a document.
* It contains CSS, which is applied to the contents of the document containing the `<style>` element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
*/
style?: MaybeComputedRef<(Style<E['style']> | string)[]>;
/**
* The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
*/
script?: MaybeComputedRef<(Script<E['script']> | string)[]>;
/**
* The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
* or if scripting is currently turned off in the browser.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
*/
noscript?: MaybeComputedRef<(Noscript<E['noscript']> | string)[]>;
/**
* Attributes for the `<html>` HTML element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
*/
htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
/**
* Attributes for the `<body>` HTML element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
*/
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
}
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
head?: VueHeadClient<any>;
};
type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
title?: ReactiveHead['title'];
titleTemplate?: ReactiveHead['titleTemplate'];
};
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a, UseHeadOptions as b, MaybeComputedRefEntriesOnly as c, UseSeoMetaInput as d, TitleTemplate as e, Base as f, Meta as g, Script as h, HtmlAttributes as i, BodyAttributes as j, MaybeReadonlyRef as k, MaybeComputedRefOrFalsy as l, MaybeComputedRefOrPromise as m };
+132
View File
@@ -0,0 +1,132 @@
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, 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, MaybeFunctionEntries, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead } from '@unhead/schema';
import { ComputedRef, Ref, Plugin } from 'vue';
type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
type MaybeComputedRefOrFalsy<T> = undefined | false | null | T | MaybeReadonlyRef<T> | Ref<T>;
/**
* @deprecated Use MaybeComputedRefOrFalsy
*/
type MaybeComputedRefOrPromise<T> = MaybeComputedRefOrFalsy<T>;
type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
[key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
};
type MaybeComputedRefEntriesOnly<T> = {
[key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
};
interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
/**
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
*/
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
}
interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
/**
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
*/
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
/**
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
*/
style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
}
type Title = MaybeComputedRef<Title$1>;
type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
type Base<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
type Link<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Link$1<E>>;
type Meta<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Meta$1<E>>;
type Style<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Style$1<E>>;
type Script<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Script$1<E>>;
type Noscript<E extends EntryAugmentation = {}> = MaybeComputedRefEntries<Noscript$1<E>>;
type HtmlAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
type BodyAttributes<E extends EntryAugmentation = {}> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeFunctionEntries<BodyEvents>>;
interface ReactiveHead<E extends MergeHead = MergeHead> {
/**
* The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
* It only contains text; tags within the element are ignored.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
*/
title?: Title;
/**
* Generate the title from a template.
*/
titleTemplate?: TitleTemplate;
/**
* Variables used to substitute in the title and meta content.
*/
templateParams?: MaybeComputedRefEntries<{
separator?: '|' | '-' | '·' | string;
} & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
/**
* The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
* There can be only one <base> element in a document.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
*/
base?: Base<E['base']>;
/**
* The `<link>` HTML element specifies relationships between the current document and an external resource.
* This element is most commonly used to link to stylesheets, but is also used to establish site icons
* (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
*/
link?: MaybeComputedRef<Link<E['link']>[]>;
/**
* The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
*/
meta?: MaybeComputedRef<Meta<E['meta']>[]>;
/**
* The `<style>` HTML element contains style information for a document, or part of a document.
* It contains CSS, which is applied to the contents of the document containing the `<style>` element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
*/
style?: MaybeComputedRef<(Style<E['style']> | string)[]>;
/**
* The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
*/
script?: MaybeComputedRef<(Script<E['script']> | string)[]>;
/**
* The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
* or if scripting is currently turned off in the browser.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
*/
noscript?: MaybeComputedRef<(Noscript<E['noscript']> | string)[]>;
/**
* Attributes for the `<html>` HTML element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
*/
htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
/**
* Attributes for the `<body>` HTML element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
*/
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
}
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
head?: VueHeadClient<any>;
};
type UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
title?: ReactiveHead['title'];
titleTemplate?: ReactiveHead['titleTemplate'];
};
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
export type { BodyAttr as B, HtmlAttr as H, Link as L, MaybeComputedRefEntries as M, Noscript as N, ReactiveHead as R, Style as S, Title as T, UseHeadInput as U, VueHeadClient as V, MaybeComputedRef as a, UseHeadOptions as b, MaybeComputedRefEntriesOnly as c, UseSeoMetaInput as d, TitleTemplate as e, Base as f, Meta as g, Script as h, HtmlAttributes as i, BodyAttributes as j, MaybeReadonlyRef as k, MaybeComputedRefOrFalsy as l, MaybeComputedRefOrPromise as m };
+86
View File
@@ -0,0 +1,86 @@
import { createServerHead as createServerHead$1, createHead as createHead$1, getActiveHead } from 'unhead';
import { version, unref, nextTick, inject } from 'vue';
import { defineHeadPlugin } from '@unhead/shared';
const Vue3 = version[0] === "3";
function resolveUnref(r) {
return typeof r === "function" ? r() : unref(r);
}
function resolveUnrefHeadInput(ref) {
if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
return ref;
const root = resolveUnref(ref);
if (!ref || !root)
return root;
if (Array.isArray(root))
return root.map((r) => resolveUnrefHeadInput(r));
if (typeof root === "object") {
const resolved = {};
for (const k in root) {
if (!Object.prototype.hasOwnProperty.call(root, k)) {
continue;
}
if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
resolved[k] = unref(root[k]);
continue;
}
resolved[k] = resolveUnrefHeadInput(root[k]);
}
return resolved;
}
return root;
}
const VueReactivityPlugin = defineHeadPlugin({
hooks: {
"entries:resolve": (ctx) => {
for (const entry of ctx.entries)
entry.resolvedInput = resolveUnrefHeadInput(entry.input);
}
}
});
const headSymbol = "usehead";
function vueInstall(head) {
const plugin = {
install(app) {
if (Vue3) {
app.config.globalProperties.$unhead = head;
app.config.globalProperties.$head = head;
app.provide(headSymbol, head);
}
}
};
return plugin.install;
}
function createServerHead(options = {}) {
const head = createServerHead$1(options);
head.use(VueReactivityPlugin);
head.install = vueInstall(head);
return head;
}
function createHead(options = {}) {
options.domDelayFn = options.domDelayFn || ((fn) => nextTick(() => setTimeout(() => fn(), 0)));
const head = createHead$1(options);
head.use(VueReactivityPlugin);
head.install = vueInstall(head);
return head;
}
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
const globalKey = "__unhead_injection_handler__";
function setHeadInjectionHandler(handler) {
_global[globalKey] = handler;
}
function injectHead() {
if (globalKey in _global) {
return _global[globalKey]();
}
const head = inject(headSymbol);
if (!head && process.env.NODE_ENV !== "production")
console.warn("Unhead is missing Vue context, falling back to shared context. This may have unexpected results.");
return head || getActiveHead();
}
export { Vue3 as V, createServerHead as a, createHead as c, headSymbol as h, injectHead as i, resolveUnrefHeadInput as r, setHeadInjectionHandler as s };