unhead 3.1.6 → 3.1.7
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/dist/client.d.mts +5 -6
- package/dist/client.d.ts +5 -6
- package/dist/client.mjs +7 -12
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +15 -10
- package/dist/legacy.d.mts +2 -2
- package/dist/legacy.d.ts +2 -2
- package/dist/legacy.mjs +9 -9
- package/dist/parser.mjs +11 -7
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.mjs +7 -7
- package/dist/scripts.d.mts +3 -3
- package/dist/scripts.d.ts +3 -3
- package/dist/scripts.mjs +2 -3
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.mjs +5 -5
- package/dist/shared/{unhead.fg-0ge_u.mjs → unhead.1eoQpFT1.mjs} +6 -1
- package/dist/shared/{unhead.CRVUlr67.d.mts → unhead.BIArU35P.d.mts} +1 -1
- package/dist/shared/{unhead.BSqa2bYq.mjs → unhead.BNhb5t7_.mjs} +4 -6
- package/dist/shared/{unhead.BeIvDlYY.d.mts → unhead.BZy3nXHx.d.mts} +1 -1
- package/dist/shared/{unhead.DvIxXxuO.mjs → unhead.Bm4Y6XQI.mjs} +3 -0
- package/dist/shared/{unhead.B37CPNIq.d.mts → unhead.Bx2bAQEg.d.mts} +1 -1
- package/dist/shared/{unhead.D-W0R71w.mjs → unhead.C-RMAxyM.mjs} +27 -38
- package/dist/shared/{unhead.CS8tFxG3.d.mts → unhead.CELAVVhh.d.mts} +3 -5
- package/dist/shared/unhead.CHEy9ana.mjs +7 -0
- package/dist/shared/{unhead.BhvKU-Uu.d.ts → unhead.CN7FHaDF.d.ts} +1 -1
- package/dist/shared/{unhead.H5gLMTHA.mjs → unhead.CR32jx68.mjs} +125 -35
- package/dist/shared/{unhead.CBkhoTGw.mjs → unhead.CT1xoGPh.mjs} +1 -1
- package/dist/shared/unhead.CaGVnLUe.mjs +231 -0
- package/dist/shared/{unhead.YBmQyFpm.d.ts → unhead.Cnhe7n9-.d.ts} +1 -1
- package/dist/shared/{unhead.Blkhu0Cr.d.ts → unhead.DQadHCLi.d.ts} +1 -1
- package/dist/shared/{unhead.CBj56GgY.d.ts → unhead.Dv-MkoX9.d.ts} +3 -5
- package/dist/shared/{unhead.CfgPMHXt.mjs → unhead.WK9wg_ep.mjs} +2 -0
- package/dist/shared/{unhead.Doc2Fa-a.mjs → unhead.YIW3bMYK.mjs} +64 -33
- package/dist/shared/{unhead.BZYKjYpn.mjs → unhead.b15Kg1OH.mjs} +3 -3
- package/dist/shared/{unhead.J7mPNB3E.mjs → unhead.tpXvlPwt.mjs} +53 -34
- package/dist/shared/{unhead.BWKj-eGY.d.ts → unhead.xa1ebPBp.d.ts} +1 -1
- package/dist/shared/{unhead.BO2PdEL4.d.mts → unhead.zyZmXwAG.d.mts} +1 -1
- package/dist/stream/client.d.mts +2 -2
- package/dist/stream/client.d.ts +2 -2
- package/dist/stream/client.mjs +3 -8
- package/dist/stream/iife.d.cts +2 -0
- package/dist/stream/iife.global.js +1 -1
- package/dist/stream/iife.mjs +2 -2
- package/dist/stream/server.d.mts +2 -2
- package/dist/stream/server.d.ts +2 -2
- package/dist/stream/server.mjs +5 -5
- package/dist/stream/unplugin.d.mts +3 -1
- package/dist/stream/unplugin.d.ts +3 -1
- package/dist/stream/unplugin.mjs +28 -6
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.mjs +4 -4
- package/package.json +2 -2
- package/dist/shared/unhead.CT3gGqve.mjs +0 -154
- package/dist/shared/unhead.CUXLLRtV.mjs +0 -5
package/dist/client.d.mts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
export { C as ClientUnhead, c as createHead } from './shared/unhead.
|
|
1
|
+
export { C as ClientUnhead, c as createHead } from './shared/unhead.BIArU35P.mjs';
|
|
2
2
|
import { R as RenderDomHeadOptions } from './shared/unhead.GpD0t1jW.mjs';
|
|
3
|
-
import { b as HeadRenderer, U as Unhead } from './shared/unhead.
|
|
4
|
-
export { C as CreateClientHeadOptions } from './shared/unhead.
|
|
3
|
+
import { b as HeadRenderer, U as Unhead } from './shared/unhead.CELAVVhh.mjs';
|
|
4
|
+
export { C as CreateClientHeadOptions } from './shared/unhead.CELAVVhh.mjs';
|
|
5
5
|
import 'hookable';
|
|
6
6
|
import './shared/unhead.Dl7UHSN0.mjs';
|
|
7
7
|
|
|
8
8
|
declare function createDomRenderer(options?: RenderDomHeadOptions): HeadRenderer<boolean>;
|
|
9
|
+
/** @deprecated Use `head.render()` instead */
|
|
10
|
+
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): boolean;
|
|
9
11
|
|
|
10
12
|
declare function createDebouncedFn(callee: () => void, delayer: (fn: () => void) => void): () => void;
|
|
11
13
|
|
|
12
|
-
/** @deprecated Use `head.render()` instead */
|
|
13
|
-
declare function renderDOMHead(head: Unhead<any>, options?: RenderDomHeadOptions): boolean;
|
|
14
|
-
|
|
15
14
|
export { Unhead, createDebouncedFn, createDomRenderer, renderDOMHead };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
export { C as ClientUnhead, c as createHead } from './shared/unhead.
|
|
1
|
+
export { C as ClientUnhead, c as createHead } from './shared/unhead.xa1ebPBp.js';
|
|
2
2
|
import { R as RenderDomHeadOptions } from './shared/unhead.DEgm41PJ.js';
|
|
3
|
-
import { b as HeadRenderer, U as Unhead } from './shared/unhead.
|
|
4
|
-
export { C as CreateClientHeadOptions } from './shared/unhead.
|
|
3
|
+
import { b as HeadRenderer, U as Unhead } from './shared/unhead.Dv-MkoX9.js';
|
|
4
|
+
export { C as CreateClientHeadOptions } from './shared/unhead.Dv-MkoX9.js';
|
|
5
5
|
import 'hookable';
|
|
6
6
|
import './shared/unhead.Dl7UHSN0.js';
|
|
7
7
|
|
|
8
8
|
declare function createDomRenderer(options?: RenderDomHeadOptions): HeadRenderer<boolean>;
|
|
9
|
+
/** @deprecated Use `head.render()` instead */
|
|
10
|
+
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): boolean;
|
|
9
11
|
|
|
10
12
|
declare function createDebouncedFn(callee: () => void, delayer: (fn: () => void) => void): () => void;
|
|
11
13
|
|
|
12
|
-
/** @deprecated Use `head.render()` instead */
|
|
13
|
-
declare function renderDOMHead(head: Unhead<any>, options?: RenderDomHeadOptions): boolean;
|
|
14
|
-
|
|
15
14
|
export { Unhead, createDebouncedFn, createDomRenderer, renderDOMHead };
|
package/dist/client.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export { c as createDomRenderer } from './shared/unhead.
|
|
3
|
-
|
|
4
|
-
import './shared/unhead.
|
|
5
|
-
import './shared/unhead.
|
|
6
|
-
import './shared/unhead.DvIxXxuO.mjs';
|
|
1
|
+
export { c as createHead } from './shared/unhead.BNhb5t7_.mjs';
|
|
2
|
+
export { c as createDomRenderer, r as renderDOMHead } from './shared/unhead.CaGVnLUe.mjs';
|
|
3
|
+
import './shared/unhead.WK9wg_ep.mjs';
|
|
4
|
+
import './shared/unhead.1eoQpFT1.mjs';
|
|
5
|
+
import './shared/unhead.Bm4Y6XQI.mjs';
|
|
7
6
|
import 'hookable';
|
|
8
|
-
import './shared/unhead.
|
|
7
|
+
import './shared/unhead.CR32jx68.mjs';
|
|
9
8
|
|
|
10
9
|
function createDebouncedFn(callee, delayer) {
|
|
11
10
|
let ctxId = 0;
|
|
@@ -19,8 +18,4 @@ function createDebouncedFn(callee, delayer) {
|
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
return renderDOMHead$1(head, options);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { createDebouncedFn, renderDOMHead };
|
|
21
|
+
export { createDebouncedFn };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { U as Unhead, n as HeadEntryOptions, A as ActiveHeadEntry } from './shared/unhead.
|
|
1
|
+
import { U as Unhead, n as HeadEntryOptions, A as ActiveHeadEntry } from './shared/unhead.CELAVVhh.mjs';
|
|
2
2
|
import { H as HeadSafe } from './shared/unhead.CpKzP6LT.mjs';
|
|
3
3
|
import { R as ResolvableHead, b5 as UseSeoMetaInput, M as InferLink, Z as Link, N as InferScript, aM as Script } from './shared/unhead.Dl7UHSN0.mjs';
|
|
4
|
-
export { c as createUnhead } from './shared/unhead.
|
|
5
|
-
export { u as useScript } from './shared/unhead.
|
|
4
|
+
export { c as createUnhead } from './shared/unhead.BZy3nXHx.mjs';
|
|
5
|
+
export { u as useScript } from './shared/unhead.zyZmXwAG.mjs';
|
|
6
6
|
import 'hookable';
|
|
7
7
|
|
|
8
8
|
declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { U as Unhead, n as HeadEntryOptions, A as ActiveHeadEntry } from './shared/unhead.
|
|
1
|
+
import { U as Unhead, n as HeadEntryOptions, A as ActiveHeadEntry } from './shared/unhead.Dv-MkoX9.js';
|
|
2
2
|
import { H as HeadSafe } from './shared/unhead.Dqn7v3Di.js';
|
|
3
3
|
import { R as ResolvableHead, b5 as UseSeoMetaInput, M as InferLink, Z as Link, N as InferScript, aM as Script } from './shared/unhead.Dl7UHSN0.js';
|
|
4
|
-
export { c as createUnhead } from './shared/unhead.
|
|
5
|
-
export { u as useScript } from './shared/unhead.
|
|
4
|
+
export { c as createUnhead } from './shared/unhead.CN7FHaDF.js';
|
|
5
|
+
export { u as useScript } from './shared/unhead.Cnhe7n9-.js';
|
|
6
6
|
import 'hookable';
|
|
7
7
|
|
|
8
8
|
declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { S as SafeInputPlugin, F as FlatMetaPlugin } from './shared/unhead.
|
|
2
|
-
export { c as createUnhead } from './shared/unhead.
|
|
3
|
-
export { u as useScript } from './shared/unhead.
|
|
4
|
-
import './shared/unhead.
|
|
5
|
-
import './shared/unhead.
|
|
6
|
-
import './shared/unhead.
|
|
7
|
-
import './shared/unhead.
|
|
1
|
+
import { S as SafeInputPlugin, F as FlatMetaPlugin } from './shared/unhead.YIW3bMYK.mjs';
|
|
2
|
+
export { c as createUnhead } from './shared/unhead.WK9wg_ep.mjs';
|
|
3
|
+
export { u as useScript } from './shared/unhead.tpXvlPwt.mjs';
|
|
4
|
+
import './shared/unhead.CT1xoGPh.mjs';
|
|
5
|
+
import './shared/unhead.1eoQpFT1.mjs';
|
|
6
|
+
import './shared/unhead.CHEy9ana.mjs';
|
|
7
|
+
import './shared/unhead.Bm4Y6XQI.mjs';
|
|
8
8
|
import 'hookable';
|
|
9
9
|
|
|
10
10
|
function useHead(unhead, input, options = {}) {
|
|
@@ -20,10 +20,15 @@ function useSeoMeta(unhead, input = {}, options) {
|
|
|
20
20
|
if (input2._flatMeta) {
|
|
21
21
|
return input2;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const meta = {};
|
|
24
|
+
for (const key in input2) {
|
|
25
|
+
if (!Object.hasOwn(input2, key) || key === "title" || key === "titleTemplate")
|
|
26
|
+
continue;
|
|
27
|
+
meta[key] = input2[key];
|
|
28
|
+
}
|
|
24
29
|
return {
|
|
25
|
-
title,
|
|
26
|
-
titleTemplate,
|
|
30
|
+
title: input2.title,
|
|
31
|
+
titleTemplate: input2.titleTemplate,
|
|
27
32
|
_flatMeta: meta
|
|
28
33
|
};
|
|
29
34
|
}
|
package/dist/legacy.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createUnhead } from './shared/unhead.
|
|
2
|
-
import { H as HeadPluginInput, U as Unhead, C as CreateClientHeadOptions, a as CreateServerHeadOptions } from './shared/unhead.
|
|
1
|
+
import { c as createUnhead } from './shared/unhead.BZy3nXHx.mjs';
|
|
2
|
+
import { H as HeadPluginInput, U as Unhead, C as CreateClientHeadOptions, a as CreateServerHeadOptions } from './shared/unhead.CELAVVhh.mjs';
|
|
3
3
|
import { R as ResolvableHead } from './shared/unhead.Dl7UHSN0.mjs';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
package/dist/legacy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createUnhead } from './shared/unhead.
|
|
2
|
-
import { H as HeadPluginInput, U as Unhead, C as CreateClientHeadOptions, a as CreateServerHeadOptions } from './shared/unhead.
|
|
1
|
+
import { c as createUnhead } from './shared/unhead.CN7FHaDF.js';
|
|
2
|
+
import { H as HeadPluginInput, U as Unhead, C as CreateClientHeadOptions, a as CreateServerHeadOptions } from './shared/unhead.Dv-MkoX9.js';
|
|
3
3
|
import { R as ResolvableHead } from './shared/unhead.Dl7UHSN0.js';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
package/dist/legacy.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.
|
|
2
|
-
import { d as defineHeadPlugin } from './shared/unhead.
|
|
3
|
-
import { c as createUnhead } from './shared/unhead.
|
|
4
|
-
import { c as createHead$1 } from './shared/unhead.
|
|
5
|
-
import { c as createHead$2 } from './shared/unhead.
|
|
1
|
+
import { P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.b15Kg1OH.mjs';
|
|
2
|
+
import { d as defineHeadPlugin } from './shared/unhead.CHEy9ana.mjs';
|
|
3
|
+
import { c as createUnhead } from './shared/unhead.WK9wg_ep.mjs';
|
|
4
|
+
import { c as createHead$1 } from './shared/unhead.BNhb5t7_.mjs';
|
|
5
|
+
import { c as createHead$2 } from './shared/unhead.C-RMAxyM.mjs';
|
|
6
6
|
import './shared/unhead.BGFxPGPQ.mjs';
|
|
7
|
-
import './shared/unhead.
|
|
8
|
-
import './shared/unhead.
|
|
7
|
+
import './shared/unhead.1eoQpFT1.mjs';
|
|
8
|
+
import './shared/unhead.Bm4Y6XQI.mjs';
|
|
9
9
|
import 'hookable';
|
|
10
|
-
import './shared/unhead.
|
|
11
|
-
import './shared/unhead.
|
|
10
|
+
import './shared/unhead.CaGVnLUe.mjs';
|
|
11
|
+
import './shared/unhead.CR32jx68.mjs';
|
|
12
12
|
|
|
13
13
|
const DeprecationsPlugin = /* @__PURE__ */ defineHeadPlugin({
|
|
14
14
|
key: "deprecations",
|
package/dist/parser.mjs
CHANGED
|
@@ -27,6 +27,7 @@ const TagIdMap = {
|
|
|
27
27
|
link: TAG_LINK,
|
|
28
28
|
base: TAG_BASE
|
|
29
29
|
};
|
|
30
|
+
const HEAD_ELEMENTS_TO_EXTRACT = /* @__PURE__ */ new Set([TAG_TITLE, TAG_META, TAG_LINK, TAG_SCRIPT, TAG_STYLE, TAG_BASE]);
|
|
30
31
|
function isWhitespace(charCode) {
|
|
31
32
|
return charCode === 32 || charCode === 9 || charCode === 10 || charCode === 13;
|
|
32
33
|
}
|
|
@@ -75,6 +76,10 @@ function parseAttributes(attrStr) {
|
|
|
75
76
|
if (!attrStr)
|
|
76
77
|
return {};
|
|
77
78
|
const result = {};
|
|
79
|
+
const setAttr = (attrName, value) => {
|
|
80
|
+
if (!Object.hasOwn(result, attrName))
|
|
81
|
+
result[attrName] = value;
|
|
82
|
+
};
|
|
78
83
|
const len = attrStr.length;
|
|
79
84
|
let i = 0;
|
|
80
85
|
const WHITESPACE = 0;
|
|
@@ -111,7 +116,7 @@ function parseAttributes(attrStr) {
|
|
|
111
116
|
if (charCode === EQUALS_CHAR) {
|
|
112
117
|
state = BEFORE_VALUE;
|
|
113
118
|
} else if (!isSpace) {
|
|
114
|
-
|
|
119
|
+
setAttr(name, "");
|
|
115
120
|
state = NAME;
|
|
116
121
|
nameStart = i;
|
|
117
122
|
nameEnd = 0;
|
|
@@ -129,13 +134,13 @@ function parseAttributes(attrStr) {
|
|
|
129
134
|
break;
|
|
130
135
|
case QUOTED_VALUE:
|
|
131
136
|
if (charCode === quoteChar) {
|
|
132
|
-
|
|
137
|
+
setAttr(name, attrStr.substring(valueStart, i));
|
|
133
138
|
state = WHITESPACE;
|
|
134
139
|
}
|
|
135
140
|
break;
|
|
136
141
|
case UNQUOTED_VALUE:
|
|
137
142
|
if (isSpace || charCode === GT_CHAR) {
|
|
138
|
-
|
|
143
|
+
setAttr(name, attrStr.substring(valueStart, i));
|
|
139
144
|
state = WHITESPACE;
|
|
140
145
|
}
|
|
141
146
|
break;
|
|
@@ -144,13 +149,13 @@ function parseAttributes(attrStr) {
|
|
|
144
149
|
}
|
|
145
150
|
if (state === QUOTED_VALUE || state === UNQUOTED_VALUE) {
|
|
146
151
|
if (name) {
|
|
147
|
-
|
|
152
|
+
setAttr(name, attrStr.substring(valueStart, i));
|
|
148
153
|
}
|
|
149
154
|
} else if (state === NAME || state === AFTER_NAME || state === BEFORE_VALUE) {
|
|
150
155
|
nameEnd = nameEnd || i;
|
|
151
156
|
const currentName = attrStr.substring(nameStart, nameEnd).toLowerCase();
|
|
152
157
|
if (currentName) {
|
|
153
|
-
|
|
158
|
+
setAttr(currentName, "");
|
|
154
159
|
}
|
|
155
160
|
}
|
|
156
161
|
return result;
|
|
@@ -194,7 +199,6 @@ function parseHtmlForUnheadExtraction(html) {
|
|
|
194
199
|
bodyTagEnd: -1,
|
|
195
200
|
bodyCloseTagStart: -1
|
|
196
201
|
};
|
|
197
|
-
const headElementsToExtract = /* @__PURE__ */ new Set([TAG_TITLE, TAG_META, TAG_LINK, TAG_SCRIPT, TAG_STYLE, TAG_BASE]);
|
|
198
202
|
function copyAccumulatedText() {
|
|
199
203
|
if (lastCopyPosition < position) {
|
|
200
204
|
const textToAdd = html.substring(lastCopyPosition, position);
|
|
@@ -336,7 +340,7 @@ function parseHtmlForUnheadExtraction(html) {
|
|
|
336
340
|
inHead = true;
|
|
337
341
|
copyAccumulatedText();
|
|
338
342
|
addText(html.substring(position, tagEnd));
|
|
339
|
-
} else if (inHead &&
|
|
343
|
+
} else if (inHead && HEAD_ELEMENTS_TO_EXTRACT.has(tagId)) {
|
|
340
344
|
if (tagId === TAG_TITLE) {
|
|
341
345
|
if (!isSelfClosing) {
|
|
342
346
|
const titleEnd = findClosingTag(html, tagEnd, tagName);
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HeadPluginInput, U as Unhead, q as HeadPluginOptions } from './shared/unhead.
|
|
1
|
+
import { H as HeadPluginInput, U as Unhead, q as HeadPluginOptions } from './shared/unhead.CELAVVhh.mjs';
|
|
2
2
|
import { V as ValidationRuleId, R as RulesConfig } from './shared/unhead.Dl_lRDXb.mjs';
|
|
3
3
|
export { a as RuleConfig, b as RuleSeverity, c as ValidationRuleOptions } from './shared/unhead.Dl_lRDXb.mjs';
|
|
4
4
|
import { v as HeadTag } from './shared/unhead.Dl7UHSN0.mjs';
|
|
@@ -49,7 +49,7 @@ declare function CanonicalPlugin(options: CanonicalPluginOptions): ((head: Unhea
|
|
|
49
49
|
key: string;
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
declare function defineHeadPlugin(plugin: HeadPluginInput): HeadPluginInput;
|
|
52
|
+
declare function defineHeadPlugin(plugin: HeadPluginInput, key?: string): HeadPluginInput;
|
|
53
53
|
|
|
54
54
|
declare const FlatMetaPlugin: HeadPluginInput;
|
|
55
55
|
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HeadPluginInput, U as Unhead, q as HeadPluginOptions } from './shared/unhead.
|
|
1
|
+
import { H as HeadPluginInput, U as Unhead, q as HeadPluginOptions } from './shared/unhead.Dv-MkoX9.js';
|
|
2
2
|
import { V as ValidationRuleId, R as RulesConfig } from './shared/unhead.Dl_lRDXb.js';
|
|
3
3
|
export { a as RuleConfig, b as RuleSeverity, c as ValidationRuleOptions } from './shared/unhead.Dl_lRDXb.js';
|
|
4
4
|
import { v as HeadTag } from './shared/unhead.Dl7UHSN0.js';
|
|
@@ -49,7 +49,7 @@ declare function CanonicalPlugin(options: CanonicalPluginOptions): ((head: Unhea
|
|
|
49
49
|
key: string;
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
declare function defineHeadPlugin(plugin: HeadPluginInput): HeadPluginInput;
|
|
52
|
+
declare function defineHeadPlugin(plugin: HeadPluginInput, key?: string): HeadPluginInput;
|
|
53
53
|
|
|
54
54
|
declare const FlatMetaPlugin: HeadPluginInput;
|
|
55
55
|
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { A as AliasSortingPlugin, P as PromisesPlugin, T as TemplateParamsPlugin } from './shared/unhead.
|
|
2
|
-
import { d as defineHeadPlugin } from './shared/unhead.
|
|
3
|
-
export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.
|
|
1
|
+
export { A as AliasSortingPlugin, P as PromisesPlugin, T as TemplateParamsPlugin } from './shared/unhead.b15Kg1OH.mjs';
|
|
2
|
+
import { d as defineHeadPlugin } from './shared/unhead.CHEy9ana.mjs';
|
|
3
|
+
export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.YIW3bMYK.mjs';
|
|
4
4
|
import { minifyJS, minifyCSS, minifyJSON } from './minify.mjs';
|
|
5
5
|
import { t as tagInputFromRuntime, o as tagPredicates, U as URL_META_KEYS, q as titleInputFromRuntime, h as headInputPredicates } from './shared/unhead.WR8XDfSi.mjs';
|
|
6
6
|
import './shared/unhead.BGFxPGPQ.mjs';
|
|
7
|
-
import './shared/unhead.
|
|
8
|
-
import './shared/unhead.
|
|
7
|
+
import './shared/unhead.CT1xoGPh.mjs';
|
|
8
|
+
import './shared/unhead.1eoQpFT1.mjs';
|
|
9
9
|
|
|
10
10
|
const META_TRANSFORMABLE_URL = [
|
|
11
11
|
"og:url",
|
|
@@ -157,7 +157,7 @@ function InferSeoMetaPlugin(options = {}) {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
|
-
});
|
|
160
|
+
}, "infer-seo-meta");
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
const JSON_TYPES = /* @__PURE__ */ new Set(["application/json", "application/ld+json"]);
|
|
@@ -543,7 +543,7 @@ function ValidatePlugin(options = {}) {
|
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
545
|
};
|
|
546
|
-
});
|
|
546
|
+
}, "validate");
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
export { CanonicalPlugin, InferSeoMetaPlugin, MinifyPlugin, ValidatePlugin, defineHeadPlugin };
|
package/dist/scripts.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as RecordingEntry } from './shared/unhead.
|
|
2
|
-
export { g as AsVoidFunctions, l as EventHandlerOptions, v as ScriptInstance, z as UseFunctionType, B as UseScriptContext, F as UseScriptInput, G as UseScriptOptions, I as UseScriptResolvedInput, J as UseScriptReturn, K as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.
|
|
3
|
-
export { u as useScript } from './shared/unhead.
|
|
1
|
+
import { R as RecordingEntry } from './shared/unhead.CELAVVhh.mjs';
|
|
2
|
+
export { g as AsVoidFunctions, l as EventHandlerOptions, v as ScriptInstance, z as UseFunctionType, B as UseScriptContext, F as UseScriptInput, G as UseScriptOptions, I as UseScriptResolvedInput, J as UseScriptReturn, K as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.CELAVVhh.mjs';
|
|
3
|
+
export { u as useScript } from './shared/unhead.zyZmXwAG.mjs';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
import './shared/unhead.Dl7UHSN0.mjs';
|
|
6
6
|
|
package/dist/scripts.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as RecordingEntry } from './shared/unhead.
|
|
2
|
-
export { g as AsVoidFunctions, l as EventHandlerOptions, v as ScriptInstance, z as UseFunctionType, B as UseScriptContext, F as UseScriptInput, G as UseScriptOptions, I as UseScriptResolvedInput, J as UseScriptReturn, K as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.
|
|
3
|
-
export { u as useScript } from './shared/unhead.
|
|
1
|
+
import { R as RecordingEntry } from './shared/unhead.Dv-MkoX9.js';
|
|
2
|
+
export { g as AsVoidFunctions, l as EventHandlerOptions, v as ScriptInstance, z as UseFunctionType, B as UseScriptContext, F as UseScriptInput, G as UseScriptOptions, I as UseScriptResolvedInput, J as UseScriptReturn, K as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.Dv-MkoX9.js';
|
|
3
|
+
export { u as useScript } from './shared/unhead.Cnhe7n9-.js';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
import './shared/unhead.Dl7UHSN0.js';
|
|
6
6
|
|
package/dist/scripts.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { u as useScript } from './shared/unhead.
|
|
2
|
-
import './shared/unhead.
|
|
1
|
+
export { u as useScript } from './shared/unhead.tpXvlPwt.mjs';
|
|
2
|
+
import './shared/unhead.Bm4Y6XQI.mjs';
|
|
3
3
|
import 'hookable';
|
|
4
|
-
import './shared/unhead.fg-0ge_u.mjs';
|
|
5
4
|
|
|
6
5
|
function createSpyProxy(target, onApply) {
|
|
7
6
|
const stack = [];
|
package/dist/server.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { S as ServerUnhead, c as createHead } from './shared/unhead.
|
|
2
|
-
import { s as RenderSSRHeadOptions, b as HeadRenderer, S as SSRHeadPayload, U as Unhead } from './shared/unhead.
|
|
3
|
-
export { a as CreateServerHeadOptions } from './shared/unhead.
|
|
1
|
+
export { S as ServerUnhead, c as createHead } from './shared/unhead.Bx2bAQEg.mjs';
|
|
2
|
+
import { s as RenderSSRHeadOptions, b as HeadRenderer, S as SSRHeadPayload, U as Unhead } from './shared/unhead.CELAVVhh.mjs';
|
|
3
|
+
export { a as CreateServerHeadOptions } from './shared/unhead.CELAVVhh.mjs';
|
|
4
4
|
import { v as HeadTag } from './shared/unhead.Dl7UHSN0.mjs';
|
|
5
5
|
import 'hookable';
|
|
6
6
|
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { S as ServerUnhead, c as createHead } from './shared/unhead.
|
|
2
|
-
import { s as RenderSSRHeadOptions, b as HeadRenderer, S as SSRHeadPayload, U as Unhead } from './shared/unhead.
|
|
3
|
-
export { a as CreateServerHeadOptions } from './shared/unhead.
|
|
1
|
+
export { S as ServerUnhead, c as createHead } from './shared/unhead.DQadHCLi.js';
|
|
2
|
+
import { s as RenderSSRHeadOptions, b as HeadRenderer, S as SSRHeadPayload, U as Unhead } from './shared/unhead.Dv-MkoX9.js';
|
|
3
|
+
export { a as CreateServerHeadOptions } from './shared/unhead.Dv-MkoX9.js';
|
|
4
4
|
import { v as HeadTag } from './shared/unhead.Dl7UHSN0.js';
|
|
5
5
|
import 'hookable';
|
|
6
6
|
|
package/dist/server.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { a as capoTagWeight, c as createHead, b as createServerRenderer, e as escapeHtml, p as propsToString, r as renderSSRHead, s as ssrRenderTags, t as tagToString } from './shared/unhead.
|
|
1
|
+
export { a as capoTagWeight, c as createHead, b as createServerRenderer, e as escapeHtml, p as propsToString, r as renderSSRHead, s as ssrRenderTags, t as tagToString } from './shared/unhead.C-RMAxyM.mjs';
|
|
2
2
|
import { parseHtmlForUnheadExtraction, applyHeadToHtml, parseHtmlForIndexes } from './parser.mjs';
|
|
3
|
-
import './shared/unhead.
|
|
4
|
-
import './shared/unhead.
|
|
3
|
+
import './shared/unhead.WK9wg_ep.mjs';
|
|
4
|
+
import './shared/unhead.Bm4Y6XQI.mjs';
|
|
5
5
|
import 'hookable';
|
|
6
|
-
import './shared/unhead.
|
|
7
|
-
import './shared/unhead.
|
|
6
|
+
import './shared/unhead.CR32jx68.mjs';
|
|
7
|
+
import './shared/unhead.1eoQpFT1.mjs';
|
|
8
8
|
|
|
9
9
|
// @__NO_SIDE_EFFECTS__
|
|
10
10
|
function transformHtmlTemplate(head, html) {
|
|
@@ -19,4 +19,9 @@ const MetaTagsArrayable = /* @__PURE__ */ new Set([
|
|
|
19
19
|
]);
|
|
20
20
|
const TagPriorityAliases = { critical: -8, high: -1, low: 2 };
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// @__NO_SIDE_EFFECTS__
|
|
23
|
+
function isUnsafeKey(key) {
|
|
24
|
+
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { DupeableTags as D, HasElementTags as H, MetaTagsArrayable as M, ScriptNetworkEvents as S, TagConfigKeys as T, UniqueTags as U, ValidHeadTags as V, SelfClosingTags as a, TagPriorityAliases as b, TagsWithInnerContent as c, UsesMergeStrategy as d, isUnsafeKey as i };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HookableCore } from 'hookable';
|
|
2
2
|
import { R as ResolvableHead } from './unhead.Dl7UHSN0.mjs';
|
|
3
|
-
import { U as Unhead, d as ClientHeadHooks, C as CreateClientHeadOptions } from './unhead.
|
|
3
|
+
import { U as Unhead, d as ClientHeadHooks, C as CreateClientHeadOptions } from './unhead.CELAVVhh.mjs';
|
|
4
4
|
|
|
5
5
|
interface ClientUnhead<T = ResolvableHead> extends Unhead<T, boolean> {
|
|
6
6
|
hooks: HookableCore<ClientHeadHooks>;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { c as createUnhead, r as registerPlugin } from './unhead.
|
|
2
|
-
import { b as TagPriorityAliases } from './unhead.
|
|
3
|
-
import { c as createHooks } from './unhead.
|
|
4
|
-
import { c as createDomRenderer } from './unhead.
|
|
1
|
+
import { c as createUnhead, r as registerPlugin } from './unhead.WK9wg_ep.mjs';
|
|
2
|
+
import { b as TagPriorityAliases } from './unhead.1eoQpFT1.mjs';
|
|
3
|
+
import { c as createHooks } from './unhead.Bm4Y6XQI.mjs';
|
|
4
|
+
import { c as createDomRenderer } from './unhead.CaGVnLUe.mjs';
|
|
5
5
|
|
|
6
6
|
const tagWeight = (tag) => typeof tag.tagPriority === "number" ? tag.tagPriority : 100 + (TagPriorityAliases[tag.tagPriority] || 0);
|
|
7
7
|
function createHead(options = {}) {
|
|
8
8
|
options.document = options.document || (typeof window !== "undefined" ? document : void 0);
|
|
9
9
|
const renderer = options.render || createDomRenderer({ document: options.document });
|
|
10
|
-
const initialPayload = options.document?.head.querySelector('script[id="unhead:payload"]')?.innerHTML || false;
|
|
11
10
|
const core = createUnhead(renderer, { document: options.document, propResolvers: options.propResolvers, _tagWeight: tagWeight, init: [] });
|
|
12
11
|
const hooks = createHooks(options.hooks);
|
|
13
12
|
let dirty = false;
|
|
@@ -56,7 +55,6 @@ function createHead(options = {}) {
|
|
|
56
55
|
renderer(head);
|
|
57
56
|
});
|
|
58
57
|
options.plugins?.forEach((p) => registerPlugin(head, p));
|
|
59
|
-
initialPayload && head.push(JSON.parse(initialPayload));
|
|
60
58
|
options.init?.forEach((e) => e && head.push(e));
|
|
61
59
|
return head;
|
|
62
60
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as HeadRenderer, c as CreateHeadOptions, U as Unhead } from './unhead.
|
|
1
|
+
import { b as HeadRenderer, c as CreateHeadOptions, U as Unhead } from './unhead.CELAVVhh.mjs';
|
|
2
2
|
import { R as ResolvableHead } from './unhead.Dl7UHSN0.mjs';
|
|
3
3
|
|
|
4
4
|
declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HookableCore } from 'hookable';
|
|
2
|
-
import { U as Unhead, S as SSRHeadPayload, f as ServerHeadHooks, a as CreateServerHeadOptions } from './unhead.
|
|
2
|
+
import { U as Unhead, S as SSRHeadPayload, f as ServerHeadHooks, a as CreateServerHeadOptions } from './unhead.CELAVVhh.mjs';
|
|
3
3
|
import { R as ResolvableHead } from './unhead.Dl7UHSN0.mjs';
|
|
4
4
|
|
|
5
5
|
interface ServerUnhead<T = ResolvableHead> extends Unhead<T, SSRHeadPayload> {
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { c as createUnhead, r as registerPlugin } from './unhead.
|
|
2
|
-
import { a as callHook, c as createHooks } from './unhead.
|
|
3
|
-
import { r as resolveTags } from './unhead.
|
|
4
|
-
import { b as TagPriorityAliases,
|
|
1
|
+
import { c as createUnhead, r as registerPlugin } from './unhead.WK9wg_ep.mjs';
|
|
2
|
+
import { a as callHook, c as createHooks } from './unhead.Bm4Y6XQI.mjs';
|
|
3
|
+
import { I as INVALID_ATTR_NAME_RE, r as resolveTags } from './unhead.CR32jx68.mjs';
|
|
4
|
+
import { b as TagPriorityAliases, a as SelfClosingTags, c as TagsWithInnerContent } from './unhead.1eoQpFT1.mjs';
|
|
5
5
|
|
|
6
|
-
const TAG_WEIGHTS = { base: -10, title: 10 };
|
|
7
|
-
const LINK_WEIGHTS = { "preconnect": 20, "stylesheet": 60, "preload": 70, "modulepreload": 70, "prefetch": 90, "dns-prefetch": 90, "prerender": 90 };
|
|
8
|
-
const ImportStyleRe = /@import/;
|
|
9
6
|
const isTruthy = (v) => v === "" || v === true;
|
|
10
7
|
function capoTagWeight(tag) {
|
|
11
8
|
if (typeof tag.tagPriority === "number")
|
|
12
9
|
return tag.tagPriority;
|
|
13
10
|
let weight = 100;
|
|
14
11
|
const offset = TagPriorityAliases[tag.tagPriority] || 0;
|
|
15
|
-
if (tag.tag
|
|
16
|
-
weight =
|
|
12
|
+
if (tag.tag === "base") {
|
|
13
|
+
weight = -10;
|
|
14
|
+
} else if (tag.tag === "title") {
|
|
15
|
+
weight = 10;
|
|
17
16
|
} else if (tag.tag === "meta") {
|
|
18
17
|
weight = tag.props["http-equiv"] === "content-security-policy" ? -30 : tag.props.charset ? -20 : tag.props.name === "viewport" ? -15 : weight;
|
|
19
18
|
} else if (tag.tag === "link" && tag.props.rel) {
|
|
20
|
-
|
|
19
|
+
const rel = tag.props.rel;
|
|
20
|
+
weight = rel === "preconnect" ? 20 : rel === "stylesheet" ? 60 : rel === "preload" || rel === "modulepreload" ? 70 : rel === "prefetch" || rel === "dns-prefetch" || rel === "prerender" ? 90 : weight;
|
|
21
21
|
} else if (tag.tag === "script") {
|
|
22
|
-
const type =
|
|
22
|
+
const type = typeof tag.props.type === "string" ? tag.props.type : "";
|
|
23
23
|
const json = type.endsWith("json");
|
|
24
24
|
if (type === "importmap")
|
|
25
25
|
weight = 25;
|
|
@@ -32,7 +32,7 @@ function capoTagWeight(tag) {
|
|
|
32
32
|
else if (isTruthy(tag.props.defer) && tag.props.src || type === "module")
|
|
33
33
|
weight = 80;
|
|
34
34
|
} else if (tag.tag === "style") {
|
|
35
|
-
weight = tag.innerHTML &&
|
|
35
|
+
weight = tag.innerHTML && /@import/.test(tag.innerHTML) ? 40 : 60;
|
|
36
36
|
}
|
|
37
37
|
return (weight || 100) + offset;
|
|
38
38
|
}
|
|
@@ -45,11 +45,19 @@ function encodeAttribute(value) {
|
|
|
45
45
|
function propsToString(props) {
|
|
46
46
|
let attrs = "";
|
|
47
47
|
for (const key in props) {
|
|
48
|
-
if (!Object.hasOwn(props, key))
|
|
48
|
+
if (!Object.hasOwn(props, key) || !key || INVALID_ATTR_NAME_RE.test(key))
|
|
49
49
|
continue;
|
|
50
50
|
let value = props[key];
|
|
51
|
-
if (
|
|
52
|
-
|
|
51
|
+
if (typeof value !== "string") {
|
|
52
|
+
if (key === "class") {
|
|
53
|
+
let out = "";
|
|
54
|
+
for (const c of value) out += out ? ` ${c}` : c;
|
|
55
|
+
value = out;
|
|
56
|
+
} else if (key === "style") {
|
|
57
|
+
let out = "";
|
|
58
|
+
for (const [k, v] of value) out += out ? `;${k}:${v}` : `${k}:${v}`;
|
|
59
|
+
value = out;
|
|
60
|
+
}
|
|
53
61
|
}
|
|
54
62
|
if (value !== false && value !== null) {
|
|
55
63
|
attrs += value === true ? ` ${key}` : ` ${key}="${encodeAttribute(value)}"`;
|
|
@@ -67,11 +75,13 @@ function escapeHtml(str) {
|
|
|
67
75
|
function tagToString(tag) {
|
|
68
76
|
const attrs = propsToString(tag.props);
|
|
69
77
|
const openTag = `<${tag.tag}${attrs}>`;
|
|
78
|
+
if (SelfClosingTags.has(tag.tag))
|
|
79
|
+
return openTag;
|
|
70
80
|
if (!TagsWithInnerContent.has(tag.tag))
|
|
71
|
-
return
|
|
81
|
+
return `${openTag}</${tag.tag}>`;
|
|
72
82
|
let content = String(tag.textContent || tag.innerHTML || "");
|
|
73
83
|
content = tag.tag === "title" ? escapeHtml(content) : content.replace(CLOSE_TAG_RE[tag.tag] ||= new RegExp(`</${tag.tag}`, "gi"), `<\\/${tag.tag}`);
|
|
74
|
-
return
|
|
84
|
+
return `${openTag}${content}</${tag.tag}>`;
|
|
75
85
|
}
|
|
76
86
|
|
|
77
87
|
function ssrRenderTags(tags, options) {
|
|
@@ -162,27 +172,6 @@ function createHead(options = {}) {
|
|
|
162
172
|
use: (p) => registerPlugin(head, p)
|
|
163
173
|
};
|
|
164
174
|
options.plugins?.forEach((p) => registerPlugin(head, p));
|
|
165
|
-
head._ssrPayload = {};
|
|
166
|
-
const payloadHook = (ctx) => {
|
|
167
|
-
let payload = {};
|
|
168
|
-
if (Object.keys(head._ssrPayload || {}).length > 0) {
|
|
169
|
-
payload = { ...head._ssrPayload };
|
|
170
|
-
}
|
|
171
|
-
if (Object.values(payload).some(Boolean)) {
|
|
172
|
-
ctx.tags.push({
|
|
173
|
-
tag: "script",
|
|
174
|
-
innerHTML: JSON.stringify(payload),
|
|
175
|
-
props: { id: "unhead:payload", type: "application/json" }
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
payloadHook._nonMutating = true;
|
|
180
|
-
registerPlugin(head, {
|
|
181
|
-
key: "server",
|
|
182
|
-
hooks: {
|
|
183
|
-
"tags:resolve": payloadHook
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
175
|
return head;
|
|
187
176
|
}
|
|
188
177
|
|
|
@@ -263,8 +263,10 @@ interface HeadPluginOptions extends CreateHeadOptions {
|
|
|
263
263
|
}
|
|
264
264
|
type HeadPluginInput = (HeadPluginOptions & {
|
|
265
265
|
key: string;
|
|
266
|
-
}) | ((head: Unhead) => HeadPluginOptions & {
|
|
266
|
+
}) | (((head: Unhead) => HeadPluginOptions & {
|
|
267
267
|
key: string;
|
|
268
|
+
}) & {
|
|
269
|
+
key?: string;
|
|
268
270
|
});
|
|
269
271
|
type HeadPlugin = HeadPluginOptions & {
|
|
270
272
|
key: string;
|
|
@@ -484,10 +486,6 @@ interface Unhead<Input = ResolvableHead, RenderResult = unknown> {
|
|
|
484
486
|
* @internal
|
|
485
487
|
*/
|
|
486
488
|
_titleTemplate?: string;
|
|
487
|
-
/**
|
|
488
|
-
* @internal
|
|
489
|
-
*/
|
|
490
|
-
_ssrPayload?: ResolvableHead;
|
|
491
489
|
/**
|
|
492
490
|
* @internal
|
|
493
491
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as HeadRenderer, c as CreateHeadOptions, U as Unhead } from './unhead.
|
|
1
|
+
import { b as HeadRenderer, c as CreateHeadOptions, U as Unhead } from './unhead.Dv-MkoX9.js';
|
|
2
2
|
import { R as ResolvableHead } from './unhead.Dl7UHSN0.js';
|
|
3
3
|
|
|
4
4
|
declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
|