unhead 3.0.0-beta.5 → 3.0.0-beta.6

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 (55) hide show
  1. package/dist/client.d.mts +5 -5
  2. package/dist/client.d.ts +5 -5
  3. package/dist/client.mjs +19 -42
  4. package/dist/index.d.mts +4 -8
  5. package/dist/index.d.ts +4 -8
  6. package/dist/index.mjs +5 -5
  7. package/dist/parser.d.mts +1 -1
  8. package/dist/parser.d.ts +1 -1
  9. package/dist/plugins.d.mts +2 -2
  10. package/dist/plugins.d.ts +2 -2
  11. package/dist/plugins.mjs +4 -4
  12. package/dist/scripts.d.mts +4 -4
  13. package/dist/scripts.d.ts +4 -4
  14. package/dist/scripts.mjs +2 -2
  15. package/dist/server.d.mts +4 -4
  16. package/dist/server.d.ts +4 -4
  17. package/dist/server.mjs +10 -13
  18. package/dist/shared/{unhead.CpsjOPAu.mjs → unhead.2y8V0W4A.mjs} +1 -1
  19. package/dist/shared/{unhead.DWEsU3pU.d.ts → unhead.B3NZQsuH.d.ts} +2 -2
  20. package/dist/shared/{unhead.CEWerdEp.d.mts → unhead.BapS9crD.d.mts} +2 -2
  21. package/dist/shared/{unhead.CEWerdEp.d.ts → unhead.BapS9crD.d.ts} +2 -2
  22. package/dist/shared/{unhead.Dk69jLbN.mjs → unhead.Bkfgmqxw.mjs} +10 -6
  23. package/dist/shared/{unhead.jLixRfSR.mjs → unhead.C2yODEXq.mjs} +2 -19
  24. package/dist/shared/{unhead.BvMMF8wH.d.mts → unhead.C4LhVpaV.d.mts} +1 -1
  25. package/dist/shared/unhead.C8J9ETnF.mjs +153 -0
  26. package/dist/shared/{unhead.C8vIYPdy.d.ts → unhead.C9MryCbP.d.ts} +24 -8
  27. package/dist/shared/{unhead.C872_DIi.mjs → unhead.CMGJIdw7.mjs} +3 -3
  28. package/dist/shared/{unhead.CPLhZXQc.d.ts → unhead.CV1o8EMt.d.ts} +1 -1
  29. package/dist/shared/unhead.Cd9rbIBR.mjs +235 -0
  30. package/dist/shared/{unhead.BMNVj5kM.d.ts → unhead.Cqwv-Snu.d.ts} +1 -1
  31. package/dist/shared/{unhead.nIyuXWp0.d.mts → unhead.CwW8GLoB.d.mts} +24 -8
  32. package/dist/shared/{unhead.CJepcqMm.mjs → unhead.CxhEb2IP.mjs} +1 -1
  33. package/dist/shared/{unhead.DQrNWUd0.mjs → unhead.D0zMN8VW.mjs} +1 -1
  34. package/dist/shared/{unhead.DV1JgQq2.d.mts → unhead.D2YTKqpr.d.mts} +1 -1
  35. package/dist/shared/{unhead.DvpX2SAn.d.mts → unhead.DFYRNPGz.d.mts} +1 -1
  36. package/dist/shared/{unhead.CZfNRJXC.d.mts → unhead.Dicp3R79.d.mts} +2 -2
  37. package/dist/shared/{unhead.CYmogFtO.d.ts → unhead.PmGaZ6n3.d.ts} +1 -1
  38. package/dist/stream/client.d.mts +3 -3
  39. package/dist/stream/client.d.ts +3 -3
  40. package/dist/stream/client.mjs +6 -12
  41. package/dist/stream/iife.d.mts +2 -2
  42. package/dist/stream/iife.d.ts +2 -2
  43. package/dist/stream/iife.global.js +1 -1
  44. package/dist/stream/iife.mjs +2 -2
  45. package/dist/stream/server.d.mts +2 -2
  46. package/dist/stream/server.d.ts +2 -2
  47. package/dist/stream/server.mjs +4 -4
  48. package/dist/types.d.mts +6 -6
  49. package/dist/types.d.ts +6 -6
  50. package/dist/utils.d.mts +2 -15
  51. package/dist/utils.d.ts +2 -15
  52. package/dist/utils.mjs +3 -3
  53. package/package.json +1 -1
  54. package/dist/shared/unhead.BVkBe8OQ.mjs +0 -309
  55. package/dist/shared/unhead.WuuRWmDo.mjs +0 -159
