unhead 3.1.5 → 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.
Files changed (61) hide show
  1. package/dist/client.d.mts +5 -6
  2. package/dist/client.d.ts +5 -6
  3. package/dist/client.mjs +7 -12
  4. package/dist/index.d.mts +3 -3
  5. package/dist/index.d.ts +3 -3
  6. package/dist/index.mjs +15 -10
  7. package/dist/legacy.d.mts +2 -2
  8. package/dist/legacy.d.ts +2 -2
  9. package/dist/legacy.mjs +9 -9
  10. package/dist/parser.mjs +11 -7
  11. package/dist/plugins.d.mts +2 -2
  12. package/dist/plugins.d.ts +2 -2
  13. package/dist/plugins.mjs +7 -7
  14. package/dist/scripts.d.mts +3 -3
  15. package/dist/scripts.d.ts +3 -3
  16. package/dist/scripts.mjs +2 -3
  17. package/dist/server.d.mts +3 -3
  18. package/dist/server.d.ts +3 -3
  19. package/dist/server.mjs +5 -5
  20. package/dist/shared/{unhead.fg-0ge_u.mjs → unhead.1eoQpFT1.mjs} +6 -1
  21. package/dist/shared/{unhead.CRVUlr67.d.mts → unhead.BIArU35P.d.mts} +1 -1
  22. package/dist/shared/{unhead.BSqa2bYq.mjs → unhead.BNhb5t7_.mjs} +4 -6
  23. package/dist/shared/{unhead.BeIvDlYY.d.mts → unhead.BZy3nXHx.d.mts} +1 -1
  24. package/dist/shared/{unhead.DvIxXxuO.mjs → unhead.Bm4Y6XQI.mjs} +3 -0
  25. package/dist/shared/{unhead.B37CPNIq.d.mts → unhead.Bx2bAQEg.d.mts} +1 -1
  26. package/dist/shared/{unhead.D-W0R71w.mjs → unhead.C-RMAxyM.mjs} +27 -38
  27. package/dist/shared/{unhead.CS8tFxG3.d.mts → unhead.CELAVVhh.d.mts} +3 -5
  28. package/dist/shared/unhead.CHEy9ana.mjs +7 -0
  29. package/dist/shared/{unhead.BhvKU-Uu.d.ts → unhead.CN7FHaDF.d.ts} +1 -1
  30. package/dist/shared/{unhead.H5gLMTHA.mjs → unhead.CR32jx68.mjs} +125 -35
  31. package/dist/shared/{unhead.CBkhoTGw.mjs → unhead.CT1xoGPh.mjs} +1 -1
  32. package/dist/shared/unhead.CaGVnLUe.mjs +231 -0
  33. package/dist/shared/{unhead.YBmQyFpm.d.ts → unhead.Cnhe7n9-.d.ts} +1 -1
  34. package/dist/shared/{unhead.Blkhu0Cr.d.ts → unhead.DQadHCLi.d.ts} +1 -1
  35. package/dist/shared/{unhead.CBj56GgY.d.ts → unhead.Dv-MkoX9.d.ts} +3 -5
  36. package/dist/shared/{unhead.CfgPMHXt.mjs → unhead.WK9wg_ep.mjs} +2 -0
  37. package/dist/shared/{unhead.Doc2Fa-a.mjs → unhead.YIW3bMYK.mjs} +64 -33
  38. package/dist/shared/{unhead.BZYKjYpn.mjs → unhead.b15Kg1OH.mjs} +3 -3
  39. package/dist/shared/{unhead.J7mPNB3E.mjs → unhead.tpXvlPwt.mjs} +53 -34
  40. package/dist/shared/{unhead.BWKj-eGY.d.ts → unhead.xa1ebPBp.d.ts} +1 -1
  41. package/dist/shared/{unhead.BO2PdEL4.d.mts → unhead.zyZmXwAG.d.mts} +1 -1
  42. package/dist/stream/client.d.mts +2 -2
  43. package/dist/stream/client.d.ts +2 -2
  44. package/dist/stream/client.mjs +3 -8
  45. package/dist/stream/iife.d.cts +2 -0
  46. package/dist/stream/iife.global.js +1 -1
  47. package/dist/stream/iife.mjs +2 -2
  48. package/dist/stream/server.d.mts +2 -2
  49. package/dist/stream/server.d.ts +2 -2
  50. package/dist/stream/server.mjs +5 -5
  51. package/dist/stream/unplugin.d.mts +5 -1
  52. package/dist/stream/unplugin.d.ts +5 -1
  53. package/dist/stream/unplugin.mjs +29 -7
  54. package/dist/types.d.mts +2 -2
  55. package/dist/types.d.ts +2 -2
  56. package/dist/utils.d.mts +1 -1
  57. package/dist/utils.d.ts +1 -1
  58. package/dist/utils.mjs +4 -4
  59. package/package.json +3 -3
  60. package/dist/shared/unhead.CT3gGqve.mjs +0 -154
  61. 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.CRVUlr67.mjs';
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.CS8tFxG3.mjs';
4
- export { C as CreateClientHeadOptions } from './shared/unhead.CS8tFxG3.mjs';
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.BWKj-eGY.js';
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.CBj56GgY.js';
4
- export { C as CreateClientHeadOptions } from './shared/unhead.CBj56GgY.js';
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
- import { r as renderDOMHead$1 } from './shared/unhead.CT3gGqve.mjs';
2
- export { c as createDomRenderer } from './shared/unhead.CT3gGqve.mjs';
3
- export { c as createHead } from './shared/unhead.BSqa2bYq.mjs';
4
- import './shared/unhead.fg-0ge_u.mjs';
5
- import './shared/unhead.H5gLMTHA.mjs';
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.CfgPMHXt.mjs';
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
- function renderDOMHead(head, options) {
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.CS8tFxG3.mjs';
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.BeIvDlYY.mjs';
5
- export { u as useScript } from './shared/unhead.BO2PdEL4.mjs';
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.CBj56GgY.js';
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.BhvKU-Uu.js';
5
- export { u as useScript } from './shared/unhead.YBmQyFpm.js';
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.Doc2Fa-a.mjs';
2
- export { c as createUnhead } from './shared/unhead.CfgPMHXt.mjs';
3
- export { u as useScript } from './shared/unhead.J7mPNB3E.mjs';
4
- import './shared/unhead.CBkhoTGw.mjs';
5
- import './shared/unhead.fg-0ge_u.mjs';
6
- import './shared/unhead.CUXLLRtV.mjs';
7
- import './shared/unhead.DvIxXxuO.mjs';
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 { title, titleTemplate, ...meta } = input2 || {};
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.BeIvDlYY.mjs';
2
- import { H as HeadPluginInput, U as Unhead, C as CreateClientHeadOptions, a as CreateServerHeadOptions } from './shared/unhead.CS8tFxG3.mjs';
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.BhvKU-Uu.js';
2
- import { H as HeadPluginInput, U as Unhead, C as CreateClientHeadOptions, a as CreateServerHeadOptions } from './shared/unhead.CBj56GgY.js';
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.BZYKjYpn.mjs';
2
- import { d as defineHeadPlugin } from './shared/unhead.CUXLLRtV.mjs';
3
- import { c as createUnhead } from './shared/unhead.CfgPMHXt.mjs';
4
- import { c as createHead$1 } from './shared/unhead.BSqa2bYq.mjs';
5
- import { c as createHead$2 } from './shared/unhead.D-W0R71w.mjs';
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.fg-0ge_u.mjs';
8
- import './shared/unhead.DvIxXxuO.mjs';
7
+ import './shared/unhead.1eoQpFT1.mjs';
8
+ import './shared/unhead.Bm4Y6XQI.mjs';
9
9
  import 'hookable';
10
- import './shared/unhead.CT3gGqve.mjs';
11
- import './shared/unhead.H5gLMTHA.mjs';
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
- result[name] = "";
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
- result[name] = attrStr.substring(valueStart, i);
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
- result[name] = attrStr.substring(valueStart, i);
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
- result[name] = attrStr.substring(valueStart, i);
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
- result[currentName] = "";
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 && headElementsToExtract.has(tagId)) {
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);
@@ -1,4 +1,4 @@
1
- import { H as HeadPluginInput, U as Unhead, q as HeadPluginOptions } from './shared/unhead.CS8tFxG3.mjs';
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.CBj56GgY.js';
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.BZYKjYpn.mjs';
2
- import { d as defineHeadPlugin } from './shared/unhead.CUXLLRtV.mjs';
3
- export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.Doc2Fa-a.mjs';
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.CBkhoTGw.mjs';
8
- import './shared/unhead.fg-0ge_u.mjs';
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 };
@@ -1,6 +1,6 @@
1
- import { R as RecordingEntry } from './shared/unhead.CS8tFxG3.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.CS8tFxG3.mjs';
3
- export { u as useScript } from './shared/unhead.BO2PdEL4.mjs';
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.CBj56GgY.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.CBj56GgY.js';
3
- export { u as useScript } from './shared/unhead.YBmQyFpm.js';
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.J7mPNB3E.mjs';
2
- import './shared/unhead.DvIxXxuO.mjs';
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.B37CPNIq.mjs';
2
- import { s as RenderSSRHeadOptions, b as HeadRenderer, S as SSRHeadPayload, U as Unhead } from './shared/unhead.CS8tFxG3.mjs';
3
- export { a as CreateServerHeadOptions } from './shared/unhead.CS8tFxG3.mjs';
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.Blkhu0Cr.js';
2
- import { s as RenderSSRHeadOptions, b as HeadRenderer, S as SSRHeadPayload, U as Unhead } from './shared/unhead.CBj56GgY.js';
3
- export { a as CreateServerHeadOptions } from './shared/unhead.CBj56GgY.js';
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.D-W0R71w.mjs';
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.CfgPMHXt.mjs';
4
- import './shared/unhead.DvIxXxuO.mjs';
3
+ import './shared/unhead.WK9wg_ep.mjs';
4
+ import './shared/unhead.Bm4Y6XQI.mjs';
5
5
  import 'hookable';
