mops
mops copied to clipboard
Mops inside web browser
I want to mops libraries in Blast, but importing this module probably wont work. You probably won't be making a browser client. All I need to know how to get its packages. I assume they are zipped and stored inside a canister somehow
To search packages you can use main actor from ic-mops npm package.
Packages are not zipped, and can be downloaded. I can move files downloading logic to a separate function and expose it, would it be helpful? Let's say it will return mapping filename->source for a package.
That will be very helpful yes.
Implemented in mops 0.34.0
How to use:
- Add mops dependency:
npm i ic-mops
- Search and download:
import {mainActor, downloadPackageFiles} from 'ic-mops/api';
let mopsActor = await mainActor();
// search
let limit = 100n;
let searchText = 'ba';
let [packages, _pageCount] = await mopsActor.search(searchText, [limit], []);
console.log(packages.map((pkg) => {
return pkg.config.name;
}));
// download
let files = await downloadPackageFiles('base');
// or with version
// let files = await downloadPackageFiles('base', '0.10.1');
for (let [filename, data] of files.entries()) {
console.log(filename, new TextDecoder().decode(new Uint8Array(data)));
}