@bigdreamsweb3/wordbin 1.0.8 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +67 -156
- package/package.json +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
Here's the **CONTRIBUTING.md** file ready for you to download and use in your project.
|
|
2
|
+
|
|
3
|
+
You can copy the content below and save it as `CONTRIBUTING.md` in the root of your repository.
|
|
4
|
+
|
|
5
|
+
```markdown
|
|
1
6
|
# Contributing to WordBin
|
|
2
7
|
|
|
3
8
|
Thank you for your interest in contributing to WordBin!
|
|
4
|
-
We welcome all kinds of help — bug reports, documentation improvements, new features, dictionary variants, tests, or small fixes.
|
|
9
|
+
We welcome all kinds of help — bug reports, documentation improvements, new features, dictionary variants, tests, or even small fixes.
|
|
5
10
|
|
|
6
11
|
This guide explains how to contribute effectively and what would be most valuable to the project right now.
|
|
7
12
|
|
|
8
|
-
---
|
|
9
|
-
|
|
10
13
|
## Table of Contents
|
|
11
14
|
|
|
12
15
|
- [Code of Conduct](#code-of-conduct)
|
|
@@ -16,22 +19,15 @@ This guide explains how to contribute effectively and what would be most valuabl
|
|
|
16
19
|
- [Submitting Pull Requests](#submitting-pull-requests)
|
|
17
20
|
- [Good First Issues](#good-first-issues)
|
|
18
21
|
- [Development Setup](#development-setup)
|
|
19
|
-
- [Project Layout](#project-layout)
|
|
20
|
-
- [Running Tests](#running-tests)
|
|
21
|
-
- [Where Things Live](#where-things-live)
|
|
22
22
|
- [Current Priorities (2026)](#current-priorities-2026)
|
|
23
23
|
- [Code Style & Conventions](#code-style--conventions)
|
|
24
24
|
- [License](#license)
|
|
25
25
|
|
|
26
|
-
---
|
|
27
|
-
|
|
28
26
|
## Code of Conduct
|
|
29
27
|
|
|
30
28
|
This project follows the [Contributor Covenant Code of Conduct v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
|
|
31
29
|
Be respectful, inclusive, and constructive in all interactions.
|
|
32
30
|
|
|
33
|
-
---
|
|
34
|
-
|
|
35
31
|
## How to Contribute
|
|
36
32
|
|
|
37
33
|
### Reporting Bugs
|
|
@@ -40,72 +36,66 @@ If you find a bug:
|
|
|
40
36
|
|
|
41
37
|
1. Check if it's already reported in [existing issues](https://github.com/bigdreamsweb3/wordbin/issues).
|
|
42
38
|
2. If not, open a new issue and include:
|
|
43
|
-
-
|
|
39
|
+
- Clear, descriptive title
|
|
44
40
|
- Steps to reproduce
|
|
45
|
-
- Expected vs actual
|
|
46
|
-
- Node.js
|
|
47
|
-
- Dictionary version used (v1
|
|
48
|
-
-
|
|
49
|
-
|
|
41
|
+
- Expected vs actual behavior
|
|
42
|
+
- Node.js / browser version
|
|
43
|
+
- Dictionary version used (v1/v2/custom)
|
|
44
|
+
- Minimal code snippet or test case
|
|
45
|
+
|
|
46
|
+
Use the **Bug report** template when available.
|
|
50
47
|
|
|
51
48
|
### Suggesting Features or Improvements
|
|
52
49
|
|
|
53
|
-
|
|
50
|
+
Have an idea for a new feature, better performance, UX improvement, or new dictionary type?
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
52
|
+
Open an issue with:
|
|
53
|
+
- Problem or opportunity you're addressing
|
|
54
|
+
- Proposed solution (as detailed as you want)
|
|
55
|
+
- Any alternatives you've considered
|
|
56
|
+
- Rough estimate of impact/benefit
|
|
59
57
|
|
|
60
|
-
|
|
58
|
+
Use the **Feature request** template if it exists.
|
|
61
59
|
|
|
62
60
|
### Submitting Pull Requests
|
|
63
61
|
|
|
62
|
+
Want to submit code? Awesome!
|
|
63
|
+
|
|
64
64
|
1. **Fork** the repository and **clone** your fork
|
|
65
|
-
2. Create a
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
# or
|
|
69
|
-
git checkout -b feat/add-top-20k-dictionary
|
|
70
|
-
```
|
|
65
|
+
2. Create a new branch:
|
|
66
|
+
`git checkout -b fix/lowercase-normalization`
|
|
67
|
+
or `feat/add-top-20k-dictionary`
|
|
71
68
|
3. Make your changes
|
|
72
|
-
4. Add or update tests
|
|
73
|
-
5. Run the
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
feat: add partialScan fallback for non-WordBin payloads
|
|
81
|
-
docs: update decode API in README
|
|
82
|
-
test: add round-trip cases for base58 and bin21 formats
|
|
83
|
-
```
|
|
69
|
+
4. Add or update tests if applicable
|
|
70
|
+
5. Run the test suite:
|
|
71
|
+
`npm test` or `npm run vitest`
|
|
72
|
+
6. Commit with clear messages (semantic style preferred):
|
|
73
|
+
`fix: normalize words to lowercase in buildDictionary`
|
|
74
|
+
`feat: add CLI flag for lowercase normalization`
|
|
75
|
+
`docs: improve contributing guide`
|
|
76
|
+
`test: add cases for empty input and literals`
|
|
84
77
|
7. Push your branch and open a pull request against `main`
|
|
85
78
|
|
|
86
|
-
Small, focused PRs are merged quickly.
|
|
79
|
+
Small, focused PRs are usually merged quickly.
|
|
80
|
+
Larger changes might be reviewed in stages — feel free to open a draft PR early to discuss.
|
|
87
81
|
|
|
88
82
|
### Good First Issues
|
|
89
83
|
|
|
90
|
-
Looking for an easy entry point? These are beginner-friendly:
|
|
84
|
+
Looking for an easy entry point? These tasks are beginner-friendly:
|
|
91
85
|
|
|
92
|
-
-
|
|
93
|
-
- Add case
|
|
86
|
+
- Improve/fix documentation or README examples
|
|
87
|
+
- Add case normalization (lowercase) to dictionary building
|
|
94
88
|
- Create a smaller curated dictionary (e.g. top 10k–50k English words)
|
|
95
89
|
- Add more helpful messages or progress indicators to the CLI
|
|
96
|
-
- Write tests for edge cases (empty strings, very long phrases,
|
|
97
|
-
-
|
|
98
|
-
|
|
99
|
-
Look for issues labelled **[good first issue]** on GitHub.
|
|
90
|
+
- Write tests for edge cases (empty strings, very long phrases, invalid base64)
|
|
91
|
+
- Create a simple browser demo (CodeSandbox, StackBlitz, or static HTML)
|
|
100
92
|
|
|
101
|
-
|
|
93
|
+
Look for issues labeled **[good first issue]** on GitHub.
|
|
102
94
|
|
|
103
95
|
## Development Setup
|
|
104
96
|
|
|
105
|
-
**Prerequisites:** Node.js ≥ 18, npm ≥ 9
|
|
106
|
-
|
|
107
97
|
```bash
|
|
108
|
-
# 1. Fork
|
|
98
|
+
# 1. Fork & clone the repo
|
|
109
99
|
git clone https://github.com/bigdreamsweb3/wordbin.git
|
|
110
100
|
cd wordbin
|
|
111
101
|
|
|
@@ -115,130 +105,51 @@ npm install
|
|
|
115
105
|
# 3. Build the library
|
|
116
106
|
npm run build
|
|
117
107
|
|
|
118
|
-
# 4. Run
|
|
108
|
+
# 4. Run tests
|
|
119
109
|
npm test
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
---
|
|
110
|
+
# or watch mode:
|
|
111
|
+
npm run vitest
|
|
123
112
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
wordbin
|
|
128
|
-
├── src/
|
|
129
|
-
│ ├── core/
|
|
130
|
-
│ │ └── wordbin.ts # WordBin class — encode(), decode(), format detection
|
|
131
|
-
│ ├── dict/
|
|
132
|
-
│ │ ├── dictionary-loader.ts # loadLatestDictionary, loadDictionaryByVersion
|
|
133
|
-
│ │ ├── builder.ts # buildDictionary() — constructs dict from a wordlist
|
|
134
|
-
│ │ └── data/ # Bundled v1 (BIP-39) dictionary JSON
|
|
135
|
-
│ ├── utils/
|
|
136
|
-
│ │ └── buffer.ts # toHex, toBase64, encodeVarint, decodeVarint, utf8*
|
|
137
|
-
│ └── constants.ts # LITERAL token value and other shared constants
|
|
138
|
-
├── test/
|
|
139
|
-
│ └── test.spec.ts # Vitest suites — encode, decode, round-trip, non-WordBin
|
|
140
|
-
├── data/ # Built dictionary files — generated, gitignored
|
|
141
|
-
└── dist/ # Compiled output — generated on build, not committed
|
|
113
|
+
# 5. Build dictionaries (optional)
|
|
114
|
+
npx wordbin build --version 2
|
|
115
|
+
# or interactive mode:
|
|
116
|
+
npx wordbin build
|
|
142
117
|
```
|
|
143
118
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
## Running Tests
|
|
147
|
-
|
|
148
|
-
The test suite is organised into four independently-controllable suites.
|
|
149
|
-
|
|
150
|
-
```bash
|
|
151
|
-
npm test # run everything once
|
|
152
|
-
npm run test:watch # watch mode — re-runs on save
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Run a single suite via CLI
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
npx vitest -t "Encode only"
|
|
159
|
-
npx vitest -t "Decode only"
|
|
160
|
-
npx vitest -t "Encode then decode"
|
|
161
|
-
npx vitest -t "Non-WordBin decode"
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Toggle suites without touching the CLI
|
|
165
|
-
|
|
166
|
-
At the top of `test/test.spec.ts`:
|
|
167
|
-
|
|
168
|
-
```ts
|
|
169
|
-
const RUN = {
|
|
170
|
-
ENCODE_ONLY: true, // encode text → verify all payload representations
|
|
171
|
-
DECODE_ONLY: true, // decode a pre-built payload → verify result
|
|
172
|
-
ENCODE_THEN_DECODE: true, // full round-trip across all 5 formats
|
|
173
|
-
NON_WORDBIN_DECODE: true, // arbitrary payloads → graceful fallback behaviour
|
|
174
|
-
};
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
Set any flag to `false` to skip that suite entirely. Skipped suites are reported as skipped — they are never silently removed.
|
|
178
|
-
|
|
179
|
-
### What each suite covers
|
|
180
|
-
|
|
181
|
-
| Suite | What it tests |
|
|
182
|
-
| ---------------------- | -------------------------------------------------------------------------------------------- |
|
|
183
|
-
| **Encode only** | All payload formats (hex, base58, base64, bin21), compression ratio, format validity |
|
|
184
|
-
| **Decode only** | Known hex payload, known base64 payload, non-WordBin fallback |
|
|
185
|
-
| **Encode then decode** | Full round-trip for hex, base58, base64, bin21, and raw `Uint8Array` |
|
|
186
|
-
| **Non-WordBin decode** | 4 foreign payloads — verifies `isWordBin: false`, `notice` is set, `text` is always a string |
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## Where Things Live
|
|
191
|
-
|
|
192
|
-
| What you want to change | File |
|
|
193
|
-
| -------------------------------------------------------- | ------------------------------------ |
|
|
194
|
-
| Encode / decode logic | `src/core/wordbin.ts` |
|
|
195
|
-
| Payload format detection (hex / base58 / base64 / bin21) | `detectAndConvert()` in `wordbin.ts` |
|
|
196
|
-
| `DecodeResult` type or `PayloadFormat` union | top of `wordbin.ts` |
|
|
197
|
-
| Partial scan / best-effort fallback | `partialScan()` in `wordbin.ts` |
|
|
198
|
-
| Dictionary loading and versioning | `src/dict/dictionary-loader.ts` |
|
|
199
|
-
| Building a dictionary from a wordlist | `src/dict/builder.ts` |
|
|
200
|
-
| Buffer utilities (varint, hex, utf8) | `src/utils/buffer.ts` |
|
|
201
|
-
| Shared constants (LITERAL byte value) | `src/constants.ts` |
|
|
202
|
-
| Tests | `test/test.spec.ts` |
|
|
203
|
-
|
|
204
|
-
---
|
|
119
|
+
Main source code lives in `src/`.
|
|
120
|
+
Generated dictionaries appear in `data/`.
|
|
205
121
|
|
|
206
122
|
## Current Priorities (2026)
|
|
207
123
|
|
|
208
124
|
These improvements would have the biggest impact right now:
|
|
209
125
|
|
|
210
|
-
-
|
|
211
|
-
-
|
|
212
|
-
-
|
|
213
|
-
-
|
|
214
|
-
-
|
|
215
|
-
-
|
|
216
|
-
- **Error messages** — clearer messages when a dictionary is missing, input is invalid, or a version mismatch is detected
|
|
126
|
+
- Case-insensitive dictionaries (normalize to lowercase during build)
|
|
127
|
+
- Smaller curated dictionaries (top 10k–50k words, programming keywords, domain-specific lists…)
|
|
128
|
+
- Performance & compression benchmarks across dictionaries and phrase lengths
|
|
129
|
+
- Interactive browser demo (CodeSandbox / StackBlitz / simple HTML page)
|
|
130
|
+
- CLI enhancements (progress bars, `--lowercase`, `--output-dir`, better help)
|
|
131
|
+
- Better error handling & messages (missing dictionary, invalid input, etc.)
|
|
217
132
|
|
|
218
|
-
If you're unsure where to begin
|
|
219
|
-
|
|
220
|
-
---
|
|
133
|
+
If you're unsure where to begin — feel free to ask in an issue or draft PR!
|
|
221
134
|
|
|
222
135
|
## Code Style & Conventions
|
|
223
136
|
|
|
224
|
-
-
|
|
225
|
-
-
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
-
|
|
229
|
-
-
|
|
137
|
+
- ESM syntax (`import` / `export`)
|
|
138
|
+
- TypeScript where possible
|
|
139
|
+
- Vitest for testing
|
|
140
|
+
- Prefer async/await
|
|
141
|
+
- Small, focused functions
|
|
142
|
+
- JSDoc comments for public APIs
|
|
230
143
|
|
|
231
|
-
|
|
144
|
+
We use **Prettier** + **ESLint** — run these before committing:
|
|
232
145
|
|
|
233
146
|
```bash
|
|
234
147
|
npm run lint
|
|
235
148
|
npm run format
|
|
236
149
|
```
|
|
237
150
|
|
|
238
|
-
---
|
|
239
|
-
|
|
240
151
|
## License
|
|
241
152
|
|
|
242
|
-
By contributing code to this project, you agree that
|
|
153
|
+
By contributing your code to this project, you agree that it will be licensed under the same [MIT License](./LICENSE) as the rest of the project.
|
|
243
154
|
|
|
244
|
-
Thank you for helping make WordBin better
|
|
155
|
+
Thank you for helping make WordBin better!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigdreamsweb3/wordbin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "WordBin – Encode words & short text into tiny, reversible binary for storage, URLs, IoT, QR codes, metadata, blockchain, or Web3 apps.",
|
|
5
5
|
"author": "Agbaka Daniel Ugonna <99cratson@gmail.com>",
|
|
6
6
|
"license": "MIT",
|