diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 23dbcc36d8..ac19f88b62 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -27,7 +27,6 @@ /**/*image*/** @timneutkens @ijjk @shuding @styfle @huozhi @ztanner @vercel/devex /**/*img* @timneutkens @ijjk @shuding @styfle @huozhi @ztanner @vercel/devex /packages/next/client/use-intersection.tsx @timneutkens @ijjk @shuding @styfle -/packages/next/server/lib/squoosh/ @timneutkens @ijjk @shuding @styfle /packages/next/server/serve-static.ts @timneutkens @ijjk @shuding @styfle @huozhi @ztanner /packages/next/server/config.ts @timneutkens @ijjk @shuding @styfle @huozhi @ztanner diff --git a/docs/03-pages/02-api-reference/01-components/image-legacy.mdx b/docs/03-pages/02-api-reference/01-components/image-legacy.mdx index b2b81a7d10..f8d3aa52e3 100644 --- a/docs/03-pages/02-api-reference/01-components/image-legacy.mdx +++ b/docs/03-pages/02-api-reference/01-components/image-legacy.mdx @@ -443,8 +443,6 @@ If you need a different provider, you can use the [`loader`](#loader) prop with > Images can not be optimized at build time using [`output: 'export'`](/docs/pages/building-your-application/deploying/static-exports), only on-demand. To use `next/legacy/image` with `output: 'export'`, you will need to use a different loader than the default. [Read more in the discussion.](https://github.com/vercel/next.js/discussions/19065) -> The `next/legacy/image` component's default loader uses [`squoosh`](https://www.npmjs.com/package/@squoosh/lib) because it is quick to install and suitable for a development environment. When using `next start` in your production environment, it is strongly recommended that you install [`sharp`](https://www.npmjs.com/package/sharp) by running `npm i sharp` in your project directory. This is not necessary for Vercel deployments, as `sharp` is installed automatically. - ## Advanced The following configuration is for advanced use cases and is usually not necessary. If you choose to configure the properties below, you will override any changes to the Next.js defaults in future updates. diff --git a/package.json b/package.json index 0078056dc1..d5e56bdf4e 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,6 @@ "@types/react-dom": "18.2.23", "@types/relay-runtime": "14.1.13", "@types/selenium-webdriver": "4.0.15", - "@types/sharp": "0.29.3", "@types/string-hash": "1.1.1", "@types/trusted-types": "2.0.3", "@typescript-eslint/eslint-plugin": "6.14.0", @@ -160,7 +159,7 @@ "html-validator": "5.1.18", "http-proxy": "1.18.1", "husky": "8.0.0", - "image-size": "0.9.3", + "image-size": "1.1.1", "is-animated": "2.0.2", "isomorphic-unfetch": "3.0.0", "jest": "29.7.0", diff --git a/packages/next/package.json b/packages/next/package.json index d3b9650198..ae1699c020 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -119,6 +119,9 @@ "optional": true } }, + "optionalDependencies": { + "sharp": "^0.33.3" + }, "devDependencies": { "@ampproject/toolbox-optimizer": "2.8.3", "@babel/code-frame": "7.22.5", @@ -234,7 +237,6 @@ "events": "3.3.0", "find-up": "4.1.0", "fresh": "0.5.2", - "get-orientation": "1.1.2", "glob": "7.1.7", "gzip-size": "5.1.1", "http-proxy": "1.18.1", @@ -243,7 +245,7 @@ "https-proxy-agent": "5.0.1", "icss-utils": "5.1.0", "ignore-loader": "0.1.2", - "image-size": "1.0.0", + "image-size": "1.1.1", "is-docker": "2.0.0", "is-wsl": "2.2.0", "jest-worker": "27.5.1", diff --git a/packages/next/src/build/collect-build-traces.ts b/packages/next/src/build/collect-build-traces.ts index 86cdcc4933..1eaf3712ea 100644 --- a/packages/next/src/build/collect-build-traces.ts +++ b/packages/next/src/build/collect-build-traces.ts @@ -305,7 +305,6 @@ export async function collectBuildTraces({ // only ignore image-optimizer code when // this is being handled outside of next-server '**/next/dist/server/image-optimizer.js', - '**/next/dist/server/lib/squoosh/**/*.wasm', ] : []), diff --git a/packages/next/src/build/webpack/loaders/next-image-loader/index.ts b/packages/next/src/build/webpack/loaders/next-image-loader/index.ts index bc663535ae..c961382610 100644 --- a/packages/next/src/build/webpack/loaders/next-image-loader/index.ts +++ b/packages/next/src/build/webpack/loaders/next-image-loader/index.ts @@ -33,7 +33,7 @@ function nextImageLoader(this: any, content: Buffer) { const imageSizeSpan = imageLoaderSpan.traceChild('image-size-calculation') const imageSize = await imageSizeSpan.traceAsyncFn(() => - getImageSize(content, extension).catch((err) => err) + getImageSize(content).catch((err) => err) ) if (imageSize instanceof Error) { diff --git a/packages/next/src/build/webpack/loaders/next-metadata-image-loader.ts b/packages/next/src/build/webpack/loaders/next-metadata-image-loader.ts index 6c94c32c1e..7f35358d5f 100644 --- a/packages/next/src/build/webpack/loaders/next-metadata-image-loader.ts +++ b/packages/next/src/build/webpack/loaders/next-metadata-image-loader.ts @@ -127,8 +127,7 @@ async function nextMetadataImageLoader( } const imageSize: { width?: number; height?: number } = await getImageSize( - content, - extension as 'avif' | 'webp' | 'png' | 'jpeg' + content ).catch((err) => err) if (imageSize instanceof Error) { diff --git a/packages/next/src/compiled/get-orientation/LICENSE b/packages/next/src/compiled/get-orientation/LICENSE deleted file mode 100644 index 9540593494..0000000000 --- a/packages/next/src/compiled/get-orientation/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -The MIT License (MIT) -Copyright © 2019 MooYeol Prescott Lee, http://debug.so - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the “Software”), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/packages/next/src/compiled/get-orientation/index.js b/packages/next/src/compiled/get-orientation/index.js deleted file mode 100644 index 7885ca5e95..0000000000 --- a/packages/next/src/compiled/get-orientation/index.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{var e={780:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});var r;(function(e){e[e["TOP_LEFT"]=1]="TOP_LEFT";e[e["TOP_RIGHT"]=2]="TOP_RIGHT";e[e["BOTTOM_RIGHT"]=3]="BOTTOM_RIGHT";e[e["BOTTOM_LEFT"]=4]="BOTTOM_LEFT";e[e["LEFT_TOP"]=5]="LEFT_TOP";e[e["RIGHT_TOP"]=6]="RIGHT_TOP";e[e["RIGHT_BOTTOM"]=7]="RIGHT_BOTTOM";e[e["LEFT_BOTTOM"]=8]="LEFT_BOTTOM"})(r=t.Orientation||(t.Orientation={}))},330:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});const s=r(781);const i=r(300);class StreamParserWritableClass extends s.Writable{constructor(){super();i(this)}}t.StreamParserWritable=StreamParserWritableClass},300:(e,t,r)=>{var s=r(491);var i=r(937)("stream-parser");e.exports=Parser;var n=-1;var a=0;var o=1;var f=2;function Parser(e){var t=e&&"function"==typeof e._transform;var r=e&&"function"==typeof e._write;if(!t&&!r)throw new Error("must pass a Writable or Transform stream in");i("extending Parser into stream");e._bytes=_bytes;e._skipBytes=_skipBytes;if(t)e._passthrough=_passthrough;if(t){e._transform=transform}else{e._write=write}}function init(e){i("initializing parser stream");e._parserBytesLeft=0;e._parserBuffers=[];e._parserBuffered=0;e._parserState=n;e._parserCallback=null;if("function"==typeof e.push){e._parserOutput=e.push.bind(e)}e._parserInit=true}function _bytes(e,t){s(!this._parserCallback,'there is already a "callback" set!');s(isFinite(e)&&e>0,'can only buffer a finite number of bytes > 0, got "'+e+'"');if(!this._parserInit)init(this);i("buffering %o bytes",e);this._parserBytesLeft=e;this._parserCallback=t;this._parserState=a}function _skipBytes(e,t){s(!this._parserCallback,'there is already a "callback" set!');s(e>0,'can only skip > 0 bytes, got "'+e+'"');if(!this._parserInit)init(this);i("skipping %o bytes",e);this._parserBytesLeft=e;this._parserCallback=t;this._parserState=o}function _passthrough(e,t){s(!this._parserCallback,'There is already a "callback" set!');s(e>0,'can only pass through > 0 bytes, got "'+e+'"');if(!this._parserInit)init(this);i("passing through %o bytes",e);this._parserBytesLeft=e;this._parserCallback=t;this._parserState=f}function write(e,t,r){if(!this._parserInit)init(this);i("write(%o bytes)",e.length);if("function"==typeof t)r=t;_(this,e,null,r)}function transform(e,t,r){if(!this._parserInit)init(this);i("transform(%o bytes)",e.length);if("function"!=typeof t){t=this._parserOutput}_(this,e,t,r)}function _data(e,t,r,s){if(e._parserBytesLeft<=0){return s(new Error("got data but not currently parsing anything"))}if(t.length<=e._parserBytesLeft){return function(){return process(e,t,r,s)}}else{return function(){var i=t.slice(0,e._parserBytesLeft);return process(e,i,r,(function(n){if(n)return s(n);if(t.length>i.length){return function(){return _data(e,t.slice(i.length),r,s)}}}))}}}function process(e,t,r,s){e._parserBytesLeft-=t.length;i("%o bytes left for stream piece",e._parserBytesLeft);if(e._parserState===a){e._parserBuffers.push(t);e._parserBuffered+=t.length}else if(e._parserState===f){r(t)}if(0===e._parserBytesLeft){var o=e._parserCallback;if(o&&e._parserState===a&&e._parserBuffers.length>1){t=Buffer.concat(e._parserBuffers,e._parserBuffered)}if(e._parserState!==a){t=null}e._parserCallback=null;e._parserBuffered=0;e._parserState=n;e._parserBuffers.splice(0);if(o){var _=[];if(t){_.push(t)}else{}if(r){_.push(r)}var p=o.length>_.length;if(p){_.push(trampoline(s))}var u=o.apply(e,_);if(!p||s===u)return s}}else{return s}}var _=trampoline(_data);function trampoline(e){return function(){var t=e.apply(this,arguments);while("function"==typeof t){t=t()}return t}}},491:e=>{"use strict";e.exports=require("assert")},937:e=>{"use strict";e.exports=require("next/dist/compiled/debug")},781:e=>{"use strict";e.exports=require("stream")}};var t={};function __nccwpck_require__(r){var s=t[r];if(s!==undefined){return s.exports}var i=t[r]={exports:{}};var n=true;try{e[r](i,i.exports,__nccwpck_require__);n=false}finally{if(n)delete t[r]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r={};(()=>{"use strict";var e=r;Object.defineProperty(e,"__esModule",{value:true});const t=__nccwpck_require__(781);const s=__nccwpck_require__(780);e.Orientation=s.Orientation;const i=__nccwpck_require__(330);const noop=()=>{};class EXIFOrientationParser extends i.StreamParserWritable{constructor(){super();this._bytes(4,this.onSignature.bind(this))}onSignature(e){const t=e.readUInt16BE(0);const r=e.readUInt16BE(2);if(t===65496){this.onJPEGMarker(e.slice(2))}else if(t===18761&&r===10752||t===19789&&r===42){this._bytes(4,(t=>{this.onTIFFHeader(Buffer.concat([e,t]))}))}else{this._skipBytes(Infinity,noop)}}onJPEGMarker(e){const t=e.readUInt16BE(0);if(t===65505){this._bytes(8,(e=>{const t=e.readUInt16BE(2)===17784&&e.readUInt16BE(4)===26982&&e.readUInt16BE(6)===0;if(t){this._bytes(8,this.onTIFFHeader.bind(this))}else{const t=e.readUInt16BE(0);const r=t-6;this._skipBytes(r,(()=>{this._bytes(2,this.onJPEGMarker.bind(this))}))}}))}else if(65504<=t&&t<=65519){this._bytes(2,(t=>{const r=t.readUInt16BE(0);const s=r-e.length;this._skipBytes(s,(()=>{this._bytes(2,this.onJPEGMarker.bind(this))}))}))}else{this._skipBytes(Infinity,noop)}}onTIFFHeader(e){const t=e.readUInt16BE(0)===18761;const readUInt16=(e,r)=>t?e.readUInt16LE(r):e.readUInt16BE(r);const readUInt32=(e,r)=>t?e.readUInt32LE(r):e.readUInt32BE(r);const r=readUInt32(e,4);const s=r-e.length;const consumeIDFBlock=()=>{this._bytes(2,(e=>{let t=readUInt16(e,0);const consumeIFDFields=()=>{if(t-- >0){this._bytes(12,(e=>{const t=readUInt16(e,0);if(t===274){const t=e.slice(8,12);const r=readUInt16(t,0);if(1<=r&&r<=8){this.emit("orientation",r)}else{this.emit("error",new Error("Unexpected Orientation value"))}this._skipBytes(Infinity,noop)}else{consumeIFDFields()}}))}else{this._skipBytes(Infinity,noop)}};consumeIFDFields()}))};if(s>0){this._skipBytes(s,consumeIDFBlock)}else{consumeIDFBlock()}}}e.EXIFOrientationParser=EXIFOrientationParser;function getOrientation(e){return new Promise(((r,i)=>{const n=(new EXIFOrientationParser).once("error",onError).once("finish",onFinish).once("orientation",onOrientation);let a=false;function onError(e){n.removeListener("finish",onFinish);n.removeListener("orientation",onOrientation);if(!a){a=true;i(e)}}function onFinish(){n.removeListener("error",onError);n.removeListener("orientation",onOrientation);if(!a){a=true;r(s.Orientation.TOP_LEFT)}}function onOrientation(e){n.removeListener("error",onError);n.removeListener("finish",onFinish);if(!a){a=true;r(e)}}if(Buffer.isBuffer(e)){n.end(e)}else if(e instanceof t.Readable){e.pipe(n)}else{throw new TypeError("Unexpected input type")}}))}e.getOrientation=getOrientation})();module.exports=r})(); \ No newline at end of file diff --git a/packages/next/src/compiled/get-orientation/package.json b/packages/next/src/compiled/get-orientation/package.json deleted file mode 100644 index e456919fce..0000000000 --- a/packages/next/src/compiled/get-orientation/package.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"get-orientation","main":"index.js","author":"MooYeol Prescott Lee ","license":"MIT"} diff --git a/packages/next/src/compiled/image-size/LICENSE b/packages/next/src/compiled/image-size/LICENSE index 1341a90d56..8bdffcff7d 100644 --- a/packages/next/src/compiled/image-size/LICENSE +++ b/packages/next/src/compiled/image-size/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright © 2017 Aditya Yadav, http://netroy.in +Copyright © 2013-Present Aditya Yadav, http://netroy.in Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/packages/next/src/compiled/image-size/index.js b/packages/next/src/compiled/image-size/index.js index f3fb40d147..59a0fa2aa6 100644 --- a/packages/next/src/compiled/image-size/index.js +++ b/packages/next/src/compiled/image-size/index.js @@ -1 +1 @@ -(()=>{var t={399:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.detector=void 0;const r=n(230);const i=Object.keys(r.typeHandlers);const s={56:"psd",66:"bmp",68:"dds",71:"gif",73:"tiff",77:"tiff",82:"webp",105:"icns",137:"png",255:"jpg"};function detector(t){const e=t[0];if(e in s){const n=s[e];if(n&&r.typeHandlers[n].validate(t)){return n}}const finder=e=>r.typeHandlers[e].validate(t);return i.find(finder)}e.detector=detector},501:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){function adopt(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,i){function fulfilled(t){try{step(r.next(t))}catch(t){i(t)}}function rejected(t){try{step(r["throw"](t))}catch(t){i(t)}}function step(t){t.done?n(t.value):adopt(t.value).then(fulfilled,rejected)}step((r=r.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:true});e.types=e.setConcurrency=e.disableTypes=e.disableFS=e.imageSize=void 0;const i=n(147);const s=n(17);const o=n(927);const c=n(230);const a=n(399);const u=512*1024;const l=new o.default({concurrency:100,autostart:true});const d={disabledFS:false,disabledTypes:[]};function lookup(t,e){const n=a.detector(t);if(typeof n!=="undefined"){if(d.disabledTypes.indexOf(n)>-1){throw new TypeError("disabled file type: "+n)}if(n in c.typeHandlers){const r=c.typeHandlers[n].calculate(t,e);if(r!==undefined){r.type=n;return r}}}throw new TypeError("unsupported file type: "+n+" (file: "+e+")")}function asyncFileToBuffer(t){return r(this,void 0,void 0,(function*(){const e=yield i.promises.open(t,"r");const{size:n}=yield e.stat();if(n<=0){yield e.close();throw new Error("Empty file")}const r=Math.min(n,u);const s=Buffer.alloc(r);yield e.read(s,0,r,0);yield e.close();return s}))}function syncFileToBuffer(t){const e=i.openSync(t,"r");const{size:n}=i.fstatSync(e);if(n<=0){i.closeSync(e);throw new Error("Empty file")}const r=Math.min(n,u);const s=Buffer.alloc(r);i.readSync(e,s,0,r,0);i.closeSync(e);return s}t.exports=e=imageSize;e["default"]=imageSize;function imageSize(t,e){if(Buffer.isBuffer(t)){return lookup(t)}if(typeof t!=="string"||d.disabledFS){throw new TypeError("invalid invocation. input should be a Buffer")}const n=s.resolve(t);if(typeof e==="function"){l.push((()=>asyncFileToBuffer(n).then((t=>process.nextTick(e,null,lookup(t,n)))).catch(e)))}else{const t=syncFileToBuffer(n);return lookup(t,n)}}e.imageSize=imageSize;const disableFS=t=>{d.disabledFS=t};e.disableFS=disableFS;const disableTypes=t=>{d.disabledTypes=t};e.disableTypes=disableTypes;const setConcurrency=t=>{l.concurrency=t};e.setConcurrency=setConcurrency;e.types=Object.keys(c.typeHandlers)},326:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.readUInt=void 0;function readUInt(t,e,n,r){n=n||0;const i=r?"BE":"LE";const s="readUInt"+e+i;return t[s].call(t,n)}e.readUInt=readUInt},230:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.typeHandlers=void 0;const r=n(798);const i=n(925);const s=n(813);const o=n(259);const c=n(341);const a=n(541);const u=n(852);const l=n(182);const d=n(32);const h=n(707);const f=n(179);const p=n(457);const g=n(438);const y=n(12);const v=n(167);const w=n(185);e.typeHandlers={bmp:r.BMP,cur:i.CUR,dds:s.DDS,gif:o.GIF,icns:c.ICNS,ico:a.ICO,j2c:u.J2C,jp2:l.JP2,jpg:d.JPG,ktx:h.KTX,png:f.PNG,pnm:p.PNM,psd:g.PSD,svg:y.SVG,tiff:v.TIFF,webp:w.WEBP}},798:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.BMP=void 0;e.BMP={validate(t){return"BM"===t.toString("ascii",0,2)},calculate(t){return{height:Math.abs(t.readInt32LE(22)),width:t.readUInt32LE(18)}}}},925:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.CUR=void 0;const r=n(541);const i=2;e.CUR={validate(t){if(t.readUInt16LE(0)!==0){return false}return t.readUInt16LE(2)===i},calculate(t){return r.ICO.calculate(t)}}},813:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.DDS=void 0;e.DDS={validate(t){return t.readUInt32LE(0)===542327876},calculate(t){return{height:t.readUInt32LE(12),width:t.readUInt32LE(16)}}}},259:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.GIF=void 0;const n=/^GIF8[79]a/;e.GIF={validate(t){const e=t.toString("ascii",0,6);return n.test(e)},calculate(t){return{height:t.readUInt16LE(8),width:t.readUInt16LE(6)}}}},341:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.ICNS=void 0;const n=4+4;const r=4;const i=4;const s={ICON:32,"ICN#":32,"icm#":16,icm4:16,icm8:16,"ics#":16,ics4:16,ics8:16,is32:16,s8mk:16,icp4:16,icl4:32,icl8:32,il32:32,l8mk:32,icp5:32,ic11:32,ich4:48,ich8:48,ih32:48,h8mk:48,icp6:64,ic12:32,it32:128,t8mk:128,ic07:128,ic08:256,ic13:256,ic09:512,ic14:512,ic10:1024};function readImageHeader(t,e){const n=e+i;return[t.toString("ascii",e,n),t.readUInt32BE(n)]}function getImageSize(t){const e=s[t];return{width:e,height:e,type:t}}e.ICNS={validate(t){return"icns"===t.toString("ascii",0,4)},calculate(t){const e=t.length;const i=t.readUInt32BE(r);let s=n;let o=readImageHeader(t,s);let c=getImageSize(o[0]);s+=o[1];if(s===i){return c}const a={height:c.height,images:[c],width:c.width};while(s{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.ICO=void 0;const n=1;const r=2+2+2;const i=1+1+1+1+2+2+4+4;function getSizeFromOffset(t,e){const n=t.readUInt8(e);return n===0?256:n}function getImageSize(t,e){const n=r+e*i;return{height:getSizeFromOffset(t,n+1),width:getSizeFromOffset(t,n)}}e.ICO={validate(t){if(t.readUInt16LE(0)!==0){return false}return t.readUInt16LE(2)===n},calculate(t){const e=t.readUInt16LE(4);const n=getImageSize(t,0);if(e===1){return n}const r=[n];for(let n=1;n{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.J2C=void 0;e.J2C={validate(t){return t.toString("hex",0,4)==="ff4fff51"},calculate(t){return{height:t.readUInt32BE(12),width:t.readUInt32BE(8)}}}},182:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.JP2=void 0;const n={ftyp:"66747970",ihdr:"69686472",jp2h:"6a703268",jp__:"6a502020",rreq:"72726571",xml_:"786d6c20"};const calculateRREQLength=t=>{const e=t.readUInt8(0);let n=1+2*e;const r=t.readUInt16BE(n);const i=r*(2+e);n=n+2+i;const s=t.readUInt16BE(n);const o=s*(16+e);return n+2+o};const parseIHDR=t=>({height:t.readUInt32BE(4),width:t.readUInt32BE(8)});e.JP2={validate(t){const e=t.toString("hex",4,8);const r=t.readUInt32BE(0);if(e!==n.jp__||r<1){return false}const i=r+4;const s=t.readUInt32BE(r);const o=t.slice(i,i+s);return o.toString("hex",0,4)===n.ftyp},calculate(t){const e=t.readUInt32BE(0);const r=t.readUInt16BE(e+2);let i=e+4+r;const s=t.toString("hex",i,i+4);switch(s){case n.rreq:const e=4;i=i+4+e+calculateRREQLength(t.slice(i+4));return parseIHDR(t.slice(i+8,i+24));case n.jp2h:return parseIHDR(t.slice(i+8,i+24));default:throw new TypeError("Unsupported header found: "+t.toString("ascii",i,i+4))}}}},32:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.JPG=void 0;const r=n(326);const i="45786966";const s=2;const o=6;const c=2;const a="4d4d";const u="4949";const l=12;const d=2;function isEXIF(t){return t.toString("hex",2,6)===i}function extractSize(t,e){return{height:t.readUInt16BE(e),width:t.readUInt16BE(e+2)}}function extractOrientation(t,e){const n=8;const i=o+n;const s=r.readUInt(t,16,i,e);for(let n=0;nt.length){return}const c=t.slice(s,o);const a=r.readUInt(c,16,0,e);if(a===274){const t=r.readUInt(c,16,2,e);if(t!==3){return}const n=r.readUInt(c,32,4,e);if(n!==1){return}return r.readUInt(c,16,8,e)}}}function validateExifBlock(t,e){const n=t.slice(s,e);const r=n.toString("hex",o,o+c);const i=r===a;const l=r===u;if(i||l){return extractOrientation(n,i)}}function validateBuffer(t,e){if(e>t.length){throw new TypeError("Corrupt JPG, exceeded buffer limits")}if(t[e]!==255){throw new TypeError("Invalid JPG, marker table corrupted")}}e.JPG={validate(t){const e=t.toString("hex",0,2);return"ffd8"===e},calculate(t){t=t.slice(4);let e;let n;while(t.length){const r=t.readUInt16BE(0);if(isEXIF(t)){e=validateExifBlock(t,r)}validateBuffer(t,r);n=t[r+1];if(n===192||n===193||n===194){const n=extractSize(t,r+5);if(!e){return n}return{height:n.height,orientation:e,width:n.width}}t=t.slice(r+2)}throw new TypeError("Invalid JPG, no size found")}}},707:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.KTX=void 0;const n="KTX 11";e.KTX={validate(t){return n===t.toString("ascii",1,7)},calculate(t){return{height:t.readUInt32LE(40),width:t.readUInt32LE(36)}}}},179:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.PNG=void 0;const n="PNG\r\n\n";const r="IHDR";const i="CgBI";e.PNG={validate(t){if(n===t.toString("ascii",1,8)){let e=t.toString("ascii",12,16);if(e===i){e=t.toString("ascii",28,32)}if(e!==r){throw new TypeError("Invalid PNG")}return true}return false},calculate(t){if(t.toString("ascii",12,16)===i){return{height:t.readUInt32BE(36),width:t.readUInt32BE(32)}}return{height:t.readUInt32BE(20),width:t.readUInt32BE(16)}}}},457:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.PNM=void 0;const n={P1:"pbm/ascii",P2:"pgm/ascii",P3:"ppm/ascii",P4:"pbm",P5:"pgm",P6:"ppm",P7:"pam",PF:"pfm"};const r=Object.keys(n);const i={default:t=>{let e=[];while(t.length>0){const n=t.shift();if(n[0]==="#"){continue}e=n.split(" ");break}if(e.length===2){return{height:parseInt(e[1],10),width:parseInt(e[0],10)}}else{throw new TypeError("Invalid PNM")}},pam:t=>{const e={};while(t.length>0){const n=t.shift();if(n.length>16||n.charCodeAt(0)>128){continue}const[r,i]=n.split(" ");if(r&&i){e[r.toLowerCase()]=parseInt(i,10)}if(e.height&&e.width){break}}if(e.height&&e.width){return{height:e.height,width:e.width}}else{throw new TypeError("Invalid PAM")}}};e.PNM={validate(t){const e=t.toString("ascii",0,2);return r.includes(e)},calculate(t){const e=t.toString("ascii",0,2);const r=n[e];const s=t.toString("ascii",3).split(/[\r\n]+/);const o=i[r]||i.default;return o(s)}}},438:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.PSD=void 0;e.PSD={validate(t){return"8BPS"===t.toString("ascii",0,4)},calculate(t){return{height:t.readUInt32BE(14),width:t.readUInt32BE(18)}}}},12:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.SVG=void 0;const n=/"']|"[^"]*"|'[^']*')*>/;const r={height:/\sheight=(['"])([^%]+?)\1/,root:n,viewbox:/\sviewBox=(['"])(.+?)\1/i,width:/\swidth=(['"])([^%]+?)\1/};const i=2.54;const s={in:96,cm:96/i,em:16,ex:8,m:96/i*100,mm:96/i/10,pc:96/72/12,pt:96/72,px:1};const o=new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(s).join("|")})?$`);function parseLength(t){const e=o.exec(t);if(!e){return undefined}return Math.round(Number(e[1])*(s[e[2]]||1))}function parseViewbox(t){const e=t.split(" ");return{height:parseLength(e[3]),width:parseLength(e[2])}}function parseAttributes(t){const e=t.match(r.width);const n=t.match(r.height);const i=t.match(r.viewbox);return{height:n&&parseLength(n[2]),viewbox:i&&parseViewbox(i[2]),width:e&&parseLength(e[2])}}function calculateByDimensions(t){return{height:t.height,width:t.width}}function calculateByViewbox(t,e){const n=e.width/e.height;if(t.width){return{height:Math.floor(t.width/n),width:t.width}}if(t.height){return{height:t.height,width:Math.floor(t.height*n)}}return{height:e.height,width:e.width}}e.SVG={validate(t){const e=String(t);return n.test(e)},calculate(t){const e=t.toString("utf8").match(r.root);if(e){const t=parseAttributes(e[0]);if(t.width&&t.height){return calculateByDimensions(t)}if(t.viewbox){return calculateByViewbox(t,t.viewbox)}}throw new TypeError("Invalid SVG")}}},167:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.TIFF=void 0;const r=n(147);const i=n(326);function readIFD(t,e,n){const s=i.readUInt(t,32,4,n);let o=1024;const c=r.statSync(e).size;if(s+o>c){o=c-s-10}const a=Buffer.alloc(o);const u=r.openSync(e,"r");r.readSync(u,a,0,o,s);r.closeSync(u);return a.slice(2)}function readValue(t,e){const n=i.readUInt(t,16,8,e);const r=i.readUInt(t,16,10,e);return(r<<16)+n}function nextTag(t){if(t.length>24){return t.slice(12)}}function extractTags(t,e){const n={};let r=t;while(r&&r.length){const t=i.readUInt(r,16,0,e);const s=i.readUInt(r,16,2,e);const o=i.readUInt(r,32,4,e);if(t===0){break}else{if(o===1&&(s===3||s===4)){n[t]=readValue(r,e)}r=nextTag(r)}}return n}function determineEndianness(t){const e=t.toString("ascii",0,2);if("II"===e){return"LE"}else if("MM"===e){return"BE"}}const s=["49492a00","4d4d002a"];e.TIFF={validate(t){return s.includes(t.toString("hex",0,4))},calculate(t,e){if(!e){throw new TypeError("Tiff doesn't support buffer")}const n=determineEndianness(t)==="BE";const r=readIFD(t,e,n);const i=extractTags(r,n);const s=i[256];const o=i[257];if(!s||!o){throw new TypeError("Invalid Tiff. Missing tags")}return{height:o,width:s}}}},185:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.WEBP=void 0;function calculateExtended(t){return{height:1+t.readUIntLE(7,3),width:1+t.readUIntLE(4,3)}}function calculateLossless(t){return{height:1+((t[4]&15)<<10|t[3]<<2|(t[2]&192)>>6),width:1+((t[2]&63)<<8|t[1])}}function calculateLossy(t){return{height:t.readInt16LE(8)&16383,width:t.readInt16LE(6)&16383}}e.WEBP={validate(t){const e="RIFF"===t.toString("ascii",0,4);const n="WEBP"===t.toString("ascii",8,12);const r="VP8"===t.toString("ascii",12,15);return e&&n&&r},calculate(t){const e=t.toString("ascii",12,16);t=t.slice(20,30);if(e==="VP8X"){const e=t[0];const n=(e&192)===0;const r=(e&1)===0;if(n&&r){return calculateExtended(t)}else{throw new TypeError("Invalid WebP")}}if(e==="VP8 "&&t[0]!==47){return calculateLossy(t)}const n=t.toString("hex",3,6);if(e==="VP8L"&&n!=="9d012a"){return calculateLossless(t)}throw new TypeError("Invalid WebP")}}},842:(t,e,n)=>{try{var r=n(837);if(typeof r.inherits!=="function")throw"";t.exports=r.inherits}catch(e){t.exports=n(782)}},782:t=>{if(typeof Object.create==="function"){t.exports=function inherits(t,e){if(e){t.super_=e;t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:false,writable:true,configurable:true}})}}}else{t.exports=function inherits(t,e){if(e){t.super_=e;var TempCtor=function(){};TempCtor.prototype=e.prototype;t.prototype=new TempCtor;t.prototype.constructor=t}}}},927:(t,e,n)=>{var r=n(842);var i=n(361).EventEmitter;t.exports=Queue;t.exports["default"]=Queue;function Queue(t){if(!(this instanceof Queue)){return new Queue(t)}i.call(this);t=t||{};this.concurrency=t.concurrency||Infinity;this.timeout=t.timeout||0;this.autostart=t.autostart||false;this.results=t.results||null;this.pending=0;this.session=0;this.running=false;this.jobs=[];this.timers={}}r(Queue,i);var s=["pop","shift","indexOf","lastIndexOf"];s.forEach((function(t){Queue.prototype[t]=function(){return Array.prototype[t].apply(this.jobs,arguments)}}));Queue.prototype.slice=function(t,e){this.jobs=this.jobs.slice(t,e);return this};Queue.prototype.reverse=function(){this.jobs.reverse();return this};var o=["push","unshift","splice"];o.forEach((function(t){Queue.prototype[t]=function(){var e=Array.prototype[t].apply(this.jobs,arguments);if(this.autostart){this.start()}return e}}));Object.defineProperty(Queue.prototype,"length",{get:function(){return this.pending+this.jobs.length}});Queue.prototype.start=function(t){if(t){callOnErrorOrEnd.call(this,t)}this.running=true;if(this.pending>=this.concurrency){return}if(this.jobs.length===0){if(this.pending===0){done.call(this)}return}var e=this;var n=this.jobs.shift();var r=true;var i=this.session;var s=null;var o=false;var c=null;var a=n.hasOwnProperty("timeout")?n.timeout:this.timeout;function next(t,a){if(r&&e.session===i){r=false;e.pending--;if(s!==null){delete e.timers[s];clearTimeout(s)}if(t){e.emit("error",t,n)}else if(o===false){if(c!==null){e.results[c]=Array.prototype.slice.call(arguments,1)}e.emit("success",a,n)}if(e.session===i){if(e.pending===0&&e.jobs.length===0){done.call(e)}else if(e.running){e.start()}}}}if(a){s=setTimeout((function(){o=true;if(e.listeners("timeout").length>0){e.emit("timeout",next,n)}else{next()}}),a);this.timers[s]=s}if(this.results){c=this.results.length;this.results[c]=null}this.pending++;e.emit("start",n);var u=n(next);if(u&&u.then&&typeof u.then==="function"){u.then((function(t){return next(null,t)})).catch((function(t){return next(t||true)}))}if(this.running&&this.jobs.length>0){this.start()}};Queue.prototype.stop=function(){this.running=false};Queue.prototype.end=function(t){clearTimers.call(this);this.jobs.length=0;this.pending=0;done.call(this,t)};function clearTimers(){for(var t in this.timers){var e=this.timers[t];delete this.timers[t];clearTimeout(e)}}function callOnErrorOrEnd(t){var e=this;this.on("error",onerror);this.on("end",onend);function onerror(t){e.end(t)}function onend(n){e.removeListener("error",onerror);e.removeListener("end",onend);t(n,this.results)}}function done(t){this.session++;this.running=false;this.emit("end",t)}},361:t=>{"use strict";t.exports=require("events")},147:t=>{"use strict";t.exports=require("fs")},17:t=>{"use strict";t.exports=require("path")},837:t=>{"use strict";t.exports=require("util")}};var e={};function __nccwpck_require__(n){var r=e[n];if(r!==undefined){return r.exports}var i=e[n]={exports:{}};var s=true;try{t[n].call(i.exports,i,i.exports,__nccwpck_require__);s=false}finally{if(s)delete e[n]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(501);module.exports=n})(); \ No newline at end of file +(()=>{var t={590:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.detector=void 0;const r=n(275);const i=Object.keys(r.typeHandlers);const o={56:"psd",66:"bmp",68:"dds",71:"gif",73:"tiff",77:"tiff",82:"webp",105:"icns",137:"png",255:"jpg"};function detector(t){const e=t[0];if(e in o){const n=o[e];if(n&&r.typeHandlers[n].validate(t)){return n}}const finder=e=>r.typeHandlers[e].validate(t);return i.find(finder)}e.detector=detector},751:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.types=e.setConcurrency=e.disableTypes=e.disableFS=e.imageSize=void 0;const r=n(147);const i=n(17);const o=n(927);const s=n(275);const c=n(590);const a=512*1024;const u=new o.default({concurrency:100,autostart:true});const d={disabledFS:false,disabledTypes:[]};function lookup(t,e){const n=(0,c.detector)(t);if(typeof n!=="undefined"){if(d.disabledTypes.indexOf(n)>-1){throw new TypeError("disabled file type: "+n)}if(n in s.typeHandlers){const r=s.typeHandlers[n].calculate(t,e);if(r!==undefined){r.type=r.type??n;return r}}}throw new TypeError("unsupported file type: "+n+" (file: "+e+")")}async function readFileAsync(t){const e=await r.promises.open(t,"r");try{const{size:t}=await e.stat();if(t<=0){throw new Error("Empty file")}const n=Math.min(t,a);const r=new Uint8Array(n);await e.read(r,0,n,0);return r}finally{await e.close()}}function readFileSync(t){const e=r.openSync(t,"r");try{const{size:t}=r.fstatSync(e);if(t<=0){throw new Error("Empty file")}const n=Math.min(t,a);const i=new Uint8Array(n);r.readSync(e,i,0,n,0);return i}finally{r.closeSync(e)}}t.exports=e=imageSize;e["default"]=imageSize;function imageSize(t,e){if(t instanceof Uint8Array){return lookup(t)}if(typeof t!=="string"||d.disabledFS){throw new TypeError("invalid invocation. input should be a Uint8Array")}const n=i.resolve(t);if(typeof e==="function"){u.push((()=>readFileAsync(n).then((t=>process.nextTick(e,null,lookup(t,n)))).catch(e)))}else{const t=readFileSync(n);return lookup(t,n)}}e.imageSize=imageSize;const disableFS=t=>{d.disabledFS=t};e.disableFS=disableFS;const disableTypes=t=>{d.disabledTypes=t};e.disableTypes=disableTypes;const setConcurrency=t=>{u.concurrency=t};e.setConcurrency=setConcurrency;e.types=Object.keys(s.typeHandlers)},683:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.BMP=void 0;const r=n(823);e.BMP={validate:t=>(0,r.toUTF8String)(t,0,2)==="BM",calculate:t=>({height:Math.abs((0,r.readInt32LE)(t,22)),width:(0,r.readUInt32LE)(t,18)})}},827:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.CUR=void 0;const r=n(345);const i=n(823);const o=2;e.CUR={validate(t){const e=(0,i.readUInt16LE)(t,0);const n=(0,i.readUInt16LE)(t,4);if(e!==0||n===0)return false;const r=(0,i.readUInt16LE)(t,2);return r===o},calculate:t=>r.ICO.calculate(t)}},387:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.DDS=void 0;const r=n(823);e.DDS={validate:t=>(0,r.readUInt32LE)(t,0)===542327876,calculate:t=>({height:(0,r.readUInt32LE)(t,12),width:(0,r.readUInt32LE)(t,16)})}},589:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.GIF=void 0;const r=n(823);const i=/^GIF8[79]a/;e.GIF={validate:t=>i.test((0,r.toUTF8String)(t,0,6)),calculate:t=>({height:(0,r.readUInt16LE)(t,8),width:(0,r.readUInt16LE)(t,6)})}},665:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.HEIF=void 0;const r=n(823);const i={avif:"avif",mif1:"heif",msf1:"heif",heic:"heic",heix:"heic",hevc:"heic",hevx:"heic"};e.HEIF={validate(t){const e=(0,r.toUTF8String)(t,4,8);const n=(0,r.toUTF8String)(t,8,12);return"ftyp"===e&&n in i},calculate(t){const e=(0,r.findBox)(t,"meta",0);const n=e&&(0,r.findBox)(t,"iprp",e.offset+12);const i=n&&(0,r.findBox)(t,"ipco",n.offset+8);const o=i&&(0,r.findBox)(t,"ispe",i.offset+8);if(o){return{height:(0,r.readUInt32BE)(t,o.offset+16),width:(0,r.readUInt32BE)(t,o.offset+12),type:(0,r.toUTF8String)(t,8,12)}}throw new TypeError("Invalid HEIF, no size found")}}},797:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.ICNS=void 0;const r=n(823);const i=4+4;const o=4;const s=4;const c={ICON:32,"ICN#":32,"icm#":16,icm4:16,icm8:16,"ics#":16,ics4:16,ics8:16,is32:16,s8mk:16,icp4:16,icl4:32,icl8:32,il32:32,l8mk:32,icp5:32,ic11:32,ich4:48,ich8:48,ih32:48,h8mk:48,icp6:64,ic12:32,it32:128,t8mk:128,ic07:128,ic08:256,ic13:256,ic09:512,ic14:512,ic10:1024};function readImageHeader(t,e){const n=e+s;return[(0,r.toUTF8String)(t,e,n),(0,r.readUInt32BE)(t,n)]}function getImageSize(t){const e=c[t];return{width:e,height:e,type:t}}e.ICNS={validate:t=>(0,r.toUTF8String)(t,0,4)==="icns",calculate(t){const e=t.length;const n=(0,r.readUInt32BE)(t,o);let s=i;let c=readImageHeader(t,s);let a=getImageSize(c[0]);s+=c[1];if(s===n)return a;const u={height:a.height,images:[a],width:a.width};while(s{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.ICO=void 0;const r=n(823);const i=1;const o=2+2+2;const s=1+1+1+1+2+2+4+4;function getSizeFromOffset(t,e){const n=t[e];return n===0?256:n}function getImageSize(t,e){const n=o+e*s;return{height:getSizeFromOffset(t,n+1),width:getSizeFromOffset(t,n)}}e.ICO={validate(t){const e=(0,r.readUInt16LE)(t,0);const n=(0,r.readUInt16LE)(t,4);if(e!==0||n===0)return false;const o=(0,r.readUInt16LE)(t,2);return o===i},calculate(t){const e=(0,r.readUInt16LE)(t,4);const n=getImageSize(t,0);if(e===1)return n;const i=[n];for(let n=1;n{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.typeHandlers=void 0;const r=n(683);const i=n(827);const o=n(387);const s=n(589);const c=n(665);const a=n(797);const u=n(345);const d=n(185);const l=n(750);const f=n(446);const h=n(992);const p=n(743);const g=n(956);const I=n(262);const y=n(967);const v=n(583);const w=n(849);const E=n(331);e.typeHandlers={bmp:r.BMP,cur:i.CUR,dds:o.DDS,gif:s.GIF,heif:c.HEIF,icns:a.ICNS,ico:u.ICO,j2c:d.J2C,jp2:l.JP2,jpg:f.JPG,ktx:h.KTX,png:p.PNG,pnm:g.PNM,psd:I.PSD,svg:y.SVG,tga:v.TGA,tiff:w.TIFF,webp:E.WEBP}},185:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.J2C=void 0;const r=n(823);e.J2C={validate:t=>(0,r.toHexString)(t,0,4)==="ff4fff51",calculate:t=>({height:(0,r.readUInt32BE)(t,12),width:(0,r.readUInt32BE)(t,8)})}},750:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.JP2=void 0;const r=n(823);e.JP2={validate(t){if((0,r.readUInt32BE)(t,4)!==1783636e3||(0,r.readUInt32BE)(t,0)<1)return false;const e=(0,r.findBox)(t,"ftyp",0);if(!e)return false;return(0,r.readUInt32BE)(t,e.offset+4)===1718909296},calculate(t){const e=(0,r.findBox)(t,"jp2h",0);const n=e&&(0,r.findBox)(t,"ihdr",e.offset+8);if(n){return{height:(0,r.readUInt32BE)(t,n.offset+8),width:(0,r.readUInt32BE)(t,n.offset+12)}}throw new TypeError("Unsupported JPEG 2000 format")}}},446:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.JPG=void 0;const r=n(823);const i="45786966";const o=2;const s=6;const c=2;const a="4d4d";const u="4949";const d=12;const l=2;function isEXIF(t){return(0,r.toHexString)(t,2,6)===i}function extractSize(t,e){return{height:(0,r.readUInt16BE)(t,e),width:(0,r.readUInt16BE)(t,e+2)}}function extractOrientation(t,e){const n=8;const i=s+n;const o=(0,r.readUInt)(t,16,i,e);for(let n=0;nt.length){return}const c=t.slice(o,s);const a=(0,r.readUInt)(c,16,0,e);if(a===274){const t=(0,r.readUInt)(c,16,2,e);if(t!==3){return}const n=(0,r.readUInt)(c,32,4,e);if(n!==1){return}return(0,r.readUInt)(c,16,8,e)}}}function validateExifBlock(t,e){const n=t.slice(o,e);const i=(0,r.toHexString)(n,s,s+c);const d=i===a;const l=i===u;if(d||l){return extractOrientation(n,d)}}function validateInput(t,e){if(e>t.length){throw new TypeError("Corrupt JPG, exceeded buffer limits")}}e.JPG={validate:t=>(0,r.toHexString)(t,0,2)==="ffd8",calculate(t){t=t.slice(4);let e;let n;while(t.length){const i=(0,r.readUInt16BE)(t,0);if(t[i]!==255){t=t.slice(1);continue}if(isEXIF(t)){e=validateExifBlock(t,i)}validateInput(t,i);n=t[i+1];if(n===192||n===193||n===194){const n=extractSize(t,i+5);if(!e){return n}return{height:n.height,orientation:e,width:n.width}}t=t.slice(i+2)}throw new TypeError("Invalid JPG, no size found")}}},992:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.KTX=void 0;const r=n(823);e.KTX={validate:t=>{const e=(0,r.toUTF8String)(t,1,7);return["KTX 11","KTX 20"].includes(e)},calculate:t=>{const e=t[5]===49?"ktx":"ktx2";const n=e==="ktx"?36:20;return{height:(0,r.readUInt32LE)(t,n+4),width:(0,r.readUInt32LE)(t,n),type:e}}}},743:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.PNG=void 0;const r=n(823);const i="PNG\r\n\n";const o="IHDR";const s="CgBI";e.PNG={validate(t){if(i===(0,r.toUTF8String)(t,1,8)){let e=(0,r.toUTF8String)(t,12,16);if(e===s){e=(0,r.toUTF8String)(t,28,32)}if(e!==o){throw new TypeError("Invalid PNG")}return true}return false},calculate(t){if((0,r.toUTF8String)(t,12,16)===s){return{height:(0,r.readUInt32BE)(t,36),width:(0,r.readUInt32BE)(t,32)}}return{height:(0,r.readUInt32BE)(t,20),width:(0,r.readUInt32BE)(t,16)}}}},956:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.PNM=void 0;const r=n(823);const i={P1:"pbm/ascii",P2:"pgm/ascii",P3:"ppm/ascii",P4:"pbm",P5:"pgm",P6:"ppm",P7:"pam",PF:"pfm"};const o={default:t=>{let e=[];while(t.length>0){const n=t.shift();if(n[0]==="#"){continue}e=n.split(" ");break}if(e.length===2){return{height:parseInt(e[1],10),width:parseInt(e[0],10)}}else{throw new TypeError("Invalid PNM")}},pam:t=>{const e={};while(t.length>0){const n=t.shift();if(n.length>16||n.charCodeAt(0)>128){continue}const[r,i]=n.split(" ");if(r&&i){e[r.toLowerCase()]=parseInt(i,10)}if(e.height&&e.width){break}}if(e.height&&e.width){return{height:e.height,width:e.width}}else{throw new TypeError("Invalid PAM")}}};e.PNM={validate:t=>(0,r.toUTF8String)(t,0,2)in i,calculate(t){const e=(0,r.toUTF8String)(t,0,2);const n=i[e];const s=(0,r.toUTF8String)(t,3).split(/[\r\n]+/);const c=o[n]||o.default;return c(s)}}},262:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.PSD=void 0;const r=n(823);e.PSD={validate:t=>(0,r.toUTF8String)(t,0,4)==="8BPS",calculate:t=>({height:(0,r.readUInt32BE)(t,14),width:(0,r.readUInt32BE)(t,18)})}},967:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.SVG=void 0;const r=n(823);const i=/"']|"[^"]*"|'[^']*')*>/;const o={height:/\sheight=(['"])([^%]+?)\1/,root:i,viewbox:/\sviewBox=(['"])(.+?)\1/i,width:/\swidth=(['"])([^%]+?)\1/};const s=2.54;const c={in:96,cm:96/s,em:16,ex:8,m:96/s*100,mm:96/s/10,pc:96/72/12,pt:96/72,px:1};const a=new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(c).join("|")})?$`);function parseLength(t){const e=a.exec(t);if(!e){return undefined}return Math.round(Number(e[1])*(c[e[2]]||1))}function parseViewbox(t){const e=t.split(" ");return{height:parseLength(e[3]),width:parseLength(e[2])}}function parseAttributes(t){const e=t.match(o.width);const n=t.match(o.height);const r=t.match(o.viewbox);return{height:n&&parseLength(n[2]),viewbox:r&&parseViewbox(r[2]),width:e&&parseLength(e[2])}}function calculateByDimensions(t){return{height:t.height,width:t.width}}function calculateByViewbox(t,e){const n=e.width/e.height;if(t.width){return{height:Math.floor(t.width/n),width:t.width}}if(t.height){return{height:t.height,width:Math.floor(t.height*n)}}return{height:e.height,width:e.width}}e.SVG={validate:t=>i.test((0,r.toUTF8String)(t,0,1e3)),calculate(t){const e=(0,r.toUTF8String)(t).match(o.root);if(e){const t=parseAttributes(e[0]);if(t.width&&t.height){return calculateByDimensions(t)}if(t.viewbox){return calculateByViewbox(t,t.viewbox)}}throw new TypeError("Invalid SVG")}}},583:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.TGA=void 0;const r=n(823);e.TGA={validate(t){return(0,r.readUInt16LE)(t,0)===0&&(0,r.readUInt16LE)(t,4)===0},calculate(t){return{height:(0,r.readUInt16LE)(t,14),width:(0,r.readUInt16LE)(t,12)}}}},849:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.TIFF=void 0;const r=n(147);const i=n(823);function readIFD(t,e,n){const o=(0,i.readUInt)(t,32,4,n);let s=1024;const c=r.statSync(e).size;if(o+s>c){s=c-o-10}const a=new Uint8Array(s);const u=r.openSync(e,"r");r.readSync(u,a,0,s,o);r.closeSync(u);return a.slice(2)}function readValue(t,e){const n=(0,i.readUInt)(t,16,8,e);const r=(0,i.readUInt)(t,16,10,e);return(r<<16)+n}function nextTag(t){if(t.length>24){return t.slice(12)}}function extractTags(t,e){const n={};let r=t;while(r&&r.length){const t=(0,i.readUInt)(r,16,0,e);const o=(0,i.readUInt)(r,16,2,e);const s=(0,i.readUInt)(r,32,4,e);if(t===0){break}else{if(s===1&&(o===3||o===4)){n[t]=readValue(r,e)}r=nextTag(r)}}return n}function determineEndianness(t){const e=(0,i.toUTF8String)(t,0,2);if("II"===e){return"LE"}else if("MM"===e){return"BE"}}const o=["49492a00","4d4d002a"];e.TIFF={validate:t=>o.includes((0,i.toHexString)(t,0,4)),calculate(t,e){if(!e){throw new TypeError("Tiff doesn't support buffer")}const n=determineEndianness(t)==="BE";const r=readIFD(t,e,n);const i=extractTags(r,n);const o=i[256];const s=i[257];if(!o||!s){throw new TypeError("Invalid Tiff. Missing tags")}return{height:s,width:o}}}},823:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.findBox=e.readUInt=e.readUInt32LE=e.readUInt32BE=e.readInt32LE=e.readUInt24LE=e.readUInt16LE=e.readUInt16BE=e.readInt16LE=e.toHexString=e.toUTF8String=void 0;const n=new TextDecoder;const toUTF8String=(t,e=0,r=t.length)=>n.decode(t.slice(e,r));e.toUTF8String=toUTF8String;const toHexString=(t,e=0,n=t.length)=>t.slice(e,n).reduce(((t,e)=>t+("0"+e.toString(16)).slice(-2)),"");e.toHexString=toHexString;const readInt16LE=(t,e=0)=>{const n=t[e]+t[e+1]*2**8;return n|(n&2**15)*131070};e.readInt16LE=readInt16LE;const readUInt16BE=(t,e=0)=>t[e]*2**8+t[e+1];e.readUInt16BE=readUInt16BE;const readUInt16LE=(t,e=0)=>t[e]+t[e+1]*2**8;e.readUInt16LE=readUInt16LE;const readUInt24LE=(t,e=0)=>t[e]+t[e+1]*2**8+t[e+2]*2**16;e.readUInt24LE=readUInt24LE;const readInt32LE=(t,e=0)=>t[e]+t[e+1]*2**8+t[e+2]*2**16+(t[e+3]<<24);e.readInt32LE=readInt32LE;const readUInt32BE=(t,e=0)=>t[e]*2**24+t[e+1]*2**16+t[e+2]*2**8+t[e+3];e.readUInt32BE=readUInt32BE;const readUInt32LE=(t,e=0)=>t[e]+t[e+1]*2**8+t[e+2]*2**16+t[e+3]*2**24;e.readUInt32LE=readUInt32LE;const r={readUInt16BE:e.readUInt16BE,readUInt16LE:e.readUInt16LE,readUInt32BE:e.readUInt32BE,readUInt32LE:e.readUInt32LE};function readUInt(t,e,n,i){n=n||0;const o=i?"BE":"LE";const s="readUInt"+e+o;return r[s](t,n)}e.readUInt=readUInt;function readBox(t,n){if(t.length-n<4)return;const r=(0,e.readUInt32BE)(t,n);if(t.length-n{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.WEBP=void 0;const r=n(823);function calculateExtended(t){return{height:1+(0,r.readUInt24LE)(t,7),width:1+(0,r.readUInt24LE)(t,4)}}function calculateLossless(t){return{height:1+((t[4]&15)<<10|t[3]<<2|(t[2]&192)>>6),width:1+((t[2]&63)<<8|t[1])}}function calculateLossy(t){return{height:(0,r.readInt16LE)(t,8)&16383,width:(0,r.readInt16LE)(t,6)&16383}}e.WEBP={validate(t){const e="RIFF"===(0,r.toUTF8String)(t,0,4);const n="WEBP"===(0,r.toUTF8String)(t,8,12);const i="VP8"===(0,r.toUTF8String)(t,12,15);return e&&n&&i},calculate(t){const e=(0,r.toUTF8String)(t,12,16);t=t.slice(20,30);if(e==="VP8X"){const e=t[0];const n=(e&192)===0;const r=(e&1)===0;if(n&&r){return calculateExtended(t)}else{throw new TypeError("Invalid WebP")}}if(e==="VP8 "&&t[0]!==47){return calculateLossy(t)}const n=(0,r.toHexString)(t,3,6);if(e==="VP8L"&&n!=="9d012a"){return calculateLossless(t)}throw new TypeError("Invalid WebP")}}},842:(t,e,n)=>{try{var r=n(837);if(typeof r.inherits!=="function")throw"";t.exports=r.inherits}catch(e){t.exports=n(782)}},782:t=>{if(typeof Object.create==="function"){t.exports=function inherits(t,e){if(e){t.super_=e;t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:false,writable:true,configurable:true}})}}}else{t.exports=function inherits(t,e){if(e){t.super_=e;var TempCtor=function(){};TempCtor.prototype=e.prototype;t.prototype=new TempCtor;t.prototype.constructor=t}}}},927:(t,e,n)=>{var r=n(842);var i=n(361).EventEmitter;t.exports=Queue;t.exports["default"]=Queue;function Queue(t){if(!(this instanceof Queue)){return new Queue(t)}i.call(this);t=t||{};this.concurrency=t.concurrency||Infinity;this.timeout=t.timeout||0;this.autostart=t.autostart||false;this.results=t.results||null;this.pending=0;this.session=0;this.running=false;this.jobs=[];this.timers={}}r(Queue,i);var o=["pop","shift","indexOf","lastIndexOf"];o.forEach((function(t){Queue.prototype[t]=function(){return Array.prototype[t].apply(this.jobs,arguments)}}));Queue.prototype.slice=function(t,e){this.jobs=this.jobs.slice(t,e);return this};Queue.prototype.reverse=function(){this.jobs.reverse();return this};var s=["push","unshift","splice"];s.forEach((function(t){Queue.prototype[t]=function(){var e=Array.prototype[t].apply(this.jobs,arguments);if(this.autostart){this.start()}return e}}));Object.defineProperty(Queue.prototype,"length",{get:function(){return this.pending+this.jobs.length}});Queue.prototype.start=function(t){if(t){callOnErrorOrEnd.call(this,t)}this.running=true;if(this.pending>=this.concurrency){return}if(this.jobs.length===0){if(this.pending===0){done.call(this)}return}var e=this;var n=this.jobs.shift();var r=true;var i=this.session;var o=null;var s=false;var c=null;var a=n.hasOwnProperty("timeout")?n.timeout:this.timeout;function next(t,a){if(r&&e.session===i){r=false;e.pending--;if(o!==null){delete e.timers[o];clearTimeout(o)}if(t){e.emit("error",t,n)}else if(s===false){if(c!==null){e.results[c]=Array.prototype.slice.call(arguments,1)}e.emit("success",a,n)}if(e.session===i){if(e.pending===0&&e.jobs.length===0){done.call(e)}else if(e.running){e.start()}}}}if(a){o=setTimeout((function(){s=true;if(e.listeners("timeout").length>0){e.emit("timeout",next,n)}else{next()}}),a);this.timers[o]=o}if(this.results){c=this.results.length;this.results[c]=null}this.pending++;e.emit("start",n);var u=n(next);if(u&&u.then&&typeof u.then==="function"){u.then((function(t){return next(null,t)})).catch((function(t){return next(t||true)}))}if(this.running&&this.jobs.length>0){this.start()}};Queue.prototype.stop=function(){this.running=false};Queue.prototype.end=function(t){clearTimers.call(this);this.jobs.length=0;this.pending=0;done.call(this,t)};function clearTimers(){for(var t in this.timers){var e=this.timers[t];delete this.timers[t];clearTimeout(e)}}function callOnErrorOrEnd(t){var e=this;this.on("error",onerror);this.on("end",onend);function onerror(t){e.end(t)}function onend(n){e.removeListener("error",onerror);e.removeListener("end",onend);t(n,this.results)}}function done(t){this.session++;this.running=false;this.emit("end",t)}},361:t=>{"use strict";t.exports=require("events")},147:t=>{"use strict";t.exports=require("fs")},17:t=>{"use strict";t.exports=require("path")},837:t=>{"use strict";t.exports=require("util")}};var e={};function __nccwpck_require__(n){var r=e[n];if(r!==undefined){return r.exports}var i=e[n]={exports:{}};var o=true;try{t[n](i,i.exports,__nccwpck_require__);o=false}finally{if(o)delete e[n]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(751);module.exports=n})(); \ No newline at end of file diff --git a/packages/next/src/server/image-optimizer.ts b/packages/next/src/server/image-optimizer.ts index 7ad6f90be4..68a5e57645 100644 --- a/packages/next/src/server/image-optimizer.ts +++ b/packages/next/src/server/image-optimizer.ts @@ -4,7 +4,6 @@ import { cpus } from 'os' import type { IncomingMessage, ServerResponse } from 'http' import { mediaType } from 'next/dist/compiled/@hapi/accept' import contentDisposition from 'next/dist/compiled/content-disposition' -import { getOrientation, Orientation } from 'next/dist/compiled/get-orientation' import imageSizeOf from 'next/dist/compiled/image-size' import isAnimated from 'next/dist/compiled/is-animated' import { join } from 'path' @@ -15,11 +14,6 @@ import type { ImageConfigComplete } from '../shared/lib/image-config' import { hasMatch } from '../shared/lib/match-remote-pattern' import type { NextConfigComplete } from './config-shared' import { createRequestResponseMocks } from './lib/mock-request' -// Do not import anything other than types from this module -// because it will throw an error when using `outputFileTracing` -// as `jest-worker` is ignored in file tracing. Use `await import` -// or `require` instead. -import type { Operation } from './lib/squoosh/main' import type { NextUrlWithParsedQuery } from './request-meta' import type { IncrementalCacheEntry, @@ -28,6 +22,7 @@ import type { import { sendEtagResponse } from './send-payload' import { getContentType, getExtension } from './serve-static' import * as Log from '../build/output/log' +import isError from '../lib/is-error' type XCacheHeader = 'MISS' | 'HIT' | 'STALE' @@ -44,10 +39,10 @@ const VECTOR_TYPES = [SVG] const BLUR_IMG_SIZE = 8 // should match `next-image-loader` const BLUR_QUALITY = 70 // should match `next-image-loader` -let sharp: typeof import('sharp') | undefined +let sharp: typeof import('sharp') try { - sharp = require(process.env.NEXT_SHARP_PATH || 'sharp') + sharp = require('sharp') if (sharp && sharp.concurrency() > 1) { // Reducing concurrency should reduce the memory usage too. // We more aggressively reduce in dev but also reduce in prod. @@ -55,12 +50,15 @@ try { const divisor = process.env.NODE_ENV === 'development' ? 4 : 2 sharp.concurrency(Math.floor(Math.max(cpus().length / divisor, 1))) } -} catch (e) { - // Sharp not present on the server, Squoosh fallback will be used +} catch (e: unknown) { + if (isError(e) && e.code === 'MODULE_NOT_FOUND') { + throw new Error( + 'Module `sharp` not found. Please run `npm install --cpu=wasm32 sharp` to install it.' + ) + } + throw e } -let showSharpMissingWarning = process.env.NODE_ENV === 'production' - export interface ImageParamsResult { href: string isAbsolute: boolean @@ -418,7 +416,6 @@ export async function optimizeImage({ quality, width, height, - nextConfigOutput, }: { buffer: Buffer contentType: string @@ -428,99 +425,38 @@ export async function optimizeImage({ nextConfigOutput?: 'standalone' | 'export' }): Promise { let optimizedBuffer = buffer - if (sharp) { - // Begin sharp transformation logic - const transformer = sharp(buffer, { - sequentialRead: true, - }) - transformer.rotate() + // Begin sharp transformation logic + const transformer = sharp(buffer, { + sequentialRead: true, + }) - if (height) { - transformer.resize(width, height) - } else { - transformer.resize(width, undefined, { - withoutEnlargement: true, - }) - } + transformer.rotate() - if (contentType === AVIF) { - if (transformer.avif) { - const avifQuality = quality - 15 - transformer.avif({ - quality: Math.max(avifQuality, 0), - chromaSubsampling: '4:2:0', // same as webp - }) - } else { - Log.warnOnce( - `Your installed version of the 'sharp' package does not support AVIF images. Run 'npm i sharp@latest' to upgrade to the latest version.\n` + - 'Read more: https://nextjs.org/docs/messages/sharp-version-avif' - ) - transformer.webp({ quality }) - } - } else if (contentType === WEBP) { - transformer.webp({ quality }) - } else if (contentType === PNG) { - transformer.png({ quality }) - } else if (contentType === JPEG) { - transformer.jpeg({ quality, progressive: true }) - } - - optimizedBuffer = await transformer.toBuffer() - // End sharp transformation logic + if (height) { + transformer.resize(width, height) } else { - if (showSharpMissingWarning && nextConfigOutput === 'standalone') { - Log.error( - `Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly. Read more at: https://nextjs.org/docs/messages/sharp-missing-in-production` - ) - throw new ImageError(500, 'Internal Server Error') - } - // Show sharp warning in production once - if (showSharpMissingWarning) { - Log.warnOnce( - `For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended. Run 'npm i sharp', and Next.js will use it automatically for Image Optimization.\n` + - 'Read more: https://nextjs.org/docs/messages/sharp-missing-in-production' - ) - showSharpMissingWarning = false - } - - // Begin Squoosh transformation logic - const orientation = await getOrientation(buffer) - - const operations: Operation[] = [] - - if (orientation === Orientation.RIGHT_TOP) { - operations.push({ type: 'rotate', numRotations: 1 }) - } else if (orientation === Orientation.BOTTOM_RIGHT) { - operations.push({ type: 'rotate', numRotations: 2 }) - } else if (orientation === Orientation.LEFT_BOTTOM) { - operations.push({ type: 'rotate', numRotations: 3 }) - } else { - // TODO: support more orientations - // eslint-disable-next-line @typescript-eslint/no-unused-vars - // const _: never = orientation - } - - if (height) { - operations.push({ type: 'resize', width, height }) - } else { - operations.push({ type: 'resize', width }) - } - - const { processBuffer } = - require('./lib/squoosh/main') as typeof import('./lib/squoosh/main') - - if (contentType === AVIF) { - optimizedBuffer = await processBuffer(buffer, operations, 'avif', quality) - } else if (contentType === WEBP) { - optimizedBuffer = await processBuffer(buffer, operations, 'webp', quality) - } else if (contentType === PNG) { - optimizedBuffer = await processBuffer(buffer, operations, 'png', quality) - } else if (contentType === JPEG) { - optimizedBuffer = await processBuffer(buffer, operations, 'jpeg', quality) - } + transformer.resize(width, undefined, { + withoutEnlargement: true, + }) } + if (contentType === AVIF) { + const avifQuality = quality - 15 + transformer.avif({ + quality: Math.max(avifQuality, 0), + chromaSubsampling: '4:2:0', // same as webp + }) + } else if (contentType === WEBP) { + transformer.webp({ quality }) + } else if (contentType === PNG) { + transformer.png({ quality }) + } else if (contentType === JPEG) { + transformer.jpeg({ quality, progressive: true }) + } + + optimizedBuffer = await transformer.toBuffer() + return optimizedBuffer } @@ -667,12 +603,10 @@ export async function imageOptimizer( }) if (optimizedBuffer) { if (isDev && width <= BLUR_IMG_SIZE && quality === BLUR_QUALITY) { - const { getMetadata } = - require('./lib/squoosh/main') as typeof import('./lib/squoosh/main') // During `next dev`, we don't want to generate blur placeholders with webpack // because it can delay starting the dev server. Instead, `next-image-loader.js` // will inline a special url to lazily generate the blur placeholder at request time. - const meta = await getMetadata(optimizedBuffer) + const meta = await getImageSize(optimizedBuffer) const opts = { blurWidth: meta.width, blurHeight: meta.height, @@ -794,29 +728,10 @@ export function sendResponse( } } -export async function getImageSize( - buffer: Buffer, - // Should match VALID_BLUR_EXT - extension: 'avif' | 'webp' | 'png' | 'jpeg' -): Promise<{ +export async function getImageSize(buffer: Buffer): Promise<{ width?: number height?: number }> { - // TODO: upgrade "image-size" package to support AVIF - // See https://github.com/image-size/image-size/issues/348 - if (extension === 'avif') { - if (sharp) { - const transformer = sharp(buffer) - const { width, height } = await transformer.metadata() - return { width, height } - } else { - const { decodeBuffer } = - require('./lib/squoosh/main') as typeof import('./lib/squoosh/main') - const { width, height } = await decodeBuffer(buffer) - return { width, height } - } - } - const { width, height } = imageSizeOf(buffer) return { width, height } } diff --git a/packages/next/src/server/lib/squoosh/.vercel.approvers b/packages/next/src/server/lib/squoosh/.vercel.approvers deleted file mode 100644 index 910964a534..0000000000 --- a/packages/next/src/server/lib/squoosh/.vercel.approvers +++ /dev/null @@ -1,3 +0,0 @@ -@timneutkens:notify -@ijjk:notify -@shuding:notify diff --git a/packages/next/src/server/lib/squoosh/LICENSE b/packages/next/src/server/lib/squoosh/LICENSE deleted file mode 100644 index d645695673..0000000000 --- a/packages/next/src/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/src/server/lib/squoosh/avif/avif_enc.d.ts b/packages/next/src/server/lib/squoosh/avif/avif_enc.d.ts deleted file mode 100644 index d91bbf36e0..0000000000 --- a/packages/next/src/server/lib/squoosh/avif/avif_enc.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -// eslint-disable-next-line no-shadow -export const enum AVIFTune { - auto, - psnr, - ssim, -} - -export interface EncodeOptions { - cqLevel: number - denoiseLevel: number - cqAlphaLevel: number - tileRowsLog2: number - tileColsLog2: number - speed: number - subsample: number - chromaDeltaQ: boolean - sharpness: number - tune: AVIFTune -} - -export interface AVIFModule extends EmscriptenWasm.Module { - encode( - data: BufferSource, - width: number, - height: number, - options: EncodeOptions - ): Uint8Array -} - -declare var moduleFactory: EmscriptenWasm.ModuleFactory - -export default moduleFactory diff --git a/packages/next/src/server/lib/squoosh/avif/avif_node_dec.js b/packages/next/src/server/lib/squoosh/avif/avif_node_dec.js deleted file mode 100644 index 0a02d0afb3..0000000000 --- a/packages/next/src/server/lib/squoosh/avif/avif_node_dec.js +++ /dev/null @@ -1,1760 +0,0 @@ -/* eslint-disable */ -var Module = (function () { - return function (Module) { - Module = Module || {} - - var Module = typeof Module !== 'undefined' ? Module : {} - var readyPromiseResolve, readyPromiseReject - Module['ready'] = new Promise(function (resolve, reject) { - readyPromiseResolve = resolve - readyPromiseReject = reject - }) - var moduleOverrides = {} - var key - for (key in Module) { - if (Module.hasOwnProperty(key)) { - moduleOverrides[key] = Module[key] - } - } - var arguments_ = [] - var thisProgram = './this.program' - var quit_ = function (status, toThrow) { - throw toThrow - } - var ENVIRONMENT_IS_WEB = false - var ENVIRONMENT_IS_WORKER = false - var ENVIRONMENT_IS_NODE = true - var scriptDirectory = '' - function locateFile(path) { - if (Module['locateFile']) { - return Module['locateFile'](path, scriptDirectory) - } - return scriptDirectory + path - } - var read_, readBinary - var nodeFS - var nodePath - if (ENVIRONMENT_IS_NODE) { - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = require('path').dirname(scriptDirectory) + '/' - } else { - scriptDirectory = __dirname + '/' - } - read_ = function shell_read(filename, binary) { - if (!nodeFS) nodeFS = require('fs') - if (!nodePath) nodePath = require('path') - filename = nodePath['normalize'](filename) - return nodeFS['readFileSync'](filename, binary ? null : 'utf8') - } - readBinary = function readBinary(filename) { - var ret = read_(filename, true) - if (!ret.buffer) { - ret = new Uint8Array(ret) - } - assert(ret.buffer) - return ret - } - if (process['argv'].length > 1) { - thisProgram = process['argv'][1].replace(/\\/g, '/') - } - arguments_ = process['argv'].slice(2) - quit_ = function (status) { - process['exit'](status) - } - Module['inspect'] = function () { - return '[Emscripten Module object]' - } - } else { - } - var out = Module['print'] || console.log.bind(console) - var err = Module['printErr'] || console.warn.bind(console) - for (key in moduleOverrides) { - if (moduleOverrides.hasOwnProperty(key)) { - Module[key] = moduleOverrides[key] - } - } - moduleOverrides = null - if (Module['arguments']) arguments_ = Module['arguments'] - if (Module['thisProgram']) thisProgram = Module['thisProgram'] - if (Module['quit']) quit_ = Module['quit'] - var tempRet0 = 0 - var setTempRet0 = function (value) { - tempRet0 = value - } - var getTempRet0 = function () { - return tempRet0 - } - var wasmBinary - if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'] - var noExitRuntime = Module['noExitRuntime'] || true - if (typeof WebAssembly !== 'object') { - abort('no native wasm support detected') - } - var wasmMemory - var ABORT = false - var EXITSTATUS - function assert(condition, text) { - if (!condition) { - abort('Assertion failed: ' + text) - } - } - var UTF8Decoder = new TextDecoder('utf8') - function UTF8ArrayToString(heap, idx, maxBytesToRead) { - var endIdx = idx + maxBytesToRead - var endPtr = idx - while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr - return UTF8Decoder.decode( - heap.subarray - ? heap.subarray(idx, endPtr) - : new Uint8Array(heap.slice(idx, endPtr)) - ) - } - function UTF8ToString(ptr, maxBytesToRead) { - if (!ptr) return '' - var maxPtr = ptr + maxBytesToRead - for (var end = ptr; !(end >= maxPtr) && HEAPU8[end]; ) ++end - return UTF8Decoder.decode(HEAPU8.subarray(ptr, end)) - } - function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { - if (!(maxBytesToWrite > 0)) return 0 - var startIdx = outIdx - var endIdx = outIdx + maxBytesToWrite - 1 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) { - var u1 = str.charCodeAt(++i) - u = (65536 + ((u & 1023) << 10)) | (u1 & 1023) - } - if (u <= 127) { - if (outIdx >= endIdx) break - heap[outIdx++] = u - } else if (u <= 2047) { - if (outIdx + 1 >= endIdx) break - heap[outIdx++] = 192 | (u >> 6) - heap[outIdx++] = 128 | (u & 63) - } else if (u <= 65535) { - if (outIdx + 2 >= endIdx) break - heap[outIdx++] = 224 | (u >> 12) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } else { - if (outIdx + 3 >= endIdx) break - heap[outIdx++] = 240 | (u >> 18) - heap[outIdx++] = 128 | ((u >> 12) & 63) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } - } - heap[outIdx] = 0 - return outIdx - startIdx - } - function stringToUTF8(str, outPtr, maxBytesToWrite) { - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite) - } - function lengthBytesUTF8(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) - u = (65536 + ((u & 1023) << 10)) | (str.charCodeAt(++i) & 1023) - if (u <= 127) ++len - else if (u <= 2047) len += 2 - else if (u <= 65535) len += 3 - else len += 4 - } - return len - } - var UTF16Decoder = new TextDecoder('utf-16le') - function UTF16ToString(ptr, maxBytesToRead) { - var endPtr = ptr - var idx = endPtr >> 1 - var maxIdx = idx + maxBytesToRead / 2 - while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx - endPtr = idx << 1 - return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)) - var str = '' - for (var i = 0; !(i >= maxBytesToRead / 2); ++i) { - var codeUnit = HEAP16[(ptr + i * 2) >> 1] - if (codeUnit == 0) break - str += String.fromCharCode(codeUnit) - } - return str - } - function stringToUTF16(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 2) return 0 - maxBytesToWrite -= 2 - var startPtr = outPtr - var numCharsToWrite = - maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length - for (var i = 0; i < numCharsToWrite; ++i) { - var codeUnit = str.charCodeAt(i) - HEAP16[outPtr >> 1] = codeUnit - outPtr += 2 - } - HEAP16[outPtr >> 1] = 0 - return outPtr - startPtr - } - function lengthBytesUTF16(str) { - return str.length * 2 - } - function UTF32ToString(ptr, maxBytesToRead) { - var i = 0 - var str = '' - while (!(i >= maxBytesToRead / 4)) { - var utf32 = HEAP32[(ptr + i * 4) >> 2] - if (utf32 == 0) break - ++i - if (utf32 >= 65536) { - var ch = utf32 - 65536 - str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023)) - } else { - str += String.fromCharCode(utf32) - } - } - return str - } - function stringToUTF32(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 4) return 0 - var startPtr = outPtr - var endPtr = startPtr + maxBytesToWrite - 4 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) { - var trailSurrogate = str.charCodeAt(++i) - codeUnit = - (65536 + ((codeUnit & 1023) << 10)) | (trailSurrogate & 1023) - } - HEAP32[outPtr >> 2] = codeUnit - outPtr += 4 - if (outPtr + 4 > endPtr) break - } - HEAP32[outPtr >> 2] = 0 - return outPtr - startPtr - } - function lengthBytesUTF32(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) ++i - len += 4 - } - return len - } - function alignUp(x, multiple) { - if (x % multiple > 0) { - x += multiple - (x % multiple) - } - return x - } - var buffer, - HEAP8, - HEAPU8, - HEAP16, - HEAPU16, - HEAP32, - HEAPU32, - HEAPF32, - HEAPF64 - function updateGlobalBufferAndViews(buf) { - buffer = buf - Module['HEAP8'] = HEAP8 = new Int8Array(buf) - Module['HEAP16'] = HEAP16 = new Int16Array(buf) - Module['HEAP32'] = HEAP32 = new Int32Array(buf) - Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf) - Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf) - Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf) - Module['HEAPF32'] = HEAPF32 = new Float32Array(buf) - Module['HEAPF64'] = HEAPF64 = new Float64Array(buf) - } - var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216 - var wasmTable - var __ATPRERUN__ = [] - var __ATINIT__ = [] - var __ATPOSTRUN__ = [] - var runtimeInitialized = false - function preRun() { - if (Module['preRun']) { - if (typeof Module['preRun'] == 'function') - Module['preRun'] = [Module['preRun']] - while (Module['preRun'].length) { - addOnPreRun(Module['preRun'].shift()) - } - } - callRuntimeCallbacks(__ATPRERUN__) - } - function initRuntime() { - runtimeInitialized = true - callRuntimeCallbacks(__ATINIT__) - } - function postRun() { - if (Module['postRun']) { - if (typeof Module['postRun'] == 'function') - Module['postRun'] = [Module['postRun']] - while (Module['postRun'].length) { - addOnPostRun(Module['postRun'].shift()) - } - } - callRuntimeCallbacks(__ATPOSTRUN__) - } - function addOnPreRun(cb) { - __ATPRERUN__.unshift(cb) - } - function addOnInit(cb) { - __ATINIT__.unshift(cb) - } - function addOnPostRun(cb) { - __ATPOSTRUN__.unshift(cb) - } - var runDependencies = 0 - var runDependencyWatcher = null - var dependenciesFulfilled = null - function addRunDependency(id) { - runDependencies++ - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - } - function removeRunDependency(id) { - runDependencies-- - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - if (runDependencies == 0) { - if (runDependencyWatcher !== null) { - clearInterval(runDependencyWatcher) - runDependencyWatcher = null - } - if (dependenciesFulfilled) { - var callback = dependenciesFulfilled - dependenciesFulfilled = null - callback() - } - } - } - Module['preloadedImages'] = {} - Module['preloadedAudios'] = {} - function abort(what) { - if (Module['onAbort']) { - Module['onAbort'](what) - } - what += '' - err(what) - ABORT = true - EXITSTATUS = 1 - what = 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.' - var e = new WebAssembly.RuntimeError(what) - readyPromiseReject(e) - throw e - } - var dataURIPrefix = 'data:application/octet-stream;base64,' - function isDataURI(filename) { - return filename.startsWith(dataURIPrefix) - } - if (Module['locateFile']) { - var wasmBinaryFile = 'avif_node_dec.wasm' - if (!isDataURI(wasmBinaryFile)) { - wasmBinaryFile = locateFile(wasmBinaryFile) - } - } else { - throw new Error('invariant') - } - function getBinary(file) { - try { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary) - } - if (readBinary) { - return readBinary(file) - } else { - throw 'both async and sync fetching of the wasm failed' - } - } catch (err) { - abort(err) - } - } - function getBinaryPromise() { - return Promise.resolve().then(function () { - return getBinary(wasmBinaryFile) - }) - } - function createWasm() { - var info = { a: asmLibraryArg } - function receiveInstance(instance, module) { - var exports = instance.exports - Module['asm'] = exports - wasmMemory = Module['asm']['C'] - updateGlobalBufferAndViews(wasmMemory.buffer) - wasmTable = Module['asm']['L'] - addOnInit(Module['asm']['D']) - removeRunDependency('wasm-instantiate') - } - addRunDependency('wasm-instantiate') - function receiveInstantiationResult(result) { - receiveInstance(result['instance']) - } - function instantiateArrayBuffer(receiver) { - return getBinaryPromise() - .then(function (binary) { - var result = WebAssembly.instantiate(binary, info) - return result - }) - .then(receiver, function (reason) { - err('failed to asynchronously prepare wasm: ' + reason) - abort(reason) - }) - } - function instantiateAsync() { - return instantiateArrayBuffer(receiveInstantiationResult) - } - if (Module['instantiateWasm']) { - try { - var exports = Module['instantiateWasm'](info, receiveInstance) - return exports - } catch (e) { - err('Module.instantiateWasm callback failed with error: ' + e) - return false - } - } - instantiateAsync().catch(readyPromiseReject) - return {} - } - function callRuntimeCallbacks(callbacks) { - while (callbacks.length > 0) { - var callback = callbacks.shift() - if (typeof callback == 'function') { - callback(Module) - continue - } - var func = callback.func - if (typeof func === 'number') { - if (callback.arg === undefined) { - wasmTable.get(func)() - } else { - wasmTable.get(func)(callback.arg) - } - } else { - func(callback.arg === undefined ? null : callback.arg) - } - } - } - function _atexit(func, arg) {} - function ___cxa_thread_atexit(a0, a1) { - return _atexit(a0, a1) - } - function __embind_register_bigint( - primitiveType, - name, - size, - minRange, - maxRange - ) {} - function getShiftFromSize(size) { - switch (size) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + size) - } - } - function embind_init_charCodes() { - var codes = new Array(256) - for (var i = 0; i < 256; ++i) { - codes[i] = String.fromCharCode(i) - } - embind_charCodes = codes - } - var embind_charCodes = undefined - function readLatin1String(ptr) { - var ret = '' - var c = ptr - while (HEAPU8[c]) { - ret += embind_charCodes[HEAPU8[c++]] - } - return ret - } - var awaitingDependencies = {} - var registeredTypes = {} - var typeDependencies = {} - var char_0 = 48 - var char_9 = 57 - function makeLegalFunctionName(name) { - if (undefined === name) { - return '_unknown' - } - name = name.replace(/[^a-zA-Z0-9_]/g, '$') - var f = name.charCodeAt(0) - if (f >= char_0 && f <= char_9) { - return '_' + name - } else { - return name - } - } - function createNamedFunction(name, body) { - name = makeLegalFunctionName(name) - return new Function( - 'body', - 'return function ' + - name + - '() {\n' + - ' "use strict";' + - ' return body.apply(this, arguments);\n' + - '};\n' - )(body) - } - function extendError(baseErrorType, errorName) { - var errorClass = createNamedFunction(errorName, function (message) { - this.name = errorName - this.message = message - var stack = new Error(message).stack - if (stack !== undefined) { - this.stack = - this.toString() + '\n' + stack.replace(/^Error(:[^\n]*)?\n/, '') - } - }) - errorClass.prototype = Object.create(baseErrorType.prototype) - errorClass.prototype.constructor = errorClass - errorClass.prototype.toString = function () { - if (this.message === undefined) { - return this.name - } else { - return this.name + ': ' + this.message - } - } - return errorClass - } - var BindingError = undefined - function throwBindingError(message) { - throw new BindingError(message) - } - var InternalError = undefined - function throwInternalError(message) { - throw new InternalError(message) - } - function whenDependentTypesAreResolved( - myTypes, - dependentTypes, - getTypeConverters - ) { - myTypes.forEach(function (type) { - typeDependencies[type] = dependentTypes - }) - function onComplete(typeConverters) { - var myTypeConverters = getTypeConverters(typeConverters) - if (myTypeConverters.length !== myTypes.length) { - throwInternalError('Mismatched type converter count') - } - for (var i = 0; i < myTypes.length; ++i) { - registerType(myTypes[i], myTypeConverters[i]) - } - } - var typeConverters = new Array(dependentTypes.length) - var unregisteredTypes = [] - var registered = 0 - dependentTypes.forEach(function (dt, i) { - if (registeredTypes.hasOwnProperty(dt)) { - typeConverters[i] = registeredTypes[dt] - } else { - unregisteredTypes.push(dt) - if (!awaitingDependencies.hasOwnProperty(dt)) { - awaitingDependencies[dt] = [] - } - awaitingDependencies[dt].push(function () { - typeConverters[i] = registeredTypes[dt] - ++registered - if (registered === unregisteredTypes.length) { - onComplete(typeConverters) - } - }) - } - }) - if (0 === unregisteredTypes.length) { - onComplete(typeConverters) - } - } - function registerType(rawType, registeredInstance, options) { - options = options || {} - if (!('argPackAdvance' in registeredInstance)) { - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - } - var name = registeredInstance.name - if (!rawType) { - throwBindingError( - 'type "' + name + '" must have a positive integer typeid pointer' - ) - } - if (registeredTypes.hasOwnProperty(rawType)) { - if (options.ignoreDuplicateRegistrations) { - return - } else { - throwBindingError("Cannot register type '" + name + "' twice") - } - } - registeredTypes[rawType] = registeredInstance - delete typeDependencies[rawType] - if (awaitingDependencies.hasOwnProperty(rawType)) { - var callbacks = awaitingDependencies[rawType] - delete awaitingDependencies[rawType] - callbacks.forEach(function (cb) { - cb() - }) - } - } - function __embind_register_bool( - rawType, - name, - size, - trueValue, - falseValue - ) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (wt) { - return !!wt - }, - toWireType: function (destructors, o) { - return o ? trueValue : falseValue - }, - argPackAdvance: 8, - readValueFromPointer: function (pointer) { - var heap - if (size === 1) { - heap = HEAP8 - } else if (size === 2) { - heap = HEAP16 - } else if (size === 4) { - heap = HEAP32 - } else { - throw new TypeError('Unknown boolean type size: ' + name) - } - return this['fromWireType'](heap[pointer >> shift]) - }, - destructorFunction: null, - }) - } - var emval_free_list = [] - var emval_handle_array = [ - {}, - { value: undefined }, - { value: null }, - { value: true }, - { value: false }, - ] - function __emval_decref(handle) { - if (handle > 4 && 0 === --emval_handle_array[handle].refcount) { - emval_handle_array[handle] = undefined - emval_free_list.push(handle) - } - } - function count_emval_handles() { - var count = 0 - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - ++count - } - } - return count - } - function get_first_emval() { - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - return emval_handle_array[i] - } - } - return null - } - function init_emval() { - Module['count_emval_handles'] = count_emval_handles - Module['get_first_emval'] = get_first_emval - } - function __emval_register(value) { - switch (value) { - case undefined: { - return 1 - } - case null: { - return 2 - } - case true: { - return 3 - } - case false: { - return 4 - } - default: { - var handle = emval_free_list.length - ? emval_free_list.pop() - : emval_handle_array.length - emval_handle_array[handle] = { refcount: 1, value: value } - return handle - } - } - } - function simpleReadValueFromPointer(pointer) { - return this['fromWireType'](HEAPU32[pointer >> 2]) - } - function __embind_register_emval(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (handle) { - var rv = emval_handle_array[handle].value - __emval_decref(handle) - return rv - }, - toWireType: function (destructors, value) { - return __emval_register(value) - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: null, - }) - } - function _embind_repr(v) { - if (v === null) { - return 'null' - } - var t = typeof v - if (t === 'object' || t === 'array' || t === 'function') { - return v.toString() - } else { - return '' + v - } - } - function floatReadValueFromPointer(name, shift) { - switch (shift) { - case 2: - return function (pointer) { - return this['fromWireType'](HEAPF32[pointer >> 2]) - } - case 3: - return function (pointer) { - return this['fromWireType'](HEAPF64[pointer >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + name) - } - } - function __embind_register_float(rawType, name, size) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (value) { - return value - }, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - return value - }, - argPackAdvance: 8, - readValueFromPointer: floatReadValueFromPointer(name, shift), - destructorFunction: null, - }) - } - function new_(constructor, argumentList) { - if (!(constructor instanceof Function)) { - throw new TypeError( - 'new_ called with constructor type ' + - typeof constructor + - ' which is not a function' - ) - } - var dummy = createNamedFunction( - constructor.name || 'unknownFunctionName', - function () {} - ) - dummy.prototype = constructor.prototype - var obj = new dummy() - var r = constructor.apply(obj, argumentList) - return r instanceof Object ? r : obj - } - function runDestructors(destructors) { - while (destructors.length) { - var ptr = destructors.pop() - var del = destructors.pop() - del(ptr) - } - } - function craftInvokerFunction( - humanName, - argTypes, - classType, - cppInvokerFunc, - cppTargetFunc - ) { - var argCount = argTypes.length - if (argCount < 2) { - throwBindingError( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - } - var isClassMethodFunc = argTypes[1] !== null && classType !== null - var needsDestructorStack = false - for (var i = 1; i < argTypes.length; ++i) { - if ( - argTypes[i] !== null && - argTypes[i].destructorFunction === undefined - ) { - needsDestructorStack = true - break - } - } - var returns = argTypes[0].name !== 'void' - var argsList = '' - var argsListWired = '' - for (var i = 0; i < argCount - 2; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - argsListWired += (i !== 0 ? ', ' : '') + 'arg' + i + 'Wired' - } - var invokerFnBody = - 'return function ' + - makeLegalFunctionName(humanName) + - '(' + - argsList + - ') {\n' + - 'if (arguments.length !== ' + - (argCount - 2) + - ') {\n' + - "throwBindingError('function " + - humanName + - " called with ' + arguments.length + ' arguments, expected " + - (argCount - 2) + - " args!');\n" + - '}\n' - if (needsDestructorStack) { - invokerFnBody += 'var destructors = [];\n' - } - var dtorStack = needsDestructorStack ? 'destructors' : 'null' - var args1 = [ - 'throwBindingError', - 'invoker', - 'fn', - 'runDestructors', - 'retType', - 'classParam', - ] - var args2 = [ - throwBindingError, - cppInvokerFunc, - cppTargetFunc, - runDestructors, - argTypes[0], - argTypes[1], - ] - if (isClassMethodFunc) { - invokerFnBody += - 'var thisWired = classParam.toWireType(' + dtorStack + ', this);\n' - } - for (var i = 0; i < argCount - 2; ++i) { - invokerFnBody += - 'var arg' + - i + - 'Wired = argType' + - i + - '.toWireType(' + - dtorStack + - ', arg' + - i + - '); // ' + - argTypes[i + 2].name + - '\n' - args1.push('argType' + i) - args2.push(argTypes[i + 2]) - } - if (isClassMethodFunc) { - argsListWired = - 'thisWired' + (argsListWired.length > 0 ? ', ' : '') + argsListWired - } - invokerFnBody += - (returns ? 'var rv = ' : '') + - 'invoker(fn' + - (argsListWired.length > 0 ? ', ' : '') + - argsListWired + - ');\n' - if (needsDestructorStack) { - invokerFnBody += 'runDestructors(destructors);\n' - } else { - for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { - var paramName = i === 1 ? 'thisWired' : 'arg' + (i - 2) + 'Wired' - if (argTypes[i].destructorFunction !== null) { - invokerFnBody += - paramName + - '_dtor(' + - paramName + - '); // ' + - argTypes[i].name + - '\n' - args1.push(paramName + '_dtor') - args2.push(argTypes[i].destructorFunction) - } - } - } - if (returns) { - invokerFnBody += - 'var ret = retType.fromWireType(rv);\n' + 'return ret;\n' - } else { - } - invokerFnBody += '}\n' - args1.push(invokerFnBody) - var invokerFunction = new_(Function, args1).apply(null, args2) - return invokerFunction - } - function ensureOverloadTable(proto, methodName, humanName) { - if (undefined === proto[methodName].overloadTable) { - var prevFunc = proto[methodName] - proto[methodName] = function () { - if ( - !proto[methodName].overloadTable.hasOwnProperty(arguments.length) - ) { - throwBindingError( - "Function '" + - humanName + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - proto[methodName].overloadTable + - ')!' - ) - } - return proto[methodName].overloadTable[arguments.length].apply( - this, - arguments - ) - } - proto[methodName].overloadTable = [] - proto[methodName].overloadTable[prevFunc.argCount] = prevFunc - } - } - function exposePublicSymbol(name, value, numArguments) { - if (Module.hasOwnProperty(name)) { - if ( - undefined === numArguments || - (undefined !== Module[name].overloadTable && - undefined !== Module[name].overloadTable[numArguments]) - ) { - throwBindingError("Cannot register public name '" + name + "' twice") - } - ensureOverloadTable(Module, name, name) - if (Module.hasOwnProperty(numArguments)) { - throwBindingError( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - numArguments + - ')!' - ) - } - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - if (undefined !== numArguments) { - Module[name].numArguments = numArguments - } - } - } - function heap32VectorToArray(count, firstElement) { - var array = [] - for (var i = 0; i < count; i++) { - array.push(HEAP32[(firstElement >> 2) + i]) - } - return array - } - function replacePublicSymbol(name, value, numArguments) { - if (!Module.hasOwnProperty(name)) { - throwInternalError('Replacing nonexistent public symbol') - } - if ( - undefined !== Module[name].overloadTable && - undefined !== numArguments - ) { - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - Module[name].argCount = numArguments - } - } - function dynCallLegacy(sig, ptr, args) { - var f = Module['dynCall_' + sig] - return args && args.length - ? f.apply(null, [ptr].concat(args)) - : f.call(null, ptr) - } - function dynCall(sig, ptr, args) { - if (sig.includes('j')) { - return dynCallLegacy(sig, ptr, args) - } - return wasmTable.get(ptr).apply(null, args) - } - function getDynCaller(sig, ptr) { - var argCache = [] - return function () { - argCache.length = arguments.length - for (var i = 0; i < arguments.length; i++) { - argCache[i] = arguments[i] - } - return dynCall(sig, ptr, argCache) - } - } - function embind__requireFunction(signature, rawFunction) { - signature = readLatin1String(signature) - function makeDynCaller() { - if (signature.includes('j')) { - return getDynCaller(signature, rawFunction) - } - return wasmTable.get(rawFunction) - } - var fp = makeDynCaller() - if (typeof fp !== 'function') { - throwBindingError( - 'unknown function pointer with signature ' + - signature + - ': ' + - rawFunction - ) - } - return fp - } - var UnboundTypeError = undefined - function getTypeName(type) { - var ptr = ___getTypeName(type) - var rv = readLatin1String(ptr) - _free(ptr) - return rv - } - function throwUnboundTypeError(message, types) { - var unboundTypes = [] - var seen = {} - function visit(type) { - if (seen[type]) { - return - } - if (registeredTypes[type]) { - return - } - if (typeDependencies[type]) { - typeDependencies[type].forEach(visit) - return - } - unboundTypes.push(type) - seen[type] = true - } - types.forEach(visit) - throw new UnboundTypeError( - message + ': ' + unboundTypes.map(getTypeName).join([', ']) - ) - } - function __embind_register_function( - name, - argCount, - rawArgTypesAddr, - signature, - rawInvoker, - fn - ) { - var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr) - name = readLatin1String(name) - rawInvoker = embind__requireFunction(signature, rawInvoker) - exposePublicSymbol( - name, - function () { - throwUnboundTypeError( - 'Cannot call ' + name + ' due to unbound types', - argTypes - ) - }, - argCount - 1 - ) - whenDependentTypesAreResolved([], argTypes, function (argTypes) { - var invokerArgsArray = [argTypes[0], null].concat(argTypes.slice(1)) - replacePublicSymbol( - name, - craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn), - argCount - 1 - ) - return [] - }) - } - function integerReadValueFromPointer(name, shift, signed) { - switch (shift) { - case 0: - return signed - ? function readS8FromPointer(pointer) { - return HEAP8[pointer] - } - : function readU8FromPointer(pointer) { - return HEAPU8[pointer] - } - case 1: - return signed - ? function readS16FromPointer(pointer) { - return HEAP16[pointer >> 1] - } - : function readU16FromPointer(pointer) { - return HEAPU16[pointer >> 1] - } - case 2: - return signed - ? function readS32FromPointer(pointer) { - return HEAP32[pointer >> 2] - } - : function readU32FromPointer(pointer) { - return HEAPU32[pointer >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + name) - } - } - function __embind_register_integer( - primitiveType, - name, - size, - minRange, - maxRange - ) { - name = readLatin1String(name) - if (maxRange === -1) { - maxRange = 4294967295 - } - var shift = getShiftFromSize(size) - var fromWireType = function (value) { - return value - } - if (minRange === 0) { - var bitshift = 32 - 8 * size - fromWireType = function (value) { - return (value << bitshift) >>> bitshift - } - } - var isUnsignedType = name.includes('unsigned') - registerType(primitiveType, { - name: name, - fromWireType: fromWireType, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - if (value < minRange || value > maxRange) { - throw new TypeError( - 'Passing a number "' + - _embind_repr(value) + - '" from JS side to C/C++ side to an argument of type "' + - name + - '", which is outside the valid range [' + - minRange + - ', ' + - maxRange + - ']!' - ) - } - return isUnsignedType ? value >>> 0 : value | 0 - }, - argPackAdvance: 8, - readValueFromPointer: integerReadValueFromPointer( - name, - shift, - minRange !== 0 - ), - destructorFunction: null, - }) - } - function __embind_register_memory_view(rawType, dataTypeIndex, name) { - var typeMapping = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ] - var TA = typeMapping[dataTypeIndex] - function decodeMemoryView(handle) { - handle = handle >> 2 - var heap = HEAPU32 - var size = heap[handle] - var data = heap[handle + 1] - return new TA(buffer, data, size) - } - name = readLatin1String(name) - registerType( - rawType, - { - name: name, - fromWireType: decodeMemoryView, - argPackAdvance: 8, - readValueFromPointer: decodeMemoryView, - }, - { ignoreDuplicateRegistrations: true } - ) - } - function __embind_register_std_string(rawType, name) { - name = readLatin1String(name) - var stdStringIsUTF8 = name === 'std::string' - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var str - if (stdStringIsUTF8) { - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i - if (i == length || HEAPU8[currentBytePtr] == 0) { - var maxRead = currentBytePtr - decodeStartPtr - var stringSegment = UTF8ToString(decodeStartPtr, maxRead) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + 1 - } - } - } else { - var a = new Array(length) - for (var i = 0; i < length; ++i) { - a[i] = String.fromCharCode(HEAPU8[value + 4 + i]) - } - str = a.join('') - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (value instanceof ArrayBuffer) { - value = new Uint8Array(value) - } - var getLength - var valueIsOfTypeString = typeof value === 'string' - if ( - !( - valueIsOfTypeString || - value instanceof Uint8Array || - value instanceof Uint8ClampedArray || - value instanceof Int8Array - ) - ) { - throwBindingError('Cannot pass non-string to std::string') - } - if (stdStringIsUTF8 && valueIsOfTypeString) { - getLength = function () { - return lengthBytesUTF8(value) - } - } else { - getLength = function () { - return value.length - } - } - var length = getLength() - var ptr = _malloc(4 + length + 1) - HEAPU32[ptr >> 2] = length - if (stdStringIsUTF8 && valueIsOfTypeString) { - stringToUTF8(value, ptr + 4, length + 1) - } else { - if (valueIsOfTypeString) { - for (var i = 0; i < length; ++i) { - var charCode = value.charCodeAt(i) - if (charCode > 255) { - _free(ptr) - throwBindingError( - 'String has UTF-16 code units that do not fit in 8 bits' - ) - } - HEAPU8[ptr + 4 + i] = charCode - } - } else { - for (var i = 0; i < length; ++i) { - HEAPU8[ptr + 4 + i] = value[i] - } - } - } - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_std_wstring(rawType, charSize, name) { - name = readLatin1String(name) - var decodeString, encodeString, getHeap, lengthBytesUTF, shift - if (charSize === 2) { - decodeString = UTF16ToString - encodeString = stringToUTF16 - lengthBytesUTF = lengthBytesUTF16 - getHeap = function () { - return HEAPU16 - } - shift = 1 - } else if (charSize === 4) { - decodeString = UTF32ToString - encodeString = stringToUTF32 - lengthBytesUTF = lengthBytesUTF32 - getHeap = function () { - return HEAPU32 - } - shift = 2 - } - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var HEAP = getHeap() - var str - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i * charSize - if (i == length || HEAP[currentBytePtr >> shift] == 0) { - var maxReadBytes = currentBytePtr - decodeStartPtr - var stringSegment = decodeString(decodeStartPtr, maxReadBytes) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + charSize - } - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (!(typeof value === 'string')) { - throwBindingError( - 'Cannot pass non-string to C++ string type ' + name - ) - } - var length = lengthBytesUTF(value) - var ptr = _malloc(4 + length + charSize) - HEAPU32[ptr >> 2] = length >> shift - encodeString(value, ptr + 4, length + charSize) - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_void(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - isVoid: true, - name: name, - argPackAdvance: 0, - fromWireType: function () { - return undefined - }, - toWireType: function (destructors, o) { - return undefined - }, - }) - } - var emval_symbols = {} - function getStringOrSymbol(address) { - var symbol = emval_symbols[address] - if (symbol === undefined) { - return readLatin1String(address) - } else { - return symbol - } - } - function emval_get_global() { - if (typeof globalThis === 'object') { - return globalThis - } - return (function () { - return Function - })()('return this')() - } - function __emval_get_global(name) { - if (name === 0) { - return __emval_register(emval_get_global()) - } else { - name = getStringOrSymbol(name) - return __emval_register(emval_get_global()[name]) - } - } - function __emval_incref(handle) { - if (handle > 4) { - emval_handle_array[handle].refcount += 1 - } - } - function requireRegisteredType(rawType, humanName) { - var impl = registeredTypes[rawType] - if (undefined === impl) { - throwBindingError( - humanName + ' has unknown type ' + getTypeName(rawType) - ) - } - return impl - } - function craftEmvalAllocator(argCount) { - var argsList = '' - for (var i = 0; i < argCount; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - } - var functionBody = - 'return function emval_allocator_' + - argCount + - '(constructor, argTypes, args) {\n' - for (var i = 0; i < argCount; ++i) { - functionBody += - 'var argType' + - i + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - i + - '], "parameter ' + - i + - '");\n' + - 'var arg' + - i + - ' = argType' + - i + - '.readValueFromPointer(args);\n' + - 'args += argType' + - i + - "['argPackAdvance'];\n" - } - functionBody += - 'var obj = new constructor(' + - argsList + - ');\n' + - 'return __emval_register(obj);\n' + - '}\n' - return new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - functionBody - )(requireRegisteredType, Module, __emval_register) - } - var emval_newers = {} - function requireHandle(handle) { - if (!handle) { - throwBindingError('Cannot use deleted val. handle = ' + handle) - } - return emval_handle_array[handle].value - } - function __emval_new(handle, argCount, argTypes, args) { - handle = requireHandle(handle) - var newer = emval_newers[argCount] - if (!newer) { - newer = craftEmvalAllocator(argCount) - emval_newers[argCount] = newer - } - return newer(handle, argTypes, args) - } - function _abort() { - abort() - } - function _longjmp(env, value) { - _setThrew(env, value || 1) - throw 'longjmp' - } - function _emscripten_longjmp(a0, a1) { - return _longjmp(a0, a1) - } - function _emscripten_memcpy_big(dest, src, num) { - HEAPU8.copyWithin(dest, src, src + num) - } - function emscripten_realloc_buffer(size) { - try { - wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16) - updateGlobalBufferAndViews(wasmMemory.buffer) - return 1 - } catch (e) {} - } - function _emscripten_resize_heap(requestedSize) { - var oldSize = HEAPU8.length - requestedSize = requestedSize >>> 0 - var maxHeapSize = 2147483648 - if (requestedSize > maxHeapSize) { - return false - } - for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { - var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown) - overGrownHeapSize = Math.min( - overGrownHeapSize, - requestedSize + 100663296 - ) - var newSize = Math.min( - maxHeapSize, - alignUp(Math.max(requestedSize, overGrownHeapSize), 65536) - ) - var replacement = emscripten_realloc_buffer(newSize) - if (replacement) { - return true - } - } - return false - } - var SYSCALLS = { - mappings: {}, - buffers: [null, [], []], - printChar: function (stream, curr) { - var buffer = SYSCALLS.buffers[stream] - if (curr === 0 || curr === 10) { - ;(stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0)) - buffer.length = 0 - } else { - buffer.push(curr) - } - }, - varargs: undefined, - get: function () { - SYSCALLS.varargs += 4 - var ret = HEAP32[(SYSCALLS.varargs - 4) >> 2] - return ret - }, - getStr: function (ptr) { - var ret = UTF8ToString(ptr) - return ret - }, - get64: function (low, high) { - return low - }, - } - function _fd_close(fd) { - return 0 - } - function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {} - function _fd_write(fd, iov, iovcnt, pnum) { - var num = 0 - for (var i = 0; i < iovcnt; i++) { - var ptr = HEAP32[(iov + i * 8) >> 2] - var len = HEAP32[(iov + (i * 8 + 4)) >> 2] - for (var j = 0; j < len; j++) { - SYSCALLS.printChar(fd, HEAPU8[ptr + j]) - } - num += len - } - HEAP32[pnum >> 2] = num - return 0 - } - function _getTempRet0() { - return getTempRet0() - } - function _setTempRet0(val) { - setTempRet0(val) - } - embind_init_charCodes() - BindingError = Module['BindingError'] = extendError(Error, 'BindingError') - InternalError = Module['InternalError'] = extendError( - Error, - 'InternalError' - ) - init_emval() - UnboundTypeError = Module['UnboundTypeError'] = extendError( - Error, - 'UnboundTypeError' - ) - var asmLibraryArg = { - j: ___cxa_thread_atexit, - v: __embind_register_bigint, - r: __embind_register_bool, - B: __embind_register_emval, - q: __embind_register_float, - t: __embind_register_function, - e: __embind_register_integer, - d: __embind_register_memory_view, - m: __embind_register_std_string, - l: __embind_register_std_wstring, - s: __embind_register_void, - h: __emval_decref, - i: __emval_get_global, - n: __emval_incref, - o: __emval_new, - a: _abort, - g: _emscripten_longjmp, - y: _emscripten_memcpy_big, - k: _emscripten_resize_heap, - A: _fd_close, - u: _fd_seek, - z: _fd_write, - b: _getTempRet0, - f: invoke_iii, - w: invoke_iiiii, - p: invoke_viiii, - x: invoke_viiiiiii, - c: _setTempRet0, - } - var asm = createWasm() - var ___wasm_call_ctors = (Module['___wasm_call_ctors'] = function () { - return (___wasm_call_ctors = Module['___wasm_call_ctors'] = - Module['asm']['D']).apply(null, arguments) - }) - var _malloc = (Module['_malloc'] = function () { - return (_malloc = Module['_malloc'] = Module['asm']['E']).apply( - null, - arguments - ) - }) - var _free = (Module['_free'] = function () { - return (_free = Module['_free'] = Module['asm']['F']).apply( - null, - arguments - ) - }) - var ___getTypeName = (Module['___getTypeName'] = function () { - return (___getTypeName = Module['___getTypeName'] = - Module['asm']['G']).apply(null, arguments) - }) - var ___embind_register_native_and_builtin_types = (Module[ - '___embind_register_native_and_builtin_types' - ] = function () { - return (___embind_register_native_and_builtin_types = Module[ - '___embind_register_native_and_builtin_types' - ] = - Module['asm']['H']).apply(null, arguments) - }) - var stackSave = (Module['stackSave'] = function () { - return (stackSave = Module['stackSave'] = Module['asm']['I']).apply( - null, - arguments - ) - }) - var stackRestore = (Module['stackRestore'] = function () { - return (stackRestore = Module['stackRestore'] = Module['asm']['J']).apply( - null, - arguments - ) - }) - var _setThrew = (Module['_setThrew'] = function () { - return (_setThrew = Module['_setThrew'] = Module['asm']['K']).apply( - null, - arguments - ) - }) - var dynCall_iiijii = (Module['dynCall_iiijii'] = function () { - return (dynCall_iiijii = Module['dynCall_iiijii'] = - Module['asm']['M']).apply(null, arguments) - }) - var dynCall_jiji = (Module['dynCall_jiji'] = function () { - return (dynCall_jiji = Module['dynCall_jiji'] = Module['asm']['N']).apply( - null, - arguments - ) - }) - function invoke_viiiiiii(index, a1, a2, a3, a4, a5, a6, a7) { - var sp = stackSave() - try { - wasmTable.get(index)(a1, a2, a3, a4, a5, a6, a7) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_viiii(index, a1, a2, a3, a4) { - var sp = stackSave() - try { - wasmTable.get(index)(a1, a2, a3, a4) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_iii(index, a1, a2) { - var sp = stackSave() - try { - return wasmTable.get(index)(a1, a2) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_iiiii(index, a1, a2, a3, a4) { - var sp = stackSave() - try { - return wasmTable.get(index)(a1, a2, a3, a4) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - var calledRun - dependenciesFulfilled = function runCaller() { - if (!calledRun) run() - if (!calledRun) dependenciesFulfilled = runCaller - } - function run(args) { - args = args || arguments_ - if (runDependencies > 0) { - return - } - preRun() - if (runDependencies > 0) { - return - } - function doRun() { - if (calledRun) return - calledRun = true - Module['calledRun'] = true - if (ABORT) return - initRuntime() - readyPromiseResolve(Module) - if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']() - postRun() - } - if (Module['setStatus']) { - Module['setStatus']('Running...') - setTimeout(function () { - setTimeout(function () { - Module['setStatus']('') - }, 1) - doRun() - }, 1) - } else { - doRun() - } - } - Module['run'] = run - if (Module['preInit']) { - if (typeof Module['preInit'] == 'function') - Module['preInit'] = [Module['preInit']] - while (Module['preInit'].length > 0) { - Module['preInit'].pop()() - } - } - run() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/src/server/lib/squoosh/avif/avif_node_dec.wasm b/packages/next/src/server/lib/squoosh/avif/avif_node_dec.wasm deleted file mode 100755 index 1cd4e1b034..0000000000 Binary files a/packages/next/src/server/lib/squoosh/avif/avif_node_dec.wasm and /dev/null differ diff --git a/packages/next/src/server/lib/squoosh/avif/avif_node_enc.js b/packages/next/src/server/lib/squoosh/avif/avif_node_enc.js deleted file mode 100644 index 4007393a4a..0000000000 --- a/packages/next/src/server/lib/squoosh/avif/avif_node_enc.js +++ /dev/null @@ -1,2027 +0,0 @@ -/* eslint-disable */ -var Module = (function () { - return function (Module) { - Module = Module || {} - - var Module = typeof Module !== 'undefined' ? Module : {} - var readyPromiseResolve, readyPromiseReject - Module['ready'] = new Promise(function (resolve, reject) { - readyPromiseResolve = resolve - readyPromiseReject = reject - }) - var moduleOverrides = {} - var key - for (key in Module) { - if (Module.hasOwnProperty(key)) { - moduleOverrides[key] = Module[key] - } - } - var arguments_ = [] - var thisProgram = './this.program' - var quit_ = function (status, toThrow) { - throw toThrow - } - var ENVIRONMENT_IS_WEB = false - var ENVIRONMENT_IS_WORKER = false - var ENVIRONMENT_IS_NODE = true - var scriptDirectory = '' - function locateFile(path) { - if (Module['locateFile']) { - return Module['locateFile'](path, scriptDirectory) - } - return scriptDirectory + path - } - var read_, readBinary - var nodeFS - var nodePath - if (ENVIRONMENT_IS_NODE) { - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = require('path').dirname(scriptDirectory) + '/' - } else { - scriptDirectory = __dirname + '/' - } - read_ = function shell_read(filename, binary) { - if (!nodeFS) nodeFS = require('fs') - if (!nodePath) nodePath = require('path') - filename = nodePath['normalize'](filename) - return nodeFS['readFileSync'](filename, binary ? null : 'utf8') - } - readBinary = function readBinary(filename) { - var ret = read_(filename, true) - if (!ret.buffer) { - ret = new Uint8Array(ret) - } - assert(ret.buffer) - return ret - } - if (process['argv'].length > 1) { - thisProgram = process['argv'][1].replace(/\\/g, '/') - } - arguments_ = process['argv'].slice(2) - quit_ = function (status) { - process['exit'](status) - } - Module['inspect'] = function () { - return '[Emscripten Module object]' - } - } else { - } - var out = Module['print'] || console.log.bind(console) - var err = Module['printErr'] || console.warn.bind(console) - for (key in moduleOverrides) { - if (moduleOverrides.hasOwnProperty(key)) { - Module[key] = moduleOverrides[key] - } - } - moduleOverrides = null - if (Module['arguments']) arguments_ = Module['arguments'] - if (Module['thisProgram']) thisProgram = Module['thisProgram'] - if (Module['quit']) quit_ = Module['quit'] - var tempRet0 = 0 - var setTempRet0 = function (value) { - tempRet0 = value - } - var getTempRet0 = function () { - return tempRet0 - } - var wasmBinary - if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'] - var noExitRuntime = Module['noExitRuntime'] || true - if (typeof WebAssembly !== 'object') { - abort('no native wasm support detected') - } - var wasmMemory - var ABORT = false - var EXITSTATUS - function assert(condition, text) { - if (!condition) { - abort('Assertion failed: ' + text) - } - } - var UTF8Decoder = new TextDecoder('utf8') - function UTF8ArrayToString(heap, idx, maxBytesToRead) { - var endIdx = idx + maxBytesToRead - var endPtr = idx - while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr - return UTF8Decoder.decode( - heap.subarray - ? heap.subarray(idx, endPtr) - : new Uint8Array(heap.slice(idx, endPtr)) - ) - } - function UTF8ToString(ptr, maxBytesToRead) { - if (!ptr) return '' - var maxPtr = ptr + maxBytesToRead - for (var end = ptr; !(end >= maxPtr) && HEAPU8[end]; ) ++end - return UTF8Decoder.decode(HEAPU8.subarray(ptr, end)) - } - function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { - if (!(maxBytesToWrite > 0)) return 0 - var startIdx = outIdx - var endIdx = outIdx + maxBytesToWrite - 1 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) { - var u1 = str.charCodeAt(++i) - u = (65536 + ((u & 1023) << 10)) | (u1 & 1023) - } - if (u <= 127) { - if (outIdx >= endIdx) break - heap[outIdx++] = u - } else if (u <= 2047) { - if (outIdx + 1 >= endIdx) break - heap[outIdx++] = 192 | (u >> 6) - heap[outIdx++] = 128 | (u & 63) - } else if (u <= 65535) { - if (outIdx + 2 >= endIdx) break - heap[outIdx++] = 224 | (u >> 12) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } else { - if (outIdx + 3 >= endIdx) break - heap[outIdx++] = 240 | (u >> 18) - heap[outIdx++] = 128 | ((u >> 12) & 63) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } - } - heap[outIdx] = 0 - return outIdx - startIdx - } - function stringToUTF8(str, outPtr, maxBytesToWrite) { - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite) - } - function lengthBytesUTF8(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) - u = (65536 + ((u & 1023) << 10)) | (str.charCodeAt(++i) & 1023) - if (u <= 127) ++len - else if (u <= 2047) len += 2 - else if (u <= 65535) len += 3 - else len += 4 - } - return len - } - var UTF16Decoder = new TextDecoder('utf-16le') - function UTF16ToString(ptr, maxBytesToRead) { - var endPtr = ptr - var idx = endPtr >> 1 - var maxIdx = idx + maxBytesToRead / 2 - while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx - endPtr = idx << 1 - return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)) - var str = '' - for (var i = 0; !(i >= maxBytesToRead / 2); ++i) { - var codeUnit = HEAP16[(ptr + i * 2) >> 1] - if (codeUnit == 0) break - str += String.fromCharCode(codeUnit) - } - return str - } - function stringToUTF16(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 2) return 0 - maxBytesToWrite -= 2 - var startPtr = outPtr - var numCharsToWrite = - maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length - for (var i = 0; i < numCharsToWrite; ++i) { - var codeUnit = str.charCodeAt(i) - HEAP16[outPtr >> 1] = codeUnit - outPtr += 2 - } - HEAP16[outPtr >> 1] = 0 - return outPtr - startPtr - } - function lengthBytesUTF16(str) { - return str.length * 2 - } - function UTF32ToString(ptr, maxBytesToRead) { - var i = 0 - var str = '' - while (!(i >= maxBytesToRead / 4)) { - var utf32 = HEAP32[(ptr + i * 4) >> 2] - if (utf32 == 0) break - ++i - if (utf32 >= 65536) { - var ch = utf32 - 65536 - str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023)) - } else { - str += String.fromCharCode(utf32) - } - } - return str - } - function stringToUTF32(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 4) return 0 - var startPtr = outPtr - var endPtr = startPtr + maxBytesToWrite - 4 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) { - var trailSurrogate = str.charCodeAt(++i) - codeUnit = - (65536 + ((codeUnit & 1023) << 10)) | (trailSurrogate & 1023) - } - HEAP32[outPtr >> 2] = codeUnit - outPtr += 4 - if (outPtr + 4 > endPtr) break - } - HEAP32[outPtr >> 2] = 0 - return outPtr - startPtr - } - function lengthBytesUTF32(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) ++i - len += 4 - } - return len - } - function alignUp(x, multiple) { - if (x % multiple > 0) { - x += multiple - (x % multiple) - } - return x - } - var buffer, - HEAP8, - HEAPU8, - HEAP16, - HEAPU16, - HEAP32, - HEAPU32, - HEAPF32, - HEAPF64 - function updateGlobalBufferAndViews(buf) { - buffer = buf - Module['HEAP8'] = HEAP8 = new Int8Array(buf) - Module['HEAP16'] = HEAP16 = new Int16Array(buf) - Module['HEAP32'] = HEAP32 = new Int32Array(buf) - Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf) - Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf) - Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf) - Module['HEAPF32'] = HEAPF32 = new Float32Array(buf) - Module['HEAPF64'] = HEAPF64 = new Float64Array(buf) - } - var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216 - var wasmTable - var __ATPRERUN__ = [] - var __ATINIT__ = [] - var __ATPOSTRUN__ = [] - var runtimeInitialized = false - function preRun() { - if (Module['preRun']) { - if (typeof Module['preRun'] == 'function') - Module['preRun'] = [Module['preRun']] - while (Module['preRun'].length) { - addOnPreRun(Module['preRun'].shift()) - } - } - callRuntimeCallbacks(__ATPRERUN__) - } - function initRuntime() { - runtimeInitialized = true - callRuntimeCallbacks(__ATINIT__) - } - function postRun() { - if (Module['postRun']) { - if (typeof Module['postRun'] == 'function') - Module['postRun'] = [Module['postRun']] - while (Module['postRun'].length) { - addOnPostRun(Module['postRun'].shift()) - } - } - callRuntimeCallbacks(__ATPOSTRUN__) - } - function addOnPreRun(cb) { - __ATPRERUN__.unshift(cb) - } - function addOnInit(cb) { - __ATINIT__.unshift(cb) - } - function addOnPostRun(cb) { - __ATPOSTRUN__.unshift(cb) - } - var runDependencies = 0 - var runDependencyWatcher = null - var dependenciesFulfilled = null - function addRunDependency(id) { - runDependencies++ - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - } - function removeRunDependency(id) { - runDependencies-- - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - if (runDependencies == 0) { - if (runDependencyWatcher !== null) { - clearInterval(runDependencyWatcher) - runDependencyWatcher = null - } - if (dependenciesFulfilled) { - var callback = dependenciesFulfilled - dependenciesFulfilled = null - callback() - } - } - } - Module['preloadedImages'] = {} - Module['preloadedAudios'] = {} - function abort(what) { - if (Module['onAbort']) { - Module['onAbort'](what) - } - what += '' - err(what) - ABORT = true - EXITSTATUS = 1 - what = 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.' - var e = new WebAssembly.RuntimeError(what) - readyPromiseReject(e) - throw e - } - var dataURIPrefix = 'data:application/octet-stream;base64,' - function isDataURI(filename) { - return filename.startsWith(dataURIPrefix) - } - if (Module['locateFile']) { - var wasmBinaryFile = 'avif_node_enc.wasm' - if (!isDataURI(wasmBinaryFile)) { - wasmBinaryFile = locateFile(wasmBinaryFile) - } - } else { - throw new Error('invariant') - } - function getBinary(file) { - try { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary) - } - if (readBinary) { - return readBinary(file) - } else { - throw 'both async and sync fetching of the wasm failed' - } - } catch (err) { - abort(err) - } - } - function getBinaryPromise() { - return Promise.resolve().then(function () { - return getBinary(wasmBinaryFile) - }) - } - function createWasm() { - var info = { a: asmLibraryArg } - function receiveInstance(instance, module) { - var exports = instance.exports - Module['asm'] = exports - wasmMemory = Module['asm']['P'] - updateGlobalBufferAndViews(wasmMemory.buffer) - wasmTable = Module['asm']['Y'] - addOnInit(Module['asm']['Q']) - removeRunDependency('wasm-instantiate') - } - addRunDependency('wasm-instantiate') - function receiveInstantiationResult(result) { - receiveInstance(result['instance']) - } - function instantiateArrayBuffer(receiver) { - return getBinaryPromise() - .then(function (binary) { - var result = WebAssembly.instantiate(binary, info) - return result - }) - .then(receiver, function (reason) { - err('failed to asynchronously prepare wasm: ' + reason) - abort(reason) - }) - } - function instantiateAsync() { - return instantiateArrayBuffer(receiveInstantiationResult) - } - if (Module['instantiateWasm']) { - try { - var exports = Module['instantiateWasm'](info, receiveInstance) - return exports - } catch (e) { - err('Module.instantiateWasm callback failed with error: ' + e) - return false - } - } - instantiateAsync().catch(readyPromiseReject) - return {} - } - function callRuntimeCallbacks(callbacks) { - while (callbacks.length > 0) { - var callback = callbacks.shift() - if (typeof callback == 'function') { - callback(Module) - continue - } - var func = callback.func - if (typeof func === 'number') { - if (callback.arg === undefined) { - wasmTable.get(func)() - } else { - wasmTable.get(func)(callback.arg) - } - } else { - func(callback.arg === undefined ? null : callback.arg) - } - } - } - function _atexit(func, arg) {} - function ___cxa_thread_atexit(a0, a1) { - return _atexit(a0, a1) - } - var SYSCALLS = { - mappings: {}, - buffers: [null, [], []], - printChar: function (stream, curr) { - var buffer = SYSCALLS.buffers[stream] - if (curr === 0 || curr === 10) { - ;(stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0)) - buffer.length = 0 - } else { - buffer.push(curr) - } - }, - varargs: undefined, - get: function () { - SYSCALLS.varargs += 4 - var ret = HEAP32[(SYSCALLS.varargs - 4) >> 2] - return ret - }, - getStr: function (ptr) { - var ret = UTF8ToString(ptr) - return ret - }, - get64: function (low, high) { - return low - }, - } - function ___sys_fcntl64(fd, cmd, varargs) { - SYSCALLS.varargs = varargs - return 0 - } - function ___sys_ioctl(fd, op, varargs) { - SYSCALLS.varargs = varargs - return 0 - } - function ___sys_open(path, flags, varargs) { - SYSCALLS.varargs = varargs - } - var structRegistrations = {} - function runDestructors(destructors) { - while (destructors.length) { - var ptr = destructors.pop() - var del = destructors.pop() - del(ptr) - } - } - function simpleReadValueFromPointer(pointer) { - return this['fromWireType'](HEAPU32[pointer >> 2]) - } - var awaitingDependencies = {} - var registeredTypes = {} - var typeDependencies = {} - var char_0 = 48 - var char_9 = 57 - function makeLegalFunctionName(name) { - if (undefined === name) { - return '_unknown' - } - name = name.replace(/[^a-zA-Z0-9_]/g, '$') - var f = name.charCodeAt(0) - if (f >= char_0 && f <= char_9) { - return '_' + name - } else { - return name - } - } - function createNamedFunction(name, body) { - name = makeLegalFunctionName(name) - return new Function( - 'body', - 'return function ' + - name + - '() {\n' + - ' "use strict";' + - ' return body.apply(this, arguments);\n' + - '};\n' - )(body) - } - function extendError(baseErrorType, errorName) { - var errorClass = createNamedFunction(errorName, function (message) { - this.name = errorName - this.message = message - var stack = new Error(message).stack - if (stack !== undefined) { - this.stack = - this.toString() + '\n' + stack.replace(/^Error(:[^\n]*)?\n/, '') - } - }) - errorClass.prototype = Object.create(baseErrorType.prototype) - errorClass.prototype.constructor = errorClass - errorClass.prototype.toString = function () { - if (this.message === undefined) { - return this.name - } else { - return this.name + ': ' + this.message - } - } - return errorClass - } - var InternalError = undefined - function throwInternalError(message) { - throw new InternalError(message) - } - function whenDependentTypesAreResolved( - myTypes, - dependentTypes, - getTypeConverters - ) { - myTypes.forEach(function (type) { - typeDependencies[type] = dependentTypes - }) - function onComplete(typeConverters) { - var myTypeConverters = getTypeConverters(typeConverters) - if (myTypeConverters.length !== myTypes.length) { - throwInternalError('Mismatched type converter count') - } - for (var i = 0; i < myTypes.length; ++i) { - registerType(myTypes[i], myTypeConverters[i]) - } - } - var typeConverters = new Array(dependentTypes.length) - var unregisteredTypes = [] - var registered = 0 - dependentTypes.forEach(function (dt, i) { - if (registeredTypes.hasOwnProperty(dt)) { - typeConverters[i] = registeredTypes[dt] - } else { - unregisteredTypes.push(dt) - if (!awaitingDependencies.hasOwnProperty(dt)) { - awaitingDependencies[dt] = [] - } - awaitingDependencies[dt].push(function () { - typeConverters[i] = registeredTypes[dt] - ++registered - if (registered === unregisteredTypes.length) { - onComplete(typeConverters) - } - }) - } - }) - if (0 === unregisteredTypes.length) { - onComplete(typeConverters) - } - } - function __embind_finalize_value_object(structType) { - var reg = structRegistrations[structType] - delete structRegistrations[structType] - var rawConstructor = reg.rawConstructor - var rawDestructor = reg.rawDestructor - var fieldRecords = reg.fields - var fieldTypes = fieldRecords - .map(function (field) { - return field.getterReturnType - }) - .concat( - fieldRecords.map(function (field) { - return field.setterArgumentType - }) - ) - whenDependentTypesAreResolved( - [structType], - fieldTypes, - function (fieldTypes) { - var fields = {} - fieldRecords.forEach(function (field, i) { - var fieldName = field.fieldName - var getterReturnType = fieldTypes[i] - var getter = field.getter - var getterContext = field.getterContext - var setterArgumentType = fieldTypes[i + fieldRecords.length] - var setter = field.setter - var setterContext = field.setterContext - fields[fieldName] = { - read: function (ptr) { - return getterReturnType['fromWireType']( - getter(getterContext, ptr) - ) - }, - write: function (ptr, o) { - var destructors = [] - setter( - setterContext, - ptr, - setterArgumentType['toWireType'](destructors, o) - ) - runDestructors(destructors) - }, - } - }) - return [ - { - name: reg.name, - fromWireType: function (ptr) { - var rv = {} - for (var i in fields) { - rv[i] = fields[i].read(ptr) - } - rawDestructor(ptr) - return rv - }, - toWireType: function (destructors, o) { - for (var fieldName in fields) { - if (!(fieldName in o)) { - throw new TypeError('Missing field: "' + fieldName + '"') - } - } - var ptr = rawConstructor() - for (fieldName in fields) { - fields[fieldName].write(ptr, o[fieldName]) - } - if (destructors !== null) { - destructors.push(rawDestructor, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: rawDestructor, - }, - ] - } - ) - } - function __embind_register_bigint( - primitiveType, - name, - size, - minRange, - maxRange - ) {} - function getShiftFromSize(size) { - switch (size) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + size) - } - } - function embind_init_charCodes() { - var codes = new Array(256) - for (var i = 0; i < 256; ++i) { - codes[i] = String.fromCharCode(i) - } - embind_charCodes = codes - } - var embind_charCodes = undefined - function readLatin1String(ptr) { - var ret = '' - var c = ptr - while (HEAPU8[c]) { - ret += embind_charCodes[HEAPU8[c++]] - } - return ret - } - var BindingError = undefined - function throwBindingError(message) { - throw new BindingError(message) - } - function registerType(rawType, registeredInstance, options) { - options = options || {} - if (!('argPackAdvance' in registeredInstance)) { - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - } - var name = registeredInstance.name - if (!rawType) { - throwBindingError( - 'type "' + name + '" must have a positive integer typeid pointer' - ) - } - if (registeredTypes.hasOwnProperty(rawType)) { - if (options.ignoreDuplicateRegistrations) { - return - } else { - throwBindingError("Cannot register type '" + name + "' twice") - } - } - registeredTypes[rawType] = registeredInstance - delete typeDependencies[rawType] - if (awaitingDependencies.hasOwnProperty(rawType)) { - var callbacks = awaitingDependencies[rawType] - delete awaitingDependencies[rawType] - callbacks.forEach(function (cb) { - cb() - }) - } - } - function __embind_register_bool( - rawType, - name, - size, - trueValue, - falseValue - ) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (wt) { - return !!wt - }, - toWireType: function (destructors, o) { - return o ? trueValue : falseValue - }, - argPackAdvance: 8, - readValueFromPointer: function (pointer) { - var heap - if (size === 1) { - heap = HEAP8 - } else if (size === 2) { - heap = HEAP16 - } else if (size === 4) { - heap = HEAP32 - } else { - throw new TypeError('Unknown boolean type size: ' + name) - } - return this['fromWireType'](heap[pointer >> shift]) - }, - destructorFunction: null, - }) - } - var emval_free_list = [] - var emval_handle_array = [ - {}, - { value: undefined }, - { value: null }, - { value: true }, - { value: false }, - ] - function __emval_decref(handle) { - if (handle > 4 && 0 === --emval_handle_array[handle].refcount) { - emval_handle_array[handle] = undefined - emval_free_list.push(handle) - } - } - function count_emval_handles() { - var count = 0 - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - ++count - } - } - return count - } - function get_first_emval() { - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - return emval_handle_array[i] - } - } - return null - } - function init_emval() { - Module['count_emval_handles'] = count_emval_handles - Module['get_first_emval'] = get_first_emval - } - function __emval_register(value) { - switch (value) { - case undefined: { - return 1 - } - case null: { - return 2 - } - case true: { - return 3 - } - case false: { - return 4 - } - default: { - var handle = emval_free_list.length - ? emval_free_list.pop() - : emval_handle_array.length - emval_handle_array[handle] = { refcount: 1, value: value } - return handle - } - } - } - function __embind_register_emval(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (handle) { - var rv = emval_handle_array[handle].value - __emval_decref(handle) - return rv - }, - toWireType: function (destructors, value) { - return __emval_register(value) - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: null, - }) - } - function _embind_repr(v) { - if (v === null) { - return 'null' - } - var t = typeof v - if (t === 'object' || t === 'array' || t === 'function') { - return v.toString() - } else { - return '' + v - } - } - function floatReadValueFromPointer(name, shift) { - switch (shift) { - case 2: - return function (pointer) { - return this['fromWireType'](HEAPF32[pointer >> 2]) - } - case 3: - return function (pointer) { - return this['fromWireType'](HEAPF64[pointer >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + name) - } - } - function __embind_register_float(rawType, name, size) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (value) { - return value - }, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - return value - }, - argPackAdvance: 8, - readValueFromPointer: floatReadValueFromPointer(name, shift), - destructorFunction: null, - }) - } - function new_(constructor, argumentList) { - if (!(constructor instanceof Function)) { - throw new TypeError( - 'new_ called with constructor type ' + - typeof constructor + - ' which is not a function' - ) - } - var dummy = createNamedFunction( - constructor.name || 'unknownFunctionName', - function () {} - ) - dummy.prototype = constructor.prototype - var obj = new dummy() - var r = constructor.apply(obj, argumentList) - return r instanceof Object ? r : obj - } - function craftInvokerFunction( - humanName, - argTypes, - classType, - cppInvokerFunc, - cppTargetFunc - ) { - var argCount = argTypes.length - if (argCount < 2) { - throwBindingError( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - } - var isClassMethodFunc = argTypes[1] !== null && classType !== null - var needsDestructorStack = false - for (var i = 1; i < argTypes.length; ++i) { - if ( - argTypes[i] !== null && - argTypes[i].destructorFunction === undefined - ) { - needsDestructorStack = true - break - } - } - var returns = argTypes[0].name !== 'void' - var argsList = '' - var argsListWired = '' - for (var i = 0; i < argCount - 2; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - argsListWired += (i !== 0 ? ', ' : '') + 'arg' + i + 'Wired' - } - var invokerFnBody = - 'return function ' + - makeLegalFunctionName(humanName) + - '(' + - argsList + - ') {\n' + - 'if (arguments.length !== ' + - (argCount - 2) + - ') {\n' + - "throwBindingError('function " + - humanName + - " called with ' + arguments.length + ' arguments, expected " + - (argCount - 2) + - " args!');\n" + - '}\n' - if (needsDestructorStack) { - invokerFnBody += 'var destructors = [];\n' - } - var dtorStack = needsDestructorStack ? 'destructors' : 'null' - var args1 = [ - 'throwBindingError', - 'invoker', - 'fn', - 'runDestructors', - 'retType', - 'classParam', - ] - var args2 = [ - throwBindingError, - cppInvokerFunc, - cppTargetFunc, - runDestructors, - argTypes[0], - argTypes[1], - ] - if (isClassMethodFunc) { - invokerFnBody += - 'var thisWired = classParam.toWireType(' + dtorStack + ', this);\n' - } - for (var i = 0; i < argCount - 2; ++i) { - invokerFnBody += - 'var arg' + - i + - 'Wired = argType' + - i + - '.toWireType(' + - dtorStack + - ', arg' + - i + - '); // ' + - argTypes[i + 2].name + - '\n' - args1.push('argType' + i) - args2.push(argTypes[i + 2]) - } - if (isClassMethodFunc) { - argsListWired = - 'thisWired' + (argsListWired.length > 0 ? ', ' : '') + argsListWired - } - invokerFnBody += - (returns ? 'var rv = ' : '') + - 'invoker(fn' + - (argsListWired.length > 0 ? ', ' : '') + - argsListWired + - ');\n' - if (needsDestructorStack) { - invokerFnBody += 'runDestructors(destructors);\n' - } else { - for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { - var paramName = i === 1 ? 'thisWired' : 'arg' + (i - 2) + 'Wired' - if (argTypes[i].destructorFunction !== null) { - invokerFnBody += - paramName + - '_dtor(' + - paramName + - '); // ' + - argTypes[i].name + - '\n' - args1.push(paramName + '_dtor') - args2.push(argTypes[i].destructorFunction) - } - } - } - if (returns) { - invokerFnBody += - 'var ret = retType.fromWireType(rv);\n' + 'return ret;\n' - } else { - } - invokerFnBody += '}\n' - args1.push(invokerFnBody) - var invokerFunction = new_(Function, args1).apply(null, args2) - return invokerFunction - } - function ensureOverloadTable(proto, methodName, humanName) { - if (undefined === proto[methodName].overloadTable) { - var prevFunc = proto[methodName] - proto[methodName] = function () { - if ( - !proto[methodName].overloadTable.hasOwnProperty(arguments.length) - ) { - throwBindingError( - "Function '" + - humanName + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - proto[methodName].overloadTable + - ')!' - ) - } - return proto[methodName].overloadTable[arguments.length].apply( - this, - arguments - ) - } - proto[methodName].overloadTable = [] - proto[methodName].overloadTable[prevFunc.argCount] = prevFunc - } - } - function exposePublicSymbol(name, value, numArguments) { - if (Module.hasOwnProperty(name)) { - if ( - undefined === numArguments || - (undefined !== Module[name].overloadTable && - undefined !== Module[name].overloadTable[numArguments]) - ) { - throwBindingError("Cannot register public name '" + name + "' twice") - } - ensureOverloadTable(Module, name, name) - if (Module.hasOwnProperty(numArguments)) { - throwBindingError( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - numArguments + - ')!' - ) - } - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - if (undefined !== numArguments) { - Module[name].numArguments = numArguments - } - } - } - function heap32VectorToArray(count, firstElement) { - var array = [] - for (var i = 0; i < count; i++) { - array.push(HEAP32[(firstElement >> 2) + i]) - } - return array - } - function replacePublicSymbol(name, value, numArguments) { - if (!Module.hasOwnProperty(name)) { - throwInternalError('Replacing nonexistent public symbol') - } - if ( - undefined !== Module[name].overloadTable && - undefined !== numArguments - ) { - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - Module[name].argCount = numArguments - } - } - function dynCallLegacy(sig, ptr, args) { - var f = Module['dynCall_' + sig] - return args && args.length - ? f.apply(null, [ptr].concat(args)) - : f.call(null, ptr) - } - function dynCall(sig, ptr, args) { - if (sig.includes('j')) { - return dynCallLegacy(sig, ptr, args) - } - return wasmTable.get(ptr).apply(null, args) - } - function getDynCaller(sig, ptr) { - var argCache = [] - return function () { - argCache.length = arguments.length - for (var i = 0; i < arguments.length; i++) { - argCache[i] = arguments[i] - } - return dynCall(sig, ptr, argCache) - } - } - function embind__requireFunction(signature, rawFunction) { - signature = readLatin1String(signature) - function makeDynCaller() { - if (signature.includes('j')) { - return getDynCaller(signature, rawFunction) - } - return wasmTable.get(rawFunction) - } - var fp = makeDynCaller() - if (typeof fp !== 'function') { - throwBindingError( - 'unknown function pointer with signature ' + - signature + - ': ' + - rawFunction - ) - } - return fp - } - var UnboundTypeError = undefined - function getTypeName(type) { - var ptr = ___getTypeName(type) - var rv = readLatin1String(ptr) - _free(ptr) - return rv - } - function throwUnboundTypeError(message, types) { - var unboundTypes = [] - var seen = {} - function visit(type) { - if (seen[type]) { - return - } - if (registeredTypes[type]) { - return - } - if (typeDependencies[type]) { - typeDependencies[type].forEach(visit) - return - } - unboundTypes.push(type) - seen[type] = true - } - types.forEach(visit) - throw new UnboundTypeError( - message + ': ' + unboundTypes.map(getTypeName).join([', ']) - ) - } - function __embind_register_function( - name, - argCount, - rawArgTypesAddr, - signature, - rawInvoker, - fn - ) { - var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr) - name = readLatin1String(name) - rawInvoker = embind__requireFunction(signature, rawInvoker) - exposePublicSymbol( - name, - function () { - throwUnboundTypeError( - 'Cannot call ' + name + ' due to unbound types', - argTypes - ) - }, - argCount - 1 - ) - whenDependentTypesAreResolved([], argTypes, function (argTypes) { - var invokerArgsArray = [argTypes[0], null].concat(argTypes.slice(1)) - replacePublicSymbol( - name, - craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn), - argCount - 1 - ) - return [] - }) - } - function integerReadValueFromPointer(name, shift, signed) { - switch (shift) { - case 0: - return signed - ? function readS8FromPointer(pointer) { - return HEAP8[pointer] - } - : function readU8FromPointer(pointer) { - return HEAPU8[pointer] - } - case 1: - return signed - ? function readS16FromPointer(pointer) { - return HEAP16[pointer >> 1] - } - : function readU16FromPointer(pointer) { - return HEAPU16[pointer >> 1] - } - case 2: - return signed - ? function readS32FromPointer(pointer) { - return HEAP32[pointer >> 2] - } - : function readU32FromPointer(pointer) { - return HEAPU32[pointer >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + name) - } - } - function __embind_register_integer( - primitiveType, - name, - size, - minRange, - maxRange - ) { - name = readLatin1String(name) - if (maxRange === -1) { - maxRange = 4294967295 - } - var shift = getShiftFromSize(size) - var fromWireType = function (value) { - return value - } - if (minRange === 0) { - var bitshift = 32 - 8 * size - fromWireType = function (value) { - return (value << bitshift) >>> bitshift - } - } - var isUnsignedType = name.includes('unsigned') - registerType(primitiveType, { - name: name, - fromWireType: fromWireType, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - if (value < minRange || value > maxRange) { - throw new TypeError( - 'Passing a number "' + - _embind_repr(value) + - '" from JS side to C/C++ side to an argument of type "' + - name + - '", which is outside the valid range [' + - minRange + - ', ' + - maxRange + - ']!' - ) - } - return isUnsignedType ? value >>> 0 : value | 0 - }, - argPackAdvance: 8, - readValueFromPointer: integerReadValueFromPointer( - name, - shift, - minRange !== 0 - ), - destructorFunction: null, - }) - } - function __embind_register_memory_view(rawType, dataTypeIndex, name) { - var typeMapping = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ] - var TA = typeMapping[dataTypeIndex] - function decodeMemoryView(handle) { - handle = handle >> 2 - var heap = HEAPU32 - var size = heap[handle] - var data = heap[handle + 1] - return new TA(buffer, data, size) - } - name = readLatin1String(name) - registerType( - rawType, - { - name: name, - fromWireType: decodeMemoryView, - argPackAdvance: 8, - readValueFromPointer: decodeMemoryView, - }, - { ignoreDuplicateRegistrations: true } - ) - } - function __embind_register_std_string(rawType, name) { - name = readLatin1String(name) - var stdStringIsUTF8 = name === 'std::string' - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var str - if (stdStringIsUTF8) { - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i - if (i == length || HEAPU8[currentBytePtr] == 0) { - var maxRead = currentBytePtr - decodeStartPtr - var stringSegment = UTF8ToString(decodeStartPtr, maxRead) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + 1 - } - } - } else { - var a = new Array(length) - for (var i = 0; i < length; ++i) { - a[i] = String.fromCharCode(HEAPU8[value + 4 + i]) - } - str = a.join('') - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (value instanceof ArrayBuffer) { - value = new Uint8Array(value) - } - var getLength - var valueIsOfTypeString = typeof value === 'string' - if ( - !( - valueIsOfTypeString || - value instanceof Uint8Array || - value instanceof Uint8ClampedArray || - value instanceof Int8Array - ) - ) { - throwBindingError('Cannot pass non-string to std::string') - } - if (stdStringIsUTF8 && valueIsOfTypeString) { - getLength = function () { - return lengthBytesUTF8(value) - } - } else { - getLength = function () { - return value.length - } - } - var length = getLength() - var ptr = _malloc(4 + length + 1) - HEAPU32[ptr >> 2] = length - if (stdStringIsUTF8 && valueIsOfTypeString) { - stringToUTF8(value, ptr + 4, length + 1) - } else { - if (valueIsOfTypeString) { - for (var i = 0; i < length; ++i) { - var charCode = value.charCodeAt(i) - if (charCode > 255) { - _free(ptr) - throwBindingError( - 'String has UTF-16 code units that do not fit in 8 bits' - ) - } - HEAPU8[ptr + 4 + i] = charCode - } - } else { - for (var i = 0; i < length; ++i) { - HEAPU8[ptr + 4 + i] = value[i] - } - } - } - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_std_wstring(rawType, charSize, name) { - name = readLatin1String(name) - var decodeString, encodeString, getHeap, lengthBytesUTF, shift - if (charSize === 2) { - decodeString = UTF16ToString - encodeString = stringToUTF16 - lengthBytesUTF = lengthBytesUTF16 - getHeap = function () { - return HEAPU16 - } - shift = 1 - } else if (charSize === 4) { - decodeString = UTF32ToString - encodeString = stringToUTF32 - lengthBytesUTF = lengthBytesUTF32 - getHeap = function () { - return HEAPU32 - } - shift = 2 - } - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var HEAP = getHeap() - var str - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i * charSize - if (i == length || HEAP[currentBytePtr >> shift] == 0) { - var maxReadBytes = currentBytePtr - decodeStartPtr - var stringSegment = decodeString(decodeStartPtr, maxReadBytes) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + charSize - } - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (!(typeof value === 'string')) { - throwBindingError( - 'Cannot pass non-string to C++ string type ' + name - ) - } - var length = lengthBytesUTF(value) - var ptr = _malloc(4 + length + charSize) - HEAPU32[ptr >> 2] = length >> shift - encodeString(value, ptr + 4, length + charSize) - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_value_object( - rawType, - name, - constructorSignature, - rawConstructor, - destructorSignature, - rawDestructor - ) { - structRegistrations[rawType] = { - name: readLatin1String(name), - rawConstructor: embind__requireFunction( - constructorSignature, - rawConstructor - ), - rawDestructor: embind__requireFunction( - destructorSignature, - rawDestructor - ), - fields: [], - } - } - function __embind_register_value_object_field( - structType, - fieldName, - getterReturnType, - getterSignature, - getter, - getterContext, - setterArgumentType, - setterSignature, - setter, - setterContext - ) { - structRegistrations[structType].fields.push({ - fieldName: readLatin1String(fieldName), - getterReturnType: getterReturnType, - getter: embind__requireFunction(getterSignature, getter), - getterContext: getterContext, - setterArgumentType: setterArgumentType, - setter: embind__requireFunction(setterSignature, setter), - setterContext: setterContext, - }) - } - function __embind_register_void(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - isVoid: true, - name: name, - argPackAdvance: 0, - fromWireType: function () { - return undefined - }, - toWireType: function (destructors, o) { - return undefined - }, - }) - } - var emval_symbols = {} - function getStringOrSymbol(address) { - var symbol = emval_symbols[address] - if (symbol === undefined) { - return readLatin1String(address) - } else { - return symbol - } - } - function emval_get_global() { - if (typeof globalThis === 'object') { - return globalThis - } - return (function () { - return Function - })()('return this')() - } - function __emval_get_global(name) { - if (name === 0) { - return __emval_register(emval_get_global()) - } else { - name = getStringOrSymbol(name) - return __emval_register(emval_get_global()[name]) - } - } - function __emval_incref(handle) { - if (handle > 4) { - emval_handle_array[handle].refcount += 1 - } - } - function requireRegisteredType(rawType, humanName) { - var impl = registeredTypes[rawType] - if (undefined === impl) { - throwBindingError( - humanName + ' has unknown type ' + getTypeName(rawType) - ) - } - return impl - } - function craftEmvalAllocator(argCount) { - var argsList = '' - for (var i = 0; i < argCount; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - } - var functionBody = - 'return function emval_allocator_' + - argCount + - '(constructor, argTypes, args) {\n' - for (var i = 0; i < argCount; ++i) { - functionBody += - 'var argType' + - i + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - i + - '], "parameter ' + - i + - '");\n' + - 'var arg' + - i + - ' = argType' + - i + - '.readValueFromPointer(args);\n' + - 'args += argType' + - i + - "['argPackAdvance'];\n" - } - functionBody += - 'var obj = new constructor(' + - argsList + - ');\n' + - 'return __emval_register(obj);\n' + - '}\n' - return new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - functionBody - )(requireRegisteredType, Module, __emval_register) - } - var emval_newers = {} - function requireHandle(handle) { - if (!handle) { - throwBindingError('Cannot use deleted val. handle = ' + handle) - } - return emval_handle_array[handle].value - } - function __emval_new(handle, argCount, argTypes, args) { - handle = requireHandle(handle) - var newer = emval_newers[argCount] - if (!newer) { - newer = craftEmvalAllocator(argCount) - emval_newers[argCount] = newer - } - return newer(handle, argTypes, args) - } - function _abort() { - abort() - } - function _longjmp(env, value) { - _setThrew(env, value || 1) - throw 'longjmp' - } - function _emscripten_longjmp(a0, a1) { - return _longjmp(a0, a1) - } - function _emscripten_memcpy_big(dest, src, num) { - HEAPU8.copyWithin(dest, src, src + num) - } - function emscripten_realloc_buffer(size) { - try { - wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16) - updateGlobalBufferAndViews(wasmMemory.buffer) - return 1 - } catch (e) {} - } - function _emscripten_resize_heap(requestedSize) { - var oldSize = HEAPU8.length - requestedSize = requestedSize >>> 0 - var maxHeapSize = 2147483648 - if (requestedSize > maxHeapSize) { - return false - } - for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { - var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown) - overGrownHeapSize = Math.min( - overGrownHeapSize, - requestedSize + 100663296 - ) - var newSize = Math.min( - maxHeapSize, - alignUp(Math.max(requestedSize, overGrownHeapSize), 65536) - ) - var replacement = emscripten_realloc_buffer(newSize) - if (replacement) { - return true - } - } - return false - } - function _fd_close(fd) { - return 0 - } - function _fd_read(fd, iov, iovcnt, pnum) { - var stream = SYSCALLS.getStreamFromFD(fd) - var num = SYSCALLS.doReadv(stream, iov, iovcnt) - HEAP32[pnum >> 2] = num - return 0 - } - function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {} - function _fd_write(fd, iov, iovcnt, pnum) { - var num = 0 - for (var i = 0; i < iovcnt; i++) { - var ptr = HEAP32[(iov + i * 8) >> 2] - var len = HEAP32[(iov + (i * 8 + 4)) >> 2] - for (var j = 0; j < len; j++) { - SYSCALLS.printChar(fd, HEAPU8[ptr + j]) - } - num += len - } - HEAP32[pnum >> 2] = num - return 0 - } - function _getTempRet0() { - return getTempRet0() - } - function _setTempRet0(val) { - setTempRet0(val) - } - function _time(ptr) { - var ret = (Date.now() / 1e3) | 0 - if (ptr) { - HEAP32[ptr >> 2] = ret - } - return ret - } - InternalError = Module['InternalError'] = extendError( - Error, - 'InternalError' - ) - embind_init_charCodes() - BindingError = Module['BindingError'] = extendError(Error, 'BindingError') - init_emval() - UnboundTypeError = Module['UnboundTypeError'] = extendError( - Error, - 'UnboundTypeError' - ) - var asmLibraryArg = { - O: ___cxa_thread_atexit, - r: ___sys_fcntl64, - G: ___sys_ioctl, - H: ___sys_open, - x: __embind_finalize_value_object, - B: __embind_register_bigint, - K: __embind_register_bool, - J: __embind_register_emval, - t: __embind_register_float, - w: __embind_register_function, - i: __embind_register_integer, - e: __embind_register_memory_view, - u: __embind_register_std_string, - o: __embind_register_std_wstring, - z: __embind_register_value_object, - g: __embind_register_value_object_field, - L: __embind_register_void, - j: __emval_decref, - N: __emval_get_global, - v: __emval_incref, - D: __emval_new, - f: _abort, - d: _emscripten_longjmp, - E: _emscripten_memcpy_big, - n: _emscripten_resize_heap, - s: _fd_close, - F: _fd_read, - A: _fd_seek, - I: _fd_write, - b: _getTempRet0, - l: invoke_iiiii, - p: invoke_iiiiiiiii, - q: invoke_iiiiiiiiii, - C: invoke_iiiiiiiiiiii, - y: invoke_ijiii, - m: invoke_vi, - h: invoke_vii, - c: invoke_viiii, - k: invoke_viiiiiiiiii, - a: _setTempRet0, - M: _time, - } - var asm = createWasm() - var ___wasm_call_ctors = (Module['___wasm_call_ctors'] = function () { - return (___wasm_call_ctors = Module['___wasm_call_ctors'] = - Module['asm']['Q']).apply(null, arguments) - }) - var _malloc = (Module['_malloc'] = function () { - return (_malloc = Module['_malloc'] = Module['asm']['R']).apply( - null, - arguments - ) - }) - var _free = (Module['_free'] = function () { - return (_free = Module['_free'] = Module['asm']['S']).apply( - null, - arguments - ) - }) - var ___getTypeName = (Module['___getTypeName'] = function () { - return (___getTypeName = Module['___getTypeName'] = - Module['asm']['T']).apply(null, arguments) - }) - var ___embind_register_native_and_builtin_types = (Module[ - '___embind_register_native_and_builtin_types' - ] = function () { - return (___embind_register_native_and_builtin_types = Module[ - '___embind_register_native_and_builtin_types' - ] = - Module['asm']['U']).apply(null, arguments) - }) - var stackSave = (Module['stackSave'] = function () { - return (stackSave = Module['stackSave'] = Module['asm']['V']).apply( - null, - arguments - ) - }) - var stackRestore = (Module['stackRestore'] = function () { - return (stackRestore = Module['stackRestore'] = Module['asm']['W']).apply( - null, - arguments - ) - }) - var _setThrew = (Module['_setThrew'] = function () { - return (_setThrew = Module['_setThrew'] = Module['asm']['X']).apply( - null, - arguments - ) - }) - var dynCall_jiiiiiiiii = (Module['dynCall_jiiiiiiiii'] = function () { - return (dynCall_jiiiiiiiii = Module['dynCall_jiiiiiiiii'] = - Module['asm']['Z']).apply(null, arguments) - }) - var dynCall_ijiii = (Module['dynCall_ijiii'] = function () { - return (dynCall_ijiii = Module['dynCall_ijiii'] = - Module['asm']['_']).apply(null, arguments) - }) - var dynCall_jiji = (Module['dynCall_jiji'] = function () { - return (dynCall_jiji = Module['dynCall_jiji'] = Module['asm']['$']).apply( - null, - arguments - ) - }) - var dynCall_jiiiiiiii = (Module['dynCall_jiiiiiiii'] = function () { - return (dynCall_jiiiiiiii = Module['dynCall_jiiiiiiii'] = - Module['asm']['aa']).apply(null, arguments) - }) - var dynCall_jiiiiii = (Module['dynCall_jiiiiii'] = function () { - return (dynCall_jiiiiii = Module['dynCall_jiiiiii'] = - Module['asm']['ba']).apply(null, arguments) - }) - var dynCall_jiiiii = (Module['dynCall_jiiiii'] = function () { - return (dynCall_jiiiii = Module['dynCall_jiiiii'] = - Module['asm']['ca']).apply(null, arguments) - }) - var dynCall_iiijii = (Module['dynCall_iiijii'] = function () { - return (dynCall_iiijii = Module['dynCall_iiijii'] = - Module['asm']['da']).apply(null, arguments) - }) - function invoke_vi(index, a1) { - var sp = stackSave() - try { - wasmTable.get(index)(a1) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_viiii(index, a1, a2, a3, a4) { - var sp = stackSave() - try { - wasmTable.get(index)(a1, a2, a3, a4) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_vii(index, a1, a2) { - var sp = stackSave() - try { - wasmTable.get(index)(a1, a2) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_iiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9) { - var sp = stackSave() - try { - return wasmTable.get(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_iiiiiiiiiiii( - index, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11 - ) { - var sp = stackSave() - try { - return wasmTable.get(index)( - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11 - ) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_iiiii(index, a1, a2, a3, a4) { - var sp = stackSave() - try { - return wasmTable.get(index)(a1, a2, a3, a4) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_viiiiiiiiii( - index, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10 - ) { - var sp = stackSave() - try { - wasmTable.get(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_iiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8) { - var sp = stackSave() - try { - return wasmTable.get(index)(a1, a2, a3, a4, a5, a6, a7, a8) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - function invoke_ijiii(index, a1, a2, a3, a4, a5) { - var sp = stackSave() - try { - return dynCall_ijiii(index, a1, a2, a3, a4, a5) - } catch (e) { - stackRestore(sp) - if (e !== e + 0 && e !== 'longjmp') throw e - _setThrew(1, 0) - } - } - var calledRun - dependenciesFulfilled = function runCaller() { - if (!calledRun) run() - if (!calledRun) dependenciesFulfilled = runCaller - } - function run(args) { - args = args || arguments_ - if (runDependencies > 0) { - return - } - preRun() - if (runDependencies > 0) { - return - } - function doRun() { - if (calledRun) return - calledRun = true - Module['calledRun'] = true - if (ABORT) return - initRuntime() - readyPromiseResolve(Module) - if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']() - postRun() - } - if (Module['setStatus']) { - Module['setStatus']('Running...') - setTimeout(function () { - setTimeout(function () { - Module['setStatus']('') - }, 1) - doRun() - }, 1) - } else { - doRun() - } - } - Module['run'] = run - if (Module['preInit']) { - if (typeof Module['preInit'] == 'function') - Module['preInit'] = [Module['preInit']] - while (Module['preInit'].length > 0) { - Module['preInit'].pop()() - } - } - run() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/src/server/lib/squoosh/avif/avif_node_enc.wasm b/packages/next/src/server/lib/squoosh/avif/avif_node_enc.wasm deleted file mode 100755 index 6a19f18bf0..0000000000 Binary files a/packages/next/src/server/lib/squoosh/avif/avif_node_enc.wasm and /dev/null differ diff --git a/packages/next/src/server/lib/squoosh/codecs.ts b/packages/next/src/server/lib/squoosh/codecs.ts deleted file mode 100644 index e1cbbe142f..0000000000 --- a/packages/next/src/server/lib/squoosh/codecs.ts +++ /dev/null @@ -1,374 +0,0 @@ -import { promises as fsp } from 'fs' -import * as path from 'path' -import { instantiateEmscriptenWasm, pathify } from './emscripten-utils.js' - -interface DecodeModule extends EmscriptenWasm.Module { - decode: (data: Uint8Array) => ImageData -} - -type DecodeModuleFactory = EmscriptenWasm.ModuleFactory - -interface RotateModuleInstance { - exports: { - memory: WebAssembly.Memory - rotate(width: number, height: number, rotate: number): void - } -} - -interface ResizeWithAspectParams { - input_width: number - input_height: number - target_width?: number - target_height?: number -} - -export interface ResizeOptions { - width?: number - height?: number - method: 'triangle' | 'catrom' | 'mitchell' | 'lanczos3' - premultiply: boolean - linearRGB: boolean -} - -export interface RotateOptions { - numRotations: number -} - -// MozJPEG -import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc' -// @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 -import type { WebPModule as WebPEncodeModule } from './webp/webp_enc' -// @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') - -// AVIF -import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc' -// @ts-ignore -import avifEnc from './avif/avif_node_enc.js' -const avifEncWasm = path.resolve(__dirname, './avif/avif_node_enc.wasm') -// @ts-ignore -import avifDec from './avif/avif_node_dec.js' -const avifDecWasm = path.resolve(__dirname, './avif/avif_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') - -// Our decoders currently rely on a `ImageData` global. -import ImageData from './image_data' -;(globalThis as any).ImageData = ImageData - -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, -}: ResizeWithAspectParams): { 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!, - } - } - - return { - width: target_width, - height: Math.round((input_height / input_width) * target_width), - } -} - -export const preprocessors = { - resize: { - name: 'Resize', - description: 'Resize the image before compressing', - instantiate: async () => { - await resizeInit() - return ( - buffer: Uint8Array, - input_width: number, - input_height: number, - { width, height, method, premultiply, linearRGB }: ResizeOptions - ) => { - ;({ 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: Uint8Array, - width: number, - height: number, - { numRotations }: RotateOptions - ) => { - 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))) - ).instance as RotateModuleInstance - const { memory } = instance.exports - const additionalPagesNeeded = Math.ceil( - (size * 2 - memory.buffer.byteLength + 8) / (64 * 1024) - ) - if (additionalPagesNeeded > 0) { - memory.grow(additionalPagesNeeded) - } - const view = new Uint8ClampedArray(memory.buffer) - view.set(buffer, 8) - instance.exports.rotate(width, height, degrees) - return new ImageData( - view.slice(size + 8, size * 2 + 8), - sameDimensions ? width : height, - sameDimensions ? height : width - ) - } - }, - defaultOptions: { - numRotations: 0, - }, - }, -} as const - -export const codecs = { - mozjpeg: { - name: 'MozJPEG', - extension: 'jpg', - detectors: [/^\xFF\xD8\xFF/], - dec: () => - instantiateEmscriptenWasm(mozDec as DecodeModuleFactory, mozDecWasm), - enc: () => - instantiateEmscriptenWasm( - mozEnc as EmscriptenWasm.ModuleFactory, - 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 ]/s], - dec: () => - instantiateEmscriptenWasm(webpDec as DecodeModuleFactory, webpDecWasm), - enc: () => - instantiateEmscriptenWasm( - webpEnc as EmscriptenWasm.ModuleFactory, - webpEncWasm - ), - defaultEncoderOptions: { - quality: 75, - target_size: 0, - target_PSNR: 0, - method: 4, - sns_strength: 50, - filter_strength: 60, - filter_sharpness: 0, - filter_type: 1, - partitions: 0, - segments: 4, - pass: 1, - show_compressed: 0, - preprocessing: 0, - autofilter: 0, - partition_limit: 0, - alpha_compression: 1, - alpha_filtering: 1, - alpha_quality: 100, - lossless: 0, - exact: 0, - image_hint: 0, - emulate_jpeg_size: 0, - thread_level: 0, - low_memory: 0, - near_lossless: 100, - use_delta_palette: 0, - use_sharp_yuv: 0, - }, - autoOptimize: { - option: 'quality', - min: 0, - max: 100, - }, - }, - avif: { - name: 'AVIF', - extension: 'avif', - // eslint-disable-next-line no-control-regex - detectors: [/^\x00\x00\x00 ftypavif\x00\x00\x00\x00/], - dec: () => - instantiateEmscriptenWasm(avifDec as DecodeModuleFactory, avifDecWasm), - enc: async () => { - return instantiateEmscriptenWasm( - avifEnc as EmscriptenWasm.ModuleFactory, - avifEncWasm - ) - }, - defaultEncoderOptions: { - cqLevel: 33, - cqAlphaLevel: -1, - denoiseLevel: 0, - tileColsLog2: 0, - tileRowsLog2: 0, - speed: 6, - subsample: 1, - chromaDeltaQ: false, - sharpness: 0, - tune: 0 /* AVIFTune.auto */, - }, - autoOptimize: { - option: 'cqLevel', - min: 62, - max: 0, - }, - }, - 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) => { - const imageData = pngEncDec.decode(buffer) - pngEncDec.cleanup() - return imageData - }, - } - }, - enc: async () => { - await pngEncDecInit() - await oxipngInit() - return { - encode: ( - buffer: Uint8ClampedArray | ArrayBuffer, - width: number, - height: number, - opts: { level: number } - ) => { - const simplePng = pngEncDec.encode( - new Uint8Array(buffer), - width, - height - ) - const imageData = oxipng.optimise(simplePng, opts.level, false) - oxipng.cleanup() - return imageData - }, - } - }, - defaultEncoderOptions: { - level: 2, - }, - autoOptimize: { - option: 'level', - min: 6, - max: 1, - }, - }, -} as const diff --git a/packages/next/src/server/lib/squoosh/emscripten-types.d.ts b/packages/next/src/server/lib/squoosh/emscripten-types.d.ts deleted file mode 100644 index 6397872299..0000000000 --- a/packages/next/src/server/lib/squoosh/emscripten-types.d.ts +++ /dev/null @@ -1,121 +0,0 @@ -// These types roughly model the object that the JS files generated by Emscripten define. Copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/emscripten/index.d.ts and turned into a type definition rather than a global to support our way of using Emscripten. -declare namespace EmscriptenWasm { - type ModuleFactory = ( - moduleOverrides?: ModuleOpts - ) => Promise - - type EnvironmentType = 'WEB' | 'NODE' | 'SHELL' | 'WORKER' - - // Options object for modularized Emscripten files. Shoe-horned by @surma. - // FIXME: This an incomplete definition! - interface ModuleOpts { - mainScriptUrlOrBlob?: string - noInitialRun?: boolean - locateFile?: (url: string) => string - onRuntimeInitialized?: () => void - } - - interface Module { - print(str: string): void - printErr(str: string): void - arguments: string[] - environment: EnvironmentType - preInit: { (): void }[] - preRun: { (): void }[] - postRun: { (): void }[] - preinitializedWebGLContext: WebGLRenderingContext - noInitialRun: boolean - noExitRuntime: boolean - logReadFiles: boolean - filePackagePrefixURL: string - wasmBinary: ArrayBuffer - - destroy(object: object): void - getPreloadedPackage( - remotePackageName: string, - remotePackageSize: number - ): ArrayBuffer - instantiateWasm( - imports: WebAssembly.Imports, - successCallback: (module: WebAssembly.Module) => void - ): WebAssembly.Exports - locateFile(url: string): string - onCustomMessage(event: MessageEvent): void - - Runtime: any - - ccall( - ident: string, - returnType: string | null, - argTypes: string[], - args: any[] - ): any - cwrap(ident: string, returnType: string | null, argTypes: string[]): any - - setValue(ptr: number, value: any, type: string, noSafe?: boolean): void - getValue(ptr: number, type: string, noSafe?: boolean): number - - ALLOC_NORMAL: number - ALLOC_STACK: number - ALLOC_STATIC: number - ALLOC_DYNAMIC: number - ALLOC_NONE: number - - allocate(slab: any, types: string, allocator: number, ptr: number): number - allocate(slab: any, types: string[], allocator: number, ptr: number): number - - Pointer_stringify(ptr: number, length?: number): string - UTF16ToString(ptr: number): string - stringToUTF16(str: string, outPtr: number): void - UTF32ToString(ptr: number): string - stringToUTF32(str: string, outPtr: number): void - - // USE_TYPED_ARRAYS == 1 - HEAP: Int32Array - IHEAP: Int32Array - FHEAP: Float64Array - - // USE_TYPED_ARRAYS == 2 - HEAP8: Int8Array - HEAP16: Int16Array - HEAP32: Int32Array - HEAPU8: Uint8Array - HEAPU16: Uint16Array - HEAPU32: Uint32Array - HEAPF32: Float32Array - HEAPF64: Float64Array - - TOTAL_STACK: number - TOTAL_MEMORY: number - FAST_MEMORY: number - - addOnPreRun(cb: () => any): void - addOnInit(cb: () => any): void - addOnPreMain(cb: () => any): void - addOnExit(cb: () => any): void - addOnPostRun(cb: () => any): void - - // Tools - intArrayFromString( - stringy: string, - dontAddNull?: boolean, - length?: number - ): number[] - intArrayToString(array: number[]): string - writeStringToMemory(str: string, buffer: number, dontAddNull: boolean): void - writeArrayToMemory(array: number[], buffer: number): void - writeAsciiToMemory(str: string, buffer: number, dontAddNull: boolean): void - - addRunDependency(id: any): void - removeRunDependency(id: any): void - - preloadedImages: any - preloadedAudios: any - - _malloc(size: number): number - _free(ptr: number): void - - // Augmentations below by @surma. - onRuntimeInitialized: () => void | null - } -} diff --git a/packages/next/src/server/lib/squoosh/emscripten-utils.ts b/packages/next/src/server/lib/squoosh/emscripten-utils.ts deleted file mode 100644 index 0cf95fd0bf..0000000000 --- a/packages/next/src/server/lib/squoosh/emscripten-utils.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { fileURLToPath } from 'url' - -export function pathify(path: string): string { - if (path.startsWith('file://')) { - path = fileURLToPath(path) - } - return path -} - -export function instantiateEmscriptenWasm( - factory: EmscriptenWasm.ModuleFactory, - path: string, - workerJS: string = '' -): Promise { - return factory({ - locateFile(requestPath) { - // The glue code generated by emscripten uses the original - // file names of the worker file and the wasm binary. - // These will have changed in the bundling process and - // we need to inject them here. - if (requestPath.endsWith('.wasm')) return pathify(path) - if (requestPath.endsWith('.worker.js')) return pathify(workerJS) - return requestPath - }, - }) -} diff --git a/packages/next/src/server/lib/squoosh/image_data.ts b/packages/next/src/server/lib/squoosh/image_data.ts deleted file mode 100644 index 16936b60e8..0000000000 --- a/packages/next/src/server/lib/squoosh/image_data.ts +++ /dev/null @@ -1,33 +0,0 @@ -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 - ) { - this._data = data - this.width = width - this.height = height - } -} diff --git a/packages/next/src/server/lib/squoosh/impl.ts b/packages/next/src/server/lib/squoosh/impl.ts deleted file mode 100644 index 776f05c73c..0000000000 --- a/packages/next/src/server/lib/squoosh/impl.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { codecs as supportedFormats, preprocessors } from './codecs' -import ImageData from './image_data' - -type EncoderKey = keyof typeof supportedFormats - -export async function decodeBuffer( - _buffer: Buffer | Uint8Array -): Promise { - const buffer = Buffer.from(_buffer) - 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 EncoderKey | undefined - if (!key) { - throw Error(`Buffer has an unsupported format`) - } - const encoder = supportedFormats[key] - const mod = await encoder.dec() - const rgba = mod.decode(new Uint8Array(buffer)) - return rgba -} - -export async function rotate( - image: ImageData, - numRotations: number -): Promise { - image = ImageData.from(image) - - const m = await preprocessors['rotate'].instantiate() - return await m(image.data, image.width, image.height, { numRotations }) -} - -type ResizeOpts = { image: ImageData } & ( - | { width: number; height?: never } - | { height: number; width?: never } - | { height: number; width: number } -) - -export async function resize({ image, width, height }: ResizeOpts) { - image = ImageData.from(image) - - const p = preprocessors['resize'] - const m = await p.instantiate() - return await m(image.data, image.width, image.height, { - ...p.defaultOptions, - width, - height, - }) -} - -export async function encodeJpeg( - image: ImageData, - { quality }: { quality: number } -): Promise { - image = ImageData.from(image) - - const e = supportedFormats['mozjpeg'] - const m = await e.enc() - const r = await m.encode(image.data, image.width, image.height, { - ...e.defaultEncoderOptions, - quality, - }) - return Buffer.from(r) -} - -export async function encodeWebp( - image: ImageData, - { quality }: { quality: number } -): Promise { - image = ImageData.from(image) - - const e = supportedFormats['webp'] - const m = await e.enc() - const r = await m.encode(image.data, image.width, image.height, { - ...e.defaultEncoderOptions, - quality, - }) - return Buffer.from(r) -} - -export async function encodeAvif( - image: ImageData, - { quality }: { quality: number } -): Promise { - image = ImageData.from(image) - - const e = supportedFormats['avif'] - const m = await e.enc() - const val = e.autoOptimize.min || 62 - const r = await m.encode(image.data, image.width, image.height, { - ...e.defaultEncoderOptions, - // Think of cqLevel as the "amount" of quantization (0 to 62), - // so a lower value yields higher quality (0 to 100). - cqLevel: Math.round(val - (quality / 100) * val), - }) - return Buffer.from(r) -} - -export async function encodePng( - image: ImageData -): Promise { - image = ImageData.from(image) - - const e = supportedFormats['oxipng'] - const m = await e.enc() - const r = await m.encode(image.data, image.width, image.height, { - ...e.defaultEncoderOptions, - }) - return Buffer.from(r) -} diff --git a/packages/next/src/server/lib/squoosh/main.ts b/packages/next/src/server/lib/squoosh/main.ts deleted file mode 100644 index 4bac4ac455..0000000000 --- a/packages/next/src/server/lib/squoosh/main.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { Worker } from 'next/dist/compiled/jest-worker' -import * as path from 'path' -import { execOnce } from '../../../shared/lib/utils' -import { cpus } from 'os' - -type RotateOperation = { - type: 'rotate' - numRotations: number -} -type ResizeOperation = { - type: 'resize' -} & ( - | { width: number; height?: never } - | { height: number; width?: never } - | { width: number; height: number } -) -export type Operation = RotateOperation | ResizeOperation -export type Encoding = 'jpeg' | 'png' | 'webp' | 'avif' - -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 getMetadata( - buffer: Buffer -): Promise<{ width: number; height: number }> { - const worker: typeof import('./impl') = getWorker() as any - const { width, height } = await worker.decodeBuffer(buffer) - return { width, height } -} - -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') { - imageData = await worker.rotate(imageData, operation.numRotations) - } else if (operation.type === 'resize') { - const opt = { image: imageData, width: 0, height: 0 } - if ( - operation.width && - imageData.width && - imageData.width > operation.width - ) { - opt.width = operation.width - } - if ( - operation.height && - imageData.height && - imageData.height > operation.height - ) { - opt.height = operation.height - } - - if (opt.width > 0 || opt.height > 0) { - imageData = await worker.resize(opt) - } - } - } - - switch (encoding) { - case 'jpeg': - return Buffer.from(await worker.encodeJpeg(imageData, { quality })) - case 'webp': - return Buffer.from(await worker.encodeWebp(imageData, { quality })) - case 'avif': - const avifQuality = quality - 20 - return Buffer.from( - await worker.encodeAvif(imageData, { - quality: Math.max(avifQuality, 0), - }) - ) - case 'png': - return Buffer.from(await worker.encodePng(imageData)) - default: - throw Error(`Unsupported encoding format`) - } -} - -export async function decodeBuffer(buffer: Buffer) { - const worker: typeof import('./impl') = getWorker() as any - const imageData = await worker.decodeBuffer(buffer) - return imageData -} diff --git a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_enc.d.ts b/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_enc.d.ts deleted file mode 100644 index 87b697a11a..0000000000 --- a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_enc.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -// eslint-disable-next-line no-shadow -export const enum MozJpegColorSpace { - GRAYSCALE = 1, - RGB, - YCbCr, -} - -export interface EncodeOptions { - quality: number - baseline: boolean - arithmetic: boolean - progressive: boolean - optimize_coding: boolean - smoothing: number - color_space: MozJpegColorSpace - quant_table: number - trellis_multipass: boolean - trellis_opt_zero: boolean - trellis_opt_table: boolean - trellis_loops: number - auto_subsample: boolean - chroma_subsample: number - separate_chroma_quality: boolean - chroma_quality: number -} - -export interface MozJPEGModule extends EmscriptenWasm.Module { - encode( - data: BufferSource, - width: number, - height: number, - options: EncodeOptions - ): Uint8Array -} - -declare var moduleFactory: EmscriptenWasm.ModuleFactory - -export default moduleFactory diff --git a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js b/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js deleted file mode 100644 index b0b76c0f65..0000000000 --- a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js +++ /dev/null @@ -1,1770 +0,0 @@ -/* eslint-disable */ -var Module = (function () { - return function (Module) { - Module = Module || {} - - var Module = typeof Module !== 'undefined' ? Module : {} - var readyPromiseResolve, readyPromiseReject - Module['ready'] = new Promise(function (resolve, reject) { - readyPromiseResolve = resolve - readyPromiseReject = reject - }) - var moduleOverrides = {} - var key - for (key in Module) { - if (Module.hasOwnProperty(key)) { - moduleOverrides[key] = Module[key] - } - } - var arguments_ = [] - var thisProgram = './this.program' - var quit_ = function (status, toThrow) { - throw toThrow - } - var ENVIRONMENT_IS_WEB = false - var ENVIRONMENT_IS_WORKER = false - var ENVIRONMENT_IS_NODE = true - var scriptDirectory = '' - function locateFile(path) { - if (Module['locateFile']) { - return Module['locateFile'](path, scriptDirectory) - } - return scriptDirectory + path - } - var read_, readBinary - var nodeFS - var nodePath - if (ENVIRONMENT_IS_NODE) { - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = require('path').dirname(scriptDirectory) + '/' - } else { - scriptDirectory = __dirname + '/' - } - read_ = function shell_read(filename, binary) { - if (!nodeFS) nodeFS = require('fs') - if (!nodePath) nodePath = require('path') - filename = nodePath['normalize'](filename) - return nodeFS['readFileSync'](filename, binary ? null : 'utf8') - } - readBinary = function readBinary(filename) { - var ret = read_(filename, true) - if (!ret.buffer) { - ret = new Uint8Array(ret) - } - assert(ret.buffer) - return ret - } - if (process['argv'].length > 1) { - thisProgram = process['argv'][1].replace(/\\/g, '/') - } - arguments_ = process['argv'].slice(2) - quit_ = function (status) { - process['exit'](status) - } - Module['inspect'] = function () { - return '[Emscripten Module object]' - } - } else { - } - var out = Module['print'] || console.log.bind(console) - var err = Module['printErr'] || console.warn.bind(console) - for (key in moduleOverrides) { - if (moduleOverrides.hasOwnProperty(key)) { - Module[key] = moduleOverrides[key] - } - } - moduleOverrides = null - if (Module['arguments']) arguments_ = Module['arguments'] - if (Module['thisProgram']) thisProgram = Module['thisProgram'] - if (Module['quit']) quit_ = Module['quit'] - var tempRet0 = 0 - var setTempRet0 = function (value) { - tempRet0 = value - } - var wasmBinary - if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'] - var noExitRuntime = Module['noExitRuntime'] || true - if (typeof WebAssembly !== 'object') { - abort('no native wasm support detected') - } - var wasmMemory - var ABORT = false - var EXITSTATUS - function assert(condition, text) { - if (!condition) { - abort('Assertion failed: ' + text) - } - } - var UTF8Decoder = new TextDecoder('utf8') - function UTF8ArrayToString(heap, idx, maxBytesToRead) { - var endIdx = idx + maxBytesToRead - var endPtr = idx - while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr - return UTF8Decoder.decode( - heap.subarray - ? heap.subarray(idx, endPtr) - : new Uint8Array(heap.slice(idx, endPtr)) - ) - } - function UTF8ToString(ptr, maxBytesToRead) { - if (!ptr) return '' - var maxPtr = ptr + maxBytesToRead - for (var end = ptr; !(end >= maxPtr) && HEAPU8[end]; ) ++end - return UTF8Decoder.decode(HEAPU8.subarray(ptr, end)) - } - function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { - if (!(maxBytesToWrite > 0)) return 0 - var startIdx = outIdx - var endIdx = outIdx + maxBytesToWrite - 1 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) { - var u1 = str.charCodeAt(++i) - u = (65536 + ((u & 1023) << 10)) | (u1 & 1023) - } - if (u <= 127) { - if (outIdx >= endIdx) break - heap[outIdx++] = u - } else if (u <= 2047) { - if (outIdx + 1 >= endIdx) break - heap[outIdx++] = 192 | (u >> 6) - heap[outIdx++] = 128 | (u & 63) - } else if (u <= 65535) { - if (outIdx + 2 >= endIdx) break - heap[outIdx++] = 224 | (u >> 12) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } else { - if (outIdx + 3 >= endIdx) break - heap[outIdx++] = 240 | (u >> 18) - heap[outIdx++] = 128 | ((u >> 12) & 63) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } - } - heap[outIdx] = 0 - return outIdx - startIdx - } - function stringToUTF8(str, outPtr, maxBytesToWrite) { - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite) - } - function lengthBytesUTF8(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) - u = (65536 + ((u & 1023) << 10)) | (str.charCodeAt(++i) & 1023) - if (u <= 127) ++len - else if (u <= 2047) len += 2 - else if (u <= 65535) len += 3 - else len += 4 - } - return len - } - var UTF16Decoder = new TextDecoder('utf-16le') - function UTF16ToString(ptr, maxBytesToRead) { - var endPtr = ptr - var idx = endPtr >> 1 - var maxIdx = idx + maxBytesToRead / 2 - while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx - endPtr = idx << 1 - return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)) - var str = '' - for (var i = 0; !(i >= maxBytesToRead / 2); ++i) { - var codeUnit = HEAP16[(ptr + i * 2) >> 1] - if (codeUnit == 0) break - str += String.fromCharCode(codeUnit) - } - return str - } - function stringToUTF16(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 2) return 0 - maxBytesToWrite -= 2 - var startPtr = outPtr - var numCharsToWrite = - maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length - for (var i = 0; i < numCharsToWrite; ++i) { - var codeUnit = str.charCodeAt(i) - HEAP16[outPtr >> 1] = codeUnit - outPtr += 2 - } - HEAP16[outPtr >> 1] = 0 - return outPtr - startPtr - } - function lengthBytesUTF16(str) { - return str.length * 2 - } - function UTF32ToString(ptr, maxBytesToRead) { - var i = 0 - var str = '' - while (!(i >= maxBytesToRead / 4)) { - var utf32 = HEAP32[(ptr + i * 4) >> 2] - if (utf32 == 0) break - ++i - if (utf32 >= 65536) { - var ch = utf32 - 65536 - str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023)) - } else { - str += String.fromCharCode(utf32) - } - } - return str - } - function stringToUTF32(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 4) return 0 - var startPtr = outPtr - var endPtr = startPtr + maxBytesToWrite - 4 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) { - var trailSurrogate = str.charCodeAt(++i) - codeUnit = - (65536 + ((codeUnit & 1023) << 10)) | (trailSurrogate & 1023) - } - HEAP32[outPtr >> 2] = codeUnit - outPtr += 4 - if (outPtr + 4 > endPtr) break - } - HEAP32[outPtr >> 2] = 0 - return outPtr - startPtr - } - function lengthBytesUTF32(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) ++i - len += 4 - } - return len - } - function writeAsciiToMemory(str, buffer, dontAddNull) { - for (var i = 0; i < str.length; ++i) { - HEAP8[buffer++ >> 0] = str.charCodeAt(i) - } - if (!dontAddNull) HEAP8[buffer >> 0] = 0 - } - function alignUp(x, multiple) { - if (x % multiple > 0) { - x += multiple - (x % multiple) - } - return x - } - var buffer, - HEAP8, - HEAPU8, - HEAP16, - HEAPU16, - HEAP32, - HEAPU32, - HEAPF32, - HEAPF64 - function updateGlobalBufferAndViews(buf) { - buffer = buf - Module['HEAP8'] = HEAP8 = new Int8Array(buf) - Module['HEAP16'] = HEAP16 = new Int16Array(buf) - Module['HEAP32'] = HEAP32 = new Int32Array(buf) - Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf) - Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf) - Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf) - Module['HEAPF32'] = HEAPF32 = new Float32Array(buf) - Module['HEAPF64'] = HEAPF64 = new Float64Array(buf) - } - var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216 - var wasmTable - var __ATPRERUN__ = [] - var __ATINIT__ = [] - var __ATPOSTRUN__ = [] - var runtimeInitialized = false - var runtimeExited = false - function preRun() { - if (Module['preRun']) { - if (typeof Module['preRun'] == 'function') - Module['preRun'] = [Module['preRun']] - while (Module['preRun'].length) { - addOnPreRun(Module['preRun'].shift()) - } - } - callRuntimeCallbacks(__ATPRERUN__) - } - function initRuntime() { - runtimeInitialized = true - callRuntimeCallbacks(__ATINIT__) - } - function exitRuntime() { - runtimeExited = true - } - function postRun() { - if (Module['postRun']) { - if (typeof Module['postRun'] == 'function') - Module['postRun'] = [Module['postRun']] - while (Module['postRun'].length) { - addOnPostRun(Module['postRun'].shift()) - } - } - callRuntimeCallbacks(__ATPOSTRUN__) - } - function addOnPreRun(cb) { - __ATPRERUN__.unshift(cb) - } - function addOnInit(cb) { - __ATINIT__.unshift(cb) - } - function addOnPostRun(cb) { - __ATPOSTRUN__.unshift(cb) - } - var runDependencies = 0 - var runDependencyWatcher = null - var dependenciesFulfilled = null - function addRunDependency(id) { - runDependencies++ - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - } - function removeRunDependency(id) { - runDependencies-- - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - if (runDependencies == 0) { - if (runDependencyWatcher !== null) { - clearInterval(runDependencyWatcher) - runDependencyWatcher = null - } - if (dependenciesFulfilled) { - var callback = dependenciesFulfilled - dependenciesFulfilled = null - callback() - } - } - } - Module['preloadedImages'] = {} - Module['preloadedAudios'] = {} - function abort(what) { - if (Module['onAbort']) { - Module['onAbort'](what) - } - what += '' - err(what) - ABORT = true - EXITSTATUS = 1 - what = 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.' - var e = new WebAssembly.RuntimeError(what) - readyPromiseReject(e) - throw e - } - var dataURIPrefix = 'data:application/octet-stream;base64,' - function isDataURI(filename) { - return filename.startsWith(dataURIPrefix) - } - if (Module['locateFile']) { - var wasmBinaryFile = 'mozjpeg_node_dec.wasm' - if (!isDataURI(wasmBinaryFile)) { - wasmBinaryFile = locateFile(wasmBinaryFile) - } - } else { - throw new Error('invariant') - } - function getBinary(file) { - try { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary) - } - if (readBinary) { - return readBinary(file) - } else { - throw 'both async and sync fetching of the wasm failed' - } - } catch (err) { - abort(err) - } - } - function getBinaryPromise() { - return Promise.resolve().then(function () { - return getBinary(wasmBinaryFile) - }) - } - function createWasm() { - var info = { a: asmLibraryArg } - function receiveInstance(instance, module) { - var exports = instance.exports - Module['asm'] = exports - wasmMemory = Module['asm']['z'] - updateGlobalBufferAndViews(wasmMemory.buffer) - wasmTable = Module['asm']['F'] - addOnInit(Module['asm']['A']) - removeRunDependency('wasm-instantiate') - } - addRunDependency('wasm-instantiate') - function receiveInstantiationResult(result) { - receiveInstance(result['instance']) - } - function instantiateArrayBuffer(receiver) { - return getBinaryPromise() - .then(function (binary) { - var result = WebAssembly.instantiate(binary, info) - return result - }) - .then(receiver, function (reason) { - err('failed to asynchronously prepare wasm: ' + reason) - abort(reason) - }) - } - function instantiateAsync() { - return instantiateArrayBuffer(receiveInstantiationResult) - } - if (Module['instantiateWasm']) { - try { - var exports = Module['instantiateWasm'](info, receiveInstance) - return exports - } catch (e) { - err('Module.instantiateWasm callback failed with error: ' + e) - return false - } - } - instantiateAsync().catch(readyPromiseReject) - return {} - } - function callRuntimeCallbacks(callbacks) { - while (callbacks.length > 0) { - var callback = callbacks.shift() - if (typeof callback == 'function') { - callback(Module) - continue - } - var func = callback.func - if (typeof func === 'number') { - if (callback.arg === undefined) { - wasmTable.get(func)() - } else { - wasmTable.get(func)(callback.arg) - } - } else { - func(callback.arg === undefined ? null : callback.arg) - } - } - } - var runtimeKeepaliveCounter = 0 - function keepRuntimeAlive() { - return noExitRuntime || runtimeKeepaliveCounter > 0 - } - function _atexit(func, arg) {} - function ___cxa_thread_atexit(a0, a1) { - return _atexit(a0, a1) - } - function __embind_register_bigint( - primitiveType, - name, - size, - minRange, - maxRange - ) {} - function getShiftFromSize(size) { - switch (size) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + size) - } - } - function embind_init_charCodes() { - var codes = new Array(256) - for (var i = 0; i < 256; ++i) { - codes[i] = String.fromCharCode(i) - } - embind_charCodes = codes - } - var embind_charCodes = undefined - function readLatin1String(ptr) { - var ret = '' - var c = ptr - while (HEAPU8[c]) { - ret += embind_charCodes[HEAPU8[c++]] - } - return ret - } - var awaitingDependencies = {} - var registeredTypes = {} - var typeDependencies = {} - var char_0 = 48 - var char_9 = 57 - function makeLegalFunctionName(name) { - if (undefined === name) { - return '_unknown' - } - name = name.replace(/[^a-zA-Z0-9_]/g, '$') - var f = name.charCodeAt(0) - if (f >= char_0 && f <= char_9) { - return '_' + name - } else { - return name - } - } - function createNamedFunction(name, body) { - name = makeLegalFunctionName(name) - return new Function( - 'body', - 'return function ' + - name + - '() {\n' + - ' "use strict";' + - ' return body.apply(this, arguments);\n' + - '};\n' - )(body) - } - function extendError(baseErrorType, errorName) { - var errorClass = createNamedFunction(errorName, function (message) { - this.name = errorName - this.message = message - var stack = new Error(message).stack - if (stack !== undefined) { - this.stack = - this.toString() + '\n' + stack.replace(/^Error(:[^\n]*)?\n/, '') - } - }) - errorClass.prototype = Object.create(baseErrorType.prototype) - errorClass.prototype.constructor = errorClass - errorClass.prototype.toString = function () { - if (this.message === undefined) { - return this.name - } else { - return this.name + ': ' + this.message - } - } - return errorClass - } - var BindingError = undefined - function throwBindingError(message) { - throw new BindingError(message) - } - var InternalError = undefined - function throwInternalError(message) { - throw new InternalError(message) - } - function whenDependentTypesAreResolved( - myTypes, - dependentTypes, - getTypeConverters - ) { - myTypes.forEach(function (type) { - typeDependencies[type] = dependentTypes - }) - function onComplete(typeConverters) { - var myTypeConverters = getTypeConverters(typeConverters) - if (myTypeConverters.length !== myTypes.length) { - throwInternalError('Mismatched type converter count') - } - for (var i = 0; i < myTypes.length; ++i) { - registerType(myTypes[i], myTypeConverters[i]) - } - } - var typeConverters = new Array(dependentTypes.length) - var unregisteredTypes = [] - var registered = 0 - dependentTypes.forEach(function (dt, i) { - if (registeredTypes.hasOwnProperty(dt)) { - typeConverters[i] = registeredTypes[dt] - } else { - unregisteredTypes.push(dt) - if (!awaitingDependencies.hasOwnProperty(dt)) { - awaitingDependencies[dt] = [] - } - awaitingDependencies[dt].push(function () { - typeConverters[i] = registeredTypes[dt] - ++registered - if (registered === unregisteredTypes.length) { - onComplete(typeConverters) - } - }) - } - }) - if (0 === unregisteredTypes.length) { - onComplete(typeConverters) - } - } - function registerType(rawType, registeredInstance, options) { - options = options || {} - if (!('argPackAdvance' in registeredInstance)) { - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - } - var name = registeredInstance.name - if (!rawType) { - throwBindingError( - 'type "' + name + '" must have a positive integer typeid pointer' - ) - } - if (registeredTypes.hasOwnProperty(rawType)) { - if (options.ignoreDuplicateRegistrations) { - return - } else { - throwBindingError("Cannot register type '" + name + "' twice") - } - } - registeredTypes[rawType] = registeredInstance - delete typeDependencies[rawType] - if (awaitingDependencies.hasOwnProperty(rawType)) { - var callbacks = awaitingDependencies[rawType] - delete awaitingDependencies[rawType] - callbacks.forEach(function (cb) { - cb() - }) - } - } - function __embind_register_bool( - rawType, - name, - size, - trueValue, - falseValue - ) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (wt) { - return !!wt - }, - toWireType: function (destructors, o) { - return o ? trueValue : falseValue - }, - argPackAdvance: 8, - readValueFromPointer: function (pointer) { - var heap - if (size === 1) { - heap = HEAP8 - } else if (size === 2) { - heap = HEAP16 - } else if (size === 4) { - heap = HEAP32 - } else { - throw new TypeError('Unknown boolean type size: ' + name) - } - return this['fromWireType'](heap[pointer >> shift]) - }, - destructorFunction: null, - }) - } - var emval_free_list = [] - var emval_handle_array = [ - {}, - { value: undefined }, - { value: null }, - { value: true }, - { value: false }, - ] - function __emval_decref(handle) { - if (handle > 4 && 0 === --emval_handle_array[handle].refcount) { - emval_handle_array[handle] = undefined - emval_free_list.push(handle) - } - } - function count_emval_handles() { - var count = 0 - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - ++count - } - } - return count - } - function get_first_emval() { - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - return emval_handle_array[i] - } - } - return null - } - function init_emval() { - Module['count_emval_handles'] = count_emval_handles - Module['get_first_emval'] = get_first_emval - } - function __emval_register(value) { - switch (value) { - case undefined: { - return 1 - } - case null: { - return 2 - } - case true: { - return 3 - } - case false: { - return 4 - } - default: { - var handle = emval_free_list.length - ? emval_free_list.pop() - : emval_handle_array.length - emval_handle_array[handle] = { refcount: 1, value: value } - return handle - } - } - } - function simpleReadValueFromPointer(pointer) { - return this['fromWireType'](HEAPU32[pointer >> 2]) - } - function __embind_register_emval(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (handle) { - var rv = emval_handle_array[handle].value - __emval_decref(handle) - return rv - }, - toWireType: function (destructors, value) { - return __emval_register(value) - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: null, - }) - } - function _embind_repr(v) { - if (v === null) { - return 'null' - } - var t = typeof v - if (t === 'object' || t === 'array' || t === 'function') { - return v.toString() - } else { - return '' + v - } - } - function floatReadValueFromPointer(name, shift) { - switch (shift) { - case 2: - return function (pointer) { - return this['fromWireType'](HEAPF32[pointer >> 2]) - } - case 3: - return function (pointer) { - return this['fromWireType'](HEAPF64[pointer >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + name) - } - } - function __embind_register_float(rawType, name, size) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (value) { - return value - }, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - return value - }, - argPackAdvance: 8, - readValueFromPointer: floatReadValueFromPointer(name, shift), - destructorFunction: null, - }) - } - function new_(constructor, argumentList) { - if (!(constructor instanceof Function)) { - throw new TypeError( - 'new_ called with constructor type ' + - typeof constructor + - ' which is not a function' - ) - } - var dummy = createNamedFunction( - constructor.name || 'unknownFunctionName', - function () {} - ) - dummy.prototype = constructor.prototype - var obj = new dummy() - var r = constructor.apply(obj, argumentList) - return r instanceof Object ? r : obj - } - function runDestructors(destructors) { - while (destructors.length) { - var ptr = destructors.pop() - var del = destructors.pop() - del(ptr) - } - } - function craftInvokerFunction( - humanName, - argTypes, - classType, - cppInvokerFunc, - cppTargetFunc - ) { - var argCount = argTypes.length - if (argCount < 2) { - throwBindingError( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - } - var isClassMethodFunc = argTypes[1] !== null && classType !== null - var needsDestructorStack = false - for (var i = 1; i < argTypes.length; ++i) { - if ( - argTypes[i] !== null && - argTypes[i].destructorFunction === undefined - ) { - needsDestructorStack = true - break - } - } - var returns = argTypes[0].name !== 'void' - var argsList = '' - var argsListWired = '' - for (var i = 0; i < argCount - 2; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - argsListWired += (i !== 0 ? ', ' : '') + 'arg' + i + 'Wired' - } - var invokerFnBody = - 'return function ' + - makeLegalFunctionName(humanName) + - '(' + - argsList + - ') {\n' + - 'if (arguments.length !== ' + - (argCount - 2) + - ') {\n' + - "throwBindingError('function " + - humanName + - " called with ' + arguments.length + ' arguments, expected " + - (argCount - 2) + - " args!');\n" + - '}\n' - if (needsDestructorStack) { - invokerFnBody += 'var destructors = [];\n' - } - var dtorStack = needsDestructorStack ? 'destructors' : 'null' - var args1 = [ - 'throwBindingError', - 'invoker', - 'fn', - 'runDestructors', - 'retType', - 'classParam', - ] - var args2 = [ - throwBindingError, - cppInvokerFunc, - cppTargetFunc, - runDestructors, - argTypes[0], - argTypes[1], - ] - if (isClassMethodFunc) { - invokerFnBody += - 'var thisWired = classParam.toWireType(' + dtorStack + ', this);\n' - } - for (var i = 0; i < argCount - 2; ++i) { - invokerFnBody += - 'var arg' + - i + - 'Wired = argType' + - i + - '.toWireType(' + - dtorStack + - ', arg' + - i + - '); // ' + - argTypes[i + 2].name + - '\n' - args1.push('argType' + i) - args2.push(argTypes[i + 2]) - } - if (isClassMethodFunc) { - argsListWired = - 'thisWired' + (argsListWired.length > 0 ? ', ' : '') + argsListWired - } - invokerFnBody += - (returns ? 'var rv = ' : '') + - 'invoker(fn' + - (argsListWired.length > 0 ? ', ' : '') + - argsListWired + - ');\n' - if (needsDestructorStack) { - invokerFnBody += 'runDestructors(destructors);\n' - } else { - for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { - var paramName = i === 1 ? 'thisWired' : 'arg' + (i - 2) + 'Wired' - if (argTypes[i].destructorFunction !== null) { - invokerFnBody += - paramName + - '_dtor(' + - paramName + - '); // ' + - argTypes[i].name + - '\n' - args1.push(paramName + '_dtor') - args2.push(argTypes[i].destructorFunction) - } - } - } - if (returns) { - invokerFnBody += - 'var ret = retType.fromWireType(rv);\n' + 'return ret;\n' - } else { - } - invokerFnBody += '}\n' - args1.push(invokerFnBody) - var invokerFunction = new_(Function, args1).apply(null, args2) - return invokerFunction - } - function ensureOverloadTable(proto, methodName, humanName) { - if (undefined === proto[methodName].overloadTable) { - var prevFunc = proto[methodName] - proto[methodName] = function () { - if ( - !proto[methodName].overloadTable.hasOwnProperty(arguments.length) - ) { - throwBindingError( - "Function '" + - humanName + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - proto[methodName].overloadTable + - ')!' - ) - } - return proto[methodName].overloadTable[arguments.length].apply( - this, - arguments - ) - } - proto[methodName].overloadTable = [] - proto[methodName].overloadTable[prevFunc.argCount] = prevFunc - } - } - function exposePublicSymbol(name, value, numArguments) { - if (Module.hasOwnProperty(name)) { - if ( - undefined === numArguments || - (undefined !== Module[name].overloadTable && - undefined !== Module[name].overloadTable[numArguments]) - ) { - throwBindingError("Cannot register public name '" + name + "' twice") - } - ensureOverloadTable(Module, name, name) - if (Module.hasOwnProperty(numArguments)) { - throwBindingError( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - numArguments + - ')!' - ) - } - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - if (undefined !== numArguments) { - Module[name].numArguments = numArguments - } - } - } - function heap32VectorToArray(count, firstElement) { - var array = [] - for (var i = 0; i < count; i++) { - array.push(HEAP32[(firstElement >> 2) + i]) - } - return array - } - function replacePublicSymbol(name, value, numArguments) { - if (!Module.hasOwnProperty(name)) { - throwInternalError('Replacing nonexistent public symbol') - } - if ( - undefined !== Module[name].overloadTable && - undefined !== numArguments - ) { - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - Module[name].argCount = numArguments - } - } - function dynCallLegacy(sig, ptr, args) { - var f = Module['dynCall_' + sig] - return args && args.length - ? f.apply(null, [ptr].concat(args)) - : f.call(null, ptr) - } - function dynCall(sig, ptr, args) { - if (sig.includes('j')) { - return dynCallLegacy(sig, ptr, args) - } - return wasmTable.get(ptr).apply(null, args) - } - function getDynCaller(sig, ptr) { - var argCache = [] - return function () { - argCache.length = arguments.length - for (var i = 0; i < arguments.length; i++) { - argCache[i] = arguments[i] - } - return dynCall(sig, ptr, argCache) - } - } - function embind__requireFunction(signature, rawFunction) { - signature = readLatin1String(signature) - function makeDynCaller() { - if (signature.includes('j')) { - return getDynCaller(signature, rawFunction) - } - return wasmTable.get(rawFunction) - } - var fp = makeDynCaller() - if (typeof fp !== 'function') { - throwBindingError( - 'unknown function pointer with signature ' + - signature + - ': ' + - rawFunction - ) - } - return fp - } - var UnboundTypeError = undefined - function getTypeName(type) { - var ptr = ___getTypeName(type) - var rv = readLatin1String(ptr) - _free(ptr) - return rv - } - function throwUnboundTypeError(message, types) { - var unboundTypes = [] - var seen = {} - function visit(type) { - if (seen[type]) { - return - } - if (registeredTypes[type]) { - return - } - if (typeDependencies[type]) { - typeDependencies[type].forEach(visit) - return - } - unboundTypes.push(type) - seen[type] = true - } - types.forEach(visit) - throw new UnboundTypeError( - message + ': ' + unboundTypes.map(getTypeName).join([', ']) - ) - } - function __embind_register_function( - name, - argCount, - rawArgTypesAddr, - signature, - rawInvoker, - fn - ) { - var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr) - name = readLatin1String(name) - rawInvoker = embind__requireFunction(signature, rawInvoker) - exposePublicSymbol( - name, - function () { - throwUnboundTypeError( - 'Cannot call ' + name + ' due to unbound types', - argTypes - ) - }, - argCount - 1 - ) - whenDependentTypesAreResolved([], argTypes, function (argTypes) { - var invokerArgsArray = [argTypes[0], null].concat(argTypes.slice(1)) - replacePublicSymbol( - name, - craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn), - argCount - 1 - ) - return [] - }) - } - function integerReadValueFromPointer(name, shift, signed) { - switch (shift) { - case 0: - return signed - ? function readS8FromPointer(pointer) { - return HEAP8[pointer] - } - : function readU8FromPointer(pointer) { - return HEAPU8[pointer] - } - case 1: - return signed - ? function readS16FromPointer(pointer) { - return HEAP16[pointer >> 1] - } - : function readU16FromPointer(pointer) { - return HEAPU16[pointer >> 1] - } - case 2: - return signed - ? function readS32FromPointer(pointer) { - return HEAP32[pointer >> 2] - } - : function readU32FromPointer(pointer) { - return HEAPU32[pointer >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + name) - } - } - function __embind_register_integer( - primitiveType, - name, - size, - minRange, - maxRange - ) { - name = readLatin1String(name) - if (maxRange === -1) { - maxRange = 4294967295 - } - var shift = getShiftFromSize(size) - var fromWireType = function (value) { - return value - } - if (minRange === 0) { - var bitshift = 32 - 8 * size - fromWireType = function (value) { - return (value << bitshift) >>> bitshift - } - } - var isUnsignedType = name.includes('unsigned') - registerType(primitiveType, { - name: name, - fromWireType: fromWireType, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - if (value < minRange || value > maxRange) { - throw new TypeError( - 'Passing a number "' + - _embind_repr(value) + - '" from JS side to C/C++ side to an argument of type "' + - name + - '", which is outside the valid range [' + - minRange + - ', ' + - maxRange + - ']!' - ) - } - return isUnsignedType ? value >>> 0 : value | 0 - }, - argPackAdvance: 8, - readValueFromPointer: integerReadValueFromPointer( - name, - shift, - minRange !== 0 - ), - destructorFunction: null, - }) - } - function __embind_register_memory_view(rawType, dataTypeIndex, name) { - var typeMapping = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ] - var TA = typeMapping[dataTypeIndex] - function decodeMemoryView(handle) { - handle = handle >> 2 - var heap = HEAPU32 - var size = heap[handle] - var data = heap[handle + 1] - return new TA(buffer, data, size) - } - name = readLatin1String(name) - registerType( - rawType, - { - name: name, - fromWireType: decodeMemoryView, - argPackAdvance: 8, - readValueFromPointer: decodeMemoryView, - }, - { ignoreDuplicateRegistrations: true } - ) - } - function __embind_register_std_string(rawType, name) { - name = readLatin1String(name) - var stdStringIsUTF8 = name === 'std::string' - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var str - if (stdStringIsUTF8) { - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i - if (i == length || HEAPU8[currentBytePtr] == 0) { - var maxRead = currentBytePtr - decodeStartPtr - var stringSegment = UTF8ToString(decodeStartPtr, maxRead) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + 1 - } - } - } else { - var a = new Array(length) - for (var i = 0; i < length; ++i) { - a[i] = String.fromCharCode(HEAPU8[value + 4 + i]) - } - str = a.join('') - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (value instanceof ArrayBuffer) { - value = new Uint8Array(value) - } - var getLength - var valueIsOfTypeString = typeof value === 'string' - if ( - !( - valueIsOfTypeString || - value instanceof Uint8Array || - value instanceof Uint8ClampedArray || - value instanceof Int8Array - ) - ) { - throwBindingError('Cannot pass non-string to std::string') - } - if (stdStringIsUTF8 && valueIsOfTypeString) { - getLength = function () { - return lengthBytesUTF8(value) - } - } else { - getLength = function () { - return value.length - } - } - var length = getLength() - var ptr = _malloc(4 + length + 1) - HEAPU32[ptr >> 2] = length - if (stdStringIsUTF8 && valueIsOfTypeString) { - stringToUTF8(value, ptr + 4, length + 1) - } else { - if (valueIsOfTypeString) { - for (var i = 0; i < length; ++i) { - var charCode = value.charCodeAt(i) - if (charCode > 255) { - _free(ptr) - throwBindingError( - 'String has UTF-16 code units that do not fit in 8 bits' - ) - } - HEAPU8[ptr + 4 + i] = charCode - } - } else { - for (var i = 0; i < length; ++i) { - HEAPU8[ptr + 4 + i] = value[i] - } - } - } - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_std_wstring(rawType, charSize, name) { - name = readLatin1String(name) - var decodeString, encodeString, getHeap, lengthBytesUTF, shift - if (charSize === 2) { - decodeString = UTF16ToString - encodeString = stringToUTF16 - lengthBytesUTF = lengthBytesUTF16 - getHeap = function () { - return HEAPU16 - } - shift = 1 - } else if (charSize === 4) { - decodeString = UTF32ToString - encodeString = stringToUTF32 - lengthBytesUTF = lengthBytesUTF32 - getHeap = function () { - return HEAPU32 - } - shift = 2 - } - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var HEAP = getHeap() - var str - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i * charSize - if (i == length || HEAP[currentBytePtr >> shift] == 0) { - var maxReadBytes = currentBytePtr - decodeStartPtr - var stringSegment = decodeString(decodeStartPtr, maxReadBytes) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + charSize - } - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (!(typeof value === 'string')) { - throwBindingError( - 'Cannot pass non-string to C++ string type ' + name - ) - } - var length = lengthBytesUTF(value) - var ptr = _malloc(4 + length + charSize) - HEAPU32[ptr >> 2] = length >> shift - encodeString(value, ptr + 4, length + charSize) - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_void(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - isVoid: true, - name: name, - argPackAdvance: 0, - fromWireType: function () { - return undefined - }, - toWireType: function (destructors, o) { - return undefined - }, - }) - } - var emval_symbols = {} - function getStringOrSymbol(address) { - var symbol = emval_symbols[address] - if (symbol === undefined) { - return readLatin1String(address) - } else { - return symbol - } - } - function emval_get_global() { - if (typeof globalThis === 'object') { - return globalThis - } - return (function () { - return Function - })()('return this')() - } - function __emval_get_global(name) { - if (name === 0) { - return __emval_register(emval_get_global()) - } else { - name = getStringOrSymbol(name) - return __emval_register(emval_get_global()[name]) - } - } - function __emval_incref(handle) { - if (handle > 4) { - emval_handle_array[handle].refcount += 1 - } - } - function requireRegisteredType(rawType, humanName) { - var impl = registeredTypes[rawType] - if (undefined === impl) { - throwBindingError( - humanName + ' has unknown type ' + getTypeName(rawType) - ) - } - return impl - } - function craftEmvalAllocator(argCount) { - var argsList = '' - for (var i = 0; i < argCount; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - } - var functionBody = - 'return function emval_allocator_' + - argCount + - '(constructor, argTypes, args) {\n' - for (var i = 0; i < argCount; ++i) { - functionBody += - 'var argType' + - i + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - i + - '], "parameter ' + - i + - '");\n' + - 'var arg' + - i + - ' = argType' + - i + - '.readValueFromPointer(args);\n' + - 'args += argType' + - i + - "['argPackAdvance'];\n" - } - functionBody += - 'var obj = new constructor(' + - argsList + - ');\n' + - 'return __emval_register(obj);\n' + - '}\n' - return new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - functionBody - )(requireRegisteredType, Module, __emval_register) - } - var emval_newers = {} - function requireHandle(handle) { - if (!handle) { - throwBindingError('Cannot use deleted val. handle = ' + handle) - } - return emval_handle_array[handle].value - } - function __emval_new(handle, argCount, argTypes, args) { - handle = requireHandle(handle) - var newer = emval_newers[argCount] - if (!newer) { - newer = craftEmvalAllocator(argCount) - emval_newers[argCount] = newer - } - return newer(handle, argTypes, args) - } - function _abort() { - abort() - } - function _emscripten_memcpy_big(dest, src, num) { - HEAPU8.copyWithin(dest, src, src + num) - } - function emscripten_realloc_buffer(size) { - try { - wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16) - updateGlobalBufferAndViews(wasmMemory.buffer) - return 1 - } catch (e) {} - } - function _emscripten_resize_heap(requestedSize) { - var oldSize = HEAPU8.length - requestedSize = requestedSize >>> 0 - var maxHeapSize = 2147483648 - if (requestedSize > maxHeapSize) { - return false - } - for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { - var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown) - overGrownHeapSize = Math.min( - overGrownHeapSize, - requestedSize + 100663296 - ) - var newSize = Math.min( - maxHeapSize, - alignUp(Math.max(requestedSize, overGrownHeapSize), 65536) - ) - var replacement = emscripten_realloc_buffer(newSize) - if (replacement) { - return true - } - } - return false - } - var ENV = {} - function getExecutableName() { - return thisProgram || './this.program' - } - function getEnvStrings() { - if (!getEnvStrings.strings) { - var lang = - ( - (typeof navigator === 'object' && - navigator.languages && - navigator.languages[0]) || - 'C' - ).replace('-', '_') + '.UTF-8' - var env = { - USER: 'web_user', - LOGNAME: 'web_user', - PATH: '/', - PWD: '/', - HOME: '/home/web_user', - LANG: lang, - _: getExecutableName(), - } - for (var x in ENV) { - env[x] = ENV[x] - } - var strings = [] - for (var x in env) { - strings.push(x + '=' + env[x]) - } - getEnvStrings.strings = strings - } - return getEnvStrings.strings - } - var SYSCALLS = { - mappings: {}, - buffers: [null, [], []], - printChar: function (stream, curr) { - var buffer = SYSCALLS.buffers[stream] - if (curr === 0 || curr === 10) { - ;(stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0)) - buffer.length = 0 - } else { - buffer.push(curr) - } - }, - varargs: undefined, - get: function () { - SYSCALLS.varargs += 4 - var ret = HEAP32[(SYSCALLS.varargs - 4) >> 2] - return ret - }, - getStr: function (ptr) { - var ret = UTF8ToString(ptr) - return ret - }, - get64: function (low, high) { - return low - }, - } - function _environ_get(__environ, environ_buf) { - var bufSize = 0 - getEnvStrings().forEach(function (string, i) { - var ptr = environ_buf + bufSize - HEAP32[(__environ + i * 4) >> 2] = ptr - writeAsciiToMemory(string, ptr) - bufSize += string.length + 1 - }) - return 0 - } - function _environ_sizes_get(penviron_count, penviron_buf_size) { - var strings = getEnvStrings() - HEAP32[penviron_count >> 2] = strings.length - var bufSize = 0 - strings.forEach(function (string) { - bufSize += string.length + 1 - }) - HEAP32[penviron_buf_size >> 2] = bufSize - return 0 - } - function _exit(status) { - exit(status) - } - function _fd_close(fd) { - return 0 - } - function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {} - function _fd_write(fd, iov, iovcnt, pnum) { - var num = 0 - for (var i = 0; i < iovcnt; i++) { - var ptr = HEAP32[(iov + i * 8) >> 2] - var len = HEAP32[(iov + (i * 8 + 4)) >> 2] - for (var j = 0; j < len; j++) { - SYSCALLS.printChar(fd, HEAPU8[ptr + j]) - } - num += len - } - HEAP32[pnum >> 2] = num - return 0 - } - function _setTempRet0(val) { - setTempRet0(val) - } - embind_init_charCodes() - BindingError = Module['BindingError'] = extendError(Error, 'BindingError') - InternalError = Module['InternalError'] = extendError( - Error, - 'InternalError' - ) - init_emval() - UnboundTypeError = Module['UnboundTypeError'] = extendError( - Error, - 'UnboundTypeError' - ) - var asmLibraryArg = { - e: ___cxa_thread_atexit, - q: __embind_register_bigint, - m: __embind_register_bool, - x: __embind_register_emval, - l: __embind_register_float, - o: __embind_register_function, - b: __embind_register_integer, - a: __embind_register_memory_view, - h: __embind_register_std_string, - g: __embind_register_std_wstring, - n: __embind_register_void, - c: __emval_decref, - d: __emval_get_global, - i: __emval_incref, - j: __emval_new, - k: _abort, - s: _emscripten_memcpy_big, - f: _emscripten_resize_heap, - t: _environ_get, - u: _environ_sizes_get, - y: _exit, - w: _fd_close, - p: _fd_seek, - v: _fd_write, - r: _setTempRet0, - } - var asm = createWasm() - var ___wasm_call_ctors = (Module['___wasm_call_ctors'] = function () { - return (___wasm_call_ctors = Module['___wasm_call_ctors'] = - Module['asm']['A']).apply(null, arguments) - }) - var _malloc = (Module['_malloc'] = function () { - return (_malloc = Module['_malloc'] = Module['asm']['B']).apply( - null, - arguments - ) - }) - var _free = (Module['_free'] = function () { - return (_free = Module['_free'] = Module['asm']['C']).apply( - null, - arguments - ) - }) - var ___getTypeName = (Module['___getTypeName'] = function () { - return (___getTypeName = Module['___getTypeName'] = - Module['asm']['D']).apply(null, arguments) - }) - var ___embind_register_native_and_builtin_types = (Module[ - '___embind_register_native_and_builtin_types' - ] = function () { - return (___embind_register_native_and_builtin_types = Module[ - '___embind_register_native_and_builtin_types' - ] = - Module['asm']['E']).apply(null, arguments) - }) - var dynCall_jiji = (Module['dynCall_jiji'] = function () { - return (dynCall_jiji = Module['dynCall_jiji'] = Module['asm']['G']).apply( - null, - arguments - ) - }) - var calledRun - function ExitStatus(status) { - this.name = 'ExitStatus' - this.message = 'Program terminated with exit(' + status + ')' - this.status = status - } - dependenciesFulfilled = function runCaller() { - if (!calledRun) run() - if (!calledRun) dependenciesFulfilled = runCaller - } - function run(args) { - args = args || arguments_ - if (runDependencies > 0) { - return - } - preRun() - if (runDependencies > 0) { - return - } - function doRun() { - if (calledRun) return - calledRun = true - Module['calledRun'] = true - if (ABORT) return - initRuntime() - readyPromiseResolve(Module) - if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']() - postRun() - } - if (Module['setStatus']) { - Module['setStatus']('Running...') - setTimeout(function () { - setTimeout(function () { - Module['setStatus']('') - }, 1) - doRun() - }, 1) - } else { - doRun() - } - } - Module['run'] = run - function exit(status, implicit) { - EXITSTATUS = status - if (implicit && keepRuntimeAlive() && status === 0) { - return - } - if (keepRuntimeAlive()) { - } else { - exitRuntime() - if (Module['onExit']) Module['onExit'](status) - ABORT = true - } - quit_(status, new ExitStatus(status)) - } - if (Module['preInit']) { - if (typeof Module['preInit'] == 'function') - Module['preInit'] = [Module['preInit']] - while (Module['preInit'].length > 0) { - Module['preInit'].pop()() - } - } - run() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm b/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm deleted file mode 100755 index abf13d75f2..0000000000 Binary files a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm and /dev/null differ diff --git a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js b/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js deleted file mode 100644 index 5ced79bc8b..0000000000 --- a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js +++ /dev/null @@ -1,1896 +0,0 @@ -/* eslint-disable */ -var Module = (function () { - return function (Module) { - Module = Module || {} - - var Module = typeof Module !== 'undefined' ? Module : {} - var readyPromiseResolve, readyPromiseReject - Module['ready'] = new Promise(function (resolve, reject) { - readyPromiseResolve = resolve - readyPromiseReject = reject - }) - var moduleOverrides = {} - var key - for (key in Module) { - if (Module.hasOwnProperty(key)) { - moduleOverrides[key] = Module[key] - } - } - var arguments_ = [] - var thisProgram = './this.program' - var quit_ = function (status, toThrow) { - throw toThrow - } - var ENVIRONMENT_IS_WEB = false - var ENVIRONMENT_IS_WORKER = false - var ENVIRONMENT_IS_NODE = true - var scriptDirectory = '' - function locateFile(path) { - if (Module['locateFile']) { - return Module['locateFile'](path, scriptDirectory) - } - return scriptDirectory + path - } - var read_, readBinary - var nodeFS - var nodePath - if (ENVIRONMENT_IS_NODE) { - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = require('path').dirname(scriptDirectory) + '/' - } else { - scriptDirectory = __dirname + '/' - } - read_ = function shell_read(filename, binary) { - if (!nodeFS) nodeFS = require('fs') - if (!nodePath) nodePath = require('path') - filename = nodePath['normalize'](filename) - return nodeFS['readFileSync'](filename, binary ? null : 'utf8') - } - readBinary = function readBinary(filename) { - var ret = read_(filename, true) - if (!ret.buffer) { - ret = new Uint8Array(ret) - } - assert(ret.buffer) - return ret - } - if (process['argv'].length > 1) { - thisProgram = process['argv'][1].replace(/\\/g, '/') - } - arguments_ = process['argv'].slice(2) - quit_ = function (status) { - process['exit'](status) - } - Module['inspect'] = function () { - return '[Emscripten Module object]' - } - } else { - } - var out = Module['print'] || console.log.bind(console) - var err = Module['printErr'] || console.warn.bind(console) - for (key in moduleOverrides) { - if (moduleOverrides.hasOwnProperty(key)) { - Module[key] = moduleOverrides[key] - } - } - moduleOverrides = null - if (Module['arguments']) arguments_ = Module['arguments'] - if (Module['thisProgram']) thisProgram = Module['thisProgram'] - if (Module['quit']) quit_ = Module['quit'] - var tempRet0 = 0 - var setTempRet0 = function (value) { - tempRet0 = value - } - var wasmBinary - if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'] - var noExitRuntime = Module['noExitRuntime'] || true - if (typeof WebAssembly !== 'object') { - abort('no native wasm support detected') - } - var wasmMemory - var ABORT = false - var EXITSTATUS - function assert(condition, text) { - if (!condition) { - abort('Assertion failed: ' + text) - } - } - var UTF8Decoder = new TextDecoder('utf8') - function UTF8ArrayToString(heap, idx, maxBytesToRead) { - var endIdx = idx + maxBytesToRead - var endPtr = idx - while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr - return UTF8Decoder.decode( - heap.subarray - ? heap.subarray(idx, endPtr) - : new Uint8Array(heap.slice(idx, endPtr)) - ) - } - function UTF8ToString(ptr, maxBytesToRead) { - if (!ptr) return '' - var maxPtr = ptr + maxBytesToRead - for (var end = ptr; !(end >= maxPtr) && HEAPU8[end]; ) ++end - return UTF8Decoder.decode(HEAPU8.subarray(ptr, end)) - } - function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { - if (!(maxBytesToWrite > 0)) return 0 - var startIdx = outIdx - var endIdx = outIdx + maxBytesToWrite - 1 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) { - var u1 = str.charCodeAt(++i) - u = (65536 + ((u & 1023) << 10)) | (u1 & 1023) - } - if (u <= 127) { - if (outIdx >= endIdx) break - heap[outIdx++] = u - } else if (u <= 2047) { - if (outIdx + 1 >= endIdx) break - heap[outIdx++] = 192 | (u >> 6) - heap[outIdx++] = 128 | (u & 63) - } else if (u <= 65535) { - if (outIdx + 2 >= endIdx) break - heap[outIdx++] = 224 | (u >> 12) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } else { - if (outIdx + 3 >= endIdx) break - heap[outIdx++] = 240 | (u >> 18) - heap[outIdx++] = 128 | ((u >> 12) & 63) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } - } - heap[outIdx] = 0 - return outIdx - startIdx - } - function stringToUTF8(str, outPtr, maxBytesToWrite) { - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite) - } - function lengthBytesUTF8(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) - u = (65536 + ((u & 1023) << 10)) | (str.charCodeAt(++i) & 1023) - if (u <= 127) ++len - else if (u <= 2047) len += 2 - else if (u <= 65535) len += 3 - else len += 4 - } - return len - } - var UTF16Decoder = new TextDecoder('utf-16le') - function UTF16ToString(ptr, maxBytesToRead) { - var endPtr = ptr - var idx = endPtr >> 1 - var maxIdx = idx + maxBytesToRead / 2 - while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx - endPtr = idx << 1 - return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)) - var str = '' - for (var i = 0; !(i >= maxBytesToRead / 2); ++i) { - var codeUnit = HEAP16[(ptr + i * 2) >> 1] - if (codeUnit == 0) break - str += String.fromCharCode(codeUnit) - } - return str - } - function stringToUTF16(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 2) return 0 - maxBytesToWrite -= 2 - var startPtr = outPtr - var numCharsToWrite = - maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length - for (var i = 0; i < numCharsToWrite; ++i) { - var codeUnit = str.charCodeAt(i) - HEAP16[outPtr >> 1] = codeUnit - outPtr += 2 - } - HEAP16[outPtr >> 1] = 0 - return outPtr - startPtr - } - function lengthBytesUTF16(str) { - return str.length * 2 - } - function UTF32ToString(ptr, maxBytesToRead) { - var i = 0 - var str = '' - while (!(i >= maxBytesToRead / 4)) { - var utf32 = HEAP32[(ptr + i * 4) >> 2] - if (utf32 == 0) break - ++i - if (utf32 >= 65536) { - var ch = utf32 - 65536 - str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023)) - } else { - str += String.fromCharCode(utf32) - } - } - return str - } - function stringToUTF32(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 4) return 0 - var startPtr = outPtr - var endPtr = startPtr + maxBytesToWrite - 4 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) { - var trailSurrogate = str.charCodeAt(++i) - codeUnit = - (65536 + ((codeUnit & 1023) << 10)) | (trailSurrogate & 1023) - } - HEAP32[outPtr >> 2] = codeUnit - outPtr += 4 - if (outPtr + 4 > endPtr) break - } - HEAP32[outPtr >> 2] = 0 - return outPtr - startPtr - } - function lengthBytesUTF32(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) ++i - len += 4 - } - return len - } - function writeAsciiToMemory(str, buffer, dontAddNull) { - for (var i = 0; i < str.length; ++i) { - HEAP8[buffer++ >> 0] = str.charCodeAt(i) - } - if (!dontAddNull) HEAP8[buffer >> 0] = 0 - } - function alignUp(x, multiple) { - if (x % multiple > 0) { - x += multiple - (x % multiple) - } - return x - } - var buffer, - HEAP8, - HEAPU8, - HEAP16, - HEAPU16, - HEAP32, - HEAPU32, - HEAPF32, - HEAPF64 - function updateGlobalBufferAndViews(buf) { - buffer = buf - Module['HEAP8'] = HEAP8 = new Int8Array(buf) - Module['HEAP16'] = HEAP16 = new Int16Array(buf) - Module['HEAP32'] = HEAP32 = new Int32Array(buf) - Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf) - Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf) - Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf) - Module['HEAPF32'] = HEAPF32 = new Float32Array(buf) - Module['HEAPF64'] = HEAPF64 = new Float64Array(buf) - } - var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216 - var wasmTable - var __ATPRERUN__ = [] - var __ATINIT__ = [] - var __ATPOSTRUN__ = [] - var runtimeInitialized = false - var runtimeExited = false - function preRun() { - if (Module['preRun']) { - if (typeof Module['preRun'] == 'function') - Module['preRun'] = [Module['preRun']] - while (Module['preRun'].length) { - addOnPreRun(Module['preRun'].shift()) - } - } - callRuntimeCallbacks(__ATPRERUN__) - } - function initRuntime() { - runtimeInitialized = true - callRuntimeCallbacks(__ATINIT__) - } - function exitRuntime() { - runtimeExited = true - } - function postRun() { - if (Module['postRun']) { - if (typeof Module['postRun'] == 'function') - Module['postRun'] = [Module['postRun']] - while (Module['postRun'].length) { - addOnPostRun(Module['postRun'].shift()) - } - } - callRuntimeCallbacks(__ATPOSTRUN__) - } - function addOnPreRun(cb) { - __ATPRERUN__.unshift(cb) - } - function addOnInit(cb) { - __ATINIT__.unshift(cb) - } - function addOnPostRun(cb) { - __ATPOSTRUN__.unshift(cb) - } - var runDependencies = 0 - var runDependencyWatcher = null - var dependenciesFulfilled = null - function addRunDependency(id) { - runDependencies++ - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - } - function removeRunDependency(id) { - runDependencies-- - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - if (runDependencies == 0) { - if (runDependencyWatcher !== null) { - clearInterval(runDependencyWatcher) - runDependencyWatcher = null - } - if (dependenciesFulfilled) { - var callback = dependenciesFulfilled - dependenciesFulfilled = null - callback() - } - } - } - Module['preloadedImages'] = {} - Module['preloadedAudios'] = {} - function abort(what) { - if (Module['onAbort']) { - Module['onAbort'](what) - } - what += '' - err(what) - ABORT = true - EXITSTATUS = 1 - what = 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.' - var e = new WebAssembly.RuntimeError(what) - readyPromiseReject(e) - throw e - } - var dataURIPrefix = 'data:application/octet-stream;base64,' - function isDataURI(filename) { - return filename.startsWith(dataURIPrefix) - } - if (Module['locateFile']) { - var wasmBinaryFile = 'mozjpeg_node_enc.wasm' - if (!isDataURI(wasmBinaryFile)) { - wasmBinaryFile = locateFile(wasmBinaryFile) - } - } else { - throw new Error('invariant') - } - function getBinary(file) { - try { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary) - } - if (readBinary) { - return readBinary(file) - } else { - throw 'both async and sync fetching of the wasm failed' - } - } catch (err) { - abort(err) - } - } - function getBinaryPromise() { - return Promise.resolve().then(function () { - return getBinary(wasmBinaryFile) - }) - } - function createWasm() { - var info = { a: asmLibraryArg } - function receiveInstance(instance, module) { - var exports = instance.exports - Module['asm'] = exports - wasmMemory = Module['asm']['C'] - updateGlobalBufferAndViews(wasmMemory.buffer) - wasmTable = Module['asm']['I'] - addOnInit(Module['asm']['D']) - removeRunDependency('wasm-instantiate') - } - addRunDependency('wasm-instantiate') - function receiveInstantiationResult(result) { - receiveInstance(result['instance']) - } - function instantiateArrayBuffer(receiver) { - return getBinaryPromise() - .then(function (binary) { - var result = WebAssembly.instantiate(binary, info) - return result - }) - .then(receiver, function (reason) { - err('failed to asynchronously prepare wasm: ' + reason) - abort(reason) - }) - } - function instantiateAsync() { - return instantiateArrayBuffer(receiveInstantiationResult) - } - if (Module['instantiateWasm']) { - try { - var exports = Module['instantiateWasm'](info, receiveInstance) - return exports - } catch (e) { - err('Module.instantiateWasm callback failed with error: ' + e) - return false - } - } - instantiateAsync().catch(readyPromiseReject) - return {} - } - function callRuntimeCallbacks(callbacks) { - while (callbacks.length > 0) { - var callback = callbacks.shift() - if (typeof callback == 'function') { - callback(Module) - continue - } - var func = callback.func - if (typeof func === 'number') { - if (callback.arg === undefined) { - wasmTable.get(func)() - } else { - wasmTable.get(func)(callback.arg) - } - } else { - func(callback.arg === undefined ? null : callback.arg) - } - } - } - var runtimeKeepaliveCounter = 0 - function keepRuntimeAlive() { - return noExitRuntime || runtimeKeepaliveCounter > 0 - } - function _atexit(func, arg) {} - function ___cxa_thread_atexit(a0, a1) { - return _atexit(a0, a1) - } - var structRegistrations = {} - function runDestructors(destructors) { - while (destructors.length) { - var ptr = destructors.pop() - var del = destructors.pop() - del(ptr) - } - } - function simpleReadValueFromPointer(pointer) { - return this['fromWireType'](HEAPU32[pointer >> 2]) - } - var awaitingDependencies = {} - var registeredTypes = {} - var typeDependencies = {} - var char_0 = 48 - var char_9 = 57 - function makeLegalFunctionName(name) { - if (undefined === name) { - return '_unknown' - } - name = name.replace(/[^a-zA-Z0-9_]/g, '$') - var f = name.charCodeAt(0) - if (f >= char_0 && f <= char_9) { - return '_' + name - } else { - return name - } - } - function createNamedFunction(name, body) { - name = makeLegalFunctionName(name) - return new Function( - 'body', - 'return function ' + - name + - '() {\n' + - ' "use strict";' + - ' return body.apply(this, arguments);\n' + - '};\n' - )(body) - } - function extendError(baseErrorType, errorName) { - var errorClass = createNamedFunction(errorName, function (message) { - this.name = errorName - this.message = message - var stack = new Error(message).stack - if (stack !== undefined) { - this.stack = - this.toString() + '\n' + stack.replace(/^Error(:[^\n]*)?\n/, '') - } - }) - errorClass.prototype = Object.create(baseErrorType.prototype) - errorClass.prototype.constructor = errorClass - errorClass.prototype.toString = function () { - if (this.message === undefined) { - return this.name - } else { - return this.name + ': ' + this.message - } - } - return errorClass - } - var InternalError = undefined - function throwInternalError(message) { - throw new InternalError(message) - } - function whenDependentTypesAreResolved( - myTypes, - dependentTypes, - getTypeConverters - ) { - myTypes.forEach(function (type) { - typeDependencies[type] = dependentTypes - }) - function onComplete(typeConverters) { - var myTypeConverters = getTypeConverters(typeConverters) - if (myTypeConverters.length !== myTypes.length) { - throwInternalError('Mismatched type converter count') - } - for (var i = 0; i < myTypes.length; ++i) { - registerType(myTypes[i], myTypeConverters[i]) - } - } - var typeConverters = new Array(dependentTypes.length) - var unregisteredTypes = [] - var registered = 0 - dependentTypes.forEach(function (dt, i) { - if (registeredTypes.hasOwnProperty(dt)) { - typeConverters[i] = registeredTypes[dt] - } else { - unregisteredTypes.push(dt) - if (!awaitingDependencies.hasOwnProperty(dt)) { - awaitingDependencies[dt] = [] - } - awaitingDependencies[dt].push(function () { - typeConverters[i] = registeredTypes[dt] - ++registered - if (registered === unregisteredTypes.length) { - onComplete(typeConverters) - } - }) - } - }) - if (0 === unregisteredTypes.length) { - onComplete(typeConverters) - } - } - function __embind_finalize_value_object(structType) { - var reg = structRegistrations[structType] - delete structRegistrations[structType] - var rawConstructor = reg.rawConstructor - var rawDestructor = reg.rawDestructor - var fieldRecords = reg.fields - var fieldTypes = fieldRecords - .map(function (field) { - return field.getterReturnType - }) - .concat( - fieldRecords.map(function (field) { - return field.setterArgumentType - }) - ) - whenDependentTypesAreResolved( - [structType], - fieldTypes, - function (fieldTypes) { - var fields = {} - fieldRecords.forEach(function (field, i) { - var fieldName = field.fieldName - var getterReturnType = fieldTypes[i] - var getter = field.getter - var getterContext = field.getterContext - var setterArgumentType = fieldTypes[i + fieldRecords.length] - var setter = field.setter - var setterContext = field.setterContext - fields[fieldName] = { - read: function (ptr) { - return getterReturnType['fromWireType']( - getter(getterContext, ptr) - ) - }, - write: function (ptr, o) { - var destructors = [] - setter( - setterContext, - ptr, - setterArgumentType['toWireType'](destructors, o) - ) - runDestructors(destructors) - }, - } - }) - return [ - { - name: reg.name, - fromWireType: function (ptr) { - var rv = {} - for (var i in fields) { - rv[i] = fields[i].read(ptr) - } - rawDestructor(ptr) - return rv - }, - toWireType: function (destructors, o) { - for (var fieldName in fields) { - if (!(fieldName in o)) { - throw new TypeError('Missing field: "' + fieldName + '"') - } - } - var ptr = rawConstructor() - for (fieldName in fields) { - fields[fieldName].write(ptr, o[fieldName]) - } - if (destructors !== null) { - destructors.push(rawDestructor, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: rawDestructor, - }, - ] - } - ) - } - function __embind_register_bigint( - primitiveType, - name, - size, - minRange, - maxRange - ) {} - function getShiftFromSize(size) { - switch (size) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + size) - } - } - function embind_init_charCodes() { - var codes = new Array(256) - for (var i = 0; i < 256; ++i) { - codes[i] = String.fromCharCode(i) - } - embind_charCodes = codes - } - var embind_charCodes = undefined - function readLatin1String(ptr) { - var ret = '' - var c = ptr - while (HEAPU8[c]) { - ret += embind_charCodes[HEAPU8[c++]] - } - return ret - } - var BindingError = undefined - function throwBindingError(message) { - throw new BindingError(message) - } - function registerType(rawType, registeredInstance, options) { - options = options || {} - if (!('argPackAdvance' in registeredInstance)) { - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - } - var name = registeredInstance.name - if (!rawType) { - throwBindingError( - 'type "' + name + '" must have a positive integer typeid pointer' - ) - } - if (registeredTypes.hasOwnProperty(rawType)) { - if (options.ignoreDuplicateRegistrations) { - return - } else { - throwBindingError("Cannot register type '" + name + "' twice") - } - } - registeredTypes[rawType] = registeredInstance - delete typeDependencies[rawType] - if (awaitingDependencies.hasOwnProperty(rawType)) { - var callbacks = awaitingDependencies[rawType] - delete awaitingDependencies[rawType] - callbacks.forEach(function (cb) { - cb() - }) - } - } - function __embind_register_bool( - rawType, - name, - size, - trueValue, - falseValue - ) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (wt) { - return !!wt - }, - toWireType: function (destructors, o) { - return o ? trueValue : falseValue - }, - argPackAdvance: 8, - readValueFromPointer: function (pointer) { - var heap - if (size === 1) { - heap = HEAP8 - } else if (size === 2) { - heap = HEAP16 - } else if (size === 4) { - heap = HEAP32 - } else { - throw new TypeError('Unknown boolean type size: ' + name) - } - return this['fromWireType'](heap[pointer >> shift]) - }, - destructorFunction: null, - }) - } - var emval_free_list = [] - var emval_handle_array = [ - {}, - { value: undefined }, - { value: null }, - { value: true }, - { value: false }, - ] - function __emval_decref(handle) { - if (handle > 4 && 0 === --emval_handle_array[handle].refcount) { - emval_handle_array[handle] = undefined - emval_free_list.push(handle) - } - } - function count_emval_handles() { - var count = 0 - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - ++count - } - } - return count - } - function get_first_emval() { - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - return emval_handle_array[i] - } - } - return null - } - function init_emval() { - Module['count_emval_handles'] = count_emval_handles - Module['get_first_emval'] = get_first_emval - } - function __emval_register(value) { - switch (value) { - case undefined: { - return 1 - } - case null: { - return 2 - } - case true: { - return 3 - } - case false: { - return 4 - } - default: { - var handle = emval_free_list.length - ? emval_free_list.pop() - : emval_handle_array.length - emval_handle_array[handle] = { refcount: 1, value: value } - return handle - } - } - } - function __embind_register_emval(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (handle) { - var rv = emval_handle_array[handle].value - __emval_decref(handle) - return rv - }, - toWireType: function (destructors, value) { - return __emval_register(value) - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: null, - }) - } - function _embind_repr(v) { - if (v === null) { - return 'null' - } - var t = typeof v - if (t === 'object' || t === 'array' || t === 'function') { - return v.toString() - } else { - return '' + v - } - } - function floatReadValueFromPointer(name, shift) { - switch (shift) { - case 2: - return function (pointer) { - return this['fromWireType'](HEAPF32[pointer >> 2]) - } - case 3: - return function (pointer) { - return this['fromWireType'](HEAPF64[pointer >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + name) - } - } - function __embind_register_float(rawType, name, size) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (value) { - return value - }, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - return value - }, - argPackAdvance: 8, - readValueFromPointer: floatReadValueFromPointer(name, shift), - destructorFunction: null, - }) - } - function new_(constructor, argumentList) { - if (!(constructor instanceof Function)) { - throw new TypeError( - 'new_ called with constructor type ' + - typeof constructor + - ' which is not a function' - ) - } - var dummy = createNamedFunction( - constructor.name || 'unknownFunctionName', - function () {} - ) - dummy.prototype = constructor.prototype - var obj = new dummy() - var r = constructor.apply(obj, argumentList) - return r instanceof Object ? r : obj - } - function craftInvokerFunction( - humanName, - argTypes, - classType, - cppInvokerFunc, - cppTargetFunc - ) { - var argCount = argTypes.length - if (argCount < 2) { - throwBindingError( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - } - var isClassMethodFunc = argTypes[1] !== null && classType !== null - var needsDestructorStack = false - for (var i = 1; i < argTypes.length; ++i) { - if ( - argTypes[i] !== null && - argTypes[i].destructorFunction === undefined - ) { - needsDestructorStack = true - break - } - } - var returns = argTypes[0].name !== 'void' - var argsList = '' - var argsListWired = '' - for (var i = 0; i < argCount - 2; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - argsListWired += (i !== 0 ? ', ' : '') + 'arg' + i + 'Wired' - } - var invokerFnBody = - 'return function ' + - makeLegalFunctionName(humanName) + - '(' + - argsList + - ') {\n' + - 'if (arguments.length !== ' + - (argCount - 2) + - ') {\n' + - "throwBindingError('function " + - humanName + - " called with ' + arguments.length + ' arguments, expected " + - (argCount - 2) + - " args!');\n" + - '}\n' - if (needsDestructorStack) { - invokerFnBody += 'var destructors = [];\n' - } - var dtorStack = needsDestructorStack ? 'destructors' : 'null' - var args1 = [ - 'throwBindingError', - 'invoker', - 'fn', - 'runDestructors', - 'retType', - 'classParam', - ] - var args2 = [ - throwBindingError, - cppInvokerFunc, - cppTargetFunc, - runDestructors, - argTypes[0], - argTypes[1], - ] - if (isClassMethodFunc) { - invokerFnBody += - 'var thisWired = classParam.toWireType(' + dtorStack + ', this);\n' - } - for (var i = 0; i < argCount - 2; ++i) { - invokerFnBody += - 'var arg' + - i + - 'Wired = argType' + - i + - '.toWireType(' + - dtorStack + - ', arg' + - i + - '); // ' + - argTypes[i + 2].name + - '\n' - args1.push('argType' + i) - args2.push(argTypes[i + 2]) - } - if (isClassMethodFunc) { - argsListWired = - 'thisWired' + (argsListWired.length > 0 ? ', ' : '') + argsListWired - } - invokerFnBody += - (returns ? 'var rv = ' : '') + - 'invoker(fn' + - (argsListWired.length > 0 ? ', ' : '') + - argsListWired + - ');\n' - if (needsDestructorStack) { - invokerFnBody += 'runDestructors(destructors);\n' - } else { - for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { - var paramName = i === 1 ? 'thisWired' : 'arg' + (i - 2) + 'Wired' - if (argTypes[i].destructorFunction !== null) { - invokerFnBody += - paramName + - '_dtor(' + - paramName + - '); // ' + - argTypes[i].name + - '\n' - args1.push(paramName + '_dtor') - args2.push(argTypes[i].destructorFunction) - } - } - } - if (returns) { - invokerFnBody += - 'var ret = retType.fromWireType(rv);\n' + 'return ret;\n' - } else { - } - invokerFnBody += '}\n' - args1.push(invokerFnBody) - var invokerFunction = new_(Function, args1).apply(null, args2) - return invokerFunction - } - function ensureOverloadTable(proto, methodName, humanName) { - if (undefined === proto[methodName].overloadTable) { - var prevFunc = proto[methodName] - proto[methodName] = function () { - if ( - !proto[methodName].overloadTable.hasOwnProperty(arguments.length) - ) { - throwBindingError( - "Function '" + - humanName + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - proto[methodName].overloadTable + - ')!' - ) - } - return proto[methodName].overloadTable[arguments.length].apply( - this, - arguments - ) - } - proto[methodName].overloadTable = [] - proto[methodName].overloadTable[prevFunc.argCount] = prevFunc - } - } - function exposePublicSymbol(name, value, numArguments) { - if (Module.hasOwnProperty(name)) { - if ( - undefined === numArguments || - (undefined !== Module[name].overloadTable && - undefined !== Module[name].overloadTable[numArguments]) - ) { - throwBindingError("Cannot register public name '" + name + "' twice") - } - ensureOverloadTable(Module, name, name) - if (Module.hasOwnProperty(numArguments)) { - throwBindingError( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - numArguments + - ')!' - ) - } - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - if (undefined !== numArguments) { - Module[name].numArguments = numArguments - } - } - } - function heap32VectorToArray(count, firstElement) { - var array = [] - for (var i = 0; i < count; i++) { - array.push(HEAP32[(firstElement >> 2) + i]) - } - return array - } - function replacePublicSymbol(name, value, numArguments) { - if (!Module.hasOwnProperty(name)) { - throwInternalError('Replacing nonexistent public symbol') - } - if ( - undefined !== Module[name].overloadTable && - undefined !== numArguments - ) { - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - Module[name].argCount = numArguments - } - } - function dynCallLegacy(sig, ptr, args) { - var f = Module['dynCall_' + sig] - return args && args.length - ? f.apply(null, [ptr].concat(args)) - : f.call(null, ptr) - } - function dynCall(sig, ptr, args) { - if (sig.includes('j')) { - return dynCallLegacy(sig, ptr, args) - } - return wasmTable.get(ptr).apply(null, args) - } - function getDynCaller(sig, ptr) { - var argCache = [] - return function () { - argCache.length = arguments.length - for (var i = 0; i < arguments.length; i++) { - argCache[i] = arguments[i] - } - return dynCall(sig, ptr, argCache) - } - } - function embind__requireFunction(signature, rawFunction) { - signature = readLatin1String(signature) - function makeDynCaller() { - if (signature.includes('j')) { - return getDynCaller(signature, rawFunction) - } - return wasmTable.get(rawFunction) - } - var fp = makeDynCaller() - if (typeof fp !== 'function') { - throwBindingError( - 'unknown function pointer with signature ' + - signature + - ': ' + - rawFunction - ) - } - return fp - } - var UnboundTypeError = undefined - function getTypeName(type) { - var ptr = ___getTypeName(type) - var rv = readLatin1String(ptr) - _free(ptr) - return rv - } - function throwUnboundTypeError(message, types) { - var unboundTypes = [] - var seen = {} - function visit(type) { - if (seen[type]) { - return - } - if (registeredTypes[type]) { - return - } - if (typeDependencies[type]) { - typeDependencies[type].forEach(visit) - return - } - unboundTypes.push(type) - seen[type] = true - } - types.forEach(visit) - throw new UnboundTypeError( - message + ': ' + unboundTypes.map(getTypeName).join([', ']) - ) - } - function __embind_register_function( - name, - argCount, - rawArgTypesAddr, - signature, - rawInvoker, - fn - ) { - var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr) - name = readLatin1String(name) - rawInvoker = embind__requireFunction(signature, rawInvoker) - exposePublicSymbol( - name, - function () { - throwUnboundTypeError( - 'Cannot call ' + name + ' due to unbound types', - argTypes - ) - }, - argCount - 1 - ) - whenDependentTypesAreResolved([], argTypes, function (argTypes) { - var invokerArgsArray = [argTypes[0], null].concat(argTypes.slice(1)) - replacePublicSymbol( - name, - craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn), - argCount - 1 - ) - return [] - }) - } - function integerReadValueFromPointer(name, shift, signed) { - switch (shift) { - case 0: - return signed - ? function readS8FromPointer(pointer) { - return HEAP8[pointer] - } - : function readU8FromPointer(pointer) { - return HEAPU8[pointer] - } - case 1: - return signed - ? function readS16FromPointer(pointer) { - return HEAP16[pointer >> 1] - } - : function readU16FromPointer(pointer) { - return HEAPU16[pointer >> 1] - } - case 2: - return signed - ? function readS32FromPointer(pointer) { - return HEAP32[pointer >> 2] - } - : function readU32FromPointer(pointer) { - return HEAPU32[pointer >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + name) - } - } - function __embind_register_integer( - primitiveType, - name, - size, - minRange, - maxRange - ) { - name = readLatin1String(name) - if (maxRange === -1) { - maxRange = 4294967295 - } - var shift = getShiftFromSize(size) - var fromWireType = function (value) { - return value - } - if (minRange === 0) { - var bitshift = 32 - 8 * size - fromWireType = function (value) { - return (value << bitshift) >>> bitshift - } - } - var isUnsignedType = name.includes('unsigned') - registerType(primitiveType, { - name: name, - fromWireType: fromWireType, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - if (value < minRange || value > maxRange) { - throw new TypeError( - 'Passing a number "' + - _embind_repr(value) + - '" from JS side to C/C++ side to an argument of type "' + - name + - '", which is outside the valid range [' + - minRange + - ', ' + - maxRange + - ']!' - ) - } - return isUnsignedType ? value >>> 0 : value | 0 - }, - argPackAdvance: 8, - readValueFromPointer: integerReadValueFromPointer( - name, - shift, - minRange !== 0 - ), - destructorFunction: null, - }) - } - function __embind_register_memory_view(rawType, dataTypeIndex, name) { - var typeMapping = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ] - var TA = typeMapping[dataTypeIndex] - function decodeMemoryView(handle) { - handle = handle >> 2 - var heap = HEAPU32 - var size = heap[handle] - var data = heap[handle + 1] - return new TA(buffer, data, size) - } - name = readLatin1String(name) - registerType( - rawType, - { - name: name, - fromWireType: decodeMemoryView, - argPackAdvance: 8, - readValueFromPointer: decodeMemoryView, - }, - { ignoreDuplicateRegistrations: true } - ) - } - function __embind_register_std_string(rawType, name) { - name = readLatin1String(name) - var stdStringIsUTF8 = name === 'std::string' - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var str - if (stdStringIsUTF8) { - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i - if (i == length || HEAPU8[currentBytePtr] == 0) { - var maxRead = currentBytePtr - decodeStartPtr - var stringSegment = UTF8ToString(decodeStartPtr, maxRead) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + 1 - } - } - } else { - var a = new Array(length) - for (var i = 0; i < length; ++i) { - a[i] = String.fromCharCode(HEAPU8[value + 4 + i]) - } - str = a.join('') - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (value instanceof ArrayBuffer) { - value = new Uint8Array(value) - } - var getLength - var valueIsOfTypeString = typeof value === 'string' - if ( - !( - valueIsOfTypeString || - value instanceof Uint8Array || - value instanceof Uint8ClampedArray || - value instanceof Int8Array - ) - ) { - throwBindingError('Cannot pass non-string to std::string') - } - if (stdStringIsUTF8 && valueIsOfTypeString) { - getLength = function () { - return lengthBytesUTF8(value) - } - } else { - getLength = function () { - return value.length - } - } - var length = getLength() - var ptr = _malloc(4 + length + 1) - HEAPU32[ptr >> 2] = length - if (stdStringIsUTF8 && valueIsOfTypeString) { - stringToUTF8(value, ptr + 4, length + 1) - } else { - if (valueIsOfTypeString) { - for (var i = 0; i < length; ++i) { - var charCode = value.charCodeAt(i) - if (charCode > 255) { - _free(ptr) - throwBindingError( - 'String has UTF-16 code units that do not fit in 8 bits' - ) - } - HEAPU8[ptr + 4 + i] = charCode - } - } else { - for (var i = 0; i < length; ++i) { - HEAPU8[ptr + 4 + i] = value[i] - } - } - } - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_std_wstring(rawType, charSize, name) { - name = readLatin1String(name) - var decodeString, encodeString, getHeap, lengthBytesUTF, shift - if (charSize === 2) { - decodeString = UTF16ToString - encodeString = stringToUTF16 - lengthBytesUTF = lengthBytesUTF16 - getHeap = function () { - return HEAPU16 - } - shift = 1 - } else if (charSize === 4) { - decodeString = UTF32ToString - encodeString = stringToUTF32 - lengthBytesUTF = lengthBytesUTF32 - getHeap = function () { - return HEAPU32 - } - shift = 2 - } - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var HEAP = getHeap() - var str - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i * charSize - if (i == length || HEAP[currentBytePtr >> shift] == 0) { - var maxReadBytes = currentBytePtr - decodeStartPtr - var stringSegment = decodeString(decodeStartPtr, maxReadBytes) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + charSize - } - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (!(typeof value === 'string')) { - throwBindingError( - 'Cannot pass non-string to C++ string type ' + name - ) - } - var length = lengthBytesUTF(value) - var ptr = _malloc(4 + length + charSize) - HEAPU32[ptr >> 2] = length >> shift - encodeString(value, ptr + 4, length + charSize) - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_value_object( - rawType, - name, - constructorSignature, - rawConstructor, - destructorSignature, - rawDestructor - ) { - structRegistrations[rawType] = { - name: readLatin1String(name), - rawConstructor: embind__requireFunction( - constructorSignature, - rawConstructor - ), - rawDestructor: embind__requireFunction( - destructorSignature, - rawDestructor - ), - fields: [], - } - } - function __embind_register_value_object_field( - structType, - fieldName, - getterReturnType, - getterSignature, - getter, - getterContext, - setterArgumentType, - setterSignature, - setter, - setterContext - ) { - structRegistrations[structType].fields.push({ - fieldName: readLatin1String(fieldName), - getterReturnType: getterReturnType, - getter: embind__requireFunction(getterSignature, getter), - getterContext: getterContext, - setterArgumentType: setterArgumentType, - setter: embind__requireFunction(setterSignature, setter), - setterContext: setterContext, - }) - } - function __embind_register_void(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - isVoid: true, - name: name, - argPackAdvance: 0, - fromWireType: function () { - return undefined - }, - toWireType: function (destructors, o) { - return undefined - }, - }) - } - var emval_symbols = {} - function getStringOrSymbol(address) { - var symbol = emval_symbols[address] - if (symbol === undefined) { - return readLatin1String(address) - } else { - return symbol - } - } - function emval_get_global() { - if (typeof globalThis === 'object') { - return globalThis - } - return (function () { - return Function - })()('return this')() - } - function __emval_get_global(name) { - if (name === 0) { - return __emval_register(emval_get_global()) - } else { - name = getStringOrSymbol(name) - return __emval_register(emval_get_global()[name]) - } - } - function __emval_incref(handle) { - if (handle > 4) { - emval_handle_array[handle].refcount += 1 - } - } - function requireRegisteredType(rawType, humanName) { - var impl = registeredTypes[rawType] - if (undefined === impl) { - throwBindingError( - humanName + ' has unknown type ' + getTypeName(rawType) - ) - } - return impl - } - function craftEmvalAllocator(argCount) { - var argsList = '' - for (var i = 0; i < argCount; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - } - var functionBody = - 'return function emval_allocator_' + - argCount + - '(constructor, argTypes, args) {\n' - for (var i = 0; i < argCount; ++i) { - functionBody += - 'var argType' + - i + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - i + - '], "parameter ' + - i + - '");\n' + - 'var arg' + - i + - ' = argType' + - i + - '.readValueFromPointer(args);\n' + - 'args += argType' + - i + - "['argPackAdvance'];\n" - } - functionBody += - 'var obj = new constructor(' + - argsList + - ');\n' + - 'return __emval_register(obj);\n' + - '}\n' - return new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - functionBody - )(requireRegisteredType, Module, __emval_register) - } - var emval_newers = {} - function requireHandle(handle) { - if (!handle) { - throwBindingError('Cannot use deleted val. handle = ' + handle) - } - return emval_handle_array[handle].value - } - function __emval_new(handle, argCount, argTypes, args) { - handle = requireHandle(handle) - var newer = emval_newers[argCount] - if (!newer) { - newer = craftEmvalAllocator(argCount) - emval_newers[argCount] = newer - } - return newer(handle, argTypes, args) - } - function _abort() { - abort() - } - function _emscripten_memcpy_big(dest, src, num) { - HEAPU8.copyWithin(dest, src, src + num) - } - function emscripten_realloc_buffer(size) { - try { - wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16) - updateGlobalBufferAndViews(wasmMemory.buffer) - return 1 - } catch (e) {} - } - function _emscripten_resize_heap(requestedSize) { - var oldSize = HEAPU8.length - requestedSize = requestedSize >>> 0 - var maxHeapSize = 2147483648 - if (requestedSize > maxHeapSize) { - return false - } - for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { - var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown) - overGrownHeapSize = Math.min( - overGrownHeapSize, - requestedSize + 100663296 - ) - var newSize = Math.min( - maxHeapSize, - alignUp(Math.max(requestedSize, overGrownHeapSize), 65536) - ) - var replacement = emscripten_realloc_buffer(newSize) - if (replacement) { - return true - } - } - return false - } - var ENV = {} - function getExecutableName() { - return thisProgram || './this.program' - } - function getEnvStrings() { - if (!getEnvStrings.strings) { - var lang = - ( - (typeof navigator === 'object' && - navigator.languages && - navigator.languages[0]) || - 'C' - ).replace('-', '_') + '.UTF-8' - var env = { - USER: 'web_user', - LOGNAME: 'web_user', - PATH: '/', - PWD: '/', - HOME: '/home/web_user', - LANG: lang, - _: getExecutableName(), - } - for (var x in ENV) { - env[x] = ENV[x] - } - var strings = [] - for (var x in env) { - strings.push(x + '=' + env[x]) - } - getEnvStrings.strings = strings - } - return getEnvStrings.strings - } - var SYSCALLS = { - mappings: {}, - buffers: [null, [], []], - printChar: function (stream, curr) { - var buffer = SYSCALLS.buffers[stream] - if (curr === 0 || curr === 10) { - ;(stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0)) - buffer.length = 0 - } else { - buffer.push(curr) - } - }, - varargs: undefined, - get: function () { - SYSCALLS.varargs += 4 - var ret = HEAP32[(SYSCALLS.varargs - 4) >> 2] - return ret - }, - getStr: function (ptr) { - var ret = UTF8ToString(ptr) - return ret - }, - get64: function (low, high) { - return low - }, - } - function _environ_get(__environ, environ_buf) { - var bufSize = 0 - getEnvStrings().forEach(function (string, i) { - var ptr = environ_buf + bufSize - HEAP32[(__environ + i * 4) >> 2] = ptr - writeAsciiToMemory(string, ptr) - bufSize += string.length + 1 - }) - return 0 - } - function _environ_sizes_get(penviron_count, penviron_buf_size) { - var strings = getEnvStrings() - HEAP32[penviron_count >> 2] = strings.length - var bufSize = 0 - strings.forEach(function (string) { - bufSize += string.length + 1 - }) - HEAP32[penviron_buf_size >> 2] = bufSize - return 0 - } - function _exit(status) { - exit(status) - } - function _fd_close(fd) { - return 0 - } - function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {} - function _fd_write(fd, iov, iovcnt, pnum) { - var num = 0 - for (var i = 0; i < iovcnt; i++) { - var ptr = HEAP32[(iov + i * 8) >> 2] - var len = HEAP32[(iov + (i * 8 + 4)) >> 2] - for (var j = 0; j < len; j++) { - SYSCALLS.printChar(fd, HEAPU8[ptr + j]) - } - num += len - } - HEAP32[pnum >> 2] = num - return 0 - } - function _setTempRet0(val) { - setTempRet0(val) - } - InternalError = Module['InternalError'] = extendError( - Error, - 'InternalError' - ) - embind_init_charCodes() - BindingError = Module['BindingError'] = extendError(Error, 'BindingError') - init_emval() - UnboundTypeError = Module['UnboundTypeError'] = extendError( - Error, - 'UnboundTypeError' - ) - var asmLibraryArg = { - B: ___cxa_thread_atexit, - l: __embind_finalize_value_object, - p: __embind_register_bigint, - y: __embind_register_bool, - x: __embind_register_emval, - i: __embind_register_float, - f: __embind_register_function, - c: __embind_register_integer, - b: __embind_register_memory_view, - j: __embind_register_std_string, - e: __embind_register_std_wstring, - m: __embind_register_value_object, - a: __embind_register_value_object_field, - z: __embind_register_void, - g: __emval_decref, - u: __emval_get_global, - k: __emval_incref, - n: __emval_new, - h: _abort, - r: _emscripten_memcpy_big, - d: _emscripten_resize_heap, - s: _environ_get, - t: _environ_sizes_get, - A: _exit, - w: _fd_close, - o: _fd_seek, - v: _fd_write, - q: _setTempRet0, - } - var asm = createWasm() - var ___wasm_call_ctors = (Module['___wasm_call_ctors'] = function () { - return (___wasm_call_ctors = Module['___wasm_call_ctors'] = - Module['asm']['D']).apply(null, arguments) - }) - var _malloc = (Module['_malloc'] = function () { - return (_malloc = Module['_malloc'] = Module['asm']['E']).apply( - null, - arguments - ) - }) - var _free = (Module['_free'] = function () { - return (_free = Module['_free'] = Module['asm']['F']).apply( - null, - arguments - ) - }) - var ___getTypeName = (Module['___getTypeName'] = function () { - return (___getTypeName = Module['___getTypeName'] = - Module['asm']['G']).apply(null, arguments) - }) - var ___embind_register_native_and_builtin_types = (Module[ - '___embind_register_native_and_builtin_types' - ] = function () { - return (___embind_register_native_and_builtin_types = Module[ - '___embind_register_native_and_builtin_types' - ] = - Module['asm']['H']).apply(null, arguments) - }) - var dynCall_jiji = (Module['dynCall_jiji'] = function () { - return (dynCall_jiji = Module['dynCall_jiji'] = Module['asm']['J']).apply( - null, - arguments - ) - }) - var calledRun - function ExitStatus(status) { - this.name = 'ExitStatus' - this.message = 'Program terminated with exit(' + status + ')' - this.status = status - } - dependenciesFulfilled = function runCaller() { - if (!calledRun) run() - if (!calledRun) dependenciesFulfilled = runCaller - } - function run(args) { - args = args || arguments_ - if (runDependencies > 0) { - return - } - preRun() - if (runDependencies > 0) { - return - } - function doRun() { - if (calledRun) return - calledRun = true - Module['calledRun'] = true - if (ABORT) return - initRuntime() - readyPromiseResolve(Module) - if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']() - postRun() - } - if (Module['setStatus']) { - Module['setStatus']('Running...') - setTimeout(function () { - setTimeout(function () { - Module['setStatus']('') - }, 1) - doRun() - }, 1) - } else { - doRun() - } - } - Module['run'] = run - function exit(status, implicit) { - EXITSTATUS = status - if (implicit && keepRuntimeAlive() && status === 0) { - return - } - if (keepRuntimeAlive()) { - } else { - exitRuntime() - if (Module['onExit']) Module['onExit'](status) - ABORT = true - } - quit_(status, new ExitStatus(status)) - } - if (Module['preInit']) { - if (typeof Module['preInit'] == 'function') - Module['preInit'] = [Module['preInit']] - while (Module['preInit'].length > 0) { - Module['preInit'].pop()() - } - } - run() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm b/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm deleted file mode 100755 index 4dc36264bc..0000000000 Binary files a/packages/next/src/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm and /dev/null differ diff --git a/packages/next/src/server/lib/squoosh/png/squoosh_oxipng.js b/packages/next/src/server/lib/squoosh/png/squoosh_oxipng.js deleted file mode 100644 index abfb6de7c3..0000000000 --- a/packages/next/src/server/lib/squoosh/png/squoosh_oxipng.js +++ /dev/null @@ -1,119 +0,0 @@ -let wasm - -let cachedTextDecoder = new TextDecoder('utf-8', { - ignoreBOM: true, - fatal: true, -}) - -cachedTextDecoder.decode() - -let cachegetUint8Memory0 = null -function getUint8Memory0() { - if ( - cachegetUint8Memory0 === null || - cachegetUint8Memory0.buffer !== wasm.memory.buffer - ) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer) - } - return cachegetUint8Memory0 -} - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)) -} - -let WASM_VECTOR_LEN = 0 - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1) - getUint8Memory0().set(arg, ptr / 1) - WASM_VECTOR_LEN = arg.length - return ptr -} - -let cachegetInt32Memory0 = null -function getInt32Memory0() { - if ( - cachegetInt32Memory0 === null || - cachegetInt32Memory0.buffer !== wasm.memory.buffer - ) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer) - } - return cachegetInt32Memory0 -} - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len) -} -/** - * @param {Uint8Array} data - * @param {number} level - * @param {boolean} interlace - * @returns {Uint8Array} - */ -export function optimise(data, level, interlace) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) - var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc) - var len0 = WASM_VECTOR_LEN - wasm.optimise(retptr, ptr0, len0, level, interlace) - 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_add_to_stack_pointer(16) - } -} - -async function load(module, imports) { - if (typeof Response === 'function' && module instanceof Response) { - if (typeof WebAssembly.instantiateStreaming === 'function') { - return await WebAssembly.instantiateStreaming(module, imports) - } - - const bytes = await module.arrayBuffer() - return await WebAssembly.instantiate(bytes, imports) - } else { - const instance = await WebAssembly.instantiate(module, imports) - - if (instance instanceof WebAssembly.Instance) { - return { instance, module } - } else { - return instance - } - } -} - -async function init(input) { - const imports = {} - imports.wbg = {} - imports.wbg.__wbindgen_throw = function (arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)) - } - - if ( - typeof input === 'string' || - (typeof Request === 'function' && input instanceof Request) || - (typeof URL === 'function' && input instanceof URL) - ) { - input = fetch(input) - } - - const { instance, module } = await load(await input, imports) - - wasm = instance.exports - init.__wbindgen_wasm_module = module - - return wasm -} - -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/src/server/lib/squoosh/png/squoosh_oxipng_bg.wasm b/packages/next/src/server/lib/squoosh/png/squoosh_oxipng_bg.wasm deleted file mode 100644 index 92ec1d8960..0000000000 Binary files a/packages/next/src/server/lib/squoosh/png/squoosh_oxipng_bg.wasm and /dev/null differ diff --git a/packages/next/src/server/lib/squoosh/png/squoosh_png.js b/packages/next/src/server/lib/squoosh/png/squoosh_png.js deleted file mode 100644 index 4ff8d7b1ab..0000000000 --- a/packages/next/src/server/lib/squoosh/png/squoosh_png.js +++ /dev/null @@ -1,183 +0,0 @@ -let wasm - -let cachedTextDecoder = new TextDecoder('utf-8', { - ignoreBOM: true, - fatal: true, -}) - -cachedTextDecoder.decode() - -let cachegetUint8Memory0 = null -function getUint8Memory0() { - if ( - cachegetUint8Memory0 === null || - cachegetUint8Memory0.buffer !== wasm.memory.buffer - ) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer) - } - return cachegetUint8Memory0 -} - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)) -} - -let cachegetUint8ClampedMemory0 = null -function getUint8ClampedMemory0() { - if ( - cachegetUint8ClampedMemory0 === null || - cachegetUint8ClampedMemory0.buffer !== wasm.memory.buffer - ) { - cachegetUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer) - } - return cachegetUint8ClampedMemory0 -} - -function getClampedArrayU8FromWasm0(ptr, len) { - return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len) -} - -const heap = new Array(32).fill(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_add_to_stack_pointer(-16) - 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_add_to_stack_pointer(16) - } -} - -function getObject(idx) { - return heap[idx] -} - -function dropObject(idx) { - if (idx < 36) return - heap[idx] = heap_next - heap_next = idx -} - -function takeObject(idx) { - const ret = getObject(idx) - dropObject(idx) - return ret -} -/** - * @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') { - return await WebAssembly.instantiateStreaming(module, imports) - } - - const bytes = await module.arrayBuffer() - return await WebAssembly.instantiate(bytes, imports) - } else { - const instance = await WebAssembly.instantiate(module, imports) - - if (instance instanceof WebAssembly.Instance) { - return { instance, module } - } else { - return instance - } - } -} - -async function init(input) { - const imports = {} - imports.wbg = {} - imports.wbg.__wbg_newwithownedu8clampedarrayandsh_787b2db8ea6bfd62 = - function (arg0, arg1, arg2, arg3) { - 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/src/server/lib/squoosh/png/squoosh_png_bg.wasm b/packages/next/src/server/lib/squoosh/png/squoosh_png_bg.wasm deleted file mode 100644 index cc5cf3660e..0000000000 Binary files a/packages/next/src/server/lib/squoosh/png/squoosh_png_bg.wasm and /dev/null differ diff --git a/packages/next/src/server/lib/squoosh/resize/squoosh_resize.js b/packages/next/src/server/lib/squoosh/resize/squoosh_resize.js deleted file mode 100644 index 20510a245b..0000000000 --- a/packages/next/src/server/lib/squoosh/resize/squoosh_resize.js +++ /dev/null @@ -1,140 +0,0 @@ -let wasm - -let cachegetUint8Memory0 = null -function getUint8Memory0() { - if ( - cachegetUint8Memory0 === null || - cachegetUint8Memory0.buffer !== wasm.memory.buffer - ) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer) - } - return cachegetUint8Memory0 -} - -let WASM_VECTOR_LEN = 0 - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1) - getUint8Memory0().set(arg, ptr / 1) - WASM_VECTOR_LEN = arg.length - return ptr -} - -let cachegetInt32Memory0 = null -function getInt32Memory0() { - if ( - cachegetInt32Memory0 === null || - cachegetInt32Memory0.buffer !== wasm.memory.buffer - ) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer) - } - return cachegetInt32Memory0 -} - -let cachegetUint8ClampedMemory0 = null -function getUint8ClampedMemory0() { - if ( - cachegetUint8ClampedMemory0 === null || - cachegetUint8ClampedMemory0.buffer !== wasm.memory.buffer - ) { - cachegetUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer) - } - return cachegetUint8ClampedMemory0 -} - -function getClampedArrayU8FromWasm0(ptr, len) { - return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len) -} -/** - * @param {Uint8Array} input_image - * @param {number} input_width - * @param {number} input_height - * @param {number} output_width - * @param {number} output_height - * @param {number} typ_idx - * @param {boolean} premultiply - * @param {boolean} color_space_conversion - * @returns {Uint8ClampedArray} - */ -export function resize( - input_image, - input_width, - input_height, - output_width, - output_height, - typ_idx, - premultiply, - color_space_conversion -) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) - var ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc) - var len0 = WASM_VECTOR_LEN - wasm.resize( - retptr, - ptr0, - len0, - input_width, - input_height, - output_width, - output_height, - typ_idx, - premultiply, - color_space_conversion - ) - var r0 = getInt32Memory0()[retptr / 4 + 0] - var r1 = getInt32Memory0()[retptr / 4 + 1] - var v1 = getClampedArrayU8FromWasm0(r0, r1).slice() - wasm.__wbindgen_free(r0, r1 * 1) - return v1 - } finally { - wasm.__wbindgen_add_to_stack_pointer(16) - } -} - -async function load(module, imports) { - if (typeof Response === 'function' && module instanceof Response) { - if (typeof WebAssembly.instantiateStreaming === 'function') { - return await WebAssembly.instantiateStreaming(module, imports) - } - - const bytes = await module.arrayBuffer() - return await WebAssembly.instantiate(bytes, imports) - } else { - const instance = await WebAssembly.instantiate(module, imports) - - if (instance instanceof WebAssembly.Instance) { - return { instance, module } - } else { - return instance - } - } -} - -async function init(input) { - const imports = {} - - if ( - typeof input === 'string' || - (typeof Request === 'function' && input instanceof Request) || - (typeof URL === 'function' && input instanceof URL) - ) { - input = fetch(input) - } - - const { instance, module } = await load(await input, imports) - - wasm = instance.exports - init.__wbindgen_wasm_module = module - - return wasm -} - -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/src/server/lib/squoosh/resize/squoosh_resize_bg.wasm b/packages/next/src/server/lib/squoosh/resize/squoosh_resize_bg.wasm deleted file mode 100644 index b910c97b05..0000000000 Binary files a/packages/next/src/server/lib/squoosh/resize/squoosh_resize_bg.wasm and /dev/null differ diff --git a/packages/next/src/server/lib/squoosh/rotate/rotate.wasm b/packages/next/src/server/lib/squoosh/rotate/rotate.wasm deleted file mode 100755 index 8c7122c9f8..0000000000 Binary files a/packages/next/src/server/lib/squoosh/rotate/rotate.wasm and /dev/null differ diff --git a/packages/next/src/server/lib/squoosh/webp/webp_enc.d.ts b/packages/next/src/server/lib/squoosh/webp/webp_enc.d.ts deleted file mode 100644 index 3c45068299..0000000000 --- a/packages/next/src/server/lib/squoosh/webp/webp_enc.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -export interface EncodeOptions { - quality: number - target_size: number - target_PSNR: number - method: number - sns_strength: number - filter_strength: number - filter_sharpness: number - filter_type: number - partitions: number - segments: number - pass: number - show_compressed: number - preprocessing: number - autofilter: number - partition_limit: number - alpha_compression: number - alpha_filtering: number - alpha_quality: number - lossless: number - exact: number - image_hint: number - emulate_jpeg_size: number - thread_level: number - low_memory: number - near_lossless: number - use_delta_palette: number - use_sharp_yuv: number -} - -export interface WebPModule extends EmscriptenWasm.Module { - encode( - data: BufferSource, - width: number, - height: number, - options: EncodeOptions - ): Uint8Array -} - -declare var moduleFactory: EmscriptenWasm.ModuleFactory - -export default moduleFactory diff --git a/packages/next/src/server/lib/squoosh/webp/webp_node_dec.js b/packages/next/src/server/lib/squoosh/webp/webp_node_dec.js deleted file mode 100644 index 7cb4ed8af9..0000000000 --- a/packages/next/src/server/lib/squoosh/webp/webp_node_dec.js +++ /dev/null @@ -1,1609 +0,0 @@ -/* eslint-disable */ -var Module = (function () { - return function (Module) { - Module = Module || {} - - var Module = typeof Module !== 'undefined' ? Module : {} - var readyPromiseResolve, readyPromiseReject - Module['ready'] = new Promise(function (resolve, reject) { - readyPromiseResolve = resolve - readyPromiseReject = reject - }) - var moduleOverrides = {} - var key - for (key in Module) { - if (Module.hasOwnProperty(key)) { - moduleOverrides[key] = Module[key] - } - } - var arguments_ = [] - var thisProgram = './this.program' - var quit_ = function (status, toThrow) { - throw toThrow - } - var ENVIRONMENT_IS_WEB = false - var ENVIRONMENT_IS_WORKER = false - var ENVIRONMENT_IS_NODE = true - var scriptDirectory = '' - function locateFile(path) { - if (Module['locateFile']) { - return Module['locateFile'](path, scriptDirectory) - } - return scriptDirectory + path - } - var read_, readBinary - var nodeFS - var nodePath - if (ENVIRONMENT_IS_NODE) { - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = require('path').dirname(scriptDirectory) + '/' - } else { - scriptDirectory = __dirname + '/' - } - read_ = function shell_read(filename, binary) { - if (!nodeFS) nodeFS = require('fs') - if (!nodePath) nodePath = require('path') - filename = nodePath['normalize'](filename) - return nodeFS['readFileSync'](filename, binary ? null : 'utf8') - } - readBinary = function readBinary(filename) { - var ret = read_(filename, true) - if (!ret.buffer) { - ret = new Uint8Array(ret) - } - assert(ret.buffer) - return ret - } - if (process['argv'].length > 1) { - thisProgram = process['argv'][1].replace(/\\/g, '/') - } - arguments_ = process['argv'].slice(2) - quit_ = function (status) { - process['exit'](status) - } - Module['inspect'] = function () { - return '[Emscripten Module object]' - } - } else { - } - var out = Module['print'] || console.log.bind(console) - var err = Module['printErr'] || console.warn.bind(console) - for (key in moduleOverrides) { - if (moduleOverrides.hasOwnProperty(key)) { - Module[key] = moduleOverrides[key] - } - } - moduleOverrides = null - if (Module['arguments']) arguments_ = Module['arguments'] - if (Module['thisProgram']) thisProgram = Module['thisProgram'] - if (Module['quit']) quit_ = Module['quit'] - var wasmBinary - if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'] - var noExitRuntime = Module['noExitRuntime'] || true - if (typeof WebAssembly !== 'object') { - abort('no native wasm support detected') - } - var wasmMemory - var ABORT = false - var EXITSTATUS - function assert(condition, text) { - if (!condition) { - abort('Assertion failed: ' + text) - } - } - var UTF8Decoder = new TextDecoder('utf8') - function UTF8ToString(ptr, maxBytesToRead) { - if (!ptr) return '' - var maxPtr = ptr + maxBytesToRead - for (var end = ptr; !(end >= maxPtr) && HEAPU8[end]; ) ++end - return UTF8Decoder.decode(HEAPU8.subarray(ptr, end)) - } - function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { - if (!(maxBytesToWrite > 0)) return 0 - var startIdx = outIdx - var endIdx = outIdx + maxBytesToWrite - 1 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) { - var u1 = str.charCodeAt(++i) - u = (65536 + ((u & 1023) << 10)) | (u1 & 1023) - } - if (u <= 127) { - if (outIdx >= endIdx) break - heap[outIdx++] = u - } else if (u <= 2047) { - if (outIdx + 1 >= endIdx) break - heap[outIdx++] = 192 | (u >> 6) - heap[outIdx++] = 128 | (u & 63) - } else if (u <= 65535) { - if (outIdx + 2 >= endIdx) break - heap[outIdx++] = 224 | (u >> 12) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } else { - if (outIdx + 3 >= endIdx) break - heap[outIdx++] = 240 | (u >> 18) - heap[outIdx++] = 128 | ((u >> 12) & 63) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } - } - heap[outIdx] = 0 - return outIdx - startIdx - } - function stringToUTF8(str, outPtr, maxBytesToWrite) { - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite) - } - function lengthBytesUTF8(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) - u = (65536 + ((u & 1023) << 10)) | (str.charCodeAt(++i) & 1023) - if (u <= 127) ++len - else if (u <= 2047) len += 2 - else if (u <= 65535) len += 3 - else len += 4 - } - return len - } - var UTF16Decoder = new TextDecoder('utf-16le') - function UTF16ToString(ptr, maxBytesToRead) { - var endPtr = ptr - var idx = endPtr >> 1 - var maxIdx = idx + maxBytesToRead / 2 - while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx - endPtr = idx << 1 - return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)) - var str = '' - for (var i = 0; !(i >= maxBytesToRead / 2); ++i) { - var codeUnit = HEAP16[(ptr + i * 2) >> 1] - if (codeUnit == 0) break - str += String.fromCharCode(codeUnit) - } - return str - } - function stringToUTF16(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 2) return 0 - maxBytesToWrite -= 2 - var startPtr = outPtr - var numCharsToWrite = - maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length - for (var i = 0; i < numCharsToWrite; ++i) { - var codeUnit = str.charCodeAt(i) - HEAP16[outPtr >> 1] = codeUnit - outPtr += 2 - } - HEAP16[outPtr >> 1] = 0 - return outPtr - startPtr - } - function lengthBytesUTF16(str) { - return str.length * 2 - } - function UTF32ToString(ptr, maxBytesToRead) { - var i = 0 - var str = '' - while (!(i >= maxBytesToRead / 4)) { - var utf32 = HEAP32[(ptr + i * 4) >> 2] - if (utf32 == 0) break - ++i - if (utf32 >= 65536) { - var ch = utf32 - 65536 - str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023)) - } else { - str += String.fromCharCode(utf32) - } - } - return str - } - function stringToUTF32(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 4) return 0 - var startPtr = outPtr - var endPtr = startPtr + maxBytesToWrite - 4 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) { - var trailSurrogate = str.charCodeAt(++i) - codeUnit = - (65536 + ((codeUnit & 1023) << 10)) | (trailSurrogate & 1023) - } - HEAP32[outPtr >> 2] = codeUnit - outPtr += 4 - if (outPtr + 4 > endPtr) break - } - HEAP32[outPtr >> 2] = 0 - return outPtr - startPtr - } - function lengthBytesUTF32(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) ++i - len += 4 - } - return len - } - function alignUp(x, multiple) { - if (x % multiple > 0) { - x += multiple - (x % multiple) - } - return x - } - var buffer, - HEAP8, - HEAPU8, - HEAP16, - HEAPU16, - HEAP32, - HEAPU32, - HEAPF32, - HEAPF64 - function updateGlobalBufferAndViews(buf) { - buffer = buf - Module['HEAP8'] = HEAP8 = new Int8Array(buf) - Module['HEAP16'] = HEAP16 = new Int16Array(buf) - Module['HEAP32'] = HEAP32 = new Int32Array(buf) - Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf) - Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf) - Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf) - Module['HEAPF32'] = HEAPF32 = new Float32Array(buf) - Module['HEAPF64'] = HEAPF64 = new Float64Array(buf) - } - var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216 - var wasmTable - var __ATPRERUN__ = [] - var __ATINIT__ = [] - var __ATPOSTRUN__ = [] - var runtimeInitialized = false - function preRun() { - if (Module['preRun']) { - if (typeof Module['preRun'] == 'function') - Module['preRun'] = [Module['preRun']] - while (Module['preRun'].length) { - addOnPreRun(Module['preRun'].shift()) - } - } - callRuntimeCallbacks(__ATPRERUN__) - } - function initRuntime() { - runtimeInitialized = true - callRuntimeCallbacks(__ATINIT__) - } - function postRun() { - if (Module['postRun']) { - if (typeof Module['postRun'] == 'function') - Module['postRun'] = [Module['postRun']] - while (Module['postRun'].length) { - addOnPostRun(Module['postRun'].shift()) - } - } - callRuntimeCallbacks(__ATPOSTRUN__) - } - function addOnPreRun(cb) { - __ATPRERUN__.unshift(cb) - } - function addOnInit(cb) { - __ATINIT__.unshift(cb) - } - function addOnPostRun(cb) { - __ATPOSTRUN__.unshift(cb) - } - var runDependencies = 0 - var runDependencyWatcher = null - var dependenciesFulfilled = null - function addRunDependency(id) { - runDependencies++ - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - } - function removeRunDependency(id) { - runDependencies-- - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - if (runDependencies == 0) { - if (runDependencyWatcher !== null) { - clearInterval(runDependencyWatcher) - runDependencyWatcher = null - } - if (dependenciesFulfilled) { - var callback = dependenciesFulfilled - dependenciesFulfilled = null - callback() - } - } - } - Module['preloadedImages'] = {} - Module['preloadedAudios'] = {} - function abort(what) { - if (Module['onAbort']) { - Module['onAbort'](what) - } - what += '' - err(what) - ABORT = true - EXITSTATUS = 1 - what = 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.' - var e = new WebAssembly.RuntimeError(what) - readyPromiseReject(e) - throw e - } - var dataURIPrefix = 'data:application/octet-stream;base64,' - function isDataURI(filename) { - return filename.startsWith(dataURIPrefix) - } - if (Module['locateFile']) { - var wasmBinaryFile = 'webp_node_dec.wasm' - if (!isDataURI(wasmBinaryFile)) { - wasmBinaryFile = locateFile(wasmBinaryFile) - } - } else { - throw new Error('invariant') - } - function getBinary(file) { - try { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary) - } - if (readBinary) { - return readBinary(file) - } else { - throw 'both async and sync fetching of the wasm failed' - } - } catch (err) { - abort(err) - } - } - function getBinaryPromise() { - return Promise.resolve().then(function () { - return getBinary(wasmBinaryFile) - }) - } - function createWasm() { - var info = { a: asmLibraryArg } - function receiveInstance(instance, module) { - var exports = instance.exports - Module['asm'] = exports - wasmMemory = Module['asm']['s'] - updateGlobalBufferAndViews(wasmMemory.buffer) - wasmTable = Module['asm']['y'] - addOnInit(Module['asm']['t']) - removeRunDependency('wasm-instantiate') - } - addRunDependency('wasm-instantiate') - function receiveInstantiationResult(result) { - receiveInstance(result['instance']) - } - function instantiateArrayBuffer(receiver) { - return getBinaryPromise() - .then(function (binary) { - var result = WebAssembly.instantiate(binary, info) - return result - }) - .then(receiver, function (reason) { - err('failed to asynchronously prepare wasm: ' + reason) - abort(reason) - }) - } - function instantiateAsync() { - return instantiateArrayBuffer(receiveInstantiationResult) - } - if (Module['instantiateWasm']) { - try { - var exports = Module['instantiateWasm'](info, receiveInstance) - return exports - } catch (e) { - err('Module.instantiateWasm callback failed with error: ' + e) - return false - } - } - instantiateAsync().catch(readyPromiseReject) - return {} - } - function callRuntimeCallbacks(callbacks) { - while (callbacks.length > 0) { - var callback = callbacks.shift() - if (typeof callback == 'function') { - callback(Module) - continue - } - var func = callback.func - if (typeof func === 'number') { - if (callback.arg === undefined) { - wasmTable.get(func)() - } else { - wasmTable.get(func)(callback.arg) - } - } else { - func(callback.arg === undefined ? null : callback.arg) - } - } - } - function _atexit(func, arg) {} - function ___cxa_thread_atexit(a0, a1) { - return _atexit(a0, a1) - } - function __embind_register_bigint( - primitiveType, - name, - size, - minRange, - maxRange - ) {} - function getShiftFromSize(size) { - switch (size) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + size) - } - } - function embind_init_charCodes() { - var codes = new Array(256) - for (var i = 0; i < 256; ++i) { - codes[i] = String.fromCharCode(i) - } - embind_charCodes = codes - } - var embind_charCodes = undefined - function readLatin1String(ptr) { - var ret = '' - var c = ptr - while (HEAPU8[c]) { - ret += embind_charCodes[HEAPU8[c++]] - } - return ret - } - var awaitingDependencies = {} - var registeredTypes = {} - var typeDependencies = {} - var char_0 = 48 - var char_9 = 57 - function makeLegalFunctionName(name) { - if (undefined === name) { - return '_unknown' - } - name = name.replace(/[^a-zA-Z0-9_]/g, '$') - var f = name.charCodeAt(0) - if (f >= char_0 && f <= char_9) { - return '_' + name - } else { - return name - } - } - function createNamedFunction(name, body) { - name = makeLegalFunctionName(name) - return new Function( - 'body', - 'return function ' + - name + - '() {\n' + - ' "use strict";' + - ' return body.apply(this, arguments);\n' + - '};\n' - )(body) - } - function extendError(baseErrorType, errorName) { - var errorClass = createNamedFunction(errorName, function (message) { - this.name = errorName - this.message = message - var stack = new Error(message).stack - if (stack !== undefined) { - this.stack = - this.toString() + '\n' + stack.replace(/^Error(:[^\n]*)?\n/, '') - } - }) - errorClass.prototype = Object.create(baseErrorType.prototype) - errorClass.prototype.constructor = errorClass - errorClass.prototype.toString = function () { - if (this.message === undefined) { - return this.name - } else { - return this.name + ': ' + this.message - } - } - return errorClass - } - var BindingError = undefined - function throwBindingError(message) { - throw new BindingError(message) - } - var InternalError = undefined - function throwInternalError(message) { - throw new InternalError(message) - } - function whenDependentTypesAreResolved( - myTypes, - dependentTypes, - getTypeConverters - ) { - myTypes.forEach(function (type) { - typeDependencies[type] = dependentTypes - }) - function onComplete(typeConverters) { - var myTypeConverters = getTypeConverters(typeConverters) - if (myTypeConverters.length !== myTypes.length) { - throwInternalError('Mismatched type converter count') - } - for (var i = 0; i < myTypes.length; ++i) { - registerType(myTypes[i], myTypeConverters[i]) - } - } - var typeConverters = new Array(dependentTypes.length) - var unregisteredTypes = [] - var registered = 0 - dependentTypes.forEach(function (dt, i) { - if (registeredTypes.hasOwnProperty(dt)) { - typeConverters[i] = registeredTypes[dt] - } else { - unregisteredTypes.push(dt) - if (!awaitingDependencies.hasOwnProperty(dt)) { - awaitingDependencies[dt] = [] - } - awaitingDependencies[dt].push(function () { - typeConverters[i] = registeredTypes[dt] - ++registered - if (registered === unregisteredTypes.length) { - onComplete(typeConverters) - } - }) - } - }) - if (0 === unregisteredTypes.length) { - onComplete(typeConverters) - } - } - function registerType(rawType, registeredInstance, options) { - options = options || {} - if (!('argPackAdvance' in registeredInstance)) { - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - } - var name = registeredInstance.name - if (!rawType) { - throwBindingError( - 'type "' + name + '" must have a positive integer typeid pointer' - ) - } - if (registeredTypes.hasOwnProperty(rawType)) { - if (options.ignoreDuplicateRegistrations) { - return - } else { - throwBindingError("Cannot register type '" + name + "' twice") - } - } - registeredTypes[rawType] = registeredInstance - delete typeDependencies[rawType] - if (awaitingDependencies.hasOwnProperty(rawType)) { - var callbacks = awaitingDependencies[rawType] - delete awaitingDependencies[rawType] - callbacks.forEach(function (cb) { - cb() - }) - } - } - function __embind_register_bool( - rawType, - name, - size, - trueValue, - falseValue - ) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (wt) { - return !!wt - }, - toWireType: function (destructors, o) { - return o ? trueValue : falseValue - }, - argPackAdvance: 8, - readValueFromPointer: function (pointer) { - var heap - if (size === 1) { - heap = HEAP8 - } else if (size === 2) { - heap = HEAP16 - } else if (size === 4) { - heap = HEAP32 - } else { - throw new TypeError('Unknown boolean type size: ' + name) - } - return this['fromWireType'](heap[pointer >> shift]) - }, - destructorFunction: null, - }) - } - var emval_free_list = [] - var emval_handle_array = [ - {}, - { value: undefined }, - { value: null }, - { value: true }, - { value: false }, - ] - function __emval_decref(handle) { - if (handle > 4 && 0 === --emval_handle_array[handle].refcount) { - emval_handle_array[handle] = undefined - emval_free_list.push(handle) - } - } - function count_emval_handles() { - var count = 0 - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - ++count - } - } - return count - } - function get_first_emval() { - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - return emval_handle_array[i] - } - } - return null - } - function init_emval() { - Module['count_emval_handles'] = count_emval_handles - Module['get_first_emval'] = get_first_emval - } - function __emval_register(value) { - switch (value) { - case undefined: { - return 1 - } - case null: { - return 2 - } - case true: { - return 3 - } - case false: { - return 4 - } - default: { - var handle = emval_free_list.length - ? emval_free_list.pop() - : emval_handle_array.length - emval_handle_array[handle] = { refcount: 1, value: value } - return handle - } - } - } - function simpleReadValueFromPointer(pointer) { - return this['fromWireType'](HEAPU32[pointer >> 2]) - } - function __embind_register_emval(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (handle) { - var rv = emval_handle_array[handle].value - __emval_decref(handle) - return rv - }, - toWireType: function (destructors, value) { - return __emval_register(value) - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: null, - }) - } - function _embind_repr(v) { - if (v === null) { - return 'null' - } - var t = typeof v - if (t === 'object' || t === 'array' || t === 'function') { - return v.toString() - } else { - return '' + v - } - } - function floatReadValueFromPointer(name, shift) { - switch (shift) { - case 2: - return function (pointer) { - return this['fromWireType'](HEAPF32[pointer >> 2]) - } - case 3: - return function (pointer) { - return this['fromWireType'](HEAPF64[pointer >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + name) - } - } - function __embind_register_float(rawType, name, size) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (value) { - return value - }, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - return value - }, - argPackAdvance: 8, - readValueFromPointer: floatReadValueFromPointer(name, shift), - destructorFunction: null, - }) - } - function new_(constructor, argumentList) { - if (!(constructor instanceof Function)) { - throw new TypeError( - 'new_ called with constructor type ' + - typeof constructor + - ' which is not a function' - ) - } - var dummy = createNamedFunction( - constructor.name || 'unknownFunctionName', - function () {} - ) - dummy.prototype = constructor.prototype - var obj = new dummy() - var r = constructor.apply(obj, argumentList) - return r instanceof Object ? r : obj - } - function runDestructors(destructors) { - while (destructors.length) { - var ptr = destructors.pop() - var del = destructors.pop() - del(ptr) - } - } - function craftInvokerFunction( - humanName, - argTypes, - classType, - cppInvokerFunc, - cppTargetFunc - ) { - var argCount = argTypes.length - if (argCount < 2) { - throwBindingError( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - } - var isClassMethodFunc = argTypes[1] !== null && classType !== null - var needsDestructorStack = false - for (var i = 1; i < argTypes.length; ++i) { - if ( - argTypes[i] !== null && - argTypes[i].destructorFunction === undefined - ) { - needsDestructorStack = true - break - } - } - var returns = argTypes[0].name !== 'void' - var argsList = '' - var argsListWired = '' - for (var i = 0; i < argCount - 2; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - argsListWired += (i !== 0 ? ', ' : '') + 'arg' + i + 'Wired' - } - var invokerFnBody = - 'return function ' + - makeLegalFunctionName(humanName) + - '(' + - argsList + - ') {\n' + - 'if (arguments.length !== ' + - (argCount - 2) + - ') {\n' + - "throwBindingError('function " + - humanName + - " called with ' + arguments.length + ' arguments, expected " + - (argCount - 2) + - " args!');\n" + - '}\n' - if (needsDestructorStack) { - invokerFnBody += 'var destructors = [];\n' - } - var dtorStack = needsDestructorStack ? 'destructors' : 'null' - var args1 = [ - 'throwBindingError', - 'invoker', - 'fn', - 'runDestructors', - 'retType', - 'classParam', - ] - var args2 = [ - throwBindingError, - cppInvokerFunc, - cppTargetFunc, - runDestructors, - argTypes[0], - argTypes[1], - ] - if (isClassMethodFunc) { - invokerFnBody += - 'var thisWired = classParam.toWireType(' + dtorStack + ', this);\n' - } - for (var i = 0; i < argCount - 2; ++i) { - invokerFnBody += - 'var arg' + - i + - 'Wired = argType' + - i + - '.toWireType(' + - dtorStack + - ', arg' + - i + - '); // ' + - argTypes[i + 2].name + - '\n' - args1.push('argType' + i) - args2.push(argTypes[i + 2]) - } - if (isClassMethodFunc) { - argsListWired = - 'thisWired' + (argsListWired.length > 0 ? ', ' : '') + argsListWired - } - invokerFnBody += - (returns ? 'var rv = ' : '') + - 'invoker(fn' + - (argsListWired.length > 0 ? ', ' : '') + - argsListWired + - ');\n' - if (needsDestructorStack) { - invokerFnBody += 'runDestructors(destructors);\n' - } else { - for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { - var paramName = i === 1 ? 'thisWired' : 'arg' + (i - 2) + 'Wired' - if (argTypes[i].destructorFunction !== null) { - invokerFnBody += - paramName + - '_dtor(' + - paramName + - '); // ' + - argTypes[i].name + - '\n' - args1.push(paramName + '_dtor') - args2.push(argTypes[i].destructorFunction) - } - } - } - if (returns) { - invokerFnBody += - 'var ret = retType.fromWireType(rv);\n' + 'return ret;\n' - } else { - } - invokerFnBody += '}\n' - args1.push(invokerFnBody) - var invokerFunction = new_(Function, args1).apply(null, args2) - return invokerFunction - } - function ensureOverloadTable(proto, methodName, humanName) { - if (undefined === proto[methodName].overloadTable) { - var prevFunc = proto[methodName] - proto[methodName] = function () { - if ( - !proto[methodName].overloadTable.hasOwnProperty(arguments.length) - ) { - throwBindingError( - "Function '" + - humanName + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - proto[methodName].overloadTable + - ')!' - ) - } - return proto[methodName].overloadTable[arguments.length].apply( - this, - arguments - ) - } - proto[methodName].overloadTable = [] - proto[methodName].overloadTable[prevFunc.argCount] = prevFunc - } - } - function exposePublicSymbol(name, value, numArguments) { - if (Module.hasOwnProperty(name)) { - if ( - undefined === numArguments || - (undefined !== Module[name].overloadTable && - undefined !== Module[name].overloadTable[numArguments]) - ) { - throwBindingError("Cannot register public name '" + name + "' twice") - } - ensureOverloadTable(Module, name, name) - if (Module.hasOwnProperty(numArguments)) { - throwBindingError( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - numArguments + - ')!' - ) - } - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - if (undefined !== numArguments) { - Module[name].numArguments = numArguments - } - } - } - function heap32VectorToArray(count, firstElement) { - var array = [] - for (var i = 0; i < count; i++) { - array.push(HEAP32[(firstElement >> 2) + i]) - } - return array - } - function replacePublicSymbol(name, value, numArguments) { - if (!Module.hasOwnProperty(name)) { - throwInternalError('Replacing nonexistent public symbol') - } - if ( - undefined !== Module[name].overloadTable && - undefined !== numArguments - ) { - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - Module[name].argCount = numArguments - } - } - function dynCallLegacy(sig, ptr, args) { - var f = Module['dynCall_' + sig] - return args && args.length - ? f.apply(null, [ptr].concat(args)) - : f.call(null, ptr) - } - function dynCall(sig, ptr, args) { - if (sig.includes('j')) { - return dynCallLegacy(sig, ptr, args) - } - return wasmTable.get(ptr).apply(null, args) - } - function getDynCaller(sig, ptr) { - var argCache = [] - return function () { - argCache.length = arguments.length - for (var i = 0; i < arguments.length; i++) { - argCache[i] = arguments[i] - } - return dynCall(sig, ptr, argCache) - } - } - function embind__requireFunction(signature, rawFunction) { - signature = readLatin1String(signature) - function makeDynCaller() { - if (signature.includes('j')) { - return getDynCaller(signature, rawFunction) - } - return wasmTable.get(rawFunction) - } - var fp = makeDynCaller() - if (typeof fp !== 'function') { - throwBindingError( - 'unknown function pointer with signature ' + - signature + - ': ' + - rawFunction - ) - } - return fp - } - var UnboundTypeError = undefined - function getTypeName(type) { - var ptr = ___getTypeName(type) - var rv = readLatin1String(ptr) - _free(ptr) - return rv - } - function throwUnboundTypeError(message, types) { - var unboundTypes = [] - var seen = {} - function visit(type) { - if (seen[type]) { - return - } - if (registeredTypes[type]) { - return - } - if (typeDependencies[type]) { - typeDependencies[type].forEach(visit) - return - } - unboundTypes.push(type) - seen[type] = true - } - types.forEach(visit) - throw new UnboundTypeError( - message + ': ' + unboundTypes.map(getTypeName).join([', ']) - ) - } - function __embind_register_function( - name, - argCount, - rawArgTypesAddr, - signature, - rawInvoker, - fn - ) { - var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr) - name = readLatin1String(name) - rawInvoker = embind__requireFunction(signature, rawInvoker) - exposePublicSymbol( - name, - function () { - throwUnboundTypeError( - 'Cannot call ' + name + ' due to unbound types', - argTypes - ) - }, - argCount - 1 - ) - whenDependentTypesAreResolved([], argTypes, function (argTypes) { - var invokerArgsArray = [argTypes[0], null].concat(argTypes.slice(1)) - replacePublicSymbol( - name, - craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn), - argCount - 1 - ) - return [] - }) - } - function integerReadValueFromPointer(name, shift, signed) { - switch (shift) { - case 0: - return signed - ? function readS8FromPointer(pointer) { - return HEAP8[pointer] - } - : function readU8FromPointer(pointer) { - return HEAPU8[pointer] - } - case 1: - return signed - ? function readS16FromPointer(pointer) { - return HEAP16[pointer >> 1] - } - : function readU16FromPointer(pointer) { - return HEAPU16[pointer >> 1] - } - case 2: - return signed - ? function readS32FromPointer(pointer) { - return HEAP32[pointer >> 2] - } - : function readU32FromPointer(pointer) { - return HEAPU32[pointer >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + name) - } - } - function __embind_register_integer( - primitiveType, - name, - size, - minRange, - maxRange - ) { - name = readLatin1String(name) - if (maxRange === -1) { - maxRange = 4294967295 - } - var shift = getShiftFromSize(size) - var fromWireType = function (value) { - return value - } - if (minRange === 0) { - var bitshift = 32 - 8 * size - fromWireType = function (value) { - return (value << bitshift) >>> bitshift - } - } - var isUnsignedType = name.includes('unsigned') - registerType(primitiveType, { - name: name, - fromWireType: fromWireType, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - if (value < minRange || value > maxRange) { - throw new TypeError( - 'Passing a number "' + - _embind_repr(value) + - '" from JS side to C/C++ side to an argument of type "' + - name + - '", which is outside the valid range [' + - minRange + - ', ' + - maxRange + - ']!' - ) - } - return isUnsignedType ? value >>> 0 : value | 0 - }, - argPackAdvance: 8, - readValueFromPointer: integerReadValueFromPointer( - name, - shift, - minRange !== 0 - ), - destructorFunction: null, - }) - } - function __embind_register_memory_view(rawType, dataTypeIndex, name) { - var typeMapping = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ] - var TA = typeMapping[dataTypeIndex] - function decodeMemoryView(handle) { - handle = handle >> 2 - var heap = HEAPU32 - var size = heap[handle] - var data = heap[handle + 1] - return new TA(buffer, data, size) - } - name = readLatin1String(name) - registerType( - rawType, - { - name: name, - fromWireType: decodeMemoryView, - argPackAdvance: 8, - readValueFromPointer: decodeMemoryView, - }, - { ignoreDuplicateRegistrations: true } - ) - } - function __embind_register_std_string(rawType, name) { - name = readLatin1String(name) - var stdStringIsUTF8 = name === 'std::string' - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var str - if (stdStringIsUTF8) { - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i - if (i == length || HEAPU8[currentBytePtr] == 0) { - var maxRead = currentBytePtr - decodeStartPtr - var stringSegment = UTF8ToString(decodeStartPtr, maxRead) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + 1 - } - } - } else { - var a = new Array(length) - for (var i = 0; i < length; ++i) { - a[i] = String.fromCharCode(HEAPU8[value + 4 + i]) - } - str = a.join('') - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (value instanceof ArrayBuffer) { - value = new Uint8Array(value) - } - var getLength - var valueIsOfTypeString = typeof value === 'string' - if ( - !( - valueIsOfTypeString || - value instanceof Uint8Array || - value instanceof Uint8ClampedArray || - value instanceof Int8Array - ) - ) { - throwBindingError('Cannot pass non-string to std::string') - } - if (stdStringIsUTF8 && valueIsOfTypeString) { - getLength = function () { - return lengthBytesUTF8(value) - } - } else { - getLength = function () { - return value.length - } - } - var length = getLength() - var ptr = _malloc(4 + length + 1) - HEAPU32[ptr >> 2] = length - if (stdStringIsUTF8 && valueIsOfTypeString) { - stringToUTF8(value, ptr + 4, length + 1) - } else { - if (valueIsOfTypeString) { - for (var i = 0; i < length; ++i) { - var charCode = value.charCodeAt(i) - if (charCode > 255) { - _free(ptr) - throwBindingError( - 'String has UTF-16 code units that do not fit in 8 bits' - ) - } - HEAPU8[ptr + 4 + i] = charCode - } - } else { - for (var i = 0; i < length; ++i) { - HEAPU8[ptr + 4 + i] = value[i] - } - } - } - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_std_wstring(rawType, charSize, name) { - name = readLatin1String(name) - var decodeString, encodeString, getHeap, lengthBytesUTF, shift - if (charSize === 2) { - decodeString = UTF16ToString - encodeString = stringToUTF16 - lengthBytesUTF = lengthBytesUTF16 - getHeap = function () { - return HEAPU16 - } - shift = 1 - } else if (charSize === 4) { - decodeString = UTF32ToString - encodeString = stringToUTF32 - lengthBytesUTF = lengthBytesUTF32 - getHeap = function () { - return HEAPU32 - } - shift = 2 - } - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var HEAP = getHeap() - var str - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i * charSize - if (i == length || HEAP[currentBytePtr >> shift] == 0) { - var maxReadBytes = currentBytePtr - decodeStartPtr - var stringSegment = decodeString(decodeStartPtr, maxReadBytes) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + charSize - } - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (!(typeof value === 'string')) { - throwBindingError( - 'Cannot pass non-string to C++ string type ' + name - ) - } - var length = lengthBytesUTF(value) - var ptr = _malloc(4 + length + charSize) - HEAPU32[ptr >> 2] = length >> shift - encodeString(value, ptr + 4, length + charSize) - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_void(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - isVoid: true, - name: name, - argPackAdvance: 0, - fromWireType: function () { - return undefined - }, - toWireType: function (destructors, o) { - return undefined - }, - }) - } - var emval_symbols = {} - function getStringOrSymbol(address) { - var symbol = emval_symbols[address] - if (symbol === undefined) { - return readLatin1String(address) - } else { - return symbol - } - } - function emval_get_global() { - if (typeof globalThis === 'object') { - return globalThis - } - return (function () { - return Function - })()('return this')() - } - function __emval_get_global(name) { - if (name === 0) { - return __emval_register(emval_get_global()) - } else { - name = getStringOrSymbol(name) - return __emval_register(emval_get_global()[name]) - } - } - function __emval_incref(handle) { - if (handle > 4) { - emval_handle_array[handle].refcount += 1 - } - } - function requireRegisteredType(rawType, humanName) { - var impl = registeredTypes[rawType] - if (undefined === impl) { - throwBindingError( - humanName + ' has unknown type ' + getTypeName(rawType) - ) - } - return impl - } - function craftEmvalAllocator(argCount) { - var argsList = '' - for (var i = 0; i < argCount; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - } - var functionBody = - 'return function emval_allocator_' + - argCount + - '(constructor, argTypes, args) {\n' - for (var i = 0; i < argCount; ++i) { - functionBody += - 'var argType' + - i + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - i + - '], "parameter ' + - i + - '");\n' + - 'var arg' + - i + - ' = argType' + - i + - '.readValueFromPointer(args);\n' + - 'args += argType' + - i + - "['argPackAdvance'];\n" - } - functionBody += - 'var obj = new constructor(' + - argsList + - ');\n' + - 'return __emval_register(obj);\n' + - '}\n' - return new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - functionBody - )(requireRegisteredType, Module, __emval_register) - } - var emval_newers = {} - function requireHandle(handle) { - if (!handle) { - throwBindingError('Cannot use deleted val. handle = ' + handle) - } - return emval_handle_array[handle].value - } - function __emval_new(handle, argCount, argTypes, args) { - handle = requireHandle(handle) - var newer = emval_newers[argCount] - if (!newer) { - newer = craftEmvalAllocator(argCount) - emval_newers[argCount] = newer - } - return newer(handle, argTypes, args) - } - function _abort() { - abort() - } - function _emscripten_memcpy_big(dest, src, num) { - HEAPU8.copyWithin(dest, src, src + num) - } - function emscripten_realloc_buffer(size) { - try { - wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16) - updateGlobalBufferAndViews(wasmMemory.buffer) - return 1 - } catch (e) {} - } - function _emscripten_resize_heap(requestedSize) { - var oldSize = HEAPU8.length - requestedSize = requestedSize >>> 0 - var maxHeapSize = 2147483648 - if (requestedSize > maxHeapSize) { - return false - } - for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { - var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown) - overGrownHeapSize = Math.min( - overGrownHeapSize, - requestedSize + 100663296 - ) - var newSize = Math.min( - maxHeapSize, - alignUp(Math.max(requestedSize, overGrownHeapSize), 65536) - ) - var replacement = emscripten_realloc_buffer(newSize) - if (replacement) { - return true - } - } - return false - } - embind_init_charCodes() - BindingError = Module['BindingError'] = extendError(Error, 'BindingError') - InternalError = Module['InternalError'] = extendError( - Error, - 'InternalError' - ) - init_emval() - UnboundTypeError = Module['UnboundTypeError'] = extendError( - Error, - 'UnboundTypeError' - ) - var asmLibraryArg = { - e: ___cxa_thread_atexit, - p: __embind_register_bigint, - n: __embind_register_bool, - r: __embind_register_emval, - m: __embind_register_float, - i: __embind_register_function, - b: __embind_register_integer, - a: __embind_register_memory_view, - h: __embind_register_std_string, - f: __embind_register_std_wstring, - o: __embind_register_void, - c: __emval_decref, - d: __emval_get_global, - j: __emval_incref, - k: __emval_new, - l: _abort, - q: _emscripten_memcpy_big, - g: _emscripten_resize_heap, - } - var asm = createWasm() - var ___wasm_call_ctors = (Module['___wasm_call_ctors'] = function () { - return (___wasm_call_ctors = Module['___wasm_call_ctors'] = - Module['asm']['t']).apply(null, arguments) - }) - var _malloc = (Module['_malloc'] = function () { - return (_malloc = Module['_malloc'] = Module['asm']['u']).apply( - null, - arguments - ) - }) - var _free = (Module['_free'] = function () { - return (_free = Module['_free'] = Module['asm']['v']).apply( - null, - arguments - ) - }) - var ___getTypeName = (Module['___getTypeName'] = function () { - return (___getTypeName = Module['___getTypeName'] = - Module['asm']['w']).apply(null, arguments) - }) - var ___embind_register_native_and_builtin_types = (Module[ - '___embind_register_native_and_builtin_types' - ] = function () { - return (___embind_register_native_and_builtin_types = Module[ - '___embind_register_native_and_builtin_types' - ] = - Module['asm']['x']).apply(null, arguments) - }) - var calledRun - dependenciesFulfilled = function runCaller() { - if (!calledRun) run() - if (!calledRun) dependenciesFulfilled = runCaller - } - function run(args) { - args = args || arguments_ - if (runDependencies > 0) { - return - } - preRun() - if (runDependencies > 0) { - return - } - function doRun() { - if (calledRun) return - calledRun = true - Module['calledRun'] = true - if (ABORT) return - initRuntime() - readyPromiseResolve(Module) - if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']() - postRun() - } - if (Module['setStatus']) { - Module['setStatus']('Running...') - setTimeout(function () { - setTimeout(function () { - Module['setStatus']('') - }, 1) - doRun() - }, 1) - } else { - doRun() - } - } - Module['run'] = run - if (Module['preInit']) { - if (typeof Module['preInit'] == 'function') - Module['preInit'] = [Module['preInit']] - while (Module['preInit'].length > 0) { - Module['preInit'].pop()() - } - } - run() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/src/server/lib/squoosh/webp/webp_node_dec.wasm b/packages/next/src/server/lib/squoosh/webp/webp_node_dec.wasm deleted file mode 100755 index 5df324336c..0000000000 Binary files a/packages/next/src/server/lib/squoosh/webp/webp_node_dec.wasm and /dev/null differ diff --git a/packages/next/src/server/lib/squoosh/webp/webp_node_enc.js b/packages/next/src/server/lib/squoosh/webp/webp_node_enc.js deleted file mode 100644 index eacaf1b727..0000000000 --- a/packages/next/src/server/lib/squoosh/webp/webp_node_enc.js +++ /dev/null @@ -1,1794 +0,0 @@ -/* eslint-disable */ -var Module = (function () { - return function (Module) { - Module = Module || {} - - var Module = typeof Module !== 'undefined' ? Module : {} - var readyPromiseResolve, readyPromiseReject - Module['ready'] = new Promise(function (resolve, reject) { - readyPromiseResolve = resolve - readyPromiseReject = reject - }) - var moduleOverrides = {} - var key - for (key in Module) { - if (Module.hasOwnProperty(key)) { - moduleOverrides[key] = Module[key] - } - } - var arguments_ = [] - var thisProgram = './this.program' - var quit_ = function (status, toThrow) { - throw toThrow - } - var ENVIRONMENT_IS_WEB = false - var ENVIRONMENT_IS_WORKER = false - var ENVIRONMENT_IS_NODE = true - var scriptDirectory = '' - function locateFile(path) { - if (Module['locateFile']) { - return Module['locateFile'](path, scriptDirectory) - } - return scriptDirectory + path - } - var read_, readBinary - var nodeFS - var nodePath - if (ENVIRONMENT_IS_NODE) { - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = require('path').dirname(scriptDirectory) + '/' - } else { - scriptDirectory = __dirname + '/' - } - read_ = function shell_read(filename, binary) { - if (!nodeFS) nodeFS = require('fs') - if (!nodePath) nodePath = require('path') - filename = nodePath['normalize'](filename) - return nodeFS['readFileSync'](filename, binary ? null : 'utf8') - } - readBinary = function readBinary(filename) { - var ret = read_(filename, true) - if (!ret.buffer) { - ret = new Uint8Array(ret) - } - assert(ret.buffer) - return ret - } - if (process['argv'].length > 1) { - thisProgram = process['argv'][1].replace(/\\/g, '/') - } - arguments_ = process['argv'].slice(2) - quit_ = function (status) { - process['exit'](status) - } - Module['inspect'] = function () { - return '[Emscripten Module object]' - } - } else { - } - var out = Module['print'] || console.log.bind(console) - var err = Module['printErr'] || console.warn.bind(console) - for (key in moduleOverrides) { - if (moduleOverrides.hasOwnProperty(key)) { - Module[key] = moduleOverrides[key] - } - } - moduleOverrides = null - if (Module['arguments']) arguments_ = Module['arguments'] - if (Module['thisProgram']) thisProgram = Module['thisProgram'] - if (Module['quit']) quit_ = Module['quit'] - var wasmBinary - if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'] - var noExitRuntime = Module['noExitRuntime'] || true - if (typeof WebAssembly !== 'object') { - abort('no native wasm support detected') - } - var wasmMemory - var ABORT = false - var EXITSTATUS - function assert(condition, text) { - if (!condition) { - abort('Assertion failed: ' + text) - } - } - var UTF8Decoder = new TextDecoder('utf8') - function UTF8ToString(ptr, maxBytesToRead) { - if (!ptr) return '' - var maxPtr = ptr + maxBytesToRead - for (var end = ptr; !(end >= maxPtr) && HEAPU8[end]; ) ++end - return UTF8Decoder.decode(HEAPU8.subarray(ptr, end)) - } - function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { - if (!(maxBytesToWrite > 0)) return 0 - var startIdx = outIdx - var endIdx = outIdx + maxBytesToWrite - 1 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) { - var u1 = str.charCodeAt(++i) - u = (65536 + ((u & 1023) << 10)) | (u1 & 1023) - } - if (u <= 127) { - if (outIdx >= endIdx) break - heap[outIdx++] = u - } else if (u <= 2047) { - if (outIdx + 1 >= endIdx) break - heap[outIdx++] = 192 | (u >> 6) - heap[outIdx++] = 128 | (u & 63) - } else if (u <= 65535) { - if (outIdx + 2 >= endIdx) break - heap[outIdx++] = 224 | (u >> 12) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } else { - if (outIdx + 3 >= endIdx) break - heap[outIdx++] = 240 | (u >> 18) - heap[outIdx++] = 128 | ((u >> 12) & 63) - heap[outIdx++] = 128 | ((u >> 6) & 63) - heap[outIdx++] = 128 | (u & 63) - } - } - heap[outIdx] = 0 - return outIdx - startIdx - } - function stringToUTF8(str, outPtr, maxBytesToWrite) { - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite) - } - function lengthBytesUTF8(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i) - if (u >= 55296 && u <= 57343) - u = (65536 + ((u & 1023) << 10)) | (str.charCodeAt(++i) & 1023) - if (u <= 127) ++len - else if (u <= 2047) len += 2 - else if (u <= 65535) len += 3 - else len += 4 - } - return len - } - var UTF16Decoder = new TextDecoder('utf-16le') - function UTF16ToString(ptr, maxBytesToRead) { - var endPtr = ptr - var idx = endPtr >> 1 - var maxIdx = idx + maxBytesToRead / 2 - while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx - endPtr = idx << 1 - return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)) - var str = '' - for (var i = 0; !(i >= maxBytesToRead / 2); ++i) { - var codeUnit = HEAP16[(ptr + i * 2) >> 1] - if (codeUnit == 0) break - str += String.fromCharCode(codeUnit) - } - return str - } - function stringToUTF16(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 2) return 0 - maxBytesToWrite -= 2 - var startPtr = outPtr - var numCharsToWrite = - maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length - for (var i = 0; i < numCharsToWrite; ++i) { - var codeUnit = str.charCodeAt(i) - HEAP16[outPtr >> 1] = codeUnit - outPtr += 2 - } - HEAP16[outPtr >> 1] = 0 - return outPtr - startPtr - } - function lengthBytesUTF16(str) { - return str.length * 2 - } - function UTF32ToString(ptr, maxBytesToRead) { - var i = 0 - var str = '' - while (!(i >= maxBytesToRead / 4)) { - var utf32 = HEAP32[(ptr + i * 4) >> 2] - if (utf32 == 0) break - ++i - if (utf32 >= 65536) { - var ch = utf32 - 65536 - str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023)) - } else { - str += String.fromCharCode(utf32) - } - } - return str - } - function stringToUTF32(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 4) return 0 - var startPtr = outPtr - var endPtr = startPtr + maxBytesToWrite - 4 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) { - var trailSurrogate = str.charCodeAt(++i) - codeUnit = - (65536 + ((codeUnit & 1023) << 10)) | (trailSurrogate & 1023) - } - HEAP32[outPtr >> 2] = codeUnit - outPtr += 4 - if (outPtr + 4 > endPtr) break - } - HEAP32[outPtr >> 2] = 0 - return outPtr - startPtr - } - function lengthBytesUTF32(str) { - var len = 0 - for (var i = 0; i < str.length; ++i) { - var codeUnit = str.charCodeAt(i) - if (codeUnit >= 55296 && codeUnit <= 57343) ++i - len += 4 - } - return len - } - function alignUp(x, multiple) { - if (x % multiple > 0) { - x += multiple - (x % multiple) - } - return x - } - var buffer, - HEAP8, - HEAPU8, - HEAP16, - HEAPU16, - HEAP32, - HEAPU32, - HEAPF32, - HEAPF64 - function updateGlobalBufferAndViews(buf) { - buffer = buf - Module['HEAP8'] = HEAP8 = new Int8Array(buf) - Module['HEAP16'] = HEAP16 = new Int16Array(buf) - Module['HEAP32'] = HEAP32 = new Int32Array(buf) - Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf) - Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf) - Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf) - Module['HEAPF32'] = HEAPF32 = new Float32Array(buf) - Module['HEAPF64'] = HEAPF64 = new Float64Array(buf) - } - var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216 - var wasmTable - var __ATPRERUN__ = [] - var __ATINIT__ = [] - var __ATPOSTRUN__ = [] - var runtimeInitialized = false - function preRun() { - if (Module['preRun']) { - if (typeof Module['preRun'] == 'function') - Module['preRun'] = [Module['preRun']] - while (Module['preRun'].length) { - addOnPreRun(Module['preRun'].shift()) - } - } - callRuntimeCallbacks(__ATPRERUN__) - } - function initRuntime() { - runtimeInitialized = true - callRuntimeCallbacks(__ATINIT__) - } - function postRun() { - if (Module['postRun']) { - if (typeof Module['postRun'] == 'function') - Module['postRun'] = [Module['postRun']] - while (Module['postRun'].length) { - addOnPostRun(Module['postRun'].shift()) - } - } - callRuntimeCallbacks(__ATPOSTRUN__) - } - function addOnPreRun(cb) { - __ATPRERUN__.unshift(cb) - } - function addOnInit(cb) { - __ATINIT__.unshift(cb) - } - function addOnPostRun(cb) { - __ATPOSTRUN__.unshift(cb) - } - var runDependencies = 0 - var runDependencyWatcher = null - var dependenciesFulfilled = null - function addRunDependency(id) { - runDependencies++ - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - } - function removeRunDependency(id) { - runDependencies-- - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies) - } - if (runDependencies == 0) { - if (runDependencyWatcher !== null) { - clearInterval(runDependencyWatcher) - runDependencyWatcher = null - } - if (dependenciesFulfilled) { - var callback = dependenciesFulfilled - dependenciesFulfilled = null - callback() - } - } - } - Module['preloadedImages'] = {} - Module['preloadedAudios'] = {} - function abort(what) { - if (Module['onAbort']) { - Module['onAbort'](what) - } - what += '' - err(what) - ABORT = true - EXITSTATUS = 1 - what = 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.' - var e = new WebAssembly.RuntimeError(what) - readyPromiseReject(e) - throw e - } - var dataURIPrefix = 'data:application/octet-stream;base64,' - function isDataURI(filename) { - return filename.startsWith(dataURIPrefix) - } - if (Module['locateFile']) { - var wasmBinaryFile = 'webp_node_enc.wasm' - if (!isDataURI(wasmBinaryFile)) { - wasmBinaryFile = locateFile(wasmBinaryFile) - } - } else { - throw new Error('invariant') - } - function getBinary(file) { - try { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary) - } - if (readBinary) { - return readBinary(file) - } else { - throw 'both async and sync fetching of the wasm failed' - } - } catch (err) { - abort(err) - } - } - function getBinaryPromise() { - return Promise.resolve().then(function () { - return getBinary(wasmBinaryFile) - }) - } - function createWasm() { - var info = { a: asmLibraryArg } - function receiveInstance(instance, module) { - var exports = instance.exports - Module['asm'] = exports - wasmMemory = Module['asm']['x'] - updateGlobalBufferAndViews(wasmMemory.buffer) - wasmTable = Module['asm']['D'] - addOnInit(Module['asm']['y']) - removeRunDependency('wasm-instantiate') - } - addRunDependency('wasm-instantiate') - function receiveInstantiationResult(result) { - receiveInstance(result['instance']) - } - function instantiateArrayBuffer(receiver) { - return getBinaryPromise() - .then(function (binary) { - var result = WebAssembly.instantiate(binary, info) - return result - }) - .then(receiver, function (reason) { - err('failed to asynchronously prepare wasm: ' + reason) - abort(reason) - }) - } - function instantiateAsync() { - return instantiateArrayBuffer(receiveInstantiationResult) - } - if (Module['instantiateWasm']) { - try { - var exports = Module['instantiateWasm'](info, receiveInstance) - return exports - } catch (e) { - err('Module.instantiateWasm callback failed with error: ' + e) - return false - } - } - instantiateAsync().catch(readyPromiseReject) - return {} - } - function callRuntimeCallbacks(callbacks) { - while (callbacks.length > 0) { - var callback = callbacks.shift() - if (typeof callback == 'function') { - callback(Module) - continue - } - var func = callback.func - if (typeof func === 'number') { - if (callback.arg === undefined) { - wasmTable.get(func)() - } else { - wasmTable.get(func)(callback.arg) - } - } else { - func(callback.arg === undefined ? null : callback.arg) - } - } - } - function _atexit(func, arg) {} - function ___cxa_thread_atexit(a0, a1) { - return _atexit(a0, a1) - } - var structRegistrations = {} - function runDestructors(destructors) { - while (destructors.length) { - var ptr = destructors.pop() - var del = destructors.pop() - del(ptr) - } - } - function simpleReadValueFromPointer(pointer) { - return this['fromWireType'](HEAPU32[pointer >> 2]) - } - var awaitingDependencies = {} - var registeredTypes = {} - var typeDependencies = {} - var char_0 = 48 - var char_9 = 57 - function makeLegalFunctionName(name) { - if (undefined === name) { - return '_unknown' - } - name = name.replace(/[^a-zA-Z0-9_]/g, '$') - var f = name.charCodeAt(0) - if (f >= char_0 && f <= char_9) { - return '_' + name - } else { - return name - } - } - function createNamedFunction(name, body) { - name = makeLegalFunctionName(name) - return new Function( - 'body', - 'return function ' + - name + - '() {\n' + - ' "use strict";' + - ' return body.apply(this, arguments);\n' + - '};\n' - )(body) - } - function extendError(baseErrorType, errorName) { - var errorClass = createNamedFunction(errorName, function (message) { - this.name = errorName - this.message = message - var stack = new Error(message).stack - if (stack !== undefined) { - this.stack = - this.toString() + '\n' + stack.replace(/^Error(:[^\n]*)?\n/, '') - } - }) - errorClass.prototype = Object.create(baseErrorType.prototype) - errorClass.prototype.constructor = errorClass - errorClass.prototype.toString = function () { - if (this.message === undefined) { - return this.name - } else { - return this.name + ': ' + this.message - } - } - return errorClass - } - var InternalError = undefined - function throwInternalError(message) { - throw new InternalError(message) - } - function whenDependentTypesAreResolved( - myTypes, - dependentTypes, - getTypeConverters - ) { - myTypes.forEach(function (type) { - typeDependencies[type] = dependentTypes - }) - function onComplete(typeConverters) { - var myTypeConverters = getTypeConverters(typeConverters) - if (myTypeConverters.length !== myTypes.length) { - throwInternalError('Mismatched type converter count') - } - for (var i = 0; i < myTypes.length; ++i) { - registerType(myTypes[i], myTypeConverters[i]) - } - } - var typeConverters = new Array(dependentTypes.length) - var unregisteredTypes = [] - var registered = 0 - dependentTypes.forEach(function (dt, i) { - if (registeredTypes.hasOwnProperty(dt)) { - typeConverters[i] = registeredTypes[dt] - } else { - unregisteredTypes.push(dt) - if (!awaitingDependencies.hasOwnProperty(dt)) { - awaitingDependencies[dt] = [] - } - awaitingDependencies[dt].push(function () { - typeConverters[i] = registeredTypes[dt] - ++registered - if (registered === unregisteredTypes.length) { - onComplete(typeConverters) - } - }) - } - }) - if (0 === unregisteredTypes.length) { - onComplete(typeConverters) - } - } - function __embind_finalize_value_object(structType) { - var reg = structRegistrations[structType] - delete structRegistrations[structType] - var rawConstructor = reg.rawConstructor - var rawDestructor = reg.rawDestructor - var fieldRecords = reg.fields - var fieldTypes = fieldRecords - .map(function (field) { - return field.getterReturnType - }) - .concat( - fieldRecords.map(function (field) { - return field.setterArgumentType - }) - ) - whenDependentTypesAreResolved( - [structType], - fieldTypes, - function (fieldTypes) { - var fields = {} - fieldRecords.forEach(function (field, i) { - var fieldName = field.fieldName - var getterReturnType = fieldTypes[i] - var getter = field.getter - var getterContext = field.getterContext - var setterArgumentType = fieldTypes[i + fieldRecords.length] - var setter = field.setter - var setterContext = field.setterContext - fields[fieldName] = { - read: function (ptr) { - return getterReturnType['fromWireType']( - getter(getterContext, ptr) - ) - }, - write: function (ptr, o) { - var destructors = [] - setter( - setterContext, - ptr, - setterArgumentType['toWireType'](destructors, o) - ) - runDestructors(destructors) - }, - } - }) - return [ - { - name: reg.name, - fromWireType: function (ptr) { - var rv = {} - for (var i in fields) { - rv[i] = fields[i].read(ptr) - } - rawDestructor(ptr) - return rv - }, - toWireType: function (destructors, o) { - for (var fieldName in fields) { - if (!(fieldName in o)) { - throw new TypeError('Missing field: "' + fieldName + '"') - } - } - var ptr = rawConstructor() - for (fieldName in fields) { - fields[fieldName].write(ptr, o[fieldName]) - } - if (destructors !== null) { - destructors.push(rawDestructor, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: rawDestructor, - }, - ] - } - ) - } - function __embind_register_bigint( - primitiveType, - name, - size, - minRange, - maxRange - ) {} - function getShiftFromSize(size) { - switch (size) { - case 1: - return 0 - case 2: - return 1 - case 4: - return 2 - case 8: - return 3 - default: - throw new TypeError('Unknown type size: ' + size) - } - } - function embind_init_charCodes() { - var codes = new Array(256) - for (var i = 0; i < 256; ++i) { - codes[i] = String.fromCharCode(i) - } - embind_charCodes = codes - } - var embind_charCodes = undefined - function readLatin1String(ptr) { - var ret = '' - var c = ptr - while (HEAPU8[c]) { - ret += embind_charCodes[HEAPU8[c++]] - } - return ret - } - var BindingError = undefined - function throwBindingError(message) { - throw new BindingError(message) - } - function registerType(rawType, registeredInstance, options) { - options = options || {} - if (!('argPackAdvance' in registeredInstance)) { - throw new TypeError( - 'registerType registeredInstance requires argPackAdvance' - ) - } - var name = registeredInstance.name - if (!rawType) { - throwBindingError( - 'type "' + name + '" must have a positive integer typeid pointer' - ) - } - if (registeredTypes.hasOwnProperty(rawType)) { - if (options.ignoreDuplicateRegistrations) { - return - } else { - throwBindingError("Cannot register type '" + name + "' twice") - } - } - registeredTypes[rawType] = registeredInstance - delete typeDependencies[rawType] - if (awaitingDependencies.hasOwnProperty(rawType)) { - var callbacks = awaitingDependencies[rawType] - delete awaitingDependencies[rawType] - callbacks.forEach(function (cb) { - cb() - }) - } - } - function __embind_register_bool( - rawType, - name, - size, - trueValue, - falseValue - ) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (wt) { - return !!wt - }, - toWireType: function (destructors, o) { - return o ? trueValue : falseValue - }, - argPackAdvance: 8, - readValueFromPointer: function (pointer) { - var heap - if (size === 1) { - heap = HEAP8 - } else if (size === 2) { - heap = HEAP16 - } else if (size === 4) { - heap = HEAP32 - } else { - throw new TypeError('Unknown boolean type size: ' + name) - } - return this['fromWireType'](heap[pointer >> shift]) - }, - destructorFunction: null, - }) - } - var emval_free_list = [] - var emval_handle_array = [ - {}, - { value: undefined }, - { value: null }, - { value: true }, - { value: false }, - ] - function __emval_decref(handle) { - if (handle > 4 && 0 === --emval_handle_array[handle].refcount) { - emval_handle_array[handle] = undefined - emval_free_list.push(handle) - } - } - function count_emval_handles() { - var count = 0 - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - ++count - } - } - return count - } - function get_first_emval() { - for (var i = 5; i < emval_handle_array.length; ++i) { - if (emval_handle_array[i] !== undefined) { - return emval_handle_array[i] - } - } - return null - } - function init_emval() { - Module['count_emval_handles'] = count_emval_handles - Module['get_first_emval'] = get_first_emval - } - function __emval_register(value) { - switch (value) { - case undefined: { - return 1 - } - case null: { - return 2 - } - case true: { - return 3 - } - case false: { - return 4 - } - default: { - var handle = emval_free_list.length - ? emval_free_list.pop() - : emval_handle_array.length - emval_handle_array[handle] = { refcount: 1, value: value } - return handle - } - } - } - function __embind_register_emval(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (handle) { - var rv = emval_handle_array[handle].value - __emval_decref(handle) - return rv - }, - toWireType: function (destructors, value) { - return __emval_register(value) - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: null, - }) - } - function ensureOverloadTable(proto, methodName, humanName) { - if (undefined === proto[methodName].overloadTable) { - var prevFunc = proto[methodName] - proto[methodName] = function () { - if ( - !proto[methodName].overloadTable.hasOwnProperty(arguments.length) - ) { - throwBindingError( - "Function '" + - humanName + - "' called with an invalid number of arguments (" + - arguments.length + - ') - expects one of (' + - proto[methodName].overloadTable + - ')!' - ) - } - return proto[methodName].overloadTable[arguments.length].apply( - this, - arguments - ) - } - proto[methodName].overloadTable = [] - proto[methodName].overloadTable[prevFunc.argCount] = prevFunc - } - } - function exposePublicSymbol(name, value, numArguments) { - if (Module.hasOwnProperty(name)) { - if ( - undefined === numArguments || - (undefined !== Module[name].overloadTable && - undefined !== Module[name].overloadTable[numArguments]) - ) { - throwBindingError("Cannot register public name '" + name + "' twice") - } - ensureOverloadTable(Module, name, name) - if (Module.hasOwnProperty(numArguments)) { - throwBindingError( - 'Cannot register multiple overloads of a function with the same number of arguments (' + - numArguments + - ')!' - ) - } - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - if (undefined !== numArguments) { - Module[name].numArguments = numArguments - } - } - } - function enumReadValueFromPointer(name, shift, signed) { - switch (shift) { - case 0: - return function (pointer) { - var heap = signed ? HEAP8 : HEAPU8 - return this['fromWireType'](heap[pointer]) - } - case 1: - return function (pointer) { - var heap = signed ? HEAP16 : HEAPU16 - return this['fromWireType'](heap[pointer >> 1]) - } - case 2: - return function (pointer) { - var heap = signed ? HEAP32 : HEAPU32 - return this['fromWireType'](heap[pointer >> 2]) - } - default: - throw new TypeError('Unknown integer type: ' + name) - } - } - function __embind_register_enum(rawType, name, size, isSigned) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - function ctor() {} - ctor.values = {} - registerType(rawType, { - name: name, - constructor: ctor, - fromWireType: function (c) { - return this.constructor.values[c] - }, - toWireType: function (destructors, c) { - return c.value - }, - argPackAdvance: 8, - readValueFromPointer: enumReadValueFromPointer(name, shift, isSigned), - destructorFunction: null, - }) - exposePublicSymbol(name, ctor) - } - function getTypeName(type) { - var ptr = ___getTypeName(type) - var rv = readLatin1String(ptr) - _free(ptr) - return rv - } - function requireRegisteredType(rawType, humanName) { - var impl = registeredTypes[rawType] - if (undefined === impl) { - throwBindingError( - humanName + ' has unknown type ' + getTypeName(rawType) - ) - } - return impl - } - function __embind_register_enum_value(rawEnumType, name, enumValue) { - var enumType = requireRegisteredType(rawEnumType, 'enum') - name = readLatin1String(name) - var Enum = enumType.constructor - var Value = Object.create(enumType.constructor.prototype, { - value: { value: enumValue }, - constructor: { - value: createNamedFunction( - enumType.name + '_' + name, - function () {} - ), - }, - }) - Enum.values[enumValue] = Value - Enum[name] = Value - } - function _embind_repr(v) { - if (v === null) { - return 'null' - } - var t = typeof v - if (t === 'object' || t === 'array' || t === 'function') { - return v.toString() - } else { - return '' + v - } - } - function floatReadValueFromPointer(name, shift) { - switch (shift) { - case 2: - return function (pointer) { - return this['fromWireType'](HEAPF32[pointer >> 2]) - } - case 3: - return function (pointer) { - return this['fromWireType'](HEAPF64[pointer >> 3]) - } - default: - throw new TypeError('Unknown float type: ' + name) - } - } - function __embind_register_float(rawType, name, size) { - var shift = getShiftFromSize(size) - name = readLatin1String(name) - registerType(rawType, { - name: name, - fromWireType: function (value) { - return value - }, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - return value - }, - argPackAdvance: 8, - readValueFromPointer: floatReadValueFromPointer(name, shift), - destructorFunction: null, - }) - } - function new_(constructor, argumentList) { - if (!(constructor instanceof Function)) { - throw new TypeError( - 'new_ called with constructor type ' + - typeof constructor + - ' which is not a function' - ) - } - var dummy = createNamedFunction( - constructor.name || 'unknownFunctionName', - function () {} - ) - dummy.prototype = constructor.prototype - var obj = new dummy() - var r = constructor.apply(obj, argumentList) - return r instanceof Object ? r : obj - } - function craftInvokerFunction( - humanName, - argTypes, - classType, - cppInvokerFunc, - cppTargetFunc - ) { - var argCount = argTypes.length - if (argCount < 2) { - throwBindingError( - "argTypes array size mismatch! Must at least get return value and 'this' types!" - ) - } - var isClassMethodFunc = argTypes[1] !== null && classType !== null - var needsDestructorStack = false - for (var i = 1; i < argTypes.length; ++i) { - if ( - argTypes[i] !== null && - argTypes[i].destructorFunction === undefined - ) { - needsDestructorStack = true - break - } - } - var returns = argTypes[0].name !== 'void' - var argsList = '' - var argsListWired = '' - for (var i = 0; i < argCount - 2; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - argsListWired += (i !== 0 ? ', ' : '') + 'arg' + i + 'Wired' - } - var invokerFnBody = - 'return function ' + - makeLegalFunctionName(humanName) + - '(' + - argsList + - ') {\n' + - 'if (arguments.length !== ' + - (argCount - 2) + - ') {\n' + - "throwBindingError('function " + - humanName + - " called with ' + arguments.length + ' arguments, expected " + - (argCount - 2) + - " args!');\n" + - '}\n' - if (needsDestructorStack) { - invokerFnBody += 'var destructors = [];\n' - } - var dtorStack = needsDestructorStack ? 'destructors' : 'null' - var args1 = [ - 'throwBindingError', - 'invoker', - 'fn', - 'runDestructors', - 'retType', - 'classParam', - ] - var args2 = [ - throwBindingError, - cppInvokerFunc, - cppTargetFunc, - runDestructors, - argTypes[0], - argTypes[1], - ] - if (isClassMethodFunc) { - invokerFnBody += - 'var thisWired = classParam.toWireType(' + dtorStack + ', this);\n' - } - for (var i = 0; i < argCount - 2; ++i) { - invokerFnBody += - 'var arg' + - i + - 'Wired = argType' + - i + - '.toWireType(' + - dtorStack + - ', arg' + - i + - '); // ' + - argTypes[i + 2].name + - '\n' - args1.push('argType' + i) - args2.push(argTypes[i + 2]) - } - if (isClassMethodFunc) { - argsListWired = - 'thisWired' + (argsListWired.length > 0 ? ', ' : '') + argsListWired - } - invokerFnBody += - (returns ? 'var rv = ' : '') + - 'invoker(fn' + - (argsListWired.length > 0 ? ', ' : '') + - argsListWired + - ');\n' - if (needsDestructorStack) { - invokerFnBody += 'runDestructors(destructors);\n' - } else { - for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { - var paramName = i === 1 ? 'thisWired' : 'arg' + (i - 2) + 'Wired' - if (argTypes[i].destructorFunction !== null) { - invokerFnBody += - paramName + - '_dtor(' + - paramName + - '); // ' + - argTypes[i].name + - '\n' - args1.push(paramName + '_dtor') - args2.push(argTypes[i].destructorFunction) - } - } - } - if (returns) { - invokerFnBody += - 'var ret = retType.fromWireType(rv);\n' + 'return ret;\n' - } else { - } - invokerFnBody += '}\n' - args1.push(invokerFnBody) - var invokerFunction = new_(Function, args1).apply(null, args2) - return invokerFunction - } - function heap32VectorToArray(count, firstElement) { - var array = [] - for (var i = 0; i < count; i++) { - array.push(HEAP32[(firstElement >> 2) + i]) - } - return array - } - function replacePublicSymbol(name, value, numArguments) { - if (!Module.hasOwnProperty(name)) { - throwInternalError('Replacing nonexistent public symbol') - } - if ( - undefined !== Module[name].overloadTable && - undefined !== numArguments - ) { - Module[name].overloadTable[numArguments] = value - } else { - Module[name] = value - Module[name].argCount = numArguments - } - } - function dynCallLegacy(sig, ptr, args) { - var f = Module['dynCall_' + sig] - return args && args.length - ? f.apply(null, [ptr].concat(args)) - : f.call(null, ptr) - } - function dynCall(sig, ptr, args) { - if (sig.includes('j')) { - return dynCallLegacy(sig, ptr, args) - } - return wasmTable.get(ptr).apply(null, args) - } - function getDynCaller(sig, ptr) { - var argCache = [] - return function () { - argCache.length = arguments.length - for (var i = 0; i < arguments.length; i++) { - argCache[i] = arguments[i] - } - return dynCall(sig, ptr, argCache) - } - } - function embind__requireFunction(signature, rawFunction) { - signature = readLatin1String(signature) - function makeDynCaller() { - if (signature.includes('j')) { - return getDynCaller(signature, rawFunction) - } - return wasmTable.get(rawFunction) - } - var fp = makeDynCaller() - if (typeof fp !== 'function') { - throwBindingError( - 'unknown function pointer with signature ' + - signature + - ': ' + - rawFunction - ) - } - return fp - } - var UnboundTypeError = undefined - function throwUnboundTypeError(message, types) { - var unboundTypes = [] - var seen = {} - function visit(type) { - if (seen[type]) { - return - } - if (registeredTypes[type]) { - return - } - if (typeDependencies[type]) { - typeDependencies[type].forEach(visit) - return - } - unboundTypes.push(type) - seen[type] = true - } - types.forEach(visit) - throw new UnboundTypeError( - message + ': ' + unboundTypes.map(getTypeName).join([', ']) - ) - } - function __embind_register_function( - name, - argCount, - rawArgTypesAddr, - signature, - rawInvoker, - fn - ) { - var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr) - name = readLatin1String(name) - rawInvoker = embind__requireFunction(signature, rawInvoker) - exposePublicSymbol( - name, - function () { - throwUnboundTypeError( - 'Cannot call ' + name + ' due to unbound types', - argTypes - ) - }, - argCount - 1 - ) - whenDependentTypesAreResolved([], argTypes, function (argTypes) { - var invokerArgsArray = [argTypes[0], null].concat(argTypes.slice(1)) - replacePublicSymbol( - name, - craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn), - argCount - 1 - ) - return [] - }) - } - function integerReadValueFromPointer(name, shift, signed) { - switch (shift) { - case 0: - return signed - ? function readS8FromPointer(pointer) { - return HEAP8[pointer] - } - : function readU8FromPointer(pointer) { - return HEAPU8[pointer] - } - case 1: - return signed - ? function readS16FromPointer(pointer) { - return HEAP16[pointer >> 1] - } - : function readU16FromPointer(pointer) { - return HEAPU16[pointer >> 1] - } - case 2: - return signed - ? function readS32FromPointer(pointer) { - return HEAP32[pointer >> 2] - } - : function readU32FromPointer(pointer) { - return HEAPU32[pointer >> 2] - } - default: - throw new TypeError('Unknown integer type: ' + name) - } - } - function __embind_register_integer( - primitiveType, - name, - size, - minRange, - maxRange - ) { - name = readLatin1String(name) - if (maxRange === -1) { - maxRange = 4294967295 - } - var shift = getShiftFromSize(size) - var fromWireType = function (value) { - return value - } - if (minRange === 0) { - var bitshift = 32 - 8 * size - fromWireType = function (value) { - return (value << bitshift) >>> bitshift - } - } - var isUnsignedType = name.includes('unsigned') - registerType(primitiveType, { - name: name, - fromWireType: fromWireType, - toWireType: function (destructors, value) { - if (typeof value !== 'number' && typeof value !== 'boolean') { - throw new TypeError( - 'Cannot convert "' + _embind_repr(value) + '" to ' + this.name - ) - } - if (value < minRange || value > maxRange) { - throw new TypeError( - 'Passing a number "' + - _embind_repr(value) + - '" from JS side to C/C++ side to an argument of type "' + - name + - '", which is outside the valid range [' + - minRange + - ', ' + - maxRange + - ']!' - ) - } - return isUnsignedType ? value >>> 0 : value | 0 - }, - argPackAdvance: 8, - readValueFromPointer: integerReadValueFromPointer( - name, - shift, - minRange !== 0 - ), - destructorFunction: null, - }) - } - function __embind_register_memory_view(rawType, dataTypeIndex, name) { - var typeMapping = [ - Int8Array, - Uint8Array, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array, - ] - var TA = typeMapping[dataTypeIndex] - function decodeMemoryView(handle) { - handle = handle >> 2 - var heap = HEAPU32 - var size = heap[handle] - var data = heap[handle + 1] - return new TA(buffer, data, size) - } - name = readLatin1String(name) - registerType( - rawType, - { - name: name, - fromWireType: decodeMemoryView, - argPackAdvance: 8, - readValueFromPointer: decodeMemoryView, - }, - { ignoreDuplicateRegistrations: true } - ) - } - function __embind_register_std_string(rawType, name) { - name = readLatin1String(name) - var stdStringIsUTF8 = name === 'std::string' - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var str - if (stdStringIsUTF8) { - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i - if (i == length || HEAPU8[currentBytePtr] == 0) { - var maxRead = currentBytePtr - decodeStartPtr - var stringSegment = UTF8ToString(decodeStartPtr, maxRead) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + 1 - } - } - } else { - var a = new Array(length) - for (var i = 0; i < length; ++i) { - a[i] = String.fromCharCode(HEAPU8[value + 4 + i]) - } - str = a.join('') - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (value instanceof ArrayBuffer) { - value = new Uint8Array(value) - } - var getLength - var valueIsOfTypeString = typeof value === 'string' - if ( - !( - valueIsOfTypeString || - value instanceof Uint8Array || - value instanceof Uint8ClampedArray || - value instanceof Int8Array - ) - ) { - throwBindingError('Cannot pass non-string to std::string') - } - if (stdStringIsUTF8 && valueIsOfTypeString) { - getLength = function () { - return lengthBytesUTF8(value) - } - } else { - getLength = function () { - return value.length - } - } - var length = getLength() - var ptr = _malloc(4 + length + 1) - HEAPU32[ptr >> 2] = length - if (stdStringIsUTF8 && valueIsOfTypeString) { - stringToUTF8(value, ptr + 4, length + 1) - } else { - if (valueIsOfTypeString) { - for (var i = 0; i < length; ++i) { - var charCode = value.charCodeAt(i) - if (charCode > 255) { - _free(ptr) - throwBindingError( - 'String has UTF-16 code units that do not fit in 8 bits' - ) - } - HEAPU8[ptr + 4 + i] = charCode - } - } else { - for (var i = 0; i < length; ++i) { - HEAPU8[ptr + 4 + i] = value[i] - } - } - } - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_std_wstring(rawType, charSize, name) { - name = readLatin1String(name) - var decodeString, encodeString, getHeap, lengthBytesUTF, shift - if (charSize === 2) { - decodeString = UTF16ToString - encodeString = stringToUTF16 - lengthBytesUTF = lengthBytesUTF16 - getHeap = function () { - return HEAPU16 - } - shift = 1 - } else if (charSize === 4) { - decodeString = UTF32ToString - encodeString = stringToUTF32 - lengthBytesUTF = lengthBytesUTF32 - getHeap = function () { - return HEAPU32 - } - shift = 2 - } - registerType(rawType, { - name: name, - fromWireType: function (value) { - var length = HEAPU32[value >> 2] - var HEAP = getHeap() - var str - var decodeStartPtr = value + 4 - for (var i = 0; i <= length; ++i) { - var currentBytePtr = value + 4 + i * charSize - if (i == length || HEAP[currentBytePtr >> shift] == 0) { - var maxReadBytes = currentBytePtr - decodeStartPtr - var stringSegment = decodeString(decodeStartPtr, maxReadBytes) - if (str === undefined) { - str = stringSegment - } else { - str += String.fromCharCode(0) - str += stringSegment - } - decodeStartPtr = currentBytePtr + charSize - } - } - _free(value) - return str - }, - toWireType: function (destructors, value) { - if (!(typeof value === 'string')) { - throwBindingError( - 'Cannot pass non-string to C++ string type ' + name - ) - } - var length = lengthBytesUTF(value) - var ptr = _malloc(4 + length + charSize) - HEAPU32[ptr >> 2] = length >> shift - encodeString(value, ptr + 4, length + charSize) - if (destructors !== null) { - destructors.push(_free, ptr) - } - return ptr - }, - argPackAdvance: 8, - readValueFromPointer: simpleReadValueFromPointer, - destructorFunction: function (ptr) { - _free(ptr) - }, - }) - } - function __embind_register_value_object( - rawType, - name, - constructorSignature, - rawConstructor, - destructorSignature, - rawDestructor - ) { - structRegistrations[rawType] = { - name: readLatin1String(name), - rawConstructor: embind__requireFunction( - constructorSignature, - rawConstructor - ), - rawDestructor: embind__requireFunction( - destructorSignature, - rawDestructor - ), - fields: [], - } - } - function __embind_register_value_object_field( - structType, - fieldName, - getterReturnType, - getterSignature, - getter, - getterContext, - setterArgumentType, - setterSignature, - setter, - setterContext - ) { - structRegistrations[structType].fields.push({ - fieldName: readLatin1String(fieldName), - getterReturnType: getterReturnType, - getter: embind__requireFunction(getterSignature, getter), - getterContext: getterContext, - setterArgumentType: setterArgumentType, - setter: embind__requireFunction(setterSignature, setter), - setterContext: setterContext, - }) - } - function __embind_register_void(rawType, name) { - name = readLatin1String(name) - registerType(rawType, { - isVoid: true, - name: name, - argPackAdvance: 0, - fromWireType: function () { - return undefined - }, - toWireType: function (destructors, o) { - return undefined - }, - }) - } - var emval_symbols = {} - function getStringOrSymbol(address) { - var symbol = emval_symbols[address] - if (symbol === undefined) { - return readLatin1String(address) - } else { - return symbol - } - } - function emval_get_global() { - if (typeof globalThis === 'object') { - return globalThis - } - return (function () { - return Function - })()('return this')() - } - function __emval_get_global(name) { - if (name === 0) { - return __emval_register(emval_get_global()) - } else { - name = getStringOrSymbol(name) - return __emval_register(emval_get_global()[name]) - } - } - function __emval_incref(handle) { - if (handle > 4) { - emval_handle_array[handle].refcount += 1 - } - } - function craftEmvalAllocator(argCount) { - var argsList = '' - for (var i = 0; i < argCount; ++i) { - argsList += (i !== 0 ? ', ' : '') + 'arg' + i - } - var functionBody = - 'return function emval_allocator_' + - argCount + - '(constructor, argTypes, args) {\n' - for (var i = 0; i < argCount; ++i) { - functionBody += - 'var argType' + - i + - " = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + " + - i + - '], "parameter ' + - i + - '");\n' + - 'var arg' + - i + - ' = argType' + - i + - '.readValueFromPointer(args);\n' + - 'args += argType' + - i + - "['argPackAdvance'];\n" - } - functionBody += - 'var obj = new constructor(' + - argsList + - ');\n' + - 'return __emval_register(obj);\n' + - '}\n' - return new Function( - 'requireRegisteredType', - 'Module', - '__emval_register', - functionBody - )(requireRegisteredType, Module, __emval_register) - } - var emval_newers = {} - function requireHandle(handle) { - if (!handle) { - throwBindingError('Cannot use deleted val. handle = ' + handle) - } - return emval_handle_array[handle].value - } - function __emval_new(handle, argCount, argTypes, args) { - handle = requireHandle(handle) - var newer = emval_newers[argCount] - if (!newer) { - newer = craftEmvalAllocator(argCount) - emval_newers[argCount] = newer - } - return newer(handle, argTypes, args) - } - function _abort() { - abort() - } - function _emscripten_memcpy_big(dest, src, num) { - HEAPU8.copyWithin(dest, src, src + num) - } - function emscripten_realloc_buffer(size) { - try { - wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16) - updateGlobalBufferAndViews(wasmMemory.buffer) - return 1 - } catch (e) {} - } - function _emscripten_resize_heap(requestedSize) { - var oldSize = HEAPU8.length - requestedSize = requestedSize >>> 0 - var maxHeapSize = 2147483648 - if (requestedSize > maxHeapSize) { - return false - } - for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { - var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown) - overGrownHeapSize = Math.min( - overGrownHeapSize, - requestedSize + 100663296 - ) - var newSize = Math.min( - maxHeapSize, - alignUp(Math.max(requestedSize, overGrownHeapSize), 65536) - ) - var replacement = emscripten_realloc_buffer(newSize) - if (replacement) { - return true - } - } - return false - } - InternalError = Module['InternalError'] = extendError( - Error, - 'InternalError' - ) - embind_init_charCodes() - BindingError = Module['BindingError'] = extendError(Error, 'BindingError') - init_emval() - UnboundTypeError = Module['UnboundTypeError'] = extendError( - Error, - 'UnboundTypeError' - ) - var asmLibraryArg = { - w: ___cxa_thread_atexit, - l: __embind_finalize_value_object, - p: __embind_register_bigint, - s: __embind_register_bool, - r: __embind_register_emval, - n: __embind_register_enum, - d: __embind_register_enum_value, - j: __embind_register_float, - h: __embind_register_function, - c: __embind_register_integer, - b: __embind_register_memory_view, - k: __embind_register_std_string, - g: __embind_register_std_wstring, - m: __embind_register_value_object, - a: __embind_register_value_object_field, - t: __embind_register_void, - f: __emval_decref, - v: __emval_get_global, - u: __emval_incref, - o: __emval_new, - i: _abort, - q: _emscripten_memcpy_big, - e: _emscripten_resize_heap, - } - var asm = createWasm() - var ___wasm_call_ctors = (Module['___wasm_call_ctors'] = function () { - return (___wasm_call_ctors = Module['___wasm_call_ctors'] = - Module['asm']['y']).apply(null, arguments) - }) - var _malloc = (Module['_malloc'] = function () { - return (_malloc = Module['_malloc'] = Module['asm']['z']).apply( - null, - arguments - ) - }) - var _free = (Module['_free'] = function () { - return (_free = Module['_free'] = Module['asm']['A']).apply( - null, - arguments - ) - }) - var ___getTypeName = (Module['___getTypeName'] = function () { - return (___getTypeName = Module['___getTypeName'] = - Module['asm']['B']).apply(null, arguments) - }) - var ___embind_register_native_and_builtin_types = (Module[ - '___embind_register_native_and_builtin_types' - ] = function () { - return (___embind_register_native_and_builtin_types = Module[ - '___embind_register_native_and_builtin_types' - ] = - Module['asm']['C']).apply(null, arguments) - }) - var calledRun - dependenciesFulfilled = function runCaller() { - if (!calledRun) run() - if (!calledRun) dependenciesFulfilled = runCaller - } - function run(args) { - args = args || arguments_ - if (runDependencies > 0) { - return - } - preRun() - if (runDependencies > 0) { - return - } - function doRun() { - if (calledRun) return - calledRun = true - Module['calledRun'] = true - if (ABORT) return - initRuntime() - readyPromiseResolve(Module) - if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']() - postRun() - } - if (Module['setStatus']) { - Module['setStatus']('Running...') - setTimeout(function () { - setTimeout(function () { - Module['setStatus']('') - }, 1) - doRun() - }, 1) - } else { - doRun() - } - } - Module['run'] = run - if (Module['preInit']) { - if (typeof Module['preInit'] == 'function') - Module['preInit'] = [Module['preInit']] - while (Module['preInit'].length > 0) { - Module['preInit'].pop()() - } - } - run() - - return Module.ready - } -})() -export default Module diff --git a/packages/next/src/server/lib/squoosh/webp/webp_node_enc.wasm b/packages/next/src/server/lib/squoosh/webp/webp_node_enc.wasm deleted file mode 100755 index 7621054164..0000000000 Binary files a/packages/next/src/server/lib/squoosh/webp/webp_node_enc.wasm and /dev/null differ diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 652e27c46e..0fe707e3ac 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -663,15 +663,6 @@ export async function ncc_image_size(task, opts) { .target('src/compiled/image-size') } -// eslint-disable-next-line camelcase -externals['get-orientation'] = 'next/dist/compiled/get-orientation' -export async function ncc_get_orientation(task, opts) { - await task - .source(relative(__dirname, require.resolve('get-orientation'))) - .ncc({ packageName: 'get-orientation', externals }) - .target('src/compiled/get-orientation') -} - // eslint-disable-next-line camelcase externals['@hapi/accept'] = 'next/dist/compiled/@hapi/accept' export async function ncc_hapi_accept(task, opts) { @@ -2180,7 +2171,6 @@ export async function ncc(task, opts) { 'ncc_p_limit', 'ncc_raw_body', 'ncc_image_size', - 'ncc_get_orientation', 'ncc_hapi_accept', 'ncc_commander', 'ncc_node_fetch', diff --git a/packages/next/types/$$compiled.internal.d.ts b/packages/next/types/$$compiled.internal.d.ts index 17dd16aa9d..68cd1bab26 100644 --- a/packages/next/types/$$compiled.internal.d.ts +++ b/packages/next/types/$$compiled.internal.d.ts @@ -94,11 +94,6 @@ declare module 'next/dist/compiled/@hapi/accept' { export = m } -declare module 'next/dist/compiled/get-orientation' { - import m from 'get-orientation' - export = m -} - declare module 'next/dist/compiled/acorn' { import m from 'acorn' export = m diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e17b784141..537a09945f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -170,9 +170,6 @@ importers: '@types/selenium-webdriver': specifier: 4.0.15 version: 4.0.15 - '@types/sharp': - specifier: 0.29.3 - version: 0.29.3 '@types/string-hash': specifier: 1.1.1 version: 1.1.1 @@ -321,8 +318,8 @@ importers: specifier: 8.0.0 version: 8.0.0 image-size: - specifier: 0.9.3 - version: 0.9.3 + specifier: 1.1.1 + version: 1.1.1 is-animated: specifier: 2.0.2 version: 2.0.2 @@ -838,6 +835,10 @@ importers: styled-jsx: specifier: 5.1.1 version: 5.1.1(@babel/core@7.22.5)(react@18.2.0) + optionalDependencies: + sharp: + specifier: ^0.33.3 + version: 0.33.3 devDependencies: '@ampproject/toolbox-optimizer': specifier: 2.8.3 @@ -1181,9 +1182,6 @@ importers: fresh: specifier: 0.5.2 version: 0.5.2 - get-orientation: - specifier: 1.1.2 - version: 1.1.2 glob: specifier: 7.1.7 version: 7.1.7 @@ -1209,8 +1207,8 @@ importers: specifier: 0.1.2 version: 0.1.2 image-size: - specifier: 1.0.0 - version: 1.0.0 + specifier: 1.1.1 + version: 1.1.1 is-docker: specifier: 2.0.0 version: 2.0.0 @@ -3579,6 +3577,14 @@ packages: '@edge-runtime/primitives': 4.1.0 dev: true + /@emnapi/runtime@1.1.1: + resolution: {integrity: sha512-3bfqkzuR1KLx57nZfjr2NLnFOobvyS0aTszaEGCGqmYMVDRaGvgIZbjGSV/MHSSmLgQ/b9JFHQ5xm5WRZYd+XQ==} + requiresBuild: true + dependencies: + tslib: 2.6.2 + dev: false + optional: true + /@emotion/babel-plugin@11.11.0: resolution: {integrity: sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==} dependencies: @@ -4109,6 +4115,194 @@ packages: resolution: {integrity: sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==} dev: true + /@img/sharp-darwin-arm64@0.33.3: + resolution: {integrity: sha512-FaNiGX1MrOuJ3hxuNzWgsT/mg5OHG/Izh59WW2mk1UwYHUwtfbhk5QNKYZgxf0pLOhx9ctGiGa2OykD71vOnSw==} + engines: {glibc: '>=2.26', node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + optionalDependencies: + '@img/sharp-libvips-darwin-arm64': 1.0.2 + dev: false + optional: true + + /@img/sharp-darwin-x64@0.33.3: + resolution: {integrity: sha512-2QeSl7QDK9ru//YBT4sQkoq7L0EAJZA3rtV+v9p8xTKl4U1bUqTIaCnoC7Ctx2kCjQgwFXDasOtPTCT8eCTXvw==} + engines: {glibc: '>=2.26', node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [x64] + os: [darwin] + requiresBuild: true + optionalDependencies: + '@img/sharp-libvips-darwin-x64': 1.0.2 + dev: false + optional: true + + /@img/sharp-libvips-darwin-arm64@1.0.2: + resolution: {integrity: sha512-tcK/41Rq8IKlSaKRCCAuuY3lDJjQnYIW1UXU1kxcEKrfL8WR7N6+rzNoOxoQRJWTAECuKwgAHnPvqXGN8XfkHA==} + engines: {macos: '>=11', npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /@img/sharp-libvips-darwin-x64@1.0.2: + resolution: {integrity: sha512-Ofw+7oaWa0HiiMiKWqqaZbaYV3/UGL2wAPeLuJTx+9cXpCRdvQhCLG0IH8YGwM0yGWGLpsF4Su9vM1o6aer+Fw==} + engines: {macos: '>=10.13', npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /@img/sharp-libvips-linux-arm64@1.0.2: + resolution: {integrity: sha512-x7kCt3N00ofFmmkkdshwj3vGPCnmiDh7Gwnd4nUwZln2YjqPxV1NlTyZOvoDWdKQVDL911487HOueBvrpflagw==} + engines: {glibc: '>=2.26', npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@img/sharp-libvips-linux-arm@1.0.2: + resolution: {integrity: sha512-iLWCvrKgeFoglQxdEwzu1eQV04o8YeYGFXtfWU26Zr2wWT3q3MTzC+QTCO3ZQfWd3doKHT4Pm2kRmLbupT+sZw==} + engines: {glibc: '>=2.28', npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@img/sharp-libvips-linux-s390x@1.0.2: + resolution: {integrity: sha512-cmhQ1J4qVhfmS6szYW7RT+gLJq9dH2i4maq+qyXayUSn9/3iY2ZeWpbAgSpSVbV2E1JUL2Gg7pwnYQ1h8rQIog==} + engines: {glibc: '>=2.28', npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@img/sharp-libvips-linux-x64@1.0.2: + resolution: {integrity: sha512-E441q4Qdb+7yuyiADVi5J+44x8ctlrqn8XgkDTwr4qPJzWkaHwD489iZ4nGDgcuya4iMN3ULV6NwbhRZJ9Z7SQ==} + engines: {glibc: '>=2.26', npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@img/sharp-libvips-linuxmusl-arm64@1.0.2: + resolution: {integrity: sha512-3CAkndNpYUrlDqkCM5qhksfE+qSIREVpyoeHIU6jd48SJZViAmznoQQLAv4hVXF7xyUB9zf+G++e2v1ABjCbEQ==} + engines: {musl: '>=1.2.2', npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@img/sharp-libvips-linuxmusl-x64@1.0.2: + resolution: {integrity: sha512-VI94Q6khIHqHWNOh6LLdm9s2Ry4zdjWJwH56WoiJU7NTeDwyApdZZ8c+SADC8OH98KWNQXnE01UdJ9CSfZvwZw==} + engines: {musl: '>=1.2.2', npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@img/sharp-linux-arm64@0.33.3: + resolution: {integrity: sha512-Zf+sF1jHZJKA6Gor9hoYG2ljr4wo9cY4twaxgFDvlG0Xz9V7sinsPp8pFd1XtlhTzYo0IhDbl3rK7P6MzHpnYA==} + engines: {glibc: '>=2.26', node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [arm64] + os: [linux] + requiresBuild: true + optionalDependencies: + '@img/sharp-libvips-linux-arm64': 1.0.2 + dev: false + optional: true + + /@img/sharp-linux-arm@0.33.3: + resolution: {integrity: sha512-Q7Ee3fFSC9P7vUSqVEF0zccJsZ8GiiCJYGWDdhEjdlOeS9/jdkyJ6sUSPj+bL8VuOYFSbofrW0t/86ceVhx32w==} + engines: {glibc: '>=2.28', node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [arm] + os: [linux] + requiresBuild: true + optionalDependencies: + '@img/sharp-libvips-linux-arm': 1.0.2 + dev: false + optional: true + + /@img/sharp-linux-s390x@0.33.3: + resolution: {integrity: sha512-vFk441DKRFepjhTEH20oBlFrHcLjPfI8B0pMIxGm3+yilKyYeHEVvrZhYFdqIseSclIqbQ3SnZMwEMWonY5XFA==} + engines: {glibc: '>=2.28', node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [s390x] + os: [linux] + requiresBuild: true + optionalDependencies: + '@img/sharp-libvips-linux-s390x': 1.0.2 + dev: false + optional: true + + /@img/sharp-linux-x64@0.33.3: + resolution: {integrity: sha512-Q4I++herIJxJi+qmbySd072oDPRkCg/SClLEIDh5IL9h1zjhqjv82H0Seupd+q2m0yOfD+/fJnjSoDFtKiHu2g==} + engines: {glibc: '>=2.26', node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [x64] + os: [linux] + requiresBuild: true + optionalDependencies: + '@img/sharp-libvips-linux-x64': 1.0.2 + dev: false + optional: true + + /@img/sharp-linuxmusl-arm64@0.33.3: + resolution: {integrity: sha512-qnDccehRDXadhM9PM5hLvcPRYqyFCBN31kq+ErBSZtZlsAc1U4Z85xf/RXv1qolkdu+ibw64fUDaRdktxTNP9A==} + engines: {musl: '>=1.2.2', node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [arm64] + os: [linux] + requiresBuild: true + optionalDependencies: + '@img/sharp-libvips-linuxmusl-arm64': 1.0.2 + dev: false + optional: true + + /@img/sharp-linuxmusl-x64@0.33.3: + resolution: {integrity: sha512-Jhchim8kHWIU/GZ+9poHMWRcefeaxFIs9EBqf9KtcC14Ojk6qua7ghKiPs0sbeLbLj/2IGBtDcxHyjCdYWkk2w==} + engines: {musl: '>=1.2.2', node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [x64] + os: [linux] + requiresBuild: true + optionalDependencies: + '@img/sharp-libvips-linuxmusl-x64': 1.0.2 + dev: false + optional: true + + /@img/sharp-wasm32@0.33.3: + resolution: {integrity: sha512-68zivsdJ0koE96stdUfM+gmyaK/NcoSZK5dV5CAjES0FUXS9lchYt8LAB5rTbM7nlWtxaU/2GON0HVN6/ZYJAQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [wasm32] + requiresBuild: true + dependencies: + '@emnapi/runtime': 1.1.1 + dev: false + optional: true + + /@img/sharp-win32-ia32@0.33.3: + resolution: {integrity: sha512-CyimAduT2whQD8ER4Ux7exKrtfoaUiVr7HG0zZvO0XTFn2idUWljjxv58GxNTkFb8/J9Ub9AqITGkJD6ZginxQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /@img/sharp-win32-x64@0.33.3: + resolution: {integrity: sha512-viT4fUIDKnli3IfOephGnolMzhz5VaTvDRkYqtZxOMIoMQ4MrAziO7pT1nVnOt2FAm7qW5aa+CCc13aEY6Le0g==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: false + optional: true + /@isaacs/cliui@8.0.2: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -7218,12 +7412,6 @@ packages: '@types/node': 20.12.3 dev: true - /@types/sharp@0.29.3: - resolution: {integrity: sha512-83Xp05eK2hvfNnmKLr2Fz0C2A0jrr2TnSLqKRbkLTYuAu+Erj6mKQLoEMGafE73Om8p3q3ryZxtHFM/7hy4Adg==} - dependencies: - '@types/node': 20.12.3 - dev: true - /@types/shell-quote@1.7.1: resolution: {integrity: sha512-SWZ2Nom1pkyXCDohRSrkSKvDh8QOG9RfAsrt5/NsPQC4UQJ55eG0qClA40I+Gkez4KTQ0uDUT8ELRXThf3J5jw==} dev: true @@ -7525,7 +7713,7 @@ packages: '@typescript-eslint/types': 6.14.0 '@typescript-eslint/typescript-estree': 6.14.0(typescript@5.3.3) eslint: 8.56.0 - semver: 7.5.4 + semver: 7.6.0 transitivePeerDependencies: - supports-color - typescript @@ -9596,20 +9784,30 @@ packages: /color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - /color-string@1.5.4: - resolution: {integrity: sha512-57yF5yt8Xa3czSEW1jfQDE79Idk0+AkN/4KWad6tbdxUmAs3MvjxlWSWD4deYytcRfoZ9nhKyFl1kj5tBvidbw==} + /color-string@1.9.1: + resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==} + requiresBuild: true dependencies: color-name: 1.1.4 simple-swizzle: 0.2.2 - dev: true /color@3.1.3: resolution: {integrity: sha512-xgXAcTHa2HeFCGLE9Xs/R82hujGtu9Jd9x4NW3T34+OMs7VoPsjwzRczKHvTAHeJwWFwX5j15+MgAppE8ztObQ==} dependencies: color-convert: 1.9.3 - color-string: 1.5.4 + color-string: 1.9.1 dev: true + /color@4.2.3: + resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==} + engines: {node: '>=12.5.0'} + requiresBuild: true + dependencies: + color-convert: 2.0.1 + color-string: 1.9.1 + dev: false + optional: true + /colord@2.9.3: resolution: {integrity: sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==} dev: true @@ -10935,6 +11133,13 @@ packages: hasBin: true dev: true + /detect-libc@2.0.3: + resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} + engines: {node: '>=8'} + requiresBuild: true + dev: false + optional: true + /detect-newline@3.1.0: resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==} engines: {node: '>=8'} @@ -13073,14 +13278,6 @@ packages: has-proto: 1.0.1 has-symbols: 1.0.3 - /get-orientation@1.1.2: - resolution: {integrity: sha512-/pViTfifW+gBbh/RnlFYHINvELT9Znt+SYyDKAUL6uV6By019AK/s+i9XP4jSwq7lwP38Fd8HVeTxym3+hkwmQ==} - dependencies: - stream-parser: 0.3.1 - transitivePeerDependencies: - - supports-color - dev: true - /get-own-enumerable-property-symbols@3.0.2: resolution: {integrity: sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==} dev: true @@ -14128,17 +14325,9 @@ packages: resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} engines: {node: '>= 4'} - /image-size@0.9.3: - resolution: {integrity: sha512-5SakFa79uhUVSjKeQE30GVzzLJ0QNzB53+I+/VD1vIesD6GP6uatWIlgU0uisFNLt1u0d6kBydp7yfk+lLJhLQ==} - engines: {node: '>=10.18.0'} - hasBin: true - dependencies: - queue: 6.0.1 - dev: true - - /image-size@1.0.0: - resolution: {integrity: sha512-JLJ6OwBfO1KcA+TvJT+v8gbE6iWbj24LyDNFgFEN0lzegn6cC6a/p3NIDaepMsJjQjlUWqIC7wJv8lBFxPNjcw==} - engines: {node: '>=12.0.0'} + /image-size@1.1.1: + resolution: {integrity: sha512-541xKlUw6jr/6gGuk92F+mYM5zaFAc5ahphvkqvNe2bQ6gVBkd6bfrmVJ2t4KDAfikAYZyIqTnktX3i6/aQDrQ==} + engines: {node: '>=16.x'} hasBin: true dependencies: queue: 6.0.2 @@ -14461,7 +14650,7 @@ packages: /is-arrayish@0.3.2: resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} - dev: true + requiresBuild: true /is-async-function@2.0.0: resolution: {integrity: sha512-Y1JXKrfykRJGdlDwdKlLpLyMIiWqWvuSd17TvZk68PLAOGOoF4Xyav1z0Xhoi+gCYjZVeC5SI+hYFOfvXmGRCA==} @@ -15089,7 +15278,7 @@ packages: '@babel/parser': 7.22.5 '@istanbuljs/schema': 0.1.2 istanbul-lib-coverage: 3.2.0 - semver: 7.5.4 + semver: 7.6.0 transitivePeerDependencies: - supports-color dev: true @@ -15798,7 +15987,7 @@ packages: jest-util: 29.7.0 natural-compare: 1.4.0 pretty-format: 29.7.0 - semver: 7.5.4 + semver: 7.6.0 transitivePeerDependencies: - supports-color dev: true @@ -21018,12 +21207,6 @@ packages: /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - /queue@6.0.1: - resolution: {integrity: sha512-AJBQabRCCNr9ANq8v77RJEv73DPbn55cdTb+Giq4X0AVnNVZvMHlYp7XlQiN+1npCZj1DuSmaA2hYVUUDgxFDg==} - dependencies: - inherits: 2.0.4 - dev: true - /queue@6.0.2: resolution: {integrity: sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==} dependencies: @@ -22372,6 +22555,14 @@ packages: dependencies: lru-cache: 6.0.0 + /semver@7.6.0: + resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} + engines: {node: '>=10'} + hasBin: true + requiresBuild: true + dependencies: + lru-cache: 6.0.0 + /send@0.17.1: resolution: {integrity: sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==} engines: {node: '>= 0.8.0'} @@ -22478,6 +22669,37 @@ packages: resolution: {integrity: sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==} dev: true + /sharp@0.33.3: + resolution: {integrity: sha512-vHUeXJU1UvlO/BNwTpT0x/r53WkLUVxrmb5JTgW92fdFCFk0ispLMAeu/jPO2vjkXM1fYUi3K7/qcLF47pwM1A==} + engines: {libvips: '>=8.15.2', node: ^18.17.0 || ^20.3.0 || >=21.0.0} + requiresBuild: true + dependencies: + color: 4.2.3 + detect-libc: 2.0.3 + semver: 7.6.0 + optionalDependencies: + '@img/sharp-darwin-arm64': 0.33.3 + '@img/sharp-darwin-x64': 0.33.3 + '@img/sharp-libvips-darwin-arm64': 1.0.2 + '@img/sharp-libvips-darwin-x64': 1.0.2 + '@img/sharp-libvips-linux-arm': 1.0.2 + '@img/sharp-libvips-linux-arm64': 1.0.2 + '@img/sharp-libvips-linux-s390x': 1.0.2 + '@img/sharp-libvips-linux-x64': 1.0.2 + '@img/sharp-libvips-linuxmusl-arm64': 1.0.2 + '@img/sharp-libvips-linuxmusl-x64': 1.0.2 + '@img/sharp-linux-arm': 0.33.3 + '@img/sharp-linux-arm64': 0.33.3 + '@img/sharp-linux-s390x': 0.33.3 + '@img/sharp-linux-x64': 0.33.3 + '@img/sharp-linuxmusl-arm64': 0.33.3 + '@img/sharp-linuxmusl-x64': 0.33.3 + '@img/sharp-wasm32': 0.33.3 + '@img/sharp-win32-ia32': 0.33.3 + '@img/sharp-win32-x64': 0.33.3 + dev: false + optional: true + /shebang-command@1.2.0: resolution: {integrity: sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=} engines: {node: '>=0.10.0'} @@ -22534,9 +22756,9 @@ packages: /simple-swizzle@0.2.2: resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} + requiresBuild: true dependencies: is-arrayish: 0.3.2 - dev: true /sirv@1.0.10: resolution: {integrity: sha512-H5EZCoZaggEUQy8ocKsF7WAToGuZhjJlLvM3XOef46CbdIgbNeQ1p32N1PCuCjkVYwrAVOSMacN6CXXgIzuspg==} @@ -22962,14 +23184,6 @@ packages: xtend: 4.0.2 dev: true - /stream-parser@0.3.1: - resolution: {integrity: sha1-FhhUhpRCACGhGC/wrxkRwSl2F3M=} - dependencies: - debug: 2.6.9 - transitivePeerDependencies: - - supports-color - dev: true - /streamsearch@1.1.0: resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} engines: {node: '>=10.0.0'} diff --git a/scripts/trace-next-server.js b/scripts/trace-next-server.js index 422cec07cb..74ff122b72 100644 --- a/scripts/trace-next-server.js +++ b/scripts/trace-next-server.js @@ -82,7 +82,6 @@ async function main() { 'node_modules/next/dist/pages/**/*', 'node_modules/next/dist/server/image-optimizer.js', 'node_modules/next/dist/compiled/@ampproject/toolbox-optimizer/**/*', - 'node_modules/next/dist/server/lib/squoosh/**/*.wasm', 'node_modules/next/dist/compiled/webpack/(bundle4|bundle5).js', 'node_modules/react/**/*.development.js', 'node_modules/react-dom/**/*.development.js', diff --git a/test/integration/image-optimizer/test/old-sharp.test.ts b/test/integration/image-optimizer/test/old-sharp.test.ts deleted file mode 100644 index 3e3a970c74..0000000000 --- a/test/integration/image-optimizer/test/old-sharp.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -import execa from 'execa' -import fs from 'fs-extra' -import { join } from 'path' -import { setupTests } from './util' - -const appDir = join(__dirname, '../app') -const imagesDir = join(appDir, '.next', 'cache', 'images') - -describe('with outdated sharp', () => { - beforeAll(async () => { - await fs.writeFile( - join(appDir, 'package.json'), - JSON.stringify({ - packageManager: 'npm@10.2.5', - }) - ) - await execa('npm', ['add', 'sharp@0.26.3'], { - cwd: appDir, - stdio: 'inherit', - }) - }) - afterAll(async () => { - await fs.remove(join(appDir, 'node_modules')) - await fs.remove(join(appDir, 'package-lock.json')) - await fs.remove(join(appDir, 'package.json')) - }) - - setupTests({ isSharp: true, isOutdatedSharp: true, appDir, imagesDir }) -}) diff --git a/test/integration/image-optimizer/test/sharp.test.ts b/test/integration/image-optimizer/test/sharp.test.ts index fefbeeaec0..9b50817902 100644 --- a/test/integration/image-optimizer/test/sharp.test.ts +++ b/test/integration/image-optimizer/test/sharp.test.ts @@ -1,5 +1,3 @@ -import execa from 'execa' -import fs from 'fs-extra' import { join } from 'path' import { setupTests } from './util' @@ -7,23 +5,5 @@ const appDir = join(__dirname, '../app') const imagesDir = join(appDir, '.next', 'cache', 'images') describe('with latest sharp', () => { - beforeAll(async () => { - await fs.writeFile( - join(appDir, 'package.json'), - JSON.stringify({ - packageManager: 'npm@10.2.5', - }) - ) - await execa('npm', ['add', 'sharp@latest'], { - cwd: appDir, - stdio: 'inherit', - }) - }) - afterAll(async () => { - await fs.remove(join(appDir, 'node_modules')) - await fs.remove(join(appDir, 'package-lock.json')) - await fs.remove(join(appDir, 'package.json')) - }) - - setupTests({ isSharp: true, isOutdatedSharp: false, appDir, imagesDir }) + setupTests({ appDir, imagesDir }) }) diff --git a/test/integration/image-optimizer/test/squoosh.test.ts b/test/integration/image-optimizer/test/squoosh.test.ts deleted file mode 100644 index ad69765403..0000000000 --- a/test/integration/image-optimizer/test/squoosh.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { join } from 'path' -import { setupTests } from './util' - -const appDir = join(__dirname, '../app') -const imagesDir = join(appDir, '.next', 'cache', 'images') - -describe('with squoosh', () => { - setupTests({ isSharp: false, isOutdatedSharp: false, appDir, imagesDir }) -}) diff --git a/test/integration/image-optimizer/test/util.ts b/test/integration/image-optimizer/test/util.ts index 393930d1c6..255b9cdebc 100644 --- a/test/integration/image-optimizer/test/util.ts +++ b/test/integration/image-optimizer/test/util.ts @@ -18,8 +18,6 @@ import isAnimated from 'next/dist/compiled/is-animated' import type { RequestInit } from 'node-fetch' const largeSize = 1080 // defaults defined in server/config.ts -const sharpMissingText = `For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended` -const sharpOutdatedText = `Your installed version of the 'sharp' package does not support AVIF images. Run 'npm i sharp@latest' to upgrade to the latest version` const animatedWarnText = 'is an animated image so it will not be optimized. Consider adding the "unoptimized" property to the .' @@ -149,26 +147,6 @@ export function runTests(ctx) { slowImageServer.stop() }) - if (!isDev && ctx.isSharp && ctx.nextConfigImages) { - it('should handle custom sharp usage', async () => { - const res = await fetchViaHTTP(ctx.appPort, '/api/custom-sharp') - - expect(res.status).toBe(200) - expect(await res.json()).toEqual({ success: true }) - const traceFile = await fs.readJson( - join( - ctx.appDir, - '.next', - 'server', - 'pages', - 'api', - 'custom-sharp.js.nft.json' - ) - ) - expect(traceFile.files.some((file) => file.includes('sharp/'))).toBe(true) - }) - } - if (domains.length > 0) { it('should normalize invalid status codes', async () => { const url = `http://localhost:${ @@ -407,26 +385,24 @@ export function runTests(ctx) { await expectWidth(res, ctx.w) }) - if (!ctx.isOutdatedSharp) { - it('should downlevel avif format to jpeg for old Safari', async () => { - const accept = - 'image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5' - const query = { w: ctx.w, q: 74, url: '/test.avif' } - const opts = { headers: { accept } } - const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, opts) - expect(res.status).toBe(200) - expect(res.headers.get('Content-Type')).toContain('image/jpeg') - expect(res.headers.get('Cache-Control')).toBe( - `public, max-age=${isDev ? 0 : minimumCacheTTL}, must-revalidate` - ) - expect(res.headers.get('Vary')).toBe('Accept') - expect(res.headers.get('etag')).toBeTruthy() - expect(res.headers.get('Content-Disposition')).toBe( - `${contentDispositionType}; filename="test.jpeg"` - ) - await expectWidth(res, ctx.w) - }) - } + it('should downlevel avif format to jpeg for old Safari', async () => { + const accept = + 'image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5' + const query = { w: ctx.w, q: 74, url: '/test.avif' } + const opts = { headers: { accept } } + const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, opts) + expect(res.status).toBe(200) + expect(res.headers.get('Content-Type')).toContain('image/jpeg') + expect(res.headers.get('Cache-Control')).toBe( + `public, max-age=${isDev ? 0 : minimumCacheTTL}, must-revalidate` + ) + expect(res.headers.get('Vary')).toBe('Accept') + expect(res.headers.get('etag')).toBeTruthy() + expect(res.headers.get('Content-Disposition')).toBe( + `${contentDispositionType}; filename="test.jpeg"` + ) + await expectWidth(res, ctx.w) + }) it('should fail when url is missing', async () => { const query = { w: ctx.w, q: 100 } @@ -677,9 +653,7 @@ export function runTests(ctx) { expect(res.headers.get('Content-Disposition')).toBe( `${contentDispositionType}; filename="test.avif"` ) - // TODO: upgrade "image-size" package to support AVIF - // See https://github.com/image-size/image-size/issues/348 - //await expectWidth(res, ctx.w) + await expectWidth(res, ctx.w) }) it('should compress avif smaller than webp at q=100', async () => { @@ -1152,34 +1126,6 @@ export function runTests(ctx) { await expectWidth(res, 400) }) - if (!ctx.isSharp) { - // this checks for specific color type output by squoosh - // which differs in sharp - it('should not change the color type of a png', async () => { - // https://github.com/vercel/next.js/issues/22929 - // A grayscaled PNG with transparent pixels. - const query = { url: '/grayscale.png', w: largeSize, q: 80 } - const opts = { headers: { accept: 'image/png' } } - const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, opts) - expect(res.status).toBe(200) - expect(res.headers.get('Content-Type')).toBe('image/png') - expect(res.headers.get('Cache-Control')).toBe( - `public, max-age=${isDev ? 0 : minimumCacheTTL}, must-revalidate` - ) - expect(res.headers.get('Vary')).toBe('Accept') - expect(res.headers.get('Content-Disposition')).toBe( - `${contentDispositionType}; filename="grayscale.png"` - ) - - const png = await res.buffer() - - // Read the color type byte (offset 9 + magic number 16). - // http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html - const colorType = png.readUIntBE(25, 1) - expect(colorType).toBe(4) - }) - } - it('should set cache-control to immutable for static images', async () => { if (!ctx.isDev) { const filename = 'test' @@ -1287,34 +1233,96 @@ export function runTests(ctx) { expect(xCache).toEqual(['MISS', 'MISS', 'MISS']) }) } - - if (ctx.isDev || ctx.isSharp) { - it('should not have sharp missing warning', () => { - expect(ctx.nextOutput).not.toContain(sharpMissingText) - }) - } else { - it('should have sharp missing warning', () => { - expect(ctx.nextOutput).toContain(sharpMissingText) - }) - } - - if (ctx.isSharp && ctx.isOutdatedSharp && avifEnabled) { - it('should have sharp outdated warning', () => { - expect(ctx.nextOutput).toContain(sharpOutdatedText) - }) - } else { - it('should not have sharp outdated warning', () => { - expect(ctx.nextOutput).not.toContain(sharpOutdatedText) - }) - } } export const setupTests = (ctx) => { const nextConfig = new File(join(ctx.appDir, 'next.config.js')) - // only run one server config with outdated sharp - if (!ctx.isOutdatedSharp) { - describe('dev support w/o next.config.js', () => { + describe('dev support w/o next.config.js', () => { + if (ctx.nextConfigImages) { + // skip this test because it requires next.config.js + return + } + const size = 384 // defaults defined in server/config.ts + const curCtx = { + ...ctx, + w: size, + isDev: true, + } + + beforeAll(async () => { + const json = JSON.stringify({ + experimental: { + outputFileTracingRoot: join(__dirname, '../../../..'), + }, + }) + nextConfig.replace('{ /* replaceme */ }', json) + curCtx.nextOutput = '' + curCtx.appPort = await findPort() + curCtx.app = await launchApp(curCtx.appDir, curCtx.appPort, { + onStderr(msg) { + curCtx.nextOutput += msg + }, + cwd: curCtx.appDir, + }) + await cleanImagesDir(ctx) + }) + afterAll(async () => { + nextConfig.restore() + if (curCtx.app) await killApp(curCtx.app) + }) + + runTests(curCtx) + }) + + describe('dev support with next.config.js', () => { + const size = 400 + const curCtx = { + ...ctx, + w: size, + isDev: true, + nextConfigImages: { + domains: [ + 'localhost', + '127.0.0.1', + 'example.com', + 'assets.vercel.com', + 'image-optimization-test.vercel.app', + ], + formats: ['image/avif', 'image/webp'], + deviceSizes: [largeSize], + imageSizes: [size], + ...ctx.nextConfigImages, + }, + } + beforeAll(async () => { + const json = JSON.stringify({ + images: curCtx.nextConfigImages, + experimental: { + outputFileTracingRoot: join(__dirname, '../../../..'), + }, + }) + curCtx.nextOutput = '' + nextConfig.replace('{ /* replaceme */ }', json) + await cleanImagesDir(ctx) + curCtx.appPort = await findPort() + curCtx.app = await launchApp(curCtx.appDir, curCtx.appPort, { + onStderr(msg) { + curCtx.nextOutput += msg + }, + cwd: curCtx.appDir, + }) + }) + afterAll(async () => { + nextConfig.restore() + if (curCtx.app) await killApp(curCtx.app) + }) + + runTests(curCtx) + }) + ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( + 'Production Mode Server support w/o next.config.js', + () => { if (ctx.nextConfigImages) { // skip this test because it requires next.config.js return @@ -1323,9 +1331,8 @@ export const setupTests = (ctx) => { const curCtx = { ...ctx, w: size, - isDev: true, + isDev: false, } - beforeAll(async () => { const json = JSON.stringify({ experimental: { @@ -1334,68 +1341,13 @@ export const setupTests = (ctx) => { }) nextConfig.replace('{ /* replaceme */ }', json) curCtx.nextOutput = '' - curCtx.appPort = await findPort() - curCtx.app = await launchApp(curCtx.appDir, curCtx.appPort, { - onStderr(msg) { - curCtx.nextOutput += msg - }, - env: { - NEXT_SHARP_PATH: curCtx.isSharp - ? join(curCtx.appDir, 'node_modules', 'sharp') - : '', - }, - cwd: curCtx.appDir, - }) - await cleanImagesDir(ctx) - }) - afterAll(async () => { - nextConfig.restore() - if (curCtx.app) await killApp(curCtx.app) - }) - - runTests(curCtx) - }) - - describe('dev support with next.config.js', () => { - const size = 400 - const curCtx = { - ...ctx, - w: size, - isDev: true, - nextConfigImages: { - domains: [ - 'localhost', - '127.0.0.1', - 'example.com', - 'assets.vercel.com', - 'image-optimization-test.vercel.app', - ], - formats: ['image/avif', 'image/webp'], - deviceSizes: [largeSize], - imageSizes: [size], - ...ctx.nextConfigImages, - }, - } - beforeAll(async () => { - const json = JSON.stringify({ - images: curCtx.nextConfigImages, - experimental: { - outputFileTracingRoot: join(__dirname, '../../../..'), - }, - }) - curCtx.nextOutput = '' - nextConfig.replace('{ /* replaceme */ }', json) + await nextBuild(curCtx.appDir) await cleanImagesDir(ctx) curCtx.appPort = await findPort() - curCtx.app = await launchApp(curCtx.appDir, curCtx.appPort, { + curCtx.app = await nextStart(curCtx.appDir, curCtx.appPort, { onStderr(msg) { curCtx.nextOutput += msg }, - env: { - NEXT_SHARP_PATH: curCtx.isSharp - ? join(curCtx.appDir, 'node_modules', 'sharp') - : '', - }, cwd: curCtx.appDir, }) }) @@ -1405,53 +1357,8 @@ export const setupTests = (ctx) => { }) runTests(curCtx) - }) - ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( - 'Production Mode Server support w/o next.config.js', - () => { - if (ctx.nextConfigImages) { - // skip this test because it requires next.config.js - return - } - const size = 384 // defaults defined in server/config.ts - const curCtx = { - ...ctx, - w: size, - isDev: false, - } - beforeAll(async () => { - const json = JSON.stringify({ - experimental: { - outputFileTracingRoot: join(__dirname, '../../../..'), - }, - }) - nextConfig.replace('{ /* replaceme */ }', json) - curCtx.nextOutput = '' - await nextBuild(curCtx.appDir) - await cleanImagesDir(ctx) - curCtx.appPort = await findPort() - curCtx.app = await nextStart(curCtx.appDir, curCtx.appPort, { - onStderr(msg) { - curCtx.nextOutput += msg - }, - env: { - NEXT_SHARP_PATH: curCtx.isSharp - ? join(curCtx.appDir, 'node_modules', 'sharp') - : '', - }, - cwd: curCtx.appDir, - }) - }) - afterAll(async () => { - nextConfig.restore() - if (curCtx.app) await killApp(curCtx.app) - }) - - runTests(curCtx) - } - ) - } - + } + ) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'Production Mode Server support with next.config.js', () => { @@ -1482,20 +1389,6 @@ export const setupTests = (ctx) => { }) curCtx.nextOutput = '' nextConfig.replace('{ /* replaceme */ }', json) - - if (curCtx.isSharp) { - await fs.writeFile( - join(curCtx.appDir, 'pages', 'api', 'custom-sharp.js'), - ` - import sharp from 'sharp' - export default function handler(req, res) { - console.log(sharp) - res.json({ success: true }) - } - ` - ) - } - await nextBuild(curCtx.appDir) await cleanImagesDir(ctx) curCtx.appPort = await findPort() @@ -1503,21 +1396,11 @@ export const setupTests = (ctx) => { onStderr(msg) { curCtx.nextOutput += msg }, - env: { - NEXT_SHARP_PATH: curCtx.isSharp - ? join(curCtx.appDir, 'node_modules', 'sharp') - : '', - }, cwd: curCtx.appDir, }) }) afterAll(async () => { nextConfig.restore() - if (curCtx.isSharp) { - await fs.remove( - join(curCtx.appDir, 'pages', 'api', 'custom-sharp.js') - ) - } if (curCtx.app) await killApp(curCtx.app) }) diff --git a/test/integration/next-image-legacy/base-path/test/static.test.ts b/test/integration/next-image-legacy/base-path/test/static.test.ts index 12b1e666ce..bf5dc4b543 100644 --- a/test/integration/next-image-legacy/base-path/test/static.test.ts +++ b/test/integration/next-image-legacy/base-path/test/static.test.ts @@ -78,7 +78,7 @@ const runTests = (isDev = false) => { `style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;background-size:cover;background-position:0% 0%;filter:blur(20px);background-image:url(${ isDev ? '"/docs/_next/image?url=%2Fdocs%2F_next%2Fstatic%2Fmedia%2Ftest.fab2915d.jpg&w=8&q=70"' - : '"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoKCgoKCgsMDAsPEA4QDxYUExMUFiIYGhgaGCIzICUgICUgMy03LCksNy1RQDg4QFFeT0pPXnFlZXGPiI+7u/sBCgoKCgoKCwwMCw8QDhAPFhQTExQWIhgaGBoYIjMgJSAgJSAzLTcsKSw3LVFAODhAUV5PSk9ecWVlcY+Ij7u7+//CABEIAAYACAMBIgACEQEDEQH/xAAnAAEBAAAAAAAAAAAAAAAAAAAABwEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAAmgP/xAAcEAACAQUBAAAAAAAAAAAAAAASFBMAAQMFERX/2gAIAQEAAT8AZ1HjrKZX55JysIc4Ff/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Af//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Af//Z"' + : '"data:image/jpeg;base64,/9j/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wgARCAAGAAgDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAGUB//EABYQAAMAAAAAAAAAAAAAAAAAAAMSE//aAAgBAQABBQJhQ//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Bf//EABoQAAEFAQAAAAAAAAAAAAAAABIAARETMkH/2gAIAQEABj8CEHsLU8X/xAAYEAACAwAAAAAAAAAAAAAAAAAAEUFhcf/aAAgBAQABPyHSKKiP/9oADAMBAAIAAwAAABAD/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPxB//8QAGRAAAQUAAAAAAAAAAAAAAAAAEQAhMVHR/9oACAEBAAE/EMvICK3JX//Z"' })` ) } @@ -93,7 +93,7 @@ const runTests = (isDev = false) => { `style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;background-size:cover;background-position:0% 0%;filter:blur(20px);background-image:url(${ isDev ? '"/docs/_next/image?url=%2Fdocs%2F_next%2Fstatic%2Fmedia%2Ftest.3f1a293b.png&w=8&q=70"' - : '"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAICAAAAAAZhBqgAAAAJklEQVR42mNgkmBkYGXgZGBoY2Co/lPAcOf/dYaCzHwGEBAVEwUAZZIG0TbWicQAAAAASUVORK5CYII="' + : '"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAICAMAAAALMbVOAAAAFVBMVEUBAQEtLS1CQkIHBwf9/f21tbWurq5/IXexAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAHElEQVR4nGNggAJmJmYGJhYmBlYWNgZGRkaYMAACTwAjtdG5RQAAAABJRU5ErkJggg=="' })` ) } diff --git a/test/integration/next-image-legacy/default/test/static.test.ts b/test/integration/next-image-legacy/default/test/static.test.ts index d1eec3c9ae..5baa3f96dc 100644 --- a/test/integration/next-image-legacy/default/test/static.test.ts +++ b/test/integration/next-image-legacy/default/test/static.test.ts @@ -66,12 +66,12 @@ const runTests = () => { }) it('Should add a blur placeholder to statically imported jpg', async () => { expect(html).toContain( - `style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;background-size:cover;background-position:0% 0%;filter:blur(20px);background-image:url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoKCgoKCgsMDAsPEA4QDxYUExMUFiIYGhgaGCIzICUgICUgMy03LCksNy1RQDg4QFFeT0pPXnFlZXGPiI+7u/sBCgoKCgoKCwwMCw8QDhAPFhQTExQWIhgaGBoYIjMgJSAgJSAzLTcsKSw3LVFAODhAUV5PSk9ecWVlcY+Ij7u7+//CABEIAAYACAMBIgACEQEDEQH/xAAnAAEBAAAAAAAAAAAAAAAAAAAABwEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAAmgP/xAAcEAACAQUBAAAAAAAAAAAAAAASFBMAAQMFERX/2gAIAQEAAT8AZ1HjrKZX55JysIc4Ff/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Af//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Af//Z")"` + `style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;background-size:cover;background-position:0% 0%;filter:blur(20px);background-image:url("data:image/jpeg;base64,/9j/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wgARCAAGAAgDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAGUB//EABYQAAMAAAAAAAAAAAAAAAAAAAMSE//aAAgBAQABBQJhQ//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Bf//EABoQAAEFAQAAAAAAAAAAAAAAABIAARETMkH/2gAIAQEABj8CEHsLU8X/xAAYEAACAwAAAAAAAAAAAAAAAAAAEUFhcf/aAAgBAQABPyHSKKiP/9oADAMBAAIAAwAAABAD/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPxB//8QAGRAAAQUAAAAAAAAAAAAAAAAAEQAhMVHR/9oACAEBAAE/EMvICK3JX//Z")"` ) }) it('Should add a blur placeholder to statically imported png', async () => { expect(html).toContain( - `style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;background-size:cover;background-position:0% 0%;filter:blur(20px);background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAAOklEQVR42iWGsQkAIBDE0iuIdiLOJjiGIzjiL/Meb4okiNYIlLjK3hJMzCQG1/0qmXXOUkjAV+m9wAMe3QiV6Ne8VgAAAABJRU5ErkJggg==")` + `style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;background-size:cover;background-position:0% 0%;filter:blur(20px);background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAICAMAAAALMbVOAAAAFVBMVEUBAQEtLS1CQkIHBwf9/f21tbWurq5/IXexAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAHElEQVR4nGNggAJmJmYGJhYmBlYWNgZGRkaYMAACTwAjtdG5RQAAAABJRU5ErkJggg==")` ) }) diff --git a/test/integration/next-image-new/app-dir/test/static.test.ts b/test/integration/next-image-new/app-dir/test/static.test.ts index a5365f143a..48d31f40d4 100644 --- a/test/integration/next-image-new/app-dir/test/static.test.ts +++ b/test/integration/next-image-new/app-dir/test/static.test.ts @@ -140,7 +140,7 @@ const runTests = (isDev) => { ) } else { expect(style).toBe( - `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 240'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoKCgoKCgsMDAsPEA4QDxYUExMUFiIYGhgaGCIzICUgICUgMy03LCksNy1RQDg4QFFeT0pPXnFlZXGPiI+7u/sBCgoKCgoKCwwMCw8QDhAPFhQTExQWIhgaGBoYIjMgJSAgJSAzLTcsKSw3LVFAODhAUV5PSk9ecWVlcY+Ij7u7+//CABEIAAYACAMBIgACEQEDEQH/xAAnAAEBAAAAAAAAAAAAAAAAAAAABwEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAAmgP/xAAcEAACAQUBAAAAAAAAAAAAAAASFBMAAQMFERX/2gAIAQEAAT8AZ1HjrKZX55JysIc4Ff/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Af//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Af//Z'/%3E%3C/svg%3E")` + `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 240'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/jpeg;base64,/9j/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wgARCAAGAAgDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAGUB//EABYQAAMAAAAAAAAAAAAAAAAAAAMSE//aAAgBAQABBQJhQ//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Bf//EABoQAAEFAQAAAAAAAAAAAAAAABIAARETMkH/2gAIAQEABj8CEHsLU8X/xAAYEAACAwAAAAAAAAAAAAAAAAAAEUFhcf/aAAgBAQABPyHSKKiP/9oADAMBAAIAAwAAABAD/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPxB//8QAGRAAAQUAAAAAAAAAAAAAAAAAEQAhMVHR/9oACAEBAAE/EMvICK3JX//Z'/%3E%3C/svg%3E")` ) } } @@ -165,7 +165,7 @@ const runTests = (isDev) => { ) } else { expect(style).toBe( - `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAAOklEQVR42iWGsQkAIBDE0iuIdiLOJjiGIzjiL/Meb4okiNYIlLjK3hJMzCQG1/0qmXXOUkjAV+m9wAMe3QiV6Ne8VgAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` + `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAElBMVEUAAAA6OjolJSWwsLAfHx/9/f2oxsg2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAH0lEQVR4nGNgwAaYmKAMZmYIzcjKyghmsDAysmDTAgAEXAAhXbseDQAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` ) } } @@ -190,7 +190,7 @@ const runTests = (isDev) => { ) } else { expect(style).toBe( - `position:absolute;height:100%;width:100%;left:0;top:0;right:0;bottom:0;color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAAOklEQVR42iWGsQkAIBDE0iuIdiLOJjiGIzjiL/Meb4okiNYIlLjK3hJMzCQG1/0qmXXOUkjAV+m9wAMe3QiV6Ne8VgAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` + `position:absolute;height:100%;width:100%;left:0;top:0;right:0;bottom:0;color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAElBMVEUAAAA6OjolJSWwsLAfHx/9/f2oxsg2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAH0lEQVR4nGNgwAaYmKAMZmYIzcjKyghmsDAysmDTAgAEXAAhXbseDQAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` ) } } diff --git a/test/integration/next-image-new/base-path/test/static.test.js b/test/integration/next-image-new/base-path/test/static.test.js index 58006097f3..0cb99f4efa 100644 --- a/test/integration/next-image-new/base-path/test/static.test.js +++ b/test/integration/next-image-new/base-path/test/static.test.js @@ -135,7 +135,7 @@ const runTests = (isDev) => { ) } else { expect(style).toBe( - `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 240'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoKCgoKCgsMDAsPEA4QDxYUExMUFiIYGhgaGCIzICUgICUgMy03LCksNy1RQDg4QFFeT0pPXnFlZXGPiI+7u/sBCgoKCgoKCwwMCw8QDhAPFhQTExQWIhgaGBoYIjMgJSAgJSAzLTcsKSw3LVFAODhAUV5PSk9ecWVlcY+Ij7u7+//CABEIAAYACAMBIgACEQEDEQH/xAAnAAEBAAAAAAAAAAAAAAAAAAAABwEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAAmgP/xAAcEAACAQUBAAAAAAAAAAAAAAASFBMAAQMFERX/2gAIAQEAAT8AZ1HjrKZX55JysIc4Ff/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Af//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Af//Z'/%3E%3C/svg%3E")` + `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 240'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/jpeg;base64,/9j/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wgARCAAGAAgDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAGUB//EABYQAAMAAAAAAAAAAAAAAAAAAAMSE//aAAgBAQABBQJhQ//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Bf//EABoQAAEFAQAAAAAAAAAAAAAAABIAARETMkH/2gAIAQEABj8CEHsLU8X/xAAYEAACAwAAAAAAAAAAAAAAAAAAEUFhcf/aAAgBAQABPyHSKKiP/9oADAMBAAIAAwAAABAD/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPxB//8QAGRAAAQUAAAAAAAAAAAAAAAAAEQAhMVHR/9oACAEBAAE/EMvICK3JX//Z'/%3E%3C/svg%3E")` ) } } @@ -160,7 +160,7 @@ const runTests = (isDev) => { ) } else { expect(style).toBe( - `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAAOklEQVR42iWGsQkAIBDE0iuIdiLOJjiGIzjiL/Meb4okiNYIlLjK3hJMzCQG1/0qmXXOUkjAV+m9wAMe3QiV6Ne8VgAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` + `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAElBMVEUAAAA6OjolJSWwsLAfHx/9/f2oxsg2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAH0lEQVR4nGNgwAaYmKAMZmYIzcjKyghmsDAysmDTAgAEXAAhXbseDQAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` ) } } diff --git a/test/integration/next-image-new/default/test/static.test.ts b/test/integration/next-image-new/default/test/static.test.ts index 4377bda5c2..e6a1e8b65d 100644 --- a/test/integration/next-image-new/default/test/static.test.ts +++ b/test/integration/next-image-new/default/test/static.test.ts @@ -140,7 +140,7 @@ const runTests = (isDev) => { ) } else { expect(style).toBe( - `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 240'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoKCgoKCgsMDAsPEA4QDxYUExMUFiIYGhgaGCIzICUgICUgMy03LCksNy1RQDg4QFFeT0pPXnFlZXGPiI+7u/sBCgoKCgoKCwwMCw8QDhAPFhQTExQWIhgaGBoYIjMgJSAgJSAzLTcsKSw3LVFAODhAUV5PSk9ecWVlcY+Ij7u7+//CABEIAAYACAMBIgACEQEDEQH/xAAnAAEBAAAAAAAAAAAAAAAAAAAABwEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAAmgP/xAAcEAACAQUBAAAAAAAAAAAAAAASFBMAAQMFERX/2gAIAQEAAT8AZ1HjrKZX55JysIc4Ff/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Af//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Af//Z'/%3E%3C/svg%3E")` + `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 240'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/jpeg;base64,/9j/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wgARCAAGAAgDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAGUB//EABYQAAMAAAAAAAAAAAAAAAAAAAMSE//aAAgBAQABBQJhQ//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Bf//EABoQAAEFAQAAAAAAAAAAAAAAABIAARETMkH/2gAIAQEABj8CEHsLU8X/xAAYEAACAwAAAAAAAAAAAAAAAAAAEUFhcf/aAAgBAQABPyHSKKiP/9oADAMBAAIAAwAAABAD/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPxB//8QAGRAAAQUAAAAAAAAAAAAAAAAAEQAhMVHR/9oACAEBAAE/EMvICK3JX//Z'/%3E%3C/svg%3E")` ) } } @@ -165,7 +165,7 @@ const runTests = (isDev) => { ) } else { expect(style).toBe( - `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAAOklEQVR42iWGsQkAIBDE0iuIdiLOJjiGIzjiL/Meb4okiNYIlLjK3hJMzCQG1/0qmXXOUkjAV+m9wAMe3QiV6Ne8VgAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` + `color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAElBMVEUAAAA6OjolJSWwsLAfHx/9/f2oxsg2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAH0lEQVR4nGNgwAaYmKAMZmYIzcjKyghmsDAysmDTAgAEXAAhXbseDQAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` ) } } @@ -190,7 +190,7 @@ const runTests = (isDev) => { ) } else { expect(style).toBe( - `position:absolute;height:100%;width:100%;left:0;top:0;right:0;bottom:0;color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAAOklEQVR42iWGsQkAIBDE0iuIdiLOJjiGIzjiL/Meb4okiNYIlLjK3hJMzCQG1/0qmXXOUkjAV+m9wAMe3QiV6Ne8VgAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` + `position:absolute;height:100%;width:100%;left:0;top:0;right:0;bottom:0;color:transparent;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 320'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='none' style='filter: url(%23b);' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAElBMVEUAAAA6OjolJSWwsLAfHx/9/f2oxsg2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAH0lEQVR4nGNgwAaYmKAMZmYIzcjKyghmsDAysmDTAgAEXAAhXbseDQAAAABJRU5ErkJggg=='/%3E%3C/svg%3E")` ) } } diff --git a/test/integration/sharp-api/app/.gitignore b/test/integration/sharp-api/app/.gitignore new file mode 100644 index 0000000000..c1b956175e --- /dev/null +++ b/test/integration/sharp-api/app/.gitignore @@ -0,0 +1,2 @@ +node_modules +!package-lock.json \ No newline at end of file diff --git a/test/integration/sharp-api/app/package-lock.json b/test/integration/sharp-api/app/package-lock.json new file mode 100644 index 0000000000..5667d9956f --- /dev/null +++ b/test/integration/sharp-api/app/package-lock.json @@ -0,0 +1,585 @@ +{ + "name": "app", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "sharp": "latest" + } + }, + "node_modules/@emnapi/runtime": { + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-0.45.0.tgz", + "integrity": "sha512-Txumi3td7J4A/xTTwlssKieHKTGl3j4A1tglBx72auZ49YK7ePY6XZricgIg9mnZT4xPfA+UPCUdnhRuEFDL+w==", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.2.tgz", + "integrity": "sha512-itHBs1rPmsmGF9p4qRe++CzCgd+kFYktnsoR1sbIAfsRMrJZau0Tt1AH9KVnufc2/tU02Gf6Ibujx+15qRE03w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.0.1" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.2.tgz", + "integrity": "sha512-/rK/69Rrp9x5kaWBjVN07KixZanRr+W1OiyKdXcbjQD6KbW+obaTeBBtLUAtbBsnlTTmWthw99xqoOS7SsySDg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.0.1" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.1.tgz", + "integrity": "sha512-kQyrSNd6lmBV7O0BUiyu/OEw9yeNGFbQhbxswS1i6rMDwBBSX+e+rPzu3S+MwAiGU3HdLze3PanQ4Xkfemgzcw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "macos": ">=11", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.1.tgz", + "integrity": "sha512-eVU/JYLPVjhhrd8Tk6gosl5pVlvsqiFlt50wotCvdkFGf+mDNBJxMh+bvav+Wt3EBnNZWq8Sp2I7XfSjm8siog==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "macos": ">=10.13", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.1.tgz", + "integrity": "sha512-FtdMvR4R99FTsD53IA3LxYGghQ82t3yt0ZQ93WMZ2xV3dqrb0E8zq4VHaTOuLEAuA83oDawHV3fd+BsAPadHIQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.1.tgz", + "integrity": "sha512-bnGG+MJjdX70mAQcSLxgeJco11G+MxTz+ebxlz8Y3dxyeb3Nkl7LgLI0mXupoO+u1wRNx/iRj5yHtzA4sde1yA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.1.tgz", + "integrity": "sha512-3+rzfAR1YpMOeA2zZNp+aYEzGNWK4zF3+sdMxuCS3ey9HhDbJ66w6hDSHDMoap32DueFwhhs3vwooAB2MaK4XQ==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.1.tgz", + "integrity": "sha512-3NR1mxFsaSgMMzz1bAnnKbSAI+lHXVTqAHgc1bgzjHuXjo4hlscpUxc0vFSAPKI3yuzdzcZOkq7nDPrP2F8Jgw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.1.tgz", + "integrity": "sha512-5aBRcjHDG/T6jwC3Edl3lP8nl9U2Yo8+oTl5drd1dh9Z1EBfzUKAJFUDTDisDjUwc7N4AjnPGfCA3jl3hY8uDg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.1.tgz", + "integrity": "sha512-dcT7inI9DBFK6ovfeWRe3hG30h51cBAP5JXlZfx6pzc/Mnf9HFCQDLtYf4MCBjxaaTfjCCjkBxcy3XzOAo5txw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.2.tgz", + "integrity": "sha512-Fndk/4Zq3vAc4G/qyfXASbS3HBZbKrlnKZLEJzPLrXoJuipFNNwTes71+Ki1hwYW5lch26niRYoZFAtZVf3EGA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.0.1" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.2.tgz", + "integrity": "sha512-pz0NNo882vVfqJ0yNInuG9YH71smP4gRSdeL09ukC2YLE6ZyZePAlWKEHgAzJGTiOh8Qkaov6mMIMlEhmLdKew==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.0.1" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.2.tgz", + "integrity": "sha512-MBoInDXDppMfhSzbMmOQtGfloVAflS2rP1qPcUIiITMi36Mm5YR7r0ASND99razjQUpHTzjrU1flO76hKvP5RA==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.0.1" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.2.tgz", + "integrity": "sha512-xUT82H5IbXewKkeF5aiooajoO1tQV4PnKfS/OZtb5DDdxS/FCI/uXTVZ35GQ97RZXsycojz/AJ0asoz6p2/H/A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.0.1" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.2.tgz", + "integrity": "sha512-F+0z8JCu/UnMzg8IYW1TMeiViIWBVg7IWP6nE0p5S5EPQxlLd76c8jYemG21X99UzFwgkRo5yz2DS+zbrnxZeA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.0.1" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.2.tgz", + "integrity": "sha512-+ZLE3SQmSL+Fn1gmSaM8uFusW5Y3J9VOf+wMGNnTtJUMUxFhv+P4UPaYEYT8tqnyYVaOVGgMN/zsOxn9pSsO2A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.0.1" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.2.tgz", + "integrity": "sha512-fLbTaESVKuQcpm8ffgBD7jLb/CQLcATju/jxtTXR1XCLwbOQt+OL5zPHSDMmp2JZIeq82e18yE0Vv7zh6+6BfQ==", + "cpu": [ + "wasm32" + ], + "optional": true, + "dependencies": { + "@emnapi/runtime": "^0.45.0" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.2.tgz", + "integrity": "sha512-okBpql96hIGuZ4lN3+nsAjGeggxKm7hIRu9zyec0lnfB8E7Z6p95BuRZzDDXZOl2e8UmR4RhYt631i7mfmKU8g==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.2.tgz", + "integrity": "sha512-E4magOks77DK47FwHUIGH0RYWSgRBfGdK56kIHSVeB9uIS4pPFr4N2kIVsXdQQo4LzOsENKV5KAhRlRL7eMAdg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/color": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", + "dependencies": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + }, + "engines": { + "node": ">=12.5.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/color-string": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", + "dependencies": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, + "node_modules/detect-libc": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", + "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sharp": { + "version": "0.33.2", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.2.tgz", + "integrity": "sha512-WlYOPyyPDiiM07j/UO+E720ju6gtNtHjEGg5vovUk1Lgxyjm2LFO+37Nt/UI3MMh2l6hxTWQWi7qk3cXJTutcQ==", + "hasInstallScript": true, + "dependencies": { + "color": "^4.2.3", + "detect-libc": "^2.0.2", + "semver": "^7.5.4" + }, + "engines": { + "libvips": ">=8.15.1", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.33.2", + "@img/sharp-darwin-x64": "0.33.2", + "@img/sharp-libvips-darwin-arm64": "1.0.1", + "@img/sharp-libvips-darwin-x64": "1.0.1", + "@img/sharp-libvips-linux-arm": "1.0.1", + "@img/sharp-libvips-linux-arm64": "1.0.1", + "@img/sharp-libvips-linux-s390x": "1.0.1", + "@img/sharp-libvips-linux-x64": "1.0.1", + "@img/sharp-libvips-linuxmusl-arm64": "1.0.1", + "@img/sharp-libvips-linuxmusl-x64": "1.0.1", + "@img/sharp-linux-arm": "0.33.2", + "@img/sharp-linux-arm64": "0.33.2", + "@img/sharp-linux-s390x": "0.33.2", + "@img/sharp-linux-x64": "0.33.2", + "@img/sharp-linuxmusl-arm64": "0.33.2", + "@img/sharp-linuxmusl-x64": "0.33.2", + "@img/sharp-wasm32": "0.33.2", + "@img/sharp-win32-ia32": "0.33.2", + "@img/sharp-win32-x64": "0.33.2" + } + }, + "node_modules/simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", + "dependencies": { + "is-arrayish": "^0.3.1" + } + }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "optional": true + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } +} diff --git a/test/integration/sharp-api/app/package.json b/test/integration/sharp-api/app/package.json new file mode 100644 index 0000000000..c7c828e672 --- /dev/null +++ b/test/integration/sharp-api/app/package.json @@ -0,0 +1,7 @@ +{ + "private": true, + "packageManager": "npm@10.4.0", + "dependencies": { + "sharp": "latest" + } +} diff --git a/test/integration/sharp-api/app/pages/api/custom-sharp.js b/test/integration/sharp-api/app/pages/api/custom-sharp.js new file mode 100644 index 0000000000..ed872ac7df --- /dev/null +++ b/test/integration/sharp-api/app/pages/api/custom-sharp.js @@ -0,0 +1,5 @@ +import sharp from 'sharp' + +export default function handler(req, res) { + res.json({ success: Boolean(sharp) }) +} diff --git a/test/integration/sharp-api/test/sharp-api.test.ts b/test/integration/sharp-api/test/sharp-api.test.ts new file mode 100644 index 0000000000..c4000ded5f --- /dev/null +++ b/test/integration/sharp-api/test/sharp-api.test.ts @@ -0,0 +1,50 @@ +/* eslint-env jest */ + +import { + fetchViaHTTP, + findPort, + killApp, + nextBuild, + nextStart, +} from 'next-test-utils' +import execa from 'execa' +import fs from 'fs-extra' +import { join } from 'path' + +const appDir = join(__dirname, '../app') +let app, + appPort + + // Skip as Turbopack doesn't support `next build` yet +;(process.env.TURBOPACK ? describe.skip : describe)('sharp api', () => { + beforeAll(async () => { + await execa('npm', ['install'], { cwd: appDir, stdio: 'inherit' }) + await nextBuild(appDir) + appPort = await findPort() + app = await nextStart(appDir, appPort) + }) + afterAll(async () => { + if (app) { + await killApp(app) + } + await fs.remove(join(appDir, '.next')) + await fs.remove(join(appDir, 'node_modules')) + }) + + it('should handle custom sharp usage', async () => { + const res = await fetchViaHTTP(appPort, '/api/custom-sharp') + expect(res.status).toBe(200) + expect(await res.json()).toEqual({ success: true }) + const traceFile = await fs.readJson( + join( + appDir, + '.next', + 'server', + 'pages', + 'api', + 'custom-sharp.js.nft.json' + ) + ) + expect(traceFile.files.some((file) => file.includes('sharp/'))).toBe(true) + }) +}) diff --git a/test/production/pages-dir/production/test/index.test.ts b/test/production/pages-dir/production/test/index.test.ts index 8b70938940..c5c636dc86 100644 --- a/test/production/pages-dir/production/test/index.test.ts +++ b/test/production/pages-dir/production/test/index.test.ts @@ -178,7 +178,7 @@ createNextDescribe( ).toBe(false) expect( serverTrace.files.some((file) => file.includes('node_modules/sharp')) - ).toBe(false) + ).toBe(true) } const checks = [ diff --git a/test/turbopack-build-tests-manifest.json b/test/turbopack-build-tests-manifest.json index 327e90af29..32a5b24321 100644 --- a/test/turbopack-build-tests-manifest.json +++ b/test/turbopack-build-tests-manifest.json @@ -10904,71 +10904,6 @@ "flakey": [], "runtimeError": false }, - "test/integration/image-optimizer/test/old-sharp.test.ts": { - "passed": [], - "failed": [ - "with outdated sharp Production Mode Server support with next.config.js should automatically detect image type when content-type is octet-stream", - "with outdated sharp Production Mode Server support with next.config.js should compress avif smaller than webp at q=100", - "with outdated sharp Production Mode Server support with next.config.js should compress avif smaller than webp at q=50", - "with outdated sharp Production Mode Server support with next.config.js should compress avif smaller than webp at q=75", - "with outdated sharp Production Mode Server support with next.config.js should downlevel webp format to jpeg for old Safari", - "with outdated sharp Production Mode Server support with next.config.js should emit blur svg when width is 8 in dev but not prod", - "with outdated sharp Production Mode Server support with next.config.js should emit blur svg when width is less than 8 in dev but not prod", - "with outdated sharp Production Mode Server support with next.config.js should error if the image file does not exist", - "with outdated sharp Production Mode Server support with next.config.js should error if the resource isn't a valid image", - "with outdated sharp Production Mode Server support with next.config.js should fail when domain is not defined in next.config.js", - "with outdated sharp Production Mode Server support with next.config.js should fail when internal url is not an image", - "with outdated sharp Production Mode Server support with next.config.js should fail when q is greater than 100", - "with outdated sharp Production Mode Server support with next.config.js should fail when q is less than 1", - "with outdated sharp Production Mode Server support with next.config.js should fail when q is missing", - "with outdated sharp Production Mode Server support with next.config.js should fail when q is not a number", - "with outdated sharp Production Mode Server support with next.config.js should fail when url fails to load an image", - "with outdated sharp Production Mode Server support with next.config.js should fail when url has file protocol", - "with outdated sharp Production Mode Server support with next.config.js should fail when url has ftp protocol", - "with outdated sharp Production Mode Server support with next.config.js should fail when url is missing", - "with outdated sharp Production Mode Server support with next.config.js should fail when w is 0", - "with outdated sharp Production Mode Server support with next.config.js should fail when w is less than 0", - "with outdated sharp Production Mode Server support with next.config.js should fail when w is missing", - "with outdated sharp Production Mode Server support with next.config.js should fail when w is not a number", - "with outdated sharp Production Mode Server support with next.config.js should fail when width is not in next.config.js", - "with outdated sharp Production Mode Server support with next.config.js should handle concurrent requests", - "with outdated sharp Production Mode Server support with next.config.js should handle custom sharp usage", - "with outdated sharp Production Mode Server support with next.config.js should handle non-ascii characters in image url", - "with outdated sharp Production Mode Server support with next.config.js should have sharp outdated warning", - "with outdated sharp Production Mode Server support with next.config.js should maintain animated gif", - "with outdated sharp Production Mode Server support with next.config.js should maintain animated png", - "with outdated sharp Production Mode Server support with next.config.js should maintain animated png 2", - "with outdated sharp Production Mode Server support with next.config.js should maintain animated webp", - "with outdated sharp Production Mode Server support with next.config.js should maintain bmp", - "with outdated sharp Production Mode Server support with next.config.js should maintain ico format", - "with outdated sharp Production Mode Server support with next.config.js should maintain jpg format for old Safari", - "with outdated sharp Production Mode Server support with next.config.js should maintain png format for old Safari", - "with outdated sharp Production Mode Server support with next.config.js should normalize invalid status codes", - "with outdated sharp Production Mode Server support with next.config.js should not allow svg with application header", - "with outdated sharp Production Mode Server support with next.config.js should not allow svg with comma header", - "with outdated sharp Production Mode Server support with next.config.js should not allow svg with uppercase header", - "with outdated sharp Production Mode Server support with next.config.js should not allow vector svg", - "with outdated sharp Production Mode Server support with next.config.js should not have sharp missing warning", - "with outdated sharp Production Mode Server support with next.config.js should not resize if requested width is larger than original source image", - "with outdated sharp Production Mode Server support with next.config.js should resize absolute url from localhost", - "with outdated sharp Production Mode Server support with next.config.js should resize relative url and new Chrome accept header as avif", - "with outdated sharp Production Mode Server support with next.config.js should resize relative url and old Chrome accept header as webp", - "with outdated sharp Production Mode Server support with next.config.js should resize relative url and png accept header", - "with outdated sharp Production Mode Server support with next.config.js should resize relative url and webp Firefox accept header", - "with outdated sharp Production Mode Server support with next.config.js should resize relative url with invalid accept header as gif", - "with outdated sharp Production Mode Server support with next.config.js should resize relative url with invalid accept header as png", - "with outdated sharp Production Mode Server support with next.config.js should resize relative url with invalid accept header as tiff", - "with outdated sharp Production Mode Server support with next.config.js should return home page", - "with outdated sharp Production Mode Server support with next.config.js should set 304 status without body when etag matches if-none-match", - "with outdated sharp Production Mode Server support with next.config.js should set cache-control to immutable for static images", - "with outdated sharp Production Mode Server support with next.config.js should use cache and stale-while-revalidate when query is the same for external image", - "with outdated sharp Production Mode Server support with next.config.js should use cache and stale-while-revalidate when query is the same for internal image", - "with outdated sharp Production Mode Server support with next.config.js should use cached image file when parameters are the same for animated gif" - ], - "pending": [], - "flakey": [], - "runtimeError": false - }, "test/integration/image-optimizer/test/sharp.test.ts": { "passed": [ "with latest sharp dev support w/o next.config.js should downlevel avif format to jpeg for old Safari", @@ -11187,227 +11122,6 @@ "flakey": [], "runtimeError": false }, - "test/integration/image-optimizer/test/squoosh.test.ts": { - "passed": [ - "with squoosh dev support w/o next.config.js should downlevel avif format to jpeg for old Safari", - "with squoosh dev support w/o next.config.js should downlevel webp format to jpeg for old Safari", - "with squoosh dev support w/o next.config.js should emit blur svg when width is 8 in dev but not prod", - "with squoosh dev support w/o next.config.js should emit blur svg when width is less than 8 in dev but not prod", - "with squoosh dev support w/o next.config.js should error if the image file does not exist", - "with squoosh dev support w/o next.config.js should error if the resource isn't a valid image", - "with squoosh dev support w/o next.config.js should fail when domain is not defined in next.config.js", - "with squoosh dev support w/o next.config.js should fail when internal url is not an image", - "with squoosh dev support w/o next.config.js should fail when q is greater than 100", - "with squoosh dev support w/o next.config.js should fail when q is less than 1", - "with squoosh dev support w/o next.config.js should fail when q is missing", - "with squoosh dev support w/o next.config.js should fail when q is not a number", - "with squoosh dev support w/o next.config.js should fail when url has file protocol", - "with squoosh dev support w/o next.config.js should fail when url has ftp protocol", - "with squoosh dev support w/o next.config.js should fail when url is missing", - "with squoosh dev support w/o next.config.js should fail when w is 0", - "with squoosh dev support w/o next.config.js should fail when w is less than 0", - "with squoosh dev support w/o next.config.js should fail when w is missing", - "with squoosh dev support w/o next.config.js should fail when w is not a number", - "with squoosh dev support w/o next.config.js should fail when width is not in next.config.js", - "with squoosh dev support w/o next.config.js should handle non-ascii characters in image url", - "with squoosh dev support w/o next.config.js should maintain animated gif", - "with squoosh dev support w/o next.config.js should maintain animated png", - "with squoosh dev support w/o next.config.js should maintain animated png 2", - "with squoosh dev support w/o next.config.js should maintain animated webp", - "with squoosh dev support w/o next.config.js should maintain bmp", - "with squoosh dev support w/o next.config.js should maintain ico format", - "with squoosh dev support w/o next.config.js should maintain jpg format for old Safari", - "with squoosh dev support w/o next.config.js should maintain png format for old Safari", - "with squoosh dev support w/o next.config.js should not allow svg with application header", - "with squoosh dev support w/o next.config.js should not allow svg with comma header", - "with squoosh dev support w/o next.config.js should not allow svg with uppercase header", - "with squoosh dev support w/o next.config.js should not allow vector svg", - "with squoosh dev support w/o next.config.js should not change the color type of a png", - "with squoosh dev support w/o next.config.js should not have sharp missing warning", - "with squoosh dev support w/o next.config.js should not have sharp outdated warning", - "with squoosh dev support w/o next.config.js should not resize if requested width is larger than original source image", - "with squoosh dev support w/o next.config.js should resize relative url and old Chrome accept header as webp", - "with squoosh dev support w/o next.config.js should resize relative url and png accept header", - "with squoosh dev support w/o next.config.js should resize relative url and webp Firefox accept header", - "with squoosh dev support w/o next.config.js should resize relative url with invalid accept header as gif", - "with squoosh dev support w/o next.config.js should resize relative url with invalid accept header as png", - "with squoosh dev support w/o next.config.js should resize relative url with invalid accept header as tiff", - "with squoosh dev support w/o next.config.js should return home page", - "with squoosh dev support w/o next.config.js should set 304 status without body when etag matches if-none-match", - "with squoosh dev support w/o next.config.js should set cache-control to immutable for static images", - "with squoosh dev support w/o next.config.js should use cache and stale-while-revalidate when query is the same for internal image", - "with squoosh dev support w/o next.config.js should use cached image file when parameters are the same for animated gif", - "with squoosh dev support with next.config.js should automatically detect image type when content-type is octet-stream", - "with squoosh dev support with next.config.js should compress avif smaller than webp at q=100", - "with squoosh dev support with next.config.js should compress avif smaller than webp at q=50", - "with squoosh dev support with next.config.js should compress avif smaller than webp at q=75", - "with squoosh dev support with next.config.js should downlevel avif format to jpeg for old Safari", - "with squoosh dev support with next.config.js should downlevel webp format to jpeg for old Safari", - "with squoosh dev support with next.config.js should emit blur svg when width is 8 in dev but not prod", - "with squoosh dev support with next.config.js should emit blur svg when width is less than 8 in dev but not prod", - "with squoosh dev support with next.config.js should error if the image file does not exist", - "with squoosh dev support with next.config.js should error if the resource isn't a valid image", - "with squoosh dev support with next.config.js should fail when domain is not defined in next.config.js", - "with squoosh dev support with next.config.js should fail when internal url is not an image", - "with squoosh dev support with next.config.js should fail when q is greater than 100", - "with squoosh dev support with next.config.js should fail when q is less than 1", - "with squoosh dev support with next.config.js should fail when q is missing", - "with squoosh dev support with next.config.js should fail when q is not a number", - "with squoosh dev support with next.config.js should fail when url fails to load an image", - "with squoosh dev support with next.config.js should fail when url has file protocol", - "with squoosh dev support with next.config.js should fail when url has ftp protocol", - "with squoosh dev support with next.config.js should fail when url is missing", - "with squoosh dev support with next.config.js should fail when w is 0", - "with squoosh dev support with next.config.js should fail when w is less than 0", - "with squoosh dev support with next.config.js should fail when w is missing", - "with squoosh dev support with next.config.js should fail when w is not a number", - "with squoosh dev support with next.config.js should fail when width is not in next.config.js", - "with squoosh dev support with next.config.js should handle concurrent requests", - "with squoosh dev support with next.config.js should handle non-ascii characters in image url", - "with squoosh dev support with next.config.js should maintain animated gif", - "with squoosh dev support with next.config.js should maintain animated png", - "with squoosh dev support with next.config.js should maintain animated png 2", - "with squoosh dev support with next.config.js should maintain animated webp", - "with squoosh dev support with next.config.js should maintain bmp", - "with squoosh dev support with next.config.js should maintain ico format", - "with squoosh dev support with next.config.js should maintain jpg format for old Safari", - "with squoosh dev support with next.config.js should maintain png format for old Safari", - "with squoosh dev support with next.config.js should normalize invalid status codes", - "with squoosh dev support with next.config.js should not allow svg with application header", - "with squoosh dev support with next.config.js should not allow svg with comma header", - "with squoosh dev support with next.config.js should not allow svg with uppercase header", - "with squoosh dev support with next.config.js should not allow vector svg", - "with squoosh dev support with next.config.js should not change the color type of a png", - "with squoosh dev support with next.config.js should not have sharp missing warning", - "with squoosh dev support with next.config.js should not have sharp outdated warning", - "with squoosh dev support with next.config.js should not resize if requested width is larger than original source image", - "with squoosh dev support with next.config.js should resize absolute url from localhost", - "with squoosh dev support with next.config.js should resize relative url and new Chrome accept header as avif", - "with squoosh dev support with next.config.js should resize relative url and old Chrome accept header as webp", - "with squoosh dev support with next.config.js should resize relative url and png accept header", - "with squoosh dev support with next.config.js should resize relative url and webp Firefox accept header", - "with squoosh dev support with next.config.js should resize relative url with invalid accept header as gif", - "with squoosh dev support with next.config.js should resize relative url with invalid accept header as png", - "with squoosh dev support with next.config.js should resize relative url with invalid accept header as tiff", - "with squoosh dev support with next.config.js should return home page", - "with squoosh dev support with next.config.js should set 304 status without body when etag matches if-none-match", - "with squoosh dev support with next.config.js should set cache-control to immutable for static images", - "with squoosh dev support with next.config.js should use cache and stale-while-revalidate when query is the same for external image", - "with squoosh dev support with next.config.js should use cache and stale-while-revalidate when query is the same for internal image", - "with squoosh dev support with next.config.js should use cached image file when parameters are the same for animated gif" - ], - "failed": [ - "with squoosh Production Mode Server support w/o next.config.js should downlevel avif format to jpeg for old Safari", - "with squoosh Production Mode Server support w/o next.config.js should downlevel webp format to jpeg for old Safari", - "with squoosh Production Mode Server support w/o next.config.js should emit blur svg when width is 8 in dev but not prod", - "with squoosh Production Mode Server support w/o next.config.js should emit blur svg when width is less than 8 in dev but not prod", - "with squoosh Production Mode Server support w/o next.config.js should error if the image file does not exist", - "with squoosh Production Mode Server support w/o next.config.js should error if the resource isn't a valid image", - "with squoosh Production Mode Server support w/o next.config.js should fail when domain is not defined in next.config.js", - "with squoosh Production Mode Server support w/o next.config.js should fail when internal url is not an image", - "with squoosh Production Mode Server support w/o next.config.js should fail when q is greater than 100", - "with squoosh Production Mode Server support w/o next.config.js should fail when q is less than 1", - "with squoosh Production Mode Server support w/o next.config.js should fail when q is missing", - "with squoosh Production Mode Server support w/o next.config.js should fail when q is not a number", - "with squoosh Production Mode Server support w/o next.config.js should fail when url has file protocol", - "with squoosh Production Mode Server support w/o next.config.js should fail when url has ftp protocol", - "with squoosh Production Mode Server support w/o next.config.js should fail when url is missing", - "with squoosh Production Mode Server support w/o next.config.js should fail when w is 0", - "with squoosh Production Mode Server support w/o next.config.js should fail when w is less than 0", - "with squoosh Production Mode Server support w/o next.config.js should fail when w is missing", - "with squoosh Production Mode Server support w/o next.config.js should fail when w is not a number", - "with squoosh Production Mode Server support w/o next.config.js should fail when width is not in next.config.js", - "with squoosh Production Mode Server support w/o next.config.js should handle non-ascii characters in image url", - "with squoosh Production Mode Server support w/o next.config.js should have sharp missing warning", - "with squoosh Production Mode Server support w/o next.config.js should maintain animated gif", - "with squoosh Production Mode Server support w/o next.config.js should maintain animated png", - "with squoosh Production Mode Server support w/o next.config.js should maintain animated png 2", - "with squoosh Production Mode Server support w/o next.config.js should maintain animated webp", - "with squoosh Production Mode Server support w/o next.config.js should maintain bmp", - "with squoosh Production Mode Server support w/o next.config.js should maintain ico format", - "with squoosh Production Mode Server support w/o next.config.js should maintain jpg format for old Safari", - "with squoosh Production Mode Server support w/o next.config.js should maintain png format for old Safari", - "with squoosh Production Mode Server support w/o next.config.js should not allow svg with application header", - "with squoosh Production Mode Server support w/o next.config.js should not allow svg with comma header", - "with squoosh Production Mode Server support w/o next.config.js should not allow svg with uppercase header", - "with squoosh Production Mode Server support w/o next.config.js should not allow vector svg", - "with squoosh Production Mode Server support w/o next.config.js should not change the color type of a png", - "with squoosh Production Mode Server support w/o next.config.js should not have sharp outdated warning", - "with squoosh Production Mode Server support w/o next.config.js should not resize if requested width is larger than original source image", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url and old Chrome accept header as webp", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url and png accept header", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url and webp Firefox accept header", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url with invalid accept header as gif", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url with invalid accept header as png", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url with invalid accept header as tiff", - "with squoosh Production Mode Server support w/o next.config.js should return home page", - "with squoosh Production Mode Server support w/o next.config.js should set 304 status without body when etag matches if-none-match", - "with squoosh Production Mode Server support w/o next.config.js should set cache-control to immutable for static images", - "with squoosh Production Mode Server support w/o next.config.js should use cache and stale-while-revalidate when query is the same for internal image", - "with squoosh Production Mode Server support w/o next.config.js should use cached image file when parameters are the same for animated gif", - "with squoosh Production Mode Server support with next.config.js should automatically detect image type when content-type is octet-stream", - "with squoosh Production Mode Server support with next.config.js should compress avif smaller than webp at q=100", - "with squoosh Production Mode Server support with next.config.js should compress avif smaller than webp at q=50", - "with squoosh Production Mode Server support with next.config.js should compress avif smaller than webp at q=75", - "with squoosh Production Mode Server support with next.config.js should downlevel avif format to jpeg for old Safari", - "with squoosh Production Mode Server support with next.config.js should downlevel webp format to jpeg for old Safari", - "with squoosh Production Mode Server support with next.config.js should emit blur svg when width is 8 in dev but not prod", - "with squoosh Production Mode Server support with next.config.js should emit blur svg when width is less than 8 in dev but not prod", - "with squoosh Production Mode Server support with next.config.js should error if the image file does not exist", - "with squoosh Production Mode Server support with next.config.js should error if the resource isn't a valid image", - "with squoosh Production Mode Server support with next.config.js should fail when domain is not defined in next.config.js", - "with squoosh Production Mode Server support with next.config.js should fail when internal url is not an image", - "with squoosh Production Mode Server support with next.config.js should fail when q is greater than 100", - "with squoosh Production Mode Server support with next.config.js should fail when q is less than 1", - "with squoosh Production Mode Server support with next.config.js should fail when q is missing", - "with squoosh Production Mode Server support with next.config.js should fail when q is not a number", - "with squoosh Production Mode Server support with next.config.js should fail when url fails to load an image", - "with squoosh Production Mode Server support with next.config.js should fail when url has file protocol", - "with squoosh Production Mode Server support with next.config.js should fail when url has ftp protocol", - "with squoosh Production Mode Server support with next.config.js should fail when url is missing", - "with squoosh Production Mode Server support with next.config.js should fail when w is 0", - "with squoosh Production Mode Server support with next.config.js should fail when w is less than 0", - "with squoosh Production Mode Server support with next.config.js should fail when w is missing", - "with squoosh Production Mode Server support with next.config.js should fail when w is not a number", - "with squoosh Production Mode Server support with next.config.js should fail when width is not in next.config.js", - "with squoosh Production Mode Server support with next.config.js should handle concurrent requests", - "with squoosh Production Mode Server support with next.config.js should handle non-ascii characters in image url", - "with squoosh Production Mode Server support with next.config.js should have sharp missing warning", - "with squoosh Production Mode Server support with next.config.js should maintain animated gif", - "with squoosh Production Mode Server support with next.config.js should maintain animated png", - "with squoosh Production Mode Server support with next.config.js should maintain animated png 2", - "with squoosh Production Mode Server support with next.config.js should maintain animated webp", - "with squoosh Production Mode Server support with next.config.js should maintain bmp", - "with squoosh Production Mode Server support with next.config.js should maintain ico format", - "with squoosh Production Mode Server support with next.config.js should maintain jpg format for old Safari", - "with squoosh Production Mode Server support with next.config.js should maintain png format for old Safari", - "with squoosh Production Mode Server support with next.config.js should normalize invalid status codes", - "with squoosh Production Mode Server support with next.config.js should not allow svg with application header", - "with squoosh Production Mode Server support with next.config.js should not allow svg with comma header", - "with squoosh Production Mode Server support with next.config.js should not allow svg with uppercase header", - "with squoosh Production Mode Server support with next.config.js should not allow vector svg", - "with squoosh Production Mode Server support with next.config.js should not change the color type of a png", - "with squoosh Production Mode Server support with next.config.js should not have sharp outdated warning", - "with squoosh Production Mode Server support with next.config.js should not resize if requested width is larger than original source image", - "with squoosh Production Mode Server support with next.config.js should resize absolute url from localhost", - "with squoosh Production Mode Server support with next.config.js should resize relative url and new Chrome accept header as avif", - "with squoosh Production Mode Server support with next.config.js should resize relative url and old Chrome accept header as webp", - "with squoosh Production Mode Server support with next.config.js should resize relative url and png accept header", - "with squoosh Production Mode Server support with next.config.js should resize relative url and webp Firefox accept header", - "with squoosh Production Mode Server support with next.config.js should resize relative url with invalid accept header as gif", - "with squoosh Production Mode Server support with next.config.js should resize relative url with invalid accept header as png", - "with squoosh Production Mode Server support with next.config.js should resize relative url with invalid accept header as tiff", - "with squoosh Production Mode Server support with next.config.js should return home page", - "with squoosh Production Mode Server support with next.config.js should set 304 status without body when etag matches if-none-match", - "with squoosh Production Mode Server support with next.config.js should set cache-control to immutable for static images", - "with squoosh Production Mode Server support with next.config.js should use cache and stale-while-revalidate when query is the same for external image", - "with squoosh Production Mode Server support with next.config.js should use cache and stale-while-revalidate when query is the same for internal image", - "with squoosh Production Mode Server support with next.config.js should use cached image file when parameters are the same for animated gif" - ], - "pending": [], - "flakey": [], - "runtimeError": false - }, "test/integration/import-assertion/test/index.test.js": { "passed": ["import-assertion dev should handle json assertions"], "failed": [ diff --git a/test/turbopack-dev-tests-manifest.json b/test/turbopack-dev-tests-manifest.json index ed04adee3e..0496aba4c5 100644 --- a/test/turbopack-dev-tests-manifest.json +++ b/test/turbopack-dev-tests-manifest.json @@ -13144,227 +13144,6 @@ "flakey": [], "runtimeError": false }, - "test/integration/image-optimizer/test/squoosh.test.ts": { - "passed": [ - "with squoosh dev support w/o next.config.js should downlevel avif format to jpeg for old Safari", - "with squoosh dev support w/o next.config.js should downlevel webp format to jpeg for old Safari", - "with squoosh dev support w/o next.config.js should emit blur svg when width is 8 in dev but not prod", - "with squoosh dev support w/o next.config.js should emit blur svg when width is less than 8 in dev but not prod", - "with squoosh dev support w/o next.config.js should error if the image file does not exist", - "with squoosh dev support w/o next.config.js should error if the resource isn't a valid image", - "with squoosh dev support w/o next.config.js should fail when domain is not defined in next.config.js", - "with squoosh dev support w/o next.config.js should fail when internal url is not an image", - "with squoosh dev support w/o next.config.js should fail when q is greater than 100", - "with squoosh dev support w/o next.config.js should fail when q is less than 1", - "with squoosh dev support w/o next.config.js should fail when q is missing", - "with squoosh dev support w/o next.config.js should fail when q is not a number", - "with squoosh dev support w/o next.config.js should fail when url has file protocol", - "with squoosh dev support w/o next.config.js should fail when url has ftp protocol", - "with squoosh dev support w/o next.config.js should fail when url is missing", - "with squoosh dev support w/o next.config.js should fail when w is 0", - "with squoosh dev support w/o next.config.js should fail when w is less than 0", - "with squoosh dev support w/o next.config.js should fail when w is missing", - "with squoosh dev support w/o next.config.js should fail when w is not a number", - "with squoosh dev support w/o next.config.js should fail when width is not in next.config.js", - "with squoosh dev support w/o next.config.js should handle non-ascii characters in image url", - "with squoosh dev support w/o next.config.js should maintain animated gif", - "with squoosh dev support w/o next.config.js should maintain animated png", - "with squoosh dev support w/o next.config.js should maintain animated png 2", - "with squoosh dev support w/o next.config.js should maintain animated webp", - "with squoosh dev support w/o next.config.js should maintain bmp", - "with squoosh dev support w/o next.config.js should maintain ico format", - "with squoosh dev support w/o next.config.js should maintain jpg format for old Safari", - "with squoosh dev support w/o next.config.js should maintain png format for old Safari", - "with squoosh dev support w/o next.config.js should not allow svg with application header", - "with squoosh dev support w/o next.config.js should not allow svg with comma header", - "with squoosh dev support w/o next.config.js should not allow svg with uppercase header", - "with squoosh dev support w/o next.config.js should not allow vector svg", - "with squoosh dev support w/o next.config.js should not change the color type of a png", - "with squoosh dev support w/o next.config.js should not have sharp missing warning", - "with squoosh dev support w/o next.config.js should not have sharp outdated warning", - "with squoosh dev support w/o next.config.js should not resize if requested width is larger than original source image", - "with squoosh dev support w/o next.config.js should resize relative url and old Chrome accept header as webp", - "with squoosh dev support w/o next.config.js should resize relative url and png accept header", - "with squoosh dev support w/o next.config.js should resize relative url and webp Firefox accept header", - "with squoosh dev support w/o next.config.js should resize relative url with invalid accept header as gif", - "with squoosh dev support w/o next.config.js should resize relative url with invalid accept header as png", - "with squoosh dev support w/o next.config.js should resize relative url with invalid accept header as tiff", - "with squoosh dev support w/o next.config.js should return home page", - "with squoosh dev support w/o next.config.js should set 304 status without body when etag matches if-none-match", - "with squoosh dev support w/o next.config.js should set cache-control to immutable for static images", - "with squoosh dev support w/o next.config.js should use cache and stale-while-revalidate when query is the same for internal image", - "with squoosh dev support w/o next.config.js should use cached image file when parameters are the same for animated gif", - "with squoosh dev support with next.config.js should automatically detect image type when content-type is octet-stream", - "with squoosh dev support with next.config.js should compress avif smaller than webp at q=100", - "with squoosh dev support with next.config.js should compress avif smaller than webp at q=50", - "with squoosh dev support with next.config.js should compress avif smaller than webp at q=75", - "with squoosh dev support with next.config.js should downlevel avif format to jpeg for old Safari", - "with squoosh dev support with next.config.js should downlevel webp format to jpeg for old Safari", - "with squoosh dev support with next.config.js should emit blur svg when width is 8 in dev but not prod", - "with squoosh dev support with next.config.js should emit blur svg when width is less than 8 in dev but not prod", - "with squoosh dev support with next.config.js should error if the image file does not exist", - "with squoosh dev support with next.config.js should error if the resource isn't a valid image", - "with squoosh dev support with next.config.js should fail when domain is not defined in next.config.js", - "with squoosh dev support with next.config.js should fail when internal url is not an image", - "with squoosh dev support with next.config.js should fail when q is greater than 100", - "with squoosh dev support with next.config.js should fail when q is less than 1", - "with squoosh dev support with next.config.js should fail when q is missing", - "with squoosh dev support with next.config.js should fail when q is not a number", - "with squoosh dev support with next.config.js should fail when url fails to load an image", - "with squoosh dev support with next.config.js should fail when url has file protocol", - "with squoosh dev support with next.config.js should fail when url has ftp protocol", - "with squoosh dev support with next.config.js should fail when url is missing", - "with squoosh dev support with next.config.js should fail when w is 0", - "with squoosh dev support with next.config.js should fail when w is less than 0", - "with squoosh dev support with next.config.js should fail when w is missing", - "with squoosh dev support with next.config.js should fail when w is not a number", - "with squoosh dev support with next.config.js should fail when width is not in next.config.js", - "with squoosh dev support with next.config.js should handle concurrent requests", - "with squoosh dev support with next.config.js should handle non-ascii characters in image url", - "with squoosh dev support with next.config.js should maintain animated gif", - "with squoosh dev support with next.config.js should maintain animated png", - "with squoosh dev support with next.config.js should maintain animated png 2", - "with squoosh dev support with next.config.js should maintain animated webp", - "with squoosh dev support with next.config.js should maintain bmp", - "with squoosh dev support with next.config.js should maintain ico format", - "with squoosh dev support with next.config.js should maintain jpg format for old Safari", - "with squoosh dev support with next.config.js should maintain png format for old Safari", - "with squoosh dev support with next.config.js should normalize invalid status codes", - "with squoosh dev support with next.config.js should not allow svg with application header", - "with squoosh dev support with next.config.js should not allow svg with comma header", - "with squoosh dev support with next.config.js should not allow svg with uppercase header", - "with squoosh dev support with next.config.js should not allow vector svg", - "with squoosh dev support with next.config.js should not change the color type of a png", - "with squoosh dev support with next.config.js should not have sharp missing warning", - "with squoosh dev support with next.config.js should not have sharp outdated warning", - "with squoosh dev support with next.config.js should not resize if requested width is larger than original source image", - "with squoosh dev support with next.config.js should resize absolute url from localhost", - "with squoosh dev support with next.config.js should resize relative url and new Chrome accept header as avif", - "with squoosh dev support with next.config.js should resize relative url and old Chrome accept header as webp", - "with squoosh dev support with next.config.js should resize relative url and png accept header", - "with squoosh dev support with next.config.js should resize relative url and webp Firefox accept header", - "with squoosh dev support with next.config.js should resize relative url with invalid accept header as gif", - "with squoosh dev support with next.config.js should resize relative url with invalid accept header as png", - "with squoosh dev support with next.config.js should resize relative url with invalid accept header as tiff", - "with squoosh dev support with next.config.js should return home page", - "with squoosh dev support with next.config.js should set 304 status without body when etag matches if-none-match", - "with squoosh dev support with next.config.js should set cache-control to immutable for static images", - "with squoosh dev support with next.config.js should use cache and stale-while-revalidate when query is the same for external image", - "with squoosh dev support with next.config.js should use cache and stale-while-revalidate when query is the same for internal image", - "with squoosh dev support with next.config.js should use cached image file when parameters are the same for animated gif" - ], - "failed": [], - "pending": [ - "with squoosh Production Mode Server support w/o next.config.js should downlevel avif format to jpeg for old Safari", - "with squoosh Production Mode Server support w/o next.config.js should downlevel webp format to jpeg for old Safari", - "with squoosh Production Mode Server support w/o next.config.js should emit blur svg when width is 8 in dev but not prod", - "with squoosh Production Mode Server support w/o next.config.js should emit blur svg when width is less than 8 in dev but not prod", - "with squoosh Production Mode Server support w/o next.config.js should error if the image file does not exist", - "with squoosh Production Mode Server support w/o next.config.js should error if the resource isn't a valid image", - "with squoosh Production Mode Server support w/o next.config.js should fail when domain is not defined in next.config.js", - "with squoosh Production Mode Server support w/o next.config.js should fail when internal url is not an image", - "with squoosh Production Mode Server support w/o next.config.js should fail when q is greater than 100", - "with squoosh Production Mode Server support w/o next.config.js should fail when q is less than 1", - "with squoosh Production Mode Server support w/o next.config.js should fail when q is missing", - "with squoosh Production Mode Server support w/o next.config.js should fail when q is not a number", - "with squoosh Production Mode Server support w/o next.config.js should fail when url has file protocol", - "with squoosh Production Mode Server support w/o next.config.js should fail when url has ftp protocol", - "with squoosh Production Mode Server support w/o next.config.js should fail when url is missing", - "with squoosh Production Mode Server support w/o next.config.js should fail when w is 0", - "with squoosh Production Mode Server support w/o next.config.js should fail when w is less than 0", - "with squoosh Production Mode Server support w/o next.config.js should fail when w is missing", - "with squoosh Production Mode Server support w/o next.config.js should fail when w is not a number", - "with squoosh Production Mode Server support w/o next.config.js should fail when width is not in next.config.js", - "with squoosh Production Mode Server support w/o next.config.js should handle non-ascii characters in image url", - "with squoosh Production Mode Server support w/o next.config.js should have sharp missing warning", - "with squoosh Production Mode Server support w/o next.config.js should maintain animated gif", - "with squoosh Production Mode Server support w/o next.config.js should maintain animated png", - "with squoosh Production Mode Server support w/o next.config.js should maintain animated png 2", - "with squoosh Production Mode Server support w/o next.config.js should maintain animated webp", - "with squoosh Production Mode Server support w/o next.config.js should maintain bmp", - "with squoosh Production Mode Server support w/o next.config.js should maintain ico format", - "with squoosh Production Mode Server support w/o next.config.js should maintain jpg format for old Safari", - "with squoosh Production Mode Server support w/o next.config.js should maintain png format for old Safari", - "with squoosh Production Mode Server support w/o next.config.js should not allow svg with application header", - "with squoosh Production Mode Server support w/o next.config.js should not allow svg with comma header", - "with squoosh Production Mode Server support w/o next.config.js should not allow svg with uppercase header", - "with squoosh Production Mode Server support w/o next.config.js should not allow vector svg", - "with squoosh Production Mode Server support w/o next.config.js should not change the color type of a png", - "with squoosh Production Mode Server support w/o next.config.js should not have sharp outdated warning", - "with squoosh Production Mode Server support w/o next.config.js should not resize if requested width is larger than original source image", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url and old Chrome accept header as webp", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url and png accept header", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url and webp Firefox accept header", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url with invalid accept header as gif", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url with invalid accept header as png", - "with squoosh Production Mode Server support w/o next.config.js should resize relative url with invalid accept header as tiff", - "with squoosh Production Mode Server support w/o next.config.js should return home page", - "with squoosh Production Mode Server support w/o next.config.js should set 304 status without body when etag matches if-none-match", - "with squoosh Production Mode Server support w/o next.config.js should set cache-control to immutable for static images", - "with squoosh Production Mode Server support w/o next.config.js should use cache and stale-while-revalidate when query is the same for internal image", - "with squoosh Production Mode Server support w/o next.config.js should use cached image file when parameters are the same for animated gif", - "with squoosh Production Mode Server support with next.config.js should automatically detect image type when content-type is octet-stream", - "with squoosh Production Mode Server support with next.config.js should compress avif smaller than webp at q=100", - "with squoosh Production Mode Server support with next.config.js should compress avif smaller than webp at q=50", - "with squoosh Production Mode Server support with next.config.js should compress avif smaller than webp at q=75", - "with squoosh Production Mode Server support with next.config.js should downlevel avif format to jpeg for old Safari", - "with squoosh Production Mode Server support with next.config.js should downlevel webp format to jpeg for old Safari", - "with squoosh Production Mode Server support with next.config.js should emit blur svg when width is 8 in dev but not prod", - "with squoosh Production Mode Server support with next.config.js should emit blur svg when width is less than 8 in dev but not prod", - "with squoosh Production Mode Server support with next.config.js should error if the image file does not exist", - "with squoosh Production Mode Server support with next.config.js should error if the resource isn't a valid image", - "with squoosh Production Mode Server support with next.config.js should fail when domain is not defined in next.config.js", - "with squoosh Production Mode Server support with next.config.js should fail when internal url is not an image", - "with squoosh Production Mode Server support with next.config.js should fail when q is greater than 100", - "with squoosh Production Mode Server support with next.config.js should fail when q is less than 1", - "with squoosh Production Mode Server support with next.config.js should fail when q is missing", - "with squoosh Production Mode Server support with next.config.js should fail when q is not a number", - "with squoosh Production Mode Server support with next.config.js should fail when url fails to load an image", - "with squoosh Production Mode Server support with next.config.js should fail when url has file protocol", - "with squoosh Production Mode Server support with next.config.js should fail when url has ftp protocol", - "with squoosh Production Mode Server support with next.config.js should fail when url is missing", - "with squoosh Production Mode Server support with next.config.js should fail when w is 0", - "with squoosh Production Mode Server support with next.config.js should fail when w is less than 0", - "with squoosh Production Mode Server support with next.config.js should fail when w is missing", - "with squoosh Production Mode Server support with next.config.js should fail when w is not a number", - "with squoosh Production Mode Server support with next.config.js should fail when width is not in next.config.js", - "with squoosh Production Mode Server support with next.config.js should handle concurrent requests", - "with squoosh Production Mode Server support with next.config.js should handle non-ascii characters in image url", - "with squoosh Production Mode Server support with next.config.js should have sharp missing warning", - "with squoosh Production Mode Server support with next.config.js should maintain animated gif", - "with squoosh Production Mode Server support with next.config.js should maintain animated png", - "with squoosh Production Mode Server support with next.config.js should maintain animated png 2", - "with squoosh Production Mode Server support with next.config.js should maintain animated webp", - "with squoosh Production Mode Server support with next.config.js should maintain bmp", - "with squoosh Production Mode Server support with next.config.js should maintain ico format", - "with squoosh Production Mode Server support with next.config.js should maintain jpg format for old Safari", - "with squoosh Production Mode Server support with next.config.js should maintain png format for old Safari", - "with squoosh Production Mode Server support with next.config.js should normalize invalid status codes", - "with squoosh Production Mode Server support with next.config.js should not allow svg with application header", - "with squoosh Production Mode Server support with next.config.js should not allow svg with comma header", - "with squoosh Production Mode Server support with next.config.js should not allow svg with uppercase header", - "with squoosh Production Mode Server support with next.config.js should not allow vector svg", - "with squoosh Production Mode Server support with next.config.js should not change the color type of a png", - "with squoosh Production Mode Server support with next.config.js should not have sharp outdated warning", - "with squoosh Production Mode Server support with next.config.js should not resize if requested width is larger than original source image", - "with squoosh Production Mode Server support with next.config.js should resize absolute url from localhost", - "with squoosh Production Mode Server support with next.config.js should resize relative url and new Chrome accept header as avif", - "with squoosh Production Mode Server support with next.config.js should resize relative url and old Chrome accept header as webp", - "with squoosh Production Mode Server support with next.config.js should resize relative url and png accept header", - "with squoosh Production Mode Server support with next.config.js should resize relative url and webp Firefox accept header", - "with squoosh Production Mode Server support with next.config.js should resize relative url with invalid accept header as gif", - "with squoosh Production Mode Server support with next.config.js should resize relative url with invalid accept header as png", - "with squoosh Production Mode Server support with next.config.js should resize relative url with invalid accept header as tiff", - "with squoosh Production Mode Server support with next.config.js should return home page", - "with squoosh Production Mode Server support with next.config.js should set 304 status without body when etag matches if-none-match", - "with squoosh Production Mode Server support with next.config.js should set cache-control to immutable for static images", - "with squoosh Production Mode Server support with next.config.js should use cache and stale-while-revalidate when query is the same for external image", - "with squoosh Production Mode Server support with next.config.js should use cache and stale-while-revalidate when query is the same for internal image", - "with squoosh Production Mode Server support with next.config.js should use cached image file when parameters are the same for animated gif" - ], - "flakey": [], - "runtimeError": false - }, "test/integration/import-assertion/test/index.test.js": { "passed": ["import-assertion dev should handle json assertions"], "failed": [],