unhead 3.1.5 → 3.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/client.d.mts +5 -6
  2. package/dist/client.d.ts +5 -6
  3. package/dist/client.mjs +7 -12
  4. package/dist/index.d.mts +3 -3
  5. package/dist/index.d.ts +3 -3
  6. package/dist/index.mjs +15 -10
  7. package/dist/legacy.d.mts +2 -2
  8. package/dist/legacy.d.ts +2 -2
  9. package/dist/legacy.mjs +9 -9
  10. package/dist/parser.mjs +11 -7
  11. package/dist/plugins.d.mts +2 -2
  12. package/dist/plugins.d.ts +2 -2
  13. package/dist/plugins.mjs +7 -7
  14. package/dist/scripts.d.mts +3 -3
  15. package/dist/scripts.d.ts +3 -3
  16. package/dist/scripts.mjs +2 -3
  17. package/dist/server.d.mts +3 -3
  18. package/dist/server.d.ts +3 -3
  19. package/dist/server.mjs +5 -5
  20. package/dist/shared/{unhead.fg-0ge_u.mjs → unhead.1eoQpFT1.mjs} +6 -1
  21. package/dist/shared/{unhead.CRVUlr67.d.mts → unhead.BIArU35P.d.mts} +1 -1
  22. package/dist/shared/{unhead.BSqa2bYq.mjs → unhead.BNhb5t7_.mjs} +4 -6
  23. package/dist/shared/{unhead.BeIvDlYY.d.mts → unhead.BZy3nXHx.d.mts} +1 -1
  24. package/dist/shared/{unhead.DvIxXxuO.mjs → unhead.Bm4Y6XQI.mjs} +3 -0
  25. package/dist/shared/{unhead.B37CPNIq.d.mts → unhead.Bx2bAQEg.d.mts} +1 -1
  26. package/dist/shared/{unhead.D-W0R71w.mjs → unhead.C-RMAxyM.mjs} +27 -38
  27. package/dist/shared/{unhead.CS8tFxG3.d.mts → unhead.CELAVVhh.d.mts} +3 -5
  28. package/dist/shared/unhead.CHEy9ana.mjs +7 -0
  29. package/dist/shared/{unhead.BhvKU-Uu.d.ts → unhead.CN7FHaDF.d.ts} +1 -1
  30. package/dist/shared/{unhead.H5gLMTHA.mjs → unhead.CR32jx68.mjs} +125 -35
  31. package/dist/shared/{unhead.CBkhoTGw.mjs → unhead.CT1xoGPh.mjs} +1 -1
  32. package/dist/shared/unhead.CaGVnLUe.mjs +231 -0
  33. package/dist/shared/{unhead.YBmQyFpm.d.ts → unhead.Cnhe7n9-.d.ts} +1 -1
  34. package/dist/shared/{unhead.Blkhu0Cr.d.ts → unhead.DQadHCLi.d.ts} +1 -1
  35. package/dist/shared/{unhead.CBj56GgY.d.ts → unhead.Dv-MkoX9.d.ts} +3 -5
  36. package/dist/shared/{unhead.CfgPMHXt.mjs → unhead.WK9wg_ep.mjs} +2 -0
  37. package/dist/shared/{unhead.Doc2Fa-a.mjs → unhead.YIW3bMYK.mjs} +64 -33
  38. package/dist/shared/{unhead.BZYKjYpn.mjs → unhead.b15Kg1OH.mjs} +3 -3
  39. package/dist/shared/{unhead.J7mPNB3E.mjs → unhead.tpXvlPwt.mjs} +53 -34
  40. package/dist/shared/{unhead.BWKj-eGY.d.ts → unhead.xa1ebPBp.d.ts} +1 -1
  41. package/dist/shared/{unhead.BO2PdEL4.d.mts → unhead.zyZmXwAG.d.mts} +1 -1
  42. package/dist/stream/client.d.mts +2 -2
  43. package/dist/stream/client.d.ts +2 -2
  44. package/dist/stream/client.mjs +3 -8
  45. package/dist/stream/iife.d.cts +2 -0
  46. package/dist/stream/iife.global.js +1 -1
  47. package/dist/stream/iife.mjs +2 -2
  48. package/dist/stream/server.d.mts +2 -2
  49. package/dist/stream/server.d.ts +2 -2
  50. package/dist/stream/server.mjs +5 -5
  51. package/dist/stream/unplugin.d.mts +5 -1
  52. package/dist/stream/unplugin.d.ts +5 -1
  53. package/dist/stream/unplugin.mjs +29 -7
  54. package/dist/types.d.mts +2 -2
  55. package/dist/types.d.ts +2 -2
  56. package/dist/utils.d.mts +1 -1
  57. package/dist/utils.d.ts +1 -1
  58. package/dist/utils.mjs +4 -4
  59. package/package.json +3 -3
  60. package/dist/shared/unhead.CT3gGqve.mjs +0 -154
  61. package/dist/shared/unhead.CUXLLRtV.mjs +0 -5
