@ixo/editor 3.0.0-beta.13 → 3.0.0-beta.15

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/lib/cid.ts"],"sourcesContent":["/**\n * Compute an IPFS-compatible CID for arbitrary content.\n * Dependencies are lazy-loaded to avoid bundling IPFS libraries\n * into the main entry point.\n *\n * Uses CIDv0 with raw leaves disabled to match ixo ecosystem conventions.\n */\nexport async function computeCID(content: Uint8Array): Promise<string> {\n const { MemoryBlockstore } = await import('blockstore-core/memory');\n const { importer } = await import('ipfs-unixfs-importer');\n\n let blockstore: InstanceType<typeof MemoryBlockstore> | null = new MemoryBlockstore();\n\n try {\n function* singleFile() {\n yield { path: 'file', content };\n }\n\n let fileCid: string | null = null;\n for await (const entry of importer(singleFile(), blockstore, {\n cidVersion: 0,\n rawLeaves: false,\n wrapWithDirectory: false,\n })) {\n fileCid = entry.cid.toString();\n }\n\n if (!fileCid) {\n throw new Error('Failed to compute CID');\n }\n return fileCid;\n } finally {\n blockstore = null;\n }\n}\n\n/**\n * Compute CID for a JSON object by stringifying and encoding to UTF-8.\n */\nexport async function computeJsonCID(obj: Record<string, any>): Promise<string> {\n const json = JSON.stringify(obj);\n const encoder = new TextEncoder();\n return computeCID(encoder.encode(json));\n}\n"],"mappings":";AAOA,eAAsB,WAAW,SAAsC;AACrE,QAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,wBAAwB;AAClE,QAAM,EAAE,SAAS,IAAI,MAAM,OAAO,sBAAsB;AAExD,MAAI,aAA2D,IAAI,iBAAiB;AAEpF,MAAI;AACF,cAAU,aAAa;AACrB,YAAM,EAAE,MAAM,QAAQ,QAAQ;AAAA,IAChC;AAEA,QAAI,UAAyB;AAC7B,qBAAiB,SAAS,SAAS,WAAW,GAAG,YAAY;AAAA,MAC3D,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,mBAAmB;AAAA,IACrB,CAAC,GAAG;AACF,gBAAU,MAAM,IAAI,SAAS;AAAA,IAC/B;AAEA,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,uBAAuB;AAAA,IACzC;AACA,WAAO;AAAA,EACT,UAAE;AACA,iBAAa;AAAA,EACf;AACF;AAKA,eAAsB,eAAe,KAA2C;AAC9E,QAAM,OAAO,KAAK,UAAU,GAAG;AAC/B,QAAM,UAAU,IAAI,YAAY;AAChC,SAAO,WAAW,QAAQ,OAAO,IAAI,CAAC;AACxC;","names":[]}