@wovin/core 0.0.16 → 0.0.18
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/applog.min.js +1 -1
- package/dist/{chunk-TEQ4SIKN.min.js → chunk-E4BAQ5JJ.min.js} +2 -2
- package/dist/chunk-IHGAJTEQ.min.js +70 -0
- package/dist/chunk-IHGAJTEQ.min.js.map +1 -0
- package/dist/{chunk-OBMVNVJR.min.js → chunk-KVPEUWWR.min.js} +2 -2
- package/dist/chunk-SIIQEX77.min.js +4122 -0
- package/dist/chunk-SIIQEX77.min.js.map +1 -0
- package/dist/{chunk-NPCVLBCM.min.js → chunk-UZBCM3UI.min.js} +5 -75
- package/dist/{chunk-NPCVLBCM.min.js.map → chunk-UZBCM3UI.min.js.map} +1 -1
- package/dist/{chunk-FIOA3FZW.min.js → chunk-VDYG5VHX.min.js} +4 -4
- package/dist/{chunk-FIOA3FZW.min.js.map → chunk-VDYG5VHX.min.js.map} +1 -1
- package/dist/index.min.js +19 -16
- package/dist/ipfs/car.d.ts +2 -1
- package/dist/ipfs/car.d.ts.map +1 -1
- package/dist/ipfs/fetch-snapshot-chain.d.ts +27 -0
- package/dist/ipfs/fetch-snapshot-chain.d.ts.map +1 -0
- package/dist/ipfs.d.ts +1 -0
- package/dist/ipfs.d.ts.map +1 -1
- package/dist/ipfs.min.js +7 -4
- package/dist/pubsub/pubsub-types.d.ts +7 -7
- package/dist/pubsub/pubsub-types.d.ts.map +1 -1
- package/dist/pubsub/{pub-push.d.ts → snap-push.d.ts} +7 -7
- package/dist/pubsub/snap-push.d.ts.map +1 -0
- package/dist/pubsub.d.ts +1 -1
- package/dist/pubsub.d.ts.map +1 -1
- package/dist/pubsub.min.js +14 -14
- package/dist/query/situations.d.ts +77 -0
- package/dist/query/situations.d.ts.map +1 -1
- package/dist/query.min.js +3 -3
- package/dist/thread.min.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-JEOQUHTK.min.js +0 -1515
- package/dist/chunk-JEOQUHTK.min.js.map +0 -1
- package/dist/chunk-RPPZKO5L.min.js +0 -1
- package/dist/chunk-RPPZKO5L.min.js.map +0 -1
- package/dist/pubsub/pub-push.d.ts.map +0 -1
- /package/dist/{chunk-TEQ4SIKN.min.js.map → chunk-E4BAQ5JJ.min.js.map} +0 -0
- /package/dist/{chunk-OBMVNVJR.min.js.map → chunk-KVPEUWWR.min.js.map} +0 -0
package/dist/applog.min.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createDebugName,
|
|
5
5
|
g,
|
|
6
6
|
observableArrayMap
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UZBCM3UI.min.js";
|
|
8
8
|
import {
|
|
9
9
|
autorun,
|
|
10
10
|
comparer,
|
|
@@ -62,4 +62,4 @@ export {
|
|
|
62
62
|
includes,
|
|
63
63
|
includedIn
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-E4BAQ5JJ.min.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CID,
|
|
3
|
+
areCidsEqual,
|
|
4
|
+
decode,
|
|
5
|
+
g
|
|
6
|
+
} from "./chunk-UZBCM3UI.min.js";
|
|
7
|
+
|
|
8
|
+
// src/ipfs/fetch-snapshot-chain.ts
|
|
9
|
+
var { WARN, LOG, DEBUG, VERBOSE, ERROR } = g.setup(g.INFO);
|
|
10
|
+
async function fetchSnapshotChainUntil(options) {
|
|
11
|
+
const { rootCID, stopAtCID, fetchBlock, fetchAll, maxDepth = 100 } = options;
|
|
12
|
+
const blockStore = createMemoryBlockStore();
|
|
13
|
+
const visited = /* @__PURE__ */ new Set();
|
|
14
|
+
let currentCID = rootCID;
|
|
15
|
+
let snapshotCount = 0;
|
|
16
|
+
while (currentCID && snapshotCount < maxDepth) {
|
|
17
|
+
const cidStr = currentCID.toString();
|
|
18
|
+
if (visited.has(cidStr)) {
|
|
19
|
+
throw ERROR("[fetchSnapshotChain] snapshot chain has a loop", { currentCID: cidStr, visited: [...visited] });
|
|
20
|
+
}
|
|
21
|
+
visited.add(cidStr);
|
|
22
|
+
if (stopAtCID && areCidsEqual(currentCID, stopAtCID)) {
|
|
23
|
+
DEBUG("[fetchSnapshotChain] reached stopAtCID, stopping", stopAtCID.toString());
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
DEBUG("[fetchSnapshotChain] fetching root block", cidStr);
|
|
27
|
+
const rootCar = await fetchBlock(currentCID);
|
|
28
|
+
await addCarBlocksToStore(rootCar, blockStore);
|
|
29
|
+
const rootBytes = await blockStore.get(currentCID);
|
|
30
|
+
if (!rootBytes) {
|
|
31
|
+
throw ERROR("[fetchSnapshotChain] root block not in store after fetch", { currentCID: cidStr });
|
|
32
|
+
}
|
|
33
|
+
const root = decode(rootBytes);
|
|
34
|
+
DEBUG("[fetchSnapshotChain] fetching applogs", root.applogs.toString());
|
|
35
|
+
const applogsCar = await fetchAll(root.applogs);
|
|
36
|
+
await addCarBlocksToStore(applogsCar, blockStore);
|
|
37
|
+
DEBUG("[fetchSnapshotChain] fetching info", root.info.toString());
|
|
38
|
+
const infoCar = await fetchAll(root.info);
|
|
39
|
+
await addCarBlocksToStore(infoCar, blockStore);
|
|
40
|
+
snapshotCount++;
|
|
41
|
+
currentCID = root.prev;
|
|
42
|
+
}
|
|
43
|
+
DEBUG("[fetchSnapshotChain] done", { snapshotCount, rootCID: rootCID.toString() });
|
|
44
|
+
return { rootCID, blockStore, blocks: blockStore.getBlocksArray(), snapshotCount };
|
|
45
|
+
}
|
|
46
|
+
async function addCarBlocksToStore(car, store) {
|
|
47
|
+
for await (const { cid, bytes } of car.blocks()) {
|
|
48
|
+
const validCid = typeof cid.toV1 === "function" ? cid : CID.decode(cid.bytes);
|
|
49
|
+
await store.put(validCid, bytes);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function createMemoryBlockStore() {
|
|
53
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
54
|
+
return {
|
|
55
|
+
async get(cid) {
|
|
56
|
+
return blocks.get(cid.toV1().toString());
|
|
57
|
+
},
|
|
58
|
+
async put(cid, bytes) {
|
|
59
|
+
blocks.set(cid.toV1().toString(), bytes);
|
|
60
|
+
},
|
|
61
|
+
getBlocksArray() {
|
|
62
|
+
return Array.from(blocks.entries());
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
fetchSnapshotChainUntil
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=chunk-IHGAJTEQ.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ipfs/fetch-snapshot-chain.ts"],"sourcesContent":["import { CarReader } from '@ipld/car'\nimport * as dagJson from '@ipld/dag-json'\nimport { Logger } from 'besonders-logger'\nimport { CID } from 'multiformats/cid'\nimport type { SnapRootBlock } from '../pubsub/pubsub-types'\nimport { areCidsEqual } from './ipfs-utils'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport interface BlockStoreForFetch {\n get(cid: CID): Promise<Uint8Array | undefined>\n put(cid: CID, bytes: Uint8Array): Promise<void>\n}\n\nexport interface FetchChainOptions {\n rootCID: CID\n stopAtCID?: CID // Stop when we hit this CID (lastCID from subscription)\n fetchBlock: (cid: CID) => Promise<CarReader> // dag-scope=block\n fetchAll: (cid: CID) => Promise<CarReader> // dag-scope=all\n maxDepth?: number\n}\n\nexport interface FetchChainResult {\n rootCID: CID\n blockStore: BlockStoreForFetch\n /** Serializable blocks array for worker boundary crossing */\n blocks: [string, Uint8Array][]\n snapshotCount: number\n}\n\n/**\n * Fetches a snapshot chain iteratively, stopping at stopAtCID.\n * Uses 3 requests per snapshot: root(block), applogs(all), info(all).\n * This avoids the gateway's dag-scope=all following prev links recursively.\n */\nexport async function fetchSnapshotChainUntil(options: FetchChainOptions): Promise<FetchChainResult> {\n const { rootCID, stopAtCID, fetchBlock, fetchAll, maxDepth = 100 } = options\n const blockStore = createMemoryBlockStore()\n const visited = new Set<string>() // Loop detection for fetch\n let currentCID: CID | undefined = rootCID\n let snapshotCount = 0\n\n while (currentCID && snapshotCount < maxDepth) {\n const cidStr = currentCID.toString()\n\n // Loop detection\n if (visited.has(cidStr)) {\n throw ERROR('[fetchSnapshotChain] snapshot chain has a loop', { currentCID: cidStr, visited: [...visited] })\n }\n visited.add(cidStr)\n\n // Check stop condition BEFORE fetching content\n if (stopAtCID && areCidsEqual(currentCID, stopAtCID)) {\n DEBUG('[fetchSnapshotChain] reached stopAtCID, stopping', stopAtCID.toString())\n break // We've reached the last pulled snapshot - don't fetch it again\n }\n\n // 1. Fetch root block only (dag-scope=block)\n DEBUG('[fetchSnapshotChain] fetching root block', cidStr)\n const rootCar = await fetchBlock(currentCID)\n await addCarBlocksToStore(rootCar, blockStore)\n\n // Parse root to get applogs, info, prev CIDs\n const rootBytes = await blockStore.get(currentCID)\n if (!rootBytes) {\n throw ERROR('[fetchSnapshotChain] root block not in store after fetch', { currentCID: cidStr })\n }\n const root = dagJson.decode(rootBytes) as SnapRootBlock\n\n // 2. Fetch applogs with dag-scope=all (gets applogs block + all linked applog blocks)\n DEBUG('[fetchSnapshotChain] fetching applogs', root.applogs.toString())\n const applogsCar = await fetchAll(root.applogs)\n await addCarBlocksToStore(applogsCar, blockStore)\n\n // 3. Fetch info with dag-scope=all (gets info block + all linked info log blocks)\n DEBUG('[fetchSnapshotChain] fetching info', root.info.toString())\n const infoCar = await fetchAll(root.info)\n await addCarBlocksToStore(infoCar, blockStore)\n\n snapshotCount++\n currentCID = root.prev // Move to previous snapshot\n }\n\n DEBUG('[fetchSnapshotChain] done', { snapshotCount, rootCID: rootCID.toString() })\n return { rootCID, blockStore, blocks: blockStore.getBlocksArray(), snapshotCount }\n}\n\nasync function addCarBlocksToStore(car: CarReader, store: BlockStoreForFetch) {\n for await (const { cid, bytes } of car.blocks()) {\n const validCid = typeof cid.toV1 === 'function' ? cid : CID.decode(cid.bytes)\n await store.put(validCid, bytes)\n }\n}\n\ninterface MemoryBlockStoreWithBlocks extends BlockStoreForFetch {\n /** Get all blocks as serializable array */\n getBlocksArray(): [string, Uint8Array][]\n}\n\nfunction createMemoryBlockStore(): MemoryBlockStoreWithBlocks {\n const blocks = new Map<string, Uint8Array>()\n return {\n async get(cid: CID) {\n return blocks.get(cid.toV1().toString())\n },\n async put(cid: CID, bytes: Uint8Array) {\n blocks.set(cid.toV1().toString(), bytes)\n },\n getBlocksArray() {\n return Array.from(blocks.entries())\n },\n }\n}\n"],"mappings":";;;;;;;;AAOA,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,EAAO,MAAM,EAAO,IAAI;AA4BrE,eAAsB,wBAAwB,SAAuD;AACjG,QAAM,EAAE,SAAS,WAAW,YAAY,UAAU,WAAW,IAAI,IAAI;AACrE,QAAM,aAAa,uBAAuB;AAC1C,QAAM,UAAU,oBAAI,IAAY;AAChC,MAAI,aAA8B;AAClC,MAAI,gBAAgB;AAEpB,SAAO,cAAc,gBAAgB,UAAU;AAC3C,UAAM,SAAS,WAAW,SAAS;AAGnC,QAAI,QAAQ,IAAI,MAAM,GAAG;AACrB,YAAM,MAAM,kDAAkD,EAAE,YAAY,QAAQ,SAAS,CAAC,GAAG,OAAO,EAAE,CAAC;AAAA,IAC/G;AACA,YAAQ,IAAI,MAAM;AAGlB,QAAI,aAAa,aAAa,YAAY,SAAS,GAAG;AAClD,YAAM,oDAAoD,UAAU,SAAS,CAAC;AAC9E;AAAA,IACJ;AAGA,UAAM,4CAA4C,MAAM;AACxD,UAAM,UAAU,MAAM,WAAW,UAAU;AAC3C,UAAM,oBAAoB,SAAS,UAAU;AAG7C,UAAM,YAAY,MAAM,WAAW,IAAI,UAAU;AACjD,QAAI,CAAC,WAAW;AACZ,YAAM,MAAM,4DAA4D,EAAE,YAAY,OAAO,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
action,
|
|
22
22
|
autorun,
|
|
@@ -507,4 +507,4 @@ export {
|
|
|
507
507
|
withTimeout,
|
|
508
508
|
throwOnTimeout
|
|
509
509
|
};
|
|
510
|
-
//# sourceMappingURL=chunk-
|
|
510
|
+
//# sourceMappingURL=chunk-KVPEUWWR.min.js.map
|