tokzip 0.0.0-placeholder.0 → 1.0.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 (89) hide show
  1. package/FORMAT.md +185 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +20 -0
  4. package/README.md +156 -3
  5. package/THIRD_PARTY_NOTICES/AutoMapper__AutoMapper/LICENSE.txt +9 -0
  6. package/THIRD_PARTY_NOTICES/KaiserY__trpl-zh-cn/LICENSE +21 -0
  7. package/THIRD_PARTY_NOTICES/NeroCube__software-architect-zh-tw/LICENSE +21 -0
  8. package/THIRD_PARTY_NOTICES/StartBootstrap__startbootstrap-sb-admin-2/LICENSE +21 -0
  9. package/THIRD_PARTY_NOTICES/apache__jspwiki/LICENSE +317 -0
  10. package/THIRD_PARTY_NOTICES/apache__jspwiki/NOTICE +19 -0
  11. package/THIRD_PARTY_NOTICES/apache__tomcat/LICENSE +1143 -0
  12. package/THIRD_PARTY_NOTICES/apache__tomcat/NOTICE +68 -0
  13. package/THIRD_PARTY_NOTICES/aszx87410__huli-blog/LICENSE +201 -0
  14. package/THIRD_PARTY_NOTICES/axios__axios/LICENSE +7 -0
  15. package/THIRD_PARTY_NOTICES/bradtraversy__50projects50days/LICENSE +21 -0
  16. package/THIRD_PARTY_NOTICES/cfg-if/LICENSE-APACHE +201 -0
  17. package/THIRD_PARTY_NOTICES/cfg-if/LICENSE-MIT +25 -0
  18. package/THIRD_PARTY_NOTICES/cfug__dio/LICENSE +22 -0
  19. package/THIRD_PARTY_NOTICES/clap-rs__clap/LICENSE-APACHE +202 -0
  20. package/THIRD_PARTY_NOTICES/clap-rs__clap/LICENSE-MIT +19 -0
  21. package/THIRD_PARTY_NOTICES/colinhacks__zod/LICENSE +21 -0
  22. package/THIRD_PARTY_NOTICES/commercialhaskell__stack/LICENSE +24 -0
  23. package/THIRD_PARTY_NOTICES/compiler-builtins/LICENSE.txt +275 -0
  24. package/THIRD_PARTY_NOTICES/composer__composer/LICENSE +19 -0
  25. package/THIRD_PARTY_NOTICES/crc32fast/LICENSE-APACHE +202 -0
  26. package/THIRD_PARTY_NOTICES/crc32fast/LICENSE-MIT +21 -0
  27. package/THIRD_PARTY_NOTICES/curl__curl/COPYING +22 -0
  28. package/THIRD_PARTY_NOTICES/dart-lang__http/LICENSE +27 -0
  29. package/THIRD_PARTY_NOTICES/denoland__docs/LICENSE +20 -0
  30. package/THIRD_PARTY_NOTICES/fmtlib__fmt/LICENSE +27 -0
  31. package/THIRD_PARTY_NOTICES/google__gson/LICENSE +202 -0
  32. package/THIRD_PARTY_NOTICES/guzzle__guzzle/LICENSE +27 -0
  33. package/THIRD_PARTY_NOTICES/h5bp__html5-boilerplate/LICENSE.txt +19 -0
  34. package/THIRD_PARTY_NOTICES/haskell__aeson/LICENSE +30 -0
  35. package/THIRD_PARTY_NOTICES/index.json +323 -0
  36. package/THIRD_PARTY_NOTICES/jgthms__bulma/LICENSE +21 -0
  37. package/THIRD_PARTY_NOTICES/jquery__jquery/AUTHORS.txt +376 -0
  38. package/THIRD_PARTY_NOTICES/jquery__jquery/LICENSE.txt +20 -0
  39. package/THIRD_PARTY_NOTICES/libm/LICENSE.txt +258 -0
  40. package/THIRD_PARTY_NOTICES/libuv__libuv/AUTHORS +592 -0
  41. package/THIRD_PARTY_NOTICES/libuv__libuv/LICENSE +19 -0
  42. package/THIRD_PARTY_NOTICES/libuv__libuv/LICENSE-docs +396 -0
  43. package/THIRD_PARTY_NOTICES/libuv__libuv/LICENSE-extra +36 -0
  44. package/THIRD_PARTY_NOTICES/lodash__lodash/LICENSE +47 -0
  45. package/THIRD_PARTY_NOTICES/microsoft__TypeScript/LICENSE.txt +55 -0
  46. package/THIRD_PARTY_NOTICES/microsoft__TypeScript/ThirdPartyNoticeText.txt +193 -0
  47. package/THIRD_PARTY_NOTICES/neighborhood999__fantasy-land-traditional-chinese/LICENSE +21 -0
  48. package/THIRD_PARTY_NOTICES/nlohmann__json/LICENSE.MIT +21 -0
  49. package/THIRD_PARTY_NOTICES/nunit__nunit/LICENSE.txt +20 -0
  50. package/THIRD_PARTY_NOTICES/nunit__nunit/NOTICES.md.txt +10 -0
  51. package/THIRD_PARTY_NOTICES/nunit__nunit/THIRD_PARTY_NOTICES.md.txt +19 -0
  52. package/THIRD_PARTY_NOTICES/nunit__nunit/THIRD_PARTY_NOTICES_DEV.md.txt +33 -0
  53. package/THIRD_PARTY_NOTICES/pallets__flask/LICENSE.txt +28 -0
  54. package/THIRD_PARTY_NOTICES/psf__requests/AUTHORS.rst +195 -0
  55. package/THIRD_PARTY_NOTICES/psf__requests/LICENSE +175 -0
  56. package/THIRD_PARTY_NOTICES/psf__requests/NOTICE +2 -0
  57. package/THIRD_PARTY_NOTICES/pydantic__pydantic/LICENSE +21 -0
  58. package/THIRD_PARTY_NOTICES/rails__rails/LICENSE-MIT-LICENSE +20 -0
  59. package/THIRD_PARTY_NOTICES/rust/COPYRIGHT-library.txt +28267 -0
  60. package/THIRD_PARTY_NOTICES/rust-lang-ja__book-ja/COPYRIGHT +290 -0
  61. package/THIRD_PARTY_NOTICES/rust-lang-ja__book-ja/LICENSE-APACHE +201 -0
  62. package/THIRD_PARTY_NOTICES/rust-lang-ja__book-ja/LICENSE-MIT +25 -0
  63. package/THIRD_PARTY_NOTICES/rust-lang__book/COPYRIGHT +3 -0
  64. package/THIRD_PARTY_NOTICES/rust-lang__book/LICENSE-APACHE +201 -0
  65. package/THIRD_PARTY_NOTICES/rust-lang__book/LICENSE-MIT +25 -0
  66. package/THIRD_PARTY_NOTICES/serde-rs__serde/LICENSE-APACHE +176 -0
  67. package/THIRD_PARTY_NOTICES/serde-rs__serde/LICENSE-MIT +23 -0
  68. package/THIRD_PARTY_NOTICES/sinatra__sinatra/AUTHORS.md.txt +87 -0
  69. package/THIRD_PARTY_NOTICES/sinatra__sinatra/LICENSE +26 -0
  70. package/THIRD_PARTY_NOTICES/square__okhttp/LICENSE.txt +202 -0
  71. package/THIRD_PARTY_NOTICES/tabler__tabler/LICENSE +21 -0
  72. package/THIRD_PARTY_NOTICES/tigerbeetle__tigerbeetle/LICENSE +177 -0
  73. package/THIRD_PARTY_NOTICES/twbs__bootstrap/LICENSE +21 -0
  74. package/THIRD_PARTY_NOTICES/vuejs-jp__ja.vuejs.org/LICENSE +21 -0
  75. package/THIRD_PARTY_NOTICES/vuejs__v2.cn.vuejs.org/LICENSE +21 -0
  76. package/THIRD_PARTY_NOTICES/vuejs__v2.vuejs.org/LICENSE +21 -0
  77. package/THIRD_PARTY_NOTICES/zigtools__zls/LICENSE +21 -0
  78. package/dist/core.d.ts +32 -0
  79. package/dist/core.js +2 -0
  80. package/dist/core.js.map +1 -0
  81. package/dist/index.d.ts +10 -0
  82. package/dist/index.js +2 -0
  83. package/dist/index.js.map +1 -0
  84. package/package.json +79 -7
  85. package/src/core.ts +149 -0
  86. package/src/index.ts +25 -0
  87. package/src/wasm.d.ts +5 -0
  88. package/src/workers.ts +26 -0
  89. package/wasm/tokzip.wasm +0 -0
