@oddessentials/agent-guild 1.29.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 (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 +54 -16
  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
package/docs/api.md CHANGED
@@ -638,7 +638,7 @@ All paths are under `/api/v1`.
638
638
  | GET | `/remote-access` | | `{ remoteAccess }`: `revision`, `mode`, `busy`, `pending`, `problem` and connection details. `url` is the active address. `candidate` is the address enabling would use with Tailscale's current settings, `{ url, existing, remembered, standardUrl? }`: `remembered` when it is the address used before, and `standardUrl` when `standard: true` would choose another. |
639
639
  | POST | `/remote-access/check` | | `{ remoteAccess }` after refreshing Tailscale's status. |
640
640
  | PUT | `/remote-access` | `{ revision, action, adopt?, hosts?, origins? }` | `202`. `action` is `enable` (`adopt: true` manages a matching existing route; `standard: true`, only while remote access is off, skips the remembered address and takes port 443, else the next free port), `disable`, `custom` (with `hosts` and `origins`) or `forget` (leave an inactive route awaiting cleanup in Tailscale). Poll until `busy` is null and read `problem`. 409 `stale_settings` for an old `revision`. Needs the API token. Revoked WebSockets close with code 4403; their terminals keep running. |
641
- | GET | `/folders?path=&files=` | | `{ path, parent, home, segments, roots, entries, truncated, note }`: the subfolders of `path` (blank or `~` for the home folder). `entries` are `{ name, path, hidden }`. A missing `path` lists the nearest folder above it and names the requested path in `note`. `files=agworld` adds `files`, the world files in that folder, each `{ name, path }`. |
641
+ | GET | `/folders?path=&files=&pieces=` | | `{ path, parent, home, segments, roots, entries, truncated, note }`: the subfolders of `path` (blank or `~` for the home folder). `entries` are `{ name, path, hidden }`. A missing `path` lists the nearest folder above it and names the requested path in `note`. `files=agworld` adds `files`, the world files in that folder, each `{ name, path }`. `pieces=character` or `pieces=companion` adds `pieces`, the matching pieces in that folder and the folders directly inside it, each `{ title, folder, path }`, sorted by title, with `problem` when the piece needs a newer Agent Guild, and `workshop`, the Steam Workshop folder of Agent Guild: World found from Steam's library records, or null. |
642
642
  | POST | `/folders` | `{ path, name }` | 201 with the `GET /folders` listing of the new folder `name`, made inside `path`. |
643
643
  | GET | `/autostart` | | `{ autostart: { available, enabled, reason, note?, lastRun?, log? } }`: whether the manager starts when the user signs in. `reason` says why it is unavailable. `lastRun` is null or `{ at, outcome }`. On Linux outside WSL it also has `mode` (`off`, `sign-in`, `boot` or `both`) and `boot`, the systemd service's `{ available, enabled, reason, note, user, linger, state, commands }`. |
644
644
  | PUT | `/autostart` | `{ enabled }` or `{ mode }` | `{ autostart }` as above. `mode` (`off`, `sign-in` or `boot`) makes that the one way the manager starts; `boot` is offered only on Linux with systemd. |
@@ -669,6 +669,9 @@ All paths are under `/api/v1`.
669
669
  | GET | `/yard-worlds` | | `{ yardWorlds }`: the world replacing each Yard, by skin. A world is `{ title, revision, lights }`, or `{ title, problem }` when it cannot be used, in which case the Yard shows its original. A Yard with no entry shows its original. |
670
670
  | PUT | `/yard-worlds/:skin` | `{ path }` | `{ yardWorlds }`: checks the `.agworld` file at `path` on the manager's computer and makes it this Yard's world, replacing any before it. 400 `world_invalid` says what is wrong and leaves the Yard unchanged; 404 `unknown_yard`; 409 `world_busy` while another install runs; 409 `worlds_unsupported` without a data folder; 500 `world_unwritable`. Its plates and skies are served at `/yard/worlds/:skin/:file`. |
671
671
  | DELETE | `/yard-worlds/:skin` | | `{ yardWorlds }`: deletes this Yard's world, so it shows its original. |
672
+ | GET | `/yard-pieces` | | `{ yardPieces }`: the pieces replacing each Yard's characters and companions, by skin, then by slot: a crew id (`anthropic`, `openai`, `google`, `xai`, `shell`, `docker`) or `companion`. A piece is `{ title, revision }`, or `{ title, problem }` when it cannot be used, in which case the Yard shows its original. Terminal AI Chat wears the `shell` piece, gilded. |
673
+ | PUT | `/yard-pieces/:skin/:slot` | `{ path }` | `{ yardPieces }`: copies the piece folder at `path` on the manager's computer and makes it this slot's piece, replacing any before it. The folder holds `piece.json` (`format: 1`, `kind` `character` or `companion`, optional `title`) and `character.glb`, or all four of `companion_0.glb` to `companion_3.glb`; the models follow the Yard's skeleton, animations and `yard` extras, and are checked by drawing them with the Yard's own loader; their sizes, joints, clip lengths and `yard` extras must fall within the limits in `src/manager/yard-piece-check.mjs` and `yardExtras` in `web/yard/model.mjs`. 400 `piece_invalid` says what is wrong and leaves the slot unchanged; 404 `unknown_yard` or `unknown_slot`; 409 `piece_busy` while another change runs; 409 `pieces_unsupported` without a data folder; 500 `piece_unwritable`. Its models are served at `/yard/pieces/:skin/:slot/:file`. |
674
+ | DELETE | `/yard-pieces/:skin/:slot` | | `{ yardPieces }`: deletes this slot's piece, so it shows its original. 500 `piece_unwritable` leaves the piece in place. |
672
675
  | POST | `/companion/install` | | `201 { session }`: starts a session that downloads the latest Grove Companion, checks its signature, installs it and starts it. 400 `companion_unsupported` unless the manager runs on Windows or macOS; 409 `install_in_progress` while one runs. |
673
676
  | POST | `/yard/fireworks` | | `{ ok, pages }`: fireworks over the Yard of every open page, sent as `yard.fireworks`. `pages` is how many pages were listening. |
674
677
  | GET | `/changelog` | | `{ refreshing, okAt, error, releases }`: Agent Guild's own releases, newest first, each `{ version, url, publishedAt, sections: [{ title, changes }] }`, where `title` may be null and a change is a list of text runs. A `changelog.updated` event follows a refresh. |
@@ -746,7 +749,7 @@ but `{ type: "ping" }`, which the manager answers with `{ type: "pong" }`.
746
749
 
747
750
  | Message | Meaning |
748
751
  | --- | --- |
749
- | `{ type: "hello", version, pid, platform, startedAt, launcher, folderOpener, remoteAccess, upgrade, yardArt, yardWorlds, sessions, heartbeat, notesRevision, notesUnreadable }` | Sent first: the manager (as in `/info`), the full session list and the notepad's revision. |
752
+ | `{ type: "hello", version, pid, platform, startedAt, launcher, folderOpener, remoteAccess, upgrade, yardArt, yardWorlds, yardPieces, sessions, heartbeat, notesRevision, notesUnreadable }` | Sent first: the manager (as in `/info`), the full session list and the notepad's revision. |
750
753
  | `{ type: "session.created", session }` | A session was started by any client. |
751
754
  | `{ type: "session.updated", session }` | Status, activity, agents, name or size changed. |
752
755
  | `{ type: "session.removed", sessionId }` | A session was removed. |
@@ -755,6 +758,7 @@ but `{ type: "ping" }`, which the manager answers with `{ type: "pong" }`.
755
758
  | `{ type: "news.updated" }` | Fetch `/news` again. |
756
759
  | `{ type: "yard-art.updated", yardArt }` | The Yard's art changed state or made download progress, as in `/yard-art`. |
757
760
  | `{ type: "yard-worlds.updated", yardWorlds }` | A Yard's world was replaced or deleted, as in `/yard-worlds`. |
761
+ | `{ type: "yard-pieces.updated", yardPieces }` | A Yard's character or companion was replaced or deleted, as in `/yard-pieces`. |
758
762
  | `{ type: "yard.fireworks" }` | Fireworks over the Yard, when it is on show. |
759
763
  | `{ type: "changelog.updated" }` | Fetch `/changelog` again. |
760
764
  | `{ type: "github.updated" }` | Fetch `/github` again. |
@@ -0,0 +1,54 @@
1
+ # Changelog
2
+
3
+ ## @jsquash/jpeg@1.6.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/jpeg/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/jpeg@1.5.0
26
+
27
+ ### Adds
28
+
29
+ - Adds ability to preserve the orientation of the image when decoding. When set to `true`, the image will be rotated to the correct orientation. This is useful when the image has an orientation metadata tag that needs to be respected. By default, this is set to `false`. Note: if you are constrained on memory usage, you may want to consider rotating the image yourself either before or after decoding.
30
+
31
+ ## @jsquash/jpeg@1.4.0
32
+
33
+ ### Adds
34
+
35
+ - Adds ability to customise Emscripten module options, e.g. define your own `locateFile` method.
36
+
37
+ ## @jsquash/jpeg@1.3.0
38
+
39
+ ### Adds
40
+
41
+ - Adds Node.js ESM support
42
+ - Updates relative imports to use file extensions
43
+ - Adds `module` field to relevant `package.json`
44
+ - Updates pre.js to polyfill ImageData for Node.js
45
+
46
+ ### Misc.
47
+
48
+ - Removes *.d.ts.map files from the package
49
+
50
+ ## @jsquash/jpeg@1.2.0
51
+
52
+ ### Added
53
+
54
+ - 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,105 @@
1
+ # @jsquash/jpeg
2
+
3
+ [![npm version](https://badge.fury.io/js/@jsquash%2Fjpeg.svg)](https://badge.fury.io/js/@jsquash%2Fjpeg)
4
+
5
+ An easy experience for encoding and decoding JPEG images in the browser. Powered by WebAssembly ⚡️.
6
+
7
+ Uses the [MozJPEG](https://github.com/mozilla/mozjpeg) library.
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/jpeg
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?: DecodeOptions): Promise<ImageData>
23
+
24
+ Decodes JPEG binary ArrayBuffer to raw RGB image data.
25
+
26
+ #### data
27
+ Type: `ArrayBuffer`
28
+
29
+ #### options
30
+ Type: `Partial<DecodeOptions>`
31
+
32
+ The custom options for the decoder. Setting `preserveOrientation` to `true` will rotate the image to the correct orientation based on the metadata tag. By default, this is set to `false`.
33
+
34
+ #### Example
35
+ ```js
36
+ import { decode } from '@jsquash/jpeg';
37
+
38
+ const formEl = document.querySelector('form');
39
+ const formData = new FormData(formEl);
40
+ // Assuming user selected an input jpeg file
41
+ const imageData = await decode(await formData.get('image').arrayBuffer());
42
+ ```
43
+
44
+ ### encode(data: ImageData, options?: EncodeOptions): Promise<ArrayBuffer>
45
+
46
+ Encodes raw RGB image data to JPEG format and resolves to an ArrayBuffer of binary data.
47
+
48
+ #### data
49
+ Type: `ImageData`
50
+
51
+ #### options
52
+ Type: `Partial<EncodeOptions>`
53
+
54
+ The MozJPEG encoder options for the output image. [See default values](./meta.ts).
55
+
56
+ #### Example
57
+ ```js
58
+ import { encode } from '@jsquash/jpeg';
59
+
60
+ async function loadImage(src) {
61
+ const img = document.createElement('img');
62
+ img.src = src;
63
+ await new Promise(resolve => img.onload = resolve);
64
+ const canvas = document.createElement('canvas');
65
+ [canvas.width, canvas.height] = [img.width, img.height];
66
+ const ctx = canvas.getContext('2d');
67
+ ctx.drawImage(img, 0, 0);
68
+ return ctx.getImageData(0, 0, img.width, img.height);
69
+ }
70
+
71
+ const rawImageData = await loadImage('/example.png');
72
+ const jpegBuffer = await encode(rawImageData);
73
+ ```
74
+
75
+ ## Manual WASM initialisation (not recommended)
76
+
77
+ In most situations there is no need to manually initialise the provided WebAssembly modules.
78
+ The generated glue code takes care of this and supports most web bundlers.
79
+
80
+ 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)).
81
+
82
+ The `encode` and `decode` modules both export an `init` function that can be used to manually load the wasm module.
83
+
84
+ ```js
85
+ import decode, { init as initJpegDecode } from '@jsquash/jpeg/decode';
86
+
87
+ initJpegDecode(WASM_MODULE); // The `WASM_MODULE` variable will need to be sourced by yourself and passed as an ArrayBuffer.
88
+ const image = await fetch('./image.jpeg').then(res => res.arrayBuffer()).then(decode);
89
+ ```
90
+
91
+ You can also pass custom options to the `init` function to customise the behaviour of the module. See the [Emscripten documentation](https://emscripten.org/docs/api_reference/module.html#Module) for more information.
92
+
93
+ ```js
94
+ import decode, { init as initJpegDecode } from '@jsquash/jpeg/decode';
95
+
96
+ initJpegDecode(null, {
97
+ // Customise the path to load the wasm file
98
+ locateFile: (path, prefix) => `https://example.com/${prefix}/${path}`,
99
+ });
100
+ const image = await fetch('./image.jpeg').then(res => res.arrayBuffer()).then(decode);
101
+ ```
102
+
103
+ ## Known Issues
104
+
105
+ See [jSquash Project README](https://github.com/jamsinclair/jSquash#known-issues)
@@ -0,0 +1,132 @@
1
+ libjpeg-turbo Licenses
2
+ ======================
3
+
4
+ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
5
+
6
+ - The IJG (Independent JPEG Group) License, which is listed in
7
+ [README.ijg](README.ijg)
8
+
9
+ This license applies to the libjpeg API library and associated programs
10
+ (any code inherited from libjpeg, and any modifications to that code.)
11
+
12
+ - The Modified (3-clause) BSD License, which is listed below
13
+
14
+ This license covers the TurboJPEG API library and associated programs, as
15
+ well as the build system.
16
+
17
+ - The [zlib License](https://opensource.org/licenses/Zlib)
18
+
19
+ This license is a subset of the other two, and it covers the libjpeg-turbo
20
+ SIMD extensions.
21
+
22
+
23
+ Complying with the libjpeg-turbo Licenses
24
+ =========================================
25
+
26
+ This section provides a roll-up of the libjpeg-turbo licensing terms, to the
27
+ best of our understanding.
28
+
29
+ 1. If you are distributing a modified version of the libjpeg-turbo source,
30
+ then:
31
+
32
+ 1. You cannot alter or remove any existing copyright or license notices
33
+ from the source.
34
+
35
+ **Origin**
36
+ - Clause 1 of the IJG License
37
+ - Clause 1 of the Modified BSD License
38
+ - Clauses 1 and 3 of the zlib License
39
+
40
+ 2. You must add your own copyright notice to the header of each source
41
+ file you modified, so others can tell that you modified that file (if
42
+ there is not an existing copyright header in that file, then you can
43
+ simply add a notice stating that you modified the file.)
44
+
45
+ **Origin**
46
+ - Clause 1 of the IJG License
47
+ - Clause 2 of the zlib License
48
+
49
+ 3. You must include the IJG README file, and you must not alter any of the
50
+ copyright or license text in that file.
51
+
52
+ **Origin**
53
+ - Clause 1 of the IJG License
54
+
55
+ 2. If you are distributing only libjpeg-turbo binaries without the source, or
56
+ if you are distributing an application that statically links with
57
+ libjpeg-turbo, then:
58
+
59
+ 1. Your product documentation must include a message stating:
60
+
61
+ This software is based in part on the work of the Independent JPEG
62
+ Group.
63
+
64
+ **Origin**
65
+ - Clause 2 of the IJG license
66
+
67
+ 2. If your binary distribution includes or uses the TurboJPEG API, then
68
+ your product documentation must include the text of the Modified BSD
69
+ License (see below.)
70
+
71
+ **Origin**
72
+ - Clause 2 of the Modified BSD License
73
+
74
+ 3. You cannot use the name of the IJG or The libjpeg-turbo Project or the
75
+ contributors thereof in advertising, publicity, etc.
76
+
77
+ **Origin**
78
+ - IJG License
79
+ - Clause 3 of the Modified BSD License
80
+
81
+ 4. The IJG and The libjpeg-turbo Project do not warrant libjpeg-turbo to be
82
+ free of defects, nor do we accept any liability for undesirable
83
+ consequences resulting from your use of the software.
84
+
85
+ **Origin**
86
+ - IJG License
87
+ - Modified BSD License
88
+ - zlib License
89
+
90
+
91
+ The Modified (3-clause) BSD License
92
+ ===================================
93
+
94
+ Copyright (C)2009-2020 D. R. Commander. All Rights Reserved.
95
+ Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
96
+
97
+ Redistribution and use in source and binary forms, with or without
98
+ modification, are permitted provided that the following conditions are met:
99
+
100
+ - Redistributions of source code must retain the above copyright notice,
101
+ this list of conditions and the following disclaimer.
102
+ - Redistributions in binary form must reproduce the above copyright notice,
103
+ this list of conditions and the following disclaimer in the documentation
104
+ and/or other materials provided with the distribution.
105
+ - Neither the name of the libjpeg-turbo Project nor the names of its
106
+ contributors may be used to endorse or promote products derived from this
107
+ software without specific prior written permission.
108
+
109
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
110
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
111
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
112
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
113
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
114
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
115
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
116
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
117
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
118
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
119
+ POSSIBILITY OF SUCH DAMAGE.
120
+
121
+
122
+ Why Three Licenses?
123
+ ===================
124
+
125
+ The zlib License could have been used instead of the Modified (3-clause) BSD
126
+ License, and since the IJG License effectively subsumes the distribution
127
+ conditions of the zlib License, this would have effectively placed
128
+ libjpeg-turbo binary distributions under the IJG License. However, the IJG
129
+ License specifically refers to the Independent JPEG Group and does not extend
130
+ attribution and endorsement protections to other entities. Thus, it was
131
+ desirable to choose a license that granted us the same protections for new code
132
+ that were granted to the IJG for code derived from their software.
@@ -0,0 +1,7 @@
1
+ export interface MozJPEGModule extends EmscriptenWasm.Module {
2
+ decode(data: BufferSource, preserveOrientation: boolean): ImageData | null;
3
+ }
4
+
5
+ declare var moduleFactory: EmscriptenWasm.ModuleFactory<MozJPEGModule>;
6
+
7
+ export default moduleFactory;