initial commit
This commit is contained in:
21
node_modules/@vueuse/head/LICENSE
generated
vendored
Normal file
21
node_modules/@vueuse/head/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 EGOIST (https://egoist.sh)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
129
node_modules/@vueuse/head/README.md
generated
vendored
Normal file
129
node_modules/@vueuse/head/README.md
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
<h1 align='center'>@vueuse/head</h1>
|
||||
|
||||
<p align="center">
|
||||
<a href='https://github.com/harlan-zw/unhead/actions/workflows/test.yml'>
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/@vueuse/head" target="__blank"><img src="https://img.shields.io/npm/v/@vueuse/head?style=flat&colorA=002438&colorB=28CF8D" alt="NPM version"></a>
|
||||
<a href="https://www.npmjs.com/package/@vueuse/head" target="__blank"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/@vueuse/head?flat&colorA=002438&colorB=28CF8D"></a>
|
||||
<a href="https://github.com/vueuse/head" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/vueuse/head?flat&colorA=002438&colorB=28CF8D"></a>
|
||||
</p>
|
||||
|
||||
|
||||
<p align="center">
|
||||
Super-charged document head management for Vue, powered by <a href="https://unhead.harlanzw.com/">unhead</a>.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<table>
|
||||
<tbody>
|
||||
<td align="center">
|
||||
<img width="800" height="0" /><br>
|
||||
Created by <a href="https://github.com/sponsors/egoist">egoist</a>, maintained by <a href="https://github.com/harlan-zw">harlan-zw</a> <br>
|
||||
<sub>💛 Support ongoing development by sponsoring us.</sub><br>
|
||||
<sub>Follow <a href="https://twitter.com/harlan_zw">🐦 @harlan_zw</a> for updates • Join <a href="https://discord.gg/275MBUBvgP">Discord</a> for support</sub><br>
|
||||
<img width="800" height="0" />
|
||||
</td>
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
## ✨ v1 released!
|
||||
|
||||
Read the announcement [post](https://harlanzw.com/blog/vue-use-head-v1), provide any feedback or questions in [this discussion](https://github.com/vueuse/head/discussions/161)
|
||||
|
||||
## Features
|
||||
|
||||
- 💎 Fully typed augmentable Schema
|
||||
- 🧑🤝🧑 Side-effect based DOM patching, plays nicely your existing other tags and attributes
|
||||
- 🍣 Intuitive deduping, sorting, title templates, class merging and more
|
||||
- 🪝 Extensible hook / plugin based API
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm i @vueuse/head
|
||||
# Or Yarn
|
||||
yarn add @vueuse/head
|
||||
```
|
||||
|
||||
> Requires vue >= v3 or >=2.7
|
||||
|
||||
## Usage
|
||||
|
||||
### Vue 3
|
||||
|
||||
Register the Vue plugin:
|
||||
|
||||
```ts
|
||||
import { createApp } from "vue"
|
||||
import { createHead } from "@vueuse/head"
|
||||
|
||||
const app = createApp()
|
||||
const head = createHead()
|
||||
|
||||
app.use(head)
|
||||
|
||||
app.mount("#app")
|
||||
```
|
||||
|
||||
### Vue 2
|
||||
|
||||
Register the Vue plugin:
|
||||
|
||||
```ts
|
||||
import Vue from 'vue'
|
||||
import { createHead, HeadVuePlugin } from "@vueuse/head"
|
||||
|
||||
const head = createHead()
|
||||
// needed for Vue 2
|
||||
Vue.use(HeadVuePlugin, head)
|
||||
Vue.use(head)
|
||||
|
||||
new Vue({
|
||||
render: h => h(App),
|
||||
}).$mount('#app')
|
||||
```
|
||||
|
||||
### SSR Rendering
|
||||
|
||||
```ts
|
||||
import { renderToString } from "@vue/server-renderer"
|
||||
import { renderHeadToString } from "@vueuse/head"
|
||||
|
||||
const appHTML = await renderToString(yourVueApp)
|
||||
|
||||
// `head` is created from `createHead()`
|
||||
const { headTags, htmlAttrs, bodyAttrs, bodyTags } = renderHeadToString(head)
|
||||
|
||||
const finalHTML = `
|
||||
<html${htmlAttrs}>
|
||||
|
||||
<head>
|
||||
${headTags}
|
||||
</head>
|
||||
|
||||
<body${bodyAttrs}>
|
||||
<div id="app">${appHTML}</div>
|
||||
${bodyTags}
|
||||
</body>
|
||||
|
||||
</html>`
|
||||
```
|
||||
|
||||
## Further Documentation
|
||||
|
||||
Refer to the [unhead documentation](https://unhead.harlanzw.com/) for full API reference and more.
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://raw.githubusercontent.com/harlan-zw/static/main/sponsors.svg">
|
||||
<img src='https://raw.githubusercontent.com/harlan-zw/static/main/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [EGOIST](https://egoist.sh)
|
||||
MIT License © 2022-PRESENT [Harlan Wilton](https://github.com/harlan-zw)
|
||||
181
node_modules/@vueuse/head/dist/index.cjs
generated
vendored
Normal file
181
node_modules/@vueuse/head/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
'use strict';
|
||||
|
||||
const vue = require('@unhead/vue');
|
||||
const dom = require('@unhead/dom');
|
||||
const vue$1 = require('vue');
|
||||
const ssr = require('@unhead/ssr');
|
||||
|
||||
function createHead(initHeadObject) {
|
||||
const unhead = vue.createHead();
|
||||
const legacyHead = {
|
||||
unhead,
|
||||
install(app) {
|
||||
if (vue$1.version.startsWith("3")) {
|
||||
app.config.globalProperties.$head = unhead;
|
||||
app.provide("usehead", unhead);
|
||||
}
|
||||
},
|
||||
use(plugin) {
|
||||
unhead.use(plugin);
|
||||
},
|
||||
resolveTags() {
|
||||
return unhead.resolveTags();
|
||||
},
|
||||
headEntries() {
|
||||
return unhead.headEntries();
|
||||
},
|
||||
headTags() {
|
||||
return unhead.resolveTags();
|
||||
},
|
||||
push(input, options) {
|
||||
return unhead.push(input, options);
|
||||
},
|
||||
addEntry(input, options) {
|
||||
return unhead.push(input, options);
|
||||
},
|
||||
addHeadObjs(input, options) {
|
||||
return unhead.push(input, options);
|
||||
},
|
||||
addReactiveEntry(input, options) {
|
||||
const api = vue.useHead(input, options);
|
||||
if (typeof api !== "undefined")
|
||||
return api.dispose;
|
||||
return () => {
|
||||
};
|
||||
},
|
||||
removeHeadObjs() {
|
||||
},
|
||||
updateDOM(document, force) {
|
||||
if (force)
|
||||
dom.renderDOMHead(unhead, { document });
|
||||
else
|
||||
dom.debouncedRenderDOMHead(unhead, { delayFn: (fn) => setTimeout(() => fn(), 50), document });
|
||||
},
|
||||
internalHooks: unhead.hooks,
|
||||
hooks: {
|
||||
"before:dom": [],
|
||||
"resolved:tags": [],
|
||||
"resolved:entries": []
|
||||
}
|
||||
};
|
||||
unhead.addHeadObjs = legacyHead.addHeadObjs;
|
||||
unhead.updateDOM = legacyHead.updateDOM;
|
||||
unhead.hooks.hook("dom:beforeRender", (ctx) => {
|
||||
for (const hook of legacyHead.hooks["before:dom"]) {
|
||||
if (hook() === false)
|
||||
ctx.shouldRender = false;
|
||||
}
|
||||
});
|
||||
if (initHeadObject)
|
||||
legacyHead.addHeadObjs(initHeadObject);
|
||||
return legacyHead;
|
||||
}
|
||||
|
||||
const HeadVuePlugin = vue.Vue2ProvideUnheadPlugin;
|
||||
const renderHeadToString = (head) => ssr.renderSSRHead(head.unhead);
|
||||
|
||||
const Vue2 = vue$1.version.startsWith("2.");
|
||||
const IsBrowser = typeof window !== "undefined";
|
||||
|
||||
const addVNodeToHeadObj = (node, obj) => {
|
||||
const nodeType = Vue2 ? node.tag : node.type;
|
||||
const type = nodeType === "html" ? "htmlAttrs" : nodeType === "body" ? "bodyAttrs" : nodeType;
|
||||
if (typeof type !== "string" || !(type in obj))
|
||||
return;
|
||||
const nodeData = Vue2 ? node.data : node;
|
||||
const props = (Vue2 ? nodeData.attrs : node.props) || {};
|
||||
if (Vue2) {
|
||||
if (nodeData.staticClass)
|
||||
props.class = nodeData.staticClass;
|
||||
if (nodeData.staticStyle)
|
||||
props.style = Object.entries(nodeData.staticStyle).map(([key, value]) => `${key}:${value}`).join(";");
|
||||
}
|
||||
if (node.children) {
|
||||
const childrenAttr = Vue2 ? "text" : "children";
|
||||
props.children = Array.isArray(node.children) ? node.children[0][childrenAttr] : node[childrenAttr];
|
||||
}
|
||||
if (Array.isArray(obj[type]))
|
||||
obj[type].push(props);
|
||||
else if (type === "title")
|
||||
obj.title = props.children;
|
||||
else
|
||||
obj[type] = props;
|
||||
};
|
||||
const vnodesToHeadObj = (nodes) => {
|
||||
const obj = {
|
||||
title: void 0,
|
||||
htmlAttrs: void 0,
|
||||
bodyAttrs: void 0,
|
||||
base: void 0,
|
||||
meta: [],
|
||||
link: [],
|
||||
style: [],
|
||||
script: [],
|
||||
noscript: []
|
||||
};
|
||||
for (const node of nodes) {
|
||||
if (typeof node.type === "symbol" && Array.isArray(node.children)) {
|
||||
for (const childNode of node.children)
|
||||
addVNodeToHeadObj(childNode, obj);
|
||||
} else {
|
||||
addVNodeToHeadObj(node, obj);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
const Head = /* @__PURE__ */ vue$1.defineComponent({
|
||||
name: "Head",
|
||||
setup(_, { slots }) {
|
||||
const head = vue.injectHead();
|
||||
const obj = vue$1.ref({});
|
||||
const entry = head.push(obj);
|
||||
if (IsBrowser) {
|
||||
vue$1.onBeforeUnmount(() => {
|
||||
entry.dispose();
|
||||
});
|
||||
}
|
||||
return () => {
|
||||
vue$1.watchEffect(() => {
|
||||
if (!slots.default)
|
||||
return;
|
||||
entry.patch(vnodesToHeadObj(slots.default()));
|
||||
});
|
||||
return null;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
exports.Vue2ProvideUnheadPlugin = vue.Vue2ProvideUnheadPlugin;
|
||||
exports.VueHeadMixin = vue.VueHeadMixin;
|
||||
exports.createHeadCore = vue.createHeadCore;
|
||||
exports.injectHead = vue.injectHead;
|
||||
exports.unheadVueComposablesImports = vue.unheadVueComposablesImports;
|
||||
exports.useBodyAttrs = vue.useBodyAttrs;
|
||||
exports.useHead = vue.useHead;
|
||||
exports.useHtmlAttrs = vue.useHtmlAttrs;
|
||||
exports.useSeoMeta = vue.useSeoMeta;
|
||||
exports.useServerBodyAttrs = vue.useServerBodyAttrs;
|
||||
exports.useServerHead = vue.useServerHead;
|
||||
exports.useServerHtmlAttrs = vue.useServerHtmlAttrs;
|
||||
exports.useServerTagBase = vue.useServerTagBase;
|
||||
exports.useServerTagLink = vue.useServerTagLink;
|
||||
exports.useServerTagMeta = vue.useServerTagMeta;
|
||||
exports.useServerTagMetaFlat = vue.useServerTagMetaFlat;
|
||||
exports.useServerTagNoscript = vue.useServerTagNoscript;
|
||||
exports.useServerTagScript = vue.useServerTagScript;
|
||||
exports.useServerTagStyle = vue.useServerTagStyle;
|
||||
exports.useServerTagTitle = vue.useServerTagTitle;
|
||||
exports.useServerTitleTemplate = vue.useServerTitleTemplate;
|
||||
exports.useTagBase = vue.useTagBase;
|
||||
exports.useTagLink = vue.useTagLink;
|
||||
exports.useTagMeta = vue.useTagMeta;
|
||||
exports.useTagMetaFlat = vue.useTagMetaFlat;
|
||||
exports.useTagNoscript = vue.useTagNoscript;
|
||||
exports.useTagScript = vue.useTagScript;
|
||||
exports.useTagStyle = vue.useTagStyle;
|
||||
exports.useTagTitle = vue.useTagTitle;
|
||||
exports.useTitleTemplate = vue.useTitleTemplate;
|
||||
exports.Head = Head;
|
||||
exports.HeadVuePlugin = HeadVuePlugin;
|
||||
exports.createHead = createHead;
|
||||
exports.renderHeadToString = renderHeadToString;
|
||||
91
node_modules/@vueuse/head/dist/index.d.ts
generated
vendored
Normal file
91
node_modules/@vueuse/head/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import { HeadTag, MergeHead, MaybeComputedRef, ReactiveHead, VueHeadClient } from '@unhead/vue';
|
||||
export { ActiveHeadEntry, HeadEntryOptions, HeadTag, MaybeComputedRef, MergeHead, ReactiveHead, Unhead, UseHeadInput, Vue2ProvideUnheadPlugin, VueHeadMixin, createHeadCore, injectHead, unheadVueComposablesImports, useBodyAttrs, useHead, useHtmlAttrs, useSeoMeta, useServerBodyAttrs, useServerHead, useServerHtmlAttrs, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate } from '@unhead/vue';
|
||||
import * as _unhead_schema from '@unhead/schema';
|
||||
import { HeadEntry, HeadPlugin, HeadEntryOptions, ActiveHeadEntry, Unhead, Head as Head$1 } from '@unhead/schema';
|
||||
import * as vue from 'vue';
|
||||
import { App, Plugin } from 'vue';
|
||||
|
||||
type HookBeforeDomUpdate = (() => Promise<void | boolean> | void | boolean);
|
||||
type HookTagsResolved = ((tags: HeadTag[]) => Promise<void> | void);
|
||||
type HookEntriesResolved = ((entries: HeadEntry<any>[]) => Promise<void> | void);
|
||||
interface LegacyHeadOptions {
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
resolved?: boolean;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
raw?: boolean;
|
||||
}
|
||||
interface HeadClient<T extends MergeHead = {}> {
|
||||
install: (app: App) => void;
|
||||
resolveTags: () => Promise<HeadTag[]>;
|
||||
use: (plugin: HeadPlugin) => void;
|
||||
headEntries: () => HeadEntry<MaybeComputedRef<ReactiveHead<T>>>[];
|
||||
push: (entry: MaybeComputedRef<ReactiveHead<T>>, options?: HeadEntryOptions) => ActiveHeadEntry<MaybeComputedRef<ReactiveHead<T>>>;
|
||||
/**
|
||||
* @deprecated use `push`
|
||||
*/
|
||||
addEntry: (entry: MaybeComputedRef<ReactiveHead<T>>, options?: HeadEntryOptions & LegacyHeadOptions) => ActiveHeadEntry<MaybeComputedRef<ReactiveHead<T>>>;
|
||||
/**
|
||||
* @deprecated use `push`
|
||||
*/
|
||||
addReactiveEntry: (objs: MaybeComputedRef<ReactiveHead<T>>, options?: HeadEntryOptions & LegacyHeadOptions) => () => void;
|
||||
/**
|
||||
* @deprecated use `@unhead/dom`
|
||||
*/
|
||||
updateDOM: (document?: Document, force?: boolean) => void;
|
||||
internalHooks: Unhead['hooks'];
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
hooks:
|
||||
/**
|
||||
* Array of user provided functions to hook into before the DOM is updated.
|
||||
*
|
||||
* When returning false from this function, it will block DOM updates, this can be useful when stopping dom updates
|
||||
* between page transitions.
|
||||
*
|
||||
* You are able to modify the payload of hook using this.
|
||||
*/
|
||||
Record<'before:dom', HookBeforeDomUpdate[]> & Record<'resolved:entries', HookEntriesResolved[]> &
|
||||
/**
|
||||
* Array of user provided functions to hook into after the tags have been resolved (deduped and sorted).
|
||||
*/
|
||||
Record<'resolved:tags', HookTagsResolved[]>;
|
||||
/**
|
||||
* Backwards compatibility function to fetch the headTags.
|
||||
*
|
||||
* This function forces reactivity resolving and is not performant.
|
||||
*
|
||||
* @deprecated Use `unhead.resolveTags()`.
|
||||
*/
|
||||
headTags: () => Promise<HeadTag[]>;
|
||||
/**
|
||||
* Backwards compatibility function to add a head obj.
|
||||
*
|
||||
* Note: This will not support reactivity. Use `addReactiveEntry` instead.
|
||||
*
|
||||
* @deprecated Use addEntry
|
||||
*/
|
||||
addHeadObjs: (entry: MaybeComputedRef<ReactiveHead<T>>, options?: HeadEntryOptions) => ActiveHeadEntry<MaybeComputedRef<ReactiveHead<T>>>;
|
||||
/**
|
||||
* @deprecated Does not do anything
|
||||
*/
|
||||
removeHeadObjs: (entry: MaybeComputedRef<ReactiveHead<T>>) => void;
|
||||
/**
|
||||
* Access the underlying unhead instance.
|
||||
*/
|
||||
unhead: VueHeadClient<T>;
|
||||
}
|
||||
declare function createHead<T extends MergeHead = {}>(initHeadObject?: Head$1<T>): HeadClient<T>;
|
||||
|
||||
declare const HeadVuePlugin: Plugin;
|
||||
declare const renderHeadToString: <T extends MergeHead = {}>(head: HeadClient<T>) => Promise<_unhead_schema.SSRHeadPayload>;
|
||||
type HeadObjectPlain = Head$1;
|
||||
type HeadObject = ReactiveHead;
|
||||
|
||||
declare const Head: vue.DefineComponent<{}, () => null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{}>>, {}>;
|
||||
|
||||
export { Head, HeadClient, HeadObject, HeadObjectPlain, HeadVuePlugin, HookBeforeDomUpdate, HookEntriesResolved, HookTagsResolved, LegacyHeadOptions, createHead, renderHeadToString };
|
||||
147
node_modules/@vueuse/head/dist/index.mjs
generated
vendored
Normal file
147
node_modules/@vueuse/head/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
import { createHead as createHead$1, useHead, Vue2ProvideUnheadPlugin, injectHead } from '@unhead/vue';
|
||||
export { Vue2ProvideUnheadPlugin, VueHeadMixin, createHeadCore, injectHead, unheadVueComposablesImports, useBodyAttrs, useHead, useHtmlAttrs, useSeoMeta, useServerBodyAttrs, useServerHead, useServerHtmlAttrs, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate } from '@unhead/vue';
|
||||
import { renderDOMHead, debouncedRenderDOMHead } from '@unhead/dom';
|
||||
import { version, defineComponent, ref, onBeforeUnmount, watchEffect } from 'vue';
|
||||
import { renderSSRHead } from '@unhead/ssr';
|
||||
|
||||
function createHead(initHeadObject) {
|
||||
const unhead = createHead$1();
|
||||
const legacyHead = {
|
||||
unhead,
|
||||
install(app) {
|
||||
if (version.startsWith("3")) {
|
||||
app.config.globalProperties.$head = unhead;
|
||||
app.provide("usehead", unhead);
|
||||
}
|
||||
},
|
||||
use(plugin) {
|
||||
unhead.use(plugin);
|
||||
},
|
||||
resolveTags() {
|
||||
return unhead.resolveTags();
|
||||
},
|
||||
headEntries() {
|
||||
return unhead.headEntries();
|
||||
},
|
||||
headTags() {
|
||||
return unhead.resolveTags();
|
||||
},
|
||||
push(input, options) {
|
||||
return unhead.push(input, options);
|
||||
},
|
||||
addEntry(input, options) {
|
||||
return unhead.push(input, options);
|
||||
},
|
||||
addHeadObjs(input, options) {
|
||||
return unhead.push(input, options);
|
||||
},
|
||||
addReactiveEntry(input, options) {
|
||||
const api = useHead(input, options);
|
||||
if (typeof api !== "undefined")
|
||||
return api.dispose;
|
||||
return () => {
|
||||
};
|
||||
},
|
||||
removeHeadObjs() {
|
||||
},
|
||||
updateDOM(document, force) {
|
||||
if (force)
|
||||
renderDOMHead(unhead, { document });
|
||||
else
|
||||
debouncedRenderDOMHead(unhead, { delayFn: (fn) => setTimeout(() => fn(), 50), document });
|
||||
},
|
||||
internalHooks: unhead.hooks,
|
||||
hooks: {
|
||||
"before:dom": [],
|
||||
"resolved:tags": [],
|
||||
"resolved:entries": []
|
||||
}
|
||||
};
|
||||
unhead.addHeadObjs = legacyHead.addHeadObjs;
|
||||
unhead.updateDOM = legacyHead.updateDOM;
|
||||
unhead.hooks.hook("dom:beforeRender", (ctx) => {
|
||||
for (const hook of legacyHead.hooks["before:dom"]) {
|
||||
if (hook() === false)
|
||||
ctx.shouldRender = false;
|
||||
}
|
||||
});
|
||||
if (initHeadObject)
|
||||
legacyHead.addHeadObjs(initHeadObject);
|
||||
return legacyHead;
|
||||
}
|
||||
|
||||
const HeadVuePlugin = Vue2ProvideUnheadPlugin;
|
||||
const renderHeadToString = (head) => renderSSRHead(head.unhead);
|
||||
|
||||
const Vue2 = version.startsWith("2.");
|
||||
const IsBrowser = typeof window !== "undefined";
|
||||
|
||||
const addVNodeToHeadObj = (node, obj) => {
|
||||
const nodeType = Vue2 ? node.tag : node.type;
|
||||
const type = nodeType === "html" ? "htmlAttrs" : nodeType === "body" ? "bodyAttrs" : nodeType;
|
||||
if (typeof type !== "string" || !(type in obj))
|
||||
return;
|
||||
const nodeData = Vue2 ? node.data : node;
|
||||
const props = (Vue2 ? nodeData.attrs : node.props) || {};
|
||||
if (Vue2) {
|
||||
if (nodeData.staticClass)
|
||||
props.class = nodeData.staticClass;
|
||||
if (nodeData.staticStyle)
|
||||
props.style = Object.entries(nodeData.staticStyle).map(([key, value]) => `${key}:${value}`).join(";");
|
||||
}
|
||||
if (node.children) {
|
||||
const childrenAttr = Vue2 ? "text" : "children";
|
||||
props.children = Array.isArray(node.children) ? node.children[0][childrenAttr] : node[childrenAttr];
|
||||
}
|
||||
if (Array.isArray(obj[type]))
|
||||
obj[type].push(props);
|
||||
else if (type === "title")
|
||||
obj.title = props.children;
|
||||
else
|
||||
obj[type] = props;
|
||||
};
|
||||
const vnodesToHeadObj = (nodes) => {
|
||||
const obj = {
|
||||
title: void 0,
|
||||
htmlAttrs: void 0,
|
||||
bodyAttrs: void 0,
|
||||
base: void 0,
|
||||
meta: [],
|
||||
link: [],
|
||||
style: [],
|
||||
script: [],
|
||||
noscript: []
|
||||
};
|
||||
for (const node of nodes) {
|
||||
if (typeof node.type === "symbol" && Array.isArray(node.children)) {
|
||||
for (const childNode of node.children)
|
||||
addVNodeToHeadObj(childNode, obj);
|
||||
} else {
|
||||
addVNodeToHeadObj(node, obj);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
const Head = /* @__PURE__ */ defineComponent({
|
||||
name: "Head",
|
||||
setup(_, { slots }) {
|
||||
const head = injectHead();
|
||||
const obj = ref({});
|
||||
const entry = head.push(obj);
|
||||
if (IsBrowser) {
|
||||
onBeforeUnmount(() => {
|
||||
entry.dispose();
|
||||
});
|
||||
}
|
||||
return () => {
|
||||
watchEffect(() => {
|
||||
if (!slots.default)
|
||||
return;
|
||||
entry.patch(vnodesToHeadObj(slots.default()));
|
||||
});
|
||||
return null;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { Head, HeadVuePlugin, createHead, renderHeadToString };
|
||||
95
node_modules/@vueuse/head/package.json
generated
vendored
Normal file
95
node_modules/@vueuse/head/package.json
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"name": "@vueuse/head",
|
||||
"version": "1.0.22",
|
||||
"packageManager": "pnpm@7.5.0",
|
||||
"description": "Document head manager for Vue 3. SSR ready.",
|
||||
"author": {
|
||||
"name": "EGOIST",
|
||||
"url": "https://egoist.sh"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Harlan Wilton",
|
||||
"url": "https://harlanzw.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vueuse/head"
|
||||
},
|
||||
"keywords": [
|
||||
"vue",
|
||||
"head",
|
||||
"document",
|
||||
"ssr",
|
||||
"meta"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"stub": "unbuild --stub",
|
||||
"build": "unbuild",
|
||||
"play:vite": "vite examples/vite-ssr",
|
||||
"prepublishOnly": "npm run build",
|
||||
"test": "nuxi prepare examples/nuxt3 && vitest",
|
||||
"test:e2e": "vitest tests/e2e",
|
||||
"release": "kanpai",
|
||||
"lint": "eslint \"**/*.{ts,vue,json,yml,tsx}\" --fix"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": ">=2.7 || >=3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@unhead/dom": "^1.0.9",
|
||||
"@unhead/schema": "^1.0.9",
|
||||
"@unhead/ssr": "^1.0.9",
|
||||
"@unhead/vue": "^1.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^0.33.1",
|
||||
"@nuxt/kit": "3.0.0",
|
||||
"@nuxt/test-utils": "3.0.0",
|
||||
"@vitejs/plugin-vue": "^3.2.0",
|
||||
"@vitejs/plugin-vue-jsx": "^2.1.1",
|
||||
"@vue/compiler-sfc": "^3.2.45",
|
||||
"@vue/server-renderer": "^3.2.45",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"eslint": "^8.29.0",
|
||||
"execa": "^6.1.0",
|
||||
"get-port-please": "^2.6.1",
|
||||
"jsdom": "^20.0.3",
|
||||
"kanpai": "^0.11.0",
|
||||
"lint-staged": "^13.1.0",
|
||||
"mlly": "^1.0.0",
|
||||
"nuxt": "^3.0.0",
|
||||
"pathe": "^1.0.0",
|
||||
"playwright": "^1.28.1",
|
||||
"simple-git-hooks": "^2.8.1",
|
||||
"typescript": "^4.9.3",
|
||||
"unbuild": "^1.0.2",
|
||||
"vite": "^3.2.5",
|
||||
"vitest": "^0.25.5",
|
||||
"vue": "^3.2.45",
|
||||
"vue-router": "^4.1.6"
|
||||
},
|
||||
"resolutions": {
|
||||
"@vueuse/head": "link:."
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"pre-commit": "npx lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,vue,json,yml,tsx}": [
|
||||
"eslint \"**/*.{ts,vue,json,yml,tsx}\" --fix"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user