@stacksjs/image 0.72.38 → 0.72.39

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/fonts.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import{existsSync}from"node:fs";import{readFile}from"node:fs/promises";import{isAbsolute,resolve}from"node:path";import process from"node:process";import{loadFont}from"ts-images";export function resolveFontPath(value,root=process.cwd()){if(isAbsolute(value))return value;const local=resolve(root,value);if(existsSync(local))return local;try{return Bun.resolveSync(value,root)}catch{throw Error(`[image] Font not found: ${value}
2
2
  Looked for ${local} and for a module resolvable from ${root}.
3
- Set \`images.fonts.title\` in config/images.ts to a TrueType (.ttf) file. OpenType/CFF (.otf) and WOFF2 are not TrueType outlines and cannot be read.`)}}export async function loadFonts(fonts,root=process.cwd()){if(!fonts?.title)throw Error("[image] No font configured. Set `images.fonts.title` in config/images.ts to a TrueType (.ttf) file \u2014 "+"generated cards and screenshots draw real glyphs and cannot fall back to a system face.");const title=loadFont(new Uint8Array(await readFile(resolveFontPath(fonts.title,root)))),body=fonts.body?loadFont(new Uint8Array(await readFile(resolveFontPath(fonts.body,root)))):title;return{title,body}}
3
+ Set \`images.fonts.title\` in config/images.ts to a TrueType (.ttf) file. OpenType/CFF (.otf) and WOFF2 are not TrueType outlines and cannot be read.`)}}export async function loadFonts(fonts,root=process.cwd()){if(!fonts?.title)throw Error("[image] No font configured. Set `images.fonts.title` in config/images.ts to a TrueType (.ttf) file - generated cards and screenshots draw real glyphs and cannot fall back to a system face.");const title=loadFont(new Uint8Array(await readFile(resolveFontPath(fonts.title,root)))),body=fonts.body?loadFont(new Uint8Array(await readFile(resolveFontPath(fonts.body,root)))):title;return{title,body}}
package/dist/theme.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import{existsSync}from"node:fs";import{readFile}from"node:fs/promises";import{isAbsolute,resolve}from"node:path";import process from"node:process";import{decode,drawImage,parseColor}from"ts-images";export function projectFile(path,root=process.cwd()){return isAbsolute(path)?path:resolve(root,path)}export function requireProjectFile(path,root,describe){const resolved=projectFile(path,root);if(!existsSync(resolved))throw Error(`[image] ${describe} not found: ${path}
2
- Looked in ${resolved}. Capture it before generating \u2014 \`buddy generate:images\` frames existing captures, it does not take them.`);return resolved}export function color(value){return value===void 0?void 0:parseColor(value)}export function background(value,root=process.cwd()){if(!value)return;return{color:color(value.color),gradient:value.gradient&&{angle:value.gradient.angle,stops:value.gradient.stops.map((stop)=>({offset:stop.offset,color:parseColor(stop.color)}))},glows:value.glows?.map((glow)=>({...glow,color:parseColor(glow.color)})),image:value.image?projectFile(value.image,root):void 0}}export function device(value){if(!value)return;return{radius:value.radius,scale:value.scale,borderColor:color(value.borderColor),shadow:value.shadow===!1?void 0:{...value.shadow??{},color:color(value.shadow?.color)}}}export async function markPainter(path,root=process.cwd()){if(!path)return;const mark=await decode(new Uint8Array(await readFile(projectFile(path,root)))),aspect=mark.height>0?mark.width/mark.height:1;return{aspect,draw:(canvas,box)=>{drawImage(canvas,mark,{x:box.x,y:box.y,width:box.width??box.size*aspect,height:box.size,fit:"contain"})}}}export function themed(images,section){return{...section??{},background:section?.background??images.background,color:section?.color??images.color,mutedColor:section?.mutedColor??images.mutedColor,accent:section?.accent??images.accent,device:section?.device??images.device,brand:section?.brand??images.brand,mark:section?.mark??images.mark,markPlate:section?.markPlate!==void 0?section.markPlate:images.markPlate}}
2
+ Looked in ${resolved}. Capture it before generating - \`buddy generate:images\` frames existing captures, it does not take them.`);return resolved}export function color(value){return value===void 0?void 0:parseColor(value)}export function background(value,root=process.cwd()){if(!value)return;return{color:color(value.color),gradient:value.gradient&&{angle:value.gradient.angle,stops:value.gradient.stops.map((stop)=>({offset:stop.offset,color:parseColor(stop.color)}))},glows:value.glows?.map((glow)=>({...glow,color:parseColor(glow.color)})),image:value.image?projectFile(value.image,root):void 0}}export function device(value){if(!value)return;return{radius:value.radius,scale:value.scale,borderColor:color(value.borderColor),shadow:value.shadow===!1?void 0:{...value.shadow??{},color:color(value.shadow?.color)}}}export async function markPainter(path,root=process.cwd()){if(!path)return;const mark=await decode(new Uint8Array(await readFile(projectFile(path,root)))),aspect=mark.height>0?mark.width/mark.height:1;return{aspect,draw:(canvas,box)=>{drawImage(canvas,mark,{x:box.x,y:box.y,width:box.width??box.size*aspect,height:box.size,fit:"contain"})}}}export function themed(images,section){return{...section??{},background:section?.background??images.background,color:section?.color??images.color,mutedColor:section?.mutedColor??images.mutedColor,accent:section?.accent??images.accent,device:section?.device??images.device,brand:section?.brand??images.brand,mark:section?.mark??images.mark,markPlate:section?.markPlate!==void 0?section.markPlate:images.markPlate}}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/image",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.72.38",
5
+ "version": "0.72.39",
6
6
  "description": "Native responsive image delivery for Stacks.",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "prepublishOnly": "bun run build"
32
32
  },
33
33
  "dependencies": {
34
- "@stacksjs/types": "0.72.38",
34
+ "@stacksjs/types": "0.72.39",
35
35
  "ts-images": "^0.2.11"
36
36
  },
37
37
  "devDependencies": {