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

@robojs/patch

v0.2.0

Published

A collection of patches optimized for Robo.js projects.

Downloads

332

Readme


@robojs/patch

Tired of platform-specific bugs? Was your project working fine until recently? @robojs/patch is here to save the day! 🎩✨

This package contains a collection of lightweight patches for common issues. We intend on maintaining them for as long as needed.

Not using Robo.js yet? That's okay! Most patches work with any JavaScript project.

📚 Documentation: Getting started

🚀 Community: Join our Discord server

Installation 💻

To add this plugin to your Robo.js project:

npx robo add @robojs/patch

Or install it as a normal package if you're not using Robo.js:

npm install @robojs/patch

Patches 🩹

Discord Entry Point Command

If your Discord Activity is old or you're using the same Discord App for bots and activities, you may encounter issues with the entry point command missing as well as your activity's launch button.

This patch fixes those issues by adding the missing command to your Discord App when it goes missing. Automatically. Just by having this patch installed. 🎩✨

Please be sure to have both DISCORD_CLIENT_ID and DISCORD_TOKEN environment variables set in your .env file.

Discord Proxy

When running a Discord Activity through Discord, you may encounter Content Security Policy (CSP) issues. This patch fixes those issues, including Hot Module Replacement (HMR), by making sure internal requests follow Discord Proxy rules.

We have different ways to apply this patch depending on your project setup.

Method 1: Vite Plugin (Recommended)

If you're using Vite, you can apply the patch as a plugin in your Vite config file.

import { DiscordProxy } from '@robojs/patch'
import { defineConfig } from 'vite'

export default defineConfig({
	plugins: [DiscordProxy.Vite()]
})

[!TIP] You can find this file as /config/vite.mjs if you're using a Robo Template or vite.config.js if you're using something else.

We recommend this method because it allows the patch to run before before Vite's HMR client, ensuring that it works correctly.

Method 2: Function Call

If you're not using Vite, you can apply the patch by calling a function directly.

import { DiscordProxy } from '@robojs/patch'

DiscordProxy.patch()

Be sure to call this at the very beginning of your project, before other scripts are loaded. (e.g. the top of your index.js file)

How it works

This patch works by updating the fetch and WebSocket globals.

Each time a request is made, it makes sure that /.proxy is always included at the beginning of the URL's path. This comforms to the CSP policy set by the Discord Proxy.

This patch is extremely lightweight and only runs when needed. Nothing is patched when running outside of Discord.

External Requests

This does not affect requests made to external URLs. If you're having CSP issues with those, you may be able to fix them by creating your own Proxy or mapping them in the Discord Developer Portal.

📚 Tutorial: Resolve CSP Issues with a Proxy

Building Discord Apps?

Join our Discord Server to chat with other developers, ask questions, and share your projects. We're a friendly bunch and always happy to help! Plus, our very own AI Robo, Sage, is there to assist you with any questions you may have.

🚀 Community: Join our Discord server