unhead 2.0.0-alpha.22 → 2.0.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { am as Head, n as CreateClientHeadOptions, p as Unhead, z as RenderDomHeadOptions } from './shared/unhead.B4pP8_2D.mjs';
1
+ import { am as Head, n as CreateClientHeadOptions, p as Unhead, z as RenderDomHeadOptions } from './shared/unhead.DwYyZgT5.mjs';
2
2
  import 'hookable';
3
3
 
4
4
  declare function createHead<T = Head>(options?: CreateClientHeadOptions): Unhead<T>;
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { am as Head, n as CreateClientHeadOptions, p as Unhead, z as RenderDomHeadOptions } from './shared/unhead.B4pP8_2D.js';
1
+ import { am as Head, n as CreateClientHeadOptions, p as Unhead, z as RenderDomHeadOptions } from './shared/unhead.DwYyZgT5.js';
2
2
  import 'hookable';
3
3
 
4
4
  declare function createHead<T = Head>(options?: CreateClientHeadOptions): Unhead<T>;
package/dist/client.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createHeadCore } from './shared/unhead.x5NJGkxU.mjs';
1
+ import { c as createHeadCore } from './shared/unhead.kC9yNSGl.mjs';
2
2
  import { H as HasElementTags } from './shared/unhead.yem5I2v_.mjs';
3
3
  import { h as hashTag, i as isMetaArrayDupeKey, a as normalizeProps, d as dedupeKey } from './shared/unhead.xsi8MZXD.mjs';
4
4
  import 'hookable';
package/dist/index.d.mts CHANGED
@@ -1,11 +1,23 @@
1
- import { H as HeadSafe } from './shared/unhead.B7BBWq8B.mjs';
2
- import { p as Unhead, o as HeadEntryOptions, l as ActiveHeadEntry, ao as UseSeoMetaInput, am as Head, C as CreateHeadOptions } from './shared/unhead.B4pP8_2D.mjs';
3
- export { u as useScript } from './shared/unhead.DcPrZw2e.mjs';
1
+ import { H as HeadSafe } from './shared/unhead.C1nwjySB.mjs';
2
+ import { p as Unhead, o as HeadEntryOptions, l as ActiveHeadEntry, ao as UseSeoMetaInput, am as Head, C as CreateHeadOptions } from './shared/unhead.DwYyZgT5.mjs';
3
+ export { u as useScript } from './shared/unhead.Bg64fTJV.mjs';
4
4
  import 'hookable';
5
5
 
6
6
  declare function useHead<T extends Unhead<any>>(unhead: T, input?: Parameters<T['push']>[0], options?: HeadEntryOptions): ReturnType<T['push']>;
7
7
  declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
8
8
  declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
9
+ /**
10
+ * @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
11
+ */
12
+ declare function useServerHead<T extends Unhead<any>>(unhead: T, input?: Parameters<T['push']>[0], options?: Omit<HeadEntryOptions, 'mode'>): ReturnType<T['push']>;
13
+ /**
14
+ * @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
15
+ */
16
+ declare function useServerHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<HeadSafe>;
17
+ /**
18
+ * @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
19
+ */
20
+ declare function useServerSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<UseSeoMetaInput>;
9
21
 
10
22
  /**
11
23
  * Creates a core instance of unhead. Does not provide a global ctx for composables to work
@@ -13,4 +25,4 @@ declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMeta
13
25
  */
14
26
  declare function createHeadCore<T = Head>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
15
27
 
