@atcute/car 1.0.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.
- package/dist/atproto-repo.d.ts +10 -4
- package/dist/atproto-repo.js +18 -2
- package/dist/atproto-repo.js.map +1 -1
- package/package.json +3 -3
package/dist/atproto-repo.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as CBOR from '@atcute/cbor';
|
|
2
|
+
export declare class RepoEntry {
|
|
3
|
+
readonly collection: string;
|
|
4
|
+
readonly rkey: string;
|
|
5
|
+
readonly cid: CBOR.CIDLink;
|
|
6
|
+
private blockmap;
|
|
7
|
+
constructor(collection: string, rkey: string, cid: CBOR.CIDLink, blockmap: BlockMap);
|
|
8
|
+
get record(): unknown;
|
|
5
9
|
}
|
|
6
10
|
export declare function iterateAtpCar(buf: Uint8Array): Generator<RepoEntry>;
|
|
11
|
+
type BlockMap = Map<string, Uint8Array>;
|
|
12
|
+
export {};
|
package/dist/atproto-repo.js
CHANGED
|
@@ -2,18 +2,34 @@ import * as CBOR from '@atcute/cbor';
|
|
|
2
2
|
import * as CID from '@atcute/cid';
|
|
3
3
|
import { fromUint8Array } from './reader.js';
|
|
4
4
|
const decoder = new TextDecoder();
|
|
5
|
+
export class RepoEntry {
|
|
6
|
+
collection;
|
|
7
|
+
rkey;
|
|
8
|
+
cid;
|
|
9
|
+
blockmap;
|
|
10
|
+
constructor(collection, rkey, cid, blockmap) {
|
|
11
|
+
this.collection = collection;
|
|
12
|
+
this.rkey = rkey;
|
|
13
|
+
this.cid = cid;
|
|
14
|
+
this.blockmap = blockmap;
|
|
15
|
+
}
|
|
16
|
+
get record() {
|
|
17
|
+
return readObject(this.blockmap, this.cid);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
5
20
|
export function* iterateAtpCar(buf) {
|
|
6
21
|
const { roots, iterate } = fromUint8Array(new Uint8Array(buf));
|
|
7
22
|
assert(roots.length === 1, `expected only 1 root in the car archive; got=${roots.length}`);
|
|
23
|
+
// Collect all archive entries into a mapping of CID string -> actual bytes
|
|
8
24
|
const blockmap = new Map();
|
|
9
25
|
for (const entry of iterate()) {
|
|
10
26
|
blockmap.set(CID.format(entry.cid), entry.bytes);
|
|
11
27
|
}
|
|
28
|
+
// Read the head, then walk through the MST tree from there.
|
|
12
29
|
const commit = readObject(blockmap, roots[0]);
|
|
13
30
|
for (const { key, cid } of walkEntries(blockmap, commit.data)) {
|
|
14
31
|
const [collection, rkey] = key.split('/');
|
|
15
|
-
|
|
16
|
-
yield { collection, rkey, record };
|
|
32
|
+
yield new RepoEntry(collection, rkey, cid, blockmap);
|
|
17
33
|
}
|
|
18
34
|
}
|
|
19
35
|
function readObject(map, link) {
|
package/dist/atproto-repo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atproto-repo.js","sourceRoot":"","sources":["../lib/atproto-repo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"atproto-repo.js","sourceRoot":"","sources":["../lib/atproto-repo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,OAAO,SAAS;IAEJ;IACA;IACA;IACR;IAJT,YACiB,UAAkB,EAClB,IAAY,EACZ,GAAiB,EACzB,QAAkB;QAHV,eAAU,GAAV,UAAU,CAAQ;QAClB,SA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,CAAC;IACF,CAAC;AACF,CAAC;AAED,SAAS,MAAM,CAAC,SAAkB,EAAE,OAAe;IAClD,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@atcute/car",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"description": "read AT Protocol's CAR (content-addressable archive) repositories",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"@types/bun": "^1.1.10"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@atcute/cbor": "^1.0.2",
|
|
22
21
|
"@atcute/cid": "^1.0.1",
|
|
23
|
-
"@atcute/varint": "^1.0.0"
|
|
22
|
+
"@atcute/varint": "^1.0.0",
|
|
23
|
+
"@atcute/cbor": "^1.0.2"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsc --project tsconfig.build.json",
|