@all-the.rest/astro-image-cdn 0.2.1 → 0.2.2
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 +1 -1
- package/package.json +1 -1
- package/src/service.js +21 -5
package/README.md
CHANGED
|
@@ -154,7 +154,7 @@ ratchet check
|
|
|
154
154
|
|
|
155
155
|
The tests include real Astro static builds using `Image`, `Picture`, and `getImage()`, a real dev-server request served from local output, unrequested-image checks, a repeated warm build, and assertions that optimized variants remain outside `dist/`.
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
To release, update `package.json`, commit and push the change, then create and push a matching `vMAJOR.MINOR.PATCH` tag. Pushing that tag is the release trigger; `.github/workflows/publish.yml` validates it against `package.json`, runs `pnpm check`, and packs the package in a verification job. A separate publishing job downloads that verified tarball and publishes it with npm Trusted Publishing (GitHub Actions OIDC) and provenance. The npm Trusted Publisher must be configured for this repository and `.github/workflows/publish.yml`. Do not run `pnpm publish` locally: releases go through the tagged GitHub Actions workflow, not a local OTP-based publish.
|
|
158
158
|
|
|
159
159
|
Version 0.1.0 was bootstrapped manually because npm requires a package to exist before a trusted publisher can be configured ([`npm trust` prerequisites](https://docs.npmjs.com/cli/v12/commands/npm-trust/#prerequisites)). Subsequent version-tag releases use GitHub Actions OIDC and npm provenance, without a long-lived publish token. A new trusted-publisher configuration must complete its first successful publish within two days or it expires.
|
|
160
160
|
|
package/package.json
CHANGED
package/src/service.js
CHANGED
|
@@ -326,11 +326,27 @@ function validateStaticTransform(options, config) {
|
|
|
326
326
|
throw new Error(`astro-image-cdn does not support fit="${options.fit}".`);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
const
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
if (
|
|
329
|
+
const sourceWidth = Number(options.src.width);
|
|
330
|
+
const sourceHeight = Number(options.src.height);
|
|
331
|
+
let width = options.width == null ? undefined : Number(options.width);
|
|
332
|
+
let height = options.height == null ? undefined : Number(options.height);
|
|
333
|
+
if (width != null && height == null) {
|
|
334
|
+
height = Math.round(width * sourceHeight / sourceWidth);
|
|
335
|
+
} else if (height != null && width == null) {
|
|
336
|
+
width = Math.round(height * sourceWidth / sourceHeight);
|
|
337
|
+
} else if (width == null && height == null) {
|
|
338
|
+
width = sourceWidth;
|
|
339
|
+
height = sourceHeight;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
width = Math.round(width);
|
|
343
|
+
height = Math.round(height);
|
|
344
|
+
const expectedHeight = Math.round(width * sourceHeight / sourceWidth);
|
|
345
|
+
const expectedWidth = Math.round(height * sourceWidth / sourceHeight);
|
|
346
|
+
const isAspectPreserving = (Number.isSafeInteger(width) && width > 0)
|
|
347
|
+
&& (Number.isSafeInteger(height) && height > 0)
|
|
348
|
+
&& (height === expectedHeight || width === expectedWidth);
|
|
349
|
+
if (!isAspectPreserving) {
|
|
334
350
|
throw new Error("astro-image-cdn generates aspect-preserving variants only; per-image cropping is not supported.");
|
|
335
351
|
}
|
|
336
352
|
|