6
- import './shared/unhead.H5gLMTHA.mjs';
7
- import './shared/unhead.fg-0ge_u.mjs';
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
- 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 };
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.CS8tFxG3.mjs';
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.CfgPMHXt.mjs';
2
- import { b as TagPriorityAliases } from './unhead.fg-0ge_u.mjs';
3
- import { c as createHooks } from './unhead.DvIxXxuO.mjs';
4
- import { c as createDomRenderer } from './unhead.CT3gGqve.mjs';
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.CS8tFxG3.mjs';
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>;
@@ -8,6 +8,9 @@ function createHooks(hooks) {
8
8
  return instance;
9
9
  }
10
10
  function callHook(head, hook, ctx) {
11
+ const hooks = head.hooks?._hooks?.[hook];
12
+ if (!hooks?.length)
13
+ return;
11
14
  return head.hooks?.callHook(hook, ctx);
12
15
  }
13
16
 
@@ -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.CS8tFxG3.mjs';
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.CfgPMHXt.mjs';
2
- import { a as callHook, c as createHooks } from './unhead.DvIxXxuO.mjs';
3
- import { r as resolveTags } from './unhead.H5gLMTHA.mjs';
4
- import { b as TagPriorityAliases, c as TagsWithInnerContent, a as SelfClosingTags } from './unhead.fg-0ge_u.mjs';
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 in TAG_WEIGHTS) {
16
- weight = TAG_WEIGHTS[tag.tag];
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
- weight = LINK_WEIGHTS[tag.props.rel];
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 = String(tag.props.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 && ImportStyleRe.test(tag.innerHTML) ? 40 : 60;
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 ((key === "class" || key === "style") && typeof value !== "string") {
52
- value = key === "class" ? [...value].join(" ") : Array.from(value, ([k, v]) => `${k}:${v}`).join(";");
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 SelfClosingTags.has(tag.tag) ? openTag : `${openTag}</${tag.tag}>`;
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 SelfClosingTags.has(tag.tag) ? openTag : `${openTag}${content}</${tag.tag}>`;
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
  */
@@ -0,0 +1,7 @@
1
+ function defineHeadPlugin(plugin, key) {
2
+ if (key && typeof plugin === "function")
3
+ plugin.key = key;
4
+ return plugin;
5
+ }
6
+
7
+ export { defineHeadPlugin as d };
@@ -1,4 +1,4 @@
1
- import { b as HeadRenderer, c as CreateHeadOptions, U as Unhead } from './unhead.CBj56GgY.js';
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>;