astro 2.0.17 → 2.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 +3 -3
- package/client-base.d.ts +27 -0
- package/client-image.d.ts +48 -0
- package/components/Image.astro +28 -0
- package/dist/@types/astro.d.ts +101 -1
- package/dist/assets/consts.d.ts +4 -0
- package/dist/assets/consts.js +20 -0
- package/dist/assets/image-endpoint.d.ts +5 -0
- package/dist/assets/image-endpoint.js +50 -0
- package/dist/assets/index.d.ts +4 -0
- package/dist/assets/index.js +10 -0
- package/dist/assets/internal.d.ts +36 -0
- package/dist/assets/internal.js +70 -0
- package/dist/assets/services/service.d.ts +71 -0
- package/dist/assets/services/service.js +88 -0
- package/dist/assets/services/sharp.d.ts +3 -0
- package/dist/assets/services/sharp.js +57 -0
- package/dist/assets/services/squoosh.d.ts +3 -0
- package/dist/assets/services/squoosh.js +56 -0
- package/dist/assets/services/vendor/squoosh/avif/avif_enc.d.js +11 -0
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.d.ts +2 -0
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +1628 -0
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm +0 -0
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.d.ts +2 -0
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +1850 -0
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm +0 -0
- package/dist/assets/services/vendor/squoosh/codecs.d.ts +158 -0
- package/dist/assets/services/vendor/squoosh/codecs.js +284 -0
- package/dist/assets/services/vendor/squoosh/copy-wasm.d.ts +1 -0
- package/dist/assets/services/vendor/squoosh/copy-wasm.js +24 -0
- package/dist/assets/services/vendor/squoosh/emscripten-types.d.js +0 -0
- package/dist/assets/services/vendor/squoosh/emscripten-utils.d.ts +9 -0
- package/dist/assets/services/vendor/squoosh/emscripten-utils.js +33 -0
- package/dist/assets/services/vendor/squoosh/image-pool.d.ts +4 -0
- package/dist/assets/services/vendor/squoosh/image-pool.js +94 -0
- package/dist/assets/services/vendor/squoosh/image.d.ts +14 -0
- package/dist/assets/services/vendor/squoosh/image.js +27 -0
- package/dist/assets/services/vendor/squoosh/image_data.d.ts +9 -0
- package/dist/assets/services/vendor/squoosh/image_data.js +22 -0
- package/dist/assets/services/vendor/squoosh/impl.d.ts +22 -0
- package/dist/assets/services/vendor/squoosh/impl.js +110 -0
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_enc.d.js +11 -0
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.d.ts +2 -0
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +1631 -0
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.wasm +0 -0
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.d.ts +2 -0
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +1737 -0
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.wasm +0 -0
- package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng.d.ts +10 -0
- package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng.js +89 -0
- package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm +0 -0
- package/dist/assets/services/vendor/squoosh/png/squoosh_png.d.ts +15 -0
- package/dist/assets/services/vendor/squoosh/png/squoosh_png.js +138 -0
- package/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm +0 -0
- package/dist/assets/services/vendor/squoosh/resize/squoosh_resize.d.ts +15 -0
- package/dist/assets/services/vendor/squoosh/resize/squoosh_resize.js +95 -0
- package/dist/assets/services/vendor/squoosh/resize/squoosh_resize_bg.wasm +0 -0
- package/dist/assets/services/vendor/squoosh/rotate/rotate.wasm +0 -0
- package/dist/assets/services/vendor/squoosh/utils/execOnce.d.ts +1 -0
- package/dist/assets/services/vendor/squoosh/utils/execOnce.js +14 -0
- package/dist/assets/services/vendor/squoosh/utils/workerPool.d.ts +22 -0
- package/dist/assets/services/vendor/squoosh/utils/workerPool.js +95 -0
- package/dist/assets/services/vendor/squoosh/webp/webp_enc.d.js +4 -0
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.d.ts +2 -0
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +1473 -0
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm +0 -0
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.d.ts +2 -0
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +1640 -0
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm +0 -0
- package/dist/assets/types.d.ts +119 -0
- package/dist/assets/types.js +0 -0
- package/dist/assets/utils/etag.d.ts +12 -0
- package/dist/assets/utils/etag.js +28 -0
- package/dist/assets/utils/metadata.d.ts +6 -0
- package/dist/assets/utils/metadata.js +30 -0
- package/dist/assets/utils/queryParams.d.ts +2 -0
- package/dist/assets/utils/queryParams.js +16 -0
- package/dist/assets/utils/transformToPath.d.ts +2 -0
- package/dist/assets/utils/transformToPath.js +17 -0
- package/dist/assets/vite-plugin-assets.d.ts +5 -0
- package/dist/assets/vite-plugin-assets.js +187 -0
- package/dist/cli/check/index.d.ts +81 -2
- package/dist/cli/check/index.js +190 -44
- package/dist/cli/index.js +39 -16
- package/dist/cli/telemetry.js +1 -1
- package/dist/content/consts.d.ts +0 -1
- package/dist/content/consts.js +1 -3
- package/dist/content/internal.d.ts +7 -0
- package/dist/content/internal.js +27 -5
- package/dist/content/template/virtual-mod.d.mts +1 -0
- package/dist/content/types-generator.js +25 -10
- package/dist/content/utils.d.ts +16 -13
- package/dist/content/utils.js +29 -6
- package/dist/content/vite-plugin-content-assets.d.ts +3 -1
- package/dist/content/vite-plugin-content-assets.js +10 -6
- package/dist/content/vite-plugin-content-imports.js +54 -27
- package/dist/content/vite-plugin-content-virtual-mod.js +7 -4
- package/dist/core/add/index.js +2 -1
- package/dist/core/app/index.js +104 -134
- package/dist/core/build/generate.js +30 -5
- package/dist/core/build/index.d.ts +2 -0
- package/dist/core/build/index.js +16 -0
- package/dist/core/build/plugins/plugin-ssr.js +3 -5
- package/dist/core/config/config.js +2 -1
- package/dist/core/config/schema.d.ts +64 -8
- package/dist/core/config/schema.js +17 -3
- package/dist/core/config/settings.js +4 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.js +36 -68
- package/dist/core/create-vite.js +5 -1
- package/dist/core/dev/dev.d.ts +2 -2
- package/dist/core/dev/dev.js +24 -4
- package/dist/core/errors/dev/vite.js +6 -1
- package/dist/core/errors/errors-data.d.ts +17 -1
- package/dist/core/errors/errors-data.js +16 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/path.d.ts +1 -0
- package/dist/core/path.js +4 -0
- package/dist/core/preview/index.d.ts +3 -1
- package/dist/core/preview/index.js +16 -1
- package/dist/core/render/dev/css.js +2 -2
- package/dist/core/render/dev/environment.js +1 -5
- package/dist/core/render/environment.js +1 -2
- package/dist/core/render/result.js +13 -35
- package/dist/core/sync/index.d.ts +18 -5
- package/dist/core/sync/index.js +13 -1
- package/dist/integrations/index.js +12 -1
- package/dist/runtime/server/render/component.js +1 -1
- package/dist/runtime/server/response.js +11 -30
- package/dist/vite-plugin-astro-postprocess/index.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.js +1 -1
- package/dist/vite-plugin-env/index.js +4 -4
- package/dist/vite-plugin-inject-env-ts/index.js +17 -2
- package/dist/vite-plugin-markdown/content-entry-type.d.ts +7 -0
- package/dist/vite-plugin-markdown/content-entry-type.js +39 -0
- package/dist/vite-plugin-markdown/index.js +70 -4
- package/dist/vite-plugin-ssr-manifest/index.d.ts +2 -0
- package/dist/vite-plugin-ssr-manifest/index.js +25 -0
- package/package.json +26 -9
- package/src/content/template/types.d.ts +18 -9
- package/src/content/template/virtual-mod.mjs +6 -0
- package/tsconfigs/base.json +6 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array} data
|
|
3
|
+
* @param {number} level
|
|
4
|
+
* @param {boolean} interlace
|
|
5
|
+
* @returns {Uint8Array}
|
|
6
|
+
*/
|
|
7
|
+
export declare function optimise(data: any, level: any, interlace: any): any;
|
|
8
|
+
declare function init(input: any): Promise<WebAssembly.Exports>;
|
|
9
|
+
export default init;
|
|
10
|
+
export declare function cleanup(): void;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
let cachedTextDecoder = new TextDecoder("utf-8", {
|
|
3
|
+
ignoreBOM: true,
|
|
4
|
+
fatal: true
|
|
5
|
+
});
|
|
6
|
+
cachedTextDecoder.decode();
|
|
7
|
+
let cachegetUint8Memory0 = null;
|
|
8
|
+
function getUint8Memory0() {
|
|
9
|
+
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
|
10
|
+
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
11
|
+
}
|
|
12
|
+
return cachegetUint8Memory0;
|
|
13
|
+
}
|
|
14
|
+
function getStringFromWasm0(ptr, len) {
|
|
15
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
16
|
+
}
|
|
17
|
+
let WASM_VECTOR_LEN = 0;
|
|
18
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
19
|
+
const ptr = malloc(arg.length * 1);
|
|
20
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
21
|
+
WASM_VECTOR_LEN = arg.length;
|
|
22
|
+
return ptr;
|
|
23
|
+
}
|
|
24
|
+
let cachegetInt32Memory0 = null;
|
|
25
|
+
function getInt32Memory0() {
|
|
26
|
+
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
27
|
+
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
28
|
+
}
|
|
29
|
+
return cachegetInt32Memory0;
|
|
30
|
+
}
|
|
31
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
32
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
33
|
+
}
|
|
34
|
+
function optimise(data, level, interlace) {
|
|
35
|
+
try {
|
|
36
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
37
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
wasm.optimise(retptr, ptr0, len0, level, interlace);
|
|
40
|
+
const r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
41
|
+
const r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
42
|
+
const v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
43
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
44
|
+
return v1;
|
|
45
|
+
} finally {
|
|
46
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function load(module, imports) {
|
|
50
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
51
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
52
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
53
|
+
}
|
|
54
|
+
const bytes = await module.arrayBuffer();
|
|
55
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
56
|
+
} else {
|
|
57
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
58
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
59
|
+
return { instance, module };
|
|
60
|
+
} else {
|
|
61
|
+
return instance;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function init(input) {
|
|
66
|
+
const imports = {};
|
|
67
|
+
imports.wbg = {};
|
|
68
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
69
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
70
|
+
};
|
|
71
|
+
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
|
|
72
|
+
input = fetch(input);
|
|
73
|
+
}
|
|
74
|
+
const { instance, module } = await load(await input, imports);
|
|
75
|
+
wasm = instance.exports;
|
|
76
|
+
init.__wbindgen_wasm_module = module;
|
|
77
|
+
return wasm;
|
|
78
|
+
}
|
|
79
|
+
var squoosh_oxipng_default = init;
|
|
80
|
+
function cleanup() {
|
|
81
|
+
wasm = null;
|
|
82
|
+
cachegetUint8Memory0 = null;
|
|
83
|
+
cachegetInt32Memory0 = null;
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
cleanup,
|
|
87
|
+
squoosh_oxipng_default as default,
|
|
88
|
+
optimise
|
|
89
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array} data
|
|
3
|
+
* @param {number} width
|
|
4
|
+
* @param {number} height
|
|
5
|
+
* @returns {Uint8Array}
|
|
6
|
+
*/
|
|
7
|
+
export declare function encode(data: any, width: any, height: any): any;
|
|
8
|
+
/**
|
|
9
|
+
* @param {Uint8Array} data
|
|
10
|
+
* @returns {ImageData}
|
|
11
|
+
*/
|
|
12
|
+
export declare function decode(data: any): any;
|
|
13
|
+
declare function init(input: any): Promise<WebAssembly.Exports>;
|
|
14
|
+
export default init;
|
|
15
|
+
export declare function cleanup(): void;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
let cachedTextDecoder = new TextDecoder("utf-8", {
|
|
3
|
+
ignoreBOM: true,
|
|
4
|
+
fatal: true
|
|
5
|
+
});
|
|
6
|
+
cachedTextDecoder.decode();
|
|
7
|
+
let cachegetUint8Memory0 = null;
|
|
8
|
+
function getUint8Memory0() {
|
|
9
|
+
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
|
10
|
+
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
11
|
+
}
|
|
12
|
+
return cachegetUint8Memory0;
|
|
13
|
+
}
|
|
14
|
+
function getStringFromWasm0(ptr, len) {
|
|
15
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
16
|
+
}
|
|
17
|
+
let cachegetUint8ClampedMemory0 = null;
|
|
18
|
+
function getUint8ClampedMemory0() {
|
|
19
|
+
if (cachegetUint8ClampedMemory0 === null || cachegetUint8ClampedMemory0.buffer !== wasm.memory.buffer) {
|
|
20
|
+
cachegetUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
|
|
21
|
+
}
|
|
22
|
+
return cachegetUint8ClampedMemory0;
|
|
23
|
+
}
|
|
24
|
+
function getClampedArrayU8FromWasm0(ptr, len) {
|
|
25
|
+
return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
26
|
+
}
|
|
27
|
+
const heap = new Array(32).fill(void 0);
|
|
28
|
+
heap.push(void 0, null, true, false);
|
|
29
|
+
let heap_next = heap.length;
|
|
30
|
+
function addHeapObject(obj) {
|
|
31
|
+
if (heap_next === heap.length)
|
|
32
|
+
heap.push(heap.length + 1);
|
|
33
|
+
const idx = heap_next;
|
|
34
|
+
heap_next = heap[idx];
|
|
35
|
+
heap[idx] = obj;
|
|
36
|
+
return idx;
|
|
37
|
+
}
|
|
38
|
+
let WASM_VECTOR_LEN = 0;
|
|
39
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
40
|
+
const ptr = malloc(arg.length * 1);
|
|
41
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
42
|
+
WASM_VECTOR_LEN = arg.length;
|
|
43
|
+
return ptr;
|
|
44
|
+
}
|
|
45
|
+
let cachegetInt32Memory0 = null;
|
|
46
|
+
function getInt32Memory0() {
|
|
47
|
+
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
48
|
+
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
49
|
+
}
|
|
50
|
+
return cachegetInt32Memory0;
|
|
51
|
+
}
|
|
52
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
53
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
54
|
+
}
|
|
55
|
+
function encode(data, width, height) {
|
|
56
|
+
try {
|
|
57
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
58
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
59
|
+
const len0 = WASM_VECTOR_LEN;
|
|
60
|
+
wasm.encode(retptr, ptr0, len0, width, height);
|
|
61
|
+
const r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
62
|
+
const r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
63
|
+
const v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
64
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
65
|
+
return v1;
|
|
66
|
+
} finally {
|
|
67
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function getObject(idx) {
|
|
71
|
+
return heap[idx];
|
|
72
|
+
}
|
|
73
|
+
function dropObject(idx) {
|
|
74
|
+
if (idx < 36)
|
|
75
|
+
return;
|
|
76
|
+
heap[idx] = heap_next;
|
|
77
|
+
heap_next = idx;
|
|
78
|
+
}
|
|
79
|
+
function takeObject(idx) {
|
|
80
|
+
const ret = getObject(idx);
|
|
81
|
+
dropObject(idx);
|
|
82
|
+
return ret;
|
|
83
|
+
}
|
|
84
|
+
function decode(data) {
|
|
85
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
86
|
+
const len0 = WASM_VECTOR_LEN;
|
|
87
|
+
const ret = wasm.decode(ptr0, len0);
|
|
88
|
+
return takeObject(ret);
|
|
89
|
+
}
|
|
90
|
+
async function load(module, imports) {
|
|
91
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
92
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
93
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
94
|
+
}
|
|
95
|
+
const bytes = await module.arrayBuffer();
|
|
96
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
97
|
+
} else {
|
|
98
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
99
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
100
|
+
return { instance, module };
|
|
101
|
+
} else {
|
|
102
|
+
return instance;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function init(input) {
|
|
107
|
+
const imports = {};
|
|
108
|
+
imports.wbg = {};
|
|
109
|
+
imports.wbg.__wbg_newwithownedu8clampedarrayandsh_787b2db8ea6bfd62 = function(arg0, arg1, arg2, arg3) {
|
|
110
|
+
const v0 = getClampedArrayU8FromWasm0(arg0, arg1).slice();
|
|
111
|
+
wasm.__wbindgen_free(arg0, arg1 * 1);
|
|
112
|
+
const ret = new ImageData(v0, arg2 >>> 0, arg3 >>> 0);
|
|
113
|
+
return addHeapObject(ret);
|
|
114
|
+
};
|
|
115
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
116
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
117
|
+
};
|
|
118
|
+
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
|
|
119
|
+
input = fetch(input);
|
|
120
|
+
}
|
|
121
|
+
const { instance, module } = await load(await input, imports);
|
|
122
|
+
wasm = instance.exports;
|
|
123
|
+
init.__wbindgen_wasm_module = module;
|
|
124
|
+
return wasm;
|
|
125
|
+
}
|
|
126
|
+
var squoosh_png_default = init;
|
|
127
|
+
function cleanup() {
|
|
128
|
+
wasm = null;
|
|
129
|
+
cachegetUint8ClampedMemory0 = null;
|
|
130
|
+
cachegetUint8Memory0 = null;
|
|
131
|
+
cachegetInt32Memory0 = null;
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
cleanup,
|
|
135
|
+
decode,
|
|
136
|
+
squoosh_png_default as default,
|
|
137
|
+
encode
|
|
138
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array} input_image
|
|
3
|
+
* @param {number} input_width
|
|
4
|
+
* @param {number} input_height
|
|
5
|
+
* @param {number} output_width
|
|
6
|
+
* @param {number} output_height
|
|
7
|
+
* @param {number} typ_idx
|
|
8
|
+
* @param {boolean} premultiply
|
|
9
|
+
* @param {boolean} color_space_conversion
|
|
10
|
+
* @returns {Uint8ClampedArray}
|
|
11
|
+
*/
|
|
12
|
+
export declare function resize(input_image: any, input_width: any, input_height: any, output_width: any, output_height: any, typ_idx: any, premultiply: any, color_space_conversion: any): any;
|
|
13
|
+
declare function init(input: any): Promise<WebAssembly.Exports>;
|
|
14
|
+
export default init;
|
|
15
|
+
export declare function cleanup(): void;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
let cachegetUint8Memory0 = null;
|
|
3
|
+
function getUint8Memory0() {
|
|
4
|
+
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
|
5
|
+
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
6
|
+
}
|
|
7
|
+
return cachegetUint8Memory0;
|
|
8
|
+
}
|
|
9
|
+
let WASM_VECTOR_LEN = 0;
|
|
10
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
11
|
+
const ptr = malloc(arg.length * 1);
|
|
12
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
13
|
+
WASM_VECTOR_LEN = arg.length;
|
|
14
|
+
return ptr;
|
|
15
|
+
}
|
|
16
|
+
let cachegetInt32Memory0 = null;
|
|
17
|
+
function getInt32Memory0() {
|
|
18
|
+
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
19
|
+
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
20
|
+
}
|
|
21
|
+
return cachegetInt32Memory0;
|
|
22
|
+
}
|
|
23
|
+
let cachegetUint8ClampedMemory0 = null;
|
|
24
|
+
function getUint8ClampedMemory0() {
|
|
25
|
+
if (cachegetUint8ClampedMemory0 === null || cachegetUint8ClampedMemory0.buffer !== wasm.memory.buffer) {
|
|
26
|
+
cachegetUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
|
|
27
|
+
}
|
|
28
|
+
return cachegetUint8ClampedMemory0;
|
|
29
|
+
}
|
|
30
|
+
function getClampedArrayU8FromWasm0(ptr, len) {
|
|
31
|
+
return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
32
|
+
}
|
|
33
|
+
function resize(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) {
|
|
34
|
+
try {
|
|
35
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
36
|
+
const ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc);
|
|
37
|
+
const len0 = WASM_VECTOR_LEN;
|
|
38
|
+
wasm.resize(
|
|
39
|
+
retptr,
|
|
40
|
+
ptr0,
|
|
41
|
+
len0,
|
|
42
|
+
input_width,
|
|
43
|
+
input_height,
|
|
44
|
+
output_width,
|
|
45
|
+
output_height,
|
|
46
|
+
typ_idx,
|
|
47
|
+
premultiply,
|
|
48
|
+
color_space_conversion
|
|
49
|
+
);
|
|
50
|
+
const r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
51
|
+
const r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
52
|
+
const v1 = getClampedArrayU8FromWasm0(r0, r1).slice();
|
|
53
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
54
|
+
return v1;
|
|
55
|
+
} finally {
|
|
56
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function load(module, imports) {
|
|
60
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
61
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
62
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
63
|
+
}
|
|
64
|
+
const bytes = await module.arrayBuffer();
|
|
65
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
66
|
+
} else {
|
|
67
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
68
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
69
|
+
return { instance, module };
|
|
70
|
+
} else {
|
|
71
|
+
return instance;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function init(input) {
|
|
76
|
+
const imports = {};
|
|
77
|
+
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
|
|
78
|
+
input = fetch(input);
|
|
79
|
+
}
|
|
80
|
+
const { instance, module } = await load(await input, imports);
|
|
81
|
+
wasm = instance.exports;
|
|
82
|
+
init.__wbindgen_wasm_module = module;
|
|
83
|
+
return wasm;
|
|
84
|
+
}
|
|
85
|
+
var squoosh_resize_default = init;
|
|
86
|
+
function cleanup() {
|
|
87
|
+
wasm = null;
|
|
88
|
+
cachegetUint8Memory0 = null;
|
|
89
|
+
cachegetInt32Memory0 = null;
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
cleanup,
|
|
93
|
+
squoosh_resize_default as default,
|
|
94
|
+
resize
|
|
95
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function execOnce<T extends (...args: any[]) => ReturnType<T>>(fn: T): T;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Worker } from 'worker_threads';
|
|
3
|
+
interface Job<I> {
|
|
4
|
+
msg: I;
|
|
5
|
+
resolve: (result: any) => void;
|
|
6
|
+
reject: (reason: any) => void;
|
|
7
|
+
}
|
|
8
|
+
export default class WorkerPool<I, O> {
|
|
9
|
+
numWorkers: number;
|
|
10
|
+
jobQueue: TransformStream<Job<I>, Job<I>>;
|
|
11
|
+
workerQueue: TransformStream<Worker, Worker>;
|
|
12
|
+
done: Promise<void>;
|
|
13
|
+
constructor(numWorkers: number, workerFile: string);
|
|
14
|
+
_readLoop(): Promise<void>;
|
|
15
|
+
_nextWorker(): Promise<Worker>;
|
|
16
|
+
_terminateAll(): Promise<void>;
|
|
17
|
+
join(): Promise<void>;
|
|
18
|
+
dispatchJob(msg: I): Promise<O>;
|
|
19
|
+
private jobPromise;
|
|
20
|
+
static useThisThreadAsWorker<I, O>(cb: (msg: I) => O): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { parentPort, Worker } from "worker_threads";
|
|
2
|
+
function uuid() {
|
|
3
|
+
return Array.from({ length: 16 }, () => Math.floor(Math.random() * 256).toString(16)).join("");
|
|
4
|
+
}
|
|
5
|
+
class WorkerPool {
|
|
6
|
+
constructor(numWorkers, workerFile) {
|
|
7
|
+
this.numWorkers = numWorkers;
|
|
8
|
+
this.jobQueue = new TransformStream();
|
|
9
|
+
this.workerQueue = new TransformStream();
|
|
10
|
+
const writer = this.workerQueue.writable.getWriter();
|
|
11
|
+
for (let i = 0; i < numWorkers; i++) {
|
|
12
|
+
writer.write(new Worker(workerFile));
|
|
13
|
+
}
|
|
14
|
+
writer.releaseLock();
|
|
15
|
+
this.done = this._readLoop();
|
|
16
|
+
}
|
|
17
|
+
async _readLoop() {
|
|
18
|
+
const reader = this.jobQueue.readable.getReader();
|
|
19
|
+
while (true) {
|
|
20
|
+
const { value, done } = await reader.read();
|
|
21
|
+
if (done) {
|
|
22
|
+
await this._terminateAll();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!value) {
|
|
26
|
+
throw new Error("Reader did not return any value");
|
|
27
|
+
}
|
|
28
|
+
const { msg, resolve, reject } = value;
|
|
29
|
+
const worker = await this._nextWorker();
|
|
30
|
+
this.jobPromise(worker, msg).then((result) => resolve(result)).catch((reason) => reject(reason)).finally(() => {
|
|
31
|
+
const writer = this.workerQueue.writable.getWriter();
|
|
32
|
+
writer.write(worker);
|
|
33
|
+
writer.releaseLock();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async _nextWorker() {
|
|
38
|
+
const reader = this.workerQueue.readable.getReader();
|
|
39
|
+
const { value } = await reader.read();
|
|
40
|
+
reader.releaseLock();
|
|
41
|
+
if (!value) {
|
|
42
|
+
throw new Error("No worker left");
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
async _terminateAll() {
|
|
47
|
+
for (let n = 0; n < this.numWorkers; n++) {
|
|
48
|
+
const worker = await this._nextWorker();
|
|
49
|
+
worker.terminate();
|
|
50
|
+
}
|
|
51
|
+
this.workerQueue.writable.close();
|
|
52
|
+
}
|
|
53
|
+
async join() {
|
|
54
|
+
this.jobQueue.writable.getWriter().close();
|
|
55
|
+
await this.done;
|
|
56
|
+
}
|
|
57
|
+
dispatchJob(msg) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const writer = this.jobQueue.writable.getWriter();
|
|
60
|
+
writer.write({ msg, resolve, reject });
|
|
61
|
+
writer.releaseLock();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
jobPromise(worker, msg) {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
const id = uuid();
|
|
67
|
+
worker.postMessage({ msg, id });
|
|
68
|
+
worker.on("message", function f({ error, result, id: rid }) {
|
|
69
|
+
if (rid !== id) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (error) {
|
|
73
|
+
reject(error);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
worker.off("message", f);
|
|
77
|
+
resolve(result);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
static useThisThreadAsWorker(cb) {
|
|
82
|
+
parentPort.on("message", async (data) => {
|
|
83
|
+
const { msg, id } = data;
|
|
84
|
+
try {
|
|
85
|
+
const result = await cb(msg);
|
|
86
|
+
parentPort.postMessage({ result, id });
|
|
87
|
+
} catch (e) {
|
|
88
|
+
parentPort.postMessage({ error: e.message, id });
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
WorkerPool as default
|
|
95
|
+
};
|