@oddessentials/agent-guild 1.29.0 → 1.30.1

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.
Files changed (107) hide show
  1. package/bin/native/win32-arm64/agent-guild-report.exe +0 -0
  2. package/bin/native/win32-x64/agent-guild-report.exe +0 -0
  3. package/bin/windows/arm64/agent-guild-start.exe +0 -0
  4. package/bin/windows/x64/agent-guild-start.exe +0 -0
  5. package/docs/api.md +6 -2
  6. package/node_modules/@jsquash/jpeg/CHANGELOG.md +54 -0
  7. package/node_modules/@jsquash/jpeg/LICENSE +201 -0
  8. package/node_modules/@jsquash/jpeg/README.md +105 -0
  9. package/node_modules/@jsquash/jpeg/codec/LICENSE.codec.md +132 -0
  10. package/node_modules/@jsquash/jpeg/codec/dec/mozjpeg_dec.d.ts +7 -0
  11. package/node_modules/@jsquash/jpeg/codec/dec/mozjpeg_dec.js +15 -0
  12. package/node_modules/@jsquash/jpeg/codec/dec/mozjpeg_dec.wasm +0 -0
  13. package/node_modules/@jsquash/jpeg/codec/enc/mozjpeg_enc.d.ts +37 -0
  14. package/node_modules/@jsquash/jpeg/codec/enc/mozjpeg_enc.js +15 -0
  15. package/node_modules/@jsquash/jpeg/codec/enc/mozjpeg_enc.wasm +0 -0
  16. package/node_modules/@jsquash/jpeg/codec/pre.js +24 -0
  17. package/node_modules/@jsquash/jpeg/decode.d.ts +16 -0
  18. package/node_modules/@jsquash/jpeg/decode.js +36 -0
  19. package/node_modules/@jsquash/jpeg/emscripten-types.d.ts +137 -0
  20. package/node_modules/@jsquash/jpeg/encode.d.ts +21 -0
  21. package/node_modules/@jsquash/jpeg/encode.js +35 -0
  22. package/node_modules/@jsquash/jpeg/index.d.ts +3 -0
  23. package/node_modules/@jsquash/jpeg/index.js +2 -0
  24. package/node_modules/@jsquash/jpeg/meta.d.ts +24 -0
  25. package/node_modules/@jsquash/jpeg/meta.js +25 -0
  26. package/node_modules/@jsquash/jpeg/package.json +32 -0
  27. package/node_modules/@jsquash/jpeg/utils.d.ts +17 -0
  28. package/node_modules/@jsquash/jpeg/utils.js +31 -0
  29. package/node_modules/@jsquash/png/CHANGELOG.md +69 -0
  30. package/node_modules/@jsquash/png/LICENSE +201 -0
  31. package/node_modules/@jsquash/png/README.md +114 -0
  32. package/node_modules/@jsquash/png/codec/LICENSE.codec.md +29 -0
  33. package/node_modules/@jsquash/png/codec/README.md +5 -0
  34. package/node_modules/@jsquash/png/codec/pkg/README.md +5 -0
  35. package/node_modules/@jsquash/png/codec/pkg/squoosh_png.d.ts +71 -0
  36. package/node_modules/@jsquash/png/codec/pkg/squoosh_png.js +314 -0
  37. package/node_modules/@jsquash/png/codec/pkg/squoosh_png_bg.wasm +0 -0
  38. package/node_modules/@jsquash/png/codec/pkg/squoosh_png_bg.wasm.d.ts +13 -0
  39. package/node_modules/@jsquash/png/codec/pre.js +24 -0
  40. package/node_modules/@jsquash/png/decode.d.ts +29 -0
  41. package/node_modules/@jsquash/png/decode.js +35 -0
  42. package/node_modules/@jsquash/png/encode.d.ts +31 -0
  43. package/node_modules/@jsquash/png/encode.js +40 -0
  44. package/node_modules/@jsquash/png/index.d.ts +3 -0
  45. package/node_modules/@jsquash/png/index.js +2 -0
  46. package/node_modules/@jsquash/png/meta.d.ts +16 -0
  47. package/node_modules/@jsquash/png/meta.js +15 -0
  48. package/node_modules/@jsquash/png/package.json +34 -0
  49. package/node_modules/@jsquash/webp/CHANGELOG.md +48 -0
  50. package/node_modules/@jsquash/webp/LICENSE +201 -0
  51. package/node_modules/@jsquash/webp/README.md +100 -0
  52. package/node_modules/@jsquash/webp/codec/LICENSE.codec.md +29 -0
  53. package/node_modules/@jsquash/webp/codec/Makefile.animated.backup +88 -0
  54. package/node_modules/@jsquash/webp/codec/README.md +5 -0
  55. package/node_modules/@jsquash/webp/codec/dec/README.md +18 -0
  56. package/node_modules/@jsquash/webp/codec/dec/webp_dec.d.ts +7 -0
  57. package/node_modules/@jsquash/webp/codec/dec/webp_dec.js +16 -0
  58. package/node_modules/@jsquash/webp/codec/dec/webp_dec.wasm +0 -0
  59. package/node_modules/@jsquash/webp/codec/enc/README.md +22 -0
  60. package/node_modules/@jsquash/webp/codec/enc/webp_enc.d.ts +42 -0
  61. package/node_modules/@jsquash/webp/codec/enc/webp_enc.js +16 -0
  62. package/node_modules/@jsquash/webp/codec/enc/webp_enc.wasm +0 -0
  63. package/node_modules/@jsquash/webp/codec/enc/webp_enc_simd.d.ts +1 -0
  64. package/node_modules/@jsquash/webp/codec/enc/webp_enc_simd.js +16 -0
  65. package/node_modules/@jsquash/webp/codec/enc/webp_enc_simd.wasm +0 -0
  66. package/node_modules/@jsquash/webp/codec/pre.js +24 -0
  67. package/node_modules/@jsquash/webp/decode.d.ts +15 -0
  68. package/node_modules/@jsquash/webp/decode.js +34 -0
  69. package/node_modules/@jsquash/webp/emscripten-types.d.ts +137 -0
  70. package/node_modules/@jsquash/webp/encode.d.ts +23 -0
  71. package/node_modules/@jsquash/webp/encode.js +43 -0
  72. package/node_modules/@jsquash/webp/index.d.ts +3 -0
  73. package/node_modules/@jsquash/webp/index.js +2 -0
  74. package/node_modules/@jsquash/webp/meta.d.ts +19 -0
  75. package/node_modules/@jsquash/webp/meta.js +33 -0
  76. package/node_modules/@jsquash/webp/package.json +35 -0
  77. package/node_modules/@jsquash/webp/utils.d.ts +17 -0
  78. package/node_modules/@jsquash/webp/utils.js +31 -0
  79. package/node_modules/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
  80. package/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
  81. package/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  82. package/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  83. package/node_modules/wasm-feature-detect/LICENSE +202 -0
  84. package/node_modules/wasm-feature-detect/README.md +109 -0
  85. package/node_modules/wasm-feature-detect/README.md.ejs +89 -0
  86. package/node_modules/wasm-feature-detect/dist/cjs/index.cjs +1 -0
  87. package/node_modules/wasm-feature-detect/dist/esm/index.js +1 -0
  88. package/node_modules/wasm-feature-detect/dist/index.d.cts +24 -0
  89. package/node_modules/wasm-feature-detect/dist/index.d.ts +24 -0
  90. package/node_modules/wasm-feature-detect/dist/umd/index.js +1 -0
  91. package/node_modules/wasm-feature-detect/package.json +53 -0
  92. package/package.json +4 -1
  93. package/src/manager/config.mjs +1 -0
  94. package/src/manager/folder-browser.mjs +31 -2
  95. package/src/manager/main.mjs +2 -0
  96. package/src/manager/server.mjs +19 -5
  97. package/src/manager/steam-workshop.mjs +64 -0
  98. package/src/manager/yard-piece-check.mjs +424 -0
  99. package/src/manager/yard-pieces.mjs +188 -0
  100. package/web/app.js +55 -17
  101. package/web/index.html +14 -1
  102. package/web/skins/guild/skin.css +2 -13
  103. package/web/styles.css +14 -0
  104. package/web/yard/art.json +1 -1
  105. package/web/yard/model.mjs +44 -2
  106. package/web/yard/renderer.js +136 -27
  107. package/web/yard/view.js +123 -11
