@wovin/core 0.1.25 → 0.1.27

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 (46) hide show
  1. package/dist/applog.min.js +2 -1
  2. package/dist/blockstore/index.d.ts +21 -0
  3. package/dist/blockstore/index.d.ts.map +1 -0
  4. package/dist/blockstore.d.ts +2 -0
  5. package/dist/blockstore.d.ts.map +1 -0
  6. package/dist/blockstore.min.js +26 -0
  7. package/dist/blockstore.min.js.map +1 -0
  8. package/dist/{chunk-ZGU3O24G.min.js → chunk-CWVWWFE3.min.js} +6 -6
  9. package/dist/chunk-CWVWWFE3.min.js.map +1 -0
  10. package/dist/{chunk-USEP3ZEM.min.js → chunk-LHD7NNK6.min.js} +2 -2
  11. package/dist/{chunk-ITZTLALV.min.js → chunk-MCMSRRF7.min.js} +2 -2
  12. package/dist/chunk-MCMSRRF7.min.js.map +1 -0
  13. package/dist/{chunk-SA7YLEF6.min.js → chunk-N2LOFNFT.min.js} +20 -8
  14. package/dist/chunk-N2LOFNFT.min.js.map +1 -0
  15. package/dist/{chunk-CWGXD56S.min.js → chunk-NKGFXL72.min.js} +18 -13
  16. package/dist/{chunk-CWGXD56S.min.js.map → chunk-NKGFXL72.min.js.map} +1 -1
  17. package/dist/chunk-QO2KMGDN.min.js +3771 -0
  18. package/dist/chunk-QO2KMGDN.min.js.map +1 -0
  19. package/dist/{chunk-R7EMHBM3.min.js → chunk-XWBLRTV5.min.js} +783 -4064
  20. package/dist/chunk-XWBLRTV5.min.js.map +1 -0
  21. package/dist/{chunk-HHFNRKOI.min.js → chunk-YUH56CPQ.min.js} +2 -2
  22. package/dist/index.min.js +16 -13
  23. package/dist/ipfs.min.js +5 -4
  24. package/dist/ipns/ipns-record.d.ts +34 -0
  25. package/dist/ipns/ipns-record.d.ts.map +1 -0
  26. package/dist/ipns.d.ts +2 -0
  27. package/dist/ipns.d.ts.map +1 -0
  28. package/dist/ipns.min.js +6419 -0
  29. package/dist/ipns.min.js.map +1 -0
  30. package/dist/pubsub/pubsub-types.d.ts +1 -1
  31. package/dist/pubsub/pubsub-types.d.ts.map +1 -1
  32. package/dist/pubsub/snap-push.d.ts +2 -2
  33. package/dist/pubsub/snap-push.d.ts.map +1 -1
  34. package/dist/pubsub.min.js +5 -4
  35. package/dist/query.min.js +4 -3
  36. package/dist/retrieve/update-thread.d.ts +8 -1
  37. package/dist/retrieve/update-thread.d.ts.map +1 -1
  38. package/dist/retrieve.min.js +9 -6
  39. package/dist/thread.min.js +2 -1
  40. package/package.json +11 -1
  41. package/dist/chunk-ITZTLALV.min.js.map +0 -1
  42. package/dist/chunk-R7EMHBM3.min.js.map +0 -1
  43. package/dist/chunk-SA7YLEF6.min.js.map +0 -1
  44. package/dist/chunk-ZGU3O24G.min.js.map +0 -1
  45. /package/dist/{chunk-USEP3ZEM.min.js.map → chunk-LHD7NNK6.min.js.map} +0 -0
  46. /package/dist/{chunk-HHFNRKOI.min.js.map → chunk-YUH56CPQ.min.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/retrieve/update-thread.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 { Applog } from '../applog/datom-types'\nimport { removeDuplicateAppLogs } from '../applog/applog-utils'\nimport type { SnapRootBlock, SnapBlockLogsOrChunks } from '../pubsub/pubsub-types'\nimport { unchunkApplogsBlock } from '../pubsub/snap-push'\nimport { areCidsEqual } from '../ipfs/ipfs-utils'\nimport type { WriteableThread } from '../thread/writeable'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\n/**\n * Block retrieval abstraction - fetch or get blocks.\n * Implemented by gateway retriever or local blockstore.\n */\nexport interface BlockRetriever {\n\t/** Get single block by CID */\n\tgetBlock(cid: CID): Promise<Uint8Array>\n\t/** Get all blocks in DAG rooted at CID (for applogs/info sub-DAGs) */\n\tgetDag(cid: CID): AsyncIterable<{ cid: CID; bytes: Uint8Array }>\n}\n\n/**\n * Options for updateThreadFromSnapshot\n */\nexport interface UpdateOptions {\n\t/** CID of last included snapshot - exclude this and older snapshots */\n\texcludeSnapshotCID?: CID\n\t/** Stop when we reach this counter (walking backwards) */\n\tstopAtCounter?: number\n\t/** Maximum number of snapshots to traverse (default: 100) */\n\tmaxDepth?: number\n}\n\n/**\n * Result from updateThreadFromSnapshot\n */\nexport interface UpdateResult {\n\t/** Root CID that was fetched */\n\tcid: CID\n\t/** All applogs decoded from the chain */\n\tapplogs: Applog[]\n\t/** Count of applogs actually inserted (not duplicates) */\n\tinsertedCount: number\n\t/** Number of snapshots traversed */\n\tsnapshotCount: number\n\t/** Counter range encountered (min/max) */\n\tcounterRange?: { minCounter: number; maxCounter: number }\n}\n\n/**\n * Simple in-memory block store used during snapshot chain fetch.\n */\ninterface MemoryBlockStore {\n\tget(cid: CID): Uint8Array | undefined\n\tput(cid: CID, bytes: Uint8Array): void\n}\n\nfunction createMemoryBlockStore(): MemoryBlockStore {\n\tconst blocks = new Map<string, Uint8Array>()\n\treturn {\n\t\tget(cid: CID) {\n\t\t\treturn blocks.get(cid.toV1().toString())\n\t\t},\n\t\tput(cid: CID, bytes: Uint8Array) {\n\t\t\tblocks.set(cid.toV1().toString(), bytes)\n\t\t},\n\t}\n}\n\nasync function getDecodedBlock<T>(blockStore: MemoryBlockStore, cid: CID): Promise<T | null> {\n\tconst bytes = blockStore.get(cid)\n\tif (!bytes) return null\n\treturn dagJson.decode(bytes) as T\n}\n\n/**\n * Fetch snapshot chain from CID using a BlockRetriever, decode applogs, insert into thread.\n * Stops before excludeSnapshotCID if provided (incremental update).\n *\n * @param thread - WriteableThread to insert applogs into\n * @param cid - Root CID of the snapshot to start from\n * @param retriever - BlockRetriever for fetching blocks\n * @param options - Optional configuration\n * @returns UpdateResult with applogs and counts\n */\nexport async function updateThreadFromSnapshot(\n\tthread: WriteableThread,\n\tcid: CID,\n\tretriever: BlockRetriever,\n\toptions?: UpdateOptions\n): Promise<UpdateResult> {\n\tconst { excludeSnapshotCID, stopAtCounter, maxDepth = 100 } = options ?? {}\n\n\tDEBUG('[updateThreadFromSnapshot] starting from', cid.toString(), {\n\t\texcludeSnapshotCID: excludeSnapshotCID?.toString(),\n\t\tstopAtCounter,\n\t\tmaxDepth,\n\t})\n\n\tconst blockStore = createMemoryBlockStore()\n\tconst visited = new Set<string>()\n\tlet currentCID: CID | undefined = cid\n\tlet snapshotCount = 0\n\tconst allApplogs: Applog[] = []\n\tlet minCounter = Infinity\n\tlet maxCounter = -Infinity\n\tlet lastCounter: number | undefined\n\n\twhile (currentCID && snapshotCount < maxDepth) {\n\t\tconst cidStr = currentCID.toString()\n\n\t\t// Loop detection\n\t\tif (visited.has(cidStr)) {\n\t\t\tthrow ERROR('[updateThreadFromSnapshot] snapshot chain has a loop', {\n\t\t\t\tcurrentCID: cidStr,\n\t\t\t\tvisited: [...visited],\n\t\t\t})\n\t\t}\n\t\tvisited.add(cidStr)\n\n\t\t// Check stop condition BEFORE fetching content\n\t\tif (excludeSnapshotCID && areCidsEqual(currentCID, excludeSnapshotCID)) {\n\t\t\tDEBUG('[updateThreadFromSnapshot] reached excludeSnapshotCID, stopping', excludeSnapshotCID.toString())\n\t\t\tbreak\n\t\t}\n\n\t\t// 1. Fetch root block\n\t\tDEBUG('[updateThreadFromSnapshot] fetching root block', cidStr)\n\t\tconst rootBytes = await retriever.getBlock(currentCID)\n\t\tblockStore.put(currentCID, rootBytes)\n\n\t\t// Parse root to get applogs, info, prev CIDs\n\t\tconst root = dagJson.decode(rootBytes) as SnapRootBlock\n\n\t\t// Track counter range and validate sequentiality\n\t\tif (root.prevCounter !== undefined) {\n\t\t\tminCounter = Math.min(minCounter, root.prevCounter)\n\t\t\tmaxCounter = Math.max(maxCounter, root.prevCounter)\n\n\t\t\t// Validate sequentiality (walking backwards, counter should decrease)\n\t\t\tif (lastCounter !== undefined && root.prevCounter !== lastCounter - 1) {\n\t\t\t\tWARN('[updateThreadFromSnapshot] counter gap detected', {\n\t\t\t\t\texpected: lastCounter - 1,\n\t\t\t\t\tgot: root.prevCounter,\n\t\t\t\t})\n\t\t\t}\n\t\t\tlastCounter = root.prevCounter\n\t\t}\n\n\t\t// Stop condition based on counter\n\t\tif (stopAtCounter !== undefined && root.prevCounter !== undefined && root.prevCounter <= stopAtCounter) {\n\t\t\tDEBUG('[updateThreadFromSnapshot] reached stopAtCounter', { stopAtCounter, prevCounter: root.prevCounter })\n\t\t\tbreak\n\t\t}\n\n\t\t// 2. Fetch applogs DAG\n\t\tDEBUG('[updateThreadFromSnapshot] fetching applogs', root.applogs.toString())\n\t\tfor await (const { cid: blockCid, bytes } of retriever.getDag(root.applogs)) {\n\t\t\tblockStore.put(blockCid, bytes)\n\t\t}\n\n\t\t// 3. Fetch info DAG\n\t\tDEBUG('[updateThreadFromSnapshot] fetching info', root.info.toString())\n\t\tfor await (const { cid: blockCid, bytes } of retriever.getDag(root.info)) {\n\t\t\tblockStore.put(blockCid, bytes)\n\t\t}\n\n\t\t// Decode applogs from this snapshot\n\t\tconst applogsBlock = await getDecodedBlock<SnapBlockLogsOrChunks>(blockStore, root.applogs)\n\t\tif (!applogsBlock) {\n\t\t\tthrow ERROR('[updateThreadFromSnapshot] applogs block not found', { cid: root.applogs.toString() })\n\t\t}\n\n\t\t// Use the unchunk helper which handles both chunked and non-chunked formats\n\t\tconst applogCIDs = await unchunkApplogsBlock(applogsBlock, {\n\t\t\tget: async (cid: CID) => blockStore.get(cid)!,\n\t\t})\n\n\t\t// Resolve each applog CID to actual applog data\n\t\tfor (const applogCID of applogCIDs) {\n\t\t\tconst applog = await getDecodedBlock<Applog>(blockStore, applogCID)\n\t\t\tif (!applog) {\n\t\t\t\tWARN('[updateThreadFromSnapshot] applog not found:', applogCID.toString())\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Normalize pv field if it's a CID instance\n\t\t\tif ((applog.pv as any) instanceof CID) {\n\t\t\t\tapplog.pv = (applog.pv as any as CID).toV1().toString()\n\t\t\t}\n\t\t\tallApplogs.push({\n\t\t\t\t...applog,\n\t\t\t\tcid: applogCID.toV1().toString(),\n\t\t\t})\n\t\t}\n\n\t\tsnapshotCount++\n\t\tcurrentCID = root.prev // Move to previous snapshot\n\t}\n\n\tDEBUG('[updateThreadFromSnapshot] fetched', {\n\t\tsnapshotCount,\n\t\tapplogCount: allApplogs.length,\n\t\trootCID: cid.toString(),\n\t})\n\n\t// Deduplicate applogs (in case of overlapping snapshots)\n\tconst deduplicated = removeDuplicateAppLogs(allApplogs, 'cleanup')\n\n\t// Insert into thread\n\tconst inserted = thread.insertMissing(deduplicated, false)\n\n\tDEBUG('[updateThreadFromSnapshot] inserted', {\n\t\tinsertedCount: inserted.length,\n\t\tduplicateCount: deduplicated.length - inserted.length,\n\t})\n\n\treturn {\n\t\tcid,\n\t\tapplogs: deduplicated,\n\t\tinsertedCount: inserted.length,\n\t\tsnapshotCount,\n\t\tcounterRange: minCounter !== Infinity ? { minCounter, maxCounter } : undefined,\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,EAAO,MAAM,EAAO,IAAI;AAiDrE,SAAS,yBAA2C;AACnD,QAAM,SAAS,oBAAI,IAAwB;AAC3C,SAAO;AAAA,IACN,IAAI,KAAU;AACb,aAAO,OAAO,IAAI,IAAI,KAAK,EAAE,SAAS,CAAC;AAAA,IACxC;AAAA,IACA,IAAI,KAAU,OAAmB;AAChC,aAAO,IAAI,IAAI,KAAK,EAAE,SAAS,GAAG,KAAK;AAAA,IACxC;AAAA,EACD;AACD;AAEA,eAAe,gBAAmB,YAA8B,KAA6B;AAC5F,QAAM,QAAQ,WAAW,IAAI,GAAG;AAChC,MAAI,CAAC,MAAO,QAAO;AACnB,SAAe,OAAO,KAAK;AAC5B;AAYA,eAAsB,yBACrB,QACA,KACA,WACA,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IAC5C,eAAe,SAAS;AAAA,IACxB,gBAAgB,aAAa,SAAS,SAAS;AAAA,EAChD,CAAC;AAED,SAAO;AAAA,IACN;AAAA,IACA,SAAS;AAAA,IACT,eAAe,SAAS;AAAA,IACxB;AAAA,IACA,cAAc,eAAe,WAAW,EAAE,YAAY,WAAW,IAAI;AAAA,EACtE;AACD;","names":["cid"]}
@@ -1 +0,0 @@
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 stopAtCounter?: number // Stop when we reach this counter (walking backwards)\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 counterRange?: { minCounter: number; maxCounter: 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, stopAtCounter, 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 let minCounter = Infinity\n let maxCounter = -Infinity\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 // Track counter range\n if (root.prevCounter !== undefined) {\n minCounter = Math.min(minCounter, root.prevCounter)\n maxCounter = Math.max(maxCounter, root.prevCounter)\n }\n\n // Stop condition based on counter\n if (stopAtCounter !== undefined && root.prevCounter !== undefined && root.prevCounter <= stopAtCounter) {\n DEBUG('[fetchSnapshotChain] reached stopAtCounter', { stopAtCounter, prevCounter: root.prevCounter })\n break\n }\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 {\n rootCID,\n blockStore,\n blocks: blockStore.getBlocksArray(),\n snapshotCount,\n counterRange: minCounter !== Infinity ? { minCounter, maxCounter } : undefined,\n }\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;AA8BrE,eAAsB,wBAAwB,SAAuD;AACjG,QAAM,EAAE,SAAS,WAAW,eAAe,YAAY,UAAU,WAAW,IAAI,IAAI;AACpF,QAAM,aAAa,uBAAuB;AAC1C,QAAM,UAAU,oBAAI,IAAY;AAChC,MAAI,aAA8B;AAClC,MAAI,gBAAgB;AACpB,MAAI,aAAa;AACjB,MAAI,aAAa;AAEjB,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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