@unhead/shared 1.8.12 → 1.8.14

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/index.cjs CHANGED
@@ -96,7 +96,7 @@ function packObject(input, options) {
96
96
  options.value = options.value || v;
97
97
  options.resolveKey = options.resolveKey || ((k2) => k2);
98
98
  const resolveKey = (index) => {
99
- const arr = asArray(options?.[index]);
99
+ const arr = asArray(options[index]);
100
100
  return arr.find((k2) => {
101
101
  if (typeof k2 === "string" && k2.includes(".")) {
102
102
  return k2;
@@ -167,7 +167,7 @@ function unpackToString(value, options) {
167
167
  value2 = unpackToString(value2, options);
168
168
  if (options.resolve) {
169
169
  const resolved = options.resolve({ key, value: value2 });
170
- if (resolved)
170
+ if (typeof resolved !== "undefined")
171
171
  return resolved;
172
172
  }
173
173
  if (typeof value2 === "number")
@@ -520,16 +520,17 @@ async function normaliseTag(tagName, input, e) {
520
520
  }
521
521
  return Array.isArray(tag.props.content) ? tag.props.content.map((v) => ({ ...tag, props: { ...tag.props, content: v } })) : tag;
522
522
  }
523
- function normaliseClassProp(v) {
523
+ function normaliseStyleClassProps(key, v) {
524
+ const sep = key === "class" ? " " : ";";
524
525
  if (typeof v === "object" && !Array.isArray(v)) {
525
- v = Object.keys(v).filter((k) => v[k]);
526
+ v = Object.entries(v).filter(([, v2]) => v2).map(([k, v2]) => key === "style" ? `${k}:${v2}` : k);
526
527
  }
527
- return (Array.isArray(v) ? v.join(" ") : v).split(" ").filter((c) => c.trim()).filter(Boolean).join(" ");
528
+ return (Array.isArray(v) ? v.join(sep) : v).split(sep).filter((c) => c.trim()).filter(Boolean).join(sep);
528
529
  }
529
530
  async function normaliseProps(props, virtual) {
530
531
  for (const k of Object.keys(props)) {
531
- if (k === "class") {
532
- props[k] = normaliseClassProp(props[k]);
532
+ if (["class", "style"].includes(k)) {
533
+ props[k] = normaliseStyleClassProps(k, props[k]);
533
534
  continue;
534
535
  }
535
536
  if (props[k] instanceof Promise)
@@ -656,9 +657,9 @@ exports.composableNames = composableNames;
656
657
  exports.defineHeadPlugin = defineHeadPlugin;
657
658
  exports.hashCode = hashCode;
658
659
  exports.hashTag = hashTag;
659
- exports.normaliseClassProp = normaliseClassProp;
660
660
  exports.normaliseEntryTags = normaliseEntryTags;
661
661
  exports.normaliseProps = normaliseProps;
662
+ exports.normaliseStyleClassProps = normaliseStyleClassProps;
662
663
  exports.normaliseTag = normaliseTag;
663
664
  exports.packMeta = packMeta;
664
665
  exports.processTemplateParams = processTemplateParams;
package/dist/index.d.cts CHANGED
@@ -38,7 +38,7 @@ declare function packMeta<T extends Required<Head>['meta']>(inputs: T): MetaFlat
38
38
  declare function whitelistSafeInput(input: Record<string, MaybeArray<Record<string, string>>>): HeadSafe;
39
39
 
40
40
  declare function normaliseTag<T extends HeadTag>(tagName: T['tag'], input: HeadTag['props'] | string, e: HeadEntry<T>): Promise<T | T[] | false>;
41
- declare function normaliseClassProp(v: Required<Required<Head>['htmlAttrs']['class']>): string;
41
+ declare function normaliseStyleClassProps<T extends 'class' | 'style'>(key: T, v: Required<Required<Head>['htmlAttrs']['class']> | Required<Required<Head>['htmlAttrs']['style']>): string;
42
42
  declare function normaliseProps<T extends HeadTag>(props: T['props'], virtual?: boolean): Promise<T['props']>;
43
43
  declare const TagEntityBits = 10;
44
44
  declare function normaliseEntryTags<T extends {} = Head>(e: HeadEntry<T>): Promise<HeadTag[]>;
@@ -62,4 +62,4 @@ declare const NetworkEvents: string[];
62
62
 
63
63
  declare function processTemplateParams(s: string, p: TemplateParams, sep: string): string;
64
64
 
65
- export { type Arrayable, HasElementTags, IsBrowser, NetworkEvents, SelfClosingTags, SortModifiers, TAG_ALIASES, TAG_WEIGHTS, TagConfigKeys, TagEntityBits, TagsWithInnerContent, UniqueTags, ValidHeadTags, asArray, composableNames, defineHeadPlugin, hashCode, hashTag, normaliseClassProp, normaliseEntryTags, normaliseProps, normaliseTag, packMeta, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, resolveTitleTemplate, tagDedupeKey, tagWeight, unpackMeta, whitelistSafeInput };
65
+ export { type Arrayable, HasElementTags, IsBrowser, NetworkEvents, SelfClosingTags, SortModifiers, TAG_ALIASES, TAG_WEIGHTS, TagConfigKeys, TagEntityBits, TagsWithInnerContent, UniqueTags, ValidHeadTags, asArray, composableNames, defineHeadPlugin, hashCode, hashTag, normaliseEntryTags, normaliseProps, normaliseStyleClassProps, normaliseTag, packMeta, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, resolveTitleTemplate, tagDedupeKey, tagWeight, unpackMeta, whitelistSafeInput };
package/dist/index.d.mts CHANGED
@@ -38,7 +38,7 @@ declare function packMeta<T extends Required<Head>['meta']>(inputs: T): MetaFlat
38
38
  declare function whitelistSafeInput(input: Record<string, MaybeArray<Record<string, string>>>): HeadSafe;
39
39
 
40
40
  declare function normaliseTag<T extends HeadTag>(tagName: T['tag'], input: HeadTag['props'] | string, e: HeadEntry<T>): Promise<T | T[] | false>;
41
- declare function normaliseClassProp(v: Required<Required<Head>['htmlAttrs']['class']>): string;
41
+ declare function normaliseStyleClassProps<T extends 'class' | 'style'>(key: T, v: Required<Required<Head>['htmlAttrs']['class']> | Required<Required<Head>['htmlAttrs']['style']>): string;
42
42
  declare function normaliseProps<T extends HeadTag>(props: T['props'], virtual?: boolean): Promise<T['props']>;
43
43
  declare const TagEntityBits = 10;
44
44
  declare function normaliseEntryTags<T extends {} = Head>(e: HeadEntry<T>): Promise<HeadTag[]>;
@@ -62,4 +62,4 @@ declare const NetworkEvents: string[];
62
62
 
63
63
  declare function processTemplateParams(s: string, p: TemplateParams, sep: string): string;
64
64
 
65
- export { type Arrayable, HasElementTags, IsBrowser, NetworkEvents, SelfClosingTags, SortModifiers, TAG_ALIASES, TAG_WEIGHTS, TagConfigKeys, TagEntityBits, TagsWithInnerContent, UniqueTags, ValidHeadTags, asArray, composableNames, defineHeadPlugin, hashCode, hashTag, normaliseClassProp, normaliseEntryTags, normaliseProps, normaliseTag, packMeta, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, resolveTitleTemplate, tagDedupeKey, tagWeight, unpackMeta, whitelistSafeInput };
65
+ export { type Arrayable, HasElementTags, IsBrowser, NetworkEvents, SelfClosingTags, SortModifiers, TAG_ALIASES, TAG_WEIGHTS, TagConfigKeys, TagEntityBits, TagsWithInnerContent, UniqueTags, ValidHeadTags, asArray, composableNames, defineHeadPlugin, hashCode, hashTag, normaliseEntryTags, normaliseProps, normaliseStyleClassProps, normaliseTag, packMeta, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, resolveTitleTemplate, tagDedupeKey, tagWeight, unpackMeta, whitelistSafeInput };
package/dist/index.d.ts CHANGED
@@ -38,7 +38,7 @@ declare function packMeta<T extends Required<Head>['meta']>(inputs: T): MetaFlat
38
38
  declare function whitelistSafeInput(input: Record<string, MaybeArray<Record<string, string>>>): HeadSafe;
39
39
 
40
40
  declare function normaliseTag<T extends HeadTag>(tagName: T['tag'], input: HeadTag['props'] | string, e: HeadEntry<T>): Promise<T | T[] | false>;
41
- declare function normaliseClassProp(v: Required<Required<Head>['htmlAttrs']['class']>): string;
41
+ declare function normaliseStyleClassProps<T extends 'class' | 'style'>(key: T, v: Required<Required<Head>['htmlAttrs']['class']> | Required<Required<Head>['htmlAttrs']['style']>): string;
42
42
  declare function normaliseProps<T extends HeadTag>(props: T['props'], virtual?: boolean): Promise<T['props']>;
43
43
  declare const TagEntityBits = 10;
44
44
  declare function normaliseEntryTags<T extends {} = Head>(e: HeadEntry<T>): Promise<HeadTag[]>;
@@ -62,4 +62,4 @@ declare const NetworkEvents: string[];
62
62
 
63
63
  declare function processTemplateParams(s: string, p: TemplateParams, sep: string): string;
64
64
 
65
- export { type Arrayable, HasElementTags, IsBrowser, NetworkEvents, SelfClosingTags, SortModifiers, TAG_ALIASES, TAG_WEIGHTS, TagConfigKeys, TagEntityBits, TagsWithInnerContent, UniqueTags, ValidHeadTags, asArray, composableNames, defineHeadPlugin, hashCode, hashTag, normaliseClassProp, normaliseEntryTags, normaliseProps, normaliseTag, packMeta, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, resolveTitleTemplate, tagDedupeKey, tagWeight, unpackMeta, whitelistSafeInput };
65
+ export { type Arrayable, HasElementTags, IsBrowser, NetworkEvents, SelfClosingTags, SortModifiers, TAG_ALIASES, TAG_WEIGHTS, TagConfigKeys, TagEntityBits, TagsWithInnerContent, UniqueTags, ValidHeadTags, asArray, composableNames, defineHeadPlugin, hashCode, hashTag, normaliseEntryTags, normaliseProps, normaliseStyleClassProps, normaliseTag, packMeta, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, resolveTitleTemplate, tagDedupeKey, tagWeight, unpackMeta, whitelistSafeInput };
package/dist/index.mjs CHANGED
@@ -94,7 +94,7 @@ function packObject(input, options) {
94
94
  options.value = options.value || v;
95
95
  options.resolveKey = options.resolveKey || ((k2) => k2);
96
96
  const resolveKey = (index) => {
97
- const arr = asArray(options?.[index]);
97
+ const arr = asArray(options[index]);
98
98
  return arr.find((k2) => {
99
99
  if (typeof k2 === "string" && k2.includes(".")) {
100
100
  return k2;
@@ -165,7 +165,7 @@ function unpackToString(value, options) {
165
165
  value2 = unpackToString(value2, options);
166
166
  if (options.resolve) {
167
167
  const resolved = options.resolve({ key, value: value2 });
168
- if (resolved)
168
+ if (typeof resolved !== "undefined")
169
169
  return resolved;
170
170
  }
171
171
  if (typeof value2 === "number")
@@ -518,16 +518,17 @@ async function normaliseTag(tagName, input, e) {
518
518
  }
519
519
  return Array.isArray(tag.props.content) ? tag.props.content.map((v) => ({ ...tag, props: { ...tag.props, content: v } })) : tag;
520
520
  }
521
- function normaliseClassProp(v) {
521
+ function normaliseStyleClassProps(key, v) {
522
+ const sep = key === "class" ? " " : ";";
522
523
  if (typeof v === "object" && !Array.isArray(v)) {
523
- v = Object.keys(v).filter((k) => v[k]);
524
+ v = Object.entries(v).filter(([, v2]) => v2).map(([k, v2]) => key === "style" ? `${k}:${v2}` : k);
524
525
  }
525
- return (Array.isArray(v) ? v.join(" ") : v).split(" ").filter((c) => c.trim()).filter(Boolean).join(" ");
526
+ return (Array.isArray(v) ? v.join(sep) : v).split(sep).filter((c) => c.trim()).filter(Boolean).join(sep);
526
527
  }
527
528
  async function normaliseProps(props, virtual) {
528
529
  for (const k of Object.keys(props)) {
529
- if (k === "class") {
530
- props[k] = normaliseClassProp(props[k]);
530
+ if (["class", "style"].includes(k)) {
531
+ props[k] = normaliseStyleClassProps(k, props[k]);
531
532
  continue;
532
533
  }
533
534
  if (props[k] instanceof Promise)
@@ -637,4 +638,4 @@ function processTemplateParams(s, p, sep) {
637
638
  return s;
638
639
  }
639
640
 
640
- export { HasElementTags, IsBrowser, NetworkEvents, SelfClosingTags, SortModifiers, TAG_ALIASES, TAG_WEIGHTS, TagConfigKeys, TagEntityBits, TagsWithInnerContent, UniqueTags, ValidHeadTags, asArray$1 as asArray, composableNames, defineHeadPlugin, hashCode, hashTag, normaliseClassProp, normaliseEntryTags, normaliseProps, normaliseTag, packMeta, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, resolveTitleTemplate, tagDedupeKey, tagWeight, unpackMeta, whitelistSafeInput };
641
+ export { HasElementTags, IsBrowser, NetworkEvents, SelfClosingTags, SortModifiers, TAG_ALIASES, TAG_WEIGHTS, TagConfigKeys, TagEntityBits, TagsWithInnerContent, UniqueTags, ValidHeadTags, asArray$1 as asArray, composableNames, defineHeadPlugin, hashCode, hashTag, normaliseEntryTags, normaliseProps, normaliseStyleClassProps, normaliseTag, packMeta, processTemplateParams, resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue, resolveTitleTemplate, tagDedupeKey, tagWeight, unpackMeta, whitelistSafeInput };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/shared",
3
3
  "type": "module",
4
- "version": "1.8.12",
4
+ "version": "1.8.14",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -34,10 +34,10 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@unhead/schema": "1.8.12"
37
+ "@unhead/schema": "1.8.14"
38
38
  },
39
39
  "devDependencies": {
40
- "packrup": "^0.1.0"
40
+ "packrup": "^0.1.2"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "unbuild .",