npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ligolang/compact-ligo-ide

v3.0.3

Published

A React component for embedding Ligo code snippets on a page.

Downloads

13

Readme

A React component for embedding Ligo code snippets on a page.

Quick start

  1. Install package yarn add @ligolang/compact-ligo-ide
  2. Add CompactLigoIde component to a page
import { Code, Language } from "@ligolang/compact-ligo-ide";

const App = () => {
  const codeWithConfig = `(*_*
  name: CameLigo Contract
  dryRun:
    entrypoint: main
    parameters: Increment 2
    storage: 0
*_*)
// variant defining pseudo multi-entrypoint actions

type action is
| Increment of int
| Decrement of int

function add (const a : int ; const b : int) : int is
  block { skip } with a + b

function subtract (const a : int ; const b : int) : int is
  block { skip } with a - b

// real entrypoint that re-routes the flow based
// on the action provided
function main (const p : action ; const s : int) :
  (list(operation) * int) is
  block { skip } with ((nil : list(operation)),
  case p of
  | Increment(n) -> add(s, n)
  | Decrement(n) -> subtract(s, n)
  end)`;

  const editor = {
    title: 'Smart Contract',
    language: Language.CameLigo
  };
  const compile = {
    entrypoint: 'main'
  };
  const dryRun = {
    entrypoint: 'main',
    parameters: 'Increment 1',
    storage: '0'
  };
  const deploy = {
    entrypoint: 'main',
    storage: '0'
  };
  const evaluateFunction = {
    entrypoint: 'add',
    parameters: '5, 3'
  };

  return <CompactLigoIde
    theme="light"
    editor={editor}
    compile={compile}
    dryRun={dryRun}
    deploy={deploy}
    evaluateFunction={evaluateFunction}>
    {codeWithConfig}
  </CompactLigoIde>
};
  1. Apply styling
<style type="text/css">
  .compactLigoIde {
    height: 600px;
    width: 600px;
  }
</style>

Configuration

Compact Ligo IDE can be configured via component parameters and/or by passing configuration as a child. The example above illustrastes how to do so.

Available configuration

interface CompactLigoIdeProps {
  editor?: Partial<EditorConfig>;
  compile?: Partial<CompileConfig>;
  dryRun?: Partial<DryRunConfig>;
  deploy?: Partial<DeployConfig>;
  evaluateFunction?: Partial<EvaluateFunctionConfig>;
  evaluateValue?: Partial<EvaluateValueConfig>;
  result?: string;
  webIdeUrl?: string;
  theme?: "dark" | "light";
  children?: string;
}

interface EditorConfig {
  language: Language;
  code: string;
  dirty: boolean;
  title: string;
}

interface CompileConfig {
  entrypoint: string;
}

interface DryRunConfig {
  entrypoint: string;
  parameters: string;
  storage: string;
}

interface DeployConfig {
  entrypoint: string;
  storage: string;
}

interface EvaluateFunctionConfig {
  entrypoint: string;
  parameters: string;
}

interface EvaluateValueConfig {
  entrypoint: string;
}

Alternatively, the component can be configured by passing the configuration like so:

(*_*
  name: PascaLIGO Contract
  language: pascaligo
  compile:
    entrypoint: main
  dryRun:
    entrypoint: main
    parameters: Increment (1)
    storage: 0
  deploy:
    entrypoint: main
    storage: 0
  evaluateValue:
    entrypoint: ""
  evaluateFunction:
    entrypoint: add
    parameters: (5, 6)
*_*)
// variant defining pseudo multi-entrypoint actions
type action is
| Increment of int
| Decrement of int

function add (const a : int ; const b : int) : int is
  block { skip } with a + b

function subtract (const a : int ; const b : int) : int is
  block { skip } with a - b

// real entrypoint that re-routes the flow based
// on the action provided
function main (const p : action ; const s : int) :
  (list(operation) * int) is
  block { skip } with ((nil : list(operation)),
  case p of
  | Increment(n) -> add(s, n)
  | Decrement(n) -> subtract(s, n)
  end)

Contribute

Starting dev server

  1. Install dependencies with yarn install
  2. Run yarn start
  3. Open http://localhost:1234 in a browser

Build package

Run yarn build.

Publish package

Run npm publish --access=public.