package/FORMAT.md ADDED
@@ -0,0 +1,185 @@
1
+ # tokzip frame format (version 2)
2
+
3
+ Format 2 is a permanent read contract: future package releases must continue to decode valid
4
+ format-2 frames. The current writer emits format 2. Earlier experimental formats are unsupported.
5
+ Package versions and frame-format versions are independent.
6
+
7
+ Dictionaries, trained model priors, language IDs, token grammar, and decoding rules are format
8
+ identity. Changing them for new writes requires a new format identifier and retaining the
9
+ format-2 decoder with its original assets. The frame header identifies which decoder to use;
10
+ introducing a new writer must not require rewriting existing stored records. Encoder search
11
+ and language detection may improve within format 2 when the existing decoder can still read
12
+ the resulting frames.
13
+
14
+ `test/fixtures/format2Assets.json` freezes the SHA-256 of every format-2 dictionary and prior
15
+ from its recorded source revision. The asset check also rejects added or removed `.bin` files
16
+ in the current asset directories. When introducing new assets, preserve the frozen format-2
17
+ set separately and keep its hash checks; do not replace the recorded hashes with new values.
18
+ `test/fixtures/format2Languages.json` contains independent single-segment reference frames
19
+ for every language ID, encoded with that language's dictionary and priors at the same revision.
20
+ `test/fixtures/format2.json` also covers empty and nonempty stored frames, multi-segment frames,
21
+ and blocked frames with coded and stored blocks.
22
+ Keep these fixtures unchanged and run them against the public decoder in every release.
23
+
24
+ The reference implementation is `rust/crates/tokzip`. All multi-byte integers are little-endian;
25
+ varints are LEB128 (7 payload bits per byte, bit 7 = continue, canonical: a multi-byte varint
26
+ never ends in a zero byte).
27
+
28
+ ## Frame
29
+
30
+ ```
31
+ frame := header sizeVarint crc32 body
32
+ ```
33
+
34
+ - `header`: one byte — magic `1101` in the high nibble, then two version bits (2; the value 3
35
+ is reserved for an extension byte that would follow), then two layout bits: 0 =
36
+ single-segment, 1 = multi-segment, 2 = blocked, 3 = stored.
37
+ - `sizeVarint`: decompressed length in bytes. For coded frames decoders reject a length above
38
+ 8192 × the body length before allocating anything — and, unless the frame is blocked, above
39
+ 4 MiB — and reject a frame whose coded body needs more than a fixed synthetic-padding budget
40
+ past its end while decoding.
41
+ - `crc32`: IEEE CRC-32 of the decompressed content; decoders verify it before returning.
42
+ - `body`: stored → the content itself (exactly `size` bytes). Blocked → the block sequence
43
+ (§1). Otherwise a segment table (§2) then the range-coded stream (§4).
44
+
45
+ The content is a UTF-8 string; the format carries no content type.
46
+
47
+ Stored frames are the encoder's fallback whenever coding would not be strictly smaller or the
48
+ encoder's own decode check fails; empty content is always stored.
49
+
50
+ ## 1. Blocks
51
+
52
+ Content above 4 MiB is coded as consecutive blocks of 4 MiB (the last one shorter), so the
53
+ coder's working set is bounded by the block size; a blocked frame whose `size` fits one block
54
+ is a structural error. Each block is coded independently: its own language segments and
55
+ models, and tokens never reach into an earlier block.
56
+
57
+ ```
58
+ block := blockLayout payloadLenVarint payload
59
+ ```
60
+
61
+ - `blockLayout`: one byte with the frame header's layout values — 0 single-segment, 1
62
+ multi-segment, 3 stored (2 and anything above 3 are a structural error).
63
+ - `payload`: stored → the block's content (exactly the block length). Otherwise the block's
64
+ segment table (§2) then its range-coded stream (§4), laid out exactly as a single-block body.
65
+
66
+ The encoder stores a block whose coded payload would not be strictly smaller or fails its
67
+ decode check — and, without coding the rest, a block longer than 256 KiB whose first 256 KiB
68
+ does not shrink when coded on its own — and falls back to a stored frame when the blocked frame
69
+ as a whole would not be smaller. Trailing bytes after the last block are a structural error.
70
+
71
+ ## 2. Segments
72
+
73
+ The encoder splits the content (or each block) into language segments (contiguous, covering the whole
74
+ content). Single segment: one byte, the language id. Multi-segment (layout 1): a varint
75
+ segment count (at most 2^20; decoders reject more), then per segment a language-id byte and a
76
+ varint length; lengths are non-zero and sum to `size` (the block length in a blocked frame).
77
+
78
+ Language ids (format identity — the dictionaries and priors they name are part of the codec).
79
+ Each language belongs to a model group (§5):
80
+
81
+ | id | language | group | dictionary suffix |
82
+ | --- | ---------- | -------- | ----------------- |
83
+ | 0 | text | prose | 128 KB |
84
+ | 1 | en-US | prose | 128 KB |
85
+ | 2 | ja-JP | japanese | 128 KB |
86
+ | 3 | html | code | 48 KB |
87
+ | 4 | css | code | 48 KB |
88
+ | 5 | javascript | code | 48 KB |
89
+ | 6 | typescript | code | 48 KB |
90
+ | 7 | c | code | 48 KB |
91
+ | 8 | cpp | code | 48 KB |
92
+ | 9 | csharp | code | 48 KB |
93
+ | 10 | dart | code | 48 KB |
94
+ | 11 | haskell | code | 48 KB |
95
+ | 12 | java | code | 48 KB |
96
+ | 13 | jsp | code | 48 KB |
97
+ | 14 | php | code | 48 KB |
98
+ | 15 | python | code | 48 KB |
99
+ | 16 | ruby | code | 48 KB |
100
+ | 17 | rust | code | 48 KB |
101
+ | 18 | zig | code | 48 KB |
102
+ | 19 | zh-CN | chinese | 128 KB |
103
+ | 20 | zh-TW | chinese | 128 KB |
104
+
105
+ Each language's dictionary is the shared wrapper (`dict/wrapper.bin`), then its group's shared
106
+ part (`dict/<group>.bin`: 64 KB for `code`, empty for the other groups), then its trained
107
+ suffix (`dict/<language>.bin`); its models start from its group's literal priors
108
+ (`priors/<group>.bin`) and its own nodes (`priors/<language>.bin`) (§5).
109
+
110
+ ## 3. Window
111
+
112
+ Tokens address a source by distance `d ≥ 1` from the current position `p`: `d ≤ p` reaches
113
+ into the already-decoded content, larger distances continue into the active segment's
114
+ dictionary as if it preceded the content (`dict[D − (d − p)]`, `D` = dictionary length). A
115
+ copy runs forward one byte at a time, so it may overlap its own output and may cross from the
116
+ dictionary into the content. Tokens never cross a segment boundary.
117
+
118
+ ## 4. Coded stream
119
+
120
+ One LZMA-style adaptive binary range coder (32-bit range, 11-bit probabilities, adaptation
121
+ shift 5, renormalization at 2^24) codes the whole body (one block's payload in a blocked
122
+ frame) across all of its segments. The encoder drops the always-zero first output byte, ends
123
+ the stream on the value of the final interval with the most trailing zero bytes, and trims
124
+ trailing zero bytes; the decoder feeds zeros past the end of the body and rejects a body that
125
+ has bytes it never read.
126
+
127
+ Coder state shared across segments: the 12-state LZMA state machine and the four most recent
128
+ distances (`reps`, stored as distance − 1, initially 0). At every segment start, a rep whose
129
+ distance exceeds `p + D` of the new segment resets to 0 (distance 1). Each segment swaps in its
130
+ language's adaptive models; a language's models persist across all of its segments in one block.
131
+
132
+ Token grammar per position (bits are coded with the model node named in brackets; `s` is the
133
+ state):
134
+
135
+ - `[is_match s] = 0` → **literal**: 8 bits MSB-first through the literal tree of the context
136
+ pair (class of the previous byte, class of the byte before it; §5). After a match (`s ≥ 7`) the first bits are coded through the shared
137
+ matched-literal trees, predicted by the byte at `reps[0] + 1`, until the first mismatch.
138
+ - `[is_match s] = 1`, `[is_rep s] = 0` → **explicit match**:
139
+ - `[is_dict s] = 0`: length (`LEN` model) then distance − 1 (`HIST_DIST` model).
140
+ - `[is_dict s] = 1`: length (`DICT_LEN` model) then the absolute dictionary offset
141
+ (`DICT_OFF` model); the distance is `p + D − offset`.
142
+ - `reps` = [distance − 1, reps[0], reps[1], reps[2]].
143
+ - `[is_match s] = 1`, `[is_rep s] = 1` → **rep match**: `[is_rep_g0 s] = 0` selects `reps[0]`
144
+ (`[is_rep0_long s] = 0` is a single-byte short rep with no length); otherwise `is_rep_g1` /
145
+ `is_rep_g2` select `reps[1..3]`, which move to the front. Then a length (`REP_LEN` model).
146
+
147
+ Lengths: `choice` bit → 3-bit tree (2–9), `choice2` bit → 3-bit tree (10–17), else 8-bit tree
148
+ (18–273). Distances/offsets: 6-bit slot tree per length state (`min(len − 2, 3)`), then for
149
+ slots ≥ 4 the LZMA footer bits — reverse bit trees for slots < 14 (`spec_pos`), direct bits plus
150
+ a 4-bit reverse `align` tree beyond.
151
+
152
+ ## 5. Models and priors
153
+
154
+ Probabilities have a logical flat layout (`lz.rs`: `is_match`,
155
+ `is_rep`, `is_rep_g0`, `is_rep_g1`, `is_rep_g2`, `is_rep0_long`, `is_dict` × 12 states;
156
+ `LEN`, `REP_LEN`, `DICT_LEN` × 274; `HIST_DIST`, `DICT_OFF` × 386; 128 × 32 literal context
157
+ pairs × 256 plain-tree nodes; 512 shared matched-literal nodes). The literal context of a
158
+ position is the pair (class of the previous byte, class of the byte before it), each byte
159
+ continuing into the dictionary before the content start and 0 where neither exists. Every
160
+ node's initial probability is quantized to 8 bits: the value 128 (`PRIORS_DEFAULT`) is the
161
+ flat probability `p11 = 1024`, any other `q` is `p11 = (q << 3) | 4`. `priors/<language>.bin`
162
+ holds the language's own nodes
163
+ (those before the literal trees), one byte each in layout order. `priors/<group>.bin` holds
164
+ the 256-entry previous-byte → class table (values < 128), the 256-entry second-previous-byte →
165
+ class table (values < 32), then every 256-node tree from the literal trees on (the plain
166
+ literal trees, then the two matched-literal trees) as a depth-first walk with one flag bit per
167
+ visited node — 1: the node's value follows in the value stream and its children are walked; 0:
168
+ the node and its subtree are flat and skipped — the flag bits of a tree packed LSB-first into
169
+ bytes, followed by its values. The current generation is trained offline (`bun run train`). These assets are format
170
+ identity.
171
+
172
+ The class tables and the literal trees (everything from the literal context pairs on) are
173
+ shared by the languages of a model group — prose (`text`, `en-US`), Japanese, Chinese, code —
174
+ and trained on the group's pooled literal statistics; a literal node whose trained value would
175
+ have saved fewer than 6 bits on the training data stays at the flat probability 1/2. The nodes
176
+ before the literal trees are per language. At runtime, immutable literal priors and context
177
+ tables are allocated once per group; each document adapts its own copies of the trees it uses.
178
+
179
+ The module embeds the priors as committed and the dictionaries in a packed form that is not
180
+ part of the format (see `rust/crates/tokzip/build.rs` and `pack.rs`): each dictionary part
181
+ coded by the codec itself as one segment with the models of the language. Language suffixes
182
+ use the wrapper and group dictionary as their prefix dictionary; a group's shared part uses
183
+ no dictionary and the group's first language's models. They are decoded on first use. The
184
+ detection table maps each 4-gram hash through a 16-bit index to a three-byte language set,
185
+ which detection reads instead of decoding the dictionaries.
package/LICENSE ADDED
@@ -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 [yyyy] [name of copyright owner]
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.
package/NOTICE ADDED
@@ -0,0 +1,20 @@
1
+ tokzip
2
+ Copyright 2026 WillBooster Inc.
3
+
4
+ Original tokzip code is licensed under the Apache License, Version 2.0.
5
+
6
+ The dictionaries embedded in wasm/tokzip.wasm and stored in dict/ contain
7
+ selected, concatenated and truncated fragments of third-party public training
8
+ documents. These fragments remain subject to their upstream licenses. The
9
+ source repository pins and upstream license, copyright and NOTICE files are
10
+ provided in THIRD_PARTY_NOTICES/index.json and the directories it identifies.
11
+ The handcrafted wrapper dictionary is original tokzip content.
12
+
13
+ The Wasm module also incorporates crc32fast, cfg-if, and the Rust standard
14
+ library, including compiler-builtins and libm. Their license and copyright
15
+ material is provided under THIRD_PARTY_NOTICES/. The Rust notice catalog is
16
+ rendered as plain text from the pinned toolchain and includes components for
17
+ other targets that may not be linked into this module. Upstream Markdown
18
+ notice files have a .txt suffix to preserve them without project formatting.
19
+
20
+ The Apache-2.0 license for tokzip does not replace any third-party terms.
package/README.md CHANGED
@@ -1,6 +1,159 @@
1
1
  # tokzip
