@stacksjs/image 0.70.234 → 0.70.236

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/app-icons.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import process from "node:process";
2
2
  import { generateAppIcons, generateFavicons } from "ts-images";
3
- import { projectFile } from "./theme";
3
+ import { projectFile, requireProjectFile } from "./theme";
4
4
  export async function generateAppIconSet(images, root = process.cwd()) {
5
5
  const appIcons = images.appIcons;
6
6
  if (appIcons?.enabled !== !0 || !appIcons.source)
7
7
  return { icons: [], favicons: [] };
8
- const source = projectFile(appIcons.source, root), platforms = appIcons.platforms?.length ? appIcons.platforms : ["ios", "macos"], icons = await generateAppIcons(source, {
8
+ const source = requireProjectFile(appIcons.source, root, "App icon source"), platforms = appIcons.platforms?.length ? appIcons.platforms : ["ios", "macos"], icons = await generateAppIcons(source, {
9
9
  outputDir: projectFile(appIcons.outputDir ?? "resources/app-icons", root),
10
10
  platform: platforms.length === 1 ? platforms[0] : "all"
11
11
  }), favicons = appIcons.favicon ? await generateFavicons(source, projectFile(appIcons.faviconDir ?? "public", root)) : [];
package/dist/app-store.js CHANGED
@@ -2,7 +2,7 @@ import { mkdir } from "node:fs/promises";
2
2
  import process from "node:process";
3
3
  import { APP_STORE_MAX_SCREENSHOTS, generateAppStoreScreenshots } from "ts-images";
4
4
  import { loadFonts } from "./fonts";
5
- import { background, color, device, markPainter, projectFile, themed } from "./theme";
5
+ import { background, color, device, markPainter, projectFile, requireProjectFile, themed } from "./theme";
6
6
  export async function generateAppStoreScreenshotSet(images, root = process.cwd()) {
7
7
  if (images.appStore?.enabled !== !0 || !images.appStore.slides?.length)
8
8
  return {};
@@ -25,7 +25,7 @@ export async function generateAppStoreScreenshotSet(images, root = process.cwd()
25
25
  }, results = {};
26
26
  for (const display of displays) {
27
27
  const slides = declared.filter((slide) => !slide.displays?.length || slide.displays.includes(display)).map((slide) => ({
28
- capture: projectFile(slide.capture, root),
28
+ capture: requireProjectFile(slide.capture, root, `Capture for the "${slide.headline}" slide`),
29
29
  headline: slide.headline,
30
30
  subheadline: slide.subheadline,
31
31
  background: background(slide.background, root)
package/dist/social.js CHANGED
@@ -2,7 +2,7 @@ import { mkdir } from "node:fs/promises";
2
2
  import process from "node:process";
3
3
  import { generateSocialCards } from "ts-images";
4
4
  import { loadFonts } from "./fonts";
5
- import { background, color, device, markPainter, projectFile, themed } from "./theme";
5
+ import { background, color, device, markPainter, projectFile, requireProjectFile, themed } from "./theme";
6
6
  const PRESET_SIZES = {
7
7
  og: { width: 1200, height: 630 },
8
8
  twitter: { width: 1200, height: 600 },
@@ -40,7 +40,7 @@ export async function generateSocialCardSet(images, root = process.cwd()) {
40
40
  eyebrow: page.eyebrow,
41
41
  subtitle: page.subtitle,
42
42
  foreground: shot ? {
43
- image: projectFile(shot, root),
43
+ image: requireProjectFile(shot, root, `Product shot for ${page.path}`),
44
44
  radius: deviceOptions?.radius,
45
45
  borderColor: deviceOptions?.borderColor,
46
46
  shadow: deviceOptions?.shadow,
package/dist/theme.d.ts CHANGED
@@ -10,6 +10,16 @@ import type { ImageData, RGBA, SurfaceBackground } from 'ts-images';
10
10
  * which is the point of having a shared palette at all.
11
11
  */
12
12
  export declare function projectFile(path: string, root?: string): string;
13
+ /**
14
+ * Resolve a configured asset, failing with something a person can act on.
15
+ *
16
+ * These paths point at things a build step produced — a capture of a running
17
+ * app, an exported logo — so the common failure is not a typo but an ordering
18
+ * mistake: generate before capture, or after a clean that wiped the captures.
19
+ * Left to the codec, that surfaces as a bare ENOENT under ten frames of stack
20
+ * with no mention of which slide or which config key is at fault.
21
+ */
22
+ export declare function requireProjectFile(path: string, root: string, describe: string): string;
13
23
  export declare function color(value: ImageColor | undefined): RGBA | undefined;
14
24
  export declare function background(value: ImageBackgroundConfig | undefined, root?: string): SurfaceBackground | undefined;
15
25
  /**
package/dist/theme.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { existsSync } from "node:fs";
1
2
  import { readFile } from "node:fs/promises";
2
3
  import { isAbsolute, resolve } from "node:path";
3
4
  import process from "node:process";
@@ -5,6 +6,13 @@ import { decode, drawImage, parseColor } from "ts-images";
5
6
  export function projectFile(path, root = process.cwd()) {
6
7
  return isAbsolute(path) ? path : resolve(root, path);
7
8
  }
9
+ export function requireProjectFile(path, root, describe) {
10
+ const resolved = projectFile(path, root);
11
+ if (!existsSync(resolved))
12
+ throw Error(`[image] ${describe} not found: ${path}
13
+ Looked in ${resolved}. Capture it before generating \u2014 \`buddy generate:images\` frames existing captures, it does not take them.`);
14
+ return resolved;
15
+ }
8
16
  export function color(value) {
9
17
  return value === void 0 ? void 0 : parseColor(value);
10
18
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/image",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.234",
5
+ "version": "0.70.236",
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.70.234",
34
+ "@stacksjs/types": "0.70.236",
35
35
  "ts-images": "^0.2.6"
36
36
  },
37
37
  "devDependencies": {