open-index/open-npm huggingface dataset:
npm package: @hyrfilm/workhorse
Description: Transactional task queue for the browser with support for OPFS, localStorage, sessionStorage, in-memory
Author: Jonas Holmer
Latest version: 0.3.1

# workhorse [![codecov](https://codecov.io/gh/hyrfilm/workhorse/graph/badge.svg?token=4371ZQKKQ0)](https://codecov.io/gh/hyrfilm/workhorse)

## persistent task queue for the browser
[demo page](https://hyrfilm.github.io/workhorse)

Depending on your use-case can be configured with various forms of guarentees:
* once-and-only-once execution
* guaranteed ordering
* transactional (full ACID-support)
* Fully in-memory taskquees or using the high performance file system (OPFS)
* extensively property / fuzz testing in regards to concurrency (deadlocks, race-conditions etc)
* performance: tested with a concurrency settings up a setting of 1000 consumers (eg a 1000 simulatanous uploads/downloads)
* observability
* extensibility in terms of plugins

Implemented using SQLite running in webworkers.

## brief overview
```mermaid
graph TD
    %% User Interaction
    API["API (queue, poll, run, requeue, getStatus, startPoller, stopPoller, shutdown)"]

    API --> Workhorse
    Workhorse --> Config
    Config["Config (defaultOptions)"]

    %% Workhorse Components
    Workhorse["Workhorse"] --> Dispatcher
    Dispatcher --> TaskQueue
    Dispatcher --> ExecutorPool
    Dispatcher --> PluginHandler

    %% Executor and Queue Interaction
    ExecutorPool --> Executor
    Executor --> TaskQueue
    TaskQueue --> Database["runQuery createDatabase"]
    Database --> nodesqlite["better-sqlite3"]
    Database --> sqlocal["sqlocal"]
    sqlocal --> Webworker
    Webworker --> sqlite3.wasm
    nodesqlite --> sqlite3["in-memory database when testing"]

    %% Plugins
    PluginHandler["Plugin Handler"] --> Plugins["Plugins (PauseWhenOffline, etc.)"]

    %% Task Lifecycle State Flow
    subgraph Task Lifecycle
        queued --> executing
        executing --> successful
        executing --> failed
        failed --> queued
    end

    %% Utilities and Helpers
    Config --> Defaults["Defaults & Factories"]
    Defaults --> Factories["Factories"]

    %% Component Grouping
    classDef core fill:#aef,stroke:#058,stroke-width:2px
    class API,Workhorse,Dispatcher,ExecutorPool,Executor,TaskQueue,SQLiteStorage,XStateMachines,PluginHandler core
```
npm package: @hyrioo/vite-plugin-material-symbols-svg
Description: Vite plugin for Material Symbols SVG icons
Latest version: 0.2.0

# @hyrioo/vite-plugin-material-symbols-svg

```bash
npm install @hyrioo/vite-plugin-material-symbols-svg @hyrioo/vue-material-symbol
```

See the project docs for setup and API details.
npm package: @hyrious/bdic-cli
Description: Simply rewrites Fuxy526/bdic-cli
Author: hyrious
Latest version: 0.1.1

# @hyrious/bdic-cli

> Simple CLI for searching in various dictionaries.

## Usage

```
bdic <word> [-c] [-d <dict>]
```

### Install

```bash
npm r -g bdic-cli
npm i -g @hyrious/bdic-cli
```

## Credits

- [bdic-cli (Fuxy526)](https://github.com/Fuxy526/bdic-cli)
- [Saladict](https://github.com/crimx/ext-saladict)

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/blivec
Description: bilibili live cli
Author: hyrious
Latest version: 0.4.13

# <samp>&gt; <ins>b</ins>ilibili-<ins>live</ins>-<ins>c</ins>li</samp>

[![code style](https://antfu.me/badge-code-style.svg)](https://github.com/antfu/eslint-config)

Personal tool for viewing <ruby>弾幕 <rp>(</rp><rt>danmaku</rt><rp>)</rp></ruby> and other utils in bilibili live streaming.

## Why

It will cost too much CPU to open a browser when playing [osu!](https://osu.ppy.sh/users/hyrious), where the performance of CPU matters when the beatmap becomes more difficult and you need at least 240 FPS to play well.

The main goal of this tool is to provide a cheap way to interact with bilibili live streaming without hurting the game's performance. If you want a better API library, see [credits](#credits).

## Install

You don't have to install it if you have `npx`,

```bash
npx @hyrious/blivec ...args
```

Or you can choose to install it globally, which will give you a shortcut name `bl`,

```bash
npm i -g @hyrious/blivec
bl ...args
```

## Usage

> [!NOTE]
> Many commands require cookies to run correctly.
> Use incognito mode to get the cookie that won't expire easily.

```
  bl <room_id>                      # listen danmaku (requires cookie for
                                      displaying user names)
     --json                         # print all events in json

  bl <room_id> <message>            # send danmaku (requires cookie)

  bl get <room_id>                  # get stream url
     --json                         # print them in json

  bl feed                           # get feed list (requires cookie)
     --json                         # print them in json

  bl d <room_id> [--interval=1]     # dd mode
     --interval=<minutes>           # set 0 to disable polling
     --mpv                          # open in mpv instead
     --on-close=<behavior>          # do something on window close
                default             # restart player    (alias: --default)
                ask                 # ask quality again (alias: --ask)
                quit                # quit DD mode      (alias: --quit)
     -- [...player_args]            # pass args to ffplay or mpv
```

## Develop

PR & issues are welcome!

## Credits

- [blivedm](https://github.com/xfgryujk/blivedm)
- [bilibili-live-ws](https://github.com/simon300000/bilibili-live-ws)
- [Bilibili-Live-API](https://github.com/lovelyyoshino/Bilibili-Live-API)
- [bilibili-live-stream](https://github.com/ikexing-cn/bilibili-live-stream)

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/bun-why
Description: Can't wait and implement `bun why`
Author: hyrious
Latest version: 0.1.1

# @hyrious/bun-why

Simple `bun why` implementation.

> [!NOTE]
> Requires text-based `bun.lock` file.

## Usage

```console
bunx @hyrious/bun-why <package-spec>
```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/bun.lockb
Description: Parse and print bun.lockb
Author: hyrious
Latest version: 0.0.4

# @hyrious/bun.lockb

Parse and print `bun`'s binary lockfile `bun.lockb`. [Try it online.](https://hyrious.me/tool/bun.lockb)

## Usage

```js
import { parse } from '@hyrious/bun.lockb'

console.log(parse(fs.readFileSync('bun.lockb')))
```

## How it works?

Translate [bun/src/install/lockfile.zig](https://github.com/oven-sh/bun/blob/main/src/install/lockfile.zig) (MIT licensed) to JS.

## What's next?

Let's see if `bun` will decide to change its lockfile to text format ([bun#5486](https://github.com/oven-sh/bun/issues/5486)).

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/codemirror-theme-mariana
Description: Mariana theme for the CodeMirror code editor
Author: hyrious
Latest version: 0.1.2

# @hyrious/codemirror-theme-mariana

Mariana theme for the CodeMirror code editor.

![screenshot](https://github.com/user-attachments/assets/8dfb7a56-18c9-4594-9ca5-f694fd7b5132)

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/configs
Description: Shared configs across my projects
Author: hyrious
Latest version: 0.1.6

# @hyrious/configs

Shared configs across my projects.

## Usage

```bash
npm i -g @hyrious/configs
```

### [tsconfig.json](./docs/tsconfig.md)

- 0.1.6: Add `"types": ["*"]` to the Node.js variant. [TypeScript 5.x to 6.0 Migration Guide](https://gist.github.com/privatenumber/3d2e80da28f84ee30b77d53e1693378f).

- 0.1.5: Add new variant for Node.js directly run TypeScript files.

- 0.1.4: Remove `"verbatimModuleSyntax"` from the casual variant.

- 0.1.3: Add [`"moduleDetection": "force"`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#control-over-module-detection).

- 0.1.2: Make use of [`"module": "Preserve"`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-4.html#support-for-require-calls-in---moduleresolution-bundler-and---module-preserve) (TypeScript &ge; 5.4)\
  If your TypeScript Compiler &lt; 5.4, you can lock `"@hyrious/configs": "0.1.1"`.

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/corepack-cli
Description: Some helpful scripts when using corepack.
Author: hyrious
Latest version: 0.1.1

## @hyrious/corepack

Some helpful scripts when using corepack.

## Usage

```bash
npx @hyrious/corepack-cli prepare-latest pnpm
```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/done
Description: A command line tool to help standardize release.
Author: hyrious
Latest version: 0.1.1

## @hyrious/done

A command line tool to help standardize release.

Just run `npx @hyrious/done`.

### Diff. with [`done`](https://github.com/unix/done)

- Preview next version in command line.
- Handle npm v7 (which updates package-lock.json on release).
- Provide alter bin named `npm-done` to prevent conflict with `shell` reservations.\
  However, it does not mean it is only for `npm`. `yarn` & `pnpm` are also supported.
- Doesn't bundle everything.\
  It helps installing because `semver` is already a dependency of `npm` and many other tools.

### Known Issue

PRs are welcome.

- Yarn2+ is not supported yet.
  Checkout [their docs](https://yarnpkg.com/cli/version) to see how to make it.

### Why

I made this tiny cli for my personal convenience,
it's just working without many options.

### See Also

- [np](https://github.com/sindresorhus/np)
- [release-it](https://github.com/release-it/release-it)

### License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/dup
Description: Find duplicates in your lockfile
Author: hyrious
Latest version: 0.1.7

# @hyrious/dup

Find duplicates in your package-lock.json / pnpm-lock.yaml.

This script is using string matching, it is very fast.

## Usage

<pre><code>$ cd path/to/your/npm-project
$ <a href="https://github.com/antfu/ni">nlx</a> @hyrious/dup
foo@1.0.0
foo@2.0.0</code></pre>

### Next Steps

You can run <code><a href="https://github.com/antfu/ni">na</a> why {package-name}</code>
to find out why they are there in your dependencies tree.

- The duplicates are likely to happen after you have run
  <code><a href="https://github.com/antfu/taze">taze</a> -wi</code>. This is
  because package managers tend to keep indirect dependencies' versions if
  updating them is not necessary and for smaller downloading footprint.

  You can run <code><a href="https://github.com/antfu/ni">na</a> dedupe</code>
  to force update all dependencies to the same version (if possible).

- Some modules may deploy their function and CLI in the same package, which
  results in the CLI's dependencies (`yargs`, `commander`, etc.) being included
  in your dependencies tree and you actually does not need them.

  You can add [overrides](https://pnpm.io/settings#overrides) to remove
  them, for example (in pnpm-workspace.yaml):

  ```yaml
  overrides:
    "critters>chalk": "npm:noop-package@1.0.0"
    "html-minifier>commander": "npm:noop-package@1.0.0"
  ```

  Or in [package.json](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#overrides)
  (for npm):

  ```json
  "overrides": {
    "chalk": "npm:noop-package@1.0.0",
    "commander": "npm:noop-package@1.0.0"
  }
  ```

- If an indirect dependency's newer version breaks your codebase, you can either

  - Hack into it (if possible) in your codebase and alter its behavior;
  - Make a [patch](https://pnpm.io/cli/patch) to fix it manually;
  - Raise an issue to the package's repo.

  I'm just encouraging you to use less dependencies to risk less.

- Bonus: run `DUP_EVIL=1 dup` to add overrides to all duplicate dependencies.
  It's _evil_ since things may break because of dependencies getting newer.

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/esbuild-dev
Description: Build and run your script.ts with esbuild
Author: hyrious
Latest version: 0.10.14

## @hyrious/esbuild-dev

Build and run your `script.ts`, like `ts-node` or `node-dev`.

Require Node.js `^14.18 || >=16` to use `--enable-source-maps` and top-level await.

### Features

- ⚡ **_Fast_** with the help of esbuild, use `esbuild-dev` to substitute `ts-node`
  - pros: checkout [this repo's actions](https://github.com/hyrious/esbuild-dev/actions),
    `npm run build` done in 0.30s!
  - cons: you won't get any type checking at all
- 🐛 **_Easy to Debug_** with the help of node's `--enable-source-maps`
- ✨ **_No Magic_** other than esbuild itself. the author refuses to use any `require.extensions`-like things

### Install

```bash
npm i -g @hyrious/esbuild-dev esbuild
```

> **Note:** esbuild is a peer dependency!

### Usage

```bash
esbuild-dev [--watch] main.ts
```

[Read the docs to learn more.](https://hyrious.me/esbuild-dev)

### Develop

The source codes in the project is carefully written in a style that esbuild won't generate interop helpers. Refer [esbuild#1831](https://github.com/evanw/esbuild/issues/1831#issuecomment-992909043) to learn how.

### License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/esbuild-plugin-code-tag
Description: Strip code tag functions and dedent strings
Author: hyrious
Latest version: 0.1.0

## @hyrious/esbuild-plugin-code-tag

This plugin strips [code tags](https://github.com/fregante/code-tag) from your source code.

### Install

```
npm add -D code-tag @hyrious/esbuild-plugin-code-tag
```

### Usage

```js
const { build } = require("esbuild");
const { codeTag } = require("@hyrious/esbuild-plugin-code-tag");

build({
  entryPoints: ["src/index.ts"],
  bundle: true,
  format: "esm",
  plugins: [codeTag()],
}).catch(() => process.exit(1));
```

### Options

```js
codeTag({
  filter: /\.(m?ts|[jt]sx)$/,
  tags: ["html", "css", "gql", "graphql", "md", "markdown", "sql"],
  dedent: [],
});
```

**filter** (default: `/\.(m?ts|[jt]sx)$/`)

A RegExp passed to [`onLoad()`](https://esbuild.github.io/plugins/#on-load) to
match source codes, it is recommended to set a custom filter to skip files
for better performance. By default it does not process .{js,mjs} files.

**tags** (default: `["html", "css", "gql", "graphql", "md", "markdown", "sql"]`)

An array of tags to be stripped. For example if you set `tags` to `["html", "css"]`,
the following transform will happen:

```js
console.log(html`
  <h2>Title</h2>
  <p>hello, world!</p>
`);
```

becomes

```js
console.log(`
  <h2>Title</h2>
  <p>hello, world!</p>
`);
```

**dedent** (default: `[]`)

Template literals after these tags will be [de-indented](https://github.com/tamino-martinius/node-ts-dedent).
For example if you set `dedent` to `["html", "css"]`, the following transform will happen:

```js
console.log(html`
  <h2>Title</h2>
  <p>hello, world!</p>
`);
```

becomes

```js
console.log(`<h2>Title</h2>
<p>hello, world!</p>`);
```

By default `dedent` is empty, so that the default behavior will be the same as
not having this plugin.

### Caveats

- It does not support nested code tags, i.e.

  ```js
  const fragment = html`
    <style>
      ${css`
        body {
          color: red;
        }
      `}
    </style>
  `;
  ```

  If you need to write code like above, you can move inner strings to another scope:

  ```js
  const style = css`
    body {
      color: red;
    }
  `;
  const fragment = html`<style>${style}<style>`;
  ```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/esbuild-plugin-external
Description: Compute and mark external modules
Author: hyrious
Latest version: 0.1.4

# @hyrious/esbuild-plugin-external

An esbuild plugin to help you compute and mark external modules manually.

## Features

- Excludes `dependencies` and `peerDependencies` from `package.json`.
- Adds custom loader `with { external: "./replacement.js" }`.
- Automatically externalizes imports with pattern matching.

## Usage

```js
import external from '@hyrious/esbuild-plugin-external'

await esbuild.build({
  entryPoints: ['src/index.ts', 'src/cli.ts'],
  bundle: true,
  format: 'esm',
  platform: 'node',
  packages: 'bundle',
  plugins: [external()]
}).catch(() => process.exit(1))
```

### Options

```js
external({
  package: true,
  filter: /\.ts$/,
  auto: [{ filter: /\.js$/ }],
})
```

- **package**: Automatically mark dependencies and peer dependencies from package.json.
  This is enabled by default.

- **filter**: Filter in files to be enhanced to use import attribute `with { external: "replace" }`.
  This is disabled by default, you need to pass in a regex to make it work.
  Example:

  ```js
  import * as mod from '../foo' with { external: "./foo.js" }
  // will be bundled into =>
  import * as mod from './foo.js'
  ```

- **auto**: Filter in paths to be externalized and perform a simple replacement to strip leading `'../'`s.
  This is disabled by default, you need to pass in a config to make it work.
  Example:

  ```js
  // auto: [{ filter: /\.js$/ }]
  import * as mod from './index.js' // will be marked external
  import * as mod from '../foo.js' // will be externalized as './foo.js'
  ```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/esbuild-plugin-style
Description: The missing style loader for esbuild.
Author: hyrious
Latest version: 0.3.5

# @hyrious/esbuild-plugin-style

The missing style-loader for esbuild.

## Usage

```js
const { style } = require("@hyrious/esbuild-plugin-style");

require("esbuild").build({
  entryPoints: ["app.js"],
  bundle: true,
  outfile: "out.js",
  plugins: [style()],
}).catch(() => process.exit(1));
```

Given such app.js and style.css:

```js
import "./style.css";
console.log(1);
```

```css
body { color: red; }
```

Outputs (things like):

```js
let style = document.createElement("style");
style.append("body { color: red }");
document.head.append(style);
console.log(1);
```

### Options

```ts
export function style({ minify = true, charset = "utf8" }): Plugin;
```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/esbuild-plugin-svelte
Description: Load .svelte files in esbuild.
Author: hyrious
Latest version: 0.3.3

# @hyrious/esbuild-plugin-svelte

Minimal efforts to make svelte work in esbuild.

## Install

```bash
npm add -D @hyrious/esbuild-plugin-svelte svelte esbuild
```

## Usage

```js
import { build } from 'esbuild'
import { svelte } from '@hyrious/esbuild-plugin-svelte'

await build({
  entryPoints: ['main.js'],
  bundle: true,
  plugins: [svelte()],
}).catch(() => process.exit(1))
```

## Options

```js
svelte({
  filter: /\.svelte(\?.*)?$/,
  compilerOptions: {},
  preprocess: [],
  emitCss: true,
  inspector: void 0,
  dynamicCompileOptions: () => void 0,
})
```

### filter

Passed to esbuild [`onLoad()`](https://esbuild.github.io/plugins/#on-load)
callback to match svelte files.

### compilerOptions

See [svelte/compiler#CompileOptions](https://svelte.dev/docs/svelte/svelte-compiler#CompileOptions).

If not specified, the `dev` mode is detected with the following logic:

- If either one of the following config is set, `dev: false`.
  - `minify: true`
  - `define: { 'process.env.NODE_ENV': '"production"' }`
  - `define: { 'import.meta.env.NODE_ENV': '"production"' }`
  - `define: { 'import.meta.env.DEV': 'false' }`
- Otherwise, `dev: true`.

If not specified, the `ssr` mode (`generate: 'server'`) is detected with the following logic:

- If either one of the following config is set, `generate: 'server'`.
  - `define: { 'import.meta.env.SSR': 'true' }`
- Otherwise, `generate: 'client'`.

### preprocess

See [svelte/compiler#Preprocessor](https://svelte.dev/docs/svelte/svelte-compiler#Preprocessor).

You can opt-in the esbuild-powered TypeScript preprocessor by:

```js
import { svelte, typescript } from '@hyrious/esbuild-plugin-svelte'

svelte({
  // esbuild will print warnings on the final js, so suppress them here.
  preprocess: [typescript({ onwarn: false })],
})
```

### emitCss

Generate virtual CSS files. If `true` (by default), it will set svelte compile
options `css: 'external'` automatically.

### inspector

Enable svelte inspector during development (see the `dev` logic above).
You can set it to `false` to ensure it is not enabled anyway.

### dynamicCompileOptions

A function to update [`compilerOptions`](#compileroptions) before compilation.

```js
svelte({
  dynamicCompileOptions({ filename }) {
    if (filename.includes('node_modules')) return { runes: false }
  },
})
```

## Credits

- [sveltejs/vite-plugin-svelte](https://github.com/sveltejs/vite-plugin-svelte)
- [EMH333/esbuild-svelte](https://github.com/EMH333/esbuild-svelte)
- [rixo/svelte-hmr](https://github.com/sveltejs/svelte-hmr)

## [Changelog](./CHANGELOG.md)

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/esbuild-plugin-svgo
Description: SVGO plugin for esbuild.
Author: hyrious
Latest version: 0.2.0

# @hyrious/esbuild-plugin-svgo

[SVGO](https://github.com/svg/svgo) plugin for esbuild.

## Usage

```js
const { svgo } = require("@hyrious/esbuild-plugin-svgo");

require("esbuild").build({
  entryPoints: ["app.js"],
  bundle: true,
  outfile: "out.js",
  plugins: [svgo()],
  loader: { '.svg': 'dataurl' },
}).catch(() => process.exit(1));
```

### Options

```ts
export function svgo(config?: Config): Plugin;
```

See [SVGO Options](https://github.com/svg/svgo#configuration).

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/esbuild-serve
Description: simple watch and reload server with esbuild
Author: hyrious
Latest version: 0.3.12

# esbuild-serve

[![GitHub Repo](https://img.shields.io/badge/github-hyrious/esbuild--serve-blue)](https://github.com/hyrious/esbuild-serve/) ![total lines](https://img.shields.io/tokei/lines/github/hyrious/esbuild-serve) [![npm package](https://img.shields.io/npm/v/@hyrious/esbuild-serve)](https://www.npmjs.com/package/@hyrious/esbuild-serve)

### Usage

Serve your static site:

```bash
> npx @hyrious/esbuild-serve
[esbuild-serve] serving http://localhost:3000
```

Build your static site:

```bash
> npx @hyrious/esbuild-serve --build
```

Other options:

```
> npx @hyrious/esbuild-serve --help
usage:
  esbuild-serve [--open] [servedir]   -- serve a folder
  esbuild-serve --build [servedir]    -- bundle scripts
  esbuild-serve --dry-run [servedir]  -- print `esbuild --serve ...`
  esbuild-serve init                  -- create an example index.html
```

### Description

This is a simple wrapper of [`esbuild --serve`](https://esbuild.github.io/api/#serve),
which enables auto reload and zero-config development.

**Difference to [vite]**:

1. Vite doesn't do bundle (at least, your code) in development for the best speed.
   This tool does bundle everything into a single file.
2. `index.html` in vite is part of your source code, development and production will
   treat it differently. While in this tool, `index.html` is part of your production site.
3. You can have multiple entry points, but if you do that, their output file names
   must be the same with the source files', this is limited by esbuild build options.\
   e.g. if you request `js/app.js` and `js/home.js`, there must be `some-folder/app.ts` and `some-folder/home.js` in your source code.

### Zero-config Assumptions

This tool follows the example usage from esbuild document, which gives:

```bash
esbuild src/app.js --servedir=www --outdir=www/js --bundle
```

That is to say, you need a public folder with `index.html` in it to formalize a static site.

Recommended folder names: `public`, `www`, `dist`, `(root folder)`.

Run `esbuild-serve init` to create an example folder with an example index.html.

### Config

Create an `esbuild.config.ts`:

```ts
import { defineConfig } from "@hyrious/esbuild-serve";

export default defineConfig({
  serve: {},
  build: {},
});
```

### Todo

- [Access metafile in serve mode](https://github.com/evanw/esbuild/issues/1072).\
  Due to this problem, currently it must run `esbuild.build` to generate metafile
  to search dependency files to watch for auto reload.

### License

MIT @ [hyrious](https://github.com/hyrious)

[vite]: https://github.com/vitejs/vite
npm package: @hyrious/fuzzy-match
Description: Match string like Sublime Text
Author: hyrious
Latest version: 0.1.1

## @hyrious/fuzzy-match

> A string match function that help implementing fuzzy search like Sublime Text.

The algorithm is derived from [this C implementation of fts_fuzzy_match](https://github.com/tajmone/fuzzy-search/tree/master/fts_fuzzy_match/0.2.0/c).

## Install

```
npm add @hyrious/fuzzy-match
```

## Usage

```js
import { match, match_trace } from "@hyrious/fuzzy-match";

match("th", "tth-hash");
// => 45 (score, maybe negative)

match("not found", "string");
// => -Infinity

// Match with backtrack, useful when we want to highlight the matching chars.
match_trace("th", "tth-hash");
// => { score: 45, stops: [0, 4] }

match_trace("not found", "string");
// => null
```

### Possible Fuzzy Search Implementation

```js
import { match } from "@hyrious/fuzzy-match";

function search(text, list) {
  return list
    .map((item) => ({
      item,
      score: match(text, item),
    }))
    .filter(({ score }) => score > -Infinity)
    .sort((a, b) => b.score - a.score);
}
```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/gfm
Description: Use GitHub API to render markdown.
Author: hyrious
Latest version: 0.1.5

## Preview GitHub Flavored Markdown

[![GitHub Repo](https://img.shields.io/badge/github-hyrious/gfm-blue)](https://github.com/hyrious/gfm/) ![total lines](https://img.shields.io/tokei/lines/github/hyrious/gfm) [![npm package](https://img.shields.io/npm/v/@hyrious/gfm)](https://www.npmjs.com/package/@hyrious/gfm) [![install size](https://packagephobia.com/badge?p=@hyrious/gfm)](https://packagephobia.com/result?p=@hyrious/gfm)

This repo provides a [site](https://hyrious.me/gfm), a cli tool,
a nodejs library and a deno library. Below is the library description.

### Install

```shell-session
# globally (as cli)
> npm i -g @hyrious/gfm
# locally (as library)
> npm i -D @hyrious/gfm
# deno see below
```

### Usage

As cli:

> Note: only one \*.md maybe passed to `gfm`, multiple files are ignored.

```shell-session
> gfm file.md
<p>content of this file</p>
> cat file.md | gfm
<p>content of this file</p>
# start a local server (like the site, with hot reloading enabled)
> gfm --serve file.md
# you may want to use a token to increase rate limit,
# simply append --token and it will ask for it before going.
> gfm file.md --token
Input Token (invisible): ******
<p>content of this file</p>
```

As library:

```js
import { render } from "@hyrious/gfm";
const rateLimit = {};
const html = await render("# markdown", { token, rateLimit });
console.log(rateLimit, html);
```

As deno library (you have to use it with `--allow-net`):

```ts
import { render } from "https://esm.run/@hyrious/gfm";
// same interface as nodejs library
```

As native browser module:

```html
<script type="module">
    import { render } from "https://esm.run/@hyrious/gfm";
</script>
```

As iife or umd (like jquery):

```html
<script src="https://cdn.jsdelivr.net/npm/@hyrious/gfm"></script>
<script>GFM.render("# hello").then(text => {})</script>
```

> Note: render results are not cached, you should implement caching on your own.

### Why

The library is written in .mjs to use vanilla `import` in nodejs (since 14).
It then uses rollup to convert mjs to cjs for `require` users.
It uses `browser`, `module` and conditional exports in package.json to support many platforms.

I personally made this package for a reference of the correct way
to support multiple environments in one package.
You (Me) should look at package.json for more details.

**package.json with comments**

```js
{
    // node's require and import, to override it, see "exports"
    "main": "dist/index.js",
    // https://nodejs.org/api/packages.html#packages_conditional_exports
    "exports": {
        "import": "./src/index.mjs",
        "require": "./dist/index.js"
    },
    // front-end bundler read this (like vite or webpack)
    "module": "src/index.browser.mjs",
    // cdn like jsdelivr read this
    "browser": "dist/index.browser.js"
}
```

### Licence

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/git-tm
Description: Git time-machine.
Author: hyrious
Latest version: 0.1.3

# @hyrious/git-tm

Git Time-Machine. View files in a repository at a specific time.

## Usage

```console
$ npx @hyrious/git-tm [path/to/repo]
serving http://localhost:7000
```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/import-cost
Description: Get package size of import statements, powered by esbuild
Author: hyrious
Latest version: 0.1.6

# @hyrious/import-cost

> Get imported code size of a package.

This package is heavily inspired by [import-cost](https://github.com/wix/import-cost).

## Usage

### CLI

```bash
> npx @hyrious/import-cost file.ts

Package   Cost     Where
lodash    70 kiB   file.ts:2
```

### API

#### importCost(path, code, options?)

```js
import { importCost } from '@hyrious/import-cost'

const result = await importCost('file.ts', `
  import { uniqueId } from 'lodash'
`)
// => { errors: [], warnings: [], packages: [
//   { path: 'file.ts', name: 'lodash', line: 2, size: 70000, gzip: 70000 }
// ] }
```

- `path` {String} The path to the file, this is used for looking up the `node_modules` folder.
- `code` {String} The contents of the file.
- `options` {Object}
  - `lang` {String} Override the language infered from file extension. Available values: `js`, `ts`, `jsx`, `tsx`, `vue`, `svelte`.
  - `external` {String[]} Override packages to be excluded from the bundle. By default, all peer dependencies scanned from the package.json indicated by `path` will be excluded.
- Returns: {Promise&lang;Object&rang;}
  - `errors`, `warnings` {Object[]} Passed through from [esbuild](https://esbuild.github.io/api/#build-api).
  - `packages` {Object[]}
    - `path` {String} The path to the file, same as the input argument.
    - `name` {String} The name of the analyzed package.
    - `line` {Number} The line number of the import statement.
    - `size` {Number} The size of the package in bytes.
    - `gzip` {Number} The size of the package in bytes after gzip.
    - `fail` {Boolean} `true` if failed to bundle the package with esbuild.

#### cache

```js
import { cache } from '@hyrious/import-cost'

cache.clear()
```

## Related Works

- [vscode-import-cost](https://github.com/hyrious/vscode-import-cost): The VS Code extension that uses this package.

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/ink
Description: Draw perfect pressure-sensitive freehand strokes.
Author: hyrious
Latest version: 0.0.3

# @hyrious/ink

Draw perfect pressure-sensitive freehand lines on the browser.

> This library implements a simplified algorithm of [perfect-freehand](https://github.com/steveruizok/perfect-freehand).

## Usage

```js
import { Stroke } from '@hyrious/ink'

// Create the stroke like in onpointerdown
let stroke = Stroke.create()

// Update the stroke like in onpointermove
stroke.push({ x: ev.clientX, y: ev.clientY, r: ev.pressure })

// The stroke is made up with many sections, get each section's outline
stroke.sections.forEach((index) => {
  // PERF: the outline() function is quite expensive,
  // only the last section might change by further 'push()'s
  let points = stroke.outline(index, 8)
  // Draw this stroke in any way you like
  let path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
  path.setAttribute('d', points.reduce((d, { x, y }, i) => d + (i > 0 ? `L${x},${y}` : `M${x},${y}`), '') + 'z')
})

// Serialize the stroke
localStorage.setItem('stroke-0', JSON.stringify(stroke.toJSON()))

// De-serialize and restore a stroke
stroke = Stroke.fromJSON(JSON.parse(localStorage.getItem('stroke-0')))
```

### Possible CRDT Implementation

```ts
// Insert some points to stroke with `id`, at index `from`
type Message = { id: ID, from: number, points: { x: number, y: number, r: number }[] }

socket.on('stroke', (msg: Message) => {
  stroke = (strokes[msg.id] ||= Stroke.create())
  stroke.insert(msg.from, msg.points)
})
```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/install-electron
Description: Install electron from local cache
Author: hyrious
Latest version: 0.1.1

# @hyrious/install-electron

Requires Node.js &ge; 20.1.0 to use `fs.readdir({ recursive: true })`.

## Usage

### Install electron from the cache, or fallback to the latest

```bash
npx @hyrious/install-electron
```

### Install electron within a version range, prefer from cache

```bash
npx @hyrious/install-electron ^30
```

> [!NOTE]
> If the range is a tag, like `latest`, `30-x-y`.
> They are pointing to some specific version, which often changes and this package can't help.
> You should not use them to install packages. However, ranges like `30.x` are fine.

### Options

```console
> npx @hyrious/install-electron --dry-run
30.0.9, not cached

> npx @hyrious/install-electron --dry-run --json
{ "version": "30.0.9", "cached": false }
```

## How It Works

`@electron/get` downloads electron to [a known place](https://github.com/electron/get#how-it-works).
`@hyrious/install-electron` examines this place to find a proper version that you have cached.

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/lbq
Description: Simple command line task runner written in Node.js
Author: hyrious
Latest version: 0.2.1

# @hyrious/lbq

Simple command line task runner written in Node.js.

## Usage

```console
$ npm i -g @hyrious/lbq
$ lbq --edit
```

## Configuration

`lbq` loads `{configPath}/lbq/index.ts` to get all commands, where `configPath` is:

- Windows: `%LOCALAPPDATA%`
- macOS: `~/Library/Preferences`
- Linux: `` $XDG_CONFIG_HOME `` or `~/.config`

`lbq` uses [`jiti`](https://github.com/unjs/jiti) under the hood to load TypeScript files.
So you can use `jiti`'s environment variables to configure its behaviors or debug it.

You can use `lbq --edit` to open an editor in the config folder.

Example config file:

```ts
// {configPath}/lbq/index.ts
import { defineConfig } from 'lbq'

export default register => {
  register('hello', () => {
    console.log('world')
  })
}
```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/license
Description: Generate LICENSE.txt from GitHub API
Author: hyrious
Latest version: 0.2.0

## @hyrious/license

Generate LICENSE.txt from GitHub API.

```bash
npx @hyrious/license
```

### Changelog

#### 0.2.0

- Requires Node.js 20+ to use native `fetch()`.

### License (real)

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/marked-cli
Description: Preview markdown file with marked.js
Author: hyrious
Latest version: 0.2.19

# @hyrious/marked-cli

A simple script to preview local markdown file with hot reload.

> Want to use it in VS Code? Check out [this extension](https://github.com/hyrious/vscode-marked)!

## Usage

    npx @hyrious/marked-cli README.md
    serving http://localhost:5000

### Options

There's none.

The first version of this script is quickly written in 10 minutes.
You can submit a PR or raise an issue if you really need some configuration.

### What's in it?

This package has 2 purposes:

- Let the rendering result be like GitHub.com as much as possible.
- As small as possible.

### [Changelog](./CHANGELOG.md)

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/npm-mirror
Description: Use the registry secretly.
Author: hyrious
Latest version: 0.1.3

# @hyrious/npm-mirror

Do something under a custom registry, then rewrite them back to the default one.

> [!NOTE]
> It currently only works for `npm` and `bun`'s text lockfile, no `pnpm` support.

## Usage

```console
$ npx @hyrious/npm-mirror
Enabling custom registry: http://registry.npmmirror.com
Updated .npmrc
Updated package-lock.json

$ npm i -D esbuild

$ npx @hyrious/npm-mirror
Resetting default registry...
Updated .npmrc
Updated package-lock.json
```

### Options

```console
$ npx @hyrious/npm-mirror [registry] [dir]
```

#### registry

Default: `http://registry.npmmirror.com` (A mirror of registry in China.)

Despite of passing CLI arguments, it can also be configured with the environment variable `NPM_MIRROR_REGISTRY`.

The CLI updates `.npmrc` and `package-lock.json` to use or not use the registry.
The trigger is whether `.npmrc` is configured to use that registry or there's at least one package using the registry in the lockfile.

If the `.npmrc` has different registry configured, it throws an error.

#### dir

Default: `process.cwd()`

The CLI searches `package-lock.json` from `dir`, then its parent dir and so on.

If you want to change the `dir` argument without touching `registry`, you can pass in `_` or `*` in the first argument, e.g.

```console
$ npx @hyrious/npm-mirror _ path/to/project
```

### CI

If environment variable `CI` is present, the CLI does nothing.

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/npm-repo
Description: npm-repo, but resolves GitHub tags
Author: hyrious
Latest version: 0.1.5

# @hyrious/npm-repo

> [`npm repo`](https://docs.npmjs.com/cli/v10/commands/npm-repo), but look for
> corresponding GitHub tags.

## Usage

### CLI

```console
$ npx @hyrious/npm-repo vite
https://github.com/vitejs/vite/tree/v5.0.12/packages/vite
$                                 # ^^^^^^^ usually 'HEAD'

$ npx @hyrious/npm-repo vite --comapre 5.0.11
$ npx @hyrious/npm-repo vite --comapre 5.0.11...latest
https://github.com/vitejs/vite/compare/v5.0.11...v5.0.12
$                                    # ^^^^^^^ resolves to GitHub tags
$                                             # ^^^^^^ resolves dist tags
```

You can combine usage with [`taze`](https://github.com/antfu/taze) to firstly
check updates in your local project, then pass into this tool to read the diff
on GitHub quickly.

### Browser

This package is possible to be bundled for browser.

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/rimraf
Description: Just fs.promises.rm and fs.rmSync.
Author: hyrious
Latest version: 0.1.0

## @hyrious/rimraf

> Just a tiny wrapper of `fs.promises.rm` and `fs.rmSync`.

Requires Node.js >= 14.14.

### Usage

```bash
npx @hyrious/rimraf node_modules
```

```js
import rimraf from '@hyrious/rimraf'

await rimraf('node_modules')
rimraf.sync('node_modules')
```

### Alters

- [@zkochan/rimraf](https://github.com/zkochan/packages/blob/main/rimraf)\
  this repo is almost the same code as zkochan's, except that it is in pure esm.

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/rvdata2-textconv
Description: git diff textconv tool for Scripts.rvdata2
Author: hyrious
Latest version: 0.1.1

## @hyrious/rvdata2-textconv

> A simple textconv script to print Scripts.rvdata2 (RPG Maker VA) in git diff.

## Install

```
npm i -g @hyrious/rvdata2-textconv
```

## Usage

Print contents of Scripts.rvdata2:

```
rvdata2-textconv Scripts.rvdata2
```

### Git

Add this to your global `.gitconfig` or `.git/config` per repo:

```gitconfig
[diff "rvdata2"]
	textconv = rvdata2-textconv
```

Add this to your `.gitattributes` per repo (create one if not exist):

```gitattributes
*.rvdata2   diff=rvdata2
```

## Todo

Currently I'm not in a hurry to implement features below, if you find this
tool helpful and want something new, feel free to raise an issue or make
a pull request!

- Add a smarter printer to handle other `.rvdata2` files, for example:
	- if the file starts with `Scripts`, print it in $RGSS_SCRIPTS format
	- if the file contains an array of objects, and the first one is `nil`, print it in database format (one item per line)
	- otherwise, print it in yaml or json format
- When the "smart" one not work, add flags to manually select one format:
	- e.g. run with `--format=db`

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/shellwords
Description: Ruby's stdlib shellwords porting to JS.
Author: hyrious
Latest version: 0.1.1

## @hyrious/shellwords

Ruby's stdlib [shellwords](https://ruby-doc.org/stdlib-2.7.0/libdoc/shellwords/rdoc/Shellwords.html) porting to JS (TS).

### Usage

```js
import Shellwords from "@hyrious/shellwords"
// const Shellwords = require("@hyrious/shellwords")

Shellwords.split('here are "two words"')
// [ 'here', 'are', 'two words' ]
Shellwords.escape("It's better to give than to receive")
// "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"
Shellwords.join(['--a=b c', '-d', 'e f'])
// '--a\\=b\\ c -d e\\ f'
```

### Alters

- [marques-work/shellwords](https://github.com/marques-work/shellwords)

### Licence

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/sort-package-json
Description: Sort package.json
Author: hyrious
Latest version: 0.1.2

# @hyrious/sort-package-json

Basically [this preset](https://github.com/antfu/eslint-config/blob/main/src/configs/sort.ts) as a standalone package.
I just don't want to install 80 MB of dependencies for a simple task.

## Usage

```console
$ npx @hyrious/sort-package-json
  ✅ package.json
```

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/string-width
Description: Displayed width of strings according to UAX#11 rules
Author: hyrious
Latest version: 0.1.0

# @hyrious/string-width

> Get displayed width of unicode strings according to UAX#11 rules.

This package is a JS port of [Rust's unicode-width](https://github.com/unicode-rs/unicode-width).

## Caveats

It does not handle [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) and complex emoji sequences.
You can use [strip-ansi](https://www.npmjs.com/package/strip-ansi) and [emoji-regex](https://www.npmjs.com/package/emoji-regex) before passing strings to this package. See [test.js](./test.js) of commented out test cases.

## Install

```
npm add @hyrious/string-width
```

## Usage

```js
import stringWidth from '@hyrious/string-width'
// const stringWidth = require('@hyrious/string-width')

stringWidth('a')
//=> 1

stringWidth('古')
//=> 2
```

### stringWidth(string, options?)

- `string` {String} The string to get the width of.
- `options` {Object}
  - `ambiguousIsNarrow` {Boolean} (default: `true`) Whether to treat [ambiguous-width characters](https://www.unicode.org/reports/tr11/#Ambiguous) as narrow (count of 1) instead of wide (count of 2).

Returns a number of the column width of the string.

## Alternatives

- [string-width](https://github.com/sindresorhus/string-width)

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/telegraph
Description: https://hyrious.me
Author: hyrious
Latest version: 0.2.7

# @hyrious/telegraph

> Opinionated blogging workflow by [@hyrious](https://github.com/hyrious).

## Get Started

This tool does not work out of the box.
Take a look at [my blog's \_src folder](https://github.com/hyrious/hyrious.github.io/blob/main/_src) to continue.

Required files (folders):

```
_src/               # source files
  hello-world.md    # must have a front-matter with { title, date } fields
  style.css
  index.html
  p.html
p/                  # rendered posts
  hello-world.html
  index.html        # rendered from _src/p.html
style.css
index.html
```

## Commands

- `tg build [--watch] [--serve] [root]`: Build the site, expects a `_src` folder in `[root]`.
- `tg new <title> [root]`: Create a new post `_src/title.md`.

## Rules

The folder `_src` and `p` are hard-coded, not changeable.

`_src/*.css` &rarr; `*.css`\
`_src/p.html`, `_src/*.md` &rarr; `p/index.html`\
`_src/*.html`, `_src/*.md` &rarr; `*.html`\
`_src/*.md` &rarr; `p/*.html`

### Front-matter

`_src/*.md` **must** have the two attributes in its front-matter:

```yaml
title: Hello, world!
date: 2022-01-21
```

An optional attribute, `scripts`, can be used to import js files:

```yaml
scripts:
  - ../script.mjs
```

yields &darr;

```html
<script type="module" src="../script.mjs"></script>
```

### Assets

`_src/*.css` can import `https://...css` assets, they will be fetched during
build and be included in the final bundle.

### Template

`_src/*.html` are templates, they can use a simple template language:

```svelte
<ul>
  {#each posts as post}
  <li><a href="p/{ post.id }">{ post.title }</a></li>
  {/each}
</ul>
```

Available variables:

```ts
var site: { date: string }
var posts: Post[]
var post: Post | null // only exist in _src/post.html
interface Post {
  id: string
  title: string
  date: string
  text: string
  html: string
}
```

## Develop

```console
npm install && npm link
tg path/to/blog
npm r -g @hyrious/telegraph
```

See [Develop](./Develop.md) for more technical details.

## Changelog

## License

MIT @ [hyrious](https://github.com/hyrious)
npm package: @hyrious/up
Description: upgrade all packages to latest version
Author: hyrious
Latest version: 0.1.1

This tool radically upgrade all your dependencies (in package.json) to latest version.

:warning: This tool does not provide any way to _downgrade_ or _ignore_ specific packages.

### Usage

```bash
# upgrade all packages in "dependencies"
npx @hyrious/up
# upgrade all packages in "devDependencies"
npx @hyrious/up -D
# upgrade all packages in "dependencies" and "devDependencies"
npx @hyrious/up +D
```

Behind the scene:

```bash
# check the latest version info at https://data.jsdelivr.com/v1/package/npm/vue
# it uses jsdelivr for now, maybe add registry later
# find out which tag is currently being used, e.g. "next"
npm uninstall vue
npm install vue@next
# if we can not fetch the info, just do nothing
```

It also supports `yarn` and `pnpm`. In that case, commands are:

```bash
yarn remove vue
yarn add vue@next
```

```bash
pnpm remove vue
pnpm add vue@next
```

#### Full command options list

```
up [-D|+D] [--npm|--yarn|--pnpm] [--dry-run]
           upgrade dependencies by default
        -D upgrade devDependencies
        +D upgrade dependencies and devDependencies
     --npm force using npm, in case it can not figure out which pm you are using
    --yarn force using yarn
    --pnpm force using pnpm
 --dry-run output what commands it will run, but don't actually run them
```

### License

The MIT license.
npm package: @hyrious/use-reactive
Description: use vue's reactive in react hooks
Author: hyrious
Latest version: 0.1.7

## useReactive

Use vue's reactivity api in react.

### Usage

```jsx
import { useReactive } from "@hyrious/use-reactive";
function Counter() {
  const state = useReactive({ count: 0 });
  return <button onClick={() => state.count++}>{state.count}</button>;
}
```

### How it works?

Vue's reactivity api does the trick:

```js
import { reactive, watchEffect } from "vue";
const state = reactive({ count: 0 });
watchEffect(() => {
  console.log(state.count);
  // accessing "state.count" triggers a proxy's get handler.
  // vue depends on the proxy to track it, so the next time
  // state.count changes, watchEffect will run again.

  // if we do nothing here, watchEffect will loop run until
  // it find some deps. that's it.
});
```

### License

MIT @ [hyrious](https://github.com/hyrious)