@oddessentials/agent-guild 1.28.0 → 1.30.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.
Files changed (133) 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 +10 -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/argparse/lib/argparse.js +1 -1
  80. package/node_modules/argparse/lib/textwrap.js +13 -2
  81. package/node_modules/argparse/package.json +1 -1
  82. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +737 -686
  83. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -1
  84. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +8 -8
  85. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -1
  86. package/node_modules/markdown-it/dist/markdown-it.cjs.js +660 -518
  87. package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -1
  88. package/node_modules/markdown-it/dist/markdown-it.d.mts +1 -0
  89. package/node_modules/markdown-it/dist/markdown-it.mjs +179 -124
  90. package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -1
  91. package/node_modules/markdown-it/package.json +11 -11
  92. package/node_modules/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
  93. package/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
  94. package/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  95. package/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  96. package/node_modules/wasm-feature-detect/LICENSE +202 -0
  97. package/node_modules/wasm-feature-detect/README.md +109 -0
  98. package/node_modules/wasm-feature-detect/README.md.ejs +89 -0
  99. package/node_modules/wasm-feature-detect/dist/cjs/index.cjs +1 -0
  100. package/node_modules/wasm-feature-detect/dist/esm/index.js +1 -0
  101. package/node_modules/wasm-feature-detect/dist/index.d.cts +24 -0
  102. package/node_modules/wasm-feature-detect/dist/index.d.ts +24 -0
  103. package/node_modules/wasm-feature-detect/dist/umd/index.js +1 -0
  104. package/node_modules/wasm-feature-detect/package.json +53 -0
  105. package/node_modules/ws/README.md +21 -29
  106. package/node_modules/ws/lib/buffer-util.js +13 -2
  107. package/node_modules/ws/lib/sender.js +4 -1
  108. package/node_modules/ws/lib/websocket.js +8 -3
  109. package/node_modules/ws/package.json +1 -1
  110. package/package.json +7 -4
  111. package/src/manager/config.mjs +2 -0
  112. package/src/manager/folder-browser.mjs +39 -3
  113. package/src/manager/main.mjs +4 -0
  114. package/src/manager/server.mjs +32 -5
  115. package/src/manager/steam-workshop.mjs +64 -0
  116. package/src/manager/yard-art.mjs +1 -1
  117. package/src/manager/yard-piece-check.mjs +424 -0
  118. package/src/manager/yard-pieces.mjs +188 -0
  119. package/src/manager/yard-worlds.mjs +214 -0
  120. package/web/app.js +175 -11
  121. package/web/index.html +20 -2
  122. package/web/skins/grove/ui/companion-bird.webp +0 -0
  123. package/web/skins/guild/skin.css +2 -13
  124. package/web/styles.css +15 -1
  125. package/web/yard/art.json +1 -1
  126. package/web/yard/model.mjs +44 -2
  127. package/web/yard/photo.js +3 -4
  128. package/web/yard/renderer.js +150 -38
  129. package/web/yard/vendor/engine.js +500 -495
  130. package/web/yard/view.js +160 -14
  131. package/web/yard/yard.css +55 -12
  132. package/web/skins/grove/ui/install-now-dark.svg +0 -91
  133. package/web/skins/grove/ui/install-now-light.svg +0 -91
