open-index/open-npm huggingface dataset:
npm package: @insertish/isomorphic-ws
Description: Isomorphic implementation of WebSocket
Author: @heineiuo
Latest version: 4.0.1

# isomorphic-ws

Isomorphic implementation of WebSocket.

It uses:
- [ws](https://github.com/websockets/ws) on Node
- [global.WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) in browsers

## Limitations

Before using this module you should know that
[`ws`](https://github.com/websockets/ws/blob/master/doc/ws.md#class-websocket)
is not perfectly API compatible with
[WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket),
you should always test your code against both Node and browsers.

Some major differences:

- no `Server` implementation in browsers
- no support for the constructor
  [`options`](https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketaddress-protocols-options)
  argument in browsers

## Usage

You need to install both this package and [ws](https://github.com/websockets/ws):

```
> npm i isomorphic-ws ws
```

Then just require this package:

```js
const WebSocket = require('isomorphic-ws');

const ws = new WebSocket('wss://echo.websocket.org/');

ws.onopen = function open() {
  console.log('connected');
  ws.send(Date.now());
};

ws.onclose = function close() {
  console.log('disconnected');
};

ws.onmessage = function incoming(data) {
  console.log(`Roundtrip time: ${Date.now() - data.data} ms`);

  setTimeout(function timeout() {
    ws.send(Date.now());
  }, 500);
};
```

## License

[MIT](LICENSE)
npm package: @insertish/mutable
Description: Mutable object utilities.
Author: Paul Makles
Latest version: 1.1.0

![npm](https://img.shields.io/npm/v/@insertish/mutable?style=flat-square)

### Why?

The use-case of this library is for when you need to monitor mutations for a set of objects.

- When taking an object from the map, you will get a reference as JS passes objects by reference.
- This means everywhere you use the object will have the latest version of the object.
- Then to monitor mutations, we use a Proxy on the object internally which feeds into an EventEmitter on the map.

You may be wondering if something like Redux would do the job, probably, but it gets a bit messy when you also want to persist all the data, i.e. you're serializing and writing huge amounts of data for every small little change.

The solution is to wrap every object internally and catch any mutations on the objects.
- For any mutation, events are emitted which can be used to re-render React elements which use that relevant data.
- And for any mutation, we can also update IndexedDB with the new partial data, instead of re-saving everything.

### Example Usage

```typescript
import { MutableMap } from '@insertish/mutable';

type User = {
    _id: string
    username: string
    online: boolean
    flag: number
}

class Users extends MutableMap<User> {
    updateUsername(id: string, username: string) {
        // we would call an API here to verify we can do this
        // and then use Reflect to set the correct field
        this.map[id].username = username;
    }
}

let map = new Users();

map.on('create', item => console.log('Created user', item));
map.on('delete', id => console.log('Deleted user with id', id));
map.on('mutation', (user: User, property: string) => console.log('User', user._id, 'has had property', property, 'changed!'));

map.create({ _id: '123', username: 'aaa', online: true, flag: 0 });

let user = map.get('123');
map.updateUsername('123', 'bbb');
map.updateUsername('123', 'bbb'); // Internally, we use lodash.isEqual to prevent multiple events firing.
console.log(JSON.stringify(user)); // Since it's a normal object, we can just serialize it if we want.

map.set({ _id: '456', username: 'bbb', online: false, flag: 0 });
map.set({ _id: '456', username: 'bbb', online: false, flag: 8 });
map.patch('456', { online: true });
map.patch('123', { flag: 1 });
map.delete('456');
```

### Usage with IndexedDB

To use with IDB, simply pass a ZangoDB collection in. (reliance on this library isn't necessary, but I am already using it elsewhere in the project this is going to be used in, feel free to PR to use just IDB)

```typescript
import { Db } from '@insertish/zangodb';
let db = new Db('state', 1, [ 'users' ]);

let map = new MutableMap<T>(db.collection('users'));

// After constructing, always reload state first.
map.restore(); // -> Promise<void>

// All changes are automatically saved to IDB.
```
npm package: @insertish/oapi
Description: API Library Generator for OpenAPI
Author: Paul Makles
Latest version: 0.2.6

# OAPI Client

This is a CLI for auto-generating an API library for a given OpenAPI spec which uses JSON primarily and conforms to Revolt's API style.

Thank you to [bree](https://bree.dev/) for helping me figure out all the especially difficult types.

## Goals

- Commit programming atrocities internally.
- Pretend everything is fine externally.
- Provide a simple strongly typed API experience to the user.

## Example

Here's what you can achieve with this library:

```typescript
import { API } from "your-api";

let id = "user_id";

// By default, we use the first server specified in the API spec.
new API()
	// Path parameters are specified using template strings.
	.get(`/users/${id}`)
	.then((user) => {
		// User is still fully typed!
		return user.username;
	})
	.then(console.log);
```

Conflict resolution is also automatic, so conflicting prefixes will not cause issues:

```typescript
import { API } from "your-api";

// For a route /some/{string}:
new API().get("/some/this is an example").then((x) => {
	x; // number
});

// For a route /some/{string}/conflicting:
new API().get("/some/this is an example/conflicting").then((x) => {
	x; // string
});
```

You can also provide your query and body parameters at the same time:

```typescript
import { API } from "your-api";

// PATCH /users/@me?preserve=true
// Body: { username: string }
new API().patch(`/users/@me`, {
	// Specify query parameters
	preserve: true,
	// Or body parameters
	username: "something",
});
```

This removes the overhead of having to remember exactly what goes where and provides a much nicer (and still strongly typed) API experience.

Currently this only supports rauth and Revolt authentication, but you can still provide your own Axios config or add your own authentication.

```typescript
new API({
	baseURL: "https://example.com",
	authentication: {
		rauth: "session token",
	},
});
```

## Setup Guide

Create a new project and configure it:

```sh
yarn init
yarn add @insertish/oapi axios lodash.defaultsdeep
yarn add --dev typescript openapi-typescript @types/lodash.defaultsdeep
```

Place your OpenAPI specification at the root of your API library at `OpenAPI.json`.

Update your `package.json` to include the following:

```json
{
    [...],
    "scripts": {
        "build": "oapilib && tsc"
    }
}
```

**Note**: you may want to use `STRICT=1 opailib`, see "Strict Mode" below.

Setup Typescript:

```sh
yarn exec tsc -- --init
```

Change `tsconfig.json` to include:

```json
{
	"compilerOptions": {
		"outDir": "./dist",
		"rootDir": "./src",
		"declaration": true
	}
}
```

Create a new `src` directory.

Now generate the library: (`src` folder will be overwritten!)

```sh
yarn build
```

## Replace `anyOf` with `oneOf`

If your spec uses `anyOf`, the values are mapped as an intersection while you may actually want all of these values to be treated as if they were `oneOf`, or otherwise a union.

You can specify the environment variable `REWRITE_ANYOF` to any truthy value.

```sh
REWRITE_ANYOF=1 oapilib
```
npm package: @insertish/utterances
Description: React component for utterances
Author: Yeongjun Kim
Latest version: 0.1.3-patch.1

# utterances-react

[![npm version](https://badge.fury.io/js/utterances-react.svg)](https://badge.fury.io/js/utterances-react)
[![GitHub version](https://badge.fury.io/gh/wicksome%2Futterances-react.svg)](https://badge.fury.io/gh/wicksome%2Futterances-react)

This is React component for [utterances][utterances]

## Install

```bash
# npm
$ npm i utterances-react
# yarn
$ yarn add utterances-react
```

## Usage

```js
import Utterances from "utterances-react"

export default ({ data }) => {
  return (
    <Utterances
      repo="wicksome/utterances-react"
      issueTerm="pathname"
      label=""
      theme="github-light"
      crossorigin="anonymous"
      async={false}
      style={`
        & .utterances {
          max-width: 950px;
        }
    `}
    />
  )
}
```

## License

MIT

[utterances]: https://utteranc.es/
npm package: @insertish/vite
Description: Native-ESM powered web dev build tool
Author: Evan You
Latest version: 2.4.0-beta.3-dynamic-import-css-3c1466b

# vite ⚡

> Next Generation Frontend Tooling

- 💡 Instant Server Start
- ⚡️ Lightning Fast HMR
- 🛠️ Rich Features
- 📦 Optimized Build
- 🔩 Universal Plugin Interface
- 🔑 Fully Typed APIs

Vite (French word for "fast", pronounced `/vit/`) is a new breed of frontend build tool that significantly improves the frontend development experience. It consists of two major parts:

- A dev server that serves your source files over [native ES modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), with [rich built-in features](https://vitejs.dev/guide/features.html) and astonishingly fast [Hot Module Replacement (HMR)](https://vitejs.dev/guide/features.html#hot-module-replacement).

- A [build command](https://vitejs.dev/guide/build.html) that bundles your code with [Rollup](https://rollupjs.org), pre-configured to output highly optimized static assets for production.

In addition, Vite is highly extensible via its [Plugin API](https://vitejs.dev/guide/api-plugin.html) and [JavaScript API](https://vitejs.dev/guide/api-javascript.html) with full typing support.

[Read the Docs to Learn More](https://vitejs.dev).
npm package: @insertish/vite-plugin-babel-macros
Description: Use babel macros with vite (and custom Babel config)
Author: MapleLeaf
Latest version: 1.0.5

# vite-plugin-babel-macros

Use [babel macros](https://github.com/kentcdodds/babel-plugin-macros) in your [Vite](https://vitejs.dev) project!

## Install

```sh
npm install --dev vite-plugin-babel-macros
```

Then, add it to `vite.config.js` or `vite.config.ts`:

```js
import macrosPlugin from "vite-plugin-babel-macros"

export default {
	// ...
	plugins: [
		// ...
		macrosPlugin(),
	],
}
```
npm package: @insforge/shared
Description: Shared utilities and React contexts for Insforge packages
Author: Insforge
Latest version: 1.1.5

# @insforge/shared

Shared utilities, types, and React contexts for Insforge packages.

## Purpose

This package centralizes React Context definitions to prevent duplication issues when using `tsup` with multiple entry points. By defining contexts here, all Insforge packages (`@insforge/react`, `@insforge/nextjs`, etc.) import from the same source, ensuring a single Context instance.

## Architecture Pattern

Inspired by `@clerk/shared`, this package solves the Context duplication problem:

### The Problem

When using `bundle: true` with multiple entry points:

```typescript
// tsup.config.ts
entry: {
  index: 'src/index.ts',
  hooks: 'src/hooks/index.ts',
  components: 'src/components/index.ts'
}
```

Each entry point bundles its own copy of Context → Provider uses Context instance A, but components use Context instance B → `useContext` returns `undefined`.

### The Solution

1. **Centralized Context**: Define all Contexts in `@insforge/shared`
2. **External React**: Mark `react` as external in tsup config
3. **Shared Import**: All packages import Context from `@insforge/shared`

```typescript
// packages/shared/tsup.config.ts
export default defineConfig({
  external: ['react', 'react-dom'], // Critical!
  bundle: true,
});
```

## Exports

### Main Entry (`@insforge/shared`)

```typescript
import type { InsforgeUser, InsforgeContextValue, OAuthProvider } from '@insforge/shared';
```

### React Entry (`@insforge/shared/react`)

```typescript
import { InsforgeContext } from '@insforge/shared/react';
```

## Usage

This package is intended for internal use within the Insforge monorepo. Application developers should not need to import from it directly.

## License

MIT