Git Product home page Git Product logo

meteor's Introduction


Warning

Meteor is in a very early stage of development. Mainstream site support is not guaranteed. You can see our roadmap here.

The modern interception proxy you've been waiting for.

Meteor is a web proxy powered by service workers that intercepts HTTP requests and routes them through a Wisp server using bare-mux.

Installation

Meteor is a client-side JavaScript library. You can install it in your application in one of two ways:

  1. Hosting manually

Build Meteor's scripts by first cloning the repository, installing packages (pnpm install), running pnpm build and copy the files in the dist/ folder into a meteor folder in your application's folder.

  1. Serving a static path with a backend framework

meteorPath is exported from the meteorproxy NPM package, which resolves to a path in node_modules of built Meteor scripts. You can use this however you serve static directories in your backend framework.

Express:

import express from 'express'
import { meteorPath } from 'meteorproxy'

const app = express()
app.use("/meteor/", express.static(meteorPath)

Fastify:

import Fastify from 'fastify'
import fastifyStatic from '@fastify/static'
import { meteorPath } from 'meteorproxy'

Fastify()
  .register(fastifyStatic, {
    root: meteorPath,
    prefix: '/meteor/'
  })

You can use this path with the vite-plugin-static-copy Vite plugin in your Vite (or Vite-powered) app to copy Meteor scripts into your assets directory. Install vite-plugin-static-copy with your favorite package manager and use the path in the plugin's configuration.

import { defineConfig } from 'vite'
import { meteorPath } from 'meteorproxy'
import { viteStaticCopy } from 'vite-plugin-static-copy'

export default defineConfig({
  plugins: [
    // ...
    viteStaticCopy({
      targets: [
        {
          src: `${meteorPath}/meteor.*`.replace(/\\/g, "/"),
          dest: "meteor",
          overwrite: false,
        },
      ],
    })
  ]
})

Usage

Once you have the scripts served, register your service worker and set your transport on your frontend.

if ('serviceWorker' in navigator) {
    const registration = await navigator.serviceWorker.register('/sw.js')
    let connection = new BareMux.BareMuxConnection("/baremux/worker.js")
    await connection.setTransport(
      "/epoxy/index.mjs", // replace with your transport
      [{
        wisp: `wss://wisp-server-here.com`, // replace with the url of your wisp server
      }]
    )
  })
}

// After a button click or other event:
iframe.src = self.$meteor.util.formatUrl("https://google.com"") // replace with a chosen url

Important

During our testing, we've found that Meteor only supports being viewed inside iframes due to a limitation with bare-mux.

More in-depth usage and configuration will be coming soon in a Wiki.

Testing and development

Running pnpm demo will serve a UI to test Meteor, along with a dev server that watches for changes in the source code and re-builds accordingly.

meteor's People

Contributors

proudparrot2 avatar incognitotgt avatar notplayingallday383 avatar avad3 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.