@@ -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 modified this file to allow manual instantiation of the Wasm Module.
15
+ */
16
+ export function initEmscriptenModule(moduleFactory, wasmModule, moduleOptionOverrides = {}) {
17
+ let instantiateWasm;
18
+ if (wasmModule) {
19
+ instantiateWasm = (imports, callback) => {
20
+ const instance = new WebAssembly.Instance(wasmModule, imports);
21
+ callback(instance);
22
+ return instance.exports;
23
+ };
24
+ }
25
+ return moduleFactory({
26
+ // Just to be safe, don't automatically invoke any wasm functions
27
+ noInitialRun: true,
28
+ instantiateWasm,
29
+ ...moduleOptionOverrides,
30
+ });
31
+ }
@@ -0,0 +1,69 @@
1
+ # Changelog
2
+
3
+ ## @jsquash/png@3.1.1
4
+
5
+ ### Fixes
6
+
7
+ - Fixes the type definitions for the `encode` and `decode` methods to work correctly with the intended bitDepths.
8
+
9
+ ## @jsquash/png@3.1.0
10
+
11
+ ### Added
12
+
13
+ - Added `bitDepth` option to `decode` method to allow decoding of 16-bit PNGs to their 16-bit RGBA values
14
+ - Added `encode` method to allow encoding of 16-bit RGBA image data
15
+ - A Uint16Array is required for the pixel data when `bitDepth` is set to 16
16
+
17
+ ## @jsquash/png@3.0.1
18
+
19
+ ### Fixes
20
+
21
+ - Fixes the decoding of PNG images using non-rgba color types.
22
+
23
+ ## @jsquash/png@3.0.0
24
+
25
+ ### Breaking Changes
26
+
27
+ - `encode` method now returns an `ArrayBuffer` which matches the return type of other jSquash `encode` methods
28
+ - Ignores checksum errors. Allows images with invalid header chunks to be decoded (Fixes [#44](https://github.com/jamsinclair/jSquash/issues/44))
29
+ - Upgrades codec to image-png 0.17.10 (increases wasm file size by 54KB)
30
+ - Codec wasm and js files moved to /codec/pkg dir (due to addition of Rust source)
31
+ - If you are accessing the wasm file by path you'll need to update your paths to reference `node_modules/@jsquash/png/codec/pkg/squoosh_png_bg.wasm`. It's now nested in the `pkg` dir.
32
+
33
+ ## @jsquash/png@2.2.0
34
+
35
+ ### Adds
36
+
37
+ - Adds Node.js ESM support
38
+ - Updates relative imports to use file extensions
39
+ - Adds `module` field to relevant `package.json`
40
+ - Updates pre.js to polyfill ImageData for Node.js
41
+
42
+ ### Misc.
43
+
44
+ - Removes *.d.ts.map files from the package
45
+
46
+ ## @jsquash/png@2.1.4
47
+
48
+ ### Fixes
49
+
50
+ - Removes unused wasm-feature-detect dependency
51
+
52
+ ## @jsquash/png@2.1.2
53
+
54
+ Re-release of 2.1.1 with correct dist files
55
+ ### Fixes
56
+
57
+ - Check for caches object on `globalThis` before using it
58
+
59
+ ## @jsquash/png@2.1.1
60
+
61
+ ### Fixes
62
+
63
+ - Check for caches object on `globalThis` before using it
64
+
65
+ ## @jsquash/png@2.1.0
66
+
67
+ ### Added
68
+
69
+ - Include polyfills for Cloudflare Worker environment for easier compatibility
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2023] jamsinclair
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,114 @@
1
+ # @jsquash/png
2
+
3
+ [![npm version](https://badge.fury.io/js/@jsquash%2Fpng.svg)](https://badge.fury.io/js/@jsquash%2Fpng)
4
+
5
+ An easy experience for encoding and decoding PNG images in the browser. Powered by WebAssembly ⚡️.
6
+
7
+ Uses the [rust PNG crate](https://docs.rs/png/0.11.0/png/).
8
+
9
+ A [jSquash](https://github.com/jamsinclair/jSquash) package. Codecs and supporting code derived from the [Squoosh](https://github.com/GoogleChromeLabs/squoosh) app.
10
+
11
+ ## Installation
12
+
13
+ ```shell
14
+ npm install --save @jsquash/png
15
+ # Or your favourite package manager alternative
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ Note: You will need to either manually include the wasm files from the codec directory or use a bundler like WebPack or Rollup to include them in your app/server.
21
+
22
+ ### decode(data: ArrayBuffer, options?: { bitDepth?: 8 | 16 }): Promise<ImageData | ImageDataRGBA16>
23
+
24
+ Decodes PNG binary ArrayBuffer to raw image data.
25
+ By default, it decodes to 8-bit RGBA image data.
26
+ If `options.bitDepth` is set to 16, it decodes to 16-bit RGBA image data.
27
+
28
+ #### data
29
+ Type: `ArrayBuffer`
30
+
31
+ #### options (optional)
32
+ Type: `object`
33
+ - `bitDepth` (optional): `8 | 16` - The desired bit depth of the output. Defaults to `8`.
34
+
35
+ #### Example
36
+ ```js
37
+ import { decode } from '@jsquash/png';
38
+
39
+ const formEl = document.querySelector('form');
40
+ const formData = new FormData(formEl);
41
+ // Decode to 8-bit RGBA
42
+ const imageData8bit = await decode(await formData.get('image').arrayBuffer());
43
+ // Decode to 16-bit RGBA
44
+ const imageData16bit = await decode(await formData.get('image').arrayBuffer(), { bitDepth: 16 });
45
+ ```
46
+
47
+ ### encode(data: ImageData | ImageDataRGBA16, options?: { bitDepth?: 8 | 16 }): Promise<ArrayBuffer>
48
+
49
+ > ℹ️ You may want to use the [@jsquash/oxipng](/packages/oxipng) package instead. It can both optimise and encode to PNG directly from raw image data (8-bit images only).
50
+
51
+ Encodes raw RGB image data to PNG format and resolves to an ArrayBuffer of binary data.
52
+
53
+ Can optionally specify the bit depth of the output PNG. The default is 8-bit.
54
+
55
+ #### data
56
+ Type: `ImageData` or for 16-bit images `{ data: Uint16Array; width: number; height: number; }`
57
+
58
+ #### Example
59
+ ```js
60
+ import { encode } from '@jsquash/png';
61
+
62
+ async function loadImage(src) {
63
+ const img = document.createElement('img');
64
+ img.src = src;
65
+ await new Promise(resolve => img.onload = resolve);
66
+ const canvas = document.createElement('canvas');
67
+ [canvas.width, canvas.height] = [img.width, img.height];
68
+ const ctx = canvas.getContext('2d');
69
+ ctx.drawImage(img, 0, 0);
70
+ return ctx.getImageData(0, 0, img.width, img.height);
71
+ }
72
+
73
+ const rawImageData = await loadImage('/example.jpg');
74
+ const pngBuffer = await encode(rawImageData);
75
+ ```
76
+
77
+ #### Example with 16-bit image data
78
+ ```js
79
+ import { encode } from '@jsquash/png';
80
+
81
+ async function create16bitImage(src) {
82
+ const pixels = new Uint16Array(4 * 256 * 256);
83
+ for (let i = 0; i < pixels.length; i += 4) {
84
+ pixels[i] = Math.floor(Math.random() * 65535); // R
85
+ pixels[i + 1] = Math.floor(Math.random() * 65535); // G
86
+ pixels[i + 2] = Math.floor(Math.random() * 65535); // B
87
+ pixels[i + 3] = 65535; // A
88
+ }
89
+ return {
90
+ data: pixels,
91
+ width: 256,
92
+ height: 256,
93
+ };
94
+ }
95
+
96
+ const rawImageData = await create16bitImage();
97
+ const png16bitBuffer = await encode(rawImageData, { bitDepth: 16 });
98
+ ```
99
+
100
+ ## Manual WASM initialisation (not recommended)
101
+
102
+ In most situations there is no need to manually initialise the provided WebAssembly modules.
103
+ The generated glue code takes care of this and supports most web bundlers.
104
+
105
+ One situation where this arises is when using the modules in Cloudflare Workers ([See the README for more info](/README.md#usage-in-cloudflare-workers)).
106
+
107
+ The `encode` and `decode` modules both export an `init` function that can be used to manually load the wasm module.
108
+
109
+ ```js
110
+ import decode, { init as initPngDecode } from '@jsquash/png/decode';
111
+
112
+ initPngDecode(WASM_MODULE); // The `WASM_MODULE` variable will need to be sourced by yourself and passed as an ArrayBuffer.
113
+ const image = await fetch('./image.png').then(res => res.arrayBuffer()).then(decode);
114
+ ```
@@ -0,0 +1,29 @@
1
+ Copyright (c) 2010, Google Inc. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are
5
+ met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in
12
+ the documentation and/or other materials provided with the
13
+ distribution.
14
+
15
+ * Neither the name of Google nor the names of its contributors may
16
+ be used to endorse or promote products derived from this software
17
+ without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,5 @@
1
+ # PNG
2
+
3
+ - Source: https://github.com/GoogleChromeLabs/squoosh
4
+ - Version: v1.12.0
5
+ - License: Apache-2.0
@@ -0,0 +1,5 @@
1
+ # PNG
2
+
3
+ - Source: https://github.com/GoogleChromeLabs/squoosh
4
+ - Version: v1.12.0
5
+ - License: Apache-2.0
@@ -0,0 +1,71 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {Uint8Array} data
5
+ * @param {number} width
6
+ * @param {number} height
7
+ * @param {number} bit_depth
8
+ * @returns {Uint8Array}
9
+ */
10
+ export function encode(data: Uint8Array, width: number, height: number, bit_depth: number): Uint8Array;
11
+ /**
12
+ * @param {Uint8Array} data
13
+ * @returns {ImageData}
14
+ */
15
+ export function decode(data: Uint8Array): ImageData;
16
+ /**
17
+ * @param {Uint8Array} data
18
+ * @returns {ImageDataRGBA16}
19
+ */
20
+ export function decode_rgba16(data: Uint8Array): ImageDataRGBA16;
21
+ /**
22
+ */
23
+ export class ImageDataRGBA16 {
24
+ free(): void;
25
+ /**
26
+ */
27
+ readonly data: Uint16Array;
28
+ /**
29
+ */
30
+ readonly height: number;
31
+ /**
32
+ */
33
+ readonly width: number;
34
+ }
35
+
36
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
37
+
38
+ export interface InitOutput {
39
+ readonly memory: WebAssembly.Memory;
40
+ readonly __wbg_imagedatargba16_free: (a: number) => void;
41
+ readonly imagedatargba16_width: (a: number) => number;
42
+ readonly imagedatargba16_height: (a: number) => number;
43
+ readonly imagedatargba16_data: (a: number) => number;
44
+ readonly encode: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
45
+ readonly decode: (a: number, b: number) => number;
46
+ readonly decode_rgba16: (a: number, b: number) => number;
47
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
48
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
49
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
50
+ }
51
+
52
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
53
+ /**
54
+ * Instantiates the given `module`, which can either be bytes or
55
+ * a precompiled `WebAssembly.Module`.
56
+ *
57
+ * @param {SyncInitInput} module
58
+ *
59
+ * @returns {InitOutput}
60
+ */
61
+ export function initSync(module: SyncInitInput): InitOutput;
62
+
63
+ /**
64
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
65
+ * for everything else, calls `WebAssembly.instantiate` directly.
66
+ *
67
+ * @param {InitInput | Promise<InitInput>} module_or_path
68
+ *
69
+ * @returns {Promise<InitOutput>}
70
+ */
71
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;