@@ -0,0 +1,314 @@
1
+ let wasm;
2
+
3
+ const heap = new Array(128).fill(undefined);
4
+
5
+ heap.push(undefined, null, true, false);
6
+
7
+ let heap_next = heap.length;
8
+
9
+ function addHeapObject(obj) {
10
+ if (heap_next === heap.length) heap.push(heap.length + 1);
11
+ const idx = heap_next;
12
+ heap_next = heap[idx];
13
+
14
+ heap[idx] = obj;
15
+ return idx;
16
+ }
17
+
18
+ function getObject(idx) { return heap[idx]; }
19
+
20
+ function dropObject(idx) {
21
+ if (idx < 132) return;
22
+ heap[idx] = heap_next;
23
+ heap_next = idx;
24
+ }
25
+
26
+ function takeObject(idx) {
27
+ const ret = getObject(idx);
28
+ dropObject(idx);
29
+ return ret;
30
+ }
31
+
32
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
33
+
34
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
35
+
36
+ let cachedUint8Memory0 = null;
37
+
38
+ function getUint8Memory0() {
39
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
40
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
41
+ }
42
+ return cachedUint8Memory0;
43
+ }
44
+
45
+ function getStringFromWasm0(ptr, len) {
46
+ ptr = ptr >>> 0;
47
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
48
+ }
49
+
50
+ let cachedUint8ClampedMemory0 = null;
51
+
52
+ function getUint8ClampedMemory0() {
53
+ if (cachedUint8ClampedMemory0 === null || cachedUint8ClampedMemory0.byteLength === 0) {
54
+ cachedUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
55
+ }
56
+ return cachedUint8ClampedMemory0;
57
+ }
58
+
59
+ function getClampedArrayU8FromWasm0(ptr, len) {
60
+ ptr = ptr >>> 0;
61
+ return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len);
62
+ }
63
+
64
+ let WASM_VECTOR_LEN = 0;
65
+
66
+ function passArray8ToWasm0(arg, malloc) {
67
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
68
+ getUint8Memory0().set(arg, ptr / 1);
69
+ WASM_VECTOR_LEN = arg.length;
70
+ return ptr;
71
+ }
72
+
73
+ let cachedInt32Memory0 = null;
74
+
75
+ function getInt32Memory0() {
76
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
77
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
78
+ }
79
+ return cachedInt32Memory0;
80
+ }
81
+
82
+ function getArrayU8FromWasm0(ptr, len) {
83
+ ptr = ptr >>> 0;
84
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
85
+ }
86
+ /**
87
+ * @param {Uint8Array} data
88
+ * @param {number} width
89
+ * @param {number} height
90
+ * @param {number} bit_depth
91
+ * @returns {Uint8Array}
92
+ */
93
+ export function encode(data, width, height, bit_depth) {
94
+ try {
95
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
96
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
97
+ const len0 = WASM_VECTOR_LEN;
98
+ wasm.encode(retptr, ptr0, len0, width, height, bit_depth);
99
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
100
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
101
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
102
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
103
+ return v2;
104
+ } finally {
105
+ wasm.__wbindgen_add_to_stack_pointer(16);
106
+ }
107
+ }
108
+
109
+ /**
110
+ * @param {Uint8Array} data
111
+ * @returns {ImageData}
112
+ */
113
+ export function decode(data) {
114
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
115
+ const len0 = WASM_VECTOR_LEN;
116
+ const ret = wasm.decode(ptr0, len0);
117
+ return takeObject(ret);
118
+ }
119
+
120
+ /**
121
+ * @param {Uint8Array} data
122
+ * @returns {ImageDataRGBA16}
123
+ */
124
+ export function decode_rgba16(data) {
125
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
126
+ const len0 = WASM_VECTOR_LEN;
127
+ const ret = wasm.decode_rgba16(ptr0, len0);
128
+ return ImageDataRGBA16.__wrap(ret);
129
+ }
130
+
131
+ /**
132
+ */
133
+ export class ImageDataRGBA16 {
134
+
135
+ static __wrap(ptr) {
136
+ ptr = ptr >>> 0;
137
+ const obj = Object.create(ImageDataRGBA16.prototype);
138
+ obj.__wbg_ptr = ptr;
139
+
140
+ return obj;
141
+ }
142
+
143
+ __destroy_into_raw() {
144
+ const ptr = this.__wbg_ptr;
145
+ this.__wbg_ptr = 0;
146
+
147
+ return ptr;
148
+ }
149
+
150
+ free() {
151
+ const ptr = this.__destroy_into_raw();
152
+ wasm.__wbg_imagedatargba16_free(ptr);
153
+ }
154
+ /**
155
+ * @returns {number}
156
+ */
157
+ get width() {
158
+ const ret = wasm.imagedatargba16_width(this.__wbg_ptr);
159
+ return ret >>> 0;
160
+ }
161
+ /**
162
+ * @returns {number}
163
+ */
164
+ get height() {
165
+ const ret = wasm.imagedatargba16_height(this.__wbg_ptr);
166
+ return ret >>> 0;
167
+ }
168
+ /**
169
+ * @returns {Uint16Array}
170
+ */
171
+ get data() {
172
+ const ret = wasm.imagedatargba16_data(this.__wbg_ptr);
173
+ return takeObject(ret);
174
+ }
175
+ }
176
+
177
+ async function __wbg_load(module, imports) {
178
+ if (typeof Response === 'function' && module instanceof Response) {
179
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
180
+ try {
181
+ return await WebAssembly.instantiateStreaming(module, imports);
182
+
183
+ } catch (e) {
184
+ if (module.headers.get('Content-Type') != 'application/wasm') {
185
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
186
+
187
+ } else {
188
+ throw e;
189
+ }
190
+ }
191
+ }
192
+
193
+ const bytes = await module.arrayBuffer();
194
+ return await WebAssembly.instantiate(bytes, imports);
195
+
196
+ } else {
197
+ const instance = await WebAssembly.instantiate(module, imports);
198
+
199
+ if (instance instanceof WebAssembly.Instance) {
200
+ return { instance, module };
201
+
202
+ } else {
203
+ return instance;
204
+ }
205
+ }
206
+ }
207
+
208
+ function __wbg_get_imports() {
209
+ const imports = {};
210
+ imports.wbg = {};
211
+ imports.wbg.__wbindgen_memory = function() {
212
+ const ret = wasm.memory;
213
+ return addHeapObject(ret);
214
+ };
215
+ imports.wbg.__wbg_buffer_a448f833075b71ba = function(arg0) {
216
+ const ret = getObject(arg0).buffer;
217
+ return addHeapObject(ret);
218
+ };
219
+ imports.wbg.__wbg_newwithbyteoffsetandlength_099217381c451830 = function(arg0, arg1, arg2) {
220
+ const ret = new Uint16Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
221
+ return addHeapObject(ret);
222
+ };
223
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
224
+ takeObject(arg0);
225
+ };
226
+ imports.wbg.__wbg_newwithownedu8clampedarrayandsh_91db5987993a08fb = function(arg0, arg1, arg2, arg3) {
227
+ var v0 = getClampedArrayU8FromWasm0(arg0, arg1).slice();
228
+ wasm.__wbindgen_free(arg0, arg1 * 1, 1);
229
+ const ret = new ImageData(v0, arg2 >>> 0, arg3 >>> 0);
230
+ return addHeapObject(ret);
231
+ };
232
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
233
+ throw new Error(getStringFromWasm0(arg0, arg1));
234
+ };
235
+
236
+ return imports;
237
+ }
238
+
239
+ function __wbg_init_memory(imports, maybe_memory) {
240
+
241
+ }
242
+
243
+ function __wbg_finalize_init(instance, module) {
244
+ wasm = instance.exports;
245
+ __wbg_init.__wbindgen_wasm_module = module;
246
+ cachedInt32Memory0 = null;
247
+ cachedUint8Memory0 = null;
248
+ cachedUint8ClampedMemory0 = null;
249
+
250
+
251
+ return wasm;
252
+ }
253
+
254
+ function initSync(module) {
255
+ if (wasm !== undefined) return wasm;
256
+
257
+ const imports = __wbg_get_imports();
258
+
259
+ __wbg_init_memory(imports);
260
+
261
+ if (!(module instanceof WebAssembly.Module)) {
262
+ module = new WebAssembly.Module(module);
263
+ }
264
+
265
+ const instance = new WebAssembly.Instance(module, imports);
266
+
267
+ return __wbg_finalize_init(instance, module);
268
+ }
269
+
270
+ async function __wbg_init(input) {
271
+ if (wasm !== undefined) return wasm;
272
+
273
+ if (typeof input === 'undefined') {
274
+ input = new URL('squoosh_png_bg.wasm', import.meta.url);
275
+ }
276
+ const imports = __wbg_get_imports();
277
+
278
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
279
+ input = fetch(input);
280
+ }
281
+
282
+ __wbg_init_memory(imports);
283
+
284
+ const { instance, module } = await __wbg_load(await input, imports);
285
+
286
+ return __wbg_finalize_init(instance, module);
287
+ }
288
+
289
+ export { initSync }
290
+ export default __wbg_init;
291
+ const isServiceWorker = globalThis.ServiceWorkerGlobalScope !== undefined;
292
+ const isRunningInCloudFlareWorkers = isServiceWorker && typeof self !== 'undefined' && globalThis.caches && globalThis.caches.default !== undefined;
293
+ const isRunningInNode = typeof process === 'object' && process.release && process.release.name === 'node';
294
+
295
+ if (isRunningInCloudFlareWorkers || isRunningInNode) {
296
+ if (!globalThis.ImageData) {
297
+ // Simple Polyfill for ImageData Object
298
+ globalThis.ImageData = class ImageData {
299
+ constructor(data, width, height) {
300
+ this.data = data;
301
+ this.width = width;
302
+ this.height = height;
303
+ }
304
+ };
305
+ }
306
+
307
+ if (import.meta.url === undefined) {
308
+ import.meta.url = 'https://localhost';
309
+ }
310
+
311
+ if (typeof self !== 'undefined' && self.location === undefined) {
312
+ self.location = { href: '' };
313
+ }
314
+ }
@@ -0,0 +1,13 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function __wbg_imagedatargba16_free(a: number): void;
5
+ export function imagedatargba16_width(a: number): number;
6
+ export function imagedatargba16_height(a: number): number;
7
+ export function imagedatargba16_data(a: number): number;
8
+ export function encode(a: number, b: number, c: number, d: number, e: number, f: number): void;
9
+ export function decode(a: number, b: number): number;
10
+ export function decode_rgba16(a: number, b: number): number;
11
+ export function __wbindgen_free(a: number, b: number, c: number): void;
12
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
13
+ export function __wbindgen_malloc(a: number, b: number): number;
@@ -0,0 +1,24 @@
1
+ const isServiceWorker = globalThis.ServiceWorkerGlobalScope !== undefined;
2
+ const isRunningInCloudFlareWorkers = isServiceWorker && typeof self !== 'undefined' && globalThis.caches && globalThis.caches.default !== undefined;
3
+ const isRunningInNode = typeof process === 'object' && process.release && process.release.name === 'node';
4
+
5
+ if (isRunningInCloudFlareWorkers || isRunningInNode) {
6
+ if (!globalThis.ImageData) {
7
+ // Simple Polyfill for ImageData Object
8
+ globalThis.ImageData = class ImageData {
9
+ constructor(data, width, height) {
10
+ this.data = data;
11
+ this.width = width;
12
+ this.height = height;
13
+ }
14
+ };
15
+ }
16
+
17
+ if (import.meta.url === undefined) {
18
+ import.meta.url = 'https://localhost';
19
+ }
20
+
21
+ if (typeof self !== 'undefined' && self.location === undefined) {
22
+ self.location = { href: '' };
23
+ }
24
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ /**
14
+ * Notice: I (Jamie Sinclair) have copied this code from the JPEG encode module
15
+ * and modified it to decode PNG images.
16
+ */
17
+ import type { ImageDataRGBA16, InitInput, InitOutput as PngModule } from './codec/pkg/squoosh_png.js';
18
+ export interface DecodeOptions {
19
+ bitDepth?: 8 | 16;
20
+ }
21
+ export declare function init(moduleOrPath?: InitInput): Promise<PngModule>;
22
+ export declare function decode(data: ArrayBuffer, options: {
23
+ bitDepth: 16;
24
+ }): Promise<ImageDataRGBA16>;
25
+ export declare function decode(data: ArrayBuffer, options?: {
26
+ bitDepth?: 8;
27
+ }): Promise<ImageData>;
28
+ export default decode;
29
+ //# sourceMappingURL=decode.d.ts.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ import initPngModule, { decode as pngDecodeWasm, decode_rgba16 as pngDecodeRgba16Wasm, } from './codec/pkg/squoosh_png.js';
14
+ let pngModule;
15
+ export async function init(moduleOrPath) {
16
+ if (!pngModule) {
17
+ pngModule = initPngModule(moduleOrPath);
18
+ }
19
+ return pngModule;
20
+ }
21
+ export async function decode(data, options = {}) {
22
+ await init();
23
+ const { bitDepth = 8 } = options;
24
+ if (bitDepth === 16) {
25
+ const imageData = await pngDecodeRgba16Wasm(new Uint8Array(data));
26
+ if (!imageData)
27
+ throw new Error('Encoding error.');
28
+ return imageData;
29
+ }
30
+ const imageData = await pngDecodeWasm(new Uint8Array(data));
31
+ if (!imageData)
32
+ throw new Error('Encoding error.');
33
+ return imageData;
34
+ }
35
+ export default decode;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ /**
14
+ * Notice: I (Jamie Sinclair) have copied this code from the JPEG encode module
15
+ * and modified it to encode PNG images and also optimise them.
16
+ */
17
+ import type { InitInput, InitOutput as PngModule } from './codec/pkg/squoosh_png.js';
18
+ type ImageDataRGBA16 = {
19
+ data: Uint16Array;
20
+ width: number;
21
+ height: number;
22
+ };
23
+ export declare function init(moduleOrPath?: InitInput): Promise<PngModule>;
24
+ export default function encode(data: ImageDataRGBA16, options: {
25
+ bitDepth: 16;
26
+ }): Promise<ArrayBuffer>;
27
+ export default function encode(data: ImageData, options?: {
28
+ bitDepth?: 8;
29
+ }): Promise<ArrayBuffer>;
30
+ export {};
31
+ //# sourceMappingURL=encode.d.ts.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ import initPngModule, { encode as pngEncode } from './codec/pkg/squoosh_png.js';
14
+ let pngModule;
15
+ export async function init(moduleOrPath) {
16
+ if (!pngModule) {
17
+ pngModule = initPngModule(moduleOrPath);
18
+ }
19
+ return pngModule;
20
+ }
21
+ export default async function encode(data, options = {}) {
22
+ var _a;
23
+ await init();
24
+ const bitDepth = (_a = options === null || options === void 0 ? void 0 : options.bitDepth) !== null && _a !== void 0 ? _a : 8;
25
+ if (bitDepth !== 8 && bitDepth !== 16) {
26
+ throw new Error('Invalid bit depth. Must be either 8 or 16.');
27
+ }
28
+ const isUint16Array = data.data instanceof Uint16Array;
29
+ if (isUint16Array && bitDepth !== 16) {
30
+ throw new Error('Invalid bit depth, must be 16 for Uint16Array or manually convert to RGB8 values with Uint8Array.');
31
+ }
32
+ if (!isUint16Array && bitDepth === 16) {
33
+ throw new Error('Invalid bit depth, must be 8 for Uint8Array or manually convert to RGB16 values with Uint16Array.');
34
+ }
35
+ const encodeData = new Uint8Array(data.data.buffer);
36
+ const output = await pngEncode(encodeData, data.width, data.height, bitDepth);
37
+ if (!output)
38
+ throw new Error('Encoding error.');
39
+ return output.buffer;
40
+ }
@@ -0,0 +1,3 @@
1
+ export { default as encode } from './encode.js';
2
+ export { default as decode } from './decode.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default as encode } from './encode.js';
2
+ export { default as decode } from './decode.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ export declare const label = "PNG";
14
+ export declare const mimeType = "image/png";
15
+ export declare const extension = "png";
16
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ export const label = 'PNG';
14
+ export const mimeType = 'image/png';
15
+ export const extension = 'png';
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@jsquash/png",
3
+ "version": "3.1.1",
4
+ "main": "index.js",
5
+ "description": "Wasm png encoder and decoder supporting the browser. Repackaged from Squoosh App.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/jamsinclair/jSquash.git"
9
+ },
10
+ "author": {
11
+ "name": "Jamie Sinclair",
12
+ "email": "jamsinclairnz+npm@gmail.com"
13
+ },
14
+ "keywords": [
15
+ "image",
16
+ "optimisation",
17
+ "optimization",
18
+ "squoosh",
19
+ "wasm",
20
+ "webassembly",
21
+ "png"
22
+ ],
23
+ "license": "Apache-2.0",
24
+ "scripts": {
25
+ "clean": "rm -rf dist",
26
+ "build": "npm run clean && tsc && cp -r codec package.json README.md CHANGELOG.md .npmignore ../../LICENSE dist && (rm dist/codec/pkg/.gitignore || true)",
27
+ "prepublishOnly": "[[ \"$PWD\" == *'/dist' ]] && exit 0 || (echo 'Please run npm publish from the dist directory' && exit 1)"
28
+ },
29
+ "devDependencies": {
30
+ "typescript": "^4.4.4"
31
+ },
32
+ "type": "module",
33
+ "sideEffects": false
34
+ }
@@ -0,0 +1,48 @@
1
+ # Changelog
2
+
3
+ ## @jsquash/webp@1.5.0
4
+
5
+ ### Adds
6
+
7
+ - Adds support for only providing a module option override to the `init` function directly
8
+
9
+ **Example:**
10
+ ```ts
11
+ import encode, { init } from '@jsquash/webp/encode';
12
+ await init({
13
+ locateFile: (path) => {
14
+ const remoteLocation = 'https://cdn.mydomain.com/wasm';
15
+ return remoteLocation + path;
16
+ }
17
+ });
18
+ const buffer = await encode(/* image data */);
19
+ ```
20
+
21
+ ### Fixes
22
+
23
+ - Updates `locateFile` emscripten module option type to support prefix parameter.
24
+
25
+ ## @jsquash/webp@1.4.0
26
+
27
+ ### Adds
28
+
29
+ - Adds ability to customise Emscripten module options, e.g. define your own `locateFile` method.
30
+
31
+ ## @jsquash/webp@1.3.0
32
+
33
+ ### Adds
34
+
35
+ - Adds Node.js ESM support
36
+ - Updates relative imports to use file extensions
37
+ - Adds `module` field to relevant `package.json`
38
+ - Updates pre.js to polyfill ImageData for Node.js
39
+
40
+ ### Misc.
41
+
42
+ - Removes *.d.ts.map files from the package
43
+
44
+ ## @jsquash/webp@1.2.0
45
+
46
+ ### Added
47
+
48
+ - Include polyfills for Cloudflare Worker environment for easier compatibility