tloncorp / eyrie

A perch for watching the %eyre

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eyrie

An app for testing the validity of %eyre and our %eyre client, @urbit/http-api

eyrie.mp4

Requirements

Currently eyrie requires at least version 2.4.3-debug of @urbit/http-api to work.

Getting Started

To install eyrie

npm install @tloncorp/eyrie

Then import:

import '@tloncorp/eyrie'

and now you can use anywhere you would a normal HTML element:

<tlon-eyrie />

You must pass eyrie your instance of the @urbit/http-api client so that it can listen to what's happening in the client, by calling the init method on the element:

//...
const api = new Urbit(...)
const eyrie = document.querySelector('tlon-eyrie');
eyrie.init({ api, onReset: () => ... }); 
//...

React Example

If you're using React here's a full example of how it can be used as a component you can include anywhere in your app:

import React, { useEffect, useRef } from 'react';
import '@tloncorp/eyrie';
import { Eyrie as Eyr } from '@tloncorp/eyrie';
import api from '@/api';

declare global {
  namespace JSX {
    interface IntrinsicElements {
      'tlon-eyrie': any;
    }
  }
}

export default function Eyrie() {
  const ref = useRef<Eyr>(null);

  useEffect(() => {
    ref.current?.init({ api });
  }, []);

  return <tlon-eyrie ref={ref} class="fixed bottom-4 right-4" />;
}

Desk

The desk currently contains a minimal gall agent for testing subscriptions. It responds to any subscriptions at the path /every/{duration} with a subscription that will give facts at every time interval given from the duration. The duration should be in the format of a typical @dr like ~s20.

UI

eyrie is mainly a React app which is wrapped inside a web component for ease of distribution to any web app regardless of framework and for encapsulation purposes so that we aren't polluting or getting polluted by the outside environment. We use Vite as both a way to serve an example UI for testing the component, but also to bundle the component for distribution.

About

A perch for watching the %eyre


Languages

Language:hoon 60.1%Language:TypeScript 36.3%Language:HTML 1.9%Language:CSS 0.9%Language:JavaScript 0.7%