@techninja/clearstack 0.3.44 → 0.3.46

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.
@@ -53,10 +53,12 @@ export function loadTokens(projectDir) {
53
53
  const full = resolve(projectDir, p);
54
54
  if (!existsSync(full)) continue;
55
55
  const css = readFileSync(full, 'utf-8');
56
+ /** @type {Record<string, string>} */
56
57
  const vars = {};
57
58
  for (const m of css.matchAll(/--([^:]+):\s*([^;]+)/g)) vars[m[1].trim()] = m[2].trim();
58
59
  if (Object.keys(vars).length) return vars;
59
60
  }
61
+ /** @type {Record<string, string>} */
60
62
  return {};
61
63
  }
62
64
 
@@ -67,22 +69,26 @@ export function loadTokens(projectDir) {
67
69
  * @param {{ tokens?: Record<string, string>, logo?: string, siteName?: string }} site
68
70
  */
69
71
  export function buildContext(config, itemData, site) {
70
- const t = site.tokens || {};
72
+ const t = /** @type {Record<string, string>} */ (site.tokens || {});
71
73
  const title = interpolate(config.title, itemData);
72
74
  const desc = config.description ? interpolate(config.description, itemData) : '';
73
75
  const image = config.image ? interpolate(config.image, itemData) : '';
74
76
  const baseUrl = itemData.store?.url || '';
75
77
  const resolvedImage = image && !image.startsWith('http') ? `${baseUrl}${image}` : image;
76
- const item = itemData.item || {};
77
- const emoji = item.emoji || itemData.emoji || '';
78
- const tags = item.tags || itemData.tags || [];
78
+ const item = /** @type {Record<string, unknown>} */ (itemData.item || {});
79
+ const emoji = /** @type {string} */ (item.emoji || itemData.emoji || '');
80
+ const tags = /** @type {string[]} */ (item.tags || itemData.tags || []);
79
81
  const tagsHtml = tags.map((t) => `<div class="tag">#${t}</div>`).join('');
80
- const postTitle = item.title || item.caption || item.name || '';
81
- const logoSrc = item.logo?.wordmark || item.logo?.mark || '';
82
+ const postTitle = /** @type {string} */ (item.title || item.caption || item.name || '');
83
+ const logo = /** @type {{wordmark?: string, mark?: string}} */ (item.logo || {});
84
+ const logoSrc = logo.wordmark || logo.mark || '';
82
85
  const itemLogoHtml = logoSrc ? `<img src="${logoSrc}" alt="${postTitle}">` : '';
83
- const dateFormatted = item.date ? new Date(item.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }) : '';
84
- const mediaUrl = resolvedImage || (item.files?.[0] ? `https://data.tn42.com/assets-media/${item.files[0]}` : '');
85
- const isVideo = item.type === 'video' || (item.files?.[0] || '').endsWith('.mp4');
86
+ const rawDate = /** @type {string|number} */ (item.date || '');
87
+ const dateFormatted = rawDate ? new Date(rawDate).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }) : '';
88
+ const files = /** @type {string[]} */ (item.files || []);
89
+ const mediaUrl = resolvedImage || (files[0] ? `https://data.tn42.com/assets-media/${files[0]}` : '');
90
+ const isVideo = item.type === 'video' || (files[0] || '').endsWith('.mp4');
91
+ const price = /** @type {number} */ (item.price || 0);
86
92
 
87
93
  return {
88
94
  ...itemData, ...item,
@@ -103,7 +109,7 @@ export function buildContext(config, itemData, site) {
103
109
  : mediaUrl ? `<img src="${mediaUrl}" style="position:absolute;inset:0;width:100%;height:100%;object-fit:cover">` : '',
104
110
  variantsFormatted: formatNum(item.expected_variants),
105
111
  uniqueFormatted: formatNum(item.estimated_unique_variants),
106
- priceFormatted: item.price ? `$${(item.price / 100).toFixed(2)}` : '',
112
+ priceFormatted: price ? `$${(price / 100).toFixed(2)}` : '',
107
113
  imageHtml: resolvedImage ? `<img class="hero" src="${resolvedImage}">` : '',
108
114
  cardClass: resolvedImage ? 'card-with-image' : '',
109
115
  siteLogo: site.logo ? `<img class="logo" src="${site.logo}">` : '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techninja/clearstack",
3
- "version": "0.3.44",
3
+ "version": "0.3.46",
4
4
  "type": "module",
5
5
  "description": "A no-build web component framework specification — scaffold, validate, and evolve spec-compliant projects",
6
6
  "bin": {