initial commit
This commit is contained in:
12
node_modules/@unhead/dom/README.md
generated
vendored
Normal file
12
node_modules/@unhead/dom/README.md
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# @unhead/dom
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
# yarn add @unhead/dom
|
||||
npm install @unhead/dom
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
See the [@unhead/dom](https://unhead.harlanzw.com/guide/getting-started/how-it-works#unheaddom) for how this works.
|
||||
199
node_modules/@unhead/dom/dist/index.cjs
generated
vendored
Normal file
199
node_modules/@unhead/dom/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
'use strict';
|
||||
|
||||
const TagsWithInnerContent = ["script", "style", "noscript"];
|
||||
const HasElementTags = [
|
||||
"base",
|
||||
"meta",
|
||||
"link",
|
||||
"style",
|
||||
"script",
|
||||
"noscript"
|
||||
];
|
||||
|
||||
const UniqueTags = ["base", "title", "titleTemplate", "bodyAttrs", "htmlAttrs"];
|
||||
function tagDedupeKey(tag, fn) {
|
||||
const { props, tag: tagName } = tag;
|
||||
if (UniqueTags.includes(tagName))
|
||||
return tagName;
|
||||
if (tagName === "link" && props.rel === "canonical")
|
||||
return "canonical";
|
||||
if (props.charset)
|
||||
return "charset";
|
||||
const name = ["id"];
|
||||
if (tagName === "meta")
|
||||
name.push(...["name", "property", "http-equiv"]);
|
||||
for (const n of name) {
|
||||
if (typeof props[n] !== "undefined") {
|
||||
const val = String(props[n]);
|
||||
if (fn && !fn(val))
|
||||
return false;
|
||||
return `${tagName}:${n}:${val}`;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const setAttrs = (ctx, markSideEffect) => {
|
||||
const { tag, $el } = ctx;
|
||||
if (!$el)
|
||||
return;
|
||||
Object.entries(tag.props).forEach(([k, value]) => {
|
||||
value = String(value);
|
||||
const attrSdeKey = `attr:${k}`;
|
||||
if (k === "class") {
|
||||
if (!value)
|
||||
return;
|
||||
for (const c of value.split(" ")) {
|
||||
const classSdeKey = `${attrSdeKey}:${c}`;
|
||||
if (markSideEffect)
|
||||
markSideEffect(ctx, classSdeKey, () => $el.classList.remove(c));
|
||||
if (!$el.classList.contains(c))
|
||||
$el.classList.add(c);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (markSideEffect && !k.startsWith("data-h-"))
|
||||
markSideEffect(ctx, attrSdeKey, () => $el.removeAttribute(k));
|
||||
if ($el.getAttribute(k) !== value)
|
||||
$el.setAttribute(k, value);
|
||||
});
|
||||
if (TagsWithInnerContent.includes(tag.tag) && $el.innerHTML !== (tag.children || ""))
|
||||
$el.innerHTML = tag.children || "";
|
||||
};
|
||||
|
||||
function hashCode(s) {
|
||||
let h = 9;
|
||||
for (let i = 0; i < s.length; )
|
||||
h = Math.imul(h ^ s.charCodeAt(i++), 9 ** 9);
|
||||
return ((h ^ h >>> 9) + 65536).toString(16).substring(1, 8).toLowerCase();
|
||||
}
|
||||
|
||||
async function renderDOMHead(head, options = {}) {
|
||||
const ctx = { shouldRender: true };
|
||||
await head.hooks.callHook("dom:beforeRender", ctx);
|
||||
if (!ctx.shouldRender)
|
||||
return;
|
||||
const dom = options.document || window.document;
|
||||
const staleSideEffects = head._popSideEffectQueue();
|
||||
head.headEntries().map((entry) => entry._sde).forEach((sde) => {
|
||||
Object.entries(sde).forEach(([key, fn]) => {
|
||||
staleSideEffects[key] = fn;
|
||||
});
|
||||
});
|
||||
const preRenderTag = async (tag) => {
|
||||
const entry = head.headEntries().find((e) => e._i === tag._e);
|
||||
const renderCtx = {
|
||||
renderId: tag._d || hashCode(JSON.stringify({ ...tag, _e: void 0, _p: void 0 })),
|
||||
$el: null,
|
||||
shouldRender: true,
|
||||
tag,
|
||||
entry,
|
||||
staleSideEffects
|
||||
};
|
||||
await head.hooks.callHook("dom:beforeRenderTag", renderCtx);
|
||||
return renderCtx;
|
||||
};
|
||||
const renders = [];
|
||||
const pendingRenders = {
|
||||
body: [],
|
||||
head: []
|
||||
};
|
||||
const markSideEffect = (ctx2, key, fn) => {
|
||||
key = `${ctx2.renderId}:${key}`;
|
||||
if (ctx2.entry)
|
||||
ctx2.entry._sde[key] = fn;
|
||||
delete staleSideEffects[key];
|
||||
};
|
||||
const markEl = (ctx2) => {
|
||||
head._elMap[ctx2.renderId] = ctx2.$el;
|
||||
renders.push(ctx2);
|
||||
markSideEffect(ctx2, "el", () => {
|
||||
ctx2.$el?.remove();
|
||||
delete head._elMap[ctx2.renderId];
|
||||
});
|
||||
};
|
||||
for (const t of await head.resolveTags()) {
|
||||
const ctx2 = await preRenderTag(t);
|
||||
if (!ctx2.shouldRender)
|
||||
continue;
|
||||
const { tag } = ctx2;
|
||||
if (tag.tag === "title") {
|
||||
dom.title = tag.children || "";
|
||||
renders.push(ctx2);
|
||||
continue;
|
||||
}
|
||||
if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
|
||||
ctx2.$el = dom[tag.tag === "htmlAttrs" ? "documentElement" : "body"];
|
||||
setAttrs(ctx2, markSideEffect);
|
||||
renders.push(ctx2);
|
||||
continue;
|
||||
}
|
||||
ctx2.$el = head._elMap[ctx2.renderId];
|
||||
if (!ctx2.$el && tag._hash) {
|
||||
ctx2.$el = dom.querySelector(`${tag.tagPosition?.startsWith("body") ? "body" : "head"} > ${tag.tag}[data-h-${tag._hash}]`);
|
||||
}
|
||||
if (ctx2.$el) {
|
||||
if (ctx2.tag._d)
|
||||
setAttrs(ctx2);
|
||||
markEl(ctx2);
|
||||
continue;
|
||||
}
|
||||
ctx2.$el = dom.createElement(tag.tag);
|
||||
setAttrs(ctx2);
|
||||
pendingRenders[tag.tagPosition?.startsWith("body") ? "body" : "head"].push(ctx2);
|
||||
}
|
||||
Object.entries(pendingRenders).forEach(([pos, queue]) => {
|
||||
if (!queue.length)
|
||||
return;
|
||||
for (const $el of [...dom[pos].children].reverse()) {
|
||||
const elTag = $el.tagName.toLowerCase();
|
||||
if (!HasElementTags.includes(elTag))
|
||||
continue;
|
||||
const dedupeKey = tagDedupeKey({
|
||||
tag: elTag,
|
||||
props: $el.getAttributeNames().reduce((props, name) => ({ ...props, [name]: $el.getAttribute(name) }), {})
|
||||
});
|
||||
const matchIdx = queue.findIndex((ctx2) => ctx2 && (ctx2.tag._d === dedupeKey || $el.isEqualNode(ctx2.$el)));
|
||||
if (matchIdx !== -1) {
|
||||
const ctx2 = queue[matchIdx];
|
||||
ctx2.$el = $el;
|
||||
setAttrs(ctx2);
|
||||
markEl(ctx2);
|
||||
delete queue[matchIdx];
|
||||
}
|
||||
}
|
||||
queue.forEach((ctx2) => {
|
||||
if (!ctx2.$el)
|
||||
return;
|
||||
switch (ctx2.tag.tagPosition) {
|
||||
case "bodyClose":
|
||||
dom.body.appendChild(ctx2.$el);
|
||||
break;
|
||||
case "bodyOpen":
|
||||
dom.body.insertBefore(ctx2.$el, dom.body.firstChild);
|
||||
break;
|
||||
case "head":
|
||||
default:
|
||||
dom.head.appendChild(ctx2.$el);
|
||||
break;
|
||||
}
|
||||
markEl(ctx2);
|
||||
});
|
||||
});
|
||||
for (const ctx2 of renders)
|
||||
await head.hooks.callHook("dom:renderTag", ctx2);
|
||||
Object.values(staleSideEffects).forEach((fn) => fn());
|
||||
}
|
||||
exports.domUpdatePromise = null;
|
||||
async function debouncedRenderDOMHead(head, options = {}) {
|
||||
function doDomUpdate() {
|
||||
exports.domUpdatePromise = null;
|
||||
return renderDOMHead(head, options);
|
||||
}
|
||||
const delayFn = options.delayFn || ((fn) => setTimeout(fn, 10));
|
||||
return exports.domUpdatePromise = exports.domUpdatePromise || new Promise((resolve) => delayFn(() => resolve(doDomUpdate())));
|
||||
}
|
||||
|
||||
exports.debouncedRenderDOMHead = debouncedRenderDOMHead;
|
||||
exports.hashCode = hashCode;
|
||||
exports.renderDOMHead = renderDOMHead;
|
||||
26
node_modules/@unhead/dom/dist/index.d.ts
generated
vendored
Normal file
26
node_modules/@unhead/dom/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Unhead } from '@unhead/schema';
|
||||
|
||||
interface RenderDomHeadOptions {
|
||||
/**
|
||||
* Document to use for rendering. Allows stubbing for testing.
|
||||
*/
|
||||
document?: Document;
|
||||
}
|
||||
/**
|
||||
* Render the head tags to the DOM.
|
||||
*/
|
||||
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): Promise<void>;
|
||||
/**
|
||||
* Global instance of the dom update promise. Used for debounding head updates.
|
||||
*/
|
||||
declare let domUpdatePromise: Promise<void> | null;
|
||||
/**
|
||||
* Queue a debounced update of the DOM head.
|
||||
*/
|
||||
declare function debouncedRenderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions & {
|
||||
delayFn?: (fn: () => void) => void;
|
||||
}): Promise<void>;
|
||||
|
||||
declare function hashCode(s: string): string;
|
||||
|
||||
export { RenderDomHeadOptions, debouncedRenderDOMHead, domUpdatePromise, hashCode, renderDOMHead };
|
||||
195
node_modules/@unhead/dom/dist/index.mjs
generated
vendored
Normal file
195
node_modules/@unhead/dom/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
const TagsWithInnerContent = ["script", "style", "noscript"];
|
||||
const HasElementTags = [
|
||||
"base",
|
||||
"meta",
|
||||
"link",
|
||||
"style",
|
||||
"script",
|
||||
"noscript"
|
||||
];
|
||||
|
||||
const UniqueTags = ["base", "title", "titleTemplate", "bodyAttrs", "htmlAttrs"];
|
||||
function tagDedupeKey(tag, fn) {
|
||||
const { props, tag: tagName } = tag;
|
||||
if (UniqueTags.includes(tagName))
|
||||
return tagName;
|
||||
if (tagName === "link" && props.rel === "canonical")
|
||||
return "canonical";
|
||||
if (props.charset)
|
||||
return "charset";
|
||||
const name = ["id"];
|
||||
if (tagName === "meta")
|
||||
name.push(...["name", "property", "http-equiv"]);
|
||||
for (const n of name) {
|
||||
if (typeof props[n] !== "undefined") {
|
||||
const val = String(props[n]);
|
||||
if (fn && !fn(val))
|
||||
return false;
|
||||
return `${tagName}:${n}:${val}`;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const setAttrs = (ctx, markSideEffect) => {
|
||||
const { tag, $el } = ctx;
|
||||
if (!$el)
|
||||
return;
|
||||
Object.entries(tag.props).forEach(([k, value]) => {
|
||||
value = String(value);
|
||||
const attrSdeKey = `attr:${k}`;
|
||||
if (k === "class") {
|
||||
if (!value)
|
||||
return;
|
||||
for (const c of value.split(" ")) {
|
||||
const classSdeKey = `${attrSdeKey}:${c}`;
|
||||
if (markSideEffect)
|
||||
markSideEffect(ctx, classSdeKey, () => $el.classList.remove(c));
|
||||
if (!$el.classList.contains(c))
|
||||
$el.classList.add(c);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (markSideEffect && !k.startsWith("data-h-"))
|
||||
markSideEffect(ctx, attrSdeKey, () => $el.removeAttribute(k));
|
||||
if ($el.getAttribute(k) !== value)
|
||||
$el.setAttribute(k, value);
|
||||
});
|
||||
if (TagsWithInnerContent.includes(tag.tag) && $el.innerHTML !== (tag.children || ""))
|
||||
$el.innerHTML = tag.children || "";
|
||||
};
|
||||
|
||||
function hashCode(s) {
|
||||
let h = 9;
|
||||
for (let i = 0; i < s.length; )
|
||||
h = Math.imul(h ^ s.charCodeAt(i++), 9 ** 9);
|
||||
return ((h ^ h >>> 9) + 65536).toString(16).substring(1, 8).toLowerCase();
|
||||
}
|
||||
|
||||
async function renderDOMHead(head, options = {}) {
|
||||
const ctx = { shouldRender: true };
|
||||
await head.hooks.callHook("dom:beforeRender", ctx);
|
||||
if (!ctx.shouldRender)
|
||||
return;
|
||||
const dom = options.document || window.document;
|
||||
const staleSideEffects = head._popSideEffectQueue();
|
||||
head.headEntries().map((entry) => entry._sde).forEach((sde) => {
|
||||
Object.entries(sde).forEach(([key, fn]) => {
|
||||
staleSideEffects[key] = fn;
|
||||
});
|
||||
});
|
||||
const preRenderTag = async (tag) => {
|
||||
const entry = head.headEntries().find((e) => e._i === tag._e);
|
||||
const renderCtx = {
|
||||
renderId: tag._d || hashCode(JSON.stringify({ ...tag, _e: void 0, _p: void 0 })),
|
||||
$el: null,
|
||||
shouldRender: true,
|
||||
tag,
|
||||
entry,
|
||||
staleSideEffects
|
||||
};
|
||||
await head.hooks.callHook("dom:beforeRenderTag", renderCtx);
|
||||
return renderCtx;
|
||||
};
|
||||
const renders = [];
|
||||
const pendingRenders = {
|
||||
body: [],
|
||||
head: []
|
||||
};
|
||||
const markSideEffect = (ctx2, key, fn) => {
|
||||
key = `${ctx2.renderId}:${key}`;
|
||||
if (ctx2.entry)
|
||||
ctx2.entry._sde[key] = fn;
|
||||
delete staleSideEffects[key];
|
||||
};
|
||||
const markEl = (ctx2) => {
|
||||
head._elMap[ctx2.renderId] = ctx2.$el;
|
||||
renders.push(ctx2);
|
||||
markSideEffect(ctx2, "el", () => {
|
||||
ctx2.$el?.remove();
|
||||
delete head._elMap[ctx2.renderId];
|
||||
});
|
||||
};
|
||||
for (const t of await head.resolveTags()) {
|
||||
const ctx2 = await preRenderTag(t);
|
||||
if (!ctx2.shouldRender)
|
||||
continue;
|
||||
const { tag } = ctx2;
|
||||
if (tag.tag === "title") {
|
||||
dom.title = tag.children || "";
|
||||
renders.push(ctx2);
|
||||
continue;
|
||||
}
|
||||
if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
|
||||
ctx2.$el = dom[tag.tag === "htmlAttrs" ? "documentElement" : "body"];
|
||||
setAttrs(ctx2, markSideEffect);
|
||||
renders.push(ctx2);
|
||||
continue;
|
||||
}
|
||||
ctx2.$el = head._elMap[ctx2.renderId];
|
||||
if (!ctx2.$el && tag._hash) {
|
||||
ctx2.$el = dom.querySelector(`${tag.tagPosition?.startsWith("body") ? "body" : "head"} > ${tag.tag}[data-h-${tag._hash}]`);
|
||||
}
|
||||
if (ctx2.$el) {
|
||||
if (ctx2.tag._d)
|
||||
setAttrs(ctx2);
|
||||
markEl(ctx2);
|
||||
continue;
|
||||
}
|
||||
ctx2.$el = dom.createElement(tag.tag);
|
||||
setAttrs(ctx2);
|
||||
pendingRenders[tag.tagPosition?.startsWith("body") ? "body" : "head"].push(ctx2);
|
||||
}
|
||||
Object.entries(pendingRenders).forEach(([pos, queue]) => {
|
||||
if (!queue.length)
|
||||
return;
|
||||
for (const $el of [...dom[pos].children].reverse()) {
|
||||
const elTag = $el.tagName.toLowerCase();
|
||||
if (!HasElementTags.includes(elTag))
|
||||
continue;
|
||||
const dedupeKey = tagDedupeKey({
|
||||
tag: elTag,
|
||||
props: $el.getAttributeNames().reduce((props, name) => ({ ...props, [name]: $el.getAttribute(name) }), {})
|
||||
});
|
||||
const matchIdx = queue.findIndex((ctx2) => ctx2 && (ctx2.tag._d === dedupeKey || $el.isEqualNode(ctx2.$el)));
|
||||
if (matchIdx !== -1) {
|
||||
const ctx2 = queue[matchIdx];
|
||||
ctx2.$el = $el;
|
||||
setAttrs(ctx2);
|
||||
markEl(ctx2);
|
||||
delete queue[matchIdx];
|
||||
}
|
||||
}
|
||||
queue.forEach((ctx2) => {
|
||||
if (!ctx2.$el)
|
||||
return;
|
||||
switch (ctx2.tag.tagPosition) {
|
||||
case "bodyClose":
|
||||
dom.body.appendChild(ctx2.$el);
|
||||
break;
|
||||
case "bodyOpen":
|
||||
dom.body.insertBefore(ctx2.$el, dom.body.firstChild);
|
||||
break;
|
||||
case "head":
|
||||
default:
|
||||
dom.head.appendChild(ctx2.$el);
|
||||
break;
|
||||
}
|
||||
markEl(ctx2);
|
||||
});
|
||||
});
|
||||
for (const ctx2 of renders)
|
||||
await head.hooks.callHook("dom:renderTag", ctx2);
|
||||
Object.values(staleSideEffects).forEach((fn) => fn());
|
||||
}
|
||||
let domUpdatePromise = null;
|
||||
async function debouncedRenderDOMHead(head, options = {}) {
|
||||
function doDomUpdate() {
|
||||
domUpdatePromise = null;
|
||||
return renderDOMHead(head, options);
|
||||
}
|
||||
const delayFn = options.delayFn || ((fn) => setTimeout(fn, 10));
|
||||
return domUpdatePromise = domUpdatePromise || new Promise((resolve) => delayFn(() => resolve(doDomUpdate())));
|
||||
}
|
||||
|
||||
export { debouncedRenderDOMHead, domUpdatePromise, hashCode, renderDOMHead };
|
||||
43
node_modules/@unhead/dom/package.json
generated
vendored
Normal file
43
node_modules/@unhead/dom/package.json
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@unhead/dom",
|
||||
"type": "module",
|
||||
"version": "1.0.14",
|
||||
"packageManager": "pnpm@7.19.0",
|
||||
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/harlan-zw",
|
||||
"homepage": "https://github.com/harlan-zw/unhead#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/harlan-zw/unhead.git",
|
||||
"directory": "packages/dom"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/harlan-zw/unhead/issues"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@unhead/schema": "1.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"zhead": "^1.0.9"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild .",
|
||||
"stub": "unbuild . --stub",
|
||||
"export:sizes": "npx export-size . -r"
|
||||
}
|
||||
}
|
||||
16
node_modules/@unhead/schema/README.md
generated
vendored
Normal file
16
node_modules/@unhead/schema/README.md
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# `@unhead/schema`
|
||||
|
||||
Typescript definitions for document `<head>`.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install --save-dev @unhead/schema
|
||||
|
||||
# Using yarn
|
||||
yarn add --dev @unhead/schema
|
||||
```
|
||||
|
||||
## Types
|
||||
|
||||
See [head.ts](./src/head.ts) for the full list of types.
|
||||
2
node_modules/@unhead/schema/dist/index.cjs
generated
vendored
Normal file
2
node_modules/@unhead/schema/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
|
||||
364
node_modules/@unhead/schema/dist/index.d.ts
generated
vendored
Normal file
364
node_modules/@unhead/schema/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,364 @@
|
||||
import { MaybePromiseProps, HeadTag as HeadTag$1, MergeHead, BaseBodyAttributes, HtmlAttributes as HtmlAttributes$1, Merge, Base as Base$1, DefinedValueOrEmptyObject, LinkBase, HttpEventAttributes, DataKeys, Style as Style$1, ScriptBase, Noscript as Noscript$1, BodyEvents, Meta as Meta$1, Stringable } from '@zhead/schema';
|
||||
export { DataKeys, DefinedValueOrEmptyObject, MergeHead, MetaFlatInput, SpeculationRules, TagKey } from '@zhead/schema';
|
||||
import { NestedHooks, Hookable } from 'hookable';
|
||||
|
||||
interface ResolvesDuplicates {
|
||||
/**
|
||||
* By default, tags which share the same unique key `name`, `property` are de-duped. To allow duplicates
|
||||
* to be made you can provide a unique key for each entry.
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* @deprecated Use `key` instead
|
||||
*/
|
||||
hid?: string;
|
||||
/**
|
||||
* @deprecated Use `key` instead
|
||||
*/
|
||||
vmid?: string;
|
||||
/**
|
||||
* Specify where to render the tag.
|
||||
*
|
||||
* @default 'head'
|
||||
*/
|
||||
tagDuplicateStrategy?: 'replace' | 'merge';
|
||||
}
|
||||
type ValidTagPositions = 'head' | 'bodyClose' | 'bodyOpen';
|
||||
interface TagPosition {
|
||||
/**
|
||||
* Specify where to render the tag.
|
||||
*
|
||||
* @default 'head'
|
||||
*/
|
||||
tagPosition?: ValidTagPositions;
|
||||
/**
|
||||
* Render the tag before the body close.
|
||||
*
|
||||
* @deprecated Use `tagPosition: 'bodyClose'` instead.
|
||||
*/
|
||||
body?: true;
|
||||
}
|
||||
type InnerContentVal = string | Record<string, any>;
|
||||
interface InnerContent {
|
||||
/**
|
||||
* Text content of the tag.
|
||||
*
|
||||
* Alias for children
|
||||
*/
|
||||
innerHTML?: InnerContentVal;
|
||||
/**
|
||||
* Sets the textContent of an element.
|
||||
*/
|
||||
children?: InnerContentVal;
|
||||
/**
|
||||
* Sets the textContent of an element. This will be HTML encoded.
|
||||
*
|
||||
* Alias for children
|
||||
*/
|
||||
textContent?: InnerContentVal;
|
||||
}
|
||||
interface TagPriority {
|
||||
/**
|
||||
* The priority for rendering the tag, without this all tags are rendered as they are registered
|
||||
* (besides some special tags).
|
||||
*
|
||||
* The following special tags have default priorities:
|
||||
* * -2 <meta charset ...>
|
||||
* * -1 <base>
|
||||
* * 0 <meta http-equiv="content-security-policy" ...>
|
||||
*
|
||||
* All other tags have a default priority of 10: <meta>, <script>, <link>, <style>, etc
|
||||
*/
|
||||
tagPriority?: number | 'critical' | 'high' | 'low' | `before:${string}` | `after:${string}`;
|
||||
}
|
||||
type TagUserProperties = TagPriority & TagPosition & MaybePromiseProps<InnerContent> & ResolvesDuplicates;
|
||||
interface TagInternalProperties {
|
||||
/**
|
||||
* Entry ID
|
||||
*/
|
||||
_e?: number;
|
||||
/**
|
||||
* Position
|
||||
*/
|
||||
_p?: number;
|
||||
/**
|
||||
* Dedupe key
|
||||
*/
|
||||
_d?: string;
|
||||
}
|
||||
type HeadTag = HeadTag$1 & TagUserProperties & TagInternalProperties;
|
||||
type HeadTagKeys = (keyof HeadTag)[];
|
||||
|
||||
type Never<T> = {
|
||||
[P in keyof T]?: never;
|
||||
};
|
||||
type UserTagConfigWithoutInnerContent = TagPriority & TagPosition & ResolvesDuplicates & Never<InnerContent>;
|
||||
type UserAttributesConfig = ResolvesDuplicates & TagPriority & Never<InnerContent & TagPosition>;
|
||||
interface SchemaAugmentations extends MergeHead {
|
||||
base: UserAttributesConfig;
|
||||
htmlAttrs: UserAttributesConfig;
|
||||
bodyAttrs: UserAttributesConfig;
|
||||
link: UserTagConfigWithoutInnerContent;
|
||||
meta: UserTagConfigWithoutInnerContent;
|
||||
style: TagUserProperties;
|
||||
script: TagUserProperties;
|
||||
noscript: TagUserProperties;
|
||||
}
|
||||
type MaybeArray<T> = T | T[];
|
||||
type BaseBodyAttr = BaseBodyAttributes;
|
||||
type BaseHtmlAttr = HtmlAttributes$1;
|
||||
interface BodyAttr extends Omit<BaseBodyAttr, '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<string> | Record<string, boolean>;
|
||||
}
|
||||
interface HtmlAttr extends Omit<HtmlAttributes$1, '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<string> | Record<string, boolean>;
|
||||
}
|
||||
interface BaseMeta extends Omit<Meta$1, 'content'> {
|
||||
/**
|
||||
* This attribute contains the value for the http-equiv, name or property attribute, depending on which is used.
|
||||
*
|
||||
* You can provide an array of values to create multiple tags sharing the same name, property or http-equiv.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-content
|
||||
*/
|
||||
content?: MaybeArray<Stringable>;
|
||||
}
|
||||
type EntryAugmentation = undefined | Record<string, any>;
|
||||
type MaybeFunctionEntries<T> = {
|
||||
[key in keyof T]?: T[key] | ((e: Event) => void);
|
||||
};
|
||||
type Title = string | null;
|
||||
type TitleTemplate = string | null | ((title?: string) => string | null);
|
||||
type Base<E extends EntryAugmentation = {}> = Partial<Merge<SchemaAugmentations['base'], MaybePromiseProps<Base$1>>> & DefinedValueOrEmptyObject<E>;
|
||||
type Link<E extends EntryAugmentation = {}> = MaybePromiseProps<LinkBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['link'] & DefinedValueOrEmptyObject<E>;
|
||||
type Meta<E extends EntryAugmentation = {}> = MaybePromiseProps<BaseMeta> & DataKeys & SchemaAugmentations['meta'] & DefinedValueOrEmptyObject<E>;
|
||||
type Style<E extends EntryAugmentation = {}> = MaybePromiseProps<Style$1> & DataKeys & SchemaAugmentations['style'] & DefinedValueOrEmptyObject<E>;
|
||||
type Script<E extends EntryAugmentation = {}> = MaybePromiseProps<ScriptBase> & MaybeFunctionEntries<HttpEventAttributes> & DataKeys & SchemaAugmentations['script'] & DefinedValueOrEmptyObject<E>;
|
||||
type Noscript<E extends EntryAugmentation = {}> = MaybePromiseProps<Noscript$1> & DataKeys & SchemaAugmentations['noscript'] & DefinedValueOrEmptyObject<E>;
|
||||
type HtmlAttributes<E extends EntryAugmentation = {}> = MaybePromiseProps<HtmlAttr> & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>;
|
||||
type BodyAttributes<E extends EntryAugmentation = {}> = MaybePromiseProps<BodyAttr> & MaybeFunctionEntries<BodyEvents> & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>;
|
||||
interface Head<E extends MergeHead = SchemaAugmentations> {
|
||||
/**
|
||||
* 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 | Promise<Title>;
|
||||
/**
|
||||
* Generate the title from a template.
|
||||
*
|
||||
* Should include a `%s` placeholder for the title, for example `%s - My Site`.
|
||||
*/
|
||||
titleTemplate?: TitleTemplate;
|
||||
/**
|
||||
* 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?: 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?: 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?: Style<E['style']>[];
|
||||
/**
|
||||
* 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?: Script<E['script']>[];
|
||||
/**
|
||||
* 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?: Noscript<E['noscript']>[];
|
||||
/**
|
||||
* 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 HookResult = Promise<void> | void;
|
||||
interface SSRHeadPayload {
|
||||
headTags: string;
|
||||
bodyTags: string;
|
||||
bodyTagsOpen: string;
|
||||
htmlAttrs: string;
|
||||
bodyAttrs: string;
|
||||
}
|
||||
interface EntryResolveCtx<T> {
|
||||
tags: HeadTag[];
|
||||
entries: HeadEntry<T>[];
|
||||
}
|
||||
interface DomRenderTagContext {
|
||||
$el?: Element | null;
|
||||
shouldRender: boolean;
|
||||
renderId: string;
|
||||
tag: HeadTag;
|
||||
entry?: HeadEntry<any>;
|
||||
staleSideEffects: SideEffectsRecord;
|
||||
}
|
||||
interface BeforeRenderContext {
|
||||
shouldRender: boolean;
|
||||
}
|
||||
interface SSRRenderContext {
|
||||
tags: HeadTag[];
|
||||
html: SSRHeadPayload;
|
||||
}
|
||||
interface HeadHooks {
|
||||
'init': (ctx: Unhead<any>) => HookResult;
|
||||
'entries:updated': (ctx: Unhead<any>) => HookResult;
|
||||
'entries:resolve': (ctx: EntryResolveCtx<any>) => HookResult;
|
||||
'tag:normalise': (ctx: {
|
||||
tag: HeadTag;
|
||||
entry: HeadEntry<any>;
|
||||
}) => HookResult;
|
||||
'tags:resolve': (ctx: {
|
||||
tags: HeadTag[];
|
||||
}) => HookResult;
|
||||
'dom:beforeRender': (ctx: BeforeRenderContext) => HookResult;
|
||||
'dom:beforeRenderTag': (ctx: DomRenderTagContext) => HookResult;
|
||||
'dom:renderTag': (ctx: DomRenderTagContext) => HookResult;
|
||||
'ssr:beforeRender': (ctx: BeforeRenderContext) => HookResult;
|
||||
'ssr:render': (ctx: {
|
||||
tags: HeadTag[];
|
||||
}) => HookResult;
|
||||
'ssr:rendered': (ctx: SSRRenderContext) => HookResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Side effects are mapped with a key and their cleanup function.
|
||||
*
|
||||
* For example `meta:data-h-4h46h465`: () => { document.querySelector('meta[data-h-4h46h465]').remove() }
|
||||
*/
|
||||
type SideEffectsRecord = Record<string, () => void>;
|
||||
type RuntimeMode = 'server' | 'client' | 'all';
|
||||
interface HeadEntry<Input> {
|
||||
/**
|
||||
* User provided input for the entry.
|
||||
*/
|
||||
input: Input;
|
||||
/**
|
||||
* Optional resolved input which will be used if set.
|
||||
*/
|
||||
resolvedInput?: Input;
|
||||
/**
|
||||
* The mode that the entry should be used in.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
_m?: RuntimeMode;
|
||||
/**
|
||||
* Head entry index
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
_i: number;
|
||||
/**
|
||||
* Side effects
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
_sde: SideEffectsRecord;
|
||||
}
|
||||
type HeadPlugin = Omit<CreateHeadOptions, 'plugins'>;
|
||||
/**
|
||||
* An active head entry provides an API to manipulate it.
|
||||
*/
|
||||
interface ActiveHeadEntry<Input> {
|
||||
/**
|
||||
* Updates the entry with new input.
|
||||
*
|
||||
* Will first clear any side effects for previous input.
|
||||
*/
|
||||
patch: (input: Input) => void;
|
||||
/**
|
||||
* Dispose the entry, removing it from the active head.
|
||||
*
|
||||
* Will queue side effects for removal.
|
||||
*/
|
||||
dispose: () => void;
|
||||
}
|
||||
interface CreateHeadOptions {
|
||||
domDelayFn?: (fn: () => void) => void;
|
||||
document?: Document;
|
||||
plugins?: HeadPlugin[];
|
||||
hooks?: NestedHooks<HeadHooks>;
|
||||
}
|
||||
interface HeadEntryOptions {
|
||||
mode?: RuntimeMode;
|
||||
}
|
||||
interface Unhead<Input extends {} = Head> {
|
||||
/**
|
||||
* The active head entries.
|
||||
*/
|
||||
headEntries: () => HeadEntry<Input>[];
|
||||
/**
|
||||
* Create a new head entry.
|
||||
*/
|
||||
push: (entry: Input, options?: HeadEntryOptions) => ActiveHeadEntry<Input>;
|
||||
/**
|
||||
* Resolve tags from head entries.
|
||||
*/
|
||||
resolveTags: () => Promise<HeadTag[]>;
|
||||
/**
|
||||
* Exposed hooks for easier extension.
|
||||
*/
|
||||
hooks: Hookable<HeadHooks>;
|
||||
/**
|
||||
* Resolved options
|
||||
*/
|
||||
resolvedOptions: CreateHeadOptions;
|
||||
/**
|
||||
* Use a head plugin, loads the plugins hooks.
|
||||
*/
|
||||
use: (plugin: HeadPlugin) => void;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_popSideEffectQueue: () => SideEffectsRecord;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_elMap: Record<string, Element>;
|
||||
}
|
||||
|
||||
export { ActiveHeadEntry, Base, BaseBodyAttr, BaseHtmlAttr, BeforeRenderContext, BodyAttributes, CreateHeadOptions, DomRenderTagContext, EntryAugmentation, EntryResolveCtx, Head, HeadEntry, HeadEntryOptions, HeadHooks, HeadPlugin, HeadTag, HeadTagKeys, HookResult, HtmlAttributes, InnerContent, InnerContentVal, Link, MaybeArray, MaybeFunctionEntries, Meta, Never, Noscript, ResolvesDuplicates, RuntimeMode, SSRHeadPayload, SSRRenderContext, SchemaAugmentations, Script, SideEffectsRecord, Style, TagInternalProperties, TagPosition, TagPriority, TagUserProperties, Title, TitleTemplate, Unhead, UserAttributesConfig, UserTagConfigWithoutInnerContent, ValidTagPositions };
|
||||
1
node_modules/@unhead/schema/dist/index.mjs
generated
vendored
Normal file
1
node_modules/@unhead/schema/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
45
node_modules/@unhead/schema/package.json
generated
vendored
Normal file
45
node_modules/@unhead/schema/package.json
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "@unhead/schema",
|
||||
"type": "module",
|
||||
"version": "1.0.14",
|
||||
"packageManager": "pnpm@7.19.0",
|
||||
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/harlan-zw",
|
||||
"homepage": "https://github.com/harlan-zw/unhead#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/harlan-zw/unhead.git",
|
||||
"directory": "packages/schema"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/harlan-zw/unhead/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"head",
|
||||
"meta tags",
|
||||
"types"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@zhead/schema": "^1.0.9",
|
||||
"hookable": "^5.4.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild .",
|
||||
"stub": "unbuild . --stub"
|
||||
}
|
||||
}
|
||||
12
node_modules/@unhead/ssr/README.md
generated
vendored
Normal file
12
node_modules/@unhead/ssr/README.md
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# @unhead/dom
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
# yarn add @unhead/dom
|
||||
npm install @unhead/ssr
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
See the [Unhead](https://unhead.harlanzw.com/) for more details.
|
||||
62
node_modules/@unhead/ssr/dist/index.cjs
generated
vendored
Normal file
62
node_modules/@unhead/ssr/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
const SelfClosingTags = ["meta", "link", "base"];
|
||||
|
||||
const propsToString = (props) => {
|
||||
const handledAttributes = [];
|
||||
for (const [key, value] of Object.entries(props)) {
|
||||
if (value === false || value == null)
|
||||
continue;
|
||||
let attribute = key;
|
||||
if (value !== true)
|
||||
attribute += `="${String(value).replace(/"/g, """)}"`;
|
||||
handledAttributes.push(attribute);
|
||||
}
|
||||
return handledAttributes.length > 0 ? ` ${handledAttributes.join(" ")}` : "";
|
||||
};
|
||||
|
||||
const tagToString = (tag) => {
|
||||
const attrs = propsToString(tag.props);
|
||||
const openTag = `<${tag.tag}${attrs}>`;
|
||||
return SelfClosingTags.includes(tag.tag) ? openTag : `${openTag}${tag.children || ""}</${tag.tag}>`;
|
||||
};
|
||||
|
||||
function ssrRenderTags(tags) {
|
||||
const schema = { htmlAttrs: {}, bodyAttrs: {}, tags: { head: [], bodyClose: [], bodyOpen: [] } };
|
||||
for (const tag of tags) {
|
||||
if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
|
||||
schema[tag.tag] = { ...schema[tag.tag], ...tag.props };
|
||||
continue;
|
||||
}
|
||||
schema.tags[tag.tagPosition || "head"].push(tagToString(tag));
|
||||
}
|
||||
return {
|
||||
headTags: schema.tags.head.join("\n"),
|
||||
bodyTags: schema.tags.bodyClose.join("\n"),
|
||||
bodyTagsOpen: schema.tags.bodyOpen.join("\n"),
|
||||
htmlAttrs: propsToString(schema.htmlAttrs),
|
||||
bodyAttrs: propsToString(schema.bodyAttrs)
|
||||
};
|
||||
}
|
||||
|
||||
async function renderSSRHead(head) {
|
||||
const beforeRenderCtx = { shouldRender: true };
|
||||
await head.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
|
||||
if (!beforeRenderCtx.shouldRender) {
|
||||
return {
|
||||
headTags: "",
|
||||
bodyTags: "",
|
||||
bodyTagsOpen: "",
|
||||
htmlAttrs: "",
|
||||
bodyAttrs: ""
|
||||
};
|
||||
}
|
||||
const ctx = { tags: await head.resolveTags() };
|
||||
await head.hooks.callHook("ssr:render", ctx);
|
||||
const html = ssrRenderTags(ctx.tags);
|
||||
const renderCtx = { tags: ctx.tags, html };
|
||||
await head.hooks.callHook("ssr:rendered", renderCtx);
|
||||
return renderCtx.html;
|
||||
}
|
||||
|
||||
exports.renderSSRHead = renderSSRHead;
|
||||
6
node_modules/@unhead/ssr/dist/index.d.ts
generated
vendored
Normal file
6
node_modules/@unhead/ssr/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Unhead, SSRHeadPayload } from '@unhead/schema';
|
||||
export { SSRHeadPayload } from '@unhead/schema';
|
||||
|
||||
declare function renderSSRHead<T extends {}>(head: Unhead<T>): Promise<SSRHeadPayload>;
|
||||
|
||||
export { renderSSRHead };
|
||||
60
node_modules/@unhead/ssr/dist/index.mjs
generated
vendored
Normal file
60
node_modules/@unhead/ssr/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
const SelfClosingTags = ["meta", "link", "base"];
|
||||
|
||||
const propsToString = (props) => {
|
||||
const handledAttributes = [];
|
||||
for (const [key, value] of Object.entries(props)) {
|
||||
if (value === false || value == null)
|
||||
continue;
|
||||
let attribute = key;
|
||||
if (value !== true)
|
||||
attribute += `="${String(value).replace(/"/g, """)}"`;
|
||||
handledAttributes.push(attribute);
|
||||
}
|
||||
return handledAttributes.length > 0 ? ` ${handledAttributes.join(" ")}` : "";
|
||||
};
|
||||
|
||||
const tagToString = (tag) => {
|
||||
const attrs = propsToString(tag.props);
|
||||
const openTag = `<${tag.tag}${attrs}>`;
|
||||
return SelfClosingTags.includes(tag.tag) ? openTag : `${openTag}${tag.children || ""}</${tag.tag}>`;
|
||||
};
|
||||
|
||||
function ssrRenderTags(tags) {
|
||||
const schema = { htmlAttrs: {}, bodyAttrs: {}, tags: { head: [], bodyClose: [], bodyOpen: [] } };
|
||||
for (const tag of tags) {
|
||||
if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
|
||||
schema[tag.tag] = { ...schema[tag.tag], ...tag.props };
|
||||
continue;
|
||||
}
|
||||
schema.tags[tag.tagPosition || "head"].push(tagToString(tag));
|
||||
}
|
||||
return {
|
||||
headTags: schema.tags.head.join("\n"),
|
||||
bodyTags: schema.tags.bodyClose.join("\n"),
|
||||
bodyTagsOpen: schema.tags.bodyOpen.join("\n"),
|
||||
htmlAttrs: propsToString(schema.htmlAttrs),
|
||||
bodyAttrs: propsToString(schema.bodyAttrs)
|
||||
};
|
||||
}
|
||||
|
||||
async function renderSSRHead(head) {
|
||||
const beforeRenderCtx = { shouldRender: true };
|
||||
await head.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
|
||||
if (!beforeRenderCtx.shouldRender) {
|
||||
return {
|
||||
headTags: "",
|
||||
bodyTags: "",
|
||||
bodyTagsOpen: "",
|
||||
htmlAttrs: "",
|
||||
bodyAttrs: ""
|
||||
};
|
||||
}
|
||||
const ctx = { tags: await head.resolveTags() };
|
||||
await head.hooks.callHook("ssr:render", ctx);
|
||||
const html = ssrRenderTags(ctx.tags);
|
||||
const renderCtx = { tags: ctx.tags, html };
|
||||
await head.hooks.callHook("ssr:rendered", renderCtx);
|
||||
return renderCtx.html;
|
||||
}
|
||||
|
||||
export { renderSSRHead };
|
||||
43
node_modules/@unhead/ssr/package.json
generated
vendored
Normal file
43
node_modules/@unhead/ssr/package.json
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@unhead/ssr",
|
||||
"type": "module",
|
||||
"version": "1.0.14",
|
||||
"packageManager": "pnpm@7.19.0",
|
||||
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/harlan-zw",
|
||||
"homepage": "https://github.com/harlan-zw/unhead#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/harlan-zw/unhead.git",
|
||||
"directory": "packages/ssr"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/harlan-zw/unhead/issues"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@unhead/schema": "1.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"zhead": "^1.0.9"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild .",
|
||||
"stub": "unbuild . --stub",
|
||||
"export:sizes": "npx export-size . -r"
|
||||
}
|
||||
}
|
||||
1095
node_modules/@unhead/vue/dist/index.cjs
generated
vendored
Normal file
1095
node_modules/@unhead/vue/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
164
node_modules/@unhead/vue/dist/index.d.ts
generated
vendored
Normal file
164
node_modules/@unhead/vue/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
import * as _unhead_schema from '@unhead/schema';
|
||||
import { Head, CreateHeadOptions, Unhead, 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, MetaFlatInput, ActiveHeadEntry } from '@unhead/schema';
|
||||
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
|
||||
import { ComputedRef, Ref, Plugin } from 'vue';
|
||||
|
||||
/**
|
||||
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
||||
* and does not register DOM plugins.
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
declare function createHeadCore<T extends {} = Head>(options?: CreateHeadOptions): Unhead<T>;
|
||||
|
||||
type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
|
||||
type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
|
||||
type MaybeComputedRefOrPromise<T> = T | MaybeReadonlyRef<T> | Ref<T> | Promise<T>;
|
||||
type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
|
||||
[key in keyof T]?: MaybeComputedRefOrPromise<T[key]>;
|
||||
};
|
||||
type Arrayable<T> = T | Array<T>;
|
||||
|
||||
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'> {
|
||||
/**
|
||||
* 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>>;
|
||||
}
|
||||
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>>>;
|
||||
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 | Promise<Title>;
|
||||
/**
|
||||
* Generate the title from a template.
|
||||
*/
|
||||
titleTemplate?: TitleTemplate;
|
||||
/**
|
||||
* 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']>[]>;
|
||||
/**
|
||||
* 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']>[]>;
|
||||
/**
|
||||
* 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']>[]>;
|
||||
/**
|
||||
* 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 UseHeadInput<T extends MergeHead = {}> = MaybeComputedRef<ReactiveHead<T>>;
|
||||
|
||||
declare function resolveUnrefHeadInput(ref: any, lastKey?: string | number): any;
|
||||
declare function asArray<T>(value: Arrayable<T>): T[];
|
||||
|
||||
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
||||
declare const headSymbol = "usehead";
|
||||
declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
|
||||
declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn'>): VueHeadClient<T>;
|
||||
|
||||
declare const VueHeadMixin: {
|
||||
created(): void;
|
||||
};
|
||||
|
||||
declare const VueReactiveUseHeadPlugin: () => _unhead_schema.HeadPlugin;
|
||||
|
||||
declare const Vue2ProvideUnheadPlugin: Plugin;
|
||||
|
||||
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadInput<T>>;
|
||||
declare const useServerTagTitle: (title: ReactiveHead['title']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerTagMeta: (meta: Arrayable<Meta>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerTagLink: (link: Arrayable<Link>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerTagScript: (script: Arrayable<Script>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerTagStyle: (style: Arrayable<Style>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerTagNoscript: (noscript: Arrayable<Noscript>) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerTagBase: (base: ReactiveHead['base']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useServerBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void | _unhead_schema.ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
|
||||
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
||||
declare const useTagTitle: (title: ReactiveHead['title']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useTagMeta: (meta: Arrayable<Meta>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useTagMetaFlat: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useSeoMeta: (meta: MaybeComputedRefEntries<MetaFlatInput>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useTagLink: (link: Arrayable<Link>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useTagScript: (script: Arrayable<Script>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useTagStyle: (style: Arrayable<Style>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useTagNoscript: (noscript: Arrayable<Noscript>) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useTagBase: (base: ReactiveHead['base']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void | ActiveHeadEntry<UseHeadInput<MergeHead>>;
|
||||
|
||||
declare const unheadVueComposablesImports: {
|
||||
from: string;
|
||||
imports: string[];
|
||||
}[];
|
||||
|
||||
export { Arrayable, Base, BodyAttributes, HtmlAttributes, Link, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefOrPromise, MaybeReadonlyRef, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, UseHeadInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, VueReactiveUseHeadPlugin, asArray, createHead, createHeadCore, headSymbol, injectHead, resolveUnrefHeadInput, 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 };
|
||||
1059
node_modules/@unhead/vue/dist/index.mjs
generated
vendored
Normal file
1059
node_modules/@unhead/vue/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
48
node_modules/@unhead/vue/package.json
generated
vendored
Normal file
48
node_modules/@unhead/vue/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "@unhead/vue",
|
||||
"type": "module",
|
||||
"version": "1.0.14",
|
||||
"packageManager": "pnpm@7.19.0",
|
||||
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/harlan-zw",
|
||||
"homepage": "https://github.com/harlan-zw/unhead#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/harlan-zw/unhead.git",
|
||||
"directory": "packages/vue"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/harlan-zw/unhead/issues"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"vue": ">=2.7 || >=3"
|
||||
},
|
||||
"dependencies": {
|
||||
"hookable": "^5.4.2",
|
||||
"@unhead/schema": "1.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vue": "^3.2.45",
|
||||
"unhead": "1.0.14"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild .",
|
||||
"stub": "unbuild . --stub",
|
||||
"export:sizes": "npx export-size . -r"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user