unhead 3.0.2 → 3.0.4

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 (47) hide show
  1. package/dist/client.d.mts +5 -5
  2. package/dist/client.d.ts +5 -5
  3. package/dist/client.mjs +6 -63
  4. package/dist/index.d.mts +6 -7
  5. package/dist/index.d.ts +6 -7
  6. package/dist/index.mjs +2 -1
  7. package/dist/legacy.d.mts +26 -0
  8. package/dist/legacy.d.ts +26 -0
  9. package/dist/legacy.mjs +63 -0
  10. package/dist/parser.d.mts +1 -1
  11. package/dist/parser.d.ts +1 -1
  12. package/dist/plugins.d.mts +2 -2
  13. package/dist/plugins.d.ts +2 -2
  14. package/dist/plugins.mjs +5 -129
  15. package/dist/scripts.d.mts +4 -4
  16. package/dist/scripts.d.ts +4 -4
  17. package/dist/server.d.mts +4 -4
  18. package/dist/server.d.ts +4 -4
  19. package/dist/shared/{unhead.D4KaR-FM.d.ts → unhead.9aHQrEvB.d.ts} +2 -2
  20. package/dist/shared/{unhead.D_bywjUE.mjs → unhead.A4ndrqqe.mjs} +2 -5
  21. package/dist/shared/{unhead.DJ6joC2O.d.mts → unhead.Bbk6Q9rK.d.mts} +2 -2
  22. package/dist/shared/{unhead.BJTN1X0i.d.mts → unhead.BcynQ3qJ.d.mts} +81 -20
  23. package/dist/shared/{unhead.BJTN1X0i.d.ts → unhead.BcynQ3qJ.d.ts} +81 -20
  24. package/dist/shared/{unhead.C6alnWbQ.d.mts → unhead.BfINO8Du.d.mts} +2 -2
  25. package/dist/shared/{unhead.BRWMyYIW.d.ts → unhead.BmdY3z1V.d.ts} +1 -1
  26. package/dist/shared/unhead.CGloe9Qc.d.mts +6 -0
  27. package/dist/shared/unhead.CH30252c.mjs +129 -0
  28. package/dist/shared/{unhead.CpT6Kxc0.d.ts → unhead.CHsGwxB0.d.ts} +2 -2
  29. package/dist/shared/unhead.CUXLLRtV.mjs +5 -0
  30. package/dist/shared/{unhead.BhElfVXO.d.ts → unhead.CvqH1vcy.d.ts} +1 -1
  31. package/dist/shared/{unhead.BXRLaj2l.d.mts → unhead.D91IvQ_J.d.mts} +1 -1
  32. package/dist/shared/unhead.DCXRrsx_.d.ts +6 -0
  33. package/dist/shared/{unhead.DH3TZMHc.d.ts → unhead.DoIxTwSF.d.ts} +1 -1
  34. package/dist/shared/{unhead.Dp1MlAYz.d.mts → unhead.DvqMLXpO.d.mts} +1 -1
  35. package/dist/shared/{unhead.CZPkBynw.d.mts → unhead.LatFr5s0.d.mts} +1 -1
  36. package/dist/shared/{unhead.YGcEMcjf.d.ts → unhead.Ogog_XUX.d.ts} +1 -1
  37. package/dist/shared/unhead.YnmwhfIN.mjs +64 -0
  38. package/dist/shared/{unhead.DsHmk_XC.d.mts → unhead.m4TuRTvV.d.mts} +1 -1
  39. package/dist/stream/client.d.mts +3 -3
  40. package/dist/stream/client.d.ts +3 -3
  41. package/dist/stream/server.d.mts +3 -3
  42. package/dist/stream/server.d.ts +3 -3
  43. package/dist/types.d.mts +6 -6
  44. package/dist/types.d.ts +6 -6
  45. package/dist/utils.d.mts +2 -2
  46. package/dist/utils.d.ts +2 -2
  47. package/package.json +8 -1
