UNPKG

@builder.io/qwik

Version:

An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.

1,435 lines 288 kB
/** * @license * @builder.io/qwik/optimizer 1.16.0 * Copyright Builder.io, Inc. All Rights Reserved. * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE */ globalThis.qwikOptimizer = function(module) { "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) { __defProp(target, name, { get: all[name], enumerable: true }); } }; var __copyProps = (to, from, except, desc) => { if (from && "object" === typeof from || "function" === typeof from) { for (let key of __getOwnPropNames(from)) { __hasOwnProp.call(to, key) || key === except || __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } } return to; }; var __toESM = (mod, isNodeMode, target) => (target = null != mod ? __create(__getProtoOf(mod)) : {}, __copyProps(!isNodeMode && mod && mod.__esModule ? target : __defProp(target, "default", { value: mod, enumerable: true }), mod)); var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var require_utils = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/utils.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.findBox = exports2.readUInt = exports2.readUInt32LE = exports2.readUInt32BE = exports2.readInt32LE = exports2.readUInt24LE = exports2.readUInt16LE = exports2.readUInt16BE = exports2.readInt16LE = exports2.toHexString = exports2.toUTF8String = void 0; var decoder = new TextDecoder; var toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end)); exports2.toUTF8String = toUTF8String; var toHexString = (input, start = 0, end = input.length) => input.slice(start, end).reduce((memo, i) => memo + ("0" + i.toString(16)).slice(-2), ""); exports2.toHexString = toHexString; var readInt16LE = (input, offset = 0) => { const val = input[offset] + 256 * input[offset + 1]; return val | 131070 * (32768 & val); }; exports2.readInt16LE = readInt16LE; var readUInt16BE = (input, offset = 0) => 256 * input[offset] + input[offset + 1]; exports2.readUInt16BE = readUInt16BE; var readUInt16LE = (input, offset = 0) => input[offset] + 256 * input[offset + 1]; exports2.readUInt16LE = readUInt16LE; var readUInt24LE = (input, offset = 0) => input[offset] + 256 * input[offset + 1] + 65536 * input[offset + 2]; exports2.readUInt24LE = readUInt24LE; var readInt32LE = (input, offset = 0) => input[offset] + 256 * input[offset + 1] + 65536 * input[offset + 2] + (input[offset + 3] << 24); exports2.readInt32LE = readInt32LE; var readUInt32BE = (input, offset = 0) => input[offset] * 2 ** 24 + 65536 * input[offset + 1] + 256 * input[offset + 2] + input[offset + 3]; exports2.readUInt32BE = readUInt32BE; var readUInt32LE = (input, offset = 0) => input[offset] + 256 * input[offset + 1] + 65536 * input[offset + 2] + input[offset + 3] * 2 ** 24; exports2.readUInt32LE = readUInt32LE; var methods = { readUInt16BE: exports2.readUInt16BE, readUInt16LE: exports2.readUInt16LE, readUInt32BE: exports2.readUInt32BE, readUInt32LE: exports2.readUInt32LE }; function readUInt(input, bits, offset, isBigEndian) { offset = offset || 0; const endian = isBigEndian ? "BE" : "LE"; const methodName = "readUInt" + bits + endian; return methods[methodName](input, offset); } exports2.readUInt = readUInt; function readBox(buffer, offset) { if (buffer.length - offset < 4) { return; } const boxSize = (0, exports2.readUInt32BE)(buffer, offset); if (buffer.length - offset < boxSize) { return; } return { name: (0, exports2.toUTF8String)(buffer, 4 + offset, 8 + offset), offset: offset, size: boxSize }; } function findBox(buffer, boxName, offset) { while (offset < buffer.length) { const box = readBox(buffer, offset); if (!box) { break; } if (box.name === boxName) { return box; } offset += box.size; } } exports2.findBox = findBox; } }); var require_bmp = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/bmp.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.BMP = void 0; var utils_1 = require_utils(); exports2.BMP = { validate: input => "BM" === (0, utils_1.toUTF8String)(input, 0, 2), calculate: input => ({ height: Math.abs((0, utils_1.readInt32LE)(input, 22)), width: (0, utils_1.readUInt32LE)(input, 18) }) }; } }); var require_ico = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/ico.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.ICO = void 0; var utils_1 = require_utils(); var TYPE_ICON = 1; var SIZE_HEADER = 6; var SIZE_IMAGE_ENTRY = 16; function getSizeFromOffset(input, offset) { const value = input[offset]; return 0 === value ? 256 : value; } function getImageSize(input, imageIndex) { const offset = SIZE_HEADER + imageIndex * SIZE_IMAGE_ENTRY; return { height: getSizeFromOffset(input, offset + 1), width: getSizeFromOffset(input, offset) }; } exports2.ICO = { validate(input) { const reserved = (0, utils_1.readUInt16LE)(input, 0); const imageCount = (0, utils_1.readUInt16LE)(input, 4); if (0 !== reserved || 0 === imageCount) { return false; } const imageType = (0, utils_1.readUInt16LE)(input, 2); return imageType === TYPE_ICON; }, calculate(input) { const nbImages = (0, utils_1.readUInt16LE)(input, 4); const imageSize = getImageSize(input, 0); if (1 === nbImages) { return imageSize; } const imgs = [ imageSize ]; for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) { imgs.push(getImageSize(input, imageIndex)); } return { height: imageSize.height, images: imgs, width: imageSize.width }; } }; } }); var require_cur = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/cur.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.CUR = void 0; var ico_12 = require_ico(); var utils_1 = require_utils(); var TYPE_CURSOR = 2; exports2.CUR = { validate(input) { const reserved = (0, utils_1.readUInt16LE)(input, 0); const imageCount = (0, utils_1.readUInt16LE)(input, 4); if (0 !== reserved || 0 === imageCount) { return false; } const imageType = (0, utils_1.readUInt16LE)(input, 2); return imageType === TYPE_CURSOR; }, calculate: input => ico_12.ICO.calculate(input) }; } }); var require_dds = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/dds.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DDS = void 0; var utils_1 = require_utils(); exports2.DDS = { validate: input => 542327876 === (0, utils_1.readUInt32LE)(input, 0), calculate: input => ({ height: (0, utils_1.readUInt32LE)(input, 12), width: (0, utils_1.readUInt32LE)(input, 16) }) }; } }); var require_gif = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/gif.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.GIF = void 0; var utils_1 = require_utils(); var gifRegexp = /^GIF8[79]a/; exports2.GIF = { validate: input => gifRegexp.test((0, utils_1.toUTF8String)(input, 0, 6)), calculate: input => ({ height: (0, utils_1.readUInt16LE)(input, 8), width: (0, utils_1.readUInt16LE)(input, 6) }) }; } }); var require_icns = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/icns.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.ICNS = void 0; var utils_1 = require_utils(); var SIZE_HEADER = 8; var FILE_LENGTH_OFFSET = 4; var ENTRY_LENGTH_OFFSET = 4; var ICON_TYPE_SIZE = { 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(input, imageOffset) { const imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET; return [ (0, utils_1.toUTF8String)(input, imageOffset, imageLengthOffset), (0, utils_1.readUInt32BE)(input, imageLengthOffset) ]; } function getImageSize(type) { const size = ICON_TYPE_SIZE[type]; return { width: size, height: size, type: type }; } exports2.ICNS = { validate: input => "icns" === (0, utils_1.toUTF8String)(input, 0, 4), calculate(input) { const inputLength = input.length; const fileLength = (0, utils_1.readUInt32BE)(input, FILE_LENGTH_OFFSET); let imageOffset = SIZE_HEADER; let imageHeader = readImageHeader(input, imageOffset); let imageSize = getImageSize(imageHeader[0]); imageOffset += imageHeader[1]; if (imageOffset === fileLength) { return imageSize; } const result = { height: imageSize.height, images: [ imageSize ], width: imageSize.width }; while (imageOffset < fileLength && imageOffset < inputLength) { imageHeader = readImageHeader(input, imageOffset); imageSize = getImageSize(imageHeader[0]); imageOffset += imageHeader[1]; result.images.push(imageSize); } return result; } }; } }); var require_j2c = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/j2c.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.J2C = void 0; var utils_1 = require_utils(); exports2.J2C = { validate: input => "ff4fff51" === (0, utils_1.toHexString)(input, 0, 4), calculate: input => ({ height: (0, utils_1.readUInt32BE)(input, 12), width: (0, utils_1.readUInt32BE)(input, 8) }) }; } }); var require_jp2 = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/jp2.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.JP2 = void 0; var utils_1 = require_utils(); exports2.JP2 = { validate(input) { if (1783636e3 !== (0, utils_1.readUInt32BE)(input, 4) || (0, utils_1.readUInt32BE)(input, 0) < 1) { return false; } const ftypBox = (0, utils_1.findBox)(input, "ftyp", 0); if (!ftypBox) { return false; } return 1718909296 === (0, utils_1.readUInt32BE)(input, ftypBox.offset + 4); }, calculate(input) { const jp2hBox = (0, utils_1.findBox)(input, "jp2h", 0); const ihdrBox = jp2hBox && (0, utils_1.findBox)(input, "ihdr", jp2hBox.offset + 8); if (ihdrBox) { return { height: (0, utils_1.readUInt32BE)(input, ihdrBox.offset + 8), width: (0, utils_1.readUInt32BE)(input, ihdrBox.offset + 12) }; } throw new TypeError("Unsupported JPEG 2000 format"); } }; } }); var require_jpg = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/jpg.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.JPG = void 0; var utils_1 = require_utils(); var EXIF_MARKER = "45786966"; var APP1_DATA_SIZE_BYTES = 2; var EXIF_HEADER_BYTES = 6; var TIFF_BYTE_ALIGN_BYTES = 2; var BIG_ENDIAN_BYTE_ALIGN = "4d4d"; var LITTLE_ENDIAN_BYTE_ALIGN = "4949"; var IDF_ENTRY_BYTES = 12; var NUM_DIRECTORY_ENTRIES_BYTES = 2; function isEXIF(input) { return (0, utils_1.toHexString)(input, 2, 6) === EXIF_MARKER; } function extractSize(input, index) { return { height: (0, utils_1.readUInt16BE)(input, index), width: (0, utils_1.readUInt16BE)(input, index + 2) }; } function extractOrientation(exifBlock, isBigEndian) { const idfOffset = 8; const offset = EXIF_HEADER_BYTES + idfOffset; const idfDirectoryEntries = (0, utils_1.readUInt)(exifBlock, 16, offset, isBigEndian); for (let directoryEntryNumber = 0; directoryEntryNumber < idfDirectoryEntries; directoryEntryNumber++) { const start = offset + NUM_DIRECTORY_ENTRIES_BYTES + directoryEntryNumber * IDF_ENTRY_BYTES; const end = start + IDF_ENTRY_BYTES; if (start > exifBlock.length) { return; } const block = exifBlock.slice(start, end); const tagNumber = (0, utils_1.readUInt)(block, 16, 0, isBigEndian); if (274 === tagNumber) { const dataFormat = (0, utils_1.readUInt)(block, 16, 2, isBigEndian); if (3 !== dataFormat) { return; } const numberOfComponents = (0, utils_1.readUInt)(block, 32, 4, isBigEndian); if (1 !== numberOfComponents) { return; } return (0, utils_1.readUInt)(block, 16, 8, isBigEndian); } } } function validateExifBlock(input, index) { const exifBlock = input.slice(APP1_DATA_SIZE_BYTES, index); const byteAlign = (0, utils_1.toHexString)(exifBlock, EXIF_HEADER_BYTES, EXIF_HEADER_BYTES + TIFF_BYTE_ALIGN_BYTES); const isBigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN; const isLittleEndian = byteAlign === LITTLE_ENDIAN_BYTE_ALIGN; if (isBigEndian || isLittleEndian) { return extractOrientation(exifBlock, isBigEndian); } } function validateInput(input, index) { if (index > input.length) { throw new TypeError("Corrupt JPG, exceeded buffer limits"); } } exports2.JPG = { validate: input => "ffd8" === (0, utils_1.toHexString)(input, 0, 2), calculate(input) { input = input.slice(4); let orientation; let next; while (input.length) { const i = (0, utils_1.readUInt16BE)(input, 0); if (255 !== input[i]) { input = input.slice(1); continue; } isEXIF(input) && (orientation = validateExifBlock(input, i)); validateInput(input, i); next = input[i + 1]; if (192 === next || 193 === next || 194 === next) { const size = extractSize(input, i + 5); if (!orientation) { return size; } return { height: size.height, orientation: orientation, width: size.width }; } input = input.slice(i + 2); } throw new TypeError("Invalid JPG, no size found"); } }; } }); var require_ktx = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/ktx.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.KTX = void 0; var utils_1 = require_utils(); exports2.KTX = { validate: input => { const signature = (0, utils_1.toUTF8String)(input, 1, 7); return [ "KTX 11", "KTX 20" ].includes(signature); }, calculate: input => { const type = 49 === input[5] ? "ktx" : "ktx2"; const offset = "ktx" === type ? 36 : 20; return { height: (0, utils_1.readUInt32LE)(input, offset + 4), width: (0, utils_1.readUInt32LE)(input, offset), type: type }; } }; } }); var require_png = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/png.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.PNG = void 0; var utils_1 = require_utils(); var pngSignature = "PNG\r\n\n"; var pngImageHeaderChunkName = "IHDR"; var pngFriedChunkName = "CgBI"; exports2.PNG = { validate(input) { if (pngSignature === (0, utils_1.toUTF8String)(input, 1, 8)) { let chunkName = (0, utils_1.toUTF8String)(input, 12, 16); chunkName === pngFriedChunkName && (chunkName = (0, utils_1.toUTF8String)(input, 28, 32)); if (chunkName !== pngImageHeaderChunkName) { throw new TypeError("Invalid PNG"); } return true; } return false; }, calculate(input) { if ((0, utils_1.toUTF8String)(input, 12, 16) === pngFriedChunkName) { return { height: (0, utils_1.readUInt32BE)(input, 36), width: (0, utils_1.readUInt32BE)(input, 32) }; } return { height: (0, utils_1.readUInt32BE)(input, 20), width: (0, utils_1.readUInt32BE)(input, 16) }; } }; } }); var require_pnm = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/pnm.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.PNM = void 0; var utils_1 = require_utils(); var PNMTypes = { P1: "pbm/ascii", P2: "pgm/ascii", P3: "ppm/ascii", P4: "pbm", P5: "pgm", P6: "ppm", P7: "pam", PF: "pfm" }; var handlers = { default: lines => { let dimensions = []; while (lines.length > 0) { const line = lines.shift(); if ("#" === line[0]) { continue; } dimensions = line.split(" "); break; } if (2 === dimensions.length) { return { height: parseInt(dimensions[1], 10), width: parseInt(dimensions[0], 10) }; } throw new TypeError("Invalid PNM"); }, pam: lines => { const size = {}; while (lines.length > 0) { const line = lines.shift(); if (line.length > 16 || line.charCodeAt(0) > 128) { continue; } const [key, value] = line.split(" "); key && value && (size[key.toLowerCase()] = parseInt(value, 10)); if (size.height && size.width) { break; } } if (size.height && size.width) { return { height: size.height, width: size.width }; } throw new TypeError("Invalid PAM"); } }; exports2.PNM = { validate: input => (0, utils_1.toUTF8String)(input, 0, 2) in PNMTypes, calculate(input) { const signature = (0, utils_1.toUTF8String)(input, 0, 2); const type = PNMTypes[signature]; const lines = (0, utils_1.toUTF8String)(input, 3).split(/[\r\n]+/); const handler = handlers[type] || handlers.default; return handler(lines); } }; } }); var require_psd = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/psd.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.PSD = void 0; var utils_1 = require_utils(); exports2.PSD = { validate: input => "8BPS" === (0, utils_1.toUTF8String)(input, 0, 4), calculate: input => ({ height: (0, utils_1.readUInt32BE)(input, 14), width: (0, utils_1.readUInt32BE)(input, 18) }) }; } }); var require_svg = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/svg.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.SVG = void 0; var utils_1 = require_utils(); var svgReg = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/; var extractorRegExps = { height: /\sheight=(['"])([^%]+?)\1/, root: svgReg, viewbox: /\sviewBox=(['"])(.+?)\1/i, width: /\swidth=(['"])([^%]+?)\1/ }; var INCH_CM = 2.54; var units = { in: 96, cm: 96 / INCH_CM, em: 16, ex: 8, m: 96 / INCH_CM * 100, mm: 96 / INCH_CM / 10, pc: 96 / 72 / 12, pt: 96 / 72, px: 1 }; var unitsReg = new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(units).join("|")})?$`); function parseLength(len) { const m = unitsReg.exec(len); if (!m) { return; } return Math.round(Number(m[1]) * (units[m[2]] || 1)); } function parseViewbox(viewbox) { const bounds = viewbox.split(" "); return { height: parseLength(bounds[3]), width: parseLength(bounds[2]) }; } function parseAttributes(root) { const width = root.match(extractorRegExps.width); const height = root.match(extractorRegExps.height); const viewbox = root.match(extractorRegExps.viewbox); return { height: height && parseLength(height[2]), viewbox: viewbox && parseViewbox(viewbox[2]), width: width && parseLength(width[2]) }; } function calculateByDimensions(attrs) { return { height: attrs.height, width: attrs.width }; } function calculateByViewbox(attrs, viewbox) { const ratio = viewbox.width / viewbox.height; if (attrs.width) { return { height: Math.floor(attrs.width / ratio), width: attrs.width }; } if (attrs.height) { return { height: attrs.height, width: Math.floor(attrs.height * ratio) }; } return { height: viewbox.height, width: viewbox.width }; } exports2.SVG = { validate: input => svgReg.test((0, utils_1.toUTF8String)(input, 0, 1e3)), calculate(input) { const root = (0, utils_1.toUTF8String)(input).match(extractorRegExps.root); if (root) { const attrs = parseAttributes(root[0]); if (attrs.width && attrs.height) { return calculateByDimensions(attrs); } if (attrs.viewbox) { return calculateByViewbox(attrs, attrs.viewbox); } } throw new TypeError("Invalid SVG"); } }; } }); var require_tga = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/tga.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.TGA = void 0; var utils_1 = require_utils(); exports2.TGA = { validate: input => 0 === (0, utils_1.readUInt16LE)(input, 0) && 0 === (0, utils_1.readUInt16LE)(input, 4), calculate: input => ({ height: (0, utils_1.readUInt16LE)(input, 14), width: (0, utils_1.readUInt16LE)(input, 12) }) }; } }); var require_webp = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/webp.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.WEBP = void 0; var utils_1 = require_utils(); function calculateExtended(input) { return { height: 1 + (0, utils_1.readUInt24LE)(input, 7), width: 1 + (0, utils_1.readUInt24LE)(input, 4) }; } function calculateLossless(input) { return { height: 1 + ((15 & input[4]) << 10 | input[3] << 2 | (192 & input[2]) >> 6), width: 1 + ((63 & input[2]) << 8 | input[1]) }; } function calculateLossy(input) { return { height: 16383 & (0, utils_1.readInt16LE)(input, 8), width: 16383 & (0, utils_1.readInt16LE)(input, 6) }; } exports2.WEBP = { validate(input) { const riffHeader = "RIFF" === (0, utils_1.toUTF8String)(input, 0, 4); const webpHeader = "WEBP" === (0, utils_1.toUTF8String)(input, 8, 12); const vp8Header = "VP8" === (0, utils_1.toUTF8String)(input, 12, 15); return riffHeader && webpHeader && vp8Header; }, calculate(input) { const chunkHeader = (0, utils_1.toUTF8String)(input, 12, 16); input = input.slice(20, 30); if ("VP8X" === chunkHeader) { const extendedHeader = input[0]; const validStart = 0 === (192 & extendedHeader); const validEnd = 0 === (1 & extendedHeader); if (validStart && validEnd) { return calculateExtended(input); } throw new TypeError("Invalid WebP"); } if ("VP8 " === chunkHeader && 47 !== input[0]) { return calculateLossy(input); } const signature = (0, utils_1.toHexString)(input, 3, 6); if ("VP8L" === chunkHeader && "9d012a" !== signature) { return calculateLossless(input); } throw new TypeError("Invalid WebP"); } }; } }); var require_heif = __commonJS({ "node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/types/heif.js"(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); exports2.HEIF = void 0; var utils_1 = require_utils(); var brandMap = { avif: "avif", mif1: "heif", msf1: "heif", heic: "heic", heix: "heic", hevc: "heic", hevx: "heic" }; exports2.HEIF = { validate(buffer) { const ftype = (0, utils_1.toUTF8String)(buffer, 4, 8); const brand = (0, utils_1.toUTF8String)(buffer, 8, 12); return "ftyp" === ftype && brand in brandMap; }, calculate(buffer) { const metaBox = (0, utils_1.findBox)(buffer, "meta", 0); const iprpBox = metaBox && (0, utils_1.findBox)(buffer, "iprp", metaBox.offset + 12); const ipcoBox = iprpBox && (0, utils_1.findBox)(buffer, "ipco", iprpBox.offset + 8); const ispeBox = ipcoBox && (0, utils_1.findBox)(buffer, "ispe", ipcoBox.offset + 8); if (ispeBox) { return { height: (0, utils_1.readUInt32BE)(buffer, ispeBox.offset + 16), width: (0, utils_1.readUInt32BE)(buffer, ispeBox.offset + 12), type: (0, utils_1.toUTF8String)(buffer, 8, 12) }; } throw new TypeError("Invalid HEIF, no size found"); } }; } }); var index_exports = {}; __export(index_exports, { createOptimizer: () => createOptimizer, qwikRollup: () => qwikRollup, qwikVite: () => qwikVite, symbolMapper: () => symbolMapper, versions: () => versions }); module.exports = __toCommonJS(index_exports); function createPath(opts = {}) { function assertPath(path) { if ("string" !== typeof path) { throw new TypeError("Path must be a string. Received " + JSON.stringify(path)); } } function normalizeStringPosix(path, allowAboveRoot) { let res = ""; let lastSegmentLength = 0; let lastSlash = -1; let dots = 0; let code; for (let i = 0; i <= path.length; ++i) { if (i < path.length) { code = path.charCodeAt(i); } else { if (47 === code) { break; } code = 47; } if (47 === code) { if (lastSlash === i - 1 || 1 === dots) {} else if (lastSlash !== i - 1 && 2 === dots) { if (res.length < 2 || 2 !== lastSegmentLength || 46 !== res.charCodeAt(res.length - 1) || 46 !== res.charCodeAt(res.length - 2)) { if (res.length > 2) { const lastSlashIndex = res.lastIndexOf("/"); if (lastSlashIndex !== res.length - 1) { if (-1 === lastSlashIndex) { res = ""; lastSegmentLength = 0; } else { res = res.slice(0, lastSlashIndex); lastSegmentLength = res.length - 1 - res.lastIndexOf("/"); } lastSlash = i; dots = 0; continue; } } else if (2 === res.length || 1 === res.length) { res = ""; lastSegmentLength = 0; lastSlash = i; dots = 0; continue; } } if (allowAboveRoot) { res.length > 0 ? res += "/.." : res = ".."; lastSegmentLength = 2; } } else { res.length > 0 ? res += "/" + path.slice(lastSlash + 1, i) : res = path.slice(lastSlash + 1, i); lastSegmentLength = i - lastSlash - 1; } lastSlash = i; dots = 0; } else { 46 === code && -1 !== dots ? ++dots : dots = -1; } } return res; } function _format(sep2, pathObject) { const dir = pathObject.dir || pathObject.root; const base2 = pathObject.base || (pathObject.name || "") + (pathObject.ext || ""); if (!dir) { return base2; } if (dir === pathObject.root) { return dir + base2; } return dir + sep2 + base2; } const resolve = function(...paths) { let resolvedPath = ""; let resolvedAbsolute = false; let cwd; for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) { let path; if (i >= 0) { path = paths[i]; } else { void 0 === cwd && (cwd = opts && "function" === typeof opts.cwd ? opts.cwd() : "undefined" !== typeof process && "function" === typeof process.cwd ? process.cwd() : "/"); path = cwd; } assertPath(path); if (0 === path.length) { continue; } resolvedPath = path + "/" + resolvedPath; resolvedAbsolute = 47 === path.charCodeAt(0); } resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); return resolvedAbsolute ? resolvedPath.length > 0 ? "/" + resolvedPath : "/" : resolvedPath.length > 0 ? resolvedPath : "."; }; const normalize = function(path) { assertPath(path); if (0 === path.length) { return "."; } const isAbsolute2 = 47 === path.charCodeAt(0); const trailingSeparator = 47 === path.charCodeAt(path.length - 1); path = normalizeStringPosix(path, !isAbsolute2); 0 !== path.length || isAbsolute2 || (path = "."); path.length > 0 && trailingSeparator && (path += "/"); if (isAbsolute2) { return "/" + path; } return path; }; const isAbsolute = function(path) { assertPath(path); return path.length > 0 && 47 === path.charCodeAt(0); }; const join = function(...paths) { if (0 === paths.length) { return "."; } let joined; for (let i = 0; i < paths.length; ++i) { const arg = paths[i]; assertPath(arg); arg.length > 0 && (void 0 === joined ? joined = arg : joined += "/" + arg); } if (void 0 === joined) { return "."; } return normalize(joined); }; const relative = function(from, to) { assertPath(from); assertPath(to); if (from === to) { return ""; } from = resolve(from); to = resolve(to); if (from === to) { return ""; } let fromStart = 1; for (;fromStart < from.length; ++fromStart) { if (47 !== from.charCodeAt(fromStart)) { break; } } const fromEnd = from.length; const fromLen = fromEnd - fromStart; let toStart = 1; for (;toStart < to.length; ++toStart) { if (47 !== to.charCodeAt(toStart)) { break; } } const toEnd = to.length; const toLen = toEnd - toStart; const length = fromLen < toLen ? fromLen : toLen; let lastCommonSep = -1; let i = 0; for (;i <= length; ++i) { if (i === length) { if (toLen > length) { if (47 === to.charCodeAt(toStart + i)) { return to.slice(toStart + i + 1); } if (0 === i) { return to.slice(toStart + i); } } else { fromLen > length && (47 === from.charCodeAt(fromStart + i) ? lastCommonSep = i : 0 === i && (lastCommonSep = 0)); } break; } const fromCode = from.charCodeAt(fromStart + i); const toCode = to.charCodeAt(toStart + i); if (fromCode !== toCode) { break; } 47 === fromCode && (lastCommonSep = i); } let out = ""; for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) { i !== fromEnd && 47 !== from.charCodeAt(i) || (0 === out.length ? out += ".." : out += "/.."); } if (out.length > 0) { return out + to.slice(toStart + lastCommonSep); } toStart += lastCommonSep; 47 === to.charCodeAt(toStart) && ++toStart; return to.slice(toStart); }; const dirname = function(path) { assertPath(path); if (0 === path.length) { return "."; } let code = path.charCodeAt(0); const hasRoot = 47 === code; let end = -1; let matchedSlash = true; for (let i = path.length - 1; i >= 1; --i) { code = path.charCodeAt(i); if (47 === code) { if (!matchedSlash) { end = i; break; } } else { matchedSlash = false; } } if (-1 === end) { return hasRoot ? "/" : "."; } if (hasRoot && 1 === end) { return "//"; } return path.slice(0, end); }; const basename = function(path, ext) { if (void 0 !== ext && "string" !== typeof ext) { throw new TypeError('"ext" argument must be a string'); } assertPath(path); let start = 0; let end = -1; let matchedSlash = true; let i; if (void 0 !== ext && ext.length > 0 && ext.length <= path.length) { if (ext.length === path.length && ext === path) { return ""; } let extIdx = ext.length - 1; let firstNonSlashEnd = -1; for (i = path.length - 1; i >= 0; --i) { const code = path.charCodeAt(i); if (47 === code) { if (!matchedSlash) { start = i + 1; break; } } else { if (-1 === firstNonSlashEnd) { matchedSlash = false; firstNonSlashEnd = i + 1; } if (extIdx >= 0) { if (code === ext.charCodeAt(extIdx)) { -1 === --extIdx && (end = i); } else { extIdx = -1; end = firstNonSlashEnd; } } } } start === end ? end = firstNonSlashEnd : -1 === end && (end = path.length); return path.slice(start, end); } for (i = path.length - 1; i >= 0; --i) { if (47 === path.charCodeAt(i)) { if (!matchedSlash) { start = i + 1; break; } } else if (-1 === end) { matchedSlash = false; end = i + 1; } } if (-1 === end) { return ""; } return path.slice(start, end); }; const extname = function(path) { assertPath(path); let startDot = -1; let startPart = 0; let end = -1; let matchedSlash = true; let preDotState = 0; for (let i = path.length - 1; i >= 0; --i) { const code = path.charCodeAt(i); if (47 === code) { if (!matchedSlash) { startPart = i + 1; break; } continue; } if (-1 === end) { matchedSlash = false; end = i + 1; } 46 === code ? -1 === startDot ? startDot = i : 1 !== preDotState && (preDotState = 1) : -1 !== startDot && (preDotState = -1); } if (-1 === startDot || -1 === end || 0 === preDotState || 1 === preDotState && startDot === end - 1 && startDot === startPart + 1) { return ""; } return path.slice(startDot, end); }; const format = function(pathObject) { if (null === pathObject || "object" !== typeof pathObject) { throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); } return _format("/", pathObject); }; const parse = function(path) { assertPath(path); const ret = { root: "", dir: "", base: "", ext: "", name: "" }; if (0 === path.length) { return ret; } let code = path.charCodeAt(0); let start; const isAbsolute2 = 47 === code; if (isAbsolute2) { ret.root = "/"; start = 1; } else { start = 0; } let startDot = -1; let startPart = 0; let end = -1; let matchedSlash = true; let i = path.length - 1; let preDotState = 0; for (;i >= start; --i) { code = path.charCodeAt(i); if (47 === code) { if (!matchedSlash) { startPart = i + 1; break; } continue; } if (-1 === end) { matchedSlash = false; end = i + 1; } 46 === code ? -1 === startDot ? startDot = i : 1 !== preDotState && (preDotState = 1) : -1 !== startDot && (preDotState = -1); } if (-1 === startDot || -1 === end || 0 === preDotState || 1 === preDotState && startDot === end - 1 && startDot === startPart + 1) { -1 !== end && (ret.base = ret.name = 0 === startPart && isAbsolute2 ? path.slice(1, end) : path.slice(startPart, end)); } else { if (0 === startPart && isAbsolute2) { ret.name = path.slice(1, startDot); ret.base = path.slice(1, end); } else { ret.name = path.slice(startPart, startDot); ret.base = path.slice(startPart, end); } ret.ext = path.slice(startDot, end); } startPart > 0 ? ret.dir = path.slice(0, startPart - 1) : isAbsolute2 && (ret.dir = "/"); return ret; }; const sep = "/"; const delimiter = ":"; return { relative: relative, resolve: resolve, parse: parse, format: format, join: join, isAbsolute: isAbsolute, basename: basename, normalize: normalize, dirname: dirname, extname: extname, delimiter: delimiter, sep: sep, win32: null, posix: { relative: relative, resolve: resolve, parse: parse, format: format, join: join, isAbsolute: isAbsolute, basename: basename, normalize: normalize, dirname: dirname, extname: extname, delimiter: delimiter, sep: sep, win32: null, posix: null } }; } var QWIK_BINDING_MAP = {}; var versions = { qwik: "1.16.0" }; async function getSystem() { const sysEnv = getEnv(); const sys = { dynamicImport: path => { throw new Error(`Qwik Optimizer sys.dynamicImport() not implemented, trying to import: "${path}"`); }, strictDynamicImport: path => { throw new Error(`Qwik Optimizer sys.strictDynamicImport() not implemented, trying to import: "${path}"`); }, path: null, cwd: () => "/", os: "unknown", env: sysEnv }; sys.path = createPath(sys); false; if ("node" === sysEnv || "bun" === sysEnv) { sys.dynamicImport = path => require(path); sys.strictDynamicImport = path => import(path); if ("undefined" === typeof TextEncoder) { const nodeUtil = await sys.dynamicImport("node:util"); globalThis.TextEncoder = nodeUtil.TextEncoder; globalThis.TextDecoder = nodeUtil.TextDecoder; } } else if ("webworker" === sysEnv || "browsermain" === sysEnv) { sys.strictDynamicImport = path => import(path); sys.dynamicImport = async path => { const cjsRsp = await fetch(path); const cjsCode = await cjsRsp.text(); const cjsModule = { exports: {} }; const cjsRun = new Function("module", "exports", cjsCode); cjsRun(cjsModule, cjsModule.exports); return cjsModule.exports; }; } if ("node" === sysEnv || "bun" === sysEnv) { sys.path = await sys.dynamicImport("node:path"); sys.cwd = () => process.cwd(); sys.os = process.platform; } else if ("deno" === sysEnv) { sys.path = await sys.dynamicImport("node:path"); sys.cwd = () => Deno.cwd(); sys.os = Deno.platform(); } return sys; } var getPlatformInputFiles = async sys => { if ("function" === typeof sys.getInputFiles) { return sys.getInputFiles; } if ("node" === sys.env) { const fs = await sys.dynamicImport("node:fs"); return async rootDir => { const getChildFilePaths = async dir => { const stats = await fs.promises.stat(dir); const flatted = []; if (stats.isDirectory()) { const dirItems = await fs.promises.readdir(dir); const files = await Promise.all(dirItems.map(async subdir => { const resolvedPath = sys.path.resolve(dir, subdir); const stats2 = await fs.promises.stat(resolvedPath); return stats2.isDirectory() ? getChildFilePaths(resolvedPath) : [ resolvedPath ]; })); for (const file of files) { flatted.push(...file); } } else { flatted.push(dir); } return flatted.filter(a => sys.path.extname(a).toLowerCase() in extensions); }; const filePaths = await getChildFilePaths(rootDir); const inputs = (await Promise.all(filePaths.map(async filePath => { const input = { code: await fs.promises.readFile(filePath, "utf8"), path: filePath }; return input; }))).sort((a, b) => { if (a.path < b.path) { return -1; } if (a.path > b.path) { return 1; } return 0; }); return inputs; }; } return null; }; async function loadPlatformBinding(sys) { const sysEnv = getEnv(); if ("node" === sysEnv || "bun" === sysEnv) { const platform = QWIK_BINDING_MAP[process.platform]; if (platform) { const triples = platform[process.arch]; if (triples) { for (const triple of triples) { try { false; const mod = await sys.dynamicImport(`../bindings/${triple.platformArchABI}`); return mod; } catch (e) { console.warn(`Unable to load native binding ${triple.platformArchABI}. Falling back to wasm build.`, null == e ? void 0 : e.message); } } } } } if ("node" === sysEnv || "bun" === sysEnv) { const wasmPath = sys.path.join(__dirname, "..", "bindings", "qwik_wasm_bg.wasm"); const mod = await sys.dynamicImport("../bindings/qwik.wasm.cjs"); const fs = await sys.dynamicImport("node:fs"); return new Promise((resolve, reject) => { fs.readFile(wasmPath, (err, buf) => { null != err ? reject(err) : resolve(buf); }); }).then(buf => WebAssembly.compile(buf)).then(wasm => mod.default(wasm)).then(() => mod); } if ("webworker" === sysEnv || "browsermain" === sysEnv) { let version2 = versions.qwik; const cachedCjsCode = `qwikWasmCjs${version2}`; const cachedWasmRsp = `qwikWasmRsp${version2}`; let cjsCode = globalThis[cachedCjsCode]; let wasmRsp = globalThis[cachedWasmRsp]; if (!cjsCode || !wasmRsp) { version2 = versions.qwik.split("-dev")[0]; const cdnUrl = `https://cdn.jsdelivr.net/npm/@builder.io/qwik@${version2}/bindings/`; const cjsModuleUrl = new URL("./qwik.wasm.cjs", cdnUrl).href; const wasmUrl = new URL("./qwik_wasm_bg.wasm", cdnUrl).href; const rsps = await Promise.all([ fetch(cjsModuleUrl), fetch(wasmUrl) ]); for (const rsp of rsps) { if (!rsp.ok) { throw new Error(`Unable to fetch Qwik WASM binding from ${rsp.url}`); } } const cjsRsp = rsps[0]; globalThis[cachedCjsCode] = cjsCode = await cjsRsp.text(); globalThis[cachedWasmRsp] = wasmRsp = rsps[1]; } const cjsModule = { exports: {} }; const cjsRun = new Function("module", "exports", cjsCode); cjsRun(cjsModule, cjsModule.exports); const mod = cjsModule.exports; await mod.default(wasmRsp.clone()); return mod; } false; throw new Error("Platform not supported"); } var getEnv = () => { if ("undefined" !== typeof Deno) { return "deno"; } if ("undefined" !== typeof Bun) { return "bun"; } if ("undefined" !== typeof process && "undefined" !== typeof global && process.versions && process.versions.node) { return "node"; } if ("undefined" !== typeof self && "undefined" !== typeof location && "undefined" !== typeof navigator && "function" === typeof fetch && "function" === typeof WorkerGlobalScope && "function" === typeof self.importScripts) { return "webworker"; } if ("undefined" !== typeof window && "undefined" !== typeof document && "undefined" !== typeof location && "undefined" !== typeof navigator && "function" === typeof Window && "function" === typeof fetch) { return "browsermain"; } return "unknown"; }; var extensions = { ".js": true, ".ts": true, ".tsx": true, ".jsx": true, ".mjs": true }; var createOptimizer = async (optimizerOptions = {}) => { const sys = (null == optimizerOptions ? void 0 : optimizerOptions.sys) || await getSystem(); const binding = (null == optimizerOptions ? void 0 : optimizerOptions.binding) || await loadPlatformBinding(sys); const optimizer = { transformModules: async opts => transformModulesSync(binding, opts), transformModulesSync: opts => transformModulesSync(binding, opts), transformFs: async opts => transformFsAsync(sys, binding, opts), transformFsSync: opts => transformFsSync(binding, opts), sys: sys }; return optimizer; }; var transformModulesSync = (binding, opts) => binding.transform_modules(convertOptions(opts)); var transformFsSync = (binding, opts) => { if (binding.transform_fs) { return binding.transform_fs(convertOptions(opts)); } throw new Error("Not implemented"); }; var transformFsAsync = async (sys, binding, fsOpts) => { if (binding.transform_fs && !sys.getInputFiles) { return binding.transform_fs(convertOptions(fsOpts)); } const getInputFiles =