@wovin/core 0.1.20 → 0.1.22
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/{chunk-W477A74Z.min.js → chunk-FWL2ZJCW.min.js} +2 -2
- package/dist/{chunk-3HHBRM32.min.js → chunk-IIF2KSDX.min.js} +51 -1
- package/dist/{chunk-3HHBRM32.min.js.map → chunk-IIF2KSDX.min.js.map} +1 -1
- package/dist/index.min.js +4 -2
- package/dist/ipfs/car.d.ts +1 -0
- package/dist/ipfs/car.d.ts.map +1 -1
- package/dist/ipfs.min.js +3 -1
- package/dist/pubsub/connector.d.ts +1 -1
- package/dist/pubsub/connector.d.ts.map +1 -1
- package/dist/pubsub.min.js +1 -1
- package/dist/retrieve.min.js +2 -2
- package/package.json +1 -1
- /package/dist/{chunk-W477A74Z.min.js.map → chunk-FWL2ZJCW.min.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unchunkApplogsBlock
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IIF2KSDX.min.js";
|
|
4
4
|
import {
|
|
5
5
|
CID,
|
|
6
6
|
areCidsEqual,
|
|
@@ -129,4 +129,4 @@ async function updateThreadFromSnapshot(thread, cid, retriever, options) {
|
|
|
129
129
|
export {
|
|
130
130
|
updateThreadFromSnapshot
|
|
131
131
|
};
|
|
132
|
-
//# sourceMappingURL=chunk-
|
|
132
|
+
//# sourceMappingURL=chunk-FWL2ZJCW.min.js.map
|
|
@@ -3913,6 +3913,55 @@ async function makeCarBlob(roots, blocks) {
|
|
|
3913
3913
|
async function carFromBlob(blob) {
|
|
3914
3914
|
return CarReader.fromBytes(new Uint8Array(await blob.arrayBuffer()));
|
|
3915
3915
|
}
|
|
3916
|
+
function extractCids(value) {
|
|
3917
|
+
if (value instanceof CID) return [value];
|
|
3918
|
+
if (Array.isArray(value)) return value.flatMap(extractCids);
|
|
3919
|
+
if (value && typeof value === "object") return Object.values(value).flatMap(extractCids);
|
|
3920
|
+
return [];
|
|
3921
|
+
}
|
|
3922
|
+
var MAX_COLLECT_BLOCKS = 1e6;
|
|
3923
|
+
async function collectDagBlocks(startCID, blockStore) {
|
|
3924
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3925
|
+
const blocks = [];
|
|
3926
|
+
const queue = [startCID];
|
|
3927
|
+
while (queue.length > 0) {
|
|
3928
|
+
if (blocks.length >= MAX_COLLECT_BLOCKS) {
|
|
3929
|
+
WARN(`[collectDagBlocks] hit ${MAX_COLLECT_BLOCKS} block limit, returning partial result`);
|
|
3930
|
+
break;
|
|
3931
|
+
}
|
|
3932
|
+
const cid = queue.shift();
|
|
3933
|
+
const cidStr = cid.toString();
|
|
3934
|
+
if (visited.has(cidStr)) continue;
|
|
3935
|
+
visited.add(cidStr);
|
|
3936
|
+
let bytes;
|
|
3937
|
+
try {
|
|
3938
|
+
bytes = await blockStore.get(cid);
|
|
3939
|
+
} catch {
|
|
3940
|
+
WARN(`[collectDagBlocks] block not found: ${cidStr}, stopping this branch`);
|
|
3941
|
+
continue;
|
|
3942
|
+
}
|
|
3943
|
+
if (!bytes) {
|
|
3944
|
+
WARN(`[collectDagBlocks] block not found: ${cidStr}, stopping this branch`);
|
|
3945
|
+
continue;
|
|
3946
|
+
}
|
|
3947
|
+
blocks.push({ cid, bytes });
|
|
3948
|
+
if (blocks.length % 1e3 === 0) {
|
|
3949
|
+
LOG(`[collectDagBlocks] collected ${blocks.length} blocks...`);
|
|
3950
|
+
}
|
|
3951
|
+
try {
|
|
3952
|
+
const decoded = decode(bytes);
|
|
3953
|
+
const childCids = extractCids(decoded);
|
|
3954
|
+
for (const child of childCids) {
|
|
3955
|
+
if (!visited.has(child.toString())) {
|
|
3956
|
+
queue.push(child);
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
} catch {
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
DEBUG(`[collectDagBlocks] collected ${blocks.length} blocks from ${startCID.toString()}`);
|
|
3963
|
+
return blocks;
|
|
3964
|
+
}
|
|
3916
3965
|
function streamReaderToIterable(bodyReader) {
|
|
3917
3966
|
return (async function* () {
|
|
3918
3967
|
while (true) {
|
|
@@ -4118,6 +4167,7 @@ export {
|
|
|
4118
4167
|
makeCarOut,
|
|
4119
4168
|
makeCarBlob,
|
|
4120
4169
|
carFromBlob,
|
|
4170
|
+
collectDagBlocks,
|
|
4121
4171
|
streamReaderToIterable
|
|
4122
4172
|
};
|
|
4123
|
-
//# sourceMappingURL=chunk-
|
|
4173
|
+
//# sourceMappingURL=chunk-IIF2KSDX.min.js.map
|