Giter VIP home page Giter VIP logo

crosscall's Introduction

crosscall

postmessage rpc and events across origins

npm install crosscall

  • remote procedure calls and events between webpages
    even if they are on different origins

  • crosscall client opens the host page in an iframe or a popup
    the host can expose async functionality to the client
    crosscall mediates the client and host via postmessage

  • live demo

  • crosscall shares a similar interface with renraku

  • i'm currently using crosscall a lot in my authoritarian project

see example code until i write a real readme

crosscall's People

Contributors

chase-moskal avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

crosscall's Issues

Cleaner architecture to attach crosscall client to an existing iframe/popup?

current architecture

  • instancing crosscall Client spawns the host page in a new iframe or popup
  • it would be better if this was more optional, if it integrated nicely into an existing popup or iframe
  • as a workaround (or maybe just a solution), an existing iframe or popup's bound postMessage can be provided as a shim, which avoids spawning an iframe or popup
  • that has the downside simply of feeling gross, invoking the word 'shim' which feels like hacks

new architecture

  • could a new architecture make it feel less hacky, to have to provide a shim?
  • maybe postMessage could be a first-class option rather than a shim
  • maybe all the shims should be made first-class options rather than have this 'shim' label at all

maybe the whole idea should be scrapped and it should stay the way it is.. food for thought

Readme improvements

  • explain some use-cases
  • explain iframe and popup usage contexts
  • highlight seamless callable interface featuring typings
  • developer walkthrough broadly explains crosscall's sourcecode

Refactor callee and permissions, move events under topics

const host = new crosscall.Host({

  // NEW CALLEE
  callee: {
    exampleTopic: {
      methods: {
        async exampleMethodAlpha(a) { return a + 1 },
        async exampleMethodBravo(a, b) { return a + b }
      },
      events: {
        exampleEvent: {
          listen(listener) {
            window.addEventListener("explosion", listener)
          },
          unlisten(listener) {
            window.removeEventListener("explosion", listener)
          }
        }
      }
    }
  },

  // NEW PERMISSIONS
  permissions: [{
    origin: /^http:\/\/localhost:8080$/,
    allowed: {
      exampleTopic: {
        methods: ["exampleMethodAlpha", "exampleMethodBravo"].
        events: ["exampleEvent"]
      }
    }
  }]
})

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.