package/dist/client.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- export { C as ClientUnhead, c as createHead } from './shared/unhead.CZfNRJXC.mjs';
2
- import { R as RenderDomHeadOptions } from './shared/unhead.DvpX2SAn.mjs';
3
- import { p as HeadRenderer, q as Unhead } from './shared/unhead.nIyuXWp0.mjs';
4
- export { n as CreateClientHeadOptions } from './shared/unhead.nIyuXWp0.mjs';
1
+ export { C as ClientUnhead, c as createHead } from './shared/unhead.Dicp3R79.mjs';
2
+ import { R as RenderDomHeadOptions } from './shared/unhead.DFYRNPGz.mjs';
3
+ import { p as HeadRenderer, q as Unhead } from './shared/unhead.CwW8GLoB.mjs';
4
+ export { n as CreateClientHeadOptions } from './shared/unhead.CwW8GLoB.mjs';
5
5
  import 'hookable';
6
- import './shared/unhead.CEWerdEp.mjs';
6
+ import './shared/unhead.BapS9crD.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.DWEsU3pU.js';
2
- import { R as RenderDomHeadOptions } from './shared/unhead.CYmogFtO.js';
3
- import { p as HeadRenderer, q as Unhead } from './shared/unhead.C8vIYPdy.js';
4
- export { n as CreateClientHeadOptions } from './shared/unhead.C8vIYPdy.js';
1
+ export { C as ClientUnhead, c as createHead } from './shared/unhead.B3NZQsuH.js';
2
+ import { R as RenderDomHeadOptions } from './shared/unhead.PmGaZ6n3.js';
3
+ import { p as HeadRenderer, q as Unhead } from './shared/unhead.C9MryCbP.js';
4
+ export { n as CreateClientHeadOptions } from './shared/unhead.C9MryCbP.js';
5
5
  import 'hookable';
6
- import './shared/unhead.CEWerdEp.js';
6
+ import './shared/unhead.BapS9crD.js';
7
7
 
8
8
  declare function createDomRenderer(options?: RenderDomHeadOptions): HeadRenderer<boolean>;
9
9
 
package/dist/client.mjs CHANGED
@@ -1,28 +1,22 @@
1
- import { c as createDomRenderer, r as renderDOMHead$1 } from './shared/unhead.WuuRWmDo.mjs';
2
- import { c as createUnhead, r as registerPlugin } from './shared/unhead.Dk69jLbN.mjs';
3
- import { d as TagPriorityAliases } from './shared/unhead.jLixRfSR.mjs';
1
+ import { c as createDomRenderer, r as renderDOMHead$1 } from './shared/unhead.C8J9ETnF.mjs';
2
+ import { c as createUnhead, r as registerPlugin } from './shared/unhead.Bkfgmqxw.mjs';
4
3
  import { c as createHooks } from './shared/unhead.DvIxXxuO.mjs';
5
- import './shared/unhead.BVkBe8OQ.mjs';
4
+ import './shared/unhead.C2yODEXq.mjs';
5
+ import './shared/unhead.Cd9rbIBR.mjs';
6
6
  import 'hookable';
7
7
 