@@ -1,11 +1,11 @@
1
1
  import { parseHtmlForIndexes, applyHeadToHtml } from '../parser.mjs';
2
- import { c as createHead } from '../shared/unhead.D-W0R71w.mjs';
2
+ import { c as createHead } from '../shared/unhead.C-RMAxyM.mjs';
3
3
  import { DEFAULT_STREAM_KEY } from './client.mjs';
4
- import '../shared/unhead.CfgPMHXt.mjs';
5
- import '../shared/unhead.DvIxXxuO.mjs';
4
+ import '../shared/unhead.WK9wg_ep.mjs';
5
+ import '../shared/unhead.Bm4Y6XQI.mjs';
6
6
  import 'hookable';
7
- import '../shared/unhead.H5gLMTHA.mjs';
8
- import '../shared/unhead.fg-0ge_u.mjs';
7
+ import '../shared/unhead.CR32jx68.mjs';
8
+ import '../shared/unhead.1eoQpFT1.mjs';
9
9
 
10
10
  const LT_RE = /</g;
11
11
  const GT_RE = />/g;
@@ -15,6 +15,8 @@ interface StreamingPluginOptions {
15
15
  * source-level AST injection (React/Solid/Svelte). Vue does not use it.
16
16
  */
17
17
  filter?: RegExp;
18
+ /** Optional source-code prefilter for transform hooks. */
19
+ codeFilter?: RegExp;
18
20
  /** Transform handler called for files matching `filter`. */
19
21
  transform?: (code: string, id: string, options?: {
20
22
  ssr?: boolean;
@@ -66,7 +68,9 @@ interface StreamingPluginOptions {
66
68
  * - vite dev (v6+ environments): `this.environment.name === 'ssr'` per-transform
67
69
  * - webpack/rspack: `compiler.options.name === 'server'` or `target === 'node'`
68
70
  */
69
- declare function buildStreamingPluginOptions(options: StreamingPluginOptions): UnpluginOptions;
71
+ declare function buildStreamingPluginOptions(options: StreamingPluginOptions, meta?: {
72
+ framework?: string;
73
+ }): UnpluginOptions;
70
74
  /**
71
75
  * Internal cross-bundler unplugin factory. Framework wrappers pick a single bundler's
72
76
  * output (`.vite`, `.webpack`, `.rspack`, etc.) to expose via their own subpath export.
@@ -15,6 +15,8 @@ interface StreamingPluginOptions {
15
15
  * source-level AST injection (React/Solid/Svelte). Vue does not use it.
16
16
  */
17
17
  filter?: RegExp;
18
+ /** Optional source-code prefilter for transform hooks. */
19
+ codeFilter?: RegExp;
18
20
  /** Transform handler called for files matching `filter`. */
19
21
  transform?: (code: string, id: string, options?: {
20
22
  ssr?: boolean;
@@ -66,7 +68,9 @@ interface StreamingPluginOptions {
66
68
  * - vite dev (v6+ environments): `this.environment.name === 'ssr'` per-transform
67
69
  * - webpack/rspack: `compiler.options.name === 'server'` or `target === 'node'`
68
70
  */
69
- declare function buildStreamingPluginOptions(options: StreamingPluginOptions): UnpluginOptions;
71
+ declare function buildStreamingPluginOptions(options: StreamingPluginOptions, meta?: {
72
+ framework?: string;
73
+ }): UnpluginOptions;
70
74
  /**
71
75
  * Internal cross-bundler unplugin factory. Framework wrappers pick a single bundler's
72
76
  * output (`.vite`, `.webpack`, `.rspack`, etc.) to expose via their own subpath export.
@@ -27,7 +27,7 @@ function buildClientStub(framework, streamKey, warnOnMissing) {
27
27
  return `import{createHead}from'${framework}/client'
28
28
  const s=window[${key}];if(s){const q=s._q;s._q=[];const h=createHead({document});q.forEach(e=>h.push(e));s.push=e=>h.push(e);s._head=h}${warnBranch}`;
29
29
  }
30
- function buildStreamingPluginOptions(options) {
30
+ function buildStreamingPluginOptions(options, meta = {}) {
31
31
  const {
32
32
  framework,
33
33
  name,
@@ -37,6 +37,7 @@ function buildStreamingPluginOptions(options) {
37
37
  warnOnMissingServerBootstrap
38
38
  } = options;
39
39
  const state = {
40
+ isVite: meta.framework === "vite",
40
41
  isBuild: false,
41
42
  ssr: false
42
43
  };
@@ -47,15 +48,31 @@ function buildStreamingPluginOptions(options) {
47
48
  function warnEnabled() {
48
49
  return warnOnMissingServerBootstrap ?? !state.isBuild;
49
50
  }
51
+ function resolveEmittedIifePath(hookThis, ctx) {
52
+ const ref = state.emittedIifeFileId;
53
+ if (!ref)
54
+ return;
55
+ for (const asset of Object.values(ctx?.bundle || {})) {
56
+ if (asset?.type === "asset" && asset.fileName && (asset.name === "unhead-streaming.js" || asset.names?.includes("unhead-streaming.js")))
57
+ return asset.fileName;
58
+ }
59
+ if (typeof hookThis?.getFileName === "function") {
60
+ const fileName = hookThis.getFileName(ref);
61
+ if (fileName && fileName !== ref)
62
+ return fileName;
63
+ }
64
+ }
50
65
  return {
51
66
  name: name ?? `${framework}:streaming`,
52
67
  enforce: "pre",
53
68
  async buildStart() {
69
+ if (!state.isVite || mode === "module")
70
+ return;
54
71
  await loadIifeCode();
55
72
  if (mode === "async" && state.isBuild && typeof this.emitFile === "function") {
56
73
  if (!iifeCode)
57
74
  throw new Error("[unhead] Streaming IIFE not built. Run `pnpm build` in packages/unhead first.");
58
- state.emittedIifeFileName = this.emitFile({
75
+ state.emittedIifeFileId = this.emitFile({
59
76
  type: "asset",
60
77
  name: "unhead-streaming.js",
61
78
  source: iifeCode
@@ -67,7 +84,7 @@ function buildStreamingPluginOptions(options) {
67
84
  handler(id) {
68
85
  if (id === VIRTUAL_CLIENT_ID || id === `/${VIRTUAL_CLIENT_ID}`)
69
86
  return RESOLVED_ID;
70
- if (id === VIRTUAL_IIFE_ID || id === `/${VIRTUAL_IIFE_ID}`)
87
+ if (state.isVite && (id === VIRTUAL_IIFE_ID || id === `/${VIRTUAL_IIFE_ID}`))
71
88
  return RESOLVED_IIFE_ID;
72
89
  }
73
90
  },
@@ -84,6 +101,8 @@ function buildStreamingPluginOptions(options) {
84
101
  };
85
102
  }
86
103
  if (id === RESOLVED_IIFE_ID) {
104
+ if (!state.isVite)
105
+ return;
87
106
  if (isSSR)
88
107
  return { code: "", moduleType: "js" };
89
108
  if (!iifeCode)
@@ -94,7 +113,7 @@ function buildStreamingPluginOptions(options) {
94
113
  },
95
114
  ...options.transform && options.filter ? {
96
115
  transform: {
97
- filter: { id: options.filter },
116
+ filter: options.codeFilter ? { id: options.filter, code: options.codeFilter } : { id: options.filter },
98
117
  handler(code, id, opts) {
99
118
  return options.transform(code, id, { ssr: isSSRCall(this, opts) });
100
119
  }
@@ -112,6 +131,7 @@ function buildStreamingPluginOptions(options) {
112
131
  },
113
132
  vite: {
114
133
  apply(_config, env) {
134
+ state.isVite = true;
115
135
  if (env.isSsrBuild)
116
136
  state.ssr = true;
117
137
  if (env.command === "build")
@@ -119,6 +139,7 @@ function buildStreamingPluginOptions(options) {
119
139
  return true;
120
140
  },
121
141
  configResolved(config) {
142
+ state.isVite = true;
122
143
  if (config.command === "build")
123
144
  state.isBuild = true;
124
145
  },
@@ -129,7 +150,7 @@ function buildStreamingPluginOptions(options) {
129
150
  // full Vite plugin pipeline (resolveId/load) and aren't stripped or
130
151
  // rewritten by downstream HTML transforms.
131
152
  order: "pre",
132
- handler() {
153
+ handler(_html, ctx) {
133
154
  const nonceValue = resolveNonce(nonce);
134
155
  const nonceAttr = nonceValue ? { nonce: nonceValue } : {};
135
156
  if (mode === "inline") {
@@ -143,7 +164,8 @@ function buildStreamingPluginOptions(options) {
143
164
  }];
144
165
  }
145
166
  if (mode === "async") {
146
- const src = state.isBuild && state.emittedIifeFileName ? `/${state.emittedIifeFileName}` : `/${VIRTUAL_IIFE_ID}`;
167
+ const fileName = state.isBuild ? resolveEmittedIifePath(this, ctx) : void 0;
168
+ const src = fileName ? `/${fileName}` : `/${VIRTUAL_IIFE_ID}`;
147
169
  return [{
148
170
  tag: "script",
149
171
  attrs: { ...nonceAttr, async: true, src },
@@ -161,6 +183,6 @@ function buildStreamingPluginOptions(options) {
161
183
  }
162
184
  };
163
185
  }
164
- const createStreamingPlugin = createUnplugin(buildStreamingPluginOptions);
186
+ const createStreamingPlugin = /* @__PURE__ */ createUnplugin(buildStreamingPluginOptions);
165
187
 
166
188
  export { VIRTUAL_CLIENT_ID, VIRTUAL_IIFE_ID, buildStreamingPluginOptions, createStreamingPlugin };
package/dist/types.d.mts CHANGED
@@ -1,10 +1,10 @@
1
- export { A as ActiveHeadEntry, g as AsVoidFunctions, d as ClientHeadHooks, h as CoreHeadHooks, C as CreateClientHeadOptions, c as CreateHeadOptions, a as CreateServerHeadOptions, e as CreateStreamableServerHeadOptions, D as DOMHeadHooks, i as DomBeforeRenderCtx, j as DomRenderTagContext, k as DomState, E as EntryResolveCtx, l as EventHandlerOptions, m as HeadEntry, n as HeadEntryOptions, o as HeadHooks, p as HeadPlugin, H as HeadPluginInput, q as HeadPluginOptions, b as HeadRenderer, r as HookResult, P as PropResolver, R as RecordingEntry, s as RenderSSRHeadOptions, t as SSRHeadHooks, S as SSRHeadPayload, u as SSRRenderContext, v as ScriptInstance, f as ServerHeadHooks, w as ShouldRenderContext, x as SideEffectsRecord, y as SyncHookResult, U as Unhead, z as UseFunctionType, B as UseScriptContext, F as UseScriptInput, G as UseScriptOptions, I as UseScriptResolvedInput, J as UseScriptReturn, K as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.CS8tFxG3.mjs';
1
+ export { A as ActiveHeadEntry, g as AsVoidFunctions, d as ClientHeadHooks, h as CoreHeadHooks, C as CreateClientHeadOptions, c as CreateHeadOptions, a as CreateServerHeadOptions, e as CreateStreamableServerHeadOptions, D as DOMHeadHooks, i as DomBeforeRenderCtx, j as DomRenderTagContext, k as DomState, E as EntryResolveCtx, l as EventHandlerOptions, m as HeadEntry, n as HeadEntryOptions, o as HeadHooks, p as HeadPlugin, H as HeadPluginInput, q as HeadPluginOptions, b as HeadRenderer, r as HookResult, P as PropResolver, R as RecordingEntry, s as RenderSSRHeadOptions, t as SSRHeadHooks, S as SSRHeadPayload, u as SSRRenderContext, v as ScriptInstance, f as ServerHeadHooks, w as ShouldRenderContext, x as SideEffectsRecord, y as SyncHookResult, U as Unhead, z as UseFunctionType, B as UseScriptContext, F as UseScriptInput, G as UseScriptOptions, I as UseScriptResolvedInput, J as UseScriptReturn, K as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.CELAVVhh.mjs';
2
2
  export { R as RenderDomHeadOptions } from './shared/unhead.GpD0t1jW.mjs';
3
3
  export { B as Base, a as BodyAttributes, H as HeadSafe, b as HtmlAttributes, N as Noscript, S as SafeBodyAttr, c as SafeHtmlAttr, d as SafeLink, e as SafeMeta, f as SafeNoscript, g as SafeScript, h as SafeStyle, i as Style } from './shared/unhead.CpKzP6LT.mjs';
4
4
  import { B as Booleanable } from './shared/unhead.Dl7UHSN0.mjs';
5
5
  export { A as AlternateFeedLink, a as AlternateLanguageLink, b as AlternateLink, c as AlternateMediaLink, d as AlternateStylesheetLink, e as AmpHtmlLink, f as AppleTouchIconLink, g as AppleTouchStartupImageLink, h as ApplicationJsonScript, i as Arrayable, j as AuthorLink, k as BareAlternateLink, l as BodyAttributesWithoutEvents, m as BodyEvents, C as CanonicalLink, n as CharsetMeta, o as CompressionDictionaryLink, D as DataKeys, p as DeepReadonly, q as DeepResolvableProperties, r as DnsPrefetchLink, E as ExpectLink, s as ExternalScript, F as FaviconLink, G as GenericLink, t as GenericScript, u as GlobalAttributes, H as HasTemplateParams, v as HeadTag, w as HeadTagKeys, x as HelpLink, y as HttpEquivMeta, z as HttpEventAttributes, I as HubLink, J as IconLink, K as ImportMapConfig, L as ImportMapScript, M as InferLink, N as InferScript, O as InlineModuleScript, P as InlineScript, Q as InnerContent, T as InnerContentVal, U as InternalTagKey, V as JsonLdScript, W as KnownLinkRel, X as KnownScriptType, Y as LicenseLink, Z as Link, _ as LinkBase, $ as LinkHttpEvents, a0 as ManifestLink, a1 as MaskIconLink, a2 as MaybeArray, a3 as MaybeEventFnHandlers, a4 as MeLink, a5 as Meta, a6 as MetaBase, a7 as MetaFlat, a8 as MetaGeneric, a9 as MetaNames, aa as MetaProperties, ab as ModuleScript, ac as ModulepreloadLink, ad as NameMeta, ae as Never, af as NextLink, ag as PingbackLink, ah as PreconnectLink, ai as PrefetchLink, aj as PreloadFontLink, ak as PreloadImageLink, al as PreloadLink, am as PreloadLinkBase, an as PreloadOtherLink, ao as PreloadScriptLink, ap as PreloadStyleLink, aq as PrerenderLink, ar as PrevLink, as as PrivacyPolicyLink, at as ProcessesTemplateParams, au as PropertyMeta, av as RawInput, aw as ResolvableBase, ax as ResolvableBodyAttributes, R as ResolvableHead, ay as ResolvableHtmlAttributes, az as ResolvableLink, aA as ResolvableMeta, aB as ResolvableNoscript, aC as ResolvableProperties, aD as ResolvableScript, aE as ResolvableStyle, aF as ResolvableTemplateParams, aG as ResolvableTitle, aH as ResolvableTitleTemplate, aI as ResolvableUnion, aJ as ResolvableValue, aK as ResolvesDuplicates, aL as SchemaAugmentations, aM as Script, aN as ScriptBase, aO as ScriptHttpEvents, aP as SearchLink, S as SerializableHead, aQ as SitemapLink, aR as SpeculationRules, aS as SpeculationRulesScript, aT as StringInnerContent, aU as Stringable, aV as StylesheetLink, aW as TagKey, aX as TagPosition, aY as TagPriority, aZ as TagUserProperties, a_ as TemplateParams, a$ as TemplateParamsAugmentations, b0 as TermsOfServiceLink, b1 as UnheadBodyAttributesWithoutEvents, b2 as UnheadHtmlAttributes, b3 as UnheadMeta, b4 as UseHeadInput, b5 as UseSeoMetaInput, b6 as ValidTagPositions, b7 as WebmentionLink } from './shared/unhead.Dl7UHSN0.mjs';
6
6
  export { createSpyProxy } from './scripts.mjs';
7
- export { u as useScript } from './shared/unhead.BO2PdEL4.mjs';
7
+ export { u as useScript } from './shared/unhead.zyZmXwAG.mjs';
8
8
  import 'hookable';
9
9
 
10
10
  interface AriaAttributes {
package/dist/types.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { A as ActiveHeadEntry, g as AsVoidFunctions, d as ClientHeadHooks, h as CoreHeadHooks, C as CreateClientHeadOptions, c as CreateHeadOptions, a as CreateServerHeadOptions, e as CreateStreamableServerHeadOptions, D as DOMHeadHooks, i as DomBeforeRenderCtx, j as DomRenderTagContext, k as DomState, E as EntryResolveCtx, l as EventHandlerOptions, m as HeadEntry, n as HeadEntryOptions, o as HeadHooks, p as HeadPlugin, H as HeadPluginInput, q as HeadPluginOptions, b as HeadRenderer, r as HookResult, P as PropResolver, R as RecordingEntry, s as RenderSSRHeadOptions, t as SSRHeadHooks, S as SSRHeadPayload, u as SSRRenderContext, v as ScriptInstance, f as ServerHeadHooks, w as ShouldRenderContext, x as SideEffectsRecord, y as SyncHookResult, U as Unhead, z as UseFunctionType, B as UseScriptContext, F as UseScriptInput, G as UseScriptOptions, I as UseScriptResolvedInput, J as UseScriptReturn, K as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.CBj56GgY.js';
1
+ export { A as ActiveHeadEntry, g as AsVoidFunctions, d as ClientHeadHooks, h as CoreHeadHooks, C as CreateClientHeadOptions, c as CreateHeadOptions, a as CreateServerHeadOptions, e as CreateStreamableServerHeadOptions, D as DOMHeadHooks, i as DomBeforeRenderCtx, j as DomRenderTagContext, k as DomState, E as EntryResolveCtx, l as EventHandlerOptions, m as HeadEntry, n as HeadEntryOptions, o as HeadHooks, p as HeadPlugin, H as HeadPluginInput, q as HeadPluginOptions, b as HeadRenderer, r as HookResult, P as PropResolver, R as RecordingEntry, s as RenderSSRHeadOptions, t as SSRHeadHooks, S as SSRHeadPayload, u as SSRRenderContext, v as ScriptInstance, f as ServerHeadHooks, w as ShouldRenderContext, x as SideEffectsRecord, y as SyncHookResult, U as Unhead, z as UseFunctionType, B as UseScriptContext, F as UseScriptInput, G as UseScriptOptions, I as UseScriptResolvedInput, J as UseScriptReturn, K as UseScriptStatus, W as WarmupStrategy } from './shared/unhead.Dv-MkoX9.js';
2
2
  export { R as RenderDomHeadOptions } from './shared/unhead.DEgm41PJ.js';
3
3
  export { B as Base, a as BodyAttributes, H as HeadSafe, b as HtmlAttributes, N as Noscript, S as SafeBodyAttr, c as SafeHtmlAttr, d as SafeLink, e as SafeMeta, f as SafeNoscript, g as SafeScript, h as SafeStyle, i as Style } from './shared/unhead.Dqn7v3Di.js';
4
4
  import { B as Booleanable } from './shared/unhead.Dl7UHSN0.js';
5
5
  export { A as AlternateFeedLink, a as AlternateLanguageLink, b as AlternateLink, c as AlternateMediaLink, d as AlternateStylesheetLink, e as AmpHtmlLink, f as AppleTouchIconLink, g as AppleTouchStartupImageLink, h as ApplicationJsonScript, i as Arrayable, j as AuthorLink, k as BareAlternateLink, l as BodyAttributesWithoutEvents, m as BodyEvents, C as CanonicalLink, n as CharsetMeta, o as CompressionDictionaryLink, D as DataKeys, p as DeepReadonly, q as DeepResolvableProperties, r as DnsPrefetchLink, E as ExpectLink, s as ExternalScript, F as FaviconLink, G as GenericLink, t as GenericScript, u as GlobalAttributes, H as HasTemplateParams, v as HeadTag, w as HeadTagKeys, x as HelpLink, y as HttpEquivMeta, z as HttpEventAttributes, I as HubLink, J as IconLink, K as ImportMapConfig, L as ImportMapScript, M as InferLink, N as InferScript, O as InlineModuleScript, P as InlineScript, Q as InnerContent, T as InnerContentVal, U as InternalTagKey, V as JsonLdScript, W as KnownLinkRel, X as KnownScriptType, Y as LicenseLink, Z as Link, _ as LinkBase, $ as LinkHttpEvents, a0 as ManifestLink, a1 as MaskIconLink, a2 as MaybeArray, a3 as MaybeEventFnHandlers, a4 as MeLink, a5 as Meta, a6 as MetaBase, a7 as MetaFlat, a8 as MetaGeneric, a9 as MetaNames, aa as MetaProperties, ab as ModuleScript, ac as ModulepreloadLink, ad as NameMeta, ae as Never, af as NextLink, ag as PingbackLink, ah as PreconnectLink, ai as PrefetchLink, aj as PreloadFontLink, ak as PreloadImageLink, al as PreloadLink, am as PreloadLinkBase, an as PreloadOtherLink, ao as PreloadScriptLink, ap as PreloadStyleLink, aq as PrerenderLink, ar as PrevLink, as as PrivacyPolicyLink, at as ProcessesTemplateParams, au as PropertyMeta, av as RawInput, aw as ResolvableBase, ax as ResolvableBodyAttributes, R as ResolvableHead, ay as ResolvableHtmlAttributes, az as ResolvableLink, aA as ResolvableMeta, aB as ResolvableNoscript, aC as ResolvableProperties, aD as ResolvableScript, aE as ResolvableStyle, aF as ResolvableTemplateParams, aG as ResolvableTitle, aH as ResolvableTitleTemplate, aI as ResolvableUnion, aJ as ResolvableValue, aK as ResolvesDuplicates, aL as SchemaAugmentations, aM as Script, aN as ScriptBase, aO as ScriptHttpEvents, aP as SearchLink, S as SerializableHead, aQ as SitemapLink, aR as SpeculationRules, aS as SpeculationRulesScript, aT as StringInnerContent, aU as Stringable, aV as StylesheetLink, aW as TagKey, aX as TagPosition, aY as TagPriority, aZ as TagUserProperties, a_ as TemplateParams, a$ as TemplateParamsAugmentations, b0 as TermsOfServiceLink, b1 as UnheadBodyAttributesWithoutEvents, b2 as UnheadHtmlAttributes, b3 as UnheadMeta, b4 as UseHeadInput, b5 as UseSeoMetaInput, b6 as ValidTagPositions, b7 as WebmentionLink } from './shared/unhead.Dl7UHSN0.js';
6
6
  export { createSpyProxy } from './scripts.js';
7
- export { u as useScript } from './shared/unhead.YBmQyFpm.js';
7
+ export { u as useScript } from './shared/unhead.Cnhe7n9-.js';
8
8
  import 'hookable';
9
9
 
10
10
  interface AriaAttributes {
package/dist/utils.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { v as HeadTag, a7 as MetaFlat, R as ResolvableHead, a_ as TemplateParams } from './shared/unhead.Dl7UHSN0.mjs';
2
- import { P as PropResolver, U as Unhead } from './shared/unhead.CS8tFxG3.mjs';
2
+ import { P as PropResolver, U as Unhead } from './shared/unhead.CELAVVhh.mjs';
3
3
  import 'hookable';
4
4
 
5
5
  declare const SelfClosingTags: Set<string>;
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { v as HeadTag, a7 as MetaFlat, R as ResolvableHead, a_ as TemplateParams } from './shared/unhead.Dl7UHSN0.js';
2
- import { P as PropResolver, U as Unhead } from './shared/unhead.CBj56GgY.js';
2
+ import { P as PropResolver, U as Unhead } from './shared/unhead.Dv-MkoX9.js';
3
3
  import 'hookable';
4
4
 
5
5
  declare const SelfClosingTags: Set<string>;
package/dist/utils.mjs CHANGED
@@ -1,6 +1,6 @@
1
- export { D as DupeableTags, H as HasElementTags, M as MetaTagsArrayable, S as ScriptNetworkEvents, a as SelfClosingTags, T as TagConfigKeys, b as TagPriorityAliases, c as TagsWithInnerContent, U as UniqueTags, d as UsesMergeStrategy, V as ValidHeadTags } from './shared/unhead.fg-0ge_u.mjs';
2
- export { d as dedupeKey, a as dedupeTags, h as hashTag, i as isMetaArrayDupeKey, n as normalizeEntryToTags, b as normalizeProps, r as resolveTags, c as resolveTitleTemplate, s as sanitizeTags, w as walkResolver } from './shared/unhead.H5gLMTHA.mjs';
3
- export { r as resolveMetaKeyType, a as resolveMetaKeyValue, b as resolvePackedMetaObjectValue, u as unpackMeta } from './shared/unhead.CBkhoTGw.mjs';
1
+ export { D as DupeableTags, H as HasElementTags, M as MetaTagsArrayable, S as ScriptNetworkEvents, a as SelfClosingTags, T as TagConfigKeys, b as TagPriorityAliases, c as TagsWithInnerContent, U as UniqueTags, d as UsesMergeStrategy, V as ValidHeadTags } from './shared/unhead.1eoQpFT1.mjs';
2
+ export { d as dedupeKey, a as dedupeTags, h as hashTag, i as isMetaArrayDupeKey, n as normalizeEntryToTags, b as normalizeProps, r as resolveTags, c as resolveTitleTemplate, s as sanitizeTags, w as walkResolver } from './shared/unhead.CR32jx68.mjs';
3
+ export { r as resolveMetaKeyType, a as resolveMetaKeyValue, b as resolvePackedMetaObjectValue, u as unpackMeta } from './shared/unhead.CT1xoGPh.mjs';
4
4
  export { p as processTemplateParams } from './shared/unhead.BGFxPGPQ.mjs';
5
- import './shared/unhead.DvIxXxuO.mjs';
5
+ import './shared/unhead.Bm4Y6XQI.mjs';
6
6
  import 'hookable';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "3.1.5",
4
+ "version": "3.1.7",
5
5
  "description": "Full-stack <head> manager built for any framework.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -156,12 +156,12 @@
156
156
  },
157
157
  "dependencies": {
158
158
  "hookable": "^6.1.1",
159
- "unplugin": "^3.0.0"
159
+ "unplugin": "^3.2.0"
160
160
  },
161
161
  "devDependencies": {
162
162
  "@rollup/plugin-node-resolve": "^16.0.3",
163
163
  "rollup": "^4.62.2",
164
- "vite": "^8.0.16"
164
+ "vite": "^8.1.0"
165
165
  },
166
166
  "scripts": {
167
167
  "build": "unbuild",
@@ -1,154 +0,0 @@
1
- import { H as HasElementTags } from './unhead.fg-0ge_u.mjs';
2
- import { b as normalizeProps, d as dedupeKey, h as hashTag, r as resolveTags, i as isMetaArrayDupeKey } from './unhead.H5gLMTHA.mjs';
3
- import { a as callHook } from './unhead.DvIxXxuO.mjs';
4
-
5
- const WHITESPACE_RE = /\s+/;
6
- // @__NO_SIDE_EFFECTS__
7
- function createDomRenderer(options = {}) {
8
- return (head) => _renderDOMHead(head, options);
9
- }
10
- function renderDOMHead(head, options = {}) {
11
- return _renderDOMHead(head, options);
12
- }
13
- function _renderDOMHead(head, options = {}) {
14
- const dom = options.document || head.resolvedOptions.document;
15
- if (!dom || !head.dirty && ![...head.entries.values()].some((e) => e._pending !== void 0))
16
- return false;
17
- const beforeRenderCtx = { shouldRender: true, tags: [] };
18
- callHook(head, "dom:beforeRender", beforeRenderCtx);
19
- if (!beforeRenderCtx.shouldRender || head._du)
20
- return false;
21
- head._du = true;
22
- let state = head._dom;
23
- if (!state) {
24
- state = { _t: dom.title, _e: /* @__PURE__ */ new Map([["htmlAttrs", dom.documentElement], ["bodyAttrs", dom.body]]), _p: {}, _s: {} };
25
- for (const el of [...dom.body.children, ...dom.head.children]) {
26
- const tag = el.tagName.toLowerCase();
27
- if (!HasElementTags.has(tag))
28
- continue;
29
- const props = { innerHTML: el.innerHTML };
30
- for (const n of el.getAttributeNames())
31
- props[n] = el.getAttribute(n);
32
- const next = normalizeProps({ tag, props: {} }, props);
33
- next.key = el.getAttribute("data-hid") || void 0;
34
- let k = next._d = dedupeKey(next) || hashTag(next);
35
- let c = 1;
36
- while (state._e.has(k))
37
- k = `${next._d}:${c++}`;
38
- state._e.set(k, el);
39
- }
40
- for (const entry of head.entries.values()) {
41
- if (entry._o !== void 0) {
42
- const orig = entry._o;
43
- for (const t of ["bodyAttrs", "htmlAttrs"]) {
44
- const cls = orig[t]?.class;
45
- if (typeof cls === "string") {
46
- const $el = state._e.get(t);
47
- for (const c of cls.split(WHITESPACE_RE)) {
48
- if (c)
49
- state._p[`${t}:attr:class:${c}`] = () => $el.classList.remove(c);
50
- }
51
- }
52
- }
53
- delete entry._o;
54
- }
55
- }
56
- } else {
57
- state._p = { ...state._s };
58
- }
59
- state._s = {};
60
- function track(id, scope, fn) {
61
- const k = `${id}:${scope}`;
62
- state._s[k] = fn;
63
- delete state._p[k];
64
- }
65
- function trackCtx({ id, $el, tag }) {
66
- const isAttr = tag.tag.endsWith("Attrs");
67
- state._e.set(id, $el);
68
- if (!isAttr) {
69
- if (tag.textContent && tag.textContent !== $el.textContent)
70
- $el.textContent = tag.textContent;
71
- if (tag.innerHTML && tag.innerHTML !== $el.innerHTML)
72
- $el.innerHTML = tag.innerHTML;
73
- track(id, "el", () => {
74
- $el?.remove();
75
- state._e.delete(id);
76
- });
77
- }
78
- for (const k in tag.props) {
79
- const v = tag.props[k];
80
- if (k[0] === "o" && k[1] === "n" && typeof v === "function") {
81
- const ev = k.slice(2);
82
- if ($el?.dataset?.[`${k}fired`])
83
- v.call($el, new Event(ev));
84
- if ($el.getAttribute(`data-${k}`) !== "") {
85
- (tag.tag === "bodyAttrs" ? dom.defaultView : $el).addEventListener(ev, v.bind($el));
86
- $el.setAttribute(`data-${k}`, "");
87
- }
88
- continue;
89
- }
90
- const ck = `attr:${k}`;
91
- if (k === "class" && v) {
92
- for (const c of v) {
93
- if (isAttr)
94
- track(id, `${ck}:${c}`, () => $el.classList.remove(c));
95
- if (!$el.classList.contains(c))
96
- $el.classList.add(c);
97
- }
98
- } else if (k === "style" && v) {
99
- for (const [sk, sv] of v) {
100
- track(id, `${ck}:${sk}`, () => $el.style.removeProperty(sk));
101
- $el.style.setProperty(sk, sv);
102
- }
103
- } else if (v !== false && v !== null) {
104
- if ($el.getAttribute(k) !== v)
105
- $el.setAttribute(k, v === true ? "" : String(v));
106
- if (isAttr)
107
- track(id, ck, () => $el.removeAttribute(k));
108
- }
109
- }
110
- }
111
- const pending = [];
112
- const frag = {};
113
- const rawTags = resolveTags(head, options.tagWeight ? { tagWeight: options.tagWeight } : void 0);
114
- const tags = [];
115
- const dupeKeyCounter = /* @__PURE__ */ new Map();
116
- for (const tag of rawTags) {
117
- const count = dupeKeyCounter.get(tag._d) || 0;
118
- const id = (count ? `${tag._d}:${count}` : tag._d) || tag._h;
119
- const ctx = { tag, id, shouldRender: true };
120
- if (tag._d && isMetaArrayDupeKey(tag._d))
121
- dupeKeyCounter.set(tag._d, count + 1);
122
- tags.push(ctx);
123
- if (tag.tag === "title") {
124
- dom.title = tag.textContent;
125
- track("title", "", () => dom.title = state._t);
126
- continue;
127
- }
128
- ctx.$el = state._e.get(id);
129
- if (ctx.$el)
130
- trackCtx(ctx);
131
- else if (HasElementTags.has(tag.tag))
132
- pending.push(ctx);
133
- }
134
- for (const ctx of pending) {
135
- ctx.$el = dom.createElement(ctx.tag.tag);
136
- trackCtx(ctx);
137
- (frag[ctx.tag.tagPosition || "head"] ??= dom.createDocumentFragment()).appendChild(ctx.$el);
138
- }
139
- if (frag.head)
140
- dom.head.appendChild(frag.head);
141
- if (frag.bodyOpen)
142
- dom.body.insertBefore(frag.bodyOpen, dom.body.firstChild);
143
- if (frag.bodyClose)
144
- dom.body.appendChild(frag.bodyClose);
145
- for (const k in state._p)
146
- state._p[k]();
147
- head._dom = state;
148
- callHook(head, "dom:rendered", { renders: tags });
149
- head._du = false;
150
- head.dirty = false;
151
- return true;
152
- }
153
-
154
- export { createDomRenderer as c, renderDOMHead as r };
@@ -1,5 +0,0 @@
1
- function defineHeadPlugin(plugin) {
2
- return plugin;
3
- }
4
-
5
- export { defineHeadPlugin as d };