mirror of
https://ghproxy.net/https://github.com/abhijitb/helix.git
synced 2025-08-27 15:33:37 +08:00
Initial commit
This commit is contained in:
commit
153a4e9fd7
345 changed files with 359185 additions and 0 deletions
146
README.md
Normal file
146
README.md
Normal file
|
@ -0,0 +1,146 @@
|
|||
|
||||
# ⚛️ Helix – A Modern WordPress Admin UI
|
||||
|
||||
Helix is a fully custom, React-powered replacement for the default WordPress admin (`wp-admin`). Designed for speed, simplicity, and extensibility, Helix provides a clean and intuitive interface for managing your WordPress site.
|
||||
|
||||
> Think of it as **your own WordPress control panel**, built for modern needs — with optional 2FA, global settings access, and a modular React interface.
|
||||
|
||||
---
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- 🚀 Full React-based SPA admin interface (built with Vite)
|
||||
- ⚙️ Modular settings panels (site language, title, etc.)
|
||||
- 🔐 Optional two-factor authentication (per user)
|
||||
- 🔁 Full override of `wp-admin` via redirect
|
||||
- 📡 Custom REST API endpoints for settings and control
|
||||
- 🧩 Easily extendable with new components and admin pages
|
||||
|
||||
---
|
||||
|
||||
## 🗂️ Directory Structure
|
||||
|
||||
```
|
||||
helix/
|
||||
├── helix.php # Plugin entry point
|
||||
├── admin/ # PHP admin logic
|
||||
│ ├── init.php # Registers custom admin page
|
||||
│ ├── rest-routes.php # Defines REST API endpoints
|
||||
│ └── disable-wp-admin.php # Redirects all wp-admin traffic
|
||||
├── build/ # Compiled Vite build (output)
|
||||
├── src/ # React source
|
||||
│ ├── App.jsx # Root SPA app
|
||||
│ ├── pages/ # Modular page views
|
||||
│ ├── components/ # Reusable UI components
|
||||
│ └── features/ # Feature modules (e.g. 2FA)
|
||||
├── enqueue.php # Enqueues the SPA in WP
|
||||
├── vite.config.js # Vite build config
|
||||
├── package.json # JS dependencies & scripts
|
||||
└── README.md # You are here!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Getting Started
|
||||
|
||||
### 1. Install & Activate the Plugin
|
||||
|
||||
- Download and unzip into `wp-content/plugins/helix`
|
||||
- Or upload the ZIP via the WordPress admin panel
|
||||
- Activate the **Helix** plugin
|
||||
|
||||
### 2. Build the React App
|
||||
|
||||
Helix uses [Vite](https://vitejs.dev/) for fast frontend development and builds.
|
||||
|
||||
```bash
|
||||
# Navigate to the plugin directory
|
||||
cd wp-content/plugins/helix
|
||||
|
||||
# Install dependencies
|
||||
npm install
|
||||
|
||||
# Build the production app
|
||||
npm run build
|
||||
```
|
||||
|
||||
This will output the React SPA to the `/build` directory, which WordPress loads automatically.
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Development Mode
|
||||
|
||||
To run Vite in development with hot module reload:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
> Optional: You can proxy WordPress via Vite or use BrowserSync for live updates.
|
||||
|
||||
---
|
||||
|
||||
## 🧱 Plugin Hooks & REST API
|
||||
|
||||
### Custom Admin Page
|
||||
The plugin registers a new admin page at:
|
||||
|
||||
```
|
||||
/wp-admin/admin.php?page=helix
|
||||
```
|
||||
|
||||
It becomes the new dashboard and **replaces** `wp-admin`.
|
||||
|
||||
### Redirecting wp-admin
|
||||
All standard `wp-admin` pages (except Helix) redirect to the custom React UI.
|
||||
|
||||
### REST API Example
|
||||
Custom REST route to fetch site settings:
|
||||
|
||||
```
|
||||
GET /wp-json/helix/v1/settings
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Optional 2FA
|
||||
|
||||
Helix includes a basic architecture for optional **Two-Factor Authentication (TOTP)**:
|
||||
|
||||
- Each user can enable/disable 2FA in their settings.
|
||||
- Secrets are stored securely in `user_meta`.
|
||||
- Validation can be added via `wp_login` or custom middleware.
|
||||
|
||||
---
|
||||
|
||||
## 📦 Scripts
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `npm run dev` | Start Vite dev server |
|
||||
| `npm run build` | Build production assets |
|
||||
| `npm install` | Install dependencies |
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ To Do / Ideas
|
||||
|
||||
- [ ] Post and Page Manager (custom list views)
|
||||
- [ ] Media Library replacement
|
||||
- [ ] User & Role Manager
|
||||
- [ ] Live preview / content sync
|
||||
- [ ] Theming system (Light/Dark)
|
||||
- [ ] Accessibility support
|
||||
|
||||
---
|
||||
|
||||
## 📄 License
|
||||
|
||||
MIT License – Customize, extend, and rebrand as you see fit.
|
||||
|
||||
---
|
||||
|
||||
## ✍️ Author
|
||||
|
||||
Built by Acecoder
|
||||
Feel free to reach out with contributions or questions!
|
7
admin/disable-wp-admin.php
Normal file
7
admin/disable-wp-admin.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
add_action('admin_init', function () {
|
||||
$screen = get_current_screen();
|
||||
if (!is_admin() || $screen->id === 'toplevel_page_helix') return;
|
||||
wp_redirect(admin_url('admin.php?page=helix'));
|
||||
exit;
|
||||
});
|
6
admin/init.php
Normal file
6
admin/init.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
add_action('admin_menu', function () {
|
||||
add_menu_page('Helix', 'Helix', 'read', 'helix', function () {
|
||||
echo '<div id="helix-root"></div>';
|
||||
}, 'dashicons-admin-generic', 2);
|
||||
});
|
13
admin/rest-routes.php
Normal file
13
admin/rest-routes.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
add_action('rest_api_init', function () {
|
||||
register_rest_route('helix/v1', '/settings', [
|
||||
'methods' => 'GET',
|
||||
'permission_callback' => '__return_true',
|
||||
'callback' => function () {
|
||||
return [
|
||||
'siteTitle' => get_option('blogname'),
|
||||
'language' => get_option('WPLANG'),
|
||||
];
|
||||
}
|
||||
]);
|
||||
});
|
11
enqueue.php
Normal file
11
enqueue.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
add_action('admin_enqueue_scripts', function ($hook) {
|
||||
if ($hook !== 'toplevel_page_helix') return;
|
||||
|
||||
wp_enqueue_script('helix-app', plugin_dir_url(__FILE__) . 'build/index.js', [], null, true);
|
||||
wp_localize_script('helix-app', 'helixData', [
|
||||
'restUrl' => esc_url_raw(rest_url('helix/v1/')),
|
||||
'nonce' => wp_create_nonce('wp_rest'),
|
||||
'user' => wp_get_current_user(),
|
||||
]);
|
||||
});
|
12
helix.php
Normal file
12
helix.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: Helix – Modern WP Admin
|
||||
Description: A React-powered replacement for the WordPress admin UI.
|
||||
Version: 0.1.0
|
||||
Author: Your Name
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/admin/init.php';
|
||||
require_once __DIR__ . '/admin/rest-routes.php';
|
||||
require_once __DIR__ . '/admin/disable-wp-admin.php';
|
||||
require_once __DIR__ . '/enqueue.php';
|
1
node_modules/.bin/esbuild
generated
vendored
Symbolic link
1
node_modules/.bin/esbuild
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../esbuild/bin/esbuild
|
1
node_modules/.bin/loose-envify
generated
vendored
Symbolic link
1
node_modules/.bin/loose-envify
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../loose-envify/cli.js
|
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nanoid/bin/nanoid.cjs
|
1
node_modules/.bin/rollup
generated
vendored
Symbolic link
1
node_modules/.bin/rollup
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../rollup/dist/bin/rollup
|
1
node_modules/.bin/vite
generated
vendored
Symbolic link
1
node_modules/.bin/vite
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../vite/bin/vite.js
|
1040
node_modules/.package-lock.json
generated
vendored
Normal file
1040
node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
3
node_modules/@esbuild/darwin-arm64/README.md
generated
vendored
Normal file
3
node_modules/@esbuild/darwin-arm64/README.md
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# esbuild
|
||||
|
||||
This is the macOS ARM 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
BIN
node_modules/@esbuild/darwin-arm64/bin/esbuild
generated
vendored
Executable file
BIN
node_modules/@esbuild/darwin-arm64/bin/esbuild
generated
vendored
Executable file
Binary file not shown.
20
node_modules/@esbuild/darwin-arm64/package.json
generated
vendored
Normal file
20
node_modules/@esbuild/darwin-arm64/package.json
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "@esbuild/darwin-arm64",
|
||||
"version": "0.21.5",
|
||||
"description": "The macOS ARM 64-bit binary for esbuild, a JavaScript bundler.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/evanw/esbuild.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"preferUnplugged": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
]
|
||||
}
|
888
node_modules/@remix-run/router/CHANGELOG.md
generated
vendored
Normal file
888
node_modules/@remix-run/router/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,888 @@
|
|||
# `@remix-run/router`
|
||||
|
||||
## 1.23.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add `fetcherKey` as a parameter to `patchRoutesOnNavigation` ([#13109](https://github.com/remix-run/react-router/pull/13109))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix regression introduced in `6.29.0` via [#12169](https://github.com/remix-run/react-router/pull/12169) that caused issues navigating to hash routes inside splat routes for applications using Lazy Route Discovery (`patchRoutesOnNavigation`) ([#13108](https://github.com/remix-run/react-router/pull/13108))
|
||||
|
||||
## 1.22.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Provide the request `signal` as a parameter to `patchRoutesOnNavigation` ([#12900](https://github.com/remix-run/react-router/pull/12900))
|
||||
|
||||
- This can be used to abort any manifest fetches if the in-flight navigation/fetcher is aborted
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Do not log v7 deprecation warnings in production builds ([#12794](https://github.com/remix-run/react-router/pull/12794))
|
||||
- Strip search parameters from `patchRoutesOnNavigation` `path` param for fetcher calls ([#12899](https://github.com/remix-run/react-router/pull/12899))
|
||||
- Properly bubble headers when throwing a `data()` result ([#12845](https://github.com/remix-run/react-router/pull/12845))
|
||||
- Optimize route matching by skipping redundant `matchRoutes` calls when possible ([#12169](https://github.com/remix-run/react-router/pull/12169))
|
||||
|
||||
## 1.21.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- - Fix issue with fetcher data cleanup in the data layer on fetcher unmount ([#12674](https://github.com/remix-run/react-router/pull/12674))
|
||||
- Fix behavior of manual fetcher keys when not opted into `future.v7_fetcherPersist`
|
||||
|
||||
## 1.21.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- - Log deprecation warnings for v7 flags ([#11750](https://github.com/remix-run/react-router/pull/11750))
|
||||
- Add deprecation warnings to `json`/`defer` in favor of returning raw objects
|
||||
- These methods will be removed in React Router v7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update JSDoc URLs for new website structure (add /v6/ segment) ([#12141](https://github.com/remix-run/react-router/pull/12141))
|
||||
|
||||
## 1.20.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Stabilize `unstable_patchRoutesOnNavigation` ([#11973](https://github.com/remix-run/react-router/pull/11973))
|
||||
- Add new `PatchRoutesOnNavigationFunctionArgs` type for convenience ([#11967](https://github.com/remix-run/react-router/pull/11967))
|
||||
- Stabilize `unstable_dataStrategy` ([#11974](https://github.com/remix-run/react-router/pull/11974))
|
||||
- Stabilize the `unstable_flushSync` option for navigations and fetchers ([#11989](https://github.com/remix-run/react-router/pull/11989))
|
||||
- Stabilize the `unstable_viewTransition` option for navigations and the corresponding `unstable_useViewTransitionState` hook ([#11989](https://github.com/remix-run/react-router/pull/11989))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix bug when submitting to the current contextual route (parent route with an index child) when an `?index` param already exists from a prior submission ([#12003](https://github.com/remix-run/react-router/pull/12003))
|
||||
- Fix `useFormAction` bug - when removing `?index` param it would not keep other non-Remix `index` params ([#12003](https://github.com/remix-run/react-router/pull/12003))
|
||||
- Fix bug with fetchers not persisting `preventScrollReset` through redirects during concurrent fetches ([#11999](https://github.com/remix-run/react-router/pull/11999))
|
||||
- Remove internal cache to fix issues with interrupted `patchRoutesOnNavigation` calls ([#12055](https://github.com/remix-run/react-router/pull/12055))
|
||||
- We used to cache in-progress calls to `patchRoutesOnNavigation` internally so that multiple navigations with the same start/end would only execute the function once and use the same promise
|
||||
- However, this approach was at odds with `patch` short circuiting if a navigation was interrupted (and the `request.signal` aborted) since the first invocation's `patch` would no-op
|
||||
- This cache also made some assumptions as to what a valid cache key might be - and is oblivious to any other application-state changes that may have occurred
|
||||
- So, the cache has been removed because in _most_ cases, repeated calls to something like `import()` for async routes will already be cached automatically - and if not it's easy enough for users to implement this cache in userland
|
||||
- Avoid unnecessary `console.error` on fetcher abort due to back-to-back revalidation calls ([#12050](https://github.com/remix-run/react-router/pull/12050))
|
||||
- Expose errors thrown from `patchRoutesOnNavigation` directly to `useRouteError` instead of wrapping them in a 400 `ErrorResponse` instance ([#12111](https://github.com/remix-run/react-router/pull/12111))
|
||||
- Fix types for `RouteObject` within `PatchRoutesOnNavigationFunction`'s `patch` method so it doesn't expect agnostic route objects passed to `patch` ([#11967](https://github.com/remix-run/react-router/pull/11967))
|
||||
- Fix bugs with `partialHydration` when hydrating with errors ([#12070](https://github.com/remix-run/react-router/pull/12070))
|
||||
- Remove internal `discoveredRoutes` FIFO queue from `unstable_patchRoutesOnNavigation` ([#11977](https://github.com/remix-run/react-router/pull/11977))
|
||||
|
||||
## 1.19.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update the `unstable_dataStrategy` API to allow for more advanced implementations ([#11943](https://github.com/remix-run/react-router/pull/11943))
|
||||
- Rename `unstable_HandlerResult` to `unstable_DataStrategyResult`
|
||||
- The return signature has changed from a parallel array of `unstable_DataStrategyResult[]` (parallel to `matches`) to a key/value object of `routeId => unstable_DataStrategyResult`
|
||||
- This allows you to more easily decide to opt-into or out-of revalidating data that may not have been revalidated by default (via `match.shouldLoad`)
|
||||
- ⚠️ This is a breaking change if you've currently adopted `unstable_dataStrategy`
|
||||
- Added a new `fetcherKey` parameter to `unstable_dataStrategy` to allow differentiation from navigational and fetcher calls
|
||||
- You should now return/throw a result from your `handlerOverride` instead of returning a `DataStrategyResult`
|
||||
- If you are aggregating the results of `match.resolve()` into a final results object you should not need to think about the `DataStrategyResult` type
|
||||
- If you are manually filling your results object from within your `handlerOverride`, then you will need to assign a `DataStrategyResult` as the value so React Router knows if it's a successful execution or an error.
|
||||
- Preserve view transition through redirects ([#11925](https://github.com/remix-run/react-router/pull/11925))
|
||||
- Fix blocker usage when `blocker.proceed` is called quickly/synchronously ([#11930](https://github.com/remix-run/react-router/pull/11930))
|
||||
- Preserve pending view transitions through a router revalidation call ([#11917](https://github.com/remix-run/react-router/pull/11917))
|
||||
|
||||
## 1.19.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fog of War: Update `unstable_patchRoutesOnMiss` logic so that we call the method when we match routes with dynamic param or splat segments in case there exists a higher-scoring static route that we've not yet discovered. ([#11883](https://github.com/remix-run/react-router/pull/11883))
|
||||
|
||||
- We also now leverage an internal FIFO queue of previous paths we've already called `unstable_patchRouteOnMiss` against so that we don't re-call on subsequent navigations to the same path
|
||||
|
||||
- Rename `unstable_patchRoutesOnMiss` to `unstable_patchRoutesOnNavigation` to match new behavior ([#11888](https://github.com/remix-run/react-router/pull/11888))
|
||||
|
||||
## 1.19.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add a new `replace(url, init?)` alternative to `redirect(url, init?)` that performs a `history.replaceState` instead of a `history.pushState` on client-side navigation redirects ([#11811](https://github.com/remix-run/react-router/pull/11811))
|
||||
- Add a new `unstable_data()` API for usage with Remix Single Fetch ([#11836](https://github.com/remix-run/react-router/pull/11836))
|
||||
- This API is not intended for direct usage in React Router SPA applications
|
||||
- It is primarily intended for usage with `createStaticHandler.query()` to allow loaders/actions to return arbitrary data + `status`/`headers` without forcing the serialization of data into a `Response` instance
|
||||
- This allows for more advanced serialization tactics via `unstable_dataStrategy` such as serializing via `turbo-stream` in Remix Single Fetch
|
||||
- ⚠️ This removes the `status` field from `HandlerResult`
|
||||
- If you need to return a specific `status` from `unstable_dataStrategy` you should instead do so via `unstable_data()`
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix internal cleanup of interrupted fetchers to avoid invalid revalidations on navigations ([#11839](https://github.com/remix-run/react-router/pull/11839))
|
||||
- When a `fetcher.load` is interrupted by an `action` submission, we track it internally and force revalidation once the `action` completes
|
||||
- We previously only cleared out this internal tracking info on a successful _navigation_ submission
|
||||
- Therefore, if the `fetcher.load` was interrupted by a `fetcher.submit`, then we wouldn't remove it from this internal tracking info on successful load (incorrectly)
|
||||
- And then on the next navigation it's presence in the internal tracking would automatically trigger execution of the `fetcher.load` again, ignoring any `shouldRevalidate` logic
|
||||
- This fix cleans up the internal tracking so it applies to both navigation submission and fetcher submissions
|
||||
- Fix initial hydration behavior when using `future.v7_partialHydration` along with `unstable_patchRoutesOnMiss` ([#11838](https://github.com/remix-run/react-router/pull/11838))
|
||||
- During initial hydration, `router.state.matches` will now include any partial matches so that we can render ancestor `HydrateFallback` components
|
||||
|
||||
## 1.18.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Stabilize `future.unstable_skipActionErrorRevalidation` as `future.v7_skipActionErrorRevalidation` ([#11769](https://github.com/remix-run/react-router/pull/11769))
|
||||
- When this flag is enabled, actions will not automatically trigger a revalidation if they return/throw a `Response` with a `4xx`/`5xx` status code
|
||||
- You may still opt-into revalidation via `shouldRevalidate`
|
||||
- This also changes `shouldRevalidate`'s `unstable_actionStatus` parameter to `actionStatus`
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix bubbling of errors thrown from `unstable_patchRoutesOnMiss` ([#11786](https://github.com/remix-run/react-router/pull/11786))
|
||||
- Fix hydration in SSR apps using `unstable_patchRoutesOnMiss` that matched a splat route on the server ([#11790](https://github.com/remix-run/react-router/pull/11790))
|
||||
|
||||
## 1.17.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fog of War (unstable): Trigger a new `router.routes` identity/reflow during route patching ([#11740](https://github.com/remix-run/react-router/pull/11740))
|
||||
- Fog of War (unstable): Fix initial matching when a splat route matches ([#11759](https://github.com/remix-run/react-router/pull/11759))
|
||||
|
||||
## 1.17.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add support for Lazy Route Discovery (a.k.a. Fog of War) ([#11626](https://github.com/remix-run/react-router/pull/11626))
|
||||
|
||||
- RFC: <https://github.com/remix-run/react-router/discussions/11113>
|
||||
- `unstable_patchRoutesOnMiss` docs: <https://reactrouter.com/v6/routers/create-browser-router>
|
||||
|
||||
## 1.16.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Support `unstable_dataStrategy` on `staticHandler.queryRoute` ([#11515](https://github.com/remix-run/react-router/pull/11515))
|
||||
|
||||
## 1.16.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098))
|
||||
- This option allows Data Router applications to take control over the approach for executing route loaders and actions
|
||||
- The default implementation is today's behavior, to fetch all loaders in parallel, but this option allows users to implement more advanced data flows including Remix single-fetch, middleware/context APIs, automatic loader caching, and more
|
||||
- Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix. It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually. ([#11377](https://github.com/remix-run/react-router/pull/11377))
|
||||
- Add a new `future.unstable_skipActionRevalidation` future flag ([#11098](https://github.com/remix-run/react-router/pull/11098))
|
||||
- Currently, active loaders revalidate after any action, regardless of the result
|
||||
- With this flag enabled, actions that return/throw a 4xx/5xx response status will no longer automatically revalidate
|
||||
- This should reduce load on your server since it's rare that a 4xx/5xx should actually mutate any data
|
||||
- If you need to revalidate after a 4xx/5xx result with this flag enabled, you can still do that via returning `true` from `shouldRevalidate`
|
||||
- `shouldRevalidate` now also receives a new `unstable_actionStatus` argument alongside `actionResult` so you can make decision based on the status of the `action` response without having to encode it into the action data
|
||||
- Added a `skipLoaderErrorBubbling` flag to `staticHandler.query` to disable error bubbling on loader executions for single-fetch scenarios where the client-side router will handle the bubbling ([#11098](https://github.com/remix-run/react-router/pull/11098))
|
||||
|
||||
## 1.15.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix a `future.v7_partialHydration` bug that would re-run loaders below the boundary on hydration if SSR loader errors bubbled to a parent boundary ([#11324](https://github.com/remix-run/react-router/pull/11324))
|
||||
- Fix a `future.v7_partialHydration` bug that would consider the router uninitialized if a route did not have a loader ([#11325](https://github.com/remix-run/react-router/pull/11325))
|
||||
|
||||
## 1.15.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Preserve hydrated errors during partial hydration runs ([#11305](https://github.com/remix-run/react-router/pull/11305))
|
||||
|
||||
## 1.15.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix encoding/decoding issues with pre-encoded dynamic parameter values ([#11199](https://github.com/remix-run/react-router/pull/11199))
|
||||
|
||||
## 1.15.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add a `createStaticHandler` `future.v7_throwAbortReason` flag to throw `request.signal.reason` (defaults to a `DOMException`) when a request is aborted instead of an `Error` such as `new Error("query() call aborted: GET /path")` ([#11104](https://github.com/remix-run/react-router/pull/11104))
|
||||
|
||||
- Please note that `DOMException` was added in Node v17 so you will not get a `DOMException` on Node 16 and below.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Respect the `ErrorResponse` status code if passed to `getStaticContextFormError` ([#11213](https://github.com/remix-run/react-router/pull/11213))
|
||||
|
||||
## 1.14.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix bug where dashes were not picked up in dynamic parameter names ([#11160](https://github.com/remix-run/react-router/pull/11160))
|
||||
- Do not attempt to deserialize empty JSON responses ([#11164](https://github.com/remix-run/react-router/pull/11164))
|
||||
|
||||
## 1.14.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix bug with `route.lazy` not working correctly on initial SPA load when `v7_partialHydration` is specified ([#11121](https://github.com/remix-run/react-router/pull/11121))
|
||||
- Fix bug preventing revalidation from occurring for persisted fetchers unmounted during the `submitting` phase ([#11102](https://github.com/remix-run/react-router/pull/11102))
|
||||
- De-dup relative path logic in `resolveTo` ([#11097](https://github.com/remix-run/react-router/pull/11097))
|
||||
|
||||
## 1.14.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Added a new `future.v7_partialHydration` future flag that enables partial hydration of a data router when Server-Side Rendering. This allows you to provide `hydrationData.loaderData` that has values for _some_ initially matched route loaders, but not all. When this flag is enabled, the router will call `loader` functions for routes that do not have hydration loader data during `router.initialize()`, and it will render down to the deepest provided `HydrateFallback` (up to the first route without hydration data) while it executes the unhydrated routes. ([#11033](https://github.com/remix-run/react-router/pull/11033))
|
||||
|
||||
For example, the following router has a `root` and `index` route, but only provided `hydrationData.loaderData` for the `root` route. Because the `index` route has a `loader`, we need to run that during initialization. With `future.v7_partialHydration` specified, `<RouterProvider>` will render the `RootComponent` (because it has data) and then the `IndexFallback` (since it does not have data). Once `indexLoader` finishes, application will update and display `IndexComponent`.
|
||||
|
||||
```jsx
|
||||
let router = createBrowserRouter(
|
||||
[
|
||||
{
|
||||
id: "root",
|
||||
path: "/",
|
||||
loader: rootLoader,
|
||||
Component: RootComponent,
|
||||
Fallback: RootFallback,
|
||||
children: [
|
||||
{
|
||||
id: "index",
|
||||
index: true,
|
||||
loader: indexLoader,
|
||||
Component: IndexComponent,
|
||||
HydrateFallback: IndexFallback,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
{
|
||||
future: {
|
||||
v7_partialHydration: true,
|
||||
},
|
||||
hydrationData: {
|
||||
loaderData: {
|
||||
root: { message: "Hydrated from Root!" },
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
If the above example did not have an `IndexFallback`, then `RouterProvider` would instead render the `RootFallback` while it executed the `indexLoader`.
|
||||
|
||||
**Note:** When `future.v7_partialHydration` is provided, the `<RouterProvider fallbackElement>` prop is ignored since you can move it to a `Fallback` on your top-most route. The `fallbackElement` prop will be removed in React Router v7 when `v7_partialHydration` behavior becomes the standard behavior.
|
||||
|
||||
- Add a new `future.v7_relativeSplatPath` flag to implement a breaking bug fix to relative routing when inside a splat route. ([#11087](https://github.com/remix-run/react-router/pull/11087))
|
||||
|
||||
This fix was originally added in [#10983](https://github.com/remix-run/react-router/issues/10983) and was later reverted in [#11078](https://github.com/remix-run/react-router/pull/11078) because it was determined that a large number of existing applications were relying on the buggy behavior (see [#11052](https://github.com/remix-run/react-router/issues/11052))
|
||||
|
||||
**The Bug**
|
||||
The buggy behavior is that without this flag, the default behavior when resolving relative paths is to _ignore_ any splat (`*`) portion of the current route path.
|
||||
|
||||
**The Background**
|
||||
This decision was originally made thinking that it would make the concept of nested different sections of your apps in `<Routes>` easier if relative routing would _replace_ the current splat:
|
||||
|
||||
```jsx
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="dashboard/*" element={<Dashboard />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
```
|
||||
|
||||
Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
|
||||
|
||||
```jsx
|
||||
function Dashboard() {
|
||||
return (
|
||||
<div>
|
||||
<h2>Dashboard</h2>
|
||||
<nav>
|
||||
<Link to="/">Dashboard Home</Link>
|
||||
<Link to="team">Team</Link>
|
||||
<Link to="projects">Projects</Link>
|
||||
</nav>
|
||||
|
||||
<Routes>
|
||||
<Route path="/" element={<DashboardHome />} />
|
||||
<Route path="team" element={<DashboardTeam />} />
|
||||
<Route path="projects" element={<DashboardProjects />} />
|
||||
</Routes>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
Now, all links and route paths are relative to the router above them. This makes code splitting and compartmentalizing your app really easy. You could render the `Dashboard` as its own independent app, or embed it into your large app without making any changes to it.
|
||||
|
||||
**The Problem**
|
||||
|
||||
The problem is that this concept of ignoring part of a path breaks a lot of other assumptions in React Router - namely that `"."` always means the current location pathname for that route. When we ignore the splat portion, we start getting invalid paths when using `"."`:
|
||||
|
||||
```jsx
|
||||
// If we are on URL /dashboard/team, and we want to link to /dashboard/team:
|
||||
function DashboardTeam() {
|
||||
// ❌ This is broken and results in <a href="/dashboard">
|
||||
return <Link to=".">A broken link to the Current URL</Link>;
|
||||
|
||||
// ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
|
||||
return <Link to="./team">A broken link to the Current URL</Link>;
|
||||
}
|
||||
```
|
||||
|
||||
We've also introduced an issue that we can no longer move our `DashboardTeam` component around our route hierarchy easily - since it behaves differently if we're underneath a non-splat route, such as `/dashboard/:widget`. Now, our `"."` links will, properly point to ourself _inclusive of the dynamic param value_ so behavior will break from it's corresponding usage in a `/dashboard/*` route.
|
||||
|
||||
Even worse, consider a nested splat route configuration:
|
||||
|
||||
```jsx
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="dashboard">
|
||||
<Route path="*" element={<Dashboard />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
```
|
||||
|
||||
Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
|
||||
|
||||
Another common issue arose in Data Routers (and Remix) where any `<Form>` should post to it's own route `action` if you the user doesn't specify a form action:
|
||||
|
||||
```jsx
|
||||
let router = createBrowserRouter({
|
||||
path: "/dashboard",
|
||||
children: [
|
||||
{
|
||||
path: "*",
|
||||
action: dashboardAction,
|
||||
Component() {
|
||||
// ❌ This form is broken! It throws a 405 error when it submits because
|
||||
// it tries to submit to /dashboard (without the splat value) and the parent
|
||||
// `/dashboard` route doesn't have an action
|
||||
return <Form method="post">...</Form>;
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
This is just a compounded issue from the above because the default location for a `Form` to submit to is itself (`"."`) - and if we ignore the splat portion, that now resolves to the parent route.
|
||||
|
||||
**The Solution**
|
||||
If you are leveraging this behavior, it's recommended to enable the future flag, move your splat to it's own route, and leverage `../` for any links to "sibling" pages:
|
||||
|
||||
```jsx
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="dashboard">
|
||||
<Route index path="*" element={<Dashboard />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
|
||||
function Dashboard() {
|
||||
return (
|
||||
<div>
|
||||
<h2>Dashboard</h2>
|
||||
<nav>
|
||||
<Link to="..">Dashboard Home</Link>
|
||||
<Link to="../team">Team</Link>
|
||||
<Link to="../projects">Projects</Link>
|
||||
</nav>
|
||||
|
||||
<Routes>
|
||||
<Route path="/" element={<DashboardHome />} />
|
||||
<Route path="team" element={<DashboardTeam />} />
|
||||
<Route path="projects" element={<DashboardProjects />} />
|
||||
</Router>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
This way, `.` means "the full current pathname for my route" in all cases (including static, dynamic, and splat routes) and `..` always means "my parents pathname".
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Catch and bubble errors thrown when trying to unwrap responses from `loader`/`action` functions ([#11061](https://github.com/remix-run/react-router/pull/11061))
|
||||
- Fix `relative="path"` issue when rendering `Link`/`NavLink` outside of matched routes ([#11062](https://github.com/remix-run/react-router/pull/11062))
|
||||
|
||||
## 1.13.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see <https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329>). We plan to re-introduce this fix behind a future flag in the next minor version. ([#11078](https://github.com/remix-run/react-router/pull/11078))
|
||||
|
||||
## 1.13.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Export the `PathParam` type from the public API ([#10719](https://github.com/remix-run/react-router/pull/10719))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix bug with `resolveTo` in splat routes ([#11045](https://github.com/remix-run/react-router/pull/11045))
|
||||
- This is a follow up to [#10983](https://github.com/remix-run/react-router/pull/10983) to handle the few other code paths using `getPathContributingMatches`
|
||||
- This removes the `UNSAFE_getPathContributingMatches` export from `@remix-run/router` since we no longer need this in the `react-router`/`react-router-dom` layers
|
||||
- Do not revalidate unmounted fetchers when `v7_fetcherPersist` is enabled ([#11044](https://github.com/remix-run/react-router/pull/11044))
|
||||
|
||||
## 1.12.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add `unstable_flushSync` option to `router.navigate` and `router.fetch` to tell the React Router layer to opt-out of `React.startTransition` and into `ReactDOM.flushSync` for state updates ([#11005](https://github.com/remix-run/react-router/pull/11005))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix `relative="path"` bug where relative path calculations started from the full location pathname, instead of from the current contextual route pathname. ([#11006](https://github.com/remix-run/react-router/pull/11006))
|
||||
|
||||
```jsx
|
||||
<Route path="/a">
|
||||
<Route path="/b" element={<Component />}>
|
||||
<Route path="/c" />
|
||||
</Route>
|
||||
</Route>;
|
||||
|
||||
function Component() {
|
||||
return (
|
||||
<>
|
||||
{/* This is now correctly relative to /a/b, not /a/b/c */}
|
||||
<Link to=".." relative="path" />
|
||||
<Outlet />
|
||||
</>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## 1.11.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add a new `future.v7_fetcherPersist` flag to the `@remix-run/router` to change the persistence behavior of fetchers when `router.deleteFetcher` is called. Instead of being immediately cleaned up, fetchers will persist until they return to an `idle` state ([RFC](https://github.com/remix-run/remix/discussions/7698)) ([#10962](https://github.com/remix-run/react-router/pull/10962))
|
||||
|
||||
- This is sort of a long-standing bug fix as the `useFetchers()` API was always supposed to only reflect **in-flight** fetcher information for pending/optimistic UI -- it was not intended to reflect fetcher data or hang onto fetchers after they returned to an `idle` state
|
||||
- Keep an eye out for the following specific behavioral changes when opting into this flag and check your app for compatibility:
|
||||
- Fetchers that complete _while still mounted_ will no longer appear in `useFetchers()`. They served effectively no purpose in there since you can access the data via `useFetcher().data`).
|
||||
- Fetchers that previously unmounted _while in-flight_ will not be immediately aborted and will instead be cleaned up once they return to an `idle` state. They will remain exposed via `useFetchers` while in-flight so you can still access pending/optimistic data after unmount.
|
||||
|
||||
- When `v7_fetcherPersist` is enabled, the router now performs ref-counting on fetcher keys via `getFetcher`/`deleteFetcher` so it knows when a given fetcher is totally unmounted from the UI ([#10977](https://github.com/remix-run/react-router/pull/10977))
|
||||
|
||||
- Once a fetcher has been totally unmounted, we can ignore post-processing of a persisted fetcher result such as a redirect or an error
|
||||
- The router will also pass a new `deletedFetchers` array to the subscriber callbacks so that the UI layer can remove associated fetcher data
|
||||
|
||||
- Add support for optional path segments in `matchPath` ([#10768](https://github.com/remix-run/react-router/pull/10768))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix `router.getFetcher`/`router.deleteFetcher` type definitions which incorrectly specified `key` as an optional parameter ([#10960](https://github.com/remix-run/react-router/pull/10960))
|
||||
|
||||
## 1.10.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add experimental support for the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition) by allowing users to opt-into view transitions on navigations via the new `unstable_viewTransition` option to `router.navigate` ([#10916](https://github.com/remix-run/react-router/pull/10916))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Allow 404 detection to leverage root route error boundary if path contains a URL segment ([#10852](https://github.com/remix-run/react-router/pull/10852))
|
||||
- Fix `ErrorResponse` type to avoid leaking internal field ([#10876](https://github.com/remix-run/react-router/pull/10876))
|
||||
|
||||
## 1.9.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- In order to move towards stricter TypeScript support in the future, we're aiming to replace current usages of `any` with `unknown` on exposed typings for user-provided data. To do this in Remix v2 without introducing breaking changes in React Router v6, we have added generics to a number of shared types. These continue to default to `any` in React Router and are overridden with `unknown` in Remix. In React Router v7 we plan to move these to `unknown` as a breaking change. ([#10843](https://github.com/remix-run/react-router/pull/10843))
|
||||
- `Location` now accepts a generic for the `location.state` value
|
||||
- `ActionFunctionArgs`/`ActionFunction`/`LoaderFunctionArgs`/`LoaderFunction` now accept a generic for the `context` parameter (only used in SSR usages via `createStaticHandler`)
|
||||
- The return type of `useMatches` (now exported as `UIMatch`) accepts generics for `match.data` and `match.handle` - both of which were already set to `unknown`
|
||||
- Move the `@private` class export `ErrorResponse` to an `UNSAFE_ErrorResponseImpl` export since it is an implementation detail and there should be no construction of `ErrorResponse` instances in userland. This frees us up to export a `type ErrorResponse` which correlates to an instance of the class via `InstanceType`. Userland code should only ever be using `ErrorResponse` as a type and should be type-narrowing via `isRouteErrorResponse`. ([#10811](https://github.com/remix-run/react-router/pull/10811))
|
||||
- Export `ShouldRevalidateFunctionArgs` interface ([#10797](https://github.com/remix-run/react-router/pull/10797))
|
||||
- Removed private/internal APIs only required for the Remix v1 backwards compatibility layer and no longer needed in Remix v2 (`_isFetchActionRedirect`, `_hasFetcherDoneAnything`) ([#10715](https://github.com/remix-run/react-router/pull/10715))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Add method/url to error message on aborted `query`/`queryRoute` calls ([#10793](https://github.com/remix-run/react-router/pull/10793))
|
||||
- Fix a race-condition with loader/action-thrown errors on `route.lazy` routes ([#10778](https://github.com/remix-run/react-router/pull/10778))
|
||||
- Fix type for `actionResult` on the arguments object passed to `shouldRevalidate` ([#10779](https://github.com/remix-run/react-router/pull/10779))
|
||||
|
||||
## 1.8.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add's a new `redirectDocument()` function which allows users to specify that a redirect from a `loader`/`action` should trigger a document reload (via `window.location`) instead of attempting to navigate to the redirected location via React Router ([#10705](https://github.com/remix-run/react-router/pull/10705))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix an issue in `queryRoute` that was not always identifying thrown `Response` instances ([#10717](https://github.com/remix-run/react-router/pull/10717))
|
||||
- Ensure hash history always includes a leading slash on hash pathnames ([#10753](https://github.com/remix-run/react-router/pull/10753))
|
||||
|
||||
## 1.7.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Trigger an error if a `defer` promise resolves/rejects with `undefined` in order to match the behavior of loaders and actions which must return a value or `null` ([#10690](https://github.com/remix-run/react-router/pull/10690))
|
||||
- Properly handle fetcher redirects interrupted by normal navigations ([#10674](https://github.com/remix-run/react-router/pull/10674), [#10709](https://github.com/remix-run/react-router/pull/10709))
|
||||
- Initial-load fetchers should not automatically revalidate on GET navigations ([#10688](https://github.com/remix-run/react-router/pull/10688))
|
||||
- Enhance the return type of `Route.lazy` to prohibit returning an empty object ([#10634](https://github.com/remix-run/react-router/pull/10634))
|
||||
|
||||
## 1.7.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix issues with reused blockers on subsequent navigations ([#10656](https://github.com/remix-run/react-router/pull/10656))
|
||||
|
||||
## 1.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Add support for `application/json` and `text/plain` encodings for `router.navigate`/`router.fetch` submissions. To leverage these encodings, pass your data in a `body` parameter and specify the desired `formEncType`: ([#10413](https://github.com/remix-run/react-router/pull/10413))
|
||||
|
||||
```js
|
||||
// By default, the encoding is "application/x-www-form-urlencoded"
|
||||
router.navigate("/", {
|
||||
formMethod: "post",
|
||||
body: { key: "value" },
|
||||
});
|
||||
|
||||
async function action({ request }) {
|
||||
// await request.formData() => FormData instance with entry [key=value]
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
// Pass `formEncType` to opt-into a different encoding (json)
|
||||
router.navigate("/", {
|
||||
formMethod: "post",
|
||||
formEncType: "application/json",
|
||||
body: { key: "value" },
|
||||
});
|
||||
|
||||
async function action({ request }) {
|
||||
// await request.json() => { key: "value" }
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
// Pass `formEncType` to opt-into a different encoding (text)
|
||||
router.navigate("/", {
|
||||
formMethod: "post",
|
||||
formEncType: "text/plain",
|
||||
body: "Text submission",
|
||||
});
|
||||
|
||||
async function action({ request }) {
|
||||
// await request.text() => "Text submission"
|
||||
}
|
||||
```
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Call `window.history.pushState/replaceState` before updating React Router state (instead of after) so that `window.location` matches `useLocation` during synchronous React 17 rendering ([#10448](https://github.com/remix-run/react-router/pull/10448))
|
||||
- ⚠️ However, generally apps should not be relying on `window.location` and should always reference `useLocation` when possible, as `window.location` will not be in sync 100% of the time (due to `popstate` events, concurrent mode, etc.)
|
||||
- Strip `basename` from the `location` provided to `<ScrollRestoration getKey>` to match the `useLocation` behavior ([#10550](https://github.com/remix-run/react-router/pull/10550))
|
||||
- Avoid calling `shouldRevalidate` for fetchers that have not yet completed a data load ([#10623](https://github.com/remix-run/react-router/pull/10623))
|
||||
- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573))
|
||||
- Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581))
|
||||
|
||||
## 1.6.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Allow fetcher revalidations to complete if submitting fetcher is deleted ([#10535](https://github.com/remix-run/react-router/pull/10535))
|
||||
- Re-throw `DOMException` (`DataCloneError`) when attempting to perform a `PUSH` navigation with non-serializable state. ([#10427](https://github.com/remix-run/react-router/pull/10427))
|
||||
- Ensure revalidations happen when hash is present ([#10516](https://github.com/remix-run/react-router/pull/10516))
|
||||
- upgrade jest and jsdom ([#10453](https://github.com/remix-run/react-router/pull/10453))
|
||||
|
||||
## 1.6.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix HMR-driven error boundaries by properly reconstructing new routes and `manifest` in `\_internalSetRoutes` ([#10437](https://github.com/remix-run/react-router/pull/10437))
|
||||
- Fix bug where initial data load would not kick off when hash is present ([#10493](https://github.com/remix-run/react-router/pull/10493))
|
||||
|
||||
## 1.6.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix `basename` handling when navigating without a path ([#10433](https://github.com/remix-run/react-router/pull/10433))
|
||||
- "Same hash" navigations no longer re-run loaders to match browser behavior (i.e. `/path#hash -> /path#hash`) ([#10408](https://github.com/remix-run/react-router/pull/10408))
|
||||
|
||||
## 1.6.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Enable relative routing in the `@remix-run/router` when providing a source route ID from which the path is relative to: ([#10336](https://github.com/remix-run/react-router/pull/10336))
|
||||
|
||||
- Example: `router.navigate("../path", { fromRouteId: "some-route" })`.
|
||||
- This also applies to `router.fetch` which already receives a source route ID
|
||||
|
||||
- Introduce a new `@remix-run/router` `future.v7_prependBasename` flag to enable `basename` prefixing to all paths coming into `router.navigate` and `router.fetch`.
|
||||
|
||||
- Previously the `basename` was prepended in the React Router layer, but now that relative routing is being handled by the router we need prepend the `basename` _after_ resolving any relative paths
|
||||
- This also enables `basename` support in `useFetcher` as well
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Enhance `LoaderFunction`/`ActionFunction` return type to prevent `undefined` from being a valid return value ([#10267](https://github.com/remix-run/react-router/pull/10267))
|
||||
- Ensure proper 404 error on `fetcher.load` call to a route without a `loader` ([#10345](https://github.com/remix-run/react-router/pull/10345))
|
||||
- Deprecate the `createRouter` `detectErrorBoundary` option in favor of the new `mapRouteProperties` option for converting a framework-agnostic route to a framework-aware route. This allows us to set more than just the `hasErrorBoundary` property during route pre-processing, and is now used for mapping `Component -> element` and `ErrorBoundary -> errorElement` in `react-router`. ([#10287](https://github.com/remix-run/react-router/pull/10287))
|
||||
- Fixed a bug where fetchers were incorrectly attempting to revalidate on search params changes or routing to the same URL (using the same logic for route `loader` revalidations). However, since fetchers have a static href, they should only revalidate on `action` submissions or `router.revalidate` calls. ([#10344](https://github.com/remix-run/react-router/pull/10344))
|
||||
- Decouple `AbortController` usage between revalidating fetchers and the thing that triggered them such that the unmount/deletion of a revalidating fetcher doesn't impact the ongoing triggering navigation/revalidation ([#10271](https://github.com/remix-run/react-router/pull/10271))
|
||||
|
||||
## 1.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Added support for [**Future Flags**](https://reactrouter.com/v6/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
|
||||
|
||||
- When `future.v7_normalizeFormMethod === false` (default v6 behavior),
|
||||
- `useNavigation().formMethod` is lowercase
|
||||
- `useFetcher().formMethod` is lowercase
|
||||
- When `future.v7_normalizeFormMethod === true`:
|
||||
- `useNavigation().formMethod` is uppercase
|
||||
- `useFetcher().formMethod` is uppercase
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Provide fetcher submission to `shouldRevalidate` if the fetcher action redirects ([#10208](https://github.com/remix-run/react-router/pull/10208))
|
||||
- Properly handle `lazy()` errors during router initialization ([#10201](https://github.com/remix-run/react-router/pull/10201))
|
||||
- Remove `instanceof` check for `DeferredData` to be resilient to ESM/CJS boundaries in SSR bundling scenarios ([#10247](https://github.com/remix-run/react-router/pull/10247))
|
||||
- Update to latest `@remix-run/web-fetch@4.3.3` ([#10216](https://github.com/remix-run/react-router/pull/10216))
|
||||
|
||||
## 1.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- **Introducing Lazy Route Modules!** ([#10045](https://github.com/remix-run/react-router/pull/10045))
|
||||
|
||||
In order to keep your application bundles small and support code-splitting of your routes, we've introduced a new `lazy()` route property. This is an async function that resolves the non-route-matching portions of your route definition (`loader`, `action`, `element`/`Component`, `errorElement`/`ErrorBoundary`, `shouldRevalidate`, `handle`).
|
||||
|
||||
Lazy routes are resolved on initial load and during the `loading` or `submitting` phase of a navigation or fetcher call. You cannot lazily define route-matching properties (`path`, `index`, `children`) since we only execute your lazy route functions after we've matched known routes.
|
||||
|
||||
Your `lazy` functions will typically return the result of a dynamic import.
|
||||
|
||||
```jsx
|
||||
// In this example, we assume most folks land on the homepage so we include that
|
||||
// in our critical-path bundle, but then we lazily load modules for /a and /b so
|
||||
// they don't load until the user navigates to those routes
|
||||
let routes = createRoutesFromElements(
|
||||
<Route path="/" element={<Layout />}>
|
||||
<Route index element={<Home />} />
|
||||
<Route path="a" lazy={() => import("./a")} />
|
||||
<Route path="b" lazy={() => import("./b")} />
|
||||
</Route>
|
||||
);
|
||||
```
|
||||
|
||||
Then in your lazy route modules, export the properties you want defined for the route:
|
||||
|
||||
```jsx
|
||||
export async function loader({ request }) {
|
||||
let data = await fetchData(request);
|
||||
return json(data);
|
||||
}
|
||||
|
||||
// Export a `Component` directly instead of needing to create a React Element from it
|
||||
export function Component() {
|
||||
let data = useLoaderData();
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>You made it!</h1>
|
||||
<p>{data}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// Export an `ErrorBoundary` directly instead of needing to create a React Element from it
|
||||
export function ErrorBoundary() {
|
||||
let error = useRouteError();
|
||||
return isRouteErrorResponse(error) ? (
|
||||
<h1>
|
||||
{error.status} {error.statusText}
|
||||
</h1>
|
||||
) : (
|
||||
<h1>{error.message || error}</h1>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
An example of this in action can be found in the [`examples/lazy-loading-router-provider`](https://github.com/remix-run/react-router/tree/main/examples/lazy-loading-router-provider) directory of the repository.
|
||||
|
||||
🙌 Huge thanks to @rossipedia for the [Initial Proposal](https://github.com/remix-run/react-router/discussions/9826) and [POC Implementation](https://github.com/remix-run/react-router/pull/9830).
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix `generatePath` incorrectly applying parameters in some cases ([#10078](https://github.com/remix-run/react-router/pull/10078))
|
||||
|
||||
## 1.3.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Correctly perform a hard redirect for same-origin absolute URLs outside of the router `basename` ([#10076](https://github.com/remix-run/react-router/pull/10076))
|
||||
- Ensure status code and headers are maintained for `defer` loader responses in `createStaticHandler`'s `query()` method ([#10077](https://github.com/remix-run/react-router/pull/10077))
|
||||
- Change `invariant` to an `UNSAFE_invariant` export since it's only intended for internal use ([#10066](https://github.com/remix-run/react-router/pull/10066))
|
||||
- Add internal API for custom HMR implementations ([#9996](https://github.com/remix-run/react-router/pull/9996))
|
||||
|
||||
## 1.3.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Remove inaccurate console warning for POP navigations and update active blocker logic ([#10030](https://github.com/remix-run/react-router/pull/10030))
|
||||
- Only check for differing origin on absolute URL redirects ([#10033](https://github.com/remix-run/react-router/pull/10033))
|
||||
|
||||
## 1.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fixes 2 separate issues for revalidating fetcher `shouldRevalidate` calls ([#9948](https://github.com/remix-run/react-router/pull/9948))
|
||||
- The `shouldRevalidate` function was only being called for _explicit_ revalidation scenarios (after a mutation, manual `useRevalidator` call, or an `X-Remix-Revalidate` header used for cookie setting in Remix). It was not properly being called on _implicit_ revalidation scenarios that also apply to navigation `loader` revalidation, such as a change in search params or clicking a link for the page we're already on. It's now correctly called in those additional scenarios.
|
||||
- The parameters being passed were incorrect and inconsistent with one another since the `current*`/`next*` parameters reflected the static `fetcher.load` URL (and thus were identical). Instead, they should have reflected the the navigation that triggered the revalidation (as the `form*` parameters did). These parameters now correctly reflect the triggering navigation.
|
||||
- Respect `preventScrollReset` on `<fetcher.Form>` ([#9963](https://github.com/remix-run/react-router/pull/9963))
|
||||
- Do not short circuit on hash change only mutation submissions ([#9944](https://github.com/remix-run/react-router/pull/9944))
|
||||
- Remove `instanceof` check from `isRouteErrorResponse` to avoid bundling issues on the server ([#9930](https://github.com/remix-run/react-router/pull/9930))
|
||||
- Fix navigation for hash routers on manual URL changes ([#9980](https://github.com/remix-run/react-router/pull/9980))
|
||||
- Detect when a `defer` call only contains critical data and remove the `AbortController` ([#9965](https://github.com/remix-run/react-router/pull/9965))
|
||||
- Send the name as the value when url-encoding `File` `FormData` entries ([#9867](https://github.com/remix-run/react-router/pull/9867))
|
||||
|
||||
## 1.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Added support for navigation blocking APIs ([#9709](https://github.com/remix-run/react-router/pull/9709))
|
||||
- Expose deferred information from `createStaticHandler` ([#9760](https://github.com/remix-run/react-router/pull/9760))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Improved absolute redirect url detection in actions/loaders ([#9829](https://github.com/remix-run/react-router/pull/9829))
|
||||
- Fix URL creation with memory histories ([#9814](https://github.com/remix-run/react-router/pull/9814))
|
||||
- Fix `generatePath` when optional params are present ([#9764](https://github.com/remix-run/react-router/pull/9764))
|
||||
- Fix scroll reset if a submission redirects ([#9886](https://github.com/remix-run/react-router/pull/9886))
|
||||
- Fix 404 bug with same-origin absolute redirects ([#9913](https://github.com/remix-run/react-router/pull/9913))
|
||||
- Support `OPTIONS` requests in `staticHandler.queryRoute` ([#9914](https://github.com/remix-run/react-router/pull/9914))
|
||||
|
||||
## 1.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Include submission info in `shouldRevalidate` on action redirects ([#9777](https://github.com/remix-run/react-router/pull/9777), [#9782](https://github.com/remix-run/react-router/pull/9782))
|
||||
- Reset `actionData` on action redirect to current location ([#9772](https://github.com/remix-run/react-router/pull/9772))
|
||||
|
||||
## 1.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Remove `unstable_` prefix from `createStaticHandler`/`createStaticRouter`/`StaticRouterProvider` ([#9738](https://github.com/remix-run/react-router/pull/9738))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix explicit `replace` on submissions and `PUSH` on submission to new paths ([#9734](https://github.com/remix-run/react-router/pull/9734))
|
||||
- Fix a few bugs where loader/action data wasn't properly cleared on errors ([#9735](https://github.com/remix-run/react-router/pull/9735))
|
||||
- Prevent `useLoaderData` usage in `errorElement` ([#9735](https://github.com/remix-run/react-router/pull/9735))
|
||||
- Skip initial scroll restoration for SSR apps with `hydrationData` ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
||||
|
||||
## 1.1.0
|
||||
|
||||
This release introduces support for [Optional Route Segments](https://github.com/remix-run/react-router/issues/9546). Now, adding a `?` to the end of any path segment will make that entire segment optional. This works for both static segments and dynamic parameters.
|
||||
|
||||
**Optional Params Examples**
|
||||
|
||||
- Path `lang?/about` will match:
|
||||
- `/:lang/about`
|
||||
- `/about`
|
||||
- Path `/multistep/:widget1?/widget2?/widget3?` will match:
|
||||
- `/multistep`
|
||||
- `/multistep/:widget1`
|
||||
- `/multistep/:widget1/:widget2`
|
||||
- `/multistep/:widget1/:widget2/:widget3`
|
||||
|
||||
**Optional Static Segment Example**
|
||||
|
||||
- Path `/home?` will match:
|
||||
- `/`
|
||||
- `/home`
|
||||
- Path `/fr?/about` will match:
|
||||
- `/about`
|
||||
- `/fr/about`
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Allows optional routes and optional static segments ([#9650](https://github.com/remix-run/react-router/pull/9650))
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Stop incorrectly matching on partial named parameters, i.e. `<Route path="prefix-:param">`, to align with how splat parameters work. If you were previously relying on this behavior then it's recommended to extract the static portion of the path at the `useParams` call site: ([#9506](https://github.com/remix-run/react-router/pull/9506))
|
||||
|
||||
```jsx
|
||||
// Old behavior at URL /prefix-123
|
||||
<Route path="prefix-:id" element={<Comp /> }>
|
||||
|
||||
function Comp() {
|
||||
let params = useParams(); // { id: '123' }
|
||||
let id = params.id; // "123"
|
||||
...
|
||||
}
|
||||
|
||||
// New behavior at URL /prefix-123
|
||||
<Route path=":id" element={<Comp /> }>
|
||||
|
||||
function Comp() {
|
||||
let params = useParams(); // { id: 'prefix-123' }
|
||||
let id = params.id.replace(/^prefix-/, ''); // "123"
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
- Persist `headers` on `loader` `request`'s after SSR document `action` request ([#9721](https://github.com/remix-run/react-router/pull/9721))
|
||||
- Fix requests sent to revalidating loaders so they reflect a GET request ([#9660](https://github.com/remix-run/react-router/pull/9660))
|
||||
- Fix issue with deeply nested optional segments ([#9727](https://github.com/remix-run/react-router/pull/9727))
|
||||
- GET forms now expose a submission on the loading navigation ([#9695](https://github.com/remix-run/react-router/pull/9695))
|
||||
- Fix error boundary tracking for multiple errors bubbling to the same boundary ([#9702](https://github.com/remix-run/react-router/pull/9702))
|
||||
|
||||
## 1.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix requests sent to revalidating loaders so they reflect a `GET` request ([#9680](https://github.com/remix-run/react-router/pull/9680))
|
||||
- Remove `instanceof Response` checks in favor of `isResponse` ([#9690](https://github.com/remix-run/react-router/pull/9690))
|
||||
- Fix `URL` creation in Cloudflare Pages or other non-browser-environments ([#9682](https://github.com/remix-run/react-router/pull/9682), [#9689](https://github.com/remix-run/react-router/pull/9689))
|
||||
- Add `requestContext` support to static handler `query`/`queryRoute` ([#9696](https://github.com/remix-run/react-router/pull/9696))
|
||||
- Note that the unstable API of `queryRoute(path, routeId)` has been changed to `queryRoute(path, { routeId, requestContext })`
|
||||
|
||||
## 1.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Throw an error if an `action`/`loader` function returns `undefined` as revalidations need to know whether the loader has previously been executed. `undefined` also causes issues during SSR stringification for hydration. You should always ensure you `loader`/`action` returns a value, and you may return `null` if you don't wish to return anything. ([#9511](https://github.com/remix-run/react-router/pull/9511))
|
||||
- Properly handle redirects to external domains ([#9590](https://github.com/remix-run/react-router/pull/9590), [#9654](https://github.com/remix-run/react-router/pull/9654))
|
||||
- Preserve the HTTP method on 307/308 redirects ([#9597](https://github.com/remix-run/react-router/pull/9597))
|
||||
- Support `basename` in static data routers ([#9591](https://github.com/remix-run/react-router/pull/9591))
|
||||
- Enhanced `ErrorResponse` bodies to contain more descriptive text in internal 403/404/405 scenarios
|
||||
|
||||
## 1.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix hrefs generated when using `createHashRouter` ([#9409](https://github.com/remix-run/react-router/pull/9409))
|
||||
- fix encoding/matching issues with special chars ([#9477](https://github.com/remix-run/react-router/pull/9477), [#9496](https://github.com/remix-run/react-router/pull/9496))
|
||||
- Support `basename` and relative routing in `loader`/`action` redirects ([#9447](https://github.com/remix-run/react-router/pull/9447))
|
||||
- Ignore pathless layout routes when looking for proper submission `action` function ([#9455](https://github.com/remix-run/react-router/pull/9455))
|
||||
- properly support `index` routes with a `path` in `useResolvedPath` ([#9486](https://github.com/remix-run/react-router/pull/9486))
|
||||
- Add UMD build for `@remix-run/router` ([#9446](https://github.com/remix-run/react-router/pull/9446))
|
||||
- fix `createURL` in local file execution in Firefox ([#9464](https://github.com/remix-run/react-router/pull/9464))
|
||||
- Updates to `unstable_createStaticHandler` for incorporating into Remix ([#9482](https://github.com/remix-run/react-router/pull/9482), [#9465](https://github.com/remix-run/react-router/pull/9465))
|
||||
|
||||
## 1.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Reset `actionData` after a successful action redirect ([#9334](https://github.com/remix-run/react-router/pull/9334))
|
||||
- Update `matchPath` to avoid false positives on dash-separated segments ([#9300](https://github.com/remix-run/react-router/pull/9300))
|
||||
- If an index route has children, it will result in a runtime error. We have strengthened our `RouteObject`/`RouteProps` types to surface the error in TypeScript. ([#9366](https://github.com/remix-run/react-router/pull/9366))
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Preserve state from `initialEntries` ([#9288](https://github.com/remix-run/react-router/pull/9288))
|
||||
- Preserve `?index` for fetcher get submissions to index routes ([#9312](https://github.com/remix-run/react-router/pull/9312))
|
||||
|
||||
## 1.0.0
|
||||
|
||||
This is the first stable release of `@remix-run/router`, which provides all the underlying routing and data loading/mutation logic for `react-router`. You should _not_ be using this package directly unless you are authoring a routing library similar to `react-router`.
|
||||
|
||||
For an overview of the features provided by `react-router`, we recommend you go check out the [docs](https://reactrouter.com), especially the [feature overview](https://reactrouter.com/en/6.4.0/start/overview) and the [tutorial](https://reactrouter.com/en/6.4.0/start/tutorial).
|
||||
|
||||
For an overview of the features provided by `@remix-run/router`, please check out the [`README`](./README.md).
|
23
node_modules/@remix-run/router/LICENSE.md
generated
vendored
Normal file
23
node_modules/@remix-run/router/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) React Training LLC 2015-2019
|
||||
Copyright (c) Remix Software Inc. 2020-2021
|
||||
Copyright (c) Shopify Inc. 2022-2023
|
||||
|
||||
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.
|
135
node_modules/@remix-run/router/README.md
generated
vendored
Normal file
135
node_modules/@remix-run/router/README.md
generated
vendored
Normal file
|
@ -0,0 +1,135 @@
|
|||
# Remix Router
|
||||
|
||||
The `@remix-run/router` package is a framework-agnostic routing package (sometimes referred to as a browser-emulator) that serves as the heart of [React Router][react-router] and [Remix][remix] and provides all the core functionality for routing coupled with data loading and data mutations. It comes with built-in handling of errors, race-conditions, interruptions, cancellations, lazy-loading data, and much, much more.
|
||||
|
||||
If you're using React Router, you should never `import` anything directly from the `@remix-run/router` - you should have everything you need in `react-router-dom` (or `react-router`/`react-router-native` if you're not rendering in the browser). All of those packages should re-export everything you would otherwise need from `@remix-run/router`.
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> This router is a low-level package intended to be consumed by UI layer routing libraries. You should very likely not be using this package directly unless you are authoring a routing library such as [`react-router-dom`][react-router-repo] or one of it's other [UI ports][remix-routers-repo].
|
||||
|
||||
## API
|
||||
|
||||
A Router instance can be created using `createRouter`:
|
||||
|
||||
```js
|
||||
// Create and initialize a router. "initialize" contains all side effects
|
||||
// including history listeners and kicking off the initial data fetch
|
||||
let router = createRouter({
|
||||
// Required properties
|
||||
routes: [{
|
||||
path: '/',
|
||||
loader: ({ request, params }) => { /* ... */ },
|
||||
children: [{
|
||||
path: 'home',
|
||||
loader: ({ request, params }) => { /* ... */ },
|
||||
}]
|
||||
},
|
||||
history: createBrowserHistory(),
|
||||
|
||||
// Optional properties
|
||||
basename, // Base path
|
||||
mapRouteProperties, // Map framework-agnostic routes to framework-aware routes
|
||||
future, // Future flags
|
||||
hydrationData, // Hydration data if using server-side-rendering
|
||||
}).initialize();
|
||||
```
|
||||
|
||||
Internally, the Router represents the state in an object of the following format, which is available through `router.state`. You can also register a subscriber of the signature `(state: RouterState) => void` to execute when the state updates via `router.subscribe()`;
|
||||
|
||||
```ts
|
||||
interface RouterState {
|
||||
// False during the initial data load, true once we have our initial data
|
||||
initialized: boolean;
|
||||
// The `history` action of the most recently completed navigation
|
||||
historyAction: Action;
|
||||
// The current location of the router. During a navigation this reflects
|
||||
// the "old" location and is updated upon completion of the navigation
|
||||
location: Location;
|
||||
// The current set of route matches
|
||||
matches: DataRouteMatch[];
|
||||
// The state of the current navigation
|
||||
navigation: Navigation;
|
||||
// The state of any in-progress router.revalidate() calls
|
||||
revalidation: RevalidationState;
|
||||
// Data from the loaders for the current matches
|
||||
loaderData: RouteData;
|
||||
// Data from the action for the current matches
|
||||
actionData: RouteData | null;
|
||||
// Errors thrown from loaders/actions for the current matches
|
||||
errors: RouteData | null;
|
||||
// Map of all active fetchers
|
||||
fetchers: Map<string, Fetcher>;
|
||||
// Scroll position to restore to for the active Location, false if we
|
||||
// should not restore, or null if we don't have a saved position
|
||||
// Note: must be enabled via router.enableScrollRestoration()
|
||||
restoreScrollPosition: number | false | null;
|
||||
// Proxied `preventScrollReset` value passed to router.navigate()
|
||||
preventScrollReset: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
### Navigations
|
||||
|
||||
All navigations are done through the `router.navigate` API which is overloaded to support different types of navigations:
|
||||
|
||||
```js
|
||||
// Link navigation (pushes onto the history stack by default)
|
||||
router.navigate("/page");
|
||||
|
||||
// Link navigation (replacing the history stack)
|
||||
router.navigate("/page", { replace: true });
|
||||
|
||||
// Pop navigation (moving backward/forward in the history stack)
|
||||
router.navigate(-1);
|
||||
|
||||
// Form submission navigation
|
||||
let formData = new FormData();
|
||||
formData.append(key, value);
|
||||
router.navigate("/page", {
|
||||
formMethod: "post",
|
||||
formData,
|
||||
});
|
||||
|
||||
// Relative routing from a source routeId
|
||||
router.navigate("../../somewhere", {
|
||||
fromRouteId: "active-route-id",
|
||||
});
|
||||
```
|
||||
|
||||
### Fetchers
|
||||
|
||||
Fetchers are a mechanism to call loaders/actions without triggering a navigation, and are done through the `router.fetch()` API. All fetch calls require a unique key to identify the fetcher.
|
||||
|
||||
```js
|
||||
// Execute the loader for /page
|
||||
router.fetch("key", "/page");
|
||||
|
||||
// Submit to the action for /page
|
||||
let formData = new FormData();
|
||||
formData.append(key, value);
|
||||
router.fetch("key", "/page", {
|
||||
formMethod: "post",
|
||||
formData,
|
||||
});
|
||||
```
|
||||
|
||||
### Revalidation
|
||||
|
||||
By default, active loaders will revalidate after any navigation or fetcher mutation. If you need to kick off a revalidation for other use-cases, you can use `router.revalidate()` to re-execute all active loaders.
|
||||
|
||||
### Future Flags
|
||||
|
||||
We use _Future Flags_ in the router to help us introduce breaking changes in an opt-in fashion ahead of major releases. Please check out the [blog post][future-flags-post] and [React Router Docs][api-development-strategy] for more information on this process. The currently available future flags in `@remix-run/router` are:
|
||||
|
||||
| Flag | Description |
|
||||
| ------------------------ | ------------------------------------------------------------------------- |
|
||||
| `v7_normalizeFormMethod` | Normalize `useNavigation().formMethod` to be an uppercase HTTP Method |
|
||||
| `v7_prependBasename` | Prepend the `basename` to incoming `router.navigate`/`router.fetch` paths |
|
||||
|
||||
[react-router]: https://reactrouter.com
|
||||
[remix]: https://remix.run
|
||||
[react-router-repo]: https://github.com/remix-run/react-router
|
||||
[remix-routers-repo]: https://github.com/brophdawg11/remix-routers
|
||||
[api-development-strategy]: https://reactrouter.com/v6/guides/api-development-strategy
|
||||
[future-flags-post]: https://remix.run/blog/future-flags
|
250
node_modules/@remix-run/router/dist/history.d.ts
generated
vendored
Normal file
250
node_modules/@remix-run/router/dist/history.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,250 @@
|
|||
/**
|
||||
* Actions represent the type of change to a location value.
|
||||
*/
|
||||
export declare enum Action {
|
||||
/**
|
||||
* A POP indicates a change to an arbitrary index in the history stack, such
|
||||
* as a back or forward navigation. It does not describe the direction of the
|
||||
* navigation, only that the current index changed.
|
||||
*
|
||||
* Note: This is the default action for newly created history objects.
|
||||
*/
|
||||
Pop = "POP",
|
||||
/**
|
||||
* A PUSH indicates a new entry being added to the history stack, such as when
|
||||
* a link is clicked and a new page loads. When this happens, all subsequent
|
||||
* entries in the stack are lost.
|
||||
*/
|
||||
Push = "PUSH",
|
||||
/**
|
||||
* A REPLACE indicates the entry at the current index in the history stack
|
||||
* being replaced by a new one.
|
||||
*/
|
||||
Replace = "REPLACE"
|
||||
}
|
||||
/**
|
||||
* The pathname, search, and hash values of a URL.
|
||||
*/
|
||||
export interface Path {
|
||||
/**
|
||||
* A URL pathname, beginning with a /.
|
||||
*/
|
||||
pathname: string;
|
||||
/**
|
||||
* A URL search string, beginning with a ?.
|
||||
*/
|
||||
search: string;
|
||||
/**
|
||||
* A URL fragment identifier, beginning with a #.
|
||||
*/
|
||||
hash: string;
|
||||
}
|
||||
/**
|
||||
* An entry in a history stack. A location contains information about the
|
||||
* URL path, as well as possibly some arbitrary state and a key.
|
||||
*/
|
||||
export interface Location<State = any> extends Path {
|
||||
/**
|
||||
* A value of arbitrary data associated with this location.
|
||||
*/
|
||||
state: State;
|
||||
/**
|
||||
* A unique string associated with this location. May be used to safely store
|
||||
* and retrieve data in some other storage API, like `localStorage`.
|
||||
*
|
||||
* Note: This value is always "default" on the initial location.
|
||||
*/
|
||||
key: string;
|
||||
}
|
||||
/**
|
||||
* A change to the current location.
|
||||
*/
|
||||
export interface Update {
|
||||
/**
|
||||
* The action that triggered the change.
|
||||
*/
|
||||
action: Action;
|
||||
/**
|
||||
* The new location.
|
||||
*/
|
||||
location: Location;
|
||||
/**
|
||||
* The delta between this location and the former location in the history stack
|
||||
*/
|
||||
delta: number | null;
|
||||
}
|
||||
/**
|
||||
* A function that receives notifications about location changes.
|
||||
*/
|
||||
export interface Listener {
|
||||
(update: Update): void;
|
||||
}
|
||||
/**
|
||||
* Describes a location that is the destination of some navigation, either via
|
||||
* `history.push` or `history.replace`. This may be either a URL or the pieces
|
||||
* of a URL path.
|
||||
*/
|
||||
export type To = string | Partial<Path>;
|
||||
/**
|
||||
* A history is an interface to the navigation stack. The history serves as the
|
||||
* source of truth for the current location, as well as provides a set of
|
||||
* methods that may be used to change it.
|
||||
*
|
||||
* It is similar to the DOM's `window.history` object, but with a smaller, more
|
||||
* focused API.
|
||||
*/
|
||||
export interface History {
|
||||
/**
|
||||
* The last action that modified the current location. This will always be
|
||||
* Action.Pop when a history instance is first created. This value is mutable.
|
||||
*/
|
||||
readonly action: Action;
|
||||
/**
|
||||
* The current location. This value is mutable.
|
||||
*/
|
||||
readonly location: Location;
|
||||
/**
|
||||
* Returns a valid href for the given `to` value that may be used as
|
||||
* the value of an <a href> attribute.
|
||||
*
|
||||
* @param to - The destination URL
|
||||
*/
|
||||
createHref(to: To): string;
|
||||
/**
|
||||
* Returns a URL for the given `to` value
|
||||
*
|
||||
* @param to - The destination URL
|
||||
*/
|
||||
createURL(to: To): URL;
|
||||
/**
|
||||
* Encode a location the same way window.history would do (no-op for memory
|
||||
* history) so we ensure our PUSH/REPLACE navigations for data routers
|
||||
* behave the same as POP
|
||||
*
|
||||
* @param to Unencoded path
|
||||
*/
|
||||
encodeLocation(to: To): Path;
|
||||
/**
|
||||
* Pushes a new location onto the history stack, increasing its length by one.
|
||||
* If there were any entries in the stack after the current one, they are
|
||||
* lost.
|
||||
*
|
||||
* @param to - The new URL
|
||||
* @param state - Data to associate with the new location
|
||||
*/
|
||||
push(to: To, state?: any): void;
|
||||
/**
|
||||
* Replaces the current location in the history stack with a new one. The
|
||||
* location that was replaced will no longer be available.
|
||||
*
|
||||
* @param to - The new URL
|
||||
* @param state - Data to associate with the new location
|
||||
*/
|
||||
replace(to: To, state?: any): void;
|
||||
/**
|
||||
* Navigates `n` entries backward/forward in the history stack relative to the
|
||||
* current index. For example, a "back" navigation would use go(-1).
|
||||
*
|
||||
* @param delta - The delta in the stack index
|
||||
*/
|
||||
go(delta: number): void;
|
||||
/**
|
||||
* Sets up a listener that will be called whenever the current location
|
||||
* changes.
|
||||
*
|
||||
* @param listener - A function that will be called when the location changes
|
||||
* @returns unlisten - A function that may be used to stop listening
|
||||
*/
|
||||
listen(listener: Listener): () => void;
|
||||
}
|
||||
/**
|
||||
* A user-supplied object that describes a location. Used when providing
|
||||
* entries to `createMemoryHistory` via its `initialEntries` option.
|
||||
*/
|
||||
export type InitialEntry = string | Partial<Location>;
|
||||
export type MemoryHistoryOptions = {
|
||||
initialEntries?: InitialEntry[];
|
||||
initialIndex?: number;
|
||||
v5Compat?: boolean;
|
||||
};
|
||||
/**
|
||||
* A memory history stores locations in memory. This is useful in stateful
|
||||
* environments where there is no web browser, such as node tests or React
|
||||
* Native.
|
||||
*/
|
||||
export interface MemoryHistory extends History {
|
||||
/**
|
||||
* The current index in the history stack.
|
||||
*/
|
||||
readonly index: number;
|
||||
}
|
||||
/**
|
||||
* Memory history stores the current location in memory. It is designed for use
|
||||
* in stateful non-browser environments like tests and React Native.
|
||||
*/
|
||||
export declare function createMemoryHistory(options?: MemoryHistoryOptions): MemoryHistory;
|
||||
/**
|
||||
* A browser history stores the current location in regular URLs in a web
|
||||
* browser environment. This is the standard for most web apps and provides the
|
||||
* cleanest URLs the browser's address bar.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
|
||||
*/
|
||||
export interface BrowserHistory extends UrlHistory {
|
||||
}
|
||||
export type BrowserHistoryOptions = UrlHistoryOptions;
|
||||
/**
|
||||
* Browser history stores the location in regular URLs. This is the standard for
|
||||
* most web apps, but it requires some configuration on the server to ensure you
|
||||
* serve the same app at multiple URLs.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
|
||||
*/
|
||||
export declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
|
||||
/**
|
||||
* A hash history stores the current location in the fragment identifier portion
|
||||
* of the URL in a web browser environment.
|
||||
*
|
||||
* This is ideal for apps that do not control the server for some reason
|
||||
* (because the fragment identifier is never sent to the server), including some
|
||||
* shared hosting environments that do not provide fine-grained controls over
|
||||
* which pages are served at which URLs.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory
|
||||
*/
|
||||
export interface HashHistory extends UrlHistory {
|
||||
}
|
||||
export type HashHistoryOptions = UrlHistoryOptions;
|
||||
/**
|
||||
* Hash history stores the location in window.location.hash. This makes it ideal
|
||||
* for situations where you don't want to send the location to the server for
|
||||
* some reason, either because you do cannot configure it or the URL space is
|
||||
* reserved for something else.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
|
||||
*/
|
||||
export declare function createHashHistory(options?: HashHistoryOptions): HashHistory;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare function invariant(value: boolean, message?: string): asserts value;
|
||||
export declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
|
||||
export declare function warning(cond: any, message: string): void;
|
||||
/**
|
||||
* Creates a Location object with a unique key from the given Path
|
||||
*/
|
||||
export declare function createLocation(current: string | Location, to: To, state?: any, key?: string): Readonly<Location>;
|
||||
/**
|
||||
* Creates a string URL path from the given pathname, search, and hash components.
|
||||
*/
|
||||
export declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
|
||||
/**
|
||||
* Parses a string URL path into its separate pathname, search, and hash components.
|
||||
*/
|
||||
export declare function parsePath(path: string): Partial<Path>;
|
||||
export interface UrlHistory extends History {
|
||||
}
|
||||
export type UrlHistoryOptions = {
|
||||
window?: Window;
|
||||
v5Compat?: boolean;
|
||||
};
|
9
node_modules/@remix-run/router/dist/index.d.ts
generated
vendored
Normal file
9
node_modules/@remix-run/router/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticPatchRoutesOnNavigationFunction, AgnosticPatchRoutesOnNavigationFunctionArgs, AgnosticRouteMatch, AgnosticRouteObject, DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyMatch, DataStrategyResult, ErrorResponse, FormEncType, FormMethod, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, PathMatch, PathParam, PathPattern, RedirectFunction, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, TrackedPromise, UIMatch, V7_FormMethod, DataWithResponseInit as UNSAFE_DataWithResponseInit, } from "./utils";
|
||||
export { AbortedDeferredError, data, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, replace, resolvePath, resolveTo, stripBasename, } from "./utils";
|
||||
export type { BrowserHistory, BrowserHistoryOptions, HashHistory, HashHistoryOptions, History, InitialEntry, Location, MemoryHistory, MemoryHistoryOptions, Path, To, } from "./history";
|
||||
export { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, parsePath, } from "./history";
|
||||
export * from "./router";
|
||||
/** @internal */
|
||||
export type { RouteManifest as UNSAFE_RouteManifest } from "./utils";
|
||||
export { DeferredData as UNSAFE_DeferredData, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch, decodePath as UNSAFE_decodePath, getResolveToMatches as UNSAFE_getResolveToMatches, } from "./utils";
|
||||
export { invariant as UNSAFE_invariant, warning as UNSAFE_warning, } from "./history";
|
5607
node_modules/@remix-run/router/dist/router.cjs.js
generated
vendored
Normal file
5607
node_modules/@remix-run/router/dist/router.cjs.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@remix-run/router/dist/router.cjs.js.map
generated
vendored
Normal file
1
node_modules/@remix-run/router/dist/router.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
525
node_modules/@remix-run/router/dist/router.d.ts
generated
vendored
Normal file
525
node_modules/@remix-run/router/dist/router.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,525 @@
|
|||
import type { History, Location, Path, To } from "./history";
|
||||
import { Action as HistoryAction } from "./history";
|
||||
import type { AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticRouteObject, DataStrategyFunction, DeferredData, DetectErrorBoundaryFunction, FormEncType, HTMLFormMethod, MapRoutePropertiesFunction, RouteData, Submission, UIMatch, AgnosticPatchRoutesOnNavigationFunction, DataWithResponseInit } from "./utils";
|
||||
/**
|
||||
* A Router instance manages all navigation and data loading/mutations
|
||||
*/
|
||||
export interface Router {
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the basename for the router
|
||||
*/
|
||||
get basename(): RouterInit["basename"];
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the future config for the router
|
||||
*/
|
||||
get future(): FutureConfig;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the current state of the router
|
||||
*/
|
||||
get state(): RouterState;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the routes for this router instance
|
||||
*/
|
||||
get routes(): AgnosticDataRouteObject[];
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the window associated with the router
|
||||
*/
|
||||
get window(): RouterInit["window"];
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Initialize the router, including adding history listeners and kicking off
|
||||
* initial data fetches. Returns a function to cleanup listeners and abort
|
||||
* any in-progress loads
|
||||
*/
|
||||
initialize(): Router;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Subscribe to router.state updates
|
||||
*
|
||||
* @param fn function to call with the new state
|
||||
*/
|
||||
subscribe(fn: RouterSubscriber): () => void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Enable scroll restoration behavior in the router
|
||||
*
|
||||
* @param savedScrollPositions Object that will manage positions, in case
|
||||
* it's being restored from sessionStorage
|
||||
* @param getScrollPosition Function to get the active Y scroll position
|
||||
* @param getKey Function to get the key to use for restoration
|
||||
*/
|
||||
enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Navigate forward/backward in the history stack
|
||||
* @param to Delta to move in the history stack
|
||||
*/
|
||||
navigate(to: number): Promise<void>;
|
||||
/**
|
||||
* Navigate to the given path
|
||||
* @param to Path to navigate to
|
||||
* @param opts Navigation options (method, submission, etc.)
|
||||
*/
|
||||
navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Trigger a fetcher load/submission
|
||||
*
|
||||
* @param key Fetcher key
|
||||
* @param routeId Route that owns the fetcher
|
||||
* @param href href to fetch
|
||||
* @param opts Fetcher options, (method, submission, etc.)
|
||||
*/
|
||||
fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Trigger a revalidation of all current route loaders and fetcher loads
|
||||
*/
|
||||
revalidate(): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Utility function to create an href for the given location
|
||||
* @param location
|
||||
*/
|
||||
createHref(location: Location | URL): string;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Utility function to URL encode a destination path according to the internal
|
||||
* history implementation
|
||||
* @param to
|
||||
*/
|
||||
encodeLocation(to: To): Path;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Get/create a fetcher for the given key
|
||||
* @param key
|
||||
*/
|
||||
getFetcher<TData = any>(key: string): Fetcher<TData>;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Delete the fetcher for a given key
|
||||
* @param key
|
||||
*/
|
||||
deleteFetcher(key: string): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Cleanup listeners and abort any in-progress loads
|
||||
*/
|
||||
dispose(): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Get a navigation blocker
|
||||
* @param key The identifier for the blocker
|
||||
* @param fn The blocker function implementation
|
||||
*/
|
||||
getBlocker(key: string, fn: BlockerFunction): Blocker;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Delete a navigation blocker
|
||||
* @param key The identifier for the blocker
|
||||
*/
|
||||
deleteBlocker(key: string): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE DO NOT USE
|
||||
*
|
||||
* Patch additional children routes into an existing parent route
|
||||
* @param routeId The parent route id or a callback function accepting `patch`
|
||||
* to perform batch patching
|
||||
* @param children The additional children routes
|
||||
*/
|
||||
patchRoutes(routeId: string | null, children: AgnosticRouteObject[]): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* HMR needs to pass in-flight route updates to React Router
|
||||
* TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
|
||||
*/
|
||||
_internalSetRoutes(routes: AgnosticRouteObject[]): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Internal fetch AbortControllers accessed by unit tests
|
||||
*/
|
||||
_internalFetchControllers: Map<string, AbortController>;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Internal pending DeferredData instances accessed by unit tests
|
||||
*/
|
||||
_internalActiveDeferreds: Map<string, DeferredData>;
|
||||
}
|
||||
/**
|
||||
* State maintained internally by the router. During a navigation, all states
|
||||
* reflect the the "old" location unless otherwise noted.
|
||||
*/
|
||||
export interface RouterState {
|
||||
/**
|
||||
* The action of the most recent navigation
|
||||
*/
|
||||
historyAction: HistoryAction;
|
||||
/**
|
||||
* The current location reflected by the router
|
||||
*/
|
||||
location: Location;
|
||||
/**
|
||||
* The current set of route matches
|
||||
*/
|
||||
matches: AgnosticDataRouteMatch[];
|
||||
/**
|
||||
* Tracks whether we've completed our initial data load
|
||||
*/
|
||||
initialized: boolean;
|
||||
/**
|
||||
* Current scroll position we should start at for a new view
|
||||
* - number -> scroll position to restore to
|
||||
* - false -> do not restore scroll at all (used during submissions)
|
||||
* - null -> don't have a saved position, scroll to hash or top of page
|
||||
*/
|
||||
restoreScrollPosition: number | false | null;
|
||||
/**
|
||||
* Indicate whether this navigation should skip resetting the scroll position
|
||||
* if we are unable to restore the scroll position
|
||||
*/
|
||||
preventScrollReset: boolean;
|
||||
/**
|
||||
* Tracks the state of the current navigation
|
||||
*/
|
||||
navigation: Navigation;
|
||||
/**
|
||||
* Tracks any in-progress revalidations
|
||||
*/
|
||||
revalidation: RevalidationState;
|
||||
/**
|
||||
* Data from the loaders for the current matches
|
||||
*/
|
||||
loaderData: RouteData;
|
||||
/**
|
||||
* Data from the action for the current matches
|
||||
*/
|
||||
actionData: RouteData | null;
|
||||
/**
|
||||
* Errors caught from loaders for the current matches
|
||||
*/
|
||||
errors: RouteData | null;
|
||||
/**
|
||||
* Map of current fetchers
|
||||
*/
|
||||
fetchers: Map<string, Fetcher>;
|
||||
/**
|
||||
* Map of current blockers
|
||||
*/
|
||||
blockers: Map<string, Blocker>;
|
||||
}
|
||||
/**
|
||||
* Data that can be passed into hydrate a Router from SSR
|
||||
*/
|
||||
export type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
|
||||
/**
|
||||
* Future flags to toggle new feature behavior
|
||||
*/
|
||||
export interface FutureConfig {
|
||||
v7_fetcherPersist: boolean;
|
||||
v7_normalizeFormMethod: boolean;
|
||||
v7_partialHydration: boolean;
|
||||
v7_prependBasename: boolean;
|
||||
v7_relativeSplatPath: boolean;
|
||||
v7_skipActionErrorRevalidation: boolean;
|
||||
}
|
||||
/**
|
||||
* Initialization options for createRouter
|
||||
*/
|
||||
export interface RouterInit {
|
||||
routes: AgnosticRouteObject[];
|
||||
history: History;
|
||||
basename?: string;
|
||||
/**
|
||||
* @deprecated Use `mapRouteProperties` instead
|
||||
*/
|
||||
detectErrorBoundary?: DetectErrorBoundaryFunction;
|
||||
mapRouteProperties?: MapRoutePropertiesFunction;
|
||||
future?: Partial<FutureConfig>;
|
||||
hydrationData?: HydrationState;
|
||||
window?: Window;
|
||||
dataStrategy?: DataStrategyFunction;
|
||||
patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction;
|
||||
}
|
||||
/**
|
||||
* State returned from a server-side query() call
|
||||
*/
|
||||
export interface StaticHandlerContext {
|
||||
basename: Router["basename"];
|
||||
location: RouterState["location"];
|
||||
matches: RouterState["matches"];
|
||||
loaderData: RouterState["loaderData"];
|
||||
actionData: RouterState["actionData"];
|
||||
errors: RouterState["errors"];
|
||||
statusCode: number;
|
||||
loaderHeaders: Record<string, Headers>;
|
||||
actionHeaders: Record<string, Headers>;
|
||||
activeDeferreds: Record<string, DeferredData> | null;
|
||||
_deepestRenderedBoundaryId?: string | null;
|
||||
}
|
||||
/**
|
||||
* A StaticHandler instance manages a singular SSR navigation/fetch event
|
||||
*/
|
||||
export interface StaticHandler {
|
||||
dataRoutes: AgnosticDataRouteObject[];
|
||||
query(request: Request, opts?: {
|
||||
requestContext?: unknown;
|
||||
skipLoaderErrorBubbling?: boolean;
|
||||
dataStrategy?: DataStrategyFunction;
|
||||
}): Promise<StaticHandlerContext | Response>;
|
||||
queryRoute(request: Request, opts?: {
|
||||
routeId?: string;
|
||||
requestContext?: unknown;
|
||||
dataStrategy?: DataStrategyFunction;
|
||||
}): Promise<any>;
|
||||
}
|
||||
type ViewTransitionOpts = {
|
||||
currentLocation: Location;
|
||||
nextLocation: Location;
|
||||
};
|
||||
/**
|
||||
* Subscriber function signature for changes to router state
|
||||
*/
|
||||
export interface RouterSubscriber {
|
||||
(state: RouterState, opts: {
|
||||
deletedFetchers: string[];
|
||||
viewTransitionOpts?: ViewTransitionOpts;
|
||||
flushSync: boolean;
|
||||
}): void;
|
||||
}
|
||||
/**
|
||||
* Function signature for determining the key to be used in scroll restoration
|
||||
* for a given location
|
||||
*/
|
||||
export interface GetScrollRestorationKeyFunction {
|
||||
(location: Location, matches: UIMatch[]): string | null;
|
||||
}
|
||||
/**
|
||||
* Function signature for determining the current scroll position
|
||||
*/
|
||||
export interface GetScrollPositionFunction {
|
||||
(): number;
|
||||
}
|
||||
export type RelativeRoutingType = "route" | "path";
|
||||
type BaseNavigateOrFetchOptions = {
|
||||
preventScrollReset?: boolean;
|
||||
relative?: RelativeRoutingType;
|
||||
flushSync?: boolean;
|
||||
};
|
||||
type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
|
||||
replace?: boolean;
|
||||
state?: any;
|
||||
fromRouteId?: string;
|
||||
viewTransition?: boolean;
|
||||
};
|
||||
type BaseSubmissionOptions = {
|
||||
formMethod?: HTMLFormMethod;
|
||||
formEncType?: FormEncType;
|
||||
} & ({
|
||||
formData: FormData;
|
||||
body?: undefined;
|
||||
} | {
|
||||
formData?: undefined;
|
||||
body: any;
|
||||
});
|
||||
/**
|
||||
* Options for a navigate() call for a normal (non-submission) navigation
|
||||
*/
|
||||
type LinkNavigateOptions = BaseNavigateOptions;
|
||||
/**
|
||||
* Options for a navigate() call for a submission navigation
|
||||
*/
|
||||
type SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;
|
||||
/**
|
||||
* Options to pass to navigate() for a navigation
|
||||
*/
|
||||
export type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
|
||||
/**
|
||||
* Options for a fetch() load
|
||||
*/
|
||||
type LoadFetchOptions = BaseNavigateOrFetchOptions;
|
||||
/**
|
||||
* Options for a fetch() submission
|
||||
*/
|
||||
type SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;
|
||||
/**
|
||||
* Options to pass to fetch()
|
||||
*/
|
||||
export type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
|
||||
/**
|
||||
* Potential states for state.navigation
|
||||
*/
|
||||
export type NavigationStates = {
|
||||
Idle: {
|
||||
state: "idle";
|
||||
location: undefined;
|
||||
formMethod: undefined;
|
||||
formAction: undefined;
|
||||
formEncType: undefined;
|
||||
formData: undefined;
|
||||
json: undefined;
|
||||
text: undefined;
|
||||
};
|
||||
Loading: {
|
||||
state: "loading";
|
||||
location: Location;
|
||||
formMethod: Submission["formMethod"] | undefined;
|
||||
formAction: Submission["formAction"] | undefined;
|
||||
formEncType: Submission["formEncType"] | undefined;
|
||||
formData: Submission["formData"] | undefined;
|
||||
json: Submission["json"] | undefined;
|
||||
text: Submission["text"] | undefined;
|
||||
};
|
||||
Submitting: {
|
||||
state: "submitting";
|
||||
location: Location;
|
||||
formMethod: Submission["formMethod"];
|
||||
formAction: Submission["formAction"];
|
||||
formEncType: Submission["formEncType"];
|
||||
formData: Submission["formData"];
|
||||
json: Submission["json"];
|
||||
text: Submission["text"];
|
||||
};
|
||||
};
|
||||
export type Navigation = NavigationStates[keyof NavigationStates];
|
||||
export type RevalidationState = "idle" | "loading";
|
||||
/**
|
||||
* Potential states for fetchers
|
||||
*/
|
||||
type FetcherStates<TData = any> = {
|
||||
Idle: {
|
||||
state: "idle";
|
||||
formMethod: undefined;
|
||||
formAction: undefined;
|
||||
formEncType: undefined;
|
||||
text: undefined;
|
||||
formData: undefined;
|
||||
json: undefined;
|
||||
data: TData | undefined;
|
||||
};
|
||||
Loading: {
|
||||
state: "loading";
|
||||
formMethod: Submission["formMethod"] | undefined;
|
||||
formAction: Submission["formAction"] | undefined;
|
||||
formEncType: Submission["formEncType"] | undefined;
|
||||
text: Submission["text"] | undefined;
|
||||
formData: Submission["formData"] | undefined;
|
||||
json: Submission["json"] | undefined;
|
||||
data: TData | undefined;
|
||||
};
|
||||
Submitting: {
|
||||
state: "submitting";
|
||||
formMethod: Submission["formMethod"];
|
||||
formAction: Submission["formAction"];
|
||||
formEncType: Submission["formEncType"];
|
||||
text: Submission["text"];
|
||||
formData: Submission["formData"];
|
||||
json: Submission["json"];
|
||||
data: TData | undefined;
|
||||
};
|
||||
};
|
||||
export type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
|
||||
interface BlockerBlocked {
|
||||
state: "blocked";
|
||||
reset(): void;
|
||||
proceed(): void;
|
||||
location: Location;
|
||||
}
|
||||
interface BlockerUnblocked {
|
||||
state: "unblocked";
|
||||
reset: undefined;
|
||||
proceed: undefined;
|
||||
location: undefined;
|
||||
}
|
||||
interface BlockerProceeding {
|
||||
state: "proceeding";
|
||||
reset: undefined;
|
||||
proceed: undefined;
|
||||
location: Location;
|
||||
}
|
||||
export type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
||||
export type BlockerFunction = (args: {
|
||||
currentLocation: Location;
|
||||
nextLocation: Location;
|
||||
historyAction: HistoryAction;
|
||||
}) => boolean;
|
||||
export declare const IDLE_NAVIGATION: NavigationStates["Idle"];
|
||||
export declare const IDLE_FETCHER: FetcherStates["Idle"];
|
||||
export declare const IDLE_BLOCKER: BlockerUnblocked;
|
||||
/**
|
||||
* Create a router and listen to history POP navigations
|
||||
*/
|
||||
export declare function createRouter(init: RouterInit): Router;
|
||||
export declare const UNSAFE_DEFERRED_SYMBOL: unique symbol;
|
||||
/**
|
||||
* Future flags to toggle new feature behavior
|
||||
*/
|
||||
export interface StaticHandlerFutureConfig {
|
||||
v7_relativeSplatPath: boolean;
|
||||
v7_throwAbortReason: boolean;
|
||||
}
|
||||
export interface CreateStaticHandlerOptions {
|
||||
basename?: string;
|
||||
/**
|
||||
* @deprecated Use `mapRouteProperties` instead
|
||||
*/
|
||||
detectErrorBoundary?: DetectErrorBoundaryFunction;
|
||||
mapRouteProperties?: MapRoutePropertiesFunction;
|
||||
future?: Partial<StaticHandlerFutureConfig>;
|
||||
}
|
||||
export declare function createStaticHandler(routes: AgnosticRouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
|
||||
/**
|
||||
* Given an existing StaticHandlerContext and an error thrown at render time,
|
||||
* provide an updated StaticHandlerContext suitable for a second SSR render
|
||||
*/
|
||||
export declare function getStaticContextFromError(routes: AgnosticDataRouteObject[], context: StaticHandlerContext, error: any): StaticHandlerContext;
|
||||
export declare function isDataWithResponseInit(value: any): value is DataWithResponseInit<unknown>;
|
||||
export declare function isDeferredData(value: any): value is DeferredData;
|
||||
export {};
|
5038
node_modules/@remix-run/router/dist/router.js
generated
vendored
Normal file
5038
node_modules/@remix-run/router/dist/router.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@remix-run/router/dist/router.js.map
generated
vendored
Normal file
1
node_modules/@remix-run/router/dist/router.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5613
node_modules/@remix-run/router/dist/router.umd.js
generated
vendored
Normal file
5613
node_modules/@remix-run/router/dist/router.umd.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@remix-run/router/dist/router.umd.js.map
generated
vendored
Normal file
1
node_modules/@remix-run/router/dist/router.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
node_modules/@remix-run/router/dist/router.umd.min.js
generated
vendored
Normal file
12
node_modules/@remix-run/router/dist/router.umd.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@remix-run/router/dist/router.umd.min.js.map
generated
vendored
Normal file
1
node_modules/@remix-run/router/dist/router.umd.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
555
node_modules/@remix-run/router/dist/utils.d.ts
generated
vendored
Normal file
555
node_modules/@remix-run/router/dist/utils.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,555 @@
|
|||
import type { Location, Path, To } from "./history";
|
||||
/**
|
||||
* Map of routeId -> data returned from a loader/action/error
|
||||
*/
|
||||
export interface RouteData {
|
||||
[routeId: string]: any;
|
||||
}
|
||||
export declare enum ResultType {
|
||||
data = "data",
|
||||
deferred = "deferred",
|
||||
redirect = "redirect",
|
||||
error = "error"
|
||||
}
|
||||
/**
|
||||
* Successful result from a loader or action
|
||||
*/
|
||||
export interface SuccessResult {
|
||||
type: ResultType.data;
|
||||
data: unknown;
|
||||
statusCode?: number;
|
||||
headers?: Headers;
|
||||
}
|
||||
/**
|
||||
* Successful defer() result from a loader or action
|
||||
*/
|
||||
export interface DeferredResult {
|
||||
type: ResultType.deferred;
|
||||
deferredData: DeferredData;
|
||||
statusCode?: number;
|
||||
headers?: Headers;
|
||||
}
|
||||
/**
|
||||
* Redirect result from a loader or action
|
||||
*/
|
||||
export interface RedirectResult {
|
||||
type: ResultType.redirect;
|
||||
response: Response;
|
||||
}
|
||||
/**
|
||||
* Unsuccessful result from a loader or action
|
||||
*/
|
||||
export interface ErrorResult {
|
||||
type: ResultType.error;
|
||||
error: unknown;
|
||||
statusCode?: number;
|
||||
headers?: Headers;
|
||||
}
|
||||
/**
|
||||
* Result from a loader or action - potentially successful or unsuccessful
|
||||
*/
|
||||
export type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
|
||||
type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
|
||||
type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
|
||||
/**
|
||||
* Users can specify either lowercase or uppercase form methods on `<Form>`,
|
||||
* useSubmit(), `<fetcher.Form>`, etc.
|
||||
*/
|
||||
export type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
|
||||
/**
|
||||
* Active navigation/fetcher form methods are exposed in lowercase on the
|
||||
* RouterState
|
||||
*/
|
||||
export type FormMethod = LowerCaseFormMethod;
|
||||
export type MutationFormMethod = Exclude<FormMethod, "get">;
|
||||
/**
|
||||
* In v7, active navigation/fetcher form methods are exposed in uppercase on the
|
||||
* RouterState. This is to align with the normalization done via fetch().
|
||||
*/
|
||||
export type V7_FormMethod = UpperCaseFormMethod;
|
||||
export type V7_MutationFormMethod = Exclude<V7_FormMethod, "GET">;
|
||||
export type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
|
||||
type JsonObject = {
|
||||
[Key in string]: JsonValue;
|
||||
} & {
|
||||
[Key in string]?: JsonValue | undefined;
|
||||
};
|
||||
type JsonArray = JsonValue[] | readonly JsonValue[];
|
||||
type JsonPrimitive = string | number | boolean | null;
|
||||
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
||||
/**
|
||||
* @private
|
||||
* Internal interface to pass around for action submissions, not intended for
|
||||
* external consumption
|
||||
*/
|
||||
export type Submission = {
|
||||
formMethod: FormMethod | V7_FormMethod;
|
||||
formAction: string;
|
||||
formEncType: FormEncType;
|
||||
formData: FormData;
|
||||
json: undefined;
|
||||
text: undefined;
|
||||
} | {
|
||||
formMethod: FormMethod | V7_FormMethod;
|
||||
formAction: string;
|
||||
formEncType: FormEncType;
|
||||
formData: undefined;
|
||||
json: JsonValue;
|
||||
text: undefined;
|
||||
} | {
|
||||
formMethod: FormMethod | V7_FormMethod;
|
||||
formAction: string;
|
||||
formEncType: FormEncType;
|
||||
formData: undefined;
|
||||
json: undefined;
|
||||
text: string;
|
||||
};
|
||||
/**
|
||||
* @private
|
||||
* Arguments passed to route loader/action functions. Same for now but we keep
|
||||
* this as a private implementation detail in case they diverge in the future.
|
||||
*/
|
||||
interface DataFunctionArgs<Context> {
|
||||
request: Request;
|
||||
params: Params;
|
||||
context?: Context;
|
||||
}
|
||||
/**
|
||||
* Arguments passed to loader functions
|
||||
*/
|
||||
export interface LoaderFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
||||
}
|
||||
/**
|
||||
* Arguments passed to action functions
|
||||
*/
|
||||
export interface ActionFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
||||
}
|
||||
/**
|
||||
* Loaders and actions can return anything except `undefined` (`null` is a
|
||||
* valid return value if there is no data to return). Responses are preferred
|
||||
* and will ease any future migration to Remix
|
||||
*/
|
||||
type DataFunctionValue = Response | NonNullable<unknown> | null;
|
||||
type DataFunctionReturnValue = Promise<DataFunctionValue> | DataFunctionValue;
|
||||
/**
|
||||
* Route loader function signature
|
||||
*/
|
||||
export type LoaderFunction<Context = any> = {
|
||||
(args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
||||
} & {
|
||||
hydrate?: boolean;
|
||||
};
|
||||
/**
|
||||
* Route action function signature
|
||||
*/
|
||||
export interface ActionFunction<Context = any> {
|
||||
(args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
||||
}
|
||||
/**
|
||||
* Arguments passed to shouldRevalidate function
|
||||
*/
|
||||
export interface ShouldRevalidateFunctionArgs {
|
||||
currentUrl: URL;
|
||||
currentParams: AgnosticDataRouteMatch["params"];
|
||||
nextUrl: URL;
|
||||
nextParams: AgnosticDataRouteMatch["params"];
|
||||
formMethod?: Submission["formMethod"];
|
||||
formAction?: Submission["formAction"];
|
||||
formEncType?: Submission["formEncType"];
|
||||
text?: Submission["text"];
|
||||
formData?: Submission["formData"];
|
||||
json?: Submission["json"];
|
||||
actionStatus?: number;
|
||||
actionResult?: any;
|
||||
defaultShouldRevalidate: boolean;
|
||||
}
|
||||
/**
|
||||
* Route shouldRevalidate function signature. This runs after any submission
|
||||
* (navigation or fetcher), so we flatten the navigation/fetcher submission
|
||||
* onto the arguments. It shouldn't matter whether it came from a navigation
|
||||
* or a fetcher, what really matters is the URLs and the formData since loaders
|
||||
* have to re-run based on the data models that were potentially mutated.
|
||||
*/
|
||||
export interface ShouldRevalidateFunction {
|
||||
(args: ShouldRevalidateFunctionArgs): boolean;
|
||||
}
|
||||
/**
|
||||
* Function provided by the framework-aware layers to set `hasErrorBoundary`
|
||||
* from the framework-aware `errorElement` prop
|
||||
*
|
||||
* @deprecated Use `mapRouteProperties` instead
|
||||
*/
|
||||
export interface DetectErrorBoundaryFunction {
|
||||
(route: AgnosticRouteObject): boolean;
|
||||
}
|
||||
export interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
||||
shouldLoad: boolean;
|
||||
resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
|
||||
}
|
||||
export interface DataStrategyFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
||||
matches: DataStrategyMatch[];
|
||||
fetcherKey: string | null;
|
||||
}
|
||||
/**
|
||||
* Result from a loader or action called via dataStrategy
|
||||
*/
|
||||
export interface DataStrategyResult {
|
||||
type: "data" | "error";
|
||||
result: unknown;
|
||||
}
|
||||
export interface DataStrategyFunction {
|
||||
(args: DataStrategyFunctionArgs): Promise<Record<string, DataStrategyResult>>;
|
||||
}
|
||||
export type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
|
||||
signal: AbortSignal;
|
||||
path: string;
|
||||
matches: M[];
|
||||
fetcherKey: string | undefined;
|
||||
patch: (routeId: string | null, children: O[]) => void;
|
||||
};
|
||||
export type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => void | Promise<void>;
|
||||
/**
|
||||
* Function provided by the framework-aware layers to set any framework-specific
|
||||
* properties from framework-agnostic properties
|
||||
*/
|
||||
export interface MapRoutePropertiesFunction {
|
||||
(route: AgnosticRouteObject): {
|
||||
hasErrorBoundary: boolean;
|
||||
} & Record<string, any>;
|
||||
}
|
||||
/**
|
||||
* Keys we cannot change from within a lazy() function. We spread all other keys
|
||||
* onto the route. Either they're meaningful to the router, or they'll get
|
||||
* ignored.
|
||||
*/
|
||||
export type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
|
||||
export declare const immutableRouteKeys: Set<ImmutableRouteKey>;
|
||||
type RequireOne<T, Key = keyof T> = Exclude<{
|
||||
[K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
|
||||
}[keyof T], undefined>;
|
||||
/**
|
||||
* lazy() function to load a route definition, which can add non-matching
|
||||
* related properties to a route
|
||||
*/
|
||||
export interface LazyRouteFunction<R extends AgnosticRouteObject> {
|
||||
(): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
|
||||
}
|
||||
/**
|
||||
* Base RouteObject with common props shared by all types of routes
|
||||
*/
|
||||
type AgnosticBaseRouteObject = {
|
||||
caseSensitive?: boolean;
|
||||
path?: string;
|
||||
id?: string;
|
||||
loader?: LoaderFunction | boolean;
|
||||
action?: ActionFunction | boolean;
|
||||
hasErrorBoundary?: boolean;
|
||||
shouldRevalidate?: ShouldRevalidateFunction;
|
||||
handle?: any;
|
||||
lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
|
||||
};
|
||||
/**
|
||||
* Index routes must not have children
|
||||
*/
|
||||
export type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
|
||||
children?: undefined;
|
||||
index: true;
|
||||
};
|
||||
/**
|
||||
* Non-index routes may have children, but cannot have index
|
||||
*/
|
||||
export type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
|
||||
children?: AgnosticRouteObject[];
|
||||
index?: false;
|
||||
};
|
||||
/**
|
||||
* A route object represents a logical route, with (optionally) its child
|
||||
* routes organized in a tree-like structure.
|
||||
*/
|
||||
export type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
|
||||
export type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
|
||||
id: string;
|
||||
};
|
||||
export type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
|
||||
children?: AgnosticDataRouteObject[];
|
||||
id: string;
|
||||
};
|
||||
/**
|
||||
* A data route object, which is just a RouteObject with a required unique ID
|
||||
*/
|
||||
export type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
|
||||
export type RouteManifest = Record<string, AgnosticDataRouteObject | undefined>;
|
||||
type _PathParam<Path extends string> = Path extends `${infer L}/${infer R}` ? _PathParam<L> | _PathParam<R> : Path extends `:${infer Param}` ? Param extends `${infer Optional}?` ? Optional : Param : never;
|
||||
/**
|
||||
* Examples:
|
||||
* "/a/b/*" -> "*"
|
||||
* ":a" -> "a"
|
||||
* "/a/:b" -> "b"
|
||||
* "/a/blahblahblah:b" -> "b"
|
||||
* "/:a/:b" -> "a" | "b"
|
||||
* "/:a/b/:c/*" -> "a" | "c" | "*"
|
||||
*/
|
||||
export type PathParam<Path extends string> = Path extends "*" | "/*" ? "*" : Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> : _PathParam<Path>;
|
||||
export type ParamParseKey<Segment extends string> = [
|
||||
PathParam<Segment>
|
||||
] extends [never] ? string : PathParam<Segment>;
|
||||
/**
|
||||
* The parameters that were parsed from the URL path.
|
||||
*/
|
||||
export type Params<Key extends string = string> = {
|
||||
readonly [key in Key]: string | undefined;
|
||||
};
|
||||
/**
|
||||
* A RouteMatch contains info about how a route matched a URL.
|
||||
*/
|
||||
export interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
|
||||
/**
|
||||
* The names and values of dynamic parameters in the URL.
|
||||
*/
|
||||
params: Params<ParamKey>;
|
||||
/**
|
||||
* The portion of the URL pathname that was matched.
|
||||
*/
|
||||
pathname: string;
|
||||
/**
|
||||
* The portion of the URL pathname that was matched before child routes.
|
||||
*/
|
||||
pathnameBase: string;
|
||||
/**
|
||||
* The route object that was used to match.
|
||||
*/
|
||||
route: RouteObjectType;
|
||||
}
|
||||
export interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
||||
}
|
||||
export declare function convertRoutesToDataRoutes(routes: AgnosticRouteObject[], mapRouteProperties: MapRoutePropertiesFunction, parentPath?: string[], manifest?: RouteManifest): AgnosticDataRouteObject[];
|
||||
/**
|
||||
* Matches the given routes to a location and returns the match data.
|
||||
*
|
||||
* @see https://reactrouter.com/v6/utils/match-routes
|
||||
*/
|
||||
export declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
|
||||
export declare function matchRoutesImpl<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename: string, allowPartial: boolean): AgnosticRouteMatch<string, RouteObjectType>[] | null;
|
||||
export interface UIMatch<Data = unknown, Handle = unknown> {
|
||||
id: string;
|
||||
pathname: string;
|
||||
params: AgnosticRouteMatch["params"];
|
||||
data: Data;
|
||||
handle: Handle;
|
||||
}
|
||||
export declare function convertRouteMatchToUiMatch(match: AgnosticDataRouteMatch, loaderData: RouteData): UIMatch;
|
||||
/**
|
||||
* Returns a path with params interpolated.
|
||||
*
|
||||
* @see https://reactrouter.com/v6/utils/generate-path
|
||||
*/
|
||||
export declare function generatePath<Path extends string>(originalPath: Path, params?: {
|
||||
[key in PathParam<Path>]: string | null;
|
||||
}): string;
|
||||
/**
|
||||
* A PathPattern is used to match on some portion of a URL pathname.
|
||||
*/
|
||||
export interface PathPattern<Path extends string = string> {
|
||||
/**
|
||||
* A string to match against a URL pathname. May contain `:id`-style segments
|
||||
* to indicate placeholders for dynamic parameters. May also end with `/*` to
|
||||
* indicate matching the rest of the URL pathname.
|
||||
*/
|
||||
path: Path;
|
||||
/**
|
||||
* Should be `true` if the static portions of the `path` should be matched in
|
||||
* the same case.
|
||||
*/
|
||||
caseSensitive?: boolean;
|
||||
/**
|
||||
* Should be `true` if this pattern should match the entire URL pathname.
|
||||
*/
|
||||
end?: boolean;
|
||||
}
|
||||
/**
|
||||
* A PathMatch contains info about how a PathPattern matched on a URL pathname.
|
||||
*/
|
||||
export interface PathMatch<ParamKey extends string = string> {
|
||||
/**
|
||||
* The names and values of dynamic parameters in the URL.
|
||||
*/
|
||||
params: Params<ParamKey>;
|
||||
/**
|
||||
* The portion of the URL pathname that was matched.
|
||||
*/
|
||||
pathname: string;
|
||||
/**
|
||||
* The portion of the URL pathname that was matched before child routes.
|
||||
*/
|
||||
pathnameBase: string;
|
||||
/**
|
||||
* The pattern that was used to match.
|
||||
*/
|
||||
pattern: PathPattern;
|
||||
}
|
||||
/**
|
||||
* Performs pattern matching on a URL pathname and returns information about
|
||||
* the match.
|
||||
*
|
||||
* @see https://reactrouter.com/v6/utils/match-path
|
||||
*/
|
||||
export declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
|
||||
export declare function decodePath(value: string): string;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare function stripBasename(pathname: string, basename: string): string | null;
|
||||
/**
|
||||
* Returns a resolved path object relative to the given pathname.
|
||||
*
|
||||
* @see https://reactrouter.com/v6/utils/resolve-path
|
||||
*/
|
||||
export declare function resolvePath(to: To, fromPathname?: string): Path;
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* When processing relative navigation we want to ignore ancestor routes that
|
||||
* do not contribute to the path, such that index/pathless layout routes don't
|
||||
* interfere.
|
||||
*
|
||||
* For example, when moving a route element into an index route and/or a
|
||||
* pathless layout route, relative link behavior contained within should stay
|
||||
* the same. Both of the following examples should link back to the root:
|
||||
*
|
||||
* <Route path="/">
|
||||
* <Route path="accounts" element={<Link to=".."}>
|
||||
* </Route>
|
||||
*
|
||||
* <Route path="/">
|
||||
* <Route path="accounts">
|
||||
* <Route element={<AccountsLayout />}> // <-- Does not contribute
|
||||
* <Route index element={<Link to=".."} /> // <-- Does not contribute
|
||||
* </Route
|
||||
* </Route>
|
||||
* </Route>
|
||||
*/
|
||||
export declare function getPathContributingMatches<T extends AgnosticRouteMatch = AgnosticRouteMatch>(matches: T[]): T[];
|
||||
export declare function getResolveToMatches<T extends AgnosticRouteMatch = AgnosticRouteMatch>(matches: T[], v7_relativeSplatPath: boolean): string[];
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare function resolveTo(toArg: To, routePathnames: string[], locationPathname: string, isPathRelative?: boolean): Path;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare function getToPathname(to: To): string | undefined;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare const joinPaths: (paths: string[]) => string;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare const normalizePathname: (pathname: string) => string;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare const normalizeSearch: (search: string) => string;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare const normalizeHash: (hash: string) => string;
|
||||
export type JsonFunction = <Data>(data: Data, init?: number | ResponseInit) => Response;
|
||||
/**
|
||||
* This is a shortcut for creating `application/json` responses. Converts `data`
|
||||
* to JSON and sets the `Content-Type` header.
|
||||
*
|
||||
* @deprecated The `json` method is deprecated in favor of returning raw objects.
|
||||
* This method will be removed in v7.
|
||||
*/
|
||||
export declare const json: JsonFunction;
|
||||
export declare class DataWithResponseInit<D> {
|
||||
type: string;
|
||||
data: D;
|
||||
init: ResponseInit | null;
|
||||
constructor(data: D, init?: ResponseInit);
|
||||
}
|
||||
/**
|
||||
* Create "responses" that contain `status`/`headers` without forcing
|
||||
* serialization into an actual `Response` - used by Remix single fetch
|
||||
*/
|
||||
export declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
|
||||
export interface TrackedPromise extends Promise<any> {
|
||||
_tracked?: boolean;
|
||||
_data?: any;
|
||||
_error?: any;
|
||||
}
|
||||
export declare class AbortedDeferredError extends Error {
|
||||
}
|
||||
export declare class DeferredData {
|
||||
private pendingKeysSet;
|
||||
private controller;
|
||||
private abortPromise;
|
||||
private unlistenAbortSignal;
|
||||
private subscribers;
|
||||
data: Record<string, unknown>;
|
||||
init?: ResponseInit;
|
||||
deferredKeys: string[];
|
||||
constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
|
||||
private trackPromise;
|
||||
private onSettle;
|
||||
private emit;
|
||||
subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
|
||||
cancel(): void;
|
||||
resolveData(signal: AbortSignal): Promise<boolean>;
|
||||
get done(): boolean;
|
||||
get unwrappedData(): {};
|
||||
get pendingKeys(): string[];
|
||||
}
|
||||
export type DeferFunction = (data: Record<string, unknown>, init?: number | ResponseInit) => DeferredData;
|
||||
/**
|
||||
* @deprecated The `defer` method is deprecated in favor of returning raw
|
||||
* objects. This method will be removed in v7.
|
||||
*/
|
||||
export declare const defer: DeferFunction;
|
||||
export type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
||||
/**
|
||||
* A redirect response. Sets the status code and the `Location` header.
|
||||
* Defaults to "302 Found".
|
||||
*/
|
||||
export declare const redirect: RedirectFunction;
|
||||
/**
|
||||
* A redirect response that will force a document reload to the new location.
|
||||
* Sets the status code and the `Location` header.
|
||||
* Defaults to "302 Found".
|
||||
*/
|
||||
export declare const redirectDocument: RedirectFunction;
|
||||
/**
|
||||
* A redirect response that will perform a `history.replaceState` instead of a
|
||||
* `history.pushState` for client-side navigation redirects.
|
||||
* Sets the status code and the `Location` header.
|
||||
* Defaults to "302 Found".
|
||||
*/
|
||||
export declare const replace: RedirectFunction;
|
||||
export type ErrorResponse = {
|
||||
status: number;
|
||||
statusText: string;
|
||||
data: any;
|
||||
};
|
||||
/**
|
||||
* @private
|
||||
* Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies
|
||||
*
|
||||
* We don't export the class for public use since it's an implementation
|
||||
* detail, but we export the interface above so folks can build their own
|
||||
* abstractions around instances via isRouteErrorResponse()
|
||||
*/
|
||||
export declare class ErrorResponseImpl implements ErrorResponse {
|
||||
status: number;
|
||||
statusText: string;
|
||||
data: any;
|
||||
private error?;
|
||||
private internal;
|
||||
constructor(status: number, statusText: string | undefined, data: any, internal?: boolean);
|
||||
}
|
||||
/**
|
||||
* Check if the given error is an ErrorResponse generated from a 4xx/5xx
|
||||
* Response thrown from an action/loader
|
||||
*/
|
||||
export declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
||||
export {};
|
746
node_modules/@remix-run/router/history.ts
generated
vendored
Normal file
746
node_modules/@remix-run/router/history.ts
generated
vendored
Normal file
|
@ -0,0 +1,746 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//#region Types and Constants
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Actions represent the type of change to a location value.
|
||||
*/
|
||||
export enum Action {
|
||||
/**
|
||||
* A POP indicates a change to an arbitrary index in the history stack, such
|
||||
* as a back or forward navigation. It does not describe the direction of the
|
||||
* navigation, only that the current index changed.
|
||||
*
|
||||
* Note: This is the default action for newly created history objects.
|
||||
*/
|
||||
Pop = "POP",
|
||||
|
||||
/**
|
||||
* A PUSH indicates a new entry being added to the history stack, such as when
|
||||
* a link is clicked and a new page loads. When this happens, all subsequent
|
||||
* entries in the stack are lost.
|
||||
*/
|
||||
Push = "PUSH",
|
||||
|
||||
/**
|
||||
* A REPLACE indicates the entry at the current index in the history stack
|
||||
* being replaced by a new one.
|
||||
*/
|
||||
Replace = "REPLACE",
|
||||
}
|
||||
|
||||
/**
|
||||
* The pathname, search, and hash values of a URL.
|
||||
*/
|
||||
export interface Path {
|
||||
/**
|
||||
* A URL pathname, beginning with a /.
|
||||
*/
|
||||
pathname: string;
|
||||
|
||||
/**
|
||||
* A URL search string, beginning with a ?.
|
||||
*/
|
||||
search: string;
|
||||
|
||||
/**
|
||||
* A URL fragment identifier, beginning with a #.
|
||||
*/
|
||||
hash: string;
|
||||
}
|
||||
|
||||
// TODO: (v7) Change the Location generic default from `any` to `unknown` and
|
||||
// remove Remix `useLocation` wrapper.
|
||||
|
||||
/**
|
||||
* An entry in a history stack. A location contains information about the
|
||||
* URL path, as well as possibly some arbitrary state and a key.
|
||||
*/
|
||||
export interface Location<State = any> extends Path {
|
||||
/**
|
||||
* A value of arbitrary data associated with this location.
|
||||
*/
|
||||
state: State;
|
||||
|
||||
/**
|
||||
* A unique string associated with this location. May be used to safely store
|
||||
* and retrieve data in some other storage API, like `localStorage`.
|
||||
*
|
||||
* Note: This value is always "default" on the initial location.
|
||||
*/
|
||||
key: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A change to the current location.
|
||||
*/
|
||||
export interface Update {
|
||||
/**
|
||||
* The action that triggered the change.
|
||||
*/
|
||||
action: Action;
|
||||
|
||||
/**
|
||||
* The new location.
|
||||
*/
|
||||
location: Location;
|
||||
|
||||
/**
|
||||
* The delta between this location and the former location in the history stack
|
||||
*/
|
||||
delta: number | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that receives notifications about location changes.
|
||||
*/
|
||||
export interface Listener {
|
||||
(update: Update): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes a location that is the destination of some navigation, either via
|
||||
* `history.push` or `history.replace`. This may be either a URL or the pieces
|
||||
* of a URL path.
|
||||
*/
|
||||
export type To = string | Partial<Path>;
|
||||
|
||||
/**
|
||||
* A history is an interface to the navigation stack. The history serves as the
|
||||
* source of truth for the current location, as well as provides a set of
|
||||
* methods that may be used to change it.
|
||||
*
|
||||
* It is similar to the DOM's `window.history` object, but with a smaller, more
|
||||
* focused API.
|
||||
*/
|
||||
export interface History {
|
||||
/**
|
||||
* The last action that modified the current location. This will always be
|
||||
* Action.Pop when a history instance is first created. This value is mutable.
|
||||
*/
|
||||
readonly action: Action;
|
||||
|
||||
/**
|
||||
* The current location. This value is mutable.
|
||||
*/
|
||||
readonly location: Location;
|
||||
|
||||
/**
|
||||
* Returns a valid href for the given `to` value that may be used as
|
||||
* the value of an <a href> attribute.
|
||||
*
|
||||
* @param to - The destination URL
|
||||
*/
|
||||
createHref(to: To): string;
|
||||
|
||||
/**
|
||||
* Returns a URL for the given `to` value
|
||||
*
|
||||
* @param to - The destination URL
|
||||
*/
|
||||
createURL(to: To): URL;
|
||||
|
||||
/**
|
||||
* Encode a location the same way window.history would do (no-op for memory
|
||||
* history) so we ensure our PUSH/REPLACE navigations for data routers
|
||||
* behave the same as POP
|
||||
*
|
||||
* @param to Unencoded path
|
||||
*/
|
||||
encodeLocation(to: To): Path;
|
||||
|
||||
/**
|
||||
* Pushes a new location onto the history stack, increasing its length by one.
|
||||
* If there were any entries in the stack after the current one, they are
|
||||
* lost.
|
||||
*
|
||||
* @param to - The new URL
|
||||
* @param state - Data to associate with the new location
|
||||
*/
|
||||
push(to: To, state?: any): void;
|
||||
|
||||
/**
|
||||
* Replaces the current location in the history stack with a new one. The
|
||||
* location that was replaced will no longer be available.
|
||||
*
|
||||
* @param to - The new URL
|
||||
* @param state - Data to associate with the new location
|
||||
*/
|
||||
replace(to: To, state?: any): void;
|
||||
|
||||
/**
|
||||
* Navigates `n` entries backward/forward in the history stack relative to the
|
||||
* current index. For example, a "back" navigation would use go(-1).
|
||||
*
|
||||
* @param delta - The delta in the stack index
|
||||
*/
|
||||
go(delta: number): void;
|
||||
|
||||
/**
|
||||
* Sets up a listener that will be called whenever the current location
|
||||
* changes.
|
||||
*
|
||||
* @param listener - A function that will be called when the location changes
|
||||
* @returns unlisten - A function that may be used to stop listening
|
||||
*/
|
||||
listen(listener: Listener): () => void;
|
||||
}
|
||||
|
||||
type HistoryState = {
|
||||
usr: any;
|
||||
key?: string;
|
||||
idx: number;
|
||||
};
|
||||
|
||||
const PopStateEventType = "popstate";
|
||||
//#endregion
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//#region Memory History
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* A user-supplied object that describes a location. Used when providing
|
||||
* entries to `createMemoryHistory` via its `initialEntries` option.
|
||||
*/
|
||||
export type InitialEntry = string | Partial<Location>;
|
||||
|
||||
export type MemoryHistoryOptions = {
|
||||
initialEntries?: InitialEntry[];
|
||||
initialIndex?: number;
|
||||
v5Compat?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* A memory history stores locations in memory. This is useful in stateful
|
||||
* environments where there is no web browser, such as node tests or React
|
||||
* Native.
|
||||
*/
|
||||
export interface MemoryHistory extends History {
|
||||
/**
|
||||
* The current index in the history stack.
|
||||
*/
|
||||
readonly index: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Memory history stores the current location in memory. It is designed for use
|
||||
* in stateful non-browser environments like tests and React Native.
|
||||
*/
|
||||
export function createMemoryHistory(
|
||||
options: MemoryHistoryOptions = {}
|
||||
): MemoryHistory {
|
||||
let { initialEntries = ["/"], initialIndex, v5Compat = false } = options;
|
||||
let entries: Location[]; // Declare so we can access from createMemoryLocation
|
||||
entries = initialEntries.map((entry, index) =>
|
||||
createMemoryLocation(
|
||||
entry,
|
||||
typeof entry === "string" ? null : entry.state,
|
||||
index === 0 ? "default" : undefined
|
||||
)
|
||||
);
|
||||
let index = clampIndex(
|
||||
initialIndex == null ? entries.length - 1 : initialIndex
|
||||
);
|
||||
let action = Action.Pop;
|
||||
let listener: Listener | null = null;
|
||||
|
||||
function clampIndex(n: number): number {
|
||||
return Math.min(Math.max(n, 0), entries.length - 1);
|
||||
}
|
||||
function getCurrentLocation(): Location {
|
||||
return entries[index];
|
||||
}
|
||||
function createMemoryLocation(
|
||||
to: To,
|
||||
state: any = null,
|
||||
key?: string
|
||||
): Location {
|
||||
let location = createLocation(
|
||||
entries ? getCurrentLocation().pathname : "/",
|
||||
to,
|
||||
state,
|
||||
key
|
||||
);
|
||||
warning(
|
||||
location.pathname.charAt(0) === "/",
|
||||
`relative pathnames are not supported in memory history: ${JSON.stringify(
|
||||
to
|
||||
)}`
|
||||
);
|
||||
return location;
|
||||
}
|
||||
|
||||
function createHref(to: To) {
|
||||
return typeof to === "string" ? to : createPath(to);
|
||||
}
|
||||
|
||||
let history: MemoryHistory = {
|
||||
get index() {
|
||||
return index;
|
||||
},
|
||||
get action() {
|
||||
return action;
|
||||
},
|
||||
get location() {
|
||||
return getCurrentLocation();
|
||||
},
|
||||
createHref,
|
||||
createURL(to) {
|
||||
return new URL(createHref(to), "http://localhost");
|
||||
},
|
||||
encodeLocation(to: To) {
|
||||
let path = typeof to === "string" ? parsePath(to) : to;
|
||||
return {
|
||||
pathname: path.pathname || "",
|
||||
search: path.search || "",
|
||||
hash: path.hash || "",
|
||||
};
|
||||
},
|
||||
push(to, state) {
|
||||
action = Action.Push;
|
||||
let nextLocation = createMemoryLocation(to, state);
|
||||
index += 1;
|
||||
entries.splice(index, entries.length, nextLocation);
|
||||
if (v5Compat && listener) {
|
||||
listener({ action, location: nextLocation, delta: 1 });
|
||||
}
|
||||
},
|
||||
replace(to, state) {
|
||||
action = Action.Replace;
|
||||
let nextLocation = createMemoryLocation(to, state);
|
||||
entries[index] = nextLocation;
|
||||
if (v5Compat && listener) {
|
||||
listener({ action, location: nextLocation, delta: 0 });
|
||||
}
|
||||
},
|
||||
go(delta) {
|
||||
action = Action.Pop;
|
||||
let nextIndex = clampIndex(index + delta);
|
||||
let nextLocation = entries[nextIndex];
|
||||
index = nextIndex;
|
||||
if (listener) {
|
||||
listener({ action, location: nextLocation, delta });
|
||||
}
|
||||
},
|
||||
listen(fn: Listener) {
|
||||
listener = fn;
|
||||
return () => {
|
||||
listener = null;
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
return history;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//#region Browser History
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* A browser history stores the current location in regular URLs in a web
|
||||
* browser environment. This is the standard for most web apps and provides the
|
||||
* cleanest URLs the browser's address bar.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
|
||||
*/
|
||||
export interface BrowserHistory extends UrlHistory {}
|
||||
|
||||
export type BrowserHistoryOptions = UrlHistoryOptions;
|
||||
|
||||
/**
|
||||
* Browser history stores the location in regular URLs. This is the standard for
|
||||
* most web apps, but it requires some configuration on the server to ensure you
|
||||
* serve the same app at multiple URLs.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
|
||||
*/
|
||||
export function createBrowserHistory(
|
||||
options: BrowserHistoryOptions = {}
|
||||
): BrowserHistory {
|
||||
function createBrowserLocation(
|
||||
window: Window,
|
||||
globalHistory: Window["history"]
|
||||
) {
|
||||
let { pathname, search, hash } = window.location;
|
||||
return createLocation(
|
||||
"",
|
||||
{ pathname, search, hash },
|
||||
// state defaults to `null` because `window.history.state` does
|
||||
(globalHistory.state && globalHistory.state.usr) || null,
|
||||
(globalHistory.state && globalHistory.state.key) || "default"
|
||||
);
|
||||
}
|
||||
|
||||
function createBrowserHref(window: Window, to: To) {
|
||||
return typeof to === "string" ? to : createPath(to);
|
||||
}
|
||||
|
||||
return getUrlBasedHistory(
|
||||
createBrowserLocation,
|
||||
createBrowserHref,
|
||||
null,
|
||||
options
|
||||
);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//#region Hash History
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* A hash history stores the current location in the fragment identifier portion
|
||||
* of the URL in a web browser environment.
|
||||
*
|
||||
* This is ideal for apps that do not control the server for some reason
|
||||
* (because the fragment identifier is never sent to the server), including some
|
||||
* shared hosting environments that do not provide fine-grained controls over
|
||||
* which pages are served at which URLs.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory
|
||||
*/
|
||||
export interface HashHistory extends UrlHistory {}
|
||||
|
||||
export type HashHistoryOptions = UrlHistoryOptions;
|
||||
|
||||
/**
|
||||
* Hash history stores the location in window.location.hash. This makes it ideal
|
||||
* for situations where you don't want to send the location to the server for
|
||||
* some reason, either because you do cannot configure it or the URL space is
|
||||
* reserved for something else.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
|
||||
*/
|
||||
export function createHashHistory(
|
||||
options: HashHistoryOptions = {}
|
||||
): HashHistory {
|
||||
function createHashLocation(
|
||||
window: Window,
|
||||
globalHistory: Window["history"]
|
||||
) {
|
||||
let {
|
||||
pathname = "/",
|
||||
search = "",
|
||||
hash = "",
|
||||
} = parsePath(window.location.hash.substr(1));
|
||||
|
||||
// Hash URL should always have a leading / just like window.location.pathname
|
||||
// does, so if an app ends up at a route like /#something then we add a
|
||||
// leading slash so all of our path-matching behaves the same as if it would
|
||||
// in a browser router. This is particularly important when there exists a
|
||||
// root splat route (<Route path="*">) since that matches internally against
|
||||
// "/*" and we'd expect /#something to 404 in a hash router app.
|
||||
if (!pathname.startsWith("/") && !pathname.startsWith(".")) {
|
||||
pathname = "/" + pathname;
|
||||
}
|
||||
|
||||
return createLocation(
|
||||
"",
|
||||
{ pathname, search, hash },
|
||||
// state defaults to `null` because `window.history.state` does
|
||||
(globalHistory.state && globalHistory.state.usr) || null,
|
||||
(globalHistory.state && globalHistory.state.key) || "default"
|
||||
);
|
||||
}
|
||||
|
||||
function createHashHref(window: Window, to: To) {
|
||||
let base = window.document.querySelector("base");
|
||||
let href = "";
|
||||
|
||||
if (base && base.getAttribute("href")) {
|
||||
let url = window.location.href;
|
||||
let hashIndex = url.indexOf("#");
|
||||
href = hashIndex === -1 ? url : url.slice(0, hashIndex);
|
||||
}
|
||||
|
||||
return href + "#" + (typeof to === "string" ? to : createPath(to));
|
||||
}
|
||||
|
||||
function validateHashLocation(location: Location, to: To) {
|
||||
warning(
|
||||
location.pathname.charAt(0) === "/",
|
||||
`relative pathnames are not supported in hash history.push(${JSON.stringify(
|
||||
to
|
||||
)})`
|
||||
);
|
||||
}
|
||||
|
||||
return getUrlBasedHistory(
|
||||
createHashLocation,
|
||||
createHashHref,
|
||||
validateHashLocation,
|
||||
options
|
||||
);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//#region UTILS
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export function invariant(value: boolean, message?: string): asserts value;
|
||||
export function invariant<T>(
|
||||
value: T | null | undefined,
|
||||
message?: string
|
||||
): asserts value is T;
|
||||
export function invariant(value: any, message?: string) {
|
||||
if (value === false || value === null || typeof value === "undefined") {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
export function warning(cond: any, message: string) {
|
||||
if (!cond) {
|
||||
// eslint-disable-next-line no-console
|
||||
if (typeof console !== "undefined") console.warn(message);
|
||||
|
||||
try {
|
||||
// Welcome to debugging history!
|
||||
//
|
||||
// This error is thrown as a convenience, so you can more easily
|
||||
// find the source for a warning that appears in the console by
|
||||
// enabling "pause on exceptions" in your JavaScript debugger.
|
||||
throw new Error(message);
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
function createKey() {
|
||||
return Math.random().toString(36).substr(2, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* For browser-based histories, we combine the state and key into an object
|
||||
*/
|
||||
function getHistoryState(location: Location, index: number): HistoryState {
|
||||
return {
|
||||
usr: location.state,
|
||||
key: location.key,
|
||||
idx: index,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Location object with a unique key from the given Path
|
||||
*/
|
||||
export function createLocation(
|
||||
current: string | Location,
|
||||
to: To,
|
||||
state: any = null,
|
||||
key?: string
|
||||
): Readonly<Location> {
|
||||
let location: Readonly<Location> = {
|
||||
pathname: typeof current === "string" ? current : current.pathname,
|
||||
search: "",
|
||||
hash: "",
|
||||
...(typeof to === "string" ? parsePath(to) : to),
|
||||
state,
|
||||
// TODO: This could be cleaned up. push/replace should probably just take
|
||||
// full Locations now and avoid the need to run through this flow at all
|
||||
// But that's a pretty big refactor to the current test suite so going to
|
||||
// keep as is for the time being and just let any incoming keys take precedence
|
||||
key: (to && (to as Location).key) || key || createKey(),
|
||||
};
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a string URL path from the given pathname, search, and hash components.
|
||||
*/
|
||||
export function createPath({
|
||||
pathname = "/",
|
||||
search = "",
|
||||
hash = "",
|
||||
}: Partial<Path>) {
|
||||
if (search && search !== "?")
|
||||
pathname += search.charAt(0) === "?" ? search : "?" + search;
|
||||
if (hash && hash !== "#")
|
||||
pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
||||
return pathname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a string URL path into its separate pathname, search, and hash components.
|
||||
*/
|
||||
export function parsePath(path: string): Partial<Path> {
|
||||
let parsedPath: Partial<Path> = {};
|
||||
|
||||
if (path) {
|
||||
let hashIndex = path.indexOf("#");
|
||||
if (hashIndex >= 0) {
|
||||
parsedPath.hash = path.substr(hashIndex);
|
||||
path = path.substr(0, hashIndex);
|
||||
}
|
||||
|
||||
let searchIndex = path.indexOf("?");
|
||||
if (searchIndex >= 0) {
|
||||
parsedPath.search = path.substr(searchIndex);
|
||||
path = path.substr(0, searchIndex);
|
||||
}
|
||||
|
||||
if (path) {
|
||||
parsedPath.pathname = path;
|
||||
}
|
||||
}
|
||||
|
||||
return parsedPath;
|
||||
}
|
||||
|
||||
export interface UrlHistory extends History {}
|
||||
|
||||
export type UrlHistoryOptions = {
|
||||
window?: Window;
|
||||
v5Compat?: boolean;
|
||||
};
|
||||
|
||||
function getUrlBasedHistory(
|
||||
getLocation: (window: Window, globalHistory: Window["history"]) => Location,
|
||||
createHref: (window: Window, to: To) => string,
|
||||
validateLocation: ((location: Location, to: To) => void) | null,
|
||||
options: UrlHistoryOptions = {}
|
||||
): UrlHistory {
|
||||
let { window = document.defaultView!, v5Compat = false } = options;
|
||||
let globalHistory = window.history;
|
||||
let action = Action.Pop;
|
||||
let listener: Listener | null = null;
|
||||
|
||||
let index = getIndex()!;
|
||||
// Index should only be null when we initialize. If not, it's because the
|
||||
// user called history.pushState or history.replaceState directly, in which
|
||||
// case we should log a warning as it will result in bugs.
|
||||
if (index == null) {
|
||||
index = 0;
|
||||
globalHistory.replaceState({ ...globalHistory.state, idx: index }, "");
|
||||
}
|
||||
|
||||
function getIndex(): number {
|
||||
let state = globalHistory.state || { idx: null };
|
||||
return state.idx;
|
||||
}
|
||||
|
||||
function handlePop() {
|
||||
action = Action.Pop;
|
||||
let nextIndex = getIndex();
|
||||
let delta = nextIndex == null ? null : nextIndex - index;
|
||||
index = nextIndex;
|
||||
if (listener) {
|
||||
listener({ action, location: history.location, delta });
|
||||
}
|
||||
}
|
||||
|
||||
function push(to: To, state?: any) {
|
||||
action = Action.Push;
|
||||
let location = createLocation(history.location, to, state);
|
||||
if (validateLocation) validateLocation(location, to);
|
||||
|
||||
index = getIndex() + 1;
|
||||
let historyState = getHistoryState(location, index);
|
||||
let url = history.createHref(location);
|
||||
|
||||
// try...catch because iOS limits us to 100 pushState calls :/
|
||||
try {
|
||||
globalHistory.pushState(historyState, "", url);
|
||||
} catch (error) {
|
||||
// If the exception is because `state` can't be serialized, let that throw
|
||||
// outwards just like a replace call would so the dev knows the cause
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#shared-history-push/replace-state-steps
|
||||
// https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal
|
||||
if (error instanceof DOMException && error.name === "DataCloneError") {
|
||||
throw error;
|
||||
}
|
||||
// They are going to lose state here, but there is no real
|
||||
// way to warn them about it since the page will refresh...
|
||||
window.location.assign(url);
|
||||
}
|
||||
|
||||
if (v5Compat && listener) {
|
||||
listener({ action, location: history.location, delta: 1 });
|
||||
}
|
||||
}
|
||||
|
||||
function replace(to: To, state?: any) {
|
||||
action = Action.Replace;
|
||||
let location = createLocation(history.location, to, state);
|
||||
if (validateLocation) validateLocation(location, to);
|
||||
|
||||
index = getIndex();
|
||||
let historyState = getHistoryState(location, index);
|
||||
let url = history.createHref(location);
|
||||
globalHistory.replaceState(historyState, "", url);
|
||||
|
||||
if (v5Compat && listener) {
|
||||
listener({ action, location: history.location, delta: 0 });
|
||||
}
|
||||
}
|
||||
|
||||
function createURL(to: To): URL {
|
||||
// window.location.origin is "null" (the literal string value) in Firefox
|
||||
// under certain conditions, notably when serving from a local HTML file
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=878297
|
||||
let base =
|
||||
window.location.origin !== "null"
|
||||
? window.location.origin
|
||||
: window.location.href;
|
||||
|
||||
let href = typeof to === "string" ? to : createPath(to);
|
||||
// Treating this as a full URL will strip any trailing spaces so we need to
|
||||
// pre-encode them since they might be part of a matching splat param from
|
||||
// an ancestor route
|
||||
href = href.replace(/ $/, "%20");
|
||||
invariant(
|
||||
base,
|
||||
`No window.location.(origin|href) available to create URL for href: ${href}`
|
||||
);
|
||||
return new URL(href, base);
|
||||
}
|
||||
|
||||
let history: History = {
|
||||
get action() {
|
||||
return action;
|
||||
},
|
||||
get location() {
|
||||
return getLocation(window, globalHistory);
|
||||
},
|
||||
listen(fn: Listener) {
|
||||
if (listener) {
|
||||
throw new Error("A history only accepts one active listener");
|
||||
}
|
||||
window.addEventListener(PopStateEventType, handlePop);
|
||||
listener = fn;
|
||||
|
||||
return () => {
|
||||
window.removeEventListener(PopStateEventType, handlePop);
|
||||
listener = null;
|
||||
};
|
||||
},
|
||||
createHref(to) {
|
||||
return createHref(window, to);
|
||||
},
|
||||
createURL,
|
||||
encodeLocation(to) {
|
||||
// Encode a Location the same way window.location would
|
||||
let url = createURL(to);
|
||||
return {
|
||||
pathname: url.pathname,
|
||||
search: url.search,
|
||||
hash: url.hash,
|
||||
};
|
||||
},
|
||||
push,
|
||||
replace,
|
||||
go(n) {
|
||||
return globalHistory.go(n);
|
||||
},
|
||||
};
|
||||
|
||||
return history;
|
||||
}
|
||||
|
||||
//#endregion
|
106
node_modules/@remix-run/router/index.ts
generated
vendored
Normal file
106
node_modules/@remix-run/router/index.ts
generated
vendored
Normal file
|
@ -0,0 +1,106 @@
|
|||
export type {
|
||||
ActionFunction,
|
||||
ActionFunctionArgs,
|
||||
AgnosticDataIndexRouteObject,
|
||||
AgnosticDataNonIndexRouteObject,
|
||||
AgnosticDataRouteMatch,
|
||||
AgnosticDataRouteObject,
|
||||
AgnosticIndexRouteObject,
|
||||
AgnosticNonIndexRouteObject,
|
||||
AgnosticPatchRoutesOnNavigationFunction,
|
||||
AgnosticPatchRoutesOnNavigationFunctionArgs,
|
||||
AgnosticRouteMatch,
|
||||
AgnosticRouteObject,
|
||||
DataStrategyFunction,
|
||||
DataStrategyFunctionArgs,
|
||||
DataStrategyMatch,
|
||||
DataStrategyResult,
|
||||
ErrorResponse,
|
||||
FormEncType,
|
||||
FormMethod,
|
||||
HTMLFormMethod,
|
||||
JsonFunction,
|
||||
LazyRouteFunction,
|
||||
LoaderFunction,
|
||||
LoaderFunctionArgs,
|
||||
ParamParseKey,
|
||||
Params,
|
||||
PathMatch,
|
||||
PathParam,
|
||||
PathPattern,
|
||||
RedirectFunction,
|
||||
ShouldRevalidateFunction,
|
||||
ShouldRevalidateFunctionArgs,
|
||||
TrackedPromise,
|
||||
UIMatch,
|
||||
V7_FormMethod,
|
||||
DataWithResponseInit as UNSAFE_DataWithResponseInit,
|
||||
} from "./utils";
|
||||
|
||||
export {
|
||||
AbortedDeferredError,
|
||||
data,
|
||||
defer,
|
||||
generatePath,
|
||||
getToPathname,
|
||||
isRouteErrorResponse,
|
||||
joinPaths,
|
||||
json,
|
||||
matchPath,
|
||||
matchRoutes,
|
||||
normalizePathname,
|
||||
redirect,
|
||||
redirectDocument,
|
||||
replace,
|
||||
resolvePath,
|
||||
resolveTo,
|
||||
stripBasename,
|
||||
} from "./utils";
|
||||
|
||||
export type {
|
||||
BrowserHistory,
|
||||
BrowserHistoryOptions,
|
||||
HashHistory,
|
||||
HashHistoryOptions,
|
||||
History,
|
||||
InitialEntry,
|
||||
Location,
|
||||
MemoryHistory,
|
||||
MemoryHistoryOptions,
|
||||
Path,
|
||||
To,
|
||||
} from "./history";
|
||||
|
||||
export {
|
||||
Action,
|
||||
createBrowserHistory,
|
||||
createHashHistory,
|
||||
createMemoryHistory,
|
||||
createPath,
|
||||
parsePath,
|
||||
} from "./history";
|
||||
|
||||
export * from "./router";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// DANGER! PLEASE READ ME!
|
||||
// We consider these exports an implementation detail and do not guarantee
|
||||
// against any breaking changes, regardless of the semver release. Use with
|
||||
// extreme caution and only if you understand the consequences. Godspeed.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** @internal */
|
||||
export type { RouteManifest as UNSAFE_RouteManifest } from "./utils";
|
||||
export {
|
||||
DeferredData as UNSAFE_DeferredData,
|
||||
ErrorResponseImpl as UNSAFE_ErrorResponseImpl,
|
||||
convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes,
|
||||
convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch,
|
||||
decodePath as UNSAFE_decodePath,
|
||||
getResolveToMatches as UNSAFE_getResolveToMatches,
|
||||
} from "./utils";
|
||||
|
||||
export {
|
||||
invariant as UNSAFE_invariant,
|
||||
warning as UNSAFE_warning,
|
||||
} from "./history";
|
33
node_modules/@remix-run/router/package.json
generated
vendored
Normal file
33
node_modules/@remix-run/router/package.json
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "@remix-run/router",
|
||||
"version": "1.23.0",
|
||||
"description": "Nested/Data-driven/Framework-agnostic Routing",
|
||||
"keywords": [
|
||||
"remix",
|
||||
"router",
|
||||
"location"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remix-run/react-router",
|
||||
"directory": "packages/router"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Remix Software <hello@remix.run>",
|
||||
"sideEffects": false,
|
||||
"main": "./dist/router.cjs.js",
|
||||
"unpkg": "./dist/router.umd.min.js",
|
||||
"module": "./dist/router.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/",
|
||||
"*.ts",
|
||||
"CHANGELOG.md"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
6001
node_modules/@remix-run/router/router.ts
generated
vendored
Normal file
6001
node_modules/@remix-run/router/router.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1722
node_modules/@remix-run/router/utils.ts
generated
vendored
Normal file
1722
node_modules/@remix-run/router/utils.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
3
node_modules/@rollup/rollup-darwin-arm64/README.md
generated
vendored
Normal file
3
node_modules/@rollup/rollup-darwin-arm64/README.md
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# `@rollup/rollup-darwin-arm64`
|
||||
|
||||
This is the **aarch64-apple-darwin** binary for `rollup`
|
19
node_modules/@rollup/rollup-darwin-arm64/package.json
generated
vendored
Normal file
19
node_modules/@rollup/rollup-darwin-arm64/package.json
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "@rollup/rollup-darwin-arm64",
|
||||
"version": "4.46.2",
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"files": [
|
||||
"rollup.darwin-arm64.node"
|
||||
],
|
||||
"description": "Native bindings for Rollup",
|
||||
"author": "Lukas Taegert-Atkinson",
|
||||
"homepage": "https://rollupjs.org/",
|
||||
"license": "MIT",
|
||||
"repository": "rollup/rollup",
|
||||
"main": "./rollup.darwin-arm64.node"
|
||||
}
|
BIN
node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node
generated
vendored
Normal file
BIN
node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node
generated
vendored
Normal file
Binary file not shown.
21
node_modules/@types/estree/LICENSE
generated
vendored
Normal file
21
node_modules/@types/estree/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
15
node_modules/@types/estree/README.md
generated
vendored
Normal file
15
node_modules/@types/estree/README.md
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Installation
|
||||
> `npm install --save @types/estree`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for estree (https://github.com/estree/estree).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Fri, 06 Jun 2025 00:04:33 GMT
|
||||
* Dependencies: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [RReverser](https://github.com/RReverser).
|
167
node_modules/@types/estree/flow.d.ts
generated
vendored
Normal file
167
node_modules/@types/estree/flow.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
declare namespace ESTree {
|
||||
interface FlowTypeAnnotation extends Node {}
|
||||
|
||||
interface FlowBaseTypeAnnotation extends FlowTypeAnnotation {}
|
||||
|
||||
interface FlowLiteralTypeAnnotation extends FlowTypeAnnotation, Literal {}
|
||||
|
||||
interface FlowDeclaration extends Declaration {}
|
||||
|
||||
interface AnyTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface ArrayTypeAnnotation extends FlowTypeAnnotation {
|
||||
elementType: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface BooleanLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
||||
|
||||
interface BooleanTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface ClassImplements extends Node {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterInstantiation | null;
|
||||
}
|
||||
|
||||
interface ClassProperty {
|
||||
key: Expression;
|
||||
value?: Expression | null;
|
||||
typeAnnotation?: TypeAnnotation | null;
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface DeclareClass extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
body: ObjectTypeAnnotation;
|
||||
extends: InterfaceExtends[];
|
||||
}
|
||||
|
||||
interface DeclareFunction extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface DeclareModule extends FlowDeclaration {
|
||||
id: Literal | Identifier;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
interface DeclareVariable extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface FunctionTypeAnnotation extends FlowTypeAnnotation {
|
||||
params: FunctionTypeParam[];
|
||||
returnType: FlowTypeAnnotation;
|
||||
rest?: FunctionTypeParam | null;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
}
|
||||
|
||||
interface FunctionTypeParam {
|
||||
name: Identifier;
|
||||
typeAnnotation: FlowTypeAnnotation;
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
interface GenericTypeAnnotation extends FlowTypeAnnotation {
|
||||
id: Identifier | QualifiedTypeIdentifier;
|
||||
typeParameters?: TypeParameterInstantiation | null;
|
||||
}
|
||||
|
||||
interface InterfaceExtends extends Node {
|
||||
id: Identifier | QualifiedTypeIdentifier;
|
||||
typeParameters?: TypeParameterInstantiation | null;
|
||||
}
|
||||
|
||||
interface InterfaceDeclaration extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
extends: InterfaceExtends[];
|
||||
body: ObjectTypeAnnotation;
|
||||
}
|
||||
|
||||
interface IntersectionTypeAnnotation extends FlowTypeAnnotation {
|
||||
types: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface MixedTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface NullableTypeAnnotation extends FlowTypeAnnotation {
|
||||
typeAnnotation: TypeAnnotation;
|
||||
}
|
||||
|
||||
interface NumberLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
||||
|
||||
interface NumberTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface StringLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
||||
|
||||
interface StringTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
|
||||
interface TupleTypeAnnotation extends FlowTypeAnnotation {
|
||||
types: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface TypeofTypeAnnotation extends FlowTypeAnnotation {
|
||||
argument: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeAlias extends FlowDeclaration {
|
||||
id: Identifier;
|
||||
typeParameters?: TypeParameterDeclaration | null;
|
||||
right: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeAnnotation extends Node {
|
||||
typeAnnotation: FlowTypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeCastExpression extends Expression {
|
||||
expression: Expression;
|
||||
typeAnnotation: TypeAnnotation;
|
||||
}
|
||||
|
||||
interface TypeParameterDeclaration extends Node {
|
||||
params: Identifier[];
|
||||
}
|
||||
|
||||
interface TypeParameterInstantiation extends Node {
|
||||
params: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface ObjectTypeAnnotation extends FlowTypeAnnotation {
|
||||
properties: ObjectTypeProperty[];
|
||||
indexers: ObjectTypeIndexer[];
|
||||
callProperties: ObjectTypeCallProperty[];
|
||||
}
|
||||
|
||||
interface ObjectTypeCallProperty extends Node {
|
||||
value: FunctionTypeAnnotation;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface ObjectTypeIndexer extends Node {
|
||||
id: Identifier;
|
||||
key: FlowTypeAnnotation;
|
||||
value: FlowTypeAnnotation;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface ObjectTypeProperty extends Node {
|
||||
key: Expression;
|
||||
value: FlowTypeAnnotation;
|
||||
optional: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
interface QualifiedTypeIdentifier extends Node {
|
||||
qualification: Identifier | QualifiedTypeIdentifier;
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
interface UnionTypeAnnotation extends FlowTypeAnnotation {
|
||||
types: FlowTypeAnnotation[];
|
||||
}
|
||||
|
||||
interface VoidTypeAnnotation extends FlowBaseTypeAnnotation {}
|
||||
}
|
694
node_modules/@types/estree/index.d.ts
generated
vendored
Normal file
694
node_modules/@types/estree/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,694 @@
|
|||
// This definition file follows a somewhat unusual format. ESTree allows
|
||||
// runtime type checks based on the `type` parameter. In order to explain this
|
||||
// to typescript we want to use discriminated union types:
|
||||
// https://github.com/Microsoft/TypeScript/pull/9163
|
||||
//
|
||||
// For ESTree this is a bit tricky because the high level interfaces like
|
||||
// Node or Function are pulling double duty. We want to pass common fields down
|
||||
// to the interfaces that extend them (like Identifier or
|
||||
// ArrowFunctionExpression), but you can't extend a type union or enforce
|
||||
// common fields on them. So we've split the high level interfaces into two
|
||||
// types, a base type which passes down inherited fields, and a type union of
|
||||
// all types which extend the base type. Only the type union is exported, and
|
||||
// the union is how other types refer to the collection of inheriting types.
|
||||
//
|
||||
// This makes the definitions file here somewhat more difficult to maintain,
|
||||
// but it has the notable advantage of making ESTree much easier to use as
|
||||
// an end user.
|
||||
|
||||
export interface BaseNodeWithoutComments {
|
||||
// Every leaf interface that extends BaseNode must specify a type property.
|
||||
// The type property should be a string literal. For example, Identifier
|
||||
// has: `type: "Identifier"`
|
||||
type: string;
|
||||
loc?: SourceLocation | null | undefined;
|
||||
range?: [number, number] | undefined;
|
||||
}
|
||||
|
||||
export interface BaseNode extends BaseNodeWithoutComments {
|
||||
leadingComments?: Comment[] | undefined;
|
||||
trailingComments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
export interface NodeMap {
|
||||
AssignmentProperty: AssignmentProperty;
|
||||
CatchClause: CatchClause;
|
||||
Class: Class;
|
||||
ClassBody: ClassBody;
|
||||
Expression: Expression;
|
||||
Function: Function;
|
||||
Identifier: Identifier;
|
||||
Literal: Literal;
|
||||
MethodDefinition: MethodDefinition;
|
||||
ModuleDeclaration: ModuleDeclaration;
|
||||
ModuleSpecifier: ModuleSpecifier;
|
||||
Pattern: Pattern;
|
||||
PrivateIdentifier: PrivateIdentifier;
|
||||
Program: Program;
|
||||
Property: Property;
|
||||
PropertyDefinition: PropertyDefinition;
|
||||
SpreadElement: SpreadElement;
|
||||
Statement: Statement;
|
||||
Super: Super;
|
||||
SwitchCase: SwitchCase;
|
||||
TemplateElement: TemplateElement;
|
||||
VariableDeclarator: VariableDeclarator;
|
||||
}
|
||||
|
||||
export type Node = NodeMap[keyof NodeMap];
|
||||
|
||||
export interface Comment extends BaseNodeWithoutComments {
|
||||
type: "Line" | "Block";
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface SourceLocation {
|
||||
source?: string | null | undefined;
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
/** >= 1 */
|
||||
line: number;
|
||||
/** >= 0 */
|
||||
column: number;
|
||||
}
|
||||
|
||||
export interface Program extends BaseNode {
|
||||
type: "Program";
|
||||
sourceType: "script" | "module";
|
||||
body: Array<Directive | Statement | ModuleDeclaration>;
|
||||
comments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
export interface Directive extends BaseNode {
|
||||
type: "ExpressionStatement";
|
||||
expression: Literal;
|
||||
directive: string;
|
||||
}
|
||||
|
||||
export interface BaseFunction extends BaseNode {
|
||||
params: Pattern[];
|
||||
generator?: boolean | undefined;
|
||||
async?: boolean | undefined;
|
||||
// The body is either BlockStatement or Expression because arrow functions
|
||||
// can have a body that's either. FunctionDeclarations and
|
||||
// FunctionExpressions have only BlockStatement bodies.
|
||||
body: BlockStatement | Expression;
|
||||
}
|
||||
|
||||
export type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
||||
|
||||
export type Statement =
|
||||
| ExpressionStatement
|
||||
| BlockStatement
|
||||
| StaticBlock
|
||||
| EmptyStatement
|
||||
| DebuggerStatement
|
||||
| WithStatement
|
||||
| ReturnStatement
|
||||
| LabeledStatement
|
||||
| BreakStatement
|
||||
| ContinueStatement
|
||||
| IfStatement
|
||||
| SwitchStatement
|
||||
| ThrowStatement
|
||||
| TryStatement
|
||||
| WhileStatement
|
||||
| DoWhileStatement
|
||||
| ForStatement
|
||||
| ForInStatement
|
||||
| ForOfStatement
|
||||
| Declaration;
|
||||
|
||||
export interface BaseStatement extends BaseNode {}
|
||||
|
||||
export interface EmptyStatement extends BaseStatement {
|
||||
type: "EmptyStatement";
|
||||
}
|
||||
|
||||
export interface BlockStatement extends BaseStatement {
|
||||
type: "BlockStatement";
|
||||
body: Statement[];
|
||||
innerComments?: Comment[] | undefined;
|
||||
}
|
||||
|
||||
export interface StaticBlock extends Omit<BlockStatement, "type"> {
|
||||
type: "StaticBlock";
|
||||
}
|
||||
|
||||
export interface ExpressionStatement extends BaseStatement {
|
||||
type: "ExpressionStatement";
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface IfStatement extends BaseStatement {
|
||||
type: "IfStatement";
|
||||
test: Expression;
|
||||
consequent: Statement;
|
||||
alternate?: Statement | null | undefined;
|
||||
}
|
||||
|
||||
export interface LabeledStatement extends BaseStatement {
|
||||
type: "LabeledStatement";
|
||||
label: Identifier;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface BreakStatement extends BaseStatement {
|
||||
type: "BreakStatement";
|
||||
label?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
export interface ContinueStatement extends BaseStatement {
|
||||
type: "ContinueStatement";
|
||||
label?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
export interface WithStatement extends BaseStatement {
|
||||
type: "WithStatement";
|
||||
object: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface SwitchStatement extends BaseStatement {
|
||||
type: "SwitchStatement";
|
||||
discriminant: Expression;
|
||||
cases: SwitchCase[];
|
||||
}
|
||||
|
||||
export interface ReturnStatement extends BaseStatement {
|
||||
type: "ReturnStatement";
|
||||
argument?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
export interface ThrowStatement extends BaseStatement {
|
||||
type: "ThrowStatement";
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface TryStatement extends BaseStatement {
|
||||
type: "TryStatement";
|
||||
block: BlockStatement;
|
||||
handler?: CatchClause | null | undefined;
|
||||
finalizer?: BlockStatement | null | undefined;
|
||||
}
|
||||
|
||||
export interface WhileStatement extends BaseStatement {
|
||||
type: "WhileStatement";
|
||||
test: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface DoWhileStatement extends BaseStatement {
|
||||
type: "DoWhileStatement";
|
||||
body: Statement;
|
||||
test: Expression;
|
||||
}
|
||||
|
||||
export interface ForStatement extends BaseStatement {
|
||||
type: "ForStatement";
|
||||
init?: VariableDeclaration | Expression | null | undefined;
|
||||
test?: Expression | null | undefined;
|
||||
update?: Expression | null | undefined;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface BaseForXStatement extends BaseStatement {
|
||||
left: VariableDeclaration | Pattern;
|
||||
right: Expression;
|
||||
body: Statement;
|
||||
}
|
||||
|
||||
export interface ForInStatement extends BaseForXStatement {
|
||||
type: "ForInStatement";
|
||||
}
|
||||
|
||||
export interface DebuggerStatement extends BaseStatement {
|
||||
type: "DebuggerStatement";
|
||||
}
|
||||
|
||||
export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
|
||||
|
||||
export interface BaseDeclaration extends BaseStatement {}
|
||||
|
||||
export interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
|
||||
type: "FunctionDeclaration";
|
||||
/** It is null when a function declaration is a part of the `export default function` statement */
|
||||
id: Identifier | null;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
export interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
export interface VariableDeclaration extends BaseDeclaration {
|
||||
type: "VariableDeclaration";
|
||||
declarations: VariableDeclarator[];
|
||||
kind: "var" | "let" | "const" | "using" | "await using";
|
||||
}
|
||||
|
||||
export interface VariableDeclarator extends BaseNode {
|
||||
type: "VariableDeclarator";
|
||||
id: Pattern;
|
||||
init?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
export interface ExpressionMap {
|
||||
ArrayExpression: ArrayExpression;
|
||||
ArrowFunctionExpression: ArrowFunctionExpression;
|
||||
AssignmentExpression: AssignmentExpression;
|
||||
AwaitExpression: AwaitExpression;
|
||||
BinaryExpression: BinaryExpression;
|
||||
CallExpression: CallExpression;
|
||||
ChainExpression: ChainExpression;
|
||||
ClassExpression: ClassExpression;
|
||||
ConditionalExpression: ConditionalExpression;
|
||||
FunctionExpression: FunctionExpression;
|
||||
Identifier: Identifier;
|
||||
ImportExpression: ImportExpression;
|
||||
Literal: Literal;
|
||||
LogicalExpression: LogicalExpression;
|
||||
MemberExpression: MemberExpression;
|
||||
MetaProperty: MetaProperty;
|
||||
NewExpression: NewExpression;
|
||||
ObjectExpression: ObjectExpression;
|
||||
SequenceExpression: SequenceExpression;
|
||||
TaggedTemplateExpression: TaggedTemplateExpression;
|
||||
TemplateLiteral: TemplateLiteral;
|
||||
ThisExpression: ThisExpression;
|
||||
UnaryExpression: UnaryExpression;
|
||||
UpdateExpression: UpdateExpression;
|
||||
YieldExpression: YieldExpression;
|
||||
}
|
||||
|
||||
export type Expression = ExpressionMap[keyof ExpressionMap];
|
||||
|
||||
export interface BaseExpression extends BaseNode {}
|
||||
|
||||
export type ChainElement = SimpleCallExpression | MemberExpression;
|
||||
|
||||
export interface ChainExpression extends BaseExpression {
|
||||
type: "ChainExpression";
|
||||
expression: ChainElement;
|
||||
}
|
||||
|
||||
export interface ThisExpression extends BaseExpression {
|
||||
type: "ThisExpression";
|
||||
}
|
||||
|
||||
export interface ArrayExpression extends BaseExpression {
|
||||
type: "ArrayExpression";
|
||||
elements: Array<Expression | SpreadElement | null>;
|
||||
}
|
||||
|
||||
export interface ObjectExpression extends BaseExpression {
|
||||
type: "ObjectExpression";
|
||||
properties: Array<Property | SpreadElement>;
|
||||
}
|
||||
|
||||
export interface PrivateIdentifier extends BaseNode {
|
||||
type: "PrivateIdentifier";
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Property extends BaseNode {
|
||||
type: "Property";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value: Expression | Pattern; // Could be an AssignmentProperty
|
||||
kind: "init" | "get" | "set";
|
||||
method: boolean;
|
||||
shorthand: boolean;
|
||||
computed: boolean;
|
||||
}
|
||||
|
||||
export interface PropertyDefinition extends BaseNode {
|
||||
type: "PropertyDefinition";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value?: Expression | null | undefined;
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
export interface FunctionExpression extends BaseFunction, BaseExpression {
|
||||
id?: Identifier | null | undefined;
|
||||
type: "FunctionExpression";
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
export interface SequenceExpression extends BaseExpression {
|
||||
type: "SequenceExpression";
|
||||
expressions: Expression[];
|
||||
}
|
||||
|
||||
export interface UnaryExpression extends BaseExpression {
|
||||
type: "UnaryExpression";
|
||||
operator: UnaryOperator;
|
||||
prefix: true;
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface BinaryExpression extends BaseExpression {
|
||||
type: "BinaryExpression";
|
||||
operator: BinaryOperator;
|
||||
left: Expression | PrivateIdentifier;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export interface AssignmentExpression extends BaseExpression {
|
||||
type: "AssignmentExpression";
|
||||
operator: AssignmentOperator;
|
||||
left: Pattern | MemberExpression;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export interface UpdateExpression extends BaseExpression {
|
||||
type: "UpdateExpression";
|
||||
operator: UpdateOperator;
|
||||
argument: Expression;
|
||||
prefix: boolean;
|
||||
}
|
||||
|
||||
export interface LogicalExpression extends BaseExpression {
|
||||
type: "LogicalExpression";
|
||||
operator: LogicalOperator;
|
||||
left: Expression;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export interface ConditionalExpression extends BaseExpression {
|
||||
type: "ConditionalExpression";
|
||||
test: Expression;
|
||||
alternate: Expression;
|
||||
consequent: Expression;
|
||||
}
|
||||
|
||||
export interface BaseCallExpression extends BaseExpression {
|
||||
callee: Expression | Super;
|
||||
arguments: Array<Expression | SpreadElement>;
|
||||
}
|
||||
export type CallExpression = SimpleCallExpression | NewExpression;
|
||||
|
||||
export interface SimpleCallExpression extends BaseCallExpression {
|
||||
type: "CallExpression";
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
export interface NewExpression extends BaseCallExpression {
|
||||
type: "NewExpression";
|
||||
}
|
||||
|
||||
export interface MemberExpression extends BaseExpression, BasePattern {
|
||||
type: "MemberExpression";
|
||||
object: Expression | Super;
|
||||
property: Expression | PrivateIdentifier;
|
||||
computed: boolean;
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
export type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
|
||||
|
||||
export interface BasePattern extends BaseNode {}
|
||||
|
||||
export interface SwitchCase extends BaseNode {
|
||||
type: "SwitchCase";
|
||||
test?: Expression | null | undefined;
|
||||
consequent: Statement[];
|
||||
}
|
||||
|
||||
export interface CatchClause extends BaseNode {
|
||||
type: "CatchClause";
|
||||
param: Pattern | null;
|
||||
body: BlockStatement;
|
||||
}
|
||||
|
||||
export interface Identifier extends BaseNode, BaseExpression, BasePattern {
|
||||
type: "Identifier";
|
||||
name: string;
|
||||
}
|
||||
|
||||
export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
|
||||
|
||||
export interface SimpleLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value: string | boolean | number | null;
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
export interface RegExpLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value?: RegExp | null | undefined;
|
||||
regex: {
|
||||
pattern: string;
|
||||
flags: string;
|
||||
};
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
export interface BigIntLiteral extends BaseNode, BaseExpression {
|
||||
type: "Literal";
|
||||
value?: bigint | null | undefined;
|
||||
bigint: string;
|
||||
raw?: string | undefined;
|
||||
}
|
||||
|
||||
export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
||||
|
||||
export type BinaryOperator =
|
||||
| "=="
|
||||
| "!="
|
||||
| "==="
|
||||
| "!=="
|
||||
| "<"
|
||||
| "<="
|
||||
| ">"
|
||||
| ">="
|
||||
| "<<"
|
||||
| ">>"
|
||||
| ">>>"
|
||||
| "+"
|
||||
| "-"
|
||||
| "*"
|
||||
| "/"
|
||||
| "%"
|
||||
| "**"
|
||||
| "|"
|
||||
| "^"
|
||||
| "&"
|
||||
| "in"
|
||||
| "instanceof";
|
||||
|
||||
export type LogicalOperator = "||" | "&&" | "??";
|
||||
|
||||
export type AssignmentOperator =
|
||||
| "="
|
||||
| "+="
|
||||
| "-="
|
||||
| "*="
|
||||
| "/="
|
||||
| "%="
|
||||
| "**="
|
||||
| "<<="
|
||||
| ">>="
|
||||
| ">>>="
|
||||
| "|="
|
||||
| "^="
|
||||
| "&="
|
||||
| "||="
|
||||
| "&&="
|
||||
| "??=";
|
||||
|
||||
export type UpdateOperator = "++" | "--";
|
||||
|
||||
export interface ForOfStatement extends BaseForXStatement {
|
||||
type: "ForOfStatement";
|
||||
await: boolean;
|
||||
}
|
||||
|
||||
export interface Super extends BaseNode {
|
||||
type: "Super";
|
||||
}
|
||||
|
||||
export interface SpreadElement extends BaseNode {
|
||||
type: "SpreadElement";
|
||||
argument: Expression;
|
||||
}
|
||||
|
||||
export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
|
||||
type: "ArrowFunctionExpression";
|
||||
expression: boolean;
|
||||
body: BlockStatement | Expression;
|
||||
}
|
||||
|
||||
export interface YieldExpression extends BaseExpression {
|
||||
type: "YieldExpression";
|
||||
argument?: Expression | null | undefined;
|
||||
delegate: boolean;
|
||||
}
|
||||
|
||||
export interface TemplateLiteral extends BaseExpression {
|
||||
type: "TemplateLiteral";
|
||||
quasis: TemplateElement[];
|
||||
expressions: Expression[];
|
||||
}
|
||||
|
||||
export interface TaggedTemplateExpression extends BaseExpression {
|
||||
type: "TaggedTemplateExpression";
|
||||
tag: Expression;
|
||||
quasi: TemplateLiteral;
|
||||
}
|
||||
|
||||
export interface TemplateElement extends BaseNode {
|
||||
type: "TemplateElement";
|
||||
tail: boolean;
|
||||
value: {
|
||||
/** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
|
||||
cooked?: string | null | undefined;
|
||||
raw: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AssignmentProperty extends Property {
|
||||
value: Pattern;
|
||||
kind: "init";
|
||||
method: boolean; // false
|
||||
}
|
||||
|
||||
export interface ObjectPattern extends BasePattern {
|
||||
type: "ObjectPattern";
|
||||
properties: Array<AssignmentProperty | RestElement>;
|
||||
}
|
||||
|
||||
export interface ArrayPattern extends BasePattern {
|
||||
type: "ArrayPattern";
|
||||
elements: Array<Pattern | null>;
|
||||
}
|
||||
|
||||
export interface RestElement extends BasePattern {
|
||||
type: "RestElement";
|
||||
argument: Pattern;
|
||||
}
|
||||
|
||||
export interface AssignmentPattern extends BasePattern {
|
||||
type: "AssignmentPattern";
|
||||
left: Pattern;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export type Class = ClassDeclaration | ClassExpression;
|
||||
export interface BaseClass extends BaseNode {
|
||||
superClass?: Expression | null | undefined;
|
||||
body: ClassBody;
|
||||
}
|
||||
|
||||
export interface ClassBody extends BaseNode {
|
||||
type: "ClassBody";
|
||||
body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
|
||||
}
|
||||
|
||||
export interface MethodDefinition extends BaseNode {
|
||||
type: "MethodDefinition";
|
||||
key: Expression | PrivateIdentifier;
|
||||
value: FunctionExpression;
|
||||
kind: "constructor" | "method" | "get" | "set";
|
||||
computed: boolean;
|
||||
static: boolean;
|
||||
}
|
||||
|
||||
export interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
|
||||
type: "ClassDeclaration";
|
||||
/** It is null when a class declaration is a part of the `export default class` statement */
|
||||
id: Identifier | null;
|
||||
}
|
||||
|
||||
export interface ClassDeclaration extends MaybeNamedClassDeclaration {
|
||||
id: Identifier;
|
||||
}
|
||||
|
||||
export interface ClassExpression extends BaseClass, BaseExpression {
|
||||
type: "ClassExpression";
|
||||
id?: Identifier | null | undefined;
|
||||
}
|
||||
|
||||
export interface MetaProperty extends BaseExpression {
|
||||
type: "MetaProperty";
|
||||
meta: Identifier;
|
||||
property: Identifier;
|
||||
}
|
||||
|
||||
export type ModuleDeclaration =
|
||||
| ImportDeclaration
|
||||
| ExportNamedDeclaration
|
||||
| ExportDefaultDeclaration
|
||||
| ExportAllDeclaration;
|
||||
export interface BaseModuleDeclaration extends BaseNode {}
|
||||
|
||||
export type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
|
||||
export interface BaseModuleSpecifier extends BaseNode {
|
||||
local: Identifier;
|
||||
}
|
||||
|
||||
export interface ImportDeclaration extends BaseModuleDeclaration {
|
||||
type: "ImportDeclaration";
|
||||
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
|
||||
attributes: ImportAttribute[];
|
||||
source: Literal;
|
||||
}
|
||||
|
||||
export interface ImportSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportSpecifier";
|
||||
imported: Identifier | Literal;
|
||||
}
|
||||
|
||||
export interface ImportAttribute extends BaseNode {
|
||||
type: "ImportAttribute";
|
||||
key: Identifier | Literal;
|
||||
value: Literal;
|
||||
}
|
||||
|
||||
export interface ImportExpression extends BaseExpression {
|
||||
type: "ImportExpression";
|
||||
source: Expression;
|
||||
options?: Expression | null | undefined;
|
||||
}
|
||||
|
||||
export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportDefaultSpecifier";
|
||||
}
|
||||
|
||||
export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
|
||||
type: "ImportNamespaceSpecifier";
|
||||
}
|
||||
|
||||
export interface ExportNamedDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportNamedDeclaration";
|
||||
declaration?: Declaration | null | undefined;
|
||||
specifiers: ExportSpecifier[];
|
||||
attributes: ImportAttribute[];
|
||||
source?: Literal | null | undefined;
|
||||
}
|
||||
|
||||
export interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
|
||||
type: "ExportSpecifier";
|
||||
local: Identifier | Literal;
|
||||
exported: Identifier | Literal;
|
||||
}
|
||||
|
||||
export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportDefaultDeclaration";
|
||||
declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression;
|
||||
}
|
||||
|
||||
export interface ExportAllDeclaration extends BaseModuleDeclaration {
|
||||
type: "ExportAllDeclaration";
|
||||
exported: Identifier | Literal | null;
|
||||
attributes: ImportAttribute[];
|
||||
source: Literal;
|
||||
}
|
||||
|
||||
export interface AwaitExpression extends BaseExpression {
|
||||
type: "AwaitExpression";
|
||||
argument: Expression;
|
||||
}
|
27
node_modules/@types/estree/package.json
generated
vendored
Normal file
27
node_modules/@types/estree/package.json
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "@types/estree",
|
||||
"version": "1.0.8",
|
||||
"description": "TypeScript definitions for estree",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "RReverser",
|
||||
"githubUsername": "RReverser",
|
||||
"url": "https://github.com/RReverser"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/estree"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {},
|
||||
"peerDependencies": {},
|
||||
"typesPublisherContentHash": "7a167b6e4a4d9f6e9a2cb9fd3fc45c885f89cbdeb44b3e5961bb057a45c082fd",
|
||||
"typeScriptVersion": "5.1",
|
||||
"nonNpm": true
|
||||
}
|
21
node_modules/esbuild/LICENSE.md
generated
vendored
Normal file
21
node_modules/esbuild/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Evan Wallace
|
||||
|
||||
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.
|
3
node_modules/esbuild/README.md
generated
vendored
Normal file
3
node_modules/esbuild/README.md
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# esbuild
|
||||
|
||||
This is a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://esbuild.github.io/api/) for details.
|
BIN
node_modules/esbuild/bin/esbuild
generated
vendored
Executable file
BIN
node_modules/esbuild/bin/esbuild
generated
vendored
Executable file
Binary file not shown.
285
node_modules/esbuild/install.js
generated
vendored
Normal file
285
node_modules/esbuild/install.js
generated
vendored
Normal file
|
@ -0,0 +1,285 @@
|
|||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
|
||||
// lib/npm/node-platform.ts
|
||||
var fs = require("fs");
|
||||
var os = require("os");
|
||||
var path = require("path");
|
||||
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
|
||||
var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
|
||||
var knownWindowsPackages = {
|
||||
"win32 arm64 LE": "@esbuild/win32-arm64",
|
||||
"win32 ia32 LE": "@esbuild/win32-ia32",
|
||||
"win32 x64 LE": "@esbuild/win32-x64"
|
||||
};
|
||||
var knownUnixlikePackages = {
|
||||
"aix ppc64 BE": "@esbuild/aix-ppc64",
|
||||
"android arm64 LE": "@esbuild/android-arm64",
|
||||
"darwin arm64 LE": "@esbuild/darwin-arm64",
|
||||
"darwin x64 LE": "@esbuild/darwin-x64",
|
||||
"freebsd arm64 LE": "@esbuild/freebsd-arm64",
|
||||
"freebsd x64 LE": "@esbuild/freebsd-x64",
|
||||
"linux arm LE": "@esbuild/linux-arm",
|
||||
"linux arm64 LE": "@esbuild/linux-arm64",
|
||||
"linux ia32 LE": "@esbuild/linux-ia32",
|
||||
"linux mips64el LE": "@esbuild/linux-mips64el",
|
||||
"linux ppc64 LE": "@esbuild/linux-ppc64",
|
||||
"linux riscv64 LE": "@esbuild/linux-riscv64",
|
||||
"linux s390x BE": "@esbuild/linux-s390x",
|
||||
"linux x64 LE": "@esbuild/linux-x64",
|
||||
"linux loong64 LE": "@esbuild/linux-loong64",
|
||||
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
||||
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
||||
"sunos x64 LE": "@esbuild/sunos-x64"
|
||||
};
|
||||
var knownWebAssemblyFallbackPackages = {
|
||||
"android arm LE": "@esbuild/android-arm",
|
||||
"android x64 LE": "@esbuild/android-x64"
|
||||
};
|
||||
function pkgAndSubpathForCurrentPlatform() {
|
||||
let pkg;
|
||||
let subpath;
|
||||
let isWASM = false;
|
||||
let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
|
||||
if (platformKey in knownWindowsPackages) {
|
||||
pkg = knownWindowsPackages[platformKey];
|
||||
subpath = "esbuild.exe";
|
||||
} else if (platformKey in knownUnixlikePackages) {
|
||||
pkg = knownUnixlikePackages[platformKey];
|
||||
subpath = "bin/esbuild";
|
||||
} else if (platformKey in knownWebAssemblyFallbackPackages) {
|
||||
pkg = knownWebAssemblyFallbackPackages[platformKey];
|
||||
subpath = "bin/esbuild";
|
||||
isWASM = true;
|
||||
} else {
|
||||
throw new Error(`Unsupported platform: ${platformKey}`);
|
||||
}
|
||||
return { pkg, subpath, isWASM };
|
||||
}
|
||||
function downloadedBinPath(pkg, subpath) {
|
||||
const esbuildLibDir = path.dirname(require.resolve("esbuild"));
|
||||
return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
|
||||
}
|
||||
|
||||
// lib/npm/node-install.ts
|
||||
var fs2 = require("fs");
|
||||
var os2 = require("os");
|
||||
var path2 = require("path");
|
||||
var zlib = require("zlib");
|
||||
var https = require("https");
|
||||
var child_process = require("child_process");
|
||||
var versionFromPackageJSON = require(path2.join(__dirname, "package.json")).version;
|
||||
var toPath = path2.join(__dirname, "bin", "esbuild");
|
||||
var isToPathJS = true;
|
||||
function validateBinaryVersion(...command) {
|
||||
command.push("--version");
|
||||
let stdout;
|
||||
try {
|
||||
stdout = child_process.execFileSync(command.shift(), command, {
|
||||
// Without this, this install script strangely crashes with the error
|
||||
// "EACCES: permission denied, write" but only on Ubuntu Linux when node is
|
||||
// installed from the Snap Store. This is not a problem when you download
|
||||
// the official version of node. The problem appears to be that stderr
|
||||
// (i.e. file descriptor 2) isn't writable?
|
||||
//
|
||||
// More info:
|
||||
// - https://snapcraft.io/ (what the Snap Store is)
|
||||
// - https://nodejs.org/dist/ (download the official version of node)
|
||||
// - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
|
||||
//
|
||||
stdio: "pipe"
|
||||
}).toString().trim();
|
||||
} catch (err) {
|
||||
if (os2.platform() === "darwin" && /_SecTrustEvaluateWithError/.test(err + "")) {
|
||||
let os3 = "this version of macOS";
|
||||
try {
|
||||
os3 = "macOS " + child_process.execFileSync("sw_vers", ["-productVersion"]).toString().trim();
|
||||
} catch {
|
||||
}
|
||||
throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
|
||||
|
||||
The Go compiler (which esbuild relies on) no longer supports ${os3},
|
||||
which means the "esbuild" binary executable can't be run. You can either:
|
||||
|
||||
* Update your version of macOS to one that the Go compiler supports
|
||||
* Use the "esbuild-wasm" package instead of the "esbuild" package
|
||||
* Build esbuild yourself using an older version of the Go compiler
|
||||
`);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
if (stdout !== versionFromPackageJSON) {
|
||||
throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)}`);
|
||||
}
|
||||
}
|
||||
function isYarn() {
|
||||
const { npm_config_user_agent } = process.env;
|
||||
if (npm_config_user_agent) {
|
||||
return /\byarn\//.test(npm_config_user_agent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function fetch(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
https.get(url, (res) => {
|
||||
if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
|
||||
return fetch(res.headers.location).then(resolve, reject);
|
||||
if (res.statusCode !== 200)
|
||||
return reject(new Error(`Server responded with ${res.statusCode}`));
|
||||
let chunks = [];
|
||||
res.on("data", (chunk) => chunks.push(chunk));
|
||||
res.on("end", () => resolve(Buffer.concat(chunks)));
|
||||
}).on("error", reject);
|
||||
});
|
||||
}
|
||||
function extractFileFromTarGzip(buffer, subpath) {
|
||||
try {
|
||||
buffer = zlib.unzipSync(buffer);
|
||||
} catch (err) {
|
||||
throw new Error(`Invalid gzip data in archive: ${err && err.message || err}`);
|
||||
}
|
||||
let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
|
||||
let offset = 0;
|
||||
subpath = `package/${subpath}`;
|
||||
while (offset < buffer.length) {
|
||||
let name = str(offset, 100);
|
||||
let size = parseInt(str(offset + 124, 12), 8);
|
||||
offset += 512;
|
||||
if (!isNaN(size)) {
|
||||
if (name === subpath) return buffer.subarray(offset, offset + size);
|
||||
offset += size + 511 & ~511;
|
||||
}
|
||||
}
|
||||
throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
|
||||
}
|
||||
function installUsingNPM(pkg, subpath, binPath) {
|
||||
const env = { ...process.env, npm_config_global: void 0 };
|
||||
const esbuildLibDir = path2.dirname(require.resolve("esbuild"));
|
||||
const installDir = path2.join(esbuildLibDir, "npm-install");
|
||||
fs2.mkdirSync(installDir);
|
||||
try {
|
||||
fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
|
||||
child_process.execSync(
|
||||
`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${versionFromPackageJSON}`,
|
||||
{ cwd: installDir, stdio: "pipe", env }
|
||||
);
|
||||
const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
|
||||
fs2.renameSync(installedBinPath, binPath);
|
||||
} finally {
|
||||
try {
|
||||
removeRecursive(installDir);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
function removeRecursive(dir) {
|
||||
for (const entry of fs2.readdirSync(dir)) {
|
||||
const entryPath = path2.join(dir, entry);
|
||||
let stats;
|
||||
try {
|
||||
stats = fs2.lstatSync(entryPath);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
if (stats.isDirectory()) removeRecursive(entryPath);
|
||||
else fs2.unlinkSync(entryPath);
|
||||
}
|
||||
fs2.rmdirSync(dir);
|
||||
}
|
||||
function applyManualBinaryPathOverride(overridePath) {
|
||||
const pathString = JSON.stringify(overridePath);
|
||||
fs2.writeFileSync(toPath, `#!/usr/bin/env node
|
||||
require('child_process').execFileSync(${pathString}, process.argv.slice(2), { stdio: 'inherit' });
|
||||
`);
|
||||
const libMain = path2.join(__dirname, "lib", "main.js");
|
||||
const code = fs2.readFileSync(libMain, "utf8");
|
||||
fs2.writeFileSync(libMain, `var ESBUILD_BINARY_PATH = ${pathString};
|
||||
${code}`);
|
||||
}
|
||||
function maybeOptimizePackage(binPath) {
|
||||
if (os2.platform() !== "win32" && !isYarn()) {
|
||||
const tempPath = path2.join(__dirname, "bin-esbuild");
|
||||
try {
|
||||
fs2.linkSync(binPath, tempPath);
|
||||
fs2.renameSync(tempPath, toPath);
|
||||
isToPathJS = false;
|
||||
fs2.unlinkSync(tempPath);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
|
||||
const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${versionFromPackageJSON}.tgz`;
|
||||
console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
|
||||
try {
|
||||
fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
|
||||
fs2.chmodSync(binPath, 493);
|
||||
} catch (e) {
|
||||
console.error(`[esbuild] Failed to download ${JSON.stringify(url)}: ${e && e.message || e}`);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async function checkAndPreparePackage() {
|
||||
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
|
||||
if (!fs2.existsSync(ESBUILD_BINARY_PATH)) {
|
||||
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
|
||||
} else {
|
||||
applyManualBinaryPathOverride(ESBUILD_BINARY_PATH);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
|
||||
let binPath;
|
||||
try {
|
||||
binPath = require.resolve(`${pkg}/${subpath}`);
|
||||
} catch (e) {
|
||||
console.error(`[esbuild] Failed to find package "${pkg}" on the file system
|
||||
|
||||
This can happen if you use the "--no-optional" flag. The "optionalDependencies"
|
||||
package.json feature is used by esbuild to install the correct binary executable
|
||||
for your current platform. This install script will now attempt to work around
|
||||
this. If that fails, you need to remove the "--no-optional" flag to use esbuild.
|
||||
`);
|
||||
binPath = downloadedBinPath(pkg, subpath);
|
||||
try {
|
||||
console.error(`[esbuild] Trying to install package "${pkg}" using npm`);
|
||||
installUsingNPM(pkg, subpath, binPath);
|
||||
} catch (e2) {
|
||||
console.error(`[esbuild] Failed to install package "${pkg}" using npm: ${e2 && e2.message || e2}`);
|
||||
try {
|
||||
await downloadDirectlyFromNPM(pkg, subpath, binPath);
|
||||
} catch (e3) {
|
||||
throw new Error(`Failed to install package "${pkg}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
maybeOptimizePackage(binPath);
|
||||
}
|
||||
checkAndPreparePackage().then(() => {
|
||||
if (isToPathJS) {
|
||||
validateBinaryVersion(process.execPath, toPath);
|
||||
} else {
|
||||
validateBinaryVersion(toPath);
|
||||
}
|
||||
});
|
705
node_modules/esbuild/lib/main.d.ts
generated
vendored
Normal file
705
node_modules/esbuild/lib/main.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,705 @@
|
|||
export type Platform = 'browser' | 'node' | 'neutral'
|
||||
export type Format = 'iife' | 'cjs' | 'esm'
|
||||
export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx'
|
||||
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'
|
||||
export type Charset = 'ascii' | 'utf8'
|
||||
export type Drop = 'console' | 'debugger'
|
||||
|
||||
interface CommonOptions {
|
||||
/** Documentation: https://esbuild.github.io/api/#sourcemap */
|
||||
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both'
|
||||
/** Documentation: https://esbuild.github.io/api/#legal-comments */
|
||||
legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external'
|
||||
/** Documentation: https://esbuild.github.io/api/#source-root */
|
||||
sourceRoot?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#sources-content */
|
||||
sourcesContent?: boolean
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#format */
|
||||
format?: Format
|
||||
/** Documentation: https://esbuild.github.io/api/#global-name */
|
||||
globalName?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#target */
|
||||
target?: string | string[]
|
||||
/** Documentation: https://esbuild.github.io/api/#supported */
|
||||
supported?: Record<string, boolean>
|
||||
/** Documentation: https://esbuild.github.io/api/#platform */
|
||||
platform?: Platform
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
||||
mangleProps?: RegExp
|
||||
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
||||
reserveProps?: RegExp
|
||||
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
||||
mangleQuoted?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
||||
mangleCache?: Record<string, string | false>
|
||||
/** Documentation: https://esbuild.github.io/api/#drop */
|
||||
drop?: Drop[]
|
||||
/** Documentation: https://esbuild.github.io/api/#drop-labels */
|
||||
dropLabels?: string[]
|
||||
/** Documentation: https://esbuild.github.io/api/#minify */
|
||||
minify?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#minify */
|
||||
minifyWhitespace?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#minify */
|
||||
minifyIdentifiers?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#minify */
|
||||
minifySyntax?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#line-limit */
|
||||
lineLimit?: number
|
||||
/** Documentation: https://esbuild.github.io/api/#charset */
|
||||
charset?: Charset
|
||||
/** Documentation: https://esbuild.github.io/api/#tree-shaking */
|
||||
treeShaking?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#ignore-annotations */
|
||||
ignoreAnnotations?: boolean
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#jsx */
|
||||
jsx?: 'transform' | 'preserve' | 'automatic'
|
||||
/** Documentation: https://esbuild.github.io/api/#jsx-factory */
|
||||
jsxFactory?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#jsx-fragment */
|
||||
jsxFragment?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#jsx-import-source */
|
||||
jsxImportSource?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#jsx-development */
|
||||
jsxDev?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#jsx-side-effects */
|
||||
jsxSideEffects?: boolean
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#define */
|
||||
define?: { [key: string]: string }
|
||||
/** Documentation: https://esbuild.github.io/api/#pure */
|
||||
pure?: string[]
|
||||
/** Documentation: https://esbuild.github.io/api/#keep-names */
|
||||
keepNames?: boolean
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#color */
|
||||
color?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#log-level */
|
||||
logLevel?: LogLevel
|
||||
/** Documentation: https://esbuild.github.io/api/#log-limit */
|
||||
logLimit?: number
|
||||
/** Documentation: https://esbuild.github.io/api/#log-override */
|
||||
logOverride?: Record<string, LogLevel>
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#tsconfig-raw */
|
||||
tsconfigRaw?: string | TsconfigRaw
|
||||
}
|
||||
|
||||
export interface TsconfigRaw {
|
||||
compilerOptions?: {
|
||||
alwaysStrict?: boolean
|
||||
baseUrl?: string
|
||||
experimentalDecorators?: boolean
|
||||
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error'
|
||||
jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev'
|
||||
jsxFactory?: string
|
||||
jsxFragmentFactory?: string
|
||||
jsxImportSource?: string
|
||||
paths?: Record<string, string[]>
|
||||
preserveValueImports?: boolean
|
||||
strict?: boolean
|
||||
target?: string
|
||||
useDefineForClassFields?: boolean
|
||||
verbatimModuleSyntax?: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export interface BuildOptions extends CommonOptions {
|
||||
/** Documentation: https://esbuild.github.io/api/#bundle */
|
||||
bundle?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#splitting */
|
||||
splitting?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#preserve-symlinks */
|
||||
preserveSymlinks?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#outfile */
|
||||
outfile?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#metafile */
|
||||
metafile?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#outdir */
|
||||
outdir?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#outbase */
|
||||
outbase?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#external */
|
||||
external?: string[]
|
||||
/** Documentation: https://esbuild.github.io/api/#packages */
|
||||
packages?: 'external'
|
||||
/** Documentation: https://esbuild.github.io/api/#alias */
|
||||
alias?: Record<string, string>
|
||||
/** Documentation: https://esbuild.github.io/api/#loader */
|
||||
loader?: { [ext: string]: Loader }
|
||||
/** Documentation: https://esbuild.github.io/api/#resolve-extensions */
|
||||
resolveExtensions?: string[]
|
||||
/** Documentation: https://esbuild.github.io/api/#main-fields */
|
||||
mainFields?: string[]
|
||||
/** Documentation: https://esbuild.github.io/api/#conditions */
|
||||
conditions?: string[]
|
||||
/** Documentation: https://esbuild.github.io/api/#write */
|
||||
write?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#allow-overwrite */
|
||||
allowOverwrite?: boolean
|
||||
/** Documentation: https://esbuild.github.io/api/#tsconfig */
|
||||
tsconfig?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#out-extension */
|
||||
outExtension?: { [ext: string]: string }
|
||||
/** Documentation: https://esbuild.github.io/api/#public-path */
|
||||
publicPath?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#entry-names */
|
||||
entryNames?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#chunk-names */
|
||||
chunkNames?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#asset-names */
|
||||
assetNames?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#inject */
|
||||
inject?: string[]
|
||||
/** Documentation: https://esbuild.github.io/api/#banner */
|
||||
banner?: { [type: string]: string }
|
||||
/** Documentation: https://esbuild.github.io/api/#footer */
|
||||
footer?: { [type: string]: string }
|
||||
/** Documentation: https://esbuild.github.io/api/#entry-points */
|
||||
entryPoints?: string[] | Record<string, string> | { in: string, out: string }[]
|
||||
/** Documentation: https://esbuild.github.io/api/#stdin */
|
||||
stdin?: StdinOptions
|
||||
/** Documentation: https://esbuild.github.io/plugins/ */
|
||||
plugins?: Plugin[]
|
||||
/** Documentation: https://esbuild.github.io/api/#working-directory */
|
||||
absWorkingDir?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#node-paths */
|
||||
nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
|
||||
}
|
||||
|
||||
export interface StdinOptions {
|
||||
contents: string | Uint8Array
|
||||
resolveDir?: string
|
||||
sourcefile?: string
|
||||
loader?: Loader
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
id: string
|
||||
pluginName: string
|
||||
text: string
|
||||
location: Location | null
|
||||
notes: Note[]
|
||||
|
||||
/**
|
||||
* Optional user-specified data that is passed through unmodified. You can
|
||||
* use this to stash the original error, for example.
|
||||
*/
|
||||
detail: any
|
||||
}
|
||||
|
||||
export interface Note {
|
||||
text: string
|
||||
location: Location | null
|
||||
}
|
||||
|
||||
export interface Location {
|
||||
file: string
|
||||
namespace: string
|
||||
/** 1-based */
|
||||
line: number
|
||||
/** 0-based, in bytes */
|
||||
column: number
|
||||
/** in bytes */
|
||||
length: number
|
||||
lineText: string
|
||||
suggestion: string
|
||||
}
|
||||
|
||||
export interface OutputFile {
|
||||
path: string
|
||||
contents: Uint8Array
|
||||
hash: string
|
||||
/** "contents" as text (changes automatically with "contents") */
|
||||
readonly text: string
|
||||
}
|
||||
|
||||
export interface BuildResult<ProvidedOptions extends BuildOptions = BuildOptions> {
|
||||
errors: Message[]
|
||||
warnings: Message[]
|
||||
/** Only when "write: false" */
|
||||
outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined)
|
||||
/** Only when "metafile: true" */
|
||||
metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined)
|
||||
/** Only when "mangleCache" is present */
|
||||
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
|
||||
}
|
||||
|
||||
export interface BuildFailure extends Error {
|
||||
errors: Message[]
|
||||
warnings: Message[]
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#serve-arguments */
|
||||
export interface ServeOptions {
|
||||
port?: number
|
||||
host?: string
|
||||
servedir?: string
|
||||
keyfile?: string
|
||||
certfile?: string
|
||||
fallback?: string
|
||||
onRequest?: (args: ServeOnRequestArgs) => void
|
||||
}
|
||||
|
||||
export interface ServeOnRequestArgs {
|
||||
remoteAddress: string
|
||||
method: string
|
||||
path: string
|
||||
status: number
|
||||
/** The time to generate the response, not to send it */
|
||||
timeInMS: number
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#serve-return-values */
|
||||
export interface ServeResult {
|
||||
port: number
|
||||
host: string
|
||||
}
|
||||
|
||||
export interface TransformOptions extends CommonOptions {
|
||||
/** Documentation: https://esbuild.github.io/api/#sourcefile */
|
||||
sourcefile?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#loader */
|
||||
loader?: Loader
|
||||
/** Documentation: https://esbuild.github.io/api/#banner */
|
||||
banner?: string
|
||||
/** Documentation: https://esbuild.github.io/api/#footer */
|
||||
footer?: string
|
||||
}
|
||||
|
||||
export interface TransformResult<ProvidedOptions extends TransformOptions = TransformOptions> {
|
||||
code: string
|
||||
map: string
|
||||
warnings: Message[]
|
||||
/** Only when "mangleCache" is present */
|
||||
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
|
||||
/** Only when "legalComments" is "external" */
|
||||
legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined)
|
||||
}
|
||||
|
||||
export interface TransformFailure extends Error {
|
||||
errors: Message[]
|
||||
warnings: Message[]
|
||||
}
|
||||
|
||||
export interface Plugin {
|
||||
name: string
|
||||
setup: (build: PluginBuild) => (void | Promise<void>)
|
||||
}
|
||||
|
||||
export interface PluginBuild {
|
||||
/** Documentation: https://esbuild.github.io/plugins/#build-options */
|
||||
initialOptions: BuildOptions
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#resolve */
|
||||
resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-start */
|
||||
onStart(callback: () =>
|
||||
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-end */
|
||||
onEnd(callback: (result: BuildResult) =>
|
||||
(OnEndResult | null | void | Promise<OnEndResult | null | void>)): void
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve */
|
||||
onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
|
||||
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-load */
|
||||
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
|
||||
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-dispose */
|
||||
onDispose(callback: () => void): void
|
||||
|
||||
// This is a full copy of the esbuild library in case you need it
|
||||
esbuild: {
|
||||
context: typeof context,
|
||||
build: typeof build,
|
||||
buildSync: typeof buildSync,
|
||||
transform: typeof transform,
|
||||
transformSync: typeof transformSync,
|
||||
formatMessages: typeof formatMessages,
|
||||
formatMessagesSync: typeof formatMessagesSync,
|
||||
analyzeMetafile: typeof analyzeMetafile,
|
||||
analyzeMetafileSync: typeof analyzeMetafileSync,
|
||||
initialize: typeof initialize,
|
||||
version: typeof version,
|
||||
}
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#resolve-options */
|
||||
export interface ResolveOptions {
|
||||
pluginName?: string
|
||||
importer?: string
|
||||
namespace?: string
|
||||
resolveDir?: string
|
||||
kind?: ImportKind
|
||||
pluginData?: any
|
||||
with?: Record<string, string>
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#resolve-results */
|
||||
export interface ResolveResult {
|
||||
errors: Message[]
|
||||
warnings: Message[]
|
||||
|
||||
path: string
|
||||
external: boolean
|
||||
sideEffects: boolean
|
||||
namespace: string
|
||||
suffix: string
|
||||
pluginData: any
|
||||
}
|
||||
|
||||
export interface OnStartResult {
|
||||
errors?: PartialMessage[]
|
||||
warnings?: PartialMessage[]
|
||||
}
|
||||
|
||||
export interface OnEndResult {
|
||||
errors?: PartialMessage[]
|
||||
warnings?: PartialMessage[]
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */
|
||||
export interface OnResolveOptions {
|
||||
filter: RegExp
|
||||
namespace?: string
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */
|
||||
export interface OnResolveArgs {
|
||||
path: string
|
||||
importer: string
|
||||
namespace: string
|
||||
resolveDir: string
|
||||
kind: ImportKind
|
||||
pluginData: any
|
||||
with: Record<string, string>
|
||||
}
|
||||
|
||||
export type ImportKind =
|
||||
| 'entry-point'
|
||||
|
||||
// JS
|
||||
| 'import-statement'
|
||||
| 'require-call'
|
||||
| 'dynamic-import'
|
||||
| 'require-resolve'
|
||||
|
||||
// CSS
|
||||
| 'import-rule'
|
||||
| 'composes-from'
|
||||
| 'url-token'
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */
|
||||
export interface OnResolveResult {
|
||||
pluginName?: string
|
||||
|
||||
errors?: PartialMessage[]
|
||||
warnings?: PartialMessage[]
|
||||
|
||||
path?: string
|
||||
external?: boolean
|
||||
sideEffects?: boolean
|
||||
namespace?: string
|
||||
suffix?: string
|
||||
pluginData?: any
|
||||
|
||||
watchFiles?: string[]
|
||||
watchDirs?: string[]
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-load-options */
|
||||
export interface OnLoadOptions {
|
||||
filter: RegExp
|
||||
namespace?: string
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */
|
||||
export interface OnLoadArgs {
|
||||
path: string
|
||||
namespace: string
|
||||
suffix: string
|
||||
pluginData: any
|
||||
with: Record<string, string>
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/plugins/#on-load-results */
|
||||
export interface OnLoadResult {
|
||||
pluginName?: string
|
||||
|
||||
errors?: PartialMessage[]
|
||||
warnings?: PartialMessage[]
|
||||
|
||||
contents?: string | Uint8Array
|
||||
resolveDir?: string
|
||||
loader?: Loader
|
||||
pluginData?: any
|
||||
|
||||
watchFiles?: string[]
|
||||
watchDirs?: string[]
|
||||
}
|
||||
|
||||
export interface PartialMessage {
|
||||
id?: string
|
||||
pluginName?: string
|
||||
text?: string
|
||||
location?: Partial<Location> | null
|
||||
notes?: PartialNote[]
|
||||
detail?: any
|
||||
}
|
||||
|
||||
export interface PartialNote {
|
||||
text?: string
|
||||
location?: Partial<Location> | null
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#metafile */
|
||||
export interface Metafile {
|
||||
inputs: {
|
||||
[path: string]: {
|
||||
bytes: number
|
||||
imports: {
|
||||
path: string
|
||||
kind: ImportKind
|
||||
external?: boolean
|
||||
original?: string
|
||||
with?: Record<string, string>
|
||||
}[]
|
||||
format?: 'cjs' | 'esm'
|
||||
with?: Record<string, string>
|
||||
}
|
||||
}
|
||||
outputs: {
|
||||
[path: string]: {
|
||||
bytes: number
|
||||
inputs: {
|
||||
[path: string]: {
|
||||
bytesInOutput: number
|
||||
}
|
||||
}
|
||||
imports: {
|
||||
path: string
|
||||
kind: ImportKind | 'file-loader'
|
||||
external?: boolean
|
||||
}[]
|
||||
exports: string[]
|
||||
entryPoint?: string
|
||||
cssBundle?: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface FormatMessagesOptions {
|
||||
kind: 'error' | 'warning'
|
||||
color?: boolean
|
||||
terminalWidth?: number
|
||||
}
|
||||
|
||||
export interface AnalyzeMetafileOptions {
|
||||
color?: boolean
|
||||
verbose?: boolean
|
||||
}
|
||||
|
||||
export interface WatchOptions {
|
||||
}
|
||||
|
||||
export interface BuildContext<ProvidedOptions extends BuildOptions = BuildOptions> {
|
||||
/** Documentation: https://esbuild.github.io/api/#rebuild */
|
||||
rebuild(): Promise<BuildResult<ProvidedOptions>>
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#watch */
|
||||
watch(options?: WatchOptions): Promise<void>
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#serve */
|
||||
serve(options?: ServeOptions): Promise<ServeResult>
|
||||
|
||||
cancel(): Promise<void>
|
||||
dispose(): Promise<void>
|
||||
}
|
||||
|
||||
// This is a TypeScript type-level function which replaces any keys in "In"
|
||||
// that aren't in "Out" with "never". We use this to reject properties with
|
||||
// typos in object literals. See: https://stackoverflow.com/questions/49580725
|
||||
type SameShape<Out, In extends Out> = In & { [Key in Exclude<keyof In, keyof Out>]: never }
|
||||
|
||||
/**
|
||||
* This function invokes the "esbuild" command-line tool for you. It returns a
|
||||
* promise that either resolves with a "BuildResult" object or rejects with a
|
||||
* "BuildFailure" object.
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: yes
|
||||
*
|
||||
* Documentation: https://esbuild.github.io/api/#build
|
||||
*/
|
||||
export declare function build<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildResult<T>>
|
||||
|
||||
/**
|
||||
* This is the advanced long-running form of "build" that supports additional
|
||||
* features such as watch mode and a local development server.
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: no
|
||||
*
|
||||
* Documentation: https://esbuild.github.io/api/#build
|
||||
*/
|
||||
export declare function context<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildContext<T>>
|
||||
|
||||
/**
|
||||
* This function transforms a single JavaScript file. It can be used to minify
|
||||
* JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript
|
||||
* to older JavaScript. It returns a promise that is either resolved with a
|
||||
* "TransformResult" object or rejected with a "TransformFailure" object.
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: yes
|
||||
*
|
||||
* Documentation: https://esbuild.github.io/api/#transform
|
||||
*/
|
||||
export declare function transform<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): Promise<TransformResult<T>>
|
||||
|
||||
/**
|
||||
* Converts log messages to formatted message strings suitable for printing in
|
||||
* the terminal. This allows you to reuse the built-in behavior of esbuild's
|
||||
* log message formatter. This is a batch-oriented API for efficiency.
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: yes
|
||||
*/
|
||||
export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>
|
||||
|
||||
/**
|
||||
* Pretty-prints an analysis of the metafile JSON to a string. This is just for
|
||||
* convenience to be able to match esbuild's pretty-printing exactly. If you want
|
||||
* to customize it, you can just inspect the data in the metafile yourself.
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: yes
|
||||
*
|
||||
* Documentation: https://esbuild.github.io/api/#analyze
|
||||
*/
|
||||
export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>
|
||||
|
||||
/**
|
||||
* A synchronous version of "build".
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: no
|
||||
*
|
||||
* Documentation: https://esbuild.github.io/api/#build
|
||||
*/
|
||||
export declare function buildSync<T extends BuildOptions>(options: SameShape<BuildOptions, T>): BuildResult<T>
|
||||
|
||||
/**
|
||||
* A synchronous version of "transform".
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: no
|
||||
*
|
||||
* Documentation: https://esbuild.github.io/api/#transform
|
||||
*/
|
||||
export declare function transformSync<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): TransformResult<T>
|
||||
|
||||
/**
|
||||
* A synchronous version of "formatMessages".
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: no
|
||||
*/
|
||||
export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[]
|
||||
|
||||
/**
|
||||
* A synchronous version of "analyzeMetafile".
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: no
|
||||
*
|
||||
* Documentation: https://esbuild.github.io/api/#analyze
|
||||
*/
|
||||
export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string
|
||||
|
||||
/**
|
||||
* This configures the browser-based version of esbuild. It is necessary to
|
||||
* call this first and wait for the returned promise to be resolved before
|
||||
* making other API calls when using esbuild in the browser.
|
||||
*
|
||||
* - Works in node: yes
|
||||
* - Works in browser: yes ("options" is required)
|
||||
*
|
||||
* Documentation: https://esbuild.github.io/api/#browser
|
||||
*/
|
||||
export declare function initialize(options: InitializeOptions): Promise<void>
|
||||
|
||||
export interface InitializeOptions {
|
||||
/**
|
||||
* The URL of the "esbuild.wasm" file. This must be provided when running
|
||||
* esbuild in the browser.
|
||||
*/
|
||||
wasmURL?: string | URL
|
||||
|
||||
/**
|
||||
* The result of calling "new WebAssembly.Module(buffer)" where "buffer"
|
||||
* is a typed array or ArrayBuffer containing the binary code of the
|
||||
* "esbuild.wasm" file.
|
||||
*
|
||||
* You can use this as an alternative to "wasmURL" for environments where it's
|
||||
* not possible to download the WebAssembly module.
|
||||
*/
|
||||
wasmModule?: WebAssembly.Module
|
||||
|
||||
/**
|
||||
* By default esbuild runs the WebAssembly-based browser API in a web worker
|
||||
* to avoid blocking the UI thread. This can be disabled by setting "worker"
|
||||
* to false.
|
||||
*/
|
||||
worker?: boolean
|
||||
}
|
||||
|
||||
export let version: string
|
||||
|
||||
// Call this function to terminate esbuild's child process. The child process
|
||||
// is not terminated and re-created after each API call because it's more
|
||||
// efficient to keep it around when there are multiple API calls.
|
||||
//
|
||||
// In node this happens automatically before the parent node process exits. So
|
||||
// you only need to call this if you know you will not make any more esbuild
|
||||
// API calls and you want to clean up resources.
|
||||
//
|
||||
// Unlike node, Deno lacks the necessary APIs to clean up child processes
|
||||
// automatically. You must manually call stop() in Deno when you're done
|
||||
// using esbuild or Deno will continue running forever.
|
||||
//
|
||||
// Another reason you might want to call this is if you are using esbuild from
|
||||
// within a Deno test. Deno fails tests that create a child process without
|
||||
// killing it before the test ends, so you have to call this function (and
|
||||
// await the returned promise) in every Deno test that uses esbuild.
|
||||
export declare function stop(): Promise<void>
|
||||
|
||||
// Note: These declarations exist to avoid type errors when you omit "dom" from
|
||||
// "lib" in your "tsconfig.json" file. TypeScript confusingly declares the
|
||||
// global "WebAssembly" type in "lib.dom.d.ts" even though it has nothing to do
|
||||
// with the browser DOM and is present in many non-browser JavaScript runtimes
|
||||
// (e.g. node and deno). Declaring it here allows esbuild's API to be used in
|
||||
// these scenarios.
|
||||
//
|
||||
// There's an open issue about getting this problem corrected (although these
|
||||
// declarations will need to remain even if this is fixed for backward
|
||||
// compatibility with older TypeScript versions):
|
||||
//
|
||||
// https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/826
|
||||
//
|
||||
declare global {
|
||||
namespace WebAssembly {
|
||||
interface Module {
|
||||
}
|
||||
}
|
||||
interface URL {
|
||||
}
|
||||
}
|
2239
node_modules/esbuild/lib/main.js
generated
vendored
Normal file
2239
node_modules/esbuild/lib/main.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
46
node_modules/esbuild/package.json
generated
vendored
Normal file
46
node_modules/esbuild/package.json
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "esbuild",
|
||||
"version": "0.21.5",
|
||||
"description": "An extremely fast JavaScript and CSS bundler and minifier.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/evanw/esbuild.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "node install.js"
|
||||
},
|
||||
"main": "lib/main.js",
|
||||
"types": "lib/main.d.ts",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.21.5",
|
||||
"@esbuild/android-arm": "0.21.5",
|
||||
"@esbuild/android-arm64": "0.21.5",
|
||||
"@esbuild/android-x64": "0.21.5",
|
||||
"@esbuild/darwin-arm64": "0.21.5",
|
||||
"@esbuild/darwin-x64": "0.21.5",
|
||||
"@esbuild/freebsd-arm64": "0.21.5",
|
||||
"@esbuild/freebsd-x64": "0.21.5",
|
||||
"@esbuild/linux-arm": "0.21.5",
|
||||
"@esbuild/linux-arm64": "0.21.5",
|
||||
"@esbuild/linux-ia32": "0.21.5",
|
||||
"@esbuild/linux-loong64": "0.21.5",
|
||||
"@esbuild/linux-mips64el": "0.21.5",
|
||||
"@esbuild/linux-ppc64": "0.21.5",
|
||||
"@esbuild/linux-riscv64": "0.21.5",
|
||||
"@esbuild/linux-s390x": "0.21.5",
|
||||
"@esbuild/linux-x64": "0.21.5",
|
||||
"@esbuild/netbsd-x64": "0.21.5",
|
||||
"@esbuild/openbsd-x64": "0.21.5",
|
||||
"@esbuild/sunos-x64": "0.21.5",
|
||||
"@esbuild/win32-arm64": "0.21.5",
|
||||
"@esbuild/win32-ia32": "0.21.5",
|
||||
"@esbuild/win32-x64": "0.21.5"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
151
node_modules/js-tokens/CHANGELOG.md
generated
vendored
Normal file
151
node_modules/js-tokens/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,151 @@
|
|||
### Version 4.0.0 (2018-01-28) ###
|
||||
|
||||
- Added: Support for ES2018. The only change needed was recognizing the `s`
|
||||
regex flag.
|
||||
- Changed: _All_ tokens returned by the `matchToToken` function now have a
|
||||
`closed` property. It is set to `undefined` for the tokens where “closed”
|
||||
doesn’t make sense. This means that all tokens objects have the same shape,
|
||||
which might improve performance.
|
||||
|
||||
These are the breaking changes:
|
||||
|
||||
- `'/a/s'.match(jsTokens)` no longer returns `['/', 'a', '/', 's']`, but
|
||||
`['/a/s']`. (There are of course other variations of this.)
|
||||
- Code that rely on some token objects not having the `closed` property could
|
||||
now behave differently.
|
||||
|
||||
|
||||
### Version 3.0.2 (2017-06-28) ###
|
||||
|
||||
- No code changes. Just updates to the readme.
|
||||
|
||||
|
||||
### Version 3.0.1 (2017-01-30) ###
|
||||
|
||||
- Fixed: ES2015 unicode escapes with more than 6 hex digits are now matched
|
||||
correctly.
|
||||
|
||||
|
||||
### Version 3.0.0 (2017-01-11) ###
|
||||
|
||||
This release contains one breaking change, that should [improve performance in
|
||||
V8][v8-perf]:
|
||||
|
||||
> So how can you, as a JavaScript developer, ensure that your RegExps are fast?
|
||||
> If you are not interested in hooking into RegExp internals, make sure that
|
||||
> neither the RegExp instance, nor its prototype is modified in order to get the
|
||||
> best performance:
|
||||
>
|
||||
> ```js
|
||||
> var re = /./g;
|
||||
> re.exec(''); // Fast path.
|
||||
> re.new_property = 'slow';
|
||||
> ```
|
||||
|
||||
This module used to export a single regex, with `.matchToToken` bolted
|
||||
on, just like in the above example. This release changes the exports of
|
||||
the module to avoid this issue.
|
||||
|
||||
Before:
|
||||
|
||||
```js
|
||||
import jsTokens from "js-tokens"
|
||||
// or:
|
||||
var jsTokens = require("js-tokens")
|
||||
var matchToToken = jsTokens.matchToToken
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```js
|
||||
import jsTokens, {matchToToken} from "js-tokens"
|
||||
// or:
|
||||
var jsTokens = require("js-tokens").default
|
||||
var matchToToken = require("js-tokens").matchToToken
|
||||
```
|
||||
|
||||
[v8-perf]: http://v8project.blogspot.se/2017/01/speeding-up-v8-regular-expressions.html
|
||||
|
||||
|
||||
### Version 2.0.0 (2016-06-19) ###
|
||||
|
||||
- Added: Support for ES2016. In other words, support for the `**` exponentiation
|
||||
operator.
|
||||
|
||||
These are the breaking changes:
|
||||
|
||||
- `'**'.match(jsTokens)` no longer returns `['*', '*']`, but `['**']`.
|
||||
- `'**='.match(jsTokens)` no longer returns `['*', '*=']`, but `['**=']`.
|
||||
|
||||
|
||||
### Version 1.0.3 (2016-03-27) ###
|
||||
|
||||
- Improved: Made the regex ever so slightly smaller.
|
||||
- Updated: The readme.
|
||||
|
||||
|
||||
### Version 1.0.2 (2015-10-18) ###
|
||||
|
||||
- Improved: Limited npm package contents for a smaller download. Thanks to
|
||||
@zertosh!
|
||||
|
||||
|
||||
### Version 1.0.1 (2015-06-20) ###
|
||||
|
||||
- Fixed: Declared an undeclared variable.
|
||||
|
||||
|
||||
### Version 1.0.0 (2015-02-26) ###
|
||||
|
||||
- Changed: Merged the 'operator' and 'punctuation' types into 'punctuator'. That
|
||||
type is now equivalent to the Punctuator token in the ECMAScript
|
||||
specification. (Backwards-incompatible change.)
|
||||
- Fixed: A `-` followed by a number is now correctly matched as a punctuator
|
||||
followed by a number. It used to be matched as just a number, but there is no
|
||||
such thing as negative number literals. (Possibly backwards-incompatible
|
||||
change.)
|
||||
|
||||
|
||||
### Version 0.4.1 (2015-02-21) ###
|
||||
|
||||
- Added: Support for the regex `u` flag.
|
||||
|
||||
|
||||
### Version 0.4.0 (2015-02-21) ###
|
||||
|
||||
- Improved: `jsTokens.matchToToken` performance.
|
||||
- Added: Support for octal and binary number literals.
|
||||
- Added: Support for template strings.
|
||||
|
||||
|
||||
### Version 0.3.1 (2015-01-06) ###
|
||||
|
||||
- Fixed: Support for unicode spaces. They used to be allowed in names (which is
|
||||
very confusing), and some unicode newlines were wrongly allowed in strings and
|
||||
regexes.
|
||||
|
||||
|
||||
### Version 0.3.0 (2014-12-19) ###
|
||||
|
||||
- Changed: The `jsTokens.names` array has been replaced with the
|
||||
`jsTokens.matchToToken` function. The capturing groups of `jsTokens` are no
|
||||
longer part of the public API; instead use said function. See this [gist] for
|
||||
an example. (Backwards-incompatible change.)
|
||||
- Changed: The empty string is now considered an “invalid” token, instead an
|
||||
“empty” token (its own group). (Backwards-incompatible change.)
|
||||
- Removed: component support. (Backwards-incompatible change.)
|
||||
|
||||
[gist]: https://gist.github.com/lydell/be49dbf80c382c473004
|
||||
|
||||
|
||||
### Version 0.2.0 (2014-06-19) ###
|
||||
|
||||
- Changed: Match ES6 function arrows (`=>`) as an operator, instead of its own
|
||||
category (“functionArrow”), for simplicity. (Backwards-incompatible change.)
|
||||
- Added: ES6 splats (`...`) are now matched as an operator (instead of three
|
||||
punctuations). (Backwards-incompatible change.)
|
||||
|
||||
|
||||
### Version 0.1.0 (2014-03-08) ###
|
||||
|
||||
- Initial release.
|
21
node_modules/js-tokens/LICENSE
generated
vendored
Normal file
21
node_modules/js-tokens/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
||||
|
||||
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.
|
240
node_modules/js-tokens/README.md
generated
vendored
Normal file
240
node_modules/js-tokens/README.md
generated
vendored
Normal file
|
@ -0,0 +1,240 @@
|
|||
Overview [](https://travis-ci.org/lydell/js-tokens)
|
||||
========
|
||||
|
||||
A regex that tokenizes JavaScript.
|
||||
|
||||
```js
|
||||
var jsTokens = require("js-tokens").default
|
||||
|
||||
var jsString = "var foo=opts.foo;\n..."
|
||||
|
||||
jsString.match(jsTokens)
|
||||
// ["var", " ", "foo", "=", "opts", ".", "foo", ";", "\n", ...]
|
||||
```
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
`npm install js-tokens`
|
||||
|
||||
```js
|
||||
import jsTokens from "js-tokens"
|
||||
// or:
|
||||
var jsTokens = require("js-tokens").default
|
||||
```
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
### `jsTokens` ###
|
||||
|
||||
A regex with the `g` flag that matches JavaScript tokens.
|
||||
|
||||
The regex _always_ matches, even invalid JavaScript and the empty string.
|
||||
|
||||
The next match is always directly after the previous.
|
||||
|
||||
### `var token = matchToToken(match)` ###
|
||||
|
||||
```js
|
||||
import {matchToToken} from "js-tokens"
|
||||
// or:
|
||||
var matchToToken = require("js-tokens").matchToToken
|
||||
```
|
||||
|
||||
Takes a `match` returned by `jsTokens.exec(string)`, and returns a `{type:
|
||||
String, value: String}` object. The following types are available:
|
||||
|
||||
- string
|
||||
- comment
|
||||
- regex
|
||||
- number
|
||||
- name
|
||||
- punctuator
|
||||
- whitespace
|
||||
- invalid
|
||||
|
||||
Multi-line comments and strings also have a `closed` property indicating if the
|
||||
token was closed or not (see below).
|
||||
|
||||
Comments and strings both come in several flavors. To distinguish them, check if
|
||||
the token starts with `//`, `/*`, `'`, `"` or `` ` ``.
|
||||
|
||||
Names are ECMAScript IdentifierNames, that is, including both identifiers and
|
||||
keywords. You may use [is-keyword-js] to tell them apart.
|
||||
|
||||
Whitespace includes both line terminators and other whitespace.
|
||||
|
||||
[is-keyword-js]: https://github.com/crissdev/is-keyword-js
|
||||
|
||||
|
||||
ECMAScript support
|
||||
==================
|
||||
|
||||
The intention is to always support the latest ECMAScript version whose feature
|
||||
set has been finalized.
|
||||
|
||||
If adding support for a newer version requires changes, a new version with a
|
||||
major verion bump will be released.
|
||||
|
||||
Currently, ECMAScript 2018 is supported.
|
||||
|
||||
|
||||
Invalid code handling
|
||||
=====================
|
||||
|
||||
Unterminated strings are still matched as strings. JavaScript strings cannot
|
||||
contain (unescaped) newlines, so unterminated strings simply end at the end of
|
||||
the line. Unterminated template strings can contain unescaped newlines, though,
|
||||
so they go on to the end of input.
|
||||
|
||||
Unterminated multi-line comments are also still matched as comments. They
|
||||
simply go on to the end of the input.
|
||||
|
||||
Unterminated regex literals are likely matched as division and whatever is
|
||||
inside the regex.
|
||||
|
||||
Invalid ASCII characters have their own capturing group.
|
||||
|
||||
Invalid non-ASCII characters are treated as names, to simplify the matching of
|
||||
names (except unicode spaces which are treated as whitespace). Note: See also
|
||||
the [ES2018](#es2018) section.
|
||||
|
||||
Regex literals may contain invalid regex syntax. They are still matched as
|
||||
regex literals. They may also contain repeated regex flags, to keep the regex
|
||||
simple.
|
||||
|
||||
Strings may contain invalid escape sequences.
|
||||
|
||||
|
||||
Limitations
|
||||
===========
|
||||
|
||||
Tokenizing JavaScript using regexes—in fact, _one single regex_—won’t be
|
||||
perfect. But that’s not the point either.
|
||||
|
||||
You may compare jsTokens with [esprima] by using `esprima-compare.js`.
|
||||
See `npm run esprima-compare`!
|
||||
|
||||
[esprima]: http://esprima.org/
|
||||
|
||||
### Template string interpolation ###
|
||||
|
||||
Template strings are matched as single tokens, from the starting `` ` `` to the
|
||||
ending `` ` ``, including interpolations (whose tokens are not matched
|
||||
individually).
|
||||
|
||||
Matching template string interpolations requires recursive balancing of `{` and
|
||||
`}`—something that JavaScript regexes cannot do. Only one level of nesting is
|
||||
supported.
|
||||
|
||||
### Division and regex literals collision ###
|
||||
|
||||
Consider this example:
|
||||
|
||||
```js
|
||||
var g = 9.82
|
||||
var number = bar / 2/g
|
||||
|
||||
var regex = / 2/g
|
||||
```
|
||||
|
||||
A human can easily understand that in the `number` line we’re dealing with
|
||||
division, and in the `regex` line we’re dealing with a regex literal. How come?
|
||||
Because humans can look at the whole code to put the `/` characters in context.
|
||||
A JavaScript regex cannot. It only sees forwards. (Well, ES2018 regexes can also
|
||||
look backwards. See the [ES2018](#es2018) section).
|
||||
|
||||
When the `jsTokens` regex scans throught the above, it will see the following
|
||||
at the end of both the `number` and `regex` rows:
|
||||
|
||||
```js
|
||||
/ 2/g
|
||||
```
|
||||
|
||||
It is then impossible to know if that is a regex literal, or part of an
|
||||
expression dealing with division.
|
||||
|
||||
Here is a similar case:
|
||||
|
||||
```js
|
||||
foo /= 2/g
|
||||
foo(/= 2/g)
|
||||
```
|
||||
|
||||
The first line divides the `foo` variable with `2/g`. The second line calls the
|
||||
`foo` function with the regex literal `/= 2/g`. Again, since `jsTokens` only
|
||||
sees forwards, it cannot tell the two cases apart.
|
||||
|
||||
There are some cases where we _can_ tell division and regex literals apart,
|
||||
though.
|
||||
|
||||
First off, we have the simple cases where there’s only one slash in the line:
|
||||
|
||||
```js
|
||||
var foo = 2/g
|
||||
foo /= 2
|
||||
```
|
||||
|
||||
Regex literals cannot contain newlines, so the above cases are correctly
|
||||
identified as division. Things are only problematic when there are more than
|
||||
one non-comment slash in a single line.
|
||||
|
||||
Secondly, not every character is a valid regex flag.
|
||||
|
||||
```js
|
||||
var number = bar / 2/e
|
||||
```
|
||||
|
||||
The above example is also correctly identified as division, because `e` is not a
|
||||
valid regex flag. I initially wanted to future-proof by allowing `[a-zA-Z]*`
|
||||
(any letter) as flags, but it is not worth it since it increases the amount of
|
||||
ambigous cases. So only the standard `g`, `m`, `i`, `y` and `u` flags are
|
||||
allowed. This means that the above example will be identified as division as
|
||||
long as you don’t rename the `e` variable to some permutation of `gmiyus` 1 to 6
|
||||
characters long.
|
||||
|
||||
Lastly, we can look _forward_ for information.
|
||||
|
||||
- If the token following what looks like a regex literal is not valid after a
|
||||
regex literal, but is valid in a division expression, then the regex literal
|
||||
is treated as division instead. For example, a flagless regex cannot be
|
||||
followed by a string, number or name, but all of those three can be the
|
||||
denominator of a division.
|
||||
- Generally, if what looks like a regex literal is followed by an operator, the
|
||||
regex literal is treated as division instead. This is because regexes are
|
||||
seldomly used with operators (such as `+`, `*`, `&&` and `==`), but division
|
||||
could likely be part of such an expression.
|
||||
|
||||
Please consult the regex source and the test cases for precise information on
|
||||
when regex or division is matched (should you need to know). In short, you
|
||||
could sum it up as:
|
||||
|
||||
If the end of a statement looks like a regex literal (even if it isn’t), it
|
||||
will be treated as one. Otherwise it should work as expected (if you write sane
|
||||
code).
|
||||
|
||||
### ES2018 ###
|
||||
|
||||
ES2018 added some nice regex improvements to the language.
|
||||
|
||||
- [Unicode property escapes] should allow telling names and invalid non-ASCII
|
||||
characters apart without blowing up the regex size.
|
||||
- [Lookbehind assertions] should allow matching telling division and regex
|
||||
literals apart in more cases.
|
||||
- [Named capture groups] might simplify some things.
|
||||
|
||||
These things would be nice to do, but are not critical. They probably have to
|
||||
wait until the oldest maintained Node.js LTS release supports those features.
|
||||
|
||||
[Unicode property escapes]: http://2ality.com/2017/07/regexp-unicode-property-escapes.html
|
||||
[Lookbehind assertions]: http://2ality.com/2017/05/regexp-lookbehind-assertions.html
|
||||
[Named capture groups]: http://2ality.com/2017/05/regexp-named-capture-groups.html
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
[MIT](LICENSE).
|
23
node_modules/js-tokens/index.js
generated
vendored
Normal file
23
node_modules/js-tokens/index.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
||||
// License: MIT. (See LICENSE.)
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
})
|
||||
|
||||
// This regex comes from regex.coffee, and is inserted here by generate-index.js
|
||||
// (run `npm run build`).
|
||||
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g
|
||||
|
||||
exports.matchToToken = function(match) {
|
||||
var token = {type: "invalid", value: match[0], closed: undefined}
|
||||
if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4])
|
||||
else if (match[ 5]) token.type = "comment"
|
||||
else if (match[ 6]) token.type = "comment", token.closed = !!match[7]
|
||||
else if (match[ 8]) token.type = "regex"
|
||||
else if (match[ 9]) token.type = "number"
|
||||
else if (match[10]) token.type = "name"
|
||||
else if (match[11]) token.type = "punctuator"
|
||||
else if (match[12]) token.type = "whitespace"
|
||||
return token
|
||||
}
|
30
node_modules/js-tokens/package.json
generated
vendored
Normal file
30
node_modules/js-tokens/package.json
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "js-tokens",
|
||||
"version": "4.0.0",
|
||||
"author": "Simon Lydell",
|
||||
"license": "MIT",
|
||||
"description": "A regex that tokenizes JavaScript.",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
"js",
|
||||
"token",
|
||||
"tokenize",
|
||||
"regex"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"repository": "lydell/js-tokens",
|
||||
"scripts": {
|
||||
"test": "mocha --ui tdd",
|
||||
"esprima-compare": "node esprima-compare ./index.js everything.js/es5.js",
|
||||
"build": "node generate-index.js",
|
||||
"dev": "npm run build && npm test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffeescript": "2.1.1",
|
||||
"esprima": "4.0.0",
|
||||
"everything.js": "1.0.3",
|
||||
"mocha": "5.0.0"
|
||||
}
|
||||
}
|
21
node_modules/loose-envify/LICENSE
generated
vendored
Normal file
21
node_modules/loose-envify/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Andres Suarez <zertosh@gmail.com>
|
||||
|
||||
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.
|
45
node_modules/loose-envify/README.md
generated
vendored
Normal file
45
node_modules/loose-envify/README.md
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
# loose-envify
|
||||
|
||||
[](https://travis-ci.org/zertosh/loose-envify)
|
||||
|
||||
Fast (and loose) selective `process.env` replacer using [js-tokens](https://github.com/lydell/js-tokens) instead of an AST. Works just like [envify](https://github.com/hughsk/envify) but much faster.
|
||||
|
||||
## Gotchas
|
||||
|
||||
* Doesn't handle broken syntax.
|
||||
* Doesn't look inside embedded expressions in template strings.
|
||||
- **this won't work:**
|
||||
```js
|
||||
console.log(`the current env is ${process.env.NODE_ENV}`);
|
||||
```
|
||||
* Doesn't replace oddly-spaced or oddly-commented expressions.
|
||||
- **this won't work:**
|
||||
```js
|
||||
console.log(process./*won't*/env./*work*/NODE_ENV);
|
||||
```
|
||||
|
||||
## Usage/Options
|
||||
|
||||
loose-envify has the exact same interface as [envify](https://github.com/hughsk/envify), including the CLI.
|
||||
|
||||
## Benchmark
|
||||
|
||||
```
|
||||
envify:
|
||||
|
||||
$ for i in {1..5}; do node bench/bench.js 'envify'; done
|
||||
708ms
|
||||
727ms
|
||||
791ms
|
||||
719ms
|
||||
720ms
|
||||
|
||||
loose-envify:
|
||||
|
||||
$ for i in {1..5}; do node bench/bench.js '../'; done
|
||||
51ms
|
||||
52ms
|
||||
52ms
|
||||
52ms
|
||||
52ms
|
||||
```
|
16
node_modules/loose-envify/cli.js
generated
vendored
Executable file
16
node_modules/loose-envify/cli.js
generated
vendored
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var looseEnvify = require('./');
|
||||
var fs = require('fs');
|
||||
|
||||
if (process.argv[2]) {
|
||||
fs.createReadStream(process.argv[2], {encoding: 'utf8'})
|
||||
.pipe(looseEnvify(process.argv[2]))
|
||||
.pipe(process.stdout);
|
||||
} else {
|
||||
process.stdin.resume()
|
||||
process.stdin
|
||||
.pipe(looseEnvify(__filename))
|
||||
.pipe(process.stdout);
|
||||
}
|
4
node_modules/loose-envify/custom.js
generated
vendored
Normal file
4
node_modules/loose-envify/custom.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// envify compatibility
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./loose-envify');
|
3
node_modules/loose-envify/index.js
generated
vendored
Normal file
3
node_modules/loose-envify/index.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = require('./loose-envify')(process.env);
|
36
node_modules/loose-envify/loose-envify.js
generated
vendored
Normal file
36
node_modules/loose-envify/loose-envify.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
var stream = require('stream');
|
||||
var util = require('util');
|
||||
var replace = require('./replace');
|
||||
|
||||
var jsonExtRe = /\.json$/;
|
||||
|
||||
module.exports = function(rootEnv) {
|
||||
rootEnv = rootEnv || process.env;
|
||||
return function (file, trOpts) {
|
||||
if (jsonExtRe.test(file)) {
|
||||
return stream.PassThrough();
|
||||
}
|
||||
var envs = trOpts ? [rootEnv, trOpts] : [rootEnv];
|
||||
return new LooseEnvify(envs);
|
||||
};
|
||||
};
|
||||
|
||||
function LooseEnvify(envs) {
|
||||
stream.Transform.call(this);
|
||||
this._data = '';
|
||||
this._envs = envs;
|
||||
}
|
||||
util.inherits(LooseEnvify, stream.Transform);
|
||||
|
||||
LooseEnvify.prototype._transform = function(buf, enc, cb) {
|
||||
this._data += buf;
|
||||
cb();
|
||||
};
|
||||
|
||||
LooseEnvify.prototype._flush = function(cb) {
|
||||
var replaced = replace(this._data, this._envs);
|
||||
this.push(replaced);
|
||||
cb();
|
||||
};
|
36
node_modules/loose-envify/package.json
generated
vendored
Normal file
36
node_modules/loose-envify/package.json
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "loose-envify",
|
||||
"version": "1.4.0",
|
||||
"description": "Fast (and loose) selective `process.env` replacer using js-tokens instead of an AST",
|
||||
"keywords": [
|
||||
"environment",
|
||||
"variables",
|
||||
"browserify",
|
||||
"browserify-transform",
|
||||
"transform",
|
||||
"source",
|
||||
"configuration"
|
||||
],
|
||||
"homepage": "https://github.com/zertosh/loose-envify",
|
||||
"license": "MIT",
|
||||
"author": "Andres Suarez <zertosh@gmail.com>",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"loose-envify": "cli.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/zertosh/loose-envify.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^13.1.1",
|
||||
"envify": "^3.4.0",
|
||||
"tap": "^8.0.0"
|
||||
}
|
||||
}
|
65
node_modules/loose-envify/replace.js
generated
vendored
Normal file
65
node_modules/loose-envify/replace.js
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
'use strict';
|
||||
|
||||
var jsTokens = require('js-tokens').default;
|
||||
|
||||
var processEnvRe = /\bprocess\.env\.[_$a-zA-Z][$\w]+\b/;
|
||||
var spaceOrCommentRe = /^(?:\s|\/[/*])/;
|
||||
|
||||
function replace(src, envs) {
|
||||
if (!processEnvRe.test(src)) {
|
||||
return src;
|
||||
}
|
||||
|
||||
var out = [];
|
||||
var purge = envs.some(function(env) {
|
||||
return env._ && env._.indexOf('purge') !== -1;
|
||||
});
|
||||
|
||||
jsTokens.lastIndex = 0
|
||||
var parts = src.match(jsTokens);
|
||||
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
if (parts[i ] === 'process' &&
|
||||
parts[i + 1] === '.' &&
|
||||
parts[i + 2] === 'env' &&
|
||||
parts[i + 3] === '.') {
|
||||
var prevCodeToken = getAdjacentCodeToken(-1, parts, i);
|
||||
var nextCodeToken = getAdjacentCodeToken(1, parts, i + 4);
|
||||
var replacement = getReplacementString(envs, parts[i + 4], purge);
|
||||
if (prevCodeToken !== '.' &&
|
||||
nextCodeToken !== '.' &&
|
||||
nextCodeToken !== '=' &&
|
||||
typeof replacement === 'string') {
|
||||
out.push(replacement);
|
||||
i += 4;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
out.push(parts[i]);
|
||||
}
|
||||
|
||||
return out.join('');
|
||||
}
|
||||
|
||||
function getAdjacentCodeToken(dir, parts, i) {
|
||||
while (true) {
|
||||
var part = parts[i += dir];
|
||||
if (!spaceOrCommentRe.test(part)) {
|
||||
return part;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getReplacementString(envs, name, purge) {
|
||||
for (var j = 0; j < envs.length; j++) {
|
||||
var env = envs[j];
|
||||
if (typeof env[name] !== 'undefined') {
|
||||
return JSON.stringify(env[name]);
|
||||
}
|
||||
}
|
||||
if (purge) {
|
||||
return 'undefined';
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = replace;
|
20
node_modules/nanoid/LICENSE
generated
vendored
Normal file
20
node_modules/nanoid/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
|
||||
|
||||
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.
|
39
node_modules/nanoid/README.md
generated
vendored
Normal file
39
node_modules/nanoid/README.md
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Nano ID
|
||||
|
||||
<img src="https://ai.github.io/nanoid/logo.svg" align="right"
|
||||
alt="Nano ID logo by Anton Lovchikov" width="180" height="94">
|
||||
|
||||
**English** | [Русский](./README.ru.md) | [简体中文](./README.zh-CN.md) | [Bahasa Indonesia](./README.id-ID.md)
|
||||
|
||||
A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
|
||||
|
||||
> “An amazing level of senseless perfectionism,
|
||||
> which is simply impossible not to respect.”
|
||||
|
||||
* **Small.** 130 bytes (minified and gzipped). No dependencies.
|
||||
[Size Limit] controls the size.
|
||||
* **Fast.** It is 2 times faster than UUID.
|
||||
* **Safe.** It uses hardware random generator. Can be used in clusters.
|
||||
* **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
|
||||
So ID size was reduced from 36 to 21 symbols.
|
||||
* **Portable.** Nano ID was ported
|
||||
to [20 programming languages](#other-programming-languages).
|
||||
|
||||
```js
|
||||
import { nanoid } from 'nanoid'
|
||||
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
|
||||
```
|
||||
|
||||
Supports modern browsers, IE [with Babel], Node.js and React Native.
|
||||
|
||||
[online tool]: https://gitpod.io/#https://github.com/ai/nanoid/
|
||||
[with Babel]: https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/
|
||||
[Size Limit]: https://github.com/ai/size-limit
|
||||
|
||||
<a href="https://evilmartians.com/?utm_source=nanoid">
|
||||
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
|
||||
alt="Sponsored by Evil Martians" width="236" height="54">
|
||||
</a>
|
||||
|
||||
## Docs
|
||||
Read full docs **[here](https://github.com/ai/nanoid#readme)**.
|
69
node_modules/nanoid/async/index.browser.cjs
generated
vendored
Normal file
69
node_modules/nanoid/async/index.browser.cjs
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
||||
|
||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
// First, a bitmask is necessary to generate the ID. The bitmask makes bytes
|
||||
// values closer to the alphabet size. The bitmask calculates the closest
|
||||
// `2^31 - 1` number, which exceeds the alphabet size.
|
||||
// For example, the bitmask for the alphabet size 30 is 31 (00011111).
|
||||
// `Math.clz32` is not used, because it is not available in browsers.
|
||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
||||
// Though, the bitmask solution is not perfect since the bytes exceeding
|
||||
// the alphabet size are refused. Therefore, to reliably generate the ID,
|
||||
// the random bytes redundancy has to be satisfied.
|
||||
|
||||
// Note: every hardware random generator call is performance expensive,
|
||||
// because the system call for entropy collection takes a lot of time.
|
||||
// So, to avoid additional system calls, extra bytes are requested in advance.
|
||||
|
||||
// Next, a step determines how many random bytes to generate.
|
||||
// The number of random bytes gets decided upon the ID size, mask,
|
||||
// alphabet size, and magic number 1.6 (using 1.6 peaks at performance
|
||||
// according to benchmarks).
|
||||
|
||||
// `-~f => Math.ceil(f)` if f is a float
|
||||
// `-~i => i + 1` if i is an integer
|
||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
||||
|
||||
return async (size = defaultSize) => {
|
||||
let id = ''
|
||||
while (true) {
|
||||
let bytes = crypto.getRandomValues(new Uint8Array(step))
|
||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
||||
let i = step | 0
|
||||
while (i--) {
|
||||
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let nanoid = async (size = 21) => {
|
||||
let id = ''
|
||||
let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))
|
||||
|
||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
||||
while (size--) {
|
||||
// It is incorrect to use bytes exceeding the alphabet size.
|
||||
// The following mask reduces the random byte in the 0-255 value
|
||||
// range to the 0-63 value range. Therefore, adding hacks, such
|
||||
// as empty string fallback or magic numbers, is unneccessary because
|
||||
// the bitmask trims bytes down to the alphabet size.
|
||||
let byte = bytes[size] & 63
|
||||
if (byte < 36) {
|
||||
// `0-9a-z`
|
||||
id += byte.toString(36)
|
||||
} else if (byte < 62) {
|
||||
// `A-Z`
|
||||
id += (byte - 26).toString(36).toUpperCase()
|
||||
} else if (byte < 63) {
|
||||
id += '_'
|
||||
} else {
|
||||
id += '-'
|
||||
}
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
module.exports = { nanoid, customAlphabet, random }
|
34
node_modules/nanoid/async/index.browser.js
generated
vendored
Normal file
34
node_modules/nanoid/async/index.browser.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
||||
return async (size = defaultSize) => {
|
||||
let id = ''
|
||||
while (true) {
|
||||
let bytes = crypto.getRandomValues(new Uint8Array(step))
|
||||
let i = step | 0
|
||||
while (i--) {
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let nanoid = async (size = 21) => {
|
||||
let id = ''
|
||||
let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))
|
||||
while (size--) {
|
||||
let byte = bytes[size] & 63
|
||||
if (byte < 36) {
|
||||
id += byte.toString(36)
|
||||
} else if (byte < 62) {
|
||||
id += (byte - 26).toString(36).toUpperCase()
|
||||
} else if (byte < 63) {
|
||||
id += '_'
|
||||
} else {
|
||||
id += '-'
|
||||
}
|
||||
}
|
||||
return id
|
||||
}
|
||||
export { nanoid, customAlphabet, random }
|
71
node_modules/nanoid/async/index.cjs
generated
vendored
Normal file
71
node_modules/nanoid/async/index.cjs
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
let crypto = require('crypto')
|
||||
|
||||
let { urlAlphabet } = require('../url-alphabet/index.cjs')
|
||||
|
||||
// `crypto.randomFill()` is a little faster than `crypto.randomBytes()`,
|
||||
// because it is possible to use in combination with `Buffer.allocUnsafe()`.
|
||||
let random = bytes =>
|
||||
new Promise((resolve, reject) => {
|
||||
// `Buffer.allocUnsafe()` is faster because it doesn’t flush the memory.
|
||||
// Memory flushing is unnecessary since the buffer allocation itself resets
|
||||
// the memory with the new bytes.
|
||||
crypto.randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(buf)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
// First, a bitmask is necessary to generate the ID. The bitmask makes bytes
|
||||
// values closer to the alphabet size. The bitmask calculates the closest
|
||||
// `2^31 - 1` number, which exceeds the alphabet size.
|
||||
// For example, the bitmask for the alphabet size 30 is 31 (00011111).
|
||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
||||
// Though, the bitmask solution is not perfect since the bytes exceeding
|
||||
// the alphabet size are refused. Therefore, to reliably generate the ID,
|
||||
// the random bytes redundancy has to be satisfied.
|
||||
|
||||
// Note: every hardware random generator call is performance expensive,
|
||||
// because the system call for entropy collection takes a lot of time.
|
||||
// So, to avoid additional system calls, extra bytes are requested in advance.
|
||||
|
||||
// Next, a step determines how many random bytes to generate.
|
||||
// The number of random bytes gets decided upon the ID size, mask,
|
||||
// alphabet size, and magic number 1.6 (using 1.6 peaks at performance
|
||||
// according to benchmarks).
|
||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
||||
|
||||
let tick = (id, size = defaultSize) =>
|
||||
random(step).then(bytes => {
|
||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
||||
let i = step
|
||||
while (i--) {
|
||||
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length >= size) return id
|
||||
}
|
||||
return tick(id, size)
|
||||
})
|
||||
|
||||
return size => tick('', size)
|
||||
}
|
||||
|
||||
let nanoid = (size = 21) =>
|
||||
random((size |= 0)).then(bytes => {
|
||||
let id = ''
|
||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
||||
while (size--) {
|
||||
// It is incorrect to use bytes exceeding the alphabet size.
|
||||
// The following mask reduces the random byte in the 0-255 value
|
||||
// range to the 0-63 value range. Therefore, adding hacks, such
|
||||
// as empty string fallback or magic numbers, is unneccessary because
|
||||
// the bitmask trims bytes down to the alphabet size.
|
||||
id += urlAlphabet[bytes[size] & 63]
|
||||
}
|
||||
return id
|
||||
})
|
||||
|
||||
module.exports = { nanoid, customAlphabet, random }
|
56
node_modules/nanoid/async/index.d.ts
generated
vendored
Normal file
56
node_modules/nanoid/async/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* Generate secure URL-friendly unique ID. The non-blocking version.
|
||||
*
|
||||
* By default, the ID will have 21 symbols to have a collision probability
|
||||
* similar to UUID v4.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid/async'
|
||||
* nanoid().then(id => {
|
||||
* model.id = id
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A promise with a random string.
|
||||
*/
|
||||
export function nanoid(size?: number): Promise<string>
|
||||
|
||||
/**
|
||||
* A low-level function.
|
||||
* Generate secure unique ID with custom alphabet. The non-blocking version.
|
||||
*
|
||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
||||
* will not be secure.
|
||||
*
|
||||
* @param alphabet Alphabet used to generate the ID.
|
||||
* @param defaultSize Size of the ID. The default size is 21.
|
||||
* @returns A function that returns a promise with a random string.
|
||||
*
|
||||
* ```js
|
||||
* import { customAlphabet } from 'nanoid/async'
|
||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
||||
* nanoid().then(id => {
|
||||
* model.id = id //=> "8ё56а"
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export function customAlphabet(
|
||||
alphabet: string,
|
||||
defaultSize?: number
|
||||
): (size?: number) => Promise<string>
|
||||
|
||||
/**
|
||||
* Generate an array of random bytes collected from hardware noise.
|
||||
*
|
||||
* ```js
|
||||
* import { random } from 'nanoid/async'
|
||||
* random(5).then(bytes => {
|
||||
* bytes //=> [10, 67, 212, 67, 89]
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @param bytes Size of the array.
|
||||
* @returns A promise with a random bytes array.
|
||||
*/
|
||||
export function random(bytes: number): Promise<Uint8Array>
|
35
node_modules/nanoid/async/index.js
generated
vendored
Normal file
35
node_modules/nanoid/async/index.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
import crypto from 'crypto'
|
||||
import { urlAlphabet } from '../url-alphabet/index.js'
|
||||
let random = bytes =>
|
||||
new Promise((resolve, reject) => {
|
||||
crypto.randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(buf)
|
||||
}
|
||||
})
|
||||
})
|
||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
||||
let tick = (id, size = defaultSize) =>
|
||||
random(step).then(bytes => {
|
||||
let i = step
|
||||
while (i--) {
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length >= size) return id
|
||||
}
|
||||
return tick(id, size)
|
||||
})
|
||||
return size => tick('', size)
|
||||
}
|
||||
let nanoid = (size = 21) =>
|
||||
random((size |= 0)).then(bytes => {
|
||||
let id = ''
|
||||
while (size--) {
|
||||
id += urlAlphabet[bytes[size] & 63]
|
||||
}
|
||||
return id
|
||||
})
|
||||
export { nanoid, customAlphabet, random }
|
26
node_modules/nanoid/async/index.native.js
generated
vendored
Normal file
26
node_modules/nanoid/async/index.native.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { getRandomBytesAsync } from 'expo-random'
|
||||
import { urlAlphabet } from '../url-alphabet/index.js'
|
||||
let random = getRandomBytesAsync
|
||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
||||
let tick = (id, size = defaultSize) =>
|
||||
random(step).then(bytes => {
|
||||
let i = step
|
||||
while (i--) {
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length >= size) return id
|
||||
}
|
||||
return tick(id, size)
|
||||
})
|
||||
return size => tick('', size)
|
||||
}
|
||||
let nanoid = (size = 21) =>
|
||||
random((size |= 0)).then(bytes => {
|
||||
let id = ''
|
||||
while (size--) {
|
||||
id += urlAlphabet[bytes[size] & 63]
|
||||
}
|
||||
return id
|
||||
})
|
||||
export { nanoid, customAlphabet, random }
|
12
node_modules/nanoid/async/package.json
generated
vendored
Normal file
12
node_modules/nanoid/async/package.json
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"module": "index.js",
|
||||
"react-native": {
|
||||
"./index.js": "./index.native.js"
|
||||
},
|
||||
"browser": {
|
||||
"./index.js": "./index.browser.js",
|
||||
"./index.cjs": "./index.browser.cjs"
|
||||
}
|
||||
}
|
55
node_modules/nanoid/bin/nanoid.cjs
generated
vendored
Executable file
55
node_modules/nanoid/bin/nanoid.cjs
generated
vendored
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
let { nanoid, customAlphabet } = require('..')
|
||||
|
||||
function print(msg) {
|
||||
process.stdout.write(msg + '\n')
|
||||
}
|
||||
|
||||
function error(msg) {
|
||||
process.stderr.write(msg + '\n')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
||||
print(`
|
||||
Usage
|
||||
$ nanoid [options]
|
||||
|
||||
Options
|
||||
-s, --size Generated ID size
|
||||
-a, --alphabet Alphabet to use
|
||||
-h, --help Show this help
|
||||
|
||||
Examples
|
||||
$ nanoid --s 15
|
||||
S9sBF77U6sDB8Yg
|
||||
|
||||
$ nanoid --size 10 --alphabet abc
|
||||
bcabababca`)
|
||||
process.exit()
|
||||
}
|
||||
|
||||
let alphabet, size
|
||||
for (let i = 2; i < process.argv.length; i++) {
|
||||
let arg = process.argv[i]
|
||||
if (arg === '--size' || arg === '-s') {
|
||||
size = Number(process.argv[i + 1])
|
||||
i += 1
|
||||
if (Number.isNaN(size) || size <= 0) {
|
||||
error('Size must be positive integer')
|
||||
}
|
||||
} else if (arg === '--alphabet' || arg === '-a') {
|
||||
alphabet = process.argv[i + 1]
|
||||
i += 1
|
||||
} else {
|
||||
error('Unknown argument ' + arg)
|
||||
}
|
||||
}
|
||||
|
||||
if (alphabet) {
|
||||
let customNanoid = customAlphabet(alphabet, size)
|
||||
print(customNanoid())
|
||||
} else {
|
||||
print(nanoid(size))
|
||||
}
|
72
node_modules/nanoid/index.browser.cjs
generated
vendored
Normal file
72
node_modules/nanoid/index.browser.cjs
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
// This file replaces `index.js` in bundlers like webpack or Rollup,
|
||||
// according to `browser` config in `package.json`.
|
||||
|
||||
let { urlAlphabet } = require('./url-alphabet/index.cjs')
|
||||
|
||||
let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
||||
|
||||
let customRandom = (alphabet, defaultSize, getRandom) => {
|
||||
// First, a bitmask is necessary to generate the ID. The bitmask makes bytes
|
||||
// values closer to the alphabet size. The bitmask calculates the closest
|
||||
// `2^31 - 1` number, which exceeds the alphabet size.
|
||||
// For example, the bitmask for the alphabet size 30 is 31 (00011111).
|
||||
// `Math.clz32` is not used, because it is not available in browsers.
|
||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
||||
// Though, the bitmask solution is not perfect since the bytes exceeding
|
||||
// the alphabet size are refused. Therefore, to reliably generate the ID,
|
||||
// the random bytes redundancy has to be satisfied.
|
||||
|
||||
// Note: every hardware random generator call is performance expensive,
|
||||
// because the system call for entropy collection takes a lot of time.
|
||||
// So, to avoid additional system calls, extra bytes are requested in advance.
|
||||
|
||||
// Next, a step determines how many random bytes to generate.
|
||||
// The number of random bytes gets decided upon the ID size, mask,
|
||||
// alphabet size, and magic number 1.6 (using 1.6 peaks at performance
|
||||
// according to benchmarks).
|
||||
|
||||
// `-~f => Math.ceil(f)` if f is a float
|
||||
// `-~i => i + 1` if i is an integer
|
||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
||||
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
while (true) {
|
||||
let bytes = getRandom(step)
|
||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
||||
let j = step | 0
|
||||
while (j--) {
|
||||
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
||||
id += alphabet[bytes[j] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let customAlphabet = (alphabet, size = 21) =>
|
||||
customRandom(alphabet, size, random)
|
||||
|
||||
let nanoid = (size = 21) =>
|
||||
crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
||||
// It is incorrect to use bytes exceeding the alphabet size.
|
||||
// The following mask reduces the random byte in the 0-255 value
|
||||
// range to the 0-63 value range. Therefore, adding hacks, such
|
||||
// as empty string fallback or magic numbers, is unneccessary because
|
||||
// the bitmask trims bytes down to the alphabet size.
|
||||
byte &= 63
|
||||
if (byte < 36) {
|
||||
// `0-9a-z`
|
||||
id += byte.toString(36)
|
||||
} else if (byte < 62) {
|
||||
// `A-Z`
|
||||
id += (byte - 26).toString(36).toUpperCase()
|
||||
} else if (byte > 62) {
|
||||
id += '-'
|
||||
} else {
|
||||
id += '_'
|
||||
}
|
||||
return id
|
||||
}, '')
|
||||
|
||||
module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
34
node_modules/nanoid/index.browser.js
generated
vendored
Normal file
34
node_modules/nanoid/index.browser.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { urlAlphabet } from './url-alphabet/index.js'
|
||||
let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
||||
let customRandom = (alphabet, defaultSize, getRandom) => {
|
||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
while (true) {
|
||||
let bytes = getRandom(step)
|
||||
let j = step | 0
|
||||
while (j--) {
|
||||
id += alphabet[bytes[j] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let customAlphabet = (alphabet, size = 21) =>
|
||||
customRandom(alphabet, size, random)
|
||||
let nanoid = (size = 21) =>
|
||||
crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
||||
byte &= 63
|
||||
if (byte < 36) {
|
||||
id += byte.toString(36)
|
||||
} else if (byte < 62) {
|
||||
id += (byte - 26).toString(36).toUpperCase()
|
||||
} else if (byte > 62) {
|
||||
id += '-'
|
||||
} else {
|
||||
id += '_'
|
||||
}
|
||||
return id
|
||||
}, '')
|
||||
export { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
85
node_modules/nanoid/index.cjs
generated
vendored
Normal file
85
node_modules/nanoid/index.cjs
generated
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
let crypto = require('crypto')
|
||||
|
||||
let { urlAlphabet } = require('./url-alphabet/index.cjs')
|
||||
|
||||
// It is best to make fewer, larger requests to the crypto module to
|
||||
// avoid system call overhead. So, random numbers are generated in a
|
||||
// pool. The pool is a Buffer that is larger than the initial random
|
||||
// request size by this multiplier. The pool is enlarged if subsequent
|
||||
// requests exceed the maximum buffer size.
|
||||
const POOL_SIZE_MULTIPLIER = 128
|
||||
let pool, poolOffset
|
||||
|
||||
let fillPool = bytes => {
|
||||
if (!pool || pool.length < bytes) {
|
||||
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
|
||||
crypto.randomFillSync(pool)
|
||||
poolOffset = 0
|
||||
} else if (poolOffset + bytes > pool.length) {
|
||||
crypto.randomFillSync(pool)
|
||||
poolOffset = 0
|
||||
}
|
||||
poolOffset += bytes
|
||||
}
|
||||
|
||||
let random = bytes => {
|
||||
// `|=` convert `bytes` to number to prevent `valueOf` abusing and pool pollution
|
||||
fillPool((bytes |= 0))
|
||||
return pool.subarray(poolOffset - bytes, poolOffset)
|
||||
}
|
||||
|
||||
let customRandom = (alphabet, defaultSize, getRandom) => {
|
||||
// First, a bitmask is necessary to generate the ID. The bitmask makes bytes
|
||||
// values closer to the alphabet size. The bitmask calculates the closest
|
||||
// `2^31 - 1` number, which exceeds the alphabet size.
|
||||
// For example, the bitmask for the alphabet size 30 is 31 (00011111).
|
||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
||||
// Though, the bitmask solution is not perfect since the bytes exceeding
|
||||
// the alphabet size are refused. Therefore, to reliably generate the ID,
|
||||
// the random bytes redundancy has to be satisfied.
|
||||
|
||||
// Note: every hardware random generator call is performance expensive,
|
||||
// because the system call for entropy collection takes a lot of time.
|
||||
// So, to avoid additional system calls, extra bytes are requested in advance.
|
||||
|
||||
// Next, a step determines how many random bytes to generate.
|
||||
// The number of random bytes gets decided upon the ID size, mask,
|
||||
// alphabet size, and magic number 1.6 (using 1.6 peaks at performance
|
||||
// according to benchmarks).
|
||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
||||
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
while (true) {
|
||||
let bytes = getRandom(step)
|
||||
// A compact alternative for `for (let i = 0; i < step; i++)`.
|
||||
let i = step
|
||||
while (i--) {
|
||||
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let customAlphabet = (alphabet, size = 21) =>
|
||||
customRandom(alphabet, size, random)
|
||||
|
||||
let nanoid = (size = 21) => {
|
||||
// `|=` convert `size` to number to prevent `valueOf` abusing and pool pollution
|
||||
fillPool((size |= 0))
|
||||
let id = ''
|
||||
// We are reading directly from the random pool to avoid creating new array
|
||||
for (let i = poolOffset - size; i < poolOffset; i++) {
|
||||
// It is incorrect to use bytes exceeding the alphabet size.
|
||||
// The following mask reduces the random byte in the 0-255 value
|
||||
// range to the 0-63 value range. Therefore, adding hacks, such
|
||||
// as empty string fallback or magic numbers, is unneccessary because
|
||||
// the bitmask trims bytes down to the alphabet size.
|
||||
id += urlAlphabet[pool[i] & 63]
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
91
node_modules/nanoid/index.d.cts
generated
vendored
Normal file
91
node_modules/nanoid/index.d.cts
generated
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
* Generate secure URL-friendly unique ID.
|
||||
*
|
||||
* By default, the ID will have 21 symbols to have a collision probability
|
||||
* similar to UUID v4.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid'
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A random string.
|
||||
*/
|
||||
export function nanoid(size?: number): string
|
||||
|
||||
/**
|
||||
* Generate secure unique ID with custom alphabet.
|
||||
*
|
||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
||||
* will not be secure.
|
||||
*
|
||||
* @param alphabet Alphabet used to generate the ID.
|
||||
* @param defaultSize Size of the ID. The default size is 21.
|
||||
* @returns A random string generator.
|
||||
*
|
||||
* ```js
|
||||
* const { customAlphabet } = require('nanoid')
|
||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
||||
* nanoid() //=> "8ё56а"
|
||||
* ```
|
||||
*/
|
||||
export function customAlphabet(
|
||||
alphabet: string,
|
||||
defaultSize?: number
|
||||
): (size?: number) => string
|
||||
|
||||
/**
|
||||
* Generate unique ID with custom random generator and alphabet.
|
||||
*
|
||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
||||
* will not be secure.
|
||||
*
|
||||
* ```js
|
||||
* import { customRandom } from 'nanoid/format'
|
||||
*
|
||||
* const nanoid = customRandom('abcdef', 5, size => {
|
||||
* const random = []
|
||||
* for (let i = 0; i < size; i++) {
|
||||
* random.push(randomByte())
|
||||
* }
|
||||
* return random
|
||||
* })
|
||||
*
|
||||
* nanoid() //=> "fbaef"
|
||||
* ```
|
||||
*
|
||||
* @param alphabet Alphabet used to generate a random string.
|
||||
* @param size Size of the random string.
|
||||
* @param random A random bytes generator.
|
||||
* @returns A random string generator.
|
||||
*/
|
||||
export function customRandom(
|
||||
alphabet: string,
|
||||
size: number,
|
||||
random: (bytes: number) => Uint8Array
|
||||
): () => string
|
||||
|
||||
/**
|
||||
* URL safe symbols.
|
||||
*
|
||||
* ```js
|
||||
* import { urlAlphabet } from 'nanoid'
|
||||
* const nanoid = customAlphabet(urlAlphabet, 10)
|
||||
* nanoid() //=> "Uakgb_J5m9"
|
||||
* ```
|
||||
*/
|
||||
export const urlAlphabet: string
|
||||
|
||||
/**
|
||||
* Generate an array of random bytes collected from hardware noise.
|
||||
*
|
||||
* ```js
|
||||
* import { customRandom, random } from 'nanoid'
|
||||
* const nanoid = customRandom("abcdef", 5, random)
|
||||
* ```
|
||||
*
|
||||
* @param bytes Size of the array.
|
||||
* @returns An array of random bytes.
|
||||
*/
|
||||
export function random(bytes: number): Uint8Array
|
91
node_modules/nanoid/index.d.ts
generated
vendored
Normal file
91
node_modules/nanoid/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
* Generate secure URL-friendly unique ID.
|
||||
*
|
||||
* By default, the ID will have 21 symbols to have a collision probability
|
||||
* similar to UUID v4.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid'
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A random string.
|
||||
*/
|
||||
export function nanoid(size?: number): string
|
||||
|
||||
/**
|
||||
* Generate secure unique ID with custom alphabet.
|
||||
*
|
||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
||||
* will not be secure.
|
||||
*
|
||||
* @param alphabet Alphabet used to generate the ID.
|
||||
* @param defaultSize Size of the ID. The default size is 21.
|
||||
* @returns A random string generator.
|
||||
*
|
||||
* ```js
|
||||
* const { customAlphabet } = require('nanoid')
|
||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
||||
* nanoid() //=> "8ё56а"
|
||||
* ```
|
||||
*/
|
||||
export function customAlphabet(
|
||||
alphabet: string,
|
||||
defaultSize?: number
|
||||
): (size?: number) => string
|
||||
|
||||
/**
|
||||
* Generate unique ID with custom random generator and alphabet.
|
||||
*
|
||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
||||
* will not be secure.
|
||||
*
|
||||
* ```js
|
||||
* import { customRandom } from 'nanoid/format'
|
||||
*
|
||||
* const nanoid = customRandom('abcdef', 5, size => {
|
||||
* const random = []
|
||||
* for (let i = 0; i < size; i++) {
|
||||
* random.push(randomByte())
|
||||
* }
|
||||
* return random
|
||||
* })
|
||||
*
|
||||
* nanoid() //=> "fbaef"
|
||||
* ```
|
||||
*
|
||||
* @param alphabet Alphabet used to generate a random string.
|
||||
* @param size Size of the random string.
|
||||
* @param random A random bytes generator.
|
||||
* @returns A random string generator.
|
||||
*/
|
||||
export function customRandom(
|
||||
alphabet: string,
|
||||
size: number,
|
||||
random: (bytes: number) => Uint8Array
|
||||
): () => string
|
||||
|
||||
/**
|
||||
* URL safe symbols.
|
||||
*
|
||||
* ```js
|
||||
* import { urlAlphabet } from 'nanoid'
|
||||
* const nanoid = customAlphabet(urlAlphabet, 10)
|
||||
* nanoid() //=> "Uakgb_J5m9"
|
||||
* ```
|
||||
*/
|
||||
export const urlAlphabet: string
|
||||
|
||||
/**
|
||||
* Generate an array of random bytes collected from hardware noise.
|
||||
*
|
||||
* ```js
|
||||
* import { customRandom, random } from 'nanoid'
|
||||
* const nanoid = customRandom("abcdef", 5, random)
|
||||
* ```
|
||||
*
|
||||
* @param bytes Size of the array.
|
||||
* @returns An array of random bytes.
|
||||
*/
|
||||
export function random(bytes: number): Uint8Array
|
45
node_modules/nanoid/index.js
generated
vendored
Normal file
45
node_modules/nanoid/index.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
import crypto from 'crypto'
|
||||
import { urlAlphabet } from './url-alphabet/index.js'
|
||||
const POOL_SIZE_MULTIPLIER = 128
|
||||
let pool, poolOffset
|
||||
let fillPool = bytes => {
|
||||
if (!pool || pool.length < bytes) {
|
||||
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
|
||||
crypto.randomFillSync(pool)
|
||||
poolOffset = 0
|
||||
} else if (poolOffset + bytes > pool.length) {
|
||||
crypto.randomFillSync(pool)
|
||||
poolOffset = 0
|
||||
}
|
||||
poolOffset += bytes
|
||||
}
|
||||
let random = bytes => {
|
||||
fillPool((bytes |= 0))
|
||||
return pool.subarray(poolOffset - bytes, poolOffset)
|
||||
}
|
||||
let customRandom = (alphabet, defaultSize, getRandom) => {
|
||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
while (true) {
|
||||
let bytes = getRandom(step)
|
||||
let i = step
|
||||
while (i--) {
|
||||
id += alphabet[bytes[i] & mask] || ''
|
||||
if (id.length === size) return id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let customAlphabet = (alphabet, size = 21) =>
|
||||
customRandom(alphabet, size, random)
|
||||
let nanoid = (size = 21) => {
|
||||
fillPool((size |= 0))
|
||||
let id = ''
|
||||
for (let i = poolOffset - size; i < poolOffset; i++) {
|
||||
id += urlAlphabet[pool[i] & 63]
|
||||
}
|
||||
return id
|
||||
}
|
||||
export { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
1
node_modules/nanoid/nanoid.js
generated
vendored
Normal file
1
node_modules/nanoid/nanoid.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export let nanoid=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e<63?"_":"-"),"");
|
34
node_modules/nanoid/non-secure/index.cjs
generated
vendored
Normal file
34
node_modules/nanoid/non-secure/index.cjs
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
// This alphabet uses `A-Za-z0-9_-` symbols.
|
||||
// The order of characters is optimized for better gzip and brotli compression.
|
||||
// References to the same file (works both for gzip and brotli):
|
||||
// `'use`, `andom`, and `rict'`
|
||||
// References to the brotli default dictionary:
|
||||
// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
|
||||
let urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||
|
||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
||||
let i = size | 0
|
||||
while (i--) {
|
||||
// `| 0` is more compact and faster than `Math.floor()`.
|
||||
id += alphabet[(Math.random() * alphabet.length) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
||||
}
|
||||
|
||||
let nanoid = (size = 21) => {
|
||||
let id = ''
|
||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
||||
let i = size | 0
|
||||
while (i--) {
|
||||
// `| 0` is more compact and faster than `Math.floor()`.
|
||||
id += urlAlphabet[(Math.random() * 64) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
module.exports = { nanoid, customAlphabet }
|
33
node_modules/nanoid/non-secure/index.d.ts
generated
vendored
Normal file
33
node_modules/nanoid/non-secure/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Generate URL-friendly unique ID. This method uses the non-secure
|
||||
* predictable random generator with bigger collision probability.
|
||||
*
|
||||
* ```js
|
||||
* import { nanoid } from 'nanoid/non-secure'
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A random string.
|
||||
*/
|
||||
export function nanoid(size?: number): string
|
||||
|
||||
/**
|
||||
* Generate a unique ID based on a custom alphabet.
|
||||
* This method uses the non-secure predictable random generator
|
||||
* with bigger collision probability.
|
||||
*
|
||||
* @param alphabet Alphabet used to generate the ID.
|
||||
* @param defaultSize Size of the ID. The default size is 21.
|
||||
* @returns A random string generator.
|
||||
*
|
||||
* ```js
|
||||
* import { customAlphabet } from 'nanoid/non-secure'
|
||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
||||
* model.id = //=> "8ё56а"
|
||||
* ```
|
||||
*/
|
||||
export function customAlphabet(
|
||||
alphabet: string,
|
||||
defaultSize?: number
|
||||
): (size?: number) => string
|
21
node_modules/nanoid/non-secure/index.js
generated
vendored
Normal file
21
node_modules/nanoid/non-secure/index.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
let urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
let i = size | 0
|
||||
while (i--) {
|
||||
id += alphabet[(Math.random() * alphabet.length) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
||||
}
|
||||
let nanoid = (size = 21) => {
|
||||
let id = ''
|
||||
let i = size | 0
|
||||
while (i--) {
|
||||
id += urlAlphabet[(Math.random() * 64) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
||||
export { nanoid, customAlphabet }
|
6
node_modules/nanoid/non-secure/package.json
generated
vendored
Normal file
6
node_modules/nanoid/non-secure/package.json
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"module": "index.js",
|
||||
"react-native": "index.js"
|
||||
}
|
89
node_modules/nanoid/package.json
generated
vendored
Normal file
89
node_modules/nanoid/package.json
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"name": "nanoid",
|
||||
"version": "3.3.11",
|
||||
"description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
|
||||
"keywords": [
|
||||
"uuid",
|
||||
"random",
|
||||
"id",
|
||||
"url"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"author": "Andrey Sitnik <andrey@sitnik.ru>",
|
||||
"license": "MIT",
|
||||
"repository": "ai/nanoid",
|
||||
"browser": {
|
||||
"./index.js": "./index.browser.js",
|
||||
"./async/index.js": "./async/index.browser.js",
|
||||
"./async/index.cjs": "./async/index.browser.cjs",
|
||||
"./index.cjs": "./index.browser.cjs"
|
||||
},
|
||||
"react-native": "index.js",
|
||||
"bin": "./bin/nanoid.cjs",
|
||||
"sideEffects": false,
|
||||
"types": "./index.d.ts",
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"module": "index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"react-native": "./index.browser.js",
|
||||
"browser": "./index.browser.js",
|
||||
"require": {
|
||||
"types": "./index.d.cts",
|
||||
"default": "./index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
"./async/package.json": "./async/package.json",
|
||||
"./async": {
|
||||
"browser": "./async/index.browser.js",
|
||||
"require": {
|
||||
"types": "./index.d.cts",
|
||||
"default": "./async/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./async/index.js"
|
||||
},
|
||||
"default": "./async/index.js"
|
||||
},
|
||||
"./non-secure/package.json": "./non-secure/package.json",
|
||||
"./non-secure": {
|
||||
"require": {
|
||||
"types": "./index.d.cts",
|
||||
"default": "./non-secure/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./non-secure/index.js"
|
||||
},
|
||||
"default": "./non-secure/index.js"
|
||||
},
|
||||
"./url-alphabet/package.json": "./url-alphabet/package.json",
|
||||
"./url-alphabet": {
|
||||
"require": {
|
||||
"types": "./index.d.cts",
|
||||
"default": "./url-alphabet/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./url-alphabet/index.js"
|
||||
},
|
||||
"default": "./url-alphabet/index.js"
|
||||
}
|
||||
}
|
||||
}
|
7
node_modules/nanoid/url-alphabet/index.cjs
generated
vendored
Normal file
7
node_modules/nanoid/url-alphabet/index.cjs
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
// This alphabet uses `A-Za-z0-9_-` symbols.
|
||||
// The order of characters is optimized for better gzip and brotli compression.
|
||||
// Same as in non-secure/index.js
|
||||
let urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||
|
||||
module.exports = { urlAlphabet }
|
3
node_modules/nanoid/url-alphabet/index.js
generated
vendored
Normal file
3
node_modules/nanoid/url-alphabet/index.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
let urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||
export { urlAlphabet }
|
6
node_modules/nanoid/url-alphabet/package.json
generated
vendored
Normal file
6
node_modules/nanoid/url-alphabet/package.json
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"module": "index.js",
|
||||
"react-native": "index.js"
|
||||
}
|
15
node_modules/picocolors/LICENSE
generated
vendored
Normal file
15
node_modules/picocolors/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
ISC License
|
||||
|
||||
Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
21
node_modules/picocolors/README.md
generated
vendored
Normal file
21
node_modules/picocolors/README.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# picocolors
|
||||
|
||||
The tiniest and the fastest library for terminal output formatting with ANSI colors.
|
||||
|
||||
```javascript
|
||||
import pc from "picocolors"
|
||||
|
||||
console.log(
|
||||
pc.green(`How are ${pc.italic(`you`)} doing?`)
|
||||
)
|
||||
```
|
||||
|
||||
- **No dependencies.**
|
||||
- **14 times** smaller and **2 times** faster than chalk.
|
||||
- Used by popular tools like PostCSS, SVGO, Stylelint, and Browserslist.
|
||||
- Node.js v6+ & browsers support. Support for both CJS and ESM projects.
|
||||
- TypeScript type declarations included.
|
||||
- [`NO_COLOR`](https://no-color.org/) friendly.
|
||||
|
||||
## Docs
|
||||
Read **[full docs](https://github.com/alexeyraspopov/picocolors#readme)** on GitHub.
|
25
node_modules/picocolors/package.json
generated
vendored
Normal file
25
node_modules/picocolors/package.json
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "picocolors",
|
||||
"version": "1.1.1",
|
||||
"main": "./picocolors.js",
|
||||
"types": "./picocolors.d.ts",
|
||||
"browser": {
|
||||
"./picocolors.js": "./picocolors.browser.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"description": "The tiniest and the fastest library for terminal output formatting with ANSI colors",
|
||||
"files": [
|
||||
"picocolors.*",
|
||||
"types.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"terminal",
|
||||
"colors",
|
||||
"formatting",
|
||||
"cli",
|
||||
"console"
|
||||
],
|
||||
"author": "Alexey Raspopov",
|
||||
"repository": "alexeyraspopov/picocolors",
|
||||
"license": "ISC"
|
||||
}
|
4
node_modules/picocolors/picocolors.browser.js
generated
vendored
Normal file
4
node_modules/picocolors/picocolors.browser.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
var x=String;
|
||||
var create=function() {return {isColorSupported:false,reset:x,bold:x,dim:x,italic:x,underline:x,inverse:x,hidden:x,strikethrough:x,black:x,red:x,green:x,yellow:x,blue:x,magenta:x,cyan:x,white:x,gray:x,bgBlack:x,bgRed:x,bgGreen:x,bgYellow:x,bgBlue:x,bgMagenta:x,bgCyan:x,bgWhite:x,blackBright:x,redBright:x,greenBright:x,yellowBright:x,blueBright:x,magentaBright:x,cyanBright:x,whiteBright:x,bgBlackBright:x,bgRedBright:x,bgGreenBright:x,bgYellowBright:x,bgBlueBright:x,bgMagentaBright:x,bgCyanBright:x,bgWhiteBright:x}};
|
||||
module.exports=create();
|
||||
module.exports.createColors = create;
|
5
node_modules/picocolors/picocolors.d.ts
generated
vendored
Normal file
5
node_modules/picocolors/picocolors.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { Colors } from "./types"
|
||||
|
||||
declare const picocolors: Colors & { createColors: (enabled?: boolean) => Colors }
|
||||
|
||||
export = picocolors
|
75
node_modules/picocolors/picocolors.js
generated
vendored
Normal file
75
node_modules/picocolors/picocolors.js
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
let p = process || {}, argv = p.argv || [], env = p.env || {}
|
||||
let isColorSupported =
|
||||
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
||||
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI)
|
||||
|
||||
let formatter = (open, close, replace = open) =>
|
||||
input => {
|
||||
let string = "" + input, index = string.indexOf(close, open.length)
|
||||
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
||||
}
|
||||
|
||||
let replaceClose = (string, close, replace, index) => {
|
||||
let result = "", cursor = 0
|
||||
do {
|
||||
result += string.substring(cursor, index) + replace
|
||||
cursor = index + close.length
|
||||
index = string.indexOf(close, cursor)
|
||||
} while (~index)
|
||||
return result + string.substring(cursor)
|
||||
}
|
||||
|
||||
let createColors = (enabled = isColorSupported) => {
|
||||
let f = enabled ? formatter : () => String
|
||||
return {
|
||||
isColorSupported: enabled,
|
||||
reset: f("\x1b[0m", "\x1b[0m"),
|
||||
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
||||
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
||||
italic: f("\x1b[3m", "\x1b[23m"),
|
||||
underline: f("\x1b[4m", "\x1b[24m"),
|
||||
inverse: f("\x1b[7m", "\x1b[27m"),
|
||||
hidden: f("\x1b[8m", "\x1b[28m"),
|
||||
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
||||
|
||||
black: f("\x1b[30m", "\x1b[39m"),
|
||||
red: f("\x1b[31m", "\x1b[39m"),
|
||||
green: f("\x1b[32m", "\x1b[39m"),
|
||||
yellow: f("\x1b[33m", "\x1b[39m"),
|
||||
blue: f("\x1b[34m", "\x1b[39m"),
|
||||
magenta: f("\x1b[35m", "\x1b[39m"),
|
||||
cyan: f("\x1b[36m", "\x1b[39m"),
|
||||
white: f("\x1b[37m", "\x1b[39m"),
|
||||
gray: f("\x1b[90m", "\x1b[39m"),
|
||||
|
||||
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
||||
bgRed: f("\x1b[41m", "\x1b[49m"),
|
||||
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
||||
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
||||
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
||||
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
||||
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
||||
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
||||
|
||||
blackBright: f("\x1b[90m", "\x1b[39m"),
|
||||
redBright: f("\x1b[91m", "\x1b[39m"),
|
||||
greenBright: f("\x1b[92m", "\x1b[39m"),
|
||||
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
||||
blueBright: f("\x1b[94m", "\x1b[39m"),
|
||||
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
||||
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
||||
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
||||
|
||||
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
||||
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
||||
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
||||
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
||||
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
||||
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
||||
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
||||
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = createColors()
|
||||
module.exports.createColors = createColors
|
51
node_modules/picocolors/types.d.ts
generated
vendored
Normal file
51
node_modules/picocolors/types.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
export type Formatter = (input: string | number | null | undefined) => string
|
||||
|
||||
export interface Colors {
|
||||
isColorSupported: boolean
|
||||
|
||||
reset: Formatter
|
||||
bold: Formatter
|
||||
dim: Formatter
|
||||
italic: Formatter
|
||||
underline: Formatter
|
||||
inverse: Formatter
|
||||
hidden: Formatter
|
||||
strikethrough: Formatter
|
||||
|
||||
black: Formatter
|
||||
red: Formatter
|
||||
green: Formatter
|
||||
yellow: Formatter
|
||||
blue: Formatter
|
||||
magenta: Formatter
|
||||
cyan: Formatter
|
||||
white: Formatter
|
||||
gray: Formatter
|
||||
|
||||
bgBlack: Formatter
|
||||
bgRed: Formatter
|
||||
bgGreen: Formatter
|
||||
bgYellow: Formatter
|
||||
bgBlue: Formatter
|
||||
bgMagenta: Formatter
|
||||
bgCyan: Formatter
|
||||
bgWhite: Formatter
|
||||
|
||||
blackBright: Formatter
|
||||
redBright: Formatter
|
||||
greenBright: Formatter
|
||||
yellowBright: Formatter
|
||||
blueBright: Formatter
|
||||
magentaBright: Formatter
|
||||
cyanBright: Formatter
|
||||
whiteBright: Formatter
|
||||
|
||||
bgBlackBright: Formatter
|
||||
bgRedBright: Formatter
|
||||
bgGreenBright: Formatter
|
||||
bgYellowBright: Formatter
|
||||
bgBlueBright: Formatter
|
||||
bgMagentaBright: Formatter
|
||||
bgCyanBright: Formatter
|
||||
bgWhiteBright: Formatter
|
||||
}
|
20
node_modules/postcss/LICENSE
generated
vendored
Normal file
20
node_modules/postcss/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright 2013 Andrey Sitnik <andrey@sitnik.ru>
|
||||
|
||||
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.
|
29
node_modules/postcss/README.md
generated
vendored
Normal file
29
node_modules/postcss/README.md
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
# PostCSS
|
||||
|
||||
<img align="right" width="95" height="95"
|
||||
alt="Philosopher’s stone, logo of PostCSS"
|
||||
src="https://postcss.org/logo.svg">
|
||||
|
||||
PostCSS is a tool for transforming styles with JS plugins.
|
||||
These plugins can lint your CSS, support variables and mixins,
|
||||
transpile future CSS syntax, inline images, and more.
|
||||
|
||||
PostCSS is used by industry leaders including Wikipedia, Twitter, Alibaba,
|
||||
and JetBrains. The [Autoprefixer] and [Stylelint] PostCSS plugins are some of the most popular CSS tools.
|
||||
|
||||
---
|
||||
|
||||
<img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" /> Built by
|
||||
<b><a href="https://evilmartians.com/devtools?utm_source=postcss&utm_campaign=devtools-button&utm_medium=github">Evil Martians</a></b>, go-to agency for <b>developer tools</b>.
|
||||
|
||||
---
|
||||
|
||||
[Abstract Syntax Tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
|
||||
[Evil Martians]: https://evilmartians.com/?utm_source=postcss
|
||||
[Autoprefixer]: https://github.com/postcss/autoprefixer
|
||||
[Stylelint]: https://stylelint.io/
|
||||
[plugins]: https://github.com/postcss/postcss#plugins
|
||||
|
||||
|
||||
## Docs
|
||||
Read full docs **[here](https://postcss.org/)**.
|
140
node_modules/postcss/lib/at-rule.d.ts
generated
vendored
Normal file
140
node_modules/postcss/lib/at-rule.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,140 @@
|
|||
import Container, {
|
||||
ContainerProps,
|
||||
ContainerWithChildren
|
||||
} from './container.js'
|
||||
|
||||
declare namespace AtRule {
|
||||
export interface AtRuleRaws extends Record<string, unknown> {
|
||||
/**
|
||||
* The space symbols after the last child of the node to the end of the node.
|
||||
*/
|
||||
after?: string
|
||||
|
||||
/**
|
||||
* The space between the at-rule name and its parameters.
|
||||
*/
|
||||
afterName?: string
|
||||
|
||||
/**
|
||||
* The space symbols before the node. It also stores `*`
|
||||
* and `_` symbols before the declaration (IE hack).
|
||||
*/
|
||||
before?: string
|
||||
|
||||
/**
|
||||
* The symbols between the last parameter and `{` for rules.
|
||||
*/
|
||||
between?: string
|
||||
|
||||
/**
|
||||
* The rule’s selector with comments.
|
||||
*/
|
||||
params?: {
|
||||
raw: string
|
||||
value: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains `true` if the last child has an (optional) semicolon.
|
||||
*/
|
||||
semicolon?: boolean
|
||||
}
|
||||
|
||||
export interface AtRuleProps extends ContainerProps {
|
||||
/** Name of the at-rule. */
|
||||
name: string
|
||||
/** Parameters following the name of the at-rule. */
|
||||
params?: number | string
|
||||
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
||||
raws?: AtRuleRaws
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
export { AtRule_ as default }
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an at-rule.
|
||||
*
|
||||
* ```js
|
||||
* Once (root, { AtRule }) {
|
||||
* let media = new AtRule({ name: 'media', params: 'print' })
|
||||
* media.append(…)
|
||||
* root.append(media)
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* If it’s followed in the CSS by a `{}` block, this node will have
|
||||
* a nodes property representing its children.
|
||||
*
|
||||
* ```js
|
||||
* const root = postcss.parse('@charset "UTF-8"; @media print {}')
|
||||
*
|
||||
* const charset = root.first
|
||||
* charset.type //=> 'atrule'
|
||||
* charset.nodes //=> undefined
|
||||
*
|
||||
* const media = root.last
|
||||
* media.nodes //=> []
|
||||
* ```
|
||||
*/
|
||||
declare class AtRule_ extends Container {
|
||||
/**
|
||||
* An array containing the layer’s children.
|
||||
*
|
||||
* ```js
|
||||
* const root = postcss.parse('@layer example { a { color: black } }')
|
||||
* const layer = root.first
|
||||
* layer.nodes.length //=> 1
|
||||
* layer.nodes[0].selector //=> 'a'
|
||||
* ```
|
||||
*
|
||||
* Can be `undefinded` if the at-rule has no body.
|
||||
*
|
||||
* ```js
|
||||
* const root = postcss.parse('@layer a, b, c;')
|
||||
* const layer = root.first
|
||||
* layer.nodes //=> undefined
|
||||
* ```
|
||||
*/
|
||||
nodes: Container['nodes'] | undefined
|
||||
parent: ContainerWithChildren | undefined
|
||||
|
||||
raws: AtRule.AtRuleRaws
|
||||
type: 'atrule'
|
||||
/**
|
||||
* The at-rule’s name immediately follows the `@`.
|
||||
*
|
||||
* ```js
|
||||
* const root = postcss.parse('@media print {}')
|
||||
* const media = root.first
|
||||
* media.name //=> 'media'
|
||||
* ```
|
||||
*/
|
||||
get name(): string
|
||||
set name(value: string)
|
||||
|
||||
/**
|
||||
* The at-rule’s parameters, the values that follow the at-rule’s name
|
||||
* but precede any `{}` block.
|
||||
*
|
||||
* ```js
|
||||
* const root = postcss.parse('@media print, screen {}')
|
||||
* const media = root.first
|
||||
* media.params //=> 'print, screen'
|
||||
* ```
|
||||
*/
|
||||
get params(): string
|
||||
|
||||
set params(value: string)
|
||||
|
||||
constructor(defaults?: AtRule.AtRuleProps)
|
||||
assign(overrides: AtRule.AtRuleProps | object): this
|
||||
clone(overrides?: Partial<AtRule.AtRuleProps>): this
|
||||
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this
|
||||
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this
|
||||
}
|
||||
|
||||
declare class AtRule extends AtRule_ {}
|
||||
|
||||
export = AtRule
|
25
node_modules/postcss/lib/at-rule.js
generated
vendored
Normal file
25
node_modules/postcss/lib/at-rule.js
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
'use strict'
|
||||
|
||||
let Container = require('./container')
|
||||
|
||||
class AtRule extends Container {
|
||||
constructor(defaults) {
|
||||
super(defaults)
|
||||
this.type = 'atrule'
|
||||
}
|
||||
|
||||
append(...children) {
|
||||
if (!this.proxyOf.nodes) this.nodes = []
|
||||
return super.append(...children)
|
||||
}
|
||||
|
||||
prepend(...children) {
|
||||
if (!this.proxyOf.nodes) this.nodes = []
|
||||
return super.prepend(...children)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AtRule
|
||||
AtRule.default = AtRule
|
||||
|
||||
Container.registerAtRule(AtRule)
|
68
node_modules/postcss/lib/comment.d.ts
generated
vendored
Normal file
68
node_modules/postcss/lib/comment.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
import Container from './container.js'
|
||||
import Node, { NodeProps } from './node.js'
|
||||
|
||||
declare namespace Comment {
|
||||
export interface CommentRaws extends Record<string, unknown> {
|
||||
/**
|
||||
* The space symbols before the node.
|
||||
*/
|
||||
before?: string
|
||||
|
||||
/**
|
||||
* The space symbols between `/*` and the comment’s text.
|
||||
*/
|
||||
left?: string
|
||||
|
||||
/**
|
||||
* The space symbols between the comment’s text.
|
||||
*/
|
||||
right?: string
|
||||
}
|
||||
|
||||
export interface CommentProps extends NodeProps {
|
||||
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
||||
raws?: CommentRaws
|
||||
/** Content of the comment. */
|
||||
text: string
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
export { Comment_ as default }
|
||||
}
|
||||
|
||||
/**
|
||||
* It represents a class that handles
|
||||
* [CSS comments](https://developer.mozilla.org/en-US/docs/Web/CSS/Comments)
|
||||
*
|
||||
* ```js
|
||||
* Once (root, { Comment }) {
|
||||
* const note = new Comment({ text: 'Note: …' })
|
||||
* root.append(note)
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Remember that CSS comments inside selectors, at-rule parameters,
|
||||
* or declaration values will be stored in the `raws` properties
|
||||
* explained above.
|
||||
*/
|
||||
declare class Comment_ extends Node {
|
||||
parent: Container | undefined
|
||||
raws: Comment.CommentRaws
|
||||
type: 'comment'
|
||||
/**
|
||||
* The comment's text.
|
||||
*/
|
||||
get text(): string
|
||||
|
||||
set text(value: string)
|
||||
|
||||
constructor(defaults?: Comment.CommentProps)
|
||||
assign(overrides: Comment.CommentProps | object): this
|
||||
clone(overrides?: Partial<Comment.CommentProps>): this
|
||||
cloneAfter(overrides?: Partial<Comment.CommentProps>): this
|
||||
cloneBefore(overrides?: Partial<Comment.CommentProps>): this
|
||||
}
|
||||
|
||||
declare class Comment extends Comment_ {}
|
||||
|
||||
export = Comment
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue