text-compress 2.0.0 → 2.0.3
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/README.md +33 -1
- package/dist/cli/output.d.ts +1 -7
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +1 -20
- package/dist/cli/output.js.map +1 -1
- package/dist/cli/usage.d.ts.map +1 -1
- package/dist/cli/usage.js +3 -2
- package/dist/cli/usage.js.map +1 -1
- package/dist/cli.js +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/split/parts.d.ts +35 -9
- package/dist/split/parts.d.ts.map +1 -1
- package/dist/split/parts.js +162 -26
- package/dist/split/parts.js.map +1 -1
- package/dist/streaming/folder.d.ts.map +1 -1
- package/dist/streaming/folder.js +10 -62
- package/dist/streaming/folder.js.map +1 -1
- package/package.json +21 -11
- package/skills/text-compress/cli/SKILL.md +180 -0
- package/skills/text-compress/core/SKILL.md +63 -0
- package/skills/text-compress/library/SKILL.md +180 -0
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ Brotli-compress text or entire folder trees into pasteable base64 or Z85 strings
|
|
|
14
14
|
- **Password protection** — AES-256-GCM (`-p` / `--password`)
|
|
15
15
|
- **v2 split parts** — self-describing parts; shuffled names, merged files, any sibling as entry
|
|
16
16
|
- **CLI + library** — terminal or `import from "text-compress"`
|
|
17
|
+
- **Agent skills** — versioned [TanStack Intent](https://tanstack.com/intent/latest/docs/overview) skills ship with the package for AI coding agents
|
|
17
18
|
|
|
18
19
|
## Install
|
|
19
20
|
|
|
@@ -21,6 +22,9 @@ Brotli-compress text or entire folder trees into pasteable base64 or Z85 strings
|
|
|
21
22
|
npm install -g text-compress
|
|
22
23
|
```
|
|
23
24
|
|
|
25
|
+
If you use an AI coding agent, run `npx @tanstack/intent@latest install` in your
|
|
26
|
+
project to load versioned skills shipped with this package.
|
|
27
|
+
|
|
24
28
|
Or run without installing:
|
|
25
29
|
|
|
26
30
|
```bash
|
|
@@ -135,7 +139,7 @@ Password-protected payloads error without `-p` (they are **not** silently re-com
|
|
|
135
139
|
|
|
136
140
|
## v2 split output
|
|
137
141
|
|
|
138
|
-
Large outputs split into numbered files (`output.1.txt`, `output.02.txt`, …). Each part embeds order in a `
|
|
142
|
+
Large outputs split into numbered files (`output.1.txt`, `output.02.txt`, …). Each part embeds order in a printable ASCII header (`;TCP2;<part>;<total>;`). The `-s` limit applies to the **entire part file** (header + payload), not just the encoded content.
|
|
139
143
|
|
|
140
144
|
On decompress:
|
|
141
145
|
|
|
@@ -164,10 +168,38 @@ npm run build
|
|
|
164
168
|
npm run check
|
|
165
169
|
```
|
|
166
170
|
|
|
171
|
+
Git hooks (via [Husky](https://typicode.github.io/husky/)) run automatically after `bun install`:
|
|
172
|
+
|
|
173
|
+
- **pre-commit** — `lint` + `typecheck`
|
|
174
|
+
- **pre-push** — `check:ci` + `test`
|
|
175
|
+
|
|
176
|
+
### Publish
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npm login
|
|
180
|
+
npm publish --access public
|
|
181
|
+
```
|
|
182
|
+
|
|
167
183
|
See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) and [docs/LEARNING.md](docs/LEARNING.md).
|
|
168
184
|
|
|
169
185
|
## Changelog
|
|
170
186
|
|
|
187
|
+
### v2.0.3 — `text-compress` (2026-07-09)
|
|
188
|
+
|
|
189
|
+
- Use printable ASCII `;TCP2;` split headers so part files stay copyable in text editors (legacy binary `TCP\x02` headers still accepted on read)
|
|
190
|
+
- Apply `-s` / auto-split limits to the full part file size, including the header
|
|
191
|
+
- Add Husky git hooks (`pre-commit`: lint + typecheck, `pre-push`: check + test)
|
|
192
|
+
|
|
193
|
+
### v2.0.2 — `text-compress` (2026-07-09)
|
|
194
|
+
|
|
195
|
+
- Ship [TanStack Intent](https://tanstack.com/intent/latest/docs/overview) agent skills (`core`, `cli`, `library`) inside the npm package
|
|
196
|
+
- Add `check-skills` CI workflow and `npm run validate:skills`
|
|
197
|
+
|
|
198
|
+
### v2.0.1 — `text-compress` (2026-07-08)
|
|
199
|
+
|
|
200
|
+
- Republish as **`text-compress@2.0.1`** (npm name finalized after `txtc` rejection)
|
|
201
|
+
- Normalized `bin` path for npm publish
|
|
202
|
+
|
|
171
203
|
### v2.0.0 — `text-compress` (2026-07-08)
|
|
172
204
|
|
|
173
205
|
- New npm package **`text-compress`** (v1 remains `@startdoing/tc@1.0.4`)
|
package/dist/cli/output.d.ts
CHANGED
|
@@ -3,11 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Write compressed output to disk, optionally split into numbered parts.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
* Write an encoded string to one file or multiple split part files.
|
|
8
|
-
*/
|
|
9
|
-
export declare function writeCompressedOutput(encoded: string, outputPath: string, explicitSplit?: number): {
|
|
10
|
-
paths: string[];
|
|
11
|
-
splitChunkSize?: number;
|
|
12
|
-
};
|
|
6
|
+
export { writeEncodedOutput as writeCompressedOutput } from "../split/parts.js";
|
|
13
7
|
//# sourceMappingURL=output.d.ts.map
|
package/dist/cli/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/cli/output.js
CHANGED
|
@@ -3,24 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Write compressed output to disk, optionally split into numbered parts.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
import { formatSplitOutputPath, resolveSplitChunkSize, splitString, wrapSplitChunk, } from "../split/parts.js";
|
|
8
|
-
/**
|
|
9
|
-
* Write an encoded string to one file or multiple split part files.
|
|
10
|
-
*/
|
|
11
|
-
export function writeCompressedOutput(encoded, outputPath, explicitSplit) {
|
|
12
|
-
const splitChunkSize = resolveSplitChunkSize(encoded.length, explicitSplit);
|
|
13
|
-
if (splitChunkSize === undefined) {
|
|
14
|
-
writeFileSync(outputPath, encoded, "utf-8");
|
|
15
|
-
return { paths: [outputPath] };
|
|
16
|
-
}
|
|
17
|
-
const chunks = splitString(encoded, splitChunkSize);
|
|
18
|
-
const totalParts = chunks.length;
|
|
19
|
-
const paths = chunks.map((chunk, index) => {
|
|
20
|
-
const partPath = formatSplitOutputPath(outputPath, index + 1, totalParts);
|
|
21
|
-
writeFileSync(partPath, wrapSplitChunk(index + 1, totalParts, chunk), "utf-8");
|
|
22
|
-
return partPath;
|
|
23
|
-
});
|
|
24
|
-
return { paths, splitChunkSize };
|
|
25
|
-
}
|
|
6
|
+
export { writeEncodedOutput as writeCompressedOutput } from "../split/parts.js";
|
|
26
7
|
//# sourceMappingURL=output.js.map
|
package/dist/cli/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/cli/usage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mCAAmC;AACnC,wBAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mCAAmC;AACnC,wBAAgB,UAAU,SAkEzB"}
|
package/dist/cli/usage.js
CHANGED
|
@@ -25,8 +25,9 @@ Options:
|
|
|
25
25
|
-C, --compress Always compress (even if input looks compressed)
|
|
26
26
|
-D, --decompress Always decompress
|
|
27
27
|
-o, --output <path> Output path (optional, see defaults below)
|
|
28
|
-
-s, --split <chars> Split compressed output into multiple files
|
|
29
|
-
at most this many characters
|
|
28
|
+
-s, --split <chars> Split compressed output into multiple files. Each
|
|
29
|
+
part file is at most this many characters total,
|
|
30
|
+
including the ;TCP2; header (compress only).
|
|
30
31
|
If omitted, auto-splits at 30,000 characters when
|
|
31
32
|
the output is larger. Parts are named by inserting
|
|
32
33
|
.NNN before the extension, e.g. output.001.txt
|
package/dist/cli/usage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mCAAmC;AACnC,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,GAAG,CAAC
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mCAAmC;AACnC,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgEb,CAAC,CAAA;AACF,CAAC"}
|
package/dist/cli.js
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export { unpackDirectory } from "./archive/unpack.js";
|
|
|
16
16
|
export { assertDirectory, readTextFile } from "./fs/paths.js";
|
|
17
17
|
export { decompressPayload, TAG_FOLDER, TAG_TEXT } from "./payload/tags.js";
|
|
18
18
|
export type { SplitChunk } from "./split/parts.js";
|
|
19
|
-
export { AUTO_SPLIT_CHARS, assembleSplitChunks, createSplitChunkHeader, extractFilenamePrefix, formatSplitOutputPath, parseSplitBuffer, parseSplitPartPath, readSplitInput, resolveSplitChunkSize, resolveSplitInputPaths, SPLIT_MAGIC, splitString, tryParseSplitChunks, wrapSplitChunk, } from "./split/parts.js";
|
|
19
|
+
export { AUTO_SPLIT_CHARS, assembleSplitChunks, createSplitChunkHeader, extractFilenamePrefix, formatSplitOutputPath, parseSplitBuffer, parseSplitPartPath, readSplitInput, resolveSplitChunkSize, resolveSplitInputPaths, resolveSplitPartCount, SPLIT_MAGIC, splitEncodedIntoWrappedParts, splitString, tryParseSplitChunks, wrapSplitChunk, writeEncodedOutput, } from "./split/parts.js";
|
|
20
20
|
export type { Encoding } from "./types.js";
|
|
21
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGlE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE7D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3E,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGlE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE7D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3E,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,WAAW,EACX,4BAA4B,EAC5B,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,kBAAkB,GACnB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -21,5 +21,5 @@ export { assertDirectory, readTextFile } from "./fs/paths.js";
|
|
|
21
21
|
// Low-level payload access
|
|
22
22
|
export { decompressPayload, TAG_FOLDER, TAG_TEXT } from "./payload/tags.js";
|
|
23
23
|
// Split-file helpers
|
|
24
|
-
export { AUTO_SPLIT_CHARS, assembleSplitChunks, createSplitChunkHeader, extractFilenamePrefix, formatSplitOutputPath, parseSplitBuffer, parseSplitPartPath, readSplitInput, resolveSplitChunkSize, resolveSplitInputPaths, SPLIT_MAGIC, splitString, tryParseSplitChunks, wrapSplitChunk, } from "./split/parts.js";
|
|
24
|
+
export { AUTO_SPLIT_CHARS, assembleSplitChunks, createSplitChunkHeader, extractFilenamePrefix, formatSplitOutputPath, parseSplitBuffer, parseSplitPartPath, readSplitInput, resolveSplitChunkSize, resolveSplitInputPaths, resolveSplitPartCount, SPLIT_MAGIC, splitEncodedIntoWrappedParts, splitString, tryParseSplitChunks, wrapSplitChunk, writeEncodedOutput, } from "./split/parts.js";
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElE,WAAW;AACX,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACpD,oDAAoD;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,0BAA0B;AAC1B,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC7D,2BAA2B;AAC3B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3E,qBAAqB;AACrB,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElE,WAAW;AACX,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACpD,oDAAoD;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,0BAA0B;AAC1B,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC7D,2BAA2B;AAC3B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3E,qBAAqB;AACrB,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,WAAW,EACX,4BAA4B,EAC5B,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,kBAAkB,GACnB,MAAM,kBAAkB,CAAA"}
|
package/dist/split/parts.d.ts
CHANGED
|
@@ -9,13 +9,17 @@
|
|
|
9
9
|
*
|
|
10
10
|
* ## v2 split format
|
|
11
11
|
*
|
|
12
|
-
* Each logical part is prefixed with a
|
|
13
|
-
* file content, not filenames
|
|
12
|
+
* Each logical part is prefixed with a short ASCII header so order is encoded
|
|
13
|
+
* in file content, not filenames. The header uses only printable text (no NUL
|
|
14
|
+
* or control bytes) so split files stay pasteable and open in any text editor:
|
|
14
15
|
*
|
|
15
16
|
* ```
|
|
16
|
-
*
|
|
17
|
+
* ;TCP2;<partIndex>;<totalParts>;<payload…>
|
|
17
18
|
* ```
|
|
18
19
|
*
|
|
20
|
+
* Legacy v2.0.x files used a 12-byte binary header (`TCP\x02` + u32le fields);
|
|
21
|
+
* those are still accepted on read.
|
|
22
|
+
*
|
|
19
23
|
* Every part carries `totalParts`, so any single valid part reveals how many
|
|
20
24
|
* logical parts exist. A physical file may contain one or more consecutive
|
|
21
25
|
* parts. Parts can be read in any file order, and adjacent part files can be
|
|
@@ -41,12 +45,13 @@
|
|
|
41
45
|
* ## Auto-split threshold
|
|
42
46
|
*
|
|
43
47
|
* When no explicit `-s` size is given, outputs longer than
|
|
44
|
-
* {@link AUTO_SPLIT_CHARS} are automatically split.
|
|
48
|
+
* {@link AUTO_SPLIT_CHARS} are automatically split. Split limits count the
|
|
49
|
+
* entire part file, including the `;TCP2;` header — not just the payload.
|
|
45
50
|
*/
|
|
46
51
|
/** Default character threshold for automatic output splitting. */
|
|
47
52
|
export declare const AUTO_SPLIT_CHARS = 30000;
|
|
48
|
-
/**
|
|
49
|
-
export declare const SPLIT_MAGIC
|
|
53
|
+
/** ASCII prefix identifying a v2 split chunk header. */
|
|
54
|
+
export declare const SPLIT_MAGIC = ";TCP2;";
|
|
50
55
|
/** One parsed logical part from split file content. */
|
|
51
56
|
export interface SplitChunk {
|
|
52
57
|
partIndex: number;
|
|
@@ -58,17 +63,38 @@ export interface SplitChunk {
|
|
|
58
63
|
*
|
|
59
64
|
* @param encodedLength - Total characters in the encoded string.
|
|
60
65
|
* @param explicitSplit - User-provided `-s` value, if any.
|
|
61
|
-
* @returns
|
|
66
|
+
* @returns Max characters per part file (header + payload), or `undefined` when no split is needed.
|
|
62
67
|
*/
|
|
63
68
|
export declare function resolveSplitChunkSize(encodedLength: number, explicitSplit?: number): number | undefined;
|
|
69
|
+
/** Character length of the split header for one part. */
|
|
70
|
+
export declare function splitHeaderLength(partIndex: number, totalParts: number): number;
|
|
71
|
+
/** Smallest allowed `-s` value (header-only part for a single-part output). */
|
|
72
|
+
export declare function minSplitPartChars(): number;
|
|
73
|
+
/**
|
|
74
|
+
* Resolve how many part files are needed when each file is at most `maxPartChars`.
|
|
75
|
+
*
|
|
76
|
+
* Iterates until the guessed `totalParts` matches the count implied by header sizes.
|
|
77
|
+
*/
|
|
78
|
+
export declare function resolveSplitPartCount(encodedLength: number, maxPartChars: number): number;
|
|
79
|
+
/**
|
|
80
|
+
* Split encoded text into wrapped part strings, each at most `maxPartChars` long.
|
|
81
|
+
*/
|
|
82
|
+
export declare function splitEncodedIntoWrappedParts(encoded: string, maxPartChars: number): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Write encoded text to one file or numbered split part files.
|
|
85
|
+
*/
|
|
86
|
+
export declare function writeEncodedOutput(encoded: string, outputPath: string, explicitSplit?: number): {
|
|
87
|
+
paths: string[];
|
|
88
|
+
splitChunkSize?: number;
|
|
89
|
+
};
|
|
64
90
|
/**
|
|
65
91
|
* Split a string into fixed-size chunks (last chunk may be shorter).
|
|
66
92
|
*
|
|
67
93
|
* @throws If `chunkSize` is not a positive integer.
|
|
68
94
|
*/
|
|
69
95
|
export declare function splitString(value: string, chunkSize: number): string[];
|
|
70
|
-
/** Build the
|
|
71
|
-
export declare function createSplitChunkHeader(partIndex: number, totalParts: number):
|
|
96
|
+
/** Build the ASCII v2 split chunk header. */
|
|
97
|
+
export declare function createSplitChunkHeader(partIndex: number, totalParts: number): string;
|
|
72
98
|
/**
|
|
73
99
|
* Wrap one encoded payload chunk with a v2 split header.
|
|
74
100
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/split/parts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/split/parts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAKH,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,QAAS,CAAA;AAEtC,wDAAwD;AACxD,eAAO,MAAM,WAAW,WAAW,CAAA;AAOnC,uDAAuD;AACvD,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,GAAG,SAAS,CAIpB;AAED,yDAAyD;AACzD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE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AAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAEvE;AAkBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBlE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG;IACjD,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CAoBA"}
|
package/dist/split/parts.js
CHANGED
|
@@ -9,13 +9,17 @@
|
|
|
9
9
|
*
|
|
10
10
|
* ## v2 split format
|
|
11
11
|
*
|
|
12
|
-
* Each logical part is prefixed with a
|
|
13
|
-
* file content, not filenames
|
|
12
|
+
* Each logical part is prefixed with a short ASCII header so order is encoded
|
|
13
|
+
* in file content, not filenames. The header uses only printable text (no NUL
|
|
14
|
+
* or control bytes) so split files stay pasteable and open in any text editor:
|
|
14
15
|
*
|
|
15
16
|
* ```
|
|
16
|
-
*
|
|
17
|
+
* ;TCP2;<partIndex>;<totalParts>;<payload…>
|
|
17
18
|
* ```
|
|
18
19
|
*
|
|
20
|
+
* Legacy v2.0.x files used a 12-byte binary header (`TCP\x02` + u32le fields);
|
|
21
|
+
* those are still accepted on read.
|
|
22
|
+
*
|
|
19
23
|
* Every part carries `totalParts`, so any single valid part reveals how many
|
|
20
24
|
* logical parts exist. A physical file may contain one or more consecutive
|
|
21
25
|
* parts. Parts can be read in any file order, and adjacent part files can be
|
|
@@ -41,21 +45,24 @@
|
|
|
41
45
|
* ## Auto-split threshold
|
|
42
46
|
*
|
|
43
47
|
* When no explicit `-s` size is given, outputs longer than
|
|
44
|
-
* {@link AUTO_SPLIT_CHARS} are automatically split.
|
|
48
|
+
* {@link AUTO_SPLIT_CHARS} are automatically split. Split limits count the
|
|
49
|
+
* entire part file, including the `;TCP2;` header — not just the payload.
|
|
45
50
|
*/
|
|
46
|
-
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
51
|
+
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
47
52
|
import { dirname, join } from "node:path";
|
|
48
53
|
/** Default character threshold for automatic output splitting. */
|
|
49
54
|
export const AUTO_SPLIT_CHARS = 30_000;
|
|
50
|
-
/**
|
|
51
|
-
export const SPLIT_MAGIC =
|
|
52
|
-
|
|
55
|
+
/** ASCII prefix identifying a v2 split chunk header. */
|
|
56
|
+
export const SPLIT_MAGIC = ";TCP2;";
|
|
57
|
+
/** Legacy binary magic from v2.0.x (still accepted on read). */
|
|
58
|
+
const LEGACY_SPLIT_MAGIC = Buffer.from([0x54, 0x43, 0x50, 0x02]);
|
|
59
|
+
const LEGACY_SPLIT_HEADER_SIZE = 12;
|
|
53
60
|
/**
|
|
54
61
|
* Decide whether and how to split encoded output.
|
|
55
62
|
*
|
|
56
63
|
* @param encodedLength - Total characters in the encoded string.
|
|
57
64
|
* @param explicitSplit - User-provided `-s` value, if any.
|
|
58
|
-
* @returns
|
|
65
|
+
* @returns Max characters per part file (header + payload), or `undefined` when no split is needed.
|
|
59
66
|
*/
|
|
60
67
|
export function resolveSplitChunkSize(encodedLength, explicitSplit) {
|
|
61
68
|
if (explicitSplit !== undefined)
|
|
@@ -64,6 +71,91 @@ export function resolveSplitChunkSize(encodedLength, explicitSplit) {
|
|
|
64
71
|
return AUTO_SPLIT_CHARS;
|
|
65
72
|
return undefined;
|
|
66
73
|
}
|
|
74
|
+
/** Character length of the split header for one part. */
|
|
75
|
+
export function splitHeaderLength(partIndex, totalParts) {
|
|
76
|
+
return createSplitChunkHeader(partIndex, totalParts).length;
|
|
77
|
+
}
|
|
78
|
+
/** Smallest allowed `-s` value (header-only part for a single-part output). */
|
|
79
|
+
export function minSplitPartChars() {
|
|
80
|
+
return splitHeaderLength(1, 1);
|
|
81
|
+
}
|
|
82
|
+
function assertSplitPartChars(maxPartChars) {
|
|
83
|
+
const min = minSplitPartChars();
|
|
84
|
+
if (!Number.isInteger(maxPartChars) || maxPartChars < min) {
|
|
85
|
+
throw new Error(`Split size must be at least ${min} characters (to fit split headers).`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function countSplitParts(encodedLength, maxPartChars, totalPartsGuess) {
|
|
89
|
+
if (encodedLength === 0)
|
|
90
|
+
return 1;
|
|
91
|
+
let offset = 0;
|
|
92
|
+
let partIndex = 0;
|
|
93
|
+
while (offset < encodedLength) {
|
|
94
|
+
partIndex++;
|
|
95
|
+
const payloadCap = maxPartChars - splitHeaderLength(partIndex, totalPartsGuess);
|
|
96
|
+
if (payloadCap < 1) {
|
|
97
|
+
throw new Error(`Split size ${maxPartChars} is too small for ${totalPartsGuess} parts (header alone is ${splitHeaderLength(partIndex, totalPartsGuess)} characters).`);
|
|
98
|
+
}
|
|
99
|
+
offset += Math.min(payloadCap, encodedLength - offset);
|
|
100
|
+
}
|
|
101
|
+
return partIndex;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Resolve how many part files are needed when each file is at most `maxPartChars`.
|
|
105
|
+
*
|
|
106
|
+
* Iterates until the guessed `totalParts` matches the count implied by header sizes.
|
|
107
|
+
*/
|
|
108
|
+
export function resolveSplitPartCount(encodedLength, maxPartChars) {
|
|
109
|
+
assertSplitPartChars(maxPartChars);
|
|
110
|
+
if (encodedLength === 0)
|
|
111
|
+
return 1;
|
|
112
|
+
let totalParts = 1;
|
|
113
|
+
for (let i = 0; i < 20; i++) {
|
|
114
|
+
const next = countSplitParts(encodedLength, maxPartChars, totalParts);
|
|
115
|
+
if (next === totalParts)
|
|
116
|
+
return totalParts;
|
|
117
|
+
totalParts = next;
|
|
118
|
+
}
|
|
119
|
+
return totalParts;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Split encoded text into wrapped part strings, each at most `maxPartChars` long.
|
|
123
|
+
*/
|
|
124
|
+
export function splitEncodedIntoWrappedParts(encoded, maxPartChars) {
|
|
125
|
+
assertSplitPartChars(maxPartChars);
|
|
126
|
+
const totalParts = resolveSplitPartCount(encoded.length, maxPartChars);
|
|
127
|
+
const parts = [];
|
|
128
|
+
let offset = 0;
|
|
129
|
+
for (let partIndex = 1; partIndex <= totalParts; partIndex++) {
|
|
130
|
+
const payloadCap = maxPartChars - splitHeaderLength(partIndex, totalParts);
|
|
131
|
+
const payload = encoded.slice(offset, offset + payloadCap);
|
|
132
|
+
const wrapped = wrapSplitChunk(partIndex, totalParts, payload);
|
|
133
|
+
if (wrapped.length > maxPartChars) {
|
|
134
|
+
throw new Error(`Split part ${partIndex} is ${wrapped.length} characters, exceeding limit ${maxPartChars}.`);
|
|
135
|
+
}
|
|
136
|
+
parts.push(wrapped);
|
|
137
|
+
offset += payload.length;
|
|
138
|
+
}
|
|
139
|
+
return parts;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Write encoded text to one file or numbered split part files.
|
|
143
|
+
*/
|
|
144
|
+
export function writeEncodedOutput(encoded, outputPath, explicitSplit) {
|
|
145
|
+
const maxPartChars = resolveSplitChunkSize(encoded.length, explicitSplit);
|
|
146
|
+
if (maxPartChars === undefined) {
|
|
147
|
+
writeFileSync(outputPath, encoded, "utf-8");
|
|
148
|
+
return { paths: [outputPath] };
|
|
149
|
+
}
|
|
150
|
+
const wrappedParts = splitEncodedIntoWrappedParts(encoded, maxPartChars);
|
|
151
|
+
const totalParts = wrappedParts.length;
|
|
152
|
+
const paths = wrappedParts.map((content, index) => {
|
|
153
|
+
const partPath = formatSplitOutputPath(outputPath, index + 1, totalParts);
|
|
154
|
+
writeFileSync(partPath, content, "utf-8");
|
|
155
|
+
return partPath;
|
|
156
|
+
});
|
|
157
|
+
return { paths, splitChunkSize: maxPartChars };
|
|
158
|
+
}
|
|
67
159
|
/**
|
|
68
160
|
* Split a string into fixed-size chunks (last chunk may be shorter).
|
|
69
161
|
*
|
|
@@ -81,37 +173,70 @@ export function splitString(value, chunkSize) {
|
|
|
81
173
|
}
|
|
82
174
|
return chunks;
|
|
83
175
|
}
|
|
84
|
-
/** Build the
|
|
176
|
+
/** Build the ASCII v2 split chunk header. */
|
|
85
177
|
export function createSplitChunkHeader(partIndex, totalParts) {
|
|
86
|
-
|
|
87
|
-
SPLIT_MAGIC.copy(header, 0);
|
|
88
|
-
header.writeUInt32LE(partIndex, 4);
|
|
89
|
-
header.writeUInt32LE(totalParts, 8);
|
|
90
|
-
return header;
|
|
178
|
+
return `${SPLIT_MAGIC}${partIndex};${totalParts};`;
|
|
91
179
|
}
|
|
92
180
|
/**
|
|
93
181
|
* Wrap one encoded payload chunk with a v2 split header.
|
|
94
182
|
*/
|
|
95
183
|
export function wrapSplitChunk(partIndex, totalParts, payload) {
|
|
96
|
-
return
|
|
97
|
-
createSplitChunkHeader(partIndex, totalParts),
|
|
98
|
-
Buffer.from(payload, "utf-8"),
|
|
99
|
-
]).toString("utf-8");
|
|
184
|
+
return `${createSplitChunkHeader(partIndex, totalParts)}${payload}`;
|
|
100
185
|
}
|
|
101
|
-
function
|
|
186
|
+
function parseTextSplitHeader(text, offset) {
|
|
187
|
+
if (!text.startsWith(SPLIT_MAGIC, offset))
|
|
188
|
+
return null;
|
|
189
|
+
let pos = offset + SPLIT_MAGIC.length;
|
|
190
|
+
const partEnd = text.indexOf(";", pos);
|
|
191
|
+
if (partEnd === -1)
|
|
192
|
+
return null;
|
|
193
|
+
const partIndex = Number(text.slice(pos, partEnd));
|
|
194
|
+
pos = partEnd + 1;
|
|
195
|
+
const totalEnd = text.indexOf(";", pos);
|
|
196
|
+
if (totalEnd === -1)
|
|
197
|
+
return null;
|
|
198
|
+
const totalParts = Number(text.slice(pos, totalEnd));
|
|
199
|
+
if (!Number.isInteger(partIndex) ||
|
|
200
|
+
!Number.isInteger(totalParts) ||
|
|
201
|
+
partIndex < 1 ||
|
|
202
|
+
totalParts < 1) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
return { partIndex, totalParts, headerEnd: totalEnd + 1 };
|
|
206
|
+
}
|
|
207
|
+
function readTextSplitChunks(text) {
|
|
208
|
+
const chunks = [];
|
|
209
|
+
let offset = 0;
|
|
210
|
+
while (offset < text.length) {
|
|
211
|
+
const header = parseTextSplitHeader(text, offset);
|
|
212
|
+
if (!header) {
|
|
213
|
+
throw new Error("Invalid split format: unexpected data between split chunks.");
|
|
214
|
+
}
|
|
215
|
+
const nextMagic = text.indexOf(SPLIT_MAGIC, header.headerEnd);
|
|
216
|
+
const end = nextMagic === -1 ? text.length : nextMagic;
|
|
217
|
+
chunks.push({
|
|
218
|
+
partIndex: header.partIndex,
|
|
219
|
+
totalParts: header.totalParts,
|
|
220
|
+
payload: text.slice(header.headerEnd, end),
|
|
221
|
+
});
|
|
222
|
+
offset = end;
|
|
223
|
+
}
|
|
224
|
+
return chunks;
|
|
225
|
+
}
|
|
226
|
+
function readLegacyBinarySplitChunks(buf) {
|
|
102
227
|
const chunks = [];
|
|
103
228
|
let offset = 0;
|
|
104
229
|
while (offset < buf.length) {
|
|
105
|
-
if (buf.length - offset <
|
|
230
|
+
if (buf.length - offset < LEGACY_SPLIT_HEADER_SIZE) {
|
|
106
231
|
throw new Error("Invalid split format: truncated chunk header.");
|
|
107
232
|
}
|
|
108
|
-
if (!buf.subarray(offset, offset +
|
|
233
|
+
if (!buf.subarray(offset, offset + LEGACY_SPLIT_MAGIC.length).equals(LEGACY_SPLIT_MAGIC)) {
|
|
109
234
|
throw new Error("Invalid split format: unexpected data between split chunks.");
|
|
110
235
|
}
|
|
111
236
|
const partIndex = buf.readUInt32LE(offset + 4);
|
|
112
237
|
const totalParts = buf.readUInt32LE(offset + 8);
|
|
113
|
-
offset +=
|
|
114
|
-
const nextMagic = buf.indexOf(
|
|
238
|
+
offset += LEGACY_SPLIT_HEADER_SIZE;
|
|
239
|
+
const nextMagic = buf.indexOf(LEGACY_SPLIT_MAGIC, offset);
|
|
115
240
|
const end = nextMagic === -1 ? buf.length : nextMagic;
|
|
116
241
|
const payload = buf.subarray(offset, end).toString("utf-8");
|
|
117
242
|
chunks.push({ partIndex, totalParts, payload });
|
|
@@ -119,15 +244,26 @@ function readSplitChunks(buf) {
|
|
|
119
244
|
}
|
|
120
245
|
return chunks;
|
|
121
246
|
}
|
|
247
|
+
function readSplitChunks(buf) {
|
|
248
|
+
if (buf.subarray(0, SPLIT_MAGIC.length).toString("utf-8") === SPLIT_MAGIC) {
|
|
249
|
+
return readTextSplitChunks(buf.toString("utf-8"));
|
|
250
|
+
}
|
|
251
|
+
if (buf.subarray(0, LEGACY_SPLIT_MAGIC.length).equals(LEGACY_SPLIT_MAGIC)) {
|
|
252
|
+
return readLegacyBinarySplitChunks(buf);
|
|
253
|
+
}
|
|
254
|
+
throw new Error("Invalid split format: missing chunk header.");
|
|
255
|
+
}
|
|
122
256
|
/**
|
|
123
257
|
* Parse split chunks from a buffer when it starts with a split header.
|
|
124
258
|
*
|
|
125
259
|
* @returns `null` when the buffer is not split data or is malformed.
|
|
126
260
|
*/
|
|
127
261
|
export function tryParseSplitChunks(buf) {
|
|
128
|
-
if (buf.length <
|
|
262
|
+
if (buf.length < SPLIT_MAGIC.length)
|
|
129
263
|
return null;
|
|
130
|
-
|
|
264
|
+
const startsWithText = buf.subarray(0, SPLIT_MAGIC.length).toString("utf-8") === SPLIT_MAGIC;
|
|
265
|
+
const startsWithLegacy = buf.subarray(0, LEGACY_SPLIT_MAGIC.length).equals(LEGACY_SPLIT_MAGIC);
|
|
266
|
+
if (!startsWithText && !startsWithLegacy)
|
|
131
267
|
return null;
|
|
132
268
|
try {
|
|
133
269
|
return readSplitChunks(buf);
|
package/dist/split/parts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.js","sourceRoot":"","sources":["../../src/split/parts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH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GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAC3C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;IAC/B,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,0CAA0C,qBAAqB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACjG,CAAC;IAED,MAAM,OAAO,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAC9E,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE,CAAA;AAC5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder.d.ts","sourceRoot":"","sources":["../../src/streaming/folder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;
|
|
1
|
+
{"version":3,"file":"folder.d.ts","sourceRoot":"","sources":["../../src/streaming/folder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA2BH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAQ3C,uDAAuD;AACvD,UAAU,YAAY;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;CACrB;AA6GD,8CAA8C;AAC9C,MAAM,WAAW,0BAA2B,SAAQ,YAAY;IAC9D,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,QAAa,EACvB,KAAK,CAAC,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,0BAA0B,CAAC,CAuBrC"}
|
package/dist/streaming/folder.js
CHANGED
|
@@ -34,11 +34,10 @@ import { writeDirEntry, writeFileEntry } from "../archive/format.js";
|
|
|
34
34
|
import { createMaxQualityBrotliCompress } from "../compression/brotli.js";
|
|
35
35
|
import { encryptBuffer } from "../crypto/password.js";
|
|
36
36
|
import { encodeBase64 } from "../encoding/base64.js";
|
|
37
|
-
import { estimatedEncodedLength } from "../encoding/index.js";
|
|
38
37
|
import { encodeBase85 } from "../encoding/z85.js";
|
|
39
38
|
import { walkDirectory } from "../fs/walk.js";
|
|
40
39
|
import { TAG_FOLDER } from "../payload/tags.js";
|
|
41
|
-
import {
|
|
40
|
+
import { writeEncodedOutput } from "../split/parts.js";
|
|
42
41
|
/** Buffer size when copying file content into the archive. */
|
|
43
42
|
const COPY_CHUNK = 1024 * 1024;
|
|
44
43
|
/** Buffer size when reading compressed bytes for Base64 encoding. */
|
|
@@ -97,19 +96,10 @@ function prependTagStream(tag, filePath) {
|
|
|
97
96
|
async function brotliCompressFile(inputPath, outputPath) {
|
|
98
97
|
await pipeline(prependTagStream(TAG_FOLDER, inputPath), createMaxQualityBrotliCompress(statSync(inputPath).size + 1), createWriteStream(outputPath));
|
|
99
98
|
}
|
|
100
|
-
/** Open one numbered part file for split output. */
|
|
101
|
-
function openPart(outputPath, partIndex, totalParts) {
|
|
102
|
-
const path = formatSplitOutputPath(outputPath, partIndex, totalParts);
|
|
103
|
-
const fd = openSync(path, "w");
|
|
104
|
-
writeSync(fd, createSplitChunkHeader(partIndex, totalParts));
|
|
105
|
-
return { path, fd };
|
|
106
|
-
}
|
|
107
99
|
/**
|
|
108
|
-
* Stream-read a binary file and write encoded text to
|
|
109
|
-
*
|
|
110
|
-
* Handles optional character-based splitting across part files.
|
|
100
|
+
* Stream-read a binary file and write encoded text to a single output file.
|
|
111
101
|
*/
|
|
112
|
-
function
|
|
102
|
+
function encodeBinaryFileToTextFile(inputPath, outputPath, encoding) {
|
|
113
103
|
const binaryBytes = statSync(inputPath).size;
|
|
114
104
|
const srcFd = openSync(inputPath, "r");
|
|
115
105
|
const readAndEncode = (writeEncoded) => {
|
|
@@ -137,57 +127,14 @@ function encodeBinaryFileToTextFiles(inputPath, outputPath, encoding, split) {
|
|
|
137
127
|
writeEncoded(encodeBase85(raw));
|
|
138
128
|
}
|
|
139
129
|
};
|
|
140
|
-
|
|
141
|
-
const outFd = openSync(outputPath, "w");
|
|
142
|
-
try {
|
|
143
|
-
readAndEncode((text) => writeSync(outFd, text));
|
|
144
|
-
}
|
|
145
|
-
finally {
|
|
146
|
-
closeSync(srcFd);
|
|
147
|
-
closeSync(outFd);
|
|
148
|
-
}
|
|
149
|
-
return [outputPath];
|
|
150
|
-
}
|
|
151
|
-
const encodedLength = estimatedEncodedLength(binaryBytes, encoding);
|
|
152
|
-
const totalParts = Math.ceil(encodedLength / split);
|
|
153
|
-
const paths = [];
|
|
154
|
-
let partIndex = 1;
|
|
155
|
-
let part = openPart(outputPath, partIndex, totalParts);
|
|
156
|
-
paths.push(part.path);
|
|
157
|
-
let partChars = 0;
|
|
158
|
-
const flushPart = () => {
|
|
159
|
-
closeSync(part.fd);
|
|
160
|
-
if (partIndex < totalParts) {
|
|
161
|
-
partIndex++;
|
|
162
|
-
part = openPart(outputPath, partIndex, totalParts);
|
|
163
|
-
paths.push(part.path);
|
|
164
|
-
partChars = 0;
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
const writeEncoded = (text) => {
|
|
168
|
-
let offset = 0;
|
|
169
|
-
while (offset < text.length) {
|
|
170
|
-
const remaining = split - partChars;
|
|
171
|
-
if (remaining <= 0) {
|
|
172
|
-
flushPart();
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
const slice = text.slice(offset, offset + remaining);
|
|
176
|
-
writeSync(part.fd, slice);
|
|
177
|
-
partChars += slice.length;
|
|
178
|
-
offset += slice.length;
|
|
179
|
-
if (partChars >= split && offset < text.length)
|
|
180
|
-
flushPart();
|
|
181
|
-
}
|
|
182
|
-
};
|
|
130
|
+
const outFd = openSync(outputPath, "w");
|
|
183
131
|
try {
|
|
184
|
-
readAndEncode(
|
|
132
|
+
readAndEncode((text) => writeSync(outFd, text));
|
|
185
133
|
}
|
|
186
134
|
finally {
|
|
187
135
|
closeSync(srcFd);
|
|
188
|
-
closeSync(
|
|
136
|
+
closeSync(outFd);
|
|
189
137
|
}
|
|
190
|
-
return paths;
|
|
191
138
|
}
|
|
192
139
|
/**
|
|
193
140
|
* Compress a folder to encoded text file(s) using the streaming pipeline.
|
|
@@ -208,9 +155,10 @@ export async function compressFolderToPath(dirPath, outputPath, encoding = 64, s
|
|
|
208
155
|
encodeInputPath = encryptedPath;
|
|
209
156
|
}
|
|
210
157
|
const compressedBytes = statSync(encodeInputPath).size;
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
const
|
|
158
|
+
const encodedPath = join(tempDir, "encoded.txt");
|
|
159
|
+
encodeBinaryFileToTextFile(encodeInputPath, encodedPath, encoding);
|
|
160
|
+
const encoded = readFileSync(encodedPath, "utf-8");
|
|
161
|
+
const { paths: outputPaths, splitChunkSize } = writeEncodedOutput(encoded, outputPath, split);
|
|
214
162
|
return { ...stats, compressedBytes, outputPaths, splitChunkSize };
|
|
215
163
|
}
|
|
216
164
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder.js","sourceRoot":"","sources":["../../src/streaming/folder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,aAAa,EACb,SAAS,GACV,M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B,CAAC,CAAA;IAEtD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QACpD,MAAM,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;QACrD,IAAI,eAAe,GAAG,cAAc,CAAA;QACpC,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;YACpD,aAAa,CAAC,aAAa,EAAE,aAAa,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAA;YACnF,eAAe,GAAG,aAAa,CAAA;QACjC,CAAC;QACD,MAAM,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC,IAAI,CAAA;QACtD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;QAChD,0BAA0B,CAAC,eAAe,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAA;QAClE,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;QAClD,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;QAC7F,OAAO,EAAE,GAAG,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,CAAA;IACnE,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACnD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "text-compress",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Brotli-compress text or folders to base64/base85 strings for easy sharing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,19 +12,26 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
|
-
"text-compress": "
|
|
15
|
+
"text-compress": "dist/cli.js"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
|
-
"dist"
|
|
18
|
+
"dist",
|
|
19
|
+
"skills",
|
|
20
|
+
"!skills/_artifacts"
|
|
19
21
|
],
|
|
20
22
|
"scripts": {
|
|
21
23
|
"build": "tsc",
|
|
22
|
-
"check": "biome check --write . && tsc",
|
|
24
|
+
"check": "biome check --write . && tsc && bun run validate:skills",
|
|
25
|
+
"check:ci": "biome check . && tsc && bun run validate:skills",
|
|
23
26
|
"dev": "tsx src/cli.ts",
|
|
27
|
+
"lint": "biome check .",
|
|
28
|
+
"typecheck": "tsc",
|
|
24
29
|
"test": "vitest run",
|
|
25
30
|
"pretest": "npm run build",
|
|
26
31
|
"test:watch": "vitest",
|
|
27
|
-
"prepublishOnly": "npm run build"
|
|
32
|
+
"prepublishOnly": "npm run build",
|
|
33
|
+
"validate:skills": "intent validate",
|
|
34
|
+
"prepare": "husky"
|
|
28
35
|
},
|
|
29
36
|
"keywords": [
|
|
30
37
|
"brotli",
|
|
@@ -33,7 +40,8 @@
|
|
|
33
40
|
"base85",
|
|
34
41
|
"z85",
|
|
35
42
|
"text",
|
|
36
|
-
"archive"
|
|
43
|
+
"archive",
|
|
44
|
+
"tanstack-intent"
|
|
37
45
|
],
|
|
38
46
|
"repository": {
|
|
39
47
|
"type": "git",
|
|
@@ -48,11 +56,13 @@
|
|
|
48
56
|
"node": ">=18"
|
|
49
57
|
},
|
|
50
58
|
"devDependencies": {
|
|
51
|
-
"@biomejs/biome": "^2.5.
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
59
|
+
"@biomejs/biome": "^2.5.3",
|
|
60
|
+
"@tanstack/intent": "^0.3.5",
|
|
61
|
+
"@types/node": "^26.1.1",
|
|
62
|
+
"husky": "^9.1.7",
|
|
63
|
+
"tsx": "^4.23.0",
|
|
64
|
+
"typescript": "^7.0.2",
|
|
65
|
+
"vitest": "^4.1.10"
|
|
56
66
|
},
|
|
57
67
|
"dependencies": {
|
|
58
68
|
"ignore": "^7.0.5"
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cli
|
|
3
|
+
description: >
|
|
4
|
+
text-compress CLI: auto-detect compress vs decompress from input path or -t
|
|
5
|
+
text, -e 64/85 encoding, -p password, -s split parts, -o output, --compress
|
|
6
|
+
and --decompress force flags. No compress/decompress subcommands in v2.
|
|
7
|
+
metadata:
|
|
8
|
+
type: sub-skill
|
|
9
|
+
library: text-compress
|
|
10
|
+
library_version: '2.0.2'
|
|
11
|
+
sources:
|
|
12
|
+
- startdo-ing/text-compress-cli:README.md
|
|
13
|
+
- startdo-ing/text-compress-cli:src/cli/main.ts
|
|
14
|
+
- startdo-ing/text-compress-cli:src/cli/args.ts
|
|
15
|
+
- startdo-ing/text-compress-cli:src/cli/detect.ts
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# text-compress — CLI
|
|
19
|
+
|
|
20
|
+
This skill builds on text-compress/core. Read it first for encoding, pipeline,
|
|
21
|
+
and v1→v2 migration context.
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g text-compress
|
|
27
|
+
# or without installing:
|
|
28
|
+
npx text-compress ./notes.md
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Local development:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm run dev -- ./notes.md
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Core Patterns
|
|
38
|
+
|
|
39
|
+
### Auto-detect compress or decompress
|
|
40
|
+
|
|
41
|
+
Pass a path; the CLI picks the operation. Directories always compress. Files
|
|
42
|
+
and inline text are checked for a valid compressed payload.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
text-compress ./notes.md # compress file → notes.txt
|
|
46
|
+
text-compress ./notes.txt # decompress if valid payload
|
|
47
|
+
text-compress ./my-project # compress folder
|
|
48
|
+
text-compress -t "hello world" # compress inline text
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Password protection
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
text-compress ./notes.md -p "my secret" -o locked.txt
|
|
55
|
+
text-compress ./locked.txt -p "my secret" -o notes.md
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Base85 encoding and split output
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
text-compress ./notes.md -e 85
|
|
62
|
+
text-compress ./large-file.txt -s 4000
|
|
63
|
+
text-compress ./output.7.txt # decompress any split sibling
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Force mode when auto-detect is wrong
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
text-compress --compress ./looks-compressed.txt
|
|
70
|
+
text-compress --decompress ./plain.md
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Default output paths (when `-o` omitted)
|
|
74
|
+
|
|
75
|
+
| Operation | Default output |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| Compress file/text | `<input>.txt` |
|
|
78
|
+
| Compress folder | `<folder-name>.txt` |
|
|
79
|
+
| Decompress text | `<input>.de.txt` |
|
|
80
|
+
| Decompress folder | `<input>.de/` |
|
|
81
|
+
|
|
82
|
+
## Common Mistakes
|
|
83
|
+
|
|
84
|
+
### [CRITICAL] Using v1 subcommands `compress` / `decompress`
|
|
85
|
+
|
|
86
|
+
Wrong:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
tc compress notes.md
|
|
90
|
+
tc decompress out.txt
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Correct:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
text-compress notes.md
|
|
97
|
+
text-compress out.txt
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
v2 has no required subcommand. Legacy `compress`/`decompress` as the first
|
|
101
|
+
argument still work but are deprecated.
|
|
102
|
+
|
|
103
|
+
Source: README.md — Migration from @startdoing/tc v1
|
|
104
|
+
|
|
105
|
+
### [HIGH] Omitting password on protected payload
|
|
106
|
+
|
|
107
|
+
Wrong:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
text-compress ./locked.txt
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Correct:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
text-compress ./locked.txt -p "my secret"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Password-protected payloads error without `-p`. They are **not** silently
|
|
120
|
+
re-compressed.
|
|
121
|
+
|
|
122
|
+
Source: src/cli/main.ts, src/payload/tags.ts
|
|
123
|
+
|
|
124
|
+
### [HIGH] Passing a directory to decompress
|
|
125
|
+
|
|
126
|
+
Wrong:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
text-compress ./restored-project/
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Correct:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
text-compress ./restored-project.txt
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Decompress expects a compressed file path, not an output directory.
|
|
139
|
+
|
|
140
|
+
Source: src/cli/args.ts
|
|
141
|
+
|
|
142
|
+
### [MEDIUM] Mixing v1 and v2 split part files
|
|
143
|
+
|
|
144
|
+
Wrong:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Expecting v1 raw concatenation without ;TCP2; headers
|
|
148
|
+
text-compress ./v1-part.1.txt
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Correct:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# v2 parts have ;TCP2; ASCII headers; pass any sibling
|
|
155
|
+
text-compress ./output.7.txt
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
v2 split format is not compatible with v1.
|
|
159
|
+
|
|
160
|
+
Source: README.md — v2 split output
|
|
161
|
+
|
|
162
|
+
### [MEDIUM] Multiple input sources
|
|
163
|
+
|
|
164
|
+
Wrong:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
text-compress ./a.md -t "hello"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Correct:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
text-compress ./a.md
|
|
174
|
+
# or
|
|
175
|
+
text-compress -t "hello"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Only one input source allowed per invocation.
|
|
179
|
+
|
|
180
|
+
Source: src/cli/args.ts
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: core
|
|
3
|
+
description: >
|
|
4
|
+
text-compress core concepts: Brotli-compress text or folders to pasteable
|
|
5
|
+
Base64 or Z85 strings. CLI auto-detect (compress vs decompress), library
|
|
6
|
+
API (compress, decompress, compressFolder, decompressToPath), encoding 64/85,
|
|
7
|
+
password protection, v2 split parts. Entry point for all text-compress skills.
|
|
8
|
+
metadata:
|
|
9
|
+
type: core
|
|
10
|
+
library: text-compress
|
|
11
|
+
library_version: '2.0.2'
|
|
12
|
+
sources:
|
|
13
|
+
- startdo-ing/text-compress-cli:README.md
|
|
14
|
+
- startdo-ing/text-compress-cli:docs/ARCHITECTURE.md
|
|
15
|
+
- startdo-ing/text-compress-cli:src/index.ts
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# text-compress — Core Concepts
|
|
19
|
+
|
|
20
|
+
`text-compress` turns UTF-8 text or entire folder trees into a single pasteable
|
|
21
|
+
string (Base64 or Z85), and back again. Use the CLI for terminal workflows or
|
|
22
|
+
import from `"text-compress"` in Node.js/TypeScript.
|
|
23
|
+
|
|
24
|
+
**Package:** npm package `text-compress` (v2). Legacy v1 is `@startdoing/tc@1.0.4`
|
|
25
|
+
— do not mix APIs or split formats between versions.
|
|
26
|
+
|
|
27
|
+
## Pipeline
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Input → type tag → Brotli (max quality) → Base64 or Z85 → pasteable string
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Folder archives use a custom binary format before compression. Large outputs can
|
|
34
|
+
be split into numbered part files for chat paste limits.
|
|
35
|
+
|
|
36
|
+
## Sub-Skills
|
|
37
|
+
|
|
38
|
+
| Need to... | Read |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| Run compress/decompress from the terminal | text-compress/cli/SKILL.md |
|
|
41
|
+
| Call compress/decompress from TypeScript | text-compress/library/SKILL.md |
|
|
42
|
+
|
|
43
|
+
## Quick Decision Tree
|
|
44
|
+
|
|
45
|
+
- Terminal one-liner, auto-detect mode? → text-compress/cli
|
|
46
|
+
- Programmatic use in Node/TS? → text-compress/library
|
|
47
|
+
- Password-protected payload? → pass `-p` / `password` on both compress and decompress
|
|
48
|
+
- Large output for chat paste limits? → use `-s` split (CLI) or split helpers (library)
|
|
49
|
+
- Migrating from `@startdoing/tc` v1? → new package name, no subcommands, new split format
|
|
50
|
+
|
|
51
|
+
## Encoding
|
|
52
|
+
|
|
53
|
+
| Value | Format | When |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `64` (default) | Base64 | Paste anywhere |
|
|
56
|
+
| `85` | Z85 (ZeroMQ RFC 32) | ~8% smaller; punctuation-safe in code blocks |
|
|
57
|
+
|
|
58
|
+
Use the same encoding for compress and decompress. When `-e` is omitted on
|
|
59
|
+
decompress, the CLI tries both.
|
|
60
|
+
|
|
61
|
+
## Version
|
|
62
|
+
|
|
63
|
+
Targets `text-compress` v2.0.2.
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: library
|
|
3
|
+
description: >
|
|
4
|
+
text-compress library API: compress, decompress, compressFolder,
|
|
5
|
+
decompressToPath, decompressPayload, split helpers. Encoding 64|85, optional
|
|
6
|
+
password. TAG_TEXT vs TAG_FOLDER routing. Import from "text-compress".
|
|
7
|
+
metadata:
|
|
8
|
+
type: sub-skill
|
|
9
|
+
library: text-compress
|
|
10
|
+
library_version: '2.0.2'
|
|
11
|
+
sources:
|
|
12
|
+
- startdo-ing/text-compress-cli:README.md
|
|
13
|
+
- startdo-ing/text-compress-cli:src/index.ts
|
|
14
|
+
- startdo-ing/text-compress-cli:src/api/text.ts
|
|
15
|
+
- startdo-ing/text-compress-cli:src/api/folder.ts
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# text-compress — Library API
|
|
19
|
+
|
|
20
|
+
This skill builds on text-compress/core. Read it first for encoding and pipeline
|
|
21
|
+
context.
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import {
|
|
27
|
+
compress,
|
|
28
|
+
decompress,
|
|
29
|
+
compressFolder,
|
|
30
|
+
decompressToPath,
|
|
31
|
+
} from "text-compress";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Requires Node.js >= 18. Package name is `"text-compress"` (not `@startdoing/tc`).
|
|
35
|
+
|
|
36
|
+
## Core Patterns
|
|
37
|
+
|
|
38
|
+
### Compress and decompress text
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const encoded = compress("hello world");
|
|
42
|
+
const restored = decompress(encoded);
|
|
43
|
+
|
|
44
|
+
// Z85 encoding (~8% smaller)
|
|
45
|
+
const z85 = compress("hello world", 85);
|
|
46
|
+
const fromZ85 = decompress(z85, 85);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Password-protected text
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
const locked = compress("hello world", 64, "my secret");
|
|
53
|
+
const unlocked = decompress(locked, 64, "my secret");
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Folder archives
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const { encoded, fileCount, dirCount, originalBytes } =
|
|
60
|
+
compressFolder("./my-project");
|
|
61
|
+
|
|
62
|
+
decompressToPath(encoded, "./restored-project");
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Low-level payload access
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { decompressPayload, TAG_TEXT, TAG_FOLDER } from "text-compress";
|
|
69
|
+
|
|
70
|
+
const { tag, data } = decompressPayload(encoded, 64, password);
|
|
71
|
+
if (tag === TAG_TEXT) {
|
|
72
|
+
const text = data.toString("utf-8");
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## API Reference
|
|
77
|
+
|
|
78
|
+
| Function | Description |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `compress(text, encoding?, password?)` | UTF-8 text → encoded string (`64` or `85`) |
|
|
81
|
+
| `decompress(encoded, encoding?, password?)` | Encoded text payload → string |
|
|
82
|
+
| `compressFolder(dirPath, encoding?, password?)` | Folder → `{ encoded, fileCount, ... }` |
|
|
83
|
+
| `decompressToPath(encoded, destDir, encoding?, password?)` | Unpack folder archive |
|
|
84
|
+
| `decompressPayload(encoded, encoding?, password?)` | Low-level `{ tag, data }` |
|
|
85
|
+
|
|
86
|
+
## Common Mistakes
|
|
87
|
+
|
|
88
|
+
### [CRITICAL] Using v1 package import
|
|
89
|
+
|
|
90
|
+
Wrong:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { compress } from "@startdoing/tc";
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Correct:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { compress, decompress } from "text-compress";
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
v1 remains frozen at 1.0.4; v2 is a separate npm package.
|
|
103
|
+
|
|
104
|
+
Source: README.md — Migration
|
|
105
|
+
|
|
106
|
+
### [HIGH] Calling decompress on a folder payload
|
|
107
|
+
|
|
108
|
+
Wrong:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
const encoded = compressFolder("./project").encoded;
|
|
112
|
+
const text = decompress(encoded); // throws
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Correct:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
decompressToPath(encoded, "./restored");
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Text and folder payloads share encoding but differ by tag byte after Brotli
|
|
122
|
+
decompression. `decompress()` throws if the tag is `TAG_FOLDER`.
|
|
123
|
+
|
|
124
|
+
Source: src/api/text.ts
|
|
125
|
+
|
|
126
|
+
### [HIGH] Calling decompressToPath on text payload
|
|
127
|
+
|
|
128
|
+
Wrong:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
const encoded = compress("hello");
|
|
132
|
+
decompressToPath(encoded, "./out"); // throws
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Correct:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
const text = decompress(encoded);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Source: src/api/folder.ts
|
|
142
|
+
|
|
143
|
+
### [MEDIUM] Mismatched encoding on round-trip
|
|
144
|
+
|
|
145
|
+
Wrong:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
const encoded = compress("hello", 85);
|
|
149
|
+
const text = decompress(encoded, 64); // fails or garbage
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Correct:
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
const encoded = compress("hello", 85);
|
|
156
|
+
const text = decompress(encoded, 85);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Source: src/encoding/index.ts
|
|
160
|
+
|
|
161
|
+
### [MEDIUM] compressFolder loads entire tree into memory
|
|
162
|
+
|
|
163
|
+
Wrong:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
// For very large folders in production scripts
|
|
167
|
+
compressFolder("/huge-monorepo");
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Correct:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# CLI uses streaming pipeline for folders (bounded memory)
|
|
174
|
+
text-compress ./huge-monorepo
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The library `compressFolder()` walks and serializes in memory. The CLI
|
|
178
|
+
streaming path is internal and not exported.
|
|
179
|
+
|
|
180
|
+
Source: docs/ARCHITECTURE.md — Two folder compression paths
|