full site update
This commit is contained in:
10
node_modules/astro/dist/assets/services/service.d.ts
generated
vendored
10
node_modules/astro/dist/assets/services/service.d.ts
generated
vendored
@@ -1,5 +1,5 @@
|
||||
import type { AstroConfig } from '../../@types/astro.js';
|
||||
import type { ImageOutputFormat, ImageTransform, UnresolvedSrcSetValue } from '../types.js';
|
||||
import type { AstroConfig } from '../../types/public/config.js';
|
||||
import type { ImageFit, ImageOutputFormat, ImageTransform, UnresolvedSrcSetValue } from '../types.js';
|
||||
export type ImageService = LocalImageService | ExternalImageService;
|
||||
export declare function isLocalService(service: ImageService | undefined): service is LocalImageService;
|
||||
export declare function parseQuality(quality: string): string | number;
|
||||
@@ -13,7 +13,7 @@ interface SharedServiceProps<T extends Record<string, any> = Record<string, any>
|
||||
/**
|
||||
* Return the URL to the endpoint or URL your images are generated from.
|
||||
*
|
||||
* For a local service, your service should expose an endpoint handling the image requests, or use Astro's at `/_image`.
|
||||
* For a local service, your service should expose an endpoint handling the image requests, or use Astro's which by default, is located at `/_image`.
|
||||
*
|
||||
* For external services, this should point to the URL your images are coming from, for instance, `/_vercel/image`
|
||||
*
|
||||
@@ -44,7 +44,7 @@ interface SharedServiceProps<T extends Record<string, any> = Record<string, any>
|
||||
validateOptions?: (options: ImageTransform, imageConfig: ImageConfig<T>) => ImageTransform | Promise<ImageTransform>;
|
||||
}
|
||||
export type ExternalImageService<T extends Record<string, any> = Record<string, any>> = SharedServiceProps<T>;
|
||||
export type LocalImageTransform = {
|
||||
type LocalImageTransform = {
|
||||
src: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
@@ -76,6 +76,8 @@ export type BaseServiceTransform = {
|
||||
height?: number;
|
||||
format: string;
|
||||
quality?: string | null;
|
||||
fit?: ImageFit;
|
||||
position?: string;
|
||||
};
|
||||
/**
|
||||
* Basic local service using the included `_image` endpoint.
|
||||
|
98
node_modules/astro/dist/assets/services/service.js
generated
vendored
98
node_modules/astro/dist/assets/services/service.js
generated
vendored
@@ -1,8 +1,8 @@
|
||||
import { isRemoteAllowed } from "@astrojs/internal-helpers/remote";
|
||||
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
||||
import { isRemotePath, joinPaths } from "../../core/path.js";
|
||||
import { DEFAULT_HASH_PROPS, DEFAULT_OUTPUT_FORMAT, VALID_SUPPORTED_FORMATS } from "../consts.js";
|
||||
import { isESMImportedImage } from "../utils/imageKind.js";
|
||||
import { isRemoteAllowed } from "../utils/remotePattern.js";
|
||||
import { isESMImportedImage, isRemoteImage } from "../utils/imageKind.js";
|
||||
function isLocalService(service) {
|
||||
if (!service) {
|
||||
return false;
|
||||
@@ -16,10 +16,11 @@ function parseQuality(quality) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
const sortNumeric = (a, b) => a - b;
|
||||
const baseService = {
|
||||
propertiesToHash: DEFAULT_HASH_PROPS,
|
||||
validateOptions(options) {
|
||||
if (!options.src || typeof options.src !== "string" && typeof options.src !== "object") {
|
||||
if (!options.src || !isRemoteImage(options.src) && !isESMImportedImage(options.src)) {
|
||||
throw new AstroError({
|
||||
...AstroErrorData.ExpectedImage,
|
||||
message: AstroErrorData.ExpectedImage.message(
|
||||
@@ -76,11 +77,32 @@ const baseService = {
|
||||
}
|
||||
if (options.width) options.width = Math.round(options.width);
|
||||
if (options.height) options.height = Math.round(options.height);
|
||||
if (options.layout && options.width && options.height) {
|
||||
options.fit ??= "cover";
|
||||
delete options.layout;
|
||||
}
|
||||
if (options.fit === "none") {
|
||||
delete options.fit;
|
||||
}
|
||||
return options;
|
||||
},
|
||||
getHTMLAttributes(options) {
|
||||
const { targetWidth, targetHeight } = getTargetDimensions(options);
|
||||
const { src, width, height, format, quality, densities, widths, formats, ...attributes } = options;
|
||||
const {
|
||||
src,
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
quality,
|
||||
densities,
|
||||
widths,
|
||||
formats,
|
||||
layout,
|
||||
priority,
|
||||
fit,
|
||||
position,
|
||||
...attributes
|
||||
} = options;
|
||||
return {
|
||||
...attributes,
|
||||
width: targetWidth,
|
||||
@@ -90,22 +112,28 @@ const baseService = {
|
||||
};
|
||||
},
|
||||
getSrcSet(options) {
|
||||
const srcSet = [];
|
||||
const { targetWidth } = getTargetDimensions(options);
|
||||
const { targetWidth, targetHeight } = getTargetDimensions(options);
|
||||
const aspectRatio = targetWidth / targetHeight;
|
||||
const { widths, densities } = options;
|
||||
const targetFormat = options.format ?? DEFAULT_OUTPUT_FORMAT;
|
||||
let transformedWidths = (widths ?? []).sort(sortNumeric);
|
||||
let imageWidth = options.width;
|
||||
let maxWidth = Infinity;
|
||||
if (isESMImportedImage(options.src)) {
|
||||
imageWidth = options.src.width;
|
||||
maxWidth = imageWidth;
|
||||
if (transformedWidths.length > 0 && transformedWidths.at(-1) > maxWidth) {
|
||||
transformedWidths = transformedWidths.filter((width) => width <= maxWidth);
|
||||
transformedWidths.push(maxWidth);
|
||||
}
|
||||
}
|
||||
transformedWidths = Array.from(new Set(transformedWidths));
|
||||
const {
|
||||
width: transformWidth,
|
||||
height: transformHeight,
|
||||
...transformWithoutDimensions
|
||||
} = options;
|
||||
const allWidths = [];
|
||||
let allWidths = [];
|
||||
if (densities) {
|
||||
const densityValues = densities.map((density) => {
|
||||
if (typeof density === "number") {
|
||||
@@ -114,40 +142,28 @@ const baseService = {
|
||||
return parseFloat(density);
|
||||
}
|
||||
});
|
||||
const densityWidths = densityValues.sort().map((density) => Math.round(targetWidth * density));
|
||||
allWidths.push(
|
||||
...densityWidths.map((width, index) => ({
|
||||
maxTargetWidth: Math.min(width, maxWidth),
|
||||
descriptor: `${densityValues[index]}x`
|
||||
}))
|
||||
);
|
||||
} else if (widths) {
|
||||
allWidths.push(
|
||||
...widths.map((width) => ({
|
||||
maxTargetWidth: Math.min(width, maxWidth),
|
||||
descriptor: `${width}w`
|
||||
}))
|
||||
);
|
||||
const densityWidths = densityValues.sort(sortNumeric).map((density) => Math.round(targetWidth * density));
|
||||
allWidths = densityWidths.map((width, index) => ({
|
||||
width,
|
||||
descriptor: `${densityValues[index]}x`
|
||||
}));
|
||||
} else if (transformedWidths.length > 0) {
|
||||
allWidths = transformedWidths.map((width) => ({
|
||||
width,
|
||||
descriptor: `${width}w`
|
||||
}));
|
||||
}
|
||||
for (const { maxTargetWidth, descriptor } of allWidths) {
|
||||
const srcSetTransform = { ...transformWithoutDimensions };
|
||||
if (maxTargetWidth !== imageWidth) {
|
||||
srcSetTransform.width = maxTargetWidth;
|
||||
} else {
|
||||
if (options.width && options.height) {
|
||||
srcSetTransform.width = options.width;
|
||||
srcSetTransform.height = options.height;
|
||||
}
|
||||
}
|
||||
srcSet.push({
|
||||
transform: srcSetTransform,
|
||||
return allWidths.map(({ width, descriptor }) => {
|
||||
const height = Math.round(width / aspectRatio);
|
||||
const transform = { ...transformWithoutDimensions, width, height };
|
||||
return {
|
||||
transform,
|
||||
descriptor,
|
||||
attributes: {
|
||||
type: `image/${targetFormat}`
|
||||
}
|
||||
});
|
||||
}
|
||||
return srcSet;
|
||||
};
|
||||
});
|
||||
},
|
||||
getURL(options, imageConfig) {
|
||||
const searchParams = new URLSearchParams();
|
||||
@@ -162,12 +178,14 @@ const baseService = {
|
||||
w: "width",
|
||||
h: "height",
|
||||
q: "quality",
|
||||
f: "format"
|
||||
f: "format",
|
||||
fit: "fit",
|
||||
position: "position"
|
||||
};
|
||||
Object.entries(params).forEach(([param, key]) => {
|
||||
options[key] && searchParams.append(param, options[key].toString());
|
||||
});
|
||||
const imageEndpoint = joinPaths(import.meta.env.BASE_URL, "/_image");
|
||||
const imageEndpoint = joinPaths(import.meta.env.BASE_URL, imageConfig.endpoint.route);
|
||||
return `${imageEndpoint}?${searchParams}`;
|
||||
},
|
||||
parseURL(url) {
|
||||
@@ -180,7 +198,9 @@ const baseService = {
|
||||
width: params.has("w") ? parseInt(params.get("w")) : void 0,
|
||||
height: params.has("h") ? parseInt(params.get("h")) : void 0,
|
||||
format: params.get("f"),
|
||||
quality: params.get("q")
|
||||
quality: params.get("q"),
|
||||
fit: params.get("fit"),
|
||||
position: params.get("position") ?? void 0
|
||||
};
|
||||
return transform;
|
||||
}
|
||||
|
43
node_modules/astro/dist/assets/services/sharp.js
generated
vendored
43
node_modules/astro/dist/assets/services/sharp.js
generated
vendored
@@ -20,6 +20,15 @@ async function loadSharp() {
|
||||
sharpImport.cache(false);
|
||||
return sharpImport;
|
||||
}
|
||||
const fitMap = {
|
||||
fill: "fill",
|
||||
contain: "inside",
|
||||
cover: "cover",
|
||||
none: "outside",
|
||||
"scale-down": "inside",
|
||||
outside: "outside",
|
||||
inside: "inside"
|
||||
};
|
||||
const sharpService = {
|
||||
validateOptions: baseService.validateOptions,
|
||||
getURL: baseService.getURL,
|
||||
@@ -36,10 +45,26 @@ const sharpService = {
|
||||
limitInputPixels: config.service.config.limitInputPixels
|
||||
});
|
||||
result.rotate();
|
||||
if (transform.height && !transform.width) {
|
||||
result.resize({ height: Math.round(transform.height) });
|
||||
const withoutEnlargement = Boolean(transform.fit);
|
||||
if (transform.width && transform.height && transform.fit) {
|
||||
const fit = fitMap[transform.fit] ?? "inside";
|
||||
result.resize({
|
||||
width: Math.round(transform.width),
|
||||
height: Math.round(transform.height),
|
||||
fit,
|
||||
position: transform.position,
|
||||
withoutEnlargement
|
||||
});
|
||||
} else if (transform.height && !transform.width) {
|
||||
result.resize({
|
||||
height: Math.round(transform.height),
|
||||
withoutEnlargement
|
||||
});
|
||||
} else if (transform.width) {
|
||||
result.resize({ width: Math.round(transform.width) });
|
||||
result.resize({
|
||||
width: Math.round(transform.width),
|
||||
withoutEnlargement
|
||||
});
|
||||
}
|
||||
if (transform.format) {
|
||||
let quality = void 0;
|
||||
@@ -51,7 +76,17 @@ const sharpService = {
|
||||
quality = transform.quality in qualityTable ? qualityTable[transform.quality] : void 0;
|
||||
}
|
||||
}
|
||||
result.toFormat(transform.format, { quality });
|
||||
const isGifInput = inputBuffer[0] === 71 && // 'G'
|
||||
inputBuffer[1] === 73 && // 'I'
|
||||
inputBuffer[2] === 70 && // 'F'
|
||||
inputBuffer[3] === 56 && // '8'
|
||||
(inputBuffer[4] === 57 || inputBuffer[4] === 55) && // '9' or '7'
|
||||
inputBuffer[5] === 97;
|
||||
if (transform.format === "webp" && isGifInput) {
|
||||
result.webp({ quality: typeof quality === "number" ? quality : void 0, loop: 0 });
|
||||
} else {
|
||||
result.toFormat(transform.format, { quality });
|
||||
}
|
||||
}
|
||||
const { data, info } = await result.toBuffer({ resolveWithObject: true });
|
||||
return {
|
||||
|
3
node_modules/astro/dist/assets/services/squoosh.d.ts
generated
vendored
3
node_modules/astro/dist/assets/services/squoosh.d.ts
generated
vendored
@@ -1,3 +0,0 @@
|
||||
import { type LocalImageService } from './service.js';
|
||||
declare const service: LocalImageService;
|
||||
export default service;
|
90
node_modules/astro/dist/assets/services/squoosh.js
generated
vendored
90
node_modules/astro/dist/assets/services/squoosh.js
generated
vendored
@@ -1,90 +0,0 @@
|
||||
import { yellow } from "kleur/colors";
|
||||
import { imageMetadata } from "../utils/metadata.js";
|
||||
import {
|
||||
baseService,
|
||||
parseQuality
|
||||
} from "./service.js";
|
||||
import { processBuffer } from "./vendor/squoosh/image-pool.js";
|
||||
console.warn(
|
||||
yellow(
|
||||
"The Squoosh image service is deprecated and will be removed in Astro 5.x. We suggest migrating to the default Sharp image service instead, as it is faster, more powerful and better maintained."
|
||||
)
|
||||
);
|
||||
const baseQuality = { low: 25, mid: 50, high: 80, max: 100 };
|
||||
const qualityTable = {
|
||||
avif: {
|
||||
// Squoosh's AVIF encoder has a bit of a weird behavior where `62` is technically the maximum, and anything over is overkill
|
||||
max: 62,
|
||||
high: 45,
|
||||
mid: 35,
|
||||
low: 20
|
||||
},
|
||||
jpeg: baseQuality,
|
||||
jpg: baseQuality,
|
||||
webp: baseQuality
|
||||
// Squoosh's PNG encoder does not support a quality setting, so we can skip that here
|
||||
};
|
||||
async function getRotationForEXIF(inputBuffer, src) {
|
||||
const meta = await imageMetadata(inputBuffer, src);
|
||||
if (!meta) return void 0;
|
||||
switch (meta.orientation) {
|
||||
case 3:
|
||||
case 4:
|
||||
return { type: "rotate", numRotations: 2 };
|
||||
case 5:
|
||||
case 6:
|
||||
return { type: "rotate", numRotations: 1 };
|
||||
case 7:
|
||||
case 8:
|
||||
return { type: "rotate", numRotations: 3 };
|
||||
case void 0:
|
||||
default:
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
const service = {
|
||||
validateOptions: baseService.validateOptions,
|
||||
getURL: baseService.getURL,
|
||||
parseURL: baseService.parseURL,
|
||||
getHTMLAttributes: baseService.getHTMLAttributes,
|
||||
getSrcSet: baseService.getSrcSet,
|
||||
async transform(inputBuffer, transformOptions) {
|
||||
const transform = transformOptions;
|
||||
let format = transform.format;
|
||||
if (format === "svg") return { data: inputBuffer, format: "svg" };
|
||||
const operations = [];
|
||||
const rotation = await getRotationForEXIF(inputBuffer, transform.src);
|
||||
if (rotation) {
|
||||
operations.push(rotation);
|
||||
}
|
||||
if (transform.height && !transform.width) {
|
||||
operations.push({
|
||||
type: "resize",
|
||||
height: Math.round(transform.height)
|
||||
});
|
||||
} else if (transform.width) {
|
||||
operations.push({
|
||||
type: "resize",
|
||||
width: Math.round(transform.width)
|
||||
});
|
||||
}
|
||||
let quality = void 0;
|
||||
if (transform.quality) {
|
||||
const parsedQuality = parseQuality(transform.quality);
|
||||
if (typeof parsedQuality === "number") {
|
||||
quality = parsedQuality;
|
||||
} else {
|
||||
quality = transform.quality in qualityTable[format] ? qualityTable[format][transform.quality] : void 0;
|
||||
}
|
||||
}
|
||||
const data = await processBuffer(inputBuffer, operations, format, quality);
|
||||
return {
|
||||
data: Buffer.from(data),
|
||||
format
|
||||
};
|
||||
}
|
||||
};
|
||||
var squoosh_default = service;
|
||||
export {
|
||||
squoosh_default as default
|
||||
};
|
11
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_enc.d.js
generated
vendored
11
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_enc.d.js
generated
vendored
@@ -1,11 +0,0 @@
|
||||
var AVIFTune = /* @__PURE__ */ ((AVIFTune2) => {
|
||||
AVIFTune2[AVIFTune2["auto"] = 0] = "auto";
|
||||
AVIFTune2[AVIFTune2["psnr"] = 1] = "psnr";
|
||||
AVIFTune2[AVIFTune2["ssim"] = 2] = "ssim";
|
||||
return AVIFTune2;
|
||||
})(AVIFTune || {});
|
||||
var avif_enc_d_default = moduleFactory;
|
||||
export {
|
||||
AVIFTune,
|
||||
avif_enc_d_default as default
|
||||
};
|
2
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare var Module: (Module: any) => any;
|
||||
export default Module;
|
1594
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js
generated
vendored
1594
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js
generated
vendored
File diff suppressed because it is too large
Load Diff
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm
generated
vendored
Binary file not shown.
2
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
4
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm.js
generated
vendored
4
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm.js
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare var Module: (Module: any) => any;
|
||||
export default Module;
|
1811
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js
generated
vendored
1811
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js
generated
vendored
File diff suppressed because it is too large
Load Diff
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm
generated
vendored
Binary file not shown.
2
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
4
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm.js
generated
vendored
4
node_modules/astro/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm.js
generated
vendored
File diff suppressed because one or more lines are too long
157
node_modules/astro/dist/assets/services/vendor/squoosh/codecs.d.ts
generated
vendored
157
node_modules/astro/dist/assets/services/vendor/squoosh/codecs.d.ts
generated
vendored
@@ -1,157 +0,0 @@
|
||||
interface DecodeModule extends EmscriptenWasm.Module {
|
||||
decode: (data: Uint8Array) => ImageData;
|
||||
}
|
||||
export interface ResizeOptions {
|
||||
width?: number;
|
||||
height?: number;
|
||||
method: 'triangle' | 'catrom' | 'mitchell' | 'lanczos3';
|
||||
premultiply: boolean;
|
||||
linearRGB: boolean;
|
||||
}
|
||||
export interface RotateOptions {
|
||||
numRotations: number;
|
||||
}
|
||||
import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc.js';
|
||||
import type { WebPModule as WebPEncodeModule } from './webp/webp_enc.js';
|
||||
import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc.js';
|
||||
import ImageData from './image_data.js';
|
||||
export declare const preprocessors: {
|
||||
readonly resize: {
|
||||
readonly name: "Resize";
|
||||
readonly description: "Resize the image before compressing";
|
||||
readonly instantiate: () => Promise<(buffer: Uint8Array, input_width: number, input_height: number, { width, height, method, premultiply, linearRGB }: ResizeOptions) => ImageData>;
|
||||
readonly defaultOptions: {
|
||||
readonly method: "lanczos3";
|
||||
readonly fitMethod: "stretch";
|
||||
readonly premultiply: true;
|
||||
readonly linearRGB: true;
|
||||
};
|
||||
};
|
||||
readonly rotate: {
|
||||
readonly name: "Rotate";
|
||||
readonly description: "Rotate image";
|
||||
readonly instantiate: () => Promise<(buffer: Uint8Array, width: number, height: number, { numRotations }: RotateOptions) => Promise<ImageData>>;
|
||||
readonly defaultOptions: {
|
||||
readonly numRotations: 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
export declare const codecs: {
|
||||
readonly mozjpeg: {
|
||||
readonly name: "MozJPEG";
|
||||
readonly extension: "jpg";
|
||||
readonly detectors: readonly [RegExp];
|
||||
readonly dec: () => Promise<DecodeModule>;
|
||||
readonly enc: () => Promise<MozJPEGEncodeModule>;
|
||||
readonly defaultEncoderOptions: {
|
||||
readonly quality: 75;
|
||||
readonly baseline: false;
|
||||
readonly arithmetic: false;
|
||||
readonly progressive: true;
|
||||
readonly optimize_coding: true;
|
||||
readonly smoothing: 0;
|
||||
readonly color_space: 3;
|
||||
readonly quant_table: 3;
|
||||
readonly trellis_multipass: false;
|
||||
readonly trellis_opt_zero: false;
|
||||
readonly trellis_opt_table: false;
|
||||
readonly trellis_loops: 1;
|
||||
readonly auto_subsample: true;
|
||||
readonly chroma_subsample: 2;
|
||||
readonly separate_chroma_quality: false;
|
||||
readonly chroma_quality: 75;
|
||||
};
|
||||
readonly autoOptimize: {
|
||||
readonly option: "quality";
|
||||
readonly min: 0;
|
||||
readonly max: 100;
|
||||
};
|
||||
};
|
||||
readonly webp: {
|
||||
readonly name: "WebP";
|
||||
readonly extension: "webp";
|
||||
readonly detectors: readonly [RegExp];
|
||||
readonly dec: () => Promise<DecodeModule>;
|
||||
readonly enc: () => Promise<WebPEncodeModule>;
|
||||
readonly defaultEncoderOptions: {
|
||||
readonly quality: 75;
|
||||
readonly target_size: 0;
|
||||
readonly target_PSNR: 0;
|
||||
readonly method: 4;
|
||||
readonly sns_strength: 50;
|
||||
readonly filter_strength: 60;
|
||||
readonly filter_sharpness: 0;
|
||||
readonly filter_type: 1;
|
||||
readonly partitions: 0;
|
||||
readonly segments: 4;
|
||||
readonly pass: 1;
|
||||
readonly show_compressed: 0;
|
||||
readonly preprocessing: 0;
|
||||
readonly autofilter: 0;
|
||||
readonly partition_limit: 0;
|
||||
readonly alpha_compression: 1;
|
||||
readonly alpha_filtering: 1;
|
||||
readonly alpha_quality: 100;
|
||||
readonly lossless: 0;
|
||||
readonly exact: 0;
|
||||
readonly image_hint: 0;
|
||||
readonly emulate_jpeg_size: 0;
|
||||
readonly thread_level: 0;
|
||||
readonly low_memory: 0;
|
||||
readonly near_lossless: 100;
|
||||
readonly use_delta_palette: 0;
|
||||
readonly use_sharp_yuv: 0;
|
||||
};
|
||||
readonly autoOptimize: {
|
||||
readonly option: "quality";
|
||||
readonly min: 0;
|
||||
readonly max: 100;
|
||||
};
|
||||
};
|
||||
readonly avif: {
|
||||
readonly name: "AVIF";
|
||||
readonly extension: "avif";
|
||||
readonly detectors: readonly [RegExp];
|
||||
readonly dec: () => Promise<DecodeModule>;
|
||||
readonly enc: () => Promise<AVIFEncodeModule>;
|
||||
readonly defaultEncoderOptions: {
|
||||
readonly cqLevel: 33;
|
||||
readonly cqAlphaLevel: -1;
|
||||
readonly denoiseLevel: 0;
|
||||
readonly tileColsLog2: 0;
|
||||
readonly tileRowsLog2: 0;
|
||||
readonly speed: 6;
|
||||
readonly subsample: 1;
|
||||
readonly chromaDeltaQ: false;
|
||||
readonly sharpness: 0;
|
||||
readonly tune: 0;
|
||||
};
|
||||
readonly autoOptimize: {
|
||||
readonly option: "cqLevel";
|
||||
readonly min: 62;
|
||||
readonly max: 0;
|
||||
};
|
||||
};
|
||||
readonly oxipng: {
|
||||
readonly name: "OxiPNG";
|
||||
readonly extension: "png";
|
||||
readonly detectors: readonly [RegExp];
|
||||
readonly dec: () => Promise<{
|
||||
decode: (buffer: Buffer | Uint8Array) => any;
|
||||
}>;
|
||||
readonly enc: () => Promise<{
|
||||
encode: (buffer: Uint8ClampedArray | ArrayBuffer, width: number, height: number, opts: {
|
||||
level: number;
|
||||
}) => any;
|
||||
}>;
|
||||
readonly defaultEncoderOptions: {
|
||||
readonly level: 2;
|
||||
};
|
||||
readonly autoOptimize: {
|
||||
readonly option: "level";
|
||||
readonly min: 6;
|
||||
readonly max: 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
export {};
|
287
node_modules/astro/dist/assets/services/vendor/squoosh/codecs.js
generated
vendored
287
node_modules/astro/dist/assets/services/vendor/squoosh/codecs.js
generated
vendored
@@ -1,287 +0,0 @@
|
||||
import { instantiateEmscriptenWasm } from "./emscripten-utils.js";
|
||||
import mozDec from "./mozjpeg/mozjpeg_node_dec.js";
|
||||
import mozDecWasm from "./mozjpeg/mozjpeg_node_dec.wasm.js";
|
||||
import mozEnc from "./mozjpeg/mozjpeg_node_enc.js";
|
||||
import mozEncWasm from "./mozjpeg/mozjpeg_node_enc.wasm.js";
|
||||
import webpDec from "./webp/webp_node_dec.js";
|
||||
import webpDecWasm from "./webp/webp_node_dec.wasm.js";
|
||||
import webpEnc from "./webp/webp_node_enc.js";
|
||||
import webpEncWasm from "./webp/webp_node_enc.wasm.js";
|
||||
import avifDec from "./avif/avif_node_dec.js";
|
||||
import avifDecWasm from "./avif/avif_node_dec.wasm.js";
|
||||
import avifEnc from "./avif/avif_node_enc.js";
|
||||
import avifEncWasm from "./avif/avif_node_enc.wasm.js";
|
||||
import * as pngEncDec from "./png/squoosh_png.js";
|
||||
import pngEncDecWasm from "./png/squoosh_png_bg.wasm.js";
|
||||
const pngEncDecInit = () => pngEncDec.default(pngEncDecWasm);
|
||||
import * as oxipng from "./png/squoosh_oxipng.js";
|
||||
import oxipngWasm from "./png/squoosh_oxipng_bg.wasm.js";
|
||||
const oxipngInit = () => oxipng.default(oxipngWasm);
|
||||
import * as resize from "./resize/squoosh_resize.js";
|
||||
import resizeWasm from "./resize/squoosh_resize_bg.wasm.js";
|
||||
const resizeInit = () => resize.default(resizeWasm);
|
||||
import rotateWasm from "./rotate/rotate.wasm.js";
|
||||
import ImageData from "./image_data.js";
|
||||
global.ImageData = ImageData;
|
||||
function resizeNameToIndex(name) {
|
||||
switch (name) {
|
||||
case "triangle":
|
||||
return 0;
|
||||
case "catrom":
|
||||
return 1;
|
||||
case "mitchell":
|
||||
return 2;
|
||||
case "lanczos3":
|
||||
return 3;
|
||||
default:
|
||||
throw Error(`Unknown resize algorithm "${name}"`);
|
||||
}
|
||||
}
|
||||
function resizeWithAspect({
|
||||
input_width,
|
||||
input_height,
|
||||
target_width,
|
||||
target_height
|
||||
}) {
|
||||
if (!target_width && !target_height) {
|
||||
throw Error("Need to specify at least width or height when resizing");
|
||||
}
|
||||
if (target_width && target_height) {
|
||||
return { width: target_width, height: target_height };
|
||||
}
|
||||
if (!target_width) {
|
||||
return {
|
||||
width: Math.round(input_width / input_height * target_height),
|
||||
height: target_height
|
||||
};
|
||||
}
|
||||
return {
|
||||
width: target_width,
|
||||
height: Math.round(input_height / input_width * target_width)
|
||||
};
|
||||
}
|
||||
const preprocessors = {
|
||||
resize: {
|
||||
name: "Resize",
|
||||
description: "Resize the image before compressing",
|
||||
instantiate: async () => {
|
||||
await resizeInit();
|
||||
return (buffer, input_width, input_height, { width, height, method, premultiply, linearRGB }) => {
|
||||
;
|
||||
({ width, height } = resizeWithAspect({
|
||||
input_width,
|
||||
input_height,
|
||||
target_width: width,
|
||||
target_height: height
|
||||
}));
|
||||
const imageData = new ImageData(
|
||||
resize.resize(
|
||||
buffer,
|
||||
input_width,
|
||||
input_height,
|
||||
width,
|
||||
height,
|
||||
resizeNameToIndex(method),
|
||||
premultiply,
|
||||
linearRGB
|
||||
),
|
||||
width,
|
||||
height
|
||||
);
|
||||
resize.cleanup();
|
||||
return imageData;
|
||||
};
|
||||
},
|
||||
defaultOptions: {
|
||||
method: "lanczos3",
|
||||
fitMethod: "stretch",
|
||||
premultiply: true,
|
||||
linearRGB: true
|
||||
}
|
||||
},
|
||||
rotate: {
|
||||
name: "Rotate",
|
||||
description: "Rotate image",
|
||||
instantiate: async () => {
|
||||
return async (buffer, width, height, { numRotations }) => {
|
||||
const degrees = numRotations * 90 % 360;
|
||||
const sameDimensions = degrees === 0 || degrees === 180;
|
||||
const size = width * height * 4;
|
||||
const instance = (await WebAssembly.instantiate(rotateWasm)).instance;
|
||||
const { memory } = instance.exports;
|
||||
const additionalPagesNeeded = Math.ceil(
|
||||
(size * 2 - memory.buffer.byteLength + 8) / (64 * 1024)
|
||||
);
|
||||
if (additionalPagesNeeded > 0) {
|
||||
memory.grow(additionalPagesNeeded);
|
||||
}
|
||||
const view = new Uint8ClampedArray(memory.buffer);
|
||||
view.set(buffer, 8);
|
||||
instance.exports.rotate(width, height, degrees);
|
||||
return new ImageData(
|
||||
view.slice(size + 8, size * 2 + 8),
|
||||
sameDimensions ? width : height,
|
||||
sameDimensions ? height : width
|
||||
);
|
||||
};
|
||||
},
|
||||
defaultOptions: {
|
||||
numRotations: 0
|
||||
}
|
||||
}
|
||||
};
|
||||
const codecs = {
|
||||
mozjpeg: {
|
||||
name: "MozJPEG",
|
||||
extension: "jpg",
|
||||
detectors: [/^\xFF\xD8\xFF/],
|
||||
dec: () => instantiateEmscriptenWasm(mozDec, mozDecWasm),
|
||||
enc: () => instantiateEmscriptenWasm(
|
||||
mozEnc,
|
||||
mozEncWasm
|
||||
),
|
||||
defaultEncoderOptions: {
|
||||
quality: 75,
|
||||
baseline: false,
|
||||
arithmetic: false,
|
||||
progressive: true,
|
||||
optimize_coding: true,
|
||||
smoothing: 0,
|
||||
color_space: 3,
|
||||
quant_table: 3,
|
||||
trellis_multipass: false,
|
||||
trellis_opt_zero: false,
|
||||
trellis_opt_table: false,
|
||||
trellis_loops: 1,
|
||||
auto_subsample: true,
|
||||
chroma_subsample: 2,
|
||||
separate_chroma_quality: false,
|
||||
chroma_quality: 75
|
||||
},
|
||||
autoOptimize: {
|
||||
option: "quality",
|
||||
min: 0,
|
||||
max: 100
|
||||
}
|
||||
},
|
||||
webp: {
|
||||
name: "WebP",
|
||||
extension: "webp",
|
||||
detectors: [/^RIFF....WEBPVP8[LX ]/s],
|
||||
dec: () => instantiateEmscriptenWasm(webpDec, webpDecWasm),
|
||||
enc: () => instantiateEmscriptenWasm(
|
||||
webpEnc,
|
||||
webpEncWasm
|
||||
),
|
||||
defaultEncoderOptions: {
|
||||
quality: 75,
|
||||
target_size: 0,
|
||||
target_PSNR: 0,
|
||||
method: 4,
|
||||
sns_strength: 50,
|
||||
filter_strength: 60,
|
||||
filter_sharpness: 0,
|
||||
filter_type: 1,
|
||||
partitions: 0,
|
||||
segments: 4,
|
||||
pass: 1,
|
||||
show_compressed: 0,
|
||||
preprocessing: 0,
|
||||
autofilter: 0,
|
||||
partition_limit: 0,
|
||||
alpha_compression: 1,
|
||||
alpha_filtering: 1,
|
||||
alpha_quality: 100,
|
||||
lossless: 0,
|
||||
exact: 0,
|
||||
image_hint: 0,
|
||||
emulate_jpeg_size: 0,
|
||||
thread_level: 0,
|
||||
low_memory: 0,
|
||||
near_lossless: 100,
|
||||
use_delta_palette: 0,
|
||||
use_sharp_yuv: 0
|
||||
},
|
||||
autoOptimize: {
|
||||
option: "quality",
|
||||
min: 0,
|
||||
max: 100
|
||||
}
|
||||
},
|
||||
avif: {
|
||||
name: "AVIF",
|
||||
extension: "avif",
|
||||
// Disable eslint rule to not touch the original code
|
||||
// eslint-disable-next-line no-control-regex, regexp/control-character-escape
|
||||
detectors: [/^\x00\x00\x00 ftypavif\x00\x00\x00\x00/],
|
||||
dec: () => instantiateEmscriptenWasm(avifDec, avifDecWasm),
|
||||
enc: async () => {
|
||||
return instantiateEmscriptenWasm(
|
||||
avifEnc,
|
||||
avifEncWasm
|
||||
);
|
||||
},
|
||||
defaultEncoderOptions: {
|
||||
cqLevel: 33,
|
||||
cqAlphaLevel: -1,
|
||||
denoiseLevel: 0,
|
||||
tileColsLog2: 0,
|
||||
tileRowsLog2: 0,
|
||||
speed: 6,
|
||||
subsample: 1,
|
||||
chromaDeltaQ: false,
|
||||
sharpness: 0,
|
||||
tune: 0
|
||||
},
|
||||
autoOptimize: {
|
||||
option: "cqLevel",
|
||||
min: 62,
|
||||
max: 0
|
||||
}
|
||||
},
|
||||
oxipng: {
|
||||
name: "OxiPNG",
|
||||
extension: "png",
|
||||
// Disable eslint rule to not touch the original code
|
||||
// eslint-disable-next-line no-control-regex, regexp/control-character-escape
|
||||
detectors: [/^\x89PNG\x0D\x0A\x1A\x0A/],
|
||||
dec: async () => {
|
||||
await pngEncDecInit();
|
||||
return {
|
||||
decode: (buffer) => {
|
||||
const imageData = pngEncDec.decode(buffer);
|
||||
pngEncDec.cleanup();
|
||||
return imageData;
|
||||
}
|
||||
};
|
||||
},
|
||||
enc: async () => {
|
||||
await pngEncDecInit();
|
||||
await oxipngInit();
|
||||
return {
|
||||
encode: (buffer, width, height, opts) => {
|
||||
const simplePng = pngEncDec.encode(
|
||||
new Uint8Array(buffer),
|
||||
width,
|
||||
height
|
||||
);
|
||||
const imageData = oxipng.optimise(simplePng, opts.level, false);
|
||||
oxipng.cleanup();
|
||||
return imageData;
|
||||
}
|
||||
};
|
||||
},
|
||||
defaultEncoderOptions: {
|
||||
level: 2
|
||||
},
|
||||
autoOptimize: {
|
||||
option: "level",
|
||||
min: 6,
|
||||
max: 1
|
||||
}
|
||||
}
|
||||
};
|
||||
export {
|
||||
codecs,
|
||||
preprocessors
|
||||
};
|
0
node_modules/astro/dist/assets/services/vendor/squoosh/emscripten-types.d.js
generated
vendored
0
node_modules/astro/dist/assets/services/vendor/squoosh/emscripten-types.d.js
generated
vendored
9
node_modules/astro/dist/assets/services/vendor/squoosh/emscripten-utils.d.ts
generated
vendored
9
node_modules/astro/dist/assets/services/vendor/squoosh/emscripten-utils.d.ts
generated
vendored
@@ -1,9 +0,0 @@
|
||||
export declare function pathify(path: string): string;
|
||||
export declare function instantiateEmscriptenWasm<T extends EmscriptenWasm.Module>(factory: EmscriptenWasm.ModuleFactory<T>, bytes: Uint8Array): Promise<T>;
|
||||
export declare function dirname(url: string): string;
|
||||
/**
|
||||
* On certain serverless hosts, our ESM bundle is transpiled to CJS before being run, which means
|
||||
* import.meta.url is undefined, so we'll fall back to __filename in those cases
|
||||
* We should be able to remove this once https://github.com/netlify/zip-it-and-ship-it/issues/750 is fixed
|
||||
*/
|
||||
export declare function getModuleURL(url: string | undefined): string;
|
31
node_modules/astro/dist/assets/services/vendor/squoosh/emscripten-utils.js
generated
vendored
31
node_modules/astro/dist/assets/services/vendor/squoosh/emscripten-utils.js
generated
vendored
@@ -1,31 +0,0 @@
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
function pathify(path) {
|
||||
if (path.startsWith("file://")) {
|
||||
path = fileURLToPath(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
function instantiateEmscriptenWasm(factory, bytes) {
|
||||
return factory({
|
||||
// @ts-expect-error This is a valid Emscripten option, but the type definitions don't know about it
|
||||
wasmBinary: bytes,
|
||||
locateFile(file) {
|
||||
return file;
|
||||
}
|
||||
});
|
||||
}
|
||||
function dirname(url) {
|
||||
return url.substring(0, url.lastIndexOf("/"));
|
||||
}
|
||||
function getModuleURL(url) {
|
||||
if (!url) {
|
||||
return pathToFileURL(__filename).toString();
|
||||
}
|
||||
return url;
|
||||
}
|
||||
export {
|
||||
dirname,
|
||||
getModuleURL,
|
||||
instantiateEmscriptenWasm,
|
||||
pathify
|
||||
};
|
3
node_modules/astro/dist/assets/services/vendor/squoosh/image-pool.d.ts
generated
vendored
3
node_modules/astro/dist/assets/services/vendor/squoosh/image-pool.d.ts
generated
vendored
@@ -1,3 +0,0 @@
|
||||
import type { ImageOutputFormat } from '../../../types.js';
|
||||
import type { Operation } from './image.js';
|
||||
export declare function processBuffer(buffer: Uint8Array, operations: Operation[], encoding: ImageOutputFormat, quality?: number): Promise<Uint8Array>;
|
97
node_modules/astro/dist/assets/services/vendor/squoosh/image-pool.js
generated
vendored
97
node_modules/astro/dist/assets/services/vendor/squoosh/image-pool.js
generated
vendored
@@ -1,97 +0,0 @@
|
||||
import { cpus } from "node:os";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { isMainThread } from "node:worker_threads";
|
||||
import { getModuleURL } from "./emscripten-utils.js";
|
||||
import * as impl from "./impl.js";
|
||||
import execOnce from "./utils/execOnce.js";
|
||||
import WorkerPool from "./utils/workerPool.js";
|
||||
const getWorker = execOnce(() => {
|
||||
return new WorkerPool(
|
||||
// There will be at most 7 workers needed since each worker will take
|
||||
// at least 1 operation type.
|
||||
Math.max(1, Math.min(cpus().length - 1, 7)),
|
||||
fileURLToPath(getModuleURL(import.meta.url))
|
||||
);
|
||||
});
|
||||
function handleJob(params) {
|
||||
switch (params.operation) {
|
||||
case "decode":
|
||||
return impl.decodeBuffer(params.buffer);
|
||||
case "resize":
|
||||
return impl.resize({
|
||||
image: params.imageData,
|
||||
width: params.width,
|
||||
height: params.height
|
||||
});
|
||||
case "rotate":
|
||||
return impl.rotate(params.imageData, params.numRotations);
|
||||
case "encodeavif":
|
||||
return impl.encodeAvif(params.imageData, { quality: params.quality });
|
||||
case "encodejpeg":
|
||||
return impl.encodeJpeg(params.imageData, { quality: params.quality });
|
||||
case "encodepng":
|
||||
return impl.encodePng(params.imageData);
|
||||
case "encodewebp":
|
||||
return impl.encodeWebp(params.imageData, { quality: params.quality });
|
||||
default:
|
||||
throw Error(`Invalid job "${params.operation}"`);
|
||||
}
|
||||
}
|
||||
async function processBuffer(buffer, operations, encoding, quality) {
|
||||
const worker = await getWorker();
|
||||
let imageData = await worker.dispatchJob({
|
||||
operation: "decode",
|
||||
buffer
|
||||
});
|
||||
for (const operation of operations) {
|
||||
if (operation.type === "rotate") {
|
||||
imageData = await worker.dispatchJob({
|
||||
operation: "rotate",
|
||||
imageData,
|
||||
numRotations: operation.numRotations
|
||||
});
|
||||
} else if (operation.type === "resize") {
|
||||
imageData = await worker.dispatchJob({
|
||||
operation: "resize",
|
||||
imageData,
|
||||
height: operation.height,
|
||||
width: operation.width
|
||||
});
|
||||
}
|
||||
}
|
||||
switch (encoding) {
|
||||
case "avif":
|
||||
return await worker.dispatchJob({
|
||||
operation: "encodeavif",
|
||||
imageData,
|
||||
quality
|
||||
});
|
||||
case "jpeg":
|
||||
case "jpg":
|
||||
return await worker.dispatchJob({
|
||||
operation: "encodejpeg",
|
||||
imageData,
|
||||
quality
|
||||
});
|
||||
case "png":
|
||||
return await worker.dispatchJob({
|
||||
operation: "encodepng",
|
||||
imageData
|
||||
});
|
||||
case "webp":
|
||||
return await worker.dispatchJob({
|
||||
operation: "encodewebp",
|
||||
imageData,
|
||||
quality
|
||||
});
|
||||
case "svg":
|
||||
default:
|
||||
throw Error(`Unsupported encoding format`);
|
||||
}
|
||||
}
|
||||
if (!isMainThread) {
|
||||
WorkerPool.useThisThreadAsWorker(handleJob);
|
||||
}
|
||||
export {
|
||||
processBuffer
|
||||
};
|
13
node_modules/astro/dist/assets/services/vendor/squoosh/image.d.ts
generated
vendored
13
node_modules/astro/dist/assets/services/vendor/squoosh/image.d.ts
generated
vendored
@@ -1,13 +0,0 @@
|
||||
import type { ImageOutputFormat } from '../../../types.js';
|
||||
type RotateOperation = {
|
||||
type: 'rotate';
|
||||
numRotations: number;
|
||||
};
|
||||
type ResizeOperation = {
|
||||
type: 'resize';
|
||||
width?: number;
|
||||
height?: number;
|
||||
};
|
||||
export type Operation = RotateOperation | ResizeOperation;
|
||||
export declare function processBuffer(buffer: Buffer, operations: Operation[], encoding: ImageOutputFormat, quality?: number): Promise<Uint8Array>;
|
||||
export {};
|
28
node_modules/astro/dist/assets/services/vendor/squoosh/image.js
generated
vendored
28
node_modules/astro/dist/assets/services/vendor/squoosh/image.js
generated
vendored
@@ -1,28 +0,0 @@
|
||||
import * as impl from "./impl.js";
|
||||
async function processBuffer(buffer, operations, encoding, quality) {
|
||||
let imageData = await impl.decodeBuffer(buffer);
|
||||
for (const operation of operations) {
|
||||
if (operation.type === "rotate") {
|
||||
imageData = await impl.rotate(imageData, operation.numRotations);
|
||||
} else if (operation.type === "resize") {
|
||||
imageData = await impl.resize({ image: imageData, width: operation.width, height: operation.height });
|
||||
}
|
||||
}
|
||||
switch (encoding) {
|
||||
case "avif":
|
||||
return await impl.encodeAvif(imageData, { quality });
|
||||
case "jpeg":
|
||||
case "jpg":
|
||||
return await impl.encodeJpeg(imageData, { quality });
|
||||
case "png":
|
||||
return await impl.encodePng(imageData);
|
||||
case "webp":
|
||||
return await impl.encodeWebp(imageData, { quality });
|
||||
case "svg":
|
||||
default:
|
||||
throw Error(`Unsupported encoding format`);
|
||||
}
|
||||
}
|
||||
export {
|
||||
processBuffer
|
||||
};
|
8
node_modules/astro/dist/assets/services/vendor/squoosh/image_data.d.ts
generated
vendored
8
node_modules/astro/dist/assets/services/vendor/squoosh/image_data.d.ts
generated
vendored
@@ -1,8 +0,0 @@
|
||||
export default class ImageData {
|
||||
static from(input: ImageData): ImageData;
|
||||
private _data;
|
||||
width: number;
|
||||
height: number;
|
||||
get data(): Buffer;
|
||||
constructor(data: Buffer | Uint8Array | Uint8ClampedArray, width: number, height: number);
|
||||
}
|
25
node_modules/astro/dist/assets/services/vendor/squoosh/image_data.js
generated
vendored
25
node_modules/astro/dist/assets/services/vendor/squoosh/image_data.js
generated
vendored
@@ -1,25 +0,0 @@
|
||||
class ImageData {
|
||||
static from(input) {
|
||||
return new ImageData(input.data || input._data, input.width, input.height);
|
||||
}
|
||||
_data;
|
||||
width;
|
||||
height;
|
||||
get data() {
|
||||
if (Object.prototype.toString.call(this._data) === "[object Object]") {
|
||||
return Buffer.from(Object.values(this._data));
|
||||
}
|
||||
if (this._data instanceof Buffer || this._data instanceof Uint8Array || this._data instanceof Uint8ClampedArray) {
|
||||
return Buffer.from(this._data);
|
||||
}
|
||||
throw new Error("invariant");
|
||||
}
|
||||
constructor(data, width, height) {
|
||||
this._data = data;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
}
|
||||
export {
|
||||
ImageData as default
|
||||
};
|
21
node_modules/astro/dist/assets/services/vendor/squoosh/impl.d.ts
generated
vendored
21
node_modules/astro/dist/assets/services/vendor/squoosh/impl.d.ts
generated
vendored
@@ -1,21 +0,0 @@
|
||||
import ImageData from './image_data.js';
|
||||
export declare function decodeBuffer(_buffer: Buffer | Uint8Array): Promise<ImageData>;
|
||||
export declare function rotate(image: ImageData, numRotations: number): Promise<ImageData>;
|
||||
type ResizeOpts = {
|
||||
image: ImageData;
|
||||
} & {
|
||||
width?: number;
|
||||
height?: number;
|
||||
};
|
||||
export declare function resize({ image, width, height }: ResizeOpts): Promise<ImageData>;
|
||||
export declare function encodeJpeg(image: ImageData, opts: {
|
||||
quality?: number;
|
||||
}): Promise<Uint8Array>;
|
||||
export declare function encodeWebp(image: ImageData, opts: {
|
||||
quality?: number;
|
||||
}): Promise<Uint8Array>;
|
||||
export declare function encodeAvif(image: ImageData, opts: {
|
||||
quality?: number;
|
||||
}): Promise<Uint8Array>;
|
||||
export declare function encodePng(image: ImageData): Promise<Uint8Array>;
|
||||
export {};
|
111
node_modules/astro/dist/assets/services/vendor/squoosh/impl.js
generated
vendored
111
node_modules/astro/dist/assets/services/vendor/squoosh/impl.js
generated
vendored
@@ -1,111 +0,0 @@
|
||||
import { preprocessors, codecs as supportedFormats } from "./codecs.js";
|
||||
import ImageData from "./image_data.js";
|
||||
const DELAY_MS = 1e3;
|
||||
let _promise;
|
||||
function delayOnce(ms) {
|
||||
if (!_promise) {
|
||||
_promise = new Promise((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
});
|
||||
}
|
||||
return _promise;
|
||||
}
|
||||
function maybeDelay() {
|
||||
const isAppleM1 = process.arch === "arm64" && process.platform === "darwin";
|
||||
if (isAppleM1) {
|
||||
return delayOnce(DELAY_MS);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
async function decodeBuffer(_buffer) {
|
||||
const buffer = Buffer.from(_buffer);
|
||||
const firstChunk = buffer.slice(0, 16);
|
||||
const firstChunkString = Array.from(firstChunk).map((v) => String.fromCodePoint(v)).join("");
|
||||
if (firstChunkString.includes("GIF")) {
|
||||
throw Error(`GIF images are not supported, please use the Sharp image service`);
|
||||
}
|
||||
const key = Object.entries(supportedFormats).find(
|
||||
([, { detectors }]) => detectors.some((detector) => detector.exec(firstChunkString))
|
||||
)?.[0];
|
||||
if (!key) {
|
||||
throw Error(`Buffer has an unsupported format`);
|
||||
}
|
||||
const encoder = supportedFormats[key];
|
||||
const mod = await encoder.dec();
|
||||
const rgba = mod.decode(new Uint8Array(buffer));
|
||||
return rgba;
|
||||
}
|
||||
async function rotate(image, numRotations) {
|
||||
image = ImageData.from(image);
|
||||
const m = await preprocessors["rotate"].instantiate();
|
||||
return await m(image.data, image.width, image.height, { numRotations });
|
||||
}
|
||||
async function resize({ image, width, height }) {
|
||||
image = ImageData.from(image);
|
||||
const p = preprocessors["resize"];
|
||||
const m = await p.instantiate();
|
||||
await maybeDelay();
|
||||
return await m(image.data, image.width, image.height, {
|
||||
...p.defaultOptions,
|
||||
width,
|
||||
height
|
||||
});
|
||||
}
|
||||
async function encodeJpeg(image, opts) {
|
||||
image = ImageData.from(image);
|
||||
const e = supportedFormats["mozjpeg"];
|
||||
const m = await e.enc();
|
||||
await maybeDelay();
|
||||
const quality = opts.quality || e.defaultEncoderOptions.quality;
|
||||
const r = await m.encode(image.data, image.width, image.height, {
|
||||
...e.defaultEncoderOptions,
|
||||
quality
|
||||
});
|
||||
return r;
|
||||
}
|
||||
async function encodeWebp(image, opts) {
|
||||
image = ImageData.from(image);
|
||||
const e = supportedFormats["webp"];
|
||||
const m = await e.enc();
|
||||
await maybeDelay();
|
||||
const quality = opts.quality || e.defaultEncoderOptions.quality;
|
||||
const r = await m.encode(image.data, image.width, image.height, {
|
||||
...e.defaultEncoderOptions,
|
||||
quality
|
||||
});
|
||||
return r;
|
||||
}
|
||||
async function encodeAvif(image, opts) {
|
||||
image = ImageData.from(image);
|
||||
const e = supportedFormats["avif"];
|
||||
const m = await e.enc();
|
||||
await maybeDelay();
|
||||
const val = e.autoOptimize.min;
|
||||
const quality = opts.quality || 75;
|
||||
const r = await m.encode(image.data, image.width, image.height, {
|
||||
...e.defaultEncoderOptions,
|
||||
// Think of cqLevel as the "amount" of quantization (0 to 62),
|
||||
// so a lower value yields higher quality (0 to 100).
|
||||
cqLevel: quality === 0 ? val : Math.round(val - quality / 100 * val)
|
||||
});
|
||||
return r;
|
||||
}
|
||||
async function encodePng(image) {
|
||||
image = ImageData.from(image);
|
||||
const e = supportedFormats["oxipng"];
|
||||
const m = await e.enc();
|
||||
await maybeDelay();
|
||||
const r = await m.encode(image.data, image.width, image.height, {
|
||||
...e.defaultEncoderOptions
|
||||
});
|
||||
return r;
|
||||
}
|
||||
export {
|
||||
decodeBuffer,
|
||||
encodeAvif,
|
||||
encodeJpeg,
|
||||
encodePng,
|
||||
encodeWebp,
|
||||
resize,
|
||||
rotate
|
||||
};
|
11
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_enc.d.js
generated
vendored
11
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_enc.d.js
generated
vendored
@@ -1,11 +0,0 @@
|
||||
var MozJpegColorSpace = /* @__PURE__ */ ((MozJpegColorSpace2) => {
|
||||
MozJpegColorSpace2[MozJpegColorSpace2["GRAYSCALE"] = 1] = "GRAYSCALE";
|
||||
MozJpegColorSpace2[MozJpegColorSpace2["RGB"] = 2] = "RGB";
|
||||
MozJpegColorSpace2[MozJpegColorSpace2["YCbCr"] = 3] = "YCbCr";
|
||||
return MozJpegColorSpace2;
|
||||
})(MozJpegColorSpace || {});
|
||||
var mozjpeg_enc_d_default = moduleFactory;
|
||||
export {
|
||||
MozJpegColorSpace,
|
||||
mozjpeg_enc_d_default as default
|
||||
};
|
2
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare var Module: (Module: any) => any;
|
||||
export default Module;
|
1599
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js
generated
vendored
1599
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js
generated
vendored
File diff suppressed because it is too large
Load Diff
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.wasm
generated
vendored
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
File diff suppressed because one or more lines are too long
2
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare var Module: (Module: any) => any;
|
||||
export default Module;
|
1705
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js
generated
vendored
1705
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js
generated
vendored
File diff suppressed because it is too large
Load Diff
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.wasm
generated
vendored
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
File diff suppressed because one or more lines are too long
10
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_oxipng.d.ts
generated
vendored
10
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_oxipng.d.ts
generated
vendored
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
* @param {number} level
|
||||
* @param {boolean} interlace
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export declare function optimise(data: any, level: any, interlace: any): any;
|
||||
declare function init(input: any): Promise<WebAssembly.Exports>;
|
||||
export default init;
|
||||
export declare function cleanup(): void;
|
89
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_oxipng.js
generated
vendored
89
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_oxipng.js
generated
vendored
@@ -1,89 +0,0 @@
|
||||
let wasm;
|
||||
let cachedTextDecoder = new TextDecoder("utf-8", {
|
||||
ignoreBOM: true,
|
||||
fatal: true
|
||||
});
|
||||
cachedTextDecoder.decode();
|
||||
let cachegetUint8Memory0 = null;
|
||||
function getUint8Memory0() {
|
||||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint8Memory0;
|
||||
}
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
function passArray8ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 1);
|
||||
getUint8Memory0().set(arg, ptr / 1);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
let cachegetInt32Memory0 = null;
|
||||
function getInt32Memory0() {
|
||||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetInt32Memory0;
|
||||
}
|
||||
function getArrayU8FromWasm0(ptr, len) {
|
||||
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
function optimise(data, level, interlace) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
wasm.optimise(retptr, ptr0, len0, level, interlace);
|
||||
const r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
const r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
const v1 = getArrayU8FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_free(r0, r1 * 1);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
async function load(module, imports) {
|
||||
if (typeof Response === "function" && module instanceof Response) {
|
||||
if (typeof WebAssembly.instantiateStreaming === "function") {
|
||||
return await WebAssembly.instantiateStreaming(module, imports);
|
||||
}
|
||||
const bytes = await module.arrayBuffer();
|
||||
return await WebAssembly.instantiate(bytes, imports);
|
||||
} else {
|
||||
const instance = await WebAssembly.instantiate(module, imports);
|
||||
if (instance instanceof WebAssembly.Instance) {
|
||||
return { instance, module };
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
async function init(input) {
|
||||
const imports = {};
|
||||
imports.wbg = {};
|
||||
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
};
|
||||
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
|
||||
input = fetch(input);
|
||||
}
|
||||
const { instance, module } = await load(await input, imports);
|
||||
wasm = instance.exports;
|
||||
init.__wbindgen_wasm_module = module;
|
||||
return wasm;
|
||||
}
|
||||
var squoosh_oxipng_default = init;
|
||||
function cleanup() {
|
||||
wasm = null;
|
||||
cachegetUint8Memory0 = null;
|
||||
cachegetInt32Memory0 = null;
|
||||
}
|
||||
export {
|
||||
cleanup,
|
||||
squoosh_oxipng_default as default,
|
||||
optimise
|
||||
};
|
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm
generated
vendored
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
4
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm.js
generated
vendored
4
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm.js
generated
vendored
File diff suppressed because one or more lines are too long
15
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png.d.ts
generated
vendored
15
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png.d.ts
generated
vendored
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
* @param {number} width
|
||||
* @param {number} height
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export declare function encode(data: any, width: any, height: any): any;
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
* @returns {ImageData}
|
||||
*/
|
||||
export declare function decode(data: any): any;
|
||||
declare function init(input: any): Promise<WebAssembly.Exports>;
|
||||
export default init;
|
||||
export declare function cleanup(): void;
|
136
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png.js
generated
vendored
136
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png.js
generated
vendored
@@ -1,136 +0,0 @@
|
||||
let wasm;
|
||||
let cachedTextDecoder = new TextDecoder("utf-8", {
|
||||
ignoreBOM: true,
|
||||
fatal: true
|
||||
});
|
||||
cachedTextDecoder.decode();
|
||||
let cachegetUint8Memory0 = null;
|
||||
function getUint8Memory0() {
|
||||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint8Memory0;
|
||||
}
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
let cachegetUint8ClampedMemory0 = null;
|
||||
function getUint8ClampedMemory0() {
|
||||
if (cachegetUint8ClampedMemory0 === null || cachegetUint8ClampedMemory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint8ClampedMemory0;
|
||||
}
|
||||
function getClampedArrayU8FromWasm0(ptr, len) {
|
||||
return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
const heap = new Array(32).fill(void 0);
|
||||
heap.push(void 0, null, true, false);
|
||||
let heap_next = heap.length;
|
||||
function addHeapObject(obj) {
|
||||
if (heap_next === heap.length) heap.push(heap.length + 1);
|
||||
const idx = heap_next;
|
||||
heap_next = heap[idx];
|
||||
heap[idx] = obj;
|
||||
return idx;
|
||||
}
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
function passArray8ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 1);
|
||||
getUint8Memory0().set(arg, ptr / 1);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
let cachegetInt32Memory0 = null;
|
||||
function getInt32Memory0() {
|
||||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetInt32Memory0;
|
||||
}
|
||||
function getArrayU8FromWasm0(ptr, len) {
|
||||
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
function encode(data, width, height) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
wasm.encode(retptr, ptr0, len0, width, height);
|
||||
const r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
const r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
const v1 = getArrayU8FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_free(r0, r1 * 1);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
function getObject(idx) {
|
||||
return heap[idx];
|
||||
}
|
||||
function dropObject(idx) {
|
||||
if (idx < 36) return;
|
||||
heap[idx] = heap_next;
|
||||
heap_next = idx;
|
||||
}
|
||||
function takeObject(idx) {
|
||||
const ret = getObject(idx);
|
||||
dropObject(idx);
|
||||
return ret;
|
||||
}
|
||||
function decode(data) {
|
||||
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.decode(ptr0, len0);
|
||||
return takeObject(ret);
|
||||
}
|
||||
async function load(module, imports) {
|
||||
if (typeof Response === "function" && module instanceof Response) {
|
||||
if (typeof WebAssembly.instantiateStreaming === "function") {
|
||||
return await WebAssembly.instantiateStreaming(module, imports);
|
||||
}
|
||||
const bytes = await module.arrayBuffer();
|
||||
return await WebAssembly.instantiate(bytes, imports);
|
||||
} else {
|
||||
const instance = await WebAssembly.instantiate(module, imports);
|
||||
if (instance instanceof WebAssembly.Instance) {
|
||||
return { instance, module };
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
async function init(input) {
|
||||
const imports = {};
|
||||
imports.wbg = {};
|
||||
imports.wbg.__wbg_newwithownedu8clampedarrayandsh_787b2db8ea6bfd62 = function(arg0, arg1, arg2, arg3) {
|
||||
const v0 = getClampedArrayU8FromWasm0(arg0, arg1).slice();
|
||||
wasm.__wbindgen_free(arg0, arg1 * 1);
|
||||
const ret = new ImageData(v0, arg2 >>> 0, arg3 >>> 0);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
};
|
||||
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
|
||||
input = fetch(input);
|
||||
}
|
||||
const { instance, module } = await load(await input, imports);
|
||||
wasm = instance.exports;
|
||||
init.__wbindgen_wasm_module = module;
|
||||
return wasm;
|
||||
}
|
||||
var squoosh_png_default = init;
|
||||
function cleanup() {
|
||||
wasm = null;
|
||||
cachegetUint8ClampedMemory0 = null;
|
||||
cachegetUint8Memory0 = null;
|
||||
cachegetInt32Memory0 = null;
|
||||
}
|
||||
export {
|
||||
cleanup,
|
||||
decode,
|
||||
squoosh_png_default as default,
|
||||
encode
|
||||
};
|
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm
generated
vendored
Binary file not shown.
2
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
4
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm.js
generated
vendored
4
node_modules/astro/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm.js
generated
vendored
File diff suppressed because one or more lines are too long
15
node_modules/astro/dist/assets/services/vendor/squoosh/resize/squoosh_resize.d.ts
generated
vendored
15
node_modules/astro/dist/assets/services/vendor/squoosh/resize/squoosh_resize.d.ts
generated
vendored
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* @param {Uint8Array} input_image
|
||||
* @param {number} input_width
|
||||
* @param {number} input_height
|
||||
* @param {number} output_width
|
||||
* @param {number} output_height
|
||||
* @param {number} typ_idx
|
||||
* @param {boolean} premultiply
|
||||
* @param {boolean} color_space_conversion
|
||||
* @returns {Uint8ClampedArray}
|
||||
*/
|
||||
export declare function resize(input_image: any, input_width: any, input_height: any, output_width: any, output_height: any, typ_idx: any, premultiply: any, color_space_conversion: any): any;
|
||||
declare function init(input: any): Promise<WebAssembly.Exports>;
|
||||
export default init;
|
||||
export declare function cleanup(): void;
|
95
node_modules/astro/dist/assets/services/vendor/squoosh/resize/squoosh_resize.js
generated
vendored
95
node_modules/astro/dist/assets/services/vendor/squoosh/resize/squoosh_resize.js
generated
vendored
@@ -1,95 +0,0 @@
|
||||
let wasm;
|
||||
let cachegetUint8Memory0 = null;
|
||||
function getUint8Memory0() {
|
||||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint8Memory0;
|
||||
}
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
function passArray8ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 1);
|
||||
getUint8Memory0().set(arg, ptr / 1);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
let cachegetInt32Memory0 = null;
|
||||
function getInt32Memory0() {
|
||||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetInt32Memory0;
|
||||
}
|
||||
let cachegetUint8ClampedMemory0 = null;
|
||||
function getUint8ClampedMemory0() {
|
||||
if (cachegetUint8ClampedMemory0 === null || cachegetUint8ClampedMemory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint8ClampedMemory0;
|
||||
}
|
||||
function getClampedArrayU8FromWasm0(ptr, len) {
|
||||
return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
function resize(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
const ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
wasm.resize(
|
||||
retptr,
|
||||
ptr0,
|
||||
len0,
|
||||
input_width,
|
||||
input_height,
|
||||
output_width,
|
||||
output_height,
|
||||
typ_idx,
|
||||
premultiply,
|
||||
color_space_conversion
|
||||
);
|
||||
const r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
const r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
const v1 = getClampedArrayU8FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_free(r0, r1 * 1);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
async function load(module, imports) {
|
||||
if (typeof Response === "function" && module instanceof Response) {
|
||||
if (typeof WebAssembly.instantiateStreaming === "function") {
|
||||
return await WebAssembly.instantiateStreaming(module, imports);
|
||||
}
|
||||
const bytes = await module.arrayBuffer();
|
||||
return await WebAssembly.instantiate(bytes, imports);
|
||||
} else {
|
||||
const instance = await WebAssembly.instantiate(module, imports);
|
||||
if (instance instanceof WebAssembly.Instance) {
|
||||
return { instance, module };
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
async function init(input) {
|
||||
const imports = {};
|
||||
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
|
||||
input = fetch(input);
|
||||
}
|
||||
const { instance, module } = await load(await input, imports);
|
||||
wasm = instance.exports;
|
||||
init.__wbindgen_wasm_module = module;
|
||||
return wasm;
|
||||
}
|
||||
var squoosh_resize_default = init;
|
||||
function cleanup() {
|
||||
wasm = null;
|
||||
cachegetUint8Memory0 = null;
|
||||
cachegetInt32Memory0 = null;
|
||||
}
|
||||
export {
|
||||
cleanup,
|
||||
squoosh_resize_default as default,
|
||||
resize
|
||||
};
|
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/resize/squoosh_resize_bg.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/resize/squoosh_resize_bg.wasm
generated
vendored
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
File diff suppressed because one or more lines are too long
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/rotate/rotate.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/rotate/rotate.wasm
generated
vendored
Binary file not shown.
2
node_modules/astro/dist/assets/services/vendor/squoosh/rotate/rotate.wasm.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/rotate/rotate.wasm.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
4
node_modules/astro/dist/assets/services/vendor/squoosh/rotate/rotate.wasm.js
generated
vendored
4
node_modules/astro/dist/assets/services/vendor/squoosh/rotate/rotate.wasm.js
generated
vendored
@@ -1,4 +0,0 @@
|
||||
var rotate_wasm_default = Buffer.from("AGFzbQEAAAABDAJgAn9/AGADf39/AAMGBQAAAAABBQMBABAGEQJ/AEGAgMAAC38AQYCAwAALBy4EBm1lbW9yeQIABnJvdGF0ZQAECl9fZGF0YV9lbmQDAAtfX2hlYXBfYmFzZQMBCpsJBUkBAX8gACABbCIAQf////8DcSICBEBBCCEBIABBAnRBCGohAANAIAAgASgCADYCACABQQRqIQEgAEEEaiEAIAJBf2oiAg0ACwsLzQMBFH8gAUECdCERIAAgAWwiDEECdEEEaiESA0ACQAJAAkACQCAEQQFxRQRAIAMgAU8NAiADQQFqIQgMAQsgA0EPaiICIANJIggNASACIAFJIgVFDQEgASADQRBqIAgbIAEgBRshCCACIQMLIAEgA0EQaiICIAIgAUsbIQ0gA0F/cyETIBIgA0ECdGshFEEAIQVBACEOA0ACQAJAIA5FBEAgBSAASQ0BQQEhBAwGCyAAIAVBEGogBUEPaiICIAVJIgcbIAAgAiAASRshBUEBIQQgByACIABPcg0FDAELIAUiAkEBaiEFC0EBIQ4gAyANTw0AIAAgAkEQaiIPIAAgD0kbQQJ0IAJBAnRrIRUgEyABIAJsaiEHIBQgASACQQFqbEECdGohCSADIQoDQCAAIApsIgYgAmoiBEEQaiAAIAZqIA8gAEkbIgYgBEkgDCAGSXINAyAEIAZHBEAgBEECdEEIaiELIBUhBiAHIRAgCSEEA0AgDCABIBBqIhBNDQUgBCALKAIANgIAIAQgEWohBCALQQRqIQsgBkF8aiIGDQALCyAHQX9qIQcgCUF8aiEJIA0gCkEBaiIKRw0ACwwACwALDwsACyAIIQMMAAsAC1MBAX8CQCAAIAFsQQJ0IgJBCGoiAEEIRg0AIAAgAmpBfGohAEEAIQEDQCABIAJGDQEgACABQQhqKAIANgIAIABBfGohACACIAFBBGoiAUcNAAsLC9oDARN/IABBf2ohEEEAIAFBAnRrIREgACABbCIMQQJ0QQhqIRIDQAJAAkACQAJAIARBAXFFBEAgAyABTw0CIANBAWohCQwBCyADQQ9qIgIgA0kiCQ0BIAIgAUkiBUUNASABIANBEGogCRsgASAFGyEJIAIhAwsgASADQRBqIgIgAiABSxshDSASIANBAnRqIRNBACEFQQAhBgNAAkACQCAGQQFxRQRAIAUgAEkNAUEBIQQMBgsgACAFQRBqIAVBD2oiAiAFSSIIGyAAIAIgAEkbIQVBASEEIAggAiAAT3INBQwBCyAFIgJBAWohBQtBASEGIAMgDU8NACAAIAJBEGoiDiAAIA5JG0ECdCACQQJ0ayEUIAMgASAAIAJrbGohCCATIAEgECACa2xBAnRqIQogAyELA0AgACALbCIHIAJqIgRBEGogACAHaiAOIABJGyIHIARJIAwgB0lyDQMgBCAHRwRAIARBAnRBCGohBiAUIQcgCCEPIAohBANAIAwgDyABayIPTQ0FIAQgBigCADYCACAEIBFqIQQgBkEEaiEGIAdBfGoiBw0ACwtBASEGIAhBAWohCCAKQQRqIQogDSALQQFqIgtHDQALDAALAAsPCwALIAkhAwwACwALUAACQAJAAkACQCACQbMBTARAIAJFDQIgAkHaAEcNASAAIAEQAQ8LIAJBtAFGDQIgAkGOAkYNAwsACyAAIAEQAA8LIAAgARACDwsgACABEAMLAE0JcHJvZHVjZXJzAghsYW5ndWFnZQEEUnVzdAAMcHJvY2Vzc2VkLWJ5AQVydXN0Yx0xLjQ3LjAgKDE4YmY2YjRmMCAyMDIwLTEwLTA3KQ==", "base64");
|
||||
export {
|
||||
rotate_wasm_default as default
|
||||
};
|
1
node_modules/astro/dist/assets/services/vendor/squoosh/utils/execOnce.d.ts
generated
vendored
1
node_modules/astro/dist/assets/services/vendor/squoosh/utils/execOnce.d.ts
generated
vendored
@@ -1 +0,0 @@
|
||||
export default function execOnce<T extends (...args: any[]) => ReturnType<T>>(fn: T): T;
|
14
node_modules/astro/dist/assets/services/vendor/squoosh/utils/execOnce.js
generated
vendored
14
node_modules/astro/dist/assets/services/vendor/squoosh/utils/execOnce.js
generated
vendored
@@ -1,14 +0,0 @@
|
||||
function execOnce(fn) {
|
||||
let used = false;
|
||||
let result;
|
||||
return (...args) => {
|
||||
if (!used) {
|
||||
used = true;
|
||||
result = fn(...args);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
export {
|
||||
execOnce as default
|
||||
};
|
21
node_modules/astro/dist/assets/services/vendor/squoosh/utils/workerPool.d.ts
generated
vendored
21
node_modules/astro/dist/assets/services/vendor/squoosh/utils/workerPool.d.ts
generated
vendored
@@ -1,21 +0,0 @@
|
||||
import { Worker } from 'worker_threads';
|
||||
interface Job<I> {
|
||||
msg: I;
|
||||
resolve: (result: any) => void;
|
||||
reject: (reason: any) => void;
|
||||
}
|
||||
export default class WorkerPool<I, O> {
|
||||
numWorkers: number;
|
||||
jobQueue: TransformStream<Job<I>, Job<I>>;
|
||||
workerQueue: TransformStream<Worker, Worker>;
|
||||
done: Promise<void>;
|
||||
constructor(numWorkers: number, workerFile: string);
|
||||
_readLoop(): Promise<void>;
|
||||
_nextWorker(): Promise<Worker>;
|
||||
_terminateAll(): Promise<void>;
|
||||
join(): Promise<void>;
|
||||
dispatchJob(msg: I): Promise<O>;
|
||||
private jobPromise;
|
||||
static useThisThreadAsWorker<I, O>(cb: (msg: I) => O): void;
|
||||
}
|
||||
export {};
|
99
node_modules/astro/dist/assets/services/vendor/squoosh/utils/workerPool.js
generated
vendored
99
node_modules/astro/dist/assets/services/vendor/squoosh/utils/workerPool.js
generated
vendored
@@ -1,99 +0,0 @@
|
||||
import { parentPort, Worker } from "worker_threads";
|
||||
function uuid() {
|
||||
return Array.from({ length: 16 }, () => Math.floor(Math.random() * 256).toString(16)).join("");
|
||||
}
|
||||
class WorkerPool {
|
||||
numWorkers;
|
||||
jobQueue;
|
||||
workerQueue;
|
||||
done;
|
||||
constructor(numWorkers, workerFile) {
|
||||
this.numWorkers = numWorkers;
|
||||
this.jobQueue = new TransformStream();
|
||||
this.workerQueue = new TransformStream();
|
||||
const writer = this.workerQueue.writable.getWriter();
|
||||
for (let i = 0; i < numWorkers; i++) {
|
||||
writer.write(new Worker(workerFile));
|
||||
}
|
||||
writer.releaseLock();
|
||||
this.done = this._readLoop();
|
||||
}
|
||||
async _readLoop() {
|
||||
const reader = this.jobQueue.readable.getReader();
|
||||
while (true) {
|
||||
const { value, done } = await reader.read();
|
||||
if (done) {
|
||||
await this._terminateAll();
|
||||
return;
|
||||
}
|
||||
if (!value) {
|
||||
throw new Error("Reader did not return any value");
|
||||
}
|
||||
const { msg, resolve, reject } = value;
|
||||
const worker = await this._nextWorker();
|
||||
this.jobPromise(worker, msg).then((result) => resolve(result)).catch((reason) => reject(reason)).finally(() => {
|
||||
const writer = this.workerQueue.writable.getWriter();
|
||||
writer.write(worker);
|
||||
writer.releaseLock();
|
||||
});
|
||||
}
|
||||
}
|
||||
async _nextWorker() {
|
||||
const reader = this.workerQueue.readable.getReader();
|
||||
const { value } = await reader.read();
|
||||
reader.releaseLock();
|
||||
if (!value) {
|
||||
throw new Error("No worker left");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
async _terminateAll() {
|
||||
for (let n = 0; n < this.numWorkers; n++) {
|
||||
const worker = await this._nextWorker();
|
||||
worker.terminate();
|
||||
}
|
||||
this.workerQueue.writable.close();
|
||||
}
|
||||
async join() {
|
||||
this.jobQueue.writable.getWriter().close();
|
||||
await this.done;
|
||||
}
|
||||
dispatchJob(msg) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const writer = this.jobQueue.writable.getWriter();
|
||||
writer.write({ msg, resolve, reject });
|
||||
writer.releaseLock();
|
||||
});
|
||||
}
|
||||
jobPromise(worker, msg) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = uuid();
|
||||
worker.postMessage({ msg, id });
|
||||
worker.on("message", function f({ error, result, id: rid }) {
|
||||
if (rid !== id) {
|
||||
return;
|
||||
}
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
worker.off("message", f);
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
static useThisThreadAsWorker(cb) {
|
||||
parentPort.on("message", async (data) => {
|
||||
const { msg, id } = data;
|
||||
try {
|
||||
const result = await cb(msg);
|
||||
parentPort.postMessage({ result, id });
|
||||
} catch (e) {
|
||||
parentPort.postMessage({ error: e.message, id });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
export {
|
||||
WorkerPool as default
|
||||
};
|
4
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_enc.d.js
generated
vendored
4
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_enc.d.js
generated
vendored
@@ -1,4 +0,0 @@
|
||||
var webp_enc_d_default = moduleFactory;
|
||||
export {
|
||||
webp_enc_d_default as default
|
||||
};
|
2
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare var Module: (Module: any) => any;
|
||||
export default Module;
|
1444
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js
generated
vendored
1444
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js
generated
vendored
File diff suppressed because it is too large
Load Diff
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm
generated
vendored
Binary file not shown.
2
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
4
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm.js
generated
vendored
4
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm.js
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare var Module: (Module: any) => any;
|
||||
export default Module;
|
1611
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js
generated
vendored
1611
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js
generated
vendored
File diff suppressed because it is too large
Load Diff
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm
generated
vendored
BIN
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm
generated
vendored
Binary file not shown.
2
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm.d.ts
generated
vendored
2
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
4
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm.js
generated
vendored
4
node_modules/astro/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm.js
generated
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user