unhead 2.1.9 → 3.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -7
- package/dist/client.d.mts +10 -8
- package/dist/client.d.ts +10 -8
- package/dist/client.mjs +59 -201
- package/dist/index.d.mts +6 -25
- package/dist/index.d.ts +6 -25
- package/dist/index.mjs +37 -8
- package/dist/parser.d.mts +1 -2
- package/dist/parser.d.ts +1 -2
- package/dist/plugins.d.mts +3 -4
- package/dist/plugins.d.ts +3 -4
- package/dist/plugins.mjs +131 -8
- package/dist/scripts.d.mts +4 -3
- package/dist/scripts.d.ts +4 -3
- package/dist/scripts.mjs +4 -2
- package/dist/server.d.mts +17 -21
- package/dist/server.d.ts +17 -21
- package/dist/server.mjs +15 -169
- package/dist/shared/{unhead.CApf5sj3.mjs → unhead.2y8V0W4A.mjs} +1 -1
- package/dist/shared/{unhead.DKj0fe9v.d.mts → unhead.5ph757u1.d.mts} +1015 -666
- package/dist/shared/{unhead.DKj0fe9v.d.ts → unhead.5ph757u1.d.ts} +1015 -666
- package/dist/shared/unhead.B9UFuLCK.d.mts +13 -0
- package/dist/shared/unhead.BLJ5lSpj.mjs +195 -0
- package/dist/shared/unhead.Bkfgmqxw.mjs +52 -0
- package/dist/shared/{unhead.ChAQb_uO.d.ts → unhead.BqsuEzgR.d.ts} +5 -8
- package/dist/shared/unhead.C-4k1ONY.d.ts +14 -0
- package/dist/shared/{unhead.yem5I2v_.mjs → unhead.C2yODEXq.mjs} +4 -20
- package/dist/shared/unhead.CdKxe2-O.mjs +153 -0
- package/dist/shared/{unhead.B_NszWhX.d.ts → unhead.Cfuv4vVm.d.ts} +2 -6
- package/dist/shared/unhead.CmjOtSnf.d.ts +454 -0
- package/dist/shared/unhead.CuATeS8P.d.ts +13 -0
- package/dist/shared/{unhead.DQc16pHI.mjs → unhead.CxhEb2IP.mjs} +1 -7
- package/dist/shared/unhead.CzbvM4Ih.d.mts +454 -0
- package/dist/shared/{unhead.BnoAbrHA.mjs → unhead.D2jdZ2BM.mjs} +6 -5
- package/dist/shared/unhead.DECeL1s3.d.mts +14 -0
- package/dist/shared/unhead.DvIxXxuO.mjs +14 -0
- package/dist/shared/{unhead.MXxTEjru.d.mts → unhead.OoU46jDW.d.mts} +5 -8
- package/dist/shared/{unhead.D1Xv45s3.d.mts → unhead.sufKyII-.d.mts} +2 -6
- package/dist/shared/unhead.zRLmrZrG.mjs +246 -0
- package/dist/stream/client.d.mts +22 -0
- package/dist/stream/client.d.ts +22 -0
- package/dist/stream/client.mjs +87 -0
- package/dist/stream/iife.d.mts +9 -0
- package/dist/stream/iife.d.ts +9 -0
- package/dist/stream/iife.global.js +1 -0
- package/dist/stream/iife.mjs +2 -0
- package/dist/stream/server.d.mts +164 -0
- package/dist/stream/server.d.ts +164 -0
- package/dist/stream/server.mjs +117 -0
- package/dist/stream/vite.d.mts +31 -0
- package/dist/stream/vite.d.ts +31 -0
- package/dist/stream/vite.mjs +70 -0
- package/dist/types.d.mts +7 -52
- package/dist/types.d.ts +7 -52
- package/dist/utils.d.mts +23 -6
- package/dist/utils.d.ts +23 -6
- package/dist/utils.mjs +5 -4
- package/package.json +66 -8
- package/dist/legacy.d.mts +0 -16
- package/dist/legacy.d.ts +0 -16
- package/dist/legacy.mjs +0 -47
- package/dist/shared/unhead.BPM0-cfG.mjs +0 -44
- package/dist/shared/unhead.CbpEuj3y.mjs +0 -71
- package/dist/shared/unhead.D_nrZZPH.mjs +0 -182
- package/dist/shared/unhead.ckV6dpEQ.mjs +0 -166
- package/dist/shared/unhead.fVVqDC1O.mjs +0 -203
- package/legacy.d.ts +0 -1
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ useHead({
|
|
|
54
54
|
### Server-Side Rendering
|
|
55
55
|
|
|
56
56
|
```ts
|
|
57
|
-
import { createHead
|
|
57
|
+
import { createHead } from 'unhead/server'
|
|
58
58
|
|
|
59
59
|
const head = createHead()
|
|
60
60
|
|
|
@@ -65,25 +65,38 @@ useHead({
|
|
|
65
65
|
}, { head })
|
|
66
66
|
|
|
67
67
|
// Render head tags
|
|
68
|
-
const { headTags, bodyTags } =
|
|
68
|
+
const { headTags, bodyTags } = head.render()
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
### Client-Side
|
|
71
|
+
### Client-Side Rendering
|
|
72
72
|
|
|
73
73
|
```ts
|
|
74
|
-
import { createHead
|
|
74
|
+
import { createHead } from 'unhead/client'
|
|
75
75
|
|
|
76
|
+
// Create head instance (auto-renders on changes)
|
|
76
77
|
const head = createHead()
|
|
77
78
|
|
|
78
|
-
// Enable DOM rendering
|
|
79
|
-
renderDOMHead(head)
|
|
80
|
-
|
|
81
79
|
// Add reactive head entries
|
|
82
80
|
useHead({
|
|
83
81
|
title: 'Client App'
|
|
84
82
|
}, { head })
|
|
85
83
|
```
|
|
86
84
|
|
|
85
|
+
### Custom Renderers
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { createServerRenderer, createUnhead } from 'unhead/server'
|
|
89
|
+
|
|
90
|
+
// Create a custom renderer with options
|
|
91
|
+
const renderer = createServerRenderer({ omitLineBreaks: true })
|
|
92
|
+
|
|
93
|
+
// Pass renderer to createUnhead
|
|
94
|
+
const head = createUnhead(renderer, { /* options */ })
|
|
95
|
+
|
|
96
|
+
// Render using head.render()
|
|
97
|
+
const html = head.render()
|
|
98
|
+
```
|
|
99
|
+
|
|
87
100
|
## Framework Integrations
|
|
88
101
|
|
|
89
102
|
Unhead provides optimized integrations for popular frameworks:
|
package/dist/client.d.mts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
export { C as ClientUnhead, c as createHead } from './shared/unhead.B9UFuLCK.mjs';
|
|
2
|
+
import { R as RenderDomHeadOptions } from './shared/unhead.DECeL1s3.mjs';
|
|
3
|
+
import { p as HeadRenderer, q as Unhead } from './shared/unhead.CzbvM4Ih.mjs';
|
|
4
|
+
export { n as CreateClientHeadOptions } from './shared/unhead.CzbvM4Ih.mjs';
|
|
2
5
|
import 'hookable';
|
|
6
|
+
import './shared/unhead.5ph757u1.mjs';
|
|
3
7
|
|
|
4
|
-
declare function
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Render the head tags to the DOM.
|
|
8
|
-
*/
|
|
9
|
-
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): Promise<void>;
|
|
8
|
+
declare function createDomRenderer(options?: RenderDomHeadOptions): HeadRenderer<boolean>;
|
|
10
9
|
|
|
11
10
|
declare function createDebouncedFn(callee: () => void, delayer: (fn: () => void) => void): () => void;
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
/** @deprecated Use `head.render()` instead */
|
|
13
|
+
declare function renderDOMHead(head: Unhead<any>, options?: RenderDomHeadOptions): boolean;
|
|
14
|
+
|
|
15
|
+
export { Unhead, createDebouncedFn, createDomRenderer, renderDOMHead };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
export { C as ClientUnhead, c as createHead } from './shared/unhead.CuATeS8P.js';
|
|
2
|
+
import { R as RenderDomHeadOptions } from './shared/unhead.C-4k1ONY.js';
|
|
3
|
+
import { p as HeadRenderer, q as Unhead } from './shared/unhead.CmjOtSnf.js';
|
|
4
|
+
export { n as CreateClientHeadOptions } from './shared/unhead.CmjOtSnf.js';
|
|
2
5
|
import 'hookable';
|
|
6
|
+
import './shared/unhead.5ph757u1.js';
|
|
3
7
|
|
|
4
|
-
declare function
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Render the head tags to the DOM.
|
|
8
|
-
*/
|
|
9
|
-
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): Promise<void>;
|
|
8
|
+
declare function createDomRenderer(options?: RenderDomHeadOptions): HeadRenderer<boolean>;
|
|
10
9
|
|
|
11
10
|
declare function createDebouncedFn(callee: () => void, delayer: (fn: () => void) => void): () => void;
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
/** @deprecated Use `head.render()` instead */
|
|
13
|
+
declare function renderDOMHead(head: Unhead<any>, options?: RenderDomHeadOptions): boolean;
|
|
14
|
+
|
|
15
|
+
export { Unhead, createDebouncedFn, createDomRenderer, renderDOMHead };
|
package/dist/client.mjs
CHANGED
|
@@ -1,210 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { c as createDomRenderer, r as renderDOMHead$1 } from './shared/unhead.CdKxe2-O.mjs';
|
|
2
|
+
import { c as createUnhead, r as registerPlugin } from './shared/unhead.Bkfgmqxw.mjs';
|
|
3
|
+
import { c as createHooks } from './shared/unhead.DvIxXxuO.mjs';
|
|
4
|
+
import './shared/unhead.C2yODEXq.mjs';
|
|
5
|
+
import './shared/unhead.zRLmrZrG.mjs';
|
|
4
6
|
import 'hookable';
|
|
5
|
-
import './shared/unhead.CbpEuj3y.mjs';
|
|
6
|
-
|
|
7
|
-
async function renderDOMHead(head, options = {}) {
|
|
8
|
-
const dom = options.document || head.resolvedOptions.document;
|
|
9
|
-
if (!dom || !head.dirty)
|
|
10
|
-
return;
|
|
11
|
-
const beforeRenderCtx = { shouldRender: true, tags: [] };
|
|
12
|
-
await head.hooks.callHook("dom:beforeRender", beforeRenderCtx);
|
|
13
|
-
if (!beforeRenderCtx.shouldRender)
|
|
14
|
-
return;
|
|
15
|
-
if (head._domUpdatePromise) {
|
|
16
|
-
return head._domUpdatePromise;
|
|
17
|
-
}
|
|
18
|
-
head._domUpdatePromise = new Promise(async (resolve) => {
|
|
19
|
-
const dupeKeyCounter = /* @__PURE__ */ new Map();
|
|
20
|
-
const resolveTagPromise = new Promise((resolve2) => {
|
|
21
|
-
head.resolveTags().then((tags2) => {
|
|
22
|
-
resolve2(
|
|
23
|
-
tags2.map((tag) => {
|
|
24
|
-
const count = dupeKeyCounter.get(tag._d) || 0;
|
|
25
|
-
const res = {
|
|
26
|
-
tag,
|
|
27
|
-
id: (count ? `${tag._d}:${count}` : tag._d) || tag._h,
|
|
28
|
-
shouldRender: true
|
|
29
|
-
};
|
|
30
|
-
if (tag._d && isMetaArrayDupeKey(tag._d)) {
|
|
31
|
-
dupeKeyCounter.set(tag._d, count + 1);
|
|
32
|
-
}
|
|
33
|
-
return res;
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
let state = head._dom;
|
|
39
|
-
if (!state) {
|
|
40
|
-
state = {
|
|
41
|
-
title: dom.title,
|
|
42
|
-
elMap: (/* @__PURE__ */ new Map()).set("htmlAttrs", dom.documentElement).set("bodyAttrs", dom.body)
|
|
43
|
-
};
|
|
44
|
-
for (const key of ["body", "head"]) {
|
|
45
|
-
const children = dom[key]?.children;
|
|
46
|
-
for (const c of children) {
|
|
47
|
-
const tag = c.tagName.toLowerCase();
|
|
48
|
-
if (!HasElementTags.has(tag)) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const next = normalizeProps({ tag, props: {} }, {
|
|
52
|
-
innerHTML: c.innerHTML,
|
|
53
|
-
...c.getAttributeNames().reduce((props, name) => {
|
|
54
|
-
props[name] = c.getAttribute(name);
|
|
55
|
-
return props;
|
|
56
|
-
}, {}) || {}
|
|
57
|
-
});
|
|
58
|
-
next.key = c.getAttribute("data-hid") || void 0;
|
|
59
|
-
next._d = dedupeKey(next) || hashTag(next);
|
|
60
|
-
if (state.elMap.has(next._d)) {
|
|
61
|
-
let count = 1;
|
|
62
|
-
let k = next._d;
|
|
63
|
-
while (state.elMap.has(k)) {
|
|
64
|
-
k = `${next._d}:${count++}`;
|
|
65
|
-
}
|
|
66
|
-
state.elMap.set(k, c);
|
|
67
|
-
} else {
|
|
68
|
-
state.elMap.set(next._d, c);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
state.pendingSideEffects = { ...state.sideEffects };
|
|
74
|
-
state.sideEffects = {};
|
|
75
|
-
function track(id, scope, fn) {
|
|
76
|
-
const k = `${id}:${scope}`;
|
|
77
|
-
state.sideEffects[k] = fn;
|
|
78
|
-
delete state.pendingSideEffects[k];
|
|
79
|
-
}
|
|
80
|
-
function trackCtx({ id, $el, tag }) {
|
|
81
|
-
const isAttrTag = tag.tag.endsWith("Attrs");
|
|
82
|
-
state.elMap.set(id, $el);
|
|
83
|
-
if (!isAttrTag) {
|
|
84
|
-
if (tag.textContent && tag.textContent !== $el.textContent) {
|
|
85
|
-
$el.textContent = tag.textContent;
|
|
86
|
-
}
|
|
87
|
-
if (tag.innerHTML && tag.innerHTML !== $el.innerHTML) {
|
|
88
|
-
$el.innerHTML = tag.innerHTML;
|
|
89
|
-
}
|
|
90
|
-
track(id, "el", () => {
|
|
91
|
-
$el?.remove();
|
|
92
|
-
state.elMap.delete(id);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
for (const k in tag.props) {
|
|
96
|
-
if (!Object.prototype.hasOwnProperty.call(tag.props, k))
|
|
97
|
-
continue;
|
|
98
|
-
const value = tag.props[k];
|
|
99
|
-
if (k.startsWith("on") && typeof value === "function") {
|
|
100
|
-
const dataset = $el?.dataset;
|
|
101
|
-
if (dataset && dataset[`${k}fired`]) {
|
|
102
|
-
const ek = k.slice(0, -5);
|
|
103
|
-
value.call($el, new Event(ek.substring(2)));
|
|
104
|
-
}
|
|
105
|
-
if ($el.getAttribute(`data-${k}`) !== "") {
|
|
106
|
-
(tag.tag === "bodyAttrs" ? dom.defaultView : $el).addEventListener(
|
|
107
|
-
// onload -> load
|
|
108
|
-
k.substring(2),
|
|
109
|
-
value.bind($el)
|
|
110
|
-
);
|
|
111
|
-
$el.setAttribute(`data-${k}`, "");
|
|
112
|
-
}
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const ck = `attr:${k}`;
|
|
116
|
-
if (k === "class") {
|
|
117
|
-
if (!value) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
for (const c of value) {
|
|
121
|
-
isAttrTag && track(id, `${ck}:${c}`, () => $el.classList.remove(c));
|
|
122
|
-
!$el.classList.contains(c) && $el.classList.add(c);
|
|
123
|
-
}
|
|
124
|
-
} else if (k === "style") {
|
|
125
|
-
if (!value) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
for (const [k2, v] of value) {
|
|
129
|
-
track(id, `${ck}:${k2}`, () => {
|
|
130
|
-
$el.style.removeProperty(k2);
|
|
131
|
-
});
|
|
132
|
-
$el.style.setProperty(k2, v);
|
|
133
|
-
}
|
|
134
|
-
} else if (value !== false && value !== null) {
|
|
135
|
-
$el.getAttribute(k) !== value && $el.setAttribute(k, value === true ? "" : String(value));
|
|
136
|
-
isAttrTag && track(id, ck, () => $el.removeAttribute(k));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const pending = [];
|
|
141
|
-
const frag = {
|
|
142
|
-
bodyClose: void 0,
|
|
143
|
-
bodyOpen: void 0,
|
|
144
|
-
head: void 0
|
|
145
|
-
};
|
|
146
|
-
const tags = await resolveTagPromise;
|
|
147
|
-
for (const ctx of tags) {
|
|
148
|
-
const { tag, shouldRender, id } = ctx;
|
|
149
|
-
if (!shouldRender)
|
|
150
|
-
continue;
|
|
151
|
-
if (tag.tag === "title") {
|
|
152
|
-
dom.title = tag.textContent;
|
|
153
|
-
track("title", "", () => dom.title = state.title);
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
ctx.$el = ctx.$el || state.elMap.get(id);
|
|
157
|
-
if (ctx.$el) {
|
|
158
|
-
trackCtx(ctx);
|
|
159
|
-
} else if (HasElementTags.has(tag.tag)) {
|
|
160
|
-
pending.push(ctx);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
for (const ctx of pending) {
|
|
164
|
-
const pos = ctx.tag.tagPosition || "head";
|
|
165
|
-
ctx.$el = dom.createElement(ctx.tag.tag);
|
|
166
|
-
trackCtx(ctx);
|
|
167
|
-
frag[pos] = frag[pos] || dom.createDocumentFragment();
|
|
168
|
-
frag[pos].appendChild(ctx.$el);
|
|
169
|
-
}
|
|
170
|
-
for (const ctx of tags)
|
|
171
|
-
await head.hooks.callHook("dom:renderTag", ctx, dom, track);
|
|
172
|
-
frag.head && dom.head.appendChild(frag.head);
|
|
173
|
-
frag.bodyOpen && dom.body.insertBefore(frag.bodyOpen, dom.body.firstChild);
|
|
174
|
-
frag.bodyClose && dom.body.appendChild(frag.bodyClose);
|
|
175
|
-
for (const k in state.pendingSideEffects) {
|
|
176
|
-
state.pendingSideEffects[k]();
|
|
177
|
-
}
|
|
178
|
-
head._dom = state;
|
|
179
|
-
await head.hooks.callHook("dom:rendered", { renders: tags });
|
|
180
|
-
resolve();
|
|
181
|
-
}).finally(() => {
|
|
182
|
-
head._domUpdatePromise = void 0;
|
|
183
|
-
head.dirty = false;
|
|
184
|
-
});
|
|
185
|
-
return head._domUpdatePromise;
|
|
186
|
-
}
|
|
187
7
|
|
|
8
|
+
const P = { critical: -8, high: -1, low: 2 };
|
|
9
|
+
const tagWeight = (tag) => typeof tag.tagPriority === "number" ? tag.tagPriority : 100 + (P[tag.tagPriority] || 0);
|
|
188
10
|
function createHead(options = {}) {
|
|
189
|
-
const render = options.domOptions?.render || renderDOMHead;
|
|
190
11
|
options.document = options.document || (typeof window !== "undefined" ? document : void 0);
|
|
12
|
+
const renderer = options.render || createDomRenderer({ document: options.document });
|
|
191
13
|
const initialPayload = options.document?.head.querySelector('script[id="unhead:payload"]')?.innerHTML || false;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
14
|
+
const core = createUnhead(renderer, { document: options.document, propResolvers: options.propResolvers, _tagWeight: tagWeight, init: [] });
|
|
15
|
+
const hooks = createHooks(options.hooks);
|
|
16
|
+
let dirty = false;
|
|
17
|
+
const head = {
|
|
18
|
+
...core,
|
|
19
|
+
ssr: false,
|
|
20
|
+
hooks,
|
|
21
|
+
use: (p) => registerPlugin(head, p),
|
|
22
|
+
get dirty() {
|
|
23
|
+
return dirty;
|
|
24
|
+
},
|
|
25
|
+
set dirty(v) {
|
|
26
|
+
dirty = v;
|
|
27
|
+
},
|
|
28
|
+
render: () => renderer(head),
|
|
29
|
+
invalidate() {
|
|
30
|
+
for (const e of core.entries.values()) delete e._tags;
|
|
31
|
+
dirty = true;
|
|
32
|
+
hooks.callHook("entries:updated", head);
|
|
33
|
+
},
|
|
34
|
+
push(input, _options) {
|
|
35
|
+
const active = core.push(input, _options);
|
|
36
|
+
core.entries.get(active._i)._o = input;
|
|
37
|
+
dirty = true;
|
|
38
|
+
hooks.callHook("entries:updated", head);
|
|
39
|
+
return {
|
|
40
|
+
_i: active._i,
|
|
41
|
+
patch(input2) {
|
|
42
|
+
active.patch(input2);
|
|
43
|
+
dirty = true;
|
|
44
|
+
hooks.callHook("entries:updated", head);
|
|
45
|
+
},
|
|
46
|
+
dispose() {
|
|
47
|
+
if (core.entries.has(active._i)) {
|
|
48
|
+
active.dispose();
|
|
49
|
+
head.invalidate();
|
|
50
|
+
}
|
|
200
51
|
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
hooks.hook("entries:updated", () => {
|
|
56
|
+
renderer(head);
|
|
207
57
|
});
|
|
58
|
+
options.plugins?.forEach((p) => registerPlugin(head, p));
|
|
59
|
+
initialPayload && head.push(JSON.parse(initialPayload));
|
|
60
|
+
options.init?.forEach((e) => e && head.push(e));
|
|
61
|
+
return head;
|
|
208
62
|
}
|
|
209
63
|
|
|
210
64
|
function createDebouncedFn(callee, delayer) {
|
|
@@ -219,4 +73,8 @@ function createDebouncedFn(callee, delayer) {
|
|
|
219
73
|
};
|
|
220
74
|
}
|
|
221
75
|
|
|
222
|
-
|
|
76
|
+
function renderDOMHead(head, options) {
|
|
77
|
+
return renderDOMHead$1(head, options);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { createDebouncedFn, createDomRenderer, createHead, renderDOMHead };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
import { H as HeadSafe } from './shared/unhead.
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { H as HeadSafe } from './shared/unhead.OoU46jDW.mjs';
|
|
2
|
+
import { aj as ResolvableHead, am as UseSeoMetaInput } from './shared/unhead.5ph757u1.mjs';
|
|
3
|
+
import { q as Unhead, o as HeadEntryOptions, k as ActiveHeadEntry, p as HeadRenderer, C as CreateHeadOptions } from './shared/unhead.CzbvM4Ih.mjs';
|
|
4
|
+
export { u as useScript } from './shared/unhead.sufKyII-.mjs';
|
|
4
5
|
import 'hookable';
|
|
5
6
|
|
|
6
7
|
declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
|
|
7
8
|
declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
|
8
9
|
declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
|
11
|
-
*/
|
|
12
|
-
declare function useServerHead<T extends Unhead<any>>(unhead: T, input?: Parameters<T['push']>[0], options?: Omit<HeadEntryOptions, 'mode'>): ReturnType<T['push']>;
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
|
15
|
-
*/
|
|
16
|
-
declare function useServerHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<HeadSafe>;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
|
19
|
-
*/
|
|
20
|
-
declare function useServerSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<UseSeoMetaInput>;
|
|
21
10
|
|
|
22
|
-
|
|
23
|
-
* @deprecated use `createUnhead` instead
|
|
24
|
-
*/
|
|
25
|
-
declare function createHeadCore<T = ResolvableHead>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
28
|
-
* and does not register DOM plugins.
|
|
29
|
-
*/
|
|
30
|
-
declare function createUnhead<T = ResolvableHead>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
|
11
|
+
declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
|
|
31
12
|
|
|
32
|
-
export {
|
|
13
|
+
export { createUnhead, useHead, useHeadSafe, useSeoMeta };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
import { H as HeadSafe } from './shared/unhead.
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { H as HeadSafe } from './shared/unhead.BqsuEzgR.js';
|
|
2
|
+
import { aj as ResolvableHead, am as UseSeoMetaInput } from './shared/unhead.5ph757u1.js';
|
|
3
|
+
import { q as Unhead, o as HeadEntryOptions, k as ActiveHeadEntry, p as HeadRenderer, C as CreateHeadOptions } from './shared/unhead.CmjOtSnf.js';
|
|
4
|
+
export { u as useScript } from './shared/unhead.Cfuv4vVm.js';
|
|
4
5
|
import 'hookable';
|
|
5
6
|
|
|
6
7
|
declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
|
|
7
8
|
declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
|
8
9
|
declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
|
11
|
-
*/
|
|
12
|
-
declare function useServerHead<T extends Unhead<any>>(unhead: T, input?: Parameters<T['push']>[0], options?: Omit<HeadEntryOptions, 'mode'>): ReturnType<T['push']>;
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
|
15
|
-
*/
|
|
16
|
-
declare function useServerHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<HeadSafe>;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
|
|
19
|
-
*/
|
|
20
|
-
declare function useServerSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<UseSeoMetaInput>;
|
|
21
10
|
|
|
22
|
-
|
|
23
|
-
* @deprecated use `createUnhead` instead
|
|
24
|
-
*/
|
|
25
|
-
declare function createHeadCore<T = ResolvableHead>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
28
|
-
* and does not register DOM plugins.
|
|
29
|
-
*/
|
|
30
|
-
declare function createUnhead<T = ResolvableHead>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
|
11
|
+
declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
|
|
31
12
|
|
|
32
|
-
export {
|
|
13
|
+
export { createUnhead, useHead, useHeadSafe, useSeoMeta };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
export { c as
|
|
3
|
-
export { u as useScript } from './shared/unhead.
|
|
4
|
-
import './shared/unhead.
|
|
5
|
-
import './shared/unhead.
|
|
6
|
-
import './shared/unhead.
|
|
1
|
+
import { S as SafeInputPlugin, F as FlatMetaPlugin } from './shared/unhead.2y8V0W4A.mjs';
|
|
2
|
+
export { c as createUnhead } from './shared/unhead.Bkfgmqxw.mjs';
|
|
3
|
+
export { u as useScript } from './shared/unhead.D2jdZ2BM.mjs';
|
|
4
|
+
import './shared/unhead.CxhEb2IP.mjs';
|
|
5
|
+
import './shared/unhead.C2yODEXq.mjs';
|
|
6
|
+
import './shared/unhead.DvIxXxuO.mjs';
|
|
7
7
|
import 'hookable';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
function useHead(unhead, input, options = {}) {
|
|
10
|
+
return unhead.push(input || {}, options);
|
|
11
|
+
}
|
|
12
|
+
function useHeadSafe(unhead, input = {}, options = {}) {
|
|
13
|
+
unhead.use(SafeInputPlugin);
|
|
14
|
+
return useHead(unhead, input, Object.assign(options, { _safe: true }));
|
|
15
|
+
}
|
|
16
|
+
function useSeoMeta(unhead, input = {}, options) {
|
|
17
|
+
unhead.use(FlatMetaPlugin);
|
|
18
|
+
function normalize(input2) {
|
|
19
|
+
if (input2._flatMeta) {
|
|
20
|
+
return input2;
|
|
21
|
+
}
|
|
22
|
+
const { title, titleTemplate, ...meta } = input2 || {};
|
|
23
|
+
return {
|
|
24
|
+
title,
|
|
25
|
+
titleTemplate,
|
|
26
|
+
_flatMeta: meta
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const entry = unhead.push(normalize(input), options);
|
|
30
|
+
const corePatch = entry.patch;
|
|
31
|
+
if (!entry.__patched) {
|
|
32
|
+
entry.patch = (input2) => corePatch(normalize(input2));
|
|
33
|
+
entry.__patched = true;
|
|
34
|
+
}
|
|
35
|
+
return entry;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { useHead, useHeadSafe, useSeoMeta };
|
package/dist/parser.d.mts
CHANGED
package/dist/parser.d.ts
CHANGED
package/dist/plugins.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as HeadPluginInput, q as Unhead, h as HeadPluginOptions } from './shared/unhead.CzbvM4Ih.mjs';
|
|
2
2
|
import 'hookable';
|
|
3
|
+
import './shared/unhead.5ph757u1.mjs';
|
|
3
4
|
|
|
4
5
|
declare const AliasSortingPlugin: HeadPluginInput;
|
|
5
6
|
|
|
@@ -30,8 +31,6 @@ declare function CanonicalPlugin(options: CanonicalPluginOptions): ((head: Unhea
|
|
|
30
31
|
|
|
31
32
|
declare function defineHeadPlugin(plugin: HeadPluginInput): HeadPluginInput;
|
|
32
33
|
|
|
33
|
-
declare const DeprecationsPlugin: HeadPluginInput;
|
|
34
|
-
|
|
35
34
|
declare const FlatMetaPlugin: HeadPluginInput;
|
|
36
35
|
|
|
37
36
|
interface InferSeoMetaPluginOptions {
|
|
@@ -62,4 +61,4 @@ declare const SafeInputPlugin: HeadPluginInput;
|
|
|
62
61
|
|
|
63
62
|
declare const TemplateParamsPlugin: HeadPluginInput;
|
|
64
63
|
|
|
65
|
-
export { AliasSortingPlugin, CanonicalPlugin,
|
|
64
|
+
export { AliasSortingPlugin, CanonicalPlugin, FlatMetaPlugin, InferSeoMetaPlugin, PromisesPlugin, SafeInputPlugin, TemplateParamsPlugin, defineHeadPlugin };
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as HeadPluginInput, q as Unhead, h as HeadPluginOptions } from './shared/unhead.CmjOtSnf.js';
|
|
2
2
|
import 'hookable';
|
|
3
|
+
import './shared/unhead.5ph757u1.js';
|
|
3
4
|
|
|
4
5
|
declare const AliasSortingPlugin: HeadPluginInput;
|
|
5
6
|
|
|
@@ -30,8 +31,6 @@ declare function CanonicalPlugin(options: CanonicalPluginOptions): ((head: Unhea
|
|
|
30
31
|
|
|
31
32
|
declare function defineHeadPlugin(plugin: HeadPluginInput): HeadPluginInput;
|
|
32
33
|
|
|
33
|
-
declare const DeprecationsPlugin: HeadPluginInput;
|
|
34
|
-
|
|
35
34
|
declare const FlatMetaPlugin: HeadPluginInput;
|
|
36
35
|
|
|
37
36
|
interface InferSeoMetaPluginOptions {
|
|
@@ -62,4 +61,4 @@ declare const SafeInputPlugin: HeadPluginInput;
|
|
|
62
61
|
|
|
63
62
|
declare const TemplateParamsPlugin: HeadPluginInput;
|
|
64
63
|
|
|
65
|
-
export { AliasSortingPlugin, CanonicalPlugin,
|
|
64
|
+
export { AliasSortingPlugin, CanonicalPlugin, FlatMetaPlugin, InferSeoMetaPlugin, PromisesPlugin, SafeInputPlugin, TemplateParamsPlugin, defineHeadPlugin };
|