16
- export { createHeadCore, useHead, useHeadSafe, useSeoMeta };
28
+ export { createHeadCore, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,23 @@
1
- import { H as HeadSafe } from './shared/unhead.D_YYNboR.js';
2
- import { p as Unhead, o as HeadEntryOptions, l as ActiveHeadEntry, ao as UseSeoMetaInput, am as Head, C as CreateHeadOptions } from './shared/unhead.B4pP8_2D.js';
3
- export { u as useScript } from './shared/unhead.CES0yIUs.js';
1
+ import { H as HeadSafe } from './shared/unhead.DtJaJIsF.js';
2
+ import { p as Unhead, o as HeadEntryOptions, l as ActiveHeadEntry, ao as UseSeoMetaInput, am as Head, C as CreateHeadOptions } from './shared/unhead.DwYyZgT5.js';
3
+ export { u as useScript } from './shared/unhead.C6vvMYCS.js';
4
4
  import 'hookable';
5
5
 
6
6
  declare function useHead<T extends Unhead<any>>(unhead: T, input?: Parameters<T['push']>[0], options?: HeadEntryOptions): ReturnType<T['push']>;
7
7
  declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
8
8
  declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<UseSeoMetaInput>;
9
+ /**
10
+ * @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
11
+ */
12
+ declare function useServerHead<T extends Unhead<any>>(unhead: T, input?: Parameters<T['push']>[0], options?: Omit<HeadEntryOptions, 'mode'>): ReturnType<T['push']>;
13
+ /**
14
+ * @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
15
+ */
16
+ declare function useServerHeadSafe<T extends Unhead<any>>(unhead: T, input?: HeadSafe, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<HeadSafe>;
17
+ /**
18
+ * @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
19
+ */
20
+ declare function useServerSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMetaInput, options?: Omit<HeadEntryOptions, 'mode'>): ActiveHeadEntry<UseSeoMetaInput>;
9
21
 
10
22
  /**
11
23
  * Creates a core instance of unhead. Does not provide a global ctx for composables to work
@@ -13,4 +25,4 @@ declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input?: UseSeoMeta
13
25
  */
14
26
  declare function createHeadCore<T = Head>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
15
27
 
16
- export { createHeadCore, useHead, useHeadSafe, useSeoMeta };
28
+ export { createHeadCore, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { u as useHead, a as useHeadSafe, b as useSeoMeta } from './shared/unhead.C2emW6l4.mjs';
2
- export { c as createHeadCore } from './shared/unhead.x5NJGkxU.mjs';
1
+ export { u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/unhead.PEkM8z0l.mjs';
2
+ export { c as createHeadCore } from './shared/unhead.kC9yNSGl.mjs';
3
3
  export { u as useScript } from './shared/unhead.CG0hxuzW.mjs';
4
4
  import './shared/unhead.z5bPaiJg.mjs';
5
5
  import './shared/unhead.DFwCX-QT.mjs';
package/dist/legacy.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- export { createHeadCore, useHead, useHeadSafe, useSeoMeta } from './index.mjs';
2
- import { p as Unhead, am as Head, C as CreateHeadOptions } from './shared/unhead.B4pP8_2D.mjs';
3
- export { u as useScript } from './shared/unhead.DcPrZw2e.mjs';
4
- import './shared/unhead.B7BBWq8B.mjs';
1
+ export { createHeadCore, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta } from './index.mjs';
2
+ import { p as Unhead, am as Head, C as CreateHeadOptions } from './shared/unhead.DwYyZgT5.mjs';
3
+ export { u as useScript } from './shared/unhead.Bg64fTJV.mjs';
4
+ import './shared/unhead.C1nwjySB.mjs';
5
5
  import 'hookable';
6
6
 
7
7
  declare const activeHead: {
package/dist/legacy.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { createHeadCore, useHead, useHeadSafe, useSeoMeta } from './index.js';
2
- import { p as Unhead, am as Head, C as CreateHeadOptions } from './shared/unhead.B4pP8_2D.js';
3
- export { u as useScript } from './shared/unhead.CES0yIUs.js';
4
- import './shared/unhead.D_YYNboR.js';
1
+ export { createHeadCore, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta } from './index.js';
2
+ import { p as Unhead, am as Head, C as CreateHeadOptions } from './shared/unhead.DwYyZgT5.js';
3
+ export { u as useScript } from './shared/unhead.C6vvMYCS.js';
4
+ import './shared/unhead.DtJaJIsF.js';
5
5
  import 'hookable';
6
6
 
7
7
  declare const activeHead: {
package/dist/legacy.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { c as createHeadCore } from './shared/unhead.x5NJGkxU.mjs';
1
+ import { c as createHeadCore } from './shared/unhead.kC9yNSGl.mjs';
2
2
  import { D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.9Qw6eOEM.mjs';
3
- export { u as useHead, a as useHeadSafe, b as useSeoMeta } from './shared/unhead.C2emW6l4.mjs';
3
+ export { u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/unhead.PEkM8z0l.mjs';
4
4
  export { u as useScript } from './shared/unhead.CG0hxuzW.mjs';
5
5
  import 'hookable';
6
6
  import './shared/unhead.xsi8MZXD.mjs';
@@ -1,4 +1,4 @@
1
- import { j as HeadPluginInput } from './shared/unhead.B4pP8_2D.mjs';
1
+ import { j as HeadPluginInput } from './shared/unhead.DwYyZgT5.mjs';
2
2
  import 'hookable';
3
3
 
4
4
  declare const AliasSortingPlugin: HeadPluginInput;
package/dist/plugins.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { j as HeadPluginInput } from './shared/unhead.B4pP8_2D.js';
1
+ import { j as HeadPluginInput } from './shared/unhead.DwYyZgT5.js';
2
2
  import 'hookable';
3
3
 
4
4
  declare const AliasSortingPlugin: HeadPluginInput;
package/dist/plugins.mjs CHANGED
@@ -56,14 +56,14 @@ function InferSeoMetaPlugin(options = {}) {
56
56
  tagPriority: "low"
57
57
  },
58
58
  {
59
- property: "og:title",
60
- content: "%infer",
61
- tagPriority: "low"
59
+ "property": "og:title",
60
+ "tagPriority": "low",
61
+ "data-infer": ""
62
62
  },
63
63
  {
64
- property: "og:description",
65
- content: "%infer",
66
- tagPriority: "low"
64
+ "property": "og:description",
65
+ "tagPriority": "low",
66
+ "data-infer": ""
67
67
  }
68
68
  ]
69
69
  });
@@ -74,7 +74,7 @@ function InferSeoMetaPlugin(options = {}) {
74
74
  let title = head._title || "";
75
75
  const titleTemplate = head._titleTemplate;
76
76
  const ogTitle = tagMap.get("meta:og:title");
77
- if (ogTitle?.props?.content === "%infer") {
77
+ if (typeof ogTitle?.props["data-infer"] !== "undefined") {
78
78
  if (titleTemplate) {
79
79
  title = typeof titleTemplate === "function" ? titleTemplate(title) : titleTemplate.replace("%s", title);
80
80
  }
@@ -82,7 +82,7 @@ function InferSeoMetaPlugin(options = {}) {
82
82
  }
83
83
  const description = tagMap.get("meta:description")?.props?.content;
84
84
  const ogDescription = tagMap.get("meta:og:description");
85
- if (ogDescription?.props?.content === "%infer") {
85
+ if (typeof ogDescription?.props["data-infer"] !== "undefined") {
86
86
  ogDescription.props.content = options.ogDescription ? options.ogDescription(description) : description || "";
87
87
  }
88
88
  }
@@ -1,6 +1,6 @@
1
- import { R as RecordingEntry } from './shared/unhead.B4pP8_2D.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.B4pP8_2D.mjs';
3
- export { u as useScript } from './shared/unhead.DcPrZw2e.mjs';
1
+ import { R as RecordingEntry } from './shared/unhead.DwYyZgT5.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.DwYyZgT5.mjs';
3
+ export { u as useScript } from './shared/unhead.Bg64fTJV.mjs';
4
4
  import 'hookable';
5
5
 
6
6
  declare function createSpyProxy<T extends Record<string, any> | any[]>(target: T, onApply: (stack: RecordingEntry[][]) => void): T;
package/dist/scripts.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { R as RecordingEntry } from './shared/unhead.B4pP8_2D.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.B4pP8_2D.js';
3
- export { u as useScript } from './shared/unhead.CES0yIUs.js';
1
+ import { R as RecordingEntry } from './shared/unhead.DwYyZgT5.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.DwYyZgT5.js';
3
+ export { u as useScript } from './shared/unhead.C6vvMYCS.js';
4
4
  import 'hookable';
5
5
 
6
6
  declare function createSpyProxy<T extends Record<string, any> | any[]>(target: T, onApply: (stack: RecordingEntry[][]) => void): T;
package/dist/server.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { am as Head, m as CreateServerHeadOptions, p as Unhead, s as RenderSSRHeadOptions, r as SSRHeadPayload, an as ResolvedHead, aB as HeadTag } from './shared/unhead.B4pP8_2D.mjs';
1
+ import { am as Head, m as CreateServerHeadOptions, p as Unhead, s as RenderSSRHeadOptions, r as SSRHeadPayload, an as ResolvedHead, aB as HeadTag } from './shared/unhead.DwYyZgT5.mjs';
2
2
  import 'hookable';
3
3
 
4
4
  declare function createHead<T = Head>(options?: CreateServerHeadOptions): Unhead<T>;
package/dist/server.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { am as Head, m as CreateServerHeadOptions, p as Unhead, s as RenderSSRHeadOptions, r as SSRHeadPayload, an as ResolvedHead, aB as HeadTag } from './shared/unhead.B4pP8_2D.js';
1
+ import { am as Head, m as CreateServerHeadOptions, p as Unhead, s as RenderSSRHeadOptions, r as SSRHeadPayload, an as ResolvedHead, aB as HeadTag } from './shared/unhead.DwYyZgT5.js';
2
2
  import 'hookable';
3
3
 
4
4
  declare function createHead<T = Head>(options?: CreateServerHeadOptions): Unhead<T>;
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createHeadCore } from './shared/unhead.x5NJGkxU.mjs';
1
+ import { c as createHeadCore } from './shared/unhead.kC9yNSGl.mjs';
2
2
  import { T as TagsWithInnerContent, S as SelfClosingTags$1 } from './shared/unhead.yem5I2v_.mjs';
3
3
  import 'hookable';
4
4
  import './shared/unhead.xsi8MZXD.mjs';
@@ -204,7 +204,7 @@ async function renderSSRHead(head, options) {
204
204
 
205
205
  async function transformHtmlTemplate(head, html, options) {
206
206
  const { html: parsedHtml, input } = extractUnheadInputFromHtml(html);
207
- head.entries.set(0, { _i: 0, input, options: {} });
207
+ head.push(input, { _index: 0 });
208
208
  const headHtml = await renderSSRHead(head, options);
209
209
  return parsedHtml.replace("<html>", `<html${headHtml.htmlAttrs}>`).replace("<body>", `<body>${headHtml.bodyTagsOpen ? `
210
210
  ${headHtml.bodyTagsOpen}` : ``}`).replace("<body>", `<body${headHtml.bodyAttrs}>`).replace("</head>", `${headHtml.headTags}</head>`).replace("</body>", `${headHtml.bodyTags}</body>`);
@@ -1,4 +1,4 @@
1
- import { p as Unhead, c as UseScriptInput, e as UseScriptOptions, f as UseScriptReturn } from './unhead.B4pP8_2D.mjs';
1
+ import { p as Unhead, c as UseScriptInput, e as UseScriptOptions, f as UseScriptReturn } from './unhead.DwYyZgT5.mjs';
2
2
 
3
3
  /**
4
4
  * Load third-party scripts with SSR support and a proxied API.
@@ -1,4 +1,4 @@
1
- import { am as Head, aL as ResolvableValue, aM as ResolvableProperties, L as LinkBase, G as DataKeys, O as SchemaAugmentations, _ as BaseMeta, a6 as Style, J as ScriptBase, a8 as Noscript, a9 as HtmlAttributes, aa as BodyAttributes } from './unhead.B4pP8_2D.mjs';
1
+ import { am as Head, aL as ResolvableValue, aM as ResolvableProperties, L as LinkBase, G as DataKeys, O as SchemaAugmentations, _ as BaseMeta, a6 as Style, J as ScriptBase, a8 as Noscript, a9 as HtmlAttributes, aa as BodyAttributes } from './unhead.DwYyZgT5.mjs';
2
2
 
3
3
  type SafeBodyAttr = ResolvableProperties<Pick<BodyAttributes, 'id' | 'class' | 'style'> & DataKeys & SchemaAugmentations['bodyAttrs']>;
4
4
  type SafeHtmlAttr = ResolvableProperties<Pick<HtmlAttributes, 'id' | 'class' | 'style' | 'lang' | 'dir'> & DataKeys & SchemaAugmentations['htmlAttrs']>;
@@ -1,4 +1,4 @@
1
- import { p as Unhead, c as UseScriptInput, e as UseScriptOptions, f as UseScriptReturn } from './unhead.B4pP8_2D.js';
1
+ import { p as Unhead, c as UseScriptInput, e as UseScriptOptions, f as UseScriptReturn } from './unhead.DwYyZgT5.js';
2
2
 
3
3
  /**
4
4
  * Load third-party scripts with SSR support and a proxied API.
@@ -1,4 +1,4 @@
1
- import { am as Head, aL as ResolvableValue, aM as ResolvableProperties, L as LinkBase, G as DataKeys, O as SchemaAugmentations, _ as BaseMeta, a6 as Style, J as ScriptBase, a8 as Noscript, a9 as HtmlAttributes, aa as BodyAttributes } from './unhead.B4pP8_2D.js';
1
+ import { am as Head, aL as ResolvableValue, aM as ResolvableProperties, L as LinkBase, G as DataKeys, O as SchemaAugmentations, _ as BaseMeta, a6 as Style, J as ScriptBase, a8 as Noscript, a9 as HtmlAttributes, aa as BodyAttributes } from './unhead.DwYyZgT5.js';
2
2
 
3
3
  type SafeBodyAttr = ResolvableProperties<Pick<BodyAttributes, 'id' | 'class' | 'style'> & DataKeys & SchemaAugmentations['bodyAttrs']>;
4
4
  type SafeHtmlAttr = ResolvableProperties<Pick<HtmlAttributes, 'id' | 'class' | 'style' | 'lang' | 'dir'> & DataKeys & SchemaAugmentations['htmlAttrs']>;
@@ -2191,7 +2191,7 @@ interface ActiveHeadEntry<Input> {
2191
2191
  /**
2192
2192
  * @internal
2193
2193
  */
2194
- _poll: () => void;
2194
+ _poll: (rm?: boolean) => void;
2195
2195
  }
2196
2196
  type PropResolver = (key: string, value: any, tag?: HeadTag) => any;
2197
2197
  interface CreateHeadOptions {
@@ -2233,12 +2233,19 @@ interface CreateClientHeadOptions extends CreateHeadOptions {
2233
2233
  domOptions?: DomPluginOptions;
2234
2234
  }
2235
2235
  interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplateParams, ResolvesDuplicates {
2236
+ /**
2237
+ * @deprecated Tree shaking should now be handled using import.meta.* if statements.
2238
+ */
2236
2239
  mode?: RuntimeMode;
2237
2240
  head?: Unhead;
2238
2241
  /**
2239
2242
  * @internal
2240
2243
  */
2241
2244
  _safe?: boolean;
2245
+ /**
2246
+ * @internal
2247
+ */
2248
+ _index?: number;
2242
2249
  }
2243
2250
  interface Unhead<Input = Head> {
2244
2251
  /**
@@ -2191,7 +2191,7 @@ interface ActiveHeadEntry<Input> {
2191
2191
  /**
2192
2192
  * @internal
2193
2193
  */
2194
- _poll: () => void;
2194
+ _poll: (rm?: boolean) => void;
2195
2195
  }
2196
2196
  type PropResolver = (key: string, value: any, tag?: HeadTag) => any;
2197
2197
  interface CreateHeadOptions {
@@ -2233,12 +2233,19 @@ interface CreateClientHeadOptions extends CreateHeadOptions {
2233
2233
  domOptions?: DomPluginOptions;
2234
2234
  }
2235
2235
  interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplateParams, ResolvesDuplicates {
2236
+ /**
2237
+ * @deprecated Tree shaking should now be handled using import.meta.* if statements.
2238
+ */
2236
2239
  mode?: RuntimeMode;
2237
2240
  head?: Unhead;
2238
2241
  /**
2239
2242
  * @internal
2240
2243
  */
2241
2244
  _safe?: boolean;
2245
+ /**
2246
+ * @internal
2247
+ */
2248
+ _index?: number;
2242
2249
  }
2243
2250
  interface Unhead<Input = Head> {
2244
2251
  /**
@@ -28,5 +28,17 @@ function useSeoMeta(unhead, input = {}, options) {
28
28
  }
29
29
  return entry;
30
30
  }
31
+ function useServerHead(unhead, input = {}, options = {}) {
32
+ options.mode = "server";
33
+ return unhead.push(input, options);
34
+ }
35
+ function useServerHeadSafe(unhead, input = {}, options = {}) {
36
+ options.mode = "server";
37
+ return useHeadSafe(unhead, input, { ...options, mode: "server" });
38
+ }
39
+ function useServerSeoMeta(unhead, input = {}, options) {
40
+ options.mode = "server";
41
+ return useSeoMeta(unhead, input, { ...options, mode: "server" });
42
+ }
31
43
 
32
- export { useHeadSafe as a, useSeoMeta as b, useHead as u };
44
+ export { useHeadSafe as a, useSeoMeta as b, useServerHead as c, useServerHeadSafe as d, useServerSeoMeta as e, useHead as u };
@@ -18,6 +18,7 @@ function createHeadCore(resolvedOptions = {}) {
18
18
  const ssr = !resolvedOptions.document;
19
19
  const entries = /* @__PURE__ */ new Map();
20
20
  const plugins = /* @__PURE__ */ new Map();
21
+ const normalizeQueue = [];
21
22
  const head = {
22
23
  _entryCount: 1,
23
24
  // 0 is reserved for internal use
@@ -34,25 +35,24 @@ function createHeadCore(resolvedOptions = {}) {
34
35
  push(input, _options = {}) {
35
36
  const options = { ..._options };
36
37
  delete options.head;
37
- const _i = head._entryCount++;
38
+ const _i = _options._index ?? head._entryCount++;
39
+ const inst = { _i, input, options };
38
40
  const _ = {
39
- _poll() {
41
+ _poll(rm = false) {
40
42
  head.dirty = true;
43
+ !rm && normalizeQueue.push(_i);
41
44
  hooks.callHook("entries:updated", head);
42
45
  },
43
46
  dispose() {
44
47
  if (entries.delete(_i)) {
45
- _._poll();
48
+ _._poll(true);
46
49
  }
47
50
  },
48
51
  // a patch is the same as creating a new entry, just a nice DX
49
52
  patch(input2) {
50
53
  if (!options.mode || options.mode === "server" && ssr || options.mode === "client" && !ssr) {
51
- entries.set(_i, {
52
- _i,
53
- input: input2,
54
- options
55
- });
54
+ inst.input = input2;
55
+ entries.set(_i, inst);
56
56
  _._poll();
57
57
  }
58
58
  }
@@ -67,22 +67,25 @@ function createHeadCore(resolvedOptions = {}) {
67
67
  entries: [...head.entries.values()]
68
68
  };
69
69
  await hooks.callHook("entries:resolve", ctx);
70
- const allTags = [];
71
- let hasFlatMeta = false;
72
- for (const e of ctx.entries) {
73
- const normalizeCtx = {
74
- tags: normalizeEntryToTags(e.input, resolvedOptions.propResolvers || []).map((t) => Object.assign(t, e.options)),
75
- entry: e
76
- };
77
- await hooks.callHook("entries:normalize", normalizeCtx);
78
- allTags.push(...normalizeCtx.tags.map((t, i) => {
79
- t._w = tagWeight(head, t);
80
- t._p = (e._i << 10) + i;
81
- t._d = dedupeKey(t);
82
- return t;
83
- }));
70
+ while (normalizeQueue.length) {
71
+ const i = normalizeQueue.shift();
72
+ const e = entries.get(i);
73
+ if (e) {
74
+ const normalizeCtx = {
75
+ tags: normalizeEntryToTags(e.input, resolvedOptions.propResolvers || []).map((t) => Object.assign(t, e.options)),
76
+ entry: e
77
+ };
78
+ await hooks.callHook("entries:normalize", normalizeCtx);
79
+ e._tags = normalizeCtx.tags.map((t, i2) => {
80
+ t._w = tagWeight(head, t);
81
+ t._p = (e._i << 10) + i2;
82
+ t._d = dedupeKey(t);
83
+ return t;
84
+ });
85
+ }
84
86
  }
85
- allTags.sort(sortTags).reduce((acc, next) => {
87
+ let hasFlatMeta = false;
88
+ ctx.entries.flatMap((e) => e._tags || []).sort(sortTags).reduce((acc, next) => {
86
89
  const k = String(next._d || next._p);
87
90
  if (!acc.has(k))
88
91
  return acc.set(k, next);
package/dist/types.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- export { l as ActiveHeadEntry, aF as Arrayable, A as AsVoidFunctions, a3 as Base, V as BaseBodyAttr, X as BaseHtmlAttr, _ as BaseMeta, Y as BodyAttr, aa as BodyAttributes, F as BodyEvents, aD as Booleanable, n as CreateClientHeadOptions, C as CreateHeadOptions, m as CreateServerHeadOptions, G as DataKeys, aO as DeepResolvableProperties, aG as DefinedValueOrEmptyObject, v as DomBeforeRenderCtx, B as DomPluginOptions, u as DomRenderTagContext, D as DomState, $ as EntryAugmentation, t as EntryResolveCtx, E as EventHandlerOptions, aK as Falsey, aA as HasTemplateParams, am as Head, H as HeadEntry, o as HeadEntryOptions, y as HeadHooks, k as HeadPlugin, j as HeadPluginInput, i as HeadPluginOptions, aB as HeadTag, aC as HeadTagKeys, al as HeadUtils, q as HookResult, Z as HtmlAttr, a9 as HtmlAttributes, I as HttpEventAttributes, au as InnerContent, at as InnerContentVal, a4 as Link, L as LinkBase, T as MaybeArray, a0 as MaybeEventFnHandlers, aH as Merge, aI as MergeHead, a5 as Meta, M as MetaFlatInput, aJ as Never, a8 as Noscript, az as ProcessesTemplateParams, P as PropResolver, R as RecordingEntry, z as RenderDomHeadOptions, s as RenderSSRHeadOptions, aM as ResolvableProperties, aN as ResolvableUnion, aL as ResolvableValue, ad as ResolvedBase, ak as ResolvedBodyAttributes, an as ResolvedHead, aj as ResolvedHtmlAttributes, ae as ResolvedLink, af as ResolvedMeta, ai as ResolvedNoscript, Q as ResolvedSchemaAugmentations, ah as ResolvedScript, ag as ResolvedStyle, ab as ResolvedTitle, ac as ResolvedTitleTemplate, aq as ResolvesDuplicates, h as RuntimeMode, r as SSRHeadPayload, x as SSRRenderContext, O as SchemaAugmentations, a7 as Script, J as ScriptBase, S as ScriptInstance, w as ShouldRenderContext, g as SideEffectsRecord, aE as Stringable, a6 as Style, ax as TagKey, as as TagPosition, av as TagPriority, aw as TagUserProperties, ay as TemplateParams, a1 as Title, a2 as TitleTemplate, p as Unhead, d as UseFunctionType, ap as UseHeadInput, a as UseScriptContext, c as UseScriptInput, e as UseScriptOptions, b as UseScriptResolvedInput, f as UseScriptReturn, U as UseScriptStatus, ao as UseSeoMetaInput, N as UserAttributesConfig, K as UserTagConfigWithoutInnerContent, ar as ValidTagPositions, W as WarmupStrategy } from './shared/unhead.B4pP8_2D.mjs';
2
- export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle } from './shared/unhead.B7BBWq8B.mjs';
3
- export { u as useScript } from './shared/unhead.DcPrZw2e.mjs';
1
+ export { l as ActiveHeadEntry, aF as Arrayable, A as AsVoidFunctions, a3 as Base, V as BaseBodyAttr, X as BaseHtmlAttr, _ as BaseMeta, Y as BodyAttr, aa as BodyAttributes, F as BodyEvents, aD as Booleanable, n as CreateClientHeadOptions, C as CreateHeadOptions, m as CreateServerHeadOptions, G as DataKeys, aO as DeepResolvableProperties, aG as DefinedValueOrEmptyObject, v as DomBeforeRenderCtx, B as DomPluginOptions, u as DomRenderTagContext, D as DomState, $ as EntryAugmentation, t as EntryResolveCtx, E as EventHandlerOptions, aK as Falsey, aA as HasTemplateParams, am as Head, H as HeadEntry, o as HeadEntryOptions, y as HeadHooks, k as HeadPlugin, j as HeadPluginInput, i as HeadPluginOptions, aB as HeadTag, aC as HeadTagKeys, al as HeadUtils, q as HookResult, Z as HtmlAttr, a9 as HtmlAttributes, I as HttpEventAttributes, au as InnerContent, at as InnerContentVal, a4 as Link, L as LinkBase, T as MaybeArray, a0 as MaybeEventFnHandlers, aH as Merge, aI as MergeHead, a5 as Meta, M as MetaFlatInput, aJ as Never, a8 as Noscript, az as ProcessesTemplateParams, P as PropResolver, R as RecordingEntry, z as RenderDomHeadOptions, s as RenderSSRHeadOptions, aM as ResolvableProperties, aN as ResolvableUnion, aL as ResolvableValue, ad as ResolvedBase, ak as ResolvedBodyAttributes, an as ResolvedHead, aj as ResolvedHtmlAttributes, ae as ResolvedLink, af as ResolvedMeta, ai as ResolvedNoscript, Q as ResolvedSchemaAugmentations, ah as ResolvedScript, ag as ResolvedStyle, ab as ResolvedTitle, ac as ResolvedTitleTemplate, aq as ResolvesDuplicates, h as RuntimeMode, r as SSRHeadPayload, x as SSRRenderContext, O as SchemaAugmentations, a7 as Script, J as ScriptBase, S as ScriptInstance, w as ShouldRenderContext, g as SideEffectsRecord, aE as Stringable, a6 as Style, ax as TagKey, as as TagPosition, av as TagPriority, aw as TagUserProperties, ay as TemplateParams, a1 as Title, a2 as TitleTemplate, p as Unhead, d as UseFunctionType, ap as UseHeadInput, a as UseScriptContext, c as UseScriptInput, e as UseScriptOptions, b as UseScriptResolvedInput, f as UseScriptReturn, U as UseScriptStatus, ao as UseSeoMetaInput, N as UserAttributesConfig, K as UserTagConfigWithoutInnerContent, ar as ValidTagPositions, W as WarmupStrategy } from './shared/unhead.DwYyZgT5.mjs';
2
+ export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle } from './shared/unhead.C1nwjySB.mjs';
3
+ export { u as useScript } from './shared/unhead.Bg64fTJV.mjs';
4
4
  export { createSpyProxy } from './scripts.mjs';
5
5
  import 'hookable';
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { l as ActiveHeadEntry, aF as Arrayable, A as AsVoidFunctions, a3 as Base, V as BaseBodyAttr, X as BaseHtmlAttr, _ as BaseMeta, Y as BodyAttr, aa as BodyAttributes, F as BodyEvents, aD as Booleanable, n as CreateClientHeadOptions, C as CreateHeadOptions, m as CreateServerHeadOptions, G as DataKeys, aO as DeepResolvableProperties, aG as DefinedValueOrEmptyObject, v as DomBeforeRenderCtx, B as DomPluginOptions, u as DomRenderTagContext, D as DomState, $ as EntryAugmentation, t as EntryResolveCtx, E as EventHandlerOptions, aK as Falsey, aA as HasTemplateParams, am as Head, H as HeadEntry, o as HeadEntryOptions, y as HeadHooks, k as HeadPlugin, j as HeadPluginInput, i as HeadPluginOptions, aB as HeadTag, aC as HeadTagKeys, al as HeadUtils, q as HookResult, Z as HtmlAttr, a9 as HtmlAttributes, I as HttpEventAttributes, au as InnerContent, at as InnerContentVal, a4 as Link, L as LinkBase, T as MaybeArray, a0 as MaybeEventFnHandlers, aH as Merge, aI as MergeHead, a5 as Meta, M as MetaFlatInput, aJ as Never, a8 as Noscript, az as ProcessesTemplateParams, P as PropResolver, R as RecordingEntry, z as RenderDomHeadOptions, s as RenderSSRHeadOptions, aM as ResolvableProperties, aN as ResolvableUnion, aL as ResolvableValue, ad as ResolvedBase, ak as ResolvedBodyAttributes, an as ResolvedHead, aj as ResolvedHtmlAttributes, ae as ResolvedLink, af as ResolvedMeta, ai as ResolvedNoscript, Q as ResolvedSchemaAugmentations, ah as ResolvedScript, ag as ResolvedStyle, ab as ResolvedTitle, ac as ResolvedTitleTemplate, aq as ResolvesDuplicates, h as RuntimeMode, r as SSRHeadPayload, x as SSRRenderContext, O as SchemaAugmentations, a7 as Script, J as ScriptBase, S as ScriptInstance, w as ShouldRenderContext, g as SideEffectsRecord, aE as Stringable, a6 as Style, ax as TagKey, as as TagPosition, av as TagPriority, aw as TagUserProperties, ay as TemplateParams, a1 as Title, a2 as TitleTemplate, p as Unhead, d as UseFunctionType, ap as UseHeadInput, a as UseScriptContext, c as UseScriptInput, e as UseScriptOptions, b as UseScriptResolvedInput, f as UseScriptReturn, U as UseScriptStatus, ao as UseSeoMetaInput, N as UserAttributesConfig, K as UserTagConfigWithoutInnerContent, ar as ValidTagPositions, W as WarmupStrategy } from './shared/unhead.B4pP8_2D.js';
2
- export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle } from './shared/unhead.D_YYNboR.js';
3
- export { u as useScript } from './shared/unhead.CES0yIUs.js';
1
+ export { l as ActiveHeadEntry, aF as Arrayable, A as AsVoidFunctions, a3 as Base, V as BaseBodyAttr, X as BaseHtmlAttr, _ as BaseMeta, Y as BodyAttr, aa as BodyAttributes, F as BodyEvents, aD as Booleanable, n as CreateClientHeadOptions, C as CreateHeadOptions, m as CreateServerHeadOptions, G as DataKeys, aO as DeepResolvableProperties, aG as DefinedValueOrEmptyObject, v as DomBeforeRenderCtx, B as DomPluginOptions, u as DomRenderTagContext, D as DomState, $ as EntryAugmentation, t as EntryResolveCtx, E as EventHandlerOptions, aK as Falsey, aA as HasTemplateParams, am as Head, H as HeadEntry, o as HeadEntryOptions, y as HeadHooks, k as HeadPlugin, j as HeadPluginInput, i as HeadPluginOptions, aB as HeadTag, aC as HeadTagKeys, al as HeadUtils, q as HookResult, Z as HtmlAttr, a9 as HtmlAttributes, I as HttpEventAttributes, au as InnerContent, at as InnerContentVal, a4 as Link, L as LinkBase, T as MaybeArray, a0 as MaybeEventFnHandlers, aH as Merge, aI as MergeHead, a5 as Meta, M as MetaFlatInput, aJ as Never, a8 as Noscript, az as ProcessesTemplateParams, P as PropResolver, R as RecordingEntry, z as RenderDomHeadOptions, s as RenderSSRHeadOptions, aM as ResolvableProperties, aN as ResolvableUnion, aL as ResolvableValue, ad as ResolvedBase, ak as ResolvedBodyAttributes, an as ResolvedHead, aj as ResolvedHtmlAttributes, ae as ResolvedLink, af as ResolvedMeta, ai as ResolvedNoscript, Q as ResolvedSchemaAugmentations, ah as ResolvedScript, ag as ResolvedStyle, ab as ResolvedTitle, ac as ResolvedTitleTemplate, aq as ResolvesDuplicates, h as RuntimeMode, r as SSRHeadPayload, x as SSRRenderContext, O as SchemaAugmentations, a7 as Script, J as ScriptBase, S as ScriptInstance, w as ShouldRenderContext, g as SideEffectsRecord, aE as Stringable, a6 as Style, ax as TagKey, as as TagPosition, av as TagPriority, aw as TagUserProperties, ay as TemplateParams, a1 as Title, a2 as TitleTemplate, p as Unhead, d as UseFunctionType, ap as UseHeadInput, a as UseScriptContext, c as UseScriptInput, e as UseScriptOptions, b as UseScriptResolvedInput, f as UseScriptReturn, U as UseScriptStatus, ao as UseSeoMetaInput, N as UserAttributesConfig, K as UserTagConfigWithoutInnerContent, ar as ValidTagPositions, W as WarmupStrategy } from './shared/unhead.DwYyZgT5.js';
2
+ export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle } from './shared/unhead.DtJaJIsF.js';
3
+ export { u as useScript } from './shared/unhead.C6vvMYCS.js';
4
4
  export { createSpyProxy } from './scripts.js';
5
5
  import 'hookable';
package/dist/utils.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { aB as HeadTag, _ as BaseMeta, aP as ResolvedMetaFlat, am as Head, P as PropResolver, p as Unhead, ay as TemplateParams } from './shared/unhead.B4pP8_2D.mjs';
1
+ import { aB as HeadTag, _ as BaseMeta, aP as ResolvedMetaFlat, am as Head, P as PropResolver, p as Unhead, ay as TemplateParams } from './shared/unhead.DwYyZgT5.mjs';
2
2
  import 'hookable';
3
3
 
4
4
  declare const SelfClosingTags: Set<string>;
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { aB as HeadTag, _ as BaseMeta, aP as ResolvedMetaFlat, am as Head, P as PropResolver, p as Unhead, ay as TemplateParams } from './shared/unhead.B4pP8_2D.js';
1
+ import { aB as HeadTag, _ as BaseMeta, aP as ResolvedMetaFlat, am as Head, P as PropResolver, p as Unhead, ay as TemplateParams } from './shared/unhead.DwYyZgT5.js';
2
2
  import 'hookable';
3
3
 
4
4
  declare const SelfClosingTags: Set<string>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "2.0.0-alpha.22",
4
+ "version": "2.0.0-alpha.23",
5
5
  "description": "Full-stack <head> manager built for any framework.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",