@xylabs/sdk-meta 5.0.82 → 5.0.84

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/README.md CHANGED
@@ -57,18 +57,26 @@ function addMetaToHead(
57
57
  value): void;
58
58
  ```
59
59
 
60
+ Adds or replaces a meta tag in the document head.
61
+
60
62
  ## Parameters
61
63
 
62
64
  ### $
63
65
 
64
66
  `CheerioAPI`
65
67
 
68
+ The Cheerio API instance for the document.
69
+
66
70
  ### name
67
71
 
68
72
  `string`
69
73
 
74
+ The meta property name.
75
+
70
76
  ### value
71
77
 
78
+ The meta content value (string, array, or nested object).
79
+
72
80
  `string` | `object`
73
81
 
74
82
  ## Returns
@@ -85,20 +93,28 @@ function addMetaToHead(
85
93
  function getMetaAsDict(obj, parentKey?): Record<string, string>;
86
94
  ```
87
95
 
96
+ Recursively flattens a nested meta object into a flat dictionary with colon-delimited keys.
97
+
88
98
  ## Parameters
89
99
 
90
100
  ### obj
91
101
 
92
102
  [`StringIndexable`](#../type-aliases/StringIndexable)
93
103
 
104
+ The nested object to flatten.
105
+
94
106
  ### parentKey?
95
107
 
96
108
  `string`
97
109
 
110
+ The accumulated key prefix from parent levels.
111
+
98
112
  ## Returns
99
113
 
100
114
  `Record`\<`string`, `string`\>
101
115
 
116
+ A flat record mapping colon-delimited property names to string values.
117
+
102
118
  ### <a id="mergeDocumentHead"></a>mergeDocumentHead
103
119
 
104
120
  [**@xylabs/sdk-meta**](#../README)
@@ -109,20 +125,29 @@ function getMetaAsDict(obj, parentKey?): Record<string, string>;
109
125
  function mergeDocumentHead(destination, source): string;
110
126
  ```
111
127
 
128
+ Merges meta tags from the source HTML head into the destination HTML head.
129
+ Existing meta tags with matching property attributes are replaced; others are appended.
130
+
112
131
  ## Parameters
113
132
 
114
133
  ### destination
115
134
 
116
135
  `string`
117
136
 
137
+ The base HTML string to merge into.
138
+
118
139
  ### source
119
140
 
120
141
  `string`
121
142
 
143
+ The HTML string whose head meta tags will be merged.
144
+
122
145
  ## Returns
123
146
 
124
147
  `string`
125
148
 
149
+ The merged HTML string.
150
+
126
151
  ### <a id="metaBuilder"></a>metaBuilder
127
152
 
128
153
  [**@xylabs/sdk-meta**](#../README)
@@ -136,24 +161,34 @@ function metaBuilder(
136
161
  handler?): string;
137
162
  ```
138
163
 
164
+ Injects meta properties, title, and description into an HTML string.
165
+
139
166
  ## Parameters
140
167
 
141
168
  ### html
142
169
 
143
170
  `string`
144
171
 
172
+ The base HTML string to modify.
173
+
145
174
  ### meta
146
175
 
147
176
  [`Meta`](#../interfaces/Meta)
148
177
 
178
+ The metadata to inject.
179
+
149
180
  ### handler?
150
181
 
151
182
  `string`
152
183
 
184
+ Optional meta-handler property value to include.
185
+
153
186
  ## Returns
154
187
 
155
188
  `string`
156
189
 
190
+ The modified HTML string with injected metadata.
191
+
157
192
  ### interfaces
158
193
 
159
194
  ### <a id="Meta"></a>Meta
@@ -162,6 +197,8 @@ function metaBuilder(
162
197
 
163
198
  ***
164
199
 
200
+ Represents page metadata including Open Graph and Twitter card properties.
201
+
165
202
  ## Properties
166
203
 
167
204
  ### description?
@@ -200,6 +237,8 @@ optional twitter: TwitterMeta;
200
237
 
201
238
  ***
202
239
 
240
+ Open Graph protocol metadata for rich link previews.
241
+
203
242
  ## Properties
204
243
 
205
244
  ### audio?
@@ -286,6 +325,8 @@ optional video: OpenGraphStructuredProperty;
286
325
 
287
326
  ***
288
327
 
328
+ Structured properties for an Open Graph media object (image, video, or audio).
329
+
289
330
  ## Properties
290
331
 
291
332
  ### ?
@@ -348,6 +389,8 @@ optional width: number;
348
389
 
349
390
  ***
350
391
 
392
+ Twitter App Card metadata containing app store identifiers, names, and URLs per platform.
393
+
351
394
  ## Properties
352
395
 
353
396
  ### id?
@@ -639,6 +682,8 @@ type OpenGraphStructuredProperty =
639
682
  | (string | OpenGraphStructured)[];
640
683
  ```
641
684
 
685
+ A structured Open Graph property value: a URL string, a structured object, or an array of either.
686
+
642
687
  ### <a id="StringIndexable"></a>StringIndexable
643
688
 
644
689
  [**@xylabs/sdk-meta**](#../README)
@@ -649,6 +694,8 @@ type OpenGraphStructuredProperty =
649
694
  type StringIndexable = object;
650
695
  ```
651
696
 
697
+ An object with string keys and arbitrary values, used for recursive meta flattening.
698
+
652
699
  ## Index Signature
653
700
 
654
701
  ```ts
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Merges meta tags from the source HTML head into the destination HTML head.
3
+ * Existing meta tags with matching property attributes are replaced; others are appended.
4
+ * @param destination - The base HTML string to merge into.
5
+ * @param source - The HTML string whose head meta tags will be merged.
6
+ * @returns The merged HTML string.
7
+ */
1
8
  export declare const mergeDocumentHead: (destination: string, source: string) => string;
2
9
  //# sourceMappingURL=mergeDocumentHead.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeDocumentHead.d.ts","sourceRoot":"","sources":["../../../src/html/mergeDocumentHead.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,EAAE,QAAQ,MAAM,WAwCpE,CAAA"}
1
+ {"version":3,"file":"mergeDocumentHead.d.ts","sourceRoot":"","sources":["../../../src/html/mergeDocumentHead.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,EAAE,QAAQ,MAAM,WAwCpE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/html/mergeDocumentHead.ts","../../src/lib/getMetaAsDict.ts","../../src/meta/builder.ts"],"sourcesContent":["import { isString } from '@xylabs/typeof'\nimport { load } from 'cheerio'\n\nconst opts = {}\n// const opts = { decodeEntities: false }\n\nexport const mergeDocumentHead = (destination: string, source: string) => {\n const $destination = load(destination, opts)\n const $source = load(source, opts)\n\n // For each child node of the source head\n $source('head')\n .children()\n .each((_, element) => {\n const el = $destination(element)\n\n // Special case for meta tags: We want to match them by the name attribute\n if (el[0].tagName === 'meta') {\n const property = el.attr('property')\n if (isString(property)) {\n const match = $destination(`head meta[property=\"${property}\"]`)\n\n // If it exists, replace it, otherwise append it\n if (match.length > 0) {\n match.replaceWith(el)\n return\n } else {\n $destination('head').append(el)\n }\n }\n // else {\n // // For all other elements, just check if the same element exists in the first HTML string\n // const match = $destination(el[0].tagName)\n\n // // If it exists, replace it, otherwise append it\n // if (match.length > 0) {\n // match.replaceWith(el)\n // } else {\n // $destination('head').append(el)\n // }\n // }\n }\n })\n\n // Return the merged HTML\n return $destination.html(opts)\n}\n","import { isString } from '@xylabs/typeof'\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type StringIndexable = { [key: string]: any }\n\nconst propertyDelimiter = ':'\n\nexport const getMetaAsDict = (obj: StringIndexable, parentKey?: string): Record<string, string> => {\n let flatRecord: StringIndexable = {}\n for (const key in obj) {\n if (typeof obj[key] === 'object' && obj[key] !== null) {\n // If the value is another object, we want to iterate through its keys as well.\n const childRecord = getMetaAsDict(obj[key] as StringIndexable, `${isString(parentKey) ? parentKey : ''}${key}${propertyDelimiter}`)\n flatRecord = { ...flatRecord, ...childRecord }\n } else {\n // Concatenate the key with its parent key.\n const newKey = isString(parentKey) ? `${parentKey}${key}` : key\n const trimmed = newKey.endsWith(propertyDelimiter) ? newKey.slice(0, -1) : newKey\n flatRecord[trimmed] = `${obj[key]}`\n }\n }\n return flatRecord\n}\n","import { isString } from '@xylabs/typeof'\nimport type { CheerioAPI } from 'cheerio'\nimport { load } from 'cheerio'\n\nimport { getMetaAsDict } from '../lib/index.ts'\nimport type { Meta } from '../models/index.ts'\n\n/* test change */\n\nexport const addMetaToHead = ($: CheerioAPI, name: string, value: string | object) => {\n if (typeof value === 'string') {\n const newMeta = `<meta property=\"${name}\" content=\"${value}\" />`\n const existingMeta = $(`head meta[property=\"${name}\"]`)\n if ((existingMeta?.length ?? 0) > 0) {\n existingMeta.replaceWith(newMeta)\n } else {\n $('head').append(newMeta)\n }\n } else if (Array.isArray(value)) {\n for (const item of value) addMetaToHead($, `${name}`, item)\n } else if (typeof value === 'object') {\n for (let [key, v] of Object.entries(value)) {\n if (key === 'url') {\n addMetaToHead($, name, v)\n } else {\n addMetaToHead($, `${name}:${key}`, v)\n }\n }\n } else {\n throw new TypeError(`Invalid item type [${name}, ${typeof value}]`)\n }\n}\n\nexport const metaBuilder = (html: string, meta: Meta, handler?: string) => {\n const $ = load(html)\n // NOTE: This assumes unique meta properties (no duplicates)\n // which is generally the case, but not always (you can have\n // multiple og:video:tag tags, for example)\n const metaProperties = getMetaAsDict(meta)\n for (const [key, value] of Object.entries(metaProperties)) {\n addMetaToHead($, key, value)\n }\n if (isString(meta.description)) {\n addMetaToHead($, 'description', meta.description)\n }\n if (isString(meta.title)) {\n $('title').text(meta.title)\n }\n if (isString(handler)) {\n addMetaToHead($, 'meta-handler', handler)\n }\n return $.html()\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAErB,IAAM,OAAO,CAAC;AAGP,IAAM,oBAAoB,CAAC,aAAqB,WAAmB;AACxE,QAAM,eAAe,KAAK,aAAa,IAAI;AAC3C,QAAM,UAAU,KAAK,QAAQ,IAAI;AAGjC,UAAQ,MAAM,EACX,SAAS,EACT,KAAK,CAAC,GAAG,YAAY;AACpB,UAAM,KAAK,aAAa,OAAO;AAG/B,QAAI,GAAG,CAAC,EAAE,YAAY,QAAQ;AAC5B,YAAM,WAAW,GAAG,KAAK,UAAU;AACnC,UAAI,SAAS,QAAQ,GAAG;AACtB,cAAM,QAAQ,aAAa,uBAAuB,QAAQ,IAAI;AAG9D,YAAI,MAAM,SAAS,GAAG;AACpB,gBAAM,YAAY,EAAE;AACpB;AAAA,QACF,OAAO;AACL,uBAAa,MAAM,EAAE,OAAO,EAAE;AAAA,QAChC;AAAA,MACF;AAAA,IAYF;AAAA,EACF,CAAC;AAGH,SAAO,aAAa,KAAK,IAAI;AAC/B;;;AC9CA,SAAS,YAAAA,iBAAgB;AAIzB,IAAM,oBAAoB;AAEnB,IAAM,gBAAgB,CAAC,KAAsB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AA,IACF;AAAA,EACF,OAAO;AACL,UAAM,IAAI,UAAU,sBAAsB,IAAI,KAAK,OAAO,KAAK,GAAG;AAAA,EACpE;AACF;AAEO,IAAM,cAAc,CAAC,MAAc,MAAY,YAAqB;AACzE,QAAM,IAAIC,MAAK,IAAI;AAInB,QAAM,iBAAiB,cAAc,IAAI;AACzC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,cAAc,GAAG;AACzD,kBAAc,GAAG,KAAK,KAAK;AAAA,EAC7B;AACA,MAAIC,UAAS,KAAK,WAAW,GAAG;AAC9B,kBAAc,GAAG,eAAe,KAAK,WAAW;AAAA,EAClD;AACA,MAAIA,UAAS,KAAK,KAAK,GAAG;AACxB,MAAE,OAAO,EAAE,KAAK,KAAK,KAAK;AAAA,EAC5B;AACA,MAAIA,UAAS,OAAO,GAAG;AACrB,kBAAc,GAAG,gBAAgB,OAAO;AAAA,EAC1C;AACA,SAAO,EAAE,KAAK;AAChB;","names":["isString","isString","load","load","isString"]}
1
+ {"version":3,"sources":["../../src/html/mergeDocumentHead.ts","../../src/lib/getMetaAsDict.ts","../../src/meta/builder.ts"],"sourcesContent":["import { isString } from '@xylabs/typeof'\nimport { load } from 'cheerio'\n\nconst opts = {}\n// const opts = { decodeEntities: false }\n\n/**\n * Merges meta tags from the source HTML head into the destination HTML head.\n * Existing meta tags with matching property attributes are replaced; others are appended.\n * @param destination - The base HTML string to merge into.\n * @param source - The HTML string whose head meta tags will be merged.\n * @returns The merged HTML string.\n */\nexport const mergeDocumentHead = (destination: string, source: string) => {\n const $destination = load(destination, opts)\n const $source = load(source, opts)\n\n // For each child node of the source head\n $source('head')\n .children()\n .each((_, element) => {\n const el = $destination(element)\n\n // Special case for meta tags: We want to match them by the name attribute\n if (el[0].tagName === 'meta') {\n const property = el.attr('property')\n if (isString(property)) {\n const match = $destination(`head meta[property=\"${property}\"]`)\n\n // If it exists, replace it, otherwise append it\n if (match.length > 0) {\n match.replaceWith(el)\n return\n } else {\n $destination('head').append(el)\n }\n }\n // else {\n // // For all other elements, just check if the same element exists in the first HTML string\n // const match = $destination(el[0].tagName)\n\n // // If it exists, replace it, otherwise append it\n // if (match.length > 0) {\n // match.replaceWith(el)\n // } else {\n // $destination('head').append(el)\n // }\n // }\n }\n })\n\n // Return the merged HTML\n return $destination.html(opts)\n}\n","import { isString } from '@xylabs/typeof'\n\n/** An object with string keys and arbitrary values, used for recursive meta flattening. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type StringIndexable = { [key: string]: any }\n\nconst propertyDelimiter = ':'\n\n/**\n * Recursively flattens a nested meta object into a flat dictionary with colon-delimited keys.\n * @param obj - The nested object to flatten.\n * @param parentKey - The accumulated key prefix from parent levels.\n * @returns A flat record mapping colon-delimited property names to string values.\n */\nexport const getMetaAsDict = (obj: StringIndexable, parentKey?: string): Record<string, string> => {\n let flatRecord: StringIndexable = {}\n for (const key in obj) {\n if (typeof obj[key] === 'object' && obj[key] !== null) {\n // If the value is another object, we want to iterate through its keys as well.\n const childRecord = getMetaAsDict(obj[key] as StringIndexable, `${isString(parentKey) ? parentKey : ''}${key}${propertyDelimiter}`)\n flatRecord = { ...flatRecord, ...childRecord }\n } else {\n // Concatenate the key with its parent key.\n const newKey = isString(parentKey) ? `${parentKey}${key}` : key\n const trimmed = newKey.endsWith(propertyDelimiter) ? newKey.slice(0, -1) : newKey\n flatRecord[trimmed] = `${obj[key]}`\n }\n }\n return flatRecord\n}\n","import { isString } from '@xylabs/typeof'\nimport type { CheerioAPI } from 'cheerio'\nimport { load } from 'cheerio'\n\nimport { getMetaAsDict } from '../lib/index.ts'\nimport type { Meta } from '../models/index.ts'\n\n/* test change */\n\n/**\n * Adds or replaces a meta tag in the document head.\n * @param $ - The Cheerio API instance for the document.\n * @param name - The meta property name.\n * @param value - The meta content value (string, array, or nested object).\n */\nexport const addMetaToHead = ($: CheerioAPI, name: string, value: string | object) => {\n if (typeof value === 'string') {\n const newMeta = `<meta property=\"${name}\" content=\"${value}\" />`\n const existingMeta = $(`head meta[property=\"${name}\"]`)\n if ((existingMeta?.length ?? 0) > 0) {\n existingMeta.replaceWith(newMeta)\n } else {\n $('head').append(newMeta)\n }\n } else if (Array.isArray(value)) {\n for (const item of value) addMetaToHead($, `${name}`, item)\n } else if (typeof value === 'object') {\n for (let [key, v] of Object.entries(value)) {\n if (key === 'url') {\n addMetaToHead($, name, v)\n } else {\n addMetaToHead($, `${name}:${key}`, v)\n }\n }\n } else {\n throw new TypeError(`Invalid item type [${name}, ${typeof value}]`)\n }\n}\n\n/**\n * Injects meta properties, title, and description into an HTML string.\n * @param html - The base HTML string to modify.\n * @param meta - The metadata to inject.\n * @param handler - Optional meta-handler property value to include.\n * @returns The modified HTML string with injected metadata.\n */\nexport const metaBuilder = (html: string, meta: Meta, handler?: string) => {\n const $ = load(html)\n // NOTE: This assumes unique meta properties (no duplicates)\n // which is generally the case, but not always (you can have\n // multiple og:video:tag tags, for example)\n const metaProperties = getMetaAsDict(meta)\n for (const [key, value] of Object.entries(metaProperties)) {\n addMetaToHead($, key, value)\n }\n if (isString(meta.description)) {\n addMetaToHead($, 'description', meta.description)\n }\n if (isString(meta.title)) {\n $('title').text(meta.title)\n }\n if (isString(handler)) {\n addMetaToHead($, 'meta-handler', handler)\n }\n return $.html()\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAErB,IAAM,OAAO,CAAC;AAUP,IAAM,oBAAoB,CAAC,aAAqB,WAAmB;AACxE,QAAM,eAAe,KAAK,aAAa,IAAI;AAC3C,QAAM,UAAU,KAAK,QAAQ,IAAI;AAGjC,UAAQ,MAAM,EACX,SAAS,EACT,KAAK,CAAC,GAAG,YAAY;AACpB,UAAM,KAAK,aAAa,OAAO;AAG/B,QAAI,GAAG,CAAC,EAAE,YAAY,QAAQ;AAC5B,YAAM,WAAW,GAAG,KAAK,UAAU;AACnC,UAAI,SAAS,QAAQ,GAAG;AACtB,cAAM,QAAQ,aAAa,uBAAuB,QAAQ,I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,QAAQ,MAAO,eAAc,GAAG,GAAG,IAAI,IAAI,IAAI;AAAA,EAC5D,WAAW,OAAO,UAAU,UAAU;AACpC,aAAS,CAAC,KAAK,CAAC,KAAK,OAAO,QAAQ,KAAK,GAAG;AAC1C,UAAI,QAAQ,OAAO;AACjB,sBAAc,GAAG,MAAM,CAAC;AAAA,MAC1B,OAAO;AACL,sBAAc,GAAG,GAAG,IAAI,IAAI,GAAG,IAAI,CAAC;AAAA,MACtC;AAAA,IACF;AAAA,EACF,OAAO;AACL,UAAM,IAAI,UAAU,sBAAsB,IAAI,KAAK,OAAO,KAAK,GAAG;AAAA,EACpE;AACF;AASO,IAAM,cAAc,CAAC,MAAc,MAAY,YAAqB;AACzE,QAAM,IAAIC,MAAK,IAAI;AAInB,QAAM,iBAAiB,cAAc,IAAI;AACzC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,cAAc,GAAG;AACzD,kBAAc,GAAG,KAAK,KAAK;AAAA,EAC7B;AACA,MAAIC,UAAS,KAAK,WAAW,GAAG;AAC9B,kBAAc,GAAG,eAAe,KAAK,WAAW;AAAA,EAClD;AACA,MAAIA,UAAS,KAAK,KAAK,GAAG;AACxB,MAAE,OAAO,EAAE,KAAK,KAAK,KAAK;AAAA,EAC5B;AACA,MAAIA,UAAS,OAAO,GAAG;AACrB,kBAAc,GAAG,gBAAgB,OAAO;AAAA,EAC1C;AACA,SAAO,EAAE,KAAK;AAChB;","names":["isString","isString","load","load","isString"]}
@@ -1,5 +1,12 @@
1
+ /** An object with string keys and arbitrary values, used for recursive meta flattening. */
1
2
  export type StringIndexable = {
2
3
  [key: string]: any;
3
4
  };
5
+ /**
6
+ * Recursively flattens a nested meta object into a flat dictionary with colon-delimited keys.
7
+ * @param obj - The nested object to flatten.
8
+ * @param parentKey - The accumulated key prefix from parent levels.
9
+ * @returns A flat record mapping colon-delimited property names to string values.
10
+ */
4
11
  export declare const getMetaAsDict: (obj: StringIndexable, parentKey?: string) => Record<string, string>;
5
12
  //# sourceMappingURL=getMetaAsDict.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getMetaAsDict.d.ts","sourceRoot":"","sources":["../../../src/lib/getMetaAsDict.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAIpD,eAAO,MAAM,aAAa,GAAI,KAAK,eAAe,EAAE,YAAY,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAe7F,CAAA"}
1
+ {"version":3,"file":"getMetaAsDict.d.ts","sourceRoot":"","sources":["../../../src/lib/getMetaAsDict.ts"],"names":[],"mappings":"AAEA,2FAA2F;AAE3F,MAAM,MAAM,eAAe,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAIpD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,eAAe,EAAE,YAAY,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAe7F,CAAA"}
@@ -1,5 +1,18 @@
1
1
  import type { CheerioAPI } from 'cheerio';
2
2
  import type { Meta } from '../models/index.ts';
3
+ /**
4
+ * Adds or replaces a meta tag in the document head.
5
+ * @param $ - The Cheerio API instance for the document.
6
+ * @param name - The meta property name.
7
+ * @param value - The meta content value (string, array, or nested object).
8
+ */
3
9
  export declare const addMetaToHead: ($: CheerioAPI, name: string, value: string | object) => void;
10
+ /**
11
+ * Injects meta properties, title, and description into an HTML string.
12
+ * @param html - The base HTML string to modify.
13
+ * @param meta - The metadata to inject.
14
+ * @param handler - Optional meta-handler property value to include.
15
+ * @returns The modified HTML string with injected metadata.
16
+ */
4
17
  export declare const metaBuilder: (html: string, meta: Meta, handler?: string) => string;
5
18
  //# sourceMappingURL=builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/meta/builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAI9C,eAAO,MAAM,aAAa,GAAI,GAAG,UAAU,EAAE,MAAM,MAAM,EAAE,OAAO,MAAM,GAAG,MAAM,SAsBhF,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,MAAM,IAAI,EAAE,UAAU,MAAM,WAmBrE,CAAA"}
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/meta/builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAI9C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,UAAU,EAAE,MAAM,MAAM,EAAE,OAAO,MAAM,GAAG,MAAM,SAsBhF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,MAAM,IAAI,EAAE,UAAU,MAAM,WAmBrE,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import type { OpenGraphMeta } from './OpenGraph/index.ts';
2
2
  import type { TwitterMeta } from './Twitter/index.ts';
3
+ /** Represents page metadata including Open Graph and Twitter card properties. */
3
4
  export interface Meta {
4
5
  description?: string;
5
6
  og?: OpenGraphMeta;
@@ -1 +1 @@
1
- {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../../../src/models/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,MAAM,WAAW,IAAI;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,WAAW,CAAA;CACtB"}
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../../../src/models/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,iFAAiF;AACjF,MAAM,WAAW,IAAI;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,WAAW,CAAA;CACtB"}
@@ -1,4 +1,5 @@
1
1
  import type { OpenGraphStructuredProperty } from './OpenGraphStructuredProperty.ts';
2
+ /** Open Graph protocol metadata for rich link previews. */
2
3
  export interface OpenGraphMeta {
3
4
  audio?: OpenGraphStructuredProperty;
4
5
  description?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenGraphMeta.d.ts","sourceRoot":"","sources":["../../../../src/models/OpenGraph/OpenGraphMeta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AAKnF,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,2BAA2B,CAAA;IACnC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,2BAA2B,CAAA;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,2BAA2B,CAAA;CACpC"}
1
+ {"version":3,"file":"OpenGraphMeta.d.ts","sourceRoot":"","sources":["../../../../src/models/OpenGraph/OpenGraphMeta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AAKnF,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,2BAA2B,CAAA;IACnC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,2BAA2B,CAAA;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,2BAA2B,CAAA;CACpC"}
@@ -1,3 +1,4 @@
1
+ /** Structured properties for an Open Graph media object (image, video, or audio). */
1
2
  export interface OpenGraphStructured {
2
3
  ''?: string;
3
4
  'alt'?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenGraphStructured.d.ts","sourceRoot":"","sources":["../../../../src/models/OpenGraph/OpenGraphStructured.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
1
+ {"version":3,"file":"OpenGraphStructured.d.ts","sourceRoot":"","sources":["../../../../src/models/OpenGraph/OpenGraphStructured.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IAClC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
@@ -1,3 +1,4 @@
1
1
  import type { OpenGraphStructured } from './OpenGraphStructured.ts';
2
+ /** A structured Open Graph property value: a URL string, a structured object, or an array of either. */
2
3
  export type OpenGraphStructuredProperty = string | OpenGraphStructured | (string | OpenGraphStructured)[];
3
4
  //# sourceMappingURL=OpenGraphStructuredProperty.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenGraphStructuredProperty.d.ts","sourceRoot":"","sources":["../../../../src/models/OpenGraph/OpenGraphStructuredProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnE,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,mBAAmB,GAAG,CAAC,MAAM,GAAG,mBAAmB,CAAC,EAAE,CAAA"}
1
+ {"version":3,"file":"OpenGraphStructuredProperty.d.ts","sourceRoot":"","sources":["../../../../src/models/OpenGraph/OpenGraphStructuredProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnE,wGAAwG;AACxG,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,mBAAmB,GAAG,CAAC,MAAM,GAAG,mBAAmB,CAAC,EAAE,CAAA"}
@@ -1,3 +1,4 @@
1
+ /** Twitter App Card metadata containing app store identifiers, names, and URLs per platform. */
1
2
  export interface TwitterApp {
2
3
  id?: {
3
4
  googleplay?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"TwitterApp.d.ts","sourceRoot":"","sources":["../../../../src/models/Twitter/TwitterApp.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,EAAE,CAAC,EAAE;QACH,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,IAAI,CAAC,EAAE;QACL,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,GAAG,CAAC,EAAE;QACJ,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF"}
1
+ {"version":3,"file":"TwitterApp.d.ts","sourceRoot":"","sources":["../../../../src/models/Twitter/TwitterApp.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,MAAM,WAAW,UAAU;IACzB,EAAE,CAAC,EAAE;QACH,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,IAAI,CAAC,EAAE;QACL,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,GAAG,CAAC,EAAE;QACJ,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/sdk-meta",
3
- "version": "5.0.82",
3
+ "version": "5.0.84",
4
4
  "description": "Base functionality used throughout XYO TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "meta",
@@ -37,13 +37,13 @@
37
37
  "!**/*.test.*"
38
38
  ],
39
39
  "dependencies": {
40
- "@xylabs/typeof": "~5.0.82",
40
+ "@xylabs/typeof": "~5.0.84",
41
41
  "cheerio": "~1.2.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "~25.4.0",
45
- "@xylabs/ts-scripts-yarn3": "~7.4.11",
46
- "@xylabs/tsconfig": "~7.4.11",
45
+ "@xylabs/ts-scripts-yarn3": "~7.4.13",
46
+ "@xylabs/tsconfig": "~7.4.13",
47
47
  "typescript": "~5.9.3",
48
48
  "vitest": "~4.0.18"
49
49
  },