astro 3.0.12 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/astro-jsx.d.ts +28 -1
- package/client.d.ts +8 -4
- package/components/ViewTransitions.astro +77 -24
- package/content-types.template.d.ts +6 -1
- package/dist/@types/astro.d.ts +43 -22
- package/dist/assets/build/generate.d.ts +1 -1
- package/dist/assets/build/remote.d.ts +1 -1
- package/dist/assets/consts.d.ts +2 -2
- package/dist/assets/consts.js +4 -10
- package/dist/assets/internal.js +3 -2
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +7 -3
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/codecs.d.ts +4 -4
- package/dist/assets/services/vendor/squoosh/image-pool.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/image.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/image_data.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/impl.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/resize/squoosh_resize_bg.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/rotate/rotate.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/utils/workerPool.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm.d.ts +1 -1
- package/dist/assets/utils/metadata.d.ts +1 -1
- package/dist/assets/utils/metadata.js +6 -2
- package/dist/assets/vite-plugin-assets.d.ts +1 -1
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/add/babel.d.ts +12 -11
- package/dist/config/index.d.ts +1 -1
- package/dist/config/vite-plugin-content-listen.d.ts +2 -2
- package/dist/content/server-listeners.d.ts +1 -1
- package/dist/content/types-generator.d.ts +2 -2
- package/dist/content/utils.d.ts +1 -1
- package/dist/content/utils.js +1 -1
- package/dist/content/vite-plugin-content-assets.d.ts +1 -1
- package/dist/content/vite-plugin-content-imports.d.ts +1 -1
- package/dist/content/vite-plugin-content-virtual-mod.d.ts +1 -1
- package/dist/core/app/common.d.ts +1 -1
- package/dist/core/app/index.d.ts +1 -1
- package/dist/core/app/node.d.ts +3 -3
- package/dist/core/app/ssrPipeline.d.ts +1 -1
- package/dist/core/app/types.d.ts +2 -2
- package/dist/core/build/buildPipeline.d.ts +4 -4
- package/dist/core/build/common.d.ts +1 -1
- package/dist/core/build/css-asset-name.d.ts +1 -1
- package/dist/core/build/generate.d.ts +2 -2
- package/dist/core/build/generate.js +3 -0
- package/dist/core/build/index.d.ts +1 -1
- package/dist/core/build/internal.d.ts +3 -3
- package/dist/core/build/page-data.d.ts +3 -3
- package/dist/core/build/plugin.d.ts +2 -2
- package/dist/core/build/plugins/index.d.ts +1 -1
- package/dist/core/build/plugins/plugin-css.d.ts +3 -3
- package/dist/core/build/plugins/plugin-hoisted-scripts.d.ts +3 -3
- package/dist/core/build/plugins/plugin-internals.d.ts +1 -1
- package/dist/core/build/plugins/plugin-manifest.d.ts +3 -3
- package/dist/core/build/plugins/plugin-manifest.js +2 -2
- package/dist/core/build/plugins/plugin-middleware.d.ts +3 -3
- package/dist/core/build/plugins/plugin-pages.d.ts +3 -3
- package/dist/core/build/plugins/plugin-prerender.d.ts +1 -1
- package/dist/core/build/plugins/plugin-renderers.d.ts +2 -2
- package/dist/core/build/plugins/plugin-ssr.d.ts +2 -2
- package/dist/core/build/plugins/plugin-ssr.js +2 -2
- package/dist/core/build/static-build.d.ts +2 -2
- package/dist/core/build/types.d.ts +5 -4
- package/dist/core/compile/cache.d.ts +1 -1
- package/dist/core/compile/compile.d.ts +1 -1
- package/dist/core/compile/index.d.ts +2 -2
- package/dist/core/config/config.d.ts +2 -2
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/schema.d.ts +29 -15
- package/dist/core/config/schema.js +1 -0
- package/dist/core/config/settings.d.ts +1 -1
- package/dist/core/config/vite-load.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/response.d.ts +1 -1
- package/dist/core/create-vite.d.ts +3 -3
- package/dist/core/create-vite.js +1 -1
- package/dist/core/dev/container.d.ts +4 -4
- package/dist/core/dev/dev.d.ts +3 -3
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.d.ts +3 -3
- package/dist/core/endpoint/index.d.ts +3 -3
- package/dist/core/errors/dev/utils.js +4 -4
- package/dist/core/errors/errors-data.d.ts +12 -3
- package/dist/core/errors/errors-data.js +7 -4
- package/dist/core/errors/index.d.ts +1 -1
- package/dist/core/errors/overlay.js +2 -2
- package/dist/core/logger/node.d.ts +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.d.ts +2 -2
- package/dist/core/middleware/index.d.ts +2 -2
- package/dist/core/middleware/loadMiddleware.d.ts +2 -2
- package/dist/core/middleware/sequence.d.ts +1 -1
- package/dist/core/module-loader/loader.d.ts +2 -2
- package/dist/core/module-loader/vite.d.ts +1 -1
- package/dist/core/pipeline.d.ts +1 -1
- package/dist/core/preview/index.d.ts +1 -1
- package/dist/core/preview/static-preview-server.d.ts +3 -3
- package/dist/core/redirects/component.d.ts +2 -2
- package/dist/core/redirects/helpers.d.ts +1 -1
- package/dist/core/render/context.d.ts +2 -2
- package/dist/core/render/core.d.ts +1 -1
- package/dist/core/render/environment.d.ts +1 -1
- package/dist/core/render/index.d.ts +2 -2
- package/dist/core/render/paginate.d.ts +1 -1
- package/dist/core/render/params-and-props.d.ts +1 -1
- package/dist/core/render/renderer.d.ts +1 -1
- package/dist/core/render/result.d.ts +1 -1
- package/dist/core/render/route-cache.d.ts +1 -1
- package/dist/core/render/ssr-element.d.ts +2 -2
- package/dist/core/render/ssr-element.js +1 -3
- package/dist/core/request.d.ts +2 -2
- package/dist/core/routing/manifest/create.d.ts +3 -3
- package/dist/core/routing/manifest/generator.d.ts +1 -1
- package/dist/core/routing/manifest/serialization.d.ts +1 -1
- package/dist/core/routing/match.d.ts +1 -1
- package/dist/core/routing/params.d.ts +1 -1
- package/dist/core/routing/validation.d.ts +2 -2
- package/dist/core/sync/index.d.ts +2 -2
- package/dist/core/util.d.ts +2 -2
- package/dist/events/session.d.ts +1 -1
- package/dist/integrations/astroFeaturesValidation.d.ts +1 -1
- package/dist/integrations/index.d.ts +3 -3
- package/dist/prerender/metadata.d.ts +1 -1
- package/dist/prerender/routing.d.ts +2 -2
- package/dist/prerender/utils.d.ts +1 -1
- package/dist/runtime/client/hmr.js +1 -1
- package/dist/runtime/client/idle.d.ts +1 -1
- package/dist/runtime/client/load.d.ts +1 -1
- package/dist/runtime/client/media.d.ts +1 -1
- package/dist/runtime/client/only.d.ts +1 -1
- package/dist/runtime/client/visible.d.ts +1 -1
- package/dist/runtime/client/visible.prebuilt.d.ts +1 -1
- package/dist/runtime/client/visible.prebuilt.js +1 -1
- package/dist/runtime/server/astro-component.d.ts +1 -1
- package/dist/runtime/server/astro-global.d.ts +1 -1
- package/dist/runtime/server/astro-island.d.ts +1 -4
- package/dist/runtime/server/endpoint.d.ts +2 -2
- package/dist/runtime/server/hydration.d.ts +1 -1
- package/dist/runtime/server/render/astro/factory.d.ts +3 -3
- package/dist/runtime/server/render/astro/head-and-content.d.ts +1 -1
- package/dist/runtime/server/render/astro/index.d.ts +2 -2
- package/dist/runtime/server/render/astro/instance.d.ts +1 -1
- package/dist/runtime/server/render/astro/render.d.ts +1 -1
- package/dist/runtime/server/render/common.d.ts +1 -1
- package/dist/runtime/server/render/component.d.ts +1 -1
- package/dist/runtime/server/render/dom.d.ts +1 -1
- package/dist/runtime/server/render/head.d.ts +1 -1
- package/dist/runtime/server/render/index.d.ts +2 -2
- package/dist/runtime/server/render/page.d.ts +2 -2
- package/dist/runtime/server/render/tags.d.ts +2 -2
- package/dist/runtime/server/render/tags.js +1 -1
- package/dist/runtime/server/render/util.d.ts +1 -1
- package/dist/runtime/server/scripts.d.ts +1 -1
- package/dist/runtime/server/serialize.d.ts +1 -1
- package/dist/runtime/server/transition.d.ts +1 -1
- package/dist/transitions/index.d.ts +1 -1
- package/dist/type-utils.d.ts +4 -0
- package/dist/vite-plugin-astro/hmr.d.ts +1 -1
- package/dist/vite-plugin-astro/index.d.ts +2 -2
- package/dist/vite-plugin-astro/metadata.d.ts +2 -2
- package/dist/vite-plugin-astro/types.d.ts +1 -1
- package/dist/vite-plugin-astro-server/base.d.ts +1 -1
- package/dist/vite-plugin-astro-server/controller.d.ts +2 -2
- package/dist/vite-plugin-astro-server/css.d.ts +1 -1
- package/dist/vite-plugin-astro-server/devPipeline.d.ts +4 -4
- package/dist/vite-plugin-astro-server/index.d.ts +1 -1
- package/dist/vite-plugin-astro-server/metadata.d.ts +2 -2
- package/dist/vite-plugin-astro-server/plugin.d.ts +2 -2
- package/dist/vite-plugin-astro-server/request.d.ts +4 -4
- package/dist/vite-plugin-astro-server/resolve.d.ts +1 -1
- package/dist/vite-plugin-astro-server/response.d.ts +2 -2
- package/dist/vite-plugin-astro-server/route.d.ts +2 -2
- package/dist/vite-plugin-astro-server/route.js +0 -1
- package/dist/vite-plugin-astro-server/scripts.d.ts +2 -2
- package/dist/vite-plugin-astro-server/vite.d.ts +1 -1
- package/dist/vite-plugin-config-alias/index.d.ts +1 -1
- package/dist/vite-plugin-env/index.d.ts +1 -1
- package/dist/vite-plugin-inject-env-ts/index.d.ts +1 -1
- package/dist/vite-plugin-load-fallback/index.d.ts +1 -1
- package/dist/vite-plugin-markdown/index.d.ts +1 -1
- package/dist/vite-plugin-markdown/index.js +20 -20
- package/dist/vite-plugin-mdx/index.d.ts +1 -1
- package/dist/vite-plugin-utils/index.d.ts +1 -1
- package/package.json +4 -2
- package/types.d.ts +6 -1
- package/dist/assets/vendor/image-size/detector.d.ts +0 -3
- package/dist/assets/vendor/image-size/detector.js +0 -28
- package/dist/assets/vendor/image-size/index.d.ts +0 -11
- package/dist/assets/vendor/image-size/index.js +0 -93
- package/dist/assets/vendor/image-size/readUInt.d.ts +0 -4
- package/dist/assets/vendor/image-size/readUInt.js +0 -9
- package/dist/assets/vendor/image-size/types/bmp.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/bmp.js +0 -14
- package/dist/assets/vendor/image-size/types/cur.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/cur.js +0 -16
- package/dist/assets/vendor/image-size/types/dds.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/dds.js +0 -14
- package/dist/assets/vendor/image-size/types/gif.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/gif.js +0 -16
- package/dist/assets/vendor/image-size/types/icns.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/icns.js +0 -87
- package/dist/assets/vendor/image-size/types/ico.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/ico.js +0 -42
- package/dist/assets/vendor/image-size/types/interface.d.ts +0 -14
- package/dist/assets/vendor/image-size/types/interface.js +0 -0
- package/dist/assets/vendor/image-size/types/j2c.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/j2c.js +0 -14
- package/dist/assets/vendor/image-size/types/jp2.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/jp2.js +0 -56
- package/dist/assets/vendor/image-size/types/jpg.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/jpg.js +0 -95
- package/dist/assets/vendor/image-size/types/ktx.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/ktx.js +0 -15
- package/dist/assets/vendor/image-size/types/png.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/png.js +0 -33
- package/dist/assets/vendor/image-size/types/pnm.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/pnm.js +0 -72
- package/dist/assets/vendor/image-size/types/psd.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/psd.js +0 -14
- package/dist/assets/vendor/image-size/types/svg.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/svg.js +0 -91
- package/dist/assets/vendor/image-size/types/tiff.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/tiff.js +0 -81
- package/dist/assets/vendor/image-size/types/webp.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/webp.js +0 -51
- package/dist/assets/vendor/image-size/types.d.ts +0 -19
- package/dist/assets/vendor/image-size/types.js +0 -37
- package/dist/assets/vendor/queue/queue.d.ts +0 -39
- package/dist/assets/vendor/queue/queue.js +0 -187
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const BoxTypes = {
|
|
2
|
-
ftyp: "66747970",
|
|
3
|
-
ihdr: "69686472",
|
|
4
|
-
jp2h: "6a703268",
|
|
5
|
-
jp__: "6a502020",
|
|
6
|
-
rreq: "72726571",
|
|
7
|
-
xml_: "786d6c20"
|
|
8
|
-
};
|
|
9
|
-
const calculateRREQLength = (box) => {
|
|
10
|
-
const unit = box.readUInt8(0);
|
|
11
|
-
let offset = 1 + 2 * unit;
|
|
12
|
-
const numStdFlags = box.readUInt16BE(offset);
|
|
13
|
-
const flagsLength = numStdFlags * (2 + unit);
|
|
14
|
-
offset = offset + 2 + flagsLength;
|
|
15
|
-
const numVendorFeatures = box.readUInt16BE(offset);
|
|
16
|
-
const featuresLength = numVendorFeatures * (16 + unit);
|
|
17
|
-
return offset + 2 + featuresLength;
|
|
18
|
-
};
|
|
19
|
-
const parseIHDR = (box) => {
|
|
20
|
-
return {
|
|
21
|
-
height: box.readUInt32BE(4),
|
|
22
|
-
width: box.readUInt32BE(8)
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const JP2 = {
|
|
26
|
-
validate(buffer) {
|
|
27
|
-
const signature = buffer.toString("hex", 4, 8);
|
|
28
|
-
const signatureLength = buffer.readUInt32BE(0);
|
|
29
|
-
if (signature !== BoxTypes.jp__ || signatureLength < 1) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
const ftypeBoxStart = signatureLength + 4;
|
|
33
|
-
const ftypBoxLength = buffer.readUInt32BE(signatureLength);
|
|
34
|
-
const ftypBox = buffer.slice(ftypeBoxStart, ftypeBoxStart + ftypBoxLength);
|
|
35
|
-
return ftypBox.toString("hex", 0, 4) === BoxTypes.ftyp;
|
|
36
|
-
},
|
|
37
|
-
calculate(buffer) {
|
|
38
|
-
const signatureLength = buffer.readUInt32BE(0);
|
|
39
|
-
const ftypBoxLength = buffer.readUInt16BE(signatureLength + 2);
|
|
40
|
-
let offset = signatureLength + 4 + ftypBoxLength;
|
|
41
|
-
const nextBoxType = buffer.toString("hex", offset, offset + 4);
|
|
42
|
-
switch (nextBoxType) {
|
|
43
|
-
case BoxTypes.rreq:
|
|
44
|
-
const MAGIC = 4;
|
|
45
|
-
offset = offset + 4 + MAGIC + calculateRREQLength(buffer.slice(offset + 4));
|
|
46
|
-
return parseIHDR(buffer.slice(offset + 8, offset + 24));
|
|
47
|
-
case BoxTypes.jp2h:
|
|
48
|
-
return parseIHDR(buffer.slice(offset + 8, offset + 24));
|
|
49
|
-
default:
|
|
50
|
-
throw new TypeError("Unsupported header found: " + buffer.toString("ascii", offset, offset + 4));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
export {
|
|
55
|
-
JP2
|
|
56
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { readUInt } from "../readUInt.js";
|
|
2
|
-
const EXIF_MARKER = "45786966";
|
|
3
|
-
const APP1_DATA_SIZE_BYTES = 2;
|
|
4
|
-
const EXIF_HEADER_BYTES = 6;
|
|
5
|
-
const TIFF_BYTE_ALIGN_BYTES = 2;
|
|
6
|
-
const BIG_ENDIAN_BYTE_ALIGN = "4d4d";
|
|
7
|
-
const LITTLE_ENDIAN_BYTE_ALIGN = "4949";
|
|
8
|
-
const IDF_ENTRY_BYTES = 12;
|
|
9
|
-
const NUM_DIRECTORY_ENTRIES_BYTES = 2;
|
|
10
|
-
function isEXIF(buffer) {
|
|
11
|
-
return buffer.toString("hex", 2, 6) === EXIF_MARKER;
|
|
12
|
-
}
|
|
13
|
-
function extractSize(buffer, index) {
|
|
14
|
-
return {
|
|
15
|
-
height: buffer.readUInt16BE(index),
|
|
16
|
-
width: buffer.readUInt16BE(index + 2)
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function extractOrientation(exifBlock, isBigEndian) {
|
|
20
|
-
const idfOffset = 8;
|
|
21
|
-
const offset = EXIF_HEADER_BYTES + idfOffset;
|
|
22
|
-
const idfDirectoryEntries = readUInt(exifBlock, 16, offset, isBigEndian);
|
|
23
|
-
for (let directoryEntryNumber = 0; directoryEntryNumber < idfDirectoryEntries; directoryEntryNumber++) {
|
|
24
|
-
const start = offset + NUM_DIRECTORY_ENTRIES_BYTES + directoryEntryNumber * IDF_ENTRY_BYTES;
|
|
25
|
-
const end = start + IDF_ENTRY_BYTES;
|
|
26
|
-
if (start > exifBlock.length) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const block = exifBlock.slice(start, end);
|
|
30
|
-
const tagNumber = readUInt(block, 16, 0, isBigEndian);
|
|
31
|
-
if (tagNumber === 274) {
|
|
32
|
-
const dataFormat = readUInt(block, 16, 2, isBigEndian);
|
|
33
|
-
if (dataFormat !== 3) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const numberOfComponents = readUInt(block, 32, 4, isBigEndian);
|
|
37
|
-
if (numberOfComponents !== 1) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
return readUInt(block, 16, 8, isBigEndian);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function validateExifBlock(buffer, index) {
|
|
45
|
-
const exifBlock = buffer.slice(APP1_DATA_SIZE_BYTES, index);
|
|
46
|
-
const byteAlign = exifBlock.toString("hex", EXIF_HEADER_BYTES, EXIF_HEADER_BYTES + TIFF_BYTE_ALIGN_BYTES);
|
|
47
|
-
const isBigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN;
|
|
48
|
-
const isLittleEndian = byteAlign === LITTLE_ENDIAN_BYTE_ALIGN;
|
|
49
|
-
if (isBigEndian || isLittleEndian) {
|
|
50
|
-
return extractOrientation(exifBlock, isBigEndian);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function validateBuffer(buffer, index) {
|
|
54
|
-
if (index > buffer.length) {
|
|
55
|
-
throw new TypeError("Corrupt JPG, exceeded buffer limits");
|
|
56
|
-
}
|
|
57
|
-
if (buffer[index] !== 255) {
|
|
58
|
-
throw new TypeError("Invalid JPG, marker table corrupted");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const JPG = {
|
|
62
|
-
validate(buffer) {
|
|
63
|
-
const SOIMarker = buffer.toString("hex", 0, 2);
|
|
64
|
-
return "ffd8" === SOIMarker;
|
|
65
|
-
},
|
|
66
|
-
calculate(buffer) {
|
|
67
|
-
buffer = buffer.slice(4);
|
|
68
|
-
let orientation;
|
|
69
|
-
let next;
|
|
70
|
-
while (buffer.length) {
|
|
71
|
-
const i = buffer.readUInt16BE(0);
|
|
72
|
-
if (isEXIF(buffer)) {
|
|
73
|
-
orientation = validateExifBlock(buffer, i);
|
|
74
|
-
}
|
|
75
|
-
validateBuffer(buffer, i);
|
|
76
|
-
next = buffer[i + 1];
|
|
77
|
-
if (next === 192 || next === 193 || next === 194) {
|
|
78
|
-
const size = extractSize(buffer, i + 5);
|
|
79
|
-
if (!orientation) {
|
|
80
|
-
return size;
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
height: size.height,
|
|
84
|
-
orientation,
|
|
85
|
-
width: size.width
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
buffer = buffer.slice(i + 2);
|
|
89
|
-
}
|
|
90
|
-
throw new TypeError("Invalid JPG, no size found");
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
export {
|
|
94
|
-
JPG
|
|
95
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const SIGNATURE = "KTX 11";
|
|
2
|
-
const KTX = {
|
|
3
|
-
validate(buffer) {
|
|
4
|
-
return SIGNATURE === buffer.toString("ascii", 1, 7);
|
|
5
|
-
},
|
|
6
|
-
calculate(buffer) {
|
|
7
|
-
return {
|
|
8
|
-
height: buffer.readUInt32LE(40),
|
|
9
|
-
width: buffer.readUInt32LE(36)
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
KTX
|
|
15
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const pngSignature = "PNG\r\n\n";
|
|
2
|
-
const pngImageHeaderChunkName = "IHDR";
|
|
3
|
-
const pngFriedChunkName = "CgBI";
|
|
4
|
-
const PNG = {
|
|
5
|
-
validate(buffer) {
|
|
6
|
-
if (pngSignature === buffer.toString("ascii", 1, 8)) {
|
|
7
|
-
let chunkName = buffer.toString("ascii", 12, 16);
|
|
8
|
-
if (chunkName === pngFriedChunkName) {
|
|
9
|
-
chunkName = buffer.toString("ascii", 28, 32);
|
|
10
|
-
}
|
|
11
|
-
if (chunkName !== pngImageHeaderChunkName) {
|
|
12
|
-
throw new TypeError("Invalid PNG");
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
},
|
|
18
|
-
calculate(buffer) {
|
|
19
|
-
if (buffer.toString("ascii", 12, 16) === pngFriedChunkName) {
|
|
20
|
-
return {
|
|
21
|
-
height: buffer.readUInt32BE(36),
|
|
22
|
-
width: buffer.readUInt32BE(32)
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
height: buffer.readUInt32BE(20),
|
|
27
|
-
width: buffer.readUInt32BE(16)
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
PNG
|
|
33
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const PNMTypes = {
|
|
2
|
-
P1: "pbm/ascii",
|
|
3
|
-
P2: "pgm/ascii",
|
|
4
|
-
P3: "ppm/ascii",
|
|
5
|
-
P4: "pbm",
|
|
6
|
-
P5: "pgm",
|
|
7
|
-
P6: "ppm",
|
|
8
|
-
P7: "pam",
|
|
9
|
-
PF: "pfm"
|
|
10
|
-
};
|
|
11
|
-
const Signatures = Object.keys(PNMTypes);
|
|
12
|
-
const handlers = {
|
|
13
|
-
default: (lines) => {
|
|
14
|
-
let dimensions = [];
|
|
15
|
-
while (lines.length > 0) {
|
|
16
|
-
const line = lines.shift();
|
|
17
|
-
if (line[0] === "#") {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
dimensions = line.split(" ");
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
if (dimensions.length === 2) {
|
|
24
|
-
return {
|
|
25
|
-
height: parseInt(dimensions[1], 10),
|
|
26
|
-
width: parseInt(dimensions[0], 10)
|
|
27
|
-
};
|
|
28
|
-
} else {
|
|
29
|
-
throw new TypeError("Invalid PNM");
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
pam: (lines) => {
|
|
33
|
-
const size = {};
|
|
34
|
-
while (lines.length > 0) {
|
|
35
|
-
const line = lines.shift();
|
|
36
|
-
if (line.length > 16 || line.charCodeAt(0) > 128) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
const [key, value] = line.split(" ");
|
|
40
|
-
if (key && value) {
|
|
41
|
-
size[key.toLowerCase()] = parseInt(value, 10);
|
|
42
|
-
}
|
|
43
|
-
if (size.height && size.width) {
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (size.height && size.width) {
|
|
48
|
-
return {
|
|
49
|
-
height: size.height,
|
|
50
|
-
width: size.width
|
|
51
|
-
};
|
|
52
|
-
} else {
|
|
53
|
-
throw new TypeError("Invalid PAM");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const PNM = {
|
|
58
|
-
validate(buffer) {
|
|
59
|
-
const signature = buffer.toString("ascii", 0, 2);
|
|
60
|
-
return Signatures.includes(signature);
|
|
61
|
-
},
|
|
62
|
-
calculate(buffer) {
|
|
63
|
-
const signature = buffer.toString("ascii", 0, 2);
|
|
64
|
-
const type = PNMTypes[signature];
|
|
65
|
-
const lines = buffer.toString("ascii", 3).split(/[\r\n]+/);
|
|
66
|
-
const handler = handlers[type] || handlers.default;
|
|
67
|
-
return handler(lines);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
export {
|
|
71
|
-
PNM
|
|
72
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const svgReg = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/;
|
|
2
|
-
const extractorRegExps = {
|
|
3
|
-
height: /\sheight=(['"])([^%]+?)\1/,
|
|
4
|
-
root: svgReg,
|
|
5
|
-
viewbox: /\sviewBox=(['"])(.+?)\1/i,
|
|
6
|
-
width: /\swidth=(['"])([^%]+?)\1/
|
|
7
|
-
};
|
|
8
|
-
const INCH_CM = 2.54;
|
|
9
|
-
const units = {
|
|
10
|
-
in: 96,
|
|
11
|
-
cm: 96 / INCH_CM,
|
|
12
|
-
em: 16,
|
|
13
|
-
ex: 8,
|
|
14
|
-
m: 96 / INCH_CM * 100,
|
|
15
|
-
mm: 96 / INCH_CM / 10,
|
|
16
|
-
pc: 96 / 72 / 12,
|
|
17
|
-
pt: 96 / 72,
|
|
18
|
-
px: 1
|
|
19
|
-
};
|
|
20
|
-
const unitsReg = new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(units).join("|")})?$`);
|
|
21
|
-
function parseLength(len) {
|
|
22
|
-
const m = unitsReg.exec(len);
|
|
23
|
-
if (!m) {
|
|
24
|
-
return void 0;
|
|
25
|
-
}
|
|
26
|
-
return Math.round(Number(m[1]) * (units[m[2]] || 1));
|
|
27
|
-
}
|
|
28
|
-
function parseViewbox(viewbox) {
|
|
29
|
-
const bounds = viewbox.split(" ");
|
|
30
|
-
return {
|
|
31
|
-
height: parseLength(bounds[3]),
|
|
32
|
-
width: parseLength(bounds[2])
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function parseAttributes(root) {
|
|
36
|
-
const width = root.match(extractorRegExps.width);
|
|
37
|
-
const height = root.match(extractorRegExps.height);
|
|
38
|
-
const viewbox = root.match(extractorRegExps.viewbox);
|
|
39
|
-
return {
|
|
40
|
-
height: height && parseLength(height[2]),
|
|
41
|
-
viewbox: viewbox && parseViewbox(viewbox[2]),
|
|
42
|
-
width: width && parseLength(width[2])
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function calculateByDimensions(attrs) {
|
|
46
|
-
return {
|
|
47
|
-
height: attrs.height,
|
|
48
|
-
width: attrs.width
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function calculateByViewbox(attrs, viewbox) {
|
|
52
|
-
const ratio = viewbox.width / viewbox.height;
|
|
53
|
-
if (attrs.width) {
|
|
54
|
-
return {
|
|
55
|
-
height: Math.floor(attrs.width / ratio),
|
|
56
|
-
width: attrs.width
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (attrs.height) {
|
|
60
|
-
return {
|
|
61
|
-
height: attrs.height,
|
|
62
|
-
width: Math.floor(attrs.height * ratio)
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
height: viewbox.height,
|
|
67
|
-
width: viewbox.width
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const SVG = {
|
|
71
|
-
validate(buffer) {
|
|
72
|
-
const str = String(buffer);
|
|
73
|
-
return svgReg.test(str);
|
|
74
|
-
},
|
|
75
|
-
calculate(buffer) {
|
|
76
|
-
const root = buffer.toString("utf8").match(extractorRegExps.root);
|
|
77
|
-
if (root) {
|
|
78
|
-
const attrs = parseAttributes(root[0]);
|
|
79
|
-
if (attrs.width && attrs.height) {
|
|
80
|
-
return calculateByDimensions(attrs);
|
|
81
|
-
}
|
|
82
|
-
if (attrs.viewbox) {
|
|
83
|
-
return calculateByViewbox(attrs, attrs.viewbox);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
throw new TypeError("Invalid SVG");
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
export {
|
|
90
|
-
SVG
|
|
91
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import { readUInt } from "../readUInt.js";
|
|
3
|
-
function readIFD(buffer, filepath, isBigEndian) {
|
|
4
|
-
const ifdOffset = readUInt(buffer, 32, 4, isBigEndian);
|
|
5
|
-
let bufferSize = 1024;
|
|
6
|
-
const fileSize = fs.statSync(filepath).size;
|
|
7
|
-
if (ifdOffset + bufferSize > fileSize) {
|
|
8
|
-
bufferSize = fileSize - ifdOffset - 10;
|
|
9
|
-
}
|
|
10
|
-
const endBuffer = Buffer.alloc(bufferSize);
|
|
11
|
-
const descriptor = fs.openSync(filepath, "r");
|
|
12
|
-
fs.readSync(descriptor, endBuffer, 0, bufferSize, ifdOffset);
|
|
13
|
-
fs.closeSync(descriptor);
|
|
14
|
-
return endBuffer.slice(2);
|
|
15
|
-
}
|
|
16
|
-
function readValue(buffer, isBigEndian) {
|
|
17
|
-
const low = readUInt(buffer, 16, 8, isBigEndian);
|
|
18
|
-
const high = readUInt(buffer, 16, 10, isBigEndian);
|
|
19
|
-
return (high << 16) + low;
|
|
20
|
-
}
|
|
21
|
-
function nextTag(buffer) {
|
|
22
|
-
if (buffer.length > 24) {
|
|
23
|
-
return buffer.slice(12);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function extractTags(buffer, isBigEndian) {
|
|
27
|
-
const tags = {};
|
|
28
|
-
let temp = buffer;
|
|
29
|
-
while (temp?.length) {
|
|
30
|
-
const code = readUInt(temp, 16, 0, isBigEndian);
|
|
31
|
-
const type = readUInt(temp, 16, 2, isBigEndian);
|
|
32
|
-
const length = readUInt(temp, 32, 4, isBigEndian);
|
|
33
|
-
if (code === 0) {
|
|
34
|
-
break;
|
|
35
|
-
} else {
|
|
36
|
-
if (length === 1 && (type === 3 || type === 4)) {
|
|
37
|
-
tags[code] = readValue(temp, isBigEndian);
|
|
38
|
-
}
|
|
39
|
-
temp = nextTag(temp);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return tags;
|
|
43
|
-
}
|
|
44
|
-
function determineEndianness(buffer) {
|
|
45
|
-
const signature = buffer.toString("ascii", 0, 2);
|
|
46
|
-
if ("II" === signature) {
|
|
47
|
-
return "LE";
|
|
48
|
-
} else if ("MM" === signature) {
|
|
49
|
-
return "BE";
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const signatures = [
|
|
53
|
-
// '492049', // currently not supported
|
|
54
|
-
"49492a00",
|
|
55
|
-
// Little endian
|
|
56
|
-
"4d4d002a"
|
|
57
|
-
// Big Endian
|
|
58
|
-
// '4d4d002a', // BigTIFF > 4GB. currently not supported
|
|
59
|
-
];
|
|
60
|
-
const TIFF = {
|
|
61
|
-
validate(buffer) {
|
|
62
|
-
return signatures.includes(buffer.toString("hex", 0, 4));
|
|
63
|
-
},
|
|
64
|
-
calculate(buffer, filepath) {
|
|
65
|
-
if (!filepath) {
|
|
66
|
-
throw new TypeError("Tiff doesn't support buffer");
|
|
67
|
-
}
|
|
68
|
-
const isBigEndian = determineEndianness(buffer) === "BE";
|
|
69
|
-
const ifdBuffer = readIFD(buffer, filepath, isBigEndian);
|
|
70
|
-
const tags = extractTags(ifdBuffer, isBigEndian);
|
|
71
|
-
const width = tags[256];
|
|
72
|
-
const height = tags[257];
|
|
73
|
-
if (!width || !height) {
|
|
74
|
-
throw new TypeError("Invalid Tiff. Missing tags");
|
|
75
|
-
}
|
|
76
|
-
return { height, width };
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
export {
|
|
80
|
-
TIFF
|
|
81
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
function calculateExtended(buffer) {
|
|
2
|
-
return {
|
|
3
|
-
height: 1 + buffer.readUIntLE(7, 3),
|
|
4
|
-
width: 1 + buffer.readUIntLE(4, 3)
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
function calculateLossless(buffer) {
|
|
8
|
-
return {
|
|
9
|
-
height: 1 + ((buffer[4] & 15) << 10 | buffer[3] << 2 | (buffer[2] & 192) >> 6),
|
|
10
|
-
width: 1 + ((buffer[2] & 63) << 8 | buffer[1])
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function calculateLossy(buffer) {
|
|
14
|
-
return {
|
|
15
|
-
height: buffer.readInt16LE(8) & 16383,
|
|
16
|
-
width: buffer.readInt16LE(6) & 16383
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const WEBP = {
|
|
20
|
-
validate(buffer) {
|
|
21
|
-
const riffHeader = "RIFF" === buffer.toString("ascii", 0, 4);
|
|
22
|
-
const webpHeader = "WEBP" === buffer.toString("ascii", 8, 12);
|
|
23
|
-
const vp8Header = "VP8" === buffer.toString("ascii", 12, 15);
|
|
24
|
-
return riffHeader && webpHeader && vp8Header;
|
|
25
|
-
},
|
|
26
|
-
calculate(buffer) {
|
|
27
|
-
const chunkHeader = buffer.toString("ascii", 12, 16);
|
|
28
|
-
buffer = buffer.slice(20, 30);
|
|
29
|
-
if (chunkHeader === "VP8X") {
|
|
30
|
-
const extendedHeader = buffer[0];
|
|
31
|
-
const validStart = (extendedHeader & 192) === 0;
|
|
32
|
-
const validEnd = (extendedHeader & 1) === 0;
|
|
33
|
-
if (validStart && validEnd) {
|
|
34
|
-
return calculateExtended(buffer);
|
|
35
|
-
} else {
|
|
36
|
-
throw new TypeError("Invalid WebP");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (chunkHeader === "VP8 " && buffer[0] !== 47) {
|
|
40
|
-
return calculateLossy(buffer);
|
|
41
|
-
}
|
|
42
|
-
const signature = buffer.toString("hex", 3, 6);
|
|
43
|
-
if (chunkHeader === "VP8L" && signature !== "9d012a") {
|
|
44
|
-
return calculateLossless(buffer);
|
|
45
|
-
}
|
|
46
|
-
throw new TypeError("Invalid WebP");
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
export {
|
|
50
|
-
WEBP
|
|
51
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const typeHandlers: {
|
|
2
|
-
bmp: import("./types/interface.js").IImage;
|
|
3
|
-
cur: import("./types/interface.js").IImage;
|
|
4
|
-
dds: import("./types/interface.js").IImage;
|
|
5
|
-
gif: import("./types/interface.js").IImage;
|
|
6
|
-
icns: import("./types/interface.js").IImage;
|
|
7
|
-
ico: import("./types/interface.js").IImage;
|
|
8
|
-
j2c: import("./types/interface.js").IImage;
|
|
9
|
-
jp2: import("./types/interface.js").IImage;
|
|
10
|
-
jpg: import("./types/interface.js").IImage;
|
|
11
|
-
ktx: import("./types/interface.js").IImage;
|
|
12
|
-
png: import("./types/interface.js").IImage;
|
|
13
|
-
pnm: import("./types/interface.js").IImage;
|
|
14
|
-
psd: import("./types/interface.js").IImage;
|
|
15
|
-
svg: import("./types/interface.js").IImage;
|
|
16
|
-
tiff: import("./types/interface.js").IImage;
|
|
17
|
-
webp: import("./types/interface.js").IImage;
|
|
18
|
-
};
|
|
19
|
-
export type imageType = keyof typeof typeHandlers;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { BMP } from "./types/bmp.js";
|
|
2
|
-
import { CUR } from "./types/cur.js";
|
|
3
|
-
import { DDS } from "./types/dds.js";
|
|
4
|
-
import { GIF } from "./types/gif.js";
|
|
5
|
-
import { ICNS } from "./types/icns.js";
|
|
6
|
-
import { ICO } from "./types/ico.js";
|
|
7
|
-
import { J2C } from "./types/j2c.js";
|
|
8
|
-
import { JP2 } from "./types/jp2.js";
|
|
9
|
-
import { JPG } from "./types/jpg.js";
|
|
10
|
-
import { KTX } from "./types/ktx.js";
|
|
11
|
-
import { PNG } from "./types/png.js";
|
|
12
|
-
import { PNM } from "./types/pnm.js";
|
|
13
|
-
import { PSD } from "./types/psd.js";
|
|
14
|
-
import { SVG } from "./types/svg.js";
|
|
15
|
-
import { TIFF } from "./types/tiff.js";
|
|
16
|
-
import { WEBP } from "./types/webp.js";
|
|
17
|
-
const typeHandlers = {
|
|
18
|
-
bmp: BMP,
|
|
19
|
-
cur: CUR,
|
|
20
|
-
dds: DDS,
|
|
21
|
-
gif: GIF,
|
|
22
|
-
icns: ICNS,
|
|
23
|
-
ico: ICO,
|
|
24
|
-
j2c: J2C,
|
|
25
|
-
jp2: JP2,
|
|
26
|
-
jpg: JPG,
|
|
27
|
-
ktx: KTX,
|
|
28
|
-
png: PNG,
|
|
29
|
-
pnm: PNM,
|
|
30
|
-
psd: PSD,
|
|
31
|
-
svg: SVG,
|
|
32
|
-
tiff: TIFF,
|
|
33
|
-
webp: WEBP
|
|
34
|
-
};
|
|
35
|
-
export {
|
|
36
|
-
typeHandlers
|
|
37
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Since CustomEvent is only supported in nodejs since version 19,
|
|
3
|
-
* you have to create your own class instead of using CustomEvent
|
|
4
|
-
* @see https://github.com/nodejs/node/issues/40678
|
|
5
|
-
* */
|
|
6
|
-
export class QueueEvent extends Event {
|
|
7
|
-
constructor(name: any, detail: any);
|
|
8
|
-
detail: any;
|
|
9
|
-
}
|
|
10
|
-
export default class Queue extends EventTarget {
|
|
11
|
-
constructor(options?: {});
|
|
12
|
-
concurrency: any;
|
|
13
|
-
timeout: any;
|
|
14
|
-
autostart: any;
|
|
15
|
-
results: any;
|
|
16
|
-
pending: number;
|
|
17
|
-
session: number;
|
|
18
|
-
running: boolean;
|
|
19
|
-
jobs: any[];
|
|
20
|
-
timers: any[];
|
|
21
|
-
_errorHandler(evt: any): void;
|
|
22
|
-
pop(): any;
|
|
23
|
-
shift(): any;
|
|
24
|
-
indexOf(searchElement: any, fromIndex: any): number;
|
|
25
|
-
lastIndexOf(searchElement: any, fromIndex: any): number;
|
|
26
|
-
slice(start: any, end: any): this;
|
|
27
|
-
reverse(): this;
|
|
28
|
-
push(...workers: any[]): number;
|
|
29
|
-
unshift(...workers: any[]): number;
|
|
30
|
-
splice(start: any, deleteCount: any, ...workers: any[]): this;
|
|
31
|
-
get length(): number;
|
|
32
|
-
start(callback: any): any;
|
|
33
|
-
stop(): void;
|
|
34
|
-
end(error: any): void;
|
|
35
|
-
clearTimers(): void;
|
|
36
|
-
_addCallbackToEndEvent(cb: any): void;
|
|
37
|
-
_createPromiseToEndEvent(): Promise<any>;
|
|
38
|
-
done(error: any): void;
|
|
39
|
-
}
|