package/dist/client.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- export { C as ClientUnhead, c as createHead } from './shared/unhead.DJ6joC2O.mjs';
2
- import { R as RenderDomHeadOptions } from './shared/unhead.BXRLaj2l.mjs';
3
- import { p as HeadRenderer, U as Unhead } from './shared/unhead.DsHmk_XC.mjs';
4
- export { c as CreateClientHeadOptions } from './shared/unhead.DsHmk_XC.mjs';
1
+ export { C as ClientUnhead, c as createHead } from './shared/unhead.Bbk6Q9rK.mjs';
2
+ import { R as RenderDomHeadOptions } from './shared/unhead.D91IvQ_J.mjs';
3
+ import { p as HeadRenderer, U as Unhead } from './shared/unhead.m4TuRTvV.mjs';
4
+ export { c as CreateClientHeadOptions } from './shared/unhead.m4TuRTvV.mjs';
5
5
  import 'hookable';
6
- import './shared/unhead.BJTN1X0i.mjs';
6
+ import './shared/unhead.BcynQ3qJ.mjs';
7
7
 
8
8
  declare function createDomRenderer(options?: RenderDomHeadOptions): HeadRenderer<boolean>;
9
9
 
package/dist/client.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { C as ClientUnhead, c as createHead } from './shared/unhead.CpT6Kxc0.js';
2
- import { R as RenderDomHeadOptions } from './shared/unhead.YGcEMcjf.js';
3
- import { p as HeadRenderer, U as Unhead } from './shared/unhead.BRWMyYIW.js';
4
- export { c as CreateClientHeadOptions } from './shared/unhead.BRWMyYIW.js';
1
+ export { C as ClientUnhead, c as createHead } from './shared/unhead.CHsGwxB0.js';
2
+ import { R as RenderDomHeadOptions } from './shared/unhead.Ogog_XUX.js';
3
+ import { p as HeadRenderer, U as Unhead } from './shared/unhead.BmdY3z1V.js';
4
+ export { c as CreateClientHeadOptions } from './shared/unhead.BmdY3z1V.js';
5
5
  import 'hookable';
6
- import './shared/unhead.BJTN1X0i.js';
6
+ import './shared/unhead.BcynQ3qJ.js';
7
7
 
8
8
  declare function createDomRenderer(options?: RenderDomHeadOptions): HeadRenderer<boolean>;
9
9
 
package/dist/client.mjs CHANGED
@@ -1,68 +1,11 @@
1
- import { c as createDomRenderer, r as renderDOMHead$1 } from './shared/unhead.pv34ME7O.mjs';
2
- import { c as createUnhead, r as registerPlugin } from './shared/unhead.CfgPMHXt.mjs';
3
- import { c as createHooks } from './shared/unhead.DvIxXxuO.mjs';
1
+ import { r as renderDOMHead$1 } from './shared/unhead.pv34ME7O.mjs';
2
+ export { c as createDomRenderer } from './shared/unhead.pv34ME7O.mjs';
3
+ export { c as createHead } from './shared/unhead.YnmwhfIN.mjs';
4
4
  import './shared/unhead.fg-0ge_u.mjs';
5
5
  import './shared/unhead.DiRbsb3I.mjs';
6
+ import './shared/unhead.DvIxXxuO.mjs';
6
7
  import 'hookable';
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);
10
- function createHead(options = {}) {
11
- options.document = options.document || (typeof window !== "undefined" ? document : void 0);
12
- const renderer = options.render || createDomRenderer({ document: options.document });
13
- const initialPayload = options.document?.head.querySelector('script[id="unhead:payload"]')?.innerHTML || false;
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 onRendered = _options?.onRendered;
36
- const unhook = onRendered ? hooks.hook("dom:rendered", onRendered) : void 0;
37
- const active = core.push(input, _options);
38
- core.entries.get(active._i)._o = input;
39
- dirty = true;
40
- hooks.callHook("entries:updated", head);
41
- return {
42
- _i: active._i,
43
- patch(input2) {
44
- active.patch(input2);
45
- dirty = true;
46
- hooks.callHook("entries:updated", head);
47
- },
48
- dispose() {
49
- unhook?.();
50
- if (core.entries.has(active._i)) {
51
- active.dispose();
52
- head.invalidate();
53
- }
54
- }
55
- };
56
- }
57
- };
58
- hooks.hook("entries:updated", () => {
59
- renderer(head);
60
- });
61
- options.plugins?.forEach((p) => registerPlugin(head, p));
62
- initialPayload && head.push(JSON.parse(initialPayload));
63
- options.init?.forEach((e) => e && head.push(e));
64
- return head;
65
- }
8
+ import './shared/unhead.CfgPMHXt.mjs';
66
9
 
