cbyte 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/99367107.cbyte +34 -0
  2. package/cbyte.js +18 -7
  3. package/package.json +1 -1
package/99367107.cbyte ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "format": "cbyte",
3
+ "version": 1.1,
4
+ "chunk_size": 4096,
5
+ "original_size": 16552,
6
+ "original_ext": ".pdf",
7
+ "chunks": [
8
+ {
9
+ "cid": "bafkreiacqklbx4vdykcehffxqqutkogrecieqmg7inhpb3ipd76bbjlzgm",
10
+ "length": 4096,
11
+ "count": 1
12
+ },
13
+ {
14
+ "cid": "bafkreiawx6r5puro2aw4rv7n44w34pk4givaagjxsykzn327v2623oj6sm",
15
+ "length": 4096,
16
+ "count": 1
17
+ },
18
+ {
19
+ "cid": "bafkreiara7il76jrtiyizb3z6hd2tcjn5ohqyhlwxff5gid3crgsqet4ya",
20
+ "length": 4096,
21
+ "count": 1
22
+ },
23
+ {
24
+ "cid": "bafkreia3e4vp7hmirxgaj37bmyjthwf45yvgyysown3egoce3sjsqagmqu",
25
+ "length": 4096,
26
+ "count": 1
27
+ },
28
+ {
29
+ "cid": "bafkreiaxfpoxjvvjwr2g2qnlhq63eqynh3nufsm2vxcdmudokdbr4z3hom",
30
+ "length": 168,
31
+ "count": 1
32
+ }
33
+ ]
34
+ }
package/cbyte.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // Increase listener limit to avoid warnings
4
- // require('events').defaultMaxListeners = 6000;
5
4
  import evt from 'events';
6
5
  import fs from 'fs';
7
6
  import crypto from 'crypto';
@@ -18,6 +17,18 @@ evt.defaultMaxListeners = 6000;
18
17
  const program = new Command();
19
18
  let helia = null;
20
19
 
20
+ // ---- Promise.withResolvers polyfill (Node < 22) ----
21
+ if (typeof Promise.withResolvers !== 'function') {
22
+ Promise.withResolvers = function () {
23
+ let resolve, reject
24
+ const promise = new Promise((res, rej) => {
25
+ resolve = res
26
+ reject = rej
27
+ })
28
+ return { promise, resolve, reject }
29
+ }
30
+ }
31
+
21
32
  // Initialize Helia node once
22
33
  async function ensureHelia() {
23
34
  if (!helia) {
@@ -56,7 +67,7 @@ async function pack(filePath, outFile, chunkSize = 4096, pin = false) {
56
67
 
57
68
  const manifest = {
58
69
  format: 'cbyte',
59
- version: 1.9,
70
+ version: 1.11,
60
71
  chunk_size: chunkSize,
61
72
  original_size: data.length,
62
73
  original_ext: path.extname(filePath),
@@ -88,7 +99,7 @@ async function pack(filePath, outFile, chunkSize = 4096, pin = false) {
88
99
  });
89
100
 
90
101
  uploaded++;
91
- renderProgress(uploaded, hashes.length, 'Packing');
102
+ renderProgress(uploaded, hashes.length, 'Packing ...');
92
103
  }));
93
104
  }
94
105
  process.stderr.write('\n');
@@ -104,7 +115,7 @@ async function unpack(manifestPath, outFile) {
104
115
  const manifest = JSON.parse(fs.readFileSync(manifestPath));
105
116
  if (!outFile) {
106
117
  const base = path.basename(manifestPath, path.extname(manifestPath));
107
- const ext = manifest.original_ext || '.out';
118
+ const ext = manifest.original_ext || '.bin';
108
119
  outFile = `${base}${ext}`;
109
120
  }
110
121
 
@@ -120,7 +131,7 @@ async function unpack(manifestPath, outFile) {
120
131
  for (let j = 0; j < entry.count; j++) {
121
132
  fs.writeSync(fd, blockBytes.slice(0, entry.length));
122
133
  completed++;
123
- renderProgress(completed, total, 'Unpacking');
134
+ renderProgress(completed, total, 'Unpacking... ');
124
135
  }
125
136
  }));
126
137
  }
@@ -158,14 +169,14 @@ async function pin(manifestPath) {
158
169
  for (const { cid } of manifest.chunks) {
159
170
  await helia.pin.add(cid);
160
171
  pinned++;
161
- renderProgress(pinned, manifest.chunks.length, 'Pinning');
172
+ renderProgress(pinned, manifest.chunks.length, 'Pinning...');
162
173
  }
163
174
  process.stderr.write('\n');
164
175
  console.log('All blocks pinned');
165
176
  }
166
177
 
167
178
  // CLI definition
168
- program.version('1.0.0');
179
+ program.version('1.10.0');
169
180
 
170
181
  program
171
182
  .command('pack <file>')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cbyte",
3
3
  "type": "module",
4
- "version": "1.9.0",
4
+ "version": "1.11.0",
5
5
  "description": "Content-addressed deduplicated storage CLI using IPFS with automatic unpack extension retention",
6
6
  "main": "cbyte.js",
7
7
  "bin": {