UNPKG

@reclaimprotocol/browser-extension-sdk

Version:

This guide will walk you through integrating the Reclaim Protocol Browser Extension SDK into your own browser extension or web application. It covers installation, manifest configuration, background initialization, content script setup, and how to trigg

2 lines 1.7 kB
#!/usr/bin/env node const fs=require("fs"),path=require("path"),cp=require("child_process");function parseArgs(){const e=process.argv.slice(2),n={};for(let o=0;o<e.length;o++){const[c,i]=e[o].split("=");c.startsWith("--")&&(n[c.replace(/^--/,"")]=i??!0)}return n}function ensureDir(e){fs.mkdirSync(e,{recursive:!0})}function copyFile(e,n){ensureDir(path.dirname(n)),fs.copyFileSync(e,n)}function copyDir(e,n){if(fs.existsSync(e)){ensureDir(n);for(const o of fs.readdirSync(e)){const c=path.join(e,o),i=path.join(n,o);fs.statSync(c).isDirectory()?copyDir(c,i):copyFile(c,i)}}}async function main(){const e=parseArgs(),n=process.cwd(),o=path.resolve(__dirname,".."),c=path.resolve(n,e["public-dir"]||"public");console.log("[reclaim] downloading circuits...");const i=path.join(o,"scripts","download-circuits.js");try{cp.execFileSync(process.execPath,[i],{stdio:"inherit",cwd:n})}catch(e){console.error("[reclaim] circuits download failed",e.message),process.exit(1)}console.log("[reclaim] copying assets...");const s=path.join(c,"reclaim-browser-extension-sdk");copyFile(path.join(o,"content","content.bundle.js"),path.join(s,"content","content.bundle.js")),copyDir(path.join(o,"content","components"),path.join(s,"content","components")),copyDir(path.join(o,"interceptor"),path.join(s,"interceptor")),copyDir(path.join(o,"offscreen"),path.join(s,"offscreen"));const t=path.join(o,"343.bundle.js");fs.existsSync(t)&&copyFile(t,path.join(c,"343.bundle.js")),copyFile(path.join(o,"ReclaimExtensionSDK.bundle.js"),path.join(c,"reclaim-browser-extension-sdk","ReclaimExtensionSDK.bundle.js")),console.log("[reclaim] setup complete")}main().catch(e=>{console.error("[reclaim] setup failed",e),process.exit(1)});