Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mops inside web browser #165

Open
infu opened this issue Nov 5, 2023 · 3 comments
Open

Mops inside web browser #165

infu opened this issue Nov 5, 2023 · 3 comments
Assignees
Labels

Comments

@infu
Copy link

infu commented Nov 5, 2023

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

@ZenVoich
Copy link
Owner

ZenVoich commented Nov 6, 2023

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.

@infu
Copy link
Author

infu commented Nov 7, 2023

That will be very helpful yes.

@ZenVoich
Copy link
Owner

Implemented in mops 0.34.0

How to use:

  1. Add mops dependency:
npm i ic-mops
  1. 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)));
}

@ZenVoich ZenVoich self-assigned this Nov 14, 2023
@ZenVoich ZenVoich added the cli label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants