Giter VIP home page Giter VIP logo

ao-playground's Introduction

AOS Playground Logo

Welcome to the AOS Web Playground! Web Interface for 'ao' Permaweb Computer Grid ๐Ÿฐ ๐Ÿ•ณ๏ธ ๐Ÿ‘ˆ

Features โ€ข How it works? โ€ข Tech Stack โ€ข Try Now โ†—๏ธ

AOS Playground Image

Features

  • ๐ŸŒ Decentralized: AOS Playground is hosted on the Permaweb network.
  • โœจ Multi-modal Support: Multi-modal editor with a native file explorer built in.
  • ๐Ÿ“ฆ Resolved Imports: Import from other files in the explorer using pcall.
  • ๐Ÿ—ฃ๏ธ Language Formatting: Language formatting for Lua files using wasm module.
  • ๐Ÿž Debugging: Supports debugging using the Lua AST Parser.
  • ๐Ÿ’พ Persistence: Entire application is persisted using LocalStorage and IndexedDB.
  • ๐ŸŽจ Themes: Supports Multiple themes such as Andromeda, Poimandres, Github Light/Dark, Slack Ochin, and more

How it works?

AOS Playground is a web interface for the AO Operating System. It is hosted on the Permaweb network and uses the @permaweb/aoconnect SDK to interact with the network.

The main part of the application using monaco-editor by Microsoft. The editor is configured to support Lua language.

Language formatting is done using a custom compiled wasm module which runs in workers. (โŒ˜ + S to test it)

The core feature of the editor is module resolve and import. Let's take an example to see how it works

-- src/file1.lua

file1 = {
  message = "Message from File 1"
}
-- index.lua

local ok = pcall(require,".src.file1")

return file1.message

What happens when you run index.lua file?

First a Abstract Syntax Trr will be generated for the Lua file.

Abstract Syntax Tree for index.lua
{
  "type": "Chunk",
  "body": [
    {
      "type": "LocalStatement",
      "variables": [
        {
          "type": "Identifier",
          "name": "ok"
        }
      ],
      "init": [
        {
          "type": "CallExpression",
          "base": {
            "type": "Identifier",
            "name": "pcall"
          },
          "arguments": [
            {
              "type": "Identifier",
              "name": "require"
            },
            {
              "type": "StringLiteral",
              "value": null,
              "raw": "\".src.file1\""
            }
          ]
        }
      ]
    },
    {
      "type": "ReturnStatement",
      "arguments": [
        {
          "type": "MemberExpression",
          "indexer": ".",
          "identifier": {
            "type": "Identifier",
            "name": "message"
          },
          "base": {
            "type": "Identifier",
            "name": "file1"
          }
        }
      ]
    }
  ],
  "comments": [
    {
      "type": "Comment",
      "value": " index.lua",
      "raw": "-- index.lua"
    }
  ]
}

Then the content is traversed for any pcall statements. If a pcall statement is found, the value of the CallExpression is resolved in the local file explorer.

If the file is found then it recursively checks that file for other imports until there are no more imports.

Then the order of execution is determined and the files are executed in that order.

Why pcall instead of require?

The reason for using pcall is to catch any errors that might occur during the execution of the file. If an error occurs, the error is caught and the error message is returned instead of the throwing the actual error.

Tech Stack

  • Frontend: React, TypeScript, TailwindCSS, @shadcn/ui
  • Editor: Monaco Editor, skiki (Syntax highlighting)
  • Persistence: Dexie and LocalStorage
  • Querying: React Query
  • AO Operations: @permaweb/aoconnect
  • Language Formatting: Custom compiled wasm module
  • Debugging: Lua AST Parser

License

MIT

ao-playground's People

Contributors

envoy-vc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.