67
10
  function createDebouncedFn(callee, delayer) {
68
11
  let ctxId = 0;
@@ -80,4 +23,4 @@ function renderDOMHead(head, options) {
80
23
  return renderDOMHead$1(head, options);
81
24
  }
82
25
 
83
- export { createDebouncedFn, createDomRenderer, createHead, renderDOMHead };
26
+ export { createDebouncedFn, renderDOMHead };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
- import { U as Unhead, k as HeadEntryOptions, A as ActiveHeadEntry, p as HeadRenderer, d as CreateHeadOptions } from './shared/unhead.DsHmk_XC.mjs';
2
- import { at as ResolvableHead, b1 as UseSeoMetaInput, J as InferLink, U as Link, K as InferScript, aI as Script } from './shared/unhead.BJTN1X0i.mjs';
3
- import { H as HeadSafe } from './shared/unhead.CZPkBynw.mjs';
4
- export { u as useScript } from './shared/unhead.Dp1MlAYz.mjs';
1
+ import { U as Unhead, k as HeadEntryOptions, A as ActiveHeadEntry } from './shared/unhead.m4TuRTvV.mjs';
2
+ import { at as ResolvableHead, b1 as UseSeoMetaInput, J as InferLink, U as Link, K as InferScript, aI as Script } from './shared/unhead.BcynQ3qJ.mjs';
3
+ import { H as HeadSafe } from './shared/unhead.LatFr5s0.mjs';
4
+ export { c as createUnhead } from './shared/unhead.CGloe9Qc.mjs';
5
+ export { u as useScript } from './shared/unhead.DvqMLXpO.mjs';
5
6
  import 'hookable';
6
7
 
7
8
  declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
@@ -57,6 +58,4 @@ declare function defineLink<const T extends {
57
58
  */
58
59
  declare function defineScript<const T extends object>(script: T & InferScript<T>): Script;
59
60
 
60
- declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
61
-
62
- export { createUnhead, defineLink, defineScript, useHead, useHeadSafe, useSeoMeta };
61
+ export { defineLink, defineScript, useHead, useHeadSafe, useSeoMeta };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { U as Unhead, k as HeadEntryOptions, A as ActiveHeadEntry, p as HeadRenderer, d as CreateHeadOptions } from './shared/unhead.BRWMyYIW.js';
2
- import { at as ResolvableHead, b1 as UseSeoMetaInput, J as InferLink, U as Link, K as InferScript, aI as Script } from './shared/unhead.BJTN1X0i.js';
3
- import { H as HeadSafe } from './shared/unhead.BhElfVXO.js';
4
- export { u as useScript } from './shared/unhead.DH3TZMHc.js';
1
+ import { U as Unhead, k as HeadEntryOptions, A as ActiveHeadEntry } from './shared/unhead.BmdY3z1V.js';
2
+ import { at as ResolvableHead, b1 as UseSeoMetaInput, J as InferLink, U as Link, K as InferScript, aI as Script } from './shared/unhead.BcynQ3qJ.js';
3
+ import { H as HeadSafe } from './shared/unhead.CvqH1vcy.js';
4
+ export { c as createUnhead } from './shared/unhead.DCXRrsx_.js';
5
+ export { u as useScript } from './shared/unhead.DoIxTwSF.js';
5
6
  import 'hookable';
6
7
 
7
8
  declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
@@ -57,6 +58,4 @@ declare function defineLink<const T extends {
57
58
  */
58
59
  declare function defineScript<const T extends object>(script: T & InferScript<T>): Script;
59
60
 
60
- declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
61
-
62
- export { createUnhead, defineLink, defineScript, useHead, useHeadSafe, useSeoMeta };
61
+ export { defineLink, defineScript, useHead, useHeadSafe, useSeoMeta };
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
- import { S as SafeInputPlugin, F as FlatMetaPlugin } from './shared/unhead.D_bywjUE.mjs';
1
+ import { S as SafeInputPlugin, F as FlatMetaPlugin } from './shared/unhead.A4ndrqqe.mjs';
2
2
  export { c as createUnhead } from './shared/unhead.CfgPMHXt.mjs';
3
3
  export { u as useScript } from './shared/unhead.DctB-0lW.mjs';
4
4
  import './shared/unhead.JWUDzlIs.mjs';
5
5
  import './shared/unhead.fg-0ge_u.mjs';
6
+ import './shared/unhead.CUXLLRtV.mjs';
6
7
  import './shared/unhead.DvIxXxuO.mjs';
7
8
  import 'hookable';
8
9
 
@@ -0,0 +1,26 @@
1
+ import { c as createUnhead } from './shared/unhead.CGloe9Qc.mjs';
2
+ import { n as HeadPluginInput, U as Unhead, c as CreateClientHeadOptions, e as CreateServerHeadOptions } from './shared/unhead.m4TuRTvV.mjs';
3
+ import { at as ResolvableHead } from './shared/unhead.BcynQ3qJ.mjs';
4
+ import 'hookable';
5
+
6
+ /**
7
+ * Maps unhead v1/v2 tag props (`children`, `hid`, `vmid`, `body`, `renderPriority`) to their
8
+ * v3 equivalents (`innerHTML`, `key`, `tagPosition`, `tagPriority`).
9
+ *
10
+ * Intended as a temporary migration aid. Remove once all call sites use the v3 API.
11
+ */
12
+ declare const DeprecationsPlugin: HeadPluginInput;
13
+ /**
14
+ * The full v2 migration plugin set applied by the legacy `createHead`/`createServerHead`.
15
+ * Export so users with a custom `createHead` can opt into one-line v2 compatibility.
16
+ */
17
+ declare const legacyPlugins: HeadPluginInput[];
18
+ declare const activeHead: {
19
+ value: Unhead<any> | null;
20
+ };
21
+ declare function getActiveHead<T extends Record<string, any> = ResolvableHead>(): Unhead<T> | null;
22
+ declare function createHead<T extends Record<string, any> = ResolvableHead>(options?: CreateClientHeadOptions): Unhead<T>;
23
+ declare function createServerHead<T extends Record<string, any> = ResolvableHead>(options?: Omit<CreateServerHeadOptions, 'propResolvers'>): Unhead<T>;
24
+ declare const createHeadCore: typeof createUnhead;
25
+
26
+ export { DeprecationsPlugin, activeHead, createHead, createHeadCore, createServerHead, getActiveHead, legacyPlugins };
@@ -0,0 +1,26 @@
1
+ import { c as createUnhead } from './shared/unhead.DCXRrsx_.js';
2
+ import { n as HeadPluginInput, U as Unhead, c as CreateClientHeadOptions, e as CreateServerHeadOptions } from './shared/unhead.BmdY3z1V.js';
3
+ import { at as ResolvableHead } from './shared/unhead.BcynQ3qJ.js';
4
+ import 'hookable';
5
+
6
+ /**
7
+ * Maps unhead v1/v2 tag props (`children`, `hid`, `vmid`, `body`, `renderPriority`) to their
8
+ * v3 equivalents (`innerHTML`, `key`, `tagPosition`, `tagPriority`).
9
+ *
10
+ * Intended as a temporary migration aid. Remove once all call sites use the v3 API.
11
+ */
12
+ declare const DeprecationsPlugin: HeadPluginInput;
13
+ /**
14
+ * The full v2 migration plugin set applied by the legacy `createHead`/`createServerHead`.
15
+ * Export so users with a custom `createHead` can opt into one-line v2 compatibility.
16
+ */
17
+ declare const legacyPlugins: HeadPluginInput[];
18
+ declare const activeHead: {
19
+ value: Unhead<any> | null;
20
+ };
21
+ declare function getActiveHead<T extends Record<string, any> = ResolvableHead>(): Unhead<T> | null;
22
+ declare function createHead<T extends Record<string, any> = ResolvableHead>(options?: CreateClientHeadOptions): Unhead<T>;
23
+ declare function createServerHead<T extends Record<string, any> = ResolvableHead>(options?: Omit<CreateServerHeadOptions, 'propResolvers'>): Unhead<T>;
24
+ declare const createHeadCore: typeof createUnhead;
25
+
26
+ export { DeprecationsPlugin, activeHead, createHead, createHeadCore, createServerHead, getActiveHead, legacyPlugins };
@@ -0,0 +1,63 @@
1
+ import { P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.CH30252c.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.YnmwhfIN.mjs';
5
+ import { c as createHead$2 } from './shared/unhead.C5ypJnIO.mjs';
6
+ import './shared/unhead.BGFxPGPQ.mjs';
7
+ import './shared/unhead.DvIxXxuO.mjs';
8
+ import 'hookable';
9
+ import './shared/unhead.pv34ME7O.mjs';
10
+ import './shared/unhead.fg-0ge_u.mjs';
11
+ import './shared/unhead.DiRbsb3I.mjs';
12
+
13
+ const DeprecationsPlugin = /* @__PURE__ */ defineHeadPlugin({
14
+ key: "deprecations",
15
+ hooks: {
16
+ "entries:normalize": ({ tags }) => {
17
+ for (const tag of tags) {
18
+ if (tag.props.children) {
19
+ tag.innerHTML = tag.props.children;
20
+ delete tag.props.children;
21
+ }
22
+ if (tag.props.hid) {
23
+ tag.key = tag.props.hid;
24
+ delete tag.props.hid;
25
+ }
26
+ if (tag.props.vmid) {
27
+ tag.key = tag.props.vmid;
28
+ delete tag.props.vmid;
29
+ }
30
+ if ("body" in tag.props) {
31
+ if (tag.props.body) {
32
+ tag.tagPosition = "bodyClose";
33
+ }
34
+ delete tag.props.body;
35
+ }
36
+ if (tag.props.renderPriority != null) {
37
+ tag.tagPriority = tag.props.renderPriority;
38
+ delete tag.props.renderPriority;
39
+ }
40
+ }
41
+ }
42
+ }
43
+ });
44
+ const legacyPlugins = [DeprecationsPlugin, PromisesPlugin, TemplateParamsPlugin, AliasSortingPlugin];
45
+ const activeHead = { value: null };
46
+ function getActiveHead() {
47
+ return activeHead.value;
48
+ }
49
+ function createHead(options = {}) {
50
+ return activeHead.value = createHead$1({
51
+ ...options,
52
+ plugins: [...legacyPlugins, ...options.plugins || []]
53
+ });
54
+ }
55
+ function createServerHead(options = {}) {
56
+ return activeHead.value = createHead$2({
57
+ ...options,
58
+ plugins: [...legacyPlugins, ...options.plugins || []]
59
+ });
60
+ }
61
+ const createHeadCore = createUnhead;
62
+
63
+ export { DeprecationsPlugin, activeHead, createHead, createHeadCore, createServerHead, getActiveHead, legacyPlugins };
package/dist/parser.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { aM as SerializableHead } from './shared/unhead.BJTN1X0i.mjs';
1
+ import { aM as SerializableHead } from './shared/unhead.BcynQ3qJ.mjs';
2
2
 
3
3
  declare const TagIdMap: {
4
4
  readonly html: 0;
package/dist/parser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { aM as SerializableHead } from './shared/unhead.BJTN1X0i.js';
1
+ import { aM as SerializableHead } from './shared/unhead.BcynQ3qJ.js';
2
2
 
3
3
  declare const TagIdMap: {
4
4
  readonly html: 0;
@@ -1,5 +1,5 @@
1
- import { n as HeadPluginInput, U as Unhead, o as HeadPluginOptions } from './shared/unhead.DsHmk_XC.mjs';
2
- import { t as HeadTag } from './shared/unhead.BJTN1X0i.mjs';
1
+ import { n as HeadPluginInput, U as Unhead, o as HeadPluginOptions } from './shared/unhead.m4TuRTvV.mjs';
2
+ import { t as HeadTag } from './shared/unhead.BcynQ3qJ.mjs';
3
3
  import 'hookable';
4
4
 
5
5
  declare const AliasSortingPlugin: HeadPluginInput;
package/dist/plugins.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as HeadPluginInput, U as Unhead, o as HeadPluginOptions } from './shared/unhead.BRWMyYIW.js';
2
- import { t as HeadTag } from './shared/unhead.BJTN1X0i.js';
1
+ import { n as HeadPluginInput, U as Unhead, o as HeadPluginOptions } from './shared/unhead.BmdY3z1V.js';
2
+ import { t as HeadTag } from './shared/unhead.BcynQ3qJ.js';
3
3
  import 'hookable';
4
4
 
5
5
  declare const AliasSortingPlugin: HeadPluginInput;
package/dist/plugins.mjs CHANGED
@@ -1,48 +1,11 @@
1
- import { d as defineHeadPlugin } from './shared/unhead.D_bywjUE.mjs';
2
- export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.D_bywjUE.mjs';
1
+ export { A as AliasSortingPlugin, P as PromisesPlugin, T as TemplateParamsPlugin } from './shared/unhead.CH30252c.mjs';
2
+ import { d as defineHeadPlugin } from './shared/unhead.CUXLLRtV.mjs';
3
+ export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.A4ndrqqe.mjs';
3
4
  import { minifyJS, minifyCSS, minifyJSON } from './minify.mjs';
4
- import { p as processTemplateParams } from './shared/unhead.BGFxPGPQ.mjs';
5
+ import './shared/unhead.BGFxPGPQ.mjs';
5
6
  import './shared/unhead.JWUDzlIs.mjs';
6
7
  import './shared/unhead.fg-0ge_u.mjs';
7
8
 
8
- const sortTags = (a, b) => a._w === b._w ? a._p - b._p : a._w - b._w;
9
- const formatKey = (k) => !k.includes(":key") ? k.split(":").join(":key:") : k;
10
- const AliasSortingPlugin = defineHeadPlugin({
11
- key: "aliasSorting",
12
- hooks: {
13
- "tags:resolve": (ctx) => {
14
- let m = false;
15
- for (const t of ctx.tags) {
16
- const p = t.tagPriority;
17
- if (!p)
18
- continue;
19
- const s = String(p);
20
- if (s.startsWith("before:")) {
21
- const k = formatKey(s.slice(7));
22
- const l = ctx.tagMap.get(k);
23
- if (l) {
24
- if (typeof l.tagPriority === "number")
25
- t.tagPriority = l.tagPriority;
26
- t._p = l._p - 1;
27
- m = true;
28
- }
29
- } else if (s.startsWith("after:")) {
30
- const k = formatKey(s.slice(6));
31
- const l = ctx.tagMap.get(k);
32
- if (l) {
33
- if (typeof l.tagPriority === "number")
34
- t.tagPriority = l.tagPriority;
35
- t._p = l._p + 1;
36
- m = true;
37
- }
38
- }
39
- }
40
- if (m)
41
- ctx.tags = ctx.tags.sort(sortTags);
42
- }
43
- }
44
- });
45
-
46
9
  const META_TRANSFORMABLE_URL = [
47
10
  "og:url",
48
11
  "og:image",
@@ -238,93 +201,6 @@ function MinifyPlugin(options) {
238
201
  };
239
202
  }
240
203
 
241
- async function walkPromises(v) {
242
- const type = typeof v;
243
- if (type === "function") {
244
- return v;
245
- }
246
- if (v instanceof Promise) {
247
- return await v;
248
- }
249
- if (Array.isArray(v)) {
250
- return await Promise.all(v.map((r) => walkPromises(r)));
251
- }
252
- if (v?.constructor === Object) {
253
- const next = {};
254
- for (const key of Object.keys(v)) {
255
- next[key] = await walkPromises(v[key]);
256
- }
257
- return next;
258
- }
259
- return v;
260
- }
261
- const PromisesPlugin = /* @__PURE__ */ defineHeadPlugin({
262
- key: "promises",
263
- hooks: {
264
- "entries:resolve": async (ctx) => {
265
- const promises = [];
266
- for (const k in ctx.entries) {
267
- if (!ctx.entries[k]._promisesProcessed) {
268
- promises.push(
269
- walkPromises(ctx.entries[k].input).then((val) => {
270
- ctx.entries[k].input = val;
271
- ctx.entries[k]._promisesProcessed = true;
272
- })
273
- );
274
- }
275
- }
276
- await Promise.all(promises);
277
- }
278
- }
279
- });
280
-
281
- const SupportedAttrs = {
282
- meta: "content",
283
- link: "href",
284
- htmlAttrs: "lang"
285
- };
286
- const contentAttrs = ["innerHTML", "textContent"];
287
- const TemplateParamsPlugin = /* @__PURE__ */ defineHeadPlugin((head) => {
288
- return {
289
- key: "template-params",
290
- hooks: {
291
- "tags:resolve": ({ tagMap, tags }) => {
292
- const params = tagMap.get("templateParams")?.props || {};
293
- const sep = params.separator || "|";
294
- delete params.separator;
295
- params.pageTitle = processTemplateParams(
296
- // find templateParams
297
- params.pageTitle || head._title || "",
298
- params,
299
- sep
300
- );
301
- for (const tag of tags) {
302
- if (tag.processTemplateParams === false) {
303
- continue;
304
- }
305
- const v = SupportedAttrs[tag.tag];
306
- if (v && typeof tag.props[v] === "string") {
307
- tag.props[v] = processTemplateParams(tag.props[v], params, sep);
308
- } else if (tag.processTemplateParams || tag.tag === "titleTemplate" || tag.tag === "title") {
309
- for (const p of contentAttrs) {
310
- if (typeof tag[p] === "string")
311
- tag[p] = processTemplateParams(tag[p], params, sep, tag.tag === "script" && tag.props.type.endsWith("json"));
312
- }
313
- }
314
- }
315
- head._templateParams = params;
316
- head._separator = sep;
317
- },
318
- "tags:afterResolve": ({ tagMap }) => {
319
- const title = tagMap.get("title");
320
- if (title?.textContent && title.processTemplateParams !== false) {
321
- title.textContent = processTemplateParams(title.textContent, head._templateParams, head._separator);
322
- }
323
- }
324
- }
325
- };
326
- });
327
-
328
204
  const URL_META_KEYS = /* @__PURE__ */ new Set([
329
205
  "og:url",
330
206
  "og:image",
@@ -831,4 +707,4 @@ function ValidatePlugin(options = {}) {
831
707
  });
832
708
  }
833
709
 
834
- export { AliasSortingPlugin, CanonicalPlugin, InferSeoMetaPlugin, MinifyPlugin, PromisesPlugin, TemplateParamsPlugin, ValidatePlugin, defineHeadPlugin };
710
+ export { CanonicalPlugin, InferSeoMetaPlugin, MinifyPlugin, ValidatePlugin, defineHeadPlugin };
@@ -1,8 +1,8 @@
1
- import { R as RecordingEntry } from './shared/unhead.DsHmk_XC.mjs';
2
- export { a as AsVoidFunctions, j as EventHandlerOptions, u 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.DsHmk_XC.mjs';
3
- export { u as useScript } from './shared/unhead.Dp1MlAYz.mjs';
1
+ import { R as RecordingEntry } from './shared/unhead.m4TuRTvV.mjs';
2
+ export { a as AsVoidFunctions, j as EventHandlerOptions, u 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.m4TuRTvV.mjs';
3
+ export { u as useScript } from './shared/unhead.DvqMLXpO.mjs';
4
4
  import 'hookable';
5
- import './shared/unhead.BJTN1X0i.mjs';
5
+ import './shared/unhead.BcynQ3qJ.mjs';
6
6
 
7
7
  declare function createSpyProxy<T extends Record<string, any> | any[]>(target: T, onApply: (stack: RecordingEntry[][]) => void): T;
8
8
 
package/dist/scripts.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { R as RecordingEntry } from './shared/unhead.BRWMyYIW.js';
2
- export { a as AsVoidFunctions, j as EventHandlerOptions, u 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.BRWMyYIW.js';
3
- export { u as useScript } from './shared/unhead.DH3TZMHc.js';
1
+ import { R as RecordingEntry } from './shared/unhead.BmdY3z1V.js';
2
+ export { a as AsVoidFunctions, j as EventHandlerOptions, u 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.BmdY3z1V.js';
3
+ export { u as useScript } from './shared/unhead.DoIxTwSF.js';
4
4
  import 'hookable';
5
- import './shared/unhead.BJTN1X0i.js';
5
+ import './shared/unhead.BcynQ3qJ.js';
6
6
 
7
7
  declare function createSpyProxy<T extends Record<string, any> | any[]>(target: T, onApply: (stack: RecordingEntry[][]) => void): T;
8
8
 
package/dist/server.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- export { S as ServerUnhead, c as createHead } from './shared/unhead.C6alnWbQ.mjs';
2
- import { r as RenderSSRHeadOptions, p as HeadRenderer, s as SSRHeadPayload, U as Unhead } from './shared/unhead.DsHmk_XC.mjs';
3
- export { e as CreateServerHeadOptions } from './shared/unhead.DsHmk_XC.mjs';
4
- import { t as HeadTag } from './shared/unhead.BJTN1X0i.mjs';
1
+ export { S as ServerUnhead, c as createHead } from './shared/unhead.BfINO8Du.mjs';
2
+ import { r as RenderSSRHeadOptions, p as HeadRenderer, s as SSRHeadPayload, U as Unhead } from './shared/unhead.m4TuRTvV.mjs';
3
+ export { e as CreateServerHeadOptions } from './shared/unhead.m4TuRTvV.mjs';
4
+ import { t as HeadTag } from './shared/unhead.BcynQ3qJ.mjs';
5
5
  import 'hookable';
6
6
 
7
7
  declare function createServerRenderer(options?: RenderSSRHeadOptions): HeadRenderer<SSRHeadPayload>;
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { S as ServerUnhead, c as createHead } from './shared/unhead.D4KaR-FM.js';
2
- import { r as RenderSSRHeadOptions, p as HeadRenderer, s as SSRHeadPayload, U as Unhead } from './shared/unhead.BRWMyYIW.js';
3
- export { e as CreateServerHeadOptions } from './shared/unhead.BRWMyYIW.js';
4
- import { t as HeadTag } from './shared/unhead.BJTN1X0i.js';
1
+ export { S as ServerUnhead, c as createHead } from './shared/unhead.9aHQrEvB.js';
2
+ import { r as RenderSSRHeadOptions, p as HeadRenderer, s as SSRHeadPayload, U as Unhead } from './shared/unhead.BmdY3z1V.js';
3
+ export { e as CreateServerHeadOptions } from './shared/unhead.BmdY3z1V.js';
4
+ import { t as HeadTag } from './shared/unhead.BcynQ3qJ.js';
5
5
  import 'hookable';
6
6
 
7
7
  declare function createServerRenderer(options?: RenderSSRHeadOptions): HeadRenderer<SSRHeadPayload>;
@@ -1,6 +1,6 @@
1
1
  import { HookableCore } from 'hookable';
2
- import { U as Unhead, s as SSRHeadPayload, v as ServerHeadHooks, e as CreateServerHeadOptions } from './unhead.BRWMyYIW.js';
3
- import { at as ResolvableHead } from './unhead.BJTN1X0i.js';
2
+ import { U as Unhead, s as SSRHeadPayload, v as ServerHeadHooks, e as CreateServerHeadOptions } from './unhead.BmdY3z1V.js';
3
+ import { at as ResolvableHead } from './unhead.BcynQ3qJ.js';
4
4
 
5
5
  interface ServerUnhead<T = ResolvableHead> extends Unhead<T, SSRHeadPayload> {
6
6
  hooks: HookableCore<ServerHeadHooks>;
@@ -1,8 +1,5 @@
1
1
  import { u as unpackMeta } from './unhead.JWUDzlIs.mjs';
2
-
3
- function defineHeadPlugin(plugin) {
4
- return plugin;
5
- }
2
+ import { d as defineHeadPlugin } from './unhead.CUXLLRtV.mjs';
6
3
 
7
4
  const FlatMetaPlugin = /* @__PURE__ */ defineHeadPlugin({
8
5
  key: "flatMeta",
@@ -233,4 +230,4 @@ const SafeInputPlugin = (
233
230
  })
234
231
  );
235
232
 
236
- export { FlatMetaPlugin as F, SafeInputPlugin as S, defineHeadPlugin as d };
233
+ export { FlatMetaPlugin as F, SafeInputPlugin as S };
@@ -1,6 +1,6 @@
1
1
  import { HookableCore } from 'hookable';
2
- import { U as Unhead, C as ClientHeadHooks, c as CreateClientHeadOptions } from './unhead.DsHmk_XC.mjs';
3
- import { at as ResolvableHead } from './unhead.BJTN1X0i.mjs';
2
+ import { U as Unhead, C as ClientHeadHooks, c as CreateClientHeadOptions } from './unhead.m4TuRTvV.mjs';
3
+ import { at as ResolvableHead } from './unhead.BcynQ3qJ.mjs';
4
4
 
5
5
  interface ClientUnhead<T = ResolvableHead> extends Unhead<T, boolean> {
6
6
  hooks: HookableCore<ClientHeadHooks>;