@bigdreamsweb3/wordbin 1.0.6 → 1.0.8

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.
@@ -0,0 +1,58 @@
1
+ import { EncodeResult, WordBinDictionary } from '../types.js';
2
+ type PayloadFormat = "bytes" | "base58" | "base64" | "hex" | "bin21";
3
+ export interface DecodeResult {
4
+ /** The decoded text — words for WordBin payloads, best-effort for others. */
5
+ text: string;
6
+ /** True only when the payload was a valid, fully-parsed WordBin stream. */
7
+ isWordBin: boolean;
8
+ /** Auto-detected wire format of the input. */
9
+ detectedFormat: PayloadFormat;
10
+ /**
11
+ * Human-readable notice when the payload is not a valid WordBin stream.
12
+ * Includes information about what the decoder did as a fallback.
13
+ */
14
+ notice?: string;
15
+ /**
16
+ * Present when partial scanning was used (non-WordBin payloads).
17
+ * Lists raw byte sequences that had no dictionary match, in order.
18
+ */
19
+ rawSegments?: string[];
20
+ }
21
+ export declare class WordBin {
22
+ private primaryDictVersion;
23
+ private log;
24
+ constructor(initialDict?: WordBinDictionary, options?: {
25
+ debug?: boolean;
26
+ });
27
+ static createFromWords(words: string[]): Promise<WordBin>;
28
+ static createFromJson(dictJson: WordBinDictionary): Promise<WordBin>;
29
+ static create(options?: {
30
+ debug?: boolean;
31
+ }): Promise<WordBin>;
32
+ private getMapsForVersion;
33
+ encode(text: string | EncodeResult | Uint8Array, options?: {
34
+ dictVersion?: number;
35
+ }): Promise<EncodeResult>;
36
+ /**
37
+ * Decodes any supported payload format back to human-readable text.
38
+ *
39
+ * For valid WordBin payloads: returns the exact original words.
40
+ * For non-WordBin payloads: scans byte-by-byte, extracts dictionary words
41
+ * wherever possible, and preserves unrecognised
42
+ * bytes as "[0xXX]" markers.
43
+ */
44
+ decode(payload: Uint8Array | string): Promise<DecodeResult>;
45
+ /**
46
+ * O(n) longest-match-first decode. Returns null if any byte has no match.
47
+ * This is the fast path; tryDecode is used as a backtracking fallback.
48
+ */
49
+ private greedyDecode;
50
+ /**
51
+ * Scans through the buffer extracting any recognised dictionary words.
52
+ * Unrecognised bytes are collected as raw segments and rendered as [0xXX].
53
+ * Always consumes the entire buffer — never returns null.
54
+ */
55
+ private partialScan;
56
+ private tryDecode;
57
+ }
58
+ export {};
@@ -446,15 +446,15 @@
446
446
  "988180": [
447
447
  "offer"
448
448
  ],
449
- "b0ad": [
450
- "able"
451
- ],
452
449
  "df864c": [
453
450
  "abandon"
454
451
  ],
455
452
  "bcffaa": [
456
453
  "ability"
457
454
  ],
455
+ "b0ad": [
456
+ "able"
457
+ ],
458
458
  "a4262e": [
459
459
  "about"
460
460
  ],
@@ -1647,8 +1647,7 @@
1647
1647
  "crush"
1648
1648
  ],
1649
1649
  "58a6": [
1650
- "cry",
1651
- "math"
1650
+ "cry"
1652
1651
  ],
1653
1652
  "60a0f7": [
1654
1653
  "crystal"
@@ -2574,24 +2573,24 @@
2574
2573
  "5a5770": [
2575
2574
  "furnace"
2576
2575
  ],
2577
- "f44a": [
2578
- "fury"
2579
- ],
2580
2576
  "ebb3de": [
2581
2577
  "future"
2582
2578
  ],
2579
+ "f44a": [
2580
+ "fury"
2581
+ ],
2583
2582
  "4e5aa6": [
2584
2583
  "gadget"
2585
2584
  ],
2586
2585
  "66dd": [
2587
2586
  "gain"
2588
2587
  ],
2589
- "eba4ae": [
2590
- "galaxy"
2591
- ],
2592
2588
  "ce387d": [
2593
2589
  "gallery"
2594
2590
  ],
2591
+ "eba4ae": [
2592
+ "galaxy"
2593
+ ],
2595
2594
  "6ca5": [
2596
2595
  "game"
2597
2596
  ],
@@ -6143,6 +6142,9 @@
6143
6142
  ],
6144
6143
  "24fe": [
6145
6144
  "zoo"
6145
+ ],
6146
+ "ad06fa": [
6147
+ "math"
6146
6148
  ]
6147
6149
  }
6148
6150
  }
@@ -1,4 +1,4 @@
1
- import { WordBinDictionary } from './types';
1
+ import { WordBinDictionary } from '../types';
2
2
  export interface BuildDictionaryOptions {
3
3
  /**
4
4
  * Dictionary version number (used in header and for format compatibility)
@@ -1,4 +1,4 @@
1
- import { WordBinDictionary } from './types.js';
1
+ import { WordBinDictionary } from '../types.js';
2
2
  /**
3
3
  * Scan all available dictionary versions from all data dirs
4
4
  */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { MAGIC } from './constants.js';
2
- export { buildDictionary } from './dictionary';
3
- export { WordBin } from './core.js';
1
+ export { MAGIC } from './constants';
2
+ export { buildDictionary } from './dict/builder';
3
+ export { WordBin } from './core/index';
4
4
  export type { EncodeResult, WordBinDictionary } from './types';