2
2
 
3
- This is a placeholder for the upcoming tokzip package.
4
- It contains no compression implementation or public API.
3
+ [![Test](https://github.com/WillBooster/tokzip/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tokzip/actions/workflows/test.yml)
4
+ [![Test rust](https://github.com/WillBooster/tokzip/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tokzip/actions/workflows/test-rust.yml)
5
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
6
+ [![wbfy](https://img.shields.io/badge/wbfy-20.36.11-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
5
7
 
6
- Source repository: https://github.com/WillBooster/tokzip
8
+ Lossless compressor for **prompts, LLM outputs, and source code** stored at rest — one
9
+ function in, one function out, no compression options (only an optional decode length limit).
10
+ The codec is Rust compiled to a single **wasm module (~1.1 MB, with 21 dictionaries
11
+ and trained models)** with a thin TypeScript wrapper; it runs on Node, Bun,
12
+ and Cloudflare Workers.
13
+ The module requires WebAssembly SIMD, which [Workers supports](https://developers.cloudflare.com/workers/runtime-apis/webassembly/#simd).
14
+
15
+ ```ts
16
+ import { compress, decompress } from 'tokzip';
17
+
18
+ const frame = compress(text); // Uint8Array; strings must be well-formed UTF-16 (no lone surrogates)
19
+ const restored = decompress(frame); // === text
20
+ decompress(untrustedFrame, { maxLength: 8 * 1024 * 1024 }); // throws instead of expanding further
21
+ ```
22
+
23
+ - **Node and Bun** load the module from the `wasm/` file shipped in the package (bundlers such
24
+ as Next.js trace the `new URL(..., import.meta.url)` reference and carry the file along).
25
+ - **Cloudflare Workers** resolve the `workerd` export condition (wrangler and the Cloudflare
26
+ Vite plugin set it) to an entry that imports the `.wasm` as a module, which is the only way
27
+ Workers accept wasm. The wrapper imports `node:buffer`, so the Worker needs the
28
+ `nodejs_compat` compatibility flag. The first call in an isolate decodes the dictionary of
29
+ each language it uses and initializes shared model priors lazily; later calls reuse them.
30
+ First-use CPU depends on the languages and the runtime, so measure it separately from warm calls.
31
+ - `FORMAT_VERSION` is 2. Future package releases will retain decoding support for format 2,
32
+ including its dictionaries and trained model priors. A future format can improve compression
33
+ for new writes without requiring existing records to be recompressed. Earlier experimental
34
+ formats are not supported. `TokzipDecodeError` carries a numeric `code`. See [FORMAT.md](FORMAT.md)
35
+ for the wire specification and compatibility rules.
36
+
37
+ There is nothing to configure: the encoder **detects the language of the input itself,
38
+ segment by segment** — a Japanese prompt, a Markdown answer with an HTML block whose
39
+ `<script>` is JavaScript, a TypeScript file — and codes each segment with the matching
40
+ trained dictionary and model priors. Embedded languages: `text`, `en-US`, `ja-JP`, `zh-CN`,
41
+ `zh-TW`, `html`, `css`, `javascript`, `typescript`, `c`, `cpp`, `csharp`, `dart`,
42
+ `haskell`, `java`, `jsp`, `php`, `python`, `ruby`, `rust`, `zig`; anything else falls back to
43
+ the closest one.
44
+
45
+ - **Codec**: LZ77 over the document plus the segment's dictionary (128 KB for prose
46
+ languages; for code, a 64 KB part shared by every programming language plus 48 KB per
47
+ language; COVER-trained: the fragments of the public corpus whose 8-byte grams occur in the
48
+ most documents — counted over the public corpus and, for the languages it holds at least
49
+ 1 MiB of, the private production corpus, so every dictionary byte is a substring of a public document
50
+ while the selection follows production usage; segment size picked by coding held-out
51
+ documents), price-based parse (a bounded shortest-path over 1 KB chunks, committing early
52
+ on long matches), adaptive binary range coder
53
+ (LZMA-style symbol layout, terminated on the shortest representation of its final interval)
54
+ whose literals are modeled by an order-2 context (128 trained classes of the previous byte
55
+ × 32 of the one before) and whose models start from trained priors — short documents get
56
+ the benefit of the statistics immediately, long documents adapt to themselves. The literal
57
+ priors are shared in memory by the languages of a group (Latin prose, Japanese, Chinese, code) and
58
+ trained on the group's pooled statistics — public and private documents alike, since priors
59
+ are statistics, not content; the rest is per language. Matches into the
60
+ dictionary are coded as absolute dictionary offsets, so the same fragment costs the same
61
+ wherever it is referenced.
62
+ - **Detection without a parser**: one table maps every 4-gram hash to the languages whose
63
+ dictionary contains it; the input is scored per 64-byte window, sampling alternate positions
64
+ on documents of at least 128 bytes. Labeled code fences add a hint. A Viterbi pass with a
65
+ switch penalty turns the scores into segments, whose
66
+ boundaries snap to the nearest line start. The table stores 16-bit indices into a palette
67
+ of language sets; dense sets are scored by subtracting misses instead of adding hits. On mixed
68
+ prose + code documents this codes ~4 pp smaller than the best single language. When the
69
+ split is uncertain (several segments, or a single language that is not the strongest
70
+ dictionary match) the encoder also codes the document as one segment of the strongest
71
+ match and keeps the smaller — comparing the two on the first 2 KB only above 4 KB, so
72
+ the amount of trial input stays bounded. Identical trial segmentations are encoded only once
73
+ as the selected full document.
74
+ - **Storage-grade**: every frame carries a CRC-32 of its content, `compress` decodes
75
+ every coded block it builds and compares the result to the input before accepting it
76
+ (storing the content — or, in a multi-block frame, that block — verbatim otherwise), and the
77
+ decoder checks framing and CRC-32, reporting failed checks with a typed `TokzipDecodeError`. Incompressible input never expands beyond the stored-frame header (5 bytes
78
+ plus the length varint). Content above 4 MiB is coded as independent 4 MiB blocks (a block
79
+ whose first 256 KiB does not shrink is stored without coding the rest), so the coder's
80
+ working set (several copies of a block) stays bounded whatever the document size; only the
81
+ input and the output (held twice while the frame is assembled) scale with it. The format
82
+ bounds a frame's expansion only relative to its size (a small frame of repetitive content
83
+ legitimately expands thousands of times), so pass `maxLength` when decompressing frames from
84
+ an untrusted source.
85
+
86
+ ## Results
87
+
88
+ Bench split of the pinned [`tokzip-corpus`](https://github.com/WillBooster/tokzip-corpus)
89
+ plus the private production corpus when checked out beside it (21 languages),
90
+ compressed size as a percentage of the input:
91
+
92
+ | documents | tokzip | brotli -11 | zstd -19 | gzip -9 |
93
+ | ---------- | --------- | ---------- | -------- | ------- |
94
+ | all | **20.8%** | 26.3% | 31.1% | 31.9% |
95
+ | ≤ 1 KB | **28.5%** | 47.6% | 60.2% | 61.1% |
96
+ | 1–4 KB | **23.0%** | 33.9% | 42.1% | 42.2% |
97
+ | 4–16 KB | **20.8%** | 25.8% | 30.4% | 31.2% |
98
+ | > 16 KB | **19.1%** | 21.6% | 24.5% | 25.6% |
99
+ | ja-JP | **24.9%** | 35.6% | 42.8% | 43.3% |
100
+ | zh-CN | **26.4%** | 36.8% | 45.3% | 46.1% |
101
+ | typescript | **14.9%** | 17.7% | 19.8% | 20.6% |
102
+ | java | **13.9%** | 23.3% | 28.2% | 28.6% |
103
+ | html | **17.8%** | 21.3% | 25.4% | 26.1% |
104
+
105
+ Cloudflare Workers allow [128 MB per isolate and 10 ms of CPU per request on the free plan](https://developers.cloudflare.com/workers/platform/limits/).
106
+ Dictionary initialization and larger documents can exceed the free CPU budget; local throughput
107
+ is not a reliable way to predict production Workers CPU.
108
+
109
+ Run it yourself: `bun run bench` (add `--speed` for throughput and `--json <file>` for a
110
+ machine-readable report). `--codec-only --repeat 3` measures tokzip alone after warming the
111
+ corpus. With `--speed`, JSON reports include throughput and p50/p95/p99/max latency for the whole
112
+ corpus and each language, size band, and corpus. Reports include the runtime, corpus
113
+ fingerprint, and Wasm hash; every measured frame is checked for lossless round-trip recovery.
114
+ To measure serialized application responses, pass `--input <documents.jsonl>`: each non-blank
115
+ line is one complete JSON value, compressed as written, without the line separator. This uses
116
+ only the supplied file. Reports contain aggregate measurements and fingerprints, not the input
117
+ records.
118
+
119
+ ## License
120
+
121
+ Original tokzip code is licensed under [Apache-2.0](LICENSE). Embedded dictionary fragments
122
+ and compiled dependencies retain their upstream terms. Redistributors must retain the
123
+ accompanying [NOTICE](NOTICE) and [third-party license material](THIRD_PARTY_NOTICES/index.json).
124
+
125
+ ## Development
126
+
127
+ Read the [dependency patch notes](https://github.com/WillBooster/tokzip/blob/main/patches/README.md)
128
+ before updating the patched development dependencies.
129
+
130
+ ```bash
131
+ mise install # bun, node, rust (+ wasm32-unknown-unknown)
132
+ bun install
133
+ bun run build # rust → wasm/tokzip.wasm (committed; rebuild after codec changes), then builds dist/
134
+ bun test # round-trip and resilience tests through the wasm build
135
+ cargo test --release --manifest-path rust/Cargo.toml
136
+ bun run train # new-format development only: read FORMAT.md before overwriting frozen assets
137
+ ```
138
+
139
+ Layout: `rust/crates/tokzip` (codec: `lz.rs` token coding + `lz/parse.rs` price-based search,
140
+ `lang.rs` dictionaries + detection, `languages.rs` the language table, `train.rs` dictionary + priors trainer,
141
+ `pack.rs` + `build.rs` asset packing), `rust/crates/tokzip-wasm` (C-ABI exports), `src/`
142
+ (wrapper: `core.ts` over a compiled module, `index.ts` for Node and Bun, `workers.ts` for
143
+ Cloudflare Workers), `dict/` (the wrapper, the code group's shared part, and each language's
144
+ suffix) and `priors/` (each group's packed literal priors and each language's own model
145
+ nodes; the build embeds them as committed, each dictionary part coded by the codec itself,
146
+ and the detection table of every dictionary's 4-grams), `scripts/train` (wrapper dictionary + trainer entry), `scripts/bench` (corpus
147
+ benchmark), `bench/cloudflare` (Workers benchmark: `bunx wrangler deploy --config
148
+ bench/cloudflare/wrangler.jsonc`, then `node bench/cloudflare/measure.ts <worker-url>`). The
149
+ Workers driver records request CPU from `wrangler tail` and client time-to-first-byte for
150
+ prose, code, JSON responses, and a large mixed document. The driver discards requests on an
151
+ isolate's first invocation. `fresh-*` rows create a fresh
152
+ Wasm instance and initialize its dictionaries; other codec rows additionally require the
153
+ sample to be prepared. Decoder frames are prepared locally, so a fresh decode never needs a
154
+ compression in the measured request.
155
+
156
+ Codec iteration aids (`--features train`): `cargo run --release --features train --example
157
+ eval -- <corpus>:<language> ...` reports ratio and speed per language (`TOKZIP_COST=1` adds
158
+ the share of output bits per model group), `--example prof` the per-step cost of small
159
+ documents.
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2010 Jimmy Bogard
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017-2025 Rust 中文社区
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013-2021 Start Bootstrap LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.