unhead 2.0.19 → 2.1.0

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.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { a as createUnhead } from './shared/unhead.DH45uomy.mjs';
1
+ import { a as createUnhead } from './shared/unhead.CGCfDSEL.mjs';
2
2
  import { H as HasElementTags } from './shared/unhead.yem5I2v_.mjs';
3
- import { h as hashTag, i as isMetaArrayDupeKey, a as normalizeProps, d as dedupeKey } from './shared/unhead.BpRRHAhY.mjs';
3
+ import { h as hashTag, i as isMetaArrayDupeKey, a as normalizeProps, d as dedupeKey } from './shared/unhead.CYpwL2hc.mjs';
4
4
  import 'hookable';
5
- import './shared/unhead.DZbvapt-.mjs';
5
+ import './shared/unhead.CbpEuj3y.mjs';
6
6
 
7
7
  async function renderDOMHead(head, options = {}) {
8
8
  const dom = options.document || head.resolvedOptions.document;
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  export { u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/unhead.BPM0-cfG.mjs';
2
- export { c as createHeadCore, a as createUnhead } from './shared/unhead.DH45uomy.mjs';
2
+ export { c as createHeadCore, a as createUnhead } from './shared/unhead.CGCfDSEL.mjs';
3
3
  export { u as useScript } from './shared/unhead.B578PsDV.mjs';
4
4
  import './shared/unhead.CApf5sj3.mjs';
5
5
  import './shared/unhead.DQc16pHI.mjs';
6
6
  import './shared/unhead.yem5I2v_.mjs';
7
7
  import 'hookable';
8
- import './shared/unhead.BpRRHAhY.mjs';
9
- import './shared/unhead.DZbvapt-.mjs';
8
+ import './shared/unhead.CYpwL2hc.mjs';
9
+ import './shared/unhead.CbpEuj3y.mjs';
package/dist/legacy.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { a as createUnhead } from './shared/unhead.DH45uomy.mjs';
2
- import { D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.Djo8ep_Y.mjs';
1
+ import { a as createUnhead } from './shared/unhead.CGCfDSEL.mjs';
2
+ import { D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin, A as AliasSortingPlugin } from './shared/unhead.ckV6dpEQ.mjs';
3
3
  export { u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/unhead.BPM0-cfG.mjs';
4
4
  export { u as useScript } from './shared/unhead.B578PsDV.mjs';
5
5
  import 'hookable';
6
- import './shared/unhead.BpRRHAhY.mjs';
6
+ import './shared/unhead.CYpwL2hc.mjs';
7
7
  import './shared/unhead.yem5I2v_.mjs';
8
- import './shared/unhead.DZbvapt-.mjs';
8
+ import './shared/unhead.CbpEuj3y.mjs';
9
9
  import './shared/unhead.CApf5sj3.mjs';
10
10
  import './shared/unhead.DQc16pHI.mjs';
11
11
  import './shared/unhead.BYvz9V1x.mjs';
package/dist/plugins.mjs CHANGED
@@ -1,7 +1,7 @@
1
- export { A as AliasSortingPlugin, D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin } from './shared/unhead.Djo8ep_Y.mjs';
1
+ export { A as AliasSortingPlugin, D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin } from './shared/unhead.ckV6dpEQ.mjs';
2
2
  import { d as defineHeadPlugin } from './shared/unhead.CApf5sj3.mjs';
3
3
  export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.CApf5sj3.mjs';
4
- import './shared/unhead.DZbvapt-.mjs';
4
+ import './shared/unhead.CbpEuj3y.mjs';
5
5
  import './shared/unhead.BYvz9V1x.mjs';
6
6
  import './shared/unhead.DQc16pHI.mjs';
7
7
  import './shared/unhead.yem5I2v_.mjs';
package/dist/server.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { a as createUnhead } from './shared/unhead.DH45uomy.mjs';
1
+ import { a as createUnhead } from './shared/unhead.CGCfDSEL.mjs';
2
2
  import { T as TagsWithInnerContent, S as SelfClosingTags } from './shared/unhead.yem5I2v_.mjs';
3
3
  import { parseHtmlForUnheadExtraction } from './parser.mjs';
4
4
  import 'hookable';
5
- import './shared/unhead.BpRRHAhY.mjs';
6
- import './shared/unhead.DZbvapt-.mjs';
5
+ import './shared/unhead.CYpwL2hc.mjs';
6
+ import './shared/unhead.CbpEuj3y.mjs';
7
7
 
8
8
  // @__NO_SIDE_EFFECTS__
9
9
  function createHead(options = {}) {
@@ -1,6 +1,6 @@
1
1
  import { createHooks } from 'hookable';
2
- import { n as normalizeEntryToTags, d as dedupeKey, i as isMetaArrayDupeKey } from './unhead.BpRRHAhY.mjs';
3
- import { t as tagWeight, s as sortTags } from './unhead.DZbvapt-.mjs';
2
+ import { n as normalizeEntryToTags, d as dedupeKey, i as isMetaArrayDupeKey } from './unhead.CYpwL2hc.mjs';
3
+ import { t as tagWeight, s as sortTags } from './unhead.CbpEuj3y.mjs';
4
4
  import { c as UsesMergeStrategy, V as ValidHeadTags } from './unhead.yem5I2v_.mjs';
5
5
 
6
6
  function registerPlugin(head, p) {
@@ -151,7 +151,7 @@ function createUnhead(resolvedOptions = {}) {
151
151
  continue;
152
152
  }
153
153
  if (tag === "script" && innerHTML) {
154
- if (props.type?.endsWith("json")) {
154
+ if (String(props.type).endsWith("json")) {
155
155
  const v = typeof innerHTML === "string" ? innerHTML : JSON.stringify(innerHTML);
156
156
  t.innerHTML = v.replace(/</g, "\\u003C");
157
157
  } else if (typeof innerHTML === "string") {
@@ -25,8 +25,8 @@ function dedupeKey(tag) {
25
25
  for (const n of allowedMetaProperties) {
26
26
  if (props[n] !== void 0) {
27
27
  const propValue = props[n];
28
- const isStructured = propValue.includes(":");
29
- const isStandardSingle = StandardSingleMetaTags.has(propValue);
28
+ const isStructured = propValue && typeof propValue === "string" && propValue.includes(":");
29
+ const isStandardSingle = propValue && StandardSingleMetaTags.has(propValue);
30
30
  const shouldAlwaysDedupe = isStructured || isStandardSingle;
31
31
  const keyPart = !shouldAlwaysDedupe && tag.key ? `:key:${tag.key}` : "";
32
32
  return `${name}:${propValue}${keyPart}`;
@@ -63,17 +63,14 @@ function walkResolver(val, resolve, key) {
63
63
  val = val();
64
64
  }
65
65
  }
66
- let v;
67
- if (resolve) {
68
- v = resolve(key, val);
69
- }
66
+ const v = resolve ? resolve(key, val) : val;
70
67
  if (Array.isArray(v)) {
71
68
  return v.map((r) => walkResolver(r, resolve));
72
69
  }
73
70
  if (v?.constructor === Object) {
74
71
  const next = {};
75
- for (const key2 of Object.keys(v)) {
76
- next[key2] = walkResolver(v[key2], resolve, key2);
72
+ for (const k of Object.keys(v)) {
73
+ next[k] = walkResolver(v[k], resolve, k);
77
74
  }
78
75
  return next;
79
76
  }
@@ -83,11 +80,13 @@ function walkResolver(val, resolve, key) {
83
80
  function normalizeStyleClassProps(key, value) {
84
81
  const store = key === "style" ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Set();
85
82
  function processValue(rawValue) {
86
- const value2 = rawValue.trim();
83
+ if (rawValue == null || rawValue === void 0)
84
+ return;
85
+ const value2 = String(rawValue).trim();
87
86
  if (!value2)
88
87
  return;
89
88
  if (key === "style") {
90
- const [k, ...v] = value2.split(":").map((s) => s.trim());
89
+ const [k, ...v] = value2.split(":").map((s) => s ? s.trim() : "");
91
90
  if (k && v.length)
92
91
  store.set(k, v.join(":"));
93
92
  } else {
@@ -101,7 +100,7 @@ function normalizeStyleClassProps(key, value) {
101
100
  } else if (value && typeof value === "object") {
102
101
  Object.entries(value).forEach(([k, v]) => {
103
102
  if (v && v !== "false") {
104
- key === "style" ? store.set(k.trim(), v) : processValue(k);
103
+ key === "style" ? store.set(String(k).trim(), String(v)) : processValue(k);
105
104
  }
106
105
  });
107
106
  }
@@ -144,8 +143,9 @@ function normalizeProps(tag, input) {
144
143
  }
145
144
  const strValue = String(value);
146
145
  const isDataKey = key.startsWith("data-");
146
+ const isMetaContentKey = tag.tag === "meta" && key === "content";
147
147
  if (strValue === "true" || strValue === "") {
148
- tag.props[key] = isDataKey ? strValue : true;
148
+ tag.props[key] = isDataKey || isMetaContentKey ? strValue : true;
149
149
  } else if (!value && isDataKey && strValue === "false") {
150
150
  tag.props[key] = "false";
151
151
  } else if (value !== void 0) {
@@ -54,11 +54,12 @@ function tagWeight(head, tag) {
54
54
  } else if (tag.tag === "link" && tag.props.rel) {
55
55
  weight = weightMap.link[tag.props.rel];
56
56
  } else if (tag.tag === "script") {
57
+ const type = String(tag.props.type);
57
58
  if (isTruthy(tag.props.async)) {
58
59
  weight = weightMap.script.async;
59
- } else if (tag.props.src && !isTruthy(tag.props.defer) && !isTruthy(tag.props.async) && tag.props.type !== "module" && !tag.props.type?.endsWith("json")) {
60
+ } else if (tag.props.src && !isTruthy(tag.props.defer) && !isTruthy(tag.props.async) && type !== "module" && !type.endsWith("json") || tag.innerHTML && !type.endsWith("json")) {
60
61
  weight = weightMap.script.sync;
61
- } else if (isTruthy(tag.props.defer) && tag.props.src && !isTruthy(tag.props.async)) {
62
+ } else if (isTruthy(tag.props.defer) && tag.props.src && !isTruthy(tag.props.async) || type === "module") {
62
63
  weight = weightMap.script.defer;
63
64
  }
64
65
  } else if (tag.tag === "style") {
@@ -1,5 +1,5 @@
1
1
  import { d as defineHeadPlugin } from './unhead.CApf5sj3.mjs';
2
- import { s as sortTags } from './unhead.DZbvapt-.mjs';
2
+ import { s as sortTags } from './unhead.CbpEuj3y.mjs';
3
3
  import { p as processTemplateParams } from './unhead.BYvz9V1x.mjs';
4
4
 
5
5
  const formatKey = (k) => !k.includes(":key") ? k.split(":").join(":key:") : k;
package/dist/utils.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  export { D as DupeableTags, H as HasElementTags, M as MetaTagsArrayable, b as ScriptNetworkEvents, S as SelfClosingTags, a as TagConfigKeys, T as TagsWithInnerContent, U as UniqueTags, c as UsesMergeStrategy, V as ValidHeadTags } from './shared/unhead.yem5I2v_.mjs';
2
- export { d as dedupeKey, h as hashTag, i as isMetaArrayDupeKey, n as normalizeEntryToTags, a as normalizeProps, w as walkResolver } from './shared/unhead.BpRRHAhY.mjs';
2
+ export { d as dedupeKey, h as hashTag, i as isMetaArrayDupeKey, n as normalizeEntryToTags, a as normalizeProps, w as walkResolver } from './shared/unhead.CYpwL2hc.mjs';
3
3
  export { r as resolveMetaKeyType, a as resolveMetaKeyValue, b as resolvePackedMetaObjectValue, u as unpackMeta } from './shared/unhead.DQc16pHI.mjs';
4
- export { s as sortTags, t as tagWeight } from './shared/unhead.DZbvapt-.mjs';
4
+ export { s as sortTags, t as tagWeight } from './shared/unhead.CbpEuj3y.mjs';
5
5
  export { p as processTemplateParams } from './shared/unhead.BYvz9V1x.mjs';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "2.0.19",
4
+ "version": "2.1.0",
5
5
  "description": "Full-stack <head> manager built for any framework.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",