8
- function tagWeight(tag) {
9
- return typeof tag.tagPriority === "number" ? tag.tagPriority : 100 + (TagPriorityAliases[tag.tagPriority] || 0);
10
- }
8
+ const P = { critical: -8, high: -1, low: 2 };
9
+ const tagWeight = (tag) => typeof tag.tagPriority === "number" ? tag.tagPriority : 100 + (P[tag.tagPriority] || 0);
11
10
  function createHead(options = {}) {
12
11
  options.document = options.document || (typeof window !== "undefined" ? document : void 0);
13
12
  const renderer = options.render || createDomRenderer({ document: options.document });
14
13
  const initialPayload = options.document?.head.querySelector('script[id="unhead:payload"]')?.innerHTML || false;
15
- const core = createUnhead(renderer, {
16
- document: options.document,
17
- propResolvers: options.propResolvers,
18
- _tagWeight: tagWeight,
19
- init: []
20
- // push on wrapped head instead
21
- });
14
+ const core = createUnhead(renderer, { document: options.document, propResolvers: options.propResolvers, _tagWeight: tagWeight, init: [] });
22
15
  const hooks = createHooks(options.hooks);
23
16
  let dirty = false;
24
17
  const head = {
25
18
  ...core,
19
+ ssr: false,
26
20
  hooks,
27
21
  use: (p) => registerPlugin(head, p),
28
22
  get dirty() {
@@ -31,56 +25,39 @@ function createHead(options = {}) {
31
25
  set dirty(v) {
32
26
  dirty = v;
33
27
  },
34
- render() {
35
- return renderer(head);
36
- },
28
+ render: () => renderer(head),
37
29
  invalidate() {
38
- for (const entry of core.entries.values()) {
39
- entry._dirty = true;
40
- }
30
+ for (const e of core.entries.values()) delete e._tags;
41
31
  dirty = true;
42
32
  hooks.callHook("entries:updated", head);
43
33
  },
44
34
  push(input, _options) {
45
35
  const active = core.push(input, _options);
46
- const entry = core.entries.get(active._i);
47
- entry._dirty = true;
36
+ core.entries.get(active._i)._o = input;
48
37
  dirty = true;
49
38
  hooks.callHook("entries:updated", head);
50
- const corePatch = active.patch;
51
- const coreDispose = active.dispose;
52
- const clientActive = {
39
+ return {
53
40
  _i: active._i,
54
41
  patch(input2) {
55
- corePatch(input2);
56
- entry._dirty = true;
42
+ active.patch(input2);
57
43
  dirty = true;
58
44
  hooks.callHook("entries:updated", head);
59
45
  },
60
46
  dispose() {
61
47
  if (core.entries.has(active._i)) {
62
- coreDispose();
48
+ active.dispose();
63
49
  head.invalidate();
64
50
  }
65
51
  }
66
52
  };
67
- return clientActive;
68
53
  }
69
54
  };
70
- (options.plugins || []).forEach((p) => registerPlugin(head, p));
71
- registerPlugin(head, {
72
- key: "client",
73
- hooks: {
74
- "entries:updated": () => {
75
- head.render();
76
- }
77
- }
55
+ hooks.hook("entries:updated", () => {
56
+ renderer(head);
78
57
  });
79
- const initEntries = [
80
- initialPayload ? JSON.parse(initialPayload) : false,
81
- ...options.init || []
82
- ];
83
- initEntries.forEach((e) => e && head.push(e));
58
+ options.plugins?.forEach((p) => registerPlugin(head, p));
59
+ initialPayload && head.push(JSON.parse(initialPayload));
60
+ options.init?.forEach((e) => e && head.push(e));
84
61
  return head;
85
62
  }
86
63
 
package/dist/index.d.mts CHANGED
@@ -1,17 +1,13 @@
1
- import { H as HeadSafe } from './shared/unhead.DV1JgQq2.mjs';
2
- import { ad as ResolvableHead, ag as UseSeoMetaInput } from './shared/unhead.CEWerdEp.mjs';
3
- import { q as Unhead, o as HeadEntryOptions, k as ActiveHeadEntry, p as HeadRenderer, C as CreateHeadOptions } from './shared/unhead.nIyuXWp0.mjs';
4
- export { u as useScript } from './shared/unhead.BvMMF8wH.mjs';
1
+ import { H as HeadSafe } from './shared/unhead.D2YTKqpr.mjs';
2
+ import { ad as ResolvableHead, ag as UseSeoMetaInput } from './shared/unhead.BapS9crD.mjs';
3
+ import { q as Unhead, o as HeadEntryOptions, k as ActiveHeadEntry, p as HeadRenderer, C as CreateHeadOptions } from './shared/unhead.CwW8GLoB.mjs';
4
+ export { u as useScript } from './shared/unhead.C4LhVpaV.mjs';
5
5
  import 'hookable';
6
6
 
7
7
  declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
8
8
  declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
9
9
  declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
10
10
 
11
- /**
12
- * Creates a core instance of unhead. Does not provide a global ctx for composables to work
13
- * and does not register DOM plugins.
14
- */
15
11
  declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
16
12
 
17
13
  export { createUnhead, useHead, useHeadSafe, useSeoMeta };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,13 @@
1
- import { H as HeadSafe } from './shared/unhead.CPLhZXQc.js';
2
- import { ad as ResolvableHead, ag as UseSeoMetaInput } from './shared/unhead.CEWerdEp.js';
3
- import { q as Unhead, o as HeadEntryOptions, k as ActiveHeadEntry, p as HeadRenderer, C as CreateHeadOptions } from './shared/unhead.C8vIYPdy.js';
4
- export { u as useScript } from './shared/unhead.BMNVj5kM.js';
1
+ import { H as HeadSafe } from './shared/unhead.CV1o8EMt.js';
2
+ import { ad as ResolvableHead, ag as UseSeoMetaInput } from './shared/unhead.BapS9crD.js';
3
+ import { q as Unhead, o as HeadEntryOptions, k as ActiveHeadEntry, p as HeadRenderer, C as CreateHeadOptions } from './shared/unhead.C9MryCbP.js';
4
+ export { u as useScript } from './shared/unhead.Cqwv-Snu.js';
5
5
  import 'hookable';
6
6
 
7
7
  declare function useHead<T extends Unhead<any>, I = ResolvableHead>(unhead: T, input?: ResolvableHead, options?: HeadEntryOptions): ActiveHeadEntry<I>;
8
8
  declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
9
9
  declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
10
10
 
11
- /**
12
- * Creates a core instance of unhead. Does not provide a global ctx for composables to work
13
- * and does not register DOM plugins.
14
- */
15
11
  declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
16
12
 
17
13
  export { createUnhead, useHead, useHeadSafe, useSeoMeta };
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { S as SafeInputPlugin, F as FlatMetaPlugin } from './shared/unhead.CpsjOPAu.mjs';
2
- export { c as createUnhead } from './shared/unhead.Dk69jLbN.mjs';
3
- export { u as useScript } from './shared/unhead.DQrNWUd0.mjs';
4
- import './shared/unhead.CJepcqMm.mjs';
5
- import './shared/unhead.jLixRfSR.mjs';
1
+ import { S as SafeInputPlugin, F as FlatMetaPlugin } from './shared/unhead.2y8V0W4A.mjs';
2
+ export { c as createUnhead } from './shared/unhead.Bkfgmqxw.mjs';
3
+ export { u as useScript } from './shared/unhead.D0zMN8VW.mjs';
4
+ import './shared/unhead.CxhEb2IP.mjs';
5
+ import './shared/unhead.C2yODEXq.mjs';
6
6
  import './shared/unhead.DvIxXxuO.mjs';
7
7
  import 'hookable';
8
8
 
package/dist/parser.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ae as SerializableHead } from './shared/unhead.CEWerdEp.mjs';
1
+ import { ae as SerializableHead } from './shared/unhead.BapS9crD.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 { ae as SerializableHead } from './shared/unhead.CEWerdEp.js';
1
+ import { ae as SerializableHead } from './shared/unhead.BapS9crD.js';
2
2
 
3
3
  declare const TagIdMap: {
4
4
  readonly html: 0;
@@ -1,6 +1,6 @@
1
- import { i as HeadPluginInput, q as Unhead, h as HeadPluginOptions } from './shared/unhead.nIyuXWp0.mjs';
1
+ import { i as HeadPluginInput, q as Unhead, h as HeadPluginOptions } from './shared/unhead.CwW8GLoB.mjs';
2
2
  import 'hookable';
3
- import './shared/unhead.CEWerdEp.mjs';
3
+ import './shared/unhead.BapS9crD.mjs';
4
4
 
5
5
  declare const AliasSortingPlugin: HeadPluginInput;
6
6
 
package/dist/plugins.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { i as HeadPluginInput, q as Unhead, h as HeadPluginOptions } from './shared/unhead.C8vIYPdy.js';
1
+ import { i as HeadPluginInput, q as Unhead, h as HeadPluginOptions } from './shared/unhead.C9MryCbP.js';
2
2
  import 'hookable';
3
- import './shared/unhead.CEWerdEp.js';
3
+ import './shared/unhead.BapS9crD.js';
4
4
 
5
5
  declare const AliasSortingPlugin: HeadPluginInput;
6
6
 
package/dist/plugins.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { d as defineHeadPlugin } from './shared/unhead.CpsjOPAu.mjs';
2
- export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.CpsjOPAu.mjs';
1
+ import { d as defineHeadPlugin } from './shared/unhead.2y8V0W4A.mjs';
2
+ export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.2y8V0W4A.mjs';
3
3
  import { p as processTemplateParams } from './shared/unhead.BYvz9V1x.mjs';
4
- import './shared/unhead.CJepcqMm.mjs';
5
- import './shared/unhead.jLixRfSR.mjs';
4
+ import './shared/unhead.CxhEb2IP.mjs';
5
+ import './shared/unhead.C2yODEXq.mjs';
6
6
 
7
7
  const sortTags = (a, b) => a._w === b._w ? a._p - b._p : a._w - b._w;
8
8
  const formatKey = (k) => !k.includes(":key") ? k.split(":").join(":key:") : k;
@@ -1,8 +1,8 @@
1
- import { R as RecordingEntry } from './shared/unhead.nIyuXWp0.mjs';
2
- export { A as AsVoidFunctions, E as EventHandlerOptions, S as ScriptInstance, d as UseFunctionType, a as UseScriptContext, c as UseScriptInput, e as UseScriptOptions, b as UseScriptResolvedInput, f as UseScriptReturn, U as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.nIyuXWp0.mjs';
3
- export { u as useScript } from './shared/unhead.BvMMF8wH.mjs';
1
+ import { R as RecordingEntry } from './shared/unhead.CwW8GLoB.mjs';
2
+ export { A as AsVoidFunctions, E as EventHandlerOptions, S as ScriptInstance, d as UseFunctionType, a as UseScriptContext, c as UseScriptInput, e as UseScriptOptions, b as UseScriptResolvedInput, f as UseScriptReturn, U as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.CwW8GLoB.mjs';
3
+ export { u as useScript } from './shared/unhead.C4LhVpaV.mjs';
4
4
  import 'hookable';
5
- import './shared/unhead.CEWerdEp.mjs';
5
+ import './shared/unhead.BapS9crD.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.C8vIYPdy.js';
2
- export { A as AsVoidFunctions, E as EventHandlerOptions, S as ScriptInstance, d as UseFunctionType, a as UseScriptContext, c as UseScriptInput, e as UseScriptOptions, b as UseScriptResolvedInput, f as UseScriptReturn, U as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.C8vIYPdy.js';
3
- export { u as useScript } from './shared/unhead.BMNVj5kM.js';
1
+ import { R as RecordingEntry } from './shared/unhead.C9MryCbP.js';
2
+ export { A as AsVoidFunctions, E as EventHandlerOptions, S as ScriptInstance, d as UseFunctionType, a as UseScriptContext, c as UseScriptInput, e as UseScriptOptions, b as UseScriptResolvedInput, f as UseScriptReturn, U as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.C9MryCbP.js';
3
+ export { u as useScript } from './shared/unhead.Cqwv-Snu.js';
4
4
  import 'hookable';
5
- import './shared/unhead.CEWerdEp.js';
5
+ import './shared/unhead.BapS9crD.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/scripts.mjs CHANGED
@@ -1,7 +1,7 @@
1
- export { u as useScript } from './shared/unhead.DQrNWUd0.mjs';
1
+ export { u as useScript } from './shared/unhead.D0zMN8VW.mjs';
2
2
  import './shared/unhead.DvIxXxuO.mjs';
3
3
  import 'hookable';
4
- import './shared/unhead.jLixRfSR.mjs';
4
+ import './shared/unhead.C2yODEXq.mjs';
5
5
 
6
6
  function createSpyProxy(target, onApply) {
7
7
  const stack = [];
package/dist/server.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HookableCore } from 'hookable';
2
- import { l as CreateServerHeadOptions, q as Unhead, t as SSRHeadPayload, J as ServerHeadHooks, u as RenderSSRHeadOptions, p as HeadRenderer } from './shared/unhead.nIyuXWp0.mjs';
3
- import { ad as ResolvableHead, aC as HeadTag } from './shared/unhead.CEWerdEp.mjs';
2
+ import { l as CreateServerHeadOptions, q as Unhead, t as SSRHeadPayload, J as ServerHeadHooks, u as RenderSSRHeadOptions, p as HeadRenderer } from './shared/unhead.CwW8GLoB.mjs';
3
+ import { ad as ResolvableHead, aC as HeadTag } from './shared/unhead.BapS9crD.mjs';
4
4
 
5
5
  interface ServerUnhead<T = ResolvableHead> extends Unhead<T, SSRHeadPayload> {
6
6
  hooks: HookableCore<ServerHeadHooks>;
@@ -16,7 +16,7 @@ declare function capoTagWeight(tag: HeadTag): number;
16
16
  * and injecting the resulting head tags back into the HTML.
17
17
  * Uses optimized parsing and index-based HTML construction for best performance.
18
18
  */
19
- declare function transformHtmlTemplate(head: Unhead<any>, html: string, options?: RenderSSRHeadOptions): Promise<string>;
19
+ declare function transformHtmlTemplate(head: Unhead<any, SSRHeadPayload>, html: string): string;
20
20
  /**
21
21
  * Transform an HTML template string by injecting head tags managed by Unhead.
22
22
  *
@@ -26,7 +26,7 @@ declare function transformHtmlTemplate(head: Unhead<any>, html: string, options?
26
26
  * However, this also means that any head tags or attributes already present in the HTML may be duplicated or
27
27
  * ordered incorrectly, so use with caution.
28
28
  */
29
- declare function transformHtmlTemplateRaw(head: Unhead<any>, html: string, options?: RenderSSRHeadOptions): Promise<string>;
29
+ declare function transformHtmlTemplateRaw(head: Unhead<any, SSRHeadPayload>, html: string): string;
30
30
 
31
31
  declare function propsToString(props: Record<string, any>): string;
32
32
 
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HookableCore } from 'hookable';
2
- import { l as CreateServerHeadOptions, q as Unhead, t as SSRHeadPayload, J as ServerHeadHooks, u as RenderSSRHeadOptions, p as HeadRenderer } from './shared/unhead.C8vIYPdy.js';
3
- import { ad as ResolvableHead, aC as HeadTag } from './shared/unhead.CEWerdEp.js';
2
+ import { l as CreateServerHeadOptions, q as Unhead, t as SSRHeadPayload, J as ServerHeadHooks, u as RenderSSRHeadOptions, p as HeadRenderer } from './shared/unhead.C9MryCbP.js';
3
+ import { ad as ResolvableHead, aC as HeadTag } from './shared/unhead.BapS9crD.js';
4
4
 
5
5
  interface ServerUnhead<T = ResolvableHead> extends Unhead<T, SSRHeadPayload> {
6
6
  hooks: HookableCore<ServerHeadHooks>;
@@ -16,7 +16,7 @@ declare function capoTagWeight(tag: HeadTag): number;
16
16
  * and injecting the resulting head tags back into the HTML.
17
17
  * Uses optimized parsing and index-based HTML construction for best performance.
18
18
  */
19
- declare function transformHtmlTemplate(head: Unhead<any>, html: string, options?: RenderSSRHeadOptions): Promise<string>;
19
+ declare function transformHtmlTemplate(head: Unhead<any, SSRHeadPayload>, html: string): string;
20
20
  /**
21
21
  * Transform an HTML template string by injecting head tags managed by Unhead.
22
22
  *
@@ -26,7 +26,7 @@ declare function transformHtmlTemplate(head: Unhead<any>, html: string, options?
26
26
  * However, this also means that any head tags or attributes already present in the HTML may be duplicated or
27
27
  * ordered incorrectly, so use with caution.
28
28
  */
29
- declare function transformHtmlTemplateRaw(head: Unhead<any>, html: string, options?: RenderSSRHeadOptions): Promise<string>;
29
+ declare function transformHtmlTemplateRaw(head: Unhead<any, SSRHeadPayload>, html: string): string;
30
30
 
31
31
  declare function propsToString(props: Record<string, any>): string;
32
32
 
package/dist/server.mjs CHANGED
@@ -1,25 +1,22 @@
1
- import { r as renderSSRHead$1 } from './shared/unhead.C872_DIi.mjs';
2
- export { b as capoTagWeight, c as createHead, a as createServerRenderer, e as escapeHtml, p as propsToString, s as ssrRenderTags, t as tagToString } from './shared/unhead.C872_DIi.mjs';
3
- import './shared/unhead.Dk69jLbN.mjs';
1
+ import { r as renderSSRHead$1 } from './shared/unhead.CMGJIdw7.mjs';
2
+ export { b as capoTagWeight, c as createHead, a as createServerRenderer, e as escapeHtml, p as propsToString, s as ssrRenderTags, t as tagToString } from './shared/unhead.CMGJIdw7.mjs';
3
+ import { parseHtmlForUnheadExtraction, applyHeadToHtml, parseHtmlForIndexes } from './parser.mjs';
4
+ import './shared/unhead.Bkfgmqxw.mjs';
4
5
  import './shared/unhead.DvIxXxuO.mjs';
5
6
  import 'hookable';
6
- import './shared/unhead.BVkBe8OQ.mjs';
7
- import './shared/unhead.jLixRfSR.mjs';
7
+ import './shared/unhead.Cd9rbIBR.mjs';
8
+ import './shared/unhead.C2yODEXq.mjs';
8
9
 
9
10
  // @__NO_SIDE_EFFECTS__
10
- async function transformHtmlTemplate(head, html, options) {
11
- const { parseHtmlForUnheadExtraction, applyHeadToHtml } = await import('./parser.mjs');
11
+ function transformHtmlTemplate(head, html) {
12
12
  const template = parseHtmlForUnheadExtraction(html);
13
13
  head.push(template.input, { _index: 0 });
14
- const headHtml = renderSSRHead$1(head, options);
15
- return applyHeadToHtml(template, headHtml);
14
+ return applyHeadToHtml(template, head.render());
16
15
  }
17
16
  // @__NO_SIDE_EFFECTS__
18
- async function transformHtmlTemplateRaw(head, html, options) {
19
- const { parseHtmlForIndexes, applyHeadToHtml } = await import('./parser.mjs');
20
- const headHtml = renderSSRHead$1(head, options);
17
+ function transformHtmlTemplateRaw(head, html) {
21
18
  const template = parseHtmlForIndexes(html);
22
- return applyHeadToHtml(template, headHtml);
19
+ return applyHeadToHtml(template, head.render());
23
20
  }
24
21
 
25
22
  function renderSSRHead(head, options) {
@@ -1,4 +1,4 @@
1
- import { u as unpackMeta } from './unhead.CJepcqMm.mjs';
1
+ import { u as unpackMeta } from './unhead.CxhEb2IP.mjs';
2
2
 
3
3
  function defineHeadPlugin(plugin) {
4
4
  return plugin;
@@ -1,6 +1,6 @@
1
1
  import { HookableCore } from 'hookable';
2
- import { n as CreateClientHeadOptions, q as Unhead, I as ClientHeadHooks } from './unhead.C8vIYPdy.js';
3
- import { ad as ResolvableHead } from './unhead.CEWerdEp.js';
2
+ import { n as CreateClientHeadOptions, q as Unhead, I as ClientHeadHooks } from './unhead.C9MryCbP.js';
3
+ import { ad as ResolvableHead } from './unhead.BapS9crD.js';
4
4
 
5
5
  interface ClientUnhead<T = ResolvableHead> extends Unhead<T, boolean> {
6
6
  hooks: HookableCore<ClientHeadHooks>;
@@ -871,7 +871,7 @@ interface MetaFlatArticle {
871
871
  articleSection?: string;
872
872
  /**
873
873
  * Tag words associated with this article.
874
- * @example ['Apple', 'Steve Jobs]
874
+ * @example ['Apple', 'Steve Jobs']
875
875
  */
876
876
  articleTag?: string[];
877
877
  }
@@ -893,7 +893,7 @@ interface MetaFlatBook {
893
893
  bookReleaseDate?: string;
894
894
  /**
895
895
  * Tag words associated with this book.
896
- * @example ['Apple', 'Steve Jobs]
896
+ * @example ['Apple', 'Steve Jobs']
897
897
  */
898
898
  bookTag?: string[];
899
899
  }
@@ -871,7 +871,7 @@ interface MetaFlatArticle {
871
871
  articleSection?: string;
872
872
  /**
873
873
  * Tag words associated with this article.
874
- * @example ['Apple', 'Steve Jobs]
874
+ * @example ['Apple', 'Steve Jobs']
875
875
  */
876
876
  articleTag?: string[];
877
877
  }
@@ -893,7 +893,7 @@ interface MetaFlatBook {
893
893
  bookReleaseDate?: string;
894
894
  /**
895
895
  * Tag words associated with this book.
896
- * @example ['Apple', 'Steve Jobs]
896
+ * @example ['Apple', 'Steve Jobs']
897
897
  */
898
898
  bookTag?: string[];
899
899
  }
@@ -3,9 +3,8 @@ function registerPlugin(head, p) {
3
3
  const key = plugin.key || String(head.plugins.size + 1);
4
4
  if (!head.plugins.get(key)) {
5
5
  head.plugins.set(key, plugin);
6
- for (const hookKey in plugin.hooks || {}) {
7
- head.hooks?.hook(hookKey, plugin.hooks[hookKey]);
8
- }
6
+ for (const k in plugin.hooks || {})
7
+ head.hooks?.hook(k, plugin.hooks[k]);
9
8
  }
10
9
  }
11
10
  // @__NO_SIDE_EFFECTS__
@@ -22,9 +21,9 @@ function createUnhead(renderer, resolvedOptions = {}) {
22
21
  render: () => renderer(head),
23
22
  use: (p) => registerPlugin(head, p),
24
23
  push(input, _options) {
25
- const options = { ..._options || {} };
24
+ const _i = _options?._index ?? head._entryCount++;
25
+ const options = _options ? { ..._options } : {};
26
26
  delete options.head;
27
- const _i = options._index ?? head._entryCount++;
28
27
  const entry = { _i, input, options };
29
28
  entries.set(_i, entry);
30
29
  const active = {
@@ -33,7 +32,12 @@ function createUnhead(renderer, resolvedOptions = {}) {
33
32
  entries.delete(_i);
34
33
  },
35
34
  patch(input2) {
36
- entry.input = input2;
35
+ if (ssr) {
36
+ entry.input = input2;
37
+ delete entry._tags;
38
+ } else {
39
+ entry._pending = input2;
40
+ }
37
41
  if (!entries.has(_i))
38
42
  entries.set(_i, entry);
39
43
  }
@@ -1,25 +1,8 @@
1
1
  const SelfClosingTags = /* @__PURE__ */ new Set(["meta", "link", "base"]);
2
2
  const DupeableTags = /* @__PURE__ */ new Set(["link", "style", "script", "noscript"]);
3
3
  const TagsWithInnerContent = /* @__PURE__ */ new Set(["title", "titleTemplate", "script", "style", "noscript"]);
4
- const HasElementTags = /* @__PURE__ */ new Set([
5
- "base",
6
- "meta",
7
- "link",
8
- "style",
9
- "script",
10
- "noscript"
11
- ]);
12
- const ValidHeadTags = /* @__PURE__ */ new Set([
13
- "title",
14
- "base",
15
- "htmlAttrs",
16
- "bodyAttrs",
17
- "meta",
18
- "link",
19
- "style",
20
- "script",
21
- "noscript"
22
- ]);
4
+ const HasElementTags = /* @__PURE__ */ new Set(["base", "meta", "link", "style", "script", "noscript"]);
5
+ const ValidHeadTags = /* @__PURE__ */ new Set(["title", "base", "htmlAttrs", "bodyAttrs", "meta", "link", "style", "script", "noscript"]);
23
6
  const UniqueTags = /* @__PURE__ */ new Set(["base", "title", "titleTemplate", "bodyAttrs", "htmlAttrs", "templateParams"]);
24
7
  const TagConfigKeys = /* @__PURE__ */ new Set(["key", "tagPosition", "tagPriority", "tagDuplicateStrategy", "innerHTML", "textContent", "processTemplateParams"]);
25
8
  const ScriptNetworkEvents = /* @__PURE__ */ new Set(["onload", "onerror"]);
@@ -1,4 +1,4 @@
1
- import { q as Unhead, c as UseScriptInput, e as UseScriptOptions, f as UseScriptReturn } from './unhead.nIyuXWp0.mjs';
1
+ import { q as Unhead, c as UseScriptInput, e as UseScriptOptions, f as UseScriptReturn } from './unhead.CwW8GLoB.mjs';
2
2
 
3
3
  /**
4
4
  * Load third-party scripts with SSR support and a proxied API.