Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
β |
---|---|---|---|
0 | repos | repos/linuxwave/release.sh | #!/usr/bin/env bash
set -e
if [ -z "$1" ]; then
echo "Please provide a tag."
echo "Usage: ./release.sh v[X.Y.Z]"
exit
fi
echo "Preparing $1..."
# update the version
msg="\/\/ managed by release.sh"
sed -E -i "s/^(const version = ).* $msg$/\1\"${1#v}\"; $msg/" build.zig
zig build test
# update the changelog
git cliff --tag "$1" >CHANGELOG.md
git add -A
git commit -m "chore(release): prepare for $1"
git show
# generate a changelog for the tag message
changelog=$(git cliff --tag "$1" --unreleased --strip all | sed -e '/^#/d' -e '/^$/d')
# create a signed tag
# https://keyserver.ubuntu.com/pks/lookup?search=0xC0701E98290D90B8&op=vindex
git -c user.name="linuxwave" \
-c user.email="[email protected]" \
-c user.signingkey="21B6926360C8A0C82C48155DC0701E98290D90B8" \
tag -f -s -a "$1" -m "Release $1" -m "$changelog"
git tag -v "$1"
echo "Done!"
echo "Now push the commit (git push) and the tag (git push --tags)."
|
0 | repos | repos/linuxwave/RELEASE.md | # Creating a Release π§π΅
[GitHub](https://github.com/orhun/linuxwave/releases) releases are automated via [GitHub actions](.github/workflows/cd.yml) and triggered by pushing a tag.
1. Run the [release script](./release.sh): `./release.sh v[X.Y.Z]` (requires [git-cliff](https://github.com/orhun/git-cliff) for changelog generation)
2. Push the changes: `git push`
3. Check if [Continuous Integration](https://github.com/orhun/linuxwave/actions) workflow is completed successfully.
4. Push the tags: `git push --tags`
5. Wait for [Continuous Deployment](https://github.com/orhun/linuxwave/actions) workflow to finish.
|
0 | repos | repos/linuxwave/SECURITY.md | # Security Policy π§π΅
## Supported Versions
The following versions are supported with security updates:
| Version | Supported |
| ------- | ------------------ |
| 0.1.x | :white_check_mark: |
## Reporting a Vulnerability
Please use the [GitHub Security Advisories](https://github.com/orhun/linuxwave/security/advisories/new) feature to report vulnerabilities.
|
0 | repos | repos/linuxwave/CODE_OF_CONDUCT.md | # Contributor Covenant Code of Conduct π§π΅
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected]
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
|
0 | repos | repos/linuxwave/CONTRIBUTING.md | # Contributing π§π΅
A big welcome and thank you for considering contributing to `linuxwave`! It is people like you that make it a reality for users in the open source community.
Reading and following these guidelines will help us make the contribution process easy and effective for everyone involved. It also communicates that you agree to respect the time of the developers managing and developing this project. In return, we will reciprocate that respect by addressing your issue, assessing changes, and helping you finalize your pull requests.
## Quicklinks
- [Code of Conduct](#code-of-conduct)
- [Getting Started](#getting-started)
- [Issues](#issues)
- [Pull Requests](#pull-requests)
- [License](#license)
## Code of Conduct
We take our open source community seriously and hold ourselves and other contributors to high standards of communication. By participating and contributing to this project, you agree to uphold our [Code of Conduct](./CODE_OF_CONDUCT.md).
## Getting Started
Contributions are made to this repo via Issues and Pull Requests (PRs). A few general guidelines that cover both:
- First, discuss the change you wish to make via creating an [issue](https://github.com/orhun/linuxwave/issues/new/choose), [email](mailto:[email protected]), or any other method with the owners of this repository before making a change.
- Search for existing issues and PRs before creating your own.
- We work hard to make sure issues are handled on time but, depending on the impact, it could take a while to investigate the root cause. A friendly ping in the comment thread to the submitter or a contributor can help draw attention if your issue is blocking.
### Issues
Issues should be used to report problems with the project, request a new feature, or discuss potential changes before a PR is created. When you create a new issue, a template will be loaded that will guide you through collecting and providing the information we need to investigate.
If you find an issue that addresses the problem you're having, please add your own reproduction information to the existing issue rather than creating a new one. Adding a [reaction](https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) can also help be indicating to our maintainers that a particular problem is affecting more than just the reporter.
### Pull Requests
PRs are always welcome and can be a quick way to get your fix or improvement slated for the next release. In general, PRs should:
- Only fix/add the functionality in question **or** address widespread whitespace/style issues, not both.
- Add unit or integration tests for fixed or changed functionality (if a test suite already exists).
- Address a single concern in the least number of changed lines as possible.
- Include documentation.
- Be accompanied by a complete Pull Request template (loaded automatically when a PR is created).
For changes that address core functionality or would require breaking changes (e.g. a major release), it's best to open an issue to discuss your proposal first. This is not required but can save time in creating and reviewing changes.
In general, we follow the "[fork-and-pull](https://github.com/susam/gitpr)" Git workflow:
1. Fork the repository to your own GitHub account.
2. Clone the project to your local environment.
```sh
git clone https://github.com/<user>/linuxwave && cd linuxwave/
```
3. Create a branch locally with a succinct but descriptive name.
```sh
git checkout -b <branch_name>
```
3. Make sure you have everything listed in the [prerequisites](./README.md#prerequisites) section installed. If so, build the project:
```sh
zig build
```
4. Test the functionality by running the binary:
```sh
zig build run
```
5. Start committing changes to the branch.
6. Add your tests or update the existing tests according to the changes and check if the tests are passed.
```sh
zig build test
```
8. Push changes to your fork.
9. Open a PR in our repository and follow the [PR template](./.github/PULL_REQUEST_TEMPLATE.md) so that we can efficiently review the changes.
10. Wait for approval from the repository owners. Discuss the possible changes and update your PR if necessary.
11. The PR will be merged once you have the sign-off of the repository owners.
## License
By contributing, you agree that your contributions will be licensed under [The MIT License](./LICENSE).
|
0 | repos | repos/linuxwave/README.md | # `linuxwave` π§π΅
<p align="center">
<img src="https://github.com/orhun/linuxwave/blob/main/assets/demo.gif" alt="demo">
<a href="https://github.com/orhun/linuxwave/releases"><img src="https://img.shields.io/github/v/release/orhun/linuxwave?style=flat&labelColor=1d1d1d&color=424242&logo=GitHub&logoColor=white" alt="GitHub Release"></a>
<a href="https://codecov.io/gh/orhun/linuxwave"><img src="https://img.shields.io/codecov/c/gh/orhun/linuxwave?style=flat&labelColor=1d1d1d&color=424242&logo=Codecov&logoColor=white" alt="Coverage"></a>
<a href="https://github.com/orhun/linuxwave/actions?query=workflow%3A%22Continuous+Integration%22"><img src="https://img.shields.io/github/actions/workflow/status/orhun/linuxwave/ci.yml?branch=main&style=flat&labelColor=1d1d1d&color=424242&logo=GitHub%20Actions&logoColor=white" alt="Continuous Integration"></a>
<a href="https://github.com/orhun/linuxwave/actions?query=workflow%3A%22Continuous+Deployment%22"><img src="https://img.shields.io/github/actions/workflow/status/orhun/linuxwave/cd.yml?style=flat&labelColor=1d1d1d&color=424242&logo=GitHub%20Actions&logoColor=white&label=deploy" alt="Continuous Deployment"></a>
<a href="https://hub.docker.com/r/orhunp/gpg-tui"><img src="https://img.shields.io/github/actions/workflow/status/orhun/linuxwave/docker.yml?style=flat&labelColor=1d1d1d&color=424242&label=docker&logo=Docker&logoColor=white" alt="Docker Builds"></a>
<a href="https://orhun.dev/linuxwave/docs/"><img src="https://img.shields.io/github/actions/workflow/status/orhun/linuxwave/pages.yml?style=flat&labelColor=1d1d1d&color=424242&logo=Zig&logoColor=white&label=docs" alt="Documentation"></a>
<p align="center">
<a href="https://www.youtube.com/watch?v=SLiEuvDmo8M"><strong>Click here to watch the demo!</strong></a><br>
<a href="https://open.spotify.com/track/0ChxCDjs6wKnl8iu71K7yp">Listen to "linuxwave" on Spotify!</a>
</p>
</p>
<details>
<summary>Table of Contents</summary>
<!-- vim-markdown-toc GFM -->
- [Motivation β¨](#motivation-)
- [Installation π€](#installation-)
- [Build from source](#build-from-source)
- [Prerequisites](#prerequisites)
- [Instructions](#instructions)
- [Binary releases](#binary-releases)
- [Arch Linux](#arch-linux)
- [Void Linux](#void-linux)
- [Docker](#docker)
- [Images](#images)
- [Usage](#usage)
- [Building](#building)
- [Examples π΅](#examples-)
- [Presets πΉ](#presets-)
- [Usage π](#usage-)
- [`scale`](#scale)
- [`note`](#note)
- [`rate`](#rate)
- [`channels`](#channels)
- [`format`](#format)
- [`volume`](#volume)
- [`duration`](#duration)
- [`input`](#input)
- [`output`](#output)
- [Funding π](#funding-)
- [Contributing π±](#contributing-)
- [License βοΈ](#license-)
- [Copyright βοΈ](#copyright-)
<!-- vim-markdown-toc -->
</details>
## Motivation β¨
- [Bash One Liner - Compose Music From Entropy in /dev/urandom](https://web.archive.org/web/20230122184930/https://blog.robertelder.org/bash-one-liner-compose-music/)
- ['Music' from /dev/urandom](https://news.ycombinator.com/item?id=11238247)
## Installation π€
### Build from source
#### Prerequisites
- [Zig](https://ziglang.org/download/) (`0.10.1`)
#### Instructions
1. Clone the repository.
```sh
git clone https://github.com/orhun/linuxwave && cd linuxwave/
```
2. Update git submodules.
```sh
git submodule update --init --recursive
```
3. Build.
```sh
zig build -Drelease-safe
```
Binary will be located at `zig-out/bin/linuxwave`. You can also run the binary directly via `zig build run`.
If you want to use `linuxwave` in your Zig project as a package, the API documentation is available [here](https://orhun.dev/linuxwave/docs).
### Binary releases
See the available binaries for different targets from the [releases page](https://github.com/orhun/linuxwave/releases). They are automated via [Continuous Deployment](.github/workflows/cd.yml) workflow.
Release tarballs are signed with the following PGP key: [0xC0701E98290D90B8](https://keyserver.ubuntu.com/pks/lookup?search=0xC0701E98290D90B8&op=vindex)
### Arch Linux
`linuxwave` can be installed from the [community repository](https://archlinux.org/packages/community/x86_64/linuxwave/) using [pacman](https://wiki.archlinux.org/title/Pacman):
```sh
pacman -S linuxwave
```
### Void Linux
`linuxwave` can be installed from official Void Linux package repository:
```sh
xbps-install linuxwave
```
### Docker
#### Images
Docker builds are [automated](./.github/workflows/docker.yml) and images are available in the following registries:
- [Docker Hub](https://hub.docker.com/r/orhunp/linuxwave)
- [GitHub Container Registry](https://github.com/orhun/linuxwave/pkgs/container/linuxwave)
#### Usage
The following command can be used to generate `output.wav` in the current working directory:
```sh
docker run --rm -v "$(pwd)":/app "orhunp/linuxwave:${TAG:-latest}"
```
#### Building
Custom Docker images can be built from the [Dockerfile](./Dockerfile):
```sh
docker build -t linuxwave .
```
## Examples π΅
**Default**: Read random data from `/dev/urandom` to generate a 20-second music composition in the A4 scale and save it to `output.wav`:
```sh
linuxwave
```
Or play it directly with [mpv](https://mpv.io/) without saving:
```sh
linuxwave -o - | mpv -
```
To use the A minor blues scale:
```sh
linuxwave -s 0,3,5,6,7,10 -n 220 -o blues.wav
```
Read from an arbitrary file and turn it into a 10-second music composition in the C major scale:
```sh
linuxwave -i build.zig -n 261.63 -d 10 -o music.wav
```
Read from stdin via giving `-` as input:
```sh
cat README.md | linuxwave -i -
```
Write to stdout via giving `-` as output:
```
linuxwave -o - > output.wav
```
## Presets πΉ
Generate a **calming music** with a sample rate of 2000 Hz and a 32-bit little-endian signed integer format:
```sh
linuxwave -r 2000 -f S32_LE -o calm.wav
```
Generate a **chiptune music** with a sample rate of 44100 Hz, stereo (2-channel) output and 8-bit unsigned integer format:
```sh
linuxwave -r 44100 -f U8 -c 2 -o chiptune.wav
```
Generate a **boss stage music** with the volume of 65:
```sh
linuxwave -s 0,7,1 -n 60 -v 65 -o boss.wav
```
Generate a **spooky low-fidelity music** with a sample rate of 1000 Hz, 4-channel output:
```sh
linuxwave -s 0,1,5,3 -n 100 -r 1000 -v 55 -c 4 -o spooky_manor.wav
```
Feel free to [submit a pull request](CONTRIBUTING.md) to show off your preset here!
Also, see [this discussion](https://github.com/orhun/linuxwave/discussions/1) for browsing the music generated by our community.
## Usage π
```
Options:
-s, --scale <SCALE> Sets the musical scale [default: 0,2,3,5,7,8,10,12]
-n, --note <HZ> Sets the frequency of the note [default: 440 (A4)]
-r, --rate <HZ> Sets the sample rate [default: 24000]
-c, --channels <NUM> Sets the number of channels [default: 1]
-f, --format <FORMAT> Sets the sample format [default: S16_LE]
-v, --volume <VOL> Sets the volume (0-100) [default: 50]
-d, --duration <SECS> Sets the duration [default: 20]
-i, --input <FILE> Sets the input file [default: /dev/urandom]
-o, --output <FILE> Sets the output file [default: output.wav]
-V, --version Display version information.
-h, --help Display this help and exit.
```
### `scale`
Sets the musical scale for the output. It takes a list of [semitones](https://en.wikipedia.org/wiki/Semitone) separated by commas as its argument.
The default value is `0,2,3,5,7,8,10,12`, which represents a major scale starting from C.
Here are other examples:
- A natural minor scale: `0,2,3,5,7,8,10`
- A pentatonic scale starting from G: `7,9,10,12,14`
- A blues scale starting from D: `2,3,4,6,7,10`
- An octatonic scale starting from F#: `6,7,9,10,12,13,15,16`
- Ryukyuan (Okinawa) Japanese scale: `4,5,7,11`
### `note`
The `note` option sets the frequency of the note played. It takes a frequency in Hz as its argument.
The default value is `440`, which represents A4. You can see the frequencies of musical notes [here](https://pages.mtu.edu/~suits/notefreqs.html).
Other examples would be:
- A3 (220 Hz)
- C4 (261.63 Hz)
- G4 (392 Hz)
- A4 (440 Hz) (default)
- E5 (659.26 Hz)
### `rate`
Sets the sample rate for the output in Hertz (Hz).
The default value is `24000`.
### `channels`
Sets the number of audio channels in the output file. It takes an integer as its argument, representing the number of audio channels to generate. The default value is `1`, indicating mono audio.
For stereo audio, set the value to `2`. For multi-channel audio, specify the desired number of channels.
Note that the more audio channels you use, the larger the resulting file size will be.
### `format`
Sets the sample format for the output file. It takes a string representation of the format as its argument.
The default value is `S16_LE`, which represents 16-bit little-endian signed integer.
Possible values are:
- `U8`: Unsigned 8-bit.
- `S16_LE`: Signed 16-bit little-endian.
- `S24_LE`: Signed 24-bit little-endian.
- `S32_LE`: Signed 32-bit little-endian.
### `volume`
Sets the volume of the output file as a percentage from 0 to 100.
The default value is `50`.
### `duration`
Sets the duration of the output file in seconds. It takes a float as its argument.
The default value is `20` seconds.
### `input`
Sets the input file for the music generation. It takes a filename as its argument.
The default value is `/dev/urandom`, which generates random data.
You can provide _any_ type of file for this argument and it will generate music based on the contents of that file.
### `output`
Sets the output file. It takes a filename as its argument.
The default value is `output.wav`.
## Funding π
If you find `linuxwave` and/or other projects on my [GitHub profile](https://github.com/orhun) useful, consider supporting me on [GitHub Sponsors](https://github.com/sponsors/orhun) or [becoming a patron](https://www.patreon.com/join/orhunp)!
[](https://github.com/sponsors/orhun)
[](https://patreon.com/join/orhunp)
[](https://patreon.com/join/orhunp)
## Contributing π±
See our [Contribution Guide](./CONTRIBUTING.md) and please follow the [Code of Conduct](./CODE_OF_CONDUCT.md) in all your interactions with the project.
## License βοΈ
Licensed under [The MIT License](./LICENSE).
## Copyright βοΈ
Copyright Β© 2023, [Orhun ParmaksΔ±z](mailto:[email protected])
|
0 | repos | repos/linuxwave/build.zig | const std = @import("std");
/// Executable name.
const exe_name = "linuxwave";
/// Version.
const version = "0.1.5"; // managed by release.sh
/// Adds the required packages to the given executable.
///
/// This is used for providing the dependencies for main executable as well as the tests.
fn addPackages(allocator: std.mem.Allocator, exe: *std.build.LibExeObjStep) !void {
exe.addPackagePath("clap", "libs/zig-clap/clap.zig");
for ([_][]const u8{ "file", "gen", "wav" }) |package| {
const path = try std.fmt.allocPrint(allocator, "src/{s}.zig", .{package});
defer allocator.free(path);
exe.addPackagePath(package, path);
}
}
pub fn build(b: *std.build.Builder) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
// Add custom options.
const pie = b.option(bool, "pie", "Build a Position Independent Executable") orelse true;
const relro = b.option(bool, "relro", "Force all relocations to be read-only after processing") orelse true;
const coverage = b.option(bool, "test-coverage", "Generate test coverage") orelse false;
const documentation = b.option(bool, "docs", "Generate documentation") orelse false;
// Add main executable.
const exe = b.addExecutable(exe_name, "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
if (documentation) {
exe.emit_docs = .emit;
}
exe.pie = pie;
exe.link_z_relro = relro;
exe.install();
// Add packages.
try addPackages(b.allocator, exe);
// Add executable options.
const exe_options = b.addOptions();
exe.addOptions("build_options", exe_options);
exe_options.addOption([]const u8, "version", version);
exe_options.addOption([]const u8, "exe_name", exe_name);
// Create the run step and add arguments.
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
// Define the run step.
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// Add tests.
const test_step = b.step("test", "Run tests");
for ([_][]const u8{ "main", "wav", "file", "gen" }) |module| {
const test_module = b.fmt("src/{s}.zig", .{module});
var exe_tests = b.addTest(test_module);
if (coverage) {
exe_tests.setExecCmd(&[_]?[]const u8{
"kcov",
"kcov-output",
null,
});
}
exe_tests.setTarget(target);
exe_tests.setBuildMode(mode);
try addPackages(b.allocator, exe_tests);
exe_tests.addOptions("build_options", exe_options);
test_step.dependOn(&exe_tests.step);
}
}
|
0 | repos/linuxwave | repos/linuxwave/assets/index.html | <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://orhun.dev/linuxwave" />
<meta property="og:title" content="linuxwave" />
<meta
property="og:description"
content="Generate music from the entropy of Linux π§π΅"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<script
async
src="https://umami.orhun.dev/script.js"
data-website-id="5ede5926-bbf9-45ed-8b38-4f7d343a8866"
></script>
<title>π§ linuxwave</title>
<style>
@keyframes intro {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
body,
html {
background-color: #171717;
font-family: Arial, sans-serif;
height: 100%;
margin: 0;
padding: 0;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
img {
max-width: 50%;
border: 1px solid white;
border-radius: 10px;
box-shadow: 0 0 10px white;
animation: intro 1s both;
animation-delay: 0.15s;
}
.buttons {
display: flex;
justify-content: center;
align-items: center;
margin-top: 20px;
animation: intro 2s both;
animation-delay: 0.15s;
}
.button {
margin: 0 10px;
padding: 10px 20px;
font-size: 16px;
background-color: #171717;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
box-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
transition: box-shadow 0.3s ease-in-out;
}
.button:hover {
box-shadow: 0 0 16px rgba(255, 255, 255, 0.8);
}
</style>
</head>
<body>
<div class="container">
<img
src="https://raw.githubusercontent.com/orhun/linuxwave/main/assets/demo.gif"
alt="demo"
/>
<div class="buttons">
<a href="https://github.com/orhun/linuxwave">
<button class="button">GitHub</button>
</a>
<a href="https://www.youtube.com/watch?v=SLiEuvDmo8M">
<button class="button">Watch the Demo</button>
</a>
<a href="docs">
<button class="button">Zig Docs</button>
</a>
</div>
</div>
</body>
</html>
|
0 | repos/linuxwave | repos/linuxwave/src/defaults.zig | const wav = @import("wav");
// Default input file.
pub const input = "/dev/urandom";
// Default output file.
pub const output = "output.wav";
// Semitones from the base note in a major musical scale.
pub const scale = "0,2,3,5,7,8,10,12";
// Default sample rate.
pub const sample_rate: usize = 24000;
// Frequency of A4. (<https://en.wikipedia.org/wiki/A440_(pitch_standard)>)
pub const note: f32 = 440;
// Default number of channels.
pub const channels: usize = 1;
// Default sample format.
pub const format = wav.Format.S16_LE;
// Default volume control.
pub const volume: u8 = 50;
// Default duration.
pub const duration: usize = 20;
|
0 | repos/linuxwave | repos/linuxwave/src/wav.zig | //! Waveform Audio File Format encoder.
//!
//! <https://en.wikipedia.org/wiki/WAV>
const std = @import("std");
/// File header.
const RIFF = [4]u8{ 'R', 'I', 'F', 'F' };
/// RIFF type.
const WAVE = [4]u8{ 'W', 'A', 'V', 'E' };
/// Chunk name for the information about how the waveform data is stored.
const FMT_ = [4]u8{ 'f', 'm', 't', ' ' };
/// Chunk name for the digital audio sample data.
const DATA = [4]u8{ 'd', 'a', 't', 'a' };
// Total length of the header.
const header_len: u32 = 44;
/// Format of the waveform data.
pub const Format = enum {
/// Unsigned 8-bit.
U8,
/// Signed 16-bit little-endian.
S16_LE,
/// Signed 24-bit little-endian.
S24_LE,
/// Signed 32-bit little-endian.
S32_LE,
/// Returns the bytes per sample.
pub fn getNumBytes(self: Format) u16 {
return switch (self) {
.U8 => 1,
.S16_LE => 2,
.S24_LE => 3,
.S32_LE => 4,
};
}
};
/// Encoder configuration.
pub const EncoderConfig = struct {
/// Number of channels.
num_channels: usize,
/// Sample rate.
sample_rate: usize,
/// Sample format.
format: Format,
/// Returns the data length needed for given duration.
pub fn getDataLength(self: EncoderConfig, duration: usize) usize {
return duration * (self.sample_rate * self.num_channels * self.format.getNumBytes()) - header_len;
}
};
/// WAV encoder implementation.
pub fn Encoder(comptime Writer: type) type {
// Position of the data chunk.
const data_chunk_pos: u32 = 36;
return struct {
// Encode WAV.
pub fn encode(writer: Writer, data: []const u8, config: EncoderConfig) !void {
try writeChunks(writer, config, data);
}
/// Writes the headers with placeholder values for length.
///
/// This can be used while streaming the WAV file i.e. when the total length is unknown.
pub fn writeHeader(writer: Writer, config: EncoderConfig) !void {
try writeChunks(writer, config, null);
}
/// Patches the headers to seek back and patch the headers for length values.
pub fn patchHeader(writer: Writer, seeker: anytype, data_len: u32) !void {
try seeker.seekTo(4);
try writer.writeIntLittle(u32, data_chunk_pos + 8 + data_len - 8);
try seeker.seekTo(data_chunk_pos + 4);
try writer.writeIntLittle(u32, data_len);
}
/// Writes the WAV chunks with optional data.
///
/// <WAVE-form> β RIFF('WAVE'
/// <fmt-ck> // Format
/// [<fact-ck>] // Fact chunk
/// [<cue-ck>] // Cue points
/// [<playlist-ck>] // Playlist
/// [<assoc-data-list>] // Associated data list
/// <wave-data> ) // Wave data
fn writeChunks(writer: Writer, config: EncoderConfig, opt_data: ?[]const u8) !void {
// Chunk configuration.
const bytes_per_sample = config.format.getNumBytes();
const num_channels = @intCast(u16, config.num_channels);
const sample_rate = @intCast(u32, config.sample_rate);
const byte_rate = sample_rate * @as(u32, num_channels) * bytes_per_sample;
const block_align: u16 = num_channels * bytes_per_sample;
const bits_per_sample: u16 = bytes_per_sample * 8;
const data_len = if (opt_data) |data| @intCast(u32, data.len) else 0;
// Write the file header.
try writer.writeAll(&RIFF);
if (opt_data != null) {
try writer.writeIntLittle(u32, data_chunk_pos + 8 + data_len - 8);
} else {
try writer.writeIntLittle(u32, 0);
}
try writer.writeAll(&WAVE);
// Write the format chunk.
try writer.writeAll(&FMT_);
// Encode with pulse-code modulation (LPCM).
try writer.writeIntLittle(u32, 16);
// Uncompressed.
try writer.writeIntLittle(u16, 1);
try writer.writeIntLittle(u16, num_channels);
try writer.writeIntLittle(u32, sample_rate);
try writer.writeIntLittle(u32, byte_rate);
try writer.writeIntLittle(u16, block_align);
try writer.writeIntLittle(u16, bits_per_sample);
// Write the data chunk.
try writer.writeAll(&DATA);
if (opt_data) |data| {
try writer.writeIntLittle(u32, data_len);
try writer.writeAll(data);
} else {
try writer.writeIntLittle(u32, 0);
}
}
};
}
test "encode WAV" {
var buffer: [1000]u8 = undefined;
var stream = std.io.fixedBufferStream(&buffer);
var writer = stream.writer();
try Encoder(@TypeOf(writer)).encode(writer, &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, .{
.num_channels = 1,
.sample_rate = 44100,
.format = .S16_LE,
});
try std.testing.expectEqualSlices(u8, "RIFF", buffer[0..4]);
}
test "stream out WAV" {
var buffer: [1000]u8 = undefined;
var fbs = std.io.fixedBufferStream(&buffer);
const WavEncoder = Encoder(@TypeOf(fbs).Writer);
try WavEncoder.writeHeader(fbs.writer(), .{
.num_channels = 1,
.sample_rate = 44100,
.format = .S16_LE,
});
try std.testing.expectEqual(@as(u64, 44), try fbs.getPos());
try std.testing.expectEqual(@as(u32, 0), std.mem.readIntLittle(u32, buffer[4..8]));
try std.testing.expectEqual(@as(u32, 0), std.mem.readIntLittle(u32, buffer[40..44]));
const data = &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0 };
try fbs.writer().writeAll(data);
try std.testing.expectEqual(@as(u64, 52), try fbs.getPos());
try WavEncoder.patchHeader(fbs.writer(), fbs.seekableStream(), data.len);
try std.testing.expectEqual(@as(u32, 44), std.mem.readIntLittle(u32, buffer[4..8]));
try std.testing.expectEqual(@as(u32, 8), std.mem.readIntLittle(u32, buffer[40..44]));
}
|
0 | repos/linuxwave | repos/linuxwave/src/main.zig | const std = @import("std");
const wav = @import("wav");
const gen = @import("gen");
const file = @import("file");
const args = @import("args.zig");
const defaults = @import("defaults.zig");
const build_options = @import("build_options");
const clap = @import("clap");
/// Runs `linuxwave`.
fn run(allocator: std.mem.Allocator, output: anytype) !void {
// Parse command-line arguments.
const cli = try clap.parse(clap.Help, &args.params, args.parsers, .{});
defer cli.deinit();
if (cli.args.help) {
try output.print("{s}\n", .{args.banner});
return clap.help(output, clap.Help, &args.params, args.help_options);
} else if (cli.args.version) {
try output.print("{s} {s}\n", .{ build_options.exe_name, build_options.version });
return;
}
// Create encoder configuration.
const encoder_config = wav.EncoderConfig{
.num_channels = if (cli.args.channels) |channels| channels else defaults.channels,
.sample_rate = if (cli.args.rate) |rate| @floatToInt(usize, rate) else defaults.sample_rate,
.format = if (cli.args.format) |format| format else defaults.format,
};
// Create generator configuration.
var scale = s: {
var scale = std.ArrayList(u8).init(allocator);
var splits = std.mem.split(u8, if (cli.args.scale) |s| s else defaults.scale, ",");
while (splits.next()) |chunk| {
try scale.append(try std.fmt.parseInt(u8, chunk, 0));
}
break :s scale.toOwnedSlice();
};
defer allocator.free(scale);
const generator_config = gen.GeneratorConfig{
.scale = scale,
.note = if (cli.args.note) |note| note else defaults.note,
.volume = if (cli.args.volume) |volume| volume else defaults.volume,
};
const duration = if (cli.args.duration) |duration| duration else defaults.duration;
const data_len = encoder_config.getDataLength(duration) / (gen.Generator.sample_count - 2);
// Read data from a file or stdin.
const input_file = if (cli.args.input) |input| input else defaults.input;
const buffer = b: {
if (std.mem.eql(u8, input_file, "-")) {
try output.print("Reading {d} bytes from stdin\n", .{data_len});
var list = try std.ArrayList(u8).initCapacity(allocator, data_len);
var buffer = list.allocatedSlice();
const stdin = std.io.getStdIn().reader();
try stdin.readNoEof(buffer);
break :b buffer;
} else {
try output.print("Reading {d} bytes from {s}\n", .{ data_len, input_file });
break :b try file.readBytes(allocator, input_file, data_len);
}
};
defer allocator.free(buffer);
// Generate music.
const generator = gen.Generator.init(generator_config);
var data = std.ArrayList(u8).init(allocator);
for (buffer) |v| {
var gen_data = try generator.generate(allocator, v);
defer allocator.free(gen_data);
try data.appendSlice(gen_data);
}
// Encode WAV.
const out = if (cli.args.output) |out| out else defaults.output;
const writer = w: {
if (std.mem.eql(u8, out, "-")) {
try output.print("Writing to stdout\n", .{});
break :w std.io.getStdOut().writer();
} else {
try output.print("Saving to {s}\n", .{out});
const out_file = try std.fs.cwd().createFile(out, .{});
break :w out_file.writer();
}
};
const wav_data = data.toOwnedSlice();
defer allocator.free(wav_data);
try wav.Encoder(@TypeOf(writer)).encode(writer, wav_data, encoder_config);
}
/// Entry-point.
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
const stderr = std.io.getStdErr().writer();
run(allocator, stderr) catch |err| {
try stderr.print("Error occurred: {}\n", .{err});
};
}
test "run" {
const allocator = std.testing.allocator;
var buffer = std.ArrayList(u8).init(allocator);
const output = buffer.writer();
try run(allocator, output);
const result = buffer.toOwnedSlice();
defer allocator.free(result);
try std.testing.expectEqualStrings(
\\Reading 96 bytes from /dev/urandom
\\Saving to output.wav
\\
, result);
}
|
0 | repos/linuxwave | repos/linuxwave/src/file.zig | //! File operations helper.
const std = @import("std");
/// Reads the given file and returns a byte array with the length of `len`.
pub fn readBytes(
allocator: std.mem.Allocator,
path: []const u8,
len: usize,
) ![]u8 {
const file = try std.fs.cwd().openFile(path, .{});
defer file.close();
var list = try std.ArrayList(u8).initCapacity(allocator, len);
var buffer = list.allocatedSlice();
const bytes_read = try file.read(buffer);
return buffer[0..bytes_read];
}
test "read bytes from the file" {
// Get the current directory.
var cwd_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var cwd = try std.os.getcwd(&cwd_buffer);
// Concatenate the current directory with the builder file.
const allocator = std.testing.allocator;
const path = try std.fs.path.join(allocator, &.{ cwd, "build.zig" });
defer allocator.free(path);
// Read the contents of the file and compare.
const bytes = try readBytes(allocator, path, 9);
try std.testing.expectEqualStrings("const std", bytes);
defer allocator.free(bytes);
}
|
0 | repos/linuxwave | repos/linuxwave/src/gen.zig | //! Music generator.
const std = @import("std");
/// Generator configuration.
pub const GeneratorConfig = struct {
/// Semitones from the base note in a major musical scale.
scale: []const u8,
/// Frequency of the note.
///
/// <https://pages.mtu.edu/~suits/notefreqs.html>
note: f32,
/// Volume control.
volume: u8,
};
/// Generator implementation.
pub const Generator = struct {
/// Number of calculated samples per sine curve (affects perceived frequency).
pub const sample_count: usize = 10000;
/// Configuration.
config: GeneratorConfig,
/// Creates a new instance.
pub fn init(config: GeneratorConfig) Generator {
return Generator{ .config = config };
}
/// Generates a sound from the given sample.
///
/// Returns an array that contains the amplitudes of the sound wave at a given point in time.
pub fn generate(self: Generator, allocator: std.mem.Allocator, sample: u8) ![]u8 {
var buffer = std.ArrayList(u8).init(allocator);
var i: usize = 0;
while (i < sample_count) : (i += 1) {
// Calculate the frequency according to the equal temperament.
// Hertz = 440 * 2^(semitone distance / 12)
// (<http://en.wikipedia.org/wiki/Equal_temperament>)
var amp = @sin(self.config.note * std.math.pi *
std.math.pow(f32, 2, @intToFloat(f32, self.config.scale[sample % self.config.scale.len]) / 12) *
(@intToFloat(f64, i) * 0.0001));
// Scale the amplitude between 0 and 256.
amp = (amp * std.math.maxInt(u8) / 2) + (std.math.maxInt(u8) / 2);
// Apply the volume control.
amp = amp * @intToFloat(f64, self.config.volume) / 100;
try buffer.append(@floatToInt(u8, amp));
}
return buffer.toOwnedSlice();
}
};
test "generate music" {
const config = GeneratorConfig{
.scale = &[_]u8{ 0, 1 },
.note = 440,
.volume = 100,
};
const generator = Generator.init(config);
const allocator = std.testing.allocator;
var data1 = try generator.generate(allocator, 'a');
defer allocator.free(data1);
try std.testing.expectEqualSlices(u8, &[_]u8{ 127, 145, 163, 181, 197, 212, 225, 235 }, data1[0..8]);
try std.testing.expect(data1.len == 10000);
var data2 = try generator.generate(allocator, 'b');
defer allocator.free(data2);
try std.testing.expectEqualSlices(u8, &[_]u8{ 127, 144, 161, 178, 193, 208, 221, 232 }, data2[0..8]);
try std.testing.expect(data2.len == 10000);
}
|
0 | repos/linuxwave | repos/linuxwave/src/args.zig | const wav = @import("wav");
const clap = @import("clap");
// Banner text.
pub const banner =
\\
\\ β β
\\ β ββββββββββββββββ β Generate music from the entropy of Linux π§π΅
\\ ββββββββββββββββββ https://github.com/orhun/linuxwave
\\
\\Options:
;
// Parameters that the program can take.
pub const params = clap.parseParamsComptime(
\\-s, --scale <SCALE> Sets the musical scale [default: 0,2,3,5,7,8,10,12]
\\-n, --note <HZ> Sets the frequency of the note [default: 440 (A4)]
\\-r, --rate <HZ> Sets the sample rate [default: 24000]
\\-c, --channels <NUM> Sets the number of channels [default: 1]
\\-f, --format <FORMAT> Sets the sample format [default: S16_LE]
\\-v, --volume <VOL> Sets the volume (0-100) [default: 50]
\\-d, --duration <SECS> Sets the duration [default: 20]
\\-i, --input <FILE> Sets the input file [default: /dev/urandom]
\\-o, --output <FILE> Sets the output file [default: output.wav]
\\-V, --version Display version information.
\\-h, --help Display this help and exit.
);
// Style options for the help text.
pub const help_options = clap.HelpOptions{ .spacing_between_parameters = 0, .indent = 2, .description_on_new_line = false };
/// Argument parsers.
pub const parsers = .{
.NUM = clap.parsers.int(usize, 0),
.SCALE = clap.parsers.string,
.HZ = clap.parsers.float(f32),
.VOL = clap.parsers.int(u8, 0),
.SECS = clap.parsers.int(usize, 0),
.FILE = clap.parsers.string,
.FORMAT = clap.parsers.enumeration(wav.Format),
};
|
0 | repos | repos/libxev/shell.nix | (import
(
let
flake-compat = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat;
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${flake-compat.locked.rev}.tar.gz";
sha256 = flake-compat.locked.narHash;
}
)
{src = ./.;})
.shellNix
|
0 | repos | repos/libxev/README.md | # libxev
libxev is a cross-platform event loop. libxev provides a unified event loop
abstraction for non-blocking IO, timers, signals, events, and more that
works on macOS, Windows, Linux, and WebAssembly (browser and WASI). It is
written in [Zig](https://ziglang.org/) but exports a C-compatible API (which
further makes it compatible with any language out there that can communicate
with C APIs).
**Project Status: π² Unstable, alpha-ish quality.** The feature list is quite
good across multiple platforms, but there are plenty of missing features.
The project hasn't been well tested in real-world environments and there
are lots of low-hanging fruit for performance optimization. I'm not promising
any API compatibility at this point, either. If you want a production ready,
high quality, generalized event loop implementation check out
[libuv](https://libuv.org/), libev, etc.
**Why a new event loop library?** A few reasons. One, I think Zig lacks
a generalized event loop comparable to libuv in features ("generalized"
being a key word here). Two, I wanted to build a library like this around
the design patterns of [io_uring](https://unixism.net/loti/what_is_io_uring.html),
even mimicking its style on top of other OS primitives (
[credit to this awesome blog post](https://tigerbeetle.com/blog/a-friendly-abstraction-over-iouring-and-kqueue/)).
Three, I wanted an event loop library that could build to WebAssembly
(both WASI and freestanding) and that didn't really fit well
into the goals of API style of existing libraries without bringing in
something super heavy like Emscripten. The motivation for this library
primarily though is scratching my own itch!
## Features
**Cross-platform.** Linux (`io_uring` and `epoll`), macOS (`kqueue`),
WebAssembly + WASI (`poll_oneoff`, threaded and non-threaded runtimes).
(Windows support is planned and coming soon)
**[Proactor API](https://en.wikipedia.org/wiki/Proactor_pattern).** Work
is submitted to the libxev event loop and the caller is notified of
work _completion_, as opposed to work _readiness_.
**Zero runtime allocations.** This helps make runtime performance more
predictable and makes libxev well suited for embedded environments.
**Timers, TCP, UDP, Files, Processes.** High-level platform-agnostic APIs for
interacting with timers, TCP/UDP sockets, files, processes, and more. For
platforms that don't support async IO, the file operations are automatically
scheduled to a thread pool.
**Generic Thread Pool (Optional).** You can create a generic thread pool,
configure its resource utilization, and use this to perform custom background
tasks. The thread pool is used by some backends to do non-blocking tasks that
don't have reliable non-blocking APIs (such as local file operations with
`kqueue`). The thread pool can be shared across multiple threads and event
loops to optimize resource utilization.
**Low-level and High-Level API.** The high-level API is platform-agnostic
but has some opinionated behavior and limited flexibility. The high-level
API is recommended but the low-level API is always an available escape hatch.
The low-level API is platform-specific and provides a mechanism for libxev
users to squeeze out maximum performance. The low-level API is _just enough
abstraction_ above the OS interface to make it easier to use without
sacrificing noticable performance.
**Tree Shaking (Zig).** This is a feature of Zig, but substantially benefits
libraries such as libxev. Zig will only include function calls and features
that you actually use. If you don't use a particular kind of high-level
watcher (such as UDP sockets), then the functionality related to that
abstraction is not compiled into your final binary at all. This lets libxev
support optional "nice-to-have" functionality that may be considered
"bloat" in some cases, but the end user doesn't have to pay for it.
**Dependency-free.** libxev has no dependencies other than the built-in
OS APIs at runtime. The C library depends on libc. This makes it very
easy to cross-compile.
### Roadmap
There are plenty of missing features that I still want to add:
* Pipe high-level API
* Signal handlers
* Filesystem events
* Windows backend
* Freestanding WebAssembly support via an external event loop (i.e. the browser)
And more...
### Performance
There is plenty of room for performance improvements, and I want to be
fully clear that I haven't done a lot of optimization work. Still,
performance is looking good. I've tried to port many of
[libuv benchmarks](https://github.com/libuv/libuv) to use the libxev
API.
I won't post specific benchmark results until I have a better
environment to run them in. As a _very broad generalization_,
you shouldn't notice a slowdown using libxev compared to other
major event loops. This may differ on a feature-by-feature basis, and
if you can show really poor performance in an issue I'm interested
in resolving it!
## Example
The example below shows an identical program written in Zig and in C
that uses libxev to run a single 5s timer. This is almost silly how
simple it is but is meant to just convey the overall feel of the library
rather than a practical use case.
<table>
<tr>
<td> Zig </td> <td> C </td>
</tr>
<tr>
<td>
```zig
const xev = @import("xev");
pub fn main() !void {
var loop = try xev.Loop.init(.{});
defer loop.deinit();
const w = try xev.Timer.init();
defer w.deinit();
// 5s timer
var c: xev.Completion = undefined;
w.run(&loop, &c, 5000, void, null, &timerCallback);
try loop.run(.until_done);
}
fn timerCallback(
userdata: ?*void,
loop: *xev.Loop,
c: *xev.Completion,
result: xev.Timer.RunError!void,
) xev.CallbackAction {
_ = userdata;
_ = loop;
_ = c;
_ = result catch unreachable;
return .disarm;
}
```
</td>
<td>
```zig
#include <stddef.h>
#include <stdio.h>
#include <xev.h>
xev_cb_action timerCallback(xev_loop* loop, xev_completion* c, int result, void *userdata) {
return XEV_DISARM;
}
int main(void) {
xev_loop loop;
if (xev_loop_init(&loop) != 0) {
printf("xev_loop_init failure\n");
return 1;
}
xev_watcher w;
if (xev_timer_init(&w) != 0) {
printf("xev_timer_init failure\n");
return 1;
}
xev_completion c;
xev_timer_run(&w, &loop, &c, 5000, NULL, &timerCallback);
xev_loop_run(&loop, XEV_RUN_UNTIL_DONE);
xev_timer_deinit(&w);
xev_loop_deinit(&loop);
return 0;
}
```
</td>
</tr>
</table>
## Installation (Zig)
**These instructions are for Zig downstream users only.** If you are
using the C API to libxev, see the "Build" section.
This package works with the Zig package manager introduced in Zig 0.11.
Create a `build.zig.zon` file like this:
```zig
.{
.name = "my-project",
.version = "0.0.0",
.dependencies = .{
.libxev = .{
.url = "https://github.com/mitchellh/libxev/archive/<git-ref-here>.tar.gz",
.hash = "12208070233b17de6be05e32af096a6760682b48598323234824def41789e993432c",
},
},
}
```
And in your `build.zig`:
```zig
const xev = b.dependency("libxev", .{ .target = target, .optimize = optimize });
exe.addModule("xev", xev.module("xev"));
```
## Documentation
π§ Documentation is a work-in-progress. π§
Currently, documentation is available in three forms: **man pages**,
**examples**, and **code comments.** In the future, I plan on writing detailed
guides and API documentation in website form, but that isn't currently
available.
### Man Pages
The man pages are relatively detailed! `xev(7)` will
give you a good overview of the entire library. `xev-zig(7)` and
`xev-c(7)` will provide overviews of the Zig and C API, respectively.
From there, API-specifc man pages such as `xev_loop_init(3)` are
available. This is the best documentation currently.
There are multiple ways to browse the man pages. The most immediately friendly
is to just browse the raw man page sources in the `docs/` directory in
your web browser. The man page source is a _markdown-like_ syntax so it
renders _okay_ in your browser via GitHub.
Another approach is to run `zig build -Dman-pages` and the man pages
will be available in `zig-out`. This requires
[scdoc](https://git.sr.ht/~sircmpwn/scdoc)
to be installed (this is available in most package managers).
Once you've built the man pages, you can render them by path:
```
$ man zig-out/share/man/man7/xev.7
```
And the final approach is to install libxev via your favorite package
manager (if and when available), which should hopefully put your man pages
into your man path, so you can just do `man 7 xev`.
### Examples
There are examples available in the `examples/` folder. The examples are
available in both C and Zig, and you can tell which one is which using
the file extension.
To build an example, use the following:
```
$ zig build -Dexample-name=_basic.zig
...
$ zig-out/bin/example-basic
...
```
The `-Dexample-name` value should be the filename including the extension.
### Code Comments
The Zig code is well commented. If you're comfortable reading code comments
you can find a lot of insight within them. The source is in the `src/`
directory.
# Build
Build requires the installation of the latest [Zig nightly](https://ziglang.org/download/).
**libxev has no other build dependencies.**
Once installed, `zig build install` on its own will build the full library and output
a [FHS-compatible](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard)
directory in `zig-out`. You can customize the output directory with the
`--prefix` flag.
## Tests
libxev has a large and growing test suite. To run the tests for the current
platform:
```sh
$ zig build test
...
```
This will run all the tests for all the supported features for the current
host platform. For example, on Linux this will run both the full io_uring
and epoll test suite.
**You can build and run tests for other platforms** by cross-compiling the
test executable, copying it to a target machine and executing it. For example,
the below shows how to cross-compile and build the tests for macOS from Linux:
```sh
$ zig build -Dtarget=aarch64-macos -Dinstall-tests
...
$ file zig-out/bin/xev-test
zig-out/bin/xev-test: Mach-O 64-bit arm64 executable
```
**WASI is a special-case.** You can run tests for WASI if you have
[wasmtime](https://wasmtime.dev/) installed:
```
$ zig build test -Dtarget=wasm32-wasi -Dwasmtime
...
```
|
0 | repos | repos/libxev/build.zig.zon | .{
.name = "libxev",
.minimum_zig_version = "0.12.0-dev.3191+9cf28d1e9",
.paths = .{""},
.version = "0.0.0",
}
|
0 | repos | repos/libxev/build.zig | const std = @import("std");
const CompileStep = std.build.Step.Compile;
const ScdocStep = @import("src/build/ScdocStep.zig");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
_ = b.addModule("xev", .{ .root_source_file = b.path("src/main.zig") });
const man_pages = b.option(
bool,
"man-pages",
"Set to true to build man pages. Requires scdoc. Defaults to true if scdoc is found.",
) orelse if (b.findProgram(&[_][]const u8{"scdoc"}, &[_][]const u8{})) |_|
true
else |err| switch (err) {
error.FileNotFound => false,
else => return err,
};
const bench_name = b.option(
[]const u8,
"bench-name",
"Build and install a single benchmark",
);
const bench_install = b.option(
bool,
"bench",
"Install the benchmark binaries to zig-out/bench",
) orelse (bench_name != null);
const example_name = b.option(
[]const u8,
"example-name",
"Build and install a single example",
);
const example_install = b.option(
bool,
"example",
"Install the example binaries to zig-out/example",
) orelse (example_name != null);
const test_install = b.option(
bool,
"install-tests",
"Install the test binaries into zig-out",
) orelse false;
// Our tests require libc on Linux and Mac. Note that libxev itself
// does NOT require libc.
const test_libc = switch (target.result.os.tag) {
.linux, .macos => true,
else => false,
};
// We always build our test exe as part of `zig build` so that
// we can easily run it manually without digging through the cache.
const test_exe = b.addTest(.{
.name = "xev-test",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
if (test_libc) test_exe.linkLibC(); // Tests depend on libc, libxev does not
if (test_install) b.installArtifact(test_exe);
// zig build test test binary and runner.
const tests_run = b.addRunArtifact(test_exe);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&tests_run.step);
// Static C lib
const static_c_lib: ?*std.Build.Step.Compile = if (target.result.os.tag != .wasi) lib: {
const static_lib = b.addStaticLibrary(.{
.name = "xev",
.root_source_file = b.path("src/c_api.zig"),
.target = target,
.optimize = optimize,
});
static_lib.linkLibC();
// Link required libraries if targeting Windows
if (target.result.os.tag == .windows) {
static_lib.linkSystemLibrary("ws2_32");
static_lib.linkSystemLibrary("mswsock");
}
b.installArtifact(static_lib);
b.default_step.dependOn(&static_lib.step);
const static_binding_test = b.addExecutable(.{
.name = "static-binding-test",
.target = target,
.optimize = optimize,
});
static_binding_test.linkLibC();
static_binding_test.addIncludePath(b.path("include"));
static_binding_test.addCSourceFile(.{
.file = b.path("examples/_basic.c"),
.flags = &[_][]const u8{ "-Wall", "-Wextra", "-pedantic", "-std=c99", "-D_POSIX_C_SOURCE=199309L" },
});
static_binding_test.linkLibrary(static_lib);
if (test_install) b.installArtifact(static_binding_test);
const static_binding_test_run = b.addRunArtifact(static_binding_test);
test_step.dependOn(&static_binding_test_run.step);
break :lib static_lib;
} else null;
// Dynamic C lib. We only build this if this is the native target so we
// can link to libxml2 on our native system.
if (target.query.isNative()) {
const dynamic_lib_name = "xev";
const dynamic_lib = b.addSharedLibrary(.{
.name = dynamic_lib_name,
.root_source_file = b.path("src/c_api.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(dynamic_lib);
b.default_step.dependOn(&dynamic_lib.step);
const dynamic_binding_test = b.addExecutable(.{
.name = "dynamic-binding-test",
.target = target,
.optimize = optimize,
});
dynamic_binding_test.linkLibC();
dynamic_binding_test.addIncludePath(b.path("include"));
dynamic_binding_test.addCSourceFile(.{
.file = b.path("examples/_basic.c"),
.flags = &[_][]const u8{ "-Wall", "-Wextra", "-pedantic", "-std=c99" },
});
dynamic_binding_test.linkLibrary(dynamic_lib);
if (test_install) b.installArtifact(dynamic_binding_test);
const dynamic_binding_test_run = b.addRunArtifact(dynamic_binding_test);
test_step.dependOn(&dynamic_binding_test_run.step);
}
// C Headers
const c_header = b.addInstallFileWithDir(
b.path("include/xev.h"),
.header,
"xev.h",
);
b.getInstallStep().dependOn(&c_header.step);
// pkg-config
{
const file = try b.cache_root.join(b.allocator, &[_][]const u8{"libxev.pc"});
const pkgconfig_file = try std.fs.cwd().createFile(file, .{});
const writer = pkgconfig_file.writer();
try writer.print(
\\prefix={s}
\\includedir=${{prefix}}/include
\\libdir=${{prefix}}/lib
\\
\\Name: libxev
\\URL: https://github.com/mitchellh/libxev
\\Description: High-performance, cross-platform event loop
\\Version: 0.1.0
\\Cflags: -I${{includedir}}
\\Libs: -L${{libdir}} -lxev
, .{b.install_prefix});
defer pkgconfig_file.close();
b.getInstallStep().dependOn(&b.addInstallFileWithDir(
.{ .cwd_relative = file },
.prefix,
"share/pkgconfig/libxev.pc",
).step);
}
// Benchmarks
_ = try benchTargets(b, target, optimize, bench_install, bench_name);
// Examples
_ = try exampleTargets(b, target, optimize, static_c_lib, example_install, example_name);
// Man pages
if (man_pages) {
const scdoc_step = ScdocStep.create(b);
try scdoc_step.install();
}
}
fn benchTargets(
b: *std.Build,
target: std.Build.ResolvedTarget,
mode: std.builtin.OptimizeMode,
install: bool,
install_name: ?[]const u8,
) !std.StringHashMap(*std.Build.Step.Compile) {
_ = mode;
var map = std.StringHashMap(*std.Build.Step.Compile).init(b.allocator);
// Open the directory
const c_dir_path = "src/bench";
var c_dir = try std.fs.cwd().openDir(comptime thisDir() ++ "/" ++ c_dir_path, .{ .iterate = true });
defer c_dir.close();
// Go through and add each as a step
var c_dir_it = c_dir.iterate();
while (try c_dir_it.next()) |entry| {
// Get the index of the last '.' so we can strip the extension.
const index = std.mem.lastIndexOfScalar(u8, entry.name, '.') orelse continue;
if (index == 0) continue;
// Name of the app and full path to the entrypoint.
const name = entry.name[0..index];
const path = try std.fs.path.join(b.allocator, &[_][]const u8{
c_dir_path,
entry.name,
});
// If we have specified a specific name, only install that one.
if (install_name) |n| {
if (!std.mem.eql(u8, n, name)) continue;
}
// Executable builder.
const c_exe = b.addExecutable(.{
.name = name,
.root_source_file = b.path(path),
.target = target,
.optimize = .ReleaseFast, // benchmarks are always release fast
});
c_exe.root_module.addImport("xev", b.modules.get("xev").?);
if (install) {
const install_step = b.addInstallArtifact(c_exe, .{
.dest_dir = .{ .override = .{ .custom = "bench" } },
});
b.getInstallStep().dependOn(&install_step.step);
}
// Store the mapping
try map.put(try b.allocator.dupe(u8, name), c_exe);
}
return map;
}
fn exampleTargets(
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
c_lib_: ?*std.Build.Step.Compile,
install: bool,
install_name: ?[]const u8,
) !void {
// Ignore if we're not installing
if (!install) return;
// Open the directory
const c_dir_path = (comptime thisDir()) ++ "/examples";
var c_dir = try std.fs.cwd().openDir(c_dir_path, .{ .iterate = true });
defer c_dir.close();
// Go through and add each as a step
var c_dir_it = c_dir.iterate();
while (try c_dir_it.next()) |entry| {
// Get the index of the last '.' so we can strip the extension.
const index = std.mem.lastIndexOfScalar(u8, entry.name, '.') orelse continue;
if (index == 0) continue;
// If we have specified a specific name, only install that one.
if (install_name) |n| {
if (!std.mem.eql(u8, n, entry.name)) continue;
}
// Name of the app and full path to the entrypoint.
const name = entry.name[0..index];
const path = try std.fs.path.join(b.allocator, &[_][]const u8{
c_dir_path,
entry.name,
});
const is_zig = std.mem.eql(u8, entry.name[index + 1 ..], "zig");
if (is_zig) {
const c_exe = b.addExecutable(.{
.name = name,
.root_source_file = .{ .cwd_relative = path },
.target = target,
.optimize = optimize,
});
c_exe.root_module.addImport("xev", b.modules.get("xev").?);
if (install) {
const install_step = b.addInstallArtifact(c_exe, .{
.dest_dir = .{ .override = .{ .custom = "example" } },
});
b.getInstallStep().dependOn(&install_step.step);
}
} else {
const c_lib = c_lib_ orelse return error.UnsupportedPlatform;
const c_exe = b.addExecutable(.{
.name = name,
.target = target,
.optimize = optimize,
});
c_exe.linkLibC();
c_exe.addIncludePath(b.path("include"));
c_exe.addCSourceFile(.{
.file = .{ .cwd_relative = path },
.flags = &[_][]const u8{
"-Wall",
"-Wextra",
"-pedantic",
"-std=c99",
"-D_POSIX_C_SOURCE=199309L",
},
});
c_exe.linkLibrary(c_lib);
if (install) {
const install_step = b.addInstallArtifact(c_exe, .{
.dest_dir = .{ .override = .{ .custom = "example" } },
});
b.getInstallStep().dependOn(&install_step.step);
}
}
// If we have specified a specific name, only install that one.
if (install_name) |_| break;
} else {
if (install_name) |n| {
std.debug.print("No example file named: {s}\n", .{n});
std.debug.print("Choices:\n", .{});
var c_dir_it2 = c_dir.iterate();
while (try c_dir_it2.next()) |entry| {
std.debug.print("\t{s}\n", .{entry.name});
}
return error.InvalidExampleName;
}
}
}
/// Path to the directory with the build.zig.
fn thisDir() []const u8 {
return std.fs.path.dirname(@src().file) orelse unreachable;
}
|
0 | repos | repos/libxev/flake.nix | {
description = "libxev is a high performance, cross-platform event loop.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-24.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
zig.url = "github:mitchellh/zig-overlay";
# Used for shell.nix
flake-compat = {
url = github:edolstra/flake-compat;
flake = false;
};
};
outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs: let
overlays = [
# Other overlays
(final: prev: rec {
zigpkgs = inputs.zig.packages.${prev.system};
zig = inputs.zig.packages.${prev.system}."0.13.0";
# Latest versions
wasmtime = inputs.nixpkgs-unstable.legacyPackages.${prev.system}.wasmtime;
wasmer = inputs.nixpkgs-unstable.legacyPackages.${prev.system}.wasmer;
# Our package
libxev = prev.callPackage ./nix/package.nix {};
})
];
# Our supported systems are the same supported systems as the Zig binaries
systems = builtins.attrNames inputs.zig.packages;
in
flake-utils.lib.eachSystem systems (
system: let
pkgs = import nixpkgs {inherit overlays system;};
in rec {
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
mandoc
scdoc
zig
# Wasm
wabt
wasmtime
wasmer
# Website
nodejs
];
};
# For compatibility with older versions of the `nix` binary
devShell = self.devShells.${system}.default;
# Our package
packages.libxev = pkgs.libxev;
defaultPackage = packages.libxev;
}
);
}
|
0 | repos | repos/libxev/flake.lock | {
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1717895720,
"narHash": "sha256-Dl6JKx1rIDEuv4q9rtlt9QwyerSQbrk1bUtNHzx9bIY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e0826ec06d2b3db8e28e280d68179f022b1d160",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "release-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1675584158,
"narHash": "sha256-SBkchaDzCHxnPNRDdtZ5ko5caHio9iS0Mbyn/xXbXxs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d840126a0890621e7b220894d749132dd4bde6a0",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1708161998,
"narHash": "sha256-6KnemmUorCvlcAvGziFosAVkrlWZGIc6UNT9GUYr0jQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "84d981bae8b5e783b3b548de505b22880559515f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable",
"zig": "zig"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"zig": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1717848532,
"narHash": "sha256-d+xIUvSTreHl8pAmU1fnmkfDTGQYCn2Rb/zOwByxS2M=",
"owner": "mitchellh",
"repo": "zig-overlay",
"rev": "02fc5cc555fc14fda40c42d7c3250efa43812b43",
"type": "github"
},
"original": {
"owner": "mitchellh",
"repo": "zig-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
|
0 | repos/libxev | repos/libxev/nix/package.nix | { stdenv
, lib
, zig
, pkg-config
, scdoc
}:
stdenv.mkDerivation rec {
pname = "libxev";
version = "0.1.0";
src = ./..;
nativeBuildInputs = [ zig scdoc pkg-config ];
buildInputs = [];
dontConfigure = true;
preBuild = ''
# Necessary for zig cache to work
export HOME=$TMPDIR
'';
installPhase = ''
runHook preInstall
zig build -Doptimize=ReleaseFast -Dman-pages --prefix $out install
runHook postInstall
'';
outputs = [ "out" "dev" "man" ];
meta = with lib; {
description = "A high performance, cross-platform event loop.";
homepage = "https://github.com/mitchellh/libxev";
license = licenses.mit;
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
};
}
|
0 | repos/libxev | repos/libxev/include/xev.h | #ifndef XEV_H
#define XEV_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
/* TODO(mitchellh): we should use platform detection to set the correct
* byte sizes here. We choose some overly large values for now so that
* we can retain ABI compatibility. */
const size_t XEV_SIZEOF_LOOP = 512;
const size_t XEV_SIZEOF_COMPLETION = 320;
const size_t XEV_SIZEOF_WATCHER = 256;
const size_t XEV_SIZEOF_THREADPOOL = 64;
const size_t XEV_SIZEOF_THREADPOOL_BATCH = 24;
const size_t XEV_SIZEOF_THREADPOOL_TASK = 24;
const size_t XEV_SIZEOF_THREADPOOL_CONFIG = 64;
#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
typedef max_align_t XEV_ALIGN_T;
#else
// max_align_t is usually synonymous with the largest scalar type, which is long double on most platforms, and its alignment requirement is either 8 or 16.
typedef long double XEV_ALIGN_T;
#endif
/* There's a ton of preprocessor directives missing here for real cross-platform
* compatibility. I'm going to defer to the community or future issues to help
* plug those holes. For now, we get some stuff working we can test! */
/* Opaque types. These types have a size defined so that they can be
* statically allocated but they are not to be accessed. */
// todo: give struct individual alignment, instead of max alignment
typedef struct { XEV_ALIGN_T _pad; uint8_t data[XEV_SIZEOF_LOOP - sizeof(XEV_ALIGN_T)]; } xev_loop;
typedef struct { XEV_ALIGN_T _pad; uint8_t data[XEV_SIZEOF_COMPLETION - sizeof(XEV_ALIGN_T)]; } xev_completion;
typedef struct { XEV_ALIGN_T _pad; uint8_t data[XEV_SIZEOF_WATCHER - sizeof(XEV_ALIGN_T)]; } xev_watcher;
typedef struct { XEV_ALIGN_T _pad; uint8_t data[XEV_SIZEOF_THREADPOOL - sizeof(XEV_ALIGN_T)]; } xev_threadpool;
typedef struct { XEV_ALIGN_T _pad; uint8_t data[XEV_SIZEOF_THREADPOOL_BATCH - sizeof(XEV_ALIGN_T)]; } xev_threadpool_batch;
typedef struct { XEV_ALIGN_T _pad; uint8_t data[XEV_SIZEOF_THREADPOOL_TASK - sizeof(XEV_ALIGN_T)]; } xev_threadpool_task;
typedef struct { XEV_ALIGN_T _pad; uint8_t data[XEV_SIZEOF_THREADPOOL_CONFIG - sizeof(XEV_ALIGN_T)]; } xev_threadpool_config;
/* Callback types. */
typedef enum { XEV_DISARM = 0, XEV_REARM = 1 } xev_cb_action;
typedef void (*xev_task_cb)(xev_threadpool_task* t);
typedef xev_cb_action (*xev_timer_cb)(xev_loop* l, xev_completion* c, int result, void* userdata);
typedef xev_cb_action (*xev_async_cb)(xev_loop* l, xev_completion* c, int result, void* userdata);
typedef enum {
XEV_RUN_NO_WAIT = 0,
XEV_RUN_ONCE = 1,
XEV_RUN_UNTIL_DONE = 2,
} xev_run_mode_t;
typedef enum {
XEV_COMPLETION_DEAD = 0,
XEV_COMPLETION_ACTIVE = 1,
} xev_completion_state_t;
/* Documentation for functions can be found in man pages or online. I
* purposely do not add docs to the header so that you can quickly scan
* all exported functions. */
int xev_loop_init(xev_loop* loop);
void xev_loop_deinit(xev_loop* loop);
int xev_loop_run(xev_loop* loop, xev_run_mode_t mode);
int64_t xev_loop_now(xev_loop* loop);
void xev_loop_update_now(xev_loop* loop);
void xev_completion_zero(xev_completion* c);
xev_completion_state_t xev_completion_state(xev_completion* c);
void xev_threadpool_config_init(xev_threadpool_config* config);
void xev_threadpool_config_set_stack_size(xev_threadpool_config* config, uint32_t v);
void xev_threadpool_config_set_max_threads(xev_threadpool_config* config, uint32_t v);
int xev_threadpool_init(xev_threadpool* pool, xev_threadpool_config* config);
void xev_threadpool_deinit(xev_threadpool* pool);
void xev_threadpool_shutdown(xev_threadpool* pool);
void xev_threadpool_schedule(xev_threadpool* pool, xev_threadpool_batch *batch);
void xev_threadpool_task_init(xev_threadpool_task* t, xev_task_cb cb);
void xev_threadpool_batch_init(xev_threadpool_batch* b);
void xev_threadpool_batch_push_task(xev_threadpool_batch* b, xev_threadpool_task *t);
void xev_threadpool_batch_push_batch(xev_threadpool_batch* b, xev_threadpool_batch *other);
int xev_timer_init(xev_watcher *w);
void xev_timer_deinit(xev_watcher *w);
void xev_timer_run(xev_watcher *w, xev_loop* loop, xev_completion* c, uint64_t next_ms, void* userdata, xev_timer_cb cb);
void xev_timer_reset(xev_watcher *w, xev_loop* loop, xev_completion* c, xev_completion *c_cancel, uint64_t next_ms, void* userdata, xev_timer_cb cb);
void xev_timer_cancel(xev_watcher *w, xev_loop* loop, xev_completion* c, xev_completion* c_cancel, void* userdata, xev_timer_cb cb);
int xev_async_init(xev_watcher *w);
void xev_async_deinit(xev_watcher *w);
int xev_async_notify(xev_watcher *w);
void xev_async_wait(xev_watcher *w, xev_loop* loop, xev_completion* c, void* userdata, xev_async_cb cb);
#ifdef __cplusplus
}
#endif
#endif /* XEV_H */
|
0 | repos/libxev | repos/libxev/src/debug.zig | const std = @import("std");
inline fn indent(depth: usize, writer: anytype) !void {
for (0..depth) |_| try writer.writeByte(' ');
}
pub fn describe(comptime T: type, writer: anytype, depth: usize) !void {
const type_info = @typeInfo(T);
switch (type_info) {
.Type,
.Void,
.Bool,
.NoReturn,
.Int,
.Float,
.Pointer,
.Array,
.ComptimeFloat,
.ComptimeInt,
.Undefined,
.Null,
.Optional,
.ErrorUnion,
.ErrorSet,
.Enum,
.Fn,
.Opaque,
.Frame,
.AnyFrame,
.Vector,
.EnumLiteral,
=> {
try writer.print("{s} ({d} bytes)", .{ @typeName(T), @sizeOf(T) });
},
.Union => |s| {
try writer.print("{s} ({d} bytes) {{\n", .{ @typeName(T), @sizeOf(T) });
inline for (s.fields) |f| {
try indent(depth + 4, writer);
try writer.print("{s}: ", .{f.name});
try describe(f.type, writer, depth + 4);
try writer.writeByte('\n');
}
try indent(depth, writer);
try writer.writeByte('}');
},
.Struct => |s| {
try writer.print("{s} ({d} bytes) {{\n", .{ @typeName(T), @sizeOf(T) });
inline for (s.fields) |f| {
try indent(depth + 4, writer);
try writer.print("{s}: ", .{f.name});
try describe(f.type, writer, depth + 4);
try writer.writeByte('\n');
}
try indent(depth, writer);
try writer.writeByte('}');
},
}
}
|
0 | repos/libxev | repos/libxev/src/main.zig | const std = @import("std");
const builtin = @import("builtin");
/// The low-level IO interfaces using the recommended compile-time
/// interface for the target system.
const xev = Backend.default().Api();
pub usingnamespace xev;
//pub usingnamespace Epoll;
/// System-specific interfaces. Note that they are always pub for
/// all systems but if you reference them and force them to be analyzed
/// the proper system APIs must exist. Due to Zig's lazy analysis, if you
/// don't use any interface it will NOT be compiled (yay!).
pub const IO_Uring = Xev(.io_uring, @import("backend/io_uring.zig"));
pub const Epoll = Xev(.epoll, @import("backend/epoll.zig"));
pub const Kqueue = Xev(.kqueue, @import("backend/kqueue.zig"));
pub const WasiPoll = Xev(.wasi_poll, @import("backend/wasi_poll.zig"));
pub const IOCP = Xev(.iocp, @import("backend/iocp.zig"));
/// Generic thread pool implementation.
pub const ThreadPool = @import("ThreadPool.zig");
/// This stream (lowercase s) can be used as a namespace to access
/// Closeable, Writeable, Readable, etc. so that custom streams
/// can be constructed.
pub const stream = @import("watcher/stream.zig");
/// The backend types.
pub const Backend = enum {
io_uring,
epoll,
kqueue,
wasi_poll,
iocp,
/// Returns a recommend default backend from inspecting the system.
pub fn default() Backend {
return @as(?Backend, switch (builtin.os.tag) {
.linux => .io_uring,
.ios, .macos => .kqueue,
.wasi => .wasi_poll,
.windows => .iocp,
else => null,
}) orelse {
@compileLog(builtin.os);
@compileError("no default backend for this target");
};
}
/// Returns the Api (return value of Xev) for the given backend type.
pub fn Api(comptime self: Backend) type {
return switch (self) {
.io_uring => IO_Uring,
.epoll => Epoll,
.kqueue => Kqueue,
.wasi_poll => WasiPoll,
.iocp => IOCP,
};
}
};
/// Creates the Xev API based on a backend type.
///
/// For the default backend type for your system (i.e. io_uring on Linux),
/// this is the main API you interact with. It is `usingnamespaced` into
/// the "xev" package so you'd use types such as `xev.Loop`, `xev.Completion`,
/// etc.
///
/// Unless you're using a custom or specific backend type, you do NOT ever
/// need to call the Xev function itself.
pub fn Xev(comptime be: Backend, comptime T: type) type {
return struct {
const Self = @This();
const loop = @import("loop.zig");
/// The backend that this is. This is supplied at comptime so
/// it is up to the caller to say the right thing. This lets custom
/// implementations also "quack" like an implementation.
pub const backend = be;
/// The core loop APIs.
pub const Loop = T.Loop;
pub const Completion = T.Completion;
pub const Result = T.Result;
pub const ReadBuffer = T.ReadBuffer;
pub const WriteBuffer = T.WriteBuffer;
pub const Options = loop.Options;
pub const RunMode = loop.RunMode;
pub const CallbackAction = loop.CallbackAction;
pub const CompletionState = loop.CompletionState;
/// Error types
pub const AcceptError = T.AcceptError;
pub const CancelError = T.CancelError;
pub const CloseError = T.CloseError;
pub const ConnectError = T.ConnectError;
pub const ShutdownError = T.ShutdownError;
pub const WriteError = T.WriteError;
pub const ReadError = T.ReadError;
/// The high-level helper interfaces that make it easier to perform
/// common tasks. These may not work with all possible Loop implementations.
pub const Async = @import("watcher/async.zig").Async(Self);
pub const File = @import("watcher/file.zig").File(Self);
pub const Process = @import("watcher/process.zig").Process(Self);
pub const Stream = stream.GenericStream(Self);
pub const Timer = @import("watcher/timer.zig").Timer(Self);
pub const TCP = @import("watcher/tcp.zig").TCP(Self);
pub const UDP = @import("watcher/udp.zig").UDP(Self);
/// The callback of the main Loop operations. Higher level interfaces may
/// use a different callback mechanism.
pub const Callback = *const fn (
userdata: ?*anyopaque,
loop: *Loop,
completion: *Completion,
result: Result,
) CallbackAction;
/// A way to access the raw type.
pub const Sys = T;
/// A callback that does nothing and immediately disarms. This
/// implements xev.Callback and is the default value for completions.
pub fn noopCallback(
_: ?*anyopaque,
_: *Loop,
_: *Completion,
_: Result,
) CallbackAction {
return .disarm;
}
test {
@import("std").testing.refAllDecls(@This());
}
test "completion is zero-able" {
const c: Completion = .{};
_ = c;
}
};
}
test {
// Tested on all platforms
_ = @import("heap.zig");
_ = @import("queue.zig");
_ = @import("queue_mpsc.zig");
_ = ThreadPool;
// Test the C API
if (builtin.os.tag != .wasi) _ = @import("c_api.zig");
// OS-specific tests
switch (builtin.os.tag) {
.linux => {
_ = Epoll;
_ = IO_Uring;
_ = @import("linux/timerfd.zig");
},
.wasi => {
//_ = WasiPoll;
_ = @import("backend/wasi_poll.zig");
},
.windows => {
_ = @import("backend/iocp.zig");
},
else => {},
}
}
|
0 | repos/libxev | repos/libxev/src/ThreadPool.zig | //! Thread pool copied almost directly from Zap[1]. In @kprotty's own words:
//! lock-free, allocation-free* (excluding spawning threads), supports batch
//! scheduling, and dynamically spawns threads while handling thread spawn
//! failure. I highly recommend reading @kprotty's incredible blog post[2] on
//! this topic.
//!
//! The original file in Zap is licensed under the MIT license, and the
//! license and copyright is reproduced below. The libxev project is also
//! MIT licensed so the entire project (including this file) are equally
//! licensed. This is just a convenience note for any OSS users, contributors,
//! etc.
//!
//! MIT License
//!
//! Copyright (c) 2021 kprotty
//!
//! Permission is hereby granted, free of charge, to any person obtaining a copy
//! of this software and associated documentation files (the "Software"), to deal
//! in the Software without restriction, including without limitation the rights
//! to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//! copies of the Software, and to permit persons to whom the Software is
//! furnished to do so, subject to the following conditions:
//!
//! The above copyright notice and this permission notice shall be included in all
//! copies or substantial portions of the Software.
//!
//! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//! SOFTWARE.
//!
//! [1]: https://github.com/kprotty/zap
//! [2]: https://zig.news/kprotty/resource-efficient-thread-pools-with-zig-3291
const ThreadPool = @This();
const std = @import("std");
const assert = std.debug.assert;
const Atomic = std.atomic.Value;
stack_size: u32,
max_threads: u32,
sync: Atomic(u32) = Atomic(u32).init(@bitCast(Sync{})),
idle_event: Event = .{},
join_event: Event = .{},
run_queue: Node.Queue = .{},
threads: Atomic(?*Thread) = Atomic(?*Thread).init(null),
const Sync = packed struct {
/// Tracks the number of threads not searching for Tasks
idle: u14 = 0,
/// Tracks the number of threads spawned
spawned: u14 = 0,
/// What you see is what you get
unused: bool = false,
/// Used to not miss notifications while state = waking
notified: bool = false,
/// The current state of the thread pool
state: enum(u2) {
/// A notification can be issued to wake up a sleeping as the "waking thread".
pending = 0,
/// The state was notifiied with a signal. A thread is woken up.
/// The first thread to transition to `waking` becomes the "waking thread".
signaled,
/// There is a "waking thread" among us.
/// No other thread should be woken up until the waking thread transitions the state.
waking,
/// The thread pool was terminated. Start decremented `spawned` so that it can be joined.
shutdown,
} = .pending,
};
/// Configuration options for the thread pool.
/// TODO: add CPU core affinity?
pub const Config = struct {
stack_size: u32 = (std.Thread.SpawnConfig{}).stack_size,
max_threads: u32 = 0,
};
/// Statically initialize the thread pool using the configuration.
pub fn init(config: Config) ThreadPool {
return .{
.stack_size = @max(1, config.stack_size),
.max_threads = if (config.max_threads > 0)
config.max_threads
else
@intCast(std.Thread.getCpuCount() catch 1),
};
}
/// Wait for a thread to call shutdown() on the thread pool and kill the worker threads.
pub fn deinit(self: *ThreadPool) void {
self.join();
self.* = undefined;
}
/// A Task represents the unit of Work / Job / Execution that the ThreadPool schedules.
/// The user provides a `callback` which is invoked when the *Task can run on a thread.
pub const Task = struct {
node: Node = .{},
callback: *const fn (*Task) void,
};
/// An unordered collection of Tasks which can be submitted for scheduling as a group.
pub const Batch = struct {
len: usize = 0,
head: ?*Task = null,
tail: ?*Task = null,
/// Create a batch from a single task.
pub fn from(task: *Task) Batch {
return Batch{
.len = 1,
.head = task,
.tail = task,
};
}
/// Another batch into this one, taking ownership of its tasks.
pub fn push(self: *Batch, batch: Batch) void {
if (batch.len == 0) return;
if (self.len == 0) {
self.* = batch;
} else {
self.tail.?.node.next = if (batch.head) |h| &h.node else null;
self.tail = batch.tail;
self.len += batch.len;
}
}
};
/// Schedule a batch of tasks to be executed by some thread on the thread pool.
pub fn schedule(self: *ThreadPool, batch: Batch) void {
// Sanity check
if (batch.len == 0) {
return;
}
// Extract out the Node's from the Tasks
var list = Node.List{
.head = &batch.head.?.node,
.tail = &batch.tail.?.node,
};
// Push the task Nodes to the most approriate queue
if (Thread.current) |thread| {
thread.run_buffer.push(&list) catch thread.run_queue.push(list);
} else {
self.run_queue.push(list);
}
// Try to notify a thread
const is_waking = false;
return self.notify(is_waking);
}
inline fn notify(self: *ThreadPool, is_waking: bool) void {
// Fast path to check the Sync state to avoid calling into notifySlow().
// If we're waking, then we need to update the state regardless
if (!is_waking) {
const sync: Sync = @bitCast(self.sync.load(.monotonic));
if (sync.notified) {
return;
}
}
return self.notifySlow(is_waking);
}
noinline fn notifySlow(self: *ThreadPool, is_waking: bool) void {
var sync: Sync = @bitCast(self.sync.load(.monotonic));
while (sync.state != .shutdown) {
const can_wake = is_waking or (sync.state == .pending);
if (is_waking) {
assert(sync.state == .waking);
}
var new_sync = sync;
new_sync.notified = true;
if (can_wake and sync.idle > 0) { // wake up an idle thread
new_sync.state = .signaled;
} else if (can_wake and sync.spawned < self.max_threads) { // spawn a new thread
new_sync.state = .signaled;
new_sync.spawned += 1;
} else if (is_waking) { // no other thread to pass on "waking" status
new_sync.state = .pending;
} else if (sync.notified) { // nothing to update
return;
}
// Release barrier synchronizes with Acquire in wait()
// to ensure pushes to run queues happen before observing a posted notification.
sync = @bitCast(self.sync.cmpxchgWeak(
@bitCast(sync),
@bitCast(new_sync),
.release,
.monotonic,
) orelse {
// We signaled to notify an idle thread
if (can_wake and sync.idle > 0) {
return self.idle_event.notify();
}
// We signaled to spawn a new thread
if (can_wake and sync.spawned < self.max_threads) {
const spawn_config = std.Thread.SpawnConfig{ .stack_size = self.stack_size };
const thread = std.Thread.spawn(spawn_config, Thread.run, .{self}) catch return self.unregister(null);
return thread.detach();
}
return;
});
}
}
noinline fn wait(self: *ThreadPool, _is_waking: bool) error{Shutdown}!bool {
var is_idle = false;
var is_waking = _is_waking;
var sync: Sync = @bitCast(self.sync.load(.monotonic));
while (true) {
if (sync.state == .shutdown) return error.Shutdown;
if (is_waking) assert(sync.state == .waking);
// Consume a notification made by notify().
if (sync.notified) {
var new_sync = sync;
new_sync.notified = false;
if (is_idle)
new_sync.idle -= 1;
if (sync.state == .signaled)
new_sync.state = .waking;
// Acquire barrier synchronizes with notify()
// to ensure that pushes to run queue are observed after wait() returns.
sync = @bitCast(self.sync.cmpxchgWeak(
@bitCast(sync),
@bitCast(new_sync),
.acquire,
.monotonic,
) orelse {
return is_waking or (sync.state == .signaled);
});
// No notification to consume.
// Mark this thread as idle before sleeping on the idle_event.
} else if (!is_idle) {
var new_sync = sync;
new_sync.idle += 1;
if (is_waking)
new_sync.state = .pending;
sync = @bitCast(self.sync.cmpxchgWeak(
@bitCast(sync),
@bitCast(new_sync),
.monotonic,
.monotonic,
) orelse {
is_waking = false;
is_idle = true;
continue;
});
// Wait for a signal by either notify() or shutdown() without wasting cpu cycles.
// TODO: Add I/O polling here.
} else {
self.idle_event.wait();
sync = @bitCast(self.sync.load(.monotonic));
}
}
}
/// Marks the thread pool as shutdown
pub noinline fn shutdown(self: *ThreadPool) void {
var sync: Sync = @bitCast(self.sync.load(.monotonic));
while (sync.state != .shutdown) {
var new_sync = sync;
new_sync.notified = true;
new_sync.state = .shutdown;
new_sync.idle = 0;
// Full barrier to synchronize with both wait() and notify()
sync = @bitCast(self.sync.cmpxchgWeak(
@bitCast(sync),
@bitCast(new_sync),
.acq_rel,
.monotonic,
) orelse {
// Wake up any threads sleeping on the idle_event.
// TODO: I/O polling notification here.
if (sync.idle > 0) self.idle_event.shutdown();
return;
});
}
}
fn register(noalias self: *ThreadPool, noalias thread: *Thread) void {
// Push the thread onto the threads stack in a lock-free manner.
var threads = self.threads.load(.monotonic);
while (true) {
thread.next = threads;
threads = self.threads.cmpxchgWeak(
threads,
thread,
.release,
.monotonic,
) orelse break;
}
}
fn unregister(noalias self: *ThreadPool, noalias maybe_thread: ?*Thread) void {
// Un-spawn one thread, either due to a failed OS thread spawning or the thread is exitting.
const one_spawned: u32 = @bitCast(Sync{ .spawned = 1 });
const sync: Sync = @bitCast(self.sync.fetchSub(one_spawned, .release));
assert(sync.spawned > 0);
// The last thread to exit must wake up the thread pool join()er
// who will start the chain to shutdown all the threads.
if (sync.state == .shutdown and sync.spawned == 1) {
self.join_event.notify();
}
// If this is a thread pool thread, wait for a shutdown signal by the thread pool join()er.
const thread = maybe_thread orelse return;
thread.join_event.wait();
// After receiving the shutdown signal, shutdown the next thread in the pool.
// We have to do that without touching the thread pool itself since it's memory is invalidated by now.
// So just follow our .next link.
const next_thread = thread.next orelse return;
next_thread.join_event.notify();
}
fn join(self: *ThreadPool) void {
// Wait for the thread pool to be shutdown() then for all threads to enter a joinable state
self.join_event.wait();
const sync: Sync = @bitCast(self.sync.load(.monotonic));
assert(sync.state == .shutdown);
assert(sync.spawned == 0);
// If there are threads, start off the chain sending it the shutdown signal.
// The thread receives the shutdown signal and sends it to the next thread, and the next..
const thread = self.threads.load(.acquire) orelse return;
thread.join_event.notify();
}
const Thread = struct {
next: ?*Thread = null,
target: ?*Thread = null,
join_event: Event = .{},
run_queue: Node.Queue = .{},
run_buffer: Node.Buffer = .{},
threadlocal var current: ?*Thread = null;
/// Thread entry point which runs a worker for the ThreadPool
fn run(thread_pool: *ThreadPool) void {
var self = Thread{};
current = &self;
thread_pool.register(&self);
defer thread_pool.unregister(&self);
var is_waking = false;
while (true) {
is_waking = thread_pool.wait(is_waking) catch return;
while (self.pop(thread_pool)) |result| {
if (result.pushed or is_waking)
thread_pool.notify(is_waking);
is_waking = false;
const task: *Task = @fieldParentPtr("node", result.node);
(task.callback)(task);
}
}
}
/// Try to dequeue a Node/Task from the ThreadPool.
/// Spurious reports of dequeue() returning empty are allowed.
fn pop(noalias self: *Thread, noalias thread_pool: *ThreadPool) ?Node.Buffer.Stole {
// Check our local buffer first
if (self.run_buffer.pop()) |node| {
return Node.Buffer.Stole{
.node = node,
.pushed = false,
};
}
// Then check our local queue
if (self.run_buffer.consume(&self.run_queue)) |stole| {
return stole;
}
// Then the global queue
if (self.run_buffer.consume(&thread_pool.run_queue)) |stole| {
return stole;
}
// TODO: add optimistic I/O polling here
// Then try work stealing from other threads
var num_threads: u32 = @as(Sync, @bitCast(thread_pool.sync.load(.monotonic))).spawned;
while (num_threads > 0) : (num_threads -= 1) {
// Traverse the stack of registered threads on the thread pool
const target = self.target orelse thread_pool.threads.load(.acquire) orelse unreachable;
self.target = target.next;
// Try to steal from their queue first to avoid contention (the target steal's from queue last).
if (self.run_buffer.consume(&target.run_queue)) |stole| {
return stole;
}
// Skip stealing from the buffer if we're the target.
// We still steal from our own queue above given it may have just been locked the first time we tried.
if (target == self) {
continue;
}
// Steal from the buffer of a remote thread as a last resort
if (self.run_buffer.steal(&target.run_buffer)) |stole| {
return stole;
}
}
return null;
}
};
/// An event which stores 1 semaphore token and is multi-threaded safe.
/// The event can be shutdown(), waking up all wait()ing threads and
/// making subsequent wait()'s return immediately.
const Event = struct {
state: Atomic(u32) = Atomic(u32).init(EMPTY),
const EMPTY = 0;
const WAITING = 1;
const NOTIFIED = 2;
const SHUTDOWN = 3;
/// Wait for and consume a notification
/// or wait for the event to be shutdown entirely
noinline fn wait(self: *Event) void {
var acquire_with: u32 = EMPTY;
var state = self.state.load(.monotonic);
while (true) {
// If we're shutdown then exit early.
// Acquire barrier to ensure operations before the shutdown() are seen after the wait().
// Shutdown is rare so it's better to have an Acquire barrier here instead of on CAS failure + load which are common.
if (state == SHUTDOWN) {
@fence(.acquire);
return;
}
// Consume a notification when it pops up.
// Acquire barrier to ensure operations before the notify() appear after the wait().
if (state == NOTIFIED) {
state = self.state.cmpxchgWeak(
state,
acquire_with,
.acquire,
.monotonic,
) orelse return;
continue;
}
// There is no notification to consume, we should wait on the event by ensuring its WAITING.
if (state != WAITING) blk: {
state = self.state.cmpxchgWeak(
state,
WAITING,
.monotonic,
.monotonic,
) orelse break :blk;
continue;
}
// Wait on the event until a notify() or shutdown().
// If we wake up to a notification, we must acquire it with WAITING instead of EMPTY
// since there may be other threads sleeping on the Futex who haven't been woken up yet.
//
// Acquiring to WAITING will make the next notify() or shutdown() wake a sleeping futex thread
// who will either exit on SHUTDOWN or acquire with WAITING again, ensuring all threads are awoken.
// This unfortunately results in the last notify() or shutdown() doing an extra futex wake but that's fine.
std.Thread.Futex.wait(&self.state, WAITING);
state = self.state.load(.monotonic);
acquire_with = WAITING;
}
}
/// Post a notification to the event if it doesn't have one already
/// then wake up a waiting thread if there is one as well.
fn notify(self: *Event) void {
return self.wake(NOTIFIED, 1);
}
/// Marks the event as shutdown, making all future wait()'s return immediately.
/// Then wakes up any threads currently waiting on the Event.
fn shutdown(self: *Event) void {
return self.wake(SHUTDOWN, std.math.maxInt(u32));
}
fn wake(self: *Event, release_with: u32, wake_threads: u32) void {
// Update the Event to notifty it with the new `release_with` state (either NOTIFIED or SHUTDOWN).
// Release barrier to ensure any operations before this are this to happen before the wait() in the other threads.
const state = self.state.swap(release_with, .release);
// Only wake threads sleeping in futex if the state is WAITING.
// Avoids unnecessary wake ups.
if (state == WAITING) {
std.Thread.Futex.wake(&self.state, wake_threads);
}
}
};
/// Linked list intrusive memory node and lock-free data structures to operate with it
const Node = struct {
next: ?*Node = null,
/// A linked list of Nodes
const List = struct {
head: *Node,
tail: *Node,
};
/// An unbounded multi-producer-(non blocking)-multi-consumer queue of Node pointers.
const Queue = struct {
stack: Atomic(usize) = Atomic(usize).init(0),
cache: ?*Node = null,
const HAS_CACHE: usize = 0b01;
const IS_CONSUMING: usize = 0b10;
const PTR_MASK: usize = ~(HAS_CACHE | IS_CONSUMING);
comptime {
assert(@alignOf(Node) >= ((IS_CONSUMING | HAS_CACHE) + 1));
}
fn push(noalias self: *Queue, list: List) void {
var stack = self.stack.load(.monotonic);
while (true) {
// Attach the list to the stack (pt. 1)
list.tail.next = @ptrFromInt(stack & PTR_MASK);
// Update the stack with the list (pt. 2).
// Don't change the HAS_CACHE and IS_CONSUMING bits of the consumer.
var new_stack = @intFromPtr(list.head);
assert(new_stack & ~PTR_MASK == 0);
new_stack |= (stack & ~PTR_MASK);
// Push to the stack with a release barrier for the consumer to see the proper list links.
stack = self.stack.cmpxchgWeak(
stack,
new_stack,
.release,
.monotonic,
) orelse break;
}
}
fn tryAcquireConsumer(self: *Queue) error{ Empty, Contended }!?*Node {
var stack = self.stack.load(.monotonic);
while (true) {
if (stack & IS_CONSUMING != 0)
return error.Contended; // The queue already has a consumer.
if (stack & (HAS_CACHE | PTR_MASK) == 0)
return error.Empty; // The queue is empty when there's nothing cached and nothing in the stack.
// When we acquire the consumer, also consume the pushed stack if the cache is empty.
var new_stack = stack | HAS_CACHE | IS_CONSUMING;
if (stack & HAS_CACHE == 0) {
assert(stack & PTR_MASK != 0);
new_stack &= ~PTR_MASK;
}
// Acquire barrier on getting the consumer to see cache/Node updates done by previous consumers
// and to ensure our cache/Node updates in pop() happen after that of previous consumers.
stack = self.stack.cmpxchgWeak(
stack,
new_stack,
.acquire,
.monotonic,
) orelse return self.cache orelse @ptrFromInt(stack & PTR_MASK);
}
}
fn releaseConsumer(noalias self: *Queue, noalias consumer: ?*Node) void {
// Stop consuming and remove the HAS_CACHE bit as well if the consumer's cache is empty.
// When HAS_CACHE bit is zeroed, the next consumer will acquire the pushed stack nodes.
var remove = IS_CONSUMING;
if (consumer == null)
remove |= HAS_CACHE;
// Release the consumer with a release barrier to ensure cache/node accesses
// happen before the consumer was released and before the next consumer starts using the cache.
self.cache = consumer;
const stack = self.stack.fetchSub(remove, .release);
assert(stack & remove != 0);
}
fn pop(noalias self: *Queue, noalias consumer_ref: *?*Node) ?*Node {
// Check the consumer cache (fast path)
if (consumer_ref.*) |node| {
consumer_ref.* = node.next;
return node;
}
// Load the stack to see if there was anything pushed that we could grab.
var stack = self.stack.load(.monotonic);
assert(stack & IS_CONSUMING != 0);
if (stack & PTR_MASK == 0) {
return null;
}
// Nodes have been pushed to the stack, grab then with an Acquire barrier to see the Node links.
stack = self.stack.swap(HAS_CACHE | IS_CONSUMING, .acquire);
assert(stack & IS_CONSUMING != 0);
assert(stack & PTR_MASK != 0);
const node: *Node = @ptrFromInt(stack & PTR_MASK);
consumer_ref.* = node.next;
return node;
}
};
/// A bounded single-producer, multi-consumer ring buffer for node pointers.
const Buffer = struct {
head: Atomic(Index) = Atomic(Index).init(0),
tail: Atomic(Index) = Atomic(Index).init(0),
array: [capacity]Atomic(*Node) = undefined,
const Index = u32;
const capacity = 256; // Appears to be a pretty good trade-off in space vs contended throughput
comptime {
assert(std.math.maxInt(Index) >= capacity);
assert(std.math.isPowerOfTwo(capacity));
}
fn push(noalias self: *Buffer, noalias list: *List) error{Overflow}!void {
var head = self.head.load(.monotonic);
var tail = self.tail.raw; // we're the only thread that can change this
while (true) {
var size = tail -% head;
assert(size <= capacity);
// Push nodes from the list to the buffer if it's not empty..
if (size < capacity) {
var nodes: ?*Node = list.head;
while (size < capacity) : (size += 1) {
const node = nodes orelse break;
nodes = node.next;
// Array written atomically with weakest ordering since it could be getting atomically read by steal().
self.array[tail % capacity].store(node, .unordered);
tail +%= 1;
}
// Release barrier synchronizes with Acquire loads for steal()ers to see the array writes.
self.tail.store(tail, .release);
// Update the list with the nodes we pushed to the buffer and try again if there's more.
list.head = nodes orelse return;
std.atomic.spinLoopHint();
head = self.head.load(.monotonic);
continue;
}
// Try to steal/overflow half of the tasks in the buffer to make room for future push()es.
// Migrating half amortizes the cost of stealing while requiring future pops to still use the buffer.
// Acquire barrier to ensure the linked list creation after the steal only happens after we succesfully steal.
var migrate = size / 2;
head = self.head.cmpxchgWeak(
head,
head +% migrate,
.acquire,
.monotonic,
) orelse {
// Link the migrated Nodes together
const first = self.array[head % capacity].raw;
while (migrate > 0) : (migrate -= 1) {
const prev = self.array[head % capacity].raw;
head +%= 1;
prev.next = self.array[head % capacity].raw;
}
// Append the list that was supposed to be pushed to the end of the migrated Nodes
const last = self.array[(head -% 1) % capacity].raw;
last.next = list.head;
list.tail.next = null;
// Return the migrated nodes + the original list as overflowed
list.head = first;
return error.Overflow;
};
}
}
fn pop(self: *Buffer) ?*Node {
var head = self.head.load(.monotonic);
const tail = self.tail.raw; // we're the only thread that can change this
while (true) {
// Quick sanity check and return null when not empty
const size = tail -% head;
assert(size <= capacity);
if (size == 0) {
return null;
}
// Dequeue with an acquire barrier to ensure any writes done to the Node
// only happen after we succesfully claim it from the array.
head = self.head.cmpxchgWeak(
head,
head +% 1,
.acquire,
.monotonic,
) orelse return self.array[head % capacity].raw;
}
}
const Stole = struct {
node: *Node,
pushed: bool,
};
fn consume(noalias self: *Buffer, noalias queue: *Queue) ?Stole {
var consumer = queue.tryAcquireConsumer() catch return null;
defer queue.releaseConsumer(consumer);
const head = self.head.load(.monotonic);
const tail = self.tail.raw; // we're the only thread that can change this
const size = tail -% head;
assert(size <= capacity);
assert(size == 0); // we should only be consuming if our array is empty
// Pop nodes from the queue and push them to our array.
// Atomic stores to the array as steal() threads may be atomically reading from it.
var pushed: Index = 0;
while (pushed < capacity) : (pushed += 1) {
const node = queue.pop(&consumer) orelse break;
self.array[(tail +% pushed) % capacity].store(node, .unordered);
}
// We will be returning one node that we stole from the queue.
// Get an extra, and if that's not possible, take one from our array.
const node = queue.pop(&consumer) orelse blk: {
if (pushed == 0) return null;
pushed -= 1;
break :blk self.array[(tail +% pushed) % capacity].raw;
};
// Update the array tail with the nodes we pushed to it.
// Release barrier to synchronize with Acquire barrier in steal()'s to see the written array Nodes.
if (pushed > 0) self.tail.store(tail +% pushed, .release);
return Stole{
.node = node,
.pushed = pushed > 0,
};
}
fn steal(noalias self: *Buffer, noalias buffer: *Buffer) ?Stole {
const head = self.head.load(.monotonic);
const tail = self.tail.raw; // we're the only thread that can change this
const size = tail -% head;
assert(size <= capacity);
assert(size == 0); // we should only be stealing if our array is empty
while (true) : (std.atomic.spinLoopHint()) {
const buffer_head = buffer.head.load(.acquire);
const buffer_tail = buffer.tail.load(.acquire);
// Overly large size indicates the the tail was updated a lot after the head was loaded.
// Reload both and try again.
const buffer_size = buffer_tail -% buffer_head;
if (buffer_size > capacity) {
continue;
}
// Try to steal half (divCeil) to amortize the cost of stealing from other threads.
const steal_size = buffer_size - (buffer_size / 2);
if (steal_size == 0) {
return null;
}
// Copy the nodes we will steal from the target's array to our own.
// Atomically load from the target buffer array as it may be pushing and atomically storing to it.
// Atomic store to our array as other steal() threads may be atomically loading from it as above.
var i: Index = 0;
while (i < steal_size) : (i += 1) {
const node = buffer.array[(buffer_head +% i) % capacity].load(.unordered);
self.array[(tail +% i) % capacity].store(node, .unordered);
}
// Try to commit the steal from the target buffer using:
// - an Acquire barrier to ensure that we only interact with the stolen Nodes after the steal was committed.
// - a Release barrier to ensure that the Nodes are copied above prior to the committing of the steal
// because if they're copied after the steal, the could be getting rewritten by the target's push().
_ = buffer.head.cmpxchgStrong(
buffer_head,
buffer_head +% steal_size,
.acq_rel,
.monotonic,
) orelse {
// Pop one from the nodes we stole as we'll be returning it
const pushed = steal_size - 1;
const node = self.array[(tail +% pushed) % capacity].raw;
// Update the array tail with the nodes we pushed to it.
// Release barrier to synchronize with Acquire barrier in steal()'s to see the written array Nodes.
if (pushed > 0) self.tail.store(tail +% pushed, .release);
return Stole{
.node = node,
.pushed = pushed > 0,
};
};
}
}
};
};
|
0 | repos/libxev | repos/libxev/src/c_api.zig | // This file contains the C bindings that are exported when building
// the system libraries.
//
// WHERE IS THE DOCUMENTATION? Note that all the documentation for the C
// interface is in the man pages. The header file xev.h purposely has no
// documentation so that its concise and easy to see the list of exported
// functions.
const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const xev = @import("main.zig");
export fn xev_loop_init(loop: *xev.Loop) c_int {
// TODO: overflow
loop.* = xev.Loop.init(.{}) catch |err| return errorCode(err);
return 0;
}
export fn xev_loop_deinit(loop: *xev.Loop) void {
loop.deinit();
}
export fn xev_loop_run(loop: *xev.Loop, mode: xev.RunMode) c_int {
loop.run(mode) catch |err| return errorCode(err);
return 0;
}
export fn xev_loop_now(loop: *xev.Loop) i64 {
return loop.now();
}
export fn xev_loop_update_now(loop: *xev.Loop) void {
loop.update_now();
}
export fn xev_completion_zero(c: *xev.Completion) void {
c.* = .{};
}
export fn xev_completion_state(c: *xev.Completion) xev.CompletionState {
return c.state();
}
//-------------------------------------------------------------------
// ThreadPool
export fn xev_threadpool_config_init(cfg: *xev.ThreadPool.Config) void {
cfg.* = .{};
}
export fn xev_threadpool_config_set_stack_size(
cfg: *xev.ThreadPool.Config,
v: u32,
) void {
cfg.stack_size = v;
}
export fn xev_threadpool_config_set_max_threads(
cfg: *xev.ThreadPool.Config,
v: u32,
) void {
cfg.max_threads = v;
}
export fn xev_threadpool_init(
threadpool: *xev.ThreadPool,
cfg_: ?*xev.ThreadPool.Config,
) c_int {
const cfg: xev.ThreadPool.Config = if (cfg_) |v| v.* else .{};
threadpool.* = xev.ThreadPool.init(cfg);
return 0;
}
export fn xev_threadpool_deinit(threadpool: *xev.ThreadPool) void {
threadpool.deinit();
}
export fn xev_threadpool_shutdown(threadpool: *xev.ThreadPool) void {
threadpool.shutdown();
}
export fn xev_threadpool_schedule(
pool: *xev.ThreadPool,
batch: *xev.ThreadPool.Batch,
) void {
pool.schedule(batch.*);
}
export fn xev_threadpool_task_init(
t: *xev.ThreadPool.Task,
cb: *const fn (*xev.ThreadPool.Task) callconv(.C) void,
) void {
const extern_t = @as(*Task, @ptrCast(@alignCast(t)));
extern_t.c_callback = cb;
t.* = .{
.callback = (struct {
fn callback(inner_t: *xev.ThreadPool.Task) void {
const outer_t: *Task = @alignCast(@fieldParentPtr(
"data",
@as(*Task.Data, @ptrCast(inner_t)),
));
outer_t.c_callback(inner_t);
}
}).callback,
};
}
export fn xev_threadpool_batch_init(b: *xev.ThreadPool.Batch) void {
b.* = .{};
}
export fn xev_threadpool_batch_push_task(
b: *xev.ThreadPool.Batch,
t: *xev.ThreadPool.Task,
) void {
b.push(xev.ThreadPool.Batch.from(t));
}
export fn xev_threadpool_batch_push_batch(
b: *xev.ThreadPool.Batch,
other: *xev.ThreadPool.Batch,
) void {
b.push(other.*);
}
//-------------------------------------------------------------------
// Timers
export fn xev_timer_init(v: *xev.Timer) c_int {
v.* = xev.Timer.init() catch |err| return errorCode(err);
return 0;
}
export fn xev_timer_deinit(v: *xev.Timer) void {
v.deinit();
}
export fn xev_timer_run(
v: *xev.Timer,
loop: *xev.Loop,
c: *xev.Completion,
next_ms: u64,
userdata: ?*anyopaque,
cb: *const fn (
*xev.Loop,
*xev.Completion,
c_int,
?*anyopaque,
) callconv(.C) xev.CallbackAction,
) void {
const Callback = @typeInfo(@TypeOf(cb)).Pointer.child;
const extern_c = @as(*Completion, @ptrCast(@alignCast(c)));
extern_c.c_callback = @as(*const anyopaque, @ptrCast(cb));
v.run(loop, c, next_ms, anyopaque, userdata, (struct {
fn callback(
ud: ?*anyopaque,
cb_loop: *xev.Loop,
cb_c: *xev.Completion,
r: xev.Timer.RunError!void,
) xev.CallbackAction {
const cb_extern_c = @as(*Completion, @ptrCast(cb_c));
const cb_c_callback = @as(
*const Callback,
@ptrCast(@alignCast(cb_extern_c.c_callback)),
);
return @call(.auto, cb_c_callback, .{
cb_loop,
cb_c,
if (r) |_| 0 else |err| errorCode(err),
ud,
});
}
}).callback);
}
export fn xev_timer_reset(
v: *xev.Timer,
loop: *xev.Loop,
c: *xev.Completion,
c_cancel: *xev.Completion,
next_ms: u64,
userdata: ?*anyopaque,
cb: *const fn (
*xev.Loop,
*xev.Completion,
c_int,
?*anyopaque,
) callconv(.C) xev.CallbackAction,
) void {
const Callback = @typeInfo(@TypeOf(cb)).Pointer.child;
const extern_c = @as(*Completion, @ptrCast(@alignCast(c)));
extern_c.c_callback = @as(*const anyopaque, @ptrCast(cb));
v.reset(loop, c, c_cancel, next_ms, anyopaque, userdata, (struct {
fn callback(
ud: ?*anyopaque,
cb_loop: *xev.Loop,
cb_c: *xev.Completion,
r: xev.Timer.RunError!void,
) xev.CallbackAction {
const cb_extern_c = @as(*Completion, @ptrCast(cb_c));
const cb_c_callback = @as(
*const Callback,
@ptrCast(@alignCast(cb_extern_c.c_callback)),
);
return @call(.auto, cb_c_callback, .{
cb_loop,
cb_c,
if (r) |_| 0 else |err| errorCode(err),
ud,
});
}
}).callback);
}
export fn xev_timer_cancel(
v: *xev.Timer,
loop: *xev.Loop,
c_timer: *xev.Completion,
c_cancel: *xev.Completion,
userdata: ?*anyopaque,
cb: *const fn (
*xev.Loop,
*xev.Completion,
c_int,
?*anyopaque,
) callconv(.C) xev.CallbackAction,
) void {
const Callback = @typeInfo(@TypeOf(cb)).Pointer.child;
const extern_c = @as(*Completion, @ptrCast(@alignCast(c_cancel)));
extern_c.c_callback = @as(*const anyopaque, @ptrCast(cb));
v.cancel(loop, c_timer, c_cancel, anyopaque, userdata, (struct {
fn callback(
ud: ?*anyopaque,
cb_loop: *xev.Loop,
cb_c: *xev.Completion,
r: xev.Timer.CancelError!void,
) xev.CallbackAction {
const cb_extern_c = @as(*Completion, @ptrCast(cb_c));
const cb_c_callback = @as(
*const Callback,
@ptrCast(@alignCast(cb_extern_c.c_callback)),
);
return @call(.auto, cb_c_callback, .{
cb_loop,
cb_c,
if (r) |_| 0 else |err| errorCode(err),
ud,
});
}
}).callback);
}
//-------------------------------------------------------------------
// Async
export fn xev_async_init(v: *xev.Async) c_int {
v.* = xev.Async.init() catch |err| return errorCode(err);
return 0;
}
export fn xev_async_deinit(v: *xev.Async) void {
v.deinit();
}
export fn xev_async_notify(v: *xev.Async) c_int {
v.notify() catch |err| return errorCode(err);
return 0;
}
export fn xev_async_wait(
v: *xev.Async,
loop: *xev.Loop,
c: *xev.Completion,
userdata: ?*anyopaque,
cb: *const fn (
*xev.Loop,
*xev.Completion,
c_int,
?*anyopaque,
) callconv(.C) xev.CallbackAction,
) void {
const Callback = @typeInfo(@TypeOf(cb)).Pointer.child;
const extern_c = @as(*Completion, @ptrCast(@alignCast(c)));
extern_c.c_callback = @as(*const anyopaque, @ptrCast(cb));
v.wait(loop, c, anyopaque, userdata, (struct {
fn callback(
ud: ?*anyopaque,
cb_loop: *xev.Loop,
cb_c: *xev.Completion,
r: xev.Async.WaitError!void,
) xev.CallbackAction {
const cb_extern_c = @as(*Completion, @ptrCast(cb_c));
const cb_c_callback = @as(
*const Callback,
@ptrCast(@alignCast(cb_extern_c.c_callback)),
);
return @call(.auto, cb_c_callback, .{
cb_loop,
cb_c,
if (r) |_| 0 else |err| errorCode(err),
ud,
});
}
}).callback);
}
//-------------------------------------------------------------------
// Sync with xev.h
/// Since we can't pass the callback at comptime with C, we have to
/// have an additional field on completions to store our callback pointer.
/// We just tack it onto the end of the memory chunk that C programs allocate
/// for completions.
const Completion = extern struct {
const Data = [@sizeOf(xev.Completion)]u8;
data: Data,
c_callback: *const anyopaque,
};
const Task = extern struct {
const Data = [@sizeOf(xev.ThreadPool.Task)]u8;
data: Data,
c_callback: *const fn (*xev.ThreadPool.Task) callconv(.C) void,
};
/// Returns the unique error code for an error.
fn errorCode(err: anyerror) c_int {
// TODO(mitchellh): This is a bad idea because its not stable across
// code changes. For now we just document that error codes are not
// stable but that is not useful at all!
return @intFromError(err);
}
test "c-api sizes" {
// This tests the sizes that are defined in the C API. We must ensure
// that our main structure sizes never exceed these so that the C ABI
// is maintained.
//
// THE MAGIC NUMBERS ARE KEPT IN SYNC WITH "include/xev.h"
const testing = std.testing;
try testing.expect(@sizeOf(xev.Loop) <= 512);
try testing.expect(@sizeOf(Completion) <= 320);
try testing.expect(@sizeOf(xev.Async) <= 256);
try testing.expect(@sizeOf(xev.Timer) <= 256);
try testing.expectEqual(@as(usize, 48), @sizeOf(xev.ThreadPool));
try testing.expectEqual(@as(usize, 24), @sizeOf(xev.ThreadPool.Batch));
try testing.expectEqual(@as(usize, 24), @sizeOf(Task));
try testing.expectEqual(@as(usize, 8), @sizeOf(xev.ThreadPool.Config));
}
|
0 | repos/libxev | repos/libxev/src/heap.zig | const std = @import("std");
const assert = std.debug.assert;
/// An intrusive heap implementation backed by a pairing heap[1] implementation.
///
/// Why? Intrusive data structures require the element type to hold the metadata
/// required for the structure, rather than an additional container structure.
/// There are numerous pros/cons that are documented well by Boost[2]. For Zig,
/// I think the primary benefits are making data structures allocation free
/// (rather, shifting allocation up to the consumer which can choose how they
/// want the memory to be available). There are various costs to this such as
/// the costs of pointer chasing, larger memory overhead, requiring the element
/// type to be aware of its container, etc. But for certain use cases an intrusive
/// data structure can yield much better performance.
///
/// Usage notes:
/// - The element T is expected to have a field "heap" of type InstrusiveHeapField.
/// See the tests for a full example of how to set this.
/// - You can easily make this a min or max heap by inverting the result of
/// "less" below.
///
/// [1]: https://en.wikipedia.org/wiki/Pairing_heap
/// [2]: https://www.boost.org/doc/libs/1_64_0/doc/html/intrusive/intrusive_vs_nontrusive.html
pub fn Intrusive(
comptime T: type,
comptime Context: type,
comptime less: *const fn (ctx: Context, a: *T, b: *T) bool,
) type {
return struct {
const Self = @This();
root: ?*T = null,
context: Context,
/// Insert a new element v into the heap. An element v can only
/// be a member of a single heap at any given time. When compiled
/// with runtime-safety, assertions will help verify this property.
pub fn insert(self: *Self, v: *T) void {
self.root = if (self.root) |root| self.meld(v, root) else v;
}
/// Look at the next minimum value but do not remove it.
pub fn peek(self: *Self) ?*T {
return self.root;
}
/// Delete the minimum value from the heap and return it.
pub fn deleteMin(self: *Self) ?*T {
const root = self.root orelse return null;
self.root = if (root.heap.child) |child|
self.combine_siblings(child)
else
null;
// Clear pointers with runtime safety so we can verify on
// insert that values aren't incorrectly being set multiple times.
root.heap = .{};
return root;
}
/// Remove the value v from the heap.
pub fn remove(self: *Self, v: *T) void {
// If v doesn't have a previous value, this must be the root
// element. If it is NOT the root element, v can't be in this
// heap and we trigger an assertion failure.
const prev = v.heap.prev orelse {
assert(self.root.? == v);
_ = self.deleteMin();
return;
};
// Detach "v" from the tree and clean up any links so it
// is as if this node never nexisted. The previous value
// must point to the proper next value and the pointers
// must all be cleaned up.
if (v.heap.next) |next| next.heap.prev = prev;
if (prev.heap.child == v)
prev.heap.child = v.heap.next
else
prev.heap.next = v.heap.next;
v.heap.prev = null;
v.heap.next = null;
// If we have children, then we need to merge them back in.
const child = v.heap.child orelse return;
v.heap.child = null;
const x = self.combine_siblings(child);
self.root = self.meld(x, self.root.?);
}
/// Meld (union) two heaps together. This isn't a generalized
/// union. It assumes that a.heap.next is null so this is only
/// meant in specific scenarios in the pairing heap where meld
/// is expected.
///
/// For example, when melding a new value "v" with an existing
/// root "root", "v" must always be the first param.
fn meld(self: *Self, a: *T, b: *T) *T {
assert(a.heap.next == null);
if (less(self.context, a, b)) {
// B points back to A
b.heap.prev = a;
// If B has siblings, then A inherits B's siblings
// and B's immediate sibling must point back to A to
// maintain the doubly linked list.
if (b.heap.next) |b_next| {
a.heap.next = b_next;
b_next.heap.prev = a;
b.heap.next = null;
}
// If A has a child, then B becomes the leftmost sibling
// of that child.
if (a.heap.child) |a_child| {
b.heap.next = a_child;
a_child.heap.prev = b;
}
// B becomes the leftmost child of A
a.heap.child = b;
return a;
}
// Replace A with B in the tree. Any of B's children
// become siblings of A. A becomes the leftmost child of B.
// A points back to B
b.heap.prev = a.heap.prev;
a.heap.prev = b;
if (b.heap.child) |b_child| {
a.heap.next = b_child;
b_child.heap.prev = a;
}
b.heap.child = a;
return b;
}
/// Combine the siblings of the leftmost value "left" into a single
/// new rooted with the minimum value.
fn combine_siblings(self: *Self, left: *T) *T {
left.heap.prev = null;
// Merge pairs right
var root: *T = root: {
var a: *T = left;
while (true) {
var b = a.heap.next orelse break :root a;
a.heap.next = null;
b = self.meld(a, b);
a = b.heap.next orelse break :root b;
}
};
// Merge pairs left
while (true) {
var b = root.heap.prev orelse return root;
b.heap.next = null;
root = self.meld(b, root);
}
}
};
}
/// The state that is required for IntrusiveHeap element types. This
/// should be set as the "heap" field in the type T.
pub fn IntrusiveField(comptime T: type) type {
return struct {
child: ?*T = null,
prev: ?*T = null,
next: ?*T = null,
};
}
test "heap" {
const Elem = struct {
const Self = @This();
value: usize = 0,
heap: IntrusiveField(Self) = .{},
};
const Heap = Intrusive(Elem, void, (struct {
fn less(ctx: void, a: *Elem, b: *Elem) bool {
_ = ctx;
return a.value < b.value;
}
}).less);
var a: Elem = .{ .value = 12 };
var b: Elem = .{ .value = 24 };
var c: Elem = .{ .value = 7 };
var d: Elem = .{ .value = 9 };
var h: Heap = .{ .context = {} };
h.insert(&a);
h.insert(&b);
h.insert(&c);
h.insert(&d);
h.remove(&d);
const testing = std.testing;
try testing.expect(h.deleteMin().?.value == 7);
try testing.expect(h.deleteMin().?.value == 12);
try testing.expect(h.deleteMin().?.value == 24);
try testing.expect(h.deleteMin() == null);
}
test "heap remove root" {
const Elem = struct {
const Self = @This();
value: usize = 0,
heap: IntrusiveField(Self) = .{},
};
const Heap = Intrusive(Elem, void, (struct {
fn less(ctx: void, a: *Elem, b: *Elem) bool {
_ = ctx;
return a.value < b.value;
}
}).less);
var a: Elem = .{ .value = 12 };
var b: Elem = .{ .value = 24 };
var h: Heap = .{ .context = {} };
h.insert(&a);
h.insert(&b);
h.remove(&a);
const testing = std.testing;
try testing.expect(h.deleteMin().?.value == 24);
try testing.expect(h.deleteMin() == null);
}
test "heap remove with children" {
const Elem = struct {
const Self = @This();
value: usize = 0,
heap: IntrusiveField(Self) = .{},
};
const Heap = Intrusive(Elem, void, (struct {
fn less(ctx: void, a: *Elem, b: *Elem) bool {
_ = ctx;
return a.value < b.value;
}
}).less);
var a: Elem = .{ .value = 36 };
var b: Elem = .{ .value = 24 };
var c: Elem = .{ .value = 12 };
var h: Heap = .{ .context = {} };
h.insert(&a);
h.insert(&b);
h.insert(&c);
h.remove(&b);
const testing = std.testing;
try testing.expect(h.deleteMin().?.value == 12);
try testing.expect(h.deleteMin().?.value == 36);
try testing.expect(h.deleteMin() == null);
}
test "heap equal values" {
const testing = std.testing;
const Elem = struct {
const Self = @This();
value: usize = 0,
heap: IntrusiveField(Self) = .{},
};
const Heap = Intrusive(Elem, void, (struct {
fn less(ctx: void, a: *Elem, b: *Elem) bool {
_ = ctx;
return a.value < b.value;
}
}).less);
var a: Elem = .{ .value = 1 };
var b: Elem = .{ .value = 2 };
var c: Elem = .{ .value = 3 };
var d: Elem = .{ .value = 4 };
var h: Heap = .{ .context = {} };
h.insert(&a);
h.insert(&b);
h.insert(&c);
h.insert(&d);
try testing.expect(h.deleteMin().?.value == 1);
try testing.expect(h.deleteMin().?.value == 2);
try testing.expect(h.deleteMin().?.value == 3);
try testing.expect(h.deleteMin().?.value == 4);
try testing.expect(h.deleteMin() == null);
}
test "heap: million values" {
const testing = std.testing;
const alloc = testing.allocator;
const Elem = struct {
const Self = @This();
value: usize = 0,
heap: IntrusiveField(Self) = .{},
};
const Heap = Intrusive(Elem, void, (struct {
fn less(ctx: void, a: *Elem, b: *Elem) bool {
_ = ctx;
return a.value < b.value;
}
}).less);
const NUM_TIMERS: usize = 1000 * 1000;
var elems = try alloc.alloc(Elem, NUM_TIMERS);
defer alloc.free(elems);
var i: usize = 0;
var value: usize = 0;
while (i < NUM_TIMERS) : (i += 1) {
if (i % 100 == 0) value += 1;
elems[i] = .{ .value = value };
}
var h: Heap = .{ .context = {} };
for (elems) |*elem| {
h.insert(elem);
}
var count: usize = 0;
var last: usize = 0;
while (h.deleteMin()) |elem| {
count += 1;
try testing.expect(elem.value >= last);
last = elem.value;
}
try testing.expect(h.deleteMin() == null);
try testing.expect(count == NUM_TIMERS);
}
test "heap: dangling next pointer" {
const testing = std.testing;
const Elem = struct {
const Self = @This();
value: usize = 0,
heap: IntrusiveField(Self) = .{},
};
const Heap = Intrusive(Elem, void, (struct {
fn less(ctx: void, a: *Elem, b: *Elem) bool {
_ = ctx;
return a.value < b.value;
}
}).less);
var a: Elem = .{ .value = 2 };
var b: Elem = .{ .value = 4 };
var c: Elem = .{ .value = 5 };
var d: Elem = .{ .value = 1 };
var e: Elem = .{ .value = 3 };
var h: Heap = .{ .context = {} };
h.insert(&a);
h.insert(&b);
h.insert(&c);
h.insert(&d);
h.insert(&e);
try testing.expect(h.deleteMin().?.value == 1);
try testing.expect(h.deleteMin().?.value == 2);
try testing.expect(h.deleteMin().?.value == 3);
try testing.expect(h.deleteMin().?.value == 4);
try testing.expect(h.deleteMin().?.value == 5);
try testing.expect(h.deleteMin() == null);
}
|
0 | repos/libxev | repos/libxev/src/queue.zig | const std = @import("std");
const assert = std.debug.assert;
/// An intrusive queue implementation. The type T must have a field
/// "next" of type `?*T`.
///
/// For those unaware, an intrusive variant of a data structure is one in which
/// the data type in the list has the pointer to the next element, rather
/// than a higher level "node" or "container" type. The primary benefit
/// of this (and the reason we implement this) is that it defers all memory
/// management to the caller: the data structure implementation doesn't need
/// to allocate "nodes" to contain each element. Instead, the caller provides
/// the element and how its allocated is up to them.
pub fn Intrusive(comptime T: type) type {
return struct {
const Self = @This();
/// Head is the front of the queue and tail is the back of the queue.
head: ?*T = null,
tail: ?*T = null,
/// Enqueue a new element to the back of the queue.
pub fn push(self: *Self, v: *T) void {
assert(v.next == null);
if (self.tail) |tail| {
// If we have elements in the queue, then we add a new tail.
tail.next = v;
self.tail = v;
} else {
// No elements in the queue we setup the initial state.
self.head = v;
self.tail = v;
}
}
/// Dequeue the next element from the queue.
pub fn pop(self: *Self) ?*T {
// The next element is in "head".
const next = self.head orelse return null;
// If the head and tail are equal this is the last element
// so we also set tail to null so we can now be empty.
if (self.head == self.tail) self.tail = null;
// Head is whatever is next (if we're the last element,
// this will be null);
self.head = next.next;
// We set the "next" field to null so that this element
// can be inserted again.
next.next = null;
return next;
}
/// Returns true if the queue is empty.
pub fn empty(self: *const Self) bool {
return self.head == null;
}
};
}
test Intrusive {
const testing = std.testing;
// Types
const Elem = struct {
const Self = @This();
next: ?*Self = null,
};
const Queue = Intrusive(Elem);
var q: Queue = .{};
try testing.expect(q.empty());
// Elems
var elems: [10]Elem = .{.{}} ** 10;
// One
try testing.expect(q.pop() == null);
q.push(&elems[0]);
try testing.expect(!q.empty());
try testing.expect(q.pop().? == &elems[0]);
try testing.expect(q.pop() == null);
try testing.expect(q.empty());
// Two
try testing.expect(q.pop() == null);
q.push(&elems[0]);
q.push(&elems[1]);
try testing.expect(q.pop().? == &elems[0]);
try testing.expect(q.pop().? == &elems[1]);
try testing.expect(q.pop() == null);
// Interleaved
try testing.expect(q.pop() == null);
q.push(&elems[0]);
try testing.expect(q.pop().? == &elems[0]);
q.push(&elems[1]);
try testing.expect(q.pop().? == &elems[1]);
try testing.expect(q.pop() == null);
}
|
0 | repos/libxev | repos/libxev/src/windows.zig | const std = @import("std");
const windows = std.os.windows;
const posix = std.posix;
pub usingnamespace std.os.windows;
/// Namespace containing missing utils from std
pub const exp = struct {
pub const STATUS_PENDING = 0x00000103;
pub const STILL_ACTIVE = STATUS_PENDING;
pub const JOBOBJECT_ASSOCIATE_COMPLETION_PORT = extern struct {
CompletionKey: windows.ULONG_PTR,
CompletionPort: windows.HANDLE,
};
pub const JOBOBJECT_BASIC_LIMIT_INFORMATION = extern struct {
PerProcessUserTimeLimit: windows.LARGE_INTEGER,
PerJobUserTimeLimit: windows.LARGE_INTEGER,
LimitFlags: windows.DWORD,
MinimumWorkingSetSize: windows.SIZE_T,
MaximumWorkingSetSize: windows.SIZE_T,
ActiveProcessLimit: windows.DWORD,
Affinity: windows.ULONG_PTR,
PriorityClass: windows.DWORD,
SchedulingClass: windows.DWORD,
};
pub const IO_COUNTERS = extern struct {
ReadOperationCount: windows.ULONGLONG,
WriteOperationCount: windows.ULONGLONG,
OtherOperationCount: windows.ULONGLONG,
ReadTransferCount: windows.ULONGLONG,
WriteTransferCount: windows.ULONGLONG,
OtherTransferCount: windows.ULONGLONG,
};
pub const JOBOBJECT_EXTENDED_LIMIT_INFORMATION = extern struct {
BasicLimitInformation: JOBOBJECT_BASIC_LIMIT_INFORMATION,
IoInfo: IO_COUNTERS,
ProcessMemoryLimit: windows.SIZE_T,
JobMemoryLimit: windows.SIZE_T,
PeakProcessMemoryUsed: windows.SIZE_T,
PeakJobMemoryUsed: windows.SIZE_T,
};
pub const JOB_OBJECT_LIMIT_ACTIVE_PROCESS = 0x00000008;
pub const JOB_OBJECT_LIMIT_AFFINITY = 0x00000010;
pub const JOB_OBJECT_LIMIT_BREAKAWAY_OK = 0x00000800;
pub const JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x00000400;
pub const JOB_OBJECT_LIMIT_JOB_MEMORY = 0x00000200;
pub const JOB_OBJECT_LIMIT_JOB_TIME = 0x00000004;
pub const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x00002000;
pub const JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME = 0x00000004;
pub const JOB_OBJECT_LIMIT_PRIORITY_CLASS = 0x00000020;
pub const JOB_OBJECT_LIMIT_PROCESS_MEMORY = 0x00000100;
pub const JOB_OBJECT_LIMIT_PROCESS_TIME = 0x00000002;
pub const JOB_OBJECT_LIMIT_SCHEDULING_CLASS = 0x00000080;
pub const JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK = 0x00001000;
pub const JOB_OBJECT_LIMIT_SUBSET_AFFINITY = 0x00004000;
pub const JOB_OBJECT_LIMIT_WORKINGSET = 0x00000001;
pub const JOBOBJECT_INFORMATION_CLASS = enum(c_int) {
JobObjectAssociateCompletionPortInformation = 7,
JobObjectBasicLimitInformation = 2,
JobObjectBasicUIRestrictions = 4,
JobObjectCpuRateControlInformation = 15,
JobObjectEndOfJobTimeInformation = 6,
JobObjectExtendedLimitInformation = 9,
JobObjectGroupInformation = 11,
JobObjectGroupInformationEx = 14,
JobObjectLimitViolationInformation2 = 34,
JobObjectNetRateControlInformation = 32,
JobObjectNotificationLimitInformation = 12,
JobObjectNotificationLimitInformation2 = 33,
JobObjectSecurityLimitInformation = 5,
};
pub const JOB_OBJECT_MSG_TYPE = enum(windows.DWORD) {
JOB_OBJECT_MSG_END_OF_JOB_TIME = 1,
JOB_OBJECT_MSG_END_OF_PROCESS_TIME = 2,
JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT = 3,
JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO = 4,
JOB_OBJECT_MSG_NEW_PROCESS = 6,
JOB_OBJECT_MSG_EXIT_PROCESS = 7,
JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS = 8,
JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT = 9,
JOB_OBJECT_MSG_JOB_MEMORY_LIMIT = 10,
JOB_OBJECT_MSG_NOTIFICATION_LIMIT = 11,
JOB_OBJECT_MSG_JOB_CYCLE_TIME_LIMIT = 12,
JOB_OBJECT_MSG_SILO_TERMINATED = 13,
_,
};
pub const kernel32 = struct {
pub extern "kernel32" fn GetProcessId(Process: windows.HANDLE) callconv(windows.WINAPI) windows.DWORD;
pub extern "kernel32" fn CreateJobObjectA(lpSecurityAttributes: ?*windows.SECURITY_ATTRIBUTES, lpName: ?windows.LPCSTR) callconv(windows.WINAPI) windows.HANDLE;
pub extern "kernel32" fn AssignProcessToJobObject(hJob: windows.HANDLE, hProcess: windows.HANDLE) callconv(windows.WINAPI) windows.BOOL;
pub extern "kernel32" fn SetInformationJobObject(
hJob: windows.HANDLE,
JobObjectInformationClass: JOBOBJECT_INFORMATION_CLASS,
lpJobObjectInformation: windows.LPVOID,
cbJobObjectInformationLength: windows.DWORD,
) callconv(windows.WINAPI) windows.BOOL;
};
pub const CreateFileError = error{} || posix.UnexpectedError;
pub fn CreateFile(
lpFileName: [*:0]const u16,
dwDesiredAccess: windows.DWORD,
dwShareMode: windows.DWORD,
lpSecurityAttributes: ?*windows.SECURITY_ATTRIBUTES,
dwCreationDisposition: windows.DWORD,
dwFlagsAndAttributes: windows.DWORD,
hTemplateFile: ?windows.HANDLE,
) CreateFileError!windows.HANDLE {
const handle = windows.kernel32.CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
if (handle == windows.INVALID_HANDLE_VALUE) {
const err = windows.kernel32.GetLastError();
return switch (err) {
else => windows.unexpectedError(err),
};
}
return handle;
}
pub fn ReadFile(
handle: windows.HANDLE,
buffer: []u8,
overlapped: ?*windows.OVERLAPPED,
) windows.ReadFileError!?usize {
var read: windows.DWORD = 0;
const result: windows.BOOL = windows.kernel32.ReadFile(handle, buffer.ptr, @as(windows.DWORD, @intCast(buffer.len)), &read, overlapped);
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
return switch (err) {
windows.Win32Error.IO_PENDING => null,
else => windows.unexpectedError(err),
};
}
return @as(usize, @intCast(read));
}
pub fn WriteFile(
handle: windows.HANDLE,
buffer: []const u8,
overlapped: ?*windows.OVERLAPPED,
) windows.WriteFileError!?usize {
var written: windows.DWORD = 0;
const result: windows.BOOL = windows.kernel32.WriteFile(handle, buffer.ptr, @as(windows.DWORD, @intCast(buffer.len)), &written, overlapped);
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
return switch (err) {
windows.Win32Error.IO_PENDING => null,
else => windows.unexpectedError(err),
};
}
return @as(usize, @intCast(written));
}
pub const DeleteFileError = error{} || posix.UnexpectedError;
pub fn DeleteFile(name: [*:0]const u16) DeleteFileError!void {
const result: windows.BOOL = windows.kernel32.DeleteFileW(name);
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
return switch (err) {
else => windows.unexpectedError(err),
};
}
}
pub const CreateJobObjectError = error{AlreadyExists} || posix.UnexpectedError;
pub fn CreateJobObject(
lpSecurityAttributes: ?*windows.SECURITY_ATTRIBUTES,
lpName: ?windows.LPCSTR,
) !windows.HANDLE {
const handle = kernel32.CreateJobObjectA(lpSecurityAttributes, lpName);
return switch (windows.kernel32.GetLastError()) {
.SUCCESS => handle,
.ALREADY_EXISTS => CreateJobObjectError.AlreadyExists,
else => |err| windows.unexpectedError(err),
};
}
pub fn AssignProcessToJobObject(hJob: windows.HANDLE, hProcess: windows.HANDLE) posix.UnexpectedError!void {
const result: windows.BOOL = kernel32.AssignProcessToJobObject(hJob, hProcess);
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
return switch (err) {
else => windows.unexpectedError(err),
};
}
}
pub fn SetInformationJobObject(
hJob: windows.HANDLE,
JobObjectInformationClass: JOBOBJECT_INFORMATION_CLASS,
lpJobObjectInformation: windows.LPVOID,
cbJobObjectInformationLength: windows.DWORD,
) posix.UnexpectedError!void {
const result: windows.BOOL = kernel32.SetInformationJobObject(
hJob,
JobObjectInformationClass,
lpJobObjectInformation,
cbJobObjectInformationLength,
);
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
return switch (err) {
else => windows.unexpectedError(err),
};
}
}
};
|
0 | repos/libxev | repos/libxev/src/queue_mpsc.zig | const std = @import("std");
const assert = std.debug.assert;
/// An intrusive MPSC (multi-provider, single consumer) queue implementation.
/// The type T must have a field "next" of type `?*T`.
///
/// This is an implementatin of a Vyukov Queue[1].
/// TODO(mitchellh): I haven't audited yet if I got all the atomic operations
/// correct. I was short term more focused on getting something that seemed
/// to work; I need to make sure it actually works.
///
/// For those unaware, an intrusive variant of a data structure is one in which
/// the data type in the list has the pointer to the next element, rather
/// than a higher level "node" or "container" type. The primary benefit
/// of this (and the reason we implement this) is that it defers all memory
/// management to the caller: the data structure implementation doesn't need
/// to allocate "nodes" to contain each element. Instead, the caller provides
/// the element and how its allocated is up to them.
///
/// [1]: https://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue
pub fn Intrusive(comptime T: type) type {
return struct {
const Self = @This();
/// Head is the front of the queue and tail is the back of the queue.
head: *T,
tail: *T,
stub: T,
/// Initialize the queue. This requires a stable pointer to itself.
/// This must be called before the queue is used concurrently.
pub fn init(self: *Self) void {
self.head = &self.stub;
self.tail = &self.stub;
self.stub.next = null;
}
/// Push an item onto the queue. This can be called by any number
/// of producers.
pub fn push(self: *Self, v: *T) void {
@atomicStore(?*T, &v.next, null, .unordered);
const prev = @atomicRmw(*T, &self.head, .Xchg, v, .acq_rel);
@atomicStore(?*T, &prev.next, v, .release);
}
/// Pop the first in element from the queue. This must be called
/// by only a single consumer at any given time.
pub fn pop(self: *Self) ?*T {
var tail = @atomicLoad(*T, &self.tail, .unordered);
var next_ = @atomicLoad(?*T, &tail.next, .acquire);
if (tail == &self.stub) {
const next = next_ orelse return null;
@atomicStore(*T, &self.tail, next, .unordered);
tail = next;
next_ = @atomicLoad(?*T, &tail.next, .acquire);
}
if (next_) |next| {
@atomicStore(*T, &self.tail, next, .release);
tail.next = null;
return tail;
}
const head = @atomicLoad(*T, &self.head, .unordered);
if (tail != head) return null;
self.push(&self.stub);
next_ = @atomicLoad(?*T, &tail.next, .acquire);
if (next_) |next| {
@atomicStore(*T, &self.tail, next, .unordered);
tail.next = null;
return tail;
}
return null;
}
};
}
test Intrusive {
const testing = std.testing;
// Types
const Elem = struct {
const Self = @This();
next: ?*Self = null,
};
const Queue = Intrusive(Elem);
var q: Queue = undefined;
q.init();
// Elems
var elems: [10]Elem = .{.{}} ** 10;
// One
try testing.expect(q.pop() == null);
q.push(&elems[0]);
try testing.expect(q.pop().? == &elems[0]);
try testing.expect(q.pop() == null);
// Two
try testing.expect(q.pop() == null);
q.push(&elems[0]);
q.push(&elems[1]);
try testing.expect(q.pop().? == &elems[0]);
try testing.expect(q.pop().? == &elems[1]);
try testing.expect(q.pop() == null);
// // Interleaved
try testing.expect(q.pop() == null);
q.push(&elems[0]);
try testing.expect(q.pop().? == &elems[0]);
q.push(&elems[1]);
try testing.expect(q.pop().? == &elems[1]);
try testing.expect(q.pop() == null);
}
|
0 | repos/libxev | repos/libxev/src/loop.zig | //! Common loop structures. The actual loop implementation is in backend-specific
//! files such as linux/io_uring.zig.
const std = @import("std");
const assert = std.debug.assert;
const xev = @import("main.zig");
/// Common options across backends. Not all options apply to all backends.
/// Read the doc comment for individual fields to learn what backends they
/// apply to.
pub const Options = struct {
/// The number of queued completions that can be in flight before
/// requiring interaction with the kernel.
///
/// Backends: io_uring
entries: u32 = 256,
/// A thread pool to use for blocking operations. If the backend doesn't
/// need to perform any blocking operations then no threads will ever
/// be spawned. If the backend does need to perform blocking operations
/// on a thread and no thread pool is provided, the operations will simply
/// fail. Unless you're trying to really optimize for space, it is
/// recommended you provide a thread pool.
///
/// Backends: epoll, kqueue
thread_pool: ?*xev.ThreadPool = null,
};
/// The loop run mode -- all backends are required to support this in some way.
/// Backends may provide backend-specific APIs that behave slightly differently
/// or in a more configurable way.
pub const RunMode = enum(c_int) {
/// Run the event loop once. If there are no blocking operations ready,
/// return immediately.
no_wait = 0,
/// Run the event loop once, waiting for at least one blocking operation
/// to complete.
once = 1,
/// Run the event loop until it is "done". "Doneness" is defined as
/// there being no more completions that are active.
until_done = 2,
};
/// The result type for callbacks. This should be used by all loop
/// implementations and higher level abstractions in order to control
/// what to do after the loop completes.
pub const CallbackAction = enum(c_int) {
/// The request is complete and is not repeated. For example, a read
/// callback only fires once and is no longer watched for reads. You
/// can always free memory associated with the completion prior to
/// returning this.
disarm = 0,
/// Requeue the same operation request with the same parameters
/// with the event loop. This makes it easy to repeat a read, timer,
/// etc. This rearms the request EXACTLY as-is. For example, the
/// low-level timer interface for io_uring uses an absolute timeout.
/// If you rearm the timer, it will fire immediately because the absolute
/// timeout will be in the past.
///
/// The completion is reused so it is not safe to use the same completion
/// for anything else.
rearm = 1,
};
/// The state that a completion can be in.
pub const CompletionState = enum(c_int) {
/// The completion is not being used and is ready to be configured
/// for new work.
dead = 0,
/// The completion is part of an event loop. This may be already waited
/// on or in the process of being registered.
active = 1,
};
|
0 | repos/libxev/src | repos/libxev/src/linux/timerfd.zig | const std = @import("std");
const linux = std.os.linux;
const posix = std.posix;
/// Timerfd is a wrapper around the timerfd system calls. See the
/// timerfd_create man page for information on timerfd and associated
/// system calls.
///
/// This is a small wrapper around timerfd to make it slightly more
/// pleasant to use, but may not expose all available functionality.
/// For maximum control you should use the syscalls directly.
pub const Timerfd = struct {
/// The timerfd file descriptor for use with poll, etc.
fd: i32,
/// timerfd_create
pub fn init(clock: Clock, flags: linux.TFD) !Timerfd {
const res = linux.timerfd_create(@intFromEnum(clock), flags);
return switch (posix.errno(res)) {
.SUCCESS => .{ .fd = @as(i32, @intCast(res)) },
else => error.UnknownError,
};
}
pub fn deinit(self: *const Timerfd) void {
posix.close(self.fd);
}
/// timerfd_settime
pub fn set(
self: *const Timerfd,
flags: linux.TFD.TIMER,
new_value: *const Spec,
old_value: ?*Spec,
) !void {
const res = linux.timerfd_settime(
self.fd,
flags,
@as(*const linux.itimerspec, @ptrCast(new_value)),
@as(?*linux.itimerspec, @ptrCast(old_value)),
);
return switch (posix.errno(res)) {
.SUCCESS => {},
else => error.UnknownError,
};
}
/// timerfd_gettime
pub fn get(self: *const Timerfd) !Spec {
var out: Spec = undefined;
const res = linux.timerfd_gettime(self.fd, @as(*linux.itimerspec, @ptrCast(&out)));
return switch (posix.errno(res)) {
.SUCCESS => out,
else => error.UnknownError,
};
}
/// The clocks available for a Timerfd. This is a non-exhaustive enum
/// so that unsupported values can be attempted to be passed into the
/// system calls.
pub const Clock = enum(i32) {
realtime = 0,
monotonic = 1,
boottime = 7,
realtime_alarm = 8,
boottime_alarm = 9,
_,
};
/// itimerspec
pub const Spec = extern struct {
interval: TimeSpec = .{},
value: TimeSpec = .{},
};
/// timespec
pub const TimeSpec = extern struct {
seconds: isize = 0,
nanoseconds: isize = 0,
};
};
test Timerfd {
const testing = std.testing;
var t = try Timerfd.init(.monotonic, .{});
defer t.deinit();
// Set
try t.set(.{}, &.{ .value = .{ .seconds = 60 } }, null);
try testing.expect((try t.get()).value.seconds > 0);
// Disarm
var old: Timerfd.Spec = undefined;
try t.set(.{}, &.{ .value = .{ .seconds = 0 } }, &old);
try testing.expect(old.value.seconds > 0);
}
|
0 | repos/libxev/src | repos/libxev/src/build/ScdocStep.zig | const std = @import("std");
const mem = std.mem;
const fs = std.fs;
const Step = std.Build.Step;
const Build = std.Build;
/// ScdocStep generates man pages using scdoc(1).
///
/// It reads all the raw pages from src_path and writes them to out_path.
/// src_path is typically "docs/" relative to the build root and out_path is
/// the build cache.
///
/// The man pages can be installed by calling install() on the step.
const ScdocStep = @This();
step: Step,
builder: *Build,
/// path to read man page sources from, defaults to the "doc/" subdirectory
/// from the build.zig file. This must be an absolute path.
src_path: []const u8,
/// path where the generated man pages will be written (NOT installed). This
/// defaults to build cache root.
out_path: []const u8,
pub fn create(builder: *Build) *ScdocStep {
const self = builder.allocator.create(ScdocStep) catch unreachable;
self.* = init(builder);
return self;
}
pub fn init(builder: *Build) ScdocStep {
return ScdocStep{
.builder = builder,
.step = Step.init(.{
.id = .custom,
.name = "generate man pages",
.owner = builder,
.makeFn = make,
}),
.src_path = builder.pathFromRoot("docs/"),
.out_path = builder.cache_root.join(builder.allocator, &[_][]const u8{
"man",
}) catch unreachable,
};
}
fn make(step: *std.Build.Step, _: std.Progress.Node) !void {
const self: *ScdocStep = @fieldParentPtr("step", step);
// Create our cache path
// TODO(mitchellh): ideally this would be pure zig
{
const command = try std.fmt.allocPrint(
self.builder.allocator,
"rm -f {[path]s}/* && mkdir -p {[path]s}",
.{ .path = self.out_path },
);
_ = self.builder.run(&[_][]const u8{ "sh", "-c", command });
}
// Find all our man pages which are in our src path ending with ".scd".
var dir = try fs.openDirAbsolute(self.src_path, .{ .iterate = true });
defer dir.close();
var iter = dir.iterate();
while (try iter.next()) |*entry| {
// We only want "scd" files to generate.
if (!mem.eql(u8, fs.path.extension(entry.name), ".scd")) {
continue;
}
const src = try fs.path.join(
self.builder.allocator,
&[_][]const u8{ self.src_path, entry.name },
);
const dst = try fs.path.join(
self.builder.allocator,
&[_][]const u8{ self.out_path, entry.name[0..(entry.name.len - 4)] },
);
const command = try std.fmt.allocPrint(
self.builder.allocator,
"scdoc < {s} > {s}",
.{ src, dst },
);
_ = self.builder.run(&[_][]const u8{ "sh", "-c", command });
}
}
pub fn install(self: *ScdocStep) !void {
// Ensure that `zig build install` depends on our generation step first.
self.builder.getInstallStep().dependOn(&self.step);
// Then run our install step which looks at what we made out of our
// generation and moves it to the install prefix.
const install_step = InstallStep.create(self.builder, self);
self.builder.getInstallStep().dependOn(&install_step.step);
}
/// Install man pages, create using install() on ScdocStep.
const InstallStep = struct {
step: Step,
builder: *Build,
scdoc: *ScdocStep,
pub fn create(builder: *Build, scdoc: *ScdocStep) *InstallStep {
const self = builder.allocator.create(InstallStep) catch unreachable;
self.* = InstallStep.init(builder, scdoc);
self.step.dependOn(&scdoc.step);
return self;
}
fn init(builder: *Build, scdoc: *ScdocStep) InstallStep {
return InstallStep{
.builder = builder,
.step = Step.init(.{
.id = .custom,
.name = "install man pages",
.owner = builder,
.makeFn = InstallStep.make,
}),
.scdoc = scdoc,
};
}
fn make(step: *Step, progress: std.Progress.Node) !void {
const self: *InstallStep = @fieldParentPtr("step", step);
// Get our absolute output path
var path = self.scdoc.out_path;
if (!fs.path.isAbsolute(path)) {
path = self.builder.pathFromRoot(path);
}
// Find all our man pages which are in our src path ending with ".scd".
var dir = try fs.openDirAbsolute(path, .{ .iterate = true });
defer dir.close();
var iter = dir.iterate();
while (try iter.next()) |*entry| {
// We expect filenames to be "foo.3" and this gets us "3"
const section = entry.name[(entry.name.len - 1)..];
const src = try fs.path.join(
self.builder.allocator,
&[_][]const u8{ path, entry.name },
);
const output = try std.fmt.allocPrint(
self.builder.allocator,
"share/man/man{s}/{s}",
.{ section, entry.name },
);
const fileStep = self.builder.addInstallFile(
.{ .cwd_relative = src },
output,
);
try fileStep.step.make(progress);
}
}
};
|
0 | repos/libxev/src | repos/libxev/src/watcher/timer.zig | const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const os = std.os;
/// A timer fires a callback after a specified amount of time. A timer can
/// repeat by returning "rearm" in the callback or by rescheduling the
/// start within the callback.
pub fn Timer(comptime xev: type) type {
return struct {
const Self = @This();
/// Create a new timer.
pub fn init() !Self {
return .{};
}
pub fn deinit(self: *const Self) void {
// Nothing for now.
_ = self;
}
/// Start the timer. The timer will execute in next_ms milliseconds from
/// now.
///
/// This will use the monotonic clock on your system if available so
/// this is immune to system clock changes or drift. The callback is
/// guaranteed to fire NO EARLIER THAN "next_ms" milliseconds. We can't
/// make any guarantees about exactness or time bounds because its possible
/// for your OS to just... pause.. the process for an indefinite period of
/// time.
///
/// Like everything else in libxev, if you want something to repeat, you
/// must then requeue the completion manually. This punts off one of the
/// "hard" aspects of timers: it is up to you to determine what the semantic
/// meaning of intervals are. For example, if you want a timer to repeat every
/// 10 seconds, is it every 10th second of a wall clock? every 10th second
/// after an invocation? every 10th second after the work time from the
/// invocation? You have the power to answer these questions, manually.
pub fn run(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
next_ms: u64,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: RunError!void,
) xev.CallbackAction,
) void {
_ = self;
loop.timer(c, next_ms, userdata, (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
@as(?*Userdata, if (Userdata == void) null else @ptrCast(@alignCast(ud))),
l_inner,
c_inner,
if (r.timer) |trigger| @as(RunError!void, switch (trigger) {
.request, .expiration => {},
.cancel => error.Canceled,
}) else |err| err,
});
}
}).callback);
}
/// Reset a timer to execute in next_ms milliseconds. If the timer
/// is already started, this will stop it and restart it. If the
/// timer has never been started, this is equivalent to running "run".
/// In every case, the timer callback is updated to the given userdata
/// and callback.
///
/// This requires an additional completion c_cancel to represent
/// the need to possibly cancel the previous timer. You can check
/// if c_cancel was used by checking the state() after the call.
///
/// VERY IMPORTANT: both c and c_cancel MUST NOT be undefined. They
/// must be initialized to ".{}" if being used for the first time.
pub fn reset(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
c_cancel: *xev.Completion,
next_ms: u64,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: RunError!void,
) xev.CallbackAction,
) void {
_ = self;
loop.timer_reset(c, c_cancel, next_ms, userdata, (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
@as(?*Userdata, if (Userdata == void) null else @ptrCast(@alignCast(ud))),
l_inner,
c_inner,
if (r.timer) |trigger| @as(RunError!void, switch (trigger) {
.request, .expiration => {},
.cancel => error.Canceled,
}) else |err| err,
});
}
}).callback);
}
/// Cancel a previously started timer. The timer to cancel used the completion
/// "c_cancel". A new completion "c" must be specified which will be called
/// with the callback once cancellation is complete.
///
/// The original timer will still have its callback fired but with the
/// error "error.Canceled".
pub fn cancel(
self: Self,
loop: *xev.Loop,
c_timer: *xev.Completion,
c_cancel: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: CancelError!void,
) xev.CallbackAction,
) void {
_ = self;
c_cancel.* = switch (xev.backend) {
.io_uring => .{
.op = .{
.timer_remove = .{
.timer = c_timer,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
@as(?*Userdata, if (Userdata == void) null else @ptrCast(@alignCast(ud))),
l_inner,
c_inner,
if (r.timer_remove) |_| {} else |err| err,
});
}
}).callback,
},
.epoll,
.kqueue,
.wasi_poll,
.iocp,
=> .{
.op = .{
.cancel = .{
.c = c_timer,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
@as(?*Userdata, if (Userdata == void) null else @ptrCast(@alignCast(ud))),
l_inner,
c_inner,
if (r.cancel) |_| {} else |err| err,
});
}
}).callback,
},
};
loop.add(c_cancel);
}
/// Error that could happen while running a timer.
pub const RunError = error{
/// The timer was canceled before it could expire
Canceled,
/// Some unexpected error.
Unexpected,
};
pub const CancelError = xev.CancelError;
test "timer" {
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var timer = try init();
defer timer.deinit();
// Add the timer
var called = false;
var c1: xev.Completion = undefined;
timer.run(&loop, &c1, 1, bool, &called, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
r: RunError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback);
// Wait
try loop.run(.until_done);
try testing.expect(called);
}
test "timer reset" {
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var timer = try init();
defer timer.deinit();
var c_timer: xev.Completion = .{};
var c_cancel: xev.Completion = .{};
const cb = (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
r: RunError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback;
// Add the timer
var canceled = false;
timer.run(&loop, &c_timer, 100_000, bool, &canceled, cb);
// Wait
try loop.run(.no_wait);
try testing.expect(!canceled);
// Reset it
timer.reset(&loop, &c_timer, &c_cancel, 1, bool, &canceled, cb);
try loop.run(.until_done);
try testing.expect(canceled);
try testing.expect(c_timer.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "timer reset before tick" {
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var timer = try init();
defer timer.deinit();
var c_timer: xev.Completion = .{};
var c_cancel: xev.Completion = .{};
const cb = (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
r: RunError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback;
// Add the timer
var canceled = false;
timer.run(&loop, &c_timer, 100_000, bool, &canceled, cb);
// Reset it
timer.reset(&loop, &c_timer, &c_cancel, 1, bool, &canceled, cb);
try loop.run(.until_done);
try testing.expect(canceled);
try testing.expect(c_timer.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "timer reset after trigger" {
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var timer = try init();
defer timer.deinit();
var c_timer: xev.Completion = .{};
var c_cancel: xev.Completion = .{};
const cb = (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
r: RunError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback;
// Add the timer
var canceled = false;
timer.run(&loop, &c_timer, 1, bool, &canceled, cb);
try loop.run(.until_done);
try testing.expect(canceled);
canceled = false;
// Reset it
timer.reset(&loop, &c_timer, &c_cancel, 1, bool, &canceled, cb);
try loop.run(.until_done);
try testing.expect(canceled);
try testing.expect(c_timer.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "timer cancel" {
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var timer = try init();
defer timer.deinit();
// Add the timer
var canceled = false;
var c1: xev.Completion = undefined;
timer.run(&loop, &c1, 100_000, bool, &canceled, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
r: RunError!void,
) xev.CallbackAction {
ud.?.* = if (r) false else |err| err == error.Canceled;
return .disarm;
}
}).callback);
// Cancel
var cancel_confirm = false;
var c2: xev.Completion = undefined;
timer.cancel(&loop, &c1, &c2, bool, &cancel_confirm, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
r: CancelError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback);
// Wait
try loop.run(.until_done);
try testing.expect(canceled);
try testing.expect(cancel_confirm);
}
};
}
|
0 | repos/libxev/src | repos/libxev/src/watcher/stream.zig | const std = @import("std");
const assert = std.debug.assert;
const builtin = @import("builtin");
const common = @import("common.zig");
const queue = @import("../queue.zig");
/// Options for creating a stream type. Each of the options makes the
/// functionality available for the stream.
pub const Options = struct {
read: ReadMethod,
write: WriteMethod,
close: bool,
/// True to schedule the read/write on the threadpool.
threadpool: bool = false,
pub const ReadMethod = enum { none, read, recv };
pub const WriteMethod = enum { none, write, send };
};
/// Creates a stream type that is meant to be embedded within other
/// types using "usingnamespace". A stream is something that supports read,
/// write, close, etc. The exact operations supported are defined by the
/// "options" struct.
///
/// T requirements:
/// - field named "fd" of type fd_t or socket_t
/// - decl named "initFd" to initialize a new T from a fd
///
pub fn Stream(comptime xev: type, comptime T: type, comptime options: Options) type {
return struct {
pub usingnamespace if (options.close) Closeable(xev, T, options) else struct {};
pub usingnamespace if (options.read != .none) Readable(xev, T, options) else struct {};
pub usingnamespace if (options.write != .none) Writeable(xev, T, options) else struct {};
};
}
pub fn Closeable(comptime xev: type, comptime T: type, comptime options: Options) type {
_ = options;
return struct {
const Self = T;
pub const CloseError = xev.CloseError;
/// Close the socket.
pub fn close(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: Self,
r: CloseError!void,
) xev.CallbackAction,
) void {
c.* = .{
.op = .{ .close = .{ .fd = self.fd } },
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const fd = T.initFd(c_inner.op.close.fd);
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
fd,
if (r.close) |_| {} else |err| err,
});
}
}).callback,
};
loop.add(c);
}
};
}
pub fn Readable(comptime xev: type, comptime T: type, comptime options: Options) type {
return struct {
const Self = T;
pub const ReadError = xev.ReadError;
/// Read from the socket. This performs a single read. The callback must
/// requeue the read if additional reads want to be performed. Additional
/// reads simultaneously can be queued by calling this multiple times. Note
/// that depending on the backend, the reads can happen out of order.
pub fn read(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
buf: xev.ReadBuffer,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: Self,
b: xev.ReadBuffer,
r: ReadError!usize,
) xev.CallbackAction,
) void {
switch (buf) {
inline .slice, .array => {
c.* = .{
.op = switch (options.read) {
.none => unreachable,
.read => .{
.read = .{
.fd = self.fd,
.buffer = buf,
},
},
.recv => .{
.recv = .{
.fd = self.fd,
.buffer = buf,
},
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return switch (options.read) {
.none => unreachable,
.recv => @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
T.initFd(c_inner.op.recv.fd),
c_inner.op.recv.buffer,
if (r.recv) |v| v else |err| err,
}),
.read => @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
T.initFd(c_inner.op.read.fd),
c_inner.op.read.buffer,
if (r.read) |v| v else |err| err,
}),
};
}
}).callback,
};
// If we're dup-ing, then we ask the backend to manage the fd.
switch (xev.backend) {
.io_uring,
.wasi_poll,
.iocp,
=> {},
.epoll => {
if (options.threadpool)
c.flags.threadpool = true
else
c.flags.dup = true;
},
.kqueue => {
if (options.threadpool) c.flags.threadpool = true;
},
}
loop.add(c);
},
}
}
};
}
pub fn Writeable(comptime xev: type, comptime T: type, comptime options: Options) type {
return struct {
const Self = T;
pub const WriteError = xev.WriteError;
/// WriteQueue is the queue of write requests for ordered writes.
/// This can be copied around.
pub const WriteQueue = queue.Intrusive(WriteRequest);
/// WriteRequest is a single request for a write. It wraps a
/// completion so that it can be inserted into the WriteQueue.
pub const WriteRequest = struct {
completion: xev.Completion = .{},
userdata: ?*anyopaque = null,
/// This is the original buffer passed to queueWrite. We have
/// to keep track of this because we may be forced to split
/// the write or rearm the write due to partial writes, but when
/// we call the final callback we want to pass the original
/// complete buffer.
full_write_buffer: xev.WriteBuffer,
next: ?*@This() = null,
/// This can be used to convert a completion pointer back to
/// a WriteRequest. This is only safe of course if the completion
/// originally is from a write request. This is useful for getting
/// the WriteRequest back in a callback from queuedWrite.
pub fn from(c: *xev.Completion) *WriteRequest {
return @fieldParentPtr("completion", c);
}
};
/// Write to the stream. This queues the writes to ensure they
/// remain in order. Queueing has a small overhead: you must
/// maintain a WriteQueue and WriteRequests instead of just
/// Completions.
///
/// If ordering isn't important, or you can maintain ordering
/// naturally in your program, consider using write since it
/// has a slightly smaller overhead.
///
/// The "CallbackAction" return value of this callback behaves slightly
/// different. The "rearm" return value will re-queue the same write
/// at the end of the queue.
///
/// It is safe to call this at anytime from the main thread.
pub fn queueWrite(
self: Self,
loop: *xev.Loop,
q: *WriteQueue,
req: *WriteRequest,
buf: xev.WriteBuffer,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: Self,
b: xev.WriteBuffer,
r: WriteError!usize,
) xev.CallbackAction,
) void {
// Initialize our completion
req.* = .{ .full_write_buffer = buf };
// Must be kept in sync with partial write logic inside the callback
self.write_init(&req.completion, buf);
req.completion.userdata = q;
req.completion.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const q_inner = @as(?*WriteQueue, @ptrCast(@alignCast(ud))).?;
// The queue MUST have a request because a completion
// can only be added if the queue is not empty, and
// nothing else should be popping!.
//
// We only peek the request here (not pop) because we may
// need to rearm this write if the write was partial.
const req_inner: *WriteRequest = q_inner.head.?;
const cb_res = write_result(c_inner, r);
var result: WriteError!usize = cb_res.result;
// Checks whether the entire buffer was written, this is
// necessary to guarantee correct ordering of writes.
// If the write was partial, it re-submits the remainder of
// the buffer.
const queued_len = writeBufferLength(cb_res.buf);
if (cb_res.result) |written_len| {
if (written_len < queued_len) {
// Write remainder of the buffer, reusing the same completion
const rem_buf = writeBufferRemainder(cb_res.buf, written_len);
cb_res.writer.write_init(&req_inner.completion, rem_buf);
req_inner.completion.userdata = q_inner;
req_inner.completion.callback = callback;
l_inner.add(&req_inner.completion);
return .disarm;
}
// We wrote the entire buffer, modify the result to indicate
// to the caller that all bytes have been written.
result = writeBufferLength(req_inner.full_write_buffer);
} else |_| {}
// We can pop previously peeked request.
_ = q_inner.pop().?;
const action = @call(.always_inline, cb, .{
common.userdataValue(Userdata, req_inner.userdata),
l_inner,
c_inner,
cb_res.writer,
req_inner.full_write_buffer,
result,
});
// Rearm requeues this request, it doesn't return rearm
// on the actual callback here...
if (action == .rearm) q_inner.push(req_inner);
// If we have another request, add that completion next.
if (q_inner.head) |req_next| l_inner.add(&req_next.completion);
// We always disarm because the completion in the next
// request will be used if there is more to queue.
return .disarm;
}
}).callback;
// The userdata as to go on the WriteRequest because we need
// our actual completion userdata to be the WriteQueue so that
// we can process the queue.
req.userdata = @as(?*anyopaque, @ptrCast(@alignCast(userdata)));
// If the queue is empty, then we add our completion. Otherwise,
// the previously queued writes will trigger this one.
if (q.empty()) loop.add(&req.completion);
// We always add this item to our queue no matter what
q.push(req);
}
/// Write to the stream. This performs a single write. Additional
/// writes can be requested by calling this multiple times.
///
/// IMPORTANT: writes are NOT queued. There is no order guarantee
/// if this is called multiple times. If ordered writes are important
/// (they usually are!) then you should only call write again once
/// the previous write callback is called.
///
/// If ordering is important, use queueWrite instead.
pub fn write(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
buf: xev.WriteBuffer,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: Self,
b: xev.WriteBuffer,
r: WriteError!usize,
) xev.CallbackAction,
) void {
self.write_init(c, buf);
c.userdata = userdata;
c.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const cb_res = write_result(c_inner, r);
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
cb_res.writer,
cb_res.buf,
cb_res.result,
});
}
}).callback;
loop.add(c);
}
/// Extracts the result from a completion for a write callback.
inline fn write_result(c: *xev.Completion, r: xev.Result) struct {
writer: Self,
buf: xev.WriteBuffer,
result: WriteError!usize,
} {
return switch (options.write) {
.none => unreachable,
.send => .{
.writer = T.initFd(c.op.send.fd),
.buf = c.op.send.buffer,
.result = if (r.send) |v| v else |err| err,
},
.write => .{
.writer = T.initFd(c.op.write.fd),
.buf = c.op.write.buffer,
.result = if (r.write) |v| v else |err| err,
},
};
}
/// Initialize the completion c for a write. This does NOT set
/// userdata or a callback.
fn write_init(
self: Self,
c: *xev.Completion,
buf: xev.WriteBuffer,
) void {
switch (buf) {
inline .slice, .array => {
c.* = .{
.op = switch (options.write) {
.none => unreachable,
.write => .{
.write = .{
.fd = self.fd,
.buffer = buf,
},
},
.send => .{
.send = .{
.fd = self.fd,
.buffer = buf,
},
},
},
};
// If we're dup-ing, then we ask the backend to manage the fd.
switch (xev.backend) {
.io_uring,
.wasi_poll,
.iocp,
=> {},
.epoll => {
if (options.threadpool) {
c.flags.threadpool = true;
} else {
c.flags.dup = true;
}
},
.kqueue => {
if (options.threadpool) c.flags.threadpool = true;
},
}
},
}
}
/// Returns the length of the write buffer
fn writeBufferLength(buf: xev.WriteBuffer) usize {
return switch (buf) {
.slice => |slice| slice.len,
.array => |array| array.len,
};
}
/// Given a `WriteBuffer` and number of bytes written during the previous
/// write operation, returns a new `WriteBuffer` with remaining data.
fn writeBufferRemainder(buf: xev.WriteBuffer, offset: usize) xev.WriteBuffer {
switch (buf) {
.slice => |slice| {
assert(offset <= slice.len);
return .{ .slice = slice[offset..] };
},
.array => |array| {
assert(offset <= array.len);
const rem_len = array.len - offset;
var wb = xev.WriteBuffer{ .array = .{
.array = undefined,
.len = rem_len,
} };
@memcpy(
wb.array.array[0..rem_len],
array.array[offset..][0..rem_len],
);
return wb;
},
}
}
};
}
/// Creates a generic stream type that supports read, write, close. This
/// can be used for any file descriptor that would exhibit normal blocking
/// behavior on read/write. This should NOT be used for local files because
/// local files have some special properties; you should use xev.File for that.
pub fn GenericStream(comptime xev: type) type {
return struct {
const Self = @This();
/// The underlying file
fd: std.posix.fd_t,
pub usingnamespace Stream(xev, Self, .{
.close = true,
.read = .read,
.write = .write,
});
/// Initialize a generic stream from a file descriptor.
pub fn initFd(fd: std.posix.fd_t) Self {
return .{
.fd = fd,
};
}
/// Clean up any watcher resources. This does NOT close the file.
/// If you want to close the file you must call close or do so
/// synchronously.
pub fn deinit(self: *const Self) void {
_ = self;
}
test "pty: child to parent" {
const testing = std.testing;
switch (builtin.os.tag) {
.linux, .macos => {},
else => return error.SkipZigTest,
}
// Create the pty parent/child side.
var pty = try Pty.init();
defer pty.deinit();
var loop = try xev.Loop.init(.{});
defer loop.deinit();
const parent = initFd(pty.parent);
const child = initFd(pty.child);
// Read
var read_buf: [128]u8 = undefined;
var read_len: ?usize = null;
var c_read: xev.Completion = undefined;
parent.read(&loop, &c_read, .{ .slice = &read_buf }, ?usize, &read_len, (struct {
fn callback(
ud: ?*?usize,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.ReadBuffer,
r: Self.ReadError!usize,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// This should not block!
try loop.run(.no_wait);
try testing.expect(read_len == null);
// Send
const send_buf = "hello, world!";
var c_write: xev.Completion = undefined;
child.write(&loop, &c_write, .{ .slice = send_buf }, void, null, (struct {
fn callback(
_: ?*void,
_: *xev.Loop,
c: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
_ = c;
_ = r catch unreachable;
return .disarm;
}
}).callback);
// The write and read should trigger
try loop.run(.until_done);
try testing.expect(read_len != null);
try testing.expectEqualSlices(u8, send_buf, read_buf[0..read_len.?]);
}
test "pty: parent to child" {
const testing = std.testing;
switch (builtin.os.tag) {
.linux, .macos => {},
else => return error.SkipZigTest,
}
// Create the pty parent/child side.
var pty = try Pty.init();
defer pty.deinit();
var loop = try xev.Loop.init(.{});
defer loop.deinit();
const parent = initFd(pty.parent);
const child = initFd(pty.child);
// Read
var read_buf: [128]u8 = undefined;
var read_len: ?usize = null;
var c_read: xev.Completion = undefined;
child.read(&loop, &c_read, .{ .slice = &read_buf }, ?usize, &read_len, (struct {
fn callback(
ud: ?*?usize,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.ReadBuffer,
r: Self.ReadError!usize,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// This should not block!
try loop.run(.no_wait);
try testing.expect(read_len == null);
// Send (note the newline at the end of the buf is important
// since we're in cooked mode)
const send_buf = "hello, world!\n";
var c_write: xev.Completion = undefined;
parent.write(&loop, &c_write, .{ .slice = send_buf }, void, null, (struct {
fn callback(
_: ?*void,
_: *xev.Loop,
c: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
_ = c;
_ = r catch unreachable;
return .disarm;
}
}).callback);
// The write and read should trigger
try loop.run(.until_done);
try testing.expect(read_len != null);
try testing.expectEqualSlices(u8, send_buf, read_buf[0..read_len.?]);
}
test "pty: queued writes" {
const testing = std.testing;
switch (builtin.os.tag) {
.linux, .macos => {},
else => return error.SkipZigTest,
}
// Create the pty parent/child side.
var pty = try Pty.init();
defer pty.deinit();
var loop = try xev.Loop.init(.{});
defer loop.deinit();
const parent = initFd(pty.parent);
const child = initFd(pty.child);
// Read
var read_buf: [128]u8 = undefined;
var read_len: ?usize = null;
var c_read: xev.Completion = undefined;
child.read(&loop, &c_read, .{ .slice = &read_buf }, ?usize, &read_len, (struct {
fn callback(
ud: ?*?usize,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.ReadBuffer,
r: Self.ReadError!usize,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// This should not block!
try loop.run(.no_wait);
try testing.expect(read_len == null);
var write_queue: Self.WriteQueue = .{};
var write_req: [2]Self.WriteRequest = undefined;
// Send (note the newline at the end of the buf is important
// since we're in cooked mode)
parent.queueWrite(
&loop,
&write_queue,
&write_req[0],
.{ .slice = "hello, " },
void,
null,
(struct {
fn callback(
_: ?*void,
_: *xev.Loop,
c: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
_ = c;
_ = r catch unreachable;
return .disarm;
}
}).callback,
);
var c_result: ?*xev.Completion = null;
parent.queueWrite(
&loop,
&write_queue,
&write_req[1],
.{ .slice = "world!\n" },
?*xev.Completion,
&c_result,
(struct {
fn callback(
ud: ?*?*xev.Completion,
_: *xev.Loop,
c: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = c;
return .disarm;
}
}).callback,
);
// The write and read should trigger
try loop.run(.until_done);
try testing.expect(read_len != null);
try testing.expectEqualSlices(u8, "hello, world!\n", read_buf[0..read_len.?]);
// Verify our completion is equal to our request
try testing.expect(Self.WriteRequest.from(c_result.?) == &write_req[1]);
}
};
}
/// Helper to open a pty. This isn't exposed as a public API this is only
/// used for tests.
const Pty = struct {
/// The file descriptors for the parent/child side of the pty. This refers
/// to the master/slave side respectively, and while that terminology is
/// the officially used terminology of the syscall, I will use parent/child
/// here.
parent: std.posix.fd_t,
child: std.posix.fd_t,
/// Redeclare this winsize struct so we can just use a Zig struct. This
/// layout should be correct on all tested platforms.
const Winsize = extern struct {
ws_row: u16,
ws_col: u16,
ws_xpixel: u16,
ws_ypixel: u16,
};
// libc pty.h
extern "c" fn openpty(
parent: *std.posix.fd_t,
child: *std.posix.fd_t,
name: ?[*]u8,
termios: ?*const anyopaque, // termios but we don't use it
winsize: ?*const Winsize,
) c_int;
pub fn init() !Pty {
// Reasonable size
var size: Winsize = .{
.ws_row = 80,
.ws_col = 80,
.ws_xpixel = 800,
.ws_ypixel = 600,
};
var parent_fd: std.posix.fd_t = undefined;
var child_fd: std.posix.fd_t = undefined;
if (openpty(
&parent_fd,
&child_fd,
null,
null,
&size,
) < 0)
return error.OpenptyFailed;
errdefer {
_ = std.posix.system.close(parent_fd);
_ = std.posix.system.close(child_fd);
}
return .{
.parent = parent_fd,
.child = child_fd,
};
}
pub fn deinit(self: *Pty) void {
std.posix.close(self.parent);
std.posix.close(self.child);
}
};
|
0 | repos/libxev/src | repos/libxev/src/watcher/file.zig | const std = @import("std");
const builtin = @import("builtin");
const common = @import("common.zig");
const assert = std.debug.assert;
const posix = std.posix;
const main = @import("../main.zig");
const stream = @import("stream.zig");
/// File operations.
///
/// These operations typically run on the event loop thread pool, rather
/// than the core async OS APIs, because most core async OS APIs don't support
/// async operations on regular files (with many caveats attached to that
/// statement). This high-level abstraction will attempt to make the right
/// decision about what to do but this should generally be used by
/// operations that need to run on a thread pool. For operations that you're
/// sure are better supported by core async OS APIs (such as sockets, pipes,
/// TTYs, etc.), use a specific high-level abstraction like xev.TCP or
/// the generic xev.Stream.
///
/// This is a "higher-level abstraction" in libxev. The goal of higher-level
/// abstractions in libxev are to make it easier to use specific functionality
/// with the event loop, but does not promise perfect flexibility or optimal
/// performance. In almost all cases, the abstraction is good enough. But,
/// if you have specific needs or want to push for the most optimal performance,
/// use the platform-specific Loop directly.
pub fn File(comptime xev: type) type {
return struct {
const Self = @This();
const FdType = if (xev.backend == .iocp) std.windows.HANDLE else posix.socket_t;
/// The underlying file
fd: FdType,
pub usingnamespace stream.Stream(xev, Self, .{
.close = true,
.read = .read,
.write = .write,
.threadpool = true,
});
/// Initialize a File from a std.fs.File.
pub fn init(file: std.fs.File) !Self {
return .{
.fd = file.handle,
};
}
/// Initialize a File from a file descriptor.
pub fn initFd(fd: std.fs.File.Handle) Self {
return .{
.fd = fd,
};
}
/// Clean up any watcher resources. This does NOT close the file.
/// If you want to close the file you must call close or do so
/// synchronously.
pub fn deinit(self: *const File) void {
_ = self;
}
pub fn pread(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
buf: xev.ReadBuffer,
offset: u64,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: Self,
b: xev.ReadBuffer,
r: Self.ReadError!usize,
) xev.CallbackAction,
) void {
switch (buf) {
inline .slice, .array => {
c.* = .{
.op = .{
.pread = .{
.fd = self.fd,
.buffer = buf,
.offset = offset,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
Self.initFd(c_inner.op.pread.fd),
c_inner.op.pread.buffer,
if (r.pread) |v| v else |err| err,
});
}
}).callback,
};
// If we're dup-ing, then we ask the backend to manage the fd.
switch (xev.backend) {
.io_uring,
.wasi_poll,
.iocp,
=> {},
.epoll => {
c.flags.threadpool = true;
},
.kqueue => {
c.flags.threadpool = true;
},
}
loop.add(c);
},
}
}
pub fn queuePWrite(
self: Self,
loop: *xev.Loop,
q: *Self.WriteQueue,
req: *Self.WriteRequest,
buf: xev.WriteBuffer,
offset: u64,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: Self,
b: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction,
) void {
// Initialize our completion
req.* = .{};
self.pwrite_init(&req.completion, buf, offset);
req.completion.userdata = q;
req.completion.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const q_inner = @as(?*Self.WriteQueue, @ptrCast(@alignCast(ud))).?;
// The queue MUST have a request because a completion
// can only be added if the queue is not empty, and
// nothing else should be popping!.
const req_inner = q_inner.pop().?;
const cb_res = pwrite_result(c_inner, r);
const action = @call(.always_inline, cb, .{
common.userdataValue(Userdata, req_inner.userdata),
l_inner,
c_inner,
cb_res.writer,
cb_res.buf,
cb_res.result,
});
// Rearm requeues this request, it doesn't return rearm
// on the actual callback here...
if (action == .rearm) q_inner.push(req_inner);
// If we have another request, add that completion next.
if (q_inner.head) |req_next| l_inner.add(&req_next.completion);
// We always disarm because the completion in the next
// request will be used if there is more to queue.
return .disarm;
}
}).callback;
// The userdata as to go on the WriteRequest because we need
// our actual completion userdata to be the WriteQueue so that
// we can process the queue.
req.userdata = @as(?*anyopaque, @ptrCast(@alignCast(userdata)));
// If the queue is empty, then we add our completion. Otherwise,
// the previously queued writes will trigger this one.
if (q.empty()) loop.add(&req.completion);
// We always add this item to our queue no matter what
q.push(req);
}
pub fn pwrite(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
buf: xev.WriteBuffer,
offset: u64,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: Self,
b: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction,
) void {
self.pwrite_init(c, buf, offset);
c.userdata = userdata;
c.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const cb_res = pwrite_result(c_inner, r);
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
cb_res.writer,
cb_res.buf,
cb_res.result,
});
}
}).callback;
loop.add(c);
}
inline fn pwrite_result(c: *xev.Completion, r: xev.Result) struct {
writer: Self,
buf: xev.WriteBuffer,
result: Self.WriteError!usize,
} {
return .{
.writer = Self.initFd(c.op.pwrite.fd),
.buf = c.op.pwrite.buffer,
.result = if (r.pwrite) |v| v else |err| err,
};
}
fn pwrite_init(
self: Self,
c: *xev.Completion,
buf: xev.WriteBuffer,
offset: u64,
) void {
switch (buf) {
inline .slice, .array => {
c.* = .{
.op = .{
.pwrite = .{
.fd = self.fd,
.buffer = buf,
.offset = offset,
},
},
};
// If we're dup-ing, then we ask the backend to manage the fd.
switch (xev.backend) {
.io_uring,
.wasi_poll,
.iocp,
=> {},
.epoll => {
c.flags.threadpool = true;
},
.kqueue => {
c.flags.threadpool = true;
},
}
},
}
}
test "read/write" {
// wasi: local files don't work with poll (always ready)
if (builtin.os.tag == .wasi) return error.SkipZigTest;
// windows: std.fs.File is not opened with OVERLAPPED flag.
if (builtin.os.tag == .windows) return error.SkipZigTest;
const testing = std.testing;
var tpool = main.ThreadPool.init(.{});
defer tpool.deinit();
defer tpool.shutdown();
var loop = try xev.Loop.init(.{ .thread_pool = &tpool });
defer loop.deinit();
// Create our file
const path = "test_watcher_file";
const f = try std.fs.cwd().createFile(path, .{
.read = true,
.truncate = true,
});
defer f.close();
defer std.fs.cwd().deleteFile(path) catch {};
const file = try init(f);
// Perform a write and then a read
var write_buf = [_]u8{ 1, 1, 2, 3, 5, 8, 13 };
var c_write: xev.Completion = undefined;
file.write(&loop, &c_write, .{ .slice = &write_buf }, void, null, (struct {
fn callback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
_ = r catch unreachable;
return .disarm;
}
}).callback);
// Wait for the write
try loop.run(.until_done);
// Make sure the data is on disk
try f.sync();
const f2 = try std.fs.cwd().openFile(path, .{});
defer f2.close();
const file2 = try init(f2);
// Read
var read_buf: [128]u8 = undefined;
var read_len: usize = 0;
file2.read(&loop, &c_write, .{ .slice = &read_buf }, usize, &read_len, (struct {
fn callback(
ud: ?*usize,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.ReadBuffer,
r: Self.ReadError!usize,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
try loop.run(.until_done);
try testing.expectEqual(read_len, write_buf.len);
try testing.expectEqualSlices(u8, &write_buf, read_buf[0..read_len]);
}
test "pread/pwrite" {
// wasi: local files don't work with poll (always ready)
if (builtin.os.tag == .wasi) return error.SkipZigTest;
// windows: std.fs.File is not opened with OVERLAPPED flag.
if (builtin.os.tag == .windows) return error.SkipZigTest;
const testing = std.testing;
var tpool = main.ThreadPool.init(.{});
defer tpool.deinit();
defer tpool.shutdown();
var loop = try xev.Loop.init(.{ .thread_pool = &tpool });
defer loop.deinit();
// Create our file
const path = "test_watcher_file";
const f = try std.fs.cwd().createFile(path, .{
.read = true,
.truncate = true,
});
defer f.close();
defer std.fs.cwd().deleteFile(path) catch {};
const file = try init(f);
// Perform a write and then a read
var write_buf = [_]u8{ 1, 1, 2, 3, 5, 8, 13 };
var c_write: xev.Completion = undefined;
file.pwrite(&loop, &c_write, .{ .slice = &write_buf }, 0, void, null, (struct {
fn callback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
_ = r catch unreachable;
return .disarm;
}
}).callback);
// Wait for the write
try loop.run(.until_done);
// Make sure the data is on disk
try f.sync();
const f2 = try std.fs.cwd().openFile(path, .{});
defer f2.close();
const file2 = try init(f2);
var read_buf: [128]u8 = undefined;
var read_len: usize = 0;
file2.pread(&loop, &c_write, .{ .slice = &read_buf }, 0, usize, &read_len, (struct {
fn callback(
ud: ?*usize,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.ReadBuffer,
r: Self.ReadError!usize,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
try loop.run(.until_done);
try testing.expectEqualSlices(u8, &write_buf, read_buf[0..read_len]);
}
test "queued writes" {
// wasi: local files don't work with poll (always ready)
if (builtin.os.tag == .wasi) return error.SkipZigTest;
// windows: std.fs.File is not opened with OVERLAPPED flag.
if (builtin.os.tag == .windows) return error.SkipZigTest;
const testing = std.testing;
var tpool = main.ThreadPool.init(.{});
defer tpool.deinit();
defer tpool.shutdown();
var loop = try xev.Loop.init(.{ .thread_pool = &tpool });
defer loop.deinit();
// Create our file
const path = "test_watcher_file";
const f = try std.fs.cwd().createFile(path, .{
.read = true,
.truncate = true,
});
defer f.close();
defer std.fs.cwd().deleteFile(path) catch {};
const file = try init(f);
var write_queue: Self.WriteQueue = .{};
var write_req: [2]Self.WriteRequest = undefined;
// Perform a write and then a read
file.queueWrite(
&loop,
&write_queue,
&write_req[0],
.{ .slice = "1234" },
void,
null,
(struct {
fn callback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
_ = r catch unreachable;
return .disarm;
}
}).callback,
);
file.queueWrite(
&loop,
&write_queue,
&write_req[1],
.{ .slice = "5678" },
void,
null,
(struct {
fn callback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
_ = r catch unreachable;
return .disarm;
}
}).callback,
);
// Wait for the write
try loop.run(.until_done);
// Make sure the data is on disk
try f.sync();
const f2 = try std.fs.cwd().openFile(path, .{});
defer f2.close();
const file2 = try init(f2);
// Read
var read_buf: [128]u8 = undefined;
var read_len: usize = 0;
var c_read: xev.Completion = undefined;
file2.read(&loop, &c_read, .{ .slice = &read_buf }, usize, &read_len, (struct {
fn callback(
ud: ?*usize,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.ReadBuffer,
r: Self.ReadError!usize,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
try loop.run(.until_done);
try testing.expectEqualSlices(u8, "12345678", read_buf[0..read_len]);
}
};
}
|
0 | repos/libxev/src | repos/libxev/src/watcher/process.zig | const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const linux = std.os.linux;
const posix = std.posix;
const common = @import("common.zig");
/// Process management, such as waiting for process exit.
pub fn Process(comptime xev: type) type {
return switch (xev.backend) {
// Supported, uses pidfd
.io_uring,
.epoll,
=> ProcessPidFd(xev),
.kqueue => ProcessKqueue(xev),
.iocp => ProcessIocp(xev),
// Unsupported
.wasi_poll => struct {},
};
}
/// Process implementation using pidfd (Linux).
fn ProcessPidFd(comptime xev: type) type {
return struct {
const Self = @This();
/// The error that can come in the wait callback.
pub const WaitError = xev.Sys.PollError || error{
InvalidChild,
};
/// pidfd file descriptor
fd: posix.fd_t,
/// Create a new process watcher for the given pid.
pub fn init(pid: posix.pid_t) !Self {
// Note: SOCK_NONBLOCK == PIDFD_NONBLOCK but we should PR that
// over to Zig.
const res = linux.pidfd_open(pid, posix.SOCK.NONBLOCK);
const fd = switch (posix.errno(res)) {
.SUCCESS => @as(posix.fd_t, @intCast(res)),
.INVAL => return error.InvalidArgument,
.MFILE => return error.ProcessFdQuotaExceeded,
.NFILE => return error.SystemFdQuotaExceeded,
.NODEV => return error.SystemResources,
.NOMEM => return error.SystemResources,
else => |err| return posix.unexpectedErrno(err),
};
return .{
.fd = fd,
};
}
/// Clean up the process watcher.
pub fn deinit(self: *Self) void {
std.posix.close(self.fd);
}
/// Wait for the process to exit. This will automatically call
/// `waitpid` or equivalent and report the exit status.
pub fn wait(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: WaitError!u32,
) xev.CallbackAction,
) void {
const events: u32 = comptime switch (xev.backend) {
.io_uring => posix.POLL.IN,
.epoll => linux.EPOLL.IN,
else => unreachable,
};
c.* = .{
.op = .{
.poll = .{
.fd = self.fd,
.events = events,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const arg: WaitError!u32 = arg: {
// If our poll failed, report that error.
_ = r.poll catch |err| break :arg err;
// We need to wait on the pidfd because it is noted as ready
const fd = c_inner.op.poll.fd;
var info: linux.siginfo_t = undefined;
const res = linux.waitid(.PIDFD, fd, &info, linux.W.EXITED);
break :arg switch (posix.errno(res)) {
.SUCCESS => @as(u32, @intCast(info.fields.common.second.sigchld.status)),
.CHILD => error.InvalidChild,
// The fd isn't ready to read, I guess?
.AGAIN => return .rearm,
else => |err| err: {
std.log.warn("unexpected process wait errno={}", .{err});
break :err error.Unexpected;
},
};
};
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
arg,
});
}
}).callback,
};
loop.add(c);
}
/// Common tests
pub usingnamespace ProcessTests(xev, Self, &.{ "sh", "-c", "exit 0" }, &.{ "sh", "-c", "exit 42" });
};
}
fn ProcessKqueue(comptime xev: type) type {
return struct {
const Self = @This();
/// The error that can come in the wait callback.
pub const WaitError = xev.Sys.ProcError;
/// The pid to watch.
pid: posix.pid_t,
/// Create a new process watcher for the given pid.
pub fn init(pid: posix.pid_t) !Self {
return .{
.pid = pid,
};
}
/// Does nothing for Kqueue.
pub fn deinit(self: *Self) void {
_ = self;
}
/// Wait for the process to exit. This will automatically call
/// `waitpid` or equivalent and report the exit status.
pub fn wait(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: WaitError!u32,
) xev.CallbackAction,
) void {
c.* = .{
.op = .{
.proc = .{
.pid = self.pid,
.flags = posix.system.NOTE_EXIT | posix.system.NOTE_EXITSTATUS,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
if (r.proc) |v| v else |err| err,
});
}
}).callback,
};
loop.add(c);
}
/// Common tests
pub usingnamespace ProcessTests(xev, Self, &.{ "sh", "-c", "exit 0" }, &.{ "sh", "-c", "exit 42" });
};
}
const windows = @import("../windows.zig");
fn ProcessIocp(comptime xev: type) type {
return struct {
const Self = @This();
pub const WaitError = xev.Sys.JobObjectError;
job: windows.HANDLE,
process: windows.HANDLE,
pub fn init(process: posix.pid_t) !Self {
const current_process = windows.kernel32.GetCurrentProcess();
// Duplicate the process handle so we don't rely on the caller keeping it alive
var dup_process: windows.HANDLE = undefined;
const dup_result = windows.kernel32.DuplicateHandle(
current_process,
process,
current_process,
&dup_process,
0,
windows.FALSE,
windows.DUPLICATE_SAME_ACCESS,
);
if (dup_result == 0) return windows.unexpectedError(windows.kernel32.GetLastError());
const job = try windows.exp.CreateJobObject(null, null);
errdefer _ = windows.kernel32.CloseHandle(job);
try windows.exp.AssignProcessToJobObject(job, dup_process);
return .{
.job = job,
.process = dup_process,
};
}
pub fn deinit(self: *Self) void {
_ = windows.kernel32.CloseHandle(self.job);
_ = windows.kernel32.CloseHandle(self.process);
}
pub fn wait(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: WaitError!u32,
) xev.CallbackAction,
) void {
c.* = .{
.op = .{
.job_object = .{
.job = self.job,
.userdata = self.process,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
if (r.job_object) |result| {
switch (result) {
.associated => {
// There was a period of time between when the job object was created
// and when it was associated with the completion port. We may have
// missed a notification, so check if it's still alive.
var exit_code: windows.DWORD = undefined;
const process: windows.HANDLE = @ptrCast(c_inner.op.job_object.userdata);
const has_code = windows.kernel32.GetExitCodeProcess(process, &exit_code) != 0;
if (!has_code) std.log.warn("unable to get exit code for process={}", .{windows.kernel32.GetLastError()});
if (exit_code == windows.exp.STILL_ACTIVE) return .rearm;
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
exit_code,
});
},
.message => |message| {
const result_inner = switch (message.type) {
.JOB_OBJECT_MSG_EXIT_PROCESS,
.JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS,
=> b: {
const process: windows.HANDLE = @ptrCast(c_inner.op.job_object.userdata);
const pid = windows.exp.kernel32.GetProcessId(process);
if (pid == 0) break :b WaitError.Unexpected;
if (message.value != pid) return .rearm;
var exit_code: windows.DWORD = undefined;
const has_code = windows.kernel32.GetExitCodeProcess(process, &exit_code) != 0;
if (!has_code) std.log.warn("unable to get exit code for process={}", .{windows.kernel32.GetLastError()});
break :b if (has_code) exit_code else WaitError.Unexpected;
},
else => return .rearm,
};
return @call(.always_inline, cb, .{ common.userdataValue(Userdata, ud), l_inner, c_inner, result_inner });
},
}
} else |err| {
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
err,
});
}
}
}).callback,
};
loop.add(c);
}
/// Common tests
pub usingnamespace ProcessTests(xev, Self, &.{ "cmd.exe", "/C", "exit 0" }, &.{ "cmd.exe", "/C", "exit 42" });
};
}
fn ProcessTests(
comptime xev: type,
comptime Impl: type,
comptime argv_0: []const []const u8,
comptime argv_42: []const []const u8,
) type {
return struct {
test "process wait" {
const testing = std.testing;
const alloc = testing.allocator;
var child = std.process.Child.init(argv_0, alloc);
try child.spawn();
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var p = try Impl.init(child.id);
defer p.deinit();
// Wait
var code: ?u32 = null;
var c_wait: xev.Completion = undefined;
p.wait(&loop, &c_wait, ?u32, &code, (struct {
fn callback(
ud: ?*?u32,
_: *xev.Loop,
_: *xev.Completion,
r: Impl.WaitError!u32,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// Wait for wake
try loop.run(.until_done);
try testing.expectEqual(@as(u32, 0), code.?);
}
test "process wait with non-zero exit code" {
const testing = std.testing;
const alloc = testing.allocator;
var child = std.process.Child.init(argv_42, alloc);
try child.spawn();
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var p = try Impl.init(child.id);
defer p.deinit();
// Wait
var code: ?u32 = null;
var c_wait: xev.Completion = undefined;
p.wait(&loop, &c_wait, ?u32, &code, (struct {
fn callback(
ud: ?*?u32,
_: *xev.Loop,
_: *xev.Completion,
r: Impl.WaitError!u32,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// Wait for wake
try loop.run(.until_done);
try testing.expectEqual(@as(u32, 42), code.?);
}
test "process wait on a process that already exited" {
const testing = std.testing;
const alloc = testing.allocator;
var child = std.process.Child.init(argv_0, alloc);
try child.spawn();
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var p = try Impl.init(child.id);
defer p.deinit();
_ = try child.wait();
// Wait
var code: ?u32 = null;
var c_wait: xev.Completion = undefined;
p.wait(&loop, &c_wait, ?u32, &code, (struct {
fn callback(
ud: ?*?u32,
_: *xev.Loop,
_: *xev.Completion,
r: Impl.WaitError!u32,
) xev.CallbackAction {
ud.?.* = r catch 0;
return .disarm;
}
}).callback);
// Wait for wake
try loop.run(.until_done);
try testing.expectEqual(@as(u32, 0), code.?);
}
};
}
|
0 | repos/libxev/src | repos/libxev/src/watcher/udp.zig | const std = @import("std");
const assert = std.debug.assert;
const posix = std.posix;
const stream = @import("stream.zig");
const common = @import("common.zig");
/// UDP client and server.
///
/// This is a "higher-level abstraction" in libxev. The goal of higher-level
/// abstractions in libxev are to make it easier to use specific functionality
/// with the event loop, but does not promise perfect flexibility or optimal
/// performance. In almost all cases, the abstraction is good enough. But,
/// if you have specific needs or want to push for the most optimal performance,
/// use the platform-specific Loop directly.
pub fn UDP(comptime xev: type) type {
return switch (xev.backend) {
// Supported, uses sendmsg/recvmsg exclusively
.io_uring,
.epoll,
=> UDPSendMsg(xev),
// Supported, uses sendto/recvfrom
.kqueue => UDPSendto(xev),
// Supported with tweaks
.iocp => UDPSendtoIOCP(xev),
// Noop
.wasi_poll => struct {},
};
}
/// UDP implementation that uses sendto/recvfrom.
fn UDPSendto(comptime xev: type) type {
return struct {
const Self = @This();
fd: posix.socket_t,
/// See UDPSendMsg.State
pub const State = struct {
userdata: ?*anyopaque,
};
pub usingnamespace stream.Stream(xev, Self, .{
.close = true,
.read = .none,
.write = .none,
});
/// Initialize a new UDP with the family from the given address. Only
/// the family is used, the actual address has no impact on the created
/// resource.
pub fn init(addr: std.net.Address) !Self {
return .{
.fd = try posix.socket(
addr.any.family,
posix.SOCK.NONBLOCK | posix.SOCK.DGRAM | posix.SOCK.CLOEXEC,
0,
),
};
}
/// Initialize a UDP socket from a file descriptor.
pub fn initFd(fd: posix.socket_t) Self {
return .{
.fd = fd,
};
}
/// Bind the address to the socket.
pub fn bind(self: Self, addr: std.net.Address) !void {
try posix.setsockopt(self.fd, posix.SOL.SOCKET, posix.SO.REUSEPORT, &std.mem.toBytes(@as(c_int, 1)));
try posix.setsockopt(self.fd, posix.SOL.SOCKET, posix.SO.REUSEADDR, &std.mem.toBytes(@as(c_int, 1)));
try posix.bind(self.fd, &addr.any, addr.getOsSockLen());
}
/// Read from the socket. This performs a single read. The callback must
/// requeue the read if additional reads want to be performed. Additional
/// reads simultaneously can be queued by calling this multiple times. Note
/// that depending on the backend, the reads can happen out of order.
pub fn read(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
s: *State,
buf: xev.ReadBuffer,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: *State,
addr: std.net.Address,
s: Self,
b: xev.ReadBuffer,
r: ReadError!usize,
) xev.CallbackAction,
) void {
s.* = .{
.userdata = userdata,
};
switch (buf) {
inline .slice, .array => {
c.* = .{
.op = .{
.recvfrom = .{
.fd = self.fd,
.buffer = buf,
},
},
.userdata = s,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const s_inner = @as(?*State, @ptrCast(@alignCast(ud))).?;
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, s_inner.userdata),
l_inner,
c_inner,
s_inner,
std.net.Address.initPosix(@alignCast(&c_inner.op.recvfrom.addr)),
initFd(c_inner.op.recvfrom.fd),
c_inner.op.recvfrom.buffer,
r.recvfrom,
});
}
}).callback,
};
loop.add(c);
},
}
}
/// Write to the socket. This performs a single write. Additional writes
/// can be queued by calling this multiple times. Note that depending on the
/// backend, writes can happen out of order.
pub fn write(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
s: *State,
addr: std.net.Address,
buf: xev.WriteBuffer,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: *State,
s: Self,
b: xev.WriteBuffer,
r: WriteError!usize,
) xev.CallbackAction,
) void {
s.* = .{
.userdata = userdata,
};
switch (buf) {
inline .slice, .array => {
c.* = .{
.op = .{
.sendto = .{
.fd = self.fd,
.buffer = buf,
.addr = addr,
},
},
.userdata = s,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const s_inner = @as(?*State, @ptrCast(@alignCast(ud))).?;
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, s_inner.userdata),
l_inner,
c_inner,
s_inner,
initFd(c_inner.op.sendto.fd),
c_inner.op.sendto.buffer,
r.sendto,
});
}
}).callback,
};
loop.add(c);
},
}
}
pub const ReadError = xev.ReadError;
pub const WriteError = xev.WriteError;
/// Common tests
pub usingnamespace UDPTests(xev, Self);
};
}
/// UDP implementation that uses sendto/recvfrom.
fn UDPSendtoIOCP(comptime xev: type) type {
return struct {
const Self = @This();
const windows = std.os.windows;
fd: windows.HANDLE,
/// See UDPSendMsg.State
pub const State = struct {
userdata: ?*anyopaque,
};
pub usingnamespace stream.Stream(xev, Self, .{
.close = true,
.read = .none,
.write = .none,
});
/// Initialize a new UDP with the family from the given address. Only
/// the family is used, the actual address has no impact on the created
/// resource.
pub fn init(addr: std.net.Address) !Self {
const socket = try windows.WSASocketW(addr.any.family, posix.SOCK.DGRAM, 0, null, 0, windows.ws2_32.WSA_FLAG_OVERLAPPED);
return .{
.fd = socket,
};
}
/// Initialize a UDP socket from a file descriptor.
pub fn initFd(fd: windows.HANDLE) Self {
return .{
.fd = fd,
};
}
/// Bind the address to the socket.
pub fn bind(self: Self, addr: std.net.Address) !void {
const socket = @as(windows.ws2_32.SOCKET, @ptrCast(self.fd));
try posix.setsockopt(socket, posix.SOL.SOCKET, posix.SO.REUSEADDR, &std.mem.toBytes(@as(c_int, 1)));
try posix.bind(socket, &addr.any, addr.getOsSockLen());
}
/// Read from the socket. This performs a single read. The callback must
/// requeue the read if additional reads want to be performed. Additional
/// reads simultaneously can be queued by calling this multiple times. Note
/// that depending on the backend, the reads can happen out of order.
///
/// TODO(mitchellh): a way to receive the remote addr
pub fn read(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
s: *State,
buf: xev.ReadBuffer,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: *State,
addr: std.net.Address,
s: Self,
b: xev.ReadBuffer,
r: ReadError!usize,
) xev.CallbackAction,
) void {
s.* = .{
.userdata = userdata,
};
switch (buf) {
inline .slice, .array => {
c.* = .{
.op = .{
.recvfrom = .{
.fd = self.fd,
.buffer = buf,
},
},
.userdata = s,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const s_inner: *State = @ptrCast(@alignCast(ud.?));
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, s_inner.userdata),
l_inner,
c_inner,
s_inner,
std.net.Address.initPosix(@alignCast(&c_inner.op.recvfrom.addr)),
initFd(c_inner.op.recvfrom.fd),
c_inner.op.recvfrom.buffer,
r.recvfrom,
});
}
}).callback,
};
loop.add(c);
},
}
}
/// Write to the socket. This performs a single write. Additional writes
/// can be queued by calling this multiple times. Note that depending on the
/// backend, writes can happen out of order.
pub fn write(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
s: *State,
addr: std.net.Address,
buf: xev.WriteBuffer,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: *State,
s: Self,
b: xev.WriteBuffer,
r: WriteError!usize,
) xev.CallbackAction,
) void {
s.* = .{
.userdata = userdata,
};
switch (buf) {
inline .slice, .array => {
c.* = .{
.op = .{
.sendto = .{
.fd = self.fd,
.buffer = buf,
.addr = addr,
},
},
.userdata = s,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const s_inner: *State = @ptrCast(@alignCast(ud.?));
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, s_inner.userdata),
l_inner,
c_inner,
s_inner,
initFd(c_inner.op.sendto.fd),
c_inner.op.sendto.buffer,
r.sendto,
});
}
}).callback,
};
loop.add(c);
},
}
}
pub const ReadError = xev.ReadError;
pub const WriteError = xev.WriteError;
/// Common tests
pub usingnamespace UDPTests(xev, Self);
};
}
/// UDP implementation that uses sendmsg/recvmsg
fn UDPSendMsg(comptime xev: type) type {
return struct {
const Self = @This();
fd: posix.socket_t,
/// UDP requires some extra state to perform operations. The state is
/// opaque. This isn't part of xev.Completion because it is relatively
/// large and would force ALL operations (not just UDP) to have a relatively
/// large structure size and we didn't want to pay that cost.
pub const State = struct {
userdata: ?*anyopaque = null,
op: union {
recv: struct {
buf: xev.ReadBuffer,
addr_buffer: std.posix.sockaddr.storage = undefined,
msghdr: std.posix.msghdr,
iov: [1]std.posix.iovec,
},
send: struct {
buf: xev.WriteBuffer,
addr: std.net.Address,
msghdr: std.posix.msghdr_const,
iov: [1]std.posix.iovec_const,
},
},
};
pub usingnamespace stream.Stream(xev, Self, .{
.close = true,
.read = .none,
.write = .none,
});
/// Initialize a new UDP with the family from the given address. Only
/// the family is used, the actual address has no impact on the created
/// resource.
pub fn init(addr: std.net.Address) !Self {
// On io_uring we don't use non-blocking sockets because we may
// just get EAGAIN over and over from completions.
const flags = flags: {
var flags: u32 = posix.SOCK.DGRAM | posix.SOCK.CLOEXEC;
if (xev.backend != .io_uring) flags |= posix.SOCK.NONBLOCK;
break :flags flags;
};
return .{
.fd = try posix.socket(addr.any.family, flags, 0),
};
}
/// Initialize a UDP socket from a file descriptor.
pub fn initFd(fd: posix.socket_t) Self {
return .{
.fd = fd,
};
}
/// Bind the address to the socket.
pub fn bind(self: Self, addr: std.net.Address) !void {
try posix.setsockopt(self.fd, posix.SOL.SOCKET, posix.SO.REUSEPORT, &std.mem.toBytes(@as(c_int, 1)));
try posix.setsockopt(self.fd, posix.SOL.SOCKET, posix.SO.REUSEADDR, &std.mem.toBytes(@as(c_int, 1)));
try posix.bind(self.fd, &addr.any, addr.getOsSockLen());
}
/// Read from the socket. This performs a single read. The callback must
/// requeue the read if additional reads want to be performed. Additional
/// reads simultaneously can be queued by calling this multiple times. Note
/// that depending on the backend, the reads can happen out of order.
pub fn read(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
s: *State,
buf: xev.ReadBuffer,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: *State,
addr: std.net.Address,
s: Self,
b: xev.ReadBuffer,
r: ReadError!usize,
) xev.CallbackAction,
) void {
s.op = .{ .recv = undefined };
s.* = .{
.userdata = userdata,
.op = .{
.recv = .{
.buf = buf,
.msghdr = .{
.name = @ptrCast(&s.op.recv.addr_buffer),
.namelen = @sizeOf(@TypeOf(s.op.recv.addr_buffer)),
.iov = &s.op.recv.iov,
.iovlen = 1,
.control = null,
.controllen = 0,
.flags = 0,
},
.iov = undefined,
},
},
};
switch (s.op.recv.buf) {
.slice => |v| {
s.op.recv.iov[0] = .{
.base = v.ptr,
.len = v.len,
};
},
.array => |*arr| {
s.op.recv.iov[0] = .{
.base = arr,
.len = arr.len,
};
},
}
c.* = .{
.op = .{
.recvmsg = .{
.fd = self.fd,
.msghdr = &s.op.recv.msghdr,
},
},
.userdata = s,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const s_inner = @as(?*State, @ptrCast(@alignCast(ud))).?;
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, s_inner.userdata),
l_inner,
c_inner,
s_inner,
std.net.Address.initPosix(@ptrCast(&s_inner.op.recv.addr_buffer)),
initFd(c_inner.op.recvmsg.fd),
s_inner.op.recv.buf,
if (r.recvmsg) |v| v else |err| err,
});
}
}).callback,
};
// If we're dup-ing, then we ask the backend to manage the fd.
switch (xev.backend) {
.io_uring,
.kqueue,
.wasi_poll,
.iocp,
=> {},
.epoll => c.flags.dup = true,
}
loop.add(c);
}
/// Write to the socket. This performs a single write. Additional writes
/// can be queued by calling this multiple times. Note that depending on the
/// backend, writes can happen out of order.
pub fn write(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
s: *State,
addr: std.net.Address,
buf: xev.WriteBuffer,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: *State,
s: Self,
b: xev.WriteBuffer,
r: WriteError!usize,
) xev.CallbackAction,
) void {
// Set the active field for runtime safety
s.op = .{ .send = undefined };
s.* = .{
.userdata = userdata,
.op = .{
.send = .{
.addr = addr,
.buf = buf,
.msghdr = .{
.name = &s.op.send.addr.any,
.namelen = addr.getOsSockLen(),
.iov = &s.op.send.iov,
.iovlen = 1,
.control = null,
.controllen = 0,
.flags = 0,
},
.iov = undefined,
},
},
};
switch (s.op.send.buf) {
.slice => |v| {
s.op.send.iov[0] = .{
.base = v.ptr,
.len = v.len,
};
},
.array => |*arr| {
s.op.send.iov[0] = .{
.base = &arr.array,
.len = arr.len,
};
},
}
// On backends like epoll, you watch file descriptors for
// specific events. Our implementation doesn't merge multiple
// completions for a single fd, so we have to dup the fd. This
// means we use more fds than we could optimally. This isn't a
// problem with io_uring.
c.* = .{
.op = .{
.sendmsg = .{
.fd = self.fd,
.msghdr = &s.op.send.msghdr,
},
},
.userdata = s,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
const s_inner = @as(?*State, @ptrCast(@alignCast(ud))).?;
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, s_inner.userdata),
l_inner,
c_inner,
s_inner,
initFd(c_inner.op.sendmsg.fd),
s_inner.op.send.buf,
if (r.sendmsg) |v| v else |err| err,
});
}
}).callback,
};
// If we're dup-ing, then we ask the backend to manage the fd.
switch (xev.backend) {
.io_uring,
.kqueue,
.wasi_poll,
.iocp,
=> {},
.epoll => c.flags.dup = true,
}
loop.add(c);
}
pub const ReadError = xev.ReadError;
pub const WriteError = xev.WriteError;
/// Common tests
pub usingnamespace UDPTests(xev, Self);
};
}
fn UDPTests(comptime xev: type, comptime Impl: type) type {
return struct {
test "UDP: read/write" {
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
const address = try std.net.Address.parseIp4("127.0.0.1", 3132);
const server = try Impl.init(address);
const client = try Impl.init(address);
// Bind / Recv
try server.bind(address);
var c_read: xev.Completion = undefined;
var s_read: Impl.State = undefined;
var recv_buf: [128]u8 = undefined;
var recv_len: usize = 0;
server.read(&loop, &c_read, &s_read, .{ .slice = &recv_buf }, usize, &recv_len, (struct {
fn callback(
ud: ?*usize,
_: *xev.Loop,
_: *xev.Completion,
_: *Impl.State,
_: std.net.Address,
_: Impl,
_: xev.ReadBuffer,
r: Impl.ReadError!usize,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// Send
var send_buf = [_]u8{ 1, 1, 2, 3, 5, 8, 13 };
var c_write: xev.Completion = undefined;
var s_write: Impl.State = undefined;
client.write(&loop, &c_write, &s_write, address, .{ .slice = &send_buf }, void, null, (struct {
fn callback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
_: *Impl.State,
_: Impl,
_: xev.WriteBuffer,
r: Impl.WriteError!usize,
) xev.CallbackAction {
_ = r catch unreachable;
return .disarm;
}
}).callback);
// Wait for the send/receive
try loop.run(.until_done);
try testing.expect(recv_len > 0);
try testing.expectEqualSlices(u8, &send_buf, recv_buf[0..recv_len]);
// Close
server.close(&loop, &c_read, void, null, (struct {
fn callback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
_: Impl,
r: Impl.CloseError!void,
) xev.CallbackAction {
_ = r catch unreachable;
return .disarm;
}
}).callback);
client.close(&loop, &c_write, void, null, (struct {
fn callback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
_: Impl,
r: Impl.CloseError!void,
) xev.CallbackAction {
_ = r catch unreachable;
return .disarm;
}
}).callback);
try loop.run(.until_done);
}
};
}
|
0 | repos/libxev/src | repos/libxev/src/watcher/async.zig | /// "Wake up" an event loop from any thread using an async completion.
const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const posix = std.posix;
const common = @import("common.zig");
pub fn Async(comptime xev: type) type {
return switch (xev.backend) {
// Supported, uses eventfd
.io_uring,
.epoll,
=> AsyncEventFd(xev),
// Supported, uses the backend API
.wasi_poll => AsyncLoopState(xev, xev.Loop.threaded),
// Supported, uses mach ports
.kqueue => AsyncMachPort(xev),
.iocp => AsyncIOCP(xev),
};
}
/// Async implementation using eventfd (Linux).
fn AsyncEventFd(comptime xev: type) type {
return struct {
const Self = @This();
/// The error that can come in the wait callback.
pub const WaitError = xev.ReadError;
/// eventfd file descriptor
fd: posix.fd_t,
/// Create a new async. An async can be assigned to exactly one loop
/// to be woken up. The completion must be allocated in advance.
pub fn init() !Self {
return .{
.fd = try std.posix.eventfd(0, 0),
};
}
/// Clean up the async. This will forcibly deinitialize any resources
/// and may result in erroneous wait callbacks to be fired.
pub fn deinit(self: *Self) void {
std.posix.close(self.fd);
}
/// Wait for a message on this async. Note that async messages may be
/// coalesced (or they may not be) so you should not expect a 1:1 mapping
/// between send and wait.
///
/// Just like the rest of libxev, the wait must be re-queued if you want
/// to continue to be notified of async events.
///
/// You should NOT register an async with multiple loops (the same loop
/// is fine -- but unnecessary). The behavior when waiting on multiple
/// loops is undefined.
pub fn wait(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: WaitError!void,
) xev.CallbackAction,
) void {
c.* = .{
.op = .{
.read = .{
.fd = self.fd,
.buffer = .{ .array = undefined },
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
if (r.read) |v| assert(v > 0) else |err| err,
});
}
}).callback,
};
loop.add(c);
}
/// Notify a loop to wake up synchronously. This should never block forever
/// (it will always EVENTUALLY succeed regardless of if the loop is currently
/// ticking or not).
///
/// The "c" value is the completion associated with the "wait".
///
/// Internal details subject to change but if you're relying on these
/// details then you may want to consider using a lower level interface
/// using the loop directly:
///
/// - linux+io_uring: eventfd is used. If the eventfd write would block
/// (EAGAIN) then we assume success because the eventfd is full.
///
pub fn notify(self: Self) !void {
// We want to just write "1" in the correct byte order as our host.
const val = @as([8]u8, @bitCast(@as(u64, 1)));
_ = posix.write(self.fd, &val) catch |err| switch (err) {
error.WouldBlock => return,
else => return err,
};
}
/// Common tests
pub usingnamespace AsyncTests(xev, Self);
};
}
/// Async implementation using mach ports (Darwin).
///
/// This allocates a mach port per async request and sends to that mach
/// port to wake up the loop and trigger the completion.
fn AsyncMachPort(comptime xev: type) type {
return struct {
const Self = @This();
/// The error that can come in the wait callback.
pub const WaitError = xev.Sys.MachPortError;
/// Missing Mach APIs from Zig stdlib. Data from xnu: osfmk/mach/port.h
const mach_port_flavor_t = c_int;
const mach_port_limits = extern struct { mpl_qlimit: c_uint };
const MACH_PORT_LIMITS_INFO = 1;
extern "c" fn mach_port_set_attributes(
task: posix.system.ipc_space_t,
name: posix.system.mach_port_name_t,
flavor: mach_port_flavor_t,
info: *anyopaque,
count: posix.system.mach_msg_type_number_t,
) posix.system.kern_return_t;
extern "c" fn mach_port_destroy(
task: posix.system.ipc_space_t,
name: posix.system.mach_port_name_t,
) posix.system.kern_return_t;
/// The mach port
port: posix.system.mach_port_name_t,
/// Create a new async. An async can be assigned to exactly one loop
/// to be woken up. The completion must be allocated in advance.
pub fn init() !Self {
const mach_self = posix.system.mach_task_self();
// Allocate the port
var mach_port: posix.system.mach_port_name_t = undefined;
switch (posix.system.getKernError(posix.system.mach_port_allocate(
mach_self,
@intFromEnum(posix.system.MACH_PORT_RIGHT.RECEIVE),
&mach_port,
))) {
.SUCCESS => {}, // Success
else => return error.MachPortAllocFailed,
}
errdefer _ = mach_port_destroy(mach_self, mach_port);
// Insert a send right into the port since we also use this to send
switch (posix.system.getKernError(posix.system.mach_port_insert_right(
mach_self,
mach_port,
mach_port,
@intFromEnum(posix.system.MACH_MSG_TYPE.MAKE_SEND),
))) {
.SUCCESS => {}, // Success
else => return error.MachPortAllocFailed,
}
// Modify the port queue size to be 1 because we are only
// using it for notifications and not for any other purpose.
var limits: mach_port_limits = .{ .mpl_qlimit = 1 };
switch (posix.system.getKernError(mach_port_set_attributes(
mach_self,
mach_port,
MACH_PORT_LIMITS_INFO,
&limits,
@sizeOf(@TypeOf(limits)),
))) {
.SUCCESS => {}, // Success
else => return error.MachPortAllocFailed,
}
return .{
.port = mach_port,
};
}
/// Clean up the async. This will forcibly deinitialize any resources
/// and may result in erroneous wait callbacks to be fired.
pub fn deinit(self: *Self) void {
_ = mach_port_destroy(
posix.system.mach_task_self(),
self.port,
);
}
/// Wait for a message on this async. Note that async messages may be
/// coalesced (or they may not be) so you should not expect a 1:1 mapping
/// between send and wait.
///
/// Just like the rest of libxev, the wait must be re-queued if you want
/// to continue to be notified of async events.
///
/// You should NOT register an async with multiple loops (the same loop
/// is fine -- but unnecessary). The behavior when waiting on multiple
/// loops is undefined.
pub fn wait(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: WaitError!void,
) xev.CallbackAction,
) void {
c.* = .{
.op = .{
.machport = .{
.port = self.port,
.buffer = .{ .array = undefined },
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
// Drain the mach port so that we only fire one
// notification even if many are queued.
drain(c_inner.op.machport.port);
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
if (r.machport) |_| {} else |err| err,
});
}
}).callback,
};
loop.add(c);
}
/// Drain the given mach port. All message bodies are discarded.
fn drain(port: posix.system.mach_port_name_t) void {
var message: struct {
header: posix.system.mach_msg_header_t,
} = undefined;
while (true) {
switch (posix.system.getMachMsgError(posix.system.mach_msg(
&message.header,
posix.system.MACH_RCV_MSG | posix.system.MACH_RCV_TIMEOUT,
0,
@sizeOf(@TypeOf(message)),
port,
posix.system.MACH_MSG_TIMEOUT_NONE,
posix.system.MACH_PORT_NULL,
))) {
// This means a read would've blocked, so we drained.
.RCV_TIMED_OUT => return,
// We dequeued, so we want to loop again.
.SUCCESS => {},
// We dequeued but the message had a body. We ignore
// message bodies for async so we are happy to discard
// it and continue.
.RCV_TOO_LARGE => {},
else => |err| {
std.log.warn("mach msg drain err, may duplicate async wakeups err={}", .{err});
return;
},
}
}
}
/// Notify a loop to wake up synchronously. This should never block forever
/// (it will always EVENTUALLY succeed regardless of if the loop is currently
/// ticking or not).
pub fn notify(self: Self) !void {
// This constructs an empty mach message. It has no data.
var msg: posix.system.mach_msg_header_t = .{
// We use COPY_SEND which will not increment any send ref
// counts because it'll reuse the existing send right.
.msgh_bits = @intFromEnum(posix.system.MACH_MSG_TYPE.COPY_SEND),
.msgh_size = @sizeOf(posix.system.mach_msg_header_t),
.msgh_remote_port = self.port,
.msgh_local_port = posix.system.MACH_PORT_NULL,
.msgh_voucher_port = undefined,
.msgh_id = undefined,
};
return switch (posix.system.getMachMsgError(
posix.system.mach_msg(
&msg,
posix.system.MACH_SEND_MSG | posix.system.MACH_SEND_TIMEOUT,
msg.msgh_size,
0,
posix.system.MACH_PORT_NULL,
0, // Fail instantly if the port is full
posix.system.MACH_PORT_NULL,
),
)) {
.SUCCESS => {},
else => |e| {
std.log.warn("mach msg err={}", .{e});
return error.MachMsgFailed;
},
// This is okay because it means that there was no more buffer
// space meaning that the port will wake up.
.SEND_NO_BUFFER => {},
// This means that the send would've blocked because the
// queue is full. We assume success because the port is full.
.SEND_TIMED_OUT => {},
};
}
/// Common tests
pub usingnamespace AsyncTests(xev, Self);
};
}
/// Async implementation that is deferred to the backend implementation
/// loop state. This is kind of a hacky implementation and not recommended
/// but its the only way currently to get asyncs to work on WASI.
fn AsyncLoopState(comptime xev: type, comptime threaded: bool) type {
// TODO: we don't support threaded loop state async. We _can_ it just
// isn't done yet. To support it we need to have some sort of mutex
// to guard waiter below.
if (threaded) return struct {};
return struct {
const Self = @This();
wakeup: bool = false,
waiter: ?struct {
loop: *xev.Loop,
c: *xev.Completion,
} = null,
/// The error that can come in the wait callback.
pub const WaitError = xev.Sys.AsyncError;
pub fn init() !Self {
return .{};
}
pub fn deinit(self: *Self) void {
_ = self;
}
pub fn wait(
self: *Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: WaitError!void,
) xev.CallbackAction,
) void {
c.* = .{
.op = .{
.async_wait = .{},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
if (r.async_wait) |_| {} else |err| err,
});
}
}).callback,
};
loop.add(c);
self.waiter = .{
.loop = loop,
.c = c,
};
if (self.wakeup) self.notify() catch {};
}
pub fn notify(self: *Self) !void {
if (self.waiter) |w|
w.loop.async_notify(w.c)
else
self.wakeup = true;
}
/// Common tests
pub usingnamespace AsyncTests(xev, Self);
};
}
/// Async implementation for IOCP.
fn AsyncIOCP(comptime xev: type) type {
return struct {
const Self = @This();
const windows = std.os.windows;
pub const WaitError = xev.Sys.AsyncError;
guard: std.Thread.Mutex = .{},
wakeup: bool = false,
waiter: ?struct {
loop: *xev.Loop,
c: *xev.Completion,
} = null,
pub fn init() !Self {
return Self{};
}
pub fn deinit(self: *Self) void {
_ = self;
}
pub fn wait(
self: *Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: WaitError!void,
) xev.CallbackAction,
) void {
c.* = xev.Completion{
.op = .{ .async_wait = .{} },
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
if (r.async_wait) |_| {} else |err| err,
});
}
}).callback,
};
loop.add(c);
self.guard.lock();
defer self.guard.unlock();
self.waiter = .{
.loop = loop,
.c = c,
};
if (self.wakeup) loop.async_notify(c);
}
pub fn notify(self: *Self) !void {
self.guard.lock();
defer self.guard.unlock();
if (self.waiter) |w| {
w.loop.async_notify(w.c);
} else {
self.wakeup = true;
}
}
/// Common tests
pub usingnamespace AsyncTests(xev, Self);
};
}
fn AsyncTests(comptime xev: type, comptime Impl: type) type {
return struct {
test "async" {
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var notifier = try Impl.init();
defer notifier.deinit();
// Wait
var wake: bool = false;
var c_wait: xev.Completion = undefined;
notifier.wait(&loop, &c_wait, bool, &wake, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
r: Impl.WaitError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback);
// Send a notification
try notifier.notify();
// Wait for wake
try loop.run(.until_done);
try testing.expect(wake);
}
test "async: notify first" {
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var notifier = try Impl.init();
defer notifier.deinit();
// Send a notification
try notifier.notify();
// Wait
var wake: bool = false;
var c_wait: xev.Completion = undefined;
notifier.wait(&loop, &c_wait, bool, &wake, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
r: Impl.WaitError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback);
// Wait for wake
try loop.run(.until_done);
try testing.expect(wake);
}
test "async batches multiple notifications" {
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
var notifier = try Impl.init();
defer notifier.deinit();
// Send a notification many times
try notifier.notify();
try notifier.notify();
try notifier.notify();
try notifier.notify();
try notifier.notify();
// Wait
var count: u32 = 0;
var c_wait: xev.Completion = undefined;
notifier.wait(&loop, &c_wait, u32, &count, (struct {
fn callback(
ud: ?*u32,
_: *xev.Loop,
_: *xev.Completion,
r: Impl.WaitError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* += 1;
return .rearm;
}
}).callback);
// Send a notification
try notifier.notify();
// Wait for wake
try loop.run(.once);
for (0..10) |_| try loop.run(.no_wait);
try testing.expectEqual(@as(u32, 1), count);
}
};
}
|
0 | repos/libxev/src | repos/libxev/src/watcher/tcp.zig | const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const posix = std.posix;
const stream = @import("stream.zig");
const common = @import("common.zig");
/// TCP client and server.
///
/// This is a "higher-level abstraction" in libxev. The goal of higher-level
/// abstractions in libxev are to make it easier to use specific functionality
/// with the event loop, but does not promise perfect flexibility or optimal
/// performance. In almost all cases, the abstraction is good enough. But,
/// if you have specific needs or want to push for the most optimal performance,
/// use the platform-specific Loop directly.
pub fn TCP(comptime xev: type) type {
return struct {
const Self = @This();
const FdType = if (xev.backend == .iocp) std.os.windows.HANDLE else posix.socket_t;
fd: FdType,
pub usingnamespace stream.Stream(xev, Self, .{
.close = true,
.read = .recv,
.write = .send,
});
/// Initialize a new TCP with the family from the given address. Only
/// the family is used, the actual address has no impact on the created
/// resource.
pub fn init(addr: std.net.Address) !Self {
if (xev.backend == .wasi_poll) @compileError("unsupported in WASI");
const fd = if (xev.backend == .iocp)
try std.os.windows.WSASocketW(addr.any.family, posix.SOCK.STREAM, 0, null, 0, std.os.windows.ws2_32.WSA_FLAG_OVERLAPPED)
else fd: {
// On io_uring we don't use non-blocking sockets because we may
// just get EAGAIN over and over from completions.
const flags = flags: {
var flags: u32 = posix.SOCK.STREAM | posix.SOCK.CLOEXEC;
if (xev.backend != .io_uring) flags |= posix.SOCK.NONBLOCK;
break :flags flags;
};
break :fd try posix.socket(addr.any.family, flags, 0);
};
return .{
.fd = fd,
};
}
/// Initialize a TCP socket from a file descriptor.
pub fn initFd(fd: FdType) Self {
return .{
.fd = fd,
};
}
/// Bind the address to the socket.
pub fn bind(self: Self, addr: std.net.Address) !void {
if (xev.backend == .wasi_poll) @compileError("unsupported in WASI");
const fd = if (xev.backend == .iocp) @as(std.os.windows.ws2_32.SOCKET, @ptrCast(self.fd)) else self.fd;
try posix.setsockopt(fd, posix.SOL.SOCKET, posix.SO.REUSEADDR, &std.mem.toBytes(@as(c_int, 1)));
try posix.bind(fd, &addr.any, addr.getOsSockLen());
}
/// Listen for connections on the socket. This puts the socket into passive
/// listening mode. Connections must still be accepted one at a time.
pub fn listen(self: Self, backlog: u31) !void {
if (xev.backend == .wasi_poll) @compileError("unsupported in WASI");
const fd = if (xev.backend == .iocp) @as(std.os.windows.ws2_32.SOCKET, @ptrCast(self.fd)) else self.fd;
try posix.listen(fd, backlog);
}
/// Accept a single connection.
pub fn accept(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: AcceptError!Self,
) xev.CallbackAction,
) void {
c.* = .{
.op = .{
.accept = .{
.socket = self.fd,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
if (r.accept) |fd| initFd(fd) else |err| err,
});
}
}).callback,
};
// If we're dup-ing, then we ask the backend to manage the fd.
switch (xev.backend) {
.io_uring,
.kqueue,
.wasi_poll,
.iocp,
=> {},
.epoll => c.flags.dup = true,
}
loop.add(c);
}
/// Establish a connection as a client.
pub fn connect(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
addr: std.net.Address,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: Self,
r: ConnectError!void,
) xev.CallbackAction,
) void {
if (xev.backend == .wasi_poll) @compileError("unsupported in WASI");
c.* = .{
.op = .{
.connect = .{
.socket = self.fd,
.addr = addr,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
initFd(c_inner.op.connect.socket),
if (r.connect) |_| {} else |err| err,
});
}
}).callback,
};
loop.add(c);
}
/// Shutdown the socket. This always only shuts down the writer side. You
/// can use the lower level interface directly to control this if the
/// platform supports it.
pub fn shutdown(
self: Self,
loop: *xev.Loop,
c: *xev.Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
s: Self,
r: ShutdownError!void,
) xev.CallbackAction,
) void {
c.* = .{
.op = .{
.shutdown = .{
.socket = self.fd,
.how = .send,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
common.userdataValue(Userdata, ud),
l_inner,
c_inner,
initFd(c_inner.op.shutdown.socket),
if (r.shutdown) |_| {} else |err| err,
});
}
}).callback,
};
loop.add(c);
}
pub const AcceptError = xev.AcceptError;
pub const ConnectError = xev.ConnectError;
pub const ShutdownError = xev.ShutdownError;
test "TCP: accept/connect/send/recv/close" {
// We have no way to get a socket in WASI from a WASI context.
if (xev.backend == .wasi_poll) return error.SkipZigTest;
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
// Choose random available port (Zig #14907)
var address = try std.net.Address.parseIp4("127.0.0.1", 0);
const server = try Self.init(address);
// Bind and listen
try server.bind(address);
try server.listen(1);
// Retrieve bound port and initialize client
var sock_len = address.getOsSockLen();
const fd = if (xev.backend == .iocp) @as(std.os.windows.ws2_32.SOCKET, @ptrCast(server.fd)) else server.fd;
try posix.getsockname(fd, &address.any, &sock_len);
const client = try Self.init(address);
//const address = try std.net.Address.parseIp4("127.0.0.1", 3132);
//var server = try Self.init(address);
//var client = try Self.init(address);
// Completions we need
var c_accept: xev.Completion = undefined;
var c_connect: xev.Completion = undefined;
// Accept
var server_conn: ?Self = null;
server.accept(&loop, &c_accept, ?Self, &server_conn, (struct {
fn callback(
ud: ?*?Self,
_: *xev.Loop,
_: *xev.Completion,
r: AcceptError!Self,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// Connect
var connected: bool = false;
client.connect(&loop, &c_connect, address, bool, &connected, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
r: ConnectError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback);
// Wait for the connection to be established
try loop.run(.until_done);
try testing.expect(server_conn != null);
try testing.expect(connected);
// Close the server
var server_closed = false;
server.close(&loop, &c_accept, bool, &server_closed, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
r: Self.CloseError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback);
try loop.run(.until_done);
try testing.expect(server_closed);
// Send
var send_buf = [_]u8{ 1, 1, 2, 3, 5, 8, 13 };
client.write(&loop, &c_connect, .{ .slice = &send_buf }, void, null, (struct {
fn callback(
_: ?*void,
_: *xev.Loop,
c: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
_ = c;
_ = r catch unreachable;
return .disarm;
}
}).callback);
// Receive
var recv_buf: [128]u8 = undefined;
var recv_len: usize = 0;
server_conn.?.read(&loop, &c_accept, .{ .slice = &recv_buf }, usize, &recv_len, (struct {
fn callback(
ud: ?*usize,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.ReadBuffer,
r: Self.ReadError!usize,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// Wait for the send/receive
try loop.run(.until_done);
try testing.expectEqualSlices(u8, &send_buf, recv_buf[0..recv_len]);
// Close
server_conn.?.close(&loop, &c_accept, ?Self, &server_conn, (struct {
fn callback(
ud: ?*?Self,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
r: Self.CloseError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = null;
return .disarm;
}
}).callback);
client.close(&loop, &c_connect, bool, &connected, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
r: Self.CloseError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = false;
return .disarm;
}
}).callback);
try loop.run(.until_done);
try testing.expect(server_conn == null);
try testing.expect(!connected);
try testing.expect(server_closed);
}
// Potentially flaky - this test could hang if the sender is unable to
// write everything to the socket for whatever reason
// (e.g. incorrectly sized buffer on the receiver side), or if the
// receiver is trying to receive while sender has nothing left to send.
//
// Overview:
// 1. Set up server and client sockets
// 2. connect & accept, set SO_SNDBUF to 8kB on the client
// 3. Try to send 1MB buffer from client to server without queuing, this _should_ fail
// and theoretically send <= 8kB, but in practice, it seems to write ~32kB.
// Asserts that <= 100kB was written
// 4. Set up a queued write with the remaining buffer, shutdown() the socket afterwards
// 5. Set up a receiver that loops until it receives the entire buffer
// 6. Assert send_buf == recv_buf
test "TCP: Queued writes" {
// We have no way to get a socket in WASI from a WASI context.
if (xev.backend == .wasi_poll) return error.SkipZigTest;
// Windows doesn't seem to respect the SNDBUF socket option.
if (builtin.os.tag == .windows) return error.SkipZigTest;
const testing = std.testing;
var loop = try xev.Loop.init(.{});
defer loop.deinit();
// Choose random available port (Zig #14907)
var address = try std.net.Address.parseIp4("127.0.0.1", 0);
const server = try Self.init(address);
// Bind and listen
try server.bind(address);
try server.listen(1);
// Retrieve bound port and initialize client
var sock_len = address.getOsSockLen();
try posix.getsockname(server.fd, &address.any, &sock_len);
const client = try Self.init(address);
// Completions we need
var c_accept: xev.Completion = undefined;
var c_connect: xev.Completion = undefined;
// Accept
var server_conn: ?Self = null;
server.accept(&loop, &c_accept, ?Self, &server_conn, (struct {
fn callback(
ud: ?*?Self,
_: *xev.Loop,
_: *xev.Completion,
r: AcceptError!Self,
) xev.CallbackAction {
ud.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// Connect
var connected: bool = false;
client.connect(&loop, &c_connect, address, bool, &connected, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
r: ConnectError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback);
// Wait for the connection to be established
try loop.run(.until_done);
try testing.expect(server_conn != null);
try testing.expect(connected);
// Close the server
var server_closed = false;
server.close(&loop, &c_accept, bool, &server_closed, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
r: Self.CloseError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = true;
return .disarm;
}
}).callback);
try loop.run(.until_done);
try testing.expect(server_closed);
// Unqueued send - Limit send buffer to 8kB, this should force partial writes.
try posix.setsockopt(client.fd, posix.SOL.SOCKET, posix.SO.SNDBUF, &std.mem.toBytes(@as(c_int, 8192)));
const send_buf = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 } ** 100_000;
var sent_unqueued: usize = 0;
// First we try to send the whole 1MB buffer in one write operation, this _should_ result
// in a partial write.
client.write(&loop, &c_connect, .{ .slice = &send_buf }, usize, &sent_unqueued, (struct {
fn callback(
sent_unqueued_inner: ?*usize,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
sent_unqueued_inner.?.* = r catch unreachable;
return .disarm;
}
}).callback);
// Make sure that we sent a small fraction of the buffer
try loop.run(.until_done);
// SO_SNDBUF doesn't seem to be respected exactly, sent_unqueued will often be ~32kB
// even though SO_SNDBUF was set to 8kB
try testing.expect(sent_unqueued < (send_buf.len / 10));
// Set up queued write
var w_queue = Self.WriteQueue{};
var wr_send: xev.TCP.WriteRequest = undefined;
var sent_queued: usize = 0;
const queued_slice = send_buf[sent_unqueued..];
client.queueWrite(&loop, &w_queue, &wr_send, .{ .slice = queued_slice }, usize, &sent_queued, (struct {
fn callback(
sent_queued_inner: ?*usize,
l: *xev.Loop,
c: *xev.Completion,
tcp: Self,
_: xev.WriteBuffer,
r: Self.WriteError!usize,
) xev.CallbackAction {
sent_queued_inner.?.* = r catch unreachable;
tcp.shutdown(l, c, void, null, (struct {
fn callback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: Self.ShutdownError!void,
) xev.CallbackAction {
return .disarm;
}
}).callback);
return .disarm;
}
}).callback);
// Set up receiver which is going to keep reading until it reads the full
// send buffer
const Receiver = struct {
loop: *xev.Loop,
conn: Self,
completion: xev.Completion = .{},
buf: [send_buf.len]u8 = undefined,
bytes_read: usize = 0,
pub fn read(receiver: *@This()) void {
if (receiver.bytes_read == receiver.buf.len) return;
const read_buf = xev.ReadBuffer{
.slice = receiver.buf[receiver.bytes_read..],
};
receiver.conn.read(receiver.loop, &receiver.completion, read_buf, @This(), receiver, readCb);
}
pub fn readCb(
receiver_opt: ?*@This(),
_: *xev.Loop,
_: *xev.Completion,
_: Self,
_: xev.ReadBuffer,
r: Self.ReadError!usize,
) xev.CallbackAction {
var receiver = receiver_opt.?;
const n_bytes = r catch unreachable;
receiver.bytes_read += n_bytes;
if (receiver.bytes_read < send_buf.len) {
receiver.read();
}
return .disarm;
}
};
var receiver = Receiver{
.loop = &loop,
.conn = server_conn.?,
};
receiver.read();
// Wait for the send/receive
try loop.run(.until_done);
try testing.expectEqualSlices(u8, &send_buf, receiver.buf[0..receiver.bytes_read]);
try testing.expect(send_buf.len == sent_unqueued + sent_queued);
// Close
server_conn.?.close(&loop, &c_accept, ?Self, &server_conn, (struct {
fn callback(
ud: ?*?Self,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
r: Self.CloseError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = null;
return .disarm;
}
}).callback);
client.close(&loop, &c_connect, bool, &connected, (struct {
fn callback(
ud: ?*bool,
_: *xev.Loop,
_: *xev.Completion,
_: Self,
r: Self.CloseError!void,
) xev.CallbackAction {
_ = r catch unreachable;
ud.?.* = false;
return .disarm;
}
}).callback);
try loop.run(.until_done);
try testing.expect(server_conn == null);
try testing.expect(!connected);
try testing.expect(server_closed);
}
};
}
|
0 | repos/libxev/src | repos/libxev/src/watcher/common.zig | /// Convert the callback value with an opaque pointer into the userdata type
/// that we can pass to our higher level callback types.
pub fn userdataValue(comptime Userdata: type, v: ?*anyopaque) ?*Userdata {
// Void userdata is always a null pointer.
if (Userdata == void) return null;
return @ptrCast(@alignCast(v));
}
|
0 | repos/libxev/src | repos/libxev/src/bench/ping-udp1.zig | const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const Instant = std.time.Instant;
const xev = @import("xev");
pub const std_options: std.Options = .{
.log_level = .info,
};
pub fn main() !void {
try run(1);
}
pub fn run(comptime count: comptime_int) !void {
var thread_pool = xev.ThreadPool.init(.{});
defer thread_pool.deinit();
defer thread_pool.shutdown();
var loop = try xev.Loop.init(.{
.entries = std.math.pow(u13, 2, 12),
.thread_pool = &thread_pool,
});
defer loop.deinit();
const addr = try std.net.Address.parseIp4("127.0.0.1", 3131);
var pingers: [count]Pinger = undefined;
for (&pingers) |*p| {
p.* = try Pinger.init(addr);
try p.start(&loop);
}
const start_time = try Instant.now();
try loop.run(.until_done);
const end_time = try Instant.now();
const total: usize = total: {
var total: usize = 0;
for (&pingers) |p| total += p.pongs;
break :total total;
};
const elapsed = @as(f64, @floatFromInt(end_time.since(start_time)));
std.log.info("ping_pongs: {d} pingers, ~{d:.0} roundtrips/s", .{
count,
@as(f64, @floatFromInt(total)) / (elapsed / 1e9),
});
}
const Pinger = struct {
udp: xev.UDP,
addr: std.net.Address,
state: usize = 0,
pongs: u64 = 0,
read_buf: [1024]u8 = undefined,
c_read: xev.Completion = undefined,
c_write: xev.Completion = undefined,
state_read: xev.UDP.State = undefined,
state_write: xev.UDP.State = undefined,
op_count: u8 = 0,
pub const PING = "PING\n";
pub fn init(addr: std.net.Address) !Pinger {
return .{
.udp = try xev.UDP.init(addr),
.state = 0,
.pongs = 0,
.addr = addr,
};
}
pub fn start(self: *Pinger, loop: *xev.Loop) !void {
try self.udp.bind(self.addr);
self.udp.read(
loop,
&self.c_read,
&self.state_read,
.{ .slice = &self.read_buf },
Pinger,
self,
Pinger.readCallback,
);
self.write(loop);
}
pub fn write(self: *Pinger, loop: *xev.Loop) void {
self.udp.write(
loop,
&self.c_write,
&self.state_write,
self.addr,
.{ .slice = PING[0..PING.len] },
Pinger,
self,
writeCallback,
);
}
pub fn readCallback(
self_: ?*Pinger,
loop: *xev.Loop,
c: *xev.Completion,
_: *xev.UDP.State,
_: std.net.Address,
socket: xev.UDP,
buf: xev.ReadBuffer,
r: xev.UDP.ReadError!usize,
) xev.CallbackAction {
_ = c;
_ = socket;
const self = self_.?;
const n = r catch unreachable;
const data = buf.slice[0..n];
var i: usize = 0;
while (i < n) : (i += 1) {
assert(data[i] == PING[self.state]);
self.state = (self.state + 1) % (PING.len);
if (self.state == 0) {
self.pongs += 1;
// If we're done then exit
if (self.pongs > 500_000) {
self.udp.close(loop, &self.c_read, Pinger, self, closeCallback);
return .disarm;
}
self.op_count += 1;
if (self.op_count == 2) {
self.op_count = 0;
// Send another ping
self.write(loop);
}
}
}
return .rearm;
}
pub fn writeCallback(
self_: ?*Pinger,
loop: *xev.Loop,
_: *xev.Completion,
_: *xev.UDP.State,
_: xev.UDP,
_: xev.WriteBuffer,
r: xev.UDP.WriteError!usize,
) xev.CallbackAction {
const self = self_.?;
self.op_count += 1;
if (self.op_count == 2) {
self.op_count = 0;
// Send another ping
self.write(loop);
}
_ = r catch unreachable;
return .disarm;
}
pub fn closeCallback(
_: ?*Pinger,
_: *xev.Loop,
_: *xev.Completion,
_: xev.UDP,
r: xev.UDP.CloseError!void,
) xev.CallbackAction {
_ = r catch unreachable;
return .disarm;
}
};
|
0 | repos/libxev/src | repos/libxev/src/bench/async8.zig | const std = @import("std");
const run = @import("async1.zig").run;
pub const std_options: std.Options = .{
.log_level = .info,
};
pub fn main() !void {
try run(8);
}
|
0 | repos/libxev/src | repos/libxev/src/bench/udp_pummel_1v1.zig | const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const Instant = std.time.Instant;
const xev = @import("xev");
const EXPECTED = "RANG TANG DING DONG I AM THE JAPANESE SANDMAN";
/// This is a global var decremented for the test without any locks. That's
/// how the original is written and that's how we're going to do it.
var packet_counter: usize = 1e6;
var send_cb_called: usize = 0;
var recv_cb_called: usize = 0;
pub const std_options: std.Options = .{
.log_level = .info,
};
pub fn main() !void {
try run(1, 1);
}
pub fn run(comptime n_senders: comptime_int, comptime n_receivers: comptime_int) !void {
const base_port = 12345;
var thread_pool = xev.ThreadPool.init(.{});
defer thread_pool.deinit();
defer thread_pool.shutdown();
var loop = try xev.Loop.init(.{
.entries = std.math.pow(u13, 2, 12),
.thread_pool = &thread_pool,
});
defer loop.deinit();
var receivers: [n_receivers]Receiver = undefined;
for (&receivers, 0..) |*r, i| {
const addr = try std.net.Address.parseIp4("127.0.0.1", @as(u16, @intCast(base_port + i)));
r.* = .{ .udp = try xev.UDP.init(addr) };
try r.udp.bind(addr);
r.udp.read(
&loop,
&r.c_recv,
&r.udp_state,
.{ .slice = &r.recv_buf },
Receiver,
r,
Receiver.readCallback,
);
}
var senders: [n_senders]Sender = undefined;
for (&senders, 0..) |*s, i| {
const addr = try std.net.Address.parseIp4(
"127.0.0.1",
@as(u16, @intCast(base_port + (i % n_receivers))),
);
s.* = .{ .udp = try xev.UDP.init(addr) };
s.udp.write(
&loop,
&s.c_send,
&s.udp_state,
addr,
.{ .slice = EXPECTED },
Sender,
s,
Sender.writeCallback,
);
}
const start_time = try Instant.now();
try loop.run(.until_done);
const end_time = try Instant.now();
const elapsed = @as(f64, @floatFromInt(end_time.since(start_time)));
std.log.info("udp_pummel_{d}v{d}: {d:.0}f/s received, {d:.0}f/s sent, {d} received, {d} sent in {d:.1} seconds", .{
n_senders,
n_receivers,
@as(f64, @floatFromInt(recv_cb_called)) / (elapsed / std.time.ns_per_s),
@as(f64, @floatFromInt(send_cb_called)) / (elapsed / std.time.ns_per_s),
recv_cb_called,
send_cb_called,
elapsed / std.time.ns_per_s,
});
}
const Sender = struct {
udp: xev.UDP,
udp_state: xev.UDP.State = undefined,
c_send: xev.Completion = undefined,
fn writeCallback(
_: ?*Sender,
l: *xev.Loop,
_: *xev.Completion,
_: *xev.UDP.State,
_: xev.UDP,
_: xev.WriteBuffer,
r: xev.UDP.WriteError!usize,
) xev.CallbackAction {
_ = r catch unreachable;
if (packet_counter == 0) {
l.stop();
return .disarm;
}
packet_counter -|= 1;
send_cb_called += 1;
return .rearm;
}
};
const Receiver = struct {
udp: xev.UDP,
udp_state: xev.UDP.State = undefined,
c_recv: xev.Completion = undefined,
recv_buf: [65536]u8 = undefined,
fn readCallback(
_: ?*Receiver,
_: *xev.Loop,
_: *xev.Completion,
_: *xev.UDP.State,
_: std.net.Address,
_: xev.UDP,
b: xev.ReadBuffer,
r: xev.UDP.ReadError!usize,
) xev.CallbackAction {
const n = r catch |err| {
switch (err) {
error.EOF => {},
else => std.log.warn("err={}", .{err}),
}
return .disarm;
};
if (!std.mem.eql(u8, b.slice[0..n], EXPECTED)) {
@panic("Unexpected data.");
}
recv_cb_called += 1;
return .rearm;
}
};
|
0 | repos/libxev/src | repos/libxev/src/bench/million-timers.zig | const std = @import("std");
const Instant = std.time.Instant;
const xev = @import("xev");
pub const NUM_TIMERS: usize = 10 * 1000 * 1000;
pub fn main() !void {
var thread_pool = xev.ThreadPool.init(.{});
defer thread_pool.deinit();
defer thread_pool.shutdown();
var loop = try xev.Loop.init(.{
.entries = std.math.pow(u13, 2, 12),
.thread_pool = &thread_pool,
});
defer loop.deinit();
const GPA = std.heap.GeneralPurposeAllocator(.{});
var gpa: GPA = .{};
defer _ = gpa.deinit();
const alloc = gpa.allocator();
var cs = try alloc.alloc(xev.Completion, NUM_TIMERS);
defer alloc.free(cs);
const before_all = try Instant.now();
var i: usize = 0;
var timeout: u64 = 1;
while (i < NUM_TIMERS) : (i += 1) {
if (i % 1000 == 0) timeout += 1;
const timer = try xev.Timer.init();
timer.run(&loop, &cs[i], timeout, void, null, timerCallback);
}
const before_run = try Instant.now();
try loop.run(.until_done);
const after_run = try Instant.now();
const after_all = try Instant.now();
std.log.info("{d:.2} seconds total", .{@as(f64, @floatFromInt(after_all.since(before_all))) / 1e9});
std.log.info("{d:.2} seconds init", .{@as(f64, @floatFromInt(before_run.since(before_all))) / 1e9});
std.log.info("{d:.2} seconds dispatch", .{@as(f64, @floatFromInt(after_run.since(before_run))) / 1e9});
std.log.info("{d:.2} seconds cleanup", .{@as(f64, @floatFromInt(after_all.since(after_run))) / 1e9});
}
pub const std_options: std.Options = .{
.log_level = .info,
};
var timer_callback_count: usize = 0;
fn timerCallback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
result: xev.Timer.RunError!void,
) xev.CallbackAction {
_ = result catch unreachable;
timer_callback_count += 1;
return .disarm;
}
|
0 | repos/libxev/src | repos/libxev/src/bench/async2.zig | const std = @import("std");
const run = @import("async1.zig").run;
pub const std_options: std.Options = .{
.log_level = .info,
};
pub fn main() !void {
try run(2);
}
|
0 | repos/libxev/src | repos/libxev/src/bench/async4.zig | const std = @import("std");
const run = @import("async1.zig").run;
pub const std_options: std.Options = .{
.log_level = .info,
};
pub fn main() !void {
try run(4);
}
|
0 | repos/libxev/src | repos/libxev/src/bench/async_pummel_4.zig | const std = @import("std");
const run = @import("async_pummel_1.zig").run;
pub const std_options: std.Options = .{
.log_level = .info,
};
pub fn main() !void {
try run(4);
}
|
0 | repos/libxev/src | repos/libxev/src/bench/async_pummel_8.zig | const std = @import("std");
const run = @import("async_pummel_1.zig").run;
pub const std_options: std.Options = .{
.log_level = .info,
};
pub fn main() !void {
try run(8);
}
|
0 | repos/libxev/src | repos/libxev/src/bench/async1.zig | const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const Instant = std.time.Instant;
const xev = @import("xev");
pub const std_options: std.Options = .{
.log_level = .info,
};
// Tune-ables
pub const NUM_PINGS = 1000 * 1000;
pub fn main() !void {
try run(1);
}
pub fn run(comptime thread_count: comptime_int) !void {
var loop = try xev.Loop.init(.{});
defer loop.deinit();
// Initialize all our threads
var contexts: [thread_count]Thread = undefined;
var threads: [contexts.len]std.Thread = undefined;
var comps: [contexts.len]xev.Completion = undefined;
for (&contexts, 0..) |*ctx, i| {
ctx.* = try Thread.init();
ctx.main_async.wait(&loop, &comps[i], Thread, ctx, mainAsyncCallback);
threads[i] = try std.Thread.spawn(.{}, Thread.threadMain, .{ctx});
}
const start_time = try Instant.now();
try loop.run(.until_done);
for (&threads) |thr| thr.join();
const end_time = try Instant.now();
const elapsed = @as(f64, @floatFromInt(end_time.since(start_time)));
std.log.info("async{d}: {d:.2} seconds ({d:.2}/sec)", .{
thread_count,
elapsed / 1e9,
NUM_PINGS / (elapsed / 1e9),
});
}
fn mainAsyncCallback(
ud: ?*Thread,
_: *xev.Loop,
_: *xev.Completion,
r: xev.Async.WaitError!void,
) xev.CallbackAction {
_ = r catch unreachable;
const self = ud.?;
self.worker_async.notify() catch unreachable;
self.main_sent += 1;
self.main_seen += 1;
return if (self.main_sent >= NUM_PINGS) .disarm else .rearm;
}
/// The thread state
const Thread = struct {
loop: xev.Loop,
worker_async: xev.Async,
main_async: xev.Async,
worker_sent: usize = 0,
worker_seen: usize = 0,
main_sent: usize = 0,
main_seen: usize = 0,
pub fn init() !Thread {
return .{
.loop = try xev.Loop.init(.{}),
.worker_async = try xev.Async.init(),
.main_async = try xev.Async.init(),
};
}
pub fn threadMain(self: *Thread) !void {
// Kick us off
try self.main_async.notify();
// Start our waiter
var c: xev.Completion = undefined;
self.worker_async.wait(&self.loop, &c, Thread, self, asyncCallback);
// Run
try self.loop.run(.until_done);
if (self.worker_sent < NUM_PINGS) @panic("FAIL");
}
fn asyncCallback(
ud: ?*Thread,
_: *xev.Loop,
_: *xev.Completion,
r: xev.Async.WaitError!void,
) xev.CallbackAction {
_ = r catch unreachable;
const self = ud.?;
self.main_async.notify() catch unreachable;
self.worker_sent += 1;
self.worker_seen += 1;
return if (self.worker_sent >= NUM_PINGS) .disarm else .rearm;
}
};
|
0 | repos/libxev/src | repos/libxev/src/bench/ping-pongs.zig | const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const Instant = std.time.Instant;
const xev = @import("xev");
pub const std_options: std.Options = .{
.log_level = .info,
};
pub fn main() !void {
var thread_pool = xev.ThreadPool.init(.{});
defer thread_pool.deinit();
defer thread_pool.shutdown();
var loop = try xev.Loop.init(.{
.entries = std.math.pow(u13, 2, 12),
.thread_pool = &thread_pool,
});
defer loop.deinit();
const GPA = std.heap.GeneralPurposeAllocator(.{});
var gpa: GPA = .{};
defer _ = gpa.deinit();
const alloc = gpa.allocator();
var server_loop = try xev.Loop.init(.{
.entries = std.math.pow(u13, 2, 12),
.thread_pool = &thread_pool,
});
defer server_loop.deinit();
var server = try Server.init(alloc, &server_loop);
defer server.deinit();
try server.start();
// Start our echo server
const server_thr = try std.Thread.spawn(.{}, Server.threadMain, .{&server});
// Start our client
var client_loop = try xev.Loop.init(.{
.entries = std.math.pow(u13, 2, 12),
.thread_pool = &thread_pool,
});
defer client_loop.deinit();
var client = try Client.init(alloc, &client_loop);
defer client.deinit();
try client.start();
const start_time = try Instant.now();
try client_loop.run(.until_done);
server_thr.join();
const end_time = try Instant.now();
const elapsed = @as(f64, @floatFromInt(end_time.since(start_time)));
std.log.info("{d:.2} roundtrips/s", .{@as(f64, @floatFromInt(client.pongs)) / (elapsed / 1e9)});
std.log.info("{d:.2} seconds total", .{elapsed / 1e9});
}
/// Memory pools for things that need stable pointers
const BufferPool = std.heap.MemoryPool([4096]u8);
const CompletionPool = std.heap.MemoryPool(xev.Completion);
const TCPPool = std.heap.MemoryPool(xev.TCP);
/// The client state
const Client = struct {
loop: *xev.Loop,
completion_pool: CompletionPool,
read_buf: [1024]u8,
pongs: u64,
state: usize = 0,
stop: bool = false,
pub const PING = "PING\n";
pub fn init(alloc: Allocator, loop: *xev.Loop) !Client {
return .{
.loop = loop,
.completion_pool = CompletionPool.init(alloc),
.read_buf = undefined,
.pongs = 0,
.state = 0,
.stop = false,
};
}
pub fn deinit(self: *Client) void {
self.completion_pool.deinit();
}
/// Must be called with stable self pointer.
pub fn start(self: *Client) !void {
const addr = try std.net.Address.parseIp4("127.0.0.1", 3131);
const socket = try xev.TCP.init(addr);
const c = try self.completion_pool.create();
socket.connect(self.loop, c, addr, Client, self, connectCallback);
}
fn connectCallback(
self_: ?*Client,
l: *xev.Loop,
c: *xev.Completion,
socket: xev.TCP,
r: xev.TCP.ConnectError!void,
) xev.CallbackAction {
_ = r catch unreachable;
const self = self_.?;
// Send message
socket.write(l, c, .{ .slice = PING[0..PING.len] }, Client, self, writeCallback);
// Read
const c_read = self.completion_pool.create() catch unreachable;
socket.read(l, c_read, .{ .slice = &self.read_buf }, Client, self, readCallback);
return .disarm;
}
fn writeCallback(
self_: ?*Client,
l: *xev.Loop,
c: *xev.Completion,
s: xev.TCP,
b: xev.WriteBuffer,
r: xev.TCP.WriteError!usize,
) xev.CallbackAction {
_ = r catch unreachable;
_ = l;
_ = s;
_ = b;
// Put back the completion.
self_.?.completion_pool.destroy(c);
return .disarm;
}
fn readCallback(
self_: ?*Client,
l: *xev.Loop,
c: *xev.Completion,
socket: xev.TCP,
buf: xev.ReadBuffer,
r: xev.TCP.ReadError!usize,
) xev.CallbackAction {
const self = self_.?;
const n = r catch unreachable;
const data = buf.slice[0..n];
// Count the number of pings in our message
var i: usize = 0;
while (i < n) : (i += 1) {
assert(data[i] == PING[self.state]);
self.state = (self.state + 1) % (PING.len);
if (self.state == 0) {
self.pongs += 1;
// If we're done then exit
if (self.pongs > 500_000) {
socket.shutdown(l, c, Client, self, shutdownCallback);
return .disarm;
}
// Send another ping
const c_ping = self.completion_pool.create() catch unreachable;
socket.write(l, c_ping, .{ .slice = PING[0..PING.len] }, Client, self, writeCallback);
}
}
// Read again
return .rearm;
}
fn shutdownCallback(
self_: ?*Client,
l: *xev.Loop,
c: *xev.Completion,
socket: xev.TCP,
r: xev.TCP.ShutdownError!void,
) xev.CallbackAction {
_ = r catch {};
const self = self_.?;
socket.close(l, c, Client, self, closeCallback);
return .disarm;
}
fn closeCallback(
self_: ?*Client,
l: *xev.Loop,
c: *xev.Completion,
socket: xev.TCP,
r: xev.TCP.CloseError!void,
) xev.CallbackAction {
_ = l;
_ = socket;
_ = r catch unreachable;
const self = self_.?;
self.stop = true;
self.completion_pool.destroy(c);
return .disarm;
}
};
/// The server state
const Server = struct {
loop: *xev.Loop,
buffer_pool: BufferPool,
completion_pool: CompletionPool,
socket_pool: TCPPool,
stop: bool,
pub fn init(alloc: Allocator, loop: *xev.Loop) !Server {
return .{
.loop = loop,
.buffer_pool = BufferPool.init(alloc),
.completion_pool = CompletionPool.init(alloc),
.socket_pool = TCPPool.init(alloc),
.stop = false,
};
}
pub fn deinit(self: *Server) void {
self.buffer_pool.deinit();
self.completion_pool.deinit();
self.socket_pool.deinit();
}
/// Must be called with stable self pointer.
pub fn start(self: *Server) !void {
const addr = try std.net.Address.parseIp4("127.0.0.1", 3131);
var socket = try xev.TCP.init(addr);
const c = try self.completion_pool.create();
try socket.bind(addr);
try socket.listen(std.os.linux.SOMAXCONN);
socket.accept(self.loop, c, Server, self, acceptCallback);
}
pub fn threadMain(self: *Server) !void {
try self.loop.run(.until_done);
}
fn destroyBuf(self: *Server, buf: []const u8) void {
self.buffer_pool.destroy(
@alignCast(
@as(*[4096]u8, @ptrFromInt(@intFromPtr(buf.ptr))),
),
);
}
fn acceptCallback(
self_: ?*Server,
l: *xev.Loop,
c: *xev.Completion,
r: xev.TCP.AcceptError!xev.TCP,
) xev.CallbackAction {
const self = self_.?;
// Create our socket
const socket = self.socket_pool.create() catch unreachable;
socket.* = r catch unreachable;
// Start reading -- we can reuse c here because its done.
const buf = self.buffer_pool.create() catch unreachable;
socket.read(l, c, .{ .slice = buf }, Server, self, readCallback);
return .disarm;
}
fn readCallback(
self_: ?*Server,
loop: *xev.Loop,
c: *xev.Completion,
socket: xev.TCP,
buf: xev.ReadBuffer,
r: xev.TCP.ReadError!usize,
) xev.CallbackAction {
const self = self_.?;
const n = r catch |err| switch (err) {
error.EOF => {
self.destroyBuf(buf.slice);
socket.shutdown(loop, c, Server, self, shutdownCallback);
return .disarm;
},
else => {
self.destroyBuf(buf.slice);
self.completion_pool.destroy(c);
std.log.warn("server read unexpected err={}", .{err});
return .disarm;
},
};
// Echo it back
const c_echo = self.completion_pool.create() catch unreachable;
const buf_write = self.buffer_pool.create() catch unreachable;
@memcpy(buf_write, buf.slice[0..n]);
socket.write(loop, c_echo, .{ .slice = buf_write[0..n] }, Server, self, writeCallback);
// Read again
return .rearm;
}
fn writeCallback(
self_: ?*Server,
l: *xev.Loop,
c: *xev.Completion,
s: xev.TCP,
buf: xev.WriteBuffer,
r: xev.TCP.WriteError!usize,
) xev.CallbackAction {
_ = l;
_ = s;
_ = r catch unreachable;
// We do nothing for write, just put back objects into the pool.
const self = self_.?;
self.completion_pool.destroy(c);
self.buffer_pool.destroy(
@alignCast(
@as(*[4096]u8, @ptrFromInt(@intFromPtr(buf.slice.ptr))),
),
);
return .disarm;
}
fn shutdownCallback(
self_: ?*Server,
l: *xev.Loop,
c: *xev.Completion,
s: xev.TCP,
r: xev.TCP.ShutdownError!void,
) xev.CallbackAction {
_ = r catch {};
const self = self_.?;
s.close(l, c, Server, self, closeCallback);
return .disarm;
}
fn closeCallback(
self_: ?*Server,
l: *xev.Loop,
c: *xev.Completion,
socket: xev.TCP,
r: xev.TCP.CloseError!void,
) xev.CallbackAction {
_ = l;
_ = r catch unreachable;
_ = socket;
const self = self_.?;
self.stop = true;
self.completion_pool.destroy(c);
return .disarm;
}
};
|
0 | repos/libxev/src | repos/libxev/src/bench/async_pummel_1.zig | const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const Instant = std.time.Instant;
const xev = @import("xev");
pub const std_options: std.Options = .{
.log_level = .info,
};
// Tune-ables
pub const NUM_PINGS = 1000 * 1000;
pub fn main() !void {
try run(1);
}
pub fn run(comptime thread_count: comptime_int) !void {
var thread_pool = xev.ThreadPool.init(.{});
defer thread_pool.deinit();
defer thread_pool.shutdown();
var loop = try xev.Loop.init(.{
.entries = std.math.pow(u13, 2, 12),
.thread_pool = &thread_pool,
});
defer loop.deinit();
// Create our async
notifier = try xev.Async.init();
defer notifier.deinit();
const userdata: ?*void = null;
var c: xev.Completion = undefined;
notifier.wait(&loop, &c, void, userdata, &asyncCallback);
// Initialize all our threads
var threads: [thread_count]std.Thread = undefined;
for (&threads) |*thr| {
thr.* = try std.Thread.spawn(.{}, threadMain, .{});
}
const start_time = try Instant.now();
try loop.run(.until_done);
for (&threads) |thr| thr.join();
const end_time = try Instant.now();
const elapsed = @as(f64, @floatFromInt(end_time.since(start_time)));
std.log.info("async_pummel_{d}: {d} callbacks in {d:.2} seconds ({d:.2}/sec)", .{
thread_count,
callbacks,
elapsed / 1e9,
@as(f64, @floatFromInt(callbacks)) / (elapsed / 1e9),
});
}
var callbacks: usize = 0;
var notifier: xev.Async = undefined;
var state: enum { running, stop, stopped } = .running;
fn asyncCallback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
r: xev.Async.WaitError!void,
) xev.CallbackAction {
_ = r catch unreachable;
callbacks += 1;
if (callbacks < NUM_PINGS) return .rearm;
// We're done
state = .stop;
while (state != .stopped) std.time.sleep(0);
return .disarm;
}
fn threadMain() !void {
while (state == .running) try notifier.notify();
state = .stopped;
}
|
0 | repos/libxev/src | repos/libxev/src/bench/async_pummel_2.zig | const std = @import("std");
const run = @import("async_pummel_1.zig").run;
pub const std_options: std.Options = .{
.log_level = .info,
};
pub fn main() !void {
try run(2);
}
|
0 | repos/libxev/src | repos/libxev/src/backend/wasi_poll.zig | const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const wasi = std.os.wasi;
const posix = std.posix;
const queue = @import("../queue.zig");
const heap = @import("../heap.zig");
const xev = @import("../main.zig").WasiPoll;
pub const Loop = struct {
pub const threaded = std.Target.wasm.featureSetHas(builtin.cpu.features, .atomics);
const TimerHeap = heap.Intrusive(Timer, void, Timer.less);
const WakeupType = if (threaded) std.atomic.Atomic(bool) else bool;
const wakeup_init = if (threaded) .{ .value = false } else false;
/// The number of active completions. This DOES NOT include completions that
/// are queued in the submissions queue.
active: usize = 0,
/// Our queue of submissions that we want to enqueue on the next tick.
submissions: queue.Intrusive(Completion) = .{},
/// Our list of async waiters.
asyncs: queue.Intrusive(Completion) = .{},
/// Batch of subscriptions to send to poll.
batch: Batch = .{},
/// Heap of timers.
timers: TimerHeap = .{ .context = {} },
/// The wakeup signal variable for Async. If we have Wasm threads
/// enabled then we use an atomic for this, otherwise we just use a plain
/// bool because we know we're single threaded.
wakeup: WakeupType = wakeup_init,
/// Cached time
cached_now: wasi.timestamp_t,
/// Some internal fields we can pack for better space.
flags: packed struct {
/// Whether we're in a run or not (to prevent nested runs).
in_run: bool = false,
/// Whether our loop is in a stopped state or not.
stopped: bool = false,
} = .{},
pub fn init(options: xev.Options) !Loop {
_ = options;
return .{ .cached_now = try get_now() };
}
pub fn deinit(self: *Loop) void {
_ = self;
}
/// Run the event loop. See RunMode documentation for details on modes.
pub fn run(self: *Loop, mode: xev.RunMode) !void {
switch (mode) {
.no_wait => try self.tick(0),
.once => try self.tick(1),
.until_done => while (!self.done()) try self.tick(1),
}
}
/// Stop the loop. This can only be called from the main thread.
/// This will stop the loop forever. Future ticks will do nothing.
///
/// This does NOT stop any completions that are queued to be executed
/// in the thread pool. If you are using a thread pool, completions
/// are not safe to recover until the thread pool is shut down. If
/// you're not using a thread pool, all completions are safe to
/// read/write once any outstanding `run` or `tick` calls are returned.
pub fn stop(self: *Loop) void {
self.flags.stopped = true;
}
/// Add a completion to the loop. This doesn't DO anything except queue
/// the completion. Any configuration errors will be exposed via the
/// callback on the next loop tick.
pub fn add(self: *Loop, c: *Completion) void {
c.flags.state = .adding;
self.submissions.push(c);
}
fn done(self: *Loop) bool {
return self.flags.stopped or (self.active == 0 and
self.submissions.empty());
}
/// Wake up the event loop and force a tick. This only works if there
/// is a corresponding async_wait completion _already registered_ with
/// the event loop. If there isn't already a completion, it will still
/// work, but the async_wait will be triggered on the next loop tick
/// it is added, and the loop won't wake up until then. This is usually
/// pointless since completions can only be added from the main thread.
///
/// The completion c doesn't yet have to be registered as a waiter, but
///
///
/// This function can be called from any thread.
pub fn async_notify(self: *Loop, c: *Completion) void {
assert(c.op == .async_wait);
if (threaded) {
self.wakeup.store(true, .SeqCst);
c.op.async_wait.wakeup.store(true, .SeqCst);
} else {
self.wakeup = true;
c.op.async_wait.wakeup = true;
}
}
/// Tick through the event loop once, waiting for at least "wait" completions
/// to be processed by the loop itself.
pub fn tick(self: *Loop, wait: u32) !void {
// If we're stopped then the loop is fully over.
if (self.flags.stopped) return;
// We can't nest runs.
if (self.flags.in_run) return error.NestedRunsNotAllowed;
self.flags.in_run = true;
defer self.flags.in_run = false;
// Submit all the submissions. We copy the submission queue so that
// any resubmits don't cause an infinite loop.
var queued = self.submissions;
self.submissions = .{};
while (queued.pop()) |c| {
// We ignore any completions that aren't in the adding state.
// This usually means that we switched them to be deleted or
// something.
if (c.flags.state != .adding) continue;
self.start(c);
}
// Wait and process events. We only do this if we have any active.
var wait_rem = @as(usize, @intCast(wait));
while (true) {
// If we're stopped then the loop is fully over.
if (self.flags.stopped) return;
// We must always update the loop time even if we have no
// active completions.
self.update_now();
if (!(self.active > 0 and (wait == 0 or wait_rem > 0))) break;
// Run our expired timers
const now_timer: Timer = .{ .next = self.cached_now };
while (self.timers.peek()) |t| {
if (!Timer.less({}, t, &now_timer)) break;
// Remove the timer
assert(self.timers.deleteMin().? == t);
// Completion is now dead because it has been processed.
// Users can reuse it (unless they specify rearm in
// which case we readd it).
const c = t.c;
c.flags.state = .dead;
self.active -= 1;
// Lower our remaining count
wait_rem -|= 1;
// Invoke
const action = c.callback(c.userdata, self, c, .{
.timer = .expiration,
});
switch (action) {
.disarm => {},
.rearm => self.start(c),
}
}
// Run our async waiters
if (!self.asyncs.empty()) {
const wakeup = if (threaded) self.wakeup.load(.SeqCst) else self.wakeup;
if (wakeup) {
// Reset to false, we've "woken up" now.
if (threaded)
self.wakeup.store(false, .SeqCst)
else
self.wakeup = false;
// There is at least one pending async. This isn't efficient
// AT ALL. We should improve this in the short term by
// using a queue here of asyncs we know should wake up
// (we know because we have access to it in async_notify).
// I didn't do that right away because we need a Wasm
// compatibile std.Thread.Mutex.
var asyncs = self.asyncs;
self.asyncs = .{};
while (asyncs.pop()) |c| {
const c_wakeup = if (threaded)
c.op.async_wait.wakeup.load(.SeqCst)
else
c.op.async_wait.wakeup;
// If we aren't waking this one up, requeue
if (!c_wakeup) {
self.asyncs.push(c);
continue;
}
// We are waking up, mark this as dead and call it.
c.flags.state = .dead;
self.active -= 1;
// Lower our waiters
wait_rem -|= 1;
const action = c.callback(c.userdata, self, c, .{ .async_wait = {} });
switch (action) {
// We disarm by default
.disarm => {},
// Rearm we just restart it. We use start instead of
// add because then it'll become immediately available
// if we loop again.
.rearm => self.start(c),
}
}
}
}
// Setup our timeout. If we have nothing to wait for then
// we just set an expiring timer so that we still poll but it
// will return ASAP.
const timeout: wasi.timestamp_t = if (wait_rem == 0) self.cached_now else timeout: {
// If we have a timer use that value, otherwise we can afford
// to sleep for awhile since we're waiting for something to
// happen. We set this sleep to 60 seconds arbitrarily. On
// other backends we wait indefinitely.
const t: *const Timer = self.timers.peek() orelse
break :timeout self.cached_now + (60 * std.time.ns_per_s);
break :timeout t.next;
};
self.batch.array[0] = .{
.userdata = 0,
.u = .{
.tag = wasi.EVENTTYPE_CLOCK,
.u = .{
.clock = .{
.id = @as(u32, @bitCast(posix.CLOCK.MONOTONIC)),
.timeout = timeout,
.precision = 1 * std.time.ns_per_ms,
.flags = wasi.SUBSCRIPTION_CLOCK_ABSTIME,
},
},
},
};
// Build our batch of subscriptions and poll
var events: [Batch.capacity]wasi.event_t = undefined;
const subs = self.batch.array[0..self.batch.len];
assert(events.len >= subs.len);
var n: usize = 0;
switch (wasi.poll_oneoff(&subs[0], &events[0], subs.len, &n)) {
.SUCCESS => {},
else => |err| return posix.unexpectedErrno(err),
}
// Poll!
for (events[0..n]) |ev| {
// A system event
if (ev.userdata == 0) continue;
const c = @as(*Completion, @ptrFromInt(@as(usize, @intCast(ev.userdata))));
// We assume disarm since this is the safest time to access
// the completion. It makes rearms slightly more expensive
// but not by very much.
c.flags.state = .dead;
self.batch.put(c);
self.active -= 1;
const res = c.perform();
const action = c.callback(c.userdata, self, c, res);
switch (action) {
// We disarm by default
.disarm => {},
// Rearm we just restart it. We use start instead of
// add because then it'll become immediately available
// if we loop again.
.rearm => self.start(c),
}
}
if (wait == 0) break;
wait_rem -|= n;
}
}
fn start(self: *Loop, completion: *Completion) void {
const res_: ?Result = switch (completion.op) {
.noop => {
completion.flags.state = .dead;
return;
},
.cancel => |v| res: {
// We stop immediately. We only stop if we are in the
// "adding" state because cancellation or any other action
// means we're complete already.
//
// For example, if we're in the deleting state, it means
// someone is cancelling the cancel. So we do nothing. If
// we're in the dead state it means we ran already.
if (completion.flags.state == .adding) {
if (v.c.op == .cancel) break :res .{ .cancel = CancelError.InvalidOp };
self.stop_completion(v.c);
}
// We always run timers
break :res .{ .cancel = {} };
},
.read => res: {
const sub = self.batch.get(completion) catch |err| break :res .{ .read = err };
sub.* = completion.subscription();
break :res null;
},
.pread => res: {
const sub = self.batch.get(completion) catch |err| break :res .{ .pread = err };
sub.* = completion.subscription();
break :res null;
},
.write => res: {
const sub = self.batch.get(completion) catch |err| break :res .{ .write = err };
sub.* = completion.subscription();
break :res null;
},
.pwrite => res: {
const sub = self.batch.get(completion) catch |err| break :res .{ .pwrite = err };
sub.* = completion.subscription();
break :res null;
},
.recv => res: {
const sub = self.batch.get(completion) catch |err| break :res .{ .recv = err };
sub.* = completion.subscription();
break :res null;
},
.send => res: {
const sub = self.batch.get(completion) catch |err| break :res .{ .send = err };
sub.* = completion.subscription();
break :res null;
},
.accept => res: {
const sub = self.batch.get(completion) catch |err| break :res .{ .accept = err };
sub.* = completion.subscription();
break :res null;
},
.shutdown => |v| res: {
const how: wasi.sdflags_t = switch (v.how) {
.both => wasi.SHUT.WR | wasi.SHUT.RD,
.recv => wasi.SHUT.RD,
.send => wasi.SHUT.WR,
};
break :res .{
.shutdown = switch (wasi.sock_shutdown(v.socket, how)) {
.SUCCESS => {},
else => |err| posix.unexpectedErrno(err),
},
};
},
.close => |v| res: {
posix.close(v.fd);
break :res .{ .close = {} };
},
.async_wait => res: {
// Add our async to the list of asyncs
self.asyncs.push(completion);
break :res null;
},
.timer => |*v| res: {
// Point back to completion since we need this. In the future
// we want to use @fieldParentPtr but https://github.com/ziglang/zig/issues/6611
v.c = completion;
// Insert the timer into our heap.
self.timers.insert(v);
// We always run timers
break :res null;
},
};
// If we failed to add the completion then we call the callback
// immediately and mark the error.
if (res_) |res| {
completion.flags.state = .dead;
switch (completion.callback(
completion.userdata,
self,
completion,
res,
)) {
.disarm => {},
// If we rearm then we requeue this. Due to the way that tick works,
// this won't try to re-add immediately it won't happen until the
// next tick.
.rearm => self.add(completion),
}
return;
}
// The completion is now active since it is in our poll set.
completion.flags.state = .active;
// Increase our active count
self.active += 1;
}
fn stop_completion(self: *Loop, c: *Completion) void {
// We may modify the state below so we need to know now if this
// completion was active.
const active = c.flags.state == .active;
const rearm: bool = switch (c.op) {
.timer => |*v| timer: {
assert(v.c == c);
// Timers needs to be removed from the timer heap only if
// it has been inserted.
if (c.flags.state == .active) {
self.timers.remove(v);
}
// If the timer was never fired, we need to fire it with
// the cancellation notice.
if (c.flags.state != .dead) {
// If we have reset set AND we got a cancellation result,
// that means that we were canceled so that we can update
// our expiration time.
if (v.reset) |r| {
v.next = r;
v.reset = null;
break :timer true;
}
// We have to set the completion as dead here because
// it isn't safe to modify completions after a callback.
c.flags.state = .dead;
const action = c.callback(c.userdata, self, c, .{ .timer = .cancel });
switch (action) {
.disarm => {},
.rearm => break :timer true,
}
}
break :timer false;
},
else => unreachable,
};
// Decrement the active count so we know how many are running for
// .until_done run semantics.
if (active) self.active -= 1;
// If we're rearming, add it again immediately
if (rearm) self.start(c);
}
/// Add a timer to the loop. The timer will initially execute in "next_ms"
/// from now and will repeat every "repeat_ms" thereafter. If "repeat_ms" is
/// zero then the timer is oneshot. If "next_ms" is zero then the timer will
/// invoke immediately (the callback will be called immediately -- as part
/// of this function call -- to avoid any additional system calls).
pub fn timer(
self: *Loop,
c: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
c.* = .{
.op = .{
.timer = .{
.next = timer_next(next_ms),
},
},
.userdata = userdata,
.callback = cb,
};
self.add(c);
}
/// See io_uring.timer_reset for docs.
pub fn timer_reset(
self: *Loop,
c: *Completion,
c_cancel: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
switch (c.flags.state) {
.dead, .deleting => {
self.timer(c, next_ms, userdata, cb);
return;
},
// Adding state we can just modify the metadata and return
// since the timer isn't in the heap yet.
.adding => {
c.op.timer.next = timer_next(next_ms);
c.userdata = userdata;
c.callback = cb;
return;
},
.active => {
// Update the reset time for the timer to the desired time
// along with all the callbacks.
c.op.timer.reset = timer_next(next_ms);
c.userdata = userdata;
c.callback = cb;
// If the cancellation is active, we assume its for this timer
// and do nothing.
if (c_cancel.state() == .active) return;
assert(c_cancel.state() == .dead and c.state() == .active);
c_cancel.* = .{ .op = .{ .cancel = .{ .c = c } } };
self.add(c_cancel);
},
}
}
/// Returns the "loop" time in milliseconds. The loop time is updated
/// once per loop tick, before IO polling occurs. It remains constant
/// throughout callback execution.
///
/// You can force an update of the "now" value by calling update_now()
/// at any time from the main thread.
///
/// The clock that is used is not guaranteed. In general, a monotonic
/// clock source is always used if available. This value should typically
/// just be used for relative time calculations within the loop, such as
/// answering the question "did this happen <x> ms ago?".
pub fn now(self: *Loop) i64 {
return std.math.lossyCast(i64, @divFloor(self.cached_now, std.time.ns_per_ms));
}
/// Update the cached time.
pub fn update_now(self: *Loop) void {
if (get_now()) |t| self.cached_now = t else |_| {}
}
fn timer_next(next_ms: u64) wasi.timestamp_t {
// Get the absolute time we'll execute this timer next.
var now_ts: wasi.timestamp_t = undefined;
switch (wasi.clock_time_get(@as(u32, @bitCast(posix.CLOCK.MONOTONIC)), 1, &now_ts)) {
.SUCCESS => {},
.INVAL => unreachable,
else => unreachable,
}
// TODO: overflow
now_ts += next_ms * std.time.ns_per_ms;
return now_ts;
}
fn get_now() !wasi.timestamp_t {
var ts: wasi.timestamp_t = undefined;
return switch (wasi.clock_time_get(posix.CLOCK.MONOTONIC, 1, &ts)) {
.SUCCESS => ts,
.INVAL => error.UnsupportedClock,
else => |err| posix.unexpectedErrno(err),
};
}
};
pub const Completion = struct {
/// Operation to execute. This is only safe to read BEFORE the completion
/// is queued. After being queued (with "add"), the operation may change.
op: Operation = .{ .noop = {} },
/// Userdata and callback for when the completion is finished.
userdata: ?*anyopaque = null,
callback: xev.Callback = xev.noopCallback,
//---------------------------------------------------------------
// Internal fields
flags: packed struct {
/// Watch state of this completion. We use this to determine whether
/// we're active, adding, deleting, etc. This lets us add and delete
/// multiple times before a loop tick and handle the state properly.
state: State = .dead,
} = .{},
/// Intrusive queue field
next: ?*Completion = null,
/// Index in the batch array.
batch_idx: usize = 0,
const State = enum(u3) {
/// completion is not part of any loop
dead = 0,
/// completion is in the submission queue
adding = 1,
/// completion is in the deletion queue
deleting = 2,
/// completion is actively being sent to poll
active = 3,
};
/// Returns the state of this completion. There are some things to
/// be caution about when calling this function.
///
/// First, this is only safe to call from the main thread. This cannot
/// be called from any other thread.
///
/// Second, if you are using default "undefined" completions, this will
/// NOT return a valid value if you access it. You must zero your
/// completion using ".{}". You only need to zero the completion once.
/// Once the completion is in use, it will always be valid.
///
/// Third, if you stop the loop (loop.stop()), the completions registered
/// with the loop will NOT be reset to a dead state.
pub fn state(self: Completion) xev.CompletionState {
return switch (self.flags.state) {
.dead => .dead,
.adding, .deleting, .active => .active,
};
}
fn subscription(self: *Completion) wasi.subscription_t {
return switch (self.op) {
.read => |v| .{
.userdata = @intFromPtr(self),
.u = .{
.tag = wasi.EVENTTYPE_FD_READ,
.u = .{
.fd_read = .{
.fd = v.fd,
},
},
},
},
.pread => |v| .{
.userdata = @intFromPtr(self),
.u = .{
.tag = wasi.EVENTTYPE_FD_READ,
.u = .{
.fd_read = .{
.fd = v.fd,
},
},
},
},
.write => |v| .{
.userdata = @intFromPtr(self),
.u = .{
.tag = wasi.EVENTTYPE_FD_WRITE,
.u = .{
.fd_write = .{
.fd = v.fd,
},
},
},
},
.pwrite => |v| .{
.userdata = @intFromPtr(self),
.u = .{
.tag = wasi.EVENTTYPE_FD_WRITE,
.u = .{
.fd_write = .{
.fd = v.fd,
},
},
},
},
.accept => |v| .{
.userdata = @intFromPtr(self),
.u = .{
.tag = wasi.EVENTTYPE_FD_READ,
.u = .{
.fd_read = .{
.fd = v.socket,
},
},
},
},
.recv => |v| .{
.userdata = @intFromPtr(self),
.u = .{
.tag = wasi.EVENTTYPE_FD_READ,
.u = .{
.fd_read = .{
.fd = v.fd,
},
},
},
},
.send => |v| .{
.userdata = @intFromPtr(self),
.u = .{
.tag = wasi.EVENTTYPE_FD_WRITE,
.u = .{
.fd_write = .{
.fd = v.fd,
},
},
},
},
.close,
.async_wait,
.noop,
.shutdown,
.cancel,
.timer,
=> unreachable,
};
}
/// Perform the operation associated with this completion. This will
/// perform the full blocking operation for the completion.
fn perform(self: *Completion) Result {
return switch (self.op) {
// This should never happen because we always do these synchronously
// or in another location.
.close,
.async_wait,
.noop,
.shutdown,
.cancel,
.timer,
=> unreachable,
.accept => |*op| res: {
var out_fd: posix.fd_t = undefined;
break :res .{
.accept = switch (wasi.sock_accept(op.socket, 0, &out_fd)) {
.SUCCESS => out_fd,
else => |err| posix.unexpectedErrno(err),
},
};
},
.read => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.read(op.fd, v),
.array => |*v| posix.read(op.fd, v),
};
break :res .{
.read = if (n_) |n|
if (n == 0) error.EOF else n
else |err|
err,
};
},
.pread => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.pread(op.fd, v, op.offset),
.array => |*v| posix.pread(op.fd, v, op.offset),
};
break :res .{
.pread = if (n_) |n|
if (n == 0) error.EOF else n
else |err|
err,
};
},
.write => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.write(op.fd, v),
.array => |*v| posix.write(op.fd, v.array[0..v.len]),
};
break :res .{
.write = if (n_) |n| n else |err| err,
};
},
.pwrite => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.pwrite(op.fd, v, op.offset),
.array => |*v| posix.pwrite(op.fd, v.array[0..v.len], op.offset),
};
break :res .{
.pwrite = if (n_) |n| n else |err| err,
};
},
.recv => |*op| res: {
var n: usize = undefined;
var roflags: wasi.roflags_t = undefined;
const errno = switch (op.buffer) {
.slice => |v| slice: {
var iovs = [1]posix.iovec{posix.iovec{
.base = v.ptr,
.len = v.len,
}};
break :slice wasi.sock_recv(
op.fd,
@ptrCast(&iovs[0]),
iovs.len,
0,
&n,
&roflags,
);
},
.array => |*v| array: {
var iovs = [1]posix.iovec{posix.iovec{
.base = v,
.len = v.len,
}};
break :array wasi.sock_recv(
op.fd,
@ptrCast(&iovs[0]),
iovs.len,
0,
&n,
&roflags,
);
},
};
break :res .{
.recv = switch (errno) {
.SUCCESS => n,
else => |err| posix.unexpectedErrno(err),
},
};
},
.send => |*op| res: {
var n: usize = undefined;
const errno = switch (op.buffer) {
.slice => |v| slice: {
var iovs = [1]posix.iovec_const{posix.iovec_const{
.base = v.ptr,
.len = v.len,
}};
break :slice wasi.sock_send(
op.fd,
@ptrCast(&iovs[0]),
iovs.len,
0,
&n,
);
},
.array => |*v| array: {
var iovs = [1]posix.iovec_const{posix.iovec_const{
.base = &v.array,
.len = v.len,
}};
break :array wasi.sock_send(
op.fd,
@ptrCast(&iovs[0]),
iovs.len,
0,
&n,
);
},
};
break :res .{
.send = switch (errno) {
.SUCCESS => n,
else => |err| posix.unexpectedErrno(err),
},
};
},
};
}
};
pub const OperationType = enum {
noop,
cancel,
accept,
read,
pread,
write,
pwrite,
send,
recv,
shutdown,
close,
timer,
async_wait,
};
/// The result type based on the operation type. For a callback, the
/// result tag will ALWAYS match the operation tag.
pub const Result = union(OperationType) {
noop: void,
cancel: CancelError!void,
accept: AcceptError!posix.fd_t,
read: ReadError!usize,
pread: ReadError!usize,
write: WriteError!usize,
pwrite: WriteError!usize,
send: WriteError!usize,
recv: ReadError!usize,
shutdown: ShutdownError!void,
close: CloseError!void,
timer: TimerError!TimerTrigger,
async_wait: AsyncError!void,
};
/// All the supported operations of this event loop. These are always
/// backend-specific and therefore the structure and types change depending
/// on the underlying system in use. The high level operations are
/// done by initializing the request handles.
pub const Operation = union(OperationType) {
noop: void,
cancel: struct {
c: *Completion,
},
accept: struct {
socket: posix.socket_t,
},
read: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
},
pread: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
offset: u64,
},
write: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
},
pwrite: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
offset: u64,
},
send: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
},
recv: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
},
shutdown: struct {
socket: posix.socket_t,
how: posix.ShutdownHow = .both,
},
close: struct {
fd: posix.fd_t,
},
timer: Timer,
async_wait: struct {
wakeup: Loop.WakeupType = Loop.wakeup_init,
},
};
const Timer = struct {
/// The absolute time to fire this timer next.
next: wasi.timestamp_t,
/// Only used internally. If this is non-null and timer is
/// CANCELLED, then the timer is rearmed automatically with this
/// as the next time. The callback will not be called on the
/// cancellation.
reset: ?wasi.timestamp_t = null,
/// Internal heap fields.
heap: heap.IntrusiveField(Timer) = .{},
/// We point back to completion for now. When issue[1] is fixed,
/// we can juse use that from our heap fields.
/// [1]: https://github.com/ziglang/zig/issues/6611
c: *Completion = undefined,
fn less(_: void, a: *const Timer, b: *const Timer) bool {
return a.next < b.next;
}
};
pub const CancelError = error{
/// Invalid operation to cancel. You cannot cancel a cancel operation.
InvalidOp,
};
pub const CloseError = error{
Unknown,
};
pub const AcceptError = Batch.Error || error{
Unexpected,
};
pub const ConnectError = error{};
pub const ShutdownError = error{
Unexpected,
};
pub const ReadError = Batch.Error || posix.ReadError || posix.PReadError ||
error{
EOF,
Unknown,
};
pub const WriteError = Batch.Error || posix.WriteError || posix.PWriteError ||
error{
Unknown,
};
pub const AsyncError = error{
Unknown,
};
pub const TimerError = error{
Unexpected,
};
pub const TimerTrigger = enum {
/// Timer expired.
expiration,
/// Timer was canceled.
cancel,
/// Unused
request,
};
/// ReadBuffer are the various options for reading.
pub const ReadBuffer = union(enum) {
/// Read into this slice.
slice: []u8,
/// Read into this array, just set this to undefined and it will
/// be populated up to the size of the array. This is an option because
/// the other union members force a specific size anyways so this lets us
/// use the other size in the union to support small reads without worrying
/// about buffer allocation.
///
/// To know the size read you have to use the return value of the
/// read operations (i.e. recv).
///
/// Note that the union at the time of this writing could accomodate a
/// much larger fixed size array here but we want to retain flexiblity
/// for future fields.
array: [32]u8,
// TODO: future will have vectors
};
/// WriteBuffer are the various options for writing.
pub const WriteBuffer = union(enum) {
/// Write from this buffer.
slice: []const u8,
/// Write from this array. See ReadBuffer.array for why we support this.
array: struct {
array: [32]u8,
len: usize,
},
// TODO: future will have vectors
};
/// A batch of subscriptions to send to poll_oneoff.
const Batch = struct {
pub const capacity = 1024;
/// The array of subscriptions. Sub zero is ALWAYS our loop timeout
/// so the actual capacity of this for user completions is (len - 1).
array: [capacity]wasi.subscription_t = undefined,
/// The length of the used slots in the array including our reserved slot.
len: usize = 1,
pub const Error = error{BatchFull};
/// Initialize a batch entry for the given completion. This will
/// store the batch index on the completion.
pub fn get(self: *Batch, c: *Completion) Error!*wasi.subscription_t {
if (self.len >= self.array.len) return error.BatchFull;
c.batch_idx = self.len;
self.len += 1;
return &self.array[c.batch_idx];
}
/// Put an entry back.
pub fn put(self: *Batch, c: *Completion) void {
assert(c.batch_idx > 0);
assert(self.len > 1);
const old_idx = c.batch_idx;
c.batch_idx = 0;
self.len -= 1;
// If we're empty then we don't worry about swapping.
if (self.len == 0) return;
// We're not empty so swap the value we just removed with the
// last one so our empty slot is always at the end.
self.array[old_idx] = self.array[self.len];
const swapped = @as(*Completion, @ptrFromInt(@as(usize, @intCast(self.array[old_idx].userdata))));
swapped.batch_idx = old_idx;
}
test {
const testing = std.testing;
var b: Batch = .{};
var cs: [capacity - 1]Completion = undefined;
for (&cs, 0..) |*c, i| {
c.* = .{ .op = undefined, .callback = undefined };
const sub = try b.get(c);
sub.* = .{ .userdata = @intFromPtr(c), .u = undefined };
try testing.expectEqual(@as(usize, i + 1), c.batch_idx);
}
var bad: Completion = .{ .op = undefined, .callback = undefined };
try testing.expectError(error.BatchFull, b.get(&bad));
// Put one back
const old = cs[4].batch_idx;
const replace = &cs[cs.len - 1];
b.put(&cs[4]);
try testing.expect(b.len == capacity - 1);
try testing.expect(b.array[old].userdata == @intFromPtr(replace));
try testing.expect(replace.batch_idx == old);
// Put it back in
const sub = try b.get(&cs[4]);
sub.* = .{ .userdata = @intFromPtr(&cs[4]), .u = undefined };
try testing.expect(cs[4].batch_idx == capacity - 1);
}
};
test "wasi: loop time" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// should never init zero
const now = loop.now();
try testing.expect(now > 0);
// should update on a loop tick
while (now == loop.now()) try loop.run(.no_wait);
}
test "wasi: timer" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var called = false;
var c1: xev.Completion = undefined;
loop.timer(&c1, 1, &called, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// Add another timer
var called2 = false;
var c2: xev.Completion = undefined;
loop.timer(&c2, 100_000, &called2, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// State checking
try testing.expect(c1.state() == .active);
try testing.expect(c2.state() == .active);
// Tick
while (!called) try loop.run(.no_wait);
try testing.expect(called);
try testing.expect(!called2);
// State checking
try testing.expect(c1.state() == .dead);
try testing.expect(c2.state() == .active);
}
test "wasi: timer reset" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, cb);
// We know timer won't be called from the timer test previously.
try loop.run(.no_wait);
try testing.expect(trigger == null);
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .active);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "wasi: timer reset before tick" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, cb);
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .dead);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "wasi: timer reset after trigger" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 1, &trigger, cb);
// Run the timer
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
trigger = null;
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .dead);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "wasi: timer cancellation" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: xev.Completion = undefined;
loop.timer(&c1, 100_000, &trigger, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const ptr = @as(*?TimerTrigger, @ptrCast(@alignCast(ud.?)));
ptr.* = r.timer catch unreachable;
return .disarm;
}
}).callback);
// Tick and verify we're not called.
try loop.run(.no_wait);
try testing.expect(trigger == null);
// Cancel the timer
var called = false;
var c_cancel: xev.Completion = .{
.op = .{
.cancel = .{
.c = &c1,
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.cancel catch unreachable;
const ptr = @as(*bool, @ptrCast(@alignCast(ud.?)));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel);
// Tick
try loop.run(.until_done);
try testing.expect(called);
try testing.expect(trigger.? == .cancel);
}
test "wasi: canceling a completed operation" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: xev.Completion = undefined;
loop.timer(&c1, 1, &trigger, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const ptr = @as(*?TimerTrigger, @ptrCast(@alignCast(ud.?)));
ptr.* = r.timer catch unreachable;
return .disarm;
}
}).callback);
// Tick and verify we're not called.
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
// Cancel the timer
var called = false;
var c_cancel: xev.Completion = .{
.op = .{
.cancel = .{
.c = &c1,
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.cancel catch unreachable;
const ptr = @as(*bool, @ptrCast(@alignCast(ud.?)));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel);
// Tick
try loop.run(.until_done);
try testing.expect(called);
try testing.expect(trigger.? == .expiration);
}
test "wasi: file" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a file
const path = "zig-cache/wasi-test-file.txt";
const dir = std.fs.cwd();
// We can't use dir.createFile yet: https://github.com/ziglang/zig/issues/14324
const f = f: {
const w = wasi;
const oflags = w.O.CREAT | w.O.TRUNC;
const base: w.rights_t = w.RIGHT.FD_WRITE |
w.RIGHT.FD_READ |
w.RIGHT.FD_DATASYNC |
w.RIGHT.FD_SEEK |
w.RIGHT.FD_TELL |
w.RIGHT.FD_FDSTAT_SET_FLAGS |
w.RIGHT.FD_SYNC |
w.RIGHT.FD_ALLOCATE |
w.RIGHT.FD_ADVISE |
w.RIGHT.FD_FILESTAT_SET_TIMES |
w.RIGHT.FD_FILESTAT_SET_SIZE |
w.RIGHT.FD_FILESTAT_GET |
w.RIGHT.POLL_FD_READWRITE;
const fdflags: w.fdflags_t = w.FDFLAG.SYNC | w.FDFLAG.RSYNC | w.FDFLAG.DSYNC;
const fd = try posix.openatWasi(dir.fd, path, 0x0, oflags, 0x0, base, fdflags);
break :f std.fs.File{ .handle = fd };
};
defer dir.deleteFile(path) catch unreachable;
defer f.close();
// Start a reader
var read_buf: [128]u8 = undefined;
var read_len: ?usize = null;
var c_read: xev.Completion = .{
.op = .{
.read = .{
.fd = f.handle,
.buffer = .{ .slice = &read_buf },
},
},
.userdata = &read_len,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*?usize, @ptrCast(@alignCast(ud.?)));
ptr.* = r.read catch |err| switch (err) {
error.EOF => 0,
else => unreachable,
};
return .disarm;
}
}).callback,
};
loop.add(&c_read);
// Tick. The reader should NOT read because we are blocked with no data.
try loop.run(.until_done);
try testing.expect(read_len.? == 0);
// Start a writer
const write_buf = "hello!";
var write_len: ?usize = null;
var c_write: xev.Completion = .{
.op = .{
.write = .{
.fd = f.handle,
.buffer = .{ .slice = write_buf },
},
},
.userdata = &write_len,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*?usize, @ptrCast(@alignCast(ud.?)));
ptr.* = r.write catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_write);
try loop.run(.until_done);
try testing.expect(write_len.? == write_buf.len);
// Close
var c_close: xev.Completion = .{
.op = .{
.close = .{
.fd = f.handle,
},
},
.userdata = null,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = ud;
_ = l;
_ = c;
_ = r.close catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_close);
try loop.run(.until_done);
// Read and verify we've written
const f_verify = try dir.openFile(path, .{});
defer f_verify.close();
read_len = try f_verify.readAll(&read_buf);
try testing.expectEqualStrings(write_buf, read_buf[0..read_len.?]);
}
|
0 | repos/libxev/src | repos/libxev/src/backend/kqueue.zig | //! Backend to use kqueue. This is currently only tested on macOS but
//! support for BSDs is planned (if it doesn't already work).
const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const posix = std.posix;
const queue = @import("../queue.zig");
const queue_mpsc = @import("../queue_mpsc.zig");
const heap = @import("../heap.zig");
const main = @import("../main.zig");
const xev = main.Kqueue;
const ThreadPool = main.ThreadPool;
const log = std.log.scoped(.libxev_kqueue);
pub const Loop = struct {
const TimerHeap = heap.Intrusive(Timer, void, Timer.less);
const TaskCompletionQueue = queue_mpsc.Intrusive(Completion);
/// The fd of the kqueue.
kqueue_fd: posix.fd_t,
/// The mach port that this kqueue always has a filter for. Writing
/// an empty message to this port can be used to wake up the loop
/// at any time. Waking up the loop via this port won't trigger any
/// particular completion, it just forces tick to cycle.
mach_port: xev.Async,
mach_port_buffer: [32]u8 = undefined,
/// The number of active completions. This DOES NOT include completions that
/// are queued in the submissions queue.
active: usize = 0,
/// Our queue of submissions that we want to enqueue on the next tick.
/// These are NOT started, they are NOT submitted to kqueue. They are
/// pending.
submissions: queue.Intrusive(Completion) = .{},
/// The queue of cancellation requests. These will point to the
/// completion that we need to cancel. We don't queue the exact completion
/// to cancel because it may be in another queue.
cancellations: queue.Intrusive(Completion) = .{},
/// Our queue of completed completions where the callback hasn't been
/// called yet, but the "result" field should be set on every completion.
/// This is used to delay completion callbacks until the next tick.
/// Values in the completion queue must not be in the kqueue.
completions: queue.Intrusive(Completion) = .{},
/// Heap of timers. We use heaps instead of the EVFILT_TIMER because
/// it avoids a lot of syscalls in the case where there are a LOT of
/// timers.
timers: TimerHeap = .{ .context = {} },
/// The thread pool to use for blocking operations that kqueue can't do.
thread_pool: ?*ThreadPool,
/// The MPSC queue for completed completions from the thread pool.
thread_pool_completions: TaskCompletionQueue,
/// Cached time
cached_now: posix.timespec,
/// Some internal fields we can pack for better space.
flags: packed struct {
/// True once it is initialized.
init: bool = false,
/// Whether we're in a run or not (to prevent nested runs).
in_run: bool = false,
/// Whether our loop is in a stopped state or not.
stopped: bool = false,
} = .{},
/// Initialize a new kqueue-backed event loop. See the Options docs
/// for what options matter for kqueue.
pub fn init(options: xev.Options) !Loop {
// This creates a new kqueue fd
const fd = try posix.kqueue();
errdefer posix.close(fd);
var mach_port = try xev.Async.init();
errdefer mach_port.deinit();
var res: Loop = .{
.kqueue_fd = fd,
.mach_port = mach_port,
.thread_pool = options.thread_pool,
.thread_pool_completions = undefined,
.cached_now = undefined,
};
res.update_now();
return res;
}
/// Deinitialize the loop, this closes the kqueue. Any events that
/// were unprocessed are lost -- their callbacks will never be called.
pub fn deinit(self: *Loop) void {
posix.close(self.kqueue_fd);
self.mach_port.deinit();
}
/// Stop the loop. This can only be called from the main thread.
/// This will stop the loop forever. Future ticks will do nothing.
///
/// This does NOT stop any completions that are queued to be executed
/// in the thread pool. If you are using a thread pool, completions
/// are not safe to recover until the thread pool is shut down. If
/// you're not using a thread pool, all completions are safe to
/// read/write once any outstanding `run` or `tick` calls are returned.
pub fn stop(self: *Loop) void {
self.flags.stopped = true;
}
/// Add a completion to the loop. The completion is not started until
/// the loop is run (`run`, `tick`) or an explicit submission request
/// is made (`submit`).
pub fn add(self: *Loop, completion: *Completion) void {
// If this is a cancellation, we special case it and add it to
// a separate queue so we can handle them first.
if (completion.op == .cancel) {
assert(!self.start(completion, undefined));
return;
}
// We just add the completion to the queue. Failures can happen
// at submission or tick time.
completion.flags.state = .adding;
self.submissions.push(completion);
}
/// Submit any enqueue completions. This does not fire any callbacks
/// for completed events (success or error). Callbacks are only fired
/// on the next tick.
///
/// If an error is returned, some events might be lost. Errors are
/// exceptional and should generally not happen. If we could recover
/// which completions were not submitted and restore them we would,
/// but the kqueue API doesn't provide that level of clarity.
pub fn submit(self: *Loop) !void {
// We try to submit as many events at once as we can.
var events: [256]Kevent = undefined;
var events_len: usize = 0;
// Submit all the submissions. We copy the submission queue so that
// any resubmits don't cause an infinite loop.
var queued = self.submissions;
self.submissions = .{};
// On error, we have to restore the queue because we may be batching.
errdefer self.submissions = queued;
while (true) {
queue_pop: while (queued.pop()) |c| {
switch (c.flags.state) {
// If we're adding then we start the event.
.adding => if (self.start(c, &events[events_len])) {
events_len += 1;
if (events_len >= events.len) break :queue_pop;
},
// If we're deleting then we create a deletion event and
// queue the completion to notify cancellation.
.deleting => if (c.kevent()) |ev| {
const ecanceled = -1 * @as(i32, @intCast(@intFromEnum(posix.system.E.CANCELED)));
c.result = c.syscall_result(ecanceled);
c.flags.state = .dead;
self.completions.push(c);
events[events_len] = ev;
events[events_len].flags = posix.system.EV_DELETE;
events_len += 1;
if (events_len >= events.len) break :queue_pop;
},
// This is set if the completion was canceled while in the
// submission queue. This is a special case where we still
// want to call the callback to tell it it was canceled.
.dead => self.stop_completion(c),
// Shouldn't happen if our logic is all correct.
.active => log.err(
"invalid state in submission queue state={}",
.{c.flags.state},
),
}
}
// If we have no events then we have to have gone through the entire
// submission queue and we're done.
if (events_len == 0) break;
// Zero timeout so that kevent returns immediately.
var timeout = std.mem.zeroes(posix.timespec);
const completed = try kevent_syscall(
self.kqueue_fd,
events[0..events_len],
events[0..events.len],
&timeout,
);
events_len = 0;
// Go through the completed events and queue them.
// NOTE: we currently never process completions (we set
// event list to zero length) because it was leading to
// memory corruption we need to investigate.
for (events[0..completed]) |ev| {
const c: *Completion = @ptrFromInt(@as(usize, @intCast(ev.udata)));
// We handle deletions separately.
if (ev.flags & posix.system.EV_DELETE != 0) continue;
// If EV_ERROR is set, then submission failed for this
// completion. We get the syscall errorcode from data and
// store it.
if (ev.flags & posix.system.EV_ERROR != 0) {
c.result = c.syscall_result(-@as(i32, @intCast(ev.data)));
} else {
// No error, means that this completion is ready to work.
c.result = c.perform(&ev);
}
assert(c.result != null);
self.completions.push(c);
}
}
}
/// Process the cancellations queue. This doesn't call any callbacks
/// or perform any syscalls. This just shuffles state around and sets
/// things up for cancellation to occur.
fn process_cancellations(self: *Loop) void {
while (self.cancellations.pop()) |c| {
const target = c.op.cancel.c;
switch (target.flags.state) {
// If the target is dead already we do nothing.
.dead => {},
// If the targeting is in the process of being removed
// from the kqueue we do nothing because its already done.
.deleting => {},
// If they are in the submission queue, mark them as dead
// so they will never be submitted.
.adding => target.flags.state = .dead,
// If it is active we need to schedule the deletion.
.active => self.stop_completion(target),
}
// We completed the cancellation.
c.result = .{ .cancel = {} };
self.completions.push(c);
}
}
/// Run the event loop. See RunMode documentation for details on modes.
/// Once the loop is run, the pointer MUST remain stable.
pub fn run(self: *Loop, mode: xev.RunMode) !void {
switch (mode) {
.no_wait => try self.tick(0),
.once => try self.tick(1),
.until_done => while (!self.done()) try self.tick(1),
}
}
/// Tick through the event loop once, waiting for at least "wait" completions
/// to be processed by the loop itself.
pub fn tick(self: *Loop, wait: u32) !void {
// If we're stopped then the loop is fully over.
if (self.flags.stopped) return;
// We can't nest runs.
if (self.flags.in_run) return error.NestedRunsNotAllowed;
self.flags.in_run = true;
defer self.flags.in_run = false;
// Initialize
if (!self.flags.init) {
self.flags.init = true;
if (self.thread_pool != null) {
self.thread_pool_completions.init();
}
// Add our event so that we wake up when our mach port receives an
// event. We have to add here because we need a stable self pointer.
const events = [_]Kevent{.{
.ident = @as(usize, @intCast(self.mach_port.port)),
.filter = posix.system.EVFILT_MACHPORT,
.flags = posix.system.EV_ADD | posix.system.EV_ENABLE,
.fflags = posix.system.MACH_RCV_MSG,
.data = 0,
.udata = 0,
.ext = .{
@intFromPtr(&self.mach_port_buffer),
self.mach_port_buffer.len,
},
}};
const n = kevent_syscall(
self.kqueue_fd,
&events,
events[0..0],
null,
) catch |err| {
// We reset initialization because we can't do anything
// safely unless we get this mach port registered!
self.flags.init = false;
return err;
};
assert(n == 0);
}
// The list of events, used as both a changelist and eventlist.
var events: [256]Kevent = undefined;
// The number of events in the events array to submit as changes
// on repeat ticks. Used mostly for efficient disarm.
var changes: usize = 0;
var wait_rem = @as(usize, @intCast(wait));
// Handle all of our cancellations first because we may be able
// to stop submissions from even happening if its still queued.
// Plus, cancellations sometimes add more to the submission queue
// (to remove from kqueue)
self.process_cancellations();
// TODO(mitchellh): an optimization in the future is for the last
// batch of submissions to return the changelist, because we can
// reuse that for the kevent call later...
try self.submit();
// Explaining the loop condition: we want to loop only if we have
// active handles (because it means we have something to do)
// and we have stuff we want to wait for still (wait_rem > 0) or
// we requested just a nowait tick (because we have to loop at least
// once).
//
// We also loop if there are any requested changes. Requested
// changes are only ever deletions currently, so we just process
// those until we have no more.
while (true) {
// If we're stopped then the loop is fully over.
if (self.flags.stopped) return;
// We must update our time no matter what
self.update_now();
// NOTE(mitchellh): This is a hideous boolean statement we should
// clean it up.
if (!((self.active > 0 and (wait == 0 or wait_rem > 0)) or
changes > 0 or
!self.completions.empty())) break;
// Run our expired timers
const now_timer: Timer = .{ .next = self.cached_now };
while (self.timers.peek()) |t| {
if (!Timer.less({}, t, &now_timer)) break;
// Remove the timer
assert(self.timers.deleteMin().? == t);
// Mark completion as done
const c = t.c;
c.flags.state = .dead;
// We mark it as inactive here because if we rearm below
// the start() function will reincrement this.
self.active -= 1;
// Lower our remaining count since we have processed something.
wait_rem -|= 1;
// Invoke
const action = c.callback(c.userdata, self, c, .{ .timer = .expiration });
switch (action) {
.disarm => {},
// We use undefined as the second param because timers
// never set a kevent, and we assert false for the same
// reason.
.rearm => assert(!self.start(c, undefined)),
}
}
// Migrate our completions from the thread pool MPSC queue to our
// completion queue.
// TODO: unify the queues
if (self.thread_pool != null) {
while (self.thread_pool_completions.pop()) |c| {
self.completions.push(c);
}
}
// Process the completions we already have completed.
while (self.completions.pop()) |c| {
// disarm_ev is the Kevent to use for disarming if the
// completion wants to disarm. We have to calculate this up
// front because c can be reused in callback.
const disarm_ev: ?Kevent = ev: {
// If we're not active then we were never part of the kqueue.
// If we are part of a threadpool we also never were part
// of the kqueue.
if (c.flags.state != .active or
c.flags.threadpool) break :ev null;
break :ev c.kevent();
};
// We store whether this completion was active so we can decrement
// the active count later
const c_active = c.flags.state == .active;
c.flags.state = .dead;
// Decrease our waiters because we are definitely processing one.
wait_rem -|= 1;
// Completion queue items MUST have a result set.
const action = c.callback(c.userdata, self, c, c.result.?);
switch (action) {
// If we're active we have to schedule a delete. Otherwise
// we do nothing because we were never part of the kqueue.
.disarm => {
if (disarm_ev) |ev| {
events[changes] = ev;
events[changes].flags = posix.system.EV_DELETE;
events[changes].udata = 0;
changes += 1;
assert(changes <= events.len);
}
if (c_active) self.active -= 1;
},
// Only resubmit if we aren't already active (in the queue)
.rearm => if (!c_active) self.submissions.push(c),
}
}
// Determine our next timeout based on the timers
const timeout: ?posix.timespec = timeout: {
if (wait_rem == 0) break :timeout std.mem.zeroes(posix.timespec);
// If we have a timer, we want to set the timeout to our next
// timer value. If we have no timer, we wait forever.
const t = self.timers.peek() orelse break :timeout null;
// Determine the time in milliseconds.
const ms_now = @as(u64, @intCast(self.cached_now.tv_sec)) * std.time.ms_per_s +
@as(u64, @intCast(self.cached_now.tv_nsec)) / std.time.ns_per_ms;
const ms_next = @as(u64, @intCast(t.next.tv_sec)) * std.time.ms_per_s +
@as(u64, @intCast(t.next.tv_nsec)) / std.time.ns_per_ms;
const ms = ms_next -| ms_now;
// Convert to s/ns for the timespec
const sec = ms / std.time.ms_per_s;
const nsec = (ms % std.time.ms_per_s) * std.time.ns_per_ms;
break :timeout .{ .tv_sec = @intCast(sec), .tv_nsec = @intCast(nsec) };
};
// Wait for changes. Note that we ALWAYS attempt to get completions
// back even if are done waiting (wait_rem == 0) because if we have
// to make a syscall to submit changes, we might as well also check
// for done events too.
const completed = completed: while (true) {
break :completed kevent_syscall(
self.kqueue_fd,
events[0..changes],
events[0..events.len],
if (timeout) |*t| t else null,
) catch |err| switch (err) {
// This should never happen because we always have
// space in our event list. If I'm reading the BSD source
// right (and Apple does something similar...) then ENOENT
// is always put into the eventlist if there is space:
// https://github.com/freebsd/freebsd-src/blob/5a4a83fd0e67a0d7787d2f3e09ef0e5552a1ffb6/sys/kern/kern_event.c#L1668
error.EventNotFound => unreachable,
// Any other error is fatal
else => return err,
};
};
// Reset changes since they're not submitted
changes = 0;
// Go through the completed events and queue them.
for (events[0..completed]) |ev| {
// Zero udata values are internal events that we do nothing
// on such as the mach port wakeup.
if (ev.udata == 0) continue;
// Ignore any successful deletions. This can only happen
// from disarms below and in that case we already processed
// their callback.
if (ev.flags & posix.system.EV_DELETE != 0) continue;
// This can only be set during changelist processing so
// that means that this event was never actually active.
// Therefore, we only decrement the waiters by 1 if we
// processed an active change.
if (ev.flags & posix.system.EV_ERROR != 0) {
// We cannot use c here because c is already dead
// at this point for this event.
continue;
}
wait_rem -|= 1;
const c: *Completion = @ptrFromInt(@as(usize, @intCast(ev.udata)));
// c is ready to be reused rigt away if we're dearming
// so we mark it as dead.
c.flags.state = .dead;
const result = c.perform(&ev);
const action = c.callback(c.userdata, self, c, result);
switch (action) {
.disarm => {
// Mark this event for deletion, it'll happen
// on the next tick.
events[changes] = ev;
events[changes].flags = posix.system.EV_DELETE;
events[changes].udata = 0;
changes += 1;
assert(changes <= events.len);
self.active -= 1;
},
// We rearm by default with kqueue so we just have to make
// sure that the state is correct.
.rearm => {
c.flags.state = .active;
},
}
}
// If we ran through the loop once we break if we don't care.
if (wait == 0) break;
}
}
/// Returns the "loop" time in milliseconds. The loop time is updated
/// once per loop tick, before IO polling occurs. It remains constant
/// throughout callback execution.
///
/// You can force an update of the "now" value by calling update_now()
/// at any time from the main thread.
///
/// The clock that is used is not guaranteed. In general, a monotonic
/// clock source is always used if available. This value should typically
/// just be used for relative time calculations within the loop, such as
/// answering the question "did this happen <x> ms ago?".
pub fn now(self: *Loop) i64 {
// If anything overflows we just return the max value.
const max = std.math.maxInt(i64);
// Calculate all the values, being careful about overflows in order
// to just return the maximum value.
const sec = std.math.mul(isize, self.cached_now.tv_sec, std.time.ms_per_s) catch return max;
const nsec = @divFloor(self.cached_now.tv_nsec, std.time.ns_per_ms);
return std.math.lossyCast(i64, sec +| nsec);
}
/// Update the cached time.
pub fn update_now(self: *Loop) void {
posix.clock_gettime(posix.CLOCK.MONOTONIC, &self.cached_now) catch {};
}
/// Add a timer to the loop. The timer will execute in "next_ms". This
/// is oneshot: the timer will not repeat. To repeat a timer, either
/// schedule another in your callback or return rearm from the callback.
pub fn timer(
self: *Loop,
c: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
c.* = .{
.op = .{
.timer = .{
.next = self.timer_next(next_ms),
},
},
.userdata = userdata,
.callback = cb,
};
self.add(c);
}
/// See io_uring.timer_reset for docs.
pub fn timer_reset(
self: *Loop,
c: *Completion,
c_cancel: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
switch (c.flags.state) {
.dead, .deleting => {
self.timer(c, next_ms, userdata, cb);
return;
},
// Adding state we can just modify the metadata and return
// since the timer isn't in the heap yet.
.adding => {
c.op.timer.next = self.timer_next(next_ms);
c.userdata = userdata;
c.callback = cb;
return;
},
.active => {
// Update the reset time for the timer to the desired time
// along with all the callbacks.
c.op.timer.reset = self.timer_next(next_ms);
c.userdata = userdata;
c.callback = cb;
// If the cancellation is active, we assume its for this timer
// and do nothing.
if (c_cancel.state() == .active) return;
assert(c_cancel.state() == .dead and c.state() == .active);
c_cancel.* = .{ .op = .{ .cancel = .{ .c = c } } };
self.add(c_cancel);
},
}
}
fn timer_next(self: Loop, next_ms: u64) posix.timespec {
// Get the timestamp of the absolute time that we'll execute this timer.
// There are lots of failure scenarios here in math. If we see any
// of them we just use the maximum value.
const max: posix.timespec = .{
.tv_sec = std.math.maxInt(isize),
.tv_nsec = std.math.maxInt(isize),
};
const next_s = std.math.cast(isize, next_ms / std.time.ms_per_s) orelse
return max;
const next_ns = std.math.cast(
isize,
(next_ms % std.time.ms_per_s) * std.time.ns_per_ms,
) orelse return max;
return .{
.tv_sec = std.math.add(isize, self.cached_now.tv_sec, next_s) catch
return max,
.tv_nsec = std.math.add(isize, self.cached_now.tv_nsec, next_ns) catch
return max,
};
}
fn done(self: *Loop) bool {
return self.flags.stopped or (self.active == 0 and
self.submissions.empty() and
self.completions.empty());
}
/// Start the completion. This returns true if the Kevent was set
/// and should be queued.
fn start(self: *Loop, c: *Completion, ev: *Kevent) bool {
const StartAction = union(enum) {
/// We have set the kevent out parameter
kevent: void,
// We are a timer,
timer: void,
// We are a cancellation
cancel: void,
// We want to run on the threadpool
threadpool: void,
/// We have a result code from making a system call now.
result: i32,
};
const action: StartAction = if (c.flags.threadpool) .{
.threadpool = {},
} else switch (c.op) {
.noop => {
c.flags.state = .dead;
return false;
},
.cancel => action: {
// Queue the cancel
break :action .{ .cancel = {} };
},
.accept => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.connect => |*v| action: {
while (true) {
const result = posix.system.connect(v.socket, &v.addr.any, v.addr.getOsSockLen());
switch (posix.errno(result)) {
// Interrupt, try again
.INTR => continue,
// This means the connect is blocked and in progress.
// We register for the write event which will let us know
// when it is complete.
.AGAIN, .INPROGRESS => {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
// Any other error we report
else => break :action .{ .result = result },
}
}
},
.write => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.pwrite => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.read => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.pread => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.send => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.recv => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.sendto => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.recvfrom => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.machport => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.proc => action: {
ev.* = c.kevent().?;
break :action .{ .kevent = {} };
},
.shutdown => |v| action: {
const result = posix.system.shutdown(v.socket, switch (v.how) {
.recv => posix.SHUT.RD,
.send => posix.SHUT.WR,
.both => posix.SHUT.RDWR,
});
break :action .{ .result = result };
},
.close => |v| action: {
posix.close(v.fd);
break :action .{ .result = 0 };
},
.timer => |*v| action: {
// Point back to completion since we need this. In the future
// we want to use @fieldParentPtr but https://github.com/ziglang/zig/issues/6611
v.c = c;
// Insert the timer into our heap.
self.timers.insert(v);
// We always run timers
break :action .{ .timer = {} };
},
};
switch (action) {
.kevent,
.timer,
=> {
// Increase our active count so we now wait for this. We
// assume it'll successfully queue. If it doesn't we handle
// that later (see submit)
self.active += 1;
c.flags.state = .active;
// We only return true if this is a kevent, since other
// actions can come in here.
return action == .kevent;
},
.cancel => {
// We are considered an active completion.
self.active += 1;
c.flags.state = .active;
self.cancellations.push(c);
return false;
},
.threadpool => {
// We need to mark this completion as active no matter
// what happens below so that we mark is inactive with
// completion handling.
self.active += 1;
c.flags.state = .active;
// We need a thread pool otherwise we set an error on
// our result and queue the completion.
const pool = self.thread_pool orelse {
// We use EPERM as a way to note there is no thread
// pool. We can change this in the future if there is
// a better choice.
const eperm = -1 * @as(i32, @intCast(@intFromEnum(posix.system.E.PERM)));
c.result = c.syscall_result(eperm);
self.completions.push(c);
return false;
};
// Setup our completion state so that the thread can
// communicate back to our main thread.
c.task_loop = self;
c.task = .{ .callback = thread_perform };
// Schedule it, from this point forward its not safe to touch c.
pool.schedule(ThreadPool.Batch.from(&c.task));
return false;
},
// A result is immediately available. Queue the completion to
// be invoked.
.result => |result| {
c.result = c.syscall_result(result);
self.completions.push(c);
return false;
},
}
}
fn stop_completion(self: *Loop, c: *Completion) void {
if (c.flags.state == .active) {
// If there is a result already, then we're already in the
// completion queue and we can be done. Items in the completion
// queue can NOT be in the kqueue too.
if (c.result != null) return;
// If this completion has a kevent associated with it, then
// we must remove the kevent. We remove the kevent by adding it
// to the submission queue (because its the same syscall) but
// setting the state to deleting.
if (c.kevent() != null) {
self.active -= 1;
c.flags.state = .deleting;
self.submissions.push(c);
return;
}
}
// Inspect other operations. WARNING: the state can be ANYTHING
// here so per op be sure to check the state flag.
switch (c.op) {
.timer => |*v| {
if (c.flags.state == .active) {
// Remove from the heap so it never fires...
self.timers.remove(v);
// If we have reset set AND we got a cancellation result,
// that means that we were canceled so that we can update
// our expiration time.
if (v.reset) |r| {
v.next = r;
v.reset = null;
self.active -= 1;
self.add(c);
return;
}
}
// Add to our completions so we trigger the callback.
c.result = .{ .timer = .cancel };
self.completions.push(c);
// Note the timers state purposely remains ACTIVE so that
// when we process the completion we decrement the
// active count.
},
else => {},
}
}
/// This is the main callback for the threadpool to perform work
/// on completions for the loop.
fn thread_perform(t: *ThreadPool.Task) void {
const c: *Completion = @fieldParentPtr("task", t);
// Do our task
c.result = c.perform(null);
// Add to our completion queue
c.task_loop.thread_pool_completions.push(c);
// Wake up our main loop
c.task_loop.wakeup() catch {};
}
/// Sends an empty message to this loop's mach port so that it wakes
/// up if it is blocking on kevent().
fn wakeup(self: *Loop) !void {
try self.mach_port.notify();
}
};
/// A completion is a request to perform some work with the loop.
pub const Completion = struct {
/// Operation to execute.
op: Operation = .{ .noop = {} },
/// Userdata and callback for when the completion is finished.
userdata: ?*anyopaque = null,
callback: xev.Callback = xev.noopCallback,
//---------------------------------------------------------------
// Internal fields
/// Intrusive queue field
next: ?*Completion = null,
/// Result code of the syscall. Only used internally in certain
/// scenarios, should not be relied upon by program authors.
result: ?Result = null,
flags: packed struct {
/// Watch state of this completion. We use this to determine whether
/// we're active, adding, deleting, etc. This lets us add and delete
/// multiple times before a loop tick and handle the state properly.
state: State = .dead,
/// Set this to true to schedule this operation on the thread pool.
/// This can be set by anyone. If the operation is scheduled on
/// the thread pool then it will NOT be registered with kqueue even
/// if it is supported.
threadpool: bool = false,
} = .{},
/// If scheduled on a thread pool, this will be set. This is NOT a
/// reliable way to get access to the loop and shouldn't be used
/// except internally.
task: ThreadPool.Task = undefined,
task_loop: *Loop = undefined,
const State = enum(u3) {
/// completion is not part of any loop
dead = 0,
/// completion is in the submission queue
adding = 1,
/// completion is in the deletion queue
deleting = 2,
/// completion is submitted with kqueue successfully
active = 3,
};
/// Returns the state of this completion. There are some things to
/// be caution about when calling this function.
///
/// First, this is only safe to call from the main thread. This cannot
/// be called from any other thread.
///
/// Second, if you are using default "undefined" completions, this will
/// NOT return a valid value if you access it. You must zero your
/// completion using ".{}". You only need to zero the completion once.
/// Once the completion is in use, it will always be valid.
///
/// Third, if you stop the loop (loop.stop()), the completions registered
/// with the loop will NOT be reset to a dead state.
pub fn state(self: Completion) xev.CompletionState {
return switch (self.flags.state) {
.dead => .dead,
.adding, .deleting, .active => .active,
};
}
/// Returns a kevent for this completion, if any. Note that the
/// kevent isn't immediately useful for all event types. For example,
/// "connect" requires you to initiate the connection first.
fn kevent(self: *Completion) ?Kevent {
return switch (self.op) {
.noop => unreachable,
.cancel,
.close,
.timer,
.shutdown,
=> null,
.accept => |v| kevent_init(.{
.ident = @intCast(v.socket),
.filter = posix.system.EVFILT_READ,
.flags = posix.system.EV_ADD | posix.system.EV_ENABLE,
.fflags = 0,
.data = 0,
.udata = @intFromPtr(self),
}),
.connect => |v| kevent_init(.{
.ident = @intCast(v.socket),
.filter = posix.system.EVFILT_WRITE,
.flags = posix.system.EV_ADD | posix.system.EV_ENABLE,
.fflags = 0,
.data = 0,
.udata = @intFromPtr(self),
}),
.machport => kevent: {
// We can't use |*v| above because it crahses the Zig
// compiler (as of 0.11.0-dev.1413). We can retry another time.
const v = &self.op.machport;
const slice: []u8 = switch (v.buffer) {
.slice => |slice| slice,
.array => |*arr| arr,
};
// The kevent below waits for a machport to have a message
// available AND automatically reads the message into the
// buffer since MACH_RCV_MSG is set.
break :kevent .{
.ident = @intCast(v.port),
.filter = posix.system.EVFILT_MACHPORT,
.flags = posix.system.EV_ADD | posix.system.EV_ENABLE,
.fflags = posix.system.MACH_RCV_MSG,
.data = 0,
.udata = @intFromPtr(self),
.ext = .{ @intFromPtr(slice.ptr), slice.len },
};
},
.proc => |v| kevent_init(.{
.ident = @intCast(v.pid),
.filter = posix.system.EVFILT_PROC,
.flags = posix.system.EV_ADD | posix.system.EV_ENABLE,
.fflags = v.flags,
.data = 0,
.udata = @intFromPtr(self),
}),
inline .write, .pwrite, .send, .sendto => |v| kevent_init(.{
.ident = @intCast(v.fd),
.filter = posix.system.EVFILT_WRITE,
.flags = posix.system.EV_ADD | posix.system.EV_ENABLE,
.fflags = 0,
.data = 0,
.udata = @intFromPtr(self),
}),
inline .read, .pread, .recv, .recvfrom => |v| kevent_init(.{
.ident = @intCast(v.fd),
.filter = posix.system.EVFILT_READ,
.flags = posix.system.EV_ADD | posix.system.EV_ENABLE,
.fflags = 0,
.data = 0,
.udata = @intFromPtr(self),
}),
};
}
/// Perform the operation associated with this completion. This will
/// perform the full blocking operation for the completion.
fn perform(self: *Completion, ev_: ?*const Kevent) Result {
return switch (self.op) {
.cancel,
.close,
.noop,
.timer,
.shutdown,
=> {
log.warn("perform op={s}", .{@tagName(self.op)});
unreachable;
},
.accept => |*op| .{
.accept = if (posix.accept(
op.socket,
&op.addr,
&op.addr_size,
op.flags,
)) |v|
v
else |err|
err,
},
.connect => |*op| .{
.connect = if (posix.getsockoptError(op.socket)) {} else |err| err,
},
.write => |*op| .{
.write = switch (op.buffer) {
.slice => |v| posix.write(op.fd, v),
.array => |*v| posix.write(op.fd, v.array[0..v.len]),
},
},
.pwrite => |*op| .{
.pwrite = switch (op.buffer) {
.slice => |v| posix.pwrite(op.fd, v, op.offset),
.array => |*v| posix.pwrite(op.fd, v.array[0..v.len], op.offset),
},
},
.send => |*op| .{
.send = switch (op.buffer) {
.slice => |v| posix.send(op.fd, v, 0),
.array => |*v| posix.send(op.fd, v.array[0..v.len], 0),
},
},
.sendto => |*op| .{
.sendto = switch (op.buffer) {
.slice => |v| posix.sendto(op.fd, v, 0, &op.addr.any, op.addr.getOsSockLen()),
.array => |*v| posix.sendto(op.fd, v.array[0..v.len], 0, &op.addr.any, op.addr.getOsSockLen()),
},
},
.read => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.read(op.fd, v),
.array => |*v| posix.read(op.fd, v),
};
break :res .{
.read = if (n_) |n|
if (n == 0) error.EOF else n
else |err|
err,
};
},
.pread => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.pread(op.fd, v, op.offset),
.array => |*v| posix.pread(op.fd, v, op.offset),
};
break :res .{
.pread = if (n_) |n|
if (n == 0) error.EOF else n
else |err|
err,
};
},
.recv => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.recv(op.fd, v, 0),
.array => |*v| posix.recv(op.fd, v, 0),
};
break :res .{
.recv = if (n_) |n|
if (n == 0) error.EOF else n
else |err|
err,
};
},
.recvfrom => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.recvfrom(op.fd, v, 0, &op.addr, &op.addr_size),
.array => |*v| posix.recvfrom(op.fd, v, 0, &op.addr, &op.addr_size),
};
break :res .{
.recvfrom = if (n_) |n|
if (n == 0) error.EOF else n
else |err|
err,
};
},
// Our machport operation ALWAYS has MACH_RCV set so there
// is no operation to perform. kqueue automatically reads in
// the mach message into the read buffer.
.machport => .{
.machport = {},
},
// For proc watching, it is identical to the syscall result.
.proc => res: {
const ev = ev_ orelse break :res .{ .proc = ProcError.MissingKevent };
// If we have the exit status, we read it.
if (ev.fflags & (posix.system.NOTE_EXIT | posix.system.NOTE_EXITSTATUS) > 0) {
const data: u32 = @intCast(ev.data);
if (posix.W.IFEXITED(data)) break :res .{
.proc = posix.W.EXITSTATUS(data),
};
}
break :res .{ .proc = 0 };
},
};
}
/// Returns the error result for the given result code. This is called
/// in the situation that kqueue fails to enqueue the completion or
/// a raw syscall fails.
fn syscall_result(c: *Completion, r: i32) Result {
const errno: posix.E = if (r >= 0) .SUCCESS else @enumFromInt(-r);
return switch (c.op) {
.noop => unreachable,
.accept => .{
.accept = switch (errno) {
.SUCCESS => r,
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.connect => .{
.connect = switch (errno) {
.SUCCESS => {},
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.write => .{
.write = switch (errno) {
.SUCCESS => @intCast(r),
.CANCELED => error.Canceled,
.PERM => error.PermissionDenied,
else => |err| posix.unexpectedErrno(err),
},
},
.pwrite => .{
.pwrite = switch (errno) {
.SUCCESS => @intCast(r),
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.read => .{
.read = switch (errno) {
.SUCCESS => if (r == 0) error.EOF else @intCast(r),
.CANCELED => error.Canceled,
.PERM => error.PermissionDenied,
else => |err| posix.unexpectedErrno(err),
},
},
.pread => .{
.pread = switch (errno) {
.SUCCESS => if (r == 0) error.EOF else @intCast(r),
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.send => .{
.send = switch (errno) {
.SUCCESS => @intCast(r),
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.recv => .{
.recv = switch (errno) {
.SUCCESS => if (r == 0) error.EOF else @intCast(r),
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.sendto => .{
.sendto = switch (errno) {
.SUCCESS => @intCast(r),
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.recvfrom => .{
.recvfrom = switch (errno) {
.SUCCESS => @intCast(r),
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.machport => .{
.machport = switch (errno) {
.SUCCESS => {},
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.proc => .{
.proc = switch (errno) {
.SUCCESS => @intCast(r),
.CANCELED => error.Canceled,
.SRCH => ProcError.NoSuchProcess,
else => |err| posix.unexpectedErrno(err),
},
},
.shutdown => .{
.shutdown = switch (errno) {
.SUCCESS => {},
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.close => .{
.close = switch (errno) {
.SUCCESS => {},
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.timer => .{
.timer = switch (errno) {
// Success is impossible because timers don't execute syscalls.
.SUCCESS => unreachable,
.CANCELED => error.Canceled,
else => |err| posix.unexpectedErrno(err),
},
},
.cancel => .{
.cancel = switch (errno) {
.SUCCESS => {},
.CANCELED => error.Canceled,
// Syscall errors should not be possible since cancel
// doesn't run any syscalls.
else => |err| {
posix.unexpectedErrno(err) catch {};
unreachable;
},
},
},
};
}
};
pub const OperationType = enum {
noop,
accept,
connect,
read,
write,
pread,
pwrite,
send,
recv,
sendto,
recvfrom,
close,
shutdown,
timer,
cancel,
machport,
proc,
};
/// All the supported operations of this event loop. These are always
/// backend-specific and therefore the structure and types change depending
/// on the underlying system in use. The high level operations are
/// done by initializing the request handles.
pub const Operation = union(OperationType) {
noop: void,
accept: struct {
socket: posix.socket_t,
addr: posix.sockaddr = undefined,
addr_size: posix.socklen_t = @sizeOf(posix.sockaddr),
flags: u32 = posix.SOCK.CLOEXEC,
},
connect: struct {
socket: posix.socket_t,
addr: std.net.Address,
},
read: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
},
write: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
},
pread: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
offset: u64,
},
pwrite: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
offset: u64,
},
send: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
},
recv: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
},
// Note: this is making our Completion quite large. We can follow
// the pattern of io_uring and require another user-provided pointer
// here for state to move all this stuff out to a pointer.
sendto: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
addr: std.net.Address,
},
recvfrom: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
addr: posix.sockaddr = undefined,
addr_size: posix.socklen_t = @sizeOf(posix.sockaddr),
},
close: struct {
fd: posix.fd_t,
},
shutdown: struct {
socket: posix.socket_t,
how: posix.ShutdownHow = .both,
},
timer: Timer,
cancel: struct {
c: *Completion,
},
machport: struct {
port: posix.system.mach_port_name_t,
buffer: ReadBuffer,
},
proc: struct {
pid: posix.pid_t,
flags: u32 = posix.system.NOTE_EXIT | posix.system.NOTE_EXITSTATUS,
},
};
pub const Result = union(OperationType) {
noop: void,
accept: AcceptError!posix.socket_t,
connect: ConnectError!void,
read: ReadError!usize,
write: WriteError!usize,
pread: ReadError!usize,
pwrite: WriteError!usize,
send: WriteError!usize,
recv: ReadError!usize,
sendto: WriteError!usize,
recvfrom: ReadError!usize,
close: CloseError!void,
shutdown: ShutdownError!void,
timer: TimerError!TimerTrigger,
cancel: CancelError!void,
machport: MachPortError!void,
proc: ProcError!u32,
};
pub const CancelError = error{
Canceled,
};
pub const AcceptError = posix.KEventError || posix.AcceptError || error{
Canceled,
Unexpected,
};
pub const ConnectError = posix.KEventError || posix.ConnectError || error{
Canceled,
Unexpected,
};
pub const ReadError = posix.KEventError ||
posix.ReadError ||
posix.PReadError ||
posix.RecvFromError ||
error{
EOF,
Canceled,
PermissionDenied,
Unexpected,
};
pub const WriteError = posix.KEventError ||
posix.WriteError ||
posix.PWriteError ||
posix.SendError ||
posix.SendMsgError ||
posix.SendToError ||
error{
Canceled,
PermissionDenied,
Unexpected,
};
pub const MachPortError = posix.KEventError || error{
Canceled,
Unexpected,
};
pub const ProcError = posix.KEventError || error{
Canceled,
MissingKevent,
Unexpected,
NoSuchProcess,
};
pub const ShutdownError = posix.ShutdownError || error{
Canceled,
Unexpected,
};
pub const CloseError = error{
Canceled,
Unexpected,
};
pub const TimerError = error{
Canceled,
Unexpected,
};
pub const TimerTrigger = enum {
/// Unused with epoll
request,
/// Timer expired.
expiration,
/// Timer was canceled.
cancel,
};
/// ReadBuffer are the various options for reading.
pub const ReadBuffer = union(enum) {
/// Read into this slice.
slice: []u8,
/// Read into this array, just set this to undefined and it will
/// be populated up to the size of the array. This is an option because
/// the other union members force a specific size anyways so this lets us
/// use the other size in the union to support small reads without worrying
/// about buffer allocation.
///
/// To know the size read you have to use the return value of the
/// read operations (i.e. recv).
///
/// Note that the union at the time of this writing could accomodate a
/// much larger fixed size array here but we want to retain flexiblity
/// for future fields.
array: [32]u8,
// TODO: future will have vectors
};
/// WriteBuffer are the various options for writing.
pub const WriteBuffer = union(enum) {
/// Write from this buffer.
slice: []const u8,
/// Write from this array. See ReadBuffer.array for why we support this.
array: struct {
array: [32]u8,
len: usize,
},
// TODO: future will have vectors
};
/// Timer that is inserted into the heap.
const Timer = struct {
/// The absolute time to fire this timer next.
next: posix.timespec,
/// Only used internally. If this is non-null and timer is
/// CANCELLED, then the timer is rearmed automatically with this
/// as the next time. The callback will not be called on the
/// cancellation.
reset: ?posix.timespec = null,
/// Internal heap fields.
heap: heap.IntrusiveField(Timer) = .{},
/// We point back to completion for now. When issue[1] is fixed,
/// we can juse use that from our heap fields.
/// [1]: https://github.com/ziglang/zig/issues/6611
c: *Completion = undefined,
fn less(_: void, a: *const Timer, b: *const Timer) bool {
return a.ns() < b.ns();
}
/// Returns the nanoseconds of this timer. Note that maxInt(u64) ns is
/// 584 years so if we get any overflows we just use maxInt(u64). If
/// any software is running in 584 years waiting on this timer...
/// shame on me I guess... but I'll be dead.
fn ns(self: *const Timer) u64 {
assert(self.next.tv_sec >= 0);
assert(self.next.tv_nsec >= 0);
const max = std.math.maxInt(u64);
const s_ns = std.math.mul(
u64,
@as(u64, @intCast(self.next.tv_sec)),
std.time.ns_per_s,
) catch return max;
return std.math.add(u64, s_ns, @as(u64, @intCast(self.next.tv_nsec))) catch
return max;
}
};
/// Kevent is either kevent_s or kevent64_s depending on the target platform.
/// This lets us support both Mac and non-Mac platforms.
const Kevent = switch (builtin.os.tag) {
.ios, .macos => posix.system.kevent64_s,
else => @compileError("kqueue not supported yet for target OS"),
};
/// kevent calls either kevent or kevent64 depending on the
/// target platform.
fn kevent_syscall(
kq: i32,
changelist: []const Kevent,
eventlist: []Kevent,
timeout: ?*const posix.timespec,
) posix.KEventError!usize {
// Normaly Kevent? Just use the normal posix.kevent call.
if (Kevent == posix.Kevent) return try posix.kevent(
kq,
changelist,
eventlist,
timeout,
);
// Otherwise, we have to call the kevent64 variant.
while (true) {
const rc = posix.system.kevent64(
kq,
changelist.ptr,
std.math.cast(c_int, changelist.len) orelse return error.Overflow,
eventlist.ptr,
std.math.cast(c_int, eventlist.len) orelse return error.Overflow,
0,
timeout,
);
switch (posix.errno(rc)) {
.SUCCESS => return @intCast(rc),
.ACCES => return error.AccessDenied,
.FAULT => unreachable,
.BADF => unreachable, // Always a race condition.
.INTR => continue,
.INVAL => unreachable,
.NOENT => return error.EventNotFound,
.NOMEM => return error.SystemResources,
.SRCH => return error.ProcessNotFound,
else => unreachable,
}
}
}
/// kevent_init initializes a Kevent from an posix.Kevent. This is used when
/// the "ext" fields are zero.
inline fn kevent_init(ev: posix.Kevent) Kevent {
if (Kevent == posix.Kevent) return ev;
return .{
.ident = ev.ident,
.filter = ev.filter,
.flags = ev.flags,
.fflags = ev.fflags,
.data = ev.data,
.udata = ev.udata,
.ext = .{ 0, 0 },
};
}
comptime {
if (@sizeOf(Completion) != 256) {
@compileLog(@sizeOf(Completion));
unreachable;
}
}
test "kqueue: loop time" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// should never init zero
const now = loop.now();
try testing.expect(now > 0);
// should update on a loop tick
while (now == loop.now()) try loop.run(.no_wait);
}
test "kqueue: stop" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var called = false;
var c1: Completion = undefined;
loop.timer(&c1, 1_000_000, &called, (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, _: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = r;
const b: *bool = @ptrCast(ud.?);
b.* = true;
return .disarm;
}
}).callback);
// Tick
try loop.run(.no_wait);
try testing.expect(!called);
// Stop
loop.stop();
try loop.run(.until_done);
try testing.expect(!called);
}
test "kqueue: timer" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var called = false;
var c1: xev.Completion = undefined;
loop.timer(&c1, 1, &called, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = r;
const b: *bool = @ptrCast(ud.?);
b.* = true;
return .disarm;
}
}).callback);
// Add another timer
var called2 = false;
var c2: xev.Completion = undefined;
loop.timer(&c2, 100_000, &called2, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = r;
const b: *bool = @ptrCast(ud.?);
b.* = true;
return .disarm;
}
}).callback);
// State checking
try testing.expect(c1.state() == .active);
try testing.expect(c2.state() == .active);
// Tick
while (!called) try loop.run(.no_wait);
try testing.expect(called);
try testing.expect(!called2);
// State checking
try testing.expect(c1.state() == .dead);
try testing.expect(c2.state() == .active);
}
test "kqueue: timer reset" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v: *?TimerTrigger = @ptrCast(ud.?);
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, cb);
// We know timer won't be called from the timer test previously.
try loop.run(.no_wait);
try testing.expect(trigger == null);
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .active);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "kqueue: timer reset before tick" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v: *?TimerTrigger = @ptrCast(ud.?);
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, cb);
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .dead);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "kqueue: timer reset after trigger" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v: *?TimerTrigger = @ptrCast(ud.?);
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 1, &trigger, cb);
// Run the timer
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
trigger = null;
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .dead);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "kqueue: timer cancellation" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: xev.Completion = undefined;
loop.timer(&c1, 100_000, &trigger, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const ptr: *?TimerTrigger = @ptrCast(@alignCast(ud.?));
ptr.* = r.timer catch unreachable;
return .disarm;
}
}).callback);
// Tick and verify we're not called.
try loop.run(.no_wait);
try testing.expect(trigger == null);
// Cancel the timer
var called = false;
var c_cancel: xev.Completion = .{
.op = .{
.cancel = .{
.c = &c1,
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.cancel catch unreachable;
const ptr: *bool = @ptrCast(@alignCast(ud.?));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel);
// Tick
try loop.run(.until_done);
try testing.expect(called);
try testing.expect(trigger.? == .cancel);
}
test "kqueue: canceling a completed operation" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: xev.Completion = undefined;
loop.timer(&c1, 1, &trigger, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const ptr: *?TimerTrigger = @ptrCast(@alignCast(ud.?));
ptr.* = r.timer catch unreachable;
return .disarm;
}
}).callback);
// Tick and verify we're not called.
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
// Cancel the timer
var called = false;
var c_cancel: xev.Completion = .{
.op = .{
.cancel = .{
.c = &c1,
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.cancel catch unreachable;
const ptr: *bool = @ptrCast(@alignCast(ud.?));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel);
// Tick
try loop.run(.until_done);
try testing.expect(called);
try testing.expect(trigger.? == .expiration);
}
test "kqueue: socket accept/connect/send/recv/close" {
const mem = std.mem;
const net = std.net;
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a TCP server socket
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const kernel_backlog = 1;
var ln = try posix.socket(address.any.family, posix.SOCK.STREAM | posix.SOCK.CLOEXEC, 0);
errdefer posix.close(ln);
try posix.setsockopt(ln, posix.SOL.SOCKET, posix.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try posix.bind(ln, &address.any, address.getOsSockLen());
try posix.listen(ln, kernel_backlog);
// Create a TCP client socket
var client_conn = try posix.socket(
address.any.family,
posix.SOCK.NONBLOCK | posix.SOCK.STREAM | posix.SOCK.CLOEXEC,
0,
);
errdefer posix.close(client_conn);
// Accept
var server_conn: posix.socket_t = 0;
var c_accept: Completion = .{
.op = .{
.accept = .{
.socket = ln,
},
},
.userdata = &server_conn,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const conn = @as(*posix.socket_t, @ptrCast(@alignCast(ud.?)));
conn.* = r.accept catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_accept);
// Connect
var connected = false;
var c_connect: xev.Completion = .{
.op = .{
.connect = .{
.socket = client_conn,
.addr = address,
},
},
.userdata = &connected,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.connect catch unreachable;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_connect);
// Wait for the connection to be established
try loop.run(.until_done);
try testing.expect(server_conn > 0);
try testing.expect(connected);
// Send
var c_send: xev.Completion = .{
.op = .{
.send = .{
.fd = client_conn,
.buffer = .{ .slice = &[_]u8{ 1, 1, 2, 3, 5, 8, 13 } },
},
},
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.send catch unreachable;
_ = ud;
return .disarm;
}
}).callback,
};
loop.add(&c_send);
// Receive
var recv_buf: [128]u8 = undefined;
var recv_len: usize = 0;
var c_recv: xev.Completion = .{
.op = .{
.recv = .{
.fd = server_conn,
.buffer = .{ .slice = &recv_buf },
},
},
.userdata = &recv_len,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*usize, @ptrCast(@alignCast(ud.?)));
ptr.* = r.recv catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_recv);
// Wait for the send/receive
try loop.run(.until_done);
try testing.expectEqualSlices(u8, c_send.op.send.buffer.slice, recv_buf[0..recv_len]);
// Shutdown
var shutdown = false;
var c_client_shutdown: xev.Completion = .{
.op = .{
.shutdown = .{
.socket = client_conn,
},
},
.userdata = &shutdown,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.shutdown catch unreachable;
const ptr = @as(*bool, @ptrCast(@alignCast(ud.?)));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_client_shutdown);
try loop.run(.until_done);
try testing.expect(shutdown);
// Read should be EOF
var eof: ?bool = null;
c_recv = .{
.op = .{
.recv = .{
.fd = server_conn,
.buffer = .{ .slice = &recv_buf },
},
},
.userdata = &eof,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*?bool, @ptrCast(@alignCast(ud.?)));
ptr.* = if (r.recv) |_| false else |err| switch (err) {
error.EOF => true,
else => false,
};
return .disarm;
}
}).callback,
};
loop.add(&c_recv);
try loop.run(.until_done);
try testing.expect(eof.? == true);
// Close
var c_client_close: xev.Completion = .{
.op = .{
.close = .{
.fd = client_conn,
},
},
.userdata = &client_conn,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.close catch unreachable;
const ptr = @as(*posix.socket_t, @ptrCast(@alignCast(ud.?)));
ptr.* = 0;
return .disarm;
}
}).callback,
};
loop.add(&c_client_close);
var c_server_close: xev.Completion = .{
.op = .{
.close = .{
.fd = ln,
},
},
.userdata = &ln,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.close catch unreachable;
const ptr = @as(*posix.socket_t, @ptrCast(@alignCast(ud.?)));
ptr.* = 0;
return .disarm;
}
}).callback,
};
loop.add(&c_server_close);
// Wait for the sockets to close
try loop.run(.until_done);
try testing.expect(ln == 0);
try testing.expect(client_conn == 0);
}
test "kqueue: file IO on thread pool" {
const testing = std.testing;
var tpool = main.ThreadPool.init(.{});
defer tpool.deinit();
defer tpool.shutdown();
var loop = try Loop.init(.{ .thread_pool = &tpool });
defer loop.deinit();
// Create our file
const path = "test_watcher_file";
const f = try std.fs.cwd().createFile(path, .{
.read = true,
.truncate = true,
});
defer f.close();
defer std.fs.cwd().deleteFile(path) catch {};
// Perform a write and then a read
var write_buf = [_]u8{ 1, 1, 2, 3, 5, 8, 13 };
var c_write: xev.Completion = .{
.op = .{
.write = .{
.fd = f.handle,
.buffer = .{ .slice = &write_buf },
},
},
.flags = .{ .threadpool = true },
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = ud;
_ = l;
_ = c;
_ = r.write catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_write);
// Wait for the write
try loop.run(.until_done);
// Make sure the data is on disk
try f.sync();
const f2 = try std.fs.cwd().openFile(path, .{});
defer f2.close();
// Read
var read_buf: [128]u8 = undefined;
var read_len: usize = 0;
var c_read: xev.Completion = .{
.op = .{
.read = .{
.fd = f2.handle,
.buffer = .{ .slice = &read_buf },
},
},
.flags = .{ .threadpool = true },
.userdata = &read_len,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*usize, @ptrCast(@alignCast(ud.?)));
ptr.* = r.read catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_read);
// Wait for the send/receive
try loop.run(.until_done);
try testing.expectEqualSlices(u8, &write_buf, read_buf[0..read_len]);
}
test "kqueue: mach port" {
if (builtin.os.tag != .macos) return error.SkipZigTest;
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Allocate the port
const mach_self = posix.system.mach_task_self();
var mach_port: posix.system.mach_port_name_t = undefined;
try testing.expectEqual(
posix.system.KernE.SUCCESS,
posix.system.getKernError(posix.system.mach_port_allocate(
mach_self,
@intFromEnum(posix.system.MACH_PORT_RIGHT.RECEIVE),
&mach_port,
)),
);
defer _ = posix.system.mach_port_deallocate(mach_self, mach_port);
// Add the waiter
var called = false;
var c_wait: xev.Completion = .{
.op = .{
.machport = .{
.port = mach_port,
.buffer = .{ .array = undefined },
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.machport catch unreachable;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_wait);
// Tick so we submit... should not call since we never sent.
try loop.run(.no_wait);
try testing.expect(!called);
// Send a message to the port
var msg: posix.system.mach_msg_header_t = .{
.msgh_bits = @intFromEnum(posix.system.MACH_MSG_TYPE.MAKE_SEND_ONCE),
.msgh_size = @sizeOf(posix.system.mach_msg_header_t),
.msgh_remote_port = mach_port,
.msgh_local_port = posix.system.MACH_PORT_NULL,
.msgh_voucher_port = undefined,
.msgh_id = undefined,
};
try testing.expectEqual(posix.system.MachMsgE.SUCCESS, posix.system.getMachMsgError(
posix.system.mach_msg(
&msg,
posix.system.MACH_SEND_MSG,
msg.msgh_size,
0,
posix.system.MACH_PORT_NULL,
posix.system.MACH_MSG_TIMEOUT_NONE,
posix.system.MACH_PORT_NULL,
),
));
// We should receive now!
try loop.run(.until_done);
try testing.expect(called);
// We should not receive again
called = false;
loop.add(&c_wait);
// Tick so we submit... should not call since we never sent.
try loop.run(.no_wait);
try testing.expect(!called);
}
test "kqueue: socket accept/cancel cancellation should decrease active count" {
const mem = std.mem;
const net = std.net;
const testing = std.testing;
//if (true) return error.SkipZigTest;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a TCP server socket
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const kernel_backlog = 1;
var ln = try posix.socket(address.any.family, posix.SOCK.STREAM | posix.SOCK.CLOEXEC, 0);
errdefer posix.close(ln);
try posix.setsockopt(ln, posix.SOL.SOCKET, posix.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try posix.bind(ln, &address.any, address.getOsSockLen());
try posix.listen(ln, kernel_backlog);
// Accept
var server_conn: posix.socket_t = 0;
var c_accept: Completion = .{
.op = .{
.accept = .{
.socket = ln,
},
},
.userdata = &server_conn,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
_: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = ud;
_ = r.accept catch |err| switch (err) {
error.Canceled => {},
else => @panic("wrong"),
};
return .disarm;
}
}).callback,
};
loop.add(&c_accept);
try loop.run(.no_wait);
try testing.expectEqual(@as(usize, 1), loop.active);
var cancel_called = false;
var c_cancel: Completion = .{
.op = .{
.cancel = .{
.c = &c_accept,
},
},
.userdata = &cancel_called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
_: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = r.cancel catch unreachable;
const ptr = @as(*?bool, @ptrCast(@alignCast(ud.?)));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel);
try testing.expectEqual(@as(usize, 2), loop.active);
try loop.run(.once);
try testing.expect(cancel_called);
// Both callbacks are called active count should be 0
try testing.expectEqual(@as(usize, 0), loop.active);
var c_server_close: xev.Completion = .{
.op = .{
.close = .{
.fd = ln,
},
},
.userdata = &ln,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.close catch unreachable;
const ptr = @as(*posix.socket_t, @ptrCast(@alignCast(ud.?)));
ptr.* = 0;
return .disarm;
}
}).callback,
};
loop.add(&c_server_close);
// Wait for the sockets to close
try loop.run(.until_done);
try testing.expect(ln == 0);
}
|
0 | repos/libxev/src | repos/libxev/src/backend/epoll.zig | const std = @import("std");
const assert = std.debug.assert;
const linux = std.os.linux;
const posix = std.posix;
const queue = @import("../queue.zig");
const queue_mpsc = @import("../queue_mpsc.zig");
const heap = @import("../heap.zig");
const main = @import("../main.zig");
const xev = main.Epoll;
const ThreadPool = main.ThreadPool;
/// Epoll backend.
///
/// WARNING: this backend is a bit of a mess. It is missing features and in
/// general is in much poorer quality than all of the other backends. It
/// isn't meant to really be used yet. We should remodel this in the style of
/// the kqueue backend.
pub const Loop = struct {
const TimerHeap = heap.Intrusive(Operation.Timer, void, Operation.Timer.less);
const TaskCompletionQueue = queue_mpsc.Intrusive(Completion);
fd: posix.fd_t,
/// The number of active completions. This DOES NOT include completions that
/// are queued in the submissions queue.
active: usize = 0,
/// Our queue of submissions that we want to enqueue on the next tick.
submissions: queue.Intrusive(Completion) = .{},
/// The queue for completions to delete from the epoll fd.
deletions: queue.Intrusive(Completion) = .{},
/// Heap of timers.
timers: TimerHeap = .{ .context = {} },
/// The thread pool to use for blocking operations that epoll can't do.
thread_pool: ?*ThreadPool,
/// The MPSC queue for completed completions from the thread pool.
thread_pool_completions: TaskCompletionQueue,
/// Cached time
cached_now: posix.timespec,
/// Some internal fields we can pack for better space.
flags: packed struct {
/// True once it is initialized.
init: bool = false,
/// Whether we're in a run or not (to prevent nested runs).
in_run: bool = false,
/// Whether our loop is in a stopped state or not.
stopped: bool = false,
} = .{},
pub fn init(options: xev.Options) !Loop {
var res: Loop = .{
.fd = try posix.epoll_create1(std.os.linux.EPOLL.CLOEXEC),
.thread_pool = options.thread_pool,
.thread_pool_completions = undefined,
.cached_now = undefined,
};
res.update_now();
return res;
}
pub fn deinit(self: *Loop) void {
posix.close(self.fd);
}
/// Run the event loop. See RunMode documentation for details on modes.
/// Once the loop is run, the pointer MUST remain stable.
pub fn run(self: *Loop, mode: xev.RunMode) !void {
switch (mode) {
.no_wait => try self.tick(0),
.once => try self.tick(1),
.until_done => while (!self.done()) try self.tick(1),
}
}
fn done(self: *Loop) bool {
return self.flags.stopped or (self.active == 0 and
self.submissions.empty());
}
/// Stop the loop. This can only be called from the main thread.
/// This will stop the loop forever. Future ticks will do nothing.
///
/// This does NOT stop any completions that are queued to be executed
/// in the thread pool. If you are using a thread pool, completions
/// are not safe to recover until the thread pool is shut down. If
/// you're not using a thread pool, all completions are safe to
/// read/write once any outstanding `run` or `tick` calls are returned.
pub fn stop(self: *Loop) void {
self.flags.stopped = true;
}
/// Add a completion to the loop.
pub fn add(self: *Loop, completion: *Completion) void {
switch (completion.flags.state) {
// Already adding, forget about it.
.adding => return,
// If it is dead we're good. If we're deleting we'll ignore it
// while we're processing.
.dead,
.deleting,
=> {},
.active => unreachable,
}
completion.flags.state = .adding;
// We just add the completion to the queue. Failures can happen
// at tick time...
self.submissions.push(completion);
}
/// Delete a completion from the loop.
pub fn delete(self: *Loop, completion: *Completion) void {
switch (completion.flags.state) {
// Already deleted
.deleting => return,
// If we're active then we will stop it and remove from epoll.
// If we're adding then we'll ignore it when adding.
.dead, .active, .adding => {},
}
completion.flags.state = .deleting;
self.deletions.push(completion);
}
/// Returns the "loop" time in milliseconds. The loop time is updated
/// once per loop tick, before IO polling occurs. It remains constant
/// throughout callback execution.
///
/// You can force an update of the "now" value by calling update_now()
/// at any time from the main thread.
///
/// The clock that is used is not guaranteed. In general, a monotonic
/// clock source is always used if available. This value should typically
/// just be used for relative time calculations within the loop, such as
/// answering the question "did this happen <x> ms ago?".
pub fn now(self: *Loop) i64 {
// If anything overflows we just return the max value.
const max = std.math.maxInt(i64);
// Calculate all the values, being careful about overflows in order
// to just return the maximum value.
const sec = std.math.mul(isize, self.cached_now.tv_sec, std.time.ms_per_s) catch return max;
const nsec = @divFloor(self.cached_now.tv_nsec, std.time.ns_per_ms);
return std.math.lossyCast(i64, sec +| nsec);
}
/// Update the cached time.
pub fn update_now(self: *Loop) void {
posix.clock_gettime(posix.CLOCK.MONOTONIC, &self.cached_now) catch {};
}
/// Add a timer to the loop. The timer will execute in "next_ms". This
/// is oneshot: the timer will not repeat. To repeat a timer, either
/// schedule another in your callback or return rearm from the callback.
pub fn timer(
self: *Loop,
c: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
c.* = .{
.op = .{
.timer = .{
.next = self.timer_next(next_ms),
},
},
.userdata = userdata,
.callback = cb,
};
self.add(c);
}
/// See io_uring.timer_reset for docs.
pub fn timer_reset(
self: *Loop,
c: *Completion,
c_cancel: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
switch (c.flags.state) {
.dead, .deleting => {
self.timer(c, next_ms, userdata, cb);
return;
},
// Adding state we can just modify the metadata and return
// since the timer isn't in the heap yet.
.adding => {
c.op.timer.next = self.timer_next(next_ms);
c.userdata = userdata;
c.callback = cb;
return;
},
.active => {
// Update the reset time for the timer to the desired time
// along with all the callbacks.
c.op.timer.reset = self.timer_next(next_ms);
c.userdata = userdata;
c.callback = cb;
// If the cancellation is active, we assume its for this timer
// and do nothing.
if (c_cancel.state() == .active) return;
assert(c_cancel.state() == .dead and c.state() == .active);
c_cancel.* = .{ .op = .{ .cancel = .{ .c = c } } };
self.add(c_cancel);
},
}
}
fn timer_next(self: *Loop, next_ms: u64) posix.timespec {
// Get the timestamp of the absolute time that we'll execute this timer.
// There are lots of failure scenarios here in math. If we see any
// of them we just use the maximum value.
const max: posix.timespec = .{
.tv_sec = std.math.maxInt(isize),
.tv_nsec = std.math.maxInt(isize),
};
const next_s = std.math.cast(isize, next_ms / std.time.ms_per_s) orelse
return max;
const next_ns = std.math.cast(
isize,
(next_ms % std.time.ms_per_s) * std.time.ns_per_ms,
) orelse return max;
return .{
.tv_sec = std.math.add(isize, self.cached_now.tv_sec, next_s) catch
return max,
.tv_nsec = std.math.add(isize, self.cached_now.tv_nsec, next_ns) catch
return max,
};
}
/// Tick through the event loop once, waiting for at least "wait" completions
/// to be processed by the loop itself.
pub fn tick(self: *Loop, wait: u32) !void {
// If we're stopped then the loop is fully over.
if (self.flags.stopped) return;
// We can't nest runs.
if (self.flags.in_run) return error.NestedRunsNotAllowed;
self.flags.in_run = true;
defer self.flags.in_run = false;
// Initialize
if (!self.flags.init) {
self.flags.init = true;
if (self.thread_pool != null) {
self.thread_pool_completions.init();
}
}
// Submit all the submissions. We copy the submission queue so that
// any resubmits don't cause an infinite loop.
var queued = self.submissions;
self.submissions = .{};
while (queued.pop()) |c| {
// We ignore any completions that aren't in the adding state.
// This usually means that we switched them to be deleted or
// something.
if (c.flags.state != .adding) continue;
self.start(c);
}
// Handle all deletions so we don't wait for them.
while (self.deletions.pop()) |c| {
if (c.flags.state != .deleting) continue;
self.stop_completion(c);
}
// If we have no active handles then we return no matter what.
if (self.active == 0) {
// We still have to update our concept of "now".
self.update_now();
return;
}
// Wait and process events. We only do this if we have any active.
var events: [1024]linux.epoll_event = undefined;
var wait_rem: usize = @intCast(wait);
while (self.active > 0 and (wait == 0 or wait_rem > 0)) {
self.update_now();
const now_timer: Operation.Timer = .{ .next = self.cached_now };
// Run our expired timers
while (self.timers.peek()) |t| {
if (!Operation.Timer.less({}, t, &now_timer)) break;
// Remove the timer
assert(self.timers.deleteMin().? == t);
// Mark completion as done
const c = t.c;
c.flags.state = .dead;
self.active -= 1;
// Lower our remaining count
wait_rem -|= 1;
// Invoke
const action = c.callback(c.userdata, self, c, .{
.timer = .expiration,
});
switch (action) {
.disarm => {},
.rearm => self.start(c),
}
}
// Run our completed thread pool work
if (self.thread_pool != null) {
while (self.thread_pool_completions.pop()) |c| {
// Mark completion as done
c.flags.state = .dead;
self.active -= 1;
// Lower our remaining count
wait_rem -|= 1;
// Invoke
const action = c.callback(c.userdata, self, c, c.task_result);
switch (action) {
.disarm => {},
.rearm => self.start(c),
}
}
}
// Determine our next timeout based on the timers
const timeout: i32 = if (wait_rem == 0) 0 else timeout: {
// If we have a timer, we want to set the timeout to our next
// timer value. If we have no timer, we wait forever.
// TODO: do not wait 100ms here, use an eventfd for our
// thread pool to wake us up.
const t = self.timers.peek() orelse break :timeout 100;
// Determine the time in milliseconds.
const ms_now = @as(u64, @intCast(self.cached_now.tv_sec)) * std.time.ms_per_s +
@as(u64, @intCast(self.cached_now.tv_nsec)) / std.time.ns_per_ms;
const ms_next = @as(u64, @intCast(t.next.tv_sec)) * std.time.ms_per_s +
@as(u64, @intCast(t.next.tv_nsec)) / std.time.ns_per_ms;
break :timeout @as(i32, @intCast(ms_next -| ms_now));
};
const n = posix.epoll_wait(self.fd, &events, timeout);
if (n < 0) {
switch (posix.errno(n)) {
.INTR => continue,
else => |err| return posix.unexpectedErrno(err),
}
}
// Process all our events and invoke their completion handlers
for (events[0..n]) |ev| {
const c: *Completion = @ptrFromInt(@as(usize, @intCast(ev.data.ptr)));
// We get the fd and mark this as in progress we can properly
// clean this up late.r
const fd = if (c.flags.dup) c.flags.dup_fd else c.fd();
const close_dup = c.flags.dup;
c.flags.state = .dead;
const res = c.perform();
const action = c.callback(c.userdata, self, c, res);
switch (action) {
.disarm => {
// We can't use self.stop because we can't trust
// that c is still a valid pointer.
if (fd) |v| {
posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_DEL,
v,
null,
) catch unreachable;
if (close_dup) {
posix.close(v);
}
}
self.active -= 1;
},
// For epoll, epoll remains armed by default. We have to
// reset the state, that is all.
.rearm => c.flags.state = .active,
}
}
if (wait == 0) break;
wait_rem -|= n;
}
}
/// Shedule a completion to run on a thread.
fn thread_schedule(self: *Loop, c: *Completion) !void {
const pool = self.thread_pool orelse return error.ThreadPoolRequired;
// Setup our completion state so that thread_perform can do stuff
c.task_completions = &self.thread_pool_completions;
c.task = .{ .callback = Loop.thread_perform };
// We need to mark this completion as active before we schedule.
c.flags.state = .active;
self.active += 1;
// Schedule it, from this point forward its not safe to touch c.
pool.schedule(ThreadPool.Batch.from(&c.task));
}
/// This is the main callback for the threadpool to perform work
/// on completions for the loop.
fn thread_perform(t: *ThreadPool.Task) void {
const c: *Completion = @fieldParentPtr("task", t);
// Do our task
c.task_result = c.perform();
// Add to our completion queue
c.task_completions.push(c);
}
fn start(self: *Loop, completion: *Completion) void {
const res_: ?Result = switch (completion.op) {
.noop => {
completion.flags.state = .dead;
return;
},
.cancel => |v| res: {
if (completion.flags.threadpool) {
break :res .{ .cancel = error.ThreadPoolUnsupported };
}
// We stop immediately. We only stop if we are in the
// "adding" state because cancellation or any other action
// means we're complete already.
if (completion.flags.state == .adding) {
if (v.c.op == .cancel) @panic("cannot cancel a cancellation");
self.stop_completion(v.c);
}
// We always run timers
break :res .{ .cancel = {} };
},
.accept => res: {
var ev: linux.epoll_event = .{
.events = linux.EPOLL.IN,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .accept = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .accept = err };
},
.connect => |*v| res: {
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .connect = err };
if (posix.connect(fd, &v.addr.any, v.addr.getOsSockLen())) {
break :res .{ .connect = {} };
} else |err| switch (err) {
// If we would block then we register with epoll
error.WouldBlock => {},
// Any other error we just return immediately
else => break :res .{ .connect = err },
}
// If connect returns WouldBlock then we register for OUT events
// and are notified of connection completion that way.
var ev: linux.epoll_event = .{
.events = linux.EPOLL.OUT,
.data = .{ .ptr = @intFromPtr(completion) },
};
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .connect = err };
},
.read => res: {
if (completion.flags.threadpool) {
if (self.thread_schedule(completion)) |_|
return
else |err|
break :res .{ .read = err };
}
var ev: linux.epoll_event = .{
.events = linux.EPOLL.IN | linux.EPOLL.RDHUP,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .read = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .read = err };
},
.pread => res: {
if (completion.flags.threadpool) {
if (self.thread_schedule(completion)) |_|
return
else |err|
break :res .{ .read = err };
}
var ev: linux.epoll_event = .{
.events = linux.EPOLL.IN | linux.EPOLL.RDHUP,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .read = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .read = err };
},
.write => res: {
if (completion.flags.threadpool) {
if (self.thread_schedule(completion)) |_|
return
else |err|
break :res .{ .write = err };
}
var ev: linux.epoll_event = .{
.events = linux.EPOLL.OUT,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .write = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .write = err };
},
.pwrite => res: {
if (completion.flags.threadpool) {
if (self.thread_schedule(completion)) |_|
return
else |err|
break :res .{ .write = err };
}
var ev: linux.epoll_event = .{
.events = linux.EPOLL.OUT,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .write = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .write = err };
},
.send => res: {
var ev: linux.epoll_event = .{
.events = linux.EPOLL.OUT,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .send = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .send = err };
},
.recv => res: {
var ev: linux.epoll_event = .{
.events = linux.EPOLL.IN | linux.EPOLL.RDHUP,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .recv = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .recv = err };
},
.sendmsg => |*v| res: {
if (v.buffer) |_| {
@panic("TODO: sendmsg with buffer");
}
var ev: linux.epoll_event = .{
.events = linux.EPOLL.OUT,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .sendmsg = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .sendmsg = err };
},
.recvmsg => res: {
var ev: linux.epoll_event = .{
.events = linux.EPOLL.IN | linux.EPOLL.RDHUP,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .recvmsg = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .recvmsg = err };
},
.close => |v| res: {
posix.close(v.fd);
break :res .{ .close = {} };
},
.shutdown => |v| res: {
break :res .{ .shutdown = posix.shutdown(v.socket, v.how) };
},
.timer => |*v| res: {
// Point back to completion since we need this. In the future
// we want to use @fieldParentPtr but https://github.com/ziglang/zig/issues/6611
v.c = completion;
// Insert the timer into our heap.
self.timers.insert(v);
// We always run timers
break :res null;
},
.poll => |v| res: {
var ev: linux.epoll_event = .{
.events = v.events,
.data = .{ .ptr = @intFromPtr(completion) },
};
const fd = completion.fd_maybe_dup() catch |err| break :res .{ .poll = err };
break :res if (posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_ADD,
fd,
&ev,
)) null else |err| .{ .poll = err };
},
};
// If we failed to add the completion then we call the callback
// immediately and mark the error.
if (res_) |res| {
completion.flags.state = .dead;
switch (completion.callback(
completion.userdata,
self,
completion,
res,
)) {
.disarm => {},
// If we rearm then we requeue this. Due to the way that tick works,
// this won't try to re-add immediately it won't happen until the
// next tick.
.rearm => self.add(completion),
}
return;
}
// If the completion was requested on a threadpool we should
// never reach her.
assert(!completion.flags.threadpool);
// Mark the completion as active if we reached this point
completion.flags.state = .active;
// Increase our active count
self.active += 1;
}
fn stop_completion(self: *Loop, completion: *Completion) void {
// Delete. This should never fail.
const maybe_fd = if (completion.flags.dup) completion.flags.dup_fd else completion.fd();
if (maybe_fd) |fd| {
posix.epoll_ctl(
self.fd,
linux.EPOLL.CTL_DEL,
fd,
null,
) catch unreachable;
} else switch (completion.op) {
.timer => |*v| {
const c = v.c;
if (c.flags.state == .active) {
// Timers needs to be removed from the timer heap.
self.timers.remove(v);
}
// If the timer was never fired, we need to fire it with
// the cancellation notice.
if (c.flags.state != .dead) {
// If we have reset set AND we got a cancellation result,
// that means that we were canceled so that we can update
// our expiration time.
if (v.reset) |r| {
v.next = r;
v.reset = null;
self.active -= 1;
self.start(c);
return;
}
const action = c.callback(c.userdata, self, c, .{ .timer = .cancel });
switch (action) {
.disarm => {},
.rearm => {
self.active -= 1;
self.start(c);
return;
},
}
}
},
else => unreachable,
}
// Decrement the active count so we know how many are running for
// .until_done run semantics.
if (completion.flags.state == .active) self.active -= 1;
// Mark the completion as done
completion.flags.state = .dead;
}
};
pub const Completion = struct {
/// Operation to execute. This is only safe to read BEFORE the completion
/// is queued. After being queued (with "add"), the operation may change.
op: Operation = .{ .noop = {} },
/// Userdata and callback for when the completion is finished.
userdata: ?*anyopaque = null,
callback: xev.Callback = xev.noopCallback,
//---------------------------------------------------------------
// Internal fields
/// If scheduled on a thread pool, this will be set. This is NOT a
/// reliable way to get access to the loop and shouldn't be used
/// except internally.
task: ThreadPool.Task = undefined,
task_completions: *Loop.TaskCompletionQueue = undefined,
task_result: Result = undefined,
flags: packed struct {
/// Watch state of this completion. We use this to determine whether
/// we're active, adding, deleting, etc. This lets us add and delete
/// multiple times before a loop tick and handle the state properly.
state: State = .dead,
/// Schedule this onto the threadpool rather than epoll. Not all
/// operations support this.
threadpool: bool = false,
/// Set to true to dup the file descriptor for the operation prior
/// to setting it up with epoll. This is a hack to make it so that
/// a completion can represent a single op per fd, since epoll requires
/// a single fd for multiple ops. We don't want to track that esp
/// since epoll isn't the primary Linux interface.
dup: bool = false,
dup_fd: posix.fd_t = 0,
} = .{},
/// Intrusive queue field
next: ?*Completion = null,
const State = enum(u3) {
/// completion is not part of any loop
dead = 0,
/// completion is in the submission queue
adding = 1,
/// completion is in the deletion queue
deleting = 2,
/// completion is registered with epoll
active = 3,
};
/// Returns the state of this completion. There are some things to
/// be caution about when calling this function.
///
/// First, this is only safe to call from the main thread. This cannot
/// be called from any other thread.
///
/// Second, if you are using default "undefined" completions, this will
/// NOT return a valid value if you access it. You must zero your
/// completion using ".{}". You only need to zero the completion once.
/// Once the completion is in use, it will always be valid.
///
/// Third, if you stop the loop (loop.stop()), the completions registered
/// with the loop will NOT be reset to a dead state.
pub fn state(self: Completion) xev.CompletionState {
return switch (self.flags.state) {
.dead => .dead,
.adding, .deleting, .active => .active,
};
}
/// Perform the operation associated with this completion. This will
/// perform the full blocking operation for the completion.
fn perform(self: *Completion) Result {
return switch (self.op) {
// This should never happen because we always do these synchronously
// or in another location.
.cancel,
.close,
.noop,
.shutdown,
.timer,
=> unreachable,
.accept => |*op| .{
.accept = if (posix.accept(
op.socket,
&op.addr,
&op.addr_size,
op.flags,
)) |v|
v
else |_|
error.Unknown,
},
.connect => |*op| .{
.connect = if (posix.getsockoptError(op.socket)) {} else |err| err,
},
.poll => .{ .poll = {} },
.read => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.read(op.fd, v),
.array => |*v| posix.read(op.fd, v),
};
break :res .{
.read = if (n_) |n|
if (n == 0) error.EOF else n
else |err|
err,
};
},
.pread => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.pread(op.fd, v, op.offset),
.array => |*v| posix.pread(op.fd, v, op.offset),
};
break :res .{
.pread = if (n_) |n|
if (n == 0) error.EOF else n
else |err|
err,
};
},
.write => |*op| .{
.write = switch (op.buffer) {
.slice => |v| posix.write(op.fd, v),
.array => |*v| posix.write(op.fd, v.array[0..v.len]),
},
},
.pwrite => |*op| .{
.pwrite = switch (op.buffer) {
.slice => |v| posix.pwrite(op.fd, v, op.offset),
.array => |*v| posix.pwrite(op.fd, v.array[0..v.len], op.offset),
},
},
.send => |*op| .{
.send = switch (op.buffer) {
.slice => |v| posix.send(op.fd, v, 0),
.array => |*v| posix.send(op.fd, v.array[0..v.len], 0),
},
},
.sendmsg => |*op| .{
.sendmsg = if (posix.sendmsg(op.fd, op.msghdr, 0)) |v|
v
else |err|
err,
},
.recvmsg => |*op| res: {
const res = std.os.linux.recvmsg(op.fd, op.msghdr, 0);
break :res .{
.recvmsg = if (res == 0)
error.EOF
else if (res > 0)
res
else switch (posix.errno(res)) {
else => |err| posix.unexpectedErrno(err),
},
};
},
.recv => |*op| res: {
const n_ = switch (op.buffer) {
.slice => |v| posix.recv(op.fd, v, 0),
.array => |*v| posix.recv(op.fd, v, 0),
};
break :res .{
.recv = if (n_) |n|
if (n == 0) error.EOF else n
else |err|
err,
};
},
};
}
/// Return the fd for the completion. This will perform a dup(2) if
/// requested.
fn fd_maybe_dup(self: *Completion) error{DupFailed}!posix.fd_t {
const old_fd = self.fd().?;
if (!self.flags.dup) return old_fd;
if (self.flags.dup_fd > 0) return self.flags.dup_fd;
self.flags.dup_fd = posix.dup(old_fd) catch return error.DupFailed;
return self.flags.dup_fd;
}
/// Returns the fd associated with the completion (if any).
fn fd(self: *Completion) ?posix.fd_t {
return switch (self.op) {
.accept => |v| v.socket,
.connect => |v| v.socket,
.poll => |v| v.fd,
.read => |v| v.fd,
.pread => |v| v.fd,
.recv => |v| v.fd,
.write => |v| v.fd,
.pwrite => |v| v.fd,
.send => |v| v.fd,
.sendmsg => |v| v.fd,
.recvmsg => |v| v.fd,
.close => |v| v.fd,
.shutdown => |v| v.socket,
.cancel,
.timer,
=> null,
.noop => unreachable,
};
}
};
pub const OperationType = enum {
noop,
cancel,
accept,
connect,
poll,
read,
pread,
write,
pwrite,
send,
recv,
sendmsg,
recvmsg,
close,
shutdown,
timer,
};
/// The result type based on the operation type. For a callback, the
/// result tag will ALWAYS match the operation tag.
pub const Result = union(OperationType) {
noop: void,
cancel: CancelError!void,
accept: AcceptError!posix.socket_t,
connect: ConnectError!void,
poll: PollError!void,
read: ReadError!usize,
pread: ReadError!usize,
write: WriteError!usize,
pwrite: WriteError!usize,
send: WriteError!usize,
recv: ReadError!usize,
sendmsg: WriteError!usize,
recvmsg: ReadError!usize,
close: CloseError!void,
shutdown: ShutdownError!void,
timer: TimerError!TimerTrigger,
};
/// All the supported operations of this event loop. These are always
/// backend-specific and therefore the structure and types change depending
/// on the underlying system in use. The high level operations are
/// done by initializing the request handles.
pub const Operation = union(OperationType) {
noop: void,
cancel: struct {
c: *Completion,
},
accept: struct {
socket: posix.socket_t,
addr: posix.sockaddr = undefined,
addr_size: posix.socklen_t = @sizeOf(posix.sockaddr),
flags: u32 = posix.SOCK.CLOEXEC,
},
connect: struct {
socket: posix.socket_t,
addr: std.net.Address,
},
/// Poll for events but do not perform any operations on them being
/// ready. The "events" field are a OR-ed list of EPOLL events.
poll: struct {
fd: posix.fd_t,
events: u32,
},
read: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
},
pread: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
offset: u64,
},
write: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
},
pwrite: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
offset: u64,
},
send: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
},
recv: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
},
sendmsg: struct {
fd: posix.fd_t,
msghdr: *posix.msghdr_const,
/// Optionally, a write buffer can be specified and the given
/// msghdr will be populated with information about this buffer.
buffer: ?WriteBuffer = null,
/// Do not use this, it is only used internally.
iov: [1]posix.iovec_const = undefined,
},
recvmsg: struct {
fd: posix.fd_t,
msghdr: *posix.msghdr,
},
close: struct {
fd: posix.fd_t,
},
shutdown: struct {
socket: posix.socket_t,
how: posix.ShutdownHow = .both,
},
timer: Timer,
const Timer = struct {
/// The absolute time to fire this timer next.
next: std.os.linux.timespec,
/// Only used internally. If this is non-null and timer is
/// CANCELLED, then the timer is rearmed automatically with this
/// as the next time. The callback will not be called on the
/// cancellation.
reset: ?std.os.linux.timespec = null,
/// Internal heap fields.
heap: heap.IntrusiveField(Timer) = .{},
/// We point back to completion for now. When issue[1] is fixed,
/// we can juse use that from our heap fields.
/// [1]: https://github.com/ziglang/zig/issues/6611
c: *Completion = undefined,
fn less(_: void, a: *const Timer, b: *const Timer) bool {
return a.ns() < b.ns();
}
/// Returns the nanoseconds of this timer. Note that maxInt(u64) ns is
/// 584 years so if we get any overflows we just use maxInt(u64). If
/// any software is running in 584 years waiting on this timer...
/// shame on me I guess... but I'll be dead.
fn ns(self: *const Timer) u64 {
assert(self.next.tv_sec >= 0);
assert(self.next.tv_nsec >= 0);
const max = std.math.maxInt(u64);
const s_ns = std.math.mul(
u64,
@as(u64, @intCast(self.next.tv_sec)),
std.time.ns_per_s,
) catch return max;
return std.math.add(u64, s_ns, @as(u64, @intCast(self.next.tv_nsec))) catch
return max;
}
};
};
/// ReadBuffer are the various options for reading.
pub const ReadBuffer = union(enum) {
/// Read into this slice.
slice: []u8,
/// Read into this array, just set this to undefined and it will
/// be populated up to the size of the array. This is an option because
/// the other union members force a specific size anyways so this lets us
/// use the other size in the union to support small reads without worrying
/// about buffer allocation.
///
/// To know the size read you have to use the return value of the
/// read operations (i.e. recv).
///
/// Note that the union at the time of this writing could accomodate a
/// much larger fixed size array here but we want to retain flexiblity
/// for future fields.
array: [32]u8,
// TODO: future will have vectors
};
/// WriteBuffer are the various options for writing.
pub const WriteBuffer = union(enum) {
/// Write from this buffer.
slice: []const u8,
/// Write from this array. See ReadBuffer.array for why we support this.
array: struct {
array: [32]u8,
len: usize,
},
// TODO: future will have vectors
};
const ThreadPoolError = error{
ThreadPoolRequired,
ThreadPoolUnsupported,
};
pub const CancelError = ThreadPoolError || error{
NotFound,
};
pub const AcceptError = posix.EpollCtlError || error{
DupFailed,
Unknown,
};
pub const CloseError = posix.EpollCtlError || error{
Unknown,
};
pub const PollError = posix.EpollCtlError || error{
DupFailed,
Unknown,
};
pub const ShutdownError = posix.EpollCtlError || posix.ShutdownError || error{
Unknown,
};
pub const ConnectError = posix.EpollCtlError || posix.ConnectError || error{
DupFailed,
Unknown,
};
pub const ReadError = ThreadPoolError || posix.EpollCtlError ||
posix.ReadError ||
posix.PReadError ||
posix.RecvFromError ||
error{
DupFailed,
EOF,
Unknown,
};
pub const WriteError = ThreadPoolError || posix.EpollCtlError ||
posix.WriteError ||
posix.PWriteError ||
posix.SendError ||
posix.SendMsgError ||
error{
DupFailed,
Unknown,
};
pub const TimerError = error{
Unexpected,
};
pub const TimerTrigger = enum {
/// Unused with epoll
request,
/// Timer expired.
expiration,
/// Timer was canceled.
cancel,
};
test "Completion size" {
const testing = std.testing;
// Just so we are aware when we change the size
try testing.expectEqual(@as(usize, 200), @sizeOf(Completion));
}
test "epoll: default completion" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
var c: Completion = .{};
loop.add(&c);
// Tick
try loop.run(.until_done);
// Completion should be dead.
try testing.expect(c.state() == .dead);
}
test "epoll: loop time" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// should never init zero
const now = loop.now();
try testing.expect(now > 0);
// should update on a loop tick
while (now == loop.now()) try loop.run(.no_wait);
}
test "epoll: stop" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var called = false;
var c1: Completion = undefined;
loop.timer(&c1, 1_000_000, &called, (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, _: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// Tick
try loop.run(.no_wait);
try testing.expect(!called);
// Stop
loop.stop();
try loop.run(.until_done);
try testing.expect(!called);
}
test "epoll: timer" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var called = false;
var c1: xev.Completion = undefined;
loop.timer(&c1, 1, &called, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// Add another timer
var called2 = false;
var c2: xev.Completion = undefined;
loop.timer(&c2, 100_000, &called2, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// State checking
try testing.expect(c1.state() == .active);
try testing.expect(c2.state() == .active);
// Tick
while (!called) try loop.run(.no_wait);
try testing.expect(called);
try testing.expect(!called2);
// State checking
try testing.expect(c1.state() == .dead);
try testing.expect(c2.state() == .active);
}
test "epoll: timer reset" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, cb);
// We know timer won't be called from the timer test previously.
try loop.run(.no_wait);
try testing.expect(trigger == null);
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .active);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "epoll: timer reset before tick" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, cb);
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .dead);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "epoll: timer reset after trigger" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 1, &trigger, cb);
// Run the timer
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
trigger = null;
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .dead);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "epoll: timerfd" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// We'll try with a simple timerfd
const Timerfd = @import("../linux/timerfd.zig").Timerfd;
var t = try Timerfd.init(.monotonic, .{});
defer t.deinit();
try t.set(.{}, &.{ .value = .{ .nanoseconds = 1 } }, null);
// Add the timer
var called = false;
var c: Completion = .{
.op = .{
.read = .{
.fd = t.fd,
.buffer = .{ .array = undefined },
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = r.read catch unreachable;
_ = c;
_ = l;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c);
// Tick
try loop.run(.until_done);
try testing.expect(called);
}
test "epoll: socket accept/connect/send/recv/close" {
const mem = std.mem;
const net = std.net;
const os = posix;
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a TCP server socket
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const kernel_backlog = 1;
var ln = try os.socket(address.any.family, os.SOCK.STREAM | os.SOCK.CLOEXEC, 0);
errdefer os.close(ln);
try os.setsockopt(ln, os.SOL.SOCKET, os.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try os.bind(ln, &address.any, address.getOsSockLen());
try os.listen(ln, kernel_backlog);
// Create a TCP client socket
var client_conn = try os.socket(
address.any.family,
os.SOCK.NONBLOCK | os.SOCK.STREAM | os.SOCK.CLOEXEC,
0,
);
errdefer os.close(client_conn);
// Accept
var server_conn: os.socket_t = 0;
var c_accept: Completion = .{
.op = .{
.accept = .{
.socket = ln,
},
},
.userdata = &server_conn,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const conn = @as(*os.socket_t, @ptrCast(@alignCast(ud.?)));
conn.* = r.accept catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_accept);
// Connect
var connected = false;
var c_connect: xev.Completion = .{
.op = .{
.connect = .{
.socket = client_conn,
.addr = address,
},
},
.userdata = &connected,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.connect catch unreachable;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_connect);
// Wait for the connection to be established
try loop.run(.until_done);
try testing.expect(server_conn > 0);
try testing.expect(connected);
// Send
var c_send: xev.Completion = .{
.op = .{
.send = .{
.fd = client_conn,
.buffer = .{ .slice = &[_]u8{ 1, 1, 2, 3, 5, 8, 13 } },
},
},
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.send catch unreachable;
_ = ud;
return .disarm;
}
}).callback,
};
loop.add(&c_send);
// Receive
var recv_buf: [128]u8 = undefined;
var recv_len: usize = 0;
var c_recv: xev.Completion = .{
.op = .{
.recv = .{
.fd = server_conn,
.buffer = .{ .slice = &recv_buf },
},
},
.userdata = &recv_len,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*usize, @ptrCast(@alignCast(ud.?)));
ptr.* = r.recv catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_recv);
// Wait for the send/receive
try loop.run(.until_done);
try testing.expectEqualSlices(u8, c_send.op.send.buffer.slice, recv_buf[0..recv_len]);
// Shutdown
var shutdown = false;
var c_client_shutdown: xev.Completion = .{
.op = .{
.shutdown = .{
.socket = client_conn,
},
},
.userdata = &shutdown,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.shutdown catch unreachable;
const ptr = @as(*bool, @ptrCast(@alignCast(ud.?)));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_client_shutdown);
try loop.run(.until_done);
try testing.expect(shutdown);
// Read should be EOF
var eof: ?bool = null;
c_recv = .{
.op = .{
.recv = .{
.fd = server_conn,
.buffer = .{ .slice = &recv_buf },
},
},
.userdata = &eof,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*?bool, @ptrCast(@alignCast(ud.?)));
ptr.* = if (r.recv) |_| false else |err| switch (err) {
error.EOF => true,
else => false,
};
return .disarm;
}
}).callback,
};
loop.add(&c_recv);
try loop.run(.until_done);
try testing.expect(eof.? == true);
// Close
var c_client_close: xev.Completion = .{
.op = .{
.close = .{
.fd = client_conn,
},
},
.userdata = &client_conn,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.close catch unreachable;
const ptr = @as(*os.socket_t, @ptrCast(@alignCast(ud.?)));
ptr.* = 0;
return .disarm;
}
}).callback,
};
loop.add(&c_client_close);
var c_server_close: xev.Completion = .{
.op = .{
.close = .{
.fd = ln,
},
},
.userdata = &ln,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.close catch unreachable;
const ptr = @as(*os.socket_t, @ptrCast(@alignCast(ud.?)));
ptr.* = 0;
return .disarm;
}
}).callback,
};
loop.add(&c_server_close);
// Wait for the sockets to close
try loop.run(.until_done);
try testing.expect(ln == 0);
try testing.expect(client_conn == 0);
}
test "epoll: timer cancellation" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: xev.Completion = undefined;
loop.timer(&c1, 100_000, &trigger, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const ptr = @as(*?TimerTrigger, @ptrCast(@alignCast(ud.?)));
ptr.* = r.timer catch unreachable;
return .disarm;
}
}).callback);
// Tick and verify we're not called.
try loop.run(.no_wait);
try testing.expect(trigger == null);
// Cancel the timer
var called = false;
var c_cancel: xev.Completion = .{
.op = .{
.cancel = .{
.c = &c1,
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.cancel catch unreachable;
const ptr = @as(*bool, @ptrCast(@alignCast(ud.?)));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel);
// Tick
try loop.run(.until_done);
try testing.expect(called);
try testing.expect(trigger.? == .cancel);
}
test "epoll: canceling a completed operation" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: xev.Completion = undefined;
loop.timer(&c1, 1, &trigger, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const ptr = @as(*?TimerTrigger, @ptrCast(@alignCast(ud.?)));
ptr.* = r.timer catch unreachable;
return .disarm;
}
}).callback);
// Tick and verify we're not called.
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
// Cancel the timer
var called = false;
var c_cancel: xev.Completion = .{
.op = .{
.cancel = .{
.c = &c1,
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.cancel catch unreachable;
const ptr = @as(*bool, @ptrCast(@alignCast(ud.?)));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel);
// Tick
try loop.run(.until_done);
try testing.expect(called);
try testing.expect(trigger.? == .expiration);
}
|
0 | repos/libxev/src | repos/libxev/src/backend/iocp.zig | //! Backend to use win32 IOCP.
const std = @import("std");
const assert = std.debug.assert;
const windows = @import("../windows.zig");
const queue = @import("../queue.zig");
const heap = @import("../heap.zig");
const xev = @import("../main.zig").IOCP;
const posix = std.posix;
const log = std.log.scoped(.libxev_iocp);
pub const Loop = struct {
const TimerHeap = heap.Intrusive(Timer, void, Timer.less);
/// The handle to the IO completion port.
iocp_handle: windows.HANDLE = windows.INVALID_HANDLE_VALUE,
/// The number of active completions. This DOES NOT include completions that are queued in the
/// submissions queue.
active: usize = 0,
/// Our queue of submissions that we want to enqueue on the next tick.
/// These are NOT started.
submissions: queue.Intrusive(Completion) = .{},
/// The queue of cancellation requests. These will point to the completion that we need to
/// cancel. We don't enqueue the exact completion to cancel because it may be in another queue.
cancellations: queue.Intrusive(Completion) = .{},
/// Our queue of completed completions where the callback hasn't been called yet, but the
/// "result" field should be set on every completion. This is used to delay completion callbacks
/// until the next tick.
completions: queue.Intrusive(Completion) = .{},
/// Our queue of waiting completions
asyncs: queue.Intrusive(Completion) = .{},
/// Heap of timers.
timers: TimerHeap = .{ .context = {} },
/// Cached time
cached_now: u64,
/// Duration of a tick of Windows QueryPerformanceCounter.
qpc_duration: u64,
/// Some internal fields we can pack for better space.
flags: packed struct {
/// Whether we're in a run of not (to prevent nested runs).
in_run: bool = false,
/// Whether our loop is in a stopped state or not.
stopped: bool = false,
} = .{},
/// Initialize a new IOCP-backed event loop. See the Options docs
/// for what options matter for IOCP.
pub fn init(options: xev.Options) !Loop {
_ = options;
// Get the duration of the QueryPerformanceCounter.
// We should check if the division is lossless, but it returns 10_000_000 on my machine so
// we'll handle that later.
const qpc_duration = 1_000_000_000 / windows.QueryPerformanceFrequency();
// This creates a new Completion Port
const handle = try windows.CreateIoCompletionPort(windows.INVALID_HANDLE_VALUE, null, 0, 1);
var res: Loop = .{
.iocp_handle = handle,
.qpc_duration = qpc_duration,
.cached_now = undefined,
};
res.update_now();
return res;
}
/// Deinitialize the loop, this closes the handle to the Completion Port. Any events that were
/// unprocessed are lost -- their callbacks will never be called.
pub fn deinit(self: *Loop) void {
windows.CloseHandle(self.iocp_handle);
}
/// Stop the loop. This can only be called from the main thread.
/// This will stop the loop forever. Future ticks will do nothing.
///
/// This does NOT stop any completions associated to operations that are in-flight.
pub fn stop(self: *Loop) void {
self.flags.stopped = true;
}
/// Add a completion to the loop. The completion is not started until the loop is run (`run`) or
/// an explicit submission request is made (`submit`).
pub fn add(self: *Loop, completion: *Completion) void {
// If the completion is a cancel operation, we start it immediately as it will be put in the
// cancellations queue.
if (completion.op == .cancel) {
self.start_completion(completion);
return;
}
switch (completion.flags.state) {
// The completion is in an adding state already, nothing needs to be done.
.adding => return,
// The completion is dead, probably because it was canceled.
.dead => {},
// If we reach this point, we have a problem...
.active => unreachable,
}
// We just add the completion to the queue. Failures can happen
// at submission or tick time.
completion.flags.state = .adding;
self.submissions.push(completion);
}
/// Submit any enqueued completions. This does not fire any callbacks for completed events
/// (success or error). Callbacks are only fired on the next tick.
pub fn submit(self: *Loop) !void {
// Submit all the submissions. We copy the submission queue so that any resubmits don't
// cause an infinite loop.
var queued = self.submissions;
self.submissions = .{};
// On error, we have to restore the queue because we may be batching.
errdefer self.submissions = queued;
while (queued.pop()) |c| {
switch (c.flags.state) {
.adding => self.start_completion(c),
.dead => self.stop_completion(c, null),
.active => std.log.err(
"invalid state in submission queue state={}",
.{c.flags.state},
),
}
}
}
/// Process the cancellations queue. This doesn't call any callbacks but can potentially make
/// system call to cancel active IO.
fn process_cancellations(self: *Loop) void {
while (self.cancellations.pop()) |c| {
const target = c.op.cancel.c;
var cancel_result: CancelError!void = {};
switch (target.flags.state) {
// If the target is dead already we do nothing.
.dead => {},
// If it is in the submission queue, mark them as dead so they will never be
// submitted.
.adding => target.flags.state = .dead,
// If it is active we need to schedule the deletion.
.active => self.stop_completion(target, &cancel_result),
}
// We completed the cancellation.
c.result = .{ .cancel = cancel_result };
self.completions.push(c);
}
}
/// Run the event loop. See RunMode documentation for details on modes.
/// Once the loop is run, the pointer MUST remain stable.
pub fn run(self: *Loop, mode: xev.RunMode) !void {
switch (mode) {
.no_wait => try self.tick(0),
.once => try self.tick(1),
.until_done => while (!self.done()) try self.tick(1),
}
}
/// Tick through the event loop once, waiting for at least "wait" completions to be processed by
/// the loop itself.
pub fn tick(self: *Loop, wait: u32) !void {
// If we're stopped then the loop is fully over.
if (self.flags.stopped) return;
// We can't nest runs.
if (self.flags.in_run) return error.NestedRunsNotAllowed;
self.flags.in_run = true;
defer self.flags.in_run = false;
// The list of entry that will be filled with a call to GetQueuedCompletionStatusEx.
var entries: [128]windows.OVERLAPPED_ENTRY = undefined;
var wait_rem = @as(usize, @intCast(wait));
// Handle all of our cancellations first because we may be able to stop submissions from
// even happening if its still queued. Plus, cancellations sometimes add more to the
// submission queue.
self.process_cancellations();
// Submit pending completions.
try self.submit();
// Loop condition is inspired from the kqueue backend. See its documentation for details.
while (true) {
// If we're stopped then the loop is fully over.
if (self.flags.stopped) return;
// We must update our time no matter what.
self.update_now();
const should_continue = (self.active > 0 and (wait == 0 or wait_rem > 0)) or !self.completions.empty();
if (!should_continue) break;
// Run our expired timers.
const now_timer: Timer = .{ .next = self.cached_now };
while (self.timers.peek()) |t| {
if (!Timer.less({}, t, &now_timer)) break;
// Remove the timer
assert(self.timers.deleteMin().? == t);
// Mark completion as done
const c = t.c;
c.flags.state = .dead;
// We mark it as inactive here because if we rearm below the start() function will
// reincrement this.
self.active -= 1;
// Lower our remaining count since we have processed something.
wait_rem -|= 1;
// Invoke
const action = c.callback(c.userdata, self, c, .{ .timer = .expiration });
switch (action) {
.disarm => {},
.rearm => self.start_completion(c),
}
}
// Process the completions we already have completed.
while (self.completions.pop()) |c| {
// We store whether this completion was active so we can decrement the active count
// later.
const c_active = c.flags.state == .active;
c.flags.state = .dead;
// Decrease our waiters because we are definitely processing one.
wait_rem -|= 1;
// Completion queue items MUST have a result set.
const action = c.callback(c.userdata, self, c, c.result.?);
switch (action) {
.disarm => {
// If we were active, decrement the number of active completions.
if (c_active) self.active -= 1;
},
// Only resubmit if we aren't already active
.rearm => if (!c_active) self.submissions.push(c),
}
}
// Process asyncs
if (!self.asyncs.empty()) {
var asyncs = self.asyncs;
self.asyncs = .{};
while (asyncs.pop()) |c| {
const c_wakeup = c.op.async_wait.wakeup.swap(false, .seq_cst);
// If we aren't waking this one up, requeue
if (!c_wakeup) {
self.asyncs.push(c);
continue;
}
// We are waking up, mark this as dead and call it.
c.flags.state = .dead;
self.active -= 1;
// Lower our waiters
wait_rem -|= 1;
const action = c.callback(c.userdata, self, c, .{ .async_wait = {} });
switch (action) {
.disarm => {},
.rearm => self.start_completion(c),
}
}
}
// If we have processed enough event, we break out of the loop.
if (wait_rem == 0) break;
// Determine our next timeout based on the timers.
const timeout: ?windows.DWORD = timeout: {
// If we have a timer, we want to set the timeout to our next timer value. If we
// have no timer, we wait forever.
const t = self.timers.peek() orelse break :timeout null;
// Determin the time in milliseconds. If the cast fails, we fallback to the maximum
// acceptable value.
const ms_now = self.cached_now / std.time.ns_per_ms;
const ms_next = t.next / std.time.ns_per_ms;
const ms = ms_next -| ms_now;
break :timeout std.math.cast(windows.DWORD, ms) orelse windows.INFINITE - 1;
};
// Wait for changes IO completions.
const count: u32 = windows.GetQueuedCompletionStatusEx(self.iocp_handle, &entries, timeout, false) catch |err| switch (err) {
// A timeout means that nothing was completed.
error.Timeout => 0,
else => return err,
};
// Go through the entries and perform completions callbacks.
for (entries[0..count]) |entry| {
const completion: *Completion = if (entry.lpCompletionKey == 0) completion: {
// We retrieve the Completion from the OVERLAPPED pointer as we know it's a part of
// the Completion struct.
const overlapped_ptr: ?*windows.OVERLAPPED = @as(?*windows.OVERLAPPED, @ptrCast(entry.lpOverlapped));
if (overlapped_ptr == null) {
// Probably an async wakeup
continue;
}
break :completion @alignCast(@fieldParentPtr("overlapped", overlapped_ptr.?));
} else completion: {
// JobObjects are a special case where the OVERLAPPED_ENTRY fields are interpreted differently.
// When JOBOBJECT_ASSOCIATE_COMPLETION_PORT is used, lpOverlapped actually contains the message
// value, and not the address of the overlapped structure. The Completion pointer is passed
// as the completion key instead.
const completion: *Completion = @ptrFromInt(entry.lpCompletionKey);
completion.result = .{ .job_object = .{
.message = .{
.type = @enumFromInt(entry.dwNumberOfBytesTransferred),
.value = @intFromPtr(entry.lpOverlapped),
},
} };
break :completion completion;
};
wait_rem -|= 1;
self.active -= 1;
completion.flags.state = .dead;
const result = completion.perform();
const action = completion.callback(completion.userdata, self, completion, result);
switch (action) {
.disarm => {},
.rearm => {
completion.reset();
self.start_completion(completion);
},
}
}
// If we ran through the loop once we break if we don't care.
if (wait == 0) break;
}
}
/// Returns the "loop" time in milliseconds. The loop time is updated once per loop tick, before
/// IO polling occurs. It remains constant throughout callback execution.
///
/// You can force an update of the "now" value by calling update_now() at any time from the main
/// thread.
///
/// QueryPerformanceCounter is used to get the current timestamp.
pub fn now(self: *Loop) i64 {
return @as(i64, @intCast(self.cached_now));
}
/// Update the cached time.
pub fn update_now(self: *Loop) void {
// Compute the current timestamp in ms by multiplying the QueryPerfomanceCounter value in
// ticks by the duration of a tick.
self.cached_now = windows.QueryPerformanceCounter() * self.qpc_duration;
}
/// Add a timer to the loop. The timer will execute in "next_ms". This is oneshot: the timer
/// will not repeat. To repeat a timer, either schedule another in your callback or return rearm
/// from the callback.
pub fn timer(
self: *Loop,
c: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
c.* = .{
.op = .{
.timer = .{
.next = self.timer_next(next_ms),
},
},
.userdata = userdata,
.callback = cb,
};
self.add(c);
}
/// see io_uring.timer_reset for docs.
pub fn timer_reset(
self: *Loop,
c: *Completion,
c_cancel: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
switch (c.flags.state) {
.dead => {
self.timer(c, next_ms, userdata, cb);
return;
},
// Adding state we can just modify the metadata and return since the timer isn't in the
// heap yet.
.adding => {
c.op.timer.next = self.timer_next(next_ms);
c.userdata = userdata;
c.callback = cb;
},
.active => {
// Update the reset time for the timer to the desired time along with all the
// callbacks.
c.op.timer.reset = self.timer_next(next_ms);
c.userdata = userdata;
c.callback = cb;
// If the cancellation is active, we assume its for this timer.
if (c_cancel.state() == .active) return;
assert(c_cancel.state() == .dead and c.state() == .active);
c_cancel.* = .{ .op = .{ .cancel = .{ .c = c } } };
self.add(c_cancel);
},
}
}
// Get the absolute timestamp corresponding to the given "next_ms".
pub fn timer_next(self: *Loop, next_ms: u64) u64 {
return self.cached_now + next_ms * std.time.ns_per_ms;
}
pub fn done(self: *Loop) bool {
return self.flags.stopped or (self.active == 0 and
self.submissions.empty() and
self.completions.empty());
}
// Start the completion.
fn start_completion(self: *Loop, completion: *Completion) void {
const StartAction = union(enum) {
// We successfully submitted the operation.
submitted: void,
// We are a timer.
timer: void,
// We are a cancellation.
cancel: void,
// We are an async wait
async_wait: void,
// We have a result code from making a system call now.
result: Result,
};
const action: StartAction = switch (completion.op) {
.noop => {
completion.flags.state = .dead;
return;
},
.accept => |*v| action: {
if (v.internal_accept_socket == null) {
var addr: posix.sockaddr.storage = undefined;
var addr_len: i32 = @sizeOf(posix.sockaddr.storage);
std.debug.assert(windows.ws2_32.getsockname(asSocket(v.socket), @as(*posix.sockaddr, @ptrCast(&addr)), &addr_len) == 0);
var socket_type: i32 = 0;
const socket_type_bytes = std.mem.asBytes(&socket_type);
var opt_len: i32 = @as(i32, @intCast(socket_type_bytes.len));
std.debug.assert(windows.ws2_32.getsockopt(asSocket(v.socket), posix.SOL.SOCKET, posix.SO.TYPE, socket_type_bytes, &opt_len) == 0);
v.internal_accept_socket = windows.WSASocketW(addr.family, socket_type, 0, null, 0, windows.ws2_32.WSA_FLAG_OVERLAPPED) catch |err| {
break :action .{ .result = .{ .accept = err } };
};
}
self.associate_fd(completion.handle().?) catch unreachable;
var discard: u32 = undefined;
const result = windows.ws2_32.AcceptEx(
asSocket(v.socket),
asSocket(v.internal_accept_socket.?),
&v.storage,
0,
0,
@as(u32, @intCast(@sizeOf(posix.sockaddr.storage))),
&discard,
&completion.overlapped,
);
if (result != windows.TRUE) {
const err = windows.ws2_32.WSAGetLastError();
switch (err) {
windows.ws2_32.WinsockError.WSA_IO_PENDING => break :action .{ .submitted = {} },
else => {
windows.CloseHandle(v.internal_accept_socket.?);
break :action .{ .result = .{ .accept = windows.unexpectedWSAError(err) } };
},
}
}
break :action .{ .submitted = {} };
},
.close => |v| .{ .result = .{ .close = windows.CloseHandle(v.fd) } },
.connect => |*v| action: {
const result = windows.ws2_32.connect(asSocket(v.socket), &v.addr.any, @as(i32, @intCast(v.addr.getOsSockLen())));
if (result != 0) {
const err = windows.ws2_32.WSAGetLastError();
break :action switch (err) {
else => .{ .result = .{ .connect = windows.unexpectedWSAError(err) } },
};
}
break :action .{ .result = .{ .connect = {} } };
},
.read => |*v| action: {
self.associate_fd(completion.handle().?) catch unreachable;
const buffer: []u8 = if (v.buffer == .slice) v.buffer.slice else &v.buffer.array;
break :action if (windows.exp.ReadFile(v.fd, buffer, &completion.overlapped)) |_|
.{
.submitted = {},
}
else |err|
.{
.result = .{ .read = err },
};
},
.pread => |*v| action: {
self.associate_fd(completion.handle().?) catch unreachable;
const buffer: []u8 = if (v.buffer == .slice) v.buffer.slice else &v.buffer.array;
completion.overlapped.DUMMYUNIONNAME.DUMMYSTRUCTNAME.Offset = @intCast(v.offset & 0xFFFF_FFFF_FFFF_FFFF);
completion.overlapped.DUMMYUNIONNAME.DUMMYSTRUCTNAME.OffsetHigh = @intCast(v.offset >> 32);
break :action if (windows.exp.ReadFile(v.fd, buffer, &completion.overlapped)) |_|
.{
.submitted = {},
}
else |err|
.{
.result = .{ .pread = err },
};
},
.shutdown => |*v| .{ .result = .{ .shutdown = posix.shutdown(asSocket(v.socket), v.how) } },
.write => |*v| action: {
self.associate_fd(completion.handle().?) catch unreachable;
const buffer: []const u8 = if (v.buffer == .slice) v.buffer.slice else v.buffer.array.array[0..v.buffer.array.len];
break :action if (windows.exp.WriteFile(v.fd, buffer, &completion.overlapped)) |_|
.{
.submitted = {},
}
else |err|
.{
.result = .{ .write = err },
};
},
.pwrite => |*v| action: {
self.associate_fd(completion.handle().?) catch unreachable;
const buffer: []const u8 = if (v.buffer == .slice) v.buffer.slice else v.buffer.array.array[0..v.buffer.array.len];
completion.overlapped.DUMMYUNIONNAME.DUMMYSTRUCTNAME.Offset = @intCast(v.offset & 0xFFFF_FFFF_FFFF_FFFF);
completion.overlapped.DUMMYUNIONNAME.DUMMYSTRUCTNAME.OffsetHigh = @intCast(v.offset >> 32);
break :action if (windows.exp.WriteFile(v.fd, buffer, &completion.overlapped)) |_|
.{
.submitted = {},
}
else |err|
.{
.result = .{ .pwrite = err },
};
},
.send => |*v| action: {
self.associate_fd(completion.handle().?) catch unreachable;
const buffer: []const u8 = if (v.buffer == .slice) v.buffer.slice else v.buffer.array.array[0..v.buffer.array.len];
v.wsa_buffer = .{ .buf = @constCast(buffer.ptr), .len = @as(u32, @intCast(buffer.len)) };
const result = windows.ws2_32.WSASend(
asSocket(v.fd),
@as([*]windows.ws2_32.WSABUF, @ptrCast(&v.wsa_buffer)),
1,
null,
0,
&completion.overlapped,
null,
);
if (result != 0) {
const err = windows.ws2_32.WSAGetLastError();
break :action switch (err) {
windows.ws2_32.WinsockError.WSA_IO_PENDING => .{ .submitted = {} },
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => .{ .result = .{ .send = error.Canceled } },
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .send = error.ConnectionReset } },
else => .{ .result = .{ .send = windows.unexpectedWSAError(err) } },
};
}
break :action .{ .submitted = {} };
},
.recv => |*v| action: {
self.associate_fd(completion.handle().?) catch unreachable;
const buffer: []u8 = if (v.buffer == .slice) v.buffer.slice else &v.buffer.array;
v.wsa_buffer = .{ .buf = buffer.ptr, .len = @as(u32, @intCast(buffer.len)) };
var flags: u32 = 0;
const result = windows.ws2_32.WSARecv(
asSocket(v.fd),
@as([*]windows.ws2_32.WSABUF, @ptrCast(&v.wsa_buffer)),
1,
null,
&flags,
&completion.overlapped,
null,
);
if (result != 0) {
const err = windows.ws2_32.WSAGetLastError();
break :action switch (err) {
windows.ws2_32.WinsockError.WSA_IO_PENDING => .{ .submitted = {} },
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => .{ .result = .{ .recv = error.Canceled } },
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .recv = error.ConnectionReset } },
else => .{ .result = .{ .recv = windows.unexpectedWSAError(err) } },
};
}
break :action .{ .submitted = {} };
},
.sendto => |*v| action: {
self.associate_fd(completion.handle().?) catch unreachable;
const buffer: []const u8 = if (v.buffer == .slice) v.buffer.slice else v.buffer.array.array[0..v.buffer.array.len];
v.wsa_buffer = .{ .buf = @constCast(buffer.ptr), .len = @as(u32, @intCast(buffer.len)) };
const result = windows.ws2_32.WSASendTo(
asSocket(v.fd),
@as([*]windows.ws2_32.WSABUF, @ptrCast(&v.wsa_buffer)),
1,
null,
0,
&v.addr.any,
@as(i32, @intCast(v.addr.getOsSockLen())),
&completion.overlapped,
null,
);
if (result != 0) {
const err = windows.ws2_32.WSAGetLastError();
break :action switch (err) {
windows.ws2_32.WinsockError.WSA_IO_PENDING => .{ .submitted = {} },
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => .{ .result = .{ .sendto = error.Canceled } },
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .sendto = error.ConnectionReset } },
else => .{ .result = .{ .sendto = windows.unexpectedWSAError(err) } },
};
}
break :action .{ .submitted = {} };
},
.recvfrom => |*v| action: {
self.associate_fd(completion.handle().?) catch unreachable;
const buffer: []u8 = if (v.buffer == .slice) v.buffer.slice else &v.buffer.array;
v.wsa_buffer = .{ .buf = buffer.ptr, .len = @as(u32, @intCast(buffer.len)) };
var flags: u32 = 0;
const result = windows.ws2_32.WSARecvFrom(
asSocket(v.fd),
@as([*]windows.ws2_32.WSABUF, @ptrCast(&v.wsa_buffer)),
1,
null,
&flags,
&v.addr,
@as(*i32, @ptrCast(&v.addr_size)),
&completion.overlapped,
null,
);
if (result != 0) {
const err = windows.ws2_32.WSAGetLastError();
break :action switch (err) {
windows.ws2_32.WinsockError.WSA_IO_PENDING => .{ .submitted = {} },
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => .{ .result = .{ .recvfrom = error.Canceled } },
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .recvfrom = error.ConnectionReset } },
else => .{ .result = .{ .recvfrom = windows.unexpectedWSAError(err) } },
};
}
break :action .{ .submitted = {} };
},
.timer => |*v| action: {
v.c = completion;
self.timers.insert(v);
break :action .{ .timer = {} };
},
.cancel => action: {
self.cancellations.push(completion);
break :action .{ .cancel = {} };
},
.async_wait => action: {
self.asyncs.push(completion);
break :action .{ .async_wait = {} };
},
.job_object => |*v| action: {
if (!v.associated) {
var port = windows.exp.JOBOBJECT_ASSOCIATE_COMPLETION_PORT{
.CompletionKey = @intFromPtr(completion),
.CompletionPort = self.iocp_handle,
};
windows.exp.SetInformationJobObject(
v.job,
.JobObjectAssociateCompletionPortInformation,
&port,
@sizeOf(windows.exp.JOBOBJECT_ASSOCIATE_COMPLETION_PORT),
) catch |err| break :action .{ .result = .{ .job_object = err } };
v.associated = true;
const action = completion.callback(completion.userdata, self, completion, .{ .job_object = .{ .associated = {} } });
switch (action) {
.disarm => {
completion.flags.state = .dead;
return;
},
.rearm => break :action .{ .submitted = {} },
}
}
break :action .{ .submitted = {} };
},
};
switch (action) {
.timer, .submitted, .cancel => {
// Increase our active count so we now wait for this. We assume it'll successfully
// queue. If it doesn't we handle that later (see submit).
self.active += 1;
completion.flags.state = .active;
},
.async_wait => {
// We are considered an active completion.
self.active += 1;
completion.flags.state = .active;
},
// A result is immediately available. Queue the completion to be invoked.
.result => |r| {
completion.result = r;
self.completions.push(completion);
},
}
}
/// Stop the completion. Fill `cancel_result` if it is non-null.
fn stop_completion(self: *Loop, completion: *Completion, cancel_result: ?*CancelError!void) void {
if (completion.flags.state == .active and completion.result != null) return;
// Inspect other operations. WARNING: the state can be anything here so per op be sure to
// check the state flag.
switch (completion.op) {
.timer => |*v| {
if (completion.flags.state == .active) {
// Remove from the heap so it never fires...
self.timers.remove(v);
// If we have reset AND we got cancellation result, that means that we were
// canceled so that we can update our expiration time.
if (v.reset) |r| {
v.next = r;
v.reset = null;
completion.flags.state = .dead;
self.active -= 1;
self.add(completion);
return;
}
}
// Add to our completion so we trigger the callback.
completion.result = .{ .timer = .cancel };
self.completions.push(completion);
// Note the timers state purposely remains ACTIVE so that
// when we process the completion we decrement the
// active count.
},
.accept => |*v| {
if (completion.flags.state == .active) {
const result = windows.kernel32.CancelIoEx(asSocket(v.socket), &completion.overlapped);
cancel_result.?.* = if (result == windows.FALSE)
windows.unexpectedError(windows.kernel32.GetLastError())
else {};
}
},
inline .read, .pread, .write, .pwrite, .recv, .send, .sendto, .recvfrom => |*v| {
if (completion.flags.state == .active) {
const result = windows.kernel32.CancelIoEx(asSocket(v.fd), &completion.overlapped);
cancel_result.?.* = if (result == windows.FALSE)
windows.unexpectedError(windows.kernel32.GetLastError())
else {};
}
},
else => @panic("Not implemented"),
}
}
// Sens an empty Completion token so that the loop wakes up if it is waiting for a completion
// event.
pub fn async_notify(self: *Loop, completion: *Completion) void {
// The completion must be in a waiting state.
assert(completion.op == .async_wait);
// The completion has been wakeup, this is used to see which completion in the async queue
// needs to be removed.
completion.op.async_wait.wakeup.store(true, .seq_cst);
const result = windows.kernel32.PostQueuedCompletionStatus(
self.iocp_handle,
0,
0,
null,
);
// NOTE(Corendos): if something goes wrong, ignore it for the moment.
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
windows.unexpectedError(err) catch {};
}
}
/// Associate a handler to the internal completion port.
/// This has to be done only once per handle so we delegate the responsibility to the caller.
pub fn associate_fd(self: Loop, fd: windows.HANDLE) !void {
if (fd == windows.INVALID_HANDLE_VALUE or self.iocp_handle == windows.INVALID_HANDLE_VALUE) return error.InvalidParameter;
// We ignore the error here because multiple call to CreateIoCompletionPort with a HANDLE
// already registered triggers a INVALID_PARAMETER error and we have no way to see the cause
// of it.
_ = windows.kernel32.CreateIoCompletionPort(fd, self.iocp_handle, 0, 0);
}
};
/// Convenience to convert from windows.HANDLE to windows.ws2_32.SOCKET (which are the same thing).
inline fn asSocket(h: windows.HANDLE) windows.ws2_32.SOCKET {
return @as(windows.ws2_32.SOCKET, @ptrCast(h));
}
/// A completion is a request to perform some work with the loop.
pub const Completion = struct {
/// Operation to execute.
op: Operation = .{ .noop = {} },
/// Userdata and callback for when the completion is finished.
userdata: ?*anyopaque = null,
callback: xev.Callback = xev.noopCallback,
//---------------------------------------------------------------
// Internal fields
/// Intrusive queue field.
next: ?*Completion = null,
/// Result code of the syscall. Only used internally in certain scenarios, should not be relied
/// upon by program authors.
result: ?Result = null,
flags: packed struct {
/// Watch state of this completion. We use this to determine whether we're active, adding or
/// dead. This lets us add and abd delete multiple times before a loop tick and handle the
/// state properly.
state: State = .dead,
} = .{},
/// Win32 OVERLAPPED struct used for asynchronous IO. Only used internally in certain scenarios.
/// It needs to be there as we rely on @fieldParentPtr to get the completion using a pointer to
/// that field.
overlapped: windows.OVERLAPPED = .{
.Internal = 0,
.InternalHigh = 0,
.DUMMYUNIONNAME = .{ .Pointer = null },
.hEvent = null,
},
/// Loop associated with this completion. HANDLE are required to be associated with an I/O
/// Completion Port to work properly.
loop: ?*const xev.Loop = null,
const State = enum(u2) {
/// completion is not part of any loop
dead = 0,
/// completion is in the submission queue
adding = 1,
/// completion is submitted successfully
active = 2,
};
/// Returns the state of this completion. There are some things to be cautious about when
/// calling this function.
///
/// First, this is only safe to call from the main thread. This cannot be called from any other
/// thread.
///
/// Second, if you are using default "undefined" completions, this will NOT return a valid value
/// if you access it. You must zero your completion using ".{}". You only need to zero the
/// completion once. Once the completion is in use, it will always be valid.
///
/// Third, if you stop the loop (loop.stop()), the completions registered with the loop will NOT
/// be reset to a dead state.
pub fn state(self: Completion) xev.CompletionState {
return switch (self.flags.state) {
.dead => .dead,
.adding, .active => .active,
};
}
/// Returns a handle for the current operation if it makes sense.
fn handle(self: Completion) ?windows.HANDLE {
return switch (self.op) {
inline .accept => |*v| v.socket,
inline .read, .pread, .write, .pwrite, .recv, .send, .recvfrom, .sendto => |*v| v.fd,
else => null,
};
}
/// Perform the operation associated with this completion. This will perform the full blocking
/// operation for the completion.
pub fn perform(self: *Completion) Result {
return switch (self.op) {
.noop, .close, .connect, .shutdown, .timer, .cancel => {
std.log.warn("perform op={s}", .{@tagName(self.op)});
unreachable;
},
.accept => |*v| r: {
var bytes_transferred: u32 = 0;
var flags: u32 = 0;
const result = windows.ws2_32.WSAGetOverlappedResult(asSocket(v.socket), &self.overlapped, &bytes_transferred, windows.FALSE, &flags);
if (result != windows.TRUE) {
const err = windows.ws2_32.WSAGetLastError();
const r = .{
.accept = switch (err) {
windows.ws2_32.WinsockError.WSA_OPERATION_ABORTED => error.Canceled,
else => windows.unexpectedWSAError(err),
},
};
windows.CloseHandle(v.internal_accept_socket.?);
break :r r;
}
break :r .{ .accept = self.op.accept.internal_accept_socket.? };
},
.read => |*v| r: {
var bytes_transferred: windows.DWORD = 0;
const result = windows.kernel32.GetOverlappedResult(v.fd, &self.overlapped, &bytes_transferred, windows.FALSE);
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
break :r .{ .read = switch (err) {
windows.Win32Error.OPERATION_ABORTED => error.Canceled,
else => error.Unexpected,
} };
}
break :r .{ .read = @as(usize, @intCast(bytes_transferred)) };
},
.pread => |*v| r: {
var bytes_transferred: windows.DWORD = 0;
const result = windows.kernel32.GetOverlappedResult(v.fd, &self.overlapped, &bytes_transferred, windows.FALSE);
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
break :r .{ .read = switch (err) {
windows.Win32Error.OPERATION_ABORTED => error.Canceled,
else => error.Unexpected,
} };
}
break :r .{ .pread = @as(usize, @intCast(bytes_transferred)) };
},
.write => |*v| r: {
var bytes_transferred: windows.DWORD = 0;
const result = windows.kernel32.GetOverlappedResult(v.fd, &self.overlapped, &bytes_transferred, windows.FALSE);
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
break :r .{ .write = switch (err) {
windows.Win32Error.OPERATION_ABORTED => error.Canceled,
else => error.Unexpected,
} };
}
break :r .{ .write = @as(usize, @intCast(bytes_transferred)) };
},
.pwrite => |*v| r: {
var bytes_transferred: windows.DWORD = 0;
const result = windows.kernel32.GetOverlappedResult(v.fd, &self.overlapped, &bytes_transferred, windows.FALSE);
if (result == windows.FALSE) {
const err = windows.kernel32.GetLastError();
break :r .{ .write = switch (err) {
windows.Win32Error.OPERATION_ABORTED => error.Canceled,
else => error.Unexpected,
} };
}
break :r .{ .pwrite = @as(usize, @intCast(bytes_transferred)) };
},
.send => |*v| r: {
var bytes_transferred: u32 = 0;
var flags: u32 = 0;
const result = windows.ws2_32.WSAGetOverlappedResult(asSocket(v.fd), &self.overlapped, &bytes_transferred, windows.FALSE, &flags);
if (result != windows.TRUE) {
const err = windows.ws2_32.WSAGetLastError();
break :r .{
.send = switch (err) {
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => error.Canceled,
.WSAECONNRESET, .WSAENETRESET => error.ConnectionReset,
else => windows.unexpectedWSAError(err),
},
};
}
break :r .{ .send = @as(usize, @intCast(bytes_transferred)) };
},
.recv => |*v| r: {
var bytes_transferred: u32 = 0;
var flags: u32 = 0;
const result = windows.ws2_32.WSAGetOverlappedResult(asSocket(v.fd), &self.overlapped, &bytes_transferred, windows.FALSE, &flags);
if (result != windows.TRUE) {
const err = windows.ws2_32.WSAGetLastError();
break :r .{
.recv = switch (err) {
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => error.Canceled,
.WSAECONNRESET, .WSAENETRESET => error.ConnectionReset,
else => windows.unexpectedWSAError(err),
},
};
}
// NOTE(Corendos): according to Win32 documentation, EOF has to be detected using the socket type.
const socket_type = t: {
var socket_type: windows.DWORD = 0;
const socket_type_bytes = std.mem.asBytes(&socket_type);
var opt_len: i32 = @as(i32, @intCast(socket_type_bytes.len));
// Here we assume the call will succeed because the socket should be valid.
std.debug.assert(windows.ws2_32.getsockopt(asSocket(v.fd), posix.SOL.SOCKET, posix.SO.TYPE, socket_type_bytes, &opt_len) == 0);
break :t socket_type;
};
if (socket_type == posix.SOCK.STREAM and bytes_transferred == 0) {
break :r .{ .recv = error.EOF };
}
break :r .{ .recv = @as(usize, @intCast(bytes_transferred)) };
},
.sendto => |*v| r: {
var bytes_transferred: u32 = 0;
var flags: u32 = 0;
const result = windows.ws2_32.WSAGetOverlappedResult(asSocket(v.fd), &self.overlapped, &bytes_transferred, windows.FALSE, &flags);
if (result != windows.TRUE) {
const err = windows.ws2_32.WSAGetLastError();
break :r .{
.sendto = switch (err) {
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => error.Canceled,
.WSAECONNRESET, .WSAENETRESET => error.ConnectionReset,
else => windows.unexpectedWSAError(err),
},
};
}
break :r .{ .sendto = @as(usize, @intCast(bytes_transferred)) };
},
.recvfrom => |*v| r: {
var bytes_transferred: u32 = 0;
var flags: u32 = 0;
const result = windows.ws2_32.WSAGetOverlappedResult(asSocket(v.fd), &self.overlapped, &bytes_transferred, windows.FALSE, &flags);
if (result != windows.TRUE) {
const err = windows.ws2_32.WSAGetLastError();
break :r .{
.recvfrom = switch (err) {
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => error.Canceled,
.WSAECONNRESET, .WSAENETRESET => error.ConnectionReset,
else => windows.unexpectedWSAError(err),
},
};
}
break :r .{ .recvfrom = @as(usize, @intCast(bytes_transferred)) };
},
.async_wait => .{ .async_wait = {} },
.job_object => self.result.?,
};
}
/// Reset the completion so it can be reused (in case of rearming for example).
pub fn reset(self: *Completion) void {
self.overlapped = .{
.Internal = 0,
.InternalHigh = 0,
.DUMMYUNIONNAME = .{ .Pointer = null },
.hEvent = null,
};
self.result = null;
}
};
pub const OperationType = enum {
/// Do nothing. This operation will not be queued and will never
/// have its callback fired. This is NOT equivalent to the io_uring
/// "nop" operation.
noop,
/// Accept a connection on a socket.
accept,
/// Close a file descriptor.
close,
/// Initiate a connection on a socket.
connect,
/// Read
read,
/// Pread
pread,
/// Shutdown all or part of a full-duplex connection.
shutdown,
/// Write
write,
/// Pwrite
pwrite,
/// Send
send,
/// Recv
recv,
/// Sendto
sendto,
/// Recvfrom
recvfrom,
/// A oneshot or repeating timer. For io_uring, this is implemented
/// using the timeout mechanism.
timer,
/// Cancel an existing operation.
cancel,
/// Wait for an async event to be posted.
async_wait,
/// Receive a notification from a job object associated with a completion port
job_object,
};
/// All the supported operations of this event loop. These are always
/// backend-specific and therefore the structure and types change depending
/// on the underlying system in use. The high level operations are
/// done by initializing the request handles.
pub const Operation = union(OperationType) {
noop: void,
accept: struct {
socket: windows.HANDLE,
storage: [@sizeOf(posix.sockaddr.storage)]u8 = undefined,
internal_accept_socket: ?windows.HANDLE = null,
},
close: struct {
fd: windows.HANDLE,
},
connect: struct {
socket: windows.HANDLE,
addr: std.net.Address,
},
read: struct {
fd: windows.HANDLE,
buffer: ReadBuffer,
},
pread: struct {
fd: windows.HANDLE,
buffer: ReadBuffer,
offset: u64,
},
shutdown: struct {
socket: windows.HANDLE,
how: posix.ShutdownHow = .both,
},
write: struct {
fd: windows.HANDLE,
buffer: WriteBuffer,
},
pwrite: struct {
fd: windows.HANDLE,
buffer: WriteBuffer,
offset: u64,
},
send: struct {
fd: windows.HANDLE,
buffer: WriteBuffer,
wsa_buffer: windows.ws2_32.WSABUF = undefined,
},
recv: struct {
fd: windows.HANDLE,
buffer: ReadBuffer,
wsa_buffer: windows.ws2_32.WSABUF = undefined,
},
sendto: struct {
fd: windows.HANDLE,
buffer: WriteBuffer,
addr: std.net.Address,
wsa_buffer: windows.ws2_32.WSABUF = undefined,
},
recvfrom: struct {
fd: windows.HANDLE,
buffer: ReadBuffer,
addr: posix.sockaddr = undefined,
addr_size: posix.socklen_t = @sizeOf(posix.sockaddr),
wsa_buffer: windows.ws2_32.WSABUF = undefined,
},
timer: Timer,
cancel: struct {
c: *Completion,
},
async_wait: struct {
wakeup: std.atomic.Value(bool) = .{ .raw = false },
},
job_object: struct {
job: windows.HANDLE,
userdata: ?*anyopaque,
/// Tracks if the job has been associated with the completion port.
/// Do not use this, it is used internally.
associated: bool = false,
},
};
/// The result type based on the operation type. For a callback, the
/// result tag will ALWAYS match the operation tag.
pub const Result = union(OperationType) {
noop: void,
accept: AcceptError!windows.HANDLE,
close: CloseError!void,
connect: ConnectError!void,
read: ReadError!usize,
pread: ReadError!usize,
shutdown: ShutdownError!void,
write: WriteError!usize,
pwrite: WriteError!usize,
send: WriteError!usize,
recv: ReadError!usize,
sendto: WriteError!usize,
recvfrom: ReadError!usize,
timer: TimerError!TimerTrigger,
cancel: CancelError!void,
async_wait: AsyncError!void,
job_object: JobObjectError!JobObjectResult,
};
pub const CancelError = error{
Unexpected,
};
pub const AcceptError = error{
AddressFamilyNotSupported,
ProcessFdQuotaExceeded,
SystemResources,
ProtocolNotSupported,
Canceled,
Unexpected,
};
pub const CloseError = error{
Unexpected,
};
pub const ConnectError = error{
Canceled,
Unexpected,
};
pub const ShutdownError = posix.ShutdownError || error{
Unexpected,
};
pub const WriteError = windows.WriteFileError || error{
Canceled,
ConnectionReset,
Unexpected,
};
pub const ReadError = windows.ReadFileError || error{
EOF,
Canceled,
ConnectionReset,
Unexpected,
};
pub const AsyncError = error{
Unexpected,
};
pub const TimerError = error{
Unexpected,
};
pub const TimerTrigger = enum {
/// Unused with IOCP
request,
/// Timer expired.
expiration,
/// Timer was canceled.
cancel,
};
pub const JobObjectError = error{
Unexpected,
};
pub const JobObjectResult = union(enum) {
// The job object was associated with the completion port
associated: void,
/// A message was recived on the completion port for this job object
message: struct {
type: windows.exp.JOB_OBJECT_MSG_TYPE,
value: usize,
},
};
/// ReadBuffer are the various options for reading.
pub const ReadBuffer = union(enum) {
/// Read into this slice.
slice: []u8,
/// Read into this array, just set this to undefined and it will
/// be populated up to the size of the array. This is an option because
/// the other union members force a specific size anyways so this lets us
/// use the other size in the union to support small reads without worrying
/// about buffer allocation.
///
/// To know the size read you have to use the return value of the
/// read operations (i.e. recv).
///
/// Note that the union at the time of this writing could accomodate a
/// much larger fixed size array here but we want to retain flexiblity
/// for future fields.
array: [32]u8,
// TODO: future will have vectors
};
/// WriteBuffer are the various options for writing.
pub const WriteBuffer = union(enum) {
/// Write from this buffer.
slice: []const u8,
/// Write from this array. See ReadBuffer.array for why we support this.
array: struct {
array: [32]u8,
len: usize,
},
// TODO: future will have vectors
};
/// Timer that is inserted into the heap.
pub const Timer = struct {
/// The absolute time to fire this timer next.
next: u64,
/// Only used internally. If this is non-null and timer is
/// CANCELLED, then the timer is rearmed automatically with this
/// as the next time. The callback will not be called on the
/// cancellation.
reset: ?u64 = null,
/// Internal heap field.
heap: heap.IntrusiveField(Timer) = .{},
/// We point back to completion for now. When issue[1] is fixed,
/// we can juse use that from our heap fields.
/// [1]: https://github.com/ziglang/zig/issues/6611
c: *Completion = undefined,
fn less(_: void, a: *const Timer, b: *const Timer) bool {
return a.next < b.next;
}
};
test "iocp: loop time" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// should never init zero
const now = loop.now();
try testing.expect(now > 0);
while (now == loop.now()) try loop.run(.no_wait);
}
test "iocp: stop" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var called = false;
var c1: Completion = undefined;
loop.timer(&c1, 1_000_000, &called, (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, _: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// Tick
try loop.run(.no_wait);
try testing.expect(!called);
// Stop
loop.stop();
try loop.run(.until_done);
try testing.expect(!called);
}
test "iocp: timer" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var called = false;
var c1: xev.Completion = undefined;
loop.timer(&c1, 1, &called, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// Add another timer
var called2 = false;
var c2: xev.Completion = undefined;
loop.timer(&c2, 100_000, &called2, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// State checking
try testing.expect(c1.state() == .active);
try testing.expect(c2.state() == .active);
// Tick
while (!called) try loop.run(.no_wait);
try testing.expect(called);
try testing.expect(!called2);
// State checking
try testing.expect(c1.state() == .dead);
try testing.expect(c2.state() == .active);
}
test "iocp: timer reset" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, cb);
// We know timer won't be called from the timer test previously.
try loop.run(.no_wait);
try testing.expect(trigger == null);
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .active);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "iocp: timer reset before tick" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, cb);
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .dead);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "iocp: timer reset after trigger" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 1, &trigger, cb);
// Run the timer
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
trigger = null;
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .dead);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "iocp: timer cancellation" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: xev.Completion = undefined;
loop.timer(&c1, 100_000, &trigger, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const ptr: *?TimerTrigger = @ptrCast(@alignCast(ud.?));
ptr.* = r.timer catch unreachable;
return .disarm;
}
}).callback);
// Tick and verify we're not called.
try loop.run(.no_wait);
try testing.expect(trigger == null);
// Cancel the timer
var called = false;
var c_cancel: xev.Completion = .{
.op = .{
.cancel = .{
.c = &c1,
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.cancel catch unreachable;
const ptr: *bool = @ptrCast(@alignCast(ud.?));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel);
// Tick
try loop.run(.until_done);
try testing.expect(called);
try testing.expect(trigger.? == .cancel);
}
test "iocp: canceling a completed operation" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: xev.Completion = undefined;
loop.timer(&c1, 1, &trigger, (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const ptr: *?TimerTrigger = @ptrCast(@alignCast(ud.?));
ptr.* = r.timer catch unreachable;
return .disarm;
}
}).callback);
// Tick and verify we're not called.
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
// Cancel the timer
var called = false;
var c_cancel: xev.Completion = .{
.op = .{
.cancel = .{
.c = &c1,
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.cancel catch unreachable;
const ptr: *bool = @ptrCast(@alignCast(ud.?));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel);
// Tick
try loop.run(.until_done);
try testing.expect(called);
try testing.expect(trigger.? == .expiration);
}
test "iocp: noop" {
var loop = try Loop.init(.{});
defer loop.deinit();
var c: Completion = .{};
loop.add(&c);
try loop.run(.once);
}
test "iocp: file IO" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const utf16_file_name = (try windows.sliceToPrefixedFileW(null, "test_watcher_file")).span();
const f_handle = try windows.exp.CreateFile(utf16_file_name, windows.GENERIC_READ | windows.GENERIC_WRITE, 0, null, windows.OPEN_ALWAYS, windows.FILE_FLAG_OVERLAPPED, null);
defer windows.exp.DeleteFile(utf16_file_name) catch {};
defer windows.CloseHandle(f_handle);
// Perform a write and then a read
var write_buf = [_]u8{ 1, 1, 2, 3, 5, 8, 13 };
var c_write: xev.Completion = .{
.op = .{
.write = .{
.fd = f_handle,
.buffer = .{ .slice = &write_buf },
},
},
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = ud;
_ = l;
_ = c;
_ = r.write catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_write);
// Wait for the write
try loop.run(.until_done);
// Read
var read_buf: [128]u8 = undefined;
var read_len: usize = 0;
var c_read: xev.Completion = .{
.op = .{
.read = .{
.fd = f_handle,
.buffer = .{ .slice = &read_buf },
},
},
.userdata = &read_len,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr: *usize = @ptrCast(@alignCast(ud.?));
ptr.* = r.read catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_read);
// Wait for the read
try loop.run(.until_done);
try testing.expectEqualSlices(u8, &write_buf, read_buf[0..read_len]);
}
test "iocp: file IO with offset" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const utf16_file_name = (try windows.sliceToPrefixedFileW(null, "test_watcher_file")).span();
const f_handle = try windows.exp.CreateFile(utf16_file_name, windows.GENERIC_READ | windows.GENERIC_WRITE, 0, null, windows.OPEN_ALWAYS, windows.FILE_FLAG_OVERLAPPED, null);
defer windows.exp.DeleteFile(utf16_file_name) catch {};
defer windows.CloseHandle(f_handle);
// Perform a write and then a read
var write_buf = [_]u8{ 1, 1, 2, 3, 5, 8, 13 };
var c_write: xev.Completion = .{
.op = .{
.pwrite = .{
.fd = f_handle,
.buffer = .{ .slice = &write_buf },
.offset = 1,
},
},
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = ud;
_ = l;
_ = c;
_ = r.pwrite catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_write);
// Wait for the write
try loop.run(.until_done);
// Read
var read_buf: [128]u8 = undefined;
var read_len: usize = 0;
var c_read: xev.Completion = .{
.op = .{
.pread = .{
.fd = f_handle,
.buffer = .{ .slice = &read_buf },
.offset = 1,
},
},
.userdata = &read_len,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr: *usize = @ptrCast(@alignCast(ud.?));
ptr.* = r.pread catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_read);
// Wait for the read
try loop.run(.until_done);
try testing.expectEqualSlices(u8, &write_buf, read_buf[0..read_len]);
}
test "iocp: socket accept/connect/send/recv/close" {
const mem = std.mem;
const net = std.net;
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a TCP server socket
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const kernel_backlog = 1;
const ln = try windows.WSASocketW(posix.AF.INET, posix.SOCK.STREAM, posix.IPPROTO.TCP, null, 0, windows.ws2_32.WSA_FLAG_OVERLAPPED);
errdefer posix.close(ln);
try posix.setsockopt(ln, posix.SOL.SOCKET, posix.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try posix.bind(ln, &address.any, address.getOsSockLen());
try posix.listen(ln, kernel_backlog);
// Create a TCP client socket
const client_conn = try windows.WSASocketW(posix.AF.INET, posix.SOCK.STREAM, posix.IPPROTO.TCP, null, 0, windows.ws2_32.WSA_FLAG_OVERLAPPED);
errdefer posix.close(client_conn);
var server_conn_result: Result = undefined;
var c_accept: Completion = .{
.op = .{
.accept = .{
.socket = ln,
},
},
.userdata = &server_conn_result,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const conn: *Result = @ptrCast(@alignCast(ud.?));
conn.* = r;
return .disarm;
}
}).callback,
};
loop.add(&c_accept);
// Connect
var connected = false;
var c_connect: xev.Completion = .{
.op = .{
.connect = .{
.socket = client_conn,
.addr = address,
},
},
.userdata = &connected,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.connect catch unreachable;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_connect);
// Wait for the connection to be established
try loop.run(.until_done);
//try testing.expect(server_conn > 0);
try testing.expect(connected);
const server_conn = try server_conn_result.accept;
// Send
var c_send: xev.Completion = .{
.op = .{
.send = .{
.fd = client_conn,
.buffer = .{ .slice = &[_]u8{ 1, 1, 2, 3, 5, 8, 13 } },
},
},
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.send catch unreachable;
_ = ud;
return .disarm;
}
}).callback,
};
loop.add(&c_send);
// Receive
var recv_buf: [128]u8 = undefined;
var recv_len: usize = 0;
var c_recv: xev.Completion = .{
.op = .{
.recv = .{
.fd = server_conn,
.buffer = .{ .slice = &recv_buf },
},
},
.userdata = &recv_len,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr: *usize = @ptrCast(@alignCast(ud.?));
ptr.* = r.recv catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_recv);
// Wait for the send/receive
try loop.run(.until_done);
try testing.expectEqualSlices(u8, c_send.op.send.buffer.slice, recv_buf[0..recv_len]);
// Shutdown
var shutdown = false;
var c_client_shutdown: xev.Completion = .{
.op = .{
.shutdown = .{
.socket = client_conn,
},
},
.userdata = &shutdown,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.shutdown catch unreachable;
const ptr: *bool = @ptrCast(@alignCast(ud.?));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_client_shutdown);
try loop.run(.until_done);
try testing.expect(shutdown);
// Read should be EOF
var eof: ?bool = null;
c_recv = .{
.op = .{
.recv = .{
.fd = server_conn,
.buffer = .{ .slice = &recv_buf },
},
},
.userdata = &eof,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr: *?bool = @ptrCast(@alignCast(ud.?));
ptr.* = if (r.recv) |_| false else |err| switch (err) {
error.EOF => true,
else => false,
};
return .disarm;
}
}).callback,
};
loop.add(&c_recv);
try loop.run(.until_done);
try testing.expect(eof.? == true);
// Close
var client_conn_closed: bool = false;
var c_client_close: xev.Completion = .{
.op = .{
.close = .{
.fd = client_conn,
},
},
.userdata = &client_conn_closed,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.close catch unreachable;
const ptr: *bool = @ptrCast(@alignCast(ud.?));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_client_close);
var ln_closed: bool = false;
var c_server_close: xev.Completion = .{
.op = .{
.close = .{
.fd = ln,
},
},
.userdata = &ln_closed,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
_ = r.close catch unreachable;
const ptr: *bool = @ptrCast(@alignCast(ud.?));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_server_close);
// Wait for the sockets to close
try loop.run(.until_done);
try testing.expect(ln_closed);
try testing.expect(client_conn_closed);
}
test "iocp: recv cancellation" {
const mem = std.mem;
const net = std.net;
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a TCP server socket
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const socket = try windows.WSASocketW(posix.AF.INET, posix.SOCK.DGRAM, posix.IPPROTO.UDP, null, 0, windows.ws2_32.WSA_FLAG_OVERLAPPED);
errdefer posix.close(socket);
try posix.setsockopt(socket, posix.SOL.SOCKET, posix.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try posix.bind(socket, &address.any, address.getOsSockLen());
var recv_buf: [128]u8 = undefined;
var recv_result: Result = undefined;
var c_recv: xev.Completion = .{
.op = .{
.recv = .{
.fd = socket,
.buffer = .{ .slice = &recv_buf },
},
},
.userdata = &recv_result,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const ptr: *Result = @ptrCast(@alignCast(ud.?));
ptr.* = r;
return .disarm;
}
}).callback,
};
loop.add(&c_recv);
try loop.submit();
var c_cancel_recv: xev.Completion = .{
.op = .{ .cancel = .{ .c = &c_recv } },
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = r.cancel catch unreachable;
_ = ud;
_ = l;
_ = c;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel_recv);
// Wait for the send/receive
try loop.run(.until_done);
try testing.expect(recv_result == .recv);
try testing.expectError(error.Canceled, recv_result.recv);
}
test "iocp: accept cancellation" {
const mem = std.mem;
const net = std.net;
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a TCP server socket
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const kernel_backlog = 1;
const ln = try windows.WSASocketW(posix.AF.INET, posix.SOCK.STREAM, posix.IPPROTO.TCP, null, 0, windows.ws2_32.WSA_FLAG_OVERLAPPED);
errdefer posix.close(ln);
try posix.setsockopt(ln, posix.SOL.SOCKET, posix.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try posix.bind(ln, &address.any, address.getOsSockLen());
try posix.listen(ln, kernel_backlog);
var server_conn_result: Result = undefined;
var c_accept: Completion = .{
.op = .{
.accept = .{
.socket = ln,
},
},
.userdata = &server_conn_result,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
_ = c;
const conn: *Result = @ptrCast(@alignCast(ud.?));
conn.* = r;
return .disarm;
}
}).callback,
};
loop.add(&c_accept);
try loop.submit();
var c_cancel_accept: xev.Completion = .{
.op = .{ .cancel = .{ .c = &c_accept } },
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = r.cancel catch unreachable;
_ = ud;
_ = l;
_ = c;
return .disarm;
}
}).callback,
};
loop.add(&c_cancel_accept);
// Wait for the send/receive
try loop.run(.until_done);
try testing.expect(server_conn_result == .accept);
try testing.expectError(error.Canceled, server_conn_result.accept);
}
|
0 | repos/libxev/src | repos/libxev/src/backend/io_uring.zig | const std = @import("std");
const assert = std.debug.assert;
const linux = std.os.linux;
const posix = std.posix;
const queue = @import("../queue.zig");
const xev = @import("../main.zig").IO_Uring;
pub const Loop = struct {
ring: linux.IoUring,
/// The number of active completions. This DOES NOT include completions that
/// are queued in the submissions queue.
active: usize = 0,
/// Our queue of submissions that failed to enqueue.
submissions: queue.Intrusive(Completion) = .{},
/// Cached time
cached_now: posix.timespec = undefined,
flags: packed struct {
/// True if the "now" field is outdated and should be updated
/// when it is used.
now_outdated: bool = true,
/// Whether the loop is stopped or not.
stopped: bool = false,
/// Whether we're in a run or not (to prevent nested runs).
in_run: bool = false,
} = .{},
/// Initialize the event loop. "entries" is the maximum number of
/// submissions that can be queued at one time. The number of completions
/// always matches the number of entries so the memory allocated will be
/// 2x entries (plus the basic loop overhead).
pub fn init(options: xev.Options) !Loop {
const entries = std.math.cast(u13, options.entries) orelse
return error.TooManyEntries;
var result: Loop = .{
// TODO(mitchellh): add an init_advanced function or something
// for people using the io_uring API directly to be able to set
// the flags for this.
.ring = try linux.IoUring.init(entries, 0),
};
result.update_now();
return result;
}
pub fn deinit(self: *Loop) void {
self.ring.deinit();
}
/// Run the event loop. See RunMode documentation for details on modes.
pub fn run(self: *Loop, mode: xev.RunMode) !void {
switch (mode) {
.no_wait => try self.tick_(.no_wait),
.once => try self.tick_(.once),
.until_done => try self.tick_(.until_done),
}
}
/// Stop the loop. This can only be called from the main thread.
/// This will stop the loop forever. Future ticks will do nothing.
/// All completions are safe to read/write once any outstanding
/// `run` or `tick` calls are returned.
pub fn stop(self: *Loop) void {
self.flags.stopped = true;
}
/// Returns the "loop" time in milliseconds. The loop time is updated
/// once per loop tick, before IO polling occurs. It remains constant
/// throughout callback execution.
///
/// You can force an update of the "now" value by calling update_now()
/// at any time from the main thread.
///
/// The clock that is used is not guaranteed. In general, a monotonic
/// clock source is always used if available. This value should typically
/// just be used for relative time calculations within the loop, such as
/// answering the question "did this happen <x> ms ago?".
pub fn now(self: *Loop) i64 {
if (self.flags.now_outdated) self.update_now();
// If anything overflows we just return the max value.
const max = std.math.maxInt(i64);
// Calculate all the values, being careful about overflows in order
// to just return the maximum value.
const sec = std.math.mul(isize, self.cached_now.tv_sec, std.time.ms_per_s) catch return max;
const nsec = @divFloor(self.cached_now.tv_nsec, std.time.ns_per_ms);
return std.math.lossyCast(i64, sec +| nsec);
}
/// Update the cached time.
pub fn update_now(self: *Loop) void {
posix.clock_gettime(posix.CLOCK.MONOTONIC, &self.cached_now) catch {};
self.flags.now_outdated = false;
}
/// Tick the loop. The mode is comptime so we can do some tricks to
/// avoid function calls and runtime branching.
fn tick_(self: *Loop, comptime mode: xev.RunMode) !void {
// We can't nest runs.
if (self.flags.in_run) return error.NestedRunsNotAllowed;
self.flags.in_run = true;
defer self.flags.in_run = false;
// The total number of events we're waiting for.
const wait = switch (mode) {
// until_done is one because we need to wait for at least one
// (if we have any).
.until_done => 1,
.once => 1,
.no_wait => 0,
};
var cqes: [128]linux.io_uring_cqe = undefined;
while (true) {
// If we're stopped then the loop is fully over.
if (self.flags.stopped) break;
// We always note that our "now" value is outdated even if we have
// no completions to execute.
self.flags.now_outdated = true;
if (self.active == 0 and self.submissions.empty()) break;
// If we have no queued submissions then we do the wait as part
// of the submit call, because then we can do exactly once syscall
// to get all our events.
if (self.submissions.empty()) {
_ = self.ring.submit_and_wait(wait) catch |err| switch (err) {
error.SignalInterrupt => continue,
else => return err,
};
} else {
// We have submissions, meaning we have to do multiple submissions
// anyways so we always just do non-waiting ones.
_ = self.submit() catch |err| switch (err) {
error.SignalInterrupt => continue,
else => return err,
};
}
// Wait for completions...
const count = self.ring.copy_cqes(&cqes, wait) catch |err| switch (err) {
// EINTR means our blocking syscall was interrupted by some
// process signal. We just retry when we can. See signal(7).
error.SignalInterrupt => continue,
else => return err,
};
for (cqes[0..count]) |cqe| {
const c = @as(?*Completion, @ptrFromInt(@as(usize, @intCast(cqe.user_data)))) orelse continue;
self.active -= 1;
c.flags.state = .dead;
switch (c.invoke(self, cqe.res)) {
.disarm => {},
.rearm => self.add(c),
}
}
// Subtract our waiters. If we reached zero then we're done.
switch (mode) {
.no_wait => break,
.once => if (count > 0) break,
.until_done => {},
}
}
}
/// The errors that can come from submit. This has to be explicit
/// for now since Zig 0.11 has issues with the inferred error set.
/// We should try again someday.
pub const SubmitError = error{
Unexpected,
SystemResources,
FileDescriptorInvalid,
FileDescriptorInBadState,
CompletionQueueOvercommitted,
SubmissionQueueEntryInvalid,
BufferInvalid,
RingShuttingDown,
OpcodeNotSupported,
SignalInterrupt,
};
/// Submit all queued operations. This never does an io_uring submit
/// and wait operation.
pub fn submit(self: *Loop) SubmitError!void {
_ = try self.ring.submit();
// If we have any submissions that failed to submit, we try to
// send those now. We have to make a copy so that any failures are
// resubmitted without an infinite loop.
var queued = self.submissions;
self.submissions = .{};
while (queued.pop()) |c| self.add_(c, true);
}
/// Add a timer to the loop. The timer will initially execute in "next_ms"
/// from now and will repeat every "repeat_ms" thereafter. If "next_ms" is
/// zero then the timer will invoke on the next loop tick.
///
/// If next_ms is too large of a value that it doesn't fit into the
/// kernel time structure, the maximum sleep value will be used for your
/// system (this is at least 45 days on a 32-bit system, and thousands of
/// years on a 64-bit system).
pub fn timer(
self: *Loop,
c: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
c.* = .{
.op = .{
.timer = .{
.next = self.timer_next(next_ms),
},
},
.userdata = userdata,
.callback = cb,
};
self.add(c);
}
/// Reset a timer to trigger in next_ms.
///
/// Important: c and c_cancel must NEVER be undefined. If you are using
/// timer_reset you should always initial c to the zero value ".{}".
///
/// If the timer completion "c" is dead, this is equivalent to calling
/// "timer" and "c_cancel" is not used. You can verify this scenario by
/// checking "c_cancel.state()" after this call.
///
/// If the timer completion "c" is active, and "c_cancel" is also active,
/// it is assumed that c_cancel is already resetting the timer. The
/// "next_ms" time is updated but otherwise the cancellation continues
/// and reset works.
///
/// If the timer completion "c" is active, and "c_cancel" is dead,
/// "c" is cancelled and restarted to trigger in next_ms.
///
/// There is no guarantee that c_cancel will ever be used. Check the
/// resulting state to know if you can reclaim its memory or not.
pub fn timer_reset(
self: *Loop,
c: *Completion,
c_cancel: *Completion,
next_ms: u64,
userdata: ?*anyopaque,
comptime cb: xev.Callback,
) void {
if (c.state() == .dead) {
self.timer(c, next_ms, userdata, cb);
return;
}
// Update the reset time for the timer to the desired time
// along with all the callbacks.
c.op.timer.reset = self.timer_next(next_ms);
c.userdata = userdata;
c.callback = cb;
// If the cancellation is active, we assume its for this timer
// and do nothing.
if (c_cancel.state() == .active) return;
assert(c_cancel.state() == .dead and c.state() == .active);
// Note: we COULD use IORING_TIMEOUT_UPDATE here with the
// IORING_TIMEOUT_REMOVE op. We don't right now because it complicates
// our logic and ups our required kernel version to 5.11 while this
// works good enough. If there is a compelling reason to use
// IORING_TIMEOUT_UPDATE, I'm open to hearing it.
c_cancel.* = .{
.op = .{ .timer_remove = .{ .timer = c } },
};
self.add(c_cancel);
}
fn timer_next(self: *Loop, next_ms: u64) linux.kernel_timespec {
// Get the timestamp of the absolute time that we'll execute this timer.
// There are lots of failure scenarios here in math. If we see any
// of them we just use the maximum value.
const max: linux.kernel_timespec = .{
.tv_sec = std.math.maxInt(isize),
.tv_nsec = std.math.maxInt(isize),
};
const next_s = std.math.cast(isize, next_ms / std.time.ms_per_s) orelse
return max;
const next_ns = std.math.cast(
isize,
(next_ms % std.time.ms_per_s) * std.time.ns_per_ms,
) orelse return max;
if (self.flags.now_outdated) self.update_now();
return .{
.tv_sec = std.math.add(isize, self.cached_now.tv_sec, next_s) catch
return max,
.tv_nsec = std.math.add(isize, self.cached_now.tv_nsec, next_ns) catch
return max,
};
}
/// Add a completion to the loop. This does NOT start the operation!
/// You must call "submit" at some point to submit all of the queued
/// work.
pub fn add(self: *Loop, completion: *Completion) void {
self.add_(completion, false);
}
/// Internal add function. The only difference is try_submit. If try_submit
/// is true, then this function will attempt to submit the queue to the
/// ring if the submission queue is full rather than filling up our FIFO.
inline fn add_(
self: *Loop,
completion: *Completion,
try_submit: bool,
) void {
// The completion at this point is active no matter what because
// it is going to be queued.
completion.flags.state = .active;
const sqe = self.ring.get_sqe() catch |err| switch (err) {
error.SubmissionQueueFull => retry: {
// If the queue is full and we're in try_submit mode then we
// attempt to submit. This is used during submission flushing.
if (try_submit) {
if (self.submit()) {
// Submission succeeded but we may still fail (unlikely)
// to get an SQE...
if (self.ring.get_sqe()) |sqe| {
break :retry sqe;
} else |retry_err| switch (retry_err) {
error.SubmissionQueueFull => {},
}
} else |_| {}
}
// Add the completion to our submissions to try to flush later.
self.submissions.push(completion);
return;
},
};
// Increase active to the amount in the ring.
self.active += 1;
// Setup the submission depending on the operation
switch (completion.op) {
// Do nothing with noop completions.
.noop => {
completion.flags.state = .dead;
self.active -= 1;
return;
},
.accept => |*v| sqe.prep_accept(
v.socket,
&v.addr,
&v.addr_size,
v.flags,
),
.close => |v| sqe.prep_close(v.fd),
.connect => |*v| sqe.prep_connect(
v.socket,
&v.addr.any,
v.addr.getOsSockLen(),
),
.poll => |v| sqe.prep_poll_add(v.fd, v.events),
.read => |*v| switch (v.buffer) {
.array => |*buf| sqe.prep_read(
v.fd,
buf,
// offset is a u64 but if the value is -1 then it uses
// the offset in the fd.
@bitCast(@as(i64, -1)),
),
.slice => |buf| sqe.prep_read(
v.fd,
buf,
// offset is a u64 but if the value is -1 then it uses
// the offset in the fd.
@bitCast(@as(i64, -1)),
),
},
.pread => |*v| switch (v.buffer) {
.array => |*buf| sqe.prep_read(
v.fd,
buf,
v.offset,
),
.slice => |buf| sqe.prep_read(
v.fd,
buf,
v.offset,
),
},
.recv => |*v| switch (v.buffer) {
.array => |*buf| sqe.prep_recv(
v.fd,
buf,
0,
),
.slice => |buf| sqe.prep_recv(
v.fd,
buf,
0,
),
},
.recvmsg => |*v| {
sqe.prep_recvmsg(
v.fd,
v.msghdr,
0,
);
},
.send => |*v| switch (v.buffer) {
.array => |*buf| sqe.prep_send(
v.fd,
buf.array[0..buf.len],
0,
),
.slice => |buf| sqe.prep_send(
v.fd,
buf,
0,
),
},
.sendmsg => |*v| {
if (v.buffer) |_| {
@panic("TODO: sendmsg with buffer");
}
sqe.prep_sendmsg(
v.fd,
v.msghdr,
0,
);
},
.shutdown => |v| sqe.prep_shutdown(
v.socket,
switch (v.how) {
.both => linux.SHUT.RDWR,
.send => linux.SHUT.WR,
.recv => linux.SHUT.RD,
},
),
.timer => |*v| sqe.prep_timeout(
&v.next,
0,
linux.IORING_TIMEOUT_ABS,
),
.timer_remove => |v| sqe.prep_timeout_remove(
@intFromPtr(v.timer),
0,
),
.write => |*v| switch (v.buffer) {
.array => |*buf| sqe.prep_write(
v.fd,
buf.array[0..buf.len],
// offset is a u64 but if the value is -1 then it uses
// the offset in the fd.
@bitCast(@as(i64, -1)),
),
.slice => |buf| sqe.prep_write(
v.fd,
buf,
// offset is a u64 but if the value is -1 then it uses
// the offset in the fd.
@bitCast(@as(i64, -1)),
),
},
.pwrite => |*v| switch (v.buffer) {
.array => |*buf| sqe.prep_write(
v.fd,
buf.array[0..buf.len],
v.offset,
),
.slice => |buf| sqe.prep_write(
v.fd,
buf,
v.offset,
),
},
.cancel => |v| sqe.prep_cancel(@intCast(@intFromPtr(v.c)), 0),
}
// Our sqe user data always points back to the completion.
// The prep functions above reset the user data so we have to do this
// here.
sqe.user_data = @intFromPtr(completion);
}
/// Submits a completion cancelation request.
/// Results in error.NotFound if the completion couldn't be located because
/// it was already completed or an invalid Completion was provided.
pub fn cancel(
self: *Loop,
c: *Completion,
c_cancel: *Completion,
comptime Userdata: type,
userdata: ?*Userdata,
comptime cb: *const fn (
ud: ?*Userdata,
l: *xev.Loop,
c: *xev.Completion,
r: CancelError!void,
) xev.CallbackAction,
) void {
c_cancel.* = .{
.op = .{
.cancel = .{
.c = c,
},
},
.userdata = userdata,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l_inner: *xev.Loop,
c_inner: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
return @call(.always_inline, cb, .{
@as(?*Userdata, if (Userdata == void) null else @ptrCast(@alignCast(ud))),
l_inner,
c_inner,
if (r.cancel) |_| {} else |err| err,
});
}
}).callback,
};
self.add(c_cancel);
}
};
/// A completion represents a single queued request in the ring.
/// Completions must have stable pointers.
///
/// For the lowest overhead, these can be created manually and queued
/// directly. The API over the individual fields isn't the most user-friendly
/// since it is tune for performance. For user-friendly operations,
/// use the higher-level functions on this structure or the even
/// higher-level abstractions like the Timer struct.
pub const Completion = struct {
/// Operation to execute. This is only safe to read BEFORE the completion
/// is queued. After being queued (with "add"), the operation may change.
op: Operation = .{ .noop = {} },
/// Userdata and callback for when the completion is finished.
userdata: ?*anyopaque = null,
callback: xev.Callback = xev.noopCallback,
/// Internally set
next: ?*Completion = null,
flags: packed struct {
state: State = .dead,
} = .{},
const State = enum(u1) {
/// completion is not part of any loop
dead = 0,
/// completion is registered with epoll
active = 1,
};
/// Returns the state of this completion. There are some things to
/// be caution about when calling this function.
///
/// First, this is only safe to call from the main thread. This cannot
/// be called from any other thread.
///
/// Second, if you are using default "undefined" completions, this will
/// NOT return a valid value if you access it. You must zero your
/// completion using ".{}". You only need to zero the completion once.
/// Once the completion is in use, it will always be valid.
///
/// Third, if you stop the loop (loop.stop()), the completions registered
/// with the loop will NOT be reset to a dead state.
pub fn state(self: Completion) xev.CompletionState {
return switch (self.flags.state) {
.dead => .dead,
.active => .active,
};
}
/// Invokes the callback for this completion after properly constructing
/// the Result based on the res code.
fn invoke(self: *Completion, loop: *Loop, res: i32) xev.CallbackAction {
const result: Result = switch (self.op) {
.noop => unreachable,
.accept => .{
.accept = if (res >= 0)
@intCast(res)
else switch (@as(posix.E, @enumFromInt(-res))) {
.CANCELED => error.Canceled,
.AGAIN => error.Again,
else => |errno| posix.unexpectedErrno(errno),
},
},
.close => .{
.close = if (res >= 0) {} else switch (@as(posix.E, @enumFromInt(-res))) {
else => |errno| posix.unexpectedErrno(errno),
},
},
.connect => .{
.connect = if (res >= 0) {} else switch (@as(posix.E, @enumFromInt(-res))) {
.CANCELED => error.Canceled,
.CONNREFUSED => error.ConnectionRefused,
.TIMEDOUT => error.TimedOut,
.HOSTUNREACH => error.HostUnreachable,
else => |errno| posix.unexpectedErrno(errno),
},
},
.poll => .{
.poll = if (res >= 0) {} else switch (@as(posix.E, @enumFromInt(-res))) {
else => |errno| posix.unexpectedErrno(errno),
},
},
.read => .{
.read = self.readResult(.read, res),
},
.pread => .{
.pread = self.readResult(.pread, res),
},
.recv => .{
.recv = self.readResult(.recv, res),
},
.recvmsg => .{
.recvmsg = self.readResult(.recvmsg, res),
},
.send => .{
.send = if (res >= 0)
@intCast(res)
else switch (@as(posix.E, @enumFromInt(-res))) {
.CANCELED => error.Canceled,
.PIPE => error.BrokenPipe,
.CONNRESET => error.ConnectionReset,
else => |errno| posix.unexpectedErrno(errno),
},
},
.sendmsg => .{
.sendmsg = if (res >= 0)
@intCast(res)
else switch (@as(posix.E, @enumFromInt(-res))) {
.CANCELED => error.Canceled,
.PIPE => error.BrokenPipe,
.CONNRESET => error.ConnectionReset,
else => |errno| posix.unexpectedErrno(errno),
},
},
.shutdown => .{
.shutdown = if (res >= 0) {} else switch (@as(posix.E, @enumFromInt(-res))) {
.CANCELED => error.Canceled,
else => |errno| posix.unexpectedErrno(errno),
},
},
.timer => |*op| timer: {
const e = @as(posix.E, @enumFromInt(-res));
// If we have reset set, that means that we were canceled so
// that we can update our expiration time.
if (op.reset) |r| {
op.next = r;
op.reset = null;
return .rearm;
}
break :timer .{
.timer = if (res >= 0) .request else switch (e) {
.TIME => .expiration,
.CANCELED => .cancel,
else => |errno| posix.unexpectedErrno(errno),
},
};
},
.timer_remove => .{
.timer_remove = if (res >= 0) {} else switch (@as(posix.E, @enumFromInt(-res))) {
.NOENT => error.NotFound,
.BUSY => error.ExpirationInProgress,
// Okay, I don't know why this might happen. It appears to
// happen when the timer you're attempting to cancel has
// already expired, but I can't reproduce this in a unit
// test. If this isn't safe to ignore or someone can find
// the meaning of this, I'd be curious.
.TIME => {},
else => |errno| posix.unexpectedErrno(errno),
},
},
.write => .{
.write = if (res >= 0)
@intCast(res)
else switch (@as(posix.E, @enumFromInt(-res))) {
.CANCELED => error.Canceled,
else => |errno| posix.unexpectedErrno(errno),
},
},
.pwrite => .{
.pwrite = if (res >= 0)
@intCast(res)
else switch (@as(posix.E, @enumFromInt(-res))) {
.CANCELED => error.Canceled,
else => |errno| posix.unexpectedErrno(errno),
},
},
.cancel => .{
.cancel = if (res >= 0) {} else switch (@as(posix.E, @enumFromInt(-res))) {
.NOENT => error.NotFound,
.ALREADY => error.ExpirationInProgress,
else => |errno| posix.unexpectedErrno(errno),
},
},
};
return self.callback(self.userdata, loop, self, result);
}
fn readResult(self: *Completion, comptime op: OperationType, res: i32) ReadError!usize {
if (res > 0) {
return @intCast(res);
}
if (res == 0) {
const active = @field(self.op, @tagName(op));
if (!@hasField(@TypeOf(active), "buffer")) return ReadError.EOF;
// If we receieve a zero byte read, it is an EOF _unless_
// the requestesd buffer size was zero (weird).
return switch (active.buffer) {
.slice => |b| if (b.len == 0) 0 else ReadError.EOF,
.array => ReadError.EOF,
};
}
return switch (@as(posix.E, @enumFromInt(-res))) {
.CANCELED => error.Canceled,
.CONNRESET => error.ConnectionReset,
else => |errno| posix.unexpectedErrno(errno),
};
}
};
pub const OperationType = enum {
/// Do nothing. This operation will not be queued and will never
/// have its callback fired. This is NOT equivalent to the io_uring
/// "nop" operation.
noop,
/// Accept a connection on a socket.
accept,
/// Close a file descriptor.
close,
/// Initiate a connection on a socket.
connect,
/// Poll a fd. Only oneshot mode is supported today.
poll,
/// Read
read,
/// PRead
pread,
/// Receive a message from a socket.
recv,
/// Send a message on a socket.
send,
/// Send a message on a socket using sendmsg (i.e. UDP).
sendmsg,
/// Recieve a message on a socket using recvmsg (i.e. UDP).
recvmsg,
/// Shutdown all or part of a full-duplex connection.
shutdown,
/// PWrite
pwrite,
/// Write
write,
/// A oneshot or repeating timer. For io_uring, this is implemented
/// using the timeout mechanism.
timer,
/// Cancel an existing timer.
timer_remove,
/// Cancel an existing operation.
cancel,
};
/// The result type based on the operation type. For a callback, the
/// result tag will ALWAYS match the operation tag.
pub const Result = union(OperationType) {
noop: void,
accept: AcceptError!posix.socket_t,
close: CloseError!void,
connect: ConnectError!void,
poll: PollError!void,
read: ReadError!usize,
pread: ReadError!usize,
recv: ReadError!usize,
send: WriteError!usize,
sendmsg: WriteError!usize,
recvmsg: ReadError!usize,
shutdown: ShutdownError!void,
pwrite: WriteError!usize,
write: WriteError!usize,
timer: TimerError!TimerTrigger,
timer_remove: TimerRemoveError!void,
cancel: CancelError!void,
};
/// All the supported operations of this event loop. These are always
/// backend-specific and therefore the structure and types change depending
/// on the underlying system in use. The high level operations are
/// done by initializing the request handles.
pub const Operation = union(OperationType) {
noop: void,
accept: struct {
socket: posix.socket_t,
addr: posix.sockaddr = undefined,
addr_size: posix.socklen_t = @sizeOf(posix.sockaddr),
flags: u32 = posix.SOCK.CLOEXEC,
},
close: struct {
fd: posix.fd_t,
},
connect: struct {
socket: posix.socket_t,
addr: std.net.Address,
},
poll: struct {
fd: posix.fd_t,
events: u32 = posix.POLL.IN,
},
read: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
},
pread: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
offset: u64,
},
recv: struct {
fd: posix.fd_t,
buffer: ReadBuffer,
},
send: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
},
sendmsg: struct {
fd: posix.fd_t,
msghdr: *posix.msghdr_const,
/// Optionally, a write buffer can be specified and the given
/// msghdr will be populated with information about this buffer.
buffer: ?WriteBuffer = null,
/// Do not use this, it is only used internally.
iov: [1]posix.iovec_const = undefined,
},
recvmsg: struct {
fd: posix.fd_t,
msghdr: *posix.msghdr,
},
shutdown: struct {
socket: posix.socket_t,
how: posix.ShutdownHow = .both,
},
pwrite: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
offset: u64,
},
write: struct {
fd: posix.fd_t,
buffer: WriteBuffer,
},
timer: struct {
next: linux.kernel_timespec,
/// Only used internally. If this is non-null and timer is
/// CANCELLED, then the timer is rearmed automatically with this
/// as the next time. The callback will not be called on the
/// cancellation.
reset: ?linux.kernel_timespec = null,
},
timer_remove: struct {
timer: *Completion,
},
cancel: struct {
c: *Completion,
},
};
/// ReadBuffer are the various options for reading.
pub const ReadBuffer = union(enum) {
/// Read into this slice.
slice: []u8,
/// Read into this array, just set this to undefined and it will
/// be populated up to the size of the array. This is an option because
/// the other union members force a specific size anyways so this lets us
/// use the other size in the union to support small reads without worrying
/// about buffer allocation.
///
/// To know the size read you have to use the return value of the
/// read operations (i.e. recv).
///
/// Note that the union at the time of this writing could accomodate a
/// much larger fixed size array here but we want to retain flexiblity
/// for future fields.
array: [32]u8,
// TODO: future will have vectors
};
/// WriteBuffer are the various options for writing.
pub const WriteBuffer = union(enum) {
/// Write from this buffer.
slice: []const u8,
/// Write from this array. See ReadBuffer.array for why we support this.
array: struct {
array: [32]u8,
len: usize,
},
// TODO: future will have vectors
};
pub const AcceptError = error{
Canceled,
Again,
Unexpected,
};
pub const CancelError = error{
NotFound,
ExpirationInProgress,
Unexpected,
};
pub const CloseError = error{
Canceled,
Unexpected,
};
pub const ConnectError = error{
Canceled,
Unexpected,
ConnectionRefused,
HostUnreachable,
TimedOut,
};
pub const PollError = error{
Canceled,
Unexpected,
};
pub const ReadError = error{
EOF,
Canceled,
Unexpected,
ConnectionReset,
};
pub const ShutdownError = error{
Canceled,
Unexpected,
};
pub const WriteError = error{
Canceled,
BrokenPipe,
ConnectionReset,
Unexpected,
};
pub const TimerError = error{
Unexpected,
};
pub const TimerRemoveError = error{
NotFound,
ExpirationInProgress,
Unexpected,
};
pub const TimerTrigger = enum {
/// Timer completed due to linked request completing in time.
request,
/// Timer expired.
expiration,
/// Timer was canceled.
cancel,
};
test "Completion size" {
const testing = std.testing;
// Just so we are aware when we change the size
try testing.expectEqual(@as(usize, 152), @sizeOf(Completion));
}
test "io_uring: overflow entries count" {
const testing = std.testing;
{
var loop = try Loop.init(.{});
defer loop.deinit();
}
{
try testing.expectError(error.TooManyEntries, Loop.init(.{
.entries = std.math.pow(u14, 2, 13),
}));
}
}
test "io_uring: default completion" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Due to implementation details, we need to have an ongoing completion to test that the noop operation works properly
var timer_called = false;
var c1: Completion = undefined;
loop.timer(&c1, 1, &timer_called, (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, _: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
var c: Completion = .{};
loop.add(&c);
// Tick
try loop.run(.until_done);
// Completion should have been called and be dead.
try testing.expect(c.state() == .dead);
try testing.expect(timer_called);
}
test "io_uring: timerfd" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// We'll try with a simple timerfd
const Timerfd = @import("../linux/timerfd.zig").Timerfd;
var t = try Timerfd.init(.monotonic, .{});
defer t.deinit();
try t.set(.{}, &.{ .value = .{ .nanoseconds = 1 } }, null);
// Add the timer
var called = false;
var c: Completion = .{
.op = .{
.read = .{
.fd = t.fd,
.buffer = .{ .array = undefined },
},
},
.userdata = &called,
.callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
c: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = c;
_ = r;
_ = l;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c);
// Verify states
try testing.expect(c.state() == .active);
// Tick
try loop.run(.until_done);
try testing.expect(called);
try testing.expect(c.state() == .dead);
}
test "io_uring: timer" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var called = false;
var c1: Completion = undefined;
loop.timer(&c1, 1, &called, (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, _: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// Add another timer
var called2 = false;
var c2: Completion = undefined;
loop.timer(&c2, 100_000, &called2, (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, _: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// State checking
try testing.expect(c1.state() == .active);
try testing.expect(c2.state() == .active);
// Tick
while (!called) try loop.run(.no_wait);
try testing.expect(called);
try testing.expect(!called2);
// State checking
try testing.expect(c1.state() == .dead);
try testing.expect(c2.state() == .active);
}
test "io_uring: timer reset" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
const cb: xev.Callback = (struct {
fn callback(
ud: ?*anyopaque,
l: *xev.Loop,
_: *xev.Completion,
r: xev.Result,
) xev.CallbackAction {
_ = l;
const v = @as(*?TimerTrigger, @ptrCast(ud.?));
v.* = r.timer catch unreachable;
return .disarm;
}
}).callback;
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, cb);
// We know timer won't be called from the timer test previously.
try loop.run(.no_wait);
try testing.expect(trigger == null);
// Reset the timer
var c_cancel: Completion = .{};
loop.timer_reset(&c1, &c_cancel, 1, &trigger, cb);
try testing.expect(c1.state() == .active);
try testing.expect(c_cancel.state() == .active);
// Run
try loop.run(.until_done);
try testing.expect(trigger.? == .expiration);
try testing.expect(c1.state() == .dead);
try testing.expect(c_cancel.state() == .dead);
}
test "io_uring: stop" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var called = false;
var c1: Completion = undefined;
loop.timer(&c1, 1_000_000, &called, (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, _: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = r;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback);
// Tick
try loop.run(.no_wait);
try testing.expect(!called);
// Stop
loop.stop();
try loop.run(.until_done);
try testing.expect(!called);
}
test "io_uring: loop time" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// should never init zero
const now = loop.now();
try testing.expect(now > 0);
// should update on a loop tick
while (now == loop.now()) try loop.run(.no_wait);
}
test "io_uring: timer remove" {
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Add the timer
var trigger: ?TimerTrigger = null;
var c1: Completion = undefined;
loop.timer(&c1, 100_000, &trigger, (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, _: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
const b = @as(*?TimerTrigger, @ptrCast(ud.?));
b.* = r.timer catch unreachable;
return .disarm;
}
}).callback);
// Remove it
var c_remove: Completion = .{
.op = .{
.timer_remove = .{
.timer = &c1,
},
},
.userdata = null,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
_ = ud;
_ = r.timer_remove catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_remove);
// Tick
try loop.run(.until_done);
try testing.expect(trigger.? == .cancel);
}
test "io_uring: socket accept/connect/send/recv/close" {
const mem = std.mem;
const net = std.net;
const os = posix;
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a TCP server socket
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const kernel_backlog = 1;
var ln = try os.socket(address.any.family, os.SOCK.STREAM | os.SOCK.CLOEXEC, 0);
errdefer os.close(ln);
try os.setsockopt(ln, os.SOL.SOCKET, os.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try os.bind(ln, &address.any, address.getOsSockLen());
try os.listen(ln, kernel_backlog);
// Create a TCP client socket
var client_conn = try os.socket(address.any.family, os.SOCK.STREAM | os.SOCK.CLOEXEC, 0);
errdefer os.close(client_conn);
// Accept
var server_conn: os.socket_t = 0;
var c_accept: Completion = .{
.op = .{
.accept = .{
.socket = ln,
},
},
.userdata = &server_conn,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
const conn = @as(*os.socket_t, @ptrCast(@alignCast(ud.?)));
conn.* = r.accept catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_accept);
// Connect
var connected = false;
var c_connect: Completion = .{
.op = .{
.connect = .{
.socket = client_conn,
.addr = address,
},
},
.userdata = &connected,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
_ = r.connect catch unreachable;
const b = @as(*bool, @ptrCast(ud.?));
b.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_connect);
// Wait for the connection to be established
try loop.run(.until_done);
try testing.expect(server_conn > 0);
try testing.expect(connected);
// Send
var c_send: Completion = .{
.op = .{
.send = .{
.fd = client_conn,
.buffer = .{ .slice = &[_]u8{ 1, 1, 2, 3, 5, 8, 13 } },
},
},
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
_ = r.send catch unreachable;
_ = ud;
return .disarm;
}
}).callback,
};
loop.add(&c_send);
// Receive
var recv_buf: [128]u8 = undefined;
var recv_len: usize = 0;
var c_recv: Completion = .{
.op = .{
.recv = .{
.fd = server_conn,
.buffer = .{ .slice = &recv_buf },
},
},
.userdata = &recv_len,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*usize, @ptrCast(@alignCast(ud.?)));
ptr.* = r.recv catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_recv);
// Wait for the send/receive
try loop.run(.until_done);
try testing.expectEqualSlices(u8, c_send.op.send.buffer.slice, recv_buf[0..recv_len]);
// Shutdown
var shutdown = false;
var c_client_shutdown: Completion = .{
.op = .{
.shutdown = .{
.socket = client_conn,
},
},
.userdata = &shutdown,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
_ = r.shutdown catch unreachable;
const ptr = @as(*bool, @ptrCast(@alignCast(ud.?)));
ptr.* = true;
return .disarm;
}
}).callback,
};
loop.add(&c_client_shutdown);
try loop.run(.until_done);
try testing.expect(shutdown);
// Read should be EOF
var eof: ?bool = null;
c_recv = .{
.op = .{
.recv = .{
.fd = server_conn,
.buffer = .{ .slice = &recv_buf },
},
},
.userdata = &eof,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*?bool, @ptrCast(@alignCast(ud.?)));
ptr.* = if (r.recv) |_| false else |err| switch (err) {
error.EOF => true,
else => false,
};
return .disarm;
}
}).callback,
};
loop.add(&c_recv);
try loop.run(.until_done);
try testing.expect(eof.? == true);
// Close
var c_client_close: Completion = .{
.op = .{
.close = .{
.fd = client_conn,
},
},
.userdata = &client_conn,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
_ = r.close catch unreachable;
const ptr = @as(*os.socket_t, @ptrCast(@alignCast(ud.?)));
ptr.* = 0;
return .disarm;
}
}).callback,
};
loop.add(&c_client_close);
var c_server_close: Completion = .{
.op = .{
.close = .{
.fd = ln,
},
},
.userdata = &ln,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
_ = r.close catch unreachable;
const ptr = @as(*os.socket_t, @ptrCast(@alignCast(ud.?)));
ptr.* = 0;
return .disarm;
}
}).callback,
};
loop.add(&c_server_close);
// Wait for the sockets to close
try loop.run(.until_done);
try testing.expect(ln == 0);
try testing.expect(client_conn == 0);
}
test "io_uring: sendmsg/recvmsg" {
const mem = std.mem;
const net = std.net;
const os = posix;
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a TCP server socket
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const server = try posix.socket(address.any.family, posix.SOCK.DGRAM, 0);
defer posix.close(server);
try posix.setsockopt(server, posix.SOL.SOCKET, posix.SO.REUSEPORT, &mem.toBytes(@as(c_int, 1)));
try posix.setsockopt(server, posix.SOL.SOCKET, posix.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try posix.bind(server, &address.any, address.getOsSockLen());
const client = try posix.socket(address.any.family, posix.SOCK.DGRAM, 0);
defer posix.close(client);
// Send
const buffer_send = [_]u8{42} ** 128;
const iovecs_send = [_]os.iovec_const{
os.iovec_const{ .base = &buffer_send, .len = buffer_send.len },
};
var msg_send = os.msghdr_const{
.name = &address.any,
.namelen = address.getOsSockLen(),
.iov = &iovecs_send,
.iovlen = 1,
.control = null,
.controllen = 0,
.flags = 0,
};
var c_sendmsg: Completion = .{
.op = .{
.sendmsg = .{
.fd = client,
.msghdr = &msg_send,
},
},
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = ud;
_ = l;
_ = c;
_ = r.sendmsg catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_sendmsg);
// Recv
var buffer_recv = [_]u8{0} ** 128;
var iovecs_recv = [_]os.iovec{
os.iovec{ .base = &buffer_recv, .len = buffer_recv.len },
};
const addr = [_]u8{0} ** 4;
var address_recv = net.Address.initIp4(addr, 0);
var msg_recv: os.msghdr = os.msghdr{
.name = &address_recv.any,
.namelen = address_recv.getOsSockLen(),
.iov = &iovecs_recv,
.iovlen = 1,
.control = null,
.controllen = 0,
.flags = 0,
};
var recv_size: usize = 0;
var c_recvmsg: Completion = .{
.op = .{
.recvmsg = .{
.fd = server,
.msghdr = &msg_recv,
},
},
.userdata = &recv_size,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
_ = l;
_ = c;
const ptr = @as(*usize, @ptrCast(@alignCast(ud.?)));
ptr.* = r.recvmsg catch unreachable;
return .disarm;
}
}).callback,
};
loop.add(&c_recvmsg);
// Wait for the sockets to close
try loop.run(.until_done);
try testing.expect(recv_size == buffer_recv.len);
try testing.expectEqualSlices(u8, buffer_send[0..buffer_recv.len], buffer_recv[0..]);
}
test "io_uring: socket read cancellation" {
const mem = std.mem;
const net = std.net;
const testing = std.testing;
var loop = try Loop.init(.{});
defer loop.deinit();
// Create a UDP server socket
const address = try net.Address.parseIp4("127.0.0.1", 3131);
const socket = try posix.socket(address.any.family, posix.SOCK.DGRAM | posix.SOCK.CLOEXEC, 0);
errdefer posix.close(socket);
try posix.setsockopt(socket, posix.SOL.SOCKET, posix.SO.REUSEADDR, &mem.toBytes(@as(c_int, 1)));
try posix.bind(socket, &address.any, address.getOsSockLen());
// Read
var read_result: xev.Result = undefined;
var c_read: Completion = .{
.op = .{
.read = .{
.fd = socket,
.buffer = .{
.array = undefined,
},
},
},
.userdata = &read_result,
.callback = (struct {
fn callback(ud: ?*anyopaque, l: *xev.Loop, c: *xev.Completion, r: xev.Result) xev.CallbackAction {
const ptr = @as(*xev.Result, @ptrCast(@alignCast(ud)));
ptr.* = r;
_ = c;
_ = l;
return .disarm;
}
}).callback,
};
loop.add(&c_read);
// Cancellation
var c_read_cancel = Completion{};
loop.cancel(
&c_read,
&c_read_cancel,
void,
null,
(struct {
fn callback(ud: ?*void, l: *xev.Loop, c: *xev.Completion, r: xev.CancelError!void) xev.CallbackAction {
r catch unreachable;
_ = c;
_ = l;
_ = ud;
return .disarm;
}
}).callback,
);
loop.add(&c_read_cancel);
// Wait for the read to be cancelled
try loop.run(.until_done);
try testing.expectEqual(OperationType.read, @as(OperationType, read_result));
try testing.expectError(error.Canceled, read_result.read);
}
|
0 | repos/libxev | repos/libxev/examples/_basic.zig | const std = @import("std");
const Instant = std.time.Instant;
const xev = @import("xev");
pub fn main() !void {
// Initialize the loop state. Notice we can use a stack-allocated
// value here. We can even pass around the loop by value! The loop
// will contain all of our "completions" (watches).
var loop = try xev.Loop.init(.{});
defer loop.deinit();
// Initialize a completion and a watcher. A completion is the actual
// thing a loop does for us, and a watcher is a high-level structure
// to help make it easier to use completions.
var c: xev.Completion = undefined;
const timer = try xev.Timer.init();
timer.run(&loop, &c, 1, void, null, timerCallback);
// Run the loop until there are no more completions.
try loop.run(.until_done);
}
fn timerCallback(
_: ?*void,
_: *xev.Loop,
_: *xev.Completion,
result: xev.Timer.RunError!void,
) xev.CallbackAction {
_ = result catch unreachable;
return .disarm;
}
|
0 | repos/libxev | repos/libxev/examples/_basic.c | #include <stddef.h>
#include <stdio.h>
#include <xev.h>
xev_cb_action timerCallback(xev_loop* loop, xev_completion* c, int result, void *userdata) {
return XEV_DISARM;
}
int main(void) {
// Initialize the loop state. Notice we can use a stack-allocated
// value here. We can even pass around the loop by value! The loop
// will contain all of our "completions" (watches).
xev_loop loop;
if (xev_loop_init(&loop) != 0) {
printf("xev_loop_init failure\n");
return 1;
}
// Initialize a completion and a watcher. A completion is the actual
// thing a loop does for us, and a watcher is a high-level structure
// to help make it easier to use completions.
xev_completion c;
xev_watcher w;
// In this case, we initialize a timer watcher.
if (xev_timer_init(&w) != 0) {
printf("xev_timer_init failure\n");
return 1;
}
// Configure the timer to run in 1ms. This requires the completion that
// we actually configure to become a timer, and the loop that the
// completion should be registered with.
xev_timer_run(&w, &loop, &c, 1, NULL, &timerCallback);
// Run the loop until there are no more completions.
xev_loop_run(&loop, XEV_RUN_UNTIL_DONE);
xev_timer_deinit(&w);
xev_loop_deinit(&loop);
return 0;
}
|
0 | repos/libxev | repos/libxev/examples/async.c | #include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <xev.h>
#define UNUSED(v) ((void)v);
xev_cb_action timer_callback(xev_loop* loop, xev_completion* c, int result, void *userdata) {
UNUSED(loop); UNUSED(c); UNUSED(result);
// Send the notification to our async which will wake up the loop and
// call the waiter callback.
xev_async_notify((xev_watcher *)userdata);
return XEV_DISARM;
}
xev_cb_action async_callback(xev_loop* loop, xev_completion* c, int result, void *userdata) {
UNUSED(loop); UNUSED(c); UNUSED(result);
bool *notified = (bool *)userdata;
*notified = true;
return XEV_DISARM;
}
int main(void) {
xev_loop loop;
if (xev_loop_init(&loop) != 0) {
printf("xev_loop_init failure\n");
return 1;
}
// Initialize an async watcher. An async watcher can be used to wake up
// the event loop from any thread.
xev_completion async_c;
xev_watcher async;
if (xev_async_init(&async) != 0) {
printf("xev_async_init failure\n");
return 1;
}
// We start a "waiter" for the async watcher. Only one waiter can
// ever be set at a time. This callback will be called when the async
// is notified (via xev_async_notify).
bool notified = false;
xev_async_wait(&async, &loop, &async_c, ¬ified, &async_callback);
// Initialize a timer. The timer will fire our async.
xev_completion timer_c;
xev_watcher timer;
if (xev_timer_init(&timer) != 0) {
printf("xev_timer_init failure\n");
return 1;
}
xev_timer_run(&timer, &loop, &timer_c, 1, &async, &timer_callback);
// Run the loop until there are no more completions. This means
// that both the async watcher AND the timer have to complete.
// Notice that if you comment out `xev_async_notify` in the timer
// callback this blocks forever (because the async watcher is waiting).
xev_loop_run(&loop, XEV_RUN_UNTIL_DONE);
if (!notified) {
printf("FAIL! async should've been notified!");
return 1;
}
xev_timer_deinit(&timer);
xev_async_deinit(&async);
xev_loop_deinit(&loop);
return 0;
}
|
0 | repos/libxev | repos/libxev/examples/million-timers.c | // libuv million-timers benchmark ported to libxev
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <xev.h>
#define NUM_TIMERS (10 * 1000 * 1000)
static int timer_cb_called;
xev_cb_action timer_cb(xev_loop* loop, xev_completion* c, int result, void *userdata) {
timer_cb_called++;
return XEV_DISARM;
}
#ifdef _WIN32
#include <windows.h>
uint64_t hrtime(void) {
static int initialized = 0;
static LARGE_INTEGER start_timestamp;
static uint64_t qpc_tick_duration;
if (!initialized) {
initialized = 1;
LARGE_INTEGER qpc_freq;
QueryPerformanceFrequency(&qpc_freq);
qpc_tick_duration = 1e9 / qpc_freq.QuadPart;
QueryPerformanceCounter(&start_timestamp);
}
LARGE_INTEGER t;
QueryPerformanceCounter(&t);
t.QuadPart -= start_timestamp.QuadPart;
return (uint64_t)t.QuadPart * qpc_tick_duration;
}
#else
uint64_t hrtime(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_nsec + (ts.tv_sec * 1e9);
}
#endif
int main(void) {
xev_watcher* timers;
xev_completion* completions;
xev_loop loop;
uint64_t before_all;
uint64_t before_run;
uint64_t after_run;
uint64_t after_all;
int timeout;
int i;
int err;
timers = malloc(NUM_TIMERS * sizeof(timers[0]));
completions = malloc(NUM_TIMERS * sizeof(completions[0]));
if ((err = xev_loop_init(&loop)) != 0) {
fprintf(stderr, "xev_loop_init failure\n");
return 1;
}
timeout = 1;
before_all = hrtime();
for (i = 0; i < NUM_TIMERS; i++) {
if (i % 1000 == 0) timeout++;
xev_timer_init(timers + i);
xev_timer_run(timers + i, &loop, completions + i, timeout, NULL, &timer_cb);
}
before_run = hrtime();
xev_loop_run(&loop, XEV_RUN_UNTIL_DONE);
after_run = hrtime();
after_all = hrtime();
if (timer_cb_called != NUM_TIMERS) return 1;
free(timers);
free(completions);
fprintf(stderr, "%.2f seconds total\n", (after_all - before_all) / 1e9);
fprintf(stderr, "%.2f seconds init\n", (before_run - before_all) / 1e9);
fprintf(stderr, "%.2f seconds dispatch\n", (after_run - before_run) / 1e9);
fprintf(stderr, "%.2f seconds cleanup\n", (after_all - after_run) / 1e9);
fflush(stderr);
return 0;
}
|
0 | repos/libxev | repos/libxev/examples/threadpool.c | #include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <xev.h>
// We create a job struct that can contain additional state that we use
// for our threadpool tasks. In this case, we only have a boolean to note
// we're done but you can imagine any sort of user data here!
typedef struct {
xev_threadpool_task pool_task;
bool done;
} job_t;
// We use the container_of trick to access our job_t from a threadpool task.
// See task_callback.
#define container_of(ptr, type, member) \
((type *) ((char *) (ptr) - offsetof(type, member)))
// This is the callback that is invoked when the task is being worked on.
void task_callback(xev_threadpool_task* t) {
job_t *job = container_of(t, job_t, pool_task);
job->done = true;
}
int main(void) {
xev_threadpool pool;
if (xev_threadpool_init(&pool, NULL) != 0) {
printf("xev_threadpool_init failure\n");
return 1;
}
// A "batch" is used to group together multiple tasks that we schedule
// atomically into the thread pool. We initialize an empty batch that
// we'll add our tasks to.
xev_threadpool_batch batch;
xev_threadpool_batch_init(&batch);
// Create all our tasks we want to submit. The number here can be changed
// to anything!
const int TASK_COUNT = 128;
job_t jobs[TASK_COUNT];
for (int i = 0; i < TASK_COUNT; i++) {
jobs[i].done = false;
xev_threadpool_task_init(&jobs[i].pool_task, &task_callback);
xev_threadpool_batch_push_task(&batch, &jobs[i].pool_task);
}
// Schedule our batch. This will immediately queue and start the tasks
// if there are available threads. This will also automatically start
// threads as needed. After this, you can reclaim the memory associated
// with "batch".
xev_threadpool_schedule(&pool, &batch);
// We need a way to detect that our work is done. Normally here you'd
// use some sort of waitgroup or signal the libxev loop or something.
// Since this example is showing ONLY the threadpool, we just do a
// somewhat unsafe thing and just race on done booleans...
while (true) {
bool done = true;
for (int i = 0; i < TASK_COUNT; i++) {
if (!jobs[i].done) {
done = false;
break;
}
}
if (done) break;
}
// Shutdown notifies the threadpool to notify the threads it has launched
// to start shutting down. This MUST be called.
xev_threadpool_shutdown(&pool);
// Deinit reclaims memory.
xev_threadpool_deinit(&pool);
printf("%d tasks completed!\n", TASK_COUNT);
return 0;
}
|
0 | repos/libxev | repos/libxev/docs/xev_threadpool.3.scd | xev_threadpool(3) "github.com/mitchellh/libxev" "Library Functions Manual"
# NAME
xev_threadpool - generic thread pool for scheduling work
# LIBRARY
libxev (_-lxev_)
# SYNOPSIS
```
#include <xev.h>;
xev_threadpool pool;
```
# DESCRIPTION
*xev_threadpool* is a generic thread pool that is lock-free, allocation-free
(except spawning threads), supports batch scheduling, dynamically spawns
threads, and handles thread spawn failure. It can be used to queue work that
should be executed on other threads as resources permit.
This man page focuses on the C API for the thread pool. The Zig API
can be discovered by reading the `src/ThreadPool.zig` file. This page will
provide a broad overview of using the thread pool API but won't cover
specific details such as an exhaustive list of error return codes.
There are multiple types that are important when working with thread pools.
- *xev_threadpool* is the pool itself.
- *xev_threadpool_config* is used to configure a new pool.
- *xev_threadpool_task* is a single task to execute.
- *xev_threadpool_batch* is a batch of zero or more tasks.
All the types are expected to be allocated by the program author. They
can be allocated on the stack or heap, but their pointer lifetimes must
remain valid as documented throughout this manual.
# POOL CREATION AND MANAGEMENT
To start, a pool must be initialized. The easiest way to initialize a pool
is with xev_threadpool_init(3) and no configuration. The default configuration
will choose reasonable defaults.
```
xev_threadpool pool;
assert(xev_threadpool_init(&pool, null));
```
The pool is now ready to have task batches scheduled to it. To shutdown
a pool, you must call xev_shutdown(3) and xev_deinit(3).
```
xev_shutdown(&pool);
xev_deinit(&pool);
```
The xev_shutdown(3) call notifies all threads that the pool is in a shutdown
state. They complete their most recent tasks, shut down, and accept no new
work. This function returns _immediately_. The xev_deinit(3) call waits for
all the threads in the pool to exit, then cleans up any additional state.
xev_deinit(3) and xev_shutdown(3) can be called in any order.
The xev_threadpool(3) value must be pointer-stable until after
xev_deinit(3) returns. After this point, no other xev_threadpool API
calls can be called using the pointer. You may reinitialize and reuse the
value.
# TASK SCHEDULING
A task is a single unit of work. A task is inserted into a _batch_.
A batch is scheduled with a _pool_. The first step is to define a task:
```
void do_expensive_work(xev_threadpool_task* t) {}
xev_threadpool_task t;
xev_threadpool_task_init(&t, &do_expensive_work);
```
The task then must be added to a batch. The code below creates a batch
with a single item "t". You can use xev_threadpool_batch_push_batch(3) to merge
multiple batches.
```
xev_threadpool_batch b;
xev_threadpool_batch_init(&b);
xev_threadpool_batch_push_task(&b, &t);
```
Finally, the batch must be scheduled with the pool with
xev_threadpool_schedule(3):
```
xev_threadpool_schedule(&pool, &b);
```
The scheduled work can be picked up immediately. The work is executed
on a separate thread so if resources are available, the work may begin
immediately. Otherwise, it is queued for execution later.
You can call xev_threadpool_schedule(3) from multiple threads against
the same pool to schedule work concurrently. You MUST NOT read or write
batches concurrently; for concurrent scheduling each thread should build
up its own batch.
## MEMORY LIFETIMES
- The task "t" must be pointer-stable until the task has completed execution.
- The task "t" can only be scheduled in one pool exactly one time until
it has completed execution. You CAN NOT initialize a task and add it to
multiple batches.
- The batch "b" can be copied and doesn't need to be pointer-stable. The
batch can be freed at anytime.
## TASK STATE
The callback type only gives access to the `xev_threadpool_task` pointer.
To associate state or userdata with a task, make the task a member of
a struct and use the `container_of` macro (shown below) to access the
parent container.
An example is shown below:
```
typedef struct {
xev_threadpool_task task;
bool state;
// other state can be here, too.
} work_t;
#define container_of(ptr, type, member) \
((type *) ((char *) (ptr) - offsetof(type, member)))
void do_expensive_work(xev_threadpool_task* t) {
work_t *work = container_of(t, work_t, task);
work->state = true;
}
work_t work;
xev_threadpool_task_init(&work.task, &do_expensive_work);
```
*IMPORTANT:* The `xev_threadpool_task` must be aligned to a power-of-2
memory address. When using it in a struct, be careful that it is properly
aligned.
# SEE ALSO
xev(7), xev-c(7)
<https://zig.news/kprotty/resource-efficient-thread-pools-with-zig-3291>
<https://github.com/mitchellh/libxev>
# AUTHORS
King Protty (https://github.com/kprotty) is the author of the thread pool.
Mitchell Hashimoto ([email protected]) is the author of the C API and
documentation. Plus any open source contributors. See <https://github.com/mitchellh/libxev>.
|
0 | repos/libxev | repos/libxev/docs/xev_completion_zero.3.scd | xev_completion_zero(3) "github.com/mitchellh/libxev" "Library Functions Manual"
# NAME
xev_completion_zero - set a completion to the zero value
# LIBRARY
libxev (_-lxev_)
# SYNOPSIS
```
#include <xev.h>;
xev_completion_zero(&c);
```
# DESCRIPTION
*xev_completion_zero* sets default values for the given completion, rather
than uninitialized memory state. This is particularly useful if you're using
xev_completion_state(3). Otherwise, it isn't necessary.
_You typically do NOT need to call this!_ You are allowed to pass uninitialized
completions to almost all functions that start an operation. However, you
_do need to call this_ if you are inspecting completion state (i.e.
xev_completion_state(3)) before the completion is started.
You do NOT need to call this after you are done using a completion. Once
a completion has been used, the value of the completion is always initialized.
The ONLY time you need to call this is if you're inspecting completion state
prior to the completion ever being used.
# SEE ALSO
xev_completion_state(3), xev(7), xev-c(7)
<https://github.com/mitchellh/libxev>
# AUTHORS
Mitchell Hashimoto ([email protected]) and any open source contributors.
See <https://github.com/mitchellh/libxev>.
|
0 | repos/libxev | repos/libxev/docs/xev.7.scd | xev(7) "github.com/mitchellh/libxev" "Miscellaneous Information Manual"
# NAME
libxev - high-performance, cross-platform event loop
# DESCRIPTION
*libxev* is a high-performance, cross-platform event loop. libxev provides a
unified event loop abstraction for non-blocking IO, timers, signals, events,
and more that works on macOS, Windows, Linux, and WebAssembly (browser and WASI).
It is written in Zig but exports a C-compatible API (which makes it compatible
with any language out there that can communicate with C APIs).
This manual will focus on general libxev concepts. For details specific
to the C API see xev-c(7) and for details specific to the Zig API see
xev-zig(7).
# FEATURES
*Cross-platform.* Linux (io_uring(7) and epoll(7)), macOS (kqueue(2)),
WebAssembly + WASI (poll_oneoff(2), threaded and non-threaded runtimes).
(Windows support is planned and coming soon)
*Proactor API.* Work is submitted to the libxev event loop and the caller
is notified of work _completion_, as opposed to work _readiness_.
*Zero runtime allocations.* This helps make runtime performance more
predictable and makes libxev well suited for embedded environments.
*Timers, TCP, UDP.* High-level platform-agnostic APIs for interacting
with timers, TCP/UDP sockets, and more.
*Generic Thread Pool (Optional).* You can create a generic thread pool,
configure its resource utilization, and use this to perform custom background
tasks. The thread pool is used by some backends to do non-blocking tasks that
don't have reliable non-blocking APIs (such as local file operations with
kqueue(7)). The thread pool can be shared across multiple threads and event
loops to optimize resource utilization.
*Low-level and High-Level API.* The high-level API is platform-agnostic
but has some opinionated behavior and limited flexibility. The high-level
API is recommended but the low-level API is always an available escape hatch.
The low-level API is platform-specific and provides a mechanism for libxev
users to squeeze out maximum performance. The low-level API is _just enough
abstraction_ above the OS interface to make it easier to use without
sacrificing noticable performance.
*Tree Shaking (Zig).* This is a feature of Zig, but substantially benefits
libraries such as libxev. Zig will only include function calls and features
that you actually use. If you don't use a particular kind of high-level
watcher (such as UDP sockets), then the functionality related to that
abstraction is not compiled into your final binary at all. This lets libxev
support optional "nice-to-have" functionality that may be considered
"bloat" in some cases, but the end user doesn't have to pay for it.
*Dependency-free.* libxev has no dependencies other than the built-in
OS APIs at runtime. The C library depends on libc. This makes it very
easy to cross-compile.
# EVENT LOOP PROGRAMMING
Event loop programming is a programming design pattern where a program
registers multiple events and is notified when those events occur.
Concretely, event loop programming is typically used as a foundational
component of asynchronous programs. It is the core mechanism used to
for asynchronous network IO, disk IO, timers, signals, and more.
There are two popular event loop styles: _proactor_ and _reactor_.
The reactor pattern notifies the event loop user of task _readiness_,
whereas the proactor pattern notifies the event loop user of task _completion_.
Examples of reactor APIs: POSIX poll(2), BSD kqueue(2). Examples of proactor
APIs: Linux io_uring(7), Windows IOCP, and JavaScript IO callbacks.
*libxev is a proactor event loop.*
# LIBXEV GENERAL CONCEPTS
## TERMINOLOGY
- *Loop*: An instance of an event loop.
- *Completion*: A request to perform some work. A completion is _queued_
in an event loop, and an associated callback is invoked when the work
is completed.
- *Watcher*: A slightly higher level abstraction to make it easier to
work with common capabilities in a cross-platform way. For example,
files, sockets, async/notify patterns, etc. These are just opinionated
logic and sugar on top of completions.
- *Disarm/Rearm*: A completion that is actively being worked on by the
event loop is considered _armed_. When a completion is complete, the
program can choose to _disarm_ or _rearm_ the completion. If a completion
is disarmed, it is no longer in use. If a completion is rearmed, it will
repeat its work and fire the associated callback again.
## MEMORY ALLOCATION
libxev doesn't do any runtime memory allocation. The caller is expected
to allocate memory and provide libxev with pointers. The caller is then
free to allocate on the stack or heap in the way that is best suited for
their program and lifecycle.
The lifecycles of various resources in libxev are documented in their
resource-specific documentation sections. libxev _never_ takes ownership
of a programmer-provided memory location.
## LOOPS
The `xev.Loop` (Zig) and `xev_loop` (C) types represent a single event
loop. A program may have multiple event loops, but most typically there
is at most one per thread. If you are just getting started, just use a
single event loop per thread until you're more comfortable with the API.
Completions are _added_ to the event loop. Completions are explained
in more detail in the next section but at a high level represent a request
to perform some work. The event loop does NOT begin performing any work
until the loop is run. This is important, so to repeat it in another way:
an _added_ completion does nothing until the next time a loop is run.
An event loop is _run_ with `loop.run` (Zig) or xev_loop_run(3) (C).
The first thing the event loop does is _submit_ any _added_ completions.
Submitted completions begin their requested work in the background. If a
completion doesn't complete and the loop run returns (such as with a "no wait"
run mode -- covered later), the work will continue in the background and
may be checked for completion with another loop tick.
A loop can be run in multiple _run modes_:
- *No Wait.* This runs through the loop without blocking on any completions.
If a completion is ready, the callbacks will be fired, but otherwise
the loop will return.
- *Once.* This runs the loop and waits for at least one completion to become
ready before returning.
- *Until Done.* This runs the loop and waits until there are no more
completions in the event loop. This can potentially run forever as
completion callbacks rearm or register new completions. This is the
most common run mode and is usually used to start up the "main" loop
of a program. The loop can be stopped from the main thread using the
`stop` API call.
An event loop has to be allocated to a stable memory address (stable
pointer) _once you have called `run`_ once. Prior to calling run, you
can copy the loop value. However, once the loop has run any times
(even a no wait run once), the loop pointer must remain stable.
## COMPLETIONS
The `xev.Completion` (Zig) and `xev_completion` (C) types represent a
single request to do some work, such as read or write a file, accept
a network connection, sleep on a timer, etc.
Completions do nothing until they are _added_ to an event loop (and
even then, do nothing until the next event loop tick). Completions must
only be added to one event loop at a time. After a completion is dead
(see states below), it can be used with another event loop or the memory
can be reclaimed.
Completions have multiple states that are managed by libxev:
- *Dead.* The completion can be configured for new work and added to
an event loop. The completion is not actively being used by the loop
so you can also free memory associated with it. This is its initial state.
- *Added.* The completion is queued to be submitted to an event loop.
The completion must no longer be modified.
- *Active.* The completion is submitted as part of an event loop and actively
performing some work. The completion must no longer be modified.
The memory associated with a completion is always owned by the program
author. libxev never takes ownership of memory and never dynamically
allocates or free memory on its own. The memory associated with a completion
cannot be freed unless the the completion is dead.
A completion is dead only in the following scenarios:
- The completion has never been added to an event loop.
- The completion callback has been fired and the callback return action
was "disarm." The completion memory is safe to free _during the callback_,
in this case, too.
- The event loop that a completion was added to has been deinitialized.
Even if the completion never fired, all system resources registered by
libxev for the completion are no longer in use.
## CALLBACKS
When the work associated with a completion has been completed, libxev
will invoke the registered callback. At a low-level, all callbacks have
the same function signature. The Zig signature is shown below.
```
pub const xev.Callback = *const fn (
userdata: ?*anyopaque,
loop: *xev.Loop,
completion: *xev.Completion,
result: xev.Result,
) xev.CallbackAction;
```
*NOTE:* The "low-level" word above is important. In general, program authors
will be using the _high-level_ APIs which have varied and more
programmer-friendly callback signatures depending on the feature. For example,
TCP connection accept will provide the new connection in the callback.
Underneath these abstractions, however, this regular completion callback
signature is used.
Every callback gets access to some optional programmer-provided userdata,
the loop where the completion was added, the completion itself, and a
result union.
The result of the callback is the action to take and is either "disarm"
or "rearm" (covered in TERMINOLOGY above).
Some callback tips for common behaviors:
- You can reuse the completion for a different operation now as long as
you return the disarm action. For example, after a TCP connection callback,
you can reuse the same completion now to begin writing data. The "loop"
parameter is specifically provided to make this easy.
- You can free the memory associated with a completion from the callback
if you no longer intend to use it. In fact, its unsafe to free memory
for an active completion except after the callback is fired (or the
event loop is deinitialized).
# EXAMPLE (C)
The example below shows how the C API can be used to initialize an event
loop and run a 5 second timer. To learn more about the C API, see
xev-c(7).
```
#include <stddef.h>
#include <stdio.h>
#include <xev.h>
xev_cb_action timerCallback(xev_loop* loop, xev_completion* c, int result, void *userdata) {
return XEV_DISARM;
}
int main(void) {
// Initialize the loop state. Notice we can use a stack-allocated
// value here. We can even pass around the loop by value! The loop
// will contain all of our "completions" (watches).
xev_loop loop;
if (xev_loop_init(&loop, 128) != 0) {
printf("xev_loop_init failure\n");
return 1;
}
// Initialize a completion and a watcher. A completion is the actual
// thing a loop does for us, and a watcher is a high-level structure
// to help make it easier to use completions.
xev_completion c;
xev_watcher w;
// In this case, we initialize a timer watcher.
if (xev_timer_init(&w) != 0) {
printf("xev_timer_init failure\n");
return 1;
}
// Configure the timer to run in 5s. This requires the completion that
// we actually configure to become a timer, and the loop that the
// completion should be registered with.
xev_timer_run(&w, &loop, &c, 5000, NULL, &timerCallback);
// Run the loop until there are no more completions.
xev_loop_run(&loop, XEV_RUN_UNTIL_DONE);
xev_timer_deinit(&w);
xev_loop_deinit(&loop);
return 0;
}
```
# EXAMPLE (ZIG)
The example below shows how the Zig API can be used to initialize an event
loop and run a 5 second timer. To learn more about the Zig API, see
xev-zig(7).
```
const xev = @import("xev");
pub fn main() !void {
// Initialize the loop state. Notice we can use a stack-allocated
// value here. We can even pass around the loop by value! The loop
// will contain all of our "completions" (watches).
var loop = try xev.Loop.init(.{ .entries = 128 });
defer loop.deinit();
// Initialize a completion and a watcher. A completion is the actual
// thing a loop does for us, and a watcher is a high-level structure
// to help make it easier to use completions.
var c: xev.Completion = undefined;
// In this case, we initialize a timer watcher.
const w = try xev.Timer.init();
defer w.deinit();
// Configure the timer to run in 5s. This requires the completion that
// we actually configure to become a timer, and the loop that the
// completion should be registered with.
w.run(&loop, &c, 5000, void, null, &timerCallback);
// Run the loop until there are no more completions.
try loop.run(.until_done);
}
fn timerCallback(
userdata: ?*void,
loop: *xev.Loop,
c: *xev.Completion,
result: xev.Timer.RunError!void,
) xev.CallbackAction {
_ = userdata;
_ = loop;
_ = c;
_ = result catch unreachable;
return .disarm;
}
```
# SEE ALSO
xev-c(7), xev-zig(7)
<https://github.com/mitchellh/libxev>
# AUTHORS
Mitchell Hashimoto ([email protected]) and any open source contributors.
See <https://github.com/mitchellh/libxev>.
|
0 | repos/libxev | repos/libxev/docs/xev-faq.7.scd | xev-faq(7) "github.com/mitchellh/libxev" "Miscellaneous Information Manual"
# NAME
libxev Frequently Asked Questions (FAQ)
# DESCRIPTION
This manual page contains frequently asked questions around the design
and usage of libxev. The goal of this page is to collect various tips or
varios common challenges people run into. The information in this page
may duplicate documentation that is available for a specific API or
concept.
# FAQ
## HOW CAN I CHECK IF A COMPLETION, TIMER, SOCKET, ETC. IS ACTIVE?
Some other event loops (libuv, libev) have a function that can check if
a given _thing_ (timer, socket, etc.) is "active." "Active" means that the
thing in question is part of an event loop and _running_ (the definition of
running is dependent on the type of the watcher).
For libxev, the correct question to ask is: is this _completion_ active?
A completion represents a single operation and can be used to determine
if a corresponding watcher is active if the complation was used with
the watcher.
Completion state can be checked using the `c.state()` function (Zig) or
the xev_completion_state(3) function (C). This will return an enum value
of "dead" or "alive". More enum values may be added in the future if
it is determined that finer grained state is useful.
# SUGGEST A TOPIC
There is still a lot of improvement to be made to the documentation. Please
suggest any topics to cover at <https://github.com/mitchellh/libxev>.
# SEE ALSO
xev(7)
<https://github.com/mitchellh/libxev>
# AUTHORS
Mitchell Hashimoto ([email protected]) and any open source contributors.
See <https://github.com/mitchellh/libxev>.
|
0 | repos/libxev | repos/libxev/docs/xev-c.7.scd | xev-c(7) "github.com/mitchellh/libxev" "Miscellaneous Information Manual"
# NAME
libxev C API
# DESCRIPTION
See xev(7) for a general libxev overview. This man page will give a more
specific overview of the C API for libxev.
TODO -- This isn't written yet, sorry.
|
0 | repos/libxev | repos/libxev/docs/xev-zig.7.scd | xev-zig(7) "github.com/mitchellh/libxev" "Miscellaneous Information Manual"
# NAME
libxev Zig API
# DESCRIPTION
See xev(7) for a general libxev overview. This man page will give a more
specific overview of the Zig API for libxev.
libxev is written in Zig and exports a native Zig API. The Zig API
takes advantage of first-class Zig concepts such as comptime parameters,
error sets, etc. in order to provide an idiomatic Zig experience. Beyond
basic idioms, these Zig features usually result in improved performance
over the C API. For example, all callbacks in the Zig API must be available
at comptime because the callback call is always inlined -- this results in
a noticable performance improvement over equivalent C consumption of libxev.
The primary Zig API is visible in `src/main.zig` in the libxev source. The main file uses a somewhat convoluted `usingnamespace` to setup the
API so it isn't immediately obvious, but the API is provided by the `Xev`
function. For example, available consts are: `xev.Loop`, `xev.Completion`,
etc.
# INSTALLATION
libxev has no dependencies, making it easy to install into your Zig project
using any available Zig package manager or Git submodules. The `build.zig`
file exports a `module` constant that you can use with `addAnonymousModule`:
```
// build.zig
const libxev = @import("submodules/libxev/build.zig");
pub fn build(b: *std.build.Builder) !void {
// Your other build options...
my_exe.addAnonymousModule("xev", libxev.module);
}
```
The package is then available in your source code as "xev":
```
// Your main.zig
const xev = @import("xev");
```
# QUICK START
## INITIALIZING A LOOP
After importing xev, the first thing you'll need is an event loop:
```
var loop = try xev.Loop.init(.{});
defer loop.deinit(); // or wherever your cleanup is
```
This initializes the resources associated with an event loop. An event loop
_can be copied_ until the first `run` is called. Once `run` is called,
the loop *must be at a stable memory location* (pointer won't change).
## ADDING A COMPLETION
An empty event loop does nothing. You must add one or more _completions_
to request work to be done asynchronously. A completion is represented with
the `xev.Completion` structure. A completion *must have a stable memory
location when it is added to the loop* until the completion is finished.
xev(7) talks more about completion lifetimes and memory allocation requirements.
The example below adds a timer to the previously initialized event loop:
```
var c_timer: xev.Completion = undefined;
const timer = try xev.Timer.init();
timer.run(&loop, &c_timer, 5_000, void, null, timerCallback);
```
This uses the `xev.Timer` _high-level abstraction_. This is an abstraction
that provides a common API on top of multiple operating system async APIs.
You can also use the low-level API to manage completions with the loop directly,
but these are not portable.
**Important concept to notice:** The completion allocation is up to the
program author. It can be stack allocated (such as in this case) or heap
allocated. The pointer must remain stable until it is complete. This gives
program authors substantial power over optimizing the performance of libxev.
In fact, libxev doesn't perform _any_ dynamic memory allocation.
## RUNNING THE LOOP
An added completion is a request for future work. The work does not start
until the completion is submitted. A completion is submitted only during
an event loop tick. To tick the event loop, use the `run` method:
```
try loop.run(.until_done);
```
The enum value is an `xev.RunMode` described in xev(7). This call will run
until the loop has no more active completions (`until_done`). At
some point (in about 5 seconds), this will call the registered `timerCallback`.
# MEMORY ALLOCATIONS
You'll notice that none of the Zig APIs take an allocator as an argument.
libxev does not perform any dynamic memory allocations. All memory must be
provided by the caller. This section will outline specific memory management
rules you should be aware of when using libxev.
*xev.Loop.* This can be copied and moved until `submit`, `tick`, or `run`
is called. Once any of those loop functions are called, the loop memory
must remain at a stable address. It is not safe to copy, move, or reuse the
memory that loop is occupying until `deinit` completes.
*xev.Completion.* This can be copied and moved until the completion is
added to a loop. A completion is often added to a loop with any function
call on a high-level abstraction that takes a completion pointer as a function
argument such as `xev.Timer.run`. The completion memory can be reclaimed
only when the callback associated with it is fired or the loop is deinitialized.
# SUGGEST A TOPIC
There is still a lot of improvement to be made to the documentation. Please
suggest any topics to cover at <https://github.com/mitchellh/libxev>.
# SEE ALSO
xev(7)
<https://github.com/mitchellh/libxev>
# AUTHORS
Mitchell Hashimoto ([email protected]) and any open source contributors.
See <https://github.com/mitchellh/libxev>.
|
0 | repos/libxev | repos/libxev/docs/xev_completion_state.3.scd | xev_completion_state(3) "github.com/mitchellh/libxev" "Library Functions Manual"
# NAME
xev_completion_state - check the state of a completion
# LIBRARY
libxev (_-lxev_)
# SYNOPSIS
```
#include <xev.h>;
xev_completion_state_t state = xev_completion_state(&c);
```
# DESCRIPTION
*xev_completion_state* returns the current state of a completion: dead
if the completion is not currently used or active if the completion is
part of an event loop.
The state is sometimes useful to determine if an operation has already
started or not. For example, the completion state can be used to check if
a timer is running or not.
The completion must be initialized if there is any chance the program author
may call this function prior to the completion being used. To initialize
a completion use xev_completion_zero(3).
This function can only be called from the main thread.
# RETURN VALUES
The return value is always a valid xev_completion_state_t enum value.
# SEE ALSO
xev_completion_state(3), xev(7), xev-c(7)
<https://github.com/mitchellh/libxev>
# AUTHORS
Mitchell Hashimoto ([email protected]) and any open source contributors.
See <https://github.com/mitchellh/libxev>.
|
0 | repos/libxev | repos/libxev/website/next.config.js | /** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.jsx',
})
module.exports = withNextra(nextConfig)
|
0 | repos/libxev | repos/libxev/website/.eslintrc.json | {
"extends": "next/core-web-vitals"
}
|
0 | repos/libxev | repos/libxev/website/package.json | {
"name": "website",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@next/font": "13.1.2",
"@types/node": "18.11.18",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.10",
"eslint": "8.32.0",
"eslint-config-next": "13.1.2",
"next": "13.1.2",
"nextra": "^2.2.5",
"nextra-theme-docs": "^2.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.9.4"
}
}
|
0 | repos/libxev | repos/libxev/website/package-lock.json | {
"name": "website",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "website",
"version": "0.1.0",
"dependencies": {
"@next/font": "13.1.2",
"@types/node": "18.11.18",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.10",
"eslint": "8.32.0",
"eslint-config-next": "13.1.2",
"next": "13.1.2",
"nextra": "^2.2.5",
"nextra-theme-docs": "^2.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.9.4"
}
},
"node_modules/@babel/runtime": {
"version": "7.20.7",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.7.tgz",
"integrity": "sha512-UF0tvkUtxwAgZ5W/KrkHf0Rn0fdnLDU9ScxBrEVNUprE/MzirjK4MJUX1/BVDv00Sv8cljtukVK1aky++X1SjQ==",
"dependencies": {
"regenerator-runtime": "^0.13.11"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@eslint/eslintrc": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz",
"integrity": "sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==",
"dependencies": {
"ajv": "^6.12.4",
"debug": "^4.3.2",
"espree": "^9.4.0",
"globals": "^13.19.0",
"ignore": "^5.2.0",
"import-fresh": "^3.2.1",
"js-yaml": "^4.1.0",
"minimatch": "^3.1.2",
"strip-json-comments": "^3.1.1"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/@headlessui/react": {
"version": "1.7.7",
"resolved": "https://registry.npmjs.org/@headlessui/react/-/react-1.7.7.tgz",
"integrity": "sha512-BqDOd/tB9u2tA0T3Z0fn18ktw+KbVwMnkxxsGPIH2hzssrQhKB5n/6StZOyvLYP/FsYtvuXfi9I0YowKPv2c1w==",
"dependencies": {
"client-only": "^0.0.1"
},
"engines": {
"node": ">=10"
},
"peerDependencies": {
"react": "^16 || ^17 || ^18",
"react-dom": "^16 || ^17 || ^18"
}
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.11.8",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz",
"integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==",
"dependencies": {
"@humanwhocodes/object-schema": "^1.2.1",
"debug": "^4.1.1",
"minimatch": "^3.0.5"
},
"engines": {
"node": ">=10.10.0"
}
},
"node_modules/@humanwhocodes/module-importer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
"integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==",
"engines": {
"node": ">=12.22"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/nzakas"
}
},
"node_modules/@humanwhocodes/object-schema": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA=="
},
"node_modules/@mdx-js/mdx": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mdx-js/mdx/-/mdx-2.2.1.tgz",
"integrity": "sha512-hZ3ex7exYLJn6FfReq8yTvA6TE53uW9UHJQM9IlSauOuS55J9y8RtA7W+dzp6Yrzr00/U1sd7q+Wf61q6SfiTQ==",
"dependencies": {
"@types/estree-jsx": "^1.0.0",
"@types/mdx": "^2.0.0",
"estree-util-build-jsx": "^2.0.0",
"estree-util-is-identifier-name": "^2.0.0",
"estree-util-to-js": "^1.1.0",
"estree-walker": "^3.0.0",
"hast-util-to-estree": "^2.0.0",
"markdown-extensions": "^1.0.0",
"periscopic": "^3.0.0",
"remark-mdx": "^2.0.0",
"remark-parse": "^10.0.0",
"remark-rehype": "^10.0.0",
"unified": "^10.0.0",
"unist-util-position-from-estree": "^1.0.0",
"unist-util-stringify-position": "^3.0.0",
"unist-util-visit": "^4.0.0",
"vfile": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/@mdx-js/react": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-2.2.1.tgz",
"integrity": "sha512-YdXcMcEnqZhzql98RNrqYo9cEhTTesBiCclEtoiQUbJwx87q9453GTapYU6kJ8ZZ2ek1Vp25SiAXEFy5O/eAPw==",
"dependencies": {
"@types/mdx": "^2.0.0",
"@types/react": ">=16"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"peerDependencies": {
"react": ">=16"
}
},
"node_modules/@napi-rs/simple-git": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git/-/simple-git-0.1.8.tgz",
"integrity": "sha512-BvOMdkkofTz6lEE35itJ/laUokPhr/5ToMGlOH25YnhLD2yN1KpRAT4blW9tT8281/1aZjW3xyi73bs//IrDKA==",
"engines": {
"node": ">= 10"
},
"optionalDependencies": {
"@napi-rs/simple-git-android-arm-eabi": "0.1.8",
"@napi-rs/simple-git-android-arm64": "0.1.8",
"@napi-rs/simple-git-darwin-arm64": "0.1.8",
"@napi-rs/simple-git-darwin-x64": "0.1.8",
"@napi-rs/simple-git-linux-arm-gnueabihf": "0.1.8",
"@napi-rs/simple-git-linux-arm64-gnu": "0.1.8",
"@napi-rs/simple-git-linux-arm64-musl": "0.1.8",
"@napi-rs/simple-git-linux-x64-gnu": "0.1.8",
"@napi-rs/simple-git-linux-x64-musl": "0.1.8",
"@napi-rs/simple-git-win32-arm64-msvc": "0.1.8",
"@napi-rs/simple-git-win32-x64-msvc": "0.1.8"
}
},
"node_modules/@napi-rs/simple-git-android-arm-eabi": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-android-arm-eabi/-/simple-git-android-arm-eabi-0.1.8.tgz",
"integrity": "sha512-JJCejHBB1G6O8nxjQLT4quWCcvLpC3oRdJJ9G3MFYSCoYS8i1bWCWeU+K7Br+xT+D6s1t9q8kNJAwJv9Ygpi0g==",
"cpu": [
"arm"
],
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-android-arm64": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-android-arm64/-/simple-git-android-arm64-0.1.8.tgz",
"integrity": "sha512-mraHzwWBw3tdRetNOS5KnFSjvdAbNBnjFLA8I4PwTCPJj3Q4txrigcPp2d59cJ0TC51xpnPXnZjYdNwwSI9g6g==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-darwin-arm64": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-darwin-arm64/-/simple-git-darwin-arm64-0.1.8.tgz",
"integrity": "sha512-ufy/36eI/j4UskEuvqSH7uXtp3oXeLDmjQCfKJz3u5Vx98KmOMKrqAm2H81AB2WOtCo5mqS6PbBeUXR8BJX8lQ==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-darwin-x64": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-darwin-x64/-/simple-git-darwin-x64-0.1.8.tgz",
"integrity": "sha512-Vb21U+v3tPJNl+8JtIHHT8HGe6WZ8o1Tq3f6p+Jx9Cz71zEbcIiB9FCEMY1knS/jwQEOuhhlI9Qk7d4HY+rprA==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-linux-arm-gnueabihf": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-arm-gnueabihf/-/simple-git-linux-arm-gnueabihf-0.1.8.tgz",
"integrity": "sha512-6BPTJ7CzpSm2t54mRLVaUr3S7ORJfVJoCk2rQ8v8oDg0XAMKvmQQxOsAgqKBo9gYNHJnqrOx3AEuEgvB586BuQ==",
"cpu": [
"arm"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-linux-arm64-gnu": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-arm64-gnu/-/simple-git-linux-arm64-gnu-0.1.8.tgz",
"integrity": "sha512-qfESqUCAA/XoQpRXHptSQ8gIFnETCQt1zY9VOkplx6tgYk9PCeaX4B1Xuzrh3eZamSCMJFn+1YB9Ut8NwyGgAA==",
"cpu": [
"arm64"
],
"hasInstallScript": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-linux-arm64-musl": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-arm64-musl/-/simple-git-linux-arm64-musl-0.1.8.tgz",
"integrity": "sha512-G80BQPpaRmQpn8dJGHp4I2/YVhWDUNJwcCrJAtAdbKFDCMyCHJBln2ERL/+IEUlIAT05zK/c1Z5WEprvXEdXow==",
"cpu": [
"arm64"
],
"hasInstallScript": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-linux-x64-gnu": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-x64-gnu/-/simple-git-linux-x64-gnu-0.1.8.tgz",
"integrity": "sha512-NI6o1sZYEf6vPtNWJAm9w8BxJt+LlSFW0liSjYe3lc3e4dhMfV240f0ALeqlwdIldRPaDFwZSJX5/QbS7nMzhw==",
"cpu": [
"x64"
],
"hasInstallScript": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-linux-x64-musl": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-x64-musl/-/simple-git-linux-x64-musl-0.1.8.tgz",
"integrity": "sha512-wljGAEOW41er45VTiU8kXJmO480pQKzsgRCvPlJJSCaEVBbmo6XXbFIXnZy1a2J3Zyy2IOsRB4PVkUZaNuPkZQ==",
"cpu": [
"x64"
],
"hasInstallScript": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-win32-arm64-msvc": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-win32-arm64-msvc/-/simple-git-win32-arm64-msvc-0.1.8.tgz",
"integrity": "sha512-QuV4QILyKPfbWHoQKrhXqjiCClx0SxbCTVogkR89BwivekqJMd9UlMxZdoCmwLWutRx4z9KmzQqokvYI5QeepA==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@napi-rs/simple-git-win32-x64-msvc": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-win32-x64-msvc/-/simple-git-win32-x64-msvc-0.1.8.tgz",
"integrity": "sha512-UzNS4JtjhZhZ5hRLq7BIUq+4JOwt1ThIKv11CsF1ag2l99f0123XvfEpjczKTaa94nHtjXYc2Mv9TjccBqYOew==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/env": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.1.2.tgz",
"integrity": "sha512-PpT4UZIX66VMTqXt4HKEJ+/PwbS+tWmmhZlazaws1a+dbUA5pPdjntQ46Jvj616i3ZKN9doS9LHx3y50RLjAWg=="
},
"node_modules/@next/eslint-plugin-next": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.1.2.tgz",
"integrity": "sha512-WGaNVvIYphdriesP6r7jq/8l7u38tzotnVQuxc1RYKLqYYApSsrebti3OCPoT3Gx0pw2smPIFHH98RzcsgW5GQ==",
"dependencies": {
"glob": "7.1.7"
}
},
"node_modules/@next/font": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/font/-/font-13.1.2.tgz",
"integrity": "sha512-NXGXGFGiOKEnvBIHq9cdFTKbHO2/4B3Zd9K27M7j1DioIQVar7oVRqZMYs0h3XMVEZLwjjkdAtqRPCzzd3RtXg=="
},
"node_modules/@next/swc-android-arm-eabi": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.2.tgz",
"integrity": "sha512-7mRz1owoGsbfIcdOJA3kk7KEwPZ+OvVT1z9DkR/yru4QdVLF69h/1SHy0vlUNQMxDRllabhxCfkoZCB34GOGAg==",
"cpu": [
"arm"
],
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-android-arm64": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.1.2.tgz",
"integrity": "sha512-mgjZ2eJSayovQm1LcE54BLSI4jjnnnLtq5GY5g+DdPuUiCT644gKtjZ/w2BQvuIecCqqBO+Ph9yzo/wUTq7NLg==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-darwin-arm64": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.2.tgz",
"integrity": "sha512-RikoQqy109r2222UJlyGs4dZw2BibkfPqpeFdW5JEGv+L2PStlHID8DwyVYbmHfQ0VIBGvbf/NAUtFakAWlhwg==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.2.tgz",
"integrity": "sha512-JbDZjaTvL8gyPC5TAH6OnD4jmXPkyUxRYPvu08ZmhT/XAFBb/Cso0BdXyDax/BPCG70mimP9d3hXNKNq+A0VtQ==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-freebsd-x64": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.2.tgz",
"integrity": "sha512-ax4j8VrdFQ/xc3W7Om0u1vnDxVApQHKsChBbAMynCrnycZmpbqK4MZu4ZkycT+mx2eccCiqZROpbzDbEdPosEw==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm-gnueabihf": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.2.tgz",
"integrity": "sha512-NcRHTesnCxnUvSJa637PQJffBBkmqi5XS/xVWGY7dI6nyJ+pC96Oj7kd+mcjnFUQI5lHKbg39qBWKtOzbezc4w==",
"cpu": [
"arm"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.2.tgz",
"integrity": "sha512-AxJdjocLtPrsBY4P2COSBIc3crT5bpjgGenNuINoensOlXhBkYM0aRDYZdydwXOhG+kN2ngUvfgitop9pa204w==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.2.tgz",
"integrity": "sha512-JmNimDkcCRq7P5zpkdqeaSZ69qKDntEPtyIaMNWqy5M0WUJxGim0Fs6Qzxayiyvuuh9Guxks4woQ/j/ZvX/c8Q==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.2.tgz",
"integrity": "sha512-TsLsjZwUlgmvI42neTuIoD6K9RlXCUzqPtvIClgXxVO0um0DiZwK+M+0zX/uVXhMVphfPY2c5YeR1zFSIONY4A==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.2.tgz",
"integrity": "sha512-eSkyXgCXydEFPTkcncQOGepafedPte6JT/OofB9uvruucrrMVBagCASOuPxodWEMrlfEKSXVnExMKIlfmQMD7A==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.2.tgz",
"integrity": "sha512-DmXFaRTgt2KrV9dmRLifDJE+cYiutHVFIw5/C9BtnwXH39uf3YbPxeD98vNrtqqqZVVLXY/1ySaSIwzYnqeY9g==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-ia32-msvc": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.2.tgz",
"integrity": "sha512-3+nBkuFs/wT+lmRVQNH5SyDT7I4vUlNPntosEaEP63FuYQdPLaxz0GvcR66MdFSFh2fsvazpe4wciOwVS4FItQ==",
"cpu": [
"ia32"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-x64-msvc": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.2.tgz",
"integrity": "sha512-avsyveEvcvH42PvKjR4Pb8JlLttuGURr2H3ZhS2b85pHOiZ7yjH3rMUoGnNzuLMApyxYaCvd4MedPrLhnNhkog==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
"integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
"dependencies": {
"@nodelib/fs.stat": "2.0.5",
"run-parallel": "^1.1.9"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/@nodelib/fs.stat": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
"integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==",
"engines": {
"node": ">= 8"
}
},
"node_modules/@nodelib/fs.walk": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
"integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
"dependencies": {
"@nodelib/fs.scandir": "2.1.5",
"fastq": "^1.6.0"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/@pkgr/utils": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.3.1.tgz",
"integrity": "sha512-wfzX8kc1PMyUILA+1Z/EqoE4UCXGy0iRGMhPwdfae1+f0OXlLqCk+By+aMzgJBzR9AzS4CDizioG6Ss1gvAFJw==",
"dependencies": {
"cross-spawn": "^7.0.3",
"is-glob": "^4.0.3",
"open": "^8.4.0",
"picocolors": "^1.0.0",
"tiny-glob": "^0.2.9",
"tslib": "^2.4.0"
},
"engines": {
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/unts"
}
},
"node_modules/@popperjs/core": {
"version": "2.11.6",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
"integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/popperjs"
}
},
"node_modules/@rushstack/eslint-patch": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz",
"integrity": "sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg=="
},
"node_modules/@swc/helpers": {
"version": "0.4.14",
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.14.tgz",
"integrity": "sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==",
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@types/acorn": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/@types/acorn/-/acorn-4.0.6.tgz",
"integrity": "sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==",
"dependencies": {
"@types/estree": "*"
}
},
"node_modules/@types/debug": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz",
"integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==",
"dependencies": {
"@types/ms": "*"
}
},
"node_modules/@types/estree": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz",
"integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ=="
},
"node_modules/@types/estree-jsx": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/estree-jsx/-/estree-jsx-1.0.0.tgz",
"integrity": "sha512-3qvGd0z8F2ENTGr/GG1yViqfiKmRfrXVx5sJyHGFu3z7m5g5utCQtGp/g29JnjflhtQJBv1WDQukHiT58xPcYQ==",
"dependencies": {
"@types/estree": "*"
}
},
"node_modules/@types/hast": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz",
"integrity": "sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==",
"dependencies": {
"@types/unist": "*"
}
},
"node_modules/@types/js-yaml": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.5.tgz",
"integrity": "sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA=="
},
"node_modules/@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ=="
},
"node_modules/@types/katex": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.11.1.tgz",
"integrity": "sha512-DUlIj2nk0YnJdlWgsFuVKcX27MLW0KbKmGVoUHmFr+74FYYNUDAaj9ZqTADvsbE8rfxuVmSFc7KczYn5Y09ozg=="
},
"node_modules/@types/mdast": {
"version": "3.0.10",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.10.tgz",
"integrity": "sha512-W864tg/Osz1+9f4lrGTZpCSO5/z4608eUp19tbozkq2HJK6i3z1kT0H9tlADXuYIb1YYOBByU4Jsqkk75q48qA==",
"dependencies": {
"@types/unist": "*"
}
},
"node_modules/@types/mdx": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.3.tgz",
"integrity": "sha512-IgHxcT3RC8LzFLhKwP3gbMPeaK7BM9eBH46OdapPA7yvuIUJ8H6zHZV53J8hGZcTSnt95jANt+rTBNUUc22ACQ=="
},
"node_modules/@types/ms": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz",
"integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA=="
},
"node_modules/@types/node": {
"version": "18.11.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA=="
},
"node_modules/@types/prop-types": {
"version": "15.7.5",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
},
"node_modules/@types/react": {
"version": "18.0.26",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.26.tgz",
"integrity": "sha512-hCR3PJQsAIXyxhTNSiDFY//LhnMZWpNNr5etoCqx/iUfGc5gXWtQR2Phl908jVR6uPXacojQWTg4qRpkxTuGug==",
"dependencies": {
"@types/prop-types": "*",
"@types/scheduler": "*",
"csstype": "^3.0.2"
}
},
"node_modules/@types/react-dom": {
"version": "18.0.10",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.10.tgz",
"integrity": "sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==",
"dependencies": {
"@types/react": "*"
}
},
"node_modules/@types/scheduler": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="
},
"node_modules/@types/unist": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
"integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ=="
},
"node_modules/@typescript-eslint/parser": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.2.tgz",
"integrity": "sha512-38zMsKsG2sIuM5Oi/olurGwYJXzmtdsHhn5mI/pQogP+BjYVkK5iRazCQ8RGS0V+YLk282uWElN70zAAUmaYHw==",
"dependencies": {
"@typescript-eslint/scope-manager": "5.48.2",
"@typescript-eslint/types": "5.48.2",
"@typescript-eslint/typescript-estree": "5.48.2",
"debug": "^4.3.4"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.2.tgz",
"integrity": "sha512-zEUFfonQid5KRDKoI3O+uP1GnrFd4tIHlvs+sTJXiWuypUWMuDaottkJuR612wQfOkjYbsaskSIURV9xo4f+Fw==",
"dependencies": {
"@typescript-eslint/types": "5.48.2",
"@typescript-eslint/visitor-keys": "5.48.2"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/types": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.2.tgz",
"integrity": "sha512-hE7dA77xxu7ByBc6KCzikgfRyBCTst6dZQpwaTy25iMYOnbNljDT4hjhrGEJJ0QoMjrfqrx+j1l1B9/LtKeuqA==",
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.2.tgz",
"integrity": "sha512-bibvD3z6ilnoVxUBFEgkO0k0aFvUc4Cttt0dAreEr+nrAHhWzkO83PEVVuieK3DqcgL6VAK5dkzK8XUVja5Zcg==",
"dependencies": {
"@typescript-eslint/types": "5.48.2",
"@typescript-eslint/visitor-keys": "5.48.2",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.2.tgz",
"integrity": "sha512-z9njZLSkwmjFWUelGEwEbdf4NwKvfHxvGC0OcGN1Hp/XNDIcJ7D5DpPNPv6x6/mFvc1tQHsaWmpD/a4gOvvCJQ==",
"dependencies": {
"@typescript-eslint/types": "5.48.2",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/acorn": {
"version": "8.8.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
"integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/acorn-jsx": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
"peerDependencies": {
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/arch": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/arch/-/arch-2.2.0.tgz",
"integrity": "sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/arg": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/arg/-/arg-1.0.0.tgz",
"integrity": "sha512-Wk7TEzl1KqvTGs/uyhmHO/3XLd3t1UeU4IstvPXVzGPM522cTjqjNZ99esCkcL52sjqjo8e8CTBcWhkxvGzoAw=="
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
},
"node_modules/aria-query": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz",
"integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==",
"dependencies": {
"deep-equal": "^2.0.5"
}
},
"node_modules/array-includes": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.6.tgz",
"integrity": "sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"get-intrinsic": "^1.1.3",
"is-string": "^1.0.7"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"engines": {
"node": ">=8"
}
},
"node_modules/array.prototype.flat": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz",
"integrity": "sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"es-shim-unscopables": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/array.prototype.flatmap": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz",
"integrity": "sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"es-shim-unscopables": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/array.prototype.tosorted": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.1.tgz",
"integrity": "sha512-pZYPXPRl2PqWcsUs6LOMn+1f1532nEoPTYowBtqLwAW+W8vSVhkIGnmOX1t/UQjD6YGI0vcD2B1U7ZFGQH9jnQ==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"es-shim-unscopables": "^1.0.0",
"get-intrinsic": "^1.1.3"
}
},
"node_modules/ast-types-flow": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz",
"integrity": "sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag=="
},
"node_modules/astring": {
"version": "1.8.4",
"resolved": "https://registry.npmjs.org/astring/-/astring-1.8.4.tgz",
"integrity": "sha512-97a+l2LBU3Op3bBQEff79i/E4jMD2ZLFD8rHx9B6mXyB2uQwhJQYfiDqUwtfjF4QA1F2qs//N6Cw8LetMbQjcw==",
"bin": {
"astring": "bin/astring"
}
},
"node_modules/available-typed-arrays": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz",
"integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/axe-core": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.6.2.tgz",
"integrity": "sha512-b1WlTV8+XKLj9gZy2DZXgQiyDp9xkkoe2a6U6UbYccScq2wgH/YwCeI2/Jq2mgo0HzQxqJOjWZBLeA/mqsk5Mg==",
"engines": {
"node": ">=4"
}
},
"node_modules/axobject-query": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",
"integrity": "sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg==",
"dependencies": {
"deep-equal": "^2.0.5"
}
},
"node_modules/bail": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz",
"integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dependencies": {
"fill-range": "^7.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/call-bind": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
"dependencies": {
"function-bind": "^1.1.1",
"get-intrinsic": "^1.0.2"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"engines": {
"node": ">=6"
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001445",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001445.tgz",
"integrity": "sha512-8sdQIdMztYmzfTMO6KfLny878Ln9c2M0fc7EH60IjlP4Dc4PiCy7K2Vl3ITmWgOyPgVQKa5x+UP/KqFsxj4mBg==",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/browserslist"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/caniuse-lite"
}
]
},
"node_modules/ccount": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
"integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/character-entities": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz",
"integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/character-entities-html4": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz",
"integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/character-entities-legacy": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz",
"integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/character-reference-invalid": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz",
"integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/client-only": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz",
"integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="
},
"node_modules/clipboardy": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-1.2.2.tgz",
"integrity": "sha512-16KrBOV7bHmHdxcQiCvfUFYVFyEah4FI8vYT1Fr7CGSA4G+xBWMEfUEQJS1hxeHGtI9ju1Bzs9uXSbj5HZKArw==",
"dependencies": {
"arch": "^2.1.0",
"execa": "^0.8.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/clsx": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz",
"integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==",
"engines": {
"node": ">=6"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/comma-separated-tokens": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",
"integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/commander": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
"integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==",
"engines": {
"node": ">= 12"
}
},
"node_modules/compute-scroll-into-view": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-2.0.4.tgz",
"integrity": "sha512-y/ZA3BGnxoM/QHHQ2Uy49CLtnWPbt4tTPpEEZiEmmiWBFKjej7nEyH8Ryz54jH0MLXflUYA3Er2zUxPSJu5R+g=="
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/csstype": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
"integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw=="
},
"node_modules/damerau-levenshtein": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",
"integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA=="
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/decode-named-character-reference": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz",
"integrity": "sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==",
"dependencies": {
"character-entities": "^2.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/deep-equal": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.0.tgz",
"integrity": "sha512-RdpzE0Hv4lhowpIUKKMJfeH6C1pXdtT1/it80ubgWqwI3qpuxUBpC1S4hnHg+zjnuOoDkzUtUCEEkG+XG5l3Mw==",
"dependencies": {
"call-bind": "^1.0.2",
"es-get-iterator": "^1.1.2",
"get-intrinsic": "^1.1.3",
"is-arguments": "^1.1.1",
"is-array-buffer": "^3.0.1",
"is-date-object": "^1.0.5",
"is-regex": "^1.1.4",
"is-shared-array-buffer": "^1.0.2",
"isarray": "^2.0.5",
"object-is": "^1.1.5",
"object-keys": "^1.1.1",
"object.assign": "^4.1.4",
"regexp.prototype.flags": "^1.4.3",
"side-channel": "^1.0.4",
"which-boxed-primitive": "^1.0.2",
"which-collection": "^1.0.1",
"which-typed-array": "^1.1.9"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/deep-is": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ=="
},
"node_modules/define-lazy-prop": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz",
"integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==",
"engines": {
"node": ">=8"
}
},
"node_modules/define-properties": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz",
"integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==",
"dependencies": {
"has-property-descriptors": "^1.0.0",
"object-keys": "^1.1.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
"engines": {
"node": ">=6"
}
},
"node_modules/diff": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz",
"integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==",
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"dependencies": {
"path-type": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
"integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==",
"dependencies": {
"esutils": "^2.0.2"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/emoji-regex": {
"version": "9.2.2",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="
},
"node_modules/enhanced-resolve": {
"version": "5.12.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz",
"integrity": "sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ==",
"dependencies": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/es-abstract": {
"version": "1.21.1",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.21.1.tgz",
"integrity": "sha512-QudMsPOz86xYz/1dG1OuGBKOELjCh99IIWHLzy5znUB6j8xG2yMA7bfTV86VSqKF+Y/H08vQPR+9jyXpuC6hfg==",
"dependencies": {
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"es-set-tostringtag": "^2.0.1",
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"function.prototype.name": "^1.1.5",
"get-intrinsic": "^1.1.3",
"get-symbol-description": "^1.0.0",
"globalthis": "^1.0.3",
"gopd": "^1.0.1",
"has": "^1.0.3",
"has-property-descriptors": "^1.0.0",
"has-proto": "^1.0.1",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.4",
"is-array-buffer": "^3.0.1",
"is-callable": "^1.2.7",
"is-negative-zero": "^2.0.2",
"is-regex": "^1.1.4",
"is-shared-array-buffer": "^1.0.2",
"is-string": "^1.0.7",
"is-typed-array": "^1.1.10",
"is-weakref": "^1.0.2",
"object-inspect": "^1.12.2",
"object-keys": "^1.1.1",
"object.assign": "^4.1.4",
"regexp.prototype.flags": "^1.4.3",
"safe-regex-test": "^1.0.0",
"string.prototype.trimend": "^1.0.6",
"string.prototype.trimstart": "^1.0.6",
"typed-array-length": "^1.0.4",
"unbox-primitive": "^1.0.2",
"which-typed-array": "^1.1.9"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/es-get-iterator": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz",
"integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==",
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"has-symbols": "^1.0.3",
"is-arguments": "^1.1.1",
"is-map": "^2.0.2",
"is-set": "^2.0.2",
"is-string": "^1.0.7",
"isarray": "^2.0.5",
"stop-iteration-iterator": "^1.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/es-set-tostringtag": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz",
"integrity": "sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==",
"dependencies": {
"get-intrinsic": "^1.1.3",
"has": "^1.0.3",
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-shim-unscopables": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz",
"integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==",
"dependencies": {
"has": "^1.0.3"
}
},
"node_modules/es-to-primitive": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
"integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==",
"dependencies": {
"is-callable": "^1.1.4",
"is-date-object": "^1.0.1",
"is-symbol": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint": {
"version": "8.32.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.32.0.tgz",
"integrity": "sha512-nETVXpnthqKPFyuY2FNjz/bEd6nbosRgKbkgS/y1C7LJop96gYHWpiguLecMHQ2XCPxn77DS0P+68WzG6vkZSQ==",
"dependencies": {
"@eslint/eslintrc": "^1.4.1",
"@humanwhocodes/config-array": "^0.11.8",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
"debug": "^4.3.2",
"doctrine": "^3.0.0",
"escape-string-regexp": "^4.0.0",
"eslint-scope": "^7.1.1",
"eslint-utils": "^3.0.0",
"eslint-visitor-keys": "^3.3.0",
"espree": "^9.4.0",
"esquery": "^1.4.0",
"esutils": "^2.0.2",
"fast-deep-equal": "^3.1.3",
"file-entry-cache": "^6.0.1",
"find-up": "^5.0.0",
"glob-parent": "^6.0.2",
"globals": "^13.19.0",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
"is-path-inside": "^3.0.3",
"js-sdsl": "^4.1.4",
"js-yaml": "^4.1.0",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
"lodash.merge": "^4.6.2",
"minimatch": "^3.1.2",
"natural-compare": "^1.4.0",
"optionator": "^0.9.1",
"regexpp": "^3.2.0",
"strip-ansi": "^6.0.1",
"strip-json-comments": "^3.1.0",
"text-table": "^0.2.0"
},
"bin": {
"eslint": "bin/eslint.js"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/eslint-config-next": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.1.2.tgz",
"integrity": "sha512-zdRAQOr8v69ZwJRtBrGqAqm160ONqKxU/pV1FB1KlgfyqveGsLZmlQ7l31otwtw763901J7xdiTVkj2y3YxXZA==",
"dependencies": {
"@next/eslint-plugin-next": "13.1.2",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.42.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.31.7",
"eslint-plugin-react-hooks": "^4.5.0"
},
"peerDependencies": {
"eslint": "^7.23.0 || ^8.0.0",
"typescript": ">=3.3.1"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/eslint-import-resolver-node": {
"version": "0.3.7",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.7.tgz",
"integrity": "sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==",
"dependencies": {
"debug": "^3.2.7",
"is-core-module": "^2.11.0",
"resolve": "^1.22.1"
}
},
"node_modules/eslint-import-resolver-node/node_modules/debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/eslint-import-resolver-typescript": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.5.3.tgz",
"integrity": "sha512-njRcKYBc3isE42LaTcJNVANR3R99H9bAxBDMNDr2W7yq5gYPxbU3MkdhsQukxZ/Xg9C2vcyLlDsbKfRDg0QvCQ==",
"dependencies": {
"debug": "^4.3.4",
"enhanced-resolve": "^5.10.0",
"get-tsconfig": "^4.2.0",
"globby": "^13.1.2",
"is-core-module": "^2.10.0",
"is-glob": "^4.0.3",
"synckit": "^0.8.4"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/unts/projects/eslint-import-resolver-ts"
},
"peerDependencies": {
"eslint": "*",
"eslint-plugin-import": "*"
}
},
"node_modules/eslint-import-resolver-typescript/node_modules/globby": {
"version": "13.1.3",
"resolved": "https://registry.npmjs.org/globby/-/globby-13.1.3.tgz",
"integrity": "sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw==",
"dependencies": {
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.11",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^4.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint-import-resolver-typescript/node_modules/slash": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
"integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint-module-utils": {
"version": "2.7.4",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz",
"integrity": "sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==",
"dependencies": {
"debug": "^3.2.7"
},
"engines": {
"node": ">=4"
},
"peerDependenciesMeta": {
"eslint": {
"optional": true
}
}
},
"node_modules/eslint-module-utils/node_modules/debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/eslint-plugin-import": {
"version": "2.27.5",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz",
"integrity": "sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==",
"dependencies": {
"array-includes": "^3.1.6",
"array.prototype.flat": "^1.3.1",
"array.prototype.flatmap": "^1.3.1",
"debug": "^3.2.7",
"doctrine": "^2.1.0",
"eslint-import-resolver-node": "^0.3.7",
"eslint-module-utils": "^2.7.4",
"has": "^1.0.3",
"is-core-module": "^2.11.0",
"is-glob": "^4.0.3",
"minimatch": "^3.1.2",
"object.values": "^1.1.6",
"resolve": "^1.22.1",
"semver": "^6.3.0",
"tsconfig-paths": "^3.14.1"
},
"engines": {
"node": ">=4"
},
"peerDependencies": {
"eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8"
}
},
"node_modules/eslint-plugin-import/node_modules/debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/eslint-plugin-import/node_modules/doctrine": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
"integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==",
"dependencies": {
"esutils": "^2.0.2"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/eslint-plugin-import/node_modules/semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/eslint-plugin-jsx-a11y": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.7.1.tgz",
"integrity": "sha512-63Bog4iIethyo8smBklORknVjB0T2dwB8Mr/hIC+fBS0uyHdYYpzM/Ed+YC8VxTjlXHEWFOdmgwcDn1U2L9VCA==",
"dependencies": {
"@babel/runtime": "^7.20.7",
"aria-query": "^5.1.3",
"array-includes": "^3.1.6",
"array.prototype.flatmap": "^1.3.1",
"ast-types-flow": "^0.0.7",
"axe-core": "^4.6.2",
"axobject-query": "^3.1.1",
"damerau-levenshtein": "^1.0.8",
"emoji-regex": "^9.2.2",
"has": "^1.0.3",
"jsx-ast-utils": "^3.3.3",
"language-tags": "=1.0.5",
"minimatch": "^3.1.2",
"object.entries": "^1.1.6",
"object.fromentries": "^2.0.6",
"semver": "^6.3.0"
},
"engines": {
"node": ">=4.0"
},
"peerDependencies": {
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8"
}
},
"node_modules/eslint-plugin-jsx-a11y/node_modules/semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/eslint-plugin-react": {
"version": "7.32.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.32.1.tgz",
"integrity": "sha512-vOjdgyd0ZHBXNsmvU+785xY8Bfe57EFbTYYk8XrROzWpr9QBvpjITvAXt9xqcE6+8cjR/g1+mfumPToxsl1www==",
"dependencies": {
"array-includes": "^3.1.6",
"array.prototype.flatmap": "^1.3.1",
"array.prototype.tosorted": "^1.1.1",
"doctrine": "^2.1.0",
"estraverse": "^5.3.0",
"jsx-ast-utils": "^2.4.1 || ^3.0.0",
"minimatch": "^3.1.2",
"object.entries": "^1.1.6",
"object.fromentries": "^2.0.6",
"object.hasown": "^1.1.2",
"object.values": "^1.1.6",
"prop-types": "^15.8.1",
"resolve": "^2.0.0-next.4",
"semver": "^6.3.0",
"string.prototype.matchall": "^4.0.8"
},
"engines": {
"node": ">=4"
},
"peerDependencies": {
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8"
}
},
"node_modules/eslint-plugin-react-hooks": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz",
"integrity": "sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==",
"engines": {
"node": ">=10"
},
"peerDependencies": {
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0"
}
},
"node_modules/eslint-plugin-react/node_modules/doctrine": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
"integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==",
"dependencies": {
"esutils": "^2.0.2"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/eslint-plugin-react/node_modules/resolve": {
"version": "2.0.0-next.4",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.4.tgz",
"integrity": "sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ==",
"dependencies": {
"is-core-module": "^2.9.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
"bin": {
"resolve": "bin/resolve"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/eslint-plugin-react/node_modules/semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/eslint-scope": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz",
"integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==",
"dependencies": {
"esrecurse": "^4.3.0",
"estraverse": "^5.2.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/eslint-utils": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz",
"integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==",
"dependencies": {
"eslint-visitor-keys": "^2.0.0"
},
"engines": {
"node": "^10.0.0 || ^12.0.0 || >= 14.0.0"
},
"funding": {
"url": "https://github.com/sponsors/mysticatea"
},
"peerDependencies": {
"eslint": ">=5"
}
},
"node_modules/eslint-utils/node_modules/eslint-visitor-keys": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz",
"integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==",
"engines": {
"node": ">=10"
}
},
"node_modules/eslint-visitor-keys": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz",
"integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==",
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/espree": {
"version": "9.4.1",
"resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz",
"integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==",
"dependencies": {
"acorn": "^8.8.0",
"acorn-jsx": "^5.3.2",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/esquery": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz",
"integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==",
"dependencies": {
"estraverse": "^5.1.0"
},
"engines": {
"node": ">=0.10"
}
},
"node_modules/esrecurse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
"integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
"dependencies": {
"estraverse": "^5.2.0"
},
"engines": {
"node": ">=4.0"
}
},
"node_modules/estraverse": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"engines": {
"node": ">=4.0"
}
},
"node_modules/estree-util-attach-comments": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/estree-util-attach-comments/-/estree-util-attach-comments-2.1.0.tgz",
"integrity": "sha512-rJz6I4L0GaXYtHpoMScgDIwM0/Vwbu5shbMeER596rB2D1EWF6+Gj0e0UKzJPZrpoOc87+Q2kgVFHfjAymIqmw==",
"dependencies": {
"@types/estree": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/estree-util-build-jsx": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/estree-util-build-jsx/-/estree-util-build-jsx-2.2.2.tgz",
"integrity": "sha512-m56vOXcOBuaF+Igpb9OPAy7f9w9OIkb5yhjsZuaPm7HoGi4oTOQi0h2+yZ+AtKklYFZ+rPC4n0wYCJCEU1ONqg==",
"dependencies": {
"@types/estree-jsx": "^1.0.0",
"estree-util-is-identifier-name": "^2.0.0",
"estree-walker": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/estree-util-is-identifier-name": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-2.0.1.tgz",
"integrity": "sha512-rxZj1GkQhY4x1j/CSnybK9cGuMFQYFPLq0iNyopqf14aOVLFtMv7Esika+ObJWPWiOHuMOAHz3YkWoLYYRnzWQ==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/estree-util-to-js": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/estree-util-to-js/-/estree-util-to-js-1.1.0.tgz",
"integrity": "sha512-490lbfCcpLk+ofK6HCgqDfYs4KAfq6QVvDw3+Bm1YoKRgiOjKiKYGAVQE1uwh7zVxBgWhqp4FDtp5SqunpUk1A==",
"dependencies": {
"@types/estree-jsx": "^1.0.0",
"astring": "^1.8.0",
"source-map": "^0.7.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/estree-util-value-to-estree": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/estree-util-value-to-estree/-/estree-util-value-to-estree-1.3.0.tgz",
"integrity": "sha512-Y+ughcF9jSUJvncXwqRageavjrNPAI+1M/L3BI3PyLp1nmgYTGUXU6t5z1Y7OWuThoDdhPME07bQU+d5LxdJqw==",
"dependencies": {
"is-plain-obj": "^3.0.0"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/estree-util-visit": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/estree-util-visit/-/estree-util-visit-1.2.0.tgz",
"integrity": "sha512-wdsoqhWueuJKsh5hqLw3j8lwFqNStm92VcwtAOAny8g/KS/l5Y8RISjR4k5W6skCj3Nirag/WUCMS0Nfy3sgsg==",
"dependencies": {
"@types/estree-jsx": "^1.0.0",
"@types/unist": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/estree-walker": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.2.tgz",
"integrity": "sha512-C03BvXCQIH/po+PNPONx/zSM9ziPr9weX8xNhYb/IJtdJ9z+L4z9VKPTB+UTHdmhnIopA2kc419ueyVyHVktwA=="
},
"node_modules/esutils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/execa": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz",
"integrity": "sha512-zDWS+Rb1E8BlqqhALSt9kUhss8Qq4nN3iof3gsOdyINksElaPyNBtKUMTR62qhvgVWR0CqCX7sdnKe4MnUbFEA==",
"dependencies": {
"cross-spawn": "^5.0.1",
"get-stream": "^3.0.0",
"is-stream": "^1.1.0",
"npm-run-path": "^2.0.0",
"p-finally": "^1.0.0",
"signal-exit": "^3.0.0",
"strip-eof": "^1.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/execa/node_modules/cross-spawn": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
"integrity": "sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==",
"dependencies": {
"lru-cache": "^4.0.1",
"shebang-command": "^1.2.0",
"which": "^1.2.9"
}
},
"node_modules/execa/node_modules/lru-cache": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
"integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==",
"dependencies": {
"pseudomap": "^1.0.2",
"yallist": "^2.1.2"
}
},
"node_modules/execa/node_modules/shebang-command": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",
"integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==",
"dependencies": {
"shebang-regex": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/execa/node_modules/shebang-regex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz",
"integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/execa/node_modules/which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"which": "bin/which"
}
},
"node_modules/execa/node_modules/yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
"integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A=="
},
"node_modules/extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
},
"node_modules/extend-shallow": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==",
"dependencies": {
"is-extendable": "^0.1.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
},
"node_modules/fast-glob": {
"version": "3.2.12",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz",
"integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==",
"dependencies": {
"@nodelib/fs.stat": "^2.0.2",
"@nodelib/fs.walk": "^1.2.3",
"glob-parent": "^5.1.2",
"merge2": "^1.3.0",
"micromatch": "^4.0.4"
},
"engines": {
"node": ">=8.6.0"
}
},
"node_modules/fast-glob/node_modules/glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dependencies": {
"is-glob": "^4.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
},
"node_modules/fast-levenshtein": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw=="
},
"node_modules/fastq": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz",
"integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==",
"dependencies": {
"reusify": "^1.0.4"
}
},
"node_modules/file-entry-cache": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
"integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==",
"dependencies": {
"flat-cache": "^3.0.4"
},
"engines": {
"node": "^10.12.0 || >=12.0.0"
}
},
"node_modules/fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dependencies": {
"to-regex-range": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/find-up": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
"integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
"dependencies": {
"locate-path": "^6.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/flat-cache": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz",
"integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==",
"dependencies": {
"flatted": "^3.1.0",
"rimraf": "^3.0.2"
},
"engines": {
"node": "^10.12.0 || >=12.0.0"
}
},
"node_modules/flatted": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz",
"integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ=="
},
"node_modules/flexsearch": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/flexsearch/-/flexsearch-0.7.31.tgz",
"integrity": "sha512-XGozTsMPYkm+6b5QL3Z9wQcJjNYxp0CYn3U1gO7dwD6PAqU1SVWZxI9CCg3z+ml3YfqdPnrBehaBrnH2AGKbNA=="
},
"node_modules/focus-visible": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/focus-visible/-/focus-visible-5.2.0.tgz",
"integrity": "sha512-Rwix9pBtC1Nuy5wysTmKy+UjbDJpIfg8eHjw0rjZ1mX4GNLz1Bmd16uDpI3Gk1i70Fgcs8Csg2lPm8HULFg9DQ=="
},
"node_modules/for-each": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
"integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==",
"dependencies": {
"is-callable": "^1.1.3"
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
},
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"node_modules/function.prototype.name": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz",
"integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"es-abstract": "^1.19.0",
"functions-have-names": "^1.2.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/functions-have-names": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz",
"integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz",
"integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==",
"dependencies": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==",
"engines": {
"node": ">=4"
}
},
"node_modules/get-symbol-description": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz",
"integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==",
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-tsconfig": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.3.0.tgz",
"integrity": "sha512-YCcF28IqSay3fqpIu5y3Krg/utCBHBeoflkZyHj/QcqI2nrLPC3ZegS9CmIo+hJb8K7aiGsuUl7PwWVjNG2HQQ==",
"funding": {
"url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
}
},
"node_modules/git-up": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz",
"integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==",
"dependencies": {
"is-ssh": "^1.4.0",
"parse-url": "^8.1.0"
}
},
"node_modules/git-url-parse": {
"version": "13.1.0",
"resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-13.1.0.tgz",
"integrity": "sha512-5FvPJP/70WkIprlUZ33bm4UAaFdjcLkJLpWft1BeZKqwR0uhhNGoKwlUaPtVb4LxCSQ++erHapRak9kWGj+FCA==",
"dependencies": {
"git-up": "^7.0.0"
}
},
"node_modules/github-slugger": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz",
"integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw=="
},
"node_modules/glob": {
"version": "7.1.7",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",
"integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
},
"engines": {
"node": "*"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/glob-parent": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
"integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==",
"dependencies": {
"is-glob": "^4.0.3"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/globals": {
"version": "13.19.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.19.0.tgz",
"integrity": "sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==",
"dependencies": {
"type-fest": "^0.20.2"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/globalthis": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz",
"integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==",
"dependencies": {
"define-properties": "^1.1.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/globalyzer": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
"integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q=="
},
"node_modules/globby": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
"dependencies": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.9",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^3.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/globrex": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
},
"node_modules/gopd": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
"dependencies": {
"get-intrinsic": "^1.1.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/graceful-fs": {
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA=="
},
"node_modules/grapheme-splitter": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
"integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ=="
},
"node_modules/gray-matter": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz",
"integrity": "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==",
"dependencies": {
"js-yaml": "^3.13.1",
"kind-of": "^6.0.2",
"section-matter": "^1.0.0",
"strip-bom-string": "^1.0.0"
},
"engines": {
"node": ">=6.0"
}
},
"node_modules/gray-matter/node_modules/argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dependencies": {
"sprintf-js": "~1.0.2"
}
},
"node_modules/gray-matter/node_modules/js-yaml": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
"dependencies": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dependencies": {
"function-bind": "^1.1.1"
},
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/has-bigints": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz",
"integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/has-property-descriptors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz",
"integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==",
"dependencies": {
"get-intrinsic": "^1.1.1"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz",
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-tostringtag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz",
"integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==",
"dependencies": {
"has-symbols": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hash-obj": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/hash-obj/-/hash-obj-4.0.0.tgz",
"integrity": "sha512-FwO1BUVWkyHasWDW4S8o0ssQXjvyghLV2rfVhnN36b2bbcj45eGiuzdn9XOvOpjV3TKQD7Gm2BWNXdE9V4KKYg==",
"dependencies": {
"is-obj": "^3.0.0",
"sort-keys": "^5.0.0",
"type-fest": "^1.0.2"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/hash-obj/node_modules/type-fest": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-1.4.0.tgz",
"integrity": "sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/hast-util-from-parse5": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-7.1.1.tgz",
"integrity": "sha512-R6PoNcUs89ZxLJmMWsVbwSWuz95/9OriyQZ3e2ybwqGsRXzhA6gv49rgGmQvLbZuSNDv9fCg7vV7gXUsvtUFaA==",
"dependencies": {
"@types/hast": "^2.0.0",
"@types/unist": "^2.0.0",
"hastscript": "^7.0.0",
"property-information": "^6.0.0",
"vfile": "^5.0.0",
"vfile-location": "^4.0.0",
"web-namespaces": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-is-element": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-2.1.3.tgz",
"integrity": "sha512-O1bKah6mhgEq2WtVMk+Ta5K7pPMqsBBlmzysLdcwKVrqzZQ0CHqUPiIVspNhAG1rvxpvJjtGee17XfauZYKqVA==",
"dependencies": {
"@types/hast": "^2.0.0",
"@types/unist": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-parse-selector": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-3.1.1.tgz",
"integrity": "sha512-jdlwBjEexy1oGz0aJ2f4GKMaVKkA9jwjr4MjAAI22E5fM/TXVZHuS5OpONtdeIkRKqAaryQ2E9xNQxijoThSZA==",
"dependencies": {
"@types/hast": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-to-estree": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/hast-util-to-estree/-/hast-util-to-estree-2.2.1.tgz",
"integrity": "sha512-kiGD9WIW3gRKK8Gao3n1f+ahUeTMeJUJILnIT2QNrPigDNdH7rJxzhEbh81UajGeAdAHFecT1a+fLVOCTq9B4Q==",
"dependencies": {
"@types/estree": "^1.0.0",
"@types/estree-jsx": "^1.0.0",
"@types/hast": "^2.0.0",
"@types/unist": "^2.0.0",
"comma-separated-tokens": "^2.0.0",
"estree-util-attach-comments": "^2.0.0",
"estree-util-is-identifier-name": "^2.0.0",
"hast-util-whitespace": "^2.0.0",
"mdast-util-mdx-expression": "^1.0.0",
"mdast-util-mdxjs-esm": "^1.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0",
"style-to-object": "^0.4.1",
"unist-util-position": "^4.0.0",
"zwitch": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-to-text": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-3.1.2.tgz",
"integrity": "sha512-tcllLfp23dJJ+ju5wCCZHVpzsQQ43+moJbqVX3jNWPB7z/KFC4FyZD6R7y94cHL6MQ33YtMZL8Z0aIXXI4XFTw==",
"dependencies": {
"@types/hast": "^2.0.0",
"@types/unist": "^2.0.0",
"hast-util-is-element": "^2.0.0",
"unist-util-find-after": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-whitespace": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-2.0.1.tgz",
"integrity": "sha512-nAxA0v8+vXSBDt3AnRUNjyRIQ0rD+ntpbAp4LnPkumc5M9yUbSMa4XDU9Q6etY4f1Wp4bNgvc1yjiZtsTTrSng==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hastscript": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-7.2.0.tgz",
"integrity": "sha512-TtYPq24IldU8iKoJQqvZOuhi5CyCQRAbvDOX0x1eW6rsHSxa/1i2CCiptNTotGHJ3VoHRGmqiv6/D3q113ikkw==",
"dependencies": {
"@types/hast": "^2.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-parse-selector": "^3.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/ignore": {
"version": "5.2.4",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",
"integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==",
"engines": {
"node": ">= 4"
}
},
"node_modules/import-fresh": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
"integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==",
"dependencies": {
"parent-module": "^1.0.0",
"resolve-from": "^4.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/imurmurhash": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==",
"engines": {
"node": ">=0.8.19"
}
},
"node_modules/inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
"dependencies": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/inline-style-parser": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.1.1.tgz",
"integrity": "sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q=="
},
"node_modules/internal-slot": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.4.tgz",
"integrity": "sha512-tA8URYccNzMo94s5MQZgH8NB/XTa6HsOo0MLfXTKKEnHVVdegzaQoFZ7Jp44bdvLvY2waT5dc+j5ICEswhi7UQ==",
"dependencies": {
"get-intrinsic": "^1.1.3",
"has": "^1.0.3",
"side-channel": "^1.0.4"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/intersection-observer": {
"version": "0.12.2",
"resolved": "https://registry.npmjs.org/intersection-observer/-/intersection-observer-0.12.2.tgz",
"integrity": "sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg=="
},
"node_modules/is-alphabetical": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz",
"integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/is-alphanumerical": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz",
"integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==",
"dependencies": {
"is-alphabetical": "^2.0.0",
"is-decimal": "^2.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/is-arguments": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz",
"integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==",
"dependencies": {
"call-bind": "^1.0.2",
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-array-buffer": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.1.tgz",
"integrity": "sha512-ASfLknmY8Xa2XtB4wmbz13Wu202baeA18cJBCeCy0wXUHZF0IPyVEXqKEcd+t2fNSLLL1vC6k7lxZEojNbISXQ==",
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"is-typed-array": "^1.1.10"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-bigint": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz",
"integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==",
"dependencies": {
"has-bigints": "^1.0.1"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-boolean-object": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz",
"integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==",
"dependencies": {
"call-bind": "^1.0.2",
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-buffer": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"engines": {
"node": ">=4"
}
},
"node_modules/is-callable": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
"integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-core-module": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",
"integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
"dependencies": {
"has": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-date-object": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz",
"integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==",
"dependencies": {
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-decimal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz",
"integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/is-docker": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
"bin": {
"is-docker": "cli.js"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-extendable": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
"integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-glob": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"dependencies": {
"is-extglob": "^2.1.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-hexadecimal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz",
"integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/is-map": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz",
"integrity": "sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-negative-zero": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
"integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/is-number-object": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz",
"integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==",
"dependencies": {
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-obj": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-3.0.0.tgz",
"integrity": "sha512-IlsXEHOjtKhpN8r/tRFj2nDyTmHvcfNeu/nrRIcXE17ROeatXchkojffa1SpdqW4cr/Fj6QkEf/Gn4zf6KKvEQ==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-path-inside": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
"integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/is-plain-obj": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz",
"integrity": "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-reference": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.1.tgz",
"integrity": "sha512-baJJdQLiYaJdvFbJqXrcGv3WU3QCzBlUcI5QhbesIm6/xPsvmO+2CDoi/GMOFBQEQm+PXkwOPrp9KK5ozZsp2w==",
"dependencies": {
"@types/estree": "*"
}
},
"node_modules/is-regex": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz",
"integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==",
"dependencies": {
"call-bind": "^1.0.2",
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-set": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.2.tgz",
"integrity": "sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-shared-array-buffer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz",
"integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==",
"dependencies": {
"call-bind": "^1.0.2"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-ssh": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz",
"integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==",
"dependencies": {
"protocols": "^2.0.1"
}
},
"node_modules/is-stream": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-string": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz",
"integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==",
"dependencies": {
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-symbol": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz",
"integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==",
"dependencies": {
"has-symbols": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-typed-array": {
"version": "1.1.10",
"resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz",
"integrity": "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==",
"dependencies": {
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"gopd": "^1.0.1",
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-weakmap": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz",
"integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-weakref": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz",
"integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==",
"dependencies": {
"call-bind": "^1.0.2"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-weakset": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.2.tgz",
"integrity": "sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==",
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.1"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-wsl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"dependencies": {
"is-docker": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/isarray": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
"integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
},
"node_modules/js-sdsl": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz",
"integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/js-sdsl"
}
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
},
"node_modules/json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
"integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw=="
},
"node_modules/json5": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dependencies": {
"minimist": "^1.2.0"
},
"bin": {
"json5": "lib/cli.js"
}
},
"node_modules/jsonc-parser": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",
"integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w=="
},
"node_modules/jsx-ast-utils": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz",
"integrity": "sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw==",
"dependencies": {
"array-includes": "^3.1.5",
"object.assign": "^4.1.3"
},
"engines": {
"node": ">=4.0"
}
},
"node_modules/katex": {
"version": "0.16.4",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.16.4.tgz",
"integrity": "sha512-WudRKUj8yyBeVDI4aYMNxhx5Vhh2PjpzQw1GRu/LVGqL4m1AxwD1GcUp0IMbdJaf5zsjtj8ghP0DOQRYhroNkw==",
"funding": [
"https://opencollective.com/katex",
"https://github.com/sponsors/katex"
],
"dependencies": {
"commander": "^8.0.0"
},
"bin": {
"katex": "cli.js"
}
},
"node_modules/kind-of": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/kleur": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
"integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==",
"engines": {
"node": ">=6"
}
},
"node_modules/language-subtag-registry": {
"version": "0.3.22",
"resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz",
"integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w=="
},
"node_modules/language-tags": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz",
"integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==",
"dependencies": {
"language-subtag-registry": "~0.3.2"
}
},
"node_modules/levn": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
"integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
"dependencies": {
"prelude-ls": "^1.2.1",
"type-check": "~0.4.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
"integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
"dependencies": {
"p-locate": "^5.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ=="
},
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="
},
"node_modules/longest-streak": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz",
"integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"dependencies": {
"js-tokens": "^3.0.0 || ^4.0.0"
},
"bin": {
"loose-envify": "cli.js"
}
},
"node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dependencies": {
"yallist": "^4.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/markdown-extensions": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-1.1.1.tgz",
"integrity": "sha512-WWC0ZuMzCyDHYCasEGs4IPvLyTGftYwh6wIEOULOF0HXcqZlhwRzrK0w2VUlxWA98xnvb/jszw4ZSkJ6ADpM6Q==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/markdown-table": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.3.tgz",
"integrity": "sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/match-sorter": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/match-sorter/-/match-sorter-6.3.1.tgz",
"integrity": "sha512-mxybbo3pPNuA+ZuCUhm5bwNkXrJTbsk5VWbR5wiwz/GC6LIiegBGn2w3O08UG/jdbYLinw51fSQ5xNU1U3MgBw==",
"dependencies": {
"@babel/runtime": "^7.12.5",
"remove-accents": "0.4.2"
}
},
"node_modules/mdast-util-definitions": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-5.1.1.tgz",
"integrity": "sha512-rQ+Gv7mHttxHOBx2dkF4HWTg+EE+UR78ptQWDylzPKaQuVGdG4HIoY3SrS/pCp80nZ04greFvXbVFHT+uf0JVQ==",
"dependencies": {
"@types/mdast": "^3.0.0",
"@types/unist": "^2.0.0",
"unist-util-visit": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-find-and-replace": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-2.2.1.tgz",
"integrity": "sha512-SobxkQXFAdd4b5WmEakmkVoh18icjQRxGy5OWTCzgsLRm1Fu/KCtwD1HIQSsmq5ZRjVH0Ehwg6/Fn3xIUk+nKw==",
"dependencies": {
"escape-string-regexp": "^5.0.0",
"unist-util-is": "^5.0.0",
"unist-util-visit-parents": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
"integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/mdast-util-from-markdown": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-1.2.0.tgz",
"integrity": "sha512-iZJyyvKD1+K7QX1b5jXdE7Sc5dtoTry1vzV28UZZe8Z1xVnB/czKntJ7ZAkG0tANqRnBF6p3p7GpU1y19DTf2Q==",
"dependencies": {
"@types/mdast": "^3.0.0",
"@types/unist": "^2.0.0",
"decode-named-character-reference": "^1.0.0",
"mdast-util-to-string": "^3.1.0",
"micromark": "^3.0.0",
"micromark-util-decode-numeric-character-reference": "^1.0.0",
"micromark-util-decode-string": "^1.0.0",
"micromark-util-normalize-identifier": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"unist-util-stringify-position": "^3.0.0",
"uvu": "^0.5.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-gfm": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-2.0.1.tgz",
"integrity": "sha512-42yHBbfWIFisaAfV1eixlabbsa6q7vHeSPY+cg+BBjX51M8xhgMacqH9g6TftB/9+YkcI0ooV4ncfrJslzm/RQ==",
"dependencies": {
"mdast-util-from-markdown": "^1.0.0",
"mdast-util-gfm-autolink-literal": "^1.0.0",
"mdast-util-gfm-footnote": "^1.0.0",
"mdast-util-gfm-strikethrough": "^1.0.0",
"mdast-util-gfm-table": "^1.0.0",
"mdast-util-gfm-task-list-item": "^1.0.0",
"mdast-util-to-markdown": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-gfm-autolink-literal": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-1.0.2.tgz",
"integrity": "sha512-FzopkOd4xTTBeGXhXSBU0OCDDh5lUj2rd+HQqG92Ld+jL4lpUfgX2AT2OHAVP9aEeDKp7G92fuooSZcYJA3cRg==",
"dependencies": {
"@types/mdast": "^3.0.0",
"ccount": "^2.0.0",
"mdast-util-find-and-replace": "^2.0.0",
"micromark-util-character": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-gfm-footnote": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-1.0.1.tgz",
"integrity": "sha512-p+PrYlkw9DeCRkTVw1duWqPRHX6Ywh2BNKJQcZbCwAuP/59B0Lk9kakuAd7KbQprVO4GzdW8eS5++A9PUSqIyw==",
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-to-markdown": "^1.3.0",
"micromark-util-normalize-identifier": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-gfm-strikethrough": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-1.0.2.tgz",
"integrity": "sha512-T/4DVHXcujH6jx1yqpcAYYwd+z5lAYMw4Ls6yhTfbMMtCt0PHY4gEfhW9+lKsLBtyhUGKRIzcUA2FATVqnvPDA==",
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-to-markdown": "^1.3.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-gfm-table": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-1.0.6.tgz",
"integrity": "sha512-uHR+fqFq3IvB3Rd4+kzXW8dmpxUhvgCQZep6KdjsLK4O6meK5dYZEayLtIxNus1XO3gfjfcIFe8a7L0HZRGgag==",
"dependencies": {
"@types/mdast": "^3.0.0",
"markdown-table": "^3.0.0",
"mdast-util-from-markdown": "^1.0.0",
"mdast-util-to-markdown": "^1.3.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-gfm-task-list-item": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-1.0.1.tgz",
"integrity": "sha512-KZ4KLmPdABXOsfnM6JHUIjxEvcx2ulk656Z/4Balw071/5qgnhz+H1uGtf2zIGnrnvDC8xR4Fj9uKbjAFGNIeA==",
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-to-markdown": "^1.3.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-math": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-math/-/mdast-util-math-2.0.1.tgz",
"integrity": "sha512-ZZtjyRwobsiVg4bY0Q5CzAZztpbjRIA7ZlMMb0PNkwTXOnJTUoHvzBhVG95LIuek5Mlj1l2P+jBvWviqW7G+0A==",
"dependencies": {
"@types/mdast": "^3.0.0",
"longest-streak": "^3.0.0",
"mdast-util-to-markdown": "^1.3.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-mdx": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-mdx/-/mdast-util-mdx-2.0.0.tgz",
"integrity": "sha512-M09lW0CcBT1VrJUaF/PYxemxxHa7SLDHdSn94Q9FhxjCQfuW7nMAWKWimTmA3OyDMSTH981NN1csW1X+HPSluw==",
"dependencies": {
"mdast-util-mdx-expression": "^1.0.0",
"mdast-util-mdx-jsx": "^2.0.0",
"mdast-util-mdxjs-esm": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-mdx-expression": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-1.3.1.tgz",
"integrity": "sha512-TTb6cKyTA1RD+1su1iStZ5PAv3rFfOUKcoU5EstUpv/IZo63uDX03R8+jXjMEhcobXnNOiG6/ccekvVl4eV1zQ==",
"dependencies": {
"@types/estree-jsx": "^1.0.0",
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"mdast-util-from-markdown": "^1.0.0",
"mdast-util-to-markdown": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-mdx-jsx": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-2.1.0.tgz",
"integrity": "sha512-KzgzfWMhdteDkrY4mQtyvTU5bc/W4ppxhe9SzelO6QUUiwLAM+Et2Dnjjprik74a336kHdo0zKm7Tp+n6FFeRg==",
"dependencies": {
"@types/estree-jsx": "^1.0.0",
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"ccount": "^2.0.0",
"mdast-util-to-markdown": "^1.3.0",
"parse-entities": "^4.0.0",
"stringify-entities": "^4.0.0",
"unist-util-remove-position": "^4.0.0",
"unist-util-stringify-position": "^3.0.0",
"vfile-message": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-mdxjs-esm": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/mdast-util-mdxjs-esm/-/mdast-util-mdxjs-esm-1.3.0.tgz",
"integrity": "sha512-7N5ihsOkAEGjFotIX9p/YPdl4TqUoMxL4ajNz7PbT89BqsdWJuBC9rvgt6wpbwTZqWWR0jKWqQbwsOWDBUZv4g==",
"dependencies": {
"@types/estree-jsx": "^1.0.0",
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"mdast-util-from-markdown": "^1.0.0",
"mdast-util-to-markdown": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-phrasing": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-3.0.0.tgz",
"integrity": "sha512-S+QYsDRLkGi8U7o5JF1agKa/sdP+CNGXXLqC17pdTVL8FHHgQEiwFGa9yE5aYtUxNiFGYoaDy9V1kC85Sz86Gg==",
"dependencies": {
"@types/mdast": "^3.0.0",
"unist-util-is": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-hast": {
"version": "12.2.5",
"resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-12.2.5.tgz",
"integrity": "sha512-EFNhT35ZR/VZ85/EedDdCNTq0oFM+NM/+qBomVGQ0+Lcg0nhI8xIwmdCzNMlVlCJNXRprpobtKP/IUh8cfz6zQ==",
"dependencies": {
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"mdast-util-definitions": "^5.0.0",
"micromark-util-sanitize-uri": "^1.1.0",
"trim-lines": "^3.0.0",
"unist-builder": "^3.0.0",
"unist-util-generated": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-markdown": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-1.5.0.tgz",
"integrity": "sha512-bbv7TPv/WC49thZPg3jXuqzuvI45IL2EVAr/KxF0BSdHsU0ceFHOmwQn6evxAh1GaoK/6GQ1wp4R4oW2+LFL/A==",
"dependencies": {
"@types/mdast": "^3.0.0",
"@types/unist": "^2.0.0",
"longest-streak": "^3.0.0",
"mdast-util-phrasing": "^3.0.0",
"mdast-util-to-string": "^3.0.0",
"micromark-util-decode-string": "^1.0.0",
"unist-util-visit": "^4.0.0",
"zwitch": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-string": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.0.tgz",
"integrity": "sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/merge2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
"engines": {
"node": ">= 8"
}
},
"node_modules/micromark": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/micromark/-/micromark-3.1.0.tgz",
"integrity": "sha512-6Mj0yHLdUZjHnOPgr5xfWIMqMWS12zDN6iws9SLuSz76W8jTtAv24MN4/CL7gJrl5vtxGInkkqDv/JIoRsQOvA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"@types/debug": "^4.0.0",
"debug": "^4.0.0",
"decode-named-character-reference": "^1.0.0",
"micromark-core-commonmark": "^1.0.1",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-chunked": "^1.0.0",
"micromark-util-combine-extensions": "^1.0.0",
"micromark-util-decode-numeric-character-reference": "^1.0.0",
"micromark-util-encode": "^1.0.0",
"micromark-util-normalize-identifier": "^1.0.0",
"micromark-util-resolve-all": "^1.0.0",
"micromark-util-sanitize-uri": "^1.0.0",
"micromark-util-subtokenize": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.1",
"uvu": "^0.5.0"
}
},
"node_modules/micromark-core-commonmark": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-1.0.6.tgz",
"integrity": "sha512-K+PkJTxqjFfSNkfAhp4GB+cZPfQd6dxtTXnf+RjZOV7T4EEXnvgzOcnp+eSTmpGk9d1S9sL6/lqrgSNn/s0HZA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"decode-named-character-reference": "^1.0.0",
"micromark-factory-destination": "^1.0.0",
"micromark-factory-label": "^1.0.0",
"micromark-factory-space": "^1.0.0",
"micromark-factory-title": "^1.0.0",
"micromark-factory-whitespace": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-chunked": "^1.0.0",
"micromark-util-classify-character": "^1.0.0",
"micromark-util-html-tag-name": "^1.0.0",
"micromark-util-normalize-identifier": "^1.0.0",
"micromark-util-resolve-all": "^1.0.0",
"micromark-util-subtokenize": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.1",
"uvu": "^0.5.0"
}
},
"node_modules/micromark-extension-gfm": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-2.0.1.tgz",
"integrity": "sha512-p2sGjajLa0iYiGQdT0oelahRYtMWvLjy8J9LOCxzIQsllMCGLbsLW+Nc+N4vi02jcRJvedVJ68cjelKIO6bpDA==",
"dependencies": {
"micromark-extension-gfm-autolink-literal": "^1.0.0",
"micromark-extension-gfm-footnote": "^1.0.0",
"micromark-extension-gfm-strikethrough": "^1.0.0",
"micromark-extension-gfm-table": "^1.0.0",
"micromark-extension-gfm-tagfilter": "^1.0.0",
"micromark-extension-gfm-task-list-item": "^1.0.0",
"micromark-util-combine-extensions": "^1.0.0",
"micromark-util-types": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-gfm-autolink-literal": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-1.0.3.tgz",
"integrity": "sha512-i3dmvU0htawfWED8aHMMAzAVp/F0Z+0bPh3YrbTPPL1v4YAlCZpy5rBO5p0LPYiZo0zFVkoYh7vDU7yQSiCMjg==",
"dependencies": {
"micromark-util-character": "^1.0.0",
"micromark-util-sanitize-uri": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-gfm-footnote": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-1.0.4.tgz",
"integrity": "sha512-E/fmPmDqLiMUP8mLJ8NbJWJ4bTw6tS+FEQS8CcuDtZpILuOb2kjLqPEeAePF1djXROHXChM/wPJw0iS4kHCcIg==",
"dependencies": {
"micromark-core-commonmark": "^1.0.0",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-normalize-identifier": "^1.0.0",
"micromark-util-sanitize-uri": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-gfm-strikethrough": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-1.0.4.tgz",
"integrity": "sha512-/vjHU/lalmjZCT5xt7CcHVJGq8sYRm80z24qAKXzaHzem/xsDYb2yLL+NNVbYvmpLx3O7SYPuGL5pzusL9CLIQ==",
"dependencies": {
"micromark-util-chunked": "^1.0.0",
"micromark-util-classify-character": "^1.0.0",
"micromark-util-resolve-all": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-gfm-table": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-1.0.5.tgz",
"integrity": "sha512-xAZ8J1X9W9K3JTJTUL7G6wSKhp2ZYHrFk5qJgY/4B33scJzE2kpfRL6oiw/veJTbt7jiM/1rngLlOKPWr1G+vg==",
"dependencies": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-gfm-tagfilter": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-1.0.1.tgz",
"integrity": "sha512-Ty6psLAcAjboRa/UKUbbUcwjVAv5plxmpUTy2XC/3nJFL37eHej8jrHrRzkqcpipJliuBH30DTs7+3wqNcQUVA==",
"dependencies": {
"micromark-util-types": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-gfm-task-list-item": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-1.0.3.tgz",
"integrity": "sha512-PpysK2S1Q/5VXi72IIapbi/jliaiOFzv7THH4amwXeYXLq3l1uo8/2Be0Ac1rEwK20MQEsGH2ltAZLNY2KI/0Q==",
"dependencies": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-math": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/micromark-extension-math/-/micromark-extension-math-2.0.2.tgz",
"integrity": "sha512-cFv2B/E4pFPBBFuGgLHkkNiFAIQv08iDgPH2HCuR2z3AUgMLecES5Cq7AVtwOtZeRrbA80QgMUk8VVW0Z+D2FA==",
"dependencies": {
"@types/katex": "^0.11.0",
"katex": "^0.13.0",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-math/node_modules/katex": {
"version": "0.13.24",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.13.24.tgz",
"integrity": "sha512-jZxYuKCma3VS5UuxOx/rFV1QyGSl3Uy/i0kTJF3HgQ5xMinCQVF8Zd4bMY/9aI9b9A2pjIBOsjSSm68ykTAr8w==",
"funding": [
"https://opencollective.com/katex",
"https://github.com/sponsors/katex"
],
"dependencies": {
"commander": "^8.0.0"
},
"bin": {
"katex": "cli.js"
}
},
"node_modules/micromark-extension-mdx-expression": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-mdx-expression/-/micromark-extension-mdx-expression-1.0.3.tgz",
"integrity": "sha512-TjYtjEMszWze51NJCZmhv7MEBcgYRgb3tJeMAJ+HQCAaZHHRBaDCccqQzGizR/H4ODefP44wRTgOn2vE5I6nZA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-factory-mdx-expression": "^1.0.0",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-events-to-acorn": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"node_modules/micromark-extension-mdx-jsx": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-mdx-jsx/-/micromark-extension-mdx-jsx-1.0.3.tgz",
"integrity": "sha512-VfA369RdqUISF0qGgv2FfV7gGjHDfn9+Qfiv5hEwpyr1xscRj/CiVRkU7rywGFCO7JwJ5L0e7CJz60lY52+qOA==",
"dependencies": {
"@types/acorn": "^4.0.0",
"estree-util-is-identifier-name": "^2.0.0",
"micromark-factory-mdx-expression": "^1.0.0",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0",
"vfile-message": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-mdx-md": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-extension-mdx-md/-/micromark-extension-mdx-md-1.0.0.tgz",
"integrity": "sha512-xaRAMoSkKdqZXDAoSgp20Azm0aRQKGOl0RrS81yGu8Hr/JhMsBmfs4wR7m9kgVUIO36cMUQjNyiyDKPrsv8gOw==",
"dependencies": {
"micromark-util-types": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-mdxjs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-extension-mdxjs/-/micromark-extension-mdxjs-1.0.0.tgz",
"integrity": "sha512-TZZRZgeHvtgm+IhtgC2+uDMR7h8eTKF0QUX9YsgoL9+bADBpBY6SiLvWqnBlLbCEevITmTqmEuY3FoxMKVs1rQ==",
"dependencies": {
"acorn": "^8.0.0",
"acorn-jsx": "^5.0.0",
"micromark-extension-mdx-expression": "^1.0.0",
"micromark-extension-mdx-jsx": "^1.0.0",
"micromark-extension-mdx-md": "^1.0.0",
"micromark-extension-mdxjs-esm": "^1.0.0",
"micromark-util-combine-extensions": "^1.0.0",
"micromark-util-types": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-mdxjs-esm": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-mdxjs-esm/-/micromark-extension-mdxjs-esm-1.0.3.tgz",
"integrity": "sha512-2N13ol4KMoxb85rdDwTAC6uzs8lMX0zeqpcyx7FhS7PxXomOnLactu8WI8iBNXW8AVyea3KIJd/1CKnUmwrK9A==",
"dependencies": {
"micromark-core-commonmark": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-events-to-acorn": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"unist-util-position-from-estree": "^1.1.0",
"uvu": "^0.5.0",
"vfile-message": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-factory-destination": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-1.0.0.tgz",
"integrity": "sha512-eUBA7Rs1/xtTVun9TmV3gjfPz2wEwgK5R5xcbIM5ZYAtvGF6JkyaDsj0agx8urXnO31tEO6Ug83iVH3tdedLnw==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"node_modules/micromark-factory-label": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-1.0.2.tgz",
"integrity": "sha512-CTIwxlOnU7dEshXDQ+dsr2n+yxpP0+fn271pu0bwDIS8uqfFcumXpj5mLn3hSC8iw2MUr6Gx8EcKng1dD7i6hg==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"node_modules/micromark-factory-mdx-expression": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/micromark-factory-mdx-expression/-/micromark-factory-mdx-expression-1.0.6.tgz",
"integrity": "sha512-WRQIc78FV7KrCfjsEf/sETopbYjElh3xAmNpLkd1ODPqxEngP42eVRGbiPEQWpRV27LzqW+XVTvQAMIIRLPnNA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-events-to-acorn": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"unist-util-position-from-estree": "^1.0.0",
"uvu": "^0.5.0",
"vfile-message": "^3.0.0"
}
},
"node_modules/micromark-factory-space": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-1.0.0.tgz",
"integrity": "sha512-qUmqs4kj9a5yBnk3JMLyjtWYN6Mzfcx8uJfi5XAveBniDevmZasdGBba5b4QsvRcAkmvGo5ACmSUmyGiKTLZew==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-character": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"node_modules/micromark-factory-title": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-1.0.2.tgz",
"integrity": "sha512-zily+Nr4yFqgMGRKLpTVsNl5L4PMu485fGFDOQJQBl2NFpjGte1e86zC0da93wf97jrc4+2G2GQudFMHn3IX+A==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"node_modules/micromark-factory-whitespace": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-1.0.0.tgz",
"integrity": "sha512-Qx7uEyahU1lt1RnsECBiuEbfr9INjQTGa6Err+gF3g0Tx4YEviPbqqGKNv/NrBaE7dVHdn1bVZKM/n5I/Bak7A==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"node_modules/micromark-util-character": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-1.1.0.tgz",
"integrity": "sha512-agJ5B3unGNJ9rJvADMJ5ZiYjBRyDpzKAOk01Kpi1TKhlT1APx3XZk6eN7RtSz1erbWHC2L8T3xLZ81wdtGRZzg==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"node_modules/micromark-util-chunked": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-1.0.0.tgz",
"integrity": "sha512-5e8xTis5tEZKgesfbQMKRCyzvffRRUX+lK/y+DvsMFdabAicPkkZV6gO+FEWi9RfuKKoxxPwNL+dFF0SMImc1g==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-symbol": "^1.0.0"
}
},
"node_modules/micromark-util-classify-character": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-1.0.0.tgz",
"integrity": "sha512-F8oW2KKrQRb3vS5ud5HIqBVkCqQi224Nm55o5wYLzY/9PwHGXC01tr3d7+TqHHz6zrKQ72Okwtvm/xQm6OVNZA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"node_modules/micromark-util-combine-extensions": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-1.0.0.tgz",
"integrity": "sha512-J8H058vFBdo/6+AsjHp2NF7AJ02SZtWaVUjsayNFeAiydTxUwViQPxN0Hf8dp4FmCQi0UUFovFsEyRSUmFH3MA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-chunked": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"node_modules/micromark-util-decode-numeric-character-reference": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-1.0.0.tgz",
"integrity": "sha512-OzO9AI5VUtrTD7KSdagf4MWgHMtET17Ua1fIpXTpuhclCqD8egFWo85GxSGvxgkGS74bEahvtM0WP0HjvV0e4w==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-symbol": "^1.0.0"
}
},
"node_modules/micromark-util-decode-string": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-1.0.2.tgz",
"integrity": "sha512-DLT5Ho02qr6QWVNYbRZ3RYOSSWWFuH3tJexd3dgN1odEuPNxCngTCXJum7+ViRAd9BbdxCvMToPOD/IvVhzG6Q==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"decode-named-character-reference": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-decode-numeric-character-reference": "^1.0.0",
"micromark-util-symbol": "^1.0.0"
}
},
"node_modules/micromark-util-encode": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-1.0.1.tgz",
"integrity": "sha512-U2s5YdnAYexjKDel31SVMPbfi+eF8y1U4pfiRW/Y8EFVCy/vgxk/2wWTxzcqE71LHtCuCzlBDRU2a5CQ5j+mQA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
]
},
"node_modules/micromark-util-events-to-acorn": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/micromark-util-events-to-acorn/-/micromark-util-events-to-acorn-1.2.0.tgz",
"integrity": "sha512-WWp3bf7xT9MppNuw3yPjpnOxa8cj5ACivEzXJKu0WwnjBYfzaBvIAT9KfeyI0Qkll+bfQtfftSwdgTH6QhTOKw==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"@types/acorn": "^4.0.0",
"@types/estree": "^1.0.0",
"estree-util-visit": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0",
"vfile-location": "^4.0.0",
"vfile-message": "^3.0.0"
}
},
"node_modules/micromark-util-html-tag-name": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-1.1.0.tgz",
"integrity": "sha512-BKlClMmYROy9UiV03SwNmckkjn8QHVaWkqoAqzivabvdGcwNGMMMH/5szAnywmsTBUzDsU57/mFi0sp4BQO6dA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
]
},
"node_modules/micromark-util-normalize-identifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-1.0.0.tgz",
"integrity": "sha512-yg+zrL14bBTFrQ7n35CmByWUTFsgst5JhA4gJYoty4Dqzj4Z4Fr/DHekSS5aLfH9bdlfnSvKAWsAgJhIbogyBg==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-symbol": "^1.0.0"
}
},
"node_modules/micromark-util-resolve-all": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-1.0.0.tgz",
"integrity": "sha512-CB/AGk98u50k42kvgaMM94wzBqozSzDDaonKU7P7jwQIuH2RU0TeBqGYJz2WY1UdihhjweivStrJ2JdkdEmcfw==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-types": "^1.0.0"
}
},
"node_modules/micromark-util-sanitize-uri": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-1.1.0.tgz",
"integrity": "sha512-RoxtuSCX6sUNtxhbmsEFQfWzs8VN7cTctmBPvYivo98xb/kDEoTCtJQX5wyzIYEmk/lvNFTat4hL8oW0KndFpg==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-character": "^1.0.0",
"micromark-util-encode": "^1.0.0",
"micromark-util-symbol": "^1.0.0"
}
},
"node_modules/micromark-util-subtokenize": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-1.0.2.tgz",
"integrity": "sha512-d90uqCnXp/cy4G881Ub4psE57Sf8YD0pim9QdjCRNjfas2M1u6Lbt+XZK9gnHL2XFhnozZiEdCa9CNfXSfQ6xA==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
],
"dependencies": {
"micromark-util-chunked": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"node_modules/micromark-util-symbol": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-1.0.1.tgz",
"integrity": "sha512-oKDEMK2u5qqAptasDAwWDXq0tG9AssVwAx3E9bBF3t/shRIGsWIRG+cGafs2p/SnDSOecnt6hZPCE2o6lHfFmQ==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
]
},
"node_modules/micromark-util-types": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-1.0.2.tgz",
"integrity": "sha512-DCfg/T8fcrhrRKTPjRrw/5LLvdGV7BHySf/1LOZx7TzWZdYRjogNtyNq885z3nNallwr3QUKARjqvHqX1/7t+w==",
"funding": [
{
"type": "GitHub Sponsors",
"url": "https://github.com/sponsors/unifiedjs"
},
{
"type": "OpenCollective",
"url": "https://opencollective.com/unified"
}
]
},
"node_modules/micromatch": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"dependencies": {
"braces": "^3.0.2",
"picomatch": "^2.3.1"
},
"engines": {
"node": ">=8.6"
}
},
"node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/minimist": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
"engines": {
"node": ">=4"
}
},
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/nanoid": {
"version": "3.3.4",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
"integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="
},
"node_modules/next": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/next/-/next-13.1.2.tgz",
"integrity": "sha512-Rdnnb2YH///w78FEOR/IQ6TXga+qpth4OqFSem48ng1PYYKr6XBsIk1XVaRcIGM3o6iiHnun0nJvkJHDf+ICyQ==",
"dependencies": {
"@next/env": "13.1.2",
"@swc/helpers": "0.4.14",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
"styled-jsx": "5.1.1"
},
"bin": {
"next": "dist/bin/next"
},
"engines": {
"node": ">=14.6.0"
},
"optionalDependencies": {
"@next/swc-android-arm-eabi": "13.1.2",
"@next/swc-android-arm64": "13.1.2",
"@next/swc-darwin-arm64": "13.1.2",
"@next/swc-darwin-x64": "13.1.2",
"@next/swc-freebsd-x64": "13.1.2",
"@next/swc-linux-arm-gnueabihf": "13.1.2",
"@next/swc-linux-arm64-gnu": "13.1.2",
"@next/swc-linux-arm64-musl": "13.1.2",
"@next/swc-linux-x64-gnu": "13.1.2",
"@next/swc-linux-x64-musl": "13.1.2",
"@next/swc-win32-arm64-msvc": "13.1.2",
"@next/swc-win32-ia32-msvc": "13.1.2",
"@next/swc-win32-x64-msvc": "13.1.2"
},
"peerDependencies": {
"fibers": ">= 3.1.0",
"node-sass": "^6.0.0 || ^7.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sass": "^1.3.0"
},
"peerDependenciesMeta": {
"fibers": {
"optional": true
},
"node-sass": {
"optional": true
},
"sass": {
"optional": true
}
}
},
"node_modules/next-mdx-remote": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/next-mdx-remote/-/next-mdx-remote-4.2.1.tgz",
"integrity": "sha512-PcVF1r5XTBjiNVXw0GyaIcOwQsklHo36+7ycfmtJb52TIkT0nM4Hzv4wgJwNg7+jvTbap99qWsMwdKUYR9WxAA==",
"dependencies": {
"@mdx-js/mdx": "^2.2.1",
"@mdx-js/react": "^2.2.1",
"vfile": "^5.3.0",
"vfile-matter": "^3.0.1"
},
"engines": {
"node": ">=14",
"npm": ">=7"
},
"peerDependencies": {
"react": ">=16.x <=18.x",
"react-dom": ">=16.x <=18.x"
}
},
"node_modules/next-seo": {
"version": "5.15.0",
"resolved": "https://registry.npmjs.org/next-seo/-/next-seo-5.15.0.tgz",
"integrity": "sha512-LGbcY91yDKGMb7YI+28n3g+RuChUkt6pXNpa8FkfKkEmNiJkeRDEXTnnjVtwT9FmMhG6NH8qwHTelGrlYm9rgg==",
"peerDependencies": {
"next": "^8.1.1-canary.54 || >=9.0.0",
"react": ">=16.0.0",
"react-dom": ">=16.0.0"
}
},
"node_modules/next-themes": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz",
"integrity": "sha512-B+AKNfYNIzh0vqQQKqQItTS8evEouKD7H5Hj3kmuPERwddR2TxvDSFZuTj6T7Jfn1oyeUyJMydPl1Bkxkh0W7A==",
"peerDependencies": {
"next": "*",
"react": "*",
"react-dom": "*"
}
},
"node_modules/nextra": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/nextra/-/nextra-2.2.5.tgz",
"integrity": "sha512-sm8mtKxLhfGWNv0yGd9GRL+DPDdVJlyEGn+6zk7gOPQor4X6G1VLcNjGlGYFovS4ZHNrg8oKmhOZSkq79PBrtw==",
"dependencies": {
"@mdx-js/mdx": "^2.1.5",
"@mdx-js/react": "^2.1.5",
"@napi-rs/simple-git": "^0.1.8",
"github-slugger": "^2.0.0",
"graceful-fs": "^4.2.10",
"gray-matter": "^4.0.3",
"katex": "^0.16.4",
"lodash.get": "^4.4.2",
"next-mdx-remote": "^4.2.0",
"p-limit": "^3.1.0",
"rehype-katex": "^6.0.2",
"rehype-pretty-code": "0.9.2",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"remark-reading-time": "^2.0.1",
"shiki": "^0.12.1",
"slash": "^3.0.0",
"title": "^3.5.3",
"unist-util-visit": "^4.1.1"
},
"peerDependencies": {
"next": ">=9.5.3",
"react": ">=16.13.1",
"react-dom": ">=16.13.1"
}
},
"node_modules/nextra-theme-docs": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/nextra-theme-docs/-/nextra-theme-docs-2.2.5.tgz",
"integrity": "sha512-dpfOr8O4w3+q2BpBvnOXsmuvDCrrVl9QPrETzN8xKc9z6+oJNt4PEZOHRHo2rADHyV4832sSnWxhERrVzvqfNA==",
"dependencies": {
"@headlessui/react": "^1.7.7",
"@popperjs/core": "^2.11.6",
"clsx": "^1.2.1",
"flexsearch": "^0.7.21",
"focus-visible": "^5.2.0",
"git-url-parse": "^13.1.0",
"intersection-observer": "^0.12.2",
"match-sorter": "^6.3.1",
"next-seo": "^5.5.0",
"next-themes": "^0.2.1",
"scroll-into-view-if-needed": "^3.0.0",
"zod": "^3.20.2"
},
"peerDependencies": {
"next": ">=9.5.3",
"react": ">=16.13.1",
"react-dom": ">=16.13.1"
}
},
"node_modules/npm-run-path": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
"integrity": "sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==",
"dependencies": {
"path-key": "^2.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/npm-run-path/node_modules/path-key": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",
"integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==",
"engines": {
"node": ">=4"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {
"version": "1.12.3",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object-is": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz",
"integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/object.assign": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz",
"integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"has-symbols": "^1.0.3",
"object-keys": "^1.1.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object.entries": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.6.tgz",
"integrity": "sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/object.fromentries": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.6.tgz",
"integrity": "sha512-VciD13dswC4j1Xt5394WR4MzmAQmlgN72phd/riNp9vtD7tp4QQWJ0R4wvclXcafgcYK8veHRed2W6XeGBvcfg==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object.hasown": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.2.tgz",
"integrity": "sha512-B5UIT3J1W+WuWIU55h0mjlwaqxiE5vYENJXIXZ4VFe05pNYrkKuK0U/6aFcb0pKywYJh7IhfoqUfKVmrJJHZHw==",
"dependencies": {
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object.values": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.6.tgz",
"integrity": "sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"dependencies": {
"wrappy": "1"
}
},
"node_modules/open": {
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/open/-/open-8.4.0.tgz",
"integrity": "sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==",
"dependencies": {
"define-lazy-prop": "^2.0.0",
"is-docker": "^2.1.1",
"is-wsl": "^2.2.0"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/optionator": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
"integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==",
"dependencies": {
"deep-is": "^0.1.3",
"fast-levenshtein": "^2.0.6",
"levn": "^0.4.1",
"prelude-ls": "^1.2.1",
"type-check": "^0.4.0",
"word-wrap": "^1.2.3"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/p-finally": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
"integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==",
"engines": {
"node": ">=4"
}
},
"node_modules/p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
"integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
"dependencies": {
"yocto-queue": "^0.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
"integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
"dependencies": {
"p-limit": "^3.0.2"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"dependencies": {
"callsites": "^3.0.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/parse-entities": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.0.tgz",
"integrity": "sha512-5nk9Fn03x3rEhGaX1FU6IDwG/k+GxLXlFAkgrbM1asuAFl3BhdQWvASaIsmwWypRNcZKHPYnIuOSfIWEyEQnPQ==",
"dependencies": {
"@types/unist": "^2.0.0",
"character-entities": "^2.0.0",
"character-entities-legacy": "^3.0.0",
"character-reference-invalid": "^2.0.0",
"decode-named-character-reference": "^1.0.0",
"is-alphanumerical": "^2.0.0",
"is-decimal": "^2.0.0",
"is-hexadecimal": "^2.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/parse-numeric-range": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/parse-numeric-range/-/parse-numeric-range-1.3.0.tgz",
"integrity": "sha512-twN+njEipszzlMJd4ONUYgSfZPDxgHhT9Ahed5uTigpQn90FggW4SA/AIPq/6a149fTbE9qBEcSwE3FAEp6wQQ=="
},
"node_modules/parse-path": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz",
"integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==",
"dependencies": {
"protocols": "^2.0.0"
}
},
"node_modules/parse-url": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz",
"integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==",
"dependencies": {
"parse-path": "^7.0.0"
}
},
"node_modules/parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
},
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"engines": {
"node": ">=8"
}
},
"node_modules/path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"engines": {
"node": ">=8"
}
},
"node_modules/path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
},
"node_modules/path-type": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"engines": {
"node": ">=8"
}
},
"node_modules/periscopic": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.0.4.tgz",
"integrity": "sha512-SFx68DxCv0Iyo6APZuw/AKewkkThGwssmU0QWtTlvov3VAtPX+QJ4CadwSaz8nrT5jPIuxdvJWB4PnD2KNDxQg==",
"dependencies": {
"estree-walker": "^3.0.0",
"is-reference": "^3.0.0"
}
},
"node_modules/picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
},
"node_modules/picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
"integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/postcss"
}
],
"dependencies": {
"nanoid": "^3.3.4",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.2"
},
"engines": {
"node": "^10 || ^12 || >=14"
}
},
"node_modules/prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/prop-types": {
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
"dependencies": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.13.1"
}
},
"node_modules/property-information": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/property-information/-/property-information-6.2.0.tgz",
"integrity": "sha512-kma4U7AFCTwpqq5twzC1YVIDXSqg6qQK6JN0smOw8fgRy1OkMi0CYSzFmsy6dnqSenamAtj0CyXMUJ1Mf6oROg==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/protocols": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz",
"integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q=="
},
"node_modules/pseudomap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
"integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ=="
},
"node_modules/punycode": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.2.0.tgz",
"integrity": "sha512-LN6QV1IJ9ZhxWTNdktaPClrNfp8xdSAYS0Zk2ddX7XsXZAxckMHPCBcHRo0cTcEIgYPRiGEkmji3Idkh2yFtYw==",
"engines": {
"node": ">=6"
}
},
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/react": {
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
"integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
"dependencies": {
"loose-envify": "^1.1.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/react-dom": {
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
"integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.0"
},
"peerDependencies": {
"react": "^18.2.0"
}
},
"node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"node_modules/reading-time": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/reading-time/-/reading-time-1.5.0.tgz",
"integrity": "sha512-onYyVhBNr4CmAxFsKS7bz+uTLRakypIe4R+5A824vBSkQy/hB3fZepoVEf8OVAxzLvK+H/jm9TzpI3ETSm64Kg=="
},
"node_modules/regenerator-runtime": {
"version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
},
"node_modules/regexp.prototype.flags": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz",
"integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"functions-have-names": "^1.2.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/regexpp": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz",
"integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/mysticatea"
}
},
"node_modules/rehype-katex": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-6.0.2.tgz",
"integrity": "sha512-C4gDAlS1+l0hJqctyiU64f9CvT00S03qV1T6HiMzbSuLBgWUtcqydWHY9OpKrm0SpkK16FNd62CDKyWLwV2ppg==",
"dependencies": {
"@types/hast": "^2.0.0",
"@types/katex": "^0.11.0",
"hast-util-to-text": "^3.1.0",
"katex": "^0.15.0",
"rehype-parse": "^8.0.0",
"unified": "^10.0.0",
"unist-util-remove-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-katex/node_modules/katex": {
"version": "0.15.6",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.15.6.tgz",
"integrity": "sha512-UpzJy4yrnqnhXvRPhjEuLA4lcPn6eRngixW7Q3TJErjg3Aw2PuLFBzTkdUb89UtumxjhHTqL3a5GDGETMSwgJA==",
"funding": [
"https://opencollective.com/katex",
"https://github.com/sponsors/katex"
],
"dependencies": {
"commander": "^8.0.0"
},
"bin": {
"katex": "cli.js"
}
},
"node_modules/rehype-parse": {
"version": "8.0.4",
"resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-8.0.4.tgz",
"integrity": "sha512-MJJKONunHjoTh4kc3dsM1v3C9kGrrxvA3U8PxZlP2SjH8RNUSrb+lF7Y0KVaUDnGH2QZ5vAn7ulkiajM9ifuqg==",
"dependencies": {
"@types/hast": "^2.0.0",
"hast-util-from-parse5": "^7.0.0",
"parse5": "^6.0.0",
"unified": "^10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-pretty-code": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/rehype-pretty-code/-/rehype-pretty-code-0.9.2.tgz",
"integrity": "sha512-l369pvBK6ihBEuy2+VDpHU+zbbY8I+Z4LiyIOunHAt3xyw6selaOFKc/DnX94jI5OJb3+NgjbOxXx2yaAypjZw==",
"dependencies": {
"hash-obj": "^4.0.0",
"nanoid": "^4.0.0",
"parse-numeric-range": "^1.3.0"
},
"engines": {
"node": "^12.16.0 || >=13.2.0"
},
"peerDependencies": {
"shiki": "*"
}
},
"node_modules/rehype-pretty-code/node_modules/nanoid": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.0.tgz",
"integrity": "sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg==",
"bin": {
"nanoid": "bin/nanoid.js"
},
"engines": {
"node": "^14 || ^16 || >=18"
}
},
"node_modules/remark-gfm": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz",
"integrity": "sha512-lEFDoi2PICJyNrACFOfDD3JlLkuSbOa5Wd8EPt06HUdptv8Gn0bxYTdbU/XXQ3swAPkEaGxxPN9cbnMHvVu1Ig==",
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-gfm": "^2.0.0",
"micromark-extension-gfm": "^2.0.0",
"unified": "^10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/remark-math": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/remark-math/-/remark-math-5.1.1.tgz",
"integrity": "sha512-cE5T2R/xLVtfFI4cCePtiRn+e6jKMtFDR3P8V3qpv8wpKjwvHoBA4eJzvX+nVrnlNy0911bdGmuspCSwetfYHw==",
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-math": "^2.0.0",
"micromark-extension-math": "^2.0.0",
"unified": "^10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/remark-mdx": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/remark-mdx/-/remark-mdx-2.2.1.tgz",
"integrity": "sha512-R9wcN+/THRXTKyRBp6Npo/mcbGA2iT3N4G8qUqLA5pOEg7kBidHv8K2hHidCMYZ6DXmwK18umu0K4cicgA2PPQ==",
"dependencies": {
"mdast-util-mdx": "^2.0.0",
"micromark-extension-mdxjs": "^1.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/remark-parse": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-10.0.1.tgz",
"integrity": "sha512-1fUyHr2jLsVOkhbvPRBJ5zTKZZyD6yZzYaWCS6BPBdQ8vEMBCH+9zNCDA6tET/zHCi/jLqjCWtlJZUPk+DbnFw==",
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-from-markdown": "^1.0.0",
"unified": "^10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/remark-reading-time": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/remark-reading-time/-/remark-reading-time-2.0.1.tgz",
"integrity": "sha512-fy4BKy9SRhtYbEHvp6AItbRTnrhiDGbqLQTSYVbQPGuRCncU1ubSsh9p/W5QZSxtYcUXv8KGL0xBgPLyNJA1xw==",
"dependencies": {
"estree-util-is-identifier-name": "^2.0.0",
"estree-util-value-to-estree": "^1.3.0",
"reading-time": "^1.3.0",
"unist-util-visit": "^3.1.0"
}
},
"node_modules/remark-reading-time/node_modules/unist-util-visit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz",
"integrity": "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA==",
"dependencies": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0",
"unist-util-visit-parents": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/remark-reading-time/node_modules/unist-util-visit-parents": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz",
"integrity": "sha512-1xAFJXAKpnnJl8G7K5KgU7FY55y3GcLIXqkzUj5QF/QVP7biUm0K0O2oqVkYsdjzJKifYeWn9+o6piAK2hGSHw==",
"dependencies": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/remark-rehype": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-10.1.0.tgz",
"integrity": "sha512-EFmR5zppdBp0WQeDVZ/b66CWJipB2q2VLNFMabzDSGR66Z2fQii83G5gTBbgGEnEEA0QRussvrFHxk1HWGJskw==",
"dependencies": {
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"mdast-util-to-hast": "^12.1.0",
"unified": "^10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/remove-accents": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/remove-accents/-/remove-accents-0.4.2.tgz",
"integrity": "sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA=="
},
"node_modules/resolve": {
"version": "1.22.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",
"integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==",
"dependencies": {
"is-core-module": "^2.9.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
"bin": {
"resolve": "bin/resolve"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"engines": {
"node": ">=4"
}
},
"node_modules/reusify": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
"engines": {
"iojs": ">=1.0.0",
"node": ">=0.10.0"
}
},
"node_modules/rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"dependencies": {
"glob": "^7.1.3"
},
"bin": {
"rimraf": "bin.js"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/run-parallel": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
"integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"dependencies": {
"queue-microtask": "^1.2.2"
}
},
"node_modules/sade": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
"integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
"dependencies": {
"mri": "^1.1.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/safe-regex-test": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz",
"integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==",
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"is-regex": "^1.1.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/scheduler": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
"integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
"dependencies": {
"loose-envify": "^1.1.0"
}
},
"node_modules/scroll-into-view-if-needed": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/scroll-into-view-if-needed/-/scroll-into-view-if-needed-3.0.4.tgz",
"integrity": "sha512-s+/F50jwTOUt+u5oEIAzum9MN2lUQNvWBe/zfEsVQcbaERjGkKLq1s+2wCHkahMLC8nMLbzMVKivx9JhunXaZg==",
"dependencies": {
"compute-scroll-into-view": "^2.0.4"
}
},
"node_modules/section-matter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz",
"integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==",
"dependencies": {
"extend-shallow": "^2.0.1",
"kind-of": "^6.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dependencies": {
"shebang-regex": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"engines": {
"node": ">=8"
}
},
"node_modules/shiki": {
"version": "0.12.1",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.12.1.tgz",
"integrity": "sha512-aieaV1m349rZINEBkjxh2QbBvFFQOlgqYTNtCal82hHj4dDZ76oMlQIX+C7ryerBTDiga3e5NfH6smjdJ02BbQ==",
"dependencies": {
"jsonc-parser": "^3.2.0",
"vscode-oniguruma": "^1.7.0",
"vscode-textmate": "^8.0.0"
}
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
"dependencies": {
"call-bind": "^1.0.0",
"get-intrinsic": "^1.0.2",
"object-inspect": "^1.9.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="
},
"node_modules/slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"engines": {
"node": ">=8"
}
},
"node_modules/sort-keys": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-5.0.0.tgz",
"integrity": "sha512-Pdz01AvCAottHTPQGzndktFNdbRA75BgOfeT1hH+AMnJFv8lynkPi42rfeEhpx1saTEI3YNMWxfqu0sFD1G8pw==",
"dependencies": {
"is-plain-obj": "^4.0.0"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/sort-keys/node_modules/is-plain-obj": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
"integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/source-map": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz",
"integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==",
"engines": {
"node": ">= 8"
}
},
"node_modules/source-map-js": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/space-separated-tokens": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz",
"integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g=="
},
"node_modules/stop-iteration-iterator": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz",
"integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==",
"dependencies": {
"internal-slot": "^1.0.4"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/string.prototype.matchall": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz",
"integrity": "sha512-6zOCOcJ+RJAQshcTvXPHoxoQGONa3e/Lqx90wUA+wEzX78sg5Bo+1tQo4N0pohS0erG9qtCqJDjNCQBjeWVxyg==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"get-intrinsic": "^1.1.3",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.3",
"regexp.prototype.flags": "^1.4.3",
"side-channel": "^1.0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/string.prototype.trimend": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz",
"integrity": "sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/string.prototype.trimstart": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz",
"integrity": "sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==",
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/stringify-entities": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.3.tgz",
"integrity": "sha512-BP9nNHMhhfcMbiuQKCqMjhDP5yBCAxsPu4pHFFzJ6Alo9dZgY4VLDPutXqIjpRiMoKdp7Av85Gr73Q5uH9k7+g==",
"dependencies": {
"character-entities-html4": "^2.0.0",
"character-entities-legacy": "^3.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
"engines": {
"node": ">=4"
}
},
"node_modules/strip-bom-string": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
"integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/strip-eof": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"integrity": "sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/strip-json-comments": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/style-to-object": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-0.4.1.tgz",
"integrity": "sha512-HFpbb5gr2ypci7Qw+IOhnP2zOU7e77b+rzM+wTzXzfi1PrtBCX0E7Pk4wL4iTLnhzZ+JgEGAhX81ebTg/aYjQw==",
"dependencies": {
"inline-style-parser": "0.1.1"
}
},
"node_modules/styled-jsx": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz",
"integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==",
"dependencies": {
"client-only": "0.0.1"
},
"engines": {
"node": ">= 12.0.0"
},
"peerDependencies": {
"react": ">= 16.8.0 || 17.x.x || ^18.0.0-0"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
},
"babel-plugin-macros": {
"optional": true
}
}
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/synckit": {
"version": "0.8.4",
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.4.tgz",
"integrity": "sha512-Dn2ZkzMdSX827QbowGbU/4yjWuvNaCoScLLoMo/yKbu+P4GBR6cRGKZH27k6a9bRzdqcyd1DE96pQtQ6uNkmyw==",
"dependencies": {
"@pkgr/utils": "^2.3.1",
"tslib": "^2.4.0"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/unts"
}
},
"node_modules/tapable": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
"engines": {
"node": ">=6"
}
},
"node_modules/text-table": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
"integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw=="
},
"node_modules/tiny-glob": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
"integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
"dependencies": {
"globalyzer": "0.1.0",
"globrex": "^0.1.2"
}
},
"node_modules/title": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/title/-/title-3.5.3.tgz",
"integrity": "sha512-20JyowYglSEeCvZv3EZ0nZ046vLarO37prvV0mbtQV7C8DJPGgN967r8SJkqd3XK3K3lD3/Iyfp3avjfil8Q2Q==",
"dependencies": {
"arg": "1.0.0",
"chalk": "2.3.0",
"clipboardy": "1.2.2",
"titleize": "1.0.0"
},
"bin": {
"title": "bin/title.js"
}
},
"node_modules/title/node_modules/ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dependencies": {
"color-convert": "^1.9.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/title/node_modules/chalk": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz",
"integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==",
"dependencies": {
"ansi-styles": "^3.1.0",
"escape-string-regexp": "^1.0.5",
"supports-color": "^4.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/title/node_modules/color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dependencies": {
"color-name": "1.1.3"
}
},
"node_modules/title/node_modules/color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
},
"node_modules/title/node_modules/escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/title/node_modules/has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha512-P+1n3MnwjR/Epg9BBo1KT8qbye2g2Ou4sFumihwt6I4tsUX7jnLcX4BTOSKg/B1ZrIYMN9FcEnG4x5a7NB8Eng==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/title/node_modules/supports-color": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz",
"integrity": "sha512-ycQR/UbvI9xIlEdQT1TQqwoXtEldExbCEAJgRo5YXlmSKjv6ThHnP9/vwGa1gr19Gfw+LkFd7KqYMhzrRC5JYw==",
"dependencies": {
"has-flag": "^2.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/titleize": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/titleize/-/titleize-1.0.0.tgz",
"integrity": "sha512-TARUb7z1pGvlLxgPk++7wJ6aycXF3GJ0sNSBTAsTuJrQG5QuZlkUQP+zl+nbjAh4gMX9yDw9ZYklMd7vAfJKEw==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dependencies": {
"is-number": "^7.0.0"
},
"engines": {
"node": ">=8.0"
}
},
"node_modules/trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",
"integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/trough": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/trough/-/trough-2.1.0.tgz",
"integrity": "sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/tsconfig-paths": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
"integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==",
"dependencies": {
"@types/json5": "^0.0.29",
"json5": "^1.0.1",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
}
},
"node_modules/tslib": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
"integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA=="
},
"node_modules/tsutils": {
"version": "3.21.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
"dependencies": {
"tslib": "^1.8.1"
},
"engines": {
"node": ">= 6"
},
"peerDependencies": {
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
}
},
"node_modules/tsutils/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
},
"node_modules/type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
"integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
"dependencies": {
"prelude-ls": "^1.2.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/type-fest": {
"version": "0.20.2",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/typed-array-length": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz",
"integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==",
"dependencies": {
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"is-typed-array": "^1.1.9"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/typescript": {
"version": "4.9.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz",
"integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
"integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==",
"dependencies": {
"call-bind": "^1.0.2",
"has-bigints": "^1.0.2",
"has-symbols": "^1.0.3",
"which-boxed-primitive": "^1.0.2"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/unified": {
"version": "10.1.2",
"resolved": "https://registry.npmjs.org/unified/-/unified-10.1.2.tgz",
"integrity": "sha512-pUSWAi/RAnVy1Pif2kAoeWNBa3JVrx0MId2LASj8G+7AiHWoKZNTomq6LG326T68U7/e263X6fTdcXIy7XnF7Q==",
"dependencies": {
"@types/unist": "^2.0.0",
"bail": "^2.0.0",
"extend": "^3.0.0",
"is-buffer": "^2.0.0",
"is-plain-obj": "^4.0.0",
"trough": "^2.0.0",
"vfile": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unified/node_modules/is-plain-obj": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
"integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/unist-builder": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-3.0.0.tgz",
"integrity": "sha512-GFxmfEAa0vi9i5sd0R2kcrI9ks0r82NasRq5QHh2ysGngrc6GiqD5CDf1FjPenY4vApmFASBIIlk/jj5J5YbmQ==",
"dependencies": {
"@types/unist": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-find-after": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-find-after/-/unist-util-find-after-4.0.0.tgz",
"integrity": "sha512-gfpsxKQde7atVF30n5Gff2fQhAc4/HTOV4CvkXpTg9wRfQhZWdXitpyXHWB6YcYgnsxLx+4gGHeVjCTAAp9sjw==",
"dependencies": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-generated": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-2.0.0.tgz",
"integrity": "sha512-TiWE6DVtVe7Ye2QxOVW9kqybs6cZexNwTwSMVgkfjEReqy/xwGpAXb99OxktoWwmL+Z+Epb0Dn8/GNDYP1wnUw==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-is": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz",
"integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-position": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.3.tgz",
"integrity": "sha512-p/5EMGIa1qwbXjA+QgcBXaPWjSnZfQ2Sc3yBEEfgPwsEmJd8Qh+DSk3LGnmOM4S1bY2C0AjmMnB8RuEYxpPwXQ==",
"dependencies": {
"@types/unist": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-position-from-estree": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/unist-util-position-from-estree/-/unist-util-position-from-estree-1.1.1.tgz",
"integrity": "sha512-xtoY50b5+7IH8tFbkw64gisG9tMSpxDjhX9TmaJJae/XuxQ9R/Kc8Nv1eOsf43Gt4KV/LkriMy9mptDr7XLcaw==",
"dependencies": {
"@types/unist": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-remove-position": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-4.0.1.tgz",
"integrity": "sha512-0yDkppiIhDlPrfHELgB+NLQD5mfjup3a8UYclHruTJWmY74je8g+CIFr79x5f6AkmzSwlvKLbs63hC0meOMowQ==",
"dependencies": {
"@types/unist": "^2.0.0",
"unist-util-visit": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-stringify-position": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.2.tgz",
"integrity": "sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==",
"dependencies": {
"@types/unist": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-visit": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.1.1.tgz",
"integrity": "sha512-n9KN3WV9k4h1DxYR1LoajgN93wpEi/7ZplVe02IoB4gH5ctI1AaF2670BLHQYbwj+pY83gFtyeySFiyMHJklrg==",
"dependencies": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0",
"unist-util-visit-parents": "^5.1.1"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-visit-parents": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.1.1.tgz",
"integrity": "sha512-gks4baapT/kNRaWxuGkl5BIhoanZo7sC/cUT/JToSRNL1dYoXRFl75d++NkjYk4TAu2uv2Px+l8guMajogeuiw==",
"dependencies": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
"dependencies": {
"punycode": "^2.1.0"
}
},
"node_modules/uvu": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/uvu/-/uvu-0.5.6.tgz",
"integrity": "sha512-+g8ENReyr8YsOc6fv/NVJs2vFdHBnBNdfE49rshrTzDWOlUx4Gq7KOS2GD8eqhy2j+Ejq29+SbKH8yjkAqXqoA==",
"dependencies": {
"dequal": "^2.0.0",
"diff": "^5.0.0",
"kleur": "^4.0.3",
"sade": "^1.7.3"
},
"bin": {
"uvu": "bin.js"
},
"engines": {
"node": ">=8"
}
},
"node_modules/vfile": {
"version": "5.3.6",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.6.tgz",
"integrity": "sha512-ADBsmerdGBs2WYckrLBEmuETSPyTD4TuLxTrw0DvjirxW1ra4ZwkbzG8ndsv3Q57smvHxo677MHaQrY9yxH8cA==",
"dependencies": {
"@types/unist": "^2.0.0",
"is-buffer": "^2.0.0",
"unist-util-stringify-position": "^3.0.0",
"vfile-message": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile-location": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz",
"integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==",
"dependencies": {
"@types/unist": "^2.0.0",
"vfile": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile-matter": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/vfile-matter/-/vfile-matter-3.0.1.tgz",
"integrity": "sha512-CAAIDwnh6ZdtrqAuxdElUqQRQDQgbbIrYtDYI8gCjXS1qQ+1XdLoK8FIZWxJwn0/I+BkSSZpar3SOgjemQz4fg==",
"dependencies": {
"@types/js-yaml": "^4.0.0",
"is-buffer": "^2.0.0",
"js-yaml": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile-message": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.3.tgz",
"integrity": "sha512-0yaU+rj2gKAyEk12ffdSbBfjnnj+b1zqTBv3OQCTn8yEB02bsPizwdBPrLJjHnK+cU9EMMcUnNv938XcZIkmdA==",
"dependencies": {
"@types/unist": "^2.0.0",
"unist-util-stringify-position": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vscode-oniguruma": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz",
"integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA=="
},
"node_modules/vscode-textmate": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz",
"integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg=="
},
"node_modules/web-namespaces": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",
"integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/which-boxed-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz",
"integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==",
"dependencies": {
"is-bigint": "^1.0.1",
"is-boolean-object": "^1.1.0",
"is-number-object": "^1.0.4",
"is-string": "^1.0.5",
"is-symbol": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/which-collection": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz",
"integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==",
"dependencies": {
"is-map": "^2.0.1",
"is-set": "^2.0.1",
"is-weakmap": "^2.0.1",
"is-weakset": "^2.0.1"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/which-typed-array": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz",
"integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==",
"dependencies": {
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"gopd": "^1.0.1",
"has-tostringtag": "^1.0.0",
"is-typed-array": "^1.1.10"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
},
"node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
},
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/zod": {
"version": "3.20.2",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.20.2.tgz",
"integrity": "sha512-1MzNQdAvO+54H+EaK5YpyEy0T+Ejo/7YLHS93G3RnYWh5gaotGHwGeN/ZO687qEDU2y4CdStQYXVHIgrUl5UVQ==",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
},
"node_modules/zwitch": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
"integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
}
},
"dependencies": {
"@babel/runtime": {
"version": "7.20.7",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.7.tgz",
"integrity": "sha512-UF0tvkUtxwAgZ5W/KrkHf0Rn0fdnLDU9ScxBrEVNUprE/MzirjK4MJUX1/BVDv00Sv8cljtukVK1aky++X1SjQ==",
"requires": {
"regenerator-runtime": "^0.13.11"
}
},
"@eslint/eslintrc": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz",
"integrity": "sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==",
"requires": {
"ajv": "^6.12.4",
"debug": "^4.3.2",
"espree": "^9.4.0",
"globals": "^13.19.0",
"ignore": "^5.2.0",
"import-fresh": "^3.2.1",
"js-yaml": "^4.1.0",
"minimatch": "^3.1.2",
"strip-json-comments": "^3.1.1"
}
},
"@headlessui/react": {
"version": "1.7.7",
"resolved": "https://registry.npmjs.org/@headlessui/react/-/react-1.7.7.tgz",
"integrity": "sha512-BqDOd/tB9u2tA0T3Z0fn18ktw+KbVwMnkxxsGPIH2hzssrQhKB5n/6StZOyvLYP/FsYtvuXfi9I0YowKPv2c1w==",
"requires": {
"client-only": "^0.0.1"
}
},
"@humanwhocodes/config-array": {
"version": "0.11.8",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz",
"integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==",
"requires": {
"@humanwhocodes/object-schema": "^1.2.1",
"debug": "^4.1.1",
"minimatch": "^3.0.5"
}
},
"@humanwhocodes/module-importer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
"integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA=="
},
"@humanwhocodes/object-schema": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA=="
},
"@mdx-js/mdx": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mdx-js/mdx/-/mdx-2.2.1.tgz",
"integrity": "sha512-hZ3ex7exYLJn6FfReq8yTvA6TE53uW9UHJQM9IlSauOuS55J9y8RtA7W+dzp6Yrzr00/U1sd7q+Wf61q6SfiTQ==",
"requires": {
"@types/estree-jsx": "^1.0.0",
"@types/mdx": "^2.0.0",
"estree-util-build-jsx": "^2.0.0",
"estree-util-is-identifier-name": "^2.0.0",
"estree-util-to-js": "^1.1.0",
"estree-walker": "^3.0.0",
"hast-util-to-estree": "^2.0.0",
"markdown-extensions": "^1.0.0",
"periscopic": "^3.0.0",
"remark-mdx": "^2.0.0",
"remark-parse": "^10.0.0",
"remark-rehype": "^10.0.0",
"unified": "^10.0.0",
"unist-util-position-from-estree": "^1.0.0",
"unist-util-stringify-position": "^3.0.0",
"unist-util-visit": "^4.0.0",
"vfile": "^5.0.0"
}
},
"@mdx-js/react": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-2.2.1.tgz",
"integrity": "sha512-YdXcMcEnqZhzql98RNrqYo9cEhTTesBiCclEtoiQUbJwx87q9453GTapYU6kJ8ZZ2ek1Vp25SiAXEFy5O/eAPw==",
"requires": {
"@types/mdx": "^2.0.0",
"@types/react": ">=16"
}
},
"@napi-rs/simple-git": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git/-/simple-git-0.1.8.tgz",
"integrity": "sha512-BvOMdkkofTz6lEE35itJ/laUokPhr/5ToMGlOH25YnhLD2yN1KpRAT4blW9tT8281/1aZjW3xyi73bs//IrDKA==",
"requires": {
"@napi-rs/simple-git-android-arm-eabi": "0.1.8",
"@napi-rs/simple-git-android-arm64": "0.1.8",
"@napi-rs/simple-git-darwin-arm64": "0.1.8",
"@napi-rs/simple-git-darwin-x64": "0.1.8",
"@napi-rs/simple-git-linux-arm-gnueabihf": "0.1.8",
"@napi-rs/simple-git-linux-arm64-gnu": "0.1.8",
"@napi-rs/simple-git-linux-arm64-musl": "0.1.8",
"@napi-rs/simple-git-linux-x64-gnu": "0.1.8",
"@napi-rs/simple-git-linux-x64-musl": "0.1.8",
"@napi-rs/simple-git-win32-arm64-msvc": "0.1.8",
"@napi-rs/simple-git-win32-x64-msvc": "0.1.8"
}
},
"@napi-rs/simple-git-android-arm-eabi": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-android-arm-eabi/-/simple-git-android-arm-eabi-0.1.8.tgz",
"integrity": "sha512-JJCejHBB1G6O8nxjQLT4quWCcvLpC3oRdJJ9G3MFYSCoYS8i1bWCWeU+K7Br+xT+D6s1t9q8kNJAwJv9Ygpi0g==",
"optional": true
},
"@napi-rs/simple-git-android-arm64": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-android-arm64/-/simple-git-android-arm64-0.1.8.tgz",
"integrity": "sha512-mraHzwWBw3tdRetNOS5KnFSjvdAbNBnjFLA8I4PwTCPJj3Q4txrigcPp2d59cJ0TC51xpnPXnZjYdNwwSI9g6g==",
"optional": true
},
"@napi-rs/simple-git-darwin-arm64": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-darwin-arm64/-/simple-git-darwin-arm64-0.1.8.tgz",
"integrity": "sha512-ufy/36eI/j4UskEuvqSH7uXtp3oXeLDmjQCfKJz3u5Vx98KmOMKrqAm2H81AB2WOtCo5mqS6PbBeUXR8BJX8lQ==",
"optional": true
},
"@napi-rs/simple-git-darwin-x64": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-darwin-x64/-/simple-git-darwin-x64-0.1.8.tgz",
"integrity": "sha512-Vb21U+v3tPJNl+8JtIHHT8HGe6WZ8o1Tq3f6p+Jx9Cz71zEbcIiB9FCEMY1knS/jwQEOuhhlI9Qk7d4HY+rprA==",
"optional": true
},
"@napi-rs/simple-git-linux-arm-gnueabihf": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-arm-gnueabihf/-/simple-git-linux-arm-gnueabihf-0.1.8.tgz",
"integrity": "sha512-6BPTJ7CzpSm2t54mRLVaUr3S7ORJfVJoCk2rQ8v8oDg0XAMKvmQQxOsAgqKBo9gYNHJnqrOx3AEuEgvB586BuQ==",
"optional": true
},
"@napi-rs/simple-git-linux-arm64-gnu": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-arm64-gnu/-/simple-git-linux-arm64-gnu-0.1.8.tgz",
"integrity": "sha512-qfESqUCAA/XoQpRXHptSQ8gIFnETCQt1zY9VOkplx6tgYk9PCeaX4B1Xuzrh3eZamSCMJFn+1YB9Ut8NwyGgAA==",
"optional": true
},
"@napi-rs/simple-git-linux-arm64-musl": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-arm64-musl/-/simple-git-linux-arm64-musl-0.1.8.tgz",
"integrity": "sha512-G80BQPpaRmQpn8dJGHp4I2/YVhWDUNJwcCrJAtAdbKFDCMyCHJBln2ERL/+IEUlIAT05zK/c1Z5WEprvXEdXow==",
"optional": true
},
"@napi-rs/simple-git-linux-x64-gnu": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-x64-gnu/-/simple-git-linux-x64-gnu-0.1.8.tgz",
"integrity": "sha512-NI6o1sZYEf6vPtNWJAm9w8BxJt+LlSFW0liSjYe3lc3e4dhMfV240f0ALeqlwdIldRPaDFwZSJX5/QbS7nMzhw==",
"optional": true
},
"@napi-rs/simple-git-linux-x64-musl": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-linux-x64-musl/-/simple-git-linux-x64-musl-0.1.8.tgz",
"integrity": "sha512-wljGAEOW41er45VTiU8kXJmO480pQKzsgRCvPlJJSCaEVBbmo6XXbFIXnZy1a2J3Zyy2IOsRB4PVkUZaNuPkZQ==",
"optional": true
},
"@napi-rs/simple-git-win32-arm64-msvc": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-win32-arm64-msvc/-/simple-git-win32-arm64-msvc-0.1.8.tgz",
"integrity": "sha512-QuV4QILyKPfbWHoQKrhXqjiCClx0SxbCTVogkR89BwivekqJMd9UlMxZdoCmwLWutRx4z9KmzQqokvYI5QeepA==",
"optional": true
},
"@napi-rs/simple-git-win32-x64-msvc": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@napi-rs/simple-git-win32-x64-msvc/-/simple-git-win32-x64-msvc-0.1.8.tgz",
"integrity": "sha512-UzNS4JtjhZhZ5hRLq7BIUq+4JOwt1ThIKv11CsF1ag2l99f0123XvfEpjczKTaa94nHtjXYc2Mv9TjccBqYOew==",
"optional": true
},
"@next/env": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.1.2.tgz",
"integrity": "sha512-PpT4UZIX66VMTqXt4HKEJ+/PwbS+tWmmhZlazaws1a+dbUA5pPdjntQ46Jvj616i3ZKN9doS9LHx3y50RLjAWg=="
},
"@next/eslint-plugin-next": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.1.2.tgz",
"integrity": "sha512-WGaNVvIYphdriesP6r7jq/8l7u38tzotnVQuxc1RYKLqYYApSsrebti3OCPoT3Gx0pw2smPIFHH98RzcsgW5GQ==",
"requires": {
"glob": "7.1.7"
}
},
"@next/font": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/font/-/font-13.1.2.tgz",
"integrity": "sha512-NXGXGFGiOKEnvBIHq9cdFTKbHO2/4B3Zd9K27M7j1DioIQVar7oVRqZMYs0h3XMVEZLwjjkdAtqRPCzzd3RtXg=="
},
"@next/swc-android-arm-eabi": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.2.tgz",
"integrity": "sha512-7mRz1owoGsbfIcdOJA3kk7KEwPZ+OvVT1z9DkR/yru4QdVLF69h/1SHy0vlUNQMxDRllabhxCfkoZCB34GOGAg==",
"optional": true
},
"@next/swc-android-arm64": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.1.2.tgz",
"integrity": "sha512-mgjZ2eJSayovQm1LcE54BLSI4jjnnnLtq5GY5g+DdPuUiCT644gKtjZ/w2BQvuIecCqqBO+Ph9yzo/wUTq7NLg==",
"optional": true
},
"@next/swc-darwin-arm64": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.2.tgz",
"integrity": "sha512-RikoQqy109r2222UJlyGs4dZw2BibkfPqpeFdW5JEGv+L2PStlHID8DwyVYbmHfQ0VIBGvbf/NAUtFakAWlhwg==",
"optional": true
},
"@next/swc-darwin-x64": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.2.tgz",
"integrity": "sha512-JbDZjaTvL8gyPC5TAH6OnD4jmXPkyUxRYPvu08ZmhT/XAFBb/Cso0BdXyDax/BPCG70mimP9d3hXNKNq+A0VtQ==",
"optional": true
},
"@next/swc-freebsd-x64": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.2.tgz",
"integrity": "sha512-ax4j8VrdFQ/xc3W7Om0u1vnDxVApQHKsChBbAMynCrnycZmpbqK4MZu4ZkycT+mx2eccCiqZROpbzDbEdPosEw==",
"optional": true
},
"@next/swc-linux-arm-gnueabihf": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.2.tgz",
"integrity": "sha512-NcRHTesnCxnUvSJa637PQJffBBkmqi5XS/xVWGY7dI6nyJ+pC96Oj7kd+mcjnFUQI5lHKbg39qBWKtOzbezc4w==",
"optional": true
},
"@next/swc-linux-arm64-gnu": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.2.tgz",
"integrity": "sha512-AxJdjocLtPrsBY4P2COSBIc3crT5bpjgGenNuINoensOlXhBkYM0aRDYZdydwXOhG+kN2ngUvfgitop9pa204w==",
"optional": true
},
"@next/swc-linux-arm64-musl": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.2.tgz",
"integrity": "sha512-JmNimDkcCRq7P5zpkdqeaSZ69qKDntEPtyIaMNWqy5M0WUJxGim0Fs6Qzxayiyvuuh9Guxks4woQ/j/ZvX/c8Q==",
"optional": true
},
"@next/swc-linux-x64-gnu": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.2.tgz",
"integrity": "sha512-TsLsjZwUlgmvI42neTuIoD6K9RlXCUzqPtvIClgXxVO0um0DiZwK+M+0zX/uVXhMVphfPY2c5YeR1zFSIONY4A==",
"optional": true
},
"@next/swc-linux-x64-musl": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.2.tgz",
"integrity": "sha512-eSkyXgCXydEFPTkcncQOGepafedPte6JT/OofB9uvruucrrMVBagCASOuPxodWEMrlfEKSXVnExMKIlfmQMD7A==",
"optional": true
},
"@next/swc-win32-arm64-msvc": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.2.tgz",
"integrity": "sha512-DmXFaRTgt2KrV9dmRLifDJE+cYiutHVFIw5/C9BtnwXH39uf3YbPxeD98vNrtqqqZVVLXY/1ySaSIwzYnqeY9g==",
"optional": true
},
"@next/swc-win32-ia32-msvc": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.2.tgz",
"integrity": "sha512-3+nBkuFs/wT+lmRVQNH5SyDT7I4vUlNPntosEaEP63FuYQdPLaxz0GvcR66MdFSFh2fsvazpe4wciOwVS4FItQ==",
"optional": true
},
"@next/swc-win32-x64-msvc": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.2.tgz",
"integrity": "sha512-avsyveEvcvH42PvKjR4Pb8JlLttuGURr2H3ZhS2b85pHOiZ7yjH3rMUoGnNzuLMApyxYaCvd4MedPrLhnNhkog==",
"optional": true
},
"@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
"integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
"requires": {
"@nodelib/fs.stat": "2.0.5",
"run-parallel": "^1.1.9"
}
},
"@nodelib/fs.stat": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
"integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="
},
"@nodelib/fs.walk": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
"integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
"requires": {
"@nodelib/fs.scandir": "2.1.5",
"fastq": "^1.6.0"
}
},
"@pkgr/utils": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.3.1.tgz",
"integrity": "sha512-wfzX8kc1PMyUILA+1Z/EqoE4UCXGy0iRGMhPwdfae1+f0OXlLqCk+By+aMzgJBzR9AzS4CDizioG6Ss1gvAFJw==",
"requires": {
"cross-spawn": "^7.0.3",
"is-glob": "^4.0.3",
"open": "^8.4.0",
"picocolors": "^1.0.0",
"tiny-glob": "^0.2.9",
"tslib": "^2.4.0"
}
},
"@popperjs/core": {
"version": "2.11.6",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
"integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw=="
},
"@rushstack/eslint-patch": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz",
"integrity": "sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg=="
},
"@swc/helpers": {
"version": "0.4.14",
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.14.tgz",
"integrity": "sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==",
"requires": {
"tslib": "^2.4.0"
}
},
"@types/acorn": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/@types/acorn/-/acorn-4.0.6.tgz",
"integrity": "sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==",
"requires": {
"@types/estree": "*"
}
},
"@types/debug": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz",
"integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==",
"requires": {
"@types/ms": "*"
}
},
"@types/estree": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz",
"integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ=="
},
"@types/estree-jsx": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/estree-jsx/-/estree-jsx-1.0.0.tgz",
"integrity": "sha512-3qvGd0z8F2ENTGr/GG1yViqfiKmRfrXVx5sJyHGFu3z7m5g5utCQtGp/g29JnjflhtQJBv1WDQukHiT58xPcYQ==",
"requires": {
"@types/estree": "*"
}
},
"@types/hast": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz",
"integrity": "sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==",
"requires": {
"@types/unist": "*"
}
},
"@types/js-yaml": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.5.tgz",
"integrity": "sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA=="
},
"@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ=="
},
"@types/katex": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.11.1.tgz",
"integrity": "sha512-DUlIj2nk0YnJdlWgsFuVKcX27MLW0KbKmGVoUHmFr+74FYYNUDAaj9ZqTADvsbE8rfxuVmSFc7KczYn5Y09ozg=="
},
"@types/mdast": {
"version": "3.0.10",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.10.tgz",
"integrity": "sha512-W864tg/Osz1+9f4lrGTZpCSO5/z4608eUp19tbozkq2HJK6i3z1kT0H9tlADXuYIb1YYOBByU4Jsqkk75q48qA==",
"requires": {
"@types/unist": "*"
}
},
"@types/mdx": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.3.tgz",
"integrity": "sha512-IgHxcT3RC8LzFLhKwP3gbMPeaK7BM9eBH46OdapPA7yvuIUJ8H6zHZV53J8hGZcTSnt95jANt+rTBNUUc22ACQ=="
},
"@types/ms": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz",
"integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA=="
},
"@types/node": {
"version": "18.11.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA=="
},
"@types/prop-types": {
"version": "15.7.5",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
},
"@types/react": {
"version": "18.0.26",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.26.tgz",
"integrity": "sha512-hCR3PJQsAIXyxhTNSiDFY//LhnMZWpNNr5etoCqx/iUfGc5gXWtQR2Phl908jVR6uPXacojQWTg4qRpkxTuGug==",
"requires": {
"@types/prop-types": "*",
"@types/scheduler": "*",
"csstype": "^3.0.2"
}
},
"@types/react-dom": {
"version": "18.0.10",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.10.tgz",
"integrity": "sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==",
"requires": {
"@types/react": "*"
}
},
"@types/scheduler": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="
},
"@types/unist": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
"integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ=="
},
"@typescript-eslint/parser": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.2.tgz",
"integrity": "sha512-38zMsKsG2sIuM5Oi/olurGwYJXzmtdsHhn5mI/pQogP+BjYVkK5iRazCQ8RGS0V+YLk282uWElN70zAAUmaYHw==",
"requires": {
"@typescript-eslint/scope-manager": "5.48.2",
"@typescript-eslint/types": "5.48.2",
"@typescript-eslint/typescript-estree": "5.48.2",
"debug": "^4.3.4"
}
},
"@typescript-eslint/scope-manager": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.48.2.tgz",
"integrity": "sha512-zEUFfonQid5KRDKoI3O+uP1GnrFd4tIHlvs+sTJXiWuypUWMuDaottkJuR612wQfOkjYbsaskSIURV9xo4f+Fw==",
"requires": {
"@typescript-eslint/types": "5.48.2",
"@typescript-eslint/visitor-keys": "5.48.2"
}
},
"@typescript-eslint/types": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.48.2.tgz",
"integrity": "sha512-hE7dA77xxu7ByBc6KCzikgfRyBCTst6dZQpwaTy25iMYOnbNljDT4hjhrGEJJ0QoMjrfqrx+j1l1B9/LtKeuqA=="
},
"@typescript-eslint/typescript-estree": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.2.tgz",
"integrity": "sha512-bibvD3z6ilnoVxUBFEgkO0k0aFvUc4Cttt0dAreEr+nrAHhWzkO83PEVVuieK3DqcgL6VAK5dkzK8XUVja5Zcg==",
"requires": {
"@typescript-eslint/types": "5.48.2",
"@typescript-eslint/visitor-keys": "5.48.2",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.48.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.2.tgz",
"integrity": "sha512-z9njZLSkwmjFWUelGEwEbdf4NwKvfHxvGC0OcGN1Hp/XNDIcJ7D5DpPNPv6x6/mFvc1tQHsaWmpD/a4gOvvCJQ==",
"requires": {
"@typescript-eslint/types": "5.48.2",
"eslint-visitor-keys": "^3.3.0"
}
},
"acorn": {
"version": "8.8.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
"integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA=="
},
"acorn-jsx": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
"requires": {}
},
"ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"requires": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
}
},
"ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
},
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"arch": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/arch/-/arch-2.2.0.tgz",
"integrity": "sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ=="
},
"arg": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/arg/-/arg-1.0.0.tgz",
"integrity": "sha512-Wk7TEzl1KqvTGs/uyhmHO/3XLd3t1UeU4IstvPXVzGPM522cTjqjNZ99esCkcL52sjqjo8e8CTBcWhkxvGzoAw=="
},
"argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
},
"aria-query": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz",
"integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==",
"requires": {
"deep-equal": "^2.0.5"
}
},
"array-includes": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.6.tgz",
"integrity": "sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"get-intrinsic": "^1.1.3",
"is-string": "^1.0.7"
}
},
"array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw=="
},
"array.prototype.flat": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz",
"integrity": "sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"es-shim-unscopables": "^1.0.0"
}
},
"array.prototype.flatmap": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz",
"integrity": "sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"es-shim-unscopables": "^1.0.0"
}
},
"array.prototype.tosorted": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.1.tgz",
"integrity": "sha512-pZYPXPRl2PqWcsUs6LOMn+1f1532nEoPTYowBtqLwAW+W8vSVhkIGnmOX1t/UQjD6YGI0vcD2B1U7ZFGQH9jnQ==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"es-shim-unscopables": "^1.0.0",
"get-intrinsic": "^1.1.3"
}
},
"ast-types-flow": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz",
"integrity": "sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag=="
},
"astring": {
"version": "1.8.4",
"resolved": "https://registry.npmjs.org/astring/-/astring-1.8.4.tgz",
"integrity": "sha512-97a+l2LBU3Op3bBQEff79i/E4jMD2ZLFD8rHx9B6mXyB2uQwhJQYfiDqUwtfjF4QA1F2qs//N6Cw8LetMbQjcw=="
},
"available-typed-arrays": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz",
"integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw=="
},
"axe-core": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.6.2.tgz",
"integrity": "sha512-b1WlTV8+XKLj9gZy2DZXgQiyDp9xkkoe2a6U6UbYccScq2wgH/YwCeI2/Jq2mgo0HzQxqJOjWZBLeA/mqsk5Mg=="
},
"axobject-query": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",
"integrity": "sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg==",
"requires": {
"deep-equal": "^2.0.5"
}
},
"bail": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz",
"integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw=="
},
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"requires": {
"fill-range": "^7.0.1"
}
},
"call-bind": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
"requires": {
"function-bind": "^1.1.1",
"get-intrinsic": "^1.0.2"
}
},
"callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="
},
"caniuse-lite": {
"version": "1.0.30001445",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001445.tgz",
"integrity": "sha512-8sdQIdMztYmzfTMO6KfLny878Ln9c2M0fc7EH60IjlP4Dc4PiCy7K2Vl3ITmWgOyPgVQKa5x+UP/KqFsxj4mBg=="
},
"ccount": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
"integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="
},
"chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"character-entities": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz",
"integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ=="
},
"character-entities-html4": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz",
"integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA=="
},
"character-entities-legacy": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz",
"integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="
},
"character-reference-invalid": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz",
"integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw=="
},
"client-only": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz",
"integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="
},
"clipboardy": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-1.2.2.tgz",
"integrity": "sha512-16KrBOV7bHmHdxcQiCvfUFYVFyEah4FI8vYT1Fr7CGSA4G+xBWMEfUEQJS1hxeHGtI9ju1Bzs9uXSbj5HZKArw==",
"requires": {
"arch": "^2.1.0",
"execa": "^0.8.0"
}
},
"clsx": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz",
"integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg=="
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"comma-separated-tokens": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",
"integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="
},
"commander": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
"integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww=="
},
"compute-scroll-into-view": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-2.0.4.tgz",
"integrity": "sha512-y/ZA3BGnxoM/QHHQ2Uy49CLtnWPbt4tTPpEEZiEmmiWBFKjej7nEyH8Ryz54jH0MLXflUYA3Er2zUxPSJu5R+g=="
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
},
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"requires": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
}
},
"csstype": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
"integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw=="
},
"damerau-levenshtein": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",
"integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA=="
},
"debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"requires": {
"ms": "2.1.2"
}
},
"decode-named-character-reference": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz",
"integrity": "sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==",
"requires": {
"character-entities": "^2.0.0"
}
},
"deep-equal": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.0.tgz",
"integrity": "sha512-RdpzE0Hv4lhowpIUKKMJfeH6C1pXdtT1/it80ubgWqwI3qpuxUBpC1S4hnHg+zjnuOoDkzUtUCEEkG+XG5l3Mw==",
"requires": {
"call-bind": "^1.0.2",
"es-get-iterator": "^1.1.2",
"get-intrinsic": "^1.1.3",
"is-arguments": "^1.1.1",
"is-array-buffer": "^3.0.1",
"is-date-object": "^1.0.5",
"is-regex": "^1.1.4",
"is-shared-array-buffer": "^1.0.2",
"isarray": "^2.0.5",
"object-is": "^1.1.5",
"object-keys": "^1.1.1",
"object.assign": "^4.1.4",
"regexp.prototype.flags": "^1.4.3",
"side-channel": "^1.0.4",
"which-boxed-primitive": "^1.0.2",
"which-collection": "^1.0.1",
"which-typed-array": "^1.1.9"
}
},
"deep-is": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ=="
},
"define-lazy-prop": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz",
"integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og=="
},
"define-properties": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz",
"integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==",
"requires": {
"has-property-descriptors": "^1.0.0",
"object-keys": "^1.1.1"
}
},
"dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA=="
},
"diff": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz",
"integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw=="
},
"dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"requires": {
"path-type": "^4.0.0"
}
},
"doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
"integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==",
"requires": {
"esutils": "^2.0.2"
}
},
"emoji-regex": {
"version": "9.2.2",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="
},
"enhanced-resolve": {
"version": "5.12.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz",
"integrity": "sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ==",
"requires": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
}
},
"es-abstract": {
"version": "1.21.1",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.21.1.tgz",
"integrity": "sha512-QudMsPOz86xYz/1dG1OuGBKOELjCh99IIWHLzy5znUB6j8xG2yMA7bfTV86VSqKF+Y/H08vQPR+9jyXpuC6hfg==",
"requires": {
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"es-set-tostringtag": "^2.0.1",
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"function.prototype.name": "^1.1.5",
"get-intrinsic": "^1.1.3",
"get-symbol-description": "^1.0.0",
"globalthis": "^1.0.3",
"gopd": "^1.0.1",
"has": "^1.0.3",
"has-property-descriptors": "^1.0.0",
"has-proto": "^1.0.1",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.4",
"is-array-buffer": "^3.0.1",
"is-callable": "^1.2.7",
"is-negative-zero": "^2.0.2",
"is-regex": "^1.1.4",
"is-shared-array-buffer": "^1.0.2",
"is-string": "^1.0.7",
"is-typed-array": "^1.1.10",
"is-weakref": "^1.0.2",
"object-inspect": "^1.12.2",
"object-keys": "^1.1.1",
"object.assign": "^4.1.4",
"regexp.prototype.flags": "^1.4.3",
"safe-regex-test": "^1.0.0",
"string.prototype.trimend": "^1.0.6",
"string.prototype.trimstart": "^1.0.6",
"typed-array-length": "^1.0.4",
"unbox-primitive": "^1.0.2",
"which-typed-array": "^1.1.9"
}
},
"es-get-iterator": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz",
"integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==",
"requires": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"has-symbols": "^1.0.3",
"is-arguments": "^1.1.1",
"is-map": "^2.0.2",
"is-set": "^2.0.2",
"is-string": "^1.0.7",
"isarray": "^2.0.5",
"stop-iteration-iterator": "^1.0.0"
}
},
"es-set-tostringtag": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz",
"integrity": "sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==",
"requires": {
"get-intrinsic": "^1.1.3",
"has": "^1.0.3",
"has-tostringtag": "^1.0.0"
}
},
"es-shim-unscopables": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz",
"integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==",
"requires": {
"has": "^1.0.3"
}
},
"es-to-primitive": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
"integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==",
"requires": {
"is-callable": "^1.1.4",
"is-date-object": "^1.0.1",
"is-symbol": "^1.0.2"
}
},
"escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="
},
"eslint": {
"version": "8.32.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.32.0.tgz",
"integrity": "sha512-nETVXpnthqKPFyuY2FNjz/bEd6nbosRgKbkgS/y1C7LJop96gYHWpiguLecMHQ2XCPxn77DS0P+68WzG6vkZSQ==",
"requires": {
"@eslint/eslintrc": "^1.4.1",
"@humanwhocodes/config-array": "^0.11.8",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
"debug": "^4.3.2",
"doctrine": "^3.0.0",
"escape-string-regexp": "^4.0.0",
"eslint-scope": "^7.1.1",
"eslint-utils": "^3.0.0",
"eslint-visitor-keys": "^3.3.0",
"espree": "^9.4.0",
"esquery": "^1.4.0",
"esutils": "^2.0.2",
"fast-deep-equal": "^3.1.3",
"file-entry-cache": "^6.0.1",
"find-up": "^5.0.0",
"glob-parent": "^6.0.2",
"globals": "^13.19.0",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
"is-path-inside": "^3.0.3",
"js-sdsl": "^4.1.4",
"js-yaml": "^4.1.0",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
"lodash.merge": "^4.6.2",
"minimatch": "^3.1.2",
"natural-compare": "^1.4.0",
"optionator": "^0.9.1",
"regexpp": "^3.2.0",
"strip-ansi": "^6.0.1",
"strip-json-comments": "^3.1.0",
"text-table": "^0.2.0"
}
},
"eslint-config-next": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.1.2.tgz",
"integrity": "sha512-zdRAQOr8v69ZwJRtBrGqAqm160ONqKxU/pV1FB1KlgfyqveGsLZmlQ7l31otwtw763901J7xdiTVkj2y3YxXZA==",
"requires": {
"@next/eslint-plugin-next": "13.1.2",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.42.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.31.7",
"eslint-plugin-react-hooks": "^4.5.0"
}
},
"eslint-import-resolver-node": {
"version": "0.3.7",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.7.tgz",
"integrity": "sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==",
"requires": {
"debug": "^3.2.7",
"is-core-module": "^2.11.0",
"resolve": "^1.22.1"
},
"dependencies": {
"debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"requires": {
"ms": "^2.1.1"
}
}
}
},
"eslint-import-resolver-typescript": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.5.3.tgz",
"integrity": "sha512-njRcKYBc3isE42LaTcJNVANR3R99H9bAxBDMNDr2W7yq5gYPxbU3MkdhsQukxZ/Xg9C2vcyLlDsbKfRDg0QvCQ==",
"requires": {
"debug": "^4.3.4",
"enhanced-resolve": "^5.10.0",
"get-tsconfig": "^4.2.0",
"globby": "^13.1.2",
"is-core-module": "^2.10.0",
"is-glob": "^4.0.3",
"synckit": "^0.8.4"
},
"dependencies": {
"globby": {
"version": "13.1.3",
"resolved": "https://registry.npmjs.org/globby/-/globby-13.1.3.tgz",
"integrity": "sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw==",
"requires": {
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.11",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^4.0.0"
}
},
"slash": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
"integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew=="
}
}
},
"eslint-module-utils": {
"version": "2.7.4",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz",
"integrity": "sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==",
"requires": {
"debug": "^3.2.7"
},
"dependencies": {
"debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"requires": {
"ms": "^2.1.1"
}
}
}
},
"eslint-plugin-import": {
"version": "2.27.5",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz",
"integrity": "sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==",
"requires": {
"array-includes": "^3.1.6",
"array.prototype.flat": "^1.3.1",
"array.prototype.flatmap": "^1.3.1",
"debug": "^3.2.7",
"doctrine": "^2.1.0",
"eslint-import-resolver-node": "^0.3.7",
"eslint-module-utils": "^2.7.4",
"has": "^1.0.3",
"is-core-module": "^2.11.0",
"is-glob": "^4.0.3",
"minimatch": "^3.1.2",
"object.values": "^1.1.6",
"resolve": "^1.22.1",
"semver": "^6.3.0",
"tsconfig-paths": "^3.14.1"
},
"dependencies": {
"debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"requires": {
"ms": "^2.1.1"
}
},
"doctrine": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
"integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==",
"requires": {
"esutils": "^2.0.2"
}
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
}
}
},
"eslint-plugin-jsx-a11y": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.7.1.tgz",
"integrity": "sha512-63Bog4iIethyo8smBklORknVjB0T2dwB8Mr/hIC+fBS0uyHdYYpzM/Ed+YC8VxTjlXHEWFOdmgwcDn1U2L9VCA==",
"requires": {
"@babel/runtime": "^7.20.7",
"aria-query": "^5.1.3",
"array-includes": "^3.1.6",
"array.prototype.flatmap": "^1.3.1",
"ast-types-flow": "^0.0.7",
"axe-core": "^4.6.2",
"axobject-query": "^3.1.1",
"damerau-levenshtein": "^1.0.8",
"emoji-regex": "^9.2.2",
"has": "^1.0.3",
"jsx-ast-utils": "^3.3.3",
"language-tags": "=1.0.5",
"minimatch": "^3.1.2",
"object.entries": "^1.1.6",
"object.fromentries": "^2.0.6",
"semver": "^6.3.0"
},
"dependencies": {
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
}
}
},
"eslint-plugin-react": {
"version": "7.32.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.32.1.tgz",
"integrity": "sha512-vOjdgyd0ZHBXNsmvU+785xY8Bfe57EFbTYYk8XrROzWpr9QBvpjITvAXt9xqcE6+8cjR/g1+mfumPToxsl1www==",
"requires": {
"array-includes": "^3.1.6",
"array.prototype.flatmap": "^1.3.1",
"array.prototype.tosorted": "^1.1.1",
"doctrine": "^2.1.0",
"estraverse": "^5.3.0",
"jsx-ast-utils": "^2.4.1 || ^3.0.0",
"minimatch": "^3.1.2",
"object.entries": "^1.1.6",
"object.fromentries": "^2.0.6",
"object.hasown": "^1.1.2",
"object.values": "^1.1.6",
"prop-types": "^15.8.1",
"resolve": "^2.0.0-next.4",
"semver": "^6.3.0",
"string.prototype.matchall": "^4.0.8"
},
"dependencies": {
"doctrine": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
"integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==",
"requires": {
"esutils": "^2.0.2"
}
},
"resolve": {
"version": "2.0.0-next.4",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.4.tgz",
"integrity": "sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ==",
"requires": {
"is-core-module": "^2.9.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
}
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
}
}
},
"eslint-plugin-react-hooks": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz",
"integrity": "sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==",
"requires": {}
},
"eslint-scope": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz",
"integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==",
"requires": {
"esrecurse": "^4.3.0",
"estraverse": "^5.2.0"
}
},
"eslint-utils": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz",
"integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==",
"requires": {
"eslint-visitor-keys": "^2.0.0"
},
"dependencies": {
"eslint-visitor-keys": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz",
"integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw=="
}
}
},
"eslint-visitor-keys": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz",
"integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA=="
},
"espree": {
"version": "9.4.1",
"resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz",
"integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==",
"requires": {
"acorn": "^8.8.0",
"acorn-jsx": "^5.3.2",
"eslint-visitor-keys": "^3.3.0"
}
},
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
},
"esquery": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz",
"integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==",
"requires": {
"estraverse": "^5.1.0"
}
},
"esrecurse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
"integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
"requires": {
"estraverse": "^5.2.0"
}
},
"estraverse": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA=="
},
"estree-util-attach-comments": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/estree-util-attach-comments/-/estree-util-attach-comments-2.1.0.tgz",
"integrity": "sha512-rJz6I4L0GaXYtHpoMScgDIwM0/Vwbu5shbMeER596rB2D1EWF6+Gj0e0UKzJPZrpoOc87+Q2kgVFHfjAymIqmw==",
"requires": {
"@types/estree": "^1.0.0"
}
},
"estree-util-build-jsx": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/estree-util-build-jsx/-/estree-util-build-jsx-2.2.2.tgz",
"integrity": "sha512-m56vOXcOBuaF+Igpb9OPAy7f9w9OIkb5yhjsZuaPm7HoGi4oTOQi0h2+yZ+AtKklYFZ+rPC4n0wYCJCEU1ONqg==",
"requires": {
"@types/estree-jsx": "^1.0.0",
"estree-util-is-identifier-name": "^2.0.0",
"estree-walker": "^3.0.0"
}
},
"estree-util-is-identifier-name": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-2.0.1.tgz",
"integrity": "sha512-rxZj1GkQhY4x1j/CSnybK9cGuMFQYFPLq0iNyopqf14aOVLFtMv7Esika+ObJWPWiOHuMOAHz3YkWoLYYRnzWQ=="
},
"estree-util-to-js": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/estree-util-to-js/-/estree-util-to-js-1.1.0.tgz",
"integrity": "sha512-490lbfCcpLk+ofK6HCgqDfYs4KAfq6QVvDw3+Bm1YoKRgiOjKiKYGAVQE1uwh7zVxBgWhqp4FDtp5SqunpUk1A==",
"requires": {
"@types/estree-jsx": "^1.0.0",
"astring": "^1.8.0",
"source-map": "^0.7.0"
}
},
"estree-util-value-to-estree": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/estree-util-value-to-estree/-/estree-util-value-to-estree-1.3.0.tgz",
"integrity": "sha512-Y+ughcF9jSUJvncXwqRageavjrNPAI+1M/L3BI3PyLp1nmgYTGUXU6t5z1Y7OWuThoDdhPME07bQU+d5LxdJqw==",
"requires": {
"is-plain-obj": "^3.0.0"
}
},
"estree-util-visit": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/estree-util-visit/-/estree-util-visit-1.2.0.tgz",
"integrity": "sha512-wdsoqhWueuJKsh5hqLw3j8lwFqNStm92VcwtAOAny8g/KS/l5Y8RISjR4k5W6skCj3Nirag/WUCMS0Nfy3sgsg==",
"requires": {
"@types/estree-jsx": "^1.0.0",
"@types/unist": "^2.0.0"
}
},
"estree-walker": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.2.tgz",
"integrity": "sha512-C03BvXCQIH/po+PNPONx/zSM9ziPr9weX8xNhYb/IJtdJ9z+L4z9VKPTB+UTHdmhnIopA2kc419ueyVyHVktwA=="
},
"esutils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g=="
},
"execa": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz",
"integrity": "sha512-zDWS+Rb1E8BlqqhALSt9kUhss8Qq4nN3iof3gsOdyINksElaPyNBtKUMTR62qhvgVWR0CqCX7sdnKe4MnUbFEA==",
"requires": {
"cross-spawn": "^5.0.1",
"get-stream": "^3.0.0",
"is-stream": "^1.1.0",
"npm-run-path": "^2.0.0",
"p-finally": "^1.0.0",
"signal-exit": "^3.0.0",
"strip-eof": "^1.0.0"
},
"dependencies": {
"cross-spawn": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
"integrity": "sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==",
"requires": {
"lru-cache": "^4.0.1",
"shebang-command": "^1.2.0",
"which": "^1.2.9"
}
},
"lru-cache": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
"integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==",
"requires": {
"pseudomap": "^1.0.2",
"yallist": "^2.1.2"
}
},
"shebang-command": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",
"integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==",
"requires": {
"shebang-regex": "^1.0.0"
}
},
"shebang-regex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz",
"integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ=="
},
"which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
"requires": {
"isexe": "^2.0.0"
}
},
"yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
"integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A=="
}
}
},
"extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
},
"extend-shallow": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==",
"requires": {
"is-extendable": "^0.1.0"
}
},
"fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
},
"fast-glob": {
"version": "3.2.12",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz",
"integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==",
"requires": {
"@nodelib/fs.stat": "^2.0.2",
"@nodelib/fs.walk": "^1.2.3",
"glob-parent": "^5.1.2",
"merge2": "^1.3.0",
"micromatch": "^4.0.4"
},
"dependencies": {
"glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"requires": {
"is-glob": "^4.0.1"
}
}
}
},
"fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
},
"fast-levenshtein": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw=="
},
"fastq": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz",
"integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==",
"requires": {
"reusify": "^1.0.4"
}
},
"file-entry-cache": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
"integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==",
"requires": {
"flat-cache": "^3.0.4"
}
},
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"requires": {
"to-regex-range": "^5.0.1"
}
},
"find-up": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
"integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
"requires": {
"locate-path": "^6.0.0",
"path-exists": "^4.0.0"
}
},
"flat-cache": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz",
"integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==",
"requires": {
"flatted": "^3.1.0",
"rimraf": "^3.0.2"
}
},
"flatted": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz",
"integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ=="
},
"flexsearch": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/flexsearch/-/flexsearch-0.7.31.tgz",
"integrity": "sha512-XGozTsMPYkm+6b5QL3Z9wQcJjNYxp0CYn3U1gO7dwD6PAqU1SVWZxI9CCg3z+ml3YfqdPnrBehaBrnH2AGKbNA=="
},
"focus-visible": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/focus-visible/-/focus-visible-5.2.0.tgz",
"integrity": "sha512-Rwix9pBtC1Nuy5wysTmKy+UjbDJpIfg8eHjw0rjZ1mX4GNLz1Bmd16uDpI3Gk1i70Fgcs8Csg2lPm8HULFg9DQ=="
},
"for-each": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
"integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==",
"requires": {
"is-callable": "^1.1.3"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"function.prototype.name": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz",
"integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"es-abstract": "^1.19.0",
"functions-have-names": "^1.2.2"
}
},
"functions-have-names": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz",
"integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ=="
},
"get-intrinsic": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz",
"integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==",
"requires": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.3"
}
},
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ=="
},
"get-symbol-description": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz",
"integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==",
"requires": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.1"
}
},
"get-tsconfig": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.3.0.tgz",
"integrity": "sha512-YCcF28IqSay3fqpIu5y3Krg/utCBHBeoflkZyHj/QcqI2nrLPC3ZegS9CmIo+hJb8K7aiGsuUl7PwWVjNG2HQQ=="
},
"git-up": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz",
"integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==",
"requires": {
"is-ssh": "^1.4.0",
"parse-url": "^8.1.0"
}
},
"git-url-parse": {
"version": "13.1.0",
"resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-13.1.0.tgz",
"integrity": "sha512-5FvPJP/70WkIprlUZ33bm4UAaFdjcLkJLpWft1BeZKqwR0uhhNGoKwlUaPtVb4LxCSQ++erHapRak9kWGj+FCA==",
"requires": {
"git-up": "^7.0.0"
}
},
"github-slugger": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz",
"integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw=="
},
"glob": {
"version": "7.1.7",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",
"integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"glob-parent": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
"integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==",
"requires": {
"is-glob": "^4.0.3"
}
},
"globals": {
"version": "13.19.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.19.0.tgz",
"integrity": "sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==",
"requires": {
"type-fest": "^0.20.2"
}
},
"globalthis": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz",
"integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==",
"requires": {
"define-properties": "^1.1.3"
}
},
"globalyzer": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
"integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q=="
},
"globby": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
"requires": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.9",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^3.0.0"
}
},
"globrex": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
},
"gopd": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
"requires": {
"get-intrinsic": "^1.1.3"
}
},
"graceful-fs": {
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA=="
},
"grapheme-splitter": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
"integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ=="
},
"gray-matter": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz",
"integrity": "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==",
"requires": {
"js-yaml": "^3.13.1",
"kind-of": "^6.0.2",
"section-matter": "^1.0.0",
"strip-bom-string": "^1.0.0"
},
"dependencies": {
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"requires": {
"sprintf-js": "~1.0.2"
}
},
"js-yaml": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
}
}
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"requires": {
"function-bind": "^1.1.1"
}
},
"has-bigints": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz",
"integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ=="
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"has-property-descriptors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz",
"integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==",
"requires": {
"get-intrinsic": "^1.1.1"
}
},
"has-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz",
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg=="
},
"has-symbols": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="
},
"has-tostringtag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz",
"integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==",
"requires": {
"has-symbols": "^1.0.2"
}
},
"hash-obj": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/hash-obj/-/hash-obj-4.0.0.tgz",
"integrity": "sha512-FwO1BUVWkyHasWDW4S8o0ssQXjvyghLV2rfVhnN36b2bbcj45eGiuzdn9XOvOpjV3TKQD7Gm2BWNXdE9V4KKYg==",
"requires": {
"is-obj": "^3.0.0",
"sort-keys": "^5.0.0",
"type-fest": "^1.0.2"
},
"dependencies": {
"type-fest": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-1.4.0.tgz",
"integrity": "sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA=="
}
}
},
"hast-util-from-parse5": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-7.1.1.tgz",
"integrity": "sha512-R6PoNcUs89ZxLJmMWsVbwSWuz95/9OriyQZ3e2ybwqGsRXzhA6gv49rgGmQvLbZuSNDv9fCg7vV7gXUsvtUFaA==",
"requires": {
"@types/hast": "^2.0.0",
"@types/unist": "^2.0.0",
"hastscript": "^7.0.0",
"property-information": "^6.0.0",
"vfile": "^5.0.0",
"vfile-location": "^4.0.0",
"web-namespaces": "^2.0.0"
}
},
"hast-util-is-element": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-2.1.3.tgz",
"integrity": "sha512-O1bKah6mhgEq2WtVMk+Ta5K7pPMqsBBlmzysLdcwKVrqzZQ0CHqUPiIVspNhAG1rvxpvJjtGee17XfauZYKqVA==",
"requires": {
"@types/hast": "^2.0.0",
"@types/unist": "^2.0.0"
}
},
"hast-util-parse-selector": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-3.1.1.tgz",
"integrity": "sha512-jdlwBjEexy1oGz0aJ2f4GKMaVKkA9jwjr4MjAAI22E5fM/TXVZHuS5OpONtdeIkRKqAaryQ2E9xNQxijoThSZA==",
"requires": {
"@types/hast": "^2.0.0"
}
},
"hast-util-to-estree": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/hast-util-to-estree/-/hast-util-to-estree-2.2.1.tgz",
"integrity": "sha512-kiGD9WIW3gRKK8Gao3n1f+ahUeTMeJUJILnIT2QNrPigDNdH7rJxzhEbh81UajGeAdAHFecT1a+fLVOCTq9B4Q==",
"requires": {
"@types/estree": "^1.0.0",
"@types/estree-jsx": "^1.0.0",
"@types/hast": "^2.0.0",
"@types/unist": "^2.0.0",
"comma-separated-tokens": "^2.0.0",
"estree-util-attach-comments": "^2.0.0",
"estree-util-is-identifier-name": "^2.0.0",
"hast-util-whitespace": "^2.0.0",
"mdast-util-mdx-expression": "^1.0.0",
"mdast-util-mdxjs-esm": "^1.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0",
"style-to-object": "^0.4.1",
"unist-util-position": "^4.0.0",
"zwitch": "^2.0.0"
}
},
"hast-util-to-text": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-3.1.2.tgz",
"integrity": "sha512-tcllLfp23dJJ+ju5wCCZHVpzsQQ43+moJbqVX3jNWPB7z/KFC4FyZD6R7y94cHL6MQ33YtMZL8Z0aIXXI4XFTw==",
"requires": {
"@types/hast": "^2.0.0",
"@types/unist": "^2.0.0",
"hast-util-is-element": "^2.0.0",
"unist-util-find-after": "^4.0.0"
}
},
"hast-util-whitespace": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-2.0.1.tgz",
"integrity": "sha512-nAxA0v8+vXSBDt3AnRUNjyRIQ0rD+ntpbAp4LnPkumc5M9yUbSMa4XDU9Q6etY4f1Wp4bNgvc1yjiZtsTTrSng=="
},
"hastscript": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-7.2.0.tgz",
"integrity": "sha512-TtYPq24IldU8iKoJQqvZOuhi5CyCQRAbvDOX0x1eW6rsHSxa/1i2CCiptNTotGHJ3VoHRGmqiv6/D3q113ikkw==",
"requires": {
"@types/hast": "^2.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-parse-selector": "^3.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0"
}
},
"ignore": {
"version": "5.2.4",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",
"integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ=="
},
"import-fresh": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
"integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==",
"requires": {
"parent-module": "^1.0.0",
"resolve-from": "^4.0.0"
}
},
"imurmurhash": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA=="
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"inline-style-parser": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.1.1.tgz",
"integrity": "sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q=="
},
"internal-slot": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.4.tgz",
"integrity": "sha512-tA8URYccNzMo94s5MQZgH8NB/XTa6HsOo0MLfXTKKEnHVVdegzaQoFZ7Jp44bdvLvY2waT5dc+j5ICEswhi7UQ==",
"requires": {
"get-intrinsic": "^1.1.3",
"has": "^1.0.3",
"side-channel": "^1.0.4"
}
},
"intersection-observer": {
"version": "0.12.2",
"resolved": "https://registry.npmjs.org/intersection-observer/-/intersection-observer-0.12.2.tgz",
"integrity": "sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg=="
},
"is-alphabetical": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz",
"integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ=="
},
"is-alphanumerical": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz",
"integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==",
"requires": {
"is-alphabetical": "^2.0.0",
"is-decimal": "^2.0.0"
}
},
"is-arguments": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz",
"integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==",
"requires": {
"call-bind": "^1.0.2",
"has-tostringtag": "^1.0.0"
}
},
"is-array-buffer": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.1.tgz",
"integrity": "sha512-ASfLknmY8Xa2XtB4wmbz13Wu202baeA18cJBCeCy0wXUHZF0IPyVEXqKEcd+t2fNSLLL1vC6k7lxZEojNbISXQ==",
"requires": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"is-typed-array": "^1.1.10"
}
},
"is-bigint": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz",
"integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==",
"requires": {
"has-bigints": "^1.0.1"
}
},
"is-boolean-object": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz",
"integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==",
"requires": {
"call-bind": "^1.0.2",
"has-tostringtag": "^1.0.0"
}
},
"is-buffer": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ=="
},
"is-callable": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
"integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA=="
},
"is-core-module": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",
"integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
"requires": {
"has": "^1.0.3"
}
},
"is-date-object": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz",
"integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==",
"requires": {
"has-tostringtag": "^1.0.0"
}
},
"is-decimal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz",
"integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A=="
},
"is-docker": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ=="
},
"is-extendable": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
"integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw=="
},
"is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="
},
"is-glob": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"requires": {
"is-extglob": "^2.1.1"
}
},
"is-hexadecimal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz",
"integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg=="
},
"is-map": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz",
"integrity": "sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg=="
},
"is-negative-zero": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
"integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA=="
},
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
},
"is-number-object": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz",
"integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==",
"requires": {
"has-tostringtag": "^1.0.0"
}
},
"is-obj": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-3.0.0.tgz",
"integrity": "sha512-IlsXEHOjtKhpN8r/tRFj2nDyTmHvcfNeu/nrRIcXE17ROeatXchkojffa1SpdqW4cr/Fj6QkEf/Gn4zf6KKvEQ=="
},
"is-path-inside": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
"integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ=="
},
"is-plain-obj": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz",
"integrity": "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA=="
},
"is-reference": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.1.tgz",
"integrity": "sha512-baJJdQLiYaJdvFbJqXrcGv3WU3QCzBlUcI5QhbesIm6/xPsvmO+2CDoi/GMOFBQEQm+PXkwOPrp9KK5ozZsp2w==",
"requires": {
"@types/estree": "*"
}
},
"is-regex": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz",
"integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==",
"requires": {
"call-bind": "^1.0.2",
"has-tostringtag": "^1.0.0"
}
},
"is-set": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.2.tgz",
"integrity": "sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g=="
},
"is-shared-array-buffer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz",
"integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==",
"requires": {
"call-bind": "^1.0.2"
}
},
"is-ssh": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz",
"integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==",
"requires": {
"protocols": "^2.0.1"
}
},
"is-stream": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ=="
},
"is-string": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz",
"integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==",
"requires": {
"has-tostringtag": "^1.0.0"
}
},
"is-symbol": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz",
"integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==",
"requires": {
"has-symbols": "^1.0.2"
}
},
"is-typed-array": {
"version": "1.1.10",
"resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz",
"integrity": "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==",
"requires": {
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"gopd": "^1.0.1",
"has-tostringtag": "^1.0.0"
}
},
"is-weakmap": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz",
"integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA=="
},
"is-weakref": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz",
"integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==",
"requires": {
"call-bind": "^1.0.2"
}
},
"is-weakset": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.2.tgz",
"integrity": "sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==",
"requires": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.1"
}
},
"is-wsl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"requires": {
"is-docker": "^2.0.0"
}
},
"isarray": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
"integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="
},
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
},
"js-sdsl": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz",
"integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ=="
},
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"requires": {
"argparse": "^2.0.1"
}
},
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
},
"json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
"integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw=="
},
"json5": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"requires": {
"minimist": "^1.2.0"
}
},
"jsonc-parser": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",
"integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w=="
},
"jsx-ast-utils": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz",
"integrity": "sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw==",
"requires": {
"array-includes": "^3.1.5",
"object.assign": "^4.1.3"
}
},
"katex": {
"version": "0.16.4",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.16.4.tgz",
"integrity": "sha512-WudRKUj8yyBeVDI4aYMNxhx5Vhh2PjpzQw1GRu/LVGqL4m1AxwD1GcUp0IMbdJaf5zsjtj8ghP0DOQRYhroNkw==",
"requires": {
"commander": "^8.0.0"
}
},
"kind-of": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw=="
},
"kleur": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
"integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ=="
},
"language-subtag-registry": {
"version": "0.3.22",
"resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz",
"integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w=="
},
"language-tags": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz",
"integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==",
"requires": {
"language-subtag-registry": "~0.3.2"
}
},
"levn": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
"integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
"requires": {
"prelude-ls": "^1.2.1",
"type-check": "~0.4.0"
}
},
"locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
"integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
"requires": {
"p-locate": "^5.0.0"
}
},
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ=="
},
"lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="
},
"longest-streak": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz",
"integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g=="
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"requires": {
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
"lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"requires": {
"yallist": "^4.0.0"
}
},
"markdown-extensions": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-1.1.1.tgz",
"integrity": "sha512-WWC0ZuMzCyDHYCasEGs4IPvLyTGftYwh6wIEOULOF0HXcqZlhwRzrK0w2VUlxWA98xnvb/jszw4ZSkJ6ADpM6Q=="
},
"markdown-table": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.3.tgz",
"integrity": "sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw=="
},
"match-sorter": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/match-sorter/-/match-sorter-6.3.1.tgz",
"integrity": "sha512-mxybbo3pPNuA+ZuCUhm5bwNkXrJTbsk5VWbR5wiwz/GC6LIiegBGn2w3O08UG/jdbYLinw51fSQ5xNU1U3MgBw==",
"requires": {
"@babel/runtime": "^7.12.5",
"remove-accents": "0.4.2"
}
},
"mdast-util-definitions": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-5.1.1.tgz",
"integrity": "sha512-rQ+Gv7mHttxHOBx2dkF4HWTg+EE+UR78ptQWDylzPKaQuVGdG4HIoY3SrS/pCp80nZ04greFvXbVFHT+uf0JVQ==",
"requires": {
"@types/mdast": "^3.0.0",
"@types/unist": "^2.0.0",
"unist-util-visit": "^4.0.0"
}
},
"mdast-util-find-and-replace": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-2.2.1.tgz",
"integrity": "sha512-SobxkQXFAdd4b5WmEakmkVoh18icjQRxGy5OWTCzgsLRm1Fu/KCtwD1HIQSsmq5ZRjVH0Ehwg6/Fn3xIUk+nKw==",
"requires": {
"escape-string-regexp": "^5.0.0",
"unist-util-is": "^5.0.0",
"unist-util-visit-parents": "^5.0.0"
},
"dependencies": {
"escape-string-regexp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
"integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw=="
}
}
},
"mdast-util-from-markdown": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-1.2.0.tgz",
"integrity": "sha512-iZJyyvKD1+K7QX1b5jXdE7Sc5dtoTry1vzV28UZZe8Z1xVnB/czKntJ7ZAkG0tANqRnBF6p3p7GpU1y19DTf2Q==",
"requires": {
"@types/mdast": "^3.0.0",
"@types/unist": "^2.0.0",
"decode-named-character-reference": "^1.0.0",
"mdast-util-to-string": "^3.1.0",
"micromark": "^3.0.0",
"micromark-util-decode-numeric-character-reference": "^1.0.0",
"micromark-util-decode-string": "^1.0.0",
"micromark-util-normalize-identifier": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"unist-util-stringify-position": "^3.0.0",
"uvu": "^0.5.0"
}
},
"mdast-util-gfm": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-2.0.1.tgz",
"integrity": "sha512-42yHBbfWIFisaAfV1eixlabbsa6q7vHeSPY+cg+BBjX51M8xhgMacqH9g6TftB/9+YkcI0ooV4ncfrJslzm/RQ==",
"requires": {
"mdast-util-from-markdown": "^1.0.0",
"mdast-util-gfm-autolink-literal": "^1.0.0",
"mdast-util-gfm-footnote": "^1.0.0",
"mdast-util-gfm-strikethrough": "^1.0.0",
"mdast-util-gfm-table": "^1.0.0",
"mdast-util-gfm-task-list-item": "^1.0.0",
"mdast-util-to-markdown": "^1.0.0"
}
},
"mdast-util-gfm-autolink-literal": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-1.0.2.tgz",
"integrity": "sha512-FzopkOd4xTTBeGXhXSBU0OCDDh5lUj2rd+HQqG92Ld+jL4lpUfgX2AT2OHAVP9aEeDKp7G92fuooSZcYJA3cRg==",
"requires": {
"@types/mdast": "^3.0.0",
"ccount": "^2.0.0",
"mdast-util-find-and-replace": "^2.0.0",
"micromark-util-character": "^1.0.0"
}
},
"mdast-util-gfm-footnote": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-1.0.1.tgz",
"integrity": "sha512-p+PrYlkw9DeCRkTVw1duWqPRHX6Ywh2BNKJQcZbCwAuP/59B0Lk9kakuAd7KbQprVO4GzdW8eS5++A9PUSqIyw==",
"requires": {
"@types/mdast": "^3.0.0",
"mdast-util-to-markdown": "^1.3.0",
"micromark-util-normalize-identifier": "^1.0.0"
}
},
"mdast-util-gfm-strikethrough": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-1.0.2.tgz",
"integrity": "sha512-T/4DVHXcujH6jx1yqpcAYYwd+z5lAYMw4Ls6yhTfbMMtCt0PHY4gEfhW9+lKsLBtyhUGKRIzcUA2FATVqnvPDA==",
"requires": {
"@types/mdast": "^3.0.0",
"mdast-util-to-markdown": "^1.3.0"
}
},
"mdast-util-gfm-table": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-1.0.6.tgz",
"integrity": "sha512-uHR+fqFq3IvB3Rd4+kzXW8dmpxUhvgCQZep6KdjsLK4O6meK5dYZEayLtIxNus1XO3gfjfcIFe8a7L0HZRGgag==",
"requires": {
"@types/mdast": "^3.0.0",
"markdown-table": "^3.0.0",
"mdast-util-from-markdown": "^1.0.0",
"mdast-util-to-markdown": "^1.3.0"
}
},
"mdast-util-gfm-task-list-item": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-1.0.1.tgz",
"integrity": "sha512-KZ4KLmPdABXOsfnM6JHUIjxEvcx2ulk656Z/4Balw071/5qgnhz+H1uGtf2zIGnrnvDC8xR4Fj9uKbjAFGNIeA==",
"requires": {
"@types/mdast": "^3.0.0",
"mdast-util-to-markdown": "^1.3.0"
}
},
"mdast-util-math": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-math/-/mdast-util-math-2.0.1.tgz",
"integrity": "sha512-ZZtjyRwobsiVg4bY0Q5CzAZztpbjRIA7ZlMMb0PNkwTXOnJTUoHvzBhVG95LIuek5Mlj1l2P+jBvWviqW7G+0A==",
"requires": {
"@types/mdast": "^3.0.0",
"longest-streak": "^3.0.0",
"mdast-util-to-markdown": "^1.3.0"
}
},
"mdast-util-mdx": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-mdx/-/mdast-util-mdx-2.0.0.tgz",
"integrity": "sha512-M09lW0CcBT1VrJUaF/PYxemxxHa7SLDHdSn94Q9FhxjCQfuW7nMAWKWimTmA3OyDMSTH981NN1csW1X+HPSluw==",
"requires": {
"mdast-util-mdx-expression": "^1.0.0",
"mdast-util-mdx-jsx": "^2.0.0",
"mdast-util-mdxjs-esm": "^1.0.0"
}
},
"mdast-util-mdx-expression": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-1.3.1.tgz",
"integrity": "sha512-TTb6cKyTA1RD+1su1iStZ5PAv3rFfOUKcoU5EstUpv/IZo63uDX03R8+jXjMEhcobXnNOiG6/ccekvVl4eV1zQ==",
"requires": {
"@types/estree-jsx": "^1.0.0",
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"mdast-util-from-markdown": "^1.0.0",
"mdast-util-to-markdown": "^1.0.0"
}
},
"mdast-util-mdx-jsx": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-2.1.0.tgz",
"integrity": "sha512-KzgzfWMhdteDkrY4mQtyvTU5bc/W4ppxhe9SzelO6QUUiwLAM+Et2Dnjjprik74a336kHdo0zKm7Tp+n6FFeRg==",
"requires": {
"@types/estree-jsx": "^1.0.0",
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"ccount": "^2.0.0",
"mdast-util-to-markdown": "^1.3.0",
"parse-entities": "^4.0.0",
"stringify-entities": "^4.0.0",
"unist-util-remove-position": "^4.0.0",
"unist-util-stringify-position": "^3.0.0",
"vfile-message": "^3.0.0"
}
},
"mdast-util-mdxjs-esm": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/mdast-util-mdxjs-esm/-/mdast-util-mdxjs-esm-1.3.0.tgz",
"integrity": "sha512-7N5ihsOkAEGjFotIX9p/YPdl4TqUoMxL4ajNz7PbT89BqsdWJuBC9rvgt6wpbwTZqWWR0jKWqQbwsOWDBUZv4g==",
"requires": {
"@types/estree-jsx": "^1.0.0",
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"mdast-util-from-markdown": "^1.0.0",
"mdast-util-to-markdown": "^1.0.0"
}
},
"mdast-util-phrasing": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-3.0.0.tgz",
"integrity": "sha512-S+QYsDRLkGi8U7o5JF1agKa/sdP+CNGXXLqC17pdTVL8FHHgQEiwFGa9yE5aYtUxNiFGYoaDy9V1kC85Sz86Gg==",
"requires": {
"@types/mdast": "^3.0.0",
"unist-util-is": "^5.0.0"
}
},
"mdast-util-to-hast": {
"version": "12.2.5",
"resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-12.2.5.tgz",
"integrity": "sha512-EFNhT35ZR/VZ85/EedDdCNTq0oFM+NM/+qBomVGQ0+Lcg0nhI8xIwmdCzNMlVlCJNXRprpobtKP/IUh8cfz6zQ==",
"requires": {
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"mdast-util-definitions": "^5.0.0",
"micromark-util-sanitize-uri": "^1.1.0",
"trim-lines": "^3.0.0",
"unist-builder": "^3.0.0",
"unist-util-generated": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
}
},
"mdast-util-to-markdown": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-1.5.0.tgz",
"integrity": "sha512-bbv7TPv/WC49thZPg3jXuqzuvI45IL2EVAr/KxF0BSdHsU0ceFHOmwQn6evxAh1GaoK/6GQ1wp4R4oW2+LFL/A==",
"requires": {
"@types/mdast": "^3.0.0",
"@types/unist": "^2.0.0",
"longest-streak": "^3.0.0",
"mdast-util-phrasing": "^3.0.0",
"mdast-util-to-string": "^3.0.0",
"micromark-util-decode-string": "^1.0.0",
"unist-util-visit": "^4.0.0",
"zwitch": "^2.0.0"
}
},
"mdast-util-to-string": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.0.tgz",
"integrity": "sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA=="
},
"merge2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg=="
},
"micromark": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/micromark/-/micromark-3.1.0.tgz",
"integrity": "sha512-6Mj0yHLdUZjHnOPgr5xfWIMqMWS12zDN6iws9SLuSz76W8jTtAv24MN4/CL7gJrl5vtxGInkkqDv/JIoRsQOvA==",
"requires": {
"@types/debug": "^4.0.0",
"debug": "^4.0.0",
"decode-named-character-reference": "^1.0.0",
"micromark-core-commonmark": "^1.0.1",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-chunked": "^1.0.0",
"micromark-util-combine-extensions": "^1.0.0",
"micromark-util-decode-numeric-character-reference": "^1.0.0",
"micromark-util-encode": "^1.0.0",
"micromark-util-normalize-identifier": "^1.0.0",
"micromark-util-resolve-all": "^1.0.0",
"micromark-util-sanitize-uri": "^1.0.0",
"micromark-util-subtokenize": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.1",
"uvu": "^0.5.0"
}
},
"micromark-core-commonmark": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-1.0.6.tgz",
"integrity": "sha512-K+PkJTxqjFfSNkfAhp4GB+cZPfQd6dxtTXnf+RjZOV7T4EEXnvgzOcnp+eSTmpGk9d1S9sL6/lqrgSNn/s0HZA==",
"requires": {
"decode-named-character-reference": "^1.0.0",
"micromark-factory-destination": "^1.0.0",
"micromark-factory-label": "^1.0.0",
"micromark-factory-space": "^1.0.0",
"micromark-factory-title": "^1.0.0",
"micromark-factory-whitespace": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-chunked": "^1.0.0",
"micromark-util-classify-character": "^1.0.0",
"micromark-util-html-tag-name": "^1.0.0",
"micromark-util-normalize-identifier": "^1.0.0",
"micromark-util-resolve-all": "^1.0.0",
"micromark-util-subtokenize": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.1",
"uvu": "^0.5.0"
}
},
"micromark-extension-gfm": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-2.0.1.tgz",
"integrity": "sha512-p2sGjajLa0iYiGQdT0oelahRYtMWvLjy8J9LOCxzIQsllMCGLbsLW+Nc+N4vi02jcRJvedVJ68cjelKIO6bpDA==",
"requires": {
"micromark-extension-gfm-autolink-literal": "^1.0.0",
"micromark-extension-gfm-footnote": "^1.0.0",
"micromark-extension-gfm-strikethrough": "^1.0.0",
"micromark-extension-gfm-table": "^1.0.0",
"micromark-extension-gfm-tagfilter": "^1.0.0",
"micromark-extension-gfm-task-list-item": "^1.0.0",
"micromark-util-combine-extensions": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"micromark-extension-gfm-autolink-literal": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-1.0.3.tgz",
"integrity": "sha512-i3dmvU0htawfWED8aHMMAzAVp/F0Z+0bPh3YrbTPPL1v4YAlCZpy5rBO5p0LPYiZo0zFVkoYh7vDU7yQSiCMjg==",
"requires": {
"micromark-util-character": "^1.0.0",
"micromark-util-sanitize-uri": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"micromark-extension-gfm-footnote": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-1.0.4.tgz",
"integrity": "sha512-E/fmPmDqLiMUP8mLJ8NbJWJ4bTw6tS+FEQS8CcuDtZpILuOb2kjLqPEeAePF1djXROHXChM/wPJw0iS4kHCcIg==",
"requires": {
"micromark-core-commonmark": "^1.0.0",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-normalize-identifier": "^1.0.0",
"micromark-util-sanitize-uri": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"micromark-extension-gfm-strikethrough": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-1.0.4.tgz",
"integrity": "sha512-/vjHU/lalmjZCT5xt7CcHVJGq8sYRm80z24qAKXzaHzem/xsDYb2yLL+NNVbYvmpLx3O7SYPuGL5pzusL9CLIQ==",
"requires": {
"micromark-util-chunked": "^1.0.0",
"micromark-util-classify-character": "^1.0.0",
"micromark-util-resolve-all": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"micromark-extension-gfm-table": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-1.0.5.tgz",
"integrity": "sha512-xAZ8J1X9W9K3JTJTUL7G6wSKhp2ZYHrFk5qJgY/4B33scJzE2kpfRL6oiw/veJTbt7jiM/1rngLlOKPWr1G+vg==",
"requires": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"micromark-extension-gfm-tagfilter": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-1.0.1.tgz",
"integrity": "sha512-Ty6psLAcAjboRa/UKUbbUcwjVAv5plxmpUTy2XC/3nJFL37eHej8jrHrRzkqcpipJliuBH30DTs7+3wqNcQUVA==",
"requires": {
"micromark-util-types": "^1.0.0"
}
},
"micromark-extension-gfm-task-list-item": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-1.0.3.tgz",
"integrity": "sha512-PpysK2S1Q/5VXi72IIapbi/jliaiOFzv7THH4amwXeYXLq3l1uo8/2Be0Ac1rEwK20MQEsGH2ltAZLNY2KI/0Q==",
"requires": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"micromark-extension-math": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/micromark-extension-math/-/micromark-extension-math-2.0.2.tgz",
"integrity": "sha512-cFv2B/E4pFPBBFuGgLHkkNiFAIQv08iDgPH2HCuR2z3AUgMLecES5Cq7AVtwOtZeRrbA80QgMUk8VVW0Z+D2FA==",
"requires": {
"@types/katex": "^0.11.0",
"katex": "^0.13.0",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
},
"dependencies": {
"katex": {
"version": "0.13.24",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.13.24.tgz",
"integrity": "sha512-jZxYuKCma3VS5UuxOx/rFV1QyGSl3Uy/i0kTJF3HgQ5xMinCQVF8Zd4bMY/9aI9b9A2pjIBOsjSSm68ykTAr8w==",
"requires": {
"commander": "^8.0.0"
}
}
}
},
"micromark-extension-mdx-expression": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-mdx-expression/-/micromark-extension-mdx-expression-1.0.3.tgz",
"integrity": "sha512-TjYtjEMszWze51NJCZmhv7MEBcgYRgb3tJeMAJ+HQCAaZHHRBaDCccqQzGizR/H4ODefP44wRTgOn2vE5I6nZA==",
"requires": {
"micromark-factory-mdx-expression": "^1.0.0",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-events-to-acorn": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"micromark-extension-mdx-jsx": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-mdx-jsx/-/micromark-extension-mdx-jsx-1.0.3.tgz",
"integrity": "sha512-VfA369RdqUISF0qGgv2FfV7gGjHDfn9+Qfiv5hEwpyr1xscRj/CiVRkU7rywGFCO7JwJ5L0e7CJz60lY52+qOA==",
"requires": {
"@types/acorn": "^4.0.0",
"estree-util-is-identifier-name": "^2.0.0",
"micromark-factory-mdx-expression": "^1.0.0",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0",
"vfile-message": "^3.0.0"
}
},
"micromark-extension-mdx-md": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-extension-mdx-md/-/micromark-extension-mdx-md-1.0.0.tgz",
"integrity": "sha512-xaRAMoSkKdqZXDAoSgp20Azm0aRQKGOl0RrS81yGu8Hr/JhMsBmfs4wR7m9kgVUIO36cMUQjNyiyDKPrsv8gOw==",
"requires": {
"micromark-util-types": "^1.0.0"
}
},
"micromark-extension-mdxjs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-extension-mdxjs/-/micromark-extension-mdxjs-1.0.0.tgz",
"integrity": "sha512-TZZRZgeHvtgm+IhtgC2+uDMR7h8eTKF0QUX9YsgoL9+bADBpBY6SiLvWqnBlLbCEevITmTqmEuY3FoxMKVs1rQ==",
"requires": {
"acorn": "^8.0.0",
"acorn-jsx": "^5.0.0",
"micromark-extension-mdx-expression": "^1.0.0",
"micromark-extension-mdx-jsx": "^1.0.0",
"micromark-extension-mdx-md": "^1.0.0",
"micromark-extension-mdxjs-esm": "^1.0.0",
"micromark-util-combine-extensions": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"micromark-extension-mdxjs-esm": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/micromark-extension-mdxjs-esm/-/micromark-extension-mdxjs-esm-1.0.3.tgz",
"integrity": "sha512-2N13ol4KMoxb85rdDwTAC6uzs8lMX0zeqpcyx7FhS7PxXomOnLactu8WI8iBNXW8AVyea3KIJd/1CKnUmwrK9A==",
"requires": {
"micromark-core-commonmark": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-events-to-acorn": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"unist-util-position-from-estree": "^1.1.0",
"uvu": "^0.5.0",
"vfile-message": "^3.0.0"
}
},
"micromark-factory-destination": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-1.0.0.tgz",
"integrity": "sha512-eUBA7Rs1/xtTVun9TmV3gjfPz2wEwgK5R5xcbIM5ZYAtvGF6JkyaDsj0agx8urXnO31tEO6Ug83iVH3tdedLnw==",
"requires": {
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"micromark-factory-label": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-1.0.2.tgz",
"integrity": "sha512-CTIwxlOnU7dEshXDQ+dsr2n+yxpP0+fn271pu0bwDIS8uqfFcumXpj5mLn3hSC8iw2MUr6Gx8EcKng1dD7i6hg==",
"requires": {
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"micromark-factory-mdx-expression": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/micromark-factory-mdx-expression/-/micromark-factory-mdx-expression-1.0.6.tgz",
"integrity": "sha512-WRQIc78FV7KrCfjsEf/sETopbYjElh3xAmNpLkd1ODPqxEngP42eVRGbiPEQWpRV27LzqW+XVTvQAMIIRLPnNA==",
"requires": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-events-to-acorn": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"unist-util-position-from-estree": "^1.0.0",
"uvu": "^0.5.0",
"vfile-message": "^3.0.0"
}
},
"micromark-factory-space": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-1.0.0.tgz",
"integrity": "sha512-qUmqs4kj9a5yBnk3JMLyjtWYN6Mzfcx8uJfi5XAveBniDevmZasdGBba5b4QsvRcAkmvGo5ACmSUmyGiKTLZew==",
"requires": {
"micromark-util-character": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"micromark-factory-title": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-1.0.2.tgz",
"integrity": "sha512-zily+Nr4yFqgMGRKLpTVsNl5L4PMu485fGFDOQJQBl2NFpjGte1e86zC0da93wf97jrc4+2G2GQudFMHn3IX+A==",
"requires": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"micromark-factory-whitespace": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-1.0.0.tgz",
"integrity": "sha512-Qx7uEyahU1lt1RnsECBiuEbfr9INjQTGa6Err+gF3g0Tx4YEviPbqqGKNv/NrBaE7dVHdn1bVZKM/n5I/Bak7A==",
"requires": {
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"micromark-util-character": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-1.1.0.tgz",
"integrity": "sha512-agJ5B3unGNJ9rJvADMJ5ZiYjBRyDpzKAOk01Kpi1TKhlT1APx3XZk6eN7RtSz1erbWHC2L8T3xLZ81wdtGRZzg==",
"requires": {
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"micromark-util-chunked": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-1.0.0.tgz",
"integrity": "sha512-5e8xTis5tEZKgesfbQMKRCyzvffRRUX+lK/y+DvsMFdabAicPkkZV6gO+FEWi9RfuKKoxxPwNL+dFF0SMImc1g==",
"requires": {
"micromark-util-symbol": "^1.0.0"
}
},
"micromark-util-classify-character": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-1.0.0.tgz",
"integrity": "sha512-F8oW2KKrQRb3vS5ud5HIqBVkCqQi224Nm55o5wYLzY/9PwHGXC01tr3d7+TqHHz6zrKQ72Okwtvm/xQm6OVNZA==",
"requires": {
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"micromark-util-combine-extensions": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-1.0.0.tgz",
"integrity": "sha512-J8H058vFBdo/6+AsjHp2NF7AJ02SZtWaVUjsayNFeAiydTxUwViQPxN0Hf8dp4FmCQi0UUFovFsEyRSUmFH3MA==",
"requires": {
"micromark-util-chunked": "^1.0.0",
"micromark-util-types": "^1.0.0"
}
},
"micromark-util-decode-numeric-character-reference": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-1.0.0.tgz",
"integrity": "sha512-OzO9AI5VUtrTD7KSdagf4MWgHMtET17Ua1fIpXTpuhclCqD8egFWo85GxSGvxgkGS74bEahvtM0WP0HjvV0e4w==",
"requires": {
"micromark-util-symbol": "^1.0.0"
}
},
"micromark-util-decode-string": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-1.0.2.tgz",
"integrity": "sha512-DLT5Ho02qr6QWVNYbRZ3RYOSSWWFuH3tJexd3dgN1odEuPNxCngTCXJum7+ViRAd9BbdxCvMToPOD/IvVhzG6Q==",
"requires": {
"decode-named-character-reference": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-decode-numeric-character-reference": "^1.0.0",
"micromark-util-symbol": "^1.0.0"
}
},
"micromark-util-encode": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-1.0.1.tgz",
"integrity": "sha512-U2s5YdnAYexjKDel31SVMPbfi+eF8y1U4pfiRW/Y8EFVCy/vgxk/2wWTxzcqE71LHtCuCzlBDRU2a5CQ5j+mQA=="
},
"micromark-util-events-to-acorn": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/micromark-util-events-to-acorn/-/micromark-util-events-to-acorn-1.2.0.tgz",
"integrity": "sha512-WWp3bf7xT9MppNuw3yPjpnOxa8cj5ACivEzXJKu0WwnjBYfzaBvIAT9KfeyI0Qkll+bfQtfftSwdgTH6QhTOKw==",
"requires": {
"@types/acorn": "^4.0.0",
"@types/estree": "^1.0.0",
"estree-util-visit": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0",
"vfile-location": "^4.0.0",
"vfile-message": "^3.0.0"
}
},
"micromark-util-html-tag-name": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-1.1.0.tgz",
"integrity": "sha512-BKlClMmYROy9UiV03SwNmckkjn8QHVaWkqoAqzivabvdGcwNGMMMH/5szAnywmsTBUzDsU57/mFi0sp4BQO6dA=="
},
"micromark-util-normalize-identifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-1.0.0.tgz",
"integrity": "sha512-yg+zrL14bBTFrQ7n35CmByWUTFsgst5JhA4gJYoty4Dqzj4Z4Fr/DHekSS5aLfH9bdlfnSvKAWsAgJhIbogyBg==",
"requires": {
"micromark-util-symbol": "^1.0.0"
}
},
"micromark-util-resolve-all": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-1.0.0.tgz",
"integrity": "sha512-CB/AGk98u50k42kvgaMM94wzBqozSzDDaonKU7P7jwQIuH2RU0TeBqGYJz2WY1UdihhjweivStrJ2JdkdEmcfw==",
"requires": {
"micromark-util-types": "^1.0.0"
}
},
"micromark-util-sanitize-uri": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-1.1.0.tgz",
"integrity": "sha512-RoxtuSCX6sUNtxhbmsEFQfWzs8VN7cTctmBPvYivo98xb/kDEoTCtJQX5wyzIYEmk/lvNFTat4hL8oW0KndFpg==",
"requires": {
"micromark-util-character": "^1.0.0",
"micromark-util-encode": "^1.0.0",
"micromark-util-symbol": "^1.0.0"
}
},
"micromark-util-subtokenize": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-1.0.2.tgz",
"integrity": "sha512-d90uqCnXp/cy4G881Ub4psE57Sf8YD0pim9QdjCRNjfas2M1u6Lbt+XZK9gnHL2XFhnozZiEdCa9CNfXSfQ6xA==",
"requires": {
"micromark-util-chunked": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0"
}
},
"micromark-util-symbol": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-1.0.1.tgz",
"integrity": "sha512-oKDEMK2u5qqAptasDAwWDXq0tG9AssVwAx3E9bBF3t/shRIGsWIRG+cGafs2p/SnDSOecnt6hZPCE2o6lHfFmQ=="
},
"micromark-util-types": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-1.0.2.tgz",
"integrity": "sha512-DCfg/T8fcrhrRKTPjRrw/5LLvdGV7BHySf/1LOZx7TzWZdYRjogNtyNq885z3nNallwr3QUKARjqvHqX1/7t+w=="
},
"micromatch": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"requires": {
"braces": "^3.0.2",
"picomatch": "^2.3.1"
}
},
"minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g=="
},
"mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"nanoid": {
"version": "3.3.4",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
"integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw=="
},
"natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="
},
"next": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/next/-/next-13.1.2.tgz",
"integrity": "sha512-Rdnnb2YH///w78FEOR/IQ6TXga+qpth4OqFSem48ng1PYYKr6XBsIk1XVaRcIGM3o6iiHnun0nJvkJHDf+ICyQ==",
"requires": {
"@next/env": "13.1.2",
"@next/swc-android-arm-eabi": "13.1.2",
"@next/swc-android-arm64": "13.1.2",
"@next/swc-darwin-arm64": "13.1.2",
"@next/swc-darwin-x64": "13.1.2",
"@next/swc-freebsd-x64": "13.1.2",
"@next/swc-linux-arm-gnueabihf": "13.1.2",
"@next/swc-linux-arm64-gnu": "13.1.2",
"@next/swc-linux-arm64-musl": "13.1.2",
"@next/swc-linux-x64-gnu": "13.1.2",
"@next/swc-linux-x64-musl": "13.1.2",
"@next/swc-win32-arm64-msvc": "13.1.2",
"@next/swc-win32-ia32-msvc": "13.1.2",
"@next/swc-win32-x64-msvc": "13.1.2",
"@swc/helpers": "0.4.14",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
"styled-jsx": "5.1.1"
}
},
"next-mdx-remote": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/next-mdx-remote/-/next-mdx-remote-4.2.1.tgz",
"integrity": "sha512-PcVF1r5XTBjiNVXw0GyaIcOwQsklHo36+7ycfmtJb52TIkT0nM4Hzv4wgJwNg7+jvTbap99qWsMwdKUYR9WxAA==",
"requires": {
"@mdx-js/mdx": "^2.2.1",
"@mdx-js/react": "^2.2.1",
"vfile": "^5.3.0",
"vfile-matter": "^3.0.1"
}
},
"next-seo": {
"version": "5.15.0",
"resolved": "https://registry.npmjs.org/next-seo/-/next-seo-5.15.0.tgz",
"integrity": "sha512-LGbcY91yDKGMb7YI+28n3g+RuChUkt6pXNpa8FkfKkEmNiJkeRDEXTnnjVtwT9FmMhG6NH8qwHTelGrlYm9rgg==",
"requires": {}
},
"next-themes": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz",
"integrity": "sha512-B+AKNfYNIzh0vqQQKqQItTS8evEouKD7H5Hj3kmuPERwddR2TxvDSFZuTj6T7Jfn1oyeUyJMydPl1Bkxkh0W7A==",
"requires": {}
},
"nextra": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/nextra/-/nextra-2.2.5.tgz",
"integrity": "sha512-sm8mtKxLhfGWNv0yGd9GRL+DPDdVJlyEGn+6zk7gOPQor4X6G1VLcNjGlGYFovS4ZHNrg8oKmhOZSkq79PBrtw==",
"requires": {
"@mdx-js/mdx": "^2.1.5",
"@mdx-js/react": "^2.1.5",
"@napi-rs/simple-git": "^0.1.8",
"github-slugger": "^2.0.0",
"graceful-fs": "^4.2.10",
"gray-matter": "^4.0.3",
"katex": "^0.16.4",
"lodash.get": "^4.4.2",
"next-mdx-remote": "^4.2.0",
"p-limit": "^3.1.0",
"rehype-katex": "^6.0.2",
"rehype-pretty-code": "0.9.2",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"remark-reading-time": "^2.0.1",
"shiki": "^0.12.1",
"slash": "^3.0.0",
"title": "^3.5.3",
"unist-util-visit": "^4.1.1"
}
},
"nextra-theme-docs": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/nextra-theme-docs/-/nextra-theme-docs-2.2.5.tgz",
"integrity": "sha512-dpfOr8O4w3+q2BpBvnOXsmuvDCrrVl9QPrETzN8xKc9z6+oJNt4PEZOHRHo2rADHyV4832sSnWxhERrVzvqfNA==",
"requires": {
"@headlessui/react": "^1.7.7",
"@popperjs/core": "^2.11.6",
"clsx": "^1.2.1",
"flexsearch": "^0.7.21",
"focus-visible": "^5.2.0",
"git-url-parse": "^13.1.0",
"intersection-observer": "^0.12.2",
"match-sorter": "^6.3.1",
"next-seo": "^5.5.0",
"next-themes": "^0.2.1",
"scroll-into-view-if-needed": "^3.0.0",
"zod": "^3.20.2"
}
},
"npm-run-path": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
"integrity": "sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==",
"requires": {
"path-key": "^2.0.0"
},
"dependencies": {
"path-key": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",
"integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw=="
}
}
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="
},
"object-inspect": {
"version": "1.12.3",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g=="
},
"object-is": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz",
"integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3"
}
},
"object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
},
"object.assign": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz",
"integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"has-symbols": "^1.0.3",
"object-keys": "^1.1.1"
}
},
"object.entries": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.6.tgz",
"integrity": "sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
}
},
"object.fromentries": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.6.tgz",
"integrity": "sha512-VciD13dswC4j1Xt5394WR4MzmAQmlgN72phd/riNp9vtD7tp4QQWJ0R4wvclXcafgcYK8veHRed2W6XeGBvcfg==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
}
},
"object.hasown": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.2.tgz",
"integrity": "sha512-B5UIT3J1W+WuWIU55h0mjlwaqxiE5vYENJXIXZ4VFe05pNYrkKuK0U/6aFcb0pKywYJh7IhfoqUfKVmrJJHZHw==",
"requires": {
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
}
},
"object.values": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.6.tgz",
"integrity": "sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"requires": {
"wrappy": "1"
}
},
"open": {
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/open/-/open-8.4.0.tgz",
"integrity": "sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==",
"requires": {
"define-lazy-prop": "^2.0.0",
"is-docker": "^2.1.1",
"is-wsl": "^2.2.0"
}
},
"optionator": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
"integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==",
"requires": {
"deep-is": "^0.1.3",
"fast-levenshtein": "^2.0.6",
"levn": "^0.4.1",
"prelude-ls": "^1.2.1",
"type-check": "^0.4.0",
"word-wrap": "^1.2.3"
}
},
"p-finally": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
"integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow=="
},
"p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
"integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
"requires": {
"yocto-queue": "^0.1.0"
}
},
"p-locate": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
"integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
"requires": {
"p-limit": "^3.0.2"
}
},
"parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"requires": {
"callsites": "^3.0.0"
}
},
"parse-entities": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.0.tgz",
"integrity": "sha512-5nk9Fn03x3rEhGaX1FU6IDwG/k+GxLXlFAkgrbM1asuAFl3BhdQWvASaIsmwWypRNcZKHPYnIuOSfIWEyEQnPQ==",
"requires": {
"@types/unist": "^2.0.0",
"character-entities": "^2.0.0",
"character-entities-legacy": "^3.0.0",
"character-reference-invalid": "^2.0.0",
"decode-named-character-reference": "^1.0.0",
"is-alphanumerical": "^2.0.0",
"is-decimal": "^2.0.0",
"is-hexadecimal": "^2.0.0"
}
},
"parse-numeric-range": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/parse-numeric-range/-/parse-numeric-range-1.3.0.tgz",
"integrity": "sha512-twN+njEipszzlMJd4ONUYgSfZPDxgHhT9Ahed5uTigpQn90FggW4SA/AIPq/6a149fTbE9qBEcSwE3FAEp6wQQ=="
},
"parse-path": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz",
"integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==",
"requires": {
"protocols": "^2.0.0"
}
},
"parse-url": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz",
"integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==",
"requires": {
"parse-path": "^7.0.0"
}
},
"parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
},
"path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg=="
},
"path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="
},
"path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
},
"path-type": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw=="
},
"periscopic": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.0.4.tgz",
"integrity": "sha512-SFx68DxCv0Iyo6APZuw/AKewkkThGwssmU0QWtTlvov3VAtPX+QJ4CadwSaz8nrT5jPIuxdvJWB4PnD2KNDxQg==",
"requires": {
"estree-walker": "^3.0.0",
"is-reference": "^3.0.0"
}
},
"picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
},
"picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="
},
"postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
"integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==",
"requires": {
"nanoid": "^3.3.4",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.2"
}
},
"prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g=="
},
"prop-types": {
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
"requires": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.13.1"
}
},
"property-information": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/property-information/-/property-information-6.2.0.tgz",
"integrity": "sha512-kma4U7AFCTwpqq5twzC1YVIDXSqg6qQK6JN0smOw8fgRy1OkMi0CYSzFmsy6dnqSenamAtj0CyXMUJ1Mf6oROg=="
},
"protocols": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz",
"integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q=="
},
"pseudomap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
"integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ=="
},
"punycode": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.2.0.tgz",
"integrity": "sha512-LN6QV1IJ9ZhxWTNdktaPClrNfp8xdSAYS0Zk2ddX7XsXZAxckMHPCBcHRo0cTcEIgYPRiGEkmji3Idkh2yFtYw=="
},
"queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="
},
"react": {
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
"integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
"requires": {
"loose-envify": "^1.1.0"
}
},
"react-dom": {
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
"integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
"requires": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.0"
}
},
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"reading-time": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/reading-time/-/reading-time-1.5.0.tgz",
"integrity": "sha512-onYyVhBNr4CmAxFsKS7bz+uTLRakypIe4R+5A824vBSkQy/hB3fZepoVEf8OVAxzLvK+H/jm9TzpI3ETSm64Kg=="
},
"regenerator-runtime": {
"version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
},
"regexp.prototype.flags": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz",
"integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"functions-have-names": "^1.2.2"
}
},
"regexpp": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz",
"integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg=="
},
"rehype-katex": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-6.0.2.tgz",
"integrity": "sha512-C4gDAlS1+l0hJqctyiU64f9CvT00S03qV1T6HiMzbSuLBgWUtcqydWHY9OpKrm0SpkK16FNd62CDKyWLwV2ppg==",
"requires": {
"@types/hast": "^2.0.0",
"@types/katex": "^0.11.0",
"hast-util-to-text": "^3.1.0",
"katex": "^0.15.0",
"rehype-parse": "^8.0.0",
"unified": "^10.0.0",
"unist-util-remove-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
},
"dependencies": {
"katex": {
"version": "0.15.6",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.15.6.tgz",
"integrity": "sha512-UpzJy4yrnqnhXvRPhjEuLA4lcPn6eRngixW7Q3TJErjg3Aw2PuLFBzTkdUb89UtumxjhHTqL3a5GDGETMSwgJA==",
"requires": {
"commander": "^8.0.0"
}
}
}
},
"rehype-parse": {
"version": "8.0.4",
"resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-8.0.4.tgz",
"integrity": "sha512-MJJKONunHjoTh4kc3dsM1v3C9kGrrxvA3U8PxZlP2SjH8RNUSrb+lF7Y0KVaUDnGH2QZ5vAn7ulkiajM9ifuqg==",
"requires": {
"@types/hast": "^2.0.0",
"hast-util-from-parse5": "^7.0.0",
"parse5": "^6.0.0",
"unified": "^10.0.0"
}
},
"rehype-pretty-code": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/rehype-pretty-code/-/rehype-pretty-code-0.9.2.tgz",
"integrity": "sha512-l369pvBK6ihBEuy2+VDpHU+zbbY8I+Z4LiyIOunHAt3xyw6selaOFKc/DnX94jI5OJb3+NgjbOxXx2yaAypjZw==",
"requires": {
"hash-obj": "^4.0.0",
"nanoid": "^4.0.0",
"parse-numeric-range": "^1.3.0"
},
"dependencies": {
"nanoid": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.0.tgz",
"integrity": "sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg=="
}
}
},
"remark-gfm": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz",
"integrity": "sha512-lEFDoi2PICJyNrACFOfDD3JlLkuSbOa5Wd8EPt06HUdptv8Gn0bxYTdbU/XXQ3swAPkEaGxxPN9cbnMHvVu1Ig==",
"requires": {
"@types/mdast": "^3.0.0",
"mdast-util-gfm": "^2.0.0",
"micromark-extension-gfm": "^2.0.0",
"unified": "^10.0.0"
}
},
"remark-math": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/remark-math/-/remark-math-5.1.1.tgz",
"integrity": "sha512-cE5T2R/xLVtfFI4cCePtiRn+e6jKMtFDR3P8V3qpv8wpKjwvHoBA4eJzvX+nVrnlNy0911bdGmuspCSwetfYHw==",
"requires": {
"@types/mdast": "^3.0.0",
"mdast-util-math": "^2.0.0",
"micromark-extension-math": "^2.0.0",
"unified": "^10.0.0"
}
},
"remark-mdx": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/remark-mdx/-/remark-mdx-2.2.1.tgz",
"integrity": "sha512-R9wcN+/THRXTKyRBp6Npo/mcbGA2iT3N4G8qUqLA5pOEg7kBidHv8K2hHidCMYZ6DXmwK18umu0K4cicgA2PPQ==",
"requires": {
"mdast-util-mdx": "^2.0.0",
"micromark-extension-mdxjs": "^1.0.0"
}
},
"remark-parse": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-10.0.1.tgz",
"integrity": "sha512-1fUyHr2jLsVOkhbvPRBJ5zTKZZyD6yZzYaWCS6BPBdQ8vEMBCH+9zNCDA6tET/zHCi/jLqjCWtlJZUPk+DbnFw==",
"requires": {
"@types/mdast": "^3.0.0",
"mdast-util-from-markdown": "^1.0.0",
"unified": "^10.0.0"
}
},
"remark-reading-time": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/remark-reading-time/-/remark-reading-time-2.0.1.tgz",
"integrity": "sha512-fy4BKy9SRhtYbEHvp6AItbRTnrhiDGbqLQTSYVbQPGuRCncU1ubSsh9p/W5QZSxtYcUXv8KGL0xBgPLyNJA1xw==",
"requires": {
"estree-util-is-identifier-name": "^2.0.0",
"estree-util-value-to-estree": "^1.3.0",
"reading-time": "^1.3.0",
"unist-util-visit": "^3.1.0"
},
"dependencies": {
"unist-util-visit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz",
"integrity": "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA==",
"requires": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0",
"unist-util-visit-parents": "^4.0.0"
}
},
"unist-util-visit-parents": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz",
"integrity": "sha512-1xAFJXAKpnnJl8G7K5KgU7FY55y3GcLIXqkzUj5QF/QVP7biUm0K0O2oqVkYsdjzJKifYeWn9+o6piAK2hGSHw==",
"requires": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0"
}
}
}
},
"remark-rehype": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-10.1.0.tgz",
"integrity": "sha512-EFmR5zppdBp0WQeDVZ/b66CWJipB2q2VLNFMabzDSGR66Z2fQii83G5gTBbgGEnEEA0QRussvrFHxk1HWGJskw==",
"requires": {
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"mdast-util-to-hast": "^12.1.0",
"unified": "^10.0.0"
}
},
"remove-accents": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/remove-accents/-/remove-accents-0.4.2.tgz",
"integrity": "sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA=="
},
"resolve": {
"version": "1.22.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",
"integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==",
"requires": {
"is-core-module": "^2.9.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
}
},
"resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g=="
},
"reusify": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw=="
},
"rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"requires": {
"glob": "^7.1.3"
}
},
"run-parallel": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
"integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
"requires": {
"queue-microtask": "^1.2.2"
}
},
"sade": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
"integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
"requires": {
"mri": "^1.1.0"
}
},
"safe-regex-test": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz",
"integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==",
"requires": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"is-regex": "^1.1.4"
}
},
"scheduler": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
"integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
"requires": {
"loose-envify": "^1.1.0"
}
},
"scroll-into-view-if-needed": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/scroll-into-view-if-needed/-/scroll-into-view-if-needed-3.0.4.tgz",
"integrity": "sha512-s+/F50jwTOUt+u5oEIAzum9MN2lUQNvWBe/zfEsVQcbaERjGkKLq1s+2wCHkahMLC8nMLbzMVKivx9JhunXaZg==",
"requires": {
"compute-scroll-into-view": "^2.0.4"
}
},
"section-matter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz",
"integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==",
"requires": {
"extend-shallow": "^2.0.1",
"kind-of": "^6.0.0"
}
},
"semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"requires": {
"lru-cache": "^6.0.0"
}
},
"shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"requires": {
"shebang-regex": "^3.0.0"
}
},
"shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="
},
"shiki": {
"version": "0.12.1",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.12.1.tgz",
"integrity": "sha512-aieaV1m349rZINEBkjxh2QbBvFFQOlgqYTNtCal82hHj4dDZ76oMlQIX+C7ryerBTDiga3e5NfH6smjdJ02BbQ==",
"requires": {
"jsonc-parser": "^3.2.0",
"vscode-oniguruma": "^1.7.0",
"vscode-textmate": "^8.0.0"
}
},
"side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
"requires": {
"call-bind": "^1.0.0",
"get-intrinsic": "^1.0.2",
"object-inspect": "^1.9.0"
}
},
"signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="
},
"slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q=="
},
"sort-keys": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-5.0.0.tgz",
"integrity": "sha512-Pdz01AvCAottHTPQGzndktFNdbRA75BgOfeT1hH+AMnJFv8lynkPi42rfeEhpx1saTEI3YNMWxfqu0sFD1G8pw==",
"requires": {
"is-plain-obj": "^4.0.0"
},
"dependencies": {
"is-plain-obj": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
"integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg=="
}
}
},
"source-map": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz",
"integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA=="
},
"source-map-js": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw=="
},
"space-separated-tokens": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz",
"integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="
},
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g=="
},
"stop-iteration-iterator": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz",
"integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==",
"requires": {
"internal-slot": "^1.0.4"
}
},
"string.prototype.matchall": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz",
"integrity": "sha512-6zOCOcJ+RJAQshcTvXPHoxoQGONa3e/Lqx90wUA+wEzX78sg5Bo+1tQo4N0pohS0erG9qtCqJDjNCQBjeWVxyg==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"get-intrinsic": "^1.1.3",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.3",
"regexp.prototype.flags": "^1.4.3",
"side-channel": "^1.0.4"
}
},
"string.prototype.trimend": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz",
"integrity": "sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
}
},
"string.prototype.trimstart": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz",
"integrity": "sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
}
},
"stringify-entities": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.3.tgz",
"integrity": "sha512-BP9nNHMhhfcMbiuQKCqMjhDP5yBCAxsPu4pHFFzJ6Alo9dZgY4VLDPutXqIjpRiMoKdp7Av85Gr73Q5uH9k7+g==",
"requires": {
"character-entities-html4": "^2.0.0",
"character-entities-legacy": "^3.0.0"
}
},
"strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"requires": {
"ansi-regex": "^5.0.1"
}
},
"strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA=="
},
"strip-bom-string": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
"integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g=="
},
"strip-eof": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"integrity": "sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q=="
},
"strip-json-comments": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig=="
},
"style-to-object": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-0.4.1.tgz",
"integrity": "sha512-HFpbb5gr2ypci7Qw+IOhnP2zOU7e77b+rzM+wTzXzfi1PrtBCX0E7Pk4wL4iTLnhzZ+JgEGAhX81ebTg/aYjQw==",
"requires": {
"inline-style-parser": "0.1.1"
}
},
"styled-jsx": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz",
"integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==",
"requires": {
"client-only": "0.0.1"
}
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"requires": {
"has-flag": "^4.0.0"
}
},
"supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="
},
"synckit": {
"version": "0.8.4",
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.4.tgz",
"integrity": "sha512-Dn2ZkzMdSX827QbowGbU/4yjWuvNaCoScLLoMo/yKbu+P4GBR6cRGKZH27k6a9bRzdqcyd1DE96pQtQ6uNkmyw==",
"requires": {
"@pkgr/utils": "^2.3.1",
"tslib": "^2.4.0"
}
},
"tapable": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ=="
},
"text-table": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
"integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw=="
},
"tiny-glob": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
"integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
"requires": {
"globalyzer": "0.1.0",
"globrex": "^0.1.2"
}
},
"title": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/title/-/title-3.5.3.tgz",
"integrity": "sha512-20JyowYglSEeCvZv3EZ0nZ046vLarO37prvV0mbtQV7C8DJPGgN967r8SJkqd3XK3K3lD3/Iyfp3avjfil8Q2Q==",
"requires": {
"arg": "1.0.0",
"chalk": "2.3.0",
"clipboardy": "1.2.2",
"titleize": "1.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"requires": {
"color-convert": "^1.9.0"
}
},
"chalk": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz",
"integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==",
"requires": {
"ansi-styles": "^3.1.0",
"escape-string-regexp": "^1.0.5",
"supports-color": "^4.0.0"
}
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"requires": {
"color-name": "1.1.3"
}
},
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg=="
},
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha512-P+1n3MnwjR/Epg9BBo1KT8qbye2g2Ou4sFumihwt6I4tsUX7jnLcX4BTOSKg/B1ZrIYMN9FcEnG4x5a7NB8Eng=="
},
"supports-color": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz",
"integrity": "sha512-ycQR/UbvI9xIlEdQT1TQqwoXtEldExbCEAJgRo5YXlmSKjv6ThHnP9/vwGa1gr19Gfw+LkFd7KqYMhzrRC5JYw==",
"requires": {
"has-flag": "^2.0.0"
}
}
}
},
"titleize": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/titleize/-/titleize-1.0.0.tgz",
"integrity": "sha512-TARUb7z1pGvlLxgPk++7wJ6aycXF3GJ0sNSBTAsTuJrQG5QuZlkUQP+zl+nbjAh4gMX9yDw9ZYklMd7vAfJKEw=="
},
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"requires": {
"is-number": "^7.0.0"
}
},
"trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",
"integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg=="
},
"trough": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/trough/-/trough-2.1.0.tgz",
"integrity": "sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g=="
},
"tsconfig-paths": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
"integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==",
"requires": {
"@types/json5": "^0.0.29",
"json5": "^1.0.1",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
}
},
"tslib": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
"integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA=="
},
"tsutils": {
"version": "3.21.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
"requires": {
"tslib": "^1.8.1"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}
}
},
"type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
"integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
"requires": {
"prelude-ls": "^1.2.1"
}
},
"type-fest": {
"version": "0.20.2",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ=="
},
"typed-array-length": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz",
"integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==",
"requires": {
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"is-typed-array": "^1.1.9"
}
},
"typescript": {
"version": "4.9.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz",
"integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg=="
},
"unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
"integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==",
"requires": {
"call-bind": "^1.0.2",
"has-bigints": "^1.0.2",
"has-symbols": "^1.0.3",
"which-boxed-primitive": "^1.0.2"
}
},
"unified": {
"version": "10.1.2",
"resolved": "https://registry.npmjs.org/unified/-/unified-10.1.2.tgz",
"integrity": "sha512-pUSWAi/RAnVy1Pif2kAoeWNBa3JVrx0MId2LASj8G+7AiHWoKZNTomq6LG326T68U7/e263X6fTdcXIy7XnF7Q==",
"requires": {
"@types/unist": "^2.0.0",
"bail": "^2.0.0",
"extend": "^3.0.0",
"is-buffer": "^2.0.0",
"is-plain-obj": "^4.0.0",
"trough": "^2.0.0",
"vfile": "^5.0.0"
},
"dependencies": {
"is-plain-obj": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
"integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg=="
}
}
},
"unist-builder": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-3.0.0.tgz",
"integrity": "sha512-GFxmfEAa0vi9i5sd0R2kcrI9ks0r82NasRq5QHh2ysGngrc6GiqD5CDf1FjPenY4vApmFASBIIlk/jj5J5YbmQ==",
"requires": {
"@types/unist": "^2.0.0"
}
},
"unist-util-find-after": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-find-after/-/unist-util-find-after-4.0.0.tgz",
"integrity": "sha512-gfpsxKQde7atVF30n5Gff2fQhAc4/HTOV4CvkXpTg9wRfQhZWdXitpyXHWB6YcYgnsxLx+4gGHeVjCTAAp9sjw==",
"requires": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0"
}
},
"unist-util-generated": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-2.0.0.tgz",
"integrity": "sha512-TiWE6DVtVe7Ye2QxOVW9kqybs6cZexNwTwSMVgkfjEReqy/xwGpAXb99OxktoWwmL+Z+Epb0Dn8/GNDYP1wnUw=="
},
"unist-util-is": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz",
"integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ=="
},
"unist-util-position": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.3.tgz",
"integrity": "sha512-p/5EMGIa1qwbXjA+QgcBXaPWjSnZfQ2Sc3yBEEfgPwsEmJd8Qh+DSk3LGnmOM4S1bY2C0AjmMnB8RuEYxpPwXQ==",
"requires": {
"@types/unist": "^2.0.0"
}
},
"unist-util-position-from-estree": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/unist-util-position-from-estree/-/unist-util-position-from-estree-1.1.1.tgz",
"integrity": "sha512-xtoY50b5+7IH8tFbkw64gisG9tMSpxDjhX9TmaJJae/XuxQ9R/Kc8Nv1eOsf43Gt4KV/LkriMy9mptDr7XLcaw==",
"requires": {
"@types/unist": "^2.0.0"
}
},
"unist-util-remove-position": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-4.0.1.tgz",
"integrity": "sha512-0yDkppiIhDlPrfHELgB+NLQD5mfjup3a8UYclHruTJWmY74je8g+CIFr79x5f6AkmzSwlvKLbs63hC0meOMowQ==",
"requires": {
"@types/unist": "^2.0.0",
"unist-util-visit": "^4.0.0"
}
},
"unist-util-stringify-position": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.2.tgz",
"integrity": "sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==",
"requires": {
"@types/unist": "^2.0.0"
}
},
"unist-util-visit": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.1.1.tgz",
"integrity": "sha512-n9KN3WV9k4h1DxYR1LoajgN93wpEi/7ZplVe02IoB4gH5ctI1AaF2670BLHQYbwj+pY83gFtyeySFiyMHJklrg==",
"requires": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0",
"unist-util-visit-parents": "^5.1.1"
}
},
"unist-util-visit-parents": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.1.1.tgz",
"integrity": "sha512-gks4baapT/kNRaWxuGkl5BIhoanZo7sC/cUT/JToSRNL1dYoXRFl75d++NkjYk4TAu2uv2Px+l8guMajogeuiw==",
"requires": {
"@types/unist": "^2.0.0",
"unist-util-is": "^5.0.0"
}
},
"uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
"requires": {
"punycode": "^2.1.0"
}
},
"uvu": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/uvu/-/uvu-0.5.6.tgz",
"integrity": "sha512-+g8ENReyr8YsOc6fv/NVJs2vFdHBnBNdfE49rshrTzDWOlUx4Gq7KOS2GD8eqhy2j+Ejq29+SbKH8yjkAqXqoA==",
"requires": {
"dequal": "^2.0.0",
"diff": "^5.0.0",
"kleur": "^4.0.3",
"sade": "^1.7.3"
}
},
"vfile": {
"version": "5.3.6",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.6.tgz",
"integrity": "sha512-ADBsmerdGBs2WYckrLBEmuETSPyTD4TuLxTrw0DvjirxW1ra4ZwkbzG8ndsv3Q57smvHxo677MHaQrY9yxH8cA==",
"requires": {
"@types/unist": "^2.0.0",
"is-buffer": "^2.0.0",
"unist-util-stringify-position": "^3.0.0",
"vfile-message": "^3.0.0"
}
},
"vfile-location": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz",
"integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==",
"requires": {
"@types/unist": "^2.0.0",
"vfile": "^5.0.0"
}
},
"vfile-matter": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/vfile-matter/-/vfile-matter-3.0.1.tgz",
"integrity": "sha512-CAAIDwnh6ZdtrqAuxdElUqQRQDQgbbIrYtDYI8gCjXS1qQ+1XdLoK8FIZWxJwn0/I+BkSSZpar3SOgjemQz4fg==",
"requires": {
"@types/js-yaml": "^4.0.0",
"is-buffer": "^2.0.0",
"js-yaml": "^4.0.0"
}
},
"vfile-message": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.3.tgz",
"integrity": "sha512-0yaU+rj2gKAyEk12ffdSbBfjnnj+b1zqTBv3OQCTn8yEB02bsPizwdBPrLJjHnK+cU9EMMcUnNv938XcZIkmdA==",
"requires": {
"@types/unist": "^2.0.0",
"unist-util-stringify-position": "^3.0.0"
}
},
"vscode-oniguruma": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz",
"integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA=="
},
"vscode-textmate": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz",
"integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg=="
},
"web-namespaces": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",
"integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ=="
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"requires": {
"isexe": "^2.0.0"
}
},
"which-boxed-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz",
"integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==",
"requires": {
"is-bigint": "^1.0.1",
"is-boolean-object": "^1.1.0",
"is-number-object": "^1.0.4",
"is-string": "^1.0.5",
"is-symbol": "^1.0.3"
}
},
"which-collection": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz",
"integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==",
"requires": {
"is-map": "^2.0.1",
"is-set": "^2.0.1",
"is-weakmap": "^2.0.1",
"is-weakset": "^2.0.1"
}
},
"which-typed-array": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz",
"integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==",
"requires": {
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"gopd": "^1.0.1",
"has-tostringtag": "^1.0.0",
"is-typed-array": "^1.1.10"
}
},
"word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ=="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
},
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
},
"yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="
},
"zod": {
"version": "3.20.2",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.20.2.tgz",
"integrity": "sha512-1MzNQdAvO+54H+EaK5YpyEy0T+Ejo/7YLHS93G3RnYWh5gaotGHwGeN/ZO687qEDU2y4CdStQYXVHIgrUl5UVQ=="
},
"zwitch": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
"integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="
}
}
}
|
0 | repos/libxev | repos/libxev/website/tsconfig.json | {
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
|
0 | repos/libxev | repos/libxev/website/theme.config.jsx | import { useRouter } from 'next/router'
export default {
logo: <span>libxev</span>,
docsRepositoryBase: 'https://github.com/mitchellh/libxev/blob/website/pages',
project: {
link: 'https://github.com/mitchellh/libxev',
},
feedback: {
content: null,
},
footer: {
text: <span>
Β© {new Date().getFullYear()}
<a href="https://github.com/mitchellh/libxev" target="_blank">libxev</a>
</span>,
},
useNextSeoProps() {
const { route } = useRouter()
if (route !== '/') {
return {
titleTemplate: '%s β libxev'
}
}
},
// Hide the last updated date.
gitTimestamp: <span></span>,
}
|
0 | repos/libxev/website | repos/libxev/website/pages/getting-started.mdx | # Getting Started
TODO
|
0 | repos/libxev/website | repos/libxev/website/pages/_document.tsx | import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
|
0 | repos/libxev/website | repos/libxev/website/pages/_meta.json | {
"index": "Home",
"getting-started": "Getting Started",
"api-docs": "API"
}
|
0 | repos/libxev/website | repos/libxev/website/pages/index.mdx | # libxev
import { Callout } from 'nextra-theme-docs'
TODO! See the GitHub repo for now.
<Callout type="info">
**Coming soon.** I've just got some scaffolding down.
</Callout>
|
0 | repos/libxev/website | repos/libxev/website/pages/_app.tsx | import '@/styles/globals.css'
import type { AppProps } from 'next/app'
export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
|
0 | repos/libxev/website/pages | repos/libxev/website/pages/api-docs/concepts.mdx | # General API Concepts
|
0 | repos/libxev/website/pages | repos/libxev/website/pages/api-docs/_meta.json | {
"concepts": "Concepts"
}
|
0 | repos/libxev/website/pages | repos/libxev/website/pages/getting-started/concepts.mdx | # General Concepts
TODO
|
0 | repos/libxev/website/pages | repos/libxev/website/pages/getting-started/_meta.json | {
"concepts": "Concepts"
}
|
0 | repos/libxev/website/pages | repos/libxev/website/pages/api/hello.ts | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'
type Data = {
name: string
}
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
res.status(200).json({ name: 'John Doe' })
}
|
0 | repos/libxev/website | repos/libxev/website/styles/Home.module.css | .main {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
padding: 6rem;
min-height: 100vh;
}
.description {
display: inherit;
justify-content: inherit;
align-items: inherit;
font-size: 0.85rem;
max-width: var(--max-width);
width: 100%;
z-index: 2;
font-family: var(--font-mono);
}
.description a {
display: flex;
justify-content: center;
align-items: center;
gap: 0.5rem;
}
.description p {
position: relative;
margin: 0;
padding: 1rem;
background-color: rgba(var(--callout-rgb), 0.5);
border: 1px solid rgba(var(--callout-border-rgb), 0.3);
border-radius: var(--border-radius);
}
.code {
font-weight: 700;
font-family: var(--font-mono);
}
.grid {
display: grid;
grid-template-columns: repeat(4, minmax(25%, auto));
width: var(--max-width);
max-width: 100%;
}
.card {
padding: 1rem 1.2rem;
border-radius: var(--border-radius);
background: rgba(var(--card-rgb), 0);
border: 1px solid rgba(var(--card-border-rgb), 0);
transition: background 200ms, border 200ms;
}
.card span {
display: inline-block;
transition: transform 200ms;
}
.card h2 {
font-weight: 600;
margin-bottom: 0.7rem;
}
.card p {
margin: 0;
opacity: 0.6;
font-size: 0.9rem;
line-height: 1.5;
max-width: 30ch;
}
.center {
display: flex;
justify-content: center;
align-items: center;
position: relative;
padding: 4rem 0;
}
.center::before {
background: var(--secondary-glow);
border-radius: 50%;
width: 480px;
height: 360px;
margin-left: -400px;
}
.center::after {
background: var(--primary-glow);
width: 240px;
height: 180px;
z-index: -1;
}
.center::before,
.center::after {
content: '';
left: 50%;
position: absolute;
filter: blur(45px);
transform: translateZ(0);
}
.logo,
.thirteen {
position: relative;
}
.thirteen {
display: flex;
justify-content: center;
align-items: center;
width: 75px;
height: 75px;
padding: 25px 10px;
margin-left: 16px;
transform: translateZ(0);
border-radius: var(--border-radius);
overflow: hidden;
box-shadow: 0px 2px 8px -1px #0000001a;
}
.thirteen::before,
.thirteen::after {
content: '';
position: absolute;
z-index: -1;
}
/* Conic Gradient Animation */
.thirteen::before {
animation: 6s rotate linear infinite;
width: 200%;
height: 200%;
background: var(--tile-border);
}
/* Inner Square */
.thirteen::after {
inset: 0;
padding: 1px;
border-radius: var(--border-radius);
background: linear-gradient(
to bottom right,
rgba(var(--tile-start-rgb), 1),
rgba(var(--tile-end-rgb), 1)
);
background-clip: content-box;
}
/* Enable hover only on non-touch devices */
@media (hover: hover) and (pointer: fine) {
.card:hover {
background: rgba(var(--card-rgb), 0.1);
border: 1px solid rgba(var(--card-border-rgb), 0.15);
}
.card:hover span {
transform: translateX(4px);
}
}
@media (prefers-reduced-motion) {
.thirteen::before {
animation: none;
}
.card:hover span {
transform: none;
}
}
/* Mobile */
@media (max-width: 700px) {
.content {
padding: 4rem;
}
.grid {
grid-template-columns: 1fr;
margin-bottom: 120px;
max-width: 320px;
text-align: center;
}
.card {
padding: 1rem 2.5rem;
}
.card h2 {
margin-bottom: 0.5rem;
}
.center {
padding: 8rem 0 6rem;
}
.center::before {
transform: none;
height: 300px;
}
.description {
font-size: 0.8rem;
}
.description a {
padding: 1rem;
}
.description p,
.description div {
display: flex;
justify-content: center;
position: fixed;
width: 100%;
}
.description p {
align-items: center;
inset: 0 0 auto;
padding: 2rem 1rem 1.4rem;
border-radius: 0;
border: none;
border-bottom: 1px solid rgba(var(--callout-border-rgb), 0.25);
background: linear-gradient(
to bottom,
rgba(var(--background-start-rgb), 1),
rgba(var(--callout-rgb), 0.5)
);
background-clip: padding-box;
backdrop-filter: blur(24px);
}
.description div {
align-items: flex-end;
pointer-events: none;
inset: auto 0 0;
padding: 2rem;
height: 200px;
background: linear-gradient(
to bottom,
transparent 0%,
rgb(var(--background-end-rgb)) 40%
);
z-index: 1;
}
}
/* Tablet and Smaller Desktop */
@media (min-width: 701px) and (max-width: 1120px) {
.grid {
grid-template-columns: repeat(2, 50%);
}
}
@media (prefers-color-scheme: dark) {
.vercelLogo {
filter: invert(1);
}
.logo,
.thirteen img {
filter: invert(1) drop-shadow(0 0 0.3rem #ffffff70);
}
}
@keyframes rotate {
from {
transform: rotate(360deg);
}
to {
transform: rotate(0deg);
}
}
|
0 | repos/libxev/website | repos/libxev/website/styles/globals.css | :root {
--max-width: 1100px;
--border-radius: 12px;
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro',
'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
--primary-glow: conic-gradient(
from 180deg at 50% 50%,
#16abff33 0deg,
#0885ff33 55deg,
#54d6ff33 120deg,
#0071ff33 160deg,
transparent 360deg
);
--secondary-glow: radial-gradient(
rgba(255, 255, 255, 1),
rgba(255, 255, 255, 0)
);
--tile-start-rgb: 239, 245, 249;
--tile-end-rgb: 228, 232, 233;
--tile-border: conic-gradient(
#00000080,
#00000040,
#00000030,
#00000020,
#00000010,
#00000010,
#00000080
);
--callout-rgb: 238, 240, 241;
--callout-border-rgb: 172, 175, 176;
--card-rgb: 180, 185, 188;
--card-border-rgb: 131, 134, 135;
}
@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
--primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0));
--secondary-glow: linear-gradient(
to bottom right,
rgba(1, 65, 255, 0),
rgba(1, 65, 255, 0),
rgba(1, 65, 255, 0.3)
);
--tile-start-rgb: 2, 13, 46;
--tile-end-rgb: 2, 5, 19;
--tile-border: conic-gradient(
#ffffff80,
#ffffff40,
#ffffff30,
#ffffff20,
#ffffff10,
#ffffff10,
#ffffff80
);
--callout-rgb: 20, 20, 20;
--callout-border-rgb: 108, 108, 108;
--card-rgb: 100, 100, 100;
--card-border-rgb: 200, 200, 200;
}
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,
body {
max-width: 100vw;
overflow-x: hidden;
}
body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}
a {
color: inherit;
text-decoration: none;
}
@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}
}
|
0 | repos | repos/zig-3d-soft-engine/README.md | # 3D Soft engine written in zig
This is a first attempt by a person with no experience in
creating a 3D engine. So take everything you see with a
huge grain of salt. But if you have suggestions feel free to
raise an issue, provide a PR or contact me.
The engine is based on David Rousset's [tutorial](https://www.davrous.com/2013/06/13/tutorial-series-learning-how-to-write-a-3d-soft-engine-from-scratch-in-c-typescript-or-javascript/).
Plus math3d from Andrew Kelly's [Tetris](https://github.com/andrewrk/tetris) with additions based on [SharpDx](https://github.com/sharpdx/SharpDX).
Also the backend for creating Windows and displaying bitmaps uses Marc Tiehuis's [sdl2](https://github.com/tiehuis/zig-sdl2)
and the scribling code is based on Daniel D'Agostino [SDL2 Pixel Drawing tutorial](https://dzone.com/articles/sdl2-pixel-drawing)
and the code is [here](https://bitbucket.org/dandago/gigilabs/src/6d0e98732ca84d7d2b6cc9099faa9f4ec548e103/Sdl2PixelDrawing/Sdl2PixelDrawing/main.cpp?at=master&fileviewer=file-view-default).
## Dependencies
Needs zig PR 1820: https://github.com/ziglang/zig/pull/1820 so `fn saturateCast` in zig-misc works
* [Git Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
* [zig](https://ziglang.org/)
* [SDL2](https://www.libsdl.org/)
* [zig-sdl2](https://github.com/tiehuis/zig-sdl2) brought in as a submode and created by Marc TieHuis.
## Checkout
```
git clone --recurse-submodules https://github.com/winksaville/zig-3d-soft-engine
```
## Build
```
zig build
```
## Test individual components
```
zig test --test-filter "camera" src/camera.zig
zig test --test-filter "mesh" src/mesh.zig
zig test --test-filter "inputEvents" src/input_events.zig
zig test --test-filter "math3d" src/math3d.zig
zig test --test-filter "window" --library c --library SDL2 src/window.zig
```
## Run
```
./3d-soft-engine
```
|
0 | repos | repos/zig-3d-soft-engine/build.zig | const Builder = @import("std").build.Builder;
const builtin = @import("builtin");
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const windows = b.option(bool, "windows", "create windows build") orelse false;
var exe = b.addExecutable("3d-soft-engine", "src/main.zig");
exe.setBuildMode(mode);
if (windows) {
exe.setTarget(builtin.Arch.x86_64, builtin.Os.windows, builtin.Abi.gnu);
}
exe.linkSystemLibrary("c");
exe.linkSystemLibrary("SDL2");
exe.setOutputPath("./3d-soft-engine");
b.default_step.dependOn(&exe.step);
b.installArtifact(exe);
}
|
0 | repos/zig-3d-soft-engine | repos/zig-3d-soft-engine/src/keyboard_input.zig | const std = @import("std");
const warn = std.debug.warn;
const gl = @import("modules/zig-sdl2/src/index.zig");
const ie = @import("input_events.zig");
pub const KeyState = struct {
new_key: bool,
code: gl.SDL_Keycode,
mod: u16,
ei: ie.EventInterface,
};
var g_ks = KeyState{
.new_key = false,
.code = undefined,
.mod = undefined,
.ei = ie.EventInterface{
.event = undefined,
.handleKeyEvent = handleKeyEvent,
.handleMouseEvent = ignoreEvent,
.handleOtherEvent = ignoreEvent,
},
};
fn handleKeyEvent(pThing: *c_void, event: *gl.SDL_Event) ie.EventResult {
var pKey_state = @intToPtr(*KeyState, @ptrToInt(pThing));
switch (event.type) {
gl.SDL_KEYUP => {
pKey_state.*.new_key = true;
pKey_state.*.code = event.key.keysym.sym;
pKey_state.*.mod = event.key.keysym.mod;
},
else => {},
}
return ie.EventResult.Continue;
}
fn ignoreEvent(pThing: *c_void, event: *gl.SDL_Event) ie.EventResult {
return ie.EventResult.Continue;
}
/// Wait for a key
pub fn waitForKey(s: []const u8, exitOnEscape: bool, debug: bool) *KeyState {
if (debug) warn("{}, waiting for key: ...", s);
g_ks.new_key = false;
while (g_ks.new_key == false) {
_ = ie.pollInputEvent(&g_ks, &g_ks.ei);
}
if (debug) warn(" g_ks.mod={} g_ks.code={}\n", g_ks.mod, g_ks.code);
if (g_ks.code == gl.SDLK_ESCAPE) if (exitOnEscape) std.os.exit(1);
return &g_ks;
}
/// Wait for Esc key
pub fn waitForEsc(s: []const u8) void {
done: while (true) {
// Wait for a key
var ks = waitForKey(s, false, true);
// Stop if ESCAPE
switch (ks.code) {
gl.SDLK_ESCAPE => break :done,
else => {},
}
}
}
|
0 | repos/zig-3d-soft-engine | repos/zig-3d-soft-engine/src/color.zig | const builtin = @import("builtin");
const TypeId = builtin.TypeId;
const std = @import("std");
const math = std.math;
const assert = std.debug.assert;
const warn = std.debug.warn;
const misc = @import("modules/zig-misc/index.zig");
const saturateCast = misc.saturateCast;
const DBG = false;
pub const ColorU8 = Color(u8, u8, u8, u8);
pub fn Color(comptime A: type, comptime R: type, comptime G: type, comptime B: type) type {
return struct {
const Self = @This();
pub const Black = Self{ .a = misc.maxValue(A), .r = misc.minValue(R), .g = misc.minValue(G), .b = misc.minValue(B) };
pub const White = Self{ .a = misc.maxValue(A), .r = misc.maxValue(R), .g = misc.maxValue(G), .b = misc.maxValue(B) };
pub const Red = Self{ .a = misc.maxValue(A), .r = misc.maxValue(R), .g = misc.minValue(G), .b = misc.minValue(B) };
pub const Green = Self{ .a = misc.maxValue(A), .r = misc.minValue(R), .g = misc.maxValue(G), .b = misc.minValue(B) };
pub const Blue = Self{ .a = misc.maxValue(A), .r = misc.minValue(R), .g = misc.minValue(G), .b = misc.maxValue(B) };
a: A,
r: R,
g: G,
b: B,
pub fn init(a: A, r: R, g: G, b: B) Self {
return Self{
.a = saturateCast(A, a),
.r = saturateCast(R, r),
.g = saturateCast(G, g),
.b = saturateCast(B, b),
};
}
/// Return color as a a:r:g:b u32
pub fn asU32Argb(pSelf: *const Self) u32 {
var a = @intCast(u32, saturateCast(u8, pSelf.a));
var r = @intCast(u32, saturateCast(u8, pSelf.r));
var g = @intCast(u32, saturateCast(u8, pSelf.g));
var b = @intCast(u32, saturateCast(u8, pSelf.b));
return (a << 24) | (r << 16) | (g << 8) | (b << 0);
}
/// Scale each of the rgb components by other
pub fn colorScale(color: Self, other: f32) Self {
var a: A = color.a;
var r: R = saturateCast(R, math.round(saturateCast(f32, (color.r)) * other));
var g: G = saturateCast(G, math.round(saturateCast(f32, (color.g)) * other));
var b: B = saturateCast(B, math.round(saturateCast(f32, (color.b)) * other));
var result = Self{
.a = a,
.r = r,
.g = g,
.b = b,
};
return result;
}
/// Custom format routine
pub fn format(
pSelf: *const Self,
comptime fmt: []const u8,
context: var,
comptime FmtError: type,
output: fn (@typeOf(context), []const u8) FmtError!void,
) FmtError!void {
try std.fmt.format(context, FmtError, output, "{{ ");
try formatOneColor(A, pSelf.a, fmt, context, FmtError, output, false);
try formatOneColor(R, pSelf.r, fmt, context, FmtError, output, false);
try formatOneColor(G, pSelf.g, fmt, context, FmtError, output, false);
try formatOneColor(B, pSelf.b, fmt, context, FmtError, output, true);
try std.fmt.format(context, FmtError, output, "}}");
}
};
}
fn formatOneColor(
comptime T: type,
color: T,
comptime fmt: []const u8,
context: var,
comptime FmtError: type,
output: fn (@typeOf(context), []const u8) FmtError!void,
last: bool,
) FmtError!void {
switch (@typeId(T)) {
TypeId.Float => try std.fmt.format(context, FmtError, output, "{}{.3}{}", if (math.signbit(color)) "-" else " ", if (math.signbit(color)) -color else color, if (!last) ", " else " "),
TypeId.Int => try std.fmt.format(context, FmtError, output, "{d6}{}", color, if (!last) ", " else " "),
else => @compileError("Expected Float or Int type"),
}
}
test "Color" {
warn("\n");
var cu8 = ColorU8.White;
assert(cu8.a == 0xFF);
assert(cu8.r == 0xFF);
assert(cu8.g == 0xFF);
assert(cu8.b == 0xFF);
assert(cu8.asU32Argb() == 0xFFFFFFFF);
cu8 = ColorU8.Black;
assert(cu8.a == 0xFF);
assert(cu8.r == 0x00);
assert(cu8.g == 0x00);
assert(cu8.b == 0x00);
assert(cu8.asU32Argb() == 0xFF000000);
cu8 = ColorU8.Red;
assert(cu8.a == 0xFF);
assert(cu8.r == 0xFF);
assert(cu8.g == 0x00);
assert(cu8.b == 0x00);
assert(cu8.asU32Argb() == 0xFFFF0000);
cu8 = ColorU8.Green;
assert(cu8.a == 0xFF);
assert(cu8.r == 0x00);
assert(cu8.g == 0xFF);
assert(cu8.b == 0x00);
assert(cu8.asU32Argb() == 0xFF00FF00);
cu8 = ColorU8.Blue;
assert(cu8.a == 0xFF);
assert(cu8.r == 0x00);
assert(cu8.g == 0x00);
assert(cu8.b == 0xFF);
assert(cu8.asU32Argb() == 0xFF0000FF);
var c = Color(f32, f32, f32, f32).init(1, 2, 3, 4);
assert(c.a == f32(1));
assert(c.r == f32(2));
assert(c.g == f32(3));
assert(c.b == f32(4));
assert(c.asU32Argb() == 0x01020304);
warn("c={}:{x8}\n", &c, c.asU32Argb());
var d = Color(u2, i10, i10, i10).init(3, -3, -2, 2);
assert(d.a == u2(3));
assert(d.r == i10(-3));
assert(d.g == i10(-2));
assert(d.b == i10(2));
// This is probably wrong, we should unbias the result!
assert(d.asU32Argb() == 0x03000002);
warn("d={}:{x8}\n", &d, d.asU32Argb());
var u = Color(u2, u10, u10, u10).init(0, 3, 2, 1);
assert(u.a == u2(0));
assert(u.r == u10(3));
assert(u.g == u10(2));
assert(u.b == u10(1));
assert(u.asU32Argb() == 0x00030201);
warn("u={}:{x8}\n", &u, u.asU32Argb());
}
|
0 | repos/zig-3d-soft-engine | repos/zig-3d-soft-engine/src/create_mesh_from_babylon_json.zig | const std = @import("std");
const assert = std.debug.assert;
const warn = std.debug.warn;
const Allocator = std.mem.Allocator;
const geo = @import("modules/zig-geometry/index.zig");
const json = @import("modules/zig-json/json.zig");
const parseJsonFile = @import("modules/zig-json/parse_json_file.zig").parseJsonFile;
const DBG = false;
const DBG1 = false;
pub fn createMeshFromBabylonJson(pAllocator: *Allocator, name: []const u8, tree: json.ValueTree) !geo.Mesh {
var root = tree.root;
var meshes = root.Object.get("meshes").?.value.Array;
var positions = meshes.items[0].Object.get("positions").?.value.Array;
if (DBG) warn("positions.len={}\n", positions.len);
var normals = meshes.items[0].Object.get("normals").?.value.Array;
if (DBG) warn("normals.len={}\n", normals.len);
// If uvs isn't available then an empyt list
var uvs = if (meshes.items[0].Object.get("uvs")) |pUvs| pUvs.value.Array else std.ArrayList(json.Value).init(pAllocator);
if (DBG) warn("uvs.len={}\n", uvs.len);
var indices = meshes.items[0].Object.get("indices").?.value.Array;
if (DBG) warn("indices.len={}\n", indices.len);
var vertices_count = positions.len / 3;
var faces_count = indices.len / 3;
if (DBG) warn("vertices_count={} faces_count={}\n", vertices_count, faces_count);
var mesh = try geo.Mesh.init(pAllocator, name, vertices_count, faces_count);
var i: usize = 0;
var pos_iter = positions.iterator();
var nrml_iter = normals.iterator();
var uvs_iter = uvs.iterator();
while (i < vertices_count) : (i += 1) {
var x = try pos_iter.next().?.asFloat(f32);
var y = try pos_iter.next().?.asFloat(f32);
var z = try pos_iter.next().?.asFloat(f32);
var nx = try nrml_iter.next().?.asFloat(f32);
var ny = try nrml_iter.next().?.asFloat(f32);
var nz = try nrml_iter.next().?.asFloat(f32);
// Len of uvs maybe zero
var u: f32 = if (uvs_iter.next()) |nu| try nu.asFloat(f32) else 0.0;
var v: f32 = if (uvs_iter.next()) |nv| try nv.asFloat(f32) else 0.0;
mesh.vertices[i] = geo.Vertex{
.coord = geo.V3f32.init(x, y, z),
.world_coord = geo.V3f32.init(0, 0, 0),
.normal_coord = geo.V3f32.init(nx, ny, nz),
.texture_coord = geo.V2f32.init(u, v),
};
}
i = 0;
var indicies_iter = indices.iterator();
while (i < faces_count) : (i += 1) {
// Get the indexes for a,b,c
var a = @intCast(usize, indicies_iter.next().?.Integer);
var b = @intCast(usize, indicies_iter.next().?.Integer);
var c = @intCast(usize, indicies_iter.next().?.Integer);
var normal = geo.computeFaceNormal(mesh.vertices, a, b, c);
mesh.faces[i] = geo.Face{ .a = a, .b = b, .c = c, .normal = normal };
if (DBG1) warn("face[{}]={{ .a={} .b={} .c={} .normal={} }}\n", i, mesh.faces[i].a, mesh.faces[i].b, mesh.faces[i].c, mesh.faces[i].normal);
}
return mesh;
}
test "create_mesh_from_babylon_json.cube" {
var file_name = "src/modules/3d-test-resources/cube.babylon";
var pAllocator = std.heap.c_allocator;
var tree = try parseJsonFile(pAllocator, file_name);
defer tree.deinit();
var mesh = try createMeshFromBabylonJson(pAllocator, "cube", tree);
if (DBG) warn("mesh.vertices.len={} faces.len={}\n", mesh.vertices.len, mesh.faces.len);
assert(mesh.vertices.len == 8);
assert(mesh.faces.len == 12);
}
test "create_mesh_from_babylon_json.suzanne" {
var file_name = "src/modules/3d-test-resources/suzanne.babylon";
var pAllocator = std.heap.c_allocator;
var tree = try parseJsonFile(pAllocator, file_name);
defer tree.deinit();
var mesh = try createMeshFromBabylonJson(pAllocator, "suzanne", tree);
if (DBG) warn("mesh.vertices.len={} faces.len={}\n", mesh.vertices.len, mesh.faces.len);
assert(mesh.vertices.len == 507);
assert(mesh.faces.len == 968);
}
|
0 | repos/zig-3d-soft-engine | repos/zig-3d-soft-engine/src/camera.zig | const std = @import("std");
const assert = std.debug.assert;
const warn = std.debug.warn;
const math = std.math;
const geo = @import("modules/zig-geometry/index.zig");
pub const Camera = struct {
const Self = @This();
pub position: geo.V3f32,
pub target: geo.V3f32,
pub fn init(position: geo.V3f32, target: geo.V3f32) Self {
return Self{
.position = position,
.target = target,
};
}
};
test "camera" {
var camera = Camera.init(geo.V3f32.init(0.1, 0.2, 0.3), geo.V3f32.init(0.4, 0.5, 0.6));
assert(camera.position.data[0] == 0.1);
assert(camera.position.data[1] == 0.2);
assert(camera.position.data[2] == 0.3);
assert(camera.target.data[0] == 0.4);
assert(camera.target.data[1] == 0.5);
assert(camera.target.data[2] == 0.6);
}
|
0 | repos/zig-3d-soft-engine | repos/zig-3d-soft-engine/src/main.zig | const builtin = @import("builtin");
const std = @import("std");
const mem = std.mem;
const Allocator = mem.Allocator;
const assert = std.debug.assert;
const warn = std.debug.warn;
const gl = @import("modules/zig-sdl2/src/index.zig");
const ie = @import("input_events.zig");
const wdw = @import("window.zig");
const WindowState = struct {
window: wdw.Window,
quit: bool,
leftMouseButtonDown: bool,
ei: ie.EventInterface,
bg_color: u32,
fg_color: u32,
width: usize,
height: usize,
};
fn handleKeyEvent(pThing: *c_void, event: *gl.SDL_Event) ie.EventResult {
var pWs = @intToPtr(*WindowState, @ptrToInt(pThing));
switch (event.type) {
gl.SDL_KEYUP => {
if (event.key.keysym.sym == gl.SDLK_ESCAPE) {
pWs.quit = true;
return ie.EventResult.Quit;
}
},
else => {},
}
return ie.EventResult.Continue;
}
fn handleMouseEvent(pThing: *c_void, event: *gl.SDL_Event) ie.EventResult {
var pWs = @intToPtr(*WindowState, @ptrToInt(pThing));
switch (event.type) {
gl.SDL_MOUSEBUTTONUP => {
assert(gl.SDL_BUTTON_LMASK == 1);
if (event.button.button == gl.SDL_BUTTON_LEFT) {
pWs.leftMouseButtonDown = false;
}
},
gl.SDL_MOUSEBUTTONDOWN => {
if (event.button.button == gl.SDL_BUTTON_LEFT) {
pWs.leftMouseButtonDown = true;
}
},
gl.SDL_MOUSEMOTION => {
if (pWs.leftMouseButtonDown) {
var mouse_x: usize = @intCast(usize, event.motion.x);
var mouse_y: usize = @intCast(usize, event.motion.y);
pWs.window.putPixel(mouse_x, mouse_y, pWs.fg_color);
}
},
else => {},
}
return ie.EventResult.Continue;
}
fn handleOtherEvent(pThing: *c_void, event: *gl.SDL_Event) ie.EventResult {
return ie.EventResult.Continue;
}
pub fn main() u8 {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var ws = WindowState{
.window = undefined,
.quit = false,
.leftMouseButtonDown = false,
.ei = ie.EventInterface{
.event = undefined,
.handleKeyEvent = handleKeyEvent,
.handleMouseEvent = handleMouseEvent,
.handleOtherEvent = handleOtherEvent,
},
.bg_color = 0x00000000, // black
.fg_color = 0xffffffff, // white
.width = 640,
.height = 480,
};
ws.window = wdw.Window.init(pAllocator, ws.width, ws.height, "zig-3d-soft-engine") catch |e| {
warn("Could not init window: {}\n", e);
return 1;
};
defer ws.window.deinit();
while (!ws.quit) {
// Process all events
noEvents: while (true) {
switch (ie.pollInputEvent(&ws, &ws.ei)) {
ie.EventResult.NoEvents => {
break :noEvents;
},
ie.EventResult.Quit => {
ws.quit = true;
break :noEvents;
},
ie.EventResult.Continue => {},
}
}
// Update display
ws.window.present();
}
return 0;
}
|
0 | repos/zig-3d-soft-engine | repos/zig-3d-soft-engine/src/texture.zig | const std = @import("std");
const assert = std.debug.assert;
const warn = std.debug.warn;
const math = std.math;
const Allocator = std.mem.Allocator;
const geo = @import("modules/zig-geometry/index.zig");
const gl = @import("modules/zig-sdl2/src/index.zig");
const ColorU8 = @import("../src/color.zig").ColorU8;
const DBG = false;
pub const Texture = struct {
const Self = @This();
pAllocator: *Allocator,
pub width: usize,
pub height: usize,
pub pixels: ?[]ColorU8,
pub pixels_owned: bool,
pub fn init(pAllocator: *Allocator) Self {
return Self{
.pAllocator = pAllocator,
.width = 0,
.height = 0,
.pixels = null,
.pixels_owned = false,
};
}
pub fn initPixels(pAllocator: *Allocator, width: usize, height: usize, color: ColorU8) anyerror!Self {
var count: usize = width * height;
var pixels = try pAllocator.alloc(ColorU8, count);
var i: usize = 0;
while (i < count) : (i += 1) {
pixels[i] = color;
}
return Self{
.pAllocator = pAllocator,
.width = width,
.height = height,
.pixels = pixels,
.pixels_owned = true,
};
}
pub fn deinit(pSelf: *Self) void {
if ((pSelf.pixels_owned) and (pSelf.pixels != null)) {
pSelf.pAllocator.free(pSelf.pixels.?);
}
}
pub fn loadFile(pSelf: *Self, filename: []const u8) anyerror!void {
var cfilename = try std.cstr.addNullByte(pSelf.pAllocator, filename);
defer pSelf.pAllocator.free(cfilename);
var surface = gl.IMG_Load(cfilename.ptr) orelse return error.UnableToLoadImage;
defer gl.SDL_FreeSurface(surface);
pSelf.width = @intCast(usize, surface.w);
pSelf.height = @intCast(usize, surface.h);
var bpp: usize = @intCast(usize, surface.format.BytesPerPixel);
switch (bpp) {
1, 2, 3, 4 => {},
else => return error.UnsupportedBytesPerPixel,
}
var pitch: usize = @intCast(usize, surface.pitch);
var count: usize = pSelf.width * pSelf.height * bpp;
var pPixels: []const u8 = if (surface.pixels) |p| @ptrCast([*]u8, p)[0..count] else return error.NoPixels;
pSelf.pixels = try pSelf.pAllocator.alloc(ColorU8, count);
pSelf.pixels_owned = true;
var y: usize = 0;
var line_offset: usize = 0;
var dest_offset: usize = 0;
while (y < pSelf.height) : (y += 1) {
// Looping through the lines of pixels
var pLine: []const u8 = pPixels[line_offset..];
var x: usize = 0;
var src_offset: usize = 0;
while (x < pSelf.width) : (x += 1) {
// Loopting through the pixels on a line
// Create a slice of this pixels bytes
var pPixel: []const u8 = pLine[src_offset..(src_offset + bpp)];
src_offset += bpp;
// Extract the bytes into a u32
var raw_pixel: u32 = switch (bpp) {
1 => @intCast(u32, pPixel[0]),
2 => @intCast(u32, pPixel[0]) << 0 | @intCast(u32, pPixel[1]) << 8,
3 => @intCast(u32, pPixel[0]) << 0 | @intCast(u32, pPixel[1]) << 8 | @intCast(u32, pPixel[2]) << 16,
4 => @intCast(u32, pPixel[0]) << 0 | @intCast(u32, pPixel[1]) << 8 | @intCast(u32, pPixel[2]) << 16 | @intCast(u32, pPixel[3]) << 24,
else => unreachable,
};
// Extract the components from the raw_pixel
var a: u8 = undefined;
var r: u8 = undefined;
var g: u8 = undefined;
var b: u8 = undefined;
gl.SDL_GetRGBA(raw_pixel, surface.format, &r, &g, &b, &a);
// Store in texture pixels slice
pSelf.pixels.?[dest_offset] = ColorU8.init(a, r, g, b);
dest_offset += 1;
}
line_offset += pitch;
}
}
pub fn map(pSelf: *const Self, tu: f32, tv: f32, defaultColor: ColorU8) ColorU8 {
if (pSelf.pixels) |pPixels| {
var u = @floatToInt(usize, tu * @intToFloat(f32, pSelf.width)) % pSelf.width;
var v = @floatToInt(usize, tv * @intToFloat(f32, pSelf.height)) % pSelf.height;
var c = pPixels[(v * pSelf.width) + u];
if (DBG) warn("map: tu={.3} tv={.3} u={} v={} c={}... ", tu, tv, u, v, &c);
return c;
} else {
return defaultColor;
}
}
};
test "texture.empty" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var texture = Texture.init(pAllocator);
defer texture.deinit();
}
test "texture.known.TODO" {
// TODO: Add a test with known contents so we truly validate
}
test "texture.initPixels" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
// Create and Initialize text.pixels
var texture = try Texture.initPixels(pAllocator, 1024, 512, ColorU8.Black);
defer texture.deinit();
assert(texture.width == 1024);
assert(texture.height == 512);
assert(texture.pixels.?[0].r == ColorU8.Black.r);
assert(texture.pixels.?[0].g == ColorU8.Black.g);
assert(texture.pixels.?[0].b == ColorU8.Black.b);
}
test "texture.loadFile.bricks2" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var texture = Texture.init(pAllocator);
defer texture.deinit();
try texture.loadFile("src/modules/3d-test-resources/bricks2.jpg");
assert(texture.pixels != null);
// We "know" the first pixel isn't 0
assert(texture.pixels.?[0].asU32Argb() != 0);
}
|
0 | repos/zig-3d-soft-engine | repos/zig-3d-soft-engine/src/window.zig | const builtin = @import("builtin");
const TypeId = builtin.TypeId;
const std = @import("std");
const time = std.os.time;
const mem = std.mem;
const math = std.math;
const Allocator = mem.Allocator;
const assert = std.debug.assert;
const warn = std.debug.warn;
const gl = @import("modules/zig-sdl2/src/index.zig");
const misc = @import("modules/zig-misc/index.zig");
const saturateCast = misc.saturateCast;
const colorns = @import("color.zig");
const Color = colorns.Color;
const ColorU8 = colorns.ColorU8;
const geo = @import("modules/zig-geometry/index.zig");
const V2f32 = geo.V2f32;
const V3f32 = geo.V3f32;
const M44f32 = geo.M44f32;
const parseJsonFile = @import("modules/zig-json/parse_json_file.zig").parseJsonFile;
const createMeshFromBabylonJson = @import("create_mesh_from_babylon_json.zig").createMeshFromBabylonJson;
const Camera = @import("camera.zig").Camera;
const meshns = @import("modules/zig-geometry/mesh.zig");
const Mesh = meshns.Mesh;
const Vertex = meshns.Vertex;
const Face = meshns.Face;
const Texture = @import("texture.zig").Texture;
const ki = @import("keyboard_input.zig");
const DBG = false;
const DBG1 = false;
const DBG2 = false;
const DBG3 = false;
const DBG_RenderUsingMode = false;
const DBG_RenderUsingModeInner = false;
const DBG_RenderUsingModeWaitForKey = false;
const DBG_PutPixel = false;
const DBG_DrawTriangle = false;
const DBG_DrawTriangleInner = false;
const DBG_ProcessScanLine = false;
const DBG_ProcessScanLineInner = false;
pub const Entity = struct {
mesh: Mesh,
texture: ?Texture,
};
pub const RenderMode = enum {
Points,
Lines,
Triangles,
};
const DBG_RenderMode = RenderMode.Points;
const ScanLineData = struct {
pub y: isize,
pub ndotla: f32,
pub ndotlb: f32,
pub ndotlc: f32,
pub ndotld: f32,
pub ua: f32,
pub ub: f32,
pub uc: f32,
pub ud: f32,
pub va: f32,
pub vb: f32,
pub vc: f32,
pub vd: f32,
};
pub const Window = struct {
const Self = @This();
const ZbufferType = f32;
pAllocator: *Allocator,
width: usize,
widthci: c_int,
widthf: f32,
height: usize,
heightci: c_int,
heightf: f32,
name: []const u8,
bg_color: ColorU8,
pixels: []u32,
zbuffer: []ZbufferType,
sdl_window: *gl.SDL_Window,
sdl_renderer: *gl.SDL_Renderer,
sdl_texture: *gl.SDL_Texture,
pub fn init(pAllocator: *Allocator, width: usize, height: usize, name: []const u8) !Self {
var self = Self{
.pAllocator = pAllocator,
.bg_color = undefined,
.width = width,
.widthci = @intCast(c_int, width),
.widthf = @intToFloat(f32, width),
.height = height,
.heightci = @intCast(c_int, height),
.heightf = @intToFloat(f32, height),
.name = name,
.pixels = try pAllocator.alloc(u32, width * height),
.zbuffer = try pAllocator.alloc(f32, width * height),
.sdl_window = undefined,
.sdl_renderer = undefined,
.sdl_texture = undefined,
};
self.setBgColor(ColorU8.Black);
// Initialize SDL
if (gl.SDL_Init(gl.SDL_INIT_VIDEO | gl.SDL_INIT_AUDIO) != 0) {
return error.FailedSdlInitialization;
}
errdefer gl.SDL_Quit();
// Initialize SDL image
if (gl.IMG_Init(gl.IMG_INIT_JPG) != @intCast(c_int, gl.IMG_INIT_JPG)) {
return error.FailedSdlImageInitialization;
}
errdefer gl.IMG_Quit();
// Create Window
const x_pos: c_int = gl.SDL_WINDOWPOS_UNDEFINED;
const y_pos: c_int = gl.SDL_WINDOWPOS_UNDEFINED;
var window_flags: u32 = 0;
self.sdl_window = gl.SDL_CreateWindow(c"zig-3d-soft-engine", x_pos, y_pos, self.widthci, self.heightci, window_flags) orelse {
return error.FailedSdlWindowInitialization;
};
errdefer gl.SDL_DestroyWindow(self.sdl_window);
// This reduces CPU utilization but now dragging window is jerky
{
var r = gl.SDL_GL_SetSwapInterval(1);
if (r != 0) {
var b = gl.SDL_SetHint(gl.SDL_HINT_RENDER_VSYNC, c"1");
if (b != gl.SDL_bool.SDL_TRUE) {
warn("No VSYNC cpu utilization may be high!\n");
}
}
}
// Create Renderer
var renderer_flags: u32 = 0;
self.sdl_renderer = gl.SDL_CreateRenderer(self.sdl_window, -1, renderer_flags) orelse {
return error.FailedSdlRendererInitialization;
};
errdefer gl.SDL_DestroyRenderer(self.sdl_renderer);
// Create Texture
self.sdl_texture = gl.SDL_CreateTexture(self.sdl_renderer, gl.SDL_PIXELFORMAT_ARGB8888, gl.SDL_TEXTUREACCESS_STATIC, self.widthci, self.heightci) orelse {
return error.FailedSdlTextureInitialization;
};
errdefer gl.SDL_DestroyTexture(self.sdl_texture);
self.clear();
return self;
}
pub fn deinit(pSelf: *Self) void {
gl.SDL_DestroyTexture(pSelf.sdl_texture);
gl.SDL_DestroyRenderer(pSelf.sdl_renderer);
gl.SDL_DestroyWindow(pSelf.sdl_window);
gl.SDL_Quit();
}
pub fn setBgColor(pSelf: *Self, color: ColorU8) void {
pSelf.bg_color = color;
}
pub fn clearZbufferValue(pSelf: *Self) ZbufferType {
return misc.maxValue(ZbufferType);
}
pub fn clear(pSelf: *Self) void {
// Init Pixel buffer
for (pSelf.pixels) |*pixel| {
pixel.* = pSelf.bg_color.asU32Argb();
}
for (pSelf.zbuffer) |*elem| {
elem.* = pSelf.clearZbufferValue();
}
}
pub fn putPixel(pSelf: *Self, x: usize, y: usize, z: f32, color: ColorU8) void {
if (DBG_PutPixel) warn("putPixel: x={} y={} z={.3} c={}\n", x, y, z, &color);
var index = (y * pSelf.width) + x;
// +Z is towards screen so (-Z is away from screen) so if z is behind
// or equal to (>=) a previouly written pixel just return.
// NOTE: First value written, if they are equal, will be visible. Is this what we want?
if (z >= pSelf.zbuffer[index]) return;
pSelf.zbuffer[index] = z;
pSelf.pixels[index] = color.asU32Argb();
}
pub fn getPixel(pSelf: *Self, x: usize, y: usize) u32 {
return pSelf.pixels[(y * pSelf.width) + x];
}
pub fn present(pSelf: *Self) void {
_ = gl.SDL_UpdateTexture(pSelf.sdl_texture, null, @ptrCast(*const c_void, &pSelf.pixels[0]), pSelf.widthci * @sizeOf(@typeOf(pSelf.pixels[0])));
_ = gl.SDL_RenderClear(pSelf.sdl_renderer);
_ = gl.SDL_RenderCopy(pSelf.sdl_renderer, pSelf.sdl_texture, null, null);
_ = gl.SDL_RenderPresent(pSelf.sdl_renderer);
}
/// Project takes a 3D coord and converts it to a 2D point
/// using the transform matrix.
pub fn projectRetV2f32(pSelf: *Self, coord: V3f32, transMat: *const M44f32) V2f32 {
if (DBG1) warn("projectRetV2f32: original coord={} widthf={.3} heightf={.3}\n", &coord, pSelf.widthf, pSelf.heightf);
return geo.projectToScreenCoord(pSelf.widthf, pSelf.heightf, coord, transMat);
}
/// Draw a Vec2 point in screen coordinates clipping it if its outside the screen
pub fn drawPointV2f32(pSelf: *Self, point: V2f32, color: ColorU8) void {
pSelf.drawPointXy(@floatToInt(isize, point.x()), @floatToInt(isize, point.y()), color);
}
/// Draw a point defined by x, y in screen coordinates clipping it if its outside the screen
pub fn drawPointXy(pSelf: *Self, x: isize, y: isize, color: ColorU8) void {
//if (DBG) warn("drawPointXy: x={} y={} c={}\n", x, y, &color);
if ((x >= 0) and (y >= 0)) {
var ux = @bitCast(usize, x);
var uy = @bitCast(usize, y);
if ((ux < pSelf.width) and (uy < pSelf.height)) {
//if (DBG) warn("drawPointXy: putting x={} y={} c={}\n", ux, uy, &color);
pSelf.putPixel(ux, uy, -pSelf.clearZbufferValue(), color);
}
}
}
/// Draw a point defined by x, y in screen coordinates clipping it if its outside the screen
pub fn drawPointXyz(pSelf: *Self, x: isize, y: isize, z: f32, color: ColorU8) void {
//if (DBG) warn("drawPointXyz: x={} y={} z={.3} c={}\n", x, y, &color);
if ((x >= 0) and (y >= 0)) {
var ux = @bitCast(usize, x);
var uy = @bitCast(usize, y);
if ((ux < pSelf.width) and (uy < pSelf.height)) {
//if (DBG) warn("drawPointXyz: putting x={} y={} c={}\n", ux, uy, &color);
pSelf.putPixel(ux, uy, z, color);
}
}
}
/// Draw a line point0 and 1 are in screen coordinates
pub fn drawLine(pSelf: *Self, point0: V2f32, point1: V2f32, color: ColorU8) void {
var diff = point1.sub(&point0);
var dist = diff.length();
//if (DBG) warn("drawLine: diff={} dist={}\n", diff, dist);
if (dist < 2)
return;
var diff_half = diff.scale(0.5);
var mid_point = point0.add(&diff_half);
//if (DBG) warn("drawLe: diff_half={} mid_point={}\n", diff_half, mid_point);
pSelf.drawPointV2f32(mid_point, color);
pSelf.drawLine(point0, mid_point, color);
pSelf.drawLine(mid_point, point1, color);
}
/// Draw a line point0 and 1 are in screen coordinates using Bresnham algorithm
pub fn drawBline(pSelf: *Self, point0: V2f32, point1: V2f32, color: ColorU8) void {
//@setRuntimeSafety(false);
var x0 = @floatToInt(isize, point0.x());
var y0 = @floatToInt(isize, point0.y());
var x1 = @floatToInt(isize, point1.x());
var y1 = @floatToInt(isize, point1.y());
var dx: isize = math.absInt(x1 - x0) catch unreachable;
var dy: isize = math.absInt(y1 - y0) catch unreachable;
var sx: isize = if (x0 < x1) isize(1) else isize(-1);
var sy: isize = if (y0 < y1) isize(1) else isize(-1);
var err: isize = dx - dy;
while (true) {
pSelf.drawPointXy(x0, y0, color);
if ((x0 == x1) and (y0 == y1)) break;
var e2: isize = 2 * err;
if (e2 > -dy) {
err -= dy;
x0 += sx;
} else {
err += dx;
y0 += sy;
}
}
}
/// Project takes a 3D coord and converts it to a 2D point
/// using the transform matrix.
pub fn projectRetVertex(pSelf: *Self, vertex: Vertex, transMat: *const M44f32, worldMat: *const M44f32) Vertex {
if (DBG1) warn("projectRetVertex: original coord={} widthf={.3} heightf={.3}\n", &vertex.coord, pSelf.widthf, pSelf.heightf);
var point = vertex.coord.transform(transMat);
var point_world = vertex.coord.transform(worldMat);
var normal_world = vertex.normal_coord.transform(worldMat);
var x = (point.x() * pSelf.widthf) + (pSelf.widthf / 2.0);
var y = (-point.y() * pSelf.heightf) + (pSelf.heightf / 2.0);
return Vertex{
.coord = V3f32.init(x, y, point.z()),
.world_coord = point_world,
.normal_coord = normal_world,
.texture_coord = vertex.texture_coord,
};
}
/// Draw a V3f32 point in screen coordinates clipping it if its outside the screen
pub fn drawPointV3f32(pSelf: *Self, point: V3f32, color: ColorU8) void {
pSelf.drawPointXyz(@floatToInt(isize, math.trunc(point.x())), @floatToInt(isize, math.trunc(point.y())), point.z(), color);
}
/// Clamp value to between min and max parameters
pub fn clamp(value: f32, min: f32, max: f32) f32 {
return math.max(min, math.min(value, max));
}
/// Interplate between min and max as a percentage between
/// min and max as defined by the gradient. With 0.0 <= gradiant <= 1.0.
pub fn interpolate(min: f32, max: f32, gradient: f32) f32 {
return min + (max - min) * clamp(gradient, 0, 1);
}
/// Compute the normal dot light
pub fn computeNormalDotLight(vertex: V3f32, normal: V3f32, light_pos: V3f32) f32 {
var light_direction = light_pos.sub(&vertex);
var nrml = normal.normalize();
light_direction = light_direction.normalize();
var ndotl = nrml.dot(&light_direction);
var r = math.max(0, ndotl);
if (DBG3) warn("computeNormalDotLight: ndotl={} r={}\n", ndotl, r);
return r;
}
/// Draw a horzitontal scan line at y between line a lined defined by
/// va:vb to another defined line vc:vd. It is assumed they have
/// already been sorted and we're drawing horizontal lines with
/// line va:vb on the left and vc:vd on the right.
pub fn processScanLine(pSelf: *Self, scanLineData: ScanLineData, va: Vertex, vb: Vertex, vc: Vertex, vd: Vertex, color: ColorU8, texture: ?Texture) void {
var pa = va.coord;
var pb = vb.coord;
var pc = vc.coord;
var pd = vd.coord;
// Compute the gradiants and if the line are just points then gradient is 1
const gradient1: f32 = if (pa.y() == pb.y()) 1 else (@intToFloat(f32, scanLineData.y) - pa.y()) / (pb.y() - pa.y());
const gradient2: f32 = if (pc.y() == pd.y()) 1 else (@intToFloat(f32, scanLineData.y) - pc.y()) / (pd.y() - pc.y());
// Define the start and end point for x
var sx: isize = @floatToInt(isize, interpolate(pa.x(), pb.x(), gradient1));
var ex: isize = @floatToInt(isize, interpolate(pc.x(), pd.x(), gradient2));
// Define the start and end point for z
var sz: f32 = interpolate(pa.z(), pb.z(), gradient1);
var ez: f32 = interpolate(pc.z(), pd.z(), gradient2);
// Define the start and end point for normal dot light
var snl: f32 = interpolate(scanLineData.ndotla, scanLineData.ndotlb, gradient1);
var enl: f32 = interpolate(scanLineData.ndotlc, scanLineData.ndotld, gradient2);
// Define the start and end for texture u/v
var su: f32 = interpolate(scanLineData.ua, scanLineData.ub, gradient1);
var eu: f32 = interpolate(scanLineData.uc, scanLineData.ud, gradient2);
var sv: f32 = interpolate(scanLineData.va, scanLineData.vb, gradient1);
var ev: f32 = interpolate(scanLineData.vc, scanLineData.vd, gradient2);
// Draw a horzitional line between start and end
if (scanLineData.y >= 0) { // Check if y is negative so our v casting works
var x: isize = sx;
if (DBG_ProcessScanLine) warn("processScanLine: y={} sx={} ex={} cnt={}\n", scanLineData.y, sx, ex, ex - sx);
while (x < ex) : (x += 1) {
var gradient: f32 = @intToFloat(f32, (x - sx)) / @intToFloat(f32, (ex - sx));
var z = interpolate(sz, ez, gradient);
var ndotl = interpolate(snl, enl, gradient);
var u = interpolate(su, eu, gradient);
var v = interpolate(sv, ev, gradient);
if (x >= 0) { // Check if x is negative so our u casting works
var c: ColorU8 = undefined;
if (texture) |t| {
c = t.map(u, v, color);
if (DBG_ProcessScanLineInner) warn("processScanLine: c={}\n", &c);
} else {
c = color;
}
pSelf.drawPointXyz(x, scanLineData.y, z, c.colorScale(ndotl));
}
}
}
}
pub fn drawTriangle(pSelf: *Self, v1: Vertex, v2: Vertex, v3: Vertex, color: ColorU8, texture: ?Texture) void {
if (DBG_DrawTriangle) warn("drawTriangle:\n v1={}\n v2={}\n v3={}\n", v1, v2, v3);
// Sort the points finding top, mid, bottom.
var t = v1; // Top
var m = v2; // Mid
var b = v3; // Bottom
// Find top, i.e. the point with the smallest y value
if (t.coord.y() > m.coord.y()) {
mem.swap(Vertex, &t, &m);
}
if (m.coord.y() > b.coord.y()) {
mem.swap(Vertex, &m, &b);
}
if (t.coord.y() > m.coord.y()) {
mem.swap(Vertex, &t, &m);
}
if (DBG_DrawTriangle) warn("drawTriangle:\n t={}\n m={}\n b={}\n", t, m, b);
var light_pos = V3f32.init(0, 10, -10);
var t_ndotl = computeNormalDotLight(t.world_coord, t.normal_coord, light_pos);
var m_ndotl = computeNormalDotLight(m.world_coord, m.normal_coord, light_pos);
var b_ndotl = computeNormalDotLight(b.world_coord, b.normal_coord, light_pos);
if (DBG_DrawTriangle) warn("drawTriangle:\n t_ndotl={}\n m_ndotl={}\n b_ndotl={}\n", t_ndotl, m_ndotl, b_ndotl);
var scanLineData: ScanLineData = undefined;
// Convert the top.coord.y, mid.coord.y and bottom.coord.y to integers
var t_y = @floatToInt(isize, math.trunc(t.coord.y()));
var m_y = @floatToInt(isize, math.trunc(m.coord.y()));
var b_y = @floatToInt(isize, math.trunc(b.coord.y()));
// Create top to mid line and top to bottom lines.
// We then take the cross product of these lines and
// if the result is positive then the mid is on the right
// otherwise mid is on the left.
//
// See: https://www.davrous.com/2013/06/21/tutorial-part-4-learning-how-to-write-a-3d-software-engine-in-c-ts-or-js-rasterization-z-buffering/#comment-737
// and https://stackoverflow.com/questions/243945/calculating-a-2d-vectors-cross-product?answertab=votes#tab-top
var t_m = V2f32.init(m.coord.x() - t.coord.x(), m.coord.y() - t.coord.y());
var t_b = V2f32.init(b.coord.x() - t.coord.x(), b.coord.y() - t.coord.y());
var t_m_cross_t_b = t_m.cross(&t_b);
// Two cases, 1) triangles with mid on the right
if (t_m_cross_t_b > 0) {
if (DBG_DrawTriangle) warn("drawTriangle: mid RIGHT t_m_cross_t_b:{.5} > 0\n", t_m_cross_t_b);
// Triangles with mid on the right
// t
// |\
// | \
// | \
// | m
// | /
// | /
// |/
// b
scanLineData.y = t_y;
while (scanLineData.y <= b_y) : (scanLineData.y += 1) {
if (scanLineData.y < m_y) {
if (DBG_DrawTriangleInner) warn("drawTriangle: scanLineData.y:{} < m_y:{}\n", scanLineData.y, m_y);
scanLineData.ndotla = t_ndotl;
scanLineData.ndotlb = b_ndotl;
scanLineData.ndotlc = t_ndotl;
scanLineData.ndotld = m_ndotl;
scanLineData.ua = v1.texture_coord.x();
scanLineData.ub = v3.texture_coord.x();
scanLineData.uc = v1.texture_coord.x();
scanLineData.ud = v2.texture_coord.x();
scanLineData.va = v1.texture_coord.y();
scanLineData.vb = v3.texture_coord.y();
scanLineData.vc = v1.texture_coord.y();
scanLineData.vd = v2.texture_coord.y();
pSelf.processScanLine(scanLineData, t, b, t, m, color, texture);
} else {
if (DBG_DrawTriangleInner) warn("drawTriangle: scanLineData.y:{} >= m_y:{}\n", scanLineData.y, m_y);
scanLineData.ndotla = t_ndotl;
scanLineData.ndotlb = b_ndotl;
scanLineData.ndotlc = m_ndotl;
scanLineData.ndotld = b_ndotl;
scanLineData.ua = v1.texture_coord.x();
scanLineData.ub = v3.texture_coord.x();
scanLineData.uc = v2.texture_coord.x();
scanLineData.ud = v3.texture_coord.x();
scanLineData.va = v1.texture_coord.y();
scanLineData.vb = v3.texture_coord.y();
scanLineData.vc = v2.texture_coord.y();
scanLineData.vd = v3.texture_coord.y();
pSelf.processScanLine(scanLineData, t, b, m, b, color, texture);
}
}
} else {
if (DBG_DrawTriangle) warn("drawTriangle: mid LEFT t_m_cross_t_b:{.5} > 0\n", t_m_cross_t_b);
// Triangles with mid on the left
// t
// /|
// / |
// / |
// m |
// \ |
// \ |
// \|
// b
scanLineData.y = t_y;
while (scanLineData.y <= b_y) : (scanLineData.y += 1) {
if (scanLineData.y < m_y) {
if (DBG_DrawTriangleInner) warn("drawTriangle: scanLineData.y:{} < m_y:{}\n", scanLineData.y, m_y);
scanLineData.ndotla = t_ndotl;
scanLineData.ndotlb = m_ndotl;
scanLineData.ndotlc = t_ndotl;
scanLineData.ndotld = b_ndotl;
scanLineData.ua = v1.texture_coord.x();
scanLineData.ub = v2.texture_coord.x();
scanLineData.uc = v1.texture_coord.x();
scanLineData.ud = v3.texture_coord.x();
scanLineData.va = v1.texture_coord.y();
scanLineData.vb = v2.texture_coord.y();
scanLineData.vc = v1.texture_coord.y();
scanLineData.vd = v3.texture_coord.y();
pSelf.processScanLine(scanLineData, t, m, t, b, color, texture);
} else {
if (DBG_DrawTriangleInner) warn("drawTriangle: scanLineData.y:{} >= m_y:{}\n", scanLineData.y, m_y);
scanLineData.ndotla = m_ndotl;
scanLineData.ndotlb = b_ndotl;
scanLineData.ndotlc = t_ndotl;
scanLineData.ndotld = b_ndotl;
scanLineData.ua = v2.texture_coord.x();
scanLineData.ub = v3.texture_coord.x();
scanLineData.uc = v1.texture_coord.x();
scanLineData.ud = v3.texture_coord.x();
scanLineData.va = v2.texture_coord.y();
scanLineData.vb = v3.texture_coord.y();
scanLineData.vc = v1.texture_coord.y();
scanLineData.vd = v3.texture_coord.y();
pSelf.processScanLine(scanLineData, m, b, t, b, color, texture);
}
}
}
}
/// Render the entities into the window from the camera's point of view
pub fn renderUsingMode(pSelf: *Self, renderMode: RenderMode, camera: *const Camera, entities: []const Entity, negate_tnz: bool) void {
var view_matrix: geo.M44f32 = undefined;
view_matrix = geo.lookAtLh(&camera.position, &camera.target, &V3f32.unitY());
if (DBG_RenderUsingMode) warn("view_matrix:\n{}\n", &view_matrix);
var fov: f32 = 70;
var znear: f32 = 0.1;
var zfar: f32 = 1000.0;
var perspective_matrix = geo.perspectiveM44(f32, geo.rad(fov), pSelf.widthf / pSelf.heightf, znear, zfar);
if (DBG_RenderUsingMode) warn("perspective_matrix: fov={.3}, znear={.3} zfar={.3}\n{}\n", fov, znear, zfar, &perspective_matrix);
for (entities) |entity| {
var mesh = entity.mesh;
var rotation_matrix = geo.rotateCwPitchYawRollV3f32(mesh.rotation);
if (DBG_RenderUsingMode) warn("rotation_matrix:\n{}\n", &rotation_matrix);
var translation_matrix = geo.translationV3f32(mesh.position);
if (DBG_RenderUsingMode) warn("translation_matrix:\n{}\n", &translation_matrix);
var world_matrix = geo.mulM44f32(&translation_matrix, &rotation_matrix);
if (DBG_RenderUsingMode) warn("world_matrix:\n{}\n", &world_matrix);
var world_to_view_matrix = geo.mulM44f32(&world_matrix, &view_matrix);
var transform_matrix = geo.mulM44f32(&world_to_view_matrix, &perspective_matrix);
if (DBG_RenderUsingMode) warn("transform_matrix:\n{}\n", &transform_matrix);
if (DBG_RenderUsingMode) warn("\n");
for (mesh.faces) |face, i| {
const va = mesh.vertices[face.a];
const vb = mesh.vertices[face.b];
const vc = mesh.vertices[face.c];
if (DBG_RenderUsingModeInner) warn("va={} vb={} vc={}\n", va.coord, vb.coord, vc.coord);
var color = ColorU8.init(0xff, 0, 0xff, 0xff);
switch (renderMode) {
RenderMode.Points => {
const pa = pSelf.projectRetV2f32(va.coord, &transform_matrix);
const pb = pSelf.projectRetV2f32(vb.coord, &transform_matrix);
const pc = pSelf.projectRetV2f32(vc.coord, &transform_matrix);
if (DBG_RenderUsingModeInner) warn("pa={} pb={} pc={}\n", pa, pb, pc);
pSelf.drawPointV2f32(pa, color);
pSelf.drawPointV2f32(pb, color);
pSelf.drawPointV2f32(pc, color);
},
RenderMode.Lines => {
const pa = pSelf.projectRetV2f32(va.coord, &transform_matrix);
const pb = pSelf.projectRetV2f32(vb.coord, &transform_matrix);
const pc = pSelf.projectRetV2f32(vc.coord, &transform_matrix);
if (DBG_RenderUsingModeInner) warn("pa={} pb={} pc={}\n", pa, pb, pc);
pSelf.drawBline(pa, pb, color);
pSelf.drawBline(pb, pc, color);
pSelf.drawBline(pc, pa, color);
},
RenderMode.Triangles => {
// Transform face.normal to world_to_view_matrix and only render
// faces which can be "seen" by the camera.
// Bugs: 1) See "rendering bug"
// https://www.davrous.com/2013/07/18/tutorial-part-6-learning-how-to-write-a-3d-software-engine-in-c-ts-or-js-texture-mapping-back-face-culling-webgl
// it says that perspective isn't being taken into account and some triangles are not drawn when they should be.
//
// 2) I have to "negate_tnz" tnz so the expected triangles are VISIBLE so "if (tnz < 0) {" works.
// In the tutorial we have "if (transformedNormal < 0) {",
// see: http://david.blob.core.windows.net/softengine3d/SoftEngineJSPart6Sample2.zip
var tnz = face.normal.transformNormal(&world_to_view_matrix).z();
tnz = if (negate_tnz) -tnz else tnz;
if (tnz < 0) {
if (DBG_RenderUsingModeInner) warn("VISIBLE face.normal:{} tnz:{}\n", &face.normal, &tnz);
// Transform the vertex's
const tva = pSelf.projectRetVertex(va, &transform_matrix, &world_matrix);
const tvb = pSelf.projectRetVertex(vb, &transform_matrix, &world_matrix);
const tvc = pSelf.projectRetVertex(vc, &transform_matrix, &world_matrix);
var colorF32: f32 = undefined;
//colorF32 = 0.25 + @intToFloat(f32, i % mesh.faces.len) * (0.75 / @intToFloat(f32, mesh.faces.len));
colorF32 = 1.0;
var colorU8: u8 = saturateCast(u8, math.round(colorF32 * 256.0));
color = ColorU8.init(colorU8, colorU8, colorU8, colorU8);
pSelf.drawTriangle(tva, tvb, tvc, color, entity.texture);
if (DBG_RenderUsingModeInner) warn("tva={} tvb={} tvc={} color={}\n", tva.coord, tvb.coord, tvc.coord, &color);
} else {
if (DBG_RenderUsingModeInner) warn("HIDDEN face.normal:{} tnz:{}\n", &face.normal, &tnz);
}
},
}
if (DBG_RenderUsingModeWaitForKey) {
pSelf.present();
_ = ki.waitForKey("dt", true, DBG_RenderUsingModeWaitForKey);
}
}
}
}
pub fn render(pSelf: *Self, camera: *const Camera, entities: []const Entity) void {
renderUsingMode(pSelf, DBG_RenderMode, camera, entities, true);
}
};
|
0 | repos/zig-3d-soft-engine | repos/zig-3d-soft-engine/src/test-window.zig | const builtin = @import("builtin");
const TypeId = builtin.TypeId;
const std = @import("std");
const time = std.os.time;
const mem = std.mem;
const math = std.math;
const Allocator = mem.Allocator;
const assert = std.debug.assert;
const warn = std.debug.warn;
const gl = @import("modules/zig-sdl2/src/index.zig");
const misc = @import("modules/zig-misc/index.zig");
const saturateCast = misc.saturateCast;
const colorns = @import("color.zig");
const Color = colorns.Color;
const ColorU8 = colorns.ColorU8;
const geo = @import("modules/zig-geometry/index.zig");
const V2f32 = geo.V2f32;
const V3f32 = geo.V3f32;
const M44f32 = geo.M44f32;
const parseJsonFile = @import("modules/zig-json/parse_json_file.zig").parseJsonFile;
const createMeshFromBabylonJson = @import("create_mesh_from_babylon_json.zig").createMeshFromBabylonJson;
const Camera = @import("camera.zig").Camera;
const meshns = @import("modules/zig-geometry/mesh.zig");
const Mesh = meshns.Mesh;
const Vertex = meshns.Vertex;
const Face = meshns.Face;
const Texture = @import("texture.zig").Texture;
const ki = @import("keyboard_input.zig");
const windowns = @import("window.zig");
const Entity = windowns.Entity;
const RenderMode = windowns.RenderMode;
const Window = windowns.Window;
const DBG = false;
const DBG1 = false;
const DBG2 = false;
const DBG3 = false;
const DBG_RenderUsingModeWaitForKey = false;
const DBG_Rotate = false;
const DBG_Translate = false;
const DBG_world_to_screen = false;
const DBG_ft_bitmapToTexture = false;
test "window" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 640, 480, "testWindow");
defer window.deinit();
assert(window.width == 640);
assert(window.widthci == 640);
assert(window.widthf == f32(640));
assert(window.height == 480);
assert(window.heightci == 480);
assert(window.heightf == f32(480));
assert(mem.eql(u8, window.name, "testWindow"));
var color = ColorU8.init(0x01, 02, 03, 04);
window.putPixel(0, 0, 0, color);
assert(window.getPixel(0, 0) == color.asU32Argb());
}
test "window.projectRetV2f32" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 640, 480, "testWindow");
defer window.deinit();
var v1 = V3f32.init(0, 0, 0);
var r = window.projectRetV2f32(v1, &geo.m44f32_unit);
assert(r.x() == window.widthf / 2.0);
assert(r.y() == window.heightf / 2.0);
v1 = V3f32.init(-1.0, 1.0, 0);
r = window.projectRetV2f32(v1, &geo.m44f32_unit);
assert(r.x() == 0);
assert(r.y() == 0);
v1 = V3f32.init(1.0, -1.0, 0);
r = window.projectRetV2f32(v1, &geo.m44f32_unit);
assert(r.x() == window.widthf);
assert(r.y() == window.heightf);
v1 = V3f32.init(-1.0, -1.0, 0);
r = window.projectRetV2f32(v1, &geo.m44f32_unit);
assert(r.x() == 0);
assert(r.y() == window.heightf);
v1 = V3f32.init(1.0, 1.0, 0);
r = window.projectRetV2f32(v1, &geo.m44f32_unit);
assert(r.x() == window.widthf);
assert(r.y() == 0);
}
test "window.drawPointV2f32" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 640, 480, "testWindow");
defer window.deinit();
var p1 = V2f32.init(0, 0);
var color = ColorU8.init(0x80, 0x80, 0x80, 0x80);
window.drawPointV2f32(p1, color);
assert(window.getPixel(0, 0) == color.asU32Argb());
p1 = V2f32.init(window.widthf / 2, window.heightf / 2);
window.drawPointV2f32(p1, color);
assert(window.getPixel(window.width / 2, window.height / 2) == color.asU32Argb());
}
test "window.projectRetVertex" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 640, 480, "testWindow");
defer window.deinit();
var v1 = Vertex.init(0, 0, 0);
var r = window.projectRetVertex(v1, &geo.m44f32_unit, &geo.m44f32_unit);
assert(r.coord.x() == window.widthf / 2.0);
assert(r.coord.y() == window.heightf / 2.0);
v1 = Vertex.init(-0.5, 0.5, 0);
r = window.projectRetVertex(v1, &geo.m44f32_unit, &geo.m44f32_unit);
assert(r.coord.x() == 0);
assert(r.coord.y() == 0);
v1 = Vertex.init(0.5, -0.5, 0);
r = window.projectRetVertex(v1, &geo.m44f32_unit, &geo.m44f32_unit);
assert(r.coord.x() == window.widthf);
assert(r.coord.y() == window.heightf);
v1 = Vertex.init(-0.5, -0.5, 0);
r = window.projectRetVertex(v1, &geo.m44f32_unit, &geo.m44f32_unit);
assert(r.coord.x() == 0);
assert(r.coord.y() == window.heightf);
v1 = Vertex.init(0.5, 0.5, 0);
r = window.projectRetVertex(v1, &geo.m44f32_unit, &geo.m44f32_unit);
assert(r.coord.x() == window.widthf);
assert(r.coord.y() == 0);
}
test "window.drawLine" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 640, 480, "testWindow");
defer window.deinit();
var point1 = V2f32.init(1, 1);
var point2 = V2f32.init(4, 4);
var color = ColorU8.init(0x80, 0x80, 0x80, 0x80);
window.drawLine(point1, point2, color);
assert(window.getPixel(1, 1) == color.asU32Argb());
assert(window.getPixel(2, 2) == color.asU32Argb());
assert(window.getPixel(3, 3) == color.asU32Argb());
}
test "window.world.to.screen" {
if (DBG_world_to_screen) warn("\n");
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
const T = f32;
const widthf: T = 512;
const heightf: T = 512;
const width: u32 = @floatToInt(u32, widthf);
const height: u32 = @floatToInt(u32, heightf);
const fov: T = 90;
const aspect: T = widthf / heightf;
const znear: T = 0.01;
const zfar: T = 1.0;
var camera_position = V3f32.init(0, 0, 2);
var camera_target = V3f32.initVal(0);
var camera = Camera.init(camera_position, camera_target);
var window = try Window.init(pAllocator, width, height, "testWindow");
defer window.deinit();
var view_to_perspective_matrix = geo.perspectiveM44(f32, geo.rad(fov), aspect, znear, zfar);
if (DBG_world_to_screen) warn("view_to_perspective_matrix=\n{}\n", view_to_perspective_matrix);
var world_to_view_matrix: geo.M44f32 = undefined;
world_to_view_matrix = geo.lookAtRh(&camera.position, &camera.target, &V3f32.unitY());
world_to_view_matrix = geo.m44f32_unit;
world_to_view_matrix.data[3][2] = 2;
if (DBG_world_to_screen) warn("world_to_view_matrix=\n{}\n", world_to_view_matrix);
var world_vertexs = []V3f32{
V3f32.init(0, 1, 0),
V3f32.init(-1, -1, 0),
V3f32.init(0.5, -0.5, 0),
};
var expected_view_vertexs = []V3f32{
V3f32.init(0, 1, 2),
V3f32.init(-1, -1, 2),
V3f32.init(0.5, -0.5, 2),
};
var expected_projected_vertexs = []V3f32{
V3f32.init(0, 0.5, 1.00505),
V3f32.init(-0.5, -0.5, 1.00505),
V3f32.init(0.25, -0.25, 1.00505),
};
var expected_screen_vertexs = [][2]u32{
[]u32{ 256, 128 },
[]u32{ 128, 384 },
[]u32{ 320, 320 },
};
// Loop until end_time is reached but always loop once :)
var msf: u64 = time.ns_per_s / time.ms_per_s;
var timer = try time.Timer.start();
var end_time: u64 = 0;
if (DBG_world_to_screen) end_time += (4000 * msf);
while (true) {
window.clear();
for (world_vertexs) |world_vert, i| {
if (DBG_world_to_screen) warn("world_vert[{}] = {}\n", i, &world_vert);
var view_vert = world_vert.transform(&world_to_view_matrix);
if (DBG_world_to_screen) warn("view_vert = {}\n", view_vert);
assert(view_vert.approxEql(&expected_view_vertexs[i], 5));
var projected_vert = view_vert.transform(&view_to_perspective_matrix);
if (DBG_world_to_screen) warn("projected_vert = {}\n", projected_vert);
assert(projected_vert.approxEql(&expected_projected_vertexs[i], 5));
var point = window.projectRetV2f32(projected_vert, &geo.m44f32_unit);
var color = ColorU8.init(0xff, 0xff, 00, 0xff);
window.drawPointV2f32(point, color);
assert(window.getPixel(expected_screen_vertexs[i][0], expected_screen_vertexs[i][1]) == color.asU32Argb());
}
var center = V2f32.init(window.widthf / 2, window.heightf / 2);
window.drawPointV2f32(center, ColorU8.White);
window.present();
if (timer.read() > end_time) break;
}
}
test "window.render.cube" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 640, 480, "testWindow");
defer window.deinit();
var mesh: Mesh = undefined;
// Unit cube about 0,0,0
mesh = try Mesh.init(pAllocator, "mesh1", 8, 12);
defer mesh.deinit();
// Unit cube about 0,0,0
mesh.vertices[0] = Vertex.init(-1, 1, 1);
mesh.vertices[1] = Vertex.init(-1, -1, 1);
mesh.vertices[2] = Vertex.init(1, -1, 1);
mesh.vertices[3] = Vertex.init(1, 1, 1);
mesh.vertices[4] = Vertex.init(-1, 1, -1);
mesh.vertices[5] = Vertex.init(-1, -1, -1);
mesh.vertices[6] = Vertex.init(1, -1, -1);
mesh.vertices[7] = Vertex.init(1, 1, -1);
// 12 faces
mesh.faces[0] = Face{ .a = 0, .b = 1, .c = 2, .normal = undefined };
mesh.faces[1] = Face{ .a = 0, .b = 2, .c = 3, .normal = undefined };
mesh.faces[2] = Face{ .a = 3, .b = 2, .c = 6, .normal = undefined };
mesh.faces[3] = Face{ .a = 3, .b = 6, .c = 7, .normal = undefined };
mesh.faces[4] = Face{ .a = 7, .b = 6, .c = 5, .normal = undefined };
mesh.faces[5] = Face{ .a = 7, .b = 5, .c = 4, .normal = undefined };
mesh.faces[6] = Face{ .a = 4, .b = 5, .c = 1, .normal = undefined };
mesh.faces[7] = Face{ .a = 4, .b = 1, .c = 0, .normal = undefined };
mesh.faces[8] = Face{ .a = 0, .b = 3, .c = 4, .normal = undefined };
mesh.faces[9] = Face{ .a = 3, .b = 7, .c = 4, .normal = undefined };
mesh.faces[10] = Face{ .a = 1, .b = 6, .c = 2, .normal = undefined };
mesh.faces[11] = Face{ .a = 1, .b = 5, .c = 6, .normal = undefined };
var entity = Entity{
.texture = null,
.mesh = mesh,
};
var entities = []Entity{entity};
var movement = V3f32.init(0.01, 0.01, 0); // Small amount of movement
var camera_position = V3f32.init(0, 0, -5);
var camera_target = V3f32.initVal(0);
var camera = Camera.init(camera_position, camera_target);
// Loop until end_time is reached but always loop once :)
var ms_factor: u64 = time.ns_per_s / time.ms_per_s;
var timer = try time.Timer.start();
var end_time: u64 = if (DBG or DBG1 or DBG2) (5000 * ms_factor) else (100 * ms_factor);
while (true) {
window.clear();
if (DBG1) {
warn("rotation={.5}:{.5}:{.5}\n", entities[0].mesh.rotation.x(), entities[0].mesh.rotation.y(), entities[0].mesh.rotation.z());
}
window.render(&camera, entities);
var center = V2f32.init(window.widthf / 2, window.heightf / 2);
window.drawPointV2f32(center, ColorU8.White);
window.present();
entities[0].mesh.rotation = entities[0].mesh.rotation.add(&movement);
if (timer.read() > end_time) break;
}
}
test "window.keyctrl.triangle" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 1000, 1000, "testWindow");
defer window.deinit();
// Black background color
window.setBgColor(ColorU8.Black);
// Triangle
var mesh: Mesh = try Mesh.init(pAllocator, "triangle", 3, 1);
defer mesh.deinit();
mesh.vertices[0] = Vertex.init(0, 1, 0);
mesh.vertices[1] = Vertex.init(-1, -1, 0);
mesh.vertices[2] = Vertex.init(0.5, -0.5, 0);
mesh.faces[0] = Face.initComputeNormal(mesh.vertices, 0, 1, 2);
var entities = []Entity{Entity{
.texture = null,
.mesh = mesh,
}};
keyCtrlEntities(&window, RenderMode.Points, entities[0..], !DBG);
}
test "window.keyctrl.cube" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 1000, 1000, "render.cube");
defer window.deinit();
var file_name = "src/modules/3d-test-resources/cube.babylon";
var tree = try parseJsonFile(pAllocator, file_name);
defer tree.deinit();
var mesh = try createMeshFromBabylonJson(pAllocator, "cube", tree);
defer mesh.deinit();
assert(std.mem.eql(u8, mesh.name, "cube"));
var entities = []Entity{Entity{
.texture = null,
.mesh = mesh,
}};
keyCtrlEntities(&window, RenderMode.Points, entities[0..], !DBG);
}
test "window.keyctrl.pyramid" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 1000, 1000, "testWindow");
defer window.deinit();
// Black background color
window.setBgColor(ColorU8.Black);
var file_name = "src/modules/3d-test-resources/pyramid.babylon";
var tree = try parseJsonFile(pAllocator, file_name);
defer tree.deinit();
var mesh = try createMeshFromBabylonJson(pAllocator, "pyramid", tree);
defer mesh.deinit();
assert(std.mem.eql(u8, mesh.name, "pyramid"));
var texture = Texture.init(pAllocator);
defer texture.deinit();
try texture.loadFile("src/modules/3d-test-resources/bricks2.jpg");
var entities = []Entity{Entity{
.texture = texture, //null,
.mesh = mesh,
}};
keyCtrlEntities(&window, RenderMode.Triangles, entities[0..], !DBG);
}
test "window.keyctrl.tilted.pyramid" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 1000, 1000, "testWindow");
defer window.deinit();
// Black background color
window.setBgColor(ColorU8.Black);
var file_name = "src/modules/3d-test-resources/tilted-pyramid.babylon";
var tree = try parseJsonFile(pAllocator, file_name);
defer tree.deinit();
var mesh = try createMeshFromBabylonJson(pAllocator, "pyramid", tree);
defer mesh.deinit();
assert(std.mem.eql(u8, mesh.name, "pyramid"));
var entities = []Entity{Entity{
.texture = null,
.mesh = mesh,
}};
keyCtrlEntities(&window, RenderMode.Triangles, entities[0..], !DBG);
}
test "window.keyctrl.suzanne" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 1000, 1000, "testWindow");
defer window.deinit();
// Black background color
window.setBgColor(ColorU8.Black);
var file_name = "src/modules/3d-test-resources/suzanne.babylon";
var tree = try parseJsonFile(pAllocator, file_name);
defer tree.deinit();
var mesh = try createMeshFromBabylonJson(pAllocator, "suzanne", tree);
defer mesh.deinit();
assert(std.mem.eql(u8, mesh.name, "suzanne"));
assert(mesh.vertices.len == 507);
assert(mesh.faces.len == 968);
var entities = []Entity{Entity{
.texture = null,
.mesh = mesh,
}};
keyCtrlEntities(&window, RenderMode.Triangles, entities[0..], !DBG);
}
fn rotate(mod: u16, angles: V3f32, val: f32) V3f32 {
var r = geo.rad(val);
if (DBG_Rotate) warn("rotate: mod={x} angles={} rad(val)={}\n", mod, angles, r);
var new_angles = angles;
if ((mod & gl.KMOD_LCTRL) != 0) {
new_angles = new_angles.add(&V3f32.init(r, 0, 0));
if (DBG_Rotate) warn("rotate: add X\n");
}
if ((mod & gl.KMOD_LSHIFT) != 0) {
new_angles = new_angles.add(&V3f32.init(0, r, 0));
if (DBG_Rotate) warn("rotate: add Y\n");
}
if ((mod & gl.KMOD_RCTRL) != 0) {
new_angles = new_angles.add(&V3f32.init(0, 0, r));
if (DBG_Rotate) warn("rotate: add Z\n");
}
if (DBG_Rotate and !angles.approxEql(&new_angles, 4)) {
warn("rotate: new_angles={}\n", new_angles);
}
return new_angles;
}
fn translate(mod: u16, pos: V3f32, val: f32) V3f32 {
if (DBG_Translate) warn("translate: pos={}\n", pos);
var new_pos = pos;
if ((mod & gl.KMOD_LCTRL) != 0) {
new_pos = pos.add(&V3f32.init(val, 0, 0));
if (DBG_Translate) warn("translate: add X\n");
}
if ((mod & gl.KMOD_LSHIFT) != 0) {
new_pos = pos.add(&V3f32.init(0, val, 0));
if (DBG_Translate) warn("translate: add Y\n");
}
if ((mod & gl.KMOD_RCTRL) != 0) {
new_pos = pos.add(&V3f32.init(0, 0, val));
if (DBG_Translate) warn("translate: add Z\n");
}
if (DBG_Translate and !pos.eql(&new_pos)) {
warn("translate: new_pos={}\n", new_pos);
}
return new_pos;
}
fn keyCtrlEntities(pWindow: *Window, renderMode: RenderMode, entities: []Entity, presentOnly: bool) void {
const FocusType = enum {
Camera,
Object,
};
var focus = FocusType.Object;
var camera_position = V3f32.init(0, 0, -5);
var camera_target = V3f32.init(0, 0, 0);
var camera = Camera.init(camera_position, camera_target);
if (presentOnly) {
pWindow.clear();
pWindow.renderUsingMode(renderMode, &camera, entities[0..], true);
pWindow.present();
} else {
done: while (true) {
// Update the display
pWindow.clear();
var center = V2f32.init(pWindow.widthf / 2, pWindow.heightf / 2);
pWindow.drawPointV2f32(center, ColorU8.White);
if (DBG_RenderUsingModeWaitForKey) {
pWindow.present();
}
if (DBG1) warn("camera={}\n", &camera.position);
if (DBG1) warn("rotation={}\n", entities[0].mesh.rotation);
pWindow.renderUsingMode(renderMode, &camera, entities[0..], true);
pWindow.present();
// Wait for a key
var ks = ki.waitForKey("keyCtrlEntities", false, false);
// Process the key
// Check if changing focus
switch (ks.code) {
gl.SDLK_ESCAPE => break :done,
gl.SDLK_c => {
focus = FocusType.Camera;
if (DBG) warn("focus = Camera");
},
gl.SDLK_o => {
focus = FocusType.Object;
if (DBG) warn("focus = Object");
},
else => {},
}
if (focus == FocusType.Object) {
// Process for Object
switch (ks.code) {
gl.SDLK_LEFT => entities[0].mesh.rotation = rotate(ks.mod, entities[0].mesh.rotation, f32(15)),
gl.SDLK_RIGHT => entities[0].mesh.rotation = rotate(ks.mod, entities[0].mesh.rotation, -f32(15)),
gl.SDLK_UP => entities[0].mesh.position = translate(ks.mod, entities[0].mesh.position, f32(1)),
gl.SDLK_DOWN => entities[0].mesh.position = translate(ks.mod, entities[0].mesh.position, -f32(1)),
else => {},
}
}
if (focus == FocusType.Camera) {
// Process for Camera
switch (ks.code) {
gl.SDLK_LEFT => camera.target = rotate(ks.mod, camera.target, f32(15)),
gl.SDLK_RIGHT => camera.target = rotate(ks.mod, camera.target, -f32(15)),
gl.SDLK_UP => camera.position = translate(ks.mod, camera.position, f32(1)),
gl.SDLK_DOWN => camera.position = translate(ks.mod, camera.position, -f32(1)),
else => {},
}
}
}
}
}
test "window.bm.suzanne" {
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 1000, 1000, "testWindow");
defer window.deinit();
// Black background color
window.setBgColor(ColorU8.Black);
var file_name = "src/modules/3d-test-resources/suzanne.babylon";
var tree = try parseJsonFile(pAllocator, file_name);
defer tree.deinit();
var mesh = try createMeshFromBabylonJson(pAllocator, "suzanne", tree);
defer mesh.deinit();
assert(std.mem.eql(u8, mesh.name, "suzanne"));
assert(mesh.vertices.len == 507);
assert(mesh.faces.len == 968);
var durationInMs: u64 = 1000;
var entities = []Entity{Entity{
.texture = null,
.mesh = mesh,
}};
var loops = try timeRenderer(&window, durationInMs, RenderMode.Triangles, entities[0..]);
var fps: f32 = @intToFloat(f32, loops * time.ms_per_s) / @intToFloat(f32, durationInMs);
warn("\nwindow.bm.suzanne: fps={.5}\n", fps);
}
fn timeRenderer(pWindow: *Window, durationInMs: u64, renderMode: RenderMode, entities: []Entity) !u64 {
var camera_position = V3f32.init(0, 0, -5);
var camera_target = V3f32.init(0, 0, 0);
var camera = Camera.init(camera_position, camera_target);
// Loop until end_time is reached but always loop once :)
var msf: u64 = time.ns_per_s / time.ms_per_s;
var timer = try time.Timer.start();
var end_time: u64 = timer.read() + (durationInMs * msf);
var loops: u64 = 0;
while (true) {
loops = loops + 1;
// Render into a cleared screen
pWindow.clear();
pWindow.renderUsingMode(renderMode, &camera, entities[0..], true);
// Disable presenting as it limits framerate
//pWindow.present();
// Rotate entities[0] around Y axis
var rotation = geo.degToRad(f32(1));
var rotationVec = V3f32.init(0, rotation, 0);
entities[0].mesh.rotation = entities[0].mesh.rotation.add(&rotationVec);
if (timer.read() > end_time) break;
}
return loops;
}
const ft2 = @import("modules/zig-freetype2/freetype2.zig");
const CHAR_SIZE: usize = 14; // 14 "points" for character size
const DPI: usize = 140; // dots per inch of my display
fn ft_bitmapToTexture(texture: *Texture, bitmap: *ft2.FT_Bitmap, x: usize, y: usize, color: ColorU8, background: ColorU8) void {
var i: usize = 0;
var j: usize = 0;
var p: usize = 0;
var q: usize = 0;
var glyph_width: usize = @intCast(usize, bitmap.width);
var glyph_height: usize = @intCast(usize, bitmap.rows);
var x_max: usize = x + glyph_width;
var y_max: usize = y + glyph_height;
if (DBG_ft_bitmapToTexture)
warn("ft_bitmapToTexture: x={} y={} x_max={} y_max={} glyph_width={} glyph_height={} buffer={*}\n", x, y, x_max, y_max, glyph_width, glyph_height, bitmap.buffer);
i = x;
p = 0;
while (i < x_max) {
j = y;
q = 0;
while (j < y_max) {
if ((i >= 0) and (j >= 0) and (i < texture.width) and (j < texture.height)) {
var idx: usize = @intCast(usize, (q * glyph_width) + p);
if (bitmap.buffer == null) return;
// From http://web.comhem.se/~u34598116/content/FreeType2/main.html
var ptr: *u8 = @intToPtr(*u8, @ptrToInt(bitmap.buffer.?) + idx);
var opacity: f32 = @intToFloat(f32, ptr.*) / 255.0;
var r: u8 = undefined;
var g: u8 = undefined;
var b: u8 = undefined;
var c = background;
if (opacity > 0) {
r = @floatToInt(u8, (@intToFloat(f32, color.r) * opacity) + ((f32(1.0) - opacity) * @intToFloat(f32, background.r)));
g = @floatToInt(u8, (@intToFloat(f32, color.g) * opacity) + ((f32(1.0) - opacity) * @intToFloat(f32, background.g)));
b = @floatToInt(u8, (@intToFloat(f32, color.b) * opacity) + ((f32(1.0) - opacity) * @intToFloat(f32, background.b)));
c = ColorU8.init(color.a, r, g, b);
if (DBG_ft_bitmapToTexture) warn("<[{},{}]={.2}:{}> ", j, i, opacity, b);
}
texture.pixels.?[(j * texture.width) + i] = c;
}
j += 1;
q += 1;
}
if (DBG_ft_bitmapToTexture) warn("\n");
i += 1;
p += 1;
}
}
fn showTexture(window: *Window, texture: *Texture) void {
var y: usize = 0;
while (y < texture.height) : (y += 1) {
var x: usize = 0;
while (x < texture.width) : (x += 1) {
var color = texture.pixels.?[(y * texture.width) + x];
window.drawPointXy(@intCast(isize, x), @intCast(isize, y), color);
}
}
window.present();
}
test "test-freetype2" {
// Based on https://www.freetype.org/freetype2/docs/tutorial/example1.c
// Init Window
var direct_allocator = std.heap.DirectAllocator.init();
var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena_allocator.deinit();
var pAllocator = &arena_allocator.allocator;
var window = try Window.init(pAllocator, 1024, 1024, "testWindow");
defer window.deinit();
// Create a plane to write on.
var mesh = try Mesh.init(pAllocator, "square", 4, 2);
defer mesh.deinit();
assert(std.mem.eql(u8, mesh.name, "square"));
assert(mesh.vertices.len == 4);
assert(mesh.faces.len == 2);
// Position and orient the Mesh
mesh.position.set(0, 0, 0);
mesh.rotation.set(0, 0, 0);
// upside down triangle
//-1,1 1,1
// _____
// | /|
// | / |
// | / |
// | / |
// |/ |
// _____
// -1,-1 1,-1
mesh.vertices[0] = Vertex.init(-1, 1, 0);
mesh.vertices[1] = Vertex.init(1, 1, 0);
mesh.vertices[2] = Vertex.init(-1, -1, 0);
mesh.vertices[3] = Vertex.init(1, -1, 0);
// Compute the normal for the face and since both faces
// are in the same plane the normal is the same.
var normal = geo.computeFaceNormal(mesh.vertices, 0, 1, 2);
// Define the two faces and since this is a planeand the face normal is the same for both
mesh.faces[0] = geo.Face.init(0, 1, 2, normal);
mesh.faces[1] = geo.Face.init(1, 3, 2, normal);
// In addition, since this is a plane all the vertice normals are the same as the face normal
mesh.vertices[0].normal_coord = normal;
mesh.vertices[1].normal_coord = normal;
mesh.vertices[2].normal_coord = normal;
mesh.vertices[3].normal_coord = normal;
// The texture_coord is a unit square and we map to the two triangles
// "L" and "R":
// 0,0 1,0
// _____
// | /|
// | L / |
// | / |
// | / R |
// |/ |
// _______
// 0,1 1,1
mesh.vertices[0].texture_coord = V2f32.init(0, 0); // -1, 1
mesh.vertices[1].texture_coord = V2f32.init(1, 0); // 1, 1
mesh.vertices[2].texture_coord = V2f32.init(0, 1); // -1,-1
mesh.vertices[3].texture_coord = V2f32.init(1, 1); // 1,-1
// Setup parameters
// Filename for font
const cfilename = c"src/modules/3d-test-resources/liberation-fonts-ttf-2.00.4/LiberationMono-Regular.ttf";
// Convert Rotate angle in radians for font
var angleInDegrees = f64(0.0);
var angle = (angleInDegrees / 360.0) * math.pi * 2.0;
// Text to display
var text = "abcdefghijklmnopqrstuvwxyz";
// Init FT library
var pLibrary: ?*ft2.FT_Library = undefined;
assert(ft2.FT_Init_FreeType(&pLibrary) == 0);
defer assert(ft2.FT_Done_FreeType(pLibrary) == 0);
// Load a type face
var pFace: ?*ft2.FT_Face = undefined;
assert(ft2.FT_New_Face(pLibrary, cfilename, 0, &pFace) == 0);
defer assert(ft2.FT_Done_Face(pFace) == 0);
// Set character size
assert(ft2.FT_Set_Char_Size(pFace, ft2.fixed26_6(CHAR_SIZE, 0), 0, DPI, DPI) == 0);
// Setup matrix
var matrix: ft2.FT_Matrix = undefined;
matrix.xx = ft2.f64_fixed16_16(math.cos(angle));
matrix.xy = ft2.f64_fixed16_16(-math.sin(angle));
matrix.yx = ft2.f64_fixed16_16(math.sin(angle));
matrix.yy = ft2.f64_fixed16_16(math.cos(angle));
// Setup pen location
var pen: ft2.FT_Vector = undefined;
pen.x = ft2.f64_fixed26_6(5); // x = 5 points from left side
pen.y = ft2.f64_fixed26_6(CHAR_SIZE); // y = CHAR_SIZE in points from top
// Create and Initialize texture
var texture = try Texture.initPixels(pAllocator, 600, 600, ColorU8.White);
// Loop to print characters to texture
var slot: *ft2.FT_GlyphSlot = (pFace.?.glyph) orelse return error.NoGlyphSlot;
var n: usize = 0;
while (n < text.len) : (n += 1) {
// Setup transform
ft2.FT_Set_Transform(pFace, &matrix, &pen);
// Load glyph image into slot
assert(ft2.FT_Load_Char(pFace, text[n], ft2.FT_LOAD_RENDER) == 0);
if (DBG) {
warn("{c} position: left={} top={} width={} rows={} pitch={} adv_x={} hAdv={} hBearingX=={}\n", text[n], slot.bitmap_left, slot.bitmap_top, slot.bitmap.width, slot.bitmap.rows, slot.bitmap.pitch, slot.advance.x, slot.metrics.horiAdvance, slot.metrics.horiBearingX);
}
// Draw the character at top of texture
var line_spacing: usize = 50; // > Maximum "top" of character
ft_bitmapToTexture(&texture, &slot.bitmap, @intCast(usize, slot.bitmap_left), (6 * line_spacing) - @intCast(usize, slot.bitmap_top), ColorU8.Black, ColorU8.White);
// Move the pen
pen.x += slot.advance.x;
pen.y += slot.advance.y;
}
// Setup camera
var camera_position = V3f32.init(0, 0, -5);
var camera_target = V3f32.initVal(0);
var camera = Camera.init(camera_position, camera_target);
// background color
window.setBgColor(ColorU8.Black);
window.clear();
var entity = Entity{
.texture = texture,
.mesh = mesh,
};
var entities = []Entity{entity};
//showTexture(&window, &texture);
// Render any entities but I do NOT need to negate_tnz
window.renderUsingMode(RenderMode.Triangles, &camera, entities, false);
window.present();
if (DBG) {
ki.waitForEsc("Prese ESC to stop");
}
}
|
0 | repos/zig-3d-soft-engine | repos/zig-3d-soft-engine/src/input_events.zig | const builtin = @import("builtin");
const std = @import("std");
const mem = std.mem;
const assert = std.debug.assert;
const warn = std.debug.warn;
const gl = @import("modules/zig-sdl2/src/index.zig");
pub const EventResult = enum {
NoEvents,
Continue,
Quit,
};
pub const EventInterface = struct {
event: gl.SDL_Event,
handleKeyEvent: fn (pThing: *c_void, event: *gl.SDL_Event) EventResult,
handleMouseEvent: fn (pThing: *c_void, event: *gl.SDL_Event) EventResult,
handleOtherEvent: fn (pThing: *c_void, event: *gl.SDL_Event) EventResult,
};
pub fn processEvent(pThing: *c_void, pEi: *EventInterface, event: *gl.SDL_Event) EventResult {
switch (event.type) {
gl.SDL_QUIT => {
return EventResult.Quit;
},
gl.SDL_KEYUP, gl.SDL_KEYDOWN => |et| {
return pEi.handleKeyEvent(pThing, event);
},
gl.SDL_MOUSEBUTTONUP, gl.SDL_MOUSEBUTTONDOWN, gl.SDL_MOUSEMOTION => |et| {
return pEi.handleMouseEvent(pThing, event);
},
else => return pEi.handleOtherEvent(pThing, event),
}
}
pub fn pollInputEvent(pThing: *c_void, pEi: *EventInterface) EventResult {
var event: gl.SDL_Event = undefined;
if (gl.SDL_PollEvent(&event) == 0) return EventResult.NoEvents;
return processEvent(pThing, pEi, &event);
}
// Test
fn handleKeyEvent(pThing: *c_void, event: *gl.SDL_Event) EventResult {
var pMyThing: *Thing = @intToPtr(*Thing, @ptrToInt(pThing));
pMyThing.key_count += 1;
return EventResult.Continue;
}
fn handleMouseEvent(pThing: *c_void, event: *gl.SDL_Event) EventResult {
var pMyThing: *Thing = @intToPtr(*Thing, @ptrToInt(pThing));
pMyThing.mouse_count += 1;
return EventResult.Continue;
}
fn handleOtherEvent(pThing: *c_void, event: *gl.SDL_Event) EventResult {
var pMyThing: *Thing = @intToPtr(*Thing, @ptrToInt(pThing));
pMyThing.other_count += 1;
return EventResult.Continue;
}
const Thing = struct {
key_count: usize,
mouse_count: usize,
other_count: usize,
};
test "inputEvents" {
var thing = Thing{
.key_count = 0,
.mouse_count = 0,
.other_count = 0,
};
var ei = EventInterface{
.event = undefined,
.handleKeyEvent = handleKeyEvent,
.handleMouseEvent = handleMouseEvent,
.handleOtherEvent = handleOtherEvent,
};
var event: gl.SDL_Event = undefined;
event.type = gl.SDL_KEYDOWN;
assert(processEvent(&thing, &ei, &event) == EventResult.Continue);
assert(thing.key_count == 1);
event.type = gl.SDL_KEYUP;
assert(processEvent(&thing, &ei, &event) == EventResult.Continue);
assert(thing.key_count == 2);
event.type = gl.SDL_MOUSEBUTTONDOWN;
assert(processEvent(&thing, &ei, &event) == EventResult.Continue);
assert(thing.mouse_count == 1);
event.type = gl.SDL_MOUSEBUTTONUP;
assert(processEvent(&thing, &ei, &event) == EventResult.Continue);
assert(thing.mouse_count == 2);
event.type = gl.SDL_MOUSEMOTION;
assert(processEvent(&thing, &ei, &event) == EventResult.Continue);
assert(thing.mouse_count == 3);
}
|
0 | repos | repos/hyperzig/README.md | # HyperZig - A Hypergraph Implementation in Zig

HyperZig is a directed hypergraph implementation in Zig (https://en.wikipedia.org/wiki/Hypergraph):
- Each hyperedge can contain zero, one (unary) or multiple vertices.
- Each hyperedge can contain vertices directed to themselves one or more times.
## Usage
Add `hyperzig` as a dependency to your `build.zig.zon`:
```sh
zig fetch --save https://github.com/yamafaktory/hyperzig/archive/<commit-hash>.tar.gz
```
Add `hyperzig` as a dependency to your `build.zig`:
```zig
const hyperzig = b.dependency("hyperzig", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("hyperzig", hyperzig.module("hyperzig"));
```
## Documentation
The latest online documentation can be found [here](https://yamafaktory.github.io/hyperzig/).
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.