diff --git a/packages/next/next-server/server/lib/squoosh/LICENSE b/packages/next/next-server/server/lib/squoosh/LICENSE deleted file mode 100644 index d645695673349..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/packages/next/next-server/server/lib/squoosh/codecs.ts b/packages/next/next-server/server/lib/squoosh/codecs.ts deleted file mode 100644 index b913fc4d3c455..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/codecs.ts +++ /dev/null @@ -1,307 +0,0 @@ -import { promises as fsp } from 'fs' -import * as path from 'path' -import { instantiateEmscriptenWasm, pathify } from './emscripten-utils.js' - -// MozJPEG -// @ts-ignore -import mozEnc from './mozjpeg/mozjpeg_node_enc.js' -const mozEncWasm = path.resolve(__dirname, './mozjpeg/mozjpeg_node_enc.wasm') -// @ts-ignore -import mozDec from './mozjpeg/mozjpeg_node_dec.js' -const mozDecWasm = path.resolve(__dirname, './mozjpeg/mozjpeg_node_dec.wasm') - -// WebP -// @ts-ignore -import webpEnc from './webp/webp_node_enc.js' -const webpEncWasm = path.resolve(__dirname, './webp/webp_node_enc.wasm') -// @ts-ignore -import webpDec from './webp/webp_node_dec.js' -const webpDecWasm = path.resolve(__dirname, './webp/webp_node_dec.wasm') - -// PNG -// @ts-ignore -import * as pngEncDec from './png/squoosh_png.js' -const pngEncDecWasm = path.resolve(__dirname, './png/squoosh_png_bg.wasm') -const pngEncDecInit = () => - pngEncDec.default(fsp.readFile(pathify(pngEncDecWasm))) - -// OxiPNG -// @ts-ignore -import * as oxipng from './png/squoosh_oxipng.js' -const oxipngWasm = path.resolve(__dirname, './png/squoosh_oxipng_bg.wasm') -const oxipngInit = () => oxipng.default(fsp.readFile(pathify(oxipngWasm))) - -// Resize -// @ts-ignore -import * as resize from './resize/squoosh_resize.js' -const resizeWasm = path.resolve(__dirname, './resize/squoosh_resize_bg.wasm') -const resizeInit = () => resize.default(fsp.readFile(pathify(resizeWasm))) - -// rotate -const rotateWasm = path.resolve(__dirname, './rotate/rotate.wasm') - -import ImageData from './image_data.js' -;(global as any).ImageData = ImageData // mandatory for wasm binaries - -function resizeNameToIndex( - name: 'triangle' | 'catrom' | 'mitchell' | 'lanczos3' -) { - 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, -}: { - input_width: number - input_height: number - target_width?: number - target_height?: number -}): { width: number; height: number } { - 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!, - } - } - if (!target_height) { - return { - width: target_width, - height: Math.round((input_height / input_width) * target_width), - } - } - throw Error('invariant') -} - -export const preprocessors = { - resize: { - name: 'Resize', - description: 'Resize the image before compressing', - instantiate: async () => { - await resizeInit() - return ( - buffer: Buffer | Uint8Array, - input_width: number, - input_height: number, - { - width, - height, - method, - premultiply, - linearRGB, - }: { - width?: number - height?: number - method: 'triangle' | 'catrom' | 'mitchell' | 'lanczos3' - premultiply: boolean - linearRGB: boolean - } - ) => { - ;({ 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: Buffer | Uint8Array, - width: number, - height: number, - { numRotations }: { numRotations: number } - ) => { - const degrees = (numRotations * 90) % 360 - const sameDimensions = degrees === 0 || degrees === 180 - const size = width * height * 4 - const { instance } = await WebAssembly.instantiate( - await fsp.readFile(pathify(rotateWasm)) - ) - const exports = instance.exports as any - const { memory } = 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) - exports.rotate(width, height, degrees) - return new ImageData( - Buffer.from(view.slice(size + 8, size * 2 + 8)), - sameDimensions ? width : height, - sameDimensions ? height : width - ) - } - }, - defaultOptions: { - numRotations: 0, - }, - }, -} as const - -export 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 /*YCbCr*/, - 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 ]/], - 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, - }, - }, - oxipng: { - name: 'OxiPNG', - extension: 'png', - // eslint-disable-next-line no-control-regex - detectors: [/^\x89PNG\x0D\x0A\x1A\x0A/], - dec: async () => { - await pngEncDecInit() - return { - decode: (buffer: Buffer | Uint8Array): Buffer => { - const imageData = pngEncDec.decode(buffer) - pngEncDec.cleanup() - return imageData - }, - } as any - }, - enc: async () => { - await pngEncDecInit() - await oxipngInit() - return { - encode: ( - buffer: Buffer | Uint8Array, - width: number, - height: number, - opts: any - ) => { - const simplePng = pngEncDec.encode( - new Uint8Array(buffer), - width, - height - ) - const imageData = oxipng.optimise(simplePng, opts.level) - oxipng.cleanup() - return imageData - }, - } - }, - defaultEncoderOptions: { - level: 2, - }, - autoOptimize: { - option: 'level', - min: 6, - max: 1, - }, - }, -} as const diff --git a/packages/next/next-server/server/lib/squoosh/emscripten-utils.ts b/packages/next/next-server/server/lib/squoosh/emscripten-utils.ts deleted file mode 100644 index ed4f91c99951e..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/emscripten-utils.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { fileURLToPath } from 'url' - -export function pathify(path: string) { - if (path.startsWith('file://')) { - path = fileURLToPath(path) - } - return path -} - -export function instantiateEmscriptenWasm( - factory: (args: { - locateFile: () => string - }) => { - decode?: ( - buffer: Buffer | Uint8Array, - width: number, - height: number, - opts: any - ) => Buffer - encode?: ( - buffer: Buffer | Uint8Array, - width: number, - height: number, - opts: any - ) => Buffer - }, - path: string -) { - return factory({ - locateFile() { - return pathify(path) - }, - }) -} diff --git a/packages/next/next-server/server/lib/squoosh/image_data.ts b/packages/next/next-server/server/lib/squoosh/image_data.ts index 16936b60e872b..26cea838f8a34 100644 --- a/packages/next/next-server/server/lib/squoosh/image_data.ts +++ b/packages/next/next-server/server/lib/squoosh/image_data.ts @@ -1,32 +1,10 @@ export default class ImageData { - static from(input: ImageData): ImageData { - return new ImageData(input.data || input._data, input.width, input.height) - } - - private _data: Buffer | Uint8Array | Uint8ClampedArray - width: number - height: number - - get data(): Buffer { - 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: Buffer | Uint8Array | Uint8ClampedArray, - width: number, - height: number + public data: Buffer | Uint8Array | Uint8ClampedArray, + public width: number, + public height: number ) { - this._data = data + this.data = Uint8ClampedArray.from(data) this.width = width this.height = height } diff --git a/packages/next/next-server/server/lib/squoosh/impl.ts b/packages/next/next-server/server/lib/squoosh/impl.ts index b9efc9859114f..70d4867a87b6b 100644 --- a/packages/next/next-server/server/lib/squoosh/impl.ts +++ b/packages/next/next-server/server/lib/squoosh/impl.ts @@ -1,31 +1,28 @@ -import { codecs as supportedFormats, preprocessors } from './codecs' import ImageData from './image_data' +// @ts-ignore: TODO get TS types for squoosh +import { encoders, preprocessors } from '@squoosh/lib' -export async function decodeBuffer( - _buffer: Buffer | Uint8Array -): Promise { - const buffer = Buffer.from(_buffer) +export async function decodeBuffer(buffer: Buffer): Promise { const firstChunk = buffer.slice(0, 16) const firstChunkString = Array.from(firstChunk) .map((v) => String.fromCodePoint(v)) .join('') - const key = Object.entries(supportedFormats).find(([, { detectors }]) => - detectors.some((detector) => detector.exec(firstChunkString)) - )?.[0] as keyof typeof supportedFormats - if (!key) { + const key = Object.entries(encoders).find(([, val]) => + // @ts-ignore: TODO get TS types for squoosh + val.detectors.some((detector) => detector.exec(firstChunkString)) + )?.[0] + if (!key || !['mozjpeg', 'webp', 'oxipng'].includes(key)) { throw Error(`Buffer has an unsupported format`) } - const d = await supportedFormats[key].dec() - return d.decode(new Uint8Array(buffer)) + const d = await encoders[key].dec() + return d.decode(Uint8ClampedArray.from(buffer)) } export async function rotate( image: ImageData, numRotations: number ): Promise { - image = ImageData.from(image) - - const m = await preprocessors['rotate'].instantiate() + const m = await preprocessors.rotate.instantiate() return await m(image.data, image.width, image.height, { numRotations }) } @@ -35,9 +32,7 @@ type ResizeOpts = { image: ImageData } & ( ) export async function resize({ image, width, height }: ResizeOpts) { - image = ImageData.from(image) - - const p = preprocessors['resize'] + const p = preprocessors.resize const m = await p.instantiate() return await m(image.data, image.width, image.height, { ...p.defaultOptions, @@ -49,12 +44,10 @@ export async function resize({ image, width, height }: ResizeOpts) { export async function encodeJpeg( image: ImageData, { quality }: { quality: number } -): Promise { - image = ImageData.from(image) - - const e = supportedFormats['mozjpeg'] +): Promise { + const e = encoders.mozjpeg const m = await e.enc() - const r = await m.encode!(image.data, image.width, image.height, { + const r = await m.encode(image.data, image.width, image.height, { ...e.defaultEncoderOptions, quality, }) @@ -64,24 +57,18 @@ export async function encodeJpeg( export async function encodeWebp( image: ImageData, { quality }: { quality: number } -): Promise { - image = ImageData.from(image) - - const e = supportedFormats['webp'] +): Promise { + const e = encoders.webp const m = await e.enc() - const r = await m.encode!(image.data, image.width, image.height, { + const r = await m.encode(image.data, image.width, image.height, { ...e.defaultEncoderOptions, quality, }) return Buffer.from(r) } -export async function encodePng( - image: ImageData -): Promise { - image = ImageData.from(image) - - const e = supportedFormats['oxipng'] +export async function encodePng(image: ImageData): Promise { + const e = encoders.oxipng const m = await e.enc() const r = await m.encode(image.data, image.width, image.height, { ...e.defaultEncoderOptions, diff --git a/packages/next/next-server/server/lib/squoosh/main.ts b/packages/next/next-server/server/lib/squoosh/main.ts index 4b885764481ab..3a3d67cfa626e 100644 --- a/packages/next/next-server/server/lib/squoosh/main.ts +++ b/packages/next/next-server/server/lib/squoosh/main.ts @@ -1,7 +1,4 @@ -import { Worker } from 'jest-worker' -import * as path from 'path' -import { execOnce } from '../../../lib/utils' -import { cpus } from 'os' +import * as worker from './impl' type RotateOperation = { type: 'rotate' @@ -13,25 +10,12 @@ type ResizeOperation = { export type Operation = RotateOperation | ResizeOperation export type Encoding = 'jpeg' | 'png' | 'webp' -const getWorker = execOnce( - () => - new Worker(path.resolve(__dirname, 'impl'), { - enableWorkerThreads: true, - // There will be at most 6 workers needed since each worker will take - // at least 1 operation type. - numWorkers: Math.max(1, Math.min(cpus().length - 1, 6)), - computeWorkerKey: (method) => method, - }) -) - export async function processBuffer( buffer: Buffer, operations: Operation[], encoding: Encoding, quality: number ): Promise { - const worker: typeof import('./impl') = getWorker() as any - let imageData = await worker.decodeBuffer(buffer) for (const operation of operations) { if (operation.type === 'rotate') { diff --git a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js b/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js deleted file mode 100644 index 77b5b6a4e8bfd..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js +++ /dev/null @@ -1,1205 +0,0 @@ -/* eslint-disable */ -import { TextDecoder } from '../text-decoder' - -var Module = (function () { - // var _scriptDir = import.meta.url - - return function (Module) { - Module = Module || {} - - var e - e || (e = typeof Module !== 'undefined' ? Module : {}) - var aa, r - e.ready = new Promise(function (a, b) { - aa = a - r = b - }) - var t = {}, - u - for (u in e) e.hasOwnProperty(u) && (t[u] = e[u]) - var ba = './this.program' - function ca(a, b) { - throw b - } - var da = '', - ea, - fa, - ha, - ia - da = __dirname + '/' - ea = function (a) { - ha || (ha = require('fs')) - ia || (ia = require('path')) - a = ia.normalize(a) - return ha.readFileSync(a, null) - } - fa = function (a) { - a = ea(a) - a.buffer || (a = new Uint8Array(a)) - a.buffer || v('Assertion failed: undefined') - return a - } - ca = function (a) { - process.exit(a) - } - e.inspect = function () { - return '[Emscripten Module object]' - } - var ka = e.print || console.log.bind(console), - w = e.printErr || console.warn.bind(console) - for (u in t) t.hasOwnProperty(u) && (e[u] = t[u]) - t = null - e.thisProgram && (ba = e.thisProgram) - e.quit && (ca = e.quit) - var y - e.wasmBinary && (y = e.wasmBinary) - var noExitRuntime - e.noExitRuntime && (noExitRuntime = e.noExitRuntime) - 'object' !== typeof WebAssembly && v('no native wasm support detected') - var z, - la = !1, - ma = new TextDecoder('utf8') - function na(a, b, c) { - var d = A - if (0 < c) { - c = b + c - 1 - for (var f = 0; f < a.length; ++f) { - var g = a.charCodeAt(f) - if (55296 <= g && 57343 >= g) { - var l = a.charCodeAt(++f) - g = (65536 + ((g & 1023) << 10)) | (l & 1023) - } - if (127 >= g) { - if (b >= c) break - d[b++] = g - } else { - if (2047 >= g) { - if (b + 1 >= c) break - d[b++] = 192 | (g >> 6) - } else { - if (65535 >= g) { - if (b + 2 >= c) break - d[b++] = 224 | (g >> 12) - } else { - if (b + 3 >= c) break - d[b++] = 240 | (g >> 18) - d[b++] = 128 | ((g >> 12) & 63) - } - d[b++] = 128 | ((g >> 6) & 63) - } - d[b++] = 128 | (g & 63) - } - } - d[b] = 0 - } - } - var oa = new TextDecoder('utf-16le') - function pa(a, b) { - var c = a >> 1 - for (b = c + b / 2; !(c >= b) && C[c]; ) ++c - return oa.decode(A.subarray(a, c << 1)) - } - function qa(a, b, c) { - void 0 === c && (c = 2147483647) - if (2 > c) return 0 - c -= 2 - var d = b - c = c < 2 * a.length ? c / 2 : a.length - for (var f = 0; f < c; ++f) (D[b >> 1] = a.charCodeAt(f)), (b += 2) - D[b >> 1] = 0 - return b - d - } - function ra(a) { - return 2 * a.length - } - function sa(a, b) { - for (var c = 0, d = ''; !(c >= b / 4); ) { - var f = E[(a + 4 * c) >> 2] - if (0 == f) break - ++c - 65536 <= f - ? ((f -= 65536), - (d += String.fromCharCode(55296 | (f >> 10), 56320 | (f & 1023)))) - : (d += String.fromCharCode(f)) - } - return d - } - function ta(a, b, c) { - void 0 === c && (c = 2147483647) - if (4 > c) return 0 - var d = b - c = d + c - 4 - for (var f = 0; f < a.length; ++f) { - var g = a.charCodeAt(f) - if (55296 <= g && 57343 >= g) { - var l = a.charCodeAt(++f) - g = (65536 + ((g & 1023) << 10)) | (l & 1023) - } - E[b >> 2] = g - b += 4 - if (b + 4 > c) break - } - E[b >> 2] = 0 - return b - d - } - function ua(a) { - for (var b = 0, c = 0; c < a.length; ++c) { - var d = a.charCodeAt(c) - 55296 <= d && 57343 >= d && ++c - b += 4 - } - return b - } - var F, G, A, D, C, E, I, va, wa - function xa(a) { - F = a - e.HEAP8 = G = new Int8Array(a) - e.HEAP16 = D = new Int16Array(a) - e.HEAP32 = E = new Int32Array(a) - e.HEAPU8 = A = new Uint8Array(a) - e.HEAPU16 = C = new Uint16Array(a) - e.HEAPU32 = I = new Uint32Array(a) - e.HEAPF32 = va = new Float32Array(a) - e.HEAPF64 = wa = new Float64Array(a) - } - var ya = e.INITIAL_MEMORY || 16777216 - e.wasmMemory - ? (z = e.wasmMemory) - : (z = new WebAssembly.Memory({ initial: ya / 65536, maximum: 32768 })) - z && (F = z.buffer) - ya = F.byteLength - xa(F) - var J, - za = [], - Aa = [], - Ba = [], - Ca = [] - function Da() { - var a = e.preRun.shift() - za.unshift(a) - } - var K = 0, - Ea = null, - M = null - e.preloadedImages = {} - e.preloadedAudios = {} - function v(a) { - if (e.onAbort) e.onAbort(a) - w(a) - la = !0 - a = new WebAssembly.RuntimeError( - 'abort(' + a + '). Build with -s ASSERTIONS=1 for more info.' - ) - r(a) - throw a - } - function Fa() { - var a = N - return String.prototype.startsWith - ? a.startsWith('data:application/octet-stream;base64,') - : 0 === a.indexOf('data:application/octet-stream;base64,') - } - var N = 'mozjpeg_node_dec.wasm' - if (!Fa()) { - var Ga = N - N = e.locateFile ? e.locateFile(Ga, da) : da + Ga - } - function Ha() { - try { - if (y) return new Uint8Array(y) - if (fa) return fa(N) - throw 'both async and sync fetching of the wasm failed' - } catch (a) { - v(a) - } - } - function O(a) { - for (; 0 < a.length; ) { - var b = a.shift() - if ('function' == typeof b) b(e) - else { - var c = b.L - 'number' === typeof c - ? void 0 === b.I - ? J.get(c)() - : J.get(c)(b.I) - : c(void 0 === b.I ? null : b.I) - } - } - } - function Ia(a) { - switch (a) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + a) - } - } - var Ja = void 0 - function P(a) { - for (var b = ''; A[a]; ) b += Ja[A[a++]] - return b - } - var Q = {}, - R = {}, - S = {} - function Ka(a) { - if (void 0 === a) return '_unknown' - a = a.replace(/[^a-zA-Z0-9_]/g, '$') - var b = a.charCodeAt(0) - return 48 <= b && 57 >= b ? '_' + a : a - } - function La(a, b) { - a = Ka(a) - return new Function( - 'body', - 'return function ' + - a + - '() {\n "use strict"; return body.apply(this, arguments);\n};\n' - )(b) - } - function Ma(a) { - var b = Error, - c = La(a, function (d) { - this.name = a - this.message = d - d = Error(d).stack - void 0 !== d && - (this.stack = - this.toString() + '\n' + d.replace(/^Error(:[^\n]*)?\n/, '')) - }) - c.prototype = Object.create(b.prototype) - c.prototype.constructor = c - c.prototype.toString = function () { - return void 0 === this.message - ? this.name - : this.name + ': ' + this.message - } - return c - } - var Na = void 0 - function T(a) { - throw new Na(a) - } - var Oa = void 0 - function Pa(a, b) { - function c(h) { - h = b(h) - if (h.length !== d.length) - throw new Oa('Mismatched type converter count') - for (var k = 0; k < d.length; ++k) U(d[k], h[k]) - } - var d = [] - d.forEach(function (h) { - S[h] = a - }) - var f = Array(a.length), - g = [], - l = 0 - a.forEach(function (h, k) { - R.hasOwnProperty(h) - ? (f[k] = R[h]) - : (g.push(h), - Q.hasOwnProperty(h) || (Q[h] = []), - Q[h].push(function () { - f[k] = R[h] - ++l - l === g.length && c(f) - })) - }) - 0 === g.length && c(f) - } - function U(a, b, c) { - c = c || {} - if (!('argPackAdvance' in b)) - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - var d = b.name - a || T('type "' + d + '" must have a positive integer typeid pointer') - if (R.hasOwnProperty(a)) { - if (c.M) return - T("Cannot register type '" + d + "' twice") - } - R[a] = b - delete S[a] - Q.hasOwnProperty(a) && - ((b = Q[a]), - delete Q[a], - b.forEach(function (f) { - f() - })) - } - var Qa = [], - V = [{}, { value: void 0 }, { value: null }, { value: !0 }, { value: !1 }] - function Ra(a) { - 4 < a && 0 === --V[a].J && ((V[a] = void 0), Qa.push(a)) - } - function W(a) { - switch (a) { - case void 0: - return 1 - case null: - return 2 - case !0: - return 3 - case !1: - return 4 - default: - var b = Qa.length ? Qa.pop() : V.length - V[b] = { J: 1, value: a } - return b - } - } - function Sa(a) { - return this.fromWireType(I[a >> 2]) - } - function Va(a) { - if (null === a) return 'null' - var b = typeof a - return 'object' === b || 'array' === b || 'function' === b - ? a.toString() - : '' + a - } - function Wa(a, b) { - switch (b) { - case 2: - return function (c) { - return this.fromWireType(va[c >> 2]) - } - case 3: - return function (c) { - return this.fromWireType(wa[c >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + a) - } - } - function Xa(a) { - var b = Function - if (!(b instanceof Function)) - throw new TypeError( - 'new_ called with constructor type ' + - typeof b + - ' which is not a function' - ) - var c = La(b.name || 'unknownFunctionName', function () {}) - c.prototype = b.prototype - c = new c() - a = b.apply(c, a) - return a instanceof Object ? a : c - } - function Ya(a) { - for (; a.length; ) { - var b = a.pop() - a.pop()(b) - } - } - function Za(a, b) { - var c = e - if (void 0 === c[a].G) { - var d = c[a] - c[a] = function () { - c[a].G.hasOwnProperty(arguments.length) || - T( - "Function '" + - b + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - c[a].G + - ')!' - ) - return c[a].G[arguments.length].apply(this, arguments) - } - c[a].G = [] - c[a].G[d.K] = d - } - } - function $a(a, b, c) { - e.hasOwnProperty(a) - ? ((void 0 === c || (void 0 !== e[a].G && void 0 !== e[a].G[c])) && - T("Cannot register public name '" + a + "' twice"), - Za(a, a), - e.hasOwnProperty(c) && - T( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - c + - ')!' - ), - (e[a].G[c] = b)) - : ((e[a] = b), void 0 !== c && (e[a].O = c)) - } - function ab(a, b) { - for (var c = [], d = 0; d < a; d++) c.push(E[(b >> 2) + d]) - return c - } - function bb(a, b) { - 0 <= a.indexOf('j') || - v('Assertion failed: getDynCaller should only be called with i64 sigs') - var c = [] - return function () { - c.length = arguments.length - for (var d = 0; d < arguments.length; d++) c[d] = arguments[d] - var f - ;-1 != a.indexOf('j') - ? (f = - c && c.length - ? e['dynCall_' + a].apply(null, [b].concat(c)) - : e['dynCall_' + a].call(null, b)) - : (f = J.get(b).apply(null, c)) - return f - } - } - function cb(a, b) { - a = P(a) - var c = -1 != a.indexOf('j') ? bb(a, b) : J.get(b) - 'function' !== typeof c && - T('unknown function pointer with signature ' + a + ': ' + b) - return c - } - var db = void 0 - function eb(a) { - a = fb(a) - var b = P(a) - X(a) - return b - } - function gb(a, b) { - function c(g) { - f[g] || R[g] || (S[g] ? S[g].forEach(c) : (d.push(g), (f[g] = !0))) - } - var d = [], - f = {} - b.forEach(c) - throw new db(a + ': ' + d.map(eb).join([', '])) - } - function hb(a, b, c) { - switch (b) { - case 0: - return c - ? function (d) { - return G[d] - } - : function (d) { - return A[d] - } - case 1: - return c - ? function (d) { - return D[d >> 1] - } - : function (d) { - return C[d >> 1] - } - case 2: - return c - ? function (d) { - return E[d >> 2] - } - : function (d) { - return I[d >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + a) - } - } - var ib = {} - function jb() { - return 'object' === typeof globalThis - ? globalThis - : Function('return this')() - } - function kb(a, b) { - var c = R[a] - void 0 === c && T(b + ' has unknown type ' + eb(a)) - return c - } - var lb = {}, - mb = {} - function nb() { - if (!ob) { - var a = { - USER: 'web_user', - LOGNAME: 'web_user', - PATH: '/', - PWD: '/', - HOME: '/home/web_user', - LANG: - ( - ('object' === typeof navigator && - navigator.languages && - navigator.languages[0]) || - 'C' - ).replace('-', '_') + '.UTF-8', - _: ba || './this.program', - }, - b - for (b in mb) a[b] = mb[b] - var c = [] - for (b in a) c.push(b + '=' + a[b]) - ob = c - } - return ob - } - for (var ob, pb = [null, [], []], qb = Array(256), Y = 0; 256 > Y; ++Y) - qb[Y] = String.fromCharCode(Y) - Ja = qb - Na = e.BindingError = Ma('BindingError') - Oa = e.InternalError = Ma('InternalError') - e.count_emval_handles = function () { - for (var a = 0, b = 5; b < V.length; ++b) void 0 !== V[b] && ++a - return a - } - e.get_first_emval = function () { - for (var a = 5; a < V.length; ++a) if (void 0 !== V[a]) return V[a] - return null - } - db = e.UnboundTypeError = Ma('UnboundTypeError') - Aa.push({ - L: function () { - rb() - }, - }) - var tb = { - g: function () {}, - o: function (a, b, c, d, f) { - var g = Ia(c) - b = P(b) - U(a, { - name: b, - fromWireType: function (l) { - return !!l - }, - toWireType: function (l, h) { - return h ? d : f - }, - argPackAdvance: 8, - readValueFromPointer: function (l) { - if (1 === c) var h = G - else if (2 === c) h = D - else if (4 === c) h = E - else throw new TypeError('Unknown boolean type size: ' + b) - return this.fromWireType(h[l >> g]) - }, - H: null, - }) - }, - x: function (a, b) { - b = P(b) - U(a, { - name: b, - fromWireType: function (c) { - var d = V[c].value - Ra(c) - return d - }, - toWireType: function (c, d) { - return W(d) - }, - argPackAdvance: 8, - readValueFromPointer: Sa, - H: null, - }) - }, - n: function (a, b, c) { - c = Ia(c) - b = P(b) - U(a, { - name: b, - fromWireType: function (d) { - return d - }, - toWireType: function (d, f) { - if ('number' !== typeof f && 'boolean' !== typeof f) - throw new TypeError( - 'Cannot convert "' + Va(f) + '" to ' + this.name - ) - return f - }, - argPackAdvance: 8, - readValueFromPointer: Wa(b, c), - H: null, - }) - }, - q: function (a, b, c, d, f, g) { - var l = ab(b, c) - a = P(a) - f = cb(d, f) - $a( - a, - function () { - gb('Cannot call ' + a + ' due to unbound types', l) - }, - b - 1 - ) - Pa(l, function (h) { - var k = [h[0], null].concat(h.slice(1)), - m = (h = a), - n = f, - p = k.length - 2 > p && - T( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - for (var x = null !== k[1] && !1, B = !1, q = 1; q < k.length; ++q) - if (null !== k[q] && void 0 === k[q].H) { - B = !0 - break - } - var Ta = 'void' !== k[0].name, - H = '', - L = '' - for (q = 0; q < p - 2; ++q) - (H += (0 !== q ? ', ' : '') + 'arg' + q), - (L += (0 !== q ? ', ' : '') + 'arg' + q + 'Wired') - m = - 'return function ' + - Ka(m) + - '(' + - H + - ') {\nif (arguments.length !== ' + - (p - 2) + - ") {\nthrowBindingError('function " + - m + - " called with ' + arguments.length + ' arguments, expected " + - (p - 2) + - " args!');\n}\n" - B && (m += 'var destructors = [];\n') - var Ua = B ? 'destructors' : 'null' - H = 'throwBindingError invoker fn runDestructors retType classParam'.split( - ' ' - ) - n = [T, n, g, Ya, k[0], k[1]] - x && - (m += 'var thisWired = classParam.toWireType(' + Ua + ', this);\n') - for (q = 0; q < p - 2; ++q) - (m += - 'var arg' + - q + - 'Wired = argType' + - q + - '.toWireType(' + - Ua + - ', arg' + - q + - '); // ' + - k[q + 2].name + - '\n'), - H.push('argType' + q), - n.push(k[q + 2]) - x && (L = 'thisWired' + (0 < L.length ? ', ' : '') + L) - m += - (Ta ? 'var rv = ' : '') + - 'invoker(fn' + - (0 < L.length ? ', ' : '') + - L + - ');\n' - if (B) m += 'runDestructors(destructors);\n' - else - for (q = x ? 1 : 2; q < k.length; ++q) - (p = 1 === q ? 'thisWired' : 'arg' + (q - 2) + 'Wired'), - null !== k[q].H && - ((m += p + '_dtor(' + p + '); // ' + k[q].name + '\n'), - H.push(p + '_dtor'), - n.push(k[q].H)) - Ta && (m += 'var ret = retType.fromWireType(rv);\nreturn ret;\n') - H.push(m + '}\n') - k = Xa(H).apply(null, n) - q = b - 1 - if (!e.hasOwnProperty(h)) - throw new Oa('Replacing nonexistant public symbol') - void 0 !== e[h].G && void 0 !== q - ? (e[h].G[q] = k) - : ((e[h] = k), (e[h].K = q)) - return [] - }) - }, - c: function (a, b, c, d, f) { - function g(m) { - return m - } - b = P(b) - ;-1 === f && (f = 4294967295) - var l = Ia(c) - if (0 === d) { - var h = 32 - 8 * c - g = function (m) { - return (m << h) >>> h - } - } - var k = -1 != b.indexOf('unsigned') - U(a, { - name: b, - fromWireType: g, - toWireType: function (m, n) { - if ('number' !== typeof n && 'boolean' !== typeof n) - throw new TypeError( - 'Cannot convert "' + Va(n) + '" to ' + this.name - ) - if (n < d || n > f) - throw new TypeError( - 'Passing a number "' + - Va(n) + - '" from JS side to C/C++ side to an argument of type "' + - b + - '", which is outside the valid range [' + - d + - ', ' + - f + - ']!' - ) - return k ? n >>> 0 : n | 0 - }, - argPackAdvance: 8, - readValueFromPointer: hb(b, l, 0 !== d), - H: null, - }) - }, - b: function (a, b, c) { - function d(g) { - g >>= 2 - var l = I - return new f(F, l[g + 1], l[g]) - } - var f = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ][b] - c = P(c) - U( - a, - { - name: c, - fromWireType: d, - argPackAdvance: 8, - readValueFromPointer: d, - }, - { M: !0 } - ) - }, - i: function (a, b) { - b = P(b) - var c = 'std::string' === b - U(a, { - name: b, - fromWireType: function (d) { - var f = I[d >> 2] - if (c) - for (var g = d + 4, l = 0; l <= f; ++l) { - var h = d + 4 + l - if (l == f || 0 == A[h]) { - if (g) { - for (var k = g + (h - g), m = g; !(m >= k) && A[m]; ) ++m - g = ma.decode(A.subarray(g, m)) - } else g = '' - if (void 0 === n) var n = g - else (n += String.fromCharCode(0)), (n += g) - g = h + 1 - } - } - else { - n = Array(f) - for (l = 0; l < f; ++l) n[l] = String.fromCharCode(A[d + 4 + l]) - n = n.join('') - } - X(d) - return n - }, - toWireType: function (d, f) { - f instanceof ArrayBuffer && (f = new Uint8Array(f)) - var g = 'string' === typeof f - g || - f instanceof Uint8Array || - f instanceof Uint8ClampedArray || - f instanceof Int8Array || - T('Cannot pass non-string to std::string') - var l = (c && g - ? function () { - for (var m = 0, n = 0; n < f.length; ++n) { - var p = f.charCodeAt(n) - 55296 <= p && - 57343 >= p && - (p = - (65536 + ((p & 1023) << 10)) | - (f.charCodeAt(++n) & 1023)) - 127 >= p - ? ++m - : (m = 2047 >= p ? m + 2 : 65535 >= p ? m + 3 : m + 4) - } - return m - } - : function () { - return f.length - })(), - h = sb(4 + l + 1) - I[h >> 2] = l - if (c && g) na(f, h + 4, l + 1) - else if (g) - for (g = 0; g < l; ++g) { - var k = f.charCodeAt(g) - 255 < k && - (X(h), - T('String has UTF-16 code units that do not fit in 8 bits')) - A[h + 4 + g] = k - } - else for (g = 0; g < l; ++g) A[h + 4 + g] = f[g] - null !== d && d.push(X, h) - return h - }, - argPackAdvance: 8, - readValueFromPointer: Sa, - H: function (d) { - X(d) - }, - }) - }, - h: function (a, b, c) { - c = P(c) - if (2 === b) { - var d = pa - var f = qa - var g = ra - var l = function () { - return C - } - var h = 1 - } else - 4 === b && - ((d = sa), - (f = ta), - (g = ua), - (l = function () { - return I - }), - (h = 2)) - U(a, { - name: c, - fromWireType: function (k) { - for (var m = I[k >> 2], n = l(), p, x = k + 4, B = 0; B <= m; ++B) { - var q = k + 4 + B * b - if (B == m || 0 == n[q >> h]) - (x = d(x, q - x)), - void 0 === p - ? (p = x) - : ((p += String.fromCharCode(0)), (p += x)), - (x = q + b) - } - X(k) - return p - }, - toWireType: function (k, m) { - 'string' !== typeof m && - T('Cannot pass non-string to C++ string type ' + c) - var n = g(m), - p = sb(4 + n + b) - I[p >> 2] = n >> h - f(m, p + 4, n + b) - null !== k && k.push(X, p) - return p - }, - argPackAdvance: 8, - readValueFromPointer: Sa, - H: function (k) { - X(k) - }, - }) - }, - p: function (a, b) { - b = P(b) - U(a, { - N: !0, - name: b, - argPackAdvance: 0, - fromWireType: function () {}, - toWireType: function () {}, - }) - }, - e: Ra, - f: function (a) { - if (0 === a) return W(jb()) - var b = ib[a] - a = void 0 === b ? P(a) : b - return W(jb()[a]) - }, - j: function (a) { - 4 < a && (V[a].J += 1) - }, - k: function (a, b, c, d) { - a || T('Cannot use deleted val. handle = ' + a) - a = V[a].value - var f = lb[b] - if (!f) { - f = '' - for (var g = 0; g < b; ++g) f += (0 !== g ? ', ' : '') + 'arg' + g - var l = - 'return function emval_allocator_' + - b + - '(constructor, argTypes, args) {\n' - for (g = 0; g < b; ++g) - l += - 'var argType' + - g + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - g + - '], "parameter ' + - g + - '");\nvar arg' + - g + - ' = argType' + - g + - '.readValueFromPointer(args);\nargs += argType' + - g + - "['argPackAdvance'];\n" - f = new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - l + - ('var obj = new constructor(' + - f + - ');\nreturn __emval_register(obj);\n}\n') - )(kb, e, W) - lb[b] = f - } - return f(a, c, d) - }, - l: function () { - v() - }, - t: function (a, b, c) { - A.copyWithin(a, b, b + c) - }, - d: function (a) { - a >>>= 0 - var b = A.length - if (2147483648 < a) return !1 - for (var c = 1; 4 >= c; c *= 2) { - var d = b * (1 + 0.2 / c) - d = Math.min(d, a + 100663296) - d = Math.max(16777216, a, d) - 0 < d % 65536 && (d += 65536 - (d % 65536)) - a: { - try { - z.grow((Math.min(2147483648, d) - F.byteLength + 65535) >>> 16) - xa(z.buffer) - var f = 1 - break a - } catch (g) {} - f = void 0 - } - if (f) return !0 - } - return !1 - }, - u: function (a, b) { - var c = 0 - nb().forEach(function (d, f) { - var g = b + c - f = E[(a + 4 * f) >> 2] = g - for (g = 0; g < d.length; ++g) G[f++ >> 0] = d.charCodeAt(g) - G[f >> 0] = 0 - c += d.length + 1 - }) - return 0 - }, - v: function (a, b) { - var c = nb() - E[a >> 2] = c.length - var d = 0 - c.forEach(function (f) { - d += f.length + 1 - }) - E[b >> 2] = d - return 0 - }, - y: function (a) { - if (!noExitRuntime) { - if (e.onExit) e.onExit(a) - la = !0 - } - ca(a, new ja(a)) - }, - w: function () { - return 0 - }, - r: function () {}, - m: function (a, b, c, d) { - for (var f = 0, g = 0; g < c; g++) { - for ( - var l = E[(b + 8 * g) >> 2], h = E[(b + (8 * g + 4)) >> 2], k = 0; - k < h; - k++ - ) { - var m = A[l + k], - n = pb[a] - if (0 === m || 10 === m) { - m = 1 === a ? ka : w - var p - for (p = 0; n[p] && !(NaN <= p); ) ++p - p = ma.decode( - n.subarray ? n.subarray(0, p) : new Uint8Array(n.slice(0, p)) - ) - m(p) - n.length = 0 - } else n.push(m) - } - f += h - } - E[d >> 2] = f - return 0 - }, - a: z, - s: function () {}, - } - ;(function () { - function a(f) { - e.asm = f.exports - J = e.asm.z - K-- - e.monitorRunDependencies && e.monitorRunDependencies(K) - 0 == K && - (null !== Ea && (clearInterval(Ea), (Ea = null)), - M && ((f = M), (M = null), f())) - } - function b(f) { - a(f.instance) - } - function c(f) { - return Promise.resolve() - .then(Ha) - .then(function (g) { - return WebAssembly.instantiate(g, d) - }) - .then(f, function (g) { - w('failed to asynchronously prepare wasm: ' + g) - v(g) - }) - } - var d = { a: tb } - K++ - e.monitorRunDependencies && e.monitorRunDependencies(K) - if (e.instantiateWasm) - try { - return e.instantiateWasm(d, a) - } catch (f) { - return ( - w('Module.instantiateWasm callback failed with error: ' + f), !1 - ) - } - ;(function () { - return y || - 'function' !== typeof WebAssembly.instantiateStreaming || - Fa() || - 'function' !== typeof fetch - ? c(b) - : fetch(N, { credentials: 'same-origin' }).then(function (f) { - return WebAssembly.instantiateStreaming(f, d).then(b, function ( - g - ) { - w('wasm streaming compile failed: ' + g) - w('falling back to ArrayBuffer instantiation') - return c(b) - }) - }) - })().catch(r) - return {} - })() - var rb = (e.___wasm_call_ctors = function () { - return (rb = e.___wasm_call_ctors = e.asm.A).apply(null, arguments) - }), - sb = (e._malloc = function () { - return (sb = e._malloc = e.asm.B).apply(null, arguments) - }), - X = (e._free = function () { - return (X = e._free = e.asm.C).apply(null, arguments) - }), - fb = (e.___getTypeName = function () { - return (fb = e.___getTypeName = e.asm.D).apply(null, arguments) - }) - e.___embind_register_native_and_builtin_types = function () { - return (e.___embind_register_native_and_builtin_types = e.asm.E).apply( - null, - arguments - ) - } - e.dynCall_jiji = function () { - return (e.dynCall_jiji = e.asm.F).apply(null, arguments) - } - var Z - function ja(a) { - this.name = 'ExitStatus' - this.message = 'Program terminated with exit(' + a + ')' - this.status = a - } - M = function ub() { - Z || vb() - Z || (M = ub) - } - function vb() { - function a() { - if (!Z && ((Z = !0), (e.calledRun = !0), !la)) { - O(Aa) - O(Ba) - aa(e) - if (e.onRuntimeInitialized) e.onRuntimeInitialized() - if (e.postRun) - for ( - 'function' == typeof e.postRun && (e.postRun = [e.postRun]); - e.postRun.length; - - ) { - var b = e.postRun.shift() - Ca.unshift(b) - } - O(Ca) - } - } - if (!(0 < K)) { - if (e.preRun) - for ( - 'function' == typeof e.preRun && (e.preRun = [e.preRun]); - e.preRun.length; - - ) - Da() - O(za) - 0 < K || - (e.setStatus - ? (e.setStatus('Running...'), - setTimeout(function () { - setTimeout(function () { - e.setStatus('') - }, 1) - a() - }, 1)) - : a()) - } - } - e.run = vb - if (e.preInit) - for ( - 'function' == typeof e.preInit && (e.preInit = [e.preInit]); - 0 < e.preInit.length; - - ) - e.preInit.pop()() - noExitRuntime = !0 - vb() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm b/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm deleted file mode 100644 index 0f08ea8deea3a..0000000000000 Binary files a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm and /dev/null differ diff --git a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js b/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js deleted file mode 100644 index 5ce398d70e87a..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js +++ /dev/null @@ -1,1274 +0,0 @@ -/* eslint-disable */ -import { TextDecoder } from '../text-decoder' - -var Module = (function () { - // var _scriptDir = import.meta.url - - return function (Module) { - Module = Module || {} - - var f - f || (f = typeof Module !== 'undefined' ? Module : {}) - var aa, ba - f.ready = new Promise(function (a, b) { - aa = a - ba = b - }) - var r = {}, - t - for (t in f) f.hasOwnProperty(t) && (r[t] = f[t]) - var da = './this.program' - function ea(a, b) { - throw b - } - var fa = '', - ha, - ia, - ja, - ka - fa = __dirname + '/' - ha = function (a) { - ja || (ja = require('fs')) - ka || (ka = require('path')) - a = ka.normalize(a) - return ja.readFileSync(a, null) - } - ia = function (a) { - a = ha(a) - a.buffer || (a = new Uint8Array(a)) - a.buffer || u('Assertion failed: undefined') - return a - } - ea = function (a) { - process.exit(a) - } - f.inspect = function () { - return '[Emscripten Module object]' - } - var ma = f.print || console.log.bind(console), - v = f.printErr || console.warn.bind(console) - for (t in r) r.hasOwnProperty(t) && (f[t] = r[t]) - r = null - f.thisProgram && (da = f.thisProgram) - f.quit && (ea = f.quit) - var w - f.wasmBinary && (w = f.wasmBinary) - var noExitRuntime - f.noExitRuntime && (noExitRuntime = f.noExitRuntime) - 'object' !== typeof WebAssembly && u('no native wasm support detected') - var A, - na = !1, - oa = new TextDecoder('utf8') - function pa(a, b, c) { - var d = B - if (0 < c) { - c = b + c - 1 - for (var e = 0; e < a.length; ++e) { - var g = a.charCodeAt(e) - if (55296 <= g && 57343 >= g) { - var m = a.charCodeAt(++e) - g = (65536 + ((g & 1023) << 10)) | (m & 1023) - } - if (127 >= g) { - if (b >= c) break - d[b++] = g - } else { - if (2047 >= g) { - if (b + 1 >= c) break - d[b++] = 192 | (g >> 6) - } else { - if (65535 >= g) { - if (b + 2 >= c) break - d[b++] = 224 | (g >> 12) - } else { - if (b + 3 >= c) break - d[b++] = 240 | (g >> 18) - d[b++] = 128 | ((g >> 12) & 63) - } - d[b++] = 128 | ((g >> 6) & 63) - } - d[b++] = 128 | (g & 63) - } - } - d[b] = 0 - } - } - var qa = new TextDecoder('utf-16le') - function ra(a, b) { - var c = a >> 1 - for (b = c + b / 2; !(c >= b) && C[c]; ) ++c - return qa.decode(B.subarray(a, c << 1)) - } - function sa(a, b, c) { - void 0 === c && (c = 2147483647) - if (2 > c) return 0 - c -= 2 - var d = b - c = c < 2 * a.length ? c / 2 : a.length - for (var e = 0; e < c; ++e) (D[b >> 1] = a.charCodeAt(e)), (b += 2) - D[b >> 1] = 0 - return b - d - } - function ta(a) { - return 2 * a.length - } - function ua(a, b) { - for (var c = 0, d = ''; !(c >= b / 4); ) { - var e = F[(a + 4 * c) >> 2] - if (0 == e) break - ++c - 65536 <= e - ? ((e -= 65536), - (d += String.fromCharCode(55296 | (e >> 10), 56320 | (e & 1023)))) - : (d += String.fromCharCode(e)) - } - return d - } - function va(a, b, c) { - void 0 === c && (c = 2147483647) - if (4 > c) return 0 - var d = b - c = d + c - 4 - for (var e = 0; e < a.length; ++e) { - var g = a.charCodeAt(e) - if (55296 <= g && 57343 >= g) { - var m = a.charCodeAt(++e) - g = (65536 + ((g & 1023) << 10)) | (m & 1023) - } - F[b >> 2] = g - b += 4 - if (b + 4 > c) break - } - F[b >> 2] = 0 - return b - d - } - function wa(a) { - for (var b = 0, c = 0; c < a.length; ++c) { - var d = a.charCodeAt(c) - 55296 <= d && 57343 >= d && ++c - b += 4 - } - return b - } - var G, H, B, D, C, F, I, xa, ya - function za(a) { - G = a - f.HEAP8 = H = new Int8Array(a) - f.HEAP16 = D = new Int16Array(a) - f.HEAP32 = F = new Int32Array(a) - f.HEAPU8 = B = new Uint8Array(a) - f.HEAPU16 = C = new Uint16Array(a) - f.HEAPU32 = I = new Uint32Array(a) - f.HEAPF32 = xa = new Float32Array(a) - f.HEAPF64 = ya = new Float64Array(a) - } - var Aa = f.INITIAL_MEMORY || 16777216 - f.wasmMemory - ? (A = f.wasmMemory) - : (A = new WebAssembly.Memory({ initial: Aa / 65536, maximum: 32768 })) - A && (G = A.buffer) - Aa = G.byteLength - za(G) - var J, - Ba = [], - Ca = [], - Da = [], - Ea = [] - function Fa() { - var a = f.preRun.shift() - Ba.unshift(a) - } - var K = 0, - Ga = null, - L = null - f.preloadedImages = {} - f.preloadedAudios = {} - function u(a) { - if (f.onAbort) f.onAbort(a) - v(a) - na = !0 - a = new WebAssembly.RuntimeError( - 'abort(' + a + '). Build with -s ASSERTIONS=1 for more info.' - ) - ba(a) - throw a - } - function Ha() { - var a = M - return String.prototype.startsWith - ? a.startsWith('data:application/octet-stream;base64,') - : 0 === a.indexOf('data:application/octet-stream;base64,') - } - var M = 'mozjpeg_node_enc.wasm' - if (!Ha()) { - var Ia = M - M = f.locateFile ? f.locateFile(Ia, fa) : fa + Ia - } - function Ja() { - try { - if (w) return new Uint8Array(w) - if (ia) return ia(M) - throw 'both async and sync fetching of the wasm failed' - } catch (a) { - u(a) - } - } - function N(a) { - for (; 0 < a.length; ) { - var b = a.shift() - if ('function' == typeof b) b(f) - else { - var c = b.R - 'number' === typeof c - ? void 0 === b.L - ? J.get(c)() - : J.get(c)(b.L) - : c(void 0 === b.L ? null : b.L) - } - } - } - var O = {} - function Ka(a) { - for (; a.length; ) { - var b = a.pop() - a.pop()(b) - } - } - function P(a) { - return this.fromWireType(I[a >> 2]) - } - var Q = {}, - R = {}, - S = {} - function La(a) { - if (void 0 === a) return '_unknown' - a = a.replace(/[^a-zA-Z0-9_]/g, '$') - var b = a.charCodeAt(0) - return 48 <= b && 57 >= b ? '_' + a : a - } - function Ma(a, b) { - a = La(a) - return new Function( - 'body', - 'return function ' + - a + - '() {\n "use strict"; return body.apply(this, arguments);\n};\n' - )(b) - } - function Na(a) { - var b = Error, - c = Ma(a, function (d) { - this.name = a - this.message = d - d = Error(d).stack - void 0 !== d && - (this.stack = - this.toString() + '\n' + d.replace(/^Error(:[^\n]*)?\n/, '')) - }) - c.prototype = Object.create(b.prototype) - c.prototype.constructor = c - c.prototype.toString = function () { - return void 0 === this.message - ? this.name - : this.name + ': ' + this.message - } - return c - } - var Oa = void 0 - function Pa(a, b, c) { - function d(h) { - h = c(h) - if (h.length !== a.length) - throw new Oa('Mismatched type converter count') - for (var k = 0; k < a.length; ++k) U(a[k], h[k]) - } - a.forEach(function (h) { - S[h] = b - }) - var e = Array(b.length), - g = [], - m = 0 - b.forEach(function (h, k) { - R.hasOwnProperty(h) - ? (e[k] = R[h]) - : (g.push(h), - Q.hasOwnProperty(h) || (Q[h] = []), - Q[h].push(function () { - e[k] = R[h] - ++m - m === g.length && d(e) - })) - }) - 0 === g.length && d(e) - } - function Qa(a) { - switch (a) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + a) - } - } - var Ra = void 0 - function V(a) { - for (var b = ''; B[a]; ) b += Ra[B[a++]] - return b - } - var Sa = void 0 - function W(a) { - throw new Sa(a) - } - function U(a, b, c) { - c = c || {} - if (!('argPackAdvance' in b)) - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - var d = b.name - a || W('type "' + d + '" must have a positive integer typeid pointer') - if (R.hasOwnProperty(a)) { - if (c.V) return - W("Cannot register type '" + d + "' twice") - } - R[a] = b - delete S[a] - Q.hasOwnProperty(a) && - ((b = Q[a]), - delete Q[a], - b.forEach(function (e) { - e() - })) - } - var Ta = [], - X = [{}, { value: void 0 }, { value: null }, { value: !0 }, { value: !1 }] - function Ua(a) { - 4 < a && 0 === --X[a].M && ((X[a] = void 0), Ta.push(a)) - } - function Va(a) { - switch (a) { - case void 0: - return 1 - case null: - return 2 - case !0: - return 3 - case !1: - return 4 - default: - var b = Ta.length ? Ta.pop() : X.length - X[b] = { M: 1, value: a } - return b - } - } - function Wa(a) { - if (null === a) return 'null' - var b = typeof a - return 'object' === b || 'array' === b || 'function' === b - ? a.toString() - : '' + a - } - function Xa(a, b) { - switch (b) { - case 2: - return function (c) { - return this.fromWireType(xa[c >> 2]) - } - case 3: - return function (c) { - return this.fromWireType(ya[c >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + a) - } - } - function Ya(a) { - var b = Function - if (!(b instanceof Function)) - throw new TypeError( - 'new_ called with constructor type ' + - typeof b + - ' which is not a function' - ) - var c = Ma(b.name || 'unknownFunctionName', function () {}) - c.prototype = b.prototype - c = new c() - a = b.apply(c, a) - return a instanceof Object ? a : c - } - function Za(a, b) { - var c = f - if (void 0 === c[a].J) { - var d = c[a] - c[a] = function () { - c[a].J.hasOwnProperty(arguments.length) || - W( - "Function '" + - b + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - c[a].J + - ')!' - ) - return c[a].J[arguments.length].apply(this, arguments) - } - c[a].J = [] - c[a].J[d.O] = d - } - } - function $a(a, b, c) { - f.hasOwnProperty(a) - ? ((void 0 === c || (void 0 !== f[a].J && void 0 !== f[a].J[c])) && - W("Cannot register public name '" + a + "' twice"), - Za(a, a), - f.hasOwnProperty(c) && - W( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - c + - ')!' - ), - (f[a].J[c] = b)) - : ((f[a] = b), void 0 !== c && (f[a].ba = c)) - } - function ab(a, b) { - for (var c = [], d = 0; d < a; d++) c.push(F[(b >> 2) + d]) - return c - } - function bb(a, b) { - 0 <= a.indexOf('j') || - u('Assertion failed: getDynCaller should only be called with i64 sigs') - var c = [] - return function () { - c.length = arguments.length - for (var d = 0; d < arguments.length; d++) c[d] = arguments[d] - var e - ;-1 != a.indexOf('j') - ? (e = - c && c.length - ? f['dynCall_' + a].apply(null, [b].concat(c)) - : f['dynCall_' + a].call(null, b)) - : (e = J.get(b).apply(null, c)) - return e - } - } - function Y(a, b) { - a = V(a) - var c = -1 != a.indexOf('j') ? bb(a, b) : J.get(b) - 'function' !== typeof c && - W('unknown function pointer with signature ' + a + ': ' + b) - return c - } - var cb = void 0 - function db(a) { - a = eb(a) - var b = V(a) - Z(a) - return b - } - function fb(a, b) { - function c(g) { - e[g] || R[g] || (S[g] ? S[g].forEach(c) : (d.push(g), (e[g] = !0))) - } - var d = [], - e = {} - b.forEach(c) - throw new cb(a + ': ' + d.map(db).join([', '])) - } - function gb(a, b, c) { - switch (b) { - case 0: - return c - ? function (d) { - return H[d] - } - : function (d) { - return B[d] - } - case 1: - return c - ? function (d) { - return D[d >> 1] - } - : function (d) { - return C[d >> 1] - } - case 2: - return c - ? function (d) { - return F[d >> 2] - } - : function (d) { - return I[d >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + a) - } - } - var hb = {} - function ib() { - return 'object' === typeof globalThis - ? globalThis - : Function('return this')() - } - function jb(a, b) { - var c = R[a] - void 0 === c && W(b + ' has unknown type ' + db(a)) - return c - } - var kb = {}, - lb = {} - function mb() { - if (!nb) { - var a = { - USER: 'web_user', - LOGNAME: 'web_user', - PATH: '/', - PWD: '/', - HOME: '/home/web_user', - LANG: - ( - ('object' === typeof navigator && - navigator.languages && - navigator.languages[0]) || - 'C' - ).replace('-', '_') + '.UTF-8', - _: da || './this.program', - }, - b - for (b in lb) a[b] = lb[b] - var c = [] - for (b in a) c.push(b + '=' + a[b]) - nb = c - } - return nb - } - var nb, - ob = [null, [], []] - Oa = f.InternalError = Na('InternalError') - for (var pb = Array(256), qb = 0; 256 > qb; ++qb) - pb[qb] = String.fromCharCode(qb) - Ra = pb - Sa = f.BindingError = Na('BindingError') - f.count_emval_handles = function () { - for (var a = 0, b = 5; b < X.length; ++b) void 0 !== X[b] && ++a - return a - } - f.get_first_emval = function () { - for (var a = 5; a < X.length; ++a) if (void 0 !== X[a]) return X[a] - return null - } - cb = f.UnboundTypeError = Na('UnboundTypeError') - Ca.push({ - R: function () { - rb() - }, - }) - var tb = { - B: function () {}, - n: function (a) { - var b = O[a] - delete O[a] - var c = b.W, - d = b.X, - e = b.N, - g = e - .map(function (m) { - return m.U - }) - .concat( - e.map(function (m) { - return m.Z - }) - ) - Pa([a], g, function (m) { - var h = {} - e.forEach(function (k, n) { - var l = m[n], - p = k.S, - x = k.T, - y = m[n + e.length], - q = k.Y, - ca = k.$ - h[k.P] = { - read: function (z) { - return l.fromWireType(p(x, z)) - }, - write: function (z, E) { - var T = [] - q(ca, z, y.toWireType(T, E)) - Ka(T) - }, - } - }) - return [ - { - name: b.name, - fromWireType: function (k) { - var n = {}, - l - for (l in h) n[l] = h[l].read(k) - d(k) - return n - }, - toWireType: function (k, n) { - for (var l in h) - if (!(l in n)) - throw new TypeError('Missing field: "' + l + '"') - var p = c() - for (l in h) h[l].write(p, n[l]) - null !== k && k.push(d, p) - return p - }, - argPackAdvance: 8, - readValueFromPointer: P, - K: d, - }, - ] - }) - }, - y: function (a, b, c, d, e) { - var g = Qa(c) - b = V(b) - U(a, { - name: b, - fromWireType: function (m) { - return !!m - }, - toWireType: function (m, h) { - return h ? d : e - }, - argPackAdvance: 8, - readValueFromPointer: function (m) { - if (1 === c) var h = H - else if (2 === c) h = D - else if (4 === c) h = F - else throw new TypeError('Unknown boolean type size: ' + b) - return this.fromWireType(h[m >> g]) - }, - K: null, - }) - }, - x: function (a, b) { - b = V(b) - U(a, { - name: b, - fromWireType: function (c) { - var d = X[c].value - Ua(c) - return d - }, - toWireType: function (c, d) { - return Va(d) - }, - argPackAdvance: 8, - readValueFromPointer: P, - K: null, - }) - }, - k: function (a, b, c) { - c = Qa(c) - b = V(b) - U(a, { - name: b, - fromWireType: function (d) { - return d - }, - toWireType: function (d, e) { - if ('number' !== typeof e && 'boolean' !== typeof e) - throw new TypeError( - 'Cannot convert "' + Wa(e) + '" to ' + this.name - ) - return e - }, - argPackAdvance: 8, - readValueFromPointer: Xa(b, c), - K: null, - }) - }, - g: function (a, b, c, d, e, g) { - var m = ab(b, c) - a = V(a) - e = Y(d, e) - $a( - a, - function () { - fb('Cannot call ' + a + ' due to unbound types', m) - }, - b - 1 - ) - Pa([], m, function (h) { - var k = [h[0], null].concat(h.slice(1)), - n = (h = a), - l = e, - p = k.length - 2 > p && - W( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - for (var x = null !== k[1] && !1, y = !1, q = 1; q < k.length; ++q) - if (null !== k[q] && void 0 === k[q].K) { - y = !0 - break - } - var ca = 'void' !== k[0].name, - z = '', - E = '' - for (q = 0; q < p - 2; ++q) - (z += (0 !== q ? ', ' : '') + 'arg' + q), - (E += (0 !== q ? ', ' : '') + 'arg' + q + 'Wired') - n = - 'return function ' + - La(n) + - '(' + - z + - ') {\nif (arguments.length !== ' + - (p - 2) + - ") {\nthrowBindingError('function " + - n + - " called with ' + arguments.length + ' arguments, expected " + - (p - 2) + - " args!');\n}\n" - y && (n += 'var destructors = [];\n') - var T = y ? 'destructors' : 'null' - z = 'throwBindingError invoker fn runDestructors retType classParam'.split( - ' ' - ) - l = [W, l, g, Ka, k[0], k[1]] - x && - (n += 'var thisWired = classParam.toWireType(' + T + ', this);\n') - for (q = 0; q < p - 2; ++q) - (n += - 'var arg' + - q + - 'Wired = argType' + - q + - '.toWireType(' + - T + - ', arg' + - q + - '); // ' + - k[q + 2].name + - '\n'), - z.push('argType' + q), - l.push(k[q + 2]) - x && (E = 'thisWired' + (0 < E.length ? ', ' : '') + E) - n += - (ca ? 'var rv = ' : '') + - 'invoker(fn' + - (0 < E.length ? ', ' : '') + - E + - ');\n' - if (y) n += 'runDestructors(destructors);\n' - else - for (q = x ? 1 : 2; q < k.length; ++q) - (p = 1 === q ? 'thisWired' : 'arg' + (q - 2) + 'Wired'), - null !== k[q].K && - ((n += p + '_dtor(' + p + '); // ' + k[q].name + '\n'), - z.push(p + '_dtor'), - l.push(k[q].K)) - ca && (n += 'var ret = retType.fromWireType(rv);\nreturn ret;\n') - z.push(n + '}\n') - k = Ya(z).apply(null, l) - q = b - 1 - if (!f.hasOwnProperty(h)) - throw new Oa('Replacing nonexistant public symbol') - void 0 !== f[h].J && void 0 !== q - ? (f[h].J[q] = k) - : ((f[h] = k), (f[h].O = q)) - return [] - }) - }, - d: function (a, b, c, d, e) { - function g(n) { - return n - } - b = V(b) - ;-1 === e && (e = 4294967295) - var m = Qa(c) - if (0 === d) { - var h = 32 - 8 * c - g = function (n) { - return (n << h) >>> h - } - } - var k = -1 != b.indexOf('unsigned') - U(a, { - name: b, - fromWireType: g, - toWireType: function (n, l) { - if ('number' !== typeof l && 'boolean' !== typeof l) - throw new TypeError( - 'Cannot convert "' + Wa(l) + '" to ' + this.name - ) - if (l < d || l > e) - throw new TypeError( - 'Passing a number "' + - Wa(l) + - '" from JS side to C/C++ side to an argument of type "' + - b + - '", which is outside the valid range [' + - d + - ', ' + - e + - ']!' - ) - return k ? l >>> 0 : l | 0 - }, - argPackAdvance: 8, - readValueFromPointer: gb(b, m, 0 !== d), - K: null, - }) - }, - c: function (a, b, c) { - function d(g) { - g >>= 2 - var m = I - return new e(G, m[g + 1], m[g]) - } - var e = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ][b] - c = V(c) - U( - a, - { - name: c, - fromWireType: d, - argPackAdvance: 8, - readValueFromPointer: d, - }, - { V: !0 } - ) - }, - l: function (a, b) { - b = V(b) - var c = 'std::string' === b - U(a, { - name: b, - fromWireType: function (d) { - var e = I[d >> 2] - if (c) - for (var g = d + 4, m = 0; m <= e; ++m) { - var h = d + 4 + m - if (m == e || 0 == B[h]) { - if (g) { - for (var k = g + (h - g), n = g; !(n >= k) && B[n]; ) ++n - g = oa.decode(B.subarray(g, n)) - } else g = '' - if (void 0 === l) var l = g - else (l += String.fromCharCode(0)), (l += g) - g = h + 1 - } - } - else { - l = Array(e) - for (m = 0; m < e; ++m) l[m] = String.fromCharCode(B[d + 4 + m]) - l = l.join('') - } - Z(d) - return l - }, - toWireType: function (d, e) { - e instanceof ArrayBuffer && (e = new Uint8Array(e)) - var g = 'string' === typeof e - g || - e instanceof Uint8Array || - e instanceof Uint8ClampedArray || - e instanceof Int8Array || - W('Cannot pass non-string to std::string') - var m = (c && g - ? function () { - for (var n = 0, l = 0; l < e.length; ++l) { - var p = e.charCodeAt(l) - 55296 <= p && - 57343 >= p && - (p = - (65536 + ((p & 1023) << 10)) | - (e.charCodeAt(++l) & 1023)) - 127 >= p - ? ++n - : (n = 2047 >= p ? n + 2 : 65535 >= p ? n + 3 : n + 4) - } - return n - } - : function () { - return e.length - })(), - h = sb(4 + m + 1) - I[h >> 2] = m - if (c && g) pa(e, h + 4, m + 1) - else if (g) - for (g = 0; g < m; ++g) { - var k = e.charCodeAt(g) - 255 < k && - (Z(h), - W('String has UTF-16 code units that do not fit in 8 bits')) - B[h + 4 + g] = k - } - else for (g = 0; g < m; ++g) B[h + 4 + g] = e[g] - null !== d && d.push(Z, h) - return h - }, - argPackAdvance: 8, - readValueFromPointer: P, - K: function (d) { - Z(d) - }, - }) - }, - f: function (a, b, c) { - c = V(c) - if (2 === b) { - var d = ra - var e = sa - var g = ta - var m = function () { - return C - } - var h = 1 - } else - 4 === b && - ((d = ua), - (e = va), - (g = wa), - (m = function () { - return I - }), - (h = 2)) - U(a, { - name: c, - fromWireType: function (k) { - for (var n = I[k >> 2], l = m(), p, x = k + 4, y = 0; y <= n; ++y) { - var q = k + 4 + y * b - if (y == n || 0 == l[q >> h]) - (x = d(x, q - x)), - void 0 === p - ? (p = x) - : ((p += String.fromCharCode(0)), (p += x)), - (x = q + b) - } - Z(k) - return p - }, - toWireType: function (k, n) { - 'string' !== typeof n && - W('Cannot pass non-string to C++ string type ' + c) - var l = g(n), - p = sb(4 + l + b) - I[p >> 2] = l >> h - e(n, p + 4, l + b) - null !== k && k.push(Z, p) - return p - }, - argPackAdvance: 8, - readValueFromPointer: P, - K: function (k) { - Z(k) - }, - }) - }, - o: function (a, b, c, d, e, g) { - O[a] = { name: V(b), W: Y(c, d), X: Y(e, g), N: [] } - }, - b: function (a, b, c, d, e, g, m, h, k, n) { - O[a].N.push({ P: V(b), U: c, S: Y(d, e), T: g, Z: m, Y: Y(h, k), $: n }) - }, - z: function (a, b) { - b = V(b) - U(a, { - aa: !0, - name: b, - argPackAdvance: 0, - fromWireType: function () {}, - toWireType: function () {}, - }) - }, - h: Ua, - v: function (a) { - if (0 === a) return Va(ib()) - var b = hb[a] - a = void 0 === b ? V(a) : b - return Va(ib()[a]) - }, - m: function (a) { - 4 < a && (X[a].M += 1) - }, - p: function (a, b, c, d) { - a || W('Cannot use deleted val. handle = ' + a) - a = X[a].value - var e = kb[b] - if (!e) { - e = '' - for (var g = 0; g < b; ++g) e += (0 !== g ? ', ' : '') + 'arg' + g - var m = - 'return function emval_allocator_' + - b + - '(constructor, argTypes, args) {\n' - for (g = 0; g < b; ++g) - m += - 'var argType' + - g + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - g + - '], "parameter ' + - g + - '");\nvar arg' + - g + - ' = argType' + - g + - '.readValueFromPointer(args);\nargs += argType' + - g + - "['argPackAdvance'];\n" - e = new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - m + - ('var obj = new constructor(' + - e + - ');\nreturn __emval_register(obj);\n}\n') - )(jb, f, Va) - kb[b] = e - } - return e(a, c, d) - }, - i: function () { - u() - }, - s: function (a, b, c) { - B.copyWithin(a, b, b + c) - }, - e: function (a) { - a >>>= 0 - var b = B.length - if (2147483648 < a) return !1 - for (var c = 1; 4 >= c; c *= 2) { - var d = b * (1 + 0.2 / c) - d = Math.min(d, a + 100663296) - d = Math.max(16777216, a, d) - 0 < d % 65536 && (d += 65536 - (d % 65536)) - a: { - try { - A.grow((Math.min(2147483648, d) - G.byteLength + 65535) >>> 16) - za(A.buffer) - var e = 1 - break a - } catch (g) {} - e = void 0 - } - if (e) return !0 - } - return !1 - }, - t: function (a, b) { - var c = 0 - mb().forEach(function (d, e) { - var g = b + c - e = F[(a + 4 * e) >> 2] = g - for (g = 0; g < d.length; ++g) H[e++ >> 0] = d.charCodeAt(g) - H[e >> 0] = 0 - c += d.length + 1 - }) - return 0 - }, - u: function (a, b) { - var c = mb() - F[a >> 2] = c.length - var d = 0 - c.forEach(function (e) { - d += e.length + 1 - }) - F[b >> 2] = d - return 0 - }, - A: function (a) { - if (!noExitRuntime) { - if (f.onExit) f.onExit(a) - na = !0 - } - ea(a, new la(a)) - }, - w: function () { - return 0 - }, - q: function () {}, - j: function (a, b, c, d) { - for (var e = 0, g = 0; g < c; g++) { - for ( - var m = F[(b + 8 * g) >> 2], h = F[(b + (8 * g + 4)) >> 2], k = 0; - k < h; - k++ - ) { - var n = B[m + k], - l = ob[a] - if (0 === n || 10 === n) { - n = 1 === a ? ma : v - var p - for (p = 0; l[p] && !(NaN <= p); ) ++p - p = oa.decode( - l.subarray ? l.subarray(0, p) : new Uint8Array(l.slice(0, p)) - ) - n(p) - l.length = 0 - } else l.push(n) - } - e += h - } - F[d >> 2] = e - return 0 - }, - a: A, - r: function () {}, - } - ;(function () { - function a(e) { - f.asm = e.exports - J = f.asm.C - K-- - f.monitorRunDependencies && f.monitorRunDependencies(K) - 0 == K && - (null !== Ga && (clearInterval(Ga), (Ga = null)), - L && ((e = L), (L = null), e())) - } - function b(e) { - a(e.instance) - } - function c(e) { - return Promise.resolve() - .then(Ja) - .then(function (g) { - return WebAssembly.instantiate(g, d) - }) - .then(e, function (g) { - v('failed to asynchronously prepare wasm: ' + g) - u(g) - }) - } - var d = { a: tb } - K++ - f.monitorRunDependencies && f.monitorRunDependencies(K) - if (f.instantiateWasm) - try { - return f.instantiateWasm(d, a) - } catch (e) { - return ( - v('Module.instantiateWasm callback failed with error: ' + e), !1 - ) - } - ;(function () { - return w || - 'function' !== typeof WebAssembly.instantiateStreaming || - Ha() || - 'function' !== typeof fetch - ? c(b) - : fetch(M, { credentials: 'same-origin' }).then(function (e) { - return WebAssembly.instantiateStreaming(e, d).then(b, function ( - g - ) { - v('wasm streaming compile failed: ' + g) - v('falling back to ArrayBuffer instantiation') - return c(b) - }) - }) - })().catch(ba) - return {} - })() - var rb = (f.___wasm_call_ctors = function () { - return (rb = f.___wasm_call_ctors = f.asm.D).apply(null, arguments) - }), - sb = (f._malloc = function () { - return (sb = f._malloc = f.asm.E).apply(null, arguments) - }), - Z = (f._free = function () { - return (Z = f._free = f.asm.F).apply(null, arguments) - }), - eb = (f.___getTypeName = function () { - return (eb = f.___getTypeName = f.asm.G).apply(null, arguments) - }) - f.___embind_register_native_and_builtin_types = function () { - return (f.___embind_register_native_and_builtin_types = f.asm.H).apply( - null, - arguments - ) - } - f.dynCall_jiji = function () { - return (f.dynCall_jiji = f.asm.I).apply(null, arguments) - } - var ub - function la(a) { - this.name = 'ExitStatus' - this.message = 'Program terminated with exit(' + a + ')' - this.status = a - } - L = function vb() { - ub || wb() - ub || (L = vb) - } - function wb() { - function a() { - if (!ub && ((ub = !0), (f.calledRun = !0), !na)) { - N(Ca) - N(Da) - aa(f) - if (f.onRuntimeInitialized) f.onRuntimeInitialized() - if (f.postRun) - for ( - 'function' == typeof f.postRun && (f.postRun = [f.postRun]); - f.postRun.length; - - ) { - var b = f.postRun.shift() - Ea.unshift(b) - } - N(Ea) - } - } - if (!(0 < K)) { - if (f.preRun) - for ( - 'function' == typeof f.preRun && (f.preRun = [f.preRun]); - f.preRun.length; - - ) - Fa() - N(Ba) - 0 < K || - (f.setStatus - ? (f.setStatus('Running...'), - setTimeout(function () { - setTimeout(function () { - f.setStatus('') - }, 1) - a() - }, 1)) - : a()) - } - } - f.run = wb - if (f.preInit) - for ( - 'function' == typeof f.preInit && (f.preInit = [f.preInit]); - 0 < f.preInit.length; - - ) - f.preInit.pop()() - noExitRuntime = !0 - wb() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm b/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm deleted file mode 100644 index 6dc8b5b6f0fb0..0000000000000 Binary files a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm and /dev/null differ diff --git a/packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng.js b/packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng.js deleted file mode 100644 index f2d8ccb9c99e9..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng.js +++ /dev/null @@ -1,136 +0,0 @@ -import { TextDecoder } from '../text-decoder' - -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) -} -/** - * @param {Uint8Array} data - * @param {number} level - * @returns {Uint8Array} - */ -export function optimise(data, level) { - try { - const retptr = wasm.__wbindgen_export_0.value - 16 - wasm.__wbindgen_export_0.value = retptr - var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc) - var len0 = WASM_VECTOR_LEN - wasm.optimise(retptr, ptr0, len0, level) - var r0 = getInt32Memory0()[retptr / 4 + 0] - var r1 = getInt32Memory0()[retptr / 4 + 1] - var v1 = getArrayU8FromWasm0(r0, r1).slice() - wasm.__wbindgen_free(r0, r1 * 1) - return v1 - } finally { - wasm.__wbindgen_export_0.value += 16 - } -} - -async function load(module, imports) { - if (typeof Response === 'function' && module instanceof Response) { - if (typeof WebAssembly.instantiateStreaming === 'function') { - try { - return await WebAssembly.instantiateStreaming(module, imports) - } catch (e) { - if (module.headers.get('Content-Type') !== 'application/wasm') { - console.warn( - '`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n', - e - ) - } else { - throw e - } - } - } - - 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) { - if (typeof input === 'undefined') { - // input = import.meta.url.replace(/\.js$/, '_bg.wasm') - throw new Error('invariant') - } - 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 -} - -export default init - -// Manually remove the wasm and memory references to trigger GC -export function cleanup() { - wasm = null - cachegetUint8Memory0 = null - cachegetInt32Memory0 = null -} diff --git a/packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng_bg.wasm b/packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng_bg.wasm deleted file mode 100644 index 97715f1ad9b9c..0000000000000 Binary files a/packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng_bg.wasm and /dev/null differ diff --git a/packages/next/next-server/server/lib/squoosh/png/squoosh_png.js b/packages/next/next-server/server/lib/squoosh/png/squoosh_png.js deleted file mode 100644 index 300c68daf6309..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/png/squoosh_png.js +++ /dev/null @@ -1,204 +0,0 @@ -import { TextDecoder } from '../text-decoder' - -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(undefined) - -heap.push(undefined, 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) -} -/** - * @param {Uint8Array} data - * @param {number} width - * @param {number} height - * @returns {Uint8Array} - */ -export function encode(data, width, height) { - try { - const retptr = wasm.__wbindgen_export_1.value - 16 - wasm.__wbindgen_export_1.value = retptr - var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc) - var len0 = WASM_VECTOR_LEN - wasm.encode(retptr, ptr0, len0, width, height) - var r0 = getInt32Memory0()[retptr / 4 + 0] - var r1 = getInt32Memory0()[retptr / 4 + 1] - var v1 = getArrayU8FromWasm0(r0, r1).slice() - wasm.__wbindgen_free(r0, r1 * 1) - return v1 - } finally { - wasm.__wbindgen_export_1.value += 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 -} -/** - * @param {Uint8Array} data - * @returns {ImageData} - */ -export function decode(data) { - var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc) - var len0 = WASM_VECTOR_LEN - var 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') { - try { - return await WebAssembly.instantiateStreaming(module, imports) - } catch (e) { - if (module.headers.get('Content-Type') !== 'application/wasm') { - console.warn( - '`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n', - e - ) - } else { - throw e - } - } - } - - 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) { - if (typeof input === 'undefined') { - // input = import.meta.url.replace(/\.js$/, '_bg.wasm') - throw new Error('invariant') - } - const imports = {} - imports.wbg = {} - imports.wbg.__wbg_newwithownedu8clampedarrayandsh_787b2db8ea6bfd62 = function ( - arg0, - arg1, - arg2, - arg3 - ) { - var v0 = getClampedArrayU8FromWasm0(arg0, arg1).slice() - wasm.__wbindgen_free(arg0, arg1 * 1) - var 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 -} - -export default init - -// Manually remove the wasm and memory references to trigger GC -export function cleanup() { - wasm = null - cachegetUint8ClampedMemory0 = null - cachegetUint8Memory0 = null - cachegetInt32Memory0 = null -} diff --git a/packages/next/next-server/server/lib/squoosh/png/squoosh_png_bg.wasm b/packages/next/next-server/server/lib/squoosh/png/squoosh_png_bg.wasm deleted file mode 100644 index ef074fafe8b10..0000000000000 Binary files a/packages/next/next-server/server/lib/squoosh/png/squoosh_png_bg.wasm and /dev/null differ diff --git a/packages/next/next-server/server/lib/squoosh/resize/squoosh_resize.js b/packages/next/next-server/server/lib/squoosh/resize/squoosh_resize.js deleted file mode 100644 index f9553f3bd6b5a..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/resize/squoosh_resize.js +++ /dev/null @@ -1,139 +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 -} - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len) -} -/** - * @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 {Uint8Array} - */ -export function resize( - input_image, - input_width, - input_height, - output_width, - output_height, - typ_idx, - premultiply, - color_space_conversion -) { - var ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc) - var len0 = WASM_VECTOR_LEN - wasm.resize( - 8, - ptr0, - len0, - input_width, - input_height, - output_width, - output_height, - typ_idx, - premultiply, - color_space_conversion - ) - var r0 = getInt32Memory0()[8 / 4 + 0] - var r1 = getInt32Memory0()[8 / 4 + 1] - var v1 = getArrayU8FromWasm0(r0, r1).slice() - wasm.__wbindgen_free(r0, r1 * 1) - return v1 -} - -async function load(module, imports) { - if (typeof Response === 'function' && module instanceof Response) { - if (typeof WebAssembly.instantiateStreaming === 'function') { - try { - return await WebAssembly.instantiateStreaming(module, imports) - } catch (e) { - if (module.headers.get('Content-Type') !== 'application/wasm') { - console.warn( - '`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n', - e - ) - } else { - throw e - } - } - } - - 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) { - if (typeof input === 'undefined') { - // input = import.meta.url.replace(/\.js$/, '_bg.wasm') - throw new Error('invariant') - } - 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 -} - -export default init - -// Manually remove the wasm and memory references to trigger GC -export function cleanup() { - wasm = null - cachegetUint8Memory0 = null - cachegetInt32Memory0 = null -} diff --git a/packages/next/next-server/server/lib/squoosh/resize/squoosh_resize_bg.wasm b/packages/next/next-server/server/lib/squoosh/resize/squoosh_resize_bg.wasm deleted file mode 100644 index 0a10cca382dcc..0000000000000 Binary files a/packages/next/next-server/server/lib/squoosh/resize/squoosh_resize_bg.wasm and /dev/null differ diff --git a/packages/next/next-server/server/lib/squoosh/rotate/rotate.wasm b/packages/next/next-server/server/lib/squoosh/rotate/rotate.wasm deleted file mode 100644 index 8c7122c9f8b7e..0000000000000 Binary files a/packages/next/next-server/server/lib/squoosh/rotate/rotate.wasm and /dev/null differ diff --git a/packages/next/next-server/server/lib/squoosh/text-decoder.ts b/packages/next/next-server/server/lib/squoosh/text-decoder.ts deleted file mode 100644 index 397791f66e582..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/text-decoder.ts +++ /dev/null @@ -1,4 +0,0 @@ -const textDecoder = - typeof TextDecoder !== 'undefined' ? TextDecoder : require('util').TextDecoder - -export { textDecoder as TextDecoder } diff --git a/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.js b/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.js deleted file mode 100644 index ba9858be369bc..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.js +++ /dev/null @@ -1,1103 +0,0 @@ -/* eslint-disable */ -import { TextDecoder } from '../text-decoder' - -var Module = (function () { - // var _scriptDir = import.meta.url - - return function (Module) { - Module = Module || {} - - var e - e || (e = typeof Module !== 'undefined' ? Module : {}) - var aa, r - e.ready = new Promise(function (a, b) { - aa = a - r = b - }) - var t = {}, - u - for (u in e) e.hasOwnProperty(u) && (t[u] = e[u]) - var v = '', - ba, - ca, - da, - ea - v = __dirname + '/' - ba = function (a) { - da || (da = require('fs')) - ea || (ea = require('path')) - a = ea.normalize(a) - return da.readFileSync(a, null) - } - ca = function (a) { - a = ba(a) - a.buffer || (a = new Uint8Array(a)) - a.buffer || x('Assertion failed: undefined') - return a - } - e.inspect = function () { - return '[Emscripten Module object]' - } - e.print || console.log.bind(console) - var y = e.printErr || console.warn.bind(console) - for (u in t) t.hasOwnProperty(u) && (e[u] = t[u]) - t = null - var z - e.wasmBinary && (z = e.wasmBinary) - var noExitRuntime - e.noExitRuntime && (noExitRuntime = e.noExitRuntime) - 'object' !== typeof WebAssembly && x('no native wasm support detected') - var B, - fa = !1, - ha = new TextDecoder('utf8') - function ia(a, b, c) { - var d = C - if (0 < c) { - c = b + c - 1 - for (var f = 0; f < a.length; ++f) { - var g = a.charCodeAt(f) - if (55296 <= g && 57343 >= g) { - var l = a.charCodeAt(++f) - g = (65536 + ((g & 1023) << 10)) | (l & 1023) - } - if (127 >= g) { - if (b >= c) break - d[b++] = g - } else { - if (2047 >= g) { - if (b + 1 >= c) break - d[b++] = 192 | (g >> 6) - } else { - if (65535 >= g) { - if (b + 2 >= c) break - d[b++] = 224 | (g >> 12) - } else { - if (b + 3 >= c) break - d[b++] = 240 | (g >> 18) - d[b++] = 128 | ((g >> 12) & 63) - } - d[b++] = 128 | ((g >> 6) & 63) - } - d[b++] = 128 | (g & 63) - } - } - d[b] = 0 - } - } - var ja = new TextDecoder('utf-16le') - function ka(a, b) { - var c = a >> 1 - for (b = c + b / 2; !(c >= b) && D[c]; ) ++c - return ja.decode(C.subarray(a, c << 1)) - } - function la(a, b, c) { - void 0 === c && (c = 2147483647) - if (2 > c) return 0 - c -= 2 - var d = b - c = c < 2 * a.length ? c / 2 : a.length - for (var f = 0; f < c; ++f) (E[b >> 1] = a.charCodeAt(f)), (b += 2) - E[b >> 1] = 0 - return b - d - } - function ma(a) { - return 2 * a.length - } - function na(a, b) { - for (var c = 0, d = ''; !(c >= b / 4); ) { - var f = F[(a + 4 * c) >> 2] - if (0 == f) break - ++c - 65536 <= f - ? ((f -= 65536), - (d += String.fromCharCode(55296 | (f >> 10), 56320 | (f & 1023)))) - : (d += String.fromCharCode(f)) - } - return d - } - function oa(a, b, c) { - void 0 === c && (c = 2147483647) - if (4 > c) return 0 - var d = b - c = d + c - 4 - for (var f = 0; f < a.length; ++f) { - var g = a.charCodeAt(f) - if (55296 <= g && 57343 >= g) { - var l = a.charCodeAt(++f) - g = (65536 + ((g & 1023) << 10)) | (l & 1023) - } - F[b >> 2] = g - b += 4 - if (b + 4 > c) break - } - F[b >> 2] = 0 - return b - d - } - function pa(a) { - for (var b = 0, c = 0; c < a.length; ++c) { - var d = a.charCodeAt(c) - 55296 <= d && 57343 >= d && ++c - b += 4 - } - return b - } - var G, qa, C, E, D, F, I, ra, sa - function ta(a) { - G = a - e.HEAP8 = qa = new Int8Array(a) - e.HEAP16 = E = new Int16Array(a) - e.HEAP32 = F = new Int32Array(a) - e.HEAPU8 = C = new Uint8Array(a) - e.HEAPU16 = D = new Uint16Array(a) - e.HEAPU32 = I = new Uint32Array(a) - e.HEAPF32 = ra = new Float32Array(a) - e.HEAPF64 = sa = new Float64Array(a) - } - var ua = e.INITIAL_MEMORY || 16777216 - e.wasmMemory - ? (B = e.wasmMemory) - : (B = new WebAssembly.Memory({ initial: ua / 65536, maximum: 32768 })) - B && (G = B.buffer) - ua = G.byteLength - ta(G) - var J, - va = [], - wa = [], - xa = [], - ya = [] - function za() { - var a = e.preRun.shift() - va.unshift(a) - } - var L = 0, - Aa = null, - M = null - e.preloadedImages = {} - e.preloadedAudios = {} - function x(a) { - if (e.onAbort) e.onAbort(a) - y(a) - fa = !0 - a = new WebAssembly.RuntimeError( - 'abort(' + a + '). Build with -s ASSERTIONS=1 for more info.' - ) - r(a) - throw a - } - function Ba() { - var a = N - return String.prototype.startsWith - ? a.startsWith('data:application/octet-stream;base64,') - : 0 === a.indexOf('data:application/octet-stream;base64,') - } - var N = 'webp_node_dec.wasm' - if (!Ba()) { - var Ca = N - N = e.locateFile ? e.locateFile(Ca, v) : v + Ca - } - function Da() { - try { - if (z) return new Uint8Array(z) - if (ca) return ca(N) - throw 'both async and sync fetching of the wasm failed' - } catch (a) { - x(a) - } - } - function O(a) { - for (; 0 < a.length; ) { - var b = a.shift() - if ('function' == typeof b) b(e) - else { - var c = b.G - 'number' === typeof c - ? void 0 === b.C - ? J.get(c)() - : J.get(c)(b.C) - : c(void 0 === b.C ? null : b.C) - } - } - } - function Ea(a) { - switch (a) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + a) - } - } - var Fa = void 0 - function P(a) { - for (var b = ''; C[a]; ) b += Fa[C[a++]] - return b - } - var Q = {}, - R = {}, - S = {} - function Ga(a) { - if (void 0 === a) return '_unknown' - a = a.replace(/[^a-zA-Z0-9_]/g, '$') - var b = a.charCodeAt(0) - return 48 <= b && 57 >= b ? '_' + a : a - } - function Ha(a, b) { - a = Ga(a) - return new Function( - 'body', - 'return function ' + - a + - '() {\n "use strict"; return body.apply(this, arguments);\n};\n' - )(b) - } - function Ia(a) { - var b = Error, - c = Ha(a, function (d) { - this.name = a - this.message = d - d = Error(d).stack - void 0 !== d && - (this.stack = - this.toString() + '\n' + d.replace(/^Error(:[^\n]*)?\n/, '')) - }) - c.prototype = Object.create(b.prototype) - c.prototype.constructor = c - c.prototype.toString = function () { - return void 0 === this.message - ? this.name - : this.name + ': ' + this.message - } - return c - } - var Ja = void 0 - function T(a) { - throw new Ja(a) - } - var Ka = void 0 - function La(a, b) { - function c(h) { - h = b(h) - if (h.length !== d.length) - throw new Ka('Mismatched type converter count') - for (var k = 0; k < d.length; ++k) U(d[k], h[k]) - } - var d = [] - d.forEach(function (h) { - S[h] = a - }) - var f = Array(a.length), - g = [], - l = 0 - a.forEach(function (h, k) { - R.hasOwnProperty(h) - ? (f[k] = R[h]) - : (g.push(h), - Q.hasOwnProperty(h) || (Q[h] = []), - Q[h].push(function () { - f[k] = R[h] - ++l - l === g.length && c(f) - })) - }) - 0 === g.length && c(f) - } - function U(a, b, c) { - c = c || {} - if (!('argPackAdvance' in b)) - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - var d = b.name - a || T('type "' + d + '" must have a positive integer typeid pointer') - if (R.hasOwnProperty(a)) { - if (c.H) return - T("Cannot register type '" + d + "' twice") - } - R[a] = b - delete S[a] - Q.hasOwnProperty(a) && - ((b = Q[a]), - delete Q[a], - b.forEach(function (f) { - f() - })) - } - var Oa = [], - V = [{}, { value: void 0 }, { value: null }, { value: !0 }, { value: !1 }] - function Pa(a) { - 4 < a && 0 === --V[a].D && ((V[a] = void 0), Oa.push(a)) - } - function W(a) { - switch (a) { - case void 0: - return 1 - case null: - return 2 - case !0: - return 3 - case !1: - return 4 - default: - var b = Oa.length ? Oa.pop() : V.length - V[b] = { D: 1, value: a } - return b - } - } - function Qa(a) { - return this.fromWireType(I[a >> 2]) - } - function Ra(a) { - if (null === a) return 'null' - var b = typeof a - return 'object' === b || 'array' === b || 'function' === b - ? a.toString() - : '' + a - } - function Sa(a, b) { - switch (b) { - case 2: - return function (c) { - return this.fromWireType(ra[c >> 2]) - } - case 3: - return function (c) { - return this.fromWireType(sa[c >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + a) - } - } - function Ta(a) { - var b = Function - if (!(b instanceof Function)) - throw new TypeError( - 'new_ called with constructor type ' + - typeof b + - ' which is not a function' - ) - var c = Ha(b.name || 'unknownFunctionName', function () {}) - c.prototype = b.prototype - c = new c() - a = b.apply(c, a) - return a instanceof Object ? a : c - } - function Ua(a) { - for (; a.length; ) { - var b = a.pop() - a.pop()(b) - } - } - function Va(a, b) { - var c = e - if (void 0 === c[a].A) { - var d = c[a] - c[a] = function () { - c[a].A.hasOwnProperty(arguments.length) || - T( - "Function '" + - b + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - c[a].A + - ')!' - ) - return c[a].A[arguments.length].apply(this, arguments) - } - c[a].A = [] - c[a].A[d.F] = d - } - } - function Wa(a, b, c) { - e.hasOwnProperty(a) - ? ((void 0 === c || (void 0 !== e[a].A && void 0 !== e[a].A[c])) && - T("Cannot register public name '" + a + "' twice"), - Va(a, a), - e.hasOwnProperty(c) && - T( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - c + - ')!' - ), - (e[a].A[c] = b)) - : ((e[a] = b), void 0 !== c && (e[a].J = c)) - } - function Xa(a, b) { - for (var c = [], d = 0; d < a; d++) c.push(F[(b >> 2) + d]) - return c - } - function Ya(a, b) { - 0 <= a.indexOf('j') || - x('Assertion failed: getDynCaller should only be called with i64 sigs') - var c = [] - return function () { - c.length = arguments.length - for (var d = 0; d < arguments.length; d++) c[d] = arguments[d] - var f - ;-1 != a.indexOf('j') - ? (f = - c && c.length - ? e['dynCall_' + a].apply(null, [b].concat(c)) - : e['dynCall_' + a].call(null, b)) - : (f = J.get(b).apply(null, c)) - return f - } - } - function Za(a, b) { - a = P(a) - var c = -1 != a.indexOf('j') ? Ya(a, b) : J.get(b) - 'function' !== typeof c && - T('unknown function pointer with signature ' + a + ': ' + b) - return c - } - var $a = void 0 - function ab(a) { - a = bb(a) - var b = P(a) - X(a) - return b - } - function cb(a, b) { - function c(g) { - f[g] || R[g] || (S[g] ? S[g].forEach(c) : (d.push(g), (f[g] = !0))) - } - var d = [], - f = {} - b.forEach(c) - throw new $a(a + ': ' + d.map(ab).join([', '])) - } - function db(a, b, c) { - switch (b) { - case 0: - return c - ? function (d) { - return qa[d] - } - : function (d) { - return C[d] - } - case 1: - return c - ? function (d) { - return E[d >> 1] - } - : function (d) { - return D[d >> 1] - } - case 2: - return c - ? function (d) { - return F[d >> 2] - } - : function (d) { - return I[d >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + a) - } - } - var eb = {} - function fb() { - return 'object' === typeof globalThis - ? globalThis - : Function('return this')() - } - function gb(a, b) { - var c = R[a] - void 0 === c && T(b + ' has unknown type ' + ab(a)) - return c - } - for (var hb = {}, ib = Array(256), Y = 0; 256 > Y; ++Y) - ib[Y] = String.fromCharCode(Y) - Fa = ib - Ja = e.BindingError = Ia('BindingError') - Ka = e.InternalError = Ia('InternalError') - e.count_emval_handles = function () { - for (var a = 0, b = 5; b < V.length; ++b) void 0 !== V[b] && ++a - return a - } - e.get_first_emval = function () { - for (var a = 5; a < V.length; ++a) if (void 0 !== V[a]) return V[a] - return null - } - $a = e.UnboundTypeError = Ia('UnboundTypeError') - wa.push({ - G: function () { - jb() - }, - }) - var lb = { - g: function () {}, - o: function (a, b, c, d, f) { - var g = Ea(c) - b = P(b) - U(a, { - name: b, - fromWireType: function (l) { - return !!l - }, - toWireType: function (l, h) { - return h ? d : f - }, - argPackAdvance: 8, - readValueFromPointer: function (l) { - if (1 === c) var h = qa - else if (2 === c) h = E - else if (4 === c) h = F - else throw new TypeError('Unknown boolean type size: ' + b) - return this.fromWireType(h[l >> g]) - }, - B: null, - }) - }, - r: function (a, b) { - b = P(b) - U(a, { - name: b, - fromWireType: function (c) { - var d = V[c].value - Pa(c) - return d - }, - toWireType: function (c, d) { - return W(d) - }, - argPackAdvance: 8, - readValueFromPointer: Qa, - B: null, - }) - }, - n: function (a, b, c) { - c = Ea(c) - b = P(b) - U(a, { - name: b, - fromWireType: function (d) { - return d - }, - toWireType: function (d, f) { - if ('number' !== typeof f && 'boolean' !== typeof f) - throw new TypeError( - 'Cannot convert "' + Ra(f) + '" to ' + this.name - ) - return f - }, - argPackAdvance: 8, - readValueFromPointer: Sa(b, c), - B: null, - }) - }, - j: function (a, b, c, d, f, g) { - var l = Xa(b, c) - a = P(a) - f = Za(d, f) - Wa( - a, - function () { - cb('Cannot call ' + a + ' due to unbound types', l) - }, - b - 1 - ) - La(l, function (h) { - var k = [h[0], null].concat(h.slice(1)), - n = (h = a), - p = f, - q = k.length - 2 > q && - T( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - for (var w = null !== k[1] && !1, A = !1, m = 1; m < k.length; ++m) - if (null !== k[m] && void 0 === k[m].B) { - A = !0 - break - } - var Ma = 'void' !== k[0].name, - H = '', - K = '' - for (m = 0; m < q - 2; ++m) - (H += (0 !== m ? ', ' : '') + 'arg' + m), - (K += (0 !== m ? ', ' : '') + 'arg' + m + 'Wired') - n = - 'return function ' + - Ga(n) + - '(' + - H + - ') {\nif (arguments.length !== ' + - (q - 2) + - ") {\nthrowBindingError('function " + - n + - " called with ' + arguments.length + ' arguments, expected " + - (q - 2) + - " args!');\n}\n" - A && (n += 'var destructors = [];\n') - var Na = A ? 'destructors' : 'null' - H = 'throwBindingError invoker fn runDestructors retType classParam'.split( - ' ' - ) - p = [T, p, g, Ua, k[0], k[1]] - w && - (n += 'var thisWired = classParam.toWireType(' + Na + ', this);\n') - for (m = 0; m < q - 2; ++m) - (n += - 'var arg' + - m + - 'Wired = argType' + - m + - '.toWireType(' + - Na + - ', arg' + - m + - '); // ' + - k[m + 2].name + - '\n'), - H.push('argType' + m), - p.push(k[m + 2]) - w && (K = 'thisWired' + (0 < K.length ? ', ' : '') + K) - n += - (Ma ? 'var rv = ' : '') + - 'invoker(fn' + - (0 < K.length ? ', ' : '') + - K + - ');\n' - if (A) n += 'runDestructors(destructors);\n' - else - for (m = w ? 1 : 2; m < k.length; ++m) - (q = 1 === m ? 'thisWired' : 'arg' + (m - 2) + 'Wired'), - null !== k[m].B && - ((n += q + '_dtor(' + q + '); // ' + k[m].name + '\n'), - H.push(q + '_dtor'), - p.push(k[m].B)) - Ma && (n += 'var ret = retType.fromWireType(rv);\nreturn ret;\n') - H.push(n + '}\n') - k = Ta(H).apply(null, p) - m = b - 1 - if (!e.hasOwnProperty(h)) - throw new Ka('Replacing nonexistant public symbol') - void 0 !== e[h].A && void 0 !== m - ? (e[h].A[m] = k) - : ((e[h] = k), (e[h].F = m)) - return [] - }) - }, - c: function (a, b, c, d, f) { - function g(n) { - return n - } - b = P(b) - ;-1 === f && (f = 4294967295) - var l = Ea(c) - if (0 === d) { - var h = 32 - 8 * c - g = function (n) { - return (n << h) >>> h - } - } - var k = -1 != b.indexOf('unsigned') - U(a, { - name: b, - fromWireType: g, - toWireType: function (n, p) { - if ('number' !== typeof p && 'boolean' !== typeof p) - throw new TypeError( - 'Cannot convert "' + Ra(p) + '" to ' + this.name - ) - if (p < d || p > f) - throw new TypeError( - 'Passing a number "' + - Ra(p) + - '" from JS side to C/C++ side to an argument of type "' + - b + - '", which is outside the valid range [' + - d + - ', ' + - f + - ']!' - ) - return k ? p >>> 0 : p | 0 - }, - argPackAdvance: 8, - readValueFromPointer: db(b, l, 0 !== d), - B: null, - }) - }, - b: function (a, b, c) { - function d(g) { - g >>= 2 - var l = I - return new f(G, l[g + 1], l[g]) - } - var f = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ][b] - c = P(c) - U( - a, - { - name: c, - fromWireType: d, - argPackAdvance: 8, - readValueFromPointer: d, - }, - { H: !0 } - ) - }, - i: function (a, b) { - b = P(b) - var c = 'std::string' === b - U(a, { - name: b, - fromWireType: function (d) { - var f = I[d >> 2] - if (c) - for (var g = d + 4, l = 0; l <= f; ++l) { - var h = d + 4 + l - if (l == f || 0 == C[h]) { - if (g) { - for (var k = g + (h - g), n = g; !(n >= k) && C[n]; ) ++n - g = ha.decode(C.subarray(g, n)) - } else g = '' - if (void 0 === p) var p = g - else (p += String.fromCharCode(0)), (p += g) - g = h + 1 - } - } - else { - p = Array(f) - for (l = 0; l < f; ++l) p[l] = String.fromCharCode(C[d + 4 + l]) - p = p.join('') - } - X(d) - return p - }, - toWireType: function (d, f) { - f instanceof ArrayBuffer && (f = new Uint8Array(f)) - var g = 'string' === typeof f - g || - f instanceof Uint8Array || - f instanceof Uint8ClampedArray || - f instanceof Int8Array || - T('Cannot pass non-string to std::string') - var l = (c && g - ? function () { - for (var n = 0, p = 0; p < f.length; ++p) { - var q = f.charCodeAt(p) - 55296 <= q && - 57343 >= q && - (q = - (65536 + ((q & 1023) << 10)) | - (f.charCodeAt(++p) & 1023)) - 127 >= q - ? ++n - : (n = 2047 >= q ? n + 2 : 65535 >= q ? n + 3 : n + 4) - } - return n - } - : function () { - return f.length - })(), - h = kb(4 + l + 1) - I[h >> 2] = l - if (c && g) ia(f, h + 4, l + 1) - else if (g) - for (g = 0; g < l; ++g) { - var k = f.charCodeAt(g) - 255 < k && - (X(h), - T('String has UTF-16 code units that do not fit in 8 bits')) - C[h + 4 + g] = k - } - else for (g = 0; g < l; ++g) C[h + 4 + g] = f[g] - null !== d && d.push(X, h) - return h - }, - argPackAdvance: 8, - readValueFromPointer: Qa, - B: function (d) { - X(d) - }, - }) - }, - h: function (a, b, c) { - c = P(c) - if (2 === b) { - var d = ka - var f = la - var g = ma - var l = function () { - return D - } - var h = 1 - } else - 4 === b && - ((d = na), - (f = oa), - (g = pa), - (l = function () { - return I - }), - (h = 2)) - U(a, { - name: c, - fromWireType: function (k) { - for (var n = I[k >> 2], p = l(), q, w = k + 4, A = 0; A <= n; ++A) { - var m = k + 4 + A * b - if (A == n || 0 == p[m >> h]) - (w = d(w, m - w)), - void 0 === q - ? (q = w) - : ((q += String.fromCharCode(0)), (q += w)), - (w = m + b) - } - X(k) - return q - }, - toWireType: function (k, n) { - 'string' !== typeof n && - T('Cannot pass non-string to C++ string type ' + c) - var p = g(n), - q = kb(4 + p + b) - I[q >> 2] = p >> h - f(n, q + 4, p + b) - null !== k && k.push(X, q) - return q - }, - argPackAdvance: 8, - readValueFromPointer: Qa, - B: function (k) { - X(k) - }, - }) - }, - p: function (a, b) { - b = P(b) - U(a, { - I: !0, - name: b, - argPackAdvance: 0, - fromWireType: function () {}, - toWireType: function () {}, - }) - }, - e: Pa, - f: function (a) { - if (0 === a) return W(fb()) - var b = eb[a] - a = void 0 === b ? P(a) : b - return W(fb()[a]) - }, - k: function (a) { - 4 < a && (V[a].D += 1) - }, - l: function (a, b, c, d) { - a || T('Cannot use deleted val. handle = ' + a) - a = V[a].value - var f = hb[b] - if (!f) { - f = '' - for (var g = 0; g < b; ++g) f += (0 !== g ? ', ' : '') + 'arg' + g - var l = - 'return function emval_allocator_' + - b + - '(constructor, argTypes, args) {\n' - for (g = 0; g < b; ++g) - l += - 'var argType' + - g + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - g + - '], "parameter ' + - g + - '");\nvar arg' + - g + - ' = argType' + - g + - '.readValueFromPointer(args);\nargs += argType' + - g + - "['argPackAdvance'];\n" - f = new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - l + - ('var obj = new constructor(' + - f + - ');\nreturn __emval_register(obj);\n}\n') - )(gb, e, W) - hb[b] = f - } - return f(a, c, d) - }, - m: function () { - x() - }, - q: function (a, b, c) { - C.copyWithin(a, b, b + c) - }, - d: function (a) { - a >>>= 0 - var b = C.length - if (2147483648 < a) return !1 - for (var c = 1; 4 >= c; c *= 2) { - var d = b * (1 + 0.2 / c) - d = Math.min(d, a + 100663296) - d = Math.max(16777216, a, d) - 0 < d % 65536 && (d += 65536 - (d % 65536)) - a: { - try { - B.grow((Math.min(2147483648, d) - G.byteLength + 65535) >>> 16) - ta(B.buffer) - var f = 1 - break a - } catch (g) {} - f = void 0 - } - if (f) return !0 - } - return !1 - }, - a: B, - } - ;(function () { - function a(f) { - e.asm = f.exports - J = e.asm.s - L-- - e.monitorRunDependencies && e.monitorRunDependencies(L) - 0 == L && - (null !== Aa && (clearInterval(Aa), (Aa = null)), - M && ((f = M), (M = null), f())) - } - function b(f) { - a(f.instance) - } - function c(f) { - return Promise.resolve() - .then(Da) - .then(function (g) { - return WebAssembly.instantiate(g, d) - }) - .then(f, function (g) { - y('failed to asynchronously prepare wasm: ' + g) - x(g) - }) - } - var d = { a: lb } - L++ - e.monitorRunDependencies && e.monitorRunDependencies(L) - if (e.instantiateWasm) - try { - return e.instantiateWasm(d, a) - } catch (f) { - return ( - y('Module.instantiateWasm callback failed with error: ' + f), !1 - ) - } - ;(function () { - return z || - 'function' !== typeof WebAssembly.instantiateStreaming || - Ba() || - 'function' !== typeof fetch - ? c(b) - : fetch(N, { credentials: 'same-origin' }).then(function (f) { - return WebAssembly.instantiateStreaming(f, d).then(b, function ( - g - ) { - y('wasm streaming compile failed: ' + g) - y('falling back to ArrayBuffer instantiation') - return c(b) - }) - }) - })().catch(r) - return {} - })() - var jb = (e.___wasm_call_ctors = function () { - return (jb = e.___wasm_call_ctors = e.asm.t).apply(null, arguments) - }), - kb = (e._malloc = function () { - return (kb = e._malloc = e.asm.u).apply(null, arguments) - }), - X = (e._free = function () { - return (X = e._free = e.asm.v).apply(null, arguments) - }), - bb = (e.___getTypeName = function () { - return (bb = e.___getTypeName = e.asm.w).apply(null, arguments) - }) - e.___embind_register_native_and_builtin_types = function () { - return (e.___embind_register_native_and_builtin_types = e.asm.x).apply( - null, - arguments - ) - } - var Z - M = function mb() { - Z || nb() - Z || (M = mb) - } - function nb() { - function a() { - if (!Z && ((Z = !0), (e.calledRun = !0), !fa)) { - O(wa) - O(xa) - aa(e) - if (e.onRuntimeInitialized) e.onRuntimeInitialized() - if (e.postRun) - for ( - 'function' == typeof e.postRun && (e.postRun = [e.postRun]); - e.postRun.length; - - ) { - var b = e.postRun.shift() - ya.unshift(b) - } - O(ya) - } - } - if (!(0 < L)) { - if (e.preRun) - for ( - 'function' == typeof e.preRun && (e.preRun = [e.preRun]); - e.preRun.length; - - ) - za() - O(va) - 0 < L || - (e.setStatus - ? (e.setStatus('Running...'), - setTimeout(function () { - setTimeout(function () { - e.setStatus('') - }, 1) - a() - }, 1)) - : a()) - } - } - e.run = nb - if (e.preInit) - for ( - 'function' == typeof e.preInit && (e.preInit = [e.preInit]); - 0 < e.preInit.length; - - ) - e.preInit.pop()() - noExitRuntime = !0 - nb() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.wasm b/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.wasm deleted file mode 100644 index c3363498515a1..0000000000000 Binary files a/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.wasm and /dev/null differ diff --git a/packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.js b/packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.js deleted file mode 100644 index dc6c7d2892a1c..0000000000000 --- a/packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.js +++ /dev/null @@ -1,1220 +0,0 @@ -/* eslint-disable */ -import { TextDecoder } from '../text-decoder' - -var Module = (function () { - // var _scriptDir = import.meta.url - - return function (Module) { - Module = Module || {} - - var f - f || (f = typeof Module !== 'undefined' ? Module : {}) - var aa, ba - f.ready = new Promise(function (a, b) { - aa = a - ba = b - }) - var r = {}, - t - for (t in f) f.hasOwnProperty(t) && (r[t] = f[t]) - var ca = '', - ea, - fa, - ha, - ia - ca = __dirname + '/' - ea = function (a) { - ha || (ha = require('fs')) - ia || (ia = require('path')) - a = ia.normalize(a) - return ha.readFileSync(a, null) - } - fa = function (a) { - a = ea(a) - a.buffer || (a = new Uint8Array(a)) - a.buffer || u('Assertion failed: undefined') - return a - } - f.inspect = function () { - return '[Emscripten Module object]' - } - f.print || console.log.bind(console) - var v = f.printErr || console.warn.bind(console) - for (t in r) r.hasOwnProperty(t) && (f[t] = r[t]) - r = null - var z - f.wasmBinary && (z = f.wasmBinary) - var noExitRuntime - f.noExitRuntime && (noExitRuntime = f.noExitRuntime) - 'object' !== typeof WebAssembly && u('no native wasm support detected') - var A, - ja = !1, - ka = new TextDecoder('utf8') - function la(a, b, c) { - var d = B - if (0 < c) { - c = b + c - 1 - for (var e = 0; e < a.length; ++e) { - var g = a.charCodeAt(e) - if (55296 <= g && 57343 >= g) { - var l = a.charCodeAt(++e) - g = (65536 + ((g & 1023) << 10)) | (l & 1023) - } - if (127 >= g) { - if (b >= c) break - d[b++] = g - } else { - if (2047 >= g) { - if (b + 1 >= c) break - d[b++] = 192 | (g >> 6) - } else { - if (65535 >= g) { - if (b + 2 >= c) break - d[b++] = 224 | (g >> 12) - } else { - if (b + 3 >= c) break - d[b++] = 240 | (g >> 18) - d[b++] = 128 | ((g >> 12) & 63) - } - d[b++] = 128 | ((g >> 6) & 63) - } - d[b++] = 128 | (g & 63) - } - } - d[b] = 0 - } - } - var ma = new TextDecoder('utf-16le') - function na(a, b) { - var c = a >> 1 - for (b = c + b / 2; !(c >= b) && C[c]; ) ++c - return ma.decode(B.subarray(a, c << 1)) - } - function oa(a, b, c) { - void 0 === c && (c = 2147483647) - if (2 > c) return 0 - c -= 2 - var d = b - c = c < 2 * a.length ? c / 2 : a.length - for (var e = 0; e < c; ++e) (D[b >> 1] = a.charCodeAt(e)), (b += 2) - D[b >> 1] = 0 - return b - d - } - function pa(a) { - return 2 * a.length - } - function qa(a, b) { - for (var c = 0, d = ''; !(c >= b / 4); ) { - var e = F[(a + 4 * c) >> 2] - if (0 == e) break - ++c - 65536 <= e - ? ((e -= 65536), - (d += String.fromCharCode(55296 | (e >> 10), 56320 | (e & 1023)))) - : (d += String.fromCharCode(e)) - } - return d - } - function ra(a, b, c) { - void 0 === c && (c = 2147483647) - if (4 > c) return 0 - var d = b - c = d + c - 4 - for (var e = 0; e < a.length; ++e) { - var g = a.charCodeAt(e) - if (55296 <= g && 57343 >= g) { - var l = a.charCodeAt(++e) - g = (65536 + ((g & 1023) << 10)) | (l & 1023) - } - F[b >> 2] = g - b += 4 - if (b + 4 > c) break - } - F[b >> 2] = 0 - return b - d - } - function sa(a) { - for (var b = 0, c = 0; c < a.length; ++c) { - var d = a.charCodeAt(c) - 55296 <= d && 57343 >= d && ++c - b += 4 - } - return b - } - var G, H, B, D, C, F, I, ta, ua - function va(a) { - G = a - f.HEAP8 = H = new Int8Array(a) - f.HEAP16 = D = new Int16Array(a) - f.HEAP32 = F = new Int32Array(a) - f.HEAPU8 = B = new Uint8Array(a) - f.HEAPU16 = C = new Uint16Array(a) - f.HEAPU32 = I = new Uint32Array(a) - f.HEAPF32 = ta = new Float32Array(a) - f.HEAPF64 = ua = new Float64Array(a) - } - var wa = f.INITIAL_MEMORY || 16777216 - f.wasmMemory - ? (A = f.wasmMemory) - : (A = new WebAssembly.Memory({ initial: wa / 65536, maximum: 32768 })) - A && (G = A.buffer) - wa = G.byteLength - va(G) - var J, - xa = [], - ya = [], - za = [], - Aa = [] - function Ba() { - var a = f.preRun.shift() - xa.unshift(a) - } - var K = 0, - Ca = null, - L = null - f.preloadedImages = {} - f.preloadedAudios = {} - function u(a) { - if (f.onAbort) f.onAbort(a) - v(a) - ja = !0 - a = new WebAssembly.RuntimeError( - 'abort(' + a + '). Build with -s ASSERTIONS=1 for more info.' - ) - ba(a) - throw a - } - function Da() { - var a = M - return String.prototype.startsWith - ? a.startsWith('data:application/octet-stream;base64,') - : 0 === a.indexOf('data:application/octet-stream;base64,') - } - var M = 'webp_node_enc.wasm' - if (!Da()) { - var Ea = M - M = f.locateFile ? f.locateFile(Ea, ca) : ca + Ea - } - function Fa() { - try { - if (z) return new Uint8Array(z) - if (fa) return fa(M) - throw 'both async and sync fetching of the wasm failed' - } catch (a) { - u(a) - } - } - function N(a) { - for (; 0 < a.length; ) { - var b = a.shift() - if ('function' == typeof b) b(f) - else { - var c = b.L - 'number' === typeof c - ? void 0 === b.G - ? J.get(c)() - : J.get(c)(b.G) - : c(void 0 === b.G ? null : b.G) - } - } - } - var O = {} - function Ga(a) { - for (; a.length; ) { - var b = a.pop() - a.pop()(b) - } - } - function P(a) { - return this.fromWireType(I[a >> 2]) - } - var Q = {}, - R = {}, - S = {} - function Ha(a) { - if (void 0 === a) return '_unknown' - a = a.replace(/[^a-zA-Z0-9_]/g, '$') - var b = a.charCodeAt(0) - return 48 <= b && 57 >= b ? '_' + a : a - } - function Ia(a, b) { - a = Ha(a) - return new Function( - 'body', - 'return function ' + - a + - '() {\n "use strict"; return body.apply(this, arguments);\n};\n' - )(b) - } - function Ja(a) { - var b = Error, - c = Ia(a, function (d) { - this.name = a - this.message = d - d = Error(d).stack - void 0 !== d && - (this.stack = - this.toString() + '\n' + d.replace(/^Error(:[^\n]*)?\n/, '')) - }) - c.prototype = Object.create(b.prototype) - c.prototype.constructor = c - c.prototype.toString = function () { - return void 0 === this.message - ? this.name - : this.name + ': ' + this.message - } - return c - } - var Ka = void 0 - function La(a, b, c) { - function d(h) { - h = c(h) - if (h.length !== a.length) - throw new Ka('Mismatched type converter count') - for (var k = 0; k < a.length; ++k) U(a[k], h[k]) - } - a.forEach(function (h) { - S[h] = b - }) - var e = Array(b.length), - g = [], - l = 0 - b.forEach(function (h, k) { - R.hasOwnProperty(h) - ? (e[k] = R[h]) - : (g.push(h), - Q.hasOwnProperty(h) || (Q[h] = []), - Q[h].push(function () { - e[k] = R[h] - ++l - l === g.length && d(e) - })) - }) - 0 === g.length && d(e) - } - function Ma(a) { - switch (a) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + a) - } - } - var Na = void 0 - function V(a) { - for (var b = ''; B[a]; ) b += Na[B[a++]] - return b - } - var Oa = void 0 - function W(a) { - throw new Oa(a) - } - function U(a, b, c) { - c = c || {} - if (!('argPackAdvance' in b)) - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - var d = b.name - a || W('type "' + d + '" must have a positive integer typeid pointer') - if (R.hasOwnProperty(a)) { - if (c.P) return - W("Cannot register type '" + d + "' twice") - } - R[a] = b - delete S[a] - Q.hasOwnProperty(a) && - ((b = Q[a]), - delete Q[a], - b.forEach(function (e) { - e() - })) - } - var Pa = [], - X = [{}, { value: void 0 }, { value: null }, { value: !0 }, { value: !1 }] - function Qa(a) { - 4 < a && 0 === --X[a].H && ((X[a] = void 0), Pa.push(a)) - } - function Ra(a) { - switch (a) { - case void 0: - return 1 - case null: - return 2 - case !0: - return 3 - case !1: - return 4 - default: - var b = Pa.length ? Pa.pop() : X.length - X[b] = { H: 1, value: a } - return b - } - } - function Sa(a, b) { - var c = f - if (void 0 === c[a].F) { - var d = c[a] - c[a] = function () { - c[a].F.hasOwnProperty(arguments.length) || - W( - "Function '" + - b + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - c[a].F + - ')!' - ) - return c[a].F[arguments.length].apply(this, arguments) - } - c[a].F = [] - c[a].F[d.J] = d - } - } - function Ta(a, b, c) { - f.hasOwnProperty(a) - ? ((void 0 === c || (void 0 !== f[a].F && void 0 !== f[a].F[c])) && - W("Cannot register public name '" + a + "' twice"), - Sa(a, a), - f.hasOwnProperty(c) && - W( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - c + - ')!' - ), - (f[a].F[c] = b)) - : ((f[a] = b), void 0 !== c && (f[a].X = c)) - } - function Ua(a, b, c) { - switch (b) { - case 0: - return function (d) { - return this.fromWireType((c ? H : B)[d]) - } - case 1: - return function (d) { - return this.fromWireType((c ? D : C)[d >> 1]) - } - case 2: - return function (d) { - return this.fromWireType((c ? F : I)[d >> 2]) - } - default: - throw new TypeError('Unknown integer type: ' + a) - } - } - function Va(a) { - a = Wa(a) - var b = V(a) - Y(a) - return b - } - function Xa(a, b) { - var c = R[a] - void 0 === c && W(b + ' has unknown type ' + Va(a)) - return c - } - function Ya(a) { - if (null === a) return 'null' - var b = typeof a - return 'object' === b || 'array' === b || 'function' === b - ? a.toString() - : '' + a - } - function Za(a, b) { - switch (b) { - case 2: - return function (c) { - return this.fromWireType(ta[c >> 2]) - } - case 3: - return function (c) { - return this.fromWireType(ua[c >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + a) - } - } - function $a(a) { - var b = Function - if (!(b instanceof Function)) - throw new TypeError( - 'new_ called with constructor type ' + - typeof b + - ' which is not a function' - ) - var c = Ia(b.name || 'unknownFunctionName', function () {}) - c.prototype = b.prototype - c = new c() - a = b.apply(c, a) - return a instanceof Object ? a : c - } - function ab(a, b) { - for (var c = [], d = 0; d < a; d++) c.push(F[(b >> 2) + d]) - return c - } - function bb(a, b) { - 0 <= a.indexOf('j') || - u('Assertion failed: getDynCaller should only be called with i64 sigs') - var c = [] - return function () { - c.length = arguments.length - for (var d = 0; d < arguments.length; d++) c[d] = arguments[d] - var e - ;-1 != a.indexOf('j') - ? (e = - c && c.length - ? f['dynCall_' + a].apply(null, [b].concat(c)) - : f['dynCall_' + a].call(null, b)) - : (e = J.get(b).apply(null, c)) - return e - } - } - function Z(a, b) { - a = V(a) - var c = -1 != a.indexOf('j') ? bb(a, b) : J.get(b) - 'function' !== typeof c && - W('unknown function pointer with signature ' + a + ': ' + b) - return c - } - var cb = void 0 - function db(a, b) { - function c(g) { - e[g] || R[g] || (S[g] ? S[g].forEach(c) : (d.push(g), (e[g] = !0))) - } - var d = [], - e = {} - b.forEach(c) - throw new cb(a + ': ' + d.map(Va).join([', '])) - } - function eb(a, b, c) { - switch (b) { - case 0: - return c - ? function (d) { - return H[d] - } - : function (d) { - return B[d] - } - case 1: - return c - ? function (d) { - return D[d >> 1] - } - : function (d) { - return C[d >> 1] - } - case 2: - return c - ? function (d) { - return F[d >> 2] - } - : function (d) { - return I[d >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + a) - } - } - var fb = {} - function gb() { - return 'object' === typeof globalThis - ? globalThis - : Function('return this')() - } - var hb = {} - Ka = f.InternalError = Ja('InternalError') - for (var ib = Array(256), jb = 0; 256 > jb; ++jb) - ib[jb] = String.fromCharCode(jb) - Na = ib - Oa = f.BindingError = Ja('BindingError') - f.count_emval_handles = function () { - for (var a = 0, b = 5; b < X.length; ++b) void 0 !== X[b] && ++a - return a - } - f.get_first_emval = function () { - for (var a = 5; a < X.length; ++a) if (void 0 !== X[a]) return X[a] - return null - } - cb = f.UnboundTypeError = Ja('UnboundTypeError') - ya.push({ - L: function () { - kb() - }, - }) - var mb = { - w: function () {}, - m: function (a) { - var b = O[a] - delete O[a] - var c = b.R, - d = b.S, - e = b.I, - g = e - .map(function (l) { - return l.O - }) - .concat( - e.map(function (l) { - return l.U - }) - ) - La([a], g, function (l) { - var h = {} - e.forEach(function (k, m) { - var n = l[m], - q = k.M, - w = k.N, - x = l[m + e.length], - p = k.T, - da = k.V - h[k.K] = { - read: function (y) { - return n.fromWireType(q(w, y)) - }, - write: function (y, E) { - var T = [] - p(da, y, x.toWireType(T, E)) - Ga(T) - }, - } - }) - return [ - { - name: b.name, - fromWireType: function (k) { - var m = {}, - n - for (n in h) m[n] = h[n].read(k) - d(k) - return m - }, - toWireType: function (k, m) { - for (var n in h) - if (!(n in m)) - throw new TypeError('Missing field: "' + n + '"') - var q = c() - for (n in h) h[n].write(q, m[n]) - null !== k && k.push(d, q) - return q - }, - argPackAdvance: 8, - readValueFromPointer: P, - D: d, - }, - ] - }) - }, - s: function (a, b, c, d, e) { - var g = Ma(c) - b = V(b) - U(a, { - name: b, - fromWireType: function (l) { - return !!l - }, - toWireType: function (l, h) { - return h ? d : e - }, - argPackAdvance: 8, - readValueFromPointer: function (l) { - if (1 === c) var h = H - else if (2 === c) h = D - else if (4 === c) h = F - else throw new TypeError('Unknown boolean type size: ' + b) - return this.fromWireType(h[l >> g]) - }, - D: null, - }) - }, - r: function (a, b) { - b = V(b) - U(a, { - name: b, - fromWireType: function (c) { - var d = X[c].value - Qa(c) - return d - }, - toWireType: function (c, d) { - return Ra(d) - }, - argPackAdvance: 8, - readValueFromPointer: P, - D: null, - }) - }, - o: function (a, b, c, d) { - function e() {} - c = Ma(c) - b = V(b) - e.values = {} - U(a, { - name: b, - constructor: e, - fromWireType: function (g) { - return this.constructor.values[g] - }, - toWireType: function (g, l) { - return l.value - }, - argPackAdvance: 8, - readValueFromPointer: Ua(b, c, d), - D: null, - }) - Ta(b, e) - }, - f: function (a, b, c) { - var d = Xa(a, 'enum') - b = V(b) - a = d.constructor - d = Object.create(d.constructor.prototype, { - value: { value: c }, - constructor: { value: Ia(d.name + '_' + b, function () {}) }, - }) - a.values[c] = d - a[b] = d - }, - k: function (a, b, c) { - c = Ma(c) - b = V(b) - U(a, { - name: b, - fromWireType: function (d) { - return d - }, - toWireType: function (d, e) { - if ('number' !== typeof e && 'boolean' !== typeof e) - throw new TypeError( - 'Cannot convert "' + Ya(e) + '" to ' + this.name - ) - return e - }, - argPackAdvance: 8, - readValueFromPointer: Za(b, c), - D: null, - }) - }, - i: function (a, b, c, d, e, g) { - var l = ab(b, c) - a = V(a) - e = Z(d, e) - Ta( - a, - function () { - db('Cannot call ' + a + ' due to unbound types', l) - }, - b - 1 - ) - La([], l, function (h) { - var k = [h[0], null].concat(h.slice(1)), - m = (h = a), - n = e, - q = k.length - 2 > q && - W( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - for (var w = null !== k[1] && !1, x = !1, p = 1; p < k.length; ++p) - if (null !== k[p] && void 0 === k[p].D) { - x = !0 - break - } - var da = 'void' !== k[0].name, - y = '', - E = '' - for (p = 0; p < q - 2; ++p) - (y += (0 !== p ? ', ' : '') + 'arg' + p), - (E += (0 !== p ? ', ' : '') + 'arg' + p + 'Wired') - m = - 'return function ' + - Ha(m) + - '(' + - y + - ') {\nif (arguments.length !== ' + - (q - 2) + - ") {\nthrowBindingError('function " + - m + - " called with ' + arguments.length + ' arguments, expected " + - (q - 2) + - " args!');\n}\n" - x && (m += 'var destructors = [];\n') - var T = x ? 'destructors' : 'null' - y = 'throwBindingError invoker fn runDestructors retType classParam'.split( - ' ' - ) - n = [W, n, g, Ga, k[0], k[1]] - w && - (m += 'var thisWired = classParam.toWireType(' + T + ', this);\n') - for (p = 0; p < q - 2; ++p) - (m += - 'var arg' + - p + - 'Wired = argType' + - p + - '.toWireType(' + - T + - ', arg' + - p + - '); // ' + - k[p + 2].name + - '\n'), - y.push('argType' + p), - n.push(k[p + 2]) - w && (E = 'thisWired' + (0 < E.length ? ', ' : '') + E) - m += - (da ? 'var rv = ' : '') + - 'invoker(fn' + - (0 < E.length ? ', ' : '') + - E + - ');\n' - if (x) m += 'runDestructors(destructors);\n' - else - for (p = w ? 1 : 2; p < k.length; ++p) - (q = 1 === p ? 'thisWired' : 'arg' + (p - 2) + 'Wired'), - null !== k[p].D && - ((m += q + '_dtor(' + q + '); // ' + k[p].name + '\n'), - y.push(q + '_dtor'), - n.push(k[p].D)) - da && (m += 'var ret = retType.fromWireType(rv);\nreturn ret;\n') - y.push(m + '}\n') - k = $a(y).apply(null, n) - p = b - 1 - if (!f.hasOwnProperty(h)) - throw new Ka('Replacing nonexistant public symbol') - void 0 !== f[h].F && void 0 !== p - ? (f[h].F[p] = k) - : ((f[h] = k), (f[h].J = p)) - return [] - }) - }, - d: function (a, b, c, d, e) { - function g(m) { - return m - } - b = V(b) - ;-1 === e && (e = 4294967295) - var l = Ma(c) - if (0 === d) { - var h = 32 - 8 * c - g = function (m) { - return (m << h) >>> h - } - } - var k = -1 != b.indexOf('unsigned') - U(a, { - name: b, - fromWireType: g, - toWireType: function (m, n) { - if ('number' !== typeof n && 'boolean' !== typeof n) - throw new TypeError( - 'Cannot convert "' + Ya(n) + '" to ' + this.name - ) - if (n < d || n > e) - throw new TypeError( - 'Passing a number "' + - Ya(n) + - '" from JS side to C/C++ side to an argument of type "' + - b + - '", which is outside the valid range [' + - d + - ', ' + - e + - ']!' - ) - return k ? n >>> 0 : n | 0 - }, - argPackAdvance: 8, - readValueFromPointer: eb(b, l, 0 !== d), - D: null, - }) - }, - c: function (a, b, c) { - function d(g) { - g >>= 2 - var l = I - return new e(G, l[g + 1], l[g]) - } - var e = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ][b] - c = V(c) - U( - a, - { - name: c, - fromWireType: d, - argPackAdvance: 8, - readValueFromPointer: d, - }, - { P: !0 } - ) - }, - l: function (a, b) { - b = V(b) - var c = 'std::string' === b - U(a, { - name: b, - fromWireType: function (d) { - var e = I[d >> 2] - if (c) - for (var g = d + 4, l = 0; l <= e; ++l) { - var h = d + 4 + l - if (l == e || 0 == B[h]) { - if (g) { - for (var k = g + (h - g), m = g; !(m >= k) && B[m]; ) ++m - g = ka.decode(B.subarray(g, m)) - } else g = '' - if (void 0 === n) var n = g - else (n += String.fromCharCode(0)), (n += g) - g = h + 1 - } - } - else { - n = Array(e) - for (l = 0; l < e; ++l) n[l] = String.fromCharCode(B[d + 4 + l]) - n = n.join('') - } - Y(d) - return n - }, - toWireType: function (d, e) { - e instanceof ArrayBuffer && (e = new Uint8Array(e)) - var g = 'string' === typeof e - g || - e instanceof Uint8Array || - e instanceof Uint8ClampedArray || - e instanceof Int8Array || - W('Cannot pass non-string to std::string') - var l = (c && g - ? function () { - for (var m = 0, n = 0; n < e.length; ++n) { - var q = e.charCodeAt(n) - 55296 <= q && - 57343 >= q && - (q = - (65536 + ((q & 1023) << 10)) | - (e.charCodeAt(++n) & 1023)) - 127 >= q - ? ++m - : (m = 2047 >= q ? m + 2 : 65535 >= q ? m + 3 : m + 4) - } - return m - } - : function () { - return e.length - })(), - h = lb(4 + l + 1) - I[h >> 2] = l - if (c && g) la(e, h + 4, l + 1) - else if (g) - for (g = 0; g < l; ++g) { - var k = e.charCodeAt(g) - 255 < k && - (Y(h), - W('String has UTF-16 code units that do not fit in 8 bits')) - B[h + 4 + g] = k - } - else for (g = 0; g < l; ++g) B[h + 4 + g] = e[g] - null !== d && d.push(Y, h) - return h - }, - argPackAdvance: 8, - readValueFromPointer: P, - D: function (d) { - Y(d) - }, - }) - }, - h: function (a, b, c) { - c = V(c) - if (2 === b) { - var d = na - var e = oa - var g = pa - var l = function () { - return C - } - var h = 1 - } else - 4 === b && - ((d = qa), - (e = ra), - (g = sa), - (l = function () { - return I - }), - (h = 2)) - U(a, { - name: c, - fromWireType: function (k) { - for (var m = I[k >> 2], n = l(), q, w = k + 4, x = 0; x <= m; ++x) { - var p = k + 4 + x * b - if (x == m || 0 == n[p >> h]) - (w = d(w, p - w)), - void 0 === q - ? (q = w) - : ((q += String.fromCharCode(0)), (q += w)), - (w = p + b) - } - Y(k) - return q - }, - toWireType: function (k, m) { - 'string' !== typeof m && - W('Cannot pass non-string to C++ string type ' + c) - var n = g(m), - q = lb(4 + n + b) - I[q >> 2] = n >> h - e(m, q + 4, n + b) - null !== k && k.push(Y, q) - return q - }, - argPackAdvance: 8, - readValueFromPointer: P, - D: function (k) { - Y(k) - }, - }) - }, - n: function (a, b, c, d, e, g) { - O[a] = { name: V(b), R: Z(c, d), S: Z(e, g), I: [] } - }, - b: function (a, b, c, d, e, g, l, h, k, m) { - O[a].I.push({ K: V(b), O: c, M: Z(d, e), N: g, U: l, T: Z(h, k), V: m }) - }, - t: function (a, b) { - b = V(b) - U(a, { - W: !0, - name: b, - argPackAdvance: 0, - fromWireType: function () {}, - toWireType: function () {}, - }) - }, - g: Qa, - v: function (a) { - if (0 === a) return Ra(gb()) - var b = fb[a] - a = void 0 === b ? V(a) : b - return Ra(gb()[a]) - }, - u: function (a) { - 4 < a && (X[a].H += 1) - }, - p: function (a, b, c, d) { - a || W('Cannot use deleted val. handle = ' + a) - a = X[a].value - var e = hb[b] - if (!e) { - e = '' - for (var g = 0; g < b; ++g) e += (0 !== g ? ', ' : '') + 'arg' + g - var l = - 'return function emval_allocator_' + - b + - '(constructor, argTypes, args) {\n' - for (g = 0; g < b; ++g) - l += - 'var argType' + - g + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - g + - '], "parameter ' + - g + - '");\nvar arg' + - g + - ' = argType' + - g + - '.readValueFromPointer(args);\nargs += argType' + - g + - "['argPackAdvance'];\n" - e = new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - l + - ('var obj = new constructor(' + - e + - ');\nreturn __emval_register(obj);\n}\n') - )(Xa, f, Ra) - hb[b] = e - } - return e(a, c, d) - }, - j: function () { - u() - }, - q: function (a, b, c) { - B.copyWithin(a, b, b + c) - }, - e: function (a) { - a >>>= 0 - var b = B.length - if (2147483648 < a) return !1 - for (var c = 1; 4 >= c; c *= 2) { - var d = b * (1 + 0.2 / c) - d = Math.min(d, a + 100663296) - d = Math.max(16777216, a, d) - 0 < d % 65536 && (d += 65536 - (d % 65536)) - a: { - try { - A.grow((Math.min(2147483648, d) - G.byteLength + 65535) >>> 16) - va(A.buffer) - var e = 1 - break a - } catch (g) {} - e = void 0 - } - if (e) return !0 - } - return !1 - }, - a: A, - } - ;(function () { - function a(e) { - f.asm = e.exports - J = f.asm.x - K-- - f.monitorRunDependencies && f.monitorRunDependencies(K) - 0 == K && - (null !== Ca && (clearInterval(Ca), (Ca = null)), - L && ((e = L), (L = null), e())) - } - function b(e) { - a(e.instance) - } - function c(e) { - return Promise.resolve() - .then(Fa) - .then(function (g) { - return WebAssembly.instantiate(g, d) - }) - .then(e, function (g) { - v('failed to asynchronously prepare wasm: ' + g) - u(g) - }) - } - var d = { a: mb } - K++ - f.monitorRunDependencies && f.monitorRunDependencies(K) - if (f.instantiateWasm) - try { - return f.instantiateWasm(d, a) - } catch (e) { - return ( - v('Module.instantiateWasm callback failed with error: ' + e), !1 - ) - } - ;(function () { - return z || - 'function' !== typeof WebAssembly.instantiateStreaming || - Da() || - 'function' !== typeof fetch - ? c(b) - : fetch(M, { credentials: 'same-origin' }).then(function (e) { - return WebAssembly.instantiateStreaming(e, d).then(b, function ( - g - ) { - v('wasm streaming compile failed: ' + g) - v('falling back to ArrayBuffer instantiation') - return c(b) - }) - }) - })().catch(ba) - return {} - })() - var kb = (f.___wasm_call_ctors = function () { - return (kb = f.___wasm_call_ctors = f.asm.y).apply(null, arguments) - }), - lb = (f._malloc = function () { - return (lb = f._malloc = f.asm.z).apply(null, arguments) - }), - Y = (f._free = function () { - return (Y = f._free = f.asm.A).apply(null, arguments) - }), - Wa = (f.___getTypeName = function () { - return (Wa = f.___getTypeName = f.asm.B).apply(null, arguments) - }) - f.___embind_register_native_and_builtin_types = function () { - return (f.___embind_register_native_and_builtin_types = f.asm.C).apply( - null, - arguments - ) - } - var nb - L = function ob() { - nb || pb() - nb || (L = ob) - } - function pb() { - function a() { - if (!nb && ((nb = !0), (f.calledRun = !0), !ja)) { - N(ya) - N(za) - aa(f) - if (f.onRuntimeInitialized) f.onRuntimeInitialized() - if (f.postRun) - for ( - 'function' == typeof f.postRun && (f.postRun = [f.postRun]); - f.postRun.length; - - ) { - var b = f.postRun.shift() - Aa.unshift(b) - } - N(Aa) - } - } - if (!(0 < K)) { - if (f.preRun) - for ( - 'function' == typeof f.preRun && (f.preRun = [f.preRun]); - f.preRun.length; - - ) - Ba() - N(xa) - 0 < K || - (f.setStatus - ? (f.setStatus('Running...'), - setTimeout(function () { - setTimeout(function () { - f.setStatus('') - }, 1) - a() - }, 1)) - : a()) - } - } - f.run = pb - if (f.preInit) - for ( - 'function' == typeof f.preInit && (f.preInit = [f.preInit]); - 0 < f.preInit.length; - - ) - f.preInit.pop()() - noExitRuntime = !0 - pb() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.wasm b/packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.wasm deleted file mode 100644 index c1b08f136c12a..0000000000000 Binary files a/packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.wasm and /dev/null differ diff --git a/packages/next/package.json b/packages/next/package.json index 96eb5856caa03..875bfa1b40fa1 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -87,7 +87,7 @@ "get-orientation": "1.1.2", "https-browserify": "1.0.0", "image-size": "1.0.0", - "jest-worker": "27.0.0-next.5", + "jest-worker": "27.0.6", "native-url": "0.3.4", "node-fetch": "2.6.1", "node-html-parser": "1.4.9", @@ -153,6 +153,7 @@ "@babel/traverse": "^7.12.10", "@babel/types": "7.12.12", "@next/polyfill-nomodule": "11.0.2-canary.3", + "@squoosh/lib": "0.3.1", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", "@taskr/watch": "1.1.0", diff --git a/yarn.lock b/yarn.lock index f5cae140c25d8..bc928becec1c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3580,6 +3580,13 @@ dependencies: "@sinonjs/commons" "^1.7.0" +"@squoosh/lib@0.3.1": + version "0.3.1" + resolved "https://registry.yarnpkg.com/@squoosh/lib/-/lib-0.3.1.tgz#de022198f82837086c8e4e91b892dcfbbb420e17" + integrity sha512-ni8gyTGgW9lH/yqaqgkxerGT7daSWNU9mtvWqj+/1qqzIT9YGfFvnTtDQRMIRjRCKQ5pkK/COufvWKuzHI6Dxw== + dependencies: + web-streams-polyfill "^3.0.3" + "@svgr/babel-plugin-add-jsx-attribute@^5.4.0": version "5.4.0" resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-5.4.0.tgz#81ef61947bb268eb9d50523446f9c638fb355906" @@ -5998,7 +6005,7 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@1.0.30001228, caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001020, caniuse-lite@^1.0.30001093, caniuse-lite@^1.0.30001165, caniuse-lite@^1.0.30001202, caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001228: +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001020, caniuse-lite@^1.0.30001093, caniuse-lite@^1.0.30001165, caniuse-lite@^1.0.30001202, caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001228: version "1.0.30001228" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz#bfdc5942cd3326fa51ee0b42fbef4da9d492a7fa" integrity sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A== @@ -11389,10 +11396,10 @@ jest-watcher@^27.0.0-next.8: jest-util "^27.0.0-next.8" string-length "^4.0.1" -jest-worker@27.0.0-next.5, jest-worker@^27.0.0-next.5: - version "27.0.0-next.5" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.0.0-next.5.tgz#5985ee29b12a4e191f4aae4bb73b97971d86ec28" - integrity sha512-mk0umAQ5lT+CaOJ+Qp01N6kz48sJG2kr2n1rX0koqKf6FIygQV0qLOdN9SCYID4IVeSigDOcPeGLozdMLYfb5g== +jest-worker@27.0.6: + version "27.0.6" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.0.6.tgz#a5fdb1e14ad34eb228cfe162d9f729cdbfa28aed" + integrity sha512-qupxcj/dRuA3xHPMUd40gr2EaAurFbkwzOh7wfPaeE9id7hyjURRQoqNfHifHK3XjJU6YJJUQKILGUnwGPEOCA== dependencies: "@types/node" "*" merge-stream "^2.0.0" @@ -11407,6 +11414,15 @@ jest-worker@^26.2.1, jest-worker@^26.6.2: merge-stream "^2.0.0" supports-color "^7.0.0" +jest-worker@^27.0.0-next.5: + version "27.0.0-next.5" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.0.0-next.5.tgz#5985ee29b12a4e191f4aae4bb73b97971d86ec28" + integrity sha512-mk0umAQ5lT+CaOJ+Qp01N6kz48sJG2kr2n1rX0koqKf6FIygQV0qLOdN9SCYID4IVeSigDOcPeGLozdMLYfb5g== + dependencies: + "@types/node" "*" + merge-stream "^2.0.0" + supports-color "^8.0.0" + jest-worker@^27.0.0-next.8: version "27.0.0-next.8" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.0.0-next.8.tgz#70656d41d50d2563ff7f4b54ab8f7605518a36f2" @@ -19045,6 +19061,11 @@ web-streams-polyfill@2.1.1: resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-2.1.1.tgz#2c82b6193849ccb9efaa267772c28260ef68d6d2" integrity sha512-dlNpL2aab3g8CKfGz6rl8FNmGaRWLLn2g/DtSc9IjB30mEdE6XxzPfPSig5BwGSzI+oLxHyETrQGKjrVVhbLCg== +web-streams-polyfill@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.0.3.tgz#f49e487eedeca47a207c1aee41ee5578f884b42f" + integrity sha512-d2H/t0eqRNM4w2WvmTdoeIvzAUSpK7JmATB8Nr2lb7nQ9BTIJVjbQ/TRFVEh2gUH1HwclPdoPtfMoFfetXaZnA== + web-vitals@0.2.4: version "0.2.4" resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-0.2.4.tgz#ec3df43c834a207fd7cdefd732b2987896e08511"