feat: init
This commit is contained in:
21
node_modules/unhead/LICENSE
generated
vendored
Normal file
21
node_modules/unhead/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Harlan Wilton <harlan@harlanzw.com>
|
||||
|
||||
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.
|
||||
113
node_modules/unhead/README.md
generated
vendored
Normal file
113
node_modules/unhead/README.md
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
# unhead
|
||||
|
||||
> Full-stack `<head>` manager built for any framework
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![License][license-src]][license-href]
|
||||
|
||||
## Features
|
||||
|
||||
- 🚀 Framework agnostic - works with any framework
|
||||
- 🔄 Reactive head management
|
||||
- 🔍 SEO-friendly with rich meta tag support
|
||||
- 🖥️ Server-side rendering support
|
||||
- 📦 Lightweight and tree-shakable
|
||||
- ⚡ Performance optimized with minimal runtime overhead
|
||||
- 🎯 Type-safe with full TypeScript support
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm install unhead
|
||||
|
||||
# yarn
|
||||
yarn add unhead
|
||||
|
||||
# pnpm
|
||||
pnpm add unhead
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```ts
|
||||
import { createHead, useHead } from 'unhead'
|
||||
|
||||
// Create a head instance
|
||||
const head = createHead()
|
||||
|
||||
// Use head tags
|
||||
useHead({
|
||||
title: 'My App',
|
||||
meta: [
|
||||
{
|
||||
name: 'description',
|
||||
content: 'My awesome application'
|
||||
}
|
||||
]
|
||||
}, { head })
|
||||
```
|
||||
|
||||
### Server-Side Rendering
|
||||
|
||||
```ts
|
||||
import { createHead, renderSSRHead } from 'unhead/server'
|
||||
|
||||
const head = createHead()
|
||||
|
||||
// Add head entries
|
||||
useHead({
|
||||
title: 'SSR App',
|
||||
meta: [{ name: 'description', content: 'Server-rendered app' }]
|
||||
}, { head })
|
||||
|
||||
// Render head tags
|
||||
const { headTags, bodyTags } = await renderSSRHead(head)
|
||||
```
|
||||
|
||||
### Client-Side Hydration
|
||||
|
||||
```ts
|
||||
import { createHead, renderDOMHead } from 'unhead/client'
|
||||
|
||||
const head = createHead()
|
||||
|
||||
// Enable DOM rendering
|
||||
renderDOMHead(head)
|
||||
|
||||
// Add reactive head entries
|
||||
useHead({
|
||||
title: 'Client App'
|
||||
}, { head })
|
||||
```
|
||||
|
||||
## Framework Integrations
|
||||
|
||||
Unhead provides optimized integrations for popular frameworks:
|
||||
|
||||
- **Vue**: [`@unhead/vue`](../vue)
|
||||
- **React**: [`@unhead/react`](../react)
|
||||
- **Angular**: [`@unhead/angular`](../angular)
|
||||
- **Svelte**: [`@unhead/svelte`](../svelte)
|
||||
- **SolidJS**: [`@unhead/solid-js`](../solid-js)
|
||||
|
||||
## Documentation
|
||||
|
||||
Visit the [documentation site](https://unhead.unjs.io/) for comprehensive guides and API references.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE)
|
||||
|
||||
<!-- Badges -->
|
||||
[npm-version-src]: https://img.shields.io/npm/v/unhead/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
|
||||
[npm-version-href]: https://npmjs.com/package/unhead
|
||||
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/unhead.svg?style=flat&colorA=18181B&colorB=28CF8D
|
||||
[npm-downloads-href]: https://npmjs.com/package/unhead
|
||||
|
||||
[license-src]: https://img.shields.io/github/license/unjs/unhead.svg?style=flat&colorA=18181B&colorB=28CF8D
|
||||
[license-href]: https://github.com/unjs/unhead/blob/main/LICENSE
|
||||
1
node_modules/unhead/client.d.ts
generated
vendored
Normal file
1
node_modules/unhead/client.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/client.mjs'
|
||||
13
node_modules/unhead/dist/client.d.mts
generated
vendored
Normal file
13
node_modules/unhead/dist/client.d.mts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { R as ResolvableHead, r as CreateClientHeadOptions, U as Unhead, I as RenderDomHeadOptions } from './shared/unhead.BUCuVRIf.mjs';
|
||||
import 'hookable';
|
||||
|
||||
declare function createHead<T = ResolvableHead>(options?: CreateClientHeadOptions): Unhead<T>;
|
||||
|
||||
/**
|
||||
* Render the head tags to the DOM.
|
||||
*/
|
||||
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): Promise<void>;
|
||||
|
||||
declare function createDebouncedFn(callee: () => void, delayer: (fn: () => void) => void): () => void;
|
||||
|
||||
export { CreateClientHeadOptions, Unhead, createDebouncedFn, createHead, renderDOMHead };
|
||||
13
node_modules/unhead/dist/client.d.ts
generated
vendored
Normal file
13
node_modules/unhead/dist/client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { R as ResolvableHead, r as CreateClientHeadOptions, U as Unhead, I as RenderDomHeadOptions } from './shared/unhead.BUCuVRIf.js';
|
||||
import 'hookable';
|
||||
|
||||
declare function createHead<T = ResolvableHead>(options?: CreateClientHeadOptions): Unhead<T>;
|
||||
|
||||
/**
|
||||
* Render the head tags to the DOM.
|
||||
*/
|
||||
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): Promise<void>;
|
||||
|
||||
declare function createDebouncedFn(callee: () => void, delayer: (fn: () => void) => void): () => void;
|
||||
|
||||
export { CreateClientHeadOptions, Unhead, createDebouncedFn, createHead, renderDOMHead };
|
||||
222
node_modules/unhead/dist/client.mjs
generated
vendored
Normal file
222
node_modules/unhead/dist/client.mjs
generated
vendored
Normal file
@@ -0,0 +1,222 @@
|
||||
import { a as createUnhead } from './shared/unhead.BFfcxOoW.mjs';
|
||||
import { H as HasElementTags } from './shared/unhead.yem5I2v_.mjs';
|
||||
import { h as hashTag, i as isMetaArrayDupeKey, a as normalizeProps, d as dedupeKey } from './shared/unhead.eK9_7LaY.mjs';
|
||||
import 'hookable';
|
||||
import './shared/unhead.CbpEuj3y.mjs';
|
||||
|
||||
async function renderDOMHead(head, options = {}) {
|
||||
const dom = options.document || head.resolvedOptions.document;
|
||||
if (!dom || !head.dirty)
|
||||
return;
|
||||
const beforeRenderCtx = { shouldRender: true, tags: [] };
|
||||
await head.hooks.callHook("dom:beforeRender", beforeRenderCtx);
|
||||
if (!beforeRenderCtx.shouldRender)
|
||||
return;
|
||||
if (head._domUpdatePromise) {
|
||||
return head._domUpdatePromise;
|
||||
}
|
||||
head._domUpdatePromise = new Promise(async (resolve) => {
|
||||
const dupeKeyCounter = /* @__PURE__ */ new Map();
|
||||
const resolveTagPromise = new Promise((resolve2) => {
|
||||
head.resolveTags().then((tags2) => {
|
||||
resolve2(
|
||||
tags2.map((tag) => {
|
||||
const count = dupeKeyCounter.get(tag._d) || 0;
|
||||
const res = {
|
||||
tag,
|
||||
id: (count ? `${tag._d}:${count}` : tag._d) || hashTag(tag),
|
||||
shouldRender: true
|
||||
};
|
||||
if (tag._d && isMetaArrayDupeKey(tag._d)) {
|
||||
dupeKeyCounter.set(tag._d, count + 1);
|
||||
}
|
||||
return res;
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
let state = head._dom;
|
||||
if (!state) {
|
||||
state = {
|
||||
title: dom.title,
|
||||
elMap: (/* @__PURE__ */ new Map()).set("htmlAttrs", dom.documentElement).set("bodyAttrs", dom.body)
|
||||
};
|
||||
for (const key of ["body", "head"]) {
|
||||
const children = dom[key]?.children;
|
||||
for (const c of children) {
|
||||
const tag = c.tagName.toLowerCase();
|
||||
if (!HasElementTags.has(tag)) {
|
||||
continue;
|
||||
}
|
||||
const next = normalizeProps({ tag, props: {} }, {
|
||||
innerHTML: c.innerHTML,
|
||||
...c.getAttributeNames().reduce((props, name) => {
|
||||
props[name] = c.getAttribute(name);
|
||||
return props;
|
||||
}, {}) || {}
|
||||
});
|
||||
next.key = c.getAttribute("data-hid") || void 0;
|
||||
next._d = dedupeKey(next) || hashTag(next);
|
||||
if (state.elMap.has(next._d)) {
|
||||
let count = 1;
|
||||
let k = next._d;
|
||||
while (state.elMap.has(k)) {
|
||||
k = `${next._d}:${count++}`;
|
||||
}
|
||||
state.elMap.set(k, c);
|
||||
} else {
|
||||
state.elMap.set(next._d, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
state.pendingSideEffects = { ...state.sideEffects };
|
||||
state.sideEffects = {};
|
||||
function track(id, scope, fn) {
|
||||
const k = `${id}:${scope}`;
|
||||
state.sideEffects[k] = fn;
|
||||
delete state.pendingSideEffects[k];
|
||||
}
|
||||
function trackCtx({ id, $el, tag }) {
|
||||
const isAttrTag = tag.tag.endsWith("Attrs");
|
||||
state.elMap.set(id, $el);
|
||||
if (!isAttrTag) {
|
||||
if (tag.textContent && tag.textContent !== $el.textContent) {
|
||||
$el.textContent = tag.textContent;
|
||||
}
|
||||
if (tag.innerHTML && tag.innerHTML !== $el.innerHTML) {
|
||||
$el.innerHTML = tag.innerHTML;
|
||||
}
|
||||
track(id, "el", () => {
|
||||
$el?.remove();
|
||||
state.elMap.delete(id);
|
||||
});
|
||||
}
|
||||
for (const k in tag.props) {
|
||||
if (!Object.prototype.hasOwnProperty.call(tag.props, k))
|
||||
continue;
|
||||
const value = tag.props[k];
|
||||
if (k.startsWith("on") && typeof value === "function") {
|
||||
const dataset = $el?.dataset;
|
||||
if (dataset && dataset[`${k}fired`]) {
|
||||
const ek = k.slice(0, -5);
|
||||
value.call($el, new Event(ek.substring(2)));
|
||||
}
|
||||
if ($el.getAttribute(`data-${k}`) !== "") {
|
||||
(tag.tag === "bodyAttrs" ? dom.defaultView : $el).addEventListener(
|
||||
// onload -> load
|
||||
k.substring(2),
|
||||
value.bind($el)
|
||||
);
|
||||
$el.setAttribute(`data-${k}`, "");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const ck = `attr:${k}`;
|
||||
if (k === "class") {
|
||||
if (!value) {
|
||||
continue;
|
||||
}
|
||||
for (const c of value) {
|
||||
isAttrTag && track(id, `${ck}:${c}`, () => $el.classList.remove(c));
|
||||
!$el.classList.contains(c) && $el.classList.add(c);
|
||||
}
|
||||
} else if (k === "style") {
|
||||
if (!value) {
|
||||
continue;
|
||||
}
|
||||
for (const [k2, v] of value) {
|
||||
track(id, `${ck}:${k2}`, () => {
|
||||
$el.style.removeProperty(k2);
|
||||
});
|
||||
$el.style.setProperty(k2, v);
|
||||
}
|
||||
} else if (value !== false && value !== null) {
|
||||
$el.getAttribute(k) !== value && $el.setAttribute(k, value === true ? "" : String(value));
|
||||
isAttrTag && track(id, ck, () => $el.removeAttribute(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
const pending = [];
|
||||
const frag = {
|
||||
bodyClose: void 0,
|
||||
bodyOpen: void 0,
|
||||
head: void 0
|
||||
};
|
||||
const tags = await resolveTagPromise;
|
||||
for (const ctx of tags) {
|
||||
const { tag, shouldRender, id } = ctx;
|
||||
if (!shouldRender)
|
||||
continue;
|
||||
if (tag.tag === "title") {
|
||||
dom.title = tag.textContent;
|
||||
track("title", "", () => dom.title = state.title);
|
||||
continue;
|
||||
}
|
||||
ctx.$el = ctx.$el || state.elMap.get(id);
|
||||
if (ctx.$el) {
|
||||
trackCtx(ctx);
|
||||
} else if (HasElementTags.has(tag.tag)) {
|
||||
pending.push(ctx);
|
||||
}
|
||||
}
|
||||
for (const ctx of pending) {
|
||||
const pos = ctx.tag.tagPosition || "head";
|
||||
ctx.$el = dom.createElement(ctx.tag.tag);
|
||||
trackCtx(ctx);
|
||||
frag[pos] = frag[pos] || dom.createDocumentFragment();
|
||||
frag[pos].appendChild(ctx.$el);
|
||||
}
|
||||
for (const ctx of tags)
|
||||
await head.hooks.callHook("dom:renderTag", ctx, dom, track);
|
||||
frag.head && dom.head.appendChild(frag.head);
|
||||
frag.bodyOpen && dom.body.insertBefore(frag.bodyOpen, dom.body.firstChild);
|
||||
frag.bodyClose && dom.body.appendChild(frag.bodyClose);
|
||||
for (const k in state.pendingSideEffects) {
|
||||
state.pendingSideEffects[k]();
|
||||
}
|
||||
head._dom = state;
|
||||
await head.hooks.callHook("dom:rendered", { renders: tags });
|
||||
resolve();
|
||||
}).finally(() => {
|
||||
head._domUpdatePromise = void 0;
|
||||
head.dirty = false;
|
||||
});
|
||||
return head._domUpdatePromise;
|
||||
}
|
||||
|
||||
function createHead(options = {}) {
|
||||
const render = options.domOptions?.render || renderDOMHead;
|
||||
options.document = options.document || (typeof window !== "undefined" ? document : void 0);
|
||||
const initialPayload = options.document?.head.querySelector('script[id="unhead:payload"]')?.innerHTML || false;
|
||||
return createUnhead({
|
||||
...options,
|
||||
plugins: [
|
||||
...options.plugins || [],
|
||||
{
|
||||
key: "client",
|
||||
hooks: {
|
||||
"entries:updated": render
|
||||
}
|
||||
}
|
||||
],
|
||||
init: [
|
||||
initialPayload ? JSON.parse(initialPayload) : false,
|
||||
...options.init || []
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
function createDebouncedFn(callee, delayer) {
|
||||
let ctxId = 0;
|
||||
return () => {
|
||||
const delayFnCtxId = ++ctxId;
|
||||
delayer(() => {
|
||||
if (ctxId === delayFnCtxId) {
|
||||
callee();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export { createDebouncedFn, createHead, renderDOMHead };
|
||||
32
node_modules/unhead/dist/index.d.mts
generated
vendored
Normal file
32
node_modules/unhead/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { H as HeadSafe } from './shared/unhead.CBPtX666.mjs';
|
||||
import { U as Unhead, R as ResolvableHead, s as HeadEntryOptions, p as ActiveHeadEntry, a8 as UseSeoMetaInput, C as CreateHeadOptions } from './shared/unhead.BUCuVRIf.mjs';
|
||||
export { u as useScript } from './shared/unhead.CC7bAF1a.mjs';
|
||||
import 'hookable';
|
||||
|
||||
declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
|
||||
declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
||||
declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
|
||||
/**
|
||||
* @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
||||
*/
|
||||
declare function useServerHead<T extends Unhead<any>>(unhead: T, input?: Parameters<T['push']>[0], options?: Omit<HeadEntryOptions, 'mode'>): ReturnType<T['push']>;
|
||||
/**
|
||||
* @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
||||
*/
|
||||
declare function useServerHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<HeadSafe>;
|
||||
/**
|
||||
* @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
||||
*/
|
||||
declare function useServerSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<UseSeoMetaInput>;
|
||||
|
||||
/**
|
||||
* @deprecated use `createUnhead` instead
|
||||
*/
|
||||
declare function createHeadCore<T = ResolvableHead>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
||||
/**
|
||||
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
||||
* and does not register DOM plugins.
|
||||
*/
|
||||
declare function createUnhead<T = ResolvableHead>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
||||
|
||||
export { createHeadCore, createUnhead, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
||||
32
node_modules/unhead/dist/index.d.ts
generated
vendored
Normal file
32
node_modules/unhead/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { H as HeadSafe } from './shared/unhead.CsiVfkwJ.js';
|
||||
import { U as Unhead, R as ResolvableHead, s as HeadEntryOptions, p as ActiveHeadEntry, a8 as UseSeoMetaInput, C as CreateHeadOptions } from './shared/unhead.BUCuVRIf.js';
|
||||
export { u as useScript } from './shared/unhead.Btq-XLkr.js';
|
||||
import 'hookable';
|
||||
|
||||
declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
|
||||
declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
||||
declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
|
||||
/**
|
||||
* @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
||||
*/
|
||||
declare function useServerHead<T extends Unhead<any>>(unhead: T, input?: Parameters<T['push']>[0], options?: Omit<HeadEntryOptions, 'mode'>): ReturnType<T['push']>;
|
||||
/**
|
||||
* @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
||||
*/
|
||||
declare function useServerHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<HeadSafe>;
|
||||
/**
|
||||
* @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
||||
*/
|
||||
declare function useServerSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<UseSeoMetaInput>;
|
||||
|
||||
/**
|
||||
* @deprecated use `createUnhead` instead
|
||||
*/
|
||||
declare function createHeadCore<T = ResolvableHead>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
||||
/**
|
||||
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
||||
* and does not register DOM plugins.
|
||||
*/
|
||||
declare function createUnhead<T = ResolvableHead>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
||||
|
||||
export { createHeadCore, createUnhead, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
||||
9
node_modules/unhead/dist/index.mjs
generated
vendored
Normal file
9
node_modules/unhead/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export { u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/unhead.BPM0-cfG.mjs';
|
||||
export { c as createHeadCore, a as createUnhead } from './shared/unhead.BFfcxOoW.mjs';
|
||||
export { u as useScript } from './shared/unhead.B578PsDV.mjs';
|
||||
import './shared/unhead.CApf5sj3.mjs';
|
||||
import './shared/unhead.DQc16pHI.mjs';
|
||||
import './shared/unhead.yem5I2v_.mjs';
|
||||
import 'hookable';
|
||||
import './shared/unhead.eK9_7LaY.mjs';
|
||||
import './shared/unhead.CbpEuj3y.mjs';
|
||||
16
node_modules/unhead/dist/legacy.d.mts
generated
vendored
Normal file
16
node_modules/unhead/dist/legacy.d.mts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { createUnhead } from './index.mjs';
|
||||
export { useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta } from './index.mjs';
|
||||
import { U as Unhead, R as ResolvableHead, C as CreateHeadOptions } from './shared/unhead.BUCuVRIf.mjs';
|
||||
export { u as useScript } from './shared/unhead.CC7bAF1a.mjs';
|
||||
import './shared/unhead.CBPtX666.mjs';
|
||||
import 'hookable';
|
||||
|
||||
declare const activeHead: {
|
||||
value: Unhead<any> | null;
|
||||
};
|
||||
declare function getActiveHead(): Unhead<any> | null;
|
||||
declare function createServerHead<T extends Record<string, any> = ResolvableHead>(options?: CreateHeadOptions): Unhead<T>;
|
||||
declare function createHead<T extends Record<string, any> = ResolvableHead>(options?: CreateHeadOptions): Unhead<T>;
|
||||
declare const createHeadCore: typeof createUnhead;
|
||||
|
||||
export { activeHead, createHead, createHeadCore, createServerHead, createUnhead, getActiveHead };
|
||||
16
node_modules/unhead/dist/legacy.d.ts
generated
vendored
Normal file
16
node_modules/unhead/dist/legacy.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { createUnhead } from './index.js';
|
||||
export { useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta } from './index.js';
|
||||
import { U as Unhead, R as ResolvableHead, C as CreateHeadOptions } from './shared/unhead.BUCuVRIf.js';
|
||||
export { u as useScript } from './shared/unhead.Btq-XLkr.js';
|
||||
import './shared/unhead.CsiVfkwJ.js';
|
||||
import 'hookable';
|
||||
|
||||
declare const activeHead: {
|
||||
value: Unhead<any> | null;
|
||||
};
|
||||
declare function getActiveHead(): Unhead<any> | null;
|
||||
declare function createServerHead<T extends Record<string, any> = ResolvableHead>(options?: CreateHeadOptions): Unhead<T>;
|
||||
declare function createHead<T extends Record<string, any> = ResolvableHead>(options?: CreateHeadOptions): Unhead<T>;
|
||||
declare const createHeadCore: typeof createUnhead;
|
||||
|
||||
export { activeHead, createHead, createHeadCore, createServerHead, createUnhead, getActiveHead };
|
||||
47
node_modules/unhead/dist/legacy.mjs
generated
vendored
Normal file
47
node_modules/unhead/dist/legacy.mjs
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import { a as createUnhead } from './shared/unhead.BFfcxOoW.mjs';
|
||||
import { D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.ckV6dpEQ.mjs';
|
||||
export { u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/unhead.BPM0-cfG.mjs';
|
||||
export { u as useScript } from './shared/unhead.B578PsDV.mjs';
|
||||
import 'hookable';
|
||||
import './shared/unhead.eK9_7LaY.mjs';
|
||||
import './shared/unhead.yem5I2v_.mjs';
|
||||
import './shared/unhead.CbpEuj3y.mjs';
|
||||
import './shared/unhead.CApf5sj3.mjs';
|
||||
import './shared/unhead.DQc16pHI.mjs';
|
||||
import './shared/unhead.BYvz9V1x.mjs';
|
||||
|
||||
const activeHead = { value: null };
|
||||
function getActiveHead() {
|
||||
return activeHead?.value;
|
||||
}
|
||||
function createServerHead(options = {}) {
|
||||
return activeHead.value = createUnhead({
|
||||
disableCapoSorting: true,
|
||||
...options,
|
||||
// @ts-expect-error untyped
|
||||
document: false,
|
||||
plugins: [
|
||||
...options.plugins || [],
|
||||
DeprecationsPlugin,
|
||||
PromisesPlugin,
|
||||
TemplateParamsPlugin,
|
||||
AliasSortingPlugin
|
||||
]
|
||||
});
|
||||
}
|
||||
function createHead(options = {}) {
|
||||
return activeHead.value = createUnhead({
|
||||
disableCapoSorting: true,
|
||||
...options,
|
||||
plugins: [
|
||||
...options.plugins || [],
|
||||
DeprecationsPlugin,
|
||||
PromisesPlugin,
|
||||
TemplateParamsPlugin,
|
||||
AliasSortingPlugin
|
||||
]
|
||||
});
|
||||
}
|
||||
const createHeadCore = createUnhead;
|
||||
|
||||
export { activeHead, createHead, createHeadCore, createServerHead, createUnhead, getActiveHead };
|
||||
54
node_modules/unhead/dist/parser.d.mts
generated
vendored
Normal file
54
node_modules/unhead/dist/parser.d.mts
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import { S as SerializableHead } from './shared/unhead.BUCuVRIf.mjs';
|
||||
import 'hookable';
|
||||
|
||||
declare const TagIdMap: {
|
||||
readonly html: 0;
|
||||
readonly head: 1;
|
||||
readonly title: 4;
|
||||
readonly meta: 5;
|
||||
readonly body: 44;
|
||||
readonly script: 52;
|
||||
readonly style: 53;
|
||||
readonly link: 54;
|
||||
readonly base: 56;
|
||||
};
|
||||
interface PreparedHtmlTemplate {
|
||||
html: string;
|
||||
input: SerializableHead;
|
||||
}
|
||||
interface PreparedHtmlTemplateWithIndexes {
|
||||
html: string;
|
||||
input: SerializableHead;
|
||||
indexes: {
|
||||
htmlTagStart: number;
|
||||
htmlTagEnd: number;
|
||||
headTagEnd: number;
|
||||
bodyTagStart: number;
|
||||
bodyTagEnd: number;
|
||||
bodyCloseTagStart: number;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Parse HTML attributes string into key-value object
|
||||
*/
|
||||
declare function parseAttributes(attrStr: string): Record<string, string>;
|
||||
/**
|
||||
* Parse HTML to find tag indexes without extracting head elements
|
||||
* Used for transformHtmlTemplateRaw where we don't want to extract existing head content
|
||||
*/
|
||||
declare function parseHtmlForIndexes(html: string): PreparedHtmlTemplateWithIndexes;
|
||||
declare function parseHtmlForUnheadExtraction(html: string): PreparedHtmlTemplateWithIndexes;
|
||||
/**
|
||||
* Optimized HTML construction function that uses indexes instead of string.replace()
|
||||
* This avoids searching through the entire HTML
|
||||
*/
|
||||
declare function applyHeadToHtml(template: PreparedHtmlTemplateWithIndexes, headHtml: {
|
||||
htmlAttrs: string;
|
||||
headTags: string;
|
||||
bodyAttrs: string;
|
||||
bodyTagsOpen?: string;
|
||||
bodyTags: string;
|
||||
}): string;
|
||||
|
||||
export { TagIdMap, applyHeadToHtml, parseAttributes, parseHtmlForIndexes, parseHtmlForUnheadExtraction };
|
||||
export type { PreparedHtmlTemplate, PreparedHtmlTemplateWithIndexes };
|
||||
54
node_modules/unhead/dist/parser.d.ts
generated
vendored
Normal file
54
node_modules/unhead/dist/parser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import { S as SerializableHead } from './shared/unhead.BUCuVRIf.js';
|
||||
import 'hookable';
|
||||
|
||||
declare const TagIdMap: {
|
||||
readonly html: 0;
|
||||
readonly head: 1;
|
||||
readonly title: 4;
|
||||
readonly meta: 5;
|
||||
readonly body: 44;
|
||||
readonly script: 52;
|
||||
readonly style: 53;
|
||||
readonly link: 54;
|
||||
readonly base: 56;
|
||||
};
|
||||
interface PreparedHtmlTemplate {
|
||||
html: string;
|
||||
input: SerializableHead;
|
||||
}
|
||||
interface PreparedHtmlTemplateWithIndexes {
|
||||
html: string;
|
||||
input: SerializableHead;
|
||||
indexes: {
|
||||
htmlTagStart: number;
|
||||
htmlTagEnd: number;
|
||||
headTagEnd: number;
|
||||
bodyTagStart: number;
|
||||
bodyTagEnd: number;
|
||||
bodyCloseTagStart: number;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Parse HTML attributes string into key-value object
|
||||
*/
|
||||
declare function parseAttributes(attrStr: string): Record<string, string>;
|
||||
/**
|
||||
* Parse HTML to find tag indexes without extracting head elements
|
||||
* Used for transformHtmlTemplateRaw where we don't want to extract existing head content
|
||||
*/
|
||||
declare function parseHtmlForIndexes(html: string): PreparedHtmlTemplateWithIndexes;
|
||||
declare function parseHtmlForUnheadExtraction(html: string): PreparedHtmlTemplateWithIndexes;
|
||||
/**
|
||||
* Optimized HTML construction function that uses indexes instead of string.replace()
|
||||
* This avoids searching through the entire HTML
|
||||
*/
|
||||
declare function applyHeadToHtml(template: PreparedHtmlTemplateWithIndexes, headHtml: {
|
||||
htmlAttrs: string;
|
||||
headTags: string;
|
||||
bodyAttrs: string;
|
||||
bodyTagsOpen?: string;
|
||||
bodyTags: string;
|
||||
}): string;
|
||||
|
||||
export { TagIdMap, applyHeadToHtml, parseAttributes, parseHtmlForIndexes, parseHtmlForUnheadExtraction };
|
||||
export type { PreparedHtmlTemplate, PreparedHtmlTemplateWithIndexes };
|
||||
508
node_modules/unhead/dist/parser.mjs
generated
vendored
Normal file
508
node_modules/unhead/dist/parser.mjs
generated
vendored
Normal file
@@ -0,0 +1,508 @@
|
||||
const TAG_HTML = 0;
|
||||
const TAG_HEAD = 1;
|
||||
const TAG_TITLE = 4;
|
||||
const TAG_META = 5;
|
||||
const TAG_BODY = 44;
|
||||
const TAG_SCRIPT = 52;
|
||||
const TAG_STYLE = 53;
|
||||
const TAG_LINK = 54;
|
||||
const TAG_BASE = 56;
|
||||
const LT_CHAR = 60;
|
||||
const GT_CHAR = 62;
|
||||
const SLASH_CHAR = 47;
|
||||
const EQUALS_CHAR = 61;
|
||||
const QUOTE_CHAR = 34;
|
||||
const APOS_CHAR = 39;
|
||||
const EXCLAMATION_CHAR = 33;
|
||||
const BACKSLASH_CHAR = 92;
|
||||
const DASH_CHAR = 45;
|
||||
const TagIdMap = {
|
||||
html: TAG_HTML,
|
||||
head: TAG_HEAD,
|
||||
title: TAG_TITLE,
|
||||
meta: TAG_META,
|
||||
body: TAG_BODY,
|
||||
script: TAG_SCRIPT,
|
||||
style: TAG_STYLE,
|
||||
link: TAG_LINK,
|
||||
base: TAG_BASE
|
||||
};
|
||||
function isWhitespace(charCode) {
|
||||
return charCode === 32 || charCode === 9 || charCode === 10 || charCode === 13;
|
||||
}
|
||||
function processCommentOrDoctype(htmlChunk, position) {
|
||||
let i = position;
|
||||
const chunkLength = htmlChunk.length;
|
||||
if (i + 3 < chunkLength && htmlChunk.charCodeAt(i + 2) === DASH_CHAR && htmlChunk.charCodeAt(i + 3) === DASH_CHAR) {
|
||||
i += 4;
|
||||
while (i < chunkLength - 2) {
|
||||
if (htmlChunk.charCodeAt(i) === DASH_CHAR && htmlChunk.charCodeAt(i + 1) === DASH_CHAR && htmlChunk.charCodeAt(i + 2) === GT_CHAR) {
|
||||
i += 3;
|
||||
return {
|
||||
complete: true,
|
||||
newPosition: i,
|
||||
remainingText: ""
|
||||
};
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return {
|
||||
complete: false,
|
||||
newPosition: position,
|
||||
remainingText: htmlChunk.substring(position)
|
||||
};
|
||||
} else {
|
||||
i += 2;
|
||||
while (i < chunkLength) {
|
||||
if (htmlChunk.charCodeAt(i) === GT_CHAR) {
|
||||
i++;
|
||||
return {
|
||||
complete: true,
|
||||
newPosition: i,
|
||||
remainingText: ""
|
||||
};
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return {
|
||||
complete: false,
|
||||
newPosition: i,
|
||||
remainingText: htmlChunk.substring(position, i)
|
||||
};
|
||||
}
|
||||
}
|
||||
function parseAttributes(attrStr) {
|
||||
if (!attrStr)
|
||||
return {};
|
||||
const result = {};
|
||||
const len = attrStr.length;
|
||||
let i = 0;
|
||||
const WHITESPACE = 0;
|
||||
const NAME = 1;
|
||||
const AFTER_NAME = 2;
|
||||
const BEFORE_VALUE = 3;
|
||||
const QUOTED_VALUE = 4;
|
||||
const UNQUOTED_VALUE = 5;
|
||||
let state = WHITESPACE;
|
||||
let nameStart = 0;
|
||||
let nameEnd = 0;
|
||||
let valueStart = 0;
|
||||
let quoteChar = 0;
|
||||
let name = "";
|
||||
while (i < len) {
|
||||
const charCode = attrStr.charCodeAt(i);
|
||||
const isSpace = isWhitespace(charCode);
|
||||
switch (state) {
|
||||
case WHITESPACE:
|
||||
if (!isSpace) {
|
||||
state = NAME;
|
||||
nameStart = i;
|
||||
nameEnd = 0;
|
||||
}
|
||||
break;
|
||||
case NAME:
|
||||
if (charCode === EQUALS_CHAR || isSpace) {
|
||||
nameEnd = i;
|
||||
name = attrStr.substring(nameStart, nameEnd).toLowerCase();
|
||||
state = charCode === EQUALS_CHAR ? BEFORE_VALUE : AFTER_NAME;
|
||||
}
|
||||
break;
|
||||
case AFTER_NAME:
|
||||
if (charCode === EQUALS_CHAR) {
|
||||
state = BEFORE_VALUE;
|
||||
} else if (!isSpace) {
|
||||
result[name] = "";
|
||||
state = NAME;
|
||||
nameStart = i;
|
||||
nameEnd = 0;
|
||||
}
|
||||
break;
|
||||
case BEFORE_VALUE:
|
||||
if (charCode === QUOTE_CHAR || charCode === APOS_CHAR) {
|
||||
quoteChar = charCode;
|
||||
state = QUOTED_VALUE;
|
||||
valueStart = i + 1;
|
||||
} else if (!isSpace) {
|
||||
state = UNQUOTED_VALUE;
|
||||
valueStart = i;
|
||||
}
|
||||
break;
|
||||
case QUOTED_VALUE:
|
||||
if (charCode === BACKSLASH_CHAR && i + 1 < len) {
|
||||
i++;
|
||||
} else if (charCode === quoteChar) {
|
||||
result[name] = attrStr.substring(valueStart, i);
|
||||
state = WHITESPACE;
|
||||
}
|
||||
break;
|
||||
case UNQUOTED_VALUE:
|
||||
if (isSpace || charCode === GT_CHAR) {
|
||||
result[name] = attrStr.substring(valueStart, i);
|
||||
state = WHITESPACE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (state === QUOTED_VALUE || state === UNQUOTED_VALUE) {
|
||||
if (name) {
|
||||
result[name] = attrStr.substring(valueStart, i);
|
||||
}
|
||||
} else if (state === NAME || state === AFTER_NAME || state === BEFORE_VALUE) {
|
||||
nameEnd = nameEnd || i;
|
||||
const currentName = attrStr.substring(nameStart, nameEnd).toLowerCase();
|
||||
if (currentName) {
|
||||
result[currentName] = "";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function parseHtmlForIndexes(html) {
|
||||
const indexes = {
|
||||
htmlTagStart: html.indexOf("<html"),
|
||||
htmlTagEnd: -1,
|
||||
headTagEnd: html.indexOf("</head>"),
|
||||
bodyTagStart: html.indexOf("<body"),
|
||||
bodyTagEnd: -1,
|
||||
bodyCloseTagStart: html.indexOf("</body>")
|
||||
};
|
||||
if (indexes.htmlTagStart >= 0) {
|
||||
const htmlTagEndPos = html.indexOf(">", indexes.htmlTagStart);
|
||||
if (htmlTagEndPos >= 0) {
|
||||
indexes.htmlTagEnd = htmlTagEndPos + 1;
|
||||
}
|
||||
}
|
||||
if (indexes.bodyTagStart >= 0) {
|
||||
const bodyTagEndPos = html.indexOf(">", indexes.bodyTagStart);
|
||||
if (bodyTagEndPos >= 0) {
|
||||
indexes.bodyTagEnd = bodyTagEndPos + 1;
|
||||
}
|
||||
}
|
||||
return { html, input: {}, indexes };
|
||||
}
|
||||
function parseHtmlForUnheadExtraction(html) {
|
||||
const input = {};
|
||||
const htmlParts = [];
|
||||
let position = 0;
|
||||
let inHead = false;
|
||||
let foundBodyStart = false;
|
||||
let lastCopyPosition = 0;
|
||||
let currentOutputLength = 0;
|
||||
const indexes = {
|
||||
htmlTagStart: -1,
|
||||
htmlTagEnd: -1,
|
||||
headTagEnd: -1,
|
||||
bodyTagStart: -1,
|
||||
bodyTagEnd: -1,
|
||||
bodyCloseTagStart: -1
|
||||
};
|
||||
const headElementsToExtract = /* @__PURE__ */ new Set([TAG_TITLE, TAG_META, TAG_LINK, TAG_SCRIPT, TAG_STYLE, TAG_BASE]);
|
||||
function copyAccumulatedText() {
|
||||
if (lastCopyPosition < position) {
|
||||
const textToAdd = html.substring(lastCopyPosition, position);
|
||||
htmlParts.push(textToAdd);
|
||||
currentOutputLength += textToAdd.length;
|
||||
lastCopyPosition = position;
|
||||
}
|
||||
}
|
||||
function addText(text) {
|
||||
htmlParts.push(text);
|
||||
currentOutputLength += text.length;
|
||||
}
|
||||
while (position < html.length && !foundBodyStart) {
|
||||
const currentCharCode = html.charCodeAt(position);
|
||||
if (currentCharCode !== LT_CHAR) {
|
||||
position++;
|
||||
continue;
|
||||
}
|
||||
if (position + 1 >= html.length) {
|
||||
copyAccumulatedText();
|
||||
addText(html[position]);
|
||||
break;
|
||||
}
|
||||
const nextCharCode = html.charCodeAt(position + 1);
|
||||
if (nextCharCode === EXCLAMATION_CHAR) {
|
||||
const result = processCommentOrDoctype(html, position);
|
||||
if (result.complete) {
|
||||
copyAccumulatedText();
|
||||
addText(html.substring(position, result.newPosition));
|
||||
position = result.newPosition;
|
||||
lastCopyPosition = position;
|
||||
} else {
|
||||
copyAccumulatedText();
|
||||
addText(html.substring(position));
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (nextCharCode === SLASH_CHAR) {
|
||||
let tagEnd2 = position + 2;
|
||||
while (tagEnd2 < html.length && html.charCodeAt(tagEnd2) !== GT_CHAR) {
|
||||
tagEnd2++;
|
||||
}
|
||||
if (tagEnd2 >= html.length) {
|
||||
copyAccumulatedText();
|
||||
addText(html.substring(position));
|
||||
break;
|
||||
}
|
||||
const tagName2 = html.substring(position + 2, tagEnd2).toLowerCase().trim();
|
||||
const tagId2 = TagIdMap[tagName2] ?? -1;
|
||||
if (tagId2 === TAG_HEAD) {
|
||||
inHead = false;
|
||||
copyAccumulatedText();
|
||||
const headCloseStart = currentOutputLength;
|
||||
addText(html.substring(position, tagEnd2 + 1));
|
||||
indexes.headTagEnd = headCloseStart;
|
||||
} else {
|
||||
copyAccumulatedText();
|
||||
addText(html.substring(position, tagEnd2 + 1));
|
||||
}
|
||||
position = tagEnd2 + 1;
|
||||
lastCopyPosition = position;
|
||||
continue;
|
||||
}
|
||||
const tagStart = position + 1;
|
||||
let tagNameEnd = tagStart;
|
||||
while (tagNameEnd < html.length) {
|
||||
const c = html.charCodeAt(tagNameEnd);
|
||||
if (isWhitespace(c) || c === SLASH_CHAR || c === GT_CHAR) {
|
||||
break;
|
||||
}
|
||||
tagNameEnd++;
|
||||
}
|
||||
if (tagNameEnd >= html.length) {
|
||||
copyAccumulatedText();
|
||||
addText(html.substring(position));
|
||||
break;
|
||||
}
|
||||
const tagName = html.substring(tagStart, tagNameEnd).toLowerCase();
|
||||
const tagId = TagIdMap[tagName] ?? -1;
|
||||
let tagEnd = tagNameEnd;
|
||||
let inQuote = false;
|
||||
let quoteChar = 0;
|
||||
let foundEnd = false;
|
||||
let isSelfClosing = false;
|
||||
while (tagEnd < html.length && !foundEnd) {
|
||||
const c = html.charCodeAt(tagEnd);
|
||||
if (inQuote) {
|
||||
if (c === quoteChar) {
|
||||
inQuote = false;
|
||||
}
|
||||
} else if (c === QUOTE_CHAR || c === APOS_CHAR) {
|
||||
inQuote = true;
|
||||
quoteChar = c;
|
||||
} else if (c === SLASH_CHAR && tagEnd + 1 < html.length && html.charCodeAt(tagEnd + 1) === GT_CHAR) {
|
||||
isSelfClosing = true;
|
||||
tagEnd += 2;
|
||||
foundEnd = true;
|
||||
continue;
|
||||
} else if (c === GT_CHAR) {
|
||||
tagEnd++;
|
||||
foundEnd = true;
|
||||
continue;
|
||||
}
|
||||
tagEnd++;
|
||||
}
|
||||
if (!foundEnd) {
|
||||
copyAccumulatedText();
|
||||
addText(html.substring(position));
|
||||
break;
|
||||
}
|
||||
const attributesStr = html.substring(tagNameEnd, tagEnd - (isSelfClosing ? 2 : 1)).trim();
|
||||
const attributes = parseAttributes(attributesStr);
|
||||
if (tagId === TAG_HTML) {
|
||||
copyAccumulatedText();
|
||||
indexes.htmlTagStart = currentOutputLength;
|
||||
if (Object.keys(attributes).length > 0) {
|
||||
input.htmlAttrs = attributes;
|
||||
addText(`<${tagName}>`);
|
||||
} else {
|
||||
addText(html.substring(position, tagEnd));
|
||||
}
|
||||
indexes.htmlTagEnd = currentOutputLength;
|
||||
} else if (tagId === TAG_BODY) {
|
||||
copyAccumulatedText();
|
||||
indexes.bodyTagStart = currentOutputLength;
|
||||
if (Object.keys(attributes).length > 0) {
|
||||
input.bodyAttrs = attributes;
|
||||
addText(`<${tagName}>`);
|
||||
} else {
|
||||
addText(html.substring(position, tagEnd));
|
||||
}
|
||||
indexes.bodyTagEnd = currentOutputLength;
|
||||
foundBodyStart = true;
|
||||
position = tagEnd;
|
||||
lastCopyPosition = position;
|
||||
break;
|
||||
} else if (tagId === TAG_HEAD) {
|
||||
inHead = true;
|
||||
copyAccumulatedText();
|
||||
addText(html.substring(position, tagEnd));
|
||||
} else if (inHead && headElementsToExtract.has(tagId)) {
|
||||
if (tagId === TAG_TITLE) {
|
||||
if (!isSelfClosing) {
|
||||
const titleEnd = findClosingTag(html, tagEnd, tagName);
|
||||
if (titleEnd !== -1) {
|
||||
const titleContent = html.substring(tagEnd, titleEnd).trim();
|
||||
if (titleContent && !input.title) {
|
||||
input.title = titleContent;
|
||||
}
|
||||
position = findTagEnd(html, titleEnd, tagName);
|
||||
lastCopyPosition = position;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else if (tagId === TAG_SCRIPT) {
|
||||
const scriptAttrs = { ...attributes };
|
||||
if (!isSelfClosing) {
|
||||
const scriptEnd = findClosingTag(html, tagEnd, tagName);
|
||||
if (scriptEnd !== -1) {
|
||||
const scriptContent = html.substring(tagEnd, scriptEnd);
|
||||
scriptAttrs.innerHTML = scriptContent || "";
|
||||
position = findTagEnd(html, scriptEnd, tagName);
|
||||
} else {
|
||||
scriptAttrs.innerHTML = "";
|
||||
position = tagEnd;
|
||||
}
|
||||
} else {
|
||||
scriptAttrs.innerHTML = "";
|
||||
position = tagEnd;
|
||||
}
|
||||
lastCopyPosition = position;
|
||||
(input.script ||= []).push(scriptAttrs);
|
||||
continue;
|
||||
} else if (tagId === TAG_STYLE) {
|
||||
const styleAttrs = { ...attributes };
|
||||
if (!isSelfClosing) {
|
||||
const styleEnd = findClosingTag(html, tagEnd, tagName);
|
||||
if (styleEnd !== -1) {
|
||||
const styleContent = html.substring(tagEnd, styleEnd);
|
||||
styleAttrs.textContent = styleContent || "";
|
||||
position = findTagEnd(html, styleEnd, tagName);
|
||||
} else {
|
||||
styleAttrs.textContent = "";
|
||||
position = tagEnd;
|
||||
}
|
||||
} else {
|
||||
styleAttrs.textContent = "";
|
||||
position = tagEnd;
|
||||
}
|
||||
lastCopyPosition = position;
|
||||
(input.style ||= []).push(styleAttrs);
|
||||
continue;
|
||||
} else if (tagId === TAG_META) {
|
||||
(input.meta ||= []).push(attributes);
|
||||
position = tagEnd;
|
||||
lastCopyPosition = position;
|
||||
continue;
|
||||
} else if (tagId === TAG_LINK) {
|
||||
(input.link ||= []).push(attributes);
|
||||
position = tagEnd;
|
||||
lastCopyPosition = position;
|
||||
continue;
|
||||
} else if (tagId === TAG_BASE && !input.base) {
|
||||
input.base = attributes;
|
||||
position = tagEnd;
|
||||
lastCopyPosition = position;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
copyAccumulatedText();
|
||||
addText(html.substring(position, tagEnd));
|
||||
}
|
||||
position = tagEnd;
|
||||
lastCopyPosition = position;
|
||||
}
|
||||
const remainingHtml = html.substring(position);
|
||||
const bodyCloseIndex = remainingHtml.indexOf("</body>");
|
||||
if (bodyCloseIndex !== -1) {
|
||||
indexes.bodyCloseTagStart = currentOutputLength + bodyCloseIndex;
|
||||
}
|
||||
copyAccumulatedText();
|
||||
addText(remainingHtml);
|
||||
return { html: htmlParts.join(""), input, indexes };
|
||||
}
|
||||
function findClosingTag(html, startPos, tagName) {
|
||||
const tagId = TagIdMap[tagName];
|
||||
const isScriptOrStyle = tagId === TAG_SCRIPT || tagId === TAG_STYLE;
|
||||
if (!isScriptOrStyle) {
|
||||
const closingTag2 = `</${tagName}`;
|
||||
const index = html.indexOf(closingTag2, startPos);
|
||||
return index === -1 ? -1 : index;
|
||||
}
|
||||
const closingTag = `</${tagName}`;
|
||||
let pos = startPos;
|
||||
let inSingleQuote = false;
|
||||
let inDoubleQuote = false;
|
||||
let inBacktick = false;
|
||||
let lastCharWasBackslash = false;
|
||||
while (pos < html.length) {
|
||||
const currentCharCode = html.charCodeAt(pos);
|
||||
if (!lastCharWasBackslash) {
|
||||
if (currentCharCode === APOS_CHAR && !inDoubleQuote && !inBacktick) {
|
||||
inSingleQuote = !inSingleQuote;
|
||||
} else if (currentCharCode === QUOTE_CHAR && !inSingleQuote && !inBacktick) {
|
||||
inDoubleQuote = !inDoubleQuote;
|
||||
} else if (currentCharCode === 96 && !inSingleQuote && !inDoubleQuote) {
|
||||
inBacktick = !inBacktick;
|
||||
}
|
||||
}
|
||||
lastCharWasBackslash = currentCharCode === BACKSLASH_CHAR && !lastCharWasBackslash;
|
||||
const inQuotes = inSingleQuote || inDoubleQuote || inBacktick;
|
||||
if (!inQuotes && html.startsWith(closingTag, pos)) {
|
||||
const afterTagPos = pos + closingTag.length;
|
||||
if (afterTagPos >= html.length) {
|
||||
return pos;
|
||||
}
|
||||
const nextChar = html.charCodeAt(afterTagPos);
|
||||
if (nextChar === GT_CHAR || isWhitespace(nextChar)) {
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function findTagEnd(html, closingTagStart, tagName) {
|
||||
let pos = closingTagStart + tagName.length + 2;
|
||||
while (pos < html.length && html.charCodeAt(pos) !== GT_CHAR) {
|
||||
pos++;
|
||||
}
|
||||
return pos < html.length ? pos + 1 : pos;
|
||||
}
|
||||
function applyHeadToHtml(template, headHtml) {
|
||||
const { html, indexes } = template;
|
||||
const parts = [];
|
||||
let lastIndex = 0;
|
||||
if (indexes.htmlTagStart >= 0) {
|
||||
parts.push(html.substring(lastIndex, indexes.htmlTagStart));
|
||||
parts.push(`<html${headHtml.htmlAttrs}>`);
|
||||
lastIndex = indexes.htmlTagEnd;
|
||||
}
|
||||
if (indexes.headTagEnd >= 0) {
|
||||
parts.push(html.substring(lastIndex, indexes.headTagEnd));
|
||||
parts.push(headHtml.headTags);
|
||||
parts.push("</head>");
|
||||
lastIndex = indexes.headTagEnd + 7;
|
||||
}
|
||||
if (indexes.bodyTagStart >= 0) {
|
||||
parts.push(html.substring(lastIndex, indexes.bodyTagStart));
|
||||
if (headHtml.bodyTagsOpen) {
|
||||
parts.push(`<body${headHtml.bodyAttrs}>
|
||||
${headHtml.bodyTagsOpen}`);
|
||||
} else {
|
||||
parts.push(`<body${headHtml.bodyAttrs}>`);
|
||||
}
|
||||
lastIndex = indexes.bodyTagEnd;
|
||||
}
|
||||
if (indexes.bodyCloseTagStart >= 0) {
|
||||
parts.push(html.substring(lastIndex, indexes.bodyCloseTagStart));
|
||||
parts.push(headHtml.bodyTags);
|
||||
parts.push(html.substring(indexes.bodyCloseTagStart));
|
||||
} else {
|
||||
parts.push(html.substring(lastIndex));
|
||||
}
|
||||
return parts.join("");
|
||||
}
|
||||
|
||||
export { TagIdMap, applyHeadToHtml, parseAttributes, parseHtmlForIndexes, parseHtmlForUnheadExtraction };
|
||||
65
node_modules/unhead/dist/plugins.d.mts
generated
vendored
Normal file
65
node_modules/unhead/dist/plugins.d.mts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { n as HeadPluginInput, U as Unhead, m as HeadPluginOptions } from './shared/unhead.BUCuVRIf.mjs';
|
||||
import 'hookable';
|
||||
|
||||
declare const AliasSortingPlugin: HeadPluginInput;
|
||||
|
||||
interface CanonicalPluginOptions {
|
||||
canonicalHost?: string;
|
||||
customResolver?: (url: string) => string;
|
||||
}
|
||||
/**
|
||||
* CanonicalPlugin resolves paths in tags that require a canonical host to be set.
|
||||
*
|
||||
* - Resolves paths in meta tags like `og:image` and `twitter:image`.
|
||||
* - Resolves paths in the `og:url` meta tag.
|
||||
* - Resolves paths in the `link` tag with the `rel="canonical"` attribute.
|
||||
* @example
|
||||
* const plugin = CanonicalPlugin({
|
||||
* canonicalHost: 'https://example.com',
|
||||
* customResolver: (path) => `/custom${path}`,
|
||||
* });
|
||||
*
|
||||
* // This plugin will resolve URLs in meta tags like:
|
||||
* // <meta property="og:image" content="/image.jpg">
|
||||
* // to:
|
||||
* // <meta property="og:image" content="https://example.com/image.jpg">
|
||||
*/
|
||||
declare function CanonicalPlugin(options: CanonicalPluginOptions): ((head: Unhead) => HeadPluginOptions & {
|
||||
key: string;
|
||||
});
|
||||
|
||||
declare function defineHeadPlugin(plugin: HeadPluginInput): HeadPluginInput;
|
||||
|
||||
declare const DeprecationsPlugin: HeadPluginInput;
|
||||
|
||||
declare const FlatMetaPlugin: HeadPluginInput;
|
||||
|
||||
interface InferSeoMetaPluginOptions {
|
||||
/**
|
||||
* Transform the og title.
|
||||
*
|
||||
* @param title
|
||||
*/
|
||||
ogTitle?: ((title?: string) => string);
|
||||
/**
|
||||
* Transform the og description.
|
||||
*
|
||||
* @param title
|
||||
*/
|
||||
ogDescription?: ((description?: string) => string);
|
||||
/**
|
||||
* The twitter card to use.
|
||||
*
|
||||
* @default 'summary_large_image'
|
||||
*/
|
||||
twitterCard?: false | 'summary' | 'summary_large_image' | 'app' | 'player';
|
||||
}
|
||||
declare function InferSeoMetaPlugin(options?: InferSeoMetaPluginOptions): HeadPluginInput;
|
||||
|
||||
declare const PromisesPlugin: HeadPluginInput;
|
||||
|
||||
declare const SafeInputPlugin: HeadPluginInput;
|
||||
|
||||
declare const TemplateParamsPlugin: HeadPluginInput;
|
||||
|
||||
export { AliasSortingPlugin, CanonicalPlugin, DeprecationsPlugin, FlatMetaPlugin, InferSeoMetaPlugin, PromisesPlugin, SafeInputPlugin, TemplateParamsPlugin, defineHeadPlugin };
|
||||
65
node_modules/unhead/dist/plugins.d.ts
generated
vendored
Normal file
65
node_modules/unhead/dist/plugins.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { n as HeadPluginInput, U as Unhead, m as HeadPluginOptions } from './shared/unhead.BUCuVRIf.js';
|
||||
import 'hookable';
|
||||
|
||||
declare const AliasSortingPlugin: HeadPluginInput;
|
||||
|
||||
interface CanonicalPluginOptions {
|
||||
canonicalHost?: string;
|
||||
customResolver?: (url: string) => string;
|
||||
}
|
||||
/**
|
||||
* CanonicalPlugin resolves paths in tags that require a canonical host to be set.
|
||||
*
|
||||
* - Resolves paths in meta tags like `og:image` and `twitter:image`.
|
||||
* - Resolves paths in the `og:url` meta tag.
|
||||
* - Resolves paths in the `link` tag with the `rel="canonical"` attribute.
|
||||
* @example
|
||||
* const plugin = CanonicalPlugin({
|
||||
* canonicalHost: 'https://example.com',
|
||||
* customResolver: (path) => `/custom${path}`,
|
||||
* });
|
||||
*
|
||||
* // This plugin will resolve URLs in meta tags like:
|
||||
* // <meta property="og:image" content="/image.jpg">
|
||||
* // to:
|
||||
* // <meta property="og:image" content="https://example.com/image.jpg">
|
||||
*/
|
||||
declare function CanonicalPlugin(options: CanonicalPluginOptions): ((head: Unhead) => HeadPluginOptions & {
|
||||
key: string;
|
||||
});
|
||||
|
||||
declare function defineHeadPlugin(plugin: HeadPluginInput): HeadPluginInput;
|
||||
|
||||
declare const DeprecationsPlugin: HeadPluginInput;
|
||||
|
||||
declare const FlatMetaPlugin: HeadPluginInput;
|
||||
|
||||
interface InferSeoMetaPluginOptions {
|
||||
/**
|
||||
* Transform the og title.
|
||||
*
|
||||
* @param title
|
||||
*/
|
||||
ogTitle?: ((title?: string) => string);
|
||||
/**
|
||||
* Transform the og description.
|
||||
*
|
||||
* @param title
|
||||
*/
|
||||
ogDescription?: ((description?: string) => string);
|
||||
/**
|
||||
* The twitter card to use.
|
||||
*
|
||||
* @default 'summary_large_image'
|
||||
*/
|
||||
twitterCard?: false | 'summary' | 'summary_large_image' | 'app' | 'player';
|
||||
}
|
||||
declare function InferSeoMetaPlugin(options?: InferSeoMetaPluginOptions): HeadPluginInput;
|
||||
|
||||
declare const PromisesPlugin: HeadPluginInput;
|
||||
|
||||
declare const SafeInputPlugin: HeadPluginInput;
|
||||
|
||||
declare const TemplateParamsPlugin: HeadPluginInput;
|
||||
|
||||
export { AliasSortingPlugin, CanonicalPlugin, DeprecationsPlugin, FlatMetaPlugin, InferSeoMetaPlugin, PromisesPlugin, SafeInputPlugin, TemplateParamsPlugin, defineHeadPlugin };
|
||||
101
node_modules/unhead/dist/plugins.mjs
generated
vendored
Normal file
101
node_modules/unhead/dist/plugins.mjs
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
export { A as AliasSortingPlugin, D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin } from './shared/unhead.ckV6dpEQ.mjs';
|
||||
import { d as defineHeadPlugin } from './shared/unhead.CApf5sj3.mjs';
|
||||
export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.CApf5sj3.mjs';
|
||||
import './shared/unhead.CbpEuj3y.mjs';
|
||||
import './shared/unhead.BYvz9V1x.mjs';
|
||||
import './shared/unhead.DQc16pHI.mjs';
|
||||
import './shared/unhead.yem5I2v_.mjs';
|
||||
|
||||
const META_TRANSFORMABLE_URL = [
|
||||
"og:url",
|
||||
"og:image",
|
||||
"og:image:secure_url",
|
||||
"twitter:image",
|
||||
"twitter:image:src",
|
||||
"og:video",
|
||||
"og:video:secure_url",
|
||||
"og:see_also"
|
||||
];
|
||||
function CanonicalPlugin(options) {
|
||||
return (head) => {
|
||||
let host = options.canonicalHost || (!head.ssr ? window.location.origin : "");
|
||||
if (!host.startsWith("http") && !host.startsWith("//")) {
|
||||
host = `https://${host}`;
|
||||
}
|
||||
host = new URL(host).origin;
|
||||
function resolvePath(path) {
|
||||
if (options?.customResolver) {
|
||||
return options.customResolver(path);
|
||||
}
|
||||
if (path.startsWith("http") || path.startsWith("//"))
|
||||
return path;
|
||||
try {
|
||||
return new URL(path, host).toString();
|
||||
} catch {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return {
|
||||
key: "canonical",
|
||||
hooks: {
|
||||
"tags:resolve": (ctx) => {
|
||||
for (const tag of ctx.tags) {
|
||||
if (tag.tag === "meta" && (META_TRANSFORMABLE_URL.includes(tag.props?.property) || META_TRANSFORMABLE_URL.includes(tag.props?.name))) {
|
||||
tag.props.content = resolvePath(tag.props.content);
|
||||
} else if (tag.tag === "link" && tag.props.rel === "canonical") {
|
||||
tag.props.href = resolvePath(tag.props.href);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function InferSeoMetaPlugin(options = {}) {
|
||||
return defineHeadPlugin((head) => {
|
||||
head.push({
|
||||
meta: [
|
||||
{
|
||||
name: "twitter:card",
|
||||
content: options.twitterCard || "summary_large_image",
|
||||
tagPriority: "low"
|
||||
},
|
||||
{
|
||||
"property": "og:title",
|
||||
"tagPriority": "low",
|
||||
"data-infer": ""
|
||||
},
|
||||
{
|
||||
"property": "og:description",
|
||||
"tagPriority": "low",
|
||||
"data-infer": ""
|
||||
}
|
||||
]
|
||||
});
|
||||
return {
|
||||
key: "infer-seo-meta",
|
||||
hooks: {
|
||||
"tags:beforeResolve": ({ tagMap }) => {
|
||||
let title = head._titleTemplate || head._title;
|
||||
const ogTitle = tagMap.get("meta:og:title");
|
||||
if (typeof ogTitle?.props["data-infer"] !== "undefined") {
|
||||
if (typeof title === "function") {
|
||||
title = title(head._title);
|
||||
}
|
||||
ogTitle.props.content = options.ogTitle ? options.ogTitle(title) : title || "";
|
||||
ogTitle.processTemplateParams = true;
|
||||
}
|
||||
const description = tagMap.get("meta:description")?.props?.content;
|
||||
const ogDescription = tagMap.get("meta:og:description");
|
||||
if (typeof ogDescription?.props["data-infer"] !== "undefined") {
|
||||
ogDescription.props.content = options.ogDescription ? options.ogDescription(description) : description || "";
|
||||
ogDescription.processTemplateParams = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export { CanonicalPlugin, InferSeoMetaPlugin, defineHeadPlugin };
|
||||
8
node_modules/unhead/dist/scripts.d.mts
generated
vendored
Normal file
8
node_modules/unhead/dist/scripts.d.mts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { j as RecordingEntry } from './shared/unhead.BUCuVRIf.mjs';
|
||||
export { A as AsVoidFunctions, E as EventHandlerOptions, i as ScriptInstance, h as UseFunctionType, g as UseScriptContext, a as UseScriptInput, b as UseScriptOptions, d as UseScriptResolvedInput, c as UseScriptReturn, f as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.BUCuVRIf.mjs';
|
||||
export { r as resolveScriptKey, u as useScript } from './shared/unhead.CC7bAF1a.mjs';
|
||||
import 'hookable';
|
||||
|
||||
declare function createSpyProxy<T extends Record<string, any> | any[]>(target: T, onApply: (stack: RecordingEntry[][]) => void): T;
|
||||
|
||||
export { RecordingEntry, createSpyProxy };
|
||||
8
node_modules/unhead/dist/scripts.d.ts
generated
vendored
Normal file
8
node_modules/unhead/dist/scripts.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { j as RecordingEntry } from './shared/unhead.BUCuVRIf.js';
|
||||
export { A as AsVoidFunctions, E as EventHandlerOptions, i as ScriptInstance, h as UseFunctionType, g as UseScriptContext, a as UseScriptInput, b as UseScriptOptions, d as UseScriptResolvedInput, c as UseScriptReturn, f as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.BUCuVRIf.js';
|
||||
export { r as resolveScriptKey, u as useScript } from './shared/unhead.Btq-XLkr.js';
|
||||
import 'hookable';
|
||||
|
||||
declare function createSpyProxy<T extends Record<string, any> | any[]>(target: T, onApply: (stack: RecordingEntry[][]) => void): T;
|
||||
|
||||
export { RecordingEntry, createSpyProxy };
|
||||
30
node_modules/unhead/dist/scripts.mjs
generated
vendored
Normal file
30
node_modules/unhead/dist/scripts.mjs
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export { r as resolveScriptKey, u as useScript } from './shared/unhead.B578PsDV.mjs';
|
||||
import './shared/unhead.yem5I2v_.mjs';
|
||||
|
||||
function createSpyProxy(target, onApply) {
|
||||
const stack = [];
|
||||
let stackIdx = -1;
|
||||
const handler = (reuseStack = false) => ({
|
||||
get(_, prop, receiver) {
|
||||
if (!reuseStack) {
|
||||
stackIdx++;
|
||||
stack[stackIdx] = [];
|
||||
}
|
||||
const v = Reflect.get(_, prop, receiver);
|
||||
if (typeof v === "object" || typeof v === "function") {
|
||||
stack[stackIdx].push({ type: "get", key: prop });
|
||||
return new Proxy(v, handler(true));
|
||||
}
|
||||
stack[stackIdx].push({ type: "get", key: prop, value: v });
|
||||
return v;
|
||||
},
|
||||
apply(_, __, args) {
|
||||
stack[stackIdx].push({ type: "apply", key: "", args });
|
||||
onApply(stack);
|
||||
return Reflect.apply(_, __, args);
|
||||
}
|
||||
});
|
||||
return new Proxy(target, handler());
|
||||
}
|
||||
|
||||
export { createSpyProxy };
|
||||
52
node_modules/unhead/dist/server.d.mts
generated
vendored
Normal file
52
node_modules/unhead/dist/server.d.mts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { R as ResolvableHead, q as CreateServerHeadOptions, U as Unhead, v as RenderSSRHeadOptions, au as HeadTag } from './shared/unhead.BUCuVRIf.mjs';
|
||||
export { u as SSRHeadPayload } from './shared/unhead.BUCuVRIf.mjs';
|
||||
import { PreparedHtmlTemplate } from './parser.mjs';
|
||||
import 'hookable';
|
||||
|
||||
declare function createHead<T = ResolvableHead>(options?: CreateServerHeadOptions): Unhead<T>;
|
||||
|
||||
declare function renderSSRHead(head: Unhead<any>, options?: RenderSSRHeadOptions): Promise<{
|
||||
headTags: string;
|
||||
bodyTags: string;
|
||||
bodyTagsOpen: string;
|
||||
htmlAttrs: string;
|
||||
bodyAttrs: string;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Transform an HTML template string by extracting any head tags and attributes from it, pushing them to Unhead,
|
||||
* and injecting the resulting head tags back into the HTML.
|
||||
* Uses optimized parsing and index-based HTML construction for best performance.
|
||||
*/
|
||||
declare function transformHtmlTemplate(head: Unhead<any>, html: string, options?: RenderSSRHeadOptions): Promise<string>;
|
||||
/**
|
||||
* Transform an HTML template string by injecting head tags managed by Unhead.
|
||||
*
|
||||
* The differs to `transformHtmlTemplate` in that it does not extract and push any head input from the HTML, resulting
|
||||
* in much more performant execution if you don't need that feature.
|
||||
*
|
||||
* However, this also means that any head tags or attributes already present in the HTML may be duplicated or
|
||||
* ordered incorrectly, so use with caution.
|
||||
*/
|
||||
declare function transformHtmlTemplateRaw(head: Unhead<any>, html: string, options?: RenderSSRHeadOptions): Promise<string>;
|
||||
|
||||
/**
|
||||
* @deprecated use `parseHtmlForUnheadExtraction` from `unhead/parser` instead
|
||||
* @param html
|
||||
*/
|
||||
declare function extractUnheadInputFromHtml(html: string): PreparedHtmlTemplate;
|
||||
|
||||
declare function propsToString(props: Record<string, any>): string;
|
||||
|
||||
declare function ssrRenderTags<T extends HeadTag>(tags: T[], options?: RenderSSRHeadOptions): {
|
||||
headTags: string;
|
||||
bodyTags: string;
|
||||
bodyTagsOpen: string;
|
||||
htmlAttrs: string;
|
||||
bodyAttrs: string;
|
||||
};
|
||||
|
||||
declare function escapeHtml(str: string): string;
|
||||
declare function tagToString<T extends HeadTag>(tag: T): string;
|
||||
|
||||
export { CreateServerHeadOptions, Unhead, createHead, escapeHtml, extractUnheadInputFromHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString, transformHtmlTemplate, transformHtmlTemplateRaw };
|
||||
52
node_modules/unhead/dist/server.d.ts
generated
vendored
Normal file
52
node_modules/unhead/dist/server.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { R as ResolvableHead, q as CreateServerHeadOptions, U as Unhead, v as RenderSSRHeadOptions, au as HeadTag } from './shared/unhead.BUCuVRIf.js';
|
||||
export { u as SSRHeadPayload } from './shared/unhead.BUCuVRIf.js';
|
||||
import { PreparedHtmlTemplate } from './parser.js';
|
||||
import 'hookable';
|
||||
|
||||
declare function createHead<T = ResolvableHead>(options?: CreateServerHeadOptions): Unhead<T>;
|
||||
|
||||
declare function renderSSRHead(head: Unhead<any>, options?: RenderSSRHeadOptions): Promise<{
|
||||
headTags: string;
|
||||
bodyTags: string;
|
||||
bodyTagsOpen: string;
|
||||
htmlAttrs: string;
|
||||
bodyAttrs: string;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Transform an HTML template string by extracting any head tags and attributes from it, pushing them to Unhead,
|
||||
* and injecting the resulting head tags back into the HTML.
|
||||
* Uses optimized parsing and index-based HTML construction for best performance.
|
||||
*/
|
||||
declare function transformHtmlTemplate(head: Unhead<any>, html: string, options?: RenderSSRHeadOptions): Promise<string>;
|
||||
/**
|
||||
* Transform an HTML template string by injecting head tags managed by Unhead.
|
||||
*
|
||||
* The differs to `transformHtmlTemplate` in that it does not extract and push any head input from the HTML, resulting
|
||||
* in much more performant execution if you don't need that feature.
|
||||
*
|
||||
* However, this also means that any head tags or attributes already present in the HTML may be duplicated or
|
||||
* ordered incorrectly, so use with caution.
|
||||
*/
|
||||
declare function transformHtmlTemplateRaw(head: Unhead<any>, html: string, options?: RenderSSRHeadOptions): Promise<string>;
|
||||
|
||||
/**
|
||||
* @deprecated use `parseHtmlForUnheadExtraction` from `unhead/parser` instead
|
||||
* @param html
|
||||
*/
|
||||
declare function extractUnheadInputFromHtml(html: string): PreparedHtmlTemplate;
|
||||
|
||||
declare function propsToString(props: Record<string, any>): string;
|
||||
|
||||
declare function ssrRenderTags<T extends HeadTag>(tags: T[], options?: RenderSSRHeadOptions): {
|
||||
headTags: string;
|
||||
bodyTags: string;
|
||||
bodyTagsOpen: string;
|
||||
htmlAttrs: string;
|
||||
bodyAttrs: string;
|
||||
};
|
||||
|
||||
declare function escapeHtml(str: string): string;
|
||||
declare function tagToString<T extends HeadTag>(tag: T): string;
|
||||
|
||||
export { CreateServerHeadOptions, Unhead, createHead, escapeHtml, extractUnheadInputFromHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString, transformHtmlTemplate, transformHtmlTemplateRaw };
|
||||
180
node_modules/unhead/dist/server.mjs
generated
vendored
Normal file
180
node_modules/unhead/dist/server.mjs
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
import { a as createUnhead } from './shared/unhead.BFfcxOoW.mjs';
|
||||
import { T as TagsWithInnerContent, S as SelfClosingTags } from './shared/unhead.yem5I2v_.mjs';
|
||||
import { parseHtmlForUnheadExtraction, applyHeadToHtml, parseHtmlForIndexes } from './parser.mjs';
|
||||
import 'hookable';
|
||||
import './shared/unhead.eK9_7LaY.mjs';
|
||||
import './shared/unhead.CbpEuj3y.mjs';
|
||||
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function createHead(options = {}) {
|
||||
const unhead = createUnhead({
|
||||
...options,
|
||||
// @ts-expect-error untyped
|
||||
document: false,
|
||||
propResolvers: [
|
||||
...options.propResolvers || [],
|
||||
(k, v) => {
|
||||
if (k && k.startsWith("on") && typeof v === "function") {
|
||||
return `this.dataset.${k}fired = true`;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
],
|
||||
init: [
|
||||
options.disableDefaults ? void 0 : {
|
||||
htmlAttrs: {
|
||||
lang: "en"
|
||||
},
|
||||
meta: [
|
||||
{
|
||||
charset: "utf-8"
|
||||
},
|
||||
{
|
||||
name: "viewport",
|
||||
content: "width=device-width, initial-scale=1"
|
||||
}
|
||||
]
|
||||
},
|
||||
...options.init || []
|
||||
]
|
||||
});
|
||||
unhead._ssrPayload = {};
|
||||
unhead.use({
|
||||
key: "server",
|
||||
hooks: {
|
||||
"tags:resolve": function(ctx) {
|
||||
const title = ctx.tagMap.get("title");
|
||||
const titleTemplate = ctx.tagMap.get("titleTemplate");
|
||||
let payload = {
|
||||
title: title?.mode === "server" ? unhead._title : void 0,
|
||||
titleTemplate: titleTemplate?.mode === "server" ? unhead._titleTemplate : void 0
|
||||
};
|
||||
if (Object.keys(unhead._ssrPayload || {}).length > 0) {
|
||||
payload = {
|
||||
...unhead._ssrPayload,
|
||||
...payload
|
||||
};
|
||||
}
|
||||
if (Object.values(payload).some(Boolean)) {
|
||||
ctx.tags.push({
|
||||
tag: "script",
|
||||
innerHTML: JSON.stringify(payload),
|
||||
props: { id: "unhead:payload", type: "application/json" }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return unhead;
|
||||
}
|
||||
|
||||
function extractUnheadInputFromHtml(html) {
|
||||
return parseHtmlForUnheadExtraction(html);
|
||||
}
|
||||
|
||||
function encodeAttribute(value) {
|
||||
return String(value).replace(/"/g, """);
|
||||
}
|
||||
function propsToString(props) {
|
||||
let attrs = "";
|
||||
for (const key in props) {
|
||||
if (!Object.hasOwn(props, key))
|
||||
continue;
|
||||
let value = props[key];
|
||||
if ((key === "class" || key === "style") && typeof value !== "string") {
|
||||
value = key === "class" ? Array.from(value).join(" ") : Array.from(value).map(([k, v]) => `${k}:${v}`).join(";");
|
||||
}
|
||||
if (value !== false && value !== null) {
|
||||
attrs += value === true ? ` ${key}` : ` ${key}="${encodeAttribute(value)}"`;
|
||||
}
|
||||
}
|
||||
return attrs;
|
||||
}
|
||||
|
||||
function escapeHtml(str) {
|
||||
return str.replace(/[&<>"'/]/g, (char) => {
|
||||
switch (char) {
|
||||
case "&":
|
||||
return "&";
|
||||
case "<":
|
||||
return "<";
|
||||
case ">":
|
||||
return ">";
|
||||
case '"':
|
||||
return """;
|
||||
case "'":
|
||||
return "'";
|
||||
case "/":
|
||||
return "/";
|
||||
default:
|
||||
return char;
|
||||
}
|
||||
});
|
||||
}
|
||||
function tagToString(tag) {
|
||||
const attrs = propsToString(tag.props);
|
||||
const openTag = `<${tag.tag}${attrs}>`;
|
||||
if (!TagsWithInnerContent.has(tag.tag))
|
||||
return SelfClosingTags.has(tag.tag) ? openTag : `${openTag}</${tag.tag}>`;
|
||||
let content = String(tag.textContent || tag.innerHTML || "");
|
||||
content = tag.tag === "title" ? escapeHtml(content) : content.replace(new RegExp(`</${tag.tag}`, "gi"), `<\\/${tag.tag}`);
|
||||
return SelfClosingTags.has(tag.tag) ? openTag : `${openTag}${content}</${tag.tag}>`;
|
||||
}
|
||||
|
||||
function ssrRenderTags(tags, options) {
|
||||
const schema = { htmlAttrs: {}, bodyAttrs: {}, tags: { head: "", bodyClose: "", bodyOpen: "" } };
|
||||
const lineBreaks = !options?.omitLineBreaks ? "\n" : "";
|
||||
for (const tag of tags) {
|
||||
if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
|
||||
Object.assign(schema[tag.tag], tag.props);
|
||||
continue;
|
||||
}
|
||||
const s = tagToString(tag);
|
||||
const tagPosition = tag.tagPosition || "head";
|
||||
schema.tags[tagPosition] += schema.tags[tagPosition] ? `${lineBreaks}${s}` : s;
|
||||
}
|
||||
return {
|
||||
headTags: schema.tags.head,
|
||||
bodyTags: schema.tags.bodyClose,
|
||||
bodyTagsOpen: schema.tags.bodyOpen,
|
||||
htmlAttrs: propsToString(schema.htmlAttrs),
|
||||
bodyAttrs: propsToString(schema.bodyAttrs)
|
||||
};
|
||||
}
|
||||
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
async function renderSSRHead(head, options) {
|
||||
const beforeRenderCtx = { shouldRender: true };
|
||||
await head.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
|
||||
if (!beforeRenderCtx.shouldRender) {
|
||||
return {
|
||||
headTags: "",
|
||||
bodyTags: "",
|
||||
bodyTagsOpen: "",
|
||||
htmlAttrs: "",
|
||||
bodyAttrs: ""
|
||||
};
|
||||
}
|
||||
const ctx = { tags: options?.resolvedTags || await head.resolveTags() };
|
||||
await head.hooks.callHook("ssr:render", ctx);
|
||||
const html = ssrRenderTags(ctx.tags, options);
|
||||
const renderCtx = { tags: ctx.tags, html };
|
||||
await head.hooks.callHook("ssr:rendered", renderCtx);
|
||||
return renderCtx.html;
|
||||
}
|
||||
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
async function transformHtmlTemplate(head, html, options) {
|
||||
const template = parseHtmlForUnheadExtraction(html);
|
||||
head.push(template.input, { _index: 0 });
|
||||
const headHtml = await renderSSRHead(head, options);
|
||||
return applyHeadToHtml(template, headHtml);
|
||||
}
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
async function transformHtmlTemplateRaw(head, html, options) {
|
||||
const headHtml = await renderSSRHead(head, options);
|
||||
const template = parseHtmlForIndexes(html);
|
||||
return applyHeadToHtml(template, headHtml);
|
||||
}
|
||||
|
||||
export { createHead, escapeHtml, extractUnheadInputFromHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString, transformHtmlTemplate, transformHtmlTemplateRaw };
|
||||
266
node_modules/unhead/dist/shared/unhead.B578PsDV.mjs
generated
vendored
Normal file
266
node_modules/unhead/dist/shared/unhead.B578PsDV.mjs
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
import { b as ScriptNetworkEvents } from './unhead.yem5I2v_.mjs';
|
||||
|
||||
function createNoopedRecordingProxy(instance = {}) {
|
||||
const stack = [];
|
||||
let stackIdx = -1;
|
||||
const handler = (reuseStack = false) => ({
|
||||
get(_, prop, receiver) {
|
||||
if (!reuseStack) {
|
||||
const v = Reflect.get(_, prop, receiver);
|
||||
if (typeof v !== "undefined") {
|
||||
return v;
|
||||
}
|
||||
stackIdx++;
|
||||
stack[stackIdx] = [];
|
||||
}
|
||||
stack[stackIdx].push({ type: "get", key: prop });
|
||||
return new Proxy(() => {
|
||||
}, handler(true));
|
||||
},
|
||||
apply(_, __, args) {
|
||||
stack[stackIdx].push({ type: "apply", key: "", args });
|
||||
return void 0;
|
||||
}
|
||||
});
|
||||
return {
|
||||
proxy: new Proxy(instance || {}, handler()),
|
||||
stack
|
||||
};
|
||||
}
|
||||
function createForwardingProxy(target) {
|
||||
const handler = {
|
||||
get(_, prop, receiver) {
|
||||
const v = Reflect.get(_, prop, receiver);
|
||||
if (typeof v === "object") {
|
||||
return new Proxy(v, handler);
|
||||
}
|
||||
return v;
|
||||
},
|
||||
apply(_, __, args) {
|
||||
Reflect.apply(_, __, args);
|
||||
return void 0;
|
||||
}
|
||||
};
|
||||
return new Proxy(target, handler);
|
||||
}
|
||||
function replayProxyRecordings(target, stack) {
|
||||
stack.forEach((recordings) => {
|
||||
let context = target;
|
||||
let prevContext = target;
|
||||
recordings.forEach(({ type, key, args }) => {
|
||||
if (type === "get") {
|
||||
prevContext = context;
|
||||
context = context[key];
|
||||
} else if (type === "apply") {
|
||||
context = context.call(prevContext, ...args);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function resolveScriptKey(input) {
|
||||
return input.key || input.src || (typeof input.innerHTML === "string" ? input.innerHTML : "");
|
||||
}
|
||||
const PreconnectServerModes = ["preconnect", "dns-prefetch"];
|
||||
function useScript(head, _input, _options) {
|
||||
const input = typeof _input === "string" ? { src: _input } : _input;
|
||||
const options = _options || {};
|
||||
const id = resolveScriptKey(input);
|
||||
const prevScript = head._scripts?.[id];
|
||||
if (prevScript) {
|
||||
prevScript.setupTriggerHandler(options.trigger);
|
||||
return prevScript;
|
||||
}
|
||||
options.beforeInit?.();
|
||||
const syncStatus = (s) => {
|
||||
script.status = s;
|
||||
head.hooks.callHook(`script:updated`, hookCtx);
|
||||
};
|
||||
ScriptNetworkEvents.forEach((fn) => {
|
||||
const k = fn;
|
||||
const _fn = typeof input[k] === "function" ? input[k].bind(options.eventContext) : null;
|
||||
input[k] = (e) => {
|
||||
syncStatus(fn === "onload" ? "loaded" : fn === "onerror" ? "error" : "loading");
|
||||
_fn?.(e);
|
||||
};
|
||||
});
|
||||
const _cbs = { loaded: [], error: [] };
|
||||
const _uniqueCbs = /* @__PURE__ */ new Set();
|
||||
const _registerCb = (key, cb, options2) => {
|
||||
if (head.ssr) {
|
||||
return;
|
||||
}
|
||||
if (options2?.key) {
|
||||
const key2 = `${options2?.key}:${options2.key}`;
|
||||
if (_uniqueCbs.has(key2)) {
|
||||
return;
|
||||
}
|
||||
_uniqueCbs.add(key2);
|
||||
}
|
||||
if (_cbs[key]) {
|
||||
const i = _cbs[key].push(cb);
|
||||
return () => _cbs[key]?.splice(i - 1, 1);
|
||||
}
|
||||
cb(script.instance);
|
||||
return () => {
|
||||
};
|
||||
};
|
||||
const loadPromise = new Promise((resolve) => {
|
||||
if (head.ssr)
|
||||
return;
|
||||
const emit = (api) => requestAnimationFrame(() => resolve(api));
|
||||
const _ = head.hooks.hook("script:updated", ({ script: script2 }) => {
|
||||
const status = script2.status;
|
||||
if (script2.id === id && (status === "loaded" || status === "error")) {
|
||||
if (status === "loaded") {
|
||||
if (typeof options.use === "function") {
|
||||
const api = options.use();
|
||||
if (api) {
|
||||
emit(api);
|
||||
}
|
||||
} else {
|
||||
emit({});
|
||||
}
|
||||
} else if (status === "error") {
|
||||
resolve(false);
|
||||
}
|
||||
_();
|
||||
}
|
||||
});
|
||||
});
|
||||
const script = {
|
||||
_loadPromise: loadPromise,
|
||||
instance: !head.ssr && options?.use?.() || null,
|
||||
proxy: null,
|
||||
id,
|
||||
status: "awaitingLoad",
|
||||
remove() {
|
||||
script._triggerAbortController?.abort();
|
||||
script._triggerPromises = [];
|
||||
script._warmupEl?.dispose();
|
||||
if (script.entry) {
|
||||
script.entry.dispose();
|
||||
script.entry = void 0;
|
||||
syncStatus("removed");
|
||||
delete head._scripts?.[id];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
warmup(rel) {
|
||||
const { src } = input;
|
||||
const isCrossOrigin = !src.startsWith("/") || src.startsWith("//");
|
||||
const isPreconnect = rel && PreconnectServerModes.includes(rel);
|
||||
let href = src;
|
||||
if (!rel || isPreconnect && !isCrossOrigin) {
|
||||
return;
|
||||
}
|
||||
if (isPreconnect) {
|
||||
const $url = new URL(src);
|
||||
href = `${$url.protocol}//${$url.host}`;
|
||||
}
|
||||
const link = {
|
||||
href,
|
||||
rel,
|
||||
crossorigin: typeof input.crossorigin !== "undefined" ? input.crossorigin : isCrossOrigin ? "anonymous" : void 0,
|
||||
referrerpolicy: typeof input.referrerpolicy !== "undefined" ? input.referrerpolicy : isCrossOrigin ? "no-referrer" : void 0,
|
||||
fetchpriority: typeof input.fetchpriority !== "undefined" ? input.fetchpriority : "low",
|
||||
integrity: input.integrity,
|
||||
as: rel === "preload" ? "script" : void 0
|
||||
};
|
||||
script._warmupEl = head.push({ link: [link] }, { head, tagPriority: "high" });
|
||||
return script._warmupEl;
|
||||
},
|
||||
load(cb) {
|
||||
script._triggerAbortController?.abort();
|
||||
script._triggerPromises = [];
|
||||
if (!script.entry) {
|
||||
syncStatus("loading");
|
||||
const defaults = {
|
||||
defer: true,
|
||||
fetchpriority: "low"
|
||||
};
|
||||
if (input.src && (input.src.startsWith("http") || input.src.startsWith("//"))) {
|
||||
defaults.crossorigin = "anonymous";
|
||||
defaults.referrerpolicy = "no-referrer";
|
||||
}
|
||||
script.entry = head.push({
|
||||
script: [{ ...defaults, ...input }]
|
||||
}, options);
|
||||
}
|
||||
if (cb)
|
||||
_registerCb("loaded", cb);
|
||||
return loadPromise;
|
||||
},
|
||||
onLoaded(cb, options2) {
|
||||
return _registerCb("loaded", cb, options2);
|
||||
},
|
||||
onError(cb, options2) {
|
||||
return _registerCb("error", cb, options2);
|
||||
},
|
||||
setupTriggerHandler(trigger) {
|
||||
if (script.status !== "awaitingLoad") {
|
||||
return;
|
||||
}
|
||||
if ((typeof trigger === "undefined" || trigger === "client") && !head.ssr || trigger === "server") {
|
||||
script.load();
|
||||
} else if (trigger instanceof Promise) {
|
||||
if (head.ssr) {
|
||||
return;
|
||||
}
|
||||
if (!script._triggerAbortController) {
|
||||
script._triggerAbortController = new AbortController();
|
||||
script._triggerAbortPromise = new Promise((resolve) => {
|
||||
script._triggerAbortController.signal.addEventListener("abort", () => {
|
||||
script._triggerAbortController = null;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
script._triggerPromises = script._triggerPromises || [];
|
||||
const idx = script._triggerPromises.push(Promise.race([
|
||||
trigger.then((v) => typeof v === "undefined" || v ? script.load : void 0),
|
||||
script._triggerAbortPromise
|
||||
]).catch(() => {
|
||||
}).then((res) => {
|
||||
res?.();
|
||||
}).finally(() => {
|
||||
script._triggerPromises?.splice(idx, 1);
|
||||
}));
|
||||
} else if (typeof trigger === "function") {
|
||||
trigger(script.load);
|
||||
}
|
||||
},
|
||||
_cbs
|
||||
};
|
||||
loadPromise.then((api) => {
|
||||
if (api !== false) {
|
||||
script.instance = api;
|
||||
_cbs.loaded?.forEach((cb) => cb(api));
|
||||
_cbs.loaded = null;
|
||||
} else {
|
||||
_cbs.error?.forEach((cb) => cb());
|
||||
_cbs.error = null;
|
||||
}
|
||||
});
|
||||
const hookCtx = { script };
|
||||
script.setupTriggerHandler(options.trigger);
|
||||
if (options.use) {
|
||||
const { proxy, stack } = createNoopedRecordingProxy(head.ssr ? {} : options.use() || {});
|
||||
script.proxy = proxy;
|
||||
script.onLoaded((instance) => {
|
||||
replayProxyRecordings(instance, stack);
|
||||
script.proxy = createForwardingProxy(instance);
|
||||
});
|
||||
}
|
||||
if (!options.warmupStrategy && (typeof options.trigger === "undefined" || options.trigger === "client")) {
|
||||
options.warmupStrategy = "preload";
|
||||
}
|
||||
if (options.warmupStrategy) {
|
||||
script.warmup(options.warmupStrategy);
|
||||
}
|
||||
head._scripts = Object.assign(head._scripts || {}, { [id]: script });
|
||||
return script;
|
||||
}
|
||||
|
||||
export { resolveScriptKey as r, useScript as u };
|
||||
180
node_modules/unhead/dist/shared/unhead.BFfcxOoW.mjs
generated
vendored
Normal file
180
node_modules/unhead/dist/shared/unhead.BFfcxOoW.mjs
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
import { createHooks } from 'hookable';
|
||||
import { n as normalizeEntryToTags, d as dedupeKey, i as isMetaArrayDupeKey } from './unhead.eK9_7LaY.mjs';
|
||||
import { t as tagWeight, s as sortTags } from './unhead.CbpEuj3y.mjs';
|
||||
import { c as UsesMergeStrategy, V as ValidHeadTags } from './unhead.yem5I2v_.mjs';
|
||||
|
||||
function registerPlugin(head, p) {
|
||||
const plugin = typeof p === "function" ? p(head) : p;
|
||||
const key = plugin.key || String(head.plugins.size + 1);
|
||||
const exists = head.plugins.get(key);
|
||||
if (!exists) {
|
||||
head.plugins.set(key, plugin);
|
||||
head.hooks.addHooks(plugin.hooks || {});
|
||||
}
|
||||
}
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function createHeadCore(resolvedOptions = {}) {
|
||||
return /* @__PURE__ */ createUnhead(resolvedOptions);
|
||||
}
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function createUnhead(resolvedOptions = {}) {
|
||||
const hooks = createHooks();
|
||||
hooks.addHooks(resolvedOptions.hooks || {});
|
||||
const ssr = !resolvedOptions.document;
|
||||
const entries = /* @__PURE__ */ new Map();
|
||||
const plugins = /* @__PURE__ */ new Map();
|
||||
const normalizeQueue = /* @__PURE__ */ new Set();
|
||||
const head = {
|
||||
_entryCount: 1,
|
||||
// 0 is reserved for internal use
|
||||
plugins,
|
||||
dirty: false,
|
||||
resolvedOptions,
|
||||
hooks,
|
||||
ssr,
|
||||
entries,
|
||||
headEntries() {
|
||||
return [...entries.values()];
|
||||
},
|
||||
use: (p) => registerPlugin(head, p),
|
||||
push(input, _options) {
|
||||
const options = { ..._options || {} };
|
||||
delete options.head;
|
||||
const _i = options._index ?? head._entryCount++;
|
||||
const inst = { _i, input, options };
|
||||
const _ = {
|
||||
_poll(rm = false) {
|
||||
head.dirty = true;
|
||||
!rm && normalizeQueue.add(_i);
|
||||
hooks.callHook("entries:updated", head);
|
||||
},
|
||||
dispose() {
|
||||
if (entries.delete(_i)) {
|
||||
head.invalidate();
|
||||
}
|
||||
},
|
||||
// a patch is the same as creating a new entry, just a nice DX
|
||||
patch(input2) {
|
||||
if (!options.mode || options.mode === "server" && ssr || options.mode === "client" && !ssr) {
|
||||
inst.input = input2;
|
||||
entries.set(_i, inst);
|
||||
_._poll();
|
||||
}
|
||||
}
|
||||
};
|
||||
_.patch(input);
|
||||
return _;
|
||||
},
|
||||
async resolveTags() {
|
||||
const ctx = {
|
||||
tagMap: /* @__PURE__ */ new Map(),
|
||||
tags: [],
|
||||
entries: [...head.entries.values()]
|
||||
};
|
||||
await hooks.callHook("entries:resolve", ctx);
|
||||
while (normalizeQueue.size) {
|
||||
const i = normalizeQueue.values().next().value;
|
||||
normalizeQueue.delete(i);
|
||||
const e = entries.get(i);
|
||||
if (e) {
|
||||
const normalizeCtx = {
|
||||
tags: normalizeEntryToTags(e.input, resolvedOptions.propResolvers || []).map((t) => Object.assign(t, e.options)),
|
||||
entry: e
|
||||
};
|
||||
await hooks.callHook("entries:normalize", normalizeCtx);
|
||||
e._tags = normalizeCtx.tags.map((t, i2) => {
|
||||
t._w = tagWeight(head, t);
|
||||
t._p = (e._i << 10) + i2;
|
||||
t._d = dedupeKey(t);
|
||||
return t;
|
||||
});
|
||||
}
|
||||
}
|
||||
let hasFlatMeta = false;
|
||||
ctx.entries.flatMap((e) => (e._tags || []).map((t) => ({ ...t, props: { ...t.props } }))).sort(sortTags).reduce((acc, next) => {
|
||||
const k = String(next._d || next._p);
|
||||
if (!acc.has(k))
|
||||
return acc.set(k, next);
|
||||
const prev = acc.get(k);
|
||||
const strategy = next?.tagDuplicateStrategy || (UsesMergeStrategy.has(next.tag) ? "merge" : null) || (next.key && next.key === prev.key ? "merge" : null);
|
||||
if (strategy === "merge") {
|
||||
const newProps = { ...prev.props };
|
||||
Object.entries(next.props).forEach(([p, v]) => (
|
||||
// @ts-expect-error untyped
|
||||
newProps[p] = p === "style" ? new Map([...prev.props.style || /* @__PURE__ */ new Map(), ...v]) : p === "class" ? /* @__PURE__ */ new Set([...prev.props.class || /* @__PURE__ */ new Set(), ...v]) : v
|
||||
));
|
||||
acc.set(k, { ...next, props: newProps });
|
||||
} else if (next._p >> 10 === prev._p >> 10 && next.tag === "meta" && isMetaArrayDupeKey(k)) {
|
||||
acc.set(k, Object.assign([...Array.isArray(prev) ? prev : [prev], next], next));
|
||||
hasFlatMeta = true;
|
||||
} else if (next._w === prev._w ? next._p > prev._p : next?._w < prev?._w) {
|
||||
acc.set(k, next);
|
||||
}
|
||||
return acc;
|
||||
}, ctx.tagMap);
|
||||
const title = ctx.tagMap.get("title");
|
||||
const titleTemplate = ctx.tagMap.get("titleTemplate");
|
||||
head._title = title?.textContent;
|
||||
if (titleTemplate) {
|
||||
const titleTemplateFn = titleTemplate?.textContent;
|
||||
head._titleTemplate = titleTemplateFn;
|
||||
if (titleTemplateFn) {
|
||||
let newTitle = typeof titleTemplateFn === "function" ? titleTemplateFn(title?.textContent) : titleTemplateFn;
|
||||
if (typeof newTitle === "string" && !head.plugins.has("template-params")) {
|
||||
newTitle = newTitle.replace("%s", title?.textContent || "");
|
||||
}
|
||||
if (title) {
|
||||
newTitle === null ? ctx.tagMap.delete("title") : ctx.tagMap.set("title", { ...title, textContent: newTitle });
|
||||
} else {
|
||||
titleTemplate.tag = "title";
|
||||
titleTemplate.textContent = newTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.tags = Array.from(ctx.tagMap.values());
|
||||
if (hasFlatMeta) {
|
||||
ctx.tags = ctx.tags.flat().sort(sortTags);
|
||||
}
|
||||
await hooks.callHook("tags:beforeResolve", ctx);
|
||||
await hooks.callHook("tags:resolve", ctx);
|
||||
await hooks.callHook("tags:afterResolve", ctx);
|
||||
const finalTags = [];
|
||||
for (const t of ctx.tags) {
|
||||
const { innerHTML, tag, props } = t;
|
||||
if (!ValidHeadTags.has(tag)) {
|
||||
continue;
|
||||
}
|
||||
if (Object.keys(props).length === 0 && !t.innerHTML && !t.textContent) {
|
||||
continue;
|
||||
}
|
||||
if (tag === "meta" && !props.content && !props["http-equiv"] && !props.charset) {
|
||||
continue;
|
||||
}
|
||||
if (tag === "script" && innerHTML) {
|
||||
if (String(props.type).endsWith("json")) {
|
||||
const v = typeof innerHTML === "string" ? innerHTML : JSON.stringify(innerHTML);
|
||||
t.innerHTML = v.replace(/</g, "\\u003C");
|
||||
} else if (typeof innerHTML === "string") {
|
||||
t.innerHTML = innerHTML.replace(new RegExp(`</${tag}`, "g"), `<\\/${tag}`);
|
||||
}
|
||||
t._d = dedupeKey(t);
|
||||
}
|
||||
finalTags.push(t);
|
||||
}
|
||||
return finalTags;
|
||||
},
|
||||
invalidate() {
|
||||
for (const entry of entries.values()) {
|
||||
normalizeQueue.add(entry._i);
|
||||
}
|
||||
head.dirty = true;
|
||||
hooks.callHook("entries:updated", head);
|
||||
}
|
||||
};
|
||||
(resolvedOptions?.plugins || []).forEach((p) => registerPlugin(head, p));
|
||||
head.hooks.callHook("init", head);
|
||||
resolvedOptions.init?.forEach((e) => e && head.push(e));
|
||||
return head;
|
||||
}
|
||||
|
||||
export { createUnhead as a, createHeadCore as c };
|
||||
44
node_modules/unhead/dist/shared/unhead.BPM0-cfG.mjs
generated
vendored
Normal file
44
node_modules/unhead/dist/shared/unhead.BPM0-cfG.mjs
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { S as SafeInputPlugin, F as FlatMetaPlugin } from './unhead.CApf5sj3.mjs';
|
||||
|
||||
function useHead(unhead, input, options = {}) {
|
||||
return unhead.push(input || {}, options);
|
||||
}
|
||||
function useHeadSafe(unhead, input = {}, options = {}) {
|
||||
unhead.use(SafeInputPlugin);
|
||||
return useHead(unhead, input, Object.assign(options, { _safe: true }));
|
||||
}
|
||||
function useSeoMeta(unhead, input = {}, options) {
|
||||
unhead.use(FlatMetaPlugin);
|
||||
function normalize(input2) {
|
||||
if (input2._flatMeta) {
|
||||
return input2;
|
||||
}
|
||||
const { title, titleTemplate, ...meta } = input2 || {};
|
||||
return {
|
||||
title,
|
||||
titleTemplate,
|
||||
_flatMeta: meta
|
||||
};
|
||||
}
|
||||
const entry = unhead.push(normalize(input), options);
|
||||
const corePatch = entry.patch;
|
||||
if (!entry.__patched) {
|
||||
entry.patch = (input2) => corePatch(normalize(input2));
|
||||
entry.__patched = true;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
function useServerHead(unhead, input = {}, options = {}) {
|
||||
options.mode = "server";
|
||||
return unhead.push(input, options);
|
||||
}
|
||||
function useServerHeadSafe(unhead, input = {}, options = {}) {
|
||||
options.mode = "server";
|
||||
return useHeadSafe(unhead, input, { ...options, mode: "server" });
|
||||
}
|
||||
function useServerSeoMeta(unhead, input = {}, options) {
|
||||
options.mode = "server";
|
||||
return useSeoMeta(unhead, input, { ...options, mode: "server" });
|
||||
}
|
||||
|
||||
export { useHeadSafe as a, useSeoMeta as b, useServerHead as c, useServerHeadSafe as d, useServerSeoMeta as e, useHead as u };
|
||||
2325
node_modules/unhead/dist/shared/unhead.BUCuVRIf.d.mts
generated
vendored
Normal file
2325
node_modules/unhead/dist/shared/unhead.BUCuVRIf.d.mts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2325
node_modules/unhead/dist/shared/unhead.BUCuVRIf.d.ts
generated
vendored
Normal file
2325
node_modules/unhead/dist/shared/unhead.BUCuVRIf.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
43
node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs
generated
vendored
Normal file
43
node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
const SepSub = "%separator";
|
||||
function sub(p, token, isJson = false) {
|
||||
let val;
|
||||
if (token === "s" || token === "pageTitle") {
|
||||
val = p.pageTitle;
|
||||
} else if (token.includes(".")) {
|
||||
const dotIndex = token.indexOf(".");
|
||||
val = p[token.substring(0, dotIndex)]?.[token.substring(dotIndex + 1)];
|
||||
} else {
|
||||
val = p[token];
|
||||
}
|
||||
if (val !== void 0) {
|
||||
return isJson ? (val || "").replace(/\\/g, "\\\\").replace(/</g, "\\u003C").replace(/"/g, '\\"') : val || "";
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
function processTemplateParams(s, p, sep, isJson = false) {
|
||||
if (typeof s !== "string" || !s.includes("%"))
|
||||
return s;
|
||||
let decoded = s;
|
||||
try {
|
||||
decoded = decodeURI(s);
|
||||
} catch {
|
||||
}
|
||||
const tokens = decoded.match(/%\w+(?:\.\w+)?/g);
|
||||
if (!tokens) {
|
||||
return s;
|
||||
}
|
||||
const hasSepSub = s.includes(SepSub);
|
||||
s = s.replace(/%\w+(?:\.\w+)?/g, (token) => {
|
||||
if (token === SepSub || !tokens.includes(token)) {
|
||||
return token;
|
||||
}
|
||||
const re = sub(p, token.slice(1), isJson);
|
||||
return re !== void 0 ? re : token;
|
||||
}).trim();
|
||||
if (hasSepSub) {
|
||||
s = s.split(SepSub).map((part) => part.trim()).filter((part) => part !== "").join(sep ? ` ${sep} ` : " ");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
export { processTemplateParams as p };
|
||||
14
node_modules/unhead/dist/shared/unhead.Btq-XLkr.d.ts
generated
vendored
Normal file
14
node_modules/unhead/dist/shared/unhead.Btq-XLkr.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { U as Unhead, a as UseScriptInput, b as UseScriptOptions, c as UseScriptReturn, d as UseScriptResolvedInput } from './unhead.BUCuVRIf.js';
|
||||
|
||||
/**
|
||||
* @deprecated compute key manually
|
||||
*/
|
||||
declare function resolveScriptKey(input: UseScriptResolvedInput): string;
|
||||
/**
|
||||
* Load third-party scripts with SSR support and a proxied API.
|
||||
*
|
||||
* @see https://unhead.unjs.io/usage/composables/use-script
|
||||
*/
|
||||
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(head: Unhead<any>, _input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptReturn<T>;
|
||||
|
||||
export { resolveScriptKey as r, useScript as u };
|
||||
148
node_modules/unhead/dist/shared/unhead.CApf5sj3.mjs
generated
vendored
Normal file
148
node_modules/unhead/dist/shared/unhead.CApf5sj3.mjs
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
import { u as unpackMeta } from './unhead.DQc16pHI.mjs';
|
||||
|
||||
function defineHeadPlugin(plugin) {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
const FlatMetaPlugin = /* @__PURE__ */ defineHeadPlugin({
|
||||
key: "flatMeta",
|
||||
hooks: {
|
||||
"entries:normalize": (ctx) => {
|
||||
const tagsToAdd = [];
|
||||
ctx.tags = ctx.tags.map((t) => {
|
||||
if (t.tag !== "_flatMeta") {
|
||||
return t;
|
||||
}
|
||||
tagsToAdd.push(unpackMeta(t.props).map((p) => ({
|
||||
...t,
|
||||
tag: "meta",
|
||||
props: p
|
||||
})));
|
||||
return false;
|
||||
}).filter(Boolean).concat(...tagsToAdd);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const WhitelistAttributes = {
|
||||
htmlAttrs: /* @__PURE__ */ new Set(["class", "style", "lang", "dir"]),
|
||||
bodyAttrs: /* @__PURE__ */ new Set(["class", "style"]),
|
||||
meta: /* @__PURE__ */ new Set(["name", "property", "charset", "content", "media"]),
|
||||
noscript: /* @__PURE__ */ new Set(["textContent"]),
|
||||
style: /* @__PURE__ */ new Set(["media", "textContent", "nonce", "title", "blocking"]),
|
||||
script: /* @__PURE__ */ new Set(["type", "textContent", "nonce", "blocking"]),
|
||||
link: /* @__PURE__ */ new Set(["color", "crossorigin", "fetchpriority", "href", "hreflang", "imagesrcset", "imagesizes", "integrity", "media", "referrerpolicy", "rel", "sizes", "type"])
|
||||
};
|
||||
function acceptDataAttrs(value) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(value || {}).filter(([key]) => key === "id" || key.startsWith("data-"))
|
||||
);
|
||||
}
|
||||
function makeTagSafe(tag) {
|
||||
let next = {};
|
||||
const { tag: type, props: prev } = tag;
|
||||
switch (type) {
|
||||
// always safe
|
||||
case "title":
|
||||
case "titleTemplate":
|
||||
case "templateParams":
|
||||
next = prev;
|
||||
break;
|
||||
case "htmlAttrs":
|
||||
case "bodyAttrs":
|
||||
WhitelistAttributes[type].forEach((attr) => {
|
||||
if (prev[attr]) {
|
||||
next[attr] = prev[attr];
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "style":
|
||||
next = acceptDataAttrs(prev);
|
||||
WhitelistAttributes.style.forEach((key) => {
|
||||
if (prev[key]) {
|
||||
next[key] = prev[key];
|
||||
}
|
||||
});
|
||||
break;
|
||||
// meta is safe, except for http-equiv
|
||||
case "meta":
|
||||
WhitelistAttributes.meta.forEach((key) => {
|
||||
if (prev[key]) {
|
||||
next[key] = prev[key];
|
||||
}
|
||||
});
|
||||
break;
|
||||
// link tags we don't allow stylesheets, scripts, preloading, prerendering, prefetching, etc
|
||||
case "link":
|
||||
WhitelistAttributes.link.forEach((key) => {
|
||||
const val = prev[key];
|
||||
if (!val) {
|
||||
return;
|
||||
}
|
||||
if (key === "rel" && (val === "canonical" || val === "modulepreload" || val === "prerender" || val === "preload" || val === "prefetch")) {
|
||||
return;
|
||||
}
|
||||
if (key === "href") {
|
||||
if (val.includes("javascript:") || val.includes("data:")) {
|
||||
return;
|
||||
}
|
||||
next[key] = val;
|
||||
} else if (val) {
|
||||
next[key] = val;
|
||||
}
|
||||
});
|
||||
if (!next.href && !next.imagesrcset || !next.rel) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "noscript":
|
||||
WhitelistAttributes.noscript.forEach((key) => {
|
||||
if (prev[key]) {
|
||||
next[key] = prev[key];
|
||||
}
|
||||
});
|
||||
break;
|
||||
// we only allow JSON in scripts
|
||||
case "script":
|
||||
if (!tag.textContent || !prev.type?.endsWith("json")) {
|
||||
return false;
|
||||
}
|
||||
WhitelistAttributes.script.forEach((s) => {
|
||||
if (prev[s] === "textContent") {
|
||||
try {
|
||||
const jsonVal = typeof prev[s] === "string" ? JSON.parse(prev[s]) : prev[s];
|
||||
next[s] = JSON.stringify(jsonVal, null, 0);
|
||||
} catch {
|
||||
}
|
||||
} else if (prev[s]) {
|
||||
next[s] = prev[s];
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
if (!Object.keys(next).length && !tag.tag.endsWith("Attrs")) {
|
||||
return false;
|
||||
}
|
||||
tag.props = { ...acceptDataAttrs(prev), ...next };
|
||||
return tag;
|
||||
}
|
||||
const SafeInputPlugin = (
|
||||
/* @PURE */
|
||||
defineHeadPlugin({
|
||||
key: "safe",
|
||||
hooks: {
|
||||
"entries:normalize": (ctx) => {
|
||||
if (ctx.entry.options?._safe) {
|
||||
ctx.tags = ctx.tags.reduce((acc, tag) => {
|
||||
const safeTag = makeTagSafe(tag);
|
||||
if (safeTag)
|
||||
acc.push(safeTag);
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
export { FlatMetaPlugin as F, SafeInputPlugin as S, defineHeadPlugin as d };
|
||||
68
node_modules/unhead/dist/shared/unhead.CBPtX666.d.mts
generated
vendored
Normal file
68
node_modules/unhead/dist/shared/unhead.CBPtX666.d.mts
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import { a5 as RawInput, R as ResolvableHead, az as ResolvableValue, aA as ResolvableProperties, ag as LinkWithoutEvents, ab as DataKeys, K as SchemaAugmentations, Q as UnheadMeta, ai as ScriptWithoutEvents, O as UnheadHtmlAttributes, N as UnheadBodyAttributesWithoutEvents } from './unhead.BUCuVRIf.mjs';
|
||||
|
||||
type Base = RawInput<'base'>;
|
||||
type HtmlAttributes = RawInput<'htmlAttrs'>;
|
||||
type Noscript = RawInput<'noscript'>;
|
||||
type Style = RawInput<'style'>;
|
||||
type Meta = RawInput<'meta'>;
|
||||
type Script = RawInput<'script'>;
|
||||
type Link = RawInput<'link'>;
|
||||
type BodyAttributes = RawInput<'bodyAttrs'>;
|
||||
|
||||
type SafeBodyAttr = ResolvableProperties<Pick<UnheadBodyAttributesWithoutEvents, 'id' | 'class' | 'style'> & DataKeys & SchemaAugmentations['bodyAttrs']>;
|
||||
type SafeHtmlAttr = ResolvableProperties<Pick<UnheadHtmlAttributes, 'id' | 'class' | 'style' | 'lang' | 'dir'> & DataKeys & SchemaAugmentations['htmlAttrs']>;
|
||||
type SafeMeta = ResolvableProperties<Pick<UnheadMeta, 'id' | 'name' | 'property' | 'charset' | 'content' | 'media'> & DataKeys & SchemaAugmentations['meta']>;
|
||||
type SafeLink = ResolvableProperties<Pick<LinkWithoutEvents, 'id' | 'color' | 'crossorigin' | 'fetchpriority' | 'href' | 'hreflang' | 'imagesrcset' | 'imagesizes' | 'integrity' | 'media' | 'referrerpolicy' | 'rel' | 'sizes' | 'type'> & DataKeys & SchemaAugmentations['link']>;
|
||||
type SafeScript = ResolvableProperties<Pick<ScriptWithoutEvents, 'id' | 'type' | 'nonce' | 'blocking'> & DataKeys & SchemaAugmentations['script']>;
|
||||
type SafeNoscript = ResolvableProperties<Pick<Noscript, 'id'> & DataKeys & Omit<SchemaAugmentations['noscript'], 'innerHTML'>>;
|
||||
type SafeStyle = ResolvableProperties<Pick<Style, 'id' | 'media' | 'nonce' | 'title' | 'blocking'> & DataKeys & Omit<SchemaAugmentations['style'], 'innerHTML'>>;
|
||||
interface HeadSafe extends Pick<ResolvableHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
||||
/**
|
||||
* 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?: ResolvableValue<ResolvableValue<SafeLink[]>>;
|
||||
/**
|
||||
* 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?: ResolvableValue<ResolvableValue<SafeMeta>[]>;
|
||||
/**
|
||||
* 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?: ResolvableValue<ResolvableValue<(SafeStyle | 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?: ResolvableValue<ResolvableValue<(SafeScript | 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?: ResolvableValue<ResolvableValue<(SafeNoscript | string)>[]>;
|
||||
/**
|
||||
* Attributes for the `<html>` HTML element.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
|
||||
*/
|
||||
htmlAttrs?: ResolvableValue<SafeHtmlAttr>;
|
||||
/**
|
||||
* Attributes for the `<body>` HTML element.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
|
||||
*/
|
||||
bodyAttrs?: ResolvableValue<SafeBodyAttr>;
|
||||
}
|
||||
|
||||
export type { Base as B, HeadSafe as H, Link as L, Meta as M, Noscript as N, SafeBodyAttr as S, SafeHtmlAttr as a, SafeMeta as b, SafeLink as c, SafeScript as d, SafeNoscript as e, SafeStyle as f, HtmlAttributes as g, Style as h, Script as i, BodyAttributes as j };
|
||||
14
node_modules/unhead/dist/shared/unhead.CC7bAF1a.d.mts
generated
vendored
Normal file
14
node_modules/unhead/dist/shared/unhead.CC7bAF1a.d.mts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { U as Unhead, a as UseScriptInput, b as UseScriptOptions, c as UseScriptReturn, d as UseScriptResolvedInput } from './unhead.BUCuVRIf.mjs';
|
||||
|
||||
/**
|
||||
* @deprecated compute key manually
|
||||
*/
|
||||
declare function resolveScriptKey(input: UseScriptResolvedInput): string;
|
||||
/**
|
||||
* Load third-party scripts with SSR support and a proxied API.
|
||||
*
|
||||
* @see https://unhead.unjs.io/usage/composables/use-script
|
||||
*/
|
||||
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(head: Unhead<any>, _input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptReturn<T>;
|
||||
|
||||
export { resolveScriptKey as r, useScript as u };
|
||||
71
node_modules/unhead/dist/shared/unhead.CbpEuj3y.mjs
generated
vendored
Normal file
71
node_modules/unhead/dist/shared/unhead.CbpEuj3y.mjs
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
const sortTags = (a, b) => a._w === b._w ? a._p - b._p : a._w - b._w;
|
||||
const TAG_WEIGHTS = {
|
||||
base: -10,
|
||||
title: 10
|
||||
};
|
||||
const TAG_ALIASES = {
|
||||
critical: -8,
|
||||
high: -1,
|
||||
low: 2
|
||||
};
|
||||
const WEIGHT_MAP = {
|
||||
meta: {
|
||||
"content-security-policy": -30,
|
||||
"charset": -20,
|
||||
"viewport": -15
|
||||
},
|
||||
link: {
|
||||
"preconnect": 20,
|
||||
"stylesheet": 60,
|
||||
"preload": 70,
|
||||
"modulepreload": 70,
|
||||
"prefetch": 90,
|
||||
"dns-prefetch": 90,
|
||||
"prerender": 90
|
||||
},
|
||||
script: {
|
||||
async: 30,
|
||||
defer: 80,
|
||||
sync: 50
|
||||
},
|
||||
style: {
|
||||
imported: 40,
|
||||
sync: 60
|
||||
}
|
||||
};
|
||||
const ImportStyleRe = /@import/;
|
||||
const isTruthy = (val) => val === "" || val === true;
|
||||
function tagWeight(head, tag) {
|
||||
if (typeof tag.tagPriority === "number")
|
||||
return tag.tagPriority;
|
||||
let weight = 100;
|
||||
const offset = TAG_ALIASES[tag.tagPriority] || 0;
|
||||
const weightMap = head.resolvedOptions.disableCapoSorting ? {
|
||||
link: {},
|
||||
script: {},
|
||||
style: {}
|
||||
} : WEIGHT_MAP;
|
||||
if (tag.tag in TAG_WEIGHTS) {
|
||||
weight = TAG_WEIGHTS[tag.tag];
|
||||
} else if (tag.tag === "meta") {
|
||||
const metaType = tag.props["http-equiv"] === "content-security-policy" ? "content-security-policy" : tag.props.charset ? "charset" : tag.props.name === "viewport" ? "viewport" : null;
|
||||
if (metaType)
|
||||
weight = WEIGHT_MAP.meta[metaType];
|
||||
} else if (tag.tag === "link" && tag.props.rel) {
|
||||
weight = weightMap.link[tag.props.rel];
|
||||
} else if (tag.tag === "script") {
|
||||
const type = String(tag.props.type);
|
||||
if (isTruthy(tag.props.async)) {
|
||||
weight = weightMap.script.async;
|
||||
} else if (tag.props.src && !isTruthy(tag.props.defer) && !isTruthy(tag.props.async) && type !== "module" && !type.endsWith("json") || tag.innerHTML && !type.endsWith("json")) {
|
||||
weight = weightMap.script.sync;
|
||||
} else if (isTruthy(tag.props.defer) && tag.props.src && !isTruthy(tag.props.async) || type === "module") {
|
||||
weight = weightMap.script.defer;
|
||||
}
|
||||
} else if (tag.tag === "style") {
|
||||
weight = tag.innerHTML && ImportStyleRe.test(tag.innerHTML) ? weightMap.style.imported : weightMap.style.sync;
|
||||
}
|
||||
return (weight || 100) + offset;
|
||||
}
|
||||
|
||||
export { sortTags as s, tagWeight as t };
|
||||
68
node_modules/unhead/dist/shared/unhead.CsiVfkwJ.d.ts
generated
vendored
Normal file
68
node_modules/unhead/dist/shared/unhead.CsiVfkwJ.d.ts
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import { a5 as RawInput, R as ResolvableHead, az as ResolvableValue, aA as ResolvableProperties, ag as LinkWithoutEvents, ab as DataKeys, K as SchemaAugmentations, Q as UnheadMeta, ai as ScriptWithoutEvents, O as UnheadHtmlAttributes, N as UnheadBodyAttributesWithoutEvents } from './unhead.BUCuVRIf.js';
|
||||
|
||||
type Base = RawInput<'base'>;
|
||||
type HtmlAttributes = RawInput<'htmlAttrs'>;
|
||||
type Noscript = RawInput<'noscript'>;
|
||||
type Style = RawInput<'style'>;
|
||||
type Meta = RawInput<'meta'>;
|
||||
type Script = RawInput<'script'>;
|
||||
type Link = RawInput<'link'>;
|
||||
type BodyAttributes = RawInput<'bodyAttrs'>;
|
||||
|
||||
type SafeBodyAttr = ResolvableProperties<Pick<UnheadBodyAttributesWithoutEvents, 'id' | 'class' | 'style'> & DataKeys & SchemaAugmentations['bodyAttrs']>;
|
||||
type SafeHtmlAttr = ResolvableProperties<Pick<UnheadHtmlAttributes, 'id' | 'class' | 'style' | 'lang' | 'dir'> & DataKeys & SchemaAugmentations['htmlAttrs']>;
|
||||
type SafeMeta = ResolvableProperties<Pick<UnheadMeta, 'id' | 'name' | 'property' | 'charset' | 'content' | 'media'> & DataKeys & SchemaAugmentations['meta']>;
|
||||
type SafeLink = ResolvableProperties<Pick<LinkWithoutEvents, 'id' | 'color' | 'crossorigin' | 'fetchpriority' | 'href' | 'hreflang' | 'imagesrcset' | 'imagesizes' | 'integrity' | 'media' | 'referrerpolicy' | 'rel' | 'sizes' | 'type'> & DataKeys & SchemaAugmentations['link']>;
|
||||
type SafeScript = ResolvableProperties<Pick<ScriptWithoutEvents, 'id' | 'type' | 'nonce' | 'blocking'> & DataKeys & SchemaAugmentations['script']>;
|
||||
type SafeNoscript = ResolvableProperties<Pick<Noscript, 'id'> & DataKeys & Omit<SchemaAugmentations['noscript'], 'innerHTML'>>;
|
||||
type SafeStyle = ResolvableProperties<Pick<Style, 'id' | 'media' | 'nonce' | 'title' | 'blocking'> & DataKeys & Omit<SchemaAugmentations['style'], 'innerHTML'>>;
|
||||
interface HeadSafe extends Pick<ResolvableHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
||||
/**
|
||||
* 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?: ResolvableValue<ResolvableValue<SafeLink[]>>;
|
||||
/**
|
||||
* 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?: ResolvableValue<ResolvableValue<SafeMeta>[]>;
|
||||
/**
|
||||
* 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?: ResolvableValue<ResolvableValue<(SafeStyle | 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?: ResolvableValue<ResolvableValue<(SafeScript | 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?: ResolvableValue<ResolvableValue<(SafeNoscript | string)>[]>;
|
||||
/**
|
||||
* Attributes for the `<html>` HTML element.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
|
||||
*/
|
||||
htmlAttrs?: ResolvableValue<SafeHtmlAttr>;
|
||||
/**
|
||||
* Attributes for the `<body>` HTML element.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
|
||||
*/
|
||||
bodyAttrs?: ResolvableValue<SafeBodyAttr>;
|
||||
}
|
||||
|
||||
export type { Base as B, HeadSafe as H, Link as L, Meta as M, Noscript as N, SafeBodyAttr as S, SafeHtmlAttr as a, SafeMeta as b, SafeLink as c, SafeScript as d, SafeNoscript as e, SafeStyle as f, HtmlAttributes as g, Style as h, Script as i, BodyAttributes as j };
|
||||
196
node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs
generated
vendored
Normal file
196
node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs
generated
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
import { M as MetaTagsArrayable } from './unhead.yem5I2v_.mjs';
|
||||
|
||||
const NAMESPACES = {
|
||||
META: /* @__PURE__ */ new Set(["twitter"]),
|
||||
OG: /* @__PURE__ */ new Set(["og", "book", "article", "profile", "fb"]),
|
||||
MEDIA: /* @__PURE__ */ new Set(["ogImage", "ogVideo", "ogAudio", "twitterImage"]),
|
||||
HTTP_EQUIV: /* @__PURE__ */ new Set(["contentType", "defaultStyle", "xUaCompatible"])
|
||||
};
|
||||
const META_ALIASES = {
|
||||
articleExpirationTime: "article:expiration_time",
|
||||
articleModifiedTime: "article:modified_time",
|
||||
articlePublishedTime: "article:published_time",
|
||||
bookReleaseDate: "book:release_date",
|
||||
fbAppId: "fb:app_id",
|
||||
ogAudioSecureUrl: "og:audio:secure_url",
|
||||
ogAudioUrl: "og:audio",
|
||||
ogImageSecureUrl: "og:image:secure_url",
|
||||
ogImageUrl: "og:image",
|
||||
ogSiteName: "og:site_name",
|
||||
ogVideoSecureUrl: "og:video:secure_url",
|
||||
ogVideoUrl: "og:video",
|
||||
profileFirstName: "profile:first_name",
|
||||
profileLastName: "profile:last_name",
|
||||
profileUsername: "profile:username",
|
||||
msapplicationConfig: "msapplication-Config",
|
||||
msapplicationTileColor: "msapplication-TileColor",
|
||||
msapplicationTileImage: "msapplication-TileImage"
|
||||
};
|
||||
const MetaPackingSchema = {
|
||||
appleItunesApp: {
|
||||
unpack: {
|
||||
entrySeparator: ", ",
|
||||
// @ts-expect-error untyped
|
||||
resolve: ({ key, value }) => `${fixKeyCase(key)}=${value}`
|
||||
}
|
||||
},
|
||||
refresh: {
|
||||
metaKey: "http-equiv",
|
||||
unpack: {
|
||||
entrySeparator: ";",
|
||||
// @ts-expect-error untyped
|
||||
resolve: ({ key, value }) => key === "seconds" ? `${value}` : void 0
|
||||
}
|
||||
},
|
||||
robots: {
|
||||
unpack: {
|
||||
entrySeparator: ", ",
|
||||
// @ts-expect-error untyped
|
||||
resolve: ({ key, value }) => typeof value === "boolean" ? fixKeyCase(key) : `${fixKeyCase(key)}:${value}`
|
||||
}
|
||||
},
|
||||
contentSecurityPolicy: {
|
||||
metaKey: "http-equiv",
|
||||
unpack: {
|
||||
entrySeparator: "; ",
|
||||
// @ts-expect-error untyped
|
||||
resolve: ({ key, value }) => `${fixKeyCase(key)} ${value}`
|
||||
}
|
||||
},
|
||||
charset: {}
|
||||
};
|
||||
function fixKeyCase(key) {
|
||||
const updated = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
||||
const prefixIndex = updated.indexOf("-");
|
||||
return prefixIndex === -1 ? updated : NAMESPACES.META.has(updated.slice(0, prefixIndex)) || NAMESPACES.OG.has(updated.slice(0, prefixIndex)) ? key.replace(/([A-Z])/g, ":$1").toLowerCase() : updated;
|
||||
}
|
||||
function sanitizeObject(input) {
|
||||
return Object.fromEntries(Object.entries(input).filter(([k, v]) => String(v) !== "false" && k));
|
||||
}
|
||||
function transformObject(obj) {
|
||||
return Array.isArray(obj) ? obj.map(transformObject) : !obj || typeof obj !== "object" ? obj : Object.fromEntries(Object.entries(obj).map(([k, v]) => [fixKeyCase(k), transformObject(v)]));
|
||||
}
|
||||
function unpackToString(value, options = {}) {
|
||||
const { entrySeparator = "", keyValueSeparator = "", wrapValue, resolve } = options;
|
||||
return Object.entries(value).map(([key, val]) => {
|
||||
if (resolve) {
|
||||
const resolved = resolve({ key, value: val });
|
||||
if (resolved !== void 0)
|
||||
return resolved;
|
||||
}
|
||||
const processedVal = typeof val === "object" ? unpackToString(val, options) : typeof val === "number" ? val.toString() : typeof val === "string" && wrapValue ? `${wrapValue}${val.replace(new RegExp(wrapValue, "g"), `\\${wrapValue}`)}${wrapValue}` : val;
|
||||
return `${key}${keyValueSeparator}${processedVal}`;
|
||||
}).join(entrySeparator);
|
||||
}
|
||||
function handleObjectEntry(key, value) {
|
||||
const sanitizedValue = sanitizeObject(value);
|
||||
const fixedKey = fixKeyCase(key);
|
||||
const attr = resolveMetaKeyType(fixedKey);
|
||||
if (!MetaTagsArrayable.has(fixedKey)) {
|
||||
return [{ [attr]: fixedKey, ...sanitizedValue }];
|
||||
}
|
||||
const input = Object.fromEntries(
|
||||
Object.entries(sanitizedValue).map(([k, v]) => [`${key}${k === "url" ? "" : `${k[0].toUpperCase()}${k.slice(1)}`}`, v])
|
||||
);
|
||||
return unpackMeta(input || {}).sort((a, b) => (a[attr]?.length || 0) - (b[attr]?.length || 0));
|
||||
}
|
||||
function resolveMetaKeyType(key) {
|
||||
if (MetaPackingSchema[key]?.metaKey === "http-equiv" || NAMESPACES.HTTP_EQUIV.has(key)) {
|
||||
return "http-equiv";
|
||||
}
|
||||
const fixed = fixKeyCase(key);
|
||||
const colonIndex = fixed.indexOf(":");
|
||||
return colonIndex === -1 ? "name" : NAMESPACES.OG.has(fixed.slice(0, colonIndex)) ? "property" : "name";
|
||||
}
|
||||
function resolveMetaKeyValue(key) {
|
||||
return META_ALIASES[key] || fixKeyCase(key);
|
||||
}
|
||||
function resolvePackedMetaObjectValue(value, key) {
|
||||
if (key === "refresh")
|
||||
return `${value.seconds};url=${value.url}`;
|
||||
return unpackToString(transformObject(value), {
|
||||
keyValueSeparator: "=",
|
||||
entrySeparator: ", ",
|
||||
resolve: ({ value: value2, key: key2 }) => value2 === null ? "" : typeof value2 === "boolean" ? key2 : void 0,
|
||||
// @ts-expect-error untyped
|
||||
...MetaPackingSchema[key]?.unpack
|
||||
});
|
||||
}
|
||||
function unpackMeta(input) {
|
||||
const extras = [];
|
||||
const primitives = {};
|
||||
for (const [key, value] of Object.entries(input)) {
|
||||
if (Array.isArray(value)) {
|
||||
if (key === "themeColor") {
|
||||
value.forEach((v) => {
|
||||
if (typeof v === "object" && v !== null) {
|
||||
extras.push({ name: "theme-color", ...v });
|
||||
}
|
||||
});
|
||||
continue;
|
||||
}
|
||||
for (const v of value) {
|
||||
if (typeof v === "object" && v !== null) {
|
||||
const urlProps = [];
|
||||
const otherProps = [];
|
||||
for (const [propKey, propValue] of Object.entries(v)) {
|
||||
const metaKey = `${key}${propKey === "url" ? "" : `:${propKey}`}`;
|
||||
const meta2 = unpackMeta({ [metaKey]: propValue });
|
||||
(propKey === "url" ? urlProps : otherProps).push(...meta2);
|
||||
}
|
||||
extras.push(...urlProps, ...otherProps);
|
||||
} else {
|
||||
extras.push(...typeof v === "string" ? unpackMeta({ [key]: v }) : handleObjectEntry(key, v));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (typeof value === "object" && value) {
|
||||
if (NAMESPACES.MEDIA.has(key)) {
|
||||
const prefix = key.startsWith("twitter") ? "twitter" : "og";
|
||||
const type = key.replace(/^(og|twitter)/, "").toLowerCase();
|
||||
const metaKey = prefix === "twitter" ? "name" : "property";
|
||||
if (value.url) {
|
||||
extras.push({
|
||||
[metaKey]: `${prefix}:${type}`,
|
||||
content: value.url
|
||||
});
|
||||
}
|
||||
if (value.secureUrl) {
|
||||
extras.push({
|
||||
[metaKey]: `${prefix}:${type}:secure_url`,
|
||||
content: value.secureUrl
|
||||
});
|
||||
}
|
||||
for (const [propKey, propValue] of Object.entries(value)) {
|
||||
if (propKey !== "url" && propKey !== "secureUrl") {
|
||||
extras.push({
|
||||
[metaKey]: `${prefix}:${type}:${propKey}`,
|
||||
// @ts-expect-error untyped
|
||||
content: propValue
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (MetaTagsArrayable.has(fixKeyCase(key))) {
|
||||
extras.push(...handleObjectEntry(key, value));
|
||||
} else {
|
||||
primitives[key] = sanitizeObject(value);
|
||||
}
|
||||
} else {
|
||||
primitives[key] = value;
|
||||
}
|
||||
}
|
||||
const meta = Object.entries(primitives).map(([key, value]) => {
|
||||
if (key === "charset")
|
||||
return { charset: value === null ? "_null" : value };
|
||||
const metaKey = resolveMetaKeyType(key);
|
||||
const keyValue = resolveMetaKeyValue(key);
|
||||
const processedValue = value === null ? "_null" : typeof value === "object" ? resolvePackedMetaObjectValue(value, key) : typeof value === "number" ? value.toString() : value;
|
||||
return metaKey === "http-equiv" ? { "http-equiv": keyValue, "content": processedValue } : { [metaKey]: keyValue, content: processedValue };
|
||||
});
|
||||
return [...extras, ...meta].map(
|
||||
(m) => !("content" in m) ? m : m.content === "_null" ? { ...m, content: null } : m
|
||||
);
|
||||
}
|
||||
|
||||
export { resolveMetaKeyValue as a, resolvePackedMetaObjectValue as b, resolveMetaKeyType as r, unpackMeta as u };
|
||||
166
node_modules/unhead/dist/shared/unhead.ckV6dpEQ.mjs
generated
vendored
Normal file
166
node_modules/unhead/dist/shared/unhead.ckV6dpEQ.mjs
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
import { d as defineHeadPlugin } from './unhead.CApf5sj3.mjs';
|
||||
import { s as sortTags } from './unhead.CbpEuj3y.mjs';
|
||||
import { p as processTemplateParams } from './unhead.BYvz9V1x.mjs';
|
||||
|
||||
const formatKey = (k) => !k.includes(":key") ? k.split(":").join(":key:") : k;
|
||||
const AliasSortingPlugin = defineHeadPlugin({
|
||||
key: "aliasSorting",
|
||||
hooks: {
|
||||
"tags:resolve": (ctx) => {
|
||||
let m = false;
|
||||
for (const t of ctx.tags) {
|
||||
const p = t.tagPriority;
|
||||
if (!p)
|
||||
continue;
|
||||
const s = String(p);
|
||||
if (s.startsWith("before:")) {
|
||||
const k = formatKey(s.slice(7));
|
||||
const l = ctx.tagMap.get(k);
|
||||
if (l) {
|
||||
if (typeof l.tagPriority === "number")
|
||||
t.tagPriority = l.tagPriority;
|
||||
t._p = l._p - 1;
|
||||
m = true;
|
||||
}
|
||||
} else if (s.startsWith("after:")) {
|
||||
const k = formatKey(s.slice(6));
|
||||
const l = ctx.tagMap.get(k);
|
||||
if (l) {
|
||||
if (typeof l.tagPriority === "number")
|
||||
t.tagPriority = l.tagPriority;
|
||||
t._p = l._p + 1;
|
||||
m = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m)
|
||||
ctx.tags = ctx.tags.sort(sortTags);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const DeprecationsPlugin = /* @__PURE__ */ defineHeadPlugin({
|
||||
key: "deprecations",
|
||||
hooks: {
|
||||
"entries:normalize": ({ tags }) => {
|
||||
for (const tag of tags) {
|
||||
if (tag.props.children) {
|
||||
tag.innerHTML = tag.props.children;
|
||||
delete tag.props.children;
|
||||
}
|
||||
if (tag.props.hid) {
|
||||
tag.key = tag.props.hid;
|
||||
delete tag.props.hid;
|
||||
}
|
||||
if (tag.props.vmid) {
|
||||
tag.key = tag.props.vmid;
|
||||
delete tag.props.vmid;
|
||||
}
|
||||
if (tag.props.body) {
|
||||
tag.tagPosition = "bodyClose";
|
||||
delete tag.props.body;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function walkPromises(v) {
|
||||
const type = typeof v;
|
||||
if (type === "function") {
|
||||
return v;
|
||||
}
|
||||
if (v instanceof Promise) {
|
||||
return await v;
|
||||
}
|
||||
if (Array.isArray(v)) {
|
||||
return await Promise.all(v.map((r) => walkPromises(r)));
|
||||
}
|
||||
if (v?.constructor === Object) {
|
||||
const next = {};
|
||||
for (const key of Object.keys(v)) {
|
||||
next[key] = await walkPromises(v[key]);
|
||||
}
|
||||
return next;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
const PromisesPlugin = /* @__PURE__ */ defineHeadPlugin({
|
||||
key: "promises",
|
||||
hooks: {
|
||||
"entries:resolve": async (ctx) => {
|
||||
const promises = [];
|
||||
for (const k in ctx.entries) {
|
||||
if (!ctx.entries[k]._promisesProcessed) {
|
||||
promises.push(
|
||||
walkPromises(ctx.entries[k].input).then((val) => {
|
||||
ctx.entries[k].input = val;
|
||||
ctx.entries[k]._promisesProcessed = true;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
await Promise.all(promises);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const SupportedAttrs = {
|
||||
meta: "content",
|
||||
link: "href",
|
||||
htmlAttrs: "lang"
|
||||
};
|
||||
const contentAttrs = ["innerHTML", "textContent"];
|
||||
const TemplateParamsPlugin = /* @__PURE__ */ defineHeadPlugin((head) => {
|
||||
return {
|
||||
key: "template-params",
|
||||
hooks: {
|
||||
"entries:normalize": (ctx) => {
|
||||
const params = ctx.tags.filter((t) => t.tag === "templateParams" && t.mode === "server")?.[0]?.props || {};
|
||||
if (Object.keys(params).length) {
|
||||
head._ssrPayload = {
|
||||
templateParams: {
|
||||
...head._ssrPayload?.templateParams || {},
|
||||
...params
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
"tags:resolve": ({ tagMap, tags }) => {
|
||||
const params = tagMap.get("templateParams")?.props || {};
|
||||
const sep = params.separator || "|";
|
||||
delete params.separator;
|
||||
params.pageTitle = processTemplateParams(
|
||||
// find templateParams
|
||||
params.pageTitle || head._title || "",
|
||||
params,
|
||||
sep
|
||||
);
|
||||
for (const tag of tags) {
|
||||
if (tag.processTemplateParams === false) {
|
||||
continue;
|
||||
}
|
||||
const v = SupportedAttrs[tag.tag];
|
||||
if (v && typeof tag.props[v] === "string") {
|
||||
tag.props[v] = processTemplateParams(tag.props[v], params, sep);
|
||||
} else if (tag.processTemplateParams || tag.tag === "titleTemplate" || tag.tag === "title") {
|
||||
for (const p of contentAttrs) {
|
||||
if (typeof tag[p] === "string")
|
||||
tag[p] = processTemplateParams(tag[p], params, sep, tag.tag === "script" && tag.props.type.endsWith("json"));
|
||||
}
|
||||
}
|
||||
}
|
||||
head._templateParams = params;
|
||||
head._separator = sep;
|
||||
},
|
||||
"tags:afterResolve": ({ tagMap }) => {
|
||||
const title = tagMap.get("title");
|
||||
if (title?.textContent && title.processTemplateParams !== false) {
|
||||
title.textContent = processTemplateParams(title.textContent, head._templateParams, head._separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
export { AliasSortingPlugin as A, DeprecationsPlugin as D, PromisesPlugin as P, TemplateParamsPlugin as T };
|
||||
198
node_modules/unhead/dist/shared/unhead.eK9_7LaY.mjs
generated
vendored
Normal file
198
node_modules/unhead/dist/shared/unhead.eK9_7LaY.mjs
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
import { U as UniqueTags, T as TagsWithInnerContent, M as MetaTagsArrayable, a as TagConfigKeys, D as DupeableTags } from './unhead.yem5I2v_.mjs';
|
||||
|
||||
const allowedMetaProperties = ["name", "property", "http-equiv"];
|
||||
const StandardSingleMetaTags = /* @__PURE__ */ new Set([
|
||||
"viewport",
|
||||
"description",
|
||||
"keywords",
|
||||
"robots"
|
||||
]);
|
||||
function isMetaArrayDupeKey(v) {
|
||||
const parts = v.split(":");
|
||||
if (!parts.length)
|
||||
return false;
|
||||
return MetaTagsArrayable.has(parts[1]);
|
||||
}
|
||||
function dedupeKey(tag) {
|
||||
const { props, tag: name } = tag;
|
||||
if (UniqueTags.has(name))
|
||||
return name;
|
||||
if (name === "link" && props.rel === "canonical")
|
||||
return "canonical";
|
||||
const altKey = props.hreflang || props.type;
|
||||
if (name === "link" && props.rel === "alternate" && altKey) {
|
||||
return `alternate:${altKey}`;
|
||||
}
|
||||
if (props.charset)
|
||||
return "charset";
|
||||
if (tag.tag === "meta") {
|
||||
for (const n of allowedMetaProperties) {
|
||||
if (props[n] !== void 0) {
|
||||
const propValue = props[n];
|
||||
const isStructured = propValue && typeof propValue === "string" && propValue.includes(":");
|
||||
const isStandardSingle = propValue && StandardSingleMetaTags.has(propValue);
|
||||
const shouldAlwaysDedupe = isStructured || isStandardSingle;
|
||||
const keyPart = !shouldAlwaysDedupe && tag.key ? `:key:${tag.key}` : "";
|
||||
return `${name}:${propValue}${keyPart}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tag.key) {
|
||||
return `${name}:key:${tag.key}`;
|
||||
}
|
||||
if (props.id) {
|
||||
return `${name}:id:${props.id}`;
|
||||
}
|
||||
if (TagsWithInnerContent.has(name)) {
|
||||
const v = tag.textContent || tag.innerHTML;
|
||||
if (v) {
|
||||
return `${name}:content:${v}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
function hashTag(tag) {
|
||||
const dedupe = tag._h || tag._d;
|
||||
if (dedupe)
|
||||
return dedupe;
|
||||
const inner = tag.textContent || tag.innerHTML;
|
||||
if (inner)
|
||||
return inner;
|
||||
return `${tag.tag}:${Object.entries(tag.props).map(([k, v]) => `${k}:${String(v)}`).join(",")}`;
|
||||
}
|
||||
|
||||
function walkResolver(val, resolve, key) {
|
||||
const type = typeof val;
|
||||
if (type === "function") {
|
||||
if (!key || key !== "titleTemplate" && !(key[0] === "o" && key[1] === "n")) {
|
||||
val = val();
|
||||
}
|
||||
}
|
||||
const v = resolve ? resolve(key, val) : val;
|
||||
if (Array.isArray(v)) {
|
||||
return v.map((r) => walkResolver(r, resolve));
|
||||
}
|
||||
if (v?.constructor === Object) {
|
||||
const next = {};
|
||||
for (const k of Object.keys(v)) {
|
||||
next[k] = walkResolver(v[k], resolve, k);
|
||||
}
|
||||
return next;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
function normalizeStyleClassProps(key, value) {
|
||||
const store = key === "style" ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Set();
|
||||
function processValue(rawValue) {
|
||||
if (rawValue == null || rawValue === void 0)
|
||||
return;
|
||||
const value2 = String(rawValue).trim();
|
||||
if (!value2)
|
||||
return;
|
||||
if (key === "style") {
|
||||
const [k, ...v] = value2.split(":").map((s) => s ? s.trim() : "");
|
||||
if (k && v.length)
|
||||
store.set(k, v.join(":"));
|
||||
} else {
|
||||
value2.split(" ").filter(Boolean).forEach((c) => store.add(c));
|
||||
}
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
key === "style" ? value.split(";").forEach(processValue) : processValue(value);
|
||||
} else if (Array.isArray(value)) {
|
||||
value.forEach((item) => processValue(item));
|
||||
} else if (value && typeof value === "object") {
|
||||
Object.entries(value).forEach(([k, v]) => {
|
||||
if (v && v !== "false") {
|
||||
key === "style" ? store.set(String(k).trim(), String(v)) : processValue(k);
|
||||
}
|
||||
});
|
||||
}
|
||||
return store;
|
||||
}
|
||||
function normalizeProps(tag, input) {
|
||||
tag.props = tag.props || {};
|
||||
if (!input) {
|
||||
return tag;
|
||||
}
|
||||
if (tag.tag === "templateParams") {
|
||||
tag.props = input;
|
||||
return tag;
|
||||
}
|
||||
Object.entries(input).forEach(([key, value]) => {
|
||||
if (value === null) {
|
||||
tag.props[key] = null;
|
||||
return;
|
||||
}
|
||||
if (key === "class" || key === "style") {
|
||||
tag.props[key] = normalizeStyleClassProps(key, value);
|
||||
return;
|
||||
}
|
||||
if (TagConfigKeys.has(key)) {
|
||||
if (["textContent", "innerHTML"].includes(key) && typeof value === "object") {
|
||||
let type = input.type;
|
||||
if (!input.type) {
|
||||
type = "application/json";
|
||||
}
|
||||
if (!type?.endsWith("json") && type !== "speculationrules") {
|
||||
return;
|
||||
}
|
||||
input.type = type;
|
||||
tag.props.type = type;
|
||||
tag[key] = JSON.stringify(value);
|
||||
} else {
|
||||
tag[key] = value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
const strValue = String(value);
|
||||
const isDataKey = key.startsWith("data-");
|
||||
const isMetaContentKey = tag.tag === "meta" && key === "content";
|
||||
if (strValue === "true" || strValue === "") {
|
||||
tag.props[key] = isDataKey || isMetaContentKey ? strValue : true;
|
||||
} else if (!value && isDataKey && strValue === "false") {
|
||||
tag.props[key] = "false";
|
||||
} else if (value !== void 0) {
|
||||
tag.props[key] = value;
|
||||
}
|
||||
});
|
||||
return tag;
|
||||
}
|
||||
function normalizeTag(tagName, _input) {
|
||||
const input = typeof _input === "object" && typeof _input !== "function" ? _input : { [tagName === "script" || tagName === "noscript" || tagName === "style" ? "innerHTML" : "textContent"]: _input };
|
||||
const tag = normalizeProps({ tag: tagName, props: {} }, input);
|
||||
if (tag.key && DupeableTags.has(tag.tag)) {
|
||||
tag.props["data-hid"] = tag._h = tag.key;
|
||||
}
|
||||
if (tag.tag === "script" && typeof tag.innerHTML === "object") {
|
||||
tag.innerHTML = JSON.stringify(tag.innerHTML);
|
||||
tag.props.type = tag.props.type || "application/json";
|
||||
}
|
||||
return Array.isArray(tag.props.content) ? tag.props.content.map((v) => ({ ...tag, props: { ...tag.props, content: v } })) : tag;
|
||||
}
|
||||
function normalizeEntryToTags(input, propResolvers) {
|
||||
if (!input) {
|
||||
return [];
|
||||
}
|
||||
if (typeof input === "function") {
|
||||
input = input();
|
||||
}
|
||||
const resolvers = (key, val) => {
|
||||
for (let i = 0; i < propResolvers.length; i++) {
|
||||
val = propResolvers[i](key, val);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
input = resolvers(void 0, input);
|
||||
const tags = [];
|
||||
input = walkResolver(input, resolvers);
|
||||
Object.entries(input || {}).forEach(([key, value]) => {
|
||||
if (value === void 0)
|
||||
return;
|
||||
for (const v of Array.isArray(value) ? value : [value])
|
||||
tags.push(normalizeTag(key, v));
|
||||
});
|
||||
return tags.flat();
|
||||
}
|
||||
|
||||
export { normalizeProps as a, dedupeKey as d, hashTag as h, isMetaArrayDupeKey as i, normalizeEntryToTags as n, walkResolver as w };
|
||||
38
node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs
generated
vendored
Normal file
38
node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
const SelfClosingTags = /* @__PURE__ */ new Set(["meta", "link", "base"]);
|
||||
const DupeableTags = /* @__PURE__ */ new Set(["link", "style", "script", "noscript"]);
|
||||
const TagsWithInnerContent = /* @__PURE__ */ new Set(["title", "titleTemplate", "script", "style", "noscript"]);
|
||||
const HasElementTags = /* @__PURE__ */ new Set([
|
||||
"base",
|
||||
"meta",
|
||||
"link",
|
||||
"style",
|
||||
"script",
|
||||
"noscript"
|
||||
]);
|
||||
const ValidHeadTags = /* @__PURE__ */ new Set([
|
||||
"title",
|
||||
"base",
|
||||
"htmlAttrs",
|
||||
"bodyAttrs",
|
||||
"meta",
|
||||
"link",
|
||||
"style",
|
||||
"script",
|
||||
"noscript"
|
||||
]);
|
||||
const UniqueTags = /* @__PURE__ */ new Set(["base", "title", "titleTemplate", "bodyAttrs", "htmlAttrs", "templateParams"]);
|
||||
const TagConfigKeys = /* @__PURE__ */ new Set(["key", "tagPosition", "tagPriority", "tagDuplicateStrategy", "innerHTML", "textContent", "processTemplateParams"]);
|
||||
const ScriptNetworkEvents = /* @__PURE__ */ new Set(["onload", "onerror"]);
|
||||
const UsesMergeStrategy = /* @__PURE__ */ new Set(["templateParams", "htmlAttrs", "bodyAttrs"]);
|
||||
const MetaTagsArrayable = /* @__PURE__ */ new Set([
|
||||
"theme-color",
|
||||
"google-site-verification",
|
||||
"og",
|
||||
"article",
|
||||
"book",
|
||||
"profile",
|
||||
"twitter",
|
||||
"author"
|
||||
]);
|
||||
|
||||
export { DupeableTags as D, HasElementTags as H, MetaTagsArrayable as M, SelfClosingTags as S, TagsWithInnerContent as T, UniqueTags as U, ValidHeadTags as V, TagConfigKeys as a, ScriptNetworkEvents as b, UsesMergeStrategy as c };
|
||||
266
node_modules/unhead/dist/types.d.mts
generated
vendored
Normal file
266
node_modules/unhead/dist/types.d.mts
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
import { B as Booleanable, e as ReferrerPolicy } from './shared/unhead.BUCuVRIf.mjs';
|
||||
export { p as ActiveHeadEntry, ax as Arrayable, A as AsVoidFunctions, ae as BodyAttributesWithoutEvents, af as BodyEvents, r as CreateClientHeadOptions, C as CreateHeadOptions, q as CreateServerHeadOptions, ab as DataKeys, aC as DeepResolvableProperties, y as DomBeforeRenderCtx, J as DomPluginOptions, x as DomRenderTagContext, D as DomState, w as EntryResolveCtx, E as EventHandlerOptions, ad as GlobalAttributes, at as HasTemplateParams, a6 as Head, H as HeadEntry, s as HeadEntryOptions, G as HeadHooks, o as HeadPlugin, n as HeadPluginInput, m as HeadPluginOptions, au as HeadTag, av as HeadTagKeys, t as HookResult, ac as HttpEventAttributes, an as InnerContent, am as InnerContentVal, ag as LinkWithoutEvents, L as MaybeArray, T as MaybeEventFnHandlers, aa as MergeHead, ah as MetaFlat, M as MetaFlatInput, ay as Never, as as ProcessesTemplateParams, P as PropResolver, a5 as RawInput, j as RecordingEntry, I as RenderDomHeadOptions, v as RenderSSRHeadOptions, Y as ResolvableBase, a3 as ResolvableBodyAttributes, R as ResolvableHead, a2 as ResolvableHtmlAttributes, Z as ResolvableLink, _ as ResolvableMeta, a1 as ResolvableNoscript, aA as ResolvableProperties, a0 as ResolvableScript, $ as ResolvableStyle, a4 as ResolvableTemplateParams, V as ResolvableTitle, X as ResolvableTitleTemplate, aB as ResolvableUnion, az as ResolvableValue, a7 as ResolvedHead, aj as ResolvesDuplicates, l as RuntimeMode, u as SSRHeadPayload, F as SSRRenderContext, K as SchemaAugmentations, i as ScriptInstance, ai as ScriptWithoutEvents, S as SerializableHead, z as ShouldRenderContext, k as SideEffectsRecord, aw as Stringable, aq as TagKey, al as TagPosition, ao as TagPriority, ap as TagUserProperties, ar as TemplateParams, U as Unhead, N as UnheadBodyAttributesWithoutEvents, O as UnheadHtmlAttributes, Q as UnheadMeta, h as UseFunctionType, a9 as UseHeadInput, g as UseScriptContext, a as UseScriptInput, b as UseScriptOptions, d as UseScriptResolvedInput, c as UseScriptReturn, f as UseScriptStatus, a8 as UseSeoMetaInput, ak as ValidTagPositions, W as WarmupStrategy } from './shared/unhead.BUCuVRIf.mjs';
|
||||
export { B as Base, j as BodyAttributes, H as HeadSafe, g as HtmlAttributes, L as Link, M as Meta, N as Noscript, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle, i as Script, h as Style } from './shared/unhead.CBPtX666.mjs';
|
||||
export { r as resolveScriptKey, u as useScript } from './shared/unhead.CC7bAF1a.mjs';
|
||||
export { createSpyProxy } from './scripts.mjs';
|
||||
import 'hookable';
|
||||
|
||||
interface AriaAttributes {
|
||||
/**
|
||||
* Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change
|
||||
* notifications defined by the aria-relevant attribute.
|
||||
*/
|
||||
'role'?: 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'button' | 'checkbox' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'dialog' | 'directory' | 'document' | 'feed' | 'figure' | 'form' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'navigation' | 'note' | 'option' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'textbox' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem';
|
||||
/**
|
||||
* Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.
|
||||
*/
|
||||
'aria-activedescendant'?: string;
|
||||
/**
|
||||
* Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change
|
||||
* notifications defined by the aria-relevant attribute.
|
||||
*/
|
||||
'aria-atomic'?: Booleanable;
|
||||
/**
|
||||
* Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for
|
||||
* an input and specifies how predictions would be presented if they are made.
|
||||
*/
|
||||
'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both';
|
||||
/**
|
||||
* Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are
|
||||
* complete before exposing them to the user.
|
||||
*/
|
||||
'aria-busy'?: Booleanable;
|
||||
/**
|
||||
* Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
|
||||
*/
|
||||
'aria-checked'?: Booleanable | 'mixed';
|
||||
/**
|
||||
* Defines the total number of columns in a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-colcount'?: number;
|
||||
/**
|
||||
* Defines an element's column index or position with respect to the total number of columns within a table, grid, or
|
||||
* treegrid.
|
||||
*/
|
||||
'aria-colindex'?: number;
|
||||
/**
|
||||
* Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-colspan'?: number;
|
||||
/**
|
||||
* Identifies the element (or elements) whose contents or presence are controlled by the current element.
|
||||
*/
|
||||
'aria-controls'?: string;
|
||||
/**
|
||||
* Indicates the element that represents the current item within a container or set of related elements.
|
||||
*/
|
||||
'aria-current'?: Booleanable | 'page' | 'step' | 'location' | 'date' | 'time';
|
||||
/**
|
||||
* Identifies the element (or elements) that describes the object.
|
||||
*/
|
||||
'aria-describedby'?: string;
|
||||
/**
|
||||
* Identifies the element that provides a detailed, extended description for the object.
|
||||
*/
|
||||
'aria-details'?: string;
|
||||
/**
|
||||
* Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
|
||||
*/
|
||||
'aria-disabled'?: Booleanable;
|
||||
/**
|
||||
* Indicates what functions can be performed when a dragged object is released on the drop target.
|
||||
*/
|
||||
'aria-dropeffect'?: 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup';
|
||||
/**
|
||||
* Identifies the element that provides an error message for the object.
|
||||
*/
|
||||
'aria-errormessage'?: string;
|
||||
/**
|
||||
* Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
|
||||
*/
|
||||
'aria-expanded'?: Booleanable;
|
||||
/**
|
||||
* Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
|
||||
* allows assistive technology to override the general default of reading in document source order.
|
||||
*/
|
||||
'aria-flowto'?: string;
|
||||
/**
|
||||
* Indicates an element's "grabbed" state in a drag-and-drop operation.
|
||||
*/
|
||||
'aria-grabbed'?: Booleanable;
|
||||
/**
|
||||
* Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by
|
||||
* an element.
|
||||
*/
|
||||
'aria-haspopup'?: Booleanable | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
||||
/**
|
||||
* Indicates whether the element is exposed to an accessibility API.
|
||||
*/
|
||||
'aria-hidden'?: Booleanable;
|
||||
/**
|
||||
* Indicates the entered value does not conform to the format expected by the application.
|
||||
*/
|
||||
'aria-invalid'?: Booleanable | 'grammar' | 'spelling';
|
||||
/**
|
||||
* Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.
|
||||
*/
|
||||
'aria-keyshortcuts'?: string;
|
||||
/**
|
||||
* Defines a string value that labels the current element.
|
||||
*/
|
||||
'aria-label'?: string;
|
||||
/**
|
||||
* Identifies the element (or elements) that labels the current element.
|
||||
*/
|
||||
'aria-labelledby'?: string;
|
||||
/**
|
||||
* Defines the hierarchical level of an element within a structure.
|
||||
*/
|
||||
'aria-level'?: number;
|
||||
/**
|
||||
* Indicates that an element will be updated, and describes the types of updates the user agents, assistive
|
||||
* technologies, and user can expect from the live region.
|
||||
*/
|
||||
'aria-live'?: 'off' | 'assertive' | 'polite';
|
||||
/**
|
||||
* Indicates whether an element is modal when displayed.
|
||||
*/
|
||||
'aria-modal'?: Booleanable;
|
||||
/**
|
||||
* Indicates whether a text box accepts multiple lines of input or only a single line.
|
||||
*/
|
||||
'aria-multiline'?: Booleanable;
|
||||
/**
|
||||
* Indicates that the user may select more than one item from the current selectable descendants.
|
||||
*/
|
||||
'aria-multiselectable'?: Booleanable;
|
||||
/**
|
||||
* Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.
|
||||
*/
|
||||
'aria-orientation'?: 'horizontal' | 'vertical';
|
||||
/**
|
||||
* Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
|
||||
* between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
|
||||
*/
|
||||
'aria-owns'?: string;
|
||||
/**
|
||||
* Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no
|
||||
* value. A hint could be a sample value or a brief description of the expected format.
|
||||
*/
|
||||
'aria-placeholder'?: string;
|
||||
/**
|
||||
* Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements
|
||||
* in the set are present in the DOM.
|
||||
*/
|
||||
'aria-posinset'?: number;
|
||||
/**
|
||||
* Indicates the current "pressed" state of toggle buttons.
|
||||
*/
|
||||
'aria-pressed'?: Booleanable | 'mixed';
|
||||
/**
|
||||
* Indicates that the element is not editable, but is otherwise operable.
|
||||
*/
|
||||
'aria-readonly'?: Booleanable;
|
||||
/**
|
||||
* Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
|
||||
*/
|
||||
'aria-relevant'?: 'additions' | 'additions text' | 'all' | 'removals' | 'text';
|
||||
/**
|
||||
* Indicates that user input is required on the element before a form may be submitted.
|
||||
*/
|
||||
'aria-required'?: Booleanable;
|
||||
/**
|
||||
* Defines a human-readable, author-localized description for the role of an element.
|
||||
*/
|
||||
'aria-roledescription'?: string;
|
||||
/**
|
||||
* Defines the total number of rows in a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-rowcount'?: number;
|
||||
/**
|
||||
* Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-rowindex'?: number;
|
||||
/**
|
||||
* Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-rowspan'?: number;
|
||||
/**
|
||||
* Indicates the current "selected" state of various widgets.
|
||||
*/
|
||||
'aria-selected'?: Booleanable;
|
||||
/**
|
||||
* Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
|
||||
*/
|
||||
'aria-setsize'?: number;
|
||||
/**
|
||||
* Indicates if items in a table or grid are sorted in ascending or descending order.
|
||||
*/
|
||||
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other';
|
||||
/**
|
||||
* Defines the maximum allowed value for a range widget.
|
||||
*/
|
||||
'aria-valuemax'?: number;
|
||||
/**
|
||||
* Defines the minimum allowed value for a range widget.
|
||||
*/
|
||||
'aria-valuemin'?: number;
|
||||
/**
|
||||
* Defines the current value for a range widget.
|
||||
*/
|
||||
'aria-valuenow'?: number;
|
||||
/**
|
||||
* Defines the human readable text alternative of aria-valuenow for a range widget.
|
||||
*/
|
||||
'aria-valuetext'?: string;
|
||||
}
|
||||
|
||||
interface SpeculationRules {
|
||||
prefetch?: (SpeculationRuleList | SpeculationRuleDocument)[];
|
||||
prerender?: (SpeculationRuleList | SpeculationRuleDocument)[];
|
||||
}
|
||||
interface SpeculationRuleBase {
|
||||
/**
|
||||
* A hint about how likely the user is to navigate to the URL
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#scores
|
||||
*/
|
||||
score?: number;
|
||||
/**
|
||||
* Parse urls/patterns relative to the document's base url.
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#using-the-documents-base-url-for-external-speculation-rule-sets
|
||||
*/
|
||||
relative_to?: 'document';
|
||||
/**
|
||||
* Assertions in the rule about the capabilities of the user agent while executing them.
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#requirements
|
||||
*/
|
||||
requires?: 'anonymous-client-ip-when-cross-origin'[];
|
||||
/**
|
||||
* Indicating where the page expects the prerendered content to be activated.
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#window-name-targeting-hints
|
||||
*/
|
||||
target_hint?: '_blank' | '_self' | '_parent' | '_top';
|
||||
/**
|
||||
* The policy to use for the speculative request.
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#explicit-referrer-policy
|
||||
*/
|
||||
referrer_policy?: ReferrerPolicy;
|
||||
}
|
||||
interface SpeculationRuleList extends SpeculationRuleBase {
|
||||
source: 'list';
|
||||
urls: string[];
|
||||
}
|
||||
type SpeculationRuleFn = 'and' | 'or' | 'href_matches' | 'selector_matches' | 'not';
|
||||
type SpeculationRuleWhere = Partial<Record<SpeculationRuleFn, Partial<(Record<SpeculationRuleFn, (Partial<Record<SpeculationRuleFn, string>>) | string>)>[]>>;
|
||||
interface SpeculationRuleDocument extends SpeculationRuleBase {
|
||||
source: 'document';
|
||||
where: SpeculationRuleWhere;
|
||||
}
|
||||
|
||||
export { Booleanable };
|
||||
export type { AriaAttributes, SpeculationRules };
|
||||
266
node_modules/unhead/dist/types.d.ts
generated
vendored
Normal file
266
node_modules/unhead/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
import { B as Booleanable, e as ReferrerPolicy } from './shared/unhead.BUCuVRIf.js';
|
||||
export { p as ActiveHeadEntry, ax as Arrayable, A as AsVoidFunctions, ae as BodyAttributesWithoutEvents, af as BodyEvents, r as CreateClientHeadOptions, C as CreateHeadOptions, q as CreateServerHeadOptions, ab as DataKeys, aC as DeepResolvableProperties, y as DomBeforeRenderCtx, J as DomPluginOptions, x as DomRenderTagContext, D as DomState, w as EntryResolveCtx, E as EventHandlerOptions, ad as GlobalAttributes, at as HasTemplateParams, a6 as Head, H as HeadEntry, s as HeadEntryOptions, G as HeadHooks, o as HeadPlugin, n as HeadPluginInput, m as HeadPluginOptions, au as HeadTag, av as HeadTagKeys, t as HookResult, ac as HttpEventAttributes, an as InnerContent, am as InnerContentVal, ag as LinkWithoutEvents, L as MaybeArray, T as MaybeEventFnHandlers, aa as MergeHead, ah as MetaFlat, M as MetaFlatInput, ay as Never, as as ProcessesTemplateParams, P as PropResolver, a5 as RawInput, j as RecordingEntry, I as RenderDomHeadOptions, v as RenderSSRHeadOptions, Y as ResolvableBase, a3 as ResolvableBodyAttributes, R as ResolvableHead, a2 as ResolvableHtmlAttributes, Z as ResolvableLink, _ as ResolvableMeta, a1 as ResolvableNoscript, aA as ResolvableProperties, a0 as ResolvableScript, $ as ResolvableStyle, a4 as ResolvableTemplateParams, V as ResolvableTitle, X as ResolvableTitleTemplate, aB as ResolvableUnion, az as ResolvableValue, a7 as ResolvedHead, aj as ResolvesDuplicates, l as RuntimeMode, u as SSRHeadPayload, F as SSRRenderContext, K as SchemaAugmentations, i as ScriptInstance, ai as ScriptWithoutEvents, S as SerializableHead, z as ShouldRenderContext, k as SideEffectsRecord, aw as Stringable, aq as TagKey, al as TagPosition, ao as TagPriority, ap as TagUserProperties, ar as TemplateParams, U as Unhead, N as UnheadBodyAttributesWithoutEvents, O as UnheadHtmlAttributes, Q as UnheadMeta, h as UseFunctionType, a9 as UseHeadInput, g as UseScriptContext, a as UseScriptInput, b as UseScriptOptions, d as UseScriptResolvedInput, c as UseScriptReturn, f as UseScriptStatus, a8 as UseSeoMetaInput, ak as ValidTagPositions, W as WarmupStrategy } from './shared/unhead.BUCuVRIf.js';
|
||||
export { B as Base, j as BodyAttributes, H as HeadSafe, g as HtmlAttributes, L as Link, M as Meta, N as Noscript, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle, i as Script, h as Style } from './shared/unhead.CsiVfkwJ.js';
|
||||
export { r as resolveScriptKey, u as useScript } from './shared/unhead.Btq-XLkr.js';
|
||||
export { createSpyProxy } from './scripts.js';
|
||||
import 'hookable';
|
||||
|
||||
interface AriaAttributes {
|
||||
/**
|
||||
* Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change
|
||||
* notifications defined by the aria-relevant attribute.
|
||||
*/
|
||||
'role'?: 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'button' | 'checkbox' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'dialog' | 'directory' | 'document' | 'feed' | 'figure' | 'form' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'navigation' | 'note' | 'option' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'textbox' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem';
|
||||
/**
|
||||
* Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.
|
||||
*/
|
||||
'aria-activedescendant'?: string;
|
||||
/**
|
||||
* Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change
|
||||
* notifications defined by the aria-relevant attribute.
|
||||
*/
|
||||
'aria-atomic'?: Booleanable;
|
||||
/**
|
||||
* Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for
|
||||
* an input and specifies how predictions would be presented if they are made.
|
||||
*/
|
||||
'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both';
|
||||
/**
|
||||
* Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are
|
||||
* complete before exposing them to the user.
|
||||
*/
|
||||
'aria-busy'?: Booleanable;
|
||||
/**
|
||||
* Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
|
||||
*/
|
||||
'aria-checked'?: Booleanable | 'mixed';
|
||||
/**
|
||||
* Defines the total number of columns in a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-colcount'?: number;
|
||||
/**
|
||||
* Defines an element's column index or position with respect to the total number of columns within a table, grid, or
|
||||
* treegrid.
|
||||
*/
|
||||
'aria-colindex'?: number;
|
||||
/**
|
||||
* Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-colspan'?: number;
|
||||
/**
|
||||
* Identifies the element (or elements) whose contents or presence are controlled by the current element.
|
||||
*/
|
||||
'aria-controls'?: string;
|
||||
/**
|
||||
* Indicates the element that represents the current item within a container or set of related elements.
|
||||
*/
|
||||
'aria-current'?: Booleanable | 'page' | 'step' | 'location' | 'date' | 'time';
|
||||
/**
|
||||
* Identifies the element (or elements) that describes the object.
|
||||
*/
|
||||
'aria-describedby'?: string;
|
||||
/**
|
||||
* Identifies the element that provides a detailed, extended description for the object.
|
||||
*/
|
||||
'aria-details'?: string;
|
||||
/**
|
||||
* Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
|
||||
*/
|
||||
'aria-disabled'?: Booleanable;
|
||||
/**
|
||||
* Indicates what functions can be performed when a dragged object is released on the drop target.
|
||||
*/
|
||||
'aria-dropeffect'?: 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup';
|
||||
/**
|
||||
* Identifies the element that provides an error message for the object.
|
||||
*/
|
||||
'aria-errormessage'?: string;
|
||||
/**
|
||||
* Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
|
||||
*/
|
||||
'aria-expanded'?: Booleanable;
|
||||
/**
|
||||
* Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
|
||||
* allows assistive technology to override the general default of reading in document source order.
|
||||
*/
|
||||
'aria-flowto'?: string;
|
||||
/**
|
||||
* Indicates an element's "grabbed" state in a drag-and-drop operation.
|
||||
*/
|
||||
'aria-grabbed'?: Booleanable;
|
||||
/**
|
||||
* Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by
|
||||
* an element.
|
||||
*/
|
||||
'aria-haspopup'?: Booleanable | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
||||
/**
|
||||
* Indicates whether the element is exposed to an accessibility API.
|
||||
*/
|
||||
'aria-hidden'?: Booleanable;
|
||||
/**
|
||||
* Indicates the entered value does not conform to the format expected by the application.
|
||||
*/
|
||||
'aria-invalid'?: Booleanable | 'grammar' | 'spelling';
|
||||
/**
|
||||
* Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.
|
||||
*/
|
||||
'aria-keyshortcuts'?: string;
|
||||
/**
|
||||
* Defines a string value that labels the current element.
|
||||
*/
|
||||
'aria-label'?: string;
|
||||
/**
|
||||
* Identifies the element (or elements) that labels the current element.
|
||||
*/
|
||||
'aria-labelledby'?: string;
|
||||
/**
|
||||
* Defines the hierarchical level of an element within a structure.
|
||||
*/
|
||||
'aria-level'?: number;
|
||||
/**
|
||||
* Indicates that an element will be updated, and describes the types of updates the user agents, assistive
|
||||
* technologies, and user can expect from the live region.
|
||||
*/
|
||||
'aria-live'?: 'off' | 'assertive' | 'polite';
|
||||
/**
|
||||
* Indicates whether an element is modal when displayed.
|
||||
*/
|
||||
'aria-modal'?: Booleanable;
|
||||
/**
|
||||
* Indicates whether a text box accepts multiple lines of input or only a single line.
|
||||
*/
|
||||
'aria-multiline'?: Booleanable;
|
||||
/**
|
||||
* Indicates that the user may select more than one item from the current selectable descendants.
|
||||
*/
|
||||
'aria-multiselectable'?: Booleanable;
|
||||
/**
|
||||
* Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.
|
||||
*/
|
||||
'aria-orientation'?: 'horizontal' | 'vertical';
|
||||
/**
|
||||
* Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
|
||||
* between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
|
||||
*/
|
||||
'aria-owns'?: string;
|
||||
/**
|
||||
* Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no
|
||||
* value. A hint could be a sample value or a brief description of the expected format.
|
||||
*/
|
||||
'aria-placeholder'?: string;
|
||||
/**
|
||||
* Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements
|
||||
* in the set are present in the DOM.
|
||||
*/
|
||||
'aria-posinset'?: number;
|
||||
/**
|
||||
* Indicates the current "pressed" state of toggle buttons.
|
||||
*/
|
||||
'aria-pressed'?: Booleanable | 'mixed';
|
||||
/**
|
||||
* Indicates that the element is not editable, but is otherwise operable.
|
||||
*/
|
||||
'aria-readonly'?: Booleanable;
|
||||
/**
|
||||
* Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
|
||||
*/
|
||||
'aria-relevant'?: 'additions' | 'additions text' | 'all' | 'removals' | 'text';
|
||||
/**
|
||||
* Indicates that user input is required on the element before a form may be submitted.
|
||||
*/
|
||||
'aria-required'?: Booleanable;
|
||||
/**
|
||||
* Defines a human-readable, author-localized description for the role of an element.
|
||||
*/
|
||||
'aria-roledescription'?: string;
|
||||
/**
|
||||
* Defines the total number of rows in a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-rowcount'?: number;
|
||||
/**
|
||||
* Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-rowindex'?: number;
|
||||
/**
|
||||
* Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
|
||||
*/
|
||||
'aria-rowspan'?: number;
|
||||
/**
|
||||
* Indicates the current "selected" state of various widgets.
|
||||
*/
|
||||
'aria-selected'?: Booleanable;
|
||||
/**
|
||||
* Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
|
||||
*/
|
||||
'aria-setsize'?: number;
|
||||
/**
|
||||
* Indicates if items in a table or grid are sorted in ascending or descending order.
|
||||
*/
|
||||
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other';
|
||||
/**
|
||||
* Defines the maximum allowed value for a range widget.
|
||||
*/
|
||||
'aria-valuemax'?: number;
|
||||
/**
|
||||
* Defines the minimum allowed value for a range widget.
|
||||
*/
|
||||
'aria-valuemin'?: number;
|
||||
/**
|
||||
* Defines the current value for a range widget.
|
||||
*/
|
||||
'aria-valuenow'?: number;
|
||||
/**
|
||||
* Defines the human readable text alternative of aria-valuenow for a range widget.
|
||||
*/
|
||||
'aria-valuetext'?: string;
|
||||
}
|
||||
|
||||
interface SpeculationRules {
|
||||
prefetch?: (SpeculationRuleList | SpeculationRuleDocument)[];
|
||||
prerender?: (SpeculationRuleList | SpeculationRuleDocument)[];
|
||||
}
|
||||
interface SpeculationRuleBase {
|
||||
/**
|
||||
* A hint about how likely the user is to navigate to the URL
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#scores
|
||||
*/
|
||||
score?: number;
|
||||
/**
|
||||
* Parse urls/patterns relative to the document's base url.
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#using-the-documents-base-url-for-external-speculation-rule-sets
|
||||
*/
|
||||
relative_to?: 'document';
|
||||
/**
|
||||
* Assertions in the rule about the capabilities of the user agent while executing them.
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#requirements
|
||||
*/
|
||||
requires?: 'anonymous-client-ip-when-cross-origin'[];
|
||||
/**
|
||||
* Indicating where the page expects the prerendered content to be activated.
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#window-name-targeting-hints
|
||||
*/
|
||||
target_hint?: '_blank' | '_self' | '_parent' | '_top';
|
||||
/**
|
||||
* The policy to use for the speculative request.
|
||||
*
|
||||
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#explicit-referrer-policy
|
||||
*/
|
||||
referrer_policy?: ReferrerPolicy;
|
||||
}
|
||||
interface SpeculationRuleList extends SpeculationRuleBase {
|
||||
source: 'list';
|
||||
urls: string[];
|
||||
}
|
||||
type SpeculationRuleFn = 'and' | 'or' | 'href_matches' | 'selector_matches' | 'not';
|
||||
type SpeculationRuleWhere = Partial<Record<SpeculationRuleFn, Partial<(Record<SpeculationRuleFn, (Partial<Record<SpeculationRuleFn, string>>) | string>)>[]>>;
|
||||
interface SpeculationRuleDocument extends SpeculationRuleBase {
|
||||
source: 'document';
|
||||
where: SpeculationRuleWhere;
|
||||
}
|
||||
|
||||
export { Booleanable };
|
||||
export type { AriaAttributes, SpeculationRules };
|
||||
1
node_modules/unhead/dist/types.mjs
generated
vendored
Normal file
1
node_modules/unhead/dist/types.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
34
node_modules/unhead/dist/utils.d.mts
generated
vendored
Normal file
34
node_modules/unhead/dist/utils.d.mts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { au as HeadTag, Q as UnheadMeta, ah as MetaFlat, R as ResolvableHead, P as PropResolver, U as Unhead, ar as TemplateParams } from './shared/unhead.BUCuVRIf.mjs';
|
||||
import 'hookable';
|
||||
|
||||
declare const SelfClosingTags: Set<string>;
|
||||
declare const DupeableTags: Set<string>;
|
||||
declare const TagsWithInnerContent: Set<string>;
|
||||
declare const HasElementTags: Set<string>;
|
||||
declare const ValidHeadTags: Set<string>;
|
||||
declare const UniqueTags: Set<string>;
|
||||
declare const TagConfigKeys: Set<string>;
|
||||
declare const ScriptNetworkEvents: Set<string>;
|
||||
declare const UsesMergeStrategy: Set<string>;
|
||||
declare const MetaTagsArrayable: Set<string>;
|
||||
|
||||
declare function isMetaArrayDupeKey(v: string): boolean;
|
||||
declare function dedupeKey<T extends HeadTag>(tag: T): string | undefined;
|
||||
declare function hashTag(tag: HeadTag): string;
|
||||
|
||||
declare function resolveMetaKeyType(key: string): keyof UnheadMeta;
|
||||
declare function resolveMetaKeyValue(key: string): string;
|
||||
declare function resolvePackedMetaObjectValue(value: string, key: string): string;
|
||||
declare function unpackMeta<T extends MetaFlat>(input: T): Required<ResolvableHead>['meta'];
|
||||
|
||||
declare function normalizeProps(tag: HeadTag, input: Record<string, any>): HeadTag;
|
||||
declare function normalizeEntryToTags(input: any, propResolvers: PropResolver[]): HeadTag[];
|
||||
|
||||
declare const sortTags: (a: HeadTag, b: HeadTag) => number;
|
||||
declare function tagWeight<T extends HeadTag>(head: Unhead<any>, tag: T): number;
|
||||
|
||||
declare function processTemplateParams(s: string, p: TemplateParams, sep?: string, isJson?: boolean): string;
|
||||
|
||||
declare function walkResolver(val: any, resolve?: PropResolver, key?: string): any;
|
||||
|
||||
export { DupeableTags, HasElementTags, MetaTagsArrayable, ScriptNetworkEvents, SelfClosingTags, TagConfigKeys, TagsWithInnerContent, UniqueTags, UsesMergeStrategy, ValidHeadTags, dedupeKey, hashTag, isMetaArrayDupeKey, normalizeEntryToTags, normalizeProps, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, sortTags, tagWeight, unpackMeta, walkResolver };
|
||||
34
node_modules/unhead/dist/utils.d.ts
generated
vendored
Normal file
34
node_modules/unhead/dist/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { au as HeadTag, Q as UnheadMeta, ah as MetaFlat, R as ResolvableHead, P as PropResolver, U as Unhead, ar as TemplateParams } from './shared/unhead.BUCuVRIf.js';
|
||||
import 'hookable';
|
||||
|
||||
declare const SelfClosingTags: Set<string>;
|
||||
declare const DupeableTags: Set<string>;
|
||||
declare const TagsWithInnerContent: Set<string>;
|
||||
declare const HasElementTags: Set<string>;
|
||||
declare const ValidHeadTags: Set<string>;
|
||||
declare const UniqueTags: Set<string>;
|
||||
declare const TagConfigKeys: Set<string>;
|
||||
declare const ScriptNetworkEvents: Set<string>;
|
||||
declare const UsesMergeStrategy: Set<string>;
|
||||
declare const MetaTagsArrayable: Set<string>;
|
||||
|
||||
declare function isMetaArrayDupeKey(v: string): boolean;
|
||||
declare function dedupeKey<T extends HeadTag>(tag: T): string | undefined;
|
||||
declare function hashTag(tag: HeadTag): string;
|
||||
|
||||
declare function resolveMetaKeyType(key: string): keyof UnheadMeta;
|
||||
declare function resolveMetaKeyValue(key: string): string;
|
||||
declare function resolvePackedMetaObjectValue(value: string, key: string): string;
|
||||
declare function unpackMeta<T extends MetaFlat>(input: T): Required<ResolvableHead>['meta'];
|
||||
|
||||
declare function normalizeProps(tag: HeadTag, input: Record<string, any>): HeadTag;
|
||||
declare function normalizeEntryToTags(input: any, propResolvers: PropResolver[]): HeadTag[];
|
||||
|
||||
declare const sortTags: (a: HeadTag, b: HeadTag) => number;
|
||||
declare function tagWeight<T extends HeadTag>(head: Unhead<any>, tag: T): number;
|
||||
|
||||
declare function processTemplateParams(s: string, p: TemplateParams, sep?: string, isJson?: boolean): string;
|
||||
|
||||
declare function walkResolver(val: any, resolve?: PropResolver, key?: string): any;
|
||||
|
||||
export { DupeableTags, HasElementTags, MetaTagsArrayable, ScriptNetworkEvents, SelfClosingTags, TagConfigKeys, TagsWithInnerContent, UniqueTags, UsesMergeStrategy, ValidHeadTags, dedupeKey, hashTag, isMetaArrayDupeKey, normalizeEntryToTags, normalizeProps, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, sortTags, tagWeight, unpackMeta, walkResolver };
|
||||
5
node_modules/unhead/dist/utils.mjs
generated
vendored
Normal file
5
node_modules/unhead/dist/utils.mjs
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export { D as DupeableTags, H as HasElementTags, M as MetaTagsArrayable, b as ScriptNetworkEvents, S as SelfClosingTags, a as TagConfigKeys, T as TagsWithInnerContent, U as UniqueTags, c as UsesMergeStrategy, V as ValidHeadTags } from './shared/unhead.yem5I2v_.mjs';
|
||||
export { d as dedupeKey, h as hashTag, i as isMetaArrayDupeKey, n as normalizeEntryToTags, a as normalizeProps, w as walkResolver } from './shared/unhead.eK9_7LaY.mjs';
|
||||
export { r as resolveMetaKeyType, a as resolveMetaKeyValue, b as resolvePackedMetaObjectValue, u as unpackMeta } from './shared/unhead.DQc16pHI.mjs';
|
||||
export { s as sortTags, t as tagWeight } from './shared/unhead.CbpEuj3y.mjs';
|
||||
export { p as processTemplateParams } from './shared/unhead.BYvz9V1x.mjs';
|
||||
1
node_modules/unhead/legacy.d.ts
generated
vendored
Normal file
1
node_modules/unhead/legacy.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/legacy.mjs'
|
||||
21
node_modules/unhead/node_modules/hookable/LICENSE.md
generated
vendored
Normal file
21
node_modules/unhead/node_modules/hookable/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
||||
|
||||
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.
|
||||
291
node_modules/unhead/node_modules/hookable/README.md
generated
vendored
Normal file
291
node_modules/unhead/node_modules/hookable/README.md
generated
vendored
Normal file
@@ -0,0 +1,291 @@
|
||||
# Hookable
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![bundle][bundle-src]][bundle-href]
|
||||
[![Codecov][codecov-src]][codecov-href]
|
||||
[![License][license-src]][license-href]
|
||||
|
||||
Awaitable hooks system.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npx nypm i hookable
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
**Method A: Create a hookable instance:**
|
||||
|
||||
```js
|
||||
import { Hookable } from "hookable";
|
||||
|
||||
// Create a hookable instance
|
||||
const hooks = new Hookable();
|
||||
|
||||
// Hook on 'hello'
|
||||
hooks.hook("hello", () => {
|
||||
console.log("Hello World");
|
||||
});
|
||||
|
||||
// Call 'hello' hook
|
||||
hooks.callHook("hello");
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> You can use `HookableCore` alternatively for less bundle and runtime footprint if simple `hook`/`callHook` functionality is only needed.
|
||||
|
||||
**Method B: Extend your base class from Hookable:**
|
||||
|
||||
```js
|
||||
import { Hookable } from "hookable";
|
||||
|
||||
export default class FooLib extends Hookable {
|
||||
constructor() {
|
||||
// Call to parent to initialize
|
||||
super();
|
||||
// Initialize Hookable with custom logger
|
||||
// super(consola)
|
||||
}
|
||||
|
||||
async someFunction() {
|
||||
// Call and wait for `hook1` hooks (if any) sequential
|
||||
await this.callHook("hook1");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Inside plugins, register for any hook:**
|
||||
|
||||
```js
|
||||
const lib = new FooLib();
|
||||
|
||||
// Register a handler for `hook2`
|
||||
lib.hook("hook2", async () => {
|
||||
/* ... */
|
||||
});
|
||||
|
||||
// Register multiply handlers at once
|
||||
lib.addHooks({
|
||||
hook1: async () => {
|
||||
/* ... */
|
||||
},
|
||||
hook2: [
|
||||
/* can be also an array */
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
**Unregistering hooks:**
|
||||
|
||||
```js
|
||||
const lib = new FooLib();
|
||||
|
||||
const hook0 = async () => {
|
||||
/* ... */
|
||||
};
|
||||
const hook1 = async () => {
|
||||
/* ... */
|
||||
};
|
||||
const hook2 = async () => {
|
||||
/* ... */
|
||||
};
|
||||
|
||||
// The hook() method returns an "unregister" function
|
||||
const unregisterHook0 = lib.hook("hook0", hook0);
|
||||
const unregisterHooks1and2 = lib.addHooks({ hook1, hook2 });
|
||||
|
||||
/* ... */
|
||||
|
||||
unregisterHook0();
|
||||
unregisterHooks1and2();
|
||||
|
||||
// or
|
||||
|
||||
lib.removeHooks({ hook0, hook1 });
|
||||
lib.removeHook("hook2", hook2);
|
||||
```
|
||||
|
||||
**Triggering a hook handler once:**
|
||||
|
||||
```js
|
||||
const lib = new FooLib();
|
||||
|
||||
const unregister = lib.hook("hook0", async () => {
|
||||
// Unregister as soon as the hook is executed
|
||||
unregister();
|
||||
|
||||
/* ... */
|
||||
});
|
||||
```
|
||||
|
||||
## Hookable class
|
||||
|
||||
### `constructor()`
|
||||
|
||||
### `hook (name, fn)`
|
||||
|
||||
Register a handler for a specific hook. `fn` must be a function.
|
||||
|
||||
Returns an `unregister` function that, when called, will remove the registered handler.
|
||||
|
||||
### `hookOnce (name, fn)`
|
||||
|
||||
Similar to `hook` but unregisters hook once called.
|
||||
|
||||
Returns an `unregister` function that, when called, will remove the registered handler before first call.
|
||||
|
||||
### `addHooks(configHooks)`
|
||||
|
||||
Flatten and register hooks object.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
hookable.addHooks({
|
||||
test: {
|
||||
before: () => {},
|
||||
after: () => {},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
This registers `test:before` and `test:after` hooks at bulk.
|
||||
|
||||
Returns an `unregister` function that, when called, will remove all the registered handlers.
|
||||
|
||||
### `async callHook (name, ...args)`
|
||||
|
||||
Used by class itself to **sequentially** call handlers of a specific hook.
|
||||
|
||||
### `callHookWith (name, callerFn)`
|
||||
|
||||
If you need custom control over how hooks are called, you can provide a custom function that will receive an array of handlers of a specific hook.
|
||||
|
||||
`callerFn` if a callback function that accepts 3 arguments, `hooks`, `args` and `name`:
|
||||
|
||||
- `hooks`: Array of user hooks to be called
|
||||
- `args`: Array of arguments that should be passed each time calling a hook
|
||||
- `name`: Name of the hook
|
||||
|
||||
### `deprecateHook (old, name)`
|
||||
|
||||
Deprecate hook called `old` in favor of `name` hook.
|
||||
|
||||
### `deprecateHooks (deprecatedHooks)`
|
||||
|
||||
Deprecate all hooks from an object (keys are old and values or newer ones).
|
||||
|
||||
### `removeHook (name, fn)`
|
||||
|
||||
Remove a particular hook handler, if the `fn` handler is present.
|
||||
|
||||
### `removeHooks (configHooks)`
|
||||
|
||||
Remove multiple hook handlers.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const handler = async () => {
|
||||
/* ... */
|
||||
};
|
||||
|
||||
hookable.hook("test:before", handler);
|
||||
hookable.addHooks({ test: { after: handler } });
|
||||
|
||||
// ...
|
||||
|
||||
hookable.removeHooks({
|
||||
test: {
|
||||
before: handler,
|
||||
after: handler,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### `removeAllHooks`
|
||||
|
||||
Remove all hook handlers.
|
||||
|
||||
### `beforeEach (syncCallback)`
|
||||
|
||||
Registers a (sync) callback to be called before each hook is being called.
|
||||
|
||||
```js
|
||||
hookable.beforeEach((event) => {
|
||||
console.log(`${event.name} hook is being called with ${event.args}`);
|
||||
});
|
||||
hookable.hook("test", () => {
|
||||
console.log("running test hook");
|
||||
});
|
||||
|
||||
// test hook is being called with []
|
||||
// running test hook
|
||||
await hookable.callHook("test");
|
||||
```
|
||||
|
||||
### `afterEach (syncCallback)`
|
||||
|
||||
Registers a (sync) callback to be called after each hook is being called.
|
||||
|
||||
```js
|
||||
hookable.afterEach((event) => {
|
||||
console.log(`${event.name} hook called with ${event.args}`);
|
||||
});
|
||||
hookable.hook("test", () => {
|
||||
console.log("running test hook");
|
||||
});
|
||||
|
||||
// running test hook
|
||||
// test hook called with []
|
||||
await hookable.callHook("test");
|
||||
```
|
||||
|
||||
### `createDebugger`
|
||||
|
||||
Automatically logs each hook that is called and how long it takes to run.
|
||||
|
||||
```js
|
||||
const debug = hookable.createDebugger(hooks, { tag: "something" });
|
||||
|
||||
hooks.callHook("some-hook", "some-arg");
|
||||
// [something] some-hook: 0.21ms
|
||||
|
||||
debug.close();
|
||||
```
|
||||
|
||||
## Migration
|
||||
|
||||
### From `4.x` to `5.x`
|
||||
|
||||
- Type checking improved. You can use `Hookable<T>` or `createHooks<T>()` to provide types interface **([c2e1e22](https://github.com/unjs/hookable/commit/c2e1e223d16e7bf87117cd8d72ad3ba211a333d8))**
|
||||
- We no longer provide an IE11 compatible umd build. Instead, you should use an ESM-aware bundler such as webpack or rollup to transpile if needed.
|
||||
- Logger param is dropped. We use `console.warn` by default for deprecated hooks.
|
||||
- Package now uses named exports. You should import `{ Hookable }` instead of `Hookable` or use new `createHooks` util
|
||||
- `mergeHooks` util is exported standalone. You should replace `Hookable.mergeHooks` and `this.mergeHooks` with new `{ mergeHooks }` export
|
||||
- In versions < 5.0.0 when using `callHook` if an error happened by one of the hook callbacks, we was handling errors globally and call global `error` hook + `console.error` instead and resolve `callHook` promise! This sometimes makes confusing behavior when we think code worked but it didn't. v5 introduced a breaking change that when a hook throws an error, `callHook` also rejects instead of a global `error` event. This means you should be careful to handle all errors when using `callHook` now.
|
||||
|
||||
## Credits
|
||||
|
||||
Extracted from [Nuxt](https://github.com/nuxt/nuxt.js) hooks system originally introduced by [Sébastien Chopin](https://github.com/Atinux)
|
||||
|
||||
Thanks to [Joe Paice](https://github.com/RGBboy) for donating [hookable](https://www.npmjs.com/package/hookable) package name.
|
||||
|
||||
## License
|
||||
|
||||
MIT - Made with 💖
|
||||
|
||||
<!-- Badges -->
|
||||
|
||||
[npm-version-src]: https://img.shields.io/npm/v/hookable?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[npm-version-href]: https://npmjs.com/package/hookable
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/hookable?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[npm-downloads-href]: https://npmjs.com/package/hookable
|
||||
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/hookable/main?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[codecov-href]: https://codecov.io/gh/unjs/h3
|
||||
[bundle-src]: https://img.shields.io/bundlephobia/minzip/hookable?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[bundle-href]: https://bundlephobia.com/result?p=hookable
|
||||
[license-src]: https://img.shields.io/github/license/unjs/hookable.svg?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[license-href]: https://github.com/unjs/hookable/blob/main/LICENSE
|
||||
106
node_modules/unhead/node_modules/hookable/dist/index.d.mts
generated
vendored
Normal file
106
node_modules/unhead/node_modules/hookable/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
//#region src/types.d.ts
|
||||
type HookCallback = (...arguments_: any) => Promise<void> | void;
|
||||
interface Hooks {
|
||||
[key: string]: HookCallback;
|
||||
}
|
||||
type HookKeys<T> = keyof T & string;
|
||||
type DeprecatedHook<T> = {
|
||||
message?: string;
|
||||
to: HookKeys<T>;
|
||||
};
|
||||
type DeprecatedHooks<T> = { [name in HookKeys<T>]: DeprecatedHook<T> };
|
||||
type ValueOf<C> = C extends Record<any, any> ? C[keyof C] : never;
|
||||
type Strings<T> = Exclude<keyof T, number | symbol>;
|
||||
type KnownKeys<T> = keyof { [K in keyof T as string extends K ? never : number extends K ? never : K]: never };
|
||||
type StripGeneric<T> = Pick<T, KnownKeys<T> extends keyof T ? KnownKeys<T> : never>;
|
||||
type OnlyGeneric<T> = Omit<T, KnownKeys<T> extends keyof T ? KnownKeys<T> : never>;
|
||||
type Namespaces<T> = ValueOf<{ [key in Strings<T>]: key extends `${infer Namespace}:${string}` ? Namespace : never }>;
|
||||
type BareHooks<T> = ValueOf<{ [key in Strings<T>]: key extends `${string}:${string}` ? never : key }>;
|
||||
type HooksInNamespace<T, Namespace extends string> = ValueOf<{ [key in Strings<T>]: key extends `${Namespace}:${infer HookName}` ? HookName : never }>;
|
||||
type WithoutNamespace<T, Namespace extends string> = { [key in HooksInNamespace<T, Namespace>]: `${Namespace}:${key}` extends keyof T ? T[`${Namespace}:${key}`] : never };
|
||||
type NestedHooks<T> = (Partial<StripGeneric<T>> | Partial<OnlyGeneric<T>>) & Partial<{ [key in Namespaces<StripGeneric<T>>]: NestedHooks<WithoutNamespace<T, key>> }> & Partial<{ [key in BareHooks<StripGeneric<T>>]: T[key] }>;
|
||||
//#endregion
|
||||
//#region src/hookable.d.ts
|
||||
type InferCallback<HT, HN extends keyof HT> = HT[HN] extends HookCallback ? HT[HN] : never;
|
||||
type InferSpyEvent<HT extends Record<string, any>> = { [key in keyof HT]: {
|
||||
name: key;
|
||||
args: Parameters<HT[key]>;
|
||||
context: Record<string, any>;
|
||||
} }[keyof HT];
|
||||
declare class Hookable<HooksT extends Record<string, any> = Record<string, HookCallback>, HookNameT extends HookKeys<HooksT> = HookKeys<HooksT>> {
|
||||
private _hooks;
|
||||
private _before?;
|
||||
private _after?;
|
||||
private _deprecatedHooks;
|
||||
private _deprecatedMessages?;
|
||||
constructor();
|
||||
hook<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>, options?: {
|
||||
allowDeprecated?: boolean;
|
||||
}): () => void;
|
||||
hookOnce<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>): () => void;
|
||||
removeHook<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>): void;
|
||||
deprecateHook<NameT extends HookNameT>(name: NameT, deprecated: HookKeys<HooksT> | DeprecatedHook<HooksT>): void;
|
||||
deprecateHooks(deprecatedHooks: Partial<Record<HookNameT, DeprecatedHook<HooksT>>>): void;
|
||||
addHooks(configHooks: NestedHooks<HooksT>): () => void;
|
||||
removeHooks(configHooks: NestedHooks<HooksT>): void;
|
||||
removeAllHooks(): void;
|
||||
callHook<NameT extends HookNameT>(name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>): Promise<any> | void;
|
||||
callHookParallel<NameT extends HookNameT>(name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>): Promise<any[]> | void;
|
||||
callHookWith<NameT extends HookNameT, CallFunction extends (hooks: HookCallback[], args: Parameters<InferCallback<HooksT, NameT>>, name: NameT) => any>(caller: CallFunction, name: NameT, args: Parameters<InferCallback<HooksT, NameT>>): ReturnType<CallFunction>;
|
||||
beforeEach(function_: (event: InferSpyEvent<HooksT>) => void): () => void;
|
||||
afterEach(function_: (event: InferSpyEvent<HooksT>) => void): () => void;
|
||||
}
|
||||
declare function createHooks<T extends Record<string, any>>(): Hookable<T>;
|
||||
declare class HookableCore<HooksT extends Record<string, any> = Record<string, HookCallback>, HookNameT extends HookKeys<HooksT> = HookKeys<HooksT>> {
|
||||
protected _hooks: {
|
||||
[key: string]: HookCallback[] | undefined;
|
||||
};
|
||||
constructor();
|
||||
hook<NameT extends HookNameT>(name: NameT, fn: InferCallback<HooksT, NameT>): () => void;
|
||||
removeHook<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>): void;
|
||||
callHook<NameT extends HookNameT>(name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>): Promise<any> | void;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/utils.d.ts
|
||||
declare function flatHooks<T>(configHooks: NestedHooks<T>, hooks?: T, parentName?: string): T;
|
||||
declare function mergeHooks<T>(...hooks: NestedHooks<T>[]): T;
|
||||
declare function serial<T>(tasks: T[], function_: (task: T) => Promise<any> | any): Promise<any>;
|
||||
type CreateTask = (name?: string) => {
|
||||
run: (function_: () => Promise<any> | any) => Promise<any> | any;
|
||||
};
|
||||
declare global {
|
||||
interface Console {
|
||||
createTask?: CreateTask;
|
||||
}
|
||||
}
|
||||
/** @deprecated */
|
||||
declare function serialCaller(hooks: HookCallback[], arguments_?: any[]): Promise<any>;
|
||||
/** @deprecated */
|
||||
declare function parallelCaller(hooks: HookCallback[], args?: any[]): Promise<any>;
|
||||
//#endregion
|
||||
//#region src/debugger.d.ts
|
||||
interface CreateDebuggerOptions {
|
||||
/** An optional tag to prefix console logs with */
|
||||
tag?: string;
|
||||
/**
|
||||
* Show hook params to the console output
|
||||
*
|
||||
* Enabled for browsers by default
|
||||
*/
|
||||
inspect?: boolean;
|
||||
/**
|
||||
* Use group/groupEnd wrapper around logs happening during a specific hook
|
||||
*
|
||||
* Enabled for browsers by default
|
||||
*/
|
||||
group?: boolean;
|
||||
/** Filter which hooks to enable debugger for. Can be a string prefix or fn. */
|
||||
filter?: string | ((event: string) => boolean);
|
||||
}
|
||||
/** Start debugging hook names and timing in console */
|
||||
declare function createDebugger(hooks: Hookable<any>, _options?: CreateDebuggerOptions): {
|
||||
/** Stop debugging and remove listeners */
|
||||
close: () => void;
|
||||
};
|
||||
//#endregion
|
||||
export { CreateDebuggerOptions, DeprecatedHook, DeprecatedHooks, HookCallback, HookKeys, Hookable, HookableCore, Hooks, NestedHooks, createDebugger, createHooks, flatHooks, mergeHooks, parallelCaller, serial, serialCaller };
|
||||
266
node_modules/unhead/node_modules/hookable/dist/index.mjs
generated
vendored
Normal file
266
node_modules/unhead/node_modules/hookable/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
//#region src/utils.ts
|
||||
function flatHooks(configHooks, hooks = {}, parentName) {
|
||||
for (const key in configHooks) {
|
||||
const subHook = configHooks[key];
|
||||
const name = parentName ? `${parentName}:${key}` : key;
|
||||
if (typeof subHook === "object" && subHook !== null) flatHooks(subHook, hooks, name);
|
||||
else if (typeof subHook === "function") hooks[name] = subHook;
|
||||
}
|
||||
return hooks;
|
||||
}
|
||||
function mergeHooks(...hooks) {
|
||||
const finalHooks = {};
|
||||
for (const hook of hooks) {
|
||||
const flatenHook = flatHooks(hook);
|
||||
for (const key in flatenHook) if (finalHooks[key]) finalHooks[key].push(flatenHook[key]);
|
||||
else finalHooks[key] = [flatenHook[key]];
|
||||
}
|
||||
for (const key in finalHooks) if (finalHooks[key].length > 1) {
|
||||
const array = finalHooks[key];
|
||||
finalHooks[key] = (...arguments_) => serial(array, (function_) => function_(...arguments_));
|
||||
} else finalHooks[key] = finalHooks[key][0];
|
||||
return finalHooks;
|
||||
}
|
||||
function serial(tasks, function_) {
|
||||
return tasks.reduce((promise, task) => promise.then(() => function_(task)), Promise.resolve());
|
||||
}
|
||||
const createTask = /* @__PURE__ */ (() => {
|
||||
if (console.createTask) return console.createTask;
|
||||
const defaultTask = { run: (fn) => fn() };
|
||||
return () => defaultTask;
|
||||
})();
|
||||
function callHooks(hooks, args, startIndex, task) {
|
||||
for (let i = startIndex; i < hooks.length; i += 1) try {
|
||||
const result = task ? task.run(() => hooks[i](...args)) : hooks[i](...args);
|
||||
if (result instanceof Promise) return result.then(() => callHooks(hooks, args, i + 1, task));
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
function serialTaskCaller(hooks, args, name) {
|
||||
if (hooks.length > 0) return callHooks(hooks, args, 0, createTask(name));
|
||||
}
|
||||
function parallelTaskCaller(hooks, args, name) {
|
||||
if (hooks.length > 0) {
|
||||
const task = createTask(name);
|
||||
return Promise.all(hooks.map((hook) => task.run(() => hook(...args))));
|
||||
}
|
||||
}
|
||||
/** @deprecated */
|
||||
function serialCaller(hooks, arguments_) {
|
||||
return hooks.reduce((promise, hookFunction) => promise.then(() => hookFunction(...arguments_ || [])), Promise.resolve());
|
||||
}
|
||||
/** @deprecated */
|
||||
function parallelCaller(hooks, args) {
|
||||
return Promise.all(hooks.map((hook) => hook(...args || [])));
|
||||
}
|
||||
function callEachWith(callbacks, arg0) {
|
||||
for (const callback of [...callbacks]) callback(arg0);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/hookable.ts
|
||||
var Hookable = class {
|
||||
_hooks;
|
||||
_before;
|
||||
_after;
|
||||
_deprecatedHooks;
|
||||
_deprecatedMessages;
|
||||
constructor() {
|
||||
this._hooks = {};
|
||||
this._before = void 0;
|
||||
this._after = void 0;
|
||||
this._deprecatedMessages = void 0;
|
||||
this._deprecatedHooks = {};
|
||||
this.hook = this.hook.bind(this);
|
||||
this.callHook = this.callHook.bind(this);
|
||||
this.callHookWith = this.callHookWith.bind(this);
|
||||
}
|
||||
hook(name, function_, options = {}) {
|
||||
if (!name || typeof function_ !== "function") return () => {};
|
||||
const originalName = name;
|
||||
let dep;
|
||||
while (this._deprecatedHooks[name]) {
|
||||
dep = this._deprecatedHooks[name];
|
||||
name = dep.to;
|
||||
}
|
||||
if (dep && !options.allowDeprecated) {
|
||||
let message = dep.message;
|
||||
if (!message) message = `${originalName} hook has been deprecated` + (dep.to ? `, please use ${dep.to}` : "");
|
||||
if (!this._deprecatedMessages) this._deprecatedMessages = /* @__PURE__ */ new Set();
|
||||
if (!this._deprecatedMessages.has(message)) {
|
||||
console.warn(message);
|
||||
this._deprecatedMessages.add(message);
|
||||
}
|
||||
}
|
||||
if (!function_.name) try {
|
||||
Object.defineProperty(function_, "name", {
|
||||
get: () => "_" + name.replace(/\W+/g, "_") + "_hook_cb",
|
||||
configurable: true
|
||||
});
|
||||
} catch {}
|
||||
this._hooks[name] = this._hooks[name] || [];
|
||||
this._hooks[name].push(function_);
|
||||
return () => {
|
||||
if (function_) {
|
||||
this.removeHook(name, function_);
|
||||
function_ = void 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
hookOnce(name, function_) {
|
||||
let _unreg;
|
||||
let _function = (...arguments_) => {
|
||||
if (typeof _unreg === "function") _unreg();
|
||||
_unreg = void 0;
|
||||
_function = void 0;
|
||||
return function_(...arguments_);
|
||||
};
|
||||
_unreg = this.hook(name, _function);
|
||||
return _unreg;
|
||||
}
|
||||
removeHook(name, function_) {
|
||||
const hooks = this._hooks[name];
|
||||
if (hooks) {
|
||||
const index = hooks.indexOf(function_);
|
||||
if (index !== -1) hooks.splice(index, 1);
|
||||
if (hooks.length === 0) this._hooks[name] = void 0;
|
||||
}
|
||||
}
|
||||
deprecateHook(name, deprecated) {
|
||||
this._deprecatedHooks[name] = typeof deprecated === "string" ? { to: deprecated } : deprecated;
|
||||
const _hooks = this._hooks[name] || [];
|
||||
this._hooks[name] = void 0;
|
||||
for (const hook of _hooks) this.hook(name, hook);
|
||||
}
|
||||
deprecateHooks(deprecatedHooks) {
|
||||
for (const name in deprecatedHooks) this.deprecateHook(name, deprecatedHooks[name]);
|
||||
}
|
||||
addHooks(configHooks) {
|
||||
const hooks = flatHooks(configHooks);
|
||||
const removeFns = Object.keys(hooks).map((key) => this.hook(key, hooks[key]));
|
||||
return () => {
|
||||
for (const unreg of removeFns) unreg();
|
||||
removeFns.length = 0;
|
||||
};
|
||||
}
|
||||
removeHooks(configHooks) {
|
||||
const hooks = flatHooks(configHooks);
|
||||
for (const key in hooks) this.removeHook(key, hooks[key]);
|
||||
}
|
||||
removeAllHooks() {
|
||||
this._hooks = {};
|
||||
}
|
||||
callHook(name, ...args) {
|
||||
return this.callHookWith(serialTaskCaller, name, args);
|
||||
}
|
||||
callHookParallel(name, ...args) {
|
||||
return this.callHookWith(parallelTaskCaller, name, args);
|
||||
}
|
||||
callHookWith(caller, name, args) {
|
||||
const event = this._before || this._after ? {
|
||||
name,
|
||||
args,
|
||||
context: {}
|
||||
} : void 0;
|
||||
if (this._before) callEachWith(this._before, event);
|
||||
const result = caller(this._hooks[name] ? [...this._hooks[name]] : [], args, name);
|
||||
if (result instanceof Promise) return result.finally(() => {
|
||||
if (this._after && event) callEachWith(this._after, event);
|
||||
});
|
||||
if (this._after && event) callEachWith(this._after, event);
|
||||
return result;
|
||||
}
|
||||
beforeEach(function_) {
|
||||
this._before = this._before || [];
|
||||
this._before.push(function_);
|
||||
return () => {
|
||||
if (this._before !== void 0) {
|
||||
const index = this._before.indexOf(function_);
|
||||
if (index !== -1) this._before.splice(index, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
afterEach(function_) {
|
||||
this._after = this._after || [];
|
||||
this._after.push(function_);
|
||||
return () => {
|
||||
if (this._after !== void 0) {
|
||||
const index = this._after.indexOf(function_);
|
||||
if (index !== -1) this._after.splice(index, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
function createHooks() {
|
||||
return new Hookable();
|
||||
}
|
||||
var HookableCore = class {
|
||||
_hooks;
|
||||
constructor() {
|
||||
this._hooks = {};
|
||||
}
|
||||
hook(name, fn) {
|
||||
if (!name || typeof fn !== "function") return () => {};
|
||||
this._hooks[name] = this._hooks[name] || [];
|
||||
this._hooks[name].push(fn);
|
||||
return () => {
|
||||
if (fn) {
|
||||
this.removeHook(name, fn);
|
||||
fn = void 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
removeHook(name, function_) {
|
||||
const hooks = this._hooks[name];
|
||||
if (hooks) {
|
||||
const index = hooks.indexOf(function_);
|
||||
if (index !== -1) hooks.splice(index, 1);
|
||||
if (hooks.length === 0) this._hooks[name] = void 0;
|
||||
}
|
||||
}
|
||||
callHook(name, ...args) {
|
||||
const hooks = this._hooks[name];
|
||||
if (!hooks || hooks.length === 0) return;
|
||||
return callHooks(hooks, args, 0);
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/debugger.ts
|
||||
const isBrowser = typeof window !== "undefined";
|
||||
/** Start debugging hook names and timing in console */
|
||||
function createDebugger(hooks, _options = {}) {
|
||||
const options = {
|
||||
inspect: isBrowser,
|
||||
group: isBrowser,
|
||||
filter: () => true,
|
||||
..._options
|
||||
};
|
||||
const _filter = options.filter;
|
||||
const filter = typeof _filter === "string" ? (name) => name.startsWith(_filter) : _filter;
|
||||
const _tag = options.tag ? `[${options.tag}] ` : "";
|
||||
const logPrefix = (event) => _tag + event.name + "".padEnd(event._id, "\0");
|
||||
const _idCtr = {};
|
||||
const unsubscribeBefore = hooks.beforeEach((event) => {
|
||||
if (filter !== void 0 && !filter(event.name)) return;
|
||||
_idCtr[event.name] = _idCtr[event.name] || 0;
|
||||
event._id = _idCtr[event.name]++;
|
||||
console.time(logPrefix(event));
|
||||
});
|
||||
const unsubscribeAfter = hooks.afterEach((event) => {
|
||||
if (filter !== void 0 && !filter(event.name)) return;
|
||||
if (options.group) console.groupCollapsed(event.name);
|
||||
if (options.inspect) console.timeLog(logPrefix(event), event.args);
|
||||
else console.timeEnd(logPrefix(event));
|
||||
if (options.group) console.groupEnd();
|
||||
_idCtr[event.name]--;
|
||||
});
|
||||
return { close: () => {
|
||||
unsubscribeBefore();
|
||||
unsubscribeAfter();
|
||||
} };
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { Hookable, HookableCore, createDebugger, createHooks, flatHooks, mergeHooks, parallelCaller, serial, serialCaller };
|
||||
52
node_modules/unhead/node_modules/hookable/package.json
generated
vendored
Normal file
52
node_modules/unhead/node_modules/hookable/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "hookable",
|
||||
"version": "6.0.1",
|
||||
"description": "Awaitable hook system",
|
||||
"keywords": [
|
||||
"hook",
|
||||
"hookable",
|
||||
"plugin",
|
||||
"tapable",
|
||||
"tappable"
|
||||
],
|
||||
"repository": "unjs/hookable",
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.mjs"
|
||||
},
|
||||
"main": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.mts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"bench": "node --expose-gc --allow-natives-syntax test/bench.ts",
|
||||
"build": "obuild src/index.ts",
|
||||
"dev": "vitest",
|
||||
"lint": "eslint --cache . && prettier -c src test",
|
||||
"lint:fix": "eslint --cache . --fix && prettier -c src test -w",
|
||||
"prepublish": "pnpm build",
|
||||
"release": "pnpm test && pnpm build && changelogen --release --publish --push",
|
||||
"test": "pnpm lint && vitest run --coverage",
|
||||
"test:types": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.0.3",
|
||||
"@vitest/coverage-v8": "^4.0.16",
|
||||
"changelogen": "^0.6.2",
|
||||
"esbuild": "^0.27.2",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-config-unjs": "^0.5.0",
|
||||
"expect-type": "^1.3.0",
|
||||
"hookable-prev": "npm:hookable@^5.5.3",
|
||||
"mitata": "^1.0.34",
|
||||
"obuild": "^0.4.9",
|
||||
"prettier": "^3.7.4",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.3.0",
|
||||
"vitest": "^4.0.16"
|
||||
},
|
||||
"packageManager": "pnpm@10.26.0"
|
||||
}
|
||||
105
node_modules/unhead/package.json
generated
vendored
Normal file
105
node_modules/unhead/package.json
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
{
|
||||
"name": "unhead",
|
||||
"type": "module",
|
||||
"version": "2.1.4",
|
||||
"description": "Full-stack <head> manager built for any framework.",
|
||||
"author": {
|
||||
"name": "Harlan Wilton",
|
||||
"email": "harlan@harlanzw.com",
|
||||
"url": "https://harlanzw.com/"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"tag": "next"
|
||||
},
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/harlan-zw",
|
||||
"homepage": "https://unhead.unjs.io",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/unjs/unhead.git",
|
||||
"directory": "packages/unhead"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/unjs/unhead/issues"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"./plugins": {
|
||||
"types": "./dist/plugins.d.ts",
|
||||
"default": "./dist/plugins.mjs"
|
||||
},
|
||||
"./server": {
|
||||
"types": "./dist/server.d.ts",
|
||||
"default": "./dist/server.mjs"
|
||||
},
|
||||
"./client": {
|
||||
"types": "./dist/client.d.ts",
|
||||
"default": "./dist/client.mjs"
|
||||
},
|
||||
"./legacy": {
|
||||
"types": "./dist/legacy.d.ts",
|
||||
"default": "./dist/legacy.mjs"
|
||||
},
|
||||
"./utils": {
|
||||
"types": "./dist/utils.d.ts",
|
||||
"default": "./dist/utils.mjs"
|
||||
},
|
||||
"./types": {
|
||||
"types": "./dist/types.d.ts",
|
||||
"default": "./dist/types.mjs"
|
||||
},
|
||||
"./scripts": {
|
||||
"types": "./dist/scripts.d.ts",
|
||||
"default": "./dist/scripts.mjs"
|
||||
},
|
||||
"./parser": {
|
||||
"types": "./dist/parser.d.ts",
|
||||
"default": "./dist/parser.mjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.mjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"optionalPlugins": {
|
||||
"*": {
|
||||
"plugins": [
|
||||
"dist/plugins"
|
||||
],
|
||||
"server": [
|
||||
"dist/server"
|
||||
],
|
||||
"client": [
|
||||
"dist/client"
|
||||
],
|
||||
"legacy": [
|
||||
"dist/legacy"
|
||||
],
|
||||
"types": [
|
||||
"dist/types"
|
||||
],
|
||||
"utils": [
|
||||
"dist/utils"
|
||||
],
|
||||
"scripts": [
|
||||
"dist/scripts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"hookable": "^6.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"stub": "unbuild --stub",
|
||||
"test:attw": "attw --pack"
|
||||
}
|
||||
}
|
||||
1
node_modules/unhead/parser.d.ts
generated
vendored
Normal file
1
node_modules/unhead/parser.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/parser.mjs'
|
||||
1
node_modules/unhead/plugins.d.ts
generated
vendored
Normal file
1
node_modules/unhead/plugins.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/plugins.mjs'
|
||||
1
node_modules/unhead/scripts.d.ts
generated
vendored
Normal file
1
node_modules/unhead/scripts.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/scripts.mjs'
|
||||
1
node_modules/unhead/server.d.ts
generated
vendored
Normal file
1
node_modules/unhead/server.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/server.mjs'
|
||||
1
node_modules/unhead/types.d.ts
generated
vendored
Normal file
1
node_modules/unhead/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/types'
|
||||
1
node_modules/unhead/utils.d.ts
generated
vendored
Normal file
1
node_modules/unhead/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/utils'
|
||||
Reference in New Issue
Block a user