Repository navigation
Version Packages - #139
Merged
Merged
Version Packages#139
Conversation
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@beesolve/file-storage@0.3.0
Minor Changes
readImageDimensions({ identifier, access })to the object returned bycreateFileStorage. It reads the pixel size of an uploaded JPEG, PNG, WebP (animated included) or GIF with rangedGetObjectrequests (64 KiB, then 256 KiB, then 1 MiB) and writes nothing to S3. JPEG sizes are after EXIF orientation, which is what the optimizer expects assource: { width, height }forrectchains. It returnsundefinedfor other files and unreadable headers and throws for a missing object. Persist the result yourself, for example in youronUploadedhandler. New exports:parseImageDimensions(pure header parser over bytes),ImageDimensions,ReadImageDimensionsProps.Patch Changes
@beesolve/image-optimizer@0.4.0
Minor Changes
c838917: Cache only what is meant to be cached, and negative-cache platform errors briefly. A function timeout is answered by the Function URL as HTTP 200 with the body
Sandbox.Timedoutand noCache-Control, which CloudFront used to cache forcacheTtl(a year by default). Every handler response setsCache-Control(public, max-age={cacheTtl}orno-store), so the cache policyDefaultTTLnow only applies to responses the Lambda platform produces itself (timeouts, runtime errors, out-of-memory kills). New propfailureCacheTtl(defaultDuration.minutes(5),Duration.seconds(0)disables, whole seconds, at mostcacheTtl) is thatDefaultTTL;MinTTLis 0 andMaxTTLiscacheTtl. A repeat of a failing URL is a cache hit for 5 minutes instead of running the full timeout again. Trade-offs: a transient failure sticks for the TTL per edge location, and it throttles repeats of the same URL only, not distinct URLs (usereservedConcurrentExecutionsand WAF rate limiting for that). 4xx and 5xx statuses are governed by CloudFront error caching, not by this TTL. Handler errors (no-store) are not cached, measured for 404 and 422. The bucket behavior for other files is unchanged. Behavior change: deploying updates the cache policy, responses cached earlier stay until they expire or are invalidated. See ADR-023 and ADR-024.c838917: Add the
rect=x,y,w,hparameter. Integers are pixels of the oriented original, a value with a decimal point is a fraction of the width or height (0.5puts the edge at the centre,1.0is the whole size),fullis the whole width or height forwandh.1is one pixel,1.0is 100 percent. Fractions are rounded to 4 decimals and keep their decimal point in the cache key, they are resolved against the oriented original (Math.round(fraction * size)). The position keywords work like in imgix:xacceptsleft,centerandright,yacceptstop,middleandbottom(centeris half of the free space,(size - region size) / 2, rounded). Keywords stay in the cache key as written in lowercase, on the wrong axis or forwandhthey answer 400. The region is cut first and the other parameters work on it. Out-of-range values are clamped, a region without pixels answers 400. Needs the native module and skips size buckets.Add the
original=1parameter and theoriginalmutation. The optimizer streams the stored bytes with the stored content type and cache headers (X-Image-Optimizer: original, noVary), without sniffing or decoding, somaxSourceBytesdoes not apply. Combined with any other supported parameter it answers 400, at the edge as well.generateUrlandimageUrl(...).original()throw whenoriginalis combined with another mutation. Large files stream through the Lambda (200 MB limit, 2 MBps after 6 MB), raisetimeoutfor them. New export:Original. TheOutcometype has a neworiginalkind.Add the
rectmutation, order-aware chains and theimageUrlbuilder to the SDK.generateUrlapplies an array that contains arectin array order, maps the rect back to pixels of the original (new optionalsource: { width, height }, required when a size mutation comes before arect) and collapses the chain into one URL. Size mutations may repeat when arectseparates them. Arrays withoutrectproduce the same URLs as before. Mapped coordinates are rounded, so the cut can differ by one pixel from a step-by-step edit.rotate,flip,pixelRatio,coverBoxandpadBoxin positions that the optimizer can not honor throw an error that names the mutations. New exports:imageUrl,ImageUrlBuilder,ImageUrlProps,MutationProps,Rect,SourceSize.Add the
rectFractionmutation (andimageUrl(...).rectFraction) with fractions and"full", and the keywords"left","center","right"forxand"top","middle","bottom"fory. A singlerectFractionstays in the URL as fractions, needs nosourceeven afterfitBox,fitWidth,fitHeightorstretch(a resize keeps fractions) and throws aftercoverBoxorpadBox. It needssourcewhen the result size depends on the canvas (a size mutation before it and none orenlarge: falseafter it) and next to any otherrect. New export:RectFraction. The viewer request function is now fully minified (identifiers and syntax, ADR-021) and is 6767 bytes, far below the 10240 byte limit. Behavior is unchanged.Add focal point cropping:
fit=crop&crop=focalpoint&fp-x=..&fp-y=..&fp-z=...fp-xandfp-yare fractions (0 to 1, default 0.5) and the box is centred on the point and clamped to stay inside the image.fp-z(1 to 100, default 1, imgix semantics: 2 is 200 percent) zooms around the point. Values are rounded to at most 4 decimals, defaults are dropped, andcrop=focalpointwithout a non-default value canonicalizes to plainfit=crop.fp-*withoutcrop=focalpoint,crop=focalpointwithoutfit=crop, and out-of-range values answer 400, at the edge as well. A zoomed image abovemaxPixelsanswers 400. Size buckets use the zoomed cover scale. Needs the native module likefit=crop.coverBox.positionaccepts a focal point{ x, y, zoom? }. New export:FocalPoint.faces,edgesandfaceareastay unsupported.Add
crop=entropywithfit=crop. The native module scores a 16x16 grid of the scaled image by edge density and anchors the box at the weighted centroid (the focal point geometry atfp-z=1). It needs the native module (501 without), answers 400 for animated images, withoutfit=crop, and combined withfp-*or edge values, also at the edge.coverBox.positionaccepts"entropy". New export:EntropyPosition. Native module: new optionalentropystep flag.crop=facesandcrop=edgesstay unsupported.Patch Changes
docs/how-to/performance.mdand a README section. Only the first request for a URL (per edge location) pays, a function timeout is not cached but repeats on every request (see the cache policy changeset),rectdecodes the whole original on every miss. The documented cost of a 30 frame 2000x2000 animation is corrected to the measured 1.7 seconds and 156 MB. No behavior change.